1 #ifndef BOOST_ARCHIVE_XML_IARCHIVE_HPP
2 #define BOOST_ARCHIVE_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 // 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 <istream>
20 
21 #include <boost/scoped_ptr.hpp>
22 #include <boost/archive/detail/auto_link_archive.hpp>
23 #include <boost/archive/basic_text_iprimitive.hpp>
24 #include <boost/archive/basic_xml_iarchive.hpp>
25 #include <boost/archive/detail/register_archive.hpp>
26 #include <boost/serialization/item_version_type.hpp>
27 
28 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
29 
30 #ifdef BOOST_MSVC
31 #  pragma warning(push)
32 #  pragma warning(disable : 4511 4512)
33 #endif
34 
35 namespace boost {
36 namespace archive {
37 
38 namespace detail {
39     template<class Archive> class interface_iarchive;
40 } // namespace detail
41 
42 template<class CharType>
43 class basic_xml_grammar;
44 typedef basic_xml_grammar<char> xml_grammar;
45 
46 template<class Archive>
47 class BOOST_SYMBOL_VISIBLE xml_iarchive_impl :
48     public basic_text_iprimitive<std::istream>,
49     public basic_xml_iarchive<Archive>
50 {
51 #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
52 public:
53 #else
54 protected:
55     #if BOOST_WORKAROUND(BOOST_MSVC, < 1500)
56         // for some inexplicable reason insertion of "class" generates compile erro
57         // on msvc 7.1
58         friend detail::interface_iarchive<Archive>;
59         friend basic_xml_iarchive<Archive>;
60         friend load_access;
61     #else
62         friend class detail::interface_iarchive<Archive>;
63         friend class basic_xml_iarchive<Archive>;
64         friend class load_access;
65     #endif
66 #endif
67     // use boost:scoped_ptr to implement automatic deletion;
68     boost::scoped_ptr<xml_grammar> gimpl;
69 
get_is()70     std::istream & get_is(){
71         return is;
72     }
73     template<class T>
load(T & t)74     void load(T & t){
75         basic_text_iprimitive<std::istream>::load(t);
76     }
77     void
load(version_type & t)78     load(version_type & t){
79         unsigned int v;
80         load(v);
81         t = version_type(v);
82     }
83     void
load(boost::serialization::item_version_type & t)84     load(boost::serialization::item_version_type & t){
85         unsigned int v;
86         load(v);
87         t = boost::serialization::item_version_type(v);
88     }
89     BOOST_ARCHIVE_DECL void
90     load(char * t);
91     #ifndef BOOST_NO_INTRINSIC_WCHAR_T
92     BOOST_ARCHIVE_DECL void
93     load(wchar_t * t);
94     #endif
95     BOOST_ARCHIVE_DECL void
96     load(std::string &s);
97     #ifndef BOOST_NO_STD_WSTRING
98     BOOST_ARCHIVE_DECL void
99     load(std::wstring &ws);
100     #endif
101     template<class T>
load_override(T & t)102     void load_override(T & t){
103         basic_xml_iarchive<Archive>::load_override(t);
104     }
105     BOOST_ARCHIVE_DECL void
106     load_override(class_name_type & t);
107     BOOST_ARCHIVE_DECL void
108     init();
109     BOOST_ARCHIVE_DECL
110     xml_iarchive_impl(std::istream & is, unsigned int flags);
111     BOOST_ARCHIVE_DECL
112     ~xml_iarchive_impl();
113 };
114 
115 } // namespace archive
116 } // namespace boost
117 
118 #ifdef BOOST_MSVC
119 #pragma warning(pop)
120 #endif
121 
122 #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
123 #ifdef BOOST_MSVC
124 #  pragma warning(push)
125 #  pragma warning(disable : 4511 4512)
126 #endif
127 
128 namespace boost {
129 namespace archive {
130 
131 class BOOST_SYMBOL_VISIBLE xml_iarchive :
132     public xml_iarchive_impl<xml_iarchive>{
133 public:
xml_iarchive(std::istream & is,unsigned int flags=0)134     xml_iarchive(std::istream & is, unsigned int flags = 0) :
135         xml_iarchive_impl<xml_iarchive>(is, flags)
136     {}
~xml_iarchive()137     ~xml_iarchive(){};
138 };
139 
140 } // namespace archive
141 } // namespace boost
142 
143 // required by export
144 BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::xml_iarchive)
145 
146 #ifdef BOOST_MSVC
147 #pragma warning(pop)
148 #endif
149 
150 #endif // BOOST_ARCHIVE_XML_IARCHIVE_HPP
151