本文整理汇总了C++中json::value::Members::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Members::begin方法的具体用法?C++ Members::begin怎么用?C++ Members::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类json::value::Members
的用法示例。
在下文中一共展示了Members::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadSceneSettings
//-----------------------------------------------------------------------------------
void EngineConfig::LoadSceneSettings(Json::Value root, Json::Reader reader)
{
Json::Value settings = root["scenes"];
int componentCount = settings.size();
for( int i=0; i< componentCount; ++i )
{
Json::Value componentVal = settings[i];
Json::Value::Members members = componentVal.getMemberNames();
map<std::string, std::string> mapValues;
for( Json::Value::Members::iterator it = members.begin(); it != members.end(); ++it)
{
std::string memberName = *it;
std::string value = componentVal[memberName].asString();
mapValues[memberName] = value;
}
std::string sceneName = mapValues["name"];
std::string fileName = mapValues["file"];
SceneData *sceneData = new SceneData( sceneName, fileName );
scenes[sceneName] = sceneData;
}
settings = root["startscene"];
startScene = scenes[settings.asCString()];
}
示例2: jsonValueToVariant
FB::variant jsonValueToVariant( Json::Value root )
{
Json::Value def;
if (root.isString())
return root.asString();
else if (root.isBool())
return root.asBool();
else if (root.isDouble())
return root.asDouble();
else if (root.isInt())
return root.asInt();
else if (root.isUInt())
return root.asUInt();
else if (root.isNull())
return FB::FBNull();
else if (root.isArray()) {
FB::VariantList outList;
for (size_t i = 0; i < root.size(); ++i) {
outList.push_back(jsonValueToVariant(root.get(i, def)));
}
return outList;
} else if (root.isObject()) {
Json::Value::Members members = root.getMemberNames();
FB::VariantMap outMap;
for (Json::Value::Members::iterator it = members.begin(); it != members.end(); ++it)
{
outMap[*it] = jsonValueToVariant(root.get(*it, def));
}
return outMap;
} else {
return FB::FBVoid();
}
}
示例3: updateConfigurationMap
/**
* Updates a configuration map with the given json node.
*
* @param configurationMap The configuration map to be updated.
* @param currentNode The node to be used to update the configuration map.
*/
void JsonConfigurationParser::updateConfigurationMap(ConfigurationMap *configurationMap, const Json::Value ¤tNode) {
// retrieves the menber names
Json::Value::Members currentNodeMembers = currentNode.getMemberNames();
// retrieves the current node members iterator
Json::Value::Members::iterator currentNodeMembersIterator = currentNodeMembers.begin();
// itearates over all the current node members
while(currentNodeMembersIterator != currentNodeMembers.end()) {
// retrieves the property name
std::string &propertyName = *currentNodeMembersIterator;
// retrieves the property value
Json::Value propertyValue = currentNode[propertyName];
// creates the configuration value
ConfigurationValue *configurationValue = this->createConfigurationValue(propertyValue);
// sets the propery in the configuration map
configurationMap->setProperty(propertyName, configurationValue);
// increments the current node members iterator
currentNodeMembersIterator++;
}
}
示例4: importParameters
void JsonParameters::importParameters(Json::Value parametersImport)
{
if (parametersImport.isObject()) {
Json::Value::Members members = parametersImport.getMemberNames();
Json::Value::Members::iterator it;
for (it=members.begin(); it!=members.end(); it++) {
string name = *it;
JsonParameter *parameter = getParameter(name);
if (parameter != NULL) {
if (parameter->canDeserialize(parametersImport[name])) {
parameter->deserialize(parametersImport[name]);
} else {
std::cerr << "Can't load parameter " << name << std::endl;
}
} else {
std::cerr << "Non-existent parameter: " << name << std::endl;
}
}
} else {
if (!parametersImport.isNull()) {
std::cerr << "Parameters values should be an object" << std::endl;
}
}
}
示例5: Load
void SceneLoader::Load(const char* strFileName, GameObject *rootGameObject)
{
GameObject *pGo = 0;
Json::Value root;
Json::Reader reader;
const char* jsonText = ReadFileIntoString( strFileName );
if( !reader.parse( jsonText, root ) )
{
return;
}
Json::Value componentsVal = root["objects"];
int componentCount = componentsVal.size();
for( int i=0; i< componentCount; ++i )
{
Json::Value componentVal = componentsVal[i];
Json::Value::Members members = componentVal.getMemberNames();
std::map<std::string, std::string> mapParams;
for( Json::Value::Members::iterator it = members.begin(); it != members.end(); ++it)
{
std::string memberName = *it;
std::string value = componentVal[memberName].asString();
mapParams[memberName] = value;
}
CreateSceneObject( rootGameObject, mapParams );
}
}
示例6: getConfigOfGoods
configGoodsItem* CData::getConfigOfGoods(int tempid)
{
if(m_config_goods_dic->count() < 1)
{
// const char * path=FileUtils::getInstance()->fullPathForFilename("itemconfig.json").c_str();
// ifstream ifs;
// ifs.open(path);
// assert(ifs.is_open());
Json::Reader reader;
Json::Value root;
Json::Value items;
Json::Value::Members members;
// Json::Value::iterator it;
Json::Value::Members::iterator it;
string path = FileUtils::getInstance()->fullPathForFilename("item.json");
__String* str = __String::createWithContentsOfFile(path.c_str());
if(reader.parse(str->getCString(), root)){
members = root.getMemberNames();
it = members.begin();
while (it != members.end()) {
items = root[std::string(*it)];
configGoodsItem * item= new configGoodsItem();
char inttostr[20]="";
sprintf(inttostr, "%d",tempid);
item->bodytype=items["bodyType"].asInt();
item->name=items["name"].asString();
item->pinzhi=items["baseQuality"].asInt();
item->des=items["description"].asString();
item->tempid = items["id"].asInt();
item->icon = items["icon"].asInt();
item->maxexp = items["maxexp"].asInt();
item->growTemp = items["growTemp"].asInt();
item->comprice = items["comprice"].asInt();
item->compound = items["compound"].asInt();
m_config_goods_dic->setObject(item, item->tempid);
it++;
}
// ifs.close();
}
}
return (configGoodsItem*)m_config_goods_dic->objectForKey(tempid);
}
示例7: if
void Registry::Interface::_parseWidgets(Json::Value& value,
const Engine::Object& loader) {
unsigned int index = _spans.size() - 1;
for (Json::Value::iterator it = value["widgets"].begin();
it != value["widgets"].end();
++it) {
if ((*it).isObject()) {
if ((*it).isMember("widget")) {
_spans[index]++;
const char* widget_name = (*it)["widget"].asCString();
const Registry::Widget& widget = loader.loadWidget(widget_name);
Apsis::World::Object& object = *(new Apsis::World::Object);
if ((*it).isMember("properties")) {
Json::Value::Members members = (*it)["properties"].getMemberNames();
for (Json::Value::Members::iterator property_it = members.begin();
property_it != members.end();
++property_it) {
const char* name = (*property_it).c_str();
unsigned int property_id = Apsis::Registry::Property::id(name);
if ((*it)["properties"][name].isDouble()) {
object.set(property_id, (*it)["properties"][name].asDouble());
}
else if ((*it)["properties"][name].isString()) {
object.set(property_id, (*it)["properties"][name].asCString());
}
else if ((*it)["properties"][name].isIntegral()) {
object.set(property_id, (long)(*it)["properties"][name].asInt());
}
}
}
// Defaults
for (unsigned int i = 0; i < widget.propertyCount(); i++) {
const char* name = widget.propertyName(i);
const char* def = widget.propertyDefault(i);
if (!object.has(name)) {
object.set(name, def);
}
}
// Push to tree
_widgets.push_back(&widget);
_objects.push_back(&object);
// Child windows
_spans.push_back(0);
if ((*it).isMember("widgets")) {
_parseWidgets(*it, loader);
}
}
}
else {
throw "Interface file's 'widgets' section is malformed.";
}
}
}
示例8: test_Parse
bool CTestjsoncpp::test_Parse()
{
std::wstring wstrJson = ReleaseJsonStr();
std::string strJson = wstr2str(wstrJson, CP_UTF8);
Json::Reader jsonReader;
Json::Value root;
jsonReader.parse(strJson, root);
std::string strresult = root["result"].asString();
std::cout << "result:" << strresult << std::endl;
std::cout << "data:" << std::endl;
Json::Value jvData = root["data"];
if(jvData.isArray())
{
std::cout << "[" << std::endl;
//item
for (Json::Value::iterator it = jvData.begin(); it != jvData.end(); ++it)
{
std::cout << "{" << std::endl;
Json::Value item = *it;
Json::Value::Members memItem = item.getMemberNames();
//mem in item
for (Json::Value::Members::iterator itItem = memItem.begin(); itItem != memItem.end(); ++itItem)
{
std::string strKey = *itItem;
std::string strValue = item[strKey].asString();
std::cout << strKey << ":" << strValue << std::endl;
}
std::cout << "}" << std::endl;
}
std::cout << "]" << std::endl;
}
return false;
}
示例9: load
int Database::load()
{
if (open() != 0)
return -1;
Json::Reader reader;
if (!reader.parse(file_in, root, false)){
ERR("Json reader parse error, maybe empty file\n");
root.clear();
return -1;
}
try {
Json::Value::Members member = root.getMemberNames();
Json::Value::Members::iterator it = member.begin();
for (; it != member.end(); it++){
if (load_obj(string_to_wstring(*it)) == NULL)
ERR("Load object error\n");
}
}
catch (Json::LogicError & e) {
cout << e.what() << endl;
ERR("Json file data not correct\n");
close_json();
return -1;
}
return 0;
}
示例10: 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);
}
}
}
示例11: init
void JsonTree::init( const string &key, const Json::Value &value, bool setType, NodeType nodeType, ValueType valueType )
{
mKey = key;
mNodeType = nodeType;
mParent = 0;
mValue = "";
mValueType = valueType;
if( ! value.isNull() && ( value.isArray() || value.isObject() ) ) {
if( value.isArray() ) {
mNodeType = NODE_ARRAY;
for ( uint32_t i = 0; i < value.size(); i++ ) {
pushBack( JsonTree( "", value[ i ] ) );
}
}
else if( value.isObject() ) {
mNodeType = NODE_OBJECT;
Json::Value::Members members = value.getMemberNames();
for( Json::Value::Members::const_iterator memberIt = members.begin(); memberIt != members.end(); ++memberIt ) {
string key = *memberIt;
pushBack( JsonTree( key, value[ key ] ) );
}
}
}
else {
if( value.isBool() ) {
mValue = toString( value.asBool() );
if( setType ) {
mValueType = VALUE_BOOL;
}
}
else if ( value.isDouble() ) {
mValue = toString( value.asDouble() );
if ( setType ) {
mValueType = VALUE_DOUBLE;
}
}
else if ( value.isInt() ) {
mValue = toString( value.asInt() );
if ( setType ) {
mValueType = VALUE_INT;
}
}
else if ( value.isString() ) {
mValue = toString( value.asString() );
if ( setType ) {
mValueType = VALUE_STRING;
}
}
else if ( value.isUInt() ) {
mValue = toString( value.asUInt() );
if ( setType ) {
mValueType = VALUE_UINT;
}
}
}
}
示例12: getVehicleData
bool VehicleInfo::getVehicleData(Json::Value &message,Json::Value &result)
{
Json::Value vehicle;
Json::Value data;
Json::Value params;
bool ret = false;
params = message["params"];
vehicle = g_VehicleInfoJson["vehicle"];
Json::Value::Members mem = params.getMemberNames();
for (Json::Value::Members::iterator iter = mem.begin(); iter != mem.end(); iter++) {
std::string infoitem = std::string(*iter);
if (infoitem != "appID" && infoitem != "request") {
Json::Value require = params[infoitem];
if (!require.isBool())
continue;
if (!require.asBool())
continue;
if (vehicle.isMember(infoitem))
data[infoitem] = vehicle[infoitem];
ret = true;
}
}
if (ret) {
Json::Value::Members mem = data.getMemberNames();
for (Json::Value::Members::iterator iter = mem.begin(); iter != mem.end(); iter++) {
std::string infoitem = std::string(*iter);
result[infoitem] = data[infoitem];
}
result["code"] = 0;
result["method"] = "VehicleInfo.GetVehicleData";
} else {
result["message"] = "Params rpc, are not avaliable";
result["code"] = 9;
result["method"]="VehicleInfo.GetVehicleData";
}
return ret;
}
示例13: getConfigOfMonster
configMonsterItem* CData::getConfigOfMonster(int tempid)
{
if(m_config_monster_dic->count() < 1)
{
// const char * path=FileUtils::getInstance()->fullPathForFilename("hero.json").c_str();
// ifstream ifs;
// ifs.open(path);
// assert(ifs.is_open());
Json::Reader reader;
Json::Value root;
Json::Value items;
Json::Value::Members members;
// Json::Value::iterator it;
Json::Value::Members::iterator it;
string path = FileUtils::getInstance()->fullPathForFilename("monster.json");
__String* str = __String::createWithContentsOfFile(path.c_str());
if(reader.parse(str->getCString(), root)){
members = root.getMemberNames();
it = members.begin();
while (it != members.end()) {
items = root[std::string(*it)];
configMonsterItem * item= new configMonsterItem();
char inttostr[20]="";
sprintf(inttostr, "%d",tempid);
item->id = items["id"].asInt();
item->nickname = items["nickname"].asString();//" : "蛮夷邪士",
m_config_monster_dic->setObject(item, item->id);
it++;
}
}
}
return (configMonsterItem*)m_config_monster_dic->objectForKey(tempid);
}
示例14: loadConfig
int loadConfig(const char* filepath, Config& config)
{
std::ifstream confFile;
confFile.open(filepath);
if (!confFile.is_open())
{
cerr << "could not open config file: " << filepath << endl;
return -1;
}
else
{
cout << "config file opened" << endl;
}
confFile.seekg(0, ios::end);
int fileLen = confFile.tellg();
char *confStr = NULL;
confStr = new char[fileLen+1];
confFile.seekg(0, ios::beg);
confFile.get(confStr, fileLen+1);
//confStr[fileLen] = 0;
Json::Reader reader;
Json::Value confRoot;
if (!reader.parse(confStr, confRoot))
{
cerr << "error parsing config file: " << endl << reader.getFormattedErrorMessages() << endl;
return -2;
}
else
{
config.com.num = confRoot["COM"]["num"].asInt();
config.com.baud = confRoot["COM"]["baud"].asInt();
config.sock.port = confRoot["socket"]["port"].asInt();
config.sock.rbuff = confRoot["socket"]["read_buffer"].asInt();
config.sock.wbuff = confRoot["socket"]["send_buffer"].asInt();
Json::Value::Members styleNames = confRoot["style"].getMemberNames();
for (Json::Value::Members::iterator itr = styleNames.begin(); itr != styleNames.end();itr++)
{
config.style.styles.insert(map<string, string>::value_type(*itr, confRoot["style"][*itr].asString()));
}
}
confFile.close();
delete[] confStr;
return 0;
}
示例15: reader
Resource *ResourceManager::_load(std::string filename)
{
Json::Reader reader(Json::Features::strictMode());
Json::Value root;
if (not reader.parse(readFile(filename), root))
{
std::cout << reader.getFormattedErrorMessages() << std::endl;
return NULL;
}
std::unordered_map<std::string, ResPtr<Resource> > externalResources;
if (root.isMember("external resources"))
{
Json::Value externResVal = root["external resources"];
Json::Value::Members members = externResVal.getMemberNames();
for (Json::Value::Members::iterator it = members.begin(); it != members.end(); ++it)
{
std::string name = *it;
ResPtr<Resource> resource = load(externResVal[name].asString());
externalResources[name] = resource;
}
}
std::string resourceType = root["type"].asString();
if (resourceType == "texture")
{
return loadTexture(getMember(root, "texture"), externalResources);
} else if (resourceType == "model")
{
return loadModel(getMember(root, "model"), externalResources);
} else if (resourceType == "mesh")
{
return loadMesh(getMember(root, "mesh"), externalResources);
} else if (resourceType == "shader")
{
return loadShader(getMember(root, "shader"), externalResources);
} else if (resourceType == "material")
{
return loadMaterial(getMember(root, "material"), externalResources);
} else
{
throw std::runtime_error("Unknown resource type.");
}
}