University of Sheffield   

    The Simons
    Component Library

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

Writer Class Reference

#include <Writer.h>

Inheritance diagram for Writer:

FormatStream Stream Object XMLWriter List of all members.

Detailed Description

Writer: the superclass of all format encoding streams.

The Writer class is an intermediate class in the streams hierarchy that serves as the main interface for encoding Object data. The descendants of Writer include XMLWriter, CSVWriter and HTMLWriter. A Writer wraps up an Output stream, to which it sends its encoded data. It defines the interface for serialising root and branch Objects in an encoded form, providing 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.


Public Member Functions

 Writer ()
 Construct a standard Writer stream.

virtual ~Writer ()
 Release an unused Writer stream.

 Writer (StringID)
 Construct a file Writer stream.

OutputID stream () const
 Return the wrapped Output stream.

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

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


Protected Member Functions

 Writer (const Writer &)
 Copy another Writer stream.

virtual FileStreamID fileStream () const
 Return the wrapped FileStream.


Protected Attributes

TextOutputID output
 The underlying TextOutput stream.


Constructor & Destructor Documentation

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

Copy another Writer stream.

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

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

Writer::Writer  ) 
 

Construct a standard Writer stream.

Constructs a Writer whose output is the standard TextOutput stream, initially closed.

Returns:
a standard Writer stream.

Writer::~Writer  )  [virtual]
 

Release an unused Writer stream.

Performs all closing actions to disconnect from the underlying filesystem.

Writer::Writer StringID  name  ) 
 

Construct a file Writer stream.

Constructs a Writer stream whose output is the TextOutput stream named by the file path name.

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


Member Function Documentation

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

Return the wrapped FileStream.

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

Returns:
the wrapped Output stream.

Reimplemented from FormatStream.

WriterID Writer::put ObjectID  object  )  [virtual]
 

Write out an Object in a serially-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 Writer stream, such that a similar Reader stream may later read in the Object and its dependents and rebuild an equivalent Object cluster. The particular textual encoding is determined by subclasses. This top-level method writes out any header information and then calls putField("root", object) to write the Object cluster. A WriteFailure exception may be raised if writing fails.

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

Reimplemented in XMLWriter.

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

Write out the Object named by this field in a serially-encoded textual representation.

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 encoding protocol must at least write out the Object's type and identity. If the Object was previously written, that is all. Otherwise, writeOn(this) should be invoked on the Object, which calls putField() recursively for each of the Object's fields.

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

Reimplemented in XMLWriter.

OutputID Writer::stream  )  const [inline]
 

Return the wrapped Output stream.

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

Returns:
the wrapped Output stream.


Member Data Documentation

TextOutputID Writer::output [protected]
 

The underlying TextOutput stream.


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