map.hpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #ifndef BOOST_SERIALIZATION_MAP_HPP
  2. #define BOOST_SERIALIZATION_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/map.hpp:
  9. // serialization for stl map templates
  10. // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
  11. // Use, modification and distribution is subject to the Boost Software
  12. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  13. // http://www.boost.org/LICENSE_1_0.txt)
  14. // See http://www.boost.org for updates, documentation, and revision history.
  15. #include <map>
  16. #include <boost/config.hpp>
  17. #include <boost/serialization/utility.hpp>
  18. #include <boost/serialization/collections_save_imp.hpp>
  19. #include <boost/serialization/collections_load_imp.hpp>
  20. #include <boost/serialization/split_free.hpp>
  21. namespace boost {
  22. namespace serialization {
  23. template<class Archive, class Type, class Key, class Compare, class Allocator >
  24. inline void save(
  25. Archive & ar,
  26. const std::map<Key, Type, Compare, Allocator> &t,
  27. const unsigned int /* file_version */
  28. ){
  29. boost::serialization::stl::save_collection<
  30. Archive,
  31. std::map<Key, Type, Compare, Allocator>
  32. >(ar, t);
  33. }
  34. template<class Archive, class Type, class Key, class Compare, class Allocator >
  35. inline void load(
  36. Archive & ar,
  37. std::map<Key, Type, Compare, Allocator> &t,
  38. const unsigned int /* file_version */
  39. ){
  40. boost::serialization::stl::load_collection<
  41. Archive,
  42. std::map<Key, Type, Compare, Allocator>,
  43. boost::serialization::stl::archive_input_map<
  44. Archive, std::map<Key, Type, Compare, Allocator> >,
  45. boost::serialization::stl::no_reserve_imp<std::map<
  46. Key, Type, Compare, Allocator
  47. >
  48. >
  49. >(ar, t);
  50. }
  51. // split non-intrusive serialization function member into separate
  52. // non intrusive save/load member functions
  53. template<class Archive, class Type, class Key, class Compare, class Allocator >
  54. inline void serialize(
  55. Archive & ar,
  56. std::map<Key, Type, Compare, Allocator> &t,
  57. const unsigned int file_version
  58. ){
  59. boost::serialization::split_free(ar, t, file_version);
  60. }
  61. // multimap
  62. template<class Archive, class Type, class Key, class Compare, class Allocator >
  63. inline void save(
  64. Archive & ar,
  65. const std::multimap<Key, Type, Compare, Allocator> &t,
  66. const unsigned int /* file_version */
  67. ){
  68. boost::serialization::stl::save_collection<
  69. Archive,
  70. std::multimap<Key, Type, Compare, Allocator>
  71. >(ar, t);
  72. }
  73. template<class Archive, class Type, class Key, class Compare, class Allocator >
  74. inline void load(
  75. Archive & ar,
  76. std::multimap<Key, Type, Compare, Allocator> &t,
  77. const unsigned int /* file_version */
  78. ){
  79. boost::serialization::stl::load_collection<
  80. Archive,
  81. std::multimap<Key, Type, Compare, Allocator>,
  82. boost::serialization::stl::archive_input_multimap<
  83. Archive, std::multimap<Key, Type, Compare, Allocator>
  84. >,
  85. boost::serialization::stl::no_reserve_imp<
  86. std::multimap<Key, Type, Compare, Allocator>
  87. >
  88. >(ar, t);
  89. }
  90. // split non-intrusive serialization function member into separate
  91. // non intrusive save/load member functions
  92. template<class Archive, class Type, class Key, class Compare, class Allocator >
  93. inline void serialize(
  94. Archive & ar,
  95. std::multimap<Key, Type, Compare, Allocator> &t,
  96. const unsigned int file_version
  97. ){
  98. boost::serialization::split_free(ar, t, file_version);
  99. }
  100. } // serialization
  101. } // namespace boost
  102. #endif // BOOST_SERIALIZATION_MAP_HPP