University of Sheffield   

    The Simons
    Component Library

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

XMLReader Class Reference

#include <XMLReader.h>

Inheritance diagram for XMLReader:

Reader FormatStream Stream Object List of all members.

Detailed Description

XMLReader: a reader that reconstructs objects from XML-format data.

The XMLReader class is a kind of Reader that reconstructs Objects that were previously serialised in the XML-format generated by XMLWriter. XMLReader provides 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. The get() method is used by client programs to reconstruct a graph of Objects at the top level; while getField() should be called within the readOn() method defined for every kind of Object, to reconstruct each of its fields.


Public Member Functions

 XMLReader ()
 Construct a standard XMLReader stream.

virtual ~XMLReader ()
 Release an unused XMLReader stream.

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

 XMLReader (StringID)
 Construct a file XMLReader stream.

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

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

virtual Natural multiple () const
 Return the field multiple.


Constructor & Destructor Documentation

XMLReader::XMLReader  ) 
 

Construct a standard XMLReader stream.

Constructs an XMLReader whose input is the standard TextInput stream, initially closed.

Returns:
a standard XMLReader stream.

XMLReader::~XMLReader  )  [virtual]
 

Release an unused XMLReader stream.

Performs all closing actions to disconnect from the underlying filesystem.

XMLReader::XMLReader StringID  name  ) 
 

Construct a file XMLReader stream.

Constructs an XMLReader stream whose input is the TextInput stream named by the file path name.

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


Member Function Documentation

ObjectID XMLReader::clone  )  const [virtual]
 

Clone a copy of this XMLReader.

Creates a shallow copy, which shares the file path name, if any, but does not initialise any filesystem.

Reimplemented from Object.

ReaderID XMLReader::get ObjectID variable  )  [virtual]
 

Read in an Object from its XML-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 XMLReader decodes the serialized textual representation, which was previously encoded using an XMLWriter stream. This method reads the XML header then calls getField("root", variable) to reconstruct the Object cluster. A ReadFailure exception may be raised if reading fails.

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

Reimplemented from Reader.

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

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

The opening tag is decoded. If this is a self-closing tag, the Object has been encountered before and so the identity attribute is used to fetch the same Object. Otherwise, the tag name is used to create a blank Object of the named Type, whose field data is recovered, after which a closing tag is expected. If the opening tag also has a size attribute, the Object is a Collection with the given number of elements. Field data is reconstructed by invoking readOn(this) on the blank Object. This calls getField() recursively for each of the Object's fields. A Collection may invoke multiple() on this XMLReader to determine the number of fields to reconstruct.

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

Reimplemented from Reader.

Natural XMLReader::multiple  )  const [inline, 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.

Returns:
the field multiple.

Reimplemented from Reader.


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