[857] | 1 | #ifndef BOOST_ARCHIVE_BASIC_BINARY_IARCHIVE_HPP
|
---|
| 2 | #define BOOST_ARCHIVE_BASIC_BINARY_IARCHIVE_HPP
|
---|
| 3 |
|
---|
| 4 | // MS compatible compilers support #pragma once
|
---|
| 5 | #if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
---|
| 6 | # pragma once
|
---|
| 7 | #endif
|
---|
| 8 |
|
---|
| 9 | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
---|
| 10 | // basic_binary_iarchive.hpp
|
---|
| 11 | //
|
---|
| 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.
|
---|
| 15 |
|
---|
| 16 | // IN GENERAL, ARCHIVES CREATED WITH THIS CLASS WILL NOT BE READABLE
|
---|
| 17 | // ON PLATFORM APART FROM THE ONE THEY ARE CREATED ON
|
---|
| 18 |
|
---|
| 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)
|
---|
| 23 |
|
---|
| 24 | // See http://www.boost.org for updates, documentation, and revision history.
|
---|
| 25 | #include <cstring>
|
---|
| 26 |
|
---|
| 27 | #include <boost/config.hpp>
|
---|
| 28 | #include <boost/detail/workaround.hpp>
|
---|
| 29 | #if defined(BOOST_NO_STDC_NAMESPACE)
|
---|
| 30 | namespace std{ using ::memcpy; }
|
---|
| 31 | #endif
|
---|
| 32 |
|
---|
| 33 | #include <boost/throw_exception.hpp>
|
---|
| 34 | #include <boost/pfto.hpp>
|
---|
| 35 |
|
---|
| 36 | #include <boost/archive/detail/iserializer.hpp>
|
---|
| 37 | #include <boost/archive/detail/interface_iarchive.hpp>
|
---|
| 38 | #include <boost/archive/detail/common_iarchive.hpp>
|
---|
| 39 |
|
---|
| 40 | #include <boost/serialization/string.hpp>
|
---|
| 41 |
|
---|
| 42 | #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
---|
| 43 |
|
---|
| 44 | namespace boost {
|
---|
| 45 | namespace archive {
|
---|
| 46 |
|
---|
| 47 | /////////////////////////////////////////////////////////////////////////
|
---|
| 48 | // class basic_binary_iarchive - read serialized objects from a input binary stream
|
---|
| 49 | template<class Archive>
|
---|
| 50 | class basic_binary_iarchive :
|
---|
| 51 | public detail::common_iarchive<Archive>
|
---|
| 52 | {
|
---|
| 53 | #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
---|
| 54 | public:
|
---|
| 55 | #elif defined(BOOST_MSVC)
|
---|
| 56 | // for some inexplicable reason insertion of "class" generates compile erro
|
---|
| 57 | // on msvc 7.1
|
---|
| 58 | friend detail::interface_iarchive<Archive>;
|
---|
| 59 | protected:
|
---|
| 60 | #else
|
---|
| 61 | friend class detail::interface_iarchive<Archive>;
|
---|
| 62 | protected:
|
---|
| 63 | #endif
|
---|
| 64 | // intermediate level to support override of operators
|
---|
| 65 | // fot templates in the absence of partial function
|
---|
| 66 | // template ordering
|
---|
| 67 | template<class T>
|
---|
| 68 | void load_override(T & t, BOOST_PFTO int)
|
---|
| 69 | {
|
---|
| 70 | archive::load(* this->This(), t);
|
---|
| 71 | }
|
---|
| 72 | // binary files don't include the optional information
|
---|
| 73 | void load_override(class_id_optional_type & /* t */, int){}
|
---|
| 74 |
|
---|
| 75 | // the following have been overridden to provide specific sizes
|
---|
| 76 | // for these pseudo prmitive types.
|
---|
| 77 | void load_override(version_type & t, int){
|
---|
| 78 | // upto 255 versions
|
---|
| 79 | unsigned char x;
|
---|
| 80 | * this->This() >> x;
|
---|
| 81 | t = version_type(x);
|
---|
| 82 | }
|
---|
| 83 | void load_override(class_id_type & t, int){
|
---|
| 84 | // upto 32K classes
|
---|
| 85 | int_least16_t x;
|
---|
| 86 | * this->This() >> x;
|
---|
| 87 | t = class_id_type(x);
|
---|
| 88 | }
|
---|
| 89 | void load_override(class_id_reference_type & t, int){
|
---|
| 90 | // upto 32K classes
|
---|
| 91 | int_least16_t x;
|
---|
| 92 | * this->This() >> x;
|
---|
| 93 | t = class_id_reference_type(x);
|
---|
| 94 | }
|
---|
| 95 | void load_override(object_id_type & t, int){
|
---|
| 96 | // upto 2G objects
|
---|
| 97 | uint_least32_t x;
|
---|
| 98 | * this->This() >> x;
|
---|
| 99 | t = object_id_type(x);
|
---|
| 100 | }
|
---|
| 101 | void load_override(object_reference_type & t, int){
|
---|
| 102 | // upto 2G objects
|
---|
| 103 | uint_least32_t x;
|
---|
| 104 | * this->This() >> x;
|
---|
| 105 | t = object_reference_type(x);
|
---|
| 106 | }
|
---|
| 107 | void load_override(tracking_type & t, int){
|
---|
| 108 | char x;
|
---|
| 109 | * this->This() >> x;
|
---|
| 110 | t = (0 != x);
|
---|
| 111 | }
|
---|
| 112 |
|
---|
| 113 | BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
---|
| 114 | load_override(class_name_type & t, int);
|
---|
| 115 | BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
---|
| 116 | init();
|
---|
| 117 |
|
---|
| 118 | basic_binary_iarchive(unsigned int flags) :
|
---|
| 119 | detail::common_iarchive<Archive>(flags)
|
---|
| 120 | {}
|
---|
| 121 | };
|
---|
| 122 |
|
---|
| 123 | } // namespace archive
|
---|
| 124 | } // namespace boost
|
---|
| 125 |
|
---|
| 126 | #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
---|
| 127 |
|
---|
| 128 | #endif // BOOST_ARCHIVE_BASIC_BINARY_IARCHIVE_HPP
|
---|