Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends

ctkVersion Class Reference

#include <Libs/PluginFramework/ctkVersion.h>

List of all members.

Public Member Functions

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

Static Public Member Functions

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

Private Member Functions

 ctkVersion ()
ctkVersionoperator= (const ctkVersion &v)
void validate ()

Private Attributes

unsigned int majorVersion
unsigned int microVersion
unsigned int minorVersion
QString qualifier

Static Private Attributes

static const QRegExp RegExp = QRegExp("[a-zA-Z0-9_\\-]*")
static const QString SEPARATOR = "."

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 50 of file ctkVersion.h.


Constructor & Destructor Documentation

ctkVersion::ctkVersion (  )  [private]

Definition at line 48 of file ctkVersion.cpp.

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:
majorVersion Major component of the version identifier.
minorVersion Minor component of the version identifier.
microVersion Micro component of the version identifier.

Definition at line 61 of file ctkVersion.cpp.

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

Creates a version identifier from the specified components.

Parameters:
majorVersion Major component of the version identifier.
minorVersion Minor component of the version identifier.
microVersion Micro component of the version identifier.
qualifier Qualifier component of the version identifier.

Definition at line 67 of file ctkVersion.cpp.

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:
version string representation of the version identifier.

Definition at line 73 of file ctkVersion.cpp.

ctkVersion::ctkVersion ( const ctkVersion version  ) 

Create a version identifier from another.

Parameters:
version Another version identifier

Definition at line 116 of file ctkVersion.cpp.


Member Function Documentation

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:
object The 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.

Definition at line 181 of file ctkVersion.cpp.

const ctkVersion & ctkVersion::emptyVersion (  )  [static]

The empty version "0.0.0".

Definition at line 33 of file ctkVersion.cpp.

unsigned int ctkVersion::getMajor (  )  const

Returns the majorVersion component of this version identifier.

Returns:
The majorVersion component.

Definition at line 139 of file ctkVersion.cpp.

unsigned int ctkVersion::getMicro (  )  const

Returns the microVersion component of this version identifier.

Returns:
The microVersion component.

Definition at line 149 of file ctkVersion.cpp.

unsigned int ctkVersion::getMinor (  )  const

Returns the minorVersion component of this version identifier.

Returns:
The minorVersion component.

Definition at line 144 of file ctkVersion.cpp.

QString ctkVersion::getQualifier (  )  const

Returns the qualifier component of this version identifier.

Returns:
The qualifier component.

Definition at line 154 of file ctkVersion.cpp.

ctkVersion & ctkVersion::operator= ( const ctkVersion v  )  [private]

Definition at line 39 of file ctkVersion.cpp.

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:
object The ctkVersion object to be compared.
Returns:
true if object is a ctkVersion and is equal to this object; false otherwise.

Definition at line 170 of file ctkVersion.cpp.

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:
version string 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.

Definition at line 123 of file ctkVersion.cpp.

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.

Definition at line 159 of file ctkVersion.cpp.

void ctkVersion::validate (  )  [private]

Called by the ctkVersion constructors to validate the version components.

Returns:
true if the validation was successfull, false otherwise.

Definition at line 55 of file ctkVersion.cpp.


Friends And Related Function Documentation

friend class ctkPluginPrivate [friend]

Definition at line 54 of file ctkVersion.h.

friend class ctkVersionRange [friend]

Definition at line 55 of file ctkVersion.h.


Member Data Documentation

unsigned int ctkVersion::majorVersion [private]

Definition at line 57 of file ctkVersion.h.

unsigned int ctkVersion::microVersion [private]

Definition at line 59 of file ctkVersion.h.

unsigned int ctkVersion::minorVersion [private]

Definition at line 58 of file ctkVersion.h.

QString ctkVersion::qualifier [private]

Definition at line 60 of file ctkVersion.h.

const QRegExp ctkVersion::RegExp = QRegExp("[a-zA-Z0-9_\\-]*") [static, private]

Definition at line 63 of file ctkVersion.h.

const QString ctkVersion::SEPARATOR = "." [static, private]

Definition at line 62 of file ctkVersion.h.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines