Bayeux  3.4.1
Core Foundation library for SuperNEMO
portable_archive_exception.hpp
Go to the documentation of this file.
1 /*****************************************************************************/
13 /****************************************************************************/
14 
15 #pragma once
16 
17 #include <boost/lexical_cast.hpp>
18 #include <boost/archive/basic_archive.hpp>
19 #include <boost/archive/archive_exception.hpp>
20 
21 // hint from Johan Rade: on VMS there is still support for
22 // the VAX floating point format and this macro detects it
23 #if defined(__vms) && defined(__DECCXX) && !__IEEE_FLOAT
24 #error "VAX floating point format is not supported!"
25 #endif
26 
27 namespace boost {
28  namespace archive {
29 
30  // this value is written to the top of the stream
31  const signed char magic_byte = 127;
32 
33  // flag for fp serialization
34  const unsigned no_infnan = 64;
35 
36  // integral type for the archive version
37  typedef library_version_type archive_version_type;
38 
39  // version of the linked boost archive library
40  const archive_version_type archive_version(BOOST_ARCHIVE_VERSION());
41 
56  class portable_archive_exception : public archive_exception
57  {
58  std::string msg;
59 
60  public:
62  portable_archive_exception(signed char invalid_size)
63  : archive_exception(other_exception)
64  , msg("requested integer size exceeds type size: ")
65  {
66  msg += lexical_cast<std::string, int>(invalid_size);
67  }
68 
71  : archive_exception(other_exception)
72  , msg("cannot read a negative number into an unsigned type")
73  {
74  }
75 
77  template <typename T>
78  portable_archive_exception(const T& abnormal)
79  : archive_exception(other_exception)
80  , msg("serialization of illegal floating point value: ")
81  {
82  msg += lexical_cast<std::string>(abnormal);
83  }
84 
86  const char* what() const throw() { return msg.c_str(); }
88  };
89 
90  } // namespace archive
91 } // namespace boost
const archive_version_type archive_version(BOOST_ARCHIVE_VERSION())
const signed char magic_byte
Definition: portable_archive_exception.hpp:31
Serialization stuff for CLHEP 'vector_3d'.
Definition: portable_archive_exception.hpp:27
const char * what() const
override the base class function with our message
Definition: portable_archive_exception.hpp:86
portable_archive_exception()
negative number in unsigned type
Definition: portable_archive_exception.hpp:70
Exception being thrown when serialization cannot proceed.
Definition: portable_archive_exception.hpp:56
portable_archive_exception(signed char invalid_size)
type size is not large enough for deserialized number
Definition: portable_archive_exception.hpp:62
~portable_archive_exception()
Definition: portable_archive_exception.hpp:87
portable_archive_exception(const T &abnormal)
serialization of inf, nan and denormals
Definition: portable_archive_exception.hpp:78
const unsigned no_infnan
Definition: portable_archive_exception.hpp:34
library_version_type archive_version_type
Definition: portable_archive_exception.hpp:37