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 __ATTRIBUTES_H_INCLUDED__ 00029 #define __ATTRIBUTES_H_INCLUDED__ 00030 00031 00032 /** 00033 * @file Attributes.H 00034 * @brief Header file of class qgxml::Attributes. 00035 * 00036 * @author <a href="mailto:qgar-contact@loria.fr?subject=Qgar fwd Jan Rendek">Jan Rendek</a> 00037 * @date March 10, 2003 14:48 00038 * @since Qgar 2.1.1 00039 */ 00040 00041 00042 // For RCS/CVS use: Do not delete 00043 /* $Id: Attributes.H,v 1.6 2004/07/02 20:14:26 masini Exp $ */ 00044 00045 00046 #include <string> 00047 00048 namespace qgxml { 00049 00050 /** 00051 * @class Attributes Attributes.H <qgarlib/sax/Attributes.H> 00052 * @ingroup XML 00053 * @brief Interface for a list of XML attributes 00054 * 00055 * This interface allows access to a list of attributes in three 00056 * different ways: 00057 * -# by attribute index. 00058 * -# by namespace-qualified name 00059 * -# by qualified (prefixed) name. 00060 * 00061 * <b> This class is an adaptation for C++ of the interface of the same 00062 * name implemented in the Java SAX API (http://www.saxproject.org). 00063 * </b> 00064 * 00065 * @author <a href="mailto:qgar-contact@loria.fr?subject=Qgar fwd Jan Rendek">Jan Rendek</a> (Adaptation). 00066 * @date March 10, 2003 14:48 00067 * @since Qgar 2.1.1 00068 */ 00069 class Attributes 00070 { 00071 00072 // ------------------------------------------------------------------- 00073 // P U B L I C M E M B E R S 00074 // ------------------------------------------------------------------- 00075 public: 00076 00077 /** @name Destructor */ 00078 // ========== 00079 //@{ 00080 /** 00081 * @brief Destructor 00082 */ 00083 virtual ~Attributes() {} 00084 //@} 00085 00086 00087 /** @name Access */ 00088 // ====== 00089 //@{ 00090 00091 /** 00092 * @brief Look up the index of an attribute by XML 1.0 qualified 00093 * name. 00094 * 00095 * @param qName The qualified (prefixed) name. 00096 * 00097 * @return The index of the attribute, or -1 if it does not appear in 00098 * the list. 00099 */ 00100 virtual int getIndex(const std::string& qName) const = 0; 00101 00102 00103 /** 00104 * @brief Look up the index of an attribute by Namespace name. 00105 * 00106 * @param uri The Namespace URI, or the empty string if the name has 00107 * no Namespace URI. 00108 * 00109 * @param localName The attribute's local name. 00110 * 00111 * @return The index of the attribute, or -1 if it does not appear in 00112 * the list. 00113 */ 00114 virtual int getIndex(const std::string& uri, 00115 const std::string& localName) const = 0; 00116 00117 00118 /** 00119 * @brief Return the number of attributes in the list. 00120 * 00121 * Once you know the number of attributes, you can iterate through the 00122 * list. 00123 * 00124 * @return The number of attributes in the list. 00125 */ 00126 virtual int getLength() const = 0; 00127 00128 00129 /** 00130 * @brief Look up an attribute's local name by index. 00131 * 00132 * @param index The attribute index (zero-based). 00133 * 00134 * @return The local name, or the empty string if Namespace processing 00135 * is not being performed, or null if the index is out of range. 00136 */ 00137 virtual std::string getLocalName(int index) const = 0; 00138 00139 00140 /** 00141 * @brief Look up an attribute's XML 1.0 qualified name by index. 00142 * 00143 * @param index The attribute index (zero-based). 00144 * 00145 * @return The XML 1.0 qualified name, or the empty string if none is 00146 * available, or null if the index is out of range. 00147 */ 00148 virtual std::string getQName(int index) const = 0; 00149 00150 00151 /** 00152 * @brief Look up an attribute's type by index. 00153 * 00154 * @param index The attribute index (zero-based). 00155 * 00156 * @return The attribute's type as a string. 00157 */ 00158 virtual std::string getType(int index) const = 0; 00159 00160 00161 /** 00162 * @brief Look up an attribute's type by XML 1.0 qualified name. 00163 * 00164 * @param qName The XML 1.0 qualified name. 00165 * 00166 * @return The attribute type as a string. 00167 */ 00168 virtual std::string getType(const std::string& qName) const = 0; 00169 00170 00171 /** 00172 * @brief Look up an attribute's type by Namespace name. 00173 * 00174 * @param uri The Namespace URI, or the empty String if the name has 00175 * no Namespace URI. 00176 * 00177 * @param localName The local name of the attribute. 00178 * 00179 * @return The attribute type as a string. 00180 */ 00181 virtual std::string getType(const std::string& uri, 00182 const std::string& localName) const = 0; 00183 00184 00185 /** 00186 * @brief Look up an attribute's Namespace URI by index. 00187 * 00188 * @param index The attribute index (zero-based). 00189 * 00190 * @return The Namespace URI, or the empty string if none is 00191 * available. 00192 */ 00193 virtual std::string getURI(int index) const = 0; 00194 00195 00196 /** 00197 * @brief Look up an attribute's value by index 00198 * 00199 * @param index The attribute index (zero-based). 00200 * 00201 * @return The attribute's value as a string, or null if the index is 00202 * out of range. 00203 */ 00204 virtual std::string getValue(int index) const = 0; 00205 00206 00207 /** 00208 * @brief Look up an attribute's value by XML 1.0 qualified name. 00209 * 00210 * @param qName The XML 1.0 qualified name. 00211 * 00212 * @return The attribute value as a string, or null if the attribute 00213 * is not in the list or if qualified names are not available. 00214 */ 00215 virtual std::string getValue(const std::string& qName) const = 0; 00216 00217 00218 /** 00219 * @brief Look up an attribute's value by Namespace name. 00220 * 00221 * @param uri The Namespace URI, or the empty String if the name has 00222 * no Namespace URI. 00223 * 00224 * @param localName The local name of the attribute. 00225 * 00226 * @return The attribute value as a string, or null if the attribute 00227 * is not in the list. 00228 */ 00229 virtual std::string getValue(const std::string& uri, 00230 const std::string& localName) const = 0; 00231 00232 //@} 00233 00234 // ------------------------------------------------------------------- 00235 00236 }; // class Attributes 00237 00238 } // namespace qgxml 00239 00240 00241 #endif /* __ATTRIBUTES_H_INCLUDED__ */