list.hpp 2.5 KB

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