Skip to content

Commit eaeac2b

Browse files
committed
Feature: Add xml_tree_walker::out(const xml_node&) which is called after each node traversed
1 parent 5a1892b commit eaeac2b

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/pugixml.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6811,17 +6811,28 @@ namespace pugi
68116811
cur = cur->first_child;
68126812
}
68136813
else if (cur->next_sibling)
6814+
{
68146815
cur = cur->next_sibling;
6816+
walker.out(arg_for_each);
6817+
}
68156818
else
68166819
{
68176820
while (!cur->next_sibling && cur != _root && cur->parent)
68186821
{
6822+
xml_node arg_out(cur);
6823+
68196824
--walker._depth;
68206825
cur = cur->parent;
6826+
6827+
walker.out(arg_out);
68216828
}
68226829

68236830
if (cur != _root)
6831+
{
6832+
xml_node arg_out(cur);
68246833
cur = cur->next_sibling;
6834+
walker.out(arg_out);
6835+
}
68256836
}
68266837
}
68276838
while (cur && cur != _root);

src/pugixml.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,8 @@ namespace pugi
10481048

10491049
// Callback that is called for each node traversed
10501050
virtual bool for_each(xml_node& node) = 0;
1051+
// Callback that is called after each node traversed
1052+
virtual void out(const xml_node& ){}
10511053

10521054
// Callback that is called when traversal ends
10531055
virtual bool end(xml_node& node);

0 commit comments

Comments
 (0)