SofaBuffers C/C++ 0.12.0
API Documentation
Loading...
Searching...
No Matches
sofab::OStreamObjectOffset< MessageType, Offset > Class Template Reference

OStreamObject variant parameterized by offset only. More...

#include <sofab.hpp>

Inheritance diagram for sofab::OStreamObjectOffset< MessageType, Offset >:
[legend]
Collaboration diagram for sofab::OStreamObjectOffset< MessageType, Offset >:
[legend]

Additional Inherited Members

- Public Types inherited from sofab::OStreamImpl
using flushCallback = void(*)(std::span< const uint8_t >)
 Callback invoked with the bytes to flush (buffer full or on flush()).
 
- Public Member Functions inherited from sofab::OStreamObject< MessageType, N, Offset >
 OStreamObject () noexcept=default
 Construct with no flush callback.
 
 OStreamObject (OStreamImpl::flushCallback callback) noexcept
 Construct with a flush callback.
 
MessageType & operator-> () noexcept
 Member-access to the owned message (e.g. obj->field = ...).
 
OStreamImpl::Result serialize () noexcept
 Serialize the owned message and flush.
 
- Public Member Functions inherited from sofab::OStreamInline< N, Offset >
 OStreamInline () noexcept
 Construct with no flush callback.
 
 OStreamInline (flushCallback callback) noexcept
 Construct with a flush callback.
 
- Public Member Functions inherited from sofab::OStreamImpl
 OStreamImpl (const OStreamImpl &)=delete
 Copy construction is deleted (the context owns raw buffer pointers).
 
OStreamImpl & operator= (const OStreamImpl &)=delete
 Copy assignment is deleted (the context owns raw buffer pointers).
 
 OStreamImpl (OStreamImpl &&) noexcept=default
 Move construction (transfers the underlying context).
 
OStreamImpl & operator= (OStreamImpl &&) noexcept=default
 Move assignment (transfers the underlying context).
 
virtual ~OStreamImpl () noexcept
 Destructor; flushes any buffered bytes.
 
size_t flush () noexcept
 Flush buffered bytes through the flush callback (if any).
 
size_t bytesUsed () noexcept
 Number of bytes written to the active buffer since the last flush.
 
const uint8_t * data () const noexcept
 Pointer to the start of the active encode buffer.
 
template<typename T >
Result write (sofab_id_t id, const T &value) noexcept
 Encode a single field, deducing the wire type from T.
 
template<typename T >
Result writeLazy (sofab_id_t id, const T &value) noexcept
 Encode a nested message field, omitting it when all-default.
 
Result write (sofab_id_t id, const void *value, int32_t size) noexcept
 Encode a raw binary blob field.
 
template<typename T >
Result writeIf (sofab_id_t id, const T &value, bool condition) noexcept
 Encode a field only when condition is true.
 
Result sequenceBeginLazy (sofab_id_t id) noexcept
 Open a nested sequence whose header is held back until it turns out to have content.
 
Result sequenceEnd () noexcept
 Close the current nested sequence, letting it vanish if it got no content (MESSAGE_SPEC ยง2).
 
Result sequenceEndKeep () noexcept
 Close the current nested sequence, keeping its frame even without content.
 
bool ok () const noexcept
 Whether every write on this stream has succeeded.
 
Error error () const noexcept
 The first failure this stream saw, or Error::None.
 
Result rejectArgument () noexcept
 Refuse the value being encoded: latch Error::InvalidArgument.
 
- Protected Member Functions inherited from sofab::OStreamImpl
void onFlushCallback (size_t len) noexcept
 Invoke the user flush callback (if any) with len buffered bytes.
 
 OStreamImpl () noexcept=default
 
- Static Protected Member Functions inherited from sofab::OStreamImpl
static void static_flush_callback (sofab_ostream_t *ctx, const uint8_t *data, size_t len, void *usrptr) noexcept
 C-ABI flush trampoline: forwards to onFlushCallback() via usrptr.
 
- Protected Attributes inherited from sofab::OStreamImpl
sofab_ostream_t ctx_
 Underlying C output stream context.
 
uint8_t * buffer_
 Pointer to the active encode buffer.
 
flushCallback flushCallback_ {}
 Optional user flush callback.
 
uint8_t failed_ = 0
 Sticky: first failing write's sofab_ret_t (0 = none).
 

Detailed Description

template<OutputMessage MessageType, size_t Offset = 0>
class sofab::OStreamObjectOffset< MessageType, Offset >

OStreamObject variant parameterized by offset only.

Convenience alias-like class fixing N to the message's worst-case size while letting the caller choose a leading Offset (e.g. to reserve a header).

Template Parameters
MessageTypeAn OutputMessage type.
OffsetInitial write offset within the buffer.

Definition at line 1914 of file sofab.hpp.


The documentation for this class was generated from the following file: