当前位置: 首页>>代码示例>>C++>>正文


C++ Local::Has方法代码示例

本文整理汇总了C++中Local::Has方法的典型用法代码示例。如果您正苦于以下问题:C++ Local::Has方法的具体用法?C++ Local::Has怎么用?C++ Local::Has使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Local的用法示例。


在下文中一共展示了Local::Has方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ShowToast

void ShowToast(const FunctionCallbackInfo<Value>& args)
{
    Isolate* isolate = Isolate::GetCurrent();
    HandleScope scope(isolate);

    if (args.Length() < 2){
        isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "show() requires an object and function argument")));
        return;
    }

    Local<Object> o = args[0].As<Object>();

    WCHAR* title = NULL;
    WCHAR* msg = NULL;
    char* img = NULL;

    Local<String> titleKey = String::NewFromUtf8(isolate, "title");
    Local<String> msgKey = String::NewFromUtf8(isolate, "subtitle");
    Local<String> imgKey = String::NewFromUtf8(isolate, "imageUri");

    if (o->Has(titleKey)){
        String::Utf8Value v (o->Get(titleKey)->ToString());
        size_t len = strlen(*v) + 1;
        title = new WCHAR[len];
        swprintf(title, len, L"%S", *v);
    }

    if (o->Has(msgKey)){
        String::Utf8Value v(o->Get(msgKey)->ToString());
        size_t len = strlen(*v) + 1;
        msg = new WCHAR[len];
        swprintf(msg, len, L"%S", *v);
    }

    if (o->Has(imgKey)){
        String::Utf8Value v(o->Get(imgKey)->ToString());
        size_t len = strlen(*v) + 1;
        img = new char[len];
        sprintf(img, "%s", *v);
    }

    if (title == NULL && msg == NULL){
        return;
    }

    Local<Function> cbFn = args[1].As<Function>();

    WindowsToastNotification* wtn = new WindowsToastNotification();
    wtn->ShowNotification(title, msg, img, cbFn);
    DELETE_IF(title);
    DELETE_IF(msg);
    DELETE_IF(img);
}
开发者ID:republicwireless-open,项目名称:native-notification,代码行数:53,代码来源:notification_win.cpp

示例2: locker

JSONValue JSONValue::operator[](int index)
{
	Locker locker(isolate);
	Isolate::Scope isolateScope(isolate);
	HandleScope handleScope;
	
	// Check if value is an array
	
	if (!value->IsArray())
		throw bit::Exception("JSONValue is not an array");
	
	Local<Value> valueLocal = Local<Value>::New(value);
	Local<Array> valueArray = Local<Array>::Cast(valueLocal);
	
	if (valueArray.IsEmpty())
		throw bit::Exception("V8 array could not be created");
	
	// Check if index exists
	
	if (!valueArray->Has(index))
		throw bit::Exception("Index does not exist");
	
	// Return JSONValue
	
	Local<Value> newValue = valueArray->Get(index);
	JSONValue jsonValue(newValue, isolate);
	
	return jsonValue;
}
开发者ID:bagobor,项目名称:BitRPG,代码行数:29,代码来源:JSONValue.cpp

示例3: ThrowException

Handle<Value> ImageView::encode(const Arguments& args)
{
    HandleScope scope;

    ImageView* im = ObjectWrap::Unwrap<ImageView>(args.This());

    std::string format = "png";
    palette_ptr palette;

    // accept custom format
    if (args.Length() > 1){
        if (!args[0]->IsString())
          return ThrowException(Exception::TypeError(
            String::New("first arg, 'format' must be a string")));
        format = TOSTR(args[0]);
    }

    // options hash
    if (args.Length() >= 2) {
        if (!args[1]->IsObject())
          return ThrowException(Exception::TypeError(
            String::New("optional second arg must be an options object")));

        Local<Object> options = args[1]->ToObject();

        if (options->Has(String::New("palette")))
        {
            Local<Value> format_opt = options->Get(String::New("palette"));
            if (!format_opt->IsObject())
              return ThrowException(Exception::TypeError(
                String::New("'palette' must be an object")));
            
            Local<Object> obj = format_opt->ToObject();
            if (obj->IsNull() || obj->IsUndefined() || !Palette::constructor->HasInstance(obj))
              return ThrowException(Exception::TypeError(String::New("mapnik.Palette expected as second arg")));
    
            palette = ObjectWrap::Unwrap<Palette>(obj)->palette();
        }
    }

    // ensure callback is a function
    Local<Value> callback = args[args.Length()-1];
    if (!args[args.Length()-1]->IsFunction())
        return ThrowException(Exception::TypeError(
                  String::New("last argument must be a callback function")));

    encode_image_baton_t *closure = new encode_image_baton_t();
    closure->request.data = closure;
    closure->im = im;
    closure->image = im->this_;
    closure->format = format;
    closure->palette = palette;
    closure->error = false;
    closure->cb = Persistent<Function>::New(Handle<Function>::Cast(callback));
    uv_queue_work(uv_default_loop(), &closure->request, EIO_Encode, EIO_AfterEncode);
    //uv_ref(uv_default_loop());
    im->Ref();

    return Undefined();
}
开发者ID:yhahn,项目名称:node-mapnik,代码行数:60,代码来源:mapnik_image_view.cpp

示例4: NAN_METHOD

static inline NAN_METHOD(register_fonts)
{
    NanScope();

    try
    {
        if (args.Length() == 0 || !args[0]->IsString())
        {
            NanThrowTypeError("first argument must be a path to a directory of fonts");
            NanReturnUndefined();
        }

        bool found = false;

        std::vector<std::string> const names_before = mapnik::freetype_engine::face_names();

        // option hash
        if (args.Length() == 2){
            if (!args[1]->IsObject())
            {
                NanThrowTypeError("second argument is optional, but if provided must be an object, eg. { recurse:Boolean }");
                NanReturnUndefined();
            }

            Local<Object> options = args[1].As<Object>();
            if (options->Has(NanNew("recurse")))
            {
                Local<Value> recurse_opt = options->Get(NanNew("recurse"));
                if (!recurse_opt->IsBoolean())
                {
                    NanThrowTypeError("'recurse' must be a Boolean");
                    NanReturnUndefined();
                }

                bool recurse = recurse_opt->BooleanValue();
                std::string path = TOSTR(args[0]);
                found = mapnik::freetype_engine::register_fonts(path,recurse);
            }
        }
        else
        {
            std::string path = TOSTR(args[0]);
            found = mapnik::freetype_engine::register_fonts(path);
        }

        std::vector<std::string> const& names_after = mapnik::freetype_engine::face_names();
        if (names_after.size() == names_before.size())
            found = false;

        NanReturnValue(NanNew(found));
    }
    catch (std::exception const& ex)
    {
        NanThrowError(ex.what());
        NanReturnUndefined();
    }
}
开发者ID:ReclaimSoftware,项目名称:rs-upstream,代码行数:57,代码来源:mapnik_fonts.hpp

示例5: HtmlStripFunc

void HtmlStripFunc(const FunctionCallbackInfo<Value>& args) {
  Isolate* isolate = args.GetIsolate();
  HandleScope scope(isolate);

  uint16_t* inBuf = NULL;
  size_t inBufSize = 0;
  if (args.Length() >= 2) {
    inBuf = static_cast<uint16_t*>(  // NULL on flush.
        args[0].As<Object>()->GetIndexedPropertiesExternalArrayData());
    inBufSize = args[1]->Uint32Value();
  }

  HtmlStripOptions opts;
  // Check if we have any options passed
  if(args.Length() >= 3 && !args[2].IsEmpty() && args[2]->IsObject()){
    Local<Object> optsObj = args[2]->ToObject();
    if(!optsObj.IsEmpty()){

      if(optsObj->Has(PERSISTENT(include_script_sym))){
        opts.include_script = optsObj->Get(PERSISTENT(include_script_sym))->ToBoolean()->Value();
      }

      if(optsObj->Has(PERSISTENT(include_style_sym))){
        opts.include_style = optsObj->Get(PERSISTENT(include_style_sym))->ToBoolean()->Value();
      }

      if(optsObj->Has(PERSISTENT(compact_whitespace_sym))){
        opts.compact_whitespace = optsObj->Get(PERSISTENT(compact_whitespace_sym))->ToBoolean()->Value();
      }

      if(optsObj->Has(PERSISTENT(include_attributes_sym))){
        opts.include_attributes = true;
        opts.includeAttributesMap = optsObj->Get(PERSISTENT(include_attributes_sym))->ToObject();
        Local< String > allAttr = String::NewFromUtf8(isolate, "*");
        opts.include_all_attributes = opts.includeAttributesMap->Has(allAttr);
      }
    }
  }

  args.GetReturnValue().Set( HtmlStrip(inBuf, inBufSize, opts, isolate) );
}
开发者ID:davidgljay,项目名称:climatescrape,代码行数:41,代码来源:htmlstrip_module_new.cpp

示例6: Initialize

void Initialize(const FunctionCallbackInfo<Value>& args)
{
    Isolate* isolate = Isolate::GetCurrent();
    HandleScope scope(isolate);

    if (args.Length() < 1){
        isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "init() requires an object")));
        return;
    }

    Local<Object> o = args[0].As<Object>();

    char* appName = NULL;
    char* tempDirPath = NULL;

    Local<String> appKey = String::NewFromUtf8(isolate, "appName");
    Local<String> tempDirKey = String::NewFromUtf8(isolate, "tempDir");

    if (o->Has(appKey)){
        String::Utf8Value v(o->Get(appKey)->ToString());
        size_t len = strlen(*v) + 1;
        appName = new char[len];
        sprintf(appName, "%s", *v);
    }

    if (o->Has(tempDirKey)){
        String::Utf8Value v(o->Get(tempDirKey)->ToString());
        size_t len = strlen(*v) + 1;
        tempDirPath = new char[len];
        sprintf(tempDirPath, "%s", *v);
    }

    if (appName == NULL || tempDirPath == NULL){
        isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "init() requires 'appName' and 'tempDir'")));
        return;
    }

    WindowsToastNotification::InitSystemProps(appName, tempDirPath);
    DELETE_IF(appName);
    DELETE_IF(tempDirPath);
}
开发者ID:republicwireless-open,项目名称:native-notification,代码行数:41,代码来源:notification_win.cpp

示例7: if

Handle<Value> ODBCResult::FetchAll(const Arguments& args) {
  DEBUG_PRINTF("ODBCResult::FetchAll\n");
  
  HandleScope scope;
  
  ODBCResult* objODBCResult = ObjectWrap::Unwrap<ODBCResult>(args.Holder());
  
  uv_work_t* work_req = (uv_work_t *) (calloc(1, sizeof(uv_work_t)));
  
  fetch_work_data* data = (fetch_work_data *) calloc(1, sizeof(fetch_work_data));
  
  Local<Function> cb;
  
  data->fetchMode = objODBCResult->m_fetchMode;
  
  if (args.Length() == 1 && args[0]->IsFunction()) {
    cb = Local<Function>::Cast(args[0]);
  }
  else if (args.Length() == 2 && args[0]->IsObject() && args[1]->IsFunction()) {
    cb = Local<Function>::Cast(args[1]);  
    
    Local<Object> obj = args[0]->ToObject();
    
    if (obj->Has(OPTION_FETCH_MODE) && obj->Get(OPTION_FETCH_MODE)->IsInt32()) {
      data->fetchMode = obj->Get(OPTION_FETCH_MODE)->ToInt32()->Value();
    }
  }
  else {
    return ThrowException(Exception::TypeError(
      String::New("ODBCResult::FetchAll(): 1 or 2 arguments are required. The last argument must be a callback function.")
    ));
  }
  
  data->rows = Persistent<Array>::New(Array::New());
  data->errorCount = 0;
  data->count = 0;
  data->objError = Persistent<Object>::New(Object::New());
  
  data->cb = Persistent<Function>::New(cb);
  data->objResult = objODBCResult;
  
  work_req->data = data;
  
  uv_queue_work(uv_default_loop(),
    work_req, 
    UV_FetchAll, 
    (uv_after_work_cb)UV_AfterFetchAll);

  data->objResult->Ref();

  return scope.Close(Undefined());
}
开发者ID:hcsoft,项目名称:nodewebhis,代码行数:52,代码来源:odbc_result.cpp

示例8: ThrowException

static inline Handle<Value> register_fonts(const Arguments& args)
{
    HandleScope scope;

    try
    {
        if (!args.Length() >= 1 || !args[0]->IsString())
            return ThrowException(Exception::TypeError(
                                      String::New("first argument must be a path to a directory of fonts")));

        bool found = false;

        std::vector<std::string> const names_before = mapnik::freetype_engine::face_names();

        // option hash
        if (args.Length() == 2){
            if (!args[1]->IsObject())
                return ThrowException(Exception::TypeError(
                                          String::New("second argument is optional, but if provided must be an object, eg. { recurse:Boolean }")));

            Local<Object> options = args[1]->ToObject();
            if (options->Has(String::New("recurse")))
            {
                Local<Value> recurse_opt = options->Get(String::New("recurse"));
                if (!recurse_opt->IsBoolean())
                    return ThrowException(Exception::TypeError(
                                              String::New("'recurse' must be a Boolean")));

                bool recurse = recurse_opt->BooleanValue();
                std::string path = TOSTR(args[0]);
                found = mapnik::freetype_engine::register_fonts(path,recurse);
            }
        }
        else
        {
            std::string path = TOSTR(args[0]);
            found = mapnik::freetype_engine::register_fonts(path);
        }

        std::vector<std::string> const& names_after = mapnik::freetype_engine::face_names();
        if (names_after.size() == names_before.size())
            found = false;

        return scope.Close(Boolean::New(found));
    }
    catch (std::exception const& ex)
    {
        return ThrowException(Exception::Error(
                                  String::New(ex.what())));
    }
}
开发者ID:leandroleal,项目名称:node-mapnik,代码行数:51,代码来源:mapnik_fonts.hpp

示例9: object

  void V8BuilderPolicy::AppendToDictKeyList(std::string const & _key,
          type const & var)
  {
    Nan::HandleScope scope;
    Local<Value> object(Nan::New(object_));
    assert(object->IsObject());
    Local<Object> obj = Local<Object>::Cast(object);

    KeyMap::const_iterator k_it = keys_.find(_key);
    if (k_it == keys_.end())
    {
      Nan::Persistent<v8::String> * pers_key =
              new Nan::Persistent<v8::String>(Nan::New(_key).ToLocalChecked());
      keys_[_key] = pers_key;
      k_it = keys_.find(_key);
    }
    Local<String> key = Nan::New(*k_it->second);
//    Local<String> key = Nan::New(_key).ToLocalChecked();

    if (obj->Has(key))
    {
      Local<Value> value = obj->Get(key);
      if (value->IsArray())
      {
        Local<Array> arr = Local<Array>::Cast(value);
        arr->Set(arr->Length(), Nan::New(var));
      }
      else
      {
        Local<Array> arr(Nan::New<Array>());
        arr->Set(0, value);
        arr->Set(1, Nan::New(var));
        obj->Set(key, arr);
      }
    }
    else
    {
      if (options_.explicit_array_)
      {
        Local<Array> arr(Nan::New<Array>());
        arr->Set(0, Nan::New(var));
        obj->Set(key, arr);
      }
      else
      {
        obj->Set(key, Nan::New(var));
      }
    }
  }
开发者ID:eye3,项目名称:nkit4nodejs,代码行数:49,代码来源:v8_var_policy.cpp

示例10: has

bool JSONValue::has(const std::string &key)
{
	Locker locker(isolate);
	Isolate::Scope isolateScope(isolate);
	HandleScope handleScope;
	
	// Check if value is an object
	
	if (!value->IsObject())
		throw bit::Exception("JSONValue is not an object");
	
	Local<Value> valueLocal = Local<Value>::New(value);
	Local<Object> valueObject = Local<Object>::Cast(valueLocal);
	Local<String> keyString = String::New(key.c_str());
	
	// Check if key exists
	
	return valueObject->Has(keyString);
}
开发者ID:bagobor,项目名称:BitRPG,代码行数:19,代码来源:JSONValue.cpp

示例11: PassArray

void PassArray(const FunctionCallbackInfo<Value>& args) {
    Isolate * isolate = args.GetIsolate();
    Local<Array> array = Local<Array>::Cast(args[0]);

    if ( args.Length() < 1 || ! args[0]->IsArray()) {
        return;
    }

    if (array->Length() < 3) {
        return;
    }

    Local<String> prop = String::NewFromUtf8(isolate, "not_index");
    if (array->Get(prop)->IsUndefined() ){
        return;
    }

    for (unsigned int i = 0; i < 3; i++ ) {
      if (array->Has(i)) {
        Local<Value> v = array->Get(i);
        if ( !v->IsNumber()) return;

        double value = v->NumberValue();
        array->Set(i, Number::New(isolate, value + 1));
      }
      else {
        return;
      }
    }

    Local<Array> a = Array::New(isolate);
    a->Set(0, array->Get(0));
    a->Set(1, array->Get(prop));
    a->Set(2, array->Get(2));

    args.GetReturnValue().Set(a);
}
开发者ID:freezer333,项目名称:nodecpp-demo,代码行数:37,代码来源:strict_type_demo.cpp

示例12: while

Handle<Value> ODBCResult::FetchAllSync(const Arguments& args) {
  DEBUG_PRINTF("ODBCResult::FetchAllSync\n");

  HandleScope scope;
  
  ODBCResult* self = ObjectWrap::Unwrap<ODBCResult>(args.Holder());
  
  Local<Object> objError = Object::New();
  
  SQLRETURN ret;
  int count = 0;
  int errorCount = 0;
  int fetchMode = self->m_fetchMode;

  if (args.Length() == 1 && args[0]->IsObject()) {
    Local<Object> obj = args[0]->ToObject();
    
    if (obj->Has(OPTION_FETCH_MODE) && obj->Get(OPTION_FETCH_MODE)->IsInt32()) {
      fetchMode = obj->Get(OPTION_FETCH_MODE)->ToInt32()->Value();
    }
  }
  
  if (self->colCount == 0) {
    self->columns = ODBC::GetColumns(self->m_hSTMT, &self->colCount);
  }
  
  Local<Array> rows = Array::New();
  
  //Only loop through the recordset if there are columns
  if (self->colCount > 0) {
    //loop through all records
    while (true) {
      ret = SQLFetch(self->m_hSTMT);
      
      //check to see if there was an error
      if (ret == SQL_ERROR)  {
        errorCount++;
        
        objError = ODBC::GetSQLError(
          SQL_HANDLE_STMT, 
          self->m_hSTMT,
          (char *) "[node-odbc] Error in ODBCResult::UV_AfterFetchAll; probably"
            " your query did not have a result set."
        );
        
        break;
      }
      
      //check to see if we are at the end of the recordset
      if (ret == SQL_NO_DATA) {
        ODBC::FreeColumns(self->columns, &self->colCount);
        
        break;
      }

      if (fetchMode == FETCH_ARRAY) {
        rows->Set(
          Integer::New(count), 
          ODBC::GetRecordArray(
            self->m_hSTMT,
            self->columns,
            &self->colCount,
            self->buffer,
            self->bufferLength)
        );
      }
      else {
        rows->Set(
          Integer::New(count), 
          ODBC::GetRecordTuple(
            self->m_hSTMT,
            self->columns,
            &self->colCount,
            self->buffer,
            self->bufferLength)
        );
      }
      count++;
    }
  }
  else {
    ODBC::FreeColumns(self->columns, &self->colCount);
  }
  
  //throw the error object if there were errors
  if (errorCount > 0) {
    ThrowException(objError);
  }
  
  return scope.Close(rows);
}
开发者ID:hcsoft,项目名称:nodewebhis,代码行数:91,代码来源:odbc_result.cpp

示例13: ThrowException

Handle<Value> MemoryDatasource::add(const Arguments& args)
{

    HandleScope scope;

    if ((args.Length() != 1) || !args[0]->IsObject())
    {
        return ThrowException(Exception::Error(
                                  String::New("accepts one argument: an object including x and y (or wkt) and properties")));
    }

    MemoryDatasource* d = node::ObjectWrap::Unwrap<MemoryDatasource>(args.This());

    Local<Object> obj = args[0]->ToObject();

    if (obj->Has(String::New("wkt")) || (obj->Has(String::New("x")) && obj->Has(String::New("y"))))
    {
        if (obj->Has(String::New("wkt")))
            return ThrowException(Exception::Error(
                                      String::New("wkt not yet supported")));

        Local<Value> x = obj->Get(String::New("x"));
        Local<Value> y = obj->Get(String::New("y"));
        if (!x->IsUndefined() && x->IsNumber() && !y->IsUndefined() && y->IsNumber())
        {
            mapnik::geometry_type * pt = new mapnik::geometry_type(MAPNIK_POINT);
            pt->move_to(x->NumberValue(),y->NumberValue());
#if MAPNIK_VERSION >= 200100
            mapnik::context_ptr ctx = MAPNIK_MAKE_SHARED<mapnik::context_type>();
            mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx,d->feature_id_));
#else
            mapnik::feature_ptr feature(mapnik::feature_factory::create(d->feature_id_));
#endif
            ++(d->feature_id_);
            feature->add_geometry(pt);
            if (obj->Has(String::New("properties")))
            {
                Local<Value> props = obj->Get(String::New("properties"));
                if (props->IsObject())
                {
                    Local<Object> p_obj = props->ToObject();
                    Local<Array> names = p_obj->GetPropertyNames();
                    unsigned int i = 0;
                    unsigned int a_length = names->Length();
                    while (i < a_length)
                    {
                        Local<Value> name = names->Get(i)->ToString();
                        // if name in q.property_names() ?
                        Local<Value> value = p_obj->Get(name);
                        if (value->IsString()) {
                            mapnik::value_unicode_string ustr = d->tr_->transcode(TOSTR(value));
#if MAPNIK_VERSION >= 200100
                            feature->put_new(TOSTR(name),ustr);
#else
                            boost::put(*feature,TOSTR(name),ustr);
#endif
                        } else if (value->IsNumber()) {
                            double num = value->NumberValue();
                            // todo - round
                            if (num == value->IntegerValue()) {
#if MAPNIK_VERSION >= 200100
                                feature->put_new(TOSTR(name),static_cast<node_mapnik::value_integer>(value->IntegerValue()));
#else
                                boost::put(*feature,TOSTR(name),static_cast<int>(value->IntegerValue()));
#endif
                            } else {
                                double dub_val = value->NumberValue();
#if MAPNIK_VERSION >= 200100
                                feature->put_new(TOSTR(name),dub_val);
#else
                                boost::put(*feature,TOSTR(name),dub_val);
#endif
                            }
                        } else if (value->IsNull()) {
#if MAPNIK_VERSION >= 200100
                            feature->put_new(TOSTR(name),mapnik::value_null());
#else
                            boost::put(*feature,TOSTR(name),mapnik::value_null());
#endif
                        } else {
                            std::clog << "unhandled type for property: " << TOSTR(name) << "\n";
                        }
                        i++;
                    }
                }
            }
            mapnik::memory_datasource *cache = dynamic_cast<mapnik::memory_datasource *>(d->datasource_.get());
            cache->push(feature);
        }
    }
    return scope.Close(False());
}
开发者ID:kkoopa,项目名称:node-mapnik,代码行数:92,代码来源:mapnik_memory_datasource.cpp

示例14: KeyOperation

ScanOperation::ScanOperation(const Arguments &args) : 
  KeyOperation(),
  scan_op(0),
  index_scan_op(0),
  nbounds(0),
  isIndexScan(false)
{
  DEBUG_MARKER(UDEB_DEBUG);

  Local<Value> v;

  const Local<Object> spec = args[0]->ToObject();
  opcode = args[1]->Int32Value();
  ctx = unwrapPointer<TransactionImpl *>(args[2]->ToObject());

  lmode = NdbOperation::LM_CommittedRead;
  scan_options.scan_flags = 0;
  scan_options.optionsPresent = 0ULL;

  v = spec->Get(SCAN_TABLE_RECORD);
  if(! v->IsNull()) {
    Local<Object> o = v->ToObject();
    row_record = unwrapPointer<const Record *>(o);
    createBlobReadHandles(row_record);
  }

  v = spec->Get(SCAN_INDEX_RECORD);
  if(! v->IsNull()) {
    Local<Object> o = v->ToObject();
    isIndexScan = true;
    key_record = unwrapPointer<const Record *>(o);
  }
  
  v = spec->Get(SCAN_LOCK_MODE);
  if(! v->IsNull()) {
    int intLockMode = v->Int32Value();
    DEBUG_PRINT("Scan lock mode %d", intLockMode);
    lmode = static_cast<NdbOperation::LockMode>(intLockMode);
  }

  // SCAN_BOUNDS is an array of BoundHelpers  
  v = spec->Get(SCAN_BOUNDS);
  if(v->IsArray()) {
    Local<Object> o = v->ToObject();
    while(o->Has(nbounds)) {
      nbounds++; 
    }
    DEBUG_PRINT("Index Scan with %d IndexBounds", nbounds);
    bounds = new NdbIndexScanOperation::IndexBound *[nbounds];
    for(int i = 0 ; i < nbounds ; i++) {
      Local<Object> b = o->Get(i)->ToObject();
      bounds[i] = unwrapPointer<NdbIndexScanOperation::IndexBound *>(b);
    }
  }

  v = spec->Get(SCAN_OPTION_FLAGS);
  if(! v->IsNull()) {
    scan_options.scan_flags = v->Uint32Value();
  }
  
  v = spec->Get(SCAN_OPTION_BATCH_SIZE);
  if(! v->IsNull()) {
    scan_options.batch = v->Uint32Value();
    scan_options.optionsPresent |= NdbScanOperation::ScanOptions::SO_BATCH;
  }
  
  v = spec->Get(SCAN_OPTION_PARALLELISM);
  if(! v->IsNull()) {
    scan_options.parallel = v->Uint32Value();
    scan_options.optionsPresent |= NdbScanOperation::ScanOptions::SO_PARALLEL;
  }
  
  v = spec->Get(SCAN_FILTER_CODE);
  if(! v->IsNull()) {
    Local<Object> o = v->ToObject();
    scan_options.interpretedCode = unwrapPointer<NdbInterpretedCode *>(o);
    scan_options.optionsPresent |= NdbScanOperation::ScanOptions::SO_INTERPRETED;
  }

  /* Scanning delete requires key info */
  if(opcode == OP_SCAN_DELETE) {
    scan_options.scan_flags |= NdbScanOperation::SF_KeyInfo;
  }

  /* If any flags were set, also set SO_SCANFLAGS options */
  if(scan_options.scan_flags != 0) {
    scan_options.optionsPresent |= NdbScanOperation::ScanOptions::SO_SCANFLAGS;
  }

  /* Done defining the object */
  debug_print_flags_and_options(scan_options);
}
开发者ID:alMysql,项目名称:mysql-js,代码行数:92,代码来源:ScanOperation.cpp

示例15: format

Handle<Value> Grid::encodeSync(const Arguments& args) // format, resolution
{
    HandleScope scope;

    Grid* g = ObjectWrap::Unwrap<Grid>(args.This());
    
    // defaults
    std::string format("utf");
    unsigned int resolution = 4;
    bool add_features = true;
    
    // accept custom format
    if (args.Length() >= 1){
        if (!args[0]->IsString())
          return ThrowException(Exception::TypeError(
            String::New("first arg, 'format' must be a string")));
        format = TOSTR(args[0]);
    }
    
    // options hash
    if (args.Length() >= 2) {
        if (!args[1]->IsObject())
          return ThrowException(Exception::TypeError(
            String::New("optional second arg must be an options object")));

        Local<Object> options = args[1]->ToObject();

        if (options->Has(String::New("resolution")))
        {
            Local<Value> bind_opt = options->Get(String::New("resolution"));
            if (!bind_opt->IsNumber())
              return ThrowException(Exception::TypeError(
                String::New("'resolution' must be an Integer")));
    
            resolution = bind_opt->IntegerValue();
        }

        if (options->Has(String::New("features")))
        {
            Local<Value> bind_opt = options->Get(String::New("features"));
            if (!bind_opt->IsBoolean())
              return ThrowException(Exception::TypeError(
                String::New("'features' must be an Boolean")));
    
            add_features = bind_opt->BooleanValue();
        }
    }
    
    try {
    
        Local<Array> grid_array = Array::New();
        std::vector<mapnik::grid::lookup_type> key_order;
        node_mapnik::grid2utf<mapnik::grid>(*g->get(),grid_array,key_order,resolution);
    
        // convert key order to proper javascript array
        Local<Array> keys_a = Array::New(key_order.size());
        std::vector<std::string>::iterator it;
        unsigned int i;
        for (it = key_order.begin(), i = 0; it < key_order.end(); ++it, ++i)
        {
            keys_a->Set(i, String::New((*it).c_str()));
        }
    
        // gather feature data
        Local<Object> feature_data = Object::New();
        if (add_features) {
            node_mapnik::write_features<mapnik::grid>(*g->get(),
                           feature_data,
                           key_order
                           );
        }
        
        // Create the return hash.
        Local<Object> json = Object::New();
        json->Set(String::NewSymbol("grid"), grid_array);
        json->Set(String::NewSymbol("keys"), keys_a);
        json->Set(String::NewSymbol("data"), feature_data);
        return json;
        
    }
    catch (std::exception & ex)
    {
        return ThrowException(Exception::Error(
          String::New(ex.what())));
    }
}
开发者ID:tannewt,项目名称:node-mapnik,代码行数:86,代码来源:mapnik_grid.cpp


注:本文中的Local::Has方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。