Files
maliakal_d 3864a6cdad
Build on RHEL9 docker image / build (push) Successful in 4m4s
Build on RHEL8 docker image / build (push) Successful in 5m9s
Build and Deploy on local RHEL9 / build (push) Successful in 2m8s
Build and Deploy on local RHEL8 / build (push) Successful in 5m11s
Run Simulator Tests on local RHEL9 / build (push) Successful in 20m41s
Run Simulator Tests on local RHEL8 / build (push) Successful in 24m7s
dev/fixed version comparisons (#1623)
* fixed version comparisons, previously done lexicographically

* using structs and refactoring

* tests and small comment fix

* tests to check prerelease <= release
2026-10-22 16:51:27 +02:00

54 lines
1.5 KiB
C++

// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
#pragma once
#include <iosfwd>
#include <stdint.h>
#include <string>
namespace sls {
struct SemanticVersion {
int major{0};
int minor{0};
int patch{0};
std::string prerelease{};
std::string toString() const;
bool operator==(const SemanticVersion &other) const;
bool operator<=(const SemanticVersion &other) const;
};
class Version {
private:
/** Note: "0.0.0" is considered not semantic versioning here */
bool hasSemanticVersioning_{false};
SemanticVersion version_{};
std::string date_;
SemanticVersion parseSemanticVersion(const std::string &version);
public:
explicit Version(const std::string &s);
std::string toString() const;
bool hasSemanticVersioning() const;
std::string getVersion() const;
std::string getDate() const;
std::string concise() const;
// throws if not semantic versioning
SemanticVersion getSemanticVersion() const;
int getMajorVersion() const;
int getMinorVersion() const;
int getPatchVersion() const;
std::string getPrereleaseVersion() const;
bool isBackwardCompatible(const Version &other) const;
bool operator!=(const Version &other) const;
bool operator==(const Version &other) const;
bool operator<=(const Version &other) const;
};
std::ostream &operator<<(std::ostream &out, const SemanticVersion &v);
std::ostream &operator<<(std::ostream &out, const Version &v);
} // namespace sls