OpenMS
Loading...
Searching...
No Matches
VersionInfo::VersionDetails Struct Reference

Parsed semver-style version: major.minor.patch with an optional pre-release identifier. More...

#include <OpenMS/CONCEPT/VersionInfo.h>

Collaboration diagram for VersionInfo::VersionDetails:
[legend]

Public Member Functions

 VersionDetails ()=default
 Default-construct to 0.0.0 with an empty pre-release identifier (equivalent to EMPTY).
 
 VersionDetails (const VersionDetails &other)=default
 Copy constructor.
 
VersionDetailsoperator= (const VersionDetails &other)=default
 Copy assignment.
 
bool operator< (const VersionDetails &rhs) const
 Compare two versions lexicographically by (major, minor, patch).
 
bool operator== (const VersionDetails &rhs) const
 Field-wise equality on all four members, including string equality on the pre-release identifier.
 
bool operator!= (const VersionDetails &rhs) const
 Field-wise inequality (the logical negation of operator==).
 
bool operator> (const VersionDetails &rhs) const
 Equivalent to !(*this < rhs || *this == rhs); inherits the operator< caveat about pre-release ties.
 

Static Public Member Functions

static VersionDetails create (const std::string &version)
 Parse a semver-style "X.Y[.Z[-PRE]]" string into the struct.
 

Public Attributes

Int version_major = 0
 Major number ahead of the first '.'.
 
Int version_minor = 0
 Minor number between the first and (optional) second '.'.
 
Int version_patch = 0
 Patch number after the second '.'; left at 0 when the version string had only two components.
 
std::string pre_release_identifier
 Pre-release suffix after a trailing '-' (everything to the end of the string); empty when no '-' is present.
 

Static Public Attributes

static const VersionDetails EMPTY
 Sentinel 0.0.0 version used both as the default-constructed value and as the parse-failure return of create.
 

Detailed Description

Parsed semver-style version: major.minor.patch with an optional pre-release identifier.

Result type of VersionInfo::getVersionStruct (and of create when called with a free-form version string). Default-constructed instances compare equal to EMPTY and represent both the "0.0.0 with no pre-release" version and the parse-failure sentinel returned by create.

Constructor & Destructor Documentation

◆ VersionDetails() [1/2]

VersionDetails ( )
default

Default-construct to 0.0.0 with an empty pre-release identifier (equivalent to EMPTY).

◆ VersionDetails() [2/2]

VersionDetails ( const VersionDetails other)
default

Copy constructor.

Member Function Documentation

◆ create()

static VersionDetails create ( const std::string &  version)
static

Parse a semver-style "X.Y[.Z[-PRE]]" string into the struct.

Splits on '.' and the optional trailing '-':

  • At least one '.' is required — strings without a dot return EMPTY.
  • The major number must parse as an integer.
  • The minor number must parse as an integer; if no second '.' follows, patch is left at 0 and parsing succeeds.
  • The patch number must parse as an integer; if no trailing '-' is present, pre_release_identifier is left empty and parsing succeeds.
  • Everything after the trailing '-' (verbatim, no further parsing) becomes pre_release_identifier.

Any integer conversion failure (caught OpenMS::Exception::ConversionError) yields EMPTY; the function does not propagate the exception.

Parameters
[in]versionVersion string in "X.Y[.Z[-PRE]]" form.
Returns
Parsed struct on success, EMPTY on any of the failure paths above.

◆ operator!=()

bool operator!= ( const VersionDetails rhs) const

Field-wise inequality (the logical negation of operator==).

Parameters
[in]rhsVersion to compare against.
Returns
true if at least one field differs.

◆ operator<()

bool operator< ( const VersionDetails rhs) const

Compare two versions lexicographically by (major, minor, patch).

Versions are compared lexicographically by the (major, minor, patch) triple. A version with a pre-release identifier is considered less than the same triple without a pre-release (e.g., 1.0.0-alpha < 1.0.0). When both sides have a pre-release identifier, the triples are treated as equal for ordering (e.g., 1.0.0-alpha is not < 1.0.0-beta).

Parameters
[in]rhsVersion to compare against.
Returns
true if *this is strictly less than rhs by the rule above.

◆ operator=()

VersionDetails & operator= ( const VersionDetails other)
default

Copy assignment.

◆ operator==()

bool operator== ( const VersionDetails rhs) const

Field-wise equality on all four members, including string equality on the pre-release identifier.

Parameters
[in]rhsVersion to compare against.
Returns
true if every field of *this equals the corresponding field of rhs.

◆ operator>()

bool operator> ( const VersionDetails rhs) const

Equivalent to !(*this < rhs || *this == rhs); inherits the operator< caveat about pre-release ties.

Parameters
[in]rhsVersion to compare against.
Returns
true if *this is strictly greater than rhs.

Member Data Documentation

◆ EMPTY

const VersionDetails EMPTY
static

Sentinel 0.0.0 version used both as the default-constructed value and as the parse-failure return of create.

◆ pre_release_identifier

std::string pre_release_identifier

Pre-release suffix after a trailing '-' (everything to the end of the string); empty when no '-' is present.

◆ version_major

Int version_major = 0

Major number ahead of the first '.'.

◆ version_minor

Int version_minor = 0

Minor number between the first and (optional) second '.'.

◆ version_patch

Int version_patch = 0

Patch number after the second '.'; left at 0 when the version string had only two components.