00001 //====================================================================== 00028 //====================================================================== 00029 00030 #ifndef SDHEXCEPTION_H_ 00031 #define SDHEXCEPTION_H_ 00032 00033 //---------------------------------------------------------------------- 00034 // System Includes - include with <> 00035 //---------------------------------------------------------------------- 00036 00037 #include <iostream> 00038 #include <exception> 00039 #include <stdarg.h> 00040 #include <cstdio> // needed in gcc-4.4 (as reported by Hannes Saal) 00041 00042 //---------------------------------------------------------------------- 00043 // Project Includes - include with "" 00044 //---------------------------------------------------------------------- 00045 00046 #include "sdhlibrary_settings.h" 00047 00048 //---------------------------------------------------------------------- 00049 // Defines, enums, unions, structs, 00050 //---------------------------------------------------------------------- 00051 00052 NAMESPACE_SDH_START 00053 00054 00055 //---------------------------------------------------------------------- 00056 // Global variables 00057 //---------------------------------------------------------------------- 00058 00059 00060 //---------------------------------------------------------------------- 00061 // Function and class declaration 00062 //---------------------------------------------------------------------- 00063 00077 class VCC_EXPORT cMsg 00078 { 00079 protected: 00080 00082 enum { 00083 eMAX_MSG = 512 00084 }; 00085 00086 char msg[ eMAX_MSG ]; 00087 00088 public: 00090 cMsg(); 00091 00092 00094 cMsg( cMsg const & other ); 00095 00096 00098 cMsg( char const* fmt, ... ) SDH__attribute__((format (printf, 2, 3))); 00099 00100 /* 00101 Remark: 00102 Since non-static C++ methods have an implicit `this' argument, 00103 the arguments of such methods should be counted from two, not 00104 one, when giving values for STRING-INDEX and FIRST-TO-CHECK 00105 parameter of the format __attribute__.) 00106 */ 00107 00108 00110 char const *c_str() const; 00111 00112 }; 00113 00114 VCC_EXPORT std::ostream &operator<<(std::ostream &stream, cMsg const &msg); 00115 00116 00117 //====================================================================== 00118 00132 class VCC_EXPORT cSDHLibraryException: public std::exception 00133 { 00134 00135 protected: 00137 cMsg msg; 00138 00139 public: 00193 cSDHLibraryException( char const * _type, cMsg const & _msg ); 00194 00198 virtual const char* what() const throw(); 00199 00200 }; // cSDHLibraryException 00201 //---------------------------------------------------------------------- 00202 00206 class VCC_EXPORT cSDHErrorCommunication: public cSDHLibraryException 00207 { 00208 public: 00209 cSDHErrorCommunication( cMsg const & _msg ) 00210 : cSDHLibraryException( "cSDHErrorCommunication", _msg ) 00211 {} 00212 00213 cSDHErrorCommunication( char const* _type, cMsg const & _msg ) 00214 : cSDHLibraryException( _type, _msg ) 00215 {} 00216 }; 00217 //----------------------------------------------------------------- 00218 00219 VCC_EXPORT std::ostream &operator<<(std::ostream &stream, cSDHLibraryException const &e); 00220 00221 //====================================================================== 00222 00223 NAMESPACE_SDH_END 00224 00225 #endif 00226 00227 00228 //====================================================================== 00229 /* 00230 Here are some settings for the emacs/xemacs editor (and can be safely ignored): 00231 (e.g. to explicitely set C++ mode for *.h header files) 00232 00233 Local Variables: 00234 mode:C++ 00235 mode:ELSE 00236 End: 00237 */ 00238 //======================================================================