00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
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 #ifdef QT_QWINEXPORT
00119 #define Q_DEFINED_QASCIIDICT
00120 #include "qwinexport.h"
00121 #endif
00122 #endif // QASCIIDICT_H