| QxOrm 1.4.9 C++ Object Relational Mapping library

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Directories

- File List
- File Members

portable_archive_exception.hpp
Go to the documentation of this file.

    00001 /*****************************************************************************/
    00013 /****************************************************************************/
    00014
    00015 #ifdef _QX_ENABLE_BOOST_SERIALIZATION
    00016 #if _QX_SERIALIZE_PORTABLE_BINARY
    00017 #ifndef _QX_PORTABLE_ARCHIVE_EXCEPTION_H_
    00018 #define _QX_PORTABLE_ARCHIVE_EXCEPTION_H_
    00019
    00020 #ifdef _MSC_VER
    00021 #pragma once
    00022 #endif // _MSC_VER
    00023
    00024 #include <boost/lexical_cast.hpp>
    00025 #include <boost/archive/basic_archive.hpp>
    00026 #include <boost/archive/archive_exception.hpp>
    00027
    00028 namespace eos {
    00029
    00030         // this value is written to the top of the stream
    00031         const signed char magic_byte = 'e' | 'o' | 's';
    00032
    00033         // flag for fp serialization
    00034         const unsigned no_infnan = 64;
    00035
    00036         // integral type for the archive version
    00037         #if BOOST_VERSION < 104400
    00038                 typedef boost::archive::version_type archive_version_type;
    00039         #else
    00040                 typedef boost::archive::library_version_type archive_version_type;
    00041         #endif
    00042
    00043         // version of the linked boost archive library
    00044         const archive_version_type archive_version(
    00045         #if BOOST_VERSION < 103700
    00046                 boost::archive::ARCHIVE_VERSION()
    00047         #else
    00048                 boost::archive::BOOST_ARCHIVE_VERSION()
    00049         #endif
    00050         );
    00051
    00066         class portable_archive_exception : public boost::archive::archive_exception
    00067         {
    00068                 std::string msg;
    00069
    00070         public:
    00072                 portable_archive_exception(signed char invalid_size)
    00073                         : boost::archive::archive_exception(other_exception)
    00074                         , msg("requested integer size exceeds type size: ")
    00075                 {
    00076                         msg += boost::lexical_cast<std::string, int>(invalid_size);
    00077                 }
    00078
    00080                 portable_archive_exception()
    00081                         : boost::archive::archive_exception(other_exception)
    00082                         , msg("cannot read a negative number into an unsigned type")
    00083                 {
    00084                 }
    00085
    00087                 template <typename T>
    00088                 portable_archive_exception(const T& abnormal)
    00089                         : boost::archive::archive_exception(other_exception)
    00090                         , msg("serialization of illegal floating point value: ")
    00091                 {
    00092                         msg += boost::lexical_cast<std::string>(abnormal);
    00093                 }
    00094
    00096                 const char* what() const throw() { return msg.c_str(); }
    00097                 ~portable_archive_exception() throw() {}
    00098         };
    00099
    00100 } // namespace eos
    00101
    00102 #endif // _QX_PORTABLE_ARCHIVE_EXCEPTION_H_
    00103 #endif // _QX_SERIALIZE_PORTABLE_BINARY
    00104 #endif // _QX_ENABLE_BOOST_SERIALIZATION