source: NonGTP/Boost/boost/archive/basic_xml_iarchive.hpp @ 857

Revision 857, 4.1 KB checked in by igarcia, 19 years ago (diff)
RevLine 
[857]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) && (_MSC_VER >= 1020)
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/pfto.hpp>
21#include <boost/detail/workaround.hpp>
22
23#include <boost/archive/detail/iserializer.hpp>
24#include <boost/archive/detail/interface_iarchive.hpp>
25#include <boost/archive/detail/common_iarchive.hpp>
26
27#include <boost/serialization/nvp.hpp>
28#include <boost/serialization/string.hpp>
29
30#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
31
32namespace boost {
33namespace archive {
34
35/////////////////////////////////////////////////////////////////////////
36// class xml_iarchive - read serialized objects from a input text stream
37template<class Archive>
38class basic_xml_iarchive :
39    public detail::common_iarchive<Archive>
40{
41#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
42public:
43#elif defined(BOOST_MSVC)
44    // for some inexplicable reason insertion of "class" generates compile erro
45    // on msvc 7.1
46    friend detail::interface_iarchive<Archive>;
47protected:
48#else
49    friend class detail::interface_iarchive<Archive>;
50protected:
51#endif
52    unsigned int depth;
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>
61    void load_override(T & t,  BOOST_PFTO int)
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_STATIC_ASSERT(0 == sizeof(T));
67    }
68
69    // Anything not an attribute - see below - should be a name value
70    // pair and be processed here
71    template<class T>
72    void load_override(
73                #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
74                const
75                #endif
76                boost::serialization::nvp<T> & t,
77                int
78        ){
79        load_start(t.name());
80        archive::load(* this->This(), t.value());
81        load_end(t.name());
82    }
83
84    // specific overrides for attributes - handle as
85    // primitives. These are not name-value pairs
86    // so they have to be intercepted here and passed on to load.
87    // although the class_id is included in the xml text file in order
88    // to make the file self describing, it isn't used when loading
89    // an xml archive.  So we can skip it here.  Note: we MUST override
90    // it otherwise it will be loaded as a normal primitive w/o tag and
91    // leaving the archive in an undetermined state
92    void load_override(class_id_optional_type & /* t */, int){}
93    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
94    load_override(object_id_type & t, int);
95    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
96    load_override(version_type & t, int);
97    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
98    load_override(class_id_type & t, int);
99    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
100    load_override(tracking_type & t, int);
101    // class_name_type can't be handled here as it depends upon the
102    // char type used by the stream.  So require the derived implementation
103    // handle this.
104    // void load_override(class_name_type & t, int);
105
106    BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
107    basic_xml_iarchive(unsigned int flags);
108    BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
109    ~basic_xml_iarchive();
110};
111
112} // namespace archive
113} // namespace boost
114
115#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
116
117#endif // BOOST_ARCHIVE_BASIC_XML_IARCHIVE_HPP
Note: See TracBrowser for help on using the repository browser.