Collage  1.5.0
High-performance C++ library for developing object-oriented distributed applications.
dataStreamArchiveException.h
1 
2 /* Copyright (c) 2012, Daniel Nachbaur <danielnachbaur@googlemail.com>
3  *
4  * This file is part of Collage <https://github.com/Eyescale/Collage>
5  *
6  * This library is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License version 2.1 as published
8  * by the Free Software Foundation.
9  *
10  * This library is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef CO_DATASTREAMARCHIVEEXCEPTION_H
21 #define CO_DATASTREAMARCHIVEEXCEPTION_H
22 
23 #include <boost/lexical_cast.hpp>
24 #include <boost/archive/archive_exception.hpp>
25 
26 
27 namespace co
28 {
29 namespace serialization
30 {
31 // @internal flag for fp serialization
32 const unsigned no_infnan = 64;
33 }
34 
49 class DataStreamArchiveException : public boost::archive::archive_exception
50 {
51  std::string msg;
52 
53 public:
55  explicit DataStreamArchiveException( const signed char invalid_size )
56  : boost::archive::archive_exception(other_exception)
57  , msg("requested integer size exceeds type size: ")
58  {
59  msg += boost::lexical_cast<std::string, int>(invalid_size);
60  }
61 
64  : boost::archive::archive_exception(other_exception)
65  , msg("cannot read a negative number into an unsigned type")
66  {
67  }
68 
70  template <typename T>
71  explicit DataStreamArchiveException( const T& abnormal )
72  : boost::archive::archive_exception(other_exception)
73  , msg("serialization of illegal floating point value: ")
74  {
75  msg += boost::lexical_cast<std::string>(abnormal);
76  }
77 
79  const char* what() const throw() { return msg.c_str(); }
80  ~DataStreamArchiveException() throw() {}
81 };
82 
83 }
84 
85 #endif //CO_DATAOSTREAMARCHIVE_H
Object-oriented network library.
Definition: barrier.h:27
DataStreamArchiveException(const T &abnormal)
serialization of inf, nan and denormals
DataStreamArchiveException()
negative number in unsigned type
DataStreamArchiveException(const signed char invalid_size)
type size is not large enough for deserialized number
Exception thrown when serialization cannot proceed.
const char * what() const
override the base class function with our message