Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::property_tree::xml_parser Namespace Reference

Functions

template<class Ptree >
void read_xml (std::basic_istream< typename Ptree::key_type::value_type > &stream, Ptree &pt, int flags=0)
 Reads XML from an input stream and translates it to property tree. More...
 
template<class Ptree >
void read_xml (const std::string &filename, Ptree &pt, int flags=0, const std::locale &loc=std::locale())
 Reads XML from a file using the given locale and translates it to property tree. More...
 
template<class Ptree >
void write_xml (std::basic_ostream< typename Ptree::key_type::value_type > &stream, const Ptree &pt, const xml_writer_settings< typename Ptree::key_type > &settings=xml_writer_settings< typename Ptree::key_type >())
 Translates the property tree to XML and writes it the given output stream. More...
 
template<class Ptree >
void write_xml (const std::string &filename, const Ptree &pt, const std::locale &loc=std::locale(), const xml_writer_settings< typename Ptree::key_type > &settings=xml_writer_settings< typename Ptree::key_type >())
 Translates the property tree to XML and writes it the given file. More...
 

Function Documentation

template<class Ptree >
void boost::property_tree::xml_parser::read_xml ( std::basic_istream< typename Ptree::key_type::value_type > &  stream,
Ptree &  pt,
int  flags = 0 
)

Reads XML from an input stream and translates it to property tree.

Note
Clears existing contents of property tree. In case of error the property tree unmodified.
XML attributes are placed under keys named <xmlattr>.
Exceptions
xml_parser_errorIn case of error deserializing the property tree.
Parameters
streamStream from which to read in the property tree.
[out]ptThe property tree to populate.
flagsFlags controlling the behaviour of the parser. The following flags are supported:
  • no_concat_text – Prevents concatenation of text nodes into datastring of property tree. Puts them in separate <xmltext> strings instead.
  • no_comments – Skip XML comments.
  • trim_whitespace – Trim leading and trailing whitespace from text, and collapse sequences of whitespace.

References boost::expressions::stream.

template<class Ptree >
void boost::property_tree::xml_parser::read_xml ( const std::string &  filename,
Ptree &  pt,
int  flags = 0,
const std::locale &  loc = std::locale() 
)

Reads XML from a file using the given locale and translates it to property tree.

Note
Clears existing contents of property tree. In case of error the property tree unmodified.
XML attributes are placed under keys named <xmlattr>.
Exceptions
xml_parser_errorIn case of error deserializing the property tree.
Parameters
filenameThe file from which to read in the property tree.
[out]ptThe property tree to populate.
flagsFlags controlling the bahviour of the parser. The following flags are supported:
  • no_concat_text – Prevents concatenation of text nodes into datastring of property tree. Puts them in separate <xmltext> strings instead.
  • no_comments – Skip XML comments.
locThe locale to use when reading in the file contents.

References BOOST_ASSERT, BOOST_PROPERTY_TREE_THROW, boost::expressions::stream, and boost::property_tree::ini_parser::validate_flags().

template<class Ptree >
void boost::property_tree::xml_parser::write_xml ( std::basic_ostream< typename Ptree::key_type::value_type > &  stream,
const Ptree &  pt,
const xml_writer_settings< typename Ptree::key_type > &  settings = xml_writer_settings< typename Ptree::key_type>() 
)

Translates the property tree to XML and writes it the given output stream.

Exceptions
xml_parser_errorIn case of error translating the property tree to XML or writing to the output stream.
Parameters
streamThe stream to which to write the XML representation of the property tree.
ptThe property tree to tranlsate to XML and output.
settingsThe settings to use when writing out the property tree as XML.

References boost::expressions::stream.

template<class Ptree >
void boost::property_tree::xml_parser::write_xml ( const std::string &  filename,
const Ptree &  pt,
const std::locale &  loc = std::locale(),
const xml_writer_settings< typename Ptree::key_type > &  settings = xml_writer_settings<typename Ptree::key_type>() 
)

Translates the property tree to XML and writes it the given file.

Exceptions
xml_parser_errorIn case of error translating the property tree to XML or writing to the output stream.
Parameters
filenameThe file to which to write the XML representation of the property tree.
ptThe property tree to tranlsate to XML and output.
locThe locale to use when writing the output to file.
settingsThe settings to use when writing out the property tree as XML.

References BOOST_PROPERTY_TREE_THROW, and boost::expressions::stream.