My boost is 1.56 instead of 1.55.
In the XML example, boost provides a piece of code to write an XML file. I simplified it as follows:
void debug_settings::save(const std::string &filename){ using boost::property_tree::ptree; ptree pt; pt.put("debug.filename", m_file); pt.put("debug.level", m_level); write_xml(filename, pt);}
The format written in this code is very ugly with no indentation. So I found it online and changed it to the following:
void debug_settings::save(const std::string &filename){ using boost::property_tree::ptree; ptree pt; pt.put("debug.filename", m_file); pt.put("debug.level", m_level); boost::property_tree::xml_writer_settings<char> settings(‘\t‘,1); write_xml(filename, pt,std::local(),settings);}
It means to indent 1 \ t, and a lot of errors are reported:
In instantiation of ‘class boost::property_tree::xml_parser::xml_writer_settings<char>‘:../../game_server/common/CServerSetting.cpp:97:61: required from here../../game_server/libraries/boost_1_56_0/boost/property_tree/detail/xml_parser_writer_settings.hpp:38:35: error: ‘char‘ is not a class, struct, or union type typedef typename Str::value_type Ch;
I have never seen such errors when I am serving the food horizontally. Similar results cannot be found when you go to Baidu. You cannot read the source code of xml_parser_writer_settings. After a few hours of waste, I finally couldn't stand it. I went out to ask Google and soon found the relevant solution:
Http://www.pcl-users.org/PCL-compilation-errors-Please-help-me-td4035209.html
This is because there is a breaking API change in the boost 1.56.0 property_tree, as compared to boost 1.55.0. For more reference, see an issue described here: link.I fixed this by modifying: boost::property_tree::xml_writer_settings<char> settings (‘\t‘, 1); write_xml (filename, pt, std::locale (), settings);To: auto settings = boost::property_tree::xml_writer_make_settings<std::string> (‘\t‘, 1); write_xml (filename, pt, std::locale (), settings);In the 3 or so places this occurs...Thanks,McDamon
Http://lists.boost.org/boost-users/2014/08/82693.php
Dear all,with the release of Boost 1.56, on Ubuntu 14.04 (g++ 4.8.2, 64 bit),code like the following suddenly fails to compile:pt::xml_writer_settings<char> settings(‘\t‘, 1);pt::write_xml(someFileName, ptr_out, std::locale(), settings);"pt" is obviously an alias for boost::property_tree. The error messageI‘m getting is/opt/boost156/include/boost/property_tree/detail/xml_parser_writer_settings.hpp:38:35:error: ‘char‘ is not a class, struct, or union type typedef typename Str::value_type Ch;I can see the following possibly relevant change in property_tree:In Boost 1.55, from xml_parser.hpp:-----------------------------------template<typename Ptree>void write_xml( const std::string & , const Ptree & , const std::locale & = std::locale() , const xml_writer_settings<typename Ptree::key_type::value_type >& =xml_writer_settings<typename Ptree::key_type::value_type >());In Boost 1.56, same header:---------------------------template<typename Ptree>void write_xml( const std::string & , const Ptree & , const std::locale & = std::locale() , const xml_writer_settings<typename Ptree::key_type > &= xml_writer_settings<typename Ptree::key_type >());So xml_writer_settings is now given a Ptree::key_type instead of aPtree::key_type::value_type which I assume is the reason for the aboveerror.Is there a portable way to specify the type of indention character inwrite_xml ?Best Regards,Beet
View code
Since C ++ 11 is not enabled, write it like this.
boost::property_tree::xml_writer_settings<string> settings = boost::property_tree::xml_writer_make_settings<string> (‘ ‘, 4); write_xml( DEFAULTCONFIG,pt,std::locale(),settings );
Solve the problem.
PS: You can use this http://www.gfsoso.com/to search for code later /. Baidu is just looking for a cinema or something. The code is unreliable.
Boost formatted output XML