mirror of
https://github.com/fmang/opustags.git
synced 2025-03-14 08:30:08 +01:00
Tags: add ability to compare tags
This commit is contained in:
parent
74904fd516
commit
84a8d14ae0
23
src/tags.cc
23
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();
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user