mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-05 03:21:42 +00:00
[wpinet] uv::Buffer: Add bytes() accessor (#5653)
Also add uint8_t constructors.
This commit is contained in:
@@ -42,10 +42,23 @@ class Buffer : public uv_buf_t {
|
||||
base = const_cast<char*>(base_);
|
||||
len = static_cast<decltype(len)>(len_);
|
||||
}
|
||||
Buffer(uint8_t* base_, size_t len_) {
|
||||
base = reinterpret_cast<char*>(base_);
|
||||
len = static_cast<decltype(len)>(len_);
|
||||
}
|
||||
Buffer(const uint8_t* base_, size_t len_) {
|
||||
base = reinterpret_cast<char*>(const_cast<uint8_t*>(base_));
|
||||
len = static_cast<decltype(len)>(len_);
|
||||
}
|
||||
|
||||
std::span<const char> data() const { return {base, len}; }
|
||||
std::span<char> data() { return {base, len}; }
|
||||
|
||||
std::span<const uint8_t> bytes() const {
|
||||
return {reinterpret_cast<const uint8_t*>(base), len};
|
||||
}
|
||||
std::span<uint8_t> bytes() { return {reinterpret_cast<uint8_t*>(base), len}; }
|
||||
|
||||
operator std::span<const char>() const { return data(); } // NOLINT
|
||||
operator std::span<char>() { return data(); } // NOLINT
|
||||
|
||||
|
||||
Reference in New Issue
Block a user