![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Core/Utils/Version.h>
Utility class to work with version information following the SemVer format. More...
Utility class to work with version information following the SemVer format.
A valid version always contains of numeric major
, minor
, and patch
components, as well as an optional suffix
(called "pre-release version" in SemVer) and optional metadata
component. In addition to storing the above-mentioned information this class offers member functions for semantic comparison, and conversion from/to strings. When represented as textual string they are written as <major>.<minor>.<patch>[-<suffix>][+<metadata>]
.
0.0.0
is considered valid.
)suffix
and metadata
components Public Member Functions | |
Version (int major=0, int minor=0, int patch=0, std::string suffix="", std::string metadata="") | |
Creates a new Version instance. | |
bool | isValid () const noexcept |
Return whether all version parts are >= 0. | |
bool | isValidAndNotZero () const noexcept |
Return whether all version parts are >= 0 and at least one of them is > 0. | |
std::string | toString () const |
Format version as string <major>. | |
Static Public Member Functions | |
static Version | fromString (const std::string &versionString) |
Parses version information from a string. | |
Public Attributes | |
int | major = 0 |
Major version component. | |
int | minor = 0 |
Minor version component. | |
int | patch = 0 |
Patch version component. | |
std::string | suffix |
Optional suffix string indicating a pre-release. | |
std::string | metadata |
Optional build metadata string to store additional information about the version. | |
|
inline |
Creates a new Version instance.
major | Major version component |
minor | Minor version component |
patch | Patch version component |
suffix | Optional suffix string indicating a pre-release |
metadata | Optional metadata string to store additional information about the version |
|
static |
Parses version information from a string.
The string is expected to have the format <major>[.<minor>][.<patch>][-<suffix>][+<metadata>]
. Absent components will have their default value (0 or empty string, respectively). Leading and trailing whitespace, as well as any other content after the parsed version string will be ignored.
If parsing fails the returned Version will be invalid (i.e. components < 0).
|
noexcept |
Return whether all version parts are >= 0.
std::string toString | ( | ) | const |
Format version as string <major>.
<minor>.<patch>[-<suffix>][+<metadata>] or invalid
if it is not valid.