From e4b3987cc6e2cc1a28bbaf566f0fb6625e25f3ee Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 22 Nov 2018 15:00:12 +0100 Subject: stdbuf: Track buffer size --- include/object/stdbuf.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'include/object/stdbuf.h') diff --git a/include/object/stdbuf.h b/include/object/stdbuf.h index db30621..271c3ea 100644 --- a/include/object/stdbuf.h +++ b/include/object/stdbuf.h @@ -8,12 +8,17 @@ class BufferOutput : public T { private: BufferOutput(const BufferOutput ©); char *buffer; + uint16_t length; public: - BufferOutput(char *target) { buffer = target; } + BufferOutput(char *target) : buffer(target), length(0) {} virtual void put(char c) { *buffer = c; buffer++; + length++; + } + inline uint16_t size() { + return length; } }; -- cgit v1.2.3