line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright (C) 2003-2007, G. Allen Morris III, all rights reserved |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
51
|
use strict; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
365
|
|
4
|
|
|
|
|
|
|
package |
5
|
|
|
|
|
|
|
Data::Tabular::Table::Data; |
6
|
|
|
|
|
|
|
|
7
|
7
|
|
|
7
|
|
40
|
use base 'Data::Tabular::Table'; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
5101
|
|
8
|
|
|
|
|
|
|
|
9
|
7
|
|
|
7
|
|
7072
|
use Data::Tabular::Type; |
|
7
|
|
|
|
|
19
|
|
|
7
|
|
|
|
|
202
|
|
10
|
|
|
|
|
|
|
|
11
|
7
|
|
|
7
|
|
43
|
use Carp qw (croak); |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
5263
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new |
14
|
|
|
|
|
|
|
{ |
15
|
27
|
|
|
27
|
1
|
46
|
my $caller = shift; |
16
|
|
|
|
|
|
|
|
17
|
27
|
|
|
|
|
231
|
my $self = $caller->SUPER::new(@_); |
18
|
|
|
|
|
|
|
|
19
|
27
|
|
|
|
|
78
|
$self; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub row_count |
23
|
|
|
|
|
|
|
{ |
24
|
0
|
|
|
0
|
1
|
0
|
shift->_row_count; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _row_count |
28
|
|
|
|
|
|
|
{ |
29
|
109
|
|
|
109
|
|
150
|
my $self = shift; |
30
|
|
|
|
|
|
|
|
31
|
109
|
|
|
|
|
125
|
scalar(@{$self->{data}->{rows}}); |
|
109
|
|
|
|
|
418
|
|
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub headers |
35
|
|
|
|
|
|
|
{ |
36
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
0
|
@{$self->{data}->{headers}}; |
|
0
|
|
|
|
|
0
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub all_headers |
42
|
|
|
|
|
|
|
{ |
43
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
44
|
|
|
|
|
|
|
|
45
|
0
|
0
|
0
|
|
|
0
|
$self->{_all_headers} ||= [ @{$self->{data}->{headers} || []} ]; |
|
0
|
|
|
|
|
0
|
|
46
|
0
|
|
|
|
|
0
|
my @headers = @{$self->{_all_headers}}; |
|
0
|
|
|
|
|
0
|
|
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
0
|
@headers; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub get_row_column |
52
|
|
|
|
|
|
|
{ |
53
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
54
|
0
|
|
|
|
|
0
|
my $row = shift; |
55
|
0
|
|
|
|
|
0
|
my $column = shift; |
56
|
0
|
|
|
|
|
0
|
my $count = scalar(@{$self->{data}->{headers}}); |
|
0
|
|
|
|
|
0
|
|
57
|
0
|
|
|
|
|
0
|
my $ret; |
58
|
0
|
0
|
|
|
|
0
|
if ($column >= $count) { |
59
|
0
|
|
|
|
|
0
|
warn caller; |
60
|
0
|
|
|
|
|
0
|
$ret = 'Column too great'; |
61
|
|
|
|
|
|
|
} else { |
62
|
0
|
|
|
|
|
0
|
$ret = $self->{data}->{rows}->[$row][$column]; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
0
|
if (my $type = $self->{data}->{types}[$column]) { |
66
|
0
|
0
|
|
|
|
0
|
unless (ref $ret) { |
67
|
0
|
|
|
|
|
0
|
$type = "Data::Tabular::Type::$type"; |
68
|
0
|
|
|
|
|
0
|
$ret = bless({ data => $ret }, $type); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
0
|
return $ret; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub get_row_column_name |
76
|
|
|
|
|
|
|
{ |
77
|
1395
|
|
|
1395
|
1
|
1795
|
my $self = shift; |
78
|
1395
|
|
|
|
|
1685
|
my $row = shift; |
79
|
1395
|
|
|
|
|
5911
|
my $column_name = shift; |
80
|
1395
|
|
|
|
|
1495
|
my $count = scalar(@{$self->{data}->{headers}}); |
|
1395
|
|
|
|
|
2964
|
|
81
|
1395
|
|
|
|
|
1719
|
my $column; |
82
|
|
|
|
|
|
|
my $ret; |
83
|
|
|
|
|
|
|
|
84
|
1395
|
|
|
|
|
3713
|
for ($column = 0; $column < $count; $column++) { |
85
|
5220
|
100
|
|
|
|
19809
|
last if $self->{data}->{headers}->[$column] eq $column_name; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
1395
|
50
|
|
|
|
2950
|
if ($column >= $count) { |
89
|
0
|
|
|
|
|
0
|
$ret = 'Unknown Column '. $column_name; |
90
|
|
|
|
|
|
|
} else { |
91
|
1395
|
|
|
|
|
37334
|
$ret = $self->{data}->{rows}->[$row][$column]; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
1395
|
50
|
|
|
|
3788
|
if (my $type = $self->{data}->{types}[$column]) { |
95
|
0
|
0
|
|
|
|
0
|
unless (ref $ret) { |
96
|
0
|
|
|
|
|
0
|
$type = "Data::Tabular::Type::$type"; |
97
|
0
|
|
|
|
|
0
|
$ret = bless({ data => $ret }, $type); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
1395
|
|
|
|
|
10039
|
return $ret; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub row_package |
105
|
|
|
|
|
|
|
{ |
106
|
0
|
|
|
0
|
1
|
0
|
require Data::Tabular::Row::Data; |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
0
|
'Data::Tabular::Row::Data'; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub rows |
112
|
|
|
|
|
|
|
{ |
113
|
12
|
|
|
12
|
1
|
23
|
my $self = shift; |
114
|
12
|
|
|
|
|
39
|
my $args = { @_ }; |
115
|
12
|
|
|
|
|
22
|
my @ret; |
116
|
|
|
|
|
|
|
|
117
|
12
|
50
|
|
|
|
52
|
die 'Need output' unless $args->{output}; |
118
|
|
|
|
|
|
|
|
119
|
12
|
|
|
|
|
96
|
for (my $row = 0; $row < $self->_row_count; $row++) { |
120
|
97
|
|
|
|
|
352
|
push(@ret, $self->row_package->new( |
121
|
|
|
|
|
|
|
table => $self, # FIXME: This is very bad! |
122
|
|
|
|
|
|
|
input_row => $row, |
123
|
|
|
|
|
|
|
extra => $self->{extra}, |
124
|
|
|
|
|
|
|
output => $args->{output}, |
125
|
|
|
|
|
|
|
row_id => $row + 1, |
126
|
|
|
|
|
|
|
)); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
12
|
|
|
|
|
40
|
$self->{rows} = \@ret; |
130
|
12
|
50
|
|
|
|
64
|
wantarray ? @{$self->{rows}} : $self->{rows}; |
|
12
|
|
|
|
|
376
|
|
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
1; |
134
|
|
|
|
|
|
|
__END__ |