Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:31:00

0001 #ifndef  BOOST_SERIALIZATION_HASH_SET_HPP
0002 #define BOOST_SERIALIZATION_HASH_SET_HPP
0003 
0004 // MS compatible compilers support #pragma once
0005 #if defined(_MSC_VER)
0006 # pragma once
0007 #endif
0008 
0009 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
0010 // hash_set.hpp: serialization for stl hash_set templates
0011 
0012 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
0013 // Use, modification and distribution is subject to the Boost Software
0014 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0015 // http://www.boost.org/LICENSE_1_0.txt)
0016 
0017 //  See http://www.boost.org for updates, documentation, and revision history.
0018 
0019 #include <boost/config.hpp>
0020 #ifdef BOOST_HAS_HASH
0021 #include BOOST_HASH_SET_HEADER
0022 
0023 #include <boost/serialization/hash_collections_save_imp.hpp>
0024 #include <boost/serialization/hash_collections_load_imp.hpp>
0025 #include <boost/serialization/split_free.hpp>
0026 #include <boost/serialization/detail/stack_constructor.hpp>
0027 #include <boost/move/utility_core.hpp>
0028 
0029 namespace boost {
0030 namespace serialization {
0031 
0032 namespace stl {
0033 
0034 // hash_set input
0035 template<class Archive, class Container>
0036 struct archive_input_hash_set
0037 {
0038     inline void operator()(
0039         Archive &ar,
0040         Container &s,
0041         const unsigned int v
0042     ){
0043         typedef typename Container::value_type type;
0044         detail::stack_construct<Archive, type> t(ar, v);
0045         // borland fails silently w/o full namespace
0046         ar >> boost::serialization::make_nvp("item", t.reference());
0047         std::pair<typename Container::const_iterator, bool> result =
0048             s.insert(boost::move(t.reference()));
0049         if(result.second)
0050             ar.reset_object_address(& (* result.first), & t.reference());
0051     }
0052 };
0053 
0054 // hash_multiset input
0055 template<class Archive, class Container>
0056 struct archive_input_hash_multiset
0057 {
0058     inline void operator()(
0059         Archive &ar,
0060         Container &s,
0061         const unsigned int v
0062     ){
0063         typedef typename Container::value_type type;
0064         detail::stack_construct<Archive, type> t(ar, v);
0065         // borland fails silently w/o full namespace
0066         ar >> boost::serialization::make_nvp("item", t.reference());
0067         typename Container::const_iterator result
0068             = s.insert(boost::move(t.reference()));
0069         ar.reset_object_address(& (* result), & t.reference());
0070     }
0071 };
0072 
0073 } // stl
0074 
0075 template<
0076     class Archive,
0077     class Key,
0078     class HashFcn,
0079     class EqualKey,
0080     class Allocator
0081 >
0082 inline void save(
0083     Archive & ar,
0084     const BOOST_STD_EXTENSION_NAMESPACE::hash_set<
0085         Key, HashFcn, EqualKey, Allocator
0086     > &t,
0087     const unsigned int file_version
0088 ){
0089     boost::serialization::stl::save_hash_collection<
0090         Archive,
0091         BOOST_STD_EXTENSION_NAMESPACE::hash_set<
0092             Key, HashFcn, EqualKey, Allocator
0093         >
0094     >(ar, t);
0095 }
0096 
0097 template<
0098     class Archive,
0099     class Key,
0100     class HashFcn,
0101     class EqualKey,
0102     class Allocator
0103 >
0104 inline void load(
0105     Archive & ar,
0106     BOOST_STD_EXTENSION_NAMESPACE::hash_set<
0107         Key, HashFcn, EqualKey, Allocator
0108     > &t,
0109     const unsigned int file_version
0110 ){
0111     boost::serialization::stl::load_hash_collection<
0112         Archive,
0113         BOOST_STD_EXTENSION_NAMESPACE::hash_set<
0114             Key, HashFcn, EqualKey, Allocator
0115         >,
0116         boost::serialization::stl::archive_input_hash_set<
0117             Archive,
0118             BOOST_STD_EXTENSION_NAMESPACE::hash_set<
0119                 Key, HashFcn, EqualKey, Allocator
0120             >
0121         >
0122     >(ar, t);
0123 }
0124 
0125 // split non-intrusive serialization function member into separate
0126 // non intrusive save/load member functions
0127 template<
0128     class Archive,
0129     class Key,
0130     class HashFcn,
0131     class EqualKey,
0132     class Allocator
0133 >
0134 inline void serialize(
0135     Archive & ar,
0136     BOOST_STD_EXTENSION_NAMESPACE::hash_set<
0137         Key, HashFcn, EqualKey, Allocator
0138     > &t,
0139     const unsigned int file_version
0140 ){
0141     boost::serialization::split_free(ar, t, file_version);
0142 }
0143 
0144 // hash_multiset
0145 template<
0146     class Archive,
0147     class Key,
0148     class HashFcn,
0149     class EqualKey,
0150     class Allocator
0151 >
0152 inline void save(
0153     Archive & ar,
0154     const BOOST_STD_EXTENSION_NAMESPACE::hash_multiset<
0155         Key, HashFcn, EqualKey, Allocator
0156     > &t,
0157     const unsigned int file_version
0158 ){
0159     boost::serialization::stl::save_hash_collection<
0160         Archive,
0161         BOOST_STD_EXTENSION_NAMESPACE::hash_multiset<
0162             Key, HashFcn, EqualKey, Allocator
0163         >
0164     >(ar, t);
0165 }
0166 
0167 template<
0168     class Archive,
0169     class Key,
0170     class HashFcn,
0171     class EqualKey,
0172     class Allocator
0173 >
0174 inline void load(
0175     Archive & ar,
0176     BOOST_STD_EXTENSION_NAMESPACE::hash_multiset<
0177         Key, HashFcn, EqualKey, Allocator
0178     > &t,
0179     const unsigned int file_version
0180 ){
0181     boost::serialization::stl::load_hash_collection<
0182         Archive,
0183         BOOST_STD_EXTENSION_NAMESPACE::hash_multiset<
0184             Key, HashFcn, EqualKey, Allocator
0185         >,
0186         boost::serialization::stl::archive_input_hash_multiset<
0187             Archive,
0188             BOOST_STD_EXTENSION_NAMESPACE::hash_multiset<
0189                 Key, HashFcn, EqualKey, Allocator
0190             >
0191         >
0192     >(ar, t);
0193 }
0194 
0195 // split non-intrusive serialization function member into separate
0196 // non intrusive save/load member functions
0197 template<
0198     class Archive,
0199     class Key,
0200     class HashFcn,
0201     class EqualKey,
0202     class Allocator
0203 >
0204 inline void serialize(
0205     Archive & ar,
0206     BOOST_STD_EXTENSION_NAMESPACE::hash_multiset<
0207         Key, HashFcn, EqualKey, Allocator
0208     > & t,
0209     const unsigned int file_version
0210 ){
0211     boost::serialization::split_free(ar, t, file_version);
0212 }
0213 
0214 } // namespace serialization
0215 } // namespace boost
0216 
0217 #include <boost/serialization/collection_traits.hpp>
0218 
0219 BOOST_SERIALIZATION_COLLECTION_TRAITS(BOOST_STD_EXTENSION_NAMESPACE::hash_set)
0220 BOOST_SERIALIZATION_COLLECTION_TRAITS(BOOST_STD_EXTENSION_NAMESPACE::hash_multiset)
0221 
0222 #endif // BOOST_HAS_HASH
0223 #endif // BOOST_SERIALIZATION_HASH_SET_HPP