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() = defaultcpp
ReadCursor(const char *begin, const char *end)Same as reset(begin, end).
Parameters
| Parameter | Description |
|---|---|
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
| Parameter | Description |
|---|---|
begin (in) | first byte to read |
end (in) | one past the last byte |
remaining
cpp
size_t remaining() constReturns bytes left to read. Throws DeserializationError if the cursor is uninitialized.
current
cpp
const char *current() constReturns 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
| Parameter | Description |
|---|---|
destination (out) | where to copy the bytes |
bytes (in) | number of bytes |
what (in) | label used in the error message |