class Serializer

Serializer is an abstract base class for objects which can store Serializable objects to files or streams. More...

Contains pure virtuals
Full namefun::Serializer
Definition#include <fun/Serializer.h>
Inherited bySerialTree
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods


Detailed Description

Serializer is an abstract base class for objects which can store Serializable objects to files or streams. Depending on the subclass' implementation, the data may be stored natively, or it may be converted to strings, or stuck in a database, etc.

Think of a Serializer as taking key/value pairs of data, where the values may be Serializable objects, which implies a tree structure. Duplicate keys are allowed, but note that the only way to get at the values for duplicate keys in a Deserializer is to use one of the forms of get() which takes a reference to a list of Serializables or QStrings.

As Serializer is abstract, subclasses must provide implementations for the following methods: - put(const QString &key, const QString &val) - put(const QString &key, const Serializable &val) - setSerializableClass(const char *name) Also, setComment() does nothing in the base class.

 Serializer ()

Serializer

Creates an empty Serializer node.

 ~Serializer ()

~Serializer

[virtual]

void  put (const QString &key, const QString &val)

put

[pure virtual]

Adds a new element containing the given string value. This is one of the methods which subclasses must implement.

void  put (const QString &key, const char *val)

put

Adds a new element containing the given string value. (this one is because put(key, "bleh") was calling the bool version!)

void  put (const QString &key, int val)

put

[virtual]

This is just like the string version of put(), except that it converts the given int value to a string.

void  put (const QString &key, unsigned val)

put

[virtual]

This is just like the string version of put(), except that it converts the given unsigned int value to a string.

void  put (const QString &key, bool val)

put

[virtual]

This is just like the string version of put(), except that it converts the given bool value to a string.

void  put (const QString &key, float val)

put

[virtual]

This is just like the string version of put(), except that it converts the given float value to a string.

void  put (const QString &key, double val)

put

[virtual]

This is just like the string version of put(), except that it converts the given double value to a string.

void  put (const QString &key, const QColor &val)

put

[virtual]

This is just like the string version of put(), except that it converts the given QColor value to a string in the format #rrggbb.

void  put (const QString &key, const Serializable *val)

put

[pure virtual]

Adds a new element containing the given Serializable value. Passing a NULL Serializable here has the same effect as not calling it at all.

This is one of the methods which subclasses must implement.

void  put (const QString &key, const QPtrList &list)

put

[virtual]

Calls put() for each element in the list.

template void  put (const QString &key, InputIterator begin, InputIterator end)

put

Calls put() for each element in the list. To serialize an entire std::vector, call put(key, vec.begin(), vec.end()).

template void  put (const QString &key, const QPtrList &list)

put

Calls put() for each Serializable element in the list. This is because even if Foo is a subclass of Serializable, QPtrList can't be (or isn't being) treated as a QPtrList.

template void  put (const QString &key, const SC * const *list, unsigned len)

put

Calls put() for each Serializable element in the array of pointers. NULL elements in the list will be ignored... nuts, that means you can't rely on it to deserialize the same way. OK, how about the behavior is undefined in that case, ha ha.

void  put (const QString &key, const QStringList &list)

put

[virtual]

Calls put() for each element in the list. Note that in the result there may be no way to tell "null" and "empty" strings apart.

void  put (const QString &key, const QString *list, unsigned len)

put

[virtual]

Calls put() for each element in the list. Note that in the result there may be no way to tell "null" and "empty" strings apart.

void  put (const QString &key, const QPoint &val)

put

[virtual]

This is just like the string version of put(), except that it converts the given QPoint value to a string in the format "x,y".

void  put (const QString &key, const QSize &val)

put

[virtual]

This is just like the string version of put(), except that it converts the given QSize value to a string in the format "x,y".

void  setSerializableClass (const char *name)

setSerializableClass

[pure virtual]

This sets the name of the Serializable subclass name, so that the same class can be instantiated during deserialization. Every Serializable's serialize() method should call this with its own class name after calling its superclass' serialize().

This is one of the methods which subclasses must implement.

void  setComment (const QString &key, const QString &comment)

setComment

[virtual]

Sets an optional comment which will be associated with a child element. Note that if you have multiple elements with the same key, you're probably only going to have one comment.

The default base class behavior is to do nothing.

void  putString (const QString &key, const QString &val)

putString

void  putInt (const QString &key, int val)

putInt

void  putUInt (const QString &key, unsigned val)

putUInt

void  putBool (const QString &key, bool val)

putBool

void  putFloat (const QString &key, float val)

putFloat

void  putDouble (const QString &key, double val)

putDouble

void  putColor (const QString &key, const QColor &val)

putColor

void  putSerializable (const QString &key, const Serializable &val)

putSerializable

void  putSerializables (const QString &key, const QPtrList &list)

putSerializables

void  putStrings (const QString &key, const QStringList &list)

putStrings

void  putPoint ( const QString &key, const QPoint &val )

putPoint

void  putSize ( const QString &key, const QSize &val )

putSize

template void  put (const QString &key, const QPtrList &list)

put

template void  put (const QString &key, const SC * const *list, unsigned len)

put


Generated by: stephan on cheyenne on Mon Aug 11 14:06:52 2003, using kdoc 2.0a54.