Skip to content

Commit

Permalink
Merge branch 'fix/boost_159-160'
Browse files Browse the repository at this point in the history
  • Loading branch information
othlu committed Mar 2, 2016
2 parents 3e18290 + dfb5dcf commit be6d8b5
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef PORTABLE_BINARY_ARCHIVE_HPP
#define PORTABLE_BINARY_ARCHIVE_HPP

// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -13,7 +13,13 @@

#include <boost/config.hpp>
#include <boost/cstdint.hpp>

// breaking changes in boost >=1.59
#if BOOST_VERSION >= 105900
#else
#include <boost/serialization/pfto.hpp>
#endif

#include <boost/static_assert.hpp>

#include <climits>
Expand Down Expand Up @@ -47,7 +53,6 @@ reverse_bytes(char size, char *address){
}
}


} // namespace archive
} // namespace boost

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// portable_binary_iarchive.hpp

// (C) Copyright 2002-7 Robert Ramey - http://www.rrsd.com .
// (C) Copyright 2002-7 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -27,23 +27,31 @@
#include <boost/archive/archive_exception.hpp>
#include <boost/archive/basic_binary_iprimitive.hpp>
#include <boost/archive/detail/common_iarchive.hpp>
#include <boost/version.hpp>

// breaking changes in boost >=1.56
#if BOOST_VERSION >= 105600
#include <boost/serialization/shared_ptr.hpp>
#else
#include <boost/archive/shared_ptr_helper.hpp>
#endif

#include <boost/archive/detail/register_archive.hpp>

#include "portable_binary_archive.hpp"

namespace boost {
namespace archive {

/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// exception to be thrown if integer read from archive doesn't fit
// variable being loaded
class portable_binary_iarchive_exception :
class portable_binary_iarchive_exception :
public virtual boost::archive::archive_exception
{
public:
typedef enum {
incompatible_integer_size
incompatible_integer_size
} exception_code;
portable_binary_iarchive_exception(exception_code /* c */ ) :
boost::archive::archive_exception(boost::archive::archive_exception::other_exception)
Expand All @@ -69,24 +77,29 @@ class portable_binary_iarchive_exception :
};

/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// "Portable" input binary archive. It addresses integer size and endienness so
// "Portable" input binary archive. It addresses integer size and endienness so
// that binary archives can be passed across systems. Note:floating point types
// not addressed here
class portable_binary_iarchive :
public boost::archive::basic_binary_iprimitive<
portable_binary_iarchive,
std::istream::char_type,
std::istream::char_type,
std::istream::traits_type
>,
public boost::archive::detail::common_iarchive<
portable_binary_iarchive
>
,
// breaking changes in boost >=1.56
#if BOOST_VERSION >= 105600
public boost::serialization::shared_ptr_helper<boost::shared_ptr>
#else
public boost::archive::detail::shared_ptr_helper
#endif
{
typedef boost::archive::basic_binary_iprimitive<
portable_binary_iarchive,
std::istream::char_type,
std::istream::char_type,
std::istream::traits_type
> primitive_base_t;
typedef boost::archive::detail::common_iarchive<
Expand Down Expand Up @@ -158,26 +171,34 @@ class portable_binary_iarchive :
this->primitive_base_t::load(t);
}
// intermediate level to support override of operators
// fot templates in the absence of partial function
// fot templates in the absence of partial function
// template ordering
typedef boost::archive::detail::common_iarchive<portable_binary_iarchive>
typedef boost::archive::detail::common_iarchive<portable_binary_iarchive>
detail_common_iarchive;
template<class T>

// breaking changes in boost >=1.59
#if BOOST_VERSION >= 105900
void load_override(T & t){
this->detail_common_iarchive::load_override(t);
}
void load_override(boost::archive::class_name_type & t);
void load_override(boost::archive::class_id_optional_type & /* t */){}
#else
void load_override(T & t, BOOST_PFTO 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 & /* t */,
int
){}
// binary files don't include the optional information
void load_override(boost::archive::class_id_optional_type & /* t */, int){}
#endif


void init(unsigned int flags);
public:
portable_binary_iarchive(std::istream & is, unsigned flags = 0) :
primitive_base_t(
* is.rdbuf(),
* is.rdbuf(),
0 != (flags & boost::archive::no_codecvt)
),
archive_base_t(flags),
Expand All @@ -188,13 +209,13 @@ class portable_binary_iarchive :

portable_binary_iarchive(
std::basic_streambuf<
std::istream::char_type,
std::istream::char_type,
std::istream::traits_type
> & bsb,
> & bsb,
unsigned int flags
) :
primitive_base_t(
bsb,
bsb,
0 != (flags & boost::archive::no_codecvt)
),
archive_base_t(flags),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// portable_binary_oarchive.hpp

// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -32,16 +32,16 @@

namespace boost {
namespace archive {

/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// exception to be thrown if integer read from archive doesn't fit
// variable being loaded
class portable_binary_oarchive_exception :
class portable_binary_oarchive_exception :
public virtual boost::archive::archive_exception
{
public:
typedef enum {
invalid_flags
invalid_flags
} exception_code;
portable_binary_oarchive_exception(exception_code /* c */ )
{}
Expand All @@ -61,14 +61,14 @@ class portable_binary_oarchive_exception :
};

/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// "Portable" output binary archive. This is a variation of the native binary
// "Portable" output binary archive. This is a variation of the native binary
// archive. it addresses integer size and endienness so that binary archives can
// be passed across systems. Note:floating point types not addressed here

class portable_binary_oarchive :
public boost::archive::basic_binary_oprimitive<
portable_binary_oarchive,
std::ostream::char_type,
std::ostream::char_type,
std::ostream::traits_type
>,
public boost::archive::detail::common_oarchive<
Expand All @@ -77,7 +77,7 @@ class portable_binary_oarchive :
{
typedef boost::archive::basic_binary_oprimitive<
portable_binary_oarchive,
std::ostream::char_type,
std::ostream::char_type,
std::ostream::traits_type
> primitive_base_t;
typedef boost::archive::detail::common_oarchive<
Expand Down Expand Up @@ -133,9 +133,22 @@ class portable_binary_oarchive :

// default processing - kick back to base class. Note the
// 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;
template<class T>
// breaking changes in boost >=1.59
#if BOOST_VERSION >= 105900
void save_override(T & t){
this->detail_common_oarchive::save_override(t);
}
// explicitly convert to char * to avoid compile ambiguities
void save_override(const boost::archive::class_name_type & t){
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 */){}
#else
void save_override(T & t, BOOST_PFTO int){
this->detail_common_oarchive::save_override(t, 0);
}
Expand All @@ -144,11 +157,9 @@ class portable_binary_oarchive :
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
){}
// 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);
public:
Expand All @@ -165,13 +176,13 @@ class portable_binary_oarchive :

portable_binary_oarchive(
std::basic_streambuf<
std::ostream::char_type,
std::ostream::char_type,
std::ostream::traits_type
> & bsb,
> & bsb,
unsigned int flags
) :
primitive_base_t(
bsb,
bsb,
0 != (flags & boost::archive::no_codecvt)
),
archive_base_t(flags),
Expand Down
24 changes: 17 additions & 7 deletions Schweizer-Messer/sm_boost/src/portable_binary_iarchive.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// portable_binary_iarchive.cpp

// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -19,7 +19,7 @@
namespace boost {
namespace archive {

void
void
portable_binary_iarchive::load_impl(boost::intmax_t & l, char maxsize){
char size;
l = 0;
Expand Down Expand Up @@ -50,18 +50,28 @@ portable_binary_iarchive::load_impl(boost::intmax_t & l, char maxsize){
if(m_flags & endian_big)
#endif
reverse_bytes(size, cptr);

if(negative)
l = -l;
}

void
portable_binary_iarchive::load_override(
boost::archive::class_name_type & t, int
boost::archive::class_name_type & t
// breaking changes in boost >=1.59
#if BOOST_VERSION >= 105900
#else
, int
#endif
){
std::string cn;
cn.reserve(BOOST_SERIALIZATION_MAX_KEY_SIZE);
// breaking changes in boost >=1.59
#if BOOST_VERSION >= 105900
load_override(cn);
#else
load_override(cn, 0);
#endif
if(cn.size() > (BOOST_SERIALIZATION_MAX_KEY_SIZE - 1))
boost::serialization::throw_exception(
boost::archive::archive_exception(
Expand All @@ -72,7 +82,7 @@ portable_binary_iarchive::load_override(
t.t[cn.size()] = '\0';
}

void
void
portable_binary_iarchive::init(unsigned int flags){
if(0 == (flags & boost::archive::no_header)){
// read signature in an archive version independent manner
Expand All @@ -96,7 +106,7 @@ portable_binary_iarchive::init(unsigned int flags){
boost::archive::archive_exception::unsupported_version
)
);

#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205))
this->set_library_version(input_library_version);
//#else
Expand Down Expand Up @@ -127,7 +137,7 @@ namespace detail {

template class basic_binary_iprimitive<
portable_binary_iarchive,
std::istream::char_type,
std::istream::char_type,
std::istream::traits_type
> ;

Expand Down
Loading

0 comments on commit be6d8b5

Please sign in to comment.