[358] | 1 | /*
|
---|
| 2 | * Copyright 1999-2000,2004 The Apache Software Foundation.
|
---|
| 3 | *
|
---|
| 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
| 5 | * you may not use this file except in compliance with the License.
|
---|
| 6 | * You may obtain a copy of the License at
|
---|
| 7 | *
|
---|
| 8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
| 9 | *
|
---|
| 10 | * Unless required by applicable law or agreed to in writing, software
|
---|
| 11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
| 13 | * See the License for the specific language governing permissions and
|
---|
| 14 | * limitations under the License.
|
---|
| 15 | */
|
---|
| 16 |
|
---|
| 17 | /*
|
---|
| 18 | * $Log: SAXException.hpp,v $
|
---|
| 19 | * Revision 1.7 2004/09/08 13:56:19 peiyongz
|
---|
| 20 | * Apache License Version 2.0
|
---|
| 21 | *
|
---|
| 22 | * Revision 1.6 2003/12/01 23:23:26 neilg
|
---|
| 23 | * fix for bug 25118; thanks to Jeroen Witmond
|
---|
| 24 | *
|
---|
| 25 | * Revision 1.5 2003/08/13 15:43:24 knoaman
|
---|
| 26 | * Use memory manager when creating SAX exceptions.
|
---|
| 27 | *
|
---|
| 28 | * Revision 1.4 2003/05/15 18:27:05 knoaman
|
---|
| 29 | * Partial implementation of the configurable memory manager.
|
---|
| 30 | *
|
---|
| 31 | * Revision 1.3 2002/12/06 13:17:29 tng
|
---|
| 32 | * [Bug 9083] Make SAXNotSupportedException and SAXNotRecognizedException to be exportable
|
---|
| 33 | *
|
---|
| 34 | * Revision 1.2 2002/11/04 14:56:26 tng
|
---|
| 35 | * C++ Namespace Support.
|
---|
| 36 | *
|
---|
| 37 | * Revision 1.1.1.1 2002/02/01 22:22:08 peiyongz
|
---|
| 38 | * sane_include
|
---|
| 39 | *
|
---|
| 40 | * Revision 1.8 2000/09/07 23:55:02 andyh
|
---|
| 41 | * Fix SAXException assignment operator. Now non-virtual, and
|
---|
| 42 | * SAXParseException invokes base class operator.
|
---|
| 43 | *
|
---|
| 44 | * Revision 1.7 2000/08/09 22:06:04 jpolast
|
---|
| 45 | * more functionality to SAXException and its children.
|
---|
| 46 | * msgs are now functional for SAXNotSupportedEx and
|
---|
| 47 | * SAXNotRecognizedEx
|
---|
| 48 | *
|
---|
| 49 | * Revision 1.6 2000/08/02 18:04:02 jpolast
|
---|
| 50 | * include SAXNotSupportedException and
|
---|
| 51 | * SAXNotRecognizedException needed for sax2
|
---|
| 52 | *
|
---|
| 53 | * Revision 1.5 2000/02/24 20:12:55 abagchi
|
---|
| 54 | * Swat for removing Log from API docs
|
---|
| 55 | *
|
---|
| 56 | * Revision 1.4 2000/02/09 19:15:17 abagchi
|
---|
| 57 | * Inserted documentation for new APIs
|
---|
| 58 | *
|
---|
| 59 | * Revision 1.3 2000/02/06 07:47:58 rahulj
|
---|
| 60 | * Year 2K copyright swat.
|
---|
| 61 | *
|
---|
| 62 | * Revision 1.2 1999/12/18 00:21:23 roddey
|
---|
| 63 | * Fixed a small reported memory leak
|
---|
| 64 | *
|
---|
| 65 | * Revision 1.1.1.1 1999/11/09 01:07:47 twl
|
---|
| 66 | * Initial checkin
|
---|
| 67 | *
|
---|
| 68 | * Revision 1.2 1999/11/08 20:45:02 rahul
|
---|
| 69 | * Swat for adding in Product name and CVS comment log variable.
|
---|
| 70 | *
|
---|
| 71 | */
|
---|
| 72 |
|
---|
| 73 |
|
---|
| 74 | #ifndef SAXEXCEPTION_HPP
|
---|
| 75 | #define SAXEXCEPTION_HPP
|
---|
| 76 |
|
---|
| 77 | #include <xercesc/util/XMLString.hpp>
|
---|
| 78 | #include <xercesc/util/XMLUni.hpp>
|
---|
| 79 | #include <xercesc/util/XMemory.hpp>
|
---|
| 80 |
|
---|
| 81 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
| 82 |
|
---|
| 83 |
|
---|
| 84 | /**
|
---|
| 85 | * Encapsulate a general SAX error or warning.
|
---|
| 86 | *
|
---|
| 87 | * <p>This class can contain basic error or warning information from
|
---|
| 88 | * either the XML SAX parser or the application: a parser writer or
|
---|
| 89 | * application writer can subclass it to provide additional
|
---|
| 90 | * functionality. SAX handlers may throw this exception or
|
---|
| 91 | * any exception subclassed from it.</p>
|
---|
| 92 | *
|
---|
| 93 | * <p>If the application needs to pass through other types of
|
---|
| 94 | * exceptions, it must wrap those exceptions in a SAXException
|
---|
| 95 | * or an exception derived from a SAXException.</p>
|
---|
| 96 | *
|
---|
| 97 | * <p>If the parser or application needs to include information
|
---|
| 98 | * about a specific location in an XML document, it should use the
|
---|
| 99 | * SAXParseException subclass.</p>
|
---|
| 100 | *
|
---|
| 101 | * @see SAXParseException#SAXParseException
|
---|
| 102 | */
|
---|
| 103 | class SAX_EXPORT SAXException : public XMemory
|
---|
| 104 | {
|
---|
| 105 | public:
|
---|
| 106 | /** @name Constructors and Destructor */
|
---|
| 107 | //@{
|
---|
| 108 | /** Default constructor
|
---|
| 109 | * @param manager Pointer to the memory manager to be used to
|
---|
| 110 | * allocate objects.
|
---|
| 111 | */
|
---|
| 112 | SAXException(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) :
|
---|
| 113 |
|
---|
| 114 | fMsg(XMLString::replicate(XMLUni::fgZeroLenString, manager))
|
---|
| 115 | , fMemoryManager(manager)
|
---|
| 116 | {
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | /**
|
---|
| 120 | * Create a new SAXException.
|
---|
| 121 | *
|
---|
| 122 | * @param msg The error or warning message.
|
---|
| 123 | * @param manager Pointer to the memory manager to be used to
|
---|
| 124 | * allocate objects.
|
---|
| 125 | */
|
---|
| 126 | SAXException(const XMLCh* const msg,
|
---|
| 127 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) :
|
---|
| 128 |
|
---|
| 129 | fMsg(XMLString::replicate(msg, manager))
|
---|
| 130 | , fMemoryManager(manager)
|
---|
| 131 | {
|
---|
| 132 | }
|
---|
| 133 |
|
---|
| 134 | /**
|
---|
| 135 | * Create a new SAXException.
|
---|
| 136 | *
|
---|
| 137 | * @param msg The error or warning message.
|
---|
| 138 | * @param manager Pointer to the memory manager to be used to
|
---|
| 139 | * allocate objects.
|
---|
| 140 | */
|
---|
| 141 | SAXException(const char* const msg,
|
---|
| 142 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) :
|
---|
| 143 |
|
---|
| 144 | fMsg(XMLString::transcode(msg, manager))
|
---|
| 145 | , fMemoryManager(manager)
|
---|
| 146 | {
|
---|
| 147 | }
|
---|
| 148 |
|
---|
| 149 | /**
|
---|
| 150 | * Copy constructor
|
---|
| 151 | *
|
---|
| 152 | * @param toCopy The exception to be copy constructed
|
---|
| 153 | */
|
---|
| 154 | SAXException(const SAXException& toCopy) :
|
---|
| 155 |
|
---|
| 156 | fMsg(XMLString::replicate(toCopy.fMsg, toCopy.fMemoryManager))
|
---|
| 157 | , fMemoryManager(toCopy.fMemoryManager)
|
---|
| 158 | {
|
---|
| 159 | }
|
---|
| 160 |
|
---|
| 161 | /** Destructor */
|
---|
| 162 | virtual ~SAXException()
|
---|
| 163 | {
|
---|
| 164 | fMemoryManager->deallocate(fMsg);//delete [] fMsg;
|
---|
| 165 | }
|
---|
| 166 |
|
---|
| 167 | //@}
|
---|
| 168 |
|
---|
| 169 |
|
---|
| 170 | /** @name Public Operators */
|
---|
| 171 | //@{
|
---|
| 172 | /**
|
---|
| 173 | * Assignment operator
|
---|
| 174 | *
|
---|
| 175 | * @param toCopy The object to be copied
|
---|
| 176 | */
|
---|
| 177 | SAXException& operator=(const SAXException& toCopy)
|
---|
| 178 | {
|
---|
| 179 | if (this == &toCopy)
|
---|
| 180 | return *this;
|
---|
| 181 |
|
---|
| 182 | fMemoryManager->deallocate(fMsg);//delete [] fMsg;
|
---|
| 183 | fMsg = XMLString::replicate(toCopy.fMsg, toCopy.fMemoryManager);
|
---|
| 184 | fMemoryManager = toCopy.fMemoryManager;
|
---|
| 185 | return *this;
|
---|
| 186 | }
|
---|
| 187 | //@}
|
---|
| 188 |
|
---|
| 189 | /** @name Getter Methods */
|
---|
| 190 | //@{
|
---|
| 191 | /**
|
---|
| 192 | * Get the contents of the message
|
---|
| 193 | *
|
---|
| 194 | */
|
---|
| 195 | virtual const XMLCh* getMessage() const
|
---|
| 196 | {
|
---|
| 197 | return fMsg;
|
---|
| 198 | }
|
---|
| 199 | //@}
|
---|
| 200 |
|
---|
| 201 |
|
---|
| 202 | protected :
|
---|
| 203 | // -----------------------------------------------------------------------
|
---|
| 204 | // Protected data members
|
---|
| 205 | //
|
---|
| 206 | // fMsg
|
---|
| 207 | // This is the text of the error that is being thrown.
|
---|
| 208 | // -----------------------------------------------------------------------
|
---|
| 209 | XMLCh* fMsg;
|
---|
| 210 | MemoryManager* fMemoryManager;
|
---|
| 211 | };
|
---|
| 212 |
|
---|
| 213 | class SAX_EXPORT SAXNotSupportedException : public SAXException
|
---|
| 214 | {
|
---|
| 215 |
|
---|
| 216 | public:
|
---|
| 217 | SAXNotSupportedException(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
| 218 |
|
---|
| 219 | /**
|
---|
| 220 | * Create a new SAXException.
|
---|
| 221 | *
|
---|
| 222 | * @param msg The error or warning message.
|
---|
| 223 | * @param manager Pointer to the memory manager to be used to
|
---|
| 224 | * allocate objects.
|
---|
| 225 | */
|
---|
| 226 | SAXNotSupportedException(const XMLCh* const msg,
|
---|
| 227 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
| 228 |
|
---|
| 229 | /**
|
---|
| 230 | * Create a new SAXException.
|
---|
| 231 | *
|
---|
| 232 | * @param msg The error or warning message.
|
---|
| 233 | * @param manager Pointer to the memory manager to be used to
|
---|
| 234 | * allocate objects.
|
---|
| 235 | */
|
---|
| 236 | SAXNotSupportedException(const char* const msg,
|
---|
| 237 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
| 238 |
|
---|
| 239 | /**
|
---|
| 240 | * Copy constructor
|
---|
| 241 | *
|
---|
| 242 | * @param toCopy The exception to be copy constructed
|
---|
| 243 | */
|
---|
| 244 | SAXNotSupportedException(const SAXException& toCopy);
|
---|
| 245 | };
|
---|
| 246 |
|
---|
| 247 | class SAX_EXPORT SAXNotRecognizedException : public SAXException
|
---|
| 248 | {
|
---|
| 249 | public:
|
---|
| 250 | SAXNotRecognizedException(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
| 251 |
|
---|
| 252 | /**
|
---|
| 253 | * Create a new SAXException.
|
---|
| 254 | *
|
---|
| 255 | * @param msg The error or warning message.
|
---|
| 256 | * @param manager Pointer to the memory manager to be used to
|
---|
| 257 | * allocate objects.
|
---|
| 258 | */
|
---|
| 259 | SAXNotRecognizedException(const XMLCh* const msg,
|
---|
| 260 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
| 261 |
|
---|
| 262 | /**
|
---|
| 263 | * Create a new SAXException.
|
---|
| 264 | *
|
---|
| 265 | * @param msg The error or warning message.
|
---|
| 266 | * @param manager Pointer to the memory manager to be used to
|
---|
| 267 | * allocate objects.
|
---|
| 268 | */
|
---|
| 269 | SAXNotRecognizedException(const char* const msg,
|
---|
| 270 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
| 271 |
|
---|
| 272 | /**
|
---|
| 273 | * Copy constructor
|
---|
| 274 | *
|
---|
| 275 | * @param toCopy The exception to be copy constructed
|
---|
| 276 | */
|
---|
| 277 | SAXNotRecognizedException(const SAXException& toCopy);
|
---|
| 278 | };
|
---|
| 279 |
|
---|
| 280 | XERCES_CPP_NAMESPACE_END
|
---|
| 281 |
|
---|
| 282 | #endif
|
---|