QxOrm 1.4.9
C++ Object Relational Mapping library
Loading...
Searching...
No Matches
portable_archive_exception.hpp
Go to the documentation of this file.
1/*****************************************************************************/
13/****************************************************************************/
14
15#ifdef _QX_ENABLE_BOOST_SERIALIZATION
16#if _QX_SERIALIZE_PORTABLE_BINARY
17#ifndef _QX_PORTABLE_ARCHIVE_EXCEPTION_H_
18#define _QX_PORTABLE_ARCHIVE_EXCEPTION_H_
19
20#ifdef _MSC_VER
21#pragma once
22#endif // _MSC_VER
23
24#include <boost/lexical_cast.hpp>
25#include <boost/archive/basic_archive.hpp>
26#include <boost/archive/archive_exception.hpp>
27
28namespace eos {
29
30 // this value is written to the top of the stream
31 const signed char magic_byte = 'e' | 'o' | 's';
32
33 // flag for fp serialization
34 const unsigned no_infnan = 64;
35
36 // integral type for the archive version
37 #if BOOST_VERSION < 104400
38 typedef boost::archive::version_type archive_version_type;
39 #else
40 typedef boost::archive::library_version_type archive_version_type;
41 #endif
42
43 // version of the linked boost archive library
45 #if BOOST_VERSION < 103700
46 boost::archive::ARCHIVE_VERSION()
47 #else
48 boost::archive::BOOST_ARCHIVE_VERSION()
49 #endif
50 );
51
66 class portable_archive_exception : public boost::archive::archive_exception
67 {
68 std::string msg;
69
70 public:
72 portable_archive_exception(signed char invalid_size)
73 : boost::archive::archive_exception(other_exception)
74 , msg("requested integer size exceeds type size: ")
75 {
76 msg += boost::lexical_cast<std::string, int>(invalid_size);
77 }
78
81 : boost::archive::archive_exception(other_exception)
82 , msg("cannot read a negative number into an unsigned type")
83 {
84 }
85
87 template <typename T>
88 portable_archive_exception(const T& abnormal)
89 : boost::archive::archive_exception(other_exception)
90 , msg("serialization of illegal floating point value: ")
91 {
92 msg += boost::lexical_cast<std::string>(abnormal);
93 }
94
96 const char* what() const throw() { return msg.c_str(); }
98 };
99
100} // namespace eos
101
102#endif // _QX_PORTABLE_ARCHIVE_EXCEPTION_H_
103#endif // _QX_SERIALIZE_PORTABLE_BINARY
104#endif // _QX_ENABLE_BOOST_SERIALIZATION
Exception being thrown when serialization cannot proceed.
portable_archive_exception(signed char invalid_size)
type size is not large enough for deserialized number
portable_archive_exception()
negative number in unsigned type
const char * what() const
override the base class function with our message
portable_archive_exception(const T &abnormal)
serialization of inf, nan and denormals
const unsigned no_infnan
const signed char magic_byte
boost::archive::version_type archive_version_type
const archive_version_type archive_version(boost::archive::ARCHIVE_VERSION())