| 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 |
|
|---|
| 9 | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////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 |
|
|---|
| 21 | #include <boost/config.hpp>
|
|---|
| 22 |
|
|---|
| 23 | #include <boost/serialization/unordered_collections_save_imp.hpp>
|
|---|
| 24 | #include <boost/serialization/unordered_collections_load_imp.hpp>
|
|---|
| 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>
|
|---|
| 34 | struct archive_input_unordered_set
|
|---|
| 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>
|
|---|
| 54 | struct archive_input_unordered_multiset
|
|---|
| 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 | Key, HashFcn, EqualKey, Allocator
|
|---|
| 84 | > &t,
|
|---|
| 85 | const unsigned int /*file_version*/
|
|---|
| 86 | ){
|
|---|
| 87 | boost::serialization::stl::save_unordered_collection<
|
|---|
| 88 | Archive,
|
|---|
| 89 | std::tr1::unordered_set<
|
|---|
| 90 | Key, HashFcn, EqualKey, Allocator
|
|---|
| 91 | >
|
|---|
| 92 | >(ar, t);
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | template<
|
|---|
| 96 | class Archive,
|
|---|
| 97 | class Key,
|
|---|
| 98 | class HashFcn,
|
|---|
| 99 | class EqualKey,
|
|---|
| 100 | class Allocator
|
|---|
| 101 | >
|
|---|
| 102 | inline void load(
|
|---|
| 103 | Archive & ar,
|
|---|
| 104 | std::tr1::unordered_set<
|
|---|
| 105 | Key, HashFcn, EqualKey, Allocator
|
|---|
| 106 | > &t,
|
|---|
| 107 | const unsigned int /*file_version*/
|
|---|
| 108 | ){
|
|---|
| 109 | boost::serialization::stl::load_unordered_collection<
|
|---|
| 110 | Archive,
|
|---|
| 111 | std::tr1::unordered_set<
|
|---|
| 112 | Key, HashFcn, EqualKey, Allocator
|
|---|
| 113 | >,
|
|---|
| 114 | boost::serialization::stl::archive_input_unordered_set<
|
|---|
| 115 | Archive,
|
|---|
| 116 | std::tr1::unordered_set<
|
|---|
| 117 | Key, HashFcn, EqualKey, Allocator
|
|---|
| 118 | >
|
|---|
| 119 | >
|
|---|
| 120 | >(ar, t);
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 | // split non-intrusive serialization function member into separate
|
|---|
| 124 | // non intrusive save/load member functions
|
|---|
| 125 | template<
|
|---|
| 126 | class Archive,
|
|---|
| 127 | class Key,
|
|---|
| 128 | class HashFcn,
|
|---|
| 129 | class EqualKey,
|
|---|
| 130 | class Allocator
|
|---|
| 131 | >
|
|---|
| 132 | inline void serialize(
|
|---|
| 133 | Archive & ar,
|
|---|
| 134 | std::tr1::unordered_set<
|
|---|
| 135 | Key, HashFcn, EqualKey, Allocator
|
|---|
| 136 | > &t,
|
|---|
| 137 | const unsigned int file_version
|
|---|
| 138 | ){
|
|---|
| 139 | boost::serialization::split_free(ar, t, file_version);
|
|---|
| 140 | }
|
|---|
| 141 |
|
|---|
| 142 | // unordered_multiset
|
|---|
| 143 | template<
|
|---|
| 144 | class Archive,
|
|---|
| 145 | class Key,
|
|---|
| 146 | class HashFcn,
|
|---|
| 147 | class EqualKey,
|
|---|
| 148 | class Allocator
|
|---|
| 149 | >
|
|---|
| 150 | inline void save(
|
|---|
| 151 | Archive & ar,
|
|---|
| 152 | const std::tr1::unordered_multiset<
|
|---|
| 153 | Key, HashFcn, EqualKey, Allocator
|
|---|
| 154 | > &t,
|
|---|
| 155 | const unsigned int /*file_version*/
|
|---|
| 156 | ){
|
|---|
| 157 | boost::serialization::stl::save_unordered_collection<
|
|---|
| 158 | Archive,
|
|---|
| 159 | std::tr1::unordered_multiset<
|
|---|
| 160 | Key, HashFcn, EqualKey, Allocator
|
|---|
| 161 | >
|
|---|
| 162 | >(ar, t);
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | template<
|
|---|
| 166 | class Archive,
|
|---|
| 167 | class Key,
|
|---|
| 168 | class HashFcn,
|
|---|
| 169 | class EqualKey,
|
|---|
| 170 | class Allocator
|
|---|
| 171 | >
|
|---|
| 172 | inline void load(
|
|---|
| 173 | Archive & ar,
|
|---|
| 174 | std::tr1::unordered_multiset<
|
|---|
| 175 | Key, HashFcn, EqualKey, Allocator
|
|---|
| 176 | > &t,
|
|---|
| 177 | const unsigned int /*file_version*/
|
|---|
| 178 | ){
|
|---|
| 179 | boost::serialization::stl::load_unordered_collection<
|
|---|
| 180 | Archive,
|
|---|
| 181 | std::tr1::unordered_multiset<
|
|---|
| 182 | Key, HashFcn, EqualKey, Allocator
|
|---|
| 183 | >,
|
|---|
| 184 | boost::serialization::stl::archive_input_unordered_multiset<
|
|---|
| 185 | Archive,
|
|---|
| 186 | std::tr1::unordered_multiset<
|
|---|
| 187 | Key, HashFcn, EqualKey, Allocator
|
|---|
| 188 | >
|
|---|
| 189 | >
|
|---|
| 190 | >(ar, t);
|
|---|
| 191 | }
|
|---|
| 192 |
|
|---|
| 193 | // split non-intrusive serialization function member into separate
|
|---|
| 194 | // non intrusive save/load member functions
|
|---|
| 195 | template<
|
|---|
| 196 | class Archive,
|
|---|
| 197 | class Key,
|
|---|
| 198 | class HashFcn,
|
|---|
| 199 | class EqualKey,
|
|---|
| 200 | class Allocator
|
|---|
| 201 | >
|
|---|
| 202 | inline void serialize(
|
|---|
| 203 | Archive & ar,
|
|---|
| 204 | std::tr1::unordered_multiset<
|
|---|
| 205 | Key, HashFcn, EqualKey, Allocator
|
|---|
| 206 | > &t,
|
|---|
| 207 | const unsigned int file_version
|
|---|
| 208 | ){
|
|---|
| 209 | boost::serialization::split_free(ar, t, file_version);
|
|---|
| 210 | }
|
|---|
| 211 |
|
|---|
| 212 | } // namespace serialization
|
|---|
| 213 | } // namespace boost
|
|---|
| 214 |
|
|---|
| 215 | #endif // BOOST_SERIALIZATION_UNORDERED_SET_HPP
|
|---|