summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Klöcker <dev@ingo-kloecker.de>2023-02-01 10:12:18 +0100
committerIngo Klöcker <dev@ingo-kloecker.de>2023-02-02 09:47:10 +0100
commit84780646910cdd91555a368650e3d92cf52b86bd (patch)
tree1dba7678d4dd1dc4023a631caea06d4c1c2ce3a5
parent7f541547fc1783bb9ea119695fb76e2000bdfcf8 (diff)
downloadgpgme-84780646910cdd91555a368650e3d92cf52b86bd.tar.gz
cpp: Add const-overloads of version comparison operators
* lang/cpp/src/engineinfo.h (EngineInfo::Version): Add const-overloads of all comparison operators. -- We keep the non-const overloads for binary compatibility. GnuPG-bug-id: 6342
-rw-r--r--lang/cpp/src/engineinfo.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/lang/cpp/src/engineinfo.h b/lang/cpp/src/engineinfo.h
index ce7b4eaf..5dc5370c 100644
--- a/lang/cpp/src/engineinfo.h
+++ b/lang/cpp/src/engineinfo.h
@@ -69,6 +69,76 @@ public:
}
}
+ bool operator < (const Version& other) const
+ {
+ if (major > other.major ||
+ (major == other.major && minor > other.minor) ||
+ (major == other.major && minor == other.minor && patch > other.patch) ||
+ (major >= other.major && minor >= other.minor && patch >= other.patch)) {
+ return false;
+ }
+ return true;
+ }
+
+ bool operator < (const char* other) const
+ {
+ return operator<(Version(other));
+ }
+
+ bool operator <= (const Version &other) const
+ {
+ return !operator>(other);
+ }
+
+ bool operator <= (const char *other) const
+ {
+ return operator<=(Version(other));
+ }
+
+ bool operator > (const char* other) const
+ {
+ return operator>(Version(other));
+ }
+
+ bool operator > (const Version & other) const
+ {
+ return !operator<(other) && !operator==(other);
+ }
+
+ bool operator >= (const Version &other) const
+ {
+ return !operator<(other);
+ }
+
+ bool operator >= (const char *other) const
+ {
+ return operator>=(Version(other));
+ }
+
+ bool operator == (const Version& other) const
+ {
+ return major == other.major
+ && minor == other.minor
+ && patch == other.patch;
+ }
+
+ bool operator == (const char* other) const
+ {
+ return operator==(Version(other));
+ }
+
+ bool operator != (const Version &other) const
+ {
+ return !operator==(other);
+ }
+
+ bool operator != (const char *other) const
+ {
+ return operator!=(Version(other));
+ }
+
+ // the non-const overloads of the comparison operators are kept for
+ // binary compatibility
bool operator < (const Version& other)
{
if (major > other.major ||