#include <data_node_io.h>
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_map & | entity_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_type * | deserialize (std::istream &) |
Must be implemented to parse a node_type from the given istream. | |
virtual node_type * | deserialize (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_type & | metadata () |
metadata is an experimental feature allowing serializers to store arbitrary information in their data strings. | |
const node_type & | metadata () const |
A const overload of metadata(). |
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.
|
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. |
|
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(). |
|
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. |
|
Gets this object's magic cookie.
Cookies are registered with Definition at line 198 of file data_node_io.h. Referenced by s11n::io::data_node_serializer< NodeType >::data_node_serializer(). |
|
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. |
|
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(). |