本文整理汇总了C++中Local::IsDate方法的典型用法代码示例。如果您正苦于以下问题:C++ Local::IsDate方法的具体用法?C++ Local::IsDate怎么用?C++ Local::IsDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Local
的用法示例。
在下文中一共展示了Local::IsDate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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()) {
//.........这里部分代码省略.........
示例2: BindParameters
//.........这里部分代码省略.........
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;
}
else {
binding.js_type = ParamBinding::JS_NUMBER;
binding.c_type = SQL_C_DOUBLE;
binding.sql_type = SQL_DOUBLE;
binding.buffer = new double;
binding.buffer_len = sizeof( double );
*static_cast<double*>( binding.buffer ) = p->NumberValue();
binding.param_size = sizeof( double );
binding.digits = 0;
binding.indptr = binding.buffer_len;
}
}
else if( p->IsDate() ) {
// Since JS dates have no timezone context, all dates are assumed to be UTC
Handle<Date> dateObject = Handle<Date>::Cast<Value>( p );
assert( !dateObject.IsEmpty() );
// dates in JS are stored internally as ms count from Jan 1, 1970
double d = dateObject->NumberValue();
SQL_SS_TIMESTAMPOFFSET_STRUCT* sql_tm = new SQL_SS_TIMESTAMPOFFSET_STRUCT;
TimestampColumn sql_date( d );
sql_date.ToTimestampOffset( *sql_tm );
binding.js_type = ParamBinding::JS_DATE;
binding.c_type = SQL_C_BINARY;
// TODO: Determine proper SQL type based on version of server we're talking to
binding.sql_type = SQL_SS_TIMESTAMPOFFSET;
binding.buffer = sql_tm;
binding.buffer_len = sizeof( SQL_SS_TIMESTAMPOFFSET_STRUCT );
// TODO: Determine proper precision and size based on version of server we're talking to
binding.param_size = SQL_SERVER_2008_DEFAULT_DATETIME_PRECISION;
binding.digits = SQL_SERVER_2008_DEFAULT_DATETIME_SCALE;
binding.indptr = binding.buffer_len;
}
else if( p->IsObject() && node::Buffer::HasInstance( p )) {
// TODO: Determine if we need something to keep the Buffer object from going
// away while we use it we could just copy the data, but with buffers being
// potentially very large, that could be problematic
Local<Object> o = p.As<Object>();
binding.js_type = ParamBinding::JS_BUFFER;
binding.c_type = SQL_C_BINARY;
binding.sql_type = SQL_VARBINARY;
binding.buffer = node::Buffer::Data( o );
binding.buffer_len = node::Buffer::Length( o );
binding.param_size = binding.buffer_len;
binding.digits = 0;
binding.indptr = binding.buffer_len;
}
else {
return ParameterErrorToUserCallback( i, "Invalid parameter type" );
}
params.push_back( move( binding ));
}
}
return true;
}
示例3: isDictionaryObject
bool GNUtil::isDictionaryObject(Local<Value> obj) {
return obj->IsObject() &&
!(obj->IsRegExp() || obj->IsDate() ||
obj->IsFunction() || obj->IsArray());
}
示例4: 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( );
//.........这里部分代码省略.........