| 1 | # This program is free software: you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||
| 2 | # it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||||||
| 3 | # the Free Software Foundation, either version 2 of the License, or | ||||||||||||||||||||||||||||||||
| 4 | # (at your option) any later version. | ||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||
| 6 | # This program is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||||||
| 7 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||||||
| 8 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||||||||||||||||||||||||||||
| 9 | # GNU General Public License for more details. | ||||||||||||||||||||||||||||||||
| 10 | # | ||||||||||||||||||||||||||||||||
| 11 | # You should have received a copy of the GNU General Public License | ||||||||||||||||||||||||||||||||
| 12 | # along with this file. If not, see <http://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||
| 14 | package VisionDB::Read; | ||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 17 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 18 | 9 | ▶ | use Exporter; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 19 | 9 | ▶ | use File::Basename; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 20 | 9 | ▶ | use Fcntl qw(SEEK_SET SEEK_CUR); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | 9 | our ($VERSION, @ISA); | |||||||||||||||||||||||||||||||
| 23 | 9 | @ISA = qw( Exporter ); | |||||||||||||||||||||||||||||||
| 24 | 9 | $VERSION = 0.04; | |||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||
| 26 | 9 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | 9 | ▶ | END { | ||||||||||||||||||||||||||||||
|
Subroutine
END: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||
| 31 | #--------------------------------------# | ||||||||||||||||||||||||||||||||
| 32 | # Open DB segment from basename and # | ||||||||||||||||||||||||||||||||
| 33 | # segment number # | ||||||||||||||||||||||||||||||||
| 34 | # in: $basename, $seg # | ||||||||||||||||||||||||||||||||
| 35 | # out: $handle # | ||||||||||||||||||||||||||||||||
| 36 | # die if error # | ||||||||||||||||||||||||||||||||
| 37 | #--------------------------------------# | ||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | 51 | ▶ | sub _open_db_segment { | ||||||||||||||||||||||||||||||
|
Subroutine
_open_db_segment: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | 51 | my ($basename, $segment) = @_; | |||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||
| 43 | 51 | my $fh; | |||||||||||||||||||||||||||||||
| 44 | 51 | ▶ | my $fn = $basename.(($segment) ? ".d".sprintf("%02d", $segment) : ''); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | 51 | ▶ | open($fh, "<$fn") || die "open error ($!)\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 47 | 51 | ▶ | binmode $fh || die "cannot set binmode ($!)\n"; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$fh || die("cannot set binmode ($!)\n")
MC/DC0%0/1
$fh || die("cannot set binmode ($!)\n")
$fh
Truth table50%1/2
A
A= $fh
| |||||||||||||||||||||||||||||||||
| 48 | 51 | return $fh; | |||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | #-------------------------------------# | ||||||||||||||||||||||||||||||||
| 52 | # Destroy internal vars # | ||||||||||||||||||||||||||||||||
| 53 | # in: - # | ||||||||||||||||||||||||||||||||
| 54 | # out: - # | ||||||||||||||||||||||||||||||||
| 55 | #-------------------------------------# | ||||||||||||||||||||||||||||||||
| 56 | 28 | ▶ | sub _free_vars { | ||||||||||||||||||||||||||||||
|
Subroutine
_free_vars: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||
| 58 | 28 | my $self = shift; | |||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | 28 | undef $self->{_err}; | |||||||||||||||||||||||||||||||
| 61 | 28 | undef $self->{_db_fname}; | |||||||||||||||||||||||||||||||
| 62 | 28 | undef $self->{_db_fpath}; | |||||||||||||||||||||||||||||||
| 63 | 28 | undef $self->{_fh}; | |||||||||||||||||||||||||||||||
| 64 | 28 | undef $self->{_rec_tot}; | |||||||||||||||||||||||||||||||
| 65 | 28 | undef $self->{_rec_cur}; | |||||||||||||||||||||||||||||||
| 66 | 28 | undef $self->{_version}; | |||||||||||||||||||||||||||||||
| 67 | 28 | undef $self->{_data_hlen}; | |||||||||||||||||||||||||||||||
| 68 | 28 | undef $self->{_data_cur}; | |||||||||||||||||||||||||||||||
| 69 | 28 | undef $self->{_seg_tot}; | |||||||||||||||||||||||||||||||
| 70 | 28 | undef $self->{_seg_cur}; | |||||||||||||||||||||||||||||||
| 71 | 28 | undef $self->{_seg_size}; | |||||||||||||||||||||||||||||||
| 72 | 28 | undef $self->{_data_start}; | |||||||||||||||||||||||||||||||
| 73 | 28 | undef $self->{_data_end}; | |||||||||||||||||||||||||||||||
| 74 | 28 | undef $self->{_data_keys}; | |||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||
| 77 | #--------------------------------------# | ||||||||||||||||||||||||||||||||
| 78 | # Read next valid record and increment # | ||||||||||||||||||||||||||||||||
| 79 | # ptr to the next one # | ||||||||||||||||||||||||||||||||
| 80 | # in: $objref # | ||||||||||||||||||||||||||||||||
| 81 | # out: $data_arrayref # | ||||||||||||||||||||||||||||||||
| 82 | # die if error # | ||||||||||||||||||||||||||||||||
| 83 | #--------------------------------------# | ||||||||||||||||||||||||||||||||
| 84 | 59732 | ▶ | sub _read_next { | ||||||||||||||||||||||||||||||
|
Subroutine
_read_next: called CC=21 SCAR=30.8
| |||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||
| 86 | 59732 | my $self = shift; | |||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||
| 88 | 59732 | ▶ | $self->{_rec_cur} >= 0 || die "invalid negatve record number\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||
| 90 | 59730 | my $fh = $self->{_fh}; | |||||||||||||||||||||||||||||||
| 91 | 59730 | my $dseg = $self->{_seg_cur}; | |||||||||||||||||||||||||||||||
| 92 | 59730 | my $dptr = $self->{_data_cur}; | |||||||||||||||||||||||||||||||
| 93 | 59730 | my $data; | |||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||
| 95 | 59730 | my $del = 0; | |||||||||||||||||||||||||||||||
| 96 | 59730 | ▶ | do { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 97 | 60000 | my $buf; | |||||||||||||||||||||||||||||||
| 98 | 60000 | my ($h1, $h2) = (0, 0); | |||||||||||||||||||||||||||||||
| 99 | 60000 | ▶ | $self->{_seg_size}*$dseg + $dptr < $self->{_data_end} || die "record ptr beyond EOF\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 100 | 60000 | ▶ | (my $r = read($fh, $buf, $self->{_data_hlen})) || die "read error ($!)\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 101 | HDR1: { | ||||||||||||||||||||||||||||||||
| 102 | 60000 | ▶ | if ($self->{_version} == 4) { ($h1, $h2) = unpack('n2', $buf) if ($r == $self->{_data_hlen}); last HDR1 } | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 103 | 30000 | ▶ | if ($self->{_version} == 5) { ($h1, $h2, $del) = unpack('N2C', $buf) if ($r == $self->{_data_hlen}); last HDR1 } | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||
| 105 | 60000 | ▶ | if ($h1 == 0) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 106 | 15 | $dseg++; | |||||||||||||||||||||||||||||||
| 107 | 15 | $dptr = $self->{_data_start}; | |||||||||||||||||||||||||||||||
| 108 | 15 | ▶ | close $fh if ($fh != $self->{_fh}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 109 | 15 | $fh = _open_db_segment($self->{_db_fpath}.$self->{_db_fname}, $dseg); | |||||||||||||||||||||||||||||||
| 110 | 15 | ▶ | seek($fh, $self->{_data_start}, SEEK_SET) || die "seek error ($!)\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 111 | 15 | ▶ | read($fh, $buf, $self->{_data_hlen}) == $self->{_data_hlen} || die "read error ($!)\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 112 | HDR2: { | ||||||||||||||||||||||||||||||||
| 113 | 15 | ▶ | if ($self->{_version} == 4) { ($h1, $h2) = unpack('n2', $buf); last HDR2 } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 114 | 9 | ▶ | if ($self->{_version} == 5) { ($h1, $h2, $del) = unpack('N2C', $buf); last HDR2 } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||
| 117 | 60000 | ▶ | $del = ($h2 == 0) if ($self->{_version} == 4); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 118 | 60000 | ▶ | if ($del) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 119 | 270 | ▶ | seek($fh, $h1, SEEK_CUR) || die "seek error ($!)\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 120 | } else { | ||||||||||||||||||||||||||||||||
| 121 | 59730 | ▶ | read($fh, $buf, $h1) == $h1 || die "read error ($!)\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 122 | 59730 | $data = [$buf, $h1]; | |||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||
| 124 | 60000 | $dptr += $self->{_data_hlen}+$h1; | |||||||||||||||||||||||||||||||
| 125 | 60000 | undef $buf; | |||||||||||||||||||||||||||||||
| 126 | } until ($del == 0); | ||||||||||||||||||||||||||||||||
| 127 | 59730 | ▶ | close $self->{_fh} if ($fh != $self->{_fh}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 128 | 59730 | $self->{_fh} = $fh; | |||||||||||||||||||||||||||||||
| 129 | 59730 | $self->{_seg_cur} = $dseg; | |||||||||||||||||||||||||||||||
| 130 | 59730 | $self->{_data_cur} = $dptr; | |||||||||||||||||||||||||||||||
| 131 | 59730 | $self->{_rec_cur}++; | |||||||||||||||||||||||||||||||
| 132 | 59730 | ▶ | $self->{_rec_cur} = -1 if ($self->{_rec_cur} >= $self->{_rec_tot}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||
| 134 | 59730 | return $data; | |||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||
| 137 | ################# | ||||||||||||||||||||||||||||||||
| 138 | ## constructor ## | ||||||||||||||||||||||||||||||||
| 139 | ################# | ||||||||||||||||||||||||||||||||
| 140 | 14 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=25 SCAR=34.5
Pod
documented
| |||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||
| 142 | 14 | my ($class, $filename) = @_; | |||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||
| 144 | 14 | my $self = { | |||||||||||||||||||||||||||||||
| 145 | _err => 0, | ||||||||||||||||||||||||||||||||
| 146 | _db_fname => undef, | ||||||||||||||||||||||||||||||||
| 147 | _db_fpath => undef, | ||||||||||||||||||||||||||||||||
| 148 | _fh => undef, | ||||||||||||||||||||||||||||||||
| 149 | _rec_tot => undef, | ||||||||||||||||||||||||||||||||
| 150 | _rec_cur => undef, | ||||||||||||||||||||||||||||||||
| 151 | _version => undef, | ||||||||||||||||||||||||||||||||
| 152 | _data_hlen => undef, | ||||||||||||||||||||||||||||||||
| 153 | _data_cur => undef, | ||||||||||||||||||||||||||||||||
| 154 | _seg_tot => undef, | ||||||||||||||||||||||||||||||||
| 155 | _seg_cur => undef, | ||||||||||||||||||||||||||||||||
| 156 | _seg_size => undef, | ||||||||||||||||||||||||||||||||
| 157 | _data_start => undef, | ||||||||||||||||||||||||||||||||
| 158 | _data_end => undef, | ||||||||||||||||||||||||||||||||
| 159 | _data_keys => undef, | ||||||||||||||||||||||||||||||||
| 160 | }; | ||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||
| 162 | 14 | eval { | |||||||||||||||||||||||||||||||
| 163 | 14 | my ($buf, $hdr_kcnt, $hdr_zip, $hdr_enc); | |||||||||||||||||||||||||||||||
| 164 | 14 | ▶ | (($self->{_db_fname}, $self->{_db_fpath}) = fileparse($filename)) || die "cannot parse filename\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 165 | # open file, segment 0 | ||||||||||||||||||||||||||||||||
| 166 | 14 | $self->{_fh} = _open_db_segment($self->{_db_fpath}.$self->{_db_fname}, 0); | |||||||||||||||||||||||||||||||
| 167 | # read 1st 512 bytes (1 block) | ||||||||||||||||||||||||||||||||
| 168 | 14 | ▶ | read($self->{_fh}, $buf, 512) == 512 || die "read failed ($!)\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 169 | # check file type and version | ||||||||||||||||||||||||||||||||
| 170 | 14 | (my $t, $self->{_version}) = unpack('Nn', $buf); | |||||||||||||||||||||||||||||||
| 171 | 14 | ▶ | $t == 0x10121419 || die "wrong file type\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 172 | # acquire data area ptr | ||||||||||||||||||||||||||||||||
| 173 | DATA_PTR: { | ||||||||||||||||||||||||||||||||
| 174 | 14 | ▶ | if ($self->{_version} == 4) { $self->{_data_start} = unpack('N', substr($buf, 0x001e, 4)); last DATA_PTR; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 175 | 7 | ▶ | if ($self->{_version} == 5) { $self->{_data_start} = unpack('N', substr($buf, 0x0022, 4)); last DATA_PTR; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 176 | 0 | die "unsupported file version\n"; | |||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||
| 178 | # read the rest of header | ||||||||||||||||||||||||||||||||
| 179 | 14 | ▶ | (read($self->{_fh}, $buf, $self->{_data_start}-512, 512) == $self->{_data_start}-512 || die "read failed ($!)\n") if ($self->{_data_start} > 0); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
$self->{'_data_start'} > 0 && (read($self->{'_fh'}, $buf, $self->{'_data_start'} - 512, 512) == $self->{'_data_start'} - 512 || die("read failed ($!)\n"))
read($self->{"_fh"}, $buf, $self->{"_data_start"} - 512, 512) == $self->{"_data_start"} - 512 or die "read failed ($!)\n"
MC/DC0%0/2
$self->{'_data_start'} > 0 && (read($self->{'_fh'}, $buf, $self->{'_data_start'} - 512, 512) == $self->{'_data_start'} - 512 || die("read failed ($!)\n"))
$self->{'_data_start'} > 0
read($self->{"_fh"}, $buf, $self->{"_data_start"} - 512, 512) == $self->{"_data_start"} - 512
Truth table33%1/3
A && B
A= $self->{'_data_start'} > 0B= read($self->{"_fh"}, $buf, $self->{"_data_start"} - 512, 512) == $self->{"_data_start"} - 512
| |||||||||||||||||||||||||||||||||
| 180 | # acquire some more infos from header | ||||||||||||||||||||||||||||||||
| 181 | READ_HDR: { | ||||||||||||||||||||||||||||||||
| 182 | 14 | ▶ | if ($self->{_version} == 4) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 183 | 7 | $self->{_data_hlen} = unpack('n', substr($buf, 0x0054, 2)); | |||||||||||||||||||||||||||||||
| 184 | 7 | $self->{_seg_tot} = unpack('n', substr($buf, 0x0062, 2))+1; | |||||||||||||||||||||||||||||||
| 185 | 7 | $self->{_seg_size} = unpack('N', substr($buf, 0x0066, 4)); | |||||||||||||||||||||||||||||||
| 186 | 7 | $self->{_data_end} = unpack('N', substr($buf, 0x0018, 4)) + unpack('n', substr($buf, 0x001c, 2))*$self->{_seg_size}; | |||||||||||||||||||||||||||||||
| 187 | 7 | $self->{_rec_tot} = unpack('N', substr($buf, 0x0034, 4)); | |||||||||||||||||||||||||||||||
| 188 | 7 | $hdr_kcnt = unpack('C', substr($buf, 0x0078, 1)); | |||||||||||||||||||||||||||||||
| 189 | 7 | $hdr_zip = unpack('C', substr($buf, 0x0079, 1)); | |||||||||||||||||||||||||||||||
| 190 | 7 | $hdr_enc = unpack('C', substr($buf, 0x007a, 1)); | |||||||||||||||||||||||||||||||
| 191 | # get keys data | ||||||||||||||||||||||||||||||||
| 192 | 7 | ▶ | $self->{_data_keys} = [] if ($hdr_kcnt > 0); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 193 | 7 | for my $i (0 .. $hdr_kcnt-1) { | |||||||||||||||||||||||||||||||
| 194 | 13 | my $key_segs = unpack('C', substr($buf, 0x00a0+$i*(11+16*3)+7, 1)); | |||||||||||||||||||||||||||||||
| 195 | 13 | ▶ | $self->{_data_keys}->[$i] = [] if ($key_segs > 0); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 196 | 13 | for my $j (0 .. $key_segs-1) { | |||||||||||||||||||||||||||||||
| 197 | 19 | $self->{_data_keys}->[$i]->[$j] = [ | |||||||||||||||||||||||||||||||
| 198 | unpack('C', substr($buf, 0x00a0+$i*(11+16*3)+11+$j*3+0, 1)), # size | ||||||||||||||||||||||||||||||||
| 199 | unpack('n', substr($buf, 0x00a0+$i*(11+16*3)+11+$j*3+1, 2)) # offset | ||||||||||||||||||||||||||||||||
| 200 | ]; | ||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||
| 203 | 7 | last READ_HDR; | |||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||
| 205 | 7 | ▶ | if ($self->{_version} == 5) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 206 | 7 | $self->{_data_hlen} = unpack('n', substr($buf, 0x0068, 2)); | |||||||||||||||||||||||||||||||
| 207 | 7 | $self->{_seg_tot} = unpack('n', substr($buf, 0x0076, 2))+1; | |||||||||||||||||||||||||||||||
| 208 | 7 | $self->{_seg_size} = unpack('N', substr($buf, 0x007a, 4)); | |||||||||||||||||||||||||||||||
| 209 | 7 | $self->{_data_end} = unpack('N', substr($buf, 0x001c, 4)) + unpack('n', substr($buf, 0x0020, 2))*$self->{_seg_size}; | |||||||||||||||||||||||||||||||
| 210 | 7 | $self->{_rec_tot} = unpack('N', substr($buf, 0x003e, 4)); | |||||||||||||||||||||||||||||||
| 211 | 7 | $hdr_kcnt = unpack('C', substr($buf, 0x009d, 1)); | |||||||||||||||||||||||||||||||
| 212 | 7 | $hdr_zip = unpack('C', substr($buf, 0x009e, 1)); | |||||||||||||||||||||||||||||||
| 213 | 7 | $hdr_enc = unpack('C', substr($buf, 0x009f, 1)); | |||||||||||||||||||||||||||||||
| 214 | # get keys data | ||||||||||||||||||||||||||||||||
| 215 | 7 | ▶ | $self->{_data_keys} = [] if ($hdr_kcnt > 0); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 216 | 7 | for my $i (0 .. $hdr_kcnt-1) { | |||||||||||||||||||||||||||||||
| 217 | 13 | my $key_segs = unpack('C', substr($buf, 0x00c2+$i*(10+16*6)+7, 1)); | |||||||||||||||||||||||||||||||
| 218 | 13 | ▶ | $self->{_data_keys}->[$i] = [] if ($key_segs > 0); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 219 | 13 | for my $j (0 .. $key_segs-1) { | |||||||||||||||||||||||||||||||
| 220 | 19 | $self->{_data_keys}->[$i]->[$j] = [ | |||||||||||||||||||||||||||||||
| 221 | unpack('n', substr($buf, 0x00c2+$i*(10+16*6)+10+$j*6+0, 2)), # size | ||||||||||||||||||||||||||||||||
| 222 | unpack('N', substr($buf, 0x00c2+$i*(10+16*6)+10+$j*6+2, 4)) # offset | ||||||||||||||||||||||||||||||||
| 223 | ]; | ||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||
| 226 | 7 | last READ_HDR; | |||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||
| 229 | # check for unsupported archives | ||||||||||||||||||||||||||||||||
| 230 | 14 | ▶ | $hdr_zip == 0 || die "compressed DBs are not supported (yet)\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 231 | 14 | ▶ | $hdr_enc == 0 || die "encrypted DBs are not supported (yet)\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 232 | # check if all segments files are open-able | ||||||||||||||||||||||||||||||||
| 233 | 14 | ▶ | close(_open_db_segment($self->{_db_fpath}.$self->{_db_fname}, $_) || die "some data files are unavailable\n") for (1 .. $self->{_seg_tot}-1); | ||||||||||||||||||||||||||||||
|
Condition50%1/2
_open_db_segment($self->{'_db_fpath'} . $self->{'_db_fname'}, $_) || die("some data files are unavailable\n")
MC/DC0%0/1
_open_db_segment($self->{'_db_fpath'} . $self->{'_db_fname'}, $_) || die("some data files are unavailable\n")
_open_db_segment($self->{'_db_fpath'} . $self->{'_db_fname'}, $_)
Truth table50%1/2
A
A= _open_db_segment($self->{'_db_fpath'} . $self->{'_db_fname'}, $_)
| |||||||||||||||||||||||||||||||||
| 234 | # finalize init | ||||||||||||||||||||||||||||||||
| 235 | 14 | ▶ | $self->{_rec_cur} = ($self->{_data_start} > 0) ? 0 : -1; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 236 | 14 | $self->{_seg_cur} = 0; | |||||||||||||||||||||||||||||||
| 237 | 14 | $self->{_data_cur} = $self->{_data_start}; | |||||||||||||||||||||||||||||||
| 238 | }; | ||||||||||||||||||||||||||||||||
| 239 | 14 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | close $self->{_fh} if ($self->{_fh}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 241 | 0 | chomp $@; | |||||||||||||||||||||||||||||||
| 242 | 0 | $self->{_err} = @_; | |||||||||||||||||||||||||||||||
| 243 | #Carp::carp "Unable to initialize DB: $@"; | ||||||||||||||||||||||||||||||||
| 244 | 0 | warn "\n*** $@\n"; | |||||||||||||||||||||||||||||||
| 245 | 0 | return undef; | |||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||
| 248 | 14 | bless ($self, $class); | |||||||||||||||||||||||||||||||
| 249 | 14 | return $self; | |||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||
| 252 | ################ | ||||||||||||||||||||||||||||||||
| 253 | ## destructor ## | ||||||||||||||||||||||||||||||||
| 254 | ################ | ||||||||||||||||||||||||||||||||
| 255 | 14 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||
| 257 | 14 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||
| 259 | 14 | _free_vars($self); | |||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||
| 262 | ############################### | ||||||||||||||||||||||||||||||||
| 263 | # Free object, discard all # | ||||||||||||||||||||||||||||||||
| 264 | # in: - # | ||||||||||||||||||||||||||||||||
| 265 | # out: - # | ||||||||||||||||||||||||||||||||
| 266 | ############################### | ||||||||||||||||||||||||||||||||
| 267 | 14 | ▶ | sub free { | ||||||||||||||||||||||||||||||
|
Subroutine
free: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||
| 269 | 14 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||
| 271 | 14 | close($self->{_fh}); | |||||||||||||||||||||||||||||||
| 272 | 14 | _free_vars($self); | |||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||
| 275 | ################################### | ||||||||||||||||||||||||||||||||
| 276 | # get records counter # | ||||||||||||||||||||||||||||||||
| 277 | # in: - # | ||||||||||||||||||||||||||||||||
| 278 | # out: $scalar (record counter) # | ||||||||||||||||||||||||||||||||
| 279 | ################################### | ||||||||||||||||||||||||||||||||
| 280 | 6 | ▶ | sub records { | ||||||||||||||||||||||||||||||
|
Subroutine
records: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||
| 282 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||
| 283 | 6 | return $self->{_rec_tot}; | |||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||
| 286 | #################################### | ||||||||||||||||||||||||||||||||
| 287 | # get/set curr.record ptr # | ||||||||||||||||||||||||||||||||
| 288 | # in: $recno # | ||||||||||||||||||||||||||||||||
| 289 | # neg.values count from end # | ||||||||||||||||||||||||||||||||
| 290 | # out: $scalar (curr.record) # | ||||||||||||||||||||||||||||||||
| 291 | # undef if error # | ||||||||||||||||||||||||||||||||
| 292 | #################################### | ||||||||||||||||||||||||||||||||
| 293 | 32 | ▶ | sub recno { | ||||||||||||||||||||||||||||||
|
Subroutine
recno: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||
| 295 | 32 | my $self = shift; | |||||||||||||||||||||||||||||||
| 296 | 32 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 297 | 16 | my $rec = shift; | |||||||||||||||||||||||||||||||
| 298 | 16 | ▶ | $rec += $self->{_rec_tot} if ($rec < 0); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 299 | 16 | eval { | |||||||||||||||||||||||||||||||
| 300 | 16 | ▶ | $rec >= 0 || die "requested record is below BOF\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 301 | 12 | ▶ | $rec < $self->{_rec_tot} || die "requested record is beyond EOF\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 302 | 8 | ▶ | $self->reset if ($rec < $self->{_rec_cur}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 303 | 8 | ▶ | while ($rec > $self->{_rec_cur}) { _read_next($self) } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 304 | #while ($rec > $self->{_rec_cur}) { (my $d = _read_next($self)) || return undef; undef $d } | ||||||||||||||||||||||||||||||||
| 305 | }; | ||||||||||||||||||||||||||||||||
| 306 | 16 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 307 | 8 | chomp $@; | |||||||||||||||||||||||||||||||
| 308 | 8 | $self->{_err} = $@; | |||||||||||||||||||||||||||||||
| 309 | #Carp::carp "Unable to set recno: $@"; | ||||||||||||||||||||||||||||||||
| 310 | 8 | return undef; | |||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||
| 313 | 24 | return $self->{_rec_cur}; | |||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||
| 316 | ################################## | ||||||||||||||||||||||||||||||||
| 317 | # reset records counter # | ||||||||||||||||||||||||||||||||
| 318 | # in: - # | ||||||||||||||||||||||||||||||||
| 319 | # out: $scalar (curr.record=0) # | ||||||||||||||||||||||||||||||||
| 320 | # undef if error # | ||||||||||||||||||||||||||||||||
| 321 | ################################## | ||||||||||||||||||||||||||||||||
| 322 | 8 | ▶ | sub reset { | ||||||||||||||||||||||||||||||
|
Subroutine
reset: called CC=8 SCAR=21.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||
| 324 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||
| 326 | 8 | my $fh = $self->{_fh}; | |||||||||||||||||||||||||||||||
| 327 | 8 | eval { | |||||||||||||||||||||||||||||||
| 328 | 8 | ▶ | $self->{_data_start} > 0 || die "cannot reset on an empty DB\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 329 | 6 | ▶ | $fh = _open_db_segment($self->{_db_fpath}.$self->{_db_fname}, 0) if ($self->{_seg_cur} != 0); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 330 | 6 | ▶ | (seek($fh, $self->{_data_start}, SEEK_SET) || die "seek error ($!)\n") if ($self->{_data_start} > 0); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
$self->{'_data_start'} > 0 && (seek($fh, $self->{'_data_start'}, 0) || die("seek error ($!)\n"))
seek $fh, $self->{"_data_start"}, 0 or die "seek error ($!)\n"
MC/DC0%0/2
$self->{'_data_start'} > 0 && (seek($fh, $self->{'_data_start'}, 0) || die("seek error ($!)\n"))
$self->{'_data_start'} > 0
seek $fh, $self->{"_data_start"}, 0
Truth table0%0/3
A && B
A= $self->{'_data_start'} > 0B= seek $fh, $self->{"_data_start"}, 0
| |||||||||||||||||||||||||||||||||
| 331 | }; | ||||||||||||||||||||||||||||||||
| 332 | 8 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 333 | 2 | chomp $@; | |||||||||||||||||||||||||||||||
| 334 | 2 | $self->{_err} = $@; | |||||||||||||||||||||||||||||||
| 335 | #Carp::carp "Unable to reset recno: $@"; | ||||||||||||||||||||||||||||||||
| 336 | 2 | return undef; | |||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||
| 338 | 6 | ▶ | close $self->{_fh} if ($fh != $self->{_fh}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 339 | 6 | $self->{_fh} = $fh; | |||||||||||||||||||||||||||||||
| 340 | 6 | ▶ | $self->{_rec_cur} = ($self->{_data_start} > 0) ? 0 : -1; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 341 | 6 | $self->{_seg_cur} = 0; | |||||||||||||||||||||||||||||||
| 342 | 6 | $self->{_data_cur} = $self->{_data_start}; | |||||||||||||||||||||||||||||||
| 343 | 6 | return 0; | |||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||
| 346 | ################################ | ||||||||||||||||||||||||||||||||
| 347 | # get next record # | ||||||||||||||||||||||||||||||||
| 348 | # in: - # | ||||||||||||||||||||||||||||||||
| 349 | # out: $record_objref # | ||||||||||||||||||||||||||||||||
| 350 | # undef if error # | ||||||||||||||||||||||||||||||||
| 351 | ################################ | ||||||||||||||||||||||||||||||||
| 352 | 19920 | ▶ | sub next { | ||||||||||||||||||||||||||||||
|
Subroutine
next: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||
| 354 | 19920 | my $self = shift; | |||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||
| 356 | 19920 | my $rec_ref; | |||||||||||||||||||||||||||||||
| 357 | 19920 | eval { | |||||||||||||||||||||||||||||||
| 358 | 19920 | ▶ | $self->{_data_start} > 0 || die "cannot next on an empty DB\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 359 | 19918 | my $data_ref = _read_next($self); | |||||||||||||||||||||||||||||||
| 360 | 19916 | $rec_ref = VisionDB::Read::record->new($data_ref); | |||||||||||||||||||||||||||||||
| 361 | 19916 | undef $data_ref; | |||||||||||||||||||||||||||||||
| 362 | }; | ||||||||||||||||||||||||||||||||
| 363 | 19920 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 364 | 4 | chomp $@; | |||||||||||||||||||||||||||||||
| 365 | 4 | $self->{_err} = $@; | |||||||||||||||||||||||||||||||
| 366 | #Carp::carp "Unable to read next record: $@"; | ||||||||||||||||||||||||||||||||
| 367 | 4 | return undef; | |||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||
| 369 | 19916 | return $rec_ref; | |||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||
| 372 | ############################### | ||||||||||||||||||||||||||||||||
| 373 | # get DB base name # | ||||||||||||||||||||||||||||||||
| 374 | # in: - # | ||||||||||||||||||||||||||||||||
| 375 | # out: $scalar (base name) # | ||||||||||||||||||||||||||||||||
| 376 | ############################### | ||||||||||||||||||||||||||||||||
| 377 | 2 | ▶ | sub filename { | ||||||||||||||||||||||||||||||
|
Subroutine
filename: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||
| 379 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||
| 380 | 2 | return $self->{_db_fname}; | |||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||
| 383 | ############################### | ||||||||||||||||||||||||||||||||
| 384 | # get version number # | ||||||||||||||||||||||||||||||||
| 385 | # in: - # | ||||||||||||||||||||||||||||||||
| 386 | # out: $scalar (version) # | ||||||||||||||||||||||||||||||||
| 387 | ############################### | ||||||||||||||||||||||||||||||||
| 388 | 20 | ▶ | sub version { | ||||||||||||||||||||||||||||||
|
Subroutine
version: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||
| 390 | 20 | my $self = shift; | |||||||||||||||||||||||||||||||
| 391 | 20 | return $self->{_version}; | |||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||
| 394 | ############################### | ||||||||||||||||||||||||||||||||
| 395 | # get error number # | ||||||||||||||||||||||||||||||||
| 396 | # in: - # | ||||||||||||||||||||||||||||||||
| 397 | # out: $scalar (error num.) # | ||||||||||||||||||||||||||||||||
| 398 | ############################### | ||||||||||||||||||||||||||||||||
| 399 | 12 | ▶ | sub error { | ||||||||||||||||||||||||||||||
|
Subroutine
error: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||
| 401 | 12 | my $self = shift; | |||||||||||||||||||||||||||||||
| 402 | 12 | return $self->{_err}; | |||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||
| 405 | ################################ | ||||||||||||||||||||||||||||||||
| 406 | # get fields structure # | ||||||||||||||||||||||||||||||||
| 407 | # in: - # | ||||||||||||||||||||||||||||||||
| 408 | # out: $array (fields array) # | ||||||||||||||||||||||||||||||||
| 409 | ################################ | ||||||||||||||||||||||||||||||||
| 410 | 4 | ▶ | sub fields { | ||||||||||||||||||||||||||||||
|
Subroutine
fields: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||
| 412 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||
| 414 | 4 | my @f = (); | |||||||||||||||||||||||||||||||
| 415 | 4 | foreach my $key (@{$self->{_data_keys}}) { # each key | |||||||||||||||||||||||||||||||
| 416 | 8 | foreach my $seg (@$key) { # each segment | |||||||||||||||||||||||||||||||
| 417 | 12 | my ($len, $off) = @$seg; | |||||||||||||||||||||||||||||||
| 418 | 12 | ▶ | push(@f, $off) if (!exists { map { $_ => 1 } @f }->{$off}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 419 | 12 | ▶ | push(@f, $off+$len) if (!exists { map { $_ => 1 } @f }->{($off+$len)}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||
| 422 | 4 | return sort {$a <=> $b} @f; | |||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||
| 425 | ############################################# | ||||||||||||||||||||||||||||||||
| 426 | # sub-package VisionDB::Read::record # | ||||||||||||||||||||||||||||||||
| 427 | # # | ||||||||||||||||||||||||||||||||
| 428 | # just a data container... # | ||||||||||||||||||||||||||||||||
| 429 | ############################################# | ||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||
| 431 | package VisionDB::Read::record; | ||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||
| 433 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||
| 435 | 9 | our (@ISA, @EXPORT, @EXPORT_OK); | |||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||
| 437 | ################# | ||||||||||||||||||||||||||||||||
| 438 | ## constructor ## | ||||||||||||||||||||||||||||||||
| 439 | ################# | ||||||||||||||||||||||||||||||||
| 440 | 19916 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||
| 442 | 19916 | my ($class, $dataref) = @_; | |||||||||||||||||||||||||||||||
| 443 | 19916 | my $self = { | |||||||||||||||||||||||||||||||
| 444 | _data => $dataref->[0], | ||||||||||||||||||||||||||||||||
| 445 | _len => $dataref->[1], | ||||||||||||||||||||||||||||||||
| 446 | }; | ||||||||||||||||||||||||||||||||
| 447 | 19916 | bless($self, $class); | |||||||||||||||||||||||||||||||
| 448 | 19916 | return $self; | |||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||
| 451 | ################ | ||||||||||||||||||||||||||||||||
| 452 | ## destructor ## | ||||||||||||||||||||||||||||||||
| 453 | ################ | ||||||||||||||||||||||||||||||||
| 454 | 19916 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||
| 456 | 19916 | my $self = shift; | |||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||
| 458 | 19916 | undef $self->{_data}; | |||||||||||||||||||||||||||||||
| 459 | 19916 | undef $self->{_len}; | |||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||
| 462 | ############################### | ||||||||||||||||||||||||||||||||
| 463 | # Free object, discard all # | ||||||||||||||||||||||||||||||||
| 464 | # in: - # | ||||||||||||||||||||||||||||||||
| 465 | # out: - # | ||||||||||||||||||||||||||||||||
| 466 | ############################### | ||||||||||||||||||||||||||||||||
| 467 | 19910 | ▶ | sub dispose { | ||||||||||||||||||||||||||||||
|
Subroutine
dispose: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||
| 469 | 19910 | my $self = shift; | |||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||
| 471 | 19910 | undef $self->{_data}; | |||||||||||||||||||||||||||||||
| 472 | 19910 | undef $self->{_len}; | |||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||
| 475 | ############################### | ||||||||||||||||||||||||||||||||
| 476 | # Get data ref # | ||||||||||||||||||||||||||||||||
| 477 | # in: - # | ||||||||||||||||||||||||||||||||
| 478 | # out: $data_ref # | ||||||||||||||||||||||||||||||||
| 479 | ############################### | ||||||||||||||||||||||||||||||||
| 480 | 6 | ▶ | sub data { | ||||||||||||||||||||||||||||||
|
Subroutine
data: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||
| 482 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||
| 484 | 6 | return $self->{_data}; | |||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||
| 487 | ############################### | ||||||||||||||||||||||||||||||||
| 488 | # Get data len # | ||||||||||||||||||||||||||||||||
| 489 | # in: - # | ||||||||||||||||||||||||||||||||
| 490 | # out: $data_len # | ||||||||||||||||||||||||||||||||
| 491 | ############################### | ||||||||||||||||||||||||||||||||
| 492 | 0 | ▶ | sub size { | ||||||||||||||||||||||||||||||
|
Subroutine
size: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||
| 494 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||
| 496 | 0 | return $self->{_len}; | |||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||
| 499 | 9 | 1; | |||||||||||||||||||||||||||||||
| 500 | __END__ | ||||||||||||||||||||||||||||||||