Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | 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

void bind (const FlexLexer *lexer, tree_builder *builder)
 Sets the current builder object for this context.

void unbind (const FlexLexer *lexer)
 Frees up the internal resources used by the marshaling process for the given lexer.

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

bool open_node (const FlexLexer *lexer, const std::string &classname, const std::string &nodename)
 See tree_builder::open_node().

bool close_node (const FlexLexer *lexer)
 See tree_builder::clode_node().

bool add_property (const FlexLexer *lexer, const std::string &key, const std::string &val)
 See tree_builder::add_property().

size_t node_depth (const FlexLexer *lexer)
 See tree_builder::node_depth().

bool change_node_class (const FlexLexer *lexer, const std::string &newclassname)
 See tree_builder::change_node_class().

lexer_metadatametadata (const FlexLexer *lexer)
 Returns the lexer_metadata for the given lexer, creating one if needed.


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

References s11n::io::tree_builder_context< ContextT >::bind().

Referenced by s11n::io::tree_builder_context< ContextT >::bind().

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

References s11n::io::tree_builder_context< ContextT >::builder().

Referenced by s11n::io::tree_builder_context< ContextT >::builder().

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

References s11n::io::tree_builder_context< ContextT >::metadata().

Referenced by s11n::io::tree_builder_context< ContextT >::metadata().


The documentation for this class was generated from the following file:
Generated on Tue Jul 20 10:46:50 2004 for s11n by doxygen 1.3.7