chore(cpn): move SemanticVersion to own code files (#6844)

This commit is contained in:
Neil Horne
2025-12-07 07:38:49 +10:00
committed by GitHub
parent 7ec8b39661
commit ed17e4e649
7 changed files with 338 additions and 290 deletions
-70
View File
@@ -250,76 +250,6 @@ private:
extern Stopwatch gStopwatch;
class SemanticVersion
{
public:
explicit SemanticVersion(const QString vers);
explicit SemanticVersion() {}
~SemanticVersion() {}
bool isValid(const QString vers);
bool isValid();
bool fromString(const QString vers);
QString toString() const;
unsigned int toInt() const;
bool fromInt(const unsigned int val);
bool isEmpty(const QString vers);
bool isEmpty();
bool isPreRelease(const QString vers);
bool isPreRelease();
SemanticVersion& operator=(const SemanticVersion& rhs);
bool operator==(const SemanticVersion& rhs) {
return compare(rhs) == 0;
}
bool operator!=(const SemanticVersion& rhs) {
return compare(rhs) != 0;
}
bool operator>(const SemanticVersion& rhs) {
return compare(rhs) > 0;
}
bool operator>=(const SemanticVersion& rhs) {
return compare(rhs) >= 0;
}
bool operator<(const SemanticVersion& rhs) {
return compare(rhs) < 0;
}
bool operator<=(const SemanticVersion& rhs) {
return compare(rhs) <= 0;
}
private:
enum PreReleaseTypes {
PR_ALPHA = 0,
PR_BETA,
PR_RC,
PR_NONE
};
const QStringList PreReleaseTypesStringList = { "alpha", "beta", "rc"};
struct Version {
int major = 0;
int minor = 0;
int patch = 0;
int preReleaseType = PR_NONE;
int preReleaseNumber = 0;
};
Version version;
int compare(const SemanticVersion& other);
inline QString preReleaseTypeToString() const { return PreReleaseTypesStringList.value(version.preReleaseType, ""); }
inline int preReleaseTypeToInt(QString preRelType) const { return PreReleaseTypesStringList.indexOf(preRelType); }
};
class StatusDialog: public QDialog
{
Q_OBJECT