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