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

s11n::io::tree_builder_context< ContextT > Class Template Reference

tree_builder_context is a helper for accessing some template-dependent code from non-template-aware lexer code. More...

#include <data_node_format.h>

List of all members.

Public Types

typedef ContextT context_type
 The context type for this class.

Static Public Member Functions

static void bind (const FlexLexer *lexer, tree_builder *builder)
 Sets the current builder object for this context.
static void unbind (const FlexLexer *lexer)
 Frees up the internal resources used by the marshaling process for the given lexer.
static tree_builderbuilder (const FlexLexer *lexer)
 Gets the current builder object for this context, which must have been previously set up via a call to bind(lexer,builder).
static bool open_node (const FlexLexer *lexer, const std::string &classname, const std::string &nodename)
 See tree_builder::open_node().
static bool close_node (const FlexLexer *lexer)
 See tree_builder::clode_node().
static bool add_property (const FlexLexer *lexer, const std::string &key, const std::string &val)
 See tree_builder::add_property().
static size_t node_depth (const FlexLexer *lexer)
 See tree_builder::node_depth().
static bool change_node_class (const FlexLexer *lexer, const std::string &newclassname)
 See tree_builder::change_node_class().
static lexer_metadatametadata (const FlexLexer *lexer)
 Returns the lexer_metadata for the given lexer, creating one if needed.

Classes

struct  lexer_metadata
 This is intended for direct access by a lexer associated with this context, and ONLY by such lexers. More...


Detailed Description

template<typename ContextT>
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.

It's usage is admitedly a bit strange (indeed, it's whole existance is).

This object sets up a "context channel" where a given FlexLexer can, in a thread-safe manner, communicate data back to a data_tree_builder<NodeType> without knowing the exact NodeType.

For samples see the s11n lexers, under src/node/lex.

All of it's methods, except for builder(), mirror those of a tree_builder object, so see that class for the API docs. For the "mirrored" functions, the object being proxied is that set via builder(). It is intended that only the lexers associated with this context actually use it's API.

Calling the proxied functions when no builder is set has no effect. Calling them with no bind()ed FlexLexer may be fatal.

Definition at line 176 of file data_node_format.h.


Member Function Documentation

template<typename ContextT>
static void s11n::io::tree_builder_context< ContextT >::bind const FlexLexer lexer,
tree_builder builder
[inline, static]
 

Sets the current builder object for this context.

Pointer ownership does not change by calling this function.

This must be carefully marshalled: it must always be set immediately before the matching lexer is used, and unbind(lexer) should be called immediately afterwards to free up the internal marshaling data. Failing to call unbind will mean a resource leak (albeit a small one).

Preconditions:

  • lexer and builder must be valid pointers and must out-live the expected lifetime of this context object, which internally associates these two objects.

Definition at line 202 of file data_node_format.h.

template<typename ContextT>
static tree_builder* s11n::io::tree_builder_context< ContextT >::builder const FlexLexer lexer  )  [inline, static]
 

Gets the current builder object for this context, which must have been previously set up via a call to bind(lexer,builder).

Ownership of the returned pointer does not change by calling this function.

Definition at line 224 of file data_node_format.h.

template<typename ContextT>
static lexer_metadata& s11n::io::tree_builder_context< ContextT >::metadata const FlexLexer lexer  )  [inline, static]
 

Returns the lexer_metadata for the given lexer, creating one if needed.

It is assumed that the lexer has been bound via a call to bind().

Definition at line 314 of file data_node_format.h.


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