deque.hpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef BOOST_SERIALIZATION_DEQUE_HPP
  2. #define BOOST_SERIALIZATION_DEQUE_HPP
  3. // MS compatible compilers support #pragma once
  4. #if defined(_MSC_VER)
  5. # pragma once
  6. #endif
  7. /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
  8. // deque.hpp
  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 <deque>
  15. #include <boost/config.hpp>
  16. #include <boost/archive/basic_archive.hpp>
  17. #include <boost/serialization/collections_save_imp.hpp>
  18. #include <boost/serialization/collections_load_imp.hpp>
  19. #include <boost/serialization/detail/stack_constructor.hpp>
  20. #include <boost/serialization/split_free.hpp>
  21. namespace boost {
  22. namespace serialization {
  23. template<class Archive, class U, class Allocator>
  24. inline void save(
  25. Archive & ar,
  26. const std::deque<U, Allocator> &t,
  27. const unsigned int /* file_version */
  28. ){
  29. boost::serialization::stl::save_collection<
  30. Archive, std::deque<U, Allocator>
  31. >(ar, t);
  32. }
  33. template<class Archive, class U, class Allocator>
  34. inline void load(
  35. Archive & ar,
  36. std::deque<U, Allocator> &t,
  37. const unsigned int /* file_version */
  38. ){
  39. const boost::archive::library_version_type library_version(
  40. ar.get_library_version()
  41. );
  42. // retrieve number of elements
  43. item_version_type item_version(0);
  44. collection_size_type count;
  45. ar >> BOOST_SERIALIZATION_NVP(count);
  46. if(boost::archive::library_version_type(3) < library_version){
  47. ar >> BOOST_SERIALIZATION_NVP(item_version);
  48. }
  49. stl::collection_load_impl(ar, t, count, item_version);
  50. }
  51. // split non-intrusive serialization function member into separate
  52. // non intrusive save/load member functions
  53. template<class Archive, class U, class Allocator>
  54. inline void serialize(
  55. Archive & ar,
  56. std::deque<U, Allocator> &t,
  57. const unsigned int file_version
  58. ){
  59. boost::serialization::split_free(ar, t, file_version);
  60. }
  61. } // namespace serialization
  62. } // namespace boost
  63. #include <boost/serialization/collection_traits.hpp>
  64. BOOST_SERIALIZATION_COLLECTION_TRAITS(std::deque)
  65. #endif // BOOST_SERIALIZATION_DEQUE_HPP