Eneboo - Documentación para desarrolladores
src/qt/include/qintdict.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qt/qintdict.h   3.3.8   edited Jan 11 14:38 $
00003 **
00004 ** Definition of QIntDict template class
00005 **
00006 ** Created : 940624
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 QINTDICT_H
00039 #define QINTDICT_H
00040 
00041 #ifndef QT_H
00042 #include "qgdict.h"
00043 #endif // QT_H
00044 
00045 template<class type>
00046 class QIntDict
00047 #ifdef Q_QDOC
00048         : public QPtrCollection
00049 #else
00050         : public QGDict
00051 #endif
00052 {
00053 public:
00054     QIntDict(int size=17) : QGDict(size,IntKey,0,0) {}
00055     QIntDict( const QIntDict<type> &d ) : QGDict(d) {}
00056    ~QIntDict()                          { clear(); }
00057     QIntDict<type> &operator=(const QIntDict<type> &d)
00058                         { return (QIntDict<type>&)QGDict::operator=(d); }
00059     uint  count()   const               { return QGDict::count(); }
00060     uint  size()    const               { return QGDict::size(); }
00061     bool  isEmpty() const               { return QGDict::count() == 0; }
00062     void  insert( long k, const type *d )
00063                                         { QGDict::look_int(k,(Item)d,1); }
00064     void  replace( long k, const type *d )
00065                                         { QGDict::look_int(k,(Item)d,2); }
00066     bool  remove( long k )              { return QGDict::remove_int(k); }
00067     type *take( long k )                { return (type*)QGDict::take_int(k); }
00068     type *find( long k ) const
00069                 { return (type *)((QGDict*)this)->QGDict::look_int(k,0,0); }
00070     type *operator[]( long k ) const
00071                 { return (type *)((QGDict*)this)->QGDict::look_int(k,0,0); }
00072     void  clear()                       { QGDict::clear(); }
00073     void  resize( uint n )              { QGDict::resize(n); }
00074     void  statistics() const            { QGDict::statistics(); }
00075 
00076 #ifdef Q_QDOC
00077 protected:
00078     virtual QDataStream& read( QDataStream &, QPtrCollection::Item & );
00079     virtual QDataStream& write( QDataStream &, QPtrCollection::Item ) const;
00080 #endif
00081 
00082 private:
00083     void  deleteItem( Item d );
00084 };
00085 
00086 #if !defined(Q_BROKEN_TEMPLATE_SPECIALIZATION)
00087 template<> inline void QIntDict<void>::deleteItem( QPtrCollection::Item )
00088 {
00089 }
00090 #endif
00091 
00092 template<class type> inline void QIntDict<type>::deleteItem( QPtrCollection::Item d )
00093 {
00094     if ( del_item ) delete (type*)d;
00095 }
00096 
00097 template<class type> 
00098 class QIntDictIterator : public QGDictIterator
00099 {
00100 public:
00101     QIntDictIterator(const QIntDict<type> &d) :QGDictIterator((QGDict &)d) {}
00102    ~QIntDictIterator()        {}
00103     uint  count()   const     { return dict->count(); }
00104     bool  isEmpty() const     { return dict->count() == 0; }
00105     type *toFirst()           { return (type *)QGDictIterator::toFirst(); }
00106     operator type *()  const  { return (type *)QGDictIterator::get(); }
00107     type *current()    const  { return (type *)QGDictIterator::get(); }
00108     long  currentKey() const  { return QGDictIterator::getKeyInt(); }
00109     type *operator()()        { return (type *)QGDictIterator::operator()(); }
00110     type *operator++()        { return (type *)QGDictIterator::operator++(); }
00111     type *operator+=(uint j)  { return (type *)QGDictIterator::operator+=(j);}
00112 };
00113 
00114 #define Q_DEFINED_QINTDICT
00115 #include "qwinexport.h"
00116 #endif // QINTDICT_H
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'