| 
									
										
										
										
											2009-05-05 12:11:22 +02:00
										 |  |  | /**************************************************************************
 | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** This file is part of Qt Creator | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). | 
					
						
							|  |  |  | ** | 
					
						
							| 
									
										
										
										
											2009-06-17 00:01:27 +10:00
										 |  |  | ** Contact: Nokia Corporation (qt-info@nokia.com) | 
					
						
							| 
									
										
										
										
											2009-05-05 12:11:22 +02:00
										 |  |  | ** | 
					
						
							|  |  |  | ** Commercial Usage | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** Licensees holding valid Qt Commercial licenses may use this file in | 
					
						
							|  |  |  | ** accordance with the Qt Commercial License Agreement provided with the | 
					
						
							|  |  |  | ** Software or, alternatively, in accordance with the terms contained in | 
					
						
							|  |  |  | ** a written agreement between you and Nokia. | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** GNU Lesser General Public License Usage | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
					
						
							|  |  |  | ** General Public License version 2.1 as published by the Free Software | 
					
						
							|  |  |  | ** Foundation and appearing in the file LICENSE.LGPL included in the | 
					
						
							|  |  |  | ** packaging of this file.  Please review the following information to | 
					
						
							|  |  |  | ** ensure the GNU Lesser General Public License version 2.1 requirements | 
					
						
							|  |  |  | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** If you are unsure which license is appropriate for your use, please | 
					
						
							| 
									
										
										
										
											2009-08-14 09:30:56 +02:00
										 |  |  | ** contact the sales department at http://qt.nokia.com/contact.
 | 
					
						
							| 
									
										
										
										
											2009-05-05 12:11:22 +02:00
										 |  |  | ** | 
					
						
							|  |  |  | **************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QtCore/QStringList>
 | 
					
						
							| 
									
										
										
										
											2009-09-21 14:55:39 +02:00
										 |  |  | #include <QtCore/QLinkedList>
 | 
					
						
							| 
									
										
										
										
											2009-05-05 12:46:36 +02:00
										 |  |  | #include <QtCore/QVector>
 | 
					
						
							| 
									
										
										
										
											2009-07-02 16:38:15 +02:00
										 |  |  | #include <QtCore/QSharedPointer>
 | 
					
						
							| 
									
										
										
										
											2009-05-05 12:46:36 +02:00
										 |  |  | #include <QtCore/QTimer>
 | 
					
						
							| 
									
										
										
										
											2009-07-02 16:38:15 +02:00
										 |  |  | #include <QtCore/QMap>
 | 
					
						
							| 
									
										
										
										
											2009-09-21 15:56:40 +02:00
										 |  |  | #include <QtCore/QSet>
 | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  | #include <QtCore/QVariant>
 | 
					
						
							|  |  |  | #include <QtGui/QAction>
 | 
					
						
							| 
									
										
										
										
											2009-05-05 12:11:22 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <string>
 | 
					
						
							|  |  |  | #include <list>
 | 
					
						
							| 
									
										
										
										
											2009-05-05 12:46:36 +02:00
										 |  |  | #include <vector>
 | 
					
						
							| 
									
										
										
										
											2009-05-06 09:22:05 +02:00
										 |  |  | #include <set>
 | 
					
						
							| 
									
										
										
										
											2009-07-02 16:38:15 +02:00
										 |  |  | #include <map>
 | 
					
						
							| 
									
										
										
										
											2009-05-05 12:11:22 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <stdio.h>
 | 
					
						
							|  |  |  | #include <string.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-22 14:31:37 +02:00
										 |  |  | // Test uninitialized variables allocing memory
 | 
					
						
							|  |  |  | bool optTestUninitialized = false; | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  | bool optTestAll = false; | 
					
						
							|  |  |  | bool optEmptyContainers = false; | 
					
						
							|  |  |  | unsigned optVerbose = 0; | 
					
						
							| 
									
										
										
										
											2009-05-22 14:31:37 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  | // Provide address of type of be tested.
 | 
					
						
							|  |  |  | // When testing unitialized memory, allocate at random.
 | 
					
						
							| 
									
										
										
										
											2009-05-22 14:31:37 +02:00
										 |  |  | template <class T> | 
					
						
							|  |  |  |         inline T* testAddress(T* in) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  |     unsigned char *mem = 0; | 
					
						
							|  |  |  |     if (optTestUninitialized) { | 
					
						
							|  |  |  |         mem = new unsigned char[sizeof(T)]; | 
					
						
							| 
									
										
										
										
											2009-10-19 16:46:59 +02:00
										 |  |  |         for (unsigned int i = 0; i < sizeof(T); i++) { | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  |             mem[i] = char(rand() % 255u); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         mem = reinterpret_cast<unsigned char*>(in); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (optVerbose) { | 
					
						
							| 
									
										
										
										
											2009-10-19 16:46:59 +02:00
										 |  |  |         for (unsigned int i = 0; i < sizeof(T); i++) { | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  |             unsigned int b = mem[i]; | 
					
						
							|  |  |  |             printf("%2d %2x %3d\n", i, b, b); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         fflush(stdout); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return reinterpret_cast<T*>(mem); | 
					
						
							| 
									
										
										
										
											2009-05-22 14:31:37 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2009-05-05 12:46:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-05 12:11:22 +02:00
										 |  |  | /* Test program for Dumper development/porting.
 | 
					
						
							|  |  |  |  * Takes the type as first argument. */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // --------------- Dumper symbols
 | 
					
						
							|  |  |  | extern char qDumpInBuffer[10000]; | 
					
						
							|  |  |  | extern char qDumpOutBuffer[100000]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern "C" void *qDumpObjectData440( | 
					
						
							|  |  |  |     int protocolVersion, | 
					
						
							|  |  |  |     int token, | 
					
						
							|  |  |  |     void *data, | 
					
						
							|  |  |  | #ifdef Q_CC_MSVC // CDB cannot handle boolean parameters
 | 
					
						
							|  |  |  |     int dumpChildren, | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  |     bool dumpChildren, | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  |     int extraInt0, int extraInt1, int extraInt2, int extraInt3); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void prepareInBuffer(const char *outerType, | 
					
						
							|  |  |  |                             const char *iname, | 
					
						
							|  |  |  |                             const char *expr, | 
					
						
							|  |  |  |                             const char *innerType) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // Leave trailing '\0'
 | 
					
						
							|  |  |  |     char *ptr = qDumpInBuffer; | 
					
						
							|  |  |  |     strcpy(ptr, outerType); | 
					
						
							|  |  |  |     ptr += strlen(outerType); | 
					
						
							|  |  |  |     ptr++; | 
					
						
							|  |  |  |     strcpy(ptr, iname); | 
					
						
							|  |  |  |     ptr += strlen(iname); | 
					
						
							|  |  |  |     ptr++; | 
					
						
							|  |  |  |     strcpy(ptr, expr); | 
					
						
							|  |  |  |     ptr += strlen(expr); | 
					
						
							|  |  |  |     ptr++; | 
					
						
							|  |  |  |     strcpy(ptr, innerType); | 
					
						
							|  |  |  |     ptr += strlen(innerType); | 
					
						
							|  |  |  |     ptr++; | 
					
						
							|  |  |  |     strcpy(ptr, iname); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // ---------------  Qt types
 | 
					
						
							|  |  |  | static int dumpQString() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QString test = QLatin1String("hallo"); | 
					
						
							|  |  |  |     prepareInBuffer("QString", "local.qstring", "local.qstring", ""); | 
					
						
							| 
									
										
										
										
											2009-05-22 14:31:37 +02:00
										 |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, 0, 0, 0, 0); | 
					
						
							| 
									
										
										
										
											2009-05-05 12:11:22 +02:00
										 |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							| 
									
										
										
										
											2009-05-22 14:31:37 +02:00
										 |  |  |     QString uninitialized; | 
					
						
							| 
									
										
										
										
											2009-05-05 12:11:22 +02:00
										 |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-02 16:38:15 +02:00
										 |  |  | static int dumpQSharedPointerQString() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QSharedPointer<QString> test(new QString(QLatin1String("hallo"))); | 
					
						
							|  |  |  |     prepareInBuffer("QSharedPointer", "local.sharedpointerqstring", "local.local.sharedpointerqstring", "QString"); | 
					
						
							|  |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(QString), 0, 0, 0); | 
					
						
							|  |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							|  |  |  |     QString uninitialized; | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-05 12:11:22 +02:00
										 |  |  | static int dumpQStringList() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QStringList test = QStringList() << QLatin1String("item1") << QLatin1String("item2"); | 
					
						
							|  |  |  |     prepareInBuffer("QList", "local.qstringlist", "local.qstringlist", "QString"); | 
					
						
							| 
									
										
										
										
											2009-05-22 14:31:37 +02:00
										 |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(QString), 0, 0, 0); | 
					
						
							| 
									
										
										
										
											2009-05-05 12:11:22 +02:00
										 |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int dumpQIntList() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QList<int> test = QList<int>() << 1 << 2; | 
					
						
							|  |  |  |     prepareInBuffer("QList", "local.qintlist", "local.qintlist", "int"); | 
					
						
							| 
									
										
										
										
											2009-05-22 14:31:37 +02:00
										 |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), 0, 0, 0); | 
					
						
							| 
									
										
										
										
											2009-05-05 12:11:22 +02:00
										 |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-21 14:55:39 +02:00
										 |  |  | static int dumpQIntLinkedList() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QLinkedList<int> test = QLinkedList<int>() << 1 << 2; | 
					
						
							|  |  |  |     prepareInBuffer("QLinkedList", "local.qintlinkedlist", "local.qlinkedintlist", "int"); | 
					
						
							|  |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), 0, 0, 0); | 
					
						
							|  |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-05 12:46:36 +02:00
										 |  |  | static int dumpQIntVector() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-07-16 12:09:24 +02:00
										 |  |  |     QVector<int> test = QVector<int>() << 42 << 43; | 
					
						
							| 
									
										
										
										
											2009-05-05 12:46:36 +02:00
										 |  |  |     prepareInBuffer("QVector", "local.qintvector", "local.qintvector", "int"); | 
					
						
							| 
									
										
										
										
											2009-05-22 14:31:37 +02:00
										 |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), 0, 0, 0); | 
					
						
							| 
									
										
										
										
											2009-05-05 12:46:36 +02:00
										 |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-21 15:56:40 +02:00
										 |  |  | static int dumpQQStringVector() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QVector<QString> test = QVector<QString>() << "42s" << "43s"; | 
					
						
							|  |  |  |     prepareInBuffer("QVector", "local.qstringvector", "local.qstringvector", "QString"); | 
					
						
							|  |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(QString), 0, 0, 0); | 
					
						
							|  |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-02 16:38:15 +02:00
										 |  |  | static int dumpQMapIntInt() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QMap<int,int> test; | 
					
						
							|  |  |  |     QMapNode<int,int> mapNode; | 
					
						
							|  |  |  |     const int valueOffset = (char*)&(mapNode.value) - (char*)&mapNode; | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  |     if (!optEmptyContainers) { | 
					
						
							|  |  |  |         test.insert(42, 43); | 
					
						
							|  |  |  |         test.insert(43, 44); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-07-02 16:38:15 +02:00
										 |  |  |     prepareInBuffer("QMap", "local.qmapintint", "local.qmapintint", "int@int"); | 
					
						
							|  |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), sizeof(int), sizeof(mapNode), valueOffset); | 
					
						
							|  |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int dumpQMapIntString() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QMap<int,QString> test; | 
					
						
							|  |  |  |     QMapNode<int,QString> mapNode; | 
					
						
							|  |  |  |     const int valueOffset = (char*)&(mapNode.value) - (char*)&mapNode; | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  |     if (!optEmptyContainers) { | 
					
						
							|  |  |  |         test.insert(42, QLatin1String("fortytwo")); | 
					
						
							|  |  |  |         test.insert(43, QLatin1String("fortytree")); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-07-02 16:38:15 +02:00
										 |  |  |     prepareInBuffer("QMap", "local.qmapintqstring", "local.qmapintqstring", "int@QString"); | 
					
						
							|  |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), sizeof(QString), sizeof(mapNode), valueOffset); | 
					
						
							|  |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-21 15:56:40 +02:00
										 |  |  | static int dumpQSetInt() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QSet<int> test; | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  |     if (!optEmptyContainers) { | 
					
						
							|  |  |  |         test.insert(42); | 
					
						
							|  |  |  |         test.insert(43); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-09-21 15:56:40 +02:00
										 |  |  |     prepareInBuffer("QSet", "local.qsetint", "local.qsetint", "int"); | 
					
						
							|  |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), 0, 0, 0); | 
					
						
							|  |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-21 14:55:39 +02:00
										 |  |  | static int dumpQMapQStringString() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QMap<QString,QString> test; | 
					
						
							|  |  |  |     QMapNode<QString,QString> mapNode; | 
					
						
							|  |  |  |     const int valueOffset = (char*)&(mapNode.value) - (char*)&mapNode; | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  |     if (!optEmptyContainers) { | 
					
						
							|  |  |  |         test.insert(QLatin1String("42s"), QLatin1String("fortytwo")); | 
					
						
							|  |  |  |         test.insert(QLatin1String("423"), QLatin1String("fortytree")); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     prepareInBuffer("QMap", "local.qmapqstringqstring", "local.qmapqstringqstring", "QString@QString");     | 
					
						
							| 
									
										
										
										
											2009-09-21 14:55:39 +02:00
										 |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(QString), sizeof(QString), sizeof(mapNode), valueOffset); | 
					
						
							|  |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  | static int dumpQVariant() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-10-02 15:17:50 +02:00
										 |  |  |     QVariant test = QLatin1String("item"); | 
					
						
							|  |  |  |     prepareInBuffer("QVariant", "local.qvariant", "local.qvariant", ""); | 
					
						
							|  |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, 0, 0,0 ,0); | 
					
						
							|  |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputs("\n\n", stdout); | 
					
						
							|  |  |  |     test = QVariant(int(42)); | 
					
						
							|  |  |  |     prepareInBuffer("QVariant", "local.qvariant", "local.qvariant", ""); | 
					
						
							|  |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, 0, 0,0 ,0); | 
					
						
							|  |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputs("\n\n", stdout); | 
					
						
							|  |  |  |     test = QVariant(double(3.141)); | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  |     prepareInBuffer("QVariant", "local.qvariant", "local.qvariant", ""); | 
					
						
							|  |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, 0, 0,0 ,0); | 
					
						
							|  |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputs("\n\n", stdout); | 
					
						
							|  |  |  |     test = QVariant(QStringList(QLatin1String("item1"))); | 
					
						
							|  |  |  |     prepareInBuffer("QVariant", "local.qvariant", "local.qvariant", ""); | 
					
						
							|  |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, 0, 0,0 ,0); | 
					
						
							|  |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							| 
									
										
										
										
											2009-08-12 11:21:44 +02:00
										 |  |  |     test = QVariant(QRect(1,2, 3, 4)); | 
					
						
							|  |  |  |     prepareInBuffer("QVariant", "local.qvariant", "local.qvariant", ""); | 
					
						
							|  |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, 0, 0,0 ,0); | 
					
						
							|  |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-05 12:11:22 +02:00
										 |  |  | // ---------------  std types
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int dumpStdString() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     std::string test = "hallo"; | 
					
						
							|  |  |  |     prepareInBuffer("std::string", "local.string", "local.string", ""); | 
					
						
							| 
									
										
										
										
											2009-05-22 14:31:37 +02:00
										 |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, 0, 0, 0, 0); | 
					
						
							| 
									
										
										
										
											2009-05-05 12:11:22 +02:00
										 |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-05 16:39:51 +02:00
										 |  |  | static int dumpStdWString() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     std::wstring test = L"hallo"; | 
					
						
							|  |  |  |     prepareInBuffer("std::wstring", "local.wstring", "local.wstring", ""); | 
					
						
							| 
									
										
										
										
											2009-05-22 14:31:37 +02:00
										 |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, 0, 0, 0, 0); | 
					
						
							| 
									
										
										
										
											2009-05-05 16:39:51 +02:00
										 |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-05 12:11:22 +02:00
										 |  |  | static int dumpStdStringList() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     std::list<std::string> test; | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  |     if (!optEmptyContainers) { | 
					
						
							|  |  |  |         test.push_back("item1"); | 
					
						
							|  |  |  |         test.push_back("item2"); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-05-05 12:11:22 +02:00
										 |  |  |     prepareInBuffer("std::list", "local.stringlist", "local.stringlist", "std::string"); | 
					
						
							| 
									
										
										
										
											2009-05-22 14:31:37 +02:00
										 |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(std::string), sizeof(std::list<std::string>::allocator_type), 0, 0); | 
					
						
							| 
									
										
										
										
											2009-05-05 12:11:22 +02:00
										 |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-05 16:39:51 +02:00
										 |  |  | static int dumpStdStringQList() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QList<std::string> test; | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  |     if (!optEmptyContainers) { | 
					
						
							|  |  |  |         test.push_back("item1"); | 
					
						
							|  |  |  |         test.push_back("item2"); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-05-05 16:39:51 +02:00
										 |  |  |     prepareInBuffer("QList", "local.stringqlist", "local.stringqlist", "std::string"); | 
					
						
							| 
									
										
										
										
											2009-05-22 14:31:37 +02:00
										 |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(std::string), 0, 0, 0); | 
					
						
							| 
									
										
										
										
											2009-05-05 16:39:51 +02:00
										 |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-05 12:11:22 +02:00
										 |  |  | static int dumpStdIntList() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     std::list<int> test; | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  |     if (!optEmptyContainers) { | 
					
						
							|  |  |  |         test.push_back(1); | 
					
						
							|  |  |  |         test.push_back(2); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-05-05 12:11:22 +02:00
										 |  |  |     prepareInBuffer("std::list", "local.intlist", "local.intlist", "int"); | 
					
						
							| 
									
										
										
										
											2009-05-22 14:31:37 +02:00
										 |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), sizeof(std::list<int>::allocator_type), 0, 0); | 
					
						
							| 
									
										
										
										
											2009-05-05 12:11:22 +02:00
										 |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-05 12:46:36 +02:00
										 |  |  | static int dumpStdIntVector() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     std::vector<int> test; | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  |     if (!optEmptyContainers) { | 
					
						
							|  |  |  |         test.push_back(1); | 
					
						
							|  |  |  |         test.push_back(2); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-05-05 12:46:36 +02:00
										 |  |  |     prepareInBuffer("std::vector", "local.intvector", "local.intvector", "int"); | 
					
						
							| 
									
										
										
										
											2009-05-22 14:31:37 +02:00
										 |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), sizeof(std::list<int>::allocator_type), 0, 0); | 
					
						
							| 
									
										
										
										
											2009-05-05 12:46:36 +02:00
										 |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-05 16:39:51 +02:00
										 |  |  | static int dumpStdStringVector() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     std::vector<std::string> test; | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  |     if (!optEmptyContainers) { | 
					
						
							|  |  |  |         test.push_back("item1"); | 
					
						
							|  |  |  |         test.push_back("item2"); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-05-05 16:39:51 +02:00
										 |  |  |     prepareInBuffer("std::vector", "local.stringvector", "local.stringvector", "std::string"); | 
					
						
							| 
									
										
										
										
											2009-05-22 14:31:37 +02:00
										 |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(std::string), sizeof(std::list<int>::allocator_type), 0, 0); | 
					
						
							| 
									
										
										
										
											2009-05-05 16:39:51 +02:00
										 |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-03 13:56:27 +02:00
										 |  |  | static int dumpStdWStringVector() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     std::vector<std::wstring> test; | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  |     if (!optEmptyContainers) { | 
					
						
							|  |  |  |         test.push_back(L"item1"); | 
					
						
							|  |  |  |         test.push_back(L"item2"); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-07-03 13:56:27 +02:00
										 |  |  |     prepareInBuffer("std::vector", "local.wstringvector", "local.wstringvector", "std::wstring"); | 
					
						
							|  |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(std::wstring), sizeof(std::list<int>::allocator_type), 0, 0); | 
					
						
							|  |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-06 09:22:05 +02:00
										 |  |  | static int dumpStdIntSet() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     std::set<int> test; | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  |     if (!optEmptyContainers) { | 
					
						
							|  |  |  |         test.insert(1); | 
					
						
							|  |  |  |         test.insert(2); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-05-06 09:22:05 +02:00
										 |  |  |     prepareInBuffer("std::set", "local.intset", "local.intset", "int"); | 
					
						
							| 
									
										
										
										
											2009-05-22 14:31:37 +02:00
										 |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), sizeof(std::list<int>::allocator_type), 0, 0); | 
					
						
							| 
									
										
										
										
											2009-05-06 09:22:05 +02:00
										 |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int dumpStdStringSet() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     std::set<std::string> test; | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  |     if (!optEmptyContainers) { | 
					
						
							|  |  |  |         test.insert("item1"); | 
					
						
							|  |  |  |         test.insert("item2"); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-05-06 09:22:05 +02:00
										 |  |  |     prepareInBuffer("std::set", "local.stringset", "local.stringset", "std::string"); | 
					
						
							| 
									
										
										
										
											2009-05-22 14:31:37 +02:00
										 |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(std::string), sizeof(std::list<int>::allocator_type), 0, 0); | 
					
						
							| 
									
										
										
										
											2009-05-06 09:22:05 +02:00
										 |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-05-05 16:39:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-07 16:00:45 +02:00
										 |  |  | static int dumpStdQStringSet() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     std::set<QString> test; | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  |     if (!optEmptyContainers) { | 
					
						
							|  |  |  |         test.insert(QLatin1String("item1")); | 
					
						
							|  |  |  |         test.insert(QLatin1String("item2")); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-07-07 16:00:45 +02:00
										 |  |  |     prepareInBuffer("std::set", "local.stringset", "local.stringset", "QString"); | 
					
						
							|  |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(QString), sizeof(std::list<int>::allocator_type), 0, 0); | 
					
						
							|  |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-02 16:38:15 +02:00
										 |  |  | static int dumpStdMapIntString() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  |     std::map<int,std::string> test;     | 
					
						
							| 
									
										
										
										
											2009-07-02 16:38:15 +02:00
										 |  |  |     std::map<int,std::string>::value_type entry(42, std::string("fortytwo")); | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  |     if (!optEmptyContainers) { | 
					
						
							|  |  |  |         test.insert(entry); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-07-02 16:38:15 +02:00
										 |  |  |     const int valueOffset = (char*)&(entry.second) - (char*)&entry; | 
					
						
							|  |  |  |     prepareInBuffer("std::map", "local.stdmapintstring", "local.stdmapintstring", | 
					
						
							|  |  |  |                     "int@std::basic_string<char,std::char_traits<char>,std::allocator<char> >@std::less<int>@std::allocator<std::pair<const int,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >"); | 
					
						
							|  |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), sizeof(std::string), valueOffset, 0); | 
					
						
							|  |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-07 16:00:45 +02:00
										 |  |  | static int dumpStdMapStringString() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     typedef std::map<std::string,std::string> TestType; | 
					
						
							|  |  |  |     TestType test; | 
					
						
							|  |  |  |     const TestType::value_type entry("K", "V"); | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  |     if (!optEmptyContainers) { | 
					
						
							|  |  |  |         test.insert(entry); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-07-07 16:00:45 +02:00
										 |  |  |     const int valueOffset = (char*)&(entry.second) - (char*)&entry; | 
					
						
							|  |  |  |     prepareInBuffer("std::map", "local.stdmapstringstring", "local.stdmapstringstring", | 
					
						
							|  |  |  |                     "std::basic_string<char,std::char_traits<char>,std::allocator<char> >@std::basic_string<char,std::char_traits<char>,std::allocator<char> >@std::less<int>@std::allocator<std::pair<const std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >"); | 
					
						
							|  |  |  |     qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(std::string), sizeof(std::string), valueOffset, 0); | 
					
						
							|  |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-05 12:46:36 +02:00
										 |  |  | static int dumpQObject() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-06 09:22:05 +02:00
										 |  |  |     // Requires the childOffset to be know, but that is not critical
 | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  |     QAction action(0); | 
					
						
							|  |  |  |     QObject x; | 
					
						
							|  |  |  |     QAction *a2= new QAction(&action); | 
					
						
							|  |  |  |     a2->setObjectName(QLatin1String("a2")); | 
					
						
							|  |  |  |     action.setObjectName(QLatin1String("action")); | 
					
						
							|  |  |  |     QObject::connect(&action, SIGNAL(triggered()), &x, SLOT(deleteLater())); | 
					
						
							| 
									
										
										
										
											2009-05-05 12:46:36 +02:00
										 |  |  |     prepareInBuffer("QObject", "local.qobject", "local.qobject", ""); | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  |     qDumpObjectData440(2, 42, testAddress(&action), 1, 0, 0, 0, 0); | 
					
						
							|  |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputs("\n\n", stdout); | 
					
						
							|  |  |  |     // Property list
 | 
					
						
							|  |  |  |     prepareInBuffer("QObjectPropertyList", "local.qobjectpropertylist", "local.qobjectpropertylist", ""); | 
					
						
							|  |  |  |     qDumpObjectData440(2, 42, testAddress(&action), 1, 0, 0, 0, 0); | 
					
						
							|  |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputs("\n\n", stdout); | 
					
						
							|  |  |  |     // Signal list
 | 
					
						
							|  |  |  |     prepareInBuffer("QObjectSignalList", "local.qobjectsignallist", "local.qobjectsignallist", ""); | 
					
						
							|  |  |  |     qDumpObjectData440(2, 42, testAddress(&action), 1, 0, 0, 0, 0); | 
					
						
							|  |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     // Slot list
 | 
					
						
							|  |  |  |     prepareInBuffer("QObjectSlotList", "local.qobjectslotlist", "local.qobjectslotlist", ""); | 
					
						
							|  |  |  |     qDumpObjectData440(2, 42, testAddress(&action), 1, 0, 0, 0, 0); | 
					
						
							|  |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputs("\n\n", stdout); | 
					
						
							|  |  |  |     // Signal list
 | 
					
						
							|  |  |  |     prepareInBuffer("QObjectChildList", "local.qobjectchildlist", "local.qobjectchildlist", ""); | 
					
						
							|  |  |  |     qDumpObjectData440(2, 42, testAddress(&action), 1, 0, 0, 0, 0); | 
					
						
							|  |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int dumpQObjectList() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // Requires the childOffset to be know, but that is not critical
 | 
					
						
							|  |  |  |     QObject *root = new QObject; | 
					
						
							|  |  |  |     root ->setObjectName("root"); | 
					
						
							|  |  |  |     QTimer *t1 = new QTimer; | 
					
						
							|  |  |  |     t1 ->setObjectName("t1"); | 
					
						
							|  |  |  |     QTimer *t2 = new QTimer; | 
					
						
							|  |  |  |     t2 ->setObjectName("t2"); | 
					
						
							|  |  |  |     QObjectList test; | 
					
						
							|  |  |  |     test << root << t1 << t2; | 
					
						
							|  |  |  |     prepareInBuffer("QList", "local.qobjectlist", "local.qobjectlist", "QObject *"); | 
					
						
							|  |  |  |     qDumpObjectData440(2, 42, testAddress(&test), sizeof(QObject*), 0, 0, 0, 0); | 
					
						
							| 
									
										
										
										
											2009-05-05 12:46:36 +02:00
										 |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  |     delete root; | 
					
						
							| 
									
										
										
										
											2009-05-05 12:46:36 +02:00
										 |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  | typedef int (*DumpFunction)(); | 
					
						
							|  |  |  | typedef QMap<QString, DumpFunction> TypeDumpFunctionMap; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static TypeDumpFunctionMap registerTypes() | 
					
						
							| 
									
										
										
										
											2009-07-02 16:38:15 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  |     TypeDumpFunctionMap rc; | 
					
						
							|  |  |  |     rc.insert("QString", dumpQString); | 
					
						
							|  |  |  |     rc.insert("QSharedPointer<QString>", dumpQSharedPointerQString); | 
					
						
							|  |  |  |     rc.insert("QStringList", dumpQStringList); | 
					
						
							|  |  |  |     rc.insert("QList<int>", dumpQIntList); | 
					
						
							| 
									
										
										
										
											2009-09-21 14:55:39 +02:00
										 |  |  |     rc.insert("QLinkedList<int>", dumpQIntLinkedList); | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  |     rc.insert("QList<std::string>", dumpStdStringQList); | 
					
						
							|  |  |  |     rc.insert("QVector<int>", dumpQIntVector); | 
					
						
							| 
									
										
										
										
											2009-09-21 15:56:40 +02:00
										 |  |  |     rc.insert("QVector<QString>", dumpQQStringVector); | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  |     rc.insert("QMap<int,QString>", dumpQMapIntString); | 
					
						
							| 
									
										
										
										
											2009-09-21 14:55:39 +02:00
										 |  |  |     rc.insert("QMap<QString,QString>", dumpQMapQStringString); | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  |     rc.insert("QMap<int,int>", dumpQMapIntInt); | 
					
						
							| 
									
										
										
										
											2009-09-21 15:56:40 +02:00
										 |  |  |     rc.insert("QSet<int>", dumpQSetInt); | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  |     rc.insert("string", dumpStdString); | 
					
						
							|  |  |  |     rc.insert("wstring", dumpStdWString); | 
					
						
							|  |  |  |     rc.insert("list<int>", dumpStdIntList); | 
					
						
							|  |  |  |     rc.insert("list<string>", dumpStdStringList); | 
					
						
							|  |  |  |     rc.insert("vector<int>", dumpStdIntVector); | 
					
						
							|  |  |  |     rc.insert("vector<string>", dumpStdStringVector); | 
					
						
							|  |  |  |     rc.insert("vector<wstring>", dumpStdWStringVector); | 
					
						
							|  |  |  |     rc.insert("set<int>", dumpStdIntSet); | 
					
						
							|  |  |  |     rc.insert("set<string>", dumpStdStringSet); | 
					
						
							| 
									
										
										
										
											2009-07-07 16:00:45 +02:00
										 |  |  |     rc.insert("set<QString>", dumpStdQStringSet); | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  |     rc.insert("map<int,string>", dumpStdMapIntString); | 
					
						
							| 
									
										
										
										
											2009-07-07 16:00:45 +02:00
										 |  |  |     rc.insert("map<string,string>", dumpStdMapStringString); | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  |     rc.insert("QObject", dumpQObject); | 
					
						
							|  |  |  |     rc.insert("QObjectList", dumpQObjectList); | 
					
						
							|  |  |  |     rc.insert("QVariant", dumpQVariant); | 
					
						
							|  |  |  |     return rc; | 
					
						
							| 
									
										
										
										
											2009-07-02 16:38:15 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  | static void usage(const char *b, const TypeDumpFunctionMap &tdm) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     printf("Usage: %s [-v][-u][-e] <type1> <type2..>\n", b); | 
					
						
							|  |  |  |     printf("Usage: %s [-v][-u][-e] -a excluded_type1 <excluded_type2...>\n", b); | 
					
						
							|  |  |  |     printf("Options:  -u  Test uninitialized memory\n"); | 
					
						
							|  |  |  |     printf("          -e  Empty containers\n"); | 
					
						
							|  |  |  |     printf("          -v  Verbose\n"); | 
					
						
							|  |  |  |     printf("          -a  Test all available types\n"); | 
					
						
							|  |  |  |     printf("Supported types: "); | 
					
						
							|  |  |  |     const TypeDumpFunctionMap::const_iterator cend = tdm.constEnd(); | 
					
						
							|  |  |  |     for (TypeDumpFunctionMap::const_iterator it = tdm.constBegin(); it != cend; ++it) { | 
					
						
							|  |  |  |         fputs(qPrintable(it.key()), stdout); | 
					
						
							|  |  |  |         fputc(' ', stdout); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-05 12:11:22 +02:00
										 |  |  | int main(int argc, char *argv[]) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  |     printf("\nQt Creator Debugging Helper testing tool\n\n"); | 
					
						
							| 
									
										
										
										
											2009-05-05 12:11:22 +02:00
										 |  |  |     printf("Running query protocol\n"); | 
					
						
							| 
									
										
										
										
											2009-05-05 12:46:36 +02:00
										 |  |  |     qDumpObjectData440(1, 42, 0, 1, 0, 0, 0, 0); | 
					
						
							| 
									
										
										
										
											2009-05-05 12:11:22 +02:00
										 |  |  |     fputs(qDumpOutBuffer, stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							|  |  |  |     fputc('\n', stdout); | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const TypeDumpFunctionMap tdm = registerTypes(); | 
					
						
							|  |  |  |     const TypeDumpFunctionMap::const_iterator cend = tdm.constEnd(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (argc < 2) { | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  |         usage(argv[0], tdm); | 
					
						
							| 
									
										
										
										
											2009-05-05 12:11:22 +02:00
										 |  |  |         return 0; | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  |     // Parse args
 | 
					
						
							|  |  |  |     QStringList tests; | 
					
						
							|  |  |  |     for (int a = 1; a < argc; a++) { | 
					
						
							|  |  |  |         const char *arg = argv[a]; | 
					
						
							|  |  |  |         if (arg[0] == '-') { | 
					
						
							|  |  |  |             switch (arg[1]) { | 
					
						
							|  |  |  |             case 'a': | 
					
						
							|  |  |  |                 optTestAll = true; | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case 'u': | 
					
						
							|  |  |  |                 optTestUninitialized = true; | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case 'v': | 
					
						
							|  |  |  |                 optVerbose++; | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case 'e': | 
					
						
							|  |  |  |                 optEmptyContainers = true; | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             default: | 
					
						
							|  |  |  |                 fprintf(stderr, "Invalid option %s\n", arg); | 
					
						
							|  |  |  |                 usage(argv[0], tdm); | 
					
						
							|  |  |  |                 return -1; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             tests.push_back(QLatin1String(arg)); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     // Go
 | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  |     int rc = 0; | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  |     if (optTestAll) { | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  |         for (TypeDumpFunctionMap::const_iterator it = tdm.constBegin(); it != cend; ++it) { | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  |             const QString test = it.key(); | 
					
						
							|  |  |  |             if (tests.contains(test)) { | 
					
						
							|  |  |  |                 printf("\nSkipping: %s\n", qPrintable(test)); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 printf("\nTesting: %s\n", qPrintable(test)); | 
					
						
							|  |  |  |                 rc += (*it.value())(); | 
					
						
							|  |  |  |                 if (optTestUninitialized) | 
					
						
							|  |  |  |                     printf("Survived: %s\n", qPrintable(test)); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  |         foreach(const QString &test, tests) { | 
					
						
							|  |  |  |             printf("\nTesting: %s\n", qPrintable(test)); | 
					
						
							|  |  |  |             const TypeDumpFunctionMap::const_iterator it = tdm.constFind(test); | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  |             if (it == cend) { | 
					
						
							|  |  |  |                 rc = -1; | 
					
						
							| 
									
										
										
										
											2009-10-19 16:44:07 +02:00
										 |  |  |                 fprintf(stderr, "\nUnhandled type: %s\n", qPrintable(test)); | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  |             } else { | 
					
						
							|  |  |  |                 rc = (*it.value())(); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2009-05-22 14:31:37 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-05-05 12:46:36 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-07-06 17:36:50 +02:00
										 |  |  |     return rc; | 
					
						
							| 
									
										
										
										
											2009-05-05 12:11:22 +02:00
										 |  |  | } |