1 #ifndef BOOST_ARCHIVE_POLYMORPHIC_IARCHIVE_HPP 2 #define BOOST_ARCHIVE_POLYMORPHIC_IARCHIVE_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_iarchive.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> // std::size_t 20 #include <climits> // ULONG_MAX 21 #include <string> 22 23 #include <boost/config.hpp> 24 #if defined(BOOST_NO_STDC_NAMESPACE) 25 namespace std{ 26 using ::size_t; 27 } // namespace std 28 #endif 29 30 #include <boost/cstdint.hpp> 31 32 #include <boost/archive/detail/iserializer.hpp> 33 #include <boost/archive/detail/interface_iarchive.hpp> 34 #include <boost/serialization/nvp.hpp> 35 #include <boost/archive/detail/register_archive.hpp> 36 37 #include <boost/archive/detail/decl.hpp> 38 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header 39 40 namespace boost { 41 namespace serialization { 42 class extended_type_info; 43 } // namespace serialization 44 namespace archive { 45 namespace detail { 46 class basic_iarchive; 47 class basic_iserializer; 48 } 49 50 class polymorphic_iarchive; 51 52 class BOOST_SYMBOL_VISIBLE polymorphic_iarchive_impl : 53 public detail::interface_iarchive<polymorphic_iarchive> 54 { 55 #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS 56 public: 57 #else 58 friend class detail::interface_iarchive<polymorphic_iarchive>; 59 friend class load_access; 60 #endif 61 // primitive types the only ones permitted by polymorphic archives 62 virtual void load(bool & t) = 0; 63 64 virtual void load(char & t) = 0; 65 virtual void load(signed char & t) = 0; 66 virtual void load(unsigned char & t) = 0; 67 #ifndef BOOST_NO_CWCHAR 68 #ifndef BOOST_NO_INTRINSIC_WCHAR_T 69 virtual void load(wchar_t & t) = 0; 70 #endif 71 #endif 72 virtual void load(short & t) = 0; 73 virtual void load(unsigned short & t) = 0; 74 virtual void load(int & t) = 0; 75 virtual void load(unsigned int & t) = 0; 76 virtual void load(long & t) = 0; 77 virtual void load(unsigned long & t) = 0; 78 79 #if defined(BOOST_HAS_LONG_LONG) 80 virtual void load(boost::long_long_type & t) = 0; 81 virtual void load(boost::ulong_long_type & t) = 0; 82 #elif defined(BOOST_HAS_MS_INT64) 83 virtual void load(__int64 & t) = 0; 84 virtual void load(unsigned __int64 & t) = 0; 85 #endif 86 87 virtual void load(float & t) = 0; 88 virtual void load(double & t) = 0; 89 90 // string types are treated as primitives 91 virtual void load(std::string & t) = 0; 92 #ifndef BOOST_NO_STD_WSTRING 93 virtual void load(std::wstring & t) = 0; 94 #endif 95 96 // used for xml and other tagged formats 97 virtual void load_start(const char * name) = 0; 98 virtual void load_end(const char * name) = 0; 99 virtual void register_basic_serializer(const detail::basic_iserializer & bis) = 0; 100 virtual detail::helper_collection & get_helper_collection() = 0; 101 102 // msvc and borland won't automatically pass these to the base class so 103 // make it explicit here 104 template<class T> load_override(T & t)105 void load_override(T & t) 106 { 107 archive::load(* this->This(), t); 108 } 109 // special treatment for name-value pairs. 110 template<class T> load_override(const boost::serialization::nvp<T> & t)111 void load_override( 112 const boost::serialization::nvp< T > & t 113 ){ 114 load_start(t.name()); 115 archive::load(* this->This(), t.value()); 116 load_end(t.name()); 117 } 118 protected: ~polymorphic_iarchive_impl()119 virtual ~polymorphic_iarchive_impl(){}; 120 public: 121 // utility function implemented by all legal archives 122 virtual void set_library_version(library_version_type archive_library_version) = 0; 123 virtual library_version_type get_library_version() const = 0; 124 virtual unsigned int get_flags() const = 0; 125 virtual void delete_created_pointers() = 0; 126 virtual void reset_object_address( 127 const void * new_address, 128 const void * old_address 129 ) = 0; 130 131 virtual void load_binary(void * t, std::size_t size) = 0; 132 133 // these are used by the serialization library implementation. 134 virtual void load_object( 135 void *t, 136 const detail::basic_iserializer & bis 137 ) = 0; 138 virtual const detail::basic_pointer_iserializer * load_pointer( 139 void * & t, 140 const detail::basic_pointer_iserializer * bpis_ptr, 141 const detail::basic_pointer_iserializer * (*finder)( 142 const boost::serialization::extended_type_info & type 143 ) 144 ) = 0; 145 }; 146 147 } // namespace archive 148 } // namespace boost 149 150 #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas 151 152 namespace boost { 153 namespace archive { 154 155 class BOOST_SYMBOL_VISIBLE polymorphic_iarchive : 156 public polymorphic_iarchive_impl 157 { 158 public: ~polymorphic_iarchive()159 virtual ~polymorphic_iarchive(){}; 160 }; 161 162 } // namespace archive 163 } // namespace boost 164 165 // required by export 166 BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::polymorphic_iarchive) 167 168 #endif // BOOST_ARCHIVE_POLYMORPHIC_IARCHIVE_HPP 169