os/ossrv/ossrv_pub/boost_apis/boost/serialization/level.hpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
#ifndef BOOST_SERIALIZATION_LEVEL_HPP
sl@0
     2
#define BOOST_SERIALIZATION_LEVEL_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
// level.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/detail/workaround.hpp>
sl@0
    21
sl@0
    22
#include <boost/type_traits/is_fundamental.hpp>
sl@0
    23
#include <boost/type_traits/is_enum.hpp>
sl@0
    24
#include <boost/type_traits/is_array.hpp>
sl@0
    25
#include <boost/type_traits/is_class.hpp>
sl@0
    26
#include <boost/type_traits/is_base_and_derived.hpp>
sl@0
    27
sl@0
    28
#include <boost/mpl/eval_if.hpp>
sl@0
    29
#include <boost/mpl/int.hpp>
sl@0
    30
#include <boost/mpl/integral_c.hpp>
sl@0
    31
#include <boost/mpl/integral_c_tag.hpp>
sl@0
    32
#include <boost/mpl/aux_/nttp_decl.hpp>
sl@0
    33
sl@0
    34
#include <boost/serialization/level_enum.hpp>
sl@0
    35
sl@0
    36
namespace boost {
sl@0
    37
namespace serialization {
sl@0
    38
sl@0
    39
struct basic_traits;
sl@0
    40
sl@0
    41
// default serialization implementation level
sl@0
    42
template<class T>
sl@0
    43
struct implementation_level {
sl@0
    44
    template<class U>
sl@0
    45
    struct traits_class_level {
sl@0
    46
        typedef  BOOST_DEDUCED_TYPENAME U::level type;
sl@0
    47
    };
sl@0
    48
sl@0
    49
    typedef mpl::integral_c_tag tag;
sl@0
    50
    // note: at least one compiler complained w/o the full qualification
sl@0
    51
    // on basic traits below
sl@0
    52
    typedef
sl@0
    53
        BOOST_DEDUCED_TYPENAME mpl::eval_if<
sl@0
    54
            is_base_and_derived<boost::serialization::basic_traits, T>,
sl@0
    55
            traits_class_level<T>,
sl@0
    56
        //else
sl@0
    57
        BOOST_DEDUCED_TYPENAME mpl::eval_if<
sl@0
    58
            is_fundamental<T>,
sl@0
    59
            mpl::int_<primitive_type>,
sl@0
    60
        //else
sl@0
    61
        BOOST_DEDUCED_TYPENAME mpl::eval_if<
sl@0
    62
            is_class<T>,
sl@0
    63
            mpl::int_<object_class_info>,
sl@0
    64
        //else
sl@0
    65
        BOOST_DEDUCED_TYPENAME mpl::eval_if<
sl@0
    66
            is_array<T>,
sl@0
    67
            #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x560))
sl@0
    68
                mpl::int_<not_serializable>,
sl@0
    69
            #else
sl@0
    70
                mpl::int_<object_serializable>,
sl@0
    71
            #endif
sl@0
    72
        //else
sl@0
    73
        BOOST_DEDUCED_TYPENAME mpl::eval_if<
sl@0
    74
            is_enum<T>,
sl@0
    75
            //#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x560))
sl@0
    76
            //    mpl::int_<not_serializable>,
sl@0
    77
            //#else
sl@0
    78
                mpl::int_<primitive_type>,
sl@0
    79
            //#endif
sl@0
    80
        //else
sl@0
    81
            mpl::int_<not_serializable>
sl@0
    82
        >
sl@0
    83
        >
sl@0
    84
        >
sl@0
    85
        >
sl@0
    86
        >::type type;
sl@0
    87
        // vc 7.1 doesn't like enums here
sl@0
    88
    BOOST_STATIC_CONSTANT(int, value = implementation_level::type::value);
sl@0
    89
};
sl@0
    90
sl@0
    91
sl@0
    92
template<class T, BOOST_MPL_AUX_NTTP_DECL(int, L) >
sl@0
    93
inline bool operator>=(implementation_level<T> t, enum level_type l)
sl@0
    94
{
sl@0
    95
    return t.value >= (int)l;
sl@0
    96
}
sl@0
    97
sl@0
    98
} // namespace serialization
sl@0
    99
} // namespace boost
sl@0
   100
sl@0
   101
// specify the level of serialization implementation for the class
sl@0
   102
// require that class info saved when versioning is used
sl@0
   103
#define BOOST_CLASS_IMPLEMENTATION(T, E)                 \
sl@0
   104
    namespace boost {                                    \
sl@0
   105
    namespace serialization {                            \
sl@0
   106
    template <>                                          \
sl@0
   107
    struct implementation_level< T >                     \
sl@0
   108
    {                                                    \
sl@0
   109
        typedef mpl::integral_c_tag tag;                 \
sl@0
   110
        typedef mpl::int_< E > type;                     \
sl@0
   111
        BOOST_STATIC_CONSTANT(                           \
sl@0
   112
            int,                                         \
sl@0
   113
            value = implementation_level::type::value    \
sl@0
   114
        );                                               \
sl@0
   115
    };                                                   \
sl@0
   116
    }                                                    \
sl@0
   117
    }
sl@0
   118
    /**/
sl@0
   119
sl@0
   120
#endif // BOOST_SERIALIZATION_LEVEL_HPP