1 #ifndef BOOST_ARCHIVE_POLYMORPHIC_OARCHIVE_HPP
2 #define BOOST_ARCHIVE_POLYMORPHIC_OARCHIVE_HPP
4 // MS compatible compilers support #pragma once
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/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>
36 #include <boost/archive/detail/decl.hpp>
37 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
40 namespace serialization {
41 class extended_type_info;
42 } // namespace serialization
46 class basic_oserializer;
49 class polymorphic_oarchive;
51 class BOOST_SYMBOL_VISIBLE polymorphic_oarchive_impl :
52 public detail::interface_oarchive<polymorphic_oarchive>
54 #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
57 friend class detail::interface_oarchive<polymorphic_oarchive>;
58 friend class save_access;
60 // primitive types the only ones permitted by polymorphic archives
61 virtual void save(const bool t) = 0;
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;
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;
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;
86 virtual void save(const float t) = 0;
87 virtual void save(const double t) = 0;
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;
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;
102 virtual void end_preamble() = 0;
104 // msvc and borland won't automatically pass these to the base class so
105 // make it explicit here
107 void save_override(T & t)
109 archive::save(* this->This(), t);
111 // special treatment for name-value pairs.
114 const ::boost::serialization::nvp< T > & t
116 save_start(t.name());
117 archive::save(* this->This(), t.const_value());
121 virtual ~polymorphic_oarchive_impl() {}
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;
128 virtual void save_object(
130 const detail::basic_oserializer & bos
132 virtual void save_pointer(
134 const detail::basic_pointer_oserializer * bpos_ptr
138 // note: preserve naming symmetry
139 class BOOST_SYMBOL_VISIBLE polymorphic_oarchive :
140 public polymorphic_oarchive_impl
143 ~polymorphic_oarchive() BOOST_OVERRIDE {}
146 } // namespace archive
149 // required by export
150 BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::polymorphic_oarchive)
152 #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
154 #endif // BOOST_ARCHIVE_POLYMORPHIC_OARCHIVE_HPP