102 if (buf && len > 0) {
103 mBuf.assign(buf, buf + len);
118 setTo(
reinterpret_cast<uint8_t*
>(buf), len);
132 if (buf && len > 0) {
133 mBuf.insert(mBuf.end(), buf, buf + len);
150 return mBuf.empty() ? nullptr : mBuf.data();
161 return static_cast<uint32_t
>(mBuf.size());
201 dump(mBuf.data(),
static_cast<int32_t
>(mBuf.size()));
203 std::cout <<
"Buffer dump: (empty buffer)" << std::endl;
219 if (!s || len <= 0) {
220 std::cout <<
"Buffer dump: (null or empty data)" << std::endl;
224 std::cout <<
"Buffer dump (" << len <<
" bytes): ";
227 auto flags = std::cout.flags();
230 std::cout << std::hex << std::uppercase << std::setfill(
'0');
232 for (int32_t i = 0; i < len; ++i) {
233 std::cout << std::setw(2) << static_cast<unsigned int>(s[i]);
234 if (i < len - 1) std::cout <<
" ";
238 std::cout.flags(flags);
239 std::cout << std::endl;
254 void Buffer::_assign(uint32_t size) {
266 void Buffer::_release() {
Buffer class for dynamic byte storage and manipulation.
Dynamic byte buffer for data storage and manipulation.
uint8_t * data()
Get pointer to buffer data.
Buffer()
Default constructor - creates empty buffer.
uint32_t size() const
Get current buffer size.
void append(uint8_t *buf, int32_t len)
Append data to existing buffer contents.
void setTo(const Buffer &buffer)
Copy data from another buffer.
bool empty()
Check if buffer contains no data.
~Buffer()
Destructor - cleans up buffer resources.
void setSize(int32_t len)
Set buffer size and initialize with zeros.
void dump()
Dump current buffer contents to stdout.
Buffer & operator=(const Buffer &other)
Assignment operator - assigns data from another buffer.
void clear()
Clear all buffer contents and mark as cleared.
Software Timer namespace containing all timer-related classes.