source: NonGTP/Xerces/xerces/samples/MemParse/MemParseHandlers.cpp @ 358

Revision 358, 4.3 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: MemParseHandlers.cpp,v $
19 * Revision 1.7  2004/09/08 13:55:32  peiyongz
20 * Apache License Version 2.0
21 *
22 * Revision 1.6  2003/05/30 09:36:35  gareth
23 * Use new macros for iostream.h and std:: issues.
24 *
25 * Revision 1.5  2002/02/01 22:37:14  peiyongz
26 * sane_include
27 *
28 * Revision 1.4  2000/05/15 22:31:08  andyh
29 * Replace #include<memory.h> with <string.h> everywhere.
30 *
31 * Revision 1.3  2000/03/02 19:53:42  roddey
32 * This checkin includes many changes done while waiting for the
33 * 1.1.0 code to be finished. I can't list them all here, but a list is
34 * available elsewhere.
35 *
36 * Revision 1.2  2000/02/06 07:47:19  rahulj
37 * Year 2K copyright swat.
38 *
39 * Revision 1.1.1.1  1999/11/09 01:09:50  twl
40 * Initial checkin
41 *
42 * Revision 1.7  1999/11/08 20:43:37  rahul
43 * Swat for adding in Product name and CVS comment log variable.
44 *
45 */
46
47
48
49// ---------------------------------------------------------------------------
50//  Includes
51// ---------------------------------------------------------------------------
52#include "MemParse.hpp"
53#include <string.h>
54#include <xercesc/sax/AttributeList.hpp>
55#include <xercesc/sax/SAXParseException.hpp>
56#include <xercesc/sax/SAXException.hpp>
57
58
59
60// ---------------------------------------------------------------------------
61//  MemParseHandlers: Constructors and Destructor
62// ---------------------------------------------------------------------------
63MemParseHandlers::MemParseHandlers() :
64
65    fElementCount(0)
66    , fAttrCount(0)
67    , fCharacterCount(0)
68    , fSpaceCount(0)
69{
70}
71
72MemParseHandlers::~MemParseHandlers()
73{
74}
75
76
77// ---------------------------------------------------------------------------
78//  MemParseHandlers: Implementation of the SAX DocumentHandler interface
79// ---------------------------------------------------------------------------
80void MemParseHandlers::startElement(const   XMLCh* const    name
81                                    ,       AttributeList&  attributes)
82{
83    fElementCount++;
84    fAttrCount += attributes.getLength();
85}
86
87void MemParseHandlers::characters(  const   XMLCh* const    chars
88                                    , const unsigned int    length)
89{
90    fCharacterCount += length;
91}
92
93void MemParseHandlers::ignorableWhitespace( const   XMLCh* const chars
94                                            , const unsigned int length)
95{
96    fSpaceCount += length;
97}
98
99void MemParseHandlers::resetDocument()
100{
101    fAttrCount = 0;
102    fCharacterCount = 0;
103    fElementCount = 0;
104    fSpaceCount = 0;
105}
106
107
108
109// ---------------------------------------------------------------------------
110//  MemParseHandlers: Overrides of the SAX ErrorHandler interface
111// ---------------------------------------------------------------------------
112void MemParseHandlers::error(const SAXParseException& e)
113{
114    XERCES_STD_QUALIFIER cerr << "\nError at (file " << StrX(e.getSystemId())
115                 << ", line " << e.getLineNumber()
116                 << ", char " << e.getColumnNumber()
117         << "): " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl;
118}
119
120void MemParseHandlers::fatalError(const SAXParseException& e)
121{
122    XERCES_STD_QUALIFIER cerr << "\nFatal Error at (file " << StrX(e.getSystemId())
123                 << ", line " << e.getLineNumber()
124                 << ", char " << e.getColumnNumber()
125         << "): " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl;
126}
127
128void MemParseHandlers::warning(const SAXParseException& e)
129{
130    XERCES_STD_QUALIFIER cerr << "\nWarning at (file " << StrX(e.getSystemId())
131                 << ", line " << e.getLineNumber()
132                 << ", char " << e.getColumnNumber()
133         << "): " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl;
134}
135
136
Note: See TracBrowser for help on using the repository browser.