Chris@16: #ifndef BOOST_ARCHIVE_BASIC_ARCHIVE_HPP Chris@16: #define BOOST_ARCHIVE_BASIC_ARCHIVE_HPP Chris@16: Chris@16: // MS compatible compilers support #pragma once Chris@101: #if defined(_MSC_VER) Chris@16: # pragma once Chris@16: #endif Chris@16: Chris@16: /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 Chris@16: // basic_archive.hpp: Chris@16: Chris@16: // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . Chris@16: // Use, modification and distribution is subject to the Boost Software Chris@16: // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: // See http://www.boost.org for updates, documentation, and revision history. Chris@101: #include // count Chris@16: #include Chris@16: #include Chris@16: #include // size_t Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: #include // must be the last header Chris@16: Chris@16: namespace boost { Chris@16: namespace archive { Chris@16: Chris@16: #if defined(_MSC_VER) Chris@16: #pragma warning( push ) Chris@16: #pragma warning( disable : 4244 4267 ) Chris@16: #endif Chris@16: Chris@16: /* NOTE : Warning : Warning : Warning : Warning : Warning Chris@16: * Don't ever changes this. If you do, they previously created Chris@16: * binary archives won't be readable !!! Chris@16: */ Chris@16: class library_version_type { Chris@16: private: Chris@16: typedef uint_least16_t base_type; Chris@16: base_type t; Chris@16: public: Chris@16: library_version_type(): t(0) {}; Chris@16: explicit library_version_type(const unsigned int & t_) : t(t_){ Chris@16: BOOST_ASSERT(t_ <= boost::integer_traits::const_max); Chris@16: } Chris@16: library_version_type(const library_version_type & t_) : Chris@16: t(t_.t) Chris@16: {} Chris@16: library_version_type & operator=(const library_version_type & rhs){ Chris@16: t = rhs.t; Chris@16: return *this; Chris@16: } Chris@16: // used for text output Chris@16: operator base_type () const { Chris@16: return t; Chris@16: } Chris@16: // used for text input Chris@16: operator base_type & (){ Chris@16: return t; Chris@16: } Chris@16: bool operator==(const library_version_type & rhs) const { Chris@16: return t == rhs.t; Chris@16: } Chris@16: bool operator<(const library_version_type & rhs) const { Chris@16: return t < rhs.t; Chris@16: } Chris@16: }; Chris@16: Chris@16: BOOST_ARCHIVE_DECL(library_version_type) Chris@16: BOOST_ARCHIVE_VERSION(); Chris@16: Chris@16: class version_type { Chris@16: private: Chris@16: typedef uint_least32_t base_type; Chris@16: base_type t; Chris@16: public: Chris@16: // should be private - but MPI fails if it's not!!! Chris@16: version_type(): t(0) {}; Chris@16: explicit version_type(const unsigned int & t_) : t(t_){ Chris@16: BOOST_ASSERT(t_ <= boost::integer_traits::const_max); Chris@16: } Chris@16: version_type(const version_type & t_) : Chris@16: t(t_.t) Chris@16: {} Chris@16: version_type & operator=(const version_type & rhs){ Chris@16: t = rhs.t; Chris@16: return *this; Chris@16: } Chris@16: // used for text output Chris@16: operator base_type () const { Chris@16: return t; Chris@16: } Chris@16: // used for text intput Chris@16: operator base_type & (){ Chris@16: return t; Chris@16: } Chris@16: bool operator==(const version_type & rhs) const { Chris@16: return t == rhs.t; Chris@16: } Chris@16: bool operator<(const version_type & rhs) const { Chris@16: return t < rhs.t; Chris@16: } Chris@16: }; Chris@16: Chris@16: class class_id_type { Chris@16: private: Chris@16: typedef int_least16_t base_type; Chris@16: base_type t; Chris@16: public: Chris@16: // should be private - but then can't use BOOST_STRONG_TYPE below Chris@16: class_id_type() : t(0) {}; Chris@16: explicit class_id_type(const int t_) : t(t_){ Chris@16: BOOST_ASSERT(t_ <= boost::integer_traits::const_max); Chris@16: } Chris@16: explicit class_id_type(const std::size_t t_) : t(t_){ Chris@16: // BOOST_ASSERT(t_ <= boost::integer_traits::const_max); Chris@16: } Chris@16: class_id_type(const class_id_type & t_) : Chris@16: t(t_.t) Chris@16: {} Chris@16: class_id_type & operator=(const class_id_type & rhs){ Chris@16: t = rhs.t; Chris@16: return *this; Chris@16: } Chris@16: Chris@16: // used for text output Chris@16: operator int () const { Chris@16: return t; Chris@16: } Chris@16: // used for text input Chris@16: operator int_least16_t &() { Chris@16: return t; Chris@16: } Chris@16: bool operator==(const class_id_type & rhs) const { Chris@16: return t == rhs.t; Chris@16: } Chris@16: bool operator<(const class_id_type & rhs) const { Chris@16: return t < rhs.t; Chris@16: } Chris@16: }; Chris@16: Chris@16: #define NULL_POINTER_TAG boost::archive::class_id_type(-1) Chris@16: Chris@16: class object_id_type { Chris@16: private: Chris@16: typedef uint_least32_t base_type; Chris@16: base_type t; Chris@16: public: Chris@16: object_id_type(): t(0) {}; Chris@16: // note: presumes that size_t >= unsigned int. Chris@16: explicit object_id_type(const std::size_t & t_) : t(t_){ Chris@16: BOOST_ASSERT(t_ <= boost::integer_traits::const_max); Chris@16: } Chris@16: object_id_type(const object_id_type & t_) : Chris@16: t(t_.t) Chris@16: {} Chris@16: object_id_type & operator=(const object_id_type & rhs){ Chris@16: t = rhs.t; Chris@16: return *this; Chris@16: } Chris@16: // used for text output Chris@16: operator uint_least32_t () const { Chris@16: return t; Chris@16: } Chris@16: // used for text input Chris@16: operator uint_least32_t & () { Chris@16: return t; Chris@16: } Chris@16: bool operator==(const object_id_type & rhs) const { Chris@16: return t == rhs.t; Chris@16: } Chris@16: bool operator<(const object_id_type & rhs) const { Chris@16: return t < rhs.t; Chris@16: } Chris@16: }; Chris@16: Chris@16: #if defined(_MSC_VER) Chris@16: #pragma warning( pop ) Chris@16: #endif Chris@16: Chris@16: struct tracking_type { Chris@16: bool t; Chris@16: explicit tracking_type(const bool t_ = false) Chris@16: : t(t_) Chris@16: {}; Chris@16: tracking_type(const tracking_type & t_) Chris@16: : t(t_.t) Chris@16: {} Chris@16: operator bool () const { Chris@16: return t; Chris@16: }; Chris@16: operator bool & () { Chris@16: return t; Chris@16: }; Chris@16: tracking_type & operator=(const bool t_){ Chris@16: t = t_; Chris@16: return *this; Chris@16: } Chris@16: bool operator==(const tracking_type & rhs) const { Chris@16: return t == rhs.t; Chris@16: } Chris@16: bool operator==(const bool & rhs) const { Chris@16: return t == rhs; Chris@16: } Chris@16: tracking_type & operator=(const tracking_type & rhs){ Chris@16: t = rhs.t; Chris@16: return *this; Chris@16: } Chris@16: }; Chris@16: Chris@16: struct class_name_type : Chris@16: private boost::noncopyable Chris@16: { Chris@16: char *t; Chris@16: operator const char * & () const { Chris@16: return const_cast(t); Chris@16: } Chris@16: operator char * () { Chris@16: return t; Chris@16: } Chris@101: std::size_t size() const { Chris@101: return std::strlen(t); Chris@101: } Chris@16: explicit class_name_type(const char *key_) Chris@16: : t(const_cast(key_)){} Chris@16: explicit class_name_type(char *key_) Chris@16: : t(key_){} Chris@16: class_name_type & operator=(const class_name_type & rhs){ Chris@16: t = rhs.t; Chris@16: return *this; Chris@16: } Chris@16: }; Chris@16: Chris@16: enum archive_flags { Chris@16: no_header = 1, // suppress archive header info Chris@16: no_codecvt = 2, // suppress alteration of codecvt facet Chris@16: no_xml_tag_checking = 4, // suppress checking of xml tags Chris@16: no_tracking = 8, // suppress ALL tracking Chris@16: flags_last = 8 Chris@16: }; Chris@16: Chris@16: BOOST_ARCHIVE_DECL(const char *) Chris@16: BOOST_ARCHIVE_SIGNATURE(); Chris@16: Chris@16: /* NOTE : Warning : Warning : Warning : Warning : Warning Chris@16: * If any of these are changed to different sized types, Chris@16: * binary_iarchive won't be able to read older archives Chris@16: * unless you rev the library version and include conditional Chris@16: * code based on the library version. There is nothing Chris@16: * inherently wrong in doing this - but you have to be super Chris@16: * careful because it's easy to get wrong and start breaking Chris@16: * old archives !!! Chris@16: */ Chris@16: Chris@16: #define BOOST_ARCHIVE_STRONG_TYPEDEF(T, D) \ Chris@16: class D : public T { \ Chris@16: public: \ Chris@16: explicit D(const T tt) : T(tt){} \ Chris@16: }; \ Chris@16: /**/ Chris@16: Chris@16: BOOST_ARCHIVE_STRONG_TYPEDEF(class_id_type, class_id_reference_type) Chris@16: BOOST_ARCHIVE_STRONG_TYPEDEF(class_id_type, class_id_optional_type) Chris@16: BOOST_ARCHIVE_STRONG_TYPEDEF(object_id_type, object_reference_type) Chris@16: Chris@16: }// namespace archive Chris@16: }// namespace boost Chris@16: Chris@16: #include // pops abi_suffix.hpp pragmas Chris@16: Chris@16: #include Chris@16: Chris@16: // set implementation level to primitive for all types Chris@16: // used internally by the serialization library Chris@16: Chris@16: BOOST_CLASS_IMPLEMENTATION(boost::archive::library_version_type, primitive_type) Chris@16: BOOST_CLASS_IMPLEMENTATION(boost::archive::version_type, primitive_type) Chris@16: BOOST_CLASS_IMPLEMENTATION(boost::archive::class_id_type, primitive_type) Chris@16: BOOST_CLASS_IMPLEMENTATION(boost::archive::class_id_reference_type, primitive_type) Chris@16: BOOST_CLASS_IMPLEMENTATION(boost::archive::class_id_optional_type, primitive_type) Chris@16: BOOST_CLASS_IMPLEMENTATION(boost::archive::class_name_type, primitive_type) Chris@16: BOOST_CLASS_IMPLEMENTATION(boost::archive::object_id_type, primitive_type) Chris@16: BOOST_CLASS_IMPLEMENTATION(boost::archive::object_reference_type, primitive_type) Chris@16: BOOST_CLASS_IMPLEMENTATION(boost::archive::tracking_type, primitive_type) Chris@16: Chris@16: #include Chris@16: Chris@16: // set types used internally by the serialization library Chris@16: // to be bitwise serializable Chris@16: Chris@16: BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::library_version_type) Chris@16: BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::version_type) Chris@16: BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::class_id_type) Chris@16: BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::class_id_reference_type) Chris@16: BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::class_id_optional_type) Chris@16: BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::class_name_type) Chris@16: BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::object_id_type) Chris@16: BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::object_reference_type) Chris@16: BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::tracking_type) Chris@16: Chris@16: #endif //BOOST_ARCHIVE_BASIC_ARCHIVE_HPP