]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/serialization/hash_map.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / serialization / hash_map.hpp
1 #ifndef BOOST_SERIALIZATION_HASH_MAP_HPP
2 #define BOOST_SERIALIZATION_HASH_MAP_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 // serialization/hash_map.hpp:
11 // serialization for stl hash_map templates
12
13 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
14 // Use, modification and distribution is subject to the Boost Software
15 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
16 // http://www.boost.org/LICENSE_1_0.txt)
17
18 // See http://www.boost.org for updates, documentation, and revision history.
19
20 #include <boost/config.hpp>
21 #ifdef BOOST_HAS_HASH
22 #include BOOST_HASH_MAP_HEADER
23
24 #include <boost/serialization/utility.hpp>
25 #include <boost/serialization/hash_collections_save_imp.hpp>
26 #include <boost/serialization/hash_collections_load_imp.hpp>
27 #include <boost/serialization/split_free.hpp>
28 #include <boost/serialization/detail/stack_constructor.hpp>
29 #include <boost/move/utility_core.hpp>
30
31 namespace boost {
32 namespace serialization {
33
34 namespace stl {
35
36 // map input
37 template<class Archive, class Container>
38 struct archive_input_hash_map
39 {
40 inline void operator()(
41 Archive &ar,
42 Container &s,
43 const unsigned int v
44 ){
45 typedef typename Container::value_type type;
46 detail::stack_construct<Archive, type> t(ar, v);
47 // borland fails silently w/o full namespace
48 ar >> boost::serialization::make_nvp("item", t.reference());
49 std::pair<typename Container::const_iterator, bool> result =
50 s.insert(boost::move(t.reference()));
51 // note: the following presumes that the map::value_type was NOT tracked
52 // in the archive. This is the usual case, but here there is no way
53 // to determine that.
54 if(result.second){
55 ar.reset_object_address(
56 & (result.first->second),
57 & t.reference().second
58 );
59 }
60 }
61 };
62
63 // multimap input
64 template<class Archive, class Container>
65 struct archive_input_hash_multimap
66 {
67 inline void operator()(
68 Archive &ar,
69 Container &s,
70 const unsigned int v
71 ){
72 typedef typename Container::value_type type;
73 detail::stack_construct<Archive, type> t(ar, v);
74 // borland fails silently w/o full namespace
75 ar >> boost::serialization::make_nvp("item", t.reference());
76 typename Container::const_iterator result
77 = s.insert(boost::move(t.reference()));
78 // note: the following presumes that the map::value_type was NOT tracked
79 // in the archive. This is the usual case, but here there is no way
80 // to determine that.
81 ar.reset_object_address(
82 & result->second,
83 & t.reference()
84 );
85 }
86 };
87
88 } // stl
89
90 template<
91 class Archive,
92 class Key,
93 class T,
94 class HashFcn,
95 class EqualKey,
96 class Allocator
97 >
98 inline void save(
99 Archive & ar,
100 const BOOST_STD_EXTENSION_NAMESPACE::hash_map<
101 Key, T, HashFcn, EqualKey, Allocator
102 > &t,
103 const unsigned int file_version
104 ){
105 boost::serialization::stl::save_hash_collection<
106 Archive,
107 BOOST_STD_EXTENSION_NAMESPACE::hash_map<
108 Key, T, HashFcn, EqualKey, Allocator
109 >
110 >(ar, t);
111 }
112
113 template<
114 class Archive,
115 class Key,
116 class T,
117 class HashFcn,
118 class EqualKey,
119 class Allocator
120 >
121 inline void load(
122 Archive & ar,
123 BOOST_STD_EXTENSION_NAMESPACE::hash_map<
124 Key, T, HashFcn, EqualKey, Allocator
125 > &t,
126 const unsigned int file_version
127 ){
128 boost::serialization::stl::load_hash_collection<
129 Archive,
130 BOOST_STD_EXTENSION_NAMESPACE::hash_map<
131 Key, T, HashFcn, EqualKey, Allocator
132 >,
133 boost::serialization::stl::archive_input_hash_map<
134 Archive,
135 BOOST_STD_EXTENSION_NAMESPACE::hash_map<
136 Key, T, HashFcn, EqualKey, Allocator
137 >
138 >
139 >(ar, t);
140 }
141
142 // split non-intrusive serialization function member into separate
143 // non intrusive save/load member functions
144 template<
145 class Archive,
146 class Key,
147 class T,
148 class HashFcn,
149 class EqualKey,
150 class Allocator
151 >
152 inline void serialize(
153 Archive & ar,
154 BOOST_STD_EXTENSION_NAMESPACE::hash_map<
155 Key, T, HashFcn, EqualKey, Allocator
156 > &t,
157 const unsigned int file_version
158 ){
159 boost::serialization::split_free(ar, t, file_version);
160 }
161
162 // hash_multimap
163 template<
164 class Archive,
165 class Key,
166 class T,
167 class HashFcn,
168 class EqualKey,
169 class Allocator
170 >
171 inline void save(
172 Archive & ar,
173 const BOOST_STD_EXTENSION_NAMESPACE::hash_multimap<
174 Key, T, HashFcn, EqualKey, Allocator
175 > &t,
176 const unsigned int file_version
177 ){
178 boost::serialization::stl::save_hash_collection<
179 Archive,
180 BOOST_STD_EXTENSION_NAMESPACE::hash_multimap<
181 Key, T, HashFcn, EqualKey, Allocator
182 >
183 >(ar, t);
184 }
185
186 template<
187 class Archive,
188 class Key,
189 class T,
190 class HashFcn,
191 class EqualKey,
192 class Allocator
193 >
194 inline void load(
195 Archive & ar,
196 BOOST_STD_EXTENSION_NAMESPACE::hash_multimap<
197 Key, T, HashFcn, EqualKey, Allocator
198 > &t,
199 const unsigned int file_version
200 ){
201 boost::serialization::stl::load_hash_collection<
202 Archive,
203 BOOST_STD_EXTENSION_NAMESPACE::hash_multimap<
204 Key, T, HashFcn, EqualKey, Allocator
205 >,
206 boost::serialization::stl::archive_input_hash_multimap<
207 Archive,
208 BOOST_STD_EXTENSION_NAMESPACE::hash_multimap<
209 Key, T, HashFcn, EqualKey, Allocator
210 >
211 >
212 >(ar, t);
213 }
214
215 // split non-intrusive serialization function member into separate
216 // non intrusive save/load member functions
217 template<
218 class Archive,
219 class Key,
220 class T,
221 class HashFcn,
222 class EqualKey,
223 class Allocator
224 >
225 inline void serialize(
226 Archive & ar,
227 BOOST_STD_EXTENSION_NAMESPACE::hash_multimap<
228 Key, T, HashFcn, EqualKey, Allocator
229 > &t,
230 const unsigned int file_version
231 ){
232 boost::serialization::split_free(ar, t, file_version);
233 }
234
235 } // namespace serialization
236 } // namespace boost
237
238 #endif // BOOST_HAS_HASH
239 #endif // BOOST_SERIALIZATION_HASH_MAP_HPP