io::writer Class Reference

#include <io/writer.h>

Inheritance diagram for io::writer:

Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual ~writer () throw ()
 Virtual destructor allows correct destruction of subclasses.
int ensure_output_version_id (const char *name, io::version_id actual_version, io::version_id lowest_supported_version, const char *msg, const rutz::file_pos &pos)
virtual void write_char (const char *name, char val)=0
 Store the char attribute val in association with the tag name.
virtual void write_int (const char *name, int val)=0
 Store the int attribute val in association with the tag name.
virtual void write_bool (const char *name, bool val)=0
 Store the bool attribute val in association with the tag name.
virtual void write_double (const char *name, double val)=0
 Store the double attribute val in association with the tag name.
virtual void write_value_obj (const char *name, const rutz::value &v)=0
 Store the rutz::value attribute val in association with the tag name.
virtual void write_byte_array (const char *name, const unsigned char *data, unsigned int length)=0
 Store the raw data array in association with the tag name.
virtual void write_object (const char *name, nub::soft_ref< const io::serializable > obj)=0
 Store the io object val in association with the tag name.
virtual void write_owned_object (const char *name, nub::ref< const io::serializable > obj)=0
virtual void write_base_class (const char *base_class_name, nub::ref< const io::serializable > base_part)=0
virtual void write_root (const io::serializable *root)=0
Overloaded write functions
These functions offer a set of overloads to provide compile-time polymorphism so that any supported type (any basic type, or rutz::value, a string type) or can be written with the same source code.

void write_value (const char *name, char val)
void write_value (const char *name, int val)
void write_value (const char *name, unsigned int val)
void write_value (const char *name, unsigned long val)
void write_value (const char *name, bool val)
void write_value (const char *name, double val)
void write_value (const char *name, const rutz::fstring &val)
void write_value (const char *name, const rutz::value &v)

Protected Member Functions

virtual void write_cstring (const char *name, const char *val)=0
 Store the C-style string (char*) attribute val in association with the tag name.
void default_write_byte_array (const char *name, const unsigned char *data, unsigned int length)
 Base64 implementation of write_byte_array() for use by subclasses.


Detailed Description

io::writer provides the interface that io objects use to save their state in a write_to() implementation. It provides the inverse operations to those in io::reader. To save an object tree, a client should call write_root() on the root object in that tree. Subclasses of io::writer will implement this interface using different back ends for the actual storage medium, for example, an ASCII text file, an on-screen dialog box, a relational database, etc.

Definition at line 69 of file writer.h.


Member Function Documentation

int io::writer::ensure_output_version_id ( const char *  name,
io::version_id  actual_version,
io::version_id  lowest_supported_version,
const char *  msg,
const rutz::file_pos pos 
)

A convenience function to ensure that the current serial version is no less than the lowest_supported_version. Returns the actual_version. If this test fails, a write_version_error will be thrown.

Definition at line 84 of file writer.cc.

Referenced by Trial::write_to(), TimingHdlr::write_to(), TimingHandler::write_to(), MorphyFace::write_to(), MaskHatch::write_to(), Jitter::write_to(), House::write_to(), Gabor::write_to(), FixPt::write_to(), Fish::write_to(), Face::write_to(), ExptDriver::write_to(), EventResponseHdlr::write_to(), Block::write_to(), GxTransform::write_to(), GxText::write_to(), GxShapeKit::write_to(), GxPixmap::write_to(), GxDrawStyle::write_to(), and GxColor::write_to().

virtual void io::writer::write_owned_object ( const char *  name,
nub::ref< const io::serializable obj 
) [pure virtual]

Store the owned io object obj in association with the tag name. This function should only be used if obj is owned by the storing object; no other objects should reference obj. This allows the writer subclass to implement the storage of an owned object as a contained object.

Implemented in io::legacy_writer.

Referenced by GenericEvent::write_to(), ExptDriver::write_to(), EventResponseHdlr::write_to(), and GxShapeKit::write_to().

virtual void io::writer::write_base_class ( const char *  base_class_name,
nub::ref< const io::serializable base_part 
) [pure virtual]

Write the named base class using the io object obj, which should be arranged to point or refer to the appropriate base class part of the object. In particular, obj's virtual functions must NOT call the fully derived versions. This effect can be best accomplished with an io::proxy.

Implemented in io::legacy_writer.

Referenced by MultiEvent::write_to(), GenericEvent::write_to(), FileWriteEvent::write_to(), TimingHandler::write_to(), MorphyFace::write_to(), MaskHatch::write_to(), Jitter::write_to(), House::write_to(), GaborArray::write_to(), Gabor::write_to(), FixPt::write_to(), Fish::write_to(), Face::write_to(), ExptDriver::write_to(), CloneFace::write_to(), Block::write_to(), GxText::write_to(), and GxPixmap::write_to().

virtual void io::writer::write_root ( const io::serializable root  )  [pure virtual]

Store an entire object hierarchy, starting with the root object root. All objects and values referenced by root will be stored recursively, until there are no more remaining references.

Implemented in io::legacy_writer.


The documentation for this class was generated from the following files:

The software described here is Copyright (c) 1998-2005, Rob Peters.
This page was generated Wed Dec 3 06:56:19 2008 by Doxygen version 1.5.5.