DiaDes  0.1
DIAgnosis of Discrete-Event System
unordered_set.hh
Go to the documentation of this file.
1 #ifndef BOOST_SERIALIZATION_UNORDERED_SET_HPP
2 #define BOOST_SERIALIZATION_UNORDERED_SET_HPP
3 
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
6 # pragma once
7 #endif
8 
10 // unordered_set.hpp: serialization for stl unordered_set templates
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 <boost/tr1/unordered_set.hpp>
20 #include <unordered_set>
21 #include <boost/config.hpp>
22 
25 #include <boost/serialization/split_free.hpp>
26 
27 namespace boost {
28 namespace serialization {
29 
30 namespace stl {
31 
32 // unordered_set input
33 template<class Archive, class Container>
35 {
36  inline void operator()(
37  Archive &ar,
38  Container &s,
39  const unsigned int v
40  ){
41  typedef BOOST_DEDUCED_TYPENAME Container::value_type type;
42  detail::stack_construct<Archive, type> t(ar, v);
43  // borland fails silently w/o full namespace
44  ar >> boost::serialization::make_nvp("item", t.reference());
45  std::pair<BOOST_DEDUCED_TYPENAME Container::const_iterator, bool> result =
46  s.insert(t.reference());
47  if(result.second)
48  ar.reset_object_address(& (* result.first), & t.reference());
49  }
50 };
51 
52 // unordered_multiset input
53 template<class Archive, class Container>
55 {
56  inline void operator()(
57  Archive &ar,
58  Container &s,
59  const unsigned int v
60  ){
61  typedef BOOST_DEDUCED_TYPENAME Container::value_type type;
62  detail::stack_construct<Archive, type> t(ar, v);
63  // borland fails silently w/o full namespace
64  ar >> boost::serialization::make_nvp("item", t.reference());
65  BOOST_DEDUCED_TYPENAME Container::const_iterator result
66  = s.insert(t.reference());
67  ar.reset_object_address(& (* result), & t.reference());
68  }
69 };
70 
71 } // stl
72 
73 template<
74  class Archive,
75  class Key,
76  class HashFcn,
77  class EqualKey,
78  class Allocator
79 >
80 inline void save(
81  Archive & ar,
82  //const std::tr1::unordered_set<
83  const std::unordered_set<
84  Key, HashFcn, EqualKey, Allocator
85  > &t,
86  const unsigned int /*file_version*/
87 ){
89  Archive,
90  //std::tr1::unordered_set<
91  std::unordered_set<
92  Key, HashFcn, EqualKey, Allocator
93  >
94  >(ar, t);
95 }
96 
97 template<
98  class Archive,
99  class Key,
100  class HashFcn,
101  class EqualKey,
102  class Allocator
103 >
104 inline void load(
105  Archive & ar,
106  //std::tr1::unordered_set<
107  std::unordered_set<
108  Key, HashFcn, EqualKey, Allocator
109  > &t,
110  const unsigned int /*file_version*/
111 ){
113  Archive,
114  //std::tr1::unordered_set<
115  std::unordered_set<
116  Key, HashFcn, EqualKey, Allocator
117  >,
119  Archive,
120  // std::tr1::unordered_set<
121  std::unordered_set<
122  Key, HashFcn, EqualKey, Allocator
123  >
124  >
125  >(ar, t);
126 }
127 
128 // split non-intrusive serialization function member into separate
129 // non intrusive save/load member functions
130 template<
131  class Archive,
132  class Key,
133  class HashFcn,
134  class EqualKey,
135  class Allocator
136 >
137 inline void serialize(
138  Archive & ar,
139  // std::tr1::unordered_set<
140  std::unordered_set<
141  Key, HashFcn, EqualKey, Allocator
142  > &t,
143  const unsigned int file_version
144 ){
145  boost::serialization::split_free(ar, t, file_version);
146 }
147 
148 // unordered_multiset
149 template<
150  class Archive,
151  class Key,
152  class HashFcn,
153  class EqualKey,
154  class Allocator
155 >
156 inline void save(
157  Archive & ar,
158  // const std::tr1::unordered_multiset<
159  const std::unordered_multiset<
160  Key, HashFcn, EqualKey, Allocator
161  > &t,
162  const unsigned int /*file_version*/
163 ){
165  Archive,
166  // std::tr1::unordered_multiset<
167  std::unordered_multiset<
168  Key, HashFcn, EqualKey, Allocator
169  >
170  >(ar, t);
171 }
172 
173 template<
174  class Archive,
175  class Key,
176  class HashFcn,
177  class EqualKey,
178  class Allocator
179 >
180 inline void load(
181  Archive & ar,
182  //std::tr1::unordered_multiset<
183  std::unordered_multiset<
184  Key, HashFcn, EqualKey, Allocator
185  > &t,
186  const unsigned int /*file_version*/
187 ){
189  Archive,
190  // std::tr1::unordered_multiset<
191  std::unordered_multiset<
192  Key, HashFcn, EqualKey, Allocator
193  >,
195  Archive,
196  // std::tr1::unordered_multiset<
197  std::unordered_multiset<
198  Key, HashFcn, EqualKey, Allocator
199  >
200  >
201  >(ar, t);
202 }
203 
204 // split non-intrusive serialization function member into separate
205 // non intrusive save/load member functions
206 template<
207  class Archive,
208  class Key,
209  class HashFcn,
210  class EqualKey,
211  class Allocator
212 >
213 inline void serialize(
214  Archive & ar,
215  //std::tr1::unordered_multiset<
216  std::unordered_multiset<
217  Key, HashFcn, EqualKey, Allocator
218  > &t,
219  const unsigned int file_version
220 ){
221  boost::serialization::split_free(ar, t, file_version);
222 }
223 
224 } // namespace serialization
225 } // namespace boost
226 
227 #endif // BOOST_SERIALIZATION_UNORDERED_SET_HPP
void save(Archive &ar, const std::unordered_map< Key, HashFcn, EqualKey, Allocator > &t, const unsigned int)
void operator()(Archive &ar, Container &s, const unsigned int v)
void load(Archive &ar, std::unordered_map< Key, HashFcn, EqualKey, Allocator > &t, const unsigned int)
void serialize(Archive &ar, std::unordered_map< Key, HashFcn, EqualKey, Allocator > &t, const unsigned int file_version)
void save_unordered_collection(Archive &ar, const Container &s)
void operator()(Archive &ar, Container &s, const unsigned int v)
void load_unordered_collection(Archive &ar, Container &s)