source: NonGTP/Xerces/xerces/samples/PParse/PParseHandlers.hpp @ 358

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

xerces added

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