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