]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/serialization/include/boost/serialization/hash_collections_save_imp.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / serialization / include / boost / serialization / hash_collections_save_imp.hpp
1 #ifndef BOOST_SERIALIZATION_HASH_COLLECTIONS_SAVE_IMP_HPP
2 #define BOOST_SERIALIZATION_HASH_COLLECTIONS_SAVE_IMP_HPP
3
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER)
6 # pragma once
7 #endif
8
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // hash_collections_save_imp.hpp: serialization for stl collections
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 // helper function templates for serialization of collections
20
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>
26 #include <boost/serialization/item_version_type.hpp>
27
28 namespace boost{
29 namespace serialization {
30 namespace stl {
31
32 //////////////////////////////////////////////////////////////////////
33 // implementation of serialization for STL containers
34 //
35
36 template<class Archive, class Container>
37 inline void save_hash_collection(Archive & ar, const Container &s)
38 {
39 collection_size_type count(s.size());
40 const collection_size_type bucket_count(s.bucket_count());
41 const item_version_type item_version(
42 version<typename Container::value_type>::value
43 );
44
45 #if 0
46 /* should only be necessary to create archives of previous versions
47 * which is not currently supported. So for now comment this out
48 */
49 boost::archive::library_version_type library_version(
50 ar.get_library_version()
51 );
52 // retrieve number of elements
53 if(boost::archive::library_version_type(6) != library_version){
54 ar << BOOST_SERIALIZATION_NVP(count);
55 ar << BOOST_SERIALIZATION_NVP(bucket_count);
56 }
57 else{
58 // note: fixup for error in version 6. collection size was
59 // changed to size_t BUT for hashed collections it was implemented
60 // as an unsigned int. This should be a problem only on win64 machines
61 // but I'll leave it for everyone just in case.
62 const unsigned int c = count;
63 const unsigned int bc = bucket_count;
64 ar << BOOST_SERIALIZATION_NVP(c);
65 ar << BOOST_SERIALIZATION_NVP(bc);
66 }
67 if(boost::archive::library_version_type(3) < library_version){
68 // record number of elements
69 // make sure the target type is registered so we can retrieve
70 // the version when we load
71 ar << BOOST_SERIALIZATION_NVP(item_version);
72 }
73 #else
74 ar << BOOST_SERIALIZATION_NVP(count);
75 ar << BOOST_SERIALIZATION_NVP(bucket_count);
76 ar << BOOST_SERIALIZATION_NVP(item_version);
77 #endif
78
79 typename Container::const_iterator it = s.begin();
80 while(count-- > 0){
81 // note borland emits a no-op without the explicit namespace
82 boost::serialization::save_construct_data_adl(
83 ar,
84 &(*it),
85 boost::serialization::version<
86 typename Container::value_type
87 >::value
88 );
89 ar << boost::serialization::make_nvp("item", *it++);
90 }
91 }
92
93 } // namespace stl
94 } // namespace serialization
95 } // namespace boost
96
97 #endif //BOOST_SERIALIZATION_HASH_COLLECTIONS_SAVE_IMP_HPP