[2674] | 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 568078 2007-08-21 11:43:25Z amassari $ |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | #if !defined(XMLINTERNALERRORHANDLER_HPP) |
---|
| 23 | #define 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 | fSawWarning(false), |
---|
| 38 | fSawError(false), |
---|
| 39 | fSawFatal(false), |
---|
| 40 | fUserErrorHandler(userHandler) |
---|
| 41 | { |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | ~XMLInternalErrorHandler() |
---|
| 45 | { |
---|
| 46 | } |
---|
| 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 | { |
---|
| 96 | return fSawWarning; |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | inline bool XMLInternalErrorHandler::getSawError() const |
---|
| 100 | { |
---|
| 101 | return fSawError; |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | inline bool XMLInternalErrorHandler::getSawFatal() const |
---|
| 105 | { |
---|
| 106 | return fSawFatal; |
---|
| 107 | } |
---|
| 108 | |
---|
| 109 | inline void XMLInternalErrorHandler::warning(const SAXParseException& toCatch) |
---|
| 110 | { |
---|
| 111 | fSawWarning = true; |
---|
| 112 | if (fUserErrorHandler) |
---|
| 113 | fUserErrorHandler->warning(toCatch); |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | inline void XMLInternalErrorHandler::error(const SAXParseException& toCatch) |
---|
| 117 | { |
---|
| 118 | fSawError = true; |
---|
| 119 | if (fUserErrorHandler) |
---|
| 120 | fUserErrorHandler->error(toCatch); |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | inline void XMLInternalErrorHandler::fatalError(const SAXParseException& toCatch) |
---|
| 124 | { |
---|
| 125 | fSawFatal = true; |
---|
| 126 | if (fUserErrorHandler) |
---|
| 127 | fUserErrorHandler->fatalError(toCatch); |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | inline void XMLInternalErrorHandler::resetErrors() |
---|
| 131 | { |
---|
| 132 | fSawWarning = false; |
---|
| 133 | fSawError = false; |
---|
| 134 | fSawFatal = false; |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | XERCES_CPP_NAMESPACE_END |
---|
| 138 | |
---|
| 139 | #endif |
---|