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