diff options
| author | Glenn Smith <glenn@vector35.com> | 2020-09-14 17:15:37 -0400 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2021-07-13 15:04:49 -0400 |
| commit | ce08fff22e4bed3d977cfd662ed2a6d8caa82997 (patch) | |
| tree | 9fed8c3070837f38099d13ff78a7577fbc4ac168 /databuffer.cpp | |
| parent | 10e668db4d76658882bee7b75d47063b054a730d (diff) | |
Database api
Co-Authored-By: Josh Ferrell <josh@vector35.com>
Diffstat (limited to 'databuffer.cpp')
| -rw-r--r-- | databuffer.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/databuffer.cpp b/databuffer.cpp index 001ef8e9..cf4a608a 100644 --- a/databuffer.cpp +++ b/databuffer.cpp @@ -89,6 +89,28 @@ DataBuffer& DataBuffer::operator=(DataBuffer&& buf) return *this; } +bool DataBuffer::operator==(const DataBuffer& other) const +{ + uint8_t* data = (uint8_t*)GetData(); + uint8_t* otherData = (uint8_t*)other.GetData(); + if (GetLength() != other.GetLength()) + return false; + if (data == otherData) + return true; + + for (size_t i = 0; i < GetLength(); i++) + { + if (data[i] != otherData[i]) + return false; + } + return true; +} + +bool DataBuffer::operator!=(const DataBuffer& other) const +{ + return !(*this == other); +} + void* DataBuffer::GetData() { return BNGetDataBufferContents(m_buffer); |
