Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/boost/serialization/vector.hpp @ 29

Last change on this file since 29 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 3.6 KB
Line 
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
28namespace boost { 
29namespace serialization {
30
31/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
32// vector<T>
33template<class Archive, class U, class Allocator>
34inline void save(
35    Archive & ar,
36    const std::vector<U, Allocator> &t,
37    const unsigned int /* file_version */
38){
39    boost::serialization::stl::save_collection<Archive, std::vector<U, Allocator> >(
40        ar, t
41    );
42}
43
44template<class Archive, class U, class Allocator>
45inline void load(
46    Archive & ar,
47    std::vector<U, Allocator> &t,
48    const unsigned int /* file_version */
49){
50    boost::serialization::stl::load_collection<
51        Archive,
52        std::vector<U, Allocator>,
53        boost::serialization::stl::archive_input_seq<
54            Archive, std::vector<U, Allocator> 
55        >,
56        boost::serialization::stl::reserve_imp<std::vector<U, Allocator> >
57    >(ar, t);
58}
59
60// split non-intrusive serialization function member into separate
61// non intrusive save/load member functions
62template<class Archive, class U, class Allocator>
63inline void serialize(
64    Archive & ar,
65    std::vector<U, Allocator> & t,
66    const unsigned int file_version
67){
68    boost::serialization::split_free(ar, t, file_version);
69}
70
71#if ! BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
72
73/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
74// vector<bool>
75template<class Archive, class Allocator>
76inline void save(
77    Archive & ar,
78    const std::vector<bool, Allocator> &t,
79    const unsigned int /* file_version */
80){
81    // record number of elements
82    unsigned int count = t.size();
83    ar << BOOST_SERIALIZATION_NVP(count);
84    std::vector<bool>::const_iterator it = t.begin();
85    while(count-- > 0){
86        bool tb = *it++;
87        ar << boost::serialization::make_nvp("item", tb);
88    }
89}
90
91template<class Archive, class Allocator>
92inline void load(
93    Archive & ar,
94    std::vector<bool, Allocator> &t,
95    const unsigned int /* file_version */
96){
97    // retrieve number of elements
98    unsigned int count;
99    ar >> BOOST_SERIALIZATION_NVP(count);
100    t.clear();
101    while(count-- > 0){
102        bool i;
103        ar >> boost::serialization::make_nvp("item", i);
104        t.push_back(i);
105    }
106}
107
108// split non-intrusive serialization function member into separate
109// non intrusive save/load member functions
110template<class Archive, class Allocator>
111inline void serialize(
112    Archive & ar,
113    std::vector<bool, Allocator> & t,
114    const unsigned int file_version
115){
116    boost::serialization::split_free(ar, t, file_version);
117}
118
119#endif // BOOST_WORKAROUND
120
121} // serialization
122} // namespace boost
123
124#include <boost/serialization/collection_traits.hpp>
125
126BOOST_SERIALIZATION_COLLECTION_TRAITS(std::vector)
127
128#endif // BOOST_SERIALIZATION_VECTOR_HPP
Note: See TracBrowser for help on using the repository browser.