line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
##-*- Mode: CPerl -*- |
2
|
|
|
|
|
|
|
## |
3
|
|
|
|
|
|
|
## File: Tie/File/Indexed/Storable.pm |
4
|
|
|
|
|
|
|
## Author: Bryan Jurish |
5
|
|
|
|
|
|
|
## Description: tied array access to indexed data files: Storable-encoded references (native byte-order) |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Tie::File::Indexed::Storable; |
8
|
2
|
|
|
2
|
|
14759
|
use Tie::File::Indexed; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
50
|
|
9
|
2
|
|
|
2
|
|
1299
|
use Storable; |
|
2
|
|
|
|
|
5228
|
|
|
2
|
|
|
|
|
102
|
|
10
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
242
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
##====================================================================== |
13
|
|
|
|
|
|
|
## Globals |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
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::store_fd() |
22
|
|
|
|
|
|
|
sub writeData { |
23
|
10
|
100
|
|
10
|
1
|
33
|
return 1 if (!defined($_[1])); ##-- don't waste space on undef |
24
|
9
|
|
|
|
|
18
|
return Storable::store_fd($_[1],$_[0]{datfh}); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
## $data_or_undef = $tfi->readData($length) |
28
|
|
|
|
|
|
|
## + override transparently decodes data using Storable::retrieve_fd() |
29
|
|
|
|
|
|
|
sub readData { |
30
|
20
|
100
|
|
20
|
1
|
40
|
return undef if ($_[1]==0); |
31
|
16
|
|
|
|
|
22
|
return Storable::retrieve_fd($_[0]{datfh}); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; ##-- be happpy |