source: icXML/icXML-devel/samples/src/SAX2Count/SAX2CountHandlers.hpp @ 2726

Last change on this file since 2726 was 2726, checked in by cameron, 6 years ago

Add original Xerces tests and samples directories

File size: 3.6 KB
Line 
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: SAX2CountHandlers.hpp 679377 2008-07-24 11:56:42Z borisk $
20 */
21
22
23// ---------------------------------------------------------------------------
24//  Includes
25// ---------------------------------------------------------------------------
26#include <xercesc/sax2/Attributes.hpp>
27#include <xercesc/sax2/DefaultHandler.hpp>
28
29XERCES_CPP_NAMESPACE_USE
30
31class SAX2CountHandlers : public DefaultHandler
32{
33public:
34    // -----------------------------------------------------------------------
35    //  Constructors and Destructor
36    // -----------------------------------------------------------------------
37    SAX2CountHandlers();
38    ~SAX2CountHandlers();
39
40
41    // -----------------------------------------------------------------------
42    //  Getter methods
43    // -----------------------------------------------------------------------
44    XMLSize_t getElementCount() const
45    {
46        return fElementCount;
47    }
48
49    XMLSize_t getAttrCount() const
50    {
51        return fAttrCount;
52    }
53
54    XMLSize_t getCharacterCount() const
55    {
56        return fCharacterCount;
57    }
58
59    bool getSawErrors() const
60    {
61        return fSawErrors;
62    }
63
64    XMLSize_t getSpaceCount() const
65    {
66        return fSpaceCount;
67    }
68
69
70    // -----------------------------------------------------------------------
71    //  Handlers for the SAX ContentHandler interface
72    // -----------------------------------------------------------------------
73    void startElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname, const Attributes& attrs);
74    void characters(const XMLCh* const chars, const XMLSize_t length);
75    void ignorableWhitespace(const XMLCh* const chars, const XMLSize_t length);
76    void startDocument();
77
78
79    // -----------------------------------------------------------------------
80    //  Handlers for the SAX ErrorHandler interface
81    // -----------------------------------------------------------------------
82        void warning(const SAXParseException& exc);
83    void error(const SAXParseException& exc);
84    void fatalError(const SAXParseException& exc);
85    void resetErrors();
86
87
88private:
89    // -----------------------------------------------------------------------
90    //  Private data members
91    //
92    //  fAttrCount
93    //  fCharacterCount
94    //  fElementCount
95    //  fSpaceCount
96    //      These are just counters that are run upwards based on the input
97    //      from the document handlers.
98    //
99    //  fSawErrors
100    //      This is set by the error handlers, and is queryable later to
101    //      see if any errors occured.
102    // -----------------------------------------------------------------------
103    XMLSize_t       fAttrCount;
104    XMLSize_t       fCharacterCount;
105    XMLSize_t       fElementCount;
106    XMLSize_t       fSpaceCount;
107    bool            fSawErrors;
108};
Note: See TracBrowser for help on using the repository browser.