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
282 #ifndef QT_LINUXBASE /* the LSB defines TRUE and FALSE for us */
290 Proper for-scoping in MIPSpro CC
292 #ifndef QT_NO_KEYWORDS
293 # if defined(Q_CC_MIPS) || (defined(Q_CC_HPACC) && defined(__ia64))
294 # define for if(0){}else for
299 Workaround for static const members on MSVC++.
302 #if defined(Q_CC_MSVC)
303 # define QT_STATIC_CONST static
304 # define QT_STATIC_CONST_IMPL
306 # define QT_STATIC_CONST static const
307 # define QT_STATIC_CONST_IMPL const
311 Warnings and errors when using deprecated methods
313 #if (defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && (__GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2))) || defined(Q_CC_RVCT)
314 # define Q_DECL_DEPRECATED __attribute__ ((__deprecated__))
315 #elif defined(Q_CC_MSVC)
316 # define Q_DECL_DEPRECATED __declspec(deprecated)
317 # if defined (Q_CC_INTEL)
318 # define Q_DECL_VARIABLE_DEPRECATED
322 # define Q_DECL_DEPRECATED
324 #ifndef Q_DECL_VARIABLE_DEPRECATED
325 # define Q_DECL_VARIABLE_DEPRECATED Q_DECL_DEPRECATED
328 #if defined(QT_NO_DEPRECATED)
329 # undef QT_DEPRECATED
330 # undef QT_DEPRECATED_VARIABLE
331 # undef QT_DEPRECATED_CONSTRUCTOR
332 #elif defined(QT_DEPRECATED_WARNINGS)
333 # undef QT_DEPRECATED
334 # define QT_DEPRECATED Q_DECL_DEPRECATED
335 # undef QT_DEPRECATED_VARIABLE
336 # define QT_DEPRECATED_VARIABLE Q_DECL_VARIABLE_DEPRECATED
337 # undef QT_DEPRECATED_CONSTRUCTOR
338 # define QT_DEPRECATED_CONSTRUCTOR explicit Q_DECL_CONSTRUCTOR_DEPRECATED
340 # undef QT_DEPRECATED
341 # define QT_DEPRECATED
342 # undef QT_DEPRECATED_VARIABLE
343 # define QT_DEPRECATED_VARIABLE
344 # undef QT_DEPRECATED_CONSTRUCTOR
345 # define QT_DEPRECATED_CONSTRUCTOR
348 #ifndef QT_DISABLE_DEPRECATED_BEFORE
349 // ### Qt5: remember to change that to 5 when we reach feature freeze
350 #define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(4, 9, 0)
354 QT_DEPRECATED_SINCE(major, minor) evaluates as true if the Qt version is greater than
355 the deprecation point specified.
357 Use it to specify from which version of Qt a function or class has been deprecated
360 #if QT_DEPRECATED_SINCE(5,1)
361 QT_DEPRECATED void deprecatedFunction(); //function deprecated since Qt 5.1
366 #define QT_DEPRECATED_SINCE(major, minor) (QT_VERSION_CHECK(major, minor, 0) > QT_DISABLE_DEPRECATED_BEFORE)
368 #define QT_DEPRECATED_SINCE(major, minor) 0
371 /* moc compats (signals/slots) */
372 #ifndef QT_MOC_COMPAT
373 # define QT_MOC_COMPAT
375 # undef QT_MOC_COMPAT
376 # define QT_MOC_COMPAT
379 #ifdef QT_ASCII_CAST_WARNINGS
380 # define QT_ASCII_CAST_WARN Q_DECL_DEPRECATED
382 # define QT_ASCII_CAST_WARN
385 #if defined(__i386__) || defined(_WIN32) || defined(_WIN32_WCE)
386 # if defined(Q_CC_GNU)
387 #if !defined(Q_CC_INTEL) && ((100*(__GNUC__ - 0) + 10*(__GNUC_MINOR__ - 0) + __GNUC_PATCHLEVEL__) >= 332)
388 # define QT_FASTCALL __attribute__((regparm(3)))
392 # elif defined(Q_CC_MSVC)
393 # define QT_FASTCALL __fastcall
401 #ifdef Q_COMPILER_NULLPTR
402 # define Q_NULLPTR nullptr
407 #ifdef Q_COMPILER_DEFAULT_DELETE_MEMBERS
408 # define Q_DECL_EQ_DELETE = delete
410 # define Q_DECL_EQ_DELETE
413 #ifdef Q_COMPILER_CONSTEXPR
414 # define Q_DECL_CONSTEXPR constexpr
416 # define Q_DECL_CONSTEXPR
419 #ifdef Q_COMPILER_EXPLICIT_OVERRIDES
420 # define Q_DECL_OVERRIDE override
421 # define Q_DECL_FINAL final
423 # define Q_DECL_OVERRIDE
424 # define Q_DECL_FINAL
427 //defines the type for the WNDPROC on windows
428 //the alignment needs to be forced for sse2 to not crash with mingw
429 #if defined(Q_OS_WIN)
430 # if defined(Q_CC_MINGW)
431 # define QT_ENSURE_STACK_ALIGNED_FOR_SSE __attribute__ ((force_align_arg_pointer))
433 # define QT_ENSURE_STACK_ALIGNED_FOR_SSE
435 # define QT_WIN_CALLBACK CALLBACK QT_ENSURE_STACK_ALIGNED_FOR_SSE
438 typedef int QNoImplicitBoolCast;
440 // This logic must match the one in qmetatype.h
441 #if defined(QT_COORD_TYPE)
442 typedef QT_COORD_TYPE qreal;
443 #elif defined(QT_NO_FPU) || defined(Q_PROCESSOR_ARM) || defined(Q_OS_WINCE)
446 typedef double qreal;
450 Utility macros and inline functions
453 template <typename T>
454 Q_DECL_CONSTEXPR inline T qAbs(const T &t) { return t >= 0 ? t : -t; }
456 Q_DECL_CONSTEXPR inline int qRound(double d)
457 { return d >= 0.0 ? int(d + 0.5) : int(d - int(d-1) + 0.5) + int(d-1); }
458 Q_DECL_CONSTEXPR inline int qRound(float d)
459 { return d >= 0.0f ? int(d + 0.5f) : int(d - int(d-1) + 0.5f) + int(d-1); }
462 Just for documentation generation
467 Q_DECL_CONSTEXPR inline qint64 qRound64(double d)
468 { return d >= 0.0 ? qint64(d + 0.5) : qint64(d - double(qint64(d-1)) + 0.5) + qint64(d-1); }
469 Q_DECL_CONSTEXPR inline qint64 qRound64(float d)
470 { return d >= 0.0f ? qint64(d + 0.5f) : qint64(d - float(qint64(d-1)) + 0.5f) + qint64(d-1); }
473 Just for documentation generation
475 qint64 qRound64(qreal d);
478 template <typename T>
479 Q_DECL_CONSTEXPR inline const T &qMin(const T &a, const T &b) { return (a < b) ? a : b; }
480 template <typename T>
481 Q_DECL_CONSTEXPR inline const T &qMax(const T &a, const T &b) { return (a < b) ? b : a; }
482 template <typename T>
483 Q_DECL_CONSTEXPR inline const T &qBound(const T &min, const T &val, const T &max)
484 { return qMax(min, qMin(max, val)); }
487 Data stream functions are provided by many classes (defined in qdatastream.h)
492 #if defined(Q_OS_VXWORKS)
493 # define QT_NO_CRASHHANDLER // no popen
494 # define QT_NO_PROCESS // no exec*, no fork
496 # define QT_NO_SHAREDMEMORY // only POSIX, no SysV and in the end...
497 # define QT_NO_SYSTEMSEMAPHORE // not needed at all in a flat address space
500 # include <QtCore/qfeatures.h>
502 #define QT_SUPPORTS(FEATURE) (!defined(QT_NO_##FEATURE))
504 #if defined(Q_OS_LINUX) && defined(Q_CC_RVCT)
505 # define Q_DECL_EXPORT __attribute__((visibility("default")))
506 # define Q_DECL_IMPORT __attribute__((visibility("default")))
507 # define Q_DECL_HIDDEN __attribute__((visibility("hidden")))
510 #ifndef Q_DECL_EXPORT
511 # if defined(Q_OS_WIN) || defined(Q_CC_RVCT)
512 # define Q_DECL_EXPORT __declspec(dllexport)
513 # elif defined(QT_VISIBILITY_AVAILABLE)
514 # define Q_DECL_EXPORT __attribute__((visibility("default")))
515 # define Q_DECL_HIDDEN __attribute__((visibility("hidden")))
517 # ifndef Q_DECL_EXPORT
518 # define Q_DECL_EXPORT
521 #ifndef Q_DECL_IMPORT
522 # if defined(Q_OS_WIN) || defined(Q_CC_RVCT)
523 # define Q_DECL_IMPORT __declspec(dllimport)
525 # define Q_DECL_IMPORT
528 #ifndef Q_DECL_HIDDEN
529 # define Q_DECL_HIDDEN
534 Create Qt DLL if QT_DLL is defined (Windows only)
537 #if defined(Q_OS_WIN)
538 # if defined(QT_NODLL)
541 # elif defined(QT_MAKEDLL) /* create a Qt DLL library */
545 # if defined(QT_BUILD_CORE_LIB)
546 # define Q_CORE_EXPORT Q_DECL_EXPORT
548 # define Q_CORE_EXPORT Q_DECL_IMPORT
550 # if defined(QT_BUILD_GUI_LIB)
551 # define Q_GUI_EXPORT Q_DECL_EXPORT
553 # define Q_GUI_EXPORT Q_DECL_IMPORT
555 # if defined(QT_BUILD_WIDGETS_LIB)
556 # define Q_WIDGETS_EXPORT Q_DECL_EXPORT
558 # define Q_WIDGETS_EXPORT Q_DECL_IMPORT
560 # if defined(QT_BUILD_PLATFORMSUPPORT_LIB)
561 # define Q_PLATFORMSUPPORT_EXPORT Q_DECL_EXPORT
563 # define Q_PLATFORMSUPPORT_EXPORT Q_DECL_IMPORT
565 # if defined(QT_BUILD_PRINTSUPPORT_LIB)
566 # define Q_PRINTSUPPORT_EXPORT Q_DECL_EXPORT
568 # define Q_PRINTSUPPORT_EXPORT Q_DECL_IMPORT
570 # if defined(QT_BUILD_SQL_LIB)
571 # define Q_SQL_EXPORT Q_DECL_EXPORT
573 # define Q_SQL_EXPORT Q_DECL_IMPORT
575 # if defined(QT_BUILD_NETWORK_LIB)
576 # define Q_NETWORK_EXPORT Q_DECL_EXPORT
578 # define Q_NETWORK_EXPORT Q_DECL_IMPORT
580 # if defined(QT_BUILD_SVG_LIB)
581 # define Q_SVG_EXPORT Q_DECL_EXPORT
583 # define Q_SVG_EXPORT Q_DECL_IMPORT
585 # if defined(QT_BUILD_QTQUICK1_LIB)
586 # define Q_QTQUICK1_EXPORT Q_DECL_EXPORT
588 # define Q_QTQUICK1_EXPORT Q_DECL_IMPORT
590 # if defined(QT_BUILD_DECLARATIVE_LIB)
591 # define Q_DECLARATIVE_EXPORT Q_DECL_EXPORT
593 # define Q_DECLARATIVE_EXPORT Q_DECL_IMPORT
595 # if defined(QT_BUILD_OPENGL_LIB)
596 # define Q_OPENGL_EXPORT Q_DECL_EXPORT
598 # define Q_OPENGL_EXPORT Q_DECL_IMPORT
600 # if defined(QT_BUILD_MULTIMEDIA_LIB)
601 # define Q_MULTIMEDIA_EXPORT Q_DECL_EXPORT
603 # define Q_MULTIMEDIA_EXPORT Q_DECL_IMPORT
605 # if defined(QT_BUILD_OPENVG_LIB)
606 # define Q_OPENVG_EXPORT Q_DECL_EXPORT
608 # define Q_OPENVG_EXPORT Q_DECL_IMPORT
610 # if defined(QT_BUILD_XML_LIB)
611 # define Q_XML_EXPORT Q_DECL_EXPORT
613 # define Q_XML_EXPORT Q_DECL_IMPORT
615 # if defined(QT_BUILD_XMLPATTERNS_LIB)
616 # define Q_XMLPATTERNS_EXPORT Q_DECL_EXPORT
618 # define Q_XMLPATTERNS_EXPORT Q_DECL_IMPORT
620 # if defined(QT_BUILD_SCRIPT_LIB)
621 # define Q_SCRIPT_EXPORT Q_DECL_EXPORT
623 # define Q_SCRIPT_EXPORT Q_DECL_IMPORT
625 # if defined(QT_BUILD_SCRIPTTOOLS_LIB)
626 # define Q_SCRIPTTOOLS_EXPORT Q_DECL_EXPORT
628 # define Q_SCRIPTTOOLS_EXPORT Q_DECL_IMPORT
630 # if defined(QT_BUILD_CANVAS_LIB)
631 # define Q_CANVAS_EXPORT Q_DECL_EXPORT
633 # define Q_CANVAS_EXPORT Q_DECL_IMPORT
635 # if defined(QT_BUILD_COMPAT_LIB)
636 # define Q_COMPAT_EXPORT Q_DECL_EXPORT
638 # define Q_COMPAT_EXPORT Q_DECL_IMPORT
640 # if defined(QT_BUILD_DBUS_LIB)
641 # define Q_DBUS_EXPORT Q_DECL_EXPORT
643 # define Q_DBUS_EXPORT Q_DECL_IMPORT
645 # define Q_TEMPLATEDLL
646 # elif defined(QT_DLL) /* use a Qt DLL library */
647 # define Q_CORE_EXPORT Q_DECL_IMPORT
648 # define Q_GUI_EXPORT Q_DECL_IMPORT
649 # define Q_WIDGETS_EXPORT Q_DECL_IMPORT
650 # define Q_PLATFORMSUPPORT_EXPORT Q_DECL_IMPORT
651 # define Q_PRINTSUPPORT_EXPORT Q_DECL_IMPORT
652 # define Q_SQL_EXPORT Q_DECL_IMPORT
653 # define Q_NETWORK_EXPORT Q_DECL_IMPORT
654 # define Q_SVG_EXPORT Q_DECL_IMPORT
655 # define Q_DECLARATIVE_EXPORT Q_DECL_IMPORT
656 # define Q_QTQUICK1_EXPORT Q_DECL_IMPORT
657 # define Q_CANVAS_EXPORT Q_DECL_IMPORT
658 # define Q_OPENGL_EXPORT Q_DECL_IMPORT
659 # define Q_MULTIMEDIA_EXPORT Q_DECL_IMPORT
660 # define Q_OPENVG_EXPORT Q_DECL_IMPORT
661 # define Q_XML_EXPORT Q_DECL_IMPORT
662 # define Q_XMLPATTERNS_EXPORT Q_DECL_IMPORT
663 # define Q_SCRIPT_EXPORT Q_DECL_IMPORT
664 # define Q_SCRIPTTOOLS_EXPORT Q_DECL_IMPORT
665 # define Q_COMPAT_EXPORT Q_DECL_IMPORT
666 # define Q_DBUS_EXPORT Q_DECL_IMPORT
667 # define Q_TEMPLATEDLL
669 # define Q_NO_DECLARED_NOT_DEFINED
671 # if defined(Q_OS_LINUX) && defined(Q_CC_BOR)
672 # define Q_TEMPLATEDLL
673 # define Q_NO_DECLARED_NOT_DEFINED
675 # undef QT_MAKEDLL /* ignore these for other platforms */
679 #if !defined(Q_CORE_EXPORT)
680 # if defined(QT_SHARED)
681 # define Q_CORE_EXPORT Q_DECL_EXPORT
682 # define Q_GUI_EXPORT Q_DECL_EXPORT
683 # define Q_WIDGETS_EXPORT Q_DECL_EXPORT
684 # define Q_PLATFORMSUPPORT_EXPORT Q_DECL_EXPORT
685 # define Q_PRINTSUPPORT_EXPORT Q_DECL_EXPORT
686 # define Q_SQL_EXPORT Q_DECL_EXPORT
687 # define Q_NETWORK_EXPORT Q_DECL_EXPORT
688 # define Q_SVG_EXPORT Q_DECL_EXPORT
689 # define Q_DECLARATIVE_EXPORT Q_DECL_EXPORT
690 # define Q_QTQUICK1_EXPORT Q_DECL_EXPORT
691 # define Q_OPENGL_EXPORT Q_DECL_EXPORT
692 # define Q_MULTIMEDIA_EXPORT Q_DECL_EXPORT
693 # define Q_OPENVG_EXPORT Q_DECL_EXPORT
694 # define Q_XML_EXPORT Q_DECL_EXPORT
695 # define Q_XMLPATTERNS_EXPORT Q_DECL_EXPORT
696 # define Q_SCRIPT_EXPORT Q_DECL_EXPORT
697 # define Q_SCRIPTTOOLS_EXPORT Q_DECL_EXPORT
698 # define Q_COMPAT_EXPORT Q_DECL_EXPORT
699 # define Q_DBUS_EXPORT Q_DECL_EXPORT
701 # define Q_CORE_EXPORT
702 # define Q_GUI_EXPORT
703 # define Q_WIDGETS_EXPORT
704 # define Q_PLATFORMSUPPORT_EXPORT
705 # define Q_PRINTSUPPORT_EXPORT
706 # define Q_SQL_EXPORT
707 # define Q_NETWORK_EXPORT
708 # define Q_SVG_EXPORT
709 # define Q_DECLARATIVE_EXPORT
710 # define Q_QTQUICK1_EXPORT
711 # define Q_OPENGL_EXPORT
712 # define Q_MULTIMEDIA_EXPORT
713 # define Q_OPENVG_EXPORT
714 # define Q_XML_EXPORT
715 # define Q_XMLPATTERNS_EXPORT
716 # define Q_SCRIPT_EXPORT
717 # define Q_SCRIPTTOOLS_EXPORT
718 # define Q_COMPAT_EXPORT
719 # define Q_DBUS_EXPORT
723 // Functions marked as Q_GUI_EXPORT_INLINE were exported and inlined by mistake.
724 // Compilers like MinGW complain that the import attribute is ignored.
725 #if defined(Q_CC_MINGW)
726 # if defined(QT_BUILD_CORE_LIB)
727 # define Q_CORE_EXPORT_INLINE Q_CORE_EXPORT inline
729 # define Q_CORE_EXPORT_INLINE inline
731 # if defined(QT_BUILD_GUI_LIB)
732 # define Q_GUI_EXPORT_INLINE Q_GUI_EXPORT inline
734 # define Q_GUI_EXPORT_INLINE inline
736 # if defined(QT_BUILD_WIDGETS_LIB)
737 # define Q_WIDGETS_EXPORT_INLINE Q_WIDGETS_EXPORT inline
739 # define Q_WIDGETS_EXPORT_INLINE inline
741 # if defined(QT_BUILD_PLATFORMSUPPORT_LIB)
742 # define Q_PLATFORMSUPPORT_EXPORT_INLINE Q_PLATFORMSUPPORT_EXPORT inline
744 # define Q_PLATFORMSUPPORT_EXPORT_INLINE inline
746 # if defined(QT_BUILD_PRINTSUPPORT_LIB)
747 # define Q_PRINTSUPPORT_EXPORT_INLINE Q_PRINTSUPPORT_EXPORT inline
749 # define Q_PRINTSUPPORT_EXPORT_INLINE inline
751 # if defined(QT_BUILD_COMPAT_LIB)
752 # define Q_COMPAT_EXPORT_INLINE Q_COMPAT_EXPORT inline
754 # define Q_COMPAT_EXPORT_INLINE inline
756 #elif defined(Q_CC_RVCT)
757 // we force RVCT not to export inlines by passing --visibility_inlines_hidden
758 // so we need to just inline it, rather than exporting and inlining
759 // note: this affects the contents of the DEF files (ie. these functions do not appear)
760 # define Q_CORE_EXPORT_INLINE inline
761 # define Q_GUI_EXPORT_INLINE inline
762 # define Q_WIDGETS_EXPORT_INLINE inline
763 # define Q_PLATFORMSUPPORT_EXPORT_INLINE inline
764 # define Q_PRINTSUPPORT_EXPORT_INLINE inline
765 # define Q_COMPAT_EXPORT_INLINE inline
767 # define Q_CORE_EXPORT_INLINE Q_CORE_EXPORT inline
768 # define Q_GUI_EXPORT_INLINE Q_GUI_EXPORT inline
769 # define Q_WIDGETS_EXPORT_INLINE Q_WIDGETS_EXPORT inline
770 # define Q_PLATFORMSUPPORT_EXPORT_INLINE Q_PLATFORMSUPPORT_EXPORT inline
771 # define Q_PRINTSUPPORT_EXPORT_INLINE Q_PRINTSUPPORT_EXPORT inline
772 # define Q_COMPAT_EXPORT_INLINE Q_COMPAT_EXPORT inline
776 No, this is not an evil backdoor. QT_BUILD_INTERNAL just exports more symbols
777 for Qt's internal unit tests. If you want slower loading times and more
778 symbols that can vanish from version to version, feel free to define QT_BUILD_INTERNAL.
780 #if defined(QT_BUILD_INTERNAL) && defined(Q_OS_WIN) && defined(QT_MAKEDLL)
781 # define Q_AUTOTEST_EXPORT Q_DECL_EXPORT
782 #elif defined(QT_BUILD_INTERNAL) && defined(Q_OS_WIN) && defined(QT_DLL)
783 # define Q_AUTOTEST_EXPORT Q_DECL_IMPORT
784 #elif defined(QT_BUILD_INTERNAL) && !defined(Q_OS_WIN) && defined(QT_SHARED)
785 # define Q_AUTOTEST_EXPORT Q_DECL_EXPORT
787 # define Q_AUTOTEST_EXPORT
790 inline void qt_noop(void) {}
792 /* These wrap try/catch so we can switch off exceptions later.
794 Beware - do not use more than one QT_CATCH per QT_TRY, and do not use
795 the exception instance in the catch block.
796 If you can't live with those constraints, don't use these macros.
797 Use the QT_NO_EXCEPTIONS macro to protect your code instead.
800 #ifdef QT_BOOTSTRAPPED
801 # define QT_NO_EXCEPTIONS
803 #if !defined(QT_NO_EXCEPTIONS) && defined(Q_CC_GNU) && !defined (__EXCEPTIONS) && !defined(Q_MOC_RUN)
804 # define QT_NO_EXCEPTIONS
807 #ifdef QT_NO_EXCEPTIONS
808 # define QT_TRY if (true)
809 # define QT_CATCH(A) else
810 # define QT_THROW(A) qt_noop()
811 # define QT_RETHROW qt_noop()
814 # define QT_CATCH(A) catch (A)
815 # define QT_THROW(A) throw A
816 # define QT_RETHROW throw
819 Q_CORE_EXPORT const char *qVersion();
820 Q_CORE_EXPORT bool qSharedBuild();
822 #ifndef Q_OUTOFLINE_TEMPLATE
823 # define Q_OUTOFLINE_TEMPLATE
825 #ifndef Q_INLINE_TEMPLATE
826 # define Q_INLINE_TEMPLATE inline
830 Avoid "unused parameter" warnings
833 #if defined(Q_CC_INTEL) && !defined(Q_OS_WIN) || defined(Q_CC_RVCT)
834 template <typename T>
835 inline void qUnused(T &x) { (void)x; }
836 # define Q_UNUSED(x) qUnused(x);
838 # define Q_UNUSED(x) (void)x;
842 Debugging and error handling
845 #if !defined(QT_NO_DEBUG) && !defined(QT_DEBUG)
850 # define qPrintable(string) QString(string).toLocal8Bit().constData()
854 Q_CORE_EXPORT QString qt_error_string(int errorCode = -1);
855 Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int line);
857 #if !defined(Q_ASSERT)
858 # if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS)
859 # define Q_ASSERT(cond) qt_noop()
861 # define Q_ASSERT(cond) ((!(cond)) ? qt_assert(#cond,__FILE__,__LINE__) : qt_noop())
865 #if defined(QT_NO_DEBUG) && !defined(QT_PAINT_DEBUG)
866 #define QT_NO_PAINT_DEBUG
869 Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char *file, int line);
871 #if !defined(Q_ASSERT_X)
872 # if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS)
873 # define Q_ASSERT_X(cond, where, what) qt_noop()
875 # define Q_ASSERT_X(cond, where, what) ((!(cond)) ? qt_assert_x(where, what,__FILE__,__LINE__) : qt_noop())
880 #ifdef Q_COMPILER_STATIC_ASSERT
881 #define Q_STATIC_ASSERT(Condition) static_assert(bool(Condition), #Condition)
882 #define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message)
884 // Intentionally undefined
885 template <bool Test> class QStaticAssertFailure;
886 template <> class QStaticAssertFailure<true> {};
888 #define Q_STATIC_ASSERT_PRIVATE_JOIN(A, B) Q_STATIC_ASSERT_PRIVATE_JOIN_IMPL(A, B)
889 #define Q_STATIC_ASSERT_PRIVATE_JOIN_IMPL(A, B) A ## B
890 #define Q_STATIC_ASSERT(Condition) \
891 enum {Q_STATIC_ASSERT_PRIVATE_JOIN(q_static_assert_result, __LINE__) = sizeof(QStaticAssertFailure<!!(Condition)>)}
892 #define Q_STATIC_ASSERT_X(Condition, Message) Q_STATIC_ASSERT(Condition)
895 Q_CORE_EXPORT void qt_check_pointer(const char *, int);
896 Q_CORE_EXPORT void qBadAlloc();
898 #ifdef QT_NO_EXCEPTIONS
899 # if defined(QT_NO_DEBUG)
900 # define Q_CHECK_PTR(p) qt_noop()
902 # define Q_CHECK_PTR(p) do {if(!(p))qt_check_pointer(__FILE__,__LINE__);} while (0)
905 # define Q_CHECK_PTR(p) do { if (!(p)) qBadAlloc(); } while (0)
908 template <typename T>
909 inline T *q_check_ptr(T *p) { Q_CHECK_PTR(p); return p; }
911 #if (defined(Q_CC_GNU) && !defined(Q_OS_SOLARIS)) || defined(Q_CC_HPACC) || defined(Q_CC_DIAB)
912 # define Q_FUNC_INFO __PRETTY_FUNCTION__
913 #elif defined(_MSC_VER)
914 # define Q_FUNC_INFO __FUNCSIG__
916 # if defined(Q_OS_SOLARIS) || defined(Q_CC_XLC)
917 # define Q_FUNC_INFO __FILE__ "(line number unavailable)"
919 /* These two macros makes it possible to turn the builtin line expander into a
921 # define QT_STRINGIFY2(x) #x
922 # define QT_STRINGIFY(x) QT_STRINGIFY2(x)
923 # define Q_FUNC_INFO __FILE__ ":" QT_STRINGIFY(__LINE__)
925 /* The MIPSpro and RVCT compilers postpones macro expansion,
926 and therefore macros must be in scope when being used. */
927 # if !defined(Q_CC_MIPS) && !defined(Q_CC_RVCT)
928 # undef QT_STRINGIFY2
934 typedef void (*QFunctionPointer)();
936 #if !defined(Q_UNIMPLEMENTED)
937 # define Q_UNIMPLEMENTED() qWarning("%s:%d: %s: Unimplemented code.", __FILE__, __LINE__, Q_FUNC_INFO)
940 #if defined(QT_NO_THREAD)
942 template <typename T>
947 inline QGlobalStatic(T *p) : pointer(p) { }
948 inline ~QGlobalStatic() { pointer = 0; }
951 #define Q_GLOBAL_STATIC(TYPE, NAME) \
952 static TYPE *NAME() \
954 static TYPE thisVariable; \
955 static QGlobalStatic<TYPE > thisGlobalStatic(&thisVariable); \
956 return thisGlobalStatic.pointer; \
959 #define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \
960 static TYPE *NAME() \
962 static TYPE thisVariable ARGS; \
963 static QGlobalStatic<TYPE > thisGlobalStatic(&thisVariable); \
964 return thisGlobalStatic.pointer; \
967 #define Q_GLOBAL_STATIC_WITH_INITIALIZER(TYPE, NAME, INITIALIZER) \
968 static TYPE *NAME() \
970 static TYPE thisVariable; \
971 static QGlobalStatic<TYPE > thisGlobalStatic(0); \
972 if (!thisGlobalStatic.pointer) { \
973 TYPE *x = thisGlobalStatic.pointer = &thisVariable; \
976 return thisGlobalStatic.pointer; \
981 // forward declaration, since qatomic.h needs qglobal.h
982 template <typename T> class QBasicAtomicPointer;
984 // POD for Q_GLOBAL_STATIC
985 template <typename T>
989 QBasicAtomicPointer<T> pointer;
993 // Created as a function-local static to delete a QGlobalStatic<T>
994 template <typename T>
995 class QGlobalStaticDeleter
998 QGlobalStatic<T> &globalStatic;
999 QGlobalStaticDeleter(QGlobalStatic<T> &_globalStatic)
1000 : globalStatic(_globalStatic)
1003 inline ~QGlobalStaticDeleter()
1005 delete globalStatic.pointer.load();
1006 globalStatic.pointer.store(0);
1007 globalStatic.destroyed = true;
1011 #define Q_GLOBAL_STATIC(TYPE, NAME) \
1012 static TYPE *NAME() \
1014 static QGlobalStatic<TYPE > thisGlobalStatic \
1015 = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \
1016 if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { \
1017 TYPE *x = new TYPE; \
1018 if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) \
1021 static QGlobalStaticDeleter<TYPE > cleanup(thisGlobalStatic); \
1023 return thisGlobalStatic.pointer.load(); \
1026 #define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \
1027 static TYPE *NAME() \
1029 static QGlobalStatic<TYPE > thisGlobalStatic \
1030 = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \
1031 if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { \
1032 TYPE *x = new TYPE ARGS; \
1033 if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) \
1036 static QGlobalStaticDeleter<TYPE > cleanup(thisGlobalStatic); \
1038 return thisGlobalStatic.pointer.load(); \
1041 #define Q_GLOBAL_STATIC_WITH_INITIALIZER(TYPE, NAME, INITIALIZER) \
1042 static TYPE *NAME() \
1044 static QGlobalStatic<TYPE > thisGlobalStatic \
1045 = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \
1046 if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { \
1047 QScopedPointer<TYPE > x(new TYPE); \
1049 if (thisGlobalStatic.pointer.testAndSetOrdered(0, x.data())) { \
1050 static QGlobalStaticDeleter<TYPE > cleanup(thisGlobalStatic); \
1054 return thisGlobalStatic.pointer.load(); \
1059 Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(double p1, double p2)
1061 return (qAbs(p1 - p2) <= 0.000000000001 * qMin(qAbs(p1), qAbs(p2)));
1064 Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(float p1, float p2)
1066 return (qAbs(p1 - p2) <= 0.00001f * qMin(qAbs(p1), qAbs(p2)));
1072 Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(double d)
1074 return qAbs(d) <= 0.000000000001;
1080 Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f)
1082 return qAbs(f) <= 0.00001f;
1086 This function tests a double for a null value. It doesn't
1087 check whether the actual value is 0 or close to 0, but whether
1090 static inline bool qIsNull(double d)
1098 return val.u == quint64(0);
1102 This function tests a float for a null value. It doesn't
1103 check whether the actual value is 0 or close to 0, but whether
1106 static inline bool qIsNull(float f)
1118 Compilers which follow outdated template instantiation rules
1119 require a class to have a comparison operator to exist when
1120 a QList of this type is instantiated. It's not actually
1121 used in the list, though. Hence the dummy implementation.
1122 Just in case other code relies on it we better trigger a warning
1123 mandating a real implementation.
1126 #ifdef Q_FULL_TEMPLATE_INSTANTIATION
1127 # define Q_DUMMY_COMPARISON_OPERATOR(C) \
1128 bool operator==(const C&) const { \
1129 qWarning(#C"::operator==(const "#C"&) was called"); \
1134 # define Q_DUMMY_COMPARISON_OPERATOR(C)
1137 template <typename T>
1138 inline void qSwap(T &value1, T &value2)
1146 swap(value1, value2);
1151 These functions make it possible to use standard C++ functions with
1152 a similar name from Qt header files (especially template classes).
1154 Q_CORE_EXPORT void *qMalloc(size_t size) Q_ALLOC_SIZE(1);
1155 Q_CORE_EXPORT void qFree(void *ptr);
1156 Q_CORE_EXPORT void *qRealloc(void *ptr, size_t size) Q_ALLOC_SIZE(2);
1157 Q_CORE_EXPORT void *qMallocAligned(size_t size, size_t alignment) Q_ALLOC_SIZE(1);
1158 Q_CORE_EXPORT void *qReallocAligned(void *ptr, size_t size, size_t oldsize, size_t alignment) Q_ALLOC_SIZE(2);
1159 Q_CORE_EXPORT void qFreeAligned(void *ptr);
1160 Q_CORE_EXPORT void *qMemCopy(void *dest, const void *src, size_t n);
1161 Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n);
1165 Avoid some particularly useless warnings from some stupid compilers.
1166 To get ALL C++ compiler warnings, define QT_CC_WARNINGS or comment out
1167 the line "#define QT_NO_WARNINGS".
1169 #if !defined(QT_CC_WARNINGS)
1170 # define QT_NO_WARNINGS
1172 #if defined(QT_NO_WARNINGS)
1173 # if defined(Q_CC_MSVC)
1174 # pragma warning(disable: 4251) /* class 'A' needs to have dll interface for to be used by clients of class 'B'. */
1175 # pragma warning(disable: 4244) /* 'conversion' conversion from 'type1' to 'type2', possible loss of data */
1176 # pragma warning(disable: 4275) /* non - DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' */
1177 # pragma warning(disable: 4514) /* unreferenced inline/local function has been removed */
1178 # pragma warning(disable: 4800) /* 'type' : forcing value to bool 'true' or 'false' (performance warning) */
1179 # pragma warning(disable: 4097) /* typedef-name 'identifier1' used as synonym for class-name 'identifier2' */
1180 # pragma warning(disable: 4706) /* assignment within conditional expression */
1181 # pragma warning(disable: 4786) /* truncating debug info after 255 characters */
1182 # pragma warning(disable: 4660) /* template-class specialization 'identifier' is already instantiated */
1183 # pragma warning(disable: 4355) /* 'this' : used in base member initializer list */
1184 # pragma warning(disable: 4231) /* nonstandard extension used : 'extern' before template explicit instantiation */
1185 # pragma warning(disable: 4710) /* function not inlined */
1186 # pragma warning(disable: 4530) /* C++ exception handler used, but unwind semantics are not enabled. Specify -GX */
1187 # elif defined(Q_CC_BOR)
1188 # pragma option -w-inl
1189 # pragma option -w-aus
1198 class Q_CORE_EXPORT QFlag
1202 inline QFlag(int i);
1203 inline operator int() const { return i; }
1206 inline QFlag::QFlag(int ai) : i(ai) {}
1208 class Q_CORE_EXPORT QIncompatibleFlag
1212 inline explicit QIncompatibleFlag(int i);
1213 inline operator int() const { return i; }
1216 inline QIncompatibleFlag::QIncompatibleFlag(int ai) : i(ai) {}
1219 #ifndef Q_NO_TYPESAFE_FLAGS
1221 template<typename Enum>
1224 typedef void **Zero;
1227 typedef Enum enum_type;
1228 Q_DECL_CONSTEXPR inline QFlags(const QFlags &f) : i(f.i) {}
1229 Q_DECL_CONSTEXPR inline QFlags(Enum f) : i(f) {}
1230 Q_DECL_CONSTEXPR inline QFlags(Zero = 0) : i(0) {}
1231 inline QFlags(QFlag f) : i(f) {}
1233 inline QFlags &operator=(const QFlags &f) { i = f.i; return *this; }
1234 inline QFlags &operator&=(int mask) { i &= mask; return *this; }
1235 inline QFlags &operator&=(uint mask) { i &= mask; return *this; }
1236 inline QFlags &operator|=(QFlags f) { i |= f.i; return *this; }
1237 inline QFlags &operator|=(Enum f) { i |= f; return *this; }
1238 inline QFlags &operator^=(QFlags f) { i ^= f.i; return *this; }
1239 inline QFlags &operator^=(Enum f) { i ^= f; return *this; }
1241 Q_DECL_CONSTEXPR inline operator int() const { return i; }
1243 Q_DECL_CONSTEXPR inline QFlags operator|(QFlags f) const { return QFlags(Enum(i | f.i)); }
1244 Q_DECL_CONSTEXPR inline QFlags operator|(Enum f) const { return QFlags(Enum(i | f)); }
1245 Q_DECL_CONSTEXPR inline QFlags operator^(QFlags f) const { return QFlags(Enum(i ^ f.i)); }
1246 Q_DECL_CONSTEXPR inline QFlags operator^(Enum f) const { return QFlags(Enum(i ^ f)); }
1247 Q_DECL_CONSTEXPR inline QFlags operator&(int mask) const { return QFlags(Enum(i & mask)); }
1248 Q_DECL_CONSTEXPR inline QFlags operator&(uint mask) const { return QFlags(Enum(i & mask)); }
1249 Q_DECL_CONSTEXPR inline QFlags operator&(Enum f) const { return QFlags(Enum(i & f)); }
1250 Q_DECL_CONSTEXPR inline QFlags operator~() const { return QFlags(Enum(~i)); }
1252 Q_DECL_CONSTEXPR inline bool operator!() const { return !i; }
1254 inline bool testFlag(Enum f) const { return (i & f) == f && (f != 0 || i == int(f) ); }
1257 #define Q_DECLARE_FLAGS(Flags, Enum)\
1258 typedef QFlags<Enum> Flags;
1260 #define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) \
1261 inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) \
1262 { return QIncompatibleFlag(int(f1) | f2); }
1264 #define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags) \
1265 Q_DECL_CONSTEXPR inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, Flags::enum_type f2) \
1266 { return QFlags<Flags::enum_type>(f1) | f2; } \
1267 Q_DECL_CONSTEXPR inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, QFlags<Flags::enum_type> f2) \
1268 { return f2 | f1; } Q_DECLARE_INCOMPATIBLE_FLAGS(Flags)
1271 #else /* Q_NO_TYPESAFE_FLAGS */
1273 #define Q_DECLARE_FLAGS(Flags, Enum)\
1275 #define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
1277 #endif /* Q_NO_TYPESAFE_FLAGS */
1279 #if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_RVCT)
1280 /* make use of typeof-extension */
1281 template <typename T>
1282 class QForeachContainer {
1284 inline QForeachContainer(const T& t) : c(t), brk(0), i(c.begin()), e(c.end()) { }
1287 typename T::const_iterator i, e;
1290 #define Q_FOREACH(variable, container) \
1291 for (QForeachContainer<__typeof__(container)> _container_(container); \
1292 !_container_.brk && _container_.i != _container_.e; \
1293 __extension__ ({ ++_container_.brk; ++_container_.i; })) \
1294 for (variable = *_container_.i;; __extension__ ({--_container_.brk; break;}))
1298 struct QForeachContainerBase {};
1300 template <typename T>
1301 class QForeachContainer : public QForeachContainerBase {
1303 inline QForeachContainer(const T& t): c(t), brk(0), i(c.begin()), e(c.end()){}
1306 mutable typename T::const_iterator i, e;
1307 inline bool condition() const { return (!brk++ && i != e); }
1310 template <typename T> inline T *qForeachPointer(const T &) { return 0; }
1312 template <typename T> inline QForeachContainer<T> qForeachContainerNew(const T& t)
1313 { return QForeachContainer<T>(t); }
1315 template <typename T>
1316 inline const QForeachContainer<T> *qForeachContainer(const QForeachContainerBase *base, const T *)
1317 { return static_cast<const QForeachContainer<T> *>(base); }
1319 #if defined(Q_CC_MIPS)
1321 Proper for-scoping in MIPSpro CC
1323 # define Q_FOREACH(variable,container) \
1325 for (const QForeachContainerBase &_container_ = qForeachContainerNew(container); \
1326 qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->condition(); \
1327 ++qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i) \
1328 for (variable = *qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i; \
1329 qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk; \
1330 --qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk)
1332 #elif defined(Q_CC_DIAB)
1333 // VxWorks DIAB generates unresolvable symbols, if container is a function call
1334 # define Q_FOREACH(variable,container) \
1336 for (const QForeachContainerBase &_container_ = qForeachContainerNew(container); \
1337 qForeachContainer(&_container_, (__typeof__(container) *) 0)->condition(); \
1338 ++qForeachContainer(&_container_, (__typeof__(container) *) 0)->i) \
1339 for (variable = *qForeachContainer(&_container_, (__typeof__(container) *) 0)->i; \
1340 qForeachContainer(&_container_, (__typeof__(container) *) 0)->brk; \
1341 --qForeachContainer(&_container_, (__typeof__(container) *) 0)->brk)
1344 # define Q_FOREACH(variable, container) \
1345 for (const QForeachContainerBase &_container_ = qForeachContainerNew(container); \
1346 qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->condition(); \
1347 ++qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i) \
1348 for (variable = *qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i; \
1349 qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk; \
1350 --qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk)
1351 #endif // MSVC6 || MIPSpro
1355 #define Q_FOREVER for(;;)
1356 #ifndef QT_NO_KEYWORDS
1358 # define foreach Q_FOREACH
1361 # define forever Q_FOREVER
1366 /* tell gcc to use its built-in methods for some common functions */
1367 #if defined(QT_NO_DEBUG) && defined(Q_CC_GNU)
1368 # define qMemCopy __builtin_memcpy
1369 # define qMemSet __builtin_memset
1373 template <typename T> static inline T *qGetPtrHelper(T *ptr) { return ptr; }
1374 template <typename Wrapper> static inline typename Wrapper::pointer qGetPtrHelper(const Wrapper &p) { return p.data(); }
1376 #define Q_DECLARE_PRIVATE(Class) \
1377 inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(qGetPtrHelper(d_ptr)); } \
1378 inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(qGetPtrHelper(d_ptr)); } \
1379 friend class Class##Private;
1381 #define Q_DECLARE_PRIVATE_D(Dptr, Class) \
1382 inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(Dptr); } \
1383 inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(Dptr); } \
1384 friend class Class##Private;
1386 #define Q_DECLARE_PUBLIC(Class) \
1387 inline Class* q_func() { return static_cast<Class *>(q_ptr); } \
1388 inline const Class* q_func() const { return static_cast<const Class *>(q_ptr); } \
1391 #define Q_D(Class) Class##Private * const d = d_func()
1392 #define Q_Q(Class) Class * const q = q_func()
1394 #define QT_TR_NOOP(x) x
1395 #define QT_TR_NOOP_UTF8(x) x
1396 #define QT_TRANSLATE_NOOP(scope, x) x
1397 #define QT_TRANSLATE_NOOP_UTF8(scope, x) x
1398 #define QT_TRANSLATE_NOOP3(scope, x, comment) {x, comment}
1399 #define QT_TRANSLATE_NOOP3_UTF8(scope, x, comment) {x, comment}
1401 #ifndef QT_NO_TRANSLATION // ### This should enclose the NOOPs above
1403 // Defined in qcoreapplication.cpp
1404 // The better name qTrId() is reserved for an upcoming function which would
1405 // return a much more powerful QStringFormatter instead of a QString.
1406 Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1);
1408 #define QT_TRID_NOOP(id) id
1410 #endif // QT_NO_TRANSLATION
1412 #define QDOC_PROPERTY(text)
1415 When RTTI is not available, define this macro to force any uses of
1416 dynamic_cast to cause a compile failure.
1419 #ifdef QT_NO_DYNAMIC_CAST
1420 # define dynamic_cast QT_PREPEND_NAMESPACE(qt_dynamic_cast_check)
1422 template<typename T, typename X>
1423 T qt_dynamic_cast_check(X, T* = 0)
1424 { return T::dynamic_cast_will_always_fail_because_rtti_is_disabled; }
1428 Some classes do not permit copies to be made of an object. These
1429 classes contains a private copy constructor and assignment
1430 operator to disable copying (the compiler gives an error message).
1432 #define Q_DISABLE_COPY(Class) \
1433 Class(const Class &) Q_DECL_EQ_DELETE;\
1434 Class &operator=(const Class &) Q_DECL_EQ_DELETE;
1437 Q_CORE_EXPORT QByteArray qgetenv(const char *varName);
1438 Q_CORE_EXPORT bool qputenv(const char *varName, const QByteArray& value);
1440 inline int qIntCast(double f) { return int(f); }
1441 inline int qIntCast(float f) { return int(f); }
1444 Reentrant versions of basic rand() functions for random number generation
1446 Q_CORE_EXPORT void qsrand(uint seed);
1447 Q_CORE_EXPORT int qrand();
1449 #define QT_MODULE(x)
1452 // QNX doesn't have SYSV style shared memory. Multiprocess QWS apps,
1453 // shared fonts and QSystemSemaphore + QSharedMemory are not available
1454 # define QT_NO_SYSTEMSEMAPHORE
1455 # define QT_NO_SHAREDMEMORY
1458 #if defined (__ELF__)
1459 # if defined (Q_OS_LINUX) || defined (Q_OS_SOLARIS) || defined (Q_OS_FREEBSD) || defined (Q_OS_OPENBSD) || defined (Q_OS_IRIX)
1464 #if !defined(QT_BOOTSTRAPPED) && defined(QT_REDUCE_RELOCATIONS) && defined(__ELF__) && !defined(__PIC__)
1465 # error "You must build your code with position independent code if Qt was built with -reduce-relocations. "\
1466 "Compile your code with -fPIC or -fPIE."
1469 namespace QtPrivate {
1470 //like std::enable_if
1471 template <bool B, typename T = void> struct QEnableIf;
1472 template <typename T> struct QEnableIf<true, T> { typedef T Type; };
1478 // qDebug and friends
1479 #include <QtCore/qlogging.h>
1481 #include <QtCore/qsysinfo.h>
1482 #include <QtCore/qtypeinfo.h>
1484 #endif /* __cplusplus */
1486 #endif /* QGLOBAL_H */