All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions
Qtilities::Core::VersionNumber Class Reference

VersionNumber represents a single version number. More...

#include <VersionInformation.h>

List of all members.

Public Member Functions

int fieldWidthMinor () const
 Gets the minor version's field width.
int fieldWidthRevision () const
 Gets the revision version's field width.
virtual void fromString (const QString &version, const QString &seperator=".")
 Gets the version information from a string represenation, thus the major, minor and revision parts of the version.
bool isVersionMinorUsed () const
 Gets if the minor version is part of the version.
bool isVersionRevisionUsed () const
 Gets if the minor version is part of the version.
bool operator!= (const VersionNumber &ref) const
 Operator overload to compare two VersionNumber objects are not equal.
bool operator< (const VersionNumber &ref)
 Operator overload to check if one VersionNumber to smaller than another VersionNumber.
bool operator<= (const VersionNumber &ref)
 Operator overload to check if one VersionNumber to smaller than or equal to another VersionNumber.
VersionNumberoperator= (const VersionNumber &ref)
 Operator overload to assign one VersionNumber to another VersionNumber.
bool operator== (const VersionNumber &ref) const
 Operator overload to compare two VersionNumber objects with each other.
bool operator> (const VersionNumber &ref)
 Operator overload to check if one VersionNumber to bigger than another VersionNumber.
bool operator>= (const VersionNumber &ref)
 Operator overload to check if one VersionNumber to bigger than or equal to another VersionNumber.
void setFieldWidthMinor (int field_width)
 Sets the minor version's field width.
void setFieldWidthRevision (int field_width)
 Sets the revision version's field width.
void setIsVersionMinorUsed (bool is_used)
 Sets if the minor version is part of the version.
void setIsVersionRevisionUsed (bool is_used)
 Sets if the minor version is part of the version.
void setVersionMajor (int version)
 Sets the major version.
void setVersionMinor (int version)
 Sets the minor version.
void setVersionRevision (int version)
 Sets the revision version.
virtual QString toString (const QString &seperator=".") const
 Returns a string represenation of the complete VersionNumber, thus the major, minor and revision parts of the version.
int versionMajor () const
 Gets the major version.
int versionMinor () const
 Gets the minor version.
int versionRevision () const
 Gets the revision version.

Detailed Description

VersionNumber represents a single version number.

The VersionNumber class represents a version on three levels:

For example, to construct a version number for v1.0.3 you would do something like this:

VersionNumber number(1,0,3);
// We can now print it like this: 1.0.3
number.toString();
// Or we can print it like this: 1.0.003
number.setFieldWidthRevision(3);
number.toString();
// If we want to use the version number in a file name, it might be usefull to print it like: 1_0_003
number.toString("_");

For Minor and Revision numbers you can specify the fieldWidth using setFieldWidthMinor() and setFieldWidthRevision() respectively.

VersionNumber provides a range of functions to compare version numbers with each other. For example:

VersionNumber ver0(4,4,4);
VersionNumber ver1(5,5,5);
bool is_bigger_or_equal = (ver0 >= ver1); // False
bool is_bigger = (ver0 > ver1); // False
bool is_equal = (ver0 == ver1); // False
bool is_not_equal = (ver0 != ver1); // True
bool is_smaller_and_equal = (ver0 <= ver1); // True
bool is_smaller = (ver0 < ver1); // True
See also:
VersionInformation

This class was added in Qtilities v1.0.


Member Function Documentation

int Qtilities::Core::VersionNumber::fieldWidthMinor ( ) const

Gets the minor version's field width.

By default this is not defined and not taken into account in string representations of this version number.

void Qtilities::Core::VersionNumber::fromString ( const QString &  version,
const QString &  seperator = "." 
)
virtual

Gets the version information from a string represenation, thus the major, minor and revision parts of the version.

Parameters:
versionThe version string.
seperatorBy default this is a point, thus ".". In some cases it is desirable to use a custom field seperator. For example as an underscore "_" can be desirable when the version information must be appended to a file name.

This function keeps the used parts of the version, thus it does not change that.

void Qtilities::Core::VersionNumber::setFieldWidthRevision ( int  field_width)

Sets the revision version's field width.

By default this is not defined and not taken into account in string representations of this version number.

QString Qtilities::Core::VersionNumber::toString ( const QString &  seperator = ".") const
virtual

Returns a string represenation of the complete VersionNumber, thus the major, minor and revision parts of the version.

Parameters:
seperatorBy default this is a point, thus ".". In some cases it is desirable to use a custom field seperator. For example as an underscore "_" can be desirable when the version information must be appended to a file name.


Qtilities : Reference Documentation Back to top Copyright © 2009-2013, Jaco Naudé