I have read through the documentation for boost::property_tree and have not found a way to update or merge a ptree with another ptree. How do I do this?
Given the code b
Boost.Property tree does not support this, yet: boost.org/doc/libs/1_48_0/doc/html/property_tree/appendices.html. Look at the future work section.
Mathematical relations: ptree difference, union, intersection.
An update is simply a difference followed by a union. a = (a - b) + b
.
The general solution would require recursively traversing update ptree and putting each leaf.
However a good enough solution can be built with put_child. This may do all you need, without the complexity of a general solution.
void merge( ptree& pt, const ptree& updates )
{
BOOST_FOREACH( auto& update, updates )
{
pt.put_child( update.first, update.second );
}
}
The good enough solution has two limitations, by coincidence they are the same limitations the ini_parser has.