VersionNumber

Qt Components

Source i (link to git-repo or to original if based on someone elses unmodified work):

Add the source-code for this project on opencode.net

0
Become a Fan
5.0

Description:
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.

Ratings & Comments

0 Comments

Be the first to comment
Pling
0 Affiliates
Details
license
version 1.0
updated
added
downloads 24h 0
mediaviews 24h 0
pageviews 24h 0

More Qt Components from urwald:

product
CustomizableHeaderView
urwald
last update date: 15 years ago

Score 5.0

Other Qt Components:

product
QyurVisualSqlFilter
purser79
last update date: 8 years ago

Score 5.0

product
QyurSqlTreeView
purser79
last update date: 8 years ago

Score 6.5

product
QtBasic
mantur
last update date: 12 years ago

Score 5.0

product
up2Date
seanpatti
last update date: 9 years ago

Score 5.0

product
MStyles
mchara
last update date: 17 years ago

Score 5.0

product
Hdr reading plugin
mchara
last update date: 17 years ago

Score 5.0