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