Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/serialization/vector.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 #ifndef  BOOST_SERIALIZATION_VECTOR_HPP
0002 #define BOOST_SERIALIZATION_VECTOR_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 // vector.hpp: serialization for stl vector templates
0011 
0012 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
0013 // fast array serialization (C) Copyright 2005 Matthias Troyer
0014 // Use, modification and distribution is subject to the Boost Software
0015 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0016 // http://www.boost.org/LICENSE_1_0.txt)
0017 
0018 //  See http://www.boost.org for updates, documentation, and revision history.
0019 
0020 #include <vector>
0021 
0022 #include <boost/config.hpp>
0023 #include <boost/detail/workaround.hpp>
0024 
0025 #include <boost/serialization/access.hpp>
0026 #include <boost/serialization/nvp.hpp>
0027 #include <boost/serialization/collection_size_type.hpp>
0028 #include <boost/serialization/library_version_type.hpp>
0029 #include <boost/serialization/item_version_type.hpp>
0030 #include <boost/serialization/library_version_type.hpp>
0031 
0032 #include <boost/serialization/collections_save_imp.hpp>
0033 #include <boost/serialization/collections_load_imp.hpp>
0034 #include <boost/serialization/split_free.hpp>
0035 #include <boost/serialization/array_wrapper.hpp>
0036 #include <boost/mpl/bool_fwd.hpp>
0037 #include <boost/mpl/if.hpp>
0038 
0039 // default is being compatible with version 1.34.1 files, not 1.35 files
0040 #ifndef BOOST_SERIALIZATION_VECTOR_VERSIONED
0041 #define BOOST_SERIALIZATION_VECTOR_VERSIONED(V) (V==4 || V==5)
0042 #endif
0043 
0044 // function specializations must be defined in the appropriate
0045 // namespace - boost::serialization
0046 #if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
0047 #define STD _STLP_STD
0048 #else
0049 #define STD std
0050 #endif
0051 
0052 namespace boost {
0053 namespace serialization {
0054 
0055 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
0056 // vector< T >
0057 
0058 // the default versions
0059 
0060 template<class Archive, class U, class Allocator>
0061 inline void save(
0062     Archive & ar,
0063     const std::vector<U, Allocator> &t,
0064     const unsigned int /* file_version */,
0065     mpl::false_
0066 ){
0067     boost::serialization::stl::save_collection<Archive, STD::vector<U, Allocator> >(
0068         ar, t
0069     );
0070 }
0071 
0072 template<class Archive, class U, class Allocator>
0073 inline void load(
0074     Archive & ar,
0075     std::vector<U, Allocator> &t,
0076     const unsigned int /* file_version */,
0077     mpl::false_
0078 ){
0079     const boost::serialization::library_version_type library_version(
0080         ar.get_library_version()
0081     );
0082     // retrieve number of elements
0083     item_version_type item_version(0);
0084     collection_size_type count;
0085     ar >> BOOST_SERIALIZATION_NVP(count);
0086     if(boost::serialization::library_version_type(3) < library_version){
0087         ar >> BOOST_SERIALIZATION_NVP(item_version);
0088     }
0089     t.reserve(count);
0090     stl::collection_load_impl(ar, t, count, item_version);
0091 }
0092 
0093 // the optimized versions
0094 
0095 template<class Archive, class U, class Allocator>
0096 inline void save(
0097     Archive & ar,
0098     const std::vector<U, Allocator> &t,
0099     const unsigned int /* file_version */,
0100     mpl::true_
0101 ){
0102     const collection_size_type count(t.size());
0103     ar << BOOST_SERIALIZATION_NVP(count);
0104     if (!t.empty())
0105         // explicit template arguments to pass intel C++ compiler
0106         ar << serialization::make_array<const U, collection_size_type>(
0107             static_cast<const U *>(&t[0]),
0108             count
0109         );
0110 }
0111 
0112 template<class Archive, class U, class Allocator>
0113 inline void load(
0114     Archive & ar,
0115     std::vector<U, Allocator> &t,
0116     const unsigned int /* file_version */,
0117     mpl::true_
0118 ){
0119     collection_size_type count(t.size());
0120     ar >> BOOST_SERIALIZATION_NVP(count);
0121     t.resize(count);
0122     unsigned int item_version=0;
0123     if(BOOST_SERIALIZATION_VECTOR_VERSIONED(ar.get_library_version())) {
0124         ar >> BOOST_SERIALIZATION_NVP(item_version);
0125     }
0126     if (!t.empty())
0127         // explicit template arguments to pass intel C++ compiler
0128         ar >> serialization::make_array<U, collection_size_type>(
0129             static_cast<U *>(&t[0]),
0130             count
0131         );
0132   }
0133 
0134 // dispatch to either default or optimized versions
0135 
0136 template<class Archive, class U, class Allocator>
0137 inline void save(
0138     Archive & ar,
0139     const std::vector<U, Allocator> &t,
0140     const unsigned int file_version
0141 ){
0142     typedef typename
0143     boost::serialization::use_array_optimization<Archive>::template apply<
0144         typename remove_const<U>::type
0145     >::type use_optimized;
0146     save(ar,t,file_version, use_optimized());
0147 }
0148 
0149 template<class Archive, class U, class Allocator>
0150 inline void load(
0151     Archive & ar,
0152     std::vector<U, Allocator> &t,
0153     const unsigned int file_version
0154 ){
0155 #ifdef BOOST_SERIALIZATION_VECTOR_135_HPP
0156     if (ar.get_library_version()==boost::serialization::library_version_type(5))
0157     {
0158       load(ar,t,file_version, boost::is_arithmetic<U>());
0159       return;
0160     }
0161 #endif
0162     typedef typename
0163     boost::serialization::use_array_optimization<Archive>::template apply<
0164         typename remove_const<U>::type
0165     >::type use_optimized;
0166     load(ar,t,file_version, use_optimized());
0167 }
0168 
0169 // split non-intrusive serialization function member into separate
0170 // non intrusive save/load member functions
0171 template<class Archive, class U, class Allocator>
0172 inline void serialize(
0173     Archive & ar,
0174     std::vector<U, Allocator> & t,
0175     const unsigned int file_version
0176 ){
0177     boost::serialization::split_free(ar, t, file_version);
0178 }
0179 
0180 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
0181 // vector<bool>
0182 template<class Archive, class Allocator>
0183 inline void save(
0184     Archive & ar,
0185     const std::vector<bool, Allocator> &t,
0186     const unsigned int /* file_version */
0187 ){
0188     // record number of elements
0189     collection_size_type count (t.size());
0190     ar << BOOST_SERIALIZATION_NVP(count);
0191     std::vector<bool>::const_iterator it = t.begin();
0192     while(count-- > 0){
0193         bool tb = *it++;
0194         ar << boost::serialization::make_nvp("item", tb);
0195     }
0196 }
0197 
0198 template<class Archive, class Allocator>
0199 inline void load(
0200     Archive & ar,
0201     std::vector<bool, Allocator> &t,
0202     const unsigned int /* file_version */
0203 ){
0204     // retrieve number of elements
0205     collection_size_type count;
0206     ar >> BOOST_SERIALIZATION_NVP(count);
0207     t.resize(count);
0208     for(collection_size_type i = collection_size_type(0); i < count; ++i){
0209         bool b;
0210         ar >> boost::serialization::make_nvp("item", b);
0211         t[i] = b;
0212     }
0213 }
0214 
0215 // split non-intrusive serialization function member into separate
0216 // non intrusive save/load member functions
0217 template<class Archive, class Allocator>
0218 inline void serialize(
0219     Archive & ar,
0220     std::vector<bool, Allocator> & t,
0221     const unsigned int file_version
0222 ){
0223     boost::serialization::split_free(ar, t, file_version);
0224 }
0225 
0226 } // serialization
0227 } // namespace boost
0228 
0229 #include <boost/serialization/collection_traits.hpp>
0230 
0231 BOOST_SERIALIZATION_COLLECTION_TRAITS(std::vector)
0232 #undef STD
0233 
0234 #endif // BOOST_SERIALIZATION_VECTOR_HPP