epoc32/include/stdapis/boost/serialization/access.hpp
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@2
     1
#ifndef BOOST_SERIALIZATION_ACCESS_HPP
williamr@2
     2
#define BOOST_SERIALIZATION_ACCESS_HPP
williamr@2
     3
williamr@2
     4
// MS compatible compilers support #pragma once
williamr@2
     5
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
williamr@2
     6
# pragma once
williamr@2
     7
#endif
williamr@2
     8
williamr@2
     9
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
williamr@2
    10
// access.hpp: interface for serialization system.
williamr@2
    11
williamr@2
    12
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . 
williamr@2
    13
// Use, modification and distribution is subject to the Boost Software
williamr@2
    14
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
williamr@2
    15
// http://www.boost.org/LICENSE_1_0.txt)
williamr@2
    16
williamr@2
    17
//  See http://www.boost.org for updates, documentation, and revision history.
williamr@2
    18
williamr@2
    19
#include <boost/config.hpp>
williamr@2
    20
williamr@2
    21
#include <boost/pfto.hpp>
williamr@2
    22
williamr@2
    23
namespace boost {
williamr@2
    24
williamr@2
    25
namespace archive {
williamr@2
    26
namespace detail {
williamr@2
    27
    template<class Archive, class T>
williamr@2
    28
    class iserializer;
williamr@2
    29
    template<class Archive, class T>
williamr@2
    30
    class oserializer;
williamr@2
    31
} // namespace detail
williamr@2
    32
} // namespace archive
williamr@2
    33
williamr@2
    34
namespace serialization {
williamr@2
    35
williamr@2
    36
// forward declarations
williamr@2
    37
template<class Archive, class T>
williamr@2
    38
inline void serialize_adl(Archive &, T &, const unsigned int);
williamr@2
    39
namespace detail {
williamr@2
    40
    template<class Archive, class T>
williamr@2
    41
    struct member_saver;
williamr@2
    42
    template<class Archive, class T>
williamr@2
    43
    struct member_loader;
williamr@2
    44
} // namespace detail
williamr@2
    45
williamr@2
    46
// use an "accessor class so that we can use: 
williamr@2
    47
// "friend class boost::serialization::access;" 
williamr@2
    48
// in any serialized class to permit clean, safe access to private class members
williamr@2
    49
// by the serialization system
williamr@2
    50
williamr@2
    51
class access {
williamr@2
    52
public:
williamr@2
    53
    // grant access to "real" serialization defaults
williamr@2
    54
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
williamr@2
    55
public:
williamr@2
    56
#else
williamr@2
    57
    template<class Archive, class T>
williamr@2
    58
    friend struct detail::member_saver;
williamr@2
    59
    template<class Archive, class T>
williamr@2
    60
    friend struct detail::member_loader;
williamr@2
    61
    template<class Archive, class T>
williamr@2
    62
    friend class archive::detail::iserializer;
williamr@2
    63
    template<class Archive, class T>
williamr@2
    64
    friend class archive::detail::oserializer;
williamr@2
    65
    template<class Archive, class T>
williamr@2
    66
    friend inline void serialize(
williamr@2
    67
        Archive & ar, 
williamr@2
    68
        T & t, 
williamr@2
    69
        const BOOST_PFTO unsigned int file_version
williamr@2
    70
    );
williamr@2
    71
    template<class Archive, class T>
williamr@2
    72
    friend inline void save_construct_data(
williamr@2
    73
        Archive & ar, 
williamr@2
    74
        const T * t, 
williamr@2
    75
        const BOOST_PFTO unsigned int file_version
williamr@2
    76
    );
williamr@2
    77
    template<class Archive, class T>
williamr@2
    78
    friend inline void load_construct_data(
williamr@2
    79
        Archive & ar, 
williamr@2
    80
        T * t, 
williamr@2
    81
        const BOOST_PFTO unsigned int file_version
williamr@2
    82
    );
williamr@2
    83
#endif
williamr@2
    84
williamr@2
    85
    // pass calls to users's class implementation
williamr@2
    86
    template<class Archive, class T>
williamr@2
    87
    static void member_save(
williamr@2
    88
        Archive & ar, 
williamr@2
    89
        //const T & t,
williamr@2
    90
        T & t,
williamr@2
    91
        const unsigned int file_version
williamr@2
    92
    ){
williamr@2
    93
        t.save(ar, file_version);
williamr@2
    94
    }
williamr@2
    95
    template<class Archive, class T>
williamr@2
    96
    static void member_load(
williamr@2
    97
        Archive & ar, 
williamr@2
    98
        T & t,
williamr@2
    99
        const unsigned int file_version
williamr@2
   100
    ){
williamr@2
   101
        t.load(ar, file_version);
williamr@2
   102
    }
williamr@2
   103
    template<class Archive, class T>
williamr@2
   104
    static void serialize(
williamr@2
   105
        Archive & ar, 
williamr@2
   106
        T & t, 
williamr@2
   107
        const unsigned int file_version
williamr@2
   108
    ){
williamr@2
   109
        t.serialize(ar, file_version);
williamr@2
   110
    }
williamr@2
   111
    template<class T>
williamr@2
   112
    static void destroy( const T * t) // const appropriate here?
williamr@2
   113
    {
williamr@2
   114
        // the const business is an MSVC 6.0 hack that should be
williamr@2
   115
        // benign on everything else
williamr@2
   116
        delete const_cast<T *>(t);
williamr@2
   117
    }
williamr@2
   118
    template<class Archive, class T>
williamr@2
   119
    static void construct(Archive & /* ar */, T * t){
williamr@2
   120
        // default is inplace invocation of default constructor
williamr@2
   121
        // Note the :: before the placement new. Required if the
williamr@2
   122
        // class doesn't have a class-specific placement new defined.
williamr@2
   123
        ::new(t)T;
williamr@2
   124
    }
williamr@2
   125
};
williamr@2
   126
williamr@2
   127
} // namespace serialization
williamr@2
   128
} // namespace boost
williamr@2
   129
williamr@2
   130
#endif // BOOST_SERIALIZATION_ACCESS_HPP