Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compilation error with boost::property_tree::xml_writer_settings

In order to pretty print my XML output with boost::property_tree, I wrote the following code:

#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>

int main()
{
    std::string filename = "test.xml";
    boost::property_tree::ptree pt;
    pt.put("some.path.value", "hello");

    boost::property_tree::xml_writer_settings<char> settings('\t', 1);
    write_xml(filename, pt, settings);
}

Unfortunately I have this error and I can't find any information about it:

/usr/local/include/boost/property_tree/detail/xml_parser_writer_settings.hpp:38:19: error: type 'char' cannot be used prior to '::' because it has no members
    typedef typename Str::value_type Ch;
                     ^

Any idea?

like image 797
Martin Delille Avatar asked Mar 31 '15 14:03

Martin Delille


Video Answer


1 Answers

I'd use the helper function

std::ofstream file("test.xml");

boost::property_tree::ptree pt;    
pt.put("some.value", "test");

boost::property_tree::write_xml(
   file, pt,
   boost::property_tree::xml_writer_make_settings<std::string>('\t', 1));
like image 142
sehe Avatar answered Oct 17 '22 20:10

sehe