2 * Copyright 1999-2000,2004 The Apache Software Foundation.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 * Revision 1.1 2004/11/23 13:38:52 lpadovan
20 * * basic infrastructure for collecting statistics
22 * Revision 1.11 2004/09/08 13:55:31 peiyongz
23 * Apache License Version 2.0
25 * Revision 1.10 2003/05/30 09:36:35 gareth
26 * Use new macros for iostream.h and std:: issues.
28 * Revision 1.9 2003/02/05 18:53:22 tng
29 * [Bug 11915] Utility for freeing memory.
31 * Revision 1.8 2002/11/05 21:46:19 tng
32 * Explicit code using namespace in application.
34 * Revision 1.7 2002/06/18 16:19:40 knoaman
35 * Replace XercesDOMParser with DOMBuilder for parsing XML documents.
37 * Revision 1.6 2002/02/01 22:35:01 peiyongz
40 * Revision 1.5 2000/10/20 22:00:35 andyh
41 * DOMCount sample Minor cleanup - rename error handler class to say that it is an error handler.
43 * Revision 1.4 2000/03/02 19:53:39 roddey
44 * This checkin includes many changes done while waiting for the
45 * 1.1.0 code to be finished. I can't list them all here, but a list is
46 * available elsewhere.
48 * Revision 1.3 2000/02/11 02:43:55 abagchi
49 * Removed StrX::transcode
51 * Revision 1.2 2000/02/06 07:47:17 rahulj
52 * Year 2K copyright swat.
54 * Revision 1.1.1.1 1999/11/09 01:09:52 twl
57 * Revision 1.5 1999/11/08 20:43:35 rahul
58 * Swat for adding in Product name and CVS comment log variable.
62 // ---------------------------------------------------------------------------
64 // ---------------------------------------------------------------------------
65 #include <xercesc/dom/DOMErrorHandler.hpp>
66 #include <xercesc/util/XMLString.hpp>
67 #if defined(XERCES_NEW_IOSTREAMS)
73 XERCES_CPP_NAMESPACE_USE
75 // ---------------------------------------------------------------------------
76 // Simple error handler deriviative to install on parser
77 // ---------------------------------------------------------------------------
78 class DOMCountErrorHandler : public DOMErrorHandler
81 // -----------------------------------------------------------------------
82 // Constructors and Destructor
83 // -----------------------------------------------------------------------
84 DOMCountErrorHandler();
85 ~DOMCountErrorHandler();
88 // -----------------------------------------------------------------------
90 // -----------------------------------------------------------------------
91 bool getSawErrors() const;
94 // -----------------------------------------------------------------------
95 // Implementation of the DOM ErrorHandler interface
96 // -----------------------------------------------------------------------
97 bool handleError(const DOMError& domError);
102 // -----------------------------------------------------------------------
103 // Unimplemented constructors and operators
104 // -----------------------------------------------------------------------
105 DOMCountErrorHandler(const DOMCountErrorHandler&);
106 void operator=(const DOMCountErrorHandler&);
109 // -----------------------------------------------------------------------
110 // Private data members
113 // This is set if we get any errors, and is queryable via a getter
114 // method. Its used by the main code to suppress output if there are
116 // -----------------------------------------------------------------------
121 // ---------------------------------------------------------------------------
122 // This is a simple class that lets us do easy (though not terribly efficient)
123 // trancoding of XMLCh data to local code page for display.
124 // ---------------------------------------------------------------------------
128 // -----------------------------------------------------------------------
129 // Constructors and Destructor
130 // -----------------------------------------------------------------------
131 StrX(const XMLCh* const toTranscode)
133 // Call the private transcoding method
134 fLocalForm = XMLString::transcode(toTranscode);
139 XMLString::release(&fLocalForm);
143 // -----------------------------------------------------------------------
145 // -----------------------------------------------------------------------
146 const char* localForm() const
152 // -----------------------------------------------------------------------
153 // Private data members
156 // This is the local code page form of the string.
157 // -----------------------------------------------------------------------
161 inline XERCES_STD_QUALIFIER ostream& operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump)
163 target << toDump.localForm();
167 inline bool DOMCountErrorHandler::getSawErrors() const