Merge pull request #1483

af9a7999 account for API difference between 1.58 & 1.59 (kenshi84)
This commit is contained in:
Riccardo Spagni 2016-12-21 10:35:13 +02:00
commit 049b7e9a93
No known key found for this signature in database
GPG Key ID: 55432DF31CCD4FCD
2 changed files with 47 additions and 0 deletions

View File

@ -22,6 +22,7 @@
// See http://www.boost.org for updates, documentation, and revision history. // See http://www.boost.org for updates, documentation, and revision history.
#include <istream> #include <istream>
#include <boost/version.hpp>
#include <boost/serialization/string.hpp> #include <boost/serialization/string.hpp>
#include <boost/serialization/item_version_type.hpp> #include <boost/serialization/item_version_type.hpp>
#include <boost/archive/archive_exception.hpp> #include <boost/archive/archive_exception.hpp>
@ -153,6 +154,7 @@ protected:
} }
typedef boost::archive::detail::common_iarchive<portable_binary_iarchive> typedef boost::archive::detail::common_iarchive<portable_binary_iarchive>
detail_common_iarchive; detail_common_iarchive;
#if BOOST_VERSION > 105800
template<class T> template<class T>
void load_override(T & t){ void load_override(T & t){
this->detail_common_iarchive::load_override(t); this->detail_common_iarchive::load_override(t);
@ -160,6 +162,15 @@ protected:
void load_override(boost::archive::class_name_type & t); void load_override(boost::archive::class_name_type & t);
// binary files don't include the optional information // binary files don't include the optional information
void load_override(boost::archive::class_id_optional_type &){} void load_override(boost::archive::class_id_optional_type &){}
#else
template<class T>
void load_override(T & t, int){
this->detail_common_iarchive::load_override(t, 0);
}
void load_override(boost::archive::class_name_type & t, int);
// binary files don't include the optional information
void load_override(boost::archive::class_id_optional_type &, int){}
#endif
void init(unsigned int flags); void init(unsigned int flags);
public: public:
@ -257,6 +268,7 @@ portable_binary_iarchive::load_impl(boost::intmax_t & l, char maxsize){
l = -l; l = -l;
} }
#if BOOST_VERSION > 105800
inline void inline void
portable_binary_iarchive::load_override( portable_binary_iarchive::load_override(
boost::archive::class_name_type & t boost::archive::class_name_type & t
@ -273,6 +285,24 @@ portable_binary_iarchive::load_override(
// borland tweak // borland tweak
t.t[cn.size()] = '\0'; t.t[cn.size()] = '\0';
} }
#else
inline void
portable_binary_iarchive::load_override(
boost::archive::class_name_type & t, int
){
std::string cn;
cn.reserve(BOOST_SERIALIZATION_MAX_KEY_SIZE);
load_override(cn, 0);
if(cn.size() > (BOOST_SERIALIZATION_MAX_KEY_SIZE - 1))
boost::serialization::throw_exception(
boost::archive::archive_exception(
boost::archive::archive_exception::invalid_class_name)
);
std::memcpy(t, cn.data(), cn.size());
// borland tweak
t.t[cn.size()] = '\0';
}
#endif
inline void inline void
portable_binary_iarchive::init(unsigned int flags){ portable_binary_iarchive::init(unsigned int flags){

View File

@ -22,6 +22,7 @@
// See http://www.boost.org for updates, documentation, and revision history. // See http://www.boost.org for updates, documentation, and revision history.
#include <ostream> #include <ostream>
#include <boost/version.hpp>
#include <boost/serialization/string.hpp> #include <boost/serialization/string.hpp>
#include <boost/archive/archive_exception.hpp> #include <boost/archive/archive_exception.hpp>
#include <boost/archive/basic_binary_oprimitive.hpp> #include <boost/archive/basic_binary_oprimitive.hpp>
@ -133,6 +134,7 @@ protected:
// extra stuff to get it passed borland compilers // extra stuff to get it passed borland compilers
typedef boost::archive::detail::common_oarchive<portable_binary_oarchive> typedef boost::archive::detail::common_oarchive<portable_binary_oarchive>
detail_common_oarchive; detail_common_oarchive;
#if BOOST_VERSION > 105800
template<class T> template<class T>
void save_override(T & t){ void save_override(T & t){
this->detail_common_oarchive::save_override(t); this->detail_common_oarchive::save_override(t);
@ -146,6 +148,21 @@ protected:
void save_override( void save_override(
const boost::archive::class_id_optional_type & /* t */ const boost::archive::class_id_optional_type & /* t */
){} ){}
#else
template<class T>
void save_override(T & t, int){
this->detail_common_oarchive::save_override(t, 0);
}
// explicitly convert to char * to avoid compile ambiguities
void save_override(const boost::archive::class_name_type & t, int){
const std::string s(t);
* this << s;
}
// binary files don't include the optional information
void save_override(
const boost::archive::class_id_optional_type & /* t */, int
){}
#endif
void init(unsigned int flags); void init(unsigned int flags);
public: public: