Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
SemVer Struct Reference

Represents a simple Semantic Version number such as "4.3.7-beta". More...

#include <semver.h>

Classes

class  Parser
 Used to parse SemVers from strings. More...
 

Public Member Functions

bool operator== (const SemVer &) const =default
 Default equality operator.
 
std::strong_ordering operator<=> (const SemVer &other) const
 Compare two SemVer objects.
 

Static Public Member Functions

static std::expected< SemVer, Parser::Errorparse (std::string_view input)
 Parse a SemVer from a string.
 

Public Attributes

uint8_t major
 Major version.
 
uint8_t minor
 Minor version.
 
uint8_t patch
 Patch version.
 
std::string_view pre_release {}
 Pre-release string.
 

Detailed Description

Represents a simple Semantic Version number such as "4.3.7-beta".

Member Function Documentation

◆ operator<=>()

std::strong_ordering SemVer::operator<=> ( const SemVer & other) const

Compare two SemVer objects.

This is a custom operator implementation (instead of default) due due to the way semver handles "pre-release" information. If a SemVer has a pre-release extension, it is considered older (less than) than the same SemVer without that extension. This means that simple field-by-field compare cannot be done, as the pre-release would normally require lexicographical comparison and count anything longer as "greater than", which is the opposite of what's desired.

◆ parse()

static std::expected< SemVer, Parser::Error > SemVer::parse ( std::string_view input)
inlinestatic

Parse a SemVer from a string.

This is just a helper object to construct the parser and run it

Parameters
inputThe string to parse
Returns
std::expected<SemVer, Parser::Error> Either the successfully parsed SemVer, or the Error that arose during parsing.

The documentation for this struct was generated from the following files: