s11n::io::data_node_tree_builder< NodeType > Class Template Reference

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

#include <data_node_format.hpp>

Inheritance diagram for s11n::io::data_node_tree_builder< NodeType >:

s11n::io::tree_builder List of all members.

Public Types

typedef NodeType node_type
typedef std::list< node_type * > child_list_type

Public Member Functions

 data_node_tree_builder ()
 Creates a default builder.
virtual ~data_node_tree_builder ()
 Deletes this object's children if auto_delete() returns true.
bool open_node (const std::string &classname, const std::string &nodename)
 Opens a new node, making that the current node.
virtual bool close_node ()
 Closes the most-recently-opened node, effectively popping the previous node off of the node stack (it is not destroyed).
virtual bool add_property (const std::string &key, const std::string &val)
 Adds the given key/value pair to the current node and returns true.
size_t node_count () const
 Returns the total number of nodes opened via open_node().
size_t node_depth () const
 Returns the current depth of opened nodes.
node_typeroot_node () const
 Returns the most recent root node parsed out of the input object.
node_typecurrent_node () const
 Returns the current node.
virtual bool change_node_class (const std::string &newclassname)
 Changes class name of current node, if one is set.
virtual void reset ()
 Deletes this object's root_node() if auto_delete() is true.

Detailed Description

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

It owns all objects which build up it's tree. If you want them you must manually remove them from the container. You normally do not want them, however - they're mostly throwaway nodes on their way to becoming fully deserialized objects.

This class only provides methods for building a tree, not for traversing it. Once you have built a tree, traverse it starting at the root_node().

Based on usage conventions this type supports only a single root node.

Definition at line 360 of file data_node_format.hpp.


Member Typedef Documentation

template<typename NodeType>
typedef NodeType s11n::io::data_node_tree_builder< NodeType >::node_type

Definition at line 363 of file data_node_format.hpp.

template<typename NodeType>
typedef std::list< node_type * > s11n::io::data_node_tree_builder< NodeType >::child_list_type

Definition at line 365 of file data_node_format.hpp.


Constructor & Destructor Documentation

template<typename NodeType>
s11n::io::data_node_tree_builder< NodeType >::data_node_tree_builder (  )  [inline]

Creates a default builder.

Definition at line 368 of file data_node_format.hpp.

template<typename NodeType>
virtual s11n::io::data_node_tree_builder< NodeType >::~data_node_tree_builder (  )  [inline, virtual]

Deletes this object's children if auto_delete() returns true.

Definition at line 376 of file data_node_format.hpp.


Member Function Documentation

template<typename NodeType>
bool s11n::io::data_node_tree_builder< NodeType >::open_node ( const std::string &  classname,
const std::string &  nodename 
) [inline, virtual]

Opens a new node, making that the current node.

classname will be used for the node's impl_class() (see docs for node_type::impl_class()). name will be the object's name, which is important for de/serializing the node (see node_type::name()).

It returns false on error, else true. The default implementation has no error conditions, and therefor always returns true.

Node that classnames and node names need not be unique (nor make up unique combinations). Any number of nodes may have the same name or classname.

Implements s11n::io::tree_builder.

Definition at line 406 of file data_node_format.hpp.

References CERR.

template<typename NodeType>
virtual bool s11n::io::data_node_tree_builder< NodeType >::close_node (  )  [inline, virtual]

Closes the most-recently-opened node, effectively popping the previous node off of the node stack (it is not destroyed).

It is an error to call this more often than calling open_node().

It returns false on error (e.g., called with no opened node).

Implements s11n::io::tree_builder.

Definition at line 450 of file data_node_format.hpp.

References CERR.

template<typename NodeType>
virtual bool s11n::io::data_node_tree_builder< NodeType >::add_property ( const std::string &  key,
const std::string &  val 
) [inline, virtual]

Adds the given key/value pair to the current node and returns true.

If no node is currently opened it returns false.

Implements s11n::io::tree_builder.

Definition at line 475 of file data_node_format.hpp.

template<typename NodeType>
size_t s11n::io::data_node_tree_builder< NodeType >::node_count (  )  const [inline]

Returns the total number of nodes opened via open_node().

Definition at line 486 of file data_node_format.hpp.

template<typename NodeType>
size_t s11n::io::data_node_tree_builder< NodeType >::node_depth (  )  const [inline, virtual]

Returns the current depth of opened nodes.

A return value of 1 means the current node is the root node, for example, and 0 means that no node has yet been opened.

Implements s11n::io::tree_builder.

Definition at line 498 of file data_node_format.hpp.

template<typename NodeType>
node_type* s11n::io::data_node_tree_builder< NodeType >::root_node (  )  const [inline]

Returns the most recent root node parsed out of the input object.

Use auto_delete() to determine ownership of the returned pointer.

Definition at line 511 of file data_node_format.hpp.

template<typename NodeType>
node_type* s11n::io::data_node_tree_builder< NodeType >::current_node (  )  const [inline]

Returns the current node.

Use auto_delete() to determine ownership of the returned pointer.

Definition at line 523 of file data_node_format.hpp.

template<typename NodeType>
virtual bool s11n::io::data_node_tree_builder< NodeType >::change_node_class ( const std::string &  newclassname  )  [inline, virtual]

Changes class name of current node, if one is set.

Returns false only if no node is currently opened, else it returns true.

Implements s11n::io::tree_builder.

Definition at line 533 of file data_node_format.hpp.

template<typename NodeType>
virtual void s11n::io::data_node_tree_builder< NodeType >::reset (  )  [inline, virtual]

Deletes this object's root_node() if auto_delete() is true.

Cleans up all internal data structures so that this object has an empty state.

Reimplemented from s11n::io::tree_builder.

Definition at line 546 of file data_node_format.hpp.


The documentation for this class was generated from the following file:
Generated on Thu Feb 8 10:20:47 2007 for libs11n-1.2.5 by  doxygen 1.5.0