本文整理汇总了C++中json::value::Members类的典型用法代码示例。如果您正苦于以下问题:C++ Members类的具体用法?C++ Members怎么用?C++ Members使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Members类的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: 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;
}
示例4: 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++;
}
}
示例5: 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);
}
示例6: load_card_right_json
int CCardFieldDlg::load_card_right_json()
{
int i,idx;
Json::Value root;
Json::Reader reader;
std::ifstream input;
//input.open("e:\\works\\cardlib\\ykt.v3_1.dev\\bin\\lcsmanager\\cardright.json");
input.open((LPCTSTR)m_jsonfile);
if(input.is_open()==false)
{
AfxMessageBox("´ò¿ªÅäÖÃÎļþ´íÎó");
return -1;
}
if(reader.parse(input,root)==false)
{
std::string msg = "¶ÁÈ¡ÅäÖÃÎļþ´íÎó : " + reader.getFormatedErrorMessages();
AfxMessageBox(msg.c_str());
return -1;
}
std::string encoding = root.get("encoding","GBK").asString();
Json::Value fields = root["cardfield"];
Json::Value::Members fldid = fields.getMemberNames();
m_cardfield.clear();
for(i = 0;i < fldid.size();++i)
{
idx = atoi(fldid[i].c_str());
std::string v = fields.get(fldid[i],"Unknown").asString();
m_cardfield.insert(CARD_FILED_MAP::value_type(idx,v));
}
if(fldid.size() > m_string_len)
m_string_len = fldid.size();
// std::sort(m_cardfield.begin(),m_cardfield.end());
init_check_box();
return 0;
}
示例7: buildTasks
void QueryParser::buildTasks(
const Json::Value &query,
std::vector<std::shared_ptr<Task> > &tasks,
task_map_t &task_map) const {
Json::Value::Members members = query["operators"].getMemberNames();
std::string papiEventName = getPapiEventName(query);
for (unsigned i = 0; i < members.size(); ++i) {
Json::Value planOperationSpec = query["operators"][members[i]];
std::string typeName = planOperationSpec["type"].asString();
std::shared_ptr<PlanOperation> planOperation = QueryParser::instance().parse(
typeName, planOperationSpec);
planOperation->setEvent(papiEventName);
setInputs(planOperation, planOperationSpec);
if (auto para = std::dynamic_pointer_cast<ParallelizablePlanOperation>(planOperation)) {
para->setPart(planOperationSpec["part"].asUInt());
para->setCount(planOperationSpec["count"].asUInt());
} else {
if (planOperationSpec.isMember("part") || planOperationSpec.isMember("count")) {
throw std::runtime_error("Trying to parallelize " + typeName + ", which is not a subclass of Parallelizable");
}
}
planOperation->setOperatorId(members[i]);
if (planOperationSpec.isMember("core"))
planOperation->setPreferredCore(planOperationSpec["core"].asInt());
// check for materialization strategy
if (planOperationSpec.isMember("positions"))
planOperation->setProducesPositions(!planOperationSpec["positions"].asBool());
tasks.push_back(planOperation);
task_map[members[i]] = planOperation;
}
}
示例8: jsonParse
int jsonParse(string _s)
{
// Let's parse it
Json::Value root;
Json::Reader reader;
bool parsedSuccess = reader.parse(_s,
root,
false);
if (not parsedSuccess) {
// Report failures and their locations
// in the document.
cout << "Failed to parse JSON" << endl
<< reader.getFormatedErrorMessages()
<< endl;
return 1;
}
Json::Value::Members mem = root.getMemberNames();
Json::Value child = root[mem[0]];
cout << "name: " << mem[0] << ", child: " << child.asString() << endl;
for (int i = 1; i < mem.size(); ++i)
{
child = root[mem[i]];
cout << "name: " << mem[i] << endl;
Json::Value::Members childMem = child.getMemberNames();
cout << "\t" << "type: " << child[childMem[0]].asString() << endl;
cout << "\t" << "value: " << child[childMem[1]].asString() << endl;
cout << "\t" << "typeGen: " << child[childMem[2]].asString() << endl;
}
return 1;
}
示例9: 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;
}
}
}
示例10: 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 );
}
}
示例11: init
//virtual
bool AnimationLogic::init( const JsonValueRef json )
{
m_states.clear();
if( !json.isMember("states") || !json.isMember("events") ) return false;
for( int i=0; i< json["events"].size(); i++)
{
m_events.push_back( json["events"][i].asString() );
}
m_defaultState = json.get("default", "idle").asString();
Json::Value::Members states = json["states"].getMemberNames();
for(int i=0; i< states.size(); i++)
{
JsonValueRef stateObj = json["states"][states[i]];
Json::Value::Members events = stateObj.getMemberNames();
AnimState animState;
animState.name = states[i];
CCLOG(" animState: %s", animState.name.c_str() );
for( int j=0; j< events.size(); j++)
{
std::string newState = stateObj[ events[j] ].asString();
animState.transitionTable[ events[j] ] = newState;
CCLOG(" %s => %s", events[j].c_str(), newState.c_str() );
}
m_states[ states[i] ] = animState;
}
return true;
}
示例12: parseJsonData
bool KsCardMsg::parseJsonData(const std::string& rootname,Json::Value &root)
{
size_t i;
Json::Value::Members mbs = root.getMemberNames();
++parseLevel_;
if(parseLevel_>2)
return false;
for(i = 0;i < mbs.size(); ++i)
{
Json::Value& clt = root[mbs[i]];
std::string fullname = rootname;
if(rootname.length() > 0)
fullname += ".";
fullname += mbs[i];
if(clt.isArray() || clt.isObject())
{
if(!parseJsonData(fullname,clt))
return false;
}
else
{
msg_field_.insert(PARA_MAP_TYPE::value_type(fullname,root.get(mbs[i],"").asString()));
}
}
return true;
}
示例13: 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.";
}
}
}
示例14: SetupRegisteredUsers
void Configuration::SetupRegisteredUsers(MongooseServer& httpServer)
{
boost::mutex::scoped_lock lock(globalMutex_);
httpServer.ClearUsers();
if (!configuration_.isMember("RegisteredUsers"))
{
return;
}
const Json::Value& users = configuration_["RegisteredUsers"];
if (users.type() != Json::objectValue)
{
LOG(ERROR) << "Badly formatted list of users";
throw OrthancException(ErrorCode_BadFileFormat);
}
Json::Value::Members usernames = users.getMemberNames();
for (size_t i = 0; i < usernames.size(); i++)
{
const std::string& username = usernames[i];
std::string password = users[username].asString();
httpServer.RegisterUser(username.c_str(), password.c_str());
}
}
示例15: RegisterUserContentType
static void RegisterUserContentType()
{
if (configuration_.isMember("UserContentType"))
{
const Json::Value& parameter = configuration_["UserContentType"];
Json::Value::Members members = parameter.getMemberNames();
for (size_t i = 0; i < members.size(); i++)
{
std::string info = "\"" + members[i] + "\" = " + parameter[members[i]].toStyledString();
LOG(INFO) << "Registering user-defined attachment type: " << info;
if (!parameter[members[i]].asBool())
{
LOG(ERROR) << "Not a number in this user-defined attachment type: " << info;
throw OrthancException(ErrorCode_BadParameterType);
}
int contentType = parameter[members[i]].asInt();
try
{
RegisterUserContentType(contentType, members[i]);
}
catch (OrthancException&)
{
LOG(ERROR) << "Cannot register this user-defined attachment type: " << info;
throw;
}
}
}
}