Merge pull request #14662 from AGlass0fMilk/can-message-comparison-operators

Add CANMessage deep comparison operators
pull/14702/head
Anna Bridge 2021-05-25 14:05:03 +01:00 committed by GitHub
commit 891805b42e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 29 additions and 0 deletions

View File

@ -109,6 +109,35 @@ public:
id = _id;
memset(data, 0, 8);
}
/**
* "Deep" comparison operator (ie: compare value of each data member)
*/
bool operator ==(const CANMessage &b) const
{
if (id != b.id) {
return false;
}
if (len != b.len) {
return false;
}
if (format != b.format) {
return false;
}
if (type != b.type) {
return false;
}
if (memcmp(data, b.data, len) != 0) {
return false;
}
return true;
}
bool operator !=(const CANMessage &b) const
{
return !(*this == b);
}
};
/** @}*/