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)
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)
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
48 #if defined(ULLONG_MAX)
49 #if(ULONG_MAX == 18446744073709551615ul) // 2**64 - 1
50 #define BOOST_NO_INTRINSIC_INT64_T
52 #elif defined(ULONG_MAX)
53 #if(ULONG_MAX != 0xffffffff && ULONG_MAX == 18446744073709551615ul) // 2**64 - 1
54 #define BOOST_NO_INTRINSIC_INT64_T
57 #define BOOST_NO_INTRINSIC_INT64_T
64 namespace serialization
{
65 class extended_type_info
;
66 } // namespace serialization
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
81 friend class detail::interface_iarchive
<polymorphic_iarchive
>;
82 friend class load_access
;
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;
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;
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;
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
123 void load_override(T
& t
, BOOST_PFTO
int)
125 archive::load(* this->This(), t
);
127 // special treatment for name-value pairs.
130 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
133 boost::serialization::nvp
<T
> & t
,
136 load_start(t
.name());
137 archive::load(* this->This(), t
.value());
141 virtual ~polymorphic_iarchive_impl(){};
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
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(
158 const detail::basic_iserializer
& bis
160 virtual const detail::basic_pointer_iserializer
* load_pointer(
162 const detail::basic_pointer_iserializer
* bpis_ptr
,
163 const detail::basic_pointer_iserializer
* (*finder
)(
164 const boost::serialization::extended_type_info
& type
169 } // namespace archive
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>
181 class polymorphic_iarchive
:
182 public polymorphic_iarchive_impl
,
183 public detail::shared_ptr_helper
186 virtual ~polymorphic_iarchive(){};
189 } // namespace archive
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