classPiiVersionNumber
#include <PiiVersionNumber.h>
A class that can be used to compare version numbers composed of multiple dot-separated parts.
Description
A version number string may optionally contain a dash-separated revision name, which the class recognizes.
Typically, version numbers are composed of three numeric parts: major, minor and patch, but the class does not prevent you from using any number of parts.
PiiVersionNumber v1("1.0.0"); PiiVersionNumber v2("1.1-custom"); PiiVersionNumber v3(0, 9); PiiVersionNumber v4(0, 9, 0, "custom"); PiiVersionNumber v5(0, 9, 0); PiiVersionNumber v6("1.1-custom-2"); PiiVersionNumber v7("2.0.0-gamma"); PiiVersionNumber v8("2.0.0-delta"); QVERIFY(v1 < v2); QVERIFY(v1 >= v3); QVERIFY(v4 != v3); QVERIFY(v4 < v3); QVERIFY(v5 > v4); QVERIFY(v6 > v2); QVERIFY(v7 < v8); QCOMPARE(v2.revision(), QString("custom")); QCOMPARE(v6.revision(), QString("custom-2"));
Constructors and destructor
|
Copy a version number. |
|
|
Initialize a version number from a string. |
|
|
Create a new version number with the given |
|
Public member functions
|
bool
|
( )
See if the version contains a revision name. |
|
bool
|
Compare version numbers. |
|
bool
|
Compare version numbers. |
|
bool
|
Compare version numbers. |
|
Assign another version number to this. |
|
|
bool
|
Compare version numbers. |
|
bool
|
Compare version numbers. |
|
bool
|
Compare version numbers. |
|
int
|
(
Get the |
|
int
|
( )
Get the number of parts in the version. |
|
( )
Get the revision name. |
|
|
bool
|
Parse a version number string and set the version number fields accordingly. |
|
( )
Create a string representation of the version number. |
Function details
-
PiiVersionNumber
Copy a version number.
-
PiiVersionNumber
Initialize a version number from a string.
Valid examples include "1.0", "2.23.5.5", "0.9-beta", and even "-alpha".
-
PiiVersionNumber
Create a new version number with the given
major,minor, andpatchnumbers and arevisionname. -
~PiiVersionNumber
() -
bool hasRevision
()See if the version contains a revision name.
-
bool operator!=
Compare version numbers.
Version numbers are different if any of their elements, including the revision name, are different.
-
[inline]
Compare version numbers.
The first differing decimal place determines the ordering. If all decimal places are the same, the revision will be checked. If the revision contains dashes (-), each dash-separated part will be checked separately. The ordering is determined by comparing the parts as integers, if they are composed of digits only. Otherwise, their textual sort order (case-insensitivive) determines the ordering. Names of Greek letters are recognized as special cases. Alpha, beta, gamma, delta ect. are sorted according to the greek alphabet. If only one of the version numbers has a revision suffix, the type of the suffix determines the ordering. A numeric suffix means a bigger version whereas a textual suffix means a smaller version. Therefore, 2.0.0-beta < 2.0.0 < 2.0.0-2.
-
Compare version numbers.
See operator<().
-
PiiVersionNumber & operator=
Assign another version number to this.
-
bool operator==
Compare version numbers.
Version numbers are equal if all of their elements, including the revision name, are equal. "1.0" is different from "1.0.0".
-
Compare version numbers.
See operator<().
-
Compare version numbers.
See operator<().
-
int part
(- int index
Get the
indexthpart of the version number.Index 0 is for the major version, 1 for the minor version etc. If there is no such part, 0 will be returned.
-
int partCount
()Get the number of parts in the version.
-
QString revision
()Get the revision name.
If there is no revision name, an empty string will be returned.
-
bool setVersionString
Parse a version number string and set the version number fields accordingly.
Returns
trueiff the number was successfully parsed -
QString toString
()Create a string representation of the version number.
Version numbers will be separated with dots, and the revision name with a dash.
Add a note
Not a single note added yet. Be the first, add yours.