source: trunk/src/corelib/global/qglobal.h@ 806

Last change on this file since 806 was 797, checked in by Dmitry A. Kuminov, 15 years ago

corelib: Implemented QSysInfo::os2Version() (closes #66).

File size: 84.5 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtCore module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QGLOBAL_H
43#define QGLOBAL_H
44
45#include <stddef.h>
46
47#define QT_VERSION_STR "4.6.3"
48/*
49 QT_VERSION is (major << 16) + (minor << 8) + patch.
50*/
51#define QT_VERSION 0x040603
52/*
53 can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
54*/
55#define QT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch))
56
57#define QT_PACKAGEDATE_STR "2010-06-02"
58
59#define QT_PACKAGE_TAG "76353f177cd84327c692ea31ec644df683643194"
60
61#if !defined(QT_BUILD_MOC)
62#include <QtCore/qconfig.h>
63#endif
64
65#ifdef __cplusplus
66
67#ifndef QT_NAMESPACE /* user namespace */
68
69# define QT_PREPEND_NAMESPACE(name) ::name
70# define QT_USE_NAMESPACE
71# define QT_BEGIN_NAMESPACE
72# define QT_END_NAMESPACE
73# define QT_BEGIN_INCLUDE_NAMESPACE
74# define QT_END_INCLUDE_NAMESPACE
75# define QT_BEGIN_MOC_NAMESPACE
76# define QT_END_MOC_NAMESPACE
77# define QT_FORWARD_DECLARE_CLASS(name) class name;
78# define QT_FORWARD_DECLARE_STRUCT(name) struct name;
79# define QT_MANGLE_NAMESPACE(name) name
80
81#else /* user namespace */
82
83# define QT_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name
84# define QT_USE_NAMESPACE using namespace ::QT_NAMESPACE;
85# define QT_BEGIN_NAMESPACE namespace QT_NAMESPACE {
86# define QT_END_NAMESPACE }
87# define QT_BEGIN_INCLUDE_NAMESPACE }
88# define QT_END_INCLUDE_NAMESPACE namespace QT_NAMESPACE {
89# define QT_BEGIN_MOC_NAMESPACE QT_USE_NAMESPACE
90# define QT_END_MOC_NAMESPACE
91# define QT_FORWARD_DECLARE_CLASS(name) \
92 QT_BEGIN_NAMESPACE class name; QT_END_NAMESPACE \
93 using QT_PREPEND_NAMESPACE(name);
94
95# define QT_FORWARD_DECLARE_STRUCT(name) \
96 QT_BEGIN_NAMESPACE struct name; QT_END_NAMESPACE \
97 using QT_PREPEND_NAMESPACE(name);
98
99# define QT_MANGLE_NAMESPACE0(x) x
100# define QT_MANGLE_NAMESPACE1(a, b) a##_##b
101# define QT_MANGLE_NAMESPACE2(a, b) QT_MANGLE_NAMESPACE1(a,b)
102# define QT_MANGLE_NAMESPACE(name) QT_MANGLE_NAMESPACE2( \
103 QT_MANGLE_NAMESPACE0(name), QT_MANGLE_NAMESPACE0(QT_NAMESPACE))
104
105namespace QT_NAMESPACE {}
106
107# ifndef QT_BOOTSTRAPPED
108# ifndef QT_NO_USING_NAMESPACE
109 /*
110 This expands to a "using QT_NAMESPACE" also in _header files_.
111 It is the only way the feature can be used without too much
112 pain, but if people _really_ do not want it they can add
113 DEFINES += QT_NO_USING_NAMESPACE to their .pro files.
114 */
115 QT_USE_NAMESPACE
116# endif
117# endif
118
119#endif /* user namespace */
120
121#else /* __cplusplus */
122
123# define QT_BEGIN_NAMESPACE
124# define QT_END_NAMESPACE
125# define QT_USE_NAMESPACE
126# define QT_BEGIN_INCLUDE_NAMESPACE
127# define QT_END_INCLUDE_NAMESPACE
128
129#endif /* __cplusplus */
130
131#if defined(Q_OS_MAC) && !defined(Q_CC_INTEL)
132#define QT_BEGIN_HEADER extern "C++" {
133#define QT_END_HEADER }
134#define QT_BEGIN_INCLUDE_HEADER }
135#define QT_END_INCLUDE_HEADER extern "C++" {
136#else
137#define QT_BEGIN_HEADER
138#define QT_END_HEADER
139#define QT_BEGIN_INCLUDE_HEADER
140#define QT_END_INCLUDE_HEADER extern "C++"
141#endif
142
143/*
144 The operating system, must be one of: (Q_OS_x)
145
146 DARWIN - Darwin OS (synonym for Q_OS_MAC)
147 SYMBIAN - Symbian
148 MSDOS - MS-DOS and Windows
149 OS2 - OS/2
150 OS2EMX - XFree86 on OS/2 (not PM)
151 WIN32 - Win32 (Windows 2000/XP/Vista/7 and Windows Server 2003/2008)
152 WINCE - WinCE (Windows CE 5.0)
153 CYGWIN - Cygwin
154 SOLARIS - Sun Solaris
155 HPUX - HP-UX
156 ULTRIX - DEC Ultrix
157 LINUX - Linux
158 FREEBSD - FreeBSD
159 NETBSD - NetBSD
160 OPENBSD - OpenBSD
161 BSDI - BSD/OS
162 IRIX - SGI Irix
163 OSF - HP Tru64 UNIX
164 SCO - SCO OpenServer 5
165 UNIXWARE - UnixWare 7, Open UNIX 8
166 AIX - AIX
167 HURD - GNU Hurd
168 DGUX - DG/UX
169 RELIANT - Reliant UNIX
170 DYNIX - DYNIX/ptx
171 QNX - QNX
172 QNX6 - QNX RTP 6.1
173 LYNX - LynxOS
174 BSD4 - Any BSD 4.4 system
175 UNIX - Any UNIX BSD/SYSV system
176*/
177
178#if defined(__APPLE__) && (defined(__GNUC__) || defined(__xlC__) || defined(__xlc__))
179# define Q_OS_DARWIN
180# define Q_OS_BSD4
181# ifdef __LP64__
182# define Q_OS_DARWIN64
183# else
184# define Q_OS_DARWIN32
185# endif
186#elif defined(__SYMBIAN32__) || defined(SYMBIAN)
187# define Q_OS_SYMBIAN
188# define Q_NO_POSIX_SIGNALS
189# define QT_NO_GETIFADDRS
190#elif defined(__CYGWIN__)
191# define Q_OS_CYGWIN
192#elif defined(MSDOS) || defined(_MSDOS)
193# define Q_OS_MSDOS
194#elif defined(__OS2__)
195# if defined(__EMX__) && !defined(__INNOTEK_LIBC__)
196# define Q_OS_OS2EMX
197# else
198# define Q_OS_OS2
199# endif
200#elif !defined(SAG_COM) && (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))
201# define Q_OS_WIN32
202# define Q_OS_WIN64
203#elif !defined(SAG_COM) && (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__))
204# if defined(WINCE) || defined(_WIN32_WCE)
205# define Q_OS_WINCE
206# else
207# define Q_OS_WIN32
208# endif
209#elif defined(__MWERKS__) && defined(__INTEL__)
210# define Q_OS_WIN32
211#elif defined(__sun) || defined(sun)
212# define Q_OS_SOLARIS
213#elif defined(hpux) || defined(__hpux)
214# define Q_OS_HPUX
215#elif defined(__ultrix) || defined(ultrix)
216# define Q_OS_ULTRIX
217#elif defined(sinix)
218# define Q_OS_RELIANT
219#elif defined(__linux__) || defined(__linux)
220# define Q_OS_LINUX
221#elif defined(__FreeBSD__) || defined(__DragonFly__)
222# define Q_OS_FREEBSD
223# define Q_OS_BSD4
224#elif defined(__NetBSD__)
225# define Q_OS_NETBSD
226# define Q_OS_BSD4
227#elif defined(__OpenBSD__)
228# define Q_OS_OPENBSD
229# define Q_OS_BSD4
230#elif defined(__bsdi__)
231# define Q_OS_BSDI
232# define Q_OS_BSD4
233#elif defined(__sgi)
234# define Q_OS_IRIX
235#elif defined(__osf__)
236# define Q_OS_OSF
237#elif defined(_AIX)
238# define Q_OS_AIX
239#elif defined(__Lynx__)
240# define Q_OS_LYNX
241#elif defined(__GNU__)
242# define Q_OS_HURD
243#elif defined(__DGUX__)
244# define Q_OS_DGUX
245#elif defined(__QNXNTO__)
246# define Q_OS_QNX
247#elif defined(_SEQUENT_)
248# define Q_OS_DYNIX
249#elif defined(_SCO_DS) /* SCO OpenServer 5 + GCC */
250# define Q_OS_SCO
251#elif defined(__USLC__) /* all SCO platforms + UDK or OUDK */
252# define Q_OS_UNIXWARE
253#elif defined(__svr4__) && defined(i386) /* Open UNIX 8 + GCC */
254# define Q_OS_UNIXWARE
255#elif defined(__INTEGRITY)
256# define Q_OS_INTEGRITY
257#elif defined(VXWORKS) /* there is no "real" VxWorks define - this has to be set in the mkspec! */
258# define Q_OS_VXWORKS
259#elif defined(__MAKEDEPEND__)
260#else
261# error "Qt has not been ported to this OS - talk to [email protected]"
262#endif
263
264#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) || defined(Q_OS_WINCE)
265# define Q_OS_WIN
266#endif
267
268#if defined(Q_OS_DARWIN)
269# define Q_OS_MAC /* Q_OS_MAC is mostly for compatibility, but also more clear */
270# define Q_OS_MACX /* Q_OS_MACX is only for compatibility.*/
271# if defined(Q_OS_DARWIN64)
272# define Q_OS_MAC64
273# elif defined(Q_OS_DARWIN32)
274# define Q_OS_MAC32
275# endif
276#endif
277
278#ifdef AUTODETECT_COCOA
279# ifdef Q_OS_MAC64
280# define QT_MAC_USE_COCOA 1
281# define QT_BUILD_KEY QT_BUILD_KEY_COCOA
282# else
283# define QT_BUILD_KEY QT_BUILD_KEY_CARBON
284# endif
285#endif
286
287#if defined(Q_OS_MAC64) && !defined(QT_MAC_USE_COCOA) && !defined(QT_BUILD_QMAKE)
288#error "You are building a 64-bit application, but using a 32-bit version of Qt. Check your build configuration."
289#endif
290
291#if defined(Q_OS_MSDOS) || defined(Q_OS_OS2) || defined(Q_OS_WIN)
292# undef Q_OS_UNIX
293#elif !defined(Q_OS_UNIX)
294# define Q_OS_UNIX
295#endif
296
297#if defined(Q_OS_DARWIN) && !defined(QT_LARGEFILE_SUPPORT)
298# define QT_LARGEFILE_SUPPORT 64
299#endif
300
301#ifdef Q_OS_DARWIN
302# ifdef MAC_OS_X_VERSION_MIN_REQUIRED
303# undef MAC_OS_X_VERSION_MIN_REQUIRED
304# endif
305# define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_4
306# include <AvailabilityMacros.h>
307# if !defined(MAC_OS_X_VERSION_10_3)
308# define MAC_OS_X_VERSION_10_3 MAC_OS_X_VERSION_10_2 + 1
309# endif
310# if !defined(MAC_OS_X_VERSION_10_4)
311# define MAC_OS_X_VERSION_10_4 MAC_OS_X_VERSION_10_3 + 1
312# endif
313# if !defined(MAC_OS_X_VERSION_10_5)
314# define MAC_OS_X_VERSION_10_5 MAC_OS_X_VERSION_10_4 + 1
315# endif
316# if !defined(MAC_OS_X_VERSION_10_6)
317# define MAC_OS_X_VERSION_10_6 MAC_OS_X_VERSION_10_5 + 1
318# endif
319# if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_6)
320# warning "This version of Mac OS X is unsupported"
321# endif
322#endif
323
324#ifdef __LSB_VERSION__
325# if __LSB_VERSION__ < 40
326# error "This version of the Linux Standard Base is unsupported"
327# endif
328#ifndef QT_LINUXBASE
329# define QT_LINUXBASE
330#endif
331#endif
332
333/*
334 The compiler, must be one of: (Q_CC_x)
335
336 SYM - Digital Mars C/C++ (used to be Symantec C++)
337 MWERKS - Metrowerks CodeWarrior
338 MSVC - Microsoft Visual C/C++, Intel C++ for Windows
339 BOR - Borland/Turbo C++
340 WAT - Watcom C++
341 GNU - GNU C++
342 COMEAU - Comeau C++
343 EDG - Edison Design Group C++
344 OC - CenterLine C++
345 SUN - Forte Developer, or Sun Studio C++
346 MIPS - MIPSpro C++
347 DEC - DEC C++
348 HPACC - HP aC++
349 USLC - SCO OUDK and UDK
350 CDS - Reliant C++
351 KAI - KAI C++
352 INTEL - Intel C++ for Linux, Intel C++ for Windows
353 HIGHC - MetaWare High C/C++
354 PGI - Portland Group C++
355 GHS - Green Hills Optimizing C++ Compilers
356 GCCE - GCCE (Symbian GCCE builds)
357 RVCT - ARM Realview Compiler Suite
358 NOKIAX86 - Nokia x86 (Symbian WINSCW builds)
359
360
361 Should be sorted most to least authoritative.
362*/
363
364#if defined(__ghs)
365# define Q_OUTOFLINE_TEMPLATE inline
366#endif
367
368/* Symantec C++ is now Digital Mars */
369#if defined(__DMC__) || defined(__SC__)
370# define Q_CC_SYM
371/* "explicit" semantics implemented in 8.1e but keyword recognized since 7.5 */
372# if defined(__SC__) && __SC__ < 0x750
373# define Q_NO_EXPLICIT_KEYWORD
374# endif
375# define Q_NO_USING_KEYWORD
376
377#elif defined(__MWERKS__)
378# define Q_CC_MWERKS
379# if defined(__EMU_SYMBIAN_OS__)
380# define Q_CC_NOKIAX86
381# endif
382/* "explicit" recognized since 4.0d1 */
383
384#elif defined(_MSC_VER)
385# define Q_CC_MSVC
386/* proper support of bool for _MSC_VER >= 1100 */
387# define Q_CANNOT_DELETE_CONSTANT
388# define Q_OUTOFLINE_TEMPLATE inline
389# define Q_NO_TEMPLATE_FRIENDS
390# define QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION
391# define Q_ALIGNOF(type) __alignof(type)
392# define Q_DECL_ALIGN(n) __declspec(align(n))
393
394/* Visual C++.Net issues for _MSC_VER >= 1300 */
395# if _MSC_VER >= 1300
396# define Q_CC_MSVC_NET
397# if _MSC_VER < 1310 || (defined(Q_OS_WIN64) && defined(_M_IA64))
398# define Q_TYPENAME
399# else
400# undef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION
401# endif
402# else
403# define Q_NO_USING_KEYWORD
404# define QT_NO_MEMBER_TEMPLATES
405# endif
406# if _MSC_VER < 1310
407# define QT_NO_QOBJECT_CHECK
408# define Q_TYPENAME
409# define QT_NO_TEMPLATE_TEMPLATE_PARAMETERS
410# endif
411/* Intel C++ disguising as Visual C++: the `using' keyword avoids warnings */
412# if defined(__INTEL_COMPILER)
413# define Q_CC_INTEL
414# endif
415/* x64 does not support mmx intrinsics on windows */
416# if (defined(Q_OS_WIN64) && defined(_M_X64))
417# undef QT_HAVE_SSE
418# undef QT_HAVE_SSE2
419# undef QT_HAVE_MMX
420# undef QT_HAVE_3DNOW
421# endif
422
423
424#elif defined(__BORLANDC__) || defined(__TURBOC__)
425# define Q_CC_BOR
426# define Q_INLINE_TEMPLATE
427# if __BORLANDC__ < 0x502
428# define Q_NO_BOOL_TYPE
429# define Q_NO_EXPLICIT_KEYWORD
430# endif
431# define Q_NO_USING_KEYWORD
432
433#elif defined(__WATCOMC__)
434# define Q_CC_WAT
435
436/* Symbian GCCE */
437#elif defined(__GCCE__)
438# define Q_CC_GCCE
439# define QT_VISIBILITY_AVAILABLE
440# if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__)
441# define QT_HAVE_ARMV6
442# endif
443
444/* ARM Realview Compiler Suite
445 RVCT compiler also defines __EDG__ and __GNUC__ (if --gnu flag is given),
446 so check for it before that */
447#elif defined(__ARMCC__) || defined(__CC_ARM)
448# define Q_CC_RVCT
449# if __TARGET_ARCH_ARM >= 6
450# define QT_HAVE_ARMV6
451# endif
452#elif defined(__GNUC__)
453# define Q_CC_GNU
454# define Q_C_CALLBACKS
455# if defined(__MINGW32__)
456# define Q_CC_MINGW
457# endif
458# if defined(__INTEL_COMPILER)
459/* Intel C++ also masquerades as GCC 3.2.0 */
460# define Q_CC_INTEL
461# define Q_NO_TEMPLATE_FRIENDS
462# endif
463# ifdef __APPLE__
464# define Q_NO_DEPRECATED_CONSTRUCTORS
465# endif
466# if __GNUC__ == 2 && __GNUC_MINOR__ <= 7
467# define Q_FULL_TEMPLATE_INSTANTIATION
468# endif
469/* GCC 2.95 knows "using" but does not support it correctly */
470# if __GNUC__ == 2 && __GNUC_MINOR__ <= 95
471# define Q_NO_USING_KEYWORD
472# define QT_NO_STL_WCHAR
473# endif
474# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
475# define Q_ALIGNOF(type) __alignof__(type)
476# define Q_TYPEOF(expr) __typeof__(expr)
477# define Q_DECL_ALIGN(n) __attribute__((__aligned__(n)))
478# endif
479/* GCC 3.1 and GCC 3.2 wrongly define _SB_CTYPE_MACROS on HP-UX */
480# if defined(Q_OS_HPUX) && __GNUC__ == 3 && __GNUC_MINOR__ >= 1
481# define Q_WRONG_SB_CTYPE_MACROS
482# endif
483/* GCC <= 3.3 cannot handle template friends */
484# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ <= 3)
485# define Q_NO_TEMPLATE_FRIENDS
486# endif
487/* Apple's GCC 3.1 chokes on our streaming qDebug() */
488# if defined(Q_OS_DARWIN) && __GNUC__ == 3 && (__GNUC_MINOR__ >= 1 && __GNUC_MINOR__ < 3)
489# define Q_BROKEN_DEBUG_STREAM
490# endif
491# if (defined(Q_CC_GNU) || defined(Q_CC_INTEL)) && !defined(QT_MOC_CPP)
492# define Q_PACKED __attribute__ ((__packed__))
493# define Q_NO_PACKED_REFERENCE
494# ifndef __ARM_EABI__
495# define QT_NO_ARM_EABI
496# endif
497# endif
498
499/* IBM compiler versions are a bit messy. There are actually two products:
500 the C product, and the C++ product. The C++ compiler is always packaged
501 with the latest version of the C compiler. Version numbers do not always
502 match. This little table (I'm not sure it's accurate) should be helpful:
503
504 C++ product C product
505
506 C Set 3.1 C Compiler 3.0
507 ... ...
508 C++ Compiler 3.6.6 C Compiler 4.3
509 ... ...
510 Visual Age C++ 4.0 ...
511 ... ...
512 Visual Age C++ 5.0 C Compiler 5.0
513 ... ...
514 Visual Age C++ 6.0 C Compiler 6.0
515
516 Now:
517 __xlC__ is the version of the C compiler in hexadecimal notation
518 is only an approximation of the C++ compiler version
519 __IBMCPP__ is the version of the C++ compiler in decimal notation
520 but it is not defined on older compilers like C Set 3.1 */
521#elif defined(__xlC__)
522# define Q_CC_XLC
523# define Q_FULL_TEMPLATE_INSTANTIATION
524# if __xlC__ < 0x400
525# define Q_NO_BOOL_TYPE
526# define Q_NO_EXPLICIT_KEYWORD
527# define Q_NO_USING_KEYWORD
528# define Q_TYPENAME
529# define Q_OUTOFLINE_TEMPLATE inline
530# define Q_BROKEN_TEMPLATE_SPECIALIZATION
531# define Q_CANNOT_DELETE_CONSTANT
532# elif __xlC__ >= 0x0600
533# define Q_ALIGNOF(type) __alignof__(type)
534# define Q_TYPEOF(expr) __typeof__(expr)
535# define Q_DECL_ALIGN(n) __attribute__((__aligned__(n)))
536# define Q_PACKED __attribute__((__packed__))
537# endif
538
539/* Older versions of DEC C++ do not define __EDG__ or __EDG - observed
540 on DEC C++ V5.5-004. New versions do define __EDG__ - observed on
541 Compaq C++ V6.3-002.
542 This compiler is different enough from other EDG compilers to handle
543 it separately anyway. */
544#elif defined(__DECCXX) || defined(__DECC)
545# define Q_CC_DEC
546/* Compaq C++ V6 compilers are EDG-based but I'm not sure about older
547 DEC C++ V5 compilers. */
548# if defined(__EDG__)
549# define Q_CC_EDG
550# endif
551/* Compaq have disabled EDG's _BOOL macro and use _BOOL_EXISTS instead
552 - observed on Compaq C++ V6.3-002.
553 In any case versions prior to Compaq C++ V6.0-005 do not have bool. */
554# if !defined(_BOOL_EXISTS)
555# define Q_NO_BOOL_TYPE
556# endif
557/* Spurious (?) error messages observed on Compaq C++ V6.5-014. */
558# define Q_NO_USING_KEYWORD
559/* Apply to all versions prior to Compaq C++ V6.0-000 - observed on
560 DEC C++ V5.5-004. */
561# if __DECCXX_VER < 60060000
562# define Q_TYPENAME
563# define Q_BROKEN_TEMPLATE_SPECIALIZATION
564# define Q_CANNOT_DELETE_CONSTANT
565# endif
566/* avoid undefined symbol problems with out-of-line template members */
567# define Q_OUTOFLINE_TEMPLATE inline
568
569/* The Portland Group C++ compiler is based on EDG and does define __EDG__
570 but the C compiler does not */
571#elif defined(__PGI)
572# define Q_CC_PGI
573# if defined(__EDG__)
574# define Q_CC_EDG
575# endif
576
577/* Compilers with EDG front end are similar. To detect them we test:
578 __EDG documented by SGI, observed on MIPSpro 7.3.1.1 and KAI C++ 4.0b
579 __EDG__ documented in EDG online docs, observed on Compaq C++ V6.3-002
580 and PGI C++ 5.2-4 */
581#elif !defined(Q_OS_HPUX) && (defined(__EDG) || defined(__EDG__))
582# define Q_CC_EDG
583/* From the EDG documentation (does not seem to apply to Compaq C++):
584 _BOOL
585 Defined in C++ mode when bool is a keyword. The name of this
586 predefined macro is specified by a configuration flag. _BOOL
587 is the default.
588 __BOOL_DEFINED
589 Defined in Microsoft C++ mode when bool is a keyword. */
590# if !defined(_BOOL) && !defined(__BOOL_DEFINED)
591# define Q_NO_BOOL_TYPE
592# endif
593
594/* The Comeau compiler is based on EDG and does define __EDG__ */
595# if defined(__COMO__)
596# define Q_CC_COMEAU
597# define Q_C_CALLBACKS
598
599/* The `using' keyword was introduced to avoid KAI C++ warnings
600 but it's now causing KAI C++ errors instead. The standard is
601 unclear about the use of this keyword, and in practice every
602 compiler is using its own set of rules. Forget it. */
603# elif defined(__KCC)
604# define Q_CC_KAI
605# define Q_NO_USING_KEYWORD
606
607/* Using the `using' keyword avoids Intel C++ for Linux warnings */
608# elif defined(__INTEL_COMPILER)
609# define Q_CC_INTEL
610
611/* Uses CFront, make sure to read the manual how to tweak templates. */
612# elif defined(__ghs)
613# define Q_CC_GHS
614
615# elif defined(__DCC__)
616# define Q_CC_DIAB
617# undef Q_NO_BOOL_TYPE
618# if !defined(__bool)
619# define Q_NO_BOOL_TYPE
620# endif
621
622/* The UnixWare 7 UDK compiler is based on EDG and does define __EDG__ */
623# elif defined(__USLC__) && defined(__SCO_VERSION__)
624# define Q_CC_USLC
625/* The latest UDK 7.1.1b does not need this, but previous versions do */
626# if !defined(__SCO_VERSION__) || (__SCO_VERSION__ < 302200010)
627# define Q_OUTOFLINE_TEMPLATE inline
628# endif
629# define Q_NO_USING_KEYWORD /* ### check "using" status */
630
631/* Never tested! */
632# elif defined(CENTERLINE_CLPP) || defined(OBJECTCENTER)
633# define Q_CC_OC
634# define Q_NO_USING_KEYWORD
635
636/* CDS++ defines __EDG__ although this is not documented in the Reliant
637 documentation. It also follows conventions like _BOOL and this documented */
638# elif defined(sinix)
639# define Q_CC_CDS
640# define Q_NO_USING_KEYWORD
641
642/* The MIPSpro compiler defines __EDG */
643# elif defined(__sgi)
644# define Q_CC_MIPS
645# define Q_NO_USING_KEYWORD /* ### check "using" status */
646# define Q_NO_TEMPLATE_FRIENDS
647# if defined(_COMPILER_VERSION) && (_COMPILER_VERSION >= 740)
648# define Q_OUTOFLINE_TEMPLATE inline
649# pragma set woff 3624,3625,3649 /* turn off some harmless warnings */
650# endif
651# endif
652
653/* VxWorks' DIAB toolchain has an additional EDG type C++ compiler
654 (see __DCC__ above). This one is for C mode files (__EDG is not defined) */
655#elif defined(_DIAB_TOOL)
656# define Q_CC_DIAB
657
658/* Never tested! */
659#elif defined(__HIGHC__)
660# define Q_CC_HIGHC
661
662#elif defined(__SUNPRO_CC) || defined(__SUNPRO_C)
663# define Q_CC_SUN
664/* 5.0 compiler or better
665 'bool' is enabled by default but can be disabled using -features=nobool
666 in which case _BOOL is not defined
667 this is the default in 4.2 compatibility mode triggered by -compat=4 */
668# if __SUNPRO_CC >= 0x500
669# define QT_NO_TEMPLATE_TEMPLATE_PARAMETERS
670 /* see http://developers.sun.com/sunstudio/support/Ccompare.html */
671# if __SUNPRO_CC >= 0x590
672# define Q_ALIGNOF(type) __alignof__(type)
673# define Q_TYPEOF(expr) __typeof__(expr)
674# define Q_DECL_ALIGN(n) __attribute__((__aligned__(n)))
675// using CC 5.9: Warning: attribute visibility is unsupported and will be skipped..
676//# define Q_DECL_EXPORT __attribute__((__visibility__("default")))
677# endif
678# if __SUNPRO_CC < 0x5a0
679# define Q_NO_TEMPLATE_FRIENDS
680# endif
681# if !defined(_BOOL)
682# define Q_NO_BOOL_TYPE
683# endif
684# if defined(__SUNPRO_CC_COMPAT) && (__SUNPRO_CC_COMPAT <= 4)
685# define Q_NO_USING_KEYWORD
686# endif
687# define Q_C_CALLBACKS
688/* 4.2 compiler or older */
689# else
690# define Q_NO_BOOL_TYPE
691# define Q_NO_EXPLICIT_KEYWORD
692# define Q_NO_USING_KEYWORD
693# endif
694
695/* CDS++ does not seem to define __EDG__ or __EDG according to Reliant
696 documentation but nevertheless uses EDG conventions like _BOOL */
697#elif defined(sinix)
698# define Q_CC_EDG
699# define Q_CC_CDS
700# if !defined(_BOOL)
701# define Q_NO_BOOL_TYPE
702# endif
703# define Q_BROKEN_TEMPLATE_SPECIALIZATION
704
705#elif defined(Q_OS_HPUX)
706/* __HP_aCC was not defined in first aCC releases */
707# if defined(__HP_aCC) || __cplusplus >= 199707L
708# define Q_NO_TEMPLATE_FRIENDS
709# define Q_CC_HPACC
710# if __HP_aCC-0 < 060000
711# define QT_NO_TEMPLATE_TEMPLATE_PARAMETERS
712# define Q_DECL_EXPORT __declspec(dllexport)
713# define Q_DECL_IMPORT __declspec(dllimport)
714# endif
715# if __HP_aCC-0 >= 061200
716# define Q_DECL_ALIGNED(n) __attribute__((aligned(n)))
717# endif
718# if __HP_aCC-0 >= 062000
719# define Q_DECL_EXPORT __attribute__((visibility("default")))
720# define Q_DECL_IMPORT Q_DECL_EXPORT
721# endif
722# else
723# define Q_CC_HP
724# define Q_NO_BOOL_TYPE
725# define Q_FULL_TEMPLATE_INSTANTIATION
726# define Q_BROKEN_TEMPLATE_SPECIALIZATION
727# define Q_NO_EXPLICIT_KEYWORD
728# endif
729# define Q_NO_USING_KEYWORD /* ### check "using" status */
730
731#elif defined(__WINSCW__) && !defined(Q_CC_NOKIAX86)
732# define Q_CC_NOKIAX86
733
734
735#else
736# error "Qt has not been tested with this compiler - talk to [email protected]"
737#endif
738
739#ifndef Q_PACKED
740# define Q_PACKED
741# undef Q_NO_PACKED_REFERENCE
742#endif
743
744#ifndef Q_CONSTRUCTOR_FUNCTION
745# define Q_CONSTRUCTOR_FUNCTION0(AFUNC) \
746 static const int AFUNC ## __init_variable__ = AFUNC();
747# define Q_CONSTRUCTOR_FUNCTION(AFUNC) Q_CONSTRUCTOR_FUNCTION0(AFUNC)
748#endif
749
750#ifndef Q_DESTRUCTOR_FUNCTION
751# define Q_DESTRUCTOR_FUNCTION0(AFUNC) \
752 class AFUNC ## __dest_class__ { \
753 public: \
754 inline AFUNC ## __dest_class__() { } \
755 inline ~ AFUNC ## __dest_class__() { AFUNC(); } \
756 } AFUNC ## __dest_instance__;
757# define Q_DESTRUCTOR_FUNCTION(AFUNC) Q_DESTRUCTOR_FUNCTION0(AFUNC)
758#endif
759
760#ifndef Q_REQUIRED_RESULT
761# if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
762# define Q_REQUIRED_RESULT __attribute__ ((warn_unused_result))
763# else
764# define Q_REQUIRED_RESULT
765# endif
766#endif
767
768#ifndef Q_COMPILER_MANGLES_RETURN_TYPE
769# if defined(Q_CC_MSVC)
770# define Q_COMPILER_MANGLES_RETURN_TYPE
771# endif
772#endif
773
774/*
775 The window system, must be one of: (Q_WS_x)
776
777 MACX - Mac OS X
778 MAC9 - Mac OS 9
779 QWS - Qt for Embedded Linux
780 WIN32 - Windows
781 X11 - X Window System
782 S60 - Symbian S60
783 PM - OS/2 Presentation Manager
784 WIN16 - unsupported
785*/
786
787#if defined(Q_OS_MSDOS)
788# define Q_WS_WIN16
789# error "Qt requires Win32 and does not work with Windows 3.x"
790#elif defined(_WIN32_X11_)
791# define Q_WS_X11
792#elif defined(Q_OS_WIN32)
793# define Q_WS_WIN32
794# if defined(Q_OS_WIN64)
795# define Q_WS_WIN64
796# endif
797#elif defined(Q_OS_WINCE)
798# define Q_WS_WIN32
799# define Q_WS_WINCE
800# if defined(Q_OS_WINCE_WM)
801# define Q_WS_WINCE_WM
802# endif
803#elif defined(Q_OS_OS2)
804# define Q_WS_PM
805#elif defined(Q_OS_UNIX)
806# if defined(Q_OS_MAC) && !defined(__USE_WS_X11__) && !defined(Q_WS_QWS)
807# define Q_WS_MAC
808# define Q_WS_MACX
809# if defined(Q_OS_MAC64)
810# define Q_WS_MAC64
811# elif defined(Q_OS_MAC32)
812# define Q_WS_MAC32
813# endif
814# elif defined(Q_OS_SYMBIAN)
815# if !defined(QT_NO_S60)
816# define Q_WS_S60
817# endif
818# elif !defined(Q_WS_QWS)
819# define Q_WS_X11
820# endif
821#endif
822
823#if defined(Q_WS_WIN16) || defined(Q_WS_WIN32) || defined(Q_WS_WINCE)
824# define Q_WS_WIN
825#endif
826
827QT_BEGIN_HEADER
828QT_BEGIN_NAMESPACE
829
830/*
831 Size-dependent types (architechture-dependent byte order)
832
833 Make sure to update QMetaType when changing these typedefs
834*/
835
836typedef signed char qint8; /* 8 bit signed */
837typedef unsigned char quint8; /* 8 bit unsigned */
838typedef short qint16; /* 16 bit signed */
839typedef unsigned short quint16; /* 16 bit unsigned */
840typedef int qint32; /* 32 bit signed */
841typedef unsigned int quint32; /* 32 bit unsigned */
842#if defined(Q_OS_WIN) && !defined(Q_CC_GNU) && !defined(Q_CC_MWERKS)
843# define Q_INT64_C(c) c ## i64 /* signed 64 bit constant */
844# define Q_UINT64_C(c) c ## ui64 /* unsigned 64 bit constant */
845typedef __int64 qint64; /* 64 bit signed */
846typedef unsigned __int64 quint64; /* 64 bit unsigned */
847#else
848# define Q_INT64_C(c) static_cast<long long>(c ## LL) /* signed 64 bit constant */
849# define Q_UINT64_C(c) static_cast<unsigned long long>(c ## ULL) /* unsigned 64 bit constant */
850typedef long long qint64; /* 64 bit signed */
851typedef unsigned long long quint64; /* 64 bit unsigned */
852#endif
853
854typedef qint64 qlonglong;
855typedef quint64 qulonglong;
856
857#ifndef QT_POINTER_SIZE
858# if defined(Q_OS_WIN64)
859# define QT_POINTER_SIZE 8
860# elif defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
861# define QT_POINTER_SIZE 4
862# endif
863#endif
864
865#define Q_INIT_RESOURCE(name) \
866 do { extern int QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); \
867 QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); } while (0)
868#define Q_CLEANUP_RESOURCE(name) \
869 do { extern int QT_MANGLE_NAMESPACE(qCleanupResources_ ## name) (); \
870 QT_MANGLE_NAMESPACE(qCleanupResources_ ## name) (); } while (0)
871
872#if defined(__cplusplus)
873
874/*
875 quintptr and qptrdiff is guaranteed to be the same size as a pointer, i.e.
876
877 sizeof(void *) == sizeof(quintptr)
878 && sizeof(void *) == sizeof(qptrdiff)
879*/
880template <int> struct QIntegerForSize;
881template <> struct QIntegerForSize<1> { typedef quint8 Unsigned; typedef qint8 Signed; };
882template <> struct QIntegerForSize<2> { typedef quint16 Unsigned; typedef qint16 Signed; };
883template <> struct QIntegerForSize<4> { typedef quint32 Unsigned; typedef qint32 Signed; };
884template <> struct QIntegerForSize<8> { typedef quint64 Unsigned; typedef qint64 Signed; };
885template <class T> struct QIntegerForSizeof: QIntegerForSize<sizeof(T)> { };
886typedef QIntegerForSizeof<void*>::Unsigned quintptr;
887typedef QIntegerForSizeof<void*>::Signed qptrdiff;
888
889/*
890 Useful type definitions for Qt
891*/
892
893QT_BEGIN_INCLUDE_NAMESPACE
894typedef unsigned char uchar;
895typedef unsigned short ushort;
896typedef unsigned int uint;
897typedef unsigned long ulong;
898QT_END_INCLUDE_NAMESPACE
899
900#if defined(Q_NO_BOOL_TYPE)
901#error "Compiler doesn't support the bool type"
902#endif
903
904/*
905 Constant bool values
906*/
907
908#ifndef QT_LINUXBASE /* the LSB defines TRUE and FALSE for us */
909/* Symbian OS defines TRUE = 1 and FALSE = 0,
910redefine to built-in booleans to make autotests work properly */
911#ifdef Q_OS_SYMBIAN
912 #include <e32def.h> /* Symbian OS defines */
913
914 #undef TRUE
915 #undef FALSE
916#endif
917# ifndef TRUE
918# define TRUE true
919# define FALSE false
920# endif
921#endif
922
923/*
924 Proper for-scoping in VC++6 and MIPSpro CC
925*/
926#ifndef QT_NO_KEYWORDS
927# if (defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) && !defined(Q_CC_INTEL)) || defined(Q_CC_MIPS) || (defined(Q_CC_HPACC) && defined(__ia64))
928# define for if(0){}else for
929# endif
930#endif
931
932/*
933 Workaround for static const members on MSVC++.
934*/
935
936#if defined(Q_CC_MSVC)
937# define QT_STATIC_CONST static
938# define QT_STATIC_CONST_IMPL
939#else
940# define QT_STATIC_CONST static const
941# define QT_STATIC_CONST_IMPL const
942#endif
943
944/*
945 Warnings and errors when using deprecated methods
946*/
947#if defined(Q_MOC_RUN)
948# define Q_DECL_DEPRECATED Q_DECL_DEPRECATED
949#elif (defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && (__GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2))) || defined(Q_CC_RVCT)
950# define Q_DECL_DEPRECATED __attribute__ ((__deprecated__))
951#elif defined(Q_CC_MSVC) && (_MSC_VER >= 1300)
952# define Q_DECL_DEPRECATED __declspec(deprecated)
953# if defined (Q_CC_INTEL)
954# define Q_DECL_VARIABLE_DEPRECATED
955# else
956# endif
957#else
958# define Q_DECL_DEPRECATED
959#endif
960#ifndef Q_DECL_VARIABLE_DEPRECATED
961# define Q_DECL_VARIABLE_DEPRECATED Q_DECL_DEPRECATED
962#endif
963#ifndef Q_DECL_CONSTRUCTOR_DEPRECATED
964# if defined(Q_MOC_RUN)
965# define Q_DECL_CONSTRUCTOR_DEPRECATED Q_DECL_CONSTRUCTOR_DEPRECATED
966# elif defined(Q_NO_DEPRECATED_CONSTRUCTORS)
967# define Q_DECL_CONSTRUCTOR_DEPRECATED
968# else
969# define Q_DECL_CONSTRUCTOR_DEPRECATED Q_DECL_DEPRECATED
970# endif
971#endif
972
973#if defined(QT_NO_DEPRECATED)
974/* disable Qt3 support as well */
975# undef QT3_SUPPORT_WARNINGS
976# undef QT3_SUPPORT
977# undef QT_DEPRECATED
978# undef QT_DEPRECATED_VARIABLE
979# undef QT_DEPRECATED_CONSTRUCTOR
980#elif defined(QT_DEPRECATED_WARNINGS)
981/* enable Qt3 support warnings as well */
982# undef QT3_SUPPORT_WARNINGS
983# define QT3_SUPPORT_WARNINGS
984# undef QT_DEPRECATED
985# define QT_DEPRECATED Q_DECL_DEPRECATED
986# undef QT_DEPRECATED_VARIABLE
987# define QT_DEPRECATED_VARIABLE Q_DECL_VARIABLE_DEPRECATED
988# undef QT_DEPRECATED_CONSTRUCTOR
989# define QT_DEPRECATED_CONSTRUCTOR explicit Q_DECL_CONSTRUCTOR_DEPRECATED
990#else
991# undef QT_DEPRECATED
992# define QT_DEPRECATED
993# undef QT_DEPRECATED_VARIABLE
994# define QT_DEPRECATED_VARIABLE
995# undef QT_DEPRECATED_CONSTRUCTOR
996# define QT_DEPRECATED_CONSTRUCTOR
997#endif
998
999#if defined(QT3_SUPPORT_WARNINGS)
1000# if !defined(QT_COMPAT_WARNINGS) /* also enable compat */
1001# define QT_COMPAT_WARNINGS
1002# endif
1003# undef QT3_SUPPORT
1004# define QT3_SUPPORT Q_DECL_DEPRECATED
1005# undef QT3_SUPPORT_VARIABLE
1006# define QT3_SUPPORT_VARIABLE Q_DECL_VARIABLE_DEPRECATED
1007# undef QT3_SUPPORT_CONSTRUCTOR
1008# define QT3_SUPPORT_CONSTRUCTOR explicit Q_DECL_CONSTRUCTOR_DEPRECATED
1009#elif defined(QT3_SUPPORT) /* define back to nothing */
1010# if !defined(QT_COMPAT) /* also enable qt3 support */
1011# define QT_COMPAT
1012# endif
1013# undef QT3_SUPPORT
1014# define QT3_SUPPORT
1015# undef QT3_SUPPORT_VARIABLE
1016# define QT3_SUPPORT_VARIABLE
1017# undef QT3_SUPPORT_CONSTRUCTOR
1018# define QT3_SUPPORT_CONSTRUCTOR explicit
1019#endif
1020
1021/* moc compats (signals/slots) */
1022#ifndef QT_MOC_COMPAT
1023# if defined(QT3_SUPPORT)
1024# define QT_MOC_COMPAT QT3_SUPPORT
1025# else
1026# define QT_MOC_COMPAT
1027# endif
1028#else
1029# undef QT_MOC_COMPAT
1030# define QT_MOC_COMPAT
1031#endif
1032
1033#ifdef QT_ASCII_CAST_WARNINGS
1034# define QT_ASCII_CAST_WARN Q_DECL_DEPRECATED
1035# if defined(Q_CC_GNU) && __GNUC__ < 4
1036 /* gcc < 4 doesn't like Q_DECL_DEPRECATED in front of constructors */
1037# define QT_ASCII_CAST_WARN_CONSTRUCTOR
1038# else
1039# define QT_ASCII_CAST_WARN_CONSTRUCTOR Q_DECL_CONSTRUCTOR_DEPRECATED
1040# endif
1041#else
1042# define QT_ASCII_CAST_WARN
1043# define QT_ASCII_CAST_WARN_CONSTRUCTOR
1044#endif
1045
1046#if defined(__i386__) || defined(_WIN32) || defined(_WIN32_WCE)
1047# if defined(Q_CC_GNU)
1048#if !defined(Q_CC_INTEL) && ((100*(__GNUC__ - 0) + 10*(__GNUC_MINOR__ - 0) + __GNUC_PATCHLEVEL__) >= 332)
1049# define QT_FASTCALL __attribute__((regparm(3)))
1050#else
1051# define QT_FASTCALL
1052#endif
1053# elif defined(Q_CC_MSVC) && (_MSC_VER > 1300 || defined(Q_CC_INTEL))
1054# define QT_FASTCALL __fastcall
1055# else
1056# define QT_FASTCALL
1057# endif
1058#else
1059# define QT_FASTCALL
1060#endif
1061
1062typedef int QNoImplicitBoolCast;
1063
1064#if defined(QT_ARCH_ARM) || defined(QT_ARCH_ARMV6) || defined(QT_ARCH_AVR32) || (defined(QT_ARCH_MIPS) && (defined(Q_WS_QWS) || defined(Q_OS_WINCE))) || defined(QT_ARCH_SH) || defined(QT_ARCH_SH4A)
1065#define QT_NO_FPU
1066#endif
1067
1068// This logic must match the one in qmetatype.h
1069#if defined(QT_COORD_TYPE)
1070typedef QT_COORD_TYPE qreal;
1071#elif defined(QT_NO_FPU) || defined(QT_ARCH_ARM) || defined(QT_ARCH_WINDOWSCE) || defined(QT_ARCH_SYMBIAN)
1072typedef float qreal;
1073#else
1074typedef double qreal;
1075#endif
1076
1077/*
1078 Utility macros and inline functions
1079*/
1080
1081template <typename T>
1082inline T qAbs(const T &t) { return t >= 0 ? t : -t; }
1083
1084inline int qRound(qreal d)
1085{ return d >= 0.0 ? int(d + 0.5) : int(d - int(d-1) + 0.5) + int(d-1); }
1086
1087#if defined(QT_NO_FPU) || defined(QT_ARCH_ARM) || defined(QT_ARCH_WINDOWSCE) || defined(QT_ARCH_SYMBIAN)
1088inline qint64 qRound64(double d)
1089{ return d >= 0.0 ? qint64(d + 0.5) : qint64(d - qreal(qint64(d-1)) + 0.5) + qint64(d-1); }
1090#else
1091inline qint64 qRound64(qreal d)
1092{ return d >= 0.0 ? qint64(d + 0.5) : qint64(d - qreal(qint64(d-1)) + 0.5) + qint64(d-1); }
1093#endif
1094
1095template <typename T>
1096inline const T &qMin(const T &a, const T &b) { if (a < b) return a; return b; }
1097template <typename T>
1098inline const T &qMax(const T &a, const T &b) { if (a < b) return b; return a; }
1099template <typename T>
1100inline const T &qBound(const T &min, const T &val, const T &max)
1101{ return qMax(min, qMin(max, val)); }
1102
1103#ifdef QT3_SUPPORT
1104typedef qint8 Q_INT8;
1105typedef quint8 Q_UINT8;
1106typedef qint16 Q_INT16;
1107typedef quint16 Q_UINT16;
1108typedef qint32 Q_INT32;
1109typedef quint32 Q_UINT32;
1110typedef qint64 Q_INT64;
1111typedef quint64 Q_UINT64;
1112
1113typedef qint64 Q_LLONG;
1114typedef quint64 Q_ULLONG;
1115#if defined(Q_OS_WIN64)
1116typedef __int64 Q_LONG; /* word up to 64 bit signed */
1117typedef unsigned __int64 Q_ULONG; /* word up to 64 bit unsigned */
1118#else
1119typedef long Q_LONG; /* word up to 64 bit signed */
1120typedef unsigned long Q_ULONG; /* word up to 64 bit unsigned */
1121#endif
1122
1123# define QABS(a) qAbs(a)
1124# define QMAX(a, b) qMax((a), (b))
1125# define QMIN(a, b) qMin((a), (b))
1126#endif
1127
1128/*
1129 Data stream functions are provided by many classes (defined in qdatastream.h)
1130*/
1131
1132class QDataStream;
1133
1134#ifndef QT_BUILD_KEY
1135#define QT_BUILD_KEY "unspecified"
1136#endif
1137
1138#if defined(Q_WS_MAC)
1139# ifndef QMAC_QMENUBAR_NO_EVENT
1140# define QMAC_QMENUBAR_NO_EVENT
1141# endif
1142#endif
1143
1144#if !defined(Q_WS_QWS) && !defined(QT_NO_COP)
1145# define QT_NO_COP
1146#endif
1147
1148#if defined(Q_OS_VXWORKS)
1149# define QT_NO_CRASHHANDLER // no popen
1150# define QT_NO_PROCESS // no exec*, no fork
1151# define QT_NO_LPR
1152# define QT_NO_SHAREDMEMORY // only POSIX, no SysV and in the end...
1153# define QT_NO_SYSTEMSEMAPHORE // not needed at all in a flat address space
1154# define QT_NO_QWS_MULTIPROCESS // no processes
1155#endif
1156
1157# include <QtCore/qfeatures.h>
1158
1159#define QT_SUPPORTS(FEATURE) (!defined(QT_NO_##FEATURE))
1160
1161#ifndef Q_DECL_EXPORT
1162# if defined(Q_OS_WIN) || defined(Q_OS_OS2) || defined(Q_CC_NOKIAX86) || defined(Q_CC_RVCT)
1163# define Q_DECL_EXPORT __declspec(dllexport)
1164# elif defined(QT_VISIBILITY_AVAILABLE)
1165# define Q_DECL_EXPORT __attribute__((visibility("default")))
1166# endif
1167# ifndef Q_DECL_EXPORT
1168# define Q_DECL_EXPORT
1169# endif
1170#endif
1171#ifndef Q_DECL_IMPORT
1172# if defined(Q_OS_WIN) || defined(Q_OS_OS2) || defined(Q_CC_NOKIAX86) || defined(Q_CC_RVCT)
1173# define Q_DECL_IMPORT __declspec(dllimport)
1174# else
1175# define Q_DECL_IMPORT
1176# endif
1177#endif
1178
1179/*
1180 Create Qt DLL if QT_DLL is defined (Windows, Symbian and OS/2 only)
1181*/
1182
1183#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) || defined(Q_OS_OS2)
1184# if defined(QT_NODLL)
1185# undef QT_MAKEDLL
1186# undef QT_DLL
1187# elif defined(QT_MAKEDLL) /* create a Qt DLL library */
1188# if defined(QT_DLL)
1189# undef QT_DLL
1190# endif
1191# if defined(QT_BUILD_CORE_LIB)
1192# define Q_CORE_EXPORT Q_DECL_EXPORT
1193# else
1194# define Q_CORE_EXPORT Q_DECL_IMPORT
1195# endif
1196# if defined(QT_BUILD_GUI_LIB)
1197# define Q_GUI_EXPORT Q_DECL_EXPORT
1198# else
1199# define Q_GUI_EXPORT Q_DECL_IMPORT
1200# endif
1201# if defined(QT_BUILD_SQL_LIB)
1202# define Q_SQL_EXPORT Q_DECL_EXPORT
1203# else
1204# define Q_SQL_EXPORT Q_DECL_IMPORT
1205# endif
1206# if defined(QT_BUILD_NETWORK_LIB)
1207# define Q_NETWORK_EXPORT Q_DECL_EXPORT
1208# else
1209# define Q_NETWORK_EXPORT Q_DECL_IMPORT
1210# endif
1211# if defined(QT_BUILD_SVG_LIB)
1212# define Q_SVG_EXPORT Q_DECL_EXPORT
1213# else
1214# define Q_SVG_EXPORT Q_DECL_IMPORT
1215# endif
1216# if defined(QT_BUILD_DECLARATIVE_LIB)
1217# define Q_DECLARATIVE_EXPORT Q_DECL_EXPORT
1218# else
1219# define Q_DECLARATIVE_EXPORT Q_DECL_IMPORT
1220# endif
1221# if defined(QT_BUILD_OPENGL_LIB)
1222# define Q_OPENGL_EXPORT Q_DECL_EXPORT
1223# else
1224# define Q_OPENGL_EXPORT Q_DECL_IMPORT
1225# endif
1226# if defined(QT_BUILD_MULTIMEDIA_LIB)
1227# define Q_MULTIMEDIA_EXPORT Q_DECL_EXPORT
1228# else
1229# define Q_MULTIMEDIA_EXPORT Q_DECL_IMPORT
1230# endif
1231# if defined(QT_BUILD_OPENVG_LIB)
1232# define Q_OPENVG_EXPORT Q_DECL_EXPORT
1233# else
1234# define Q_OPENVG_EXPORT Q_DECL_IMPORT
1235# endif
1236# if defined(QT_BUILD_XML_LIB)
1237# define Q_XML_EXPORT Q_DECL_EXPORT
1238# else
1239# define Q_XML_EXPORT Q_DECL_IMPORT
1240# endif
1241# if defined(QT_BUILD_XMLPATTERNS_LIB)
1242# define Q_XMLPATTERNS_EXPORT Q_DECL_EXPORT
1243# else
1244# define Q_XMLPATTERNS_EXPORT Q_DECL_IMPORT
1245# endif
1246# if defined(QT_BUILD_SCRIPT_LIB)
1247# define Q_SCRIPT_EXPORT Q_DECL_EXPORT
1248# else
1249# define Q_SCRIPT_EXPORT Q_DECL_IMPORT
1250# endif
1251# if defined(QT_BUILD_SCRIPTTOOLS_LIB)
1252# define Q_SCRIPTTOOLS_EXPORT Q_DECL_EXPORT
1253# else
1254# define Q_SCRIPTTOOLS_EXPORT Q_DECL_IMPORT
1255# endif
1256# if defined(QT_BUILD_CANVAS_LIB)
1257# define Q_CANVAS_EXPORT Q_DECL_EXPORT
1258# else
1259# define Q_CANVAS_EXPORT Q_DECL_IMPORT
1260# endif
1261# if defined(QT_BUILD_COMPAT_LIB)
1262# define Q_COMPAT_EXPORT Q_DECL_EXPORT
1263# else
1264# define Q_COMPAT_EXPORT Q_DECL_IMPORT
1265# endif
1266# define Q_TEMPLATEDLL
1267# elif defined(QT_DLL) /* use a Qt DLL library */
1268# define Q_CORE_EXPORT Q_DECL_IMPORT
1269# define Q_GUI_EXPORT Q_DECL_IMPORT
1270# define Q_SQL_EXPORT Q_DECL_IMPORT
1271# define Q_NETWORK_EXPORT Q_DECL_IMPORT
1272# define Q_SVG_EXPORT Q_DECL_IMPORT
1273# define Q_DECLARATIVE_EXPORT Q_DECL_IMPORT
1274# define Q_CANVAS_EXPORT Q_DECL_IMPORT
1275# define Q_OPENGL_EXPORT Q_DECL_IMPORT
1276# define Q_MULTIMEDIA_EXPORT Q_DECL_IMPORT
1277# define Q_OPENVG_EXPORT Q_DECL_IMPORT
1278# define Q_XML_EXPORT Q_DECL_IMPORT
1279# define Q_XMLPATTERNS_EXPORT Q_DECL_IMPORT
1280# define Q_SCRIPT_EXPORT Q_DECL_IMPORT
1281# define Q_SCRIPTTOOLS_EXPORT Q_DECL_IMPORT
1282# define Q_COMPAT_EXPORT Q_DECL_IMPORT
1283# define Q_TEMPLATEDLL
1284# endif
1285# define Q_NO_DECLARED_NOT_DEFINED
1286#else
1287# if defined(Q_OS_LINUX) && defined(Q_CC_BOR)
1288# define Q_TEMPLATEDLL
1289# define Q_NO_DECLARED_NOT_DEFINED
1290# endif
1291# undef QT_MAKEDLL /* ignore these for other platforms */
1292# undef QT_DLL
1293#endif
1294
1295#if !defined(Q_CORE_EXPORT)
1296# if defined(QT_SHARED)
1297# define Q_CORE_EXPORT Q_DECL_EXPORT
1298# define Q_GUI_EXPORT Q_DECL_EXPORT
1299# define Q_SQL_EXPORT Q_DECL_EXPORT
1300# define Q_NETWORK_EXPORT Q_DECL_EXPORT
1301# define Q_SVG_EXPORT Q_DECL_EXPORT
1302# define Q_DECLARATIVE_EXPORT Q_DECL_EXPORT
1303# define Q_OPENGL_EXPORT Q_DECL_EXPORT
1304# define Q_MULTIMEDIA_EXPORT Q_DECL_EXPORT
1305# define Q_OPENVG_EXPORT Q_DECL_EXPORT
1306# define Q_XML_EXPORT Q_DECL_EXPORT
1307# define Q_XMLPATTERNS_EXPORT Q_DECL_EXPORT
1308# define Q_SCRIPT_EXPORT Q_DECL_EXPORT
1309# define Q_SCRIPTTOOLS_EXPORT Q_DECL_EXPORT
1310# define Q_COMPAT_EXPORT Q_DECL_EXPORT
1311# else
1312# define Q_CORE_EXPORT
1313# define Q_GUI_EXPORT
1314# define Q_SQL_EXPORT
1315# define Q_NETWORK_EXPORT
1316# define Q_SVG_EXPORT
1317# define Q_DECLARATIVE_EXPORT
1318# define Q_OPENGL_EXPORT
1319# define Q_MULTIMEDIA_EXPORT
1320# define Q_XML_EXPORT
1321# define Q_XMLPATTERNS_EXPORT
1322# define Q_SCRIPT_EXPORT
1323# define Q_SCRIPTTOOLS_EXPORT
1324# define Q_COMPAT_EXPORT
1325# endif
1326#endif
1327
1328// Functions marked as Q_GUI_EXPORT_INLINE were exported and inlined by mistake.
1329// Compilers like MinGW complain that the import attribute is ignored.
1330#if defined(Q_CC_MINGW)
1331# if defined(QT_BUILD_CORE_LIB)
1332# define Q_CORE_EXPORT_INLINE Q_CORE_EXPORT inline
1333# else
1334# define Q_CORE_EXPORT_INLINE inline
1335# endif
1336# if defined(QT_BUILD_GUI_LIB)
1337# define Q_GUI_EXPORT_INLINE Q_GUI_EXPORT inline
1338# else
1339# define Q_GUI_EXPORT_INLINE inline
1340# endif
1341#elif defined(Q_OS_OS2) && defined(Q_CC_GNU)
1342// the dllexport attribute effectively cancels inlining even when it is possible
1343// (e.g. in optimized builds) so omit it to have such functions actually inlined
1344# define Q_CORE_EXPORT_INLINE inline
1345# define Q_GUI_EXPORT_INLINE inline
1346#elif defined(Q_CC_RVCT)
1347// we force RVCT not to export inlines by passing --visibility_inlines_hidden
1348// so we need to just inline it, rather than exporting and inlining
1349// note: this affects the contents of the DEF files (ie. these functions do not appear)
1350# define Q_CORE_EXPORT_INLINE inline
1351# define Q_GUI_EXPORT_INLINE inline
1352#else
1353# define Q_CORE_EXPORT_INLINE Q_CORE_EXPORT inline
1354# define Q_GUI_EXPORT_INLINE Q_GUI_EXPORT inline
1355#endif
1356
1357/*
1358 No, this is not an evil backdoor. QT_BUILD_INTERNAL just exports more symbols
1359 for Qt's internal unit tests. If you want slower loading times and more
1360 symbols that can vanish from version to version, feel free to define QT_BUILD_INTERNAL.
1361*/
1362#if defined(QT_BUILD_INTERNAL) && (defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)) && defined(QT_MAKEDLL)
1363# define Q_AUTOTEST_EXPORT Q_DECL_EXPORT
1364#elif defined(QT_BUILD_INTERNAL) && (defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)) && defined(QT_DLL)
1365# define Q_AUTOTEST_EXPORT Q_DECL_IMPORT
1366#elif defined(QT_BUILD_INTERNAL) && !(defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)) && defined(QT_SHARED)
1367# define Q_AUTOTEST_EXPORT Q_DECL_EXPORT
1368#else
1369# define Q_AUTOTEST_EXPORT
1370#endif
1371
1372inline void qt_noop() {}
1373
1374/* These wrap try/catch so we can switch off exceptions later.
1375
1376 Beware - do not use more than one QT_CATCH per QT_TRY, and do not use
1377 the exception instance in the catch block.
1378 If you can't live with those constraints, don't use these macros.
1379 Use the QT_NO_EXCEPTIONS macro to protect your code instead.
1380*/
1381
1382#ifdef QT_BOOTSTRAPPED
1383# define QT_NO_EXCEPTIONS
1384#endif
1385#if !defined(QT_NO_EXCEPTIONS) && defined(Q_CC_GNU) && !defined (__EXCEPTIONS) && !defined(Q_MOC_RUN)
1386# define QT_NO_EXCEPTIONS
1387#endif
1388
1389#ifdef QT_NO_EXCEPTIONS
1390# define QT_TRY if (true)
1391# define QT_CATCH(A) else
1392# define QT_THROW(A) qt_noop()
1393# define QT_RETHROW qt_noop()
1394#else
1395# define QT_TRY try
1396# define QT_CATCH(A) catch (A)
1397# define QT_THROW(A) throw A
1398# define QT_RETHROW throw
1399#endif
1400
1401/*
1402 System information
1403*/
1404
1405class QString;
1406class Q_CORE_EXPORT QSysInfo {
1407public:
1408 enum Sizes {
1409 WordSize = (sizeof(void *)<<3)
1410 };
1411
1412#if defined(QT_BUILD_QMAKE)
1413 enum Endian {
1414 BigEndian,
1415 LittleEndian
1416 };
1417 /* needed to bootstrap qmake */
1418 static const int ByteOrder;
1419#elif defined(Q_BYTE_ORDER)
1420 enum Endian {
1421 BigEndian,
1422 LittleEndian
1423
1424# ifdef qdoc
1425 , ByteOrder = <platform-dependent>
1426# elif Q_BYTE_ORDER == Q_BIG_ENDIAN
1427 , ByteOrder = BigEndian
1428# elif Q_BYTE_ORDER == Q_LITTLE_ENDIAN
1429 , ByteOrder = LittleEndian
1430# else
1431# error "Undefined byte order"
1432# endif
1433 };
1434#else
1435# error "Qt not configured correctly, please run configure"
1436#endif
1437#if defined(Q_WS_WIN) || defined(Q_OS_CYGWIN)
1438 enum WinVersion {
1439 WV_32s = 0x0001,
1440 WV_95 = 0x0002,
1441 WV_98 = 0x0003,
1442 WV_Me = 0x0004,
1443 WV_DOS_based= 0x000f,
1444
1445 /* codenames */
1446 WV_NT = 0x0010,
1447 WV_2000 = 0x0020,
1448 WV_XP = 0x0030,
1449 WV_2003 = 0x0040,
1450 WV_VISTA = 0x0080,
1451 WV_WINDOWS7 = 0x0090,
1452 WV_NT_based = 0x00f0,
1453
1454 /* version numbers */
1455 WV_4_0 = WV_NT,
1456 WV_5_0 = WV_2000,
1457 WV_5_1 = WV_XP,
1458 WV_5_2 = WV_2003,
1459 WV_6_0 = WV_VISTA,
1460 WV_6_1 = WV_WINDOWS7,
1461
1462 WV_CE = 0x0100,
1463 WV_CENET = 0x0200,
1464 WV_CE_5 = 0x0300,
1465 WV_CE_6 = 0x0400,
1466 WV_CE_based = 0x0f00
1467 };
1468 static const WinVersion WindowsVersion;
1469 static WinVersion windowsVersion();
1470
1471#endif
1472#ifdef Q_OS_MAC
1473 enum MacVersion {
1474 MV_Unknown = 0x0000,
1475
1476 /* version */
1477 MV_9 = 0x0001,
1478 MV_10_0 = 0x0002,
1479 MV_10_1 = 0x0003,
1480 MV_10_2 = 0x0004,
1481 MV_10_3 = 0x0005,
1482 MV_10_4 = 0x0006,
1483 MV_10_5 = 0x0007,
1484 MV_10_6 = 0x0008,
1485
1486 /* codenames */
1487 MV_CHEETAH = MV_10_0,
1488 MV_PUMA = MV_10_1,
1489 MV_JAGUAR = MV_10_2,
1490 MV_PANTHER = MV_10_3,
1491 MV_TIGER = MV_10_4,
1492 MV_LEOPARD = MV_10_5,
1493 MV_SNOWLEOPARD = MV_10_6
1494 };
1495 static const MacVersion MacintoshVersion;
1496#endif
1497#ifdef Q_OS_SYMBIAN
1498 enum SymbianVersion {
1499 SV_Unknown = 0x0000,
1500 //These are the Symbian Ltd versions 9.2-9.4
1501 SV_9_2 = 10,
1502 SV_9_3 = 20,
1503 SV_9_4 = 30,
1504 //Following values are the symbian foundation versions, i.e. Symbian^1 == SV_SF_1
1505 SV_SF_1 = SV_9_4,
1506 SV_SF_2 = 40,
1507 SV_SF_3 = 50,
1508 SV_SF_4 = 60
1509 };
1510 static SymbianVersion symbianVersion();
1511 enum S60Version {
1512 SV_S60_None = 0,
1513 SV_S60_Unknown = 1,
1514 SV_S60_3_1 = SV_9_2,
1515 SV_S60_3_2 = SV_9_3,
1516 SV_S60_5_0 = SV_9_4,
1517 //versions beyond 5.0 are to be confirmed - it is better to use symbian version
1518 SV_S60_5_1 = SV_SF_2,
1519 SV_S60_5_2 = SV_SF_3
1520 };
1521 static S60Version s60Version();
1522#endif
1523#ifdef Q_OS_OS2
1524 enum Os2Version {
1525 /* OS/2 version */
1526 OV_Unknown = 0x00000000,
1527 OV_2_0 = 0x00000001,
1528 OV_2_1 = 0x00000002,
1529 OV_2_11 = 0x00000003,
1530 OV_3_0 = 0x01000000,
1531 OV_4_0 = 0x02040000,
1532 OV_4_5 = 0x02040500,
1533 OV_4_52 = 0x02040502,
1534
1535 /* OS/2 codenames */
1536 OV_MERLIN = OV_4_0,
1537 OV_AURORA = OV_4_5,
1538 OV_WSEB = OV_4_52,
1539
1540 /* eComStation version */
1541 OV_ECS_Unknown = 0x06000000,
1542 OV_ECS_1_0 = 0x06010000,
1543 OV_ECS_1_1 = 0x06010100,
1544 OV_ECS_1_2 = 0x06010200,
1545 OV_ECS_2_0 = 0x06020000,
1546
1547 /* version masks */
1548 OV_WARP3 = 0x01000000,
1549 OV_WARP4 = 0x02000000,
1550 OV_WARP = OV_WARP3 | OV_WARP4,
1551 OV_ECS = 0x04000000,
1552 };
1553 static Os2Version os2Version();
1554#endif
1555};
1556
1557Q_CORE_EXPORT const char *qVersion();
1558Q_CORE_EXPORT bool qSharedBuild();
1559
1560#if defined(Q_OS_MAC)
1561inline int qMacVersion() { return QSysInfo::MacintoshVersion; }
1562#endif
1563
1564#ifdef QT3_SUPPORT
1565inline QT3_SUPPORT bool qSysInfo(int *wordSize, bool *bigEndian)
1566{
1567 *wordSize = QSysInfo::WordSize;
1568 *bigEndian = (QSysInfo::ByteOrder == QSysInfo::BigEndian);
1569 return true;
1570}
1571#endif
1572
1573#if defined(Q_WS_WIN) || defined(Q_OS_CYGWIN)
1574#if defined(QT3_SUPPORT)
1575inline QT3_SUPPORT bool qt_winUnicode() { return true; }
1576inline QT3_SUPPORT int qWinVersion() { return QSysInfo::WindowsVersion; }
1577#endif
1578
1579#define QT_WA(unicode, ansi) unicode
1580#define QT_WA_INLINE(unicode, ansi) (unicode)
1581
1582#endif /* Q_WS_WIN */
1583
1584#ifndef Q_OUTOFLINE_TEMPLATE
1585# define Q_OUTOFLINE_TEMPLATE
1586#endif
1587#ifndef Q_INLINE_TEMPLATE
1588# define Q_INLINE_TEMPLATE inline
1589#endif
1590
1591#ifndef Q_TYPENAME
1592# define Q_TYPENAME typename
1593#endif
1594
1595/*
1596 Avoid "unused parameter" warnings
1597*/
1598
1599#if defined(Q_CC_INTEL) && !defined(Q_OS_WIN) || defined(Q_CC_RVCT)
1600template <typename T>
1601inline void qUnused(T &x) { (void)x; }
1602# define Q_UNUSED(x) qUnused(x);
1603#else
1604# define Q_UNUSED(x) (void)x;
1605#endif
1606
1607/*
1608 Debugging and error handling
1609*/
1610
1611/*
1612 On Symbian we do not know beforehand whether we are compiling in
1613 release or debug mode, so check the Symbian build define here,
1614 and set the QT_NO_DEBUG define appropriately.
1615*/
1616#if defined(Q_OS_SYMBIAN) && defined(NDEBUG) && !defined(QT_NO_DEBUG)
1617# define QT_NO_DEBUG
1618#endif
1619
1620#if !defined(QT_NO_DEBUG) && !defined(QT_DEBUG)
1621# define QT_DEBUG
1622#endif
1623
1624#ifndef qPrintable
1625# define qPrintable(string) (string).toLocal8Bit().constData()
1626#endif
1627
1628Q_CORE_EXPORT void qDebug(const char *, ...) /* print debug message */
1629#if defined(Q_CC_GNU) && !defined(__INSURE__)
1630 __attribute__ ((format (printf, 1, 2)))
1631#endif
1632;
1633
1634Q_CORE_EXPORT void qWarning(const char *, ...) /* print warning message */
1635#if defined(Q_CC_GNU) && !defined(__INSURE__)
1636 __attribute__ ((format (printf, 1, 2)))
1637#endif
1638;
1639
1640class QString;
1641Q_CORE_EXPORT QString qt_error_string(int errorCode = -1);
1642Q_CORE_EXPORT void qCritical(const char *, ...) /* print critical message */
1643#if defined(Q_CC_GNU) && !defined(__INSURE__)
1644 __attribute__ ((format (printf, 1, 2)))
1645#endif
1646;
1647Q_CORE_EXPORT void qFatal(const char *, ...) /* print fatal message and exit */
1648#if defined(Q_CC_GNU) && !defined(__INSURE__)
1649 __attribute__ ((format (printf, 1, 2)))
1650#endif
1651;
1652
1653#ifdef QT3_SUPPORT
1654Q_CORE_EXPORT QT3_SUPPORT void qSystemWarning(const char *msg, int code = -1);
1655#endif /* QT3_SUPPORT */
1656Q_CORE_EXPORT void qErrnoWarning(int code, const char *msg, ...);
1657Q_CORE_EXPORT void qErrnoWarning(const char *msg, ...);
1658
1659#if (defined(QT_NO_DEBUG_OUTPUT) || defined(QT_NO_TEXTSTREAM)) && !defined(QT_NO_DEBUG_STREAM)
1660#define QT_NO_DEBUG_STREAM
1661#endif
1662
1663/*
1664 Forward declarations only.
1665
1666 In order to use the qDebug() stream, you must #include<QDebug>
1667*/
1668class QDebug;
1669class QNoDebug;
1670#ifndef QT_NO_DEBUG_STREAM
1671Q_CORE_EXPORT_INLINE QDebug qDebug();
1672Q_CORE_EXPORT_INLINE QDebug qWarning();
1673Q_CORE_EXPORT_INLINE QDebug qCritical();
1674#else
1675inline QNoDebug qDebug();
1676#endif
1677
1678#define QT_NO_QDEBUG_MACRO while (false) qDebug
1679#ifdef QT_NO_DEBUG_OUTPUT
1680# define qDebug QT_NO_QDEBUG_MACRO
1681#endif
1682#define QT_NO_QWARNING_MACRO while (false) qWarning
1683#ifdef QT_NO_WARNING_OUTPUT
1684# define qWarning QT_NO_QWARNING_MACRO
1685#endif
1686
1687
1688Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int line);
1689
1690#if !defined(Q_ASSERT)
1691# ifndef QT_NO_DEBUG
1692# define Q_ASSERT(cond) ((!(cond)) ? qt_assert(#cond,__FILE__,__LINE__) : qt_noop())
1693# else
1694# define Q_ASSERT(cond) qt_noop()
1695# endif
1696#endif
1697
1698#if defined(QT_NO_DEBUG) && !defined(QT_PAINT_DEBUG)
1699#define QT_NO_PAINT_DEBUG
1700#endif
1701
1702Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char *file, int line);
1703
1704#if !defined(Q_ASSERT_X)
1705# ifndef QT_NO_DEBUG
1706# define Q_ASSERT_X(cond, where, what) ((!(cond)) ? qt_assert_x(where, what,__FILE__,__LINE__) : qt_noop())
1707# else
1708# define Q_ASSERT_X(cond, where, what) qt_noop()
1709# endif
1710#endif
1711
1712Q_CORE_EXPORT void qt_check_pointer(const char *, int);
1713Q_CORE_EXPORT void qBadAlloc();
1714
1715#ifdef QT_NO_EXCEPTIONS
1716# if defined(QT_NO_DEBUG)
1717# define Q_CHECK_PTR(p) qt_noop();
1718# else
1719# define Q_CHECK_PTR(p) do {if(!(p))qt_check_pointer(__FILE__,__LINE__);} while (0)
1720# endif
1721#else
1722# define Q_CHECK_PTR(p) do { if (!(p)) qBadAlloc(); } while (0)
1723#endif
1724
1725template <typename T>
1726inline T *q_check_ptr(T *p) { Q_CHECK_PTR(p); return p; }
1727
1728#if (defined(Q_CC_GNU) && !defined(Q_OS_SOLARIS)) || defined(Q_CC_HPACC) || defined(Q_CC_DIAB)
1729# define Q_FUNC_INFO __PRETTY_FUNCTION__
1730#elif defined(_MSC_VER)
1731 /* MSVC 2002 doesn't have __FUNCSIG__ nor can it handle QT_STRINGIFY. */
1732# if _MSC_VER <= 1300
1733# define Q_FUNC_INFO __FILE__ "(line number unavailable)"
1734# else
1735# define Q_FUNC_INFO __FUNCSIG__
1736# endif
1737#else
1738# if defined(Q_OS_SOLARIS) || defined(Q_CC_XLC) || defined(Q_OS_SYMBIAN)
1739# define Q_FUNC_INFO __FILE__ "(line number unavailable)"
1740# else
1741 /* These two macros makes it possible to turn the builtin line expander into a
1742 * string literal. */
1743# define QT_STRINGIFY2(x) #x
1744# define QT_STRINGIFY(x) QT_STRINGIFY2(x)
1745# define Q_FUNC_INFO __FILE__ ":" QT_STRINGIFY(__LINE__)
1746# endif
1747 /* The MIPSpro and RVCT compilers postpones macro expansion,
1748 and therefore macros must be in scope when being used. */
1749# if !defined(Q_CC_MIPS) && !defined(Q_CC_RVCT) && !defined(Q_CC_NOKIAX86)
1750# undef QT_STRINGIFY2
1751# undef QT_STRINGIFY
1752# endif
1753#endif
1754
1755enum QtMsgType { QtDebugMsg, QtWarningMsg, QtCriticalMsg, QtFatalMsg, QtSystemMsg = QtCriticalMsg };
1756
1757Q_CORE_EXPORT void qt_message_output(QtMsgType, const char *buf);
1758
1759typedef void (*QtMsgHandler)(QtMsgType, const char *);
1760Q_CORE_EXPORT QtMsgHandler qInstallMsgHandler(QtMsgHandler);
1761
1762#ifdef QT3_SUPPORT
1763inline QT3_SUPPORT void qSuppressObsoleteWarnings(bool = true) {}
1764inline QT3_SUPPORT void qObsolete(const char *, const char * = 0, const char * = 0) {}
1765#endif
1766
1767#if defined(QT_NO_THREAD)
1768
1769template <typename T>
1770class QGlobalStatic
1771{
1772public:
1773 T *pointer;
1774 inline QGlobalStatic(T *p) : pointer(p) { }
1775 inline ~QGlobalStatic() { pointer = 0; }
1776};
1777
1778#define Q_GLOBAL_STATIC(TYPE, NAME) \
1779 static TYPE *NAME() \
1780 { \
1781 static TYPE this_##NAME; \
1782 static QGlobalStatic<TYPE > global_##NAME(&this_##NAME); \
1783 return global_##NAME.pointer; \
1784 }
1785
1786#define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \
1787 static TYPE *NAME() \
1788 { \
1789 static TYPE this_##NAME ARGS; \
1790 static QGlobalStatic<TYPE > global_##NAME(&this_##NAME); \
1791 return global_##NAME.pointer; \
1792 }
1793
1794#define Q_GLOBAL_STATIC_WITH_INITIALIZER(TYPE, NAME, INITIALIZER) \
1795 static TYPE *NAME() \
1796 { \
1797 static TYPE this_##NAME; \
1798 static QGlobalStatic<TYPE > global_##NAME(0); \
1799 if (!global_##NAME.pointer) { \
1800 TYPE *x = global_##NAME.pointer = &this_##NAME; \
1801 INITIALIZER; \
1802 } \
1803 return global_##NAME.pointer; \
1804 }
1805
1806#else
1807
1808// forward declaration, since qatomic.h needs qglobal.h
1809template <typename T> class QBasicAtomicPointer;
1810
1811// POD for Q_GLOBAL_STATIC
1812template <typename T>
1813class QGlobalStatic
1814{
1815public:
1816 QBasicAtomicPointer<T> pointer;
1817 bool destroyed;
1818};
1819
1820// Created as a function-local static to delete a QGlobalStatic<T>
1821template <typename T>
1822class QGlobalStaticDeleter
1823{
1824public:
1825 QGlobalStatic<T> &globalStatic;
1826 QGlobalStaticDeleter(QGlobalStatic<T> &_globalStatic)
1827 : globalStatic(_globalStatic)
1828 { }
1829
1830 inline ~QGlobalStaticDeleter()
1831 {
1832 delete globalStatic.pointer;
1833 globalStatic.pointer = 0;
1834 globalStatic.destroyed = true;
1835 }
1836};
1837
1838#define Q_GLOBAL_STATIC_INIT(TYPE, NAME) \
1839 static QGlobalStatic<TYPE > this_##NAME = { Q_BASIC_ATOMIC_INITIALIZER(0), false }
1840
1841#define Q_GLOBAL_STATIC(TYPE, NAME) \
1842 Q_GLOBAL_STATIC_INIT(TYPE, NAME); \
1843 static TYPE *NAME() \
1844 { \
1845 if (!this_##NAME.pointer && !this_##NAME.destroyed) { \
1846 TYPE *x = new TYPE; \
1847 if (!this_##NAME.pointer.testAndSetOrdered(0, x)) \
1848 delete x; \
1849 else \
1850 static QGlobalStaticDeleter<TYPE > cleanup(this_##NAME); \
1851 } \
1852 return this_##NAME.pointer; \
1853 }
1854
1855#define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \
1856 Q_GLOBAL_STATIC_INIT(TYPE, NAME); \
1857 static TYPE *NAME() \
1858 { \
1859 if (!this_##NAME.pointer && !this_##NAME.destroyed) { \
1860 TYPE *x = new TYPE ARGS; \
1861 if (!this_##NAME.pointer.testAndSetOrdered(0, x)) \
1862 delete x; \
1863 else \
1864 static QGlobalStaticDeleter<TYPE > cleanup(this_##NAME); \
1865 } \
1866 return this_##NAME.pointer; \
1867 }
1868
1869#define Q_GLOBAL_STATIC_WITH_INITIALIZER(TYPE, NAME, INITIALIZER) \
1870 Q_GLOBAL_STATIC_INIT(TYPE, NAME); \
1871 static TYPE *NAME() \
1872 { \
1873 if (!this_##NAME.pointer && !this_##NAME.destroyed) { \
1874 QScopedPointer<TYPE > x(new TYPE); \
1875 INITIALIZER; \
1876 if (this_##NAME.pointer.testAndSetOrdered(0, x.data())) { \
1877 static QGlobalStaticDeleter<TYPE > cleanup(this_##NAME); \
1878 x.take(); \
1879 } \
1880 } \
1881 return this_##NAME.pointer; \
1882 }
1883
1884#endif
1885
1886class QBool
1887{
1888 bool b;
1889
1890public:
1891 inline explicit QBool(bool B) : b(B) {}
1892 inline operator const void *() const
1893 { return b ? static_cast<const void *>(this) : static_cast<const void *>(0); }
1894};
1895
1896inline bool operator==(QBool b1, bool b2) { return !b1 == !b2; }
1897inline bool operator==(bool b1, QBool b2) { return !b1 == !b2; }
1898inline bool operator==(QBool b1, QBool b2) { return !b1 == !b2; }
1899inline bool operator!=(QBool b1, bool b2) { return !b1 != !b2; }
1900inline bool operator!=(bool b1, QBool b2) { return !b1 != !b2; }
1901inline bool operator!=(QBool b1, QBool b2) { return !b1 != !b2; }
1902
1903static inline bool qFuzzyCompare(double p1, double p2)
1904{
1905 return (qAbs(p1 - p2) <= 0.000000000001 * qMin(qAbs(p1), qAbs(p2)));
1906}
1907
1908static inline bool qFuzzyCompare(float p1, float p2)
1909{
1910 return (qAbs(p1 - p2) <= 0.00001f * qMin(qAbs(p1), qAbs(p2)));
1911}
1912
1913/*!
1914 \internal
1915*/
1916static inline bool qFuzzyIsNull(double d)
1917{
1918 return qAbs(d) <= 0.000000000001;
1919}
1920
1921/*!
1922 \internal
1923*/
1924static inline bool qFuzzyIsNull(float f)
1925{
1926 return qAbs(f) <= 0.00001f;
1927}
1928
1929/*
1930 This function tests a double for a null value. It doesn't
1931 check whether the actual value is 0 or close to 0, but whether
1932 it is binary 0.
1933*/
1934static inline bool qIsNull(double d)
1935{
1936 union U {
1937 double d;
1938 quint64 u;
1939 };
1940 U val;
1941 val.d = d;
1942 return val.u == quint64(0);
1943}
1944
1945/*
1946 This function tests a float for a null value. It doesn't
1947 check whether the actual value is 0 or close to 0, but whether
1948 it is binary 0.
1949*/
1950static inline bool qIsNull(float f)
1951{
1952 union U {
1953 float f;
1954 quint32 u;
1955 };
1956 U val;
1957 val.f = f;
1958 return val.u == 0u;
1959}
1960
1961/*
1962 Compilers which follow outdated template instantiation rules
1963 require a class to have a comparison operator to exist when
1964 a QList of this type is instantiated. It's not actually
1965 used in the list, though. Hence the dummy implementation.
1966 Just in case other code relies on it we better trigger a warning
1967 mandating a real implementation.
1968*/
1969
1970#ifdef Q_FULL_TEMPLATE_INSTANTIATION
1971# define Q_DUMMY_COMPARISON_OPERATOR(C) \
1972 bool operator==(const C&) const { \
1973 qWarning(#C"::operator==(const "#C"&) was called"); \
1974 return false; \
1975 }
1976#else
1977# define Q_DUMMY_COMPARISON_OPERATOR(C)
1978#endif
1979
1980
1981/*
1982 QTypeInfo - type trait functionality
1983 qIsDetached - data sharing functionality
1984*/
1985
1986#ifndef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION
1987
1988/*
1989 The catch-all template.
1990*/
1991
1992template <typename T> inline bool qIsDetached(T &) { return true; }
1993
1994template <typename T>
1995class QTypeInfo
1996{
1997public:
1998 enum {
1999 isPointer = false,
2000 isComplex = true,
2001 isStatic = true,
2002 isLarge = (sizeof(T)>sizeof(void*)),
2003 isDummy = false
2004 };
2005};
2006
2007template <typename T>
2008class QTypeInfo<T*>
2009{
2010public:
2011 enum {
2012 isPointer = true,
2013 isComplex = false,
2014 isStatic = false,
2015 isLarge = false,
2016 isDummy = false
2017 };
2018};
2019
2020#else
2021
2022template <typename T> char QTypeInfoHelper(T*(*)());
2023void* QTypeInfoHelper(...);
2024
2025template <typename T> inline bool qIsDetached(T &) { return true; }
2026
2027template <typename T>
2028class QTypeInfo
2029{
2030public:
2031 enum {
2032 isPointer = (1 == sizeof(QTypeInfoHelper((T(*)())0))),
2033 isComplex = !isPointer,
2034 isStatic = !isPointer,
2035 isLarge = (sizeof(T)>sizeof(void*)),
2036 isDummy = false
2037 };
2038};
2039
2040#endif /* QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION */
2041
2042/*
2043 Specialize a specific type with:
2044
2045 Q_DECLARE_TYPEINFO(type, flags);
2046
2047 where 'type' is the name of the type to specialize and 'flags' is
2048 logically-OR'ed combination of the flags below.
2049*/
2050enum { /* TYPEINFO flags */
2051 Q_COMPLEX_TYPE = 0,
2052 Q_PRIMITIVE_TYPE = 0x1,
2053 Q_STATIC_TYPE = 0,
2054 Q_MOVABLE_TYPE = 0x2,
2055 Q_DUMMY_TYPE = 0x4
2056};
2057
2058#define Q_DECLARE_TYPEINFO(TYPE, FLAGS) \
2059template <> \
2060class QTypeInfo<TYPE > \
2061{ \
2062public: \
2063 enum { \
2064 isComplex = (((FLAGS) & Q_PRIMITIVE_TYPE) == 0), \
2065 isStatic = (((FLAGS) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), \
2066 isLarge = (sizeof(TYPE)>sizeof(void*)), \
2067 isPointer = false, \
2068 isDummy = (((FLAGS) & Q_DUMMY_TYPE) != 0) \
2069 }; \
2070 static inline const char *name() { return #TYPE; } \
2071}
2072
2073template <typename T>
2074inline void qSwap(T &value1, T &value2)
2075{
2076 const T t = value1;
2077 value1 = value2;
2078 value2 = t;
2079}
2080
2081/*
2082 Specialize a shared type with:
2083
2084 Q_DECLARE_SHARED(type);
2085
2086 where 'type' is the name of the type to specialize. NOTE: shared
2087 types must declare a 'bool isDetached(void) const;' member for this
2088 to work.
2089*/
2090#define Q_DECLARE_SHARED(TYPE) \
2091template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \
2092template <> inline void qSwap<TYPE>(TYPE &value1, TYPE &value2) \
2093{ \
2094 qSwap(value1.data_ptr(), value2.data_ptr()); \
2095}
2096
2097/*
2098 QTypeInfo primitive specializations
2099*/
2100Q_DECLARE_TYPEINFO(bool, Q_PRIMITIVE_TYPE);
2101Q_DECLARE_TYPEINFO(char, Q_PRIMITIVE_TYPE);
2102Q_DECLARE_TYPEINFO(signed char, Q_PRIMITIVE_TYPE);
2103Q_DECLARE_TYPEINFO(uchar, Q_PRIMITIVE_TYPE);
2104Q_DECLARE_TYPEINFO(short, Q_PRIMITIVE_TYPE);
2105Q_DECLARE_TYPEINFO(ushort, Q_PRIMITIVE_TYPE);
2106Q_DECLARE_TYPEINFO(int, Q_PRIMITIVE_TYPE);
2107Q_DECLARE_TYPEINFO(uint, Q_PRIMITIVE_TYPE);
2108Q_DECLARE_TYPEINFO(long, Q_PRIMITIVE_TYPE);
2109Q_DECLARE_TYPEINFO(ulong, Q_PRIMITIVE_TYPE);
2110Q_DECLARE_TYPEINFO(qint64, Q_PRIMITIVE_TYPE);
2111Q_DECLARE_TYPEINFO(quint64, Q_PRIMITIVE_TYPE);
2112Q_DECLARE_TYPEINFO(float, Q_PRIMITIVE_TYPE);
2113Q_DECLARE_TYPEINFO(double, Q_PRIMITIVE_TYPE);
2114#ifndef Q_OS_DARWIN
2115Q_DECLARE_TYPEINFO(long double, Q_PRIMITIVE_TYPE);
2116#endif
2117
2118/*
2119 These functions make it possible to use standard C++ functions with
2120 a similar name from Qt header files (especially template classes).
2121*/
2122Q_CORE_EXPORT void *qMalloc(size_t size);
2123Q_CORE_EXPORT void qFree(void *ptr);
2124Q_CORE_EXPORT void *qRealloc(void *ptr, size_t size);
2125Q_CORE_EXPORT void *qMallocAligned(size_t size, size_t alignment);
2126Q_CORE_EXPORT void *qReallocAligned(void *ptr, size_t size, size_t oldsize, size_t alignment);
2127Q_CORE_EXPORT void qFreeAligned(void *ptr);
2128Q_CORE_EXPORT void *qMemCopy(void *dest, const void *src, size_t n);
2129Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n);
2130
2131
2132/*
2133 Avoid some particularly useless warnings from some stupid compilers.
2134 To get ALL C++ compiler warnings, define QT_CC_WARNINGS or comment out
2135 the line "#define QT_NO_WARNINGS".
2136*/
2137#if !defined(QT_CC_WARNINGS)
2138# define QT_NO_WARNINGS
2139#endif
2140#if defined(QT_NO_WARNINGS)
2141# if defined(Q_CC_MSVC)
2142# pragma warning(disable: 4251) /* class 'A' needs to have dll interface for to be used by clients of class 'B'. */
2143# pragma warning(disable: 4244) /* 'conversion' conversion from 'type1' to 'type2', possible loss of data */
2144# pragma warning(disable: 4275) /* non - DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' */
2145# pragma warning(disable: 4514) /* unreferenced inline/local function has been removed */
2146# pragma warning(disable: 4800) /* 'type' : forcing value to bool 'true' or 'false' (performance warning) */
2147# pragma warning(disable: 4097) /* typedef-name 'identifier1' used as synonym for class-name 'identifier2' */
2148# pragma warning(disable: 4706) /* assignment within conditional expression */
2149# pragma warning(disable: 4786) /* truncating debug info after 255 characters */
2150# pragma warning(disable: 4660) /* template-class specialization 'identifier' is already instantiated */
2151# pragma warning(disable: 4355) /* 'this' : used in base member initializer list */
2152# pragma warning(disable: 4231) /* nonstandard extension used : 'extern' before template explicit instantiation */
2153# pragma warning(disable: 4710) /* function not inlined */
2154# pragma warning(disable: 4530) /* C++ exception handler used, but unwind semantics are not enabled. Specify -GX */
2155# if _MSC_VER < 1300
2156# pragma warning(disable: 4284) /* return type for 'type1::operator ->' is 'type2 *' */
2157 /* (ie; not a UDT or reference to a UDT. Will produce errors if applied using infix notation) */
2158# endif
2159# elif defined(Q_CC_BOR)
2160# pragma option -w-inl
2161# pragma option -w-aus
2162# pragma warn -inl
2163# pragma warn -pia
2164# pragma warn -ccc
2165# pragma warn -rch
2166# pragma warn -sig
2167# endif
2168#endif
2169
2170class Q_CORE_EXPORT QFlag
2171{
2172 int i;
2173public:
2174 inline QFlag(int i);
2175 inline operator int() const { return i; }
2176};
2177
2178inline QFlag::QFlag(int ai) : i(ai) {}
2179
2180class Q_CORE_EXPORT QIncompatibleFlag
2181{
2182 int i;
2183public:
2184 inline explicit QIncompatibleFlag(int i);
2185 inline operator int() const { return i; }
2186};
2187
2188inline QIncompatibleFlag::QIncompatibleFlag(int ai) : i(ai) {}
2189
2190
2191#ifndef Q_NO_TYPESAFE_FLAGS
2192
2193template<typename Enum>
2194class QFlags
2195{
2196 typedef void **Zero;
2197 int i;
2198public:
2199 typedef Enum enum_type;
2200 inline QFlags(const QFlags &f) : i(f.i) {}
2201 inline QFlags(Enum f) : i(f) {}
2202 inline QFlags(Zero = 0) : i(0) {}
2203 inline QFlags(QFlag f) : i(f) {}
2204
2205 inline QFlags &operator=(const QFlags &f) { i = f.i; return *this; }
2206 inline QFlags &operator&=(int mask) { i &= mask; return *this; }
2207 inline QFlags &operator&=(uint mask) { i &= mask; return *this; }
2208 inline QFlags &operator|=(QFlags f) { i |= f.i; return *this; }
2209 inline QFlags &operator|=(Enum f) { i |= f; return *this; }
2210 inline QFlags &operator^=(QFlags f) { i ^= f.i; return *this; }
2211 inline QFlags &operator^=(Enum f) { i ^= f; return *this; }
2212
2213 inline operator int() const { return i; }
2214
2215 inline QFlags operator|(QFlags f) const { QFlags g; g.i = i | f.i; return g; }
2216 inline QFlags operator|(Enum f) const { QFlags g; g.i = i | f; return g; }
2217 inline QFlags operator^(QFlags f) const { QFlags g; g.i = i ^ f.i; return g; }
2218 inline QFlags operator^(Enum f) const { QFlags g; g.i = i ^ f; return g; }
2219 inline QFlags operator&(int mask) const { QFlags g; g.i = i & mask; return g; }
2220 inline QFlags operator&(uint mask) const { QFlags g; g.i = i & mask; return g; }
2221 inline QFlags operator&(Enum f) const { QFlags g; g.i = i & f; return g; }
2222 inline QFlags operator~() const { QFlags g; g.i = ~i; return g; }
2223
2224 inline bool operator!() const { return !i; }
2225
2226 inline bool testFlag(Enum f) const { return (i & f) == f && (f != 0 || i == int(f) ); }
2227};
2228
2229#define Q_DECLARE_FLAGS(Flags, Enum)\
2230typedef QFlags<Enum> Flags;
2231
2232#if defined Q_CC_MSVC && _MSC_VER < 1300
2233# define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags)
2234#else
2235# define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) \
2236inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) \
2237{ return QIncompatibleFlag(int(f1) | f2); }
2238#endif
2239
2240#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags) \
2241inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, Flags::enum_type f2) \
2242{ return QFlags<Flags::enum_type>(f1) | f2; } \
2243inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, QFlags<Flags::enum_type> f2) \
2244{ return f2 | f1; } Q_DECLARE_INCOMPATIBLE_FLAGS(Flags)
2245
2246
2247#else /* Q_NO_TYPESAFE_FLAGS */
2248
2249#define Q_DECLARE_FLAGS(Flags, Enum)\
2250typedef uint Flags;
2251#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
2252
2253#endif /* Q_NO_TYPESAFE_FLAGS */
2254
2255#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_RVCT)
2256/* make use of typeof-extension */
2257template <typename T>
2258class QForeachContainer {
2259public:
2260 inline QForeachContainer(const T& t) : c(t), brk(0), i(c.begin()), e(c.end()) { }
2261 const T c;
2262 int brk;
2263 typename T::const_iterator i, e;
2264};
2265
2266#define Q_FOREACH(variable, container) \
2267for (QForeachContainer<__typeof__(container)> _container_(container); \
2268 !_container_.brk && _container_.i != _container_.e; \
2269 __extension__ ({ ++_container_.brk; ++_container_.i; })) \
2270 for (variable = *_container_.i;; __extension__ ({--_container_.brk; break;}))
2271
2272#else
2273
2274struct QForeachContainerBase {};
2275
2276template <typename T>
2277class QForeachContainer : public QForeachContainerBase {
2278public:
2279 inline QForeachContainer(const T& t): c(t), brk(0), i(c.begin()), e(c.end()){};
2280 const T c;
2281 mutable int brk;
2282 mutable typename T::const_iterator i, e;
2283 inline bool condition() const { return (!brk++ && i != e); }
2284};
2285
2286template <typename T> inline T *qForeachPointer(const T &) { return 0; }
2287
2288template <typename T> inline QForeachContainer<T> qForeachContainerNew(const T& t)
2289{ return QForeachContainer<T>(t); }
2290
2291template <typename T>
2292inline const QForeachContainer<T> *qForeachContainer(const QForeachContainerBase *base, const T *)
2293{ return static_cast<const QForeachContainer<T> *>(base); }
2294
2295#if (defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) && !defined(Q_CC_INTEL)) || defined(Q_CC_MIPS)
2296/*
2297 Proper for-scoping in VC++6 and MIPSpro CC
2298*/
2299# define Q_FOREACH(variable,container) \
2300 if(0){}else \
2301 for (const QForeachContainerBase &_container_ = qForeachContainerNew(container); \
2302 qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->condition(); \
2303 ++qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i) \
2304 for (variable = *qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i; \
2305 qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk; \
2306 --qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk)
2307
2308#elif defined(Q_CC_DIAB)
2309// VxWorks DIAB generates unresolvable symbols, if container is a function call
2310# define Q_FOREACH(variable,container) \
2311 if(0){}else \
2312 for (const QForeachContainerBase &_container_ = qForeachContainerNew(container); \
2313 qForeachContainer(&_container_, (__typeof__(container) *) 0)->condition(); \
2314 ++qForeachContainer(&_container_, (__typeof__(container) *) 0)->i) \
2315 for (variable = *qForeachContainer(&_container_, (__typeof__(container) *) 0)->i; \
2316 qForeachContainer(&_container_, (__typeof__(container) *) 0)->brk; \
2317 --qForeachContainer(&_container_, (__typeof__(container) *) 0)->brk)
2318
2319#else
2320# define Q_FOREACH(variable, container) \
2321 for (const QForeachContainerBase &_container_ = qForeachContainerNew(container); \
2322 qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->condition(); \
2323 ++qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i) \
2324 for (variable = *qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i; \
2325 qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk; \
2326 --qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk)
2327#endif // MSVC6 || MIPSpro
2328
2329#endif
2330
2331#define Q_FOREVER for(;;)
2332#ifndef QT_NO_KEYWORDS
2333# ifndef foreach
2334# define foreach Q_FOREACH
2335# endif
2336# ifndef forever
2337# define forever Q_FOREVER
2338# endif
2339#endif
2340
2341#if 0
2342/* tell gcc to use its built-in methods for some common functions */
2343#if defined(QT_NO_DEBUG) && defined(Q_CC_GNU)
2344# define qMemCopy __builtin_memcpy
2345# define qMemSet __builtin_memset
2346#endif
2347#endif
2348
2349template <typename T> static inline T *qGetPtrHelper(T *ptr) { return ptr; }
2350template <typename Wrapper> static inline typename Wrapper::pointer qGetPtrHelper(const Wrapper &p) { return p.data(); }
2351
2352#define Q_DECLARE_PRIVATE(Class) \
2353 inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(qGetPtrHelper(d_ptr)); } \
2354 inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(qGetPtrHelper(d_ptr)); } \
2355 friend class Class##Private;
2356
2357#define Q_DECLARE_PRIVATE_D(Dptr, Class) \
2358 inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(Dptr); } \
2359 inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(Dptr); } \
2360 friend class Class##Private;
2361
2362#define Q_DECLARE_PUBLIC(Class) \
2363 inline Class* q_func() { return static_cast<Class *>(q_ptr); } \
2364 inline const Class* q_func() const { return static_cast<const Class *>(q_ptr); } \
2365 friend class Class;
2366
2367#define Q_D(Class) Class##Private * const d = d_func()
2368#define Q_Q(Class) Class * const q = q_func()
2369
2370#define QT_TR_NOOP(x) (x)
2371#define QT_TR_NOOP_UTF8(x) (x)
2372#define QT_TRANSLATE_NOOP(scope, x) (x)
2373#define QT_TRANSLATE_NOOP_UTF8(scope, x) (x)
2374#define QT_TRANSLATE_NOOP3(scope, x, comment) {x, comment}
2375#define QT_TRANSLATE_NOOP3_UTF8(scope, x, comment) {x, comment}
2376
2377#ifndef QT_NO_TRANSLATION // ### This should enclose the NOOPs above
2378
2379// Defined in qcoreapplication.cpp
2380// The better name qTrId() is reserved for an upcoming function which would
2381// return a much more powerful QStringFormatter instead of a QString.
2382Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1);
2383
2384#define QT_TRID_NOOP(id) id
2385
2386#endif // QT_NO_TRANSLATION
2387
2388#define QDOC_PROPERTY(text)
2389
2390/*
2391 When RTTI is not available, define this macro to force any uses of
2392 dynamic_cast to cause a compile failure.
2393*/
2394
2395#ifdef QT_NO_DYNAMIC_CAST
2396# define dynamic_cast QT_PREPEND_NAMESPACE(qt_dynamic_cast_check)
2397
2398 template<typename T, typename X>
2399 T qt_dynamic_cast_check(X, T* = 0)
2400 { return T::dynamic_cast_will_always_fail_because_rtti_is_disabled; }
2401#endif
2402
2403/*
2404 Some classes do not permit copies to be made of an object. These
2405 classes contains a private copy constructor and assignment
2406 operator to disable copying (the compiler gives an error message).
2407*/
2408#define Q_DISABLE_COPY(Class) \
2409 Class(const Class &); \
2410 Class &operator=(const Class &);
2411
2412class QByteArray;
2413Q_CORE_EXPORT QByteArray qgetenv(const char *varName);
2414Q_CORE_EXPORT bool qputenv(const char *varName, const QByteArray& value);
2415
2416inline int qIntCast(double f) { return int(f); }
2417inline int qIntCast(float f) { return int(f); }
2418
2419/*
2420 Reentrant versions of basic rand() functions for random number generation
2421*/
2422Q_CORE_EXPORT void qsrand(uint seed);
2423Q_CORE_EXPORT int qrand();
2424
2425/*
2426 Compat functions that were generated by configure
2427*/
2428#ifdef QT3_SUPPORT
2429#ifndef QT_PRODUCT_LICENSEE
2430# define QT_PRODUCT_LICENSEE QLibraryInfo::licensee()
2431#endif
2432#ifndef QT_PRODUCT_LICENSE
2433# define QT_PRODUCT_LICENSE QLibraryInfo::licensedProducts()
2434#endif
2435QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPath();
2436QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathDocs();
2437QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathHeaders();
2438QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathLibs();
2439QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathBins();
2440QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathPlugins();
2441QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathData();
2442QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathTranslations();
2443QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathSysconf();
2444#endif
2445
2446#if defined(Q_OS_SYMBIAN)
2447
2448#ifdef SYMBIAN_BUILD_GCE
2449#define Q_SYMBIAN_HAS_EXTENDED_BITMAP_TYPE
2450#define Q_SYMBIAN_WINDOW_SIZE_CACHE
2451#define QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER
2452
2453//enabling new graphics resources
2454#ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
2455# define QT_SYMBIAN_SUPPORTS_SGIMAGE
2456#endif
2457
2458#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
2459# define Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE
2460#endif
2461#endif
2462
2463
2464//Symbian does not support data imports from a DLL
2465#define Q_NO_DATA_RELOCATION
2466
2467QT_END_NAMESPACE
2468// forward declare std::exception
2469#ifdef __cplusplus
2470namespace std { class exception; }
2471#endif
2472QT_BEGIN_NAMESPACE
2473Q_CORE_EXPORT void qt_symbian_throwIfError(int error);
2474Q_CORE_EXPORT void qt_symbian_exception2LeaveL(const std::exception& ex);
2475Q_CORE_EXPORT int qt_symbian_exception2Error(const std::exception& ex);
2476
2477#define QT_TRAP_THROWING(_f) \
2478 { \
2479 TInt ____error; \
2480 TRAP(____error, _f); \
2481 qt_symbian_throwIfError(____error); \
2482 }
2483
2484#define QT_TRYCATCH_ERROR(_err, _f) \
2485 { \
2486 _err = KErrNone; \
2487 try { \
2488 _f; \
2489 } catch (const std::exception &____ex) { \
2490 _err = qt_symbian_exception2Error(____ex); \
2491 } \
2492 }
2493
2494#define QT_TRYCATCH_LEAVING(_f) \
2495 { \
2496 TInt ____err; \
2497 QT_TRYCATCH_ERROR(____err, _f) \
2498 User::LeaveIfError(____err); \
2499 }
2500#endif
2501
2502
2503/*
2504 This gives us the possibility to check which modules the user can
2505 use. These are purely compile time checks and will generate no code.
2506*/
2507
2508/* Qt modules */
2509#define QT_MODULE_CORE 0x00001
2510#define QT_MODULE_GUI 0x00002
2511#define QT_MODULE_NETWORK 0x00004
2512#define QT_MODULE_OPENGL 0x00008
2513#define QT_MODULE_SQL 0x00010
2514#define QT_MODULE_XML 0x00020
2515#define QT_MODULE_QT3SUPPORTLIGHT 0x00040
2516#define QT_MODULE_QT3SUPPORT 0x00080
2517#define QT_MODULE_SVG 0x00100
2518#define QT_MODULE_ACTIVEQT 0x00200
2519#define QT_MODULE_GRAPHICSVIEW 0x00400
2520#define QT_MODULE_SCRIPT 0x00800
2521#define QT_MODULE_XMLPATTERNS 0x01000
2522#define QT_MODULE_HELP 0x02000
2523#define QT_MODULE_TEST 0x04000
2524#define QT_MODULE_DBUS 0x08000
2525#define QT_MODULE_SCRIPTTOOLS 0x10000
2526#define QT_MODULE_OPENVG 0x20000
2527#define QT_MODULE_MULTIMEDIA 0x40000
2528#define QT_MODULE_DECLARATIVE 0x80000
2529
2530/* Qt editions */
2531#define QT_EDITION_CONSOLE (QT_MODULE_CORE \
2532 | QT_MODULE_NETWORK \
2533 | QT_MODULE_SQL \
2534 | QT_MODULE_SCRIPT \
2535 | QT_MODULE_MULTIMEDIA \
2536 | QT_MODULE_XML \
2537 | QT_MODULE_XMLPATTERNS \
2538 | QT_MODULE_TEST \
2539 | QT_MODULE_DBUS)
2540#define QT_EDITION_DESKTOPLIGHT (QT_MODULE_CORE \
2541 | QT_MODULE_GUI \
2542 | QT_MODULE_QT3SUPPORTLIGHT \
2543 | QT_MODULE_TEST \
2544 | QT_MODULE_DBUS)
2545#define QT_EDITION_OPENSOURCE (QT_MODULE_CORE \
2546 | QT_MODULE_GUI \
2547 | QT_MODULE_NETWORK \
2548 | QT_MODULE_OPENGL \
2549 | QT_MODULE_OPENVG \
2550 | QT_MODULE_SQL \
2551 | QT_MODULE_MULTIMEDIA \
2552 | QT_MODULE_XML \
2553 | QT_MODULE_XMLPATTERNS \
2554 | QT_MODULE_SCRIPT \
2555 | QT_MODULE_SCRIPTTOOLS \
2556 | QT_MODULE_QT3SUPPORTLIGHT \
2557 | QT_MODULE_QT3SUPPORT \
2558 | QT_MODULE_SVG \
2559 | QT_MODULE_DECLARATIVE \
2560 | QT_MODULE_GRAPHICSVIEW \
2561 | QT_MODULE_HELP \
2562 | QT_MODULE_TEST \
2563 | QT_MODULE_DBUS \
2564 | QT_MODULE_ACTIVEQT)
2565#define QT_EDITION_DESKTOP (QT_EDITION_OPENSOURCE)
2566#define QT_EDITION_UNIVERSAL QT_EDITION_DESKTOP
2567#define QT_EDITION_ACADEMIC QT_EDITION_DESKTOP
2568#define QT_EDITION_EDUCATIONAL QT_EDITION_DESKTOP
2569#define QT_EDITION_EVALUATION QT_EDITION_DESKTOP
2570
2571/* Determine which modules can be used */
2572#ifndef QT_EDITION
2573# ifdef QT_BUILD_QMAKE
2574# define QT_EDITION QT_EDITION_DESKTOP
2575# else
2576# error "Qt not configured correctly, please run configure"
2577# endif
2578#endif
2579
2580#define QT_LICENSED_MODULE(x) \
2581 enum QtValidLicenseFor##x##Module { Licensed##x = true };
2582
2583/* qdoc is really unhappy with the following block of preprocessor checks,
2584 making it difficult to document classes properly after this point. */
2585
2586#if (QT_EDITION & QT_MODULE_CORE)
2587QT_LICENSED_MODULE(Core)
2588#endif
2589#if (QT_EDITION & QT_MODULE_GUI)
2590QT_LICENSED_MODULE(Gui)
2591#endif
2592#if (QT_EDITION & QT_MODULE_NETWORK)
2593QT_LICENSED_MODULE(Network)
2594#endif
2595#if (QT_EDITION & QT_MODULE_OPENGL)
2596QT_LICENSED_MODULE(OpenGL)
2597#endif
2598#if (QT_EDITION & QT_MODULE_OPENVG)
2599QT_LICENSED_MODULE(OpenVG)
2600#endif
2601#if (QT_EDITION & QT_MODULE_SQL)
2602QT_LICENSED_MODULE(Sql)
2603#endif
2604#if (QT_EDITION & QT_MODULE_MULTIMEDIA)
2605QT_LICENSED_MODULE(Multimedia)
2606#endif
2607#if (QT_EDITION & QT_MODULE_XML)
2608QT_LICENSED_MODULE(Xml)
2609#endif
2610#if (QT_EDITION & QT_MODULE_XMLPATTERNS)
2611QT_LICENSED_MODULE(XmlPatterns)
2612#endif
2613#if (QT_EDITION & QT_MODULE_HELP)
2614QT_LICENSED_MODULE(Help)
2615#endif
2616#if (QT_EDITION & QT_MODULE_SCRIPT) || defined(QT_BUILD_QMAKE)
2617QT_LICENSED_MODULE(Script)
2618#endif
2619#if (QT_EDITION & QT_MODULE_SCRIPTTOOLS)
2620QT_LICENSED_MODULE(ScriptTools)
2621#endif
2622#if (QT_EDITION & QT_MODULE_QT3SUPPORTLIGHT)
2623QT_LICENSED_MODULE(Qt3SupportLight)
2624#endif
2625#if (QT_EDITION & QT_MODULE_QT3SUPPORT)
2626QT_LICENSED_MODULE(Qt3Support)
2627#endif
2628#if (QT_EDITION & QT_MODULE_SVG)
2629QT_LICENSED_MODULE(Svg)
2630#endif
2631#if (QT_EDITION & QT_MODULE_DECLARATIVE)
2632QT_LICENSED_MODULE(Declarative)
2633#endif
2634#if (QT_EDITION & QT_MODULE_ACTIVEQT)
2635QT_LICENSED_MODULE(ActiveQt)
2636#endif
2637#if (QT_EDITION & QT_MODULE_TEST)
2638QT_LICENSED_MODULE(Test)
2639#endif
2640#if (QT_EDITION & QT_MODULE_DBUS)
2641QT_LICENSED_MODULE(DBus)
2642#endif
2643
2644#define QT_MODULE(x) \
2645 typedef QtValidLicenseFor##x##Module Qt##x##Module;
2646
2647#ifdef QT_NO_CONCURRENT
2648# define QT_NO_QFUTURE
2649#endif
2650
2651// MSVC 6.0 and MSVC .NET 2002, can`t handle the map(), etc templates,
2652// but the QFuture class compiles.
2653#if (defined(Q_CC_MSVC) && _MSC_VER <= 1300)
2654# define QT_NO_CONCURRENT
2655#endif
2656
2657// gcc 3 version has problems with some of the
2658// map/filter overloads.
2659#if defined(Q_CC_GNU) && (__GNUC__ < 4)
2660# define QT_NO_CONCURRENT_MAP
2661# define QT_NO_CONCURRENT_FILTER
2662#endif
2663
2664#ifdef Q_OS_QNX
2665// QNX doesn't have SYSV style shared memory. Multiprocess QWS apps,
2666// shared fonts and QSystemSemaphore + QSharedMemory are not available
2667# define QT_NO_QWS_MULTIPROCESS
2668# define QT_NO_QWS_SHARE_FONTS
2669# define QT_NO_SYSTEMSEMAPHORE
2670# define QT_NO_SHAREDMEMORY
2671// QNX currently doesn't support forking in a thread, so disable QProcess
2672# define QT_NO_PROCESS
2673#endif
2674
2675QT_END_NAMESPACE
2676QT_END_HEADER
2677
2678#endif /* __cplusplus */
2679
2680#endif /* QGLOBAL_H */
Note: See TracBrowser for help on using the repository browser.