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)
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.
21 #include <cstddef> // std::size_t
22 #include <boost/config.hpp>
23 #if defined(BOOST_NO_STDC_NAMESPACE)
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>
36 namespace serialization {
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);
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);
49 BOOST_SERIALIZATION_SPLIT_MEMBER()
50 binary_object(/* const */ void * const t, std::size_t size) :
54 binary_object(const binary_object & rhs) :
60 // just a little helper to support the convention that all serialization
61 // wrappers follow the naming convention make_xxxxx
63 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
67 make_binary_object(/* const */ void * t, std::size_t size){
68 return binary_object(t, size);
71 } // namespace serialization
74 // don't need versioning info for this type
75 BOOST_CLASS_IMPLEMENTATION(
77 boost::serialization::object_serializable
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.
86 BOOST_CLASS_TRACKING(binary_object, boost::serialization::track_never)
88 #endif // BOOST_SERIALIZATION_BINARY_OBJECT_HPP