smjg.libs.util.console.ConsoleInput Class Reference

The smjg.libs.util.console.ConsoleInput class is used to receive text from the standard input. More...

List of all members.

Public Member Functions

dchar readChar ()
 Reads a single Unicode character from the input stream.
void discardLine ()
 Discards the currently buffered line of input.
size_t bytesInBuffer ()
 Returns the number of bytes currently waiting in the internal buffer.
size_t bytesInLine ()
 Returns the number of bytes remaining on the current line of input.
size_t charsInBuffer ()
 Returns the number of characters currently waiting in the internal buffer.
size_t charsInLine ()
 Returns the number of characters remaining on the current line of input.
char[] readLine (bool withNewLine=false)
 Reads a line of text from the input stream.
bool eof ()
 Determines whether EOF of the input stream has been reached.


Detailed Description

The smjg.libs.util.console.ConsoleInput class is used to receive text from the standard input.

This class buffers input on a line-by-line basis.

Since:
0.03

Member Function Documentation

dchar smjg.libs.util.console.ConsoleInput.readChar (  ) 

Reads a single Unicode character from the input stream.

Returns:
the character retrieved, or dchar.init on EOF.

void smjg.libs.util.console.ConsoleInput.discardLine (  ) 

Discards the currently buffered line of input.

The next call to readChar, readLine or eof will therefore wait for a line of input from the user and use it.

If no text is waiting in the buffer, this function has no effect.

size_t smjg.libs.util.console.ConsoleInput.bytesInBuffer (  ) 

Returns the number of bytes currently waiting in the internal buffer.

This can be used to determine whether there is any more text to read before waiting for the user to input more.

Returns:
the number of bytes of UTF-8 text in the buffer, including the terminating newline if present.
See also:
bytesInLine, charsInBuffer, charsInLine

size_t smjg.libs.util.console.ConsoleInput.bytesInLine (  ) 

Returns the number of bytes remaining on the current line of input.

This can be used to determine whether there is any text, other than a newline, which can be read before waiting for the user to input more.

Returns:
the number of bytes of UTF-8 text in the buffer, excluding any terminating newline.
See also:
bytesInBuffer, charsInBuffer, charsInLine

size_t smjg.libs.util.console.ConsoleInput.charsInBuffer (  ) 

Returns the number of characters currently waiting in the internal buffer.

Returns:
the number of characters in the buffer, including the terminating newline if present.
See also:
bytesInBuffer, bytesInLine, charsInLine

size_t smjg.libs.util.console.ConsoleInput.charsInLine (  ) 

Returns the number of characters remaining on the current line of input.

Returns:
the number of characters in the buffer, excluding any terminating newline.
See also:
bytesInBuffer, charsInBuffer, charsInLine

char [] smjg.libs.util.console.ConsoleInput.readLine ( bool  withNewLine = false  ) 

Reads a line of text from the input stream.

Parameters:
withNewLine whether to include the terminating newline if it is present. This makes a difference only to the last line retrieved before EOF.
Returns:
the line retrieved, or null on EOF.

bool smjg.libs.util.console.ConsoleInput.eof (  ) 

Determines whether EOF of the input stream has been reached.

This function also reads a line of input into the buffer if it is empty and there is any input to read. Therefore, it will wait for the user to input a line if one isn't already available.

Return values:
true if the end of the input has been reached, and the buffer is empty.
false if there is input still to be read.


The documentation for this class was generated from the following file:
Generated on Sun Sep 13 19:50:35 2009 for Stewart's Utility Library by  doxygen 1.5.4