1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #ifndef CORE_BUFFER_HPP
- #define CORE_BUFFER_HPP
- #include "utils/Check.hpp"
- #include "utils/Error.hpp"
- 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);
- check_return Error copyFrom(const Buffer& other);
- check_return Error add(const void* data, int size);
- template<typename T>
- check_return Error 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
|