1 #ifndef BOOST_ARCHIVE_BASIC_BINARY_IARCHIVE_HPP
2 #define BOOST_ARCHIVE_BASIC_BINARY_IARCHIVE_HPP
4 // MS compatible compilers support #pragma once
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // basic_binary_iarchive.hpp
12 // archives stored as native binary - this should be the fastest way
13 // to archive the state of a group of obects. It makes no attempt to
14 // convert to any canonical form.
16 // IN GENERAL, ARCHIVES CREATED WITH THIS CLASS WILL NOT BE READABLE
17 // ON PLATFORM APART FROM THE ONE THEY ARE CREATED ON
19 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
20 // Use, modification and distribution is subject to the Boost Software
21 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
22 // http://www.boost.org/LICENSE_1_0.txt)
24 // See http://www.boost.org for updates, documentation, and revision history.
26 #include <boost/config.hpp>
27 #include <boost/detail/workaround.hpp>
29 #include <boost/archive/basic_archive.hpp>
30 #include <boost/archive/detail/common_iarchive.hpp>
31 #include <boost/serialization/collection_size_type.hpp>
32 #include <boost/serialization/string.hpp>
33 #include <boost/serialization/item_version_type.hpp>
34 #include <boost/integer_traits.hpp>
37 # pragma warning(push)
38 # pragma warning(disable : 4511 4512)
41 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
47 template<class Archive> class interface_iarchive;
50 /////////////////////////////////////////////////////////////////////////
51 // class basic_binary_iarchive - read serialized objects from a input binary stream
52 template<class Archive>
53 class BOOST_SYMBOL_VISIBLE basic_binary_iarchive :
54 public detail::common_iarchive<Archive>
56 #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
60 #if BOOST_WORKAROUND(BOOST_MSVC, < 1500)
61 // for some inexplicable reason insertion of "class" generates compile erro
63 friend detail::interface_iarchive<Archive>;
65 friend class detail::interface_iarchive<Archive>;
68 // intermediate level to support override of operators
69 // fot templates in the absence of partial function
70 // template ordering. If we get here pass to base class
71 // note extra nonsense to sneak it pass the borland compiers
72 typedef detail::common_iarchive<Archive> detail_common_iarchive;
74 void load_override(T & t){
75 this->detail_common_iarchive::load_override(t);
78 // include these to trap a change in binary format which
79 // isn't specifically handled
81 BOOST_STATIC_ASSERT(sizeof(class_id_type) == sizeof(int_least16_t));
82 BOOST_STATIC_ASSERT(sizeof(class_id_reference_type) == sizeof(int_least16_t));
84 BOOST_STATIC_ASSERT(sizeof(object_id_type) == sizeof(uint_least32_t));
85 BOOST_STATIC_ASSERT(sizeof(object_reference_type) == sizeof(uint_least32_t));
87 // binary files don't include the optional information
88 void load_override(class_id_optional_type & /* t */){}
90 void load_override(tracking_type & t, int /*version*/){
91 library_version_type lvt = this->get_library_version();
92 if(boost::archive::library_version_type(6) < lvt){
95 t = boost::archive::tracking_type(x);
100 t = boost::archive::tracking_type(x);
103 void load_override(class_id_type & t){
104 library_version_type lvt = this->get_library_version();
105 if(boost::archive::library_version_type(7) < lvt){
106 this->detail_common_iarchive::load_override(t);
109 if(boost::archive::library_version_type(6) < lvt){
112 t = boost::archive::class_id_type(x);
117 t = boost::archive::class_id_type(x);
120 void load_override(class_id_reference_type & t){
121 load_override(static_cast<class_id_type &>(t));
124 void load_override(version_type & t){
125 library_version_type lvt = this->get_library_version();
126 if(boost::archive::library_version_type(7) < lvt){
127 this->detail_common_iarchive::load_override(t);
130 if(boost::archive::library_version_type(6) < lvt){
133 t = boost::archive::version_type(x);
136 if(boost::archive::library_version_type(5) < lvt){
139 t = boost::archive::version_type(x);
142 if(boost::archive::library_version_type(2) < lvt){
151 t = boost::archive::version_type(x);
155 void load_override(boost::serialization::item_version_type & t){
156 library_version_type lvt = this->get_library_version();
157 // if(boost::archive::library_version_type(7) < lvt){
158 if(boost::archive::library_version_type(6) < lvt){
159 this->detail_common_iarchive::load_override(t);
162 if(boost::archive::library_version_type(6) < lvt){
165 t = boost::serialization::item_version_type(x);
170 t = boost::serialization::item_version_type(x);
174 void load_override(serialization::collection_size_type & t){
175 if(boost::archive::library_version_type(5) < this->get_library_version()){
176 this->detail_common_iarchive::load_override(t);
181 t = serialization::collection_size_type(x);
185 BOOST_ARCHIVE_OR_WARCHIVE_DECL void
186 load_override(class_name_type & t);
187 BOOST_ARCHIVE_OR_WARCHIVE_DECL void
190 basic_binary_iarchive(unsigned int flags) :
191 detail::common_iarchive<Archive>(flags)
195 } // namespace archive
202 #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
204 #endif // BOOST_ARCHIVE_BASIC_BINARY_IARCHIVE_HPP