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