Reader

Provides an API to read characters from a UTF-8 buffer and build slices into that buffer to avoid allocations (see SliceBuilder).

Constructors

this
this(ubyte[] buffer, string name)

Construct a Reader.

Members

Functions

charIndex
size_t charIndex()

Get index of the current character in the buffer.

column
uint column()

Get current column number.

encoding
Encoding encoding()

Get encoding of the input buffer.

forward
void forward(size_t length)

Move current position forward.

forward
void forward()

Move current position forward by one character.

get
dchar get()

Get the next character, moving buffer position beyond it.

get
char[] get(size_t length)

Get specified number of characters, moving buffer position beyond them.

line
uint line()

Get current line number.

mark
Mark mark()

Get a string describing current buffer position, used for error messages.

name
string name()

Get file name.

name
void name(string name)

Set file name.

peek
dchar peek(size_t index)

Get character at specified index relative to current position.

peek
dchar peek()

Optimized version of peek() for the case where peek index is 0.

peekByte
char peekByte(size_t index)

Get byte at specified index relative to current position.

peekByte
char peekByte()

Optimized version of peekByte() for the case where peek byte index is 0.

prefix
char[] prefix(size_t length)

Get specified number of characters starting at current position.

prefixBytes
char[] prefixBytes(size_t length)

Get specified number of bytes, not code points, starting at current position.

slice
char[] slice(size_t end)

Get a slice view of the internal buffer, starting at the current position.

Variables

sliceBuilder
SliceBuilder sliceBuilder;

Used to build slices of read data in Reader; to avoid allocations.

Meta