123456789101112131415161718192021222324252627282930313233 |
- #ifndef BUFFER_H
- #define BUFFER_H
- class Buffer {
- int length;
- int capacity;
- char* buffer;
- public:
- Buffer(int initialSize);
- Buffer(const Buffer& other);
- Buffer(Buffer&& other);
- ~Buffer();
- Buffer& operator=(Buffer other);
- Buffer& add(const void* data, int size);
- template<typename T>
- 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
|