| 1 | ##-*- Mode: CPerl -*- | ||||||||||||||||||||||||||||
| 2 | ## | ||||||||||||||||||||||||||||
| 3 | ## File: Tie/File/Indexed/Freeze.pm | ||||||||||||||||||||||||||||
| 4 | ## Author: Bryan Jurish <moocow@cpan.org> | ||||||||||||||||||||||||||||
| 5 | ## Description: tied array access to indexed data files: Storable-frozen references (native byte-order) | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | package Tie::File::Indexed::Freeze; | ||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Tie::File::Indexed; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Storable; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | ##====================================================================== | ||||||||||||||||||||||||||||
| 13 | ## Globals | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 2 | our @ISA = qw(Tie::File::Indexed); | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | ##====================================================================== | ||||||||||||||||||||||||||||
| 18 | ## Subclass API: Data I/O: overrides | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | ## $bool = $tfi->writeData($data) | ||||||||||||||||||||||||||||
| 21 | ## + override transparently encodes data using Storable::freeze() | ||||||||||||||||||||||||||||
| 22 | 10 | ▶ | sub writeData { | ||||||||||||||||||||||||||
|
Subroutine
writeData: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 23 | 10 | ▶ | return 1 if (!defined($_[1])); ##-- don't waste space on undef | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | 9 | return $_[0]{datfh}->print( Storable::freeze($_[1]) ); | |||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | ## $data_or_undef = $tfi->readData($length) | ||||||||||||||||||||||||||||
| 28 | ## + override transparently decodes data using Storable::thaw() | ||||||||||||||||||||||||||||
| 29 | 20 | ▶ | sub readData { | ||||||||||||||||||||||||||
|
Subroutine
readData: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||
| 30 | 20 | ▶ | return undef if ($_[1]==0 || !defined(my $buf=$_[0]->SUPER::readData($_[1]))); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$_[1] == 0 or not defined(my $buf = $_[0]->SUPER::readData($_[1]))
MC/DC50%1/2
$_[1] == 0 or not defined(my $buf = $_[0]->SUPER::readData($_[1]))
$_[1] == 0
not defined(my $buf = $_[0]->SUPER::readData($_[1]))
Truth table66%2/3
A or not(B)
A= $_[1] == 0B= not defined(my $buf = $_[0]->SUPER::readData($_[1]))
| |||||||||||||||||||||||||||||
| 31 | 16 | return Storable::thaw($buf); | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 2 | 1; ##-- be happpy | |||||||||||||||||||||||||||