source: NonGTP/Xerces/xercesc/sax/HandlerBase.hpp @ 188

Revision 188, 18.0 KB checked in by mattausch, 19 years ago (diff)

added xercesc to support

Line 
1/*
2 * The Apache Software License, Version 1.1
3 *
4 * Copyright (c) 1999-2000 The Apache Software Foundation.  All rights
5 * reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in
16 *    the documentation and/or other materials provided with the
17 *    distribution.
18 *
19 * 3. The end-user documentation included with the redistribution,
20 *    if any, must include the following acknowledgment:
21 *       "This product includes software developed by the
22 *        Apache Software Foundation (http://www.apache.org/)."
23 *    Alternately, this acknowledgment may appear in the software itself,
24 *    if and wherever such third-party acknowledgments normally appear.
25 *
26 * 4. The names "Xerces" and "Apache Software Foundation" must
27 *    not be used to endorse or promote products derived from this
28 *    software without prior written permission. For written
29 *    permission, please contact apache\@apache.org.
30 *
31 * 5. Products derived from this software may not be called "Apache",
32 *    nor may "Apache" appear in their name, without prior written
33 *    permission of the Apache Software Foundation.
34 *
35 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46 * SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This software consists of voluntary contributions made by many
50 * individuals on behalf of the Apache Software Foundation, and was
51 * originally based on software copyright (c) 1999, International
52 * Business Machines, Inc., http://www.ibm.com .  For more information
53 * on the Apache Software Foundation, please see
54 * <http://www.apache.org/>.
55 */
56
57/*
58 * $Log: HandlerBase.hpp,v $
59 * Revision 1.8  2004/01/29 11:46:32  cargilld
60 * Code cleanup changes to get rid of various compiler diagnostic messages.
61 *
62 * Revision 1.7  2003/12/01 23:23:26  neilg
63 * fix for bug 25118; thanks to Jeroen Witmond
64 *
65 * Revision 1.6  2003/05/30 16:11:44  gareth
66 * Fixes so we compile under VC7.1. Patch by Alberto Massari.
67 *
68 * Revision 1.5  2002/11/04 14:56:25  tng
69 * C++ Namespace Support.
70 *
71 * Revision 1.4  2002/07/16 18:15:00  tng
72 * [Bug 6070] warning unused variable in HandlerBase.hpp
73 *
74 * Revision 1.3  2002/06/06 20:39:16  tng
75 * Document Fix: document that the returned object from resolveEntity is owned by the parser
76 *
77 * Revision 1.2  2002/02/20 18:17:01  tng
78 * [Bug 5977] Warnings on generating apiDocs.
79 *
80 * Revision 1.1.1.1  2002/02/01 22:22:08  peiyongz
81 * sane_include
82 *
83 * Revision 1.6  2000/03/02 19:54:35  roddey
84 * This checkin includes many changes done while waiting for the
85 * 1.1.0 code to be finished. I can't list them all here, but a list is
86 * available elsewhere.
87 *
88 * Revision 1.5  2000/02/24 20:12:55  abagchi
89 * Swat for removing Log from API docs
90 *
91 * Revision 1.4  2000/02/12 03:31:55  rahulj
92 * Removed duplicate CVS Log entries.
93 *
94 * Revision 1.3  2000/02/12 01:27:19  aruna1
95 * Documentation updated
96 *
97 * Revision 1.2  2000/02/06 07:47:57  rahulj
98 * Year 2K copyright swat.
99 *
100 * Revision 1.1.1.1  1999/11/09 01:07:45  twl
101 * Initial checkin
102 *
103 * Revision 1.2  1999/11/08 20:45:00  rahul
104 * Swat for adding in Product name and CVS comment log variable.
105 *
106 */
107
108
109#ifndef HANDLERBASE_HPP
110#define HANDLERBASE_HPP
111
112#include <xercesc/sax/DocumentHandler.hpp>
113#include <xercesc/sax/DTDHandler.hpp>
114#include <xercesc/sax/EntityResolver.hpp>
115#include <xercesc/sax/ErrorHandler.hpp>
116#include <xercesc/sax/SAXParseException.hpp>
117
118XERCES_CPP_NAMESPACE_BEGIN
119
120class Locator;
121class AttributeList;
122
123/**
124  * Default base class for handlers.
125  *
126  * <p>This class implements the default behaviour for four SAX
127  * interfaces: EntityResolver, DTDHandler, DocumentHandler,
128  * and ErrorHandler.</p>
129  *
130  * <p>Application writers can extend this class when they need to
131  * implement only part of an interface; parser writers can
132  * instantiate this class to provide default handlers when the
133  * application has not supplied its own.</p>
134  *
135  * <p>Note that the use of this class is optional.</p>
136  *
137  * @see EntityResolver#EntityResolver
138  * @see DTDHandler#DTDHandler
139  * @see DocumentHandler#DocumentHandler
140  * @see ErrorHandler#ErrorHandler
141  */
142
143class SAX_EXPORT HandlerBase :
144
145    public EntityResolver, public DTDHandler, public DocumentHandler
146    , public ErrorHandler
147{
148public:
149    /** @name Default handlers for the DocumentHandler interface */
150    //@{
151  /**
152    * Receive notification of character data inside an element.
153    *
154    * <p>By default, do nothing.  Application writers may override this
155    * method to take specific actions for each chunk of character data
156    * (such as adding the data to a node or buffer, or printing it to
157    * a file).</p>
158    *
159    * @param chars The characters.
160    * @param length The number of characters to use from the
161    *               character array.
162    * @exception SAXException Any SAX exception, possibly
163    *            wrapping another exception.
164    * @see DocumentHandler#characters
165    */
166    virtual void characters
167    (
168        const   XMLCh* const    chars
169        , const unsigned int    length
170    );
171
172  /**
173    * Receive notification of the end of the document.
174    *
175    * <p>By default, do nothing.  Application writers may override this
176    * method in a subclass to take specific actions at the beginning
177    * of a document (such as finalising a tree or closing an output
178    * file).</p>
179    *
180    * @exception SAXException Any SAX exception, possibly
181    *            wrapping another exception.
182    * @see DocumentHandler#endDocument
183    */
184    virtual void endDocument();
185
186  /**
187    * Receive notification of the end of an element.
188    *
189    * <p>By default, do nothing.  Application writers may override this
190    * method in a subclass to take specific actions at the end of
191    * each element (such as finalising a tree node or writing
192    * output to a file).</p>
193    *
194    * @param name The element type name.
195    * @exception SAXException Any SAX exception, possibly
196    *            wrapping another exception.
197    * @see DocumentHandler#endElement
198    */
199    virtual void endElement(const XMLCh* const name);
200
201  /**
202    * Receive notification of ignorable whitespace in element content.
203    *
204    * <p>By default, do nothing.  Application writers may override this
205    * method to take specific actions for each chunk of ignorable
206    * whitespace (such as adding data to a node or buffer, or printing
207    * it to a file).</p>
208    *
209    * @param chars The whitespace characters.
210    * @param length The number of characters to use from the
211    *               character array.
212    * @exception SAXException Any SAX exception, possibly
213    *            wrapping another exception.
214    * @see DocumentHandler#ignorableWhitespace
215    */
216    virtual void ignorableWhitespace
217    (
218        const   XMLCh* const    chars
219        , const unsigned int    length
220    );
221
222  /**
223    * Receive notification of a processing instruction.
224    *
225    * <p>By default, do nothing.  Application writers may override this
226    * method in a subclass to take specific actions for each
227    * processing instruction, such as setting status variables or
228    * invoking other methods.</p>
229    *
230    * @param target The processing instruction target.
231    * @param data The processing instruction data, or null if
232    *             none is supplied.
233    * @exception SAXException Any SAX exception, possibly
234    *            wrapping another exception.
235    * @see DocumentHandler#processingInstruction
236    */
237    virtual void processingInstruction
238    (
239        const   XMLCh* const    target
240        , const XMLCh* const    data
241    );
242
243    /**
244    * Reset the Docuemnt object on its reuse
245    *
246    * @see DocumentHandler#resetDocument
247    */
248    virtual void resetDocument();
249    //@}
250
251    /** @name Default implementation of DocumentHandler interface */
252
253    //@{
254  /**
255    * Receive a Locator object for document events.
256    *
257    * <p>By default, do nothing.  Application writers may override this
258    * method in a subclass if they wish to store the locator for use
259    * with other document events.</p>
260    *
261    * @param locator A locator for all SAX document events.
262    * @see DocumentHandler#setDocumentLocator
263    * @see Locator
264    */
265    virtual void setDocumentLocator(const Locator* const locator);
266
267  /**
268    * Receive notification of the beginning of the document.
269    *
270    * <p>By default, do nothing.  Application writers may override this
271    * method in a subclass to take specific actions at the beginning
272    * of a document (such as allocating the root node of a tree or
273    * creating an output file).</p>
274    *
275    * @exception SAXException Any SAX exception, possibly
276    *            wrapping another exception.
277    * @see DocumentHandler#startDocument
278    */
279    virtual void startDocument();
280
281  /**
282    * Receive notification of the start of an element.
283    *
284    * <p>By default, do nothing.  Application writers may override this
285    * method in a subclass to take specific actions at the start of
286    * each element (such as allocating a new tree node or writing
287    * output to a file).</p>
288    *
289    * @param name The element type name.
290    * @param attributes The specified or defaulted attributes.
291    * @exception SAXException Any SAX exception, possibly
292    *            wrapping another exception.
293    * @see DocumentHandler#startElement
294    */
295    virtual void startElement
296    (
297        const   XMLCh* const    name
298        ,       AttributeList&  attributes
299    );
300
301    //@}
302
303    /** @name Default implementation of the EntityResolver interface. */
304
305    //@{
306  /**
307    * Resolve an external entity.
308    *
309    * <p>Always return null, so that the parser will use the system
310    * identifier provided in the XML document.  This method implements
311    * the SAX default behaviour: application writers can override it
312    * in a subclass to do special translations such as catalog lookups
313    * or URI redirection.</p>
314    *
315    * @param publicId The public identifer, or null if none is
316    *                 available.
317    * @param systemId The system identifier provided in the XML
318    *                 document.
319    * @return The new input source, or null to require the
320    *         default behaviour.
321    *         The returned InputSource is owned by the parser which is
322    *         responsible to clean up the memory.
323    * @exception SAXException Any SAX exception, possibly
324    *            wrapping another exception.
325    * @see EntityResolver#resolveEntity
326    */
327    virtual InputSource* resolveEntity
328    (
329        const   XMLCh* const    publicId
330        , const XMLCh* const    systemId
331    );
332
333    //@}
334
335    /** @name Default implementation of the ErrorHandler interface */
336    //@{
337   /**
338    * Receive notification of a recoverable parser error.
339    *
340    * <p>The default implementation does nothing.  Application writers
341    * may override this method in a subclass to take specific actions
342    * for each error, such as inserting the message in a log file or
343    * printing it to the console.</p>
344    *
345    * @param exc The warning information encoded as an exception.
346    * @exception SAXException Any SAX exception, possibly
347    *            wrapping another exception.
348    * @see ErrorHandler#warning
349    * @see SAXParseException#SAXParseException
350    */
351    virtual void error(const SAXParseException& exc);
352
353  /**
354    * Report a fatal XML parsing error.
355    *
356    * <p>The default implementation throws a SAXParseException.
357    * Application writers may override this method in a subclass if
358    * they need to take specific actions for each fatal error (such as
359    * collecting all of the errors into a single report): in any case,
360    * the application must stop all regular processing when this
361    * method is invoked, since the document is no longer reliable, and
362    * the parser may no longer report parsing events.</p>
363    *
364    * @param exc The error information encoded as an exception.
365    * @exception SAXException Any SAX exception, possibly
366    *            wrapping another exception.
367    * @see ErrorHandler#fatalError
368    * @see SAXParseException#SAXParseException
369    */
370    virtual void fatalError(const SAXParseException& exc);
371
372  /**
373    * Receive notification of a parser warning.
374    *
375    * <p>The default implementation does nothing.  Application writers
376    * may override this method in a subclass to take specific actions
377    * for each warning, such as inserting the message in a log file or
378    * printing it to the console.</p>
379    *
380    * @param exc The warning information encoded as an exception.
381    * @exception SAXException Any SAX exception, possibly
382    *            wrapping another exception.
383    * @see ErrorHandler#warning
384    * @see SAXParseException#SAXParseException
385    */
386    virtual void warning(const SAXParseException& exc);
387
388    /**
389    * Reset the Error handler object on its reuse
390    *
391    * @see ErrorHandler#resetErrors
392    */
393    virtual void resetErrors();
394
395    //@}
396
397
398    /** @name Default implementation of DTDHandler interface. */
399    //@{
400
401  /**
402    * Receive notification of a notation declaration.
403    *
404    * <p>By default, do nothing.  Application writers may override this
405    * method in a subclass if they wish to keep track of the notations
406    * declared in a document.</p>
407    *
408    * @param name The notation name.
409    * @param publicId The notation public identifier, or null if not
410    *                 available.
411    * @param systemId The notation system identifier.
412    * @see DTDHandler#notationDecl
413    */
414    virtual void notationDecl
415    (
416        const   XMLCh* const    name
417        , const XMLCh* const    publicId
418        , const XMLCh* const    systemId
419    );
420
421    /**
422    * Reset the DTD object on its reuse
423    *
424    * @see DTDHandler#resetDocType
425    */
426    virtual void resetDocType();
427
428  /**
429    * Receive notification of an unparsed entity declaration.
430    *
431    * <p>By default, do nothing.  Application writers may override this
432    * method in a subclass to keep track of the unparsed entities
433    * declared in a document.</p>
434    *
435    * @param name The entity name.
436    * @param publicId The entity public identifier, or null if not
437    *                 available.
438    * @param systemId The entity system identifier.
439    * @param notationName The name of the associated notation.
440    * @see DTDHandler#unparsedEntityDecl
441    */
442    virtual void unparsedEntityDecl
443    (
444        const   XMLCh* const    name
445        , const XMLCh* const    publicId
446        , const XMLCh* const    systemId
447        , const XMLCh* const    notationName
448    );
449    //@}
450
451    HandlerBase() {};
452    virtual ~HandlerBase() {};
453
454private:
455        // -----------------------------------------------------------------------
456    //  Unimplemented constructors and operators
457    // -----------------------------------------------------------------------
458    HandlerBase(const HandlerBase&);
459    HandlerBase& operator=(const HandlerBase&);
460};
461
462
463// ---------------------------------------------------------------------------
464//  HandlerBase: Inline default implementations
465// ---------------------------------------------------------------------------
466inline void HandlerBase::characters(const   XMLCh* const
467                                    , const unsigned int)
468{
469}
470
471inline void HandlerBase::endDocument()
472{
473}
474
475inline void HandlerBase::endElement(const XMLCh* const)
476{
477}
478
479inline void HandlerBase::error(const SAXParseException&)
480{
481}
482
483inline void HandlerBase::fatalError(const SAXParseException& exc)
484{
485    throw exc;
486}
487
488inline void
489HandlerBase::ignorableWhitespace(   const   XMLCh* const
490                                    , const unsigned int)
491{
492}
493
494inline void HandlerBase::notationDecl(  const   XMLCh* const
495                                        , const XMLCh* const
496                                        , const XMLCh* const)
497{
498}
499
500inline void
501HandlerBase::processingInstruction( const   XMLCh* const
502                                    , const XMLCh* const)
503{
504}
505
506inline void HandlerBase::resetErrors()
507{
508}
509
510inline void HandlerBase::resetDocument()
511{
512}
513
514inline void HandlerBase::resetDocType()
515{
516}
517
518inline InputSource*
519HandlerBase::resolveEntity( const   XMLCh* const
520                            , const XMLCh* const)
521{
522    return 0;
523}
524
525inline void
526HandlerBase::unparsedEntityDecl(const   XMLCh* const
527                                , const XMLCh* const
528                                , const XMLCh* const
529                                , const XMLCh* const)
530{
531}
532
533inline void HandlerBase::setDocumentLocator(const Locator* const)
534{
535}
536
537inline void HandlerBase::startDocument()
538{
539}
540
541inline void
542HandlerBase::startElement(  const   XMLCh* const
543                            ,       AttributeList&)
544{
545}
546
547inline void HandlerBase::warning(const SAXParseException&)
548{
549}
550
551XERCES_CPP_NAMESPACE_END
552
553#endif
Note: See TracBrowser for help on using the repository browser.