00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055
00056
00057 00058 00059
00060
00061 #if !defined(EXCEPTION_HPP)
00062 #define EXCEPTION_HPP
00063
00064 #include <util/XercesDefs.hpp>
00065 #include <util/XMLExceptMsgs.hpp>
00066 #include <util/XMLUni.hpp>
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 class XMLException
00079 {
00080 public:
00081
00082
00083
00084 virtual ~XMLException();
00085
00086
00087
00088
00089
00090 virtual const XMLCh* getType() const = 0;
00091
00092
00093
00094
00095
00096 XMLExcepts::Codes getCode() const;
00097 const XMLCh* getMessage() const;
00098 const char* getSrcFile() const;
00099 unsigned int getSrcLine() const;
00100
00101
00102
00103
00104
00105 void setPosition(const char* const file, const unsigned int line);
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 XMLException();
00118 XMLException(const char* const srcFile, const unsigned int srcLine);
00119 XMLException(const XMLException& toCopy);
00120 void operator=(const XMLException& toAssign);
00121
00122
00123 protected :
00124
00125
00126
00127 void loadExceptText
00128 (
00129 const XMLExcepts::Codes toLoad
00130 );
00131 void loadExceptText
00132 (
00133 const XMLExcepts::Codes toLoad
00134 , const XMLCh* const text1
00135 , const XMLCh* const text2 = 0
00136 , const XMLCh* const text3 = 0
00137 , const XMLCh* const text4 = 0
00138 );
00139 void loadExceptText
00140 (
00141 const XMLExcepts::Codes toLoad
00142 , const char* const text1
00143 , const char* const text2 = 0
00144 , const char* const text3 = 0
00145 , const char* const text4 = 0
00146 );
00147
00148
00149 private :
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164 XMLExcepts::Codes fCode;
00165 char* fSrcFile;
00166 unsigned int fSrcLine;
00167 XMLCh* fMsg;
00168 };
00169
00170
00171
00172
00173 inline XMLExcepts::Codes XMLException::getCode() const
00174 {
00175 return fCode;
00176 }
00177
00178 inline const XMLCh* XMLException::getMessage() const
00179 {
00180 return fMsg;
00181 }
00182
00183 inline const char* XMLException::getSrcFile() const
00184 {
00185 if (!fSrcFile)
00186 return "";
00187 return fSrcFile;
00188 }
00189
00190 inline unsigned int XMLException::getSrcLine() const
00191 {
00192 return fSrcLine;
00193 }
00194
00195
00196
00197
00198
00199
00200
00201 #define MakeXMLException(theType, expKeyword) \
00202 class expKeyword theType : public XMLException \
00203 { \
00204 public: \
00205 \
00206 theType(const char* const srcFile \
00207 , const unsigned int srcLine \
00208 , const XMLExcepts::Codes toThrow) : \
00209 XMLException(srcFile, srcLine) \
00210 { \
00211 loadExceptText(toThrow); \
00212 } \
00213 \
00214 theType(const theType& toCopy) : \
00215 \
00216 XMLException(toCopy) \
00217 { \
00218 } \
00219 \
00220 theType(const char* const srcFile \
00221 , const unsigned int srcLine \
00222 , const XMLExcepts::Codes toThrow \
00223 , const XMLCh* const text1 \
00224 , const XMLCh* const text2 = 0 \
00225 , const XMLCh* const text3 = 0 \
00226 , const XMLCh* const text4 = 0) : \
00227 XMLException(srcFile, srcLine) \
00228 { \
00229 loadExceptText(toThrow, text1, text2, text3, text4); \
00230 } \
00231 \
00232 theType(const char* const srcFile \
00233 , const unsigned int srcLine \
00234 , const XMLExcepts::Codes toThrow \
00235 , const char* const text1 \
00236 , const char* const text2 = 0 \
00237 , const char* const text3 = 0 \
00238 , const char* const text4 = 0) : \
00239 XMLException(srcFile, srcLine) \
00240 { \
00241 loadExceptText(toThrow, text1, text2, text3, text4); \
00242 } \
00243 \
00244 virtual ~theType() {} \
00245 \
00246 theType& operator=(const theType& toAssign) \
00247 { \
00248 XMLException::operator=(toAssign); \
00249 return *this; \
00250 } \
00251 \
00252 virtual XMLException* duplicate() const \
00253 { \
00254 return new theType(*this); \
00255 } \
00256 \
00257 virtual const XMLCh* getType() const \
00258 { \
00259 return XMLUni::fg##theType##_Name; \
00260 } \
00261 \
00262 private : \
00263 theType(); \
00264 };
00265
00266
00267
00268
00269
00270
00271
00272
00273 #define ThrowXML(type,code) throw type(__FILE__, __LINE__, code)
00274
00275 #define ThrowXML1(type,code,p1) throw type(__FILE__, __LINE__, code, p1)
00276
00277 #define ThrowXML2(type,code,p1,p2) throw type(__FILE__, __LINE__, code, p1, p2)
00278
00279 #define ThrowXML3(type,code,p1,p2,p3) throw type(__FILE__, __LINE__, code, p1, p2, p3)
00280
00281 #define ThrowXML4(type,code,p1,p2,p3,p4) throw type(__FILE__, __LINE__, code, p1, p2, p3, p4)
00282
00283 #endif