#ifndef CORE_BUFFER_H #define CORE_BUFFER_H #include "utils/Check.h" namespace Core { class Buffer final { int length; int capacity; char* buffer; public: Buffer(int initialSize = 32); Buffer(const Buffer& other) = delete; Buffer(Buffer&& other); ~Buffer(); Buffer& operator=(const Buffer& other) = delete; Buffer& operator=(Buffer&& other); // returns true on error and calls the error callback check_return bool copyFrom(const Buffer& other); // returns true on error and calls the error callback check_return bool add(const void* data, int size); // returns true on error and calls the error callback template check_return bool add(const T& t) { return add(&t, sizeof(T)); } int getLength() const; operator const char*() const; const char* getData() const; void clear(); private: void swap(Buffer& other); }; } #endif