line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright (C) 2003-2007, G. Allen Morris III, all rights reserved |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
48
|
use strict; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
400
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package |
6
|
|
|
|
|
|
|
Data::Tabular::Group; |
7
|
|
|
|
|
|
|
|
8
|
7
|
|
|
7
|
|
42
|
use base 'Data::Tabular::Table::Extra'; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
9815
|
|
9
|
|
|
|
|
|
|
|
10
|
7
|
|
|
7
|
|
8694
|
use Data::Tabular::Table::Group; |
|
7
|
|
|
|
|
21
|
|
|
7
|
|
|
|
|
216
|
|
11
|
|
|
|
|
|
|
|
12
|
7
|
|
|
7
|
|
45
|
use Carp qw (croak); |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
11364
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub clone |
15
|
|
|
|
|
|
|
{ |
16
|
0
|
|
|
0
|
0
|
0
|
my $caller = shift; |
17
|
0
|
|
0
|
|
|
0
|
my $self = shift || {}; |
18
|
0
|
|
|
|
|
0
|
my $class = ref($caller); |
19
|
0
|
|
|
|
|
0
|
for my $key (keys %$caller) { |
20
|
0
|
|
|
|
|
0
|
$self->{$key} = $caller->{$key}; |
21
|
|
|
|
|
|
|
} |
22
|
0
|
|
|
|
|
0
|
bless $self, $class; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub new |
26
|
|
|
|
|
|
|
{ |
27
|
9
|
|
|
9
|
1
|
21
|
my $caller = shift; |
28
|
|
|
|
|
|
|
|
29
|
9
|
|
|
|
|
67
|
my $self = $caller->SUPER::new(@_); |
30
|
|
|
|
|
|
|
|
31
|
9
|
100
|
|
|
|
38
|
if ($self->{groups}) { |
32
|
7
|
|
|
|
|
13
|
my @groups = @{$self->{groups}}; |
|
7
|
|
|
|
|
30
|
|
33
|
7
|
|
|
|
|
13
|
my $group = shift @groups; |
34
|
7
|
100
|
|
|
|
79
|
die 'No column required for first group.' if $group->{column}; |
35
|
6
|
|
|
|
|
24
|
my $x = 2; |
36
|
6
|
|
|
|
|
48
|
for my $group (@groups) { |
37
|
6
|
100
|
|
|
|
30
|
die "Need column for group $x" unless $group->{column}; |
38
|
5
|
|
|
|
|
14
|
$x++; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} else { |
41
|
2
|
50
|
|
|
|
10
|
die q|Columns are gone!| if $self->{columns}; |
42
|
|
|
|
|
|
|
$self->{groups} = [ |
43
|
|
|
|
|
|
|
{ |
44
|
|
|
|
|
|
|
pre => sub { |
45
|
4
|
|
|
4
|
|
6
|
my $self = shift; |
46
|
4
|
|
|
|
|
20
|
( $self->titles( class => 'xgam3x' ) ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
2
|
|
|
|
|
24
|
]; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# die 'Group needs a table' unless $self->table; |
53
|
|
|
|
|
|
|
# die 'table must be a Data::Tabular::Output object.' unless $self->table->isa('Data::Tabular::Output'); |
54
|
|
|
|
|
|
|
|
55
|
7
|
|
|
|
|
32
|
$self; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub sum_list |
59
|
|
|
|
|
|
|
{ |
60
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
61
|
0
|
|
|
|
|
0
|
@{$self->{sum}}; |
|
0
|
|
|
|
|
0
|
|
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub compare |
65
|
|
|
|
|
|
|
{ |
66
|
94
|
|
|
94
|
0
|
129
|
my $self = shift; |
67
|
94
|
|
|
|
|
101
|
my $first = shift; |
68
|
94
|
|
|
|
|
120
|
my $row = shift; |
69
|
94
|
|
|
|
|
121
|
my $key = shift; |
70
|
|
|
|
|
|
|
|
71
|
94
|
|
|
|
|
301
|
$first->get_column($key)->string ne $row->get_column($key)->string; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub _doit |
75
|
|
|
|
|
|
|
{ |
76
|
91
|
|
|
91
|
|
134
|
my $self = shift; |
77
|
91
|
|
|
|
|
116
|
my $level = shift; |
78
|
|
|
|
|
|
|
|
79
|
91
|
50
|
|
|
|
208
|
if ($level < 0) { |
80
|
0
|
|
|
|
|
0
|
return( @_ ); |
81
|
|
|
|
|
|
|
} |
82
|
91
|
100
|
|
|
|
206
|
if ($level > $self->max_level) { |
83
|
35
|
|
|
|
|
154
|
return( @_ ); |
84
|
|
|
|
|
|
|
} |
85
|
56
|
|
|
|
|
171
|
my @sections = @_; |
86
|
|
|
|
|
|
|
|
87
|
56
|
|
|
|
|
86
|
my $first = shift @sections; |
88
|
|
|
|
|
|
|
|
89
|
56
|
|
|
|
|
88
|
my @inp = (); |
90
|
|
|
|
|
|
|
|
91
|
56
|
|
|
|
|
192
|
while (my $row = shift @sections) { |
92
|
155
|
|
|
|
|
399
|
for (my $x = 1; $x <= $level; $x++) { |
93
|
94
|
50
|
|
|
|
294
|
die 'Need column' unless $self->{groups}->[$x]->{column}; |
94
|
94
|
100
|
|
|
|
271
|
if ($self->compare($first, $row, $self->{groups}->[$x]->{column})) { |
95
|
23
|
|
|
|
|
124
|
return ( $self->_do_group($level, $self->_doit($level+1, $first, @inp)), |
96
|
|
|
|
|
|
|
$self->_doit($level, $row, @sections) |
97
|
|
|
|
|
|
|
); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
132
|
|
|
|
|
499
|
push(@inp, $row); |
101
|
|
|
|
|
|
|
} |
102
|
33
|
|
|
|
|
191
|
return($self->_do_group($level, $self->_doit($level + 1, $first, @inp))); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub max_level |
106
|
|
|
|
|
|
|
{ |
107
|
91
|
|
|
91
|
0
|
122
|
my $self = shift; |
108
|
91
|
50
|
|
|
|
102
|
die 'no groups' unless(scalar(@{$self->{groups}}) - 1 >= 0); |
|
91
|
|
|
|
|
330
|
|
109
|
91
|
|
|
|
|
115
|
scalar(@{$self->{groups}}) - 1; |
|
91
|
|
|
|
|
330
|
|
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub data |
113
|
|
|
|
|
|
|
{ |
114
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
115
|
0
|
|
|
|
|
0
|
$self->{data}; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub _columns |
119
|
|
|
|
|
|
|
{ |
120
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
121
|
0
|
|
|
|
|
0
|
$self->table->columns; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub row_count |
125
|
|
|
|
|
|
|
{ |
126
|
1
|
|
|
1
|
1
|
776
|
my $self = shift; |
127
|
|
|
|
|
|
|
|
128
|
1
|
50
|
|
|
|
11
|
$self->{row_count} || die "row_count is not available until after rows is called."; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub rows |
132
|
|
|
|
|
|
|
{ |
133
|
12
|
|
|
12
|
1
|
23
|
my $self = shift; |
134
|
12
|
|
|
|
|
47
|
my $args = { @_ }; |
135
|
|
|
|
|
|
|
|
136
|
12
|
|
|
|
|
189
|
my $ret = $self->_doit(0, $self->SUPER::rows(@_)); |
137
|
|
|
|
|
|
|
|
138
|
12
|
|
|
|
|
111
|
my @rows = $ret->rows(@_); |
139
|
12
|
|
|
|
|
46
|
$self->{row_count} = scalar(@rows); |
140
|
12
|
|
|
|
|
140
|
@rows; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub group_it |
144
|
|
|
|
|
|
|
{ |
145
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
146
|
0
|
|
|
|
|
0
|
my $data = shift; # Data::Tabular::Output; |
147
|
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
0
|
my $ret; |
149
|
0
|
|
|
|
|
0
|
my $grouped = $self->{grouped}; |
150
|
0
|
0
|
0
|
|
|
0
|
unless ($self->{grouped} && $self->data eq $data) { |
151
|
0
|
|
|
|
|
0
|
$grouped = $self->new(data => $data); |
152
|
0
|
|
|
|
|
0
|
$ret = $grouped->_do_group(0, $self->_doit($self->max_level, $data->rows)); |
153
|
0
|
|
|
|
|
0
|
$grouped->{grouped} = $ret; |
154
|
|
|
|
|
|
|
} |
155
|
0
|
|
|
|
|
0
|
$grouped; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub _do_group |
159
|
|
|
|
|
|
|
{ |
160
|
56
|
|
|
56
|
|
79
|
my $self = shift; |
161
|
56
|
|
|
|
|
74
|
my $level = shift; |
162
|
|
|
|
|
|
|
|
163
|
56
|
|
|
|
|
410
|
my $ret = Data::Tabular::Table::Group->new(data => [ @_ ], level => $level, group => $self); |
164
|
56
|
|
|
|
|
715
|
($ret); |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub table |
168
|
|
|
|
|
|
|
{ |
169
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
170
|
0
|
|
|
|
|
|
$self->{table}; |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
1; |
174
|
|
|
|
|
|
|
__END__ |