| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
### |
|
3
|
|
|
|
|
|
|
### Copyright 2002-2003 University of Illinois Board of Trustees |
|
4
|
|
|
|
|
|
|
### Copyright 2002-2003 Mark D. Roth |
|
5
|
|
|
|
|
|
|
### All rights reserved. |
|
6
|
|
|
|
|
|
|
### |
|
7
|
|
|
|
|
|
|
### Config::Objective::Table - table data type for Config::Objective |
|
8
|
|
|
|
|
|
|
### |
|
9
|
|
|
|
|
|
|
### Mark D. Roth |
|
10
|
|
|
|
|
|
|
### Campus Information Technologies and Educational Services |
|
11
|
|
|
|
|
|
|
### University of Illinois at Urbana-Champaign |
|
12
|
|
|
|
|
|
|
### |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
package Config::Objective::Table; |
|
16
|
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
677
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
39
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
10
|
use Config::Objective::List; |
|
|
1
|
|
|
|
|
9
|
|
|
|
1
|
|
|
|
|
989
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our @ISA = qw(Config::Objective::List); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
############################################################################### |
|
25
|
|
|
|
|
|
|
### utility function |
|
26
|
|
|
|
|
|
|
############################################################################### |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _find_row |
|
29
|
|
|
|
|
|
|
{ |
|
30
|
3
|
|
|
3
|
|
5
|
my ($self, $query) = @_; |
|
31
|
3
|
|
|
|
|
4
|
my ($ct, $lref, $key); |
|
32
|
|
|
|
|
|
|
|
|
33
|
3
|
|
|
|
|
5
|
ROWS: for ($ct = 0; $ct < @{$self->{value}}; $ct++) |
|
|
8
|
|
|
|
|
33
|
|
|
34
|
|
|
|
|
|
|
{ |
|
35
|
8
|
|
|
|
|
12
|
$lref = $self->{value}->[$ct]; |
|
36
|
8
|
|
|
|
|
17
|
foreach $key (keys %$query) |
|
37
|
|
|
|
|
|
|
{ |
|
38
|
|
|
|
|
|
|
next ROWS |
|
39
|
8
|
100
|
|
|
|
43
|
if ($lref->[$key] !~ m/$query->{$key}/); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
3
|
|
|
|
|
15
|
return $ct; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
0
|
return undef; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
############################################################################### |
|
50
|
|
|
|
|
|
|
### insert_row method |
|
51
|
|
|
|
|
|
|
############################################################################### |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub insert_row |
|
54
|
|
|
|
|
|
|
{ |
|
55
|
1
|
|
|
1
|
1
|
3
|
my ($self, $query, $newrow) = @_; |
|
56
|
1
|
|
|
|
|
2
|
my ($row); |
|
57
|
|
|
|
|
|
|
|
|
58
|
1
|
50
|
|
|
|
6
|
die "insert_row: row specifier must be a hash\n" |
|
59
|
|
|
|
|
|
|
if (ref($query) ne 'HASH'); |
|
60
|
|
|
|
|
|
|
|
|
61
|
1
|
50
|
|
|
|
6
|
die "insert_row: new row must be list type\n" |
|
62
|
|
|
|
|
|
|
if (ref($newrow) ne 'ARRAY'); |
|
63
|
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
5
|
$row = $self->_find_row($query); |
|
65
|
1
|
50
|
|
|
|
13
|
splice(@{$self->{value}}, $row, 0, $newrow) |
|
|
1
|
|
|
|
|
7
|
|
|
66
|
|
|
|
|
|
|
if (defined($row)); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
############################################################################### |
|
71
|
|
|
|
|
|
|
### find_row method |
|
72
|
|
|
|
|
|
|
############################################################################### |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub find_row |
|
75
|
|
|
|
|
|
|
{ |
|
76
|
0
|
|
|
0
|
1
|
0
|
my ($self, $query) = @_; |
|
77
|
0
|
|
|
|
|
0
|
my ($row); |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
0
|
|
|
|
0
|
die "find_row: row specifier must be a hash\n" |
|
80
|
|
|
|
|
|
|
if (ref($query) ne 'HASH'); |
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
0
|
$row = $self->_find_row($query); |
|
83
|
0
|
0
|
|
|
|
0
|
return $self->{value}->[$row] |
|
84
|
|
|
|
|
|
|
if (defined($row)); |
|
85
|
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
0
|
return undef; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
############################################################################### |
|
91
|
|
|
|
|
|
|
### replace_row_cells method |
|
92
|
|
|
|
|
|
|
############################################################################### |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub replace_row_cells |
|
95
|
|
|
|
|
|
|
{ |
|
96
|
1
|
|
|
1
|
1
|
3
|
my ($self, $query, $replspec) = @_; |
|
97
|
1
|
|
|
|
|
3
|
my ($row, $col); |
|
98
|
|
|
|
|
|
|
|
|
99
|
1
|
50
|
|
|
|
5
|
die "replace_row_cells: row specifier must be a hash\n" |
|
100
|
|
|
|
|
|
|
if (ref($query) ne 'HASH'); |
|
101
|
|
|
|
|
|
|
|
|
102
|
1
|
50
|
|
|
|
5
|
die "replace_row_cells: replacement specifier must be a hash\n" |
|
103
|
|
|
|
|
|
|
if (ref($replspec) ne 'HASH'); |
|
104
|
|
|
|
|
|
|
|
|
105
|
1
|
|
|
|
|
4
|
$row = $self->_find_row($query); |
|
106
|
|
|
|
|
|
|
return |
|
107
|
1
|
50
|
|
|
|
3
|
if (!defined($row)); |
|
108
|
|
|
|
|
|
|
|
|
109
|
1
|
|
|
|
|
4
|
foreach $col (keys %$replspec) |
|
110
|
|
|
|
|
|
|
{ |
|
111
|
1
|
|
|
|
|
6
|
$self->{value}->[$row]->[$col] = $replspec->{$col}; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
############################################################################### |
|
117
|
|
|
|
|
|
|
### append_to_row_cells method |
|
118
|
|
|
|
|
|
|
############################################################################### |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub append_to_row_cells |
|
121
|
|
|
|
|
|
|
{ |
|
122
|
1
|
|
|
1
|
1
|
3
|
my ($self, $query, $addspec) = @_; |
|
123
|
1
|
|
|
|
|
1
|
my ($row, $col); |
|
124
|
|
|
|
|
|
|
|
|
125
|
1
|
50
|
|
|
|
5
|
die "append_to_row_cells: row specifier must be a hash\n" |
|
126
|
|
|
|
|
|
|
if (ref($query) ne 'HASH'); |
|
127
|
|
|
|
|
|
|
|
|
128
|
1
|
50
|
|
|
|
4
|
die "append_to_row_cells: addition specifier must be a hash\n" |
|
129
|
|
|
|
|
|
|
if (ref($addspec) ne 'HASH'); |
|
130
|
|
|
|
|
|
|
|
|
131
|
1
|
|
|
|
|
3
|
$row = $self->_find_row($query); |
|
132
|
|
|
|
|
|
|
return |
|
133
|
1
|
50
|
|
|
|
4
|
if (!defined($row)); |
|
134
|
|
|
|
|
|
|
|
|
135
|
1
|
|
|
|
|
3
|
foreach $col (keys %$addspec) |
|
136
|
|
|
|
|
|
|
{ |
|
137
|
1
|
50
|
|
|
|
5
|
$self->{value}->[$row]->[$col] .= ' ' |
|
138
|
|
|
|
|
|
|
if ($self->{value}->[$row]->[$col] ne ''); |
|
139
|
1
|
|
|
|
|
6
|
$self->{value}->[$row]->[$col] .= $addspec->{$col}; |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
############################################################################### |
|
145
|
|
|
|
|
|
|
### old methods - to be used for backward compatibility only! |
|
146
|
|
|
|
|
|
|
############################################################################### |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub add_before |
|
149
|
|
|
|
|
|
|
{ |
|
150
|
0
|
|
|
0
|
1
|
|
my ($self, $value) = @_; |
|
151
|
|
|
|
|
|
|
|
|
152
|
0
|
0
|
|
|
|
|
die "add_before: method requires list argument\n" |
|
153
|
|
|
|
|
|
|
if (ref($value) ne 'ARRAY'); |
|
154
|
|
|
|
|
|
|
|
|
155
|
0
|
|
|
|
|
|
die "add_before: invalid argument(s)\n" |
|
156
|
0
|
0
|
0
|
|
|
|
if (@{$value} != 3 |
|
157
|
|
|
|
|
|
|
|| ref($value->[2]) ne 'ARRAY'); |
|
158
|
|
|
|
|
|
|
|
|
159
|
0
|
|
|
|
|
|
return $self->insert_row({ $value->[0] => $value->[1] }, $value->[2]); |
|
160
|
|
|
|
|
|
|
} |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub find |
|
164
|
|
|
|
|
|
|
{ |
|
165
|
0
|
|
|
0
|
1
|
|
my ($self, $value) = @_; |
|
166
|
|
|
|
|
|
|
|
|
167
|
0
|
0
|
|
|
|
|
die "find: method requires list argument\n" |
|
168
|
|
|
|
|
|
|
if (ref($value) ne 'ARRAY'); |
|
169
|
|
|
|
|
|
|
|
|
170
|
0
|
|
|
|
|
|
die "find: invalid argument(s)\n" |
|
171
|
0
|
0
|
|
|
|
|
if (@{$value} != 2); |
|
172
|
|
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
|
return $self->find_row({ $value->[0] => "\b$value->[1]\b" }); |
|
174
|
|
|
|
|
|
|
} |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
sub replace |
|
178
|
|
|
|
|
|
|
{ |
|
179
|
0
|
|
|
0
|
1
|
|
my ($self, $value) = @_; |
|
180
|
|
|
|
|
|
|
|
|
181
|
0
|
0
|
|
|
|
|
die "replace: method requires list argument\n" |
|
182
|
|
|
|
|
|
|
if (ref($value) ne 'ARRAY'); |
|
183
|
|
|
|
|
|
|
|
|
184
|
0
|
|
|
|
|
|
die "replace: invalid argument(s)\n" |
|
185
|
0
|
0
|
|
|
|
|
if (@{$value} != 4); |
|
186
|
|
|
|
|
|
|
|
|
187
|
0
|
|
|
|
|
|
$self->replace_row_cells({ $value->[0] => $value->[1] }, |
|
188
|
|
|
|
|
|
|
{ $value->[2] => $value->[3] }); |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
sub modify |
|
193
|
|
|
|
|
|
|
{ |
|
194
|
0
|
|
|
0
|
1
|
|
my ($self, $value) = @_; |
|
195
|
|
|
|
|
|
|
|
|
196
|
0
|
0
|
|
|
|
|
die "modify: method requires list argument\n" |
|
197
|
|
|
|
|
|
|
if (ref($value) ne 'ARRAY'); |
|
198
|
|
|
|
|
|
|
|
|
199
|
0
|
|
|
|
|
|
die "modify: invalid argument(s)\n" |
|
200
|
0
|
0
|
|
|
|
|
if (@{$value} != 4); |
|
201
|
|
|
|
|
|
|
|
|
202
|
0
|
|
|
|
|
|
$self->append_to_row_cells({ $value->[0] => $value->[1] }, |
|
203
|
|
|
|
|
|
|
{ $value->[2] => $value->[3] }); |
|
204
|
|
|
|
|
|
|
} |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
############################################################################### |
|
208
|
|
|
|
|
|
|
### cleanup and documentation |
|
209
|
|
|
|
|
|
|
############################################################################### |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
1; |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
__END__ |