本文整理汇总了C++中boost::property_tree::ptree::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ ptree::erase方法的具体用法?C++ ptree::erase怎么用?C++ ptree::erase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::property_tree::ptree
的用法示例。
在下文中一共展示了ptree::erase方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: upgrade_json
bool upgrade_json (unsigned version_a, boost::property_tree::ptree & tree_a)
{
auto result (false);
switch (version_a)
{
case 1:
{
rai::account account;
account.decode_account (tree_a.get<std::string> ("account"));
tree_a.erase ("account");
tree_a.put ("account", account.to_account ());
tree_a.erase ("version");
tree_a.put ("version", "2");
result = true;
}
case 2:
{
boost::property_tree::ptree rpc_l;
rpc.serialize_json (rpc_l);
tree_a.put ("rpc_enable", "false");
tree_a.put_child ("rpc", rpc_l);
tree_a.erase ("version");
tree_a.put ("version", "3");
result = true;
}
case 3:
{
auto opencl_enable_l (tree_a.get_optional<bool> ("opencl_enable"));
if (!opencl_enable_l)
{
tree_a.put ("opencl_enable", "false");
}
auto opencl_l (tree_a.get_child_optional ("opencl"));
if (!opencl_l)
{
boost::property_tree::ptree opencl_l;
opencl.serialize_json (opencl_l);
tree_a.put_child ("opencl", opencl_l);
}
tree_a.put ("version", "4");
result = true;
}
case 4:
break;
default:
throw std::runtime_error ("Unknown qt_wallet_config version");
}
return result;
}
示例2: upgrade_option
void Set::upgrade_option( bp::ptree& ptree , const std::string& prev , const std::string& curr )
{
auto opt = ptree.get_optional<std::string>( prev );
if( opt ) {
ptree.put( curr ,*opt);
ptree.erase( prev );
}
}
示例3: if
void
mergePropertyTrees (boost::property_tree::ptree &ptMerged,
const boost::property_tree::ptree &ptSecond, int level )
{
// Value or object or array
if (level > 0 && ptSecond.empty() ) {
// Copy value
ptMerged = ptSecond;
} else if (level > 0 && ptSecond.count (std::string() ) == ptSecond.size() ) {
// Copy array
ptMerged = ptSecond;
} else {
auto it = ptSecond.begin();
for (; it != ptSecond.end(); ++it) {
boost::property_tree::ptree child = ptMerged.get_child (it->first.data(),
boost::property_tree::ptree() );
mergePropertyTrees (child, it->second, level + 1);
ptMerged.erase (it->first.data() );
ptMerged.add_child (it->first.data(), child);
}
}
}