mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka.git
synced 2025-11-02 11:37:50 +00:00
Make Buffer::operator== a free function
This commit is contained in:
@@ -134,16 +134,6 @@ public:
|
|||||||
return std::vector<T>(data_, data_ + size_);
|
return std::vector<T>(data_, data_ + size_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Compares this Buffer for equality
|
|
||||||
*/
|
|
||||||
bool operator==(const Buffer& rhs) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compares this Buffer for inequality
|
|
||||||
*/
|
|
||||||
bool operator!=(const Buffer& rhs) const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output operator
|
* Output operator
|
||||||
*/
|
*/
|
||||||
@@ -153,6 +143,16 @@ private:
|
|||||||
size_t size_;
|
size_t size_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares Buffer objects for equality
|
||||||
|
*/
|
||||||
|
bool operator==(const Buffer& lhs, const Buffer& rhs);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares Buffer objects for inequality
|
||||||
|
*/
|
||||||
|
bool operator!=(const Buffer& lhs, const Buffer& rhs);
|
||||||
|
|
||||||
} // cppkafka
|
} // cppkafka
|
||||||
|
|
||||||
#endif // CPPKAFKA_BUFFER_H
|
#endif // CPPKAFKA_BUFFER_H
|
||||||
|
|||||||
@@ -74,17 +74,6 @@ Buffer::operator string() const {
|
|||||||
return string(data_, data_ + size_);
|
return string(data_, data_ + size_);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Buffer::operator==(const Buffer& rhs) const {
|
|
||||||
if (get_size() != rhs.get_size()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return equal(get_data(), get_data() + get_size(), rhs.get_data());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Buffer::operator!=(const Buffer& rhs) const {
|
|
||||||
return !(*this == rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
ostream& operator<<(ostream& output, const Buffer& rhs) {
|
ostream& operator<<(ostream& output, const Buffer& rhs) {
|
||||||
for (const uint8_t value : rhs) {
|
for (const uint8_t value : rhs) {
|
||||||
if (value >= 0x20 && value < 0x7f) {
|
if (value >= 0x20 && value < 0x7f) {
|
||||||
@@ -101,4 +90,15 @@ ostream& operator<<(ostream& output, const Buffer& rhs) {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator==(const Buffer& lhs, const Buffer& rhs) {
|
||||||
|
if (lhs.get_size() != rhs.get_size()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return equal(lhs.get_data(), lhs.get_data() + lhs.get_size(), rhs.get_data());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const Buffer& lhs, const Buffer& rhs) {
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
} // cppkafka
|
} // cppkafka
|
||||||
|
|||||||
Reference in New Issue
Block a user