fix doc example typo
[boost.git] / boost / archive / polymorphic_iarchive.hpp
blobfb16a6fe243de58fe3238253dec0d9827c52ce3e
1 #ifndef BOOST_ARCHIVE_POLYMORPHIC_IARCHIVE_HPP
2 #define BOOST_ARCHIVE_POLYMORPHIC_IARCHIVE_HPP
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
6 # pragma once
7 #endif
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // polymorphic_iarchive.hpp
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)
17 // See http://www.boost.org for updates, documentation, and revision history.
19 #include <cstddef> // std::size_t
20 #include <climits> // ULONG_MAX
21 #include <boost/config.hpp>
23 #if defined(BOOST_NO_STDC_NAMESPACE)
24 namespace std{
25 using ::size_t;
26 } // namespace std
27 #endif
29 #include <string>
30 #include <boost/cstdint.hpp>
32 #include <boost/serialization/pfto.hpp>
33 #include <boost/archive/detail/iserializer.hpp>
34 #include <boost/archive/detail/interface_iarchive.hpp>
35 #include <boost/serialization/nvp.hpp>
36 #include <boost/archive/detail/register_archive.hpp>
38 #include <boost/archive/detail/decl.hpp>
39 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
41 // determine if its necessary to handle (u)int64_t specifically
42 // i.e. that its not a synonym for (unsigned) long
43 // if there is no 64 bit int or if its the same as a long
44 // we shouldn't define separate functions for int64 data types.
45 #if defined(BOOST_NO_INT64_T)
46 #define BOOST_NO_INTRINSIC_INT64_T
47 #else
48 #if defined(ULLONG_MAX)
49 #if(ULONG_MAX == 18446744073709551615ul) // 2**64 - 1
50 #define BOOST_NO_INTRINSIC_INT64_T
51 #endif
52 #elif defined(ULONG_MAX)
53 #if(ULONG_MAX != 0xffffffff && ULONG_MAX == 18446744073709551615ul) // 2**64 - 1
54 #define BOOST_NO_INTRINSIC_INT64_T
55 #endif
56 #else
57 #define BOOST_NO_INTRINSIC_INT64_T
58 #endif
59 #endif
61 namespace boost {
62 template<class T>
63 class shared_ptr;
64 namespace serialization {
65 class extended_type_info;
66 } // namespace serialization
67 namespace archive {
68 namespace detail {
69 class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iarchive;
70 class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iarchive;
73 class polymorphic_iarchive;
75 class polymorphic_iarchive_impl :
76 public detail::interface_iarchive<polymorphic_iarchive>
78 #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
79 public:
80 #else
81 friend class detail::interface_iarchive<polymorphic_iarchive>;
82 friend class load_access;
83 #endif
84 // primitive types the only ones permitted by polymorphic archives
85 virtual void load(bool & t) = 0;
87 virtual void load(char & t) = 0;
88 virtual void load(signed char & t) = 0;
89 virtual void load(unsigned char & t) = 0;
90 #ifndef BOOST_NO_CWCHAR
91 #ifndef BOOST_NO_INTRINSIC_WCHAR_T
92 virtual void load(wchar_t & t) = 0;
93 #endif
94 #endif
95 virtual void load(short & t) = 0;
96 virtual void load(unsigned short & t) = 0;
97 virtual void load(int & t) = 0;
98 virtual void load(unsigned int & t) = 0;
99 virtual void load(long & t) = 0;
100 virtual void load(unsigned long & t) = 0;
102 #if !defined(BOOST_NO_INTRINSIC_INT64_T)
103 virtual void load(boost::int64_t & t) = 0;
104 virtual void load(boost::uint64_t & t) = 0;
105 #endif
106 virtual void load(float & t) = 0;
107 virtual void load(double & t) = 0;
109 // string types are treated as primitives
110 virtual void load(std::string & t) = 0;
111 #ifndef BOOST_NO_STD_WSTRING
112 virtual void load(std::wstring & t) = 0;
113 #endif
115 // used for xml and other tagged formats
116 virtual void load_start(const char * name) = 0;
117 virtual void load_end(const char * name) = 0;
118 virtual void register_basic_serializer(const detail::basic_iserializer & bis) = 0;
120 // msvc and borland won't automatically pass these to the base class so
121 // make it explicit here
122 template<class T>
123 void load_override(T & t, BOOST_PFTO int)
125 archive::load(* this->This(), t);
127 // special treatment for name-value pairs.
128 template<class T>
129 void load_override(
130 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
131 const
132 #endif
133 boost::serialization::nvp<T> & t,
136 load_start(t.name());
137 archive::load(* this->This(), t.value());
138 load_end(t.name());
140 protected:
141 virtual ~polymorphic_iarchive_impl(){};
142 public:
143 // utility function implemented by all legal archives
144 virtual void set_library_version(unsigned int archive_library_version) = 0;
145 virtual unsigned int get_library_version() const = 0;
146 virtual unsigned int get_flags() const = 0;
147 virtual void delete_created_pointers() = 0;
148 virtual void reset_object_address(
149 const void * new_address,
150 const void * old_address
151 ) = 0;
153 virtual void load_binary(void * t, std::size_t size) = 0;
155 // these are used by the serialization library implementation.
156 virtual void load_object(
157 void *t,
158 const detail::basic_iserializer & bis
159 ) = 0;
160 virtual const detail::basic_pointer_iserializer * load_pointer(
161 void * & t,
162 const detail::basic_pointer_iserializer * bpis_ptr,
163 const detail::basic_pointer_iserializer * (*finder)(
164 const boost::serialization::extended_type_info & type
166 ) = 0;
169 } // namespace archive
170 } // namespace boost
172 // note special treatment of shared_ptr. This type needs a special
173 // structure associated with every archive. We created a "mix-in"
174 // class to provide this functionality. Since shared_ptr holds a
175 // special esteem in the boost library - we included it here by default.
176 #include <boost/archive/shared_ptr_helper.hpp>
178 namespace boost {
179 namespace archive {
181 class polymorphic_iarchive :
182 public polymorphic_iarchive_impl,
183 public detail::shared_ptr_helper
185 public:
186 virtual ~polymorphic_iarchive(){};
189 } // namespace archive
190 } // namespace boost
192 // required by export
193 BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::polymorphic_iarchive)
195 #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
197 #endif // BOOST_ARCHIVE_POLYMORPHIC_IARCHIVE_HPP