source: NonGTP/Xerces/xerces-c_2_8_0/include/xercesc/sax/SAXException.hpp @ 2674

Revision 2674, 6.6 KB checked in by mattausch, 16 years ago (diff)
Line 
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/*
19 * $Id: SAXException.hpp 568078 2007-08-21 11:43:25Z amassari $
20 */
21
22
23#ifndef SAXEXCEPTION_HPP
24#define SAXEXCEPTION_HPP
25
26#include <xercesc/util/XMLString.hpp>
27#include <xercesc/util/XMLUni.hpp>
28#include <xercesc/util/XMemory.hpp>
29
30XERCES_CPP_NAMESPACE_BEGIN
31
32
33/**
34  * Encapsulate a general SAX error or warning.
35  *
36  * <p>This class can contain basic error or warning information from
37  * either the XML SAX parser or the application: a parser writer or
38  * application writer can subclass it to provide additional
39  * functionality.  SAX handlers may throw this exception or
40  * any exception subclassed from it.</p>
41  *
42  * <p>If the application needs to pass through other types of
43  * exceptions, it must wrap those exceptions in a SAXException
44  * or an exception derived from a SAXException.</p>
45  *
46  * <p>If the parser or application needs to include information
47  * about a specific location in an XML document, it should use the
48  * SAXParseException subclass.</p>
49  *
50  * @see SAXParseException#SAXParseException
51  */
52class SAX_EXPORT SAXException : public XMemory
53{
54public:
55    /** @name Constructors and Destructor */
56    //@{
57    /** Default constructor
58     * @param manager    Pointer to the memory manager to be used to
59     *                   allocate objects.
60     */
61    SAXException(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) :
62
63        fMsg(XMLString::replicate(XMLUni::fgZeroLenString, manager))
64        , fMemoryManager(manager)
65    {
66    }
67
68  /**
69    * Create a new SAXException.
70    *
71    * @param msg The error or warning message.
72    * @param manager    Pointer to the memory manager to be used to
73    *                   allocate objects.
74    */
75    SAXException(const XMLCh* const msg,
76                 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) :
77
78        fMsg(XMLString::replicate(msg, manager))
79        , fMemoryManager(manager)
80    {
81    }
82
83  /**
84    * Create a new SAXException.
85    *
86    * @param msg The error or warning message.
87    * @param manager    Pointer to the memory manager to be used to
88    *                   allocate objects.
89    */
90    SAXException(const char* const msg,
91                 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) :
92
93        fMsg(XMLString::transcode(msg, manager))
94        , fMemoryManager(manager)
95    {
96    }
97
98  /**
99    * Copy constructor
100    *
101    * @param toCopy The exception to be copy constructed
102    */
103    SAXException(const SAXException& toCopy) :
104        XMemory(toCopy)
105        , fMsg(XMLString::replicate(toCopy.fMsg, toCopy.fMemoryManager))
106        , fMemoryManager(toCopy.fMemoryManager)
107    {
108    }
109
110    /** Destructor */
111    virtual ~SAXException()
112    {
113        fMemoryManager->deallocate(fMsg);//delete [] fMsg;
114    }
115
116    //@}
117
118
119    /** @name Public Operators */
120    //@{
121    /**
122      * Assignment operator
123      *
124      * @param toCopy The object to be copied
125      */
126    SAXException& operator=(const SAXException& toCopy)
127    {
128        if (this == &toCopy)
129            return *this;
130
131        fMemoryManager->deallocate(fMsg);//delete [] fMsg;
132        fMsg = XMLString::replicate(toCopy.fMsg, toCopy.fMemoryManager);
133        fMemoryManager = toCopy.fMemoryManager;
134        return *this;
135    }
136    //@}
137
138    /** @name Getter Methods */
139    //@{
140    /**
141      * Get the contents of the message
142      *
143      */
144    virtual const XMLCh* getMessage() const
145    {
146        return fMsg;
147    }
148    //@}
149
150
151protected :
152    // -----------------------------------------------------------------------
153    //  Protected data members
154    //
155    //  fMsg
156    //      This is the text of the error that is being thrown.
157    // -----------------------------------------------------------------------
158    XMLCh*  fMsg;
159    MemoryManager* fMemoryManager;
160};
161
162class SAX_EXPORT SAXNotSupportedException : public SAXException
163{
164
165public:
166        SAXNotSupportedException(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
167
168  /**
169    * Create a new SAXException.
170    *
171    * @param msg The error or warning message.
172    * @param manager    Pointer to the memory manager to be used to
173    *                   allocate objects.
174    */
175    SAXNotSupportedException(const XMLCh* const msg,
176                             MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
177
178  /**
179    * Create a new SAXException.
180    *
181    * @param msg The error or warning message.
182    * @param manager    Pointer to the memory manager to be used to
183    *                   allocate objects.
184    */
185    SAXNotSupportedException(const char* const msg,
186                             MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
187
188  /**
189    * Copy constructor
190    *
191    * @param toCopy The exception to be copy constructed
192    */
193    SAXNotSupportedException(const SAXException& toCopy);
194};
195
196class SAX_EXPORT SAXNotRecognizedException : public SAXException
197{
198public:
199        SAXNotRecognizedException(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
200
201  /**
202    * Create a new SAXException.
203    *
204    * @param msg The error or warning message.
205    * @param manager    Pointer to the memory manager to be used to
206    *                   allocate objects.
207    */
208    SAXNotRecognizedException(const XMLCh* const msg,
209                              MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
210
211  /**
212    * Create a new SAXException.
213    *
214    * @param msg The error or warning message.
215    * @param manager    Pointer to the memory manager to be used to
216    *                   allocate objects.
217    */
218    SAXNotRecognizedException(const char* const msg,
219                              MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
220
221  /**
222    * Copy constructor
223    *
224    * @param toCopy The exception to be copy constructed
225    */
226    SAXNotRecognizedException(const SAXException& toCopy);
227};
228
229XERCES_CPP_NAMESPACE_END
230
231#endif
Note: See TracBrowser for help on using the repository browser.