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

Revision 2674, 5.7 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: ErrorHandler.hpp 568078 2007-08-21 11:43:25Z amassari $
20 */
21
22
23#ifndef ERRORHANDLER_HPP
24#define ERRORHANDLER_HPP
25
26#include <xercesc/util/XercesDefs.hpp>
27
28XERCES_CPP_NAMESPACE_BEGIN
29
30class SAXParseException;
31
32
33/**
34  * Basic interface for SAX error handlers.
35  *
36  * <p>If a SAX application needs to implement customized error
37  * handling, it must implement this interface and then register an
38  * instance with the SAX parser using the parser's setErrorHandler
39  * method.  The parser will then report all errors and warnings
40  * through this interface.</p>
41  *
42  * <p> The parser shall use this interface instead of throwing an
43  * exception: it is up to the application whether to throw an
44  * exception for different types of errors and warnings.  Note,
45  * however, that there is no requirement that the parser continue to
46  * provide useful information after a call to fatalError (in other
47  * words, a SAX driver class could catch an exception and report a
48  * fatalError).</p>
49  *
50  * <p>The HandlerBase class provides a default implementation of this
51  * interface, ignoring warnings and recoverable errors and throwing a
52  * SAXParseException for fatal errors.  An application may extend
53  * that class rather than implementing the complete interface
54  * itself.</p>
55  *
56  * @see Parser#setErrorHandler
57  * @see SAXParseException#SAXParseException
58  * @see HandlerBase#HandlerBase
59  */
60
61class SAX_EXPORT ErrorHandler
62{
63public:
64    /** @name Constructors and Destructor */
65    //@{
66    /** Default constructor */
67    ErrorHandler()
68    {
69    }
70
71    /** Desctructor */
72    virtual ~ErrorHandler()
73    {
74    }
75    //@}
76
77    /** @name The error handler interface */
78    //@{
79   /**
80    * Receive notification of a warning.
81    *
82    * <p>SAX parsers will use this method to report conditions that
83    * are not errors or fatal errors as defined by the XML 1.0
84    * recommendation.  The default behaviour is to take no action.</p>
85    *
86    * <p>The SAX parser must continue to provide normal parsing events
87    * after invoking this method: it should still be possible for the
88    * application to process the document through to the end.</p>
89    *
90    * @param exc The warning information encapsulated in a
91    *            SAX parse exception.
92    * @exception SAXException Any SAX exception, possibly
93    *            wrapping another exception.
94    * @see SAXParseException#SAXParseException
95    */
96    virtual void warning(const SAXParseException& exc) = 0;
97
98  /**
99    * Receive notification of a recoverable error.
100    *
101    * <p>This corresponds to the definition of "error" in section 1.2
102    * of the W3C XML 1.0 Recommendation.  For example, a validating
103    * parser would use this callback to report the violation of a
104    * validity constraint.  The default behaviour is to take no
105    * action.</p>
106    *
107    * <p>The SAX parser must continue to provide normal parsing events
108    * after invoking this method: it should still be possible for the
109    * application to process the document through to the end.  If the
110    * application cannot do so, then the parser should report a fatal
111    * error even if the XML 1.0 recommendation does not require it to
112    * do so.</p>
113    *
114    * @param exc The error information encapsulated in a
115    *            SAX parse exception.
116    * @exception SAXException Any SAX exception, possibly
117    *            wrapping another exception.
118    * @see SAXParseException#SAXParseException
119    */
120    virtual void error(const SAXParseException& exc) = 0;
121
122  /**
123    * Receive notification of a non-recoverable error.
124    *
125    * <p>This corresponds to the definition of "fatal error" in
126    * section 1.2 of the W3C XML 1.0 Recommendation.  For example, a
127    * parser would use this callback to report the violation of a
128    * well-formedness constraint.</p>
129    *
130    * <p>The application must assume that the document is unusable
131    * after the parser has invoked this method, and should continue
132    * (if at all) only for the sake of collecting addition error
133    * messages: in fact, SAX parsers are free to stop reporting any
134    * other events once this method has been invoked.</p>
135    *
136    * @param exc The error information encapsulated in a
137    *            SAX parse exception.
138    * @exception SAXException Any SAX exception, possibly
139    *            wrapping another exception.
140    * @see SAXParseException#SAXParseException
141    */
142    virtual void fatalError(const SAXParseException& exc) = 0;
143
144    /**
145    * Reset the Error handler object on its reuse
146    *
147    * <p>This method helps in reseting the Error handler object
148    * implementational defaults each time the Error handler is begun.</p>
149    *
150    */
151    virtual void resetErrors() = 0;
152
153
154    //@}
155
156private :
157    /* Unimplemented constructors and operators */
158
159    /* Copy constructor */
160    ErrorHandler(const ErrorHandler&);
161
162    /* Assignment operator */
163    ErrorHandler& operator=(const ErrorHandler&);
164
165};
166
167XERCES_CPP_NAMESPACE_END
168
169#endif
Note: See TracBrowser for help on using the repository browser.