line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::HAProxy::Iterator; |
2
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
45
|
|
3
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
34
|
|
4
|
2
|
|
|
2
|
|
7
|
use Config::HAProxy::Node; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
35
|
|
5
|
2
|
|
|
2
|
|
7
|
use Carp; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
104
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use constant { |
8
|
2
|
|
|
|
|
794
|
NO_RECURSION => 0, |
9
|
|
|
|
|
|
|
INORDER => 1, |
10
|
|
|
|
|
|
|
POSTORDER => 2 |
11
|
2
|
|
|
2
|
|
12
|
}; |
|
2
|
|
|
|
|
2
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
20
|
|
|
20
|
0
|
19
|
my $class = shift; |
15
|
20
|
|
|
|
|
18
|
my $node = shift; |
16
|
20
|
|
|
|
|
25
|
my $self = bless { }, $class; |
17
|
20
|
50
|
|
|
|
28
|
if ($node->is_section) { |
18
|
20
|
|
|
|
|
26
|
$self->{_list} = [ $node->tree() ]; |
19
|
|
|
|
|
|
|
} else { |
20
|
0
|
|
|
|
|
0
|
$self->{_list} = [ $node ]; |
21
|
|
|
|
|
|
|
} |
22
|
20
|
|
|
|
|
37
|
local %_ = @_; |
23
|
20
|
100
|
|
|
|
29
|
if (defined($_{recursive})) { |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
24
|
16
|
|
|
|
|
21
|
$self->{_recursive} = $_{recursive}; |
25
|
|
|
|
|
|
|
} elsif ($_{inorder}) { |
26
|
4
|
|
|
|
|
7
|
$self->{_recursive} = INORDER; |
27
|
|
|
|
|
|
|
} elsif ($_{postorder}) { |
28
|
0
|
|
|
|
|
0
|
$self->{_recursive} = POSTORDER; |
29
|
|
|
|
|
|
|
} else { |
30
|
0
|
|
|
|
|
0
|
$self->{_recursive} = NO_RECURSION; |
31
|
|
|
|
|
|
|
} |
32
|
20
|
|
|
|
|
35
|
return $self; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
68
|
|
|
68
|
1
|
132
|
sub recursive { shift->{_recursive} } |
36
|
16
|
|
|
16
|
1
|
25
|
sub inorder { shift->{_recursive} == INORDER } |
37
|
16
|
|
|
16
|
1
|
32
|
sub postorder { shift->{_recursive} == POSTORDER } |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub next { |
40
|
108
|
|
|
108
|
1
|
101
|
my $self = shift; |
41
|
|
|
|
|
|
|
|
42
|
108
|
100
|
|
|
|
136
|
if ($self->{_itr}) { |
43
|
52
|
100
|
|
|
|
58
|
if (defined(my $v = $self->{_itr}->next())) { |
44
|
36
|
|
|
|
|
63
|
return $v; |
45
|
|
|
|
|
|
|
} else { |
46
|
16
|
|
|
|
|
32
|
delete $self->{_itr}; |
47
|
16
|
50
|
|
|
|
19
|
return $self->{_cur} if $self->postorder; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
72
|
100
|
|
|
|
65
|
if (defined($self->{_cur} = shift @{$self->{_list}})) { |
|
72
|
|
|
|
|
113
|
|
52
|
52
|
100
|
66
|
|
|
53
|
if ($self->recursive && $self->{_cur}->is_section) { |
53
|
16
|
|
|
|
|
19
|
$self->{_itr} = $self->{_cur}->iterator(recursive => $self->recursive); |
54
|
16
|
50
|
|
|
|
22
|
if ($self->inorder) { |
55
|
16
|
|
|
|
|
40
|
return $self->{_cur}; |
56
|
|
|
|
|
|
|
} else { |
57
|
0
|
|
|
|
|
0
|
return $self->next(); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
56
|
|
|
|
|
78
|
return $self->{_cur}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
__END__ |