1#ifndef BOOST_SERIALIZATION_COLLECTIONS_LOAD_IMP_HPP
2#define BOOST_SERIALIZATION_COLLECTIONS_LOAD_IMP_HPP
3
4// MS compatible compilers support #pragma once
5#if defined(_MSC_VER)
6# pragma once
7#endif
8
9#if defined(_MSC_VER) && (_MSC_VER <= 1020)
10# pragma warning (disable : 4786) // too long name, harmless warning
11#endif
12
13/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
14// collections_load_imp.hpp: serialization for loading stl collections
15
16// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
17// Use, modification and distribution is subject to the Boost Software
18// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
19// http://www.boost.org/LICENSE_1_0.txt)
20
21// See http://www.boost.org for updates, documentation, and revision history.
22
23// helper function templates for serialization of collections
24
25#include <boost/assert.hpp>
26#include <cstddef> // size_t
27#include <boost/config.hpp> // msvc 6.0 needs this for warning suppression
28#if defined(BOOST_NO_STDC_NAMESPACE)
29namespace std{
30 using ::size_t;
31} // namespace std
32#endif
33#include <boost/detail/workaround.hpp>
34
35#include <boost/archive/detail/basic_iarchive.hpp>
36#include <boost/serialization/access.hpp>
37#include <boost/serialization/nvp.hpp>
38#include <boost/serialization/detail/stack_constructor.hpp>
39#include <boost/serialization/collection_size_type.hpp>
40#include <boost/serialization/item_version_type.hpp>
41#include <boost/serialization/detail/is_default_constructible.hpp>
42#include <boost/utility/enable_if.hpp>
43
44namespace boost{
45namespace serialization {
46namespace stl {
47
48//////////////////////////////////////////////////////////////////////
49// implementation of serialization for STL containers
50//
51
52template<
53 class Archive,
54 class T
55>
56typename boost::enable_if<
57 typename detail::is_default_constructible<
58 typename T::value_type
59 >,
60 void
61>::type
62collection_load_impl(
63 Archive & ar,
64 T & t,
65 collection_size_type count,
66 item_version_type
67){
68 t.resize(count);
69 typename T::iterator hint;
70 hint = t.begin();
71 while(count-- > 0){
72 ar >> boost::serialization::make_nvp("item", *hint++);
73 }
74}
75
76template<
77 class Archive,
78 class T
79>
80typename boost::disable_if<
81 typename detail::is_default_constructible<
82 typename T::value_type
83 >,
84 void
85>::type
86collection_load_impl(
87 Archive & ar,
88 T & t,
89 collection_size_type count,
90 item_version_type item_version
91){
92 t.clear();
93 while(count-- > 0){
94 detail::stack_construct<Archive, typename T::value_type> u(ar, item_version);
95 ar >> boost::serialization::make_nvp("item", u.reference());
96 t.push_back(u.reference());
97 ar.reset_object_address(& t.back() , & u.reference());
98 }
99}
100
101} // namespace stl
102} // namespace serialization
103} // namespace boost
104
105#endif //BOOST_SERIALIZATION_COLLECTIONS_LOAD_IMP_HPP
106

source code of boost/boost/serialization/collections_load_imp.hpp