source: icXML/icXML-devel/samples/src/SAXCount/SAXCountHandlers.hpp @ 2733

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

More path fixes.

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