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