-rw-r--r-- | qmake/include/qasciidict.h | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/qmake/include/qasciidict.h b/qmake/include/qasciidict.h new file mode 100644 index 0000000..8f344cd --- a/dev/null +++ b/qmake/include/qasciidict.h | |||
@@ -0,0 +1,118 @@ | |||
1 | /**************************************************************************** | ||
2 | ** $Id$ | ||
3 | ** | ||
4 | ** Definition of QAsciiDict template class | ||
5 | ** | ||
6 | ** Created : 920821 | ||
7 | ** | ||
8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | ||
9 | ** | ||
10 | ** This file is part of the tools module of the Qt GUI Toolkit. | ||
11 | ** | ||
12 | ** This file may be distributed under the terms of the Q Public License | ||
13 | ** as defined by Trolltech AS of Norway and appearing in the file | ||
14 | ** LICENSE.QPL included in the packaging of this file. | ||
15 | ** | ||
16 | ** This file may be distributed and/or modified under the terms of the | ||
17 | ** GNU General Public License version 2 as published by the Free Software | ||
18 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
19 | ** packaging of this file. | ||
20 | ** | ||
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition | ||
22 | ** licenses may use this file in accordance with the Qt Commercial License | ||
23 | ** Agreement provided with the Software. | ||
24 | ** | ||
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
27 | ** | ||
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | ||
29 | ** information about Qt Commercial License Agreements. | ||
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | ||
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
32 | ** | ||
33 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
34 | ** not clear to you. | ||
35 | ** | ||
36 | **********************************************************************/ | ||
37 | |||
38 | #ifndef QASCIIDICT_H | ||
39 | #define QASCIIDICT_H | ||
40 | |||
41 | #ifndef QT_H | ||
42 | #include "qgdict.h" | ||
43 | #endif // QT_H | ||
44 | |||
45 | template<class type> | ||
46 | class QAsciiDict | ||
47 | #ifdef Q_QDOC | ||
48 | : public QPtrCollection | ||
49 | #else | ||
50 | : public QGDict | ||
51 | #endif | ||
52 | { | ||
53 | public: | ||
54 | QAsciiDict(int size=17, bool caseSensitive=TRUE, bool copyKeys=TRUE ) | ||
55 | : QGDict(size,AsciiKey,caseSensitive,copyKeys) {} | ||
56 | QAsciiDict( const QAsciiDict<type> &d ) : QGDict(d) {} | ||
57 | ~QAsciiDict() { clear(); } | ||
58 | QAsciiDict<type> &operator=(const QAsciiDict<type> &d) | ||
59 | { return (QAsciiDict<type>&)QGDict::operator=(d); } | ||
60 | uint count() const { return QGDict::count(); } | ||
61 | uint size() const { return QGDict::size(); } | ||
62 | bool isEmpty() const { return QGDict::count() == 0; } | ||
63 | |||
64 | void insert( const char *k, const type *d ) | ||
65 | { QGDict::look_ascii(k,(Item)d,1); } | ||
66 | void replace( const char *k, const type *d ) | ||
67 | { QGDict::look_ascii(k,(Item)d,2); } | ||
68 | bool remove( const char *k ){ return QGDict::remove_ascii(k); } | ||
69 | type *take( const char *k ) { return (type *)QGDict::take_ascii(k); } | ||
70 | type *find( const char *k ) const | ||
71 | { return (type *)((QGDict*)this)->QGDict::look_ascii(k,0,0); } | ||
72 | type *operator[]( const char *k ) const | ||
73 | { return (type *)((QGDict*)this)->QGDict::look_ascii(k,0,0); } | ||
74 | |||
75 | void clear() { QGDict::clear(); } | ||
76 | void resize( uint n ) { QGDict::resize(n); } | ||
77 | void statistics() const { QGDict::statistics(); } | ||
78 | |||
79 | #ifdef Q_QDOC | ||
80 | protected: | ||
81 | virtual QDataStream& read( QDataStream &, QPtrCollection::Item & ); | ||
82 | virtual QDataStream& write( QDataStream &, QPtrCollection::Item ) const; | ||
83 | #endif | ||
84 | |||
85 | private: | ||
86 | void deleteItem( Item d ); | ||
87 | }; | ||
88 | |||
89 | #if !defined(Q_BROKEN_TEMPLATE_SPECIALIZATION) | ||
90 | template<> inline void QAsciiDict<void>::deleteItem( QPtrCollection::Item ) | ||
91 | { | ||
92 | } | ||
93 | #endif | ||
94 | |||
95 | template<class type> inline void QAsciiDict<type>::deleteItem( QPtrCollection::Item d ) | ||
96 | { | ||
97 | if ( del_item ) delete (type *)d; | ||
98 | } | ||
99 | |||
100 | template<class type> | ||
101 | class QAsciiDictIterator : public QGDictIterator | ||
102 | { | ||
103 | public: | ||
104 | QAsciiDictIterator(const QAsciiDict<type> &d) | ||
105 | : QGDictIterator((QGDict &)d) {} | ||
106 | ~QAsciiDictIterator() {} | ||
107 | uint count() const { return dict->count(); } | ||
108 | bool isEmpty() const { return dict->count() == 0; } | ||
109 | type *toFirst() { return (type *)QGDictIterator::toFirst(); } | ||
110 | operator type *() const { return (type *)QGDictIterator::get(); } | ||
111 | type *current() const { return (type *)QGDictIterator::get(); } | ||
112 | const char *currentKey() const { return QGDictIterator::getKeyAscii(); } | ||
113 | type *operator()() { return (type *)QGDictIterator::operator()(); } | ||
114 | type *operator++() { return (type *)QGDictIterator::operator++(); } | ||
115 | type *operator+=(uint j) { return (type *)QGDictIterator::operator+=(j);} | ||
116 | }; | ||
117 | |||
118 | #endif // QASCIIDICT_H | ||