![]() |
Deluge Firmware 1.3.0
Build date: 2025.04.16
|
Used to parse SemVers from strings. More...
#include <semver.h>
Public Types | |
enum class | Error { INVALID_NUMBER , WRONG_CHAR , END_OF_STREAM } |
Common parsing errors. More... | |
Public Member Functions | |
Parser (std::string_view input) | |
Create a new parser with the given string. | |
std::expected< SemVer, Error > | parse () |
Execute the parser, returning either the well-formed SemVer or a Parser::Error. | |
Private Member Functions | |
std::expected< void, Error > | expect (char expected) |
Expect a character to be the next in the stream. | |
std::expected< SemVer, Error > | parseVersionCore () |
Parses a Semantic Versioning "version core" (i.e. '1.20.7') from the input stream. | |
std::expected< uint8_t, Error > | parseNumericIdentifier () |
Parse a number from the input stream. | |
std::string_view | parsePreRelease () |
Consumes all characters up to the build-tag identifier '+' and returns them. | |
Private Attributes | |
std::string_view | input_ |
size_t | index_ = 0 |
Used to parse SemVers from strings.
|
strong |
|
private |
Expect a character to be the next in the stream.
[in] | expected | The character to read |
Error::WRONG_CHAR | The character was not found |
Error::END_OF_STREAM | The input string ran out of characters to read |
|
private |
Parse a number from the input stream.
Technically less strict than the true SemVer grammar requires, this internally uses std::from_chars to parse the string to an int.
Error::INVALID_NUMBER | If the number cannot be parsed |
|
private |
Consumes all characters up to the build-tag identifier '+' and returns them.
|
private |
Parses a Semantic Versioning "version core" (i.e. '1.20.7') from the input stream.
see https://semver.org/#backusnaur-form-grammar-for-valid-semver-versions