#pragma once #include #include namespace roro { // True if `a` is an older release than `b`, comparing "vMAJOR.MINOR.PATCH" and ignoring any // git-describe suffix ("-3-gabc1234-dirty"). Anything that doesn't parse is never called older. inline bool parseVersion(const std::string& s, int out[3]) { size_t pos = s.size() > 0 && s[0] == 'v' ? 1 : 0; for (int i = 0; i < 3; i++) { if (pos >= s.size() || s[pos] < '0' || s[pos] > '9') return false; char* end; out[i] = static_cast(std::strtol(s.c_str() + pos, &end, 10)); pos = end - s.c_str(); if (i < 2) { if (pos >= s.size() || s[pos] != '.') return false; pos++; } } return true; } inline bool versionOlder(const std::string& a, const std::string& b) { int x[3], y[3]; if (!parseVersion(a, x) || !parseVersion(b, y)) return false; for (int i = 0; i < 3; i++) if (x[i] != y[i]) return x[i] < y[i]; return false; } } // namespace roro