![]() |
QxOrm
1.4.2
C++ Object Relational Mapping library
|
00001 #ifdef _QX_ENABLE_BOOST_SERIALIZATION 00002 #if _QX_SERIALIZE_PORTABLE_BINARY 00003 #ifndef _QX_PORTABLE_ARCHIVE_EXCEPTION_H_ 00004 #define _QX_PORTABLE_ARCHIVE_EXCEPTION_H_ 00005 00006 #ifdef _MSC_VER 00007 #pragma once 00008 #endif // _MSC_VER 00009 00010 #include <boost/lexical_cast.hpp> 00011 #include <boost/archive/basic_archive.hpp> 00012 #include <boost/archive/archive_exception.hpp> 00013 00014 namespace eos { 00015 00016 // this value is written to the top of the stream 00017 const signed char magic_byte = 'e' | 'o' | 's'; 00018 00019 // version of the linked boost archive library 00020 const boost::archive::version_type archive_version( 00021 #if BOOST_VERSION < 103700 00022 boost::archive::ARCHIVE_VERSION() 00023 #else 00024 boost::archive::BOOST_ARCHIVE_VERSION() 00025 #endif 00026 ); 00027 00042 class portable_archive_exception : public boost::archive::archive_exception 00043 { 00044 std::string msg; 00045 00046 public: 00047 00049 portable_archive_exception(signed char invalid_size) : boost::archive::archive_exception(other_exception), msg("requested integer size exceeds type size: ") 00050 { 00051 msg += boost::lexical_cast<std::string, int>(invalid_size); 00052 } 00053 00055 portable_archive_exception() : boost::archive::archive_exception(other_exception), msg("cannot read a negative number into an unsigned type") { ; } 00056 00058 template <typename T> 00059 portable_archive_exception(const T& abnormal) : boost::archive::archive_exception(other_exception), msg("serialization of non-portable floating point value: ") 00060 { 00061 msg += boost::lexical_cast<std::string>(abnormal); 00062 } 00063 00065 const char* what() const throw() { return msg.c_str(); } 00066 ~portable_archive_exception() throw() { ; } 00067 }; 00068 00069 } // namespace eos 00070 00071 #endif // _QX_PORTABLE_ARCHIVE_EXCEPTION_H_ 00072 #endif // _QX_SERIALIZE_PORTABLE_BINARY 00073 #endif // _QX_ENABLE_BOOST_SERIALIZATION