Intra2net AG

t2n_exception.hxx

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2006 by Intra2net AG - Gerd v. Egidy
00003 
00004 The software in this package is distributed under the GNU General
00005 Public License version 2 (with a special exception described below).
00006 
00007 A copy of GNU General Public License (GPL) is included in this distribution,
00008 in the file COPYING.GPL.
00009 
00010 As a special exception, if other files instantiate templates or use macros
00011 or inline functions from this file, or you compile this file and link it
00012 with other works to produce a work based on this file, this file
00013 does not by itself cause the resulting work to be covered
00014 by the GNU General Public License.
00015 
00016 However the source code for this file must still be made available
00017 in accordance with section (3) of the GNU General Public License.
00018 
00019 This exception does not invalidate any other reasons why a work based
00020 on this file might be covered by the GNU General Public License.
00021 */
00022 #ifndef __LIBT2N_T2N_EXCEPTION
00023 #define __LIBT2N_T2N_EXCEPTION
00024 
00025 #include <stdexcept>
00026 #include <string>
00027 
00028 #include <boost/serialization/serialization.hpp>
00029 
00030 namespace boost {
00031 namespace serialization {
00032 
00033 // make std::exception serializable
00034 template<class Archive>
00035 void serialize(Archive & ar, std::exception & g, const unsigned int version)
00036 {
00037 }
00038 
00039 } // namespace serialization
00040 } // namespace boost
00041 
00042 namespace libt2n
00043 {
00048 class t2n_exception : public std::exception
00049 {
00050     private:
00051         std::string message;
00052 
00053         friend class boost::serialization::access;
00054         template<class Archive>
00055         void serialize(Archive & ar, const unsigned int version);
00056 
00057     public:
00058         t2n_exception(const std::string& _message)
00059             { message=_message; }
00060 
00061         t2n_exception()
00062             { }
00063 
00064         virtual const char* what() const throw()
00065             { return message.c_str(); }
00066 
00067         virtual t2n_exception* clone() const
00068             { return new t2n_exception(*this); }
00069 
00070         virtual ~t2n_exception() throw()
00071             {}
00072 
00073         virtual void do_throw()
00074             { throw *this; }
00075 };
00076 
00078 class t2n_communication_error : public t2n_exception
00079 {
00080     private:
00081         friend class boost::serialization::access;
00082         template<class Archive>
00083         void serialize(Archive & ar, const unsigned int version);
00084 
00085     public:
00086         t2n_communication_error(const std::string& _message)
00087             : t2n_exception(_message)
00088             { }
00089 
00090         t2n_communication_error()
00091             { }
00092 
00093         t2n_exception* clone() const
00094             { return new t2n_communication_error(*this); }
00095 
00096         void do_throw()
00097             { throw *this; }
00098 };
00099 
00101 class t2n_connect_error : public t2n_communication_error
00102 {
00103     private:
00104         friend class boost::serialization::access;
00105         template<class Archive>
00106         void serialize(Archive & ar, const unsigned int version);
00107 
00108     public:
00109         t2n_connect_error(const std::string& _message)
00110             : t2n_communication_error(_message)
00111             { }
00112 
00113         t2n_connect_error()
00114             { }
00115 
00116         t2n_exception* clone() const
00117             { return new t2n_connect_error(*this); }
00118 
00119         void do_throw()
00120             { throw *this; }
00121 };
00122 
00124 class t2n_server_error : public t2n_communication_error
00125 {
00126     private:
00127         friend class boost::serialization::access;
00128         template<class Archive>
00129         void serialize(Archive & ar, const unsigned int version);
00130 
00131     public:
00132         t2n_server_error(const std::string& _message)
00133             : t2n_communication_error(_message)
00134             { }
00135 
00136         t2n_server_error()
00137             { }
00138 
00139         t2n_exception* clone() const
00140             { return new t2n_server_error(*this); }
00141 
00142         void do_throw()
00143             { throw *this; }
00144 };
00145 
00147 class t2n_transfer_error : public t2n_communication_error
00148 {
00149     private:
00150         friend class boost::serialization::access;
00151         template<class Archive>
00152         void serialize(Archive & ar, const unsigned int version);
00153 
00154     public:
00155         t2n_transfer_error(const std::string& _message)
00156             : t2n_communication_error(_message)
00157             { }
00158 
00159         t2n_transfer_error()
00160             { }
00161 
00162         t2n_exception* clone() const
00163             { return new t2n_transfer_error(*this); }
00164 
00165         void do_throw()
00166             { throw *this; }
00167 };
00168 
00170 class t2n_version_mismatch : public t2n_communication_error
00171 {
00172     private:
00173         friend class boost::serialization::access;
00174         template<class Archive>
00175         void serialize(Archive & ar, const unsigned int version);
00176 
00177     public:
00178         t2n_version_mismatch(const std::string& _message)
00179             : t2n_communication_error(_message)
00180             { }
00181 
00182         t2n_version_mismatch()
00183             { }
00184 
00185         t2n_exception* clone() const
00186             { return new t2n_version_mismatch(*this); }
00187 
00188         void do_throw()
00189             { throw *this; }
00190 };
00191 
00193 class t2n_command_error : public t2n_exception
00194 {
00195     private:
00196         friend class boost::serialization::access;
00197         template<class Archive>
00198         void serialize(Archive & ar, const unsigned int version);
00199 
00200     public:
00201         t2n_command_error(const std::string& _message)
00202             : t2n_exception(_message)
00203             { }
00204 
00205         t2n_command_error()
00206             { }
00207 
00208         t2n_exception* clone() const
00209             { return new t2n_command_error(*this); }
00210 
00211         void do_throw()
00212             { throw *this; }
00213 };
00214 
00216 class t2n_serialization_error : public t2n_exception
00217 {
00218     private:
00219         friend class boost::serialization::access;
00220         template<class Archive>
00221         void serialize(Archive & ar, const unsigned int version);
00222 
00223     public:
00224         t2n_serialization_error(const std::string& _message)
00225             : t2n_exception(_message)
00226             { }
00227 
00228         t2n_serialization_error()
00229             { }
00230 
00231         t2n_exception* clone() const
00232             { return new t2n_serialization_error(*this); }
00233 
00234         void do_throw()
00235             { throw *this; }
00236 };
00237 
00243 class t2n_runtime_error : public t2n_exception
00244 {
00245     private:
00246         friend class boost::serialization::access;
00247         template<class Archive>
00248         void serialize(Archive & ar, const unsigned int version);
00249 
00250     public:
00251         t2n_runtime_error(const std::string& _message)
00252             : t2n_exception(_message)
00253             { }
00254 
00255         t2n_runtime_error()
00256             { }
00257 
00258         t2n_exception* clone() const
00259             { return new t2n_runtime_error(*this); }
00260 
00261         void do_throw()
00262             { throw *this; }
00263 };
00264 
00265 }  // namespace libt2n
00266 
00267 #include "t2n_exception.tcc"
00268 
00269 #endif

Generated on 13 May 2015 by  doxygen 1.6.1
© Intra2net AG 2024 | Legal | Contact