#ifndef BUFFER_H #define BUFFER_H class Buffer final { int length; int capacity; char* buffer; public: Buffer(int initialSize = 32); Buffer(const Buffer& other); Buffer(Buffer&& other); ~Buffer(); Buffer& operator=(Buffer other); Buffer& add(const void* data, int size); template Buffer& add(const T& t) { add(&t, sizeof(T)); return *this; } int getLength() const; operator const char*() const; void clear(); private: void swap(Buffer& other); }; #endif