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