Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portable binary archive #38

Open
wants to merge 5 commits into
base: portable_binary_archive
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ SOURCES =
extended_type_info_no_rtti
polymorphic_iarchive
polymorphic_oarchive
portable_iarchive
portable_oarchive
stl_port
text_iarchive
text_oarchive
Expand Down
35 changes: 0 additions & 35 deletions include/boost/archive/portable_archive.hpp

This file was deleted.

122 changes: 60 additions & 62 deletions include/boost/archive/portable_archive_exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,76 +18,74 @@
#include <boost/archive/basic_archive.hpp>
#include <boost/archive/archive_exception.hpp>

namespace eos {
// hint from Johan Rade: on VMS there is still support for
// the VAX floating point format and this macro detects it
#if defined(__vms) && defined(__DECCXX) && !__IEEE_FLOAT
#error "VAX floating point format is not supported!"
#endif

// this value is written to the top of the stream
const signed char magic_byte = 'e' | 'o' | 's';
namespace boost {
namespace archive {

// flag for fp serialization
const unsigned no_infnan = 64;
// this value is written to the top of the stream
const signed char magic_byte = 127;

// integral type for the archive version
#if BOOST_VERSION < 104400
typedef boost::archive::version_type archive_version_type;
#else
typedef boost::archive::library_version_type archive_version_type;
#endif
// flag for fp serialization
const unsigned no_infnan = 64;

// version of the linked boost archive library
const archive_version_type archive_version(
#if BOOST_VERSION < 103700
boost::archive::ARCHIVE_VERSION()
#else
boost::archive::BOOST_ARCHIVE_VERSION()
#endif
);
// integral type for the archive version
typedef library_version_type archive_version_type;

/**
* \brief Exception being thrown when serialization cannot proceed.
*
* There are several situations in which the portable archives may fail and
* hence throw an exception:
* -# deserialization of an integer value that exceeds the range of the type
* -# (de)serialization of inf/nan through an archive with no_infnan flag set
* -# deserialization of a denormalized value without the floating point type
* supporting denormalized numbers
*
* Note that this exception will also be thrown if you mixed up your stream
* position and accidentially interpret some value for size data (in this case
* the reported size will be totally amiss most of the time).
*/
class portable_archive_exception : public boost::archive::archive_exception
{
std::string msg;
// version of the linked boost archive library
const archive_version_type archive_version(BOOST_ARCHIVE_VERSION());

public:
//! type size is not large enough for deserialized number
portable_archive_exception(signed char invalid_size)
: boost::archive::archive_exception(other_exception)
, msg("requested integer size exceeds type size: ")
/**
* \brief Exception being thrown when serialization cannot proceed.
*
* There are several situations in which the portable archives may fail and
* hence throw an exception:
* -# deserialization of an integer value that exceeds the range of the type
* -# (de)serialization of inf/nan through an archive with no_infnan flag set
* -# deserialization of a denormalized value without the floating point type
* supporting denormalized numbers
*
* Note that this exception will also be thrown if you mixed up your stream
* position and accidentially interpret some value for size data (in this case
* the reported size will be totally amiss most of the time).
*/
class portable_archive_exception : public archive_exception
{
msg += boost::lexical_cast<std::string, int>(invalid_size);
}
std::string msg;

//! negative number in unsigned type
portable_archive_exception()
: boost::archive::archive_exception(other_exception)
, msg("cannot read a negative number into an unsigned type")
{
}
public:
//! type size is not large enough for deserialized number
portable_archive_exception(signed char invalid_size)
: archive_exception(other_exception)
, msg("requested integer size exceeds type size: ")
{
msg += lexical_cast<std::string, int>(invalid_size);
}

//! serialization of inf, nan and denormals
template <typename T>
portable_archive_exception(const T& abnormal)
: boost::archive::archive_exception(other_exception)
, msg("serialization of illegal floating point value: ")
{
msg += boost::lexical_cast<std::string>(abnormal);
}
//! negative number in unsigned type
portable_archive_exception()
: archive_exception(other_exception)
, msg("cannot read a negative number into an unsigned type")
{
}

//! serialization of inf, nan and denormals
template <typename T>
portable_archive_exception(const T& abnormal)
: archive_exception(other_exception)
, msg("serialization of illegal floating point value: ")
{
msg += lexical_cast<std::string>(abnormal);
}

//! override the base class function with our message
const char* what() const throw() { return msg.c_str(); }
~portable_archive_exception() throw() {}
};
//! override the base class function with our message
const char* what() const throw() { return msg.c_str(); }
~portable_archive_exception() throw() {}
};

} // namespace eos
} // namespace archive
} // namespace boost
Loading