Skip to content

raisim::server::BoundedWriter ​

class · #include <raisim/server/SerializationHelper.hpp>

Internal: write position in a bounded buffer. The set()/setN()/setInFloat() writers accept it in place of a raw char* and then throw SerializationError instead of writing outside the buffer; on a raw char* they are unchecked. A copy keeps the same bounds, so a saved position can be written again later (e.g. to patch a count reserved earlier).

Constructors & destructor ​

BoundedWriter ​

cpp
BoundedWriter() = default
cpp
BoundedWriter(char *begin, size_t bytes)

Parameters

ParameterDescription
begin (in)start of the writable buffer; writing starts here
bytes (in)size of the writable buffer in bytes

Public member functions ​

position ​

cpp
char *position() const

Returns the current write position

offset ​

cpp
size_t offset() const

Returns bytes between the start of the buffer and the current position

remaining ​

cpp
size_t remaining() const

Returns bytes available after the current write position

claim ​

cpp
char *claim(size_t bytes)

Claim the next bytes: check that they fit, then advance past them. Throws SerializationError, leaving the position unchanged, if they do not fit.

Parameters

ParameterDescription
bytes (in)number of bytes to claim

Returns where the claimed bytes start

RaiSim — physics for robotics and AI.