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: XMLErrorReporter.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
20 | */ |
---|
21 | |
---|
22 | |
---|
23 | #if !defined(XMLERRORREPORTER_HPP) |
---|
24 | #define XMLERRORREPORTER_HPP |
---|
25 | |
---|
26 | #include <xercesc/util/XercesDefs.hpp> |
---|
27 | |
---|
28 | XERCES_CPP_NAMESPACE_BEGIN |
---|
29 | |
---|
30 | |
---|
31 | /** |
---|
32 | * This abstract class defines a callback mechanism for the scanner. By |
---|
33 | * creating a class that implements this interface and plugging an instance |
---|
34 | * of that class into the scanner, the scanner will call back on the object's |
---|
35 | * virtual methods to report error events. This class is also used with the |
---|
36 | * validator, to allow it to report errors. |
---|
37 | * |
---|
38 | * This class is primarily for use by those writing their own parser classes. |
---|
39 | * If you use the standard parser classes, DOMParser and SAXParser, you won't |
---|
40 | * use this API. You will instead use a similar mechanism defined by the SAX |
---|
41 | * API, called ErrorHandler. |
---|
42 | */ |
---|
43 | class XMLPARSER_EXPORT XMLErrorReporter |
---|
44 | { |
---|
45 | public: |
---|
46 | // ----------------------------------------------------------------------- |
---|
47 | // The types of errors we can issue |
---|
48 | // ----------------------------------------------------------------------- |
---|
49 | enum ErrTypes |
---|
50 | { |
---|
51 | ErrType_Warning |
---|
52 | , ErrType_Error |
---|
53 | , ErrType_Fatal |
---|
54 | |
---|
55 | , ErrTypes_Unknown |
---|
56 | }; |
---|
57 | |
---|
58 | |
---|
59 | // ----------------------------------------------------------------------- |
---|
60 | // Constructors are hidden, only the virtual destructor is exposed |
---|
61 | // ----------------------------------------------------------------------- |
---|
62 | |
---|
63 | /** @name Destructor */ |
---|
64 | //@{ |
---|
65 | |
---|
66 | /** |
---|
67 | * Default destructor |
---|
68 | */ |
---|
69 | virtual ~XMLErrorReporter() |
---|
70 | { |
---|
71 | } |
---|
72 | //@} |
---|
73 | |
---|
74 | |
---|
75 | // ----------------------------------------------------------------------- |
---|
76 | // The error handler interface |
---|
77 | // ----------------------------------------------------------------------- |
---|
78 | |
---|
79 | /** @name Error Handler interface */ |
---|
80 | //@{ |
---|
81 | |
---|
82 | /** Called to report errors from the scanner or validator |
---|
83 | * |
---|
84 | * This method is called back on by the scanner or validator (or any other |
---|
85 | * internal parser component which might need to report an error in the |
---|
86 | * future.) It contains all the information that the client code might |
---|
87 | * need to report or log the error. |
---|
88 | * |
---|
89 | * @param errCode The error code of the error being reported. What |
---|
90 | * this means is dependent on the domain it is from. |
---|
91 | * |
---|
92 | * @param errDomain The domain from which the error occured. The domain |
---|
93 | * is a means of providing a hierarchical layering to |
---|
94 | * the error system, so that a single set of error id |
---|
95 | * numbers don't have to be split up. |
---|
96 | * |
---|
97 | * @param type The error type, which is defined mostly by XML which |
---|
98 | * categorizes errors into warning, errors and validity |
---|
99 | * constraints. |
---|
100 | * |
---|
101 | * @param errorText The actual text of the error. This is translatable, |
---|
102 | * so can possibly be in the local language if a |
---|
103 | * translation has been provided. |
---|
104 | * |
---|
105 | * @param systemId The system id of the entity where the error occured, |
---|
106 | * fully qualified. |
---|
107 | * |
---|
108 | * @param publicId The optional public id of the entity were the error |
---|
109 | * occured. It can be an empty string if non was provided. |
---|
110 | * |
---|
111 | * @param lineNum The line number within the source XML of the error. |
---|
112 | * |
---|
113 | * @param colNum The column number within the source XML of the error. |
---|
114 | * Because of the parsing style, this is usually just |
---|
115 | * after the actual offending text. |
---|
116 | */ |
---|
117 | virtual void error |
---|
118 | ( |
---|
119 | const unsigned int errCode |
---|
120 | , const XMLCh* const errDomain |
---|
121 | , const ErrTypes type |
---|
122 | , const XMLCh* const errorText |
---|
123 | , const XMLCh* const systemId |
---|
124 | , const XMLCh* const publicId |
---|
125 | , const XMLSSize_t lineNum |
---|
126 | , const XMLSSize_t colNum |
---|
127 | ) = 0; |
---|
128 | |
---|
129 | /** Called before a new parse event to allow the handler to reset |
---|
130 | * |
---|
131 | * This method is called by the scanner before a new parse event is |
---|
132 | * about to start. It gives the error handler a chance to reset its |
---|
133 | * internal state. |
---|
134 | */ |
---|
135 | virtual void resetErrors() = 0; |
---|
136 | |
---|
137 | //@} |
---|
138 | |
---|
139 | |
---|
140 | protected : |
---|
141 | |
---|
142 | /** @name Constructor */ |
---|
143 | //@{ |
---|
144 | |
---|
145 | /** |
---|
146 | * Default constructor |
---|
147 | */ |
---|
148 | XMLErrorReporter() |
---|
149 | { |
---|
150 | } |
---|
151 | //@} |
---|
152 | |
---|
153 | private: |
---|
154 | // ----------------------------------------------------------------------- |
---|
155 | // Unimplemented constructors and destructor |
---|
156 | // ----------------------------------------------------------------------- |
---|
157 | XMLErrorReporter(const XMLErrorReporter&); |
---|
158 | XMLErrorReporter& operator=(const XMLErrorReporter&); |
---|
159 | }; |
---|
160 | |
---|
161 | XERCES_CPP_NAMESPACE_END |
---|
162 | |
---|
163 | #endif |
---|