00001 #ifndef s11n_net_s11n_v1_3_EXCEPTION_HPP_INCLUDED
00002 #define s11n_net_s11n_v1_3_EXCEPTION_HPP_INCLUDED 1
00003
00004 #include <string>
00005 #include <exception>
00006 #include <stdexcept>
00007 #include <iostream>
00008 #include <s11n.net/s11n/s11n_config.hpp>
00009
00010
00011
00012
00013
00014
00015
00016 #ifdef __GNUC__
00017 # define S11N_CURRENT_FUNCTION __PRETTY_FUNCTION__
00018 #elif defined(__BORLANDC__)
00019 # define S11N_CURRENT_FUNCTION __FUNC__
00020 #elif defined(_MSC_VER)
00021 # if _MSC_VER >= 1300 // .NET 2003
00022 # define S11N_CURRENT_FUNCTION __FUNCDNAME__
00023 # else
00024 # define S11N_CURRENT_FUNCTION __FUNCTION__
00025 # endif
00026 #else
00027 # define S11N_CURRENT_FUNCTION __FUNCTION__
00028 #endif
00029
00030
00031
00032
00033
00034 #define S11N_SOURCEINFO s11n::source_info(__FILE__,__LINE__,S11N_CURRENT_FUNCTION)
00035 namespace s11n {
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 struct source_info
00050 {
00051
00052
00053
00054
00055
00056
00057
00058 source_info( char const * file, unsigned int line, char const * func );
00059 ~source_info();
00060
00061
00062
00063 unsigned int line() const throw();
00064
00065
00066
00067 char const * file() const throw();
00068
00069
00070
00071 char const * func() const throw();
00072
00073
00074 source_info & operator=( source_info const & rhs );
00075
00076 source_info( source_info const & rhs );
00077 private:
00078 struct pimpl;
00079 pimpl * m_p;
00080 };
00081
00082
00083
00084
00085 std::ostream & operator<<( std::ostream & os, source_info const & si );
00086
00087
00088
00089
00090 struct s11n_exception : public std::exception
00091 {
00092 public:
00093 virtual ~s11n_exception() throw() {}
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118 explicit s11n_exception( const char *format, ... );
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 s11n_exception( source_info const &, const char *format, ... );
00131
00132
00133
00134
00135
00136
00137 s11n_exception( source_info const & si );
00138
00139
00140
00141
00142 virtual const char * what() const throw();
00143 protected:
00144
00145
00146
00147 void what( std::string const & ) throw();
00148 s11n_exception();
00149 private:
00150 std::string m_what;
00151 };
00152
00153
00154
00155
00156
00157
00158
00159 struct factory_exception : public s11n_exception
00160 {
00161 public:
00162 virtual ~factory_exception() throw() {}
00163 explicit factory_exception( const char *format, ... );
00164 };
00165
00166
00167
00168
00169
00170
00171 struct io_exception : public s11n_exception
00172 {
00173 public:
00174 virtual ~io_exception() throw() {}
00175 explicit io_exception( const char *format, ... );
00176 };
00177
00178
00179 }
00180
00181 #endif // s11n_net_s11n_v1_3_EXCEPTION_HPP_INCLUDED