boost_unordered_map.hpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. #ifndef BOOST_SERIALIZATION_BOOST_SERIALIZATION_UNORDERED_MAP_HPP
  2. #define BOOST_SERIALIZATION_BOOST_SERIALIZATION_UNORDERED_MAP_HPP
  3. // MS compatible compilers support #pragma once
  4. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  5. # pragma once
  6. #endif
  7. /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
  8. // serialization/unordered_map.hpp:
  9. // serialization for stl unordered_map templates
  10. // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
  11. // (C) Copyright 2014 Jim Bell
  12. // Use, modification and distribution is subject to the Boost Software
  13. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  14. // http://www.boost.org/LICENSE_1_0.txt)
  15. // See http://www.boost.org for updates, documentation, and revision history.
  16. #include <boost/config.hpp>
  17. #include <boost/unordered_map.hpp>
  18. #include <boost/serialization/utility.hpp>
  19. #include <boost/serialization/unordered_collections_save_imp.hpp>
  20. #include <boost/serialization/unordered_collections_load_imp.hpp>
  21. #include <boost/serialization/archive_input_unordered_map.hpp>
  22. #include <boost/serialization/split_free.hpp>
  23. namespace boost {
  24. namespace serialization {
  25. template<
  26. class Archive,
  27. class Key,
  28. class T,
  29. class HashFcn,
  30. class EqualKey,
  31. class Allocator
  32. >
  33. inline void save(
  34. Archive & ar,
  35. const boost::unordered_map<Key, T, HashFcn, EqualKey, Allocator> &t,
  36. const unsigned int /*file_version*/
  37. ){
  38. boost::serialization::stl::save_unordered_collection<
  39. Archive,
  40. boost::unordered_map<Key, T, HashFcn, EqualKey, Allocator>
  41. >(ar, t);
  42. }
  43. template<
  44. class Archive,
  45. class Key,
  46. class T,
  47. class HashFcn,
  48. class EqualKey,
  49. class Allocator
  50. >
  51. inline void load(
  52. Archive & ar,
  53. boost::unordered_map<Key, T, HashFcn, EqualKey, Allocator> &t,
  54. const unsigned int /*file_version*/
  55. ){
  56. boost::serialization::stl::load_unordered_collection<
  57. Archive,
  58. boost::unordered_map<Key, T, HashFcn, EqualKey, Allocator>,
  59. boost::serialization::stl::archive_input_unordered_map<
  60. Archive,
  61. boost::unordered_map<Key, T, HashFcn, EqualKey, Allocator>
  62. >
  63. >(ar, t);
  64. }
  65. // split non-intrusive serialization function member into separate
  66. // non intrusive save/load member functions
  67. template<
  68. class Archive,
  69. class Key,
  70. class T,
  71. class HashFcn,
  72. class EqualKey,
  73. class Allocator
  74. >
  75. inline void serialize(
  76. Archive & ar,
  77. boost::unordered_map<Key, T, HashFcn, EqualKey, Allocator> &t,
  78. const unsigned int file_version
  79. ){
  80. boost::serialization::split_free(ar, t, file_version);
  81. }
  82. // unordered_multimap
  83. template<
  84. class Archive,
  85. class Key,
  86. class HashFcn,
  87. class T,
  88. class EqualKey,
  89. class Allocator
  90. >
  91. inline void save(
  92. Archive & ar,
  93. const boost::unordered_multimap<Key, T, HashFcn, EqualKey, Allocator> &t,
  94. const unsigned int /*file_version*/
  95. ){
  96. boost::serialization::stl::save_unordered_collection<
  97. Archive,
  98. boost::unordered_multimap<Key, T, HashFcn, EqualKey, Allocator>
  99. >(ar, t);
  100. }
  101. template<
  102. class Archive,
  103. class Key,
  104. class T,
  105. class HashFcn,
  106. class EqualKey,
  107. class Allocator
  108. >
  109. inline void load(
  110. Archive & ar,
  111. boost::unordered_multimap<
  112. Key, T, HashFcn, EqualKey, Allocator
  113. > &t,
  114. const unsigned int /*file_version*/
  115. ){
  116. boost::serialization::stl::load_unordered_collection<
  117. Archive,
  118. boost::unordered_multimap<Key, T, HashFcn, EqualKey, Allocator>,
  119. boost::serialization::stl::archive_input_unordered_multimap<
  120. Archive,
  121. boost::unordered_multimap<Key, T, HashFcn, EqualKey, Allocator>
  122. >
  123. >(ar, t);
  124. }
  125. // split non-intrusive serialization function member into separate
  126. // non intrusive save/load member functions
  127. template<
  128. class Archive,
  129. class Key,
  130. class T,
  131. class HashFcn,
  132. class EqualKey,
  133. class Allocator
  134. >
  135. inline void serialize(
  136. Archive & ar,
  137. boost::unordered_multimap<Key, T, HashFcn, EqualKey, Allocator> &t,
  138. const unsigned int file_version
  139. ){
  140. boost::serialization::split_free(ar, t, file_version);
  141. }
  142. } // namespace serialization
  143. } // namespace boost
  144. #endif // BOOST_SERIALIZATION_BOOST_SERIALIZATION_UNORDERED_MAP_HPP