University of Sheffield   

    The Simons
    Component Library

Introduction   Class Hierarchy   Class Listing   Index of Classes   Index of Methods   Header Files  

TextInput Class Reference

#include <TextInput.h>

Inheritance diagram for TextInput:

Input FileStream Stream Object List of all members.

Detailed Description

TextInput: an input stream for reading data in text format.

TextInput is a kind of Input stream for reading data encoded in plain text format. It contrasts with ByteInput, the stream for reading data encoded in binary format. Text data is read by skipping any leading whitespace and decoding each type of value from its textual representation, placing the result in a variable. Any mismatch in the expected data format will raise an exception. All the simple types Boolean, Character, Natural, Integer and Decimal may be read. String objects and raw Character[] arrays may be read, preserving internal white space, up to a specified delimiter, which is the newline by default.


Public Member Functions

 TextInput ()
 Construct a standard TextInput stream.

virtual ~TextInput ()
 Release an unused TextInput stream.

 TextInput (StringID)
 Construct a TextInput file stream.

virtual ObjectID clone () const
 Clone a copy of this TextInput.

virtual InputID get (Boolean &)
 Read in a Boolean value.

virtual InputID get (Character &)
 Read in a Character value.

virtual InputID get (Natural &)
 Read in a Natural value.

virtual InputID get (Integer &)
 Read in an Integer value.

virtual InputID get (Decimal &)
 Read in a Decimal value.

virtual InputID get (StringID &, Character= '\n')
 Read in a String, up to a delimiter Character.

virtual InputID get (Character[], Natural, Character= '\n')
 Read in a Character array, up to a delimiter Character.

virtual InputID skip (Character= '\n')
 Skip input up to and including a delimiter Character.


Protected Member Functions

 TextInput (const TextInput &)
 Copy another TextInput stream.


Constructor & Destructor Documentation

TextInput::TextInput const TextInput &  input  )  [protected]
 

Copy another TextInput stream.

Required by C++ to ensure that copying a TextInput faithfully copies an Input. Constructs a shallow copy of the other TextInput.

Parameters:
input - the TextInput to copy.
Returns:
the copied TextInput stream.

TextInput::TextInput  ) 
 

Construct a standard TextInput stream.

Constructs a TextInput stream onto the standard input (the keyboard source). By default, the pathname is null and the filesystem is closed.

Returns:
a standard TextInput stream.

TextInput::~TextInput  )  [virtual]
 

Release an unused TextInput stream.

Performs all closing actions to disconnect from the underlying filesystem.

TextInput::TextInput StringID  name  ) 
 

Construct a TextInput file stream.

Constructs a TextInput stream onto the named file.

Parameters:
name - a file pathname.
Returns:
a file TextInput stream.


Member Function Documentation

ObjectID TextInput::clone  )  const [virtual]
 

Clone a copy of this TextInput.

This is a shallow copy, which shares the file pathname, if any, but does not initialise any filesystem.

Reimplemented from Object.

InputID TextInput::get Character  array[],
Natural  length,
Character  delimiter = '\n'
[virtual]
 

Read in a Character array, up to a delimiter Character.

The Character array must be exactly of the specified length. Attempts to read a sequence of Character values into the array argument, until length-1 values have been read or the delimiter Character is encountered. Leaves the delimiter on the Input stream. Sets the last Character to the terminating null byte. This method is abstract in Input.

Parameters:
array - where the result will be stored.
length - the length of the array
delimiter - a delimiter Character, by default newline.
Returns:
this Input stream.

Reimplemented from Input.

InputID TextInput::get StringID variable,
Character  delimiter = '\n'
[virtual]
 

Read in a String, up to a delimiter Character.

Attempts to read a sequence of Character values into the String argument, until the delimiter Character is encountered. Leaves the delimiter on the Input stream. May throw a ReadFailure exception if reading fails.

Parameters:
variable - where the result will be stored.
delimiter - a delimiter Character, by default newline.
Returns:
this Input stream.

Reimplemented from Input.

InputID TextInput::get Decimal variable  )  [virtual]
 

Read in a Decimal value.

Attempts to read the next value from this Input stream, skipping leading white space. The argument refers to a variable in which the value will be stored. May throw a ReadFailure exception if reading fails.

Parameters:
variable - where the result will be stored
Returns:
this Input stream.

Reimplemented from Input.

InputID TextInput::get Integer variable  )  [virtual]
 

Read in an Integer value.

Attempts to read the next value from this Input stream, skipping leading white space. The argument refers to a variable in which the value will be stored. May throw a ReadFailure exception if reading fails.

Parameters:
variable - where the result will be stored
Returns:
this Input stream.

Reimplemented from Input.

InputID TextInput::get Natural variable  )  [virtual]
 

Read in a Natural value.

Attempts to read the next value from this Input stream, skipping leading white space. The argument refers to a variable in which the value will be stored. May throw a ReadFailure exception if reading fails.

Parameters:
variable - where the result will be stored
Returns:
this Input stream.

Reimplemented from Input.

InputID TextInput::get Character variable  )  [virtual]
 

Read in a Character value.

Attempts to read the next value from this Input stream, skipping leading white space. The argument refers to a variable in which the value will be stored. May throw a ReadFailure exception if reading fails.

Parameters:
variable - where the result will be stored
Returns:
this Input stream.

Reimplemented from Input.

InputID TextInput::get Boolean variable  )  [virtual]
 

Read in a Boolean value.

Attempts to read the next value from this Input stream, skipping leading white space. The argument refers to a variable in which the value will be stored. May throw a ReadFailure exception if reading fails.

Parameters:
variable - where the result will be stored
Returns:
this Input stream.

Reimplemented from Input.

InputID TextInput::skip Character  delimiter = '\n'  )  [virtual]
 

Skip input up to and including a delimiter Character.

Skips all input up to and including the delimiter Character. Complements methods that read data up to, but not including, a delimiter.

Parameters:
delimiter - a delimiter Character, by default newline.

Reimplemented from Input.


The documentation for this class was generated from the following files:
Generated on Fri May 5 17:17:20 2006 for The Simons Component Library by doxygen1.3