BSB Developer Docs
Loading...
Searching...
No Matches
semver.h File Reference

Semantic version (SemVer) utility library. More...

#include <core/string.h>

Go to the source code of this file.

Data Structures

struct  SemVer
 Structure representing the semantic version values. More...
 

Enumerations

enum  SemVerOrdering { SemVerOrderingEqual , SemVerOrderingNewer , SemVerOrderingOlder }
 Enumeration of semantic version orderings. More...
 

Functions

bool semver_parse (SemVer *instance, const char *source)
 Parse semantic version from a string.
 
SemVerOrdering semver_compare (const SemVer *instance, const SemVer *other)
 Compare two semantic versions.
 
void semver_to_string (const SemVer *instance, FuriString *out_string)
 Convert a SemVer instance to string representation.
 

Detailed Description

Semantic version (SemVer) utility library.

This implementation follows the x.y.z format. No additional fields are allowed.

Enumeration Type Documentation

◆ SemVerOrdering

Enumeration of semantic version orderings.

Enumerator
SemVerOrderingEqual 

Versions are equal.

SemVerOrderingNewer 

The version in question is newer than the other one.

SemVerOrderingOlder 

The version in question is older than the other one.

Function Documentation

◆ semver_compare()

SemVerOrdering semver_compare ( const SemVer * instance,
const SemVer * other )

Compare two semantic versions.

Parameters
[in]instancepointer to the instance to be compared
[in]otherpointer to the other instance to compare with
Returns
SemVerOrderingEqual both versions are equal
SemVerOrderingNewer instance is newer than other
SemVerOrderingOlder instance is older than other

◆ semver_parse()

bool semver_parse ( SemVer * instance,
const char * source )

Parse semantic version from a string.

If the instance pointer is NULL, the source string will still be parsed normally. This can be useful if the calling code only needs to validate the source string.

Parameters
[in,out]instancepointer to the instance to contain the parsed data (can be NULL)
[in]sourcepointer to a zero-terminated version string in x.y.z format
Returns
true if the source string could be parsed, false otherwise

◆ semver_to_string()

void semver_to_string ( const SemVer * instance,
FuriString * out_string )

Convert a SemVer instance to string representation.

Parameters
[in]instancepointer to the instance to be converted
[out]out_stringpointer to a FuriString to hold the string value (must be allocated)