From c3406462d11b4241d4feee9be08e0ebe4f2e0bfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= Date: Thu, 15 Oct 2020 16:50:32 +0200 Subject: cpp, qt: Add missing comparison operators for version info comparison * lang/cpp/src/engineinfo.h (EngineInfo::Version::operator<=, EngineInfo::Version::operator>=, EngineInfo::Version::operator!=): New. * lang/qt/tests/t-various.cpp (TestVarious::testVersion): Add tests for new comparison operators. * NEWS: Mention added API --- lang/cpp/src/engineinfo.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'lang/cpp/src/engineinfo.h') diff --git a/lang/cpp/src/engineinfo.h b/lang/cpp/src/engineinfo.h index 0bf7d0e8..52bf3474 100644 --- a/lang/cpp/src/engineinfo.h +++ b/lang/cpp/src/engineinfo.h @@ -85,6 +85,16 @@ public: return operator<(Version(other)); } + bool operator <= (const Version &other) + { + return !operator>(other); + } + + bool operator <= (const char *other) + { + return operator<=(Version(other)); + } + bool operator > (const char* other) { return operator>(Version(other)); @@ -95,6 +105,16 @@ public: return !operator<(other) && !operator==(other); } + bool operator >= (const Version &other) + { + return !operator<(other); + } + + bool operator >= (const char *other) + { + return operator>=(Version(other)); + } + bool operator == (const Version& other) { return major == other.major @@ -107,6 +127,16 @@ public: return operator==(Version(other)); } + bool operator != (const Version &other) + { + return !operator==(other); + } + + bool operator != (const char *other) + { + return operator!=(Version(other)); + } + friend std::ostream& operator << (std::ostream& stream, const Version& ver) { stream << ver.major; -- cgit v1.2.3