fix doc example typo
[boost.git] / boost / serialization / binary_object.hpp
blob1f49a4f9f8c76364cfb7f0b19b7d0bd8ead1564d
1 #ifndef BOOST_SERIALIZATION_BINARY_OBJECT_HPP
2 #define BOOST_SERIALIZATION_BINARY_OBJECT_HPP
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
6 # pragma once
7 #endif
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // nvp.hpp: interface for serialization system.
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)
17 // See http://www.boost.org for updates, documentation, and revision history.
19 #include <cassert>
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
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 #include <boost/serialization/wrapper.hpp>
36 namespace boost {
37 namespace serialization {
39 struct binary_object {
40 /* const */ void * const m_t;
41 const std::size_t m_size;
42 template<class Archive>
43 void save(Archive & ar, const unsigned int /* file_version */) const {
44 ar.save_binary(m_t, m_size);
46 template<class Archive>
47 void load(Archive & ar, const unsigned int /* file_version */) const {
48 ar.load_binary(const_cast<void *>(m_t), m_size);
50 BOOST_SERIALIZATION_SPLIT_MEMBER()
51 binary_object(/* const */ void * const t, std::size_t size) :
52 m_t(t),
53 m_size(size)
55 binary_object(const binary_object & rhs) :
56 m_t(rhs.m_t),
57 m_size(rhs.m_size)
61 // just a little helper to support the convention that all serialization
62 // wrappers follow the naming convention make_xxxxx
63 inline
64 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
65 const
66 #endif
67 binary_object
68 make_binary_object(/* const */ void * t, std::size_t size){
69 return binary_object(t, size);
72 // this is a wrapper
74 template <>
75 struct is_wrapper<binary_object>
76 : public mpl::true_
77 {};
79 } // namespace serialization
80 } // boost
82 // don't need versioning info for this type
83 BOOST_CLASS_IMPLEMENTATION(
84 binary_object,
85 boost::serialization::object_serializable
88 // don't track binary objects - usually they will be created on the stack
89 // and tracking algorithm (which uses the object address) might get
90 // confused. note that these address will likely be members of some
91 // other structure which itself is tracked, so as a practical matter
92 // suppressing tracking shouldn't cause any redundancy.
94 BOOST_CLASS_TRACKING(binary_object, boost::serialization::track_never)
96 #endif // BOOST_SERIALIZATION_BINARY_OBJECT_HPP