/src/xerces-c/src/xercesc/internal/XMLInternalErrorHandler.hpp
Line | Count | Source |
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: XMLInternalErrorHandler.hpp 527149 2007-04-10 14:56:39Z amassari $ |
20 | | */ |
21 | | |
22 | | #if !defined(XERCESC_INCLUDE_GUARD_XMLINTERNALERRORHANDLER_HPP) |
23 | | #define XERCESC_INCLUDE_GUARD_XMLINTERNALERRORHANDLER_HPP |
24 | | |
25 | | #include <xercesc/util/XercesDefs.hpp> |
26 | | #include <xercesc/sax/ErrorHandler.hpp> |
27 | | |
28 | | XERCES_CPP_NAMESPACE_BEGIN |
29 | | |
30 | | class XMLInternalErrorHandler : public ErrorHandler |
31 | | { |
32 | | public: |
33 | | // ----------------------------------------------------------------------- |
34 | | // Constructors and Destructor |
35 | | // ----------------------------------------------------------------------- |
36 | | XMLInternalErrorHandler(ErrorHandler* userHandler = 0) : |
37 | 0 | fSawWarning(false), |
38 | 0 | fSawError(false), |
39 | 0 | fSawFatal(false), |
40 | 0 | fUserErrorHandler(userHandler) |
41 | 0 | { |
42 | 0 | } |
43 | | |
44 | | ~XMLInternalErrorHandler() |
45 | 0 | { |
46 | 0 | } |
47 | | |
48 | | // ----------------------------------------------------------------------- |
49 | | // Implementation of the error handler interface |
50 | | // ----------------------------------------------------------------------- |
51 | | void warning(const SAXParseException& toCatch); |
52 | | void error(const SAXParseException& toCatch); |
53 | | void fatalError(const SAXParseException& toCatch); |
54 | | void resetErrors(); |
55 | | |
56 | | // ----------------------------------------------------------------------- |
57 | | // Getter methods |
58 | | // ----------------------------------------------------------------------- |
59 | | bool getSawWarning() const; |
60 | | bool getSawError() const; |
61 | | bool getSawFatal() const; |
62 | | |
63 | | // ----------------------------------------------------------------------- |
64 | | // Private data members |
65 | | // |
66 | | // fSawWarning |
67 | | // This is set if we get any warning, and is queryable via a getter |
68 | | // method. |
69 | | // |
70 | | // fSawError |
71 | | // This is set if we get any errors, and is queryable via a getter |
72 | | // method. |
73 | | // |
74 | | // fSawFatal |
75 | | // This is set if we get any fatal, and is queryable via a getter |
76 | | // method. |
77 | | // |
78 | | // fUserErrorHandler |
79 | | // This is the error handler from user |
80 | | // ----------------------------------------------------------------------- |
81 | | bool fSawWarning; |
82 | | bool fSawError; |
83 | | bool fSawFatal; |
84 | | ErrorHandler* fUserErrorHandler; |
85 | | |
86 | | private: |
87 | | // ----------------------------------------------------------------------- |
88 | | // Unimplemented constructors and operators |
89 | | // ----------------------------------------------------------------------- |
90 | | XMLInternalErrorHandler(const XMLInternalErrorHandler&); |
91 | | XMLInternalErrorHandler& operator=(const XMLInternalErrorHandler&); |
92 | | }; |
93 | | |
94 | | inline bool XMLInternalErrorHandler::getSawWarning() const |
95 | 0 | { |
96 | 0 | return fSawWarning; |
97 | 0 | } |
98 | | |
99 | | inline bool XMLInternalErrorHandler::getSawError() const |
100 | 0 | { |
101 | 0 | return fSawError; |
102 | 0 | } |
103 | | |
104 | | inline bool XMLInternalErrorHandler::getSawFatal() const |
105 | 0 | { |
106 | 0 | return fSawFatal; |
107 | 0 | } |
108 | | |
109 | | inline void XMLInternalErrorHandler::warning(const SAXParseException& toCatch) |
110 | 0 | { |
111 | 0 | fSawWarning = true; |
112 | 0 | if (fUserErrorHandler) |
113 | 0 | fUserErrorHandler->warning(toCatch); |
114 | 0 | } |
115 | | |
116 | | inline void XMLInternalErrorHandler::error(const SAXParseException& toCatch) |
117 | 0 | { |
118 | 0 | fSawError = true; |
119 | 0 | if (fUserErrorHandler) |
120 | 0 | fUserErrorHandler->error(toCatch); |
121 | 0 | } |
122 | | |
123 | | inline void XMLInternalErrorHandler::fatalError(const SAXParseException& toCatch) |
124 | 0 | { |
125 | 0 | fSawFatal = true; |
126 | 0 | if (fUserErrorHandler) |
127 | 0 | fUserErrorHandler->fatalError(toCatch); |
128 | 0 | } |
129 | | |
130 | | inline void XMLInternalErrorHandler::resetErrors() |
131 | 0 | { |
132 | 0 | fSawWarning = false; |
133 | 0 | fSawError = false; |
134 | 0 | fSawFatal = false; |
135 | 0 | } |
136 | | |
137 | | XERCES_CPP_NAMESPACE_END |
138 | | |
139 | | #endif |