Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

XMLReader.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------*
00002  | Library QgarLib, graphics analysis and recognition                  |
00003  | Copyright (C) 2003  Qgar Project, LORIA                             |
00004  |                                                                     |
00005  | This library is free software; you can redistribute it and/or       |
00006  | modify it under the terms of the GNU Lesser General Public          |
00007  | License version 2.1, as published by the Free Software Foundation.  |
00008  |                                                                     |
00009  | This library is distributed in the hope that it will be useful,     |
00010  | but WITHOUT ANY WARRANTY; without even the implied warranty of      |
00011  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                |
00012  | See the GNU Lesser General Public License for more details.         |
00013  |                                                                     |
00014  | The GNU Lesser General Public License is included in the file       |
00015  | LICENSE.LGPL, in the root directory of the Qgar packaging. See      |
00016  | http://www.gnu.org/licenses/lgpl.html for the terms of the license. |
00017  | To receive a paper copy, write to the Free Software Foundation,     |
00018  | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.       |
00019  |                                                                     |
00020  | Contact Project Qgar for any information:                           |
00021  |   LORIA - équipe Qgar                                               |
00022  |   B.P. 239, 54506 Vandoeuvre-lès-Nancy Cedex, France                |
00023  |   email: qgar-contact@loria.fr                                      |
00024  |   http://www.qgar.org/                                              |
00025  *---------------------------------------------------------------------*/
00026 
00027 
00028 #ifndef __XMLREADER_H_INCLUDED__
00029 #define __XMLREADER_H_INCLUDED__
00030 
00031 
00032 /**
00033  * @file     XMLReader.H
00034  * @brief    Header file of class qgxml::XMLReader
00035  *
00036  * @author   <a href="mailto:qgar-contact@loria.fr?subject=Qgar fwd Jan Rendek">Jan Rendek</a>
00037  * @date     March 3, 2003  15:40
00038  * @since    Qgar 2.1.1
00039  */
00040 
00041 
00042 // For RCS/CVS use: Do not delete
00043 /* $Id: XMLReader.H,v 1.5 2004/07/02 20:36:43 masini Exp $ */
00044 
00045 #include <string>
00046 
00047 namespace qgxml {
00048 
00049 class ContentHandler;
00050 class DTDHandler;
00051 class EntityResolver;
00052 class ErrorHandler;
00053 class InputSource;
00054 
00055 
00056 
00057 
00058 /**
00059  * @class XMLReader XMLReader.H <qgarlib/sax/XMLReader.H>
00060  * @ingroup XML
00061  * @brief Interface for reading an XML document using callbacks.
00062  *
00063  * XMLReader is the interface that an XML parser's SAX2 driver must
00064  * implement. This interface allows an application to set and query
00065  * features and properties in the parser, to register event handlers
00066  * for document processing, and to initiate a document parse.
00067  *
00068  * <b> This class is an adaptation for C++ of the interface of the same
00069  * name implemented in the Java SAX API(http://www.saxproject.org).
00070  * </b> 
00071  * 
00072  * @author <a href="mailto:qgar-contact@loria.fr?subject=Qgar fwd Jan Rendek">Jan Rendek</a> (Adaptation)
00073  * @date   March 3, 2003  15:40
00074  * @since  Qgar 2.1.1
00075  */
00076 class XMLReader {
00077 
00078 // -------------------------------------------------------------------
00079 // P U B L I C    M E M B E R S
00080 // -------------------------------------------------------------------
00081 public:
00082 
00083 /** @name Destructor */
00084 //        ==========
00085 //@{
00086 /**
00087  * @brief Destructor
00088  */
00089   virtual ~XMLReader() {}
00090 
00091 //@}
00092 
00093 /** @name Access */
00094 //        ======
00095 //@{
00096 /**
00097  * @brief Return the current content handler.
00098  *
00099  * @return The current content handler, or null if none has been
00100  *         registered.
00101  */
00102   virtual ContentHandler * getContentHandler() const = 0;
00103 
00104 /**
00105  * @brief Return the current DTD handler.
00106  *
00107  * @return The current DTD handler, or null if none has been
00108  *         registered.
00109  */
00110   virtual DTDHandler * getDTDHandler() const = 0;
00111 
00112 /**
00113  * @brief Return the current entity resolver.
00114  *
00115  * @return The current entity resolver, or null if none has been
00116  *         registered.
00117  */
00118   virtual EntityResolver * getEntityResolver() const = 0;
00119 
00120 /**
00121  * @brief Return the current error handler.
00122  *
00123  * @return The current error handler, or null if none has been
00124  *         registered.
00125  */
00126   virtual ErrorHandler * getErrorHandler() const = 0;
00127 
00128 /**
00129  * @brief Look up the value of a feature flag.
00130  *
00131  * @param name The feature name.
00132  *
00133  * @return The current value of the feature (true or false).
00134  */
00135   virtual bool getFeature(const std::string& name) const = 0;
00136 
00137 /**
00138  * @brief Look up the value of a property.
00139  *
00140  * @param name The property name.
00141  *
00142  * @return The current value of the property.
00143  */
00144   virtual void * getProperty(const std::string& name) const = 0;
00145 
00146 //@}
00147 
00148 /**
00149  * @brief Parse an XML document.
00150  *
00151  * The application can use this method to instruct the XML reader to
00152  * begin parsing an XML document from any valid input source (a
00153  * character stream, a byte stream, or a URI). 
00154  *
00155  * During the parse, the XMLReader will provide information about the
00156  * XML document through the registered event handlers.
00157  *
00158  * @param input The input source for the top-level of the XML
00159  *              document.
00160  */
00161   virtual void parse(InputSource& input) = 0;
00162 
00163 /**
00164  * @brief Parse an XML document from a system identifier (URI).
00165  *
00166  * This method is a shortcut for the common case of reading a document
00167  * from a system identifier. It is the exact equivalent of parse(new
00168  * InputSource(systemId));
00169  *
00170  * @param systemId The system identifier (URI).
00171  */
00172   virtual void parse(const std::string& systemId) = 0;
00173 
00174 
00175 /** @name Transform */
00176 //        =========
00177 //@{
00178 /**
00179  * @brief Allow an application to register a content event handler.
00180  *
00181  * If the application does not register a content handler, all content
00182  * events reported by the SAX parser will be silently ignored. 
00183  *
00184  * Applications may register a new or different handler in the middle
00185  * of a parse, and the SAX parser must begin using the new handler
00186  * immediately.
00187  *
00188  * @param handler The content handler.
00189  */
00190   virtual void setContentHandler(ContentHandler * handler) = 0;
00191 
00192 /**
00193  * @brief Allow an application to register a DTD event handler.
00194  *
00195  * If the application does not register a DTD handler, all DTD events
00196  * reported by the SAX parser will be silently ignored. 
00197  *
00198  * Applications may register a new or different handler in the middle
00199  * of a parse, and the SAX parser must begin using the new handler
00200  * immediately.
00201  *
00202  * @param handler The DTD handler.
00203  */
00204   virtual void setDTDHandler(DTDHandler * handler) = 0;
00205 
00206 /**
00207  * @brief Allow an application to register an entity resolver.
00208  *
00209  * If the application does not register an entity resolver, the
00210  * XMLReader will perform its own default resolution. 
00211  *
00212  * Applications may register a new or different resolver in the middle
00213  * of a parse, and the SAX parser must begin using the new resolver
00214  * immediately.
00215  *
00216  * @param resolver The entity resolver.
00217  */
00218   virtual void setEntityResolver(EntityResolver * resolver) = 0;
00219 
00220 /**
00221  * @brief Allow an application to register an error event handler.
00222  *
00223  * If the application does not register an error handler, all error
00224  * events reported by the SAX parser will be silently ignored;
00225  * however, normal processing may not continue. 
00226  *
00227  * Applications may register a new or different handler in the middle
00228  * of a parse, and the SAX parser must begin using the new handler
00229  * immediately.
00230  *
00231  * @param handler The error handler.
00232  */
00233   virtual void setErrorHandler(ErrorHandler * handler) = 0;
00234 
00235 /**
00236  * @brief Set the value of a feature flag.
00237  *
00238  * @param name  The feature name.
00239  * @param value The requested value of the feature (true or false).
00240  */
00241   virtual void setFeature(const std::string& name, bool value) = 0;
00242 
00243 /**
00244  * @brief Set the value of a property.
00245  *
00246  * @param name  The property name.
00247  * @param value The requested value for the property.
00248  */
00249   virtual void setProperty(const std::string& name, void * value) = 0;
00250 //@}
00251 
00252 
00253 }; // class XMLReader
00254 
00255 } // namespace qgxml
00256 
00257 
00258 #endif /* __XMLREADER_H_INCLUDED__ */