deque.hpp 2.2 KB

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