Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

lrt::ParseInputStream Class Reference

A ParseInputStream can parse any input stream for tokens ("words") and read whole lines from them. More...

#include <rtstreams.h>

Inheritance diagram for lrt::ParseInputStream:

Inheritance graph
[legend]
List of all members.

Public Methods

 ParseInputStream (InputStream *in, const String &separators, const char commentStart=0)
 Creates a new ParseInputStream. More...

void setIgnoreComments (bool)
 Set if comments can be ignored. More...

void setAutoTrim (bool)
 Set if returned words and lines are auto-trimmed. More...

virtual void mark ()
 Marks the current position in the stream for later restoring it. More...

virtual void reset ()
 Restores the previously marked position in the stream. More...

virtual int read ()
 Reads a byte from the underlying input stream, or from the internal buffer.

String getWord (const String &specialSeps="")
 Reads a word from the input stream. More...

String getLine (bool skipEmpty=true)
 Reads a whole line from the input stream. More...

int getLineNumber ()
 Gets the current line number.

bool skipRestOfLine ()
 Discards the rest of the current line. More...

bool eos ()
 Returns true if the end of the underlying input stream is reached.


Static Public Attributes

const String whitespace
 The separators which make up whitespace, i.e. ' ', '\t' and '
'.
More...



Detailed Description

A ParseInputStream can parse any input stream for tokens ("words") and read whole lines from them.

It also keeps information about the current line number.


Constructor & Destructor Documentation

lrt::ParseInputStream::ParseInputStream (  InputStream *    in,
const String &    separators,
const char    commentStart = 0
) 
 

Creates a new ParseInputStream.

Parameters:
in  The input stream which provides the data for this parser.
separators  Characters which separate tokens ("words") from each other.
commentStart  The character which denotes the start of a end-of-line comment.


Member Function Documentation

String lrt::ParseInputStream::getLine (  bool    skipEmpty = true ) 
 

Reads a whole line from the input stream.

Parameters:
skipEmpty  (optional) If true, getLine() will skip empty lines and instead return the next non-empty line.

String lrt::ParseInputStream::getWord (  const String &    specialSeps = "" ) 
 

Reads a word from the input stream.

Parameters:
specialSeps  (optional) If given, does not use the input stream's default separators (as given on construction), but the given ones instead.

void lrt::ParseInputStream::mark (    )  [virtual]
 

Marks the current position in the stream for later restoring it.

This will only work if the underlying input stream supports marking.

Reimplemented from lrt::FilterInputStream.

void lrt::ParseInputStream::reset (    )  [virtual]
 

Restores the previously marked position in the stream.

This will only work if the underlying input stream supports marking.

Reimplemented from lrt::FilterInputStream.

void lrt::ParseInputStream::setAutoTrim (  bool    ) 
 

Set if returned words and lines are auto-trimmed.

If true, words and lines returned by a getWord() or getLine() will be stripped of any whitespace (including line ends). Also, words or lines which only consist of whitespace will be ignored completely. The line number counter will still work correctly. This option is turned off by default.

void lrt::ParseInputStream::setIgnoreComments (  bool    ) 
 

Set if comments can be ignored.

If true, comments will be skipped automatically by a getWord() or getLine(). Also, lines which only consist of a comment will be skipped completely. The line number counter will still work correctly. This option is turned off by default.

bool lrt::ParseInputStream::skipRestOfLine (    ) 
 

Discards the rest of the current line.

This includes the line end character '\n'.


Member Data Documentation

const String lrt::ParseInputStream::whitespace [static]
 

The separators which make up whitespace, i.e. ' ', '\t' and '
'.

This is a useful constant for the separators parameter.


The documentation for this class was generated from the following files:
This is the RoboTour API documentation version 0.1 • Copyright (C) by Florian Fischer