Sourcemeta Core 0.0.0
Loading...
Searching...
No Matches
SemVer

An implementation of the Semantic Versioning 2.0.0 specification. More...

Classes

class  sourcemeta::core::SemVer

Detailed Description

An implementation of the Semantic Versioning 2.0.0 specification.

This functionality is included as follows:

#include <sourcemeta/core/semver.h>

Class Documentation

◆ sourcemeta::core::SemVer

class sourcemeta::core::SemVer

A non-owning view over a parsed SemVer 2.0.0 version string. The input string must outlive this object.

Public Types

enum class  Mode : std::uint8_t { Strict , Loose }
 The level of strictness applied when parsing a version string. More...

Public Member Functions

 SemVer (std::string_view input, Mode mode=Mode::Strict)
 Construct a version by parsing the given string, throwing on failure.
SOURCEMETA_FORCEINLINE auto major () const noexcept -> std::uint64_t
 The major version number.
SOURCEMETA_FORCEINLINE auto minor () const noexcept -> std::uint64_t
 The minor version number.
SOURCEMETA_FORCEINLINE auto patch () const noexcept -> std::uint64_t
 The patch version number.
SOURCEMETA_FORCEINLINE auto pre_release () const noexcept -> std::string_view
 The pre-release identifier, or empty if none is present.
SOURCEMETA_FORCEINLINE auto build () const noexcept -> std::string_view
 The build metadata, or empty if none is present.
auto to_string () const -> std::string
 Serialise the version back into its string representation.

Static Public Member Functions

static auto from (std::string_view input, Mode mode=Mode::Strict) noexcept -> std::optional< SemVer >
 Parse a version from the given string, returning no value on failure.

Member Enumeration Documentation

◆ Mode

enum class sourcemeta::core::SemVer::Mode : std::uint8_t
strong

The level of strictness applied when parsing a version string.

Enumerator
Strict 

Require a fully compliant version string.

Loose 

Permit common shorthand deviations on the version core.