aboutsummaryrefslogtreecommitdiff
path: root/include/cru/common/Buffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/cru/common/Buffer.h')
-rw-r--r--include/cru/common/Buffer.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/include/cru/common/Buffer.h b/include/cru/common/Buffer.h
new file mode 100644
index 00000000..5390ebb4
--- /dev/null
+++ b/include/cru/common/Buffer.h
@@ -0,0 +1,50 @@
+#pragma once
+
+#include "Base.h"
+
+namespace cru {
+class Buffer {
+ public:
+ explicit Buffer(Index size);
+
+ Buffer(const Buffer& other);
+ Buffer(Buffer&& other) noexcept;
+
+ Buffer& operator=(const Buffer& other);
+ Buffer& operator=(Buffer&& other) noexcept;
+
+ ~Buffer();
+
+ private:
+ Index GetSize() const;
+ Index GetUsedSize() const;
+ bool IsFull() const { return GetSize() == GetUsedSize(); }
+ bool IsNotFull() const { return !IsFull(); }
+
+ std::byte& GetAt(Index index);
+ std::byte GetAt(Index index) const;
+
+ Index PushEnd(std::byte* other, Index other_size);
+ Index PopEnd(Index size);
+
+ std::byte* Data();
+ const std::byte* Data() const;
+
+ operator std::byte*() { return Data(); }
+ operator const std::byte*() const { return Data(); }
+
+ private:
+ std::byte* ptr_;
+ Index size_;
+ Index used_size_;
+};
+
+void swap(Buffer& left, Buffer& right);
+
+class BufferList {
+ public:
+ explicit BufferList(Index buffer_size);
+ private:
+
+};
+} // namespace cru