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

Last change on this file since 865 was 865, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.3 sources from branches/vendor/nokia/qt.

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