1#ifndef BOOST_ARCHIVE_POLYMORPHIC_OARCHIVE_HPP
2#define BOOST_ARCHIVE_POLYMORPHIC_OARCHIVE_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_oarchive.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> // 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#include <boost/archive/detail/oserializer.hpp>
32#include <boost/archive/detail/interface_oarchive.hpp>
33#include <boost/serialization/nvp.hpp>
34#include <boost/archive/detail/register_archive.hpp>
35
36#include <boost/archive/detail/decl.hpp>
37#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
38
39namespace boost {
40namespace serialization {
41 class extended_type_info;
42} // namespace serialization
43namespace archive {
44namespace detail {
45 class basic_oarchive;
46 class basic_oserializer;
47}
48
49class polymorphic_oarchive;
50
51class BOOST_SYMBOL_VISIBLE polymorphic_oarchive_impl :
52 public detail::interface_oarchive<polymorphic_oarchive>
53{
54#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
55public:
56#else
57 friend class detail::interface_oarchive<polymorphic_oarchive>;
58 friend class save_access;
59#endif
60 // primitive types the only ones permitted by polymorphic archives
61 virtual void save(const bool t) = 0;
62
63 virtual void save(const char t) = 0;
64 virtual void save(const signed char t) = 0;
65 virtual void save(const unsigned char t) = 0;
66 #ifndef BOOST_NO_CWCHAR
67 #ifndef BOOST_NO_INTRINSIC_WCHAR_T
68 virtual void save(const wchar_t t) = 0;
69 #endif
70 #endif
71 virtual void save(const short t) = 0;
72 virtual void save(const unsigned short t) = 0;
73 virtual void save(const int t) = 0;
74 virtual void save(const unsigned int t) = 0;
75 virtual void save(const long t) = 0;
76 virtual void save(const unsigned long t) = 0;
77
78 #if defined(BOOST_HAS_LONG_LONG)
79 virtual void save(const boost::long_long_type t) = 0;
80 virtual void save(const boost::ulong_long_type t) = 0;
81 #elif defined(BOOST_HAS_MS_INT64)
82 virtual void save(const __int64 t) = 0;
83 virtual void save(const unsigned __int64 t) = 0;
84 #endif
85
86 virtual void save(const float t) = 0;
87 virtual void save(const double t) = 0;
88
89 // string types are treated as primitives
90 virtual void save(const std::string & t) = 0;
91 #ifndef BOOST_NO_STD_WSTRING
92 virtual void save(const std::wstring & t) = 0;
93 #endif
94
95 virtual void save_null_pointer() = 0;
96 // used for xml and other tagged formats
97 virtual void save_start(const char * name) = 0;
98 virtual void save_end(const char * name) = 0;
99 virtual void register_basic_serializer(const detail::basic_oserializer & bos) = 0;
100 virtual detail::helper_collection & get_helper_collection() = 0;
101
102 virtual void end_preamble() = 0;
103
104 // msvc and borland won't automatically pass these to the base class so
105 // make it explicit here
106 template<class T>
107 void save_override(T & t)
108 {
109 archive::save(* this->This(), t);
110 }
111 // special treatment for name-value pairs.
112 template<class T>
113 void save_override(
114 const ::boost::serialization::nvp< T > & t
115 ){
116 save_start(name: t.name());
117 archive::save(* this->This(), t.const_value());
118 save_end(name: t.name());
119 }
120protected:
121 virtual ~polymorphic_oarchive_impl() {}
122public:
123 // utility functions implemented by all legal archives
124 virtual unsigned int get_flags() const = 0;
125 virtual boost::serialization::library_version_type get_library_version() const = 0;
126 virtual void save_binary(const void * t, std::size_t size) = 0;
127
128 virtual void save_object(
129 const void *x,
130 const detail::basic_oserializer & bos
131 ) = 0;
132 virtual void save_pointer(
133 const void * t,
134 const detail::basic_pointer_oserializer * bpos_ptr
135 ) = 0;
136};
137
138// note: preserve naming symmetry
139class BOOST_SYMBOL_VISIBLE polymorphic_oarchive :
140 public polymorphic_oarchive_impl
141{
142public:
143 ~polymorphic_oarchive() BOOST_OVERRIDE {}
144};
145
146} // namespace archive
147} // namespace boost
148
149// required by export
150BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::polymorphic_oarchive)
151
152#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
153
154#endif // BOOST_ARCHIVE_POLYMORPHIC_OARCHIVE_HPP
155

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