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 __CONTENTHANDLER_H_INCLUDED__ 00029 #define __CONTENTHANDLER_H_INCLUDED__ 00030 00031 00032 /** 00033 * @file ContentHandler.H 00034 * @brief Header file of class qgxml::ContentHandler. 00035 * 00036 * @author <a href="mailto:qgar-contact@loria.fr?subject=Qgar fwd Jan Rendek">Jan Rendek</a> 00037 * @date March 3, 2003 16:45 00038 * @since Qgar 2.1.1 00039 */ 00040 00041 00042 // For RCS/CVS use: Do not delete 00043 /* $Id: ContentHandler.H,v 1.7 2004/07/02 20:36:43 masini Exp $ */ 00044 00045 #include <string> 00046 00047 00048 namespace qgxml { 00049 00050 class Attributes; 00051 class Locator; 00052 00053 00054 /** 00055 * @class ContentHandler ContentHandler.H <qgarlib/sax/ContentHandler.H> 00056 * @ingroup XML 00057 * @brief Receive notification of the logical content of a document 00058 * 00059 * This is the main interface that most SAX applications implement: if 00060 * the application needs to be informed of basic parsing events, it 00061 * implements this interface and registers an instance with the SAX 00062 * parser using the setContentHandler method. The parser uses the 00063 * instance to report basic document-related events like the start and 00064 * end of elements and character data. 00065 * 00066 * The order of events in this interface is very important, and 00067 * mirrors the order of information in the document itself. For 00068 * example, all of an element's content (character data, processing 00069 * instructions, and/or subelements) will appear, in order, between 00070 * the startElement event and the corresponding endElement event. 00071 * 00072 * <b> This class is an adaptation for C++ of the interface of the same 00073 * name implemented in the Java SAX API (http://www.saxproject.org). 00074 * </b> 00075 * 00076 * @author <a href="mailto:qgar-contact@loria.fr?subject=Qgar fwd Jan Rendek">Jan Rendek</a> (Adaptation). 00077 * @date March 3, 2003 16:45 00078 * @since Qgar 2.1.1 00079 */ 00080 class ContentHandler { 00081 00082 // ------------------------------------------------------------------- 00083 // P U B L I C M E M B E R S 00084 // ------------------------------------------------------------------- 00085 public: 00086 00087 00088 00089 /** @name Destructor */ 00090 // ========== 00091 //@{ 00092 /** 00093 * @brief Destructor 00094 */ 00095 virtual ~ContentHandler() {} 00096 //@} 00097 00098 00099 /** 00100 * @brief Receive notification of character data. 00101 * 00102 * @param ch The characters from the XML document. 00103 * @param start The start position in the array. 00104 * @param length The number of characters to read from the array. 00105 */ 00106 virtual void characters(const char * ch, 00107 const unsigned int start, 00108 const unsigned int length) = 0; 00109 00110 /** 00111 * @brief Receive notification of the end of a document. 00112 * 00113 * The SAX parser will invoke this method only once, and it will be 00114 * the last method invoked during the parse. The parser shall not 00115 * invoke this method until it has either abandoned parsing (because 00116 * of an unrecoverable error) or reached the end of input. 00117 * 00118 * @see startDocument() 00119 */ 00120 virtual void endDocument() = 0; 00121 00122 /** 00123 * @brief Receive notification of the end of an element. 00124 * 00125 * The SAX parser will invoke this method at the end of every element 00126 * in the XML document; there will be a corresponding startElement 00127 * event for every endElement event (even when the element is empty). 00128 * 00129 * @param uri The Namespace URI, or the empty string if the 00130 * element has no Namespace URI or if Namespace 00131 * processing is not being performed. 00132 * @param localName The local name (without prefix), or the empty 00133 * string if Namespace processing is not being performed. 00134 * @param qName The qualified XML 1.0 name (with prefix), or the 00135 * empty string if qualified names are not 00136 * available. 00137 * 00138 * @see startElement() 00139 */ 00140 virtual void endElement(const std::string& uri, 00141 const std::string& localName, 00142 const std::string& qName) = 0; 00143 00144 /** 00145 * @brief End the scope of a prefix-URI mapping. 00146 * 00147 * @param prefix The prefix that was being mapped. This is the empty 00148 * string when a default mapping scope ends. 00149 * 00150 * @see startPrefixMapping 00151 */ 00152 virtual void endPrefixMapping(const std::string& prefix) = 0; 00153 00154 /** 00155 * @brief Receive notification of ignorable whitespace in element 00156 * content. 00157 * 00158 * @param ch The characters from the XML document. 00159 * @param start The start position in the array. 00160 * @param length The number of characters to read from the array. 00161 */ 00162 virtual void ignorableWhitespace(const char * ch, 00163 const unsigned int start, 00164 const unsigned int length) = 0; 00165 00166 /** 00167 * @brief Receive notification of a processing instruction. 00168 * 00169 * @param target The processing instruction target. 00170 * @param data The processing instruction data. The data does not 00171 * include any whitespace separating it from the 00172 * target. 00173 */ 00174 virtual void processingInstruction(const std::string& target, 00175 const std::string& data) = 0; 00176 00177 /** 00178 * @brief Receive an object for locating the origin of SAX document 00179 * events. 00180 * 00181 * @param locator An object that can return the location of any SAX 00182 * document event. 00183 */ 00184 virtual void setDocumentLocator(Locator * locator) = 0; 00185 00186 /** 00187 * @brief Receive notification of a skipped entity. 00188 * 00189 * @param name The name of the skipped entity. 00190 */ 00191 virtual void skippedEntity(const std::string& name) = 0; 00192 00193 /** 00194 * @brief Receive notification of the beginning of a document. 00195 * 00196 * The SAX parser will invoke this method only once, before any other 00197 * event callbacks (except for setDocumentLocator()). 00198 * 00199 * @see endDocument() 00200 */ 00201 virtual void startDocument() = 0; 00202 00203 /** 00204 * @brief Receive notification of the beginning of an element. 00205 * 00206 * The Parser will invoke this method at the beginning of every 00207 * element in the XML document; there will be a corresponding 00208 * endElement event for every startElement event (even when the 00209 * element is empty). All of the element's content will be reported, 00210 * in order, before the corresponding endElement event. 00211 * 00212 * @param uri The Namespace URI, or the empty string if the 00213 * element has no Namespace URI or if Namespace 00214 * processing is not being performed. 00215 * @param localName The local name (without prefix), or the empty 00216 * string if Namespace processing is not being 00217 * performed. 00218 * @param qName The qualified name (with prefix), or the empty 00219 * string if qualified names are not available. 00220 * @param atts The attributes attached to the element. 00221 * 00222 * @see endElement() 00223 */ 00224 virtual void startElement(const std::string& uri, 00225 const std::string& localName, 00226 const std::string& qName, 00227 const Attributes& atts) = 0; 00228 00229 /** 00230 * @brief Begin the scope of a prefix-URI Namespace mapping. 00231 * 00232 * @param prefix The Namespace prefix being declared. An empty string 00233 * is used for the default element namespace, which has 00234 * no prefix. 00235 * @param uri The Namespace URI the prefix is mapped to. 00236 * 00237 * @see endPrefixMapping() 00238 */ 00239 virtual void startPrefixMapping(const std::string& prefix, 00240 const std::string& uri) = 0; 00241 00242 00243 // ------------------------------------------------------------------- 00244 00245 }; // class ContentHandler 00246 00247 } // namespace qgxml 00248 00249 00250 #endif /* __CONTENTHANDLER_H_INCLUDED__ */