From 0c79025f9305b4ddf24a34c74f8e4e47f28b6a6e Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Fri, 30 Mar 2012 13:55:06 +0200 Subject: Added output of tree to stdout. --- src/tasktree.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/tasktree.cc') 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 -- cgit v1.2.3