Represents a semantic version with major, minor, patch. Additionally, supports the inclusion of optional pre-release, and build metadata components. It adheres to the Semantic Versioning 2.0.0 standard.
More...
#include <Version.hpp>
|
| | SemanticVersion (const ::QString &version) |
| | Full initialisation string constructor following the semantic version format.
|
| | SemanticVersion (std::uint8_t major=0u, std::uint8_t minor=0u, std::uint8_t patch=0u, std::optional<::QString > preRelease=std::nullopt, std::optional<::QString > buildMetadata=std::nullopt) |
| | Full initialisation constructor.
|
| const std::optional<::QString > & | buildMetadata () const noexcept |
| | An accessor to the build metadata.
|
| std::uint8_t | major () const noexcept |
| | An accessor to the major version.
|
| std::uint8_t | minor () const noexcept |
| | An accessor to the minor version.
|
| bool | operator!= (const SemanticVersion &other) const noexcept=default |
| std::strong_ordering | operator<=> (const SemanticVersion &other) const noexcept |
| | Compares two objects using a three-way comparison.
|
| bool | operator== (const SemanticVersion &other) const noexcept |
| std::uint8_t | patch () const noexcept |
| | An accessor to the patch version.
|
| const std::optional<::QString > & | preRelease () const noexcept |
| | An accessor to the pre-release version.
|
|
| DRN_UPDATING_EXPORT std::ostream & | operator<< (std::ostream &out, const SemanticVersion &sv) |
| | Populates an output stream with a semantic version.
|
Represents a semantic version with major, minor, patch. Additionally, supports the inclusion of optional pre-release, and build metadata components. It adheres to the Semantic Versioning 2.0.0 standard.
- See also
- https://semver.org/ for more information.
◆ SemanticVersion() [1/2]
| drn::updating::SemanticVersion::SemanticVersion |
( |
std::uint8_t | major = 0u, |
|
|
std::uint8_t | minor = 0u, |
|
|
std::uint8_t | patch = 0u, |
|
|
std::optional<::QString > | preRelease = std::nullopt, |
|
|
std::optional<::QString > | buildMetadata = std::nullopt ) |
Full initialisation constructor.
- Exceptions
-
| Error | When the pre-release string is invalid. |
| Error | When the build metadata string is invalid. |
- Parameters
-
| major | The major component of the version. |
| minor | The minor component of the version. |
| patch | The patch component of the version. |
| preRelease | Any pre-release identifier for the version. |
| buildMetadata | Any build metadata information. |
◆ SemanticVersion() [2/2]
| drn::updating::SemanticVersion::SemanticVersion |
( |
const ::QString & | version | ) |
|
|
explicit |
Full initialisation string constructor following the semantic version format.
- Exceptions
-
| Error | When the version string is invalid. |
- Parameters
-
| version | The semantic version string, e.g. "1.2.3-alpha.1+20241019". |
◆ buildMetadata()
| const std::optional<::QString > & drn::updating::SemanticVersion::buildMetadata |
( |
| ) |
const |
|
nodiscardnoexcept |
An accessor to the build metadata.
◆ major()
| std::uint8_t drn::updating::SemanticVersion::major |
( |
| ) |
const |
|
nodiscardnoexcept |
An accessor to the major version.
◆ minor()
| std::uint8_t drn::updating::SemanticVersion::minor |
( |
| ) |
const |
|
nodiscardnoexcept |
An accessor to the minor version.
◆ operator!=()
| bool drn::updating::SemanticVersion::operator!= |
( |
const SemanticVersion & | other | ) |
const |
|
nodiscarddefaultnoexcept |
◆ operator<=>()
| std::strong_ordering drn::updating::SemanticVersion::operator<=> |
( |
const SemanticVersion & | other | ) |
const |
|
nodiscardnoexcept |
Compares two objects using a three-way comparison.
The comparison follows semantic versioning rules:
- If the major versions are different, the one with the higher major version is greater.
- If the major versions are identical, the minor versions are compared next.
- If the minor versions are identical, the patch versions are compared next.
- If the patch versions are identical, pre-release versions are compared next.
- Pre-release versions have lower precedence than the associated normal version.
- Build metadata is not considered at any point.
- Parameters
-
| other | The other object to compare with. |
- Returns
- The result of the comparison of this object to the supplied object.
◆ operator==()
| bool drn::updating::SemanticVersion::operator== |
( |
const SemanticVersion & | other | ) |
const |
|
nodiscardnoexcept |
◆ patch()
| std::uint8_t drn::updating::SemanticVersion::patch |
( |
| ) |
const |
|
nodiscardnoexcept |
An accessor to the patch version.
◆ preRelease()
| const std::optional<::QString > & drn::updating::SemanticVersion::preRelease |
( |
| ) |
const |
|
nodiscardnoexcept |
An accessor to the pre-release version.
◆ operator<<
| DRN_UPDATING_EXPORT std::ostream & operator<< |
( |
std::ostream & | out, |
|
|
const SemanticVersion & | sv ) |
|
friend |
Populates an output stream with a semantic version.
- Parameters
-
| out | The output stream to populate. |
| sv | The version object to fill the stream with. |
- Postcondition
- The output stream contains the version in the form:
- major.minor.patch-preRelease+buildMetadata
- Returns
- The output stream with the version.