source: NonGTP/Xerces/xercesc/sax/SAXException.hpp @ 188

Revision 188, 10.2 KB checked in by mattausch, 19 years ago (diff)

added xercesc to support

Line 
1/*
2 * The Apache Software License, Version 1.1
3 *
4 * Copyright (c) 1999-2000 The Apache Software Foundation.  All rights
5 * reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in
16 *    the documentation and/or other materials provided with the
17 *    distribution.
18 *
19 * 3. The end-user documentation included with the redistribution,
20 *    if any, must include the following acknowledgment:
21 *       "This product includes software developed by the
22 *        Apache Software Foundation (http://www.apache.org/)."
23 *    Alternately, this acknowledgment may appear in the software itself,
24 *    if and wherever such third-party acknowledgments normally appear.
25 *
26 * 4. The names "Xerces" and "Apache Software Foundation" must
27 *    not be used to endorse or promote products derived from this
28 *    software without prior written permission. For written
29 *    permission, please contact apache\@apache.org.
30 *
31 * 5. Products derived from this software may not be called "Apache",
32 *    nor may "Apache" appear in their name, without prior written
33 *    permission of the Apache Software Foundation.
34 *
35 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46 * SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This software consists of voluntary contributions made by many
50 * individuals on behalf of the Apache Software Foundation, and was
51 * originally based on software copyright (c) 1999, International
52 * Business Machines, Inc., http://www.ibm.com .  For more information
53 * on the Apache Software Foundation, please see
54 * <http://www.apache.org/>.
55 */
56
57/*
58 * $Log: SAXException.hpp,v $
59 * Revision 1.6  2003/12/01 23:23:26  neilg
60 * fix for bug 25118; thanks to Jeroen Witmond
61 *
62 * Revision 1.5  2003/08/13 15:43:24  knoaman
63 * Use memory manager when creating SAX exceptions.
64 *
65 * Revision 1.4  2003/05/15 18:27:05  knoaman
66 * Partial implementation of the configurable memory manager.
67 *
68 * Revision 1.3  2002/12/06 13:17:29  tng
69 * [Bug 9083] Make SAXNotSupportedException and SAXNotRecognizedException to be exportable
70 *
71 * Revision 1.2  2002/11/04 14:56:26  tng
72 * C++ Namespace Support.
73 *
74 * Revision 1.1.1.1  2002/02/01 22:22:08  peiyongz
75 * sane_include
76 *
77 * Revision 1.8  2000/09/07 23:55:02  andyh
78 * Fix SAXException assignment operator.  Now non-virtual, and
79 * SAXParseException invokes base class operator.
80 *
81 * Revision 1.7  2000/08/09 22:06:04  jpolast
82 * more functionality to SAXException and its children.
83 * msgs are now functional for SAXNotSupportedEx and
84 * SAXNotRecognizedEx
85 *
86 * Revision 1.6  2000/08/02 18:04:02  jpolast
87 * include SAXNotSupportedException and
88 * SAXNotRecognizedException needed for sax2
89 *
90 * Revision 1.5  2000/02/24 20:12:55  abagchi
91 * Swat for removing Log from API docs
92 *
93 * Revision 1.4  2000/02/09 19:15:17  abagchi
94 * Inserted documentation for new APIs
95 *
96 * Revision 1.3  2000/02/06 07:47:58  rahulj
97 * Year 2K copyright swat.
98 *
99 * Revision 1.2  1999/12/18 00:21:23  roddey
100 * Fixed a small reported memory leak
101 *
102 * Revision 1.1.1.1  1999/11/09 01:07:47  twl
103 * Initial checkin
104 *
105 * Revision 1.2  1999/11/08 20:45:02  rahul
106 * Swat for adding in Product name and CVS comment log variable.
107 *
108 */
109
110
111#ifndef SAXEXCEPTION_HPP
112#define SAXEXCEPTION_HPP
113
114#include <xercesc/util/XMLString.hpp>
115#include <xercesc/util/XMLUni.hpp>
116#include <xercesc/util/XMemory.hpp>
117
118XERCES_CPP_NAMESPACE_BEGIN
119
120
121/**
122  * Encapsulate a general SAX error or warning.
123  *
124  * <p>This class can contain basic error or warning information from
125  * either the XML SAX parser or the application: a parser writer or
126  * application writer can subclass it to provide additional
127  * functionality.  SAX handlers may throw this exception or
128  * any exception subclassed from it.</p>
129  *
130  * <p>If the application needs to pass through other types of
131  * exceptions, it must wrap those exceptions in a SAXException
132  * or an exception derived from a SAXException.</p>
133  *
134  * <p>If the parser or application needs to include information
135  * about a specific location in an XML document, it should use the
136  * SAXParseException subclass.</p>
137  *
138  * @see SAXParseException#SAXParseException
139  */
140class SAX_EXPORT SAXException : public XMemory
141{
142public:
143    /** @name Constructors and Destructor */
144    //@{
145    /** Default constructor
146     * @param manager    Pointer to the memory manager to be used to
147     *                   allocate objects.
148     */
149    SAXException(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) :
150
151        fMsg(XMLString::replicate(XMLUni::fgZeroLenString, manager))
152        , fMemoryManager(manager)
153    {
154    }
155
156  /**
157    * Create a new SAXException.
158    *
159    * @param msg The error or warning message.
160    * @param manager    Pointer to the memory manager to be used to
161    *                   allocate objects.
162    */
163    SAXException(const XMLCh* const msg,
164                 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) :
165
166        fMsg(XMLString::replicate(msg, manager))
167        , fMemoryManager(manager)
168    {
169    }
170
171  /**
172    * Create a new SAXException.
173    *
174    * @param msg The error or warning message.
175    * @param manager    Pointer to the memory manager to be used to
176    *                   allocate objects.
177    */
178    SAXException(const char* const msg,
179                 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) :
180
181        fMsg(XMLString::transcode(msg, manager))
182        , fMemoryManager(manager)
183    {
184    }
185
186  /**
187    * Copy constructor
188    *
189    * @param toCopy The exception to be copy constructed
190    */
191    SAXException(const SAXException& toCopy) :
192
193        fMsg(XMLString::replicate(toCopy.fMsg, toCopy.fMemoryManager))
194        , fMemoryManager(toCopy.fMemoryManager)
195    {
196    }
197
198    /** Destructor */
199    virtual ~SAXException()
200    {
201        fMemoryManager->deallocate(fMsg);//delete [] fMsg;
202    }
203
204    //@}
205
206
207    /** @name Public Operators */
208    //@{
209    /**
210      * Assignment operator
211      *
212      * @param toCopy The object to be copied
213      */
214    SAXException& operator=(const SAXException& toCopy)
215    {
216        if (this == &toCopy)
217            return *this;
218
219        fMemoryManager->deallocate(fMsg);//delete [] fMsg;
220        fMsg = XMLString::replicate(toCopy.fMsg, toCopy.fMemoryManager);
221        fMemoryManager = toCopy.fMemoryManager;
222        return *this;
223    }
224    //@}
225
226    /** @name Getter Methods */
227    //@{
228    /**
229      * Get the contents of the message
230      *
231      */
232    virtual const XMLCh* getMessage() const
233    {
234        return fMsg;
235    }
236    //@}
237
238
239protected :
240    // -----------------------------------------------------------------------
241    //  Protected data members
242    //
243    //  fMsg
244    //      This is the text of the error that is being thrown.
245    // -----------------------------------------------------------------------
246    XMLCh*  fMsg;
247    MemoryManager* fMemoryManager;
248};
249
250class SAX_EXPORT SAXNotSupportedException : public SAXException
251{
252
253public:
254        SAXNotSupportedException(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
255
256  /**
257    * Create a new SAXException.
258    *
259    * @param msg The error or warning message.
260    * @param manager    Pointer to the memory manager to be used to
261    *                   allocate objects.
262    */
263    SAXNotSupportedException(const XMLCh* const msg,
264                             MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
265
266  /**
267    * Create a new SAXException.
268    *
269    * @param msg The error or warning message.
270    * @param manager    Pointer to the memory manager to be used to
271    *                   allocate objects.
272    */
273    SAXNotSupportedException(const char* const msg,
274                             MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
275
276  /**
277    * Copy constructor
278    *
279    * @param toCopy The exception to be copy constructed
280    */
281    SAXNotSupportedException(const SAXException& toCopy);
282};
283
284class SAX_EXPORT SAXNotRecognizedException : public SAXException
285{
286public:
287        SAXNotRecognizedException(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
288
289  /**
290    * Create a new SAXException.
291    *
292    * @param msg The error or warning message.
293    * @param manager    Pointer to the memory manager to be used to
294    *                   allocate objects.
295    */
296    SAXNotRecognizedException(const XMLCh* const msg,
297                              MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
298
299  /**
300    * Create a new SAXException.
301    *
302    * @param msg The error or warning message.
303    * @param manager    Pointer to the memory manager to be used to
304    *                   allocate objects.
305    */
306    SAXNotRecognizedException(const char* const msg,
307                              MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
308
309  /**
310    * Copy constructor
311    *
312    * @param toCopy The exception to be copy constructed
313    */
314    SAXNotRecognizedException(const SAXException& toCopy);
315};
316
317XERCES_CPP_NAMESPACE_END
318
319#endif
Note: See TracBrowser for help on using the repository browser.