123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- #ifndef BOOST_PROPERTY_TREE_XML_PARSER_HPP_INCLUDED
- #define BOOST_PROPERTY_TREE_XML_PARSER_HPP_INCLUDED
- #include <boost/property_tree/ptree.hpp>
- #include <boost/property_tree/detail/xml_parser_write.hpp>
- #include <boost/property_tree/detail/xml_parser_error.hpp>
- #include <boost/property_tree/detail/xml_parser_writer_settings.hpp>
- #include <boost/property_tree/detail/xml_parser_flags.hpp>
- #include <boost/property_tree/detail/xml_parser_read_rapidxml.hpp>
- #include <fstream>
- #include <string>
- #include <locale>
- namespace boost { namespace property_tree { namespace xml_parser
- {
-
- template<class Ptree>
- void read_xml(std::basic_istream<
- typename Ptree::key_type::value_type
- > &stream,
- Ptree &pt,
- int flags = 0)
- {
- read_xml_internal(stream, pt, flags, std::string());
- }
-
- template<class Ptree>
- void read_xml(const std::string &filename,
- Ptree &pt,
- int flags = 0,
- const std::locale &loc = std::locale())
- {
- BOOST_ASSERT(validate_flags(flags));
- std::basic_ifstream<typename Ptree::key_type::value_type>
- stream(filename.c_str());
- if (!stream)
- BOOST_PROPERTY_TREE_THROW(xml_parser_error(
- "cannot open file", filename, 0));
- stream.imbue(loc);
- read_xml_internal(stream, pt, flags, filename);
- }
-
- 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>() )
- {
- write_xml_internal(stream, pt, std::string(), settings);
- }
-
- 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>())
- {
- std::basic_ofstream<typename Ptree::key_type::value_type>
- stream(filename.c_str());
- if (!stream)
- BOOST_PROPERTY_TREE_THROW(xml_parser_error(
- "cannot open file", filename, 0));
- stream.imbue(loc);
- write_xml_internal(stream, pt, filename, settings);
- }
- } } }
- namespace boost { namespace property_tree
- {
- using xml_parser::read_xml;
- using xml_parser::write_xml;
- using xml_parser::xml_parser_error;
- using xml_parser::xml_writer_settings;
- using xml_parser::xml_writer_make_settings;
- } }
- #endif
|