#ifndef CORE_BUFFER_HPP #define CORE_BUFFER_HPP #include "core/utils/Check.hpp" #include "core/utils/Error.hpp" #include "core/utils/Types.hpp" namespace Core { class Buffer final { size_t length; size_t capacity; char* buffer; public: Buffer(size_t initialSize = 32); Buffer(const Buffer& other) = delete; Buffer(Buffer&& other); ~Buffer(); Buffer& operator=(const Buffer& other) = delete; Buffer& operator=(Buffer&& other); CError copyFrom(const Buffer& other); CError add(const void* data, size_t size); template check_return Error add(const T& t) { return add(&t, sizeof(T)); } size_t getLength() const; operator const char*() const; const char* getData() const; void clear(); void swap(Buffer& other); }; } #endif