Merge remote-tracking branch 'origin/master' into master-to-dev

This commit is contained in:
Jason Rhinelander 2020-09-21 19:09:14 -03:00
commit 23cecefe6f
5 changed files with 752 additions and 752 deletions

View File

@ -556,7 +556,7 @@ else()
set(WARNINGS "${WARNINGS} -Wno-error=inline-asm")
endif()
else()
set(WARNINGS "${WARNINGS} -Wlogical-op -Wno-error=maybe-uninitialized -Wno-error=cpp")
set(WARNINGS "${WARNINGS} -Wlogical-op -Wno-error=maybe-uninitialized -Wno-error=cpp -Wno-error=logical-op")
endif()
if(MINGW)
set(WARNINGS "${WARNINGS} -Wno-error=unused-value -Wno-error=unused-but-set-variable")

View File

@ -203,8 +203,8 @@ namespace tests
CHAIN_LEVIN_NOTIFY_TO_STUB(); //move levin_commands_handler interface notify(...) callbacks into nothing
BEGIN_INVOKE_MAP(test_levin_server)
HANDLE_INVOKE_T(COMMAND_EXAMPLE_1, &test_levin_server::handle_1)
HANDLE_INVOKE_T(COMMAND_EXAMPLE_2, &test_levin_server::handle_2)
HANDLE_INVOKE_T(COMMAND_EXAMPLE_1, handle_1)
HANDLE_INVOKE_T(COMMAND_EXAMPLE_2, handle_2)
END_INVOKE_MAP()
//----------------- commands handlers ----------------------------------------------

View File

@ -1,54 +1,54 @@
#ifndef PORTABLE_BINARY_ARCHIVE_HPP
#define PORTABLE_BINARY_ARCHIVE_HPP
// (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)
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
#include <boost/config.hpp>
#include <boost/cstdint.hpp>
#include <boost/static_assert.hpp>
#include <boost/archive/archive_exception.hpp>
#include <climits>
#include <utility>
#if CHAR_BIT != 8
#error This code assumes an eight-bit byte.
#endif
#include <boost/archive/basic_archive.hpp>
#include <boost/predef/other/endian.h>
#include <boost/archive/impl/archive_serializer_map.ipp>
namespace boost { namespace archive {
enum portable_binary_archive_flags {
endian_big = 0x4000,
endian_little = 0x8000
};
//#if ( endian_big <= boost::archive::flags_last )
//#error archive flags conflict
//#endif
inline void
reverse_bytes(signed char size, char *address){
if (size <= 0)
throw archive_exception(archive_exception::other_exception);
char * first = address;
char * last = first + size - 1;
for(;first < last;++first, --last){
std::swap(*first, *last);
}
}
} }
#endif // PORTABLE_BINARY_ARCHIVE_HPP
#ifndef PORTABLE_BINARY_ARCHIVE_HPP
#define PORTABLE_BINARY_ARCHIVE_HPP
// (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)
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
#include <boost/config.hpp>
#include <boost/cstdint.hpp>
#include <boost/static_assert.hpp>
#include <boost/archive/archive_exception.hpp>
#include <climits>
#include <utility>
#if CHAR_BIT != 8
#error This code assumes an eight-bit byte.
#endif
#include <boost/archive/basic_archive.hpp>
#include <boost/predef/other/endian.h>
#include <boost/archive/impl/archive_serializer_map.ipp>
namespace boost { namespace archive {
enum portable_binary_archive_flags {
endian_big = 0x4000,
endian_little = 0x8000
};
//#if ( endian_big <= boost::archive::flags_last )
//#error archive flags conflict
//#endif
inline void
reverse_bytes(signed char size, char *address){
if (size <= 0)
throw archive_exception(archive_exception::other_exception);
char * first = address;
char * last = first + size - 1;
for(;first < last;++first, --last){
std::swap(*first, *last);
}
}
} }
#endif // PORTABLE_BINARY_ARCHIVE_HPP

View File

@ -1,375 +1,375 @@
#ifndef PORTABLE_BINARY_IARCHIVE_HPP
#define PORTABLE_BINARY_IARCHIVE_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
#if defined(_MSC_VER)
#pragma warning( push )
#pragma warning( disable : 4244 )
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// portable_binary_iarchive.hpp
// (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)
// See http://www.boost.org for updates, documentation, and revision history.
#include <istream>
#include <boost/version.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/item_version_type.hpp>
#include <boost/archive/archive_exception.hpp>
#include <boost/archive/basic_binary_iprimitive.hpp>
#include <boost/archive/detail/common_iarchive.hpp>
#include <boost/archive/detail/register_archive.hpp>
#include <boost/archive/portable_binary_archive.hpp>
#include <boost/archive/impl/basic_binary_iprimitive.ipp>
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 :
public boost::archive::archive_exception
{
public:
enum exception_code {
incompatible_integer_size
} m_exception_code ;
portable_binary_iarchive_exception(exception_code c = incompatible_integer_size ) :
boost::archive::archive_exception(boost::archive::archive_exception::other_exception),
m_exception_code(c)
{}
virtual const char *what( ) const throw( )
{
const char *msg = "programmer error";
switch(m_exception_code){
case incompatible_integer_size:
msg = "integer cannot be represented";
break;
default:
msg = boost::archive::archive_exception::what();
assert(false);
break;
}
return msg;
}
};
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// "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::traits_type
>,
public boost::archive::detail::common_iarchive<
portable_binary_iarchive
>
{
typedef boost::archive::basic_binary_iprimitive<
portable_binary_iarchive,
std::istream::char_type,
std::istream::traits_type
> primitive_base_t;
typedef boost::archive::detail::common_iarchive<
portable_binary_iarchive
> archive_base_t;
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
public:
#else
friend archive_base_t;
friend primitive_base_t; // since with override load below
friend class boost::archive::detail::interface_iarchive<
portable_binary_iarchive
>;
friend class boost::archive::load_access;
protected:
#endif
unsigned int m_flags;
void load_impl(boost::intmax_t & l, char maxsize);
// default fall through for any types not specified here
template<class T>
void load(T & t){
boost::intmax_t l;
load_impl(l, sizeof(T));
// use cast to avoid compile time warning
//t = static_cast< T >(l);
t = T(l);
}
void load(boost::serialization::item_version_type & t){
boost::intmax_t l;
load_impl(l, sizeof(boost::serialization::item_version_type));
// use cast to avoid compile time warning
t = boost::serialization::item_version_type(l);
}
void load(boost::archive::version_type & t){
boost::intmax_t l;
load_impl(l, sizeof(boost::archive::version_type));
// use cast to avoid compile time warning
t = boost::archive::version_type(l);
}
void load(boost::archive::class_id_type & t){
boost::intmax_t l;
load_impl(l, sizeof(boost::archive::class_id_type));
// use cast to avoid compile time warning
t = boost::archive::class_id_type(static_cast<int>(l));
}
void load(std::string & t){
this->primitive_base_t::load(t);
}
#ifndef BOOST_NO_STD_WSTRING
void load(std::wstring & t){
this->primitive_base_t::load(t);
}
#endif
void load(float & t){
this->primitive_base_t::load(t);
// floats not supported
//BOOST_STATIC_ASSERT(false);
}
void load(double & t){
this->primitive_base_t::load(t);
// doubles not supported
//BOOST_STATIC_ASSERT(false);
}
void load(char & t){
this->primitive_base_t::load(t);
}
void load(unsigned char & t){
this->primitive_base_t::load(t);
}
typedef boost::archive::detail::common_iarchive<portable_binary_iarchive>
detail_common_iarchive;
#if BOOST_VERSION > 105800
template<class T>
void load_override(T & t){
this->detail_common_iarchive::load_override(t);
}
void load_override(boost::archive::class_name_type & t);
// binary files don't include the optional information
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);
public:
portable_binary_iarchive(std::istream & is, unsigned flags = 0) :
primitive_base_t(
* is.rdbuf(),
0 != (flags & boost::archive::no_codecvt)
),
archive_base_t(flags),
m_flags(0)
{
init(flags);
}
portable_binary_iarchive(
std::basic_streambuf<
std::istream::char_type,
std::istream::traits_type
> & bsb,
unsigned int flags
) :
primitive_base_t(
bsb,
0 != (flags & boost::archive::no_codecvt)
),
archive_base_t(flags),
m_flags(0)
{
init(flags);
}
};
} }
// required by export in boost version > 1.34
#ifdef BOOST_SERIALIZATION_REGISTER_ARCHIVE
BOOST_SERIALIZATION_REGISTER_ARCHIVE(portable_binary_iarchive)
#endif
// required by export in boost <= 1.34
#define BOOST_ARCHIVE_CUSTOM_IARCHIVE_TYPES portable_binary_iarchive
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// portable_binary_iarchive.cpp
// (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)
// See http://www.boost.org for updates, documentation, and revision history.
#include <istream>
#include <string>
#include <boost/predef/other/endian.h>
#include <boost/serialization/throw_exception.hpp>
#include <boost/archive/archive_exception.hpp>
namespace boost { namespace archive {
inline void
portable_binary_iarchive::load_impl(boost::intmax_t & l, char maxsize){
signed char size;
l = 0;
this->primitive_base_t::load(size);
if(0 == size){
return;
}
bool negative = (size < 0);
if(negative)
size = -size;
if(size > maxsize)
boost::serialization::throw_exception(
portable_binary_iarchive_exception()
);
char * cptr = reinterpret_cast<char *>(& l);
#if BOOST_ENDIAN_BIG_BYTE
cptr += (sizeof(boost::intmax_t) - size);
#endif
this->primitive_base_t::load_binary(cptr, size);
#if BOOST_ENDIAN_BIG_BYTE
if((m_flags & endian_little) || (!(m_flags & endian_big)))
#else
if(m_flags & endian_big)
#endif
reverse_bytes(size, cptr);
if(negative)
l = -l;
}
#if BOOST_VERSION > 105800
inline void
portable_binary_iarchive::load_override(
boost::archive::class_name_type & t
){
std::string cn;
cn.reserve(BOOST_SERIALIZATION_MAX_KEY_SIZE);
load_override(cn);
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';
}
#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
portable_binary_iarchive::init(unsigned int flags){
if(0 == (flags & boost::archive::no_header)){
// read signature in an archive version independent manner
std::string file_signature;
* this >> file_signature;
if(file_signature != boost::archive::BOOST_ARCHIVE_SIGNATURE())
boost::serialization::throw_exception(
boost::archive::archive_exception(
boost::archive::archive_exception::invalid_signature
)
);
// make sure the version of the reading archive library can
// support the format of the archive being read
boost::archive::library_version_type input_library_version;
* this >> input_library_version;
// ignore archive version checking
/*
// extra little .t is to get around borland quirk
if(boost::archive::BOOST_ARCHIVE_VERSION() < input_library_version)
boost::serialization::throw_exception(
boost::archive::archive_exception(
boost::archive::archive_exception::unsupported_version
)
);
*/
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205))
this->set_library_version(input_library_version);
//#else
//#if ! BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
//detail::
//#endif
boost::archive::detail::basic_iarchive::set_library_version(
input_library_version
);
#endif
}
if (!(m_flags & (endian_little | endian_big)))
m_flags |= endian_little;
unsigned char x;
load(x);
m_flags = x << CHAR_BIT;
}
} }
namespace boost {
namespace archive {
namespace detail {
template class archive_serializer_map<portable_binary_iarchive>;
}
// template class basic_binary_iprimitive<
// portable_binary_iarchive,
// std::istream::char_type,
// std::istream::traits_type
//> ;
} // namespace archive
} // namespace boost
#if defined(_MSC_VER)
#pragma warning( pop )
#endif
#endif // PORTABLE_BINARY_IARCHIVE_HPP
#ifndef PORTABLE_BINARY_IARCHIVE_HPP
#define PORTABLE_BINARY_IARCHIVE_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
#if defined(_MSC_VER)
#pragma warning( push )
#pragma warning( disable : 4244 )
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// portable_binary_iarchive.hpp
// (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)
// See http://www.boost.org for updates, documentation, and revision history.
#include <istream>
#include <boost/version.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/item_version_type.hpp>
#include <boost/archive/archive_exception.hpp>
#include <boost/archive/basic_binary_iprimitive.hpp>
#include <boost/archive/detail/common_iarchive.hpp>
#include <boost/archive/detail/register_archive.hpp>
#include <boost/archive/portable_binary_archive.hpp>
#include <boost/archive/impl/basic_binary_iprimitive.ipp>
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 :
public boost::archive::archive_exception
{
public:
enum exception_code {
incompatible_integer_size
} m_exception_code ;
portable_binary_iarchive_exception(exception_code c = incompatible_integer_size ) :
boost::archive::archive_exception(boost::archive::archive_exception::other_exception),
m_exception_code(c)
{}
virtual const char *what( ) const throw( )
{
const char *msg = "programmer error";
switch(m_exception_code){
case incompatible_integer_size:
msg = "integer cannot be represented";
break;
default:
msg = boost::archive::archive_exception::what();
assert(false);
break;
}
return msg;
}
};
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// "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::traits_type
>,
public boost::archive::detail::common_iarchive<
portable_binary_iarchive
>
{
typedef boost::archive::basic_binary_iprimitive<
portable_binary_iarchive,
std::istream::char_type,
std::istream::traits_type
> primitive_base_t;
typedef boost::archive::detail::common_iarchive<
portable_binary_iarchive
> archive_base_t;
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
public:
#else
friend archive_base_t;
friend primitive_base_t; // since with override load below
friend class boost::archive::detail::interface_iarchive<
portable_binary_iarchive
>;
friend class boost::archive::load_access;
protected:
#endif
unsigned int m_flags;
void load_impl(boost::intmax_t & l, char maxsize);
// default fall through for any types not specified here
template<class T>
void load(T & t){
boost::intmax_t l;
load_impl(l, sizeof(T));
// use cast to avoid compile time warning
//t = static_cast< T >(l);
t = T(l);
}
void load(boost::serialization::item_version_type & t){
boost::intmax_t l;
load_impl(l, sizeof(boost::serialization::item_version_type));
// use cast to avoid compile time warning
t = boost::serialization::item_version_type(l);
}
void load(boost::archive::version_type & t){
boost::intmax_t l;
load_impl(l, sizeof(boost::archive::version_type));
// use cast to avoid compile time warning
t = boost::archive::version_type(l);
}
void load(boost::archive::class_id_type & t){
boost::intmax_t l;
load_impl(l, sizeof(boost::archive::class_id_type));
// use cast to avoid compile time warning
t = boost::archive::class_id_type(static_cast<int>(l));
}
void load(std::string & t){
this->primitive_base_t::load(t);
}
#ifndef BOOST_NO_STD_WSTRING
void load(std::wstring & t){
this->primitive_base_t::load(t);
}
#endif
void load(float & t){
this->primitive_base_t::load(t);
// floats not supported
//BOOST_STATIC_ASSERT(false);
}
void load(double & t){
this->primitive_base_t::load(t);
// doubles not supported
//BOOST_STATIC_ASSERT(false);
}
void load(char & t){
this->primitive_base_t::load(t);
}
void load(unsigned char & t){
this->primitive_base_t::load(t);
}
typedef boost::archive::detail::common_iarchive<portable_binary_iarchive>
detail_common_iarchive;
#if BOOST_VERSION > 105800
template<class T>
void load_override(T & t){
this->detail_common_iarchive::load_override(t);
}
void load_override(boost::archive::class_name_type & t);
// binary files don't include the optional information
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);
public:
portable_binary_iarchive(std::istream & is, unsigned flags = 0) :
primitive_base_t(
* is.rdbuf(),
0 != (flags & boost::archive::no_codecvt)
),
archive_base_t(flags),
m_flags(0)
{
init(flags);
}
portable_binary_iarchive(
std::basic_streambuf<
std::istream::char_type,
std::istream::traits_type
> & bsb,
unsigned int flags
) :
primitive_base_t(
bsb,
0 != (flags & boost::archive::no_codecvt)
),
archive_base_t(flags),
m_flags(0)
{
init(flags);
}
};
} }
// required by export in boost version > 1.34
#ifdef BOOST_SERIALIZATION_REGISTER_ARCHIVE
BOOST_SERIALIZATION_REGISTER_ARCHIVE(portable_binary_iarchive)
#endif
// required by export in boost <= 1.34
#define BOOST_ARCHIVE_CUSTOM_IARCHIVE_TYPES portable_binary_iarchive
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// portable_binary_iarchive.cpp
// (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)
// See http://www.boost.org for updates, documentation, and revision history.
#include <istream>
#include <string>
#include <boost/predef/other/endian.h>
#include <boost/serialization/throw_exception.hpp>
#include <boost/archive/archive_exception.hpp>
namespace boost { namespace archive {
inline void
portable_binary_iarchive::load_impl(boost::intmax_t & l, char maxsize){
signed char size;
l = 0;
this->primitive_base_t::load(size);
if(0 == size){
return;
}
bool negative = (size < 0);
if(negative)
size = -size;
if(size > maxsize)
boost::serialization::throw_exception(
portable_binary_iarchive_exception()
);
char * cptr = reinterpret_cast<char *>(& l);
#if BOOST_ENDIAN_BIG_BYTE
cptr += (sizeof(boost::intmax_t) - size);
#endif
this->primitive_base_t::load_binary(cptr, size);
#if BOOST_ENDIAN_BIG_BYTE
if((m_flags & endian_little) || (!(m_flags & endian_big)))
#else
if(m_flags & endian_big)
#endif
reverse_bytes(size, cptr);
if(negative)
l = -l;
}
#if BOOST_VERSION > 105800
inline void
portable_binary_iarchive::load_override(
boost::archive::class_name_type & t
){
std::string cn;
cn.reserve(BOOST_SERIALIZATION_MAX_KEY_SIZE);
load_override(cn);
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';
}
#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
portable_binary_iarchive::init(unsigned int flags){
if(0 == (flags & boost::archive::no_header)){
// read signature in an archive version independent manner
std::string file_signature;
* this >> file_signature;
if(file_signature != boost::archive::BOOST_ARCHIVE_SIGNATURE())
boost::serialization::throw_exception(
boost::archive::archive_exception(
boost::archive::archive_exception::invalid_signature
)
);
// make sure the version of the reading archive library can
// support the format of the archive being read
boost::archive::library_version_type input_library_version;
* this >> input_library_version;
// ignore archive version checking
/*
// extra little .t is to get around borland quirk
if(boost::archive::BOOST_ARCHIVE_VERSION() < input_library_version)
boost::serialization::throw_exception(
boost::archive::archive_exception(
boost::archive::archive_exception::unsupported_version
)
);
*/
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205))
this->set_library_version(input_library_version);
//#else
//#if ! BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
//detail::
//#endif
boost::archive::detail::basic_iarchive::set_library_version(
input_library_version
);
#endif
}
if (!(m_flags & (endian_little | endian_big)))
m_flags |= endian_little;
unsigned char x;
load(x);
m_flags = x << CHAR_BIT;
}
} }
namespace boost {
namespace archive {
namespace detail {
template class archive_serializer_map<portable_binary_iarchive>;
}
// template class basic_binary_iprimitive<
// portable_binary_iarchive,
// std::istream::char_type,
// std::istream::traits_type
//> ;
} // namespace archive
} // namespace boost
#if defined(_MSC_VER)
#pragma warning( pop )
#endif
#endif // PORTABLE_BINARY_IARCHIVE_HPP

View File

@ -1,320 +1,320 @@
#ifndef PORTABLE_BINARY_OARCHIVE_HPP
#define PORTABLE_BINARY_OARCHIVE_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
#if defined(_MSC_VER)
#pragma warning( push )
#pragma warning( disable : 4244 )
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// portable_binary_oarchive.hpp
// (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)
// See http://www.boost.org for updates, documentation, and revision history.
#include <ostream>
#include <boost/version.hpp>
#include <boost/serialization/string.hpp>
#include <boost/archive/archive_exception.hpp>
#include <boost/archive/basic_binary_oprimitive.hpp>
#include <boost/archive/detail/common_oarchive.hpp>
#include <boost/archive/detail/register_archive.hpp>
#include <boost/archive/portable_binary_archive.hpp>
#include <boost/archive/impl/basic_binary_oprimitive.ipp>
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 :
public boost::archive::archive_exception
{
public:
enum exception_code {
invalid_flags
} m_exception_code ;
portable_binary_oarchive_exception(exception_code c = invalid_flags ) :
boost::archive::archive_exception(boost::archive::archive_exception::other_exception),
m_exception_code(c)
{}
virtual const char *what( ) const throw( )
{
const char *msg = "programmer error";
switch(m_exception_code){
case invalid_flags:
msg = "cannot be both big and little endian";
break;
default:
msg = boost::archive::archive_exception::what();
assert(false);
break;
}
return msg;
}
};
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// "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::traits_type
>,
public boost::archive::detail::common_oarchive<
portable_binary_oarchive
>
{
typedef boost::archive::basic_binary_oprimitive<
portable_binary_oarchive,
std::ostream::char_type,
std::ostream::traits_type
> primitive_base_t;
typedef boost::archive::detail::common_oarchive<
portable_binary_oarchive
> archive_base_t;
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
public:
#else
friend archive_base_t;
friend primitive_base_t; // since with override save below
friend class boost::archive::detail::interface_oarchive<
portable_binary_oarchive
>;
friend class boost::archive::save_access;
protected:
#endif
unsigned int m_flags;
void save_impl(const boost::intmax_t l, const char maxsize);
// add base class to the places considered when matching
// save function to a specific set of arguments. Note, this didn't
// work on my MSVC 7.0 system so we use the sure-fire method below
// using archive_base_t::save;
// default fall through for any types not specified here
template<class T>
void save(const T & t){
save_impl(t, sizeof(T));
}
void save(const std::string & t){
this->primitive_base_t::save(t);
}
#ifndef BOOST_NO_STD_WSTRING
void save(const std::wstring & t){
this->primitive_base_t::save(t);
}
#endif
void save(const float & t){
this->primitive_base_t::save(t);
// floats not supported
//BOOST_STATIC_ASSERT(false);
}
void save(const double & t){
this->primitive_base_t::save(t);
// doubles not supported
//BOOST_STATIC_ASSERT(false);
}
void save(const char & t){
this->primitive_base_t::save(t);
}
void save(const unsigned char & t){
this->primitive_base_t::save(t);
}
// 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>
detail_common_oarchive;
#if BOOST_VERSION > 105800
template<class T>
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
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);
public:
portable_binary_oarchive(std::ostream & os, unsigned flags = endian_little) :
primitive_base_t(
* os.rdbuf(),
0 != (flags & boost::archive::no_codecvt)
),
archive_base_t(flags),
m_flags(flags & (endian_big | endian_little))
{
init(flags);
}
portable_binary_oarchive(
std::basic_streambuf<
std::ostream::char_type,
std::ostream::traits_type
> & bsb,
unsigned int flags
) :
primitive_base_t(
bsb,
0 != (flags & boost::archive::no_codecvt)
),
archive_base_t(flags),
m_flags(0)
{
init(flags);
}
};
} }
// required by export in boost version > 1.34
#ifdef BOOST_SERIALIZATION_REGISTER_ARCHIVE
BOOST_SERIALIZATION_REGISTER_ARCHIVE(portable_binary_oarchive)
#endif
// required by export in boost <= 1.34
#define BOOST_ARCHIVE_CUSTOM_OARCHIVE_TYPES portable_binary_oarchive
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// portable_binary_oarchive.cpp
// (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)
// See http://www.boost.org for updates, documentation, and revision history.
#include <ostream>
#include <boost/predef/other/endian.h>
namespace boost { namespace archive {
inline void
portable_binary_oarchive::save_impl(
const boost::intmax_t l,
const char maxsize
){
signed char size = 0;
if(l == 0){
this->primitive_base_t::save(size);
return;
}
boost::intmax_t ll;
bool negative = (l < 0);
if(negative)
ll = -l;
else
ll = l;
do{
ll >>= CHAR_BIT;
++size;
}while(ll != 0);
this->primitive_base_t::save(
static_cast<signed char>(negative ? -size : size)
);
if(negative)
ll = -l;
else
ll = l;
char * cptr = reinterpret_cast<char *>(& ll);
#if BOOST_ENDIAN_BIG_BYTE
cptr += (sizeof(boost::intmax_t) - size);
if(m_flags & endian_little)
reverse_bytes(size, cptr);
#else
if(m_flags & endian_big)
reverse_bytes(size, cptr);
#endif
this->primitive_base_t::save_binary(cptr, size);
}
inline void
portable_binary_oarchive::init(unsigned int flags) {
if(m_flags == (endian_big | endian_little)){
boost::serialization::throw_exception(
portable_binary_oarchive_exception()
);
}
if(0 == (flags & boost::archive::no_header)){
// write signature in an archive version independent manner
const std::string file_signature(
boost::archive::BOOST_ARCHIVE_SIGNATURE()
);
* this << file_signature;
// ignore archive version checking
const boost::archive::library_version_type v{};
/*
// write library version
const boost::archive::library_version_type v(
boost::archive::BOOST_ARCHIVE_VERSION()
);
*/
* this << v;
}
save(static_cast<unsigned char>(m_flags >> CHAR_BIT));
}
} }
namespace boost {
namespace archive {
namespace detail {
template class archive_serializer_map<portable_binary_oarchive>;
}
// template class basic_binary_oprimitive<
// portable_binary_oarchive,
// std::ostream::char_type,
// std::ostream::traits_type
// > ;
} // namespace archive
} // namespace boost
#if defined(_MSC_VER)
#pragma warning( pop )
#endif
#endif // PORTABLE_BINARY_OARCHIVE_HPP
#ifndef PORTABLE_BINARY_OARCHIVE_HPP
#define PORTABLE_BINARY_OARCHIVE_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
#if defined(_MSC_VER)
#pragma warning( push )
#pragma warning( disable : 4244 )
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// portable_binary_oarchive.hpp
// (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)
// See http://www.boost.org for updates, documentation, and revision history.
#include <ostream>
#include <boost/version.hpp>
#include <boost/serialization/string.hpp>
#include <boost/archive/archive_exception.hpp>
#include <boost/archive/basic_binary_oprimitive.hpp>
#include <boost/archive/detail/common_oarchive.hpp>
#include <boost/archive/detail/register_archive.hpp>
#include <boost/archive/portable_binary_archive.hpp>
#include <boost/archive/impl/basic_binary_oprimitive.ipp>
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 :
public boost::archive::archive_exception
{
public:
enum exception_code {
invalid_flags
} m_exception_code ;
portable_binary_oarchive_exception(exception_code c = invalid_flags ) :
boost::archive::archive_exception(boost::archive::archive_exception::other_exception),
m_exception_code(c)
{}
virtual const char *what( ) const throw( )
{
const char *msg = "programmer error";
switch(m_exception_code){
case invalid_flags:
msg = "cannot be both big and little endian";
break;
default:
msg = boost::archive::archive_exception::what();
assert(false);
break;
}
return msg;
}
};
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// "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::traits_type
>,
public boost::archive::detail::common_oarchive<
portable_binary_oarchive
>
{
typedef boost::archive::basic_binary_oprimitive<
portable_binary_oarchive,
std::ostream::char_type,
std::ostream::traits_type
> primitive_base_t;
typedef boost::archive::detail::common_oarchive<
portable_binary_oarchive
> archive_base_t;
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
public:
#else
friend archive_base_t;
friend primitive_base_t; // since with override save below
friend class boost::archive::detail::interface_oarchive<
portable_binary_oarchive
>;
friend class boost::archive::save_access;
protected:
#endif
unsigned int m_flags;
void save_impl(const boost::intmax_t l, const char maxsize);
// add base class to the places considered when matching
// save function to a specific set of arguments. Note, this didn't
// work on my MSVC 7.0 system so we use the sure-fire method below
// using archive_base_t::save;
// default fall through for any types not specified here
template<class T>
void save(const T & t){
save_impl(t, sizeof(T));
}
void save(const std::string & t){
this->primitive_base_t::save(t);
}
#ifndef BOOST_NO_STD_WSTRING
void save(const std::wstring & t){
this->primitive_base_t::save(t);
}
#endif
void save(const float & t){
this->primitive_base_t::save(t);
// floats not supported
//BOOST_STATIC_ASSERT(false);
}
void save(const double & t){
this->primitive_base_t::save(t);
// doubles not supported
//BOOST_STATIC_ASSERT(false);
}
void save(const char & t){
this->primitive_base_t::save(t);
}
void save(const unsigned char & t){
this->primitive_base_t::save(t);
}
// 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>
detail_common_oarchive;
#if BOOST_VERSION > 105800
template<class T>
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
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);
public:
portable_binary_oarchive(std::ostream & os, unsigned flags = endian_little) :
primitive_base_t(
* os.rdbuf(),
0 != (flags & boost::archive::no_codecvt)
),
archive_base_t(flags),
m_flags(flags & (endian_big | endian_little))
{
init(flags);
}
portable_binary_oarchive(
std::basic_streambuf<
std::ostream::char_type,
std::ostream::traits_type
> & bsb,
unsigned int flags
) :
primitive_base_t(
bsb,
0 != (flags & boost::archive::no_codecvt)
),
archive_base_t(flags),
m_flags(0)
{
init(flags);
}
};
} }
// required by export in boost version > 1.34
#ifdef BOOST_SERIALIZATION_REGISTER_ARCHIVE
BOOST_SERIALIZATION_REGISTER_ARCHIVE(portable_binary_oarchive)
#endif
// required by export in boost <= 1.34
#define BOOST_ARCHIVE_CUSTOM_OARCHIVE_TYPES portable_binary_oarchive
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// portable_binary_oarchive.cpp
// (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)
// See http://www.boost.org for updates, documentation, and revision history.
#include <ostream>
#include <boost/predef/other/endian.h>
namespace boost { namespace archive {
inline void
portable_binary_oarchive::save_impl(
const boost::intmax_t l,
const char maxsize
){
signed char size = 0;
if(l == 0){
this->primitive_base_t::save(size);
return;
}
boost::intmax_t ll;
bool negative = (l < 0);
if(negative)
ll = -l;
else
ll = l;
do{
ll >>= CHAR_BIT;
++size;
}while(ll != 0);
this->primitive_base_t::save(
static_cast<signed char>(negative ? -size : size)
);
if(negative)
ll = -l;
else
ll = l;
char * cptr = reinterpret_cast<char *>(& ll);
#if BOOST_ENDIAN_BIG_BYTE
cptr += (sizeof(boost::intmax_t) - size);
if(m_flags & endian_little)
reverse_bytes(size, cptr);
#else
if(m_flags & endian_big)
reverse_bytes(size, cptr);
#endif
this->primitive_base_t::save_binary(cptr, size);
}
inline void
portable_binary_oarchive::init(unsigned int flags) {
if(m_flags == (endian_big | endian_little)){
boost::serialization::throw_exception(
portable_binary_oarchive_exception()
);
}
if(0 == (flags & boost::archive::no_header)){
// write signature in an archive version independent manner
const std::string file_signature(
boost::archive::BOOST_ARCHIVE_SIGNATURE()
);
* this << file_signature;
// ignore archive version checking
const boost::archive::library_version_type v{};
/*
// write library version
const boost::archive::library_version_type v(
boost::archive::BOOST_ARCHIVE_VERSION()
);
*/
* this << v;
}
save(static_cast<unsigned char>(m_flags >> CHAR_BIT));
}
} }
namespace boost {
namespace archive {
namespace detail {
template class archive_serializer_map<portable_binary_oarchive>;
}
// template class basic_binary_oprimitive<
// portable_binary_oarchive,
// std::ostream::char_type,
// std::ostream::traits_type
// > ;
} // namespace archive
} // namespace boost
#if defined(_MSC_VER)
#pragma warning( pop )
#endif
#endif // PORTABLE_BINARY_OARCHIVE_HPP