Need to transfer system configuration that is stored in ini file over internet. I'm using boost to deal with configuration ini file. How to save whole property tree to string?
To use boost::property_tree::ptree, include the header file boost/property_tree/ptree.hpp. This is a master header file, so no other header files need to be included. 1) An instance of type property tree is made and value (directory) is given to the instance. 2) Firstly in new ptree type variable is initialized with the value of child of "C".
Giving the output for part number and zip code: It is possible to create a Boost property from a std::string, and then write the Boost property to an XML file: Upon navigating to the same project folder after running this, observe that the XML file has been created:
What is Property Tree? The Property Tree library provides a data structure that stores an arbitrarily deeply nested tree of values, indexed at each level by some key. Each node of the tree stores its own value, plus an ordered list of its subnodes and their keys.
The Property Tree library provides a data structure that stores an arbitrarily deeply nested tree of values, indexed at each level by some key. Each node of the tree stores its own value, plus an ordered list of its subnodes and their keys.
Just write to a std::stringstream
:
std::ostringstream oss;
boost::property_tree::ini_parser::write_ini(oss, my_ptree);
std::string inifile_text = oss.str();
Replace with wstring
/wostringstream
as appropriate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With