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

s11n::streamable_type_serialization_proxy Struct Reference

A Serializable Proxy for streamable types. More...

#include <algo.hpp>

List of all members.

Public Member Functions

 streamable_type_serialization_proxy ()
template<typename NodeType, typename SerType>
bool operator() (NodeType &dest, const SerType &src) const
 Creates a property in dest, called 'v', and sets its value to src using node_traits<NodeType>::set(dest,"v",src).
template<typename NodeType, typename SerType>
bool operator() (const NodeType &src, SerType &dest) const
 Looks for a property set by the serialize operator and sets dest to its value.


Detailed Description

A Serializable Proxy for streamable types.

It "should" work with any type which meets these conditions:

The class name of serialized objects will be taken from s11n_traits<>::class_name(), which isn't truly valid because most streamable types are never registed via s11n_traits. Hmmm.

Its output is significantly bigger than using, e.g. node properties to store them, but with this proxy any streamable can be treated as a full-fledged Serializable, which allows some generic container-based serialization to be done regardless of the underlying types (see the various standard container algos for examples).

ACHTUNG: never pass the same Serializable to the operators more than once or you will get duplicate and/or incorrect data.

Definition at line 533 of file algo.hpp.


Constructor & Destructor Documentation

s11n::streamable_type_serialization_proxy::streamable_type_serialization_proxy  )  [inline]
 

Definition at line 537 of file algo.hpp.


Member Function Documentation

template<typename NodeType, typename SerType>
bool s11n::streamable_type_serialization_proxy::operator() const NodeType &  src,
SerType &  dest
const [inline]
 

Looks for a property set by the serialize operator and sets dest to its value.

The default for dest, in the case of a missing property or nonconvertable value is dest itself.

If the property is missing this function does nothing and returns false.

On success dest gets assigned the property's value and true is returned. This function cannot catch a case of inability to convert the value into a SerType: client code interested in doing so should compare dest's value to a known error value after this function returns or throw from that type's istream operator on error.

Definition at line 577 of file algo.hpp.

template<typename NodeType, typename SerType>
bool s11n::streamable_type_serialization_proxy::operator() NodeType &  dest,
const SerType &  src
const [inline]
 

Creates a property in dest, called 'v', and sets its value to src using node_traits<NodeType>::set(dest,"v",src).

Always returns true unless no class name can be found for src, in which case it returns false to avoid inserting a non-name node into the data tree (which might result in unreadable data later).

Definition at line 550 of file algo.hpp.


The documentation for this struct was generated from the following file:
Generated on Sun Dec 25 20:28:26 2005 for libs11n-1.2.3 by  doxygen 1.4.4