From 1f0ce8533cc837aa2d4155b5fc17d2004bed0197 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Wed, 5 Jun 2024 19:02:23 +0900 Subject: Rename template library nt* related files to equivalent tq* Signed-off-by: Michele Calgaro --- src/canvas/tqcanvas.h | 2 +- src/codecs/qtextcodec.cpp | 2 +- src/dialogs/qfiledialog.cpp | 2 +- src/kernel/ntqevent.h | 2 +- src/kernel/ntqfontdatabase.h | 2 +- src/kernel/ntqmime.h | 2 +- src/kernel/ntqstylesheet.h | 2 +- src/kernel/ntqt.h | 10 +- src/kernel/ntqtranslator.h | 2 +- src/kernel/ntqvariant.h | 4 +- src/kernel/qapplication_x11.cpp | 2 +- src/kernel/qclipboard_x11.cpp | 4 +- src/kernel/qfontengine_p.h | 2 +- src/kernel/qimage.cpp | 2 +- src/kernel/qkeysequence.cpp | 2 +- src/kernel/qmime.cpp | 2 +- src/kernel/qnetworkprotocol.cpp | 2 +- src/kernel/qpsprinter.cpp | 2 +- src/kernel/qrichtext.cpp | 2 +- src/kernel/qrichtext_p.h | 6 +- src/kernel/qt_pch.h | 2 +- src/kernel/qtranslator.cpp | 2 +- src/kernel/qurloperator.cpp | 2 +- src/moc/moc.pro | 2 +- src/network/qhttp.cpp | 2 +- src/opengl/qgl_x11.cpp | 2 +- src/sql/drivers/cache/tqsqlcachedresult.h | 2 +- src/sql/drivers/mysql/tqsql_mysql.cpp | 2 +- src/sql/drivers/odbc/tqsql_odbc.h | 2 +- src/sql/drivers/sqlite3/tqsql_sqlite3.cpp | 2 +- src/sql/tqdatatable.cpp | 2 +- src/sql/tqsqldriver.h | 2 +- src/sql/tqsqlextension_p.h | 4 +- src/sql/tqsqlform.h | 2 +- src/sql/tqsqlpropertymap.cpp | 2 +- src/sql/tqsqlquery.h | 2 +- src/sql/tqsqlrecord.cpp | 2 +- src/tools/ntqmap.h | 881 ------------------------------ src/tools/ntqpair.h | 109 ---- src/tools/ntqstringlist.h | 2 +- src/tools/ntqvaluelist.h | 681 ----------------------- src/tools/ntqvaluestack.h | 67 --- src/tools/ntqvaluevector.h | 577 ------------------- src/tools/qdir_p.h | 2 +- src/tools/qglist.cpp | 2 +- src/tools/qgpluginmanager.cpp | 2 +- src/tools/qmap.cpp | 257 --------- src/tools/qregexp.cpp | 2 +- src/tools/qsettings.cpp | 2 +- src/tools/qsettings_p.h | 4 +- src/tools/qt_tools.pri | 10 +- src/tools/qwinexport.cpp | 6 +- src/tools/tqmap.cpp | 257 +++++++++ src/tools/tqmap.h | 881 ++++++++++++++++++++++++++++++ src/tools/tqpair.h | 109 ++++ src/tools/tqvaluelist.h | 681 +++++++++++++++++++++++ src/tools/tqvaluestack.h | 67 +++ src/tools/tqvaluevector.h | 577 +++++++++++++++++++ src/widgets/ntqdockarea.h | 2 +- src/widgets/ntqsplitter.h | 2 +- src/widgets/ntqtextedit.h | 2 +- src/widgets/qdatetimeedit.cpp | 2 +- src/widgets/qdialogbuttons.cpp | 4 +- src/widgets/qdockarea.cpp | 2 +- src/widgets/qlineedit.cpp | 2 +- src/widgets/qmainwindow.cpp | 2 +- src/widgets/qtextbrowser.cpp | 2 +- src/widgets/qtoolbox.cpp | 2 +- src/xml/qsvgdevice.cpp | 4 +- src/xml/tqxml.cpp | 4 +- src/xml/tqxml.h | 2 +- 71 files changed, 2650 insertions(+), 2650 deletions(-) delete mode 100644 src/tools/ntqmap.h delete mode 100644 src/tools/ntqpair.h delete mode 100644 src/tools/ntqvaluelist.h delete mode 100644 src/tools/ntqvaluestack.h delete mode 100644 src/tools/ntqvaluevector.h delete mode 100644 src/tools/qmap.cpp create mode 100644 src/tools/tqmap.cpp create mode 100644 src/tools/tqmap.h create mode 100644 src/tools/tqpair.h create mode 100644 src/tools/tqvaluelist.h create mode 100644 src/tools/tqvaluestack.h create mode 100644 src/tools/tqvaluevector.h (limited to 'src') diff --git a/src/canvas/tqcanvas.h b/src/canvas/tqcanvas.h index 9bf3d729c..744f21f53 100644 --- a/src/canvas/tqcanvas.h +++ b/src/canvas/tqcanvas.h @@ -47,7 +47,7 @@ #include "ntqptrlist.h" #include "ntqbrush.h" #include "ntqpen.h" -#include "ntqvaluelist.h" +#include "tqvaluelist.h" #include "ntqpointarray.h" #endif // QT_H diff --git a/src/codecs/qtextcodec.cpp b/src/codecs/qtextcodec.cpp index 69e56fd5b..6c83640fd 100644 --- a/src/codecs/qtextcodec.cpp +++ b/src/codecs/qtextcodec.cpp @@ -48,7 +48,7 @@ #include "ntqtextcodec.h" #ifndef TQT_NO_TEXTCODEC -#include "ntqvaluelist.h" +#include "tqvaluelist.h" #include "ntqtextcodecfactory.h" #include "ntqutfcodec.h" #include "ntqnamespace.h" diff --git a/src/dialogs/qfiledialog.cpp b/src/dialogs/qfiledialog.cpp index 2b7ce1b0d..8812f2102 100644 --- a/src/dialogs/qfiledialog.cpp +++ b/src/dialogs/qfiledialog.cpp @@ -74,7 +74,7 @@ #include "ntqlineedit.h" #include "ntqlistbox.h" #include "ntqlistview.h" -#include "ntqmap.h" +#include "tqmap.h" #include "ntqmessagebox.h" #include "ntqmime.h" #include "ntqnetworkprotocol.h" diff --git a/src/kernel/ntqevent.h b/src/kernel/ntqevent.h index ae344371e..91eeb38ed 100644 --- a/src/kernel/ntqevent.h +++ b/src/kernel/ntqevent.h @@ -46,7 +46,7 @@ #include "ntqregion.h" #include "ntqnamespace.h" #include "ntqmime.h" -#include "ntqpair.h" +#include "tqpair.h" #endif // QT_H class TQ_EXPORT TQEvent: public TQt // event base class diff --git a/src/kernel/ntqfontdatabase.h b/src/kernel/ntqfontdatabase.h index 0f2a913af..1894c5598 100644 --- a/src/kernel/ntqfontdatabase.h +++ b/src/kernel/ntqfontdatabase.h @@ -46,7 +46,7 @@ #include "ntqstring.h" #include "ntqstringlist.h" #include "ntqfont.h" -#include "ntqvaluelist.h" +#include "tqvaluelist.h" #endif // QT_H diff --git a/src/kernel/ntqmime.h b/src/kernel/ntqmime.h index 5b541510a..50ed27994 100644 --- a/src/kernel/ntqmime.h +++ b/src/kernel/ntqmime.h @@ -43,7 +43,7 @@ #ifndef QT_H #include "ntqwindowdefs.h" -#include "ntqmap.h" +#include "tqmap.h" #endif // QT_H #ifndef TQT_NO_MIME diff --git a/src/kernel/ntqstylesheet.h b/src/kernel/ntqstylesheet.h index 2b397f946..d11548744 100644 --- a/src/kernel/ntqstylesheet.h +++ b/src/kernel/ntqstylesheet.h @@ -43,7 +43,7 @@ #ifndef QT_H #include "ntqstring.h" -#include "ntqvaluelist.h" +#include "tqvaluelist.h" #include "ntqptrvector.h" #include "ntqdict.h" #include "tqobject.h" diff --git a/src/kernel/ntqt.h b/src/kernel/ntqt.h index d6671bee8..eef4df773 100644 --- a/src/kernel/ntqt.h +++ b/src/kernel/ntqt.h @@ -33,7 +33,7 @@ #include "ntqgdict.h" #include "ntqfont.h" #include "ntqdatastream.h" -#include "ntqpair.h" +#include "tqpair.h" #include "ntqpoint.h" #include #include "ntqtextstream.h" @@ -46,8 +46,8 @@ #include "ntqregion.h" #include "tqsql.h" #include "ntqstrlist.h" -#include "ntqvaluelist.h" -#include "ntqmap.h" +#include "tqvaluelist.h" +#include "tqmap.h" #include "ntqdatetime.h" #include "ntqmime.h" #include "ntqasciidict.h" @@ -251,8 +251,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/src/kernel/ntqtranslator.h b/src/kernel/ntqtranslator.h index e255b81e1..39f9faa36 100644 --- a/src/kernel/ntqtranslator.h +++ b/src/kernel/ntqtranslator.h @@ -44,7 +44,7 @@ #ifndef QT_H #include "tqobject.h" -#include "ntqvaluelist.h" +#include "tqvaluelist.h" #endif // QT_H #ifndef TQT_NO_TRANSLATION diff --git a/src/kernel/ntqvariant.h b/src/kernel/ntqvariant.h index f0657b499..5e4801520 100644 --- a/src/kernel/ntqvariant.h +++ b/src/kernel/ntqvariant.h @@ -42,10 +42,10 @@ #define TQVARIANT_H #ifndef QT_H -#include "ntqmap.h" +#include "tqmap.h" #include "ntqstring.h" #include "ntqstringlist.h" -#include "ntqvaluelist.h" +#include "tqvaluelist.h" #endif // QT_H #ifndef TQT_NO_VARIANT diff --git a/src/kernel/qapplication_x11.cpp b/src/kernel/qapplication_x11.cpp index 56ba9aefa..57c55feba 100644 --- a/src/kernel/qapplication_x11.cpp +++ b/src/kernel/qapplication_x11.cpp @@ -79,7 +79,7 @@ #include "ntqbuffer.h" #include "ntqsocketnotifier.h" #include "ntqsessionmanager.h" -#include "ntqvaluelist.h" +#include "tqvaluelist.h" #include "ntqdict.h" #include "ntqguardedptr.h" #include "ntqclipboard.h" diff --git a/src/kernel/qclipboard_x11.cpp b/src/kernel/qclipboard_x11.cpp index d0571fc5a..51fbc63ab 100644 --- a/src/kernel/qclipboard_x11.cpp +++ b/src/kernel/qclipboard_x11.cpp @@ -71,8 +71,8 @@ #include "ntqdragobject.h" #include "ntqbuffer.h" #include "ntqtextcodec.h" -#include "ntqvaluelist.h" -#include "ntqmap.h" +#include "tqvaluelist.h" +#include "tqmap.h" #include "qt_x11_p.h" #include "qapplication_p.h" diff --git a/src/kernel/qfontengine_p.h b/src/kernel/qfontengine_p.h index e1fc58545..09fa32001 100644 --- a/src/kernel/qfontengine_p.h +++ b/src/kernel/qfontengine_p.h @@ -529,7 +529,7 @@ private: #elif defined( TQ_WS_MAC ) #include "qt_mac.h" -#include +#include #include class TQFontEngineMac : public TQFontEngine diff --git a/src/kernel/qimage.cpp b/src/kernel/qimage.cpp index ce95f1cb6..1097a5f80 100644 --- a/src/kernel/qimage.cpp +++ b/src/kernel/qimage.cpp @@ -49,7 +49,7 @@ #include "ntqpngio.h" #include "ntqmngio.h" #include "ntqjpegio.h" -#include "ntqmap.h" +#include "tqmap.h" #include #include "qimageformatinterface_p.h" #include "ntqwmatrix.h" diff --git a/src/kernel/qkeysequence.cpp b/src/kernel/qkeysequence.cpp index 42a955911..8a8ac86b0 100644 --- a/src/kernel/qkeysequence.cpp +++ b/src/kernel/qkeysequence.cpp @@ -44,7 +44,7 @@ #include "ntqaccel.h" #include "ntqshared.h" -#include "ntqvaluelist.h" +#include "tqvaluelist.h" #ifndef TQT_NO_REGEXP # include "ntqregexp.h" #endif diff --git a/src/kernel/qmime.cpp b/src/kernel/qmime.cpp index e1dd27d68..9b2b2a4ae 100644 --- a/src/kernel/qmime.cpp +++ b/src/kernel/qmime.cpp @@ -40,7 +40,7 @@ #ifndef TQT_NO_MIME -#include "ntqmap.h" +#include "tqmap.h" #include "ntqstringlist.h" #include "ntqfileinfo.h" #include "ntqdir.h" diff --git a/src/kernel/qnetworkprotocol.cpp b/src/kernel/qnetworkprotocol.cpp index 27b6dff44..b8ad2b55d 100644 --- a/src/kernel/qnetworkprotocol.cpp +++ b/src/kernel/qnetworkprotocol.cpp @@ -45,7 +45,7 @@ #include "ntqlocalfs.h" #include "ntqurloperator.h" #include "ntqtimer.h" -#include "ntqmap.h" +#include "tqmap.h" #include "ntqptrqueue.h" //#define TQNETWORKPROTOCOL_DEBUG diff --git a/src/kernel/qpsprinter.cpp b/src/kernel/qpsprinter.cpp index d1678fa38..58a23dfcf 100644 --- a/src/kernel/qpsprinter.cpp +++ b/src/kernel/qpsprinter.cpp @@ -69,7 +69,7 @@ #include "ntqintdict.h" #include "ntqtextcodec.h" #include "ntqsettings.h" -#include "ntqmap.h" +#include "tqmap.h" #include "ntqfontdatabase.h" #include "ntqregexp.h" #include "ntqbitmap.h" diff --git a/src/kernel/qrichtext.cpp b/src/kernel/qrichtext.cpp index ecc304071..a2ab4d0e0 100644 --- a/src/kernel/qrichtext.cpp +++ b/src/kernel/qrichtext.cpp @@ -48,7 +48,7 @@ #include "ntqtextstream.h" #include "ntqfile.h" #include "ntqapplication.h" -#include "ntqmap.h" +#include "tqmap.h" #include "ntqfileinfo.h" #include "ntqstylesheet.h" #include "ntqmime.h" diff --git a/src/kernel/qrichtext_p.h b/src/kernel/qrichtext_p.h index 1915820fa..874e61557 100644 --- a/src/kernel/qrichtext_p.h +++ b/src/kernel/qrichtext_p.h @@ -59,13 +59,13 @@ #include "ntqrect.h" #include "ntqfontmetrics.h" #include "ntqintdict.h" -#include "ntqmap.h" +#include "tqmap.h" #include "ntqstringlist.h" #include "ntqfont.h" #include "ntqcolor.h" #include "ntqsize.h" -#include "ntqvaluelist.h" -#include "ntqvaluestack.h" +#include "tqvaluelist.h" +#include "tqvaluestack.h" #include "tqobject.h" #include "ntqdict.h" #include "ntqpixmap.h" diff --git a/src/kernel/qt_pch.h b/src/kernel/qt_pch.h index 5295f8134..3e5224ae6 100644 --- a/src/kernel/qt_pch.h +++ b/src/kernel/qt_pch.h @@ -21,7 +21,7 @@ # undef _GLIBCPP_FULLY_COMPLIANT_HEADERS // Makes qlocale.cpp compile # endif # endif -#include // I must be first! +#include // I must be first! #include // All moc genereated code has this include #include #include diff --git a/src/kernel/qtranslator.cpp b/src/kernel/qtranslator.cpp index e3d1c5b98..4cc41ae00 100644 --- a/src/kernel/qtranslator.cpp +++ b/src/kernel/qtranslator.cpp @@ -64,7 +64,7 @@ static inline int qt_open(const char *pathname, int flags, mode_t mode) #include "ntqfile.h" #include "ntqbuffer.h" #include "ntqdatastream.h" -#include "ntqmap.h" +#include "tqmap.h" #include "ntqtl.h" #if defined(Q_OS_UNIX) diff --git a/src/kernel/qurloperator.cpp b/src/kernel/qurloperator.cpp index ca508c48c..e5b84ca51 100644 --- a/src/kernel/qurloperator.cpp +++ b/src/kernel/qurloperator.cpp @@ -44,7 +44,7 @@ #include "ntqurlinfo.h" #include "ntqnetworkprotocol.h" -#include "ntqmap.h" +#include "tqmap.h" #include "ntqdir.h" #include "ntqptrdict.h" #include "ntqguardedptr.h" diff --git a/src/moc/moc.pro b/src/moc/moc.pro index c8abcf0d7..6871d9d93 100644 --- a/src/moc/moc.pro +++ b/src/moc/moc.pro @@ -33,7 +33,7 @@ SOURCES = ../tools/qbuffer.cpp \ ../tools/qstringlist.cpp \ ../tools/qtextstream.cpp \ ../tools/qbitarray.cpp \ - ../tools/qmap.cpp \ + ../tools/tqmap.cpp \ ../tools/qgcache.cpp \ ../codecs/qtextcodec.cpp \ ../codecs/qutfcodec.cpp diff --git a/src/network/qhttp.cpp b/src/network/qhttp.cpp index d08f10f24..54c21fcc1 100644 --- a/src/network/qhttp.cpp +++ b/src/network/qhttp.cpp @@ -44,7 +44,7 @@ #include "ntqsocket.h" #include "ntqtextstream.h" -#include "ntqmap.h" +#include "tqmap.h" #include "ntqstring.h" #include "ntqstringlist.h" #include "ntqcstring.h" diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp index 51daa176b..dc8530f1e 100644 --- a/src/opengl/qgl_x11.cpp +++ b/src/opengl/qgl_x11.cpp @@ -42,7 +42,7 @@ #if defined(TQ_WS_X11) -#include "ntqmap.h" +#include "tqmap.h" #include "ntqpixmap.h" #include "ntqapplication.h" diff --git a/src/sql/drivers/cache/tqsqlcachedresult.h b/src/sql/drivers/cache/tqsqlcachedresult.h index f31c3853f..3542a1749 100644 --- a/src/sql/drivers/cache/tqsqlcachedresult.h +++ b/src/sql/drivers/cache/tqsqlcachedresult.h @@ -54,7 +54,7 @@ #include #include #include -#include +#include #include #if !defined( TQT_MODULE_SQL ) || defined( QT_LICENSE_PROFESSIONAL ) diff --git a/src/sql/drivers/mysql/tqsql_mysql.cpp b/src/sql/drivers/mysql/tqsql_mysql.cpp index 3854a5bb3..d91720e80 100644 --- a/src/sql/drivers/mysql/tqsql_mysql.cpp +++ b/src/sql/drivers/mysql/tqsql_mysql.cpp @@ -42,7 +42,7 @@ #include #include -#include +#include #include #define TQMYSQL_DRIVER_NAME "TQMYSQL3" diff --git a/src/sql/drivers/odbc/tqsql_odbc.h b/src/sql/drivers/odbc/tqsql_odbc.h index 3948b087a..f64d3e902 100644 --- a/src/sql/drivers/odbc/tqsql_odbc.h +++ b/src/sql/drivers/odbc/tqsql_odbc.h @@ -41,7 +41,7 @@ #ifndef TQSQL_ODBC_H #define TQSQL_ODBC_H -#include +#include #include #include #include diff --git a/src/sql/drivers/sqlite3/tqsql_sqlite3.cpp b/src/sql/drivers/sqlite3/tqsql_sqlite3.cpp index 61edda2c0..afa21ac86 100644 --- a/src/sql/drivers/sqlite3/tqsql_sqlite3.cpp +++ b/src/sql/drivers/sqlite3/tqsql_sqlite3.cpp @@ -15,7 +15,7 @@ #include "tqsql_sqlite3.h" #include -#include +#include #include #include #include diff --git a/src/sql/tqdatatable.cpp b/src/sql/tqdatatable.cpp index 9d8468c06..bb81ff6c1 100644 --- a/src/sql/tqdatatable.cpp +++ b/src/sql/tqdatatable.cpp @@ -49,7 +49,7 @@ #include "ntqlayout.h" #include "ntqpainter.h" #include "ntqpopupmenu.h" -#include "ntqvaluelist.h" +#include "tqvaluelist.h" #include "tqsqlmanager_p.h" #include "ntqdatetime.h" #include "ntqcursor.h" diff --git a/src/sql/tqsqldriver.h b/src/sql/tqsqldriver.h index 08a6f43de..ba865f099 100644 --- a/src/sql/tqsqldriver.h +++ b/src/sql/tqsqldriver.h @@ -50,7 +50,7 @@ #include "tqsqlfield.h" #include "tqsqlindex.h" #include "ntqstringlist.h" -#include "ntqmap.h" +#include "tqmap.h" #endif // QT_H #if !defined( TQT_MODULE_SQL ) || defined( QT_LICENSE_PROFESSIONAL ) diff --git a/src/sql/tqsqlextension_p.h b/src/sql/tqsqlextension_p.h index c4ea2850c..9989b3a31 100644 --- a/src/sql/tqsqlextension_p.h +++ b/src/sql/tqsqlextension_p.h @@ -54,8 +54,8 @@ // #ifndef QT_H -#include "ntqmap.h" -#include "ntqvaluevector.h" +#include "tqmap.h" +#include "tqvaluevector.h" #include "ntqstring.h" #include "ntqvariant.h" #include "tqsql.h" diff --git a/src/sql/tqsqlform.h b/src/sql/tqsqlform.h index 7771f7b70..cdd00b7cd 100644 --- a/src/sql/tqsqlform.h +++ b/src/sql/tqsqlform.h @@ -43,7 +43,7 @@ #ifndef QT_H #include "tqobject.h" -#include "ntqmap.h" +#include "tqmap.h" #endif // QT_H #if !defined( TQT_MODULE_SQL ) || defined( QT_LICENSE_PROFESSIONAL ) diff --git a/src/sql/tqsqlpropertymap.cpp b/src/sql/tqsqlpropertymap.cpp index 67451029d..6e4f2d4cc 100644 --- a/src/sql/tqsqlpropertymap.cpp +++ b/src/sql/tqsqlpropertymap.cpp @@ -45,7 +45,7 @@ #include "tqwidget.h" #include "ntqcleanuphandler.h" #include "ntqmetaobject.h" -#include "ntqmap.h" +#include "tqmap.h" class TQSqlPropertyMapPrivate { diff --git a/src/sql/tqsqlquery.h b/src/sql/tqsqlquery.h index eea5eea72..39df825aa 100644 --- a/src/sql/tqsqlquery.h +++ b/src/sql/tqsqlquery.h @@ -45,7 +45,7 @@ #include "tqobject.h" #include "ntqstring.h" #include "ntqvariant.h" -#include "ntqvaluelist.h" +#include "tqvaluelist.h" #include "tqsqlerror.h" #include "tqsqlfield.h" #include "tqsql.h" diff --git a/src/sql/tqsqlrecord.cpp b/src/sql/tqsqlrecord.cpp index b12541f8b..e6c93b1eb 100644 --- a/src/sql/tqsqlrecord.cpp +++ b/src/sql/tqsqlrecord.cpp @@ -43,7 +43,7 @@ #ifndef TQT_NO_SQL #include "ntqregexp.h" -#include "ntqvaluevector.h" +#include "tqvaluevector.h" #include "ntqshared.h" #include "ntqnamespace.h" diff --git a/src/tools/ntqmap.h b/src/tools/ntqmap.h deleted file mode 100644 index f1c41be96..000000000 --- a/src/tools/ntqmap.h +++ /dev/null @@ -1,881 +0,0 @@ -/**************************************************************************** -** -** Definition of TQMap class -** -** Created : 990406 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the tools module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQMAP_H -#define TQMAP_H - -#ifndef QT_H -#include "ntqglobal.h" -#include "ntqshared.h" -#include "ntqdatastream.h" -#include "ntqpair.h" -#include "ntqvaluelist.h" -#endif // QT_H - -#ifndef TQT_NO_STL -#include -#include -#include -#endif - -//#define QT_CHECK_MAP_RANGE - -struct TQ_EXPORT TQMapNodeBase -{ - enum Color { Red, Black }; - - TQMapNodeBase* left; - TQMapNodeBase* right; - TQMapNodeBase* parent; - - Color color; - - TQMapNodeBase* minimum() { - TQMapNodeBase* x = this; - while ( x->left ) - x = x->left; - return x; - } - - TQMapNodeBase* maximum() { - TQMapNodeBase* x = this; - while ( x->right ) - x = x->right; - return x; - } -}; - - -template -struct TQMapNode : public TQMapNodeBase -{ - TQMapNode( const K& _key, const T& _data ) { data = _data; key = _key; } - TQMapNode( const K& _key ) { key = _key; } - TQMapNode( const TQMapNode& _n ) { key = _n.key; data = _n.data; } - TQMapNode() { } - T data; - K key; -}; - - -template -class TQMapIterator -{ - public: - /** - * Typedefs - */ - typedef TQMapNode< K, T >* NodePtr; -#ifndef TQT_NO_STL - typedef std::bidirectional_iterator_tag iterator_category; -#endif - typedef T value_type; -#ifndef TQT_NO_STL - typedef ptrdiff_t difference_type; -#else - typedef int difference_type; -#endif - typedef T* pointer; - typedef T& reference; - - /** - * Variables - */ - TQMapNode* node; - - /** - * Functions - */ - TQMapIterator() : node( 0 ) {} - TQMapIterator( TQMapNode* p ) : node( p ) {} - TQMapIterator( const TQMapIterator& it ) : node( it.node ) {} - - bool operator==( const TQMapIterator& it ) const { return node == it.node; } - bool operator!=( const TQMapIterator& it ) const { return node != it.node; } - T& operator*() { return node->data; } - const T& operator*() const { return node->data; } - // UDT for T = x* - // T* operator->() const { return &node->data; } - - const K& key() const { return node->key; } - T& data() { return node->data; } - const T& data() const { return node->data; } - -private: - int inc(); - int dec(); - -public: - TQMapIterator& operator++() { - inc(); - return *this; - } - - TQMapIterator operator++(int) { - TQMapIterator tmp = *this; - inc(); - return tmp; - } - - TQMapIterator& operator--() { - dec(); - return *this; - } - - TQMapIterator operator--(int) { - TQMapIterator tmp = *this; - dec(); - return tmp; - } -}; - -template -TQ_INLINE_TEMPLATES int TQMapIterator::inc() -{ - TQMapNodeBase* tmp = node; - if ( tmp->right ) { - tmp = tmp->right; - while ( tmp->left ) - tmp = tmp->left; - } else { - TQMapNodeBase* y = tmp->parent; - while (tmp == y->right) { - tmp = y; - y = y->parent; - } - if (tmp->right != y) - tmp = y; - } - node = (NodePtr)tmp; - return 0; -} - -template -TQ_INLINE_TEMPLATES int TQMapIterator::dec() -{ - TQMapNodeBase* tmp = node; - if (tmp->color == TQMapNodeBase::Red && - tmp->parent->parent == tmp ) { - tmp = tmp->right; - } else if (tmp->left != 0) { - TQMapNodeBase* y = tmp->left; - while ( y->right ) - y = y->right; - tmp = y; - } else { - TQMapNodeBase* y = tmp->parent; - while (tmp == y->left) { - tmp = y; - y = y->parent; - } - tmp = y; - } - node = (NodePtr)tmp; - return 0; -} - -template -class TQMapConstIterator -{ - public: - /** - * Typedefs - */ - typedef TQMapNode< K, T >* NodePtr; -#ifndef TQT_NO_STL - typedef std::bidirectional_iterator_tag iterator_category; -#endif - typedef T value_type; -#ifndef TQT_NO_STL - typedef ptrdiff_t difference_type; -#else - typedef int difference_type; -#endif - typedef const T* pointer; - typedef const T& reference; - - - /** - * Variables - */ - TQMapNode* node; - - /** - * Functions - */ - TQMapConstIterator() : node( 0 ) {} - TQMapConstIterator( TQMapNode* p ) : node( p ) {} - TQMapConstIterator( const TQMapConstIterator& it ) : node( it.node ) {} - TQMapConstIterator( const TQMapIterator& it ) : node( it.node ) {} - - bool operator==( const TQMapConstIterator& it ) const { return node == it.node; } - bool operator!=( const TQMapConstIterator& it ) const { return node != it.node; } - const T& operator*() const { return node->data; } - // UDT for T = x* - // const T* operator->() const { return &node->data; } - - const K& key() const { return node->key; } - const T& data() const { return node->data; } - -private: - int inc(); - int dec(); - -public: - TQMapConstIterator& operator++() { - inc(); - return *this; - } - - TQMapConstIterator operator++(int) { - TQMapConstIterator tmp = *this; - inc(); - return tmp; - } - - TQMapConstIterator& operator--() { - dec(); - return *this; - } - - TQMapConstIterator operator--(int) { - TQMapConstIterator tmp = *this; - dec(); - return tmp; - } -}; - -template -TQ_INLINE_TEMPLATES int TQMapConstIterator::inc() -{ - TQMapNodeBase* tmp = node; - if ( tmp->right ) { - tmp = tmp->right; - while ( tmp->left ) - tmp = tmp->left; - } else { - TQMapNodeBase* y = tmp->parent; - while (tmp == y->right) { - tmp = y; - y = y->parent; - } - if (tmp->right != y) - tmp = y; - } - node = (NodePtr)tmp; - return 0; -} - -template -TQ_INLINE_TEMPLATES int TQMapConstIterator::dec() -{ - TQMapNodeBase* tmp = node; - if (tmp->color == TQMapNodeBase::Red && - tmp->parent->parent == tmp ) { - tmp = tmp->right; - } else if (tmp->left != 0) { - TQMapNodeBase* y = tmp->left; - while ( y->right ) - y = y->right; - tmp = y; - } else { - TQMapNodeBase* y = tmp->parent; - while (tmp == y->left) { - tmp = y; - y = y->parent; - } - tmp = y; - } - node = (NodePtr)tmp; - return 0; -} - -// ### 4.0: rename to something without Private in it. Not really internal. -class TQ_EXPORT TQMapPrivateBase : public TQShared -{ -public: - TQMapPrivateBase() { - node_count = 0; - } - TQMapPrivateBase( const TQMapPrivateBase* _map) { - node_count = _map->node_count; - } - - /** - * Implementations of basic tree algorithms - */ - void rotateLeft( TQMapNodeBase* x, TQMapNodeBase*& root); - void rotateRight( TQMapNodeBase* x, TQMapNodeBase*& root ); - void rebalance( TQMapNodeBase* x, TQMapNodeBase*& root ); - TQMapNodeBase* removeAndRebalance( TQMapNodeBase* z, TQMapNodeBase*& root, - TQMapNodeBase*& leftmost, - TQMapNodeBase*& rightmost ); - - /** - * Variables - */ - int node_count; -}; - - -template -class TQMapPrivate : public TQMapPrivateBase -{ -public: - /** - * Typedefs - */ - typedef TQMapIterator< Key, T > Iterator; - typedef TQMapConstIterator< Key, T > ConstIterator; - typedef TQMapNode< Key, T > Node; - typedef TQMapNode< Key, T >* NodePtr; - - /** - * Functions - */ - TQMapPrivate(); - TQMapPrivate( const TQMapPrivate< Key, T >* _map ); - ~TQMapPrivate() { clear(); delete header; } - - NodePtr copy( NodePtr p ); - void clear(); - void clear( NodePtr p ); - - Iterator begin() { return Iterator( (NodePtr)(header->left ) ); } - Iterator end() { return Iterator( header ); } - ConstIterator begin() const { return ConstIterator( (NodePtr)(header->left ) ); } - ConstIterator end() const { return ConstIterator( header ); } - - ConstIterator find(const Key& k) const; - - void remove( Iterator it ) { - NodePtr del = (NodePtr) removeAndRebalance( it.node, header->parent, header->left, header->right ); - delete del; - --node_count; - } - -#ifdef QT_QMAP_DEBUG - void inorder( TQMapNodeBase* x = 0, int level = 0 ){ - if ( !x ) - x = header->parent; - if ( x->left ) - inorder( x->left, level + 1 ); - //cout << level << " Key=" << key(x) << " Value=" << ((NodePtr)x)->data << endl; - if ( x->right ) - inorder( x->right, level + 1 ); - } -#endif - -#if 0 - Iterator insertMulti(const Key& v){ - TQMapNodeBase* y = header; - TQMapNodeBase* x = header->parent; - while (x != 0){ - y = x; - x = ( v < key(x) ) ? x->left : x->right; - } - return insert(x, y, v); - } -#endif - - Iterator insertSingle( const Key& k ); - Iterator insert( TQMapNodeBase* x, TQMapNodeBase* y, const Key& k ); - -protected: - /** - * Helpers - */ - const Key& key( TQMapNodeBase* b ) const { return ((NodePtr)b)->key; } - - /** - * Variables - */ - NodePtr header; -}; - - -template -TQ_INLINE_TEMPLATES TQMapPrivate::TQMapPrivate() { - header = new Node; - header->color = TQMapNodeBase::Red; // Mark the header - header->parent = 0; - header->left = header->right = header; -} -template -TQ_INLINE_TEMPLATES TQMapPrivate::TQMapPrivate( const TQMapPrivate< Key, T >* _map ) : TQMapPrivateBase( _map ) { - header = new Node; - header->color = TQMapNodeBase::Red; // Mark the header - if ( _map->header->parent == 0 ) { - header->parent = 0; - header->left = header->right = header; - } else { - header->parent = copy( (NodePtr)(_map->header->parent) ); - header->parent->parent = header; - header->left = header->parent->minimum(); - header->right = header->parent->maximum(); - } -} - -template -TQ_INLINE_TEMPLATES TQ_TYPENAME TQMapPrivate::NodePtr TQMapPrivate::copy( TQ_TYPENAME TQMapPrivate::NodePtr p ) -{ - if ( !p ) - return 0; - NodePtr n = new Node( *p ); - n->color = p->color; - if ( p->left ) { - n->left = copy( (NodePtr)(p->left) ); - n->left->parent = n; - } else { - n->left = 0; - } - if ( p->right ) { - n->right = copy( (NodePtr)(p->right) ); - n->right->parent = n; - } else { - n->right = 0; - } - return n; -} - -template -TQ_INLINE_TEMPLATES void TQMapPrivate::clear() -{ - clear( (NodePtr)(header->parent) ); - header->color = TQMapNodeBase::Red; - header->parent = 0; - header->left = header->right = header; - node_count = 0; -} - -template -TQ_INLINE_TEMPLATES void TQMapPrivate::clear( TQ_TYPENAME TQMapPrivate::NodePtr p ) -{ - while ( p != 0 ) { - clear( (NodePtr)p->right ); - NodePtr y = (NodePtr)p->left; - delete p; - p = y; - } -} - -template -TQ_INLINE_TEMPLATES TQ_TYPENAME TQMapPrivate::ConstIterator TQMapPrivate::find(const Key& k) const -{ - TQMapNodeBase* y = header; // Last node - TQMapNodeBase* x = header->parent; // Root node. - - while ( x != 0 ) { - // If as k <= key(x) go left - if ( !( key(x) < k ) ) { - y = x; - x = x->left; - } else { - x = x->right; - } - } - - // Was k bigger/smaller then the biggest/smallest - // element of the tree ? Return end() - if ( y == header || k < key(y) ) - return ConstIterator( header ); - return ConstIterator( (NodePtr)y ); -} - -template -TQ_INLINE_TEMPLATES TQ_TYPENAME TQMapPrivate::Iterator TQMapPrivate::insertSingle( const Key& k ) -{ - // Search correct position in the tree - TQMapNodeBase* y = header; - TQMapNodeBase* x = header->parent; - bool result = TRUE; - while ( x != 0 ) { - result = ( k < key(x) ); - y = x; - x = result ? x->left : x->right; - } - // Get iterator on the last not empty one - Iterator j( (NodePtr)y ); - if ( result ) { - // Smaller then the leftmost one ? - if ( j == begin() ) { - return insert(x, y, k ); - } else { - // Perhaps daddy is the right one ? - --j; - } - } - // Really bigger ? - if ( (j.node->key) < k ) - return insert(x, y, k ); - // We are going to replace a node - return j; -} - - -template -TQ_INLINE_TEMPLATES TQ_TYPENAME TQMapPrivate::Iterator TQMapPrivate::insert( TQMapNodeBase* x, TQMapNodeBase* y, const Key& k ) -{ - NodePtr z = new Node( k ); - if (y == header || x != 0 || k < key(y) ) { - y->left = z; // also makes leftmost = z when y == header - if ( y == header ) { - header->parent = z; - header->right = z; - } else if ( y == header->left ) - header->left = z; // maintain leftmost pointing to min node - } else { - y->right = z; - if ( y == header->right ) - header->right = z; // maintain rightmost pointing to max node - } - z->parent = y; - z->left = 0; - z->right = 0; - rebalance( z, header->parent ); - ++node_count; - return Iterator(z); -} - - -#ifdef QT_CHECK_RANGE -# if !defined( TQT_NO_DEBUG ) && defined( QT_CHECK_MAP_RANGE ) -# define TQT_CHECK_INVALID_MAP_ELEMENT if ( empty() ) tqWarning( "TQMap: Warning invalid element" ) -# define TQT_CHECK_INVALID_MAP_ELEMENT_FATAL Q_ASSERT( !empty() ); -# else -# define TQT_CHECK_INVALID_MAP_ELEMENT -# define TQT_CHECK_INVALID_MAP_ELEMENT_FATAL -# endif -#else -# define TQT_CHECK_INVALID_MAP_ELEMENT -# define TQT_CHECK_INVALID_MAP_ELEMENT_FATAL -#endif - -template class TQDeepCopy; - -template -class TQMap -{ -public: - /** - * Typedefs - */ - typedef Key key_type; - typedef T mapped_type; - typedef TQPair value_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef value_type& reference; - typedef const value_type& const_reference; -#ifndef TQT_NO_STL - typedef ptrdiff_t difference_type; -#else - typedef int difference_type; -#endif - typedef size_t size_type; - typedef TQMapIterator iterator; - typedef TQMapConstIterator const_iterator; - typedef TQPair insert_pair; - - typedef TQMapIterator< Key, T > Iterator; - typedef TQMapConstIterator< Key, T > ConstIterator; - typedef T ValueType; - typedef TQMapPrivate< Key, T > Priv; - - /** - * API - */ - TQMap() - { - sh = new TQMapPrivate< Key, T >; - } - TQMap( const TQMap& m ) - { - sh = m.sh; sh->ref(); - } - -#ifndef TQT_NO_STL - TQMap( const std::map& m ) - { - sh = new TQMapPrivate; - TQ_TYPENAME std::map::const_iterator it = m.begin(); - for ( ; it != m.end(); ++it ) { - value_type p( (*it).first, (*it).second ); - insert( p ); - } - } -#endif - ~TQMap() - { - if ( sh ) { - if ( sh->deref() ) { - delete sh; - sh = 0L; - } - } - } - TQMap& operator= ( const TQMap& m ); -#ifndef TQT_NO_STL - TQMap& operator= ( const std::map& m ) - { - clear(); - TQ_TYPENAME std::map::const_iterator it = m.begin(); - for ( ; it != m.end(); ++it ) { - value_type p( (*it).first, (*it).second ); - insert( p ); - } - return *this; - } -#endif - - iterator begin() { detach(); return sh->begin(); } - iterator end() { detach(); return sh->end(); } - const_iterator begin() const { return ((const Priv*)sh)->begin(); } - const_iterator end() const { return ((const Priv*)sh)->end(); } - const_iterator constBegin() const { return begin(); } - const_iterator constEnd() const { return end(); } - - iterator replace( const Key& k, const T& v ) - { - remove( k ); - return insert( k, v ); - } - - size_type size() const - { - return sh->node_count; - } - bool empty() const - { - return sh->node_count == 0; - } - TQPair insert( const value_type& x ); - - void erase( iterator it ) - { - detach(); - sh->remove( it ); - } - void erase( const key_type& k ); - size_type count( const key_type& k ) const; - T& operator[] ( const Key& k ); - void clear(); - - iterator find ( const Key& k ) - { - detach(); - return iterator( sh->find( k ).node ); - } - const_iterator find ( const Key& k ) const { return sh->find( k ); } - - const T& operator[] ( const Key& k ) const - { TQT_CHECK_INVALID_MAP_ELEMENT; return sh->find( k ).data(); } - bool contains ( const Key& k ) const - { return find( k ) != end(); } - //{ return sh->find( k ) != ((const Priv*)sh)->end(); } - - size_type count() const { return sh->node_count; } - - TQValueList keys() const { - TQValueList r; - for (const_iterator i=begin(); i!=end(); ++i) - r.append(i.key()); - return r; - } - - TQValueList values() const { - TQValueList r; - for (const_iterator i=begin(); i!=end(); ++i) - r.append(*i); - return r; - } - - bool isEmpty() const { return sh->node_count == 0; } - - iterator insert( const Key& key, const T& value, bool overwrite = TRUE ); - void remove( iterator it ) { detach(); sh->remove( it ); } - void remove( const Key& k ); - -#if defined(TQ_FULL_TEMPLATE_INSTANTIATION) - bool operator==( const TQMap& ) const { return FALSE; } -#ifndef TQT_NO_STL - bool operator==( const std::map& ) const { return FALSE; } -#endif -#endif - -protected: - /** - * Helpers - */ - void detach() { if ( sh->count > 1 ) detachInternal(); } - - Priv* sh; -private: - void detachInternal(); - - friend class TQDeepCopy< TQMap >; -}; - -template -TQ_INLINE_TEMPLATES TQMap& TQMap::operator= ( const TQMap& m ) -{ - m.sh->ref(); - if ( sh->deref() ) - delete sh; - sh = m.sh; - return *this; -} - -template -TQ_INLINE_TEMPLATES TQ_TYPENAME TQMap::insert_pair TQMap::insert( const TQ_TYPENAME TQMap::value_type& x ) -{ - detach(); - size_type n = size(); - iterator it = sh->insertSingle( x.first ); - bool inserted = FALSE; - if ( n < size() ) { - inserted = TRUE; - it.data() = x.second; - } - return TQPair( it, inserted ); -} - -template -TQ_INLINE_TEMPLATES void TQMap::erase( const Key& k ) -{ - detach(); - iterator it( sh->find( k ).node ); - if ( it != end() ) - sh->remove( it ); -} - -template -TQ_INLINE_TEMPLATES TQ_TYPENAME TQMap::size_type TQMap::count( const Key& k ) const -{ - const_iterator it( sh->find( k ).node ); - if ( it != end() ) { - size_type c = 0; - while ( it != end() ) { - ++it; - ++c; - } - return c; - } - return 0; -} - -template -TQ_INLINE_TEMPLATES T& TQMap::operator[] ( const Key& k ) -{ - detach(); - TQMapNode* p = sh->find( k ).node; - if ( p != sh->end().node ) - return p->data; - return insert( k, T() ).data(); -} - -template -TQ_INLINE_TEMPLATES void TQMap::clear() -{ - if ( sh->count == 1 ) - sh->clear(); - else { - sh->deref(); - sh = new TQMapPrivate; - } -} - -template -TQ_INLINE_TEMPLATES TQ_TYPENAME TQMap::iterator TQMap::insert( const Key& key, const T& value, bool overwrite ) -{ - detach(); - size_type n = size(); - iterator it = sh->insertSingle( key ); - if ( overwrite || n < size() ) - it.data() = value; - return it; -} - -template -TQ_INLINE_TEMPLATES void TQMap::remove( const Key& k ) -{ - detach(); - iterator it( sh->find( k ).node ); - if ( it != end() ) - sh->remove( it ); -} - -template -TQ_INLINE_TEMPLATES void TQMap::detachInternal() -{ - sh->deref(); sh = new TQMapPrivate( sh ); -} - - -#ifndef TQT_NO_DATASTREAM -template -TQ_INLINE_TEMPLATES TQDataStream& operator>>( TQDataStream& s, TQMap& m ) { - m.clear(); - TQ_UINT32 c; - s >> c; - for( TQ_UINT32 i = 0; i < c; ++i ) { - Key k; T t; - s >> k >> t; - m.insert( k, t ); - if ( s.atEnd() ) - break; - } - return s; -} - - -template -TQ_INLINE_TEMPLATES TQDataStream& operator<<( TQDataStream& s, const TQMap& m ) { - s << (TQ_UINT32)m.size(); - TQMapConstIterator it = m.begin(); - for( ; it != m.end(); ++it ) - s << it.key() << it.data(); - return s; -} -#endif - -#define Q_DEFINED_QMAP -#include "ntqwinexport.h" -#endif // TQMAP_H diff --git a/src/tools/ntqpair.h b/src/tools/ntqpair.h deleted file mode 100644 index cd1614685..000000000 --- a/src/tools/ntqpair.h +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Definition of TQPair class -** -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the tools module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQPAIR_H -#define TQPAIR_H - -#ifndef QT_H -#include "ntqglobal.h" -#include "ntqdatastream.h" -#endif // QT_H - -template -struct TQPair -{ - typedef T1 first_type; - typedef T2 second_type; - - TQPair() - : first( T1() ), second( T2() ) - {} - TQPair( const T1& t1, const T2& t2 ) - : first( t1 ), second( t2 ) - {} - - TQPair& operator=(const TQPair& other) - { - if (this != &other) { - first = other.first; - second = other.second; - } - return *this; - } - - T1 first; - T2 second; -}; - -template -TQ_INLINE_TEMPLATES bool operator==( const TQPair& x, const TQPair& y ) -{ - return x.first == y.first && x.second == y.second; -} - -template -TQ_INLINE_TEMPLATES bool operator<( const TQPair& x, const TQPair& y ) -{ - return x.first < y.first || - ( !( y.first < x.first ) && x.second < y.second ); -} - -template -TQ_INLINE_TEMPLATES TQPair qMakePair( const T1& x, const T2& y ) -{ - return TQPair( x, y ); -} - -#ifndef TQT_NO_DATASTREAM -template -inline TQDataStream& operator>>( TQDataStream& s, TQPair& p ) -{ - s >> p.first >> p.second; - return s; -} - -template -inline TQDataStream& operator<<( TQDataStream& s, const TQPair& p ) -{ - s << p.first << p.second; - return s; -} -#endif - -#endif diff --git a/src/tools/ntqstringlist.h b/src/tools/ntqstringlist.h index 7bda85877..219af2bf5 100644 --- a/src/tools/ntqstringlist.h +++ b/src/tools/ntqstringlist.h @@ -42,7 +42,7 @@ #define TQSTRINGLIST_H #ifndef QT_H -#include "ntqvaluelist.h" +#include "tqvaluelist.h" #include "ntqstring.h" #include "ntqstrlist.h" #endif // QT_H diff --git a/src/tools/ntqvaluelist.h b/src/tools/ntqvaluelist.h deleted file mode 100644 index 4056290df..000000000 --- a/src/tools/ntqvaluelist.h +++ /dev/null @@ -1,681 +0,0 @@ -/**************************************************************************** -** -** Definition of TQValueList class -** -** Created : 990406 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the tools module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQVALUELIST_H -#define TQVALUELIST_H - -#ifndef QT_H -#include "ntqtl.h" -#include "ntqshared.h" -#include "ntqdatastream.h" -#endif // QT_H - -#ifndef TQT_NO_STL -#include -#include -#include -#endif - -//#define QT_CHECK_VALUELIST_RANGE - -template -class TQValueListNode -{ -public: - TQValueListNode( const T& t ) : data( t ) { } - TQValueListNode() { } -#if defined(Q_TEMPLATEDLL) - // Workaround MS bug in memory de/allocation in DLL vs. EXE - virtual ~TQValueListNode() { } -#endif - - TQValueListNode* next; - TQValueListNode* prev; - T data; -}; - -template -class TQValueListIterator -{ - public: - /** - * Typedefs - */ - typedef TQValueListNode* NodePtr; -#ifndef TQT_NO_STL - typedef std::bidirectional_iterator_tag iterator_category; -#endif - typedef T value_type; - typedef size_t size_type; -#ifndef TQT_NO_STL - typedef ptrdiff_t difference_type; -#else - typedef int difference_type; -#endif - typedef T* pointer; - typedef T& reference; - - /** - * Variables - */ - NodePtr node; - - /** - * Functions - */ - TQValueListIterator() : node( 0 ) {} - TQValueListIterator( NodePtr p ) : node( p ) {} - TQValueListIterator( const TQValueListIterator& it ) : node( it.node ) {} - - bool operator==( const TQValueListIterator& it ) const { return node == it.node; } - bool operator!=( const TQValueListIterator& it ) const { return node != it.node; } - const T& operator*() const { return node->data; } - T& operator*() { return node->data; } - const T* operator->() const { return &node->data; } - T* operator->() { return &node->data; } - - TQValueListIterator& operator++() { - node = node->next; - return *this; - } - - TQValueListIterator operator++(int) { - TQValueListIterator tmp = *this; - node = node->next; - return tmp; - } - - TQValueListIterator& operator--() { - node = node->prev; - return *this; - } - - TQValueListIterator operator--(int) { - TQValueListIterator tmp = *this; - node = node->prev; - return tmp; - } - - TQValueListIterator& operator+=( int j ) { - while ( j-- ) - node = node->next; - return *this; - } - - TQValueListIterator& operator-=( int j ) { - while ( j-- ) - node = node->prev; - return *this; - } - -}; - -template -class TQValueListConstIterator -{ - public: - /** - * Typedefs - */ - typedef TQValueListNode* NodePtr; -#ifndef TQT_NO_STL - typedef std::bidirectional_iterator_tag iterator_category; -#endif - typedef T value_type; - typedef size_t size_type; -#ifndef TQT_NO_STL - typedef ptrdiff_t difference_type; -#else - typedef int difference_type; -#endif - typedef const T* pointer; - typedef const T& reference; - - /** - * Variables - */ - NodePtr node; - - /** - * Functions - */ - TQValueListConstIterator() : node( 0 ) {} - TQValueListConstIterator( NodePtr p ) : node( p ) {} - TQValueListConstIterator( const TQValueListConstIterator& it ) : node( it.node ) {} - TQValueListConstIterator( const TQValueListIterator& it ) : node( it.node ) {} - - bool operator==( const TQValueListConstIterator& it ) const { return node == it.node; } - bool operator!=( const TQValueListConstIterator& it ) const { return node != it.node; } - const T& operator*() const { return node->data; } - // UDT for T = x* - // const T* operator->() const { return &node->data; } - - TQValueListConstIterator& operator++() { - node = node->next; - return *this; - } - - TQValueListConstIterator operator++(int) { - TQValueListConstIterator tmp = *this; - node = node->next; - return tmp; - } - - TQValueListConstIterator& operator--() { - node = node->prev; - return *this; - } - - TQValueListConstIterator operator--(int) { - TQValueListConstIterator tmp = *this; - node = node->prev; - return tmp; - } -}; - -template -class TQValueListPrivate : public TQShared -{ -public: - /** - * Typedefs - */ - typedef TQValueListIterator Iterator; - typedef TQValueListConstIterator ConstIterator; - typedef TQValueListNode Node; - typedef TQValueListNode* NodePtr; - typedef size_t size_type; - - /** - * Functions - */ - TQValueListPrivate(); - TQValueListPrivate( const TQValueListPrivate& _p ); - -#if defined(Q_TEMPLATEDLL) - // Workaround MS bug in memory de/allocation in DLL vs. EXE - virtual -#endif - ~TQValueListPrivate(); - - Iterator insert( Iterator it, const T& x ); - Iterator remove( Iterator it ); - NodePtr find( NodePtr start, const T& x ) const; - int findIndex( NodePtr start, const T& x ) const; - uint contains( const T& x ) const; - bool containsYesNo( const T& x ) const; - uint remove( const T& x ); - NodePtr at( size_type i ) const; - void clear(); - - NodePtr node; - size_type nodes; -}; - -template -TQ_INLINE_TEMPLATES TQValueListPrivate::TQValueListPrivate() -{ - node = new Node(); node->next = node->prev = node; nodes = 0; -} - -template -TQ_INLINE_TEMPLATES TQValueListPrivate::TQValueListPrivate( const TQValueListPrivate& _p ) - : TQShared() -{ - node = new Node(); node->next = node->prev = node; nodes = 0; - Iterator b( _p.node->next ); - Iterator e( _p.node ); - Iterator i( node ); - while( b != e ) - insert( i, *b++ ); -} - -template -TQ_INLINE_TEMPLATES TQValueListPrivate::~TQValueListPrivate() { - NodePtr p = node->next; - while( p != node ) { - NodePtr x = p->next; - delete p; - p = x; - } - delete node; -} - -template -TQ_INLINE_TEMPLATES TQ_TYPENAME TQValueListPrivate::Iterator TQValueListPrivate::insert( TQ_TYPENAME TQValueListPrivate::Iterator it, const T& x ) -{ - NodePtr p = new Node( x ); - p->next = it.node; - p->prev = it.node->prev; - it.node->prev->next = p; - it.node->prev = p; - nodes++; - return p; -} - -template -TQ_INLINE_TEMPLATES TQ_TYPENAME TQValueListPrivate::Iterator TQValueListPrivate::remove( TQ_TYPENAME TQValueListPrivate::Iterator it ) -{ - Q_ASSERT ( it.node != node ); - NodePtr next = it.node->next; - NodePtr prev = it.node->prev; - prev->next = next; - next->prev = prev; - delete it.node; - nodes--; - return Iterator( next ); -} - -template -TQ_INLINE_TEMPLATES TQ_TYPENAME TQValueListPrivate::NodePtr TQValueListPrivate::find( TQ_TYPENAME TQValueListPrivate::NodePtr start, const T& x ) const -{ - ConstIterator first( start ); - ConstIterator last( node ); - while( first != last) { - if ( *first == x ) - return first.node; - ++first; - } - return last.node; -} - -template -TQ_INLINE_TEMPLATES int TQValueListPrivate::findIndex( TQ_TYPENAME TQValueListPrivate::NodePtr start, const T& x ) const -{ - ConstIterator first( start ); - ConstIterator last( node ); - int pos = 0; - while( first != last) { - if ( *first == x ) - return pos; - ++first; - ++pos; - } - return -1; -} - -template -TQ_INLINE_TEMPLATES uint TQValueListPrivate::contains( const T& x ) const -{ - uint result = 0; - Iterator first = Iterator( node->next ); - Iterator last = Iterator( node ); - while( first != last) { - if ( *first == x ) - ++result; - ++first; - } - return result; -} - -template -TQ_INLINE_TEMPLATES bool TQValueListPrivate::containsYesNo( const T& x ) const -{ - Iterator first = Iterator( node->next ); - Iterator last = Iterator( node ); - while( first != last) { - if ( *first == x ) - return true; - ++first; - } - return false; -} - -template -TQ_INLINE_TEMPLATES uint TQValueListPrivate::remove( const T& _x ) -{ - const T x = _x; - uint result = 0; - Iterator first = Iterator( node->next ); - Iterator last = Iterator( node ); - while( first != last) { - if ( *first == x ) { - first = remove( first ); - ++result; - } else - ++first; - } - return result; -} - -template -TQ_INLINE_TEMPLATES TQ_TYPENAME TQValueListPrivate::NodePtr TQValueListPrivate::at( size_type i ) const -{ - Q_ASSERT( i <= nodes ); - NodePtr p = node->next; - for( size_type x = 0; x < i; ++x ) - p = p->next; - return p; -} - -template -TQ_INLINE_TEMPLATES void TQValueListPrivate::clear() -{ - nodes = 0; - NodePtr p = node->next; - while( p != node ) { - NodePtr next = p->next; - delete p; - p = next; - } - node->next = node->prev = node; -} - -#ifdef QT_CHECK_RANGE -# if !defined( TQT_NO_DEBUG ) && defined( QT_CHECK_VALUELIST_RANGE ) -# define QT_CHECK_INVALID_LIST_ELEMENT if ( empty() ) tqWarning( "TQValueList: Warning invalid element" ) -# define QT_CHECK_INVALID_LIST_ELEMENT_FATAL Q_ASSERT( !empty() ); -# else -# define QT_CHECK_INVALID_LIST_ELEMENT -# define QT_CHECK_INVALID_LIST_ELEMENT_FATAL -# endif -#else -# define QT_CHECK_INVALID_LIST_ELEMENT -# define QT_CHECK_INVALID_LIST_ELEMENT_FATAL -#endif - -template class TQDeepCopy; - -template -class TQValueList -{ -public: - /** - * Typedefs - */ - typedef TQValueListIterator iterator; - typedef TQValueListConstIterator const_iterator; - typedef T value_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef size_t size_type; -#ifndef TQT_NO_STL - typedef ptrdiff_t difference_type; -#else - typedef int difference_type; -#endif - - /** - * API - */ - TQValueList() { sh = new TQValueListPrivate; } - TQValueList( const TQValueList& l ) { sh = l.sh; sh->ref(); } -#ifndef TQT_NO_STL - TQValueList( const std::list& l ) - { - sh = new TQValueListPrivate; - tqCopy( l.begin(), l.end(), std::back_inserter( *this ) ); - } -#endif - ~TQValueList() - { - if (sh->deref()) - delete sh; - } - - TQValueList& operator= ( const TQValueList& l ) - { - if (this == &l || sh == l.sh) - return *this; // Do nothing is self-assigning - l.sh->ref(); - if (sh->deref()) - delete sh; - sh = l.sh; - return *this; - } - -#ifndef TQT_NO_STL - TQValueList& operator= ( const std::list& l ) - { - detach(); - tqCopy( l.begin(), l.end(), std::back_inserter( *this ) ); - return *this; - } - - bool operator== ( const std::list& l ) const - { - if ( size() != l.size() ) - return FALSE; - const_iterator it2 = begin(); -#if !defined(Q_CC_MIPS) - typename -#endif - std::list::const_iterator it = l.begin(); - for ( ; it2 != end(); ++it2, ++it ) - if ( !((*it2) == (*it)) ) - return FALSE; - return TRUE; - } -#endif - bool operator== ( const TQValueList& l ) const; - bool operator!= ( const TQValueList& l ) const { return !( *this == l ); } - iterator begin() { detach(); return iterator( sh->node->next ); } - const_iterator begin() const { return const_iterator( sh->node->next ); } - const_iterator constBegin() const { return const_iterator( sh->node->next ); } - iterator end() { detach(); return iterator( sh->node ); } - const_iterator end() const { return const_iterator( sh->node ); } - const_iterator constEnd() const { return const_iterator( sh->node ); } - iterator insert( iterator it, const T& x ) { detach(); return sh->insert( it, x ); } - uint remove( const T& x ) { detach(); return sh->remove( x ); } - void clear(); - - // ### 4.0: move out of class - TQValueList& operator<< ( const T& x ) - { - append( x ); - return *this; - } - - size_type size() const { return sh->nodes; } - bool empty() const { return sh->nodes == 0; } - void push_front( const T& x ) { detach(); sh->insert( begin(), x ); } - void push_back( const T& x ) { detach(); sh->insert( end(), x ); } - iterator erase( iterator pos ) { detach(); return sh->remove( pos ); } - iterator erase( iterator first, iterator last ); - reference front() { QT_CHECK_INVALID_LIST_ELEMENT_FATAL; return *begin(); } - const_reference front() const { QT_CHECK_INVALID_LIST_ELEMENT_FATAL; return *begin(); } - reference back() { QT_CHECK_INVALID_LIST_ELEMENT_FATAL; return *(--end()); } - const_reference back() const { QT_CHECK_INVALID_LIST_ELEMENT_FATAL; return *(--end()); } - void pop_front() { QT_CHECK_INVALID_LIST_ELEMENT; erase( begin() ); } - void pop_back() { - QT_CHECK_INVALID_LIST_ELEMENT; - iterator tmp = end(); - erase( --tmp ); - } - void insert( iterator pos, size_type n, const T& x ); - // Some compilers (incl. vc++) would instantiate this function even if - // it is not used; this would constrain TQValueList to classes that provide - // an operator< - /* - void sort() - { - qHeapSort( *this ); - } - */ - - TQValueList operator+ ( const TQValueList& l ) const; - TQValueList& operator+= ( const TQValueList& l ); - - iterator fromLast() { detach(); return iterator( sh->node->prev ); } - const_iterator fromLast() const { return const_iterator( sh->node->prev ); } - - bool isEmpty() const { return ( sh->nodes == 0 ); } - - iterator append( const T& x ) { detach(); return sh->insert( end(), x ); } - iterator prepend( const T& x ) { detach(); return sh->insert( begin(), x ); } - - iterator remove( iterator it ) { detach(); return sh->remove( it ); } - - T& first() { QT_CHECK_INVALID_LIST_ELEMENT; detach(); return sh->node->next->data; } - const T& first() const { QT_CHECK_INVALID_LIST_ELEMENT; return sh->node->next->data; } - T& last() { QT_CHECK_INVALID_LIST_ELEMENT; detach(); return sh->node->prev->data; } - const T& last() const { QT_CHECK_INVALID_LIST_ELEMENT; return sh->node->prev->data; } - - T& operator[] ( size_type i ) { QT_CHECK_INVALID_LIST_ELEMENT; detach(); return sh->at(i)->data; } - const T& operator[] ( size_type i ) const { QT_CHECK_INVALID_LIST_ELEMENT; return sh->at(i)->data; } - iterator at( size_type i ) { QT_CHECK_INVALID_LIST_ELEMENT; detach(); return iterator( sh->at(i) ); } - const_iterator at( size_type i ) const { QT_CHECK_INVALID_LIST_ELEMENT; return const_iterator( sh->at(i) ); } - iterator find ( const T& x ) { detach(); return iterator( sh->find( sh->node->next, x) ); } - const_iterator find ( const T& x ) const { return const_iterator( sh->find( sh->node->next, x) ); } - iterator find ( iterator it, const T& x ) { detach(); return iterator( sh->find( it.node, x ) ); } - const_iterator find ( const_iterator it, const T& x ) const { return const_iterator( sh->find( it.node, x ) ); } - int findIndex( const T& x ) const { return sh->findIndex( sh->node->next, x) ; } - size_type contains( const T& x ) const { return sh->contains( x ); } - bool containsYesNo( const T& x ) const { return sh->containsYesNo( x ); } - - size_type count() const { return sh->nodes; } - - TQValueList& operator+= ( const T& x ) - { - append( x ); - return *this; - } - typedef TQValueListIterator Iterator; - typedef TQValueListConstIterator ConstIterator; - typedef T ValueType; - -protected: - /** - * Helpers - */ - void detach() - { - if (sh->count > 1) - { - sh->deref(); - sh = new TQValueListPrivate(*sh); - } - } - - /** - * Variables - */ - TQValueListPrivate* sh; - -private: - friend class TQDeepCopy< TQValueList >; -}; - -template -TQ_INLINE_TEMPLATES bool TQValueList::operator== ( const TQValueList& l ) const -{ - if ( size() != l.size() ) - return FALSE; - const_iterator it2 = begin(); - const_iterator it = l.begin(); - for( ; it != l.end(); ++it, ++it2 ) - if ( !( *it == *it2 ) ) - return FALSE; - return TRUE; -} - -template -TQ_INLINE_TEMPLATES void TQValueList::clear() -{ - if ( sh->count == 1 ) sh->clear(); else { sh->deref(); sh = new TQValueListPrivate(); } -} - -template -TQ_INLINE_TEMPLATES TQ_TYPENAME TQValueList::iterator TQValueList::erase( TQ_TYPENAME TQValueList::iterator first, TQ_TYPENAME TQValueList::iterator last ) -{ - while ( first != last ) - erase( first++ ); - return last; -} - - -template -TQ_INLINE_TEMPLATES void TQValueList::insert( TQ_TYPENAME TQValueList::iterator pos, size_type n, const T& x ) -{ - for ( ; n > 0; --n ) - insert( pos, x ); -} - -template -TQ_INLINE_TEMPLATES TQValueList TQValueList::operator+ ( const TQValueList& l ) const -{ - TQValueList l2( *this ); - for( const_iterator it = l.begin(); it != l.end(); ++it ) - l2.append( *it ); - return l2; -} - -template -TQ_INLINE_TEMPLATES TQValueList& TQValueList::operator+= ( const TQValueList& l ) -{ - TQValueList copy = l; - for( const_iterator it = copy.begin(); it != copy.end(); ++it ) - append( *it ); - return *this; -} - -#ifndef TQT_NO_DATASTREAM -template -TQ_INLINE_TEMPLATES TQDataStream& operator>>( TQDataStream& s, TQValueList& l ) -{ - l.clear(); - TQ_UINT32 c; - s >> c; - for( TQ_UINT32 i = 0; i < c && !s.atEnd(); ++i ) - { - T t; - s >> t; - l.append( t ); - } - return s; -} - -template -TQ_INLINE_TEMPLATES TQDataStream& operator<<( TQDataStream& s, const TQValueList& l ) -{ - s << (TQ_UINT32)l.size(); - TQValueListConstIterator it = l.begin(); - for( ; it != l.end(); ++it ) - s << *it; - return s; -} -#endif // TQT_NO_DATASTREAM - -#define Q_DEFINED_QVALUELIST -#define Q_DEFINED_QVALUELIST -#include "ntqwinexport.h" -#endif // TQVALUELIST_H diff --git a/src/tools/ntqvaluestack.h b/src/tools/ntqvaluestack.h deleted file mode 100644 index 1c1259fb1..000000000 --- a/src/tools/ntqvaluestack.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Definition of TQValueStack class -** -** Created : 990925 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the tools module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQVALUESTACK_H -#define TQVALUESTACK_H - -#ifndef QT_H -#include "ntqvaluelist.h" -#endif // QT_H - - -template -class TQValueStack : public TQValueList -{ -public: - TQValueStack() {} - ~TQValueStack() {} - void push( const T& d ) { this->append(d); } - T pop() - { - T elem( this->last() ); - if ( !this->isEmpty() ) - this->remove( this->fromLast() ); - return elem; - } - T& top() { return this->last(); } - const T& top() const { return this->last(); } -}; - -#endif diff --git a/src/tools/ntqvaluevector.h b/src/tools/ntqvaluevector.h deleted file mode 100644 index 90dc45e10..000000000 --- a/src/tools/ntqvaluevector.h +++ /dev/null @@ -1,577 +0,0 @@ -/**************************************************************************** -** -** Definition of TQValueVector class -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the tools module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQVALUEVECTOR_H -#define TQVALUEVECTOR_H - -#include - -#ifndef QT_H -#include "ntqtl.h" -#include "ntqshared.h" -#include "ntqdatastream.h" -#endif // QT_H - -#ifndef TQT_NO_STL -#include -#endif - -template -class TQValueVectorPrivate : public TQShared -{ -public: - typedef T value_type; - typedef T* pointer; - - TQValueVectorPrivate() - : start( 0 ), finish( 0 ), end( 0 ) - { - } - - TQValueVectorPrivate( const TQValueVectorPrivate& x ); - TQValueVectorPrivate( size_t size ); - - void derefAndDelete() // work-around for hp-cc - { - if ( deref() ) - delete this; - } - -#if defined(Q_TEMPLATEDLL) - // Workaround MS bug in memory de/allocation in DLL vs. EXE - virtual -#endif - ~TQValueVectorPrivate() - { - delete[] start; - } - - size_t size() const - { - return finish - start; - } - - bool empty() const - { - return start == finish; - } - - size_t capacity() const - { - return end - start; - } - - void insert( pointer pos, const T& x ); - void insert( pointer pos, size_t n, const T& x ); - void reserve( size_t n ); - - void clear() - { - delete[] start; - start = 0; - finish = 0; - end = 0; - } - - - pointer start; - pointer finish; - pointer end; - -private: - pointer growAndCopy( size_t n, pointer s, pointer f ); - - TQValueVectorPrivate& operator=( const TQValueVectorPrivate& x ); - -}; - -template -TQ_INLINE_TEMPLATES TQValueVectorPrivate::TQValueVectorPrivate( const TQValueVectorPrivate& x ) - : TQShared() -{ - size_t i = x.size(); - if ( i > 0 ) { - start = new T[ i ]; - finish = start + i; - end = start + i; -#if defined(__xlC__) && __xlC__ < 0x400 // xlC 3.6 confused by const - tqCopy( (pointer)x.start, (pointer)x.finish, start ); -#else - tqCopy( x.start, x.finish, start ); -#endif - } else { - start = 0; - finish = 0; - end = 0; - } -} - -template -TQ_INLINE_TEMPLATES TQValueVectorPrivate::TQValueVectorPrivate( size_t size ) -{ - if ( size > 0 ) { - start = new T[size]; - finish = start + size; - end = start + size; - } else { - start = 0; - finish = 0; - end = 0; - } -} - -template -TQ_INLINE_TEMPLATES void TQValueVectorPrivate::insert( pointer pos, const T& x ) -{ - const size_t lastSize = size(); - const size_t n = lastSize !=0 ? 2*lastSize : 1; - const size_t offset = pos - start; - pointer newStart = new T[n]; - pointer newFinish = newStart + offset; - tqCopy( start, pos, newStart ); - *newFinish = x; - tqCopy( pos, finish, ++newFinish ); - delete[] start; - start = newStart; - finish = newStart + lastSize + 1; - end = newStart + n; -} - -template -TQ_INLINE_TEMPLATES void TQValueVectorPrivate::insert( pointer pos, size_t n, const T& x ) -{ - if ( size_t( end - finish ) >= n ) { - // enough room - const size_t elems_after = finish - pos; - pointer old_finish = finish; - if ( elems_after > n ) { - tqCopy( finish - n, finish, finish ); - finish += n; - tqCopyBackward( pos, old_finish - n, old_finish ); - tqFill( pos, pos + n, x ); - } else { - pointer filler = finish; - size_t i = n - elems_after; - for ( ; i > 0; --i, ++filler ) - *filler = x; - finish += n - elems_after; - tqCopy( pos, old_finish, finish ); - finish += elems_after; - tqFill( pos, old_finish, x ); - } - } else { - // not enough room - const size_t lastSize = size(); - const size_t len = lastSize + TQMAX( lastSize, n ); - pointer newStart = new T[len]; - pointer newFinish = tqCopy( start, pos, newStart ); - // fill up inserted space - size_t i = n; - for ( ; i > 0; --i, ++newFinish ) - *newFinish = x; - newFinish = tqCopy( pos, finish, newFinish ); - delete[] start; - start = newStart; - finish = newFinish; - end = newStart + len; - } -} - -template -TQ_INLINE_TEMPLATES void TQValueVectorPrivate::reserve( size_t n ) -{ - const size_t lastSize = size(); - pointer tmp = growAndCopy( n, start, finish ); - start = tmp; - finish = tmp + lastSize; - end = start + n; -} - -template -TQ_INLINE_TEMPLATES TQ_TYPENAME TQValueVectorPrivate::pointer TQValueVectorPrivate::growAndCopy( size_t n, pointer s, pointer f ) -{ - pointer newStart = new T[n]; - tqCopy( s, f, newStart ); - delete[] start; - return newStart; -} - -template class TQDeepCopy; - -template -class TQValueVector -{ -public: - typedef T value_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef value_type* iterator; - typedef const value_type* const_iterator; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef size_t size_type; -#ifndef TQT_NO_STL - typedef ptrdiff_t difference_type; -#else - typedef int difference_type; -#endif - - TQValueVector() - { - sh = new TQValueVectorPrivate; - } - - TQValueVector( const TQValueVector& v ) - { - sh = v.sh; - sh->ref(); - } - - TQValueVector( size_type n, const T& val = T() ); - -#ifndef TQT_NO_STL - TQValueVector( std::vector& v ) // ### remove in 4.0 - { - sh = new TQValueVectorPrivate( v.size() ); - tqCopy( v.begin(), v.end(), begin() ); - } - - TQValueVector( const std::vector& v ) - { - sh = new TQValueVectorPrivate( v.size() ); - tqCopy( v.begin(), v.end(), begin() ); - } -#endif - - ~TQValueVector() - { - sh->derefAndDelete(); - } - - TQValueVector& operator= ( const TQValueVector& v ) - { - v.sh->ref(); - sh->derefAndDelete(); - sh = v.sh; - return *this; - } - -#ifndef TQT_NO_STL - TQValueVector& operator= ( const std::vector& v ) - { - clear(); - resize( v.size() ); - tqCopy( v.begin(), v.end(), begin() ); - return *this; - } -#endif - - size_type size() const { return sh->size(); } - - bool empty() const { return sh->empty(); } - - size_type capacity() const - { - return size_type( sh->capacity() ); - } - - iterator begin() - { - detach(); - return sh->start; - } - - const_iterator begin() const - { - return sh->start; - } - - const_iterator constBegin() const - { - return sh->start; - } - - iterator end() - { - detach(); - return sh->finish; - } - - const_iterator end() const - { - return sh->finish; - } - - const_iterator constEnd() const - { - return sh->finish; - } - - reference at( size_type i, bool* ok = 0 ) - { - detach(); - if ( ok ) - *ok = ( i < size() ); - return *( begin() + i ); - } - - const_reference at( size_type i, bool* ok = 0 ) const - { - if ( ok ) - *ok = ( i < size() ); - return *( begin() + i ); - } - - reference operator[]( size_type i ) - { - detach(); - return *( begin() + i ); - } - - const_reference operator[]( size_type i ) const - { - return *( begin() + i ); - } - - reference front() - { - Q_ASSERT( !empty() ); - detach(); - return *begin(); - } - - const_reference front() const - { - Q_ASSERT( !empty() ); - return *begin(); - } - - reference back() - { - Q_ASSERT( !empty() ); - detach(); - return *( end() - 1 ); - } - - const_reference back() const - { - Q_ASSERT( !empty() ); - return *( end() - 1 ); - } - - void push_back( const T& x ) - { - detach(); - if ( sh->finish == sh->end ) { - sh->reserve( size()+size()/2+1 ); - } - *sh->finish = x; - ++sh->finish; - } - - void pop_back() - { - detach(); - if ( empty() ) - return; - --sh->finish; - } - - iterator insert( iterator pos, const T& x ); - iterator insert( iterator pos, size_type n, const T& x ); - - void reserve( size_type n ) - { - if ( capacity() < n ) { - detach(); - sh->reserve( n ); - } - } - - void resize( size_type n, const T& val = T() ) - { - if ( n < size() ) - erase( begin() + n, end() ); - else - insert( end(), n - size(), val ); - } - - void clear() - { - detach(); - sh->clear(); - } - - iterator erase( iterator pos ) - { - detach(); - if ( pos + 1 != end() ) - tqCopy( pos + 1, sh->finish, pos ); - --sh->finish; - return pos; - } - - iterator erase( iterator first, iterator last ) - { - detach(); - tqCopy( last, sh->finish, first ); - sh->finish = sh->finish - ( last - first ); - return first; - } - - // ### remove in TQt 4.0 - bool operator==( const TQValueVector& x ) - { - return size()==x.size() ? tqEqual( constBegin(), constEnd(), x.begin()) : FALSE; - } - - bool operator==( const TQValueVector& x ) const - { - return size()==x.size() ? tqEqual( begin(), end(), x.begin() ) : FALSE; - } - - typedef T ValueType; - typedef ValueType *Iterator; - typedef const ValueType *ConstIterator; - - size_type count() const { return size(); } - bool isEmpty() const { return empty(); } - - reference first() { return front(); } - const_reference first() const { return front(); } - reference last() { return back(); } - const_reference last() const { return back(); } - void append( const T& x ) { push_back( x ); } - -protected: - void detach() - { - if ( sh->count > 1 ) { detachInternal(); } - } - void detachInternal(); - TQValueVectorPrivate* sh; - -private: - friend class TQDeepCopy< TQValueVector >; -}; - -template -TQ_INLINE_TEMPLATES TQValueVector::TQValueVector( size_type n, const T& val ) -{ - sh = new TQValueVectorPrivate( n ); - tqFill( begin(), end(), val ); -} - -template -TQ_INLINE_TEMPLATES void TQValueVector::detachInternal() -{ - sh->deref(); - sh = new TQValueVectorPrivate( *sh ); -} - -template -TQ_INLINE_TEMPLATES TQ_TYPENAME TQValueVector::iterator TQValueVector::insert( iterator pos, const T& x ) -{ - size_type offset = pos - sh->start; - detach(); - if ( pos == end() ) { - if ( sh->finish == sh->end ) - push_back( x ); - else { - *sh->finish = x; - ++sh->finish; - } - } else { - if ( sh->finish == sh->end ) { - sh->insert( pos, x ); - } else { - *sh->finish = *(sh->finish - 1); - ++sh->finish; - tqCopyBackward( pos, sh->finish - 2, sh->finish - 1 ); - *pos = x; - } - } - return begin() + offset; -} - -template -TQ_INLINE_TEMPLATES TQ_TYPENAME TQValueVector::iterator TQValueVector::insert( iterator pos, size_type n, const T& x ) -{ - if ( n != 0 ) { - size_type offset = pos - sh->start; - detach(); - pos = begin() + offset; - sh->insert( pos, n, x ); - } - return pos; -} - - -#ifndef TQT_NO_DATASTREAM -template -TQ_INLINE_TEMPLATES TQDataStream& operator>>( TQDataStream& s, TQValueVector& v ) -{ - v.clear(); - TQ_UINT32 c; - s >> c; - v.resize( c ); - for( TQ_UINT32 i = 0; i < c; ++i ) - { - T t; - s >> t; - v[i] = t; - } - return s; -} - -template -TQ_INLINE_TEMPLATES TQDataStream& operator<<( TQDataStream& s, const TQValueVector& v ) -{ - s << (TQ_UINT32)v.size(); - // ### use typename TQValueVector::const_iterator once all supported - // ### compilers know about the 'typename' keyword. - const T* it = v.begin(); - for( ; it != v.end(); ++it ) - s << *it; - return s; -} -#endif // TQT_NO_DATASTREAM - -#define Q_DEFINED_QVALUEVECTOR -#include "ntqwinexport.h" -#endif // TQVALUEVECTOR_H diff --git a/src/tools/qdir_p.h b/src/tools/qdir_p.h index 4538e5b26..91138abb5 100644 --- a/src/tools/qdir_p.h +++ b/src/tools/qdir_p.h @@ -56,7 +56,7 @@ #ifndef QT_H #include "ntqregexp.h" -#include "ntqvaluelist.h" +#include "tqvaluelist.h" #endif // QT_H extern TQValueList qt_makeFilterList( const TQString & ); diff --git a/src/tools/qglist.cpp b/src/tools/qglist.cpp index 9dbe81d92..979297870 100644 --- a/src/tools/qglist.cpp +++ b/src/tools/qglist.cpp @@ -41,7 +41,7 @@ #include "ntqglist.h" #include "ntqgvector.h" #include "ntqdatastream.h" -#include "ntqvaluelist.h" +#include "tqvaluelist.h" #if defined(TQT_THREAD_SUPPORT) #include "ntqmutex.h" diff --git a/src/tools/qgpluginmanager.cpp b/src/tools/qgpluginmanager.cpp index c1d6e15f0..dc72dad30 100644 --- a/src/tools/qgpluginmanager.cpp +++ b/src/tools/qgpluginmanager.cpp @@ -39,7 +39,7 @@ #include "qgpluginmanager_p.h" #ifndef TQT_NO_COMPONENT #include "qcomlibrary_p.h" -#include "ntqmap.h" +#include "tqmap.h" #include "ntqdir.h" /* diff --git a/src/tools/qmap.cpp b/src/tools/qmap.cpp deleted file mode 100644 index 4c2884501..000000000 --- a/src/tools/qmap.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQMap -** -** Created : 990406 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the tools module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "ntqmap.h" - -typedef TQMapNodeBase* NodePtr; -typedef TQMapNodeBase Node; - - -void TQMapPrivateBase::rotateLeft( NodePtr x, NodePtr& root) -{ - NodePtr y = x->right; - x->right = y->left; - if (y->left !=0) - y->left->parent = x; - y->parent = x->parent; - if (x == root) - root = y; - else if (x == x->parent->left) - x->parent->left = y; - else - x->parent->right = y; - y->left = x; - x->parent = y; -} - - -void TQMapPrivateBase::rotateRight( NodePtr x, NodePtr& root ) -{ - NodePtr y = x->left; - x->left = y->right; - if (y->right != 0) - y->right->parent = x; - y->parent = x->parent; - if (x == root) - root = y; - else if (x == x->parent->right) - x->parent->right = y; - else - x->parent->left = y; - y->right = x; - x->parent = y; -} - - -void TQMapPrivateBase::rebalance( NodePtr x, NodePtr& root) -{ - x->color = Node::Red; - while ( x != root && x->parent->color == Node::Red ) { - if ( x->parent == x->parent->parent->left ) { - NodePtr y = x->parent->parent->right; - if (y && y->color == Node::Red) { - x->parent->color = Node::Black; - y->color = Node::Black; - x->parent->parent->color = Node::Red; - x = x->parent->parent; - } else { - if (x == x->parent->right) { - x = x->parent; - rotateLeft( x, root ); - } - x->parent->color = Node::Black; - x->parent->parent->color = Node::Red; - rotateRight (x->parent->parent, root ); - } - } else { - NodePtr y = x->parent->parent->left; - if ( y && y->color == Node::Red ) { - x->parent->color = Node::Black; - y->color = Node::Black; - x->parent->parent->color = Node::Red; - x = x->parent->parent; - } else { - if (x == x->parent->left) { - x = x->parent; - rotateRight( x, root ); - } - x->parent->color = Node::Black; - x->parent->parent->color = Node::Red; - rotateLeft( x->parent->parent, root ); - } - } - } - root->color = Node::Black; -} - - -NodePtr TQMapPrivateBase::removeAndRebalance( NodePtr z, NodePtr& root, - NodePtr& leftmost, - NodePtr& rightmost ) -{ - NodePtr y = z; - NodePtr x; - NodePtr x_parent; - if (y->left == 0) { - x = y->right; - } else { - if (y->right == 0) - x = y->left; - else - { - y = y->right; - while (y->left != 0) - y = y->left; - x = y->right; - } - } - if (y != z) { - z->left->parent = y; - y->left = z->left; - if (y != z->right) { - x_parent = y->parent; - if (x) - x->parent = y->parent; - y->parent->left = x; - y->right = z->right; - z->right->parent = y; - } else { - x_parent = y; - } - if (root == z) - root = y; - else if (z->parent->left == z) - z->parent->left = y; - else - z->parent->right = y; - y->parent = z->parent; - // Swap the colors - Node::Color c = y->color; - y->color = z->color; - z->color = c; - y = z; - } else { - x_parent = y->parent; - if (x) - x->parent = y->parent; - if (root == z) - root = x; - else if (z->parent->left == z) - z->parent->left = x; - else - z->parent->right = x; - if ( leftmost == z ) { - if (z->right == 0) - leftmost = z->parent; - else - leftmost = x->minimum(); - } - if (rightmost == z) { - if (z->left == 0) - rightmost = z->parent; - else - rightmost = x->maximum(); - } - } - if (y->color != Node::Red) { - while (x != root && (x == 0 || x->color == Node::Black)) { - if (x == x_parent->left) { - NodePtr w = x_parent->right; - if (w->color == Node::Red) { - w->color = Node::Black; - x_parent->color = Node::Red; - rotateLeft(x_parent, root); - w = x_parent->right; - } - if ((w->left == 0 || w->left->color == Node::Black) && - (w->right == 0 || w->right->color == Node::Black)) { - w->color = Node::Red; - x = x_parent; - x_parent = x_parent->parent; - } else { - if (w->right == 0 || w->right->color == Node::Black) { - if (w->left) - w->left->color = Node::Black; - w->color = Node::Red; - rotateRight(w, root); - w = x_parent->right; - } - w->color = x_parent->color; - x_parent->color = Node::Black; - if (w->right) - w->right->color = Node::Black; - rotateLeft(x_parent, root); - break; - } - } else { - NodePtr w = x_parent->left; - if (w->color == Node::Red) { - w->color = Node::Black; - x_parent->color = Node::Red; - rotateRight(x_parent, root); - w = x_parent->left; - } - if ((w->right == 0 || w->right->color == Node::Black) && - (w->left == 0 || w->left->color == Node::Black)) { - w->color = Node::Red; - x = x_parent; - x_parent = x_parent->parent; - } else { - if (w->left == 0 || w->left->color == Node::Black) { - if (w->right) - w->right->color = Node::Black; - w->color = Node::Red; - rotateLeft(w, root); - w = x_parent->left; - } - w->color = x_parent->color; - x_parent->color = Node::Black; - if (w->left) - w->left->color = Node::Black; - rotateRight(x_parent, root); - break; - } - } - } - if (x) - x->color = Node::Black; - } - return y; -} diff --git a/src/tools/qregexp.cpp b/src/tools/qregexp.cpp index 5c0fac766..19b983f75 100644 --- a/src/tools/qregexp.cpp +++ b/src/tools/qregexp.cpp @@ -47,7 +47,7 @@ #include "ntqcache.h" #include "ntqcleanuphandler.h" #include "ntqintdict.h" -#include "ntqmap.h" +#include "tqmap.h" #include "ntqptrvector.h" #include "ntqstring.h" #include "ntqtl.h" diff --git a/src/tools/qsettings.cpp b/src/tools/qsettings.cpp index 6ac18bcc7..ecaa3f7d6 100644 --- a/src/tools/qsettings.cpp +++ b/src/tools/qsettings.cpp @@ -60,7 +60,7 @@ static inline int qt_open( const char *pathname, int flags, mode_t mode ) #include "ntqdir.h" #include "ntqfile.h" #include "ntqfileinfo.h" -#include "ntqmap.h" +#include "tqmap.h" #include "ntqtextstream.h" #include "ntqregexp.h" #include diff --git a/src/tools/qsettings_p.h b/src/tools/qsettings_p.h index 6dcd1a037..303466cd5 100644 --- a/src/tools/qsettings_p.h +++ b/src/tools/qsettings_p.h @@ -55,8 +55,8 @@ #ifndef QT_H #include "ntqstringlist.h" -#include "ntqmap.h" -#include "ntqvaluestack.h" +#include "tqmap.h" +#include "tqvaluestack.h" #endif // QT_H #ifndef TQT_NO_SETTINGS diff --git a/src/tools/qt_tools.pri b/src/tools/qt_tools.pri index 7153653b8..5026f3791 100644 --- a/src/tools/qt_tools.pri +++ b/src/tools/qt_tools.pri @@ -37,7 +37,7 @@ tools { $$TOOLS_H/ntqlocale.h \ $$TOOLS_P/qlocale_p.h \ $$TOOLS_H/ntqptrlist.h \ - $$TOOLS_H/ntqmap.h \ + $$TOOLS_H/tqmap.h \ $$TOOLS_H/ntqmutex.h \ $$TOOLS_P/qmutex_p.h \ $$TOOLS_P/qmutexpool_p.h \ @@ -60,9 +60,9 @@ tools { $$TOOLS_H/ntqthreadstorage.h\ $$TOOLS_P/qunicodetables_p.h \ $$TOOLS_H/ntqptrvector.h \ - $$TOOLS_H/ntqvaluelist.h \ - $$TOOLS_H/ntqvaluestack.h \ - $$TOOLS_H/ntqvaluevector.h \ + $$TOOLS_H/tqvaluelist.h \ + $$TOOLS_H/tqvaluestack.h \ + $$TOOLS_H/tqvaluevector.h \ $$TOOLS_H/ntqwaitcondition.h \ $$TOOLS_P/qcom_p.h \ $$TOOLS_P/qucom_p.h \ @@ -127,7 +127,7 @@ tools { $$TOOLS_CPP/qiodevice.cpp \ $$TOOLS_CPP/qlibrary.cpp \ $$TOOLS_CPP/qlocale.cpp \ - $$TOOLS_CPP/qmap.cpp \ + $$TOOLS_CPP/tqmap.cpp \ $$TOOLS_CPP/qmutexpool.cpp \ $$TOOLS_CPP/qptrcollection.cpp \ $$TOOLS_CPP/qregexp.cpp \ diff --git a/src/tools/qwinexport.cpp b/src/tools/qwinexport.cpp index 1584aa817..244db1cea 100644 --- a/src/tools/qwinexport.cpp +++ b/src/tools/qwinexport.cpp @@ -20,12 +20,12 @@ #include #include #include -#include +#include #include #include #include #include -#include -#include +#include +#include #include #include diff --git a/src/tools/tqmap.cpp b/src/tools/tqmap.cpp new file mode 100644 index 000000000..cbc874c63 --- /dev/null +++ b/src/tools/tqmap.cpp @@ -0,0 +1,257 @@ +/**************************************************************************** +** +** Implementation of TQMap +** +** Created : 990406 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "tqmap.h" + +typedef TQMapNodeBase* NodePtr; +typedef TQMapNodeBase Node; + + +void TQMapPrivateBase::rotateLeft( NodePtr x, NodePtr& root) +{ + NodePtr y = x->right; + x->right = y->left; + if (y->left !=0) + y->left->parent = x; + y->parent = x->parent; + if (x == root) + root = y; + else if (x == x->parent->left) + x->parent->left = y; + else + x->parent->right = y; + y->left = x; + x->parent = y; +} + + +void TQMapPrivateBase::rotateRight( NodePtr x, NodePtr& root ) +{ + NodePtr y = x->left; + x->left = y->right; + if (y->right != 0) + y->right->parent = x; + y->parent = x->parent; + if (x == root) + root = y; + else if (x == x->parent->right) + x->parent->right = y; + else + x->parent->left = y; + y->right = x; + x->parent = y; +} + + +void TQMapPrivateBase::rebalance( NodePtr x, NodePtr& root) +{ + x->color = Node::Red; + while ( x != root && x->parent->color == Node::Red ) { + if ( x->parent == x->parent->parent->left ) { + NodePtr y = x->parent->parent->right; + if (y && y->color == Node::Red) { + x->parent->color = Node::Black; + y->color = Node::Black; + x->parent->parent->color = Node::Red; + x = x->parent->parent; + } else { + if (x == x->parent->right) { + x = x->parent; + rotateLeft( x, root ); + } + x->parent->color = Node::Black; + x->parent->parent->color = Node::Red; + rotateRight (x->parent->parent, root ); + } + } else { + NodePtr y = x->parent->parent->left; + if ( y && y->color == Node::Red ) { + x->parent->color = Node::Black; + y->color = Node::Black; + x->parent->parent->color = Node::Red; + x = x->parent->parent; + } else { + if (x == x->parent->left) { + x = x->parent; + rotateRight( x, root ); + } + x->parent->color = Node::Black; + x->parent->parent->color = Node::Red; + rotateLeft( x->parent->parent, root ); + } + } + } + root->color = Node::Black; +} + + +NodePtr TQMapPrivateBase::removeAndRebalance( NodePtr z, NodePtr& root, + NodePtr& leftmost, + NodePtr& rightmost ) +{ + NodePtr y = z; + NodePtr x; + NodePtr x_parent; + if (y->left == 0) { + x = y->right; + } else { + if (y->right == 0) + x = y->left; + else + { + y = y->right; + while (y->left != 0) + y = y->left; + x = y->right; + } + } + if (y != z) { + z->left->parent = y; + y->left = z->left; + if (y != z->right) { + x_parent = y->parent; + if (x) + x->parent = y->parent; + y->parent->left = x; + y->right = z->right; + z->right->parent = y; + } else { + x_parent = y; + } + if (root == z) + root = y; + else if (z->parent->left == z) + z->parent->left = y; + else + z->parent->right = y; + y->parent = z->parent; + // Swap the colors + Node::Color c = y->color; + y->color = z->color; + z->color = c; + y = z; + } else { + x_parent = y->parent; + if (x) + x->parent = y->parent; + if (root == z) + root = x; + else if (z->parent->left == z) + z->parent->left = x; + else + z->parent->right = x; + if ( leftmost == z ) { + if (z->right == 0) + leftmost = z->parent; + else + leftmost = x->minimum(); + } + if (rightmost == z) { + if (z->left == 0) + rightmost = z->parent; + else + rightmost = x->maximum(); + } + } + if (y->color != Node::Red) { + while (x != root && (x == 0 || x->color == Node::Black)) { + if (x == x_parent->left) { + NodePtr w = x_parent->right; + if (w->color == Node::Red) { + w->color = Node::Black; + x_parent->color = Node::Red; + rotateLeft(x_parent, root); + w = x_parent->right; + } + if ((w->left == 0 || w->left->color == Node::Black) && + (w->right == 0 || w->right->color == Node::Black)) { + w->color = Node::Red; + x = x_parent; + x_parent = x_parent->parent; + } else { + if (w->right == 0 || w->right->color == Node::Black) { + if (w->left) + w->left->color = Node::Black; + w->color = Node::Red; + rotateRight(w, root); + w = x_parent->right; + } + w->color = x_parent->color; + x_parent->color = Node::Black; + if (w->right) + w->right->color = Node::Black; + rotateLeft(x_parent, root); + break; + } + } else { + NodePtr w = x_parent->left; + if (w->color == Node::Red) { + w->color = Node::Black; + x_parent->color = Node::Red; + rotateRight(x_parent, root); + w = x_parent->left; + } + if ((w->right == 0 || w->right->color == Node::Black) && + (w->left == 0 || w->left->color == Node::Black)) { + w->color = Node::Red; + x = x_parent; + x_parent = x_parent->parent; + } else { + if (w->left == 0 || w->left->color == Node::Black) { + if (w->right) + w->right->color = Node::Black; + w->color = Node::Red; + rotateLeft(w, root); + w = x_parent->left; + } + w->color = x_parent->color; + x_parent->color = Node::Black; + if (w->left) + w->left->color = Node::Black; + rotateRight(x_parent, root); + break; + } + } + } + if (x) + x->color = Node::Black; + } + return y; +} diff --git a/src/tools/tqmap.h b/src/tools/tqmap.h new file mode 100644 index 000000000..97a21883a --- /dev/null +++ b/src/tools/tqmap.h @@ -0,0 +1,881 @@ +/**************************************************************************** +** +** Definition of TQMap class +** +** Created : 990406 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQMAP_H +#define TQMAP_H + +#ifndef QT_H +#include "ntqglobal.h" +#include "ntqshared.h" +#include "ntqdatastream.h" +#include "tqpair.h" +#include "tqvaluelist.h" +#endif // QT_H + +#ifndef TQT_NO_STL +#include +#include +#include +#endif + +//#define QT_CHECK_MAP_RANGE + +struct TQ_EXPORT TQMapNodeBase +{ + enum Color { Red, Black }; + + TQMapNodeBase* left; + TQMapNodeBase* right; + TQMapNodeBase* parent; + + Color color; + + TQMapNodeBase* minimum() { + TQMapNodeBase* x = this; + while ( x->left ) + x = x->left; + return x; + } + + TQMapNodeBase* maximum() { + TQMapNodeBase* x = this; + while ( x->right ) + x = x->right; + return x; + } +}; + + +template +struct TQMapNode : public TQMapNodeBase +{ + TQMapNode( const K& _key, const T& _data ) { data = _data; key = _key; } + TQMapNode( const K& _key ) { key = _key; } + TQMapNode( const TQMapNode& _n ) { key = _n.key; data = _n.data; } + TQMapNode() { } + T data; + K key; +}; + + +template +class TQMapIterator +{ + public: + /** + * Typedefs + */ + typedef TQMapNode< K, T >* NodePtr; +#ifndef TQT_NO_STL + typedef std::bidirectional_iterator_tag iterator_category; +#endif + typedef T value_type; +#ifndef TQT_NO_STL + typedef ptrdiff_t difference_type; +#else + typedef int difference_type; +#endif + typedef T* pointer; + typedef T& reference; + + /** + * Variables + */ + TQMapNode* node; + + /** + * Functions + */ + TQMapIterator() : node( 0 ) {} + TQMapIterator( TQMapNode* p ) : node( p ) {} + TQMapIterator( const TQMapIterator& it ) : node( it.node ) {} + + bool operator==( const TQMapIterator& it ) const { return node == it.node; } + bool operator!=( const TQMapIterator& it ) const { return node != it.node; } + T& operator*() { return node->data; } + const T& operator*() const { return node->data; } + // UDT for T = x* + // T* operator->() const { return &node->data; } + + const K& key() const { return node->key; } + T& data() { return node->data; } + const T& data() const { return node->data; } + +private: + int inc(); + int dec(); + +public: + TQMapIterator& operator++() { + inc(); + return *this; + } + + TQMapIterator operator++(int) { + TQMapIterator tmp = *this; + inc(); + return tmp; + } + + TQMapIterator& operator--() { + dec(); + return *this; + } + + TQMapIterator operator--(int) { + TQMapIterator tmp = *this; + dec(); + return tmp; + } +}; + +template +TQ_INLINE_TEMPLATES int TQMapIterator::inc() +{ + TQMapNodeBase* tmp = node; + if ( tmp->right ) { + tmp = tmp->right; + while ( tmp->left ) + tmp = tmp->left; + } else { + TQMapNodeBase* y = tmp->parent; + while (tmp == y->right) { + tmp = y; + y = y->parent; + } + if (tmp->right != y) + tmp = y; + } + node = (NodePtr)tmp; + return 0; +} + +template +TQ_INLINE_TEMPLATES int TQMapIterator::dec() +{ + TQMapNodeBase* tmp = node; + if (tmp->color == TQMapNodeBase::Red && + tmp->parent->parent == tmp ) { + tmp = tmp->right; + } else if (tmp->left != 0) { + TQMapNodeBase* y = tmp->left; + while ( y->right ) + y = y->right; + tmp = y; + } else { + TQMapNodeBase* y = tmp->parent; + while (tmp == y->left) { + tmp = y; + y = y->parent; + } + tmp = y; + } + node = (NodePtr)tmp; + return 0; +} + +template +class TQMapConstIterator +{ + public: + /** + * Typedefs + */ + typedef TQMapNode< K, T >* NodePtr; +#ifndef TQT_NO_STL + typedef std::bidirectional_iterator_tag iterator_category; +#endif + typedef T value_type; +#ifndef TQT_NO_STL + typedef ptrdiff_t difference_type; +#else + typedef int difference_type; +#endif + typedef const T* pointer; + typedef const T& reference; + + + /** + * Variables + */ + TQMapNode* node; + + /** + * Functions + */ + TQMapConstIterator() : node( 0 ) {} + TQMapConstIterator( TQMapNode* p ) : node( p ) {} + TQMapConstIterator( const TQMapConstIterator& it ) : node( it.node ) {} + TQMapConstIterator( const TQMapIterator& it ) : node( it.node ) {} + + bool operator==( const TQMapConstIterator& it ) const { return node == it.node; } + bool operator!=( const TQMapConstIterator& it ) const { return node != it.node; } + const T& operator*() const { return node->data; } + // UDT for T = x* + // const T* operator->() const { return &node->data; } + + const K& key() const { return node->key; } + const T& data() const { return node->data; } + +private: + int inc(); + int dec(); + +public: + TQMapConstIterator& operator++() { + inc(); + return *this; + } + + TQMapConstIterator operator++(int) { + TQMapConstIterator tmp = *this; + inc(); + return tmp; + } + + TQMapConstIterator& operator--() { + dec(); + return *this; + } + + TQMapConstIterator operator--(int) { + TQMapConstIterator tmp = *this; + dec(); + return tmp; + } +}; + +template +TQ_INLINE_TEMPLATES int TQMapConstIterator::inc() +{ + TQMapNodeBase* tmp = node; + if ( tmp->right ) { + tmp = tmp->right; + while ( tmp->left ) + tmp = tmp->left; + } else { + TQMapNodeBase* y = tmp->parent; + while (tmp == y->right) { + tmp = y; + y = y->parent; + } + if (tmp->right != y) + tmp = y; + } + node = (NodePtr)tmp; + return 0; +} + +template +TQ_INLINE_TEMPLATES int TQMapConstIterator::dec() +{ + TQMapNodeBase* tmp = node; + if (tmp->color == TQMapNodeBase::Red && + tmp->parent->parent == tmp ) { + tmp = tmp->right; + } else if (tmp->left != 0) { + TQMapNodeBase* y = tmp->left; + while ( y->right ) + y = y->right; + tmp = y; + } else { + TQMapNodeBase* y = tmp->parent; + while (tmp == y->left) { + tmp = y; + y = y->parent; + } + tmp = y; + } + node = (NodePtr)tmp; + return 0; +} + +// ### 4.0: rename to something without Private in it. Not really internal. +class TQ_EXPORT TQMapPrivateBase : public TQShared +{ +public: + TQMapPrivateBase() { + node_count = 0; + } + TQMapPrivateBase( const TQMapPrivateBase* _map) { + node_count = _map->node_count; + } + + /** + * Implementations of basic tree algorithms + */ + void rotateLeft( TQMapNodeBase* x, TQMapNodeBase*& root); + void rotateRight( TQMapNodeBase* x, TQMapNodeBase*& root ); + void rebalance( TQMapNodeBase* x, TQMapNodeBase*& root ); + TQMapNodeBase* removeAndRebalance( TQMapNodeBase* z, TQMapNodeBase*& root, + TQMapNodeBase*& leftmost, + TQMapNodeBase*& rightmost ); + + /** + * Variables + */ + int node_count; +}; + + +template +class TQMapPrivate : public TQMapPrivateBase +{ +public: + /** + * Typedefs + */ + typedef TQMapIterator< Key, T > Iterator; + typedef TQMapConstIterator< Key, T > ConstIterator; + typedef TQMapNode< Key, T > Node; + typedef TQMapNode< Key, T >* NodePtr; + + /** + * Functions + */ + TQMapPrivate(); + TQMapPrivate( const TQMapPrivate< Key, T >* _map ); + ~TQMapPrivate() { clear(); delete header; } + + NodePtr copy( NodePtr p ); + void clear(); + void clear( NodePtr p ); + + Iterator begin() { return Iterator( (NodePtr)(header->left ) ); } + Iterator end() { return Iterator( header ); } + ConstIterator begin() const { return ConstIterator( (NodePtr)(header->left ) ); } + ConstIterator end() const { return ConstIterator( header ); } + + ConstIterator find(const Key& k) const; + + void remove( Iterator it ) { + NodePtr del = (NodePtr) removeAndRebalance( it.node, header->parent, header->left, header->right ); + delete del; + --node_count; + } + +#ifdef QT_QMAP_DEBUG + void inorder( TQMapNodeBase* x = 0, int level = 0 ){ + if ( !x ) + x = header->parent; + if ( x->left ) + inorder( x->left, level + 1 ); + //cout << level << " Key=" << key(x) << " Value=" << ((NodePtr)x)->data << endl; + if ( x->right ) + inorder( x->right, level + 1 ); + } +#endif + +#if 0 + Iterator insertMulti(const Key& v){ + TQMapNodeBase* y = header; + TQMapNodeBase* x = header->parent; + while (x != 0){ + y = x; + x = ( v < key(x) ) ? x->left : x->right; + } + return insert(x, y, v); + } +#endif + + Iterator insertSingle( const Key& k ); + Iterator insert( TQMapNodeBase* x, TQMapNodeBase* y, const Key& k ); + +protected: + /** + * Helpers + */ + const Key& key( TQMapNodeBase* b ) const { return ((NodePtr)b)->key; } + + /** + * Variables + */ + NodePtr header; +}; + + +template +TQ_INLINE_TEMPLATES TQMapPrivate::TQMapPrivate() { + header = new Node; + header->color = TQMapNodeBase::Red; // Mark the header + header->parent = 0; + header->left = header->right = header; +} +template +TQ_INLINE_TEMPLATES TQMapPrivate::TQMapPrivate( const TQMapPrivate< Key, T >* _map ) : TQMapPrivateBase( _map ) { + header = new Node; + header->color = TQMapNodeBase::Red; // Mark the header + if ( _map->header->parent == 0 ) { + header->parent = 0; + header->left = header->right = header; + } else { + header->parent = copy( (NodePtr)(_map->header->parent) ); + header->parent->parent = header; + header->left = header->parent->minimum(); + header->right = header->parent->maximum(); + } +} + +template +TQ_INLINE_TEMPLATES TQ_TYPENAME TQMapPrivate::NodePtr TQMapPrivate::copy( TQ_TYPENAME TQMapPrivate::NodePtr p ) +{ + if ( !p ) + return 0; + NodePtr n = new Node( *p ); + n->color = p->color; + if ( p->left ) { + n->left = copy( (NodePtr)(p->left) ); + n->left->parent = n; + } else { + n->left = 0; + } + if ( p->right ) { + n->right = copy( (NodePtr)(p->right) ); + n->right->parent = n; + } else { + n->right = 0; + } + return n; +} + +template +TQ_INLINE_TEMPLATES void TQMapPrivate::clear() +{ + clear( (NodePtr)(header->parent) ); + header->color = TQMapNodeBase::Red; + header->parent = 0; + header->left = header->right = header; + node_count = 0; +} + +template +TQ_INLINE_TEMPLATES void TQMapPrivate::clear( TQ_TYPENAME TQMapPrivate::NodePtr p ) +{ + while ( p != 0 ) { + clear( (NodePtr)p->right ); + NodePtr y = (NodePtr)p->left; + delete p; + p = y; + } +} + +template +TQ_INLINE_TEMPLATES TQ_TYPENAME TQMapPrivate::ConstIterator TQMapPrivate::find(const Key& k) const +{ + TQMapNodeBase* y = header; // Last node + TQMapNodeBase* x = header->parent; // Root node. + + while ( x != 0 ) { + // If as k <= key(x) go left + if ( !( key(x) < k ) ) { + y = x; + x = x->left; + } else { + x = x->right; + } + } + + // Was k bigger/smaller then the biggest/smallest + // element of the tree ? Return end() + if ( y == header || k < key(y) ) + return ConstIterator( header ); + return ConstIterator( (NodePtr)y ); +} + +template +TQ_INLINE_TEMPLATES TQ_TYPENAME TQMapPrivate::Iterator TQMapPrivate::insertSingle( const Key& k ) +{ + // Search correct position in the tree + TQMapNodeBase* y = header; + TQMapNodeBase* x = header->parent; + bool result = TRUE; + while ( x != 0 ) { + result = ( k < key(x) ); + y = x; + x = result ? x->left : x->right; + } + // Get iterator on the last not empty one + Iterator j( (NodePtr)y ); + if ( result ) { + // Smaller then the leftmost one ? + if ( j == begin() ) { + return insert(x, y, k ); + } else { + // Perhaps daddy is the right one ? + --j; + } + } + // Really bigger ? + if ( (j.node->key) < k ) + return insert(x, y, k ); + // We are going to replace a node + return j; +} + + +template +TQ_INLINE_TEMPLATES TQ_TYPENAME TQMapPrivate::Iterator TQMapPrivate::insert( TQMapNodeBase* x, TQMapNodeBase* y, const Key& k ) +{ + NodePtr z = new Node( k ); + if (y == header || x != 0 || k < key(y) ) { + y->left = z; // also makes leftmost = z when y == header + if ( y == header ) { + header->parent = z; + header->right = z; + } else if ( y == header->left ) + header->left = z; // maintain leftmost pointing to min node + } else { + y->right = z; + if ( y == header->right ) + header->right = z; // maintain rightmost pointing to max node + } + z->parent = y; + z->left = 0; + z->right = 0; + rebalance( z, header->parent ); + ++node_count; + return Iterator(z); +} + + +#ifdef QT_CHECK_RANGE +# if !defined( TQT_NO_DEBUG ) && defined( QT_CHECK_MAP_RANGE ) +# define TQT_CHECK_INVALID_MAP_ELEMENT if ( empty() ) tqWarning( "TQMap: Warning invalid element" ) +# define TQT_CHECK_INVALID_MAP_ELEMENT_FATAL Q_ASSERT( !empty() ); +# else +# define TQT_CHECK_INVALID_MAP_ELEMENT +# define TQT_CHECK_INVALID_MAP_ELEMENT_FATAL +# endif +#else +# define TQT_CHECK_INVALID_MAP_ELEMENT +# define TQT_CHECK_INVALID_MAP_ELEMENT_FATAL +#endif + +template class TQDeepCopy; + +template +class TQMap +{ +public: + /** + * Typedefs + */ + typedef Key key_type; + typedef T mapped_type; + typedef TQPair value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; +#ifndef TQT_NO_STL + typedef ptrdiff_t difference_type; +#else + typedef int difference_type; +#endif + typedef size_t size_type; + typedef TQMapIterator iterator; + typedef TQMapConstIterator const_iterator; + typedef TQPair insert_pair; + + typedef TQMapIterator< Key, T > Iterator; + typedef TQMapConstIterator< Key, T > ConstIterator; + typedef T ValueType; + typedef TQMapPrivate< Key, T > Priv; + + /** + * API + */ + TQMap() + { + sh = new TQMapPrivate< Key, T >; + } + TQMap( const TQMap& m ) + { + sh = m.sh; sh->ref(); + } + +#ifndef TQT_NO_STL + TQMap( const std::map& m ) + { + sh = new TQMapPrivate; + TQ_TYPENAME std::map::const_iterator it = m.begin(); + for ( ; it != m.end(); ++it ) { + value_type p( (*it).first, (*it).second ); + insert( p ); + } + } +#endif + ~TQMap() + { + if ( sh ) { + if ( sh->deref() ) { + delete sh; + sh = 0L; + } + } + } + TQMap& operator= ( const TQMap& m ); +#ifndef TQT_NO_STL + TQMap& operator= ( const std::map& m ) + { + clear(); + TQ_TYPENAME std::map::const_iterator it = m.begin(); + for ( ; it != m.end(); ++it ) { + value_type p( (*it).first, (*it).second ); + insert( p ); + } + return *this; + } +#endif + + iterator begin() { detach(); return sh->begin(); } + iterator end() { detach(); return sh->end(); } + const_iterator begin() const { return ((const Priv*)sh)->begin(); } + const_iterator end() const { return ((const Priv*)sh)->end(); } + const_iterator constBegin() const { return begin(); } + const_iterator constEnd() const { return end(); } + + iterator replace( const Key& k, const T& v ) + { + remove( k ); + return insert( k, v ); + } + + size_type size() const + { + return sh->node_count; + } + bool empty() const + { + return sh->node_count == 0; + } + TQPair insert( const value_type& x ); + + void erase( iterator it ) + { + detach(); + sh->remove( it ); + } + void erase( const key_type& k ); + size_type count( const key_type& k ) const; + T& operator[] ( const Key& k ); + void clear(); + + iterator find ( const Key& k ) + { + detach(); + return iterator( sh->find( k ).node ); + } + const_iterator find ( const Key& k ) const { return sh->find( k ); } + + const T& operator[] ( const Key& k ) const + { TQT_CHECK_INVALID_MAP_ELEMENT; return sh->find( k ).data(); } + bool contains ( const Key& k ) const + { return find( k ) != end(); } + //{ return sh->find( k ) != ((const Priv*)sh)->end(); } + + size_type count() const { return sh->node_count; } + + TQValueList keys() const { + TQValueList r; + for (const_iterator i=begin(); i!=end(); ++i) + r.append(i.key()); + return r; + } + + TQValueList values() const { + TQValueList r; + for (const_iterator i=begin(); i!=end(); ++i) + r.append(*i); + return r; + } + + bool isEmpty() const { return sh->node_count == 0; } + + iterator insert( const Key& key, const T& value, bool overwrite = TRUE ); + void remove( iterator it ) { detach(); sh->remove( it ); } + void remove( const Key& k ); + +#if defined(TQ_FULL_TEMPLATE_INSTANTIATION) + bool operator==( const TQMap& ) const { return FALSE; } +#ifndef TQT_NO_STL + bool operator==( const std::map& ) const { return FALSE; } +#endif +#endif + +protected: + /** + * Helpers + */ + void detach() { if ( sh->count > 1 ) detachInternal(); } + + Priv* sh; +private: + void detachInternal(); + + friend class TQDeepCopy< TQMap >; +}; + +template +TQ_INLINE_TEMPLATES TQMap& TQMap::operator= ( const TQMap& m ) +{ + m.sh->ref(); + if ( sh->deref() ) + delete sh; + sh = m.sh; + return *this; +} + +template +TQ_INLINE_TEMPLATES TQ_TYPENAME TQMap::insert_pair TQMap::insert( const TQ_TYPENAME TQMap::value_type& x ) +{ + detach(); + size_type n = size(); + iterator it = sh->insertSingle( x.first ); + bool inserted = FALSE; + if ( n < size() ) { + inserted = TRUE; + it.data() = x.second; + } + return TQPair( it, inserted ); +} + +template +TQ_INLINE_TEMPLATES void TQMap::erase( const Key& k ) +{ + detach(); + iterator it( sh->find( k ).node ); + if ( it != end() ) + sh->remove( it ); +} + +template +TQ_INLINE_TEMPLATES TQ_TYPENAME TQMap::size_type TQMap::count( const Key& k ) const +{ + const_iterator it( sh->find( k ).node ); + if ( it != end() ) { + size_type c = 0; + while ( it != end() ) { + ++it; + ++c; + } + return c; + } + return 0; +} + +template +TQ_INLINE_TEMPLATES T& TQMap::operator[] ( const Key& k ) +{ + detach(); + TQMapNode* p = sh->find( k ).node; + if ( p != sh->end().node ) + return p->data; + return insert( k, T() ).data(); +} + +template +TQ_INLINE_TEMPLATES void TQMap::clear() +{ + if ( sh->count == 1 ) + sh->clear(); + else { + sh->deref(); + sh = new TQMapPrivate; + } +} + +template +TQ_INLINE_TEMPLATES TQ_TYPENAME TQMap::iterator TQMap::insert( const Key& key, const T& value, bool overwrite ) +{ + detach(); + size_type n = size(); + iterator it = sh->insertSingle( key ); + if ( overwrite || n < size() ) + it.data() = value; + return it; +} + +template +TQ_INLINE_TEMPLATES void TQMap::remove( const Key& k ) +{ + detach(); + iterator it( sh->find( k ).node ); + if ( it != end() ) + sh->remove( it ); +} + +template +TQ_INLINE_TEMPLATES void TQMap::detachInternal() +{ + sh->deref(); sh = new TQMapPrivate( sh ); +} + + +#ifndef TQT_NO_DATASTREAM +template +TQ_INLINE_TEMPLATES TQDataStream& operator>>( TQDataStream& s, TQMap& m ) { + m.clear(); + TQ_UINT32 c; + s >> c; + for( TQ_UINT32 i = 0; i < c; ++i ) { + Key k; T t; + s >> k >> t; + m.insert( k, t ); + if ( s.atEnd() ) + break; + } + return s; +} + + +template +TQ_INLINE_TEMPLATES TQDataStream& operator<<( TQDataStream& s, const TQMap& m ) { + s << (TQ_UINT32)m.size(); + TQMapConstIterator it = m.begin(); + for( ; it != m.end(); ++it ) + s << it.key() << it.data(); + return s; +} +#endif + +#define Q_DEFINED_QMAP +#include "ntqwinexport.h" +#endif // TQMAP_H diff --git a/src/tools/tqpair.h b/src/tools/tqpair.h new file mode 100644 index 000000000..cd1614685 --- /dev/null +++ b/src/tools/tqpair.h @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Definition of TQPair class +** +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQPAIR_H +#define TQPAIR_H + +#ifndef QT_H +#include "ntqglobal.h" +#include "ntqdatastream.h" +#endif // QT_H + +template +struct TQPair +{ + typedef T1 first_type; + typedef T2 second_type; + + TQPair() + : first( T1() ), second( T2() ) + {} + TQPair( const T1& t1, const T2& t2 ) + : first( t1 ), second( t2 ) + {} + + TQPair& operator=(const TQPair& other) + { + if (this != &other) { + first = other.first; + second = other.second; + } + return *this; + } + + T1 first; + T2 second; +}; + +template +TQ_INLINE_TEMPLATES bool operator==( const TQPair& x, const TQPair& y ) +{ + return x.first == y.first && x.second == y.second; +} + +template +TQ_INLINE_TEMPLATES bool operator<( const TQPair& x, const TQPair& y ) +{ + return x.first < y.first || + ( !( y.first < x.first ) && x.second < y.second ); +} + +template +TQ_INLINE_TEMPLATES TQPair qMakePair( const T1& x, const T2& y ) +{ + return TQPair( x, y ); +} + +#ifndef TQT_NO_DATASTREAM +template +inline TQDataStream& operator>>( TQDataStream& s, TQPair& p ) +{ + s >> p.first >> p.second; + return s; +} + +template +inline TQDataStream& operator<<( TQDataStream& s, const TQPair& p ) +{ + s << p.first << p.second; + return s; +} +#endif + +#endif diff --git a/src/tools/tqvaluelist.h b/src/tools/tqvaluelist.h new file mode 100644 index 000000000..4056290df --- /dev/null +++ b/src/tools/tqvaluelist.h @@ -0,0 +1,681 @@ +/**************************************************************************** +** +** Definition of TQValueList class +** +** Created : 990406 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQVALUELIST_H +#define TQVALUELIST_H + +#ifndef QT_H +#include "ntqtl.h" +#include "ntqshared.h" +#include "ntqdatastream.h" +#endif // QT_H + +#ifndef TQT_NO_STL +#include +#include +#include +#endif + +//#define QT_CHECK_VALUELIST_RANGE + +template +class TQValueListNode +{ +public: + TQValueListNode( const T& t ) : data( t ) { } + TQValueListNode() { } +#if defined(Q_TEMPLATEDLL) + // Workaround MS bug in memory de/allocation in DLL vs. EXE + virtual ~TQValueListNode() { } +#endif + + TQValueListNode* next; + TQValueListNode* prev; + T data; +}; + +template +class TQValueListIterator +{ + public: + /** + * Typedefs + */ + typedef TQValueListNode* NodePtr; +#ifndef TQT_NO_STL + typedef std::bidirectional_iterator_tag iterator_category; +#endif + typedef T value_type; + typedef size_t size_type; +#ifndef TQT_NO_STL + typedef ptrdiff_t difference_type; +#else + typedef int difference_type; +#endif + typedef T* pointer; + typedef T& reference; + + /** + * Variables + */ + NodePtr node; + + /** + * Functions + */ + TQValueListIterator() : node( 0 ) {} + TQValueListIterator( NodePtr p ) : node( p ) {} + TQValueListIterator( const TQValueListIterator& it ) : node( it.node ) {} + + bool operator==( const TQValueListIterator& it ) const { return node == it.node; } + bool operator!=( const TQValueListIterator& it ) const { return node != it.node; } + const T& operator*() const { return node->data; } + T& operator*() { return node->data; } + const T* operator->() const { return &node->data; } + T* operator->() { return &node->data; } + + TQValueListIterator& operator++() { + node = node->next; + return *this; + } + + TQValueListIterator operator++(int) { + TQValueListIterator tmp = *this; + node = node->next; + return tmp; + } + + TQValueListIterator& operator--() { + node = node->prev; + return *this; + } + + TQValueListIterator operator--(int) { + TQValueListIterator tmp = *this; + node = node->prev; + return tmp; + } + + TQValueListIterator& operator+=( int j ) { + while ( j-- ) + node = node->next; + return *this; + } + + TQValueListIterator& operator-=( int j ) { + while ( j-- ) + node = node->prev; + return *this; + } + +}; + +template +class TQValueListConstIterator +{ + public: + /** + * Typedefs + */ + typedef TQValueListNode* NodePtr; +#ifndef TQT_NO_STL + typedef std::bidirectional_iterator_tag iterator_category; +#endif + typedef T value_type; + typedef size_t size_type; +#ifndef TQT_NO_STL + typedef ptrdiff_t difference_type; +#else + typedef int difference_type; +#endif + typedef const T* pointer; + typedef const T& reference; + + /** + * Variables + */ + NodePtr node; + + /** + * Functions + */ + TQValueListConstIterator() : node( 0 ) {} + TQValueListConstIterator( NodePtr p ) : node( p ) {} + TQValueListConstIterator( const TQValueListConstIterator& it ) : node( it.node ) {} + TQValueListConstIterator( const TQValueListIterator& it ) : node( it.node ) {} + + bool operator==( const TQValueListConstIterator& it ) const { return node == it.node; } + bool operator!=( const TQValueListConstIterator& it ) const { return node != it.node; } + const T& operator*() const { return node->data; } + // UDT for T = x* + // const T* operator->() const { return &node->data; } + + TQValueListConstIterator& operator++() { + node = node->next; + return *this; + } + + TQValueListConstIterator operator++(int) { + TQValueListConstIterator tmp = *this; + node = node->next; + return tmp; + } + + TQValueListConstIterator& operator--() { + node = node->prev; + return *this; + } + + TQValueListConstIterator operator--(int) { + TQValueListConstIterator tmp = *this; + node = node->prev; + return tmp; + } +}; + +template +class TQValueListPrivate : public TQShared +{ +public: + /** + * Typedefs + */ + typedef TQValueListIterator Iterator; + typedef TQValueListConstIterator ConstIterator; + typedef TQValueListNode Node; + typedef TQValueListNode* NodePtr; + typedef size_t size_type; + + /** + * Functions + */ + TQValueListPrivate(); + TQValueListPrivate( const TQValueListPrivate& _p ); + +#if defined(Q_TEMPLATEDLL) + // Workaround MS bug in memory de/allocation in DLL vs. EXE + virtual +#endif + ~TQValueListPrivate(); + + Iterator insert( Iterator it, const T& x ); + Iterator remove( Iterator it ); + NodePtr find( NodePtr start, const T& x ) const; + int findIndex( NodePtr start, const T& x ) const; + uint contains( const T& x ) const; + bool containsYesNo( const T& x ) const; + uint remove( const T& x ); + NodePtr at( size_type i ) const; + void clear(); + + NodePtr node; + size_type nodes; +}; + +template +TQ_INLINE_TEMPLATES TQValueListPrivate::TQValueListPrivate() +{ + node = new Node(); node->next = node->prev = node; nodes = 0; +} + +template +TQ_INLINE_TEMPLATES TQValueListPrivate::TQValueListPrivate( const TQValueListPrivate& _p ) + : TQShared() +{ + node = new Node(); node->next = node->prev = node; nodes = 0; + Iterator b( _p.node->next ); + Iterator e( _p.node ); + Iterator i( node ); + while( b != e ) + insert( i, *b++ ); +} + +template +TQ_INLINE_TEMPLATES TQValueListPrivate::~TQValueListPrivate() { + NodePtr p = node->next; + while( p != node ) { + NodePtr x = p->next; + delete p; + p = x; + } + delete node; +} + +template +TQ_INLINE_TEMPLATES TQ_TYPENAME TQValueListPrivate::Iterator TQValueListPrivate::insert( TQ_TYPENAME TQValueListPrivate::Iterator it, const T& x ) +{ + NodePtr p = new Node( x ); + p->next = it.node; + p->prev = it.node->prev; + it.node->prev->next = p; + it.node->prev = p; + nodes++; + return p; +} + +template +TQ_INLINE_TEMPLATES TQ_TYPENAME TQValueListPrivate::Iterator TQValueListPrivate::remove( TQ_TYPENAME TQValueListPrivate::Iterator it ) +{ + Q_ASSERT ( it.node != node ); + NodePtr next = it.node->next; + NodePtr prev = it.node->prev; + prev->next = next; + next->prev = prev; + delete it.node; + nodes--; + return Iterator( next ); +} + +template +TQ_INLINE_TEMPLATES TQ_TYPENAME TQValueListPrivate::NodePtr TQValueListPrivate::find( TQ_TYPENAME TQValueListPrivate::NodePtr start, const T& x ) const +{ + ConstIterator first( start ); + ConstIterator last( node ); + while( first != last) { + if ( *first == x ) + return first.node; + ++first; + } + return last.node; +} + +template +TQ_INLINE_TEMPLATES int TQValueListPrivate::findIndex( TQ_TYPENAME TQValueListPrivate::NodePtr start, const T& x ) const +{ + ConstIterator first( start ); + ConstIterator last( node ); + int pos = 0; + while( first != last) { + if ( *first == x ) + return pos; + ++first; + ++pos; + } + return -1; +} + +template +TQ_INLINE_TEMPLATES uint TQValueListPrivate::contains( const T& x ) const +{ + uint result = 0; + Iterator first = Iterator( node->next ); + Iterator last = Iterator( node ); + while( first != last) { + if ( *first == x ) + ++result; + ++first; + } + return result; +} + +template +TQ_INLINE_TEMPLATES bool TQValueListPrivate::containsYesNo( const T& x ) const +{ + Iterator first = Iterator( node->next ); + Iterator last = Iterator( node ); + while( first != last) { + if ( *first == x ) + return true; + ++first; + } + return false; +} + +template +TQ_INLINE_TEMPLATES uint TQValueListPrivate::remove( const T& _x ) +{ + const T x = _x; + uint result = 0; + Iterator first = Iterator( node->next ); + Iterator last = Iterator( node ); + while( first != last) { + if ( *first == x ) { + first = remove( first ); + ++result; + } else + ++first; + } + return result; +} + +template +TQ_INLINE_TEMPLATES TQ_TYPENAME TQValueListPrivate::NodePtr TQValueListPrivate::at( size_type i ) const +{ + Q_ASSERT( i <= nodes ); + NodePtr p = node->next; + for( size_type x = 0; x < i; ++x ) + p = p->next; + return p; +} + +template +TQ_INLINE_TEMPLATES void TQValueListPrivate::clear() +{ + nodes = 0; + NodePtr p = node->next; + while( p != node ) { + NodePtr next = p->next; + delete p; + p = next; + } + node->next = node->prev = node; +} + +#ifdef QT_CHECK_RANGE +# if !defined( TQT_NO_DEBUG ) && defined( QT_CHECK_VALUELIST_RANGE ) +# define QT_CHECK_INVALID_LIST_ELEMENT if ( empty() ) tqWarning( "TQValueList: Warning invalid element" ) +# define QT_CHECK_INVALID_LIST_ELEMENT_FATAL Q_ASSERT( !empty() ); +# else +# define QT_CHECK_INVALID_LIST_ELEMENT +# define QT_CHECK_INVALID_LIST_ELEMENT_FATAL +# endif +#else +# define QT_CHECK_INVALID_LIST_ELEMENT +# define QT_CHECK_INVALID_LIST_ELEMENT_FATAL +#endif + +template class TQDeepCopy; + +template +class TQValueList +{ +public: + /** + * Typedefs + */ + typedef TQValueListIterator iterator; + typedef TQValueListConstIterator const_iterator; + typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef size_t size_type; +#ifndef TQT_NO_STL + typedef ptrdiff_t difference_type; +#else + typedef int difference_type; +#endif + + /** + * API + */ + TQValueList() { sh = new TQValueListPrivate; } + TQValueList( const TQValueList& l ) { sh = l.sh; sh->ref(); } +#ifndef TQT_NO_STL + TQValueList( const std::list& l ) + { + sh = new TQValueListPrivate; + tqCopy( l.begin(), l.end(), std::back_inserter( *this ) ); + } +#endif + ~TQValueList() + { + if (sh->deref()) + delete sh; + } + + TQValueList& operator= ( const TQValueList& l ) + { + if (this == &l || sh == l.sh) + return *this; // Do nothing is self-assigning + l.sh->ref(); + if (sh->deref()) + delete sh; + sh = l.sh; + return *this; + } + +#ifndef TQT_NO_STL + TQValueList& operator= ( const std::list& l ) + { + detach(); + tqCopy( l.begin(), l.end(), std::back_inserter( *this ) ); + return *this; + } + + bool operator== ( const std::list& l ) const + { + if ( size() != l.size() ) + return FALSE; + const_iterator it2 = begin(); +#if !defined(Q_CC_MIPS) + typename +#endif + std::list::const_iterator it = l.begin(); + for ( ; it2 != end(); ++it2, ++it ) + if ( !((*it2) == (*it)) ) + return FALSE; + return TRUE; + } +#endif + bool operator== ( const TQValueList& l ) const; + bool operator!= ( const TQValueList& l ) const { return !( *this == l ); } + iterator begin() { detach(); return iterator( sh->node->next ); } + const_iterator begin() const { return const_iterator( sh->node->next ); } + const_iterator constBegin() const { return const_iterator( sh->node->next ); } + iterator end() { detach(); return iterator( sh->node ); } + const_iterator end() const { return const_iterator( sh->node ); } + const_iterator constEnd() const { return const_iterator( sh->node ); } + iterator insert( iterator it, const T& x ) { detach(); return sh->insert( it, x ); } + uint remove( const T& x ) { detach(); return sh->remove( x ); } + void clear(); + + // ### 4.0: move out of class + TQValueList& operator<< ( const T& x ) + { + append( x ); + return *this; + } + + size_type size() const { return sh->nodes; } + bool empty() const { return sh->nodes == 0; } + void push_front( const T& x ) { detach(); sh->insert( begin(), x ); } + void push_back( const T& x ) { detach(); sh->insert( end(), x ); } + iterator erase( iterator pos ) { detach(); return sh->remove( pos ); } + iterator erase( iterator first, iterator last ); + reference front() { QT_CHECK_INVALID_LIST_ELEMENT_FATAL; return *begin(); } + const_reference front() const { QT_CHECK_INVALID_LIST_ELEMENT_FATAL; return *begin(); } + reference back() { QT_CHECK_INVALID_LIST_ELEMENT_FATAL; return *(--end()); } + const_reference back() const { QT_CHECK_INVALID_LIST_ELEMENT_FATAL; return *(--end()); } + void pop_front() { QT_CHECK_INVALID_LIST_ELEMENT; erase( begin() ); } + void pop_back() { + QT_CHECK_INVALID_LIST_ELEMENT; + iterator tmp = end(); + erase( --tmp ); + } + void insert( iterator pos, size_type n, const T& x ); + // Some compilers (incl. vc++) would instantiate this function even if + // it is not used; this would constrain TQValueList to classes that provide + // an operator< + /* + void sort() + { + qHeapSort( *this ); + } + */ + + TQValueList operator+ ( const TQValueList& l ) const; + TQValueList& operator+= ( const TQValueList& l ); + + iterator fromLast() { detach(); return iterator( sh->node->prev ); } + const_iterator fromLast() const { return const_iterator( sh->node->prev ); } + + bool isEmpty() const { return ( sh->nodes == 0 ); } + + iterator append( const T& x ) { detach(); return sh->insert( end(), x ); } + iterator prepend( const T& x ) { detach(); return sh->insert( begin(), x ); } + + iterator remove( iterator it ) { detach(); return sh->remove( it ); } + + T& first() { QT_CHECK_INVALID_LIST_ELEMENT; detach(); return sh->node->next->data; } + const T& first() const { QT_CHECK_INVALID_LIST_ELEMENT; return sh->node->next->data; } + T& last() { QT_CHECK_INVALID_LIST_ELEMENT; detach(); return sh->node->prev->data; } + const T& last() const { QT_CHECK_INVALID_LIST_ELEMENT; return sh->node->prev->data; } + + T& operator[] ( size_type i ) { QT_CHECK_INVALID_LIST_ELEMENT; detach(); return sh->at(i)->data; } + const T& operator[] ( size_type i ) const { QT_CHECK_INVALID_LIST_ELEMENT; return sh->at(i)->data; } + iterator at( size_type i ) { QT_CHECK_INVALID_LIST_ELEMENT; detach(); return iterator( sh->at(i) ); } + const_iterator at( size_type i ) const { QT_CHECK_INVALID_LIST_ELEMENT; return const_iterator( sh->at(i) ); } + iterator find ( const T& x ) { detach(); return iterator( sh->find( sh->node->next, x) ); } + const_iterator find ( const T& x ) const { return const_iterator( sh->find( sh->node->next, x) ); } + iterator find ( iterator it, const T& x ) { detach(); return iterator( sh->find( it.node, x ) ); } + const_iterator find ( const_iterator it, const T& x ) const { return const_iterator( sh->find( it.node, x ) ); } + int findIndex( const T& x ) const { return sh->findIndex( sh->node->next, x) ; } + size_type contains( const T& x ) const { return sh->contains( x ); } + bool containsYesNo( const T& x ) const { return sh->containsYesNo( x ); } + + size_type count() const { return sh->nodes; } + + TQValueList& operator+= ( const T& x ) + { + append( x ); + return *this; + } + typedef TQValueListIterator Iterator; + typedef TQValueListConstIterator ConstIterator; + typedef T ValueType; + +protected: + /** + * Helpers + */ + void detach() + { + if (sh->count > 1) + { + sh->deref(); + sh = new TQValueListPrivate(*sh); + } + } + + /** + * Variables + */ + TQValueListPrivate* sh; + +private: + friend class TQDeepCopy< TQValueList >; +}; + +template +TQ_INLINE_TEMPLATES bool TQValueList::operator== ( const TQValueList& l ) const +{ + if ( size() != l.size() ) + return FALSE; + const_iterator it2 = begin(); + const_iterator it = l.begin(); + for( ; it != l.end(); ++it, ++it2 ) + if ( !( *it == *it2 ) ) + return FALSE; + return TRUE; +} + +template +TQ_INLINE_TEMPLATES void TQValueList::clear() +{ + if ( sh->count == 1 ) sh->clear(); else { sh->deref(); sh = new TQValueListPrivate(); } +} + +template +TQ_INLINE_TEMPLATES TQ_TYPENAME TQValueList::iterator TQValueList::erase( TQ_TYPENAME TQValueList::iterator first, TQ_TYPENAME TQValueList::iterator last ) +{ + while ( first != last ) + erase( first++ ); + return last; +} + + +template +TQ_INLINE_TEMPLATES void TQValueList::insert( TQ_TYPENAME TQValueList::iterator pos, size_type n, const T& x ) +{ + for ( ; n > 0; --n ) + insert( pos, x ); +} + +template +TQ_INLINE_TEMPLATES TQValueList TQValueList::operator+ ( const TQValueList& l ) const +{ + TQValueList l2( *this ); + for( const_iterator it = l.begin(); it != l.end(); ++it ) + l2.append( *it ); + return l2; +} + +template +TQ_INLINE_TEMPLATES TQValueList& TQValueList::operator+= ( const TQValueList& l ) +{ + TQValueList copy = l; + for( const_iterator it = copy.begin(); it != copy.end(); ++it ) + append( *it ); + return *this; +} + +#ifndef TQT_NO_DATASTREAM +template +TQ_INLINE_TEMPLATES TQDataStream& operator>>( TQDataStream& s, TQValueList& l ) +{ + l.clear(); + TQ_UINT32 c; + s >> c; + for( TQ_UINT32 i = 0; i < c && !s.atEnd(); ++i ) + { + T t; + s >> t; + l.append( t ); + } + return s; +} + +template +TQ_INLINE_TEMPLATES TQDataStream& operator<<( TQDataStream& s, const TQValueList& l ) +{ + s << (TQ_UINT32)l.size(); + TQValueListConstIterator it = l.begin(); + for( ; it != l.end(); ++it ) + s << *it; + return s; +} +#endif // TQT_NO_DATASTREAM + +#define Q_DEFINED_QVALUELIST +#define Q_DEFINED_QVALUELIST +#include "ntqwinexport.h" +#endif // TQVALUELIST_H diff --git a/src/tools/tqvaluestack.h b/src/tools/tqvaluestack.h new file mode 100644 index 000000000..5d76820de --- /dev/null +++ b/src/tools/tqvaluestack.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Definition of TQValueStack class +** +** Created : 990925 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQVALUESTACK_H +#define TQVALUESTACK_H + +#ifndef QT_H +#include "tqvaluelist.h" +#endif // QT_H + + +template +class TQValueStack : public TQValueList +{ +public: + TQValueStack() {} + ~TQValueStack() {} + void push( const T& d ) { this->append(d); } + T pop() + { + T elem( this->last() ); + if ( !this->isEmpty() ) + this->remove( this->fromLast() ); + return elem; + } + T& top() { return this->last(); } + const T& top() const { return this->last(); } +}; + +#endif diff --git a/src/tools/tqvaluevector.h b/src/tools/tqvaluevector.h new file mode 100644 index 000000000..90dc45e10 --- /dev/null +++ b/src/tools/tqvaluevector.h @@ -0,0 +1,577 @@ +/**************************************************************************** +** +** Definition of TQValueVector class +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQVALUEVECTOR_H +#define TQVALUEVECTOR_H + +#include + +#ifndef QT_H +#include "ntqtl.h" +#include "ntqshared.h" +#include "ntqdatastream.h" +#endif // QT_H + +#ifndef TQT_NO_STL +#include +#endif + +template +class TQValueVectorPrivate : public TQShared +{ +public: + typedef T value_type; + typedef T* pointer; + + TQValueVectorPrivate() + : start( 0 ), finish( 0 ), end( 0 ) + { + } + + TQValueVectorPrivate( const TQValueVectorPrivate& x ); + TQValueVectorPrivate( size_t size ); + + void derefAndDelete() // work-around for hp-cc + { + if ( deref() ) + delete this; + } + +#if defined(Q_TEMPLATEDLL) + // Workaround MS bug in memory de/allocation in DLL vs. EXE + virtual +#endif + ~TQValueVectorPrivate() + { + delete[] start; + } + + size_t size() const + { + return finish - start; + } + + bool empty() const + { + return start == finish; + } + + size_t capacity() const + { + return end - start; + } + + void insert( pointer pos, const T& x ); + void insert( pointer pos, size_t n, const T& x ); + void reserve( size_t n ); + + void clear() + { + delete[] start; + start = 0; + finish = 0; + end = 0; + } + + + pointer start; + pointer finish; + pointer end; + +private: + pointer growAndCopy( size_t n, pointer s, pointer f ); + + TQValueVectorPrivate& operator=( const TQValueVectorPrivate& x ); + +}; + +template +TQ_INLINE_TEMPLATES TQValueVectorPrivate::TQValueVectorPrivate( const TQValueVectorPrivate& x ) + : TQShared() +{ + size_t i = x.size(); + if ( i > 0 ) { + start = new T[ i ]; + finish = start + i; + end = start + i; +#if defined(__xlC__) && __xlC__ < 0x400 // xlC 3.6 confused by const + tqCopy( (pointer)x.start, (pointer)x.finish, start ); +#else + tqCopy( x.start, x.finish, start ); +#endif + } else { + start = 0; + finish = 0; + end = 0; + } +} + +template +TQ_INLINE_TEMPLATES TQValueVectorPrivate::TQValueVectorPrivate( size_t size ) +{ + if ( size > 0 ) { + start = new T[size]; + finish = start + size; + end = start + size; + } else { + start = 0; + finish = 0; + end = 0; + } +} + +template +TQ_INLINE_TEMPLATES void TQValueVectorPrivate::insert( pointer pos, const T& x ) +{ + const size_t lastSize = size(); + const size_t n = lastSize !=0 ? 2*lastSize : 1; + const size_t offset = pos - start; + pointer newStart = new T[n]; + pointer newFinish = newStart + offset; + tqCopy( start, pos, newStart ); + *newFinish = x; + tqCopy( pos, finish, ++newFinish ); + delete[] start; + start = newStart; + finish = newStart + lastSize + 1; + end = newStart + n; +} + +template +TQ_INLINE_TEMPLATES void TQValueVectorPrivate::insert( pointer pos, size_t n, const T& x ) +{ + if ( size_t( end - finish ) >= n ) { + // enough room + const size_t elems_after = finish - pos; + pointer old_finish = finish; + if ( elems_after > n ) { + tqCopy( finish - n, finish, finish ); + finish += n; + tqCopyBackward( pos, old_finish - n, old_finish ); + tqFill( pos, pos + n, x ); + } else { + pointer filler = finish; + size_t i = n - elems_after; + for ( ; i > 0; --i, ++filler ) + *filler = x; + finish += n - elems_after; + tqCopy( pos, old_finish, finish ); + finish += elems_after; + tqFill( pos, old_finish, x ); + } + } else { + // not enough room + const size_t lastSize = size(); + const size_t len = lastSize + TQMAX( lastSize, n ); + pointer newStart = new T[len]; + pointer newFinish = tqCopy( start, pos, newStart ); + // fill up inserted space + size_t i = n; + for ( ; i > 0; --i, ++newFinish ) + *newFinish = x; + newFinish = tqCopy( pos, finish, newFinish ); + delete[] start; + start = newStart; + finish = newFinish; + end = newStart + len; + } +} + +template +TQ_INLINE_TEMPLATES void TQValueVectorPrivate::reserve( size_t n ) +{ + const size_t lastSize = size(); + pointer tmp = growAndCopy( n, start, finish ); + start = tmp; + finish = tmp + lastSize; + end = start + n; +} + +template +TQ_INLINE_TEMPLATES TQ_TYPENAME TQValueVectorPrivate::pointer TQValueVectorPrivate::growAndCopy( size_t n, pointer s, pointer f ) +{ + pointer newStart = new T[n]; + tqCopy( s, f, newStart ); + delete[] start; + return newStart; +} + +template class TQDeepCopy; + +template +class TQValueVector +{ +public: + typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type* iterator; + typedef const value_type* const_iterator; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef size_t size_type; +#ifndef TQT_NO_STL + typedef ptrdiff_t difference_type; +#else + typedef int difference_type; +#endif + + TQValueVector() + { + sh = new TQValueVectorPrivate; + } + + TQValueVector( const TQValueVector& v ) + { + sh = v.sh; + sh->ref(); + } + + TQValueVector( size_type n, const T& val = T() ); + +#ifndef TQT_NO_STL + TQValueVector( std::vector& v ) // ### remove in 4.0 + { + sh = new TQValueVectorPrivate( v.size() ); + tqCopy( v.begin(), v.end(), begin() ); + } + + TQValueVector( const std::vector& v ) + { + sh = new TQValueVectorPrivate( v.size() ); + tqCopy( v.begin(), v.end(), begin() ); + } +#endif + + ~TQValueVector() + { + sh->derefAndDelete(); + } + + TQValueVector& operator= ( const TQValueVector& v ) + { + v.sh->ref(); + sh->derefAndDelete(); + sh = v.sh; + return *this; + } + +#ifndef TQT_NO_STL + TQValueVector& operator= ( const std::vector& v ) + { + clear(); + resize( v.size() ); + tqCopy( v.begin(), v.end(), begin() ); + return *this; + } +#endif + + size_type size() const { return sh->size(); } + + bool empty() const { return sh->empty(); } + + size_type capacity() const + { + return size_type( sh->capacity() ); + } + + iterator begin() + { + detach(); + return sh->start; + } + + const_iterator begin() const + { + return sh->start; + } + + const_iterator constBegin() const + { + return sh->start; + } + + iterator end() + { + detach(); + return sh->finish; + } + + const_iterator end() const + { + return sh->finish; + } + + const_iterator constEnd() const + { + return sh->finish; + } + + reference at( size_type i, bool* ok = 0 ) + { + detach(); + if ( ok ) + *ok = ( i < size() ); + return *( begin() + i ); + } + + const_reference at( size_type i, bool* ok = 0 ) const + { + if ( ok ) + *ok = ( i < size() ); + return *( begin() + i ); + } + + reference operator[]( size_type i ) + { + detach(); + return *( begin() + i ); + } + + const_reference operator[]( size_type i ) const + { + return *( begin() + i ); + } + + reference front() + { + Q_ASSERT( !empty() ); + detach(); + return *begin(); + } + + const_reference front() const + { + Q_ASSERT( !empty() ); + return *begin(); + } + + reference back() + { + Q_ASSERT( !empty() ); + detach(); + return *( end() - 1 ); + } + + const_reference back() const + { + Q_ASSERT( !empty() ); + return *( end() - 1 ); + } + + void push_back( const T& x ) + { + detach(); + if ( sh->finish == sh->end ) { + sh->reserve( size()+size()/2+1 ); + } + *sh->finish = x; + ++sh->finish; + } + + void pop_back() + { + detach(); + if ( empty() ) + return; + --sh->finish; + } + + iterator insert( iterator pos, const T& x ); + iterator insert( iterator pos, size_type n, const T& x ); + + void reserve( size_type n ) + { + if ( capacity() < n ) { + detach(); + sh->reserve( n ); + } + } + + void resize( size_type n, const T& val = T() ) + { + if ( n < size() ) + erase( begin() + n, end() ); + else + insert( end(), n - size(), val ); + } + + void clear() + { + detach(); + sh->clear(); + } + + iterator erase( iterator pos ) + { + detach(); + if ( pos + 1 != end() ) + tqCopy( pos + 1, sh->finish, pos ); + --sh->finish; + return pos; + } + + iterator erase( iterator first, iterator last ) + { + detach(); + tqCopy( last, sh->finish, first ); + sh->finish = sh->finish - ( last - first ); + return first; + } + + // ### remove in TQt 4.0 + bool operator==( const TQValueVector& x ) + { + return size()==x.size() ? tqEqual( constBegin(), constEnd(), x.begin()) : FALSE; + } + + bool operator==( const TQValueVector& x ) const + { + return size()==x.size() ? tqEqual( begin(), end(), x.begin() ) : FALSE; + } + + typedef T ValueType; + typedef ValueType *Iterator; + typedef const ValueType *ConstIterator; + + size_type count() const { return size(); } + bool isEmpty() const { return empty(); } + + reference first() { return front(); } + const_reference first() const { return front(); } + reference last() { return back(); } + const_reference last() const { return back(); } + void append( const T& x ) { push_back( x ); } + +protected: + void detach() + { + if ( sh->count > 1 ) { detachInternal(); } + } + void detachInternal(); + TQValueVectorPrivate* sh; + +private: + friend class TQDeepCopy< TQValueVector >; +}; + +template +TQ_INLINE_TEMPLATES TQValueVector::TQValueVector( size_type n, const T& val ) +{ + sh = new TQValueVectorPrivate( n ); + tqFill( begin(), end(), val ); +} + +template +TQ_INLINE_TEMPLATES void TQValueVector::detachInternal() +{ + sh->deref(); + sh = new TQValueVectorPrivate( *sh ); +} + +template +TQ_INLINE_TEMPLATES TQ_TYPENAME TQValueVector::iterator TQValueVector::insert( iterator pos, const T& x ) +{ + size_type offset = pos - sh->start; + detach(); + if ( pos == end() ) { + if ( sh->finish == sh->end ) + push_back( x ); + else { + *sh->finish = x; + ++sh->finish; + } + } else { + if ( sh->finish == sh->end ) { + sh->insert( pos, x ); + } else { + *sh->finish = *(sh->finish - 1); + ++sh->finish; + tqCopyBackward( pos, sh->finish - 2, sh->finish - 1 ); + *pos = x; + } + } + return begin() + offset; +} + +template +TQ_INLINE_TEMPLATES TQ_TYPENAME TQValueVector::iterator TQValueVector::insert( iterator pos, size_type n, const T& x ) +{ + if ( n != 0 ) { + size_type offset = pos - sh->start; + detach(); + pos = begin() + offset; + sh->insert( pos, n, x ); + } + return pos; +} + + +#ifndef TQT_NO_DATASTREAM +template +TQ_INLINE_TEMPLATES TQDataStream& operator>>( TQDataStream& s, TQValueVector& v ) +{ + v.clear(); + TQ_UINT32 c; + s >> c; + v.resize( c ); + for( TQ_UINT32 i = 0; i < c; ++i ) + { + T t; + s >> t; + v[i] = t; + } + return s; +} + +template +TQ_INLINE_TEMPLATES TQDataStream& operator<<( TQDataStream& s, const TQValueVector& v ) +{ + s << (TQ_UINT32)v.size(); + // ### use typename TQValueVector::const_iterator once all supported + // ### compilers know about the 'typename' keyword. + const T* it = v.begin(); + for( ; it != v.end(); ++it ) + s << *it; + return s; +} +#endif // TQT_NO_DATASTREAM + +#define Q_DEFINED_QVALUEVECTOR +#include "ntqwinexport.h" +#endif // TQVALUEVECTOR_H diff --git a/src/widgets/ntqdockarea.h b/src/widgets/ntqdockarea.h index ee9201597..85dce12b5 100644 --- a/src/widgets/ntqdockarea.h +++ b/src/widgets/ntqdockarea.h @@ -46,7 +46,7 @@ #include "ntqptrlist.h" #include "ntqdockwindow.h" #include "ntqlayout.h" -#include "ntqvaluelist.h" +#include "tqvaluelist.h" #include "ntqguardedptr.h" #include "ntqtextstream.h" #endif // QT_H diff --git a/src/widgets/ntqsplitter.h b/src/widgets/ntqsplitter.h index 887b1b265..425b9718f 100644 --- a/src/widgets/ntqsplitter.h +++ b/src/widgets/ntqsplitter.h @@ -43,7 +43,7 @@ #ifndef QT_H #include "ntqframe.h" -#include "ntqvaluelist.h" +#include "tqvaluelist.h" #endif // QT_H #ifndef TQT_NO_SPLITTER diff --git a/src/widgets/ntqtextedit.h b/src/widgets/ntqtextedit.h index 322fb4e00..f14e06ff8 100644 --- a/src/widgets/ntqtextedit.h +++ b/src/widgets/ntqtextedit.h @@ -45,7 +45,7 @@ #include "ntqscrollview.h" #include "ntqstylesheet.h" #include "ntqptrvector.h" -#include "ntqvaluelist.h" +#include "tqvaluelist.h" #include "ntqptrlist.h" #endif // QT_H diff --git a/src/widgets/qdatetimeedit.cpp b/src/widgets/qdatetimeedit.cpp index 0084be77d..c8ebee765 100644 --- a/src/widgets/qdatetimeedit.cpp +++ b/src/widgets/qdatetimeedit.cpp @@ -48,7 +48,7 @@ #include "ntqapplication.h" #include "ntqpixmap.h" #include "ntqapplication.h" -#include "ntqvaluelist.h" +#include "tqvaluelist.h" #include "ntqstring.h" #include "ntqstyle.h" diff --git a/src/widgets/qdialogbuttons.cpp b/src/widgets/qdialogbuttons.cpp index 8f32fd61d..ed1f4064c 100644 --- a/src/widgets/qdialogbuttons.cpp +++ b/src/widgets/qdialogbuttons.cpp @@ -42,14 +42,14 @@ #include #include #include -#include +#include #include #ifndef TQT_NO_DIALOG #include #endif // TQT_NO_DIALOG #include #include -#include +#include struct TQDialogButtonsPrivate { diff --git a/src/widgets/qdockarea.cpp b/src/widgets/qdockarea.cpp index 3693a036d..1f982a1de 100644 --- a/src/widgets/qdockarea.cpp +++ b/src/widgets/qdockarea.cpp @@ -47,7 +47,7 @@ #include "ntqapplication.h" #include "ntqpainter.h" #include "tqwidgetlist.h" -#include "ntqmap.h" +#include "tqmap.h" #include "ntqmainwindow.h" //#define TQDOCKAREA_DEBUG diff --git a/src/widgets/qlineedit.cpp b/src/widgets/qlineedit.cpp index 68048abcd..3fb88d21e 100644 --- a/src/widgets/qlineedit.cpp +++ b/src/widgets/qlineedit.cpp @@ -62,7 +62,7 @@ #include "ntqwhatsthis.h" #include "../kernel/qinternal_p.h" #include "private/qtextlayout_p.h" -#include "ntqvaluevector.h" +#include "tqvaluevector.h" #if defined(Q_OS_LINUX) #include #endif diff --git a/src/widgets/qmainwindow.cpp b/src/widgets/qmainwindow.cpp index 970d8cdf4..3510c8290 100644 --- a/src/widgets/qmainwindow.cpp +++ b/src/widgets/qmainwindow.cpp @@ -47,7 +47,7 @@ #include "ntqintdict.h" #include "ntqapplication.h" #include "ntqptrlist.h" -#include "ntqmap.h" +#include "tqmap.h" #include "ntqcursor.h" #include "ntqpainter.h" #include "ntqmenubar.h" diff --git a/src/widgets/qtextbrowser.cpp b/src/widgets/qtextbrowser.cpp index 0cc40aa64..c9baa8144 100644 --- a/src/widgets/qtextbrowser.cpp +++ b/src/widgets/qtextbrowser.cpp @@ -46,7 +46,7 @@ #include "ntqlayout.h" #include "ntqpainter.h" -#include "ntqvaluestack.h" +#include "tqvaluestack.h" #include "stdio.h" #include "ntqfile.h" #include "ntqtextstream.h" diff --git a/src/widgets/qtoolbox.cpp b/src/widgets/qtoolbox.cpp index a04c78dbe..9b4eec8e3 100644 --- a/src/widgets/qtoolbox.cpp +++ b/src/widgets/qtoolbox.cpp @@ -51,7 +51,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/xml/qsvgdevice.cpp b/src/xml/qsvgdevice.cpp index 02fa7933f..ceeb8b6e6 100644 --- a/src/xml/qsvgdevice.cpp +++ b/src/xml/qsvgdevice.cpp @@ -43,9 +43,9 @@ #include "ntqpainter.h" #include "ntqpaintdevicemetrics.h" #include "ntqfile.h" -#include "ntqmap.h" +#include "tqmap.h" #include "ntqregexp.h" -#include "ntqvaluelist.h" +#include "tqvaluelist.h" #include "ntqtextstream.h" #include "ntqimage.h" #include "ntqpixmap.h" diff --git a/src/xml/tqxml.cpp b/src/xml/tqxml.cpp index 11d6ab169..a0d3f7f18 100644 --- a/src/xml/tqxml.cpp +++ b/src/xml/tqxml.cpp @@ -43,8 +43,8 @@ #include "ntqbuffer.h" #include "ntqregexp.h" #include "ntqptrstack.h" -#include "ntqmap.h" -#include "ntqvaluestack.h" +#include "tqmap.h" +#include "tqvaluestack.h" // needed for TQT_TRANSLATE_NOOP: #include "tqobject.h" diff --git a/src/xml/tqxml.h b/src/xml/tqxml.h index b2f86dc93..caff6f125 100644 --- a/src/xml/tqxml.h +++ b/src/xml/tqxml.h @@ -46,7 +46,7 @@ #include "ntqfile.h" #include "ntqstring.h" #include "ntqstringlist.h" -#include "ntqvaluevector.h" +#include "tqvaluevector.h" #endif // QT_H #if !defined(TQT_MODULE_XML) || defined( QT_LICENSE_PROFESSIONAL ) || defined( QT_INTERNAL_XML ) -- cgit v1.2.3