Hi all!
I am trying to read an xml file with property tree (first try).
Because I have dots int the tag names I must use the extended version of
the get functions.
So here is the slightly modified example code, which sadly does'nt
compile on vc2008.
Probably its a totally silly error on my side...
// Loads debug_settings structure from the specified XML file
void load(const std::string &filename)
{
// Create an empty property tree object
using boost::property_tree::ptree;
ptree pt;
// Load the XML file into the property tree. If reading fails
// (cannot open file, parse error), an exception is thrown.
read_xml(filename, pt);
// Get the filename and store it in the m_file variable.
// Note that we construct the path to the value by separating
// the individual keys with dots. If dots appear in the keys,
// a path type with a different separator can be used.
// If the debug.filename key is not found, an exception is thrown.
std::string m_file = pt.get< std::string >( '/', "debug/filename" );
// Get the debug level and store it in the m_level variable.
// This is another version of the get method: if the value is
// not found, the default value (specified by the second
// parameter) is returned instead. The type of the value
// extracted is determined by the type of the second parameter,
// so we can simply write get(...) instead of get<int>(...).
int m_level = pt.get( '/', "debug/level", 0);
// Iterate over the debug.modules section and store all found
// modules in the m_modules set. The get_child() function
// returns a reference to the child at the specified path; if
// there is no such child, it throws. Property tree iterators
// are models of BidirectionalIterator.
std::vector< std::string > m_modules;
BOOST_FOREACH( ptree::value_type &v, pt.get_child( '/',
"debug/modules" ) )
{
m_modules.push_back( v.second.data() );
}
}
vc says:
1>c:\projekte\proptreetest\proptreetest\proptreetest.cpp(23) : error
C2664: 'std::basic_string<_Elem,_Traits,_Ax>
boost::property_tree::basic_ptree