本文整理汇总了C++中JSONValue::HasChild方法的典型用法代码示例。如果您正苦于以下问题:C++ JSONValue::HasChild方法的具体用法?C++ JSONValue::HasChild怎么用?C++ JSONValue::HasChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONValue
的用法示例。
在下文中一共展示了JSONValue::HasChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadFile
int LevelManager::loadFile(const std::string& file) {
JSONValue *fileData = JSON::Parse(file);
int retval = 0;
if(fileData && fileData->HasChild("levels")){
for(JSONValue* val : fileData->Child("levels")->AsArray()){
++retval;
levelNames.push_back(val->Child("name")->AsString());
levelList.push_back(val);
planetDataList.push_back(fileData->Child("Planets"));
}
}
delete fileData;
return retval;
}
示例2: addChildFromJSON
void addChildFromJSON(
JSONValue* jv,
UIComponent* curParent,
bool isFloating = false
) {
int i;
int j;
int curIcon = 0;
JSONValue* curTempl = NULL;
if (
jv->HasChild("template")
) {
if (
jvTemplates->HasChild(jv->Child("template")->string_value)
) {
curTempl = jvTemplates->Child(jv->Child("template")->string_value);
}
else {
cout << "invalid template \n";// << jv->Child("template")->string_value << "\n";
}
}
for (i = 0; i < E_GST_LENGTH; i++) {
guiStringValues[i] = "";
}
for (i = 0; i < E_GFT_LENGTH; i++) {
guiFloatValues[i] = 0.0f;
}
guiFloatValues[E_GFT_HASBACKGROUND] = 1.0;
guiFloatValues[E_GFT_SINGLELINE] = 1.0;
guiStringValues[E_GST_SS] = "defaultSS";
for (j = 0; j < 2; j++) {
if (curTempl != NULL) {
for (i = 0; i < E_GST_LENGTH; i++) {
if (
curTempl->HasChild(guiStringTypes[i])
) {
guiStringValues[i] = curTempl->Child(guiStringTypes[i])->string_value;
}
}
for (i = 0; i < E_GFT_LENGTH; i++) {
if (
curTempl->HasChild(guiFloatTypes[i])
) {
guiFloatValues[i] = curTempl->Child(guiFloatTypes[i])->number_value;
}
}
}
curTempl = jv;
}
guiFloatValues[E_GFT_LAYER] = max(guiFloatValues[E_GFT_LAYER],(float)(curParent->layer));
UIComponent* newParent = curParent->addChild(
curParent->nodeId,
nodeCount,
guiStringValues,
guiFloatValues,
isFloating,
jv
);
nodeCount++;
int numChildren = 0;
int numFloatingChildren = 0;
int numDataChildren = 0;
int numFilters = 0;
JSONValue* jvChildren = NULL;
JSONValue* jvFloatingChildren = NULL;
JSONValue* jvChildTemplate = NULL;
JSONValue* jvFilter = NULL;
JSONValue* curFilter = NULL;
JSONValue* jvData = NULL;
JSONValue* jvDataRoot = NULL;
JSONValue* curData = NULL;
if (jv->HasChild("children")) {
jvChildren = jv->Child("children");
numChildren = jvChildren->CountChildren();
}
for (i = 0; i < numChildren; i++) {
addChildFromJSON(jvChildren->Child(i),newParent, false);
}
if (jv->HasChild("floatingChildren")) {
jvFloatingChildren = jv->Child("floatingChildren");
//.........这里部分代码省略.........