Chris@16
|
1 #ifndef BOOST_ARCHIVE_BASIC_XML_IARCHIVE_HPP
|
Chris@16
|
2 #define BOOST_ARCHIVE_BASIC_XML_IARCHIVE_HPP
|
Chris@16
|
3
|
Chris@16
|
4 // MS compatible compilers support #pragma once
|
Chris@16
|
5 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
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_iarchive.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@16
|
20 #include <boost/serialization/pfto.hpp>
|
Chris@16
|
21 #include <boost/detail/workaround.hpp>
|
Chris@16
|
22
|
Chris@16
|
23 #include <boost/archive/detail/common_iarchive.hpp>
|
Chris@16
|
24
|
Chris@16
|
25 #include <boost/serialization/nvp.hpp>
|
Chris@16
|
26 #include <boost/serialization/string.hpp>
|
Chris@16
|
27
|
Chris@16
|
28 #include <boost/mpl/assert.hpp>
|
Chris@16
|
29
|
Chris@16
|
30 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
Chris@16
|
31
|
Chris@16
|
32 #ifdef BOOST_MSVC
|
Chris@16
|
33 # pragma warning(push)
|
Chris@16
|
34 # pragma warning(disable : 4511 4512)
|
Chris@16
|
35 #endif
|
Chris@16
|
36
|
Chris@16
|
37 namespace boost {
|
Chris@16
|
38 namespace archive {
|
Chris@16
|
39
|
Chris@16
|
40 /////////////////////////////////////////////////////////////////////////
|
Chris@16
|
41 // class xml_iarchive - read serialized objects from a input text stream
|
Chris@16
|
42 template<class Archive>
|
Chris@16
|
43 class basic_xml_iarchive :
|
Chris@16
|
44 public detail::common_iarchive<Archive>
|
Chris@16
|
45 {
|
Chris@16
|
46 protected:
|
Chris@16
|
47 #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
Chris@16
|
48 public:
|
Chris@16
|
49 #elif defined(BOOST_MSVC)
|
Chris@16
|
50 // for some inexplicable reason insertion of "class" generates compile erro
|
Chris@16
|
51 // on msvc 7.1
|
Chris@16
|
52 friend detail::interface_oarchive<Archive>;
|
Chris@16
|
53 #else
|
Chris@16
|
54 friend class detail::interface_oarchive<Archive>;
|
Chris@16
|
55 #endif
|
Chris@16
|
56 unsigned int depth;
|
Chris@16
|
57 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
58 load_start(const char *name);
|
Chris@16
|
59 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
60 load_end(const char *name);
|
Chris@16
|
61
|
Chris@16
|
62 // Anything not an attribute and not a name-value pair is an
|
Chris@16
|
63 // should be trapped here.
|
Chris@16
|
64 template<class T>
|
Chris@16
|
65 void load_override(T & t, BOOST_PFTO int)
|
Chris@16
|
66 {
|
Chris@16
|
67 // If your program fails to compile here, its most likely due to
|
Chris@16
|
68 // not specifying an nvp wrapper around the variable to
|
Chris@16
|
69 // be serialized.
|
Chris@16
|
70 BOOST_MPL_ASSERT((serialization::is_wrapper< T >));
|
Chris@16
|
71 this->detail_common_iarchive::load_override(t, 0);
|
Chris@16
|
72 }
|
Chris@16
|
73
|
Chris@16
|
74 // Anything not an attribute - see below - should be a name value
|
Chris@16
|
75 // pair and be processed here
|
Chris@16
|
76 typedef detail::common_iarchive<Archive> detail_common_iarchive;
|
Chris@16
|
77 template<class T>
|
Chris@16
|
78 void load_override(
|
Chris@16
|
79 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
Chris@16
|
80 const
|
Chris@16
|
81 #endif
|
Chris@16
|
82 boost::serialization::nvp< T > & t,
|
Chris@16
|
83 int
|
Chris@16
|
84 ){
|
Chris@16
|
85 this->This()->load_start(t.name());
|
Chris@16
|
86 this->detail_common_iarchive::load_override(t.value(), 0);
|
Chris@16
|
87 this->This()->load_end(t.name());
|
Chris@16
|
88 }
|
Chris@16
|
89
|
Chris@16
|
90 // specific overrides for attributes - handle as
|
Chris@16
|
91 // primitives. These are not name-value pairs
|
Chris@16
|
92 // so they have to be intercepted here and passed on to load.
|
Chris@16
|
93 // although the class_id is included in the xml text file in order
|
Chris@16
|
94 // to make the file self describing, it isn't used when loading
|
Chris@16
|
95 // an xml archive. So we can skip it here. Note: we MUST override
|
Chris@16
|
96 // it otherwise it will be loaded as a normal primitive w/o tag and
|
Chris@16
|
97 // leaving the archive in an undetermined state
|
Chris@16
|
98 void load_override(class_id_optional_type & /* t */, int){}
|
Chris@16
|
99 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
100 load_override(object_id_type & t, int);
|
Chris@16
|
101 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
102 load_override(version_type & t, int);
|
Chris@16
|
103 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
104 load_override(class_id_type & t, int);
|
Chris@16
|
105 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
106 load_override(tracking_type & t, int);
|
Chris@16
|
107 // class_name_type can't be handled here as it depends upon the
|
Chris@16
|
108 // char type used by the stream. So require the derived implementation
|
Chris@16
|
109 // handle this.
|
Chris@16
|
110 // void load_override(class_name_type & t, int);
|
Chris@16
|
111
|
Chris@16
|
112 BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
Chris@16
|
113 basic_xml_iarchive(unsigned int flags);
|
Chris@16
|
114 BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
Chris@16
|
115 ~basic_xml_iarchive();
|
Chris@16
|
116 };
|
Chris@16
|
117
|
Chris@16
|
118 } // namespace archive
|
Chris@16
|
119 } // namespace boost
|
Chris@16
|
120
|
Chris@16
|
121 #ifdef BOOST_MSVC
|
Chris@16
|
122 #pragma warning(pop)
|
Chris@16
|
123 #endif
|
Chris@16
|
124
|
Chris@16
|
125 #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
Chris@16
|
126
|
Chris@16
|
127 #endif // BOOST_ARCHIVE_BASIC_XML_IARCHIVE_HPP
|