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