diff options
47 files changed, 100 insertions, 3773 deletions
diff --git a/qtools/qasciidict.h b/qtools/qasciidict.h deleted file mode 100644 index 6a93a02..0000000 --- a/qtools/qasciidict.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** -** Definition of QAsciiDict template class -** -** Created : 920821 -** -** 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 QASCIIDICT_H -#define QASCIIDICT_H - -#ifndef QT_H -#include "qgdict.h" -#endif // QT_H - - -template<class type> class Q_EXPORT QAsciiDict : public QGDict -{ -public: - QAsciiDict(uint size=17, bool caseSensitive=TRUE, bool copyKeys=TRUE ) - : QGDict(size,AsciiKey,caseSensitive,copyKeys) {} - QAsciiDict( const QAsciiDict<type> &d ) : QGDict(d) {} - ~QAsciiDict() { clear(); } - QAsciiDict<type> &operator=(const QAsciiDict<type> &d) - { return (QAsciiDict<type>&)QGDict::operator=(d); } - uint count() const { return QGDict::count(); } - uint size() const { return QGDict::size(); } - bool isEmpty() const { return QGDict::count() == 0; } - - void insert( const char *k, const type *d ) - { QGDict::look_ascii(k,(Item)d,1); } - void replace( const char *k, const type *d ) - { QGDict::look_ascii(k,(Item)d,2); } - bool remove( const char *k ) { return QGDict::remove_ascii(k); } - type *take( const char *k ) { return (type *)QGDict::take_ascii(k); } - type *find( const char *k ) const - { return (type *)((QGDict*)this)->QGDict::look_ascii(k,0,0); } - type *operator[]( const char *k ) const - { return (type *)((QGDict*)this)->QGDict::look_ascii(k,0,0); } - - void clear() { QGDict::clear(); } - void resize( uint n ) { QGDict::resize(n); } - void statistics() const { QGDict::statistics(); } -private: - void deleteItem( Item d ); -}; - -#if defined(Q_DELETING_VOID_UNDEFINED) -template<> inline void QAsciiDict<void>::deleteItem( Item ) -{ -} -#endif - -template<class type> inline void QAsciiDict<type>::deleteItem( QCollection::Item d ) -{ - if ( del_item ) delete (type *)d; -} - - -template<class type> class Q_EXPORT QAsciiDictIterator : public QGDictIterator -{ -public: - QAsciiDictIterator(const QAsciiDict<type> &d) - : QGDictIterator((QGDict &)d) {} - ~QAsciiDictIterator() {} - uint count() const { return dict->count(); } - bool isEmpty() const { return dict->count() == 0; } - type *toFirst() { return (type *)QGDictIterator::toFirst(); } - operator type *() const { return (type *)QGDictIterator::get(); } - type *current() const { return (type *)QGDictIterator::get(); } - const char *currentKey() const { return QGDictIterator::getKeyAscii(); } - type *operator()() { return (type *)QGDictIterator::operator()(); } - type *operator++() { return (type *)QGDictIterator::operator++(); } - type *operator+=(uint j) { return (type *)QGDictIterator::operator+=(j);} -}; - - -#endif // QASCIIDICT_H diff --git a/qtools/qcstringlist.h b/qtools/qcstringlist.h index 7ffd4d2..a7d79b0 100644 --- a/qtools/qcstringlist.h +++ b/qtools/qcstringlist.h @@ -14,7 +14,7 @@ #ifndef QCSTRINGLIST_H #define QCSTRINGLIST_H -#include "qvaluelist.h" +#include "qvaluelist_p.h" #include "qcstring.h" #include "qregexp.h" diff --git a/qtools/qdict.doc b/qtools/qdict.doc deleted file mode 100644 index bf1ea01..0000000 --- a/qtools/qdict.doc +++ /dev/null @@ -1,492 +0,0 @@ -/**************************************************************************** -** -** -** QDict and QDictIterator class documentation -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part 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. -** -**********************************************************************/ - - -/***************************************************************************** - QDict documentation - *****************************************************************************/ - -/*! - \class QDict qdict.h - \brief The QDict class is a template class that provides a dictionary based on \c QString keys. - - \ingroup collection - \ingroup tools - - QDict is implemented as a template class. Define a template instance - QDict\<X\> to create a dictionary that operates on pointers to X, or X*. - - A dictionary is a collection that associates an item with a key. - The key is used for inserting and looking up an item. QDict has - \l QString keys, which are Unicode strings. If you want to use - non-Unicode, plain 8-bit \c char* keys, use the QAsciiDict template. - A QDict has the same performance as a QAsciiDict. - - The dictionary has very fast insertion and lookup. - - Example: - \code - #include <qdict.h> - #include <stdio.h> - - void main() - { - // Creates a dictionary that maps QString ==> char* (case insensitive) - QDict<char> dict( 17, FALSE ); - - dict.insert( "France", "Paris" ); - dict.insert( "Russia", "Moscow" ); - dict.insert( "Norway", "Oslo" ); - - printf( "%s\n", dict["Norway"] ); - printf( "%s\n", dict["FRANCE"] ); - printf( "%s\n", dict["russia"] ); - - if ( !dict["Italy"] ) - printf( "Italy not defined\n" ); - } - \endcode - - Program output: - \code - Oslo - Paris - Moscow - Italy not defined - \endcode - - The dictionary in our example maps \c QString keys to \c char* items. - Note that the mapping is case insensitive (specified in the - \link QDict::QDict() constructor\endlink). - QDict implements the \link operator[] [] operator\endlink to lookup an item. - - QDict is implemented by QGDict as a hash array with a fixed number of - entries. Each array entry points to a singly linked list of buckets, in - which the dictionary items are stored. - - When an item is inserted with a key, the key is converted (hashed) to - an integer index into the hash array. The item is inserted before the - first bucket in the list of buckets. - - Looking up an item is normally very fast. The key is again hashed to an - array index. Then QDict scans the list of buckets and returns the item - found or null if the item was not found. You cannot insert null pointers - into a dictionary. - - The size of the hash array is very important. In order to get good - performance, you should use a suitably large \link primes.html prime - number\endlink. Suitable means equal to or larger than the maximum - expected number of dictionary items. - - Items with equal keys are allowed. When inserting two items with the - same key, only the last inserted item will be visible (last in, first out) - until it is removed. - - Example: - \code - #include <qdict.h> - #include <stdio.h> - - void main() - { - // Creates a dictionary that maps QString ==> char* (case sensitive) - QDict<char> dict; - - dict.insert( "Germany", "Berlin" ); - dict.insert( "Germany", "Bonn" ); - - printf( "%s\n", dict["Germany"] ); - dict.remove( "Germany" ); // Oct 3rd 1990 - printf( "%s\n", dict["Germany"] ); - } - \endcode - - Program output: - \code - Bonn - Berlin - \endcode - - The QDictIterator class can traverse the dictionary contents, but only - in an arbitrary order. Multiple iterators may independently traverse the - same dictionary. - - Calling setAutoDelete(TRUE) for a dictionary tells it to delete items - that are removed . The default is to not delete items when they are - removed. - - When inserting an item into a dictionary, only the pointer is copied, not - the item itself. This is called a shallow copy. It is possible to make the - dictionary copy all of the item's data (known as a deep copy) when an - item is inserted. insert() calls the virtual function - QCollection::newItem() for the item to be inserted. - Inherit a dictionary and reimplement it if you want deep copies. - - When removing a dictionary item, the virtual function - QCollection::deleteItem() is called. QDict's default implementation - is to delete the item if auto-deletion is enabled. - - \sa QDictIterator, QAsciiDict, QIntDict, QPtrDict, - \link collection.html Collection Classes\endlink -*/ - - -/*! - \fn QDict::QDict( int size, bool caseSensitive ) - Constructs a dictionary with the following properties: - \arg \e size is the size of the internal hash array. - \arg \e caseSensitive specifies whether to use case sensitive lookup or not. - - Setting \e size to a suitably large \link primes.html prime - number\endlink (equal to or greater than the expected number of entries) - makes the hash distribution better and hence the lookup faster. - - Setting \e caseSensitive to TRUE will treat "abc" and "Abc" as different - keys. Setting it to FALSE will make the dictionary ignore case. - Case insensitive comparison includes the whole Unicode alphabet. -*/ - -/*! - \fn QDict::QDict( const QDict<type> &dict ) - Constructs a copy of \e dict. - - Each item in \e dict are inserted into this dictionary. - Only the pointers are copied (shallow copy). -*/ - -/*! - \fn QDict::~QDict() - Removes all items from the dictionary and destroys it. - All iterators that access this dictionary will be reset. - - \sa setAutoDelete() -*/ - -/*! - \fn QDict<type> &QDict::operator=(const QDict<type> &dict) - Assigns \e dict to this dictionary and returns a reference to this - dictionary. - - This dictionary is first cleared, then each item in \e dict is inserted - into this dictionary. - Only the pointers are copied (shallow copy), unless newItem() has been - reimplemented(). -*/ - -/*! - \fn uint QDict::count() const - Returns the number of items in the dictionary. - \sa isEmpty() -*/ - -/*! - \fn uint QDict::size() const - Returns the size of the internal hash array (as specified in the - constructor). - \sa count() -*/ - -/*! - \fn void QDict::resize( uint newsize ) - Changes the size of the hashtable the \a newsize. - The contents of the dictionary are preserved, - but all iterators on the dictionary become invalid. -*/ - -/*! - \fn bool QDict::isEmpty() const - Returns TRUE if the dictionary is empty, i.e. count() == 0. Returns FALSE - otherwise. - \sa count() -*/ - -/*! - \fn void QDict::insert( const QString &key, const type *item ) - - Inserts the \e key with the \e item into the dictionary. - - The key does not have to be a unique dictionary key. If multiple items - are inserted with the same key, only the last item will be visible. - - Null items are not allowed. - - \sa replace() -*/ - -/*! - \fn void QDict::replace( const QString &key, const type *item ) - - Replaces an item which has a key equal to \e key with \e item. - - If the item does not already exist, it will be inserted. - - Null items are not allowed. - - Equivalent to: - \code - QDict<char> dict; - ... - if ( dict.find(key) ) - dict.remove( key ); - dict.insert( key, item ); - \endcode - - If there are two or more items with equal keys, then the last inserted - of these will be replaced. - - \sa insert() -*/ - -/*! - \fn bool QDict::remove( const QString &key ) - - Removes the item associated with \e key from the dictionary. - Returns TRUE if successful, or FALSE if the key does not exist in the - dictionary. - - If there are two or more items with equal keys, then the last inserted - of these will be removed. - - The removed item is deleted if \link QCollection::setAutoDelete() - auto-deletion\endlink is enabled. - - All dictionary iterators that refer to the removed item will be set to - point to the next item in the dictionary traversing order. - - \sa take(), clear(), setAutoDelete() -*/ - -/*! - \fn type *QDict::take( const QString &key ) - - Takes the item associated with \e key out of the dictionary without - deleting it (even if \link QCollection::setAutoDelete() - auto-deletion\endlink is enabled). - - If there are two or more items with equal keys, then the last inserted - of these will be taken. - - Returns a pointer to the item taken out, or null if the key does not - exist in the dictionary. - - All dictionary iterators that refer to the taken item will be set to - point to the next item in the dictionary traversal order. - - \sa remove(), clear(), setAutoDelete() -*/ - -/*! - \fn void QDict::clear() - - Removes all items from the dictionary. - - The removed items are deleted if \link QCollection::setAutoDelete() - auto-deletion\endlink is enabled. - - All dictionary iterators that operate on dictionary are reset. - - \sa remove(), take(), setAutoDelete() -*/ - -/*! - \fn type *QDict::find( const QString &key ) const - - Returns the item associated with \e key, or null if the key does not - exist in the dictionary. - - This function uses an internal hashing algorithm to optimize lookup. - - If there are two or more items with equal keys, then the last inserted - of these will be found. - - Equivalent to the [] operator. - - \sa operator[]() -*/ - -/*! - \fn type *QDict::operator[]( const QString &key ) const - - Returns the item associated with \e key, or null if the key does not - exist in the dictionary. - - This function uses an internal hashing algorithm to optimize lookup. - - If there are two or more items with equal keys, then the last inserted - of these will be found. - - Equivalent to the find() function. - - \sa find() -*/ - -/*! - \fn void QDict::statistics() const - Debugging-only function that prints out the dictionary distribution - using qDebug(). -*/ - - -/***************************************************************************** - QDictIterator documentation - *****************************************************************************/ - -/*! - \class QDictIterator qdict.h - \brief The QDictIterator class provides an iterator for QDict collections. - - \ingroup collection - \ingroup tools - - QDictIterator is implemented as a template class. - Define a template instance QDictIterator\<X\> to create a - dictionary iterator that operates on QDict\<X\> (dictionary of X*). - - Example: - \code - #include <qdict.h> - #include <stdio.h> - - void main() - { - // Creates a dictionary that maps QString ==> char* (case insensitive) - QDict<char> dict( 17, FALSE ); - - dict.insert( "France", "Paris" ); - dict.insert( "Russia", "Moscow" ); - dict.insert( "Norway", "Oslo" ); - - QDictIterator<char> it( dict ); // iterator for dict - - while ( it.current() ) { - printf( "%s -> %s\n", it.currentKey().latin1(), it.current() ); - ++it; - } - } - \endcode - - Program output: - \code - Russia -> Moscow - Norway -> Oslo - France -> Paris - \endcode - - Note that the traversal order is arbitrary, you are not guaranteed the - order above. - - Multiple iterators may independently traverse the same dictionary. - A QDict knows about all iterators that are operating on the dictionary. - When an item is removed from the dictionary, QDict update all iterators - that are referring the removed item to point to the next item in the - traversing order. - - \sa QDict, \link collection.html Collection Classes\endlink -*/ - -/*! - \fn QDictIterator::QDictIterator( const QDict<type> &dict ) - Constructs an iterator for \e dict. The current iterator item is - set to point on the first item in the \e dict. -*/ - -/*! - \fn QDictIterator::~QDictIterator() - Destroys the iterator. -*/ - -/*! - \fn uint QDictIterator::count() const - Returns the number of items in the dictionary this iterator operates on. - \sa isEmpty() -*/ - -/*! - \fn bool QDictIterator::isEmpty() const - Returns TRUE if the dictionary is empty, i.e. count() == 0, otherwise FALSE. - \sa count() -*/ - -/*! - \fn type *QDictIterator::toFirst() - Sets the current iterator item to point to the first item in the - dictionary and returns a pointer to the item. - If the dictionary is empty it sets the current item to null and - returns null. -*/ - -/*! - \fn QDictIterator::operator type *() const - Cast operator. Returns a pointer to the current iterator item. - Same as current(). -*/ - -/*! - \fn type *QDictIterator::current() const - Returns a pointer to the current iterator item. -*/ - -/*! - \fn QString QDictIterator::currentKey() const - Returns a pointer to the key for the current iterator item. -*/ - -/*! - \fn type *QDictIterator::operator()() - Makes the succeeding item current and returns the original current item. - - If the current iterator item was the last item in the dictionary or if it - was null, null is returned. -*/ - -/*! - \fn type *QDictIterator::operator++() - Prefix ++ makes the succeeding item current and returns the new current - item. - - If the current iterator item was the last item in the dictionary or if it - was null, null is returned. -*/ - -/*! - \fn type *QDictIterator::operator+=( uint jump ) - Sets the current item to the item \e jump positions after the current item, - and returns a pointer to that item. - - If that item is beyond the last item or if the dictionary is empty, - it sets the current item to null and returns null. -*/ - - diff --git a/qtools/qdict.h b/qtools/qdict.h deleted file mode 100644 index 12db365..0000000 --- a/qtools/qdict.h +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** -** Definition of QDict template class -** -** Created : 920821 -** -** 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 QDICT_H -#define QDICT_H - -#ifndef QT_H -#include "qgdict.h" -#endif // QT_H - -#define QAsciiDict QDict -#define QAsciiDictIterator QDictIterator -#include "qasciidict.h" - -#endif // QDICT_H diff --git a/qtools/qglobal.cpp b/qtools/qglobal.cpp index 444cb3b..0e0871e 100644 --- a/qtools/qglobal.cpp +++ b/qtools/qglobal.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -** +** ** ** Global functions ** @@ -36,7 +36,7 @@ **********************************************************************/ #include "qglobal.h" -#include "qasciidict.h" +//#include "qasciidict.h" #include "qstring.h" #include <stdio.h> #include <stdarg.h> @@ -554,6 +554,7 @@ bool qt_check_pointer( bool c, const char *n, int l ) } +#if 0 static bool firstObsoleteWarning(const char *obj, const char *oldfunc ) { static QAsciiDict<int> *obsoleteDict = 0; @@ -617,6 +618,7 @@ void qObsolete( const char *message ) return; qDebug( "%s", message ); } +#endif /*! diff --git a/qtools/qglobal.h b/qtools/qglobal.h index 0deef5d..1fbe2f7 100644 --- a/qtools/qglobal.h +++ b/qtools/qglobal.h @@ -1,5 +1,5 @@ /**************************************************************************** -** +** ** ** Global type declarations and definitions ** @@ -276,7 +276,7 @@ #define _CC_V2002 #else #define _CC_V1998 -#endif +#endif #endif #ifndef Q_PACKED @@ -612,6 +612,7 @@ Q_EXPORT msg_handler qInstallMsgHandler( msg_handler ); Q_EXPORT void qSuppressObsoleteWarnings( bool = TRUE ); +#if 0 #if !defined(QT_REJECT_OBSOLETE) #define QT_OBSOLETE Q_EXPORT void qObsolete( const char *obj, const char *oldfunc, @@ -619,6 +620,7 @@ Q_EXPORT void qObsolete( const char *obj, const char *oldfunc, Q_EXPORT void qObsolete( const char *obj, const char *oldfunc ); Q_EXPORT void qObsolete( const char *message ); #endif +#endif // DvH: added to avoid warnings on recent gcc versions #define Q_DELETING_VOID_UNDEFINED diff --git a/qtools/qintdict.doc b/qtools/qintdict.doc deleted file mode 100644 index 90625da..0000000 --- a/qtools/qintdict.doc +++ /dev/null @@ -1,475 +0,0 @@ -/**************************************************************************** -** -** -** QIntDict and QIntDictIterator class documentation -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part 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. -** -**********************************************************************/ - - -/***************************************************************************** - QIntDict documentation - *****************************************************************************/ - -/*! - \class QIntDict qintdict.h - \brief The QIntDict class is a template class that provides a dictionary based on \c long keys. - - \ingroup collection - \ingroup tools - - QIntDict is implemented as a template class. Define a - template instance QIntDict\<X\> to create a dictionary that operates on - pointers to X, or X*. - - A dictionary is a collection that associates an item with a key. - The key is used for inserting and looking up an item. QIntDict has - \c long keys. - - The dictionary has very fast insertion and lookup. - - Example: - \code - #include <qintdict.h> - #include <stdio.h> - - void main() - { - QIntDict<char> dict; // maps long ==> char* - - dict.insert( 33, "France" ); - dict.insert( 7, "Russia" ); - dict.insert( 49, "Norway" ); - - printf( "%s\n", dict[49] ); - printf( "%s\n", dict[33] ); - printf( "%s\n", dict[7] ); - - if ( !dict[39] ) - printf( "39 not defined\n" ); - } - \endcode - - Program output: - \code - Norway - France - Russia - 39 not defined - \endcode - - The dictionary in our example maps \c long keys to \c char* items. - QIntDict implements the \link operator[] [] operator\endlink to lookup - an item. - - QIntDict is implemented by QGDict as a hash array with a fixed number of - entries. Each array entry points to a singly linked list of buckets, in - which the dictionary items are stored. - - When an item is inserted with a key, the key is converted (hashed) to - an integer index into the hash array using the \c mod operation. The - item is inserted before the first bucket in the list of buckets. - - Looking up an item is normally very fast. The key is again hashed to an - array index. Then QIntDict scans the list of buckets and returns the item - found or null if the item was not found. You cannot insert null pointers - into a dictionary. - - The size of the hash array is very important. In order to get good - performance, you should use a suitably large \link primes.html prime - number\endlink. Suitable means equal to or larger than the maximum - expected number of dictionary items. - - Items with equal keys are allowed. When inserting two items with the - same key, only the last inserted item will be visible (last in, first out) - until it is removed. - - Example: - \code - #include <qintdict.h> - #include <stdio.h> - - void main() - { - QIntDict<char> dict; // maps long ==> char* - - dict.insert( 7, "Russia" ); - dict.insert( 7, "USSR" ); - - printf( "%s\n", dict[7] ); - dict.remove( 7 ); // Gorbie was here - printf( "%s\n", dict[7] ); - } - \endcode - - Program output: - \code - USSR - Russia - \endcode - - The QIntDictIterator class can traverse the dictionary contents, but only - in an arbitrary order. Multiple iterators may independently traverse the - same dictionary. - - Calling setAutoDelete(TRUE) for a dictionary tells it to delete items - that are removed . The default is to not delete items when they are - removed. - - When inserting an item into a dictionary, only the pointer is copied, not - the item itself. This is called a shallow copy. It is possible to make the - dictionary copy all of the item's data (known as a deep copy) when an - item is inserted. insert() calls the virtual function - QCollection::newItem() for the item to be inserted. - Inherit a dictionary and reimplement it if you want deep copies. - - When removing a dictionary item, the virtual function - QCollection::deleteItem() is called. QIntDict's default implementation - is to delete the item if auto-deletion is enabled. - - \sa QIntDictIterator, QDict, QAsciiDict, QPtrDict, - \link collection.html Collection Classes\endlink -*/ - - -/*! - \fn QIntDict::QIntDict( int size ) - Constructs a dictionary using an internal hash array with the size - \e size. - - Setting \e size to a suitably large \link primes.html prime number\endlink - (equal to or greater than the expected number of entries) makes the hash - distribution better and hence the lookup faster. -*/ - -/*! - \fn QIntDict::QIntDict( const QIntDict<type> &dict ) - Constructs a copy of \e dict. - - Each item in \e dict are inserted into this dictionary. - Only the pointers are copied (shallow copy). -*/ - -/*! - \fn QIntDict::~QIntDict() - Removes all items from the dictionary and destroys it. - - All iterators that access this dictionary will be reset. - - \sa setAutoDelete() -*/ - -/*! - \fn QIntDict<type> &QIntDict::operator=(const QIntDict<type> &dict) - Assigns \e dict to this dictionary and returns a reference to this - dictionary. - - This dictionary is first cleared, then each item in \e dict is inserted - into this dictionary. - Only the pointers are copied (shallow copy), unless newItem() has been - reimplemented. -*/ - -/*! - \fn uint QIntDict::count() const - Returns the number of items in the dictionary. - \sa isEmpty() -*/ - -/*! - \fn uint QIntDict::size() const - Returns the size of the internal hash array (as specified in the - constructor). - \sa count() -*/ - -/*! - \fn void QIntDict::resize( uint newsize ) - Changes the size of the hashtable the \a newsize. - The contents of the dictionary are preserved, - but all iterators on the dictionary become invalid. -*/ - -/*! - \fn bool QIntDict::isEmpty() const - Returns TRUE if the dictionary is empty, i.e. count() == 0. Returns FALSE - otherwise. - \sa count() -*/ - -/*! - \fn void QIntDict::insert( long key, const type *item ) - Inserts the \e key with the \e item into the dictionary. - - The key does not have to be a unique dictionary key. If multiple items - are inserted with the same key, only the last item will be visible. - - Null items are not allowed. - - \sa replace() -*/ - -/*! - \fn void QIntDict::replace( long key, const type *item ) - Replaces an item which has a key equal to \e key with \e item. - - If the item does not already exist, it will be inserted. - - Null items are not allowed. - - Equivalent to: - \code - QIntDict<char> dict; - ... - if ( dict.find(key) ) - dict.remove( key ); - dict.insert( key, item ); - \endcode - - If there are two or more items with equal keys, then the last inserted - of these will be replaced. - - \sa insert() -*/ - -/*! - \fn bool QIntDict::remove( long key ) - Removes the item associated with \e key from the dictionary. - Returns TRUE if successful, or FALSE if the key does not exist in the - dictionary. - - If there are two or more items with equal keys, then the last inserted - of these will be removed. - - The removed item is deleted if \link QCollection::setAutoDelete() - auto-deletion\endlink is enabled. - - All dictionary iterators that refer to the removed item will be set to - point to the next item in the dictionary traversing order. - - \sa take(), clear(), setAutoDelete() -*/ - -/*! - \fn type *QIntDict::take( long key ) - Takes the item associated with \e key out of the dictionary without - deleting it (even if \link QCollection::setAutoDelete() - auto-deletion\endlink is enabled). - - If there are two or more items with equal keys, then the last inserted - of these will be taken. - - Returns a pointer to the item taken out, or null if the key does not - exist in the dictionary. - - All dictionary iterators that refer to the taken item will be set to - point to the next item in the dictionary traversing order. - - \sa remove(), clear(), setAutoDelete() -*/ - -/*! - \fn void QIntDict::clear() - Removes all items from the dictionary. - - The removed items are deleted if \link QCollection::setAutoDelete() - auto-deletion\endlink is enabled. - - All dictionary iterators that access this dictionary will be reset. - - \sa remove(), take(), setAutoDelete() -*/ - -/*! - \fn type *QIntDict::find( long key ) const - Returns the item associated with \e key, or null if the key does not - exist in the dictionary. - - This function uses an internal hashing algorithm to optimize lookup. - - If there are two or more items with equal keys, then the last inserted - of these will be found. - - Equivalent to the [] operator. - - \sa operator[]() -*/ - -/*! - \fn type *QIntDict::operator[]( long key ) const - Returns the item associated with \e key, or null if the key does not - exist in the dictionary. - - This function uses an internal hashing algorithm to optimize lookup. - - If there are two or more items with equal keys, then the last inserted - of these will be found. - - Equivalent to the find() function. - - \sa find() -*/ - -/*! - \fn void QIntDict::statistics() const - Debugging-only function that prints out the dictionary distribution - using qDebug(). -*/ - - -/***************************************************************************** - QIntDictIterator documentation - *****************************************************************************/ - -/*! - \class QIntDictIterator qintdict.h - \brief The QIntDictIterator class provides an iterator for QIntDict collections. - - \ingroup collection - \ingroup tools - - QIntDictIterator is implemented as a template class. - Define a template instance QIntDictIterator\<X\> to create a - dictionary iterator that operates on QIntDict\<X\> (dictionary of X*). - - Example: - \code - #include <qintdict.h> - #include <stdio.h> - - void main() - { - QIntDict<char> dict; // maps long ==> char* - - dict.insert( 33, "France" ); - dict.insert( 7, "Russia" ); - dict.insert( 49, "Norway" ); - - QIntDictIterator<char> it( dict ); // iterator for dict - - while ( it.current() ) { - printf( "%d -> %s\n", it.currentKey(), it.current() ); - ++it; - } - } - \endcode - - Program output: - \code - 7 -> Russia - 49 -> Norway - 33 -> France - \endcode - - Note that the traversal order is arbitrary, you are not guaranteed the - order above. - - Multiple iterators may independently traverse the same dictionary. - A QIntDict knows about all iterators that are operating on the dictionary. - When an item is removed from the dictionary, QIntDict update all - iterators that are referring the removed item to point to the next item - in the traversing order. - - \sa QIntDict, \link collection.html Collection Classes\endlink -*/ - -/*! - \fn QIntDictIterator::QIntDictIterator( const QIntDict<type> &dict ) - Constructs an iterator for \e dict. The current iterator item is - set to point on the first item in the \e dict. -*/ - -/*! - \fn QIntDictIterator::~QIntDictIterator() - Destroys the iterator. -*/ - -/*! - \fn uint QIntDictIterator::count() const - Returns the number of items in the dictionary this iterator operates on. - \sa isEmpty() -*/ - -/*! - \fn bool QIntDictIterator::isEmpty() const - Returns TRUE if the dictionary is empty, i.e. count() == 0. Returns FALSE - otherwise. - \sa count() -*/ - -/*! - \fn type *QIntDictIterator::toFirst() - Sets the current iterator item to point to the first item in the - dictionary and returns a pointer to the item. - If the dictionary is empty it sets the current item to null and - returns null. -*/ - -/*! - \fn QIntDictIterator::operator type *() const - Cast operator. Returns a pointer to the current iterator item. - Same as current(). -*/ - -/*! - \fn type *QIntDictIterator::current() const - Returns a pointer to the current iterator item. -*/ - -/*! - \fn long QIntDictIterator::currentKey() const - Returns the key for the current iterator item. -*/ - -/*! - \fn type *QIntDictIterator::operator()() - Makes the succeeding item current and returns the original current item. - - If the current iterator item was the last item in the dictionary or if it - was null, null is returned. -*/ - -/*! - \fn type *QIntDictIterator::operator++() - Prefix ++ makes the succeeding item current and returns the new current - item. - - If the current iterator item was the last item in the dictionary or if it - was null, null is returned. -*/ - -/*! - \fn type *QIntDictIterator::operator+=( uint jump ) - Sets the current item to the item \e jump positions after the current item, - and returns a pointer to that item. - - If that item is beyond the last item or if the dictionary is empty, - it sets the current item to null and returns null. -*/ diff --git a/qtools/qintdict.h b/qtools/qintdict.h deleted file mode 100644 index 0606ec8..0000000 --- a/qtools/qintdict.h +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** -** Definition of QIntDict template class -** -** Created : 940624 -** -** 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 QINTDICT_H -#define QINTDICT_H - -#ifndef QT_H -#include "qgdict.h" -#endif // QT_H - - -template<class type> class Q_EXPORT QIntDict : public QGDict -{ -public: - QIntDict(uint size=17) : QGDict(size,IntKey,0,0) {} - QIntDict( const QIntDict<type> &d ) : QGDict(d) {} - ~QIntDict() { clear(); } - QIntDict<type> &operator=(const QIntDict<type> &d) - { return (QIntDict<type>&)QGDict::operator=(d); } - uint count() const { return QGDict::count(); } - uint size() const { return QGDict::size(); } - bool isEmpty() const { return QGDict::count() == 0; } - void insert( long k, const type *d ) - { QGDict::look_int(k,(Item)d,1); } - void replace( long k, const type *d ) - { QGDict::look_int(k,(Item)d,2); } - bool remove( long k ) { return QGDict::remove_int(k); } - type *take( long k ) { return (type*)QGDict::take_int(k); } - type *find( long k ) const - { return (type *)((QGDict*)this)->QGDict::look_int(k,0,0); } - type *operator[]( long k ) const - { return (type *)((QGDict*)this)->QGDict::look_int(k,0,0); } - void clear() { QGDict::clear(); } - void resize( uint n ) { QGDict::resize(n); } - void statistics() const { QGDict::statistics(); } -private: - void deleteItem( Item d ); -}; - -#if defined(Q_DELETING_VOID_UNDEFINED) -template<> inline void QIntDict<void>::deleteItem( QCollection::Item ) -{ -} -#endif - -template<class type> inline void QIntDict<type>::deleteItem( QCollection::Item d ) -{ - if ( del_item ) delete (type *)d; -} - -template<class type> class Q_EXPORT QIntDictIterator : public QGDictIterator -{ -public: - QIntDictIterator(const QIntDict<type> &d) :QGDictIterator((QGDict &)d) {} - ~QIntDictIterator() {} - uint count() const { return dict->count(); } - bool isEmpty() const { return dict->count() == 0; } - type *toFirst() { return (type *)QGDictIterator::toFirst(); } - operator type *() const { return (type *)QGDictIterator::get(); } - type *current() const { return (type *)QGDictIterator::get(); } - long currentKey() const { return QGDictIterator::getKeyInt(); } - type *operator()() { return (type *)QGDictIterator::operator()(); } - type *operator++() { return (type *)QGDictIterator::operator++(); } - type *operator+=(uint j) { return (type *)QGDictIterator::operator+=(j);} -}; - - -#endif // QINTDICT_H diff --git a/qtools/qlist.doc b/qtools/qlist.doc deleted file mode 100644 index d28d662..0000000 --- a/qtools/qlist.doc +++ /dev/null @@ -1,1035 +0,0 @@ -/**************************************************************************** -** -** -** QList and QListIterator class documentation -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part 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. -** -**********************************************************************/ - - -/***************************************************************************** - QList documentation - *****************************************************************************/ - -/*! - \class QList qlist.h - \brief The QList class is a template class that provides doubly linked lists. - - \ingroup collection - \ingroup tools - - In Qt 2.0 QList is only implemented as a template class. Define a - template instance QList\<X\> to create a list that operates on pointers - to X, or X*. - - Example: - \code - #include <qlist.h> - #include <qstring.h> - #include <stdio.h> - - class Employee - { - public: - Employee( const QString& name, int salary ) { n=name; s=salary; } - QString name() const { return n; } - int salary() const { return s; } - private: - QString n; - int s; - }; - - void main() - { - QList<Employee> list; // list of pointers to Employee - list.setAutoDelete( TRUE ); // delete items when they are removed - - list.append( new Employee("Bill", 50000) ); - list.append( new Employee("Steve",80000) ); - list.append( new Employee("Ron", 60000) ); - - Employee *emp; - for ( emp=list.first(); emp != 0; emp=list.next() ) - printf( "%s earns %d\n", emp->name().latin1(), emp->salary() ); - } - \endcode - - Program output: - \code - Bill earns 50000 - Steve earns 80000 - Ron earns 60000 - \endcode - - The list class is indexable and has a \link at() current index\endlink - and a \link current() current item\endlink. The first item corresponds - to index 0. The current index is -1 if the current item is null. - - QList has several member functions for traversing the list, but using - a QListIterator can be more practical. Multiple list iterators may - traverse the same list, independent of each other and independent of - the current list item. - - In the example above, we make the call setAutoDelete(TRUE). - Enabling auto-deletion tells the list to delete items that are removed - from the list. The default is to not delete items when they are - removed, but that would cause a memory leak in our example since we have - no other references to the list items. - - List items are stored as \c void* in an internal QLNode, which also - holds pointers to the next and previous list items. The functions - currentNode(), removeNode() and takeNode() operate directly on the - QLNode, but they should be used with care. - - When inserting an item into a list, only the pointer is copied, not the - item itself. This is called a shallow copy. It is possible to make the - list copy all of the item's data (known as a deep copy) when an item is - inserted. insert(), inSort() and append() call the virtual function - QCollection::newItem() for the item to be inserted. - Inherit a list and reimplement it if you want deep copies. - - When removing an item from a list, the virtual function - QCollection::deleteItem() is called. QList's default implementation - is to delete the item if auto-deletion is enabled. - - The virtual function QGList::compareItems() can be reimplemented to - compare two list items. This function is called from all list functions - that need to compare list items, for instance remove(const type*). - If you only want to deal with pointers, there are functions that - compare pointers instead, for instance removeRef(const type*). - These functions are somewhat faster than those that call compareItems(). - - The QStrList class in qstrlist.h is a list of \c char*. QStrList is - a good example of a list that reimplements newItem(), deleteItem() and - compareItems() - - \sa QListIterator, \link collection.html Collection Classes\endlink -*/ - - -/*! - \fn QList::QList() - Constructs an empty list. -*/ - -/*! - \fn QList::QList( const QList<type> &list ) - Constructs a copy of \e list. - - Each item in \e list is \link append() appended\endlink to this list. - Only the pointers are copied (shallow copy). -*/ - -/*! - \fn QList::~QList() - Removes all items from the list and destroys the list. - - All list iterators that access this list will be reset. - - \sa setAutoDelete() -*/ - -/*! - \fn QList<type> &QList::operator=(const QList<type> &list) - Assigns \e list to this list and returns a reference to this list. - - This list is first cleared, then each item in \e list is - \link append() appended\endlink to this list. Only the pointers are copied - (shallow copy), unless newItem() has been reimplemented(). -*/ - -/*! - \fn bool QList::operator==(const QList<type> &list ) const - - Compares this list with \a list. Returns TRUE if the lists - contain the same data, else FALSE. -*/ - -/*! - \fn uint QList::count() const - Returns the number of items in the list. - \sa isEmpty() -*/ - -/*! - \fn void QList::sort() - - Sorts the list by the result of the virtual compareItems() function. - - The Heap-Sort algorithm is used for sorting. It sorts n items with - O(n*log n) compares. This is the asymptotic optimal solution of the - sorting problem. - - If the items in your list support operator< and operator== then you - might be better off with QSortedList since it implements the - compareItems() function for you using these two operators. - - \sa inSort() -*/ - -/*! - \fn bool QList::isEmpty() const - Returns TRUE if the list is empty, i.e. count() == 0. Returns FALSE - otherwise. - \sa count() -*/ - -/*! - \fn bool QList::insert( uint index, const type *item ) - Inserts the \e item at the position \e index in the list. - - Returns TRUE if successful, or FALSE if \e index is out of range. - The valid range is <code>0 .. count()</code> inclusive. - The item is appended if \e index == count(). - - The inserted item becomes the current list item. - - The \e item must not be a null pointer. - - \sa append(), current() -*/ - -/*! - \fn void QList::inSort( const type *item ) - Inserts the \e item at its sorted position in the list. - - The sort order depends on the virtual QGList::compareItems() function. - All items must be inserted with inSort() to maintain the sorting order. - - The inserted item becomes the current list item. - - The \e item must not be a null pointer. - - Please note that inSort is slow. If you want to insert lots of items - in a list and sort after inserting then you should use sort(). - inSort() takes up to O(n) compares. That means inserting n items in - your list will need O(n^2) compares while sort() only needs O(n*logn) - for the same task. So you inSort() only if you already have a pre-sorted - list and want to insert only few additional items. - - \sa insert(), QGList::compareItems(), current(), sort() -*/ - -/*! - \fn void QList::append( const type *item ) - Inserts the \e item at the end of the list. - - The inserted item becomes the current list item. - This is equivalent to \c insert(count(),item). - - - The \e item must not be a null pointer. - - \sa insert(), current(), prepend() -*/ - -/*! - \fn void QList::prepend( const type *item ) - - Inserts the \e item at the start of the list. - - The inserted item becomes the current list item. - This is equivalent to \c insert(0,item). - - The \e item must not be a null pointer. - - \sa append(), insert(), current() -*/ - -/*! - \fn bool QList::remove( uint index ) - Removes the item at position \e index in the list. - - Returns TRUE if successful, or FALSE if \e index is out of range. - The valid range is <code>0 .. (count() - 1)</code> inclusive. - - The removed item is deleted if \link QCollection::setAutoDelete() - auto-deletion\endlink is enabled. - - The item after the removed item becomes the new current list item if - the removed item is not the last item in the list. If the last item - is removed, the new last item becomes the current item in Qt 2.x. - In 3.0, the current item will be set to null. The current item is - set to null if the list becomes empty. - - All list iterators that refer to the removed item will be set to point - to the new current item. - - \sa take(), clear(), setAutoDelete(), current() removeRef() -*/ - -/*! - \fn bool QList::remove() - Removes the current list item. - - Returns TRUE if successful, or FALSE if the current item is null. - - The removed item is deleted if \link QCollection::setAutoDelete() - auto-deletion\endlink is enabled. - - The item after the removed item becomes the new current list item if - the removed item is not the last item in the list. If the last item - is removed, the new last item becomes the current item in Qt 2.x. - In 3.0, the current item will be set to null. The current item is - set to null if the list becomes empty. - - All list iterators that refer to the removed item will be set to point - to the new current item. - - \sa take(), clear(), setAutoDelete(), current() removeRef() -*/ - -/*! - \fn bool QList::remove( const type *item ) - Removes the first occurrence of \e item from the list. - - Returns TRUE if successful, or FALSE if the item could not be found in the - list. - - The removed item is deleted if \link QCollection::setAutoDelete() - auto-deletion\endlink is enabled. - - The compareItems() function is called when searching for the item - in the list. If compareItems() is not reimplemented, it is more - efficient to call removeRef(). - - The item after the removed item becomes the new current list item if - the removed item is not the last item in the list. If the last item - is removed, the new last item becomes the current item in Qt 2.x. - In 3.0, the current item will be set to null. The current item is - set to null if the list becomes empty. - - All list iterators that refer to the removed item will be set to point - to the new current item. - - \sa removeRef(), take(), clear(), setAutoDelete(), compareItems(), current() -*/ - -/*! - \fn bool QList::removeRef( const type *item ) - Removes the first occurrence of \e item from the list. - - Returns TRUE if successful, or FALSE if the item cannot be found in the - list. - - The removed item is deleted if \link QCollection::setAutoDelete() - auto-deletion\endlink is enabled. - - The list is scanned until the pointer \e item is found. It is removed - if it is found. - - Equivalent to: - \code - if ( list.findRef(item) != -1 ) - list.remove(); - \endcode - - The item after the removed item becomes the new current list item if - the removed item is not the last item in the list. If the last item - is removed, the new last item becomes the current item in Qt 2.x. - In 3.0, the current item will be set to null. The current item is - set to null if the list becomes empty. - - All list iterators that refer to the removed item will be set to point - to the new current item. - - \sa remove(), clear(), setAutoDelete(), current() -*/ - -/*! - \fn void QList::removeNode( QLNode *node ) - Removes the \e node from the list. - - This node must exist in the list, otherwise the program may crash. - - The removed item is deleted if \link QCollection::setAutoDelete() - auto-deletion\endlink is enabled. - - The first item in the list will become the new current list item. - The current item is set to null if the list becomes empty. - - All list iterators that refer to the removed item will be set to point to - the item succeeding this item, or the preceding item if the removed item - was the last item. - - \warning Do not call this function unless you are an expert. - - \sa takeNode(), currentNode() remove() removeRef() -*/ - -/*! - \fn bool QList::removeFirst() - Removes the first item from the list. - Returns TRUE if successful, or FALSE if the list is empty. - - The removed item is deleted if \link QCollection::setAutoDelete() - auto-deletion\endlink is enabled. - - The first item in the list becomes the new current list item. - The current item is set to null if the list becomes empty. - - All list iterators that refer to the removed item will be set to point - to the new current item. - - \sa removeLast(), setAutoDelete(), current() remove() -*/ - -/*! - \fn bool QList::removeLast() - Removes the last item from the list. - Returns TRUE if successful, or FALSE if the list is empty. - - The removed item is deleted if \link QCollection::setAutoDelete() - auto-deletion\endlink is enabled. - - The last item in the list becomes the new current list item. - The current item is set to null if the list becomes empty. - - All list iterators that refer to the removed item will be set to point - to the new current item. - - \sa removeFirst(), setAutoDelete(), current() -*/ - -/*! - \fn type *QList::take( uint index ) - Takes the item at position \e index out of the list without - deleting it (even if \link QCollection::setAutoDelete() - auto-deletion\endlink is enabled). - - Returns a pointer to the item taken out of the list, or null if - the index is out of range. - The valid range is <code>0 .. (count() - 1)</code> inclusive. - - The item after the taken item becomes the new current list item if - the taken item is not the last item in the list. If the last item - is taken, the new last item becomes the current item in Qt 2.x. In - 3.0, the current item will be set to null. The current item is set - to null if the list becomes empty. - - All list iterators that refer to the taken item will be set to point to - the new current item. - - \sa remove(), clear(), current() -*/ - -/*! - \fn type *QList::take() - Takes the current item out of the list without deleting it (even if - \link QCollection::setAutoDelete() auto-deletion\endlink is enabled). - Returns a pointer to the item taken out of the list, or null if - the current item is null. - - The item after the taken item becomes the new current list item if - the taken item is not the last item in the list. If the last item - is taken, the new last item becomes the current item in Qt 2.x. In - 3.0, the current item will be set to null. The current item is set - to null if the list becomes empty. - - All list iterators that refer to the taken item will be set to point to - the new current item. - - \sa remove(), clear(), current() -*/ - -/*! - \fn type *QList::takeNode( QLNode *node ) - Takes the \e node out of the list without deleting its item (even if - \link QCollection::setAutoDelete() auto-deletion\endlink is enabled). - Returns a pointer to the item taken out of the list. - - This node must exist in the list, otherwise the program may crash. - - The first item in the list becomes the new current list item. - - All list iterators that refer to the taken item will be set to point to - the item succeeding this item, or the preceding item if the taken item - was the last item. - - \warning Do not call this function unless you are an expert. - - \sa removeNode(), currentNode() -*/ - -/*! - \fn void QList::clear() - Removes all items from the list. - - The removed items are deleted if \link QCollection::setAutoDelete() - auto-deletion\endlink is enabled. - - All list iterators that access this list will be reset. - - \sa remove(), take(), setAutoDelete() -*/ - -/*! - \fn int QList::find( const type *item ) - Finds the first occurrence of \e item in the list. - - If the item is found, the list sets the current item to point to - the found item and returns the index of this item. - If the item is not found, the list sets the current item to null, - the current index to -1 and returns -1. - - The compareItems() function is called when searching for the item - in the list. If compareItems() is not reimplemented, it is more - efficient to call findRef(). - - \sa findNext(), findRef(), compareItems(), current() -*/ - -/*! - \fn int QList::findNext( const type *item ) - Finds the next occurrence of \e item in the list, starting from - the current list item. - - If the item is found, the list sets the current item to point to - the found item and returns the index of this item. - If the item is not found, the list sets the current item to null, - the current index to -1 and returns -1. - - The compareItems() function is called when searching for the item - in the list. If compareItems() is not reimplemented, it is more - efficient to call findNextRef(). - - \sa find(), findNextRef(), compareItems(), current() -*/ - -/*! - \fn int QList::findRef( const type *item ) - Finds the first occurrence of \e item in the list. - - If the item is found, the list sets the current item to point to - the found item and returns the index of this item. - If the item is not found, the list sets the current item to null, - the current index to -1 and returns -1. - - Calling this function is must faster than find(), because find() - compares \e item with each list item using compareItems(). - This function only compares the pointers. - - \sa findNextRef(), find(), current() -*/ - -/*! - \fn int QList::findNextRef( const type *item ) - Finds the next occurrence of \e item in the list, starting from the - current list item. - - If the item is found, the list sets the current item to point to - the found item and returns the index of this item. - If the item is not found, the list sets the current item to null, - the current index to -1 and returns -1. - - Calling this function is must faster than findNext(), because findNext() - compares \e item with each list item using compareItems(). - This function only compares the pointers. - - \sa findRef(), findNext(), current() -*/ - -/*! - \fn uint QList::contains( const type *item ) const - Counts and returns the number of occurrences of \e item in the list. - - The compareItems() function is called when looking for the \e item - in the list. If compareItems() is not reimplemented, it is more - efficient to call containsRef(). - - Does not affect the current list item. - - \sa containsRef(), compareItems() -*/ - -/*! - \fn uint QList::containsRef( const type *item ) const - Counts and returns the number of occurrences of \e item in the list. - - Calling this function is must faster than contains(), because contains() - compares \e item with each list item using compareItems(). - This function only compares the pointers. - - Does not affect the current list item. - - \sa contains() -*/ - -/*! - \fn type *QList::at( uint index ) - Returns a pointer to the item at position \e index in the list, or - null if the index is out of range. - - Sets the current list item to this item if \e index is valid. - The valid range is <code>0 .. (count() - 1)</code> inclusive. - - This function is very efficient. It starts scanning from the first - item, last item or current item, whichever is closest to \e index. - - \sa current() -*/ - -/*! - \fn int QList::at() const - Returns the index of the current list item. The returned value is -1 - if the current item is null. - \sa current() -*/ - -/*! - \fn type *QList::current() const - Returns a pointer to the current list item. The current item may be - null (implies that the current index is -1). - \sa at() -*/ - -/*! - \fn QLNode *QList::currentNode() const - Returns a pointer to the current list node. - - The node can be kept and removed later using removeNode(). - The advantage is that the item can be removed directly without - searching the list. - - \warning Do not call this function unless you are an expert. - - \sa removeNode(), takeNode(), current() -*/ - -/*! - \fn type *QList::getFirst() const - Returns a pointer to the first item in the list, or null if the - list is empty. - - Does not affect the current list item. - - \sa first(), getLast() -*/ - -/*! - \fn type *QList::getLast() const - Returns a pointer to the last item in the list, or null if the - list is empty. - - Does not affect the current list item. - - \sa last(), getFirst() -*/ - -/*! - \fn type *QList::first() - Returns a pointer to the first item in the list and makes this the - current list item, or null if the list is empty. - \sa getFirst(), last(), next(), prev(), current() -*/ - -/*! - \fn type *QList::last() - Returns a pointer to the last item in the list and makes this the - current list item, or null if the list is empty. - \sa getLast(), first(), next(), prev(), current() -*/ - -/*! - \fn type *QList::next() - Returns a pointer to the item succeeding the current item. - Returns null if the current item is null or equal to the last item. - - Makes the succeeding item current. If the current item before this - function call was the last item, the current item will be set to null. - If the current item was null, this function does nothing. - - \sa first(), last(), prev(), current() -*/ - -/*! - \fn type *QList::prev() - Returns a pointer to the item preceding the current item. - Returns null if the current item is null or equal to the first item. - - Makes the preceding item current. If the current item before this - function call was the first item, the current item will be set to null. - If the current item was null, this function does nothing. - - \sa first(), last(), next(), current() -*/ - -/***************************************************************************** - QListIterator documentation - *****************************************************************************/ - -/*! - \class QListIterator qlist.h - \brief The QListIterator class provides an iterator for QList collections. - - \ingroup collection - \ingroup tools - - Define a template instance QListIterator\<X\> to create a list iterator - that operates on QList\<X\> (list of X*). - - Example: - \code - #include <qlist.h> - #include <qstring.h> - #include <stdio.h> - - class Employee - { - public: - Employee( const char *name, int salary ) { n=name; s=salary; } - const char *name() const { return n; } - int salary() const { return s; } - private: - QString n; - int s; - }; - - void main() - { - QList<Employee> list; // list of pointers to Employee - list.setAutoDelete( TRUE ); // delete items when they are removed - - list.append( new Employee("Bill", 50000) ); - list.append( new Employee("Steve",80000) ); - list.append( new Employee("Ron", 60000) ); - - QListIterator<Employee> it(list); // iterator for employee list - for ( ; it.current(); ++it ) { - Employee *emp = it.current(); - printf( "%s earns %d\n", emp->name().latin1(), emp->salary() ); - } - } - \endcode - - Program output: - \code - Bill earns 50000 - Steve earns 80000 - Ron earns 60000 - \endcode - - Although QList has member functions to traverse the doubly linked list - structure, using a list iterator is a much more robust way of traversing - the list, because multiple list iterators can operate on the same list, - independent of each other and independent of the QList's current item. - An iterator has its own current list item and can get the next and - previous list items. It can only traverse the list, never modify it. - - A QList knows about all list iterators that are operating on the list. - When an item is removed from the list, the list update all iterators - that are pointing the removed item to point to the new current list item. - - Example: - \code - #include <qlist.h> - #include <qstring.h> - #include <stdio.h> - - class Employee - { - ... // same as above - }; - - void main() - { - QList<Employee> list; // list of pointers to Employee - list.setAutoDelete( TRUE ); // delete items when they are removed - - list.append( new Employee("Bill", 50000) ); - list.append( new Employee("Steve",80000) ); - list.append( new Employee("Ron", 60000) ); - - QListIterator<Employee> it(list); - - list.at( 1 ); // current list item: "Steve" - it.toLast(); // it: "Ron" - --it; // it: "Steve" - - // Now, both the list and the iterator are referring the same item - - list.remove(); - printf( "%s\n", it.current()->name().latin1() ); - } - \endcode - - Program output: - \code - Ron - \endcode - - \sa QList, \link collection.html collection classes\endlink -*/ - -/*! - \fn QListIterator::QListIterator( const QList<type> &list ) - Constructs an iterator for \e list. The current iterator item is - set to point on the first item in the \e list. -*/ - -/*! - \fn QListIterator::~QListIterator() - Destroys the iterator. -*/ - -/*! - \fn uint QListIterator::count() const - Returns the number of items in the list this iterator operates on. - \sa isEmpty() -*/ - -/*! - \fn bool QListIterator::isEmpty() const - Returns TRUE if the list is empty, i.e. count() == 0, otherwise FALSE. - \sa count() -*/ - -/*! - \fn bool QListIterator::atFirst() const - Returns TRUE if the current iterator item is the first list item, otherwise - FALSE. - \sa toFirst(), atLast() -*/ - -/*! - \fn bool QListIterator::atLast() const - Returns TRUE if the current iterator item is the last list item, otherwise - FALSE. - \sa toLast(), atFirst() -*/ - -/*! - \fn type *QListIterator::toFirst() - Sets the current iterator item to point to the first list item and returns - a pointer to the item. Sets the current item to null and returns null - if the list is empty. - \sa toLast(), atFirst() -*/ - -/*! - \fn type *QListIterator::toLast() - Sets the current iterator item to point to the last list item and returns - a pointer to the item. Sets the current item to null and returns null - if the list is empty. - \sa toFirst(), atLast() -*/ - -/*! - \fn QListIterator::operator type *() const - Cast operator. Returns a pointer to the current iterator item. - Same as current(). -*/ - -/*! - \fn type *QListIterator::operator*() - Asterisk operator. Returns a pointer to the current iterator item. - Same as current(). -*/ - -/*! - \fn type *QListIterator::current() const - Returns a pointer to the current iterator item. -*/ - -/*! - \fn type *QListIterator::operator()() - Makes the succeeding item current and returns the original current item. - - If the current iterator item was the last item in the list or if it was - null, null is returned. -*/ - -/*! - \fn char *QStrListIterator::operator()() - Makes the succeeding item current and returns the original current item. - - If the current iterator item was the last item in the list or if it was - null, null is returned. -*/ - -/*! - \fn type *QListIterator::operator++() - Prefix ++ makes the succeeding item current and returns the new current - item. - - If the current iterator item was the last item in the list or if it was - null, null is returned. -*/ - -/*! - \fn type *QListIterator::operator+=( uint jump ) - Sets the current item to the item \e jump positions after the current item, - and returns a pointer to that item. - - If that item is beyond the last item or if the dictionary is empty, - it sets the current item to null and returns null -*/ - -/*! - \fn type *QListIterator::operator--() - Prefix -- makes the preceding item current and returns the new current - item. - - If the current iterator item was the first item in the list or if it was - null, null is returned. -*/ - -/*! - \fn type *QListIterator::operator-=( uint jump ) - Returns the item \e jump positions before the current item, or null if - it is beyond the first item. Makes this the current item. -*/ - -/*! - \fn QListIterator<type>& QListIterator::operator=( const QListIterator<type> &it ) - Assignment. Makes a copy of the iterator \a it and returns a reference - to this iterator. -*/ - - -/***************************************************************************** - QStrList documentation - *****************************************************************************/ - -//typedef QList<char> QStrList - -/*! - \class QStrList qstrlist.h - \brief The QStrList class provides a doubly linked list of \c char*. - - \ingroup collection - \ingroup tools - - This class is a QList\<char\> instance (a list of char*). - - QStrList can make deep or shallow copies of the strings that are inserted. - - A deep copy means to allocate space for the string and then copy the string - data into it. A shallow copy is just a copy of the pointer value and not - the string data. - - The disadvantage with shallow copies is that since a pointer can only - be deleted once, the program must put all strings in a central place and - know when it is safe to delete them (i.e. when the strings are no longer - referenced by other parts of the program). This can make the program - more complex. The advantage of shallow copies is that shallow copies - consume far less memory than deep copies. It is also much faster - to copy a pointer (typically 4 or 8 bytes) than to copy string data. - - A QStrList that operates on deep copies will by default turn on - auto-deletion (see setAutoDelete()). Thus, by default, QStrList will - deallocate any string copies it allocates. - - The virtual compareItems() function is reimplemented and does a case - sensitive string comparison. The inSort() function will insert - strings in a sorted order. - - The QStrListIterator class is an iterator for QStrList. -*/ - -/*! - \fn QStrList::QStrList( bool deepCopies ) - Constructs an empty list of strings. Will make deep copies of all inserted - strings if \e deepCopies is TRUE, or uses shallow copies if \e deepCopies - is FALSE. -*/ - -/*! - \fn QStrList::QStrList( const QStrList &list ) - Constructs a copy of \e list. - - If \e list has deep copies, this list will also get deep copies. - Only the pointers are copied (shallow copy) if the other list does not - use deep copies. -*/ - -/*! - \fn QStrList::~QStrList() - Destroys the list. All strings are removed. -*/ - -/*! - \fn QStrList& QStrList::operator=( const QStrList& list ) - Assigns \e list to this list and returns a reference to this list. - - If \e list has deep copies, this list will also get deep copies. - Only the pointers are copied (shallow copy) if the other list does not - use deep copies. -*/ - - -/***************************************************************************** - QStrIList documentation - *****************************************************************************/ - -/*! - \class QStrIList qstrlist.h - \brief The QStrIList class provides a doubly linked list of \c char* with -case insensitive compare. - - \ingroup collection - \ingroup tools - - This class is a QList\<char\> instance (a list of char*). - - QStrIList is similar to QStrList except that it is case insensitive. - The virtual compareItems() function is reimplemented and does a - case insensitive string comparison. - The inSort() function will insert strings in a sorted order. - - The QStrListIterator class is an iterator for QStrList. -*/ - -/*! - \fn QStrIList::QStrIList( bool deepCopies ) - Constructs a list of strings. Will make deep copies of all inserted - strings if \e deepCopies is TRUE, or uses shallow copies if \e deepCopies - is FALSE. -*/ - -/*! - \fn QStrIList::~QStrIList() - Destroys the list. All strings are removed. -*/ - - -/***************************************************************************** - QStrListIterator documentation - *****************************************************************************/ - -/*! - \class QStrListIterator qstrlist.h - \brief The QStrListIterator class is an iterator for the QStrList and QStrIList classes. - - \ingroup tools - - This class is a QListIterator\<char\> instance. - It can traverse the strings in the QStrList and QStrIList classes. -*/ diff --git a/qtools/qlist.h b/qtools/qlist.h deleted file mode 100644 index eaaa674..0000000 --- a/qtools/qlist.h +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************** -** -** -** 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. -** -**********************************************************************/ - -/* This is a stripped version of the original QList, which has been renamed to - QInternalList. This implementation doesn't expose the current node and index, - nor direct access to the list nodes. - This makes it possible to have more constant methods. It also provides - a typesafe method to compare elements called compareValues() and a typesafe - methods to create and delete elements called newValue() and deleteValue(). - */ - -#ifndef QLIST_H -#define QLIST_H - -#ifndef QT_H -#include "qglist.h" -#endif // QT_H - - -template<class type> class Q_EXPORT QList : private QGList -{ -public: - QList() {} - QList( const QList<type> &l ) : QGList(l) {} - ~QList() { clear(); } - QList<type> &operator=(const QList<type> &l) - { return (QList<type>&)QGList::operator=(l); } - bool operator==( const QList<type> &list ) const - { return QGList::operator==( list ); } - - // capacity - uint count() const { return QGList::count(); } - bool isEmpty() const { return QGList::count() == 0; } - - // modifiers add - 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); } - - // modifiers remove - bool remove( uint i ) { return QGList::removeAt(i); } - bool remove( const type *d ) { return QGList::remove((QCollection::Item)d); } - bool removeRef( const type *d ) { return QGList::removeRef((QCollection::Item)d); } - bool removeFirst() { return QGList::removeFirst(); } - bool removeLast() { return QGList::removeLast(); } - type *take( uint i ) { return (type *)QGList::takeAt(i); } - void clear() { QGList::clear(); } - - // operations - void sort() { QGList::sort(); } - - // search - int find( const type *d ) const { return const_cast<QList<type>*>(this)->QGList::find((QCollection::Item)d); } - int findRef( const type *d ) const { return const_cast<QList<type>*>(this)->QGList::findRef((QCollection::Item)d); } - uint contains( const type *d ) const { return QGList::contains((QCollection::Item)d); } - uint containsRef( const type *d ) const { return QGList::containsRef((QCollection::Item)d); } - - // element access - type *at( uint i ) const { return (type *)const_cast<QList<type>*>(this)->QGList::at(i); } - type *getFirst() const { return (type *)QGList::cfirst(); } - type *getLast() const { return (type *)QGList::clast(); } - - // ownership - void setAutoDelete( bool enable ) { QGList::setAutoDelete(enable); } - bool autoDelete() const { return QGList::autoDelete(); } - -private: - // new to be reimplemented methods - virtual int compareValues(const type *t1,const type *t2) const - { return const_cast<QList<type>*>(this)->QGList::compareItems((QCollection::Item)t1,(QCollection::Item)t2); } - virtual type *newValue(type *item) const - { return item; } - virtual void deleteValue(type *item) const - { if (del_item) delete item; } - - // reimplemented methods - virtual Item newItem( Item item) - { return (Item)newValue((type*)item); } - virtual void deleteItem( QCollection::Item item ) - { deleteValue((type *)item); } - virtual int compareItems(QCollection::Item i1,QCollection::Item i2) - { return compareValues((const type*)i1,(const type*)i2); } -}; - -#if defined(Q_DELETING_VOID_UNDEFINED) -template<> inline void QList<void>::deleteValue(void *) const -{ -} -#endif - - -template<class type> class Q_EXPORT QListIterator : public QGListIterator -{ -public: - QListIterator(const QList<type> &l) :QGListIterator((QGList &)l) {} - ~QListIterator() {} - 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);} - QListIterator<type>& operator=(const QListIterator<type>&it) - { QGListIterator::operator=(it); return *this; } -}; - - -#endif // QLIST_H diff --git a/qtools/qmap.cpp b/qtools/qmap.cpp index 1d2510a..bb69bf0 100644 --- a/qtools/qmap.cpp +++ b/qtools/qmap.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -** +** ** ** Implementation of QMap ** @@ -35,7 +35,7 @@ ** **********************************************************************/ -#include "qmap.h" +#include "qmap_p.h" typedef QMapNodeBase* NodePtr; typedef QMapNodeBase Node; @@ -105,7 +105,7 @@ void QMapPrivateBase::rebalance( NodePtr x, NodePtr& root) x->parent->parent->color = Node::Red; x = x->parent->parent; } else { - if (x == x->parent->left) { + if (x == x->parent->left) { x = x->parent; rotateRight( x, root ); } @@ -140,7 +140,7 @@ NodePtr QMapPrivateBase::removeAndRebalance( NodePtr z, NodePtr& root, } } if (y != z) { - z->left->parent = y; + z->left->parent = y; y->left = z->left; if (y != z->right) { x_parent = y->parent; @@ -150,13 +150,13 @@ NodePtr QMapPrivateBase::removeAndRebalance( NodePtr z, NodePtr& root, y->right = z->right; z->right->parent = y; } else { - x_parent = y; + x_parent = y; } if (root == z) root = y; else if (z->parent->left == z) z->parent->left = y; - else + else z->parent->right = y; y->parent = z->parent; // Swap the colors @@ -164,10 +164,10 @@ NodePtr QMapPrivateBase::removeAndRebalance( NodePtr z, NodePtr& root, y->color = z->color; z->color = c; y = z; - } else { + } else { x_parent = y->parent; if (x) - x->parent = y->parent; + x->parent = y->parent; if (root == z) root = x; else if (z->parent->left == z) @@ -182,12 +182,12 @@ NodePtr QMapPrivateBase::removeAndRebalance( NodePtr z, NodePtr& root, } if (rightmost == z) { if (z->left == 0) - rightmost = z->parent; + rightmost = z->parent; else rightmost = x->maximum(); } } - if (y->color != Node::Red) { + if (y->color != Node::Red) { while (x != root && (x == 0 || x->color == Node::Black)) { if (x == x_parent->left) { NodePtr w = x_parent->right; @@ -232,7 +232,7 @@ NodePtr QMapPrivateBase::removeAndRebalance( NodePtr z, NodePtr& root, x_parent = x_parent->parent; } else { if (w->left == 0 || w->left->color == Node::Black) { - if (w->right) + if (w->right) w->right->color = Node::Black; w->color = Node::Red; rotateLeft(w, root); diff --git a/qtools/qmap.h b/qtools/qmap_p.h index 0031e0d..0031e0d 100644 --- a/qtools/qmap.h +++ b/qtools/qmap_p.h diff --git a/qtools/qqueue.h b/qtools/qqueue.h deleted file mode 100644 index 94bc130..0000000 --- a/qtools/qqueue.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** -** Definition of QQueue template/macro class -** -** Created : 920917 -** -** 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 QQUEUE_H -#define QQUEUE_H - -#ifndef QT_H -#include "qglist.h" -#endif // QT_H - - -template<class type> class QQueue : private QGList -{ -public: - QQueue() {} - QQueue( const QQueue<type> &q ) : QGList(q) {} - ~QQueue() { clear(); } - QQueue<type>& operator=(const QQueue<type> &q) - { return (QQueue<type>&)QGList::operator=(q); } - bool autoDelete() const { return QCollection::autoDelete(); } - void setAutoDelete( bool del ) { QCollection::setAutoDelete(del); } - uint count() const { return QGList::count(); } - bool isEmpty() const { return QGList::count() == 0; } - void enqueue( const type *d ) { QGList::append(Item(d)); } - type *dequeue() { return (type *)QGList::takeFirst();} - bool remove() { return QGList::removeFirst(); } - void clear() { QGList::clear(); } - type *head() const { return (type *)QGList::cfirst(); } - operator type *() const { return (type *)QGList::cfirst(); } - type *current() const { return (type *)QGList::cfirst(); } -private: - void deleteItem( Item d ) { if ( del_item ) delete (type *)d; } -}; - - -#endif // QQUEUE_H diff --git a/qtools/qsortedlist.doc b/qtools/qsortedlist.doc deleted file mode 100644 index 6f16f19..0000000 --- a/qtools/qsortedlist.doc +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** -** QSortedList documentation -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part 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. -** -**********************************************************************/ - - -/***************************************************************************** - QSortedList documentation - *****************************************************************************/ - -/*! - \class QSortedList qsortedlist.h - \brief The QSortedList class provides a list sorted by operator< and operator== - - \ingroup collection - \ingroup tools - - If you want to sort a QList you have to reimplement the - QGList::compareItems() method. If the elements of your list support - operator<() and operator==() then you can use QSortedList instead. - Its compareItems() calls operator<() and operator==() and returns an - appropriate result. - - Otherwise, this is as QList. - - \sa QList, \link collection.html Collection Classes\endlink -*/ - - -/*! - \fn QSortedList::QSortedList() - Constructs an empty list. -*/ - -/*! - \fn QSortedList::QSortedList( const QSortedList<type> &list ) - Constructs a copy of \e list. - - Each item in \e list is copied to this new list. -*/ - -/*! - \fn QSortedList::~QSortedList() - Removes all items from the list and destroys the list. - - All list iterators that access this list will be reset. -*/ - -/*! - \fn QSortedList<type>& QSortedList::operator=(const QSortedList<type>& list) - Assigns \e list to this list and returns a reference to this list. - - This list is first cleared, then each item in \e list is - appended to this list. Only the pointers are copied - (shallow copy), unless newItem() has been reimplemented(). -*/ - -/*! - \fn int QSortedList::compareItems( QCollection::Item s1, QCollection::Item s2 ) - - \reimp - - This reimplementation uses operator< and operator== to compare. -*/ diff --git a/qtools/qsortedlist.h b/qtools/qsortedlist.h deleted file mode 100644 index aeadd90..0000000 --- a/qtools/qsortedlist.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** -** 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 QSORTEDLIST_H -#define QSORTEDLIST_H - -#ifndef QT_H -#include "qlist.h" -#endif // QT_H - - -template<class type> class Q_EXPORT QSortedList : public QList<type> -{ -public: - QSortedList() {} - QSortedList( const QSortedList<type> &l ) : QList<type>(l) {} - ~QSortedList() { clear(); } - QSortedList<type> &operator=(const QSortedList<type> &l) - { return (QSortedList<type>&)QList<type>::operator=(l); } - - virtual int compareItems( QCollection::Item s1, QCollection::Item s2 ) - { if ( *((type*)s1) == *((type*)s2) ) return 0; return ( *((type*)s1) < *((type*)s2) ? -1 : 1 ); } -}; - -#endif diff --git a/qtools/qstack.doc b/qtools/qstack.doc deleted file mode 100644 index ece1e2a..0000000 --- a/qtools/qstack.doc +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -** -** -** QStack class documentation -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part 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. -** -**********************************************************************/ - - -/***************************************************************************** - QStack documentation - *****************************************************************************/ - -/*! - \class QStack qstack.h - \brief The QStack class is a template class that provides a stack. - - \ingroup collection - \ingroup tools - - QStack is implemented as a template class. Define a template - instance QStack\<X\> to create a stack that operates on pointers to - X, or X*. - - A stack is a Last In, First Out (LIFO) structure. Items are added to - the top of the stack with push() and retrieved from the top - with pop(). - - \sa \link collection.html Collection Classes\endlink -*/ - -/*! \fn QStack::QStack () - Creates and empty stack. -*/ - -/*! \fn QStack::QStack (const QStack<type>& s) - Creates a stack by making a shallow copy of another stack. -*/ - -/*! \fn QStack::~QStack () - Destroys the stack. All items will be deleted if autoDelete() is TRUE. -*/ - -/*! \fn QStack<type>& QStack::operator= (const QStack<type>& s) - Sets the contents of this stack by making a shallow copy of another stack. - Elements currently in this stack will be deleted if autoDelete() is TRUE. -*/ - -/*! \fn bool QStack::isEmpty () const - Returns TRUE is the stack contains no elements to be \link pop() popped\endlink. -*/ - -/*! \fn void QStack::push (const type* d) - Adds an element to the top of the stack. Last in, first out. -*/ - -/*! \fn type* QStack::pop () - Removes the top item from the stack and returns it. -*/ - -/*! \fn bool QStack::remove () - Removes the top item from the stack and deletes it if - autoDelete() is TRUE. Returns TRUE if there was an item to pop. - - \sa clear() -*/ - -/*! \fn void QStack::clear() - Removes all items from the stack, deleting them if - autoDelete() is TRUE. - - \sa remove() -*/ - -/*! \fn uint QStack::count() const - Returns the number of items in the stack. - - \sa isEmpty() -*/ - -/*! \fn type* QStack::top () const - Returns a reference to the top item on the stack (most recently pushed). - The stack is not changed. -*/ - -/*! \fn QStack::operator type* ()const - Returns a reference to the top item on the stack (most recently pushed). - The stack is not changed. -*/ - -/*! \fn type* QStack::current () const - Returns a reference to the top item on the stack (most recently pushed). - The stack is not changed. -*/ - -/*! \fn bool QStack::autoDelete() const - - The same as QCollection::autoDelete(). - - \sa setAutoDelete() -*/ - -/*! \fn void QStack::setAutoDelete( bool enable ) - - The same as QCollection::setAutoDelete(). - - \sa autoDelete() -*/ diff --git a/qtools/qstack.h b/qtools/qstack_p.h index c84d8d2..c84d8d2 100644 --- a/qtools/qstack.h +++ b/qtools/qstack_p.h diff --git a/qtools/qstring.cpp b/qtools/qstring.cpp index 3d57839..a964aca 100644 --- a/qtools/qstring.cpp +++ b/qtools/qstring.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -** +** ** ** Implementation of the QString class and related Unicode functions ** @@ -45,7 +45,7 @@ #include "qregexp.h" #include "qdatastream.h" #include "qtextcodec.h" -#include "qstack.h" +#include "qstack_p.h" #include <stdio.h> #include <stdlib.h> #include <stdarg.h> @@ -12745,7 +12745,7 @@ bool QString::findArg(int& pos, int& len) const arbitrary list of arguments. The format string supports all the escape sequences of printf() in the standard C library. - The %s escape sequence expects a utf8() encoded string. + The %s escape sequence expects a utf8() encoded string. The format string \e cformat is expected to be in latin1. If you need a unicode format string, use QString::arg() instead. For typesafe string building, with full Unicode support, you can use QTextOStream diff --git a/qtools/qstringlist.h b/qtools/qstringlist.h index 3f9fbb2..5e1e258 100644 --- a/qtools/qstringlist.h +++ b/qtools/qstringlist.h @@ -1,5 +1,5 @@ /**************************************************************************** -** +** ** ** Definition of QStringList class ** @@ -39,7 +39,7 @@ #define QSTRINGLIST_H #ifndef QT_H -#include "qvaluelist.h" +#include "qvaluelist_p.h" #include "qstring.h" #include "qregexp.h" #endif // QT_H diff --git a/qtools/qstrvec.h b/qtools/qstrvec.h deleted file mode 100644 index 15d3abb..0000000 --- a/qtools/qstrvec.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** -** Definition of QStrVec and QStrIVec classes -** -** Created : 931203 -** -** 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 QSTRVEC_H -#define QSTRVEC_H - -#ifndef QT_H -#include "qstring.h" -#include "qvector.h" -#include "qdatastream.h" -#endif // QT_H - - -#if defined(Q_TEMPLATEDLL) -template class Q_EXPORT QVector<char> -#endif - -typedef QVector<char> QStrVecBase; - - -class Q_EXPORT QStrVec : public QStrVecBase -{ -public: - QStrVec() { dc = TRUE; } - QStrVec( uint size, bool deepc = TRUE ) : QStrVecBase(size) {dc=deepc;} - ~QStrVec() { clear(); } -private: - Item newItem( Item d ) { return dc ? qstrdup( (const char*)d ) : d; } - void deleteItem( Item d ) { if ( dc ) delete[] (char*)d; } - int compareItems( Item s1, Item s2 ) - { return qstrcmp((const char*)s1, - (const char*)s2); } -#ifndef QT_NO_DATASTREAM - QDataStream &read( QDataStream &s, Item &d ) - { s >> (char *&)d; return s; } - QDataStream &write( QDataStream &s, Item d ) const - { return s << (const char*)d; } -#endif - bool dc; -}; - - -class Q_EXPORT QStrIVec : public QStrVec // case insensitive string vec -{ -public: - QStrIVec() {} - QStrIVec( uint size, bool dc = TRUE ) : QStrVec( size, dc ) {} - ~QStrIVec() { clear(); } -private: - int compareItems( Item s1, Item s2 ) - { return qstricmp((const char*)s1, - (const char*)s2); } -}; - - -#endif // QSTRVEC_H diff --git a/qtools/qvaluelist.doc b/qtools/qvaluelist.doc deleted file mode 100644 index 9f34c8e..0000000 --- a/qtools/qvaluelist.doc +++ /dev/null @@ -1,772 +0,0 @@ -/**************************************************************************** -** -** -** QValueList and QValueListIterator class documentation -** -** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. -** -** This file is part 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. -** -**********************************************************************/ - - -/***************************************************************************** - QValueList documentation - *****************************************************************************/ - -/*! - \class QValueList qvaluelist.h - \brief The QValueList class is a value based template class that provides doubly linked lists. - - \ingroup qtl - \ingroup tools - \ingroup shared - - Define a template instance QValueList\<X\> to create a list of values which all - have the class X. Please notice that QValueList does not store pointers to the - members of the list. It holds a copy of every member. That is the reason why this - kind of classes are called "value based" while QList and QDict are "reference based". - - Some classes can not be used within a QValueList, for example everything - derived from QObject and thus all classes that implement widgets. - Only values can be used in a QValueList. To qualify as a value, the class - must provide - <ul> - <li>a copy constructor, - <li>an assignment operator and - <li> a default constructor, i.e. a constructor that does not take any arguments. - </ul> - - Note that C++ defaults to field-by-field assignment operators and - copy constructors if no explicit version is supplied. In many cases, - this is sufficient. - - Example: - \code - #include <qvaluelist.h> - #include <qstring.h> - #include <stdio.h> - - class Employee - { - public: - Employee(): s(0) {} - Employee( const QString& name, int salary ) - : n(name), s(salary) - {} - - QString name() const { return n; } - int salary() const { return s; } - void setSalary( int salary ) { s = salary; } - private: - QString n; - int s; - }; - - void main() - { - typedef QValueList<Employee> EmployeeList; - EmployeeList list; // list of Employee - - list.append( Employee("Bill", 50000) ); - list.append( Employee("Steve",80000) ); - list.append( Employee("Ron", 60000) ); - - Employee joe( "Joe", 50000 ); - list.append( joe ); - joe.setSalary( 4000 ); - - EmployeeList::Iterator it; - for( it = list.begin(); it != list.end(); ++it ) - printf( "%s earns %d\n", (*it).name().latin1(), (*it).salary().latin1() ); - } - \endcode - - Program output: - \code - Bill earns 50000 - Steve earns 80000 - Ron earns 60000 - Joe earns 50000 - \endcode - - As you can see, the latest changes to Joes salary did not affect the value - in the list because the list created a copy of Joes entry. - - There are three ways of finding items in the list. The first one is by using - the at() function. It returns an iterator. The advantages of - getting an iterator is that you can now move forward or backward from this - position by incrementing/decrementing the iterator. To get the amount of - items in the list call count(). Valid indices are 0..count(). - - The second way of accessing a list is with operator[]. That means you can address - it like an array. The return value is a reference to the value stored in the list. - There exist two versions of this operator. The first one is const and returns a - const reference to the value. The second on is non const and returns a non const - reference to the value. It is up to your compiler to choose the correct one. - - The third method is to use the functions begin() and end(). - With a simple for loop as shown in the example you can iterate over the complete list. - It is save to have multiple iterators at the same time. If some member of the list is - removed then only iterators pointing to the removed member become invalid. Inserting in - the list does not invalidate any iterator. For convenience the function last() returns - an iterator for the last and first() for the first element in the list. - - In addition you can search items in the list with the find() function. It exists in a const - and a non const version. It starts searching from the beginning of the list, but another - flavor of the find() function allows you to specify where searching should start. - If you just want to know whether a certain item is at least once in the list, then you - can use the contains() function. - - Since QValueList is value based there is no need to care about deleting elements in the - list. The list holds its own copies and will free them if the corresponding member or - the list itself is deleted. You can force the list to free all of its item with clear(). - - QValueList is implicitly shared. That means you can just make copies of the list - in time O(1). If multiple QValueList instances share the same data and one - is doing a modification of the lists data then this modifying instance makes a copy - and modifies its private copy. So it does not affect the other instances. - From a developers point of view you can think that a QValueList and a copy of this - list have nothing to do with each other. Developers may only notice that copying is - very fast. People known to a CPUs MMU architecture will know this pattern as "copy on write". - - There exist three functions to insert items in the list. append() - inserts an item at the end, prepend() inserts at the beginning - and insert() inserts in front of the position given by an iterator. - - Items can be removed from the list in two ways. The first is to pass an iterator to - the remove(). The other possibility is to pass a value to remove() which will - delete all members which match this value. - - Lists can be sorted with the algorithms provided by the <a - href="qtl.html">Qt Template Library</a>, for example with - qHeapSort(): - - Example: - \code - QValueList l; - l.append( 5 ); - l.append( 8 ); - l.append( 3 ); - l.append( 4 ); - qHeapSort( l ); - \endcode - - \sa QValueListIterator -*/ - - -/*! - \fn QValueList::QValueList() - Constructs an empty list. -*/ - -/*! - \fn QValueList::QValueList( const QValueList<T>& l ) - Constructs a copy of \e l. - - This operation costs O(1) time since QValueList is implicit shared. - The first instance applying modifications to a shared list will create - a copy which takes in turn O(n) time. However returning a QValueList from - a function is very fast. -*/ - -/*! - \fn QValueList::~QValueList() - Destroys the list. References to the values in the list and all iterators - of this list become invalidated. Since QValueList is highly tuned for performance - you won't see warnings if you use invalid iterators, - because it is impossible for - an iterator to check whether it is valid or not. -*/ - -/*! - \fn QValueList<T>& QValueList::operator= ( const QValueList<T>& l ) - Assigns \e l to this list and returns a reference to this list. - - All iterators of the current list become invalidated by this operation. - The cost of such an assignment is O(1) since QValueList is implicitly shared. -*/ - -/*! - \fn QValueList<T> QValueList::operator+ ( const QValueList<T>& l ) const - Creates a new list and fills it with the elements of this list. Then the - elements of \e l are appended. - - Returns the new list. -*/ - -/*! - \fn QValueList<T>& QValueList::operator+= ( const QValueList<T>& l ) - Adds \e list to this list. - - Returns a reference to this list. -*/ - -/*! - \fn bool QValueList::operator== ( const QValueList<T>& l ) const - Compares both lists. - - Returns TRUE if both list are equal. -*/ - -/*! - \fn bool QValueList::operator!= ( const QValueList<T>& l ) const - Compares both lists. - - Returns TRUE if both list are unequal. -*/ - -/*! - \fn QValueList<T>& QValueList::operator+= ( const T& x ) - Adds the value \e x to the end of the list. - - Returns a reference to the list. -*/ - -/*! - \fn QValueList<T>& QValueList::operator<< ( const T& x ) - Adds the value \e x to the end of the list. - - Returns a reference to the list. -*/ - -/*! - \fn const T& QValueList::operator[] ( uint i ) const - Returns a const reference to the item with index \e i in the list. - It is up to you to check whether this item really exists. You can do that easily - with the count() function. However this operator does not check whether \e i - is in range and will deliver undefined results if it does not exist. -*/ - -/*! - \fn T& QValueList::operator[] ( uint i ) - Returns a reference to the item with index \e i in the list. - It is up to you to check whether this item really exists. You can do that easily - with the count() function. However this operator does not check whether \e i - is in range and will deliver undefined results if it does not exist. - In contrast to the const operator[] you may manipulate the value returned by this - operator. -*/ - -/*! - \fn uint QValueList::count() const - Returns the number of items in the list. - \sa isEmpty() -*/ - -/*! - \fn bool QValueList::isEmpty() const - Returns TRUE if the list is empty, i.e. count() == 0. Returns FALSE - otherwise. - \sa count() -*/ - -/*! - \fn Iterator QValueList::insert( Iterator it, const T& x ) - Inserts the value \e x in front of the iterator \e it. - - Returns an iterator pointing at the inserted item. - - \sa append(), prepend() -*/ - -/*! - \fn Iterator QValueList::append( const T& x ) - Inserts the value \e x at the end of the list. - - Returns an iterator pointing at the inserted item. - - \sa insert(), prepend() -*/ - -/*! - \fn Iterator QValueList::prepend( const T& x ) - Inserts the value \e x at the beginning of the list. - - Returns an iterator pointing at the inserted item. - - \sa insert(), append() -*/ - -/*! - \fn Iterator QValueList::remove( Iterator it ) - Removes the item at position \e it in the list. - - Returns an iterator pointing to the item following the - removed on or end() if the last item was deleted. - - \sa clear() -*/ - -/*! - \fn void QValueList::remove( const T& x ) - Removes all items which have the value \e x. - - \sa clear() -*/ - -/*! - \fn void QValueList::clear() - Removes all items from the list. - - \sa remove() -*/ - -/*! - \fn Iterator QValueList::find( const T& x ) - Finds the first occurrence of \e x in the list. - - Returns end() if no item did match. -*/ - -/*! - \fn ConstIterator QValueList::find( const T& x ) const - Finds the first occurrence of \e x in the list. - - Returns end() if no item did match. -*/ - -/*! - \fn Iterator QValueList::find( Iterator it, const T& x ) - Finds the first occurrence of \e x in the list starting at - the position given by \e it. - - Returns end() if no item did match. -*/ - -/*! - \fn ConstIterator QValueList::find( ConstIterator it, const T& x ) const - Finds the first occurrence of \e x in the list starting at - the position given by \e it. - - Returns end() if no item did match. -*/ - -/*! - \fn uint QValueList::contains( const T& x ) const - Counts and returns the number of occurrences of the value \e x in the list. -*/ - -/*! - \fn int QValueList::findIndex( const T& x ) const - Returns the first index of the value \e x in the list or -1 if no such value - can be found in the list. -*/ - -/*! - \fn Iterator QValueList::at( uint i ) - Returns an iterator pointing to the item at position \e i in the list, or - end() if the index is out of range. -*/ - -/*! - \fn ConstIterator QValueList::at( uint i ) const - Returns an iterator pointing to the item at position \e i in the list, or - end() if the index is out of range. -*/ - -/*! - \fn T& QValueList::first() - Returns a reference to the first item in the list or the item - referenced by end() - if no such items exists. Please note that you may not change - the value the end() Iterator is pointing to. - - \sa begin(), last() -*/ - -/*! - \fn const T& QValueList::first() const - Returns a reference to the first item in the list or the item - referenced by end() if - no such items exists. - - \sa begin(), last() -*/ - -/*! - \fn Iterator QValueList::fromLast() - Returns an iterator pointing to the last element in the list or - end() if no such item exists. - - \sa last() -*/ - -/*! - \fn ConstIterator QValueList::fromLast() const - Returns an iterator pointing to the last element in the list or - end() if no such item exists. - - \sa last() -*/ - -/*! - \fn T& QValueList::last() - Returns a reference to the last item in the list or the item - referenced by end() if no - such item exists. Please note that you may not change - the value the end() Iterator is pointing to. - - \sa end(), first(), fromLast() -*/ - -/*! - \fn const T& QValueList::last() const - Returns a reference to the last item in the list or the item - referenced by end() if no such item exists. - - \sa end(), first(), fromLast() -*/ - -/*! - \fn Iterator QValueList::begin() - Returns an iterator pointing to the first element in the list. This - iterator equals end() if the list is empty; - \sa first(), end() -*/ - -/*! - \fn ConstIterator QValueList::begin() const - Returns an iterator pointing to the first element in the list. This - iterator equals end() if the list is empty; - \sa first(), end() -*/ - -/*! - \fn Iterator QValueList::end() - Returns an iterator pointing behind the last element in the list. This - iterator equals begin() if the list is empty. - - \sa last(), begin() -*/ - -/*! - \fn ConstIterator QValueList::end() const - Returns an iterator pointing behind the last element in the list. This - iterator equals begin() if the list is empty. - - \sa last(), begin() -*/ - -/*! - \fn void QValueList::detach() - If the list does not share its data with another QValueList instance, then nothing - happens, otherwise the function creates a new copy of this data and detaches - from the shared one. This function is called whenever the list is modified. - The implicit sharing mechanism is implemented this way. -*/ - -/*! - \fn QDataStream& operator>>( QDataStream& s, QValueList<T>& l ) - \relates QValueList - Reads a list from the stream. The type \e T stored in the list must implement - the streaming operator, too. -*/ - -/*! - \fn QDataStream& operator<<( QDataStream& s, const QValueList<T>& l ) - \relates QValueList - Writes a list to the stream. The type \e T stored in the list must implement - the streaming operator, too. -*/ - -/***************************************************************************** - QValueListIterator documentation - *****************************************************************************/ - -/*! - \class QValueListIterator qvaluelist.h - \brief The QValueListIterator class provides an iterator for QValueList. - - \ingroup qtl - \ingroup tools - - You can not create an iterator by yourself. Instead you have to - ask a list to give you one. An iterator has only the size of a pointer. - On 32 bit machines that means 4 bytes otherwise 8 bytes. That makes them - very fast. In fact they resemble the semantics of pointers as good as possible - and they are almost as fast as usual pointers. - - Example: - \code - #include <qvaluelist.h> - #include <qstring.h> - #include <stdio.h> - - class Employee - { - public: - Employee(): s(0) {} - Employee( const QString& name, int salary ) - : n(name), s(salary) - {} - - QString name() const { return n; } - int salary() const { return s; } - void setSalary( int salary ) { s = salary; } - private: - QString n; - int s; - }; - - void main() - { - typedef QValueList<Employee> EmployeeList; - EmployeeList list; // list of Employee - - list.append( Employee("Bill", 50000) ); - list.append( Employee("Steve",80000) ); - list.append( Employee("Ron", 60000) ); - - Employee joe( "Joe", 50000 ); - list.append( joe ); - joe.setSalary( 4000 ); - - EmployeeList::Iterator it; - for( it = list.begin(); it != list.end(); ++it ) - printf( "%s earns %d\n", (*it).name().latin1(), (*it).salary() ); - } - \endcode - - Program output: - \code - Bill earns 50000 - Steve earns 80000 - Ron earns 60000 - Joe earns 50000 - \endcode - - In contrast to QList there are no built in functions in QValueList to - traverse the list. The only way to do this is to use iterators. - QValueList is highly optimized for performance and memory usage. - On the other hand that means that you have to be a bit more careful - by what you are doing. QValueList does not know about all its iterators - and the iterators don't even know to which list they belong. That makes - things fast and slim but a bit dangerous because it is up to you to make - sure that iterators you are using are still valid. QListIterator will be able - to give warnings while QValueListIterator may end up in an undefined state. - - For every Iterator there is a ConstIterator. When accessing a QValueList - in a const environment or if the reference or pointer to the list is itself - const, then you have to use the ConstIterator. Its semantics are the same, - but it returns only const references to the item it points to. - - \sa QValueList, QValueListConstIterator -*/ - -/*! - \fn QValueListIterator::QValueListIterator() - Creates un uninitialized iterator. -*/ - -/*! - \fn QValueListIterator::QValueListIterator( NodePtr p ) - Internal function. -*/ - -/*! - \fn QValueListIterator::QValueListIterator( const QValueListIterator<T>& it ) - Constructs a copy of the iterator \e it. -*/ - -/*! - \fn QValueListIterator::~QValueListIterator() - Destroys the iterator. -*/ - -/* Unfortunately not with MSVC - \fn T *QValueListIterator::operator->() - Pointer operator. Returns a pointer to the current iterator item. - The great advantage of this operator is that you can treat the - iterator like a pointer. - - Example: - \code - QValueList<int>::Iterator it = list.begin(); - for( ; it != end(); ++it ) - it->show(); - \endcode -*/ - -/*! - \fn T& QValueListIterator::operator*() - Asterisk operator. Returns a reference to the current iterator item. -*/ - -/*! - \fn const T& QValueListIterator::operator*() const - Asterisk operator. Returns a reference to the current iterator item. -*/ - -/*! - \fn QValueListIterator<T>& QValueListIterator::operator++() - Prefix ++ makes the succeeding item current and returns - an iterator pointing to the new current item. - The iterator can not check whether it reached the end of the list. Incrementing - the iterator as returned by end() causes undefined results. -*/ - -/*! - \fn QValueListIterator<T> QValueListIterator::operator++(int) - Postfix ++ makes the succeeding item current and returns - an iterator pointing to the new current item. - The iterator can not check whether it reached the end of the list. Incrementing - the iterator as returned by end() causes undefined results. -*/ - -/*! - \fn QValueListIterator<T>& QValueListIterator::operator--() - Prefix -- makes the previous item current and returns - an iterator pointing to the new current item. - The iterator can not check whether it reached the beginning of the list. Decrementing - the iterator as returned by begin() causes undefined results. -*/ - -/*! - \fn QValueListIterator<T> QValueListIterator::operator--(int) - Postfix -- makes the previous item current and returns - an iterator pointing to the new current item. - The iterator can not check whether it reached the beginning of the list. Decrementing - the iterator as returned by begin() causes undefined results. -*/ - -/*! - \fn bool QValueListIterator::operator==( const QValueListIterator<T>& it ) const - Compares both iterators and returns TRUE if they point to the same item. -*/ - -/*! - \fn bool QValueListIterator::operator!=( const QValueListIterator<T>& it ) const - Compares both iterators and returns TRUE if they point to different items. -*/ - -/***************************************************************************** - QValueListConstIterator documentation - *****************************************************************************/ - -/*! - \class QValueListConstIterator qvaluelist.h - \brief The QValueListConstIterator class provides an iterator for QValueList. - - \ingroup qtl - \ingroup tools - - In contrast to QValueListIterator this class is used to iterate over a const - list. It does not allow to modify the values of the list since this would - break the const semantics. - - For more information on QValueList iterators see QValueListIterator. - - \sa QValueListIterator, QValueList -*/ - -/*! - \fn QValueListConstIterator::QValueListConstIterator() - Creates un uninitialized iterator. -*/ - -/*! - \fn QValueListConstIterator::QValueListConstIterator( NodePtr p ) - Internal function. -*/ - -/*! - \fn QValueListConstIterator::QValueListConstIterator( const QValueListConstIterator<T>& it ) - Constructs a copy of the iterator \e it. -*/ - -/*! - \fn QValueListConstIterator::QValueListConstIterator( const QValueListIterator<T>& it ) - Constructs a copy of the iterator \e it. -*/ - -/*! - \fn QValueListConstIterator::~QValueListConstIterator() - Destroys the iterator. -*/ - -/* Unfortunately not with MSVC - \fn const T *QValueListConstIterator::operator->() - Pointer operator. Returns a pointer to the current iterator item. - The great advantage of this operator is that you can treat the - iterator like a pointer. - - Example: - \code - QValueList<int>::Iterator it = list.begin(); - for( ; it != end(); ++it ) - it->show(); - \endcode -*/ - -/*! - \fn const T& QValueListConstIterator::operator*() const - Asterisk operator. Returns a reference to the current iterator item. -*/ - -/*! - \fn QValueListConstIterator<T>& QValueListConstIterator::operator++() - Prefix ++ makes the succeeding item current and returns - an iterator pointing to the new current item. - The iterator can not check whether it reached the end of the list. Incrementing - the iterator as returned by end() causes undefined results. -*/ - -/*! - \fn QValueListConstIterator<T> QValueListConstIterator::operator++(int) - Postfix ++ makes the succeeding item current and returns - an iterator pointing to the new current item. - The iterator can not check whether it reached the end of the list. Incrementing - the iterator as returned by end() causes undefined results. -*/ - -/*! - \fn QValueListConstIterator<T>& QValueListConstIterator::operator--() - Prefix -- makes the previous item current and returns - an iterator pointing to the new current item. - The iterator can not check whether it reached the beginning of the list. Decrementing - the iterator as returned by begin() causes undefined results. -*/ - -/*! - \fn QValueListConstIterator<T> QValueListConstIterator::operator--(int) - Postfix -- makes the previous item current and returns - an iterator pointing to the new current item. - The iterator can not check whether it reached the beginning of the list. Decrementing - the iterator as returned by begin() causes undefined results. -*/ - -/*! - \fn bool QValueListConstIterator::operator==( const QValueListConstIterator<T>& it ) const - Compares both iterators and returns TRUE if they point to the same item. -*/ - -/*! - \fn bool QValueListConstIterator::operator!=( const QValueListConstIterator<T>& it ) const - Compares both iterators and returns TRUE if they point to different items. -*/ diff --git a/qtools/qvaluelist.h b/qtools/qvaluelist_p.h index 8885bea..8885bea 100644 --- a/qtools/qvaluelist.h +++ b/qtools/qvaluelist_p.h diff --git a/qtools/qvaluestack.h b/qtools/qvaluestack_p.h index fe4462a..5e10acb 100644 --- a/qtools/qvaluestack.h +++ b/qtools/qvaluestack_p.h @@ -1,5 +1,5 @@ /**************************************************************************** -** +** ** ** Definition of QValueStack class ** @@ -39,7 +39,7 @@ #define QVALUESTACK_H #ifndef QT_H -#include "qvaluelist.h" +#include "qvaluelist_p.h" #endif // QT_H diff --git a/qtools/qxml.h b/qtools/qxml.h index b44e42c..94005bb 100644 --- a/qtools/qxml.h +++ b/qtools/qxml.h @@ -1,5 +1,5 @@ /**************************************************************************** -** +** ** ** Definition of QXmlSimpleReader and related classes. ** @@ -51,8 +51,8 @@ #include <qfile.h> #include <qstring.h> #include <qstringlist.h> -#include <qvaluestack.h> -#include <qmap.h> +#include <qvaluestack_p.h> +#include <qmap_p.h> #endif // QT_H #ifndef QT_NO_XML diff --git a/src/configgen.py b/src/configgen.py index 063c1f4..1dcf3b5 100755 --- a/src/configgen.py +++ b/src/configgen.py @@ -683,8 +683,6 @@ def main(): print("#ifndef CONFIGVALUES_H") print("#define CONFIGVALUES_H") print("") - print("#include <qdict.h>") - print("#include <qstrlist.h>") print("#include <qcstring.h>") print("#include \"containers.h\"") print("#include \"settings.h\"") diff --git a/src/context.cpp b/src/context.cpp index 8fbd674..572e0d3 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -247,21 +247,20 @@ class PropertyMapper }; public: - PropertyMapper() : m_map(63) { m_map.setAutoDelete(TRUE); } - /** Add a property to the map * @param[in] name The name of the property to add. * @param[in] handle The method to call when the property is accessed. */ void addProperty(const char *name,typename PropertyFunc::Handler handle) { - if (m_map.find(name)) + auto it = m_map.find(name); + if (it==m_map.end()) { err("Error: adding property '%s' more than once",name); } else { - m_map.insert(name,new PropertyFunc(handle)); + m_map.insert(std::make_pair(name,std::make_unique<PropertyFunc>(handle))); } } @@ -275,16 +274,12 @@ class PropertyMapper { //printf("PropertyMapper::get(%s)\n",name); TemplateVariant result; - PropertyFuncIntf *func = m_map.find(name); - if (func) - { - result = (*func)(obj); - } - return result; + auto it = m_map.find(name); + return it!=m_map.end() ? (*it->second)(obj) : TemplateVariant(); } private: - QDict<PropertyFuncIntf> m_map; + std::unordered_map<std::string,std::unique_ptr<PropertyFuncIntf>> m_map; }; @@ -295,15 +290,15 @@ class PropertyMapper class ConfigContext::Private { public: - Private() { m_cachedLists.setAutoDelete(TRUE); } + Private() { } virtual ~Private() { } TemplateVariant fetchList(const QCString &name,const StringVector &list) { - TemplateVariant *v = m_cachedLists.find(name); - if (v==0) + auto it = m_cachedLists.find(name.str()); + if (it==m_cachedLists.end()) { TemplateList *tlist = TemplateList::alloc(); - m_cachedLists.insert(name,new TemplateVariant(tlist)); + m_cachedLists.insert(std::make_pair(name.str(),TemplateVariant(tlist))); for (const auto &s : list) { tlist->append(s.c_str()); @@ -312,11 +307,11 @@ class ConfigContext::Private } else { - return *v; + return it->second; } } private: - QDict<TemplateVariant> m_cachedLists; + std::unordered_map<std::string,TemplateVariant> m_cachedLists; }; //%% } diff --git a/src/context.h b/src/context.h index 03e502a..9573643 100644 --- a/src/context.h +++ b/src/context.h @@ -18,7 +18,6 @@ #include "types.h" #include "template.h" -#include <qlist.h> #include <stdio.h> #include "classdef.h" #include "searchindex.h" diff --git a/src/definition.h b/src/definition.h index 6c66bc7..4c0c566 100644 --- a/src/definition.h +++ b/src/definition.h @@ -19,8 +19,6 @@ #define DEFINITION_H #include <vector> -#include <qlist.h> -#include <qdict.h> #include "types.h" #include "reflist.h" diff --git a/src/diagram.cpp b/src/diagram.cpp index 80c85c6..052c1f4 100644 --- a/src/diagram.cpp +++ b/src/diagram.cpp @@ -15,8 +15,6 @@ #include <stdio.h> #include <stdlib.h> -#include <qlist.h> -#include <qarray.h> #include "ftextstream.h" #include <qfile.h> diff --git a/src/docbookgen.cpp b/src/docbookgen.cpp index d9e79cb..8d390b6 100644 --- a/src/docbookgen.cpp +++ b/src/docbookgen.cpp @@ -20,7 +20,6 @@ #include <qdir.h> #include <qfile.h> #include <qtextstream.h> -#include <qintdict.h> #include <qregexp.h> #include "docbookgen.h" #include "doxygen.h" diff --git a/src/docbookvisitor.h b/src/docbookvisitor.h index b56066f..bec7a12 100644 --- a/src/docbookvisitor.h +++ b/src/docbookvisitor.h @@ -18,8 +18,6 @@ #include "containers.h" #include "docvisitor.h" -#include <qstack.h> -#include <qlist.h> #include <qcstring.h> #include <docparser.h> diff --git a/src/doctokenizer.h b/src/doctokenizer.h index 235b403..ec73e61 100644 --- a/src/doctokenizer.h +++ b/src/doctokenizer.h @@ -20,7 +20,6 @@ #define _DOCTOKENIZER_H #include <qcstring.h> -#include <qlist.h> #include <stdio.h> #include "htmlattrib.h" diff --git a/src/doctokenizer.l b/src/doctokenizer.l index 983b5fa..0c167ca 100644 --- a/src/doctokenizer.l +++ b/src/doctokenizer.l @@ -29,7 +29,6 @@ #include <qfile.h> #include <qstring.h> -#include <qdict.h> #include <qregexp.h> #include "doctokenizer.h" diff --git a/src/doxygen.cpp b/src/doxygen.cpp index 34468be..f5a280b 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -19,15 +19,12 @@ #include <qfileinfo.h> #include <qfile.h> #include <qdir.h> -#include <qdict.h> #include <qregexp.h> -#include <qstrlist.h> #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include <qtextcodec.h> #include <errno.h> -#include <qptrdict.h> #include <qtextstream.h> #include <algorithm> diff --git a/src/doxygen.h b/src/doxygen.h index 1f514b3..5c8ad1b 100644 --- a/src/doxygen.h +++ b/src/doxygen.h @@ -17,9 +17,6 @@ #define DOXYGEN_H #include <qdatetime.h> -#include <qstrlist.h> -#include <qdict.h> -#include <qintdict.h> #include "containers.h" #include "ftextstream.h" diff --git a/src/fortranscanner.l b/src/fortranscanner.l index b3f1bae..74d6d03 100644 --- a/src/fortranscanner.l +++ b/src/fortranscanner.l @@ -56,11 +56,8 @@ #include <assert.h> #include <ctype.h> -#include <qarray.h> -#include <qstack.h> #include <qregexp.h> #include <qfile.h> -#include <qmap.h> #include "fortranscanner.h" #include "entry.h" diff --git a/src/layout.h b/src/layout.h index 4a0ae8c..d319b69 100644 --- a/src/layout.h +++ b/src/layout.h @@ -21,7 +21,6 @@ #include <memory> #include <vector> -#include <qlist.h> #include "types.h" class LayoutParser; diff --git a/src/memberdef.h b/src/memberdef.h index 39355db..7b27cff 100644 --- a/src/memberdef.h +++ b/src/memberdef.h @@ -21,7 +21,6 @@ #include <vector> #include <memory> -#include <qlist.h> #include <sys/types.h> #include "types.h" diff --git a/src/membergroup.h b/src/membergroup.h index d9a392e..b258a04 100644 --- a/src/membergroup.h +++ b/src/membergroup.h @@ -22,7 +22,6 @@ #include <map> #include <memory> -#include <qlist.h> #include "types.h" #include "reflist.h" diff --git a/src/membername.h b/src/membername.h index 1a788af..2141d22 100644 --- a/src/membername.h +++ b/src/membername.h @@ -18,7 +18,6 @@ #ifndef MEMBERNAME_H #define MEMBERNAME_H -#include <qlist.h> #include "memberdef.h" #include "linkedmap.h" diff --git a/src/perlmodgen.cpp b/src/perlmodgen.cpp index f3e11b9..20bd01b 100644 --- a/src/perlmodgen.cpp +++ b/src/perlmodgen.cpp @@ -21,7 +21,6 @@ #include <stack> #include <qdir.h> -#include <qdict.h> #include <qfile.h> #include "perlmodgen.h" diff --git a/src/reflist.h b/src/reflist.h index 0ced63b..7f4473c 100644 --- a/src/reflist.h +++ b/src/reflist.h @@ -20,8 +20,7 @@ #include <unordered_map> #include <memory> -#include <qintdict.h> -#include <qlist.h> +#include <qcstring.h> #include "linkedmap.h" class Definition; diff --git a/src/scanner.l b/src/scanner.l index 66437bc..19381dd 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -37,7 +37,6 @@ #include <assert.h> #include <ctype.h> -#include <qarray.h> #include <qregexp.h> #include <qfile.h> diff --git a/src/textdocvisitor.h b/src/textdocvisitor.h index c4ba3d7..e424529 100644 --- a/src/textdocvisitor.h +++ b/src/textdocvisitor.h @@ -1,13 +1,13 @@ /****************************************************************************** * - * + * * * * Copyright (C) 1997-2015 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its - * documentation under the terms of the GNU General Public License is hereby - * granted. No representations are made about the suitability of this software + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * @@ -21,7 +21,6 @@ #include "docvisitor.h" #include "docparser.h" -#include <qstack.h> #include <qcstring.h> #include "ftextstream.h" @@ -31,11 +30,11 @@ class TextDocVisitor : public DocVisitor { public: TextDocVisitor(FTextStream &t) : DocVisitor(DocVisitor_Text), m_t(t) {} - + //-------------------------------------- // visitor functions for leaf nodes //-------------------------------------- - + void visit(DocWord *w) { filter(w->word()); } void visit(DocLinkedWord *w) { filter(w->word()); } void visit(DocWhiteSpace *) { m_t << " "; } @@ -57,7 +56,7 @@ class TextDocVisitor : public DocVisitor //-------------------------------------- // visitor functions for compound nodes //-------------------------------------- - + void visitPre(DocAutoList *) {} void visitPost(DocAutoList *) {} void visitPre(DocAutoListItem *) {} diff --git a/src/vhdljjparser.cpp b/src/vhdljjparser.cpp index 2d67ec6..b666f4c 100644 --- a/src/vhdljjparser.cpp +++ b/src/vhdljjparser.cpp @@ -12,7 +12,6 @@ #include <qcstring.h> #include <qfileinfo.h> -#include <qcstringlist.h> #include "containers.h" #include "vhdljjparser.h" #include "vhdldocgen.h" diff --git a/src/vhdljjparser.h b/src/vhdljjparser.h index 651221c..b074511 100755 --- a/src/vhdljjparser.h +++ b/src/vhdljjparser.h @@ -3,18 +3,16 @@ #include <vector> #include <memory> +#include <string> +#include <qcstringlist.h> #include "parserintf.h" #include <stdio.h> #include <stdlib.h> #include <assert.h> #include <ctype.h> -#include <qarray.h> -#include <qcstringlist.h> #include <qfile.h> -#include <qdict.h> -#include <string> #include "types.h" #include "entry.h" #include "vhdldocgen.h" diff --git a/src/xmlgen.cpp b/src/xmlgen.cpp index e8bb9e7..d002295 100644 --- a/src/xmlgen.cpp +++ b/src/xmlgen.cpp @@ -18,7 +18,6 @@ #include <qdir.h> #include <qfile.h> #include <qtextstream.h> -#include <qintdict.h> #include "xmlgen.h" #include "doxygen.h" @@ -59,55 +58,54 @@ //------------------ -/** Helper class mapping MemberList::ListType to a string representing */ -class XmlSectionMapper : public QIntDict<char> +static std::map<MemberListType,std::string> g_xmlSectionMap = { - public: - XmlSectionMapper() : QIntDict<char>(47) - { - insert(MemberListType_pubTypes,"public-type"); - insert(MemberListType_pubMethods,"public-func"); - insert(MemberListType_pubAttribs,"public-attrib"); - insert(MemberListType_pubSlots,"public-slot"); - insert(MemberListType_signals,"signal"); - insert(MemberListType_dcopMethods,"dcop-func"); - insert(MemberListType_properties,"property"); - insert(MemberListType_events,"event"); - insert(MemberListType_interfaces,"interfaces"); - insert(MemberListType_services,"services"); - insert(MemberListType_pubStaticMethods,"public-static-func"); - insert(MemberListType_pubStaticAttribs,"public-static-attrib"); - insert(MemberListType_proTypes,"protected-type"); - insert(MemberListType_proMethods,"protected-func"); - insert(MemberListType_proAttribs,"protected-attrib"); - insert(MemberListType_proSlots,"protected-slot"); - insert(MemberListType_proStaticMethods,"protected-static-func"); - insert(MemberListType_proStaticAttribs,"protected-static-attrib"); - insert(MemberListType_pacTypes,"package-type"); - insert(MemberListType_pacMethods,"package-func"); - insert(MemberListType_pacAttribs,"package-attrib"); - insert(MemberListType_pacStaticMethods,"package-static-func"); - insert(MemberListType_pacStaticAttribs,"package-static-attrib"); - insert(MemberListType_priTypes,"private-type"); - insert(MemberListType_priMethods,"private-func"); - insert(MemberListType_priAttribs,"private-attrib"); - insert(MemberListType_priSlots,"private-slot"); - insert(MemberListType_priStaticMethods,"private-static-func"); - insert(MemberListType_priStaticAttribs,"private-static-attrib"); - insert(MemberListType_friends,"friend"); - insert(MemberListType_related,"related"); - insert(MemberListType_decDefineMembers,"define"); - insert(MemberListType_decProtoMembers,"prototype"); - insert(MemberListType_decTypedefMembers,"typedef"); - insert(MemberListType_decSequenceMembers,"sequence"); - insert(MemberListType_decDictionaryMembers,"dictionary"); - insert(MemberListType_decEnumMembers,"enum"); - insert(MemberListType_decFuncMembers,"func"); - insert(MemberListType_decVarMembers,"var"); - } + { MemberListType_pubTypes,"public-type" }, + { MemberListType_pubMethods,"public-func" }, + { MemberListType_pubAttribs,"public-attrib" }, + { MemberListType_pubSlots,"public-slot" }, + { MemberListType_signals,"signal" }, + { MemberListType_dcopMethods,"dcop-func" }, + { MemberListType_properties,"property" }, + { MemberListType_events,"event" }, + { MemberListType_interfaces,"interfaces" }, + { MemberListType_services,"services" }, + { MemberListType_pubStaticMethods,"public-static-func" }, + { MemberListType_pubStaticAttribs,"public-static-attrib" }, + { MemberListType_proTypes,"protected-type" }, + { MemberListType_proMethods,"protected-func" }, + { MemberListType_proAttribs,"protected-attrib" }, + { MemberListType_proSlots,"protected-slot" }, + { MemberListType_proStaticMethods,"protected-static-func" }, + { MemberListType_proStaticAttribs,"protected-static-attrib" }, + { MemberListType_pacTypes,"package-type" }, + { MemberListType_pacMethods,"package-func" }, + { MemberListType_pacAttribs,"package-attrib" }, + { MemberListType_pacStaticMethods,"package-static-func" }, + { MemberListType_pacStaticAttribs,"package-static-attrib" }, + { MemberListType_priTypes,"private-type" }, + { MemberListType_priMethods,"private-func" }, + { MemberListType_priAttribs,"private-attrib" }, + { MemberListType_priSlots,"private-slot" }, + { MemberListType_priStaticMethods,"private-static-func" }, + { MemberListType_priStaticAttribs,"private-static-attrib" }, + { MemberListType_friends,"friend" }, + { MemberListType_related,"related" }, + { MemberListType_decDefineMembers,"define" }, + { MemberListType_decProtoMembers,"prototype" }, + { MemberListType_decTypedefMembers,"typedef" }, + { MemberListType_decSequenceMembers,"sequence" }, + { MemberListType_decDictionaryMembers,"dictionary" }, + { MemberListType_decEnumMembers,"enum" }, + { MemberListType_decFuncMembers,"func" }, + { MemberListType_decVarMembers,"var" }, }; -static XmlSectionMapper g_xmlSectionMapper; +static const char *xmlSectionMapper(MemberListType ml) +{ + auto it = g_xmlSectionMap.find(ml); + return it!=g_xmlSectionMap.end() ? it->second.c_str() : ""; +} inline void writeXMLString(FTextStream &t,const char *s) @@ -1347,7 +1345,7 @@ static void generateXMLForClass(const ClassDef *cd,FTextStream &ti) { if ((ml->listType()&MemberListType_detailedLists)==0) { - generateXMLSection(cd,ti,t,ml.get(),g_xmlSectionMapper.find(ml->listType())); + generateXMLSection(cd,ti,t,ml.get(),xmlSectionMapper(ml->listType())); } } @@ -1444,7 +1442,7 @@ static void generateXMLForNamespace(const NamespaceDef *nd,FTextStream &ti) { if ((ml->listType()&MemberListType_declarationLists)!=0) { - generateXMLSection(nd,ti,t,ml.get(),g_xmlSectionMapper.find(ml->listType())); + generateXMLSection(nd,ti,t,ml.get(),xmlSectionMapper(ml->listType())); } } @@ -1558,7 +1556,7 @@ static void generateXMLForFile(FileDef *fd,FTextStream &ti) { if ((ml->listType()&MemberListType_declarationLists)!=0) { - generateXMLSection(fd,ti,t,ml.get(),g_xmlSectionMapper.find(ml->listType())); + generateXMLSection(fd,ti,t,ml.get(),xmlSectionMapper(ml->listType())); } } @@ -1631,7 +1629,7 @@ static void generateXMLForGroup(const GroupDef *gd,FTextStream &ti) { if ((ml->listType()&MemberListType_declarationLists)!=0) { - generateXMLSection(gd,ti,t,ml.get(),g_xmlSectionMapper.find(ml->listType())); + generateXMLSection(gd,ti,t,ml.get(),xmlSectionMapper(ml->listType())); } } |