| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/global/qglobal.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||||||||
| 2 | ** | - | ||||||||||||||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||||||||
| 4 | ** Copyright (C) 2015 Intel Corporation | - | ||||||||||||||||||
| 5 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||||||||
| 6 | ** | - | ||||||||||||||||||
| 7 | ** This file is part of the QtCore module of the Qt Toolkit. | - | ||||||||||||||||||
| 8 | ** | - | ||||||||||||||||||
| 9 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||||||||
| 10 | ** Commercial License Usage | - | ||||||||||||||||||
| 11 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||
| 12 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||
| 13 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||
| 14 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||
| 15 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||
| 16 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||||||||
| 17 | ** | - | ||||||||||||||||||
| 18 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||
| 19 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||
| 20 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||||||||
| 21 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||||||||
| 22 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||||||||
| 23 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||||||||
| 24 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||||||||
| 25 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||||||||
| 26 | ** | - | ||||||||||||||||||
| 27 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||||||||
| 28 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||||||||
| 29 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||||||||
| 30 | ** | - | ||||||||||||||||||
| 31 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||
| 32 | ** | - | ||||||||||||||||||
| 33 | ****************************************************************************/ | - | ||||||||||||||||||
| 34 | - | |||||||||||||||||||
| 35 | #include "qplatformdefs.h" | - | ||||||||||||||||||
| 36 | #include "qstring.h" | - | ||||||||||||||||||
| 37 | #include "qvector.h" | - | ||||||||||||||||||
| 38 | #include "qlist.h" | - | ||||||||||||||||||
| 39 | #include "qthreadstorage.h" | - | ||||||||||||||||||
| 40 | #include "qdir.h" | - | ||||||||||||||||||
| 41 | #include "qdatetime.h" | - | ||||||||||||||||||
| 42 | #include <private/qlocale_tools_p.h> | - | ||||||||||||||||||
| 43 | - | |||||||||||||||||||
| 44 | #include <private/qsystemlibrary_p.h> | - | ||||||||||||||||||
| 45 | #include <qmutex.h> | - | ||||||||||||||||||
| 46 | - | |||||||||||||||||||
| 47 | #ifndef QT_NO_QOBJECT | - | ||||||||||||||||||
| 48 | #include <private/qthread_p.h> | - | ||||||||||||||||||
| 49 | #endif | - | ||||||||||||||||||
| 50 | - | |||||||||||||||||||
| 51 | #include <stdlib.h> | - | ||||||||||||||||||
| 52 | #include <limits.h> | - | ||||||||||||||||||
| 53 | #include <stdarg.h> | - | ||||||||||||||||||
| 54 | #include <string.h> | - | ||||||||||||||||||
| 55 | - | |||||||||||||||||||
| 56 | #ifndef QT_NO_EXCEPTIONS | - | ||||||||||||||||||
| 57 | # include <string> | - | ||||||||||||||||||
| 58 | # include <exception> | - | ||||||||||||||||||
| 59 | #endif | - | ||||||||||||||||||
| 60 | - | |||||||||||||||||||
| 61 | #if !defined(Q_OS_WINCE) | - | ||||||||||||||||||
| 62 | # include <errno.h> | - | ||||||||||||||||||
| 63 | # if defined(Q_CC_MSVC) | - | ||||||||||||||||||
| 64 | # include <crtdbg.h> | - | ||||||||||||||||||
| 65 | # endif | - | ||||||||||||||||||
| 66 | #endif | - | ||||||||||||||||||
| 67 | - | |||||||||||||||||||
| 68 | #ifdef Q_OS_WINRT | - | ||||||||||||||||||
| 69 | #include <Ws2tcpip.h> | - | ||||||||||||||||||
| 70 | #endif // Q_OS_WINRT | - | ||||||||||||||||||
| 71 | - | |||||||||||||||||||
| 72 | #if defined(Q_OS_VXWORKS) && defined(_WRS_KERNEL) | - | ||||||||||||||||||
| 73 | # include <envLib.h> | - | ||||||||||||||||||
| 74 | #endif | - | ||||||||||||||||||
| 75 | - | |||||||||||||||||||
| 76 | #if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) | - | ||||||||||||||||||
| 77 | #include <private/qjni_p.h> | - | ||||||||||||||||||
| 78 | #endif | - | ||||||||||||||||||
| 79 | - | |||||||||||||||||||
| 80 | #if defined(Q_OS_BLACKBERRY) | - | ||||||||||||||||||
| 81 | # include <bps/deviceinfo.h> | - | ||||||||||||||||||
| 82 | #endif | - | ||||||||||||||||||
| 83 | - | |||||||||||||||||||
| 84 | #if defined(Q_OS_SOLARIS) | - | ||||||||||||||||||
| 85 | # include <sys/systeminfo.h> | - | ||||||||||||||||||
| 86 | #endif | - | ||||||||||||||||||
| 87 | - | |||||||||||||||||||
| 88 | #ifdef Q_OS_UNIX | - | ||||||||||||||||||
| 89 | #include <sys/utsname.h> | - | ||||||||||||||||||
| 90 | #include <private/qcore_unix_p.h> | - | ||||||||||||||||||
| 91 | #endif | - | ||||||||||||||||||
| 92 | - | |||||||||||||||||||
| 93 | #ifdef Q_OS_BSD4 | - | ||||||||||||||||||
| 94 | #include <sys/sysctl.h> | - | ||||||||||||||||||
| 95 | #endif | - | ||||||||||||||||||
| 96 | - | |||||||||||||||||||
| 97 | #include "archdetect.cpp" | - | ||||||||||||||||||
| 98 | - | |||||||||||||||||||
| 99 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
| 100 | - | |||||||||||||||||||
| 101 | #if !QT_DEPRECATED_SINCE(5, 0) | - | ||||||||||||||||||
| 102 | // Make sure they're defined to be exported | - | ||||||||||||||||||
| 103 | Q_CORE_EXPORT void *qMemCopy(void *dest, const void *src, size_t n); | - | ||||||||||||||||||
| 104 | Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n); | - | ||||||||||||||||||
| 105 | #endif | - | ||||||||||||||||||
| 106 | - | |||||||||||||||||||
| 107 | // Statically check assumptions about the environment we're running | - | ||||||||||||||||||
| 108 | // in. The idea here is to error or warn if otherwise implicit Qt | - | ||||||||||||||||||
| 109 | // assumptions are not fulfilled on new hardware or compilers | - | ||||||||||||||||||
| 110 | // (if this list becomes too long, consider factoring into a separate file) | - | ||||||||||||||||||
| 111 | Q_STATIC_ASSERT_X(sizeof(int) == 4, "Qt assumes that int is 32 bits"); | - | ||||||||||||||||||
| 112 | Q_STATIC_ASSERT_X(UCHAR_MAX == 255, "Qt assumes that char is 8 bits"); | - | ||||||||||||||||||
| 113 | Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined incorrectly"); | - | ||||||||||||||||||
| 114 | - | |||||||||||||||||||
| 115 | /*! | - | ||||||||||||||||||
| 116 | \class QFlag | - | ||||||||||||||||||
| 117 | \inmodule QtCore | - | ||||||||||||||||||
| 118 | \brief The QFlag class is a helper data type for QFlags. | - | ||||||||||||||||||
| 119 | - | |||||||||||||||||||
| 120 | It is equivalent to a plain \c int, except with respect to | - | ||||||||||||||||||
| 121 | function overloading and type conversions. You should never need | - | ||||||||||||||||||
| 122 | to use this class in your applications. | - | ||||||||||||||||||
| 123 | - | |||||||||||||||||||
| 124 | \sa QFlags | - | ||||||||||||||||||
| 125 | */ | - | ||||||||||||||||||
| 126 | - | |||||||||||||||||||
| 127 | /*! | - | ||||||||||||||||||
| 128 | \fn QFlag::QFlag(int value) | - | ||||||||||||||||||
| 129 | - | |||||||||||||||||||
| 130 | Constructs a QFlag object that stores the given \a value. | - | ||||||||||||||||||
| 131 | */ | - | ||||||||||||||||||
| 132 | - | |||||||||||||||||||
| 133 | /*! | - | ||||||||||||||||||
| 134 | \fn QFlag::QFlag(uint value) | - | ||||||||||||||||||
| 135 | \since Qt 5.3 | - | ||||||||||||||||||
| 136 | - | |||||||||||||||||||
| 137 | Constructs a QFlag object that stores the given \a value. | - | ||||||||||||||||||
| 138 | */ | - | ||||||||||||||||||
| 139 | - | |||||||||||||||||||
| 140 | /*! | - | ||||||||||||||||||
| 141 | \fn QFlag::QFlag(short value) | - | ||||||||||||||||||
| 142 | \since 5.3 | - | ||||||||||||||||||
| 143 | - | |||||||||||||||||||
| 144 | Constructs a QFlag object that stores the given \a value. | - | ||||||||||||||||||
| 145 | */ | - | ||||||||||||||||||
| 146 | - | |||||||||||||||||||
| 147 | /*! | - | ||||||||||||||||||
| 148 | \fn QFlag::QFlag(ushort value) | - | ||||||||||||||||||
| 149 | \since Qt 5.3 | - | ||||||||||||||||||
| 150 | - | |||||||||||||||||||
| 151 | Constructs a QFlag object that stores the given \a value. | - | ||||||||||||||||||
| 152 | */ | - | ||||||||||||||||||
| 153 | - | |||||||||||||||||||
| 154 | /*! | - | ||||||||||||||||||
| 155 | \fn QFlag::operator int() const | - | ||||||||||||||||||
| 156 | - | |||||||||||||||||||
| 157 | Returns the value stored by the QFlag object. | - | ||||||||||||||||||
| 158 | */ | - | ||||||||||||||||||
| 159 | - | |||||||||||||||||||
| 160 | /*! | - | ||||||||||||||||||
| 161 | \fn QFlag::operator uint() const | - | ||||||||||||||||||
| 162 | \since Qt 5.3 | - | ||||||||||||||||||
| 163 | - | |||||||||||||||||||
| 164 | Returns the value stored by the QFlag object. | - | ||||||||||||||||||
| 165 | */ | - | ||||||||||||||||||
| 166 | - | |||||||||||||||||||
| 167 | /*! | - | ||||||||||||||||||
| 168 | \class QFlags | - | ||||||||||||||||||
| 169 | \inmodule QtCore | - | ||||||||||||||||||
| 170 | \brief The QFlags class provides a type-safe way of storing | - | ||||||||||||||||||
| 171 | OR-combinations of enum values. | - | ||||||||||||||||||
| 172 | - | |||||||||||||||||||
| 173 | - | |||||||||||||||||||
| 174 | \ingroup tools | - | ||||||||||||||||||
| 175 | - | |||||||||||||||||||
| 176 | The QFlags<Enum> class is a template class, where Enum is an enum | - | ||||||||||||||||||
| 177 | type. QFlags is used throughout Qt for storing combinations of | - | ||||||||||||||||||
| 178 | enum values. | - | ||||||||||||||||||
| 179 | - | |||||||||||||||||||
| 180 | The traditional C++ approach for storing OR-combinations of enum | - | ||||||||||||||||||
| 181 | values is to use an \c int or \c uint variable. The inconvenience | - | ||||||||||||||||||
| 182 | with this approach is that there's no type checking at all; any | - | ||||||||||||||||||
| 183 | enum value can be OR'd with any other enum value and passed on to | - | ||||||||||||||||||
| 184 | a function that takes an \c int or \c uint. | - | ||||||||||||||||||
| 185 | - | |||||||||||||||||||
| 186 | Qt uses QFlags to provide type safety. For example, the | - | ||||||||||||||||||
| 187 | Qt::Alignment type is simply a typedef for | - | ||||||||||||||||||
| 188 | QFlags<Qt::AlignmentFlag>. QLabel::setAlignment() takes a | - | ||||||||||||||||||
| 189 | Qt::Alignment parameter, which means that any combination of | - | ||||||||||||||||||
| 190 | Qt::AlignmentFlag values, or 0, is legal: | - | ||||||||||||||||||
| 191 | - | |||||||||||||||||||
| 192 | \snippet code/src_corelib_global_qglobal.cpp 0 | - | ||||||||||||||||||
| 193 | - | |||||||||||||||||||
| 194 | If you try to pass a value from another enum or just a plain | - | ||||||||||||||||||
| 195 | integer other than 0, the compiler will report an error. If you | - | ||||||||||||||||||
| 196 | need to cast integer values to flags in a untyped fashion, you can | - | ||||||||||||||||||
| 197 | use the explicit QFlags constructor as cast operator. | - | ||||||||||||||||||
| 198 | - | |||||||||||||||||||
| 199 | If you want to use QFlags for your own enum types, use | - | ||||||||||||||||||
| 200 | the Q_DECLARE_FLAGS() and Q_DECLARE_OPERATORS_FOR_FLAGS(). | - | ||||||||||||||||||
| 201 | - | |||||||||||||||||||
| 202 | Example: | - | ||||||||||||||||||
| 203 | - | |||||||||||||||||||
| 204 | \snippet code/src_corelib_global_qglobal.cpp 1 | - | ||||||||||||||||||
| 205 | - | |||||||||||||||||||
| 206 | You can then use the \c MyClass::Options type to store | - | ||||||||||||||||||
| 207 | combinations of \c MyClass::Option values. | - | ||||||||||||||||||
| 208 | - | |||||||||||||||||||
| 209 | \section1 Flags and the Meta-Object System | - | ||||||||||||||||||
| 210 | - | |||||||||||||||||||
| 211 | The Q_DECLARE_FLAGS() macro does not expose the flags to the meta-object | - | ||||||||||||||||||
| 212 | system, so they cannot be used by Qt Script or edited in Qt Designer. | - | ||||||||||||||||||
| 213 | To make the flags available for these purposes, the Q_FLAG() macro must | - | ||||||||||||||||||
| 214 | be used: | - | ||||||||||||||||||
| 215 | - | |||||||||||||||||||
| 216 | \snippet code/src_corelib_global_qglobal.cpp meta-object flags | - | ||||||||||||||||||
| 217 | - | |||||||||||||||||||
| 218 | \section1 Naming Convention | - | ||||||||||||||||||
| 219 | - | |||||||||||||||||||
| 220 | A sensible naming convention for enum types and associated QFlags | - | ||||||||||||||||||
| 221 | types is to give a singular name to the enum type (e.g., \c | - | ||||||||||||||||||
| 222 | Option) and a plural name to the QFlags type (e.g., \c Options). | - | ||||||||||||||||||
| 223 | When a singular name is desired for the QFlags type (e.g., \c | - | ||||||||||||||||||
| 224 | Alignment), you can use \c Flag as the suffix for the enum type | - | ||||||||||||||||||
| 225 | (e.g., \c AlignmentFlag). | - | ||||||||||||||||||
| 226 | - | |||||||||||||||||||
| 227 | \sa QFlag | - | ||||||||||||||||||
| 228 | */ | - | ||||||||||||||||||
| 229 | - | |||||||||||||||||||
| 230 | /*! | - | ||||||||||||||||||
| 231 | \typedef QFlags::Int | - | ||||||||||||||||||
| 232 | \since 5.0 | - | ||||||||||||||||||
| 233 | - | |||||||||||||||||||
| 234 | Typedef for the integer type used for storage as well as for | - | ||||||||||||||||||
| 235 | implicit conversion. Either \c int or \c{unsigned int}, depending | - | ||||||||||||||||||
| 236 | on whether the enum's underlying type is signed or unsigned. | - | ||||||||||||||||||
| 237 | */ | - | ||||||||||||||||||
| 238 | - | |||||||||||||||||||
| 239 | /*! | - | ||||||||||||||||||
| 240 | \typedef QFlags::enum_type | - | ||||||||||||||||||
| 241 | - | |||||||||||||||||||
| 242 | Typedef for the Enum template type. | - | ||||||||||||||||||
| 243 | */ | - | ||||||||||||||||||
| 244 | - | |||||||||||||||||||
| 245 | /*! | - | ||||||||||||||||||
| 246 | \fn QFlags::QFlags(const QFlags &other) | - | ||||||||||||||||||
| 247 | - | |||||||||||||||||||
| 248 | Constructs a copy of \a other. | - | ||||||||||||||||||
| 249 | */ | - | ||||||||||||||||||
| 250 | - | |||||||||||||||||||
| 251 | /*! | - | ||||||||||||||||||
| 252 | \fn QFlags::QFlags(Enum flag) | - | ||||||||||||||||||
| 253 | - | |||||||||||||||||||
| 254 | Constructs a QFlags object storing the given \a flag. | - | ||||||||||||||||||
| 255 | */ | - | ||||||||||||||||||
| 256 | - | |||||||||||||||||||
| 257 | /*! | - | ||||||||||||||||||
| 258 | \fn QFlags::QFlags(Zero zero) | - | ||||||||||||||||||
| 259 | - | |||||||||||||||||||
| 260 | Constructs a QFlags object with no flags set. \a zero must be a | - | ||||||||||||||||||
| 261 | literal 0 value. | - | ||||||||||||||||||
| 262 | */ | - | ||||||||||||||||||
| 263 | - | |||||||||||||||||||
| 264 | /*! | - | ||||||||||||||||||
| 265 | \fn QFlags::QFlags(QFlag value) | - | ||||||||||||||||||
| 266 | - | |||||||||||||||||||
| 267 | Constructs a QFlags object initialized with the given integer \a | - | ||||||||||||||||||
| 268 | value. | - | ||||||||||||||||||
| 269 | - | |||||||||||||||||||
| 270 | The QFlag type is a helper type. By using it here instead of \c | - | ||||||||||||||||||
| 271 | int, we effectively ensure that arbitrary enum values cannot be | - | ||||||||||||||||||
| 272 | cast to a QFlags, whereas untyped enum values (i.e., \c int | - | ||||||||||||||||||
| 273 | values) can. | - | ||||||||||||||||||
| 274 | */ | - | ||||||||||||||||||
| 275 | - | |||||||||||||||||||
| 276 | /*! | - | ||||||||||||||||||
| 277 | \fn QFlags::QFlags(std::initializer_list<Enum> flags) | - | ||||||||||||||||||
| 278 | \since 5.4 | - | ||||||||||||||||||
| 279 | - | |||||||||||||||||||
| 280 | Constructs a QFlags object initialized with all \a flags | - | ||||||||||||||||||
| 281 | combined using the bitwise OR operator. | - | ||||||||||||||||||
| 282 | - | |||||||||||||||||||
| 283 | \sa operator|=(), operator|() | - | ||||||||||||||||||
| 284 | */ | - | ||||||||||||||||||
| 285 | - | |||||||||||||||||||
| 286 | /*! | - | ||||||||||||||||||
| 287 | \fn QFlags &QFlags::operator=(const QFlags &other) | - | ||||||||||||||||||
| 288 | - | |||||||||||||||||||
| 289 | Assigns \a other to this object and returns a reference to this | - | ||||||||||||||||||
| 290 | object. | - | ||||||||||||||||||
| 291 | */ | - | ||||||||||||||||||
| 292 | - | |||||||||||||||||||
| 293 | /*! | - | ||||||||||||||||||
| 294 | \fn QFlags &QFlags::operator&=(int mask) | - | ||||||||||||||||||
| 295 | - | |||||||||||||||||||
| 296 | Performs a bitwise AND operation with \a mask and stores the | - | ||||||||||||||||||
| 297 | result in this QFlags object. Returns a reference to this object. | - | ||||||||||||||||||
| 298 | - | |||||||||||||||||||
| 299 | \sa operator&(), operator|=(), operator^=() | - | ||||||||||||||||||
| 300 | */ | - | ||||||||||||||||||
| 301 | - | |||||||||||||||||||
| 302 | /*! | - | ||||||||||||||||||
| 303 | \fn QFlags &QFlags::operator&=(uint mask) | - | ||||||||||||||||||
| 304 | - | |||||||||||||||||||
| 305 | \overload | - | ||||||||||||||||||
| 306 | */ | - | ||||||||||||||||||
| 307 | - | |||||||||||||||||||
| 308 | /*! | - | ||||||||||||||||||
| 309 | \fn QFlags &QFlags::operator&=(Enum mask) | - | ||||||||||||||||||
| 310 | - | |||||||||||||||||||
| 311 | \overload | - | ||||||||||||||||||
| 312 | */ | - | ||||||||||||||||||
| 313 | - | |||||||||||||||||||
| 314 | /*! | - | ||||||||||||||||||
| 315 | \fn QFlags &QFlags::operator|=(QFlags other) | - | ||||||||||||||||||
| 316 | - | |||||||||||||||||||
| 317 | Performs a bitwise OR operation with \a other and stores the | - | ||||||||||||||||||
| 318 | result in this QFlags object. Returns a reference to this object. | - | ||||||||||||||||||
| 319 | - | |||||||||||||||||||
| 320 | \sa operator|(), operator&=(), operator^=() | - | ||||||||||||||||||
| 321 | */ | - | ||||||||||||||||||
| 322 | - | |||||||||||||||||||
| 323 | /*! | - | ||||||||||||||||||
| 324 | \fn QFlags &QFlags::operator|=(Enum other) | - | ||||||||||||||||||
| 325 | - | |||||||||||||||||||
| 326 | \overload | - | ||||||||||||||||||
| 327 | */ | - | ||||||||||||||||||
| 328 | - | |||||||||||||||||||
| 329 | /*! | - | ||||||||||||||||||
| 330 | \fn QFlags &QFlags::operator^=(QFlags other) | - | ||||||||||||||||||
| 331 | - | |||||||||||||||||||
| 332 | Performs a bitwise XOR operation with \a other and stores the | - | ||||||||||||||||||
| 333 | result in this QFlags object. Returns a reference to this object. | - | ||||||||||||||||||
| 334 | - | |||||||||||||||||||
| 335 | \sa operator^(), operator&=(), operator|=() | - | ||||||||||||||||||
| 336 | */ | - | ||||||||||||||||||
| 337 | - | |||||||||||||||||||
| 338 | /*! | - | ||||||||||||||||||
| 339 | \fn QFlags &QFlags::operator^=(Enum other) | - | ||||||||||||||||||
| 340 | - | |||||||||||||||||||
| 341 | \overload | - | ||||||||||||||||||
| 342 | */ | - | ||||||||||||||||||
| 343 | - | |||||||||||||||||||
| 344 | /*! | - | ||||||||||||||||||
| 345 | \fn QFlags::operator Int() const | - | ||||||||||||||||||
| 346 | - | |||||||||||||||||||
| 347 | Returns the value stored in the QFlags object as an integer. | - | ||||||||||||||||||
| 348 | - | |||||||||||||||||||
| 349 | \sa Int | - | ||||||||||||||||||
| 350 | */ | - | ||||||||||||||||||
| 351 | - | |||||||||||||||||||
| 352 | /*! | - | ||||||||||||||||||
| 353 | \fn QFlags QFlags::operator|(QFlags other) const | - | ||||||||||||||||||
| 354 | - | |||||||||||||||||||
| 355 | Returns a QFlags object containing the result of the bitwise OR | - | ||||||||||||||||||
| 356 | operation on this object and \a other. | - | ||||||||||||||||||
| 357 | - | |||||||||||||||||||
| 358 | \sa operator|=(), operator^(), operator&(), operator~() | - | ||||||||||||||||||
| 359 | */ | - | ||||||||||||||||||
| 360 | - | |||||||||||||||||||
| 361 | /*! | - | ||||||||||||||||||
| 362 | \fn QFlags QFlags::operator|(Enum other) const | - | ||||||||||||||||||
| 363 | - | |||||||||||||||||||
| 364 | \overload | - | ||||||||||||||||||
| 365 | */ | - | ||||||||||||||||||
| 366 | - | |||||||||||||||||||
| 367 | /*! | - | ||||||||||||||||||
| 368 | \fn QFlags QFlags::operator^(QFlags other) const | - | ||||||||||||||||||
| 369 | - | |||||||||||||||||||
| 370 | Returns a QFlags object containing the result of the bitwise XOR | - | ||||||||||||||||||
| 371 | operation on this object and \a other. | - | ||||||||||||||||||
| 372 | - | |||||||||||||||||||
| 373 | \sa operator^=(), operator&(), operator|(), operator~() | - | ||||||||||||||||||
| 374 | */ | - | ||||||||||||||||||
| 375 | - | |||||||||||||||||||
| 376 | /*! | - | ||||||||||||||||||
| 377 | \fn QFlags QFlags::operator^(Enum other) const | - | ||||||||||||||||||
| 378 | - | |||||||||||||||||||
| 379 | \overload | - | ||||||||||||||||||
| 380 | */ | - | ||||||||||||||||||
| 381 | - | |||||||||||||||||||
| 382 | /*! | - | ||||||||||||||||||
| 383 | \fn QFlags QFlags::operator&(int mask) const | - | ||||||||||||||||||
| 384 | - | |||||||||||||||||||
| 385 | Returns a QFlags object containing the result of the bitwise AND | - | ||||||||||||||||||
| 386 | operation on this object and \a mask. | - | ||||||||||||||||||
| 387 | - | |||||||||||||||||||
| 388 | \sa operator&=(), operator|(), operator^(), operator~() | - | ||||||||||||||||||
| 389 | */ | - | ||||||||||||||||||
| 390 | - | |||||||||||||||||||
| 391 | /*! | - | ||||||||||||||||||
| 392 | \fn QFlags QFlags::operator&(uint mask) const | - | ||||||||||||||||||
| 393 | - | |||||||||||||||||||
| 394 | \overload | - | ||||||||||||||||||
| 395 | */ | - | ||||||||||||||||||
| 396 | - | |||||||||||||||||||
| 397 | /*! | - | ||||||||||||||||||
| 398 | \fn QFlags QFlags::operator&(Enum mask) const | - | ||||||||||||||||||
| 399 | - | |||||||||||||||||||
| 400 | \overload | - | ||||||||||||||||||
| 401 | */ | - | ||||||||||||||||||
| 402 | - | |||||||||||||||||||
| 403 | /*! | - | ||||||||||||||||||
| 404 | \fn QFlags QFlags::operator~() const | - | ||||||||||||||||||
| 405 | - | |||||||||||||||||||
| 406 | Returns a QFlags object that contains the bitwise negation of | - | ||||||||||||||||||
| 407 | this object. | - | ||||||||||||||||||
| 408 | - | |||||||||||||||||||
| 409 | \sa operator&(), operator|(), operator^() | - | ||||||||||||||||||
| 410 | */ | - | ||||||||||||||||||
| 411 | - | |||||||||||||||||||
| 412 | /*! | - | ||||||||||||||||||
| 413 | \fn bool QFlags::operator!() const | - | ||||||||||||||||||
| 414 | - | |||||||||||||||||||
| 415 | Returns \c true if no flag is set (i.e., if the value stored by the | - | ||||||||||||||||||
| 416 | QFlags object is 0); otherwise returns \c false. | - | ||||||||||||||||||
| 417 | */ | - | ||||||||||||||||||
| 418 | - | |||||||||||||||||||
| 419 | /*! | - | ||||||||||||||||||
| 420 | \fn bool QFlags::testFlag(Enum flag) const | - | ||||||||||||||||||
| 421 | \since 4.2 | - | ||||||||||||||||||
| 422 | - | |||||||||||||||||||
| 423 | Returns \c true if the \a flag is set, otherwise \c false. | - | ||||||||||||||||||
| 424 | */ | - | ||||||||||||||||||
| 425 | - | |||||||||||||||||||
| 426 | /*! | - | ||||||||||||||||||
| 427 | \macro Q_DISABLE_COPY(Class) | - | ||||||||||||||||||
| 428 | \relates QObject | - | ||||||||||||||||||
| 429 | - | |||||||||||||||||||
| 430 | Disables the use of copy constructors and assignment operators | - | ||||||||||||||||||
| 431 | for the given \a Class. | - | ||||||||||||||||||
| 432 | - | |||||||||||||||||||
| 433 | Instances of subclasses of QObject should not be thought of as | - | ||||||||||||||||||
| 434 | values that can be copied or assigned, but as unique identities. | - | ||||||||||||||||||
| 435 | This means that when you create your own subclass of QObject | - | ||||||||||||||||||
| 436 | (director or indirect), you should \e not give it a copy constructor | - | ||||||||||||||||||
| 437 | or an assignment operator. However, it may not enough to simply | - | ||||||||||||||||||
| 438 | omit them from your class, because, if you mistakenly write some code | - | ||||||||||||||||||
| 439 | that requires a copy constructor or an assignment operator (it's easy | - | ||||||||||||||||||
| 440 | to do), your compiler will thoughtfully create it for you. You must | - | ||||||||||||||||||
| 441 | do more. | - | ||||||||||||||||||
| 442 | - | |||||||||||||||||||
| 443 | The curious user will have seen that the Qt classes derived | - | ||||||||||||||||||
| 444 | from QObject typically include this macro in a private section: | - | ||||||||||||||||||
| 445 | - | |||||||||||||||||||
| 446 | \snippet code/src_corelib_global_qglobal.cpp 43 | - | ||||||||||||||||||
| 447 | - | |||||||||||||||||||
| 448 | It declares a copy constructor and an assignment operator in the | - | ||||||||||||||||||
| 449 | private section, so that if you use them by mistake, the compiler | - | ||||||||||||||||||
| 450 | will report an error. | - | ||||||||||||||||||
| 451 | - | |||||||||||||||||||
| 452 | \snippet code/src_corelib_global_qglobal.cpp 44 | - | ||||||||||||||||||
| 453 | - | |||||||||||||||||||
| 454 | But even this might not catch absolutely every case. You might be | - | ||||||||||||||||||
| 455 | tempted to do something like this: | - | ||||||||||||||||||
| 456 | - | |||||||||||||||||||
| 457 | \snippet code/src_corelib_global_qglobal.cpp 45 | - | ||||||||||||||||||
| 458 | - | |||||||||||||||||||
| 459 | First of all, don't do that. Most compilers will generate code that | - | ||||||||||||||||||
| 460 | uses the copy constructor, so the privacy violation error will be | - | ||||||||||||||||||
| 461 | reported, but your C++ compiler is not required to generate code for | - | ||||||||||||||||||
| 462 | this statement in a specific way. It could generate code using | - | ||||||||||||||||||
| 463 | \e{neither} the copy constructor \e{nor} the assignment operator we | - | ||||||||||||||||||
| 464 | made private. In that case, no error would be reported, but your | - | ||||||||||||||||||
| 465 | application would probably crash when you called a member function | - | ||||||||||||||||||
| 466 | of \c{w}. | - | ||||||||||||||||||
| 467 | */ | - | ||||||||||||||||||
| 468 | - | |||||||||||||||||||
| 469 | /*! | - | ||||||||||||||||||
| 470 | \macro Q_DECLARE_FLAGS(Flags, Enum) | - | ||||||||||||||||||
| 471 | \relates QFlags | - | ||||||||||||||||||
| 472 | - | |||||||||||||||||||
| 473 | The Q_DECLARE_FLAGS() macro expands to | - | ||||||||||||||||||
| 474 | - | |||||||||||||||||||
| 475 | \snippet code/src_corelib_global_qglobal.cpp 2 | - | ||||||||||||||||||
| 476 | - | |||||||||||||||||||
| 477 | \a Enum is the name of an existing enum type, whereas \a Flags is | - | ||||||||||||||||||
| 478 | the name of the QFlags<\e{Enum}> typedef. | - | ||||||||||||||||||
| 479 | - | |||||||||||||||||||
| 480 | See the QFlags documentation for details. | - | ||||||||||||||||||
| 481 | - | |||||||||||||||||||
| 482 | \sa Q_DECLARE_OPERATORS_FOR_FLAGS() | - | ||||||||||||||||||
| 483 | */ | - | ||||||||||||||||||
| 484 | - | |||||||||||||||||||
| 485 | /*! | - | ||||||||||||||||||
| 486 | \macro Q_DECLARE_OPERATORS_FOR_FLAGS(Flags) | - | ||||||||||||||||||
| 487 | \relates QFlags | - | ||||||||||||||||||
| 488 | - | |||||||||||||||||||
| 489 | The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global \c | - | ||||||||||||||||||
| 490 | operator|() functions for \a Flags, which is of type QFlags<T>. | - | ||||||||||||||||||
| 491 | - | |||||||||||||||||||
| 492 | See the QFlags documentation for details. | - | ||||||||||||||||||
| 493 | - | |||||||||||||||||||
| 494 | \sa Q_DECLARE_FLAGS() | - | ||||||||||||||||||
| 495 | */ | - | ||||||||||||||||||
| 496 | - | |||||||||||||||||||
| 497 | /*! | - | ||||||||||||||||||
| 498 | \headerfile <QtGlobal> | - | ||||||||||||||||||
| 499 | \title Global Qt Declarations | - | ||||||||||||||||||
| 500 | \ingroup funclists | - | ||||||||||||||||||
| 501 | - | |||||||||||||||||||
| 502 | \brief The <QtGlobal> header file includes the fundamental global | - | ||||||||||||||||||
| 503 | declarations. It is included by most other Qt header files. | - | ||||||||||||||||||
| 504 | - | |||||||||||||||||||
| 505 | The global declarations include \l{types}, \l{functions} and | - | ||||||||||||||||||
| 506 | \l{macros}. | - | ||||||||||||||||||
| 507 | - | |||||||||||||||||||
| 508 | The type definitions are partly convenience definitions for basic | - | ||||||||||||||||||
| 509 | types (some of which guarantee certain bit-sizes on all platforms | - | ||||||||||||||||||
| 510 | supported by Qt), partly types related to Qt message handling. The | - | ||||||||||||||||||
| 511 | functions are related to generating messages, Qt version handling | - | ||||||||||||||||||
| 512 | and comparing and adjusting object values. And finally, some of | - | ||||||||||||||||||
| 513 | the declared macros enable programmers to add compiler or platform | - | ||||||||||||||||||
| 514 | specific code to their applications, while others are convenience | - | ||||||||||||||||||
| 515 | macros for larger operations. | - | ||||||||||||||||||
| 516 | - | |||||||||||||||||||
| 517 | \section1 Types | - | ||||||||||||||||||
| 518 | - | |||||||||||||||||||
| 519 | The header file declares several type definitions that guarantee a | - | ||||||||||||||||||
| 520 | specified bit-size on all platforms supported by Qt for various | - | ||||||||||||||||||
| 521 | basic types, for example \l qint8 which is a signed char | - | ||||||||||||||||||
| 522 | guaranteed to be 8-bit on all platforms supported by Qt. The | - | ||||||||||||||||||
| 523 | header file also declares the \l qlonglong type definition for \c | - | ||||||||||||||||||
| 524 | {long long int } (\c __int64 on Windows). | - | ||||||||||||||||||
| 525 | - | |||||||||||||||||||
| 526 | Several convenience type definitions are declared: \l qreal for \c | - | ||||||||||||||||||
| 527 | double, \l uchar for \c unsigned char, \l uint for \c unsigned | - | ||||||||||||||||||
| 528 | int, \l ulong for \c unsigned long and \l ushort for \c unsigned | - | ||||||||||||||||||
| 529 | short. | - | ||||||||||||||||||
| 530 | - | |||||||||||||||||||
| 531 | Finally, the QtMsgType definition identifies the various messages | - | ||||||||||||||||||
| 532 | that can be generated and sent to a Qt message handler; | - | ||||||||||||||||||
| 533 | QtMessageHandler is a type definition for a pointer to a function with | - | ||||||||||||||||||
| 534 | the signature | - | ||||||||||||||||||
| 535 | \c {void myMessageHandler(QtMsgType, const QMessageLogContext &, const char *)}. | - | ||||||||||||||||||
| 536 | QMessageLogContext class contains the line, file, and function the | - | ||||||||||||||||||
| 537 | message was logged at. This information is created by the QMessageLogger | - | ||||||||||||||||||
| 538 | class. | - | ||||||||||||||||||
| 539 | - | |||||||||||||||||||
| 540 | \section1 Functions | - | ||||||||||||||||||
| 541 | - | |||||||||||||||||||
| 542 | The <QtGlobal> header file contains several functions comparing | - | ||||||||||||||||||
| 543 | and adjusting an object's value. These functions take a template | - | ||||||||||||||||||
| 544 | type as argument: You can retrieve the absolute value of an object | - | ||||||||||||||||||
| 545 | using the qAbs() function, and you can bound a given object's | - | ||||||||||||||||||
| 546 | value by given minimum and maximum values using the qBound() | - | ||||||||||||||||||
| 547 | function. You can retrieve the minimum and maximum of two given | - | ||||||||||||||||||
| 548 | objects using qMin() and qMax() respectively. All these functions | - | ||||||||||||||||||
| 549 | return a corresponding template type; the template types can be | - | ||||||||||||||||||
| 550 | replaced by any other type. | - | ||||||||||||||||||
| 551 | - | |||||||||||||||||||
| 552 | Example: | - | ||||||||||||||||||
| 553 | - | |||||||||||||||||||
| 554 | \snippet code/src_corelib_global_qglobal.cpp 3 | - | ||||||||||||||||||
| 555 | - | |||||||||||||||||||
| 556 | <QtGlobal> also contains functions that generate messages from the | - | ||||||||||||||||||
| 557 | given string argument: qDebug(), qInfo(), qWarning(), qCritical(), | - | ||||||||||||||||||
| 558 | and qFatal(). These functions call the message handler | - | ||||||||||||||||||
| 559 | with the given message. | - | ||||||||||||||||||
| 560 | - | |||||||||||||||||||
| 561 | Example: | - | ||||||||||||||||||
| 562 | - | |||||||||||||||||||
| 563 | \snippet code/src_corelib_global_qglobal.cpp 4 | - | ||||||||||||||||||
| 564 | - | |||||||||||||||||||
| 565 | The remaining functions are qRound() and qRound64(), which both | - | ||||||||||||||||||
| 566 | accept a \l qreal value as their argument returning the value | - | ||||||||||||||||||
| 567 | rounded up to the nearest integer and 64-bit integer respectively, | - | ||||||||||||||||||
| 568 | the qInstallMessageHandler() function which installs the given | - | ||||||||||||||||||
| 569 | QtMessageHandler, and the qVersion() function which returns the | - | ||||||||||||||||||
| 570 | version number of Qt at run-time as a string. | - | ||||||||||||||||||
| 571 | - | |||||||||||||||||||
| 572 | \section1 Macros | - | ||||||||||||||||||
| 573 | - | |||||||||||||||||||
| 574 | The <QtGlobal> header file provides a range of macros (Q_CC_*) | - | ||||||||||||||||||
| 575 | that are defined if the application is compiled using the | - | ||||||||||||||||||
| 576 | specified platforms. For example, the Q_CC_SUN macro is defined if | - | ||||||||||||||||||
| 577 | the application is compiled using Forte Developer, or Sun Studio | - | ||||||||||||||||||
| 578 | C++. The header file also declares a range of macros (Q_OS_*) | - | ||||||||||||||||||
| 579 | that are defined for the specified platforms. For example, | - | ||||||||||||||||||
| 580 | Q_OS_UNIX which is defined for the Unix-based systems. | - | ||||||||||||||||||
| 581 | - | |||||||||||||||||||
| 582 | The purpose of these macros is to enable programmers to add | - | ||||||||||||||||||
| 583 | compiler or platform specific code to their application. | - | ||||||||||||||||||
| 584 | - | |||||||||||||||||||
| 585 | The remaining macros are convenience macros for larger operations: | - | ||||||||||||||||||
| 586 | The QT_TRANSLATE_NOOP() and QT_TR_NOOP() macros provide the | - | ||||||||||||||||||
| 587 | possibility of marking text for dynamic translation, | - | ||||||||||||||||||
| 588 | i.e. translation without changing the stored source text. The | - | ||||||||||||||||||
| 589 | Q_ASSERT() and Q_ASSERT_X() enables warning messages of various | - | ||||||||||||||||||
| 590 | level of refinement. The Q_FOREACH() and foreach() macros | - | ||||||||||||||||||
| 591 | implement Qt's foreach loop. | - | ||||||||||||||||||
| 592 | - | |||||||||||||||||||
| 593 | The Q_INT64_C() and Q_UINT64_C() macros wrap signed and unsigned | - | ||||||||||||||||||
| 594 | 64-bit integer literals in a platform-independent way. The | - | ||||||||||||||||||
| 595 | Q_CHECK_PTR() macro prints a warning containing the source code's | - | ||||||||||||||||||
| 596 | file name and line number, saying that the program ran out of | - | ||||||||||||||||||
| 597 | memory, if the pointer is 0. The qPrintable() and qUtf8Printable() | - | ||||||||||||||||||
| 598 | macros represent an easy way of printing text. | - | ||||||||||||||||||
| 599 | - | |||||||||||||||||||
| 600 | Finally, the QT_POINTER_SIZE macro expands to the size of a | - | ||||||||||||||||||
| 601 | pointer in bytes, and the QT_VERSION and QT_VERSION_STR macros | - | ||||||||||||||||||
| 602 | expand to a numeric value or a string, respectively, specifying | - | ||||||||||||||||||
| 603 | Qt's version number, i.e the version the application is compiled | - | ||||||||||||||||||
| 604 | against. | - | ||||||||||||||||||
| 605 | - | |||||||||||||||||||
| 606 | \sa <QtAlgorithms>, QSysInfo | - | ||||||||||||||||||
| 607 | */ | - | ||||||||||||||||||
| 608 | - | |||||||||||||||||||
| 609 | /*! | - | ||||||||||||||||||
| 610 | \typedef qreal | - | ||||||||||||||||||
| 611 | \relates <QtGlobal> | - | ||||||||||||||||||
| 612 | - | |||||||||||||||||||
| 613 | Typedef for \c double unless Qt is configured with the | - | ||||||||||||||||||
| 614 | \c{-qreal float} option. | - | ||||||||||||||||||
| 615 | */ | - | ||||||||||||||||||
| 616 | - | |||||||||||||||||||
| 617 | /*! \typedef uchar | - | ||||||||||||||||||
| 618 | \relates <QtGlobal> | - | ||||||||||||||||||
| 619 | - | |||||||||||||||||||
| 620 | Convenience typedef for \c{unsigned char}. | - | ||||||||||||||||||
| 621 | */ | - | ||||||||||||||||||
| 622 | - | |||||||||||||||||||
| 623 | /*! \typedef ushort | - | ||||||||||||||||||
| 624 | \relates <QtGlobal> | - | ||||||||||||||||||
| 625 | - | |||||||||||||||||||
| 626 | Convenience typedef for \c{unsigned short}. | - | ||||||||||||||||||
| 627 | */ | - | ||||||||||||||||||
| 628 | - | |||||||||||||||||||
| 629 | /*! \typedef uint | - | ||||||||||||||||||
| 630 | \relates <QtGlobal> | - | ||||||||||||||||||
| 631 | - | |||||||||||||||||||
| 632 | Convenience typedef for \c{unsigned int}. | - | ||||||||||||||||||
| 633 | */ | - | ||||||||||||||||||
| 634 | - | |||||||||||||||||||
| 635 | /*! \typedef ulong | - | ||||||||||||||||||
| 636 | \relates <QtGlobal> | - | ||||||||||||||||||
| 637 | - | |||||||||||||||||||
| 638 | Convenience typedef for \c{unsigned long}. | - | ||||||||||||||||||
| 639 | */ | - | ||||||||||||||||||
| 640 | - | |||||||||||||||||||
| 641 | /*! \typedef qint8 | - | ||||||||||||||||||
| 642 | \relates <QtGlobal> | - | ||||||||||||||||||
| 643 | - | |||||||||||||||||||
| 644 | Typedef for \c{signed char}. This type is guaranteed to be 8-bit | - | ||||||||||||||||||
| 645 | on all platforms supported by Qt. | - | ||||||||||||||||||
| 646 | */ | - | ||||||||||||||||||
| 647 | - | |||||||||||||||||||
| 648 | /*! | - | ||||||||||||||||||
| 649 | \typedef quint8 | - | ||||||||||||||||||
| 650 | \relates <QtGlobal> | - | ||||||||||||||||||
| 651 | - | |||||||||||||||||||
| 652 | Typedef for \c{unsigned char}. This type is guaranteed to | - | ||||||||||||||||||
| 653 | be 8-bit on all platforms supported by Qt. | - | ||||||||||||||||||
| 654 | */ | - | ||||||||||||||||||
| 655 | - | |||||||||||||||||||
| 656 | /*! \typedef qint16 | - | ||||||||||||||||||
| 657 | \relates <QtGlobal> | - | ||||||||||||||||||
| 658 | - | |||||||||||||||||||
| 659 | Typedef for \c{signed short}. This type is guaranteed to be | - | ||||||||||||||||||
| 660 | 16-bit on all platforms supported by Qt. | - | ||||||||||||||||||
| 661 | */ | - | ||||||||||||||||||
| 662 | - | |||||||||||||||||||
| 663 | /*! | - | ||||||||||||||||||
| 664 | \typedef quint16 | - | ||||||||||||||||||
| 665 | \relates <QtGlobal> | - | ||||||||||||||||||
| 666 | - | |||||||||||||||||||
| 667 | Typedef for \c{unsigned short}. This type is guaranteed to | - | ||||||||||||||||||
| 668 | be 16-bit on all platforms supported by Qt. | - | ||||||||||||||||||
| 669 | */ | - | ||||||||||||||||||
| 670 | - | |||||||||||||||||||
| 671 | /*! \typedef qint32 | - | ||||||||||||||||||
| 672 | \relates <QtGlobal> | - | ||||||||||||||||||
| 673 | - | |||||||||||||||||||
| 674 | Typedef for \c{signed int}. This type is guaranteed to be 32-bit | - | ||||||||||||||||||
| 675 | on all platforms supported by Qt. | - | ||||||||||||||||||
| 676 | */ | - | ||||||||||||||||||
| 677 | - | |||||||||||||||||||
| 678 | /*! | - | ||||||||||||||||||
| 679 | \typedef quint32 | - | ||||||||||||||||||
| 680 | \relates <QtGlobal> | - | ||||||||||||||||||
| 681 | - | |||||||||||||||||||
| 682 | Typedef for \c{unsigned int}. This type is guaranteed to | - | ||||||||||||||||||
| 683 | be 32-bit on all platforms supported by Qt. | - | ||||||||||||||||||
| 684 | */ | - | ||||||||||||||||||
| 685 | - | |||||||||||||||||||
| 686 | /*! \typedef qint64 | - | ||||||||||||||||||
| 687 | \relates <QtGlobal> | - | ||||||||||||||||||
| 688 | - | |||||||||||||||||||
| 689 | Typedef for \c{long long int} (\c __int64 on Windows). This type | - | ||||||||||||||||||
| 690 | is guaranteed to be 64-bit on all platforms supported by Qt. | - | ||||||||||||||||||
| 691 | - | |||||||||||||||||||
| 692 | Literals of this type can be created using the Q_INT64_C() macro: | - | ||||||||||||||||||
| 693 | - | |||||||||||||||||||
| 694 | \snippet code/src_corelib_global_qglobal.cpp 5 | - | ||||||||||||||||||
| 695 | - | |||||||||||||||||||
| 696 | \sa Q_INT64_C(), quint64, qlonglong | - | ||||||||||||||||||
| 697 | */ | - | ||||||||||||||||||
| 698 | - | |||||||||||||||||||
| 699 | /*! | - | ||||||||||||||||||
| 700 | \typedef quint64 | - | ||||||||||||||||||
| 701 | \relates <QtGlobal> | - | ||||||||||||||||||
| 702 | - | |||||||||||||||||||
| 703 | Typedef for \c{unsigned long long int} (\c{unsigned __int64} on | - | ||||||||||||||||||
| 704 | Windows). This type is guaranteed to be 64-bit on all platforms | - | ||||||||||||||||||
| 705 | supported by Qt. | - | ||||||||||||||||||
| 706 | - | |||||||||||||||||||
| 707 | Literals of this type can be created using the Q_UINT64_C() | - | ||||||||||||||||||
| 708 | macro: | - | ||||||||||||||||||
| 709 | - | |||||||||||||||||||
| 710 | \snippet code/src_corelib_global_qglobal.cpp 6 | - | ||||||||||||||||||
| 711 | - | |||||||||||||||||||
| 712 | \sa Q_UINT64_C(), qint64, qulonglong | - | ||||||||||||||||||
| 713 | */ | - | ||||||||||||||||||
| 714 | - | |||||||||||||||||||
| 715 | /*! | - | ||||||||||||||||||
| 716 | \typedef qintptr | - | ||||||||||||||||||
| 717 | \relates <QtGlobal> | - | ||||||||||||||||||
| 718 | - | |||||||||||||||||||
| 719 | Integral type for representing pointers in a signed integer (useful for | - | ||||||||||||||||||
| 720 | hashing, etc.). | - | ||||||||||||||||||
| 721 | - | |||||||||||||||||||
| 722 | Typedef for either qint32 or qint64. This type is guaranteed to | - | ||||||||||||||||||
| 723 | be the same size as a pointer on all platforms supported by Qt. On | - | ||||||||||||||||||
| 724 | a system with 32-bit pointers, qintptr is a typedef for qint32; | - | ||||||||||||||||||
| 725 | on a system with 64-bit pointers, qintptr is a typedef for | - | ||||||||||||||||||
| 726 | qint64. | - | ||||||||||||||||||
| 727 | - | |||||||||||||||||||
| 728 | Note that qintptr is signed. Use quintptr for unsigned values. | - | ||||||||||||||||||
| 729 | - | |||||||||||||||||||
| 730 | \sa qptrdiff, qint32, qint64 | - | ||||||||||||||||||
| 731 | */ | - | ||||||||||||||||||
| 732 | - | |||||||||||||||||||
| 733 | /*! | - | ||||||||||||||||||
| 734 | \typedef quintptr | - | ||||||||||||||||||
| 735 | \relates <QtGlobal> | - | ||||||||||||||||||
| 736 | - | |||||||||||||||||||
| 737 | Integral type for representing pointers in an unsigned integer (useful for | - | ||||||||||||||||||
| 738 | hashing, etc.). | - | ||||||||||||||||||
| 739 | - | |||||||||||||||||||
| 740 | Typedef for either quint32 or quint64. This type is guaranteed to | - | ||||||||||||||||||
| 741 | be the same size as a pointer on all platforms supported by Qt. On | - | ||||||||||||||||||
| 742 | a system with 32-bit pointers, quintptr is a typedef for quint32; | - | ||||||||||||||||||
| 743 | on a system with 64-bit pointers, quintptr is a typedef for | - | ||||||||||||||||||
| 744 | quint64. | - | ||||||||||||||||||
| 745 | - | |||||||||||||||||||
| 746 | Note that quintptr is unsigned. Use qptrdiff for signed values. | - | ||||||||||||||||||
| 747 | - | |||||||||||||||||||
| 748 | \sa qptrdiff, quint32, quint64 | - | ||||||||||||||||||
| 749 | */ | - | ||||||||||||||||||
| 750 | - | |||||||||||||||||||
| 751 | /*! | - | ||||||||||||||||||
| 752 | \typedef qptrdiff | - | ||||||||||||||||||
| 753 | \relates <QtGlobal> | - | ||||||||||||||||||
| 754 | - | |||||||||||||||||||
| 755 | Integral type for representing pointer differences. | - | ||||||||||||||||||
| 756 | - | |||||||||||||||||||
| 757 | Typedef for either qint32 or qint64. This type is guaranteed to be | - | ||||||||||||||||||
| 758 | the same size as a pointer on all platforms supported by Qt. On a | - | ||||||||||||||||||
| 759 | system with 32-bit pointers, quintptr is a typedef for quint32; on | - | ||||||||||||||||||
| 760 | a system with 64-bit pointers, quintptr is a typedef for quint64. | - | ||||||||||||||||||
| 761 | - | |||||||||||||||||||
| 762 | Note that qptrdiff is signed. Use quintptr for unsigned values. | - | ||||||||||||||||||
| 763 | - | |||||||||||||||||||
| 764 | \sa quintptr, qint32, qint64 | - | ||||||||||||||||||
| 765 | */ | - | ||||||||||||||||||
| 766 | - | |||||||||||||||||||
| 767 | /*! | - | ||||||||||||||||||
| 768 | \enum QtMsgType | - | ||||||||||||||||||
| 769 | \relates <QtGlobal> | - | ||||||||||||||||||
| 770 | - | |||||||||||||||||||
| 771 | This enum describes the messages that can be sent to a message | - | ||||||||||||||||||
| 772 | handler (QtMessageHandler). You can use the enum to identify and | - | ||||||||||||||||||
| 773 | associate the various message types with the appropriate | - | ||||||||||||||||||
| 774 | actions. | - | ||||||||||||||||||
| 775 | - | |||||||||||||||||||
| 776 | \value QtDebugMsg | - | ||||||||||||||||||
| 777 | A message generated by the qDebug() function. | - | ||||||||||||||||||
| 778 | \value QtInfoMsg | - | ||||||||||||||||||
| 779 | A message generated by the qInfo() function. | - | ||||||||||||||||||
| 780 | \value QtWarningMsg | - | ||||||||||||||||||
| 781 | A message generated by the qWarning() function. | - | ||||||||||||||||||
| 782 | \value QtCriticalMsg | - | ||||||||||||||||||
| 783 | A message generated by the qCritical() function. | - | ||||||||||||||||||
| 784 | \value QtFatalMsg | - | ||||||||||||||||||
| 785 | A message generated by the qFatal() function. | - | ||||||||||||||||||
| 786 | \value QtSystemMsg | - | ||||||||||||||||||
| 787 | - | |||||||||||||||||||
| 788 | \c QtInfoMsg was added in Qt 5.5. | - | ||||||||||||||||||
| 789 | - | |||||||||||||||||||
| 790 | \sa QtMessageHandler, qInstallMessageHandler() | - | ||||||||||||||||||
| 791 | */ | - | ||||||||||||||||||
| 792 | - | |||||||||||||||||||
| 793 | /*! \typedef QFunctionPointer | - | ||||||||||||||||||
| 794 | \relates <QtGlobal> | - | ||||||||||||||||||
| 795 | - | |||||||||||||||||||
| 796 | This is a typedef for \c{void (*)()}, a pointer to a function that takes | - | ||||||||||||||||||
| 797 | no arguments and returns void. | - | ||||||||||||||||||
| 798 | */ | - | ||||||||||||||||||
| 799 | - | |||||||||||||||||||
| 800 | /*! \macro qint64 Q_INT64_C(literal) | - | ||||||||||||||||||
| 801 | \relates <QtGlobal> | - | ||||||||||||||||||
| 802 | - | |||||||||||||||||||
| 803 | Wraps the signed 64-bit integer \a literal in a | - | ||||||||||||||||||
| 804 | platform-independent way. | - | ||||||||||||||||||
| 805 | - | |||||||||||||||||||
| 806 | Example: | - | ||||||||||||||||||
| 807 | - | |||||||||||||||||||
| 808 | \snippet code/src_corelib_global_qglobal.cpp 8 | - | ||||||||||||||||||
| 809 | - | |||||||||||||||||||
| 810 | \sa qint64, Q_UINT64_C() | - | ||||||||||||||||||
| 811 | */ | - | ||||||||||||||||||
| 812 | - | |||||||||||||||||||
| 813 | /*! \macro quint64 Q_UINT64_C(literal) | - | ||||||||||||||||||
| 814 | \relates <QtGlobal> | - | ||||||||||||||||||
| 815 | - | |||||||||||||||||||
| 816 | Wraps the unsigned 64-bit integer \a literal in a | - | ||||||||||||||||||
| 817 | platform-independent way. | - | ||||||||||||||||||
| 818 | - | |||||||||||||||||||
| 819 | Example: | - | ||||||||||||||||||
| 820 | - | |||||||||||||||||||
| 821 | \snippet code/src_corelib_global_qglobal.cpp 9 | - | ||||||||||||||||||
| 822 | - | |||||||||||||||||||
| 823 | \sa quint64, Q_INT64_C() | - | ||||||||||||||||||
| 824 | */ | - | ||||||||||||||||||
| 825 | - | |||||||||||||||||||
| 826 | /*! \typedef qlonglong | - | ||||||||||||||||||
| 827 | \relates <QtGlobal> | - | ||||||||||||||||||
| 828 | - | |||||||||||||||||||
| 829 | Typedef for \c{long long int} (\c __int64 on Windows). This is | - | ||||||||||||||||||
| 830 | the same as \l qint64. | - | ||||||||||||||||||
| 831 | - | |||||||||||||||||||
| 832 | \sa qulonglong, qint64 | - | ||||||||||||||||||
| 833 | */ | - | ||||||||||||||||||
| 834 | - | |||||||||||||||||||
| 835 | /*! | - | ||||||||||||||||||
| 836 | \typedef qulonglong | - | ||||||||||||||||||
| 837 | \relates <QtGlobal> | - | ||||||||||||||||||
| 838 | - | |||||||||||||||||||
| 839 | Typedef for \c{unsigned long long int} (\c{unsigned __int64} on | - | ||||||||||||||||||
| 840 | Windows). This is the same as \l quint64. | - | ||||||||||||||||||
| 841 | - | |||||||||||||||||||
| 842 | \sa quint64, qlonglong | - | ||||||||||||||||||
| 843 | */ | - | ||||||||||||||||||
| 844 | - | |||||||||||||||||||
| 845 | /*! \fn T qAbs(const T &value) | - | ||||||||||||||||||
| 846 | \relates <QtGlobal> | - | ||||||||||||||||||
| 847 | - | |||||||||||||||||||
| 848 | Compares \a value to the 0 of type T and returns the absolute | - | ||||||||||||||||||
| 849 | value. Thus if T is \e {double}, then \a value is compared to | - | ||||||||||||||||||
| 850 | \e{(double) 0}. | - | ||||||||||||||||||
| 851 | - | |||||||||||||||||||
| 852 | Example: | - | ||||||||||||||||||
| 853 | - | |||||||||||||||||||
| 854 | \snippet code/src_corelib_global_qglobal.cpp 10 | - | ||||||||||||||||||
| 855 | */ | - | ||||||||||||||||||
| 856 | - | |||||||||||||||||||
| 857 | /*! \fn int qRound(qreal value) | - | ||||||||||||||||||
| 858 | \relates <QtGlobal> | - | ||||||||||||||||||
| 859 | - | |||||||||||||||||||
| 860 | Rounds \a value to the nearest integer. | - | ||||||||||||||||||
| 861 | - | |||||||||||||||||||
| 862 | Example: | - | ||||||||||||||||||
| 863 | - | |||||||||||||||||||
| 864 | \snippet code/src_corelib_global_qglobal.cpp 11 | - | ||||||||||||||||||
| 865 | */ | - | ||||||||||||||||||
| 866 | - | |||||||||||||||||||
| 867 | /*! \fn qint64 qRound64(qreal value) | - | ||||||||||||||||||
| 868 | \relates <QtGlobal> | - | ||||||||||||||||||
| 869 | - | |||||||||||||||||||
| 870 | Rounds \a value to the nearest 64-bit integer. | - | ||||||||||||||||||
| 871 | - | |||||||||||||||||||
| 872 | Example: | - | ||||||||||||||||||
| 873 | - | |||||||||||||||||||
| 874 | \snippet code/src_corelib_global_qglobal.cpp 12 | - | ||||||||||||||||||
| 875 | */ | - | ||||||||||||||||||
| 876 | - | |||||||||||||||||||
| 877 | /*! \fn const T &qMin(const T &value1, const T &value2) | - | ||||||||||||||||||
| 878 | \relates <QtGlobal> | - | ||||||||||||||||||
| 879 | - | |||||||||||||||||||
| 880 | Returns the minimum of \a value1 and \a value2. | - | ||||||||||||||||||
| 881 | - | |||||||||||||||||||
| 882 | Example: | - | ||||||||||||||||||
| 883 | - | |||||||||||||||||||
| 884 | \snippet code/src_corelib_global_qglobal.cpp 13 | - | ||||||||||||||||||
| 885 | - | |||||||||||||||||||
| 886 | \sa qMax(), qBound() | - | ||||||||||||||||||
| 887 | */ | - | ||||||||||||||||||
| 888 | - | |||||||||||||||||||
| 889 | /*! \fn const T &qMax(const T &value1, const T &value2) | - | ||||||||||||||||||
| 890 | \relates <QtGlobal> | - | ||||||||||||||||||
| 891 | - | |||||||||||||||||||
| 892 | Returns the maximum of \a value1 and \a value2. | - | ||||||||||||||||||
| 893 | - | |||||||||||||||||||
| 894 | Example: | - | ||||||||||||||||||
| 895 | - | |||||||||||||||||||
| 896 | \snippet code/src_corelib_global_qglobal.cpp 14 | - | ||||||||||||||||||
| 897 | - | |||||||||||||||||||
| 898 | \sa qMin(), qBound() | - | ||||||||||||||||||
| 899 | */ | - | ||||||||||||||||||
| 900 | - | |||||||||||||||||||
| 901 | /*! \fn const T &qBound(const T &min, const T &value, const T &max) | - | ||||||||||||||||||
| 902 | \relates <QtGlobal> | - | ||||||||||||||||||
| 903 | - | |||||||||||||||||||
| 904 | Returns \a value bounded by \a min and \a max. This is equivalent | - | ||||||||||||||||||
| 905 | to qMax(\a min, qMin(\a value, \a max)). | - | ||||||||||||||||||
| 906 | - | |||||||||||||||||||
| 907 | Example: | - | ||||||||||||||||||
| 908 | - | |||||||||||||||||||
| 909 | \snippet code/src_corelib_global_qglobal.cpp 15 | - | ||||||||||||||||||
| 910 | - | |||||||||||||||||||
| 911 | \sa qMin(), qMax() | - | ||||||||||||||||||
| 912 | */ | - | ||||||||||||||||||
| 913 | - | |||||||||||||||||||
| 914 | /*! | - | ||||||||||||||||||
| 915 | \macro QT_VERSION_CHECK | - | ||||||||||||||||||
| 916 | \relates <QtGlobal> | - | ||||||||||||||||||
| 917 | - | |||||||||||||||||||
| 918 | Turns the major, minor and patch numbers of a version into an | - | ||||||||||||||||||
| 919 | integer, 0xMMNNPP (MM = major, NN = minor, PP = patch). This can | - | ||||||||||||||||||
| 920 | be compared with another similarly processed version id. | - | ||||||||||||||||||
| 921 | - | |||||||||||||||||||
| 922 | Example: | - | ||||||||||||||||||
| 923 | - | |||||||||||||||||||
| 924 | \snippet code/src_corelib_global_qglobal.cpp qt-version-check | - | ||||||||||||||||||
| 925 | - | |||||||||||||||||||
| 926 | \sa QT_VERSION | - | ||||||||||||||||||
| 927 | */ | - | ||||||||||||||||||
| 928 | - | |||||||||||||||||||
| 929 | /*! | - | ||||||||||||||||||
| 930 | \macro QT_VERSION | - | ||||||||||||||||||
| 931 | \relates <QtGlobal> | - | ||||||||||||||||||
| 932 | - | |||||||||||||||||||
| 933 | This macro expands a numeric value of the form 0xMMNNPP (MM = | - | ||||||||||||||||||
| 934 | major, NN = minor, PP = patch) that specifies Qt's version | - | ||||||||||||||||||
| 935 | number. For example, if you compile your application against Qt | - | ||||||||||||||||||
| 936 | 4.1.2, the QT_VERSION macro will expand to 0x040102. | - | ||||||||||||||||||
| 937 | - | |||||||||||||||||||
| 938 | You can use QT_VERSION to use the latest Qt features where | - | ||||||||||||||||||
| 939 | available. | - | ||||||||||||||||||
| 940 | - | |||||||||||||||||||
| 941 | Example: | - | ||||||||||||||||||
| 942 | - | |||||||||||||||||||
| 943 | \snippet code/src_corelib_global_qglobal.cpp 16 | - | ||||||||||||||||||
| 944 | - | |||||||||||||||||||
| 945 | \sa QT_VERSION_STR, qVersion() | - | ||||||||||||||||||
| 946 | */ | - | ||||||||||||||||||
| 947 | - | |||||||||||||||||||
| 948 | /*! | - | ||||||||||||||||||
| 949 | \macro QT_VERSION_STR | - | ||||||||||||||||||
| 950 | \relates <QtGlobal> | - | ||||||||||||||||||
| 951 | - | |||||||||||||||||||
| 952 | This macro expands to a string that specifies Qt's version number | - | ||||||||||||||||||
| 953 | (for example, "4.1.2"). This is the version against which the | - | ||||||||||||||||||
| 954 | application is compiled. | - | ||||||||||||||||||
| 955 | - | |||||||||||||||||||
| 956 | \sa qVersion(), QT_VERSION | - | ||||||||||||||||||
| 957 | */ | - | ||||||||||||||||||
| 958 | - | |||||||||||||||||||
| 959 | /*! | - | ||||||||||||||||||
| 960 | \relates <QtGlobal> | - | ||||||||||||||||||
| 961 | - | |||||||||||||||||||
| 962 | Returns the version number of Qt at run-time as a string (for | - | ||||||||||||||||||
| 963 | example, "4.1.2"). This may be a different version than the | - | ||||||||||||||||||
| 964 | version the application was compiled against. | - | ||||||||||||||||||
| 965 | - | |||||||||||||||||||
| 966 | \sa QT_VERSION_STR | - | ||||||||||||||||||
| 967 | */ | - | ||||||||||||||||||
| 968 | - | |||||||||||||||||||
| 969 | const char *qVersion() Q_DECL_NOTHROW | - | ||||||||||||||||||
| 970 | { | - | ||||||||||||||||||
| 971 | return QT_VERSION_STR; executed 585 times by 2 tests: return "5.6.4";Executed by:
| 585 | ||||||||||||||||||
| 972 | } | - | ||||||||||||||||||
| 973 | - | |||||||||||||||||||
| 974 | bool qSharedBuild() Q_DECL_NOTHROW | - | ||||||||||||||||||
| 975 | { | - | ||||||||||||||||||
| 976 | #ifdef QT_SHARED | - | ||||||||||||||||||
| 977 | return true; never executed: return true; | 0 | ||||||||||||||||||
| 978 | #else | - | ||||||||||||||||||
| 979 | return false; | - | ||||||||||||||||||
| 980 | #endif | - | ||||||||||||||||||
| 981 | } | - | ||||||||||||||||||
| 982 | - | |||||||||||||||||||
| 983 | /***************************************************************************** | - | ||||||||||||||||||
| 984 | System detection routines | - | ||||||||||||||||||
| 985 | *****************************************************************************/ | - | ||||||||||||||||||
| 986 | - | |||||||||||||||||||
| 987 | /*! | - | ||||||||||||||||||
| 988 | \class QSysInfo | - | ||||||||||||||||||
| 989 | \inmodule QtCore | - | ||||||||||||||||||
| 990 | \brief The QSysInfo class provides information about the system. | - | ||||||||||||||||||
| 991 | - | |||||||||||||||||||
| 992 | \list | - | ||||||||||||||||||
| 993 | \li \l WordSize specifies the size of a pointer for the platform | - | ||||||||||||||||||
| 994 | on which the application is compiled. | - | ||||||||||||||||||
| 995 | \li \l ByteOrder specifies whether the platform is big-endian or | - | ||||||||||||||||||
| 996 | little-endian. | - | ||||||||||||||||||
| 997 | \li \l WindowsVersion specifies the version of the Windows operating | - | ||||||||||||||||||
| 998 | system on which the application is run. | - | ||||||||||||||||||
| 999 | \li \l MacintoshVersion specifies the version of the Macintosh | - | ||||||||||||||||||
| 1000 | operating system on which the application is run. | - | ||||||||||||||||||
| 1001 | \endlist | - | ||||||||||||||||||
| 1002 | - | |||||||||||||||||||
| 1003 | Some constants are defined only on certain platforms. You can use | - | ||||||||||||||||||
| 1004 | the preprocessor symbols Q_OS_WIN and Q_OS_MACOS to test that | - | ||||||||||||||||||
| 1005 | the application is compiled under Windows or \macos. | - | ||||||||||||||||||
| 1006 | - | |||||||||||||||||||
| 1007 | \sa QLibraryInfo | - | ||||||||||||||||||
| 1008 | */ | - | ||||||||||||||||||
| 1009 | - | |||||||||||||||||||
| 1010 | /*! | - | ||||||||||||||||||
| 1011 | \enum QSysInfo::Sizes | - | ||||||||||||||||||
| 1012 | - | |||||||||||||||||||
| 1013 | This enum provides platform-specific information about the sizes of data | - | ||||||||||||||||||
| 1014 | structures used by the underlying architecture. | - | ||||||||||||||||||
| 1015 | - | |||||||||||||||||||
| 1016 | \value WordSize The size in bits of a pointer for the platform on which | - | ||||||||||||||||||
| 1017 | the application is compiled (32 or 64). | - | ||||||||||||||||||
| 1018 | */ | - | ||||||||||||||||||
| 1019 | - | |||||||||||||||||||
| 1020 | /*! | - | ||||||||||||||||||
| 1021 | \variable QSysInfo::WindowsVersion | - | ||||||||||||||||||
| 1022 | \brief the version of the Windows operating system on which the | - | ||||||||||||||||||
| 1023 | application is run. | - | ||||||||||||||||||
| 1024 | */ | - | ||||||||||||||||||
| 1025 | - | |||||||||||||||||||
| 1026 | /*! | - | ||||||||||||||||||
| 1027 | \fn QSysInfo::WindowsVersion QSysInfo::windowsVersion() | - | ||||||||||||||||||
| 1028 | \since 4.4 | - | ||||||||||||||||||
| 1029 | - | |||||||||||||||||||
| 1030 | Returns the version of the Windows operating system on which the | - | ||||||||||||||||||
| 1031 | application is run, or WV_None if the operating system is not | - | ||||||||||||||||||
| 1032 | Windows. | - | ||||||||||||||||||
| 1033 | */ | - | ||||||||||||||||||
| 1034 | - | |||||||||||||||||||
| 1035 | /*! | - | ||||||||||||||||||
| 1036 | \variable QSysInfo::MacintoshVersion | - | ||||||||||||||||||
| 1037 | \brief the version of the Macintosh operating system on which | - | ||||||||||||||||||
| 1038 | the application is run. | - | ||||||||||||||||||
| 1039 | */ | - | ||||||||||||||||||
| 1040 | - | |||||||||||||||||||
| 1041 | /*! | - | ||||||||||||||||||
| 1042 | \fn QSysInfo::MacVersion QSysInfo::macVersion() | - | ||||||||||||||||||
| 1043 | - | |||||||||||||||||||
| 1044 | Returns the version of Darwin (\macos or iOS) on which the | - | ||||||||||||||||||
| 1045 | application is run, or MV_None if the operating system | - | ||||||||||||||||||
| 1046 | is not a version of Darwin. | - | ||||||||||||||||||
| 1047 | */ | - | ||||||||||||||||||
| 1048 | - | |||||||||||||||||||
| 1049 | /*! | - | ||||||||||||||||||
| 1050 | \enum QSysInfo::Endian | - | ||||||||||||||||||
| 1051 | - | |||||||||||||||||||
| 1052 | \value BigEndian Big-endian byte order (also called Network byte order) | - | ||||||||||||||||||
| 1053 | \value LittleEndian Little-endian byte order | - | ||||||||||||||||||
| 1054 | \value ByteOrder Equals BigEndian or LittleEndian, depending on | - | ||||||||||||||||||
| 1055 | the platform's byte order. | - | ||||||||||||||||||
| 1056 | */ | - | ||||||||||||||||||
| 1057 | - | |||||||||||||||||||
| 1058 | /*! | - | ||||||||||||||||||
| 1059 | \enum QSysInfo::WinVersion | - | ||||||||||||||||||
| 1060 | - | |||||||||||||||||||
| 1061 | This enum provides symbolic names for the various versions of the | - | ||||||||||||||||||
| 1062 | Windows operating system. On Windows, the | - | ||||||||||||||||||
| 1063 | QSysInfo::WindowsVersion variable gives the version of the system | - | ||||||||||||||||||
| 1064 | on which the application is run. | - | ||||||||||||||||||
| 1065 | - | |||||||||||||||||||
| 1066 | MS-DOS-based versions: | - | ||||||||||||||||||
| 1067 | - | |||||||||||||||||||
| 1068 | \value WV_32s Windows 3.1 with Win 32s | - | ||||||||||||||||||
| 1069 | \value WV_95 Windows 95 | - | ||||||||||||||||||
| 1070 | \value WV_98 Windows 98 | - | ||||||||||||||||||
| 1071 | \value WV_Me Windows Me | - | ||||||||||||||||||
| 1072 | - | |||||||||||||||||||
| 1073 | NT-based versions (note that each operating system version is only represented once rather than each Windows edition): | - | ||||||||||||||||||
| 1074 | - | |||||||||||||||||||
| 1075 | \value WV_NT Windows NT (operating system version 4.0) | - | ||||||||||||||||||
| 1076 | \value WV_2000 Windows 2000 (operating system version 5.0) | - | ||||||||||||||||||
| 1077 | \value WV_XP Windows XP (operating system version 5.1) | - | ||||||||||||||||||
| 1078 | \value WV_2003 Windows Server 2003, Windows Server 2003 R2, Windows Home Server, Windows XP Professional x64 Edition (operating system version 5.2) | - | ||||||||||||||||||
| 1079 | \value WV_VISTA Windows Vista, Windows Server 2008 (operating system version 6.0) | - | ||||||||||||||||||
| 1080 | \value WV_WINDOWS7 Windows 7, Windows Server 2008 R2 (operating system version 6.1) | - | ||||||||||||||||||
| 1081 | \value WV_WINDOWS8 Windows 8 (operating system version 6.2) | - | ||||||||||||||||||
| 1082 | \value WV_WINDOWS8_1 Windows 8.1 (operating system version 6.3), introduced in Qt 5.2 | - | ||||||||||||||||||
| 1083 | \value WV_WINDOWS10 Windows 10 (operating system version 10.0), introduced in Qt 5.5 | - | ||||||||||||||||||
| 1084 | - | |||||||||||||||||||
| 1085 | Alternatively, you may use the following macros which correspond directly to the Windows operating system version number: | - | ||||||||||||||||||
| 1086 | - | |||||||||||||||||||
| 1087 | \value WV_4_0 Operating system version 4.0, corresponds to Windows NT | - | ||||||||||||||||||
| 1088 | \value WV_5_0 Operating system version 5.0, corresponds to Windows 2000 | - | ||||||||||||||||||
| 1089 | \value WV_5_1 Operating system version 5.1, corresponds to Windows XP | - | ||||||||||||||||||
| 1090 | \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 | - | ||||||||||||||||||
| 1091 | \value WV_6_0 Operating system version 6.0, corresponds to Windows Vista and Windows Server 2008 | - | ||||||||||||||||||
| 1092 | \value WV_6_1 Operating system version 6.1, corresponds to Windows 7 and Windows Server 2008 R2 | - | ||||||||||||||||||
| 1093 | \value WV_6_2 Operating system version 6.2, corresponds to Windows 8 | - | ||||||||||||||||||
| 1094 | \value WV_6_3 Operating system version 6.3, corresponds to Windows 8.1, introduced in Qt 5.2 | - | ||||||||||||||||||
| 1095 | \value WV_10_0 Operating system version 10.0, corresponds to Windows 10, introduced in Qt 5.5 | - | ||||||||||||||||||
| 1096 | - | |||||||||||||||||||
| 1097 | CE-based versions: | - | ||||||||||||||||||
| 1098 | - | |||||||||||||||||||
| 1099 | \value WV_CE Windows CE | - | ||||||||||||||||||
| 1100 | \value WV_CENET Windows CE .NET | - | ||||||||||||||||||
| 1101 | \value WV_CE_5 Windows CE 5.x | - | ||||||||||||||||||
| 1102 | \value WV_CE_6 Windows CE 6.x | - | ||||||||||||||||||
| 1103 | - | |||||||||||||||||||
| 1104 | The following masks can be used for testing whether a Windows | - | ||||||||||||||||||
| 1105 | version is MS-DOS-based, NT-based, or CE-based: | - | ||||||||||||||||||
| 1106 | - | |||||||||||||||||||
| 1107 | \value WV_DOS_based MS-DOS-based version of Windows | - | ||||||||||||||||||
| 1108 | \value WV_NT_based NT-based version of Windows | - | ||||||||||||||||||
| 1109 | \value WV_CE_based CE-based version of Windows | - | ||||||||||||||||||
| 1110 | - | |||||||||||||||||||
| 1111 | \value WV_None Operating system other than Windows. | - | ||||||||||||||||||
| 1112 | - | |||||||||||||||||||
| 1113 | \sa MacVersion | - | ||||||||||||||||||
| 1114 | */ | - | ||||||||||||||||||
| 1115 | - | |||||||||||||||||||
| 1116 | /*! | - | ||||||||||||||||||
| 1117 | \enum QSysInfo::MacVersion | - | ||||||||||||||||||
| 1118 | - | |||||||||||||||||||
| 1119 | This enum provides symbolic names for the various versions of the | - | ||||||||||||||||||
| 1120 | Darwin operating system, covering both \macos and iOS. The | - | ||||||||||||||||||
| 1121 | QSysInfo::MacintoshVersion variable gives the version of the | - | ||||||||||||||||||
| 1122 | system on which the application is run. | - | ||||||||||||||||||
| 1123 | - | |||||||||||||||||||
| 1124 | \value MV_9 \macos 9 | - | ||||||||||||||||||
| 1125 | \value MV_10_0 \macos 10.0 | - | ||||||||||||||||||
| 1126 | \value MV_10_1 \macos 10.1 | - | ||||||||||||||||||
| 1127 | \value MV_10_2 \macos 10.2 | - | ||||||||||||||||||
| 1128 | \value MV_10_3 \macos 10.3 | - | ||||||||||||||||||
| 1129 | \value MV_10_4 \macos 10.4 | - | ||||||||||||||||||
| 1130 | \value MV_10_5 \macos 10.5 | - | ||||||||||||||||||
| 1131 | \value MV_10_6 \macos 10.6 | - | ||||||||||||||||||
| 1132 | \value MV_10_7 \macos 10.7 | - | ||||||||||||||||||
| 1133 | \value MV_10_8 \macos 10.8 | - | ||||||||||||||||||
| 1134 | \value MV_10_9 \macos 10.9 | - | ||||||||||||||||||
| 1135 | \value MV_10_10 \macos 10.10 | - | ||||||||||||||||||
| 1136 | \value MV_10_11 \macos 10.11 | - | ||||||||||||||||||
| 1137 | \value MV_10_12 \macos 10.12 | - | ||||||||||||||||||
| 1138 | \value MV_Unknown An unknown and currently unsupported platform | - | ||||||||||||||||||
| 1139 | - | |||||||||||||||||||
| 1140 | \value MV_CHEETAH Apple codename for MV_10_0 | - | ||||||||||||||||||
| 1141 | \value MV_PUMA Apple codename for MV_10_1 | - | ||||||||||||||||||
| 1142 | \value MV_JAGUAR Apple codename for MV_10_2 | - | ||||||||||||||||||
| 1143 | \value MV_PANTHER Apple codename for MV_10_3 | - | ||||||||||||||||||
| 1144 | \value MV_TIGER Apple codename for MV_10_4 | - | ||||||||||||||||||
| 1145 | \value MV_LEOPARD Apple codename for MV_10_5 | - | ||||||||||||||||||
| 1146 | \value MV_SNOWLEOPARD Apple codename for MV_10_6 | - | ||||||||||||||||||
| 1147 | \value MV_LION Apple codename for MV_10_7 | - | ||||||||||||||||||
| 1148 | \value MV_MOUNTAINLION Apple codename for MV_10_8 | - | ||||||||||||||||||
| 1149 | \value MV_MAVERICKS Apple codename for MV_10_9 | - | ||||||||||||||||||
| 1150 | \value MV_YOSEMITE Apple codename for MV_10_10 | - | ||||||||||||||||||
| 1151 | \value MV_ELCAPITAN Apple codename for MV_10_11 | - | ||||||||||||||||||
| 1152 | \value MV_SIERRA Apple codename for MV_10_12 | - | ||||||||||||||||||
| 1153 | - | |||||||||||||||||||
| 1154 | \value MV_IOS iOS (any) | - | ||||||||||||||||||
| 1155 | \value MV_IOS_4_3 iOS 4.3 | - | ||||||||||||||||||
| 1156 | \value MV_IOS_5_0 iOS 5.0 | - | ||||||||||||||||||
| 1157 | \value MV_IOS_5_1 iOS 5.1 | - | ||||||||||||||||||
| 1158 | \value MV_IOS_6_0 iOS 6.0 | - | ||||||||||||||||||
| 1159 | \value MV_IOS_6_1 iOS 6.1 | - | ||||||||||||||||||
| 1160 | \value MV_IOS_7_0 iOS 7.0 | - | ||||||||||||||||||
| 1161 | \value MV_IOS_7_1 iOS 7.1 | - | ||||||||||||||||||
| 1162 | \value MV_IOS_8_0 iOS 8.0 | - | ||||||||||||||||||
| 1163 | \value MV_IOS_8_1 iOS 8.1 | - | ||||||||||||||||||
| 1164 | \value MV_IOS_8_2 iOS 8.2 | - | ||||||||||||||||||
| 1165 | \value MV_IOS_8_3 iOS 8.3 | - | ||||||||||||||||||
| 1166 | \value MV_IOS_8_4 iOS 8.4 | - | ||||||||||||||||||
| 1167 | \value MV_IOS_9_0 iOS 9.0 | - | ||||||||||||||||||
| 1168 | \value MV_IOS_9_1 iOS 9.1 | - | ||||||||||||||||||
| 1169 | \value MV_IOS_9_2 iOS 9.2 | - | ||||||||||||||||||
| 1170 | \value MV_IOS_9_3 iOS 9.3 | - | ||||||||||||||||||
| 1171 | \value MV_IOS_10_0 iOS 10.0 | - | ||||||||||||||||||
| 1172 | - | |||||||||||||||||||
| 1173 | \value MV_None Not a Darwin operating system | - | ||||||||||||||||||
| 1174 | - | |||||||||||||||||||
| 1175 | \sa WinVersion | - | ||||||||||||||||||
| 1176 | */ | - | ||||||||||||||||||
| 1177 | - | |||||||||||||||||||
| 1178 | /*! | - | ||||||||||||||||||
| 1179 | \macro Q_OS_DARWIN | - | ||||||||||||||||||
| 1180 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1181 | - | |||||||||||||||||||
| 1182 | Defined on Darwin-based operating systems such as \macos and iOS. | - | ||||||||||||||||||
| 1183 | */ | - | ||||||||||||||||||
| 1184 | - | |||||||||||||||||||
| 1185 | /*! | - | ||||||||||||||||||
| 1186 | \macro Q_OS_MAC | - | ||||||||||||||||||
| 1187 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1188 | - | |||||||||||||||||||
| 1189 | Deprecated synonym for \c Q_OS_DARWIN. Do not use. | - | ||||||||||||||||||
| 1190 | */ | - | ||||||||||||||||||
| 1191 | - | |||||||||||||||||||
| 1192 | /*! | - | ||||||||||||||||||
| 1193 | \macro Q_OS_OSX | - | ||||||||||||||||||
| 1194 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1195 | - | |||||||||||||||||||
| 1196 | Deprecated synonym for \c Q_OS_MACOS. Do not use. | - | ||||||||||||||||||
| 1197 | */ | - | ||||||||||||||||||
| 1198 | - | |||||||||||||||||||
| 1199 | /*! | - | ||||||||||||||||||
| 1200 | \macro Q_OS_MACOS | - | ||||||||||||||||||
| 1201 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1202 | - | |||||||||||||||||||
| 1203 | Defined on \macos. | - | ||||||||||||||||||
| 1204 | */ | - | ||||||||||||||||||
| 1205 | - | |||||||||||||||||||
| 1206 | /*! | - | ||||||||||||||||||
| 1207 | \macro Q_OS_IOS | - | ||||||||||||||||||
| 1208 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1209 | - | |||||||||||||||||||
| 1210 | Defined on iOS. | - | ||||||||||||||||||
| 1211 | */ | - | ||||||||||||||||||
| 1212 | - | |||||||||||||||||||
| 1213 | /*! | - | ||||||||||||||||||
| 1214 | \macro Q_OS_WIN | - | ||||||||||||||||||
| 1215 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1216 | - | |||||||||||||||||||
| 1217 | Defined on all supported versions of Windows. That is, if | - | ||||||||||||||||||
| 1218 | \l Q_OS_WIN32, \l Q_OS_WIN64, \l Q_OS_WINCE or \l Q_OS_WINRT is defined. | - | ||||||||||||||||||
| 1219 | */ | - | ||||||||||||||||||
| 1220 | - | |||||||||||||||||||
| 1221 | /*! | - | ||||||||||||||||||
| 1222 | \macro Q_OS_WIN32 | - | ||||||||||||||||||
| 1223 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1224 | - | |||||||||||||||||||
| 1225 | Defined on 32-bit and 64-bit versions of Windows (not on Windows CE). | - | ||||||||||||||||||
| 1226 | */ | - | ||||||||||||||||||
| 1227 | - | |||||||||||||||||||
| 1228 | /*! | - | ||||||||||||||||||
| 1229 | \macro Q_OS_WIN64 | - | ||||||||||||||||||
| 1230 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1231 | - | |||||||||||||||||||
| 1232 | Defined on 64-bit versions of Windows. | - | ||||||||||||||||||
| 1233 | */ | - | ||||||||||||||||||
| 1234 | - | |||||||||||||||||||
| 1235 | /*! | - | ||||||||||||||||||
| 1236 | \macro Q_OS_WINCE | - | ||||||||||||||||||
| 1237 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1238 | - | |||||||||||||||||||
| 1239 | Defined on Windows CE. | - | ||||||||||||||||||
| 1240 | */ | - | ||||||||||||||||||
| 1241 | - | |||||||||||||||||||
| 1242 | /*! | - | ||||||||||||||||||
| 1243 | \macro Q_OS_WINRT | - | ||||||||||||||||||
| 1244 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1245 | - | |||||||||||||||||||
| 1246 | Defined for Windows Runtime (Windows Store apps) on Windows 8, Windows RT, | - | ||||||||||||||||||
| 1247 | and Windows Phone 8. | - | ||||||||||||||||||
| 1248 | */ | - | ||||||||||||||||||
| 1249 | - | |||||||||||||||||||
| 1250 | /*! | - | ||||||||||||||||||
| 1251 | \macro Q_OS_WINPHONE | - | ||||||||||||||||||
| 1252 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1253 | - | |||||||||||||||||||
| 1254 | Defined on Windows Phone 8. | - | ||||||||||||||||||
| 1255 | */ | - | ||||||||||||||||||
| 1256 | - | |||||||||||||||||||
| 1257 | /*! | - | ||||||||||||||||||
| 1258 | \macro Q_OS_CYGWIN | - | ||||||||||||||||||
| 1259 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1260 | - | |||||||||||||||||||
| 1261 | Defined on Cygwin. | - | ||||||||||||||||||
| 1262 | */ | - | ||||||||||||||||||
| 1263 | - | |||||||||||||||||||
| 1264 | /*! | - | ||||||||||||||||||
| 1265 | \macro Q_OS_SOLARIS | - | ||||||||||||||||||
| 1266 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1267 | - | |||||||||||||||||||
| 1268 | Defined on Sun Solaris. | - | ||||||||||||||||||
| 1269 | */ | - | ||||||||||||||||||
| 1270 | - | |||||||||||||||||||
| 1271 | /*! | - | ||||||||||||||||||
| 1272 | \macro Q_OS_HPUX | - | ||||||||||||||||||
| 1273 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1274 | - | |||||||||||||||||||
| 1275 | Defined on HP-UX. | - | ||||||||||||||||||
| 1276 | */ | - | ||||||||||||||||||
| 1277 | - | |||||||||||||||||||
| 1278 | /*! | - | ||||||||||||||||||
| 1279 | \macro Q_OS_ULTRIX | - | ||||||||||||||||||
| 1280 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1281 | - | |||||||||||||||||||
| 1282 | Defined on DEC Ultrix. | - | ||||||||||||||||||
| 1283 | */ | - | ||||||||||||||||||
| 1284 | - | |||||||||||||||||||
| 1285 | /*! | - | ||||||||||||||||||
| 1286 | \macro Q_OS_LINUX | - | ||||||||||||||||||
| 1287 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1288 | - | |||||||||||||||||||
| 1289 | Defined on Linux. | - | ||||||||||||||||||
| 1290 | */ | - | ||||||||||||||||||
| 1291 | - | |||||||||||||||||||
| 1292 | /*! | - | ||||||||||||||||||
| 1293 | \macro Q_OS_ANDROID | - | ||||||||||||||||||
| 1294 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1295 | - | |||||||||||||||||||
| 1296 | Defined on Android. | - | ||||||||||||||||||
| 1297 | */ | - | ||||||||||||||||||
| 1298 | - | |||||||||||||||||||
| 1299 | /*! | - | ||||||||||||||||||
| 1300 | \macro Q_OS_FREEBSD | - | ||||||||||||||||||
| 1301 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1302 | - | |||||||||||||||||||
| 1303 | Defined on FreeBSD. | - | ||||||||||||||||||
| 1304 | */ | - | ||||||||||||||||||
| 1305 | - | |||||||||||||||||||
| 1306 | /*! | - | ||||||||||||||||||
| 1307 | \macro Q_OS_NETBSD | - | ||||||||||||||||||
| 1308 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1309 | - | |||||||||||||||||||
| 1310 | Defined on NetBSD. | - | ||||||||||||||||||
| 1311 | */ | - | ||||||||||||||||||
| 1312 | - | |||||||||||||||||||
| 1313 | /*! | - | ||||||||||||||||||
| 1314 | \macro Q_OS_OPENBSD | - | ||||||||||||||||||
| 1315 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1316 | - | |||||||||||||||||||
| 1317 | Defined on OpenBSD. | - | ||||||||||||||||||
| 1318 | */ | - | ||||||||||||||||||
| 1319 | - | |||||||||||||||||||
| 1320 | /*! | - | ||||||||||||||||||
| 1321 | \macro Q_OS_BSDI | - | ||||||||||||||||||
| 1322 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1323 | - | |||||||||||||||||||
| 1324 | Defined on BSD/OS. | - | ||||||||||||||||||
| 1325 | */ | - | ||||||||||||||||||
| 1326 | - | |||||||||||||||||||
| 1327 | /*! | - | ||||||||||||||||||
| 1328 | \macro Q_OS_IRIX | - | ||||||||||||||||||
| 1329 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1330 | - | |||||||||||||||||||
| 1331 | Defined on SGI Irix. | - | ||||||||||||||||||
| 1332 | */ | - | ||||||||||||||||||
| 1333 | - | |||||||||||||||||||
| 1334 | /*! | - | ||||||||||||||||||
| 1335 | \macro Q_OS_OSF | - | ||||||||||||||||||
| 1336 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1337 | - | |||||||||||||||||||
| 1338 | Defined on HP Tru64 UNIX. | - | ||||||||||||||||||
| 1339 | */ | - | ||||||||||||||||||
| 1340 | - | |||||||||||||||||||
| 1341 | /*! | - | ||||||||||||||||||
| 1342 | \macro Q_OS_SCO | - | ||||||||||||||||||
| 1343 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1344 | - | |||||||||||||||||||
| 1345 | Defined on SCO OpenServer 5. | - | ||||||||||||||||||
| 1346 | */ | - | ||||||||||||||||||
| 1347 | - | |||||||||||||||||||
| 1348 | /*! | - | ||||||||||||||||||
| 1349 | \macro Q_OS_UNIXWARE | - | ||||||||||||||||||
| 1350 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1351 | - | |||||||||||||||||||
| 1352 | Defined on UnixWare 7, Open UNIX 8. | - | ||||||||||||||||||
| 1353 | */ | - | ||||||||||||||||||
| 1354 | - | |||||||||||||||||||
| 1355 | /*! | - | ||||||||||||||||||
| 1356 | \macro Q_OS_AIX | - | ||||||||||||||||||
| 1357 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1358 | - | |||||||||||||||||||
| 1359 | Defined on AIX. | - | ||||||||||||||||||
| 1360 | */ | - | ||||||||||||||||||
| 1361 | - | |||||||||||||||||||
| 1362 | /*! | - | ||||||||||||||||||
| 1363 | \macro Q_OS_HURD | - | ||||||||||||||||||
| 1364 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1365 | - | |||||||||||||||||||
| 1366 | Defined on GNU Hurd. | - | ||||||||||||||||||
| 1367 | */ | - | ||||||||||||||||||
| 1368 | - | |||||||||||||||||||
| 1369 | /*! | - | ||||||||||||||||||
| 1370 | \macro Q_OS_DGUX | - | ||||||||||||||||||
| 1371 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1372 | - | |||||||||||||||||||
| 1373 | Defined on DG/UX. | - | ||||||||||||||||||
| 1374 | */ | - | ||||||||||||||||||
| 1375 | - | |||||||||||||||||||
| 1376 | /*! | - | ||||||||||||||||||
| 1377 | \macro Q_OS_RELIANT | - | ||||||||||||||||||
| 1378 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1379 | - | |||||||||||||||||||
| 1380 | Defined on Reliant UNIX. | - | ||||||||||||||||||
| 1381 | */ | - | ||||||||||||||||||
| 1382 | - | |||||||||||||||||||
| 1383 | /*! | - | ||||||||||||||||||
| 1384 | \macro Q_OS_DYNIX | - | ||||||||||||||||||
| 1385 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1386 | - | |||||||||||||||||||
| 1387 | Defined on DYNIX/ptx. | - | ||||||||||||||||||
| 1388 | */ | - | ||||||||||||||||||
| 1389 | - | |||||||||||||||||||
| 1390 | /*! | - | ||||||||||||||||||
| 1391 | \macro Q_OS_QNX | - | ||||||||||||||||||
| 1392 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1393 | - | |||||||||||||||||||
| 1394 | Defined on QNX Neutrino. | - | ||||||||||||||||||
| 1395 | */ | - | ||||||||||||||||||
| 1396 | - | |||||||||||||||||||
| 1397 | /*! | - | ||||||||||||||||||
| 1398 | \macro Q_OS_LYNX | - | ||||||||||||||||||
| 1399 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1400 | - | |||||||||||||||||||
| 1401 | Defined on LynxOS. | - | ||||||||||||||||||
| 1402 | */ | - | ||||||||||||||||||
| 1403 | - | |||||||||||||||||||
| 1404 | /*! | - | ||||||||||||||||||
| 1405 | \macro Q_OS_BSD4 | - | ||||||||||||||||||
| 1406 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1407 | - | |||||||||||||||||||
| 1408 | Defined on Any BSD 4.4 system. | - | ||||||||||||||||||
| 1409 | */ | - | ||||||||||||||||||
| 1410 | - | |||||||||||||||||||
| 1411 | /*! | - | ||||||||||||||||||
| 1412 | \macro Q_OS_UNIX | - | ||||||||||||||||||
| 1413 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1414 | - | |||||||||||||||||||
| 1415 | Defined on Any UNIX BSD/SYSV system. | - | ||||||||||||||||||
| 1416 | */ | - | ||||||||||||||||||
| 1417 | - | |||||||||||||||||||
| 1418 | /*! | - | ||||||||||||||||||
| 1419 | \macro Q_CC_SYM | - | ||||||||||||||||||
| 1420 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1421 | - | |||||||||||||||||||
| 1422 | Defined if the application is compiled using Digital Mars C/C++ | - | ||||||||||||||||||
| 1423 | (used to be Symantec C++). | - | ||||||||||||||||||
| 1424 | */ | - | ||||||||||||||||||
| 1425 | - | |||||||||||||||||||
| 1426 | /*! | - | ||||||||||||||||||
| 1427 | \macro Q_CC_MSVC | - | ||||||||||||||||||
| 1428 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1429 | - | |||||||||||||||||||
| 1430 | Defined if the application is compiled using Microsoft Visual | - | ||||||||||||||||||
| 1431 | C/C++, Intel C++ for Windows. | - | ||||||||||||||||||
| 1432 | */ | - | ||||||||||||||||||
| 1433 | - | |||||||||||||||||||
| 1434 | /*! | - | ||||||||||||||||||
| 1435 | \macro Q_CC_BOR | - | ||||||||||||||||||
| 1436 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1437 | - | |||||||||||||||||||
| 1438 | Defined if the application is compiled using Borland/Turbo C++. | - | ||||||||||||||||||
| 1439 | */ | - | ||||||||||||||||||
| 1440 | - | |||||||||||||||||||
| 1441 | /*! | - | ||||||||||||||||||
| 1442 | \macro Q_CC_WAT | - | ||||||||||||||||||
| 1443 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1444 | - | |||||||||||||||||||
| 1445 | Defined if the application is compiled using Watcom C++. | - | ||||||||||||||||||
| 1446 | */ | - | ||||||||||||||||||
| 1447 | - | |||||||||||||||||||
| 1448 | /*! | - | ||||||||||||||||||
| 1449 | \macro Q_CC_GNU | - | ||||||||||||||||||
| 1450 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1451 | - | |||||||||||||||||||
| 1452 | Defined if the application is compiled using GNU C++. | - | ||||||||||||||||||
| 1453 | */ | - | ||||||||||||||||||
| 1454 | - | |||||||||||||||||||
| 1455 | /*! | - | ||||||||||||||||||
| 1456 | \macro Q_CC_COMEAU | - | ||||||||||||||||||
| 1457 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1458 | - | |||||||||||||||||||
| 1459 | Defined if the application is compiled using Comeau C++. | - | ||||||||||||||||||
| 1460 | */ | - | ||||||||||||||||||
| 1461 | - | |||||||||||||||||||
| 1462 | /*! | - | ||||||||||||||||||
| 1463 | \macro Q_CC_EDG | - | ||||||||||||||||||
| 1464 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1465 | - | |||||||||||||||||||
| 1466 | Defined if the application is compiled using Edison Design Group | - | ||||||||||||||||||
| 1467 | C++. | - | ||||||||||||||||||
| 1468 | */ | - | ||||||||||||||||||
| 1469 | - | |||||||||||||||||||
| 1470 | /*! | - | ||||||||||||||||||
| 1471 | \macro Q_CC_OC | - | ||||||||||||||||||
| 1472 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1473 | - | |||||||||||||||||||
| 1474 | Defined if the application is compiled using CenterLine C++. | - | ||||||||||||||||||
| 1475 | */ | - | ||||||||||||||||||
| 1476 | - | |||||||||||||||||||
| 1477 | /*! | - | ||||||||||||||||||
| 1478 | \macro Q_CC_SUN | - | ||||||||||||||||||
| 1479 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1480 | - | |||||||||||||||||||
| 1481 | Defined if the application is compiled using Forte Developer, or | - | ||||||||||||||||||
| 1482 | Sun Studio C++. | - | ||||||||||||||||||
| 1483 | */ | - | ||||||||||||||||||
| 1484 | - | |||||||||||||||||||
| 1485 | /*! | - | ||||||||||||||||||
| 1486 | \macro Q_CC_MIPS | - | ||||||||||||||||||
| 1487 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1488 | - | |||||||||||||||||||
| 1489 | Defined if the application is compiled using MIPSpro C++. | - | ||||||||||||||||||
| 1490 | */ | - | ||||||||||||||||||
| 1491 | - | |||||||||||||||||||
| 1492 | /*! | - | ||||||||||||||||||
| 1493 | \macro Q_CC_DEC | - | ||||||||||||||||||
| 1494 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1495 | - | |||||||||||||||||||
| 1496 | Defined if the application is compiled using DEC C++. | - | ||||||||||||||||||
| 1497 | */ | - | ||||||||||||||||||
| 1498 | - | |||||||||||||||||||
| 1499 | /*! | - | ||||||||||||||||||
| 1500 | \macro Q_CC_HPACC | - | ||||||||||||||||||
| 1501 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1502 | - | |||||||||||||||||||
| 1503 | Defined if the application is compiled using HP aC++. | - | ||||||||||||||||||
| 1504 | */ | - | ||||||||||||||||||
| 1505 | - | |||||||||||||||||||
| 1506 | /*! | - | ||||||||||||||||||
| 1507 | \macro Q_CC_USLC | - | ||||||||||||||||||
| 1508 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1509 | - | |||||||||||||||||||
| 1510 | Defined if the application is compiled using SCO OUDK and UDK. | - | ||||||||||||||||||
| 1511 | */ | - | ||||||||||||||||||
| 1512 | - | |||||||||||||||||||
| 1513 | /*! | - | ||||||||||||||||||
| 1514 | \macro Q_CC_CDS | - | ||||||||||||||||||
| 1515 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1516 | - | |||||||||||||||||||
| 1517 | Defined if the application is compiled using Reliant C++. | - | ||||||||||||||||||
| 1518 | */ | - | ||||||||||||||||||
| 1519 | - | |||||||||||||||||||
| 1520 | /*! | - | ||||||||||||||||||
| 1521 | \macro Q_CC_KAI | - | ||||||||||||||||||
| 1522 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1523 | - | |||||||||||||||||||
| 1524 | Defined if the application is compiled using KAI C++. | - | ||||||||||||||||||
| 1525 | */ | - | ||||||||||||||||||
| 1526 | - | |||||||||||||||||||
| 1527 | /*! | - | ||||||||||||||||||
| 1528 | \macro Q_CC_INTEL | - | ||||||||||||||||||
| 1529 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1530 | - | |||||||||||||||||||
| 1531 | Defined if the application is compiled using Intel C++ for Linux, | - | ||||||||||||||||||
| 1532 | Intel C++ for Windows. | - | ||||||||||||||||||
| 1533 | */ | - | ||||||||||||||||||
| 1534 | - | |||||||||||||||||||
| 1535 | /*! | - | ||||||||||||||||||
| 1536 | \macro Q_CC_HIGHC | - | ||||||||||||||||||
| 1537 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1538 | - | |||||||||||||||||||
| 1539 | Defined if the application is compiled using MetaWare High C/C++. | - | ||||||||||||||||||
| 1540 | */ | - | ||||||||||||||||||
| 1541 | - | |||||||||||||||||||
| 1542 | /*! | - | ||||||||||||||||||
| 1543 | \macro Q_CC_PGI | - | ||||||||||||||||||
| 1544 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1545 | - | |||||||||||||||||||
| 1546 | Defined if the application is compiled using Portland Group C++. | - | ||||||||||||||||||
| 1547 | */ | - | ||||||||||||||||||
| 1548 | - | |||||||||||||||||||
| 1549 | /*! | - | ||||||||||||||||||
| 1550 | \macro Q_CC_GHS | - | ||||||||||||||||||
| 1551 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1552 | - | |||||||||||||||||||
| 1553 | Defined if the application is compiled using Green Hills | - | ||||||||||||||||||
| 1554 | Optimizing C++ Compilers. | - | ||||||||||||||||||
| 1555 | */ | - | ||||||||||||||||||
| 1556 | - | |||||||||||||||||||
| 1557 | /*! | - | ||||||||||||||||||
| 1558 | \macro Q_PROCESSOR_ALPHA | - | ||||||||||||||||||
| 1559 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1560 | - | |||||||||||||||||||
| 1561 | Defined if the application is compiled for Alpha processors. | - | ||||||||||||||||||
| 1562 | - | |||||||||||||||||||
| 1563 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1564 | */ | - | ||||||||||||||||||
| 1565 | - | |||||||||||||||||||
| 1566 | /*! | - | ||||||||||||||||||
| 1567 | \macro Q_PROCESSOR_ARM | - | ||||||||||||||||||
| 1568 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1569 | - | |||||||||||||||||||
| 1570 | Defined if the application is compiled for ARM processors. Qt currently | - | ||||||||||||||||||
| 1571 | supports three optional ARM revisions: \l Q_PROCESSOR_ARM_V5, \l | - | ||||||||||||||||||
| 1572 | Q_PROCESSOR_ARM_V6, and \l Q_PROCESSOR_ARM_V7. | - | ||||||||||||||||||
| 1573 | - | |||||||||||||||||||
| 1574 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1575 | */ | - | ||||||||||||||||||
| 1576 | /*! | - | ||||||||||||||||||
| 1577 | \macro Q_PROCESSOR_ARM_V5 | - | ||||||||||||||||||
| 1578 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1579 | - | |||||||||||||||||||
| 1580 | Defined if the application is compiled for ARMv5 processors. The \l | - | ||||||||||||||||||
| 1581 | Q_PROCESSOR_ARM macro is also defined when Q_PROCESSOR_ARM_V5 is defined. | - | ||||||||||||||||||
| 1582 | - | |||||||||||||||||||
| 1583 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1584 | */ | - | ||||||||||||||||||
| 1585 | /*! | - | ||||||||||||||||||
| 1586 | \macro Q_PROCESSOR_ARM_V6 | - | ||||||||||||||||||
| 1587 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1588 | - | |||||||||||||||||||
| 1589 | Defined if the application is compiled for ARMv6 processors. The \l | - | ||||||||||||||||||
| 1590 | Q_PROCESSOR_ARM and \l Q_PROCESSOR_ARM_V5 macros are also defined when | - | ||||||||||||||||||
| 1591 | Q_PROCESSOR_ARM_V6 is defined. | - | ||||||||||||||||||
| 1592 | - | |||||||||||||||||||
| 1593 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1594 | */ | - | ||||||||||||||||||
| 1595 | /*! | - | ||||||||||||||||||
| 1596 | \macro Q_PROCESSOR_ARM_V7 | - | ||||||||||||||||||
| 1597 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1598 | - | |||||||||||||||||||
| 1599 | Defined if the application is compiled for ARMv7 processors. The \l | - | ||||||||||||||||||
| 1600 | Q_PROCESSOR_ARM, \l Q_PROCESSOR_ARM_V5, and \l Q_PROCESSOR_ARM_V6 macros | - | ||||||||||||||||||
| 1601 | are also defined when Q_PROCESSOR_ARM_V7 is defined. | - | ||||||||||||||||||
| 1602 | - | |||||||||||||||||||
| 1603 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1604 | */ | - | ||||||||||||||||||
| 1605 | - | |||||||||||||||||||
| 1606 | /*! | - | ||||||||||||||||||
| 1607 | \macro Q_PROCESSOR_AVR32 | - | ||||||||||||||||||
| 1608 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1609 | - | |||||||||||||||||||
| 1610 | Defined if the application is compiled for AVR32 processors. | - | ||||||||||||||||||
| 1611 | - | |||||||||||||||||||
| 1612 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1613 | */ | - | ||||||||||||||||||
| 1614 | - | |||||||||||||||||||
| 1615 | /*! | - | ||||||||||||||||||
| 1616 | \macro Q_PROCESSOR_BLACKFIN | - | ||||||||||||||||||
| 1617 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1618 | - | |||||||||||||||||||
| 1619 | Defined if the application is compiled for Blackfin processors. | - | ||||||||||||||||||
| 1620 | - | |||||||||||||||||||
| 1621 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1622 | */ | - | ||||||||||||||||||
| 1623 | - | |||||||||||||||||||
| 1624 | /*! | - | ||||||||||||||||||
| 1625 | \macro Q_PROCESSOR_IA64 | - | ||||||||||||||||||
| 1626 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1627 | - | |||||||||||||||||||
| 1628 | Defined if the application is compiled for IA-64 processors. This includes | - | ||||||||||||||||||
| 1629 | all Itanium and Itanium 2 processors. | - | ||||||||||||||||||
| 1630 | - | |||||||||||||||||||
| 1631 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1632 | */ | - | ||||||||||||||||||
| 1633 | - | |||||||||||||||||||
| 1634 | /*! | - | ||||||||||||||||||
| 1635 | \macro Q_PROCESSOR_MIPS | - | ||||||||||||||||||
| 1636 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1637 | - | |||||||||||||||||||
| 1638 | Defined if the application is compiled for MIPS processors. Qt currently | - | ||||||||||||||||||
| 1639 | supports seven MIPS revisions: \l Q_PROCESSOR_MIPS_I, \l | - | ||||||||||||||||||
| 1640 | Q_PROCESSOR_MIPS_II, \l Q_PROCESSOR_MIPS_III, \l Q_PROCESSOR_MIPS_IV, \l | - | ||||||||||||||||||
| 1641 | Q_PROCESSOR_MIPS_V, \l Q_PROCESSOR_MIPS_32, and \l Q_PROCESSOR_MIPS_64. | - | ||||||||||||||||||
| 1642 | - | |||||||||||||||||||
| 1643 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1644 | */ | - | ||||||||||||||||||
| 1645 | /*! | - | ||||||||||||||||||
| 1646 | \macro Q_PROCESSOR_MIPS_I | - | ||||||||||||||||||
| 1647 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1648 | - | |||||||||||||||||||
| 1649 | Defined if the application is compiled for MIPS-I processors. The \l | - | ||||||||||||||||||
| 1650 | Q_PROCESSOR_MIPS macro is also defined when Q_PROCESSOR_MIPS_I is defined. | - | ||||||||||||||||||
| 1651 | - | |||||||||||||||||||
| 1652 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1653 | */ | - | ||||||||||||||||||
| 1654 | /*! | - | ||||||||||||||||||
| 1655 | \macro Q_PROCESSOR_MIPS_II | - | ||||||||||||||||||
| 1656 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1657 | - | |||||||||||||||||||
| 1658 | Defined if the application is compiled for MIPS-II processors. The \l | - | ||||||||||||||||||
| 1659 | Q_PROCESSOR_MIPS and \l Q_PROCESSOR_MIPS_I macros are also defined when | - | ||||||||||||||||||
| 1660 | Q_PROCESSOR_MIPS_II is defined. | - | ||||||||||||||||||
| 1661 | - | |||||||||||||||||||
| 1662 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1663 | */ | - | ||||||||||||||||||
| 1664 | /*! | - | ||||||||||||||||||
| 1665 | \macro Q_PROCESSOR_MIPS_32 | - | ||||||||||||||||||
| 1666 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1667 | - | |||||||||||||||||||
| 1668 | Defined if the application is compiled for MIPS32 processors. The \l | - | ||||||||||||||||||
| 1669 | Q_PROCESSOR_MIPS, \l Q_PROCESSOR_MIPS_I, and \l Q_PROCESSOR_MIPS_II macros | - | ||||||||||||||||||
| 1670 | are also defined when Q_PROCESSOR_MIPS_32 is defined. | - | ||||||||||||||||||
| 1671 | - | |||||||||||||||||||
| 1672 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1673 | */ | - | ||||||||||||||||||
| 1674 | /*! | - | ||||||||||||||||||
| 1675 | \macro Q_PROCESSOR_MIPS_III | - | ||||||||||||||||||
| 1676 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1677 | - | |||||||||||||||||||
| 1678 | Defined if the application is compiled for MIPS-III processors. The \l | - | ||||||||||||||||||
| 1679 | Q_PROCESSOR_MIPS, \l Q_PROCESSOR_MIPS_I, and \l Q_PROCESSOR_MIPS_II macros | - | ||||||||||||||||||
| 1680 | are also defined when Q_PROCESSOR_MIPS_III is defined. | - | ||||||||||||||||||
| 1681 | - | |||||||||||||||||||
| 1682 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1683 | */ | - | ||||||||||||||||||
| 1684 | /*! | - | ||||||||||||||||||
| 1685 | \macro Q_PROCESSOR_MIPS_IV | - | ||||||||||||||||||
| 1686 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1687 | - | |||||||||||||||||||
| 1688 | Defined if the application is compiled for MIPS-IV processors. The \l | - | ||||||||||||||||||
| 1689 | Q_PROCESSOR_MIPS, \l Q_PROCESSOR_MIPS_I, \l Q_PROCESSOR_MIPS_II, and \l | - | ||||||||||||||||||
| 1690 | Q_PROCESSOR_MIPS_III macros are also defined when Q_PROCESSOR_MIPS_IV is | - | ||||||||||||||||||
| 1691 | defined. | - | ||||||||||||||||||
| 1692 | - | |||||||||||||||||||
| 1693 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1694 | */ | - | ||||||||||||||||||
| 1695 | /*! | - | ||||||||||||||||||
| 1696 | \macro Q_PROCESSOR_MIPS_V | - | ||||||||||||||||||
| 1697 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1698 | - | |||||||||||||||||||
| 1699 | Defined if the application is compiled for MIPS-V processors. The \l | - | ||||||||||||||||||
| 1700 | Q_PROCESSOR_MIPS, \l Q_PROCESSOR_MIPS_I, \l Q_PROCESSOR_MIPS_II, \l | - | ||||||||||||||||||
| 1701 | Q_PROCESSOR_MIPS_III, and \l Q_PROCESSOR_MIPS_IV macros are also defined | - | ||||||||||||||||||
| 1702 | when Q_PROCESSOR_MIPS_V is defined. | - | ||||||||||||||||||
| 1703 | - | |||||||||||||||||||
| 1704 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1705 | */ | - | ||||||||||||||||||
| 1706 | /*! | - | ||||||||||||||||||
| 1707 | \macro Q_PROCESSOR_MIPS_64 | - | ||||||||||||||||||
| 1708 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1709 | - | |||||||||||||||||||
| 1710 | Defined if the application is compiled for MIPS64 processors. The \l | - | ||||||||||||||||||
| 1711 | Q_PROCESSOR_MIPS, \l Q_PROCESSOR_MIPS_I, \l Q_PROCESSOR_MIPS_II, \l | - | ||||||||||||||||||
| 1712 | Q_PROCESSOR_MIPS_III, \l Q_PROCESSOR_MIPS_IV, and \l Q_PROCESSOR_MIPS_V | - | ||||||||||||||||||
| 1713 | macros are also defined when Q_PROCESSOR_MIPS_64 is defined. | - | ||||||||||||||||||
| 1714 | - | |||||||||||||||||||
| 1715 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1716 | */ | - | ||||||||||||||||||
| 1717 | - | |||||||||||||||||||
| 1718 | /*! | - | ||||||||||||||||||
| 1719 | \macro Q_PROCESSOR_POWER | - | ||||||||||||||||||
| 1720 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1721 | - | |||||||||||||||||||
| 1722 | Defined if the application is compiled for POWER processors. Qt currently | - | ||||||||||||||||||
| 1723 | supports two Power variants: \l Q_PROCESSOR_POWER_32 and \l | - | ||||||||||||||||||
| 1724 | Q_PROCESSOR_POWER_64. | - | ||||||||||||||||||
| 1725 | - | |||||||||||||||||||
| 1726 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1727 | */ | - | ||||||||||||||||||
| 1728 | /*! | - | ||||||||||||||||||
| 1729 | \macro Q_PROCESSOR_POWER_32 | - | ||||||||||||||||||
| 1730 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1731 | - | |||||||||||||||||||
| 1732 | Defined if the application is compiled for 32-bit Power processors. The \l | - | ||||||||||||||||||
| 1733 | Q_PROCESSOR_POWER macro is also defined when Q_PROCESSOR_POWER_32 is | - | ||||||||||||||||||
| 1734 | defined. | - | ||||||||||||||||||
| 1735 | - | |||||||||||||||||||
| 1736 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1737 | */ | - | ||||||||||||||||||
| 1738 | /*! | - | ||||||||||||||||||
| 1739 | \macro Q_PROCESSOR_POWER_64 | - | ||||||||||||||||||
| 1740 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1741 | - | |||||||||||||||||||
| 1742 | Defined if the application is compiled for 64-bit Power processors. The \l | - | ||||||||||||||||||
| 1743 | Q_PROCESSOR_POWER macro is also defined when Q_PROCESSOR_POWER_64 is | - | ||||||||||||||||||
| 1744 | defined. | - | ||||||||||||||||||
| 1745 | - | |||||||||||||||||||
| 1746 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1747 | */ | - | ||||||||||||||||||
| 1748 | - | |||||||||||||||||||
| 1749 | /*! | - | ||||||||||||||||||
| 1750 | \macro Q_PROCESSOR_S390 | - | ||||||||||||||||||
| 1751 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1752 | - | |||||||||||||||||||
| 1753 | Defined if the application is compiled for S/390 processors. Qt supports | - | ||||||||||||||||||
| 1754 | one optional variant of S/390: Q_PROCESSOR_S390_X. | - | ||||||||||||||||||
| 1755 | - | |||||||||||||||||||
| 1756 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1757 | */ | - | ||||||||||||||||||
| 1758 | /*! | - | ||||||||||||||||||
| 1759 | \macro Q_PROCESSOR_S390_X | - | ||||||||||||||||||
| 1760 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1761 | - | |||||||||||||||||||
| 1762 | Defined if the application is compiled for S/390x processors. The \l | - | ||||||||||||||||||
| 1763 | Q_PROCESSOR_S390 macro is also defined when Q_PROCESSOR_S390_X is defined. | - | ||||||||||||||||||
| 1764 | - | |||||||||||||||||||
| 1765 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1766 | */ | - | ||||||||||||||||||
| 1767 | - | |||||||||||||||||||
| 1768 | /*! | - | ||||||||||||||||||
| 1769 | \macro Q_PROCESSOR_SH | - | ||||||||||||||||||
| 1770 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1771 | - | |||||||||||||||||||
| 1772 | Defined if the application is compiled for SuperH processors. Qt currently | - | ||||||||||||||||||
| 1773 | supports one SuperH revision: \l Q_PROCESSOR_SH_4A. | - | ||||||||||||||||||
| 1774 | - | |||||||||||||||||||
| 1775 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1776 | */ | - | ||||||||||||||||||
| 1777 | /*! | - | ||||||||||||||||||
| 1778 | \macro Q_PROCESSOR_SH_4A | - | ||||||||||||||||||
| 1779 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1780 | - | |||||||||||||||||||
| 1781 | Defined if the application is compiled for SuperH 4A processors. The \l | - | ||||||||||||||||||
| 1782 | Q_PROCESSOR_SH macro is also defined when Q_PROCESSOR_SH_4A is defined. | - | ||||||||||||||||||
| 1783 | - | |||||||||||||||||||
| 1784 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1785 | */ | - | ||||||||||||||||||
| 1786 | - | |||||||||||||||||||
| 1787 | /*! | - | ||||||||||||||||||
| 1788 | \macro Q_PROCESSOR_SPARC | - | ||||||||||||||||||
| 1789 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1790 | - | |||||||||||||||||||
| 1791 | Defined if the application is compiled for SPARC processors. Qt currently | - | ||||||||||||||||||
| 1792 | supports one optional SPARC revision: \l Q_PROCESSOR_SPARC_V9. | - | ||||||||||||||||||
| 1793 | - | |||||||||||||||||||
| 1794 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1795 | */ | - | ||||||||||||||||||
| 1796 | /*! | - | ||||||||||||||||||
| 1797 | \macro Q_PROCESSOR_SPARC_V9 | - | ||||||||||||||||||
| 1798 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1799 | - | |||||||||||||||||||
| 1800 | Defined if the application is compiled for SPARC V9 processors. The \l | - | ||||||||||||||||||
| 1801 | Q_PROCESSOR_SPARC macro is also defined when Q_PROCESSOR_SPARC_V9 is | - | ||||||||||||||||||
| 1802 | defined. | - | ||||||||||||||||||
| 1803 | - | |||||||||||||||||||
| 1804 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1805 | */ | - | ||||||||||||||||||
| 1806 | - | |||||||||||||||||||
| 1807 | /*! | - | ||||||||||||||||||
| 1808 | \macro Q_PROCESSOR_X86 | - | ||||||||||||||||||
| 1809 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1810 | - | |||||||||||||||||||
| 1811 | Defined if the application is compiled for x86 processors. Qt currently | - | ||||||||||||||||||
| 1812 | supports two x86 variants: \l Q_PROCESSOR_X86_32 and \l Q_PROCESSOR_X86_64. | - | ||||||||||||||||||
| 1813 | - | |||||||||||||||||||
| 1814 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1815 | */ | - | ||||||||||||||||||
| 1816 | /*! | - | ||||||||||||||||||
| 1817 | \macro Q_PROCESSOR_X86_32 | - | ||||||||||||||||||
| 1818 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1819 | - | |||||||||||||||||||
| 1820 | Defined if the application is compiled for 32-bit x86 processors. This | - | ||||||||||||||||||
| 1821 | includes all i386, i486, i586, and i686 processors. The \l Q_PROCESSOR_X86 | - | ||||||||||||||||||
| 1822 | macro is also defined when Q_PROCESSOR_X86_32 is defined. | - | ||||||||||||||||||
| 1823 | - | |||||||||||||||||||
| 1824 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1825 | */ | - | ||||||||||||||||||
| 1826 | /*! | - | ||||||||||||||||||
| 1827 | \macro Q_PROCESSOR_X86_64 | - | ||||||||||||||||||
| 1828 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1829 | - | |||||||||||||||||||
| 1830 | Defined if the application is compiled for 64-bit x86 processors. This | - | ||||||||||||||||||
| 1831 | includes all AMD64, Intel 64, and other x86_64/x64 processors. The \l | - | ||||||||||||||||||
| 1832 | Q_PROCESSOR_X86 macro is also defined when Q_PROCESSOR_X86_64 is defined. | - | ||||||||||||||||||
| 1833 | - | |||||||||||||||||||
| 1834 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 1835 | */ | - | ||||||||||||||||||
| 1836 | - | |||||||||||||||||||
| 1837 | /*! | - | ||||||||||||||||||
| 1838 | \macro QT_DISABLE_DEPRECATED_BEFORE | - | ||||||||||||||||||
| 1839 | \relates <QtGlobal> | - | ||||||||||||||||||
| 1840 | - | |||||||||||||||||||
| 1841 | This macro can be defined in the project file to disable functions deprecated in | - | ||||||||||||||||||
| 1842 | a specified version of Qt or any earlier version. The default version number is 5.0, | - | ||||||||||||||||||
| 1843 | meaning that functions deprecated in or before Qt 5.0 will not be included. | - | ||||||||||||||||||
| 1844 | - | |||||||||||||||||||
| 1845 | Examples: | - | ||||||||||||||||||
| 1846 | When using a future release of Qt 5, set QT_DISABLE_DEPRECATED_BEFORE=0x050100 to | - | ||||||||||||||||||
| 1847 | disable functions deprecated in Qt 5.1 and earlier. In any release, set | - | ||||||||||||||||||
| 1848 | QT_DISABLE_DEPRECATED_BEFORE=0x000000 to enable any functions, including the ones | - | ||||||||||||||||||
| 1849 | deprecated in Qt 5.0 | - | ||||||||||||||||||
| 1850 | */ | - | ||||||||||||||||||
| 1851 | - | |||||||||||||||||||
| 1852 | #if defined(QT_BUILD_QMAKE) | - | ||||||||||||||||||
| 1853 | // needed to bootstrap qmake | - | ||||||||||||||||||
| 1854 | static const unsigned int qt_one = 1; | - | ||||||||||||||||||
| 1855 | const int QSysInfo::ByteOrder = ((*((unsigned char *) &qt_one) == 0) ? BigEndian : LittleEndian); | - | ||||||||||||||||||
| 1856 | #endif | - | ||||||||||||||||||
| 1857 | - | |||||||||||||||||||
| 1858 | #if defined(Q_OS_MAC) | - | ||||||||||||||||||
| 1859 | - | |||||||||||||||||||
| 1860 | QT_BEGIN_INCLUDE_NAMESPACE | - | ||||||||||||||||||
| 1861 | #include "private/qcore_mac_p.h" | - | ||||||||||||||||||
| 1862 | #include "qnamespace.h" | - | ||||||||||||||||||
| 1863 | QT_END_INCLUDE_NAMESPACE | - | ||||||||||||||||||
| 1864 | - | |||||||||||||||||||
| 1865 | QSysInfo::MacVersion QSysInfo::macVersion() | - | ||||||||||||||||||
| 1866 | { | - | ||||||||||||||||||
| 1867 | const QAppleOperatingSystemVersion version = qt_apple_os_version(); // qtcore_mac_objc.mm | - | ||||||||||||||||||
| 1868 | #if defined(Q_OS_OSX) | - | ||||||||||||||||||
| 1869 | return QSysInfo::MacVersion(Q_MV_OSX(version.major, version.minor)); | - | ||||||||||||||||||
| 1870 | #elif defined(Q_OS_IOS) | - | ||||||||||||||||||
| 1871 | return QSysInfo::MacVersion(Q_MV_IOS(version.major, version.minor)); | - | ||||||||||||||||||
| 1872 | #else | - | ||||||||||||||||||
| 1873 | return QSysInfo::MV_Unknown; | - | ||||||||||||||||||
| 1874 | #endif | - | ||||||||||||||||||
| 1875 | } | - | ||||||||||||||||||
| 1876 | const QSysInfo::MacVersion QSysInfo::MacintoshVersion = QSysInfo::macVersion(); | - | ||||||||||||||||||
| 1877 | - | |||||||||||||||||||
| 1878 | #elif defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) || defined(Q_OS_WINCE) || defined(Q_OS_WINRT) | - | ||||||||||||||||||
| 1879 | - | |||||||||||||||||||
| 1880 | QT_BEGIN_INCLUDE_NAMESPACE | - | ||||||||||||||||||
| 1881 | #include "qt_windows.h" | - | ||||||||||||||||||
| 1882 | QT_END_INCLUDE_NAMESPACE | - | ||||||||||||||||||
| 1883 | - | |||||||||||||||||||
| 1884 | # ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||
| 1885 | class QWindowsSockInit | - | ||||||||||||||||||
| 1886 | { | - | ||||||||||||||||||
| 1887 | public: | - | ||||||||||||||||||
| 1888 | QWindowsSockInit(); | - | ||||||||||||||||||
| 1889 | ~QWindowsSockInit(); | - | ||||||||||||||||||
| 1890 | int version; | - | ||||||||||||||||||
| 1891 | }; | - | ||||||||||||||||||
| 1892 | - | |||||||||||||||||||
| 1893 | QWindowsSockInit::QWindowsSockInit() | - | ||||||||||||||||||
| 1894 | : version(0) | - | ||||||||||||||||||
| 1895 | { | - | ||||||||||||||||||
| 1896 | //### should we try for 2.2 on all platforms ?? | - | ||||||||||||||||||
| 1897 | WSAData wsadata; | - | ||||||||||||||||||
| 1898 | - | |||||||||||||||||||
| 1899 | // IPv6 requires Winsock v2.0 or better. | - | ||||||||||||||||||
| 1900 | if (WSAStartup(MAKEWORD(2,0), &wsadata) != 0) { | - | ||||||||||||||||||
| 1901 | qWarning("QTcpSocketAPI: WinSock v2.0 initialization failed."); | - | ||||||||||||||||||
| 1902 | } else { | - | ||||||||||||||||||
| 1903 | version = 0x20; | - | ||||||||||||||||||
| 1904 | } | - | ||||||||||||||||||
| 1905 | } | - | ||||||||||||||||||
| 1906 | - | |||||||||||||||||||
| 1907 | QWindowsSockInit::~QWindowsSockInit() | - | ||||||||||||||||||
| 1908 | { | - | ||||||||||||||||||
| 1909 | WSACleanup(); | - | ||||||||||||||||||
| 1910 | } | - | ||||||||||||||||||
| 1911 | Q_GLOBAL_STATIC(QWindowsSockInit, winsockInit) | - | ||||||||||||||||||
| 1912 | # endif // QT_BOOTSTRAPPED | - | ||||||||||||||||||
| 1913 | - | |||||||||||||||||||
| 1914 | #ifdef Q_OS_WINRT | - | ||||||||||||||||||
| 1915 | static inline HMODULE moduleHandleForFunction(LPCVOID address) | - | ||||||||||||||||||
| 1916 | { | - | ||||||||||||||||||
| 1917 | // This is a widely used, decades-old technique for retrieving the handle | - | ||||||||||||||||||
| 1918 | // of a module and is effectively equivalent to GetModuleHandleEx | - | ||||||||||||||||||
| 1919 | // (which is unavailable on WinRT) | - | ||||||||||||||||||
| 1920 | MEMORY_BASIC_INFORMATION mbi = { 0, 0, 0, 0, 0, 0, 0 }; | - | ||||||||||||||||||
| 1921 | if (VirtualQuery(address, &mbi, sizeof(mbi)) == 0) | - | ||||||||||||||||||
| 1922 | return 0; | - | ||||||||||||||||||
| 1923 | return reinterpret_cast<HMODULE>(mbi.AllocationBase); | - | ||||||||||||||||||
| 1924 | } | - | ||||||||||||||||||
| 1925 | #endif | - | ||||||||||||||||||
| 1926 | - | |||||||||||||||||||
| 1927 | static inline OSVERSIONINFO winOsVersion() | - | ||||||||||||||||||
| 1928 | { | - | ||||||||||||||||||
| 1929 | OSVERSIONINFO result = { sizeof(OSVERSIONINFO), 0, 0, 0, 0, {'\0'}}; | - | ||||||||||||||||||
| 1930 | - | |||||||||||||||||||
| 1931 | #ifndef Q_OS_WINCE | - | ||||||||||||||||||
| 1932 | #define GetProcAddressA GetProcAddress | - | ||||||||||||||||||
| 1933 | #endif | - | ||||||||||||||||||
| 1934 | - | |||||||||||||||||||
| 1935 | // GetModuleHandle is not supported in WinRT and linking to it at load time | - | ||||||||||||||||||
| 1936 | // will not pass the Windows App Certification Kit... but it exists and is functional, | - | ||||||||||||||||||
| 1937 | // so use some unusual but widely used techniques to get a pointer to it | - | ||||||||||||||||||
| 1938 | #ifdef Q_OS_WINRT | - | ||||||||||||||||||
| 1939 | // 1. Get HMODULE of kernel32.dll, using the address of some function exported by that DLL | - | ||||||||||||||||||
| 1940 | HMODULE kernelModule = moduleHandleForFunction(reinterpret_cast<LPCVOID>(VirtualQuery)); | - | ||||||||||||||||||
| 1941 | if (Q_UNLIKELY(!kernelModule)) | - | ||||||||||||||||||
| 1942 | return result; | - | ||||||||||||||||||
| 1943 | - | |||||||||||||||||||
| 1944 | // 2. Get pointer to GetModuleHandle so we can then load other arbitrary modules (DLLs) | - | ||||||||||||||||||
| 1945 | typedef HMODULE(WINAPI *GetModuleHandleFunction)(LPCWSTR); | - | ||||||||||||||||||
| 1946 | GetModuleHandleFunction pGetModuleHandle = reinterpret_cast<GetModuleHandleFunction>( | - | ||||||||||||||||||
| 1947 | GetProcAddressA(kernelModule, "GetModuleHandleW")); | - | ||||||||||||||||||
| 1948 | if (Q_UNLIKELY(!pGetModuleHandle)) | - | ||||||||||||||||||
| 1949 | return result; | - | ||||||||||||||||||
| 1950 | #else | - | ||||||||||||||||||
| 1951 | #define pGetModuleHandle GetModuleHandleW | - | ||||||||||||||||||
| 1952 | #endif | - | ||||||||||||||||||
| 1953 | - | |||||||||||||||||||
| 1954 | #ifndef Q_OS_WINCE | - | ||||||||||||||||||
| 1955 | HMODULE ntdll = pGetModuleHandle(L"ntdll.dll"); | - | ||||||||||||||||||
| 1956 | if (Q_UNLIKELY(!ntdll)) | - | ||||||||||||||||||
| 1957 | return result; | - | ||||||||||||||||||
| 1958 | - | |||||||||||||||||||
| 1959 | // NTSTATUS is not defined on WinRT | - | ||||||||||||||||||
| 1960 | typedef LONG NTSTATUS; | - | ||||||||||||||||||
| 1961 | typedef NTSTATUS (NTAPI *RtlGetVersionFunction)(LPOSVERSIONINFO); | - | ||||||||||||||||||
| 1962 | - | |||||||||||||||||||
| 1963 | // RtlGetVersion is documented public API but we must load it dynamically | - | ||||||||||||||||||
| 1964 | // because linking to it at load time will not pass the Windows App Certification Kit | - | ||||||||||||||||||
| 1965 | // https://msdn.microsoft.com/en-us/library/windows/hardware/ff561910.aspx | - | ||||||||||||||||||
| 1966 | RtlGetVersionFunction pRtlGetVersion = reinterpret_cast<RtlGetVersionFunction>( | - | ||||||||||||||||||
| 1967 | GetProcAddressA(ntdll, "RtlGetVersion")); | - | ||||||||||||||||||
| 1968 | if (Q_UNLIKELY(!pRtlGetVersion)) | - | ||||||||||||||||||
| 1969 | return result; | - | ||||||||||||||||||
| 1970 | - | |||||||||||||||||||
| 1971 | // GetVersionEx() has been deprecated in Windows 8.1 and will return | - | ||||||||||||||||||
| 1972 | // only Windows 8 from that version on, so use the kernel API function. | - | ||||||||||||||||||
| 1973 | pRtlGetVersion(&result); // always returns STATUS_SUCCESS | - | ||||||||||||||||||
| 1974 | #else // !Q_OS_WINCE | - | ||||||||||||||||||
| 1975 | GetVersionEx(&result); | - | ||||||||||||||||||
| 1976 | #endif | - | ||||||||||||||||||
| 1977 | - | |||||||||||||||||||
| 1978 | return result; | - | ||||||||||||||||||
| 1979 | } | - | ||||||||||||||||||
| 1980 | - | |||||||||||||||||||
| 1981 | QSysInfo::WinVersion QSysInfo::windowsVersion() | - | ||||||||||||||||||
| 1982 | { | - | ||||||||||||||||||
| 1983 | #ifndef VER_PLATFORM_WIN32s | - | ||||||||||||||||||
| 1984 | #define VER_PLATFORM_WIN32s 0 | - | ||||||||||||||||||
| 1985 | #endif | - | ||||||||||||||||||
| 1986 | #ifndef VER_PLATFORM_WIN32_WINDOWS | - | ||||||||||||||||||
| 1987 | #define VER_PLATFORM_WIN32_WINDOWS 1 | - | ||||||||||||||||||
| 1988 | #endif | - | ||||||||||||||||||
| 1989 | #ifndef VER_PLATFORM_WIN32_NT | - | ||||||||||||||||||
| 1990 | #define VER_PLATFORM_WIN32_NT 2 | - | ||||||||||||||||||
| 1991 | #endif | - | ||||||||||||||||||
| 1992 | #ifndef VER_PLATFORM_WIN32_CE | - | ||||||||||||||||||
| 1993 | #define VER_PLATFORM_WIN32_CE 3 | - | ||||||||||||||||||
| 1994 | #endif | - | ||||||||||||||||||
| 1995 | - | |||||||||||||||||||
| 1996 | static QSysInfo::WinVersion winver; | - | ||||||||||||||||||
| 1997 | if (winver) | - | ||||||||||||||||||
| 1998 | return winver; | - | ||||||||||||||||||
| 1999 | winver = QSysInfo::WV_NT; | - | ||||||||||||||||||
| 2000 | const OSVERSIONINFO osver = winOsVersion(); | - | ||||||||||||||||||
| 2001 | if (osver.dwMajorVersion == 0) | - | ||||||||||||||||||
| 2002 | return QSysInfo::WV_None; | - | ||||||||||||||||||
| 2003 | #ifdef Q_OS_WINCE | - | ||||||||||||||||||
| 2004 | DWORD qt_cever = 0; | - | ||||||||||||||||||
| 2005 | qt_cever = osver.dwMajorVersion * 100; | - | ||||||||||||||||||
| 2006 | qt_cever += osver.dwMinorVersion * 10; | - | ||||||||||||||||||
| 2007 | #endif | - | ||||||||||||||||||
| 2008 | switch (osver.dwPlatformId) { | - | ||||||||||||||||||
| 2009 | case VER_PLATFORM_WIN32s: | - | ||||||||||||||||||
| 2010 | winver = QSysInfo::WV_32s; | - | ||||||||||||||||||
| 2011 | break; | - | ||||||||||||||||||
| 2012 | case VER_PLATFORM_WIN32_WINDOWS: | - | ||||||||||||||||||
| 2013 | // We treat Windows Me (minor 90) the same as Windows 98 | - | ||||||||||||||||||
| 2014 | if (osver.dwMinorVersion == 90) | - | ||||||||||||||||||
| 2015 | winver = QSysInfo::WV_Me; | - | ||||||||||||||||||
| 2016 | else if (osver.dwMinorVersion == 10) | - | ||||||||||||||||||
| 2017 | winver = QSysInfo::WV_98; | - | ||||||||||||||||||
| 2018 | else | - | ||||||||||||||||||
| 2019 | winver = QSysInfo::WV_95; | - | ||||||||||||||||||
| 2020 | break; | - | ||||||||||||||||||
| 2021 | #ifdef Q_OS_WINCE | - | ||||||||||||||||||
| 2022 | case VER_PLATFORM_WIN32_CE: | - | ||||||||||||||||||
| 2023 | if (qt_cever >= 600) | - | ||||||||||||||||||
| 2024 | winver = QSysInfo::WV_CE_6; | - | ||||||||||||||||||
| 2025 | if (qt_cever >= 500) | - | ||||||||||||||||||
| 2026 | winver = QSysInfo::WV_CE_5; | - | ||||||||||||||||||
| 2027 | else if (qt_cever >= 400) | - | ||||||||||||||||||
| 2028 | winver = QSysInfo::WV_CENET; | - | ||||||||||||||||||
| 2029 | else | - | ||||||||||||||||||
| 2030 | winver = QSysInfo::WV_CE; | - | ||||||||||||||||||
| 2031 | break; | - | ||||||||||||||||||
| 2032 | #endif | - | ||||||||||||||||||
| 2033 | default: // VER_PLATFORM_WIN32_NT | - | ||||||||||||||||||
| 2034 | if (osver.dwMajorVersion < 5) { | - | ||||||||||||||||||
| 2035 | winver = QSysInfo::WV_NT; | - | ||||||||||||||||||
| 2036 | } else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 0) { | - | ||||||||||||||||||
| 2037 | winver = QSysInfo::WV_2000; | - | ||||||||||||||||||
| 2038 | } else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 1) { | - | ||||||||||||||||||
| 2039 | winver = QSysInfo::WV_XP; | - | ||||||||||||||||||
| 2040 | } else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 2) { | - | ||||||||||||||||||
| 2041 | winver = QSysInfo::WV_2003; | - | ||||||||||||||||||
| 2042 | } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 0) { | - | ||||||||||||||||||
| 2043 | winver = QSysInfo::WV_VISTA; | - | ||||||||||||||||||
| 2044 | } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 1) { | - | ||||||||||||||||||
| 2045 | winver = QSysInfo::WV_WINDOWS7; | - | ||||||||||||||||||
| 2046 | } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 2) { | - | ||||||||||||||||||
| 2047 | winver = QSysInfo::WV_WINDOWS8; | - | ||||||||||||||||||
| 2048 | } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 3) { | - | ||||||||||||||||||
| 2049 | winver = QSysInfo::WV_WINDOWS8_1; | - | ||||||||||||||||||
| 2050 | } else if (osver.dwMajorVersion == 10 && osver.dwMinorVersion == 0) { | - | ||||||||||||||||||
| 2051 | winver = QSysInfo::WV_WINDOWS10; | - | ||||||||||||||||||
| 2052 | } else { | - | ||||||||||||||||||
| 2053 | winver = QSysInfo::WV_NT_based; | - | ||||||||||||||||||
| 2054 | } | - | ||||||||||||||||||
| 2055 | } | - | ||||||||||||||||||
| 2056 | - | |||||||||||||||||||
| 2057 | #ifdef QT_DEBUG | - | ||||||||||||||||||
| 2058 | { | - | ||||||||||||||||||
| 2059 | if (Q_UNLIKELY(qEnvironmentVariableIsSet("QT_WINVER_OVERRIDE"))) { | - | ||||||||||||||||||
| 2060 | const QByteArray winVerOverride = qgetenv("QT_WINVER_OVERRIDE"); | - | ||||||||||||||||||
| 2061 | if (winVerOverride == "NT") | - | ||||||||||||||||||
| 2062 | winver = QSysInfo::WV_NT; | - | ||||||||||||||||||
| 2063 | else if (winVerOverride == "2000") | - | ||||||||||||||||||
| 2064 | winver = QSysInfo::WV_2000; | - | ||||||||||||||||||
| 2065 | else if (winVerOverride == "2003") | - | ||||||||||||||||||
| 2066 | winver = QSysInfo::WV_2003; | - | ||||||||||||||||||
| 2067 | else if (winVerOverride == "XP") | - | ||||||||||||||||||
| 2068 | winver = QSysInfo::WV_XP; | - | ||||||||||||||||||
| 2069 | else if (winVerOverride == "VISTA") | - | ||||||||||||||||||
| 2070 | winver = QSysInfo::WV_VISTA; | - | ||||||||||||||||||
| 2071 | else if (winVerOverride == "WINDOWS7") | - | ||||||||||||||||||
| 2072 | winver = QSysInfo::WV_WINDOWS7; | - | ||||||||||||||||||
| 2073 | else if (winVerOverride == "WINDOWS8") | - | ||||||||||||||||||
| 2074 | winver = QSysInfo::WV_WINDOWS8; | - | ||||||||||||||||||
| 2075 | else if (winVerOverride == "WINDOWS8_1") | - | ||||||||||||||||||
| 2076 | winver = QSysInfo::WV_WINDOWS8_1; | - | ||||||||||||||||||
| 2077 | else if (winVerOverride == "WINDOWS10") | - | ||||||||||||||||||
| 2078 | winver = QSysInfo::WV_WINDOWS10; | - | ||||||||||||||||||
| 2079 | } | - | ||||||||||||||||||
| 2080 | } | - | ||||||||||||||||||
| 2081 | #endif | - | ||||||||||||||||||
| 2082 | - | |||||||||||||||||||
| 2083 | return winver; | - | ||||||||||||||||||
| 2084 | } | - | ||||||||||||||||||
| 2085 | - | |||||||||||||||||||
| 2086 | static const char *winVer_helper() | - | ||||||||||||||||||
| 2087 | { | - | ||||||||||||||||||
| 2088 | switch (int(QSysInfo::WindowsVersion)) { | - | ||||||||||||||||||
| 2089 | case QSysInfo::WV_NT: | - | ||||||||||||||||||
| 2090 | return "NT"; | - | ||||||||||||||||||
| 2091 | case QSysInfo::WV_2000: | - | ||||||||||||||||||
| 2092 | return "2000"; | - | ||||||||||||||||||
| 2093 | case QSysInfo::WV_XP: | - | ||||||||||||||||||
| 2094 | return "XP"; | - | ||||||||||||||||||
| 2095 | case QSysInfo::WV_2003: | - | ||||||||||||||||||
| 2096 | return "2003"; | - | ||||||||||||||||||
| 2097 | case QSysInfo::WV_VISTA: | - | ||||||||||||||||||
| 2098 | return "Vista"; | - | ||||||||||||||||||
| 2099 | case QSysInfo::WV_WINDOWS7: | - | ||||||||||||||||||
| 2100 | return "7"; | - | ||||||||||||||||||
| 2101 | case QSysInfo::WV_WINDOWS8: | - | ||||||||||||||||||
| 2102 | return "8"; | - | ||||||||||||||||||
| 2103 | case QSysInfo::WV_WINDOWS8_1: | - | ||||||||||||||||||
| 2104 | return "8.1"; | - | ||||||||||||||||||
| 2105 | case QSysInfo::WV_WINDOWS10: | - | ||||||||||||||||||
| 2106 | return "10"; | - | ||||||||||||||||||
| 2107 | - | |||||||||||||||||||
| 2108 | case QSysInfo::WV_CE: | - | ||||||||||||||||||
| 2109 | return "CE"; | - | ||||||||||||||||||
| 2110 | case QSysInfo::WV_CENET: | - | ||||||||||||||||||
| 2111 | return "CENET"; | - | ||||||||||||||||||
| 2112 | case QSysInfo::WV_CE_5: | - | ||||||||||||||||||
| 2113 | return "CE5"; | - | ||||||||||||||||||
| 2114 | case QSysInfo::WV_CE_6: | - | ||||||||||||||||||
| 2115 | return "CE6"; | - | ||||||||||||||||||
| 2116 | } | - | ||||||||||||||||||
| 2117 | // unknown, future version | - | ||||||||||||||||||
| 2118 | return 0; | - | ||||||||||||||||||
| 2119 | } | - | ||||||||||||||||||
| 2120 | - | |||||||||||||||||||
| 2121 | const QSysInfo::WinVersion QSysInfo::WindowsVersion = QSysInfo::windowsVersion(); | - | ||||||||||||||||||
| 2122 | - | |||||||||||||||||||
| 2123 | #endif | - | ||||||||||||||||||
| 2124 | #if defined(Q_OS_UNIX) | - | ||||||||||||||||||
| 2125 | # if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) || defined(Q_OS_FREEBSD) | - | ||||||||||||||||||
| 2126 | # define USE_ETC_OS_RELEASE | - | ||||||||||||||||||
| 2127 | struct QUnixOSVersion | - | ||||||||||||||||||
| 2128 | { | - | ||||||||||||||||||
| 2129 | // from /etc/os-release older /etc/lsb-release // redhat /etc/redhat-release // debian /etc/debian_version | - | ||||||||||||||||||
| 2130 | QString productType; // $ID $DISTRIB_ID // single line file containing: // Debian | - | ||||||||||||||||||
| 2131 | QString productVersion; // $VERSION_ID $DISTRIB_RELEASE // <Vendor_ID release Version_ID> // single line file <Release_ID/sid> | - | ||||||||||||||||||
| 2132 | QString prettyName; // $PRETTY_NAME $DISTRIB_DESCRIPTION | - | ||||||||||||||||||
| 2133 | }; | - | ||||||||||||||||||
| 2134 | - | |||||||||||||||||||
| 2135 | static QString unquote(const char *begin, const char *end) | - | ||||||||||||||||||
| 2136 | { | - | ||||||||||||||||||
| 2137 | if (*begin == '"') {
| 9-18 | ||||||||||||||||||
| 2138 | Q_ASSERT(end[-1] == '"'); | - | ||||||||||||||||||
| 2139 | return QString::fromLatin1(begin + 1, end - begin - 2); executed 18 times by 4 tests: return QString::fromLatin1(begin + 1, end - begin - 2);Executed by:
| 18 | ||||||||||||||||||
| 2140 | } | - | ||||||||||||||||||
| 2141 | return QString::fromLatin1(begin, end - begin); executed 9 times by 4 tests: return QString::fromLatin1(begin, end - begin);Executed by:
| 9 | ||||||||||||||||||
| 2142 | } | - | ||||||||||||||||||
| 2143 | static QByteArray getEtcFileContent(const char *filename) | - | ||||||||||||||||||
| 2144 | { | - | ||||||||||||||||||
| 2145 | // we're avoiding QFile here | - | ||||||||||||||||||
| 2146 | int fd = qt_safe_open(filename, O_RDONLY); | - | ||||||||||||||||||
| 2147 | if (fd == -1)
| 0-9 | ||||||||||||||||||
| 2148 | return QByteArray(); never executed: return QByteArray(); | 0 | ||||||||||||||||||
| 2149 | - | |||||||||||||||||||
| 2150 | QT_STATBUF sbuf; | - | ||||||||||||||||||
| 2151 | if (QT_FSTAT(fd, &sbuf) == -1) {
| 0-9 | ||||||||||||||||||
| 2152 | qt_safe_close(fd); | - | ||||||||||||||||||
| 2153 | return QByteArray(); never executed: return QByteArray(); | 0 | ||||||||||||||||||
| 2154 | } | - | ||||||||||||||||||
| 2155 | - | |||||||||||||||||||
| 2156 | QByteArray buffer(sbuf.st_size, Qt::Uninitialized); | - | ||||||||||||||||||
| 2157 | buffer.resize(qt_safe_read(fd, buffer.data(), sbuf.st_size)); | - | ||||||||||||||||||
| 2158 | qt_safe_close(fd); | - | ||||||||||||||||||
| 2159 | return buffer; executed 9 times by 4 tests: return buffer;Executed by:
| 9 | ||||||||||||||||||
| 2160 | } | - | ||||||||||||||||||
| 2161 | - | |||||||||||||||||||
| 2162 | static bool readEtcFile(QUnixOSVersion &v, const char *filename, | - | ||||||||||||||||||
| 2163 | const QByteArray &idKey, const QByteArray &versionKey, const QByteArray &prettyNameKey) | - | ||||||||||||||||||
| 2164 | { | - | ||||||||||||||||||
| 2165 | - | |||||||||||||||||||
| 2166 | QByteArray buffer = getEtcFileContent(filename); | - | ||||||||||||||||||
| 2167 | if (buffer.isEmpty())
| 0-9 | ||||||||||||||||||
| 2168 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 2169 | - | |||||||||||||||||||
| 2170 | const char *ptr = buffer.constData(); | - | ||||||||||||||||||
| 2171 | const char *end = buffer.constEnd(); | - | ||||||||||||||||||
| 2172 | const char *eol; | - | ||||||||||||||||||
| 2173 | QByteArray line; | - | ||||||||||||||||||
| 2174 | for ( ; ptr != end; ptr = eol + 1) {
| 9-72 | ||||||||||||||||||
| 2175 | // find the end of the line after ptr | - | ||||||||||||||||||
| 2176 | eol = static_cast<const char *>(memchr(ptr, '\n', end - ptr)); | - | ||||||||||||||||||
| 2177 | if (!eol)
| 0-72 | ||||||||||||||||||
| 2178 | eol = end - 1; never executed: eol = end - 1; | 0 | ||||||||||||||||||
| 2179 | line.setRawData(ptr, eol - ptr); | - | ||||||||||||||||||
| 2180 | - | |||||||||||||||||||
| 2181 | if (line.startsWith(idKey)) {
| 9-63 | ||||||||||||||||||
| 2182 | ptr += idKey.length(); | - | ||||||||||||||||||
| 2183 | v.productType = unquote(ptr, eol); | - | ||||||||||||||||||
| 2184 | continue; executed 9 times by 4 tests: continue;Executed by:
| 9 | ||||||||||||||||||
| 2185 | } | - | ||||||||||||||||||
| 2186 | - | |||||||||||||||||||
| 2187 | if (line.startsWith(prettyNameKey)) {
| 9-54 | ||||||||||||||||||
| 2188 | ptr += prettyNameKey.length(); | - | ||||||||||||||||||
| 2189 | v.prettyName = unquote(ptr, eol); | - | ||||||||||||||||||
| 2190 | continue; executed 9 times by 4 tests: continue;Executed by:
| 9 | ||||||||||||||||||
| 2191 | } | - | ||||||||||||||||||
| 2192 | - | |||||||||||||||||||
| 2193 | if (line.startsWith(versionKey)) {
| 9-45 | ||||||||||||||||||
| 2194 | ptr += versionKey.length(); | - | ||||||||||||||||||
| 2195 | v.productVersion = unquote(ptr, eol); | - | ||||||||||||||||||
| 2196 | continue; executed 9 times by 4 tests: continue;Executed by:
| 9 | ||||||||||||||||||
| 2197 | } | - | ||||||||||||||||||
| 2198 | } executed 45 times by 4 tests: end of blockExecuted by:
| 45 | ||||||||||||||||||
| 2199 | - | |||||||||||||||||||
| 2200 | return true; executed 9 times by 4 tests: return true;Executed by:
| 9 | ||||||||||||||||||
| 2201 | } | - | ||||||||||||||||||
| 2202 | - | |||||||||||||||||||
| 2203 | static bool readEtcOsRelease(QUnixOSVersion &v) | - | ||||||||||||||||||
| 2204 | { | - | ||||||||||||||||||
| 2205 | return readEtcFile(v, "/etc/os-release", QByteArrayLiteral("ID="), executed 9 times by 4 tests: return readEtcFile(v, "/etc/os-release", ([]() -> QByteArray { enum { Size = sizeof("ID=") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "ID=" }; QByteArrayDataPtr holder = { qbyt...AME=") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "PRETTY_NAME=" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()));Executed by:
executed 9 times by 4 tests: return ba;Executed by:
| 9 | ||||||||||||||||||
| 2206 | QByteArrayLiteral("VERSION_ID="), QByteArrayLiteral("PRETTY_NAME=")); executed 9 times by 4 tests: return readEtcFile(v, "/etc/os-release", ([]() -> QByteArray { enum { Size = sizeof("ID=") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "ID=" }; QByteArrayDataPtr holder = { qbyt...AME=") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "PRETTY_NAME=" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()));Executed by:
executed 9 times by 4 tests: return ba;Executed by:
executed 9 times by 4 tests: return ba;Executed by:
| 9 | ||||||||||||||||||
| 2207 | } | - | ||||||||||||||||||
| 2208 | - | |||||||||||||||||||
| 2209 | static bool readEtcLsbRelease(QUnixOSVersion &v) | - | ||||||||||||||||||
| 2210 | { | - | ||||||||||||||||||
| 2211 | bool ok = readEtcFile(v, "/etc/lsb-release", QByteArrayLiteral("DISTRIB_ID="), never executed: return ba; | 0 | ||||||||||||||||||
| 2212 | QByteArrayLiteral("DISTRIB_RELEASE="), QByteArrayLiteral("DISTRIB_DESCRIPTION=")); never executed: return ba;never executed: return ba; | 0 | ||||||||||||||||||
| 2213 | if (ok && (v.prettyName.isEmpty() || v.prettyName == v.productType)) {
| 0 | ||||||||||||||||||
| 2214 | // some distributions have redundant information for the pretty name, | - | ||||||||||||||||||
| 2215 | // so try /etc/<lowercasename>-release | - | ||||||||||||||||||
| 2216 | - | |||||||||||||||||||
| 2217 | // we're still avoiding QFile here | - | ||||||||||||||||||
| 2218 | QByteArray distrorelease = "/etc/" + v.productType.toLatin1().toLower() + "-release"; | - | ||||||||||||||||||
| 2219 | int fd = qt_safe_open(distrorelease, O_RDONLY); | - | ||||||||||||||||||
| 2220 | if (fd != -1) {
| 0 | ||||||||||||||||||
| 2221 | QT_STATBUF sbuf; | - | ||||||||||||||||||
| 2222 | if (QT_FSTAT(fd, &sbuf) != -1 && sbuf.st_size > v.prettyName.length()) {
| 0 | ||||||||||||||||||
| 2223 | // file apparently contains interesting information | - | ||||||||||||||||||
| 2224 | QByteArray buffer(sbuf.st_size, Qt::Uninitialized); | - | ||||||||||||||||||
| 2225 | buffer.resize(qt_safe_read(fd, buffer.data(), sbuf.st_size)); | - | ||||||||||||||||||
| 2226 | v.prettyName = QString::fromLatin1(buffer.trimmed()); | - | ||||||||||||||||||
| 2227 | } never executed: end of block | 0 | ||||||||||||||||||
| 2228 | qt_safe_close(fd); | - | ||||||||||||||||||
| 2229 | } never executed: end of block | 0 | ||||||||||||||||||
| 2230 | } never executed: end of block | 0 | ||||||||||||||||||
| 2231 | - | |||||||||||||||||||
| 2232 | // some distributions have a /etc/lsb-release file that does not provide the values | - | ||||||||||||||||||
| 2233 | // we are looking for, i.e. DISTRIB_ID, DISTRIB_RELEASE and DISTRIB_DESCRIPTION. | - | ||||||||||||||||||
| 2234 | // Assuming that neither DISTRIB_ID nor DISTRIB_RELEASE were found, or contained valid values, | - | ||||||||||||||||||
| 2235 | // returning false for readEtcLsbRelease will allow further /etc/<lowercasename>-release parsing. | - | ||||||||||||||||||
| 2236 | return ok && !(v.productType.isEmpty() && v.productVersion.isEmpty()); never executed: return ok && !(v.productType.isEmpty() && v.productVersion.isEmpty());
| 0 | ||||||||||||||||||
| 2237 | } | - | ||||||||||||||||||
| 2238 | - | |||||||||||||||||||
| 2239 | #if defined(Q_OS_LINUX) | - | ||||||||||||||||||
| 2240 | static QByteArray getEtcFileFirstLine(const char *fileName) | - | ||||||||||||||||||
| 2241 | { | - | ||||||||||||||||||
| 2242 | QByteArray buffer = getEtcFileContent(fileName); | - | ||||||||||||||||||
| 2243 | if (buffer.isEmpty())
| 0 | ||||||||||||||||||
| 2244 | return QByteArray(); never executed: return QByteArray(); | 0 | ||||||||||||||||||
| 2245 | - | |||||||||||||||||||
| 2246 | const char *ptr = buffer.constData(); | - | ||||||||||||||||||
| 2247 | int eol = buffer.indexOf("\n"); | - | ||||||||||||||||||
| 2248 | return QByteArray(ptr, eol).trimmed(); never executed: return QByteArray(ptr, eol).trimmed(); | 0 | ||||||||||||||||||
| 2249 | } | - | ||||||||||||||||||
| 2250 | - | |||||||||||||||||||
| 2251 | static bool readEtcRedHatRelease(QUnixOSVersion &v) | - | ||||||||||||||||||
| 2252 | { | - | ||||||||||||||||||
| 2253 | // /etc/redhat-release analysed should be a one line file | - | ||||||||||||||||||
| 2254 | // the format of its content is <Vendor_ID release Version> | - | ||||||||||||||||||
| 2255 | // i.e. "Red Hat Enterprise Linux Workstation release 6.5 (Santiago)" | - | ||||||||||||||||||
| 2256 | QByteArray line = getEtcFileFirstLine("/etc/redhat-release"); | - | ||||||||||||||||||
| 2257 | if (line.isEmpty())
| 0 | ||||||||||||||||||
| 2258 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 2259 | - | |||||||||||||||||||
| 2260 | v.prettyName = QString::fromLatin1(line); | - | ||||||||||||||||||
| 2261 | - | |||||||||||||||||||
| 2262 | const char keyword[] = "release "; | - | ||||||||||||||||||
| 2263 | int releaseIndex = line.indexOf(keyword); | - | ||||||||||||||||||
| 2264 | v.productType = QString::fromLatin1(line.mid(0, releaseIndex)).remove(QLatin1Char(' ')); | - | ||||||||||||||||||
| 2265 | int spaceIndex = line.indexOf(' ', releaseIndex + strlen(keyword)); | - | ||||||||||||||||||
| 2266 | v.productVersion = QString::fromLatin1(line.mid(releaseIndex + strlen(keyword), | - | ||||||||||||||||||
| 2267 | spaceIndex > -1 ? spaceIndex - releaseIndex - int(strlen(keyword)) : -1)); | - | ||||||||||||||||||
| 2268 | return true; never executed: return true; | 0 | ||||||||||||||||||
| 2269 | } | - | ||||||||||||||||||
| 2270 | - | |||||||||||||||||||
| 2271 | static bool readEtcDebianVersion(QUnixOSVersion &v) | - | ||||||||||||||||||
| 2272 | { | - | ||||||||||||||||||
| 2273 | // /etc/debian_version analysed should be a one line file | - | ||||||||||||||||||
| 2274 | // the format of its content is <Release_ID/sid> | - | ||||||||||||||||||
| 2275 | // i.e. "jessie/sid" | - | ||||||||||||||||||
| 2276 | QByteArray line = getEtcFileFirstLine("/etc/debian_version"); | - | ||||||||||||||||||
| 2277 | if (line.isEmpty())
| 0 | ||||||||||||||||||
| 2278 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 2279 | - | |||||||||||||||||||
| 2280 | v.productType = QStringLiteral("Debian"); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 2281 | v.productVersion = QString::fromLatin1(line); | - | ||||||||||||||||||
| 2282 | return true; never executed: return true; | 0 | ||||||||||||||||||
| 2283 | } | - | ||||||||||||||||||
| 2284 | #endif | - | ||||||||||||||||||
| 2285 | - | |||||||||||||||||||
| 2286 | static bool findUnixOsVersion(QUnixOSVersion &v) | - | ||||||||||||||||||
| 2287 | { | - | ||||||||||||||||||
| 2288 | if (readEtcOsRelease(v))
| 0-9 | ||||||||||||||||||
| 2289 | return true; executed 9 times by 4 tests: return true;Executed by:
| 9 | ||||||||||||||||||
| 2290 | if (readEtcLsbRelease(v))
| 0 | ||||||||||||||||||
| 2291 | return true; never executed: return true; | 0 | ||||||||||||||||||
| 2292 | #if defined(Q_OS_LINUX) | - | ||||||||||||||||||
| 2293 | if (readEtcRedHatRelease(v))
| 0 | ||||||||||||||||||
| 2294 | return true; never executed: return true; | 0 | ||||||||||||||||||
| 2295 | if (readEtcDebianVersion(v))
| 0 | ||||||||||||||||||
| 2296 | return true; never executed: return true; | 0 | ||||||||||||||||||
| 2297 | #endif | - | ||||||||||||||||||
| 2298 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 2299 | } | - | ||||||||||||||||||
| 2300 | # endif // USE_ETC_OS_RELEASE | - | ||||||||||||||||||
| 2301 | #endif // Q_OS_UNIX | - | ||||||||||||||||||
| 2302 | - | |||||||||||||||||||
| 2303 | - | |||||||||||||||||||
| 2304 | /*! | - | ||||||||||||||||||
| 2305 | \since 5.4 | - | ||||||||||||||||||
| 2306 | - | |||||||||||||||||||
| 2307 | Returns the architecture of the CPU that Qt was compiled for, in text | - | ||||||||||||||||||
| 2308 | format. Note that this may not match the actual CPU that the application is | - | ||||||||||||||||||
| 2309 | running on if there's an emulation layer or if the CPU supports multiple | - | ||||||||||||||||||
| 2310 | architectures (like x86-64 processors supporting i386 applications). To | - | ||||||||||||||||||
| 2311 | detect that, use currentCpuArchitecture(). | - | ||||||||||||||||||
| 2312 | - | |||||||||||||||||||
| 2313 | Values returned by this function are stable and will not change over time, | - | ||||||||||||||||||
| 2314 | so applications can rely on the returned value as an identifier, except | - | ||||||||||||||||||
| 2315 | that new CPU types may be added over time. | - | ||||||||||||||||||
| 2316 | - | |||||||||||||||||||
| 2317 | Typical returned values are (note: list not exhaustive): | - | ||||||||||||||||||
| 2318 | \list | - | ||||||||||||||||||
| 2319 | \li "arm" | - | ||||||||||||||||||
| 2320 | \li "arm64" | - | ||||||||||||||||||
| 2321 | \li "i386" | - | ||||||||||||||||||
| 2322 | \li "ia64" | - | ||||||||||||||||||
| 2323 | \li "mips" | - | ||||||||||||||||||
| 2324 | \li "mips64" | - | ||||||||||||||||||
| 2325 | \li "power" | - | ||||||||||||||||||
| 2326 | \li "power64" | - | ||||||||||||||||||
| 2327 | \li "sparc" | - | ||||||||||||||||||
| 2328 | \li "sparcv9" | - | ||||||||||||||||||
| 2329 | \li "x86_64" | - | ||||||||||||||||||
| 2330 | \endlist | - | ||||||||||||||||||
| 2331 | - | |||||||||||||||||||
| 2332 | \sa QSysInfo::buildAbi(), QSysInfo::currentCpuArchitecture() | - | ||||||||||||||||||
| 2333 | */ | - | ||||||||||||||||||
| 2334 | QString QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 2335 | { | - | ||||||||||||||||||
| 2336 | return QStringLiteral(ARCH_PROCESSOR); never executed: return ([]() -> QString { enum { Size = sizeof(u"" "x86_64")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "x86_64" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 2337 | } | - | ||||||||||||||||||
| 2338 | - | |||||||||||||||||||
| 2339 | /*! | - | ||||||||||||||||||
| 2340 | \since 5.4 | - | ||||||||||||||||||
| 2341 | - | |||||||||||||||||||
| 2342 | Returns the architecture of the CPU that the application is running on, in | - | ||||||||||||||||||
| 2343 | text format. Note that this function depends on what the OS will report and | - | ||||||||||||||||||
| 2344 | may not detect the actual CPU architecture if the OS hides that information | - | ||||||||||||||||||
| 2345 | or is unable to provide it. For example, a 32-bit OS running on a 64-bit | - | ||||||||||||||||||
| 2346 | CPU is usually unable to determine the CPU is actually capable of running | - | ||||||||||||||||||
| 2347 | 64-bit programs. | - | ||||||||||||||||||
| 2348 | - | |||||||||||||||||||
| 2349 | Values returned by this function are mostly stable: an attempt will be made | - | ||||||||||||||||||
| 2350 | to ensure that they stay constant over time and match the values returned | - | ||||||||||||||||||
| 2351 | by QSysInfo::builldCpuArchitecture(). However, due to the nature of the | - | ||||||||||||||||||
| 2352 | operating system functions being used, there may be discrepancies. | - | ||||||||||||||||||
| 2353 | - | |||||||||||||||||||
| 2354 | Typical returned values are (note: list not exhaustive): | - | ||||||||||||||||||
| 2355 | \list | - | ||||||||||||||||||
| 2356 | \li "arm" | - | ||||||||||||||||||
| 2357 | \li "arm64" | - | ||||||||||||||||||
| 2358 | \li "i386" | - | ||||||||||||||||||
| 2359 | \li "ia64" | - | ||||||||||||||||||
| 2360 | \li "mips" | - | ||||||||||||||||||
| 2361 | \li "mips64" | - | ||||||||||||||||||
| 2362 | \li "power" | - | ||||||||||||||||||
| 2363 | \li "power64" | - | ||||||||||||||||||
| 2364 | \li "sparc" | - | ||||||||||||||||||
| 2365 | \li "sparcv9" | - | ||||||||||||||||||
| 2366 | \li "x86_64" | - | ||||||||||||||||||
| 2367 | \endlist | - | ||||||||||||||||||
| 2368 | - | |||||||||||||||||||
| 2369 | \sa QSysInfo::buildAbi(), QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 2370 | */ | - | ||||||||||||||||||
| 2371 | QString QSysInfo::currentCpuArchitecture() | - | ||||||||||||||||||
| 2372 | { | - | ||||||||||||||||||
| 2373 | #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) | - | ||||||||||||||||||
| 2374 | // We don't need to catch all the CPU architectures in this function; | - | ||||||||||||||||||
| 2375 | // only those where the host CPU might be different than the build target | - | ||||||||||||||||||
| 2376 | // (usually, 64-bit platforms). | - | ||||||||||||||||||
| 2377 | SYSTEM_INFO info; | - | ||||||||||||||||||
| 2378 | GetNativeSystemInfo(&info); | - | ||||||||||||||||||
| 2379 | switch (info.wProcessorArchitecture) { | - | ||||||||||||||||||
| 2380 | # ifdef PROCESSOR_ARCHITECTURE_AMD64 | - | ||||||||||||||||||
| 2381 | case PROCESSOR_ARCHITECTURE_AMD64: | - | ||||||||||||||||||
| 2382 | return QStringLiteral("x86_64"); | - | ||||||||||||||||||
| 2383 | # endif | - | ||||||||||||||||||
| 2384 | # ifdef PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 | - | ||||||||||||||||||
| 2385 | case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64: | - | ||||||||||||||||||
| 2386 | # endif | - | ||||||||||||||||||
| 2387 | case PROCESSOR_ARCHITECTURE_IA64: | - | ||||||||||||||||||
| 2388 | return QStringLiteral("ia64"); | - | ||||||||||||||||||
| 2389 | } | - | ||||||||||||||||||
| 2390 | #elif defined(Q_OS_UNIX) | - | ||||||||||||||||||
| 2391 | long ret = -1; | - | ||||||||||||||||||
| 2392 | struct utsname u; | - | ||||||||||||||||||
| 2393 | - | |||||||||||||||||||
| 2394 | # if defined(Q_OS_SOLARIS) | - | ||||||||||||||||||
| 2395 | // We need a special call for Solaris because uname(2) on x86 returns "i86pc" for | - | ||||||||||||||||||
| 2396 | // both 32- and 64-bit CPUs. Reference: | - | ||||||||||||||||||
| 2397 | // http://docs.oracle.com/cd/E18752_01/html/816-5167/sysinfo-2.html#REFMAN2sysinfo-2 | - | ||||||||||||||||||
| 2398 | // http://fxr.watson.org/fxr/source/common/syscall/systeminfo.c?v=OPENSOLARIS | - | ||||||||||||||||||
| 2399 | // http://fxr.watson.org/fxr/source/common/conf/param.c?v=OPENSOLARIS;im=10#L530 | - | ||||||||||||||||||
| 2400 | if (ret == -1) | - | ||||||||||||||||||
| 2401 | ret = sysinfo(SI_ARCHITECTURE_64, u.machine, sizeof u.machine); | - | ||||||||||||||||||
| 2402 | # endif | - | ||||||||||||||||||
| 2403 | - | |||||||||||||||||||
| 2404 | if (ret == -1)
| 0-1 | ||||||||||||||||||
| 2405 | ret = uname(&u); executed 1 time by 1 test: ret = uname(&u);Executed by:
| 1 | ||||||||||||||||||
| 2406 | - | |||||||||||||||||||
| 2407 | // we could use detectUnixVersion() above, but we only need a field no other function does | - | ||||||||||||||||||
| 2408 | if (ret != -1) {
| 0-1 | ||||||||||||||||||
| 2409 | // the use of QT_BUILD_INTERNAL here is simply to ensure all branches build | - | ||||||||||||||||||
| 2410 | // as we don't often build on some of the less common platforms | - | ||||||||||||||||||
| 2411 | # if defined(Q_PROCESSOR_ARM) || defined(QT_BUILD_INTERNAL) | - | ||||||||||||||||||
| 2412 | if (strcmp(u.machine, "aarch64") == 0)
| 0-1 | ||||||||||||||||||
| 2413 | return QStringLiteral("arm64"); never executed: return ([]() -> QString { enum { Size = sizeof(u"" "arm64")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "arm64" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 2414 | if (strncmp(u.machine, "armv", 4) == 0)
| 0-1 | ||||||||||||||||||
| 2415 | return QStringLiteral("arm"); never executed: return ([]() -> QString { enum { Size = sizeof(u"" "arm")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "arm" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 2416 | # endif | - | ||||||||||||||||||
| 2417 | # if defined(Q_PROCESSOR_POWER) || defined(QT_BUILD_INTERNAL) | - | ||||||||||||||||||
| 2418 | // harmonize "powerpc" and "ppc" to "power" | - | ||||||||||||||||||
| 2419 | if (strncmp(u.machine, "ppc", 3) == 0)
| 0-1 | ||||||||||||||||||
| 2420 | return QLatin1String("power") + QLatin1String(u.machine + 3); never executed: return QLatin1String("power") + QLatin1String(u.machine + 3); | 0 | ||||||||||||||||||
| 2421 | if (strncmp(u.machine, "powerpc", 7) == 0)
| 0-1 | ||||||||||||||||||
| 2422 | return QLatin1String("power") + QLatin1String(u.machine + 7); never executed: return QLatin1String("power") + QLatin1String(u.machine + 7); | 0 | ||||||||||||||||||
| 2423 | if (strcmp(u.machine, "Power Macintosh") == 0)
| 0-1 | ||||||||||||||||||
| 2424 | return QLatin1String("power"); never executed: return QLatin1String("power"); | 0 | ||||||||||||||||||
| 2425 | # endif | - | ||||||||||||||||||
| 2426 | # if defined(Q_PROCESSOR_SPARC) || defined(QT_BUILD_INTERNAL) | - | ||||||||||||||||||
| 2427 | // Solaris sysinfo(2) (above) uses "sparcv9", but uname -m says "sun4u"; | - | ||||||||||||||||||
| 2428 | // Linux says "sparc64" | - | ||||||||||||||||||
| 2429 | if (strcmp(u.machine, "sun4u") == 0 || strcmp(u.machine, "sparc64") == 0)
| 0-1 | ||||||||||||||||||
| 2430 | return QStringLiteral("sparcv9"); never executed: return ([]() -> QString { enum { Size = sizeof(u"" "sparcv9")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "sparcv9" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 2431 | if (strcmp(u.machine, "sparc32") == 0)
| 0-1 | ||||||||||||||||||
| 2432 | return QStringLiteral("sparc"); never executed: return ([]() -> QString { enum { Size = sizeof(u"" "sparc")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "sparc" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 2433 | # endif | - | ||||||||||||||||||
| 2434 | # if defined(Q_PROCESSOR_X86) || defined(QT_BUILD_INTERNAL) | - | ||||||||||||||||||
| 2435 | // harmonize all "i?86" to "i386" | - | ||||||||||||||||||
| 2436 | if (strlen(u.machine) == 4 && u.machine[0] == 'i'
| 0-1 | ||||||||||||||||||
| 2437 | && u.machine[2] == '8' && u.machine[3] == '6')
| 0 | ||||||||||||||||||
| 2438 | return QStringLiteral("i386"); never executed: return ([]() -> QString { enum { Size = sizeof(u"" "i386")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "i386" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 2439 | if (strcmp(u.machine, "amd64") == 0) // Solaris
| 0-1 | ||||||||||||||||||
| 2440 | return QStringLiteral("x86_64"); never executed: return ([]() -> QString { enum { Size = sizeof(u"" "x86_64")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "x86_64" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 2441 | # endif | - | ||||||||||||||||||
| 2442 | return QString::fromLatin1(u.machine); executed 1 time by 1 test: return QString::fromLatin1(u.machine);Executed by:
| 1 | ||||||||||||||||||
| 2443 | } | - | ||||||||||||||||||
| 2444 | #endif | - | ||||||||||||||||||
| 2445 | return buildCpuArchitecture(); never executed: return buildCpuArchitecture(); | 0 | ||||||||||||||||||
| 2446 | } | - | ||||||||||||||||||
| 2447 | - | |||||||||||||||||||
| 2448 | /*! | - | ||||||||||||||||||
| 2449 | \since 5.4 | - | ||||||||||||||||||
| 2450 | - | |||||||||||||||||||
| 2451 | Returns the full architecture string that Qt was compiled for. This string | - | ||||||||||||||||||
| 2452 | is useful for identifying different, incompatible builds. For example, it | - | ||||||||||||||||||
| 2453 | can be used as an identifier to request an upgrade package from a server. | - | ||||||||||||||||||
| 2454 | - | |||||||||||||||||||
| 2455 | The values returned from this function are kept stable as follows: the | - | ||||||||||||||||||
| 2456 | mandatory components of the result will not change in future versions of | - | ||||||||||||||||||
| 2457 | Qt, but optional suffixes may be added. | - | ||||||||||||||||||
| 2458 | - | |||||||||||||||||||
| 2459 | The returned value is composed of three or more parts, separated by dashes | - | ||||||||||||||||||
| 2460 | ("-"). They are: | - | ||||||||||||||||||
| 2461 | - | |||||||||||||||||||
| 2462 | \table | - | ||||||||||||||||||
| 2463 | \header \li Component \li Value | - | ||||||||||||||||||
| 2464 | \row \li CPU Architecture \li The same as QSysInfo::buildCpuArchitecture(), such as "arm", "i386", "mips" or "x86_64" | - | ||||||||||||||||||
| 2465 | \row \li Endianness \li "little_endian" or "big_endian" | - | ||||||||||||||||||
| 2466 | \row \li Word size \li Whether it's a 32- or 64-bit application. Possible values are: | - | ||||||||||||||||||
| 2467 | "llp64" (Windows 64-bit), "lp64" (Unix 64-bit), "ilp32" (32-bit) | - | ||||||||||||||||||
| 2468 | \row \li (Optional) ABI \li Zero or more components identifying different ABIs possible in this architecture. | - | ||||||||||||||||||
| 2469 | Currently, Qt has optional ABI components for ARM and MIPS processors: one | - | ||||||||||||||||||
| 2470 | component is the main ABI (such as "eabi", "o32", "n32", "o64"); another is | - | ||||||||||||||||||
| 2471 | whether the calling convention is using hardware floating point registers ("hardfloat" | - | ||||||||||||||||||
| 2472 | is present). | - | ||||||||||||||||||
| 2473 | - | |||||||||||||||||||
| 2474 | Additionally, if Qt was configured with \c{-qreal float}, the ABI option tag "qreal_float" | - | ||||||||||||||||||
| 2475 | will be present. If Qt was configured with another type as qreal, that type is present after | - | ||||||||||||||||||
| 2476 | "qreal_", with all characters other than letters and digits escaped by an underscore, followed | - | ||||||||||||||||||
| 2477 | by two hex digits. For example, \c{-qreal long double} becomes "qreal_long_20double". | - | ||||||||||||||||||
| 2478 | \endtable | - | ||||||||||||||||||
| 2479 | - | |||||||||||||||||||
| 2480 | \sa QSysInfo::buildCpuArchitecture() | - | ||||||||||||||||||
| 2481 | */ | - | ||||||||||||||||||
| 2482 | QString QSysInfo::buildAbi() | - | ||||||||||||||||||
| 2483 | { | - | ||||||||||||||||||
| 2484 | #ifdef Q_COMPILER_UNICODE_STRINGS | - | ||||||||||||||||||
| 2485 | // ARCH_FULL is a concatenation of strings (incl. ARCH_PROCESSOR), which breaks | - | ||||||||||||||||||
| 2486 | // QStringLiteral on MSVC. Since the concatenation behavior we want is specified | - | ||||||||||||||||||
| 2487 | // the same C++11 paper as the Unicode strings, we'll use that macro and hope | - | ||||||||||||||||||
| 2488 | // that Microsoft implements the new behavior when they add support for Unicode strings. | - | ||||||||||||||||||
| 2489 | return QStringLiteral(ARCH_FULL); executed 1 time by 1 test: return ([]() -> QString { enum { Size = sizeof(u"" "x86_64" "-" "little_endian" "-" "lp64" "" "" "")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "x86_64" "-" "little_endian" "-" "lp64" "" "" "" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());Executed by:
executed 1 time by 1 test: return qstring_literal_temp;Executed by:
| 1 | ||||||||||||||||||
| 2490 | #else | - | ||||||||||||||||||
| 2491 | return QLatin1String(ARCH_FULL); | - | ||||||||||||||||||
| 2492 | #endif | - | ||||||||||||||||||
| 2493 | } | - | ||||||||||||||||||
| 2494 | - | |||||||||||||||||||
| 2495 | static QString unknownText() | - | ||||||||||||||||||
| 2496 | { | - | ||||||||||||||||||
| 2497 | return QStringLiteral("unknown"); never executed: return ([]() -> QString { enum { Size = sizeof(u"" "unknown")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "unknown" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 2498 | } | - | ||||||||||||||||||
| 2499 | - | |||||||||||||||||||
| 2500 | /*! | - | ||||||||||||||||||
| 2501 | \since 5.4 | - | ||||||||||||||||||
| 2502 | - | |||||||||||||||||||
| 2503 | Returns the type of the operating system kernel Qt was compiled for. It's | - | ||||||||||||||||||
| 2504 | also the kernel the application is running on, unless the host operating | - | ||||||||||||||||||
| 2505 | system is running a form of compatibility or virtualization layer. | - | ||||||||||||||||||
| 2506 | - | |||||||||||||||||||
| 2507 | Values returned by this function are stable and will not change over time, | - | ||||||||||||||||||
| 2508 | so applications can rely on the returned value as an identifier, except | - | ||||||||||||||||||
| 2509 | that new OS kernel types may be added over time. | - | ||||||||||||||||||
| 2510 | - | |||||||||||||||||||
| 2511 | On Windows, this function returns the type of Windows kernel, like "wince" | - | ||||||||||||||||||
| 2512 | or "winnt". On Unix systems, it returns the same as the output of \c{uname | - | ||||||||||||||||||
| 2513 | -s} (lowercased). | - | ||||||||||||||||||
| 2514 | - | |||||||||||||||||||
| 2515 | Note that this function may return surprising values: it returns "linux" | - | ||||||||||||||||||
| 2516 | for all operating systems running Linux (including Android), "qnx" for all | - | ||||||||||||||||||
| 2517 | operating systems running QNX (including BlackBerry 10), "freebsd" for | - | ||||||||||||||||||
| 2518 | Debian/kFreeBSD, and "darwin" for \macos and iOS. For information on the type | - | ||||||||||||||||||
| 2519 | of product the application is running on, see productType(). | - | ||||||||||||||||||
| 2520 | - | |||||||||||||||||||
| 2521 | \sa QFileSelector, kernelVersion(), productType(), productVersion(), prettyProductName() | - | ||||||||||||||||||
| 2522 | */ | - | ||||||||||||||||||
| 2523 | QString QSysInfo::kernelType() | - | ||||||||||||||||||
| 2524 | { | - | ||||||||||||||||||
| 2525 | #if defined(Q_OS_WINCE) | - | ||||||||||||||||||
| 2526 | return QStringLiteral("wince"); | - | ||||||||||||||||||
| 2527 | #elif defined(Q_OS_WIN) | - | ||||||||||||||||||
| 2528 | return QStringLiteral("winnt"); | - | ||||||||||||||||||
| 2529 | #elif defined(Q_OS_UNIX) | - | ||||||||||||||||||
| 2530 | struct utsname u; | - | ||||||||||||||||||
| 2531 | if (uname(&u) == 0)
| 0-3 | ||||||||||||||||||
| 2532 | return QString::fromLatin1(u.sysname).toLower(); executed 3 times by 2 tests: return QString::fromLatin1(u.sysname).toLower();Executed by:
| 3 | ||||||||||||||||||
| 2533 | #endif | - | ||||||||||||||||||
| 2534 | return unknownText(); never executed: return unknownText(); | 0 | ||||||||||||||||||
| 2535 | } | - | ||||||||||||||||||
| 2536 | - | |||||||||||||||||||
| 2537 | /*! | - | ||||||||||||||||||
| 2538 | \since 5.4 | - | ||||||||||||||||||
| 2539 | - | |||||||||||||||||||
| 2540 | Returns the release version of the operating system kernel. On Windows, it | - | ||||||||||||||||||
| 2541 | returns the version of the NT or CE kernel. On Unix systems, including | - | ||||||||||||||||||
| 2542 | Android, BlackBerry and \macos, it returns the same as the \c{uname -r} | - | ||||||||||||||||||
| 2543 | command would return. | - | ||||||||||||||||||
| 2544 | - | |||||||||||||||||||
| 2545 | If the version could not be determined, this function may return an empty | - | ||||||||||||||||||
| 2546 | string. | - | ||||||||||||||||||
| 2547 | - | |||||||||||||||||||
| 2548 | \sa kernelType(), productType(), productVersion(), prettyProductName() | - | ||||||||||||||||||
| 2549 | */ | - | ||||||||||||||||||
| 2550 | QString QSysInfo::kernelVersion() | - | ||||||||||||||||||
| 2551 | { | - | ||||||||||||||||||
| 2552 | #ifdef Q_OS_WIN | - | ||||||||||||||||||
| 2553 | const OSVERSIONINFO osver = winOsVersion(); | - | ||||||||||||||||||
| 2554 | return QString::number(int(osver.dwMajorVersion)) + QLatin1Char('.') + QString::number(int(osver.dwMinorVersion)) | - | ||||||||||||||||||
| 2555 | + QLatin1Char('.') + QString::number(int(osver.dwBuildNumber)); | - | ||||||||||||||||||
| 2556 | #else | - | ||||||||||||||||||
| 2557 | struct utsname u; | - | ||||||||||||||||||
| 2558 | if (uname(&u) == 0)
| 0-1 | ||||||||||||||||||
| 2559 | return QString::fromLatin1(u.release); executed 1 time by 1 test: return QString::fromLatin1(u.release);Executed by:
| 1 | ||||||||||||||||||
| 2560 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||
| 2561 | #endif | - | ||||||||||||||||||
| 2562 | } | - | ||||||||||||||||||
| 2563 | - | |||||||||||||||||||
| 2564 | - | |||||||||||||||||||
| 2565 | /*! | - | ||||||||||||||||||
| 2566 | \since 5.4 | - | ||||||||||||||||||
| 2567 | - | |||||||||||||||||||
| 2568 | Returns the product name of the operating system this application is | - | ||||||||||||||||||
| 2569 | running in. If the application is running on some sort of emulation or | - | ||||||||||||||||||
| 2570 | virtualization layer (such as WINE on a Unix system), this function will | - | ||||||||||||||||||
| 2571 | inspect the emulation / virtualization layer. | - | ||||||||||||||||||
| 2572 | - | |||||||||||||||||||
| 2573 | Values returned by this function are stable and will not change over time, | - | ||||||||||||||||||
| 2574 | so applications can rely on the returned value as an identifier, except | - | ||||||||||||||||||
| 2575 | that new OS types may be added over time. | - | ||||||||||||||||||
| 2576 | - | |||||||||||||||||||
| 2577 | \b{Linux and Android note}: this function returns "android" for Linux | - | ||||||||||||||||||
| 2578 | systems running Android userspace, notably when using the Bionic library. | - | ||||||||||||||||||
| 2579 | For all other Linux systems, regardless of C library being used, it tries | - | ||||||||||||||||||
| 2580 | to determine the distribution name and returns that. If determining the | - | ||||||||||||||||||
| 2581 | distribution name failed, it returns "unknown". | - | ||||||||||||||||||
| 2582 | - | |||||||||||||||||||
| 2583 | \b{BlackBerry note}: this function returns "blackberry" for QNX systems | - | ||||||||||||||||||
| 2584 | running the BlackBerry userspace, but "qnx" for all other QNX-based | - | ||||||||||||||||||
| 2585 | systems. | - | ||||||||||||||||||
| 2586 | - | |||||||||||||||||||
| 2587 | \b{Darwin, \macos and iOS note}: this function returns "macos" for \macos | - | ||||||||||||||||||
| 2588 | systems, "ios" for iOS systems and "darwin" in case the system could not be | - | ||||||||||||||||||
| 2589 | determined. | - | ||||||||||||||||||
| 2590 | - | |||||||||||||||||||
| 2591 | \b{OS X note}: this function returns "osx" for versions of \macos prior to 10.12. | - | ||||||||||||||||||
| 2592 | - | |||||||||||||||||||
| 2593 | \b{FreeBSD note}: this function returns "debian" for Debian/kFreeBSD and | - | ||||||||||||||||||
| 2594 | "unknown" otherwise. | - | ||||||||||||||||||
| 2595 | - | |||||||||||||||||||
| 2596 | \b{Windows note}: this function returns "winphone" for builds for Windows | - | ||||||||||||||||||
| 2597 | Phone, "winrt" for WinRT builds, "wince" for Windows CE and Embedded | - | ||||||||||||||||||
| 2598 | Compact builds, and "windows" for normal desktop builds. | - | ||||||||||||||||||
| 2599 | - | |||||||||||||||||||
| 2600 | For other Unix-type systems, this function usually returns "unknown". | - | ||||||||||||||||||
| 2601 | - | |||||||||||||||||||
| 2602 | \sa QFileSelector, kernelType(), kernelVersion(), productVersion(), prettyProductName() | - | ||||||||||||||||||
| 2603 | */ | - | ||||||||||||||||||
| 2604 | QString QSysInfo::productType() | - | ||||||||||||||||||
| 2605 | { | - | ||||||||||||||||||
| 2606 | // similar, but not identical to QFileSelectorPrivate::platformSelectors | - | ||||||||||||||||||
| 2607 | #if defined(Q_OS_WINPHONE) | - | ||||||||||||||||||
| 2608 | return QStringLiteral("winphone"); | - | ||||||||||||||||||
| 2609 | #elif defined(Q_OS_WINRT) | - | ||||||||||||||||||
| 2610 | return QStringLiteral("winrt"); | - | ||||||||||||||||||
| 2611 | #elif defined(Q_OS_WINCE) | - | ||||||||||||||||||
| 2612 | return QStringLiteral("wince"); | - | ||||||||||||||||||
| 2613 | #elif defined(Q_OS_WIN) | - | ||||||||||||||||||
| 2614 | return QStringLiteral("windows"); | - | ||||||||||||||||||
| 2615 | - | |||||||||||||||||||
| 2616 | #elif defined(Q_OS_BLACKBERRY) | - | ||||||||||||||||||
| 2617 | return QStringLiteral("blackberry"); | - | ||||||||||||||||||
| 2618 | #elif defined(Q_OS_QNX) | - | ||||||||||||||||||
| 2619 | return QStringLiteral("qnx"); | - | ||||||||||||||||||
| 2620 | - | |||||||||||||||||||
| 2621 | #elif defined(Q_OS_ANDROID) | - | ||||||||||||||||||
| 2622 | return QStringLiteral("android"); | - | ||||||||||||||||||
| 2623 | - | |||||||||||||||||||
| 2624 | #elif defined(Q_OS_IOS) | - | ||||||||||||||||||
| 2625 | return QStringLiteral("ios"); | - | ||||||||||||||||||
| 2626 | #elif defined(Q_OS_MACOS) | - | ||||||||||||||||||
| 2627 | const QAppleOperatingSystemVersion version = qt_apple_os_version(); | - | ||||||||||||||||||
| 2628 | if (version.major == 10 && version.minor < 12) | - | ||||||||||||||||||
| 2629 | return QStringLiteral("osx"); | - | ||||||||||||||||||
| 2630 | return QStringLiteral("macos"); | - | ||||||||||||||||||
| 2631 | #elif defined(Q_OS_DARWIN) | - | ||||||||||||||||||
| 2632 | return QStringLiteral("darwin"); | - | ||||||||||||||||||
| 2633 | - | |||||||||||||||||||
| 2634 | #elif defined(USE_ETC_OS_RELEASE) // Q_OS_UNIX | - | ||||||||||||||||||
| 2635 | QUnixOSVersion unixOsVersion; | - | ||||||||||||||||||
| 2636 | findUnixOsVersion(unixOsVersion); | - | ||||||||||||||||||
| 2637 | if (!unixOsVersion.productType.isEmpty())
| 0-6 | ||||||||||||||||||
| 2638 | return unixOsVersion.productType; executed 6 times by 3 tests: return unixOsVersion.productType;Executed by:
| 6 | ||||||||||||||||||
| 2639 | #endif | - | ||||||||||||||||||
| 2640 | return unknownText(); never executed: return unknownText(); | 0 | ||||||||||||||||||
| 2641 | } | - | ||||||||||||||||||
| 2642 | - | |||||||||||||||||||
| 2643 | /*! | - | ||||||||||||||||||
| 2644 | \since 5.4 | - | ||||||||||||||||||
| 2645 | - | |||||||||||||||||||
| 2646 | Returns the product version of the operating system in string form. If the | - | ||||||||||||||||||
| 2647 | version could not be determined, this function returns "unknown". | - | ||||||||||||||||||
| 2648 | - | |||||||||||||||||||
| 2649 | It will return the Android, BlackBerry, iOS, \macos, Windows full-product | - | ||||||||||||||||||
| 2650 | versions on those systems. In particular, on \macos, iOS and Windows, the | - | ||||||||||||||||||
| 2651 | returned string is similar to the macVersion() or windowsVersion() enums. | - | ||||||||||||||||||
| 2652 | - | |||||||||||||||||||
| 2653 | On Linux systems, it will try to determine the distribution version and will | - | ||||||||||||||||||
| 2654 | return that. This is also done on Debian/kFreeBSD, so this function will | - | ||||||||||||||||||
| 2655 | return Debian version in that case. | - | ||||||||||||||||||
| 2656 | - | |||||||||||||||||||
| 2657 | In all other Unix-type systems, this function always returns "unknown". | - | ||||||||||||||||||
| 2658 | - | |||||||||||||||||||
| 2659 | \note The version string returned from this function is only guaranteed to | - | ||||||||||||||||||
| 2660 | be orderable on Android, BlackBerry, \macos and iOS. On Windows, some Windows | - | ||||||||||||||||||
| 2661 | versions are text ("XP" and "Vista", for example). On Linux, the version of | - | ||||||||||||||||||
| 2662 | the distribution may jump unexpectedly, please refer to the distribution's | - | ||||||||||||||||||
| 2663 | documentation for versioning practices. | - | ||||||||||||||||||
| 2664 | - | |||||||||||||||||||
| 2665 | \sa kernelType(), kernelVersion(), productType(), prettyProductName() | - | ||||||||||||||||||
| 2666 | */ | - | ||||||||||||||||||
| 2667 | QString QSysInfo::productVersion() | - | ||||||||||||||||||
| 2668 | { | - | ||||||||||||||||||
| 2669 | #if defined(Q_OS_MAC) | - | ||||||||||||||||||
| 2670 | const QAppleOperatingSystemVersion version = qt_apple_os_version(); | - | ||||||||||||||||||
| 2671 | return QString::number(version.major) + QLatin1Char('.') + QString::number(version.minor); | - | ||||||||||||||||||
| 2672 | #elif defined(Q_OS_WIN) | - | ||||||||||||||||||
| 2673 | const char *version = winVer_helper(); | - | ||||||||||||||||||
| 2674 | if (version) | - | ||||||||||||||||||
| 2675 | return QString::fromLatin1(version).toLower(); | - | ||||||||||||||||||
| 2676 | // fall through | - | ||||||||||||||||||
| 2677 | - | |||||||||||||||||||
| 2678 | // Android and Blackberry should not fall through to the Unix code | - | ||||||||||||||||||
| 2679 | #elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) | - | ||||||||||||||||||
| 2680 | return QJNIObjectPrivate::getStaticObjectField("android/os/Build$VERSION", "RELEASE", "Ljava/lang/String;").toString(); | - | ||||||||||||||||||
| 2681 | #elif defined(Q_OS_ANDROID) // Q_OS_ANDROID_NO_SDK | - | ||||||||||||||||||
| 2682 | // TBD | - | ||||||||||||||||||
| 2683 | #elif defined(Q_OS_BLACKBERRY) | - | ||||||||||||||||||
| 2684 | deviceinfo_details_t *deviceInfo; | - | ||||||||||||||||||
| 2685 | if (deviceinfo_get_details(&deviceInfo) == BPS_SUCCESS) { | - | ||||||||||||||||||
| 2686 | QString bbVersion = QString::fromLatin1(deviceinfo_details_get_device_os_version(deviceInfo)); | - | ||||||||||||||||||
| 2687 | deviceinfo_free_details(&deviceInfo); | - | ||||||||||||||||||
| 2688 | return bbVersion; | - | ||||||||||||||||||
| 2689 | } | - | ||||||||||||||||||
| 2690 | #elif defined(USE_ETC_OS_RELEASE) // Q_OS_UNIX | - | ||||||||||||||||||
| 2691 | QUnixOSVersion unixOsVersion; | - | ||||||||||||||||||
| 2692 | findUnixOsVersion(unixOsVersion); | - | ||||||||||||||||||
| 2693 | if (!unixOsVersion.productVersion.isEmpty())
| 0-2 | ||||||||||||||||||
| 2694 | return unixOsVersion.productVersion; executed 2 times by 1 test: return unixOsVersion.productVersion;Executed by:
| 2 | ||||||||||||||||||
| 2695 | #endif | - | ||||||||||||||||||
| 2696 | - | |||||||||||||||||||
| 2697 | // fallback | - | ||||||||||||||||||
| 2698 | return unknownText(); never executed: return unknownText(); | 0 | ||||||||||||||||||
| 2699 | } | - | ||||||||||||||||||
| 2700 | - | |||||||||||||||||||
| 2701 | /*! | - | ||||||||||||||||||
| 2702 | \since 5.4 | - | ||||||||||||||||||
| 2703 | - | |||||||||||||||||||
| 2704 | Returns a prettier form of productType() and productVersion(), containing | - | ||||||||||||||||||
| 2705 | other tokens like the operating system type, codenames and other | - | ||||||||||||||||||
| 2706 | information. The result of this function is suitable for displaying to the | - | ||||||||||||||||||
| 2707 | user, but not for long-term storage, as the string may change with updates | - | ||||||||||||||||||
| 2708 | to Qt. | - | ||||||||||||||||||
| 2709 | - | |||||||||||||||||||
| 2710 | If productType() is "unknown", this function will instead use the | - | ||||||||||||||||||
| 2711 | kernelType() and kernelVersion() functions. | - | ||||||||||||||||||
| 2712 | - | |||||||||||||||||||
| 2713 | \sa kernelType(), kernelVersion(), productType(), productVersion() | - | ||||||||||||||||||
| 2714 | */ | - | ||||||||||||||||||
| 2715 | QString QSysInfo::prettyProductName() | - | ||||||||||||||||||
| 2716 | { | - | ||||||||||||||||||
| 2717 | #if defined(Q_OS_IOS) | - | ||||||||||||||||||
| 2718 | return QLatin1String("iOS ") + productVersion(); | - | ||||||||||||||||||
| 2719 | #elif defined(Q_OS_MACOS) | - | ||||||||||||||||||
| 2720 | // get the known codenames | - | ||||||||||||||||||
| 2721 | const char *basename = 0; | - | ||||||||||||||||||
| 2722 | switch (int(MacintoshVersion)) { | - | ||||||||||||||||||
| 2723 | case MV_CHEETAH: | - | ||||||||||||||||||
| 2724 | case MV_PUMA: | - | ||||||||||||||||||
| 2725 | case MV_JAGUAR: | - | ||||||||||||||||||
| 2726 | case MV_PANTHER: | - | ||||||||||||||||||
| 2727 | case MV_TIGER: | - | ||||||||||||||||||
| 2728 | // This version of Qt does not run on those versions of OS X | - | ||||||||||||||||||
| 2729 | // so this case label will never be reached | - | ||||||||||||||||||
| 2730 | Q_UNREACHABLE(); | - | ||||||||||||||||||
| 2731 | break; | - | ||||||||||||||||||
| 2732 | case MV_LEOPARD: | - | ||||||||||||||||||
| 2733 | basename = "Mac OS X Leopard ("; | - | ||||||||||||||||||
| 2734 | break; | - | ||||||||||||||||||
| 2735 | case MV_SNOWLEOPARD: | - | ||||||||||||||||||
| 2736 | basename = "Mac OS X Snow Leopard ("; | - | ||||||||||||||||||
| 2737 | break; | - | ||||||||||||||||||
| 2738 | case MV_LION: | - | ||||||||||||||||||
| 2739 | basename = "OS X Lion ("; | - | ||||||||||||||||||
| 2740 | break; | - | ||||||||||||||||||
| 2741 | case MV_MOUNTAINLION: | - | ||||||||||||||||||
| 2742 | basename = "OS X Mountain Lion ("; | - | ||||||||||||||||||
| 2743 | break; | - | ||||||||||||||||||
| 2744 | case MV_MAVERICKS: | - | ||||||||||||||||||
| 2745 | basename = "OS X Mavericks ("; | - | ||||||||||||||||||
| 2746 | break; | - | ||||||||||||||||||
| 2747 | case MV_YOSEMITE: | - | ||||||||||||||||||
| 2748 | basename = "OS X Yosemite ("; | - | ||||||||||||||||||
| 2749 | break; | - | ||||||||||||||||||
| 2750 | case MV_ELCAPITAN: | - | ||||||||||||||||||
| 2751 | basename = "OS X El Capitan ("; | - | ||||||||||||||||||
| 2752 | break; | - | ||||||||||||||||||
| 2753 | case MV_SIERRA: | - | ||||||||||||||||||
| 2754 | basename = "macOS Sierra ("; | - | ||||||||||||||||||
| 2755 | break; | - | ||||||||||||||||||
| 2756 | } | - | ||||||||||||||||||
| 2757 | if (basename) | - | ||||||||||||||||||
| 2758 | return QLatin1String(basename) + productVersion() + QLatin1Char(')'); | - | ||||||||||||||||||
| 2759 | - | |||||||||||||||||||
| 2760 | // a future version of macOS | - | ||||||||||||||||||
| 2761 | return QLatin1String("macOS ") + productVersion(); | - | ||||||||||||||||||
| 2762 | #elif defined(Q_OS_WINPHONE) | - | ||||||||||||||||||
| 2763 | return QLatin1String("Windows Phone ") + QLatin1String(winVer_helper()); | - | ||||||||||||||||||
| 2764 | #elif defined(Q_OS_WIN) | - | ||||||||||||||||||
| 2765 | return QLatin1String("Windows ") + QLatin1String(winVer_helper()); | - | ||||||||||||||||||
| 2766 | #elif defined(Q_OS_ANDROID) | - | ||||||||||||||||||
| 2767 | return QLatin1String("Android ") + productVersion(); | - | ||||||||||||||||||
| 2768 | #elif defined(Q_OS_BLACKBERRY) | - | ||||||||||||||||||
| 2769 | return QLatin1String("BlackBerry ") + productVersion(); | - | ||||||||||||||||||
| 2770 | #elif defined(Q_OS_HAIKU) | - | ||||||||||||||||||
| 2771 | return QLatin1String("Haiku ") + productVersion(); | - | ||||||||||||||||||
| 2772 | #elif defined(Q_OS_UNIX) | - | ||||||||||||||||||
| 2773 | # ifdef USE_ETC_OS_RELEASE | - | ||||||||||||||||||
| 2774 | QUnixOSVersion unixOsVersion; | - | ||||||||||||||||||
| 2775 | findUnixOsVersion(unixOsVersion); | - | ||||||||||||||||||
| 2776 | if (!unixOsVersion.prettyName.isEmpty())
| 0-1 | ||||||||||||||||||
| 2777 | return unixOsVersion.prettyName; executed 1 time by 1 test: return unixOsVersion.prettyName;Executed by:
| 1 | ||||||||||||||||||
| 2778 | # endif | - | ||||||||||||||||||
| 2779 | struct utsname u; | - | ||||||||||||||||||
| 2780 | if (uname(&u) == 0)
| 0 | ||||||||||||||||||
| 2781 | return QString::fromLatin1(u.sysname) + QLatin1Char(' ') + QString::fromLatin1(u.release); never executed: return QString::fromLatin1(u.sysname) + QLatin1Char(' ') + QString::fromLatin1(u.release); | 0 | ||||||||||||||||||
| 2782 | #endif | - | ||||||||||||||||||
| 2783 | return unknownText(); never executed: return unknownText(); | 0 | ||||||||||||||||||
| 2784 | } | - | ||||||||||||||||||
| 2785 | - | |||||||||||||||||||
| 2786 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||
| 2787 | /*! | - | ||||||||||||||||||
| 2788 | \since 5.6 | - | ||||||||||||||||||
| 2789 | - | |||||||||||||||||||
| 2790 | Returns this machine's host name, if one is configured. Note that hostnames | - | ||||||||||||||||||
| 2791 | are not guaranteed to be globally unique, especially if they were | - | ||||||||||||||||||
| 2792 | configured automatically. | - | ||||||||||||||||||
| 2793 | - | |||||||||||||||||||
| 2794 | This function does not guarantee the returned host name is a Fully | - | ||||||||||||||||||
| 2795 | Qualified Domain Name (FQDN). For that, use QHostInfo to resolve the | - | ||||||||||||||||||
| 2796 | returned name to an FQDN. | - | ||||||||||||||||||
| 2797 | - | |||||||||||||||||||
| 2798 | This function returns the same as QHostInfo::localHostName(). | - | ||||||||||||||||||
| 2799 | - | |||||||||||||||||||
| 2800 | \sa QHostInfo::localDomainName | - | ||||||||||||||||||
| 2801 | */ | - | ||||||||||||||||||
| 2802 | QString QSysInfo::machineHostName() | - | ||||||||||||||||||
| 2803 | { | - | ||||||||||||||||||
| 2804 | #if defined(Q_OS_LINUX) | - | ||||||||||||||||||
| 2805 | // gethostname(3) on Linux just calls uname(2), so do it ourselves | - | ||||||||||||||||||
| 2806 | // and avoid a memcpy | - | ||||||||||||||||||
| 2807 | struct utsname u; | - | ||||||||||||||||||
| 2808 | if (uname(&u) == 0)
| 0-3 | ||||||||||||||||||
| 2809 | return QString::fromLocal8Bit(u.nodename); executed 3 times by 2 tests: return QString::fromLocal8Bit(u.nodename);Executed by:
| 3 | ||||||||||||||||||
| 2810 | #else | - | ||||||||||||||||||
| 2811 | # ifdef Q_OS_WIN | - | ||||||||||||||||||
| 2812 | // Important: QtNetwork depends on machineHostName() initializing ws2_32.dll | - | ||||||||||||||||||
| 2813 | winsockInit(); | - | ||||||||||||||||||
| 2814 | # endif | - | ||||||||||||||||||
| 2815 | - | |||||||||||||||||||
| 2816 | char hostName[512]; | - | ||||||||||||||||||
| 2817 | if (gethostname(hostName, sizeof(hostName)) == -1) | - | ||||||||||||||||||
| 2818 | return QString(); | - | ||||||||||||||||||
| 2819 | hostName[sizeof(hostName) - 1] = '\0'; | - | ||||||||||||||||||
| 2820 | return QString::fromLocal8Bit(hostName); | - | ||||||||||||||||||
| 2821 | #endif | - | ||||||||||||||||||
| 2822 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||
| 2823 | } | - | ||||||||||||||||||
| 2824 | #endif // QT_BOOTSTRAPPED | - | ||||||||||||||||||
| 2825 | - | |||||||||||||||||||
| 2826 | /*! | - | ||||||||||||||||||
| 2827 | \macro void Q_ASSERT(bool test) | - | ||||||||||||||||||
| 2828 | \relates <QtGlobal> | - | ||||||||||||||||||
| 2829 | - | |||||||||||||||||||
| 2830 | Prints a warning message containing the source code file name and | - | ||||||||||||||||||
| 2831 | line number if \a test is \c false. | - | ||||||||||||||||||
| 2832 | - | |||||||||||||||||||
| 2833 | Q_ASSERT() is useful for testing pre- and post-conditions | - | ||||||||||||||||||
| 2834 | during development. It does nothing if \c QT_NO_DEBUG was defined | - | ||||||||||||||||||
| 2835 | during compilation. | - | ||||||||||||||||||
| 2836 | - | |||||||||||||||||||
| 2837 | Example: | - | ||||||||||||||||||
| 2838 | - | |||||||||||||||||||
| 2839 | \snippet code/src_corelib_global_qglobal.cpp 17 | - | ||||||||||||||||||
| 2840 | - | |||||||||||||||||||
| 2841 | If \c b is zero, the Q_ASSERT statement will output the following | - | ||||||||||||||||||
| 2842 | message using the qFatal() function: | - | ||||||||||||||||||
| 2843 | - | |||||||||||||||||||
| 2844 | \snippet code/src_corelib_global_qglobal.cpp 18 | - | ||||||||||||||||||
| 2845 | - | |||||||||||||||||||
| 2846 | \sa Q_ASSERT_X(), qFatal(), {Debugging Techniques} | - | ||||||||||||||||||
| 2847 | */ | - | ||||||||||||||||||
| 2848 | - | |||||||||||||||||||
| 2849 | /*! | - | ||||||||||||||||||
| 2850 | \macro void Q_ASSERT_X(bool test, const char *where, const char *what) | - | ||||||||||||||||||
| 2851 | \relates <QtGlobal> | - | ||||||||||||||||||
| 2852 | - | |||||||||||||||||||
| 2853 | Prints the message \a what together with the location \a where, | - | ||||||||||||||||||
| 2854 | the source file name and line number if \a test is \c false. | - | ||||||||||||||||||
| 2855 | - | |||||||||||||||||||
| 2856 | Q_ASSERT_X is useful for testing pre- and post-conditions during | - | ||||||||||||||||||
| 2857 | development. It does nothing if \c QT_NO_DEBUG was defined during | - | ||||||||||||||||||
| 2858 | compilation. | - | ||||||||||||||||||
| 2859 | - | |||||||||||||||||||
| 2860 | Example: | - | ||||||||||||||||||
| 2861 | - | |||||||||||||||||||
| 2862 | \snippet code/src_corelib_global_qglobal.cpp 19 | - | ||||||||||||||||||
| 2863 | - | |||||||||||||||||||
| 2864 | If \c b is zero, the Q_ASSERT_X statement will output the following | - | ||||||||||||||||||
| 2865 | message using the qFatal() function: | - | ||||||||||||||||||
| 2866 | - | |||||||||||||||||||
| 2867 | \snippet code/src_corelib_global_qglobal.cpp 20 | - | ||||||||||||||||||
| 2868 | - | |||||||||||||||||||
| 2869 | \sa Q_ASSERT(), qFatal(), {Debugging Techniques} | - | ||||||||||||||||||
| 2870 | */ | - | ||||||||||||||||||
| 2871 | - | |||||||||||||||||||
| 2872 | /*! | - | ||||||||||||||||||
| 2873 | \macro void Q_ASSUME(bool expr) | - | ||||||||||||||||||
| 2874 | \relates <QtGlobal> | - | ||||||||||||||||||
| 2875 | \since 5.0 | - | ||||||||||||||||||
| 2876 | - | |||||||||||||||||||
| 2877 | Causes the compiler to assume that \a expr is \c true. This macro is useful | - | ||||||||||||||||||
| 2878 | for improving code generation, by providing the compiler with hints about | - | ||||||||||||||||||
| 2879 | conditions that it would not otherwise know about. However, there is no | - | ||||||||||||||||||
| 2880 | guarantee that the compiler will actually use those hints. | - | ||||||||||||||||||
| 2881 | - | |||||||||||||||||||
| 2882 | This macro could be considered a "lighter" version of \l{Q_ASSERT()}. While | - | ||||||||||||||||||
| 2883 | Q_ASSERT will abort the program's execution if the condition is \c false, | - | ||||||||||||||||||
| 2884 | Q_ASSUME will tell the compiler not to generate code for those conditions. | - | ||||||||||||||||||
| 2885 | Therefore, it is important that the assumptions always hold, otherwise | - | ||||||||||||||||||
| 2886 | undefined behaviour may occur. | - | ||||||||||||||||||
| 2887 | - | |||||||||||||||||||
| 2888 | If \a expr is a constantly \c false condition, Q_ASSUME will tell the compiler | - | ||||||||||||||||||
| 2889 | that the current code execution cannot be reached. That is, Q_ASSUME(false) | - | ||||||||||||||||||
| 2890 | is equivalent to Q_UNREACHABLE(). | - | ||||||||||||||||||
| 2891 | - | |||||||||||||||||||
| 2892 | In debug builds the condition is enforced by an assert to facilitate debugging. | - | ||||||||||||||||||
| 2893 | - | |||||||||||||||||||
| 2894 | \note Q_LIKELY() tells the compiler that the expression is likely, but not | - | ||||||||||||||||||
| 2895 | the only possibility. Q_ASSUME tells the compiler that it is the only | - | ||||||||||||||||||
| 2896 | possibility. | - | ||||||||||||||||||
| 2897 | - | |||||||||||||||||||
| 2898 | \sa Q_ASSERT(), Q_UNREACHABLE(), Q_LIKELY() | - | ||||||||||||||||||
| 2899 | */ | - | ||||||||||||||||||
| 2900 | - | |||||||||||||||||||
| 2901 | /*! | - | ||||||||||||||||||
| 2902 | \macro void Q_UNREACHABLE() | - | ||||||||||||||||||
| 2903 | \relates <QtGlobal> | - | ||||||||||||||||||
| 2904 | \since 5.0 | - | ||||||||||||||||||
| 2905 | - | |||||||||||||||||||
| 2906 | Tells the compiler that the current point cannot be reached by any | - | ||||||||||||||||||
| 2907 | execution, so it may optimize any code paths leading here as dead code, as | - | ||||||||||||||||||
| 2908 | well as code continuing from here. | - | ||||||||||||||||||
| 2909 | - | |||||||||||||||||||
| 2910 | This macro is useful to mark impossible conditions. For example, given the | - | ||||||||||||||||||
| 2911 | following enum: | - | ||||||||||||||||||
| 2912 | - | |||||||||||||||||||
| 2913 | \snippet code/src_corelib_global_qglobal.cpp qunreachable-enum | - | ||||||||||||||||||
| 2914 | - | |||||||||||||||||||
| 2915 | One can write a switch table like so: | - | ||||||||||||||||||
| 2916 | - | |||||||||||||||||||
| 2917 | \snippet code/src_corelib_global_qglobal.cpp qunreachable-switch | - | ||||||||||||||||||
| 2918 | - | |||||||||||||||||||
| 2919 | The advantage of inserting Q_UNREACHABLE() at that point is that the | - | ||||||||||||||||||
| 2920 | compiler is told not to generate code for a shape variable containing that | - | ||||||||||||||||||
| 2921 | value. If the macro is missing, the compiler will still generate the | - | ||||||||||||||||||
| 2922 | necessary comparisons for that value. If the case label were removed, some | - | ||||||||||||||||||
| 2923 | compilers could produce a warning that some enum values were not checked. | - | ||||||||||||||||||
| 2924 | - | |||||||||||||||||||
| 2925 | By using this macro in impossible conditions, code coverage may be improved | - | ||||||||||||||||||
| 2926 | as dead code paths may be eliminated. | - | ||||||||||||||||||
| 2927 | - | |||||||||||||||||||
| 2928 | In debug builds the condition is enforced by an assert to facilitate debugging. | - | ||||||||||||||||||
| 2929 | - | |||||||||||||||||||
| 2930 | \sa Q_ASSERT(), Q_ASSUME(), qFatal() | - | ||||||||||||||||||
| 2931 | */ | - | ||||||||||||||||||
| 2932 | - | |||||||||||||||||||
| 2933 | /*! | - | ||||||||||||||||||
| 2934 | \macro void Q_CHECK_PTR(void *pointer) | - | ||||||||||||||||||
| 2935 | \relates <QtGlobal> | - | ||||||||||||||||||
| 2936 | - | |||||||||||||||||||
| 2937 | If \a pointer is 0, prints a message containing the source | - | ||||||||||||||||||
| 2938 | code's file name and line number, saying that the program ran out | - | ||||||||||||||||||
| 2939 | of memory and aborts program execution. It throws \c std::bad_alloc instead | - | ||||||||||||||||||
| 2940 | if exceptions are enabled. | - | ||||||||||||||||||
| 2941 | - | |||||||||||||||||||
| 2942 | Q_CHECK_PTR does nothing if \c QT_NO_DEBUG and \c QT_NO_EXCEPTIONS were | - | ||||||||||||||||||
| 2943 | defined during compilation. Therefore you must not use Q_CHECK_PTR to check | - | ||||||||||||||||||
| 2944 | for successful memory allocations because the check will be disabled in | - | ||||||||||||||||||
| 2945 | some cases. | - | ||||||||||||||||||
| 2946 | - | |||||||||||||||||||
| 2947 | Example: | - | ||||||||||||||||||
| 2948 | - | |||||||||||||||||||
| 2949 | \snippet code/src_corelib_global_qglobal.cpp 21 | - | ||||||||||||||||||
| 2950 | - | |||||||||||||||||||
| 2951 | \sa qWarning(), {Debugging Techniques} | - | ||||||||||||||||||
| 2952 | */ | - | ||||||||||||||||||
| 2953 | - | |||||||||||||||||||
| 2954 | /*! | - | ||||||||||||||||||
| 2955 | \fn T *q_check_ptr(T *pointer) | - | ||||||||||||||||||
| 2956 | \relates <QtGlobal> | - | ||||||||||||||||||
| 2957 | - | |||||||||||||||||||
| 2958 | Uses Q_CHECK_PTR on \a pointer, then returns \a pointer. | - | ||||||||||||||||||
| 2959 | - | |||||||||||||||||||
| 2960 | This can be used as an inline version of Q_CHECK_PTR. | - | ||||||||||||||||||
| 2961 | */ | - | ||||||||||||||||||
| 2962 | - | |||||||||||||||||||
| 2963 | /*! | - | ||||||||||||||||||
| 2964 | \macro const char* Q_FUNC_INFO() | - | ||||||||||||||||||
| 2965 | \relates <QtGlobal> | - | ||||||||||||||||||
| 2966 | - | |||||||||||||||||||
| 2967 | Expands to a string that describe the function the macro resides in. How this string looks | - | ||||||||||||||||||
| 2968 | more specifically is compiler dependent. With GNU GCC it is typically the function signature, | - | ||||||||||||||||||
| 2969 | while with other compilers it might be the line and column number. | - | ||||||||||||||||||
| 2970 | - | |||||||||||||||||||
| 2971 | Q_FUNC_INFO can be conveniently used with qDebug(). For example, this function: | - | ||||||||||||||||||
| 2972 | - | |||||||||||||||||||
| 2973 | \snippet code/src_corelib_global_qglobal.cpp 22 | - | ||||||||||||||||||
| 2974 | - | |||||||||||||||||||
| 2975 | when instantiated with the integer type, will with the GCC compiler produce: | - | ||||||||||||||||||
| 2976 | - | |||||||||||||||||||
| 2977 | \tt{const TInputType& myMin(const TInputType&, const TInputType&) [with TInputType = int] was called with value1: 3 value2: 4} | - | ||||||||||||||||||
| 2978 | - | |||||||||||||||||||
| 2979 | If this macro is used outside a function, the behavior is undefined. | - | ||||||||||||||||||
| 2980 | */ | - | ||||||||||||||||||
| 2981 | - | |||||||||||||||||||
| 2982 | /* | - | ||||||||||||||||||
| 2983 | The Q_CHECK_PTR macro calls this function if an allocation check | - | ||||||||||||||||||
| 2984 | fails. | - | ||||||||||||||||||
| 2985 | */ | - | ||||||||||||||||||
| 2986 | void qt_check_pointer(const char *n, int l) | - | ||||||||||||||||||
| 2987 | { | - | ||||||||||||||||||
| 2988 | qFatal("In file %s, line %d: Out of memory", n, l); | - | ||||||||||||||||||
| 2989 | } never executed: end of block | 0 | ||||||||||||||||||
| 2990 | - | |||||||||||||||||||
| 2991 | /* | - | ||||||||||||||||||
| 2992 | \internal | - | ||||||||||||||||||
| 2993 | Allows you to throw an exception without including <new> | - | ||||||||||||||||||
| 2994 | Called internally from Q_CHECK_PTR on certain OS combinations | - | ||||||||||||||||||
| 2995 | */ | - | ||||||||||||||||||
| 2996 | void qBadAlloc() | - | ||||||||||||||||||
| 2997 | { | - | ||||||||||||||||||
| 2998 | QT_THROW(std::bad_alloc()); never executed: throw std::bad_alloc(); | 0 | ||||||||||||||||||
| 2999 | } | - | ||||||||||||||||||
| 3000 | - | |||||||||||||||||||
| 3001 | #ifndef QT_NO_EXCEPTIONS | - | ||||||||||||||||||
| 3002 | /* | - | ||||||||||||||||||
| 3003 | \internal | - | ||||||||||||||||||
| 3004 | Allows you to call std::terminate() without including <exception>. | - | ||||||||||||||||||
| 3005 | Called internally from QT_TERMINATE_ON_EXCEPTION | - | ||||||||||||||||||
| 3006 | */ | - | ||||||||||||||||||
| 3007 | Q_NORETURN void qTerminate() Q_DECL_NOTHROW | - | ||||||||||||||||||
| 3008 | { | - | ||||||||||||||||||
| 3009 | std::terminate(); | - | ||||||||||||||||||
| 3010 | } never executed: end of block | 0 | ||||||||||||||||||
| 3011 | #endif | - | ||||||||||||||||||
| 3012 | - | |||||||||||||||||||
| 3013 | /* | - | ||||||||||||||||||
| 3014 | The Q_ASSERT macro calls this function when the test fails. | - | ||||||||||||||||||
| 3015 | */ | - | ||||||||||||||||||
| 3016 | void qt_assert(const char *assertion, const char *file, int line) Q_DECL_NOTHROW | - | ||||||||||||||||||
| 3017 | { | - | ||||||||||||||||||
| 3018 | qFatal("ASSERT: \"%s\" in file %s, line %d", assertion, file, line); | - | ||||||||||||||||||
| 3019 | } never executed: end of block | 0 | ||||||||||||||||||
| 3020 | - | |||||||||||||||||||
| 3021 | /* | - | ||||||||||||||||||
| 3022 | The Q_ASSERT_X macro calls this function when the test fails. | - | ||||||||||||||||||
| 3023 | */ | - | ||||||||||||||||||
| 3024 | void qt_assert_x(const char *where, const char *what, const char *file, int line) Q_DECL_NOTHROW | - | ||||||||||||||||||
| 3025 | { | - | ||||||||||||||||||
| 3026 | qFatal("ASSERT failure in %s: \"%s\", file %s, line %d", where, what, file, line); | - | ||||||||||||||||||
| 3027 | } never executed: end of block | 0 | ||||||||||||||||||
| 3028 | - | |||||||||||||||||||
| 3029 | - | |||||||||||||||||||
| 3030 | /* | - | ||||||||||||||||||
| 3031 | Dijkstra's bisection algorithm to find the square root of an integer. | - | ||||||||||||||||||
| 3032 | Deliberately not exported as part of the Qt API, but used in both | - | ||||||||||||||||||
| 3033 | qsimplerichtext.cpp and qgfxraster_qws.cpp | - | ||||||||||||||||||
| 3034 | */ | - | ||||||||||||||||||
| 3035 | Q_CORE_EXPORT unsigned int qt_int_sqrt(unsigned int n) | - | ||||||||||||||||||
| 3036 | { | - | ||||||||||||||||||
| 3037 | // n must be in the range 0...UINT_MAX/2-1 | - | ||||||||||||||||||
| 3038 | if (n >= (UINT_MAX>>2)) {
| 0-23 | ||||||||||||||||||
| 3039 | unsigned int r = 2 * qt_int_sqrt(n / 4); | - | ||||||||||||||||||
| 3040 | unsigned int r2 = r + 1; | - | ||||||||||||||||||
| 3041 | return (n >= r2 * r2) ? r2 : r; never executed: return (n >= r2 * r2) ? r2 : r;
| 0 | ||||||||||||||||||
| 3042 | } | - | ||||||||||||||||||
| 3043 | uint h, p= 0, q= 1, r= n; | - | ||||||||||||||||||
| 3044 | while (q <= n)
| 23-190 | ||||||||||||||||||
| 3045 | q <<= 2; executed 190 times by 4 tests: q <<= 2;Executed by:
| 190 | ||||||||||||||||||
| 3046 | while (q != 1) {
| 23-190 | ||||||||||||||||||
| 3047 | q >>= 2; | - | ||||||||||||||||||
| 3048 | h= p + q; | - | ||||||||||||||||||
| 3049 | p >>= 1; | - | ||||||||||||||||||
| 3050 | if (r >= h) {
| 82-108 | ||||||||||||||||||
| 3051 | p += q; | - | ||||||||||||||||||
| 3052 | r -= h; | - | ||||||||||||||||||
| 3053 | } executed 108 times by 4 tests: end of blockExecuted by:
| 108 | ||||||||||||||||||
| 3054 | } executed 190 times by 4 tests: end of blockExecuted by:
| 190 | ||||||||||||||||||
| 3055 | return p; executed 23 times by 4 tests: return p;Executed by:
| 23 | ||||||||||||||||||
| 3056 | } | - | ||||||||||||||||||
| 3057 | - | |||||||||||||||||||
| 3058 | void *qMemCopy(void *dest, const void *src, size_t n) { return memcpy(dest, src, n); } never executed: return memcpy(dest, src, n); | 0 | ||||||||||||||||||
| 3059 | void *qMemSet(void *dest, int c, size_t n) { return memset(dest, c, n); } never executed: return memset(dest, c, n); | 0 | ||||||||||||||||||
| 3060 | - | |||||||||||||||||||
| 3061 | #if !defined(Q_OS_WIN) && !defined(QT_NO_THREAD) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) && \ | - | ||||||||||||||||||
| 3062 | defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L | - | ||||||||||||||||||
| 3063 | namespace { | - | ||||||||||||||||||
| 3064 | // There are two incompatible versions of strerror_r: | - | ||||||||||||||||||
| 3065 | // a) the XSI/POSIX.1 version, which returns an int, | - | ||||||||||||||||||
| 3066 | // indicating success or not | - | ||||||||||||||||||
| 3067 | // b) the GNU version, which returns a char*, which may or may not | - | ||||||||||||||||||
| 3068 | // be the beginning of the buffer we used | - | ||||||||||||||||||
| 3069 | // The GNU libc manpage for strerror_r says you should use the XSI | - | ||||||||||||||||||
| 3070 | // version in portable code. However, it's impossible to do that if | - | ||||||||||||||||||
| 3071 | // _GNU_SOURCE is defined so we use C++ overloading to decide what to do | - | ||||||||||||||||||
| 3072 | // depending on the return type | - | ||||||||||||||||||
| 3073 | static inline Q_DECL_UNUSED QString fromstrerror_helper(int, const QByteArray &buf) | - | ||||||||||||||||||
| 3074 | { | - | ||||||||||||||||||
| 3075 | return QString::fromLocal8Bit(buf.constData()); never executed: return QString::fromLocal8Bit(buf.constData()); | 0 | ||||||||||||||||||
| 3076 | } | - | ||||||||||||||||||
| 3077 | static inline Q_DECL_UNUSED QString fromstrerror_helper(const char *str, const QByteArray &) | - | ||||||||||||||||||
| 3078 | { | - | ||||||||||||||||||
| 3079 | return QString::fromLocal8Bit(str); executed 17 times by 5 tests: return QString::fromLocal8Bit(str);Executed by:
| 17 | ||||||||||||||||||
| 3080 | } | - | ||||||||||||||||||
| 3081 | } | - | ||||||||||||||||||
| 3082 | #endif | - | ||||||||||||||||||
| 3083 | - | |||||||||||||||||||
| 3084 | QString qt_error_string(int errorCode) | - | ||||||||||||||||||
| 3085 | { | - | ||||||||||||||||||
| 3086 | const char *s = 0; | - | ||||||||||||||||||
| 3087 | QString ret; | - | ||||||||||||||||||
| 3088 | if (errorCode == -1) {
| 9-3501 | ||||||||||||||||||
| 3089 | #if defined(Q_OS_WIN) | - | ||||||||||||||||||
| 3090 | errorCode = GetLastError(); | - | ||||||||||||||||||
| 3091 | #else | - | ||||||||||||||||||
| 3092 | errorCode = errno; | - | ||||||||||||||||||
| 3093 | #endif | - | ||||||||||||||||||
| 3094 | } executed 9 times by 2 tests: end of blockExecuted by:
| 9 | ||||||||||||||||||
| 3095 | switch (errorCode) { | - | ||||||||||||||||||
| 3096 | case 0: never executed: case 0: | 0 | ||||||||||||||||||
| 3097 | break; never executed: break; | 0 | ||||||||||||||||||
| 3098 | case EACCES: executed 47 times by 7 tests: case 13:Executed by:
| 47 | ||||||||||||||||||
| 3099 | s = QT_TRANSLATE_NOOP("QIODevice", "Permission denied"); | - | ||||||||||||||||||
| 3100 | break; executed 47 times by 7 tests: break;Executed by:
| 47 | ||||||||||||||||||
| 3101 | case EMFILE: never executed: case 24: | 0 | ||||||||||||||||||
| 3102 | s = QT_TRANSLATE_NOOP("QIODevice", "Too many open files"); | - | ||||||||||||||||||
| 3103 | break; never executed: break; | 0 | ||||||||||||||||||
| 3104 | case ENOENT: executed 3440 times by 49 tests: case 2:Executed by:
| 3440 | ||||||||||||||||||
| 3105 | s = QT_TRANSLATE_NOOP("QIODevice", "No such file or directory"); | - | ||||||||||||||||||
| 3106 | break; executed 3440 times by 49 tests: break;Executed by:
| 3440 | ||||||||||||||||||
| 3107 | case ENOSPC: executed 6 times by 1 test: case 28:Executed by:
| 6 | ||||||||||||||||||
| 3108 | s = QT_TRANSLATE_NOOP("QIODevice", "No space left on device"); | - | ||||||||||||||||||
| 3109 | break; executed 6 times by 1 test: break;Executed by:
| 6 | ||||||||||||||||||
| 3110 | default: { executed 17 times by 5 tests: default:Executed by:
| 17 | ||||||||||||||||||
| 3111 | #if defined(Q_OS_WIN) | - | ||||||||||||||||||
| 3112 | // Retrieve the system error message for the last-error code. | - | ||||||||||||||||||
| 3113 | # ifndef Q_OS_WINRT | - | ||||||||||||||||||
| 3114 | wchar_t *string = 0; | - | ||||||||||||||||||
| 3115 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_ALLOCATE_BUFFER, | - | ||||||||||||||||||
| 3116 | NULL, | - | ||||||||||||||||||
| 3117 | errorCode, | - | ||||||||||||||||||
| 3118 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), | - | ||||||||||||||||||
| 3119 | (LPWSTR)&string, | - | ||||||||||||||||||
| 3120 | 0, | - | ||||||||||||||||||
| 3121 | NULL); | - | ||||||||||||||||||
| 3122 | ret = QString::fromWCharArray(string); | - | ||||||||||||||||||
| 3123 | LocalFree((HLOCAL)string); | - | ||||||||||||||||||
| 3124 | # else // !Q_OS_WINRT | - | ||||||||||||||||||
| 3125 | __declspec(thread) static wchar_t errorString[4096]; | - | ||||||||||||||||||
| 3126 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, | - | ||||||||||||||||||
| 3127 | NULL, | - | ||||||||||||||||||
| 3128 | errorCode, | - | ||||||||||||||||||
| 3129 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), | - | ||||||||||||||||||
| 3130 | errorString, | - | ||||||||||||||||||
| 3131 | ARRAYSIZE(errorString), | - | ||||||||||||||||||
| 3132 | NULL); | - | ||||||||||||||||||
| 3133 | ret = QString::fromWCharArray(errorString); | - | ||||||||||||||||||
| 3134 | # endif // Q_OS_WINRT | - | ||||||||||||||||||
| 3135 | - | |||||||||||||||||||
| 3136 | if (ret.isEmpty() && errorCode == ERROR_MOD_NOT_FOUND) | - | ||||||||||||||||||
| 3137 | ret = QString::fromLatin1("The specified module could not be found."); | - | ||||||||||||||||||
| 3138 | #elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) | - | ||||||||||||||||||
| 3139 | QByteArray buf(1024, '\0'); | - | ||||||||||||||||||
| 3140 | ret = fromstrerror_helper(strerror_r(errorCode, buf.data(), buf.size()), buf); | - | ||||||||||||||||||
| 3141 | #else | - | ||||||||||||||||||
| 3142 | ret = QString::fromLocal8Bit(strerror(errorCode)); | - | ||||||||||||||||||
| 3143 | #endif | - | ||||||||||||||||||
| 3144 | break; } executed 17 times by 5 tests: break;Executed by:
| 17 | ||||||||||||||||||
| 3145 | } | - | ||||||||||||||||||
| 3146 | if (s)
| 17-3493 | ||||||||||||||||||
| 3147 | // ######## this breaks moc build currently | - | ||||||||||||||||||
| 3148 | // ret = QCoreApplication::translate("QIODevice", s); | - | ||||||||||||||||||
| 3149 | ret = QString::fromLatin1(s); executed 3493 times by 51 tests: ret = QString::fromLatin1(s);Executed by:
| 3493 | ||||||||||||||||||
| 3150 | return ret.trimmed(); executed 3510 times by 52 tests: return ret.trimmed();Executed by:
| 3510 | ||||||||||||||||||
| 3151 | } | - | ||||||||||||||||||
| 3152 | - | |||||||||||||||||||
| 3153 | // In the C runtime on all platforms access to the environment is not thread-safe. We | - | ||||||||||||||||||
| 3154 | // add thread-safety for the Qt wrappers. | - | ||||||||||||||||||
| 3155 | static QBasicMutex environmentMutex; | - | ||||||||||||||||||
| 3156 | - | |||||||||||||||||||
| 3157 | // getenv is declared as deprecated in VS2005. This function | - | ||||||||||||||||||
| 3158 | // makes use of the new secure getenv function. | - | ||||||||||||||||||
| 3159 | /*! | - | ||||||||||||||||||
| 3160 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3161 | - | |||||||||||||||||||
| 3162 | Returns the value of the environment variable with name \a | - | ||||||||||||||||||
| 3163 | varName. To get the variable string, use QByteArray::constData(). | - | ||||||||||||||||||
| 3164 | - | |||||||||||||||||||
| 3165 | \note qgetenv() was introduced because getenv() from the standard | - | ||||||||||||||||||
| 3166 | C library was deprecated in VC2005 (and later versions). qgetenv() | - | ||||||||||||||||||
| 3167 | uses the new replacement function in VC, and calls the standard C | - | ||||||||||||||||||
| 3168 | library's implementation on all other platforms. | - | ||||||||||||||||||
| 3169 | - | |||||||||||||||||||
| 3170 | \sa qputenv(), qEnvironmentVariableIsSet(), qEnvironmentVariableIsEmpty() | - | ||||||||||||||||||
| 3171 | */ | - | ||||||||||||||||||
| 3172 | QByteArray qgetenv(const char *varName) | - | ||||||||||||||||||
| 3173 | { | - | ||||||||||||||||||
| 3174 | QMutexLocker locker(&environmentMutex); | - | ||||||||||||||||||
| 3175 | #if defined(_MSC_VER) && _MSC_VER >= 1400 | - | ||||||||||||||||||
| 3176 | size_t requiredSize = 0; | - | ||||||||||||||||||
| 3177 | QByteArray buffer; | - | ||||||||||||||||||
| 3178 | getenv_s(&requiredSize, 0, 0, varName); | - | ||||||||||||||||||
| 3179 | if (requiredSize == 0) | - | ||||||||||||||||||
| 3180 | return buffer; | - | ||||||||||||||||||
| 3181 | buffer.resize(int(requiredSize)); | - | ||||||||||||||||||
| 3182 | getenv_s(&requiredSize, buffer.data(), requiredSize, varName); | - | ||||||||||||||||||
| 3183 | // requiredSize includes the terminating null, which we don't want. | - | ||||||||||||||||||
| 3184 | Q_ASSERT(buffer.endsWith('\0')); | - | ||||||||||||||||||
| 3185 | buffer.chop(1); | - | ||||||||||||||||||
| 3186 | return buffer; | - | ||||||||||||||||||
| 3187 | #else | - | ||||||||||||||||||
| 3188 | return QByteArray(::getenv(varName)); executed 35135 times by 359 tests: return QByteArray(::getenv(varName));Executed by:
| 35135 | ||||||||||||||||||
| 3189 | #endif | - | ||||||||||||||||||
| 3190 | } | - | ||||||||||||||||||
| 3191 | - | |||||||||||||||||||
| 3192 | /*! | - | ||||||||||||||||||
| 3193 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3194 | \since 5.1 | - | ||||||||||||||||||
| 3195 | - | |||||||||||||||||||
| 3196 | Returns whether the environment variable \a varName is empty. | - | ||||||||||||||||||
| 3197 | - | |||||||||||||||||||
| 3198 | Equivalent to | - | ||||||||||||||||||
| 3199 | \code | - | ||||||||||||||||||
| 3200 | qgetenv(varName).isEmpty() | - | ||||||||||||||||||
| 3201 | \endcode | - | ||||||||||||||||||
| 3202 | except that it's potentially much faster, and can't throw exceptions. | - | ||||||||||||||||||
| 3203 | - | |||||||||||||||||||
| 3204 | \sa qgetenv(), qEnvironmentVariableIsSet() | - | ||||||||||||||||||
| 3205 | */ | - | ||||||||||||||||||
| 3206 | bool qEnvironmentVariableIsEmpty(const char *varName) Q_DECL_NOEXCEPT | - | ||||||||||||||||||
| 3207 | { | - | ||||||||||||||||||
| 3208 | QMutexLocker locker(&environmentMutex); | - | ||||||||||||||||||
| 3209 | #if defined(_MSC_VER) && _MSC_VER >= 1400 | - | ||||||||||||||||||
| 3210 | // we provide a buffer that can only hold the empty string, so | - | ||||||||||||||||||
| 3211 | // when the env.var isn't empty, we'll get an ERANGE error (buffer | - | ||||||||||||||||||
| 3212 | // too small): | - | ||||||||||||||||||
| 3213 | size_t dummy; | - | ||||||||||||||||||
| 3214 | char buffer = '\0'; | - | ||||||||||||||||||
| 3215 | return getenv_s(&dummy, &buffer, 1, varName) != ERANGE; | - | ||||||||||||||||||
| 3216 | #else | - | ||||||||||||||||||
| 3217 | const char * const value = ::getenv(varName); | - | ||||||||||||||||||
| 3218 | return !value || !*value; executed 1280194 times by 549 tests: return !value || !*value;Executed by:
| 1-1280194 | ||||||||||||||||||
| 3219 | #endif | - | ||||||||||||||||||
| 3220 | } | - | ||||||||||||||||||
| 3221 | - | |||||||||||||||||||
| 3222 | /*! | - | ||||||||||||||||||
| 3223 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3224 | \since 5.5 | - | ||||||||||||||||||
| 3225 | - | |||||||||||||||||||
| 3226 | Returns the numerical value of the environment variable \a varName. | - | ||||||||||||||||||
| 3227 | If \a ok is not null, sets \c{*ok} to \c true or \c false depending | - | ||||||||||||||||||
| 3228 | on the success of the conversion. | - | ||||||||||||||||||
| 3229 | - | |||||||||||||||||||
| 3230 | Equivalent to | - | ||||||||||||||||||
| 3231 | \code | - | ||||||||||||||||||
| 3232 | qgetenv(varName).toInt() | - | ||||||||||||||||||
| 3233 | \endcode | - | ||||||||||||||||||
| 3234 | except that it's much faster, and can't throw exceptions. | - | ||||||||||||||||||
| 3235 | - | |||||||||||||||||||
| 3236 | \sa qgetenv(), qEnvironmentVariableIsSet() | - | ||||||||||||||||||
| 3237 | */ | - | ||||||||||||||||||
| 3238 | int qEnvironmentVariableIntValue(const char *varName, bool *ok) Q_DECL_NOEXCEPT | - | ||||||||||||||||||
| 3239 | { | - | ||||||||||||||||||
| 3240 | QMutexLocker locker(&environmentMutex); | - | ||||||||||||||||||
| 3241 | #if defined(_MSC_VER) && _MSC_VER >= 1400 | - | ||||||||||||||||||
| 3242 | // we provide a buffer that can hold any int value: | - | ||||||||||||||||||
| 3243 | static const int NumBinaryDigitsPerOctalDigit = 3; | - | ||||||||||||||||||
| 3244 | static const int MaxDigitsForOctalInt = | - | ||||||||||||||||||
| 3245 | (std::numeric_limits<uint>::digits + NumBinaryDigitsPerOctalDigit - 1) / NumBinaryDigitsPerOctalDigit; | - | ||||||||||||||||||
| 3246 | char buffer[MaxDigitsForOctalInt + 2]; // +1 for NUL +1 for optional '-' | - | ||||||||||||||||||
| 3247 | size_t dummy; | - | ||||||||||||||||||
| 3248 | if (getenv_s(&dummy, buffer, sizeof buffer, varName) != 0) { | - | ||||||||||||||||||
| 3249 | if (ok) | - | ||||||||||||||||||
| 3250 | *ok = false; | - | ||||||||||||||||||
| 3251 | return 0; | - | ||||||||||||||||||
| 3252 | } | - | ||||||||||||||||||
| 3253 | #else | - | ||||||||||||||||||
| 3254 | const char * const buffer = ::getenv(varName); | - | ||||||||||||||||||
| 3255 | if (!buffer || !*buffer) {
| 2-3301 | ||||||||||||||||||
| 3256 | if (ok)
| 1236-2067 | ||||||||||||||||||
| 3257 | *ok = false; executed 2067 times by 538 tests: *ok = false;Executed by:
| 2067 | ||||||||||||||||||
| 3258 | return 0; executed 3303 times by 542 tests: return 0;Executed by:
| 3303 | ||||||||||||||||||
| 3259 | } | - | ||||||||||||||||||
| 3260 | #endif | - | ||||||||||||||||||
| 3261 | bool ok_ = true; | - | ||||||||||||||||||
| 3262 | const qlonglong value = qstrtoll(buffer, Q_NULLPTR, 0, &ok_); | - | ||||||||||||||||||
| 3263 | if (int(value) != value) { // this is the check in QByteArray::toInt(), keep it in sync
| 14-98 | ||||||||||||||||||
| 3264 | if (ok)
| 7 | ||||||||||||||||||
| 3265 | *ok = false; executed 7 times by 1 test: *ok = false;Executed by:
| 7 | ||||||||||||||||||
| 3266 | return 0; executed 14 times by 1 test: return 0;Executed by:
| 14 | ||||||||||||||||||
| 3267 | } else if (ok) {
| 14-84 | ||||||||||||||||||
| 3268 | *ok = ok_; | - | ||||||||||||||||||
| 3269 | } executed 84 times by 3 tests: end of blockExecuted by:
| 84 | ||||||||||||||||||
| 3270 | return int(value); executed 98 times by 3 tests: return int(value);Executed by:
| 98 | ||||||||||||||||||
| 3271 | } | - | ||||||||||||||||||
| 3272 | - | |||||||||||||||||||
| 3273 | /*! | - | ||||||||||||||||||
| 3274 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3275 | \since 5.1 | - | ||||||||||||||||||
| 3276 | - | |||||||||||||||||||
| 3277 | Returns whether the environment variable \a varName is set. | - | ||||||||||||||||||
| 3278 | - | |||||||||||||||||||
| 3279 | Equivalent to | - | ||||||||||||||||||
| 3280 | \code | - | ||||||||||||||||||
| 3281 | !qgetenv(varName).isNull() | - | ||||||||||||||||||
| 3282 | \endcode | - | ||||||||||||||||||
| 3283 | except that it's potentially much faster, and can't throw exceptions. | - | ||||||||||||||||||
| 3284 | - | |||||||||||||||||||
| 3285 | \sa qgetenv(), qEnvironmentVariableIsEmpty() | - | ||||||||||||||||||
| 3286 | */ | - | ||||||||||||||||||
| 3287 | bool qEnvironmentVariableIsSet(const char *varName) Q_DECL_NOEXCEPT | - | ||||||||||||||||||
| 3288 | { | - | ||||||||||||||||||
| 3289 | QMutexLocker locker(&environmentMutex); | - | ||||||||||||||||||
| 3290 | #if defined(_MSC_VER) && _MSC_VER >= 1400 | - | ||||||||||||||||||
| 3291 | size_t requiredSize = 0; | - | ||||||||||||||||||
| 3292 | (void)getenv_s(&requiredSize, 0, 0, varName); | - | ||||||||||||||||||
| 3293 | return requiredSize != 0; | - | ||||||||||||||||||
| 3294 | #else | - | ||||||||||||||||||
| 3295 | return ::getenv(varName) != 0; executed 2090 times by 165 tests: return ::getenv(varName) != 0;Executed by:
| 2090 | ||||||||||||||||||
| 3296 | #endif | - | ||||||||||||||||||
| 3297 | } | - | ||||||||||||||||||
| 3298 | - | |||||||||||||||||||
| 3299 | /*! | - | ||||||||||||||||||
| 3300 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3301 | - | |||||||||||||||||||
| 3302 | This function sets the \a value of the environment variable named | - | ||||||||||||||||||
| 3303 | \a varName. It will create the variable if it does not exist. It | - | ||||||||||||||||||
| 3304 | returns 0 if the variable could not be set. | - | ||||||||||||||||||
| 3305 | - | |||||||||||||||||||
| 3306 | Calling qputenv with an empty value removes the environment variable on | - | ||||||||||||||||||
| 3307 | Windows, and makes it set (but empty) on Unix. Prefer using qunsetenv() | - | ||||||||||||||||||
| 3308 | for fully portable behavior. | - | ||||||||||||||||||
| 3309 | - | |||||||||||||||||||
| 3310 | \note qputenv() was introduced because putenv() from the standard | - | ||||||||||||||||||
| 3311 | C library was deprecated in VC2005 (and later versions). qputenv() | - | ||||||||||||||||||
| 3312 | uses the replacement function in VC, and calls the standard C | - | ||||||||||||||||||
| 3313 | library's implementation on all other platforms. | - | ||||||||||||||||||
| 3314 | - | |||||||||||||||||||
| 3315 | \sa qgetenv() | - | ||||||||||||||||||
| 3316 | */ | - | ||||||||||||||||||
| 3317 | bool qputenv(const char *varName, const QByteArray& value) | - | ||||||||||||||||||
| 3318 | { | - | ||||||||||||||||||
| 3319 | QMutexLocker locker(&environmentMutex); | - | ||||||||||||||||||
| 3320 | #if defined(_MSC_VER) && _MSC_VER >= 1400 | - | ||||||||||||||||||
| 3321 | return _putenv_s(varName, value.constData()) == 0; | - | ||||||||||||||||||
| 3322 | #elif (defined(_POSIX_VERSION) && (_POSIX_VERSION-0) >= 200112L) || defined(Q_OS_HAIKU) | - | ||||||||||||||||||
| 3323 | // POSIX.1-2001 has setenv | - | ||||||||||||||||||
| 3324 | return setenv(varName, value.constData(), true) == 0; executed 1614 times by 13 tests: return setenv(varName, value.constData(), true) == 0;Executed by:
| 1614 | ||||||||||||||||||
| 3325 | #else | - | ||||||||||||||||||
| 3326 | QByteArray buffer(varName); | - | ||||||||||||||||||
| 3327 | buffer += '='; | - | ||||||||||||||||||
| 3328 | buffer += value; | - | ||||||||||||||||||
| 3329 | char* envVar = qstrdup(buffer.constData()); | - | ||||||||||||||||||
| 3330 | int result = putenv(envVar); | - | ||||||||||||||||||
| 3331 | if (result != 0) // error. we have to delete the string. | - | ||||||||||||||||||
| 3332 | delete[] envVar; | - | ||||||||||||||||||
| 3333 | return result == 0; | - | ||||||||||||||||||
| 3334 | #endif | - | ||||||||||||||||||
| 3335 | } | - | ||||||||||||||||||
| 3336 | - | |||||||||||||||||||
| 3337 | /*! | - | ||||||||||||||||||
| 3338 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3339 | - | |||||||||||||||||||
| 3340 | This function deletes the variable \a varName from the environment. | - | ||||||||||||||||||
| 3341 | - | |||||||||||||||||||
| 3342 | Returns \c true on success. | - | ||||||||||||||||||
| 3343 | - | |||||||||||||||||||
| 3344 | \since 5.1 | - | ||||||||||||||||||
| 3345 | - | |||||||||||||||||||
| 3346 | \sa qputenv(), qgetenv() | - | ||||||||||||||||||
| 3347 | */ | - | ||||||||||||||||||
| 3348 | bool qunsetenv(const char *varName) | - | ||||||||||||||||||
| 3349 | { | - | ||||||||||||||||||
| 3350 | QMutexLocker locker(&environmentMutex); | - | ||||||||||||||||||
| 3351 | #if defined(_MSC_VER) && _MSC_VER >= 1400 | - | ||||||||||||||||||
| 3352 | return _putenv_s(varName, "") == 0; | - | ||||||||||||||||||
| 3353 | #elif (defined(_POSIX_VERSION) && (_POSIX_VERSION-0) >= 200112L) || defined(Q_OS_BSD4) || defined(Q_OS_HAIKU) | - | ||||||||||||||||||
| 3354 | // POSIX.1-2001, BSD and Haiku have unsetenv | - | ||||||||||||||||||
| 3355 | return unsetenv(varName) == 0; executed 74 times by 4 tests: return unsetenv(varName) == 0;Executed by:
| 74 | ||||||||||||||||||
| 3356 | #elif defined(Q_CC_MINGW) | - | ||||||||||||||||||
| 3357 | // On mingw, putenv("var=") removes "var" from the environment | - | ||||||||||||||||||
| 3358 | QByteArray buffer(varName); | - | ||||||||||||||||||
| 3359 | buffer += '='; | - | ||||||||||||||||||
| 3360 | return putenv(buffer.constData()) == 0; | - | ||||||||||||||||||
| 3361 | #else | - | ||||||||||||||||||
| 3362 | // Fallback to putenv("var=") which will insert an empty var into the | - | ||||||||||||||||||
| 3363 | // environment and leak it | - | ||||||||||||||||||
| 3364 | QByteArray buffer(varName); | - | ||||||||||||||||||
| 3365 | buffer += '='; | - | ||||||||||||||||||
| 3366 | char *envVar = qstrdup(buffer.constData()); | - | ||||||||||||||||||
| 3367 | return putenv(envVar) == 0; | - | ||||||||||||||||||
| 3368 | #endif | - | ||||||||||||||||||
| 3369 | } | - | ||||||||||||||||||
| 3370 | - | |||||||||||||||||||
| 3371 | #if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && (_POSIX_THREAD_SAFE_FUNCTIONS - 0 > 0) | - | ||||||||||||||||||
| 3372 | - | |||||||||||||||||||
| 3373 | # if defined(Q_OS_INTEGRITY) && defined(__GHS_VERSION_NUMBER) && (__GHS_VERSION_NUMBER < 500) | - | ||||||||||||||||||
| 3374 | // older versions of INTEGRITY used a long instead of a uint for the seed. | - | ||||||||||||||||||
| 3375 | typedef long SeedStorageType; | - | ||||||||||||||||||
| 3376 | # else | - | ||||||||||||||||||
| 3377 | typedef uint SeedStorageType; | - | ||||||||||||||||||
| 3378 | # endif | - | ||||||||||||||||||
| 3379 | - | |||||||||||||||||||
| 3380 | typedef QThreadStorage<SeedStorageType *> SeedStorage; | - | ||||||||||||||||||
| 3381 | Q_GLOBAL_STATIC(SeedStorage, randTLS) // Thread Local Storage for seed value executed 51 times by 50 tests: end of blockExecuted by:
executed 51 times by 50 tests: guard.store(QtGlobalStatic::Destroyed);Executed by:
executed 20184593 times by 50 tests: return &holder.value;Executed by:
| 0-20184593 | ||||||||||||||||||
| 3382 | - | |||||||||||||||||||
| 3383 | #elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) | - | ||||||||||||||||||
| 3384 | typedef QThreadStorage<QJNIObjectPrivate> AndroidRandomStorage; | - | ||||||||||||||||||
| 3385 | Q_GLOBAL_STATIC(AndroidRandomStorage, randomTLS) | - | ||||||||||||||||||
| 3386 | #endif | - | ||||||||||||||||||
| 3387 | - | |||||||||||||||||||
| 3388 | /*! | - | ||||||||||||||||||
| 3389 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3390 | \since 4.2 | - | ||||||||||||||||||
| 3391 | - | |||||||||||||||||||
| 3392 | Thread-safe version of the standard C++ \c srand() function. | - | ||||||||||||||||||
| 3393 | - | |||||||||||||||||||
| 3394 | Sets the argument \a seed to be used to generate a new random number sequence of | - | ||||||||||||||||||
| 3395 | pseudo random integers to be returned by qrand(). | - | ||||||||||||||||||
| 3396 | - | |||||||||||||||||||
| 3397 | The sequence of random numbers generated is deterministic per thread. For example, | - | ||||||||||||||||||
| 3398 | if two threads call qsrand(1) and subsequently call qrand(), the threads will get | - | ||||||||||||||||||
| 3399 | the same random number sequence. | - | ||||||||||||||||||
| 3400 | - | |||||||||||||||||||
| 3401 | \sa qrand() | - | ||||||||||||||||||
| 3402 | */ | - | ||||||||||||||||||
| 3403 | void qsrand(uint seed) | - | ||||||||||||||||||
| 3404 | { | - | ||||||||||||||||||
| 3405 | #if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && (_POSIX_THREAD_SAFE_FUNCTIONS - 0 > 0) | - | ||||||||||||||||||
| 3406 | SeedStorage *seedStorage = randTLS(); | - | ||||||||||||||||||
| 3407 | if (seedStorage) {
| 0-30 | ||||||||||||||||||
| 3408 | SeedStorageType *pseed = seedStorage->localData(); | - | ||||||||||||||||||
| 3409 | if (!pseed)
| 7-23 | ||||||||||||||||||
| 3410 | seedStorage->setLocalData(pseed = new SeedStorageType); executed 23 times by 2 tests: seedStorage->setLocalData(pseed = new SeedStorageType);Executed by:
| 23 | ||||||||||||||||||
| 3411 | *pseed = seed; | - | ||||||||||||||||||
| 3412 | } else { executed 30 times by 6 tests: end of blockExecuted by:
| 30 | ||||||||||||||||||
| 3413 | //global static seed storage should always exist, | - | ||||||||||||||||||
| 3414 | //except after being deleted by QGlobalStaticDeleter. | - | ||||||||||||||||||
| 3415 | //But since it still can be called from destructor of another | - | ||||||||||||||||||
| 3416 | //global static object, fallback to srand(seed) | - | ||||||||||||||||||
| 3417 | srand(seed); | - | ||||||||||||||||||
| 3418 | } never executed: end of block | 0 | ||||||||||||||||||
| 3419 | #elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) | - | ||||||||||||||||||
| 3420 | if (randomTLS->hasLocalData()) { | - | ||||||||||||||||||
| 3421 | randomTLS->localData().callMethod<void>("setSeed", "(J)V", jlong(seed)); | - | ||||||||||||||||||
| 3422 | return; | - | ||||||||||||||||||
| 3423 | } | - | ||||||||||||||||||
| 3424 | - | |||||||||||||||||||
| 3425 | QJNIObjectPrivate random("java/util/Random", | - | ||||||||||||||||||
| 3426 | "(J)V", | - | ||||||||||||||||||
| 3427 | jlong(seed)); | - | ||||||||||||||||||
| 3428 | if (!random.isValid()) { | - | ||||||||||||||||||
| 3429 | srand(seed); | - | ||||||||||||||||||
| 3430 | return; | - | ||||||||||||||||||
| 3431 | } | - | ||||||||||||||||||
| 3432 | - | |||||||||||||||||||
| 3433 | randomTLS->setLocalData(random); | - | ||||||||||||||||||
| 3434 | #else | - | ||||||||||||||||||
| 3435 | // On Windows srand() and rand() already use Thread-Local-Storage | - | ||||||||||||||||||
| 3436 | // to store the seed between calls | - | ||||||||||||||||||
| 3437 | // this is also valid for QT_NO_THREAD | - | ||||||||||||||||||
| 3438 | srand(seed); | - | ||||||||||||||||||
| 3439 | #endif | - | ||||||||||||||||||
| 3440 | } | - | ||||||||||||||||||
| 3441 | - | |||||||||||||||||||
| 3442 | /*! | - | ||||||||||||||||||
| 3443 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3444 | \since 4.2 | - | ||||||||||||||||||
| 3445 | - | |||||||||||||||||||
| 3446 | Thread-safe version of the standard C++ \c rand() function. | - | ||||||||||||||||||
| 3447 | - | |||||||||||||||||||
| 3448 | Returns a value between 0 and \c RAND_MAX (defined in \c <cstdlib> and | - | ||||||||||||||||||
| 3449 | \c <stdlib.h>), the next number in the current sequence of pseudo-random | - | ||||||||||||||||||
| 3450 | integers. | - | ||||||||||||||||||
| 3451 | - | |||||||||||||||||||
| 3452 | Use \c qsrand() to initialize the pseudo-random number generator with | - | ||||||||||||||||||
| 3453 | a seed value. | - | ||||||||||||||||||
| 3454 | - | |||||||||||||||||||
| 3455 | \sa qsrand() | - | ||||||||||||||||||
| 3456 | */ | - | ||||||||||||||||||
| 3457 | int qrand() | - | ||||||||||||||||||
| 3458 | { | - | ||||||||||||||||||
| 3459 | #if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && (_POSIX_THREAD_SAFE_FUNCTIONS - 0 > 0) | - | ||||||||||||||||||
| 3460 | SeedStorage *seedStorage = randTLS(); | - | ||||||||||||||||||
| 3461 | if (seedStorage) {
| 2-20184563 | ||||||||||||||||||
| 3462 | SeedStorageType *pseed = seedStorage->localData(); | - | ||||||||||||||||||
| 3463 | if (!pseed) {
| 648-20183915 | ||||||||||||||||||
| 3464 | seedStorage->setLocalData(pseed = new SeedStorageType); | - | ||||||||||||||||||
| 3465 | *pseed = 1; | - | ||||||||||||||||||
| 3466 | } executed 648 times by 47 tests: end of blockExecuted by:
| 648 | ||||||||||||||||||
| 3467 | return rand_r(pseed); executed 20184563 times by 49 tests: return rand_r(pseed);Executed by:
| 20184563 | ||||||||||||||||||
| 3468 | } else { | - | ||||||||||||||||||
| 3469 | //global static seed storage should always exist, | - | ||||||||||||||||||
| 3470 | //except after being deleted by QGlobalStaticDeleter. | - | ||||||||||||||||||
| 3471 | //But since it still can be called from destructor of another | - | ||||||||||||||||||
| 3472 | //global static object, fallback to rand() | - | ||||||||||||||||||
| 3473 | return rand(); executed 2 times by 1 test: return rand();Executed by:
| 2 | ||||||||||||||||||
| 3474 | } | - | ||||||||||||||||||
| 3475 | #elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) | - | ||||||||||||||||||
| 3476 | AndroidRandomStorage *randomStorage = randomTLS(); | - | ||||||||||||||||||
| 3477 | if (!randomStorage) | - | ||||||||||||||||||
| 3478 | return rand(); | - | ||||||||||||||||||
| 3479 | - | |||||||||||||||||||
| 3480 | if (randomStorage->hasLocalData()) { | - | ||||||||||||||||||
| 3481 | return randomStorage->localData().callMethod<jint>("nextInt", | - | ||||||||||||||||||
| 3482 | "(I)I", | - | ||||||||||||||||||
| 3483 | RAND_MAX); | - | ||||||||||||||||||
| 3484 | } | - | ||||||||||||||||||
| 3485 | - | |||||||||||||||||||
| 3486 | QJNIObjectPrivate random("java/util/Random", | - | ||||||||||||||||||
| 3487 | "(J)V", | - | ||||||||||||||||||
| 3488 | jlong(1)); | - | ||||||||||||||||||
| 3489 | - | |||||||||||||||||||
| 3490 | if (!random.isValid()) | - | ||||||||||||||||||
| 3491 | return rand(); | - | ||||||||||||||||||
| 3492 | - | |||||||||||||||||||
| 3493 | randomStorage->setLocalData(random); | - | ||||||||||||||||||
| 3494 | return random.callMethod<jint>("nextInt", "(I)I", RAND_MAX); | - | ||||||||||||||||||
| 3495 | #else | - | ||||||||||||||||||
| 3496 | // On Windows srand() and rand() already use Thread-Local-Storage | - | ||||||||||||||||||
| 3497 | // to store the seed between calls | - | ||||||||||||||||||
| 3498 | // this is also valid for QT_NO_THREAD | - | ||||||||||||||||||
| 3499 | return rand(); | - | ||||||||||||||||||
| 3500 | #endif | - | ||||||||||||||||||
| 3501 | } | - | ||||||||||||||||||
| 3502 | - | |||||||||||||||||||
| 3503 | /*! | - | ||||||||||||||||||
| 3504 | \macro forever | - | ||||||||||||||||||
| 3505 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3506 | - | |||||||||||||||||||
| 3507 | This macro is provided for convenience for writing infinite | - | ||||||||||||||||||
| 3508 | loops. | - | ||||||||||||||||||
| 3509 | - | |||||||||||||||||||
| 3510 | Example: | - | ||||||||||||||||||
| 3511 | - | |||||||||||||||||||
| 3512 | \snippet code/src_corelib_global_qglobal.cpp 31 | - | ||||||||||||||||||
| 3513 | - | |||||||||||||||||||
| 3514 | It is equivalent to \c{for (;;)}. | - | ||||||||||||||||||
| 3515 | - | |||||||||||||||||||
| 3516 | If you're worried about namespace pollution, you can disable this | - | ||||||||||||||||||
| 3517 | macro by adding the following line to your \c .pro file: | - | ||||||||||||||||||
| 3518 | - | |||||||||||||||||||
| 3519 | \snippet code/src_corelib_global_qglobal.cpp 32 | - | ||||||||||||||||||
| 3520 | - | |||||||||||||||||||
| 3521 | \sa Q_FOREVER | - | ||||||||||||||||||
| 3522 | */ | - | ||||||||||||||||||
| 3523 | - | |||||||||||||||||||
| 3524 | /*! | - | ||||||||||||||||||
| 3525 | \macro Q_FOREVER | - | ||||||||||||||||||
| 3526 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3527 | - | |||||||||||||||||||
| 3528 | Same as \l{forever}. | - | ||||||||||||||||||
| 3529 | - | |||||||||||||||||||
| 3530 | This macro is available even when \c no_keywords is specified | - | ||||||||||||||||||
| 3531 | using the \c .pro file's \c CONFIG variable. | - | ||||||||||||||||||
| 3532 | - | |||||||||||||||||||
| 3533 | \sa foreach() | - | ||||||||||||||||||
| 3534 | */ | - | ||||||||||||||||||
| 3535 | - | |||||||||||||||||||
| 3536 | /*! | - | ||||||||||||||||||
| 3537 | \macro foreach(variable, container) | - | ||||||||||||||||||
| 3538 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3539 | - | |||||||||||||||||||
| 3540 | This macro is used to implement Qt's \c foreach loop. The \a | - | ||||||||||||||||||
| 3541 | variable parameter is a variable name or variable definition; the | - | ||||||||||||||||||
| 3542 | \a container parameter is a Qt container whose value type | - | ||||||||||||||||||
| 3543 | corresponds to the type of the variable. See \l{The foreach | - | ||||||||||||||||||
| 3544 | Keyword} for details. | - | ||||||||||||||||||
| 3545 | - | |||||||||||||||||||
| 3546 | If you're worried about namespace pollution, you can disable this | - | ||||||||||||||||||
| 3547 | macro by adding the following line to your \c .pro file: | - | ||||||||||||||||||
| 3548 | - | |||||||||||||||||||
| 3549 | \snippet code/src_corelib_global_qglobal.cpp 33 | - | ||||||||||||||||||
| 3550 | - | |||||||||||||||||||
| 3551 | \sa Q_FOREACH() | - | ||||||||||||||||||
| 3552 | */ | - | ||||||||||||||||||
| 3553 | - | |||||||||||||||||||
| 3554 | /*! | - | ||||||||||||||||||
| 3555 | \macro Q_FOREACH(variable, container) | - | ||||||||||||||||||
| 3556 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3557 | - | |||||||||||||||||||
| 3558 | Same as foreach(\a variable, \a container). | - | ||||||||||||||||||
| 3559 | - | |||||||||||||||||||
| 3560 | This macro is available even when \c no_keywords is specified | - | ||||||||||||||||||
| 3561 | using the \c .pro file's \c CONFIG variable. | - | ||||||||||||||||||
| 3562 | - | |||||||||||||||||||
| 3563 | \sa foreach() | - | ||||||||||||||||||
| 3564 | */ | - | ||||||||||||||||||
| 3565 | - | |||||||||||||||||||
| 3566 | /*! | - | ||||||||||||||||||
| 3567 | \macro QT_TR_NOOP(sourceText) | - | ||||||||||||||||||
| 3568 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3569 | - | |||||||||||||||||||
| 3570 | Marks the string literal \a sourceText for dynamic translation in | - | ||||||||||||||||||
| 3571 | the current context (class), i.e the stored \a sourceText will not | - | ||||||||||||||||||
| 3572 | be altered. | - | ||||||||||||||||||
| 3573 | - | |||||||||||||||||||
| 3574 | The macro expands to \a sourceText. | - | ||||||||||||||||||
| 3575 | - | |||||||||||||||||||
| 3576 | Example: | - | ||||||||||||||||||
| 3577 | - | |||||||||||||||||||
| 3578 | \snippet code/src_corelib_global_qglobal.cpp 34 | - | ||||||||||||||||||
| 3579 | - | |||||||||||||||||||
| 3580 | The macro QT_TR_NOOP_UTF8() is identical except that it tells lupdate | - | ||||||||||||||||||
| 3581 | that the source string is encoded in UTF-8. Corresponding variants | - | ||||||||||||||||||
| 3582 | exist in the QT_TRANSLATE_NOOP() family of macros, too. | - | ||||||||||||||||||
| 3583 | - | |||||||||||||||||||
| 3584 | \sa QT_TRANSLATE_NOOP(), {Internationalization with Qt} | - | ||||||||||||||||||
| 3585 | */ | - | ||||||||||||||||||
| 3586 | - | |||||||||||||||||||
| 3587 | /*! | - | ||||||||||||||||||
| 3588 | \macro QT_TRANSLATE_NOOP(context, sourceText) | - | ||||||||||||||||||
| 3589 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3590 | - | |||||||||||||||||||
| 3591 | Marks the string literal \a sourceText for dynamic translation in | - | ||||||||||||||||||
| 3592 | the given \a context; i.e, the stored \a sourceText will not be | - | ||||||||||||||||||
| 3593 | altered. The \a context is typically a class and also needs to | - | ||||||||||||||||||
| 3594 | be specified as string literal. | - | ||||||||||||||||||
| 3595 | - | |||||||||||||||||||
| 3596 | The macro expands to \a sourceText. | - | ||||||||||||||||||
| 3597 | - | |||||||||||||||||||
| 3598 | Example: | - | ||||||||||||||||||
| 3599 | - | |||||||||||||||||||
| 3600 | \snippet code/src_corelib_global_qglobal.cpp 35 | - | ||||||||||||||||||
| 3601 | - | |||||||||||||||||||
| 3602 | \sa QT_TR_NOOP(), QT_TRANSLATE_NOOP3(), {Internationalization with Qt} | - | ||||||||||||||||||
| 3603 | */ | - | ||||||||||||||||||
| 3604 | - | |||||||||||||||||||
| 3605 | /*! | - | ||||||||||||||||||
| 3606 | \macro QT_TRANSLATE_NOOP3(context, sourceText, comment) | - | ||||||||||||||||||
| 3607 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3608 | \since 4.4 | - | ||||||||||||||||||
| 3609 | - | |||||||||||||||||||
| 3610 | Marks the string literal \a sourceText for dynamic translation in the | - | ||||||||||||||||||
| 3611 | given \a context and with \a comment, i.e the stored \a sourceText will | - | ||||||||||||||||||
| 3612 | not be altered. The \a context is typically a class and also needs to | - | ||||||||||||||||||
| 3613 | be specified as string literal. The string literal \a comment | - | ||||||||||||||||||
| 3614 | will be available for translators using e.g. Qt Linguist. | - | ||||||||||||||||||
| 3615 | - | |||||||||||||||||||
| 3616 | The macro expands to anonymous struct of the two string | - | ||||||||||||||||||
| 3617 | literals passed as \a sourceText and \a comment. | - | ||||||||||||||||||
| 3618 | - | |||||||||||||||||||
| 3619 | Example: | - | ||||||||||||||||||
| 3620 | - | |||||||||||||||||||
| 3621 | \snippet code/src_corelib_global_qglobal.cpp 36 | - | ||||||||||||||||||
| 3622 | - | |||||||||||||||||||
| 3623 | \sa QT_TR_NOOP(), QT_TRANSLATE_NOOP(), {Internationalization with Qt} | - | ||||||||||||||||||
| 3624 | */ | - | ||||||||||||||||||
| 3625 | - | |||||||||||||||||||
| 3626 | /*! | - | ||||||||||||||||||
| 3627 | \fn QString qtTrId(const char *id, int n = -1) | - | ||||||||||||||||||
| 3628 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3629 | \reentrant | - | ||||||||||||||||||
| 3630 | \since 4.6 | - | ||||||||||||||||||
| 3631 | - | |||||||||||||||||||
| 3632 | \brief The qtTrId function finds and returns a translated string. | - | ||||||||||||||||||
| 3633 | - | |||||||||||||||||||
| 3634 | Returns a translated string identified by \a id. | - | ||||||||||||||||||
| 3635 | If no matching string is found, the id itself is returned. This | - | ||||||||||||||||||
| 3636 | should not happen under normal conditions. | - | ||||||||||||||||||
| 3637 | - | |||||||||||||||||||
| 3638 | If \a n >= 0, all occurrences of \c %n in the resulting string | - | ||||||||||||||||||
| 3639 | are replaced with a decimal representation of \a n. In addition, | - | ||||||||||||||||||
| 3640 | depending on \a n's value, the translation text may vary. | - | ||||||||||||||||||
| 3641 | - | |||||||||||||||||||
| 3642 | Meta data and comments can be passed as documented for QObject::tr(). | - | ||||||||||||||||||
| 3643 | In addition, it is possible to supply a source string template like that: | - | ||||||||||||||||||
| 3644 | - | |||||||||||||||||||
| 3645 | \tt{//% <C string>} | - | ||||||||||||||||||
| 3646 | - | |||||||||||||||||||
| 3647 | or | - | ||||||||||||||||||
| 3648 | - | |||||||||||||||||||
| 3649 | \tt{\\begincomment% <C string> \\endcomment} | - | ||||||||||||||||||
| 3650 | - | |||||||||||||||||||
| 3651 | Example: | - | ||||||||||||||||||
| 3652 | - | |||||||||||||||||||
| 3653 | \snippet code/src_corelib_global_qglobal.cpp qttrid | - | ||||||||||||||||||
| 3654 | - | |||||||||||||||||||
| 3655 | Creating QM files suitable for use with this function requires passing | - | ||||||||||||||||||
| 3656 | the \c -idbased option to the \c lrelease tool. | - | ||||||||||||||||||
| 3657 | - | |||||||||||||||||||
| 3658 | \warning This method is reentrant only if all translators are | - | ||||||||||||||||||
| 3659 | installed \e before calling this method. Installing or removing | - | ||||||||||||||||||
| 3660 | translators while performing translations is not supported. Doing | - | ||||||||||||||||||
| 3661 | so will probably result in crashes or other undesirable behavior. | - | ||||||||||||||||||
| 3662 | - | |||||||||||||||||||
| 3663 | \sa QObject::tr(), QCoreApplication::translate(), {Internationalization with Qt} | - | ||||||||||||||||||
| 3664 | */ | - | ||||||||||||||||||
| 3665 | - | |||||||||||||||||||
| 3666 | /*! | - | ||||||||||||||||||
| 3667 | \macro QT_TRID_NOOP(id) | - | ||||||||||||||||||
| 3668 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3669 | \since 4.6 | - | ||||||||||||||||||
| 3670 | - | |||||||||||||||||||
| 3671 | \brief The QT_TRID_NOOP macro marks an id for dynamic translation. | - | ||||||||||||||||||
| 3672 | - | |||||||||||||||||||
| 3673 | The only purpose of this macro is to provide an anchor for attaching | - | ||||||||||||||||||
| 3674 | meta data like to qtTrId(). | - | ||||||||||||||||||
| 3675 | - | |||||||||||||||||||
| 3676 | The macro expands to \a id. | - | ||||||||||||||||||
| 3677 | - | |||||||||||||||||||
| 3678 | Example: | - | ||||||||||||||||||
| 3679 | - | |||||||||||||||||||
| 3680 | \snippet code/src_corelib_global_qglobal.cpp qttrid_noop | - | ||||||||||||||||||
| 3681 | - | |||||||||||||||||||
| 3682 | \sa qtTrId(), {Internationalization with Qt} | - | ||||||||||||||||||
| 3683 | */ | - | ||||||||||||||||||
| 3684 | - | |||||||||||||||||||
| 3685 | /*! | - | ||||||||||||||||||
| 3686 | \macro Q_LIKELY(expr) | - | ||||||||||||||||||
| 3687 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3688 | \since 4.8 | - | ||||||||||||||||||
| 3689 | - | |||||||||||||||||||
| 3690 | \brief Hints to the compiler that the enclosed condition, \a expr, is | - | ||||||||||||||||||
| 3691 | likely to evaluate to \c true. | - | ||||||||||||||||||
| 3692 | - | |||||||||||||||||||
| 3693 | Use of this macro can help the compiler to optimize the code. | - | ||||||||||||||||||
| 3694 | - | |||||||||||||||||||
| 3695 | Example: | - | ||||||||||||||||||
| 3696 | - | |||||||||||||||||||
| 3697 | \snippet code/src_corelib_global_qglobal.cpp qlikely | - | ||||||||||||||||||
| 3698 | - | |||||||||||||||||||
| 3699 | \sa Q_UNLIKELY() | - | ||||||||||||||||||
| 3700 | */ | - | ||||||||||||||||||
| 3701 | - | |||||||||||||||||||
| 3702 | /*! | - | ||||||||||||||||||
| 3703 | \macro Q_UNLIKELY(expr) | - | ||||||||||||||||||
| 3704 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3705 | \since 4.8 | - | ||||||||||||||||||
| 3706 | - | |||||||||||||||||||
| 3707 | \brief Hints to the compiler that the enclosed condition, \a expr, is | - | ||||||||||||||||||
| 3708 | likely to evaluate to \c false. | - | ||||||||||||||||||
| 3709 | - | |||||||||||||||||||
| 3710 | Use of this macro can help the compiler to optimize the code. | - | ||||||||||||||||||
| 3711 | - | |||||||||||||||||||
| 3712 | Example: | - | ||||||||||||||||||
| 3713 | - | |||||||||||||||||||
| 3714 | \snippet code/src_corelib_global_qglobal.cpp qunlikely | - | ||||||||||||||||||
| 3715 | - | |||||||||||||||||||
| 3716 | \sa Q_LIKELY() | - | ||||||||||||||||||
| 3717 | */ | - | ||||||||||||||||||
| 3718 | - | |||||||||||||||||||
| 3719 | /*! | - | ||||||||||||||||||
| 3720 | \macro QT_POINTER_SIZE | - | ||||||||||||||||||
| 3721 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3722 | - | |||||||||||||||||||
| 3723 | Expands to the size of a pointer in bytes (4 or 8). This is | - | ||||||||||||||||||
| 3724 | equivalent to \c sizeof(void *) but can be used in a preprocessor | - | ||||||||||||||||||
| 3725 | directive. | - | ||||||||||||||||||
| 3726 | */ | - | ||||||||||||||||||
| 3727 | - | |||||||||||||||||||
| 3728 | /*! | - | ||||||||||||||||||
| 3729 | \macro QABS(n) | - | ||||||||||||||||||
| 3730 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3731 | \obsolete | - | ||||||||||||||||||
| 3732 | - | |||||||||||||||||||
| 3733 | Use qAbs(\a n) instead. | - | ||||||||||||||||||
| 3734 | - | |||||||||||||||||||
| 3735 | \sa QMIN(), QMAX() | - | ||||||||||||||||||
| 3736 | */ | - | ||||||||||||||||||
| 3737 | - | |||||||||||||||||||
| 3738 | /*! | - | ||||||||||||||||||
| 3739 | \macro QMIN(x, y) | - | ||||||||||||||||||
| 3740 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3741 | \obsolete | - | ||||||||||||||||||
| 3742 | - | |||||||||||||||||||
| 3743 | Use qMin(\a x, \a y) instead. | - | ||||||||||||||||||
| 3744 | - | |||||||||||||||||||
| 3745 | \sa QMAX(), QABS() | - | ||||||||||||||||||
| 3746 | */ | - | ||||||||||||||||||
| 3747 | - | |||||||||||||||||||
| 3748 | /*! | - | ||||||||||||||||||
| 3749 | \macro QMAX(x, y) | - | ||||||||||||||||||
| 3750 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3751 | \obsolete | - | ||||||||||||||||||
| 3752 | - | |||||||||||||||||||
| 3753 | Use qMax(\a x, \a y) instead. | - | ||||||||||||||||||
| 3754 | - | |||||||||||||||||||
| 3755 | \sa QMIN(), QABS() | - | ||||||||||||||||||
| 3756 | */ | - | ||||||||||||||||||
| 3757 | - | |||||||||||||||||||
| 3758 | /*! | - | ||||||||||||||||||
| 3759 | \macro const char *qPrintable(const QString &str) | - | ||||||||||||||||||
| 3760 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3761 | - | |||||||||||||||||||
| 3762 | Returns \a str as a \c{const char *}. This is equivalent to | - | ||||||||||||||||||
| 3763 | \a{str}.toLocal8Bit().constData(). | - | ||||||||||||||||||
| 3764 | - | |||||||||||||||||||
| 3765 | The char pointer will be invalid after the statement in which | - | ||||||||||||||||||
| 3766 | qPrintable() is used. This is because the array returned by | - | ||||||||||||||||||
| 3767 | QString::toLocal8Bit() will fall out of scope. | - | ||||||||||||||||||
| 3768 | - | |||||||||||||||||||
| 3769 | \note qDebug(), qInfo(), qWarning(), qCritical(), qFatal() expect | - | ||||||||||||||||||
| 3770 | %s arguments to be UTF-8 encoded, while qPrintable() converts to | - | ||||||||||||||||||
| 3771 | local 8-bit encoding. Therefore qUtf8Printable() should be used | - | ||||||||||||||||||
| 3772 | for logging strings instead of qPrintable(). | - | ||||||||||||||||||
| 3773 | - | |||||||||||||||||||
| 3774 | \sa qUtf8Printable() | - | ||||||||||||||||||
| 3775 | */ | - | ||||||||||||||||||
| 3776 | - | |||||||||||||||||||
| 3777 | /*! | - | ||||||||||||||||||
| 3778 | \macro const char *qUtf8Printable(const QString &str) | - | ||||||||||||||||||
| 3779 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3780 | \since 5.4 | - | ||||||||||||||||||
| 3781 | - | |||||||||||||||||||
| 3782 | Returns \a str as a \c{const char *}. This is equivalent to | - | ||||||||||||||||||
| 3783 | \a{str}.toUtf8().constData(). | - | ||||||||||||||||||
| 3784 | - | |||||||||||||||||||
| 3785 | The char pointer will be invalid after the statement in which | - | ||||||||||||||||||
| 3786 | qUtf8Printable() is used. This is because the array returned by | - | ||||||||||||||||||
| 3787 | QString::toUtf8() will fall out of scope. | - | ||||||||||||||||||
| 3788 | - | |||||||||||||||||||
| 3789 | Example: | - | ||||||||||||||||||
| 3790 | - | |||||||||||||||||||
| 3791 | \snippet code/src_corelib_global_qglobal.cpp 37 | - | ||||||||||||||||||
| 3792 | - | |||||||||||||||||||
| 3793 | \sa qPrintable(), qDebug(), qInfo(), qWarning(), qCritical(), qFatal() | - | ||||||||||||||||||
| 3794 | */ | - | ||||||||||||||||||
| 3795 | - | |||||||||||||||||||
| 3796 | /*! | - | ||||||||||||||||||
| 3797 | \macro Q_DECLARE_TYPEINFO(Type, Flags) | - | ||||||||||||||||||
| 3798 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3799 | - | |||||||||||||||||||
| 3800 | You can use this macro to specify information about a custom type | - | ||||||||||||||||||
| 3801 | \a Type. With accurate type information, Qt's \l{Container Classes} | - | ||||||||||||||||||
| 3802 | {generic containers} can choose appropriate storage methods and | - | ||||||||||||||||||
| 3803 | algorithms. | - | ||||||||||||||||||
| 3804 | - | |||||||||||||||||||
| 3805 | \a Flags can be one of the following: | - | ||||||||||||||||||
| 3806 | - | |||||||||||||||||||
| 3807 | \list | - | ||||||||||||||||||
| 3808 | \li \c Q_PRIMITIVE_TYPE specifies that \a Type is a POD (plain old | - | ||||||||||||||||||
| 3809 | data) type with no constructor or destructor, or else a type where | - | ||||||||||||||||||
| 3810 | every bit pattern is a valid object and memcpy() creates a valid | - | ||||||||||||||||||
| 3811 | independent copy of the object. | - | ||||||||||||||||||
| 3812 | \li \c Q_MOVABLE_TYPE specifies that \a Type has a constructor | - | ||||||||||||||||||
| 3813 | and/or a destructor but can be moved in memory using \c | - | ||||||||||||||||||
| 3814 | memcpy(). Note: despite the name, this has nothing to do with move | - | ||||||||||||||||||
| 3815 | constructors or C++ move semantics. | - | ||||||||||||||||||
| 3816 | \li \c Q_COMPLEX_TYPE (the default) specifies that \a Type has | - | ||||||||||||||||||
| 3817 | constructors and/or a destructor and that it may not be moved | - | ||||||||||||||||||
| 3818 | in memory. | - | ||||||||||||||||||
| 3819 | \endlist | - | ||||||||||||||||||
| 3820 | - | |||||||||||||||||||
| 3821 | Example of a "primitive" type: | - | ||||||||||||||||||
| 3822 | - | |||||||||||||||||||
| 3823 | \snippet code/src_corelib_global_qglobal.cpp 38 | - | ||||||||||||||||||
| 3824 | - | |||||||||||||||||||
| 3825 | An example of a non-POD "primitive" type is QUuid: Even though | - | ||||||||||||||||||
| 3826 | QUuid has constructors (and therefore isn't POD), every bit | - | ||||||||||||||||||
| 3827 | pattern still represents a valid object, and memcpy() can be used | - | ||||||||||||||||||
| 3828 | to create a valid independent copy of a QUuid object. | - | ||||||||||||||||||
| 3829 | - | |||||||||||||||||||
| 3830 | Example of a movable type: | - | ||||||||||||||||||
| 3831 | - | |||||||||||||||||||
| 3832 | \snippet code/src_corelib_global_qglobal.cpp 39 | - | ||||||||||||||||||
| 3833 | */ | - | ||||||||||||||||||
| 3834 | - | |||||||||||||||||||
| 3835 | /*! | - | ||||||||||||||||||
| 3836 | \macro Q_UNUSED(name) | - | ||||||||||||||||||
| 3837 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3838 | - | |||||||||||||||||||
| 3839 | Indicates to the compiler that the parameter with the specified | - | ||||||||||||||||||
| 3840 | \a name is not used in the body of a function. This can be used to | - | ||||||||||||||||||
| 3841 | suppress compiler warnings while allowing functions to be defined | - | ||||||||||||||||||
| 3842 | with meaningful parameter names in their signatures. | - | ||||||||||||||||||
| 3843 | */ | - | ||||||||||||||||||
| 3844 | - | |||||||||||||||||||
| 3845 | struct QInternal_CallBackTable { | - | ||||||||||||||||||
| 3846 | QVector<QList<qInternalCallback> > callbacks; | - | ||||||||||||||||||
| 3847 | }; | - | ||||||||||||||||||
| 3848 | - | |||||||||||||||||||
| 3849 | Q_GLOBAL_STATIC(QInternal_CallBackTable, global_callback_table) executed 976 times by 421 tests: end of blockExecuted by:
executed 976 times by 421 tests: guard.store(QtGlobalStatic::Destroyed);Executed by:
executed 1774907 times by 525 tests: return &holder.value;Executed by:
| 0-1774907 | ||||||||||||||||||
| 3850 | - | |||||||||||||||||||
| 3851 | bool QInternal::registerCallback(Callback cb, qInternalCallback callback) | - | ||||||||||||||||||
| 3852 | { | - | ||||||||||||||||||
| 3853 | if (cb >= 0 && cb < QInternal::LastCallback) {
| 0 | ||||||||||||||||||
| 3854 | QInternal_CallBackTable *cbt = global_callback_table(); | - | ||||||||||||||||||
| 3855 | cbt->callbacks.resize(cb + 1); | - | ||||||||||||||||||
| 3856 | cbt->callbacks[cb].append(callback); | - | ||||||||||||||||||
| 3857 | return true; never executed: return true; | 0 | ||||||||||||||||||
| 3858 | } | - | ||||||||||||||||||
| 3859 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 3860 | } | - | ||||||||||||||||||
| 3861 | - | |||||||||||||||||||
| 3862 | bool QInternal::unregisterCallback(Callback cb, qInternalCallback callback) | - | ||||||||||||||||||
| 3863 | { | - | ||||||||||||||||||
| 3864 | if (cb >= 0 && cb < QInternal::LastCallback) {
| 0 | ||||||||||||||||||
| 3865 | QInternal_CallBackTable *cbt = global_callback_table(); | - | ||||||||||||||||||
| 3866 | return (bool) cbt->callbacks[cb].removeAll(callback); never executed: return (bool) cbt->callbacks[cb].removeAll(callback); | 0 | ||||||||||||||||||
| 3867 | } | - | ||||||||||||||||||
| 3868 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 3869 | } | - | ||||||||||||||||||
| 3870 | - | |||||||||||||||||||
| 3871 | bool QInternal::activateCallbacks(Callback cb, void **parameters) | - | ||||||||||||||||||
| 3872 | { | - | ||||||||||||||||||
| 3873 | Q_ASSERT_X(cb >= 0, "QInternal::activateCallback()", "Callback id must be a valid id"); | - | ||||||||||||||||||
| 3874 | - | |||||||||||||||||||
| 3875 | QInternal_CallBackTable *cbt = global_callback_table(); | - | ||||||||||||||||||
| 3876 | if (cbt && cb < cbt->callbacks.size()) {
| 0-1774907 | ||||||||||||||||||
| 3877 | QList<qInternalCallback> callbacks = cbt->callbacks[cb]; | - | ||||||||||||||||||
| 3878 | bool ret = false; | - | ||||||||||||||||||
| 3879 | for (int i=0; i<callbacks.size(); ++i)
| 0 | ||||||||||||||||||
| 3880 | ret |= (callbacks.at(i))(parameters); never executed: ret |= (callbacks.at(i))(parameters); | 0 | ||||||||||||||||||
| 3881 | return ret; never executed: return ret; | 0 | ||||||||||||||||||
| 3882 | } | - | ||||||||||||||||||
| 3883 | return false; executed 1774910 times by 526 tests: return false;Executed by:
| 1774910 | ||||||||||||||||||
| 3884 | } | - | ||||||||||||||||||
| 3885 | - | |||||||||||||||||||
| 3886 | /*! | - | ||||||||||||||||||
| 3887 | \macro Q_BYTE_ORDER | - | ||||||||||||||||||
| 3888 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3889 | - | |||||||||||||||||||
| 3890 | This macro can be used to determine the byte order your system | - | ||||||||||||||||||
| 3891 | uses for storing data in memory. i.e., whether your system is | - | ||||||||||||||||||
| 3892 | little-endian or big-endian. It is set by Qt to one of the macros | - | ||||||||||||||||||
| 3893 | Q_LITTLE_ENDIAN or Q_BIG_ENDIAN. You normally won't need to worry | - | ||||||||||||||||||
| 3894 | about endian-ness, but you might, for example if you need to know | - | ||||||||||||||||||
| 3895 | which byte of an integer or UTF-16 character is stored in the | - | ||||||||||||||||||
| 3896 | lowest address. Endian-ness is important in networking, where | - | ||||||||||||||||||
| 3897 | computers with different values for Q_BYTE_ORDER must pass data | - | ||||||||||||||||||
| 3898 | back and forth. | - | ||||||||||||||||||
| 3899 | - | |||||||||||||||||||
| 3900 | Use this macro as in the following examples. | - | ||||||||||||||||||
| 3901 | - | |||||||||||||||||||
| 3902 | \snippet code/src_corelib_global_qglobal.cpp 40 | - | ||||||||||||||||||
| 3903 | - | |||||||||||||||||||
| 3904 | \sa Q_BIG_ENDIAN, Q_LITTLE_ENDIAN | - | ||||||||||||||||||
| 3905 | */ | - | ||||||||||||||||||
| 3906 | - | |||||||||||||||||||
| 3907 | /*! | - | ||||||||||||||||||
| 3908 | \macro Q_LITTLE_ENDIAN | - | ||||||||||||||||||
| 3909 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3910 | - | |||||||||||||||||||
| 3911 | This macro represents a value you can compare to the macro | - | ||||||||||||||||||
| 3912 | Q_BYTE_ORDER to determine the endian-ness of your system. In a | - | ||||||||||||||||||
| 3913 | little-endian system, the least significant byte is stored at the | - | ||||||||||||||||||
| 3914 | lowest address. The other bytes follow in increasing order of | - | ||||||||||||||||||
| 3915 | significance. | - | ||||||||||||||||||
| 3916 | - | |||||||||||||||||||
| 3917 | \snippet code/src_corelib_global_qglobal.cpp 41 | - | ||||||||||||||||||
| 3918 | - | |||||||||||||||||||
| 3919 | \sa Q_BYTE_ORDER, Q_BIG_ENDIAN | - | ||||||||||||||||||
| 3920 | */ | - | ||||||||||||||||||
| 3921 | - | |||||||||||||||||||
| 3922 | /*! | - | ||||||||||||||||||
| 3923 | \macro Q_BIG_ENDIAN | - | ||||||||||||||||||
| 3924 | \relates <QtGlobal> | - | ||||||||||||||||||
| 3925 | - | |||||||||||||||||||
| 3926 | This macro represents a value you can compare to the macro | - | ||||||||||||||||||
| 3927 | Q_BYTE_ORDER to determine the endian-ness of your system. In a | - | ||||||||||||||||||
| 3928 | big-endian system, the most significant byte is stored at the | - | ||||||||||||||||||
| 3929 | lowest address. The other bytes follow in decreasing order of | - | ||||||||||||||||||
| 3930 | significance. | - | ||||||||||||||||||
| 3931 | - | |||||||||||||||||||
| 3932 | \snippet code/src_corelib_global_qglobal.cpp 42 | - | ||||||||||||||||||
| 3933 | - | |||||||||||||||||||
| 3934 | \sa Q_BYTE_ORDER, Q_LITTLE_ENDIAN | - | ||||||||||||||||||
| 3935 | */ | - | ||||||||||||||||||
| 3936 | - | |||||||||||||||||||
| 3937 | /*! | - | ||||||||||||||||||
| 3938 | \macro Q_GLOBAL_STATIC(type, name) | - | ||||||||||||||||||
| 3939 | \internal | - | ||||||||||||||||||
| 3940 | - | |||||||||||||||||||
| 3941 | Declares a global static variable with the given \a type and \a name. | - | ||||||||||||||||||
| 3942 | - | |||||||||||||||||||
| 3943 | Use this macro to instantiate an object in a thread-safe way, creating | - | ||||||||||||||||||
| 3944 | a global pointer that can be used to refer to it. | - | ||||||||||||||||||
| 3945 | - | |||||||||||||||||||
| 3946 | \warning This macro is subject to a race condition that can cause the object | - | ||||||||||||||||||
| 3947 | to be constructed twice. However, if this occurs, the second instance will | - | ||||||||||||||||||
| 3948 | be immediately deleted. | - | ||||||||||||||||||
| 3949 | - | |||||||||||||||||||
| 3950 | See also | - | ||||||||||||||||||
| 3951 | \l{http://www.aristeia.com/publications.html}{"C++ and the perils of Double-Checked Locking"} | - | ||||||||||||||||||
| 3952 | by Scott Meyers and Andrei Alexandrescu. | - | ||||||||||||||||||
| 3953 | */ | - | ||||||||||||||||||
| 3954 | - | |||||||||||||||||||
| 3955 | /*! | - | ||||||||||||||||||
| 3956 | \macro Q_GLOBAL_STATIC_WITH_ARGS(type, name, arguments) | - | ||||||||||||||||||
| 3957 | \internal | - | ||||||||||||||||||
| 3958 | - | |||||||||||||||||||
| 3959 | Declares a global static variable with the specified \a type and \a name. | - | ||||||||||||||||||
| 3960 | - | |||||||||||||||||||
| 3961 | Use this macro to instantiate an object using the \a arguments specified | - | ||||||||||||||||||
| 3962 | in a thread-safe way, creating a global pointer that can be used to refer | - | ||||||||||||||||||
| 3963 | to it. | - | ||||||||||||||||||
| 3964 | - | |||||||||||||||||||
| 3965 | \warning This macro is subject to a race condition that can cause the object | - | ||||||||||||||||||
| 3966 | to be constructed twice. However, if this occurs, the second instance will | - | ||||||||||||||||||
| 3967 | be immediately deleted. | - | ||||||||||||||||||
| 3968 | - | |||||||||||||||||||
| 3969 | See also | - | ||||||||||||||||||
| 3970 | \l{http://www.aristeia.com/publications.html}{"C++ and the perils of Double-Checked Locking"} | - | ||||||||||||||||||
| 3971 | by Scott Meyers and Andrei Alexandrescu. | - | ||||||||||||||||||
| 3972 | */ | - | ||||||||||||||||||
| 3973 | - | |||||||||||||||||||
| 3974 | /*! | - | ||||||||||||||||||
| 3975 | \macro QT_NAMESPACE | - | ||||||||||||||||||
| 3976 | \internal | - | ||||||||||||||||||
| 3977 | - | |||||||||||||||||||
| 3978 | If this macro is defined to \c ns all Qt classes are put in a namespace | - | ||||||||||||||||||
| 3979 | called \c ns. Also, moc will output code putting metaobjects etc. | - | ||||||||||||||||||
| 3980 | into namespace \c ns. | - | ||||||||||||||||||
| 3981 | - | |||||||||||||||||||
| 3982 | \sa QT_BEGIN_NAMESPACE, QT_END_NAMESPACE, | - | ||||||||||||||||||
| 3983 | QT_PREPEND_NAMESPACE, QT_USE_NAMESPACE, | - | ||||||||||||||||||
| 3984 | QT_BEGIN_INCLUDE_NAMESPACE, QT_END_INCLUDE_NAMESPACE, | - | ||||||||||||||||||
| 3985 | QT_BEGIN_MOC_NAMESPACE, QT_END_MOC_NAMESPACE, | - | ||||||||||||||||||
| 3986 | */ | - | ||||||||||||||||||
| 3987 | - | |||||||||||||||||||
| 3988 | /*! | - | ||||||||||||||||||
| 3989 | \macro QT_PREPEND_NAMESPACE(identifier) | - | ||||||||||||||||||
| 3990 | \internal | - | ||||||||||||||||||
| 3991 | - | |||||||||||||||||||
| 3992 | This macro qualifies \a identifier with the full namespace. | - | ||||||||||||||||||
| 3993 | It expands to \c{::QT_NAMESPACE::identifier} if \c QT_NAMESPACE is defined | - | ||||||||||||||||||
| 3994 | and only \a identifier otherwise. | - | ||||||||||||||||||
| 3995 | - | |||||||||||||||||||
| 3996 | \sa QT_NAMESPACE | - | ||||||||||||||||||
| 3997 | */ | - | ||||||||||||||||||
| 3998 | - | |||||||||||||||||||
| 3999 | /*! | - | ||||||||||||||||||
| 4000 | \macro QT_USE_NAMESPACE | - | ||||||||||||||||||
| 4001 | \internal | - | ||||||||||||||||||
| 4002 | - | |||||||||||||||||||
| 4003 | This macro expands to using QT_NAMESPACE if QT_NAMESPACE is defined | - | ||||||||||||||||||
| 4004 | and nothing otherwise. | - | ||||||||||||||||||
| 4005 | - | |||||||||||||||||||
| 4006 | \sa QT_NAMESPACE | - | ||||||||||||||||||
| 4007 | */ | - | ||||||||||||||||||
| 4008 | - | |||||||||||||||||||
| 4009 | /*! | - | ||||||||||||||||||
| 4010 | \macro QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
| 4011 | \internal | - | ||||||||||||||||||
| 4012 | - | |||||||||||||||||||
| 4013 | This macro expands to | - | ||||||||||||||||||
| 4014 | - | |||||||||||||||||||
| 4015 | \snippet code/src_corelib_global_qglobal.cpp begin namespace macro | - | ||||||||||||||||||
| 4016 | - | |||||||||||||||||||
| 4017 | if \c QT_NAMESPACE is defined and nothing otherwise. If should always | - | ||||||||||||||||||
| 4018 | appear in the file-level scope and be followed by \c QT_END_NAMESPACE | - | ||||||||||||||||||
| 4019 | at the same logical level with respect to preprocessor conditionals | - | ||||||||||||||||||
| 4020 | in the same file. | - | ||||||||||||||||||
| 4021 | - | |||||||||||||||||||
| 4022 | As a rule of thumb, \c QT_BEGIN_NAMESPACE should appear in all Qt header | - | ||||||||||||||||||
| 4023 | and Qt source files after the last \c{#include} line and before the first | - | ||||||||||||||||||
| 4024 | declaration. | - | ||||||||||||||||||
| 4025 | - | |||||||||||||||||||
| 4026 | If that rule can't be followed because, e.g., \c{#include} lines and | - | ||||||||||||||||||
| 4027 | declarations are wildly mixed, place \c QT_BEGIN_NAMESPACE before | - | ||||||||||||||||||
| 4028 | the first declaration and wrap the \c{#include} lines in | - | ||||||||||||||||||
| 4029 | \c QT_BEGIN_INCLUDE_NAMESPACE and \c QT_END_INCLUDE_NAMESPACE. | - | ||||||||||||||||||
| 4030 | - | |||||||||||||||||||
| 4031 | When using the \c QT_NAMESPACE feature in user code | - | ||||||||||||||||||
| 4032 | (e.g., when building plugins statically linked to Qt) where | - | ||||||||||||||||||
| 4033 | the user code is not intended to go into the \c QT_NAMESPACE | - | ||||||||||||||||||
| 4034 | namespace, all forward declarations of Qt classes need to | - | ||||||||||||||||||
| 4035 | be wrapped in \c QT_BEGIN_NAMESPACE and \c QT_END_NAMESPACE. | - | ||||||||||||||||||
| 4036 | After that, a \c QT_USE_NAMESPACE should follow. | - | ||||||||||||||||||
| 4037 | No further changes should be needed. | - | ||||||||||||||||||
| 4038 | - | |||||||||||||||||||
| 4039 | \sa QT_NAMESPACE | - | ||||||||||||||||||
| 4040 | */ | - | ||||||||||||||||||
| 4041 | - | |||||||||||||||||||
| 4042 | /*! | - | ||||||||||||||||||
| 4043 | \macro QT_END_NAMESPACE | - | ||||||||||||||||||
| 4044 | \internal | - | ||||||||||||||||||
| 4045 | - | |||||||||||||||||||
| 4046 | This macro expands to | - | ||||||||||||||||||
| 4047 | - | |||||||||||||||||||
| 4048 | \snippet code/src_corelib_global_qglobal.cpp end namespace macro | - | ||||||||||||||||||
| 4049 | - | |||||||||||||||||||
| 4050 | if \c QT_NAMESPACE is defined and nothing otherwise. It is used to cancel | - | ||||||||||||||||||
| 4051 | the effect of \c QT_BEGIN_NAMESPACE. | - | ||||||||||||||||||
| 4052 | - | |||||||||||||||||||
| 4053 | If a source file ends with a \c{#include} directive that includes a moc file, | - | ||||||||||||||||||
| 4054 | \c QT_END_NAMESPACE should be placed before that \c{#include}. | - | ||||||||||||||||||
| 4055 | - | |||||||||||||||||||
| 4056 | \sa QT_NAMESPACE | - | ||||||||||||||||||
| 4057 | */ | - | ||||||||||||||||||
| 4058 | - | |||||||||||||||||||
| 4059 | /*! | - | ||||||||||||||||||
| 4060 | \macro QT_BEGIN_INCLUDE_NAMESPACE | - | ||||||||||||||||||
| 4061 | \internal | - | ||||||||||||||||||
| 4062 | - | |||||||||||||||||||
| 4063 | This macro is equivalent to \c QT_END_NAMESPACE. | - | ||||||||||||||||||
| 4064 | It only serves as syntactic sugar and is intended | - | ||||||||||||||||||
| 4065 | to be used before #include lines within a | - | ||||||||||||||||||
| 4066 | \c QT_BEGIN_NAMESPACE ... \c QT_END_NAMESPACE block. | - | ||||||||||||||||||
| 4067 | - | |||||||||||||||||||
| 4068 | \sa QT_NAMESPACE | - | ||||||||||||||||||
| 4069 | */ | - | ||||||||||||||||||
| 4070 | - | |||||||||||||||||||
| 4071 | /*! | - | ||||||||||||||||||
| 4072 | \macro QT_END_INCLUDE_NAMESPACE | - | ||||||||||||||||||
| 4073 | \internal | - | ||||||||||||||||||
| 4074 | - | |||||||||||||||||||
| 4075 | This macro is equivalent to \c QT_BEGIN_NAMESPACE. | - | ||||||||||||||||||
| 4076 | It only serves as syntactic sugar and is intended | - | ||||||||||||||||||
| 4077 | to be used after #include lines within a | - | ||||||||||||||||||
| 4078 | \c QT_BEGIN_NAMESPACE ... \c QT_END_NAMESPACE block. | - | ||||||||||||||||||
| 4079 | - | |||||||||||||||||||
| 4080 | \sa QT_NAMESPACE | - | ||||||||||||||||||
| 4081 | */ | - | ||||||||||||||||||
| 4082 | - | |||||||||||||||||||
| 4083 | /*! | - | ||||||||||||||||||
| 4084 | \macro QT_BEGIN_MOC_NAMESPACE | - | ||||||||||||||||||
| 4085 | \internal | - | ||||||||||||||||||
| 4086 | - | |||||||||||||||||||
| 4087 | This macro is output by moc at the beginning of | - | ||||||||||||||||||
| 4088 | moc files. It is equivalent to \c QT_USE_NAMESPACE. | - | ||||||||||||||||||
| 4089 | - | |||||||||||||||||||
| 4090 | \sa QT_NAMESPACE | - | ||||||||||||||||||
| 4091 | */ | - | ||||||||||||||||||
| 4092 | - | |||||||||||||||||||
| 4093 | /*! | - | ||||||||||||||||||
| 4094 | \macro QT_END_MOC_NAMESPACE | - | ||||||||||||||||||
| 4095 | \internal | - | ||||||||||||||||||
| 4096 | - | |||||||||||||||||||
| 4097 | This macro is output by moc at the beginning of | - | ||||||||||||||||||
| 4098 | moc files. It expands to nothing. | - | ||||||||||||||||||
| 4099 | - | |||||||||||||||||||
| 4100 | \sa QT_NAMESPACE | - | ||||||||||||||||||
| 4101 | */ | - | ||||||||||||||||||
| 4102 | - | |||||||||||||||||||
| 4103 | /*! | - | ||||||||||||||||||
| 4104 | \fn bool qFuzzyCompare(double p1, double p2) | - | ||||||||||||||||||
| 4105 | \relates <QtGlobal> | - | ||||||||||||||||||
| 4106 | \since 4.4 | - | ||||||||||||||||||
| 4107 | \threadsafe | - | ||||||||||||||||||
| 4108 | - | |||||||||||||||||||
| 4109 | Compares the floating point value \a p1 and \a p2 and | - | ||||||||||||||||||
| 4110 | returns \c true if they are considered equal, otherwise \c false. | - | ||||||||||||||||||
| 4111 | - | |||||||||||||||||||
| 4112 | Note that comparing values where either \a p1 or \a p2 is 0.0 will not work, | - | ||||||||||||||||||
| 4113 | nor does comparing values where one of the values is NaN or infinity. | - | ||||||||||||||||||
| 4114 | If one of the values is always 0.0, use qFuzzyIsNull instead. If one of the | - | ||||||||||||||||||
| 4115 | values is likely to be 0.0, one solution is to add 1.0 to both values. | - | ||||||||||||||||||
| 4116 | - | |||||||||||||||||||
| 4117 | \snippet code/src_corelib_global_qglobal.cpp 46 | - | ||||||||||||||||||
| 4118 | - | |||||||||||||||||||
| 4119 | The two numbers are compared in a relative way, where the | - | ||||||||||||||||||
| 4120 | exactness is stronger the smaller the numbers are. | - | ||||||||||||||||||
| 4121 | */ | - | ||||||||||||||||||
| 4122 | - | |||||||||||||||||||
| 4123 | /*! | - | ||||||||||||||||||
| 4124 | \fn bool qFuzzyCompare(float p1, float p2) | - | ||||||||||||||||||
| 4125 | \relates <QtGlobal> | - | ||||||||||||||||||
| 4126 | \since 4.4 | - | ||||||||||||||||||
| 4127 | \threadsafe | - | ||||||||||||||||||
| 4128 | - | |||||||||||||||||||
| 4129 | Compares the floating point value \a p1 and \a p2 and | - | ||||||||||||||||||
| 4130 | returns \c true if they are considered equal, otherwise \c false. | - | ||||||||||||||||||
| 4131 | - | |||||||||||||||||||
| 4132 | The two numbers are compared in a relative way, where the | - | ||||||||||||||||||
| 4133 | exactness is stronger the smaller the numbers are. | - | ||||||||||||||||||
| 4134 | */ | - | ||||||||||||||||||
| 4135 | - | |||||||||||||||||||
| 4136 | /*! | - | ||||||||||||||||||
| 4137 | \macro QT_REQUIRE_VERSION(int argc, char **argv, const char *version) | - | ||||||||||||||||||
| 4138 | \relates <QtGlobal> | - | ||||||||||||||||||
| 4139 | - | |||||||||||||||||||
| 4140 | This macro can be used to ensure that the application is run | - | ||||||||||||||||||
| 4141 | against a recent enough version of Qt. This is especially useful | - | ||||||||||||||||||
| 4142 | if your application depends on a specific bug fix introduced in a | - | ||||||||||||||||||
| 4143 | bug-fix release (e.g., 4.0.2). | - | ||||||||||||||||||
| 4144 | - | |||||||||||||||||||
| 4145 | The \a argc and \a argv parameters are the \c main() function's | - | ||||||||||||||||||
| 4146 | \c argc and \c argv parameters. The \a version parameter is a | - | ||||||||||||||||||
| 4147 | string literal that specifies which version of Qt the application | - | ||||||||||||||||||
| 4148 | requires (e.g., "4.0.2"). | - | ||||||||||||||||||
| 4149 | - | |||||||||||||||||||
| 4150 | Example: | - | ||||||||||||||||||
| 4151 | - | |||||||||||||||||||
| 4152 | \snippet code/src_gui_dialogs_qmessagebox.cpp 4 | - | ||||||||||||||||||
| 4153 | */ | - | ||||||||||||||||||
| 4154 | - | |||||||||||||||||||
| 4155 | /*! | - | ||||||||||||||||||
| 4156 | \macro Q_DECL_EXPORT | - | ||||||||||||||||||
| 4157 | \relates <QtGlobal> | - | ||||||||||||||||||
| 4158 | - | |||||||||||||||||||
| 4159 | This macro marks a symbol for shared library export (see | - | ||||||||||||||||||
| 4160 | \l{sharedlibrary.html}{Creating Shared Libraries}). | - | ||||||||||||||||||
| 4161 | - | |||||||||||||||||||
| 4162 | \sa Q_DECL_IMPORT | - | ||||||||||||||||||
| 4163 | */ | - | ||||||||||||||||||
| 4164 | - | |||||||||||||||||||
| 4165 | /*! | - | ||||||||||||||||||
| 4166 | \macro Q_DECL_IMPORT | - | ||||||||||||||||||
| 4167 | \relates <QtGlobal> | - | ||||||||||||||||||
| 4168 | - | |||||||||||||||||||
| 4169 | This macro declares a symbol to be an import from a shared library (see | - | ||||||||||||||||||
| 4170 | \l{sharedlibrary.html}{Creating Shared Libraries}). | - | ||||||||||||||||||
| 4171 | - | |||||||||||||||||||
| 4172 | \sa Q_DECL_EXPORT | - | ||||||||||||||||||
| 4173 | */ | - | ||||||||||||||||||
| 4174 | - | |||||||||||||||||||
| 4175 | /*! | - | ||||||||||||||||||
| 4176 | \macro Q_DECL_CONSTEXPR | - | ||||||||||||||||||
| 4177 | \relates <QtGlobal> | - | ||||||||||||||||||
| 4178 | - | |||||||||||||||||||
| 4179 | This macro can be used to declare variable that should be constructed at compile-time, | - | ||||||||||||||||||
| 4180 | or an inline function that can be computed at compile-time. | - | ||||||||||||||||||
| 4181 | - | |||||||||||||||||||
| 4182 | It expands to "constexpr" if your compiler supports that C++11 keyword, or to nothing | - | ||||||||||||||||||
| 4183 | otherwise. | - | ||||||||||||||||||
| 4184 | - | |||||||||||||||||||
| 4185 | \sa Q_DECL_RELAXED_CONSTEXPR | - | ||||||||||||||||||
| 4186 | */ | - | ||||||||||||||||||
| 4187 | - | |||||||||||||||||||
| 4188 | /*! | - | ||||||||||||||||||
| 4189 | \macro Q_DECL_RELAXED_CONSTEXPR | - | ||||||||||||||||||
| 4190 | \relates <QtGlobal> | - | ||||||||||||||||||
| 4191 | - | |||||||||||||||||||
| 4192 | This macro can be used to declare an inline function that can be computed | - | ||||||||||||||||||
| 4193 | at compile-time according to the relaxed rules from C++14. | - | ||||||||||||||||||
| 4194 | - | |||||||||||||||||||
| 4195 | It expands to "constexpr" if your compiler supports C++14 relaxed constant | - | ||||||||||||||||||
| 4196 | expressions, or to nothing otherwise. | - | ||||||||||||||||||
| 4197 | - | |||||||||||||||||||
| 4198 | \sa Q_DECL_CONSTEXPR | - | ||||||||||||||||||
| 4199 | */ | - | ||||||||||||||||||
| 4200 | - | |||||||||||||||||||
| 4201 | /*! | - | ||||||||||||||||||
| 4202 | \macro qDebug(const char *message, ...) | - | ||||||||||||||||||
| 4203 | \relates <QtGlobal> | - | ||||||||||||||||||
| 4204 | - | |||||||||||||||||||
| 4205 | Calls the message handler with the debug message \a message. If no | - | ||||||||||||||||||
| 4206 | message handler has been installed, the message is printed to | - | ||||||||||||||||||
| 4207 | stderr. Under Windows the message is sent to the console, if it is a | - | ||||||||||||||||||
| 4208 | console application; otherwise, it is sent to the debugger. On Blackberry, the | - | ||||||||||||||||||
| 4209 | message is sent to slogger2. This function does nothing if \c QT_NO_DEBUG_OUTPUT | - | ||||||||||||||||||
| 4210 | was defined during compilation. | - | ||||||||||||||||||
| 4211 | - | |||||||||||||||||||
| 4212 | If you pass the function a format string and a list of arguments, | - | ||||||||||||||||||
| 4213 | it works in similar way to the C printf() function. The format | - | ||||||||||||||||||
| 4214 | should be a Latin-1 string. | - | ||||||||||||||||||
| 4215 | - | |||||||||||||||||||
| 4216 | Example: | - | ||||||||||||||||||
| 4217 | - | |||||||||||||||||||
| 4218 | \snippet code/src_corelib_global_qglobal.cpp 24 | - | ||||||||||||||||||
| 4219 | - | |||||||||||||||||||
| 4220 | If you include \c <QtDebug>, a more convenient syntax is also | - | ||||||||||||||||||
| 4221 | available: | - | ||||||||||||||||||
| 4222 | - | |||||||||||||||||||
| 4223 | \snippet code/src_corelib_global_qglobal.cpp 25 | - | ||||||||||||||||||
| 4224 | - | |||||||||||||||||||
| 4225 | With this syntax, the function returns a QDebug object that is | - | ||||||||||||||||||
| 4226 | configured to use the QtDebugMsg message type. It automatically | - | ||||||||||||||||||
| 4227 | puts a single space between each item, and outputs a newline at | - | ||||||||||||||||||
| 4228 | the end. It supports many C++ and Qt types. | - | ||||||||||||||||||
| 4229 | - | |||||||||||||||||||
| 4230 | To suppress the output at run-time, install your own message handler | - | ||||||||||||||||||
| 4231 | with qInstallMessageHandler(). | - | ||||||||||||||||||
| 4232 | - | |||||||||||||||||||
| 4233 | \sa qInfo(), qWarning(), qCritical(), qFatal(), qInstallMessageHandler(), | - | ||||||||||||||||||
| 4234 | {Debugging Techniques} | - | ||||||||||||||||||
| 4235 | */ | - | ||||||||||||||||||
| 4236 | - | |||||||||||||||||||
| 4237 | /*! | - | ||||||||||||||||||
| 4238 | \macro qInfo(const char *message, ...) | - | ||||||||||||||||||
| 4239 | \relates <QtGlobal> | - | ||||||||||||||||||
| 4240 | \since 5.5 | - | ||||||||||||||||||
| 4241 | - | |||||||||||||||||||
| 4242 | Calls the message handler with the informational message \a message. If no | - | ||||||||||||||||||
| 4243 | message handler has been installed, the message is printed to | - | ||||||||||||||||||
| 4244 | stderr. Under Windows, the message is sent to the console, if it is a | - | ||||||||||||||||||
| 4245 | console application; otherwise, it is sent to the debugger. On Blackberry the | - | ||||||||||||||||||
| 4246 | message is sent to slogger2. This function does nothing if \c QT_NO_INFO_OUTPUT | - | ||||||||||||||||||
| 4247 | was defined during compilation. | - | ||||||||||||||||||
| 4248 | - | |||||||||||||||||||
| 4249 | If you pass the function a format string and a list of arguments, | - | ||||||||||||||||||
| 4250 | it works in similar way to the C printf() function. The format | - | ||||||||||||||||||
| 4251 | should be a Latin-1 string. | - | ||||||||||||||||||
| 4252 | - | |||||||||||||||||||
| 4253 | Example: | - | ||||||||||||||||||
| 4254 | - | |||||||||||||||||||
| 4255 | \snippet code/src_corelib_global_qglobal.cpp qInfo_printf | - | ||||||||||||||||||
| 4256 | - | |||||||||||||||||||
| 4257 | If you include \c <QtDebug>, a more convenient syntax is also | - | ||||||||||||||||||
| 4258 | available: | - | ||||||||||||||||||
| 4259 | - | |||||||||||||||||||
| 4260 | \snippet code/src_corelib_global_qglobal.cpp qInfo_stream | - | ||||||||||||||||||
| 4261 | - | |||||||||||||||||||
| 4262 | With this syntax, the function returns a QDebug object that is | - | ||||||||||||||||||
| 4263 | configured to use the QtInfoMsg message type. It automatically | - | ||||||||||||||||||
| 4264 | puts a single space between each item, and outputs a newline at | - | ||||||||||||||||||
| 4265 | the end. It supports many C++ and Qt types. | - | ||||||||||||||||||
| 4266 | - | |||||||||||||||||||
| 4267 | To suppress the output at run-time, install your own message handler | - | ||||||||||||||||||
| 4268 | with qInstallMessageHandler(). | - | ||||||||||||||||||
| 4269 | - | |||||||||||||||||||
| 4270 | \sa qDebug(), qWarning(), qCritical(), qFatal(), qInstallMessageHandler(), | - | ||||||||||||||||||
| 4271 | {Debugging Techniques} | - | ||||||||||||||||||
| 4272 | */ | - | ||||||||||||||||||
| 4273 | - | |||||||||||||||||||
| 4274 | /*! | - | ||||||||||||||||||
| 4275 | \macro qWarning(const char *message, ...) | - | ||||||||||||||||||
| 4276 | \relates <QtGlobal> | - | ||||||||||||||||||
| 4277 | - | |||||||||||||||||||
| 4278 | Calls the message handler with the warning message \a message. If no | - | ||||||||||||||||||
| 4279 | message handler has been installed, the message is printed to | - | ||||||||||||||||||
| 4280 | stderr. Under Windows, the message is sent to the debugger. | - | ||||||||||||||||||
| 4281 | On Blackberry the message is sent to slogger2. This | - | ||||||||||||||||||
| 4282 | function does nothing if \c QT_NO_WARNING_OUTPUT was defined | - | ||||||||||||||||||
| 4283 | during compilation; it exits if the environment variable \c | - | ||||||||||||||||||
| 4284 | QT_FATAL_WARNINGS is not empty. | - | ||||||||||||||||||
| 4285 | - | |||||||||||||||||||
| 4286 | This function takes a format string and a list of arguments, | - | ||||||||||||||||||
| 4287 | similar to the C printf() function. The format should be a Latin-1 | - | ||||||||||||||||||
| 4288 | string. | - | ||||||||||||||||||
| 4289 | - | |||||||||||||||||||
| 4290 | Example: | - | ||||||||||||||||||
| 4291 | \snippet code/src_corelib_global_qglobal.cpp 26 | - | ||||||||||||||||||
| 4292 | - | |||||||||||||||||||
| 4293 | If you include <QtDebug>, a more convenient syntax is | - | ||||||||||||||||||
| 4294 | also available: | - | ||||||||||||||||||
| 4295 | - | |||||||||||||||||||
| 4296 | \snippet code/src_corelib_global_qglobal.cpp 27 | - | ||||||||||||||||||
| 4297 | - | |||||||||||||||||||
| 4298 | This syntax inserts a space between each item, and | - | ||||||||||||||||||
| 4299 | appends a newline at the end. | - | ||||||||||||||||||
| 4300 | - | |||||||||||||||||||
| 4301 | To suppress the output at runtime, install your own message handler | - | ||||||||||||||||||
| 4302 | with qInstallMessageHandler(). | - | ||||||||||||||||||
| 4303 | - | |||||||||||||||||||
| 4304 | \sa qDebug(), qInfo(), qCritical(), qFatal(), qInstallMessageHandler(), | - | ||||||||||||||||||
| 4305 | {Debugging Techniques} | - | ||||||||||||||||||
| 4306 | */ | - | ||||||||||||||||||
| 4307 | - | |||||||||||||||||||
| 4308 | /*! | - | ||||||||||||||||||
| 4309 | \macro qCritical(const char *message, ...) | - | ||||||||||||||||||
| 4310 | \relates <QtGlobal> | - | ||||||||||||||||||
| 4311 | - | |||||||||||||||||||
| 4312 | Calls the message handler with the critical message \a message. If no | - | ||||||||||||||||||
| 4313 | message handler has been installed, the message is printed to | - | ||||||||||||||||||
| 4314 | stderr. Under Windows, the message is sent to the debugger. | - | ||||||||||||||||||
| 4315 | On Blackberry the message is sent to slogger2. | - | ||||||||||||||||||
| 4316 | - | |||||||||||||||||||
| 4317 | It exits if the environment variable QT_FATAL_CRITICALS is not empty. | - | ||||||||||||||||||
| 4318 | - | |||||||||||||||||||
| 4319 | This function takes a format string and a list of arguments, | - | ||||||||||||||||||
| 4320 | similar to the C printf() function. The format should be a Latin-1 | - | ||||||||||||||||||
| 4321 | string. | - | ||||||||||||||||||
| 4322 | - | |||||||||||||||||||
| 4323 | Example: | - | ||||||||||||||||||
| 4324 | \snippet code/src_corelib_global_qglobal.cpp 28 | - | ||||||||||||||||||
| 4325 | - | |||||||||||||||||||
| 4326 | If you include <QtDebug>, a more convenient syntax is | - | ||||||||||||||||||
| 4327 | also available: | - | ||||||||||||||||||
| 4328 | - | |||||||||||||||||||
| 4329 | \snippet code/src_corelib_global_qglobal.cpp 29 | - | ||||||||||||||||||
| 4330 | - | |||||||||||||||||||
| 4331 | A space is inserted between the items, and a newline is | - | ||||||||||||||||||
| 4332 | appended at the end. | - | ||||||||||||||||||
| 4333 | - | |||||||||||||||||||
| 4334 | To suppress the output at runtime, install your own message handler | - | ||||||||||||||||||
| 4335 | with qInstallMessageHandler(). | - | ||||||||||||||||||
| 4336 | - | |||||||||||||||||||
| 4337 | \sa qDebug(), qInfo(), qWarning(), qFatal(), qInstallMessageHandler(), | - | ||||||||||||||||||
| 4338 | {Debugging Techniques} | - | ||||||||||||||||||
| 4339 | */ | - | ||||||||||||||||||
| 4340 | - | |||||||||||||||||||
| 4341 | /*! | - | ||||||||||||||||||
| 4342 | \macro qFatal(const char *message, ...) | - | ||||||||||||||||||
| 4343 | \relates <QtGlobal> | - | ||||||||||||||||||
| 4344 | - | |||||||||||||||||||
| 4345 | Calls the message handler with the fatal message \a message. If no | - | ||||||||||||||||||
| 4346 | message handler has been installed, the message is printed to | - | ||||||||||||||||||
| 4347 | stderr. Under Windows, the message is sent to the debugger. | - | ||||||||||||||||||
| 4348 | On Blackberry the message is sent to slogger2. | - | ||||||||||||||||||
| 4349 | - | |||||||||||||||||||
| 4350 | If you are using the \b{default message handler} this function will | - | ||||||||||||||||||
| 4351 | abort on Unix systems to create a core dump. On Windows, for debug builds, | - | ||||||||||||||||||
| 4352 | this function will report a _CRT_ERROR enabling you to connect a debugger | - | ||||||||||||||||||
| 4353 | to the application. | - | ||||||||||||||||||
| 4354 | - | |||||||||||||||||||
| 4355 | This function takes a format string and a list of arguments, | - | ||||||||||||||||||
| 4356 | similar to the C printf() function. | - | ||||||||||||||||||
| 4357 | - | |||||||||||||||||||
| 4358 | Example: | - | ||||||||||||||||||
| 4359 | \snippet code/src_corelib_global_qglobal.cpp 30 | - | ||||||||||||||||||
| 4360 | - | |||||||||||||||||||
| 4361 | To suppress the output at runtime, install your own message handler | - | ||||||||||||||||||
| 4362 | with qInstallMessageHandler(). | - | ||||||||||||||||||
| 4363 | - | |||||||||||||||||||
| 4364 | \sa qDebug(), qInfo(), qWarning(), qCritical(), qInstallMessageHandler(), | - | ||||||||||||||||||
| 4365 | {Debugging Techniques} | - | ||||||||||||||||||
| 4366 | */ | - | ||||||||||||||||||
| 4367 | - | |||||||||||||||||||
| 4368 | /*! | - | ||||||||||||||||||
| 4369 | \macro qMove(x) | - | ||||||||||||||||||
| 4370 | \relates <QtGlobal> | - | ||||||||||||||||||
| 4371 | - | |||||||||||||||||||
| 4372 | It expands to "std::move" if your compiler supports that C++11 function, or to nothing | - | ||||||||||||||||||
| 4373 | otherwise. | - | ||||||||||||||||||
| 4374 | - | |||||||||||||||||||
| 4375 | qMove takes an rvalue reference to its parameter \a x, and converts it to an xvalue. | - | ||||||||||||||||||
| 4376 | */ | - | ||||||||||||||||||
| 4377 | - | |||||||||||||||||||
| 4378 | /*! | - | ||||||||||||||||||
| 4379 | \macro Q_DECL_NOTHROW | - | ||||||||||||||||||
| 4380 | \relates <QtGlobal> | - | ||||||||||||||||||
| 4381 | \since 5.0 | - | ||||||||||||||||||
| 4382 | - | |||||||||||||||||||
| 4383 | This macro marks a function as never throwing, under no | - | ||||||||||||||||||
| 4384 | circumstances. If the function does nevertheless throw, the | - | ||||||||||||||||||
| 4385 | behaviour is undefined. | - | ||||||||||||||||||
| 4386 | - | |||||||||||||||||||
| 4387 | The macro expands to either "throw()", if that has some benefit on | - | ||||||||||||||||||
| 4388 | the compiler, or to C++11 noexcept, if available, or to nothing | - | ||||||||||||||||||
| 4389 | otherwise. | - | ||||||||||||||||||
| 4390 | - | |||||||||||||||||||
| 4391 | If you need C++11 noexcept semantics, don't use this macro, use | - | ||||||||||||||||||
| 4392 | Q_DECL_NOEXCEPT/Q_DECL_NOEXCEPT_EXPR instead. | - | ||||||||||||||||||
| 4393 | - | |||||||||||||||||||
| 4394 | \sa Q_DECL_NOEXCEPT, Q_DECL_NOEXCEPT_EXPR() | - | ||||||||||||||||||
| 4395 | */ | - | ||||||||||||||||||
| 4396 | - | |||||||||||||||||||
| 4397 | /*! | - | ||||||||||||||||||
| 4398 | \macro QT_TERMINATE_ON_EXCEPTION(expr) | - | ||||||||||||||||||
| 4399 | \relates <QtGlobal> | - | ||||||||||||||||||
| 4400 | \internal | - | ||||||||||||||||||
| 4401 | - | |||||||||||||||||||
| 4402 | In general, use of the Q_DECL_NOEXCEPT macro is preferred over | - | ||||||||||||||||||
| 4403 | Q_DECL_NOTHROW, because it exhibits well-defined behavior and | - | ||||||||||||||||||
| 4404 | supports the more powerful Q_DECL_NOEXCEPT_EXPR variant. However, | - | ||||||||||||||||||
| 4405 | use of Q_DECL_NOTHROW has the advantage that Windows builds | - | ||||||||||||||||||
| 4406 | benefit on a wide range or compiler versions that do not yet | - | ||||||||||||||||||
| 4407 | support the C++11 noexcept feature. | - | ||||||||||||||||||
| 4408 | - | |||||||||||||||||||
| 4409 | It may therefore be beneficial to use Q_DECL_NOTHROW and emulate | - | ||||||||||||||||||
| 4410 | the C++11 behavior manually with an embedded try/catch. | - | ||||||||||||||||||
| 4411 | - | |||||||||||||||||||
| 4412 | Qt provides the QT_TERMINATE_ON_EXCEPTION(expr) macro for this | - | ||||||||||||||||||
| 4413 | purpose. It either expands to \c expr (if Qt is compiled without | - | ||||||||||||||||||
| 4414 | exception support or the compiler supports C++11 noexcept | - | ||||||||||||||||||
| 4415 | semantics) or to | - | ||||||||||||||||||
| 4416 | \code | - | ||||||||||||||||||
| 4417 | try { expr; } catch(...) { qTerminate(); } | - | ||||||||||||||||||
| 4418 | \endcode | - | ||||||||||||||||||
| 4419 | otherwise. | - | ||||||||||||||||||
| 4420 | - | |||||||||||||||||||
| 4421 | Since this macro expands to just \c expr if the compiler supports | - | ||||||||||||||||||
| 4422 | C++11 noexcept, expecting the compiler to take over responsibility | - | ||||||||||||||||||
| 4423 | of calling std::terminate() in that case, it should not be used | - | ||||||||||||||||||
| 4424 | outside Q_DECL_NOTHROW functions. | - | ||||||||||||||||||
| 4425 | - | |||||||||||||||||||
| 4426 | \sa Q_DECL_NOEXCEPT, Q_DECL_NOTHROW, qTerminate() | - | ||||||||||||||||||
| 4427 | */ | - | ||||||||||||||||||
| 4428 | - | |||||||||||||||||||
| 4429 | /*! | - | ||||||||||||||||||
| 4430 | \macro Q_DECL_NOEXCEPT | - | ||||||||||||||||||
| 4431 | \relates <QtGlobal> | - | ||||||||||||||||||
| 4432 | \since 5.0 | - | ||||||||||||||||||
| 4433 | - | |||||||||||||||||||
| 4434 | This macro marks a function as never throwing. If the function | - | ||||||||||||||||||
| 4435 | does nevertheless throw, the behaviour is defined: | - | ||||||||||||||||||
| 4436 | std::terminate() is called. | - | ||||||||||||||||||
| 4437 | - | |||||||||||||||||||
| 4438 | The macro expands to C++11 noexcept, if available, or to nothing | - | ||||||||||||||||||
| 4439 | otherwise. | - | ||||||||||||||||||
| 4440 | - | |||||||||||||||||||
| 4441 | If you need the operator version of C++11 noexcept, use | - | ||||||||||||||||||
| 4442 | Q_DECL_NOEXCEPT_EXPR(x). | - | ||||||||||||||||||
| 4443 | - | |||||||||||||||||||
| 4444 | If you don't need C++11 noexcept semantics, e.g. because your | - | ||||||||||||||||||
| 4445 | function can't possibly throw, don't use this macro, use | - | ||||||||||||||||||
| 4446 | Q_DECL_NOTHROW instead. | - | ||||||||||||||||||
| 4447 | - | |||||||||||||||||||
| 4448 | \sa Q_DECL_NOTHROW, Q_DECL_NOEXCEPT_EXPR() | - | ||||||||||||||||||
| 4449 | */ | - | ||||||||||||||||||
| 4450 | - | |||||||||||||||||||
| 4451 | /*! | - | ||||||||||||||||||
| 4452 | \macro Q_DECL_NOEXCEPT_EXPR(x) | - | ||||||||||||||||||
| 4453 | \relates <QtGlobal> | - | ||||||||||||||||||
| 4454 | \since 5.0 | - | ||||||||||||||||||
| 4455 | - | |||||||||||||||||||
| 4456 | This macro marks a function as non-throwing if \a x is \c true. If | - | ||||||||||||||||||
| 4457 | the function does nevertheless throw, the behaviour is defined: | - | ||||||||||||||||||
| 4458 | std::terminate() is called. | - | ||||||||||||||||||
| 4459 | - | |||||||||||||||||||
| 4460 | The macro expands to C++11 noexcept(x), if available, or to | - | ||||||||||||||||||
| 4461 | nothing otherwise. | - | ||||||||||||||||||
| 4462 | - | |||||||||||||||||||
| 4463 | If you need the always-true version of C++11 noexcept, use | - | ||||||||||||||||||
| 4464 | Q_DECL_NOEXCEPT. | - | ||||||||||||||||||
| 4465 | - | |||||||||||||||||||
| 4466 | If you don't need C++11 noexcept semantics, e.g. because your | - | ||||||||||||||||||
| 4467 | function can't possibly throw, don't use this macro, use | - | ||||||||||||||||||
| 4468 | Q_DECL_NOTHROW instead. | - | ||||||||||||||||||
| 4469 | - | |||||||||||||||||||
| 4470 | \sa Q_DECL_NOTHROW, Q_DECL_NOEXCEPT | - | ||||||||||||||||||
| 4471 | */ | - | ||||||||||||||||||
| 4472 | - | |||||||||||||||||||
| 4473 | /*! | - | ||||||||||||||||||
| 4474 | \macro Q_DECL_OVERRIDE | - | ||||||||||||||||||
| 4475 | \since 5.0 | - | ||||||||||||||||||
| 4476 | \relates <QtGlobal> | - | ||||||||||||||||||
| 4477 | - | |||||||||||||||||||
| 4478 | This macro can be used to declare an overriding virtual | - | ||||||||||||||||||
| 4479 | function. Use of this markup will allow the compiler to generate | - | ||||||||||||||||||
| 4480 | an error if the overriding virtual function does not in fact | - | ||||||||||||||||||
| 4481 | override anything. | - | ||||||||||||||||||
| 4482 | - | |||||||||||||||||||
| 4483 | It expands to "override" if your compiler supports that C++11 | - | ||||||||||||||||||
| 4484 | contextual keyword, or to nothing otherwise. | - | ||||||||||||||||||
| 4485 | - | |||||||||||||||||||
| 4486 | The macro goes at the end of the function, usually after the | - | ||||||||||||||||||
| 4487 | \c{const}, if any: | - | ||||||||||||||||||
| 4488 | \code | - | ||||||||||||||||||
| 4489 | // generate error if this doesn't actually override anything: | - | ||||||||||||||||||
| 4490 | virtual void MyWidget::paintEvent(QPaintEvent*) Q_DECL_OVERRIDE; | - | ||||||||||||||||||
| 4491 | \endcode | - | ||||||||||||||||||
| 4492 | - | |||||||||||||||||||
| 4493 | \sa Q_DECL_FINAL | - | ||||||||||||||||||
| 4494 | */ | - | ||||||||||||||||||
| 4495 | - | |||||||||||||||||||
| 4496 | /*! | - | ||||||||||||||||||
| 4497 | \macro Q_DECL_FINAL | - | ||||||||||||||||||
| 4498 | \since 5.0 | - | ||||||||||||||||||
| 4499 | \relates <QtGlobal> | - | ||||||||||||||||||
| 4500 | - | |||||||||||||||||||
| 4501 | This macro can be used to declare an overriding virtual or a class | - | ||||||||||||||||||
| 4502 | as "final", with Java semantics. Further-derived classes can then | - | ||||||||||||||||||
| 4503 | no longer override this virtual function, or inherit from this | - | ||||||||||||||||||
| 4504 | class, respectively. | - | ||||||||||||||||||
| 4505 | - | |||||||||||||||||||
| 4506 | It expands to "final" if your compiler supports that C++11 | - | ||||||||||||||||||
| 4507 | contextual keyword, or something non-standard if your compiler | - | ||||||||||||||||||
| 4508 | supports something close enough to the C++11 semantics, or to | - | ||||||||||||||||||
| 4509 | nothing otherwise. | - | ||||||||||||||||||
| 4510 | - | |||||||||||||||||||
| 4511 | The macro goes at the end of the function, usually after the | - | ||||||||||||||||||
| 4512 | \c{const}, if any: | - | ||||||||||||||||||
| 4513 | \code | - | ||||||||||||||||||
| 4514 | // more-derived classes no longer permitted to override this: | - | ||||||||||||||||||
| 4515 | virtual void MyWidget::paintEvent(QPaintEvent*) Q_DECL_FINAL; | - | ||||||||||||||||||
| 4516 | \endcode | - | ||||||||||||||||||
| 4517 | - | |||||||||||||||||||
| 4518 | For classes, it goes in front of the \c{:} in the class | - | ||||||||||||||||||
| 4519 | definition, if any: | - | ||||||||||||||||||
| 4520 | \code | - | ||||||||||||||||||
| 4521 | class QRect Q_DECL_FINAL { // cannot be derived from | - | ||||||||||||||||||
| 4522 | // ... | - | ||||||||||||||||||
| 4523 | }; | - | ||||||||||||||||||
| 4524 | \endcode | - | ||||||||||||||||||
| 4525 | - | |||||||||||||||||||
| 4526 | \sa Q_DECL_OVERRIDE | - | ||||||||||||||||||
| 4527 | */ | - | ||||||||||||||||||
| 4528 | - | |||||||||||||||||||
| 4529 | /*! | - | ||||||||||||||||||
| 4530 | \macro Q_FORWARD_DECLARE_OBJC_CLASS(classname) | - | ||||||||||||||||||
| 4531 | \since 5.2 | - | ||||||||||||||||||
| 4532 | \relates <QtGlobal> | - | ||||||||||||||||||
| 4533 | - | |||||||||||||||||||
| 4534 | Forward-declares an Objective-C \a classname in a manner such that it can be | - | ||||||||||||||||||
| 4535 | compiled as either Objective-C or C++. | - | ||||||||||||||||||
| 4536 | - | |||||||||||||||||||
| 4537 | This is primarily intended for use in header files that may be included by | - | ||||||||||||||||||
| 4538 | both Objective-C and C++ source files. | - | ||||||||||||||||||
| 4539 | */ | - | ||||||||||||||||||
| 4540 | - | |||||||||||||||||||
| 4541 | /*! | - | ||||||||||||||||||
| 4542 | \macro Q_FORWARD_DECLARE_CF_TYPE(type) | - | ||||||||||||||||||
| 4543 | \since 5.2 | - | ||||||||||||||||||
| 4544 | \relates <QtGlobal> | - | ||||||||||||||||||
| 4545 | - | |||||||||||||||||||
| 4546 | Forward-declares a Core Foundation \a type. This includes the actual | - | ||||||||||||||||||
| 4547 | type and the ref type. For example, Q_FORWARD_DECLARE_CF_TYPE(CFString) | - | ||||||||||||||||||
| 4548 | declares __CFString and CFStringRef. | - | ||||||||||||||||||
| 4549 | */ | - | ||||||||||||||||||
| 4550 | - | |||||||||||||||||||
| 4551 | /*! | - | ||||||||||||||||||
| 4552 | \macro Q_FORWARD_DECLARE_MUTABLE_CF_TYPE(type) | - | ||||||||||||||||||
| 4553 | \since 5.2 | - | ||||||||||||||||||
| 4554 | \relates <QtGlobal> | - | ||||||||||||||||||
| 4555 | - | |||||||||||||||||||
| 4556 | Forward-declares a mutable Core Foundation \a type. This includes the actual | - | ||||||||||||||||||
| 4557 | type and the ref type. For example, Q_FORWARD_DECLARE_MUTABLE_CF_TYPE(CFMutableString) | - | ||||||||||||||||||
| 4558 | declares __CFMutableString and CFMutableStringRef. | - | ||||||||||||||||||
| 4559 | */ | - | ||||||||||||||||||
| 4560 | - | |||||||||||||||||||
| 4561 | QT_END_NAMESPACE | - | ||||||||||||||||||
| Source code | Switch to Preprocessed file |