From ce08fff22e4bed3d977cfd662ed2a6d8caa82997 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Mon, 14 Sep 2020 17:15:37 -0400 Subject: Database api Co-Authored-By: Josh Ferrell --- databuffer.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'databuffer.cpp') 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); -- cgit v1.3.1