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


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

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


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

示例1: argToKey

argtokey_callback_t argToKey(const Local<Value> &val, MDB_val &key, bool keyIsUint32) {
    // Check key type
    if (keyIsUint32 && !val->IsUint32()) {
        Nan::ThrowError("Invalid key. keyIsUint32 specified on the database, but the given key was not an unsigned 32-bit integer");
        return nullptr;
    }
    if (!keyIsUint32 && !val->IsString()) {
        Nan::ThrowError("Invalid key. String key expected, because keyIsUint32 isn't specified on the database.");
        return nullptr;
    }

    // Handle uint32_t key
    if (keyIsUint32) {
        uint32_t *v = new uint32_t;
        *v = val->Uint32Value();

        key.mv_size = sizeof(uint32_t);
        key.mv_data = v;

        return ([](MDB_val &key) -> void {
            delete (uint32_t*)key.mv_data;
        });
    }

    // Handle string key
    CustomExternalStringResource::writeTo(val->ToString(), &key);
    return ([](MDB_val &key) -> void {
        delete[] (uint16_t*)key.mv_data;
    });

    return nullptr;
}
开发者ID:2nd,项目名称:node-lmdb,代码行数:32,代码来源:misc.cpp

示例2: if

    static uint64_t convert_seed(Local<Value> seed_val, bool &did_throw) {
      if (seed_val->IsUint32()) {
        return seed_val->Uint32Value();
      } else if (node::Buffer::HasInstance(seed_val)) {
        char* seed_buf = node::Buffer::Data(seed_val);
        size_t seed_buf_len = node::Buffer::Length(seed_val);
        if (seed_buf_len == 4) {
#if __BYTE_ORDER == __LITTLE_ENDIAN
          return XXH_readLE32(seed_buf, XXH_littleEndian);
#else
          return XXH_readLE32(seed_buf, XXH_bigEndian);
#endif
        } else if (seed_buf_len == 8) {
#if __BYTE_ORDER == __LITTLE_ENDIAN
          return XXH_readLE64(seed_buf, XXH_littleEndian);
#else
          return XXH_readLE64(seed_buf, XXH_bigEndian);
#endif
        }
        Nan::ThrowTypeError("seed Buffer must be 4 or 8 bytes");
      } else {
        Nan::ThrowTypeError("invalid seed argument");
      }
      did_throw = true;
      return 0;
    }
开发者ID:mscdex,项目名称:node-xxhash,代码行数:26,代码来源:hash_64.hpp

示例3:

/*
 * Prototype:
 * Stalker.removeCallProbe(id)
 *
 * Docs:
 * TBW
 *
 * Example:
 * TBW
 */
static void
gum_v8_stalker_on_remove_call_probe (
    const FunctionCallbackInfo<Value> & info)
{
  GumV8Stalker * self = static_cast<GumV8Stalker *> (
      info.Data ().As<External> ()->Value ());
  Isolate * isolate = info.GetIsolate ();

  Local<Value> id = info[0];
  if (!id->IsUint32 ())
  {
    isolate->ThrowException (Exception::TypeError (String::NewFromUtf8 (isolate,
        "Stalker.removeCallProbe: argument must be a probe id")));
    return;
  }

  gum_stalker_remove_call_probe (_gum_v8_stalker_get (self),
      id->ToUint32 ()->Value ());

  return;
}
开发者ID:0xItx,项目名称:frida-gum,代码行数:31,代码来源:gumv8stalker.cpp

示例4: ThrowException

Handle<Value>
Session::Request(const Arguments& args)
{
    HandleScope scope;

    if (args.Length() < 1 || !args[0]->IsString()) {
        return ThrowException(Exception::Error(String::New(
                "Service URI string must be provided as first parameter.")));
    }
    if (args.Length() < 2 || !args[1]->IsString()) {
        return ThrowException(Exception::Error(String::New(
                "String request name must be provided as second parameter.")));
    }
    if (args.Length() < 3 || !args[2]->IsObject()) {
        return ThrowException(Exception::Error(String::New(
                "Object containing request parameters must be provided "
                "as third parameter.")));
    }
    if (args.Length() < 4 || !args[3]->IsInt32()) {
        return ThrowException(Exception::Error(String::New(
                "Integer correlation identifier must be provided "
                "as fourth parameter.")));
    }
    if (args.Length() >= 5 && !args[4]->IsUndefined() && !args[4]->IsString()) {
        return ThrowException(Exception::Error(String::New(
                "Optional request label must be a string.")));
    }
    if (args.Length() > 5) {
        return ThrowException(Exception::Error(String::New(
                "Function expects at most five arguments.")));
    }

    int cidi = args[3]->Int32Value();

    Session* session = ObjectWrap::Unwrap<Session>(args.This());

    BLPAPI_EXCEPTION_TRY

    Local<String> uri = args[0]->ToString();
    String::AsciiValue uriv(uri);

    blpapi::Service service = session->d_session->getService(*uriv);

    Local<String> name = args[1]->ToString();
    String::Utf8Value namev(name);

    blpapi::Request request = service.createRequest(*namev);

    // Loop over object properties, appending/setting into the request.
    Local<Object> obj = args[2]->ToObject();
    Local<Array> props = obj->GetPropertyNames();

    for (std::size_t i = 0; i < props->Length(); ++i) {
        // Process the key.
        Local<Value> keyval = props->Get(i);
        Local<String> key = keyval->ToString();
        String::Utf8Value keyv(key);

        // Process the value.
        //
        // The values present on the outer object are marshalled into the
        // blpapi::Request by setting values using 'set'.  Arrays indicate
        // values which should be marshalled using 'append'.
        Local<Value> val = obj->Get(keyval);
        if (val->IsString()) {
            Local<String> s = val->ToString();
            String::Utf8Value valv(s);
            request.set(*keyv, *valv);
        } else if (val->IsBoolean()) {
            request.set(*keyv, val->BooleanValue());
        } else if (val->IsNumber()) {
            request.set(*keyv, val->NumberValue());
        } else if (val->IsInt32()) {
            request.set(*keyv, val->Int32Value());
        } else if (val->IsUint32()) {
            request.set(*keyv,
                static_cast<blpapi::Int64>(val->Uint32Value()));
        } else if (val->IsDate()) {
            blpapi::Datetime dt;
            mkdatetime(&dt, val);
            request.set(*keyv, dt);
        } else if (val->IsArray()) {
            // Arrays are marshalled into the blpapi::Request by appending
            // value types using the key of the array in the outer object.
            Local<Object> subarray = val->ToObject();
            int jmax = Array::Cast(*val)->Length();
            for (int j = 0; j < jmax; ++j) {
                Local<Value> subval = subarray->Get(j);
                // Only strings, booleans, and numbers are marshalled.
                if (subval->IsString()) {
                    Local<String> s = subval->ToString();
                    String::Utf8Value subvalv(s);
                    request.append(*keyv, *subvalv);
                } else if (subval->IsBoolean()) {
                    request.append(*keyv, subval->BooleanValue());
                } else if (subval->IsNumber()) {
                    request.append(*keyv, subval->NumberValue());
                } else if (subval->IsInt32()) {
                    request.append(*keyv, subval->Int32Value());
                } else if (subval->IsUint32()) {
//.........这里部分代码省略.........
开发者ID:ZJONSSON,项目名称:node-blpapi,代码行数:101,代码来源:blpapijs.cpp

示例5: BindParameters

    bool QueryOperation::BindParameters( Handle<Array> node_params )
    {
        uint32_t count = node_params->Length();

        if( count > 0 ) {

            for( uint32_t i = 0; i < count; ++i ) {

                Local<Value> p = node_params->Get( i );
                ParamBinding binding;

                if( p->IsNull() ) {

                    binding.js_type = ParamBinding::JS_NULL;
                    binding.c_type = SQL_C_CHAR;
                    binding.sql_type = SQL_CHAR;
                    binding.param_size = 1;
                    binding.digits = 0;
                    binding.buffer = NULL;
                    binding.buffer_len = 0;
                    binding.indptr = SQL_NULL_DATA;
                }
                else if( p->IsString() ) {

                    binding.js_type = ParamBinding::JS_STRING;
                    binding.c_type = SQL_C_WCHAR;
                    binding.sql_type = SQL_WVARCHAR;
                    Local<String> str_param = p->ToString();
                    int str_len = str_param->Length();
                    binding.buffer = new uint16_t[ str_len + 1 ];   // null terminator
                    str_param->Write( static_cast<uint16_t*>( binding.buffer ));
                    if( str_len > 4000 ) {
                        binding.param_size = 0;     // max types require 0 precision
                    }
                    else {
                        binding.param_size = str_len;
                    }
                    binding.buffer_len = str_len * sizeof( uint16_t );
                    binding.digits = 0;
                    binding.indptr = binding.buffer_len;
                }
                else if( p->IsBoolean() ) {
                    
                    binding.js_type = ParamBinding::JS_BOOLEAN;
                    binding.c_type = SQL_C_BIT;
                    binding.sql_type = SQL_BIT;
                    binding.buffer = new uint16_t;
                    binding.buffer_len = sizeof( uint16_t );
                    *static_cast<uint16_t*>( binding.buffer ) = p->BooleanValue();
                    binding.param_size = 1;
                    binding.digits = 0;
                    binding.indptr = binding.buffer_len;
                }
                else if( p->IsInt32()) {

                    binding.js_type = ParamBinding::JS_INT;
                    binding.c_type = SQL_C_SLONG;
                    binding.sql_type = SQL_INTEGER;
                    binding.buffer = new int32_t;
                    binding.buffer_len = sizeof( int32_t );
                    *static_cast<int32_t*>( binding.buffer ) = p->Int32Value();
                    binding.param_size = sizeof( int32_t );
                    binding.digits = 0;
                    binding.indptr = binding.buffer_len;
                }
                else if( p->IsUint32()) {

                    binding.js_type = ParamBinding::JS_UINT;
                    binding.c_type = SQL_C_ULONG;
                    binding.sql_type = SQL_BIGINT;
                    binding.buffer = new uint32_t;
                    binding.buffer_len = sizeof( uint32_t );
                    *static_cast<int32_t*>( binding.buffer ) = p->Uint32Value();
                    binding.param_size = sizeof( uint32_t );
                    binding.digits = 0;
                    binding.indptr = binding.buffer_len;
                }
                else if( p->IsNumber()) {

                    // numbers can be either integers or doubles.  We attempt to determine which it is through a simple
                    // cast and equality check
                    double d = p->NumberValue();
                    if( _isnan( d ) || !_finite( d ) ) {

                        return ParameterErrorToUserCallback( i, "Invalid number parameter" );

                    }
                    else if( d == floor( d ) && 
                             d >= std::numeric_limits<int64_t>::min() && 
                             d <= std::numeric_limits<int64_t>::max() ) {

                        binding.js_type = ParamBinding::JS_NUMBER;
                        binding.c_type = SQL_C_SBIGINT;
                        binding.sql_type = SQL_BIGINT;
                        binding.buffer = new int64_t;
                        binding.buffer_len = sizeof( int64_t );
                        *static_cast<int64_t*>( binding.buffer ) = p->IntegerValue();
                        binding.param_size = sizeof( int64_t );
                        binding.digits = 0;
                        binding.indptr = binding.buffer_len;
//.........这里部分代码省略.........
开发者ID:ArronYR,项目名称:node-sqlserver,代码行数:101,代码来源:OdbcOperation.cpp

示例6: TransformParameter

bool CQueryParameter::TransformParameter( Isolate* isolate, Local< Value > value, sBindParameter** pOutParam )
{
	HandleScope scope( isolate );
	Local< Context > context = isolate->GetCurrentContext( );

	sBindParameter* pParameter = *pOutParam;

	if( value->IsNull( ) )
	{
		pParameter->SetNull( );
	}
	else if( value->IsString( ) )
	{
		pParameter->SetString( value.As<String>( ) );
	}
	else if( value->IsBoolean( ) )
	{
		pParameter->SetBool( value->BooleanValue( context ).FromJust( ) );
	}
	else if( value->IsInt32( ) )
	{
		pParameter->SetInt( value->Int32Value( context ).FromJust( ) );
	}
	else if( value->IsUint32( ) )
	{
		pParameter->SetUInt( value->Uint32Value( context ).FromJust( ) );
	}
	else if( value->IsNumber( ) )
	{
		double d = value->NumberValue( context ).FromJust( );
		if( _isnan( d ) || !_finite( d ) )
		{
			return false;
		}
		else if( d == floor( d ) &&
				 d >= std::numeric_limits<int64_t>::min( ) &&
				 d <= std::numeric_limits<int64_t>::max( )
				 )
		{
			pParameter->SetInt64( value->IntegerValue( context ).FromJust( ) );
		}
		else
		{
			pParameter->SetDouble( value->NumberValue( context ).FromJust( ) );
		}
	}
	else if( value->IsDate( ) )
	{
		Local<Date> dateObject = value.As<Date>( );

		pParameter->SetDate( dateObject->NumberValue( context ).FromJust( ) );
	}
	else if( value->IsObject( ) )
	{
		Local<Object> objValue = value.As<Object>( );

		if( node::Buffer::HasInstance( value ) )
		{
			pParameter->SetBuffer( isolate, objValue );
		}
		else
		{
			Local< String > strId = String::NewFromUtf8( isolate, "_objId", NewStringType::kNormal ).ToLocalChecked( );


			if( objValue->HasRealNamedProperty( context, strId ).FromJust( ) )
			{
				Local< Uint32 > numTypeId = objValue->Get( context, strId ).ToLocalChecked( ).As< Uint32 >( );

				uint32_t nType = numTypeId->Int32Value( context ).FromJust( );

				switch( nType )
				{
					case ID_INPUT_STREAM:
					{
						Local<Value> type = objValue->Get(
							context, String::NewFromUtf8( isolate, "type", NewStringType::kNormal ).ToLocalChecked( )
						).ToLocalChecked( );

						Local<Value> stream = objValue->Get(
							context, String::NewFromUtf8( isolate, "stream", NewStringType::kNormal ).ToLocalChecked( )
						).ToLocalChecked( );

						Local<Value> length = objValue->Get(
							context, String::NewFromUtf8( isolate, "length", NewStringType::kNormal ).ToLocalChecked( )
						).ToLocalChecked( );

						pParameter->SetStream( isolate, type->Uint32Value( context ).FromJust( ), stream, static_cast< SQLUINTEGER >( length->IntegerValue( context ).FromJust( ) ) );

						break;
					}
					case ID_NUMERIC_VALUE:
					{
						Local< Value > precision = objValue->Get(
							context, String::NewFromUtf8( isolate, "precision", NewStringType::kNormal ).ToLocalChecked( )
						).ToLocalChecked( );

						Local<Value> scale = objValue->Get(
							context, String::NewFromUtf8( isolate, "scale", NewStringType::kNormal ).ToLocalChecked( )
						).ToLocalChecked( );
//.........这里部分代码省略.........
开发者ID:ItsClemi,项目名称:node-odbc,代码行数:101,代码来源:QueryParameter.cpp

示例7: checkArgument

 void JSZCluster::checkArgument(const v8::FunctionCallbackInfo<v8::Value> &info, unsigned int index,
                                const std::shared_ptr<ClusterCmdParamsBase> &cmdParam) {
     if (info.Length() <= ((int) index + 1)) {
         stringstream stream;
         stream << EXECUTE_CMD_BY_ID << " needs almost " << index << " arguments where the first is the cmd";
         throw JSException(stream.str());
     }
     Local<v8::Value> arg = info[index + 1];
     switch (cmdParam->getZCLDataType()) {
         case ZCLTypeDataType::ZCLTypeUInt8:
         case ZCLTypeDataType::ZCLTypeUInt16:
         case ZCLTypeDataType::ZCLTypeUInt24:
         case ZCLTypeDataType::ZCLTypeUInt32:
         case ZCLTypeDataType::ZCLTypeUInt40:
         case ZCLTypeDataType::ZCLTypeUInt48:
         case ZCLTypeDataType::ZCLTypeUInt56:
         case ZCLTypeDataType::ZCLTypeUInt64:
             if (!arg->IsUint32()) {
                 stringstream stream;
                 stream << EXECUTE_CMD_BY_ID << " needs as argument " << index << " an unsigned integer";
                 throw JSException(stream.str());
             }
             break;
         case ZCLTypeDataType::ZCLTypeSInt8:
         case ZCLTypeDataType::ZCLTypeSInt16:
         case ZCLTypeDataType::ZCLTypeSInt24:
         case ZCLTypeDataType::ZCLTypeSInt32:
         case ZCLTypeDataType::ZCLTypeSInt40:
         case ZCLTypeDataType::ZCLTypeSInt48:
         case ZCLTypeDataType::ZCLTypeSInt56:
         case ZCLTypeDataType::ZCLTypeSInt64:
             if (!arg->IsInt32()) {
                 stringstream stream;
                 stream << EXECUTE_CMD_BY_ID << " needs as argument " << index << " an integer";
                 throw JSException(stream.str());
             }
             break;
         case ZCLTypeDataType::ZCLTypeIEEEaddress:
         case ZCLTypeDataType::ZCLTypeStringChar:
             if (!arg->IsString()) {
                 stringstream stream;
                 stream << EXECUTE_CMD_BY_ID << " needs as argument " << index << " a string";
                 throw JSException(stream.str());
             }
             break;
         case ZCLTypeDataType::ZCLTypeArray:
             if (!arg->IsUint32Array() && !arg->IsUint32Array()) {
                 if (!arg->IsArray()) {
                     stringstream stream;
                     stream << EXECUTE_CMD_BY_ID << " needs as argument " << index << " an array";
                     throw JSException(stream.str());
                 }
             }
             break;
         default:
             stringstream stream;
             stream << EXECUTE_CMD_BY_ID << " needs as argument " << index << " a type "
                    << cmdParam->getZCLDataType() << " the it is not managed";
             throw JSException(stream.str());
     }
 }
开发者ID:paoloach,项目名称:zdomus,代码行数:61,代码来源:JSZCluster.cpp


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