University of Sheffield   

    The Simons
    Component Library

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

Input Class Reference

#include <Input.h>

Inheritance diagram for Input:

FileStream Stream Object TextInput List of all members.

Detailed Description

Input: the superclass of all input file streams.

The Input class provides the ANSII standard C++ implementation of an input filesystem. It implements the FileStream protocol for opening and closing a filesystem. It implements the Stream protocol for detecting the state of a Stream. Operations that connect to the filesystem may raise a NotFound exception if the filesystem cannot be found and a NoResponse exception if the filesystem fails, or is already in use. The parent of TextInput and ByteInput, Input defines the abstract protocols for reading values of all the basic types Boolean, Character, Natural, Integer and Decimal. It also defines the protocol for reading Character[] array and String objects.


Public Member Functions

 Input ()
 Construct a standard Input stream.

virtual ~Input ()
 Release an unused Input stream.

 Input (StringID)
 Construct an Input file stream.

virtual Void open ()
 Open this Input stream for reading.

virtual Void close ()
 Close this Input stream.

virtual Boolean exists () const
 Test if this Input stream exists.

virtual Boolean empty () const
 Test if this Input stream is empty.

virtual Boolean ready () const
 Test if this Input stream is ready.

virtual Boolean failed () const
 Test if this Input stream has failed.

virtual Boolean source () const
 Test if this Input is a source.

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

 Input (const Input &)
 Copy another Input stream.


Protected Attributes

std::istream * filesystem
 The input stream pathname.


Constructor & Destructor Documentation

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

Copy another Input stream.

Required by C++ to ensure that copying an Input faithfully copies a FileStream. Constructs a shallow copy of the other Input. Shares any file pathname but leaves the underlying filesystem closed.

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

Input::Input  ) 
 

Construct a standard Input stream.

Constructs an Input stream onto the standard input (keyboard). By default, the pathname is null.

Returns:
a standard Input stream.

Input::~Input  )  [virtual]
 

Release an unused Input stream.

Performs all closing actions to disconnect from the underlying filesystem.

Input::Input StringID  path  ) 
 

Construct an Input file stream.

Constructs an Input stream onto the given path name. When opened, this Input stream will connect to the named file.

Parameters:
path - a file path name.
Returns:
a file Input stream.


Member Function Documentation

Void Input::close  )  [virtual]
 

Close this Input stream.

Provided this Input is open, closes the connection to the underlying filesystem. Otherwise, has no effect, since this Input is not connected.

Reimplemented from Stream.

Boolean Input::empty  )  const [virtual]
 

Test if this Input stream is empty.

Use this method to test for the end-of-file marker. Peeks ahead to see if the next item on the Input stream is the end-of-file marker.

Returns:
true if this Stream is empty, otherwise false.

Reimplemented from Stream.

Boolean Input::exists  )  const [virtual]
 

Test if this Input stream exists.

Use this method to test if the connection with the underlying filesystem was successfully opened.

Returns:
true if the filesystem connection exists, otherwise false.

Reimplemented from Stream.

Boolean Input::failed  )  const [virtual]
 

Test if this Input stream has failed.

Use this method to test if this Input stream failed to complete the previous input operation.

Returns:
true if this Input stream has failed, otherwise false.

Reimplemented from Stream.

InputID Input::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.
Returns:
this Input stream.

Reimplemented in TextInput.

InputID Input::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. This method is abstract in Input.

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

Reimplemented in TextInput.

InputID Input::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. This method is abstract in Input.

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

Reimplemented in TextInput.

InputID Input::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. This method is abstract in Input.

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

Reimplemented in TextInput.

InputID Input::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. This method is abstract in Input.

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

Reimplemented in TextInput.

InputID Input::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. This method is abstract in Input.

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

Reimplemented in TextInput.

InputID Input::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. This method is abstract in Input.

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

Reimplemented in TextInput.

Void Input::open  )  [virtual]
 

Open this Input stream for reading.

Provided this Input is closed, opens a connection to the underlying filesystem. Otherwise, raises a DeviceBusy exception, since the stream is busy. If the requested Input stream cannot be opened, releases the filesystem and raises a NotFound exception.

Reimplemented from Stream.

Boolean Input::ready  )  const [virtual]
 

Test if this Input stream is ready.

Use this method to test if the Input stream is ready for the next input operation.

Returns:
true if this Input stream is ready, otherwise false.

Reimplemented from Stream.

InputID Input::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 delimiting Character.

Reimplemented in TextInput.

Boolean Input::source  )  const [virtual]
 

Test if this Input is a source.

Trivially returns true for Input streams.

Returns:
true, since this Input is always a source.

Reimplemented from Stream.


Member Data Documentation

std::istream* Input::filesystem [protected]
 

The input stream pathname.


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