annotate DEPENDENCIES/generic/include/boost/archive/basic_archive.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_BASIC_ARCHIVE_HPP
Chris@16 2 #define BOOST_ARCHIVE_BASIC_ARCHIVE_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 #endif
Chris@16 8
Chris@16 9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
Chris@16 10 // basic_archive.hpp:
Chris@16 11
Chris@16 12 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
Chris@16 13 // Use, modification and distribution is subject to the Boost Software
Chris@16 14 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 15 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 16
Chris@16 17 // See http://www.boost.org for updates, documentation, and revision history.
Chris@101 18 #include <cstring> // count
Chris@16 19 #include <boost/assert.hpp>
Chris@16 20 #include <boost/config.hpp>
Chris@16 21 #include <boost/cstdint.hpp> // size_t
Chris@16 22 #include <boost/noncopyable.hpp>
Chris@16 23 #include <boost/integer_traits.hpp>
Chris@16 24
Chris@16 25 #include <boost/archive/detail/auto_link_archive.hpp>
Chris@16 26 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
Chris@16 27
Chris@16 28 namespace boost {
Chris@16 29 namespace archive {
Chris@16 30
Chris@16 31 #if defined(_MSC_VER)
Chris@16 32 #pragma warning( push )
Chris@16 33 #pragma warning( disable : 4244 4267 )
Chris@16 34 #endif
Chris@16 35
Chris@16 36 /* NOTE : Warning : Warning : Warning : Warning : Warning
Chris@16 37 * Don't ever changes this. If you do, they previously created
Chris@16 38 * binary archives won't be readable !!!
Chris@16 39 */
Chris@16 40 class library_version_type {
Chris@16 41 private:
Chris@16 42 typedef uint_least16_t base_type;
Chris@16 43 base_type t;
Chris@16 44 public:
Chris@16 45 library_version_type(): t(0) {};
Chris@16 46 explicit library_version_type(const unsigned int & t_) : t(t_){
Chris@16 47 BOOST_ASSERT(t_ <= boost::integer_traits<base_type>::const_max);
Chris@16 48 }
Chris@16 49 library_version_type(const library_version_type & t_) :
Chris@16 50 t(t_.t)
Chris@16 51 {}
Chris@16 52 library_version_type & operator=(const library_version_type & rhs){
Chris@16 53 t = rhs.t;
Chris@16 54 return *this;
Chris@16 55 }
Chris@16 56 // used for text output
Chris@16 57 operator base_type () const {
Chris@16 58 return t;
Chris@16 59 }
Chris@16 60 // used for text input
Chris@16 61 operator base_type & (){
Chris@16 62 return t;
Chris@16 63 }
Chris@16 64 bool operator==(const library_version_type & rhs) const {
Chris@16 65 return t == rhs.t;
Chris@16 66 }
Chris@16 67 bool operator<(const library_version_type & rhs) const {
Chris@16 68 return t < rhs.t;
Chris@16 69 }
Chris@16 70 };
Chris@16 71
Chris@16 72 BOOST_ARCHIVE_DECL(library_version_type)
Chris@16 73 BOOST_ARCHIVE_VERSION();
Chris@16 74
Chris@16 75 class version_type {
Chris@16 76 private:
Chris@16 77 typedef uint_least32_t base_type;
Chris@16 78 base_type t;
Chris@16 79 public:
Chris@16 80 // should be private - but MPI fails if it's not!!!
Chris@16 81 version_type(): t(0) {};
Chris@16 82 explicit version_type(const unsigned int & t_) : t(t_){
Chris@16 83 BOOST_ASSERT(t_ <= boost::integer_traits<base_type>::const_max);
Chris@16 84 }
Chris@16 85 version_type(const version_type & t_) :
Chris@16 86 t(t_.t)
Chris@16 87 {}
Chris@16 88 version_type & operator=(const version_type & rhs){
Chris@16 89 t = rhs.t;
Chris@16 90 return *this;
Chris@16 91 }
Chris@16 92 // used for text output
Chris@16 93 operator base_type () const {
Chris@16 94 return t;
Chris@16 95 }
Chris@16 96 // used for text intput
Chris@16 97 operator base_type & (){
Chris@16 98 return t;
Chris@16 99 }
Chris@16 100 bool operator==(const version_type & rhs) const {
Chris@16 101 return t == rhs.t;
Chris@16 102 }
Chris@16 103 bool operator<(const version_type & rhs) const {
Chris@16 104 return t < rhs.t;
Chris@16 105 }
Chris@16 106 };
Chris@16 107
Chris@16 108 class class_id_type {
Chris@16 109 private:
Chris@16 110 typedef int_least16_t base_type;
Chris@16 111 base_type t;
Chris@16 112 public:
Chris@16 113 // should be private - but then can't use BOOST_STRONG_TYPE below
Chris@16 114 class_id_type() : t(0) {};
Chris@16 115 explicit class_id_type(const int t_) : t(t_){
Chris@16 116 BOOST_ASSERT(t_ <= boost::integer_traits<base_type>::const_max);
Chris@16 117 }
Chris@16 118 explicit class_id_type(const std::size_t t_) : t(t_){
Chris@16 119 // BOOST_ASSERT(t_ <= boost::integer_traits<base_type>::const_max);
Chris@16 120 }
Chris@16 121 class_id_type(const class_id_type & t_) :
Chris@16 122 t(t_.t)
Chris@16 123 {}
Chris@16 124 class_id_type & operator=(const class_id_type & rhs){
Chris@16 125 t = rhs.t;
Chris@16 126 return *this;
Chris@16 127 }
Chris@16 128
Chris@16 129 // used for text output
Chris@16 130 operator int () const {
Chris@16 131 return t;
Chris@16 132 }
Chris@16 133 // used for text input
Chris@16 134 operator int_least16_t &() {
Chris@16 135 return t;
Chris@16 136 }
Chris@16 137 bool operator==(const class_id_type & rhs) const {
Chris@16 138 return t == rhs.t;
Chris@16 139 }
Chris@16 140 bool operator<(const class_id_type & rhs) const {
Chris@16 141 return t < rhs.t;
Chris@16 142 }
Chris@16 143 };
Chris@16 144
Chris@16 145 #define NULL_POINTER_TAG boost::archive::class_id_type(-1)
Chris@16 146
Chris@16 147 class object_id_type {
Chris@16 148 private:
Chris@16 149 typedef uint_least32_t base_type;
Chris@16 150 base_type t;
Chris@16 151 public:
Chris@16 152 object_id_type(): t(0) {};
Chris@16 153 // note: presumes that size_t >= unsigned int.
Chris@16 154 explicit object_id_type(const std::size_t & t_) : t(t_){
Chris@16 155 BOOST_ASSERT(t_ <= boost::integer_traits<base_type>::const_max);
Chris@16 156 }
Chris@16 157 object_id_type(const object_id_type & t_) :
Chris@16 158 t(t_.t)
Chris@16 159 {}
Chris@16 160 object_id_type & operator=(const object_id_type & rhs){
Chris@16 161 t = rhs.t;
Chris@16 162 return *this;
Chris@16 163 }
Chris@16 164 // used for text output
Chris@16 165 operator uint_least32_t () const {
Chris@16 166 return t;
Chris@16 167 }
Chris@16 168 // used for text input
Chris@16 169 operator uint_least32_t & () {
Chris@16 170 return t;
Chris@16 171 }
Chris@16 172 bool operator==(const object_id_type & rhs) const {
Chris@16 173 return t == rhs.t;
Chris@16 174 }
Chris@16 175 bool operator<(const object_id_type & rhs) const {
Chris@16 176 return t < rhs.t;
Chris@16 177 }
Chris@16 178 };
Chris@16 179
Chris@16 180 #if defined(_MSC_VER)
Chris@16 181 #pragma warning( pop )
Chris@16 182 #endif
Chris@16 183
Chris@16 184 struct tracking_type {
Chris@16 185 bool t;
Chris@16 186 explicit tracking_type(const bool t_ = false)
Chris@16 187 : t(t_)
Chris@16 188 {};
Chris@16 189 tracking_type(const tracking_type & t_)
Chris@16 190 : t(t_.t)
Chris@16 191 {}
Chris@16 192 operator bool () const {
Chris@16 193 return t;
Chris@16 194 };
Chris@16 195 operator bool & () {
Chris@16 196 return t;
Chris@16 197 };
Chris@16 198 tracking_type & operator=(const bool t_){
Chris@16 199 t = t_;
Chris@16 200 return *this;
Chris@16 201 }
Chris@16 202 bool operator==(const tracking_type & rhs) const {
Chris@16 203 return t == rhs.t;
Chris@16 204 }
Chris@16 205 bool operator==(const bool & rhs) const {
Chris@16 206 return t == rhs;
Chris@16 207 }
Chris@16 208 tracking_type & operator=(const tracking_type & rhs){
Chris@16 209 t = rhs.t;
Chris@16 210 return *this;
Chris@16 211 }
Chris@16 212 };
Chris@16 213
Chris@16 214 struct class_name_type :
Chris@16 215 private boost::noncopyable
Chris@16 216 {
Chris@16 217 char *t;
Chris@16 218 operator const char * & () const {
Chris@16 219 return const_cast<const char * &>(t);
Chris@16 220 }
Chris@16 221 operator char * () {
Chris@16 222 return t;
Chris@16 223 }
Chris@101 224 std::size_t size() const {
Chris@101 225 return std::strlen(t);
Chris@101 226 }
Chris@16 227 explicit class_name_type(const char *key_)
Chris@16 228 : t(const_cast<char *>(key_)){}
Chris@16 229 explicit class_name_type(char *key_)
Chris@16 230 : t(key_){}
Chris@16 231 class_name_type & operator=(const class_name_type & rhs){
Chris@16 232 t = rhs.t;
Chris@16 233 return *this;
Chris@16 234 }
Chris@16 235 };
Chris@16 236
Chris@16 237 enum archive_flags {
Chris@16 238 no_header = 1, // suppress archive header info
Chris@16 239 no_codecvt = 2, // suppress alteration of codecvt facet
Chris@16 240 no_xml_tag_checking = 4, // suppress checking of xml tags
Chris@16 241 no_tracking = 8, // suppress ALL tracking
Chris@16 242 flags_last = 8
Chris@16 243 };
Chris@16 244
Chris@16 245 BOOST_ARCHIVE_DECL(const char *)
Chris@16 246 BOOST_ARCHIVE_SIGNATURE();
Chris@16 247
Chris@16 248 /* NOTE : Warning : Warning : Warning : Warning : Warning
Chris@16 249 * If any of these are changed to different sized types,
Chris@16 250 * binary_iarchive won't be able to read older archives
Chris@16 251 * unless you rev the library version and include conditional
Chris@16 252 * code based on the library version. There is nothing
Chris@16 253 * inherently wrong in doing this - but you have to be super
Chris@16 254 * careful because it's easy to get wrong and start breaking
Chris@16 255 * old archives !!!
Chris@16 256 */
Chris@16 257
Chris@16 258 #define BOOST_ARCHIVE_STRONG_TYPEDEF(T, D) \
Chris@16 259 class D : public T { \
Chris@16 260 public: \
Chris@16 261 explicit D(const T tt) : T(tt){} \
Chris@16 262 }; \
Chris@16 263 /**/
Chris@16 264
Chris@16 265 BOOST_ARCHIVE_STRONG_TYPEDEF(class_id_type, class_id_reference_type)
Chris@16 266 BOOST_ARCHIVE_STRONG_TYPEDEF(class_id_type, class_id_optional_type)
Chris@16 267 BOOST_ARCHIVE_STRONG_TYPEDEF(object_id_type, object_reference_type)
Chris@16 268
Chris@16 269 }// namespace archive
Chris@16 270 }// namespace boost
Chris@16 271
Chris@16 272 #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
Chris@16 273
Chris@16 274 #include <boost/serialization/level.hpp>
Chris@16 275
Chris@16 276 // set implementation level to primitive for all types
Chris@16 277 // used internally by the serialization library
Chris@16 278
Chris@16 279 BOOST_CLASS_IMPLEMENTATION(boost::archive::library_version_type, primitive_type)
Chris@16 280 BOOST_CLASS_IMPLEMENTATION(boost::archive::version_type, primitive_type)
Chris@16 281 BOOST_CLASS_IMPLEMENTATION(boost::archive::class_id_type, primitive_type)
Chris@16 282 BOOST_CLASS_IMPLEMENTATION(boost::archive::class_id_reference_type, primitive_type)
Chris@16 283 BOOST_CLASS_IMPLEMENTATION(boost::archive::class_id_optional_type, primitive_type)
Chris@16 284 BOOST_CLASS_IMPLEMENTATION(boost::archive::class_name_type, primitive_type)
Chris@16 285 BOOST_CLASS_IMPLEMENTATION(boost::archive::object_id_type, primitive_type)
Chris@16 286 BOOST_CLASS_IMPLEMENTATION(boost::archive::object_reference_type, primitive_type)
Chris@16 287 BOOST_CLASS_IMPLEMENTATION(boost::archive::tracking_type, primitive_type)
Chris@16 288
Chris@16 289 #include <boost/serialization/is_bitwise_serializable.hpp>
Chris@16 290
Chris@16 291 // set types used internally by the serialization library
Chris@16 292 // to be bitwise serializable
Chris@16 293
Chris@16 294 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::library_version_type)
Chris@16 295 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::version_type)
Chris@16 296 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::class_id_type)
Chris@16 297 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::class_id_reference_type)
Chris@16 298 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::class_id_optional_type)
Chris@16 299 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::class_name_type)
Chris@16 300 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::object_id_type)
Chris@16 301 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::object_reference_type)
Chris@16 302 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::tracking_type)
Chris@16 303
Chris@16 304 #endif //BOOST_ARCHIVE_BASIC_ARCHIVE_HPP