52 void write_u16(u16 data);
53 void write_u24(u32 data);
54 void write_u32(u32 data);
55 void write_u48(u64 data);
56 void write_u64(u64 data);
57 void write_s8(s8 data);
58 void write_s16(s16 data);
59 void write_s24(s32 data);
60 void write_s32(s32 data);
61 void write_s48(s64 data);
62 void write_s64(s64 data);
63 void write_f32(
float data);
64 void write_f64(
double data);
67 void write_u16l(u16 data);
68 void write_u24l(u32 data);
69 void write_u32l(u32 data);
70 void write_u48l(u64 data);
71 void write_u64l(u64 data);
72 void write_s16l(s16 data);
73 void write_s24l(s32 data);
74 void write_s32l(s32 data);
75 void write_s48l(s64 data);
76 void write_s64l(s64 data);
77 void write_f32l(
float data);
78 void write_f64l(
double data);
84 virtual void write_bytes(
unsigned nbytes,
const void* src);
105 {obj.write_to(
this);}
135 : m_dst((u8*)dst), m_len(len), m_ovr(false), m_wridx(0), m_wrlen(0) {}
137 : m_dst((u8*)dst), m_len(len), m_ovr(false), m_wridx(0), m_wrlen(0) {}
160 const unsigned m_len;
168 template <
unsigned SIZE>
190 : m_dst(dst), m_rem(maxwr) {}
192 : m_dst(dst), m_rem(maxwr) {}
196 void write_bytes(
unsigned nbytes,
const void* src)
override;
222 void write_bytes(
unsigned nbytes,
const void* src)
override;
238 explicit constexpr
NullWrite(
unsigned wspace)
239 : m_write_space(wspace) {}
241 void write_bytes(
unsigned nbytes,
const void* src)
override;
244 const unsigned m_write_space;
Ephemeral Writeable interface for a simple array.
unsigned written_len() const
Report total length after write_finalize() is called.
constexpr ArrayWrite(unsigned len, void *dst)
Create an ArrayWrite object linked to the provided working buffer.
constexpr ArrayWrite(void *dst, unsigned len)
Create an ArrayWrite object linked to the provided working buffer.
bool write_finalize() override
Mark end of frame and release temporary working data.
void write_abort() override
If possible, abort the current partially-written packet.
void write_overflow() override
Optional error handling for write overflow.
void write_next(u8 data) override
Write the next byte to the underlying buffer or device.
const u8 * buffer() const
Read-only access to the working buffer.
unsigned get_write_space() const override
How many bytes can be written without blocking?
Thin wrapper for ArrayWrite with a built-in buffer.
Limited write up to N bytes.
void write_next(u8 data) override
Write the next byte to the underlying buffer or device.
void write_bytes(unsigned nbytes, const void *src) override
Write 0 or more bytes from a buffer.
constexpr LimitedWrite(unsigned maxwr, satcat5::io::Writeable *dst)
Explicitly set maximum write length in bytes.
unsigned get_write_space() const override
How many bytes can be written without blocking?
constexpr LimitedWrite(satcat5::io::Writeable *dst, unsigned maxwr)
Explicitly set maximum write length in bytes.
Writeable object that accepts and discards all incoming data.
unsigned get_write_space() const override
How many bytes can be written without blocking?
void write_next(u8 data) override
Write the next byte to the underlying buffer or device.
void write_bytes(unsigned nbytes, const void *src) override
Write 0 or more bytes from a buffer.
Forwards incoming writes to multiple downstream Writeables.
Abstract API for writing byte-streams and packets.
virtual unsigned get_write_space() const =0
How many bytes can be written without blocking?
virtual void write_bytes(unsigned nbytes, const void *src)
Write 0 or more bytes from a buffer.
virtual void write_abort()
If possible, abort the current partially-written packet.
void write_u8(u8 data)
One of many functions for writing integer/floating point values, see details.
virtual void write_overflow()
Optional error handling for write overflow.
void write_str(const char *str)
Write the contents of a null-terminated string.
virtual void write_next(u8 data)=0
Write the next byte to the underlying buffer or device.
constexpr Writeable()
Only children should create or destroy the base class.
virtual bool write_finalize()
Mark end of frame and release temporary working data.
void write_obj(const T &obj)
Templated wrapper for any object with the following method: void write_to(satcat5::io::Writeable* wr)...
Wrapper class for forwarding writes to another object.
void write_next(u8 data) override
Write the next byte to the underlying buffer or device.
unsigned get_write_space() const override
How many bytes can be written without blocking?
void write_overflow() override
Optional error handling for write overflow.
bool write_finalize() override
Mark end of frame and release temporary working data.
void write_bytes(unsigned nbytes, const void *src) override
Write 0 or more bytes from a buffer.
void write_abort() override
If possible, abort the current partially-written packet.
satcat5::io::NullWrite null_write
Global instance of the basic NullWrite object.
Basic type aliases and prototypes used throughout SatCat5.