Boost logo

Boost Users :

Subject: [Boost-users] iterating though an inifile section using boost.property_tree
From: Sean Farrow (sean.farrow_at_[hidden])
Date: 2012-02-13 14:48:20


Hi Fokes:
Ok, I've got a standard windows-stle ini file.
I can check that a section exists, and then get that section, using it->second, where it is declared as:
boost::property_tree::ptree::const_assoc_iterator it;
I've then assigned the it->second variable to a new property_tree. What I now need to do is iterate though the tree I've just assigned and get all the section keys/values.
I'm using the following code to add them all to a map:
std::map<string, string> SectionProps;
BOOST_FOREACH(boost::property_tree::ptree::value_type &v, SectionTree)
       {
Key =v.first;
Value =v.second;
SectionProps.insert(std::make_pair(Key, Value));
       }
It seems that even though thwe values in the ini file will be strings, of the vorm
Key1=valu1 as normal, I am still getting another ptree as my second argument of the pair. How do I obtain the value from this? There are never any sub sections.
Any help appreciated.
Cheers
Sean.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net