| 1 | #ifndef BOOST_SERIALIZATION_SLIST_HPP |
|---|
| 2 | #define BOOST_SERIALIZATION_SLIST_HPP |
|---|
| 3 | |
|---|
| 4 | // MS compatible compilers support #pragma once |
|---|
| 5 | #if defined(_MSC_VER) && (_MSC_VER >= 1020) |
|---|
| 6 | # pragma once |
|---|
| 7 | #endif |
|---|
| 8 | |
|---|
| 9 | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 |
|---|
| 10 | // slist.hpp |
|---|
| 11 | |
|---|
| 12 | // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . |
|---|
| 13 | // Use, modification and distribution is subject to the Boost Software |
|---|
| 14 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
|---|
| 15 | // http://www.boost.org/LICENSE_1_0.txt) |
|---|
| 16 | |
|---|
| 17 | // See http://www.boost.org for updates, documentation, and revision history. |
|---|
| 18 | |
|---|
| 19 | #include <boost/config.hpp> |
|---|
| 20 | #ifdef BOOST_HAS_SLIST |
|---|
| 21 | #include BOOST_SLIST_HEADER |
|---|
| 22 | |
|---|
| 23 | #include <boost/serialization/collections_save_imp.hpp> |
|---|
| 24 | #include <boost/serialization/collections_load_imp.hpp> |
|---|
| 25 | #include <boost/serialization/split_free.hpp> |
|---|
| 26 | #include <boost/serialization/nvp.hpp> |
|---|
| 27 | |
|---|
| 28 | namespace boost { |
|---|
| 29 | namespace serialization { |
|---|
| 30 | |
|---|
| 31 | template<class Archive, class U, class Allocator> |
|---|
| 32 | inline void save( |
|---|
| 33 | Archive & ar, |
|---|
| 34 | const BOOST_STD_EXTENSION_NAMESPACE::slist<U, Allocator> &t, |
|---|
| 35 | const unsigned int file_version |
|---|
| 36 | ){ |
|---|
| 37 | boost::serialization::stl::save_collection< |
|---|
| 38 | Archive, |
|---|
| 39 | BOOST_STD_EXTENSION_NAMESPACE::slist<U, Allocator> |
|---|
| 40 | >(ar, t); |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | template<class Archive, class U, class Allocator> |
|---|
| 44 | inline void load( |
|---|
| 45 | Archive & ar, |
|---|
| 46 | BOOST_STD_EXTENSION_NAMESPACE::slist<U, Allocator> &t, |
|---|
| 47 | const unsigned int file_version |
|---|
| 48 | ){ |
|---|
| 49 | // retrieve number of elements |
|---|
| 50 | t.clear(); |
|---|
| 51 | // retrieve number of elements |
|---|
| 52 | unsigned int count; |
|---|
| 53 | ar >> BOOST_SERIALIZATION_NVP(count); |
|---|
| 54 | if(0 == count) |
|---|
| 55 | return; |
|---|
| 56 | unsigned int v; |
|---|
| 57 | if(3 < ar.get_library_version()){ |
|---|
| 58 | ar >> make_nvp("item_version", v); |
|---|
| 59 | } |
|---|
| 60 | boost::serialization::detail::stack_construct<Archive, U> u(ar, v); |
|---|
| 61 | ar >> boost::serialization::make_nvp("item", u.reference()); |
|---|
| 62 | t.push_front(u.reference()); |
|---|
| 63 | BOOST_DEDUCED_TYPENAME BOOST_STD_EXTENSION_NAMESPACE::slist<U, Allocator>::iterator last; |
|---|
| 64 | last = t.begin(); |
|---|
| 65 | while(--count > 0){ |
|---|
| 66 | boost::serialization::detail::stack_construct<Archive, U> |
|---|
| 67 | u(ar, file_version); |
|---|
| 68 | ar >> boost::serialization::make_nvp("item", u.reference()); |
|---|
| 69 | last = t.insert_after(last, u.reference()); |
|---|
| 70 | ar.reset_object_address(& (*last), & u.reference()); |
|---|
| 71 | } |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | // split non-intrusive serialization function member into separate |
|---|
| 75 | // non intrusive save/load member functions |
|---|
| 76 | template<class Archive, class U, class Allocator> |
|---|
| 77 | inline void serialize( |
|---|
| 78 | Archive & ar, |
|---|
| 79 | BOOST_STD_EXTENSION_NAMESPACE::slist<U, Allocator> &t, |
|---|
| 80 | const unsigned int file_version |
|---|
| 81 | ){ |
|---|
| 82 | boost::serialization::split_free(ar, t, file_version); |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | } // serialization |
|---|
| 86 | } // namespace boost |
|---|
| 87 | |
|---|
| 88 | #include <boost/serialization/collection_traits.hpp> |
|---|
| 89 | |
|---|
| 90 | BOOST_SERIALIZATION_COLLECTION_TRAITS(BOOST_STD_EXTENSION_NAMESPACE::slist) |
|---|
| 91 | |
|---|
| 92 | #endif // BOOST_HAS_SLIST |
|---|
| 93 | #endif // BOOST_SERIALIZATION_SLIST_HPP |
|---|