author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Thu, 02 Sep 2010 21:20:32 +0300 | |
changeset 34 | a33bf25e6f72 |
parent 33 | 3e2da88830cd |
child 37 | 758a864f9613 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtCore module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
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 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include "qplatformdefs.h" |
|
43 |
#include "qstring.h" |
|
44 |
#include "qvector.h" |
|
45 |
#include "qlist.h" |
|
46 |
#include "qthreadstorage.h" |
|
47 |
#include "qdir.h" |
|
48 |
#include "qstringlist.h" |
|
49 |
#include "qdatetime.h" |
|
50 |
||
51 |
#ifndef QT_NO_QOBJECT |
|
52 |
#include <private/qthread_p.h> |
|
53 |
#endif |
|
54 |
||
55 |
#include <stdio.h> |
|
56 |
#include <stdlib.h> |
|
57 |
#include <limits.h> |
|
58 |
#include <stdarg.h> |
|
59 |
#include <string.h> |
|
60 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
61 |
#ifndef QT_NO_EXCEPTIONS |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
62 |
# include <string> |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
63 |
# include <exception> |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
64 |
#endif |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
65 |
|
0 | 66 |
#if !defined(Q_OS_WINCE) |
67 |
# include <errno.h> |
|
68 |
# if defined(Q_CC_MSVC) |
|
69 |
# include <crtdbg.h> |
|
70 |
# endif |
|
71 |
#endif |
|
72 |
||
73 |
#if defined(Q_OS_VXWORKS) |
|
74 |
# include <envLib.h> |
|
75 |
#endif |
|
76 |
||
77 |
#if defined(Q_CC_MWERKS) && defined(Q_OS_MACX) |
|
78 |
#include <CoreServices/CoreServices.h> |
|
79 |
#endif |
|
80 |
||
81 |
#if defined(Q_OS_SYMBIAN) |
|
82 |
#include <e32def.h> |
|
83 |
#include <e32debug.h> |
|
84 |
#include <flogger.h> |
|
85 |
#include <f32file.h> |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
86 |
#include <e32math.h> |
0 | 87 |
# include "private/qcore_symbian_p.h" |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
88 |
|
0 | 89 |
_LIT(qt_S60Filter, "Series60v?.*.sis"); |
90 |
_LIT(qt_S60SystemInstallDir, "z:\\system\\install\\"); |
|
91 |
#endif |
|
92 |
||
93 |
QT_BEGIN_NAMESPACE |
|
94 |
||
95 |
||
96 |
/*! |
|
97 |
\class QFlag |
|
98 |
\brief The QFlag class is a helper data type for QFlags. |
|
99 |
||
100 |
It is equivalent to a plain \c int, except with respect to |
|
101 |
function overloading and type conversions. You should never need |
|
102 |
to use this class in your applications. |
|
103 |
||
104 |
\sa QFlags |
|
105 |
*/ |
|
106 |
||
107 |
/*! |
|
108 |
\fn QFlag::QFlag(int value) |
|
109 |
||
110 |
Constructs a QFlag object that stores the given \a value. |
|
111 |
*/ |
|
112 |
||
113 |
/*! |
|
114 |
\fn QFlag::operator int() const |
|
115 |
||
116 |
Returns the value stored by the QFlag object. |
|
117 |
*/ |
|
118 |
||
119 |
/*! |
|
120 |
\class QFlags |
|
121 |
\brief The QFlags class provides a type-safe way of storing |
|
122 |
OR-combinations of enum values. |
|
123 |
||
124 |
||
125 |
\ingroup tools |
|
126 |
||
127 |
The QFlags<Enum> class is a template class, where Enum is an enum |
|
128 |
type. QFlags is used throughout Qt for storing combinations of |
|
129 |
enum values. |
|
130 |
||
131 |
The traditional C++ approach for storing OR-combinations of enum |
|
132 |
values is to use an \c int or \c uint variable. The inconvenience |
|
133 |
with this approach is that there's no type checking at all; any |
|
134 |
enum value can be OR'd with any other enum value and passed on to |
|
135 |
a function that takes an \c int or \c uint. |
|
136 |
||
137 |
Qt uses QFlags to provide type safety. For example, the |
|
138 |
Qt::Alignment type is simply a typedef for |
|
139 |
QFlags<Qt::AlignmentFlag>. QLabel::setAlignment() takes a |
|
140 |
Qt::Alignment parameter, which means that any combination of |
|
141 |
Qt::AlignmentFlag values,or 0, is legal: |
|
142 |
||
143 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 0 |
|
144 |
||
145 |
If you try to pass a value from another enum or just a plain |
|
146 |
integer other than 0, the compiler will report an error. If you |
|
147 |
need to cast integer values to flags in a untyped fashion, you can |
|
148 |
use the explicit QFlags constructor as cast operator. |
|
149 |
||
150 |
If you want to use QFlags for your own enum types, use |
|
151 |
the Q_DECLARE_FLAGS() and Q_DECLARE_OPERATORS_FOR_FLAGS(). |
|
152 |
||
153 |
Example: |
|
154 |
||
155 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 1 |
|
156 |
||
157 |
You can then use the \c MyClass::Options type to store |
|
158 |
combinations of \c MyClass::Option values. |
|
159 |
||
160 |
\section1 Flags and the Meta-Object System |
|
161 |
||
162 |
The Q_DECLARE_FLAGS() macro does not expose the flags to the meta-object |
|
163 |
system, so they cannot be used by Qt Script or edited in Qt Designer. |
|
164 |
To make the flags available for these purposes, the Q_FLAGS() macro must |
|
165 |
be used: |
|
166 |
||
167 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp meta-object flags |
|
168 |
||
169 |
\section1 Naming Convention |
|
170 |
||
171 |
A sensible naming convention for enum types and associated QFlags |
|
172 |
types is to give a singular name to the enum type (e.g., \c |
|
173 |
Option) and a plural name to the QFlags type (e.g., \c Options). |
|
174 |
When a singular name is desired for the QFlags type (e.g., \c |
|
175 |
Alignment), you can use \c Flag as the suffix for the enum type |
|
176 |
(e.g., \c AlignmentFlag). |
|
177 |
||
178 |
\sa QFlag |
|
179 |
*/ |
|
180 |
||
181 |
/*! |
|
182 |
\typedef QFlags::enum_type |
|
183 |
||
184 |
Typedef for the Enum template type. |
|
185 |
*/ |
|
186 |
||
187 |
/*! |
|
188 |
\fn QFlags::QFlags(const QFlags &other) |
|
189 |
||
190 |
Constructs a copy of \a other. |
|
191 |
*/ |
|
192 |
||
193 |
/*! |
|
194 |
\fn QFlags::QFlags(Enum flag) |
|
195 |
||
196 |
Constructs a QFlags object storing the given \a flag. |
|
197 |
*/ |
|
198 |
||
199 |
/*! |
|
200 |
\fn QFlags::QFlags(Zero zero) |
|
201 |
||
202 |
Constructs a QFlags object with no flags set. \a zero must be a |
|
203 |
literal 0 value. |
|
204 |
*/ |
|
205 |
||
206 |
/*! |
|
207 |
\fn QFlags::QFlags(QFlag value) |
|
208 |
||
209 |
Constructs a QFlags object initialized with the given integer \a |
|
210 |
value. |
|
211 |
||
212 |
The QFlag type is a helper type. By using it here instead of \c |
|
213 |
int, we effectively ensure that arbitrary enum values cannot be |
|
214 |
cast to a QFlags, whereas untyped enum values (i.e., \c int |
|
215 |
values) can. |
|
216 |
*/ |
|
217 |
||
218 |
/*! |
|
219 |
\fn QFlags &QFlags::operator=(const QFlags &other) |
|
220 |
||
221 |
Assigns \a other to this object and returns a reference to this |
|
222 |
object. |
|
223 |
*/ |
|
224 |
||
225 |
/*! |
|
226 |
\fn QFlags &QFlags::operator&=(int mask) |
|
227 |
||
228 |
Performs a bitwise AND operation with \a mask and stores the |
|
229 |
result in this QFlags object. Returns a reference to this object. |
|
230 |
||
231 |
\sa operator&(), operator|=(), operator^=() |
|
232 |
*/ |
|
233 |
||
234 |
/*! |
|
235 |
\fn QFlags &QFlags::operator&=(uint mask) |
|
236 |
||
237 |
\overload |
|
238 |
*/ |
|
239 |
||
240 |
/*! |
|
241 |
\fn QFlags &QFlags::operator|=(QFlags other) |
|
242 |
||
243 |
Performs a bitwise OR operation with \a other and stores the |
|
244 |
result in this QFlags object. Returns a reference to this object. |
|
245 |
||
246 |
\sa operator|(), operator&=(), operator^=() |
|
247 |
*/ |
|
248 |
||
249 |
/*! |
|
250 |
\fn QFlags &QFlags::operator|=(Enum other) |
|
251 |
||
252 |
\overload |
|
253 |
*/ |
|
254 |
||
255 |
/*! |
|
256 |
\fn QFlags &QFlags::operator^=(QFlags other) |
|
257 |
||
258 |
Performs a bitwise XOR operation with \a other and stores the |
|
259 |
result in this QFlags object. Returns a reference to this object. |
|
260 |
||
261 |
\sa operator^(), operator&=(), operator|=() |
|
262 |
*/ |
|
263 |
||
264 |
/*! |
|
265 |
\fn QFlags &QFlags::operator^=(Enum other) |
|
266 |
||
267 |
\overload |
|
268 |
*/ |
|
269 |
||
270 |
/*! |
|
271 |
\fn QFlags::operator int() const |
|
272 |
||
273 |
Returns the value stored in the QFlags object as an integer. |
|
274 |
*/ |
|
275 |
||
276 |
/*! |
|
277 |
\fn QFlags QFlags::operator|(QFlags other) const |
|
278 |
||
279 |
Returns a QFlags object containing the result of the bitwise OR |
|
280 |
operation on this object and \a other. |
|
281 |
||
282 |
\sa operator|=(), operator^(), operator&(), operator~() |
|
283 |
*/ |
|
284 |
||
285 |
/*! |
|
286 |
\fn QFlags QFlags::operator|(Enum other) const |
|
287 |
||
288 |
\overload |
|
289 |
*/ |
|
290 |
||
291 |
/*! |
|
292 |
\fn QFlags QFlags::operator^(QFlags other) const |
|
293 |
||
294 |
Returns a QFlags object containing the result of the bitwise XOR |
|
295 |
operation on this object and \a other. |
|
296 |
||
297 |
\sa operator^=(), operator&(), operator|(), operator~() |
|
298 |
*/ |
|
299 |
||
300 |
/*! |
|
301 |
\fn QFlags QFlags::operator^(Enum other) const |
|
302 |
||
303 |
\overload |
|
304 |
*/ |
|
305 |
||
306 |
/*! |
|
307 |
\fn QFlags QFlags::operator&(int mask) const |
|
308 |
||
309 |
Returns a QFlags object containing the result of the bitwise AND |
|
310 |
operation on this object and \a mask. |
|
311 |
||
312 |
\sa operator&=(), operator|(), operator^(), operator~() |
|
313 |
*/ |
|
314 |
||
315 |
/*! |
|
316 |
\fn QFlags QFlags::operator&(uint mask) const |
|
317 |
||
318 |
\overload |
|
319 |
*/ |
|
320 |
||
321 |
/*! |
|
322 |
\fn QFlags QFlags::operator&(Enum mask) const |
|
323 |
||
324 |
\overload |
|
325 |
*/ |
|
326 |
||
327 |
/*! |
|
328 |
\fn QFlags QFlags::operator~() const |
|
329 |
||
330 |
Returns a QFlags object that contains the bitwise negation of |
|
331 |
this object. |
|
332 |
||
333 |
\sa operator&(), operator|(), operator^() |
|
334 |
*/ |
|
335 |
||
336 |
/*! |
|
337 |
\fn bool QFlags::operator!() const |
|
338 |
||
339 |
Returns true if no flag is set (i.e., if the value stored by the |
|
340 |
QFlags object is 0); otherwise returns false. |
|
341 |
*/ |
|
342 |
||
343 |
/*! |
|
344 |
\fn bool QFlags::testFlag(Enum flag) const |
|
345 |
\since 4.2 |
|
346 |
||
347 |
Returns true if the \a flag is set, otherwise false. |
|
348 |
*/ |
|
349 |
||
350 |
/*! |
|
351 |
\macro Q_DISABLE_COPY(Class) |
|
352 |
\relates QObject |
|
353 |
||
354 |
Disables the use of copy constructors and assignment operators |
|
355 |
for the given \a Class. |
|
356 |
||
357 |
Instances of subclasses of QObject should not be thought of as |
|
358 |
values that can be copied or assigned, but as unique identities. |
|
359 |
This means that when you create your own subclass of QObject |
|
360 |
(director or indirect), you should \e not give it a copy constructor |
|
361 |
or an assignment operator. However, it may not enough to simply |
|
362 |
omit them from your class, because, if you mistakenly write some code |
|
363 |
that requires a copy constructor or an assignment operator (it's easy |
|
364 |
to do), your compiler will thoughtfully create it for you. You must |
|
365 |
do more. |
|
366 |
||
367 |
The curious user will have seen that the Qt classes derived |
|
368 |
from QObject typically include this macro in a private section: |
|
369 |
||
370 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 43 |
|
371 |
||
372 |
It declares a copy constructor and an assignment operator in the |
|
373 |
private section, so that if you use them by mistake, the compiler |
|
374 |
will report an error. |
|
375 |
||
376 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 44 |
|
377 |
||
378 |
But even this might not catch absolutely every case. You might be |
|
379 |
tempted to do something like this: |
|
380 |
||
381 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 45 |
|
382 |
||
383 |
First of all, don't do that. Most compilers will generate code that |
|
384 |
uses the copy constructor, so the privacy violation error will be |
|
385 |
reported, but your C++ compiler is not required to generate code for |
|
386 |
this statement in a specific way. It could generate code using |
|
387 |
\e{neither} the copy constructor \e{nor} the assignment operator we |
|
388 |
made private. In that case, no error would be reported, but your |
|
389 |
application would probably crash when you called a member function |
|
390 |
of \c{w}. |
|
391 |
*/ |
|
392 |
||
393 |
/*! |
|
394 |
\macro Q_DECLARE_FLAGS(Flags, Enum) |
|
395 |
\relates QFlags |
|
396 |
||
397 |
The Q_DECLARE_FLAGS() macro expands to |
|
398 |
||
399 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 2 |
|
400 |
||
401 |
\a Enum is the name of an existing enum type, whereas \a Flags is |
|
402 |
the name of the QFlags<\e{Enum}> typedef. |
|
403 |
||
404 |
See the QFlags documentation for details. |
|
405 |
||
406 |
\sa Q_DECLARE_OPERATORS_FOR_FLAGS() |
|
407 |
*/ |
|
408 |
||
409 |
/*! |
|
410 |
\macro Q_DECLARE_OPERATORS_FOR_FLAGS(Flags) |
|
411 |
\relates QFlags |
|
412 |
||
413 |
The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global \c |
|
414 |
operator|() functions for \a Flags, which is of type QFlags<T>. |
|
415 |
||
416 |
See the QFlags documentation for details. |
|
417 |
||
418 |
\sa Q_DECLARE_FLAGS() |
|
419 |
*/ |
|
420 |
||
421 |
/*! |
|
422 |
\headerfile <QtGlobal> |
|
423 |
\title Global Qt Declarations |
|
424 |
\ingroup funclists |
|
425 |
||
426 |
\brief The <QtGlobal> header file includes the fundamental global |
|
427 |
declarations. It is included by most other Qt header files. |
|
428 |
||
429 |
The global declarations include \l{types}, \l{functions} and |
|
430 |
\l{macros}. |
|
431 |
||
432 |
The type definitions are partly convenience definitions for basic |
|
433 |
types (some of which guarantee certain bit-sizes on all platforms |
|
434 |
supported by Qt), partly types related to Qt message handling. The |
|
435 |
functions are related to generating messages, Qt version handling |
|
436 |
and comparing and adjusting object values. And finally, some of |
|
437 |
the declared macros enable programmers to add compiler or platform |
|
438 |
specific code to their applications, while others are convenience |
|
439 |
macros for larger operations. |
|
440 |
||
441 |
\section1 Types |
|
442 |
||
443 |
The header file declares several type definitions that guarantee a |
|
444 |
specified bit-size on all platforms supported by Qt for various |
|
445 |
basic types, for example \l qint8 which is a signed char |
|
446 |
guaranteed to be 8-bit on all platforms supported by Qt. The |
|
447 |
header file also declares the \l qlonglong type definition for \c |
|
448 |
{long long int } (\c __int64 on Windows). |
|
449 |
||
450 |
Several convenience type definitions are declared: \l qreal for \c |
|
451 |
double, \l uchar for \c unsigned char, \l uint for \c unsigned |
|
452 |
int, \l ulong for \c unsigned long and \l ushort for \c unsigned |
|
453 |
short. |
|
454 |
||
455 |
Finally, the QtMsgType definition identifies the various messages |
|
456 |
that can be generated and sent to a Qt message handler; |
|
457 |
QtMsgHandler is a type definition for a pointer to a function with |
|
458 |
the signature \c {void myMsgHandler(QtMsgType, const char *)}. |
|
459 |
||
460 |
\section1 Functions |
|
461 |
||
462 |
The <QtGlobal> header file contains several functions comparing |
|
463 |
and adjusting an object's value. These functions take a template |
|
464 |
type as argument: You can retrieve the absolute value of an object |
|
465 |
using the qAbs() function, and you can bound a given object's |
|
466 |
value by given minimum and maximum values using the qBound() |
|
467 |
function. You can retrieve the minimum and maximum of two given |
|
468 |
objects using qMin() and qMax() respectively. All these functions |
|
469 |
return a corresponding template type; the template types can be |
|
470 |
replaced by any other type. |
|
471 |
||
472 |
Example: |
|
473 |
||
474 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 3 |
|
475 |
||
476 |
<QtGlobal> also contains functions that generate messages from the |
|
477 |
given string argument: qCritical(), qDebug(), qFatal() and |
|
478 |
qWarning(). These functions call the message handler with the |
|
479 |
given message. |
|
480 |
||
481 |
Example: |
|
482 |
||
483 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 4 |
|
484 |
||
485 |
The remaining functions are qRound() and qRound64(), which both |
|
486 |
accept a \l qreal value as their argument returning the value |
|
487 |
rounded up to the nearest integer and 64-bit integer respectively, |
|
488 |
the qInstallMsgHandler() function which installs the given |
|
489 |
QtMsgHandler, and the qVersion() function which returns the |
|
490 |
version number of Qt at run-time as a string. |
|
491 |
||
492 |
\section1 Macros |
|
493 |
||
494 |
The <QtGlobal> header file provides a range of macros (Q_CC_*) |
|
495 |
that are defined if the application is compiled using the |
|
496 |
specified platforms. For example, the Q_CC_SUN macro is defined if |
|
497 |
the application is compiled using Forte Developer, or Sun Studio |
|
498 |
C++. The header file also declares a range of macros (Q_OS_*) |
|
499 |
that are defined for the specified platforms. For example, |
|
500 |
Q_OS_X11 which is defined for the X Window System. |
|
501 |
||
502 |
The purpose of these macros is to enable programmers to add |
|
503 |
compiler or platform specific code to their application. |
|
504 |
||
505 |
The remaining macros are convenience macros for larger operations: |
|
506 |
The QT_TRANSLATE_NOOP() and QT_TR_NOOP() macros provide the |
|
507 |
possibility of marking text for dynamic translation, |
|
508 |
i.e. translation without changing the stored source text. The |
|
509 |
Q_ASSERT() and Q_ASSERT_X() enables warning messages of various |
|
510 |
level of refinement. The Q_FOREACH() and foreach() macros |
|
511 |
implement Qt's foreach loop. |
|
512 |
||
513 |
The Q_INT64_C() and Q_UINT64_C() macros wrap signed and unsigned |
|
514 |
64-bit integer literals in a platform-independent way. The |
|
515 |
Q_CHECK_PTR() macro prints a warning containing the source code's |
|
516 |
file name and line number, saying that the program ran out of |
|
517 |
memory, if the pointer is 0. The qPrintable() macro represent an |
|
518 |
easy way of printing text. |
|
519 |
||
520 |
Finally, the QT_POINTER_SIZE macro expands to the size of a |
|
521 |
pointer in bytes, and the QT_VERSION and QT_VERSION_STR macros |
|
522 |
expand to a numeric value or a string, respectively, specifying |
|
523 |
Qt's version number, i.e the version the application is compiled |
|
524 |
against. |
|
525 |
||
526 |
\sa <QtAlgorithms>, QSysInfo |
|
527 |
*/ |
|
528 |
||
529 |
/*! |
|
530 |
\typedef qreal |
|
531 |
\relates <QtGlobal> |
|
532 |
||
533 |
Typedef for \c double on all platforms except for those using CPUs with |
|
534 |
ARM architectures. |
|
535 |
On ARM-based platforms, \c qreal is a typedef for \c float for performance |
|
536 |
reasons. |
|
537 |
*/ |
|
538 |
||
539 |
/*! \typedef uchar |
|
540 |
\relates <QtGlobal> |
|
541 |
||
542 |
Convenience typedef for \c{unsigned char}. |
|
543 |
*/ |
|
544 |
||
545 |
/*! |
|
546 |
\fn qt_set_sequence_auto_mnemonic(bool on) |
|
547 |
\relates <QtGlobal> |
|
548 |
||
549 |
Enables automatic mnemonics on Mac if \a on is true; otherwise |
|
550 |
this feature is disabled. |
|
551 |
||
552 |
Note that this function is only available on Mac where mnemonics |
|
553 |
are disabled by default. |
|
554 |
||
555 |
To access to this function, use an extern declaration: |
|
556 |
extern void qt_set_sequence_auto_mnemonic(bool b); |
|
557 |
||
558 |
\sa {QShortcut#mnemonic}{QShortcut} |
|
559 |
*/ |
|
560 |
||
561 |
/*! \typedef ushort |
|
562 |
\relates <QtGlobal> |
|
563 |
||
564 |
Convenience typedef for \c{unsigned short}. |
|
565 |
*/ |
|
566 |
||
567 |
/*! \typedef uint |
|
568 |
\relates <QtGlobal> |
|
569 |
||
570 |
Convenience typedef for \c{unsigned int}. |
|
571 |
*/ |
|
572 |
||
573 |
/*! \typedef ulong |
|
574 |
\relates <QtGlobal> |
|
575 |
||
576 |
Convenience typedef for \c{unsigned long}. |
|
577 |
*/ |
|
578 |
||
579 |
/*! \typedef qint8 |
|
580 |
\relates <QtGlobal> |
|
581 |
||
582 |
Typedef for \c{signed char}. This type is guaranteed to be 8-bit |
|
583 |
on all platforms supported by Qt. |
|
584 |
*/ |
|
585 |
||
586 |
/*! |
|
587 |
\typedef quint8 |
|
588 |
\relates <QtGlobal> |
|
589 |
||
590 |
Typedef for \c{unsigned char}. This type is guaranteed to |
|
591 |
be 8-bit on all platforms supported by Qt. |
|
592 |
*/ |
|
593 |
||
594 |
/*! \typedef qint16 |
|
595 |
\relates <QtGlobal> |
|
596 |
||
597 |
Typedef for \c{signed short}. This type is guaranteed to be |
|
598 |
16-bit on all platforms supported by Qt. |
|
599 |
*/ |
|
600 |
||
601 |
/*! |
|
602 |
\typedef quint16 |
|
603 |
\relates <QtGlobal> |
|
604 |
||
605 |
Typedef for \c{unsigned short}. This type is guaranteed to |
|
606 |
be 16-bit on all platforms supported by Qt. |
|
607 |
*/ |
|
608 |
||
609 |
/*! \typedef qint32 |
|
610 |
\relates <QtGlobal> |
|
611 |
||
612 |
Typedef for \c{signed int}. This type is guaranteed to be 32-bit |
|
613 |
on all platforms supported by Qt. |
|
614 |
*/ |
|
615 |
||
616 |
/*! |
|
617 |
\typedef quint32 |
|
618 |
\relates <QtGlobal> |
|
619 |
||
620 |
Typedef for \c{unsigned int}. This type is guaranteed to |
|
621 |
be 32-bit on all platforms supported by Qt. |
|
622 |
*/ |
|
623 |
||
624 |
/*! \typedef qint64 |
|
625 |
\relates <QtGlobal> |
|
626 |
||
627 |
Typedef for \c{long long int} (\c __int64 on Windows). This type |
|
628 |
is guaranteed to be 64-bit on all platforms supported by Qt. |
|
629 |
||
630 |
Literals of this type can be created using the Q_INT64_C() macro: |
|
631 |
||
632 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 5 |
|
633 |
||
634 |
\sa Q_INT64_C(), quint64, qlonglong |
|
635 |
*/ |
|
636 |
||
637 |
/*! |
|
638 |
\typedef quint64 |
|
639 |
\relates <QtGlobal> |
|
640 |
||
641 |
Typedef for \c{unsigned long long int} (\c{unsigned __int64} on |
|
642 |
Windows). This type is guaranteed to be 64-bit on all platforms |
|
643 |
supported by Qt. |
|
644 |
||
645 |
Literals of this type can be created using the Q_UINT64_C() |
|
646 |
macro: |
|
647 |
||
648 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 6 |
|
649 |
||
650 |
\sa Q_UINT64_C(), qint64, qulonglong |
|
651 |
*/ |
|
652 |
||
653 |
/*! |
|
654 |
\typedef quintptr |
|
655 |
\relates <QtGlobal> |
|
656 |
||
657 |
Integral type for representing a pointers (useful for hashing, |
|
658 |
etc.). |
|
659 |
||
660 |
Typedef for either quint32 or quint64. This type is guaranteed to |
|
661 |
be the same size as a pointer on all platforms supported by Qt. On |
|
662 |
a system with 32-bit pointers, quintptr is a typedef for quint32; |
|
663 |
on a system with 64-bit pointers, quintptr is a typedef for |
|
664 |
quint64. |
|
665 |
||
666 |
Note that quintptr is unsigned. Use qptrdiff for signed values. |
|
667 |
||
668 |
\sa qptrdiff, quint32, quint64 |
|
669 |
*/ |
|
670 |
||
671 |
/*! |
|
672 |
\typedef qptrdiff |
|
673 |
\relates <QtGlobal> |
|
674 |
||
675 |
Integral type for representing pointer differences. |
|
676 |
||
677 |
Typedef for either qint32 or qint64. This type is guaranteed to be |
|
678 |
the same size as a pointer on all platforms supported by Qt. On a |
|
679 |
system with 32-bit pointers, quintptr is a typedef for quint32; on |
|
680 |
a system with 64-bit pointers, quintptr is a typedef for quint64. |
|
681 |
||
682 |
Note that qptrdiff is signed. Use quintptr for unsigned values. |
|
683 |
||
684 |
\sa quintptr, qint32, qint64 |
|
685 |
*/ |
|
686 |
||
687 |
/*! |
|
688 |
\typedef QtMsgHandler |
|
689 |
\relates <QtGlobal> |
|
690 |
||
691 |
This is a typedef for a pointer to a function with the following |
|
692 |
signature: |
|
693 |
||
694 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 7 |
|
695 |
||
696 |
\sa QtMsgType, qInstallMsgHandler() |
|
697 |
*/ |
|
698 |
||
699 |
/*! |
|
700 |
\enum QtMsgType |
|
701 |
\relates <QtGlobal> |
|
702 |
||
703 |
This enum describes the messages that can be sent to a message |
|
704 |
handler (QtMsgHandler). You can use the enum to identify and |
|
705 |
associate the various message types with the appropriate |
|
706 |
actions. |
|
707 |
||
708 |
\value QtDebugMsg |
|
709 |
A message generated by the qDebug() function. |
|
710 |
\value QtWarningMsg |
|
711 |
A message generated by the qWarning() function. |
|
712 |
\value QtCriticalMsg |
|
713 |
A message generated by the qCritical() function. |
|
714 |
\value QtFatalMsg |
|
715 |
A message generated by the qFatal() function. |
|
716 |
\value QtSystemMsg |
|
717 |
||
718 |
||
719 |
\sa QtMsgHandler, qInstallMsgHandler() |
|
720 |
*/ |
|
721 |
||
722 |
/*! \macro qint64 Q_INT64_C(literal) |
|
723 |
\relates <QtGlobal> |
|
724 |
||
725 |
Wraps the signed 64-bit integer \a literal in a |
|
726 |
platform-independent way. |
|
727 |
||
728 |
Example: |
|
729 |
||
730 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 8 |
|
731 |
||
732 |
\sa qint64, Q_UINT64_C() |
|
733 |
*/ |
|
734 |
||
735 |
/*! \macro quint64 Q_UINT64_C(literal) |
|
736 |
\relates <QtGlobal> |
|
737 |
||
738 |
Wraps the unsigned 64-bit integer \a literal in a |
|
739 |
platform-independent way. |
|
740 |
||
741 |
Example: |
|
742 |
||
743 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 9 |
|
744 |
||
745 |
\sa quint64, Q_INT64_C() |
|
746 |
*/ |
|
747 |
||
748 |
/*! \typedef qlonglong |
|
749 |
\relates <QtGlobal> |
|
750 |
||
751 |
Typedef for \c{long long int} (\c __int64 on Windows). This is |
|
752 |
the same as \l qint64. |
|
753 |
||
754 |
\sa qulonglong, qint64 |
|
755 |
*/ |
|
756 |
||
757 |
/*! |
|
758 |
\typedef qulonglong |
|
759 |
\relates <QtGlobal> |
|
760 |
||
761 |
Typedef for \c{unsigned long long int} (\c{unsigned __int64} on |
|
762 |
Windows). This is the same as \l quint64. |
|
763 |
||
764 |
\sa quint64, qlonglong |
|
765 |
*/ |
|
766 |
||
767 |
/*! \fn const T &qAbs(const T &value) |
|
768 |
\relates <QtGlobal> |
|
769 |
||
770 |
Compares \a value to the 0 of type T and returns the absolute |
|
771 |
value. Thus if T is \e {double}, then \a value is compared to |
|
772 |
\e{(double) 0}. |
|
773 |
||
774 |
Example: |
|
775 |
||
776 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 10 |
|
777 |
*/ |
|
778 |
||
779 |
/*! \fn int qRound(qreal value) |
|
780 |
\relates <QtGlobal> |
|
781 |
||
782 |
Rounds \a value to the nearest integer. |
|
783 |
||
784 |
Example: |
|
785 |
||
786 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 11 |
|
787 |
*/ |
|
788 |
||
789 |
/*! \fn qint64 qRound64(qreal value) |
|
790 |
\relates <QtGlobal> |
|
791 |
||
792 |
Rounds \a value to the nearest 64-bit integer. |
|
793 |
||
794 |
Example: |
|
795 |
||
796 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 12 |
|
797 |
*/ |
|
798 |
||
799 |
/*! \fn const T &qMin(const T &value1, const T &value2) |
|
800 |
\relates <QtGlobal> |
|
801 |
||
802 |
Returns the minimum of \a value1 and \a value2. |
|
803 |
||
804 |
Example: |
|
805 |
||
806 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 13 |
|
807 |
||
808 |
\sa qMax(), qBound() |
|
809 |
*/ |
|
810 |
||
811 |
/*! \fn const T &qMax(const T &value1, const T &value2) |
|
812 |
\relates <QtGlobal> |
|
813 |
||
814 |
Returns the maximum of \a value1 and \a value2. |
|
815 |
||
816 |
Example: |
|
817 |
||
818 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 14 |
|
819 |
||
820 |
\sa qMin(), qBound() |
|
821 |
*/ |
|
822 |
||
823 |
/*! \fn const T &qBound(const T &min, const T &value, const T &max) |
|
824 |
\relates <QtGlobal> |
|
825 |
||
826 |
Returns \a value bounded by \a min and \a max. This is equivalent |
|
827 |
to qMax(\a min, qMin(\a value, \a max)). |
|
828 |
||
829 |
Example: |
|
830 |
||
831 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 15 |
|
832 |
||
833 |
\sa qMin(), qMax() |
|
834 |
*/ |
|
835 |
||
836 |
/*! |
|
837 |
\typedef Q_INT8 |
|
838 |
\relates <QtGlobal> |
|
839 |
\compat |
|
840 |
||
841 |
Use \l qint8 instead. |
|
842 |
*/ |
|
843 |
||
844 |
/*! |
|
845 |
\typedef Q_UINT8 |
|
846 |
\relates <QtGlobal> |
|
847 |
\compat |
|
848 |
||
849 |
Use \l quint8 instead. |
|
850 |
*/ |
|
851 |
||
852 |
/*! |
|
853 |
\typedef Q_INT16 |
|
854 |
\relates <QtGlobal> |
|
855 |
\compat |
|
856 |
||
857 |
Use \l qint16 instead. |
|
858 |
*/ |
|
859 |
||
860 |
/*! |
|
861 |
\typedef Q_UINT16 |
|
862 |
\relates <QtGlobal> |
|
863 |
\compat |
|
864 |
||
865 |
Use \l quint16 instead. |
|
866 |
*/ |
|
867 |
||
868 |
/*! |
|
869 |
\typedef Q_INT32 |
|
870 |
\relates <QtGlobal> |
|
871 |
\compat |
|
872 |
||
873 |
Use \l qint32 instead. |
|
874 |
*/ |
|
875 |
||
876 |
/*! |
|
877 |
\typedef Q_UINT32 |
|
878 |
\relates <QtGlobal> |
|
879 |
\compat |
|
880 |
||
881 |
Use \l quint32 instead. |
|
882 |
*/ |
|
883 |
||
884 |
/*! |
|
885 |
\typedef Q_INT64 |
|
886 |
\relates <QtGlobal> |
|
887 |
\compat |
|
888 |
||
889 |
Use \l qint64 instead. |
|
890 |
*/ |
|
891 |
||
892 |
/*! |
|
893 |
\typedef Q_UINT64 |
|
894 |
\relates <QtGlobal> |
|
895 |
\compat |
|
896 |
||
897 |
Use \l quint64 instead. |
|
898 |
*/ |
|
899 |
||
900 |
/*! |
|
901 |
\typedef Q_LLONG |
|
902 |
\relates <QtGlobal> |
|
903 |
\compat |
|
904 |
||
905 |
Use \l qint64 instead. |
|
906 |
*/ |
|
907 |
||
908 |
/*! |
|
909 |
\typedef Q_ULLONG |
|
910 |
\relates <QtGlobal> |
|
911 |
\compat |
|
912 |
||
913 |
Use \l quint64 instead. |
|
914 |
*/ |
|
915 |
||
916 |
/*! |
|
917 |
\typedef Q_LONG |
|
918 |
\relates <QtGlobal> |
|
919 |
\compat |
|
920 |
||
921 |
Use \c{void *} instead. |
|
922 |
*/ |
|
923 |
||
924 |
/*! |
|
925 |
\typedef Q_ULONG |
|
926 |
\relates <QtGlobal> |
|
927 |
\compat |
|
928 |
||
929 |
Use \c{void *} instead. |
|
930 |
*/ |
|
931 |
||
932 |
/*! \fn bool qSysInfo(int *wordSize, bool *bigEndian) |
|
933 |
\relates <QtGlobal> |
|
934 |
||
935 |
Use QSysInfo::WordSize and QSysInfo::ByteOrder instead. |
|
936 |
*/ |
|
937 |
||
938 |
/*! |
|
939 |
\fn bool qt_winUnicode() |
|
940 |
\relates <QtGlobal> |
|
941 |
||
942 |
This function always returns true. |
|
943 |
||
944 |
\sa QSysInfo |
|
945 |
*/ |
|
946 |
||
947 |
/*! |
|
948 |
\fn int qWinVersion() |
|
949 |
\relates <QtGlobal> |
|
950 |
||
951 |
Use QSysInfo::WindowsVersion instead. |
|
952 |
||
953 |
\sa QSysInfo |
|
954 |
*/ |
|
955 |
||
956 |
/*! |
|
957 |
\fn int qMacVersion() |
|
958 |
\relates <QtGlobal> |
|
959 |
||
960 |
Use QSysInfo::MacintoshVersion instead. |
|
961 |
||
962 |
\sa QSysInfo |
|
963 |
*/ |
|
964 |
||
965 |
/*! |
|
966 |
\macro QT_VERSION_CHECK |
|
967 |
\relates <QtGlobal> |
|
968 |
||
969 |
Turns the major, minor and patch numbers of a version into an |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
970 |
integer, 0xMMNNPP (MM = major, NN = minor, PP = patch). This can |
0 | 971 |
be compared with another similarly processed version id. |
972 |
||
973 |
\sa QT_VERSION |
|
974 |
*/ |
|
975 |
||
976 |
/*! |
|
977 |
\macro QT_VERSION |
|
978 |
\relates <QtGlobal> |
|
979 |
||
980 |
This macro expands a numeric value of the form 0xMMNNPP (MM = |
|
981 |
major, NN = minor, PP = patch) that specifies Qt's version |
|
982 |
number. For example, if you compile your application against Qt |
|
983 |
4.1.2, the QT_VERSION macro will expand to 0x040102. |
|
984 |
||
985 |
You can use QT_VERSION to use the latest Qt features where |
|
986 |
available. |
|
987 |
||
988 |
Example: |
|
989 |
||
990 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 16 |
|
991 |
||
992 |
\sa QT_VERSION_STR, qVersion() |
|
993 |
*/ |
|
994 |
||
995 |
/*! |
|
996 |
\macro QT_VERSION_STR |
|
997 |
\relates <QtGlobal> |
|
998 |
||
999 |
This macro expands to a string that specifies Qt's version number |
|
1000 |
(for example, "4.1.2"). This is the version against which the |
|
1001 |
application is compiled. |
|
1002 |
||
1003 |
\sa qVersion(), QT_VERSION |
|
1004 |
*/ |
|
1005 |
||
1006 |
/*! |
|
1007 |
\relates <QtGlobal> |
|
1008 |
||
1009 |
Returns the version number of Qt at run-time as a string (for |
|
1010 |
example, "4.1.2"). This may be a different version than the |
|
1011 |
version the application was compiled against. |
|
1012 |
||
1013 |
\sa QT_VERSION_STR |
|
1014 |
*/ |
|
1015 |
||
1016 |
const char *qVersion() |
|
1017 |
{ |
|
1018 |
return QT_VERSION_STR; |
|
1019 |
} |
|
1020 |
||
1021 |
bool qSharedBuild() |
|
1022 |
{ |
|
1023 |
#ifdef QT_SHARED |
|
1024 |
return true; |
|
1025 |
#else |
|
1026 |
return false; |
|
1027 |
#endif |
|
1028 |
} |
|
1029 |
||
1030 |
/***************************************************************************** |
|
1031 |
System detection routines |
|
1032 |
*****************************************************************************/ |
|
1033 |
||
1034 |
/*! |
|
1035 |
\class QSysInfo |
|
1036 |
\brief The QSysInfo class provides information about the system. |
|
1037 |
||
1038 |
\list |
|
1039 |
\o \l WordSize specifies the size of a pointer for the platform |
|
1040 |
on which the application is compiled. |
|
1041 |
\o \l ByteOrder specifies whether the platform is big-endian or |
|
1042 |
little-endian. |
|
1043 |
\o \l WindowsVersion specifies the version of the Windows operating |
|
1044 |
system on which the application is run (Windows only) |
|
1045 |
\o \l MacintoshVersion specifies the version of the Macintosh |
|
1046 |
operating system on which the application is run (Mac only). |
|
1047 |
\endlist |
|
1048 |
||
1049 |
Some constants are defined only on certain platforms. You can use |
|
1050 |
the preprocessor symbols Q_WS_WIN and Q_WS_MAC to test that |
|
1051 |
the application is compiled under Windows or Mac. |
|
1052 |
||
1053 |
\sa QLibraryInfo |
|
1054 |
*/ |
|
1055 |
||
1056 |
/*! |
|
1057 |
\enum QSysInfo::Sizes |
|
1058 |
||
1059 |
This enum provides platform-specific information about the sizes of data |
|
1060 |
structures used by the underlying architecture. |
|
1061 |
||
1062 |
\value WordSize The size in bits of a pointer for the platform on which |
|
1063 |
the application is compiled (32 or 64). |
|
1064 |
*/ |
|
1065 |
||
1066 |
/*! |
|
1067 |
\variable QSysInfo::WindowsVersion |
|
1068 |
\brief the version of the Windows operating system on which the |
|
1069 |
application is run (Windows only) |
|
1070 |
*/ |
|
1071 |
||
1072 |
/*! |
|
1073 |
\fn QSysInfo::WindowsVersion QSysInfo::windowsVersion() |
|
1074 |
\since 4.4 |
|
1075 |
||
1076 |
Returns the version of the Windows operating system on which the |
|
1077 |
application is run (Windows only). |
|
1078 |
*/ |
|
1079 |
||
1080 |
/*! |
|
1081 |
\variable QSysInfo::MacintoshVersion |
|
1082 |
\brief the version of the Macintosh operating system on which |
|
1083 |
the application is run (Mac only). |
|
1084 |
*/ |
|
1085 |
||
1086 |
/*! |
|
1087 |
\fn QSysInfo::SymbianVersion QSysInfo::symbianVersion() |
|
1088 |
\since 4.6 |
|
1089 |
||
1090 |
Returns the version of the Symbian operating system on which the |
|
1091 |
application is run (Symbian only). |
|
1092 |
*/ |
|
1093 |
||
1094 |
/*! |
|
1095 |
\fn QSysInfo::S60Version QSysInfo::s60Version() |
|
1096 |
\since 4.6 |
|
1097 |
||
1098 |
Returns the version of the S60 SDK system on which the |
|
1099 |
application is run (S60 only). |
|
1100 |
*/ |
|
1101 |
||
1102 |
/*! |
|
1103 |
\enum QSysInfo::Endian |
|
1104 |
||
1105 |
\value BigEndian Big-endian byte order (also called Network byte order) |
|
1106 |
\value LittleEndian Little-endian byte order |
|
1107 |
\value ByteOrder Equals BigEndian or LittleEndian, depending on |
|
1108 |
the platform's byte order. |
|
1109 |
*/ |
|
1110 |
||
1111 |
/*! |
|
1112 |
\enum QSysInfo::WinVersion |
|
1113 |
||
1114 |
This enum provides symbolic names for the various versions of the |
|
1115 |
Windows operating system. On Windows, the |
|
1116 |
QSysInfo::WindowsVersion variable gives the version of the system |
|
1117 |
on which the application is run. |
|
1118 |
||
1119 |
MS-DOS-based versions: |
|
1120 |
||
1121 |
\value WV_32s Windows 3.1 with Win 32s |
|
1122 |
\value WV_95 Windows 95 |
|
1123 |
\value WV_98 Windows 98 |
|
1124 |
\value WV_Me Windows Me |
|
1125 |
||
1126 |
NT-based versions (note that each operating system version is only represented once rather than each Windows edition): |
|
1127 |
||
1128 |
\value WV_NT Windows NT (operating system version 4.0) |
|
1129 |
\value WV_2000 Windows 2000 (operating system version 5.0) |
|
1130 |
\value WV_XP Windows XP (operating system version 5.1) |
|
1131 |
\value WV_2003 Windows Server 2003, Windows Server 2003 R2, Windows Home Server, Windows XP Professional x64 Edition (operating system version 5.2) |
|
1132 |
\value WV_VISTA Windows Vista, Windows Server 2008 (operating system version 6.0) |
|
1133 |
\value WV_WINDOWS7 Windows 7, Windows Server 2008 R2 (operating system version 6.1) |
|
1134 |
||
1135 |
Alternatively, you may use the following macros which correspond directly to the Windows operating system version number: |
|
1136 |
||
1137 |
\value WV_4_0 Operating system version 4.0, corresponds to Windows NT |
|
1138 |
\value WV_5_0 Operating system version 5.0, corresponds to Windows 2000 |
|
1139 |
\value WV_5_1 Operating system version 5.1, corresponds to Windows XP |
|
1140 |
\value WV_5_2 Operating system version 5.2, corresponds to Windows Server 2003, Windows Server 2003 R2, Windows Home Server, and Windows XP Professional x64 Edition |
|
1141 |
\value WV_6_0 Operating system version 6.0, corresponds to Windows Vista and Windows Server 2008 |
|
1142 |
\value WV_6_1 Operating system version 6.1, corresponds to Windows 7 and Windows Server 2008 R2 |
|
1143 |
||
1144 |
CE-based versions: |
|
1145 |
||
1146 |
\value WV_CE Windows CE |
|
1147 |
\value WV_CENET Windows CE .NET |
|
1148 |
\value WV_CE_5 Windows CE 5.x |
|
1149 |
\value WV_CE_6 Windows CE 6.x |
|
1150 |
||
1151 |
The following masks can be used for testing whether a Windows |
|
1152 |
version is MS-DOS-based, NT-based, or CE-based: |
|
1153 |
||
1154 |
\value WV_DOS_based MS-DOS-based version of Windows |
|
1155 |
\value WV_NT_based NT-based version of Windows |
|
1156 |
\value WV_CE_based CE-based version of Windows |
|
1157 |
||
1158 |
\sa MacVersion, SymbianVersion |
|
1159 |
*/ |
|
1160 |
||
1161 |
/*! |
|
1162 |
\enum QSysInfo::MacVersion |
|
1163 |
||
1164 |
This enum provides symbolic names for the various versions of the |
|
1165 |
Macintosh operating system. On Mac, the |
|
1166 |
QSysInfo::MacintoshVersion variable gives the version of the |
|
1167 |
system on which the application is run. |
|
1168 |
||
1169 |
\value MV_9 Mac OS 9 (unsupported) |
|
1170 |
\value MV_10_0 Mac OS X 10.0 (unsupported) |
|
1171 |
\value MV_10_1 Mac OS X 10.1 (unsupported) |
|
1172 |
\value MV_10_2 Mac OS X 10.2 (unsupported) |
|
1173 |
\value MV_10_3 Mac OS X 10.3 |
|
1174 |
\value MV_10_4 Mac OS X 10.4 |
|
1175 |
\value MV_10_5 Mac OS X 10.5 |
|
1176 |
\value MV_10_6 Mac OS X 10.6 |
|
1177 |
\value MV_Unknown An unknown and currently unsupported platform |
|
1178 |
||
1179 |
\value MV_CHEETAH Apple codename for MV_10_0 |
|
1180 |
\value MV_PUMA Apple codename for MV_10_1 |
|
1181 |
\value MV_JAGUAR Apple codename for MV_10_2 |
|
1182 |
\value MV_PANTHER Apple codename for MV_10_3 |
|
1183 |
\value MV_TIGER Apple codename for MV_10_4 |
|
1184 |
\value MV_LEOPARD Apple codename for MV_10_5 |
|
1185 |
\value MV_SNOWLEOPARD Apple codename for MV_10_6 |
|
1186 |
||
1187 |
\sa WinVersion, SymbianVersion |
|
1188 |
*/ |
|
1189 |
||
1190 |
/*! |
|
1191 |
\enum QSysInfo::SymbianVersion |
|
1192 |
||
1193 |
This enum provides symbolic names for the various versions of the |
|
1194 |
Symbian operating system. On Symbian, the |
|
1195 |
QSysInfo::symbianVersion() function gives the version of the |
|
1196 |
system on which the application is run. |
|
1197 |
||
1198 |
\value SV_9_2 Symbian OS v9.2 |
|
1199 |
\value SV_9_3 Symbian OS v9.3 |
|
1200 |
\value SV_9_4 Symbian OS v9.4 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1201 |
\value SV_SF_1 Symbian^1 |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1202 |
\value SV_SF_2 Symbian^2 |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1203 |
\value SV_SF_3 Symbian^3 |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1204 |
\value SV_SF_4 Symbian^4 |
0 | 1205 |
\value SV_Unknown An unknown and currently unsupported platform |
1206 |
||
1207 |
\sa S60Version, WinVersion, MacVersion |
|
1208 |
*/ |
|
1209 |
||
1210 |
/*! |
|
1211 |
\enum QSysInfo::S60Version |
|
1212 |
||
1213 |
This enum provides symbolic names for the various versions of the |
|
1214 |
S60 SDK. On S60, the |
|
1215 |
QSysInfo::s60Version() function gives the version of the |
|
1216 |
SDK on which the application is run. |
|
1217 |
||
1218 |
\value SV_S60_3_1 S60 3rd Edition Feature Pack 1 |
|
1219 |
\value SV_S60_3_2 S60 3rd Edition Feature Pack 2 |
|
1220 |
\value SV_S60_5_0 S60 5th Edition |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1221 |
\value SV_S60_5_1 S60 5th Edition Feature Pack 1 |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1222 |
\value SV_S60_5_2 S60 5th Edition Feature Pack 2 |
0 | 1223 |
\value SV_S60_Unknown An unknown and currently unsupported platform |
1224 |
\omitvalue SV_S60_None |
|
1225 |
||
1226 |
\sa SymbianVersion, WinVersion, MacVersion |
|
1227 |
*/ |
|
1228 |
||
1229 |
/*! |
|
1230 |
\macro Q_WS_MAC |
|
1231 |
\relates <QtGlobal> |
|
1232 |
||
1233 |
Defined on Mac OS X. |
|
1234 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1235 |
\sa Q_WS_WIN, Q_WS_X11, Q_WS_QWS, Q_WS_S60 |
0 | 1236 |
*/ |
1237 |
||
1238 |
/*! |
|
1239 |
\macro Q_WS_WIN |
|
1240 |
\relates <QtGlobal> |
|
1241 |
||
1242 |
Defined on Windows. |
|
1243 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1244 |
\sa Q_WS_MAC, Q_WS_X11, Q_WS_QWS, Q_WS_S60 |
0 | 1245 |
*/ |
1246 |
||
1247 |
/*! |
|
1248 |
\macro Q_WS_X11 |
|
1249 |
\relates <QtGlobal> |
|
1250 |
||
1251 |
Defined on X11. |
|
1252 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1253 |
\sa Q_WS_MAC, Q_WS_WIN, Q_WS_QWS, Q_WS_S60 |
0 | 1254 |
*/ |
1255 |
||
1256 |
/*! |
|
1257 |
\macro Q_WS_QWS |
|
1258 |
\relates <QtGlobal> |
|
1259 |
||
1260 |
Defined on Qt for Embedded Linux. |
|
1261 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1262 |
\sa Q_WS_MAC, Q_WS_WIN, Q_WS_X11, Q_WS_S60 |
0 | 1263 |
*/ |
1264 |
||
1265 |
/*! |
|
1266 |
\macro Q_OS_DARWIN |
|
1267 |
\relates <QtGlobal> |
|
1268 |
||
1269 |
Defined on Darwin OS (synonym for Q_OS_MAC). |
|
1270 |
*/ |
|
1271 |
||
1272 |
/*! |
|
1273 |
\macro Q_OS_MSDOS |
|
1274 |
\relates <QtGlobal> |
|
1275 |
||
1276 |
Defined on MS-DOS and Windows. |
|
1277 |
*/ |
|
1278 |
||
1279 |
/*! |
|
1280 |
\macro Q_OS_OS2 |
|
1281 |
\relates <QtGlobal> |
|
1282 |
||
1283 |
Defined on OS/2. |
|
1284 |
*/ |
|
1285 |
||
1286 |
/*! |
|
1287 |
\macro Q_OS_OS2EMX |
|
1288 |
\relates <QtGlobal> |
|
1289 |
||
1290 |
Defined on XFree86 on OS/2 (not PM). |
|
1291 |
*/ |
|
1292 |
||
1293 |
/*! |
|
1294 |
\macro Q_OS_WIN32 |
|
1295 |
\relates <QtGlobal> |
|
1296 |
||
1297 |
Defined on all supported versions of Windows. |
|
1298 |
*/ |
|
1299 |
||
1300 |
/*! |
|
1301 |
\macro Q_OS_WINCE |
|
1302 |
\relates <QtGlobal> |
|
1303 |
||
1304 |
Defined on Windows CE. |
|
1305 |
*/ |
|
1306 |
||
1307 |
/*! |
|
1308 |
\macro Q_OS_CYGWIN |
|
1309 |
\relates <QtGlobal> |
|
1310 |
||
1311 |
Defined on Cygwin. |
|
1312 |
*/ |
|
1313 |
||
1314 |
/*! |
|
1315 |
\macro Q_OS_SOLARIS |
|
1316 |
\relates <QtGlobal> |
|
1317 |
||
1318 |
Defined on Sun Solaris. |
|
1319 |
*/ |
|
1320 |
||
1321 |
/*! |
|
1322 |
\macro Q_OS_HPUX |
|
1323 |
\relates <QtGlobal> |
|
1324 |
||
1325 |
Defined on HP-UX. |
|
1326 |
*/ |
|
1327 |
||
1328 |
/*! |
|
1329 |
\macro Q_OS_ULTRIX |
|
1330 |
\relates <QtGlobal> |
|
1331 |
||
1332 |
Defined on DEC Ultrix. |
|
1333 |
*/ |
|
1334 |
||
1335 |
/*! |
|
1336 |
\macro Q_OS_LINUX |
|
1337 |
\relates <QtGlobal> |
|
1338 |
||
1339 |
Defined on Linux. |
|
1340 |
*/ |
|
1341 |
||
1342 |
/*! |
|
1343 |
\macro Q_OS_FREEBSD |
|
1344 |
\relates <QtGlobal> |
|
1345 |
||
1346 |
Defined on FreeBSD. |
|
1347 |
*/ |
|
1348 |
||
1349 |
/*! |
|
1350 |
\macro Q_OS_NETBSD |
|
1351 |
\relates <QtGlobal> |
|
1352 |
||
1353 |
Defined on NetBSD. |
|
1354 |
*/ |
|
1355 |
||
1356 |
/*! |
|
1357 |
\macro Q_OS_OPENBSD |
|
1358 |
\relates <QtGlobal> |
|
1359 |
||
1360 |
Defined on OpenBSD. |
|
1361 |
*/ |
|
1362 |
||
1363 |
/*! |
|
1364 |
\macro Q_OS_BSDI |
|
1365 |
\relates <QtGlobal> |
|
1366 |
||
1367 |
Defined on BSD/OS. |
|
1368 |
*/ |
|
1369 |
||
1370 |
/*! |
|
1371 |
\macro Q_OS_IRIX |
|
1372 |
\relates <QtGlobal> |
|
1373 |
||
1374 |
Defined on SGI Irix. |
|
1375 |
*/ |
|
1376 |
||
1377 |
/*! |
|
1378 |
\macro Q_OS_OSF |
|
1379 |
\relates <QtGlobal> |
|
1380 |
||
1381 |
Defined on HP Tru64 UNIX. |
|
1382 |
*/ |
|
1383 |
||
1384 |
/*! |
|
1385 |
\macro Q_OS_SCO |
|
1386 |
\relates <QtGlobal> |
|
1387 |
||
1388 |
Defined on SCO OpenServer 5. |
|
1389 |
*/ |
|
1390 |
||
1391 |
/*! |
|
1392 |
\macro Q_OS_UNIXWARE |
|
1393 |
\relates <QtGlobal> |
|
1394 |
||
1395 |
Defined on UnixWare 7, Open UNIX 8. |
|
1396 |
*/ |
|
1397 |
||
1398 |
/*! |
|
1399 |
\macro Q_OS_AIX |
|
1400 |
\relates <QtGlobal> |
|
1401 |
||
1402 |
Defined on AIX. |
|
1403 |
*/ |
|
1404 |
||
1405 |
/*! |
|
1406 |
\macro Q_OS_HURD |
|
1407 |
\relates <QtGlobal> |
|
1408 |
||
1409 |
Defined on GNU Hurd. |
|
1410 |
*/ |
|
1411 |
||
1412 |
/*! |
|
1413 |
\macro Q_OS_DGUX |
|
1414 |
\relates <QtGlobal> |
|
1415 |
||
1416 |
Defined on DG/UX. |
|
1417 |
*/ |
|
1418 |
||
1419 |
/*! |
|
1420 |
\macro Q_OS_RELIANT |
|
1421 |
\relates <QtGlobal> |
|
1422 |
||
1423 |
Defined on Reliant UNIX. |
|
1424 |
*/ |
|
1425 |
||
1426 |
/*! |
|
1427 |
\macro Q_OS_DYNIX |
|
1428 |
\relates <QtGlobal> |
|
1429 |
||
1430 |
Defined on DYNIX/ptx. |
|
1431 |
*/ |
|
1432 |
||
1433 |
/*! |
|
1434 |
\macro Q_OS_QNX |
|
1435 |
\relates <QtGlobal> |
|
1436 |
||
1437 |
Defined on QNX Neutrino. |
|
1438 |
*/ |
|
1439 |
||
1440 |
/*! |
|
1441 |
\macro Q_OS_LYNX |
|
1442 |
\relates <QtGlobal> |
|
1443 |
||
1444 |
Defined on LynxOS. |
|
1445 |
*/ |
|
1446 |
||
1447 |
/*! |
|
1448 |
\macro Q_OS_BSD4 |
|
1449 |
\relates <QtGlobal> |
|
1450 |
||
1451 |
Defined on Any BSD 4.4 system. |
|
1452 |
*/ |
|
1453 |
||
1454 |
/*! |
|
1455 |
\macro Q_OS_UNIX |
|
1456 |
\relates <QtGlobal> |
|
1457 |
||
1458 |
Defined on Any UNIX BSD/SYSV system. |
|
1459 |
*/ |
|
1460 |
||
1461 |
/*! |
|
1462 |
\macro Q_CC_SYM |
|
1463 |
\relates <QtGlobal> |
|
1464 |
||
1465 |
Defined if the application is compiled using Digital Mars C/C++ |
|
1466 |
(used to be Symantec C++). |
|
1467 |
*/ |
|
1468 |
||
1469 |
/*! |
|
1470 |
\macro Q_CC_MWERKS |
|
1471 |
\relates <QtGlobal> |
|
1472 |
||
1473 |
Defined if the application is compiled using Metrowerks |
|
1474 |
CodeWarrior. |
|
1475 |
*/ |
|
1476 |
||
1477 |
/*! |
|
1478 |
\macro Q_CC_MSVC |
|
1479 |
\relates <QtGlobal> |
|
1480 |
||
1481 |
Defined if the application is compiled using Microsoft Visual |
|
1482 |
C/C++, Intel C++ for Windows. |
|
1483 |
*/ |
|
1484 |
||
1485 |
/*! |
|
1486 |
\macro Q_CC_BOR |
|
1487 |
\relates <QtGlobal> |
|
1488 |
||
1489 |
Defined if the application is compiled using Borland/Turbo C++. |
|
1490 |
*/ |
|
1491 |
||
1492 |
/*! |
|
1493 |
\macro Q_CC_WAT |
|
1494 |
\relates <QtGlobal> |
|
1495 |
||
1496 |
Defined if the application is compiled using Watcom C++. |
|
1497 |
*/ |
|
1498 |
||
1499 |
/*! |
|
1500 |
\macro Q_CC_GNU |
|
1501 |
\relates <QtGlobal> |
|
1502 |
||
1503 |
Defined if the application is compiled using GNU C++. |
|
1504 |
*/ |
|
1505 |
||
1506 |
/*! |
|
1507 |
\macro Q_CC_COMEAU |
|
1508 |
\relates <QtGlobal> |
|
1509 |
||
1510 |
Defined if the application is compiled using Comeau C++. |
|
1511 |
*/ |
|
1512 |
||
1513 |
/*! |
|
1514 |
\macro Q_CC_EDG |
|
1515 |
\relates <QtGlobal> |
|
1516 |
||
1517 |
Defined if the application is compiled using Edison Design Group |
|
1518 |
C++. |
|
1519 |
*/ |
|
1520 |
||
1521 |
/*! |
|
1522 |
\macro Q_CC_OC |
|
1523 |
\relates <QtGlobal> |
|
1524 |
||
1525 |
Defined if the application is compiled using CenterLine C++. |
|
1526 |
*/ |
|
1527 |
||
1528 |
/*! |
|
1529 |
\macro Q_CC_SUN |
|
1530 |
\relates <QtGlobal> |
|
1531 |
||
1532 |
Defined if the application is compiled using Forte Developer, or |
|
1533 |
Sun Studio C++. |
|
1534 |
*/ |
|
1535 |
||
1536 |
/*! |
|
1537 |
\macro Q_CC_MIPS |
|
1538 |
\relates <QtGlobal> |
|
1539 |
||
1540 |
Defined if the application is compiled using MIPSpro C++. |
|
1541 |
*/ |
|
1542 |
||
1543 |
/*! |
|
1544 |
\macro Q_CC_DEC |
|
1545 |
\relates <QtGlobal> |
|
1546 |
||
1547 |
Defined if the application is compiled using DEC C++. |
|
1548 |
*/ |
|
1549 |
||
1550 |
/*! |
|
1551 |
\macro Q_CC_HPACC |
|
1552 |
\relates <QtGlobal> |
|
1553 |
||
1554 |
Defined if the application is compiled using HP aC++. |
|
1555 |
*/ |
|
1556 |
||
1557 |
/*! |
|
1558 |
\macro Q_CC_USLC |
|
1559 |
\relates <QtGlobal> |
|
1560 |
||
1561 |
Defined if the application is compiled using SCO OUDK and UDK. |
|
1562 |
*/ |
|
1563 |
||
1564 |
/*! |
|
1565 |
\macro Q_CC_CDS |
|
1566 |
\relates <QtGlobal> |
|
1567 |
||
1568 |
Defined if the application is compiled using Reliant C++. |
|
1569 |
*/ |
|
1570 |
||
1571 |
/*! |
|
1572 |
\macro Q_CC_KAI |
|
1573 |
\relates <QtGlobal> |
|
1574 |
||
1575 |
Defined if the application is compiled using KAI C++. |
|
1576 |
*/ |
|
1577 |
||
1578 |
/*! |
|
1579 |
\macro Q_CC_INTEL |
|
1580 |
\relates <QtGlobal> |
|
1581 |
||
1582 |
Defined if the application is compiled using Intel C++ for Linux, |
|
1583 |
Intel C++ for Windows. |
|
1584 |
*/ |
|
1585 |
||
1586 |
/*! |
|
1587 |
\macro Q_CC_HIGHC |
|
1588 |
\relates <QtGlobal> |
|
1589 |
||
1590 |
Defined if the application is compiled using MetaWare High C/C++. |
|
1591 |
*/ |
|
1592 |
||
1593 |
/*! |
|
1594 |
\macro Q_CC_PGI |
|
1595 |
\relates <QtGlobal> |
|
1596 |
||
1597 |
Defined if the application is compiled using Portland Group C++. |
|
1598 |
*/ |
|
1599 |
||
1600 |
/*! |
|
1601 |
\macro Q_CC_GHS |
|
1602 |
\relates <QtGlobal> |
|
1603 |
||
1604 |
Defined if the application is compiled using Green Hills |
|
1605 |
Optimizing C++ Compilers. |
|
1606 |
*/ |
|
1607 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1608 |
/*! |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1609 |
\macro Q_OS_MAC |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1610 |
\relates <QtGlobal> |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1611 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1612 |
Defined on MAC OS (synonym for Darwin). |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1613 |
*/ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1614 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1615 |
/*! |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1616 |
\macro Q_OS_SYMBIAN |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1617 |
\relates <QtGlobal> |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1618 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1619 |
Defined on Symbian. |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1620 |
*/ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1621 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1622 |
/*! |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1623 |
\macro Q_WS_S60 |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1624 |
\relates <QtGlobal> |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1625 |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1626 |
Defined on S60 with the Avkon UI framework. |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1627 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1628 |
\sa Q_WS_MAC, Q_WS_WIN, Q_WS_X11, Q_WS_QWS |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1629 |
*/ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1630 |
|
0 | 1631 |
#if defined(QT_BUILD_QMAKE) |
1632 |
// needed to bootstrap qmake |
|
1633 |
static const unsigned int qt_one = 1; |
|
1634 |
const int QSysInfo::ByteOrder = ((*((unsigned char *) &qt_one) == 0) ? BigEndian : LittleEndian); |
|
1635 |
#endif |
|
1636 |
||
1637 |
#if !defined(QWS) && defined(Q_OS_MAC) |
|
1638 |
||
1639 |
QT_BEGIN_INCLUDE_NAMESPACE |
|
1640 |
#include "private/qcore_mac_p.h" |
|
1641 |
#include "qnamespace.h" |
|
1642 |
QT_END_INCLUDE_NAMESPACE |
|
1643 |
||
1644 |
Q_CORE_EXPORT OSErr qt_mac_create_fsref(const QString &file, FSRef *fsref) |
|
1645 |
{ |
|
1646 |
return FSPathMakeRef(reinterpret_cast<const UInt8 *>(file.toUtf8().constData()), fsref, 0); |
|
1647 |
} |
|
1648 |
||
1649 |
// Don't use this function, it won't work in 10.5 (Leopard) and up |
|
1650 |
Q_CORE_EXPORT OSErr qt_mac_create_fsspec(const QString &file, FSSpec *spec) |
|
1651 |
{ |
|
1652 |
FSRef fsref; |
|
1653 |
OSErr ret = qt_mac_create_fsref(file, &fsref); |
|
1654 |
if (ret == noErr) |
|
1655 |
ret = FSGetCatalogInfo(&fsref, kFSCatInfoNone, 0, 0, spec, 0); |
|
1656 |
return ret; |
|
1657 |
} |
|
1658 |
||
1659 |
Q_CORE_EXPORT void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding encoding=0, int len=-1) |
|
1660 |
{ |
|
1661 |
if(len == -1) |
|
1662 |
len = s.length(); |
|
1663 |
#if 0 |
|
1664 |
UnicodeMapping mapping; |
|
1665 |
mapping.unicodeEncoding = CreateTextEncoding(kTextEncodingUnicodeDefault, |
|
1666 |
kTextEncodingDefaultVariant, |
|
1667 |
kUnicode16BitFormat); |
|
1668 |
mapping.otherEncoding = (encoding ? encoding : ); |
|
1669 |
mapping.mappingVersion = kUnicodeUseLatestMapping; |
|
1670 |
||
1671 |
UnicodeToTextInfo info; |
|
1672 |
OSStatus err = CreateUnicodeToTextInfo(&mapping, &info); |
|
1673 |
if(err != noErr) { |
|
1674 |
qDebug("Qt: internal: Unable to create pascal string '%s'::%d [%ld]", |
|
1675 |
s.left(len).latin1(), (int)encoding, err); |
|
1676 |
return; |
|
1677 |
} |
|
1678 |
const int unilen = len * 2; |
|
1679 |
const UniChar *unibuf = (UniChar *)s.unicode(); |
|
1680 |
ConvertFromUnicodeToPString(info, unilen, unibuf, str); |
|
1681 |
DisposeUnicodeToTextInfo(&info); |
|
1682 |
#else |
|
1683 |
Q_UNUSED(encoding); |
|
1684 |
CFStringGetPascalString(QCFString(s), str, 256, CFStringGetSystemEncoding()); |
|
1685 |
#endif |
|
1686 |
} |
|
1687 |
||
1688 |
Q_CORE_EXPORT QString qt_mac_from_pascal_string(const Str255 pstr) { |
|
1689 |
return QCFString(CFStringCreateWithPascalString(0, pstr, CFStringGetSystemEncoding())); |
|
1690 |
} |
|
1691 |
||
1692 |
||
1693 |
||
1694 |
static QSysInfo::MacVersion macVersion() |
|
1695 |
{ |
|
1696 |
SInt32 gestalt_version; |
|
1697 |
if (Gestalt(gestaltSystemVersion, &gestalt_version) == noErr) { |
|
1698 |
return QSysInfo::MacVersion(((gestalt_version & 0x00F0) >> 4) + 2); |
|
1699 |
} |
|
1700 |
return QSysInfo::MV_Unknown; |
|
1701 |
} |
|
1702 |
const QSysInfo::MacVersion QSysInfo::MacintoshVersion = macVersion(); |
|
1703 |
||
1704 |
#elif defined(Q_OS_WIN32) || defined(Q_OS_CYGWIN) || defined(Q_OS_WINCE) |
|
1705 |
||
1706 |
QT_BEGIN_INCLUDE_NAMESPACE |
|
1707 |
#include "qt_windows.h" |
|
1708 |
QT_END_INCLUDE_NAMESPACE |
|
1709 |
||
1710 |
QSysInfo::WinVersion QSysInfo::windowsVersion() |
|
1711 |
{ |
|
1712 |
#ifndef VER_PLATFORM_WIN32s |
|
1713 |
#define VER_PLATFORM_WIN32s 0 |
|
1714 |
#endif |
|
1715 |
#ifndef VER_PLATFORM_WIN32_WINDOWS |
|
1716 |
#define VER_PLATFORM_WIN32_WINDOWS 1 |
|
1717 |
#endif |
|
1718 |
#ifndef VER_PLATFORM_WIN32_NT |
|
1719 |
#define VER_PLATFORM_WIN32_NT 2 |
|
1720 |
#endif |
|
1721 |
#ifndef VER_PLATFORM_WIN32_CE |
|
1722 |
#define VER_PLATFORM_WIN32_CE 3 |
|
1723 |
#endif |
|
1724 |
||
1725 |
static QSysInfo::WinVersion winver; |
|
1726 |
if (winver) |
|
1727 |
return winver; |
|
1728 |
winver = QSysInfo::WV_NT; |
|
1729 |
OSVERSIONINFOW osver; |
|
1730 |
osver.dwOSVersionInfoSize = sizeof(osver); |
|
1731 |
GetVersionEx(&osver); |
|
1732 |
#ifdef Q_OS_WINCE |
|
1733 |
DWORD qt_cever = 0; |
|
1734 |
qt_cever = osver.dwMajorVersion * 100; |
|
1735 |
qt_cever += osver.dwMinorVersion * 10; |
|
1736 |
#endif |
|
1737 |
switch (osver.dwPlatformId) { |
|
1738 |
case VER_PLATFORM_WIN32s: |
|
1739 |
winver = QSysInfo::WV_32s; |
|
1740 |
break; |
|
1741 |
case VER_PLATFORM_WIN32_WINDOWS: |
|
1742 |
// We treat Windows Me (minor 90) the same as Windows 98 |
|
1743 |
if (osver.dwMinorVersion == 90) |
|
1744 |
winver = QSysInfo::WV_Me; |
|
1745 |
else if (osver.dwMinorVersion == 10) |
|
1746 |
winver = QSysInfo::WV_98; |
|
1747 |
else |
|
1748 |
winver = QSysInfo::WV_95; |
|
1749 |
break; |
|
1750 |
#ifdef Q_OS_WINCE |
|
1751 |
case VER_PLATFORM_WIN32_CE: |
|
1752 |
if (qt_cever >= 600) |
|
1753 |
winver = QSysInfo::WV_CE_6; |
|
1754 |
if (qt_cever >= 500) |
|
1755 |
winver = QSysInfo::WV_CE_5; |
|
1756 |
else if (qt_cever >= 400) |
|
1757 |
winver = QSysInfo::WV_CENET; |
|
1758 |
else |
|
1759 |
winver = QSysInfo::WV_CE; |
|
1760 |
break; |
|
1761 |
#endif |
|
1762 |
default: // VER_PLATFORM_WIN32_NT |
|
1763 |
if (osver.dwMajorVersion < 5) { |
|
1764 |
winver = QSysInfo::WV_NT; |
|
1765 |
} else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 0) { |
|
1766 |
winver = QSysInfo::WV_2000; |
|
1767 |
} else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 1) { |
|
1768 |
winver = QSysInfo::WV_XP; |
|
1769 |
} else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 2) { |
|
1770 |
winver = QSysInfo::WV_2003; |
|
1771 |
} else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 0) { |
|
1772 |
winver = QSysInfo::WV_VISTA; |
|
1773 |
} else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 1) { |
|
1774 |
winver = QSysInfo::WV_WINDOWS7; |
|
1775 |
} else { |
|
1776 |
qWarning("Qt: Untested Windows version %d.%d detected!", |
|
1777 |
int(osver.dwMajorVersion), int(osver.dwMinorVersion)); |
|
1778 |
winver = QSysInfo::WV_NT_based; |
|
1779 |
} |
|
1780 |
} |
|
1781 |
||
1782 |
#ifdef QT_DEBUG |
|
1783 |
{ |
|
1784 |
QByteArray override = qgetenv("QT_WINVER_OVERRIDE"); |
|
1785 |
if (override.isEmpty()) |
|
1786 |
return winver; |
|
1787 |
||
1788 |
if (override == "Me") |
|
1789 |
winver = QSysInfo::WV_Me; |
|
1790 |
if (override == "95") |
|
1791 |
winver = QSysInfo::WV_95; |
|
1792 |
else if (override == "98") |
|
1793 |
winver = QSysInfo::WV_98; |
|
1794 |
else if (override == "NT") |
|
1795 |
winver = QSysInfo::WV_NT; |
|
1796 |
else if (override == "2000") |
|
1797 |
winver = QSysInfo::WV_2000; |
|
1798 |
else if (override == "2003") |
|
1799 |
winver = QSysInfo::WV_2003; |
|
1800 |
else if (override == "XP") |
|
1801 |
winver = QSysInfo::WV_XP; |
|
1802 |
else if (override == "VISTA") |
|
1803 |
winver = QSysInfo::WV_VISTA; |
|
1804 |
else if (override == "WINDOWS7") |
|
1805 |
winver = QSysInfo::WV_WINDOWS7; |
|
1806 |
} |
|
1807 |
#endif |
|
1808 |
||
1809 |
return winver; |
|
1810 |
} |
|
1811 |
||
1812 |
const QSysInfo::WinVersion QSysInfo::WindowsVersion = QSysInfo::windowsVersion(); |
|
1813 |
||
1814 |
#endif |
|
1815 |
||
1816 |
#ifdef Q_OS_SYMBIAN |
|
1817 |
static QSysInfo::S60Version cachedS60Version = QSysInfo::S60Version(-1); |
|
1818 |
||
1819 |
QSysInfo::S60Version QSysInfo::s60Version() |
|
1820 |
{ |
|
1821 |
if (cachedS60Version != -1) |
|
1822 |
return cachedS60Version; |
|
1823 |
||
1824 |
// Use pure Symbian code, because if done using QDir, there will be a call back |
|
1825 |
// to this method, resulting doing this expensive operation twice before the cache kicks in. |
|
1826 |
// Pure Symbian code also makes this method ~10x faster, speeding up the application launch. |
|
1827 |
RFs rfs = qt_s60GetRFs(); |
|
1828 |
TFindFile fileFinder(rfs); |
|
1829 |
CDir* contents; |
|
1830 |
TInt err = fileFinder.FindWildByDir(qt_S60Filter, qt_S60SystemInstallDir, contents); |
|
1831 |
if (err == KErrNone) { |
|
1832 |
err = contents->Sort(EDescending|ESortByName); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1833 |
if (err == KErrNone && contents->Count() > 0 && (*contents)[0].iName.Length() >= 12) { |
0 | 1834 |
TInt major = (*contents)[0].iName[9] - '0'; |
1835 |
TInt minor = (*contents)[0].iName[11] - '0'; |
|
1836 |
if (major == 3) { |
|
1837 |
if (minor == 1) { |
|
1838 |
return cachedS60Version = SV_S60_3_1; |
|
1839 |
} else if (minor == 2) { |
|
1840 |
return cachedS60Version = SV_S60_3_2; |
|
1841 |
} |
|
1842 |
} else if (major == 5) { |
|
1843 |
if (minor == 0) { |
|
1844 |
return cachedS60Version = SV_S60_5_0; |
|
1845 |
} |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1846 |
else if (minor == 1) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1847 |
return cachedS60Version = SV_S60_5_1; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1848 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1849 |
else if (minor == 2) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1850 |
return cachedS60Version = SV_S60_5_2; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1851 |
} |
0 | 1852 |
} |
1853 |
} |
|
1854 |
delete contents; |
|
1855 |
} |
|
1856 |
||
1857 |
# ifdef Q_CC_NOKIAX86 |
|
1858 |
// Some emulator environments may not contain the version specific .sis files, so |
|
1859 |
// simply hardcode the version on those environments. |
|
1860 |
# if defined(__SERIES60_31__) |
|
1861 |
return cachedS60Version = SV_S60_3_1; |
|
1862 |
# elif defined(__S60_32__) |
|
1863 |
return cachedS60Version = SV_S60_3_2; |
|
1864 |
# elif defined(__S60_50__) |
|
1865 |
return cachedS60Version = SV_S60_5_0; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1866 |
# endif |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1867 |
# endif |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1868 |
//If reaching here, it was not possible to determine the version |
0 | 1869 |
return cachedS60Version = SV_S60_Unknown; |
1870 |
} |
|
1871 |
QSysInfo::SymbianVersion QSysInfo::symbianVersion() |
|
1872 |
{ |
|
1873 |
switch (s60Version()) { |
|
1874 |
case SV_S60_3_1: |
|
1875 |
return SV_9_2; |
|
1876 |
case SV_S60_3_2: |
|
1877 |
return SV_9_3; |
|
1878 |
case SV_S60_5_0: |
|
1879 |
return SV_9_4; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1880 |
case SV_S60_5_1: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1881 |
return SV_9_4; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1882 |
case SV_S60_5_2: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1883 |
return SV_9_4; |
0 | 1884 |
default: |
1885 |
return SV_Unknown; |
|
1886 |
} |
|
1887 |
} |
|
1888 |
#endif // ifdef Q_OS_SYMBIAN |
|
1889 |
||
1890 |
/*! |
|
1891 |
\macro void Q_ASSERT(bool test) |
|
1892 |
\relates <QtGlobal> |
|
1893 |
||
1894 |
Prints a warning message containing the source code file name and |
|
1895 |
line number if \a test is false. |
|
1896 |
||
1897 |
Q_ASSERT() is useful for testing pre- and post-conditions |
|
1898 |
during development. It does nothing if \c QT_NO_DEBUG was defined |
|
1899 |
during compilation. |
|
1900 |
||
1901 |
Example: |
|
1902 |
||
1903 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 17 |
|
1904 |
||
1905 |
If \c b is zero, the Q_ASSERT statement will output the following |
|
1906 |
message using the qFatal() function: |
|
1907 |
||
1908 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 18 |
|
1909 |
||
1910 |
\sa Q_ASSERT_X(), qFatal(), {Debugging Techniques} |
|
1911 |
*/ |
|
1912 |
||
1913 |
/*! |
|
1914 |
\macro void Q_ASSERT_X(bool test, const char *where, const char *what) |
|
1915 |
\relates <QtGlobal> |
|
1916 |
||
1917 |
Prints the message \a what together with the location \a where, |
|
1918 |
the source file name and line number if \a test is false. |
|
1919 |
||
1920 |
Q_ASSERT_X is useful for testing pre- and post-conditions during |
|
1921 |
development. It does nothing if \c QT_NO_DEBUG was defined during |
|
1922 |
compilation. |
|
1923 |
||
1924 |
Example: |
|
1925 |
||
1926 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 19 |
|
1927 |
||
1928 |
If \c b is zero, the Q_ASSERT_X statement will output the following |
|
1929 |
message using the qFatal() function: |
|
1930 |
||
1931 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 20 |
|
1932 |
||
1933 |
\sa Q_ASSERT(), qFatal(), {Debugging Techniques} |
|
1934 |
*/ |
|
1935 |
||
1936 |
/*! |
|
1937 |
\macro void Q_CHECK_PTR(void *pointer) |
|
1938 |
\relates <QtGlobal> |
|
1939 |
||
1940 |
If \a pointer is 0, prints a warning message containing the source |
|
1941 |
code's file name and line number, saying that the program ran out |
|
1942 |
of memory. |
|
1943 |
||
1944 |
Q_CHECK_PTR does nothing if \c QT_NO_DEBUG was defined during |
|
1945 |
compilation. |
|
1946 |
||
1947 |
Example: |
|
1948 |
||
1949 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 21 |
|
1950 |
||
1951 |
\sa qWarning(), {Debugging Techniques} |
|
1952 |
*/ |
|
1953 |
||
1954 |
/*! |
|
1955 |
\fn T *q_check_ptr(T *pointer) |
|
1956 |
\relates <QtGlobal> |
|
1957 |
||
1958 |
Users Q_CHECK_PTR on \a pointer, then returns \a pointer. |
|
1959 |
||
1960 |
This can be used as an inline version of Q_CHECK_PTR. |
|
1961 |
*/ |
|
1962 |
||
1963 |
/*! |
|
1964 |
\macro const char* Q_FUNC_INFO() |
|
1965 |
\relates <QtGlobal> |
|
1966 |
||
1967 |
Expands to a string that describe the function the macro resides in. How this string looks |
|
1968 |
more specifically is compiler dependent. With GNU GCC it is typically the function signature, |
|
1969 |
while with other compilers it might be the line and column number. |
|
1970 |
||
1971 |
Q_FUNC_INFO can be conveniently used with qDebug(). For example, this function: |
|
1972 |
||
1973 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 22 |
|
1974 |
||
1975 |
when instantiated with the integer type, will with the GCC compiler produce: |
|
1976 |
||
1977 |
\tt{const TInputType& myMin(const TInputType&, const TInputType&) [with TInputType = int] was called with value1: 3 value2: 4} |
|
1978 |
||
1979 |
If this macro is used outside a function, the behavior is undefined. |
|
1980 |
*/ |
|
1981 |
||
1982 |
/* |
|
1983 |
The Q_CHECK_PTR macro calls this function if an allocation check |
|
1984 |
fails. |
|
1985 |
*/ |
|
1986 |
void qt_check_pointer(const char *n, int l) |
|
1987 |
{ |
|
1988 |
qWarning("In file %s, line %d: Out of memory", n, l); |
|
1989 |
} |
|
1990 |
||
1991 |
/* \internal |
|
1992 |
Allows you to throw an exception without including <new> |
|
1993 |
Called internally from Q_CHECK_PTR on certain OS combinations |
|
1994 |
*/ |
|
1995 |
void qBadAlloc() |
|
1996 |
{ |
|
1997 |
QT_THROW(std::bad_alloc()); |
|
1998 |
} |
|
1999 |
||
2000 |
/* |
|
2001 |
The Q_ASSERT macro calls this function when the test fails. |
|
2002 |
*/ |
|
2003 |
void qt_assert(const char *assertion, const char *file, int line) |
|
2004 |
{ |
|
2005 |
qFatal("ASSERT: \"%s\" in file %s, line %d", assertion, file, line); |
|
2006 |
} |
|
2007 |
||
2008 |
/* |
|
2009 |
The Q_ASSERT_X macro calls this function when the test fails. |
|
2010 |
*/ |
|
2011 |
void qt_assert_x(const char *where, const char *what, const char *file, int line) |
|
2012 |
{ |
|
2013 |
qFatal("ASSERT failure in %s: \"%s\", file %s, line %d", where, what, file, line); |
|
2014 |
} |
|
2015 |
||
2016 |
||
2017 |
/* |
|
2018 |
Dijkstra's bisection algorithm to find the square root of an integer. |
|
2019 |
Deliberately not exported as part of the Qt API, but used in both |
|
2020 |
qsimplerichtext.cpp and qgfxraster_qws.cpp |
|
2021 |
*/ |
|
2022 |
Q_CORE_EXPORT unsigned int qt_int_sqrt(unsigned int n) |
|
2023 |
{ |
|
2024 |
// n must be in the range 0...UINT_MAX/2-1 |
|
2025 |
if (n >= (UINT_MAX>>2)) { |
|
2026 |
unsigned int r = 2 * qt_int_sqrt(n / 4); |
|
2027 |
unsigned int r2 = r + 1; |
|
2028 |
return (n >= r2 * r2) ? r2 : r; |
|
2029 |
} |
|
2030 |
uint h, p= 0, q= 1, r= n; |
|
2031 |
while (q <= n) |
|
2032 |
q <<= 2; |
|
2033 |
while (q != 1) { |
|
2034 |
q >>= 2; |
|
2035 |
h= p + q; |
|
2036 |
p >>= 1; |
|
2037 |
if (r >= h) { |
|
2038 |
p += q; |
|
2039 |
r -= h; |
|
2040 |
} |
|
2041 |
} |
|
2042 |
return p; |
|
2043 |
} |
|
2044 |
||
2045 |
#if defined(qMemCopy) |
|
2046 |
# undef qMemCopy |
|
2047 |
#endif |
|
2048 |
#if defined(qMemSet) |
|
2049 |
# undef qMemSet |
|
2050 |
#endif |
|
2051 |
||
2052 |
void *qMemCopy(void *dest, const void *src, size_t n) { return memcpy(dest, src, n); } |
|
2053 |
void *qMemSet(void *dest, int c, size_t n) { return memset(dest, c, n); } |
|
2054 |
||
2055 |
static QtMsgHandler handler = 0; // pointer to debug handler |
|
2056 |
||
2057 |
#if defined(Q_CC_MWERKS) && defined(Q_OS_MACX) |
|
2058 |
extern bool qt_is_gui_used; |
|
2059 |
static void mac_default_handler(const char *msg) |
|
2060 |
{ |
|
2061 |
if (qt_is_gui_used) { |
|
2062 |
Str255 pmsg; |
|
2063 |
qt_mac_to_pascal_string(msg, pmsg); |
|
2064 |
DebugStr(pmsg); |
|
2065 |
} else { |
|
2066 |
fprintf(stderr, msg); |
|
2067 |
} |
|
2068 |
} |
|
2069 |
#endif // Q_CC_MWERKS && Q_OS_MACX |
|
2070 |
||
23
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2071 |
#if !defined(Q_OS_WIN) && !defined(QT_NO_THREAD) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) && \ |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2072 |
defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2073 |
namespace { |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2074 |
// There are two incompatible versions of strerror_r: |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2075 |
// a) the XSI/POSIX.1 version, which returns an int, |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2076 |
// indicating success or not |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2077 |
// b) the GNU version, which returns a char*, which may or may not |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2078 |
// be the beginning of the buffer we used |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2079 |
// The GNU libc manpage for strerror_r says you should use the the XSI |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2080 |
// version in portable code. However, it's impossible to do that if |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2081 |
// _GNU_SOURCE is defined so we use C++ overloading to decide what to do |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2082 |
// depending on the return type |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2083 |
static inline QString fromstrerror_helper(int, const QByteArray &buf) |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2084 |
{ |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2085 |
return QString::fromLocal8Bit(buf); |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2086 |
} |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2087 |
static inline QString fromstrerror_helper(const char *str, const QByteArray &) |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2088 |
{ |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2089 |
return QString::fromLocal8Bit(str); |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2090 |
} |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2091 |
} |
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2092 |
#endif |
0 | 2093 |
|
2094 |
QString qt_error_string(int errorCode) |
|
2095 |
{ |
|
2096 |
const char *s = 0; |
|
2097 |
QString ret; |
|
2098 |
if (errorCode == -1) { |
|
2099 |
#if defined(Q_OS_WIN) |
|
2100 |
errorCode = GetLastError(); |
|
2101 |
#else |
|
2102 |
errorCode = errno; |
|
2103 |
#endif |
|
2104 |
} |
|
2105 |
switch (errorCode) { |
|
2106 |
case 0: |
|
2107 |
break; |
|
2108 |
case EACCES: |
|
2109 |
s = QT_TRANSLATE_NOOP("QIODevice", "Permission denied"); |
|
2110 |
break; |
|
2111 |
case EMFILE: |
|
2112 |
s = QT_TRANSLATE_NOOP("QIODevice", "Too many open files"); |
|
2113 |
break; |
|
2114 |
case ENOENT: |
|
2115 |
s = QT_TRANSLATE_NOOP("QIODevice", "No such file or directory"); |
|
2116 |
break; |
|
2117 |
case ENOSPC: |
|
2118 |
s = QT_TRANSLATE_NOOP("QIODevice", "No space left on device"); |
|
2119 |
break; |
|
2120 |
default: { |
|
2121 |
#ifdef Q_OS_WIN |
|
2122 |
wchar_t *string = 0; |
|
2123 |
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, |
|
2124 |
NULL, |
|
2125 |
errorCode, |
|
2126 |
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
|
2127 |
(LPWSTR)&string, |
|
2128 |
0, |
|
2129 |
NULL); |
|
2130 |
ret = QString::fromWCharArray(string); |
|
2131 |
LocalFree((HLOCAL)string); |
|
2132 |
||
2133 |
if (ret.isEmpty() && errorCode == ERROR_MOD_NOT_FOUND) |
|
2134 |
ret = QString::fromLatin1("The specified module could not be found."); |
|
2135 |
#elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) |
|
2136 |
QByteArray buf(1024, '\0'); |
|
23
89e065397ea6
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
2137 |
ret = fromstrerror_helper(strerror_r(errorCode, buf.data(), buf.size()), buf); |
0 | 2138 |
#else |
2139 |
ret = QString::fromLocal8Bit(strerror(errorCode)); |
|
2140 |
#endif |
|
2141 |
break; } |
|
2142 |
} |
|
2143 |
if (s) |
|
2144 |
// ######## this breaks moc build currently |
|
2145 |
// ret = QCoreApplication::translate("QIODevice", s); |
|
2146 |
ret = QString::fromLatin1(s); |
|
2147 |
return ret.trimmed(); |
|
2148 |
} |
|
2149 |
||
2150 |
||
2151 |
/*! |
|
2152 |
\fn QtMsgHandler qInstallMsgHandler(QtMsgHandler handler) |
|
2153 |
\relates <QtGlobal> |
|
2154 |
||
2155 |
Installs a Qt message \a handler which has been defined |
|
2156 |
previously. Returns a pointer to the previous message handler |
|
2157 |
(which may be 0). |
|
2158 |
||
2159 |
The message handler is a function that prints out debug messages, |
|
2160 |
warnings, critical and fatal error messages. The Qt library (debug |
|
2161 |
mode) contains hundreds of warning messages that are printed |
|
2162 |
when internal errors (usually invalid function arguments) |
|
2163 |
occur. Qt built in release mode also contains such warnings unless |
|
2164 |
QT_NO_WARNING_OUTPUT and/or QT_NO_DEBUG_OUTPUT have been set during |
|
2165 |
compilation. If you implement your own message handler, you get total |
|
2166 |
control of these messages. |
|
2167 |
||
2168 |
The default message handler prints the message to the standard |
|
2169 |
output under X11 or to the debugger under Windows. If it is a |
|
2170 |
fatal message, the application aborts immediately. |
|
2171 |
||
2172 |
Only one message handler can be defined, since this is usually |
|
2173 |
done on an application-wide basis to control debug output. |
|
2174 |
||
2175 |
To restore the message handler, call \c qInstallMsgHandler(0). |
|
2176 |
||
2177 |
Example: |
|
2178 |
||
2179 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 23 |
|
2180 |
||
2181 |
\sa qDebug(), qWarning(), qCritical(), qFatal(), QtMsgType, |
|
2182 |
{Debugging Techniques} |
|
2183 |
*/ |
|
2184 |
#if defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB) |
|
2185 |
extern bool usingWinMain; |
|
2186 |
extern Q_CORE_EXPORT void qWinMsgHandler(QtMsgType t, const char* str); |
|
2187 |
#endif |
|
2188 |
||
2189 |
QtMsgHandler qInstallMsgHandler(QtMsgHandler h) |
|
2190 |
{ |
|
2191 |
QtMsgHandler old = handler; |
|
2192 |
handler = h; |
|
2193 |
#if defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB) |
|
2194 |
if (!handler && usingWinMain) |
|
2195 |
handler = qWinMsgHandler; |
|
2196 |
#endif |
|
2197 |
return old; |
|
2198 |
} |
|
2199 |
||
2200 |
/*! |
|
2201 |
\internal |
|
2202 |
*/ |
|
2203 |
void qt_message_output(QtMsgType msgType, const char *buf) |
|
2204 |
{ |
|
2205 |
if (handler) { |
|
2206 |
(*handler)(msgType, buf); |
|
2207 |
} else { |
|
2208 |
#if defined(Q_CC_MWERKS) && defined(Q_OS_MACX) |
|
2209 |
mac_default_handler(buf); |
|
2210 |
#elif defined(Q_OS_WINCE) |
|
2211 |
QString fstr = QString::fromLatin1(buf); |
|
2212 |
fstr += QLatin1Char('\n'); |
|
2213 |
OutputDebugString(reinterpret_cast<const wchar_t *> (fstr.utf16())); |
|
2214 |
#elif defined(Q_OS_SYMBIAN) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2215 |
// RDebug::Print has a cap of 256 characters so break it up |
0 | 2216 |
_LIT(format, "[Qt Message] %S"); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2217 |
const int maxBlockSize = 256 - ((const TDesC &)format).Length(); |
0 | 2218 |
const TPtrC8 ptr(reinterpret_cast<const TUint8*>(buf)); |
2219 |
HBufC* hbuffer = q_check_ptr(HBufC::New(qMin(maxBlockSize, ptr.Length()))); |
|
2220 |
for (int i = 0; i < ptr.Length(); i += hbuffer->Length()) { |
|
2221 |
hbuffer->Des().Copy(ptr.Mid(i, qMin(maxBlockSize, ptr.Length()-i))); |
|
2222 |
RDebug::Print(format, hbuffer); |
|
2223 |
} |
|
2224 |
delete hbuffer; |
|
2225 |
_LIT( KLogDir, "QT" ); |
|
2226 |
_LIT( KLogFile, "QT.log" ); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2227 |
_LIT( KLogStarting, "Starting: %S"); |
0 | 2228 |
static bool logStarted; |
2229 |
if ( !logStarted ){ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2230 |
RProcess curProc; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2231 |
TBuf<KMaxFullName + 20> procName; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2232 |
TFullName fullName = curProc.FullName(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2233 |
procName.Format(KLogStarting, &fullName); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2234 |
RFileLogger::Write( KLogDir, KLogFile, EFileLoggingModeAppend, procName); |
0 | 2235 |
logStarted = true; |
2236 |
} |
|
2237 |
||
2238 |
RFileLogger::Write( KLogDir, KLogFile, EFileLoggingModeAppend, ptr ); |
|
2239 |
#else |
|
2240 |
fprintf(stderr, "%s\n", buf); |
|
2241 |
fflush(stderr); |
|
2242 |
#endif |
|
2243 |
} |
|
2244 |
||
2245 |
if (msgType == QtFatalMsg |
|
2246 |
|| (msgType == QtWarningMsg |
|
2247 |
&& (!qgetenv("QT_FATAL_WARNINGS").isNull())) ) { |
|
2248 |
||
2249 |
#if defined(Q_CC_MSVC) && defined(QT_DEBUG) && defined(_DEBUG) && defined(_CRT_ERROR) |
|
2250 |
// get the current report mode |
|
2251 |
int reportMode = _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_WNDW); |
|
2252 |
_CrtSetReportMode(_CRT_ERROR, reportMode); |
|
2253 |
#if !defined(Q_OS_WINCE) |
|
2254 |
int ret = _CrtDbgReport(_CRT_ERROR, __FILE__, __LINE__, QT_VERSION_STR, buf); |
|
2255 |
#else |
|
2256 |
int ret = _CrtDbgReportW(_CRT_ERROR, _CRT_WIDE(__FILE__), |
|
2257 |
__LINE__, _CRT_WIDE(QT_VERSION_STR), reinterpret_cast<const wchar_t *> (QString::fromLatin1(buf).utf16())); |
|
2258 |
#endif |
|
2259 |
if (ret == 0 && reportMode & _CRTDBG_MODE_WNDW) |
|
2260 |
return; // ignore |
|
2261 |
else if (ret == 1) |
|
2262 |
_CrtDbgBreak(); |
|
2263 |
#endif |
|
2264 |
||
2265 |
#if defined(Q_OS_SYMBIAN) |
|
2266 |
__DEBUGGER(); // on the emulator, get the debugger to kick in if there's one around |
|
2267 |
TBuf<256> tmp; |
|
2268 |
TPtrC8 ptr(reinterpret_cast<const TUint8*>(buf)); |
|
2269 |
TInt len = Min(tmp.MaxLength(), ptr.Length()); |
|
2270 |
tmp.Copy(ptr.Left(len)); |
|
2271 |
// Panic the current thread. We don't use real panic codes, so 0 has no special meaning. |
|
2272 |
User::Panic(tmp, 0); |
|
2273 |
#elif (defined(Q_OS_UNIX) || defined(Q_CC_MINGW)) |
|
2274 |
abort(); // trap; generates core dump |
|
2275 |
#else |
|
2276 |
exit(1); // goodbye cruel world |
|
2277 |
#endif |
|
2278 |
} |
|
2279 |
} |
|
2280 |
||
2281 |
#if !defined(QT_NO_EXCEPTIONS) |
|
2282 |
/*! |
|
2283 |
\internal |
|
2284 |
Uses a local buffer to output the message. Not locale safe + cuts off |
|
2285 |
everything after character 255, but will work in out of memory situations. |
|
2286 |
*/ |
|
2287 |
static void qEmergencyOut(QtMsgType msgType, const char *msg, va_list ap) |
|
2288 |
{ |
|
2289 |
char emergency_buf[256] = { '\0' }; |
|
2290 |
emergency_buf[255] = '\0'; |
|
2291 |
if (msg) |
|
2292 |
qvsnprintf(emergency_buf, 255, msg, ap); |
|
2293 |
qt_message_output(msgType, emergency_buf); |
|
2294 |
} |
|
2295 |
#endif |
|
2296 |
||
2297 |
/*! |
|
2298 |
\internal |
|
2299 |
*/ |
|
2300 |
static void qt_message(QtMsgType msgType, const char *msg, va_list ap) |
|
2301 |
{ |
|
2302 |
#if !defined(QT_NO_EXCEPTIONS) |
|
2303 |
if (std::uncaught_exception()) { |
|
2304 |
qEmergencyOut(msgType, msg, ap); |
|
2305 |
return; |
|
2306 |
} |
|
2307 |
#endif |
|
2308 |
QByteArray buf; |
|
2309 |
if (msg) { |
|
2310 |
QT_TRY { |
|
2311 |
buf = QString().vsprintf(msg, ap).toLocal8Bit(); |
|
2312 |
} QT_CATCH(const std::bad_alloc &) { |
|
2313 |
#if !defined(QT_NO_EXCEPTIONS) |
|
2314 |
qEmergencyOut(msgType, msg, ap); |
|
2315 |
// don't rethrow - we use qWarning and friends in destructors. |
|
2316 |
return; |
|
2317 |
#endif |
|
2318 |
} |
|
2319 |
} |
|
2320 |
qt_message_output(msgType, buf.constData()); |
|
2321 |
} |
|
2322 |
||
2323 |
#undef qDebug |
|
2324 |
/*! |
|
2325 |
\relates <QtGlobal> |
|
2326 |
||
2327 |
Calls the message handler with the debug message \a msg. If no |
|
2328 |
message handler has been installed, the message is printed to |
|
2329 |
stderr. Under Windows, the message is sent to the console, if it is a |
|
2330 |
console application; otherwise, it is sent to the debugger. This |
|
2331 |
function does nothing if \c QT_NO_DEBUG_OUTPUT was defined |
|
2332 |
during compilation. |
|
2333 |
||
2334 |
If you pass the function a format string and a list of arguments, |
|
2335 |
it works in similar way to the C printf() function. The format |
|
2336 |
should be a Latin-1 string. |
|
2337 |
||
2338 |
Example: |
|
2339 |
||
2340 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 24 |
|
2341 |
||
2342 |
If you include \c <QtDebug>, a more convenient syntax is also |
|
2343 |
available: |
|
2344 |
||
2345 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 25 |
|
2346 |
||
2347 |
With this syntax, the function returns a QDebug object that is |
|
2348 |
configured to use the QtDebugMsg message type. It automatically |
|
2349 |
puts a single space between each item, and outputs a newline at |
|
2350 |
the end. It supports many C++ and Qt types. |
|
2351 |
||
2352 |
To suppress the output at run-time, install your own message handler |
|
2353 |
with qInstallMsgHandler(). |
|
2354 |
||
2355 |
\sa qWarning(), qCritical(), qFatal(), qInstallMsgHandler(), |
|
2356 |
{Debugging Techniques} |
|
2357 |
*/ |
|
2358 |
void qDebug(const char *msg, ...) |
|
2359 |
{ |
|
2360 |
va_list ap; |
|
2361 |
va_start(ap, msg); // use variable arg list |
|
2362 |
qt_message(QtDebugMsg, msg, ap); |
|
2363 |
va_end(ap); |
|
2364 |
} |
|
2365 |
||
2366 |
#undef qWarning |
|
2367 |
/*! |
|
2368 |
\relates <QtGlobal> |
|
2369 |
||
2370 |
Calls the message handler with the warning message \a msg. If no |
|
2371 |
message handler has been installed, the message is printed to |
|
2372 |
stderr. Under Windows, the message is sent to the debugger. This |
|
2373 |
function does nothing if \c QT_NO_WARNING_OUTPUT was defined |
|
2374 |
during compilation; it exits if the environment variable \c |
|
2375 |
QT_FATAL_WARNINGS is defined. |
|
2376 |
||
2377 |
This function takes a format string and a list of arguments, |
|
2378 |
similar to the C printf() function. The format should be a Latin-1 |
|
2379 |
string. |
|
2380 |
||
2381 |
Example: |
|
2382 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 26 |
|
2383 |
||
2384 |
If you include <QtDebug>, a more convenient syntax is |
|
2385 |
also available: |
|
2386 |
||
2387 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 27 |
|
2388 |
||
2389 |
This syntax inserts a space between each item, and |
|
2390 |
appends a newline at the end. |
|
2391 |
||
2392 |
To supress the output at runtime, install your own message handler |
|
2393 |
with qInstallMsgHandler(). |
|
2394 |
||
2395 |
\sa qDebug(), qCritical(), qFatal(), qInstallMsgHandler(), |
|
2396 |
{Debugging Techniques} |
|
2397 |
*/ |
|
2398 |
void qWarning(const char *msg, ...) |
|
2399 |
{ |
|
2400 |
va_list ap; |
|
2401 |
va_start(ap, msg); // use variable arg list |
|
2402 |
qt_message(QtWarningMsg, msg, ap); |
|
2403 |
va_end(ap); |
|
2404 |
} |
|
2405 |
||
2406 |
/*! |
|
2407 |
\relates <QtGlobal> |
|
2408 |
||
2409 |
Calls the message handler with the critical message \a msg. If no |
|
2410 |
message handler has been installed, the message is printed to |
|
2411 |
stderr. Under Windows, the message is sent to the debugger. |
|
2412 |
||
2413 |
This function takes a format string and a list of arguments, |
|
2414 |
similar to the C printf() function. The format should be a Latin-1 |
|
2415 |
string. |
|
2416 |
||
2417 |
Example: |
|
2418 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 28 |
|
2419 |
||
2420 |
If you include <QtDebug>, a more convenient syntax is |
|
2421 |
also available: |
|
2422 |
||
2423 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 29 |
|
2424 |
||
2425 |
A space is inserted between the items, and a newline is |
|
2426 |
appended at the end. |
|
2427 |
||
2428 |
To supress the output at runtime, install your own message handler |
|
2429 |
with qInstallMsgHandler(). |
|
2430 |
||
2431 |
\sa qDebug(), qWarning(), qFatal(), qInstallMsgHandler(), |
|
2432 |
{Debugging Techniques} |
|
2433 |
*/ |
|
2434 |
void qCritical(const char *msg, ...) |
|
2435 |
{ |
|
2436 |
va_list ap; |
|
2437 |
va_start(ap, msg); // use variable arg list |
|
2438 |
qt_message(QtCriticalMsg, msg, ap); |
|
2439 |
va_end(ap); |
|
2440 |
} |
|
2441 |
||
2442 |
#ifdef QT3_SUPPORT |
|
2443 |
void qSystemWarning(const char *msg, int code) |
|
2444 |
{ qCritical("%s (%s)", msg, qt_error_string(code).toLocal8Bit().constData()); } |
|
2445 |
#endif // QT3_SUPPORT |
|
2446 |
||
2447 |
void qErrnoWarning(const char *msg, ...) |
|
2448 |
{ |
|
2449 |
// qt_error_string() will allocate anyway, so we don't have |
|
2450 |
// to be careful here (like we do in plain qWarning()) |
|
2451 |
QString buf; |
|
2452 |
va_list ap; |
|
2453 |
va_start(ap, msg); |
|
2454 |
if (msg) |
|
2455 |
buf.vsprintf(msg, ap); |
|
2456 |
va_end(ap); |
|
2457 |
||
2458 |
qCritical("%s (%s)", buf.toLocal8Bit().constData(), qt_error_string(-1).toLocal8Bit().constData()); |
|
2459 |
} |
|
2460 |
||
2461 |
void qErrnoWarning(int code, const char *msg, ...) |
|
2462 |
{ |
|
2463 |
// qt_error_string() will allocate anyway, so we don't have |
|
2464 |
// to be careful here (like we do in plain qWarning()) |
|
2465 |
QString buf; |
|
2466 |
va_list ap; |
|
2467 |
va_start(ap, msg); |
|
2468 |
if (msg) |
|
2469 |
buf.vsprintf(msg, ap); |
|
2470 |
va_end(ap); |
|
2471 |
||
2472 |
qCritical("%s (%s)", buf.toLocal8Bit().constData(), qt_error_string(code).toLocal8Bit().constData()); |
|
2473 |
} |
|
2474 |
||
2475 |
/*! |
|
2476 |
\relates <QtGlobal> |
|
2477 |
||
2478 |
Calls the message handler with the fatal message \a msg. If no |
|
2479 |
message handler has been installed, the message is printed to |
|
2480 |
stderr. Under Windows, the message is sent to the debugger. |
|
2481 |
||
2482 |
If you are using the \bold{default message handler} this function will |
|
2483 |
abort on Unix systems to create a core dump. On Windows, for debug builds, |
|
2484 |
this function will report a _CRT_ERROR enabling you to connect a debugger |
|
2485 |
to the application. |
|
2486 |
||
2487 |
This function takes a format string and a list of arguments, |
|
2488 |
similar to the C printf() function. |
|
2489 |
||
2490 |
Example: |
|
2491 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 30 |
|
2492 |
||
2493 |
To supress the output at runtime, install your own message handler |
|
2494 |
with qInstallMsgHandler(). |
|
2495 |
||
2496 |
\sa qDebug(), qCritical(), qWarning(), qInstallMsgHandler(), |
|
2497 |
{Debugging Techniques} |
|
2498 |
*/ |
|
2499 |
void qFatal(const char *msg, ...) |
|
2500 |
{ |
|
2501 |
va_list ap; |
|
2502 |
va_start(ap, msg); // use variable arg list |
|
2503 |
qt_message(QtFatalMsg, msg, ap); |
|
2504 |
va_end(ap); |
|
2505 |
} |
|
2506 |
||
2507 |
// getenv is declared as deprecated in VS2005. This function |
|
2508 |
// makes use of the new secure getenv function. |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2509 |
/*! |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2510 |
\relates <QtGlobal> |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2511 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2512 |
Returns the value of the environment variable with name \a |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2513 |
varName. To get the variable string, use QByteArray::constData(). |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2514 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2515 |
\note qgetenv() was introduced because getenv() from the standard |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2516 |
C library was deprecated in VC2005 (and later versions). qgetenv() |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2517 |
uses the new replacement function in VC, and calls the standard C |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2518 |
library's implementation on all other platforms. |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2519 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2520 |
\sa qputenv() |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2521 |
*/ |
0 | 2522 |
QByteArray qgetenv(const char *varName) |
2523 |
{ |
|
2524 |
#if defined(_MSC_VER) && _MSC_VER >= 1400 |
|
2525 |
size_t requiredSize = 0; |
|
2526 |
QByteArray buffer; |
|
2527 |
getenv_s(&requiredSize, 0, 0, varName); |
|
2528 |
if (requiredSize == 0) |
|
2529 |
return buffer; |
|
2530 |
buffer.resize(int(requiredSize)); |
|
2531 |
getenv_s(&requiredSize, buffer.data(), requiredSize, varName); |
|
2532 |
// requiredSize includes the terminating null, which we don't want. |
|
2533 |
Q_ASSERT(buffer.endsWith('\0')); |
|
2534 |
buffer.chop(1); |
|
2535 |
return buffer; |
|
2536 |
#else |
|
2537 |
return QByteArray(::getenv(varName)); |
|
2538 |
#endif |
|
2539 |
} |
|
2540 |
||
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2541 |
/*! |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2542 |
\relates <QtGlobal> |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2543 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2544 |
This function sets the \a value of the environment variable named |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2545 |
\a varName. It will create the variable if it does not exist. It |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2546 |
returns 0 if the variable could not be set. |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2547 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2548 |
\note qputenv() was introduced because putenv() from the standard |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2549 |
C library was deprecated in VC2005 (and later versions). qputenv() |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2550 |
uses the replacement function in VC, and calls the standard C |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2551 |
library's implementation on all other platforms. |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2552 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2553 |
\sa qgetenv() |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2554 |
*/ |
0 | 2555 |
bool qputenv(const char *varName, const QByteArray& value) |
2556 |
{ |
|
2557 |
#if defined(_MSC_VER) && _MSC_VER >= 1400 |
|
2558 |
return _putenv_s(varName, value.constData()) == 0; |
|
2559 |
#else |
|
2560 |
QByteArray buffer(varName); |
|
2561 |
buffer += '='; |
|
2562 |
buffer += value; |
|
2563 |
char* envVar = qstrdup(buffer.constData()); |
|
2564 |
int result = putenv(envVar); |
|
2565 |
if (result != 0) // error. we have to delete the string. |
|
2566 |
delete[] envVar; |
|
2567 |
return result == 0; |
|
2568 |
#endif |
|
2569 |
} |
|
2570 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2571 |
#if (defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) |
0 | 2572 |
|
2573 |
# if defined(Q_OS_INTEGRITY) && defined(__GHS_VERSION_NUMBER) && (__GHS_VERSION_NUMBER < 500) |
|
2574 |
// older versions of INTEGRITY used a long instead of a uint for the seed. |
|
2575 |
typedef long SeedStorageType; |
|
2576 |
# else |
|
2577 |
typedef uint SeedStorageType; |
|
2578 |
# endif |
|
2579 |
||
2580 |
typedef QThreadStorage<SeedStorageType *> SeedStorage; |
|
2581 |
Q_GLOBAL_STATIC(SeedStorage, randTLS) // Thread Local Storage for seed value |
|
2582 |
||
2583 |
#endif |
|
2584 |
||
2585 |
/*! |
|
2586 |
\relates <QtGlobal> |
|
2587 |
\since 4.2 |
|
2588 |
||
2589 |
Thread-safe version of the standard C++ \c srand() function. |
|
2590 |
||
2591 |
Sets the argument \a seed to be used to generate a new random number sequence of |
|
2592 |
pseudo random integers to be returned by qrand(). |
|
2593 |
||
2594 |
The sequence of random numbers generated is deterministic per thread. For example, |
|
2595 |
if two threads call qsrand(1) and subsequently calls qrand(), the threads will get |
|
2596 |
the same random number sequence. |
|
2597 |
||
2598 |
\sa qrand() |
|
2599 |
*/ |
|
2600 |
void qsrand(uint seed) |
|
2601 |
{ |
|
2602 |
#if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2603 |
SeedStorage *seedStorage = randTLS(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2604 |
if (seedStorage) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2605 |
SeedStorageType *pseed = seedStorage->localData(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2606 |
if (!pseed) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2607 |
seedStorage->setLocalData(pseed = new SeedStorageType); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2608 |
*pseed = seed; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2609 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2610 |
//golbal static seed storage should always exist, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2611 |
//except after being deleted by QGlobalStaticDeleter. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2612 |
//But since it still can be called from destructor of another |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2613 |
//global static object, fallback to sqrand(seed) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2614 |
srand(seed); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2615 |
} |
0 | 2616 |
#else |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2617 |
// On Windows and Symbian srand() and rand() already use Thread-Local-Storage |
0 | 2618 |
// to store the seed between calls |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2619 |
// this is also valid for QT_NO_THREAD |
0 | 2620 |
srand(seed); |
2621 |
#endif |
|
2622 |
} |
|
2623 |
||
2624 |
/*! |
|
2625 |
\relates <QtGlobal> |
|
2626 |
\since 4.2 |
|
2627 |
||
2628 |
Thread-safe version of the standard C++ \c rand() function. |
|
2629 |
||
2630 |
Returns a value between 0 and \c RAND_MAX (defined in \c <cstdlib> and |
|
2631 |
\c <stdlib.h>), the next number in the current sequence of pseudo-random |
|
2632 |
integers. |
|
2633 |
||
2634 |
Use \c qsrand() to initialize the pseudo-random number generator with |
|
2635 |
a seed value. |
|
2636 |
||
2637 |
\sa qsrand() |
|
2638 |
*/ |
|
2639 |
int qrand() |
|
2640 |
{ |
|
2641 |
#if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2642 |
SeedStorage *seedStorage = randTLS(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2643 |
if (seedStorage) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2644 |
SeedStorageType *pseed = seedStorage->localData(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2645 |
if (!pseed) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2646 |
seedStorage->setLocalData(pseed = new SeedStorageType); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2647 |
*pseed = 1; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2648 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2649 |
return rand_r(pseed); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2650 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2651 |
//golbal static seed storage should always exist, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2652 |
//except after being deleted by QGlobalStaticDeleter. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2653 |
//But since it still can be called from destructor of another |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2654 |
//global static object, fallback to qrand() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2655 |
return rand(); |
0 | 2656 |
} |
2657 |
#else |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2658 |
// On Windows and Symbian srand() and rand() already use Thread-Local-Storage |
0 | 2659 |
// to store the seed between calls |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2660 |
// this is also valid for QT_NO_THREAD |
0 | 2661 |
return rand(); |
2662 |
#endif |
|
2663 |
} |
|
2664 |
||
2665 |
/*! |
|
2666 |
\macro forever |
|
2667 |
\relates <QtGlobal> |
|
2668 |
||
2669 |
This macro is provided for convenience for writing infinite |
|
2670 |
loops. |
|
2671 |
||
2672 |
Example: |
|
2673 |
||
2674 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 31 |
|
2675 |
||
2676 |
It is equivalent to \c{for (;;)}. |
|
2677 |
||
2678 |
If you're worried about namespace pollution, you can disable this |
|
2679 |
macro by adding the following line to your \c .pro file: |
|
2680 |
||
2681 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 32 |
|
2682 |
||
2683 |
\sa Q_FOREVER |
|
2684 |
*/ |
|
2685 |
||
2686 |
/*! |
|
2687 |
\macro Q_FOREVER |
|
2688 |
\relates <QtGlobal> |
|
2689 |
||
2690 |
Same as \l{forever}. |
|
2691 |
||
2692 |
This macro is available even when \c no_keywords is specified |
|
2693 |
using the \c .pro file's \c CONFIG variable. |
|
2694 |
||
2695 |
\sa foreach() |
|
2696 |
*/ |
|
2697 |
||
2698 |
/*! |
|
2699 |
\macro foreach(variable, container) |
|
2700 |
\relates <QtGlobal> |
|
2701 |
||
2702 |
This macro is used to implement Qt's \c foreach loop. The \a |
|
2703 |
variable parameter is a variable name or variable definition; the |
|
2704 |
\a container parameter is a Qt container whose value type |
|
2705 |
corresponds to the type of the variable. See \l{The foreach |
|
2706 |
Keyword} for details. |
|
2707 |
||
2708 |
If you're worried about namespace pollution, you can disable this |
|
2709 |
macro by adding the following line to your \c .pro file: |
|
2710 |
||
2711 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 33 |
|
2712 |
||
2713 |
\sa Q_FOREACH() |
|
2714 |
*/ |
|
2715 |
||
2716 |
/*! |
|
2717 |
\macro Q_FOREACH(variable, container) |
|
2718 |
\relates <QtGlobal> |
|
2719 |
||
2720 |
Same as foreach(\a variable, \a container). |
|
2721 |
||
2722 |
This macro is available even when \c no_keywords is specified |
|
2723 |
using the \c .pro file's \c CONFIG variable. |
|
2724 |
||
2725 |
\sa foreach() |
|
2726 |
*/ |
|
2727 |
||
2728 |
/*! |
|
2729 |
\macro QT_TR_NOOP(sourceText) |
|
2730 |
\relates <QtGlobal> |
|
2731 |
||
2732 |
Marks the string literal \a sourceText for dynamic translation in |
|
2733 |
the current context (class), i.e the stored \a sourceText will not |
|
2734 |
be altered. |
|
2735 |
||
2736 |
The macro expands to \a sourceText. |
|
2737 |
||
2738 |
Example: |
|
2739 |
||
2740 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 34 |
|
2741 |
||
2742 |
The macro QT_TR_NOOP_UTF8() is identical except that it tells lupdate |
|
2743 |
that the source string is encoded in UTF-8. Corresponding variants |
|
2744 |
exist in the QT_TRANSLATE_NOOP() family of macros, too. Note that |
|
2745 |
using these macros is not required if \c CODECFORTR is already set to |
|
2746 |
UTF-8 in the qmake project file. |
|
2747 |
||
2748 |
\sa QT_TRANSLATE_NOOP(), {Internationalization with Qt} |
|
2749 |
*/ |
|
2750 |
||
2751 |
/*! |
|
2752 |
\macro QT_TRANSLATE_NOOP(context, sourceText) |
|
2753 |
\relates <QtGlobal> |
|
2754 |
||
2755 |
Marks the string literal \a sourceText for dynamic translation in |
|
2756 |
the given \a context; i.e, the stored \a sourceText will not be |
|
2757 |
altered. The \a context is typically a class and also needs to |
|
2758 |
be specified as string literal. |
|
2759 |
||
2760 |
The macro expands to \a sourceText. |
|
2761 |
||
2762 |
Example: |
|
2763 |
||
2764 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 35 |
|
2765 |
||
2766 |
\sa QT_TR_NOOP(), QT_TRANSLATE_NOOP3(), {Internationalization with Qt} |
|
2767 |
*/ |
|
2768 |
||
2769 |
/*! |
|
2770 |
\macro QT_TRANSLATE_NOOP3(context, sourceText, comment) |
|
2771 |
\relates <QtGlobal> |
|
2772 |
\since 4.4 |
|
2773 |
||
2774 |
Marks the string literal \a sourceText for dynamic translation in the |
|
2775 |
given \a context and with \a comment, i.e the stored \a sourceText will |
|
2776 |
not be altered. The \a context is typically a class and also needs to |
|
2777 |
be specified as string literal. The string literal \a comment |
|
2778 |
will be available for translators using e.g. Qt Linguist. |
|
2779 |
||
2780 |
The macro expands to anonymous struct of the two string |
|
2781 |
literals passed as \a sourceText and \a comment. |
|
2782 |
||
2783 |
Example: |
|
2784 |
||
2785 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 36 |
|
2786 |
||
2787 |
\sa QT_TR_NOOP(), QT_TRANSLATE_NOOP(), {Internationalization with Qt} |
|
2788 |
*/ |
|
2789 |
||
2790 |
/*! |
|
2791 |
\fn QString qtTrId(const char *id, int n = -1) |
|
2792 |
\relates <QtGlobal> |
|
2793 |
\reentrant |
|
2794 |
\since 4.6 |
|
2795 |
||
2796 |
\brief The qtTrId function finds and returns a translated string. |
|
2797 |
||
2798 |
Returns a translated string identified by \a id. |
|
2799 |
If no matching string is found, the id itself is returned. This |
|
2800 |
should not happen under normal conditions. |
|
2801 |
||
2802 |
If \a n >= 0, all occurrences of \c %n in the resulting string |
|
2803 |
are replaced with a decimal representation of \a n. In addition, |
|
2804 |
depending on \a n's value, the translation text may vary. |
|
2805 |
||
2806 |
Meta data and comments can be passed as documented for QObject::tr(). |
|
2807 |
In addition, it is possible to supply a source string template like that: |
|
2808 |
||
2809 |
\tt{//% <C string>} |
|
2810 |
||
2811 |
or |
|
2812 |
||
2813 |
\tt{\begincomment% <C string> \endcomment} |
|
2814 |
||
2815 |
Example: |
|
2816 |
||
2817 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp qttrid |
|
2818 |
||
2819 |
Creating QM files suitable for use with this function requires passing |
|
2820 |
the \c -idbased option to the \c lrelease tool. |
|
2821 |
||
2822 |
\warning This method is reentrant only if all translators are |
|
2823 |
installed \e before calling this method. Installing or removing |
|
2824 |
translators while performing translations is not supported. Doing |
|
2825 |
so will probably result in crashes or other undesirable behavior. |
|
2826 |
||
2827 |
\sa QObject::tr(), QCoreApplication::translate(), {Internationalization with Qt} |
|
2828 |
*/ |
|
2829 |
||
2830 |
/*! |
|
2831 |
\macro QT_TRID_NOOP(id) |
|
2832 |
\relates <QtGlobal> |
|
2833 |
\since 4.6 |
|
2834 |
||
2835 |
\brief The QT_TRID_NOOP macro marks an id for dynamic translation. |
|
2836 |
||
2837 |
The only purpose of this macro is to provide an anchor for attaching |
|
2838 |
meta data like to qtTrId(). |
|
2839 |
||
2840 |
The macro expands to \a id. |
|
2841 |
||
2842 |
Example: |
|
2843 |
||
2844 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp qttrid_noop |
|
2845 |
||
2846 |
\sa qtTrId(), {Internationalization with Qt} |
|
2847 |
*/ |
|
2848 |
||
2849 |
/*! |
|
2850 |
\macro QT_POINTER_SIZE |
|
2851 |
\relates <QtGlobal> |
|
2852 |
||
2853 |
Expands to the size of a pointer in bytes (4 or 8). This is |
|
2854 |
equivalent to \c sizeof(void *) but can be used in a preprocessor |
|
2855 |
directive. |
|
2856 |
*/ |
|
2857 |
||
2858 |
/*! |
|
2859 |
\macro TRUE |
|
2860 |
\relates <QtGlobal> |
|
2861 |
\obsolete |
|
2862 |
||
2863 |
Synonym for \c true. |
|
2864 |
||
2865 |
\sa FALSE |
|
2866 |
*/ |
|
2867 |
||
2868 |
/*! |
|
2869 |
\macro FALSE |
|
2870 |
\relates <QtGlobal> |
|
2871 |
\obsolete |
|
2872 |
||
2873 |
Synonym for \c false. |
|
2874 |
||
2875 |
\sa TRUE |
|
2876 |
*/ |
|
2877 |
||
2878 |
/*! |
|
2879 |
\macro QABS(n) |
|
2880 |
\relates <QtGlobal> |
|
2881 |
\obsolete |
|
2882 |
||
2883 |
Use qAbs(\a n) instead. |
|
2884 |
||
2885 |
\sa QMIN(), QMAX() |
|
2886 |
*/ |
|
2887 |
||
2888 |
/*! |
|
2889 |
\macro QMIN(x, y) |
|
2890 |
\relates <QtGlobal> |
|
2891 |
\obsolete |
|
2892 |
||
2893 |
Use qMin(\a x, \a y) instead. |
|
2894 |
||
2895 |
\sa QMAX(), QABS() |
|
2896 |
*/ |
|
2897 |
||
2898 |
/*! |
|
2899 |
\macro QMAX(x, y) |
|
2900 |
\relates <QtGlobal> |
|
2901 |
\obsolete |
|
2902 |
||
2903 |
Use qMax(\a x, \a y) instead. |
|
2904 |
||
2905 |
\sa QMIN(), QABS() |
|
2906 |
*/ |
|
2907 |
||
2908 |
/*! |
|
2909 |
\macro const char *qPrintable(const QString &str) |
|
2910 |
\relates <QtGlobal> |
|
2911 |
||
2912 |
Returns \a str as a \c{const char *}. This is equivalent to |
|
2913 |
\a{str}.toLocal8Bit().constData(). |
|
2914 |
||
2915 |
The char pointer will be invalid after the statement in which |
|
2916 |
qPrintable() is used. This is because the array returned by |
|
2917 |
toLocal8Bit() will fall out of scope. |
|
2918 |
||
2919 |
Example: |
|
2920 |
||
2921 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 37 |
|
2922 |
||
2923 |
||
2924 |
\sa qDebug(), qWarning(), qCritical(), qFatal() |
|
2925 |
*/ |
|
2926 |
||
2927 |
/*! |
|
2928 |
\macro Q_DECLARE_TYPEINFO(Type, Flags) |
|
2929 |
\relates <QtGlobal> |
|
2930 |
||
2931 |
You can use this macro to specify information about a custom type |
|
2932 |
\a Type. With accurate type information, Qt's \l{generic |
|
2933 |
containers} can choose appropriate storage methods and algorithms. |
|
2934 |
||
2935 |
\a Flags can be one of the following: |
|
2936 |
||
2937 |
\list |
|
2938 |
\o \c Q_PRIMITIVE_TYPE specifies that \a Type is a POD (plain old |
|
2939 |
data) type with no constructor or destructor. |
|
2940 |
\o \c Q_MOVABLE_TYPE specifies that \a Type has a constructor |
|
2941 |
and/or a destructor but can be moved in memory using \c |
|
2942 |
memcpy(). |
|
2943 |
\o \c Q_COMPLEX_TYPE (the default) specifies that \a Type has |
|
2944 |
constructors and/or a destructor and that it may not be moved |
|
2945 |
in memory. |
|
2946 |
\endlist |
|
2947 |
||
2948 |
Example of a "primitive" type: |
|
2949 |
||
2950 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 38 |
|
2951 |
||
2952 |
Example of a movable type: |
|
2953 |
||
2954 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 39 |
|
2955 |
*/ |
|
2956 |
||
2957 |
/*! |
|
2958 |
\macro Q_UNUSED(name) |
|
2959 |
\relates <QtGlobal> |
|
2960 |
||
2961 |
Indicates to the compiler that the parameter with the specified |
|
2962 |
\a name is not used in the body of a function. This can be used to |
|
2963 |
suppress compiler warnings while allowing functions to be defined |
|
2964 |
with meaningful parameter names in their signatures. |
|
2965 |
*/ |
|
2966 |
||
2967 |
#if defined(QT3_SUPPORT) && !defined(QT_NO_SETTINGS) |
|
2968 |
QT_BEGIN_INCLUDE_NAMESPACE |
|
2969 |
#include <qlibraryinfo.h> |
|
2970 |
QT_END_INCLUDE_NAMESPACE |
|
2971 |
||
2972 |
static const char *qInstallLocation(QLibraryInfo::LibraryLocation loc) |
|
2973 |
{ |
|
2974 |
static QByteArray ret; |
|
2975 |
ret = QLibraryInfo::location(loc).toLatin1(); |
|
2976 |
return ret.constData(); |
|
2977 |
} |
|
2978 |
const char *qInstallPath() |
|
2979 |
{ |
|
2980 |
return qInstallLocation(QLibraryInfo::PrefixPath); |
|
2981 |
} |
|
2982 |
const char *qInstallPathDocs() |
|
2983 |
{ |
|
2984 |
return qInstallLocation(QLibraryInfo::DocumentationPath); |
|
2985 |
} |
|
2986 |
const char *qInstallPathHeaders() |
|
2987 |
{ |
|
2988 |
return qInstallLocation(QLibraryInfo::HeadersPath); |
|
2989 |
} |
|
2990 |
const char *qInstallPathLibs() |
|
2991 |
{ |
|
2992 |
return qInstallLocation(QLibraryInfo::LibrariesPath); |
|
2993 |
} |
|
2994 |
const char *qInstallPathBins() |
|
2995 |
{ |
|
2996 |
return qInstallLocation(QLibraryInfo::BinariesPath); |
|
2997 |
} |
|
2998 |
const char *qInstallPathPlugins() |
|
2999 |
{ |
|
3000 |
return qInstallLocation(QLibraryInfo::PluginsPath); |
|
3001 |
} |
|
3002 |
const char *qInstallPathData() |
|
3003 |
{ |
|
3004 |
return qInstallLocation(QLibraryInfo::DataPath); |
|
3005 |
} |
|
3006 |
const char *qInstallPathTranslations() |
|
3007 |
{ |
|
3008 |
return qInstallLocation(QLibraryInfo::TranslationsPath); |
|
3009 |
} |
|
3010 |
const char *qInstallPathSysconf() |
|
3011 |
{ |
|
3012 |
return qInstallLocation(QLibraryInfo::SettingsPath); |
|
3013 |
} |
|
3014 |
#endif |
|
3015 |
||
3016 |
struct QInternal_CallBackTable { |
|
3017 |
QVector<QList<qInternalCallback> > callbacks; |
|
3018 |
}; |
|
3019 |
||
3020 |
Q_GLOBAL_STATIC(QInternal_CallBackTable, global_callback_table) |
|
3021 |
||
3022 |
bool QInternal::registerCallback(Callback cb, qInternalCallback callback) |
|
3023 |
{ |
|
3024 |
if (cb >= 0 && cb < QInternal::LastCallback) { |
|
3025 |
QInternal_CallBackTable *cbt = global_callback_table(); |
|
3026 |
cbt->callbacks.resize(cb + 1); |
|
3027 |
cbt->callbacks[cb].append(callback); |
|
3028 |
return true; |
|
3029 |
} |
|
3030 |
return false; |
|
3031 |
} |
|
3032 |
||
3033 |
bool QInternal::unregisterCallback(Callback cb, qInternalCallback callback) |
|
3034 |
{ |
|
3035 |
if (cb >= 0 && cb < QInternal::LastCallback) { |
|
3036 |
QInternal_CallBackTable *cbt = global_callback_table(); |
|
3037 |
return (bool) cbt->callbacks[cb].removeAll(callback); |
|
3038 |
} |
|
3039 |
return false; |
|
3040 |
} |
|
3041 |
||
3042 |
bool QInternal::activateCallbacks(Callback cb, void **parameters) |
|
3043 |
{ |
|
3044 |
Q_ASSERT_X(cb >= 0, "QInternal::activateCallback()", "Callback id must be a valid id"); |
|
3045 |
||
3046 |
QInternal_CallBackTable *cbt = global_callback_table(); |
|
3047 |
if (cbt && cb < cbt->callbacks.size()) { |
|
3048 |
QList<qInternalCallback> callbacks = cbt->callbacks[cb]; |
|
3049 |
bool ret = false; |
|
3050 |
for (int i=0; i<callbacks.size(); ++i) |
|
3051 |
ret |= (callbacks.at(i))(parameters); |
|
3052 |
return ret; |
|
3053 |
} |
|
3054 |
return false; |
|
3055 |
} |
|
3056 |
||
3057 |
extern void qt_set_current_thread_to_main_thread(); |
|
3058 |
||
3059 |
bool QInternal::callFunction(InternalFunction func, void **args) |
|
3060 |
{ |
|
3061 |
Q_ASSERT_X(func >= 0, |
|
3062 |
"QInternal::callFunction()", "Callback id must be a valid id"); |
|
3063 |
#ifndef QT_NO_QOBJECT |
|
3064 |
switch (func) { |
|
3065 |
#ifndef QT_NO_THREAD |
|
3066 |
case QInternal::CreateThreadForAdoption: |
|
3067 |
*args = QAdoptedThread::createThreadForAdoption(); |
|
3068 |
return true; |
|
3069 |
#endif |
|
3070 |
case QInternal::RefAdoptedThread: |
|
3071 |
QThreadData::get2((QThread *) *args)->ref(); |
|
3072 |
return true; |
|
3073 |
case QInternal::DerefAdoptedThread: |
|
3074 |
QThreadData::get2((QThread *) *args)->deref(); |
|
3075 |
return true; |
|
3076 |
case QInternal::SetCurrentThreadToMainThread: |
|
3077 |
qt_set_current_thread_to_main_thread(); |
|
3078 |
return true; |
|
3079 |
case QInternal::SetQObjectSender: { |
|
3080 |
QObject *receiver = (QObject *) args[0]; |
|
3081 |
QObjectPrivate::Sender *sender = new QObjectPrivate::Sender; |
|
3082 |
sender->sender = (QObject *) args[1]; |
|
3083 |
sender->signal = *(int *) args[2]; |
|
3084 |
sender->ref = 1; |
|
3085 |
||
3086 |
// Store the old sender as "return value" |
|
3087 |
args[3] = QObjectPrivate::setCurrentSender(receiver, sender); |
|
3088 |
args[4] = sender; |
|
3089 |
return true; |
|
3090 |
} |
|
3091 |
case QInternal::GetQObjectSender: { |
|
3092 |
QObject *receiver = (QObject *) args[0]; |
|
3093 |
QObjectPrivate *d = QObjectPrivate::get(receiver); |
|
3094 |
args[1] = d->currentSender ? d->currentSender->sender : 0; |
|
3095 |
return true; |
|
3096 |
} |
|
3097 |
case QInternal::ResetQObjectSender: { |
|
3098 |
QObject *receiver = (QObject *) args[0]; |
|
3099 |
QObjectPrivate::Sender *oldSender = (QObjectPrivate::Sender *) args[1]; |
|
3100 |
QObjectPrivate::Sender *sender = (QObjectPrivate::Sender *) args[2]; |
|
3101 |
QObjectPrivate::resetCurrentSender(receiver, sender, oldSender); |
|
3102 |
delete sender; |
|
3103 |
return true; |
|
3104 |
} |
|
3105 |
||
3106 |
default: |
|
3107 |
break; |
|
3108 |
} |
|
3109 |
#else |
|
3110 |
Q_UNUSED(args); |
|
3111 |
Q_UNUSED(func); |
|
3112 |
#endif |
|
3113 |
||
3114 |
return false; |
|
3115 |
} |
|
3116 |
||
3117 |
/*! |
|
3118 |
\macro Q_BYTE_ORDER |
|
3119 |
\relates <QtGlobal> |
|
3120 |
||
3121 |
This macro can be used to determine the byte order your system |
|
3122 |
uses for storing data in memory. i.e., whether your system is |
|
3123 |
little-endian or big-endian. It is set by Qt to one of the macros |
|
3124 |
Q_LITTLE_ENDIAN or Q_BIG_ENDIAN. You normally won't need to worry |
|
3125 |
about endian-ness, but you might, for example if you need to know |
|
3126 |
which byte of an integer or UTF-16 character is stored in the |
|
3127 |
lowest address. Endian-ness is important in networking, where |
|
3128 |
computers with different values for Q_BYTE_ORDER must pass data |
|
3129 |
back and forth. |
|
3130 |
||
3131 |
Use this macro as in the following examples. |
|
3132 |
||
3133 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 40 |
|
3134 |
||
3135 |
\sa Q_BIG_ENDIAN, Q_LITTLE_ENDIAN |
|
3136 |
*/ |
|
3137 |
||
3138 |
/*! |
|
3139 |
\macro Q_LITTLE_ENDIAN |
|
3140 |
\relates <QtGlobal> |
|
3141 |
||
3142 |
This macro represents a value you can compare to the macro |
|
3143 |
Q_BYTE_ORDER to determine the endian-ness of your system. In a |
|
3144 |
little-endian system, the least significant byte is stored at the |
|
3145 |
lowest address. The other bytes follow in increasing order of |
|
3146 |
significance. |
|
3147 |
||
3148 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 41 |
|
3149 |
||
3150 |
\sa Q_BYTE_ORDER, Q_BIG_ENDIAN |
|
3151 |
*/ |
|
3152 |
||
3153 |
/*! |
|
3154 |
\macro Q_BIG_ENDIAN |
|
3155 |
\relates <QtGlobal> |
|
3156 |
||
3157 |
This macro represents a value you can compare to the macro |
|
3158 |
Q_BYTE_ORDER to determine the endian-ness of your system. In a |
|
3159 |
big-endian system, the most significant byte is stored at the |
|
3160 |
lowest address. The other bytes follow in decreasing order of |
|
3161 |
significance. |
|
3162 |
||
3163 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 42 |
|
3164 |
||
3165 |
\sa Q_BYTE_ORDER, Q_LITTLE_ENDIAN |
|
3166 |
*/ |
|
3167 |
||
3168 |
/*! |
|
3169 |
\macro Q_GLOBAL_STATIC(type, name) |
|
3170 |
\internal |
|
3171 |
||
3172 |
Declares a global static variable with the given \a type and \a name. |
|
3173 |
||
3174 |
Use this macro to instantiate an object in a thread-safe way, creating |
|
3175 |
a global pointer that can be used to refer to it. |
|
3176 |
||
3177 |
\warning This macro is subject to a race condition that can cause the object |
|
3178 |
to be constructed twice. However, if this occurs, the second instance will |
|
3179 |
be immediately deleted. |
|
3180 |
||
3181 |
See also |
|
3182 |
\l{http://www.aristeia.com/publications.html}{"C++ and the perils of Double-Checked Locking"} |
|
3183 |
by Scott Meyers and Andrei Alexandrescu. |
|
3184 |
*/ |
|
3185 |
||
3186 |
/*! |
|
3187 |
\macro Q_GLOBAL_STATIC_WITH_ARGS(type, name, arguments) |
|
3188 |
\internal |
|
3189 |
||
3190 |
Declares a global static variable with the specified \a type and \a name. |
|
3191 |
||
3192 |
Use this macro to instantiate an object using the \a arguments specified |
|
3193 |
in a thread-safe way, creating a global pointer that can be used to refer |
|
3194 |
to it. |
|
3195 |
||
3196 |
\warning This macro is subject to a race condition that can cause the object |
|
3197 |
to be constructed twice. However, if this occurs, the second instance will |
|
3198 |
be immediately deleted. |
|
3199 |
||
3200 |
See also |
|
3201 |
\l{http://www.aristeia.com/publications.html}{"C++ and the perils of Double-Checked Locking"} |
|
3202 |
by Scott Meyers and Andrei Alexandrescu. |
|
3203 |
*/ |
|
3204 |
||
3205 |
/*! |
|
3206 |
\macro QT_NAMESPACE |
|
3207 |
\internal |
|
3208 |
||
3209 |
If this macro is defined to \c ns all Qt classes are put in a namespace |
|
3210 |
called \c ns. Also, moc will output code putting metaobjects etc. |
|
3211 |
into namespace \c ns. |
|
3212 |
||
3213 |
\sa QT_BEGIN_NAMESPACE, QT_END_NAMESPACE, |
|
3214 |
QT_PREPEND_NAMESPACE, QT_USE_NAMESPACE, |
|
3215 |
QT_BEGIN_INCLUDE_NAMESPACE, QT_END_INCLUDE_NAMESPACE, |
|
3216 |
QT_BEGIN_MOC_NAMESPACE, QT_END_MOC_NAMESPACE, |
|
3217 |
*/ |
|
3218 |
||
3219 |
/*! |
|
3220 |
\macro QT_PREPEND_NAMESPACE(identifier) |
|
3221 |
\internal |
|
3222 |
||
3223 |
This macro qualifies \a identifier with the full namespace. |
|
3224 |
It expands to \c{::QT_NAMESPACE::identifier} if \c QT_NAMESPACE is defined |
|
3225 |
and only \a identifier otherwise. |
|
3226 |
||
3227 |
\sa QT_NAMESPACE |
|
3228 |
*/ |
|
3229 |
||
3230 |
/*! |
|
3231 |
\macro QT_USE_NAMESPACE |
|
3232 |
\internal |
|
3233 |
||
3234 |
This macro expands to using QT_NAMESPACE if QT_NAMESPACE is defined |
|
3235 |
and nothing otherwise. |
|
3236 |
||
3237 |
\sa QT_NAMESPACE |
|
3238 |
*/ |
|
3239 |
||
3240 |
/*! |
|
3241 |
\macro QT_BEGIN_NAMESPACE |
|
3242 |
\internal |
|
3243 |
||
3244 |
This macro expands to |
|
3245 |
||
3246 |
\snippet snippets/code/src_corelib_global_qglobal.cpp begin namespace macro |
|
3247 |
||
3248 |
if \c QT_NAMESPACE is defined and nothing otherwise. If should always |
|
3249 |
appear in the file-level scope and be followed by \c QT_END_NAMESPACE |
|
3250 |
at the same logical level with respect to preprocessor conditionals |
|
3251 |
in the same file. |
|
3252 |
||
3253 |
As a rule of thumb, \c QT_BEGIN_NAMESPACE should appear in all Qt header |
|
3254 |
and Qt source files after the last \c{#include} line and before the first |
|
3255 |
declaration. In Qt headers using \c QT_BEGIN_HEADER, \c QT_BEGIN_NAMESPACE |
|
3256 |
follows \c QT_BEGIN_HEADER immediately. |
|
3257 |
||
3258 |
If that rule can't be followed because, e.g., \c{#include} lines and |
|
3259 |
declarations are wildly mixed, place \c QT_BEGIN_NAMESPACE before |
|
3260 |
the first declaration and wrap the \c{#include} lines in |
|
3261 |
\c QT_BEGIN_INCLUDE_NAMESPACE and \c QT_END_INCLUDE_NAMESPACE. |
|
3262 |
||
3263 |
When using the \c QT_NAMESPACE feature in user code |
|
3264 |
(e.g., when building plugins statically linked to Qt) where |
|
3265 |
the user code is not intended to go into the \c QT_NAMESPACE |
|
3266 |
namespace, all forward declarations of Qt classes need to |
|
3267 |
be wrapped in \c QT_BEGIN_NAMESPACE and \c QT_END_NAMESPACE. |
|
3268 |
After that, a \c QT_USE_NAMESPACE should follow. |
|
3269 |
No further changes should be needed. |
|
3270 |
||
3271 |
\sa QT_NAMESPACE |
|
3272 |
*/ |
|
3273 |
||
3274 |
/*! |
|
3275 |
\macro QT_END_NAMESPACE |
|
3276 |
\internal |
|
3277 |
||
3278 |
This macro expands to |
|
3279 |
||
3280 |
\snippet snippets/code/src_corelib_global_qglobal.cpp end namespace macro |
|
3281 |
||
3282 |
if \c QT_NAMESPACE is defined and nothing otherwise. It is used to cancel |
|
3283 |
the effect of \c QT_BEGIN_NAMESPACE. |
|
3284 |
||
3285 |
If a source file ends with a \c{#include} directive that includes a moc file, |
|
3286 |
\c QT_END_NAMESPACE should be placed before that \c{#include}. |
|
3287 |
||
3288 |
\sa QT_NAMESPACE |
|
3289 |
*/ |
|
3290 |
||
3291 |
/*! |
|
3292 |
\macro QT_BEGIN_INCLUDE_NAMESPACE |
|
3293 |
\internal |
|
3294 |
||
3295 |
This macro is equivalent to \c QT_END_NAMESPACE. |
|
3296 |
It only serves as syntactic sugar and is intended |
|
3297 |
to be used before #include lines within a |
|
3298 |
\c QT_BEGIN_NAMESPACE ... \c QT_END_NAMESPACE block. |
|
3299 |
||
3300 |
\sa QT_NAMESPACE |
|
3301 |
*/ |
|
3302 |
||
3303 |
/*! |
|
3304 |
\macro QT_END_INCLUDE_NAMESPACE |
|
3305 |
\internal |
|
3306 |
||
3307 |
This macro is equivalent to \c QT_BEGIN_NAMESPACE. |
|
3308 |
It only serves as syntactic sugar and is intended |
|
3309 |
to be used after #include lines within a |
|
3310 |
\c QT_BEGIN_NAMESPACE ... \c QT_END_NAMESPACE block. |
|
3311 |
||
3312 |
\sa QT_NAMESPACE |
|
3313 |
*/ |
|
3314 |
||
3315 |
/*! |
|
3316 |
\macro QT_BEGIN_MOC_NAMESPACE |
|
3317 |
\internal |
|
3318 |
||
3319 |
This macro is output by moc at the beginning of |
|
3320 |
moc files. It is equivalent to \c QT_USE_NAMESPACE. |
|
3321 |
||
3322 |
\sa QT_NAMESPACE |
|
3323 |
*/ |
|
3324 |
||
3325 |
/*! |
|
3326 |
\macro QT_END_MOC_NAMESPACE |
|
3327 |
\internal |
|
3328 |
||
3329 |
This macro is output by moc at the beginning of |
|
3330 |
moc files. It expands to nothing. |
|
3331 |
||
3332 |
\sa QT_NAMESPACE |
|
3333 |
*/ |
|
3334 |
||
3335 |
/*! |
|
3336 |
\fn bool qFuzzyCompare(double p1, double p2) |
|
3337 |
\relates <QtGlobal> |
|
3338 |
\since 4.4 |
|
3339 |
\threadsafe |
|
3340 |
||
3341 |
Compares the floating point value \a p1 and \a p2 and |
|
3342 |
returns \c true if they are considered equal, otherwise \c false. |
|
3343 |
||
3344 |
Note that comparing values where either \a p1 or \a p2 is 0.0 will not work. |
|
3345 |
The solution to this is to compare against values greater than or equal to 1.0. |
|
3346 |
||
3347 |
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 46 |
|
3348 |
||
3349 |
The two numbers are compared in a relative way, where the |
|
3350 |
exactness is stronger the smaller the numbers are. |
|
3351 |
*/ |
|
3352 |
||
3353 |
/*! |
|
3354 |
\fn bool qFuzzyCompare(float p1, float p2) |
|
3355 |
\relates <QtGlobal> |
|
3356 |
\since 4.4 |
|
3357 |
\threadsafe |
|
3358 |
||
3359 |
Compares the floating point value \a p1 and \a p2 and |
|
3360 |
returns \c true if they are considered equal, otherwise \c false. |
|
3361 |
||
3362 |
The two numbers are compared in a relative way, where the |
|
3363 |
exactness is stronger the smaller the numbers are. |
|
3364 |
*/ |
|
3365 |
||
3366 |
/*! |
|
3367 |
\macro QT_REQUIRE_VERSION(int argc, char **argv, const char *version) |
|
3368 |
\relates <QtGlobal> |
|
3369 |
||
3370 |
This macro can be used to ensure that the application is run |
|
3371 |
against a recent enough version of Qt. This is especially useful |
|
3372 |
if your application depends on a specific bug fix introduced in a |
|
3373 |
bug-fix release (e.g., 4.0.2). |
|
3374 |
||
3375 |
The \a argc and \a argv parameters are the \c main() function's |
|
3376 |
\c argc and \c argv parameters. The \a version parameter is a |
|
3377 |
string literal that specifies which version of Qt the application |
|
3378 |
requires (e.g., "4.0.2"). |
|
3379 |
||
3380 |
Example: |
|
3381 |
||
3382 |
\snippet doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp 4 |
|
3383 |
*/ |
|
3384 |
||
3385 |
/*! |
|
3386 |
\macro Q_DECL_EXPORT |
|
3387 |
\relates <QtGlobal> |
|
3388 |
||
3389 |
This macro marks a symbol for shared library export (see |
|
3390 |
\l{sharedlibrary.html}{Creating Shared Libraries}). |
|
3391 |
||
3392 |
\sa Q_DECL_IMPORT |
|
3393 |
*/ |
|
3394 |
||
3395 |
/*! |
|
3396 |
\macro Q_DECL_IMPORT |
|
3397 |
\relates <QtGlobal> |
|
3398 |
||
3399 |
This macro declares a symbol to be an import from a shared library (see |
|
3400 |
\l{sharedlibrary.html}{Creating Shared Libraries}). |
|
3401 |
||
3402 |
\sa Q_DECL_EXPORT |
|
3403 |
*/ |
|
3404 |
||
3405 |
#if defined(Q_OS_SYMBIAN) |
|
3406 |
||
3407 |
#include <typeinfo> |
|
3408 |
||
3409 |
/*! \macro QT_TRAP_THROWING(function) |
|
3410 |
\relates <QtGlobal> |
|
3411 |
\ingroup qts60 |
|
3412 |
||
3413 |
TRAP leaves from Symbian \a function and throws an appropriate |
|
3414 |
standard C++ exception instead. |
|
3415 |
This must be used when calling Symbian OS leaving functions |
|
3416 |
from inside Qt or standard C++ code, so that the code can respond |
|
3417 |
correctly to the exception. |
|
3418 |
||
3419 |
\warning This macro is only available on Symbian. |
|
3420 |
||
3421 |
Example: |
|
3422 |
||
3423 |
\code |
|
3424 |
// A Symbian leaving function is being called within a Qt function. |
|
3425 |
// Any leave must be converted to an exception |
|
3426 |
CAknTitlePane* titlePane = S60->titlePane(); |
|
3427 |
if (titlePane) { |
|
3428 |
TPtrC captionPtr(qt_QString2TPtrC(caption)); |
|
3429 |
QT_TRAP_THROWING(titlePane->SetTextL(captionPtr)); |
|
3430 |
} |
|
3431 |
\endcode |
|
3432 |
||
3433 |
\sa QT_TRYCATCH_ERROR(), QT_TRYCATCH_LEAVING() |
|
3434 |
*/ |
|
3435 |
||
3436 |
/*! \macro QT_TRYCATCH_ERROR(error, function) |
|
3437 |
\relates <QtGlobal> |
|
3438 |
\ingroup qts60 |
|
3439 |
||
3440 |
Catch standard C++ exceptions from a \a function and convert them to a Symbian OS |
|
3441 |
\a error code, or \c KErrNone if there is no exception. |
|
3442 |
This must be used inside Qt or standard C++ code when using exception throwing |
|
3443 |
code (practically anything) and returning an error code to Symbian OS. |
|
3444 |
||
3445 |
\warning This macro is only available on Symbian. |
|
3446 |
||
3447 |
Example: |
|
3448 |
||
3449 |
\code |
|
3450 |
// An exception might be thrown in this Symbian TInt error returning function. |
|
3451 |
// It is caught and translated to an error code |
|
3452 |
TInt QServerApp::Connect(const QString &serverName) |
|
3453 |
{ |
|
3454 |
TPtrC name; |
|
3455 |
TInt err; |
|
3456 |
QT_TRYCATCH_ERROR(err, name.Set(qt_QString2TPtrC(serverName))); |
|
3457 |
if (err != KErrNone) |
|
3458 |
return err; |
|
3459 |
return iServer.Connect(name); |
|
3460 |
} |
|
3461 |
\endcode |
|
3462 |
} |
|
3463 |
||
3464 |
\sa QT_TRYCATCH_LEAVING(), QT_TRAP_THROWING() |
|
3465 |
*/ |
|
3466 |
||
3467 |
/*! \macro QT_TRYCATCH_LEAVING(function) |
|
3468 |
\relates <QtGlobal> |
|
3469 |
\ingroup qts60 |
|
3470 |
||
3471 |
Catch standard C++ exceptions from \a function and convert them to Symbian OS |
|
3472 |
leaves. This must be used inside Qt or standard C++ code when using exception |
|
3473 |
throwing code (practically anything) and returning to Symbian OS from a leaving function. |
|
3474 |
For example inside a Symbian active object's \c RunL function implemented with Qt code. |
|
3475 |
||
3476 |
\warning This macro is only available on Symbian. |
|
3477 |
||
3478 |
Example: |
|
3479 |
||
3480 |
\code |
|
3481 |
// This active object signals Qt code |
|
3482 |
// Exceptions from the Qt code must be converted to Symbian OS leaves for the active scheduler |
|
3483 |
void QWakeUpActiveObject::RunL() |
|
3484 |
{ |
|
3485 |
iStatus = KRequestPending; |
|
3486 |
SetActive(); |
|
3487 |
QT_TRYCATCH_LEAVING(m_dispatcher->wakeUpWasCalled()); |
|
3488 |
} |
|
3489 |
\endcode |
|
3490 |
||
3491 |
\sa QT_TRAP_THROWING(), QT_TRYCATCH_ERROR() |
|
3492 |
*/ |
|
3493 |
||
3494 |
#include <stdexcept> |
|
3495 |
||
3496 |
class QSymbianLeaveException : public std::exception |
|
3497 |
{ |
|
3498 |
public: |
|
3499 |
inline QSymbianLeaveException(int err) : error(err) {} |
|
3500 |
inline const char* what() const throw() { return "Symbian leave exception"; } |
|
3501 |
||
3502 |
public: |
|
3503 |
int error; |
|
3504 |
}; |
|
3505 |
||
3506 |
/*! \relates <QtGlobal> |
|
3507 |
\ingroup qts60 |
|
3508 |
||
3509 |
Throws an exception if the \a error parameter is a symbian error code. |
|
3510 |
This is the exception throwing equivalent of Symbian's User::LeaveIfError. |
|
3511 |
||
3512 |
\warning This function is only available on Symbian. |
|
3513 |
||
3514 |
\sa qt_symbian_exception2LeaveL(), qt_symbian_exception2Error() |
|
3515 |
*/ |
|
3516 |
void qt_symbian_throwIfError(int error) |
|
3517 |
{ |
|
3518 |
if (error >= KErrNone) |
|
3519 |
return; // do nothing - not an exception |
|
3520 |
switch (error) { |
|
3521 |
case KErrNoMemory: |
|
3522 |
throw std::bad_alloc(); |
|
3523 |
case KErrArgument: |
|
3524 |
throw std::invalid_argument("from Symbian error"); |
|
3525 |
case KErrOverflow: |
|
3526 |
throw std::overflow_error("from Symbian error"); |
|
3527 |
case KErrUnderflow: |
|
3528 |
throw std::underflow_error("from Symbian error"); |
|
3529 |
default: |
|
3530 |
throw QSymbianLeaveException(error); |
|
3531 |
} |
|
3532 |
} |
|
3533 |
||
3534 |
/*! \relates <QtGlobal> |
|
3535 |
\ingroup qts60 |
|
3536 |
||
3537 |
Convert a caught standard C++ exception \a aThrow to a Symbian leave |
|
3538 |
||
3539 |
\warning This function is only available on Symbian. |
|
3540 |
||
3541 |
\sa qt_symbian_throwIfError(), qt_symbian_exception2Error() |
|
3542 |
*/ |
|
3543 |
void qt_symbian_exception2LeaveL(const std::exception& aThrow) |
|
3544 |
{ |
|
3545 |
User::Leave(qt_symbian_exception2Error(aThrow)); |
|
3546 |
} |
|
3547 |
||
3548 |
/*! \relates <QtGlobal> |
|
3549 |
\ingroup qts60 |
|
3550 |
||
3551 |
Convert a caught standard C++ exception \a aThrow to a Symbian error code |
|
3552 |
||
3553 |
\warning This function is only available on Symbian. |
|
3554 |
||
3555 |
\sa qt_symbian_throwIfError(), qt_symbian_exception2LeaveL() |
|
3556 |
*/ |
|
3557 |
int qt_symbian_exception2Error(const std::exception& aThrow) |
|
3558 |
{ |
|
3559 |
const std::type_info& atype = typeid(aThrow); |
|
3560 |
int err = KErrGeneral; |
|
3561 |
||
3562 |
if(atype == typeid (std::bad_alloc)) |
|
3563 |
err = KErrNoMemory; |
|
3564 |
else if(atype == typeid(QSymbianLeaveException)) |
|
3565 |
err = static_cast<const QSymbianLeaveException&>(aThrow).error; |
|
3566 |
else { |
|
3567 |
if(atype == typeid(std::invalid_argument)) |
|
3568 |
err = KErrArgument; |
|
3569 |
else if(atype == typeid(std::out_of_range)) |
|
3570 |
// std::out_of_range is of type logic_error which by definition means that it is |
|
3571 |
// "presumably detectable before the program executes". |
|
3572 |
// std::out_of_range is used to report an argument is not within the expected range. |
|
3573 |
// The description of KErrArgument says an argument is out of range. Hence the mapping. |
|
3574 |
err = KErrArgument; |
|
3575 |
else if(atype == typeid(std::overflow_error)) |
|
3576 |
err = KErrOverflow; |
|
3577 |
else if(atype == typeid(std::underflow_error)) |
|
3578 |
err = KErrUnderflow; |
|
3579 |
qWarning("translation from std exception \"%s\" to %d", aThrow.what(), err); |
|
3580 |
} |
|
3581 |
||
3582 |
return err; |
|
3583 |
} |
|
3584 |
#endif |
|
3585 |
||
3586 |
QT_END_NAMESPACE |