aboutsummaryrefslogtreecommitdiff
path: root/include/Version.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/Version.hpp')
-rw-r--r--include/Version.hpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/include/Version.hpp b/include/Version.hpp
new file mode 100644
index 0000000..915f622
--- /dev/null
+++ b/include/Version.hpp
@@ -0,0 +1,68 @@
+#pragma once
+
+#include <string>
+
+namespace sibs
+{
+ enum class VersionOperation
+ {
+ LESS,
+ LESS_EQUAL,
+ EQUAL,
+ GREATER,
+ GREATER_EQUAL
+ };
+
+ const char* asString(VersionOperation operation);
+
+ struct PackageVersion
+ {
+ int major;
+ int minor;
+ int patch;
+
+ bool operator < (const PackageVersion &other) const
+ {
+ if(major < other.major) return true;
+ if(major == other.major && minor < other.minor) return true;
+ if(major == other.major && minor == other.minor && patch < other.patch) return true;
+ return false;
+ }
+
+ bool operator == (const PackageVersion &other) const
+ {
+ return (major == other.major) && (minor == other.minor) && (patch == other.patch);
+ }
+
+ bool operator <= (const PackageVersion &other) const
+ {
+ return *this < other || *this == other;
+ }
+
+ std::string toString() const;
+ };
+ static_assert(sizeof(PackageVersion) == sizeof(int) * 3, "Expected PackageVersion to be the same size as 3 ints");
+
+ struct PackageVersionRange
+ {
+ PackageVersionRange()
+ {
+ start = { 0, 0, 0 };
+ end = { 0, 0, 0 };
+ startDefined = false;
+ endDefined = false;
+ startOperation = VersionOperation::LESS;
+ endOperation = VersionOperation::LESS;
+ }
+
+ bool isInRange(const PackageVersion &version) const;
+ std::string toString() const;
+
+ PackageVersion start;
+ PackageVersion end;
+ bool startDefined;
+ bool endDefined;
+ VersionOperation startOperation;
+ VersionOperation endOperation;
+ };
+} \ No newline at end of file