Eneboo - Documentación para desarrolladores
|
00001 /**************************************************************************** 00002 ** $Id: qt/qasciidict.h 3.3.8 edited Jan 11 14:38 $ 00003 ** 00004 ** Definition of QAsciiDict template class 00005 ** 00006 ** Created : 920821 00007 ** 00008 ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 00009 ** 00010 ** This file is part of the tools module of the Qt GUI Toolkit. 00011 ** 00012 ** This file may be distributed under the terms of the Q Public License 00013 ** as defined by Trolltech ASA of Norway and appearing in the file 00014 ** LICENSE.QPL included in the packaging of this file. 00015 ** 00016 ** This file may be distributed and/or modified under the terms of the 00017 ** GNU General Public License version 2 as published by the Free Software 00018 ** Foundation and appearing in the file LICENSE.GPL included in the 00019 ** packaging of this file. 00020 ** 00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 00022 ** licenses may use this file in accordance with the Qt Commercial License 00023 ** Agreement provided with the Software. 00024 ** 00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00027 ** 00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 00029 ** information about Qt Commercial License Agreements. 00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information. 00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00032 ** 00033 ** Contact info@trolltech.com if any conditions of this licensing are 00034 ** not clear to you. 00035 ** 00036 **********************************************************************/ 00037 00038 #ifndef QASCIIDICT_H 00039 #define QASCIIDICT_H 00040 00041 #ifndef QT_H 00042 #include "qgdict.h" 00043 #endif // QT_H 00044 00045 template<class type> 00046 class QAsciiDict 00047 #ifdef Q_QDOC 00048 : public QPtrCollection 00049 #else 00050 : public QGDict 00051 #endif 00052 { 00053 public: 00054 QAsciiDict(int size=17, bool caseSensitive=TRUE, bool copyKeys=TRUE ) 00055 : QGDict(size,AsciiKey,caseSensitive,copyKeys) {} 00056 QAsciiDict( const QAsciiDict<type> &d ) : QGDict(d) {} 00057 ~QAsciiDict() { clear(); } 00058 QAsciiDict<type> &operator=(const QAsciiDict<type> &d) 00059 { return (QAsciiDict<type>&)QGDict::operator=(d); } 00060 uint count() const { return QGDict::count(); } 00061 uint size() const { return QGDict::size(); } 00062 bool isEmpty() const { return QGDict::count() == 0; } 00063 00064 void insert( const char *k, const type *d ) 00065 { QGDict::look_ascii(k,(Item)d,1); } 00066 void replace( const char *k, const type *d ) 00067 { QGDict::look_ascii(k,(Item)d,2); } 00068 bool remove( const char *k ) { return QGDict::remove_ascii(k); } 00069 type *take( const char *k ) { return (type *)QGDict::take_ascii(k); } 00070 type *find( const char *k ) const 00071 { return (type *)((QGDict*)this)->QGDict::look_ascii(k,0,0); } 00072 type *operator[]( const char *k ) const 00073 { return (type *)((QGDict*)this)->QGDict::look_ascii(k,0,0); } 00074 00075 void clear() { QGDict::clear(); } 00076 void resize( uint n ) { QGDict::resize(n); } 00077 void statistics() const { QGDict::statistics(); } 00078 00079 #ifdef Q_QDOC 00080 protected: 00081 virtual QDataStream& read( QDataStream &, QPtrCollection::Item & ); 00082 virtual QDataStream& write( QDataStream &, QPtrCollection::Item ) const; 00083 #endif 00084 00085 private: 00086 void deleteItem( Item d ); 00087 }; 00088 00089 #if !defined(Q_BROKEN_TEMPLATE_SPECIALIZATION) 00090 template<> inline void QAsciiDict<void>::deleteItem( QPtrCollection::Item ) 00091 { 00092 } 00093 #endif 00094 00095 template<class type> inline void QAsciiDict<type>::deleteItem( QPtrCollection::Item d ) 00096 { 00097 if ( del_item ) delete (type *)d; 00098 } 00099 00100 template<class type> 00101 class QAsciiDictIterator : public QGDictIterator 00102 { 00103 public: 00104 QAsciiDictIterator(const QAsciiDict<type> &d) 00105 : QGDictIterator((QGDict &)d) {} 00106 ~QAsciiDictIterator() {} 00107 uint count() const { return dict->count(); } 00108 bool isEmpty() const { return dict->count() == 0; } 00109 type *toFirst() { return (type *)QGDictIterator::toFirst(); } 00110 operator type *() const { return (type *)QGDictIterator::get(); } 00111 type *current() const { return (type *)QGDictIterator::get(); } 00112 const char *currentKey() const { return QGDictIterator::getKeyAscii(); } 00113 type *operator()() { return (type *)QGDictIterator::operator()(); } 00114 type *operator++() { return (type *)QGDictIterator::operator++(); } 00115 type *operator+=(uint j) { return (type *)QGDictIterator::operator+=(j);} 00116 }; 00117 00118 #define Q_DEFINED_QASCIIDICT 00119 #include "qwinexport.h" 00120 #endif // QASCIIDICT_H