File indexing completed on 2025-01-18 10:15:15
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #if !defined(XERCESC_INCLUDE_GUARD_XMLEXCEPTION_HPP)
0023 #define XERCESC_INCLUDE_GUARD_XMLEXCEPTION_HPP
0024
0025 #include <xercesc/util/XercesDefs.hpp>
0026 #include <xercesc/util/XMemory.hpp>
0027 #include <xercesc/util/XMLExceptMsgs.hpp>
0028 #include <xercesc/util/XMLUni.hpp>
0029 #include <xercesc/framework/XMLErrorReporter.hpp>
0030
0031 XERCES_CPP_NAMESPACE_BEGIN
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 class XMLUTIL_EXPORT XMLException : public XMemory
0043 {
0044 public:
0045
0046
0047
0048 virtual ~XMLException();
0049
0050
0051
0052
0053
0054 virtual const XMLCh* getType() const = 0;
0055
0056
0057
0058
0059
0060 XMLExcepts::Codes getCode() const;
0061 const XMLCh* getMessage() const;
0062 const char* getSrcFile() const;
0063 XMLFileLoc getSrcLine() const;
0064 XMLErrorReporter::ErrTypes getErrorType() const;
0065
0066
0067
0068
0069
0070 void setPosition(const char* const file, const XMLFileLoc line);
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082 XMLException();
0083 XMLException(const char* const srcFile, const XMLFileLoc srcLine, MemoryManager* const memoryManager = 0);
0084 XMLException(const XMLException& toCopy);
0085 XMLException& operator=(const XMLException& toAssign);
0086
0087 protected :
0088
0089
0090
0091 void loadExceptText
0092 (
0093 const XMLExcepts::Codes toLoad
0094 );
0095 void loadExceptText
0096 (
0097 const XMLExcepts::Codes toLoad
0098 , const XMLCh* const text1
0099 , const XMLCh* const text2 = 0
0100 , const XMLCh* const text3 = 0
0101 , const XMLCh* const text4 = 0
0102 );
0103 void loadExceptText
0104 (
0105 const XMLExcepts::Codes toLoad
0106 , const char* const text1
0107 , const char* const text2 = 0
0108 , const char* const text3 = 0
0109 , const char* const text4 = 0
0110 );
0111
0112
0113 private :
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128 XMLExcepts::Codes fCode;
0129 char* fSrcFile;
0130 XMLFileLoc fSrcLine;
0131 XMLCh* fMsg;
0132
0133 protected:
0134 MemoryManager* fMemoryManager;
0135 };
0136
0137
0138
0139
0140 inline XMLExcepts::Codes XMLException::getCode() const
0141 {
0142 return fCode;
0143 }
0144
0145 inline const XMLCh* XMLException::getMessage() const
0146 {
0147 return fMsg;
0148 }
0149
0150 inline const char* XMLException::getSrcFile() const
0151 {
0152 if (!fSrcFile)
0153 return "";
0154 return fSrcFile;
0155 }
0156
0157 inline XMLFileLoc XMLException::getSrcLine() const
0158 {
0159 return fSrcLine;
0160 }
0161
0162 inline XMLErrorReporter::ErrTypes XMLException::getErrorType() const
0163 {
0164 if ((fCode >= XMLExcepts::W_LowBounds) && (fCode <= XMLExcepts::W_HighBounds))
0165 return XMLErrorReporter::ErrType_Warning;
0166 else if ((fCode >= XMLExcepts::F_LowBounds) && (fCode <= XMLExcepts::F_HighBounds))
0167 return XMLErrorReporter::ErrType_Fatal;
0168 else if ((fCode >= XMLExcepts::E_LowBounds) && (fCode <= XMLExcepts::E_HighBounds))
0169 return XMLErrorReporter::ErrType_Error;
0170 return XMLErrorReporter::ErrTypes_Unknown;
0171 }
0172
0173
0174
0175
0176
0177
0178 #define MakeXMLException(theType, expKeyword) \
0179 class expKeyword theType : public XMLException \
0180 { \
0181 public: \
0182 \
0183 theType(const char* const srcFile \
0184 , const XMLFileLoc srcLine \
0185 , const XMLExcepts::Codes toThrow \
0186 , MemoryManager* memoryManager = 0) : \
0187 XMLException(srcFile, srcLine, memoryManager) \
0188 { \
0189 loadExceptText(toThrow); \
0190 } \
0191 \
0192 theType(const theType& toCopy) : \
0193 \
0194 XMLException(toCopy) \
0195 { \
0196 } \
0197 \
0198 theType(const char* const srcFile \
0199 , const XMLFileLoc srcLine \
0200 , const XMLExcepts::Codes toThrow \
0201 , const XMLCh* const text1 \
0202 , const XMLCh* const text2 = 0 \
0203 , const XMLCh* const text3 = 0 \
0204 , const XMLCh* const text4 = 0 \
0205 , MemoryManager* memoryManager = 0) : \
0206 XMLException(srcFile, srcLine, memoryManager) \
0207 { \
0208 loadExceptText(toThrow, text1, text2, text3, text4); \
0209 } \
0210 \
0211 theType(const char* const srcFile \
0212 , const XMLFileLoc srcLine \
0213 , const XMLExcepts::Codes toThrow \
0214 , const char* const text1 \
0215 , const char* const text2 = 0 \
0216 , const char* const text3 = 0 \
0217 , const char* const text4 = 0 \
0218 , MemoryManager* memoryManager = 0) : \
0219 XMLException(srcFile, srcLine, memoryManager) \
0220 { \
0221 loadExceptText(toThrow, text1, text2, text3, text4); \
0222 } \
0223 \
0224 virtual ~theType() {} \
0225 \
0226 theType& operator=(const theType& toAssign) \
0227 { \
0228 XMLException::operator=(toAssign); \
0229 return *this; \
0230 } \
0231 \
0232 virtual XMLException* duplicate() const \
0233 { \
0234 return new (fMemoryManager) theType(*this); \
0235 } \
0236 \
0237 virtual const XMLCh* getType() const \
0238 { \
0239 return XMLUni::fg##theType##_Name; \
0240 } \
0241 \
0242 private : \
0243 theType(); \
0244 };
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254 #define ThrowXML(type,code) throw type(__FILE__, __LINE__, code)
0255
0256 #define ThrowXML1(type,code,p1) throw type(__FILE__, __LINE__, code, p1)
0257
0258 #define ThrowXML2(type,code,p1,p2) throw type(__FILE__, __LINE__, code, p1, p2)
0259
0260 #define ThrowXML3(type,code,p1,p2,p3) throw type(__FILE__, __LINE__, code, p1, p2, p3)
0261
0262 #define ThrowXML4(type,code,p1,p2,p3,p4) throw type(__FILE__, __LINE__, code, p1, p2, p3, p4)
0263
0264 #define ThrowXMLwithMemMgr(type,code,memMgr) throw type(__FILE__, __LINE__, code, memMgr)
0265
0266 #define ThrowXMLwithMemMgr1(type,code,p1,memMgr) throw type(__FILE__, __LINE__, code, p1, 0, 0, 0, memMgr)
0267
0268 #define ThrowXMLwithMemMgr2(type,code,p1,p2,memMgr) throw type(__FILE__, __LINE__, code, p1, p2, 0, 0, memMgr)
0269
0270 #define ThrowXMLwithMemMgr3(type,code,p1,p2,p3,memMgr) throw type(__FILE__, __LINE__, code, p1, p2, p3, 0, memMgr)
0271
0272 #define ThrowXMLwithMemMgr4(type,code,p1,p2,p3,p4,memMgr) throw type(__FILE__, __LINE__, code, p1, p2, p3, p4, memMgr)
0273
0274 XERCES_CPP_NAMESPACE_END
0275
0276 #endif