From e68331598e01b22fde7eb75afb5f9da226c812d1 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Thu, 22 Aug 2024 12:58:12 -0400 Subject: [PATCH] include/buffer: add helpers for uint8_t vectors Signed-off-by: Patrick Donnelly (cherry picked from commit 814245ce789836a4e6224f2f9fb2b3c54241030d) --- src/include/buffer.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/include/buffer.h b/src/include/buffer.h index 16ee0055ad2..2b82e683da2 100644 --- a/src/include/buffer.h +++ b/src/include/buffer.h @@ -700,6 +700,12 @@ struct error_code; void copy_shallow(unsigned len, ptr &dest); void copy(unsigned len, list &dest); void copy(unsigned len, std::string &dest); + template + void copy(unsigned len, std::vector& u8v) { + u8v.resize(len); + copy(len, (char*)u8v.data()); + } + void copy_all(list &dest); // get a pointer to the currenet iterator position, return the @@ -1140,6 +1146,10 @@ struct error_code; void append(std::string_view s) { append(s.data(), s.length()); } + template + void append(const std::vector& u8v) { + append((const char *)u8v.data(), u8v.size()); + } #endif // __cplusplus >= 201703L void append(const ptr& bp); void append(ptr&& bp); -- 2.39.5