| 1 | #ifndef BOOST_SERIALIZATION_HASH_MAP_HPP |
|---|
| 2 | #define BOOST_SERIALIZATION_HASH_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/hash_map.hpp: |
|---|
| 11 | // serialization for stl hash_map templates |
|---|
| 12 | |
|---|
| 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) |
|---|
| 17 | |
|---|
| 18 | // See http://www.boost.org for updates, documentation, and revision history. |
|---|
| 19 | |
|---|
| 20 | #include <boost/config.hpp> |
|---|
| 21 | #ifdef BOOST_HAS_HASH |
|---|
| 22 | |
|---|
| 23 | #ifdef __GLIBCPP__ |
|---|
| 24 | #include <ext/hash_map> |
|---|
| 25 | #else |
|---|
| 26 | #include <hash_map> |
|---|
| 27 | #endif |
|---|
| 28 | |
|---|
| 29 | #include <boost/serialization/utility.hpp> |
|---|
| 30 | #include <boost/serialization/collections_save_imp.hpp> |
|---|
| 31 | #include <boost/serialization/collections_load_imp.hpp> |
|---|
| 32 | #include <boost/serialization/split_free.hpp> |
|---|
| 33 | |
|---|
| 34 | // function specializations must be defined in the appropriate |
|---|
| 35 | // namespace - boost::serialization |
|---|
| 36 | #if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) |
|---|
| 37 | #define STD _STLP_STD |
|---|
| 38 | #else |
|---|
| 39 | #define STD BOOST_STD_EXTENSION_NAMESPACE |
|---|
| 40 | #endif |
|---|
| 41 | |
|---|
| 42 | namespace boost { |
|---|
| 43 | namespace serialization { |
|---|
| 44 | |
|---|
| 45 | template<class Archive, class Key, class Compare, class Allocator > |
|---|
| 46 | inline void save( |
|---|
| 47 | Archive & ar, |
|---|
| 48 | const STD::hash_map<Key, Compare, Allocator> &t, |
|---|
| 49 | const unsigned int file_version |
|---|
| 50 | ){ |
|---|
| 51 | boost::serialization::stl::save_collection< |
|---|
| 52 | Archive, |
|---|
| 53 | STD::hash_map<Key, Compare, Allocator> |
|---|
| 54 | >(ar, t); |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | template<class Archive, class Key, class Compare, class Allocator > |
|---|
| 58 | inline void load( |
|---|
| 59 | Archive & ar, |
|---|
| 60 | STD::hash_map<Key, Compare, Allocator> &t, |
|---|
| 61 | const unsigned int file_version |
|---|
| 62 | ){ |
|---|
| 63 | boost::serialization::stl::load_collection< |
|---|
| 64 | Archive, |
|---|
| 65 | STD::hash_map<Key, Compare, Allocator>, |
|---|
| 66 | boost::serialization::stl::archive_input_map< |
|---|
| 67 | Archive, |
|---|
| 68 | STD::hash_map<Key, Compare, Allocator> |
|---|
| 69 | >, |
|---|
| 70 | boost::serialization::stl::no_reserve_imp< |
|---|
| 71 | STD::hash_map<Key, Compare, Allocator> |
|---|
| 72 | > |
|---|
| 73 | >(ar, t); |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | // split non-intrusive serialization function member into separate |
|---|
| 77 | // non intrusive save/load member functions |
|---|
| 78 | template<class Archive, class Key, class Compare, class Allocator > |
|---|
| 79 | inline void serialize( |
|---|
| 80 | Archive & ar, |
|---|
| 81 | STD::hash_map<Key, Compare, Allocator> &t, |
|---|
| 82 | const unsigned int file_version |
|---|
| 83 | ){ |
|---|
| 84 | boost::serialization::split_free(ar, t, file_version); |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | // hash_multimap |
|---|
| 88 | template<class Archive, class Key, class Compare, class Allocator > |
|---|
| 89 | inline void save( |
|---|
| 90 | Archive & ar, |
|---|
| 91 | const STD::hash_multimap<Key, Compare, Allocator> &t, |
|---|
| 92 | const unsigned int file_version |
|---|
| 93 | ){ |
|---|
| 94 | boost::serialization::stl::save_collection< |
|---|
| 95 | Archive, |
|---|
| 96 | STD::hash_multimap<Key, Compare, Allocator> |
|---|
| 97 | >(ar, t); |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | template<class Archive, class Key, class Compare, class Allocator > |
|---|
| 101 | inline void load( |
|---|
| 102 | Archive & ar, |
|---|
| 103 | STD::hash_multimap<Key, Compare, Allocator> &t, |
|---|
| 104 | const unsigned int file_version |
|---|
| 105 | ){ |
|---|
| 106 | boost::serialization::stl::load_collection< |
|---|
| 107 | Archive, |
|---|
| 108 | STD::hash_multimap<Key, Compare, Allocator>, |
|---|
| 109 | boost::serialization::stl::archive_input_multimap< |
|---|
| 110 | Archive, |
|---|
| 111 | STD::hash_multimap<Key, Compare, Allocator> |
|---|
| 112 | >, |
|---|
| 113 | boost::serialization::stl::no_reserve_imp< |
|---|
| 114 | STD::hash_multimap<Key, Compare, Allocator> |
|---|
| 115 | > |
|---|
| 116 | >(ar, t); |
|---|
| 117 | } |
|---|
| 118 | |
|---|
| 119 | // split non-intrusive serialization function member into separate |
|---|
| 120 | // non intrusive save/load member functions |
|---|
| 121 | template<class Archive, class Key, class Compare, class Allocator > |
|---|
| 122 | inline void serialize( |
|---|
| 123 | Archive & ar, |
|---|
| 124 | STD::hash_multimap<Key, Compare, Allocator> &t, |
|---|
| 125 | const unsigned int file_version |
|---|
| 126 | ){ |
|---|
| 127 | boost::serialization::split_free(ar, t, file_version); |
|---|
| 128 | } |
|---|
| 129 | |
|---|
| 130 | } // namespace serialization |
|---|
| 131 | } // namespace boost |
|---|
| 132 | |
|---|
| 133 | #undef STD |
|---|
| 134 | |
|---|
| 135 | #endif // BOOST_HAS_HASH |
|---|
| 136 | #endif // BOOST_SERIALIZATION_HASH_MAP_HPP |
|---|