1 #ifndef BOOST_SERIALIZATION_HASH_COLLECTIONS_SAVE_IMP_HPP
2 #define BOOST_SERIALIZATION_HASH_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 // hash_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>
27 namespace serialization
{
30 //////////////////////////////////////////////////////////////////////
31 // implementation of serialization for STL containers
34 template<class Archive
, class Container
>
35 inline void save_hash_collection(Archive
& ar
, const Container
&s
)
37 // record number of elements
38 unsigned int count
= s
.size();
39 ar
<< BOOST_SERIALIZATION_NVP(count
);
40 // make sure the target type is registered so we can retrieve
41 // the version when we load
42 if(3 < ar
.get_library_version()){
43 const unsigned int bucket_count
= s
.bucket_count();
44 ar
<< BOOST_SERIALIZATION_NVP(bucket_count
);
45 const unsigned int item_version
= version
<BOOST_DEDUCED_TYPENAME
Container::value_type
>::value
;
46 ar
<< BOOST_SERIALIZATION_NVP(item_version
);
48 BOOST_DEDUCED_TYPENAME
Container::const_iterator it
= s
.begin();
50 // note borland emits a no-op without the explicit namespace
51 boost::serialization::save_construct_data_adl(
54 boost::serialization::version
<
55 BOOST_DEDUCED_TYPENAME
Container::value_type
58 ar
<< boost::serialization::make_nvp("item", *it
++);
63 } // namespace serialization
66 #endif //BOOST_SERIALIZATION_HASH_COLLECTIONS_SAVE_IMP_HPP