1Tree::Simple::Visitor::UTsoeNresCtoendtHraisbhu(t3e)d PeTrrleeD:o:cSuimmepnltea:t:iVoinsitor::ToNestedHash(3)
2
3
4

NAME

6       Tree::Simple::Visitor::ToNestedHash - A Visitor for creating nested
7       hash trees from Tree::Simple objects.
8

SYNOPSIS

10         use Tree::Simple::Visitor::ToNestedHash;
11
12         my $visitor = Tree::Simple::Visitor::ToNestedHash->new();
13
14         # given this Tree::Simple tree
15         my $tree = Tree::Simple->new("Root")
16                       ->addChildren(
17                           Tree::Simple->new("Child1")
18                               ->addChildren(
19                                   Tree::Simple->new("GrandChild1"),
20                                   Tree::Simple->new("GrandChild2")
21                               ),
22                           Tree::Simple->new("Child2"),
23                       );
24
25         $tree->accept($visitor);
26
27         my $array_tree = $visitor->getResults();
28
29         # this then creates the equivalent nested array tree:
30         # {
31         # Root => {
32         #         Child1 => {
33         #                 GrandChild1 => {},
34         #                 GrandChild2 => {}
35         #                 },
36         #         Child2 => {}
37         #         }
38         # }
39

DESCRIPTION

41       Given a tree constructed from a Tree::Simple hierarchy, this Visitor
42       will create the equivalent tree of nested hashes.
43

METHODS

45       new There are no arguments to the constructor the object will be in its
46           default state. You can use the "setNodeFilter" and "includTrunk"
47           methods to customize its behavior.
48
49       includTrunk ($boolean)
50           Setting the $boolean value to true (1) will cause the node value of
51           the tree's root to be included in the nested hash output, setting
52           it to false will do the opposite.
53
54       setNodeFilter ($filter_function)
55           This method accepts a CODE reference as its $filter_function
56           argument and throws an exception if it is not a code reference.
57           This code reference is used to filter the tree nodes as they are
58           placed into the hash tree. The $filter_function is passed a
59           Tree::Simple object, and is expected to return the value desired
60           for inclusion into the hash tree.
61
62       visit ($tree)
63           This is the method that is used by Tree::Simple's "accept" method.
64           It can also be used on its own, it requires the $tree argument to
65           be a Tree::Simple object (or derived from a Tree::Simple object),
66           and will throw and exception otherwise.
67
68       getResults
69           This method will return the hash tree constructed.
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.38.0                      2023-07T-r2e1e::Simple::Visitor::ToNestedHash(3)
Impressum