diff options
Diffstat (limited to 'include/cru/common/Buffer.h')
-rw-r--r-- | include/cru/common/Buffer.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/cru/common/Buffer.h b/include/cru/common/Buffer.h index 5c1f7ba3..a03b69eb 100644 --- a/include/cru/common/Buffer.h +++ b/include/cru/common/Buffer.h @@ -77,6 +77,8 @@ class Buffer final { Index PushFront(const std::byte* other, Index other_size, bool use_memmove = false); + bool PushBack(std::byte b); + /** * @brief Append data to the back of used bytes and increase used size. * @return The actual size of data saved. @@ -129,6 +131,15 @@ class Buffer final { operator std::byte*() { return GetPtr(); } operator const std::byte*() const { return GetPtr(); } + /** + * @brief Detach internal buffer and return it. + * @param size If not null, size of the buffer is written to it. + * @return The buffer pointer. May be nullptr. + * + * After detach, you are responsible to delete[] it. + */ + std::byte* Detach(Index* size = nullptr); + private: void Copy_(const Buffer& other); void Move_(Buffer&& other) noexcept; |