From 785c03546ae8276a1f0cd54c44b26513d6ed91d2 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 24 Nov 2022 23:57:38 +0100 Subject: Tidy up some operators, made possible by the previous-but-one commit. --- src/language_tag.cc | 27 --------------------------- src/language_tag.h | 18 ++++++++++++------ 2 files changed, 12 insertions(+), 33 deletions(-) diff --git a/src/language_tag.cc b/src/language_tag.cc index 532dd557..8faf226c 100644 --- a/src/language_tag.cc +++ b/src/language_tag.cc @@ -332,33 +332,6 @@ LanguageTag::subtag_type_name (SubtagType type) return {}; } -bool -dcp::LanguageTag::VariantSubtag::operator== (VariantSubtag const & other) const -{ - return subtag() == other.subtag(); -} - - -bool -dcp::LanguageTag::VariantSubtag::operator< (VariantSubtag const & other) const -{ - return subtag() < other.subtag(); -} - - -bool -dcp::LanguageTag::ExtlangSubtag::operator== (ExtlangSubtag const & other) const -{ - return subtag() == other.subtag(); -} - - -bool -dcp::LanguageTag::ExtlangSubtag::operator< (ExtlangSubtag const & other) const -{ - return subtag() < other.subtag(); -} - bool dcp::operator== (dcp::LanguageTag const& a, dcp::LanguageTag const& b) diff --git a/src/language_tag.h b/src/language_tag.h index 1c7faa44..6f46c16b 100644 --- a/src/language_tag.h +++ b/src/language_tag.h @@ -71,6 +71,10 @@ public: bool operator== (SubtagData const& other) const { return subtag == other.subtag && description == other.description; } + + bool operator!=(SubtagData const& other) const { + return subtag != other.subtag || description != other.description; + } }; enum class SubtagType @@ -97,6 +101,14 @@ public: return _subtag == other._subtag; } + bool operator!=(Subtag const& other) const { + return _subtag != other._subtag; + } + + bool operator<(Subtag const& other) const { + return _subtag < other._subtag; + } + protected: Subtag (std::string subtag, SubtagType type); @@ -154,9 +166,6 @@ public: SubtagType type () const override { return SubtagType::VARIANT; } - - bool operator== (VariantSubtag const& other) const; - bool operator< (VariantSubtag const& other) const; }; @@ -171,9 +180,6 @@ public: SubtagType type () const override { return SubtagType::EXTLANG; } - - bool operator== (ExtlangSubtag const& other) const; - bool operator< (ExtlangSubtag const& other) const; }; LanguageTag () {} -- cgit v1.2.3