本文整理汇总了C++中rapidjson::Value::Size方法的典型用法代码示例。如果您正苦于以下问题:C++ Value::Size方法的具体用法?C++ Value::Size怎么用?C++ Value::Size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rapidjson::Value
的用法示例。
在下文中一共展示了Value::Size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
示例2: 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");
}
}
示例3: conversion_error
template<class OutputIterator> inline void
tws::core::copy_string_array(const rapidjson::Value& jvalues,
OutputIterator result)
{
if(!jvalues.IsArray())
throw conversion_error() << tws::error_description("copy_string_array: can only copy arrays of strings.");
if(jvalues.Empty())
return;
const rapidjson::SizeType nelements = jvalues.Size();
for(rapidjson::SizeType i = 0; i != nelements; ++i)
{
const rapidjson::Value& jelement = jvalues[i];
if(!jelement.IsString())
throw conversion_error() << tws::error_description("copy_string_array: only string elements are allowed in array.");
if(jelement.IsNull())
continue;
*result++ = jelement.GetString();
}
}
示例4: 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;
}
示例5: fromJson
bool fromJson(const rapidjson::Value &v, Vec<ElementType, Size> &dst)
{
if (!v.IsArray()) {
dst = Vec<ElementType, Size>(as<ElementType>(v));
return true;
}
ASSERT(v.Size() == 1 || v.Size() == Size,
"Cannot convert Json Array to vector: Invalid size. Expected 1 or %d, received %d", Size, v.Size());
if (v.Size() == 1)
dst = Vec<ElementType, Size>(as<ElementType>(v[0u]));
else
for (unsigned i = 0; i < Size; ++i)
dst[i] = as<ElementType>(v[i]);
return true;
}
示例6: addElemsToArray
void SuperastCPP::addElemsToArray(rapidjson::Value& parentValue,
rapidjson::Value& elemsValue) {
assert(parentValue.IsArray());
assert(elemsValue.IsArray());
for (unsigned i = 0; i < elemsValue.Size(); ++i) {
parentValue.PushBack(elemsValue[i], allocator);
}
}
示例7: system_error
std::array<T, Size> get_array(const rapidjson::Value& arr)
{
if (arr.IsArray())
{
assert(arr.Size() == Size);
std::array<T, Size> ret;
for (rapidjson::SizeType i = 0; i < arr.Size(); i++)
{
ret[i] = get_value<T>(arr[i]);
}
return ret;
}
else
{
throw std::system_error(std::error_code(), "Parse error.");
}
}
示例8: values
void OptionParser::values(rapidjson::Value& arrayValue, std::vector<std::string>& var) {
if (!arrayValue.IsArray()) {
return;
}
for (int i = 0; i < arrayValue.Size(); i++) {
var.push_back(arrayValue[i].GetString());
}
}
示例9: parseScale
//-----------------------------------------------------------------------------------
void HlmsJsonPbs::parseScale( const rapidjson::Value &jsonArray, Vector4 &offsetScale )
{
const rapidjson::SizeType arraySize = std::min( 2u, jsonArray.Size() );
for( rapidjson::SizeType i=0; i<arraySize; ++i )
{
if( jsonArray[i].IsNumber() )
offsetScale[i+2u] = static_cast<float>( jsonArray[i].GetDouble() );
}
}
示例10: ParseRange
bool JSASTNode::ParseRange(const rapidjson::Value& value)
{
assert(value.IsArray() && value.Size() == 2);
rangeStart_ = value[SizeType(0)].GetInt();
rangeEnd_ = value[SizeType(1)].GetInt();
return true;
}
示例11: node_set_flip
static void node_set_flip(cocos2d::Sprite *node, const rapidjson::Value &value)
{
if(value.IsArray() && value.Size() >= 2)
{
bool flipX, flipY;
value[0u] >> flipX;
value[1] >> flipY;
node->setFlipX(flipX);
node->setFlipY(flipY);
}
示例12: checkObjectExist_json
bool DictionaryHelper::checkObjectExist_json(const rapidjson::Value &root, int index)
{
bool bRet = false;
do {
CC_BREAK_IF(root.IsNull());
CC_BREAK_IF(!root.IsArray());
CC_BREAK_IF(index < 0 || root.Size() <= (unsigned int )index);
bRet = true;
} while (0);
return bRet;
}
示例13: retVal
//-----------------------------------------------------------------------------------
inline Vector3 HlmsJsonPbs::parseVector3Array( const rapidjson::Value &jsonArray )
{
Vector3 retVal( Vector3::ZERO );
const rapidjson::SizeType arraySize = std::min( 3u, jsonArray.Size() );
for( rapidjson::SizeType i=0; i<arraySize; ++i )
{
if( jsonArray[i].IsNumber() )
retVal[i] = static_cast<float>( jsonArray[i].GetDouble() );
}
return retVal;
}
示例14: detectEquipFlg
// 装備状態の確認
bool GameEventHelper::detectEquipFlg(rapidjson::Value& json, bool negative)
{
bool detection { false };
for(int i { 0 }; i < json.Size(); i++)
{
detection = PlayerDataManager::getInstance()->getLocalData()->isEquipedItem(stoi(json[i].GetString()));
if(negative) detection = !detection;
if(!detection) break;
}
return detection;
}
示例15: initGridData
void BgMap::initGridData(rapidjson::Value & arr)
{
m_grid = new unsigned char*[m_gridCol];
for (unsigned int i=0; i<m_gridCol; i++)
{
m_grid[i] = new unsigned char[m_gridRow];
}
int size = arr.Size();
for (unsigned int i=0; i<size; i++)
{
m_grid[i/m_gridRow][i%m_gridRow] = arr[i].GetInt();
}
}