source: NonGTP/Boost/boost/serialization/level.hpp @ 857

Revision 857, 3.9 KB checked in by igarcia, 19 years ago (diff)
RevLine 
[857]1#ifndef BOOST_SERIALIZATION_LEVEL_HPP
2#define BOOST_SERIALIZATION_LEVEL_HPP
3
4// MS compatible compilers support #pragma once
5#if defined(_MSC_VER) && (_MSC_VER >= 1020)
6# pragma once
7#endif
8
9/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10// level.hpp:
11
12// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
13// Use, modification and distribution is subject to the Boost Software
14// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
15// http://www.boost.org/LICENSE_1_0.txt)
16
17//  See http://www.boost.org for updates, documentation, and revision history.
18
19#include <boost/config.hpp>
20#include <boost/detail/workaround.hpp>
21
22#include <boost/type_traits/is_fundamental.hpp>
23#include <boost/type_traits/is_enum.hpp>
24#include <boost/type_traits/is_array.hpp>
25#include <boost/type_traits/is_class.hpp>
26#include <boost/type_traits/is_base_and_derived.hpp>
27
28#include <boost/mpl/eval_if.hpp>
29#include <boost/mpl/int.hpp>
30#include <boost/mpl/integral_c.hpp>
31#include <boost/mpl/integral_c_tag.hpp>
32
33#include <boost/serialization/level_enum.hpp>
34#include <boost/serialization/traits.hpp>
35
36namespace boost {
37namespace serialization {
38
39// default serialization implementation level
40template<class T>
41struct implementation_level {
42    template<class U>
43    struct traits_class_level {
44        typedef  BOOST_DEDUCED_TYPENAME U::level type;
45    };
46
47    typedef mpl::integral_c_tag tag;
48    typedef
49        BOOST_DEDUCED_TYPENAME mpl::eval_if<
50            is_base_and_derived<basic_traits, T>,
51            traits_class_level<T>,
52        //else
53        BOOST_DEDUCED_TYPENAME mpl::eval_if<
54            is_fundamental<T>,
55            mpl::int_<primitive_type>,
56        //else
57        BOOST_DEDUCED_TYPENAME mpl::eval_if<
58            is_class<T>,
59            mpl::int_<object_class_info>,
60        //else
61        BOOST_DEDUCED_TYPENAME mpl::eval_if<
62            is_array<T>,
63            #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x560))
64                mpl::int_<not_serializable>,
65            #else
66                mpl::int_<object_serializable>,
67            #endif
68        //else
69        BOOST_DEDUCED_TYPENAME mpl::eval_if<
70            is_enum<T>,
71            //#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x560))
72            //    mpl::int_<not_serializable>,
73            //#else
74                mpl::int_<primitive_type>,
75            //#endif
76        //else
77            mpl::int_<not_serializable>
78        >
79        >
80        >
81        >
82        >::type type;
83        // vc 7.1 doesn't like enums here
84    BOOST_STATIC_CONSTANT(int, value = implementation_level::type::value);
85};
86
87
88template<class T, enum level_type L>
89inline bool operator>=(implementation_level<T> t, enum level_type l)
90{
91    return t.value >= (int)l;
92}
93
94} // namespace serialization
95} // namespace boost
96
97// specify the level of serialization implementation for the class
98// require that class info saved when versioning is used
99#define BOOST_CLASS_IMPLEMENTATION(T, E)                 \
100    namespace boost {                                    \
101    namespace serialization {                            \
102    template <>                                          \
103    struct implementation_level< T >                     \
104    {                                                    \
105        typedef mpl::integral_c_tag tag;                 \
106        typedef mpl::int_< E > type;                     \
107        BOOST_STATIC_CONSTANT(                           \
108            int,                                         \
109            value = implementation_level::type::value    \
110        );                                               \
111    };                                                   \
112    }                                                    \
113    }
114    /**/
115
116#endif // BOOST_SERIALIZATION_LEVEL_HPP
Note: See TracBrowser for help on using the repository browser.