summaryrefslogtreecommitdiff
path: root/src/buffer.hh
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2025-02-20 22:54:56 +0100
committerJoel Klinghed <the_jk@spawned.biz>2025-02-20 22:54:56 +0100
commitb4d6df902253637f24647d3db2bc3781d69eec1c (patch)
treed8bf9ac04a270fabdfee1c15628c702471ef8bf5 /src/buffer.hh
parent441cafc7124f633e5abc684e85a11ce3c991f6ae (diff)
Initial commitHEADmain
Diffstat (limited to 'src/buffer.hh')
-rw-r--r--src/buffer.hh25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/buffer.hh b/src/buffer.hh
new file mode 100644
index 0000000..ae02e23
--- /dev/null
+++ b/src/buffer.hh
@@ -0,0 +1,25 @@
+#ifndef BUFFER_HH
+#define BUFFER_HH
+
+#include "ro_buffer.hh"
+
+#include <memory>
+
+class Buffer : public RoBuffer {
+public:
+ static std::unique_ptr<Buffer> fixed(size_t size);
+ static std::unique_ptr<Buffer> growing(size_t base_size, size_t max_size);
+ // Acts as /dev/null, ie always empty, can write anything to it.
+ static std::unique_ptr<Buffer> null();
+
+ virtual bool full() const = 0;
+
+ virtual void clear() = 0;
+
+ virtual char* wbuf(size_t request, size_t& avail) = 0;
+ virtual void wcommit(size_t bytes) = 0;
+
+ size_t write(void const* data, size_t len);
+};
+
+#endif // BUFFER_HH