A data type for version numbers.
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"); 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:
* It accepts all strings, also with special characters.
* You can use not only "." but also "-" as often as you want. (Each new dash separates a new part in the number.)
* You can safely use special characters. If they aren't "." or "-", then they are treated as normal characters. The very last segmentation (e.g. "12#rc1" to "12", "#", "rc", "1") does not only differ between QChar::isDigit() and QChar::isLetter (like RPM does), but has a third category for characters who are neither digit nor letter.
* The very first occurrence of ":" is treated as separator for the epoch. Each following occurrence of ":" is treated as normal character.