Permalink
Browse files

Reduced and improved functionality of QList

- operations on current index and node (next(), prev(), last(), first()) have been removed.
- access to internal nodes has been removed.
- old QList has been renamed to QInternalList for use inside qtools only.
- added type safe compare, new, and delete operations (compareValues(), newValue(), deleteValue()).
- add compareValues also to QDict for consistency.
- changed doxygen's implementation to comply with the new QList and QDict interface.
  • Loading branch information...
Dimitri van Heesch
Dimitri van Heesch committed Dec 30, 2013
1 parent 744d1ca commit 6e51abf63021dc9fe32c05f003232fe68a08591d
Showing with 1,087 additions and 962 deletions.
  1. +2 −2 qtools/Doxyfile
  2. +17 −3 qtools/qdict.h
  3. +2 −2 qtools/qdir.h
  4. +13 −13 qtools/qgcache.cpp
  5. +5 −5 qtools/qgdict.cpp
  6. +139 −0 qtools/qinternallist.h
  7. +45 −27 qtools/qlist.h
  8. +5 −5 qtools/qstrlist.h
  9. +7 −7 qtools/qtextcodec.cpp
  10. +1 −1 qtools/qtools.pro.in
  11. +2 −2 qtools/qwaitcondition_win32.cpp
  12. +1 −1 src/cite.cpp
  13. +32 −32 src/classdef.cpp
  14. +5 −5 src/classdef.h
  15. +5 −9 src/classlist.cpp
  16. +9 −7 src/classlist.h
  17. +11 −14 src/code.l
  18. +13 −15 src/config.l
  19. +12 −12 src/dbusxmlscanner.cpp
  20. +10 −9 src/define.h
  21. +4 −4 src/definition.cpp
  22. +2 −4 src/definition.h
  23. +79 −101 src/diagram.cpp
  24. +7 −9 src/dirdef.cpp
  25. +7 −6 src/dirdef.h
  26. +24 −22 src/docparser.cpp
  27. +5 −4 src/dot.cpp
  28. +106 −100 src/doxygen.cpp
  29. +1 −0 src/doxygen.h
  30. +3 −2 src/example.h
  31. +9 −10 src/filedef.cpp
  32. +4 −7 src/filedef.h
  33. +18 −28 src/filename.cpp
  34. +4 −3 src/filename.h
  35. +6 −4 src/fortrancode.l
  36. +2 −2 src/fortranscanner.l
  37. +4 −3 src/ftvhelp.cpp
  38. +18 −20 src/groupdef.cpp
  39. +5 −4 src/groupdef.h
  40. +10 −12 src/htmlattrib.h
  41. +3 −2 src/htmlhelp.cpp
  42. +124 −124 src/index.cpp
  43. +12 −12 src/latexgen.cpp
  44. +22 −16 src/memberdef.cpp
  45. +8 −9 src/membergroup.cpp
  46. +3 −2 src/membergroup.h
  47. +3 −11 src/memberlist.cpp
  48. +3 −2 src/memberlist.h
  49. +5 −11 src/membername.cpp
  50. +10 −10 src/membername.h
  51. +6 −7 src/namespacedef.cpp
  52. +8 −11 src/namespacedef.h
  53. +72 −76 src/outputlist.cpp
  54. +13 −13 src/outputlist.h
  55. +3 −2 src/pagedef.h
  56. +1 −1 src/perlmodgen.cpp
  57. +2 −3 src/reflist.h
  58. +12 −12 src/rtfgen.cpp
  59. +7 −7 src/scanner.l
  60. +6 −8 src/searchindex.cpp
  61. +1 −1 src/settings.h
  62. +9 −9 src/sortdict.h
  63. +40 −43 src/tagreader.cpp
  64. +4 −4 src/template.cpp
  65. +32 −29 src/util.cpp
  66. +5 −6 src/util.h
  67. +4 −4 src/vhdlcode.l
  68. +13 −9 src/vhdldocgen.cpp
  69. +1 −1 src/vhdlparser.y
  70. +1 −1 src/vhdlscanner.l
@@ -276,10 +276,10 @@ PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = NO
CLASS_DIAGRAMS = YES
MSCGEN_PATH =
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = YES
HAVE_DOT = NO
DOT_NUM_THREADS = 0
DOT_FONTNAME =
DOT_FONTSIZE = 10
@@ -52,7 +52,7 @@
#else
template<class type> class Q_EXPORT QDict : public QGDict
template<class type> class Q_EXPORT QDict : private QGDict
{
public:
QDict(int size=17, bool caseSensitive=TRUE)
@@ -61,26 +61,40 @@ template<class type> class Q_EXPORT QDict : public QGDict
~QDict() { clear(); }
QDict<type> &operator=(const QDict<type> &d)
{ return (QDict<type>&)QGDict::operator=(d); }
// capacity
uint count() const { return QGDict::count(); }
uint size() const { return QGDict::size(); }
bool isEmpty() const { return QGDict::count() == 0; }
// modifiers
void insert( const QString &k, const type *d )
{ QGDict::look_string(k,(Item)d,1); }
void replace( const QString &k, const type *d )
{ QGDict::look_string(k,(Item)d,2); }
bool remove( const QString &k ) { return QGDict::remove_string(k); }
type *take( const QString &k ) { return (type *)QGDict::take_string(k); }
void clear() { QGDict::clear(); }
void resize( uint n ) { QGDict::resize(n); }
// search
type *find( const QString &k ) const
{ return (type *)((QGDict*)this)->QGDict::look_string(k,0,0); }
type *operator[]( const QString &k ) const
{ return (type *)((QGDict*)this)->QGDict::look_string(k,0,0); }
void clear() { QGDict::clear(); }
void resize( uint n ) { QGDict::resize(n); }
// operations
void statistics() const { QGDict::statistics(); }
private:
void deleteItem( Item d );
// new to be reimplemented methods
virtual int compareValues(const type *t1,const type *t2) const
{ return const_cast<QDict<type>*>(this)->QGDict::compareItems((QCollection::Item)t1,(QCollection::Item)t2); }
// reimplemented methods
virtual int compareItems(QCollection::Item i1,QCollection::Item i2)
{ return compareValues((const type*)i1,(const type*)i2); }
};
#if defined(Q_DELETING_VOID_UNDEFINED)
@@ -44,8 +44,8 @@
#endif // QT_H
#ifndef QT_NO_DIR
typedef QList<QFileInfo> QFileInfoList;
typedef QListIterator<QFileInfo> QFileInfoListIterator;
typedef QInternalList<QFileInfo> QFileInfoList;
typedef QInternalListIterator<QFileInfo> QFileInfoListIterator;
class QStringList;
@@ -36,7 +36,7 @@
**********************************************************************/
#include "qgcache.h"
#include "qlist.h"
#include "qinternallist.h"
#include "qdict.h"
#include "qstring.h"
@@ -73,7 +73,7 @@ struct QCacheItem
QCList class (internal list of cache items)
*****************************************************************************/
class QCList : private QList<QCacheItem>
class QCList : private QInternalList<QCacheItem>
{
friend class QGCacheIterator;
friend class QCListIt;
@@ -88,13 +88,13 @@ friend class QCListIt;
void setAutoDelete( bool del ) { QCollection::setAutoDelete(del); }
bool removeFirst() { return QList<QCacheItem>::removeFirst(); }
bool removeLast() { return QList<QCacheItem>::removeLast(); }
bool removeFirst() { return QInternalList<QCacheItem>::removeFirst(); }
bool removeLast() { return QInternalList<QCacheItem>::removeLast(); }
QCacheItem *first() { return QList<QCacheItem>::first(); }
QCacheItem *last() { return QList<QCacheItem>::last(); }
QCacheItem *prev() { return QList<QCacheItem>::prev(); }
QCacheItem *next() { return QList<QCacheItem>::next(); }
QCacheItem *first() { return QInternalList<QCacheItem>::first(); }
QCacheItem *last() { return QInternalList<QCacheItem>::last(); }
QCacheItem *prev() { return QInternalList<QCacheItem>::prev(); }
QCacheItem *next() { return QInternalList<QCacheItem>::next(); }
#if defined(DEBUG)
int inserts; // variables for statistics
@@ -125,7 +125,7 @@ void QCList::insert( QCacheItem *ci )
item = next();
}
if ( item )
QList<QCacheItem>::insert( at(), ci );
QInternalList<QCacheItem>::insert( at(), ci );
else
append( ci );
#if defined(DEBUG)
@@ -136,7 +136,7 @@ void QCList::insert( QCacheItem *ci )
inline void QCList::insert( int i, QCacheItem *ci )
{
QList<QCacheItem>::insert( i, ci );
QInternalList<QCacheItem>::insert( i, ci );
#if defined(DEBUG)
ASSERT( ci->node == 0 );
#endif
@@ -166,11 +166,11 @@ inline void QCList::reference( QCacheItem *ci )
}
class QCListIt: public QListIterator<QCacheItem>
class QCListIt: public QInternalListIterator<QCacheItem>
{
public:
QCListIt( const QCList *p ): QListIterator<QCacheItem>( *p ) {}
QCListIt( const QCListIt *p ): QListIterator<QCacheItem>( *p ) {}
QCListIt( const QCList *p ): QInternalListIterator<QCacheItem>( *p ) {}
QCListIt( const QCListIt *p ): QInternalListIterator<QCacheItem>( *p ) {}
};
@@ -36,7 +36,7 @@
**********************************************************************/
#include "qgdict.h"
#include "qlist.h"
#include "qinternallist.h"
#include "qstring.h"
#include "qdatastream.h"
#include <ctype.h>
@@ -63,14 +63,14 @@ static const int op_insert = 1;
static const int op_replace = 2;
class QGDItList : public QList<QGDictIterator>
class QGDItList : public QInternalList<QGDictIterator>
{
public:
QGDItList() : QList<QGDictIterator>() {}
QGDItList( const QGDItList &list ) : QList<QGDictIterator>(list) {}
QGDItList() : QInternalList<QGDictIterator>() {}
QGDItList( const QGDItList &list ) : QInternalList<QGDictIterator>(list) {}
~QGDItList() { clear(); }
QGDItList &operator=(const QGDItList &list)
{ return (QGDItList&)QList<QGDictIterator>::operator=(list); }
{ return (QGDItList&)QInternalList<QGDictIterator>::operator=(list); }
};
@@ -0,0 +1,139 @@
/****************************************************************************
**
**
** Definition of QList template/macro class
**
** Created : 920701
**
** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
**
** This file is part of the tools module of the Qt GUI Toolkit.
**
** This file may be distributed under the terms of the Q Public License
** as defined by Trolltech AS of Norway and appearing in the file
** LICENSE.QPL included in the packaging of this file.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
** licenses may use this file in accordance with the Qt Commercial License
** Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
** information about Qt Commercial License Agreements.
** See http://www.trolltech.com/qpl/ for QPL licensing information.
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef QINTERNALLIST_H
#define QINTERNALLIST_H
#ifndef QT_H
#include "qglist.h"
#endif // QT_H
template<class type> class Q_EXPORT QInternalList : public QGList
{
public:
QInternalList() {}
QInternalList( const QInternalList<type> &l ) : QGList(l) {}
~QInternalList() { clear(); }
QInternalList<type> &operator=(const QInternalList<type> &l)
{ return (QInternalList<type>&)QGList::operator=(l); }
bool operator==( const QInternalList<type> &list ) const
{ return QGList::operator==( list ); }
uint count() const { return QGList::count(); }
bool isEmpty() const { return QGList::count() == 0; }
bool insert( uint i, const type *d){ return QGList::insertAt(i,(QCollection::Item)d); }
void inSort( const type *d ) { QGList::inSort((QCollection::Item)d); }
void prepend( const type *d ) { QGList::insertAt(0,(QCollection::Item)d); }
void append( const type *d ) { QGList::append((QCollection::Item)d); }
bool remove( uint i ) { return QGList::removeAt(i); }
bool remove() { return QGList::remove((QCollection::Item)0); }
bool remove( const type *d ) { return QGList::remove((QCollection::Item)d); }
bool removeRef( const type *d ) { return QGList::removeRef((QCollection::Item)d); }
void removeNode( QLNode *n ) { QGList::removeNode(n); }
bool removeFirst() { return QGList::removeFirst(); }
bool removeLast() { return QGList::removeLast(); }
type *take( uint i ) { return (type *)QGList::takeAt(i); }
type *take() { return (type *)QGList::take(); }
type *takeNode( QLNode *n ) { return (type *)QGList::takeNode(n); }
void clear() { QGList::clear(); }
void sort() { QGList::sort(); }
int find( const type *d ) { return QGList::find((QCollection::Item)d); }
int findNext( const type *d ) { return QGList::find((QCollection::Item)d,FALSE); }
int findRef( const type *d ) { return QGList::findRef((QCollection::Item)d); }
int findNextRef( const type *d ){ return QGList::findRef((QCollection::Item)d,FALSE);}
uint contains( const type *d ) const { return QGList::contains((QCollection::Item)d); }
uint containsRef( const type *d ) const
{ return QGList::containsRef((QCollection::Item)d); }
type *at( uint i ) { return (type *)QGList::at(i); }
int at() const { return QGList::at(); }
type *current() const { return (type *)QGList::get(); }
QLNode *currentNode() const { return QGList::currentNode(); }
type *getFirst() const { return (type *)QGList::cfirst(); }
type *getLast() const { return (type *)QGList::clast(); }
type *first() { return (type *)QGList::first(); }
type *last() { return (type *)QGList::last(); }
type *next() { return (type *)QGList::next(); }
type *prev() { return (type *)QGList::prev(); }
void toVector( QGVector *vec )const{ QGList::toVector(vec); }
private:
void deleteItem( QCollection::Item d );
};
#if defined(Q_DELETING_VOID_UNDEFINED)
template<> inline void QInternalList<void>::deleteItem( QCollection::Item )
{
}
#endif
template<class type> inline void QInternalList<type>::deleteItem( QCollection::Item d )
{
if ( del_item ) delete (type *)d;
}
template<class type> class Q_EXPORT QInternalListIterator : public QGListIterator
{
public:
QInternalListIterator(const QInternalList<type> &l) :QGListIterator((QGList &)l) {}
~QInternalListIterator() {}
uint count() const { return list->count(); }
bool isEmpty() const { return list->count() == 0; }
bool atFirst() const { return QGListIterator::atFirst(); }
bool atLast() const { return QGListIterator::atLast(); }
type *toFirst() { return (type *)QGListIterator::toFirst(); }
type *toLast() { return (type *)QGListIterator::toLast(); }
operator type *() const { return (type *)QGListIterator::get(); }
type *operator*() { return (type *)QGListIterator::get(); }
// No good, since QList<char> (ie. QStrList fails...
//
// MSVC++ gives warning
// Sunpro C++ 4.1 gives error
// type *operator->() { return (type *)QGListIterator::get(); }
type *current() const { return (type *)QGListIterator::get(); }
type *operator()() { return (type *)QGListIterator::operator()();}
type *operator++() { return (type *)QGListIterator::operator++(); }
type *operator+=(uint j) { return (type *)QGListIterator::operator+=(j);}
type *operator--() { return (type *)QGListIterator::operator--(); }
type *operator-=(uint j) { return (type *)QGListIterator::operator-=(j);}
QInternalListIterator<type>& operator=(const QInternalListIterator<type>&it)
{ QGListIterator::operator=(it); return *this; }
};
#endif // QINTERNALLIST_H
Oops, something went wrong.

0 comments on commit 6e51abf

Please sign in to comment.