9#ifndef MAXOS_COMMON_BUFFER_H
10#define MAXOS_COMMON_BUFFER_H
18namespace MaxOS::common {
28 uint8_t* m_bytes =
nullptr;
30 bool m_dont_delete =
false;
39 [[nodiscard]] uint8_t*
raw()
const;
42 void full(uint8_t
byte,
size_t offset = 0,
size_t amount = 0);
47 [[nodiscard]]
size_t capacity()
const;
50 void write(uint8_t
byte);
51 void write(
size_t offset, uint8_t
byte);
53 uint8_t
read(
size_t offset);
58 void copy_from(
const Buffer* buffer,
size_t length,
size_t offset,
size_t offset_other);
59 void copy_from(
const void* source,
size_t length);
60 void copy_from(
const void* source,
size_t length,
size_t offset);
65 void copy_to(
Buffer* buffer,
size_t length,
size_t offset,
size_t offset_other);
66 void copy_to(
void* destination,
size_t length);
67 void copy_to(
void* destination,
size_t length,
size_t offset);
Wrapper class for a region of bytes in memor in an attempt to add some memory safety....
void write(uint8_t byte)
Safely writes a byte to the buffer at the current offset.
~Buffer()
Destroy the buffer, freeing the memory.
void full(uint8_t byte, size_t offset=0, size_t amount=0)
Full the buffer with a specified byte at an offset.
void set_offset(size_t offset)
Set the offset for where operations should begin from.
size_t capacity() const
The max bytes the buffer can currently store.
uint8_t * raw() const
The raw pointer to the bytes stored in memory, use is not recommended.
uint8_t read()
Safely reads a byte from the buffer at the current offset.
bool update_offset
Should operations write/read/copy update the offset in the buffer?
void copy_to(Buffer *buffer)
Copies all the bytes from this buffer into another buffer.
void copy_from(const Buffer *buffer)
Copies all the bytes from another buffer into this buffer.
void resize(size_t size)
Grow the buffer to fit a new size.
void clear()
Fulls the buffer with 0's and resets the offset.
Defines a Logger class for logging messages with different severity levels to multiple output streams...
Defines classes for memory input and output operations of various bit widths (8, 16,...