本文整理汇总了C++中ptree::put_child方法的典型用法代码示例。如果您正苦于以下问题:C++ ptree::put_child方法的具体用法?C++ ptree::put_child怎么用?C++ ptree::put_child使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ptree
的用法示例。
在下文中一共展示了ptree::put_child方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: save
// save
void configuration::save(ptree& out_conf) const {
out_conf.put_child(settings_path_, settings_);
LOG_INFO(settings_path_, "Settings saved.");
if (!out_conf.get_child_optional(defaults_path_)) {
out_conf.put_child(defaults_path_, defaults_);
LOG_INFO(defaults_path_, "Settings saved.");
}
}
示例2: write
void ProperyTreeUtils::write(ptree & properties, const std::vector<uint8_t> & data) {
ptree propertiesData {};
for(const uint8_t & value: data){
ptree propertyValue {boost::lexical_cast<std::string>((int)value)};
propertiesData.push_back({DATA_VALUE_NAME, propertyValue});
}
properties.put_child(DATA_NAME, propertiesData);
}
示例3: addToArray
void MsgPrinter::addToArray(ptree& root, string name, string value) {
optional<ptree&> child = root.get_child_optional(name);
if (child.is_initialized()) {
ptree item;
item.put("", value);
child.get().push_front(make_pair("", item));
} else {
ptree child, item;
item.put("", value);
child.push_front(make_pair("", item));
root.put_child(name, child);
}
}
示例4: writeSelf
void MultiMatcher::writeSelf(ptree& writeTo) const {
writeTo.put(OPERATE_MODE_KEY,OPERATE_MODE_MAP_NAME[m_operateMode]);
int index=0;
ptree values;
for(auto &child : m_values){
ptree childTree;
write(child,childTree);
values.add_child(MATCHER_KEY,childTree);
}
writeTo.put_child(VALUES_KEY,values);
}
示例5: reduce_and_output
void reduce_and_output(IterT beg, IterT end, TransformT trans, ptree& parent, std::string const& path)
{
ValueT minv;
ValueT maxv;
ValueT total = 0;
ValueT avg = 0;
if(beg == end)
{
minv = maxv = total = avg = 0;
}
else
{
auto it = beg;
minv = maxv = total = trans(*it);
++it;
size_t count = 1;
for(; it != end; ++it)
{
auto v = trans(*it);
min_max(minv, maxv, v);
total += v;
++count;
}
avg = total / count;
}
ptree vnode;
vnode.put("min", minv);
vnode.put("max", maxv);
vnode.put("total", total);
vnode.put("avg", avg);
parent.put_child(path, vnode);
}