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

source code of boost/libs/serialization/include/boost/archive/detail/polymorphic_iarchive_route.hpp