1 #ifndef  BOOST_SERIALIZATION_ARCHIVE_INPUT_UNORDERED_MAP_HPP
2 #define BOOST_SERIALIZATION_ARCHIVE_INPUT_UNORDERED_MAP_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 // serialization/unordered_map.hpp:
11 // serialization for stl unordered_map templates
12 
13 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
14 // (C) Copyright 2014 Jim Bell
15 // Use, modification and distribution is subject to the Boost Software
16 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
17 // http://www.boost.org/LICENSE_1_0.txt)
18 
19 //  See http://www.boost.org for updates, documentation, and revision history.
20 
21 #include <boost/config.hpp>
22 #include <boost/serialization/nvp.hpp>
23 #include <boost/serialization/detail/stack_constructor.hpp>
24 #include <boost/serialization/utility.hpp>
25 #include <boost/move/utility_core.hpp>
26 
27 namespace boost {
28 namespace serialization {
29 namespace stl {
30 
31 // map input
32 template<class Archive, class Container>
33 struct archive_input_unordered_map
34 {
operator ()boost::serialization::stl::archive_input_unordered_map35     inline void operator()(
36         Archive &ar,
37         Container &s,
38         const unsigned int v
39     ){
40         typedef typename Container::value_type type;
41         detail::stack_construct<Archive, type> t(ar, v);
42         ar >> boost::serialization::make_nvp("item", t.reference());
43         std::pair<typename Container::const_iterator, bool> result =
44             s.insert(boost::move(t.reference()));
45         // note: the following presumes that the map::value_type was NOT tracked
46         // in the archive.  This is the usual case, but here there is no way
47         // to determine that.
48         if(result.second){
49             ar.reset_object_address(
50                 & (result.first->second),
51                 & t.reference().second
52             );
53         }
54     }
55 };
56 
57 // multimap input
58 template<class Archive, class Container>
59 struct archive_input_unordered_multimap
60 {
operator ()boost::serialization::stl::archive_input_unordered_multimap61     inline void operator()(
62         Archive &ar,
63         Container &s,
64         const unsigned int v
65     ){
66         typedef typename Container::value_type type;
67         detail::stack_construct<Archive, type> t(ar, v);
68         ar >> boost::serialization::make_nvp("item", t.reference());
69         typename Container::const_iterator result =
70             s.insert(t.reference());
71         // note: the following presumes that the map::value_type was NOT tracked
72         // in the archive.  This is the usual case, but here there is no way
73         // to determine that.
74         ar.reset_object_address(
75             & result->second,
76             & t.reference()
77         );
78     }
79 };
80 
81 } // stl
82 } // namespace serialization
83 } // namespace boost
84 
85 #endif // BOOST_SERIALIZATION_ARCHIVE_INPUT_UNORDERED_MAP_HPP
86