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

Last change on this file since 690 was 669, checked in by Dmitry A. Kuminov, 16 years ago

global: Make sure Q_*_EXPORT_INLINE functions are actually inlined in optimized (release) builds.

File size: 83.7 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.2"
48/*
49 QT_VERSION is (major << 16) + (minor << 8) + patch.
50*/
51#define QT_VERSION 0x040602
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-02-12"
58
59#define QT_PACKAGE_TAG "244b440f11a519bbd0f6a2c5cde90edb1732f2ea"
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(__SERIES60_31__) || defined(__S60_32__) || defined(__S60_50__)) && !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};
1524
1525Q_CORE_EXPORT const char *qVersion();
1526Q_CORE_EXPORT bool qSharedBuild();
1527
1528#if defined(Q_OS_MAC)
1529inline int qMacVersion() { return QSysInfo::MacintoshVersion; }
1530#endif
1531
1532#ifdef QT3_SUPPORT
1533inline QT3_SUPPORT bool qSysInfo(int *wordSize, bool *bigEndian)
1534{
1535 *wordSize = QSysInfo::WordSize;
1536 *bigEndian = (QSysInfo::ByteOrder == QSysInfo::BigEndian);
1537 return true;
1538}
1539#endif
1540
1541#if defined(Q_WS_WIN) || defined(Q_OS_CYGWIN)
1542#if defined(QT3_SUPPORT)
1543inline QT3_SUPPORT bool qt_winUnicode() { return true; }
1544inline QT3_SUPPORT int qWinVersion() { return QSysInfo::WindowsVersion; }
1545#endif
1546
1547#define QT_WA(unicode, ansi) unicode
1548#define QT_WA_INLINE(unicode, ansi) (unicode)
1549
1550#endif /* Q_WS_WIN */
1551
1552#ifndef Q_OUTOFLINE_TEMPLATE
1553# define Q_OUTOFLINE_TEMPLATE
1554#endif
1555#ifndef Q_INLINE_TEMPLATE
1556# define Q_INLINE_TEMPLATE inline
1557#endif
1558
1559#ifndef Q_TYPENAME
1560# define Q_TYPENAME typename
1561#endif
1562
1563/*
1564 Avoid "unused parameter" warnings
1565*/
1566
1567#if defined(Q_CC_INTEL) && !defined(Q_OS_WIN) || defined(Q_CC_RVCT)
1568template <typename T>
1569inline void qUnused(T &x) { (void)x; }
1570# define Q_UNUSED(x) qUnused(x);
1571#else
1572# define Q_UNUSED(x) (void)x;
1573#endif
1574
1575/*
1576 Debugging and error handling
1577*/
1578
1579/*
1580 On Symbian we do not know beforehand whether we are compiling in
1581 release or debug mode, so check the Symbian build define here,
1582 and set the QT_NO_DEBUG define appropriately.
1583*/
1584#if defined(Q_OS_SYMBIAN) && defined(NDEBUG) && !defined(QT_NO_DEBUG)
1585# define QT_NO_DEBUG
1586#endif
1587
1588#if !defined(QT_NO_DEBUG) && !defined(QT_DEBUG)
1589# define QT_DEBUG
1590#endif
1591
1592#ifndef qPrintable
1593# define qPrintable(string) (string).toLocal8Bit().constData()
1594#endif
1595
1596Q_CORE_EXPORT void qDebug(const char *, ...) /* print debug message */
1597#if defined(Q_CC_GNU) && !defined(__INSURE__)
1598 __attribute__ ((format (printf, 1, 2)))
1599#endif
1600;
1601
1602Q_CORE_EXPORT void qWarning(const char *, ...) /* print warning message */
1603#if defined(Q_CC_GNU) && !defined(__INSURE__)
1604 __attribute__ ((format (printf, 1, 2)))
1605#endif
1606;
1607
1608class QString;
1609Q_CORE_EXPORT QString qt_error_string(int errorCode = -1);
1610Q_CORE_EXPORT void qCritical(const char *, ...) /* print critical message */
1611#if defined(Q_CC_GNU) && !defined(__INSURE__)
1612 __attribute__ ((format (printf, 1, 2)))
1613#endif
1614;
1615Q_CORE_EXPORT void qFatal(const char *, ...) /* print fatal message and exit */
1616#if defined(Q_CC_GNU) && !defined(__INSURE__)
1617 __attribute__ ((format (printf, 1, 2)))
1618#endif
1619;
1620
1621#ifdef QT3_SUPPORT
1622Q_CORE_EXPORT QT3_SUPPORT void qSystemWarning(const char *msg, int code = -1);
1623#endif /* QT3_SUPPORT */
1624Q_CORE_EXPORT void qErrnoWarning(int code, const char *msg, ...);
1625Q_CORE_EXPORT void qErrnoWarning(const char *msg, ...);
1626
1627#if (defined(QT_NO_DEBUG_OUTPUT) || defined(QT_NO_TEXTSTREAM)) && !defined(QT_NO_DEBUG_STREAM)
1628#define QT_NO_DEBUG_STREAM
1629#endif
1630
1631/*
1632 Forward declarations only.
1633
1634 In order to use the qDebug() stream, you must #include<QDebug>
1635*/
1636class QDebug;
1637class QNoDebug;
1638#ifndef QT_NO_DEBUG_STREAM
1639Q_CORE_EXPORT_INLINE QDebug qDebug();
1640Q_CORE_EXPORT_INLINE QDebug qWarning();
1641Q_CORE_EXPORT_INLINE QDebug qCritical();
1642#else
1643inline QNoDebug qDebug();
1644#endif
1645
1646#define QT_NO_QDEBUG_MACRO while (false) qDebug
1647#ifdef QT_NO_DEBUG_OUTPUT
1648# define qDebug QT_NO_QDEBUG_MACRO
1649#endif
1650#define QT_NO_QWARNING_MACRO while (false) qWarning
1651#ifdef QT_NO_WARNING_OUTPUT
1652# define qWarning QT_NO_QWARNING_MACRO
1653#endif
1654
1655
1656Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int line);
1657
1658#if !defined(Q_ASSERT)
1659# ifndef QT_NO_DEBUG
1660# define Q_ASSERT(cond) ((!(cond)) ? qt_assert(#cond,__FILE__,__LINE__) : qt_noop())
1661# else
1662# define Q_ASSERT(cond) qt_noop()
1663# endif
1664#endif
1665
1666#if defined(QT_NO_DEBUG) && !defined(QT_PAINT_DEBUG)
1667#define QT_NO_PAINT_DEBUG
1668#endif
1669
1670Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char *file, int line);
1671
1672#if !defined(Q_ASSERT_X)
1673# ifndef QT_NO_DEBUG
1674# define Q_ASSERT_X(cond, where, what) ((!(cond)) ? qt_assert_x(where, what,__FILE__,__LINE__) : qt_noop())
1675# else
1676# define Q_ASSERT_X(cond, where, what) qt_noop()
1677# endif
1678#endif
1679
1680Q_CORE_EXPORT void qt_check_pointer(const char *, int);
1681
1682#ifndef QT_NO_EXCEPTIONS
1683Q_CORE_EXPORT void qBadAlloc();
1684#endif
1685
1686#ifdef QT_NO_EXCEPTIONS
1687# if defined(QT_NO_DEBUG)
1688# define Q_CHECK_PTR(p) qt_noop();
1689# else
1690# define Q_CHECK_PTR(p) do {if(!(p))qt_check_pointer(__FILE__,__LINE__);} while (0)
1691# endif
1692#else
1693# define Q_CHECK_PTR(p) do { if (!(p)) qBadAlloc(); } while (0)
1694#endif
1695
1696template <typename T>
1697inline T *q_check_ptr(T *p) { Q_CHECK_PTR(p); return p; }
1698
1699#if (defined(Q_CC_GNU) && !defined(Q_OS_SOLARIS)) || defined(Q_CC_HPACC) || defined(Q_CC_DIAB)
1700# define Q_FUNC_INFO __PRETTY_FUNCTION__
1701#elif defined(_MSC_VER)
1702 /* MSVC 2002 doesn't have __FUNCSIG__ nor can it handle QT_STRINGIFY. */
1703# if _MSC_VER <= 1300
1704# define Q_FUNC_INFO __FILE__ "(line number unavailable)"
1705# else
1706# define Q_FUNC_INFO __FUNCSIG__
1707# endif
1708#else
1709# if defined(Q_OS_SOLARIS) || defined(Q_CC_XLC) || defined(Q_OS_SYMBIAN)
1710# define Q_FUNC_INFO __FILE__ "(line number unavailable)"
1711# else
1712 /* These two macros makes it possible to turn the builtin line expander into a
1713 * string literal. */
1714# define QT_STRINGIFY2(x) #x
1715# define QT_STRINGIFY(x) QT_STRINGIFY2(x)
1716# define Q_FUNC_INFO __FILE__ ":" QT_STRINGIFY(__LINE__)
1717# endif
1718 /* The MIPSpro and RVCT compilers postpones macro expansion,
1719 and therefore macros must be in scope when being used. */
1720# if !defined(Q_CC_MIPS) && !defined(Q_CC_RVCT) && !defined(Q_CC_NOKIAX86)
1721# undef QT_STRINGIFY2
1722# undef QT_STRINGIFY
1723# endif
1724#endif
1725
1726enum QtMsgType { QtDebugMsg, QtWarningMsg, QtCriticalMsg, QtFatalMsg, QtSystemMsg = QtCriticalMsg };
1727
1728Q_CORE_EXPORT void qt_message_output(QtMsgType, const char *buf);
1729
1730typedef void (*QtMsgHandler)(QtMsgType, const char *);
1731Q_CORE_EXPORT QtMsgHandler qInstallMsgHandler(QtMsgHandler);
1732
1733#ifdef QT3_SUPPORT
1734inline QT3_SUPPORT void qSuppressObsoleteWarnings(bool = true) {}
1735inline QT3_SUPPORT void qObsolete(const char *, const char * = 0, const char * = 0) {}
1736#endif
1737
1738#if defined(QT_NO_THREAD)
1739
1740template <typename T>
1741class QGlobalStatic
1742{
1743public:
1744 T *pointer;
1745 inline QGlobalStatic(T *p) : pointer(p) { }
1746 inline ~QGlobalStatic() { pointer = 0; }
1747};
1748
1749#define Q_GLOBAL_STATIC(TYPE, NAME) \
1750 static TYPE *NAME() \
1751 { \
1752 static TYPE this_##NAME; \
1753 static QGlobalStatic<TYPE > global_##NAME(&this_##NAME); \
1754 return global_##NAME.pointer; \
1755 }
1756
1757#define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \
1758 static TYPE *NAME() \
1759 { \
1760 static TYPE this_##NAME ARGS; \
1761 static QGlobalStatic<TYPE > global_##NAME(&this_##NAME); \
1762 return global_##NAME.pointer; \
1763 }
1764
1765#define Q_GLOBAL_STATIC_WITH_INITIALIZER(TYPE, NAME, INITIALIZER) \
1766 static TYPE *NAME() \
1767 { \
1768 static TYPE this_##NAME; \
1769 static QGlobalStatic<TYPE > global_##NAME(0); \
1770 if (!global_##NAME.pointer) { \
1771 TYPE *x = global_##NAME.pointer = &this_##NAME; \
1772 INITIALIZER; \
1773 } \
1774 return global_##NAME.pointer; \
1775 }
1776
1777#else
1778
1779// forward declaration, since qatomic.h needs qglobal.h
1780template <typename T> class QBasicAtomicPointer;
1781
1782// POD for Q_GLOBAL_STATIC
1783template <typename T>
1784class QGlobalStatic
1785{
1786public:
1787 QBasicAtomicPointer<T> pointer;
1788 bool destroyed;
1789};
1790
1791// Created as a function-local static to delete a QGlobalStatic<T>
1792template <typename T>
1793class QGlobalStaticDeleter
1794{
1795public:
1796 QGlobalStatic<T> &globalStatic;
1797 QGlobalStaticDeleter(QGlobalStatic<T> &_globalStatic)
1798 : globalStatic(_globalStatic)
1799 { }
1800
1801 inline ~QGlobalStaticDeleter()
1802 {
1803 delete globalStatic.pointer;
1804 globalStatic.pointer = 0;
1805 globalStatic.destroyed = true;
1806 }
1807};
1808
1809#define Q_GLOBAL_STATIC_INIT(TYPE, NAME) \
1810 static QGlobalStatic<TYPE > this_##NAME = { Q_BASIC_ATOMIC_INITIALIZER(0), false }
1811
1812#define Q_GLOBAL_STATIC(TYPE, NAME) \
1813 Q_GLOBAL_STATIC_INIT(TYPE, NAME); \
1814 static TYPE *NAME() \
1815 { \
1816 if (!this_##NAME.pointer && !this_##NAME.destroyed) { \
1817 TYPE *x = new TYPE; \
1818 if (!this_##NAME.pointer.testAndSetOrdered(0, x)) \
1819 delete x; \
1820 else \
1821 static QGlobalStaticDeleter<TYPE > cleanup(this_##NAME); \
1822 } \
1823 return this_##NAME.pointer; \
1824 }
1825
1826#define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \
1827 Q_GLOBAL_STATIC_INIT(TYPE, NAME); \
1828 static TYPE *NAME() \
1829 { \
1830 if (!this_##NAME.pointer && !this_##NAME.destroyed) { \
1831 TYPE *x = new TYPE ARGS; \
1832 if (!this_##NAME.pointer.testAndSetOrdered(0, x)) \
1833 delete x; \
1834 else \
1835 static QGlobalStaticDeleter<TYPE > cleanup(this_##NAME); \
1836 } \
1837 return this_##NAME.pointer; \
1838 }
1839
1840#define Q_GLOBAL_STATIC_WITH_INITIALIZER(TYPE, NAME, INITIALIZER) \
1841 Q_GLOBAL_STATIC_INIT(TYPE, NAME); \
1842 static TYPE *NAME() \
1843 { \
1844 if (!this_##NAME.pointer && !this_##NAME.destroyed) { \
1845 QScopedPointer<TYPE > x(new TYPE); \
1846 INITIALIZER; \
1847 if (this_##NAME.pointer.testAndSetOrdered(0, x.data())) { \
1848 static QGlobalStaticDeleter<TYPE > cleanup(this_##NAME); \
1849 x.take(); \
1850 } \
1851 } \
1852 return this_##NAME.pointer; \
1853 }
1854
1855#endif
1856
1857class QBool
1858{
1859 bool b;
1860
1861public:
1862 inline explicit QBool(bool B) : b(B) {}
1863 inline operator const void *() const
1864 { return b ? static_cast<const void *>(this) : static_cast<const void *>(0); }
1865};
1866
1867inline bool operator==(QBool b1, bool b2) { return !b1 == !b2; }
1868inline bool operator==(bool b1, QBool b2) { return !b1 == !b2; }
1869inline bool operator==(QBool b1, QBool b2) { return !b1 == !b2; }
1870inline bool operator!=(QBool b1, bool b2) { return !b1 != !b2; }
1871inline bool operator!=(bool b1, QBool b2) { return !b1 != !b2; }
1872inline bool operator!=(QBool b1, QBool b2) { return !b1 != !b2; }
1873
1874static inline bool qFuzzyCompare(double p1, double p2)
1875{
1876 return (qAbs(p1 - p2) <= 0.000000000001 * qMin(qAbs(p1), qAbs(p2)));
1877}
1878
1879static inline bool qFuzzyCompare(float p1, float p2)
1880{
1881 return (qAbs(p1 - p2) <= 0.00001f * qMin(qAbs(p1), qAbs(p2)));
1882}
1883
1884/*!
1885 \internal
1886*/
1887static inline bool qFuzzyIsNull(double d)
1888{
1889 return qAbs(d) <= 0.000000000001;
1890}
1891
1892/*!
1893 \internal
1894*/
1895static inline bool qFuzzyIsNull(float f)
1896{
1897 return qAbs(f) <= 0.00001f;
1898}
1899
1900/*
1901 This function tests a double for a null value. It doesn't
1902 check whether the actual value is 0 or close to 0, but whether
1903 it is binary 0.
1904*/
1905static inline bool qIsNull(double d)
1906{
1907 union U {
1908 double d;
1909 quint64 u;
1910 };
1911 U val;
1912 val.d = d;
1913 return val.u == quint64(0);
1914}
1915
1916/*
1917 This function tests a float for a null value. It doesn't
1918 check whether the actual value is 0 or close to 0, but whether
1919 it is binary 0.
1920*/
1921static inline bool qIsNull(float f)
1922{
1923 union U {
1924 float f;
1925 quint32 u;
1926 };
1927 U val;
1928 val.f = f;
1929 return val.u == 0u;
1930}
1931
1932/*
1933 Compilers which follow outdated template instantiation rules
1934 require a class to have a comparison operator to exist when
1935 a QList of this type is instantiated. It's not actually
1936 used in the list, though. Hence the dummy implementation.
1937 Just in case other code relies on it we better trigger a warning
1938 mandating a real implementation.
1939*/
1940
1941#ifdef Q_FULL_TEMPLATE_INSTANTIATION
1942# define Q_DUMMY_COMPARISON_OPERATOR(C) \
1943 bool operator==(const C&) const { \
1944 qWarning(#C"::operator==(const "#C"&) was called"); \
1945 return false; \
1946 }
1947#else
1948# define Q_DUMMY_COMPARISON_OPERATOR(C)
1949#endif
1950
1951
1952/*
1953 QTypeInfo - type trait functionality
1954 qIsDetached - data sharing functionality
1955*/
1956
1957#ifndef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION
1958
1959/*
1960 The catch-all template.
1961*/
1962
1963template <typename T> inline bool qIsDetached(T &) { return true; }
1964
1965template <typename T>
1966class QTypeInfo
1967{
1968public:
1969 enum {
1970 isPointer = false,
1971 isComplex = true,
1972 isStatic = true,
1973 isLarge = (sizeof(T)>sizeof(void*)),
1974 isDummy = false
1975 };
1976};
1977
1978template <typename T>
1979class QTypeInfo<T*>
1980{
1981public:
1982 enum {
1983 isPointer = true,
1984 isComplex = false,
1985 isStatic = false,
1986 isLarge = false,
1987 isDummy = false
1988 };
1989};
1990
1991#else
1992
1993template <typename T> char QTypeInfoHelper(T*(*)());
1994void* QTypeInfoHelper(...);
1995
1996template <typename T> inline bool qIsDetached(T &) { return true; }
1997
1998template <typename T>
1999class QTypeInfo
2000{
2001public:
2002 enum {
2003 isPointer = (1 == sizeof(QTypeInfoHelper((T(*)())0))),
2004 isComplex = !isPointer,
2005 isStatic = !isPointer,
2006 isLarge = (sizeof(T)>sizeof(void*)),
2007 isDummy = false
2008 };
2009};
2010
2011#endif /* QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION */
2012
2013/*
2014 Specialize a specific type with:
2015
2016 Q_DECLARE_TYPEINFO(type, flags);
2017
2018 where 'type' is the name of the type to specialize and 'flags' is
2019 logically-OR'ed combination of the flags below.
2020*/
2021enum { /* TYPEINFO flags */
2022 Q_COMPLEX_TYPE = 0,
2023 Q_PRIMITIVE_TYPE = 0x1,
2024 Q_STATIC_TYPE = 0,
2025 Q_MOVABLE_TYPE = 0x2,
2026 Q_DUMMY_TYPE = 0x4
2027};
2028
2029#define Q_DECLARE_TYPEINFO(TYPE, FLAGS) \
2030template <> \
2031class QTypeInfo<TYPE > \
2032{ \
2033public: \
2034 enum { \
2035 isComplex = (((FLAGS) & Q_PRIMITIVE_TYPE) == 0), \
2036 isStatic = (((FLAGS) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), \
2037 isLarge = (sizeof(TYPE)>sizeof(void*)), \
2038 isPointer = false, \
2039 isDummy = (((FLAGS) & Q_DUMMY_TYPE) != 0) \
2040 }; \
2041 static inline const char *name() { return #TYPE; } \
2042}
2043
2044template <typename T>
2045inline void qSwap(T &value1, T &value2)
2046{
2047 const T t = value1;
2048 value1 = value2;
2049 value2 = t;
2050}
2051
2052/*
2053 Specialize a shared type with:
2054
2055 Q_DECLARE_SHARED(type);
2056
2057 where 'type' is the name of the type to specialize. NOTE: shared
2058 types must declare a 'bool isDetached(void) const;' member for this
2059 to work.
2060*/
2061#define Q_DECLARE_SHARED(TYPE) \
2062template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \
2063template <> inline void qSwap<TYPE>(TYPE &value1, TYPE &value2) \
2064{ \
2065 qSwap(value1.data_ptr(), value2.data_ptr()); \
2066}
2067
2068/*
2069 QTypeInfo primitive specializations
2070*/
2071Q_DECLARE_TYPEINFO(bool, Q_PRIMITIVE_TYPE);
2072Q_DECLARE_TYPEINFO(char, Q_PRIMITIVE_TYPE);
2073Q_DECLARE_TYPEINFO(signed char, Q_PRIMITIVE_TYPE);
2074Q_DECLARE_TYPEINFO(uchar, Q_PRIMITIVE_TYPE);
2075Q_DECLARE_TYPEINFO(short, Q_PRIMITIVE_TYPE);
2076Q_DECLARE_TYPEINFO(ushort, Q_PRIMITIVE_TYPE);
2077Q_DECLARE_TYPEINFO(int, Q_PRIMITIVE_TYPE);
2078Q_DECLARE_TYPEINFO(uint, Q_PRIMITIVE_TYPE);
2079Q_DECLARE_TYPEINFO(long, Q_PRIMITIVE_TYPE);
2080Q_DECLARE_TYPEINFO(ulong, Q_PRIMITIVE_TYPE);
2081Q_DECLARE_TYPEINFO(qint64, Q_PRIMITIVE_TYPE);
2082Q_DECLARE_TYPEINFO(quint64, Q_PRIMITIVE_TYPE);
2083Q_DECLARE_TYPEINFO(float, Q_PRIMITIVE_TYPE);
2084Q_DECLARE_TYPEINFO(double, Q_PRIMITIVE_TYPE);
2085#ifndef Q_OS_DARWIN
2086Q_DECLARE_TYPEINFO(long double, Q_PRIMITIVE_TYPE);
2087#endif
2088
2089/*
2090 These functions make it possible to use standard C++ functions with
2091 a similar name from Qt header files (especially template classes).
2092*/
2093Q_CORE_EXPORT void *qMalloc(size_t size);
2094Q_CORE_EXPORT void qFree(void *ptr);
2095Q_CORE_EXPORT void *qRealloc(void *ptr, size_t size);
2096Q_CORE_EXPORT void *qMallocAligned(size_t size, size_t alignment);
2097Q_CORE_EXPORT void *qReallocAligned(void *ptr, size_t size, size_t oldsize, size_t alignment);
2098Q_CORE_EXPORT void qFreeAligned(void *ptr);
2099Q_CORE_EXPORT void *qMemCopy(void *dest, const void *src, size_t n);
2100Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n);
2101
2102
2103/*
2104 Avoid some particularly useless warnings from some stupid compilers.
2105 To get ALL C++ compiler warnings, define QT_CC_WARNINGS or comment out
2106 the line "#define QT_NO_WARNINGS".
2107*/
2108#if !defined(QT_CC_WARNINGS)
2109# define QT_NO_WARNINGS
2110#endif
2111#if defined(QT_NO_WARNINGS)
2112# if defined(Q_CC_MSVC)
2113# pragma warning(disable: 4251) /* class 'A' needs to have dll interface for to be used by clients of class 'B'. */
2114# pragma warning(disable: 4244) /* 'conversion' conversion from 'type1' to 'type2', possible loss of data */
2115# pragma warning(disable: 4275) /* non - DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' */
2116# pragma warning(disable: 4514) /* unreferenced inline/local function has been removed */
2117# pragma warning(disable: 4800) /* 'type' : forcing value to bool 'true' or 'false' (performance warning) */
2118# pragma warning(disable: 4097) /* typedef-name 'identifier1' used as synonym for class-name 'identifier2' */
2119# pragma warning(disable: 4706) /* assignment within conditional expression */
2120# pragma warning(disable: 4786) /* truncating debug info after 255 characters */
2121# pragma warning(disable: 4660) /* template-class specialization 'identifier' is already instantiated */
2122# pragma warning(disable: 4355) /* 'this' : used in base member initializer list */
2123# pragma warning(disable: 4231) /* nonstandard extension used : 'extern' before template explicit instantiation */
2124# pragma warning(disable: 4710) /* function not inlined */
2125# pragma warning(disable: 4530) /* C++ exception handler used, but unwind semantics are not enabled. Specify -GX */
2126# if _MSC_VER < 1300
2127# pragma warning(disable: 4284) /* return type for 'type1::operator ->' is 'type2 *' */
2128 /* (ie; not a UDT or reference to a UDT. Will produce errors if applied using infix notation) */
2129# endif
2130# elif defined(Q_CC_BOR)
2131# pragma option -w-inl
2132# pragma option -w-aus
2133# pragma warn -inl
2134# pragma warn -pia
2135# pragma warn -ccc
2136# pragma warn -rch
2137# pragma warn -sig
2138# endif
2139#endif
2140
2141class Q_CORE_EXPORT QFlag
2142{
2143 int i;
2144public:
2145 inline QFlag(int i);
2146 inline operator int() const { return i; }
2147};
2148
2149inline QFlag::QFlag(int ai) : i(ai) {}
2150
2151class Q_CORE_EXPORT QIncompatibleFlag
2152{
2153 int i;
2154public:
2155 inline explicit QIncompatibleFlag(int i);
2156 inline operator int() const { return i; }
2157};
2158
2159inline QIncompatibleFlag::QIncompatibleFlag(int ai) : i(ai) {}
2160
2161
2162#ifndef Q_NO_TYPESAFE_FLAGS
2163
2164template<typename Enum>
2165class QFlags
2166{
2167 typedef void **Zero;
2168 int i;
2169public:
2170 typedef Enum enum_type;
2171 inline QFlags(const QFlags &f) : i(f.i) {}
2172 inline QFlags(Enum f) : i(f) {}
2173 inline QFlags(Zero = 0) : i(0) {}
2174 inline QFlags(QFlag f) : i(f) {}
2175
2176 inline QFlags &operator=(const QFlags &f) { i = f.i; return *this; }
2177 inline QFlags &operator&=(int mask) { i &= mask; return *this; }
2178 inline QFlags &operator&=(uint mask) { i &= mask; return *this; }
2179 inline QFlags &operator|=(QFlags f) { i |= f.i; return *this; }
2180 inline QFlags &operator|=(Enum f) { i |= f; return *this; }
2181 inline QFlags &operator^=(QFlags f) { i ^= f.i; return *this; }
2182 inline QFlags &operator^=(Enum f) { i ^= f; return *this; }
2183
2184 inline operator int() const { return i; }
2185
2186 inline QFlags operator|(QFlags f) const { QFlags g; g.i = i | f.i; return g; }
2187 inline QFlags operator|(Enum f) const { QFlags g; g.i = i | f; return g; }
2188 inline QFlags operator^(QFlags f) const { QFlags g; g.i = i ^ f.i; return g; }
2189 inline QFlags operator^(Enum f) const { QFlags g; g.i = i ^ f; return g; }
2190 inline QFlags operator&(int mask) const { QFlags g; g.i = i & mask; return g; }
2191 inline QFlags operator&(uint mask) const { QFlags g; g.i = i & mask; return g; }
2192 inline QFlags operator&(Enum f) const { QFlags g; g.i = i & f; return g; }
2193 inline QFlags operator~() const { QFlags g; g.i = ~i; return g; }
2194
2195 inline bool operator!() const { return !i; }
2196
2197 inline bool testFlag(Enum f) const { return (i & f) == f && (f != 0 || i == int(f) ); }
2198};
2199
2200#define Q_DECLARE_FLAGS(Flags, Enum)\
2201typedef QFlags<Enum> Flags;
2202
2203#if defined Q_CC_MSVC && _MSC_VER < 1300
2204# define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags)
2205#else
2206# define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) \
2207inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) \
2208{ return QIncompatibleFlag(int(f1) | f2); }
2209#endif
2210
2211#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags) \
2212inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, Flags::enum_type f2) \
2213{ return QFlags<Flags::enum_type>(f1) | f2; } \
2214inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, QFlags<Flags::enum_type> f2) \
2215{ return f2 | f1; } Q_DECLARE_INCOMPATIBLE_FLAGS(Flags)
2216
2217
2218#else /* Q_NO_TYPESAFE_FLAGS */
2219
2220#define Q_DECLARE_FLAGS(Flags, Enum)\
2221typedef uint Flags;
2222#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
2223
2224#endif /* Q_NO_TYPESAFE_FLAGS */
2225
2226#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_RVCT)
2227/* make use of typeof-extension */
2228template <typename T>
2229class QForeachContainer {
2230public:
2231 inline QForeachContainer(const T& t) : c(t), brk(0), i(c.begin()), e(c.end()) { }
2232 const T c;
2233 int brk;
2234 typename T::const_iterator i, e;
2235};
2236
2237#define Q_FOREACH(variable, container) \
2238for (QForeachContainer<__typeof__(container)> _container_(container); \
2239 !_container_.brk && _container_.i != _container_.e; \
2240 __extension__ ({ ++_container_.brk; ++_container_.i; })) \
2241 for (variable = *_container_.i;; __extension__ ({--_container_.brk; break;}))
2242
2243#else
2244
2245struct QForeachContainerBase {};
2246
2247template <typename T>
2248class QForeachContainer : public QForeachContainerBase {
2249public:
2250 inline QForeachContainer(const T& t): c(t), brk(0), i(c.begin()), e(c.end()){};
2251 const T c;
2252 mutable int brk;
2253 mutable typename T::const_iterator i, e;
2254 inline bool condition() const { return (!brk++ && i != e); }
2255};
2256
2257template <typename T> inline T *qForeachPointer(const T &) { return 0; }
2258
2259template <typename T> inline QForeachContainer<T> qForeachContainerNew(const T& t)
2260{ return QForeachContainer<T>(t); }
2261
2262template <typename T>
2263inline const QForeachContainer<T> *qForeachContainer(const QForeachContainerBase *base, const T *)
2264{ return static_cast<const QForeachContainer<T> *>(base); }
2265
2266#if (defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) && !defined(Q_CC_INTEL)) || defined(Q_CC_MIPS)
2267/*
2268 Proper for-scoping in VC++6 and MIPSpro CC
2269*/
2270# define Q_FOREACH(variable,container) \
2271 if(0){}else \
2272 for (const QForeachContainerBase &_container_ = qForeachContainerNew(container); \
2273 qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->condition(); \
2274 ++qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i) \
2275 for (variable = *qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i; \
2276 qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk; \
2277 --qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk)
2278
2279#elif defined(Q_CC_DIAB)
2280// VxWorks DIAB generates unresolvable symbols, if container is a function call
2281# define Q_FOREACH(variable,container) \
2282 if(0){}else \
2283 for (const QForeachContainerBase &_container_ = qForeachContainerNew(container); \
2284 qForeachContainer(&_container_, (__typeof__(container) *) 0)->condition(); \
2285 ++qForeachContainer(&_container_, (__typeof__(container) *) 0)->i) \
2286 for (variable = *qForeachContainer(&_container_, (__typeof__(container) *) 0)->i; \
2287 qForeachContainer(&_container_, (__typeof__(container) *) 0)->brk; \
2288 --qForeachContainer(&_container_, (__typeof__(container) *) 0)->brk)
2289
2290#else
2291# define Q_FOREACH(variable, container) \
2292 for (const QForeachContainerBase &_container_ = qForeachContainerNew(container); \
2293 qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->condition(); \
2294 ++qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i) \
2295 for (variable = *qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i; \
2296 qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk; \
2297 --qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk)
2298#endif // MSVC6 || MIPSpro
2299
2300#endif
2301
2302#define Q_FOREVER for(;;)
2303#ifndef QT_NO_KEYWORDS
2304# ifndef foreach
2305# define foreach Q_FOREACH
2306# endif
2307# ifndef forever
2308# define forever Q_FOREVER
2309# endif
2310#endif
2311
2312#if 0
2313/* tell gcc to use its built-in methods for some common functions */
2314#if defined(QT_NO_DEBUG) && defined(Q_CC_GNU)
2315# define qMemCopy __builtin_memcpy
2316# define qMemSet __builtin_memset
2317#endif
2318#endif
2319
2320template <typename T> static inline T *qGetPtrHelper(T *ptr) { return ptr; }
2321template <typename Wrapper> static inline typename Wrapper::pointer qGetPtrHelper(const Wrapper &p) { return p.data(); }
2322
2323#define Q_DECLARE_PRIVATE(Class) \
2324 inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(qGetPtrHelper(d_ptr)); } \
2325 inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(qGetPtrHelper(d_ptr)); } \
2326 friend class Class##Private;
2327
2328#define Q_DECLARE_PRIVATE_D(Dptr, Class) \
2329 inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(Dptr); } \
2330 inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(Dptr); } \
2331 friend class Class##Private;
2332
2333#define Q_DECLARE_PUBLIC(Class) \
2334 inline Class* q_func() { return static_cast<Class *>(q_ptr); } \
2335 inline const Class* q_func() const { return static_cast<const Class *>(q_ptr); } \
2336 friend class Class;
2337
2338#define Q_D(Class) Class##Private * const d = d_func()
2339#define Q_Q(Class) Class * const q = q_func()
2340
2341#define QT_TR_NOOP(x) (x)
2342#define QT_TR_NOOP_UTF8(x) (x)
2343#define QT_TRANSLATE_NOOP(scope, x) (x)
2344#define QT_TRANSLATE_NOOP_UTF8(scope, x) (x)
2345#define QT_TRANSLATE_NOOP3(scope, x, comment) {x, comment}
2346#define QT_TRANSLATE_NOOP3_UTF8(scope, x, comment) {x, comment}
2347
2348#ifndef QT_NO_TRANSLATION // ### This should enclose the NOOPs above
2349
2350// Defined in qcoreapplication.cpp
2351// The better name qTrId() is reserved for an upcoming function which would
2352// return a much more powerful QStringFormatter instead of a QString.
2353Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1);
2354
2355#define QT_TRID_NOOP(id) id
2356
2357#endif // QT_NO_TRANSLATION
2358
2359#define QDOC_PROPERTY(text)
2360
2361/*
2362 When RTTI is not available, define this macro to force any uses of
2363 dynamic_cast to cause a compile failure.
2364*/
2365
2366#ifdef QT_NO_DYNAMIC_CAST
2367# define dynamic_cast QT_PREPEND_NAMESPACE(qt_dynamic_cast_check)
2368
2369 template<typename T, typename X>
2370 T qt_dynamic_cast_check(X, T* = 0)
2371 { return T::dynamic_cast_will_always_fail_because_rtti_is_disabled; }
2372#endif
2373
2374/*
2375 Some classes do not permit copies to be made of an object. These
2376 classes contains a private copy constructor and assignment
2377 operator to disable copying (the compiler gives an error message).
2378*/
2379#define Q_DISABLE_COPY(Class) \
2380 Class(const Class &); \
2381 Class &operator=(const Class &);
2382
2383class QByteArray;
2384Q_CORE_EXPORT QByteArray qgetenv(const char *varName);
2385Q_CORE_EXPORT bool qputenv(const char *varName, const QByteArray& value);
2386
2387inline int qIntCast(double f) { return int(f); }
2388inline int qIntCast(float f) { return int(f); }
2389
2390/*
2391 Reentrant versions of basic rand() functions for random number generation
2392*/
2393Q_CORE_EXPORT void qsrand(uint seed);
2394Q_CORE_EXPORT int qrand();
2395
2396/*
2397 Compat functions that were generated by configure
2398*/
2399#ifdef QT3_SUPPORT
2400#ifndef QT_PRODUCT_LICENSEE
2401# define QT_PRODUCT_LICENSEE QLibraryInfo::licensee()
2402#endif
2403#ifndef QT_PRODUCT_LICENSE
2404# define QT_PRODUCT_LICENSE QLibraryInfo::licensedProducts()
2405#endif
2406QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPath();
2407QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathDocs();
2408QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathHeaders();
2409QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathLibs();
2410QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathBins();
2411QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathPlugins();
2412QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathData();
2413QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathTranslations();
2414QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathSysconf();
2415#endif
2416
2417#if defined(Q_OS_SYMBIAN)
2418
2419#ifdef SYMBIAN_GRAPHICS_USE_GCE
2420//RWsPointerCursor is fixed, so don't use low performance sprites
2421#define Q_SYMBIAN_FIXED_POINTER_CURSORS
2422#define Q_SYMBIAN_HAS_EXTENDED_BITMAP_TYPE
2423//enabling new graphics resources
2424#define QT_SYMBIAN_SUPPORTS_SGIMAGE
2425#define QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER
2426
2427#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
2428#define Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE
2429#endif
2430#endif
2431
2432
2433//Symbian does not support data imports from a DLL
2434#define Q_NO_DATA_RELOCATION
2435
2436QT_END_NAMESPACE
2437// forward declare std::exception
2438#ifdef __cplusplus
2439namespace std { class exception; }
2440#endif
2441QT_BEGIN_NAMESPACE
2442Q_CORE_EXPORT void qt_symbian_throwIfError(int error);
2443Q_CORE_EXPORT void qt_symbian_exception2LeaveL(const std::exception& ex);
2444Q_CORE_EXPORT int qt_symbian_exception2Error(const std::exception& ex);
2445
2446#define QT_TRAP_THROWING(_f) \
2447 { \
2448 TInt ____error; \
2449 TRAP(____error, _f); \
2450 qt_symbian_throwIfError(____error); \
2451 }
2452
2453#define QT_TRYCATCH_ERROR(_err, _f) \
2454 { \
2455 _err = KErrNone; \
2456 try { \
2457 _f; \
2458 } catch (const std::exception &____ex) { \
2459 _err = qt_symbian_exception2Error(____ex); \
2460 } \
2461 }
2462
2463#define QT_TRYCATCH_LEAVING(_f) \
2464 { \
2465 TInt ____err; \
2466 QT_TRYCATCH_ERROR(____err, _f) \
2467 User::LeaveIfError(____err); \
2468 }
2469#endif
2470
2471
2472/*
2473 This gives us the possibility to check which modules the user can
2474 use. These are purely compile time checks and will generate no code.
2475*/
2476
2477/* Qt modules */
2478#define QT_MODULE_CORE 0x00001
2479#define QT_MODULE_GUI 0x00002
2480#define QT_MODULE_NETWORK 0x00004
2481#define QT_MODULE_OPENGL 0x00008
2482#define QT_MODULE_SQL 0x00010
2483#define QT_MODULE_XML 0x00020
2484#define QT_MODULE_QT3SUPPORTLIGHT 0x00040
2485#define QT_MODULE_QT3SUPPORT 0x00080
2486#define QT_MODULE_SVG 0x00100
2487#define QT_MODULE_ACTIVEQT 0x00200
2488#define QT_MODULE_GRAPHICSVIEW 0x00400
2489#define QT_MODULE_SCRIPT 0x00800
2490#define QT_MODULE_XMLPATTERNS 0x01000
2491#define QT_MODULE_HELP 0x02000
2492#define QT_MODULE_TEST 0x04000
2493#define QT_MODULE_DBUS 0x08000
2494#define QT_MODULE_SCRIPTTOOLS 0x10000
2495#define QT_MODULE_OPENVG 0x20000
2496#define QT_MODULE_MULTIMEDIA 0x40000
2497#define QT_MODULE_DECLARATIVE 0x80000
2498
2499/* Qt editions */
2500#define QT_EDITION_CONSOLE (QT_MODULE_CORE \
2501 | QT_MODULE_NETWORK \
2502 | QT_MODULE_SQL \
2503 | QT_MODULE_SCRIPT \
2504 | QT_MODULE_MULTIMEDIA \
2505 | QT_MODULE_XML \
2506 | QT_MODULE_XMLPATTERNS \
2507 | QT_MODULE_TEST \
2508 | QT_MODULE_DBUS)
2509#define QT_EDITION_DESKTOPLIGHT (QT_MODULE_CORE \
2510 | QT_MODULE_GUI \
2511 | QT_MODULE_QT3SUPPORTLIGHT \
2512 | QT_MODULE_TEST \
2513 | QT_MODULE_DBUS)
2514#define QT_EDITION_OPENSOURCE (QT_MODULE_CORE \
2515 | QT_MODULE_GUI \
2516 | QT_MODULE_NETWORK \
2517 | QT_MODULE_OPENGL \
2518 | QT_MODULE_OPENVG \
2519 | QT_MODULE_SQL \
2520 | QT_MODULE_MULTIMEDIA \
2521 | QT_MODULE_XML \
2522 | QT_MODULE_XMLPATTERNS \
2523 | QT_MODULE_SCRIPT \
2524 | QT_MODULE_SCRIPTTOOLS \
2525 | QT_MODULE_QT3SUPPORTLIGHT \
2526 | QT_MODULE_QT3SUPPORT \
2527 | QT_MODULE_SVG \
2528 | QT_MODULE_DECLARATIVE \
2529 | QT_MODULE_GRAPHICSVIEW \
2530 | QT_MODULE_HELP \
2531 | QT_MODULE_TEST \
2532 | QT_MODULE_DBUS \
2533 | QT_MODULE_ACTIVEQT)
2534#define QT_EDITION_DESKTOP (QT_EDITION_OPENSOURCE)
2535#define QT_EDITION_UNIVERSAL QT_EDITION_DESKTOP
2536#define QT_EDITION_ACADEMIC QT_EDITION_DESKTOP
2537#define QT_EDITION_EDUCATIONAL QT_EDITION_DESKTOP
2538#define QT_EDITION_EVALUATION QT_EDITION_DESKTOP
2539
2540/* Determine which modules can be used */
2541#ifndef QT_EDITION
2542# ifdef QT_BUILD_QMAKE
2543# define QT_EDITION QT_EDITION_DESKTOP
2544# else
2545# error "Qt not configured correctly, please run configure"
2546# endif
2547#endif
2548
2549#define QT_LICENSED_MODULE(x) \
2550 enum QtValidLicenseFor##x##Module { Licensed##x = true };
2551
2552/* qdoc is really unhappy with the following block of preprocessor checks,
2553 making it difficult to document classes properly after this point. */
2554
2555#if (QT_EDITION & QT_MODULE_CORE)
2556QT_LICENSED_MODULE(Core)
2557#endif
2558#if (QT_EDITION & QT_MODULE_GUI)
2559QT_LICENSED_MODULE(Gui)
2560#endif
2561#if (QT_EDITION & QT_MODULE_NETWORK)
2562QT_LICENSED_MODULE(Network)
2563#endif
2564#if (QT_EDITION & QT_MODULE_OPENGL)
2565QT_LICENSED_MODULE(OpenGL)
2566#endif
2567#if (QT_EDITION & QT_MODULE_OPENVG)
2568QT_LICENSED_MODULE(OpenVG)
2569#endif
2570#if (QT_EDITION & QT_MODULE_SQL)
2571QT_LICENSED_MODULE(Sql)
2572#endif
2573#if (QT_EDITION & QT_MODULE_MULTIMEDIA)
2574QT_LICENSED_MODULE(Multimedia)
2575#endif
2576#if (QT_EDITION & QT_MODULE_XML)
2577QT_LICENSED_MODULE(Xml)
2578#endif
2579#if (QT_EDITION & QT_MODULE_XMLPATTERNS)
2580QT_LICENSED_MODULE(XmlPatterns)
2581#endif
2582#if (QT_EDITION & QT_MODULE_HELP)
2583QT_LICENSED_MODULE(Help)
2584#endif
2585#if (QT_EDITION & QT_MODULE_SCRIPT) || defined(QT_BUILD_QMAKE)
2586QT_LICENSED_MODULE(Script)
2587#endif
2588#if (QT_EDITION & QT_MODULE_SCRIPTTOOLS)
2589QT_LICENSED_MODULE(ScriptTools)
2590#endif
2591#if (QT_EDITION & QT_MODULE_QT3SUPPORTLIGHT)
2592QT_LICENSED_MODULE(Qt3SupportLight)
2593#endif
2594#if (QT_EDITION & QT_MODULE_QT3SUPPORT)
2595QT_LICENSED_MODULE(Qt3Support)
2596#endif
2597#if (QT_EDITION & QT_MODULE_SVG)
2598QT_LICENSED_MODULE(Svg)
2599#endif
2600#if (QT_EDITION & QT_MODULE_DECLARATIVE)
2601QT_LICENSED_MODULE(Declarative)
2602#endif
2603#if (QT_EDITION & QT_MODULE_ACTIVEQT)
2604QT_LICENSED_MODULE(ActiveQt)
2605#endif
2606#if (QT_EDITION & QT_MODULE_TEST)
2607QT_LICENSED_MODULE(Test)
2608#endif
2609#if (QT_EDITION & QT_MODULE_DBUS)
2610QT_LICENSED_MODULE(DBus)
2611#endif
2612
2613#define QT_MODULE(x) \
2614 typedef QtValidLicenseFor##x##Module Qt##x##Module;
2615
2616#ifdef QT_NO_CONCURRENT
2617# define QT_NO_QFUTURE
2618#endif
2619
2620// MSVC 6.0 and MSVC .NET 2002, can`t handle the map(), etc templates,
2621// but the QFuture class compiles.
2622#if (defined(Q_CC_MSVC) && _MSC_VER <= 1300)
2623# define QT_NO_CONCURRENT
2624#endif
2625
2626// gcc 3 version has problems with some of the
2627// map/filter overloads.
2628#if defined(Q_CC_GNU) && (__GNUC__ < 4)
2629# define QT_NO_CONCURRENT_MAP
2630# define QT_NO_CONCURRENT_FILTER
2631#endif
2632
2633#ifdef Q_OS_QNX
2634// QNX doesn't have SYSV style shared memory. Multiprocess QWS apps,
2635// shared fonts and QSystemSemaphore + QSharedMemory are not available
2636# define QT_NO_QWS_MULTIPROCESS
2637# define QT_NO_QWS_SHARE_FONTS
2638# define QT_NO_SYSTEMSEMAPHORE
2639# define QT_NO_SHAREDMEMORY
2640// QNX currently doesn't support forking in a thread, so disable QProcess
2641# define QT_NO_PROCESS
2642#endif
2643
2644QT_END_NAMESPACE
2645QT_END_HEADER
2646
2647#endif /* __cplusplus */
2648
2649#endif /* QGLOBAL_H */
Note: See TracBrowser for help on using the repository browser.