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

s11n::io::data_node_serializer< NodeT > Class Template Reference

data_node_serializer provides an interface for saving/loading a given abstract data node type to/from streams. More...

#include <data_node_io.h>

List of all members.

Public Types

typedef NodeT node_type
 The underlying data type used to store serialized data.
typedef std::map< std::string,
std::string > 
translation_map
 A convenience typedef, mainly for subclasses.

Public Member Functions

 data_node_serializer ()
virtual ~data_node_serializer ()
virtual const translation_mapentity_translations () const
 Returns a map intended for use with s11n::translate_entities().
virtual bool serialize (const node_type &src, std::ostream &dest)
 Must be implemented to format node_type to the given ostream.
bool serialize (const node_type &src, const std::string &destfile)
 Overloaded to save dest to the given filename.
virtual node_typedeserialize (std::istream &)
 Must be implemented to parse a node_type from the given istream.
virtual node_typedeserialize (const std::string &src)
 Overloaded to load dest from the given filename.
std::string magic_cookie () const
 Gets this object's magic cookie.

Protected Member Functions

void magic_cookie (const std::string &c)
 Sets the magic cookie for this type.
node_typemetadata ()
 metadata is an experimental feature allowing serializers to store arbitrary information in their data strings.
const node_typemetadata () const
 A const overload of metadata().


Detailed Description

template<typename NodeT>
class s11n::io::data_node_serializer< NodeT >

data_node_serializer provides an interface for saving/loading a given abstract data node type to/from streams.

It is designed for containers which comply to the s11n::data_node interface and conventions.

Conventions:

Must provide:

typedef NodeT node_type

Two de/serialize functions, following the stream-based interface shown here (filename-based variants are optional, but convenient for clients).

Definition at line 82 of file data_node_io.h.


Member Function Documentation

template<typename NodeT>
virtual node_type* s11n::io::data_node_serializer< NodeT >::deserialize const std::string &  src  )  [inline, virtual]
 

Overloaded to load dest from the given filename.

It supports zlib/bz2lib decompression for files (not source strings) if your s11n lib supports them.

This is virtual ONLY to avoid a bogus(?) error from gcc when accessing it via subclass instances.

Definition at line 182 of file data_node_io.h.

template<typename NodeT>
virtual node_type* s11n::io::data_node_serializer< NodeT >::deserialize std::istream &   )  [inline, virtual]
 

Must be implemented to parse a node_type from the given istream.

It should return true on success, false on error.

The default implementation always returns false and does nothing.

Reimplemented in s11n::io::tree_builder_lexer< NodeType, LexerSharingContext >, s11n::io::funxml_serializer< NodeType >, s11n::io::tree_builder_lexer< NodeType, sharing::funtxt_sharing_context >, s11n::io::tree_builder_lexer< NodeType, sharing::compact_sharing_context >, s11n::io::tree_builder_lexer< NodeType, sharing::funxml_sharing_context >, s11n::io::tree_builder_lexer< NodeType, sharing::parens_sharing_context >, and s11n::io::tree_builder_lexer< NodeType, sharing::simplexml_sharing_context >.

Definition at line 165 of file data_node_io.h.

Referenced by s11n::io::data_node_serializer< NodeType >::deserialize().

template<typename NodeT>
virtual const translation_map& s11n::io::data_node_serializer< NodeT >::entity_translations  )  const [inline, virtual]
 

Returns a map intended for use with s11n::translate_entities().

The default implementation returns an empty map.

Subclasses should override this to return a translation map, if they need one. The default map is empty.

Be aware that this may very well be called post-main(), so subclasses should take that into account and provide post-main()-safe maps! (Tip: see s11n::phoenix.)

Reimplemented in s11n::io::funtxt_serializer< NodeType >, s11n::io::funxml_serializer< NodeType >, s11n::io::parens_serializer< NodeType >, and s11n::io::simplexml_serializer< NodeType >.

Definition at line 119 of file data_node_io.h.

template<typename NodeT>
std::string s11n::io::data_node_serializer< NodeT >::magic_cookie  )  const [inline]
 

Gets this object's magic cookie.

Cookies are registered with class_loader<noder_serializable<NodeType>> types to match files to file input parsers.

Definition at line 198 of file data_node_io.h.

Referenced by s11n::io::data_node_serializer< NodeType >::data_node_serializer().

template<typename NodeT>
bool s11n::io::data_node_serializer< NodeT >::serialize const node_type src,
const std::string &  destfile
[inline]
 

Overloaded to save dest to the given filename.

The output file is compressed if s11n::compression_policy() has been set to enable it.

Returns true on success, false on error.

Definition at line 148 of file data_node_io.h.

template<typename NodeT>
virtual bool s11n::io::data_node_serializer< NodeT >::serialize const node_type src,
std::ostream &  dest
[inline, virtual]
 

Must be implemented to format node_type to the given ostream.

It should return true on success, false on error.

The default implementation always returns false.

Reimplemented in s11n::io::compact_serializer< NodeType >, s11n::io::funtxt_serializer< NodeType >, s11n::io::funxml_serializer< NodeType >, s11n::io::parens_serializer< NodeType >, and s11n::io::simplexml_serializer< NodeType >.

Definition at line 134 of file data_node_io.h.

Referenced by s11n::io::data_node_serializer< NodeType >::serialize().


The documentation for this class was generated from the following file:
Generated on Thu Jun 16 16:18:13 2005 for s11n by  doxygen 1.4.3-20050530