source: cpp/frams/_demos/paramtree_print.cpp @ 1252

Last change on this file since 1252 was 755, checked in by Maciej Komosinski, 7 years ago

Renamed ParamTree::Node -> ParamTree::ParamTreeNode? to avoid name conflicts with js

File size: 1.3 KB
RevLine 
[723]1#include <stdio.h>
2#include "paramtree_print.h"
3
4//#define NO_BOX_CHARACTERS
5
6#ifdef NO_BOX_CHARACTERS
7#define TREEDRAWING_L_MORE  "+-"
8#define TREEDRAWING_L_LAST  "'-"
9#define TREEDRAWING_I       "| "
10#define TREEDRAWING_NOMORE  "  "
11#define TREEDRAWING_CHILD   "+"
12#define TREEDRAWING_NOCHILD "-"
13#else
14#define TREEDRAWING_L_MORE  "├─"
15#define TREEDRAWING_L_LAST  "└─"
16#define TREEDRAWING_I       "│ "
17#define TREEDRAWING_NOMORE  "  "
18#define TREEDRAWING_CHILD   "┬"
19#define TREEDRAWING_NOCHILD "─"
20#endif
21
[755]22static void printLines(ParamTree::ParamTreeNode *n, bool first = true)
[723]23{
24        if (n->parent)
25                printLines(n->parent, false);
26        printf(n->next_sibling.get() != NULL ?
27                (first ? TREEDRAWING_L_MORE : TREEDRAWING_I)
28                : (first ? TREEDRAWING_L_LAST : TREEDRAWING_NOMORE));
29}
30
[755]31void printTree(ParamTree::ParamTreeNode *n)
[723]32{
33        while (n != NULL)
34        {
35                printLines(n);
36                printf(n->first_child.get() != NULL ? TREEDRAWING_CHILD : TREEDRAWING_NOCHILD);
37                if (n->name[0] != ' ')
38                        printf(" ");
39                printf("%s", n->name.c_str());
40                if (n->group_index >= 0)
41                        printf("\t\t(g=%d,\"%s\")", n->group_index, n->tree->pi.grname(n->group_index));
42                else
43                        printf("\t\t(not a group)");
44                printf("\n");
45                printTree(n->first_child.get());
46                n = n->next_sibling.get();
47        }
48}
Note: See TracBrowser for help on using the repository browser.