1Tree::Simple::Visitor::UGseetrAlCloDnetsrciebnudtTeerndetesP:(e:3rS)limDpolceu:m:eVnitsaittioorn::GetAllDescendents(3)
2
3
4

NAME

6       Tree::Simple::Visitor::GetAllDescendents - A Visitor for fetching all
7       the descendents of a Tree::Simple object
8

SYNOPSIS

10         use Tree::Simple::Visitor::GetAllDescendents;
11
12         # create an instance of our visitor
13         my $visitor = Tree::Simple::Visitor::GetAllDescendents->new();
14
15         # pass the visitor to a Tree::Simple object
16         $tree->accept($visitor);
17
18         # you can also get the descendents
19         # back as an array of node values
20         my @descendents = $visitor->getDescendents();
21
22         # for more complex node objects, you can specify
23         # a node filter which will be used to extract the
24         # information desired from each node
25         $visitor->setNodeFilter(sub {
26                       my ($t) = @_;
27                       return $t->getNodeValue()->description();
28                       });
29

DESCRIPTION

31       Given a Tree::Simple instance this Visitor will return all the
32       descendents recursively on down the hierarchy.
33

METHODS

35       new There are no arguments to the constructor the object will be in its
36           default state. You can use the "setNodeFilter" method to customize
37           its behavior.
38
39       setTraversalMethod ($visitor)
40           By default we will use Tree::Simple's built in depth-first (pre-
41           order) traverse method. If however, you desire the descendents to
42           be returned in a different ordering, this can be accomplished using
43           a different traversal method, you can supply a $visitor object
44           implementing that traversal type to this method (See
45           Tree::Simple::Visitor::BreadthFirstTraversal,
46           Tree::Simple::Visitor::PreOrderTraversal and
47           Tree::Simple::Visitor::PostOrderTraversal).
48
49       setNodeFilter ($filter_function)
50           This method accepts a CODE reference as its $filter_function
51           argument and throws an exception if it is not a code reference.
52           This code reference is used to filter the tree nodes as they are
53           collected. This can be used to customize output, or to gather
54           specific information from a more complex tree node. The filter
55           function should accept a single argument, which is the current
56           Tree::Simple object.
57
58       visit ($tree)
59           This is the method that is used by Tree::Simple's "accept" method.
60           It can also be used on its own, it requires the $tree argument to
61           be a Tree::Simple object (or derived from a Tree::Simple object),
62           and will throw and exception otherwise.
63
64       getAllDescendents
65           This method will give back and array of descendents in depth-first
66           order (pre-order) or in the order specified by the
67           "setTraversalMethod". If called in scalar context it will give an
68           array reference, in list context it will return a regular array.
69           This method is the same as calling "getResults".
70

Repository

72       <https://github.com/ronsavage/Tree-Simple-VisitorFactory>
73

SUPPORT

75       Bugs should be reported via the CPAN bug tracker at
76
77       <https://github.com/ronsavage/Tree-Simple-VisitorFactory/issues>
78

CODE COVERAGE

80       See the CODE COVERAGE section in Tree::Simple::VisitorFactory for more
81       information.
82

SEE ALSO

84       These Visitor classes are all subclasses of Tree::Simple::Visitor,
85       which can be found in the Tree::Simple module, you should refer to that
86       module for more information.
87

AUTHOR

89       stevan little, <stevan@iinteractive.com>
90
92       Copyright 2004, 2005 by Infinity Interactive, Inc.
93
94       <http://www.iinteractive.com>
95
96       This library is free software; you can redistribute it and/or modify it
97       under the same terms as Perl itself.
98
99
100
101perl v5.36.0                      20T2r3e-e0:1:-S2i0mple::Visitor::GetAllDescendents(3)
Impressum