Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Object serialiazation
[Input/Output]


Detailed Description

Write and read objects using I/O streams.

The Qgar library provides means to serialize (i.e. write on an output stream) and deserialize (i.e. read from an input file) an object, instance of a class.

The class of such an object must derive from class qgar::ISerializable and implement the two pure virtual functions qgar::ISerializable::read and qgar::ISerializable::write, using global functions qgar::qgReadObjName and qgar::qgReadObjData. See class qgar::GenSegment for an example.

An object of the class may then be write on an output stream and read from an output stream using stream operators qgar::operator<<() and qgar::operator>>(), respectively.

The following objects may be serialized/deserialized:


Classes

class  qgar::ISerializable
 Base interface of all serializable objects. More...

Point serialization/deserialization operators

Warning:
Class qgar::GenPoint does not derive from class qgar::ISerializable to get a smaller implementation of a point, and thus to save memory space when dealing with (lots of) points; if points were serializable, they would be implemented using an extra pointer to the table for virtual functions (the destructor in this case).


template<class T>
std::istream & qgar::operator>> (std::istream &anInStream, GenPoint< T > &aPt)
 Deserialize a point (read it from an input stream).
template<class T>
std::ostream & qgar::operator<< (std::ostream &anOutStream, const GenPoint< T > &aPt)
 Serialize a point (write it into an output stream).

Stream operators for object serialization/deserialization

std::istream & qgar::operator>> (std::istream &anInStream, ISerializable &aSerial)
 Reads a serializable object from and input stream.
std::ostream & qgar::operator<< (std::ostream &anOutStream, const ISerializable &aSerial)
 Writes a serializable object to an output stream.


Function Documentation

std::ostream& qgar::operator<< std::ostream &  anOutStream,
const ISerializable &  aSerial
[inline]
 

Writes a serializable object to an output stream.

Parameters:
anOutStream the output stream to write an object to
aSerial an object implementing the qgar::ISerializable interface

Definition at line 284 of file ISerializable.H.

template<class T>
std::ostream & qgar::operator<< std::ostream &  anOutStream,
const GenPoint< T > &  aPt
[inline]
 

Serialize a point (write it into an output stream).

A serialized point is represented as:

Point ( <X> ) ( <Y> )

Parameters:
anOutStream output stream
aPt point to serialize

Definition at line 796 of file _QGAR_GenPoint.TCC.

std::istream& qgar::operator>> std::istream &  anInStream,
ISerializable &  aSerial
[inline]
 

Reads a serializable object from and input stream.

Parameters:
anInStream the input stream to read an object from
aSerial an object implementing the qgar::ISerializable interface

Definition at line 268 of file ISerializable.H.

template<class T>
std::istream & qgar::operator>> std::istream &  anInStream,
GenPoint< T > &  aPt
[inline]
 

Deserialize a point (read it from an input stream).

A serialized point is represented as:

Point ( <X> ) ( <Y> )

Parameters:
anInStream input stream
aPt deserialized point
See also:
qgar::qgReadObjName, qgar::qgReadObjData

Definition at line 776 of file _QGAR_GenPoint.TCC.

References qgar::qgReadObjData(), and qgar::qgReadObjName().