Main Page   Class Hierarchy   Alphabetical List   Compound List   Compound Members  

util::Serializer Class Reference

#include <Serialization.h>

List of all members.

Detailed Description

Serializer is an interface for classes that are able to write and read Serializable objects.

A Serializable class must be accompanied with a Serializer in order to be dynamically serializable. A convenient way of creating the serializer is an inner class:

 class MyClass : public Serializable
   class Serializer;


 class MyClass::Serializer : public util::Serializer
   void writeToStream(ostream& out, const Serializable& obj) throw (IOException&);
   Serializable* readFromStream(istream& in) throw (IOException&);

Now you'll be able to use MyClass::Serializer as a serializer for MyClass.

Public Methods

virtual void writeToStream (std::ostream &out, const Serializable &obj)=0 throw (io::IOException&)
 Write an object to a stream.

virtual SerializablereadFromStream (std::istream &in)=0 throw (io::IOException&)
 Read an object from a stream.

Member Function Documentation

virtual Serializable* util::Serializer::readFromStream std::istream &    in throw (io::IOException&) [pure virtual]

Read an object from a stream.

This method should return a pointer to a newly allocated object whose contents were read from the given stream by using a stream operator, for example.

in  the stream to read an object from
a pointer to a newly allocated object

virtual void util::Serializer::writeToStream std::ostream &    out,
const Serializable   obj
throw (io::IOException&) [pure virtual]

Write an object to a stream.

This method shoud write the contents of an object to the given stream by using a stream operator, for example. Note that the data output to stream must always be started with a fully-qualified class name (namespace::class). One may want to use Util::getClassName to make the class name correctly formatted.

out  the output stream to write the object to
obj  the object to be written
See also:
Util::parseName(const char*)

The documentation for this class was generated from the following file:
Documentation generated on 11.09.2003 with Doxygen.
The documentation is copyrighted material.
Copyright © Topi Mäenpää 2003. All rights reserved.