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
BoundedWriter() = defaultBoundedWriter(char *begin, size_t bytes)Parameters
| Parameter | Description |
|---|---|
begin (in) | start of the writable buffer; writing starts here |
bytes (in) | size of the writable buffer in bytes |
Public member functions
position
char *position() constReturns the current write position
offset
size_t offset() constReturns bytes between the start of the buffer and the current position
remaining
size_t remaining() constReturns bytes available after the current write position
claim
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
| Parameter | Description |
|---|---|
bytes (in) | number of bytes to claim |
Returns where the claimed bytes start