Collage  0.6.1
dataStreamArchiveException.h
00001 
00002 /* Copyright (c) 2012, Daniel Nachbaur <danielnachbaur@googlemail.com>
00003  *
00004  * This library is free software; you can redistribute it and/or modify it under
00005  * the terms of the GNU Lesser General Public License version 2.1 as published
00006  * by the Free Software Foundation.
00007  *
00008  * This library is distributed in the hope that it will be useful, but WITHOUT
00009  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00010  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00011  * details.
00012  *
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this library; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00016  */
00017 
00018 #ifndef CO_DATASTREAMARCHIVEEXCEPTION_H
00019 #define CO_DATASTREAMARCHIVEEXCEPTION_H
00020 
00021 #include <boost/lexical_cast.hpp>
00022 #include <boost/archive/archive_exception.hpp>
00023 
00024 
00025 namespace co
00026 {
00027 
00028 // this value is written to the top of the stream
00029 const signed char magicByte = 'c' | 'o';
00030 
00031 // flag for fp serialization
00032 const unsigned no_infnan = 64;
00033 
00048 class DataStreamArchiveException : public boost::archive::archive_exception
00049 {
00050     std::string msg;
00051 
00052 public:
00054     DataStreamArchiveException(signed char invalid_size)
00055         : boost::archive::archive_exception(other_exception)
00056         , msg("requested integer size exceeds type size: ")
00057     {
00058         msg += boost::lexical_cast<std::string, int>(invalid_size);
00059     }
00060 
00062     DataStreamArchiveException()
00063         : boost::archive::archive_exception(other_exception)
00064         , msg("cannot read a negative number into an unsigned type")
00065     {
00066     }
00067 
00069     template <typename T>
00070     DataStreamArchiveException(const T& abnormal)
00071         : boost::archive::archive_exception(other_exception)
00072         , msg("serialization of illegal floating point value: ")
00073     {
00074         msg += boost::lexical_cast<std::string>(abnormal);
00075     }
00076 
00078     const char* what() const throw() { return msg.c_str(); }
00079     ~DataStreamArchiveException() throw() {}
00080 };
00081 
00082 }
00083 
00084 #endif //CO_DATAOSTREAMARCHIVE_H
Generated on Mon Nov 26 2012 14:41:44 for Collage 0.6.1 by  doxygen 1.7.6.1