]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/serialization/serialization.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / serialization / serialization.hpp
CommitLineData
7c673cae
FG
1#ifndef BOOST_SERIALIZATION_SERIALIZATION_HPP
2#define BOOST_SERIALIZATION_SERIALIZATION_HPP
3
4// MS compatible compilers support #pragma once
5#if defined(_MSC_VER)
6# pragma once
7#endif
8
9#if defined(_MSC_VER)
10# pragma warning (disable : 4675) // suppress ADL warning
11#endif
12
13#include <boost/config.hpp>
14#include <boost/serialization/strong_typedef.hpp>
15
16/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
17// serialization.hpp: interface for serialization system.
18
f67539c2 19// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
7c673cae
FG
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//////////////////////////////////////////////////////////////////////
f67539c2 27// public interface to serialization.
7c673cae
FG
28
29/////////////////////////////////////////////////////////////////////////////
30// layer 0 - intrusive verison
31// declared and implemented for each user defined class to be serialized
32//
33// template<Archive>
34// serialize(Archive &ar, const unsigned int file_version){
35// ar & base_object<base>(*this) & member1 & member2 ... ;
36// }
37
38/////////////////////////////////////////////////////////////////////////////
39// layer 1 - layer that routes member access through the access class.
40// this is what permits us to grant access to private class member functions
41// by specifying friend class boost::serialization::access
42
43#include <boost/serialization/access.hpp>
44
45/////////////////////////////////////////////////////////////////////////////
46// layer 2 - default implementation of non-intrusive serialization.
47//
7c673cae
FG
48
49namespace boost {
50namespace serialization {
51
52BOOST_STRONG_TYPEDEF(unsigned int, version_type)
53
54// default implementation - call the member function "serialize"
55template<class Archive, class T>
56inline void serialize(
57 Archive & ar, T & t, const unsigned int file_version
58){
59 access::serialize(ar, t, static_cast<unsigned int>(file_version));
60}
61
62// save data required for construction
63template<class Archive, class T>
64inline void save_construct_data(
f67539c2
TL
65 Archive & /*ar*/,
66 const T * /*t*/,
7c673cae
FG
67 const unsigned int /*file_version */
68){
69 // default is to save no data because default constructor
70 // requires no arguments.
71}
72
73// load data required for construction and invoke constructor in place
74template<class Archive, class T>
75inline void load_construct_data(
f67539c2
TL
76 Archive & /*ar*/,
77 T * t,
7c673cae
FG
78 const unsigned int /*file_version*/
79){
80 // default just uses the default constructor. going
81 // through access permits usage of otherwise private default
82 // constructor
83 access::construct(t);
84}
85
86/////////////////////////////////////////////////////////////////////////////
87// layer 3 - move call into serialization namespace so that ADL will function
88// in the manner we desire.
89//
90// on compilers which don't implement ADL. only the current namespace
91// i.e. boost::serialization will be searched.
f67539c2 92//
7c673cae
FG
93// on compilers which DO implement ADL
94// serialize overrides can be in any of the following
f67539c2 95//
7c673cae
FG
96// 1) same namepace as Archive
97// 2) same namespace as T
98// 3) boost::serialization
99//
100// Due to Martin Ecker
101
102template<class Archive, class T>
103inline void serialize_adl(
f67539c2
TL
104 Archive & ar,
105 T & t,
7c673cae
FG
106 const unsigned int file_version
107){
7c673cae
FG
108 const version_type v(file_version);
109 serialize(ar, t, v);
110}
111
112template<class Archive, class T>
113inline void save_construct_data_adl(
f67539c2
TL
114 Archive & ar,
115 const T * t,
7c673cae
FG
116 const unsigned int file_version
117){
f67539c2 118
7c673cae
FG
119 const version_type v(file_version);
120 save_construct_data(ar, t, v);
121}
122
123template<class Archive, class T>
124inline void load_construct_data_adl(
f67539c2
TL
125 Archive & ar,
126 T * t,
7c673cae
FG
127 const unsigned int file_version
128){
129 // see above comment
130 const version_type v(file_version);
131 load_construct_data(ar, t, v);
132}
133
134} // namespace serialization
135} // namespace boost
136
137#endif //BOOST_SERIALIZATION_SERIALIZATION_HPP