Statistics
| Revision:

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

History | View | Annotate | Download (6.1 kB)

1
#ifndef BOOST_ARCHIVE_BASIC_BINARY_OARCHIVE_HPP
2
#define BOOST_ARCHIVE_BASIC_BINARY_OARCHIVE_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_oarchive.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
// archives stored as native binary - this should be the fastest way
20
// to archive the state of a group of obects.  It makes no attempt to
21
// convert to any canonical form.
22

    
23
// IN GENERAL, ARCHIVES CREATED WITH THIS CLASS WILL NOT BE READABLE
24
// ON PLATFORM APART FROM THE ONE THEY ARE CREATE ON
25

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

    
30
#include <boost/integer.hpp>
31
#include <boost/integer_traits.hpp>
32

    
33
#include <boost/archive/detail/common_oarchive.hpp>
34
#include <boost/serialization/string.hpp>
35
#include <boost/serialization/collection_size_type.hpp>
36
#include <boost/serialization/item_version_type.hpp>
37

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

    
40
#ifdef BOOST_MSVC
41
#  pragma warning(push)
42
#  pragma warning(disable : 4511 4512)
43
#endif
44

    
45
namespace boost {
46
namespace archive {
47

    
48
namespace detail {
49
    template<class Archive> class interface_oarchive;
50
} // namespace detail
51

    
52
//////////////////////////////////////////////////////////////////////
53
// class basic_binary_oarchive - write serialized objects to a binary output stream
54
// note: this archive has no pretensions to portability.  Archive format
55
// may vary across machine architectures and compilers.  About the only
56
// guarentee is that an archive created with this code will be readable
57
// by a program built with the same tools for the same machne.  This class
58
// does have the virtue of buiding the smalles archive in the minimum amount
59
// of time.  So under some circumstances it may be he right choice.
60
template<class Archive>
61
class BOOST_SYMBOL_VISIBLE basic_binary_oarchive : 
62
    public detail::common_oarchive<Archive>
63
{
64
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
65
public:
66
#else
67
protected:
68
    #if BOOST_WORKAROUND(BOOST_MSVC, < 1500)
69
        // for some inexplicable reason insertion of "class" generates compile erro
70
        // on msvc 7.1
71
        friend detail::interface_oarchive<Archive>;
72
    #else
73
        friend class detail::interface_oarchive<Archive>;
74
    #endif
75
#endif
76
    // any datatype not specifed below will be handled by base class
77
    typedef detail::common_oarchive<Archive> detail_common_oarchive;
78
    template<class T>
79
    void save_override(const T & t){
80
      this->detail_common_oarchive::save_override(t);
81
    }
82

    
83
    // include these to trap a change in binary format which
84
    // isn't specifically handled
85
    BOOST_STATIC_ASSERT(sizeof(tracking_type) == sizeof(bool));
86
    // upto 32K classes
87
    BOOST_STATIC_ASSERT(sizeof(class_id_type) == sizeof(int_least16_t));
88
    BOOST_STATIC_ASSERT(sizeof(class_id_reference_type) == sizeof(int_least16_t));
89
    // upto 2G objects
90
    BOOST_STATIC_ASSERT(sizeof(object_id_type) == sizeof(uint_least32_t));
91
    BOOST_STATIC_ASSERT(sizeof(object_reference_type) == sizeof(uint_least32_t));
92

    
93
    // binary files don't include the optional information 
94
    void save_override(const class_id_optional_type & /* t */){}
95

    
96
    // enable this if we decide to support generation of previous versions
97
    #if 0
98
    void save_override(const boost::archive::version_type & t){
99
        library_version_type lvt = this->get_library_version();
100
        if(boost::archive::library_version_type(7) < lvt){
101
            this->detail_common_oarchive::save_override(t);
102
        }
103
        else
104
        if(boost::archive::library_version_type(6) < lvt){
105
            const boost::uint_least16_t x = t;
106
            * this->This() << x;
107
        }
108
        else{
109
            const unsigned int x = t;
110
            * this->This() << x;
111
        }
112
    }
113
    void save_override(const boost::serialization::item_version_type & t){
114
        library_version_type lvt = this->get_library_version();
115
        if(boost::archive::library_version_type(7) < lvt){
116
            this->detail_common_oarchive::save_override(t);
117
        }
118
        else
119
        if(boost::archive::library_version_type(6) < lvt){
120
            const boost::uint_least16_t x = t;
121
            * this->This() << x;
122
        }
123
        else{
124
            const unsigned int x = t;
125
            * this->This() << x;
126
        }
127
    }
128

129
    void save_override(class_id_type & t){
130
        library_version_type lvt = this->get_library_version();
131
        if(boost::archive::library_version_type(7) < lvt){
132
            this->detail_common_oarchive::save_override(t);
133
        }
134
        else
135
        if(boost::archive::library_version_type(6) < lvt){
136
            const boost::int_least16_t x = t;
137
            * this->This() << x;
138
        }
139
        else{
140
            const int x = t;
141
            * this->This() << x;
142
        }
143
    }
144
    void save_override(class_id_reference_type & t){
145
        save_override(static_cast<class_id_type &>(t));
146
    }
147

148
    #endif
149

150
    // explicitly convert to char * to avoid compile ambiguities
151
    void save_override(const class_name_type & t){
152
        const std::string s(t);
153
        * this->This() << s;
154
    }
155

156
    #if 0
157
    void save_override(const serialization::collection_size_type & t){
158
        if (get_library_version() < boost::archive::library_version_type(6)){
159
            unsigned int x=0;
160
            * this->This() >> x;
161
            t = serialization::collection_size_type(x);
162
        } 
163
        else{
164
            * this->This() >> t;
165
        }
166
    }
167
    #endif
168
    BOOST_ARCHIVE_OR_WARCHIVE_DECL void
169
    init();
170

171
    basic_binary_oarchive(unsigned int flags) :
172
        detail::common_oarchive<Archive>(flags)
173
    {}
174
};
175

176
} // namespace archive
177
} // namespace boost
178

179
#ifdef BOOST_MSVC
180
#pragma warning(pop)
181
#endif
182

    
183
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
184

    
185
#endif // BOOST_ARCHIVE_BASIC_BINARY_OARCHIVE_HPP