本文整理汇总了C++中KValueRef::IsInt方法的典型用法代码示例。如果您正苦于以下问题:C++ KValueRef::IsInt方法的具体用法?C++ KValueRef::IsInt怎么用?C++ KValueRef::IsInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KValueRef
的用法示例。
在下文中一共展示了KValueRef::IsInt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateProperties
void AppBinding::CreateProperties(const ValueList& args, KValueRef result)
{
AutoPtr<PropertiesBinding> properties = new PropertiesBinding();
result->SetObject(properties);
if (args.size() > 0 && args.at(0)->IsObject())
{
KObjectRef p = args.at(0)->ToObject();
SharedStringList names = p->GetPropertyNames();
for (size_t i = 0; i < names->size(); i++)
{
KValueRef value = p->Get(names->at(i));
ValueList setterArgs;
setterArgs.push_back(Value::NewString(names->at(i)));
setterArgs.push_back(value);
PropertiesBinding::Type type;
if (value->IsList()) type = PropertiesBinding::List;
else if (value->IsInt()) type = PropertiesBinding::Int;
else if (value->IsDouble()) type = PropertiesBinding::Double;
else if (value->IsBool()) type = PropertiesBinding::Bool;
else type = PropertiesBinding::String;
properties->Setter(setterArgs, type);
}
}
}
示例2: GetInt
int KObject::GetInt(const char* name, int defaultValue)
{
KValueRef prop = this->Get(name);
if (prop->IsInt())
{
return prop->ToInt();
}
else
{
return defaultValue;
}
}
示例3: convert
void convert (Statement &select, KValueRef arg)
{
if (arg->IsString())
{
std::string *s = new std::string(arg->ToString());
select , use(*s);
strings.push_back(s);
}
else if (arg->IsInt())
{
int *i = new int(arg->ToInt());
select , use(*i);
ints.push_back(i);
}
else if (arg->IsDouble())
{
double *d = new double(arg->ToDouble());
select , use(*d);
doubles.push_back(d);
}
else if (arg->IsBool())
{
bool *b = new bool(arg->ToBool());
select , use(*b);
bools.push_back(b);
}
else if (arg->IsNull() || arg->IsUndefined())
{
// in this case, we bind a null string (dequoted)
std::string *s = new std::string("null");
select , use(s);
strings.push_back(s);
}
else
{
throw ValueException::FromFormat("Unsupport type for argument: %s",
arg->GetType().c_str());
}
}