Imported Upstream version 1.57.0
[platform/upstream/boost.git] / boost / archive / detail / polymorphic_iarchive_route.hpp
1 #ifndef BOOST_ARCHIVE_DETAIL_POLYMORPHIC_IARCHIVE_ROUTE_HPP
2 #define BOOST_ARCHIVE_DETAIL_POLYMORPHIC_IARCHIVE_ROUTE_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 // polymorphic_iarchive_route.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 <string>
20 #include <ostream>
21 #include <cstddef>
22
23 #include <boost/config.hpp>
24 #if defined(BOOST_NO_STDC_NAMESPACE)
25 namespace std{
26     using ::size_t;
27 } // namespace std
28 #endif
29
30 #include <boost/cstdint.hpp>
31 #include <boost/integer_traits.hpp>
32 #include <boost/archive/polymorphic_iarchive.hpp>
33 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
34
35 namespace boost {
36 namespace serialization {
37     class extended_type_info;
38 } // namespace serialization
39 namespace archive {
40 namespace detail{
41
42 class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iserializer;
43 class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_iserializer;
44
45 #ifdef BOOST_MSVC
46 #  pragma warning(push)
47 #  pragma warning(disable : 4511 4512)
48 #endif
49
50 template<class ArchiveImplementation>
51 class polymorphic_iarchive_route :
52     public polymorphic_iarchive,
53     // note: gcc dynamic cross cast fails if the the derivation below is
54     // not public.  I think this is a mistake.
55     public /*protected*/ ArchiveImplementation
56 {
57 private:
58     // these are used by the serialization library.
59     virtual void load_object(
60         void *t,
61         const basic_iserializer & bis
62     ){
63         ArchiveImplementation::load_object(t, bis);
64     }
65     virtual const basic_pointer_iserializer * load_pointer(
66         void * & t,
67         const basic_pointer_iserializer * bpis_ptr,
68         const basic_pointer_iserializer * (*finder)(
69             const boost::serialization::extended_type_info & type
70         )
71     ){
72         return ArchiveImplementation::load_pointer(t, bpis_ptr, finder);
73     }
74     virtual void set_library_version(library_version_type archive_library_version){
75         ArchiveImplementation::set_library_version(archive_library_version);
76     }
77     virtual library_version_type get_library_version() const{
78         return ArchiveImplementation::get_library_version();
79     }
80     virtual unsigned int get_flags() const {
81         return ArchiveImplementation::get_flags();
82     }
83     virtual void delete_created_pointers(){
84         ArchiveImplementation::delete_created_pointers();
85     }
86     virtual void reset_object_address(
87         const void * new_address,
88         const void * old_address
89     ){
90         ArchiveImplementation::reset_object_address(new_address, old_address);
91     }
92     virtual void load_binary(void * t, std::size_t size){
93         ArchiveImplementation::load_binary(t, size);
94     }
95     // primitive types the only ones permitted by polymorphic archives
96     virtual void load(bool & t){
97         ArchiveImplementation::load(t);
98     }
99     virtual void load(char & t){
100         ArchiveImplementation::load(t);
101     }
102     virtual void load(signed char & t){
103         ArchiveImplementation::load(t);
104     }
105     virtual void load(unsigned char & t){
106         ArchiveImplementation::load(t);
107     }
108     #ifndef BOOST_NO_CWCHAR
109     #ifndef BOOST_NO_INTRINSIC_WCHAR_T
110     virtual void load(wchar_t & t){
111         ArchiveImplementation::load(t);
112     }
113     #endif
114     #endif
115     virtual void load(short & t){
116         ArchiveImplementation::load(t);
117     }
118     virtual void load(unsigned short & t){
119         ArchiveImplementation::load(t);
120     }
121     virtual void load(int & t){
122         ArchiveImplementation::load(t);
123     }
124     virtual void load(unsigned int & t){
125         ArchiveImplementation::load(t);
126     }
127     virtual void load(long & t){
128         ArchiveImplementation::load(t);
129     }
130     virtual void load(unsigned long & t){
131         ArchiveImplementation::load(t);
132     }
133     #if defined(BOOST_HAS_LONG_LONG)
134     virtual void load(boost::long_long_type & t){
135         ArchiveImplementation::load(t);
136     }
137     virtual void load(boost::ulong_long_type & t){
138         ArchiveImplementation::load(t);
139     }
140     #elif defined(BOOST_HAS_MS_INT64)
141     virtual void load(__int64 & t){
142         ArchiveImplementation::load(t);
143     }
144     virtual void load(unsigned __int64 & t){
145         ArchiveImplementation::load(t);
146     }
147     #endif
148     virtual void load(float & t){
149         ArchiveImplementation::load(t);
150     }
151     virtual void load(double & t){
152         ArchiveImplementation::load(t);
153     }
154     virtual void load(std::string & t){
155         ArchiveImplementation::load(t);
156     }
157     #ifndef BOOST_NO_STD_WSTRING
158     virtual void load(std::wstring & t){
159         ArchiveImplementation::load(t);
160     }
161     #endif
162     // used for xml and other tagged formats default does nothing
163     virtual void load_start(const char * name){
164         ArchiveImplementation::load_start(name);
165     }
166     virtual void load_end(const char * name){
167         ArchiveImplementation::load_end(name);
168     }
169
170     virtual void register_basic_serializer(const basic_iserializer & bis){
171         ArchiveImplementation::register_basic_serializer(bis);
172     }
173 public:
174     // this can't be inheriteded because they appear in mulitple
175     // parents
176     typedef mpl::bool_<true> is_loading;
177     typedef mpl::bool_<false> is_saving;
178     // the >> operator
179     template<class T>
180     polymorphic_iarchive & operator>>(T & t){
181         return polymorphic_iarchive::operator>>(t);
182     }
183     // the & operator
184     template<class T>
185     polymorphic_iarchive & operator&(T & t){
186         return polymorphic_iarchive::operator&(t);
187     }
188     // register type function
189     template<class T>
190     const basic_pointer_iserializer * 
191     register_type(T * t = NULL){
192         return ArchiveImplementation::register_type(t);
193     }
194     // all current archives take a stream as constructor argument
195     template <class _Elem, class _Tr>
196     polymorphic_iarchive_route(
197         std::basic_istream<_Elem, _Tr> & is,
198         unsigned int flags = 0
199     ) :
200         ArchiveImplementation(is, flags)
201     {}
202     virtual ~polymorphic_iarchive_route(){};
203 };
204
205 } // namespace detail
206 } // namespace archive
207 } // namespace boost
208
209 #ifdef BOOST_MSVC
210 #pragma warning(pop)
211 #endif
212
213 #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
214
215 #endif // BOOST_ARCHIVE_DETAIL_POLYMORPHIC_IARCHIVE_DISPATCH_HPP