#include <entriesblk.h>
#include <iostream>
#include <string>
#include <stdio.h>
#include <treekeyidx.h>
Go to the source code of this file.
Definition at line 90 of file treeidxutil.cpp.
92 std::cout <<
"Enter New Child Name: ";
93 fgets(buf, 1000, stdin);
94 treeKey->appendChild();
95 treeKey->setLocalName(buf);
Definition at line 77 of file treeidxutil.cpp.
78 if (treeKey->getOffset()) {
80 std::cout <<
"Enter New Sibbling Name: ";
81 fgets(buf, 1000, stdin);
83 treeKey->setLocalName(buf);
86 else std::cout <<
"Can't add sibling to root node\n";
Definition at line 69 of file treeidxutil.cpp.
71 std::cout <<
"Enter path: ";
72 fgets(buf, 1000, stdin);
73 treeKey->assureKeyPath(buf);
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 109 of file treeidxutil.cpp.
112 fprintf(stderr,
"usage: %s <tree/key/data/path>\n", *argv);
116 TreeKeyIdx *treeKey =
new TreeKeyIdx(argv[1]);
118 if (treeKey->popError()) {
119 treeKey->create(argv[1]);
121 treeKey =
new TreeKeyIdx(argv[1]);
123 TreeKeyIdx root = *treeKey;
129 std::cout <<
"[" << treeKey->getText() <<
"] > ";
130 fgets(line, 1000, stdin);
132 if (input.length() > 0) {
136 case 'p': root.root();
printTree(root, treeKey);
break;
139 case 'j': treeKey->nextSibling();
break;
141 case 'k': treeKey->previousSibling();
break;
142 case 'h': treeKey->parent();
break;
143 case 'l': treeKey->firstChild();
break;
144 case 'r': treeKey->root();
break;
148 std::cout <<
"\n p - print tree\n";
149 std::cout <<
" n - get local name\n";
150 std::cout <<
" s - set local name\n";
151 std::cout <<
" j - next sibbling\n";
152 std::cout <<
" k - previous sibbling\n";
153 std::cout <<
" h - parent\n";
154 std::cout <<
" l - first child\n";
155 std::cout <<
" r - root\n";
156 std::cout <<
" a - append sibbling\n";
157 std::cout <<
" c - append child\n";
158 std::cout <<
" u - get user data\n";
159 std::cout <<
" d - set user data\n";
160 std::cout <<
" g - goto path; create if it doesn't exist\n";
161 std::cout <<
" q - quit\n\n";
166 while (input.compare(
"q"));
void appendSibbling(TreeKeyIdx *treeKey)
void printTree(TreeKeyIdx treeKey, TreeKeyIdx *target=0, int level=1)
void setLocalName(TreeKeyIdx *treeKey)
void printLocalName(TreeKeyIdx *treeKey)
void assurePath(TreeKeyIdx *treeKey)
void appendChild(TreeKeyIdx *treeKey)
Definition at line 55 of file treeidxutil.cpp.
56 std::cout <<
"locaName: " << treeKey->getLocalName() << std::endl;
Definition at line 37 of file treeidxutil.cpp.
41 unsigned long currentOffset = target->getOffset();
42 std::cout << ((currentOffset == treeKey.getOffset()) ?
"==>" :
"");
43 for (
int i = 0; i < level; i++) std::cout <<
"\t";
44 std::cout << treeKey.getLocalName() << std::endl;
45 if (treeKey.firstChild()) {
49 if (treeKey.nextSibling())
void printTree(TreeKeyIdx treeKey, TreeKeyIdx *target=0, int level=1)
Definition at line 100 of file treeidxutil.cpp.
101 if (index < eb->getCount()) {
102 std::cout <<
"Removing entry [" << index <<
"]\n";
105 else std::cout <<
"Invalid entry number\n\n";
void removeEntry(int entryIndex)
Definition at line 60 of file treeidxutil.cpp.
62 std::cout <<
"Enter New Node Name: ";
63 fgets(buf, 1000, stdin);
64 treeKey->setLocalName(buf);