LCOV - code coverage report
Current view: top level - home/aheinecke/dev/main/qt5/include/QtCore - qglobal.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 11 11 100.0 %
Date: 2018-11-14 16:53:58 Functions: 37 52 71.2 %

          Line data    Source code
       1             : /****************************************************************************
       2             : **
       3             : ** Copyright (C) 2016 The Qt Company Ltd.
       4             : ** Copyright (C) 2016 Intel Corporation.
       5             : ** Contact: https://www.qt.io/licensing/
       6             : **
       7             : ** This file is part of the QtCore module of the Qt Toolkit.
       8             : **
       9             : ** $QT_BEGIN_LICENSE:LGPL$
      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 https://www.qt.io/terms-conditions. For further
      16             : ** information use the contact form at https://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 3 as published by the Free Software
      21             : ** Foundation and appearing in the file LICENSE.LGPL3 included in the
      22             : ** packaging of this file. Please review the following information to
      23             : ** ensure the GNU Lesser General Public License version 3 requirements
      24             : ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
      25             : **
      26             : ** GNU General Public License Usage
      27             : ** Alternatively, this file may be used under the terms of the GNU
      28             : ** General Public License version 2.0 or (at your option) the GNU General
      29             : ** Public license version 3 or any later version approved by the KDE Free
      30             : ** Qt Foundation. The licenses are as published by the Free Software
      31             : ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
      32             : ** included in the packaging of this file. Please review the following
      33             : ** information to ensure the GNU General Public License requirements will
      34             : ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
      35             : ** https://www.gnu.org/licenses/gpl-3.0.html.
      36             : **
      37             : ** $QT_END_LICENSE$
      38             : **
      39             : ****************************************************************************/
      40             : 
      41             : #ifndef QGLOBAL_H
      42             : #define QGLOBAL_H
      43             : 
      44             : #ifdef __cplusplus
      45             : #  include <type_traits>
      46             : #  include <cstddef>
      47             : #  include <utility>
      48             : #endif
      49             : #ifndef __ASSEMBLER__
      50             : #  include <stddef.h>
      51             : #endif
      52             : 
      53             : /*
      54             :    QT_VERSION is (major << 16) + (minor << 8) + patch.
      55             : */
      56             : #define QT_VERSION      QT_VERSION_CHECK(QT_VERSION_MAJOR, QT_VERSION_MINOR, QT_VERSION_PATCH)
      57             : /*
      58             :    can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
      59             : */
      60             : #define QT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch))
      61             : 
      62             : #ifdef QT_BOOTSTRAPPED
      63             : #include <QtCore/qconfig-bootstrapped.h>
      64             : #else
      65             : #include <QtCore/qconfig.h>
      66             : #include <QtCore/qtcore-config.h>
      67             : #endif
      68             : 
      69             : // The QT_SUPPORTS macro is deprecated. Don't use it in new code.
      70             : // Instead, use QT_CONFIG(feature)
      71             : // ### Qt6: remove macro
      72             : #ifdef _MSC_VER
      73             : #  define QT_SUPPORTS(FEATURE) (!defined QT_NO_##FEATURE)
      74             : #else
      75             : #  define QT_SUPPORTS(FEATURE) (!defined(QT_NO_##FEATURE))
      76             : #endif
      77             : 
      78             : /*
      79             :     The QT_CONFIG macro implements a safe compile time check for features of Qt.
      80             :     Features can be in three states:
      81             :         0 or undefined: This will lead to a compile error when testing for it
      82             :         -1: The feature is not available
      83             :         1: The feature is available
      84             : */
      85             : #define QT_CONFIG(feature) (1/QT_FEATURE_##feature == 1)
      86             : #define QT_REQUIRE_CONFIG(feature) Q_STATIC_ASSERT_X(QT_FEATURE_##feature == 1, "Required feature " #feature " for file " __FILE__ " not available.")
      87             : 
      88             : #if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
      89             : #  define QT_NO_UNSHARABLE_CONTAINERS
      90             : #endif
      91             : 
      92             : /* These two macros makes it possible to turn the builtin line expander into a
      93             :  * string literal. */
      94             : #define QT_STRINGIFY2(x) #x
      95             : #define QT_STRINGIFY(x) QT_STRINGIFY2(x)
      96             : 
      97             : #include <QtCore/qsystemdetection.h>
      98             : #include <QtCore/qprocessordetection.h>
      99             : #include <QtCore/qcompilerdetection.h>
     100             : 
     101             : #if defined (__ELF__)
     102             : #  define Q_OF_ELF
     103             : #endif
     104             : #if defined (__MACH__) && defined (__APPLE__)
     105             : #  define Q_OF_MACH_O
     106             : #endif
     107             : 
     108             : #ifdef __cplusplus
     109             : 
     110             : #include <algorithm>
     111             : 
     112             : #if !defined(QT_NAMESPACE) || defined(Q_MOC_RUN) /* user namespace */
     113             : 
     114             : # define QT_PREPEND_NAMESPACE(name) ::name
     115             : # define QT_USE_NAMESPACE
     116             : # define QT_BEGIN_NAMESPACE
     117             : # define QT_END_NAMESPACE
     118             : # define QT_BEGIN_INCLUDE_NAMESPACE
     119             : # define QT_END_INCLUDE_NAMESPACE
     120             : #ifndef QT_BEGIN_MOC_NAMESPACE
     121             : # define QT_BEGIN_MOC_NAMESPACE
     122             : #endif
     123             : #ifndef QT_END_MOC_NAMESPACE
     124             : # define QT_END_MOC_NAMESPACE
     125             : #endif
     126             : # define QT_FORWARD_DECLARE_CLASS(name) class name;
     127             : # define QT_FORWARD_DECLARE_STRUCT(name) struct name;
     128             : # define QT_MANGLE_NAMESPACE(name) name
     129             : 
     130             : #else /* user namespace */
     131             : 
     132             : # define QT_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name
     133             : # define QT_USE_NAMESPACE using namespace ::QT_NAMESPACE;
     134             : # define QT_BEGIN_NAMESPACE namespace QT_NAMESPACE {
     135             : # define QT_END_NAMESPACE }
     136             : # define QT_BEGIN_INCLUDE_NAMESPACE }
     137             : # define QT_END_INCLUDE_NAMESPACE namespace QT_NAMESPACE {
     138             : #ifndef QT_BEGIN_MOC_NAMESPACE
     139             : # define QT_BEGIN_MOC_NAMESPACE QT_USE_NAMESPACE
     140             : #endif
     141             : #ifndef QT_END_MOC_NAMESPACE
     142             : # define QT_END_MOC_NAMESPACE
     143             : #endif
     144             : # define QT_FORWARD_DECLARE_CLASS(name) \
     145             :     QT_BEGIN_NAMESPACE class name; QT_END_NAMESPACE \
     146             :     using QT_PREPEND_NAMESPACE(name);
     147             : 
     148             : # define QT_FORWARD_DECLARE_STRUCT(name) \
     149             :     QT_BEGIN_NAMESPACE struct name; QT_END_NAMESPACE \
     150             :     using QT_PREPEND_NAMESPACE(name);
     151             : 
     152             : # define QT_MANGLE_NAMESPACE0(x) x
     153             : # define QT_MANGLE_NAMESPACE1(a, b) a##_##b
     154             : # define QT_MANGLE_NAMESPACE2(a, b) QT_MANGLE_NAMESPACE1(a,b)
     155             : # define QT_MANGLE_NAMESPACE(name) QT_MANGLE_NAMESPACE2( \
     156             :         QT_MANGLE_NAMESPACE0(name), QT_MANGLE_NAMESPACE0(QT_NAMESPACE))
     157             : 
     158             : namespace QT_NAMESPACE {}
     159             : 
     160             : # ifndef QT_BOOTSTRAPPED
     161             : # ifndef QT_NO_USING_NAMESPACE
     162             :    /*
     163             :     This expands to a "using QT_NAMESPACE" also in _header files_.
     164             :     It is the only way the feature can be used without too much
     165             :     pain, but if people _really_ do not want it they can add
     166             :     DEFINES += QT_NO_USING_NAMESPACE to their .pro files.
     167             :     */
     168             :    QT_USE_NAMESPACE
     169             : # endif
     170             : # endif
     171             : 
     172             : #endif /* user namespace */
     173             : 
     174             : #else /* __cplusplus */
     175             : 
     176             : # define QT_BEGIN_NAMESPACE
     177             : # define QT_END_NAMESPACE
     178             : # define QT_USE_NAMESPACE
     179             : # define QT_BEGIN_INCLUDE_NAMESPACE
     180             : # define QT_END_INCLUDE_NAMESPACE
     181             : 
     182             : #endif /* __cplusplus */
     183             : 
     184             : // ### Qt6: remove me.
     185             : #define QT_BEGIN_HEADER
     186             : #define QT_END_HEADER
     187             : 
     188             : #if defined(Q_OS_DARWIN) && !defined(QT_LARGEFILE_SUPPORT)
     189             : #  define QT_LARGEFILE_SUPPORT 64
     190             : #endif
     191             : 
     192             : #ifndef __ASSEMBLER__
     193             : QT_BEGIN_NAMESPACE
     194             : 
     195             : /*
     196             :    Size-dependent types (architechture-dependent byte order)
     197             : 
     198             :    Make sure to update QMetaType when changing these typedefs
     199             : */
     200             : 
     201             : typedef signed char qint8;         /* 8 bit signed */
     202             : typedef unsigned char quint8;      /* 8 bit unsigned */
     203             : typedef short qint16;              /* 16 bit signed */
     204             : typedef unsigned short quint16;    /* 16 bit unsigned */
     205             : typedef int qint32;                /* 32 bit signed */
     206             : typedef unsigned int quint32;      /* 32 bit unsigned */
     207             : #if defined(Q_OS_WIN) && !defined(Q_CC_GNU)
     208             : #  define Q_INT64_C(c) c ## i64    /* signed 64 bit constant */
     209             : #  define Q_UINT64_C(c) c ## ui64   /* unsigned 64 bit constant */
     210             : typedef __int64 qint64;            /* 64 bit signed */
     211             : typedef unsigned __int64 quint64;  /* 64 bit unsigned */
     212             : #else
     213             : #  define Q_INT64_C(c) static_cast<long long>(c ## LL)     /* signed 64 bit constant */
     214             : #  define Q_UINT64_C(c) static_cast<unsigned long long>(c ## ULL) /* unsigned 64 bit constant */
     215             : typedef long long qint64;           /* 64 bit signed */
     216             : typedef unsigned long long quint64; /* 64 bit unsigned */
     217             : #endif
     218             : 
     219             : typedef qint64 qlonglong;
     220             : typedef quint64 qulonglong;
     221             : 
     222             : /*
     223             :    Useful type definitions for Qt
     224             : */
     225             : 
     226             : QT_BEGIN_INCLUDE_NAMESPACE
     227             : typedef unsigned char uchar;
     228             : typedef unsigned short ushort;
     229             : typedef unsigned int uint;
     230             : typedef unsigned long ulong;
     231             : QT_END_INCLUDE_NAMESPACE
     232             : 
     233             : #if defined(QT_COORD_TYPE)
     234             : typedef QT_COORD_TYPE qreal;
     235             : #else
     236             : typedef double qreal;
     237             : #endif
     238             : 
     239             : #if defined(QT_NO_DEPRECATED)
     240             : #  undef QT_DEPRECATED
     241             : #  undef QT_DEPRECATED_X
     242             : #  undef QT_DEPRECATED_VARIABLE
     243             : #  undef QT_DEPRECATED_CONSTRUCTOR
     244             : #elif defined(QT_DEPRECATED_WARNINGS)
     245             : #  undef QT_DEPRECATED
     246             : #  define QT_DEPRECATED Q_DECL_DEPRECATED
     247             : #  undef QT_DEPRECATED_X
     248             : #  define QT_DEPRECATED_X(text) Q_DECL_DEPRECATED_X(text)
     249             : #  undef QT_DEPRECATED_VARIABLE
     250             : #  define QT_DEPRECATED_VARIABLE Q_DECL_VARIABLE_DEPRECATED
     251             : #  undef QT_DEPRECATED_CONSTRUCTOR
     252             : #  define QT_DEPRECATED_CONSTRUCTOR explicit Q_DECL_CONSTRUCTOR_DEPRECATED
     253             : #else
     254             : #  undef QT_DEPRECATED
     255             : #  define QT_DEPRECATED
     256             : #  undef QT_DEPRECATED_X
     257             : #  define QT_DEPRECATED_X(text)
     258             : #  undef QT_DEPRECATED_VARIABLE
     259             : #  define QT_DEPRECATED_VARIABLE
     260             : #  undef QT_DEPRECATED_CONSTRUCTOR
     261             : #  define QT_DEPRECATED_CONSTRUCTOR
     262             : #endif
     263             : 
     264             : #ifndef QT_DISABLE_DEPRECATED_BEFORE
     265             : #define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(5, 0, 0)
     266             : #endif
     267             : 
     268             : /*
     269             :     QT_DEPRECATED_SINCE(major, minor) evaluates as true if the Qt version is greater than
     270             :     the deprecation point specified.
     271             : 
     272             :     Use it to specify from which version of Qt a function or class has been deprecated
     273             : 
     274             :     Example:
     275             :         #if QT_DEPRECATED_SINCE(5,1)
     276             :             QT_DEPRECATED void deprecatedFunction(); //function deprecated since Qt 5.1
     277             :         #endif
     278             : 
     279             : */
     280             : #ifdef QT_DEPRECATED
     281             : #define QT_DEPRECATED_SINCE(major, minor) (QT_VERSION_CHECK(major, minor, 0) > QT_DISABLE_DEPRECATED_BEFORE)
     282             : #else
     283             : #define QT_DEPRECATED_SINCE(major, minor) 0
     284             : #endif
     285             : 
     286             : /*
     287             :    The Qt modules' export macros.
     288             :    The options are:
     289             :     - defined(QT_STATIC): Qt was built or is being built in static mode
     290             :     - defined(QT_SHARED): Qt was built or is being built in shared/dynamic mode
     291             :    If neither was defined, then QT_SHARED is implied. If Qt was compiled in static
     292             :    mode, QT_STATIC is defined in qconfig.h. In shared mode, QT_STATIC is implied
     293             :    for the bootstrapped tools.
     294             : */
     295             : 
     296             : #ifdef QT_BOOTSTRAPPED
     297             : #  ifdef QT_SHARED
     298             : #    error "QT_SHARED and QT_BOOTSTRAPPED together don't make sense. Please fix the build"
     299             : #  elif !defined(QT_STATIC)
     300             : #    define QT_STATIC
     301             : #  endif
     302             : #endif
     303             : 
     304             : #if defined(QT_SHARED) || !defined(QT_STATIC)
     305             : #  ifdef QT_STATIC
     306             : #    error "Both QT_SHARED and QT_STATIC defined, please make up your mind"
     307             : #  endif
     308             : #  ifndef QT_SHARED
     309             : #    define QT_SHARED
     310             : #  endif
     311             : #  if defined(QT_BUILD_CORE_LIB)
     312             : #    define Q_CORE_EXPORT Q_DECL_EXPORT
     313             : #  else
     314             : #    define Q_CORE_EXPORT Q_DECL_IMPORT
     315             : #  endif
     316             : #else
     317             : #  define Q_CORE_EXPORT
     318             : #endif
     319             : 
     320             : /*
     321             :    Some classes do not permit copies to be made of an object. These
     322             :    classes contains a private copy constructor and assignment
     323             :    operator to disable copying (the compiler gives an error message).
     324             : */
     325             : #define Q_DISABLE_COPY(Class) \
     326             :     Class(const Class &) Q_DECL_EQ_DELETE;\
     327             :     Class &operator=(const Class &) Q_DECL_EQ_DELETE;
     328             : 
     329             : /*
     330             :    No, this is not an evil backdoor. QT_BUILD_INTERNAL just exports more symbols
     331             :    for Qt's internal unit tests. If you want slower loading times and more
     332             :    symbols that can vanish from version to version, feel free to define QT_BUILD_INTERNAL.
     333             : */
     334             : #if defined(QT_BUILD_INTERNAL) && defined(QT_BUILDING_QT) && defined(QT_SHARED)
     335             : #    define Q_AUTOTEST_EXPORT Q_DECL_EXPORT
     336             : #elif defined(QT_BUILD_INTERNAL) && defined(QT_SHARED)
     337             : #    define Q_AUTOTEST_EXPORT Q_DECL_IMPORT
     338             : #else
     339             : #    define Q_AUTOTEST_EXPORT
     340             : #endif
     341             : 
     342             : #define Q_INIT_RESOURCE(name) \
     343             :     do { extern int QT_MANGLE_NAMESPACE(qInitResources_ ## name) ();       \
     344             :         QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); } while (false)
     345             : #define Q_CLEANUP_RESOURCE(name) \
     346             :     do { extern int QT_MANGLE_NAMESPACE(qCleanupResources_ ## name) ();    \
     347             :         QT_MANGLE_NAMESPACE(qCleanupResources_ ## name) (); } while (false)
     348             : 
     349             : /*
     350             :  * If we're compiling C++ code:
     351             :  *  - and this is a non-namespace build, declare qVersion as extern "C"
     352             :  *  - and this is a namespace build, declare it as a regular function
     353             :  *    (we're already inside QT_BEGIN_NAMESPACE / QT_END_NAMESPACE)
     354             :  * If we're compiling C code, simply declare the function. If Qt was compiled
     355             :  * in a namespace, qVersion isn't callable anyway.
     356             :  */
     357             : #if !defined(QT_NAMESPACE) && defined(__cplusplus) && !defined(Q_QDOC)
     358             : extern "C"
     359             : #endif
     360             : Q_CORE_EXPORT Q_DECL_CONST_FUNCTION const char *qVersion(void) Q_DECL_NOTHROW;
     361             : 
     362             : #if defined(__cplusplus)
     363             : 
     364             : #ifndef Q_CONSTRUCTOR_FUNCTION
     365             : # define Q_CONSTRUCTOR_FUNCTION0(AFUNC) \
     366             :     namespace { \
     367             :     static const struct AFUNC ## _ctor_class_ { \
     368             :         inline AFUNC ## _ctor_class_() { AFUNC(); } \
     369             :     } AFUNC ## _ctor_instance_; \
     370             :     }
     371             : 
     372             : # define Q_CONSTRUCTOR_FUNCTION(AFUNC) Q_CONSTRUCTOR_FUNCTION0(AFUNC)
     373             : #endif
     374             : 
     375             : #ifndef Q_DESTRUCTOR_FUNCTION
     376             : # define Q_DESTRUCTOR_FUNCTION0(AFUNC) \
     377             :     namespace { \
     378             :     static const struct AFUNC ## _dtor_class_ { \
     379             :         inline AFUNC ## _dtor_class_() { } \
     380             :         inline ~ AFUNC ## _dtor_class_() { AFUNC(); } \
     381             :     } AFUNC ## _dtor_instance_; \
     382             :     }
     383             : # define Q_DESTRUCTOR_FUNCTION(AFUNC) Q_DESTRUCTOR_FUNCTION0(AFUNC)
     384             : #endif
     385             : 
     386             : namespace QtPrivate {
     387             :     template <class T>
     388             :     struct AlignOfHelper
     389             :     {
     390             :         char c;
     391             :         T type;
     392             : 
     393             :         AlignOfHelper();
     394             :         ~AlignOfHelper();
     395             :     };
     396             : 
     397             :     template <class T>
     398             :     struct AlignOf_Default
     399             :     {
     400             :         enum { Value = sizeof(AlignOfHelper<T>) - sizeof(T) };
     401             :     };
     402             : 
     403             :     template <class T> struct AlignOf : AlignOf_Default<T> { };
     404             :     template <class T> struct AlignOf<T &> : AlignOf<T> {};
     405             :     template <size_t N, class T> struct AlignOf<T[N]> : AlignOf<T> {};
     406             : 
     407             : #ifdef Q_COMPILER_RVALUE_REFS
     408             :     template <class T> struct AlignOf<T &&> : AlignOf<T> {};
     409             : #endif
     410             : 
     411             : #if defined(Q_PROCESSOR_X86_32) && !defined(Q_OS_WIN)
     412             :     template <class T> struct AlignOf_WorkaroundForI386Abi { enum { Value = sizeof(T) }; };
     413             : 
     414             :     // x86 ABI weirdness
     415             :     // Alignment of naked type is 8, but inside struct has alignment 4.
     416             :     template <> struct AlignOf<double>  : AlignOf_WorkaroundForI386Abi<double> {};
     417             :     template <> struct AlignOf<qint64>  : AlignOf_WorkaroundForI386Abi<qint64> {};
     418             :     template <> struct AlignOf<quint64> : AlignOf_WorkaroundForI386Abi<quint64> {};
     419             : #ifdef Q_CC_CLANG
     420             :     // GCC and Clang seem to disagree wrt to alignment of arrays
     421             :     template <size_t N> struct AlignOf<double[N]>   : AlignOf_Default<double> {};
     422             :     template <size_t N> struct AlignOf<qint64[N]>   : AlignOf_Default<qint64> {};
     423             :     template <size_t N> struct AlignOf<quint64[N]>  : AlignOf_Default<quint64> {};
     424             : #endif
     425             : #endif
     426             : } // namespace QtPrivate
     427             : 
     428             : #define QT_EMULATED_ALIGNOF(T) \
     429             :     (size_t(QT_PREPEND_NAMESPACE(QtPrivate)::AlignOf<T>::Value))
     430             : 
     431             : #ifndef Q_ALIGNOF
     432             : #define Q_ALIGNOF(T) QT_EMULATED_ALIGNOF(T)
     433             : #endif
     434             : 
     435             : 
     436             : /*
     437             :   quintptr and qptrdiff is guaranteed to be the same size as a pointer, i.e.
     438             : 
     439             :       sizeof(void *) == sizeof(quintptr)
     440             :       && sizeof(void *) == sizeof(qptrdiff)
     441             : 
     442             :   size_t and qsizetype are not guaranteed to be the same size as a pointer, but
     443             :   they usually are.
     444             : */
     445             : template <int> struct QIntegerForSize;
     446             : template <>    struct QIntegerForSize<1> { typedef quint8  Unsigned; typedef qint8  Signed; };
     447             : template <>    struct QIntegerForSize<2> { typedef quint16 Unsigned; typedef qint16 Signed; };
     448             : template <>    struct QIntegerForSize<4> { typedef quint32 Unsigned; typedef qint32 Signed; };
     449             : template <>    struct QIntegerForSize<8> { typedef quint64 Unsigned; typedef qint64 Signed; };
     450             : #if defined(Q_CC_GNU) && defined(__SIZEOF_INT128__)
     451             : template <>    struct QIntegerForSize<16> { __extension__ typedef unsigned __int128 Unsigned; __extension__ typedef __int128 Signed; };
     452             : #endif
     453             : template <class T> struct QIntegerForSizeof: QIntegerForSize<sizeof(T)> { };
     454             : typedef QIntegerForSize<Q_PROCESSOR_WORDSIZE>::Signed qregisterint;
     455             : typedef QIntegerForSize<Q_PROCESSOR_WORDSIZE>::Unsigned qregisteruint;
     456             : typedef QIntegerForSizeof<void*>::Unsigned quintptr;
     457             : typedef QIntegerForSizeof<void*>::Signed qptrdiff;
     458             : typedef qptrdiff qintptr;
     459             : using qsizetype = QIntegerForSizeof<std::size_t>::Signed;
     460             : 
     461             : /* moc compats (signals/slots) */
     462             : #ifndef QT_MOC_COMPAT
     463             : #  define QT_MOC_COMPAT
     464             : #else
     465             : #  undef QT_MOC_COMPAT
     466             : #  define QT_MOC_COMPAT
     467             : #endif
     468             : 
     469             : #ifdef QT_ASCII_CAST_WARNINGS
     470             : #  define QT_ASCII_CAST_WARN Q_DECL_DEPRECATED_X("Use fromUtf8, QStringLiteral, or QLatin1String")
     471             : #else
     472             : #  define QT_ASCII_CAST_WARN
     473             : #endif
     474             : 
     475             : #ifdef Q_PROCESSOR_X86_32
     476             : #  if defined(Q_CC_GNU)
     477             : #    define QT_FASTCALL __attribute__((regparm(3)))
     478             : #  elif defined(Q_CC_MSVC)
     479             : #    define QT_FASTCALL __fastcall
     480             : #  else
     481             : #     define QT_FASTCALL
     482             : #  endif
     483             : #else
     484             : #  define QT_FASTCALL
     485             : #endif
     486             : 
     487             : // enable gcc warnings for printf-style functions
     488             : #if defined(Q_CC_GNU) && !defined(__INSURE__)
     489             : #  if defined(Q_CC_MINGW) && !defined(Q_CC_CLANG)
     490             : #    define Q_ATTRIBUTE_FORMAT_PRINTF(A, B) \
     491             :          __attribute__((format(gnu_printf, (A), (B))))
     492             : #  else
     493             : #    define Q_ATTRIBUTE_FORMAT_PRINTF(A, B) \
     494             :          __attribute__((format(printf, (A), (B))))
     495             : #  endif
     496             : #else
     497             : #  define Q_ATTRIBUTE_FORMAT_PRINTF(A, B)
     498             : #endif
     499             : 
     500             : #ifdef Q_CC_MSVC
     501             : #  define Q_NEVER_INLINE __declspec(noinline)
     502             : #  define Q_ALWAYS_INLINE __forceinline
     503             : #elif defined(Q_CC_GNU)
     504             : #  define Q_NEVER_INLINE __attribute__((noinline))
     505             : #  define Q_ALWAYS_INLINE inline __attribute__((always_inline))
     506             : #else
     507             : #  define Q_NEVER_INLINE
     508             : #  define Q_ALWAYS_INLINE inline
     509             : #endif
     510             : 
     511             : #ifdef Q_CC_GNU
     512             : #  define QT_INIT_METAOBJECT __attribute__((init_priority(101)))
     513             : #else
     514             : #  define QT_INIT_METAOBJECT
     515             : #endif
     516             : 
     517             : //defines the type for the WNDPROC on windows
     518             : //the alignment needs to be forced for sse2 to not crash with mingw
     519             : #if defined(Q_OS_WIN)
     520             : #  if defined(Q_CC_MINGW) && !defined(Q_OS_WIN64)
     521             : #    define QT_ENSURE_STACK_ALIGNED_FOR_SSE __attribute__ ((force_align_arg_pointer))
     522             : #  else
     523             : #    define QT_ENSURE_STACK_ALIGNED_FOR_SSE
     524             : #  endif
     525             : #  define QT_WIN_CALLBACK CALLBACK QT_ENSURE_STACK_ALIGNED_FOR_SSE
     526             : #endif
     527             : 
     528             : typedef int QNoImplicitBoolCast;
     529             : 
     530             : /*
     531             :    Utility macros and inline functions
     532             : */
     533             : 
     534             : template <typename T>
     535             : Q_DECL_CONSTEXPR inline T qAbs(const T &t) { return t >= 0 ? t : -t; }
     536             : 
     537             : Q_DECL_CONSTEXPR inline int qRound(double d)
     538             : { return d >= 0.0 ? int(d + 0.5) : int(d - double(int(d-1)) + 0.5) + int(d-1); }
     539             : Q_DECL_CONSTEXPR inline int qRound(float d)
     540             : { return d >= 0.0f ? int(d + 0.5f) : int(d - float(int(d-1)) + 0.5f) + int(d-1); }
     541             : 
     542             : Q_DECL_CONSTEXPR inline qint64 qRound64(double d)
     543             : { return d >= 0.0 ? qint64(d + 0.5) : qint64(d - double(qint64(d-1)) + 0.5) + qint64(d-1); }
     544             : Q_DECL_CONSTEXPR inline qint64 qRound64(float d)
     545             : { return d >= 0.0f ? qint64(d + 0.5f) : qint64(d - float(qint64(d-1)) + 0.5f) + qint64(d-1); }
     546             : 
     547             : template <typename T>
     548           6 : Q_DECL_CONSTEXPR inline const T &qMin(const T &a, const T &b) { return (a < b) ? a : b; }
     549             : template <typename T>
     550        3818 : Q_DECL_CONSTEXPR inline const T &qMax(const T &a, const T &b) { return (a < b) ? b : a; }
     551             : template <typename T>
     552             : Q_DECL_CONSTEXPR inline const T &qBound(const T &min, const T &val, const T &max)
     553             : { return qMax(min, qMin(max, val)); }
     554             : 
     555             : #ifndef Q_FORWARD_DECLARE_OBJC_CLASS
     556             : #  ifdef __OBJC__
     557             : #    define Q_FORWARD_DECLARE_OBJC_CLASS(classname) @class classname
     558             : #  else
     559             : #    define Q_FORWARD_DECLARE_OBJC_CLASS(classname) typedef struct objc_object classname
     560             : #  endif
     561             : #endif
     562             : #ifndef Q_FORWARD_DECLARE_CF_TYPE
     563             : #  define Q_FORWARD_DECLARE_CF_TYPE(type) typedef const struct __ ## type * type ## Ref
     564             : #endif
     565             : #ifndef Q_FORWARD_DECLARE_MUTABLE_CF_TYPE
     566             : #  define Q_FORWARD_DECLARE_MUTABLE_CF_TYPE(type) typedef struct __ ## type * type ## Ref
     567             : #endif
     568             : #ifndef Q_FORWARD_DECLARE_CG_TYPE
     569             : #define Q_FORWARD_DECLARE_CG_TYPE(type) typedef const struct type *type ## Ref;
     570             : #endif
     571             : #ifndef Q_FORWARD_DECLARE_MUTABLE_CG_TYPE
     572             : #define Q_FORWARD_DECLARE_MUTABLE_CG_TYPE(type) typedef struct type *type ## Ref;
     573             : #endif
     574             : 
     575             : #ifdef Q_OS_DARWIN
     576             : #  define QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios, tvos, watchos) \
     577             :     ((defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && macos != __MAC_NA && __MAC_OS_X_VERSION_MAX_ALLOWED >= macos) || \
     578             :      (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && ios != __IPHONE_NA && __IPHONE_OS_VERSION_MAX_ALLOWED >= ios) || \
     579             :      (defined(__TV_OS_VERSION_MAX_ALLOWED) && tvos != __TVOS_NA && __TV_OS_VERSION_MAX_ALLOWED >= tvos) || \
     580             :      (defined(__WATCH_OS_VERSION_MAX_ALLOWED) && watchos != __WATCHOS_NA && __WATCH_OS_VERSION_MAX_ALLOWED >= watchos))
     581             : 
     582             : #  define QT_DARWIN_DEPLOYMENT_TARGET_BELOW(macos, ios, tvos, watchos) \
     583             :     ((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && macos != __MAC_NA && __MAC_OS_X_VERSION_MIN_REQUIRED < macos) || \
     584             :      (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && ios != __IPHONE_NA && __IPHONE_OS_VERSION_MIN_REQUIRED < ios) || \
     585             :      (defined(__TV_OS_VERSION_MIN_REQUIRED) && tvos != __TVOS_NA && __TV_OS_VERSION_MIN_REQUIRED < tvos) || \
     586             :      (defined(__WATCH_OS_VERSION_MIN_REQUIRED) && watchos != __WATCHOS_NA && __WATCH_OS_VERSION_MIN_REQUIRED < watchos))
     587             : 
     588             : #  define QT_MACOS_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios) \
     589             :       QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios, __TVOS_NA, __WATCHOS_NA)
     590             : #  define QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(macos) \
     591             :       QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, __IPHONE_NA, __TVOS_NA, __WATCHOS_NA)
     592             : #  define QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(ios) \
     593             :       QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, ios, __TVOS_NA, __WATCHOS_NA)
     594             : #  define QT_TVOS_PLATFORM_SDK_EQUAL_OR_ABOVE(tvos) \
     595             :       QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, __IPHONE_NA, tvos, __WATCHOS_NA)
     596             : #  define QT_WATCHOS_PLATFORM_SDK_EQUAL_OR_ABOVE(watchos) \
     597             :       QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, __IPHONE_NA, __TVOS_NA, watchos)
     598             : 
     599             : #  define QT_MACOS_IOS_DEPLOYMENT_TARGET_BELOW(macos, ios) \
     600             :       QT_DARWIN_DEPLOYMENT_TARGET_BELOW(macos, ios, __TVOS_NA, __WATCHOS_NA)
     601             : #  define QT_MACOS_DEPLOYMENT_TARGET_BELOW(macos) \
     602             :       QT_DARWIN_DEPLOYMENT_TARGET_BELOW(macos, __IPHONE_NA, __TVOS_NA, __WATCHOS_NA)
     603             : #  define QT_IOS_DEPLOYMENT_TARGET_BELOW(ios) \
     604             :       QT_DARWIN_DEPLOYMENT_TARGET_BELOW(__MAC_NA, ios, __TVOS_NA, __WATCHOS_NA)
     605             : #  define QT_TVOS_DEPLOYMENT_TARGET_BELOW(tvos) \
     606             :       QT_DARWIN_DEPLOYMENT_TARGET_BELOW(__MAC_NA, __IPHONE_NA, tvos, __WATCHOS_NA)
     607             : #  define QT_WATCHOS_DEPLOYMENT_TARGET_BELOW(watchos) \
     608             :       QT_DARWIN_DEPLOYMENT_TARGET_BELOW(__MAC_NA, __IPHONE_NA, __TVOS_NA, watchos)
     609             : 
     610             : // Compatibility synonyms, do not use
     611             : #  define QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(osx, ios) QT_MACOS_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(osx, ios)
     612             : #  define QT_MAC_DEPLOYMENT_TARGET_BELOW(osx, ios) QT_MACOS_IOS_DEPLOYMENT_TARGET_BELOW(osx, ios)
     613             : #  define QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(osx) QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(osx)
     614             : #  define QT_OSX_DEPLOYMENT_TARGET_BELOW(osx) QT_MACOS_DEPLOYMENT_TARGET_BELOW(osx)
     615             : 
     616             : // Implemented in qcore_mac_objc.mm
     617             : class Q_CORE_EXPORT QMacAutoReleasePool
     618             : {
     619             : public:
     620             :     QMacAutoReleasePool();
     621             :     ~QMacAutoReleasePool();
     622             : private:
     623             :     Q_DISABLE_COPY(QMacAutoReleasePool)
     624             :     void *pool;
     625             : };
     626             : 
     627             : #else
     628             : 
     629             : #define QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios, tvos, watchos) (0)
     630             : #define QT_MACOS_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios) (0)
     631             : #define QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(macos) (0)
     632             : #define QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(ios) (0)
     633             : #define QT_TVOS_PLATFORM_SDK_EQUAL_OR_ABOVE(tvos) (0)
     634             : #define QT_WATCHOS_PLATFORM_SDK_EQUAL_OR_ABOVE(watchos) (0)
     635             : 
     636             : #define QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(osx, ios) (0)
     637             : #define QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(osx) (0)
     638             : 
     639             : #endif // Q_OS_DARWIN
     640             : 
     641             : /*
     642             :    Data stream functions are provided by many classes (defined in qdatastream.h)
     643             : */
     644             : 
     645             : class QDataStream;
     646             : 
     647             : inline void qt_noop(void) {}
     648             : 
     649             : /* These wrap try/catch so we can switch off exceptions later.
     650             : 
     651             :    Beware - do not use more than one QT_CATCH per QT_TRY, and do not use
     652             :    the exception instance in the catch block.
     653             :    If you can't live with those constraints, don't use these macros.
     654             :    Use the QT_NO_EXCEPTIONS macro to protect your code instead.
     655             : */
     656             : 
     657             : #if !defined(QT_NO_EXCEPTIONS)
     658             : #  if !defined(Q_MOC_RUN)
     659             : #    if (defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) && !QT_HAS_FEATURE(cxx_exceptions)) || \
     660             :         (defined(Q_CC_GNU) && !defined(__EXCEPTIONS))
     661             : #      define QT_NO_EXCEPTIONS
     662             : #    endif
     663             : #  elif defined(QT_BOOTSTRAPPED)
     664             : #    define QT_NO_EXCEPTIONS
     665             : #  endif
     666             : #endif
     667             : 
     668             : #ifdef QT_NO_EXCEPTIONS
     669             : #  define QT_TRY if (true)
     670             : #  define QT_CATCH(A) else
     671             : #  define QT_THROW(A) qt_noop()
     672             : #  define QT_RETHROW qt_noop()
     673             : #  define QT_TERMINATE_ON_EXCEPTION(expr) do { expr; } while (false)
     674             : #else
     675             : #  define QT_TRY try
     676             : #  define QT_CATCH(A) catch (A)
     677             : #  define QT_THROW(A) throw A
     678             : #  define QT_RETHROW throw
     679             : Q_NORETURN Q_CORE_EXPORT void qTerminate() Q_DECL_NOTHROW;
     680             : #  ifdef Q_COMPILER_NOEXCEPT
     681             : #    define QT_TERMINATE_ON_EXCEPTION(expr) do { expr; } while (false)
     682             : #  else
     683             : #    define QT_TERMINATE_ON_EXCEPTION(expr) do { try { expr; } catch (...) { qTerminate(); } } while (false)
     684             : #  endif
     685             : #endif
     686             : 
     687             : Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qSharedBuild() Q_DECL_NOTHROW;
     688             : 
     689             : #ifndef Q_OUTOFLINE_TEMPLATE
     690             : #  define Q_OUTOFLINE_TEMPLATE
     691             : #endif
     692             : #ifndef Q_INLINE_TEMPLATE
     693             : #  define Q_INLINE_TEMPLATE inline
     694             : #endif
     695             : 
     696             : /*
     697             :    Avoid "unused parameter" warnings
     698             : */
     699             : #define Q_UNUSED(x) (void)x;
     700             : 
     701             : /*
     702             :    Debugging and error handling
     703             : */
     704             : 
     705             : #if !defined(QT_NO_DEBUG) && !defined(QT_DEBUG)
     706             : #  define QT_DEBUG
     707             : #endif
     708             : 
     709             : #ifndef qPrintable
     710             : #  define qPrintable(string) QString(string).toLocal8Bit().constData()
     711             : #endif
     712             : 
     713             : #ifndef qUtf8Printable
     714             : #  define qUtf8Printable(string) QString(string).toUtf8().constData()
     715             : #endif
     716             : 
     717             : /*
     718             :     Wrap QString::utf16() with enough casts to allow passing it
     719             :     to QString::asprintf("%ls") without warnings.
     720             : */
     721             : #ifndef qUtf16Printable
     722             : #  define qUtf16Printable(string) \
     723             :     static_cast<const wchar_t*>(static_cast<const void*>(QString(string).utf16()))
     724             : #endif
     725             : 
     726             : class QString;
     727             : Q_CORE_EXPORT QString qt_error_string(int errorCode = -1);
     728             : 
     729             : #ifndef Q_CC_MSVC
     730             : Q_NORETURN
     731             : #endif
     732             : Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int line) Q_DECL_NOTHROW;
     733             : 
     734             : #if !defined(Q_ASSERT)
     735             : #  if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS)
     736             : #    define Q_ASSERT(cond) static_cast<void>(false && (cond))
     737             : #  else
     738             : #    define Q_ASSERT(cond) ((cond) ? static_cast<void>(0) : qt_assert(#cond, __FILE__, __LINE__))
     739             : #  endif
     740             : #endif
     741             : 
     742             : #if defined(QT_NO_DEBUG) && !defined(QT_PAINT_DEBUG)
     743             : #define QT_NO_PAINT_DEBUG
     744             : #endif
     745             : 
     746             : #ifndef Q_CC_MSVC
     747             : Q_NORETURN
     748             : #endif
     749             : Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char *file, int line) Q_DECL_NOTHROW;
     750             : 
     751             : #if !defined(Q_ASSERT_X)
     752             : #  if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS)
     753             : #    define Q_ASSERT_X(cond, where, what) static_cast<void>(false && (cond))
     754             : #  else
     755             : #    define Q_ASSERT_X(cond, where, what) ((cond) ? static_cast<void>(0) : qt_assert_x(where, what, __FILE__, __LINE__))
     756             : #  endif
     757             : #endif
     758             : 
     759             : 
     760             : #ifdef Q_COMPILER_STATIC_ASSERT
     761             : #define Q_STATIC_ASSERT(Condition) static_assert(bool(Condition), #Condition)
     762             : #define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message)
     763             : #else
     764             : // Intentionally undefined
     765             : template <bool Test> class QStaticAssertFailure;
     766             : template <> class QStaticAssertFailure<true> {};
     767             : 
     768             : #define Q_STATIC_ASSERT_PRIVATE_JOIN(A, B) Q_STATIC_ASSERT_PRIVATE_JOIN_IMPL(A, B)
     769             : #define Q_STATIC_ASSERT_PRIVATE_JOIN_IMPL(A, B) A ## B
     770             : #ifdef __COUNTER__
     771             : #define Q_STATIC_ASSERT(Condition) \
     772             :     enum {Q_STATIC_ASSERT_PRIVATE_JOIN(q_static_assert_result, __COUNTER__) = sizeof(QStaticAssertFailure<!!(Condition)>)}
     773             : #else
     774             : #define Q_STATIC_ASSERT(Condition) \
     775             :     enum {Q_STATIC_ASSERT_PRIVATE_JOIN(q_static_assert_result, __LINE__) = sizeof(QStaticAssertFailure<!!(Condition)>)}
     776             : #endif /* __COUNTER__ */
     777             : #define Q_STATIC_ASSERT_X(Condition, Message) Q_STATIC_ASSERT(Condition)
     778             : #endif
     779             : 
     780             : Q_NORETURN Q_CORE_EXPORT void qt_check_pointer(const char *, int) Q_DECL_NOTHROW;
     781             : Q_CORE_EXPORT void qBadAlloc();
     782             : 
     783             : #ifdef QT_NO_EXCEPTIONS
     784             : #  if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS)
     785             : #    define Q_CHECK_PTR(p) qt_noop()
     786             : #  else
     787             : #    define Q_CHECK_PTR(p) do {if (!(p)) qt_check_pointer(__FILE__,__LINE__);} while (false)
     788             : #  endif
     789             : #else
     790             : #  define Q_CHECK_PTR(p) do { if (!(p)) qBadAlloc(); } while (false)
     791             : #endif
     792             : 
     793             : template <typename T>
     794             : inline T *q_check_ptr(T *p) { Q_CHECK_PTR(p); return p; }
     795             : 
     796             : typedef void (*QFunctionPointer)();
     797             : 
     798             : #if !defined(Q_UNIMPLEMENTED)
     799             : #  define Q_UNIMPLEMENTED() qWarning("Unimplemented code.")
     800             : #endif
     801             : 
     802             : Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyCompare(double p1, double p2)
     803             : {
     804             :     return (qAbs(p1 - p2) * 1000000000000. <= qMin(qAbs(p1), qAbs(p2)));
     805             : }
     806             : 
     807             : Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyCompare(float p1, float p2)
     808             : {
     809             :     return (qAbs(p1 - p2) * 100000.f <= qMin(qAbs(p1), qAbs(p2)));
     810             : }
     811             : 
     812             : Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyIsNull(double d)
     813             : {
     814             :     return qAbs(d) <= 0.000000000001;
     815             : }
     816             : 
     817             : Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED  bool qFuzzyIsNull(float f)
     818             : {
     819             :     return qAbs(f) <= 0.00001f;
     820             : }
     821             : 
     822             : /*
     823             :    This function tests a double for a null value. It doesn't
     824             :    check whether the actual value is 0 or close to 0, but whether
     825             :    it is binary 0, disregarding sign.
     826             : */
     827             : Q_REQUIRED_RESULT static inline Q_DECL_UNUSED bool qIsNull(double d)
     828             : {
     829             :     union U {
     830             :         double d;
     831             :         quint64 u;
     832             :     };
     833             :     U val;
     834             :     val.d = d;
     835             :     return (val.u & Q_UINT64_C(0x7fffffffffffffff)) == 0;
     836             : }
     837             : 
     838             : /*
     839             :    This function tests a float for a null value. It doesn't
     840             :    check whether the actual value is 0 or close to 0, but whether
     841             :    it is binary 0, disregarding sign.
     842             : */
     843             : Q_REQUIRED_RESULT static inline Q_DECL_UNUSED bool qIsNull(float f)
     844             : {
     845             :     union U {
     846             :         float f;
     847             :         quint32 u;
     848             :     };
     849             :     U val;
     850             :     val.f = f;
     851             :     return (val.u & 0x7fffffff) == 0;
     852             : }
     853             : 
     854             : /*
     855             :    Compilers which follow outdated template instantiation rules
     856             :    require a class to have a comparison operator to exist when
     857             :    a QList of this type is instantiated. It's not actually
     858             :    used in the list, though. Hence the dummy implementation.
     859             :    Just in case other code relies on it we better trigger a warning
     860             :    mandating a real implementation.
     861             : */
     862             : 
     863             : #ifdef Q_FULL_TEMPLATE_INSTANTIATION
     864             : #  define Q_DUMMY_COMPARISON_OPERATOR(C) \
     865             :     bool operator==(const C&) const { \
     866             :         qWarning(#C"::operator==(const "#C"&) was called"); \
     867             :         return false; \
     868             :     }
     869             : #else
     870             : 
     871             : #  define Q_DUMMY_COMPARISON_OPERATOR(C)
     872             : #endif
     873             : 
     874             : namespace QtPrivate
     875             : {
     876             : namespace SwapExceptionTester { // insulate users from the "using std::swap" below
     877             :     using std::swap; // import std::swap
     878             :     template <typename T>
     879             :     void checkSwap(T &t)
     880             :         Q_DECL_NOEXCEPT_EXPR(noexcept(swap(t, t)));
     881             :     // declared, but not implemented (only to be used in unevaluated contexts (noexcept operator))
     882             : }
     883             : } // namespace QtPrivate
     884             : 
     885             : template <typename T>
     886         256 : inline void qSwap(T &value1, T &value2)
     887             :     Q_DECL_NOEXCEPT_EXPR(noexcept(QtPrivate::SwapExceptionTester::checkSwap(value1)))
     888             : {
     889             :     using std::swap;
     890         256 :     swap(value1, value2);
     891         256 : }
     892             : 
     893             : #if QT_DEPRECATED_SINCE(5, 0)
     894             : Q_CORE_EXPORT QT_DEPRECATED void *qMalloc(size_t size) Q_ALLOC_SIZE(1);
     895             : Q_CORE_EXPORT QT_DEPRECATED void qFree(void *ptr);
     896             : Q_CORE_EXPORT QT_DEPRECATED void *qRealloc(void *ptr, size_t size) Q_ALLOC_SIZE(2);
     897             : Q_CORE_EXPORT QT_DEPRECATED void *qMemCopy(void *dest, const void *src, size_t n);
     898             : Q_CORE_EXPORT QT_DEPRECATED void *qMemSet(void *dest, int c, size_t n);
     899             : #endif
     900             : Q_CORE_EXPORT void *qMallocAligned(size_t size, size_t alignment) Q_ALLOC_SIZE(1);
     901             : Q_CORE_EXPORT void *qReallocAligned(void *ptr, size_t size, size_t oldsize, size_t alignment) Q_ALLOC_SIZE(2);
     902             : Q_CORE_EXPORT void qFreeAligned(void *ptr);
     903             : 
     904             : 
     905             : /*
     906             :    Avoid some particularly useless warnings from some stupid compilers.
     907             :    To get ALL C++ compiler warnings, define QT_CC_WARNINGS or comment out
     908             :    the line "#define QT_NO_WARNINGS".
     909             : */
     910             : #if !defined(QT_CC_WARNINGS)
     911             : #  define QT_NO_WARNINGS
     912             : #endif
     913             : #if defined(QT_NO_WARNINGS)
     914             : #  if defined(Q_CC_MSVC)
     915             : QT_WARNING_DISABLE_MSVC(4251) /* class 'type' needs to have dll-interface to be used by clients of class 'type2' */
     916             : QT_WARNING_DISABLE_MSVC(4244) /* conversion from 'type1' to 'type2', possible loss of data */
     917             : QT_WARNING_DISABLE_MSVC(4275) /* non - DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' */
     918             : QT_WARNING_DISABLE_MSVC(4514) /* unreferenced inline function has been removed */
     919             : QT_WARNING_DISABLE_MSVC(4800) /* 'type' : forcing value to bool 'true' or 'false' (performance warning) */
     920             : QT_WARNING_DISABLE_MSVC(4097) /* typedef-name 'identifier1' used as synonym for class-name 'identifier2' */
     921             : QT_WARNING_DISABLE_MSVC(4706) /* assignment within conditional expression */
     922             : #    if _MSC_VER <= 1310 // MSVC 2003
     923             : QT_WARNING_DISABLE_MSVC(4786) /* 'identifier' : identifier was truncated to 'number' characters in the debug information */
     924             : #    endif
     925             : QT_WARNING_DISABLE_MSVC(4355) /* 'this' : used in base member initializer list */
     926             : #    if _MSC_VER < 1800 // MSVC 2013
     927             : QT_WARNING_DISABLE_MSVC(4231) /* nonstandard extension used : 'identifier' before template explicit instantiation */
     928             : #    endif
     929             : QT_WARNING_DISABLE_MSVC(4710) /* function not inlined */
     930             : QT_WARNING_DISABLE_MSVC(4530) /* C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc */
     931             : #  elif defined(Q_CC_BOR)
     932             : #    pragma option -w-inl
     933             : #    pragma option -w-aus
     934             : #    pragma warn -inl
     935             : #    pragma warn -pia
     936             : #    pragma warn -ccc
     937             : #    pragma warn -rch
     938             : #    pragma warn -sig
     939             : #  endif
     940             : #endif
     941             : 
     942             : // this adds const to non-const objects (like std::as_const)
     943             : template <typename T>
     944         468 : Q_DECL_CONSTEXPR typename std::add_const<T>::type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
     945             : // prevent rvalue arguments:
     946             : template <typename T>
     947             : void qAsConst(const T &&) Q_DECL_EQ_DELETE;
     948             : 
     949             : #ifndef QT_NO_FOREACH
     950             : 
     951             : namespace QtPrivate {
     952             : 
     953             : template <typename T>
     954         234 : class QForeachContainer {
     955             :     Q_DISABLE_COPY(QForeachContainer)
     956             : public:
     957         224 :     QForeachContainer(const T &t) : c(t), i(qAsConst(c).begin()), e(qAsConst(c).end()) {}
     958          10 :     QForeachContainer(T &&t) : c(std::move(t)), i(qAsConst(c).begin()), e(qAsConst(c).end())  {}
     959             : 
     960             :     QForeachContainer(QForeachContainer &&other)
     961             :         : c(std::move(other.c)),
     962             :           i(qAsConst(c).begin()),
     963             :           e(qAsConst(c).end()),
     964             :           control(std::move(other.control))
     965             :     {
     966             :     }
     967             : 
     968             :     QForeachContainer &operator=(QForeachContainer &&other)
     969             :     {
     970             :         c = std::move(other.c);
     971             :         i = qAsConst(c).begin();
     972             :         e = qAsConst(c).end();
     973             :         control = std::move(other.control);
     974             :         return *this;
     975             :     }
     976             : 
     977             :     T c;
     978             :     typename T::const_iterator i, e;
     979             :     int control = 1;
     980             : };
     981             : 
     982             : template<typename T>
     983         234 : QForeachContainer<typename std::decay<T>::type> qMakeForeachContainer(T &&t)
     984             : {
     985         234 :     return QForeachContainer<typename std::decay<T>::type>(std::forward<T>(t));
     986             : }
     987             : 
     988             : }
     989             : // Explanation of the control word:
     990             : //  - it's initialized to 1
     991             : //  - that means both the inner and outer loops start
     992             : //  - if there were no breaks, at the end of the inner loop, it's set to 0, which
     993             : //    causes it to exit (the inner loop is run exactly once)
     994             : //  - at the end of the outer loop, it's inverted, so it becomes 1 again, allowing
     995             : //    the outer loop to continue executing
     996             : //  - if there was a break inside the inner loop, it will exit with control still
     997             : //    set to 1; in that case, the outer loop will invert it to 0 and will exit too
     998             : #define Q_FOREACH(variable, container)                                \
     999             : for (auto _container_ = QtPrivate::qMakeForeachContainer(container); \
    1000             :      _container_.control && _container_.i != _container_.e;         \
    1001             :      ++_container_.i, _container_.control ^= 1)                     \
    1002             :     for (variable = *_container_.i; _container_.control; _container_.control = 0)
    1003             : 
    1004             : #endif // QT_NO_FOREACH
    1005             : 
    1006             : #define Q_FOREVER for(;;)
    1007             : #ifndef QT_NO_KEYWORDS
    1008             : # ifndef QT_NO_FOREACH
    1009             : #  ifndef foreach
    1010             : #    define foreach Q_FOREACH
    1011             : #  endif
    1012             : # endif // QT_NO_FOREACH
    1013             : #  ifndef forever
    1014             : #    define forever Q_FOREVER
    1015             : #  endif
    1016             : #endif
    1017             : 
    1018             : template <typename T> static inline T *qGetPtrHelper(T *ptr) { return ptr; }
    1019             : template <typename Wrapper> static inline typename Wrapper::pointer qGetPtrHelper(const Wrapper &p) { return p.data(); }
    1020             : 
    1021             : #define Q_DECLARE_PRIVATE(Class) \
    1022             :     inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(qGetPtrHelper(d_ptr)); } \
    1023             :     inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(qGetPtrHelper(d_ptr)); } \
    1024             :     friend class Class##Private;
    1025             : 
    1026             : #define Q_DECLARE_PRIVATE_D(Dptr, Class) \
    1027             :     inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(qGetPtrHelper(Dptr)); } \
    1028             :     inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(qGetPtrHelper(Dptr)); } \
    1029             :     friend class Class##Private;
    1030             : 
    1031             : #define Q_DECLARE_PUBLIC(Class)                                    \
    1032             :     inline Class* q_func() { return static_cast<Class *>(q_ptr); } \
    1033             :     inline const Class* q_func() const { return static_cast<const Class *>(q_ptr); } \
    1034             :     friend class Class;
    1035             : 
    1036             : #define Q_D(Class) Class##Private * const d = d_func()
    1037             : #define Q_Q(Class) Class * const q = q_func()
    1038             : 
    1039             : #define QT_TR_NOOP(x) x
    1040             : #define QT_TR_NOOP_UTF8(x) x
    1041             : #define QT_TRANSLATE_NOOP(scope, x) x
    1042             : #define QT_TRANSLATE_NOOP_UTF8(scope, x) x
    1043             : #define QT_TRANSLATE_NOOP3(scope, x, comment) {x, comment}
    1044             : #define QT_TRANSLATE_NOOP3_UTF8(scope, x, comment) {x, comment}
    1045             : 
    1046             : #ifndef QT_NO_TRANSLATION // ### This should enclose the NOOPs above
    1047             : 
    1048             : // Defined in qcoreapplication.cpp
    1049             : // The better name qTrId() is reserved for an upcoming function which would
    1050             : // return a much more powerful QStringFormatter instead of a QString.
    1051             : Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1);
    1052             : 
    1053             : #define QT_TRID_NOOP(id) id
    1054             : 
    1055             : #endif // QT_NO_TRANSLATION
    1056             : 
    1057             : /*
    1058             :    When RTTI is not available, define this macro to force any uses of
    1059             :    dynamic_cast to cause a compile failure.
    1060             : */
    1061             : 
    1062             : #if defined(QT_NO_DYNAMIC_CAST) && !defined(dynamic_cast)
    1063             : #  define dynamic_cast QT_PREPEND_NAMESPACE(qt_dynamic_cast_check)
    1064             : 
    1065             :   template<typename T, typename X>
    1066             :   T qt_dynamic_cast_check(X, T* = 0)
    1067             :   { return T::dynamic_cast_will_always_fail_because_rtti_is_disabled; }
    1068             : #endif
    1069             : 
    1070             : 
    1071             : #ifdef Q_QDOC
    1072             : 
    1073             : // Just for documentation generation
    1074             : template<typename T>
    1075             : auto qOverload(T functionPointer);
    1076             : template<typename T>
    1077             : auto qConstOverload(T memberFunctionPointer);
    1078             : template<typename T>
    1079             : auto qNonConstOverload(T memberFunctionPointer);
    1080             : 
    1081             : #elif defined(Q_COMPILER_VARIADIC_TEMPLATES)
    1082             : 
    1083             : template <typename... Args>
    1084             : struct QNonConstOverload
    1085             : {
    1086             :     template <typename R, typename T>
    1087             :     Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr)
    1088             :     { return ptr; }
    1089             : 
    1090             :     template <typename R, typename T>
    1091             :     static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...)) Q_DECL_NOTHROW -> decltype(ptr)
    1092             :     { return ptr; }
    1093             : };
    1094             : 
    1095             : template <typename... Args>
    1096             : struct QConstOverload
    1097             : {
    1098             :     template <typename R, typename T>
    1099             :     Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...) const) const Q_DECL_NOTHROW -> decltype(ptr)
    1100             :     { return ptr; }
    1101             : 
    1102             :     template <typename R, typename T>
    1103             :     static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...) const) Q_DECL_NOTHROW -> decltype(ptr)
    1104             :     { return ptr; }
    1105             : };
    1106             : 
    1107             : template <typename... Args>
    1108             : struct QOverload : QConstOverload<Args...>, QNonConstOverload<Args...>
    1109             : {
    1110             :     using QConstOverload<Args...>::of;
    1111             :     using QConstOverload<Args...>::operator();
    1112             :     using QNonConstOverload<Args...>::of;
    1113             :     using QNonConstOverload<Args...>::operator();
    1114             : 
    1115             :     template <typename R>
    1116             :     Q_DECL_CONSTEXPR auto operator()(R (*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr)
    1117             :     { return ptr; }
    1118             : 
    1119             :     template <typename R>
    1120             :     static Q_DECL_CONSTEXPR auto of(R (*ptr)(Args...)) Q_DECL_NOTHROW -> decltype(ptr)
    1121             :     { return ptr; }
    1122             : };
    1123             : 
    1124             : #if defined(__cpp_variable_templates) && __cpp_variable_templates >= 201304 // C++14
    1125             : template <typename... Args> Q_CONSTEXPR Q_DECL_UNUSED QOverload<Args...> qOverload = {};
    1126             : template <typename... Args> Q_CONSTEXPR Q_DECL_UNUSED QConstOverload<Args...> qConstOverload = {};
    1127             : template <typename... Args> Q_CONSTEXPR Q_DECL_UNUSED QNonConstOverload<Args...> qNonConstOverload = {};
    1128             : #endif
    1129             : 
    1130             : #endif
    1131             : 
    1132             : 
    1133             : class QByteArray;
    1134             : Q_CORE_EXPORT QByteArray qgetenv(const char *varName);
    1135             : #ifdef Q_QDOC
    1136             : Q_CORE_EXPORT QString qEnvironmentVariable(const char *varName,
    1137             :                                            const QString &defaultValue = QString());
    1138             : #else // need it as two functions because QString is only forward-declared here
    1139             : Q_CORE_EXPORT QString qEnvironmentVariable(const char *varName);
    1140             : Q_CORE_EXPORT QString qEnvironmentVariable(const char *varName, const QString &defaultValue);
    1141             : #endif
    1142             : Q_CORE_EXPORT bool qputenv(const char *varName, const QByteArray& value);
    1143             : Q_CORE_EXPORT bool qunsetenv(const char *varName);
    1144             : 
    1145             : Q_CORE_EXPORT bool qEnvironmentVariableIsEmpty(const char *varName) Q_DECL_NOEXCEPT;
    1146             : Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) Q_DECL_NOEXCEPT;
    1147             : Q_CORE_EXPORT int  qEnvironmentVariableIntValue(const char *varName, bool *ok=Q_NULLPTR) Q_DECL_NOEXCEPT;
    1148             : 
    1149             : inline int qIntCast(double f) { return int(f); }
    1150             : inline int qIntCast(float f) { return int(f); }
    1151             : 
    1152             : /*
    1153             :   Reentrant versions of basic rand() functions for random number generation
    1154             : */
    1155             : Q_CORE_EXPORT void qsrand(uint seed);
    1156             : Q_CORE_EXPORT int qrand();
    1157             : 
    1158             : #define QT_MODULE(x)
    1159             : 
    1160             : #if !defined(QT_BOOTSTRAPPED) && defined(QT_REDUCE_RELOCATIONS) && defined(__ELF__) && \
    1161             :     (!defined(__PIC__) || (defined(__PIE__) && defined(Q_CC_GNU) && Q_CC_GNU >= 500))
    1162             : #  error "You must build your code with position independent code if Qt was built with -reduce-relocations. "\
    1163             :          "Compile your code with -fPIC (-fPIE is not enough)."
    1164             : #endif
    1165             : 
    1166             : namespace QtPrivate {
    1167             : //like std::enable_if
    1168             : template <bool B, typename T = void> struct QEnableIf;
    1169             : template <typename T> struct QEnableIf<true, T> { typedef T Type; };
    1170             : 
    1171             : template <bool B, typename T, typename F> struct QConditional { typedef T Type; };
    1172             : template <typename T, typename F> struct QConditional<false, T, F> { typedef F Type; };
    1173             : }
    1174             : 
    1175             : QT_END_NAMESPACE
    1176             : 
    1177             : // We need to keep QTypeInfo, QSysInfo, QFlags, qDebug & family in qglobal.h for compatibility with Qt 4.
    1178             : // Be careful when changing the order of these files.
    1179             : #include <QtCore/qtypeinfo.h>
    1180             : #include <QtCore/qsysinfo.h>
    1181             : #include <QtCore/qlogging.h>
    1182             : 
    1183             : #include <QtCore/qflags.h>
    1184             : 
    1185             : #include <QtCore/qatomic.h>
    1186             : #include <QtCore/qglobalstatic.h>
    1187             : #include <QtCore/qnumeric.h>
    1188             : #include <QtCore/qversiontagging.h>
    1189             : 
    1190             : #endif /* __cplusplus */
    1191             : #endif /* !__ASSEMBLER__ */
    1192             : 
    1193             : #endif /* QGLOBAL_H */

Generated by: LCOV version 1.13