Skip to content

raisim::server::ReadCursor ​

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

Internal: bounds-checked reader over an incoming wire payload. Reads past the end throw DeserializationError instead of overrunning the buffer.

Constructors & destructor ​

ReadCursor ​

cpp
ReadCursor() = default
cpp
ReadCursor(const char *begin, const char *end)

Same as reset(begin, end).

Parameters

ParameterDescription
begin (in)first byte to read
end (in)one past the last byte

Public member functions ​

reset ​

cpp
void reset(const char *begin, const char *end)

Point the cursor at [begin, end). Throws DeserializationError if a pointer is null or end < begin.

Parameters

ParameterDescription
begin (in)first byte to read
end (in)one past the last byte

remaining ​

cpp
size_t remaining() const

Returns bytes left to read. Throws DeserializationError if the cursor is uninitialized.

current ​

cpp
const char *current() const

Returns the next byte to be read (nullptr if uninitialized).

readBytes ​

cpp
void readBytes(void *destination, size_t bytes, const char *what)

Copy the next bytes and advance. Throws DeserializationError if fewer bytes remain.

Parameters

ParameterDescription
destination (out)where to copy the bytes
bytes (in)number of bytes
what (in)label used in the error message

RaiSim — physics for robotics and AI.