#include <versionnumber.h>
This class provides a data type for version numbers. Think of it as a QString which provides special behavior for version numbers in the six relational operators (<, <=, >, >=, ==, !=).
The behavior of the relational operators is similar to the behavior of RPM when comparing versions. "Similar" means that it is not equal! See http://rpm.org/wiki/PackagerDocs/Dependencies for a good description of the algorithm used by RPM to determinate version ordering.
You can assign values of the type QString and even qint64 (which will be converted to a QString) and of course of the type VersionNumber itself to it. You can use the assignment operator or the constructor for initiation. The data type is made available to QMetaType and is this way available in for example QVariant. If you want to use it in in non-template based functions like queued signal and slot connections, do something like int id = qRegisterMetaType<VersionNumber>("VersionNumber");
at the begin of your main function. This will register the type also for this use case. id
will contain the type identifier used by QMetaObject. However, for most cases id
isn't intresting.
You can convert to a string with toString(). This function returns always exactly the string which was used to initialize this object.
To compare version numbers, the QString is segmented into small parts. See http://rpm.org/wiki/PackagerDocs/Dependencies for details. The algorithm of VersionNumber differs in some points from the algorithm of RPM:
Definition at line 71 of file versionnumber.h.
typedef QList< simpleNumber > VersionNumber::numberWithPoints [private] |
Internally used data type for parts of the version number like "2.12rc1.3".
Definition at line 96 of file versionnumber.h.
typedef QList< numberWithPoints > VersionNumber::numberWithPointsAndDashes [private] |
Internally used data type for parts of the version number like "2.12rc1.3-9.7".
Definition at line 98 of file versionnumber.h.
typedef QStringList VersionNumber::simpleNumber [private] |
Internally used data type for parts of the version number like "12rc1".
Definition at line 94 of file versionnumber.h.
enum VersionNumber::characterType [private] |
Internally used data type for determinating if a QChar
is
QChar::isLetter()
or QChar::isDigit
or Definition at line 103 of file versionnumber.h.
enum VersionNumber::type_whichIsBigger [private] |
Internally used data type for determinating if when comparing two values
Definition at line 112 of file versionnumber.h.
VersionNumber::VersionNumber | ( | ) |
Definition at line 23 of file versionnumber.cpp.
VersionNumber::VersionNumber | ( | const VersionNumber & | value | ) |
Definition at line 32 of file versionnumber.cpp.
References helper_copyFromHere().
VersionNumber::VersionNumber | ( | const QString & | value | ) |
Definition at line 27 of file versionnumber.cpp.
References helper_setValue().
VersionNumber::VersionNumber | ( | const qint64 | value | ) |
Definition at line 37 of file versionnumber.cpp.
References helper_setValue().
VersionNumber::~VersionNumber | ( | ) | [virtual] |
Definition at line 42 of file versionnumber.cpp.
VersionNumber::characterType VersionNumber::helper_characterType | ( | const QChar & | value | ) | [static, private] |
Internally used to determinate the type of a QChar.
Definition at line 113 of file versionnumber.cpp.
References digit, letter, and other.
Referenced by helper_createSimpleNumber().
void VersionNumber::helper_copyFromHere | ( | const VersionNumber & | value | ) | [private] |
Internally used to copy another object to this object.
Definition at line 192 of file versionnumber.cpp.
References epoch, theString, and version_and_release.
Referenced by operator=(), and VersionNumber().
VersionNumber::numberWithPoints VersionNumber::helper_createNumberWithPoints | ( | const QString & | value | ) | [static, private] |
Internally used to create a VersionNumber::numberWithPoints from a QString
.
Definition at line 160 of file versionnumber.cpp.
References helper_createSimpleNumber().
Referenced by helper_createNumberWithPointsAndDashes().
VersionNumber::numberWithPointsAndDashes VersionNumber::helper_createNumberWithPointsAndDashes | ( | const QString & | value | ) | [static, private] |
Internally used to create a VersionNumber::numberWithPointsAndDashes from a QString
.
Definition at line 176 of file versionnumber.cpp.
References helper_createNumberWithPoints().
Referenced by helper_setValue().
VersionNumber::simpleNumber VersionNumber::helper_createSimpleNumber | ( | const QString & | value | ) | [static, private] |
Internally used to create a VersionNumber::simpleNumber from a QString
.
Definition at line 131 of file versionnumber.cpp.
References helper_characterType().
Referenced by helper_createNumberWithPoints().
void VersionNumber::helper_setValue | ( | const QString & | value | ) | [private] |
Internally used to set the value of this object to a specified string and create the segmented version of the string in epoch and version_and_release.
Definition at line 99 of file versionnumber.cpp.
References epoch, helper_createNumberWithPointsAndDashes(), theString, and version_and_release.
Referenced by operator=(), and VersionNumber().
VersionNumber::type_whichIsBigger VersionNumber::helper_whichNumberIsBigger | ( | const QString & | firstValue, | |
const QString & | secondValue | |||
) | [static, private] |
Internally used to compare 2 QStrings which are assumed to contain digits.
Definition at line 340 of file versionnumber.cpp.
References both_are_equal, first_one, and second_one.
Referenced by whichIsBigger().
VersionNumber::type_whichIsBigger VersionNumber::helper_whichStringIsBigger | ( | const QString & | firstValue, | |
const QString & | secondValue | |||
) | [static, private] |
Internally used to compare 2 QStrings which are assumed to not contain digits.
Definition at line 372 of file versionnumber.cpp.
References both_are_equal, first_one, and second_one.
Referenced by whichIsBigger().
bool VersionNumber::operator!= | ( | const VersionNumber & | value | ) | const |
Definition at line 94 of file versionnumber.cpp.
References both_are_equal, and whichIsBigger().
bool VersionNumber::operator< | ( | const VersionNumber & | value | ) | const |
Definition at line 69 of file versionnumber.cpp.
References second_one, and whichIsBigger().
bool VersionNumber::operator<= | ( | const VersionNumber & | value | ) | const |
Definition at line 74 of file versionnumber.cpp.
References first_one, and whichIsBigger().
VersionNumber VersionNumber::operator= | ( | qint64 | value | ) |
Definition at line 63 of file versionnumber.cpp.
References helper_setValue().
VersionNumber VersionNumber::operator= | ( | const QString & | value | ) |
Definition at line 57 of file versionnumber.cpp.
References helper_setValue().
VersionNumber VersionNumber::operator= | ( | const VersionNumber & | value | ) |
Definition at line 51 of file versionnumber.cpp.
References helper_copyFromHere().
bool VersionNumber::operator== | ( | const VersionNumber & | value | ) | const |
Definition at line 89 of file versionnumber.cpp.
References both_are_equal, and whichIsBigger().
bool VersionNumber::operator> | ( | const VersionNumber & | value | ) | const |
Definition at line 79 of file versionnumber.cpp.
References first_one, and whichIsBigger().
bool VersionNumber::operator>= | ( | const VersionNumber & | value | ) | const |
Definition at line 84 of file versionnumber.cpp.
References second_one, and whichIsBigger().
QString VersionNumber::toString | ( | ) | const |
VersionNumber::type_whichIsBigger VersionNumber::whichIsBigger | ( | const QString & | firstValue, | |
const QString & | secondValue | |||
) | [static, private] |
Internally used to compare 2 segments (list entries, QStrings) of a VersionNumber::simpleNumber.
size() > 0
! Otherwise this function will crash! Definition at line 390 of file versionnumber.cpp.
References helper_whichNumberIsBigger(), and helper_whichStringIsBigger().
VersionNumber::type_whichIsBigger VersionNumber::whichIsBigger | ( | const simpleNumber & | firstValue, | |
const simpleNumber & | secondValue | |||
) | [static, private] |
Internally used to compare 2 VersionNumber::simpleNumber.
Definition at line 299 of file versionnumber.cpp.
References both_are_equal, first_one, second_one, and whichIsBigger().
VersionNumber::type_whichIsBigger VersionNumber::whichIsBigger | ( | const numberWithPoints & | firstValue, | |
const numberWithPoints & | secondValue | |||
) | [static, private] |
Internally used to compare 2 VersionNumber::numberWithPoints.
Definition at line 257 of file versionnumber.cpp.
References both_are_equal, first_one, second_one, and whichIsBigger().
VersionNumber::type_whichIsBigger VersionNumber::whichIsBigger | ( | const numberWithPointsAndDashes & | firstValue, | |
const numberWithPointsAndDashes & | secondValue | |||
) | [static, private] |
Internally used to compare 2 VersionNumber::numberWithPointsAndDashes.
Definition at line 216 of file versionnumber.cpp.
References both_are_equal, first_one, second_one, and whichIsBigger().
VersionNumber::type_whichIsBigger VersionNumber::whichIsBigger | ( | const VersionNumber & | firstValue, | |
const VersionNumber & | secondValue | |||
) | [static, private] |
Internally used to compare 2 VersionNumber.
Definition at line 199 of file versionnumber.cpp.
References both_are_equal, epoch, and version_and_release.
Referenced by operator!=(), operator<(), operator<=(), operator==(), operator>(), operator>=(), and whichIsBigger().
Internally used to hold a segmented version of the first part of the version number (means: the part before the first ":").
Definition at line 126 of file versionnumber.h.
Referenced by helper_copyFromHere(), helper_setValue(), and whichIsBigger().
QString VersionNumber::theString [private] |
Internally used to hold the string who contents the version number.
If this class gets initialized with a qint64
, than this number is converted to a string.
Definition at line 123 of file versionnumber.h.
Referenced by helper_copyFromHere(), helper_setValue(), and toString().
Internally used to hold a segmented version of the second part of the version number (means: the part after the first ":").
Definition at line 129 of file versionnumber.h.
Referenced by helper_copyFromHere(), helper_setValue(), and whichIsBigger().