set.hpp 3.6 KB

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