#include <node_tree.hpp>
Public Types | |
typedef NodeT | node_type |
typedef ::s11n::node_traits< node_type > | traits_type |
typedef traits_type::child_list_type | list_type |
Public Member Functions | |
node_tree (node_type *root) | |
Ownership of node does not change, and root should outlive this object, or at least live until clime_tree() is called with another root. | |
node_tree () | |
~node_tree () | |
size_t | climb_tree (node_type *node, size_t internal_use=0) |
Maps relations of parens to children in node tree, using the given root node. | |
node_type * | parent_of (node_type &node) |
Returns the parent node of node, of 0 if no parent was mapped by climb_tree(). | |
list_type & | children_of (node_type &node) |
A convenience wrapper around traits_type::children(node). | |
bool | take_node (node_type *node) |
Removes the given node from the tree. | |
bool | reparent (node_type *n, node_type *newp) |
Reparents node n to parent node newp. | |
node_type * | root () |
Returns this object's root node. | |
void | clear () |
Clears this object's data and sets it's root() node to 0. |
node_tree provides an interface for manipulating child/parent relationships in a tree of data nodes.
NodeT must usable via s11n::node_traits<NodeT>.
Definition at line 24 of file node_tree.hpp.
|
Definition at line 48 of file node_tree.hpp. |
|
Definition at line 27 of file node_tree.hpp. |
|
Definition at line 28 of file node_tree.hpp. |
|
Ownership of node does not change, and root should outlive this object, or at least live until clime_tree() is called with another root. root may be 0. Definition at line 37 of file node_tree.hpp. References s11n::util::node_tree< NodeT >::climb_tree(), and s11n::util::node_tree< NodeT >::root(). |
|
Definition at line 42 of file node_tree.hpp. |
|
Definition at line 45 of file node_tree.hpp. |
|
A convenience wrapper around traits_type::children(node).
Definition at line 110 of file node_tree.hpp. |
|
Clears this object's data and sets it's root() node to 0. This object does not own root() and therefor does not delete it. Definition at line 194 of file node_tree.hpp. |
|
Maps relations of parens to children in node tree, using the given root node. Returns the cumulative number of nodes traversed. Ownership of node does not change, so node must outlive this object or, if it is destroyed first, climb_tree() must be called with another node before any other API of this class is called. If node == 0 then this object's data is cleared and 0 is returned. The second parameter is for internal use: never pass a value, or pass 0 if you must pass something. Definition at line 67 of file node_tree.hpp. Referenced by s11n::util::node_tree< NodeT >::node_tree(). |
|
Returns the parent node of node, of 0 if no parent was mapped by climb_tree(). The caller does not own the pointer: it is owned by it's own parent. If it has no parent, then "someone else" is assumed to have ownership of it (whoever gave it to this object, presumably). Definition at line 99 of file node_tree.hpp. |
|
Reparents node n to parent node newp. Both n and newp are assumed to be under root(). n may not be root() and neither n nor newp may be 0. Returns true on success, false on error. If this function returns false then ownership is unchanged and there are no side effects. If it returns true, ownership of n *typically* moves to newp. That is, newp will delete n when newp is destroyed. More specifically, that depends on node_type's implementation, but s11n::data_node and s11n::s11n_node both work that way. Definition at line 167 of file node_tree.hpp. References s11n::util::node_tree< NodeT >::root(). |
|
Returns this object's root node. Ownership is not changed. Definition at line 187 of file node_tree.hpp. Referenced by s11n::util::node_tree< NodeT >::node_tree(), s11n::util::node_tree< NodeT >::reparent(), and s11n::util::node_tree< NodeT >::take_node(). |
|
Removes the given node from the tree. If it returns true, the caller owns node, otherwise ownership is unchanged. Definition at line 120 of file node_tree.hpp. References s11n::util::node_tree< NodeT >::root(). |