diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-09-10 08:29:02 +0000 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-09-10 08:29:02 +0000 |
| commit | f43043e5ac727fc227d7c69673c8747507e72cf0 (patch) | |
| tree | c3e0c01ecca774d6e8f772833b19984ff1c356cc | |
| parent | 3488995080d1627f53a4f9215f3a3b67fadb98b1 (diff) | |
| download | qxmpp-f43043e5ac727fc227d7c69673c8747507e72cf0.tar.gz | |
define QXMPP_VERSION as a macro returning an integer (like QT_VERSION),
so that it is possible to write code such as:
#if QXMPP_VERSION >= 0x000300
// we have QXmpp 0.3.0 or later
#endif
| -rw-r--r-- | qxmpp.pri | 3 | ||||
| -rw-r--r-- | src/QXmppGlobal.cpp | 8 | ||||
| -rw-r--r-- | src/QXmppGlobal.h | 13 | ||||
| -rw-r--r-- | tests/tests.cpp | 2 |
4 files changed, 17 insertions, 9 deletions
@@ -1,6 +1,5 @@ # Common definitions -QXMPP_VERSION = 0.3.0_unreleased QXMPP_INCLUDE_DIR = $$PWD/src QXMPP_LIBRARY_DIR = $$PWD/lib @@ -10,5 +9,3 @@ CONFIG(debug, debug|release) { QXMPP_LIBRARY_NAME = qxmpp } -DEFINES = "QXMPP_VERSION=$$QXMPP_VERSION" - diff --git a/src/QXmppGlobal.cpp b/src/QXmppGlobal.cpp index d6459001..e670743d 100644 --- a/src/QXmppGlobal.cpp +++ b/src/QXmppGlobal.cpp @@ -24,11 +24,11 @@ #include "QXmppGlobal.h" -#define QXMPPSTRINGIZE(n) _QXMPPSTRINGIZE(n) -#define _QXMPPSTRINGIZE(n) #n - QString QXmppVersion() { - return QString(QXMPPSTRINGIZE(QXMPP_VERSION)); + return QString("%1.%2.%3").arg( + QString::number((QXMPP_VERSION >> 16) & 0xff), + QString::number((QXMPP_VERSION >> 8) & 0xff), + QString::number(QXMPP_VERSION & 0xff)); } diff --git a/src/QXmppGlobal.h b/src/QXmppGlobal.h index 5bba7259..5862eda0 100644 --- a/src/QXmppGlobal.h +++ b/src/QXmppGlobal.h @@ -25,7 +25,18 @@ #ifndef QXMPPGLOBAL_H #define QXMPPGLOBAL_H -#include "QString" +#include <QString> + +/// This macro expands a numeric value of the form 0xMMNNPP (MM = +/// major, NN = minor, PP = patch) that specifies QXmpp's version +/// number. For example, if you compile your application against +/// QXmpp 1.2.3, the QXMPP_VERSION macro will expand to 0x010203. +/// +/// You can use QXMPP_VERSION to use the latest QXmpp features where +/// available. +/// + +#define QXMPP_VERSION 0x00025a QString QXmppVersion(); diff --git a/tests/tests.cpp b/tests/tests.cpp index 875448ad..2899fbe1 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -132,7 +132,7 @@ void TestUtils::testMime() void TestUtils::testLibVersion() { - QCOMPARE(QXmppVersion(), QString("0.3.0_unreleased")); + QCOMPARE(QXmppVersion(), QString("0.2.90")); } template <class T> |
