]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/serialization/include/boost/serialization/map.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / serialization / include / boost / serialization / map.hpp
1 #ifndef BOOST_SERIALIZATION_MAP_HPP
2 #define BOOST_SERIALIZATION_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/map.hpp:
11 // serialization for stl map templates
12
13 // (C) Copyright 2002-2014 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 <map>
21
22 #include <boost/config.hpp>
23
24 #include <boost/archive/detail/basic_iarchive.hpp>
25 #include <boost/serialization/access.hpp>
26 #include <boost/serialization/nvp.hpp>
27 #include <boost/serialization/collection_size_type.hpp>
28 #include <boost/serialization/item_version_type.hpp>
29 #include <boost/serialization/detail/stack_constructor.hpp>
30
31 #include <boost/serialization/utility.hpp>
32 #include <boost/serialization/collections_save_imp.hpp>
33 #include <boost/serialization/split_free.hpp>
34
35 namespace boost {
36 namespace serialization {
37
38 ////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
39 // implementation of serialization for map and mult-map STL containers
40
41 template<class Archive, class Container>
42 inline void load_map_collection(Archive & ar, Container &s)
43 {
44 s.clear();
45 const boost::archive::library_version_type library_version(
46 ar.get_library_version()
47 );
48 // retrieve number of elements
49 item_version_type item_version(0);
50 collection_size_type count;
51 ar >> BOOST_SERIALIZATION_NVP(count);
52 if(boost::archive::library_version_type(3) < library_version){
53 ar >> BOOST_SERIALIZATION_NVP(item_version);
54 }
55 typename Container::iterator hint;
56 hint = s.begin();
57 while(count-- > 0){
58 typedef typename Container::value_type type;
59 detail::stack_construct<Archive, type> t(ar, item_version);
60 ar >> boost::serialization::make_nvp("item", t.reference());
61 typename Container::iterator result =
62 #ifdef BOOST_NO_CXX11_HDR_UNORDERED_MAP
63 s.insert(hint, t.reference());
64 #else
65 s.emplace_hint(hint, t.reference());
66 #endif
67 ar.reset_object_address(& (result->second), & t.reference().second);
68 hint = result;
69 ++hint;
70 }
71 }
72
73 // map
74 template<class Archive, class Type, class Key, class Compare, class Allocator >
75 inline void save(
76 Archive & ar,
77 const std::map<Key, Type, Compare, Allocator> &t,
78 const unsigned int /* file_version */
79 ){
80 boost::serialization::stl::save_collection<
81 Archive,
82 std::map<Key, Type, Compare, Allocator>
83 >(ar, t);
84 }
85
86 template<class Archive, class Type, class Key, class Compare, class Allocator >
87 inline void load(
88 Archive & ar,
89 std::map<Key, Type, Compare, Allocator> &t,
90 const unsigned int /* file_version */
91 ){
92 load_map_collection(ar, t);
93 }
94
95 // split non-intrusive serialization function member into separate
96 // non intrusive save/load member functions
97 template<class Archive, class Type, class Key, class Compare, class Allocator >
98 inline void serialize(
99 Archive & ar,
100 std::map<Key, Type, Compare, Allocator> &t,
101 const unsigned int file_version
102 ){
103 boost::serialization::split_free(ar, t, file_version);
104 }
105
106 // multimap
107 template<class Archive, class Type, class Key, class Compare, class Allocator >
108 inline void save(
109 Archive & ar,
110 const std::multimap<Key, Type, Compare, Allocator> &t,
111 const unsigned int /* file_version */
112 ){
113 boost::serialization::stl::save_collection<
114 Archive,
115 std::multimap<Key, Type, Compare, Allocator>
116 >(ar, t);
117 }
118
119 template<class Archive, class Type, class Key, class Compare, class Allocator >
120 inline void load(
121 Archive & ar,
122 std::multimap<Key, Type, Compare, Allocator> &t,
123 const unsigned int /* file_version */
124 ){
125 load_map_collection(ar, t);
126 }
127
128 // split non-intrusive serialization function member into separate
129 // non intrusive save/load member functions
130 template<class Archive, class Type, class Key, class Compare, class Allocator >
131 inline void serialize(
132 Archive & ar,
133 std::multimap<Key, Type, Compare, Allocator> &t,
134 const unsigned int file_version
135 ){
136 boost::serialization::split_free(ar, t, file_version);
137 }
138
139 } // serialization
140 } // namespace boost
141
142 #endif // BOOST_SERIALIZATION_MAP_HPP