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