source: NonGTP/Xerces/xerces/samples/SAXCount/SAXCountHandlers.hpp @ 358

Revision 358, 4.5 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: SAXCountHandlers.hpp,v $
19 * Revision 1.9  2004/09/08 13:55:34  peiyongz
20 * Apache License Version 2.0
21 *
22 * Revision 1.8  2004/02/15 19:43:15  amassari
23 * Removed cause for warnings in VC 7.1
24 *
25 * Revision 1.7  2002/11/05 21:46:20  tng
26 * Explicit code using namespace in application.
27 *
28 * Revision 1.6  2002/11/04 15:23:03  tng
29 * C++ Namespace Support.
30 *
31 * Revision 1.5  2002/02/01 22:41:07  peiyongz
32 * sane_include
33 *
34 * Revision 1.4  2001/08/02 17:10:29  tng
35 * Allow DOMCount/SAXCount/IDOMCount/SAX2Count to take a file that has a list of xml file as input.
36 *
37 * Revision 1.3  2000/03/02 19:53:47  roddey
38 * This checkin includes many changes done while waiting for the
39 * 1.1.0 code to be finished. I can't list them all here, but a list is
40 * available elsewhere.
41 *
42 * Revision 1.2  2000/02/06 07:47:23  rahulj
43 * Year 2K copyright swat.
44 *
45 * Revision 1.1.1.1  1999/11/09 01:09:32  twl
46 * Initial checkin
47 *
48 * Revision 1.7  1999/11/08 20:43:41  rahul
49 * Swat for adding in Product name and CVS comment log variable.
50 *
51 */
52
53
54// ---------------------------------------------------------------------------
55//  Includes
56// ---------------------------------------------------------------------------
57#include <xercesc/sax/HandlerBase.hpp>
58
59XERCES_CPP_NAMESPACE_USE
60
61XERCES_CPP_NAMESPACE_BEGIN
62class AttributeList;
63XERCES_CPP_NAMESPACE_END
64
65class SAXCountHandlers : public HandlerBase
66{
67public:
68    // -----------------------------------------------------------------------
69    //  Constructors and Destructor
70    // -----------------------------------------------------------------------
71    SAXCountHandlers();
72    ~SAXCountHandlers();
73
74
75    // -----------------------------------------------------------------------
76    //  Getter methods
77    // -----------------------------------------------------------------------
78    unsigned int getElementCount() const
79    {
80        return fElementCount;
81    }
82
83    unsigned int getAttrCount() const
84    {
85        return fAttrCount;
86    }
87
88    unsigned int getCharacterCount() const
89    {
90        return fCharacterCount;
91    }
92
93    bool getSawErrors() const
94    {
95        return fSawErrors;
96    }
97
98    unsigned int getSpaceCount() const
99    {
100        return fSpaceCount;
101    }
102
103
104    // -----------------------------------------------------------------------
105    //  Handlers for the SAX DocumentHandler interface
106    // -----------------------------------------------------------------------
107        void startElement(const XMLCh* const name, AttributeList& attributes);
108    void characters(const XMLCh* const chars, const unsigned int length);
109    void ignorableWhitespace(const XMLCh* const chars, const unsigned int length);
110    void resetDocument();
111
112
113    // -----------------------------------------------------------------------
114    //  Handlers for the SAX ErrorHandler interface
115    // -----------------------------------------------------------------------
116        void warning(const SAXParseException& exc);
117    void error(const SAXParseException& exc);
118    void fatalError(const SAXParseException& exc);
119    void resetErrors();
120
121
122private:
123    // -----------------------------------------------------------------------
124    //  Private data members
125    //
126    //  fAttrCount
127    //  fCharacterCount
128    //  fElementCount
129    //  fSpaceCount
130    //      These are just counters that are run upwards based on the input
131    //      from the document handlers.
132    //
133    //  fSawErrors
134    //      This is set by the error handlers, and is queryable later to
135    //      see if any errors occured.
136    // -----------------------------------------------------------------------
137    unsigned int    fAttrCount;
138    unsigned int    fCharacterCount;
139    unsigned int    fElementCount;
140    unsigned int    fSpaceCount;
141    bool            fSawErrors;
142};
Note: See TracBrowser for help on using the repository browser.