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

Revision 188, 11.5 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-2001 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: Parser.hpp,v $
59 * Revision 1.4  2003/03/07 18:10:06  tng
60 * Return a reference instead of void for operator=
61 *
62 * Revision 1.3  2002/11/04 14:56:26  tng
63 * C++ Namespace Support.
64 *
65 * Revision 1.2  2002/07/11 18:29:09  knoaman
66 * Grammar caching/preparsing - initial implementation.
67 *
68 * Revision 1.1.1.1  2002/02/01 22:22:08  peiyongz
69 * sane_include
70 *
71 * Revision 1.8  2001/05/11 13:26:24  tng
72 * Copyright update.
73 *
74 * Revision 1.7  2001/03/21 21:56:10  tng
75 * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
76 *
77 * Revision 1.6  2000/03/02 19:54:35  roddey
78 * This checkin includes many changes done while waiting for the
79 * 1.1.0 code to be finished. I can't list them all here, but a list is
80 * available elsewhere.
81 *
82 * Revision 1.5  2000/02/24 20:12:55  abagchi
83 * Swat for removing Log from API docs
84 *
85 * Revision 1.4  2000/02/12 03:31:55  rahulj
86 * Removed duplicate CVS Log entries.
87 *
88 * Revision 1.3  2000/02/09 01:59:12  abagchi
89 * Removed private function docs, added parse docs
90 *
91 * Revision 1.2  2000/02/06 07:47:58  rahulj
92 * Year 2K copyright swat.
93 *
94 * Revision 1.1.1.1  1999/11/09 01:07:46  twl
95 * Initial checkin
96 *
97 * Revision 1.3  1999/11/08 20:45:02  rahul
98 * Swat for adding in Product name and CVS comment log variable.
99 *
100 */
101
102#ifndef PARSER_HPP
103#define PARSER_HPP
104
105#include <xercesc/util/XercesDefs.hpp>
106
107XERCES_CPP_NAMESPACE_BEGIN
108
109class DTDHandler;
110class EntityResolver;
111class DocumentHandler;
112class ErrorHandler;
113class InputSource;
114
115/**
116  * Basic interface for SAX (Simple API for XML) parsers.
117  *
118  * All SAX parsers must implement this basic interface: it allows
119  * applications to register handlers for different types of events
120  * and to initiate a parse from a URI, or a character stream.
121  *
122  * All SAX parsers must also implement a zero-argument constructor
123  * (though other constructors are also allowed).
124  *
125  * SAX parsers are reusable but not re-entrant: the application
126  * may reuse a parser object (possibly with a different input source)
127  * once the first parse has completed successfully, but it may not
128  * invoke the parse() methods recursively within a parse.
129  *
130  * @see EntityResolver#EntityResolver
131  * @see DTDHandler#DTDHandler
132  * @see DocumentHandler#DocumentHandler
133  * @see ErrorHandler#ErrorHandler
134  * @see HandlerBase#HandlerBase
135  * @see InputSource#InputSource
136  */
137
138#include <xercesc/util/XercesDefs.hpp>
139
140class SAX_EXPORT Parser
141{
142public:
143    /** @name Constructors and Destructor */
144    // -----------------------------------------------------------------------
145    //  Constructors and Destructor
146    // -----------------------------------------------------------------------
147    //@{
148    /** The default constructor */
149    Parser()
150    {
151    }
152    /** The destructor */
153    virtual ~Parser()
154    {
155    }
156    //@}
157
158    //-----------------------------------------------------------------------
159    // The parser interface
160    //-----------------------------------------------------------------------
161    /** @name The parser interfaces */
162    //@{
163  /**
164    * Allow an application to register a custom entity resolver.
165    *
166    * If the application does not register an entity resolver, the
167    * SAX parser will resolve system identifiers and open connections
168    * to entities itself (this is the default behaviour implemented in
169    * HandlerBase).
170    *
171    * Applications may register a new or different entity resolver
172    * in the middle of a parse, and the SAX parser must begin using
173    * the new resolver immediately.
174    *
175    * @param resolver The object for resolving entities.
176    * @see EntityResolver#EntityResolver
177    * @see HandlerBase#HandlerBase
178    */
179    virtual void setEntityResolver(EntityResolver* const resolver) = 0;
180
181  /**
182    * Allow an application to register a DTD event handler.
183    *
184    * If the application does not register a DTD handler, all DTD
185    * events reported by the SAX parser will be silently ignored (this
186    * is the default behaviour implemented by HandlerBase).
187    *
188    * Applications may register a new or different handler in the middle
189    * of a parse, and the SAX parser must begin using the new handler
190    * immediately.
191    *
192    * @param handler The DTD handler.
193    * @see DTDHandler#DTDHandler
194    * @see HandlerBase#HandlerBase
195    */
196    virtual void setDTDHandler(DTDHandler* const handler) = 0;
197
198  /**
199    * Allow an application to register a document event handler.
200    *
201    * If the application does not register a document handler, all
202    * document events reported by the SAX parser will be silently
203    * ignored (this is the default behaviour implemented by
204    * HandlerBase).
205    *
206    * Applications may register a new or different handler in the
207    * middle of a parse, and the SAX parser must begin using the new
208    * handler immediately.
209    *
210    * @param handler The document handler.
211    * @see DocumentHandler#DocumentHandler
212    * @see HandlerBase#HandlerBase
213    */
214    virtual void setDocumentHandler(DocumentHandler* const handler) = 0;
215
216  /**
217    * Allow an application to register an error event handler.
218    *
219    * If the application does not register an error event handler,
220    * all error events reported by the SAX parser will be silently
221    * ignored, except for fatalError, which will throw a SAXException
222    * (this is the default behaviour implemented by HandlerBase).
223    *
224    * Applications may register a new or different handler in the
225    * middle of a parse, and the SAX parser must begin using the new
226    * handler immediately.
227    *
228    * @param handler The error handler.
229    * @see ErrorHandler#ErrorHandler
230    * @see SAXException#SAXException
231    * @see HandlerBase#HandlerBase
232    */
233    virtual void setErrorHandler(ErrorHandler* const handler) = 0;
234
235  /**
236    * Parse an XML document.
237    *
238    * The application can use this method to instruct the SAX parser
239    * to begin parsing an XML document from any valid input
240    * source (a character stream, a byte stream, or a URI).
241    *
242    * Applications may not invoke this method while a parse is in
243    * progress (they should create a new Parser instead for each
244    * additional XML document).  Once a parse is complete, an
245    * application may reuse the same Parser object, possibly with a
246    * different input source.
247    *
248    * @param source The input source for the top-level of the
249    *               XML document.
250    * @exception SAXException Any SAX exception, possibly
251    *            wrapping another exception.
252    * @exception XMLException An exception from the parser or client
253    *            handler code.
254    * @see InputSource#InputSource
255    * @see #setEntityResolver
256    * @see #setDTDHandler
257    * @see #setDocumentHandler
258    * @see #setErrorHandler
259    */
260    virtual void parse
261    (
262        const   InputSource&    source
263    ) = 0;
264
265  /**
266    * Parse an XML document from a system identifier (URI).
267    *
268    * This method is a shortcut for the common case of reading a
269    * document from a system identifier.  It is the exact equivalent
270    * of the following:
271    *
272    * parse(new URLInputSource(systemId));
273    *
274    * If the system identifier is a URL, it must be fully resolved
275    * by the application before it is passed to the parser.
276    *
277    * @param systemId The system identifier (URI).
278    * @exception SAXException Any SAX exception, possibly
279    *            wrapping another exception.
280    * @exception XMLException An exception from the parser or client
281    *            handler code.
282    * @see #parse(InputSource)
283    */
284    virtual void parse
285    (
286        const   XMLCh* const    systemId
287    ) = 0;
288
289  /**
290    * Parse an XML document from a system identifier (URI).
291    *
292    * This method is a shortcut for the common case of reading a
293    * document from a system identifier.  It is the exact equivalent
294    * of the following:
295    *
296    * parse(new URLInputSource(systemId));
297    *
298    * If the system identifier is a URL, it must be fully resolved
299    * by the application before it is passed to the parser.
300    *
301    * @param systemId The system identifier (URI).
302    * @exception SAXException Any SAX exception, possibly
303    *            wrapping another exception.
304    * @exception XMLException An exception from the parser or client
305    *            handler code.
306    * @see #parse(InputSource)
307    */
308    virtual void parse
309    (
310        const   char* const     systemId
311    ) = 0;
312    //@}
313
314
315private :
316    /* The copy constructor, you cannot call this directly */
317    Parser(const Parser&);
318
319    /* The assignment operator, you cannot call this directly */
320    Parser& operator=(const Parser&);
321};
322
323XERCES_CPP_NAMESPACE_END
324
325#endif
Note: See TracBrowser for help on using the repository browser.