Parsed semver-style version: major.minor.patch with an optional pre-release identifier.
More...
#include <OpenMS/CONCEPT/VersionInfo.h>
|
| static VersionDetails | create (const std::string &version) |
| | Parse a semver-style "X.Y[.Z[-PRE]]" string into the struct.
|
| |
|
| 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 const VersionDetails | EMPTY |
| | Sentinel 0.0.0 version used both as the default-constructed value and as the parse-failure return of create.
|
| |
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.
◆ VersionDetails() [1/2]
Default-construct to 0.0.0 with an empty pre-release identifier (equivalent to EMPTY).
◆ VersionDetails() [2/2]
◆ create()
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] | version | Version string in "X.Y[.Z[-PRE]]" form. |
- Returns
- Parsed struct on success, EMPTY on any of the failure paths above.
◆ operator!=()
Field-wise inequality (the logical negation of operator==).
- Parameters
-
| [in] | rhs | Version to compare against. |
- Returns
true if at least one field differs.
◆ operator<()
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] | rhs | Version to compare against. |
- Returns
true if *this is strictly less than rhs by the rule above.
◆ operator=()
◆ operator==()
Field-wise equality on all four members, including string equality on the pre-release identifier.
- Parameters
-
| [in] | rhs | Version to compare against. |
- Returns
true if every field of *this equals the corresponding field of rhs.
◆ operator>()
Equivalent to !(*this < rhs || *this == rhs); inherits the operator< caveat about pre-release ties.
- Parameters
-
| [in] | rhs | Version to compare against. |
- Returns
true if *this is strictly greater than rhs.
◆ EMPTY
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
Major number ahead of the first '.'.
◆ version_minor
Minor number between the first and (optional) second '.'.
◆ version_patch
Patch number after the second '.'; left at 0 when the version string had only two components.