Details
-
Suggestion
-
Resolution: Done
-
Not Evaluated
-
4.8.0
-
None
Description
Use case:
Most application are using version numbers. To use them programatically you have to write a lot of code. Strange many programmers write a own class to handle this task, even it is very repetitive.
But comparing of version numbers is a important task, which has to be done at many places in bigger applications. For example you have to compare version numbers of document formats etc. Or in network protocols compare the version numbers of the client and server.
Feature Request:
- Create QVersion, a data type which handles the common used x.y.z version numbers an is allowing to parse, serialize and compare them in many ways.
- See the example solution above.
Example solution:
A custom class:
class Version { public: Version(); Version( int major, int minor, int revision ); Version( const Version& copy ); ~Version(); const Version& operator=( const Version& assign ); public: bool isValid() const; inline int major() const { return _major; } inline int minor() const { return _minor; } inline int revision() const { return _revision; } QString toString() const; static Version fromString( const QString& str ); public: // Compare etc. bool operator==( const Version& compare ) const; bool operator!=( const Version& compare ) const; bool operator>( const Version& compare ) const; bool operator>=( const Version& compare ) const; bool operator<( const Version& compare ) const; bool operator<=( const Version& compare ) const; private: int _major; int _minor; int _revision; };