[Development] Adding support for version number comparisons

Keith Gardner kreios4004 at gmail.com
Fri May 9 18:36:08 CEST 2014


Greetings,

I have been working on adding a class to QtCore (QVersion) to support
storing version numbers, convert to/from QString, and having comparison
operators.  My goal was to provide an API to assist in the following use
cases:

   - Plugin loading where there are multiple versions on the same system.
   - File format validation.
   - Executing an already installed command line application where the
   behavior is dependent on the called application's version.
   - Performing software installations and updates.
   - QMake support for version number comparisons.

Please share other potential use cases where this might be useful.

I am not restring the use of this class for just Qt's needs and that is
where a lot of discussion about functionality has come up.  You can see the
progress for this patch at https://codereview.qt-project.org/82170.

The current implementation supports 0 to N numerical segments and a QString
suffix.  Currently, the restrictions for numerical segments are that they
cannot be negative.  The restrictions for the suffix are that it cannot
start with a number and it cannot contain any white space.  Beyond that,
there are some things that need to be defined:

   1. What level of support for Semantic Versioning 2.0.0 (
   http://www.semver.org) should be supported?
   2. What semantics should be used for version comparisons?  Numerical
   segments are more clearly defined but when introducing a non-null suffix,
   many different methods are being proposed.
      1. Should suffixes be compared purely lexicographically?  Case
      sensitive or insensitive?
         1. e.g. "1.0-beta11" < "1.0-beta2" < "1.0-Beta2"
      2. Should numerical portions in a suffix be pulled out compared
      differently?
         1. e.g. "1.0-beta2" < "1.0-beta11"
      3. Should the suffix be checked for key words to assist in
      comparisons?
         1. alpha
         2. beta
         3. gamma
         4. rc
      4. Should there be a special case where single character suffixes
      have a higher precedent to multi-character suffixes?
         1. e.g. "1.0alpha" < "1.0" < "1.0a"
      3. Are there any other versioning semantics that should be supported?

The biggest question of all, should this even be included in QtCore?

Thanks,
Keith
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20140509/7741d4f4/attachment.html>


More information about the Development mailing list