Chris@16
|
1 #ifndef BOOST_ARCHIVE_BASIC_XML_OARCHIVE_HPP
|
Chris@16
|
2 #define BOOST_ARCHIVE_BASIC_XML_OARCHIVE_HPP
|
Chris@16
|
3
|
Chris@16
|
4 // MS compatible compilers support #pragma once
|
Chris@101
|
5 #if defined(_MSC_VER)
|
Chris@16
|
6 # pragma once
|
Chris@16
|
7 #endif
|
Chris@16
|
8
|
Chris@16
|
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
Chris@16
|
10 // basic_xml_oarchive.hpp
|
Chris@16
|
11
|
Chris@16
|
12 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
Chris@16
|
13 // Use, modification and distribution is subject to the Boost Software
|
Chris@16
|
14 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
15 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
16
|
Chris@16
|
17 // See http://www.boost.org for updates, documentation, and revision history.
|
Chris@16
|
18
|
Chris@16
|
19 #include <boost/config.hpp>
|
Chris@101
|
20 #include <boost/mpl/assert.hpp>
|
Chris@101
|
21 #include <boost/serialization/pfto.hpp>
|
Chris@101
|
22 #include <boost/detail/workaround.hpp>
|
Chris@16
|
23
|
Chris@16
|
24 #include <boost/archive/detail/common_oarchive.hpp>
|
Chris@16
|
25
|
Chris@16
|
26 #include <boost/serialization/nvp.hpp>
|
Chris@16
|
27 #include <boost/serialization/tracking.hpp>
|
Chris@16
|
28 #include <boost/serialization/string.hpp>
|
Chris@16
|
29
|
Chris@16
|
30
|
Chris@16
|
31 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
Chris@16
|
32
|
Chris@16
|
33 #ifdef BOOST_MSVC
|
Chris@16
|
34 # pragma warning(push)
|
Chris@16
|
35 # pragma warning(disable : 4511 4512)
|
Chris@16
|
36 #endif
|
Chris@16
|
37
|
Chris@16
|
38 namespace boost {
|
Chris@16
|
39 namespace archive {
|
Chris@16
|
40
|
Chris@101
|
41 namespace detail {
|
Chris@101
|
42 template<class Archive> class interface_oarchive;
|
Chris@101
|
43 } // namespace detail
|
Chris@101
|
44
|
Chris@16
|
45 //////////////////////////////////////////////////////////////////////
|
Chris@16
|
46 // class basic_xml_oarchive - write serialized objects to a xml output stream
|
Chris@16
|
47 template<class Archive>
|
Chris@16
|
48 class basic_xml_oarchive :
|
Chris@16
|
49 public detail::common_oarchive<Archive>
|
Chris@16
|
50 {
|
Chris@101
|
51 #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
Chris@101
|
52 public:
|
Chris@101
|
53 #else
|
Chris@16
|
54 protected:
|
Chris@101
|
55 #endif
|
Chris@101
|
56 #if BOOST_WORKAROUND(BOOST_MSVC, < 1500)
|
Chris@16
|
57 // for some inexplicable reason insertion of "class" generates compile erro
|
Chris@16
|
58 // on msvc 7.1
|
Chris@16
|
59 friend detail::interface_oarchive<Archive>;
|
Chris@16
|
60 #else
|
Chris@16
|
61 friend class detail::interface_oarchive<Archive>;
|
Chris@101
|
62 #endif
|
Chris@16
|
63 friend class save_access;
|
Chris@16
|
64 // special stuff for xml output
|
Chris@16
|
65 unsigned int depth;
|
Chris@16
|
66 bool indent_next;
|
Chris@16
|
67 bool pending_preamble;
|
Chris@16
|
68 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
69 indent();
|
Chris@16
|
70 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
71 init();
|
Chris@16
|
72 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
73 write_attribute(
|
Chris@16
|
74 const char *attribute_name,
|
Chris@16
|
75 int t,
|
Chris@16
|
76 const char *conjunction = "=\""
|
Chris@16
|
77 );
|
Chris@16
|
78 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
79 write_attribute(
|
Chris@16
|
80 const char *attribute_name,
|
Chris@16
|
81 const char *key
|
Chris@16
|
82 );
|
Chris@16
|
83 // helpers used below
|
Chris@16
|
84 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
85 save_start(const char *name);
|
Chris@16
|
86 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
87 save_end(const char *name);
|
Chris@16
|
88 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
89 end_preamble();
|
Chris@16
|
90
|
Chris@16
|
91 // Anything not an attribute and not a name-value pair is an
|
Chris@16
|
92 // error and should be trapped here.
|
Chris@16
|
93 template<class T>
|
Chris@16
|
94 void save_override(T & t, BOOST_PFTO int)
|
Chris@16
|
95 {
|
Chris@16
|
96 // If your program fails to compile here, its most likely due to
|
Chris@16
|
97 // not specifying an nvp wrapper around the variable to
|
Chris@16
|
98 // be serialized.
|
Chris@16
|
99 BOOST_MPL_ASSERT((serialization::is_wrapper< T >));
|
Chris@16
|
100 this->detail_common_oarchive::save_override(t, 0);
|
Chris@16
|
101 }
|
Chris@16
|
102
|
Chris@16
|
103 // special treatment for name-value pairs.
|
Chris@16
|
104 typedef detail::common_oarchive<Archive> detail_common_oarchive;
|
Chris@16
|
105 template<class T>
|
Chris@16
|
106 void save_override(
|
Chris@16
|
107 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
Chris@16
|
108 const
|
Chris@16
|
109 #endif
|
Chris@16
|
110 ::boost::serialization::nvp< T > & t,
|
Chris@16
|
111 int
|
Chris@16
|
112 ){
|
Chris@16
|
113 this->This()->save_start(t.name());
|
Chris@16
|
114 this->detail_common_oarchive::save_override(t.const_value(), 0);
|
Chris@16
|
115 this->This()->save_end(t.name());
|
Chris@16
|
116 }
|
Chris@16
|
117
|
Chris@16
|
118 // specific overrides for attributes - not name value pairs so we
|
Chris@16
|
119 // want to trap them before the above "fall through"
|
Chris@16
|
120 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
121 save_override(const object_id_type & t, int);
|
Chris@16
|
122 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
123 save_override(const object_reference_type & t, int);
|
Chris@16
|
124 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
125 save_override(const version_type & t, int);
|
Chris@16
|
126 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
127 save_override(const class_id_type & t, int);
|
Chris@16
|
128 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
129 save_override(const class_id_optional_type & t, int);
|
Chris@16
|
130 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
131 save_override(const class_id_reference_type & t, int);
|
Chris@16
|
132 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
133 save_override(const class_name_type & t, int);
|
Chris@16
|
134 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
135 save_override(const tracking_type & t, int);
|
Chris@16
|
136
|
Chris@16
|
137 BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
Chris@16
|
138 basic_xml_oarchive(unsigned int flags);
|
Chris@16
|
139 BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
Chris@16
|
140 ~basic_xml_oarchive();
|
Chris@16
|
141 };
|
Chris@16
|
142
|
Chris@16
|
143 } // namespace archive
|
Chris@16
|
144 } // namespace boost
|
Chris@16
|
145
|
Chris@16
|
146 #ifdef BOOST_MSVC
|
Chris@16
|
147 #pragma warning(pop)
|
Chris@16
|
148 #endif
|
Chris@16
|
149
|
Chris@16
|
150 #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
Chris@16
|
151
|
Chris@16
|
152 #endif // BOOST_ARCHIVE_BASIC_XML_OARCHIVE_HPP
|