32#ifdef _QX_ENABLE_BOOST_SERIALIZATION
33#ifndef _QX_SERIALIZATION_BOOST_UNORDERED_MAP_H_
34#define _QX_SERIALIZATION_BOOST_UNORDERED_MAP_H_
40#include <boost/serialization/serialization.hpp>
41#include <boost/serialization/collections_save_imp.hpp>
42#include <boost/serialization/collections_load_imp.hpp>
43#include <boost/serialization/split_free.hpp>
44#include <boost/serialization/utility.hpp>
45#include <boost/serialization/nvp.hpp>
48namespace serialization {
50#if (BOOST_VERSION > 105700)
52template <
class Archive,
class Key,
class Value>
53inline void save(Archive & ar,
const boost::unordered_map<Key, Value> & t,
const unsigned int )
55 long lSize =
static_cast<long>(t.size());
56 ar << boost::serialization::make_nvp(
"size", lSize);
58 typedef typename boost::unordered_map<Key, Value>::const_iterator type_itr;
59 for (type_itr itr = t.begin(); itr != t.end(); ++itr)
61 std::pair<Key, Value> pair_key_value = std::make_pair(itr->first, itr->second);
62 ar << boost::serialization::make_nvp(
"item", pair_key_value);
66template <
class Archive,
class Key,
class Value>
67inline void load(Archive & ar, boost::unordered_map<Key, Value> & t,
const unsigned int )
70 ar >> boost::serialization::make_nvp(
"size", lSize);
74 std::pair<Key, Value> pair_key_value;
76 for (
long l = 0; l < lSize; l++)
78 ar >> boost::serialization::make_nvp(
"item", pair_key_value);
79 t.insert(pair_key_value);
85template <
class Archive,
class Key,
class Value>
86inline void save(Archive & ar,
const boost::unordered_map<Key, Value> & t,
const unsigned int )
88 boost::serialization::stl::save_collection< Archive, boost::unordered_map<Key, Value> >(ar, t);
91template <
class Archive,
class Key,
class Value>
92inline void load(Archive & ar, boost::unordered_map<Key, Value> & t,
const unsigned int )
94 boost::serialization::stl::load_collection< Archive, boost::unordered_map<Key, Value>,
95 boost::serialization::stl::archive_input_map< Archive, boost::unordered_map<Key, Value> >,
96 boost::serialization::stl::no_reserve_imp< boost::unordered_map<Key, Value> > >(ar, t);
101template <
class Archive,
class Key,
class Value>
102inline void serialize(Archive & ar, boost::unordered_map<Key, Value> & t,
const unsigned int file_version)
104 boost::serialization::split_free(ar, t, file_version);
107#if (BOOST_VERSION > 105700)
109template <
class Archive,
class Key,
class Value>
110inline void save(Archive & ar,
const boost::unordered_multimap<Key, Value> & t,
const unsigned int )
112 long lSize =
static_cast<long>(t.size());
113 ar << boost::serialization::make_nvp(
"size", lSize);
115 typedef typename boost::unordered_multimap<Key, Value>::const_iterator type_itr;
116 for (type_itr itr = t.begin(); itr != t.end(); ++itr)
118 std::pair<Key, Value> pair_key_value = std::make_pair(itr->first, itr->second);
119 ar << boost::serialization::make_nvp(
"item", pair_key_value);
123template <
class Archive,
class Key,
class Value>
124inline void load(Archive & ar, boost::unordered_multimap<Key, Value> & t,
const unsigned int )
127 ar >> boost::serialization::make_nvp(
"size", lSize);
131 std::pair<Key, Value> pair_key_value;
133 for (
long l = 0; l < lSize; l++)
135 ar >> boost::serialization::make_nvp(
"item", pair_key_value);
136 t.insert(pair_key_value);
142template <
class Archive,
class Key,
class Value>
143inline void save(Archive & ar,
const boost::unordered_multimap<Key, Value> & t,
const unsigned int )
145 boost::serialization::stl::save_collection< Archive, boost::unordered_multimap<Key, Value> >(ar, t);
148template <
class Archive,
class Key,
class Value>
149inline void load(Archive & ar, boost::unordered_multimap<Key, Value> & t,
const unsigned int )
151#if (BOOST_VERSION >= 104200)
152 boost::serialization::stl::load_collection< Archive, boost::unordered_multimap<Key, Value>,
153 boost::serialization::stl::archive_input_map< Archive, boost::unordered_multimap<Key, Value> >,
154 boost::serialization::stl::no_reserve_imp< boost::unordered_multimap<Key, Value> > >(ar, t);
156 boost::serialization::stl::load_collection< Archive, boost::unordered_multimap<Key, Value>,
157 boost::serialization::stl::archive_input_multimap< Archive, boost::unordered_multimap<Key, Value> >,
158 boost::serialization::stl::no_reserve_imp< boost::unordered_multimap<Key, Value> > >(ar, t);
164template <
class Archive,
class Key,
class Value>
165inline void serialize(Archive & ar, boost::unordered_multimap<Key, Value> & t,
const unsigned int file_version)
167 boost::serialization::split_free(ar, t, file_version);
void serialize(Archive &ar, boost::tuple< T0, T1 > &t, const unsigned int file_version)
void load(Archive &ar, boost::unordered_map< Key, Value > &t, const unsigned int)
void save(Archive &ar, const boost::unordered_map< Key, Value > &t, const unsigned int)