Chameleon

Chameleon Svn Source Tree

Root/branches/xZenu/src/util/doxygen/qtools/qlist.h

Source at commit 1322 created 9 years 5 months ago.
By meklort, Add doxygen to utils folder
1/****************************************************************************
2**
3**
4** Definition of QList template/macro class
5**
6** Created : 920701
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 QLIST_H
39#define QLIST_H
40
41#ifndef QT_H
42#include "qglist.h"
43#endif // QT_H
44
45
46template<class type> class Q_EXPORT QList : public QGList
47{
48public:
49 QList(){}
50 QList( const QList<type> &l ) : QGList(l) {}
51 ~QList(){ clear(); }
52 QList<type> &operator=(const QList<type> &l)
53{ return (QList<type>&)QGList::operator=(l); }
54 bool operator==( const QList<type> &list ) const
55 { return QGList::operator==( list ); }
56 uint count() const{ return QGList::count(); }
57 bool isEmpty() const{ return QGList::count() == 0; }
58 bool insert( uint i, const type *d){ return QGList::insertAt(i,(QCollection::Item)d); }
59 void inSort( const type *d ){ QGList::inSort((QCollection::Item)d); }
60 void prepend( const type *d ){ QGList::insertAt(0,(QCollection::Item)d); }
61 void append( const type *d ){ QGList::append((QCollection::Item)d); }
62 bool remove( uint i ){ return QGList::removeAt(i); }
63 bool remove(){ return QGList::remove((QCollection::Item)0); }
64 bool remove( const type *d ){ return QGList::remove((QCollection::Item)d); }
65 bool removeRef( const type *d ){ return QGList::removeRef((QCollection::Item)d); }
66 void removeNode( QLNode *n ){ QGList::removeNode(n); }
67 bool removeFirst(){ return QGList::removeFirst(); }
68 bool removeLast(){ return QGList::removeLast(); }
69 type *take( uint i ){ return (type *)QGList::takeAt(i); }
70 type *take(){ return (type *)QGList::take(); }
71 type *takeNode( QLNode *n ){ return (type *)QGList::takeNode(n); }
72 void clear(){ QGList::clear(); }
73 void sort(){ QGList::sort(); }
74 int find( const type *d ){ return QGList::find((QCollection::Item)d); }
75 int findNext( const type *d ){ return QGList::find((QCollection::Item)d,FALSE); }
76 int findRef( const type *d ){ return QGList::findRef((QCollection::Item)d); }
77 int findNextRef( const type *d ){ return QGList::findRef((QCollection::Item)d,FALSE);}
78 uint contains( const type *d ) const { return QGList::contains((QCollection::Item)d); }
79 uint containsRef( const type *d ) const
80{ return QGList::containsRef((QCollection::Item)d); }
81 type *at( uint i ){ return (type *)QGList::at(i); }
82 int at() const{ return QGList::at(); }
83 type *current() const{ return (type *)QGList::get(); }
84 QLNode *currentNode() const{ return QGList::currentNode(); }
85 type *getFirst() const{ return (type *)QGList::cfirst(); }
86 type *getLast() const{ return (type *)QGList::clast(); }
87 type *first(){ return (type *)QGList::first(); }
88 type *last(){ return (type *)QGList::last(); }
89 type *next(){ return (type *)QGList::next(); }
90 type *prev(){ return (type *)QGList::prev(); }
91 void toVector( QGVector *vec )const{ QGList::toVector(vec); }
92private:
93 void deleteItem( QCollection::Item d );
94};
95
96#if defined(Q_DELETING_VOID_UNDEFINED)
97template<> inline void QList<void>::deleteItem( QCollection::Item )
98{
99}
100#endif
101
102template<class type> inline void QList<type>::deleteItem( QCollection::Item d )
103{
104 if ( del_item ) delete (type *)d;
105}
106
107
108template<class type> class Q_EXPORT QListIterator : public QGListIterator
109{
110public:
111 QListIterator(const QList<type> &l) :QGListIterator((QGList &)l) {}
112 ~QListIterator() {}
113 uint count() const { return list->count(); }
114 bool isEmpty() const { return list->count() == 0; }
115 bool atFirst() const { return QGListIterator::atFirst(); }
116 bool atLast() const { return QGListIterator::atLast(); }
117 type *toFirst() { return (type *)QGListIterator::toFirst(); }
118 type *toLast() { return (type *)QGListIterator::toLast(); }
119 operator type *() const { return (type *)QGListIterator::get(); }
120 type *operator*() { return (type *)QGListIterator::get(); }
121
122 // No good, since QList<char> (ie. QStrList fails...
123 //
124 // MSVC++ gives warning
125 // Sunpro C++ 4.1 gives error
126 // type *operator->() { return (type *)QGListIterator::get(); }
127
128 type *current() const { return (type *)QGListIterator::get(); }
129 type *operator()() { return (type *)QGListIterator::operator()();}
130 type *operator++() { return (type *)QGListIterator::operator++(); }
131 type *operator+=(uint j) { return (type *)QGListIterator::operator+=(j);}
132 type *operator--() { return (type *)QGListIterator::operator--(); }
133 type *operator-=(uint j) { return (type *)QGListIterator::operator-=(j);}
134 QListIterator<type>& operator=(const QListIterator<type>&it)
135 { QGListIterator::operator=(it); return *this; }
136};
137
138
139#endif // QLIST_H
140

Archive Download this file

Revision: 1322