本文整理汇总了C++中KValueRef::IsNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ KValueRef::IsNumber方法的具体用法?C++ KValueRef::IsNumber怎么用?C++ KValueRef::IsNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KValueRef
的用法示例。
在下文中一共展示了KValueRef::IsNumber方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetNumber
double KObject::GetNumber(const char* name, double defaultValue)
{
KValueRef prop = this->Get(name);
if (prop->IsNumber())
{
return prop->ToNumber();
}
else
{
return defaultValue;
}
}
示例2: AddKrollValueToPHPArray
void KPHPArrayObject::AddKrollValueToPHPArray(KValueRef value, zval *phpArray)
{
if (value->IsNull() || value->IsUndefined())
{
add_next_index_null(phpArray);
}
else if (value->IsBool())
{
if (value->ToBool())
add_next_index_bool(phpArray, 1);
else
add_next_index_bool(phpArray, 0);
}
else if (value->IsNumber())
{
/* No way to check whether the number is an
integer or a double here. All Kroll numbers
are doubles, so return a double. This could
cause some PHP to function incorrectly if it's
doing strict type checking. */
add_next_index_double(phpArray, value->ToNumber());
}
else if (value->IsString())
{
add_next_index_stringl(phpArray, (char *) value->ToString(), strlen(value->ToString()), 1);
}
else if (value->IsObject())
{
/*TODO: Implement*/
}
else if (value->IsMethod())
{
/*TODO: Implement*/
}
else if (value->IsList())
{
zval *phpValue;
AutoPtr<KPHPArrayObject> pl = value->ToList().cast<KPHPArrayObject>();
if (!pl.isNull())
phpValue = pl->ToPHP();
else
phpValue = PHPUtils::ToPHPValue(value);
add_next_index_zval(phpArray, phpValue);
}
}
示例3: ValueToLevel
Logger::Level APIBinding::ValueToLevel(KValueRef v)
{
if (v->IsString())
{
string levelString = v->ToString();
return Logger::GetLevel(levelString);
}
else if (v->IsObject())
{
SharedString ss = v->ToObject()->DisplayString();
return Logger::GetLevel(*ss);
}
else if (v->IsNumber())
{
return (Logger::Level) v->ToInt();
}
else // return the appropriate default
{
string levelString = "";
return Logger::GetLevel(levelString);
}
}
示例4: GetBytes
static void GetBytes(KValueRef value, std::vector<BytesRef>& blobs)
{
if (value->IsObject())
{
blobs.push_back(value->ToObject().cast<Bytes>());
}
else if (value->IsString())
{
blobs.push_back(new Bytes(value->ToString()));
}
else if (value->IsList())
{
KListRef list = value->ToList();
for (size_t j = 0; j < list->Size(); j++)
{
GetBytes(list->At((int)j), blobs);
}
}
else if (value->IsNumber())
{
blobs.push_back(new Bytes(value->ToInt()));
}
}