trouble with find() in property_tree

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; }

On 23.10.2011, at 20:07, Bernd Prager wrote:
Hi,
I am experiencing trouble with the find() function in boost::property_tree. It doesn't seem to catch nested entries.
It's not intended to. It's part of the "container-style" interface, which only works on one level. Sebastian
participants (2)
-
Bernd Prager
-
Sebastian Redl