1 #ifndef BOOST_ARCHIVE_POLYMORPHIC_OARCHIVE_HPP
2 #define BOOST_ARCHIVE_POLYMORPHIC_OARCHIVE_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_oarchive.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> // size_t
20 #include <climits> // ULONG_MAX
23 #include <boost/config.hpp>
24 #if defined(BOOST_NO_STDC_NAMESPACE)
30 #include <boost/cstdint.hpp>
31 #include <boost/serialization/pfto.hpp>
32 #include <boost/archive/detail/oserializer.hpp>
33 #include <boost/archive/detail/interface_oarchive.hpp>
34 #include <boost/serialization/nvp.hpp>
35 #include <boost/archive/detail/register_archive.hpp>
37 #include <boost/archive/detail/decl.hpp>
38 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
40 // determine if its necessary to handle (u)int64_t specifically
41 // i.e. that its not a synonym for (unsigned) long
42 // if there is no 64 bit int or if its the same as a long
43 // we shouldn't define separate functions for int64 data types.
44 #if defined(BOOST_NO_INT64_T)
45 #define BOOST_NO_INTRINSIC_INT64_T
47 #if defined(ULLONG_MAX)
48 #if(ULONG_MAX == 18446744073709551615ul) // 2**64 - 1
49 #define BOOST_NO_INTRINSIC_INT64_T
51 #elif defined(ULONG_MAX)
52 #if(ULONG_MAX != 0xffffffff && ULONG_MAX == 18446744073709551615ul) // 2**64 - 1
53 #define BOOST_NO_INTRINSIC_INT64_T
56 #define BOOST_NO_INTRINSIC_INT64_T
63 namespace serialization
{
64 class extended_type_info
;
65 } // namespace serialization
68 class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oarchive
;
69 class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oserializer
;
72 class polymorphic_oarchive
;
74 class polymorphic_oarchive_impl
:
75 public detail::interface_oarchive
<polymorphic_oarchive
>
77 #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
80 friend class detail::interface_oarchive
<polymorphic_oarchive
>;
81 friend class save_access
;
83 // primitive types the only ones permitted by polymorphic archives
84 virtual void save(const bool t
) = 0;
86 virtual void save(const char t
) = 0;
87 virtual void save(const signed char t
) = 0;
88 virtual void save(const unsigned char t
) = 0;
89 #ifndef BOOST_NO_CWCHAR
90 #ifndef BOOST_NO_INTRINSIC_WCHAR_T
91 virtual void save(const wchar_t t
) = 0;
94 virtual void save(const short t
) = 0;
95 virtual void save(const unsigned short t
) = 0;
96 virtual void save(const int t
) = 0;
97 virtual void save(const unsigned int t
) = 0;
98 virtual void save(const long t
) = 0;
99 virtual void save(const unsigned long t
) = 0;
100 #if !defined(BOOST_NO_INTRINSIC_INT64_T)
101 virtual void save(const boost::int64_t t
) = 0;
102 virtual void save(const boost::uint64_t t
) = 0;
104 virtual void save(const float t
) = 0;
105 virtual void save(const double t
) = 0;
107 // string types are treated as primitives
108 virtual void save(const std::string
& t
) = 0;
109 #ifndef BOOST_NO_STD_WSTRING
110 virtual void save(const std::wstring
& t
) = 0;
113 virtual void save_null_pointer() = 0;
114 // used for xml and other tagged formats
115 virtual void save_start(const char * name
) = 0;
116 virtual void save_end(const char * name
) = 0;
117 virtual void register_basic_serializer(const detail::basic_oserializer
& bos
) = 0;
119 virtual void end_preamble() = 0;
121 // msvc and borland won't automatically pass these to the base class so
122 // make it explicit here
124 void save_override(T
& t
, BOOST_PFTO
int)
126 archive::save(* this->This(), t
);
128 // special treatment for name-value pairs.
131 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
134 ::boost::serialization::nvp
<T
> & t
, int
136 save_start(t
.name());
137 archive::save(* this->This(), t
.const_value());
141 virtual ~polymorphic_oarchive_impl(){};
143 // utility functions implemented by all legal archives
144 virtual unsigned int get_flags() const = 0;
145 virtual unsigned int get_library_version() const = 0;
146 virtual void save_binary(const void * t
, std::size_t size
) = 0;
148 virtual void save_object(
150 const detail::basic_oserializer
& bos
152 virtual void save_pointer(
154 const detail::basic_pointer_oserializer
* bpos_ptr
158 // note: preserve naming symmetry
159 class polymorphic_oarchive
:
160 public polymorphic_oarchive_impl
163 virtual ~polymorphic_oarchive(){};
166 } // namespace archive
169 // required by export
170 BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::polymorphic_oarchive
)
172 #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
174 #endif // BOOST_ARCHIVE_POLYMORPHIC_OARCHIVE_HPP