Tags: add ability to compare tags

This commit is contained in:
rr- 2016-03-16 19:35:48 +01:00
parent 74904fd516
commit 84a8d14ae0
2 changed files with 29 additions and 0 deletions

View File

@ -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();
}

View File

@ -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