本文整理汇总了C++中json::ValueIterator::index方法的典型用法代码示例。如果您正苦于以下问题:C++ ValueIterator::index方法的具体用法?C++ ValueIterator::index怎么用?C++ ValueIterator::index使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类json::ValueIterator
的用法示例。
在下文中一共展示了ValueIterator::index方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadConfig
bool RecpathConfig::LoadConfig(const std::string & path_to_config)
{
logD(recpath, _func_);
//m_mutex.lock();
m_configs.clear();
m_bIsEmpty = true;
Json::Value root; // will contains the root value after parsing.
Json::Reader reader;
std::ifstream config_file(path_to_config, std::ifstream::binary);
if(!config_file.good())
{
//m_mutex.unlock();
logE_(_func_, "fail to load config");
return false;
}
bool parsingSuccessful = reader.parse( config_file, root, false );
if(!parsingSuccessful)
{
//m_mutex.unlock();
logE_(_func_, "fail to parse config");
return false;
}
Json::Value configs = root["configs"];
if(configs.empty())
{
//m_mutex.unlock();
logE_(_func_, "fail to find \"configs\" section");
return false;
}
for( Json::ValueIterator itr = configs.begin() ; itr != configs.end() ; itr++ )
{
Json::Value value = (*itr);
Json::Value path = value["path"];
// Json::Value quota = value["quota"];
// Json::Value mode = value["mode"];
if(path.empty())// || quota.empty() || mode.empty())
{
m_configs.clear();
//m_mutex.unlock();
logE_(_func_, "fail to parse params for section No ", itr.index());
return false;
}
m_configs[path.asString()] = ConfigParam();
}
// dump config in log
int i = 0;
for(ConfigMap::const_iterator it = m_configs.begin(); it != m_configs.end(); ++it)
{
logD(recpath, _func_, "PathEntry ", i++);
logD(recpath, _func_, "Path: ", it->first.c_str());
// logD(recpath, _func_, "Quota: ", it->second.quota);
// logD(recpath, _func_, "Mode: ", it->second.write_mode);
}
m_configJson = root.toStyledString();
m_bIsInit = true;
//m_mutex.unlock();
return true;
}