boost_unordered_map.hpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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 <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 HashFcn,
  29. class EqualKey,
  30. class Allocator
  31. >
  32. inline void save(
  33. Archive & ar,
  34. const boost::unordered_map<Key, HashFcn, EqualKey, Allocator> &t,
  35. const unsigned int /*file_version*/
  36. ){
  37. boost::serialization::stl::save_unordered_collection<
  38. Archive,
  39. boost::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. boost::unordered_map<Key, HashFcn, EqualKey, Allocator> &t,
  52. const unsigned int /*file_version*/
  53. ){
  54. boost::serialization::stl::load_unordered_collection<
  55. Archive,
  56. boost::unordered_map<Key, HashFcn, EqualKey, Allocator>,
  57. boost::serialization::stl::archive_input_unordered_map<
  58. Archive,
  59. boost::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. boost::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 boost::unordered_multimap<Key, HashFcn, EqualKey, Allocator> &t,
  90. const unsigned int /*file_version*/
  91. ){
  92. boost::serialization::stl::save_unordered_collection<
  93. Archive,
  94. boost::unordered_multimap<Key, HashFcn, EqualKey, Allocator>
  95. >(ar, t);
  96. }
  97. template<
  98. class Archive,
  99. class Key,
  100. class HashFcn,
  101. class EqualKey,
  102. class Allocator
  103. >
  104. inline void load(
  105. Archive & ar,
  106. boost::unordered_multimap<
  107. Key, HashFcn, EqualKey, Allocator
  108. > &t,
  109. const unsigned int /*file_version*/
  110. ){
  111. boost::serialization::stl::load_unordered_collection<
  112. Archive,
  113. boost::unordered_multimap<Key, HashFcn, EqualKey, Allocator>,
  114. boost::serialization::stl::archive_input_unordered_multimap<
  115. Archive,
  116. boost::unordered_multimap<Key, HashFcn, EqualKey, Allocator>
  117. >
  118. >(ar, t);
  119. }
  120. // split non-intrusive serialization function member into separate
  121. // non intrusive save/load member functions
  122. template<
  123. class Archive,
  124. class Key,
  125. class HashFcn,
  126. class EqualKey,
  127. class Allocator
  128. >
  129. inline void serialize(
  130. Archive & ar,
  131. boost::unordered_multimap<Key, HashFcn, EqualKey, Allocator> &t,
  132. const unsigned int file_version
  133. ){
  134. boost::serialization::split_free(ar, t, file_version);
  135. }
  136. } // namespace serialization
  137. } // namespace boost
  138. #endif // BOOST_SERIALIZATION_UNORDERED_MAP_HPP