unordered_map.hpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. #ifndef BOOST_SERIALIZATION_UNORDERED_MAP_HPP
  2. #define 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 <unordered_map>
  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 HashFcn,
  29. class EqualKey,
  30. class Allocator
  31. >
  32. inline void save(
  33. Archive & ar,
  34. const std::unordered_map<Key, HashFcn, EqualKey, Allocator> &t,
  35. const unsigned int /*file_version*/
  36. ){
  37. boost::serialization::stl::save_unordered_collection<
  38. Archive,
  39. std::unordered_map<Key, HashFcn, EqualKey, Allocator>
  40. >(ar, t);
  41. }
  42. template<
  43. class Archive,
  44. class Key,
  45. class HashFcn,
  46. class EqualKey,
  47. class Allocator
  48. >
  49. inline void load(
  50. Archive & ar,
  51. std::unordered_map<Key, HashFcn, EqualKey, Allocator> &t,
  52. const unsigned int /*file_version*/
  53. ){
  54. boost::serialization::stl::load_unordered_collection<
  55. Archive,
  56. std::unordered_map<Key, HashFcn, EqualKey, Allocator>,
  57. boost::serialization::stl::archive_input_unordered_map<
  58. Archive,
  59. std::unordered_map<Key, HashFcn, EqualKey, Allocator>
  60. >
  61. >(ar, t);
  62. }
  63. // split non-intrusive serialization function member into separate
  64. // non intrusive save/load member functions
  65. template<
  66. class Archive,
  67. class Key,
  68. class HashFcn,
  69. class EqualKey,
  70. class Allocator
  71. >
  72. inline void serialize(
  73. Archive & ar,
  74. std::unordered_map<Key, HashFcn, EqualKey, Allocator> &t,
  75. const unsigned int file_version
  76. ){
  77. boost::serialization::split_free(ar, t, file_version);
  78. }
  79. // unordered_multimap
  80. template<
  81. class Archive,
  82. class Key,
  83. class HashFcn,
  84. class EqualKey,
  85. class Allocator
  86. >
  87. inline void save(
  88. Archive & ar,
  89. const std::unordered_multimap<
  90. Key, HashFcn, EqualKey, Allocator
  91. > &t,
  92. const unsigned int /*file_version*/
  93. ){
  94. boost::serialization::stl::save_unordered_collection<
  95. Archive,
  96. std::unordered_multimap<Key, HashFcn, EqualKey, Allocator>
  97. >(ar, t);
  98. }
  99. template<
  100. class Archive,
  101. class Key,
  102. class HashFcn,
  103. class EqualKey,
  104. class Allocator
  105. >
  106. inline void load(
  107. Archive & ar,
  108. std::unordered_multimap<
  109. Key, HashFcn, EqualKey, Allocator
  110. > &t,
  111. const unsigned int /*file_version*/
  112. ){
  113. boost::serialization::stl::load_unordered_collection<
  114. Archive,
  115. std::unordered_multimap<
  116. Key, HashFcn, EqualKey, Allocator
  117. >,
  118. boost::serialization::stl::archive_input_unordered_multimap<
  119. Archive,
  120. std::unordered_multimap<Key, HashFcn, EqualKey, Allocator>
  121. >
  122. >(ar, t);
  123. }
  124. // split non-intrusive serialization function member into separate
  125. // non intrusive save/load member functions
  126. template<
  127. class Archive,
  128. class Key,
  129. class HashFcn,
  130. class EqualKey,
  131. class Allocator
  132. >
  133. inline void serialize(
  134. Archive & ar,
  135. std::unordered_multimap<
  136. Key, HashFcn, EqualKey, Allocator
  137. > &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_UNORDERED_MAP_HPP