Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / archive / detail / check.hpp @ 2486

History | View | Annotate | Download (5.3 kB)

1 2486 sjacqu01
#ifndef BOOST_ARCHIVE_DETAIL_CHECK_HPP
2 2486 sjacqu01
#define BOOST_ARCHIVE_DETAIL_CHECK_HPP
3 2486 sjacqu01
4 2486 sjacqu01
// MS compatible compilers support #pragma once
5 2486 sjacqu01
#if defined(_MSC_VER)
6 2486 sjacqu01
# pragma once
7 2486 sjacqu01
#pragma inline_depth(511)
8 2486 sjacqu01
#pragma inline_recursion(on)
9 2486 sjacqu01
#endif
10 2486 sjacqu01
11 2486 sjacqu01
#if defined(__MWERKS__)
12 2486 sjacqu01
#pragma inline_depth(511)
13 2486 sjacqu01
#endif
14 2486 sjacqu01
15 2486 sjacqu01
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
16 2486 sjacqu01
// check.hpp: interface for serialization system.
17 2486 sjacqu01
18 2486 sjacqu01
// (C) Copyright 2009 Robert Ramey - http://www.rrsd.com .
19 2486 sjacqu01
// Use, modification and distribution is subject to the Boost Software
20 2486 sjacqu01
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
21 2486 sjacqu01
// http://www.boost.org/LICENSE_1_0.txt)
22 2486 sjacqu01
23 2486 sjacqu01
//  See http://www.boost.org for updates, documentation, and revision history.
24 2486 sjacqu01
25 2486 sjacqu01
#include <boost/config.hpp>
26 2486 sjacqu01
27 2486 sjacqu01
#include <boost/static_assert.hpp>
28 2486 sjacqu01
#include <boost/type_traits/is_const.hpp>
29 2486 sjacqu01
30 2486 sjacqu01
#include <boost/mpl/eval_if.hpp>
31 2486 sjacqu01
#include <boost/mpl/or.hpp>
32 2486 sjacqu01
#include <boost/mpl/equal_to.hpp>
33 2486 sjacqu01
#include <boost/mpl/int.hpp>
34 2486 sjacqu01
#include <boost/mpl/not.hpp>
35 2486 sjacqu01
#include <boost/mpl/greater.hpp>
36 2486 sjacqu01
#include <boost/mpl/assert.hpp>
37 2486 sjacqu01
38 2486 sjacqu01
#include <boost/serialization/static_warning.hpp>
39 2486 sjacqu01
#include <boost/serialization/version.hpp>
40 2486 sjacqu01
#include <boost/serialization/level.hpp>
41 2486 sjacqu01
#include <boost/serialization/tracking.hpp>
42 2486 sjacqu01
#include <boost/serialization/wrapper.hpp>
43 2486 sjacqu01
44 2486 sjacqu01
namespace boost {
45 2486 sjacqu01
namespace archive {
46 2486 sjacqu01
namespace detail {
47 2486 sjacqu01
48 2486 sjacqu01
// checks for objects
49 2486 sjacqu01
50 2486 sjacqu01
template<class T>
51 2486 sjacqu01
inline void check_object_level(){
52 2486 sjacqu01
    typedef
53 2486 sjacqu01
        typename mpl::greater_equal<
54 2486 sjacqu01
            serialization::implementation_level< T >,
55 2486 sjacqu01
            mpl::int_<serialization::primitive_type>
56 2486 sjacqu01
        >::type typex;
57 2486 sjacqu01
58 2486 sjacqu01
    // trap attempts to serialize objects marked
59 2486 sjacqu01
    // not_serializable
60 2486 sjacqu01
    BOOST_STATIC_ASSERT(typex::value);
61 2486 sjacqu01
}
62 2486 sjacqu01
63 2486 sjacqu01
template<class T>
64 2486 sjacqu01
inline void check_object_versioning(){
65 2486 sjacqu01
    typedef
66 2486 sjacqu01
        typename mpl::or_<
67 2486 sjacqu01
            typename mpl::greater<
68 2486 sjacqu01
                serialization::implementation_level< T >,
69 2486 sjacqu01
                mpl::int_<serialization::object_serializable>
70 2486 sjacqu01
            >,
71 2486 sjacqu01
            typename mpl::equal_to<
72 2486 sjacqu01
                serialization::version< T >,
73 2486 sjacqu01
                mpl::int_<0>
74 2486 sjacqu01
            >
75 2486 sjacqu01
        > typex;
76 2486 sjacqu01
    // trap attempts to serialize with objects that don't
77 2486 sjacqu01
    // save class information in the archive with versioning.
78 2486 sjacqu01
    BOOST_STATIC_ASSERT(typex::value);
79 2486 sjacqu01
}
80 2486 sjacqu01
81 2486 sjacqu01
template<class T>
82 2486 sjacqu01
inline void check_object_tracking(){
83 2486 sjacqu01
    // presume it has already been determined that
84 2486 sjacqu01
    // T is not a const
85 2486 sjacqu01
    BOOST_STATIC_ASSERT(! boost::is_const< T >::value);
86 2486 sjacqu01
    typedef typename mpl::equal_to<
87 2486 sjacqu01
        serialization::tracking_level< T >,
88 2486 sjacqu01
        mpl::int_<serialization::track_never>
89 2486 sjacqu01
    >::type typex;
90 2486 sjacqu01
    // saving an non-const object of a type not marked "track_never)
91 2486 sjacqu01
92 2486 sjacqu01
    // may be an indicator of an error usage of the
93 2486 sjacqu01
    // serialization library and should be double checked.
94 2486 sjacqu01
    // See documentation on object tracking.  Also, see the
95 2486 sjacqu01
    // "rationale" section of the documenation
96 2486 sjacqu01
    // for motivation for this checking.
97 2486 sjacqu01
98 2486 sjacqu01
    BOOST_STATIC_WARNING(typex::value);
99 2486 sjacqu01
}
100 2486 sjacqu01
101 2486 sjacqu01
// checks for pointers
102 2486 sjacqu01
103 2486 sjacqu01
template<class T>
104 2486 sjacqu01
inline void check_pointer_level(){
105 2486 sjacqu01
    // we should only invoke this once we KNOW that T
106 2486 sjacqu01
    // has been used as a pointer!!
107 2486 sjacqu01
    typedef
108 2486 sjacqu01
        typename mpl::or_<
109 2486 sjacqu01
            typename mpl::greater<
110 2486 sjacqu01
                serialization::implementation_level< T >,
111 2486 sjacqu01
                mpl::int_<serialization::object_serializable>
112 2486 sjacqu01
            >,
113 2486 sjacqu01
            typename mpl::not_<
114 2486 sjacqu01
                typename mpl::equal_to<
115 2486 sjacqu01
                    serialization::tracking_level< T >,
116 2486 sjacqu01
                    mpl::int_<serialization::track_selectively>
117 2486 sjacqu01
                >
118 2486 sjacqu01
            >
119 2486 sjacqu01
        > typex;
120 2486 sjacqu01
    // Address the following when serializing to a pointer:
121 2486 sjacqu01
122 2486 sjacqu01
    // a) This type doesn't save class information in the
123 2486 sjacqu01
    // archive. That is, the serialization trait implementation
124 2486 sjacqu01
    // level <= object_serializable.
125 2486 sjacqu01
    // b) Tracking for this type is set to "track selectively"
126 2486 sjacqu01
127 2486 sjacqu01
    // in this case, indication that an object is tracked is
128 2486 sjacqu01
    // not stored in the archive itself - see level == object_serializable
129 2486 sjacqu01
    // but rather the existence of the operation ar >> T * is used to
130 2486 sjacqu01
    // infer that an object of this type should be tracked.  So, if
131 2486 sjacqu01
    // you save via a pointer but don't load via a pointer the operation
132 2486 sjacqu01
    // will fail on load without given any valid reason for the failure.
133 2486 sjacqu01
134 2486 sjacqu01
    // So if your program traps here, consider changing the
135 2486 sjacqu01
    // tracking or implementation level traits - or not
136 2486 sjacqu01
    // serializing via a pointer.
137 2486 sjacqu01
    BOOST_STATIC_WARNING(typex::value);
138 2486 sjacqu01
}
139 2486 sjacqu01
140 2486 sjacqu01
template<class T>
141 2486 sjacqu01
void inline check_pointer_tracking(){
142 2486 sjacqu01
    typedef typename mpl::greater<
143 2486 sjacqu01
        serialization::tracking_level< T >,
144 2486 sjacqu01
        mpl::int_<serialization::track_never>
145 2486 sjacqu01
    >::type typex;
146 2486 sjacqu01
    // serializing an object of a type marked "track_never" through a pointer
147 2486 sjacqu01
    // could result in creating more objects than were saved!
148 2486 sjacqu01
    BOOST_STATIC_WARNING(typex::value);
149 2486 sjacqu01
}
150 2486 sjacqu01
151 2486 sjacqu01
template<class T>
152 2486 sjacqu01
inline void check_const_loading(){
153 2486 sjacqu01
    typedef
154 2486 sjacqu01
        typename mpl::or_<
155 2486 sjacqu01
            typename boost::serialization::is_wrapper< T >,
156 2486 sjacqu01
            typename mpl::not_<
157 2486 sjacqu01
                typename boost::is_const< T >
158 2486 sjacqu01
            >
159 2486 sjacqu01
        >::type typex;
160 2486 sjacqu01
    // cannot load data into a "const" object unless it's a
161 2486 sjacqu01
    // wrapper around some other non-const object.
162 2486 sjacqu01
    BOOST_STATIC_ASSERT(typex::value);
163 2486 sjacqu01
}
164 2486 sjacqu01
165 2486 sjacqu01
} // detail
166 2486 sjacqu01
} // archive
167 2486 sjacqu01
} // boost
168 2486 sjacqu01
169 2486 sjacqu01
#endif // BOOST_ARCHIVE_DETAIL_CHECK_HPP