From 84a8d14ae0da54bee00ba3ef1018c178c8c8aa85 Mon Sep 17 00:00:00 2001 From: rr- Date: Wed, 16 Mar 2016 19:35:48 +0100 Subject: [PATCH] Tags: add ability to compare tags --- src/tags.cc | 23 +++++++++++++++++++++++ src/tags.h | 6 ++++++ 2 files changed, 29 insertions(+) diff --git a/src/tags.cc b/src/tags.cc index 40ee00a..eb1ef01 100644 --- a/src/tags.cc +++ b/src/tags.cc @@ -14,6 +14,17 @@ static bool iequals(const std::string &a, const std::string &b) return true; } +bool Tag::operator !=(const Tag &other_tag) const +{ + return !operator ==(other_tag); +} + +bool Tag::operator ==(const Tag &other_tag) const +{ + return key == other_tag.key + && value == other_tag.value; +} + Tags::Tags() { } @@ -78,3 +89,15 @@ Tag opustags::parse_tag(const std::string &assoc) std::string value = assoc.substr(eq + 1); return { name, value }; } + +bool Tags::operator !=(const Tags &other_tags) const +{ + return !operator ==(other_tags); +} + +bool Tags::operator ==(const Tags &other_tags) const +{ + return vendor == other_tags.vendor + && extra == other_tags.extra + && get_all() == other_tags.get_all(); +} diff --git a/src/tags.h b/src/tags.h index aaf09b6..6291227 100644 --- a/src/tags.h +++ b/src/tags.h @@ -8,6 +8,9 @@ namespace opustags { struct Tag final { + bool operator !=(const Tag &other_tag) const; + bool operator ==(const Tag &other_tag) const; + std::string key; std::string value; }; @@ -28,6 +31,9 @@ namespace opustags { bool contains(const std::string &key) const; void clear(); + bool operator !=(const Tags &other_tags) const; + bool operator ==(const Tags &other_tags) const; + // Additional fields are required to match the specs: // https://tools.ietf.org/html/draft-ietf-codec-oggopus-14#section-5.2