source: NonGTP/Xerces/xerces/samples/SAX2Count/SAX2CountHandlers.hpp @ 358

Revision 358, 4.1 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
1/*
2 * Copyright 1999-2000,2004 The Apache Software Foundation.
3 *
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
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17/*
18 * $Log: SAX2CountHandlers.hpp,v $
19 * Revision 1.7  2004/09/08 13:55:33  peiyongz
20 * Apache License Version 2.0
21 *
22 * Revision 1.6  2004/02/15 19:43:15  amassari
23 * Removed cause for warnings in VC 7.1
24 *
25 * Revision 1.5  2002/11/05 21:46:20  tng
26 * Explicit code using namespace in application.
27 *
28 * Revision 1.4  2002/02/01 22:38:52  peiyongz
29 * sane_include
30 *
31 * Revision 1.3  2001/08/02 17:10:29  tng
32 * Allow DOMCount/SAXCount/IDOMCount/SAX2Count to take a file that has a list of xml file as input.
33 *
34 * Revision 1.2  2000/08/09 22:40:15  jpolast
35 * updates for changes to sax2 core functionality.
36 *
37 * Revision 1.1  2000/08/08 17:17:21  jpolast
38 * initial checkin of SAX2Count
39 *
40 *
41 */
42
43
44// ---------------------------------------------------------------------------
45//  Includes
46// ---------------------------------------------------------------------------
47#include <xercesc/sax2/Attributes.hpp>
48#include <xercesc/sax2/DefaultHandler.hpp>
49
50XERCES_CPP_NAMESPACE_USE
51
52class SAX2CountHandlers : public DefaultHandler
53{
54public:
55    // -----------------------------------------------------------------------
56    //  Constructors and Destructor
57    // -----------------------------------------------------------------------
58    SAX2CountHandlers();
59    ~SAX2CountHandlers();
60
61
62    // -----------------------------------------------------------------------
63    //  Getter methods
64    // -----------------------------------------------------------------------
65    unsigned int getElementCount() const
66    {
67        return fElementCount;
68    }
69
70    unsigned int getAttrCount() const
71    {
72        return fAttrCount;
73    }
74
75    unsigned int getCharacterCount() const
76    {
77        return fCharacterCount;
78    }
79
80    bool getSawErrors() const
81    {
82        return fSawErrors;
83    }
84
85    unsigned int getSpaceCount() const
86    {
87        return fSpaceCount;
88    }
89
90
91    // -----------------------------------------------------------------------
92    //  Handlers for the SAX ContentHandler interface
93    // -----------------------------------------------------------------------
94    void startElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname, const Attributes& attrs);
95    void characters(const XMLCh* const chars, const unsigned int length);
96    void ignorableWhitespace(const XMLCh* const chars, const unsigned int length);
97    void resetDocument();
98
99
100    // -----------------------------------------------------------------------
101    //  Handlers for the SAX ErrorHandler interface
102    // -----------------------------------------------------------------------
103        void warning(const SAXParseException& exc);
104    void error(const SAXParseException& exc);
105    void fatalError(const SAXParseException& exc);
106    void resetErrors();
107
108
109private:
110    // -----------------------------------------------------------------------
111    //  Private data members
112    //
113    //  fAttrCount
114    //  fCharacterCount
115    //  fElementCount
116    //  fSpaceCount
117    //      These are just counters that are run upwards based on the input
118    //      from the document handlers.
119    //
120    //  fSawErrors
121    //      This is set by the error handlers, and is queryable later to
122    //      see if any errors occured.
123    // -----------------------------------------------------------------------
124    unsigned int    fAttrCount;
125    unsigned int    fCharacterCount;
126    unsigned int    fElementCount;
127    unsigned int    fSpaceCount;
128    bool            fSawErrors;
129};
Note: See TracBrowser for help on using the repository browser.