File indexing completed on 2025-01-18 09:28:29
0001 #ifndef BOOST_ARCHIVE_BASIC_ARCHIVE_HPP
0002 #define BOOST_ARCHIVE_BASIC_ARCHIVE_HPP
0003
0004
0005 #if defined(_MSC_VER)
0006 # pragma once
0007 #endif
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #include <cstring> // count
0019 #include <boost/assert.hpp>
0020 #include <boost/config.hpp>
0021 #include <boost/integer_traits.hpp>
0022 #include <boost/noncopyable.hpp>
0023 #include <boost/serialization/library_version_type.hpp>
0024
0025 #include <boost/archive/detail/auto_link_archive.hpp>
0026 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
0027
0028 namespace boost {
0029 namespace archive {
0030
0031 #if defined(_MSC_VER)
0032 #pragma warning( push )
0033 #pragma warning( disable : 4244 4267 )
0034 #endif
0035
0036 BOOST_ARCHIVE_DECL boost::serialization::library_version_type
0037 BOOST_ARCHIVE_VERSION();
0038
0039
0040 typedef boost::serialization::library_version_type library_version_type;
0041
0042 class version_type {
0043 private:
0044 typedef uint_least32_t base_type;
0045 base_type t;
0046 public:
0047
0048 version_type(): t(0) {}
0049 explicit version_type(const unsigned int & t_) : t(t_){
0050 BOOST_ASSERT(t_ <= boost::integer_traits<base_type>::const_max);
0051 }
0052 version_type(const version_type & t_) :
0053 t(t_.t)
0054 {}
0055 version_type & operator=(const version_type & rhs){
0056 t = rhs.t;
0057 return *this;
0058 }
0059
0060 operator base_type () const {
0061 return t;
0062 }
0063
0064 operator base_type & (){
0065 return t;
0066 }
0067 bool operator==(const version_type & rhs) const {
0068 return t == rhs.t;
0069 }
0070 bool operator<(const version_type & rhs) const {
0071 return t < rhs.t;
0072 }
0073 };
0074
0075 class class_id_type {
0076 private:
0077 typedef int_least16_t base_type;
0078 base_type t;
0079 public:
0080
0081 class_id_type() : t(0) {}
0082 explicit class_id_type(const int t_) : t(t_){
0083 BOOST_ASSERT(t_ <= boost::integer_traits<base_type>::const_max);
0084 }
0085 explicit class_id_type(const std::size_t t_) : t(t_){
0086
0087 }
0088 class_id_type(const class_id_type & t_) :
0089 t(t_.t)
0090 {}
0091 class_id_type & operator=(const class_id_type & rhs){
0092 t = rhs.t;
0093 return *this;
0094 }
0095
0096
0097 operator base_type () const {
0098 return t;
0099 }
0100
0101 operator base_type &() {
0102 return t;
0103 }
0104 bool operator==(const class_id_type & rhs) const {
0105 return t == rhs.t;
0106 }
0107 bool operator<(const class_id_type & rhs) const {
0108 return t < rhs.t;
0109 }
0110 };
0111
0112 #define BOOST_SERIALIZATION_NULL_POINTER_TAG boost::archive::class_id_type(-1)
0113
0114 class object_id_type {
0115 private:
0116 typedef uint_least32_t base_type;
0117 base_type t;
0118 public:
0119 object_id_type(): t(0) {}
0120
0121
0122 explicit object_id_type(const std::size_t & t_) : t(static_cast<base_type>(t_)){
0123
0124
0125 BOOST_ASSERT(t_ <= boost::integer_traits<base_type>::const_max);
0126 }
0127 object_id_type(const object_id_type & t_) :
0128 t(t_.t)
0129 {}
0130 object_id_type & operator=(const object_id_type & rhs){
0131 t = rhs.t;
0132 return *this;
0133 }
0134
0135 operator base_type () const {
0136 return t;
0137 }
0138
0139 operator base_type & () {
0140 return t;
0141 }
0142 bool operator==(const object_id_type & rhs) const {
0143 return t == rhs.t;
0144 }
0145 bool operator<(const object_id_type & rhs) const {
0146 return t < rhs.t;
0147 }
0148 };
0149
0150 #if defined(_MSC_VER)
0151 #pragma warning( pop )
0152 #endif
0153
0154 struct tracking_type {
0155 bool t;
0156 explicit tracking_type(const bool t_ = false)
0157 : t(t_)
0158 {}
0159 tracking_type(const tracking_type & t_)
0160 : t(t_.t)
0161 {}
0162 operator bool () const {
0163 return t;
0164 }
0165 operator bool & () {
0166 return t;
0167 }
0168 tracking_type & operator=(const bool t_){
0169 t = t_;
0170 return *this;
0171 }
0172 bool operator==(const tracking_type & rhs) const {
0173 return t == rhs.t;
0174 }
0175 bool operator==(const bool & rhs) const {
0176 return t == rhs;
0177 }
0178 tracking_type & operator=(const tracking_type & rhs){
0179 t = rhs.t;
0180 return *this;
0181 }
0182 };
0183
0184 struct class_name_type :
0185 private boost::noncopyable
0186 {
0187 char *t;
0188 operator const char * & () const {
0189 return const_cast<const char * &>(t);
0190 }
0191 operator char * () {
0192 return t;
0193 }
0194 std::size_t size() const {
0195 return std::strlen(t);
0196 }
0197 explicit class_name_type(const char *key_)
0198 : t(const_cast<char *>(key_)){}
0199 explicit class_name_type(char *key_)
0200 : t(key_){}
0201 class_name_type & operator=(const class_name_type & rhs){
0202 t = rhs.t;
0203 return *this;
0204 }
0205 };
0206
0207 enum archive_flags {
0208 no_header = 1,
0209 no_codecvt = 2,
0210 no_xml_tag_checking = 4,
0211 no_tracking = 8,
0212 flags_last = 8
0213 };
0214
0215 BOOST_ARCHIVE_DECL const char *
0216 BOOST_ARCHIVE_SIGNATURE();
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228 #define BOOST_ARCHIVE_STRONG_TYPEDEF(T, D) \
0229 class D : public T { \
0230 public: \
0231 explicit D(const T tt) : T(tt){} \
0232 }; \
0233
0234
0235 BOOST_ARCHIVE_STRONG_TYPEDEF(class_id_type, class_id_reference_type)
0236 BOOST_ARCHIVE_STRONG_TYPEDEF(class_id_type, class_id_optional_type)
0237 BOOST_ARCHIVE_STRONG_TYPEDEF(object_id_type, object_reference_type)
0238
0239 }
0240 }
0241
0242 #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
0243
0244 #include <boost/serialization/level.hpp>
0245
0246
0247
0248
0249 BOOST_CLASS_IMPLEMENTATION(boost::serialization::library_version_type, primitive_type)
0250 BOOST_CLASS_IMPLEMENTATION(boost::archive::version_type, primitive_type)
0251 BOOST_CLASS_IMPLEMENTATION(boost::archive::class_id_type, primitive_type)
0252 BOOST_CLASS_IMPLEMENTATION(boost::archive::class_id_reference_type, primitive_type)
0253 BOOST_CLASS_IMPLEMENTATION(boost::archive::class_id_optional_type, primitive_type)
0254 BOOST_CLASS_IMPLEMENTATION(boost::archive::class_name_type, primitive_type)
0255 BOOST_CLASS_IMPLEMENTATION(boost::archive::object_id_type, primitive_type)
0256 BOOST_CLASS_IMPLEMENTATION(boost::archive::object_reference_type, primitive_type)
0257 BOOST_CLASS_IMPLEMENTATION(boost::archive::tracking_type, primitive_type)
0258
0259 #include <boost/serialization/is_bitwise_serializable.hpp>
0260
0261
0262
0263
0264 BOOST_IS_BITWISE_SERIALIZABLE(boost::serialization::library_version_type)
0265 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::version_type)
0266 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::class_id_type)
0267 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::class_id_reference_type)
0268 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::class_id_optional_type)
0269 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::class_name_type)
0270 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::object_id_type)
0271 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::object_reference_type)
0272 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::tracking_type)
0273
0274 #endif