本文整理汇总了C++中rapidjson::Value::GetUint64方法的典型用法代码示例。如果您正苦于以下问题:C++ Value::GetUint64方法的具体用法?C++ Value::GetUint64怎么用?C++ Value::GetUint64使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rapidjson::Value
的用法示例。
在下文中一共展示了Value::GetUint64方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unmarshall_json
inline error_code unmarshall_json(const rapidjson::Value &doc, rpc_address& val)
{
TEST_PARAM(doc.IsUint64());
dsn_address_t addr;
addr.u.value = doc.GetUint64();
val = rpc_address(addr);
TEST_PARAM(!val.is_invalid())
return ERR_OK;
}
示例2: getJsonNumber
bool getJsonNumber(const rapidjson::Value &v, T &dst) {
if (v.IsDouble())
dst = T(v.GetDouble());
else if (v.IsInt())
dst = T(v.GetInt());
else if (v.IsUint())
dst = T(v.GetUint());
else if (v.IsInt64())
dst = T(v.GetInt64());
else if (v.IsUint64())
dst = T(v.GetUint64());
else
return false;
return true;
}
示例3: system_error
std::uint64_t get_value(const rapidjson::Value& root, const char* key)
{
if (key != nullptr)
{
if (root.HasMember(key) && root[key].IsUint64())
{
return root[key].GetUint64();
}
else
throw std::system_error(std::error_code(), "Parse error.");
}
else
{
if (root.IsUint64())
return root.GetUint64();
else
throw std::system_error(std::error_code(), "Parse error.");
}
}
示例4: ConvertToMsgPack
void ConvertToMsgPack(const rapidjson::Value& json, msgpack::object& object, msgpack::zone& zone)
{
switch (json.GetType())
{
case rapidjson::kFalseType:
object = false;
break;
case rapidjson::kTrueType:
object = true;
break;
case rapidjson::kNumberType:
{
if (json.IsInt())
{
object = json.GetInt();
}
else if (json.IsUint())
{
object = json.GetUint();
}
else if (json.IsInt64())
{
object = json.GetInt64();
}
else if (json.IsUint64())
{
object = json.GetUint64();
}
else if (json.IsDouble())
{
object = json.GetDouble();
}
break;
}
case rapidjson::kStringType:
// we allocate with 'zone', otherwise the std::string's raw pointer gets used, which won't work as it gets destructed later on
object = msgpack::object(std::string(json.GetString(), json.GetStringLength()), zone);
break;
case rapidjson::kObjectType:
{
std::map<std::string, msgpack::object> list;
for (auto it = json.MemberBegin(); it != json.MemberEnd(); it++)
{
msgpack::object newObject;
ConvertToMsgPack(it->value, newObject, zone);
list.insert({ it->name.GetString(), newObject });
}
object = msgpack::object(list, zone);
break;
}
case rapidjson::kArrayType:
{
std::vector<msgpack::object> list;
for (auto it = json.Begin(); it != json.End(); it++)
{
msgpack::object newObject;
ConvertToMsgPack(*it, newObject, zone);
list.push_back(newObject);
}
object = msgpack::object(list, zone);
break;
}
default:
object = msgpack::type::nil();
break;
}
}