⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qglobal.cpp

📁 qt-x11-opensource-src-4.1.4.tar.gz源码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
/******************************************************************************** Copyright (C) 1992-2006 Trolltech ASA. All rights reserved.**** This file is part of the QtCore module of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.0 as published by the Free Software Foundation** and appearing in the file LICENSE.GPL included in the packaging of** this file.  Please review the following information to ensure GNU** General Public Licensing requirements will be met:** http://www.trolltech.com/products/qt/opensource.html**** If you are unsure which license is appropriate for your use, please** review the following information:** http://www.trolltech.com/products/qt/licensing.html or contact the** sales department at sales@trolltech.com.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/#include "qplatformdefs.h"#include "qstring.h"#include <stdio.h>#include <stdlib.h>#include <limits.h>#include <stdarg.h>#include <errno.h>#if defined(Q_CC_MSVC) && !defined(Q_OS_TEMP)#include <crtdbg.h>#endif/*!    \class QFlag    \brief The QFlag class is a helper data type for QFlags.    It is equivalent to a plain \c int, except with respect to    function overloading and type conversions. You should never need    to use this class in your applications.    \sa QFlags*//*!    \fn QFlag::QFlag(int value)    Constructs a QFlag object that stores the given \a value.*//*!    \fn QFlag::operator int() const    Returns the value stored by the QFlag object.*//*!    \class QFlags    \brief The QFlags class provides a type-safe way of storing    OR-combinations of enum values.    \mainclass    \ingroup tools    The QFlags<Enum> class is a template class, where Enum is an enum    type. QFlags is used throughout Qt for storing combinations of    enum values.    The traditional C++ approach for storing OR-combinations of enum    values is to use an \c int or \c uint variable. The inconvenience    with this approach is that there's no type checking at all; any    enum value can be OR'd with any other enum value and passed on to    a function that takes an \c int or \c uint.    Qt uses QFlags to provide type safety. For example, the    Qt::Alignment type is simply a typedef for    QFlags<Qt::AlignmentFlag>. QLabel::setAlignment() takes a    Qt::Alignment parameter, which means that any combination of    Qt::AlignmentFlag values is legal:    \code        label->setAlignment(Qt::AlignLeft | Qt::AlignTop);    \endcode    If you try to pass a value from another enum, the compiler will    report an error.    If you want to use QFlags for your own enum types, use    the Q_DECLARE_FLAGS() and Q_DECLARE_OPERATORS_FOR_FLAGS().    For example:    \code        class MyClass        {        public:            enum Option {                NoOptions = 0x0,                ShowTabs = 0x1,                ShowAll = 0x2,                SqueezeBlank = 0x4            };            Q_DECLARE_FLAGS(Options, Option)            ...        };        Q_DECLARE_OPERATORS_FOR_FLAGS(MyClass::Options)    \endcode    You can then use the \c MyClass::Options type to store    combinations of \c MyClass::Option values.    A sensible naming convension for enum types and associated QFlags    types is to give a singular name to the enum type (e.g., \c    Option) and a plural name to the QFlags type (e.g., \c Options).    When a singular name is desired for the QFlags type (e.g., \c    Alignment), you can use \c Flag as the suffix for the enum type    (e.g., \c AlignmentFlag).    \sa QFlag*//*!    \typedef QFlags::enum_type    Typedef for the Enum template type.*//*!    \fn QFlags::QFlags(const QFlags &other)    Constructs a copy of \a other.*//*!    \fn QFlags::QFlags(Enum flag)    Constructs a QFlags object storing the given \a flag.*//*!    \fn QFlags::QFlags(Zero zero)    Constructs a QFlags object with no flags set. \a zero must be a    literal 0 value.*//*!    \fn QFlags::QFlags(QFlag value)    Constructs a QFlags object initialized with the given integer \a    value.    The QFlag type is a helper type. By using it here instead of \c    int, we effectively ensure that arbitrary enum values cannot be    cast to a QFlags, whereas untyped enum values (i.e., \c int    values) can.*//*!    \fn QFlags &QFlags::operator=(const QFlags &other)    Assigns \a other to this object and returns a reference to this    object.*//*!    \fn QFlags &QFlags::operator&=(int mask)    Performs a bitwise AND operation with \a mask and stores the    result in this QFlags object. Returns a reference to this object.    \sa operator&(), operator|=(), operator^=()*//*!    \fn QFlags &QFlags::operator&=(uint mask)    \overload*//*!    \fn QFlags &QFlags::operator|=(QFlags other)    Performs a bitwise OR operation with \a other and stores the    result in this QFlags object. Returns a reference to this object.    \sa operator|(), operator&=(), operator^=()*//*!    \fn QFlags &QFlags::operator|=(Enum other)    \overload*//*!    \fn QFlags &QFlags::operator^=(QFlags other)    Performs a bitwise XOR operation with \a other and stores the    result in this QFlags object. Returns a reference to this object.    \sa operator^(), operator&=(), operator|=()*//*!    \fn QFlags &QFlags::operator^=(Enum other)    \overload*//*!    \fn QFlags::operator int() const    Returns the value stored in the QFlags object as an integer.*//*!    \fn QFlags QFlags::operator|(QFlags other) const    Returns a QFlags object containing the result of the bitwise OR    operation on this object and \a other.    \sa operator|=(), operator^(), operator&(), operator~()*//*!    \fn QFlags QFlags::operator|(Enum other) const    \overload*//*!    \fn QFlags QFlags::operator^(QFlags other) const    Returns a QFlags object containing the result of the bitwise XOR    operation on this object and \a other.    \sa operator^=(), operator&(), operator|(), operator~()*//*!    \fn QFlags QFlags::operator^(Enum other) const    \overload*//*!    \fn QFlags QFlags::operator&(int mask) const    Returns a QFlags object containing the result of the bitwise AND    operation on this object and \a mask.    \sa operator&=(), operator|(), operator^(), operator~()*//*!    \fn QFlags QFlags::operator&(uint mask) const    \overload*//*!    \fn QFlags QFlags::operator&(Enum mask) const    \overload*//*!    \fn QFlags QFlags::operator~() const    Returns a QFlags object that contains the bitwise negation of    this object.    \sa operator&(), operator|(), operator^()*//*!    \fn bool QFlags::operator!() const    Returns true if no flag is set (i.e., if the value stored by the    QFlags object is 0); otherwise returns false.*//*!    \macro Q_DECLARE_FLAGS(Flags, Enum)    \relates QFlags    The Q_DECLARE_FLAGS() macro expands to    \code        typedef QFlags<Enum> Flags;    \endcode    \a Enum is the name of an existing enum type, whereas \a Flags is    the name of the QFlags<\e{Enum}> typedef.    See the QFlags documentation for details.    \sa Q_DECLARE_OPERATORS_FOR_FLAGS()*//*!    \macro Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)    \relates QFlags    The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global \c    operator|() functions for \a Flags, which is of type QFlags<T>.    See the QFlags documentation for details.    \sa Q_DECLARE_FLAGS()*//*!    \headerfile <QtGlobal>    \title Global Qt Declarations    \brief The <QtGlobal> header file provides basic declarations and    is included by all other Qt headers.    The declarations include \l {types}, \l functions and    \l macros.    The type definitions are partly convenience definitions for basic    types (some of which guarantee certain bit-sizes on all platforms    supported by Qt), partly types related to Qt message handling. The    functions are related to generating messages, Qt version handling    and comparing and adjusting object values. And finally, some of    the declared macros enable programmers to add compiler or platform    specific code to their applications, while others are convenience    macros for larger operations.    \section1 Types    The header file declares several type definitions that guarantee a    specified bit-size on all platforms supported by Qt for various    basic types, for example \l qint8 which is a signed char    guaranteed to be 8-bit on all platforms supported by Qt. The    header file also declares the \l qlonglong type definition for \c    {long long int } (\c __int64 on Windows).    Several convenience type definitions are declared: \l qreal for \c    double, \l uchar for \c unsigned char, \l uint for \c unsigned    int, \l ulong for \c unsigned long and \l ushort for \c unsigned    short.    Finally, the QtMsgType definition identifies the various messages    that can be generated and sent to a Qt message handler;    QtMsgHandler is a type definition for a pointer to a function with    the signature \c {void myMsgHandler(QtMsgType, const char *)}.    \section1 Functions    The <QtGlobal> header file contains several functions comparing    and adjusting an object's value. These functions take a template    type as argument: You can retrieve the absolute value of an object    using the qAbs() function, and you can bound a given object's    value by given minimum and maximum values using the qBound()    function. You can retrieve the minimum and maximum of two given    objects using qMin() and qMax() respectively. All these functions    return a corresponding template type; the template types can be    replaced by any other type. For example:    \code        int myValue = 10;        int minValue = 2;        int maxValue = 6;        int boundedValue = qBound(minValue, myValue, maxValue);        // boundedValue == 6    \endcode    <QtGlobal> also contains functions that generate messages from the    given string argument: qCritical(), qDebug(), qFatal() and    qWarning(). These functions call the message handler with the    given message. For example:    \code        if (!driver()->isOpen() || driver()->isOpenError()) {            qWarning("QSqlQuery::exec: database not open");            return false;        }    \endcode    The remaining functions are qRound() and qRound64(), which both    accept a \l qreal value as their argument returning the value    rounded up to the nearest integer and 64-bit integer respectively,    the qInstallMsgHandler() function which installs the given    QtMsgHandler, and the qVersion() function which returns the    version number of Qt at run-time as a string.    \section1 Macros    The <QtGlobal> header file provides a range of macros (Q_CC_*)    that are defined if the application is compiled using the    specified platforms. For example, the Q_CC_SUN macro is defined if    the application is compiled using Forte Developer, or Sun Studio    C++.  The header file also declares a range of macros (Q_OS_*)    that are defined for the specified platforms. For example,    Q_OS_X11 which is defined for the X Window System.    The purpose of these macros is to enable programmers to add    compiler or platform specific code to their application.    The remaining macros are convenience macros for larger operations:    The QT_TRANSLATE_NOOP() and QT_TR_NOOP() macros provide the    possibility of marking text for dynamic translation,    i.e. translation without changing the stored source text. The    Q_ASSERT() and Q_ASSERT_X() enables warning messages of various    level of refinement. The Q_FOREACH() and foreach() macros    implement Qt's foreach loop.    The Q_INT64_C() and Q_UINT64_C() macros wrap signed and unsigned    64-bit integer literals in a platform-independent way. The    Q_CHECK_PTR() macro prints a warning containing the source code's    file name and line number, saying that the program ran out of    memory, if the pointer is 0. The qPrintable() macro represent an    easy way of printing text.    Finally, the QT_POINTER_SIZE macro expands to the size of a    pointer in bytes, and the QT_VERSION and QT_VERSION_STR macros    expand to a numeric value or a string, respectively, specifying    Qt's version number, i.e the version the application is compiled    against.    \sa <QtAlgorithms>, QSysInfo*//*!    \typedef qreal    \relates <QtGlobal>    Typedef for \c double.*//*! \typedef uchar    \relates <QtGlobal>    Convenience typedef for \c{unsigned char}.*//*! \typedef ushort    \relates <QtGlobal>    Convenience typedef for \c{unsigned short}.*//*! \typedef uint    \relates <QtGlobal>    Convenience typedef for \c{unsigned int}.*//*! \typedef ulong    \relates <QtGlobal>    Convenience typedef for \c{unsigned long}.*//*! \typedef qint8    \relates <QtGlobal>    Typedef for \c{signed char}. This type is guaranteed to be 8-bit    on all platforms supported by Qt.*//*!    \typedef quint8    \relates <QtGlobal>    Typedef for \c{unsigned char}. This type is guaranteed to    be 8-bit on all platforms supported by Qt.*//*! \typedef qint16    \relates <QtGlobal>    Typedef for \c{signed short}. This type is guaranteed to be    16-bit on all platforms supported by Qt.*//*!    \typedef quint16    \relates <QtGlobal>    Typedef for \c{unsigned short}. This type is guaranteed to    be 16-bit on all platforms supported by Qt.*//*! \typedef qint32    \relates <QtGlobal>    Typedef for \c{signed int}. This type is guaranteed to be 32-bit    on all platforms supported by Qt.*//*!    \typedef quint32    \relates <QtGlobal>    Typedef for \c{unsigned int}. This type is guaranteed to    be 32-bit on all platforms supported by Qt.*//*! \typedef qint64    \relates <QtGlobal>    Typedef for \c{long long int} (\c __int64 on Windows). This type    is guaranteed to be 64-bit on all platforms supported by Qt.    Literals of this type can be created using the Q_INT64_C() macro:    \code        qint64 value = Q_INT64_C(932838457459459);    \endcode    \sa Q_INT64_C(), quint64, qlonglong*//*!    \typedef quint64    \relates <QtGlobal>    Typedef for \c{unsigned long long int} (\c{unsigned __int64} on    Windows). This type is guaranteed to be 64-bit on all platforms    supported by Qt.    Literals of this type can be created using the Q_UINT64_C()    macro:    \code        quint64 value = Q_UINT64_C(932838457459459);    \endcode    \sa Q_UINT64_C(), qint64, qulonglong*//*!    \typedef QtMsgHandler    \relates <QtGlobal>    This is a typedef for a pointer to a function with the following    signature:    \code        void myMsgHandler(QtMsgType, const char *);    \endcode    \sa QtMsgType, qInstallMsgHandler()*//*!    \enum QtMsgType    \relates <QtGlobal>    This enum describes the messages that can be sent to a message    handler (QtMsgHandler). You can use the enum to identify and    associate the various message types with the appropiate    actions.    \value QtDebugMsg           A message generated by the qDebug() function.    \value QtWarningMsg           A message generated by the qWarning() function.    \value QtCriticalMsg           A message generated by the qCritical() function.    \value QtFatalMsg           A message generated by the qFatal() function.    \value QtSystemMsg    \sa QtMsgHandler, qInstallMsgHandler()*//*! \macro qint64 Q_INT64_C(literal)    \relates <QtGlobal>    Wraps the signed 64-bit integer \a literal in a    platform-independent way. For example:    \code        qint64 value = Q_INT64_C(932838457459459);    \endcode    \sa qint64, Q_UINT64_C()*//*! \macro quint64 Q_UINT64_C(literal)    \relates <QtGlobal>    Wraps the unsigned 64-bit integer \a literal in a    platform-independent way. For example:    \code        quint64 value = Q_UINT64_C(932838457459459);    \endcode    \sa quint64, Q_INT64_C()*//*! \typedef qlonglong    \relates <QtGlobal>    Typedef for \c{long long int} (\c __int64 on Windows). This is    the same as \l qint64.    \sa qulonglong, qint64*//*!    \typedef qulonglong    \relates <QtGlobal>    Typedef for \c{unsigned long long int} (\c{unsigned __int64} on    Windows). This is the same as \l quint64.    \sa quint64, qlonglong

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -