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