1 #ifndef BOOST_SERIALIZATION_COLLECTIONS_SAVE_IMP_HPP
2 #define BOOST_SERIALIZATION_COLLECTIONS_SAVE_IMP_HPP
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // collections_save_imp.hpp: serialization for stl collections
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)
17 // See http://www.boost.org for updates, documentation, and revision history.
19 // helper function templates for serialization of collections
21 #include <boost/config.hpp>
22 #include <boost/serialization/nvp.hpp>
23 #include <boost/serialization/serialization.hpp>
24 #include <boost/serialization/version.hpp>
25 #include <boost/serialization/collection_size_type.hpp>
28 namespace serialization
{
31 //////////////////////////////////////////////////////////////////////
32 // implementation of serialization for STL containers
35 template<class Archive
, class Container
>
36 inline void save_collection(Archive
& ar
, const Container
&s
)
38 // record number of elements
39 collection_size_type
const count(s
.size());
40 ar
<< BOOST_SERIALIZATION_NVP(count
);
41 // make sure the target type is registered so we can retrieve
42 // the version when we load
43 if(3 < ar
.get_library_version()){
44 const unsigned int item_version
= version
<
45 BOOST_DEDUCED_TYPENAME
Container::value_type
47 ar
<< BOOST_SERIALIZATION_NVP(item_version
);
49 BOOST_DEDUCED_TYPENAME
Container::const_iterator it
= s
.begin();
52 // note borland emits a no-op without the explicit namespace
53 boost::serialization::save_construct_data_adl(
56 boost::serialization::version
<
57 BOOST_DEDUCED_TYPENAME
Container::value_type
60 ar
<< boost::serialization::make_nvp("item", *it
++);
65 } // namespace serialization
68 #endif //BOOST_SERIALIZATION_COLLECTIONS_SAVE_IMP_HPP