Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:30:59

0001 #ifndef BOOST_SERIALIZATION_ACCESS_HPP
0002 #define BOOST_SERIALIZATION_ACCESS_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 // access.hpp: interface for serialization system.
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 
0021 namespace boost {
0022 
0023 namespace archive {
0024 namespace detail {
0025     template<class Archive, class T>
0026     class iserializer;
0027     template<class Archive, class T>
0028     class oserializer;
0029 } // namespace detail
0030 } // namespace archive
0031 
0032 namespace serialization {
0033 
0034 // forward declarations
0035 template<class Archive, class T>
0036 inline void serialize_adl(Archive &, T &, const unsigned int);
0037 namespace detail {
0038     template<class Archive, class T>
0039     struct member_saver;
0040     template<class Archive, class T>
0041     struct member_loader;
0042 } // namespace detail
0043 
0044 // use an "accessor class so that we can use:
0045 // "friend class boost::serialization::access;"
0046 // in any serialized class to permit clean, safe access to private class members
0047 // by the serialization system
0048 
0049 class access {
0050 public:
0051     // grant access to "real" serialization defaults
0052 #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
0053 public:
0054 #else
0055     template<class Archive, class T>
0056     friend struct detail::member_saver;
0057     template<class Archive, class T>
0058     friend struct detail::member_loader;
0059     template<class Archive, class T>
0060     friend class archive::detail::iserializer;
0061     template<class Archive, class T>
0062     friend class archive::detail::oserializer;
0063     template<class Archive, class T>
0064     friend inline void serialize(
0065         Archive & ar,
0066         T & t,
0067         const unsigned int file_version
0068     );
0069     template<class Archive, class T>
0070     friend inline void save_construct_data(
0071         Archive & ar,
0072         const T * t,
0073         const unsigned int file_version
0074     );
0075     template<class Archive, class T>
0076     friend inline void load_construct_data(
0077         Archive & ar,
0078         T * t,
0079         const unsigned int file_version
0080     );
0081 #endif
0082 
0083     // pass calls to users's class implementation
0084     template<class Archive, class T>
0085     static void member_save(
0086         Archive & ar,
0087         //const T & t,
0088         T & t,
0089         const unsigned int file_version
0090     ){
0091         t.save(ar, file_version);
0092     }
0093     template<class Archive, class T>
0094     static void member_load(
0095         Archive & ar,
0096         T & t,
0097         const unsigned int file_version
0098     ){
0099         t.load(ar, file_version);
0100     }
0101     template<class Archive, class T>
0102     static void serialize(
0103         Archive & ar,
0104         T & t,
0105         const unsigned int file_version
0106     ){
0107         // note: if you get a compile time error here with a
0108         // message something like:
0109         // cannot convert parameter 1 from <file type 1> to <file type 2 &>
0110         // a likely possible cause is that the class T contains a
0111         // serialize function - but that serialize function isn't
0112         // a template and corresponds to a file type different than
0113         // the class Archive.  To resolve this, don't include an
0114         // archive type other than that for which the serialization
0115         // function is defined!!!
0116         t.serialize(ar, file_version);
0117     }
0118     template<class T>
0119     static void destroy( const T * t) // const appropriate here?
0120     {
0121         // the const business is an MSVC 6.0 hack that should be
0122         // benign on everything else
0123         delete const_cast<T *>(t);
0124     }
0125     template<class T>
0126     static void construct(T * t){
0127         // default is inplace invocation of default constructor
0128         // Note the :: before the placement new. Required if the
0129         // class doesn't have a class-specific placement new defined.
0130         ::new(t)T;
0131     }
0132     template<class T, class U>
0133     static T & cast_reference(U & u){
0134         return static_cast<T &>(u);
0135     }
0136     template<class T, class U>
0137     static T * cast_pointer(U * u){
0138         return static_cast<T *>(u);
0139     }
0140 };
0141 
0142 } // namespace serialization
0143 } // namespace boost
0144 
0145 #endif // BOOST_SERIALIZATION_ACCESS_HPP