• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef BOOST_SERIALIZATION_HASH_COLLECTIONS_LOAD_IMP_HPP
2 #define BOOST_SERIALIZATION_HASH_COLLECTIONS_LOAD_IMP_HPP
3 
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER)
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 // hash_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 hashed collections
21 #include <boost/config.hpp>
22 #include <boost/serialization/nvp.hpp>
23 #include <boost/serialization/collection_size_type.hpp>
24 #include <boost/serialization/item_version_type.hpp>
25 
26 namespace boost{
27 namespace serialization {
28 namespace stl {
29 
30 //////////////////////////////////////////////////////////////////////
31 // implementation of serialization for STL containers
32 //
33 template<class Archive, class Container, class InputFunction>
load_hash_collection(Archive & ar,Container & s)34 inline void load_hash_collection(Archive & ar, Container &s)
35 {
36     collection_size_type count;
37     collection_size_type bucket_count;
38     boost::serialization::item_version_type item_version(0);
39     boost::serialization::library_version_type library_version(
40         ar.get_library_version()
41     );
42     // retrieve number of elements
43     if(boost::serialization::library_version_type(6) != library_version){
44         ar >> BOOST_SERIALIZATION_NVP(count);
45         ar >> BOOST_SERIALIZATION_NVP(bucket_count);
46     }
47     else{
48         // note: fixup for error in version 6.  collection size was
49         // changed to size_t BUT for hashed collections it was implemented
50         // as an unsigned int.  This should be a problem only on win64 machines
51         // but I'll leave it for everyone just in case.
52         unsigned int c;
53         unsigned int bc;
54         ar >> BOOST_SERIALIZATION_NVP(c);
55         count = c;
56         ar >> BOOST_SERIALIZATION_NVP(bc);
57         bucket_count = bc;
58     }
59     if(boost::serialization::library_version_type(3) < library_version){
60         ar >> BOOST_SERIALIZATION_NVP(item_version);
61     }
62     s.clear();
63     #if ! defined(__MWERKS__)
64     s.resize(bucket_count);
65     #endif
66     InputFunction ifunc;
67     while(count-- > 0){
68         ifunc(ar, s, item_version);
69     }
70 }
71 
72 } // namespace stl
73 } // namespace serialization
74 } // namespace boost
75 
76 #endif //BOOST_SERIALIZATION_HASH_COLLECTIONS_LOAD_IMP_HPP
77