📄 qglobal.h
字号:
# define Q_TEMPLATEDLL# elif defined(QT_DLL) /* use a Qt DLL library */# define Q_CORE_EXPORT Q_DECL_IMPORT# define Q_GUI_EXPORT Q_DECL_IMPORT# define Q_SQL_EXPORT Q_DECL_IMPORT# define Q_NETWORK_EXPORT Q_DECL_IMPORT# define Q_SVG_EXPORT Q_DECL_IMPORT# define Q_CANVAS_EXPORT Q_DECL_IMPORT# define Q_OPENGL_EXPORT Q_DECL_IMPORT# define Q_XML_EXPORT Q_DECL_IMPORT# define Q_COMPAT_EXPORT Q_DECL_IMPORT# define Q_TEMPLATEDLL# endif# define Q_NO_DECLARED_NOT_DEFINED#else# if defined(Q_OS_LINUX) && defined(Q_CC_BOR)# define Q_TEMPLATEDLL# define Q_NO_DECLARED_NOT_DEFINED# endif# undef QT_MAKEDLL /* ignore these for other platforms */# undef QT_DLL#endif#if !defined(Q_CORE_EXPORT)# if defined(QT_SHARED)# define Q_CORE_EXPORT Q_DECL_EXPORT# define Q_GUI_EXPORT Q_DECL_EXPORT# define Q_SQL_EXPORT Q_DECL_EXPORT# define Q_NETWORK_EXPORT Q_DECL_EXPORT# define Q_SVG_EXPORT Q_DECL_EXPORT# define Q_OPENGL_EXPORT Q_DECL_EXPORT# define Q_XML_EXPORT Q_DECL_EXPORT# define Q_COMPAT_EXPORT Q_DECL_EXPORT# else# define Q_CORE_EXPORT# define Q_GUI_EXPORT# define Q_SQL_EXPORT# define Q_NETWORK_EXPORT# define Q_SVG_EXPORT# define Q_OPENGL_EXPORT# define Q_XML_EXPORT# define Q_COMPAT_EXPORT# endif#endif/* No, this is not an evil backdoor. QT_BUILD_INTERNAL just exports more symbols for Trolltech's internal unit tests. If you want slower loading times and more symbols that can vanish from version to version, feel free to define QT_BUILD_INTERNAL.*/#if defined(QT_BUILD_INTERNAL) && defined(Q_OS_WIN) && defined(QT_MAKEDLL)# define Q_INTERNAL_EXPORT Q_DECL_EXPORT#elif defined(QT_BUILD_INTERNAL) && !defined(Q_OS_WIN) && defined(QT_SHARED)# define Q_INTERNAL_EXPORT Q_DECL_EXPORT#else# define Q_INTERNAL_EXPORT#endif/* System information*/class QString;class Q_CORE_EXPORT QSysInfo {public: enum { WordSize = (sizeof(void *)<<3) }; enum Endian { BigEndian, LittleEndian#ifdef Q_BYTE_ORDER# ifdef qdoc , ByteOrder = <platform-dependent># elif Q_BYTE_ORDER == Q_BIG_ENDIAN , ByteOrder = BigEndian# elif Q_BYTE_ORDER == Q_LITTLE_ENDIAN , ByteOrder = LittleEndian# else# error "Undefined byte order"# endif#endif };#if !defined(Q_BYTE_ORDER)# if defined(QT_BUILD_QMAKE) /* needed to bootstrap qmake */ static const int ByteOrder;# else# error "Qt not configured correctly, please run configure"# endif#endif#ifdef Q_WS_WIN enum WinVersion { WV_32s = 0x0001, WV_95 = 0x0002, WV_98 = 0x0003, WV_Me = 0x0004, WV_DOS_based= 0x000f, WV_NT = 0x0010, WV_2000 = 0x0020, WV_XP = 0x0030, WV_2003 = 0x0040, WV_VISTA = 0x0080, WV_NT_based = 0x00f0, WV_CE = 0x0100, WV_CENET = 0x0200, WV_CE_based = 0x0f00 }; static const WinVersion WindowsVersion;#endif#ifdef Q_WS_MAC enum MacVersion { MV_Unknown = 0x0000, /* version */ MV_9 = 0x0001, MV_10_0 = 0x0002, MV_10_1 = 0x0003, MV_10_2 = 0x0004, MV_10_3 = 0x0005, MV_10_4 = 0x0006, /* codenames */ MV_CHEETAH = MV_10_0, MV_PUMA = MV_10_1, MV_JAGUAR = MV_10_2, MV_PANTHER = MV_10_3, MV_TIGER = MV_10_4 }; static const MacVersion MacintoshVersion;#endif};Q_CORE_EXPORT const char *qVersion();Q_CORE_EXPORT bool qSharedBuild();#if defined(Q_OS_MAC)inline int qMacVersion() { return QSysInfo::MacintoshVersion; }#endif#ifdef QT3_SUPPORTinline QT3_SUPPORT bool qSysInfo(int *wordSize, bool *bigEndian){ *wordSize = QSysInfo::WordSize; *bigEndian = (QSysInfo::ByteOrder == QSysInfo::BigEndian); return true;}#endif#if defined(Q_WS_WIN)#if defined(QT3_SUPPORT)inline QT3_SUPPORT bool qt_winUnicode() { return !(QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based); }inline QT3_SUPPORT int qWinVersion() { return QSysInfo::WindowsVersion; }#endif#ifdef Q_OS_TEMP#define QT_WA(uni, ansi) uni#define QT_WA_INLINE(uni, ansi) (uni)#elif defined(UNICODE)#define QT_WA(uni, ansi) if (!(QSysInfo::WindowsVersion& QSysInfo::WV_DOS_based)) { uni } else { ansi }#define QT_WA_INLINE(uni, ansi) (!(QSysInfo::WindowsVersion& QSysInfo::WV_DOS_based) ? uni : ansi)#else#define QT_WA(uni, ansi) ansi#define QT_WA_INLINE(uni, ansi) ansi#endif#endif /* Q_WS_WIN */#ifndef Q_OUTOFLINE_TEMPLATE# define Q_OUTOFLINE_TEMPLATE#endif#ifndef Q_INLINE_TEMPLATE# define Q_INLINE_TEMPLATE inline#endif#ifndef Q_TYPENAME# define Q_TYPENAME typename#endif/* Avoid "unused parameter" warnings*/#if defined(Q_CC_INTEL)template <typename T>inline void qUnused(T &x) { (void)x; }# define Q_UNUSED(x) qUnused(x);#else# define Q_UNUSED(x) (void)x;#endif/* Debugging and error handling*/#if !defined(QT_NO_DEBUG) && !defined(QT_DEBUG)# define QT_DEBUG#endif#ifndef qPrintable# define qPrintable(string) (string).toLocal8Bit().constData()#endifQ_CORE_EXPORT void qDebug(const char *, ...) /* print debug message */#if defined(Q_CC_GNU) && !defined(__INSURE__) __attribute__ ((format (printf, 1, 2)))#endif;Q_CORE_EXPORT void qWarning(const char *, ...) /* print warning message */#if defined(Q_CC_GNU) && !defined(__INSURE__) __attribute__ ((format (printf, 1, 2)))#endif;class QString;Q_CORE_EXPORT QString qt_error_string(int errorCode = -1);Q_CORE_EXPORT void qCritical(const char *, ...) /* print critical message */#if defined(Q_CC_GNU) && !defined(__INSURE__) __attribute__ ((format (printf, 1, 2)))#endif;Q_CORE_EXPORT void qFatal(const char *, ...) /* print fatal message and exit */#if defined(Q_CC_GNU) && !defined(__INSURE__) __attribute__ ((format (printf, 1, 2)))#endif;#ifdef QT3_SUPPORTQ_CORE_EXPORT QT3_SUPPORT void qSystemWarning(const char *msg, int code = -1);#endif /* QT3_SUPPORT */Q_CORE_EXPORT void qErrnoWarning(int code, const char *msg, ...);Q_CORE_EXPORT void qErrnoWarning(const char *msg, ...);class QDebug;class QNoDebug;#ifdef QT_NO_DEBUG_OUTPUT# define qDebug if(1); else qDebug#endif#ifdef QT_NO_WARNING_OUTPUT# define qWarning if(1); else qWarning#endif#if (defined(QT_NO_DEBUG_OUTPUT) || defined(QT_NO_TEXTSTREAM)) && !defined(QT_NO_DEBUG_STREAM)#define QT_NO_DEBUG_STREAM#endifinline void qt_noop() {}Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int line);#if !defined(Q_ASSERT)# ifndef QT_NO_DEBUG# define Q_ASSERT(cond) do {if(!(cond))qt_assert(#cond,__FILE__,__LINE__);} while (0)# else# define Q_ASSERT(cond) do{}while(0)# endif#endifQ_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char *file, int line);#if !defined(Q_ASSERT_X)# ifndef QT_NO_DEBUG# define Q_ASSERT_X(cond, where, what) do {if(!(cond))qt_assert_x(where, what,__FILE__,__LINE__);} while (0)# else# define Q_ASSERT_X(cond, where, what) do{}while(0)# endif#endifQ_CORE_EXPORT void qt_check_pointer(const char *, int);#ifndef QT_NO_DEBUG# define Q_CHECK_PTR(p) do {if(!(p))qt_check_pointer(__FILE__,__LINE__);} while (0)#else# define Q_CHECK_PTR(p)#endifenum QtMsgType { QtDebugMsg, QtWarningMsg, QtCriticalMsg, QtFatalMsg, QtSystemMsg = QtCriticalMsg };Q_CORE_EXPORT void qt_message_output(QtMsgType, const char *buf);typedef void (*QtMsgHandler)(QtMsgType, const char *);Q_CORE_EXPORT QtMsgHandler qInstallMsgHandler(QtMsgHandler);#ifdef QT3_SUPPORTinline QT3_SUPPORT void qSuppressObsoleteWarnings(bool = true) {}inline QT3_SUPPORT void qObsolete(const char *, const char * = 0, const char * = 0) {}#endif#if defined(QT_NO_THREAD)template <typename T>class QGlobalStatic{public: T *pointer; inline QGlobalStatic(T *p) : pointer(p) { } inline ~QGlobalStatic() { pointer = 0; }};#define Q_GLOBAL_STATIC(TYPE, NAME) \ static TYPE *NAME() \ { \ static TYPE this_##NAME; \ static QGlobalStatic<TYPE > global_##NAME(&this_##NAME); \ return global_##NAME.pointer; \ }#define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \ static TYPE *NAME() \ { \ static TYPE this_##NAME ARGS; \ static QGlobalStatic<TYPE > global_##NAME(&this_##NAME); \ return global_##NAME.pointer; \ }#elsetemplate <typename T>class QGlobalStatic{public: T *pointer; bool destroyed; inline QGlobalStatic() : pointer(0), destroyed(false) { } inline ~QGlobalStatic() { delete pointer; pointer = 0; destroyed = true; }};#define Q_GLOBAL_STATIC(TYPE, NAME) \ static TYPE *NAME() \ { \ static QGlobalStatic<TYPE > this_##NAME; \ if (!this_##NAME.pointer && !this_##NAME.destroyed) { \ TYPE *x = new TYPE; \ if (!q_atomic_test_and_set_ptr(&this_##NAME.pointer, 0, x)) \ delete x; \ } \ return this_##NAME.pointer; \ }#define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \ static TYPE *NAME() \ { \ static QGlobalStatic<TYPE > this_##NAME; \ if (!this_##NAME.pointer && !this_##NAME.destroyed) { \ TYPE *x = new TYPE ARGS; \ if (!q_atomic_test_and_set_ptr(&this_##NAME.pointer, 0, x)) \ delete x; \ } \ return this_##NAME.pointer; \ }#endifclass QBool{ bool b;public: inline explicit QBool(bool B) : b(B) {} inline operator const void *() const { return b ? static_cast<const void *>(this) : static_cast<const void *>(0); }};inline bool operator==(QBool b1, bool b2) { return !b1 == !b2; }inline bool operator==(bool b1, QBool b2) { return !b1 == !b2; }inline bool operator==(QBool b1, QBool b2) { return !b1 == !b2; }inline bool operator!=(QBool b1, bool b2) { return !b1 != !b2; }inline bool operator!=(bool b1, QBool b2) { return !b1 != !b2; }inline bool operator!=(QBool b1, QBool b2) { return !b1 != !b2; }static inline bool qFuzzyCompare(double p1, double p2){ return qAbs(p1 - p2) < 0.00000000001;}static inline bool qFuzzyCompare(float p1, float p2){ return qAbs(p1 - p2) < 0.000001;}/* This function tests a double for a null value. It doesn't check whether the actual value is 0 or close to 0, but whether it is binary 0.*/static inline bool qIsNull(double d){ union U { double d; quint64 u; }; U val; val.d = d; return val.u == quint64(0);}/* This function tests a float for a null value. It doesn't check whether the actual value is 0 or close to 0, but whether it is binary 0.*/static inline bool qIsNull(float f){ union U { float f; quint32 u; }; U val; val.f = f; return val.u == 0u;}/* Compilers which follow outdated template instantiation rules require a class to have a comparison operator to exist when a QList of this type is instantiated. It's not actually used in the list, though. Hence the dummy implementation. Just in case other code relies on it we better trigger a warning mandating a real implementation.*/#ifdef Q_FULL_TEMPLATE_INSTANTIATION# define Q_DUMMY_COMPARISON_OPERATOR(C) \ bool operator==(const C&) const { \ qWarning(#C"::operator==(const "#C"&) was called"); \ return false; \ }#else# define Q_DUMMY_COMPARISON_OPERATOR(C)#endif/* QTypeInfo - type trait functionality qIsDetached - data sharing functionality*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -