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 __QTATTRIBUTESADAPTOR_H_INCLUDED__ 00029 #define __QTATTRIBUTESADAPTOR_H_INCLUDED__ 00030 00031 00032 /** 00033 * @file QtAttributesAdaptor.H 00034 * @brief Header file of class qgxml::QtAttributesAdaptor. 00035 * 00036 * @author <a href="mailto:qgar-contact@loria.fr?subject=Qgar fwd Jan Rendek">Jan Rendek</a> 00037 * @date March 11, 2003 09:52 00038 * @since Qgar 2.1.1 00039 */ 00040 00041 00042 // For RCS/CVS use: Do not delete 00043 /* $Id: QtAttributesAdaptor.H,v 1.5 2004/06/24 15:07:27 rendek Exp $ */ 00044 00045 00046 // QGAR 00047 #include <qgarlib/qtimpl/QtStringConverter.H> 00048 #include <qgarlib/sax/Attributes.H> 00049 00050 00051 // QT 00052 #include <qxml.h> 00053 00054 00055 namespace qgxml { 00056 00057 00058 /** 00059 * @class QtAttributesAdaptor QtAttributesAdaptor.H 00060 * @brief Adapts the interface of Attributes to the Qt QXmlAttributes 00061 * class. 00062 * 00063 * 00064 * <p> 00065 * This class adapts the Qgar SAX Attributes interface to the Qt 00066 * implementation: QXmlAttributes. 00067 * </p> 00068 * 00069 * @author <a href="mailto:qgar-contact@loria.fr?subject=Qgar fwd Jan Rendek">Jan Rendek</a> 00070 * @date March 11, 2003 09:52 00071 * @since Qgar 2.1.1 00072 */ 00073 class QtAttributesAdaptor : public Attributes { 00074 00075 // ------------------------------------------------------------------- 00076 // P U B L I C M E M B E R S 00077 // ------------------------------------------------------------------- 00078 public: 00079 00080 00081 /** @name Constructors */ 00082 // ============ 00083 //@{ 00084 /** 00085 * @brief Default constructor 00086 * 00087 * @param attributes a pointer to a QXmlAttributes instance to be 00088 * adapted to the qgxml::Attributes instance. 00089 */ 00090 QtAttributesAdaptor(QXmlAttributes * attributes); 00091 00092 //@} 00093 00094 00095 /** @name Destructors */ 00096 // =========== 00097 //@{ 00098 /** 00099 * @brief Destructor 00100 */ 00101 virtual ~QtAttributesAdaptor(); 00102 //@} 00103 00104 00105 /** @name Access */ 00106 // ====== 00107 //@{ 00108 00109 /** 00110 * @brief Look up the index of an attribute by XML 1.0 qualified 00111 * name. 00112 * 00113 * @param qName The qualified (prefixed) name. 00114 * 00115 * @return The index of the attribute., or -1 if it does not appear in 00116 * the list. 00117 */ 00118 virtual int getIndex(const std::string& qName) const; 00119 00120 00121 /** 00122 * @brief Look up the index of an attribute by Namespace name. 00123 * 00124 * @param uri The Namespace URI, or the empty string if the name has 00125 * no Namespace URI. 00126 * 00127 * @param localName The attribute's local name. 00128 * 00129 * @return The index of the attribute, or -1 if it does not appear in 00130 * the list. 00131 */ 00132 virtual int getIndex(const std::string& uri, 00133 const std::string& localName) const; 00134 00135 00136 /** 00137 * @brief Return the number of attributes in the list. 00138 * 00139 * Once you know the number of attributes, you can iterate through the 00140 * list. 00141 * 00142 * @return The number of attributes in the list. 00143 */ 00144 virtual int getLength() const; 00145 00146 00147 00148 /** 00149 * @brief Look up an attribute's local name by index. 00150 * 00151 * @param index The attribute index (zero-based). 00152 * 00153 * @return The local name, or the empty string if Namespace processing 00154 * is not being performed, or null if the index is out of range. 00155 */ 00156 virtual std::string getLocalName(int index) const; 00157 00158 00159 /** 00160 * @brief Look up an attribute's XML 1.0 qualified name by index. 00161 * 00162 * @param index The attribute index (zero-based). 00163 * 00164 * @return The XML 1.0 qualified name, or the empty string if none is 00165 * available, or null if the index is out of range. 00166 */ 00167 virtual std::string getQName(int index) const; 00168 00169 00170 /** 00171 * @brief Look up an attribute's type by index. 00172 * 00173 * @param index The attribute index (zero-based). 00174 * 00175 * @return The attribute's type as a string. 00176 */ 00177 virtual std::string getType(int index) const; 00178 00179 00180 /** 00181 * @brief Look up an attribute's type by XML 1.0 qualified name. 00182 * 00183 * @param qName The XML 1.0 qualified name. 00184 * 00185 * @return The attribute type as a string. 00186 */ 00187 virtual std::string getType(const std::string& qName) const; 00188 00189 00190 /** 00191 * @brief Look up an attribute's type by Namespace name. 00192 * 00193 * @param uri The Namespace URI, or the empty String if the name has 00194 * no Namespace URI. 00195 * 00196 * @param localName The local name of the attribute. 00197 * 00198 * @return The attribute type as a string. 00199 */ 00200 virtual std::string getType(const std::string& uri, 00201 const std::string& localName) const; 00202 00203 00204 /** 00205 * @brief Look up an attribute's Namespace URI by index. 00206 * 00207 * @param index The attribute index (zero-based). 00208 * 00209 * @return The Namespace URI, or the empty string if none is 00210 * available. 00211 */ 00212 virtual std::string getURI(int index) const; 00213 00214 00215 /** 00216 * @brief Look up an attribute's value by index 00217 * 00218 * @param index The attribute index (zero-based). 00219 * 00220 * @return The attribute's value as a string, or null if the index is 00221 * out of range. 00222 */ 00223 virtual std::string getValue(int index) const; 00224 00225 00226 /** 00227 * @brief Look up an attribute's value by XML 1.0 qualified name. 00228 * 00229 * @param qName The XML 1.0 qualified name. 00230 * 00231 * @return The attribute value as a string, or null if the attribute 00232 * is not in the list or if qualified names are not available. 00233 */ 00234 virtual std::string getValue(const std::string& qName) const; 00235 00236 00237 /** 00238 * @brief Look up an attribute's value by Namespace name. 00239 * 00240 * @param uri The Namespace URI, or the empty String if the name has 00241 * no Namespace URI. 00242 * 00243 * @param localName The local name of the attribute. 00244 * 00245 * @return The attribute value as a string, or null if the attribute 00246 * is not in the list. 00247 */ 00248 virtual std::string getValue(const std::string& uri, 00249 const std::string& localName) const; 00250 //@} 00251 00252 00253 00254 // ------------------------------------------------------------------- 00255 // P R O T E C T E D M E M B E R S 00256 // ------------------------------------------------------------------- 00257 protected: 00258 00259 /// The adaptee, a QXmlAttribute instance. 00260 QXmlAttributes * _impl; 00261 00262 /// A converter used to transform stl string to Qt QString and back. 00263 QtStringConverter _sc; 00264 00265 // ------------------------------------------------------------------- 00266 00267 }; // class QtAttributesAdaptor 00268 00269 } // namespace qgxml 00270 00271 #endif /* __QTATTRIBUTESADAPTOR_H_INCLUDED__ */