Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:27

0001 #ifndef BOOST_ARCHIVE_DETAIL_CHECK_HPP
0002 #define BOOST_ARCHIVE_DETAIL_CHECK_HPP
0003 
0004 // MS compatible compilers support #pragma once
0005 #if defined(_MSC_VER)
0006 # pragma once
0007 #if !defined(__clang__)
0008 #pragma inline_depth(255)
0009 #pragma inline_recursion(on)
0010 #endif
0011 #endif
0012 
0013 #if defined(__MWERKS__)
0014 #pragma inline_depth(255)
0015 #endif
0016 
0017 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
0018 // check.hpp: interface for serialization system.
0019 
0020 // (C) Copyright 2009 Robert Ramey - http://www.rrsd.com .
0021 // Use, modification and distribution is subject to the Boost Software
0022 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0023 // http://www.boost.org/LICENSE_1_0.txt)
0024 
0025 //  See http://www.boost.org for updates, documentation, and revision history.
0026 
0027 #include <boost/config.hpp>
0028 
0029 #include <boost/static_assert.hpp>
0030 #include <boost/type_traits/is_const.hpp>
0031 
0032 #include <boost/mpl/eval_if.hpp>
0033 #include <boost/mpl/or.hpp>
0034 #include <boost/mpl/equal_to.hpp>
0035 #include <boost/mpl/int.hpp>
0036 #include <boost/mpl/not.hpp>
0037 #include <boost/mpl/greater.hpp>
0038 #include <boost/mpl/assert.hpp>
0039 
0040 #include <boost/serialization/static_warning.hpp>
0041 #include <boost/serialization/version.hpp>
0042 #include <boost/serialization/level.hpp>
0043 #include <boost/serialization/tracking.hpp>
0044 #include <boost/serialization/wrapper.hpp>
0045 
0046 namespace boost {
0047 namespace archive {
0048 namespace detail {
0049 
0050 // checks for objects
0051 
0052 template<class T>
0053 inline void check_object_level(){
0054     typedef
0055         typename mpl::greater_equal<
0056             serialization::implementation_level< T >,
0057             mpl::int_<serialization::primitive_type>
0058         >::type typex;
0059 
0060     // trap attempts to serialize objects marked
0061     // not_serializable
0062     BOOST_STATIC_ASSERT(typex::value);
0063 }
0064 
0065 template<class T>
0066 inline void check_object_versioning(){
0067     typedef
0068         typename mpl::or_<
0069             typename mpl::greater<
0070                 serialization::implementation_level< T >,
0071                 mpl::int_<serialization::object_serializable>
0072             >,
0073             typename mpl::equal_to<
0074                 serialization::version< T >,
0075                 mpl::int_<0>
0076             >
0077         > typex;
0078     // trap attempts to serialize with objects that don't
0079     // save class information in the archive with versioning.
0080     BOOST_STATIC_ASSERT(typex::value);
0081 }
0082 
0083 template<class T>
0084 inline void check_object_tracking(){
0085     // presume it has already been determined that
0086     // T is not a const
0087     BOOST_STATIC_ASSERT(! boost::is_const< T >::value);
0088     typedef typename mpl::equal_to<
0089         serialization::tracking_level< T >,
0090         mpl::int_<serialization::track_never>
0091     >::type typex;
0092     // saving an non-const object of a type not marked "track_never)
0093 
0094     // may be an indicator of an error usage of the
0095     // serialization library and should be double checked.
0096     // See documentation on object tracking.  Also, see the
0097     // "rationale" section of the documentation
0098     // for motivation for this checking.
0099 
0100     BOOST_STATIC_WARNING(typex::value);
0101 }
0102 
0103 // checks for pointers
0104 
0105 template<class T>
0106 inline void check_pointer_level(){
0107     // we should only invoke this once we KNOW that T
0108     // has been used as a pointer!!
0109     typedef
0110         typename mpl::or_<
0111             typename mpl::greater<
0112                 serialization::implementation_level< T >,
0113                 mpl::int_<serialization::object_serializable>
0114             >,
0115             typename mpl::not_<
0116                 typename mpl::equal_to<
0117                     serialization::tracking_level< T >,
0118                     mpl::int_<serialization::track_selectively>
0119                 >
0120             >
0121         > typex;
0122     // Address the following when serializing to a pointer:
0123 
0124     // a) This type doesn't save class information in the
0125     // archive. That is, the serialization trait implementation
0126     // level <= object_serializable.
0127     // b) Tracking for this type is set to "track selectively"
0128 
0129     // in this case, indication that an object is tracked is
0130     // not stored in the archive itself - see level == object_serializable
0131     // but rather the existence of the operation ar >> T * is used to
0132     // infer that an object of this type should be tracked.  So, if
0133     // you save via a pointer but don't load via a pointer the operation
0134     // will fail on load without given any valid reason for the failure.
0135 
0136     // So if your program traps here, consider changing the
0137     // tracking or implementation level traits - or not
0138     // serializing via a pointer.
0139     BOOST_STATIC_WARNING(typex::value);
0140 }
0141 
0142 template<class T>
0143 void inline check_pointer_tracking(){
0144     typedef typename mpl::greater<
0145         serialization::tracking_level< T >,
0146         mpl::int_<serialization::track_never>
0147     >::type typex;
0148     // serializing an object of a type marked "track_never" through a pointer
0149     // could result in creating more objects than were saved!
0150     BOOST_STATIC_WARNING(typex::value);
0151 }
0152 
0153 template<class T>
0154 inline void check_const_loading(){
0155     typedef
0156         typename mpl::or_<
0157             typename boost::serialization::is_wrapper< T >,
0158             typename mpl::not_<
0159                 typename boost::is_const< T >
0160             >
0161         >::type typex;
0162     // cannot load data into a "const" object unless it's a
0163     // wrapper around some other non-const object.
0164     BOOST_STATIC_ASSERT(typex::value);
0165 }
0166 
0167 } // detail
0168 } // archive
0169 } // boost
0170 
0171 #endif // BOOST_ARCHIVE_DETAIL_CHECK_HPP