|
Boost : |
Subject: [boost] trouble with find() in property_tree
From: Bernd Prager (bernd_at_[hidden])
Date: 2011-10-23 14:07:39
Hi,
I am experiencing trouble with the find() function in boost::property_tree.
It doesn't seem to catch nested entries.
Statement (1) below finds the child tree, but statement (2) prints
unexpectedly "false".
That was not what I was expecting. How do I find nested children?
Thanks for any help.
-- Bernd
#include <iostream>
#include <boost/property_tree/ptree.hpp>
namespace pt = boost::property_tree;
int main(void) {
pt::ptree props;
pt::ptree const empty;
props.add("pi", 3.14159);
props.put("name.first", "bernd");
std::cout << "find(none): " << (props.find("none") ==
props.not_found() ? "false" : "true") << std::endl;
std::cout << "find(pi): " << (props.find("pi") == props.not_found()
? "false" : "true") << std::endl;
std::cout << "find(name): " << (props.find("name") ==
props.not_found() ? "false" : "true") << std::endl; // (1)
std::cout << "find(name.first): " << (props.find("name.first") ==
props.not_found() ? "false" : "true") << std::endl; // (2)
return EXIT_SUCCESS;
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk