1#ifndef BOOST_ARCHIVE_POLYMORPHIC_IARCHIVE_HPP
2#define BOOST_ARCHIVE_POLYMORPHIC_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// polymorphic_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 <cstddef> // std::size_t
20#include <climits> // ULONG_MAX
21#include <string>
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
32#include <boost/archive/detail/iserializer.hpp>
33#include <boost/archive/detail/interface_iarchive.hpp>
34#include <boost/serialization/library_version_type.hpp>
35#include <boost/serialization/nvp.hpp>
36#include <boost/archive/detail/register_archive.hpp>
37
38#include <boost/archive/detail/decl.hpp>
39#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
40
41namespace boost {
42namespace serialization {
43 class extended_type_info;
44} // namespace serialization
45namespace archive {
46namespace detail {
47 class basic_iarchive;
48 class basic_iserializer;
49}
50
51class polymorphic_iarchive;
52
53class BOOST_SYMBOL_VISIBLE polymorphic_iarchive_impl :
54 public detail::interface_iarchive<polymorphic_iarchive>
55{
56#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
57public:
58#else
59 friend class detail::interface_iarchive<polymorphic_iarchive>;
60 friend class load_access;
61#endif
62 // primitive types the only ones permitted by polymorphic archives
63 virtual void load(bool & t) = 0;
64
65 virtual void load(char & t) = 0;
66 virtual void load(signed char & t) = 0;
67 virtual void load(unsigned char & t) = 0;
68 #ifndef BOOST_NO_CWCHAR
69 #ifndef BOOST_NO_INTRINSIC_WCHAR_T
70 virtual void load(wchar_t & t) = 0;
71 #endif
72 #endif
73 virtual void load(short & t) = 0;
74 virtual void load(unsigned short & t) = 0;
75 virtual void load(int & t) = 0;
76 virtual void load(unsigned int & t) = 0;
77 virtual void load(long & t) = 0;
78 virtual void load(unsigned long & t) = 0;
79
80 #if defined(BOOST_HAS_LONG_LONG)
81 virtual void load(boost::long_long_type & t) = 0;
82 virtual void load(boost::ulong_long_type & t) = 0;
83 #elif defined(BOOST_HAS_MS_INT64)
84 virtual void load(__int64 & t) = 0;
85 virtual void load(unsigned __int64 & t) = 0;
86 #endif
87
88 virtual void load(float & t) = 0;
89 virtual void load(double & t) = 0;
90
91 // string types are treated as primitives
92 virtual void load(std::string & t) = 0;
93 #ifndef BOOST_NO_STD_WSTRING
94 virtual void load(std::wstring & t) = 0;
95 #endif
96
97 // used for xml and other tagged formats
98 virtual void load_start(const char * name) = 0;
99 virtual void load_end(const char * name) = 0;
100 virtual void register_basic_serializer(const detail::basic_iserializer & bis) = 0;
101 virtual detail::helper_collection & get_helper_collection() = 0;
102
103 // msvc and borland won't automatically pass these to the base class so
104 // make it explicit here
105 template<class T>
106 void load_override(T & t)
107 {
108 archive::load(* this->This(), t);
109 }
110 // special treatment for name-value pairs.
111 template<class T>
112 void load_override(
113 const boost::serialization::nvp< T > & t
114 ){
115 load_start(name: t.name());
116 archive::load(* this->This(), t.value());
117 load_end(name: t.name());
118 }
119protected:
120 virtual ~polymorphic_iarchive_impl() {}
121public:
122 // utility function implemented by all legal archives
123 virtual void set_library_version(
124 boost::serialization::library_version_type archive_library_version
125 ) = 0;
126 virtual boost::serialization::library_version_type get_library_version() const = 0;
127 virtual unsigned int get_flags() const = 0;
128 virtual void delete_created_pointers() = 0;
129 virtual void reset_object_address(
130 const void * new_address,
131 const void * old_address
132 ) = 0;
133
134 virtual void load_binary(void * t, std::size_t size) = 0;
135
136 // these are used by the serialization library implementation.
137 virtual void load_object(
138 void *t,
139 const detail::basic_iserializer & bis
140 ) = 0;
141 virtual const detail::basic_pointer_iserializer * load_pointer(
142 void * & t,
143 const detail::basic_pointer_iserializer * bpis_ptr,
144 const detail::basic_pointer_iserializer * (*finder)(
145 const boost::serialization::extended_type_info & type
146 )
147 ) = 0;
148};
149
150} // namespace archive
151} // namespace boost
152
153#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
154
155namespace boost {
156namespace archive {
157
158class BOOST_SYMBOL_VISIBLE polymorphic_iarchive :
159 public polymorphic_iarchive_impl
160{
161public:
162 ~polymorphic_iarchive() BOOST_OVERRIDE {}
163};
164
165} // namespace archive
166} // namespace boost
167
168// required by export
169BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::polymorphic_iarchive)
170
171#endif // BOOST_ARCHIVE_POLYMORPHIC_IARCHIVE_HPP
172

source code of boost/libs/serialization/include/boost/archive/polymorphic_iarchive.hpp