7 #ifndef __UNICONFTREE_H
8 #define __UNICONFTREE_H
10 #include "uniconfkey.h"
11 #include "unihashtree.h"
27 typedef wv::function<void(
const Sub*,
void*)> Visitor;
28 typedef wv::function<bool(
const Sub*,
const Sub*)> Comparator;
41 {
return static_cast<Sub*
>(this->
xparent); }
45 { UniHashTreeBase::_setparent(
parent); }
49 {
return static_cast<Sub*
>(UniHashTreeBase::_root()); }
56 {
return UniHashTreeBase::_fullkey(ancestor); }
63 {
return static_cast<Sub*
>(UniHashTreeBase::_find(
key)); }
72 {
return static_cast<Sub*
>(UniHashTreeBase::_findchild(
key)); }
96 for (i.rewind(); i.next();)
97 delete static_cast<Sub*
>(i.ptr());
108 void visit(
const Visitor &visitor,
void *userdata,
109 bool preorder =
true,
bool postorder =
false)
const
111 _recursive_unsorted_visit(
this,
reinterpret_cast<
112 const typename UniHashTreeBase::BaseVisitor&
>(visitor), userdata,
113 preorder, postorder);
124 bool compare(
const Sub *other,
const Comparator &comparator)
126 return _recursivecompare(
this, other,
reinterpret_cast<
127 const typename UniHashTreeBase::BaseComparator&
>(comparator));
145 {
return static_cast<Sub*
>(MyBase::ptr()); }
172 #endif // __UNICONFTREE_H
void setparent(Sub *parent)
Reparents this node.
bool compare(const Sub *other, const Comparator &comparator)
Compares this tree with another using the specified comparator function.
A recursively composed dictionary for tree-structured data indexed by UniConfKey.
void remove(const UniConfKey &key)
Removes the node for the specified key from the tree and deletes it along with any of its children.
WvString is an implementation of a simple and efficient printable-string class.
Sub * findchild(const UniConfKey &key) const
Finds the direct child node with the specified key.
const UniConfKey & key() const
Returns the key field.
const WvString & value() const
Returns the value field.
void visit(const Visitor &visitor, void *userdata, bool preorder=true, bool postorder=false) const
Performs a traversal on this tree using the specified visitor function and traversal type(s).
Sub * ptr() const
Returns a pointer to the current node.
Iter(Sub &tree)
Creates an iterator over the specified tree.
Sub * root() const
Returns a pointer to the root node of the tree.
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix fil...
void setvalue(WvStringParm value)
Sets the value field.
~UniConfTree()
Destroy this node's contents and children.
UniHashTreeBase * xparent
Sub * parent() const
Returns a pointer to the parent node, or NULL if there is none.
void zap()
Removes and deletes all children of this node.
UniConfKey fullkey(const Sub *ancestor=NULL) const
Returns full path of this node relative to an ancestor.
A plain UniConfTree that holds keys and values.
An iterator that walks over all elements on one level of a UniConfTree.
Sub * find(const UniConfKey &key) const
Finds the sub-node with the specified key.
UniConfTree(Sub *parent, const UniConfKey &key)
Creates a node and links it to a subtree, if parent is non-NULL.