CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
Public Member Functions | Static Public Member Functions | Friends | List of all members
ctkVersion Class Reference

#include <Libs/PluginFramework/ctkVersion.h>

Public Member Functions

int compare (const ctkVersion &object) const
 
 ctkVersion (const ctkVersion &version)
 
 ctkVersion (const QString &version)
 
 ctkVersion (unsigned int majorVersion, unsigned int minorVersion, unsigned int microVersion)
 
 ctkVersion (unsigned int majorVersion, unsigned int minorVersion, unsigned int microVersion, const QString &qualifier)
 
unsigned int getMajor () const
 
unsigned int getMicro () const
 
unsigned int getMinor () const
 
QString getQualifier () const
 
bool isUndefined () const
 
bool operator< (const ctkVersion &object) const
 
bool operator== (const ctkVersion &object) const
 
QString toString () const
 

Static Public Member Functions

static ctkVersion emptyVersion ()
 
static ctkVersion parseVersion (const QString &version)
 
static ctkVersion undefinedVersion ()
 

Friends

class ctkPluginPrivate
 
class ctkVersionRange
 

Detailed Description

Version identifier for plug-ins and packages.

Version identifiers have four components.

  1. Major version. A non-negative integer.
  2. Minor version. A non-negative integer.
  3. Micro version. A non-negative integer.
  4. Qualifier. A text string. See ctkVersion(const QString&) for the format of the qualifier string.

ctkVersion objects are immutable.

Definition at line 49 of file ctkVersion.h.

Constructor & Destructor Documentation

◆ ctkVersion() [1/4]

ctkVersion::ctkVersion ( unsigned int  majorVersion,
unsigned int  minorVersion,
unsigned int  microVersion 
)

Creates a version identifier from the specified numerical components.

The qualifier is set to the empty string.

Parameters
majorVersionMajor component of the version identifier.
minorVersionMinor component of the version identifier.
microVersionMicro component of the version identifier.

◆ ctkVersion() [2/4]

ctkVersion::ctkVersion ( unsigned int  majorVersion,
unsigned int  minorVersion,
unsigned int  microVersion,
const QString &  qualifier 
)

Creates a version identifier from the specified components.

Parameters
majorVersionMajor component of the version identifier.
minorVersionMinor component of the version identifier.
microVersionMicro component of the version identifier.
qualifierQualifier component of the version identifier.

◆ ctkVersion() [3/4]

ctkVersion::ctkVersion ( const QString &  version)

Created a version identifier from the specified string.

Here is the grammar for version strings.

version ::= majorVersion('.'minorVersion('.'microVersion('.'qualifier)?)?)?
majorVersion ::= digit+
minorVersion ::= digit+
microVersion ::= digit+
qualifier ::= (alpha|digit|'_'|'-')+
digit ::= [0..9]
alpha ::= [a..zA..Z]

There must be no whitespace in version.

Parameters
versionstring representation of the version identifier.

◆ ctkVersion() [4/4]

ctkVersion::ctkVersion ( const ctkVersion version)

Create a version identifier from another.

Parameters
versionAnother version identifier

Member Function Documentation

◆ compare()

int ctkVersion::compare ( const ctkVersion object) const

Compares this ctkVersion object to another object.

A version is considered to be less than another version if its majorVersion component is less than the other version's majorVersion component, or the majorVersion components are equal and its minorVersion component is less than the other version's minorVersion component, or the majorVersion and minorVersion components are equal and its microVersion component is less than the other version's microVersion component, or the majorVersion, minorVersion and microVersion components are equal and it's qualifier component is less than the other version's qualifier component (using std::string::compare).

A version is considered to be equal to another version if the majorVersion, minorVersion and microVersion components are equal and the qualifier component is equal.

Parameters
objectThe ctkVersion object to be compared.
Returns
A negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified ctkVersion object.

◆ emptyVersion()

static ctkVersion ctkVersion::emptyVersion ( )
static

The empty version "0.0.0".

◆ getMajor()

unsigned int ctkVersion::getMajor ( ) const

Returns the majorVersion component of this version identifier.

Returns
The majorVersion component.

◆ getMicro()

unsigned int ctkVersion::getMicro ( ) const

Returns the microVersion component of this version identifier.

Returns
The microVersion component.

◆ getMinor()

unsigned int ctkVersion::getMinor ( ) const

Returns the minorVersion component of this version identifier.

Returns
The minorVersion component.

◆ getQualifier()

QString ctkVersion::getQualifier ( ) const

Returns the qualifier component of this version identifier.

Returns
The qualifier component.

◆ isUndefined()

bool ctkVersion::isUndefined ( ) const

Returns the undefined state of this version identifier.

Returns
true if this version identifier is undefined, false otherwise.

◆ operator<()

bool ctkVersion::operator< ( const ctkVersion object) const

Compares this ctkVersion object to another object.

This is a convenience function for use in ordered containers. It relies on the compare(const ctkVersion&) method.

Parameters
objectThe ctkVersion object to be compared.
Returns
true if this object is less then the specified ctkVersion object, false otherwise.

◆ operator==()

bool ctkVersion::operator== ( const ctkVersion object) const

Compares this ctkVersion object to another object.

A version is considered to be equal to another version if the majorVersion, minorVersion and microVersion components are equal and the qualifier component is equal.

Parameters
objectThe ctkVersion object to be compared.
Returns
true if object is a ctkVersion and is equal to this object; false otherwise.

◆ parseVersion()

static ctkVersion ctkVersion::parseVersion ( const QString &  version)
static

Parses a version identifier from the specified string.

See ctkVersion(const QString&) for the format of the version string.

Parameters
versionstring representation of the version identifier. Leading and trailing whitespace will be ignored.
Returns
A ctkVersion object representing the version identifier. If version is the empty string then emptyVersion will be returned.

◆ toString()

QString ctkVersion::toString ( ) const

Returns the string representation of this version identifier.

The format of the version string will be majorVersion.minorVersion.microVersion if qualifier is the empty string or majorVersion.minorVersion.microVersion.qualifier otherwise.

Returns
The string representation of this version identifier.

◆ undefinedVersion()

static ctkVersion ctkVersion::undefinedVersion ( )
static

Creates an undefined version identifier, representing either infinity or minus infinity.

Friends And Related Function Documentation

◆ ctkPluginPrivate

friend class ctkPluginPrivate
friend

Definition at line 53 of file ctkVersion.h.

◆ ctkVersionRange

friend class ctkVersionRange
friend

Definition at line 54 of file ctkVersion.h.


The documentation for this class was generated from the following file: