1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtCore module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
47 #define QT_VERSION_STR "5.0.0"
49 QT_VERSION is (major << 16) + (minor << 8) + patch.
51 #define QT_VERSION 0x050000
53 can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
55 #define QT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch))
57 #define QT_PACKAGEDATE_STR "YYYY-MM-DD"
59 #define QT_PACKAGE_TAG ""
61 #if !defined(QT_BUILD_MOC)
62 #include <QtCore/qconfig.h>
66 #include <QtCore/qsystemdetection.h>
67 #include <QtCore/qcompilerdetection.h>
68 #include <QtCore/qprocessordetection.h>
76 #ifndef QT_NAMESPACE /* user namespace */
78 # define QT_PREPEND_NAMESPACE(name) ::name
79 # define QT_USE_NAMESPACE
80 # define QT_BEGIN_NAMESPACE
81 # define QT_END_NAMESPACE
82 # define QT_BEGIN_INCLUDE_NAMESPACE
83 # define QT_END_INCLUDE_NAMESPACE
84 #ifndef QT_BEGIN_MOC_NAMESPACE
85 # define QT_BEGIN_MOC_NAMESPACE
87 #ifndef QT_END_MOC_NAMESPACE
88 # define QT_END_MOC_NAMESPACE
90 # define QT_FORWARD_DECLARE_CLASS(name) class name;
91 # define QT_FORWARD_DECLARE_STRUCT(name) struct name;
92 # define QT_MANGLE_NAMESPACE(name) name
94 #else /* user namespace */
96 # define QT_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name
97 # define QT_USE_NAMESPACE using namespace ::QT_NAMESPACE;
98 # define QT_BEGIN_NAMESPACE namespace QT_NAMESPACE {
99 # define QT_END_NAMESPACE }
100 # define QT_BEGIN_INCLUDE_NAMESPACE }
101 # define QT_END_INCLUDE_NAMESPACE namespace QT_NAMESPACE {
102 #ifndef QT_BEGIN_MOC_NAMESPACE
103 # define QT_BEGIN_MOC_NAMESPACE QT_USE_NAMESPACE
105 #ifndef QT_END_MOC_NAMESPACE
106 # define QT_END_MOC_NAMESPACE
108 # define QT_FORWARD_DECLARE_CLASS(name) \
109 QT_BEGIN_NAMESPACE class name; QT_END_NAMESPACE \
110 using QT_PREPEND_NAMESPACE(name);
112 # define QT_FORWARD_DECLARE_STRUCT(name) \
113 QT_BEGIN_NAMESPACE struct name; QT_END_NAMESPACE \
114 using QT_PREPEND_NAMESPACE(name);
116 # define QT_MANGLE_NAMESPACE0(x) x
117 # define QT_MANGLE_NAMESPACE1(a, b) a##_##b
118 # define QT_MANGLE_NAMESPACE2(a, b) QT_MANGLE_NAMESPACE1(a,b)
119 # define QT_MANGLE_NAMESPACE(name) QT_MANGLE_NAMESPACE2( \
120 QT_MANGLE_NAMESPACE0(name), QT_MANGLE_NAMESPACE0(QT_NAMESPACE))
122 namespace QT_NAMESPACE {}
124 # ifndef QT_BOOTSTRAPPED
125 # ifndef QT_NO_USING_NAMESPACE
127 This expands to a "using QT_NAMESPACE" also in _header files_.
128 It is the only way the feature can be used without too much
129 pain, but if people _really_ do not want it they can add
130 DEFINES += QT_NO_USING_NAMESPACE to their .pro files.
136 #endif /* user namespace */
138 #else /* __cplusplus */
140 # define QT_BEGIN_NAMESPACE
141 # define QT_END_NAMESPACE
142 # define QT_USE_NAMESPACE
143 # define QT_BEGIN_INCLUDE_NAMESPACE
144 # define QT_END_INCLUDE_NAMESPACE
146 #endif /* __cplusplus */
148 #define QT_BEGIN_HEADER
149 #define QT_END_HEADER
151 #if defined(Q_OS_DARWIN) && !defined(QT_LARGEFILE_SUPPORT)
152 # define QT_LARGEFILE_SUPPORT 64
157 # undef Q_NO_PACKED_REFERENCE
161 # define Q_LIKELY(x) (x)
164 # define Q_UNLIKELY(x) (x)
168 # define Q_ALLOC_SIZE(x)
171 #ifndef Q_CONSTRUCTOR_FUNCTION
172 # define Q_CONSTRUCTOR_FUNCTION0(AFUNC) \
174 static const struct AFUNC ## _ctor_class_ { \
175 inline AFUNC ## _ctor_class_() { AFUNC(); } \
176 } AFUNC ## _ctor_instance_; \
179 # define Q_CONSTRUCTOR_FUNCTION(AFUNC) Q_CONSTRUCTOR_FUNCTION0(AFUNC)
182 #ifndef Q_DESTRUCTOR_FUNCTION
183 # define Q_DESTRUCTOR_FUNCTION0(AFUNC) \
185 static const struct AFUNC ## _dtor_class_ { \
186 inline AFUNC ## _dtor_class_() { } \
187 inline ~ AFUNC ## _dtor_class_() { AFUNC(); } \
188 } AFUNC ## _dtor_instance_; \
190 # define Q_DESTRUCTOR_FUNCTION(AFUNC) Q_DESTRUCTOR_FUNCTION0(AFUNC)
193 #ifndef Q_REQUIRED_RESULT
194 # if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
195 # define Q_REQUIRED_RESULT __attribute__ ((warn_unused_result))
197 # define Q_REQUIRED_RESULT
205 Size-dependent types (architechture-dependent byte order)
207 Make sure to update QMetaType when changing these typedefs
210 typedef signed char qint8; /* 8 bit signed */
211 typedef unsigned char quint8; /* 8 bit unsigned */
212 typedef short qint16; /* 16 bit signed */
213 typedef unsigned short quint16; /* 16 bit unsigned */
214 typedef int qint32; /* 32 bit signed */
215 typedef unsigned int quint32; /* 32 bit unsigned */
216 #if defined(Q_OS_WIN) && !defined(Q_CC_GNU)
217 # define Q_INT64_C(c) c ## i64 /* signed 64 bit constant */
218 # define Q_UINT64_C(c) c ## ui64 /* unsigned 64 bit constant */
219 typedef __int64 qint64; /* 64 bit signed */
220 typedef unsigned __int64 quint64; /* 64 bit unsigned */
222 # define Q_INT64_C(c) static_cast<long long>(c ## LL) /* signed 64 bit constant */
223 # define Q_UINT64_C(c) static_cast<unsigned long long>(c ## ULL) /* unsigned 64 bit constant */
224 typedef long long qint64; /* 64 bit signed */
225 typedef unsigned long long quint64; /* 64 bit unsigned */
228 typedef qint64 qlonglong;
229 typedef quint64 qulonglong;
231 #ifndef QT_POINTER_SIZE
232 # if defined(Q_OS_WIN64)
233 # define QT_POINTER_SIZE 8
234 # elif defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
235 # define QT_POINTER_SIZE 4
239 #define Q_INIT_RESOURCE_EXTERN(name) \
240 extern int QT_MANGLE_NAMESPACE(qInitResources_ ## name) ();
242 #define Q_INIT_RESOURCE(name) \
243 do { extern int QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); \
244 QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); } while (0)
245 #define Q_CLEANUP_RESOURCE(name) \
246 do { extern int QT_MANGLE_NAMESPACE(qCleanupResources_ ## name) (); \
247 QT_MANGLE_NAMESPACE(qCleanupResources_ ## name) (); } while (0)
249 #if defined(__cplusplus)
252 quintptr and qptrdiff is guaranteed to be the same size as a pointer, i.e.
254 sizeof(void *) == sizeof(quintptr)
255 && sizeof(void *) == sizeof(qptrdiff)
257 template <int> struct QIntegerForSize;
258 template <> struct QIntegerForSize<1> { typedef quint8 Unsigned; typedef qint8 Signed; };
259 template <> struct QIntegerForSize<2> { typedef quint16 Unsigned; typedef qint16 Signed; };
260 template <> struct QIntegerForSize<4> { typedef quint32 Unsigned; typedef qint32 Signed; };
261 template <> struct QIntegerForSize<8> { typedef quint64 Unsigned; typedef qint64 Signed; };
262 template <class T> struct QIntegerForSizeof: QIntegerForSize<sizeof(T)> { };
263 typedef QIntegerForSizeof<void*>::Unsigned quintptr;
264 typedef QIntegerForSizeof<void*>::Signed qptrdiff;
265 typedef qptrdiff qintptr;
268 Useful type definitions for Qt
271 QT_BEGIN_INCLUDE_NAMESPACE
272 typedef unsigned char uchar;
273 typedef unsigned short ushort;
274 typedef unsigned int uint;
275 typedef unsigned long ulong;
276 QT_END_INCLUDE_NAMESPACE
278 #if defined(Q_NO_BOOL_TYPE)
279 #error "Compiler doesn't support the bool type"
287 #ifndef QT_LINUXBASE /* the LSB defines TRUE and FALSE for us */
295 Proper for-scoping in MIPSpro CC
297 #ifndef QT_NO_KEYWORDS
298 # if defined(Q_CC_MIPS) || (defined(Q_CC_HPACC) && defined(__ia64))
299 # define for if(0){}else for
304 Workaround for static const members on MSVC++.
307 #if defined(Q_CC_MSVC)
308 # define QT_STATIC_CONST static
309 # define QT_STATIC_CONST_IMPL
311 # define QT_STATIC_CONST static const
312 # define QT_STATIC_CONST_IMPL const
316 Warnings and errors when using deprecated methods
318 #if defined(Q_MOC_RUN)
319 # define Q_DECL_DEPRECATED Q_DECL_DEPRECATED
320 #elif (defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && (__GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2))) || defined(Q_CC_RVCT)
321 # define Q_DECL_DEPRECATED __attribute__ ((__deprecated__))
322 #elif defined(Q_CC_MSVC)
323 # define Q_DECL_DEPRECATED __declspec(deprecated)
324 # if defined (Q_CC_INTEL)
325 # define Q_DECL_VARIABLE_DEPRECATED
329 # define Q_DECL_DEPRECATED
331 #ifndef Q_DECL_VARIABLE_DEPRECATED
332 # define Q_DECL_VARIABLE_DEPRECATED Q_DECL_DEPRECATED
334 #ifndef Q_DECL_CONSTRUCTOR_DEPRECATED
335 # if defined(Q_MOC_RUN)
336 # define Q_DECL_CONSTRUCTOR_DEPRECATED Q_DECL_CONSTRUCTOR_DEPRECATED
337 # elif defined(Q_NO_DEPRECATED_CONSTRUCTORS)
338 # define Q_DECL_CONSTRUCTOR_DEPRECATED
340 # define Q_DECL_CONSTRUCTOR_DEPRECATED Q_DECL_DEPRECATED
344 #if defined(QT_NO_DEPRECATED)
345 # undef QT_DEPRECATED
346 # undef QT_DEPRECATED_VARIABLE
347 # undef QT_DEPRECATED_CONSTRUCTOR
348 #elif defined(QT_DEPRECATED_WARNINGS)
349 # undef QT_DEPRECATED
350 # define QT_DEPRECATED Q_DECL_DEPRECATED
351 # undef QT_DEPRECATED_VARIABLE
352 # define QT_DEPRECATED_VARIABLE Q_DECL_VARIABLE_DEPRECATED
353 # undef QT_DEPRECATED_CONSTRUCTOR
354 # define QT_DEPRECATED_CONSTRUCTOR explicit Q_DECL_CONSTRUCTOR_DEPRECATED
356 # undef QT_DEPRECATED
357 # define QT_DEPRECATED
358 # undef QT_DEPRECATED_VARIABLE
359 # define QT_DEPRECATED_VARIABLE
360 # undef QT_DEPRECATED_CONSTRUCTOR
361 # define QT_DEPRECATED_CONSTRUCTOR
364 #ifndef QT_DISABLE_DEPRECATED_BEFORE
365 // ### Qt5: remember to change that to 5 when we reach feature freeze
366 #define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(4, 9, 0)
370 QT_DEPRECATED_SINCE(major, minor) evaluates as true if the Qt version is greater than
371 the deprecation point specified.
373 Use it to specify from which version of Qt a function or class has been deprecated
376 #if QT_DEPRECATED_SINCE(5,1)
377 QT_DEPRECATED void deprecatedFunction(); //function deprecated since Qt 5.1
382 #define QT_DEPRECATED_SINCE(major, minor) (QT_VERSION_CHECK(major, minor, 0) > QT_DISABLE_DEPRECATED_BEFORE)
384 #define QT_DEPRECATED_SINCE(major, minor) 0
387 /* moc compats (signals/slots) */
388 #ifndef QT_MOC_COMPAT
389 # define QT_MOC_COMPAT
391 # undef QT_MOC_COMPAT
392 # define QT_MOC_COMPAT
395 #ifdef QT_ASCII_CAST_WARNINGS
396 # define QT_ASCII_CAST_WARN Q_DECL_DEPRECATED
397 # if defined(Q_CC_GNU) && __GNUC__ < 4
398 /* gcc < 4 doesn't like Q_DECL_DEPRECATED in front of constructors */
399 # define QT_ASCII_CAST_WARN_CONSTRUCTOR
401 # define QT_ASCII_CAST_WARN_CONSTRUCTOR Q_DECL_CONSTRUCTOR_DEPRECATED
404 # define QT_ASCII_CAST_WARN
405 # define QT_ASCII_CAST_WARN_CONSTRUCTOR
408 #if defined(__i386__) || defined(_WIN32) || defined(_WIN32_WCE)
409 # if defined(Q_CC_GNU)
410 #if !defined(Q_CC_INTEL) && ((100*(__GNUC__ - 0) + 10*(__GNUC_MINOR__ - 0) + __GNUC_PATCHLEVEL__) >= 332)
411 # define QT_FASTCALL __attribute__((regparm(3)))
415 # elif defined(Q_CC_MSVC)
416 # define QT_FASTCALL __fastcall
424 #ifdef Q_COMPILER_NULLPTR
425 # define Q_NULLPTR nullptr
430 #ifdef Q_COMPILER_DEFAULT_DELETE_MEMBERS
431 # define Q_DECL_EQ_DELETE = delete
433 # define Q_DECL_EQ_DELETE
436 #ifdef Q_COMPILER_CONSTEXPR
437 # define Q_DECL_CONSTEXPR constexpr
439 # define Q_DECL_CONSTEXPR
442 #ifdef Q_COMPILER_EXPLICIT_OVERRIDES
443 # define Q_DECL_OVERRIDE override
444 # define Q_DECL_FINAL final
446 # define Q_DECL_OVERRIDE
447 # define Q_DECL_FINAL
450 //defines the type for the WNDPROC on windows
451 //the alignment needs to be forced for sse2 to not crash with mingw
452 #if defined(Q_OS_WIN)
453 # if defined(Q_CC_MINGW)
454 # define QT_ENSURE_STACK_ALIGNED_FOR_SSE __attribute__ ((force_align_arg_pointer))
456 # define QT_ENSURE_STACK_ALIGNED_FOR_SSE
458 # define QT_WIN_CALLBACK CALLBACK QT_ENSURE_STACK_ALIGNED_FOR_SSE
461 typedef int QNoImplicitBoolCast;
463 // This logic must match the one in qmetatype.h
464 #if defined(QT_COORD_TYPE)
465 typedef QT_COORD_TYPE qreal;
466 #elif defined(QT_NO_FPU) || defined(QT_ARCH_ARM) || defined(QT_ARCH_WINDOWSCE)
469 typedef double qreal;
473 Utility macros and inline functions
476 template <typename T>
477 Q_DECL_CONSTEXPR inline T qAbs(const T &t) { return t >= 0 ? t : -t; }
479 Q_DECL_CONSTEXPR inline int qRound(double d)
480 { return d >= 0.0 ? int(d + 0.5) : int(d - int(d-1) + 0.5) + int(d-1); }
481 Q_DECL_CONSTEXPR inline int qRound(float d)
482 { return d >= 0.0f ? int(d + 0.5f) : int(d - int(d-1) + 0.5f) + int(d-1); }
485 Just for documentation generation
490 Q_DECL_CONSTEXPR inline qint64 qRound64(double d)
491 { return d >= 0.0 ? qint64(d + 0.5) : qint64(d - double(qint64(d-1)) + 0.5) + qint64(d-1); }
492 Q_DECL_CONSTEXPR inline qint64 qRound64(float d)
493 { return d >= 0.0f ? qint64(d + 0.5f) : qint64(d - float(qint64(d-1)) + 0.5f) + qint64(d-1); }
496 Just for documentation generation
498 qint64 qRound64(qreal d);
501 template <typename T>
502 Q_DECL_CONSTEXPR inline const T &qMin(const T &a, const T &b) { return (a < b) ? a : b; }
503 template <typename T>
504 Q_DECL_CONSTEXPR inline const T &qMax(const T &a, const T &b) { return (a < b) ? b : a; }
505 template <typename T>
506 Q_DECL_CONSTEXPR inline const T &qBound(const T &min, const T &val, const T &max)
507 { return qMax(min, qMin(max, val)); }
510 Data stream functions are provided by many classes (defined in qdatastream.h)
515 #if !defined(QT_NO_COP)
519 #if defined(Q_OS_VXWORKS)
520 # define QT_NO_CRASHHANDLER // no popen
521 # define QT_NO_PROCESS // no exec*, no fork
523 # define QT_NO_SHAREDMEMORY // only POSIX, no SysV and in the end...
524 # define QT_NO_SYSTEMSEMAPHORE // not needed at all in a flat address space
525 # define QT_NO_QWS_MULTIPROCESS // no processes
528 # include <QtCore/qfeatures.h>
530 #define QT_SUPPORTS(FEATURE) (!defined(QT_NO_##FEATURE))
532 #if defined(Q_OS_LINUX) && defined(Q_CC_RVCT)
533 # define Q_DECL_EXPORT __attribute__((visibility("default")))
534 # define Q_DECL_IMPORT __attribute__((visibility("default")))
535 # define Q_DECL_HIDDEN __attribute__((visibility("hidden")))
538 #ifndef Q_DECL_EXPORT
539 # if defined(Q_OS_WIN) || defined(Q_CC_RVCT)
540 # define Q_DECL_EXPORT __declspec(dllexport)
541 # elif defined(QT_VISIBILITY_AVAILABLE)
542 # define Q_DECL_EXPORT __attribute__((visibility("default")))
543 # define Q_DECL_HIDDEN __attribute__((visibility("hidden")))
545 # ifndef Q_DECL_EXPORT
546 # define Q_DECL_EXPORT
549 #ifndef Q_DECL_IMPORT
550 # if defined(Q_OS_WIN) || defined(Q_CC_RVCT)
551 # define Q_DECL_IMPORT __declspec(dllimport)
553 # define Q_DECL_IMPORT
556 #ifndef Q_DECL_HIDDEN
557 # define Q_DECL_HIDDEN
562 Create Qt DLL if QT_DLL is defined (Windows only)
565 #if defined(Q_OS_WIN)
566 # if defined(QT_NODLL)
569 # elif defined(QT_MAKEDLL) /* create a Qt DLL library */
573 # if defined(QT_BUILD_CORE_LIB)
574 # define Q_CORE_EXPORT Q_DECL_EXPORT
576 # define Q_CORE_EXPORT Q_DECL_IMPORT
578 # if defined(QT_BUILD_GUI_LIB)
579 # define Q_GUI_EXPORT Q_DECL_EXPORT
581 # define Q_GUI_EXPORT Q_DECL_IMPORT
583 # if defined(QT_BUILD_WIDGETS_LIB)
584 # define Q_WIDGETS_EXPORT Q_DECL_EXPORT
586 # define Q_WIDGETS_EXPORT Q_DECL_IMPORT
588 # if defined(QT_BUILD_PLATFORMSUPPORT_LIB)
589 # define Q_PLATFORMSUPPORT_EXPORT Q_DECL_EXPORT
591 # define Q_PLATFORMSUPPORT_EXPORT Q_DECL_IMPORT
593 # if defined(QT_BUILD_PRINTSUPPORT_LIB)
594 # define Q_PRINTSUPPORT_EXPORT Q_DECL_EXPORT
596 # define Q_PRINTSUPPORT_EXPORT Q_DECL_IMPORT
598 # if defined(QT_BUILD_SQL_LIB)
599 # define Q_SQL_EXPORT Q_DECL_EXPORT
601 # define Q_SQL_EXPORT Q_DECL_IMPORT
603 # if defined(QT_BUILD_NETWORK_LIB)
604 # define Q_NETWORK_EXPORT Q_DECL_EXPORT
606 # define Q_NETWORK_EXPORT Q_DECL_IMPORT
608 # if defined(QT_BUILD_SVG_LIB)
609 # define Q_SVG_EXPORT Q_DECL_EXPORT
611 # define Q_SVG_EXPORT Q_DECL_IMPORT
613 # if defined(QT_BUILD_QTQUICK1_LIB)
614 # define Q_QTQUICK1_EXPORT Q_DECL_EXPORT
616 # define Q_QTQUICK1_EXPORT Q_DECL_IMPORT
618 # if defined(QT_BUILD_DECLARATIVE_LIB)
619 # define Q_DECLARATIVE_EXPORT Q_DECL_EXPORT
621 # define Q_DECLARATIVE_EXPORT Q_DECL_IMPORT
623 # if defined(QT_BUILD_OPENGL_LIB)
624 # define Q_OPENGL_EXPORT Q_DECL_EXPORT
626 # define Q_OPENGL_EXPORT Q_DECL_IMPORT
628 # if defined(QT_BUILD_MULTIMEDIA_LIB)
629 # define Q_MULTIMEDIA_EXPORT Q_DECL_EXPORT
631 # define Q_MULTIMEDIA_EXPORT Q_DECL_IMPORT
633 # if defined(QT_BUILD_OPENVG_LIB)
634 # define Q_OPENVG_EXPORT Q_DECL_EXPORT
636 # define Q_OPENVG_EXPORT Q_DECL_IMPORT
638 # if defined(QT_BUILD_XML_LIB)
639 # define Q_XML_EXPORT Q_DECL_EXPORT
641 # define Q_XML_EXPORT Q_DECL_IMPORT
643 # if defined(QT_BUILD_XMLPATTERNS_LIB)
644 # define Q_XMLPATTERNS_EXPORT Q_DECL_EXPORT
646 # define Q_XMLPATTERNS_EXPORT Q_DECL_IMPORT
648 # if defined(QT_BUILD_SCRIPT_LIB)
649 # define Q_SCRIPT_EXPORT Q_DECL_EXPORT
651 # define Q_SCRIPT_EXPORT Q_DECL_IMPORT
653 # if defined(QT_BUILD_SCRIPTTOOLS_LIB)
654 # define Q_SCRIPTTOOLS_EXPORT Q_DECL_EXPORT
656 # define Q_SCRIPTTOOLS_EXPORT Q_DECL_IMPORT
658 # if defined(QT_BUILD_CANVAS_LIB)
659 # define Q_CANVAS_EXPORT Q_DECL_EXPORT
661 # define Q_CANVAS_EXPORT Q_DECL_IMPORT
663 # if defined(QT_BUILD_COMPAT_LIB)
664 # define Q_COMPAT_EXPORT Q_DECL_EXPORT
666 # define Q_COMPAT_EXPORT Q_DECL_IMPORT
668 # if defined(QT_BUILD_DBUS_LIB)
669 # define Q_DBUS_EXPORT Q_DECL_EXPORT
671 # define Q_DBUS_EXPORT Q_DECL_IMPORT
673 # define Q_TEMPLATEDLL
674 # if defined(QT_BUILD_CONCURRENT_LIB)
675 # define Q_CONCURRENT_EXPORT Q_DECL_EXPORT
677 # define Q_CONCURRENT_EXPORT Q_DECL_IMPORT
679 # elif defined(QT_DLL) /* use a Qt DLL library */
680 # define Q_CORE_EXPORT Q_DECL_IMPORT
681 # define Q_GUI_EXPORT Q_DECL_IMPORT
682 # define Q_WIDGETS_EXPORT Q_DECL_IMPORT
683 # define Q_PLATFORMSUPPORT_EXPORT Q_DECL_IMPORT
684 # define Q_PRINTSUPPORT_EXPORT Q_DECL_IMPORT
685 # define Q_SQL_EXPORT Q_DECL_IMPORT
686 # define Q_NETWORK_EXPORT Q_DECL_IMPORT
687 # define Q_SVG_EXPORT Q_DECL_IMPORT
688 # define Q_DECLARATIVE_EXPORT Q_DECL_IMPORT
689 # define Q_QTQUICK1_EXPORT Q_DECL_IMPORT
690 # define Q_CANVAS_EXPORT Q_DECL_IMPORT
691 # define Q_OPENGL_EXPORT Q_DECL_IMPORT
692 # define Q_MULTIMEDIA_EXPORT Q_DECL_IMPORT
693 # define Q_OPENVG_EXPORT Q_DECL_IMPORT
694 # define Q_XML_EXPORT Q_DECL_IMPORT
695 # define Q_XMLPATTERNS_EXPORT Q_DECL_IMPORT
696 # define Q_SCRIPT_EXPORT Q_DECL_IMPORT
697 # define Q_SCRIPTTOOLS_EXPORT Q_DECL_IMPORT
698 # define Q_COMPAT_EXPORT Q_DECL_IMPORT
699 # define Q_DBUS_EXPORT Q_DECL_IMPORT
700 # define Q_CONCURRENT_EXPORT Q_DECL_IMPORT
701 # define Q_TEMPLATEDLL
703 # define Q_NO_DECLARED_NOT_DEFINED
705 # if defined(Q_OS_LINUX) && defined(Q_CC_BOR)
706 # define Q_TEMPLATEDLL
707 # define Q_NO_DECLARED_NOT_DEFINED
709 # undef QT_MAKEDLL /* ignore these for other platforms */
713 #if !defined(Q_CORE_EXPORT)
714 # if defined(QT_SHARED)
715 # define Q_CORE_EXPORT Q_DECL_EXPORT
716 # define Q_GUI_EXPORT Q_DECL_EXPORT
717 # define Q_WIDGETS_EXPORT Q_DECL_EXPORT
718 # define Q_PLATFORMSUPPORT_EXPORT Q_DECL_EXPORT
719 # define Q_PRINTSUPPORT_EXPORT Q_DECL_EXPORT
720 # define Q_SQL_EXPORT Q_DECL_EXPORT
721 # define Q_NETWORK_EXPORT Q_DECL_EXPORT
722 # define Q_SVG_EXPORT Q_DECL_EXPORT
723 # define Q_DECLARATIVE_EXPORT Q_DECL_EXPORT
724 # define Q_QTQUICK1_EXPORT Q_DECL_EXPORT
725 # define Q_OPENGL_EXPORT Q_DECL_EXPORT
726 # define Q_MULTIMEDIA_EXPORT Q_DECL_EXPORT
727 # define Q_OPENVG_EXPORT Q_DECL_EXPORT
728 # define Q_XML_EXPORT Q_DECL_EXPORT
729 # define Q_XMLPATTERNS_EXPORT Q_DECL_EXPORT
730 # define Q_SCRIPT_EXPORT Q_DECL_EXPORT
731 # define Q_SCRIPTTOOLS_EXPORT Q_DECL_EXPORT
732 # define Q_COMPAT_EXPORT Q_DECL_EXPORT
733 # define Q_DBUS_EXPORT Q_DECL_EXPORT
734 # define Q_CONCURRENT_EXPORT Q_DECL_EXPORT
736 # define Q_CORE_EXPORT
737 # define Q_GUI_EXPORT
738 # define Q_WIDGETS_EXPORT
739 # define Q_PLATFORMSUPPORT_EXPORT
740 # define Q_PRINTSUPPORT_EXPORT
741 # define Q_SQL_EXPORT
742 # define Q_NETWORK_EXPORT
743 # define Q_SVG_EXPORT
744 # define Q_DECLARATIVE_EXPORT
745 # define Q_QTQUICK1_EXPORT
746 # define Q_OPENGL_EXPORT
747 # define Q_MULTIMEDIA_EXPORT
748 # define Q_OPENVG_EXPORT
749 # define Q_XML_EXPORT
750 # define Q_XMLPATTERNS_EXPORT
751 # define Q_SCRIPT_EXPORT
752 # define Q_SCRIPTTOOLS_EXPORT
753 # define Q_COMPAT_EXPORT
754 # define Q_DBUS_EXPORT
755 # define Q_CONCURRENT_EXPORT
759 // Functions marked as Q_GUI_EXPORT_INLINE were exported and inlined by mistake.
760 // Compilers like MinGW complain that the import attribute is ignored.
761 #if defined(Q_CC_MINGW)
762 # if defined(QT_BUILD_CORE_LIB)
763 # define Q_CORE_EXPORT_INLINE Q_CORE_EXPORT inline
765 # define Q_CORE_EXPORT_INLINE inline
767 # if defined(QT_BUILD_GUI_LIB)
768 # define Q_GUI_EXPORT_INLINE Q_GUI_EXPORT inline
770 # define Q_GUI_EXPORT_INLINE inline
772 # if defined(QT_BUILD_WIDGETS_LIB)
773 # define Q_WIDGETS_EXPORT_INLINE Q_WIDGETS_EXPORT inline
775 # define Q_WIDGETS_EXPORT_INLINE inline
777 # if defined(QT_BUILD_PLATFORMSUPPORT_LIB)
778 # define Q_PLATFORMSUPPORT_EXPORT_INLINE Q_PLATFORMSUPPORT_EXPORT inline
780 # define Q_PLATFORMSUPPORT_EXPORT_INLINE inline
782 # if defined(QT_BUILD_PRINTSUPPORT_LIB)
783 # define Q_PRINTSUPPORT_EXPORT_INLINE Q_PRINTSUPPORT_EXPORT inline
785 # define Q_PRINTSUPPORT_EXPORT_INLINE inline
787 # if defined(QT_BUILD_COMPAT_LIB)
788 # define Q_COMPAT_EXPORT_INLINE Q_COMPAT_EXPORT inline
790 # define Q_COMPAT_EXPORT_INLINE inline
792 #elif defined(Q_CC_RVCT)
793 // we force RVCT not to export inlines by passing --visibility_inlines_hidden
794 // so we need to just inline it, rather than exporting and inlining
795 // note: this affects the contents of the DEF files (ie. these functions do not appear)
796 # define Q_CORE_EXPORT_INLINE inline
797 # define Q_GUI_EXPORT_INLINE inline
798 # define Q_WIDGETS_EXPORT_INLINE inline
799 # define Q_PLATFORMSUPPORT_EXPORT_INLINE inline
800 # define Q_PRINTSUPPORT_EXPORT_INLINE inline
801 # define Q_COMPAT_EXPORT_INLINE inline
803 # define Q_CORE_EXPORT_INLINE Q_CORE_EXPORT inline
804 # define Q_GUI_EXPORT_INLINE Q_GUI_EXPORT inline
805 # define Q_WIDGETS_EXPORT_INLINE Q_WIDGETS_EXPORT inline
806 # define Q_PLATFORMSUPPORT_EXPORT_INLINE Q_PLATFORMSUPPORT_EXPORT inline
807 # define Q_PRINTSUPPORT_EXPORT_INLINE Q_PRINTSUPPORT_EXPORT inline
808 # define Q_COMPAT_EXPORT_INLINE Q_COMPAT_EXPORT inline
812 No, this is not an evil backdoor. QT_BUILD_INTERNAL just exports more symbols
813 for Qt's internal unit tests. If you want slower loading times and more
814 symbols that can vanish from version to version, feel free to define QT_BUILD_INTERNAL.
816 #if defined(QT_BUILD_INTERNAL) && defined(Q_OS_WIN) && defined(QT_MAKEDLL)
817 # define Q_AUTOTEST_EXPORT Q_DECL_EXPORT
818 #elif defined(QT_BUILD_INTERNAL) && defined(Q_OS_WIN) && defined(QT_DLL)
819 # define Q_AUTOTEST_EXPORT Q_DECL_IMPORT
820 #elif defined(QT_BUILD_INTERNAL) && !defined(Q_OS_WIN) && defined(QT_SHARED)
821 # define Q_AUTOTEST_EXPORT Q_DECL_EXPORT
823 # define Q_AUTOTEST_EXPORT
826 inline void qt_noop(void) {}
828 /* These wrap try/catch so we can switch off exceptions later.
830 Beware - do not use more than one QT_CATCH per QT_TRY, and do not use
831 the exception instance in the catch block.
832 If you can't live with those constraints, don't use these macros.
833 Use the QT_NO_EXCEPTIONS macro to protect your code instead.
836 #ifdef QT_BOOTSTRAPPED
837 # define QT_NO_EXCEPTIONS
839 #if !defined(QT_NO_EXCEPTIONS) && defined(Q_CC_GNU) && !defined (__EXCEPTIONS) && !defined(Q_MOC_RUN)
840 # define QT_NO_EXCEPTIONS
843 #ifdef QT_NO_EXCEPTIONS
844 # define QT_TRY if (true)
845 # define QT_CATCH(A) else
846 # define QT_THROW(A) qt_noop()
847 # define QT_RETHROW qt_noop()
850 # define QT_CATCH(A) catch (A)
851 # define QT_THROW(A) throw A
852 # define QT_RETHROW throw
860 class Q_CORE_EXPORT QSysInfo {
863 WordSize = (sizeof(void *)<<3)
866 #if defined(QT_BUILD_QMAKE)
871 /* needed to bootstrap qmake */
872 static const int ByteOrder;
873 #elif defined(Q_BYTE_ORDER)
879 , ByteOrder = <platform-dependent>
880 # elif Q_BYTE_ORDER == Q_BIG_ENDIAN
881 , ByteOrder = BigEndian
882 # elif Q_BYTE_ORDER == Q_LITTLE_ENDIAN
883 , ByteOrder = LittleEndian
885 # error "Undefined byte order"
889 # error "Qt not configured correctly, please run configure"
891 #if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
897 WV_DOS_based= 0x000f,
905 WV_WINDOWS7 = 0x0090,
906 WV_NT_based = 0x00f0,
908 /* version numbers */
914 WV_6_1 = WV_WINDOWS7,
922 static const WinVersion WindowsVersion;
923 static WinVersion windowsVersion();
942 MV_CHEETAH = MV_10_0,
945 MV_PANTHER = MV_10_3,
947 MV_LEOPARD = MV_10_5,
948 MV_SNOWLEOPARD = MV_10_6,
951 static const MacVersion MacintoshVersion;
955 Q_CORE_EXPORT const char *qVersion();
956 Q_CORE_EXPORT bool qSharedBuild();
958 #if defined(Q_OS_MAC)
959 inline int qMacVersion() { return QSysInfo::MacintoshVersion; }
962 #ifndef Q_OUTOFLINE_TEMPLATE
963 # define Q_OUTOFLINE_TEMPLATE
965 #ifndef Q_INLINE_TEMPLATE
966 # define Q_INLINE_TEMPLATE inline
970 Avoid "unused parameter" warnings
973 #if defined(Q_CC_INTEL) && !defined(Q_OS_WIN) || defined(Q_CC_RVCT)
974 template <typename T>
975 inline void qUnused(T &x) { (void)x; }
976 # define Q_UNUSED(x) qUnused(x);
978 # define Q_UNUSED(x) (void)x;
982 Debugging and error handling
985 #if !defined(QT_NO_DEBUG) && !defined(QT_DEBUG)
990 # define qPrintable(string) QString(string).toLocal8Bit().constData()
994 Q_CORE_EXPORT QString qt_error_string(int errorCode = -1);
995 Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int line);
997 #if !defined(Q_ASSERT)
998 # if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS)
999 # define Q_ASSERT(cond) qt_noop()
1001 # define Q_ASSERT(cond) ((!(cond)) ? qt_assert(#cond,__FILE__,__LINE__) : qt_noop())
1005 #if defined(QT_NO_DEBUG) && !defined(QT_PAINT_DEBUG)
1006 #define QT_NO_PAINT_DEBUG
1009 Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char *file, int line);
1011 #if !defined(Q_ASSERT_X)
1012 # if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS)
1013 # define Q_ASSERT_X(cond, where, what) qt_noop()
1015 # define Q_ASSERT_X(cond, where, what) ((!(cond)) ? qt_assert_x(where, what,__FILE__,__LINE__) : qt_noop())
1020 #ifdef Q_COMPILER_STATIC_ASSERT
1021 #define Q_STATIC_ASSERT(Condition) static_assert(bool(Condition), #Condition)
1022 #define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message)
1024 // Intentionally undefined
1025 template <bool Test> class QStaticAssertFailure;
1026 template <> class QStaticAssertFailure<true> {};
1028 #define Q_STATIC_ASSERT_PRIVATE_JOIN(A, B) Q_STATIC_ASSERT_PRIVATE_JOIN_IMPL(A, B)
1029 #define Q_STATIC_ASSERT_PRIVATE_JOIN_IMPL(A, B) A ## B
1030 #define Q_STATIC_ASSERT(Condition) \
1031 enum {Q_STATIC_ASSERT_PRIVATE_JOIN(q_static_assert_result, __LINE__) = sizeof(QStaticAssertFailure<!!(Condition)>)}
1032 #define Q_STATIC_ASSERT_X(Condition, Message) Q_STATIC_ASSERT(Condition)
1035 Q_CORE_EXPORT void qt_check_pointer(const char *, int);
1036 Q_CORE_EXPORT void qBadAlloc();
1038 #ifdef QT_NO_EXCEPTIONS
1039 # if defined(QT_NO_DEBUG)
1040 # define Q_CHECK_PTR(p) qt_noop()
1042 # define Q_CHECK_PTR(p) do {if(!(p))qt_check_pointer(__FILE__,__LINE__);} while (0)
1045 # define Q_CHECK_PTR(p) do { if (!(p)) qBadAlloc(); } while (0)
1048 template <typename T>
1049 inline T *q_check_ptr(T *p) { Q_CHECK_PTR(p); return p; }
1051 #if (defined(Q_CC_GNU) && !defined(Q_OS_SOLARIS)) || defined(Q_CC_HPACC) || defined(Q_CC_DIAB)
1052 # define Q_FUNC_INFO __PRETTY_FUNCTION__
1053 #elif defined(_MSC_VER)
1054 # define Q_FUNC_INFO __FUNCSIG__
1056 # if defined(Q_OS_SOLARIS) || defined(Q_CC_XLC)
1057 # define Q_FUNC_INFO __FILE__ "(line number unavailable)"
1059 /* These two macros makes it possible to turn the builtin line expander into a
1060 * string literal. */
1061 # define QT_STRINGIFY2(x) #x
1062 # define QT_STRINGIFY(x) QT_STRINGIFY2(x)
1063 # define Q_FUNC_INFO __FILE__ ":" QT_STRINGIFY(__LINE__)
1065 /* The MIPSpro and RVCT compilers postpones macro expansion,
1066 and therefore macros must be in scope when being used. */
1067 # if !defined(Q_CC_MIPS) && !defined(Q_CC_RVCT)
1068 # undef QT_STRINGIFY2
1069 # undef QT_STRINGIFY
1074 typedef void (*QFunctionPointer)();
1076 #if !defined(Q_UNIMPLEMENTED)
1077 # define Q_UNIMPLEMENTED() qWarning("%s:%d: %s: Unimplemented code.", __FILE__, __LINE__, Q_FUNC_INFO)
1080 #if defined(QT_NO_THREAD)
1082 template <typename T>
1087 inline QGlobalStatic(T *p) : pointer(p) { }
1088 inline ~QGlobalStatic() { pointer = 0; }
1091 #define Q_GLOBAL_STATIC(TYPE, NAME) \
1092 static TYPE *NAME() \
1094 static TYPE thisVariable; \
1095 static QGlobalStatic<TYPE > thisGlobalStatic(&thisVariable); \
1096 return thisGlobalStatic.pointer; \
1099 #define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \
1100 static TYPE *NAME() \
1102 static TYPE thisVariable ARGS; \
1103 static QGlobalStatic<TYPE > thisGlobalStatic(&thisVariable); \
1104 return thisGlobalStatic.pointer; \
1107 #define Q_GLOBAL_STATIC_WITH_INITIALIZER(TYPE, NAME, INITIALIZER) \
1108 static TYPE *NAME() \
1110 static TYPE thisVariable; \
1111 static QGlobalStatic<TYPE > thisGlobalStatic(0); \
1112 if (!thisGlobalStatic.pointer) { \
1113 TYPE *x = thisGlobalStatic.pointer = &thisVariable; \
1116 return thisGlobalStatic.pointer; \
1121 // forward declaration, since qatomic.h needs qglobal.h
1122 template <typename T> class QBasicAtomicPointer;
1124 // POD for Q_GLOBAL_STATIC
1125 template <typename T>
1129 QBasicAtomicPointer<T> pointer;
1133 // Created as a function-local static to delete a QGlobalStatic<T>
1134 template <typename T>
1135 class QGlobalStaticDeleter
1138 QGlobalStatic<T> &globalStatic;
1139 QGlobalStaticDeleter(QGlobalStatic<T> &_globalStatic)
1140 : globalStatic(_globalStatic)
1143 inline ~QGlobalStaticDeleter()
1145 delete globalStatic.pointer.load();
1146 globalStatic.pointer.store(0);
1147 globalStatic.destroyed = true;
1151 #define Q_GLOBAL_STATIC(TYPE, NAME) \
1152 static TYPE *NAME() \
1154 static QGlobalStatic<TYPE > thisGlobalStatic \
1155 = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \
1156 if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { \
1157 TYPE *x = new TYPE; \
1158 if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) \
1161 static QGlobalStaticDeleter<TYPE > cleanup(thisGlobalStatic); \
1163 return thisGlobalStatic.pointer.load(); \
1166 #define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \
1167 static TYPE *NAME() \
1169 static QGlobalStatic<TYPE > thisGlobalStatic \
1170 = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \
1171 if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { \
1172 TYPE *x = new TYPE ARGS; \
1173 if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) \
1176 static QGlobalStaticDeleter<TYPE > cleanup(thisGlobalStatic); \
1178 return thisGlobalStatic.pointer.load(); \
1181 #define Q_GLOBAL_STATIC_WITH_INITIALIZER(TYPE, NAME, INITIALIZER) \
1182 static TYPE *NAME() \
1184 static QGlobalStatic<TYPE > thisGlobalStatic \
1185 = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \
1186 if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { \
1187 QScopedPointer<TYPE > x(new TYPE); \
1189 if (thisGlobalStatic.pointer.testAndSetOrdered(0, x.data())) { \
1190 static QGlobalStaticDeleter<TYPE > cleanup(thisGlobalStatic); \
1194 return thisGlobalStatic.pointer.load(); \
1199 Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(double p1, double p2)
1201 return (qAbs(p1 - p2) <= 0.000000000001 * qMin(qAbs(p1), qAbs(p2)));
1204 Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(float p1, float p2)
1206 return (qAbs(p1 - p2) <= 0.00001f * qMin(qAbs(p1), qAbs(p2)));
1212 Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(double d)
1214 return qAbs(d) <= 0.000000000001;
1220 Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f)
1222 return qAbs(f) <= 0.00001f;
1226 This function tests a double for a null value. It doesn't
1227 check whether the actual value is 0 or close to 0, but whether
1230 static inline bool qIsNull(double d)
1238 return val.u == quint64(0);
1242 This function tests a float for a null value. It doesn't
1243 check whether the actual value is 0 or close to 0, but whether
1246 static inline bool qIsNull(float f)
1258 Compilers which follow outdated template instantiation rules
1259 require a class to have a comparison operator to exist when
1260 a QList of this type is instantiated. It's not actually
1261 used in the list, though. Hence the dummy implementation.
1262 Just in case other code relies on it we better trigger a warning
1263 mandating a real implementation.
1266 #ifdef Q_FULL_TEMPLATE_INSTANTIATION
1267 # define Q_DUMMY_COMPARISON_OPERATOR(C) \
1268 bool operator==(const C&) const { \
1269 qWarning(#C"::operator==(const "#C"&) was called"); \
1274 # define Q_DUMMY_COMPARISON_OPERATOR(C)
1279 QTypeInfo - type trait functionality
1280 qIsDetached - data sharing functionality
1284 The catch-all template.
1287 template <typename T> inline bool qIsDetached(T &) { return true; }
1289 template <typename T>
1297 isLarge = (sizeof(T)>sizeof(void*)),
1304 class QTypeInfo<void>
1317 template <typename T>
1332 #define Q_DECLARE_MOVABLE_CONTAINER(CONTAINER) \
1333 template <typename T> class CONTAINER; \
1334 template <typename T> \
1335 class QTypeInfo< CONTAINER<T> > \
1339 isPointer = false, \
1342 isLarge = (sizeof(CONTAINER<T>) > sizeof(void*)), \
1344 sizeOf = sizeof(CONTAINER<T>) \
1348 Q_DECLARE_MOVABLE_CONTAINER(QList)
1349 Q_DECLARE_MOVABLE_CONTAINER(QVector)
1350 Q_DECLARE_MOVABLE_CONTAINER(QQueue)
1351 Q_DECLARE_MOVABLE_CONTAINER(QStack)
1352 Q_DECLARE_MOVABLE_CONTAINER(QLinkedList)
1353 Q_DECLARE_MOVABLE_CONTAINER(QSet)
1355 #undef Q_DECLARE_MOVABLE_CONTAINER
1358 Specialize a specific type with:
1360 Q_DECLARE_TYPEINFO(type, flags);
1362 where 'type' is the name of the type to specialize and 'flags' is
1363 logically-OR'ed combination of the flags below.
1365 enum { /* TYPEINFO flags */
1367 Q_PRIMITIVE_TYPE = 0x1,
1369 Q_MOVABLE_TYPE = 0x2,
1373 #define Q_DECLARE_TYPEINFO_BODY(TYPE, FLAGS) \
1374 class QTypeInfo<TYPE > \
1378 isComplex = (((FLAGS) & Q_PRIMITIVE_TYPE) == 0), \
1379 isStatic = (((FLAGS) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), \
1380 isLarge = (sizeof(TYPE)>sizeof(void*)), \
1381 isPointer = false, \
1382 isDummy = (((FLAGS) & Q_DUMMY_TYPE) != 0), \
1383 sizeOf = sizeof(TYPE) \
1385 static inline const char *name() { return #TYPE; } \
1388 #define Q_DECLARE_TYPEINFO(TYPE, FLAGS) \
1390 Q_DECLARE_TYPEINFO_BODY(TYPE, FLAGS)
1393 template <typename T>
1394 inline void qSwap(T &value1, T &value2)
1402 swap(value1, value2);
1407 Specialize a shared type with:
1409 Q_DECLARE_SHARED(type);
1411 where 'type' is the name of the type to specialize. NOTE: shared
1412 types must declare a 'bool isDetached(void) const;' member for this
1416 #define Q_DECLARE_SHARED_STL(TYPE)
1418 #define Q_DECLARE_SHARED_STL(TYPE) \
1421 template<> inline void swap<QT_PREPEND_NAMESPACE(TYPE)>(QT_PREPEND_NAMESPACE(TYPE) &value1, QT_PREPEND_NAMESPACE(TYPE) &value2) \
1422 { swap(value1.data_ptr(), value2.data_ptr()); } \
1427 #define Q_DECLARE_SHARED(TYPE) \
1428 template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \
1429 template <> inline void qSwap<TYPE>(TYPE &value1, TYPE &value2) \
1430 { qSwap(value1.data_ptr(), value2.data_ptr()); } \
1431 Q_DECLARE_SHARED_STL(TYPE)
1434 QTypeInfo primitive specializations
1436 Q_DECLARE_TYPEINFO(bool, Q_PRIMITIVE_TYPE);
1437 Q_DECLARE_TYPEINFO(char, Q_PRIMITIVE_TYPE);
1438 Q_DECLARE_TYPEINFO(signed char, Q_PRIMITIVE_TYPE);
1439 Q_DECLARE_TYPEINFO(uchar, Q_PRIMITIVE_TYPE);
1440 Q_DECLARE_TYPEINFO(short, Q_PRIMITIVE_TYPE);
1441 Q_DECLARE_TYPEINFO(ushort, Q_PRIMITIVE_TYPE);
1442 Q_DECLARE_TYPEINFO(int, Q_PRIMITIVE_TYPE);
1443 Q_DECLARE_TYPEINFO(uint, Q_PRIMITIVE_TYPE);
1444 Q_DECLARE_TYPEINFO(long, Q_PRIMITIVE_TYPE);
1445 Q_DECLARE_TYPEINFO(ulong, Q_PRIMITIVE_TYPE);
1446 Q_DECLARE_TYPEINFO(qint64, Q_PRIMITIVE_TYPE);
1447 Q_DECLARE_TYPEINFO(quint64, Q_PRIMITIVE_TYPE);
1448 Q_DECLARE_TYPEINFO(float, Q_PRIMITIVE_TYPE);
1449 Q_DECLARE_TYPEINFO(double, Q_PRIMITIVE_TYPE);
1451 Q_DECLARE_TYPEINFO(long double, Q_PRIMITIVE_TYPE);
1455 These functions make it possible to use standard C++ functions with
1456 a similar name from Qt header files (especially template classes).
1458 Q_CORE_EXPORT void *qMalloc(size_t size) Q_ALLOC_SIZE(1);
1459 Q_CORE_EXPORT void qFree(void *ptr);
1460 Q_CORE_EXPORT void *qRealloc(void *ptr, size_t size) Q_ALLOC_SIZE(2);
1461 Q_CORE_EXPORT void *qMallocAligned(size_t size, size_t alignment) Q_ALLOC_SIZE(1);
1462 Q_CORE_EXPORT void *qReallocAligned(void *ptr, size_t size, size_t oldsize, size_t alignment) Q_ALLOC_SIZE(2);
1463 Q_CORE_EXPORT void qFreeAligned(void *ptr);
1464 Q_CORE_EXPORT void *qMemCopy(void *dest, const void *src, size_t n);
1465 Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n);
1469 Avoid some particularly useless warnings from some stupid compilers.
1470 To get ALL C++ compiler warnings, define QT_CC_WARNINGS or comment out
1471 the line "#define QT_NO_WARNINGS".
1473 #if !defined(QT_CC_WARNINGS)
1474 # define QT_NO_WARNINGS
1476 #if defined(QT_NO_WARNINGS)
1477 # if defined(Q_CC_MSVC)
1478 # pragma warning(disable: 4251) /* class 'A' needs to have dll interface for to be used by clients of class 'B'. */
1479 # pragma warning(disable: 4244) /* 'conversion' conversion from 'type1' to 'type2', possible loss of data */
1480 # pragma warning(disable: 4275) /* non - DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' */
1481 # pragma warning(disable: 4514) /* unreferenced inline/local function has been removed */
1482 # pragma warning(disable: 4800) /* 'type' : forcing value to bool 'true' or 'false' (performance warning) */
1483 # pragma warning(disable: 4097) /* typedef-name 'identifier1' used as synonym for class-name 'identifier2' */
1484 # pragma warning(disable: 4706) /* assignment within conditional expression */
1485 # pragma warning(disable: 4786) /* truncating debug info after 255 characters */
1486 # pragma warning(disable: 4660) /* template-class specialization 'identifier' is already instantiated */
1487 # pragma warning(disable: 4355) /* 'this' : used in base member initializer list */
1488 # pragma warning(disable: 4231) /* nonstandard extension used : 'extern' before template explicit instantiation */
1489 # pragma warning(disable: 4710) /* function not inlined */
1490 # pragma warning(disable: 4530) /* C++ exception handler used, but unwind semantics are not enabled. Specify -GX */
1491 # elif defined(Q_CC_BOR)
1492 # pragma option -w-inl
1493 # pragma option -w-aus
1502 class Q_CORE_EXPORT QFlag
1506 inline QFlag(int i);
1507 inline operator int() const { return i; }
1510 inline QFlag::QFlag(int ai) : i(ai) {}
1512 class Q_CORE_EXPORT QIncompatibleFlag
1516 inline explicit QIncompatibleFlag(int i);
1517 inline operator int() const { return i; }
1520 inline QIncompatibleFlag::QIncompatibleFlag(int ai) : i(ai) {}
1523 #ifndef Q_NO_TYPESAFE_FLAGS
1525 template<typename Enum>
1528 typedef void **Zero;
1531 typedef Enum enum_type;
1532 Q_DECL_CONSTEXPR inline QFlags(const QFlags &f) : i(f.i) {}
1533 Q_DECL_CONSTEXPR inline QFlags(Enum f) : i(f) {}
1534 Q_DECL_CONSTEXPR inline QFlags(Zero = 0) : i(0) {}
1535 inline QFlags(QFlag f) : i(f) {}
1537 inline QFlags &operator=(const QFlags &f) { i = f.i; return *this; }
1538 inline QFlags &operator&=(int mask) { i &= mask; return *this; }
1539 inline QFlags &operator&=(uint mask) { i &= mask; return *this; }
1540 inline QFlags &operator|=(QFlags f) { i |= f.i; return *this; }
1541 inline QFlags &operator|=(Enum f) { i |= f; return *this; }
1542 inline QFlags &operator^=(QFlags f) { i ^= f.i; return *this; }
1543 inline QFlags &operator^=(Enum f) { i ^= f; return *this; }
1545 Q_DECL_CONSTEXPR inline operator int() const { return i; }
1547 Q_DECL_CONSTEXPR inline QFlags operator|(QFlags f) const { return QFlags(Enum(i | f.i)); }
1548 Q_DECL_CONSTEXPR inline QFlags operator|(Enum f) const { return QFlags(Enum(i | f)); }
1549 Q_DECL_CONSTEXPR inline QFlags operator^(QFlags f) const { return QFlags(Enum(i ^ f.i)); }
1550 Q_DECL_CONSTEXPR inline QFlags operator^(Enum f) const { return QFlags(Enum(i ^ f)); }
1551 Q_DECL_CONSTEXPR inline QFlags operator&(int mask) const { return QFlags(Enum(i & mask)); }
1552 Q_DECL_CONSTEXPR inline QFlags operator&(uint mask) const { return QFlags(Enum(i & mask)); }
1553 Q_DECL_CONSTEXPR inline QFlags operator&(Enum f) const { return QFlags(Enum(i & f)); }
1554 Q_DECL_CONSTEXPR inline QFlags operator~() const { return QFlags(Enum(~i)); }
1556 Q_DECL_CONSTEXPR inline bool operator!() const { return !i; }
1558 inline bool testFlag(Enum f) const { return (i & f) == f && (f != 0 || i == int(f) ); }
1561 #define Q_DECLARE_FLAGS(Flags, Enum)\
1562 typedef QFlags<Enum> Flags;
1564 #define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) \
1565 inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) \
1566 { return QIncompatibleFlag(int(f1) | f2); }
1568 #define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags) \
1569 Q_DECL_CONSTEXPR inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, Flags::enum_type f2) \
1570 { return QFlags<Flags::enum_type>(f1) | f2; } \
1571 Q_DECL_CONSTEXPR inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, QFlags<Flags::enum_type> f2) \
1572 { return f2 | f1; } Q_DECLARE_INCOMPATIBLE_FLAGS(Flags)
1575 #else /* Q_NO_TYPESAFE_FLAGS */
1577 #define Q_DECLARE_FLAGS(Flags, Enum)\
1579 #define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
1581 #endif /* Q_NO_TYPESAFE_FLAGS */
1583 #if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_RVCT)
1584 /* make use of typeof-extension */
1585 template <typename T>
1586 class QForeachContainer {
1588 inline QForeachContainer(const T& t) : c(t), brk(0), i(c.begin()), e(c.end()) { }
1591 typename T::const_iterator i, e;
1594 #define Q_FOREACH(variable, container) \
1595 for (QForeachContainer<__typeof__(container)> _container_(container); \
1596 !_container_.brk && _container_.i != _container_.e; \
1597 __extension__ ({ ++_container_.brk; ++_container_.i; })) \
1598 for (variable = *_container_.i;; __extension__ ({--_container_.brk; break;}))
1602 struct QForeachContainerBase {};
1604 template <typename T>
1605 class QForeachContainer : public QForeachContainerBase {
1607 inline QForeachContainer(const T& t): c(t), brk(0), i(c.begin()), e(c.end()){}
1610 mutable typename T::const_iterator i, e;
1611 inline bool condition() const { return (!brk++ && i != e); }
1614 template <typename T> inline T *qForeachPointer(const T &) { return 0; }
1616 template <typename T> inline QForeachContainer<T> qForeachContainerNew(const T& t)
1617 { return QForeachContainer<T>(t); }
1619 template <typename T>
1620 inline const QForeachContainer<T> *qForeachContainer(const QForeachContainerBase *base, const T *)
1621 { return static_cast<const QForeachContainer<T> *>(base); }
1623 #if defined(Q_CC_MIPS)
1625 Proper for-scoping in MIPSpro CC
1627 # define Q_FOREACH(variable,container) \
1629 for (const QForeachContainerBase &_container_ = qForeachContainerNew(container); \
1630 qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->condition(); \
1631 ++qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i) \
1632 for (variable = *qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i; \
1633 qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk; \
1634 --qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk)
1636 #elif defined(Q_CC_DIAB)
1637 // VxWorks DIAB generates unresolvable symbols, if container is a function call
1638 # define Q_FOREACH(variable,container) \
1640 for (const QForeachContainerBase &_container_ = qForeachContainerNew(container); \
1641 qForeachContainer(&_container_, (__typeof__(container) *) 0)->condition(); \
1642 ++qForeachContainer(&_container_, (__typeof__(container) *) 0)->i) \
1643 for (variable = *qForeachContainer(&_container_, (__typeof__(container) *) 0)->i; \
1644 qForeachContainer(&_container_, (__typeof__(container) *) 0)->brk; \
1645 --qForeachContainer(&_container_, (__typeof__(container) *) 0)->brk)
1648 # define Q_FOREACH(variable, container) \
1649 for (const QForeachContainerBase &_container_ = qForeachContainerNew(container); \
1650 qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->condition(); \
1651 ++qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i) \
1652 for (variable = *qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i; \
1653 qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk; \
1654 --qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk)
1655 #endif // MSVC6 || MIPSpro
1659 #define Q_FOREVER for(;;)
1660 #ifndef QT_NO_KEYWORDS
1662 # define foreach Q_FOREACH
1665 # define forever Q_FOREVER
1670 /* tell gcc to use its built-in methods for some common functions */
1671 #if defined(QT_NO_DEBUG) && defined(Q_CC_GNU)
1672 # define qMemCopy __builtin_memcpy
1673 # define qMemSet __builtin_memset
1677 template <typename T> static inline T *qGetPtrHelper(T *ptr) { return ptr; }
1678 template <typename Wrapper> static inline typename Wrapper::pointer qGetPtrHelper(const Wrapper &p) { return p.data(); }
1680 #define Q_DECLARE_PRIVATE(Class) \
1681 inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(qGetPtrHelper(d_ptr)); } \
1682 inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(qGetPtrHelper(d_ptr)); } \
1683 friend class Class##Private;
1685 #define Q_DECLARE_PRIVATE_D(Dptr, Class) \
1686 inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(Dptr); } \
1687 inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(Dptr); } \
1688 friend class Class##Private;
1690 #define Q_DECLARE_PUBLIC(Class) \
1691 inline Class* q_func() { return static_cast<Class *>(q_ptr); } \
1692 inline const Class* q_func() const { return static_cast<const Class *>(q_ptr); } \
1695 #define Q_D(Class) Class##Private * const d = d_func()
1696 #define Q_Q(Class) Class * const q = q_func()
1698 #define QT_TR_NOOP(x) x
1699 #define QT_TR_NOOP_UTF8(x) x
1700 #define QT_TRANSLATE_NOOP(scope, x) x
1701 #define QT_TRANSLATE_NOOP_UTF8(scope, x) x
1702 #define QT_TRANSLATE_NOOP3(scope, x, comment) {x, comment}
1703 #define QT_TRANSLATE_NOOP3_UTF8(scope, x, comment) {x, comment}
1705 #ifndef QT_NO_TRANSLATION // ### This should enclose the NOOPs above
1707 // Defined in qcoreapplication.cpp
1708 // The better name qTrId() is reserved for an upcoming function which would
1709 // return a much more powerful QStringFormatter instead of a QString.
1710 Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1);
1712 #define QT_TRID_NOOP(id) id
1714 #endif // QT_NO_TRANSLATION
1716 #define QDOC_PROPERTY(text)
1719 When RTTI is not available, define this macro to force any uses of
1720 dynamic_cast to cause a compile failure.
1723 #ifdef QT_NO_DYNAMIC_CAST
1724 # define dynamic_cast QT_PREPEND_NAMESPACE(qt_dynamic_cast_check)
1726 template<typename T, typename X>
1727 T qt_dynamic_cast_check(X, T* = 0)
1728 { return T::dynamic_cast_will_always_fail_because_rtti_is_disabled; }
1732 Some classes do not permit copies to be made of an object. These
1733 classes contains a private copy constructor and assignment
1734 operator to disable copying (the compiler gives an error message).
1736 #define Q_DISABLE_COPY(Class) \
1737 Class(const Class &) Q_DECL_EQ_DELETE;\
1738 Class &operator=(const Class &) Q_DECL_EQ_DELETE;
1741 Q_CORE_EXPORT QByteArray qgetenv(const char *varName);
1742 Q_CORE_EXPORT bool qputenv(const char *varName, const QByteArray& value);
1744 inline int qIntCast(double f) { return int(f); }
1745 inline int qIntCast(float f) { return int(f); }
1748 Reentrant versions of basic rand() functions for random number generation
1750 Q_CORE_EXPORT void qsrand(uint seed);
1751 Q_CORE_EXPORT int qrand();
1753 #define QT_MODULE(x)
1755 #ifdef QT_NO_CONCURRENT
1756 # define QT_NO_QFUTURE
1759 // gcc 3 version has problems with some of the
1760 // map/filter overloads.
1761 #if defined(Q_CC_GNU) && (__GNUC__ < 4)
1762 # define QT_NO_CONCURRENT_MAP
1763 # define QT_NO_CONCURRENT_FILTER
1767 // QNX doesn't have SYSV style shared memory. Multiprocess QWS apps,
1768 // shared fonts and QSystemSemaphore + QSharedMemory are not available
1769 # define QT_NO_QWS_MULTIPROCESS
1770 # define QT_NO_QWS_SHARE_FONTS
1771 # define QT_NO_SYSTEMSEMAPHORE
1772 # define QT_NO_SHAREDMEMORY
1773 // QNX currently doesn't support forking in a thread, so disable QProcess
1774 # define QT_NO_PROCESS
1777 #if defined (__ELF__)
1778 # if defined (Q_OS_LINUX) || defined (Q_OS_SOLARIS) || defined (Q_OS_FREEBSD) || defined (Q_OS_OPENBSD) || defined (Q_OS_IRIX)
1783 #if !defined(QT_BOOTSTRAPPED) && defined(QT_REDUCE_RELOCATIONS) && defined(__ELF__) && !defined(__PIC__)
1784 # error "You must build your code with position independent code if Qt was built with -reduce-relocations. "\
1785 "Compile your code with -fPIC or -fPIE."
1788 namespace QtPrivate {
1789 //like std::enable_if
1790 template <bool B, typename T = void> struct QEnableIf;
1791 template <typename T> struct QEnableIf<true, T> { typedef T Type; };
1797 // qDebug and friends
1798 #include <QtCore/qlogging.h>
1800 #endif /* __cplusplus */
1802 #endif /* QGLOBAL_H */