Chris@102
|
1 #ifndef BOOST_SERIALIZATION_UNORDERED_COLLECTIONS_LOAD_IMP_HPP
|
Chris@102
|
2 #define BOOST_SERIALIZATION_UNORDERED_COLLECTIONS_LOAD_IMP_HPP
|
Chris@102
|
3
|
Chris@102
|
4 // MS compatible compilers support #pragma once
|
Chris@102
|
5 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
Chris@102
|
6 # pragma once
|
Chris@102
|
7 # pragma warning (disable : 4786) // too long name, harmless warning
|
Chris@102
|
8 #endif
|
Chris@102
|
9
|
Chris@102
|
10 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
Chris@102
|
11 // unordered_collections_load_imp.hpp: serialization for loading stl collections
|
Chris@102
|
12
|
Chris@102
|
13 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
Chris@102
|
14 // (C) Copyright 2014 Jim Bell
|
Chris@102
|
15 // Use, modification and distribution is subject to the Boost Software
|
Chris@102
|
16 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@102
|
17 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@102
|
18
|
Chris@102
|
19 // See http://www.boost.org for updates, documentation, and revision history.
|
Chris@102
|
20
|
Chris@102
|
21 // helper function templates for serialization of collections
|
Chris@102
|
22
|
Chris@102
|
23 #include <boost/assert.hpp>
|
Chris@102
|
24 #include <cstddef> // size_t
|
Chris@102
|
25 #include <boost/config.hpp> // msvc 6.0 needs this for warning suppression
|
Chris@102
|
26 #if defined(BOOST_NO_STDC_NAMESPACE)
|
Chris@102
|
27 namespace std{
|
Chris@102
|
28 using ::size_t;
|
Chris@102
|
29 } // namespace std
|
Chris@102
|
30 #endif
|
Chris@102
|
31 #include <boost/detail/workaround.hpp>
|
Chris@102
|
32
|
Chris@102
|
33 #include <boost/archive/detail/basic_iarchive.hpp>
|
Chris@102
|
34 #include <boost/serialization/access.hpp>
|
Chris@102
|
35 #include <boost/serialization/nvp.hpp>
|
Chris@102
|
36 #include <boost/serialization/detail/stack_constructor.hpp>
|
Chris@102
|
37 #include <boost/serialization/collection_size_type.hpp>
|
Chris@102
|
38 #include <boost/serialization/item_version_type.hpp>
|
Chris@102
|
39
|
Chris@102
|
40 namespace boost{
|
Chris@102
|
41 namespace serialization {
|
Chris@102
|
42 namespace stl {
|
Chris@102
|
43
|
Chris@102
|
44 //////////////////////////////////////////////////////////////////////
|
Chris@102
|
45 // implementation of serialization for STL containers
|
Chris@102
|
46 //
|
Chris@102
|
47 template<class Archive, class Container, class InputFunction>
|
Chris@102
|
48 inline void load_unordered_collection(Archive & ar, Container &s)
|
Chris@102
|
49 {
|
Chris@102
|
50 collection_size_type count;
|
Chris@102
|
51 collection_size_type bucket_count;
|
Chris@102
|
52 boost::serialization::item_version_type item_version(0);
|
Chris@102
|
53 boost::archive::library_version_type library_version(
|
Chris@102
|
54 ar.get_library_version()
|
Chris@102
|
55 );
|
Chris@102
|
56 // retrieve number of elements
|
Chris@102
|
57 ar >> BOOST_SERIALIZATION_NVP(count);
|
Chris@102
|
58 ar >> BOOST_SERIALIZATION_NVP(bucket_count);
|
Chris@102
|
59 if(boost::archive::library_version_type(3) < library_version){
|
Chris@102
|
60 ar >> BOOST_SERIALIZATION_NVP(item_version);
|
Chris@102
|
61 }
|
Chris@102
|
62 s.clear();
|
Chris@102
|
63 s.rehash(bucket_count);
|
Chris@102
|
64 InputFunction ifunc;
|
Chris@102
|
65 while(count-- > 0){
|
Chris@102
|
66 ifunc(ar, s, item_version);
|
Chris@102
|
67 }
|
Chris@102
|
68 }
|
Chris@102
|
69
|
Chris@102
|
70 } // namespace stl
|
Chris@102
|
71 } // namespace serialization
|
Chris@102
|
72 } // namespace boost
|
Chris@102
|
73
|
Chris@102
|
74 #endif //BOOST_SERIALIZATION_UNORDERED_COLLECTIONS_LOAD_IMP_HPP
|