line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright (C) 2003-2007, G. Allen Morris III, all rights reserved |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
56
|
use strict; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
5332
|
|
4
|
|
|
|
|
|
|
package |
5
|
|
|
|
|
|
|
Data::Tabular::Table::Extra; |
6
|
|
|
|
|
|
|
|
7
|
7
|
|
|
7
|
|
52
|
use base 'Data::Tabular::Table::Data'; |
|
7
|
|
|
|
|
27
|
|
|
7
|
|
|
|
|
5362
|
|
8
|
|
|
|
|
|
|
|
9
|
7
|
|
|
7
|
|
46
|
use Carp qw (croak); |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
6417
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new |
12
|
|
|
|
|
|
|
{ |
13
|
18
|
|
|
18
|
1
|
32
|
my $caller = shift; |
14
|
18
|
|
|
|
|
179
|
my $self = $caller->SUPER::new(@_); |
15
|
|
|
|
|
|
|
|
16
|
18
|
50
|
|
|
|
30
|
$self->{_all_headers} = [ (@{$self->{data}->{headers} || []}, sort keys(%{$self->extra->{columns} || {}})) ]; |
|
18
|
50
|
|
|
|
74
|
|
|
18
|
|
|
|
|
82
|
|
17
|
|
|
|
|
|
|
|
18
|
18
|
|
|
|
|
67
|
$self; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub extra |
22
|
|
|
|
|
|
|
{ |
23
|
1831
|
|
|
1831
|
0
|
2916
|
my $self = shift; |
24
|
|
|
|
|
|
|
|
25
|
1831
|
|
|
|
|
17151
|
$self->{extra}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub is_extra |
29
|
|
|
|
|
|
|
{ |
30
|
1813
|
|
|
1813
|
1
|
2213
|
my $self = shift; |
31
|
1813
|
|
|
|
|
7748
|
my $column_name = shift; |
32
|
|
|
|
|
|
|
|
33
|
1813
|
|
|
|
|
3531
|
exists $self->extra->{columns}->{$column_name}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub headers |
37
|
|
|
|
|
|
|
{ |
38
|
554
|
|
|
554
|
1
|
735
|
my $self = shift; |
39
|
|
|
|
|
|
|
|
40
|
554
|
|
|
|
|
659
|
@{$self->{_all_headers}}; |
|
554
|
|
|
|
|
2663
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub all_headers |
44
|
|
|
|
|
|
|
{ |
45
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
46
|
|
|
|
|
|
|
|
47
|
0
|
0
|
|
|
|
0
|
$self->{_all_headers} = [ (@{$self->{data}->{headers} || []}, sort keys(%{$self->extra->{columns} || {}})) ]; |
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
0
|
@{$self->{_all_headers}}; |
|
0
|
|
|
|
|
0
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub row_package |
53
|
|
|
|
|
|
|
{ |
54
|
97
|
|
|
97
|
1
|
5093
|
require Data::Tabular::Row::Extra; |
55
|
97
|
|
|
|
|
552
|
'Data::Tabular::Row::Extra'; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub header_offset |
59
|
|
|
|
|
|
|
{ |
60
|
0
|
|
|
0
|
1
|
|
die; |
61
|
0
|
|
|
|
|
|
my $self = shift; |
62
|
0
|
|
|
|
|
|
my $column = shift; |
63
|
0
|
|
|
|
|
|
my $count = 0; |
64
|
0
|
0
|
|
|
|
|
unless ($self->{_header_off}) { |
65
|
0
|
|
|
|
|
|
for my $header ($self->headers) { |
66
|
0
|
|
|
|
|
|
$self->{_header_off}->{$header} = $count++; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
0
|
|
|
|
|
|
my $ret = $self->{_header_off}->{$column}; |
70
|
0
|
|
|
|
|
|
croak "column '$column' not found in [", |
71
|
|
|
|
|
|
|
join(" ", |
72
|
0
|
0
|
|
|
|
|
sort keys(%{$self->{_header_off}}) |
73
|
|
|
|
|
|
|
), ']' unless defined $ret; |
74
|
0
|
|
|
|
|
|
$ret; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub get_row_column |
78
|
|
|
|
|
|
|
{ |
79
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
80
|
0
|
|
|
|
|
|
my $row = shift; |
81
|
0
|
|
|
|
|
|
my $column = shift; |
82
|
0
|
|
|
|
|
|
my $count = scalar(@{$self->{data}->{headers}}); |
|
0
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
0
|
0
|
|
|
|
|
if ($column >= $count) { |
85
|
0
|
|
|
|
|
|
die 'column out of range'; |
86
|
|
|
|
|
|
|
} else { |
87
|
0
|
|
|
|
|
|
$self->{data}->{rows}->[$row][$column]; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub extra_column |
92
|
|
|
|
|
|
|
{ |
93
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
94
|
0
|
|
|
|
|
|
my $row = shift; |
95
|
0
|
|
|
|
|
|
my $key = shift; |
96
|
0
|
|
|
|
|
|
my $ret = 'N/A'; |
97
|
0
|
|
|
|
|
|
die; |
98
|
0
|
|
|
|
|
|
my $extra = $self->{extra}; |
99
|
|
|
|
|
|
|
|
100
|
0
|
0
|
|
|
|
|
return undef unless $row; |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
my $offset = $self->header_offset($key); |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
my $x = $self->extra_package->new(row => $row, table => $self); |
105
|
|
|
|
|
|
|
|
106
|
0
|
0
|
|
|
|
|
if (ref($extra->{$key}) eq 'CODE') { |
107
|
0
|
|
|
|
|
|
eval { |
108
|
0
|
|
|
|
|
|
$ret = $extra->{$key}->($x); |
109
|
|
|
|
|
|
|
}; |
110
|
0
|
0
|
|
|
|
|
if ($@) { |
111
|
0
|
|
|
|
|
|
die $@; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
} else { |
114
|
0
|
|
|
|
|
|
die 'only know how to deal with code'; |
115
|
|
|
|
|
|
|
} |
116
|
0
|
|
|
|
|
|
die $ret; |
117
|
0
|
0
|
|
|
|
|
if (ref($ret)) { |
118
|
0
|
0
|
|
|
|
|
die if (ref($ret) eq 'HASH'); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
$ret; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |
125
|
|
|
|
|
|
|
__END__ |