ESFormats: Make Content easier to compare

This commit is contained in:
Léo Lam 2017-10-01 12:37:17 +02:00
parent 1a4883ac5a
commit 2974c56e50
2 changed files with 13 additions and 0 deletions

View File

@ -67,6 +67,17 @@ bool Content::IsOptional() const
return (type & 0x4000) != 0;
}
bool operator==(const Content& lhs, const Content& rhs)
{
auto fields = [](const Content& c) { return std::tie(c.id, c.index, c.type, c.size, c.sha1); };
return fields(lhs) == fields(rhs);
}
bool operator!=(const Content& lhs, const Content& rhs)
{
return !operator==(lhs, rhs);
}
SignedBlobReader::SignedBlobReader(const std::vector<u8>& bytes) : m_bytes(bytes)
{
}

View File

@ -93,6 +93,8 @@ struct Content
std::array<u8, 20> sha1;
};
static_assert(sizeof(Content) == 36, "Content has the wrong size");
bool operator==(const Content&, const Content&);
bool operator!=(const Content&, const Content&);
struct TimeLimit
{