Chris@16: #ifndef BOOST_ARCHIVE_BASIC_XML_OARCHIVE_HPP Chris@16: #define BOOST_ARCHIVE_BASIC_XML_OARCHIVE_HPP Chris@16: Chris@16: // MS compatible compilers support #pragma once Chris@101: #if defined(_MSC_VER) Chris@16: # pragma once Chris@16: #endif Chris@16: Chris@16: /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 Chris@16: // basic_xml_oarchive.hpp Chris@16: Chris@16: // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . Chris@16: // Use, modification and distribution is subject to the Boost Software Chris@16: // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: // See http://www.boost.org for updates, documentation, and revision history. Chris@16: Chris@16: #include Chris@101: #include Chris@101: #include Chris@101: #include Chris@16: Chris@16: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: Chris@16: #include // must be the last header Chris@16: Chris@16: #ifdef BOOST_MSVC Chris@16: # pragma warning(push) Chris@16: # pragma warning(disable : 4511 4512) Chris@16: #endif Chris@16: Chris@16: namespace boost { Chris@16: namespace archive { Chris@16: Chris@101: namespace detail { Chris@101: template class interface_oarchive; Chris@101: } // namespace detail Chris@101: Chris@16: ////////////////////////////////////////////////////////////////////// Chris@16: // class basic_xml_oarchive - write serialized objects to a xml output stream Chris@16: template Chris@16: class basic_xml_oarchive : Chris@16: public detail::common_oarchive Chris@16: { Chris@101: #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS Chris@101: public: Chris@101: #else Chris@16: protected: Chris@101: #endif Chris@101: #if BOOST_WORKAROUND(BOOST_MSVC, < 1500) Chris@16: // for some inexplicable reason insertion of "class" generates compile erro Chris@16: // on msvc 7.1 Chris@16: friend detail::interface_oarchive; Chris@16: #else Chris@16: friend class detail::interface_oarchive; Chris@101: #endif Chris@16: friend class save_access; Chris@16: // special stuff for xml output Chris@16: unsigned int depth; Chris@16: bool indent_next; Chris@16: bool pending_preamble; Chris@16: BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) Chris@16: indent(); Chris@16: BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) Chris@16: init(); Chris@16: BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) Chris@16: write_attribute( Chris@16: const char *attribute_name, Chris@16: int t, Chris@16: const char *conjunction = "=\"" Chris@16: ); Chris@16: BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) Chris@16: write_attribute( Chris@16: const char *attribute_name, Chris@16: const char *key Chris@16: ); Chris@16: // helpers used below Chris@16: BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) Chris@16: save_start(const char *name); Chris@16: BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) Chris@16: save_end(const char *name); Chris@16: BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) Chris@16: end_preamble(); Chris@16: Chris@16: // Anything not an attribute and not a name-value pair is an Chris@16: // error and should be trapped here. Chris@16: template Chris@16: void save_override(T & t, BOOST_PFTO int) Chris@16: { Chris@16: // If your program fails to compile here, its most likely due to Chris@16: // not specifying an nvp wrapper around the variable to Chris@16: // be serialized. Chris@16: BOOST_MPL_ASSERT((serialization::is_wrapper< T >)); Chris@16: this->detail_common_oarchive::save_override(t, 0); Chris@16: } Chris@16: Chris@16: // special treatment for name-value pairs. Chris@16: typedef detail::common_oarchive detail_common_oarchive; Chris@16: template Chris@16: void save_override( Chris@16: #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING Chris@16: const Chris@16: #endif Chris@16: ::boost::serialization::nvp< T > & t, Chris@16: int Chris@16: ){ Chris@16: this->This()->save_start(t.name()); Chris@16: this->detail_common_oarchive::save_override(t.const_value(), 0); Chris@16: this->This()->save_end(t.name()); Chris@16: } Chris@16: Chris@16: // specific overrides for attributes - not name value pairs so we Chris@16: // want to trap them before the above "fall through" Chris@16: BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) Chris@16: save_override(const object_id_type & t, int); Chris@16: BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) Chris@16: save_override(const object_reference_type & t, int); Chris@16: BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) Chris@16: save_override(const version_type & t, int); Chris@16: BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) Chris@16: save_override(const class_id_type & t, int); Chris@16: BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) Chris@16: save_override(const class_id_optional_type & t, int); Chris@16: BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) Chris@16: save_override(const class_id_reference_type & t, int); Chris@16: BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) Chris@16: save_override(const class_name_type & t, int); Chris@16: BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) Chris@16: save_override(const tracking_type & t, int); Chris@16: Chris@16: BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) Chris@16: basic_xml_oarchive(unsigned int flags); Chris@16: BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) Chris@16: ~basic_xml_oarchive(); Chris@16: }; Chris@16: Chris@16: } // namespace archive Chris@16: } // namespace boost Chris@16: Chris@16: #ifdef BOOST_MSVC Chris@16: #pragma warning(pop) Chris@16: #endif Chris@16: Chris@16: #include // pops abi_suffix.hpp pragmas Chris@16: Chris@16: #endif // BOOST_ARCHIVE_BASIC_XML_OARCHIVE_HPP