Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
Version Class Reference

#include <elm/util/Version.h>

Public Member Functions

 Version (int major=0, int minor=0, int release=0)
 
 Version (const Version &version)
 
 Version (const char *text)
 
 Version (const cstring text)
 
 Version (const string &text)
 
Version nextRelease (void) const
 
Version nextMinor (void) const
 
Version nextMajor (void) const
 
int major (void) const
 
int minor (void) const
 
int release (void) const
 
bool accepts (const Version &version) const
 
int compare (const Version &version) const
 
 operator bool (void) const
 
Versionoperator= (const Version &version)
 
Versionoperator= (const char *text)
 
Versionoperator= (const cstring text)
 
Versionoperator= (const string &text)
 
bool operator== (const Version &version) const
 
bool operator!= (const Version &version) const
 
bool operator> (const Version &version) const
 
bool operator>= (const Version &version) const
 
bool operator< (const Version &version) const
 
bool operator<= (const Version &version) const
 

Static Public Attributes

static const Version ZERO
 

Detailed Description

Useful for representing versions. The versions are represented as a triplet composed of a major number, a minor number and a release number. Different major numbers means that two versions are uncompatible. The minor version number means ascending compatibility. The release number versions only denotes different debugging versions (no change in the interface of a compilation unit).

Constructor & Destructor Documentation

◆ Version() [1/5]

Version ( int  major = 0,
int  minor = 0,
int  release = 0 
)
inline

Build a new version.

Parameters
majorMajor number.
minorMinor number.
releaseRelease number.

References Version::major(), Version::minor(), and Version::release().

Referenced by Version::nextMajor(), Version::nextMinor(), and Version::nextRelease().

◆ Version() [2/5]

Version ( const Version version)
inline

Build a version by cloning.

Parameters
versionCloned version.

◆ Version() [3/5]

Version ( const char *  text)
inline

◆ Version() [4/5]

Version ( const cstring  text)
inline

◆ Version() [5/5]

Version ( const string text)
inline

Build a version from a string.

See also
operator=(const string& text)
Parameters
textString to build from.

Member Function Documentation

◆ accepts()

bool accepts ( const Version version) const
inline

Test if the current version accepts the given one, that is, the current one is ascendent-compatible with the given one.

Parameters
versionVersion to compare with.

Referenced by Plugger::plugFile().

◆ compare()

int compare ( const Version version) const
inline

Compare two versions. Notice that comparison is only performed on major and minor numbers.

Parameters
versionVersion to compare with.
Returns
0 for equality, <0 if current is less than passed one, >0 else.

Referenced by Version::operator!=(), Version::operator<(), Version::operator<=(), Version::operator==(), Version::operator>(), and Version::operator>=().

◆ major()

int major ( void  ) const
inline

Get the major number.

Referenced by elm::operator<<(), and Version::Version().

◆ minor()

int minor ( void  ) const
inline

Get the minor number.

Referenced by elm::operator<<(), and Version::Version().

◆ nextMajor()

Version nextMajor ( void  ) const
inline

Build a version with the next major number.

References Version::Version().

◆ nextMinor()

Version nextMinor ( void  ) const
inline

Build a version with the next minor number.

References Version::Version().

◆ nextRelease()

Version nextRelease ( void  ) const
inline

Build a version with the next release.

References Version::Version().

◆ operator bool()

operator bool ( void  ) const
inline

◆ operator!=()

bool operator!= ( const Version version) const
inline

References Version::compare().

◆ operator<()

bool operator< ( const Version version) const
inline

References Version::compare().

◆ operator<=()

bool operator<= ( const Version version) const
inline

References Version::compare().

◆ operator=() [1/4]

Version& operator= ( const char *  text)
inline

◆ operator=() [2/4]

Version& operator= ( const cstring  text)
inline

◆ operator=() [3/4]

Version & operator= ( const string text)

Set a version from a text string. The text string must have the following form: [0-9]+(.[0-9]+([0-9]+)?)?. If the string does not match, the version 0.0.0 is set.

Parameters
textText containing the version.
Returns
Current version.

References String::indexOf(), String::substring(), and Version::ZERO.

◆ operator=() [4/4]

Version & operator= ( const Version version)
inline

◆ operator==()

bool operator== ( const Version version) const
inline

References Version::compare().

◆ operator>()

bool operator> ( const Version version) const
inline

References Version::compare().

◆ operator>=()

bool operator>= ( const Version version) const
inline

References Version::compare().

◆ release()

int release ( void  ) const
inline

Get the release number.

Referenced by elm::operator<<(), and Version::Version().

Member Data Documentation

◆ ZERO

const Version ZERO
static

Zero version, that is, 0.0.0.

Referenced by Manager::displayHelp(), and Version::operator=().


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