Static Public Member Functions | List of all members
TreeUtils Class Reference

Collection of functions for investigating and processing trees. More...

#include <TreeUtils.h>

Static Public Member Functions

template<class TR >
static void erase (TR &tree, const typename TR::path_t &path)
 Deletes a node (leaf) and its subtrees. More...
 
template<class TR , class S >
static void getPaths (const TR &tree, S &container)
 Returns a list of the node names matching a pattern. The trailing '/' is NOT appended ie. should not be tested by RegExp. More...
 
template<class TR , class S >
static void getPaths (const TR &tree, S &container, const typename TR::path_t &path)
 Returns a list of the node names matching a pattern. The trailing '/' is NOT appended ie. should not be tested by RegExp. More...
 
template<class T1 , class T2 >
static void deepCopy (const T1 &srcTree, T2 &dstTree)
 
template<class T , class H >
static void traverse (H &handler, T &tree, const typename T::path_t &path=typename T::path_t())
 Traverse tree, visiting each node as a prefix operation. More...
 
template<class T >
static bool dataDumper (const T &data, std::ostream &ostr)
 Default implementation for recursive dump()
 
template<class TR , bool SKIP_EMPTY = false>
static bool dump (const TR &tree, std::ostream &ostr=std::cout, bool(*callBack)(const typename TR::node_data_t &, std::ostream &)=TreeUtils::dataDumper, const std::string &indent="")
 Render a tree using character graphics. More...
 
template<class TR >
static void dumpContents (const TR &tree, std::ostream &ostr=std::cout, const typename TR::path_t &path="")
 Debugging utility - dumps the tree, also the contents.
 
template<class TR >
static void writeINI (const TR &t, std::ostream &ostr=std::cout, const typename TR::path_t &prefix=typename TR::path_t())
 Write a Windows INI file.
 
template<class TR >
static void readINI (TR &tree, std::istream &istr)
 

Detailed Description

Collection of functions for investigating and processing trees.

Template Parameters
K- key type, implementing method empty() and cast from/to std::string.
T- value type
C- comparison functor, implementing less-than relation

Member Function Documentation

◆ dump()

static bool dump ( const TR &  tree,
std::ostream &  ostr = std::cout,
bool(*)(const typename TR::node_data_t &, std::ostream &)  callBack = TreeUtils::dataDumper,
const std::string &  indent = "" 
)
inlinestatic

Render a tree using character graphics.

Debugging utility - dumps the structure of the tree (not the contents).

Template Parameters
TR- tree type
SKIP- skip empty branches (FUTURE OPTION)
Returns
- true if empty, false if groups exist or data non-empty (FUTURE OPTION)
Examples
TreeSVG-example.cpp.

◆ erase()

static void erase ( TR &  tree,
const typename TR::path_t &  path 
)
inlinestatic

Deletes a node (leaf) and its subtrees.

If an ending slash is included, then groups but no datasets will be erased. (?)

◆ getPaths() [1/2]

static void getPaths ( const TR &  tree,
S &  container 
)
inlinestatic

Returns a list of the node names matching a pattern. The trailing '/' is NOT appended ie. should not be tested by RegExp.

Parameters
prefix- leading part of

◆ getPaths() [2/2]

static void getPaths ( const TR &  tree,
S &  container,
const typename TR::path_t &  path 
)
inlinestatic

Returns a list of the node names matching a pattern. The trailing '/' is NOT appended ie. should not be tested by RegExp.

Template Parameters
S- container (STL Sequence)
Parameters
prefix- leading part of

◆ traverse()

static void traverse ( H &  handler,
T &  tree,
const typename T::path_t &  path = typename T::path_t() 
)
inlinestatic

Traverse tree, visiting each node as a prefix operation.

Simple version.

Template Parameters
H- object with method visit(tree, path).
T- tree type, can be const

TODO: more codes than non-zero


The documentation for this class was generated from the following file: