Recents list, DataTree rewindAll(), Bookmark view updates

This commit is contained in:
Charles J. Cliffe
2016-10-05 19:10:01 -04:00
parent 560caccbc7
commit 020cef12c9
7 changed files with 205 additions and 38 deletions
+33
View File
@@ -565,6 +565,7 @@ DataNode *DataNode::getNext(const char *name_in) {
void DataNode::rewind() {
ptr = 0;
childmap_ptr.erase(childmap_ptr.begin(),childmap_ptr.end());
}
void DataNode::rewind(const char *name_in) {
@@ -1342,6 +1343,38 @@ long DataTree::getSerializedSize(DataElement &de_node_names, bool debug) /* get
return total_size;
}
void DataNode::rewindAll() {
stack<DataNode *> dn_stack;
/* start at the root */
dn_stack.push(this);
while (!dn_stack.empty()) {
dn_stack.top()->rewind();
/* if it has children, traverse into them */
if (dn_stack.top()->hasAnother()) {
dn_stack.push(dn_stack.top()->getNext());
dn_stack.top()->rewind();
} else {
/* no more children, back out until we have children, then add next child to the top */
while (!dn_stack.empty()) {
if (!dn_stack.top()->hasAnother()) {
dn_stack.top()->rewind();
dn_stack.pop();
} else
break;
}
if (!dn_stack.empty()) {
dn_stack.push(dn_stack.top()->getNext());
dn_stack.top()->rewind();
}
}
}
}
void DataNode::findAll(const char *name_in, vector<DataNode *> &node_list_out) {
stack<DataNode *> dn_stack;
+2 -2
View File
@@ -260,7 +260,8 @@ public:
DataNode *getNext(); /* get next child */
void rewind(const char *name_in); /* rewind specific */
void rewind(); /* rewind generic */
void rewindAll();
void findAll(const char *name_in, vector<DataNode *> &node_list_out);
// operator string () { string s; element()->get(s); return s; }
@@ -316,7 +317,6 @@ public:
bool operator() () { return hasAnother(); }
DataNode *operator ^(const char *name_in) { return newChild(name_in); }
};