1 | #ifndef BOOST_SERIALIZATION_BINARY_OBJECT_HPP
|
---|
2 | #define BOOST_SERIALIZATION_BINARY_OBJECT_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 | // nvp.hpp: interface for serialization system.
|
---|
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 <cassert>
|
---|
20 |
|
---|
21 | #include <cstddef> // std::size_t
|
---|
22 | #include <boost/config.hpp>
|
---|
23 | #if defined(BOOST_NO_STDC_NAMESPACE)
|
---|
24 | namespace std{
|
---|
25 | using ::size_t;
|
---|
26 | } // namespace std
|
---|
27 | #endif
|
---|
28 |
|
---|
29 | #include <boost/preprocessor/stringize.hpp>
|
---|
30 | #include <boost/serialization/tracking.hpp>
|
---|
31 | #include <boost/serialization/level.hpp>
|
---|
32 | #include <boost/serialization/split_member.hpp>
|
---|
33 | #include <boost/serialization/nvp.hpp>
|
---|
34 |
|
---|
35 | namespace boost {
|
---|
36 | namespace serialization {
|
---|
37 |
|
---|
38 | struct binary_object {
|
---|
39 | /* const */ void * const m_t;
|
---|
40 | const std::size_t m_size;
|
---|
41 | template<class Archive>
|
---|
42 | void save(Archive & ar, const unsigned int /* file_version */) const {
|
---|
43 | ar.save_binary(m_t, m_size);
|
---|
44 | }
|
---|
45 | template<class Archive>
|
---|
46 | void load(Archive & ar, const unsigned int /* file_version */) const {
|
---|
47 | ar.load_binary(const_cast<void *>(m_t), m_size);
|
---|
48 | }
|
---|
49 | BOOST_SERIALIZATION_SPLIT_MEMBER()
|
---|
50 | binary_object(/* const */ void * const t, std::size_t size) :
|
---|
51 | m_t(t),
|
---|
52 | m_size(size)
|
---|
53 | {}
|
---|
54 | binary_object(const binary_object & rhs) :
|
---|
55 | m_t(rhs.m_t),
|
---|
56 | m_size(rhs.m_size)
|
---|
57 | {}
|
---|
58 | };
|
---|
59 |
|
---|
60 | // just a little helper to support the convention that all serialization
|
---|
61 | // wrappers follow the naming convention make_xxxxx
|
---|
62 | inline
|
---|
63 | #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
---|
64 | const
|
---|
65 | #endif
|
---|
66 | binary_object
|
---|
67 | make_binary_object(/* const */ void * t, std::size_t size){
|
---|
68 | return binary_object(t, size);
|
---|
69 | }
|
---|
70 |
|
---|
71 | } // namespace serialization
|
---|
72 | } // boost
|
---|
73 |
|
---|
74 | // don't need versioning info for this type
|
---|
75 | BOOST_CLASS_IMPLEMENTATION(
|
---|
76 | binary_object,
|
---|
77 | boost::serialization::object_serializable
|
---|
78 | )
|
---|
79 |
|
---|
80 | // don't track binary objects - usually they will be created on the stack
|
---|
81 | // and tracking algorithm (which uses the object address) might get
|
---|
82 | // confused. note that these address will likely be members of some
|
---|
83 | // other structure which itself is tracked, so as a practical matter
|
---|
84 | // suppressing tracking shouldn't cause any redundancy.
|
---|
85 |
|
---|
86 | BOOST_CLASS_TRACKING(binary_object, boost::serialization::track_never)
|
---|
87 |
|
---|
88 | #endif // BOOST_SERIALIZATION_BINARY_OBJECT_HPP
|
---|