Detailed Description

Treats a string of characters as a stream. This allows it to be read one character at a time. Attempting to read after the end of the stream will generate a Dom.StringReader.NULL character.

Inheritance diagram for Dom.StringReader:
Css.CssLexer Dom.HtmlLexer Nitro.CodeLexer

Public Member Functions

 StringReader (byte[] str)
 Creates a new reader for the raw single-byte encoded string. Useful if you're talking to e.g. a webserver with a binary protocol. More...
 
 StringReader (string str)
 Creates a new reader for the given string. More...
 
bool More ()
 Checks if there is anything left to read. More...
 
bool Peek (string str)
 Checks if the given string is next. More...
 
bool PeekLower (string str)
 Checks if the given string is next; it checks by lowercasing the target character. More...
 
char Peek ()
 Takes a peek at the next character in the stream without reading it. More...
 
char Peek (int delta)
 Takes a peek at the character that is a number of characters away from the next one without actually reading it. Peek(0) is the next character, Peek(1) is the one after that etc. More...
 
void StepBack ()
 Steps back one place in the stream. More...
 
void Advance ()
 Steps forward one place in the stream. More...
 
void Advance (int places)
 Steps forward the given number of places in the stream. More...
 
int Length ()
 The length of the string. More...
 
string ReadString (int length)
 Reads a substring of the given length. Note that this does not do bounds checking. More...
 
virtual char Read ()
 Reads a character from the stream and advances the stream one place. More...
 
void ReadUntil (char character)
 Keeps reading the given character from the stream until it's no longer next. Used for e.g. stripping an unknown length block of whitespaces in the stream. More...
 
void ReadOff (char[] chars)
 Keeps reading from the stream until no characters in the given set are next. Used for e.g. stripping an unknown number of newlines (
or ) from this stream. More...
 
void ReadOff (char[] chars, out int count)
 Keeps reading from the stream until no characters in the given set are next. Used for e.g. stripping an unknown number of newlines (
or ) from this stream. More...
 
int NextIndexOf (char character)
 Gets the next index of the given character. The length is returned if it wasn't found at all. More...
 
int NextIndexOf (char character, int limit)
 Gets the next index of the given character, up to limit. Limit is returned if it wasn't found at all. More...
 
virtual int GetLineNumber ()
 Gets the line number that the pointer is currently at. More...
 
int GetLineNumber (out int charOnLine)
 Gets the line number and character number that the pointer is currently at. More...
 
string ReadLine (int lineNumber)
 Reads the numbered line from this stream. More...
 

Static Public Member Functions

static int NextIndexOf (int position, string input, char character, int limit)
 Gets the next index of the given character, up to limit. Limit is returned if it wasn't found at all. More...
 
static int NextIndexOf (int position, string input, char character)
 Gets the next index of the given character. The length is returned if it wasn't found at all. More...
 

Public Attributes

string Input
 The original string. More...
 
int Position
 The current position this reader is at in the string. More...
 
int InputLength
 The length of the input string. More...
 

Static Public Attributes

static char NULL ='\0'
 The null character. This is returned when operations are working beyond the end of the stream. More...
 

Constructor & Destructor Documentation

Dom.StringReader.StringReader ( byte[]  str)
inline

Creates a new reader for the raw single-byte encoded string. Useful if you're talking to e.g. a webserver with a binary protocol.

Parameters
strThe set of characters that is encoded as one byte per character.
Dom.StringReader.StringReader ( string  str)
inline

Creates a new reader for the given string.

Parameters
strThe string to treat as a stream of characters.

Member Function Documentation

void Dom.StringReader.Advance ( )
inline

Steps forward one place in the stream.

void Dom.StringReader.Advance ( int  places)
inline

Steps forward the given number of places in the stream.

virtual int Dom.StringReader.GetLineNumber ( )
inlinevirtual

Gets the line number that the pointer is currently at.

Returns
The current line number, starting from 1.
int Dom.StringReader.GetLineNumber ( out int  charOnLine)
inline

Gets the line number and character number that the pointer is currently at.

Parameters
charOnLineThe column/ character number the reader is at on this line.
Returns
The current line number, starting from 1.
int Dom.StringReader.Length ( )
inline

The length of the string.

bool Dom.StringReader.More ( )
inline

Checks if there is anything left to read.

Returns
True if there is more content to read.
int Dom.StringReader.NextIndexOf ( char  character)
inline

Gets the next index of the given character. The length is returned if it wasn't found at all.

int Dom.StringReader.NextIndexOf ( char  character,
int  limit 
)
inline

Gets the next index of the given character, up to limit. Limit is returned if it wasn't found at all.

static int Dom.StringReader.NextIndexOf ( int  position,
string  input,
char  character,
int  limit 
)
inlinestatic

Gets the next index of the given character, up to limit. Limit is returned if it wasn't found at all.

static int Dom.StringReader.NextIndexOf ( int  position,
string  input,
char  character 
)
inlinestatic

Gets the next index of the given character. The length is returned if it wasn't found at all.

bool Dom.StringReader.Peek ( string  str)
inline

Checks if the given string is next.

char Dom.StringReader.Peek ( )
inline

Takes a peek at the next character in the stream without reading it.

char Dom.StringReader.Peek ( int  delta)
inline

Takes a peek at the character that is a number of characters away from the next one without actually reading it. Peek(0) is the next character, Peek(1) is the one after that etc.

bool Dom.StringReader.PeekLower ( string  str)
inline

Checks if the given string is next; it checks by lowercasing the target character.

virtual char Dom.StringReader.Read ( )
inlinevirtual

Reads a character from the stream and advances the stream one place.

Reimplemented in Nitro.CodeLexer.

string Dom.StringReader.ReadLine ( int  lineNumber)
inline

Reads the numbered line from this stream.

Parameters
lineNumberThe number of the line to read.
Returns
The numbered line as a string.
void Dom.StringReader.ReadOff ( char[]  chars)
inline

Keeps reading from the stream until no characters in the given set are next. Used for e.g. stripping an unknown number of newlines (
or ) from this stream.

Parameters
charsThe set of characters to read off.
void Dom.StringReader.ReadOff ( char[]  chars,
out int  count 
)
inline

Keeps reading from the stream until no characters in the given set are next. Used for e.g. stripping an unknown number of newlines (
or ) from this stream.

Parameters
charsThe set of characters to read off.
countThe number of characters that were read from the stream.
string Dom.StringReader.ReadString ( int  length)
inline

Reads a substring of the given length. Note that this does not do bounds checking.

void Dom.StringReader.ReadUntil ( char  character)
inline

Keeps reading the given character from the stream until it's no longer next. Used for e.g. stripping an unknown length block of whitespaces in the stream.

Parameters
characterThe character to read off from this stream.
void Dom.StringReader.StepBack ( )
inline

Steps back one place in the stream.

Member Data Documentation

string Dom.StringReader.Input

The original string.

int Dom.StringReader.InputLength

The length of the input string.

char Dom.StringReader.NULL ='\0'
static

The null character. This is returned when operations are working beyond the end of the stream.

int Dom.StringReader.Position

The current position this reader is at in the string.