University of Sheffield   

    The Simons
    Component Library

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

Reader Class Reference

#include <Reader.h>

Inheritance diagram for Reader:

FormatStream Stream Object CGIReader XMLReader List of all members.

Detailed Description

Reader: the abstract superclass of all format decoding streams.

The Reader class is an intermediate class in the streams hierarchy that serves as the main interface for decoding Object data. The descendants of Reader include XMLReader, CSVReader and CGIReader. A Reader wraps up an Input stream, from which it obtains its encoded data. It defines the interface for restoring root and branch Objects from their encoded forms, providing get() to reconstruct a root Object and all Objects reachable from it; and getField() to reconstruct a branch Object stored as the named field of some other Object.


Public Member Functions

 Reader ()
 Construct a standard Reader stream.

virtual ~Reader ()
 Release an unused Reader stream.

 Reader (StringID)
 Construct a file Reader stream.

virtual Natural multiple () const
 Return the field multiple.

InputID stream () const
 Return the wrapped Input stream.

virtual ReaderID get (ObjectID &)
 Read in an Object from its serially-encoded, textual representation.

virtual ReaderID getField (StringID, ObjectID &)
 Read in the Object named by this field from its serially-encoded textual representation.


Protected Member Functions

 Reader (const Reader &)
 Copy another Reader stream.

virtual FileStreamID fileStream () const
 Return the wrapped FileStream.


Protected Attributes

TextInputID input
 The underlying TextInput stream.


Constructor & Destructor Documentation

Reader::Reader const Reader &  other  )  [protected]
 

Copy another Reader stream.

Required by C++ to ensure that copying an Reader faithfully copies a FormatStream. Constructs a shallow copy of the other Reader, sharing the underlying TextInput stream.

Parameters:
other - the other Reader to copy.
Returns:
the copied Reader stream.

Reader::Reader  ) 
 

Construct a standard Reader stream.

Constructs a Reader whose input is the standard TextInput stream, initially closed.

Returns:
a standard Reader stream.

Reader::~Reader  )  [virtual]
 

Release an unused Reader stream.

Performs all closing actions to disconnect from the underlying filesystem.

Reader::Reader StringID  name  ) 
 

Construct a file Reader stream.

Constructs a Reader stream whose input is the TextInput stream named by the file path name.

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


Member Function Documentation

FileStreamID Reader::fileStream  )  const [inline, protected, virtual]
 

Return the wrapped FileStream.

This is the same as the Input stream, but the returned type is more general. This method is used by FormatStream to access the abstract wrapped FileStream.

Returns:
the wrapped Input stream.

Reimplemented from FormatStream.

ReaderID Reader::get ObjectID variable  )  [virtual]
 

Read in an Object from its serially-encoded, textual representation.

This is the top-level method for reconstructing an Object cluster. The argument variable will be initialised with an Object and all of its connected dependents, as this Reader decodes the serialized textual representation, which was previously encoded using a Writer stream. The expected textual encoding is determined by subclasses. This top-level method reads in any header information and then calls getField("root", variable) to read the Object cluster. A ReadFailure exception may be raised if reading fails.

Parameters:
variable - a variable in which to store the result.

Reimplemented in XMLReader.

ReaderID Reader::getField StringID  label,
ObjectID variable
[virtual]
 

Read in the Object named by this field from its serially-encoded textual representation.

The argument variable will be initialised with an Object and all of its connected dependents. This method is abstract and must be implemented in all subclasses, which support particular textual encodings, such as XML-format or CSV-format encodings, for example. The decoding protocol must at least read in the Object's type and identity. If the identity was previously read, the corresponding object should be returned. Otherwise, a new instance of the type should be created, on which readOn(this) is invoked, which calls getField() recursively for each of the Object's fields.

Parameters:
label - the field label
variable - a variable in which to store the result.

Reimplemented in CGIReader, and XMLReader.

Natural Reader::multiple  )  const [virtual]
 

Return the field multiple.

Attribute fields have a multiple of one. The element field of a Collection has a variable multiple, ranging from zero to many. This method is used by Collection in readOn() to determine how many element fields to expect. This method is abstract in Reader.

Returns:
the field multiple.

Reimplemented in XMLReader.

InputID Reader::stream  )  const [inline]
 

Return the wrapped Input stream.

This method is used by Value and String objects, which are leaf-nodes in any object graph, to access the more basic Input stream. These leaf-node objects read their contents directly as text, in their readOn() method.

Returns:
the wrapped Input stream.


Member Data Documentation

TextInputID Reader::input [protected]
 

The underlying TextInput stream.


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