LookAheadBuffer Class

Provides access to a stream and allows to peek at the next characters, up to the buffer's capacity.

public class LookAheadBuffer : ILookAheadBuffer

Remarks

This class implements a circular buffer with a fixed capacity.

Implements

Constructors

NameDescription
LookAheadBuffer(TextReader, int)Initializes a new instance of the LookAheadBuffer class.

LookAheadBuffer(TextReader, int)

LookAheadBuffer.cs

Initializes a new instance of the LookAheadBuffer class.

public LookAheadBuffer(TextReader input, int capacity)

Parameters

input TextReader
The input.
capacity int
The capacity.

Properties

NameDescription
EndOfInputGets a value indicating whether the end of the input reader has been reached.

Gets a value indicating whether the end of the input reader has been reached.

public bool EndOfInput { get; }

Property value

bool

Methods

NameDescription
Cache(int)Reads characters until at least length characters are in the buffer.
Peek(int)Gets the character at thhe specified offset.
Skip(int)Skips the next length characters. Those characters must have been obtained first by calling the LookAheadBuffer.Peek or LookAheadBuffer.Cache methods.

Reads characters until at least length characters are in the buffer.

public void Cache(int length)

Parameters

length int
Number of characters to cache.

Gets the character at thhe specified offset.

public char Peek(int offset)

Parameters

offset int

Returns

char

Skips the next length characters. Those characters must have been obtained first by calling the LookAheadBuffer.Peek or LookAheadBuffer.Cache methods.

public void Skip(int length)

Parameters

length int