I just blew up all day trying to answer this question!
. -, , , . ptree.
using namespace boost::property_tree;
ptree r_pt;
ptree *c_pt;
read_xml( "file.xml" , r_pt);
try {
c_pt = &(r_pt.get_child( "example" ));
}
catch (ptree_bad_path) {
c_pt = &(r_pt.put_child( "example", ptree() ));
}
std::cout << "Setting 1 is " << c_pt.get("setting1", 0) << std::endl;
, , , boost:: optional type. .
empty_ptree < > .
template<class Ptree>
inline const Ptree &empty_ptree()
{
static Ptree pt;
return pt;
}
, , empty_ptree_trick.cpp, , , .