University of Sheffield   

    The Simons
    Component Library

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

XMLWriter Class Reference

#include <XMLWriter.h>

Inheritance diagram for XMLWriter:

Writer FormatStream Stream Object List of all members.

Detailed Description

XMLWriter: a writer that serialises objects as XML-format data.

The XMLWriter class is a kind of Writer that serialises Objects in the XML-format, such that XMLReader may later reconstruct them. XMLWriter provides put() to serialise a root Object and all Objects reachable from it; and putField() to serialise a branch Object stored as the named field of some other Object. The put() method is used by client programs to serialise a graph of Objects at the top level; while putField() should be called within the writeOn() method defined for every Object, to serialise each of its fields.


Public Member Functions

 XMLWriter ()
 Construct a standard XMLWriter stream.

virtual ~XMLWriter ()
 Release an unused XMLWriter stream.

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

 XMLWriter (StringID)
 Construct a file XMLWriter stream.

virtual WriterID put (ObjectID)
 Write out an Object in an XML-encoded, textual representation.

virtual WriterID putField (StringID, ObjectID)
 Write out the Object named by this field in an XML-encoded textual representation.


Constructor & Destructor Documentation

XMLWriter::XMLWriter  ) 
 

Construct a standard XMLWriter stream.

Constructs an XMLWriter whose output is the standard TextOutput stream, initially closed.

Returns:
a standard XMLWriter stream.

XMLWriter::~XMLWriter  )  [virtual]
 

Release an unused XMLWriter stream.

Performs all closing actions to disconnect from the underlying filesystem.

XMLWriter::XMLWriter StringID  name  ) 
 

Construct a file XMLWriter stream.

Constructs an XMLWriter stream whose output is the TextOutput stream named by the file path name.

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


Member Function Documentation

ObjectID XMLWriter::clone  )  const [virtual]
 

Clone a copy of this XMLWriter.

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

Reimplemented from Object.

WriterID XMLWriter::put ObjectID  object  )  [virtual]
 

Write out an Object in an XML-encoded, textual representation.

This is the top-level method for serializing an Object cluster. The Object and all of its connected dependents will be written to this XMLWriter stream, such that an XMLReader stream may later read in the Object and its dependents and rebuild the same connected cluster. This method writes the XML header then calls putField("root", object) to serialise the Object cluster. A WriteFailure exception may be raised if writing fails.

Parameters:
object - the Object to encode on this XMLWriter.

Reimplemented from Writer.

WriterID XMLWriter::putField StringID  label,
ObjectID  object
[virtual]
 

Write out the Object named by this field in an XML-encoded textual representation.

If the Object has not been encountered before, writes out a pair of opening and closing tags, surrounding the Object's field data, which is indented. Otherwise, writes out a single self-closing tag. The tag name is the Object's type name. Tag attributes include the field name and the identity. Simple Value objects have no identity. Collection objects also write a size attribute. Field data is written by invoking writeOn(this) on the Object after the opening tag. This calls putField() recursively for each of the Object's fields.

Parameters:
label - the field label
object - the Object to encode on this Writer.

Reimplemented from Writer.


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