本文整理汇总了C++中json::Value::isIntegral方法的典型用法代码示例。如果您正苦于以下问题:C++ Value::isIntegral方法的具体用法?C++ Value::isIntegral怎么用?C++ Value::isIntegral使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类json::Value
的用法示例。
在下文中一共展示了Value::isIntegral方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
GmResultDigest::GmResultDigest(const Json::Value &jsonTypeValuePair) {
fIsValid = false;
if (!jsonTypeValuePair.isArray()) {
gm_fprintf(stderr, "found non-array json value when parsing GmResultDigest: %s\n",
jsonTypeValuePair.toStyledString().c_str());
DEBUGFAIL_SEE_STDERR;
} else if (2 != jsonTypeValuePair.size()) {
gm_fprintf(stderr, "found json array with wrong size when parsing GmResultDigest: %s\n",
jsonTypeValuePair.toStyledString().c_str());
DEBUGFAIL_SEE_STDERR;
} else {
// TODO(epoger): The current implementation assumes that the
// result digest is always of type kJsonKey_Hashtype_Bitmap_64bitMD5
Json::Value jsonHashValue = jsonTypeValuePair[1];
if (!jsonHashValue.isIntegral()) {
gm_fprintf(stderr,
"found non-integer jsonHashValue when parsing GmResultDigest: %s\n",
jsonTypeValuePair.toStyledString().c_str());
DEBUGFAIL_SEE_STDERR;
} else {
fHashDigest = jsonHashValue.asUInt64();
fIsValid = true;
}
}
}
示例2: process_result
Json::Value Connection::process_result(const Json::Value& value) {
if(value.isObject()) {
Json::Value id = value["id"];
if(!id.isIntegral() or id.asInt() != 0) {
std::stringstream error;
error << value.toStyledString() << " is no id=0";
throw ConnectionError(error.str());
}
Json::Value jsonrpc = value["jsonrpc"];
if(!jsonrpc.isString()) {
std::stringstream error;
error << value.toStyledString() << " has no string member: jsonrpc";
throw ConnectionError(error.str());
}
Json::Value result = value["result"];
if(!result.isObject()) {
std::stringstream error;
error << value.toStyledString() << " has no object member: result";
throw ConnectionError(error.str());
}
return result;
} else {
std::stringstream error;
error << value.toStyledString() << " is no json object";
throw ConnectionError(error.str());
}
}
示例3: Deserialize
bool Deserialize ( const Json::Value& json_val, json_lib::uint64& obj_val )
{
if ( json_val.isIntegral () )
{
obj_val = json_val.asUInt64 ();
return true;
}
return false;
}
示例4: pushKey
void LuaModule::pushKey(const Json::Value &key, lua_State * stack) {
if (key.isString()) {
lua_pushstring(stack, key.asString().c_str());
} else if (key.isIntegral()) {
throw std::runtime_error("Integer keys must not be pushed. "
"Use lua_rawseti();");
} else {
throw std::runtime_error("Key is not string nor integer");
}
}
示例5: asUnsignedLong
unsigned long JsonUtils::asUnsignedLong(const Json::Value &value, long unsigned int defaultValue)
{
long unsigned int returned = defaultValue;
if(value.isString())
returned = Ogre::StringConverter::parseUnsignedLong(value.asString(), defaultValue);
if(value.isIntegral())
returned = value.asUInt64();
return returned;
}
示例6: asInt
int JsonUtils::asInt(const Json::Value &value, int defaultValue)
{
int returned = defaultValue;
if(value.isString())
returned = Ogre::StringConverter::parseInt(value.asString(), defaultValue);
if(value.isIntegral())
returned = value.asInt();
return returned;
}
示例7: to_uint
/***************以下函数用于读取json静态数据***************/
unsigned int to_uint(const Json::Value& val)
{
if ( val.isIntegral() )
return val.asUInt();
if ( val.isDouble() )
return (unsigned int)val.asDouble();
if ( val.isString() )
return strtoul(val.asCString(), NULL, 0 );
return 0;
}
示例8:
void
ValueTest::checkIs( const Json::Value &value, const IsCheck &check )
{
JSONTEST_ASSERT_EQUAL( check.isObject_, value.isObject() );
JSONTEST_ASSERT_EQUAL( check.isArray_, value.isArray() );
JSONTEST_ASSERT_EQUAL( check.isBool_, value.isBool() );
JSONTEST_ASSERT_EQUAL( check.isDouble_, value.isDouble() );
JSONTEST_ASSERT_EQUAL( check.isInt_, value.isInt() );
JSONTEST_ASSERT_EQUAL( check.isUInt_, value.isUInt() );
JSONTEST_ASSERT_EQUAL( check.isIntegral_, value.isIntegral() );
JSONTEST_ASSERT_EQUAL( check.isNumeric_, value.isNumeric() );
JSONTEST_ASSERT_EQUAL( check.isString_, value.isString() );
JSONTEST_ASSERT_EQUAL( check.isNull_, value.isNull() );
}
示例9: pushValue
void LuaModule::pushValue(const Json::Value &val, lua_State * stack) {
if (val.isIntegral()) {
lua_pushinteger(stack, val.asInt());
} else if (val.isDouble()) {
lua_pushnumber(stack, val.asDouble());
} else if (val.isBool()) {
lua_pushboolean(stack, val.asBool());
} else if (val.isString()) {
lua_pushstring(stack, val.asString().c_str());
} else if (val.isNull()) {
//lua_pushstring(stack, val.asString().c_str());
lua_pushnil(stack);
} else {
lua_pop(stack, 1);
std::stringstream ss;
ss << val.type();
std::string typeNum;
ss >> typeNum;
throw std::runtime_error("Value type error: value of type " + typeNum);
}
}