SocketReader

Input range that will read data from a socket and return token-separated values. The token will be excluded.

This struct is allocation-free as it acts as a (specialized) circular buffer.

package
struct SocketReader (
size_t MAX_FIELD_SIZE = 512
size_t FIELDS = 16
) {}

Members

Functions

empty
bool empty()

Tells whenever the range is empty (i.e. no more fields can be read)

front
cstring front()

Get the current element

popFront
ssize_t popFront(ISocket socket, int flags)

Discard the current item (front) and process the next field

Variables

e
ErrnoException e;

Exception to throw on error

Parameters

MAX_FIELD_SIZE

Maximum length a line can have. As lines can be non-contiguous (if a line starts at the end of the circular buffer and ends at the beginning of it), but we need to provide them contiguous to the reader, a buffer is used and written to in this situation.

FIELDS

The maximum number of maximum length fields that the buffer can store. In other words, MAX_FIELD_SIZE * FIELDS == capacity.

Meta