mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-30 03:15:38 -05:00
add any (*
) to ComparableVersionInfo
This commit is contained in:
parent
7d74f16c01
commit
2b1dc178a4
2 changed files with 17 additions and 6 deletions
|
@ -13,6 +13,7 @@ namespace geode {
|
|||
MoreEq,
|
||||
Less,
|
||||
More,
|
||||
Any
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -196,6 +197,10 @@ namespace geode {
|
|||
static Result<ComparableVersionInfo> parse(std::string const& string);
|
||||
|
||||
constexpr bool compare(VersionInfo const& version) const {
|
||||
if (m_compare == VersionCompare::Any) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// opposing major versions never match
|
||||
if (m_version.getMajor() != version.getMajor()) {
|
||||
return false;
|
||||
|
|
|
@ -133,6 +133,11 @@ std::ostream& geode::operator<<(std::ostream& stream, VersionInfo const& version
|
|||
Result<ComparableVersionInfo> ComparableVersionInfo::parse(std::string const& rawStr) {
|
||||
VersionCompare compare;
|
||||
auto string = rawStr;
|
||||
|
||||
if (string == "*") {
|
||||
return Ok(ComparableVersionInfo({0, 0, 0}, VersionCompare::Any));
|
||||
}
|
||||
|
||||
if (string.starts_with("<=")) {
|
||||
compare = VersionCompare::LessEq;
|
||||
string.erase(0, 2);
|
||||
|
@ -162,13 +167,14 @@ Result<ComparableVersionInfo> ComparableVersionInfo::parse(std::string const& ra
|
|||
}
|
||||
|
||||
std::string ComparableVersionInfo::toString() const {
|
||||
std::string prefix = "";
|
||||
std::string prefix;
|
||||
switch (m_compare) {
|
||||
case VersionCompare::Exact: prefix = "="; break;
|
||||
case VersionCompare::LessEq: prefix = "<="; break;
|
||||
case VersionCompare::MoreEq: prefix = ">="; break;
|
||||
case VersionCompare::Less: prefix = "<"; break;
|
||||
case VersionCompare::More: prefix = ">"; break;
|
||||
case VersionCompare::Any: return "*";
|
||||
}
|
||||
return prefix + m_version.toString();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue