Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / archive / basic_binary_iarchive.hpp @ 2486

History | View | Annotate | Download (6.7 kB)

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)
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

    
26
#include <boost/config.hpp>
27
#include <boost/detail/workaround.hpp>
28

    
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>
35

    
36
#ifdef BOOST_MSVC
37
#  pragma warning(push)
38
#  pragma warning(disable : 4511 4512)
39
#endif
40

    
41
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
42

    
43
namespace boost { 
44
namespace archive {
45

    
46
namespace detail {
47
    template<class Archive> class interface_iarchive;
48
} // namespace detail
49

    
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>
55
{
56
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
57
public:
58
#else
59
protected:
60
    #if BOOST_WORKAROUND(BOOST_MSVC, < 1500)
61
        // for some inexplicable reason insertion of "class" generates compile erro
62
        // on msvc 7.1
63
        friend detail::interface_iarchive<Archive>;
64
    #else
65
        friend class detail::interface_iarchive<Archive>;
66
    #endif
67
#endif
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;
73
    template<class T>
74
    void load_override(T & t){
75
      this->detail_common_iarchive::load_override(t);
76
    }
77

    
78
    // include these to trap a change in binary format which
79
    // isn't specifically handled
80
    // upto 32K classes
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));
83
    // upto 2G objects
84
    BOOST_STATIC_ASSERT(sizeof(object_id_type) == sizeof(uint_least32_t));
85
    BOOST_STATIC_ASSERT(sizeof(object_reference_type) == sizeof(uint_least32_t));
86

    
87
    // binary files don't include the optional information 
88
    void load_override(class_id_optional_type & /* t */){}
89

    
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){
93
            int_least8_t x=0;
94
            * this->This() >> x;
95
            t = boost::archive::tracking_type(x);
96
        }
97
        else{
98
            bool x=0;
99
            * this->This() >> x;
100
            t = boost::archive::tracking_type(x);
101
        }
102
    }
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);
107
        }
108
        else
109
        if(boost::archive::library_version_type(6) < lvt){
110
            int_least16_t x=0;
111
            * this->This() >> x;
112
            t = boost::archive::class_id_type(x);
113
        }
114
        else{
115
            int x=0;
116
            * this->This() >> x;
117
            t = boost::archive::class_id_type(x);
118
        }
119
    }
120
    void load_override(class_id_reference_type & t){
121
        load_override(static_cast<class_id_type &>(t));
122
    }
123

    
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);
128
        }
129
        else
130
        if(boost::archive::library_version_type(6) < lvt){
131
            uint_least8_t x=0;
132
            * this->This() >> x;
133
            t = boost::archive::version_type(x);
134
        }
135
        else
136
        if(boost::archive::library_version_type(5) < lvt){
137
            uint_least16_t x=0;
138
            * this->This() >> x;
139
            t = boost::archive::version_type(x);
140
        }
141
        else
142
        if(boost::archive::library_version_type(2) < lvt){
143
            // upto 255 versions
144
            unsigned char x=0;
145
            * this->This() >> x;
146
            t = version_type(x);
147
        }
148
        else{
149
            unsigned int x=0;
150
            * this->This() >> x;
151
            t = boost::archive::version_type(x);
152
        }
153
    }
154

    
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);
160
        }
161
        else
162
        if(boost::archive::library_version_type(6) < lvt){
163
            uint_least16_t x=0;
164
            * this->This() >> x;
165
            t = boost::serialization::item_version_type(x);
166
        }
167
        else{
168
            unsigned int x=0;
169
            * this->This() >> x;
170
            t = boost::serialization::item_version_type(x);
171
        }
172
    }
173

    
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);
177
        }
178
        else{
179
            unsigned int x=0;
180
            * this->This() >> x;
181
            t = serialization::collection_size_type(x);
182
        } 
183
    }
184

    
185
    BOOST_ARCHIVE_OR_WARCHIVE_DECL void
186
    load_override(class_name_type & t);
187
    BOOST_ARCHIVE_OR_WARCHIVE_DECL void
188
    init();
189
   
190
    basic_binary_iarchive(unsigned int flags) :
191
        detail::common_iarchive<Archive>(flags)
192
    {}
193
};
194

    
195
} // namespace archive
196
} // namespace boost
197

    
198
#ifdef BOOST_MSVC
199
#pragma warning(pop)
200
#endif
201

    
202
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
203

    
204
#endif // BOOST_ARCHIVE_BASIC_BINARY_IARCHIVE_HPP