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