#pragma once #include #include #include #include namespace breeze { /// A semantic version: major.minor.patch with an optional pre-release tag. /// A pre-release sorts before the release it leads up to (1.0.0-rc1 < 1.0.0). struct Version { int major = 0; int minor = 0; int patch = 0; std::string pre; [[nodiscard]] std::string toString() const; }; /// Accepts "1.2.3", "v1.2.3", "1.2.3-rc1", "1.2" (patch 0) and "1" (minor and patch 0); /// anything else, including build metadata after '+', is dropped or rejected. std::optional parseVersion(std::string_view text); int compare(const Version& a, const Version& b); bool operator<(const Version& a, const Version& b); bool operator==(const Version& a, const Version& b); /// The greatest of `versions`; with `sameMajorAs`, only of those with that major version. std::optional greatest(const std::vector& versions, std::optional sameMajorAs = std::nullopt); }