本文整理汇总了C++中json::Value::isUInt64方法的典型用法代码示例。如果您正苦于以下问题:C++ Value::isUInt64方法的具体用法?C++ Value::isUInt64怎么用?C++ Value::isUInt64使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类json::Value
的用法示例。
在下文中一共展示了Value::isUInt64方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseFromJsonToDictionary
/// 从 Json 解析数据到 dictNode 中
static void parseFromJsonToDictionary(const Json::Value & jsonNode, CCDictionary * dictNode)
{
Json::Value::Members members = jsonNode.getMemberNames();
for (Json::Value::Members::iterator beg = members.begin(); beg != members.end(); ++beg)
{
std::string name = *beg;
Json::Value child = jsonNode[name];
if (child.isArray())
{
CCArray * arr = CCArray::create();
parseFromJsonToArray(child, arr);
dictNode->setObject(arr, name);
}
else if (child.isObject())
{
CCDictionary * dict = CCDictionary::create();
parseFromJsonToDictionary(child, dict);
dictNode->setObject(dict, name);
}
else if (child.isString())
{
CCString * str = CCString::createWithFormat("%s", child.asCString());
dictNode->setObject(str, name);
}
else if (child.isInt())
{
CCString * str = CCString::createWithFormat("%d", child.asInt());
dictNode->setObject(str, name);
}
else if (child.isUInt())
{
CCString * str = CCString::createWithFormat("%u", child.asUInt());
dictNode->setObject(str, name);
}
else if (child.isInt64())
{
CCString * str = CCString::createWithFormat("%lld", child.asInt64());
dictNode->setObject(str, name);
}
else if (child.isUInt64())
{
CCString * str = CCString::createWithFormat("%llu", child.asUInt64());
dictNode->setObject(str, name);
}
else if (child.isDouble())
{
CCString * str = CCString::createWithFormat("%f", child.asDouble());
dictNode->setObject(str, name);
}
else if (child.isBool())
{
CCString * str = CCString::createWithFormat("%d", child.asInt());
dictNode->setObject(str, name);
}
}
}
示例2: TrexRpcException
void
TrexRpcCommand::check_field_type_common(const Json::Value &field, const std::string &name, field_type_e type, Json::Value &result) {
std::stringstream ss;
/* first check if field exists */
if (field == Json::Value::null) {
ss << "field '" << name << "' is missing";
generate_parse_err(result, ss.str());
}
bool rc = true;
switch (type) {
case FIELD_TYPE_BYTE:
if ( (!field.isUInt()) || (field.asInt() > 0xFF)) {
rc = false;
}
break;
case FIELD_TYPE_UINT16:
if ( (!field.isUInt()) || (field.asInt() > 0xFFFF)) {
rc = false;
}
break;
case FIELD_TYPE_UINT32:
if ( (!field.isUInt()) || (field.asUInt() > 0xFFFFFFFF)) {
rc = false;
}
break;
case FIELD_TYPE_UINT64:
if (!field.isUInt64()) {
rc = false;
}
break;
case FIELD_TYPE_BOOL:
if (!field.isBool()) {
rc = false;
}
break;
case FIELD_TYPE_INT:
if (!field.isInt()) {
rc = false;
}
break;
case FIELD_TYPE_DOUBLE:
if (!field.isDouble()) {
rc = false;
}
break;
case FIELD_TYPE_OBJ:
if (!field.isObject()) {
rc = false;
}
break;
case FIELD_TYPE_STR:
if (!field.isString()) {
rc = false;
}
break;
case FIELD_TYPE_ARRAY:
if (!field.isArray()) {
rc = false;
}
break;
default:
throw TrexRpcException("unhandled type");
break;
}
if (!rc) {
ss << "error at offset: " << field.getOffsetStart() << " - '" << name << "' is '" << json_type_to_name(field) << "', expecting '" << type_to_str(type) << "'";
generate_parse_err(result, ss.str());
}
}