SW Task Event Loop Framework v1.0.0
High-performance C++ asynchronous event loop framework with timer management and promise-based programming
Loading...
Searching...
No Matches
Buffer.h
Go to the documentation of this file.
1
9 #pragma once
10 #include <vector>
11 #include <cstdint>
12 #include <memory>
13
14 namespace swt {
58 class Buffer {
59 public:
60 // ========== CONSTRUCTORS AND DESTRUCTOR ==========
61
70 Buffer();
71
81 Buffer(const Buffer& other);
82
89 ~Buffer();
90
109 Buffer& operator=(const Buffer& other);
110
111 // ========== SIZE AND INITIALIZATION METHODS ==========
112
130 void setSize(int32_t len);
131
132 // ========== DATA COPYING METHODS ==========
133
151 void setTo(const Buffer& buffer);
152
171 void setTo(uint8_t* buf, int32_t len);
172
190 void setTo(char* buf, int32_t len);
191
211 void append(uint8_t* buf, int32_t len);
212
213 // ========== DATA ACCESS METHODS ==========
214
236 uint8_t* data();
237
255 uint32_t size() const;
256
275 bool empty();
276
277 // ========== BUFFER MANAGEMENT METHODS ==========
278
296 void clear();
297
298 // ========== DEBUG AND UTILITY METHODS ==========
299
318 void dump();
319
341 static void dump(uint8_t* s, int32_t len);
342
343 private:
344 // ========== INTERNAL METHODS ==========
345
357 void _assign(uint32_t size);
358
369 void _release();
370
371 private:
372 // ========== MEMBER VARIABLES ==========
373
380 std::vector<uint8_t> mBuf;
381
388 bool mClear;
389 };
390 }
Dynamic byte buffer for data storage and manipulation.
Definition Buffer.h:58
uint8_t * data()
Get pointer to buffer data.
Definition Buffer.cpp:149
Buffer()
Default constructor - creates empty buffer.
Definition Buffer.cpp:21
uint32_t size() const
Get current buffer size.
Definition Buffer.cpp:160
void append(uint8_t *buf, int32_t len)
Append data to existing buffer contents.
Definition Buffer.cpp:131
void setTo(const Buffer &buffer)
Copy data from another buffer.
Definition Buffer.cpp:87
bool empty()
Check if buffer contains no data.
Definition Buffer.cpp:171
~Buffer()
Destructor - cleans up buffer resources.
Definition Buffer.cpp:42
void setSize(int32_t len)
Set buffer size and initialize with zeros.
Definition Buffer.cpp:73
void dump()
Dump current buffer contents to stdout.
Definition Buffer.cpp:199
Buffer & operator=(const Buffer &other)
Assignment operator - assigns data from another buffer.
Definition Buffer.cpp:54
void clear()
Clear all buffer contents and mark as cleared.
Definition Buffer.cpp:185
Software Timer namespace containing all timer-related classes.
Definition Awaitable.h:21