comparison DEPENDENCIES/generic/include/boost/serialization/map.hpp @ 101:c530137014c0

Update Boost headers (1.58.0)
author Chris Cannam
date Mon, 07 Sep 2015 11:12:49 +0100
parents 2665513ce2d3
children
comparison
equal deleted inserted replaced
100:793467b5e61c 101:c530137014c0
1 #ifndef BOOST_SERIALIZATION_MAP_HPP 1 #ifndef BOOST_SERIALIZATION_MAP_HPP
2 #define BOOST_SERIALIZATION_MAP_HPP 2 #define BOOST_SERIALIZATION_MAP_HPP
3 3
4 // MS compatible compilers support #pragma once 4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER) && (_MSC_VER >= 1020) 5 #if defined(_MSC_VER)
6 # pragma once 6 # pragma once
7 #endif 7 #endif
8 8
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // serialization/map.hpp: 10 // serialization/map.hpp:
11 // serialization for stl map templates 11 // serialization for stl map templates
12 12
13 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . 13 // (C) Copyright 2002-2014 Robert Ramey - http://www.rrsd.com .
14 // Use, modification and distribution is subject to the Boost Software 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 15 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
16 // http://www.boost.org/LICENSE_1_0.txt) 16 // http://www.boost.org/LICENSE_1_0.txt)
17 17
18 // See http://www.boost.org for updates, documentation, and revision history. 18 // See http://www.boost.org for updates, documentation, and revision history.
19 19
20 #include <map> 20 #include <map>
21 21
22 #include <boost/config.hpp> 22 #include <boost/config.hpp>
23 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
24 #include <boost/serialization/utility.hpp> 31 #include <boost/serialization/utility.hpp>
25 #include <boost/serialization/collections_save_imp.hpp> 32 #include <boost/serialization/collections_save_imp.hpp>
26 #include <boost/serialization/collections_load_imp.hpp>
27 #include <boost/serialization/split_free.hpp> 33 #include <boost/serialization/split_free.hpp>
28 34
29 namespace boost { 35 namespace boost {
30 namespace serialization { 36 namespace serialization {
31 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 // borland fails silently w/o full namespace
61 ar >> boost::serialization::make_nvp("item", t.reference());
62 typename Container::iterator result = s.insert(hint, t.reference());
63 ar.reset_object_address(& (result->second), & t.reference().second);
64 hint = result;
65 }
66 }
67
68 // map
32 template<class Archive, class Type, class Key, class Compare, class Allocator > 69 template<class Archive, class Type, class Key, class Compare, class Allocator >
33 inline void save( 70 inline void save(
34 Archive & ar, 71 Archive & ar,
35 const std::map<Key, Type, Compare, Allocator> &t, 72 const std::map<Key, Type, Compare, Allocator> &t,
36 const unsigned int /* file_version */ 73 const unsigned int /* file_version */
45 inline void load( 82 inline void load(
46 Archive & ar, 83 Archive & ar,
47 std::map<Key, Type, Compare, Allocator> &t, 84 std::map<Key, Type, Compare, Allocator> &t,
48 const unsigned int /* file_version */ 85 const unsigned int /* file_version */
49 ){ 86 ){
50 boost::serialization::stl::load_collection< 87 load_map_collection(ar, t);
51 Archive,
52 std::map<Key, Type, Compare, Allocator>,
53 boost::serialization::stl::archive_input_map<
54 Archive, std::map<Key, Type, Compare, Allocator> >,
55 boost::serialization::stl::no_reserve_imp<std::map<
56 Key, Type, Compare, Allocator
57 >
58 >
59 >(ar, t);
60 } 88 }
61 89
62 // split non-intrusive serialization function member into separate 90 // split non-intrusive serialization function member into separate
63 // non intrusive save/load member functions 91 // non intrusive save/load member functions
64 template<class Archive, class Type, class Key, class Compare, class Allocator > 92 template<class Archive, class Type, class Key, class Compare, class Allocator >
87 inline void load( 115 inline void load(
88 Archive & ar, 116 Archive & ar,
89 std::multimap<Key, Type, Compare, Allocator> &t, 117 std::multimap<Key, Type, Compare, Allocator> &t,
90 const unsigned int /* file_version */ 118 const unsigned int /* file_version */
91 ){ 119 ){
92 boost::serialization::stl::load_collection< 120 load_map_collection(ar, t);
93 Archive,
94 std::multimap<Key, Type, Compare, Allocator>,
95 boost::serialization::stl::archive_input_map<
96 Archive, std::multimap<Key, Type, Compare, Allocator>
97 >,
98 boost::serialization::stl::no_reserve_imp<
99 std::multimap<Key, Type, Compare, Allocator>
100 >
101 >(ar, t);
102 } 121 }
103 122
104 // split non-intrusive serialization function member into separate 123 // split non-intrusive serialization function member into separate
105 // non intrusive save/load member functions 124 // non intrusive save/load member functions
106 template<class Archive, class Type, class Key, class Compare, class Allocator > 125 template<class Archive, class Type, class Key, class Compare, class Allocator >