source: NonGTP/Xerces/xerces/include/xercesc/internal/XMLInternalErrorHandler.hpp @ 358

Revision 358, 4.6 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
1/*
2 * Copyright 2001,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: XMLInternalErrorHandler.hpp,v $
19 * Revision 1.4  2004/09/08 13:56:14  peiyongz
20 * Apache License Version 2.0
21 *
22 * Revision 1.3  2004/01/29 11:46:30  cargilld
23 * Code cleanup changes to get rid of various compiler diagnostic messages.
24 *
25 * Revision 1.2  2002/11/04 14:58:18  tng
26 * C++ Namespace Support.
27 *
28 * Revision 1.1.1.1  2002/02/01 22:21:58  peiyongz
29 * sane_include
30 *
31 * Revision 1.1  2001/07/26 17:04:10  tng
32 * Schema: Process should stop after fatal error, and user throws need to be rethrown.
33 *
34 */
35
36#if !defined(XMLINTERNALERRORHANDLER_HPP)
37#define XMLINTERNALERRORHANDLER_HPP
38
39#include <xercesc/util/XercesDefs.hpp>
40#include <xercesc/sax/ErrorHandler.hpp>
41
42XERCES_CPP_NAMESPACE_BEGIN
43
44class XMLInternalErrorHandler : public ErrorHandler
45{
46public:
47    // -----------------------------------------------------------------------
48    //  Constructors and Destructor
49    // -----------------------------------------------------------------------
50    XMLInternalErrorHandler(ErrorHandler* userHandler = 0) :
51       fSawWarning(false),
52       fSawError(false),
53       fSawFatal(false),
54       fUserErrorHandler(userHandler)
55    {
56    }
57
58    ~XMLInternalErrorHandler()
59    {
60    }
61
62    // -----------------------------------------------------------------------
63    //  Implementation of the error handler interface
64    // -----------------------------------------------------------------------
65    void warning(const SAXParseException& toCatch);
66    void error(const SAXParseException& toCatch);
67    void fatalError(const SAXParseException& toCatch);
68    void resetErrors();
69
70    // -----------------------------------------------------------------------
71    //  Getter methods
72    // -----------------------------------------------------------------------
73    bool getSawWarning() const;
74    bool getSawError() const;
75    bool getSawFatal() const;
76
77    // -----------------------------------------------------------------------
78    //  Private data members
79    //
80    //  fSawWarning
81    //      This is set if we get any warning, and is queryable via a getter
82    //      method.
83    //
84    //  fSawError
85    //      This is set if we get any errors, and is queryable via a getter
86    //      method.
87    //
88    //  fSawFatal
89    //      This is set if we get any fatal, and is queryable via a getter
90    //      method.
91    //
92    //  fUserErrorHandler
93    //      This is the error handler from user
94    // -----------------------------------------------------------------------
95    bool    fSawWarning;
96    bool    fSawError;
97    bool    fSawFatal;
98    ErrorHandler* fUserErrorHandler;
99
100private:
101    // -----------------------------------------------------------------------
102    //  Unimplemented constructors and operators
103    // -----------------------------------------------------------------------
104    XMLInternalErrorHandler(const XMLInternalErrorHandler&);
105    XMLInternalErrorHandler& operator=(const XMLInternalErrorHandler&);
106};
107
108inline bool XMLInternalErrorHandler::getSawWarning() const
109{
110    return fSawWarning;
111}
112
113inline bool XMLInternalErrorHandler::getSawError() const
114{
115    return fSawError;
116}
117
118inline bool XMLInternalErrorHandler::getSawFatal() const
119{
120    return fSawFatal;
121}
122
123inline void XMLInternalErrorHandler::warning(const SAXParseException& toCatch)
124{
125    fSawWarning = true;
126    if (fUserErrorHandler)
127        fUserErrorHandler->warning(toCatch);
128}
129
130inline void XMLInternalErrorHandler::error(const SAXParseException& toCatch)
131{
132    fSawError = true;
133    if (fUserErrorHandler)
134        fUserErrorHandler->error(toCatch);
135}
136
137inline void XMLInternalErrorHandler::fatalError(const SAXParseException& toCatch)
138{
139    fSawFatal = true;
140    if (fUserErrorHandler)
141        fUserErrorHandler->fatalError(toCatch);
142}
143
144inline void XMLInternalErrorHandler::resetErrors()
145{
146    fSawWarning = false;
147    fSawError = false;
148    fSawFatal = false;
149}
150
151XERCES_CPP_NAMESPACE_END
152
153#endif
Note: See TracBrowser for help on using the repository browser.