示例#1
0
// 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
0
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
0
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);
	}
}
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
0
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);
}