本文整理汇总了C++中Local::IsTrue方法的典型用法代码示例。如果您正苦于以下问题:C++ Local::IsTrue方法的具体用法?C++ Local::IsTrue怎么用?C++ Local::IsTrue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Local
的用法示例。
在下文中一共展示了Local::IsTrue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertToList
getdns_list* GNUtil::convertToList(Local<Array> array) {
uint32_t len = array->Length();
getdns_list* result = getdns_list_create();
for (uint32_t i = 0; i < len; ++i) {
size_t idx = getdns_list_get_length(result, &idx);
Local<Value> val = array->Get(i);
GetdnsType type = getGetdnsType(val);
switch (type) {
case IntType:
getdns_list_set_int(result, idx, val->ToUint32()->Value());
break;
case BoolType:
if (val->IsTrue()) {
getdns_list_set_int(result, idx, GETDNS_EXTENSION_TRUE);
} else {
getdns_list_set_int(result, idx, GETDNS_EXTENSION_FALSE);
}
break;
case StringType:
{
struct getdns_bindata strdata;
String::Utf8Value utf8Str(val->ToString());
int len = utf8Str.length();
strdata.data = (uint8_t*) *utf8Str;
strdata.size = len;
getdns_list_set_bindata(result, idx, &strdata);
}
break;
case BinDataType:
{
struct getdns_bindata bdata;
bdata.data = (uint8_t*) node::Buffer::Data(val);
bdata.size = node::Buffer::Length(val);
getdns_list_set_bindata(result, idx, &bdata);
}
break;
case ListType:
{
Local<Array> subArray = Local<Array>::Cast(val);
struct getdns_list* sublist = GNUtil::convertToList(subArray);
getdns_list_set_list(result, idx, sublist);
getdns_list_destroy(sublist);
}
break;
case DictType:
{
Local<Object> subObj = val->ToObject();
struct getdns_dict* subdict = GNUtil::convertToDict(subObj);
if (subdict) {
getdns_list_set_dict(result, idx, subdict);
getdns_dict_destroy(subdict);
}
}
break;
default:
break;
}
}
return result;
}
示例2: Assert
void ConsoleInterfaces::Assert(const FunctionCallbackInfo<Value>& args)
{
Handle<External> ext = Handle<External>::Cast(args.Data());
Flathead *pFH = (Flathead *)ext->Value();
int counter = 0;
if (args.Length() == 0)
{
pFH->GetConfiguration()->LoggingFn()(LogLevels::Assert, "");
return;
}
Local<Value> value = args[0];
if (value->IsTrue())
{
args.GetReturnValue().Set(counter);
return;
}
if (pFH->GetConfiguration()->LoggingFn() != NULL)
{
for (int i = 1; i < args.Length(); i++)
{
Local<Value> value = args[i];
String::Utf8Value outputString(value);
pFH->GetConfiguration()->LoggingFn()(LogLevels::Assert, *outputString);
counter++;
}
}
args.GetReturnValue().Set(counter);
}
示例3: value
inline void
encodeBoolean(bson_buffer *bb, const char *name, const Local<Value> element) {
bool value(element->IsTrue());
bson_append_bool(bb, name, value);
}
示例4: convertToDict
getdns_dict* GNUtil::convertToDict(Local<Object> obj) {
if (obj->IsRegExp() || obj->IsDate() ||
obj->IsFunction() || obj->IsUndefined() ||
obj->IsNull() || obj->IsArray()) {
return NULL;
}
Local<Array> names = obj->GetOwnPropertyNames();
getdns_dict* result = getdns_dict_create();
for(unsigned int i = 0; i < names->Length(); i++) {
Local<Value> nameVal = names->Get(i);
Nan::Utf8String name(nameVal);
Local<Value> val = obj->Get(nameVal);
GetdnsType type = getGetdnsType(val);
switch (type) {
case IntType:
getdns_dict_set_int(result, *name, val->ToUint32()->Value());
break;
case BoolType:
if (val->IsTrue()) {
getdns_dict_set_int(result, *name, GETDNS_EXTENSION_TRUE);
} else {
getdns_dict_set_int(result, *name, GETDNS_EXTENSION_FALSE);
}
break;
case StringType:
{
struct getdns_bindata strdata;
String::Utf8Value utf8Str(val->ToString());
int len = utf8Str.length();
strdata.data = (uint8_t*) *utf8Str;
strdata.size = len;
getdns_dict_set_bindata(result, *name, &strdata);
}
break;
case BinDataType:
{
struct getdns_bindata bdata;
bdata.data = (uint8_t*) node::Buffer::Data(val);
bdata.size = node::Buffer::Length(val);
getdns_dict_set_bindata(result, *name, &bdata);
}
break;
case ListType:
{
Local<Array> subArray = Local<Array>::Cast(val);
struct getdns_list* sublist = GNUtil::convertToList(subArray);
getdns_dict_set_list(result, *name, sublist);
getdns_list_destroy(sublist);
}
break;
case DictType:
{
Local<Object> subObj = val->ToObject();
struct getdns_dict* subdict = GNUtil::convertToDict(subObj);
if (subdict) {
getdns_dict_set_dict(result, *name, subdict);
getdns_dict_destroy(subdict);
}
}
break;
default:
break;
}
}
return result;
}