]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/serialization/collections_save_imp.hpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / boost / serialization / collections_save_imp.hpp
1 #ifndef BOOST_SERIALIZATION_COLLECTIONS_SAVE_IMP_HPP
2 #define BOOST_SERIALIZATION_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 // 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/core/addressof.hpp>
23 #include <boost/serialization/nvp.hpp>
24 #include <boost/serialization/serialization.hpp>
25 #include <boost/serialization/version.hpp>
26 #include <boost/serialization/collection_size_type.hpp>
27 #include <boost/serialization/item_version_type.hpp>
28
29 namespace boost{
30 namespace serialization {
31 namespace stl {
32
33 //////////////////////////////////////////////////////////////////////
34 // implementation of serialization for STL containers
35 //
36
37 template<class Archive, class Container>
38 inline void save_collection(
39 Archive & ar,
40 const Container &s,
41 collection_size_type count)
42 {
43 ar << BOOST_SERIALIZATION_NVP(count);
44 // record number of elements
45 const item_version_type item_version(
46 version<typename Container::value_type>::value
47 );
48 #if 0
49 boost::archive::library_version_type library_version(
50 ar.get_library_version()
51 );
52 if(boost::archive::library_version_type(3) < library_version){
53 ar << BOOST_SERIALIZATION_NVP(item_version);
54 }
55 #else
56 ar << BOOST_SERIALIZATION_NVP(item_version);
57 #endif
58
59 typename Container::const_iterator it = s.begin();
60 while(count-- > 0){
61 // note borland emits a no-op without the explicit namespace
62 boost::serialization::save_construct_data_adl(
63 ar,
64 boost::addressof(*it),
65 item_version
66 );
67 ar << boost::serialization::make_nvp("item", *it++);
68 }
69 }
70
71 template<class Archive, class Container>
72 inline void save_collection(Archive & ar, const Container &s)
73 {
74 // record number of elements
75 collection_size_type count(s.size());
76 save_collection(ar, s, count);
77 }
78
79 } // namespace stl
80 } // namespace serialization
81 } // namespace boost
82
83 #endif //BOOST_SERIALIZATION_COLLECTIONS_SAVE_IMP_HPP