diff options
author | Ingo Klöcker <[email protected]> | 2023-02-01 09:12:18 +0000 |
---|---|---|
committer | Ingo Klöcker <[email protected]> | 2023-02-02 08:47:10 +0000 |
commit | 84780646910cdd91555a368650e3d92cf52b86bd (patch) | |
tree | 1dba7678d4dd1dc4023a631caea06d4c1c2ce3a5 | |
parent | core: Allow usage of gpgtar also for new enough gpg 2.2 (diff) | |
download | gpgme-84780646910cdd91555a368650e3d92cf52b86bd.tar.gz gpgme-84780646910cdd91555a368650e3d92cf52b86bd.zip |
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.h | 70 |
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 || |