本文整理汇总了C++中rapidjson::Value::GetInt方法的典型用法代码示例。如果您正苦于以下问题:C++ Value::GetInt方法的具体用法?C++ Value::GetInt怎么用?C++ Value::GetInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rapidjson::Value
的用法示例。
在下文中一共展示了Value::GetInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrintValue
void PrintValue(rapidjson::Value &value)
{
rapidjson::Type type = value.GetType();
if (type == rapidjson::Type::kNumberType)
{
printf("%d", value.GetInt());
}
else if (type == rapidjson::Type::kStringType)
{
printf("%s", value.GetString());
}
else if (type == rapidjson::Type::kTrueType)
{
printf("가능");
}
else if (type == rapidjson::Type::kFalseType)
{
printf("불가능");
}
else if (type == rapidjson::Type::kArrayType)
{
for (int i = 0; i < value.Size(); i++)
{
PrintValue(value[i]);
if (i < value.Size() - 1)
printf(", ");
}
printf("\n");
}
else if (type == rapidjson::Type::kObjectType)
{
for (auto iter = value.MemberBegin(); iter != value.MemberEnd(); iter++)
{
rapidjson::Value &member = iter->value;
std::string name = iter->name.GetString();
if (member.GetType() == rapidjson::Type::kObjectType || member.GetType() == rapidjson::Type::kArrayType)
{
printf("\n- %s -\n", name.c_str());
PrintValue(member);
}
else
{
printf("%s : ", name.c_str());
PrintValue(member);
printf("\n");
}
}
}
else
{
printf("Null");
}
}
示例2: ToJSONValue
// Convert rapidjson value to JSON value.
static void ToJSONValue(JSONValue& jsonValue, const rapidjson::Value& rapidjsonValue)
{
switch (rapidjsonValue.GetType())
{
case kNullType:
// Reset to null type
jsonValue.SetType(JSON_NULL);
break;
case kFalseType:
jsonValue = false;
break;
case kTrueType:
jsonValue = true;
break;
case kNumberType:
if (rapidjsonValue.IsInt())
jsonValue = rapidjsonValue.GetInt();
else if (rapidjsonValue.IsUint())
jsonValue = rapidjsonValue.GetUint();
else
jsonValue = rapidjsonValue.GetDouble();
break;
case kStringType:
jsonValue = rapidjsonValue.GetString();
break;
case kArrayType:
{
jsonValue.Resize(rapidjsonValue.Size());
for (unsigned i = 0; i < rapidjsonValue.Size(); ++i)
{
ToJSONValue(jsonValue[i], rapidjsonValue[i]);
}
}
break;
case kObjectType:
{
jsonValue.SetType(JSON_OBJECT);
for (rapidjson::Value::ConstMemberIterator i = rapidjsonValue.MemberBegin(); i != rapidjsonValue.MemberEnd(); ++i)
{
JSONValue& value = jsonValue[String(i->name.GetString())];
ToJSONValue(value, i->value);
}
}
break;
default:
break;
}
}
示例3: 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;
}
示例4: setProperty
bool UIFrameViewLoader::setProperty(cocos2d::Node *p, const std::string & name, const rapidjson::Value & value, rapidjson::Value & properties)
{
uilib::FrameView *image = dynamic_cast<uilib::FrameView*>(p);
CCAssert(image, "UIFrameViewLoader::setProperty");
if (name == "image")
{
if(value.IsString())
{
image->setImage(value.GetString());
}
}
else if(name == "customSizeEnable")
{
if(value.IsBool())
{
image->setCustomSizeEnable(value.GetBool());
}
}
else if(name == "capInsets")
{
cocos2d::Rect rc;
if(helper::parseValue(value, rc))
{
image->setCapInsets(rc);
}
}
else if(name == "color")
{
cocos2d::Color3B cr;
if(helper::parseValue(value, cr))
{
image->setColor(cr);
}
}
else if(name == "opacity")
{
if(value.IsInt())
{
image->setOpacity(value.GetInt());
}
}
else
{
return base_class::setProperty(p, name, value, properties);
}
return true;
}
示例5: read_print_for_array
void Json_Parser::read_print_for_array(rapidjson::Value &va,int i){
if (va.IsBool()) {
const bool flag=va.GetBool();
CCLOG("%d:%d",i,flag);
}
else if (va.IsDouble()) {
const double flag=va.GetDouble();
CCLOG("%d:%f",i,flag);
}
else if (va.IsInt()) {
const int flag=va.GetInt();
CCLOG("%d:%d",i,flag);
}
else if (va.IsString()) {
const std::string flag=va.GetString();
CCLOG("%d:%s",i,flag.c_str());
}
else if (va.IsNull()) {
CCLOG("%d:null",i);
}
else if(va.IsObject())
{
CCLOG("obj----------%d",i);
auto it=va.MemberBegin();
for (;it!=va.MemberEnd();it++) {
if (va.HasMember(it->name)) {
read_print(va,it->name.GetString());
}
}
}
else if(va.IsArray())
{
CCLOG("array-------%d",i);
for (int i=0; i<va.Size();i++) {
read_print_for_array(va[i],i);
}
}
}
示例6: read_to_map_for_array
void Json_Parser::read_to_map_for_array(cocos2d::ValueVector &temp,rapidjson::Value &va,int i){
CCLOG("dex:%d",i);
if (va.IsBool()) {
const bool flag=va.GetBool();
temp.push_back(Value(flag));
}
else if (va.IsDouble()) {
const double flag=va.GetDouble();
temp.push_back(Value(flag));
}
else if (va.IsInt()) {
const int flag=va.GetInt();
temp.push_back(Value(flag));
}
else if (va.IsString()) {
const std::string flag=va.GetString();
temp.push_back(Value(flag));
// CCLOG("++:%d",temp.size());
}
else if (va.IsNull()) {
temp.push_back(Value(nullptr));
}
else if(va.IsObject())
{
cocos2d::ValueMap temp2;
auto it=va.MemberBegin();
for (;it!=va.MemberEnd();it++) {
if (va.HasMember(it->name)) {
read_to_map(temp2,va,it->name.GetString());
}
}
temp.push_back(Value(temp2));
// CCLOG("mapinvectro层:%lu",temp2.size());
}
else if(va.IsArray())
{
cocos2d::ValueVector temp2;
for (int i=0; i<va.Size();i++) {
read_to_map_for_array(temp2,va[i],i);
}
temp.push_back(Value(temp2));
// CCLOG("vectorinvectro层:%lu",temp.size());
}
}
示例7: system_error
std::int32_t get_value(const rapidjson::Value& root, const char* key)
{
if (key != nullptr)
{
if (root.HasMember(key) && root[key].IsInt())
return root[key].GetInt();
else
throw std::system_error(std::error_code(), "Parse error.");
}
else
{
if (root.IsInt())
return root.GetInt();
else
throw std::system_error(std::error_code(), "Parse error.");
}
}
示例8: set_value
bool MetaDataValue::set_value(const rapidjson::Value& v)
{
if( v.IsDouble())
{
_vPtr = new double(v.GetDouble());
}
else if(v.IsBool())
{
_vPtr = new bool(v.GetBool());
}
else if(v.IsInt())
{
_vPtr = new int(v.GetInt());
}
else if(v.IsString())
{
_vPtr = new std::string(v.GetString());
}
else
return false;
return true;
}
示例9: parseValue
static void parseValue(SettingValue &value, const rapidjson::Value &json_val)
{
if (json_val.IsInt())
value = json_val.GetInt();
else if (json_val.IsString())
value = std::string(json_val.GetString(), json_val.GetStringLength());
else if (json_val.IsBool())
value = json_val.GetBool();
else if (json_val.IsArray())
{
SettingList value_list;
for (auto it = json_val.Begin(); it != json_val.End(); ++it)
{
SettingValue child_val;
parseValue(child_val, *it);
value_list.push_back(child_val);
}
value = value_list;
}
else if (json_val.IsObject())
{
SettingMap value_map;
for (auto it = json_val.MemberBegin(); it != json_val.MemberEnd(); ++it)
{
SettingValue child_val;
parseValue(child_val, it->value);
value_map[it->name.GetString()] = child_val;
}
value = value_map;
}
else
throw std::runtime_error("Unexpected JSON value type.");
}
示例10: 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;
}
}
示例11:
template<> inline int
conf_getter<int>(const rapidjson::Value & value)
{
return value.GetInt();
}
示例12: detectFlg
// フラグの確認
bool GameEventHelper::detectFlg(rapidjson::Value& json, bool negative)
{
bool detection { false };
if (!json.IsArray())
{
// 自分自身のステータスを確認
detection = PlayerDataManager::getInstance()->getLocalData()->checkEventStatus(DungeonSceneManager::getInstance()->getLocation().map_id, DungeonSceneManager::getInstance()->getRunningEventId(), json.GetInt());
if(negative) detection = !detection;
}
else if (!json[0].IsArray())
{
detection = PlayerDataManager::getInstance()->getLocalData()->checkEventStatus(stoi(json[0].GetString()), stoi(json[1].GetString()), json[2].GetInt());
if(negative) detection = !detection;
}
else
{
// 複数の場合
for(int i { 0 }; i < json.Size(); i++)
{
detection = PlayerDataManager::getInstance()->getLocalData()->checkEventStatus(stoi(json[i][0].GetString()), stoi(json[i][1].GetString()), json[i][2].GetInt());
if(negative) detection = !detection;
if(!detection) break;
}
}
return detection;
}
示例13: Deserialize_Int
int Deserialize_Int(const rapidjson::Value& value)
{
assert(value.IsNumber());
return value.GetInt();
}
示例14: if
void json2tvalue(QVariant & output, const rapidjson::Value & input, int itype)
{
if(input.IsNull())
{
output.clear();
}
else if(input.IsInt64())
{
output = QVariant(input.GetInt64());
}
else if(input.IsInt())
{
output = QVariant(input.GetInt());
}
else if(input.IsDouble())
{
output = QVariant(input.GetDouble());
}
else if(input.IsBool())
{
output = QVariant(input.GetBool());
}
else if(input.IsString())
{
output = QVariant(QString(input.GetString()));
}
else if(input.IsArray())
{
switch(itype)
{
case QVariant::Point:
{
assert(input.Size() == 2);
output = QPoint(input[0u].GetDouble(), input[1].GetDouble());
break;
}
case QVariant::PointF:
{
assert(input.Size() == 2);
output = QPointF(input[0u].GetDouble(), input[1].GetDouble());
break;
}
case QVariant::Size:
{
assert(input.Size() == 2);
output = QSize(input[0u].GetDouble(), input[1].GetDouble());
break;
}
case QVariant::SizeF:
{
assert(input.Size() == 2);
output = QSizeF(input[0u].GetDouble(), input[1].GetDouble());
break;
}
case QVariant::Rect:
{
assert(input.Size() == 4);
output = QRect(input[0u].GetDouble(), input[1].GetDouble(), input[2].GetDouble(), input[3].GetDouble());
break;
}
case QVariant::RectF:
{
assert(input.Size() == 4);
output = QRectF(input[0u].GetDouble(), input[1].GetDouble(), input[2].GetDouble(), input[3].GetDouble());
break;
}
case QVariant::Vector2D:
{
assert(input.Size() == 2);
output = QVector2D(input[0u].GetDouble(), input[1].GetDouble());
break;
}
case QVariant::Vector3D:
{
assert(input.Size() == 3);
output = QVector3D(input[0u].GetDouble(), input[1].GetDouble(), input[2].GetDouble());
break;
}
case QVariant::Vector4D:
{
assert(input.Size() == 4);
output = QVector4D(input[0u].GetDouble(), input[1].GetDouble(), input[2].GetDouble(), input[3].GetDouble());
break;
}
case QVariant::Color:
{
assert(input.Size() == 4);
output = QColor(input[0u].GetDouble(), input[1].GetDouble(), input[2].GetDouble(), input[3].GetDouble());
break;
}
case QVariant::StringList:
{
QStringList list;
list.reserve(input.Size());
for(rapidjson::Value::ConstValueIterator it = input.Begin(); it != input.End(); ++it)
{
QString tmp(it->GetString());
list.append(tmp);
}
//.........这里部分代码省略.........
示例15: clone_value
bool clone_value(rapidjson::Value & output, const rapidjson::Value & input, rapidjson::Value::AllocatorType & allocator)
{
if(&output == &input)
{
return false;
}
if(input.IsNull())
{
output.SetNull();
}
else if(input.IsInt64())
{
output.SetInt(input.GetInt64());
}
else if(input.IsInt())
{
output.SetInt(input.GetInt());
}
else if(input.IsDouble())
{
output.SetDouble(input.GetDouble());
}
else if(input.IsBool())
{
output.SetBool(input.GetBool());
}
else if(input.IsString())
{
output.SetString(input.GetString(), input.GetStringLength(), allocator);
}
else if(input.IsArray())
{
rapidjson::Value temp;
output.SetArray();
output.Reserve(input.Size(), allocator);
for(rapidjson::SizeType i = 0; i < input.Size(); ++i)
{
clone_value(temp, input[i], allocator);
output.PushBack(temp, allocator);
}
}
else if(input.IsObject())
{
output.SetObject();
rapidjson::Value key, val;
for(rapidjson::Value::ConstMemberIterator it = input.MemberBegin();
it != input.MemberEnd(); ++it)
{
clone_value(key, it->name, allocator);
clone_value(val, it->value, allocator);
output.AddMember(key, val, allocator);
}
}
else
{
assert(false && "shuldn't execute to here.");
return false;
}
return true;
}