// ---------------------------------------------------------------------------- // Copyright (C) 2002-2005 Marcin Kalicinski // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // For more information, see www.boost.org // ---------------------------------------------------------------------------- #ifndef BOOST_PROPERTY_TREE_XML_PARSER_HPP_INCLUDED #define BOOST_PROPERTY_TREE_XML_PARSER_HPP_INCLUDED #include #include #include #include // Include proper parser #ifdef BOOST_PROPERTY_TREE_XML_PARSER_TINYXML #include #else #include #endif #include #include #include namespace boost { namespace property_tree { namespace xml_parser { // Read XML from stream template void read_xml(std::basic_istream &stream, Ptree &pt, int flags = 0) { read_xml_internal(stream, pt, flags, std::string()); } // Read XML from file template 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 stream(filename.c_str()); if (!stream) throw xml_parser_error("cannot open file", filename, 0); stream.imbue(loc); read_xml_internal(stream, pt, flags, filename); } // Write XML to stream template void write_xml(std::basic_ostream &stream, const Ptree &pt) { write_xml_internal(stream, pt, std::string()); } // Write XML to file template void write_xml(const std::string &filename, const Ptree &pt, const std::locale &loc = std::locale()) { std::basic_ofstream stream(filename.c_str()); if (!stream) throw xml_parser_error("cannot open file", filename, 0); stream.imbue(loc); write_xml_internal(stream, pt, filename); } } } } namespace boost { namespace property_tree { using xml_parser::read_xml; using xml_parser::write_xml; using xml_parser::xml_parser_error; } } #endif