1 #ifndef BOOST_ARCHIVE_BASIC_XML_OARCHIVE_HPP
2 #define BOOST_ARCHIVE_BASIC_XML_OARCHIVE_HPP
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // basic_xml_oarchive.hpp
12 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
13 // Use, modification and distribution is subject to the Boost Software
14 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
15 // http://www.boost.org/LICENSE_1_0.txt)
17 // See http://www.boost.org for updates, documentation, and revision history.
19 #include <boost/config.hpp>
21 #include <boost/archive/detail/common_oarchive.hpp>
23 #include <boost/serialization/nvp.hpp>
24 #include <boost/serialization/tracking.hpp>
25 #include <boost/serialization/string.hpp>
27 #include <boost/mpl/assert.hpp>
29 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
34 //////////////////////////////////////////////////////////////////////
35 // class basic_xml_oarchive - write serialized objects to a xml output stream
36 template<class Archive
>
37 class basic_xml_oarchive
:
38 public detail::common_oarchive
<Archive
>
41 #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
43 #elif defined(BOOST_MSVC)
44 // for some inexplicable reason insertion of "class" generates compile erro
46 friend detail::interface_oarchive
<Archive
>;
47 friend class save_access
;
49 friend class detail::interface_oarchive
<Archive
>;
50 friend class save_access
;
52 // special stuff for xml output
55 bool pending_preamble
;
56 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
58 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
60 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
62 const char *attribute_name
,
64 const char *conjunction
= "=\""
66 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
68 const char *attribute_name
,
72 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
73 save_start(const char *name
);
74 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
75 save_end(const char *name
);
76 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
79 // Anything not an attribute and not a name-value pair is an
80 // error and should be trapped here.
82 void save_override(T
& t
, BOOST_PFTO
int)
84 // If your program fails to compile here, its most likely due to
85 // not specifying an nvp wrapper around the variable to
87 BOOST_MPL_ASSERT((serialization::is_wrapper
<T
>));
88 this->detail_common_oarchive::save_override(t
, 0);
91 // special treatment for name-value pairs.
92 typedef detail::common_oarchive
<Archive
> detail_common_oarchive
;
95 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
98 ::boost::serialization::nvp
<T
> & t
,
101 this->This()->save_start(t
.name());
102 this->detail_common_oarchive::save_override(t
.const_value(), 0);
103 this->This()->save_end(t
.name());
106 // specific overrides for attributes - not name value pairs so we
107 // want to trap them before the above "fall through"
108 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
109 save_override(const object_id_type
& t
, int);
110 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
111 save_override(const object_reference_type
& t
, int);
112 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
113 save_override(const version_type
& t
, int);
114 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
115 save_override(const class_id_type
& t
, int);
116 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
117 save_override(const class_id_optional_type
& t
, int);
118 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
119 save_override(const class_id_reference_type
& t
, int);
120 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
121 save_override(const class_name_type
& t
, int);
122 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
123 save_override(const tracking_type
& t
, int);
125 BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
126 basic_xml_oarchive(unsigned int flags
);
127 BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
128 ~basic_xml_oarchive();
131 } // namespace archive
134 #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
136 #endif // BOOST_ARCHIVE_BASIC_XML_OARCHIVE_HPP