Imported Upstream version 1.64.0
[platform/upstream/boost.git] / boost / serialization / list.hpp
1 #ifndef BOOST_SERIALIZATION_LIST_HPP
2 #define BOOST_SERIALIZATION_LIST_HPP
3
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER)
6 # pragma once
7 #endif
8
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // list.hpp: serialization for stl list templates
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 <list>
20
21 #include <boost/config.hpp>
22
23 #include <boost/serialization/collections_save_imp.hpp>
24 #include <boost/serialization/collections_load_imp.hpp>
25
26 #include <boost/archive/detail/basic_iarchive.hpp>
27 #include <boost/serialization/access.hpp>
28 #include <boost/serialization/nvp.hpp>
29 #include <boost/serialization/collection_size_type.hpp>
30 #include <boost/serialization/item_version_type.hpp>
31 #include <boost/serialization/split_free.hpp>
32
33 namespace boost { 
34 namespace serialization {
35
36 template<class Archive, class U, class Allocator>
37 inline void save(
38     Archive & ar,
39     const std::list<U, Allocator> &t,
40     const unsigned int /* file_version */
41 ){
42     boost::serialization::stl::save_collection<
43         Archive, 
44         std::list<U, Allocator> 
45     >(ar, t);
46 }
47
48 template<class Archive, class U, class Allocator>
49 inline void load(
50     Archive & ar,
51     std::list<U, Allocator> &t,
52     const unsigned int /* file_version */
53 ){
54     const boost::archive::library_version_type library_version(
55         ar.get_library_version()
56     );
57     // retrieve number of elements
58     item_version_type item_version(0);
59     collection_size_type count;
60     ar >> BOOST_SERIALIZATION_NVP(count);
61     if(boost::archive::library_version_type(3) < library_version){
62         ar >> BOOST_SERIALIZATION_NVP(item_version);
63     }
64     stl::collection_load_impl(ar, t, count, item_version);
65 }
66
67 // split non-intrusive serialization function member into separate
68 // non intrusive save/load member functions
69 template<class Archive, class U, class Allocator>
70 inline void serialize(
71     Archive & ar,
72     std::list<U, Allocator> & t,
73     const unsigned int file_version
74 ){
75     boost::serialization::split_free(ar, t, file_version);
76 }
77
78 } // serialization
79 } // namespace boost
80
81 #include <boost/serialization/collection_traits.hpp>
82
83 BOOST_SERIALIZATION_COLLECTION_TRAITS(std::list)
84
85 #endif // BOOST_SERIALIZATION_LIST_HPP