mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka.git
synced 2025-10-31 18:47:48 +00:00
Added Buffer::Buffer(iter, iter) constructor overload
This commit is contained in:
@@ -82,6 +82,11 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Iter>
|
||||
Buffer(const Iter first, Iter last)
|
||||
: Buffer(&*first, std::distance(first, last)) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a buffer from a vector
|
||||
*
|
||||
|
||||
@@ -260,8 +260,7 @@ HeaderType HeaderList<HeaderType>::at(size_t index) const {
|
||||
if (error != RD_KAFKA_RESP_ERR_NO_ERROR) {
|
||||
throw Exception(error.to_string());
|
||||
}
|
||||
//Use 'Buffer' to implicitly convert to 'BufferType'
|
||||
return HeaderType(name, Buffer(value, size));
|
||||
return HeaderType(name, BufferType(value, value + size));
|
||||
}
|
||||
|
||||
template <typename HeaderType>
|
||||
|
||||
@@ -39,7 +39,11 @@ TEST_CASE("construction", "[buffer]") {
|
||||
const string str_data = "Hello world!";
|
||||
const vector<uint8_t> data(str_data.begin(), str_data.end());
|
||||
const Buffer buffer(data);
|
||||
const Buffer buffer2(data.begin(), data.end());
|
||||
const Buffer buffer3(str_data.data(), str_data.data() + str_data.size());
|
||||
CHECK(str_data == buffer);
|
||||
CHECK(buffer == buffer2);
|
||||
CHECK(buffer == buffer3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user