os/ossrv/ossrv_pub/boost_apis/boost/serialization/split_free.hpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
#ifndef BOOST_SERIALIZATION_SPLIT_FREE_HPP
sl@0
     2
#define BOOST_SERIALIZATION_SPLIT_FREE_HPP
sl@0
     3
sl@0
     4
// MS compatible compilers support #pragma once
sl@0
     5
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
sl@0
     6
# pragma once
sl@0
     7
#endif
sl@0
     8
sl@0
     9
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
sl@0
    10
// split_free.hpp:
sl@0
    11
sl@0
    12
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . 
sl@0
    13
// Use, modification and distribution is subject to the Boost Software
sl@0
    14
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
sl@0
    15
// http://www.boost.org/LICENSE_1_0.txt)
sl@0
    16
sl@0
    17
//  See http://www.boost.org for updates, documentation, and revision history.
sl@0
    18
sl@0
    19
#include <boost/config.hpp>
sl@0
    20
#include <boost/mpl/eval_if.hpp>
sl@0
    21
#include <boost/mpl/identity.hpp>
sl@0
    22
#include <boost/serialization/serialization.hpp>
sl@0
    23
sl@0
    24
namespace boost {
sl@0
    25
namespace archive {
sl@0
    26
    namespace detail {
sl@0
    27
        template<class Archive> class interface_oarchive;
sl@0
    28
        template<class Archive> class interface_iarchive;
sl@0
    29
    } // namespace detail
sl@0
    30
} // namespace archive
sl@0
    31
sl@0
    32
namespace serialization {
sl@0
    33
sl@0
    34
//namespace detail {
sl@0
    35
template<class Archive, class T>
sl@0
    36
struct free_saver {
sl@0
    37
    static void invoke(
sl@0
    38
        Archive & ar, 
sl@0
    39
        const  T & t, 
sl@0
    40
        const unsigned int file_version
sl@0
    41
    ){
sl@0
    42
        // use function overload (version_type) to workaround
sl@0
    43
        // two-phase lookup issue
sl@0
    44
        const version_type v(file_version);
sl@0
    45
        save(ar, t, v);
sl@0
    46
    }
sl@0
    47
};
sl@0
    48
template<class Archive, class T>
sl@0
    49
struct free_loader {
sl@0
    50
    static void invoke(
sl@0
    51
        Archive & ar, 
sl@0
    52
        T & t, 
sl@0
    53
        const unsigned int file_version
sl@0
    54
    ){
sl@0
    55
        // use function overload (version_type) to workaround
sl@0
    56
        // two-phase lookup issue
sl@0
    57
        const version_type v(file_version);
sl@0
    58
        load(ar, t, v);
sl@0
    59
    }
sl@0
    60
};
sl@0
    61
//} // namespace detail
sl@0
    62
sl@0
    63
template<class Archive, class T>
sl@0
    64
inline void split_free(
sl@0
    65
    Archive & ar, 
sl@0
    66
    T & t, 
sl@0
    67
    const unsigned int file_version
sl@0
    68
){
sl@0
    69
    typedef BOOST_DEDUCED_TYPENAME mpl::eval_if<
sl@0
    70
        BOOST_DEDUCED_TYPENAME Archive::is_saving,
sl@0
    71
        mpl::identity</* detail:: */ free_saver<Archive, T> >, 
sl@0
    72
        mpl::identity</* detail:: */ free_loader<Archive, T> >
sl@0
    73
    >::type typex;
sl@0
    74
    typex::invoke(ar, t, file_version);
sl@0
    75
}
sl@0
    76
sl@0
    77
} // namespace serialization
sl@0
    78
} // namespace boost
sl@0
    79
sl@0
    80
#define BOOST_SERIALIZATION_SPLIT_FREE(T)       \
sl@0
    81
namespace boost { namespace serialization {     \
sl@0
    82
template<class Archive>                         \
sl@0
    83
inline void serialize(                          \
sl@0
    84
        Archive & ar,                               \
sl@0
    85
        T & t,                                      \
sl@0
    86
        const unsigned int file_version             \
sl@0
    87
){                                              \
sl@0
    88
        split_free(ar, t, file_version);            \
sl@0
    89
}                                               \
sl@0
    90
}}
sl@0
    91
/**/
sl@0
    92
sl@0
    93
#endif // BOOST_SERIALIZATION_SPLIT_FREE_HPP