annotate DEPENDENCIES/generic/include/boost/archive/detail/check.hpp @ 133:4acb5d8d80b6 tip

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