| 1 | /****************************************************************************
|
|---|
| 2 | ** $Id: qptrvector.h 2 2005-11-16 15:49:26Z dmik $
|
|---|
| 3 | **
|
|---|
| 4 | ** Definition of QPtrVector pointer based template class
|
|---|
| 5 | **
|
|---|
| 6 | ** Created : 930907
|
|---|
| 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 QPTRVECTOR_H
|
|---|
| 39 | #define QPTRVECTOR_H
|
|---|
| 40 |
|
|---|
| 41 | #ifndef QT_H
|
|---|
| 42 | #include "qgvector.h"
|
|---|
| 43 | #endif // QT_H
|
|---|
| 44 |
|
|---|
| 45 | template<class type>
|
|---|
| 46 | class QPtrVector
|
|---|
| 47 | #ifdef Q_QDOC
|
|---|
| 48 | : public QPtrCollection
|
|---|
| 49 | #else
|
|---|
| 50 | : public QGVector
|
|---|
| 51 | #endif
|
|---|
| 52 | {
|
|---|
| 53 | public:
|
|---|
| 54 | QPtrVector() { }
|
|---|
| 55 | QPtrVector( uint size ) : QGVector(size) { }
|
|---|
| 56 | QPtrVector( const QPtrVector<type> &v ) : QGVector( v ) { }
|
|---|
| 57 | ~QPtrVector() { clear(); }
|
|---|
| 58 | QPtrVector<type> &operator=(const QPtrVector<type> &v)
|
|---|
| 59 | { return (QPtrVector<type>&)QGVector::operator=(v); }
|
|---|
| 60 | bool operator==( const QPtrVector<type> &v ) const { return QGVector::operator==(v); }
|
|---|
| 61 | type **data() const { return (type **)QGVector::data(); }
|
|---|
| 62 | uint size() const { return QGVector::size(); }
|
|---|
| 63 | uint count() const { return QGVector::count(); }
|
|---|
| 64 | bool isEmpty() const { return QGVector::count() == 0; }
|
|---|
| 65 | bool isNull() const { return QGVector::size() == 0; }
|
|---|
| 66 | bool resize( uint size ) { return QGVector::resize(size); }
|
|---|
| 67 | bool insert( uint i, const type *d){ return QGVector::insert(i,(Item)d); }
|
|---|
| 68 | bool remove( uint i ) { return QGVector::remove(i); }
|
|---|
| 69 | type *take( uint i ) { return (type *)QGVector::take(i); }
|
|---|
| 70 | void clear() { QGVector::clear(); }
|
|---|
| 71 | bool fill( const type *d, int size=-1 )
|
|---|
| 72 | { return QGVector::fill((Item)d,size);}
|
|---|
| 73 | void sort() { QGVector::sort(); }
|
|---|
| 74 | int bsearch( const type *d ) const{ return QGVector::bsearch((Item)d); }
|
|---|
| 75 | int findRef( const type *d, uint i=0 ) const
|
|---|
| 76 | { return QGVector::findRef((Item)d,i);}
|
|---|
| 77 | int find( const type *d, uint i= 0 ) const
|
|---|
| 78 | { return QGVector::find((Item)d,i); }
|
|---|
| 79 | uint containsRef( const type *d ) const
|
|---|
| 80 | { return QGVector::containsRef((Item)d); }
|
|---|
| 81 | uint contains( const type *d ) const
|
|---|
| 82 | { return QGVector::contains((Item)d); }
|
|---|
| 83 | type *operator[]( int i ) const { return (type *)QGVector::at(i); }
|
|---|
| 84 | type *at( uint i ) const { return (type *)QGVector::at(i); }
|
|---|
| 85 | void toList( QGList *list ) const { QGVector::toList(list); }
|
|---|
| 86 |
|
|---|
| 87 | #ifdef Q_QDOC
|
|---|
| 88 | protected:
|
|---|
| 89 | virtual int compareItems( QPtrCollection::Item d1, QPtrCollection::Item d2 );
|
|---|
| 90 | virtual QDataStream& read( QDataStream &s, QPtrCollection::Item &d );
|
|---|
| 91 | virtual QDataStream& write( QDataStream &s, QPtrCollection::Item d ) const;
|
|---|
| 92 | #endif
|
|---|
| 93 |
|
|---|
| 94 | private:
|
|---|
| 95 | void deleteItem( Item d );
|
|---|
| 96 | };
|
|---|
| 97 |
|
|---|
| 98 | #if !defined(Q_BROKEN_TEMPLATE_SPECIALIZATION)
|
|---|
| 99 | template<> inline void QPtrVector<void>::deleteItem( QPtrCollection::Item )
|
|---|
| 100 | {
|
|---|
| 101 | }
|
|---|
| 102 | #endif
|
|---|
| 103 |
|
|---|
| 104 | template<class type> inline void QPtrVector<type>::deleteItem( QPtrCollection::Item d )
|
|---|
| 105 | {
|
|---|
| 106 | if ( del_item ) delete (type *)d;
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 | #ifndef QT_NO_COMPAT
|
|---|
| 110 | #define QVector QPtrVector
|
|---|
| 111 | #endif
|
|---|
| 112 |
|
|---|
| 113 | #define Q_DEFINED_QPTRVECTOR
|
|---|
| 114 | #include "qwinexport.h"
|
|---|
| 115 | #endif // QVECTOR_H
|
|---|