summaryrefslogtreecommitdiff
path: root/src/tasktree.cc
diff options
context:
space:
mode:
authorJonas Suhr Christensen <jsc@umbraculum.org>2012-03-30 13:55:06 +0200
committerJonas Suhr Christensen <jsc@umbraculum.org>2012-03-30 13:55:06 +0200
commit0c79025f9305b4ddf24a34c74f8e4e47f28b6a6e (patch)
treeaea3b63aa61312ece0691f2b60f73a4145ded563 /src/tasktree.cc
parent802a8b7e4896a12d8eced17b6ee54c7bca02a629 (diff)
Added output of tree to stdout.
Diffstat (limited to 'src/tasktree.cc')
-rw-r--r--src/tasktree.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/tasktree.cc b/src/tasktree.cc
index e44efee..6e36974 100644
--- a/src/tasktree.cc
+++ b/src/tasktree.cc
@@ -182,6 +182,23 @@ void TaskTree::insertChild(node_t* parent, node_t* child) {
child->parent = parent;
}
+static void printNode(node_t* node, std::string prefix) {
+ if(!node) return;
+ task_t t = node->data;
+ printf("%s/%u - %s\n", prefix.c_str(), t.id, t.title.c_str());
+ char buf[4096];
+ sprintf(buf, "%s/%u - %s", prefix.c_str(), t.id, t.title.c_str());
+
+ NodeList::iterator it;
+ for(it = node->children.begin(); it != node->children.end(); it++) {
+ node_t* child = *it;
+ printNode(child, buf);
+ }
+}
+
+void TaskTree::toStdOut() {
+ printNode(root, "/");
+}
#ifdef TEST_TASKTREE