本文整理汇总了C++中boost::property_tree::ptree::put_value方法的典型用法代码示例。如果您正苦于以下问题:C++ ptree::put_value方法的具体用法?C++ ptree::put_value怎么用?C++ ptree::put_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::property_tree::ptree
的用法示例。
在下文中一共展示了ptree::put_value方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: merge
void Settings::merge(const boost::property_tree::ptree& from,
boost::property_tree::ptree& to,
bool overwrite)
{
// Is this a single value or a subtree?
if (!from.data().empty()) {
// Single value
if (overwrite || to.data().empty()) {
to.put_value(from.data());
}
return;
}
// Subtree
for (const auto& fromEntry : from) {
// Does the key exist in the destination?
auto toIt = to.find(fromEntry.first);
if (toIt == to.not_found()) {
ptree::ptree child;
// Recurse into the new child
merge(fromEntry.second, child, overwrite);
// Create a path object because ptree uses '.' as a path delimiter
// when strings are used
ptree::ptree::path_type treePath = createPath(fromEntry.first);
to.add_child(treePath, child);
} else {
// Recurse into the subtrees
merge(fromEntry.second, toIt->second, overwrite);
}
}
}