[857] | 1 | #ifndef BOOST_SERIALIZATION_VECTOR_HPP
|
---|
| 2 | #define BOOST_SERIALIZATION_VECTOR_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 | // vector.hpp: serialization for stl vector 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 <vector>
|
---|
| 20 |
|
---|
| 21 | #include <boost/config.hpp>
|
---|
| 22 | #include <boost/detail/workaround.hpp>
|
---|
| 23 |
|
---|
| 24 | #include <boost/serialization/collections_save_imp.hpp>
|
---|
| 25 | #include <boost/serialization/collections_load_imp.hpp>
|
---|
| 26 | #include <boost/serialization/split_free.hpp>
|
---|
| 27 |
|
---|
| 28 | // function specializations must be defined in the appropriate
|
---|
| 29 | // namespace - boost::serialization
|
---|
| 30 | #if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
|
---|
| 31 | #define STD _STLP_STD
|
---|
| 32 | #else
|
---|
| 33 | #define STD std
|
---|
| 34 | #endif
|
---|
| 35 |
|
---|
| 36 | namespace boost {
|
---|
| 37 | namespace serialization {
|
---|
| 38 |
|
---|
| 39 | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
---|
| 40 | // vector<T>
|
---|
| 41 | template<class Archive, class U, class Allocator>
|
---|
| 42 | inline void save(
|
---|
| 43 | Archive & ar,
|
---|
| 44 | const STD::vector<U, Allocator> &t,
|
---|
| 45 | const unsigned int /* file_version */
|
---|
| 46 | ){
|
---|
| 47 | boost::serialization::stl::save_collection<Archive, STD::vector<U, Allocator> >(
|
---|
| 48 | ar, t
|
---|
| 49 | );
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | template<class Archive, class U, class Allocator>
|
---|
| 53 | inline void load(
|
---|
| 54 | Archive & ar,
|
---|
| 55 | STD::vector<U, Allocator> &t,
|
---|
| 56 | const unsigned int /* file_version */
|
---|
| 57 | ){
|
---|
| 58 | boost::serialization::stl::load_collection<
|
---|
| 59 | Archive,
|
---|
| 60 | STD::vector<U, Allocator>,
|
---|
| 61 | boost::serialization::stl::archive_input_seq<
|
---|
| 62 | Archive, STD::vector<U, Allocator>
|
---|
| 63 | >,
|
---|
| 64 | boost::serialization::stl::reserve_imp<STD::vector<U, Allocator> >
|
---|
| 65 | >(ar, t);
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | // split non-intrusive serialization function member into separate
|
---|
| 69 | // non intrusive save/load member functions
|
---|
| 70 | template<class Archive, class U, class Allocator>
|
---|
| 71 | inline void serialize(
|
---|
| 72 | Archive & ar,
|
---|
| 73 | STD::vector<U, Allocator> & t,
|
---|
| 74 | const unsigned int file_version
|
---|
| 75 | ){
|
---|
| 76 | boost::serialization::split_free(ar, t, file_version);
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 | #if ! BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
---|
| 80 |
|
---|
| 81 | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
---|
| 82 | // vector<bool>
|
---|
| 83 | template<class Archive, class Allocator>
|
---|
| 84 | inline void save(
|
---|
| 85 | Archive & ar,
|
---|
| 86 | const STD::vector<bool, Allocator> &t,
|
---|
| 87 | const unsigned int /* file_version */
|
---|
| 88 | ){
|
---|
| 89 | // record number of elements
|
---|
| 90 | unsigned int count = t.size();
|
---|
| 91 | ar << BOOST_SERIALIZATION_NVP(count);
|
---|
| 92 | STD::vector<bool>::const_iterator it = t.begin();
|
---|
| 93 | while(count-- > 0){
|
---|
| 94 | bool tb = *it++;
|
---|
| 95 | ar << boost::serialization::make_nvp("item", tb);
|
---|
| 96 | }
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | template<class Archive, class Allocator>
|
---|
| 100 | inline void load(
|
---|
| 101 | Archive & ar,
|
---|
| 102 | STD::vector<bool, Allocator> &t,
|
---|
| 103 | const unsigned int /* file_version */
|
---|
| 104 | ){
|
---|
| 105 | // retrieve number of elements
|
---|
| 106 | unsigned int count;
|
---|
| 107 | ar >> BOOST_SERIALIZATION_NVP(count);
|
---|
| 108 | t.clear();
|
---|
| 109 | while(count-- > 0){
|
---|
| 110 | bool i;
|
---|
| 111 | ar >> boost::serialization::make_nvp("item", i);
|
---|
| 112 | t.push_back(i);
|
---|
| 113 | }
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 | // split non-intrusive serialization function member into separate
|
---|
| 117 | // non intrusive save/load member functions
|
---|
| 118 | template<class Archive, class Allocator>
|
---|
| 119 | inline void serialize(
|
---|
| 120 | Archive & ar,
|
---|
| 121 | STD::vector<bool, Allocator> & t,
|
---|
| 122 | const unsigned int file_version
|
---|
| 123 | ){
|
---|
| 124 | boost::serialization::split_free(ar, t, file_version);
|
---|
| 125 | }
|
---|
| 126 |
|
---|
| 127 | #endif // BOOST_WORKAROUND
|
---|
| 128 |
|
---|
| 129 | } // serialization
|
---|
| 130 | } // namespace boost
|
---|
| 131 |
|
---|
| 132 | #include <boost/serialization/collection_traits.hpp>
|
---|
| 133 |
|
---|
| 134 | BOOST_SERIALIZATION_COLLECTION_TRAITS(STD::vector)
|
---|
| 135 | #undef STD
|
---|
| 136 |
|
---|
| 137 | #endif // BOOST_SERIALIZATION_VECTOR_HPP
|
---|