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 heirarchy, 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 argu‐
56           ment and throws an exception if it is not a code reference. This
57           code reference is used to filter the tree nodes as they are placed
58           into the hash tree. The $filter_function is passed a Tree::Simple
59           object, and is expected to return the value desired for inclusion
60           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

BUGS

72       None that I am aware of. Of course, if you find a bug, let me know, and
73       I will be sure to fix it.
74

CODE COVERAGE

76       See the CODE COVERAGE section in Tree::Simple::VisitorFactory for more
77       inforamtion.
78

SEE ALSO

80       These Visitor classes are all subclasses of Tree::Simple::Visitor,
81       which can be found in the Tree::Simple module, you should refer to that
82       module for more information.
83

AUTHOR

85       stevan little, <stevan@iinteractive.com>
86
88       Copyright 2004, 2005 by Infinity Interactive, Inc.
89
90       <http://www.iinteractive.com>
91
92       This library is free software; you can redistribute it and/or modify it
93       under the same terms as Perl itself.
94
95
96
97perl v5.8.8                       2005-07T-r1e3e::Simple::Visitor::ToNestedHash(3)
Impressum