I'm using boots's property_tree library. I'm looking for a way to get a child node from a ptree
object, but return an empty ptree
if failed. I came across a nice example in property_tree/examples/empty_ptree_trick.cpp:
void process_settings(const std::string &filename)
{
ptree pt;
read_info(filename, pt);
const ptree &settings = pt.get_child("settings", empty_ptree<ptree>());
std::cout << "\n Processing " << filename << std::endl;
std::cout << " Setting 1 is " << settings.get("setting1", 0) << std::endl;
std::cout << " Setting 2 is " << settings.get("setting2", 0.0) << std::endl;
std::cout << " Setting 3 is " << settings.get("setting3", "default") << std::endl;
}
which does exactly what I need. The problem is that the compiler complains that empty_ptree()
function is not a member of boost:property_tree
. Any ideas where empty_ptree()
is?
I'm using boost 1.44 on VS2010.
Note, that will prevent throwing an instance of 'boost::wrapexceptboost::property_tree::ptree_bad_path'