Eneboo - Documentación para desarrolladores
src/qt/include/qdict.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qt/qdict.h   3.3.8   edited Jan 11 14:38 $
00003 **
00004 ** Definition of QDict template class
00005 **
00006 ** Created : 920821
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 QDICT_H
00039 #define QDICT_H
00040 
00041 #ifndef QT_H
00042 #include "qgdict.h"
00043 #endif // QT_H
00044 
00045 template<class type>
00046 class QDict
00047 #ifdef Q_QDOC
00048         : public QPtrCollection
00049 #else
00050         : public QGDict
00051 #endif
00052 {
00053 public:
00054     QDict( int size = 17, bool caseSensitive = TRUE )
00055         : QGDict( size, StringKey, caseSensitive, FALSE ) { }
00056     QDict( const QDict<type> &d ) : QGDict( d ) { }
00057     ~QDict()                            { clear(); }
00058     QDict<type> &operator=(const QDict<type> &d)
00059                         { return (QDict<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 QString &k, const type *d )
00065                                         { QGDict::look_string(k,(Item)d,1); }
00066     void  replace( const QString &k, const type *d )
00067                                         { QGDict::look_string(k,(Item)d,2); }
00068     bool  remove( const QString &k )    { return QGDict::remove_string(k); }
00069     type *take( const QString &k )      { return (type *)QGDict::take_string(k); }
00070     type *find( const QString &k ) const
00071                 { return (type *)((QGDict*)this)->QGDict::look_string(k,0,0); }
00072     type *operator[]( const QString &k ) const
00073                 { return (type *)((QGDict*)this)->QGDict::look_string(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 QDict<void>::deleteItem( Item )
00091 {
00092 }
00093 #endif
00094 
00095 template<class type> inline void QDict<type>::deleteItem( QPtrCollection::Item d )
00096 {
00097     if ( del_item ) delete (type *)d;
00098 }
00099 
00100 template<class type>
00101 class QDictIterator : public QGDictIterator
00102 {
00103 public:
00104     QDictIterator(const QDict<type> &d) : QGDictIterator((QGDict &)d) { }
00105     ~QDictIterator()          {}
00106     uint  count()   const     { return dict->count(); }
00107     bool  isEmpty() const     { return dict->count() == 0; }
00108     type *toFirst()           { return (type *)QGDictIterator::toFirst(); }
00109     operator type *() const   { return (type *)QGDictIterator::get(); }
00110     type *operator*()         { return (type *)QGDictIterator::get(); }
00111     type   *current() const   { return (type *)QGDictIterator::get(); }
00112     QString currentKey() const{ return QGDictIterator::getKeyString(); }
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 #define Q_DEFINED_QDICT
00119 #include "qwinexport.h"
00120 #endif // QDICT_H
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'