Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/boost/archive/basic_xml_iarchive.hpp @ 29

Last change on this file since 29 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 4.0 KB
Line 
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/common_iarchive.hpp>
24
25#include <boost/serialization/nvp.hpp>
26#include <boost/serialization/string.hpp>
27
28#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
29
30namespace boost {
31namespace archive {
32
33/////////////////////////////////////////////////////////////////////////
34// class xml_iarchive - read serialized objects from a input text stream
35template<class Archive>
36class basic_xml_iarchive : 
37    public detail::common_iarchive<Archive>
38{
39protected:
40#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
41public:
42#elif defined(BOOST_MSVC)
43    // for some inexplicable reason insertion of "class" generates compile erro
44    // on msvc 7.1
45    friend detail::interface_oarchive<Archive>;
46#else
47    friend class detail::interface_oarchive<Archive>;
48#endif
49    unsigned int depth;
50    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
51    load_start(const char *name);
52    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
53    load_end(const char *name);
54
55    // Anything not an attribute and not a name-value pair is an
56    // should be trapped here.
57    template<class T>
58    void load_override(T & t,  BOOST_PFTO int)
59    {
60        // If your program fails to compile here, its most likely due to
61        // not specifying an nvp wrapper around the variable to
62        // be serialized.
63        BOOST_STATIC_ASSERT(0 == sizeof(T));
64    }
65
66    // Anything not an attribute - see below - should be a name value
67    // pair and be processed here
68    typedef detail::common_iarchive<Archive> detail_common_iarchive;
69    template<class T>
70    void load_override(
71        #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
72        const
73        #endif
74        boost::serialization::nvp<T> & t, 
75        int
76    ){
77        load_start(t.name());
78        this->detail_common_iarchive::load_override(t.value(), 0);
79        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    void load_override(class_id_optional_type & /* t */, int){}
91    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
92    load_override(object_id_type & t, int);
93    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
94    load_override(version_type & t, int);
95    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
96    load_override(class_id_type & t, int);
97    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
98    load_override(tracking_type & t, int);
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, int);
103
104    BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) 
105    basic_xml_iarchive(unsigned int flags);
106    BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) 
107    ~basic_xml_iarchive();
108};
109
110} // namespace archive
111} // namespace boost
112
113#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
114
115#endif // BOOST_ARCHIVE_BASIC_XML_IARCHIVE_HPP
Note: See TracBrowser for help on using the repository browser.