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

s11n::io Namespace Reference

The s11n::io namespace defines some i/o-related types which conform to the conventions expected by the s11n::de/serialize() free functions. More...


Classes

class  s11n::io::compact_serializer< NodeType >
 De/serializes objects from/to a compact binary-like grammar. More...

class  s11n::io::tree_builder
 tree_builder exists mainly so some lex-based code can get access to a non-templated type (so we don't have to hard-code the parsers to a node_type). More...

class  s11n::io::tree_builder_context< ContextT >
 tree_builder_context is a helper for accessing some template-dependent code from non-template-aware lexer code. More...

struct  s11n::io::tree_builder_context< ContextT >::lexer_metadata
 This is intended for direct access by a lexer associated with this context, and ONLY by such lexers. More...

class  s11n::io::data_node_tree_builder< NodeType >
 data_node_tree_builder is a helper class for building trees from deserialized data, designed particularly for use with lex/callback-based tree builders. More...

class  s11n::io::tree_builder_lexer< NodeType, LexerSharingContext >
 tree_builder_lexer is a type intended to ease the implementation of lex-based node tree parsers. More...

class  s11n::io::key_value_serializer< NodeType >
 A helper for serializing properties to a stream. More...

struct  s11n::io::node_child_simple_formatter< SerializerT >
 A helper functor to loop over serializable children of a node from within a Serializer implementation. More...

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. More...

class  s11n::io::funtxt_serializer< NodeType >
 De/serializes objects from/to this class' config-file-like grammar. More...

class  s11n::io::funxml_serializer< NodeType >
 De/serializes objects from/to a simple XML grammar, with all properties and children stored as subnodes. More...

class  s11n::io::parens_serializer< NodeType >
 De/serializes objects from/to a lisp-like grammar. More...

class  s11n::io::simplexml_serializer< NodeType >
 De/serializes objects from/to a simple XML grammar, with properties stored as XML attibutes and children stored as subnodes. More...


Typedefs

typedef std::map< std::string,
std::string > 
entity_translation_map
 convenience typedef

typedef s11n::io::data_node_serializer<
s11n::data_node
base_serializer
 Short-form name of the base serializer type for s11n::data_node.

typedef s11n::io::compact_serializer<
s11n::data_node
compact
 Short-form name of the compact_serializer for s11n::data_node.

typedef s11n::io::funtxt_serializer<
s11n::data_node
funtxt
 Short-form name of the funtxt_serializer for s11n::data_node.

typedef s11n::io::funxml_serializer<
s11n::data_node
funxml
 Short-form name of the funxml_serializer for s11n::data_node.

typedef s11n::io::parens_serializer<
s11n::data_node
parens
 Short-form name of the parens_serializer for s11n::data_node.

typedef s11n::io::simplexml_serializer<
s11n::data_node
simplexml
 Short-form name of the simplexml_serializer for s11n::data_node.


Functions

template<typename NodeType, typename BuilderContext> NodeType * deserialize_lex_forwarder (const std::string &lexerClassName, std::istream &src)
 This function exists for a really long, strange reason involving accessing templatized types from template-free code (FlexLexers).

std::string get_magic_cookie (const std::string &src, bool AsFile=true)
 Convenience function for grabbing the first line of a file.

std::string get_magic_cookie (std::istream &is)
 Convenience function for grabbing the first line of a stream.

template<typename NodeType, typename SerializerBaseType> NodeType * load_node_classload_serializer (std::istream &is)
 Tries to load a NodeType object from the given node.

template<typename NodeType> NodeType * load_node (std::istream &is)
 Tries to load a node from the given input stream.

template<typename NodeType> NodeType * load_node (const std::string &src, bool AsFile=true)
 Overloaded form of load_node( istream ), provided for convenience.

template<typename NodeT, typename SerializableT> SerializableT * load_serializable (std::istream &src)
 Tries to load a SerializableT from the given stream.

template<typename NodeT, typename SerializableT> SerializableT * load_serializable (const std::string &src, bool AsFile=true)
 An overloaded form which takes an input string.

template<typename NodeType, typename SerializerT> bool save_node (const NodeType &src, std::ostream &dest)
 Saves src to the given ostream using the given Serializer type.

template<typename SerializerT, typename SerializableT> bool save_serializable (const SerializableT &src, std::ostream &dest)
 Saves src, a Serializable type, to the given ostream using a SerializerT serializer.

template<typename SerializerT, typename SerializableT> bool save_serializable (const SerializableT &src, const std::string &filename)
 An overloaded form which takes a filename.

entity_translation_mapfuntxt_serializer_translations ()
 The entity translations map used by funtxt_serializer.

entity_translation_mapfunxml_serializer_translations ()
 The entity translations map used by funxml_serializer.

entity_translation_mapparens_serializer_translations ()
 The entity translations map used by parens_serializer.

entity_translation_mapsimplexml_serializer_translations ()
 The entity translations map used by simplexml_serializer.


Detailed Description

The s11n::io namespace defines some i/o-related types which conform to the conventions expected by the s11n::de/serialize() free functions.

In theory clients can swap out these types and still use the core s11n interface. The core has no dependencies on this namespace.


Function Documentation

template<typename NodeType, typename BuilderContext>
NodeType* deserialize_lex_forwarder const std::string &  lexerClassName,
std::istream &  src
 

This function exists for a really long, strange reason involving accessing templatized types from template-free code (FlexLexers).

  • lexerClassName is the name of a FlexLexer subclass. It must be registered with the FlexLexer classloader.

  • src is the stream to pass on to the lexer.

  • BuilderContext should be the same one expected by the specific lexer. See the existing lexers for examples. You want to pass the actual BuilderContext's context here, not a tree_builder_context<> type.

The caller owns the returned poiner, which may be 0.

Bug-in-waiting: we don't yet have a way of knowing if a lexer partially populates the builder.

Definition at line 561 of file data_node_format.h.

Referenced by s11n::io::tree_builder_lexer< NodeType, sharing::simplexml_sharing_context >::deserialize().

std::string get_magic_cookie std::istream &  is  ) 
 

Convenience function for grabbing the first line of a stream.

Returns the first line of the given stream, or an empty string on error.

std::string get_magic_cookie const std::string &  src,
bool  AsFile = true
 

Convenience function for grabbing the first line of a file.

If AsFile == true then returns the first line of the file, else returns up to the first newline of src.

Referenced by load_node_classload_serializer().

template<typename NodeType>
NodeType* load_node const std::string &  src,
bool  AsFile = true
 

Overloaded form of load_node( istream ), provided for convenience.

If AsFile is true, input is treated as a file, otherwise it is treated as a string containing input to parse.

ACHTUNG: Only usable for loading ROOT nodes.

Maintenance note: AsFile==false may be extremely inefficient, as src may get copied one additional time.

Definition at line 298 of file data_node_io.h.

template<typename NodeType>
NodeType* load_node std::istream &  is  ) 
 

Tries to load a node from the given input stream.

ACHTUNG: Only usable for loading ROOT nodes.

Definition at line 278 of file data_node_io.h.

template<typename NodeType, typename SerializerBaseType>
NodeType* load_node_classload_serializer std::istream &  is  ) 
 

Tries to load a NodeType object from the given node.

It uses the cookie from the input stream and classload<SerializerBaseType>() to find a matching Serializer.

0 is returned on error, else a new pointer, which the caller owns.

Achtung: the first line of input from the input stream is consumed by this function (to find the cookie), and the cookie is not passed on to the handler! The only reliable way around [that i know of] this is to buffer the whole input as a string, and i don't wanna do that (it's bad for massive data files).

ACHTUNG: Only usable for loading ROOT nodes.

Definition at line 249 of file data_node_io.h.

References get_magic_cookie().

template<typename NodeT, typename SerializableT>
SerializableT* load_serializable const std::string &  src,
bool  AsFile = true
 

An overloaded form which takes an input string.

If AsFile is true the string is treated as a file name, otherwise it is processed as an input stream.

ACHTUNG: Only usable for loading ROOT nodes.

Definition at line 335 of file data_node_io.h.

References s11n::get_istream().

template<typename NodeT, typename SerializableT>
SerializableT* load_serializable std::istream &  src  ) 
 

Tries to load a SerializableT from the given stream.

On success returns a new object, else 0.

The caller owns the returned pointer.

ACHTUNG: Only usable for loading ROOT nodes.

Definition at line 315 of file data_node_io.h.

template<typename NodeType, typename SerializerT>
bool save_node const NodeType &  src,
std::ostream &  dest
 

Saves src to the given ostream using the given Serializer type.

ONLY use this for saving root nodes!

Definition at line 355 of file data_node_io.h.

template<typename SerializerT, typename SerializableT>
bool save_serializable const SerializableT &  src,
const std::string &  filename
 

An overloaded form which takes a filename.

ONLY use this for saving root nodes!

Definition at line 392 of file data_node_io.h.

References save_serializable().

template<typename SerializerT, typename SerializableT>
bool save_serializable const SerializableT &  src,
std::ostream &  dest
 

Saves src, a Serializable type, to the given ostream using a SerializerT serializer.

SerializerT must be compatible with s11n::io::data_node_serializer<> conventions and must provide a typedef XXX node_type, where XXX is a data type conforming to s11n::data_node conventions.

Returns true on success, false on error.

ONLY use this for saving root nodes!

Definition at line 377 of file data_node_io.h.

Referenced by save_serializable().


Generated on Tue Jul 20 10:46:49 2004 for s11n by doxygen 1.3.7