Cursor

A forward only data input iterator This is used either as adapter to File reading or as adapter to by-chunk data where arbitrary read length ease the implementation of an algorithm

Members

Functions

ffw
void ffw(ulong dist)

Fast-forward and discard dist bytes. Passing size_t.max will exhaust the input.

get
ubyte get()

Reads a single byte

getValue
T getValue()

Get a value of type T. Is a convenience over readValue.

read
ubyte[] read(ubyte[] buffer)

Read up to buffer.length bytes into buffer and return what was read. Returns a smaller slice only if EOI was reached.

read
T[] read(T[] buffer)
Undocumented in source. Be warned that the author may not have intended to support it.
readValue
void readValue(T* val)

Read T.sizeof data and returns it as a T. Similar to get!T but the value is passed as pointer to be filled in. Prefer this form for greater values (e.g. dozens of bytes)

Properties

eoi
bool eoi [@property getter]

Whether end-of-input was reached

name
string name [@property getter]

The name of the data source For FileCursor, this will be the filename, otherwise a description of the type of data.

pos
ulong pos [@property getter]

Position in the stream (how many bytes read so far)

Meta