1 #ifndef BOOST_SERIALIZATION_HASH_MAP_HPP
2 #define BOOST_SERIALIZATION_HASH_MAP_HPP
4 // MS compatible compilers support #pragma once
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // serialization/hash_map.hpp:
11 // serialization for stl hash_map templates
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)
18 // See http://www.boost.org for updates, documentation, and revision history.
20 #include <boost/config.hpp>
22 #include BOOST_HASH_MAP_HEADER
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>
30 namespace serialization {
35 template<class Archive, class Container>
36 struct archive_input_hash_map
38 inline void operator()(
43 typedef typename Container::value_type type;
44 detail::stack_construct<Archive, type> t(ar, v);
45 // borland fails silently w/o full namespace
46 ar >> boost::serialization::make_nvp("item", t.reference());
47 std::pair<typename Container::const_iterator, bool> result =
48 s.insert(t.reference());
49 // note: the following presumes that the map::value_type was NOT tracked
50 // in the archive. This is the usual case, but here there is no way
53 ar.reset_object_address(
54 & (result.first->second),
55 & t.reference().second
62 template<class Archive, class Container>
63 struct archive_input_hash_multimap
65 inline void operator()(
70 typedef typename Container::value_type type;
71 detail::stack_construct<Archive, type> t(ar, v);
72 // borland fails silently w/o full namespace
73 ar >> boost::serialization::make_nvp("item", t.reference());
74 typename Container::const_iterator result
75 = s.insert(t.reference());
76 // note: the following presumes that the map::value_type was NOT tracked
77 // in the archive. This is the usual case, but here there is no way
79 ar.reset_object_address(
97 const BOOST_STD_EXTENSION_NAMESPACE::hash_map<
98 Key, HashFcn, EqualKey, Allocator
100 const unsigned int file_version
102 boost::serialization::stl::save_hash_collection<
104 BOOST_STD_EXTENSION_NAMESPACE::hash_map<
105 Key, HashFcn, EqualKey, Allocator
119 BOOST_STD_EXTENSION_NAMESPACE::hash_map<
120 Key, HashFcn, EqualKey, Allocator
122 const unsigned int file_version
124 boost::serialization::stl::load_hash_collection<
126 BOOST_STD_EXTENSION_NAMESPACE::hash_map<
127 Key, HashFcn, EqualKey, Allocator
129 boost::serialization::stl::archive_input_hash_map<
131 BOOST_STD_EXTENSION_NAMESPACE::hash_map<
132 Key, HashFcn, EqualKey, Allocator
138 // split non-intrusive serialization function member into separate
139 // non intrusive save/load member functions
147 inline void serialize(
149 BOOST_STD_EXTENSION_NAMESPACE::hash_map<
150 Key, HashFcn, EqualKey, Allocator
152 const unsigned int file_version
154 boost::serialization::split_free(ar, t, file_version);
167 const BOOST_STD_EXTENSION_NAMESPACE::hash_multimap<
168 Key, HashFcn, EqualKey, Allocator
170 const unsigned int file_version
172 boost::serialization::stl::save_hash_collection<
174 BOOST_STD_EXTENSION_NAMESPACE::hash_multimap<
175 Key, HashFcn, EqualKey, Allocator
189 BOOST_STD_EXTENSION_NAMESPACE::hash_multimap<
190 Key, HashFcn, EqualKey, Allocator
192 const unsigned int file_version
194 boost::serialization::stl::load_hash_collection<
196 BOOST_STD_EXTENSION_NAMESPACE::hash_multimap<
197 Key, HashFcn, EqualKey, Allocator
199 boost::serialization::stl::archive_input_hash_multimap<
201 BOOST_STD_EXTENSION_NAMESPACE::hash_multimap<
202 Key, HashFcn, EqualKey, Allocator
208 // split non-intrusive serialization function member into separate
209 // non intrusive save/load member functions
217 inline void serialize(
219 BOOST_STD_EXTENSION_NAMESPACE::hash_multimap<
220 Key, HashFcn, EqualKey, Allocator
222 const unsigned int file_version
224 boost::serialization::split_free(ar, t, file_version);
227 } // namespace serialization
230 #endif // BOOST_HAS_HASH
231 #endif // BOOST_SERIALIZATION_HASH_MAP_HPP