TT/Persistent.pm

filter: Statementstmt 17.7% 37 / 208 Branchbran 0.0% 0 / 112 Conditioncond 0.0% 0 / 93 MC/DCmcdc 0.0% 0 / 50 Subroutinesub 26.5% 13 / 49 Podpod 62.8% 22 / 35 totaltotal 13.1% 72 / 547 CC 91 SCAR 39.2
CC
91
Cov
9%
savePerlRef
182.0
loadPerlRef
132.0
loadPerlString
90.0
CRAP 50.4
« TT/Dict/JSON.pm ↑ Summary TT/IO.pm »
1 ## -*- Mode: CPerl -*-
2 ##
3 ## File: Lingua::TT::Persistent.pm
4 ## Author: Bryan Jurish <TT/IO.pm>
5 ## Description: abstract class for persistent & configurable objects
6  
7 package Lingua::TT::Persistent;
8 #use Lingua::TT::Logger;
9 1 ▶use Lingua::TT::Unify;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Lingua::TT::IO;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Storable;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use overload;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 ##==============================================================================
20 ## Globals
21 ##==============================================================================
22  
23 1 our @ISA = qw();
24  
25 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 *isa = \&UNIVERSAL::isa;
27 1 *can = \&UNIVERSAL::can;
28 }
29  
30 ##==============================================================================
31 ## Constructors etc.
32 ##==============================================================================
33  
34 ## $obj = CLASS_OR_OBJ->new(%args)
35 ## + object structure: (assumed to be HASH ref, other references should be OK
36 ## with appropritate method overrides
37 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
38 0 my $that = shift;
39 0 ▶ return bless {@_}, ref($that)||$that;
Condition0%0/3
ref $that || $that
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table0%0/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
40 }
41  
42 ## $obj = $obj->clone()
43 ## + deep clone
44 0 ▶sub clone {
Subroutine clone: not called CC=1 SCAR=6.9
Pod documented
45 #storable_push({Eval=>1,Deparse=>1});
46 0 my $clone = Storable::dclone($_[0]);
47 #storable_pop();
48 0 return $clone;
49 }
50  
51 ## @STORABLE_STACK
52 ## + state variables (HASH-refs) for Storable module
53 1 our @STORABLE_STACK = qw();
54  
55 ## \%vars = CLASS_OR_OBJ->storable_push()
56 ## \%vars = CLASS_OR_OBJ->storable_push(\%vars)
57 ## + pushes old Storable state vars onto @STORABLE_STACK, & sets current \%vars
58 0 ▶sub storable_push {
Subroutine storable_push: not called CC=3 SCAR=18.7
Pod undocumented
59 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
60 0 my $vars = shift;
61 0 ▶ $vars = {Deparse=>1,Eval=>1} if (!$vars);
Branch: 1 branch
BranchTrueFalseTotal
unless $vars 0 0 0
62 0 push(@STORABLE_STACK, {Deparse=>$Storable::Deparse,Eval=>$Storable::Eval});
63 0 ${"Storable::$_"} = $vars->{$_} foreach (keys %$vars);
64 0 return $vars;
65 }
66  
67 ## \%vars = CLASS_OR_OBJ->storable_pop()
68 ## + pops Storable state vars from @STORABLE_STACK
69 0 ▶sub storable_pop {
Subroutine storable_pop: not called CC=3 SCAR=18.1
Pod undocumented
70 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
71 0 ▶ return if (!@STORABLE_STACK); ##-- nothing to do
Branch: 1 branch
BranchTrueFalseTotal
unless @Lingua::TT::Persistent::STORABLE_STACK 0 0 0
72 0 my $vars = pop(@STORABLE_STACK);
73 0 ${"Storable::$_"} = $vars->{$_} foreach (keys %$vars);
74 0 return $vars;
75 }
76  
77  
78 ##==============================================================================
79 ## Methods: Persistence
80 ##==============================================================================
81  
82 ##======================================================================
83 ## Methods: Persistence: Perl
84  
85 ## @keys = $class_or_obj->noSaveKeys()
86 ## + returns list of keys not to be saved for perl-mode I/O
87 ## + default just returns empty list
88 0 ▶sub noSaveKeys { return qw(); }
Subroutine noSaveKeys: not called CC=1 SCAR=6.9
Pod documented
89  
90 ## $saveRef = $obj->savePerlRef()
91 ## + return reference to be saved (hack)
92 ## + default implementation assumes $obj is HASH-ref
93 0 ▶sub savePerlRef {
Subroutine savePerlRef: not called CC=13 SCAR=52.0
Pod documented
94 0 my $obj = shift;
95 0 my %noSave = map {($_=>undef)} $obj->noSaveKeys;
96 return bless({
97 0 ▶ map { ($_=>(ref($obj->{$_}) && can($obj->{$_},'savePerlRef') ? $obj->{$_}->savePerlRef : $obj->{$_})) }
Branch: 1 branch
BranchTrueFalseTotal
ref $obj->{$_} && can($obj->{$_}, 'savePerlRef') ? : 0 0 0
Condition0%0/3
ref $obj->{$_} and can($obj->{$_}, "savePerlRef")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $obj->{$_} and can($obj->{$_}, "savePerlRef")
ref $obj->{$_} can($obj->{$_}, "savePerlRef")
Truth table0%0/3
A and B
A= ref $obj->{$_}B= can($obj->{$_}, "savePerlRef")
ABresult
0X0
100
111
98 grep {
99 0 (!exists($noSave{$_})
100 && (!ref($obj->{$_})
101 || !isa($obj->{$_},'CODE')
102 || !isa($obj->{$_},'GLOB')
103 || (ref($obj) !~ /^DB_File\b/)
104 || !isa($obj->{$_},'IO::Handle')
105 || !isa($obj->{$_},'Gfsm::Automaton')
106 || !isa($obj->{$_},'Gfsm::Alphabet')
107 || !isa($obj->{$_},'Gfsm::Semiring')
108 || !isa($obj->{$_},'Gfsm::XL::Cascade')
109 0 ▶ || !isa($obj->{$_},'Gfsm::XL::Cascade::Lookup')
Condition0%0/30
exists $noSave{$_} || ref $obj->{$_} && Lingua::TT::Persistent::isa($obj->{$_}, 'CODE') && Lingua::TT::Persistent::isa($obj->{$_}, 'GLOB') && ref($obj) =~ /^DB_File\b/ && Lingua::TT::Persistent::isa($obj->{$_}, 'IO::Handle') && Lingua::TT::Persistent::isa($obj->{$_}, 'Gfsm::Automaton') && Lingua::TT::Persistent::isa($obj->{$_}, 'Gfsm::Alphabet') && Lingua::TT::Persistent::isa($obj->{$_}, 'Gfsm::Semiring') && Lingua::TT::Persistent::isa($obj->{$_}, 'Gfsm::XL::Cascade') && Lingua::TT::Persistent::isa($obj->{$_}, 'Gfsm::XL::Cascade::Lookup')
l!l&&r!l&&!r
000
ref $obj->{$_} and Lingua::TT::Persistent::isa($obj->{$_}, "CODE") and Lingua::TT::Persistent::isa($obj->{$_}, "GLOB") and ref($obj) =~ /^DB_File\b/ and Lingua::TT::Persistent::isa($obj->{$_}, "IO::Handle") and Lingua::TT::Persistent::isa($obj->{$_}, "Gfsm::Automaton") and Lingua::TT::Persistent::isa($obj->{$_}, "Gfsm::Alphabet") and Lingua::TT::Persistent::isa($obj->{$_}, "Gfsm::Semiring") and Lingua::TT::Persistent::isa($obj->{$_}, "Gfsm::XL::Cascade") and Lingua::TT::Persistent::isa($obj->{$_}, "Gfsm::XL::Cascade::Lookup")
!ll&&!rl&&r
000
ref $obj->{$_} and Lingua::TT::Persistent::isa($obj->{$_}, "CODE") and Lingua::TT::Persistent::isa($obj->{$_}, "GLOB") and ref($obj) =~ /^DB_File\b/ and Lingua::TT::Persistent::isa($obj->{$_}, "IO::Handle") and Lingua::TT::Persistent::isa($obj->{$_}, "Gfsm::Automaton") and Lingua::TT::Persistent::isa($obj->{$_}, "Gfsm::Alphabet") and Lingua::TT::Persistent::isa($obj->{$_}, "Gfsm::Semiring") and Lingua::TT::Persistent::isa($obj->{$_}, "Gfsm::XL::Cascade")
!ll&&!rl&&r
000
ref $obj->{$_} and Lingua::TT::Persistent::isa($obj->{$_}, "CODE") and Lingua::TT::Persistent::isa($obj->{$_}, "GLOB") and ref($obj) =~ /^DB_File\b/ and Lingua::TT::Persistent::isa($obj->{$_}, "IO::Handle") and Lingua::TT::Persistent::isa($obj->{$_}, "Gfsm::Automaton") and Lingua::TT::Persistent::isa($obj->{$_}, "Gfsm::Alphabet") and Lingua::TT::Persistent::isa($obj->{$_}, "Gfsm::Semiring")
!ll&&!rl&&r
000
ref $obj->{$_} and Lingua::TT::Persistent::isa($obj->{$_}, "CODE") and Lingua::TT::Persistent::isa($obj->{$_}, "GLOB") and ref($obj) =~ /^DB_File\b/ and Lingua::TT::Persistent::isa($obj->{$_}, "IO::Handle") and Lingua::TT::Persistent::isa($obj->{$_}, "Gfsm::Automaton") and Lingua::TT::Persistent::isa($obj->{$_}, "Gfsm::Alphabet")
!ll&&!rl&&r
000
ref $obj->{$_} and Lingua::TT::Persistent::isa($obj->{$_}, "CODE") and Lingua::TT::Persistent::isa($obj->{$_}, "GLOB") and ref($obj) =~ /^DB_File\b/ and Lingua::TT::Persistent::isa($obj->{$_}, "IO::Handle") and Lingua::TT::Persistent::isa($obj->{$_}, "Gfsm::Automaton")
!ll&&!rl&&r
000
ref $obj->{$_} and Lingua::TT::Persistent::isa($obj->{$_}, "CODE") and Lingua::TT::Persistent::isa($obj->{$_}, "GLOB") and ref($obj) =~ /^DB_File\b/ and Lingua::TT::Persistent::isa($obj->{$_}, "IO::Handle")
!ll&&!rl&&r
000
ref $obj->{$_} and Lingua::TT::Persistent::isa($obj->{$_}, "CODE") and Lingua::TT::Persistent::isa($obj->{$_}, "GLOB") and ref($obj) =~ /^DB_File\b/
!ll&&!rl&&r
000
ref $obj->{$_} and Lingua::TT::Persistent::isa($obj->{$_}, "CODE") and Lingua::TT::Persistent::isa($obj->{$_}, "GLOB")
!ll&&!rl&&r
000
ref $obj->{$_} and Lingua::TT::Persistent::isa($obj->{$_}, "CODE")
!ll&&!rl&&r
000
MC/DC0%0/11
exists $noSave{$_} || ref $obj->{$_} && Lingua::TT::Persistent::isa($obj->{$_}, 'CODE') && Lingua::TT::Persistent::isa($obj->{$_}, 'GLOB') && ref($obj) =~ /^DB_File\b/ && Lingua::TT::Persistent::isa($obj->{$_}, 'IO::Handle') && Lingua::TT::Persistent::isa($obj->{$_}, 'Gfsm::Automaton') && Lingua::TT::Persistent::isa($obj->{$_}, 'Gfsm::Alphabet') && Lingua::TT::Persistent::isa($obj->{$_}, 'Gfsm::Semiring') && Lingua::TT::Persistent::isa($obj->{$_}, 'Gfsm::XL::Cascade') && Lingua::TT::Persistent::isa($obj->{$_}, 'Gfsm::XL::Cascade::Lookup')
exists $noSave{$_} ref $obj->{$_} Lingua::TT::Persistent::isa($obj->{$_}, "CODE") Lingua::TT::Persistent::isa($obj->{$_}, "GLOB") ref($obj) =~ /^DB_File\b/ Lingua::TT::Persistent::isa($obj->{$_}, "IO::Handle") Lingua::TT::Persistent::isa($obj->{$_}, "Gfsm::Automaton") Lingua::TT::Persistent::isa($obj->{$_}, "Gfsm::Alphabet") Lingua::TT::Persistent::isa($obj->{$_}, "Gfsm::Semiring") Lingua::TT::Persistent::isa($obj->{$_}, "Gfsm::XL::Cascade") Lingua::TT::Persistent::isa($obj->{$_}, "Gfsm::XL::Cascade::Lookup")
Truth table0%0/12
A || B and C and D and E and F and G and H and I and J and K
A= exists $noSave{$_}B= ref $obj->{$_}C= Lingua::TT::Persistent::isa($obj->{$_}, "CODE")D= Lingua::TT::Persistent::isa($obj->{$_}, "GLOB")E= ref($obj) =~ /^DB_File\b/F= Lingua::TT::Persistent::isa($obj->{$_}, "IO::Handle")G= Lingua::TT::Persistent::isa($obj->{$_}, "Gfsm::Automaton")H= Lingua::TT::Persistent::isa($obj->{$_}, "Gfsm::Alphabet")I= Lingua::TT::Persistent::isa($obj->{$_}, "Gfsm::Semiring")J= Lingua::TT::Persistent::isa($obj->{$_}, "Gfsm::XL::Cascade")K= Lingua::TT::Persistent::isa($obj->{$_}, "Gfsm::XL::Cascade::Lookup")
ABCDEFGHIJKresult
1XXXXXXXXXX1
011111111111
00XXXXXXXXX0
010XXXXXXXX0
0110XXXXXXX0
01110XXXXXX0
011110XXXXX0
0111110XXXX0
01111110XXX0
011111110XX0
0111111110X0
011111111100
110 )
111 )}
112 keys(%$obj)
113 }, ref($obj));
114 }
115  
116 ## $loadedObj = $CLASS_OR_OBJ->loadPerlRef($ref)
117 ## + default implementation just clobbers $CLASS_OR_OBJ with $ref and blesses
118 0 ▶sub loadPerlRef {
Subroutine loadPerlRef: not called CC=11 SCAR=48.8
Pod documented
119 0 my ($that,$ref) = @_;
120 0 ▶ return $that if (!defined($ref) || $ref eq $that); ##-- literal load
Branch: 1 branch
BranchTrueFalseTotal
if not defined $ref or $ref eq $that 0 0 0
Condition0%0/3
not defined $ref or $ref eq $that
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $ref or $ref eq $that
not defined $ref $ref eq $that
Truth table0%0/3
not(A) or B
A= not defined $refB= $ref eq $that
ABresult
1X1
011
000
121 0 ▶ $that = ref($ref) if (UNIVERSAL::isa($ref,$that)); ##-- "virtual load": return subclass for superclass method
Branch: 1 branch
BranchTrueFalseTotal
if UNIVERSAL::isa($ref, $that) 0 0 0
122 0 ▶ my $obj = ref($that) ? $that : $that->new();
Branch: 1 branch
BranchTrueFalseTotal
ref $that ? : 0 0 0
123 0 $obj = bless(unifyClobber($obj,$ref,undef),ref($obj));
124 0 ▶ if (UNIVERSAL::isa($that,'HASH') && UNIVERSAL::isa($obj,'HASH')) {
Branch: 3 branches
BranchTrueFalseTotal
if (UNIVERSAL::isa($that, 'HASH') and UNIVERSAL::isa($obj, 'HASH')) { } 0 0 0
elsif (UNIVERSAL::isa($that, 'ARRAY') and UNIVERSAL::isa($obj, 'ARRAY')) { } 0 0 0
elsif (UNIVERSAL::isa($that, 'SCALAR') and UNIVERSAL::isa($obj, 'SCALAR')) { } 0 0 0
Condition0%0/3
UNIVERSAL::isa($that, "HASH") and UNIVERSAL::isa($obj, "HASH")
!ll&&!rl&&r
000
MC/DC0%0/2
UNIVERSAL::isa($that, "HASH") and UNIVERSAL::isa($obj, "HASH")
UNIVERSAL::isa($that, "HASH") UNIVERSAL::isa($obj, "HASH")
Truth table0%0/3
A and B
A= UNIVERSAL::isa($that, "HASH")B= UNIVERSAL::isa($obj, "HASH")
ABresult
0X0
100
111
125 0 %$that = %$obj; ##-- hack in case someone does "$obj->load()" and expects $obj to be destructively altered...
126 0 return $that;
127 ▶ } elsif (UNIVERSAL::isa($that,'ARRAY') && UNIVERSAL::isa($obj,'ARRAY')) {
Condition0%0/3
UNIVERSAL::isa($that, "ARRAY") and UNIVERSAL::isa($obj, "ARRAY")
!ll&&!rl&&r
000
MC/DC0%0/2
UNIVERSAL::isa($that, "ARRAY") and UNIVERSAL::isa($obj, "ARRAY")
UNIVERSAL::isa($that, "ARRAY") UNIVERSAL::isa($obj, "ARRAY")
Truth table0%0/3
A and B
A= UNIVERSAL::isa($that, "ARRAY")B= UNIVERSAL::isa($obj, "ARRAY")
ABresult
0X0
100
111
128 0 @$that = @$obj; ##-- ... analagous hack for array refs
129 0 return $that;
130 ▶ } elsif (UNIVERSAL::isa($that,'SCALAR') && UNIVERSAL::isa($obj,'SCALAR')) {
Condition0%0/3
UNIVERSAL::isa($that, "SCALAR") and UNIVERSAL::isa($obj, "SCALAR")
!ll&&!rl&&r
000
MC/DC0%0/2
UNIVERSAL::isa($that, "SCALAR") and UNIVERSAL::isa($obj, "SCALAR")
UNIVERSAL::isa($that, "SCALAR") UNIVERSAL::isa($obj, "SCALAR")
Truth table0%0/3
A and B
A= UNIVERSAL::isa($that, "SCALAR")B= UNIVERSAL::isa($obj, "SCALAR")
ABresult
0X0
100
111
131 0 $$that = $$obj; ##-- ... analagous hack for scalar refs
132 0 return $that;
133 }
134 0 return $obj;
135 }
136  
137 ##----------------------------------------------------
138 ## Methods: Persistence: Perl: File (delegate to string)
139  
140 ## $rc = $obj->savePerlFile($filename_or_fh, @args)
141 ## + calls "$obj->savePerlString(@args)"
142 0 ▶sub savePerlFile {
Subroutine savePerlFile: not called CC=4 SCAR=30.0
Pod documented
143 0 my ($obj,$file) = (shift,shift);
144 0 ▶ my $fh = ref($file) ? $file : IO::File->new(">$file");
Branch: 1 branch
BranchTrueFalseTotal
ref $file ? : 0 0 0
145 0 ▶ confess(ref($obj), "::savePerlFile(): open failed for '$file': $!")
Branch: 1 branch
BranchTrueFalseTotal
unless $fh 0 0 0
146 if (!$fh);
147 0 $fh->print("## Perl code auto-generated by ", __PACKAGE__, "::savePerlFile()\n",
148 "## EDIT AT YOUR OWN RISK\n",
149 $obj->savePerlString(@_));
150 0 ▶ $fh->close() if (!ref($file));
Branch: 1 branch
BranchTrueFalseTotal
unless ref $file 0 0 0
151 0 return 1;
152 }
153  
154 ## $obj = $CLASS_OR_OBJ->loadPerlFile($filename_or_fh, %args)
155 ## + calls $CLASS_OR_OBJ->loadPerlString(var=>undef,src=>$filename_or_fh, %args)
156 0 ▶sub loadPerlFile {
Subroutine loadPerlFile: not called CC=5 SCAR=34.0
Pod documented
157 0 my ($that,$file,%args) = @_;
158 0 ▶ my $fh = ref($file) ? $file : IO::File->new("<$file");
Branch: 1 branch
BranchTrueFalseTotal
ref $file ? : 0 0 0
159 0 ▶ confess((ref($that)||$that), "::loadPerlFile(): open failed for '$file': $!") if (!$fh);
Branch: 1 branch
BranchTrueFalseTotal
unless $fh 0 0 0
Condition0%0/3
ref $that || $that
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table0%0/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
160 0 local $/=undef;
161 0 my $str = <$fh>;
162 0 ▶ $fh->close() if (!ref($file));
Branch: 1 branch
BranchTrueFalseTotal
unless ref $file 0 0 0
163 0 return $that->loadPerlString($str, var=>undef, src=>$file, %args);
164 }
165  
166 ##----------------------------------------------------
167 ## Methods: Persistence: Perl: String (perl code)
168  
169 ## $str = $obj->savePerlString(%args)
170 ## + save $obj as perl code
171 ## + %args:
172 ## var => $perl_var_name
173 0 ▶sub savePerlString {
Subroutine savePerlString: not called CC=3 SCAR=24.8
Pod documented
174 0 my ($obj,%args) = @_;
175 0 ▶ my $var = $args{var} ? $args{var} : '$obj';
Branch: 1 branch
BranchTrueFalseTotal
$args{'var'} ? : 0 0 0
176 0 my $dumper = (Data::Dumper->new([$obj],[$var])
177 ->Indent(1)
178 ->Purity(1)
179 ->Terse(0)
180 ->Sortkeys(1)
181 ->Freezer('freezePerlRef')
182 ->Toaster('toastPerlRef'));
183 0 my $str = join('', $dumper->Dump);
184  
185 ##-- un-freeze hack
186 0 our (%PERL_FROZEN);
187 0 foreach (values(%PERL_FROZEN)) {
188 0 ${$_->[1]} = $_->[0];
189 }
190 0 %PERL_FROZEN = qw();
191  
192 0 return $str;
193 }
194  
195 ## $obj = $CLASS_OR_OBJ->loadPerlString($str,%args)
196 ## + %args:
197 ## var=>$perl_var_name, ##-- default='$index' ; local var: $VAR
198 ## src=>$src_name, ##-- default=(substr($str,0,42).'...'); local var: $SRC
199 ## %more_obj_args, ##-- literally inserted into $obj
200 ## + load from perl code string
201 0 ▶sub loadPerlString {
Subroutine loadPerlString: not called CC=9 SCAR=45.0
Pod documented
202 0 my ($that,$str,%args) = @_;
203 0 ▶ my $var = $args{var} ? $args{var} : '$obj';
Branch: 1 branch
BranchTrueFalseTotal
$args{'var'} ? : 0 0 0
204 my $src = (defined($args{src})
205 ? $args{src}
206 0 ▶ : (length($str) <= 42
Branch: 2 branches
BranchTrueFalseTotal
defined $args{'src'} ? : 0 0 0
length $str <= 42 ? : 0 0 0
207 ? $str
208 : (substr($str,0,42).'...')));
209 0 my $VAR = $var;
210 0 ▶ my $SRC = (defined($args{src}) ? $args{src} : '/dev/null');
Branch: 1 branch
BranchTrueFalseTotal
defined $args{'src'} ? : 0 0 0
211 0 my $TOP = $Lingua::TT::Unify::TOP;
212 0 delete(@args{qw(var src)});
213  
214 0 my $loaded = eval("no strict; $str; $var");
215 0 ▶ confess((ref($that)||$that), "::loadString(): eval() failed for '$src': ", $@ ? $@ : $!)
Branch: 2 branches
BranchTrueFalseTotal
if $@ or not defined $loaded 0 0 0
$@ ? : 0 0 0
Condition0%0/6
$@ or not defined $loaded
l!l&&r!l&&!r
000
ref $that || $that
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ or not defined $loaded
$@ not defined $loaded
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table0%0/3
A or not(B)
A= $@B= not defined $loaded
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
216 if ($@ || !defined($loaded)); #|| $!
217  
218 0 return $that->loadPerlRef($loaded);
219 }
220  
221 ##----------------------------------------------------
222 ## Methods: Persistence: Perl: freeze/toast
223  
224 ## undef = $obj->freezePerlRef()
225 ## + in-place freezer
226 0 ▶sub freezePerlRef {
Subroutine freezePerlRef: not called CC=2 SCAR=17.9
Pod undocumented
227 0 our (%PERL_FROZEN);
228 0 my $obj = $_[0];
229 0 my $ref = bless($obj->savePerlRef(),ref($obj));
230 0 my $okey = overload::StrVal($obj);
231 0 my $rkey = overload::StrVal($ref);
232 0 ▶ return $obj if ($okey eq $rkey);
Branch: 1 branch
BranchTrueFalseTotal
if $okey eq $rkey 0 0 0
233 0 $PERL_FROZEN{$rkey} = [$obj,\$ref];
234 0 $_[0] = $ref;
235 }
236  
237 ## undef = $obj->toastPerlRef()
238 ## + in-place toaster
239 0 ▶sub toastPerlRef {
Subroutine toastPerlRef: not called CC=1 SCAR=6.9
Pod undocumented
240 0 $_[0] = $_[0]->loadPerlRef($_[0]);
241 }
242  
243 ##======================================================================
244 ## Methods: Persistence: Binary
245  
246 ## @keys = $class_or_obj->noSaveBinKeys()
247 ## + returns list of keys not to be saved for binary mode I/O
248 ## + default just returns empty $obj->noSaveKeys()
249 0 ▶sub noSaveBinKeys { return $_[0]->noSaveKeys(); }
Subroutine noSaveBinKeys: not called CC=1 SCAR=6.9
Pod documented
250  
251 ## $binRef = $obj->saveBinRef()
252 ## + return reference to be saved in binary mode
253 ## + default implementation assumes $obj is HASH-ref
254 0 ▶sub saveBinRef {
Subroutine saveBinRef: not called CC=7 SCAR=40.3
Pod documented
255 0 my $obj = shift;
256 0 my %noSave = map {($_=>undef)} $obj->noSaveBinKeys;
257 return
258 bless({
259 0 ▶ map { ($_=>(ref($obj->{$_}) && UNIVERSAL::can($obj->{$_},'saveBinRef') ? $obj->{$_}->saveBinRef() : $obj->{$_})) }
Branch: 1 branch
BranchTrueFalseTotal
ref $obj->{$_} && UNIVERSAL::can($obj->{$_}, 'saveBinRef') ? : 0 0 0
Condition0%0/3
ref $obj->{$_} and UNIVERSAL::can($obj->{$_}, "saveBinRef")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $obj->{$_} and UNIVERSAL::can($obj->{$_}, "saveBinRef")
ref $obj->{$_} UNIVERSAL::can($obj->{$_}, "saveBinRef")
Truth table0%0/3
A and B
A= ref $obj->{$_}B= UNIVERSAL::can($obj->{$_}, "saveBinRef")
ABresult
0X0
100
111
260 grep {
261 0 (!exists($noSave{$_})
262 && (!ref($obj->{$_})
263 || !UNIVERSAL::isa($obj->{$_},'CODE')
264 || !UNIVERSAL::isa($obj->{$_},'GLOB')
265 0 ▶ || !UNIVERSAL::isa($obj->{$_},'IO::Handle')
Condition0%0/12
exists $noSave{$_} || ref $obj->{$_} && UNIVERSAL::isa($obj->{$_}, 'CODE') && UNIVERSAL::isa($obj->{$_}, 'GLOB') && UNIVERSAL::isa($obj->{$_}, 'IO::Handle')
l!l&&r!l&&!r
000
ref $obj->{$_} and UNIVERSAL::isa($obj->{$_}, "CODE") and UNIVERSAL::isa($obj->{$_}, "GLOB") and UNIVERSAL::isa($obj->{$_}, "IO::Handle")
!ll&&!rl&&r
000
ref $obj->{$_} and UNIVERSAL::isa($obj->{$_}, "CODE") and UNIVERSAL::isa($obj->{$_}, "GLOB")
!ll&&!rl&&r
000
ref $obj->{$_} and UNIVERSAL::isa($obj->{$_}, "CODE")
!ll&&!rl&&r
000
MC/DC0%0/5
exists $noSave{$_} || ref $obj->{$_} && UNIVERSAL::isa($obj->{$_}, 'CODE') && UNIVERSAL::isa($obj->{$_}, 'GLOB') && UNIVERSAL::isa($obj->{$_}, 'IO::Handle')
exists $noSave{$_} ref $obj->{$_} UNIVERSAL::isa($obj->{$_}, "CODE") UNIVERSAL::isa($obj->{$_}, "GLOB") UNIVERSAL::isa($obj->{$_}, "IO::Handle")
Truth table0%0/6
A || B and C and D and E
A= exists $noSave{$_}B= ref $obj->{$_}C= UNIVERSAL::isa($obj->{$_}, "CODE")D= UNIVERSAL::isa($obj->{$_}, "GLOB")E= UNIVERSAL::isa($obj->{$_}, "IO::Handle")
ABCDEresult
1XXXX1
011111
00XXX0
010XX0
0110X0
011100
266 #|| !UNIVERSAL::isa($obj->{$_},'Gfsm::Automaton')
267 #|| !UNIVERSAL::isa($obj->{$_},'Gfsm::Alphabet')
268 #|| !UNIVERSAL::isa($obj->{$_},'Gfsm::Semiring')
269 #|| !UNIVERSAL::isa($obj->{$_},'Gfsm::XL::Cascade')
270 #|| !UNIVERSAL::isa($obj->{$_},'Gfsm::XL::Cascade::Lookup')
271 )
272 )}
273 keys(%$obj)
274 },
275 ref($obj));
276 }
277  
278 ## $loadedObj = $CLASS_OR_OBJ->loadBinRef($ref)
279 ## + default implementation just duplicates default loadPerlRef($ref)
280 0 ▶sub loadBinRef {
Subroutine loadBinRef: not called CC=1 SCAR=6.9
Pod documented
281 0 return Lingua::TT::Persistent::loadPerlRef(@_);
282 }
283  
284 ##----------------------------------------------------
285 ## Methods: Persistence: Bin: File (delegate to FH)
286  
287 ## $rc = $obj->saveBinFile($filename_or_fh, %args)
288 ## + save $obj as binary data to a file or filehandle
289 ## + calls $obj->saveBinFh($fh,%args)
290 0 ▶sub saveBinFile {
Subroutine saveBinFile: not called CC=4 SCAR=30.0
Pod documented
291 0 my ($obj,$file,%args) = @_;
292 0 ▶ my $fh = ref($file) ? $file : IO::File->new(">$file");
Branch: 1 branch
BranchTrueFalseTotal
ref $file ? : 0 0 0
293 0 ▶ confess(ref($obj)."::saveBinFile(): open failed for '$file': $!") if (!$fh);
Branch: 1 branch
BranchTrueFalseTotal
unless $fh 0 0 0
294 0 my $rc = $obj->saveBinFh($fh,%args,dst=>$file);
295 0 ▶ $fh->close() if (!ref($file));
Branch: 1 branch
BranchTrueFalseTotal
unless ref $file 0 0 0
296 0 return $rc;
297 }
298  
299 ## $obj = $CLASS_OR_OBJ->loadBinFile($filename_or_fh, %args)
300 ## + load $obj as binary data from a file or filehandle
301 ## + calls $obj->loadBinFh($fh,%args)
302 0 ▶sub loadBinFile {
Subroutine loadBinFile: not called CC=5 SCAR=34.0
Pod documented
303 0 my ($that,$file,%args) = @_;
304 0 ▶ my $fh = ref($file) ? $file : IO::File->new("<$file");
Branch: 1 branch
BranchTrueFalseTotal
ref $file ? : 0 0 0
305 0 ▶ confess((ref($that)||$that)."::loadBinFile(): open failed for '$file': $!") if (!$fh);
Branch: 1 branch
BranchTrueFalseTotal
unless $fh 0 0 0
Condition0%0/3
ref $that || $that
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table0%0/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
306 0 my $rc = $that->loadBinFh($fh,%args,src=>$file);
307 0 ▶ $fh->close() if (!ref($file));
Branch: 1 branch
BranchTrueFalseTotal
unless ref $file 0 0 0
308 0 return $rc;
309 }
310  
311 ##----------------------------------------------------
312 ## Methods: Persistence: Bin: String (delegate to FH)
313  
314 ## $str = $obj->saveBinString(%args)
315 ## + save $obj as binary data using Storable module
316 ## + calls $obj->saveBinFh($fh,%args)
317 0 ▶sub saveBinString {
Subroutine saveBinString: not called CC=3 SCAR=24.8
Pod documented
318 0 my ($obj,%args) = @_;
319 0 my $str = '';
320 0 my $fh = IO::Handle->new();
321 0 ▶ CORE::open($fh,'>',\$str)
Branch: 1 branch
BranchTrueFalseTotal
open $fh, ">", \$str or confess(ref($obj) . '::saveBinString(): could not open() filehandle for string ref') 0 0 0
322 or confess(ref($obj)."::saveBinString(): could not open() filehandle for string ref");
323 0 my $rc = $obj->saveBinFh($fh);
324 0 $fh->close();
325 0 ▶ return $rc ? $str : undef;
Branch: 1 branch
BranchTrueFalseTotal
$rc ? : 0 0 0
326 }
327  
328 ## $obj = $CLASS_OR_OBJ->loadBinString( $str, %args)
329 ## $obj = $CLASS_OR_OBJ->loadBinString(\$str, %args)
330 ## + load $obj from Storable binary data string
331 ## + calls $obj->loadBinFh($fh,%args)
332 ## + %args:
333 ## src=>$src_name, ##-- default=(substr($str,0,42).'...')
334 0 ▶sub loadBinString {
Subroutine loadBinString: not called CC=6 SCAR=37.4
Pod documented
335 0 my ($that,$str,%args) = @_;
336 my $src = (defined($args{src})
337 ? $args{src}
338 0 ▶ : (length($str) <= 42
Branch: 2 branches
BranchTrueFalseTotal
defined $args{'src'} ? : 0 0 0
length $str <= 42 ? : 0 0 0
339 ? $str
340 : (substr($str,0,42).'...')));
341  
342 0 my $fh = IO::Handle->new();
343 0 ▶ CORE::open($fh,'<',(ref($str) ? $str : \$str))
Branch: 2 branches
BranchTrueFalseTotal
open $fh, "<", ref $str ? $str : \$str or confess((ref $that || $that) . '::loadBinString(): could not open() filehandle for string ref') 0 0 0
ref $str ? : 0 0 0
Condition0%0/3
ref $that || $that
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table0%0/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
344 or confess((ref($that)||$that)."::loadBinString(): could not open() filehandle for string ref");
345 0 my $rc = $that->loadBinFh($fh,src=>$src,%args);
346 0 $fh->close;
347 0 return $rc;
348 }
349  
350 ##----------------------------------------------------
351 ## Methods: Persistence: Bin: FH (guts)
352  
353 ## $obj_or_undef = $obj->saveBinFh($fh,%args)
354 ## + save $obj to binary Storable data handle
355 ## + calls $obj->saveBinRef()
356 ## + %args:
357 ## netorder => $bool, ##-- if true (default), save in network order
358 0 ▶sub saveBinFh {
Subroutine saveBinFh: not called CC=5 SCAR=34.0
Pod documented
359 0 my ($obj,$fh,%args) = @_;
360 0 my $ref = $obj->saveBinRef();
361 0 ▶ if ($args{netorder} || !exists($args{netorder})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"netorder"} or not exists $args{"netorder"}) 0 0 0
Condition0%0/3
$args{"netorder"} or not exists $args{"netorder"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"netorder"} or not exists $args{"netorder"}
$args{"netorder"} not exists $args{"netorder"}
Truth table0%0/3
A or not(B)
A= $args{"netorder"}B= not exists $args{"netorder"}
ABresult
1X1
011
000
362 0 ▶ return Storable::nstore_fd($ref,$fh) ? $obj : undef;
Branch: 1 branch
BranchTrueFalseTotal
Storable::nstore_fd($ref, $fh) ? : 0 0 0
363 }
364 0 ▶ return Storable::store_fd($ref,$fh) ? $obj : undef;
Branch: 1 branch
BranchTrueFalseTotal
Storable::store_fd($ref, $fh) ? : 0 0 0
365 }
366  
367 ## $obj = $CLASS_OR_OBJ->loadBinFh($fh, %args)
368 ## + load $obj from Storable binary data handle
369 ## + calls $obj->loadBinFh($fh,%args)
370 ## + %args:
371 ## src=>$src_name, ##-- default=(substr($str,0,42).'...')
372 0 ▶sub loadBinFh {
Subroutine loadBinFh: not called CC=1 SCAR=6.9
Pod documented
373 0 my ($that,$fh,%args) = @_;
374 0 my $loaded = Storable::retrieve_fd($fh);
375 0 return $that->loadBinRef($loaded);
376 }
377  
378 ##======================================================================
379 ## Methods: Persistence: Native
380  
381 ##----------------------------------------------------
382 ## Methods: Persistence: Native: File (delegate to FH)
383  
384 ## $rc = $obj->saveNativeFile($filename_or_fh, %args)
385 ## + save $obj as native data to a file or filehandle
386 ## + calls $obj->saveNativeFh($fh,%args)
387 0 ▶sub saveNativeFile {
Subroutine saveNativeFile: not called CC=4 SCAR=30.0
Pod undocumented
388 0 my ($obj,$file,%args) = @_;
389 0 ▶ my $fh = ref($file) ? $file : Lingua::TT::IO->open(">",$file,%args)->{fh};
Branch: 1 branch
BranchTrueFalseTotal
ref $file ? : 0 0 0
390 0 ▶ confess(ref($obj)."::saveNativeFile(): open failed for '$file': $!") if (!$fh);
Branch: 1 branch
BranchTrueFalseTotal
unless $fh 0 0 0
391 0 my $rc = $obj->saveNativeFh($fh,%args,dst=>$file);
392 0 ▶ $fh->close() if (!ref($file));
Branch: 1 branch
BranchTrueFalseTotal
unless ref $file 0 0 0
393 0 return $rc;
394 }
395  
396 ## $obj = $CLASS_OR_OBJ->loadNativeFile($filename_or_fh, %args)
397 ## + load $obj as native data from a file or filehandle
398 ## + calls $obj->loadNativeFh($fh,%args)
399 0 ▶sub loadNativeFile {
Subroutine loadNativeFile: not called CC=5 SCAR=34.0
Pod undocumented
400 0 my ($that,$file,%args) = @_;
401 0 ▶ my $fh = ref($file) ? $file : Lingua::TT::IO->open("<",$file,%args)->{fh};
Branch: 1 branch
BranchTrueFalseTotal
ref $file ? : 0 0 0
402 0 ▶ confess((ref($that)||$that)."::loadNativeFile(): open failed for '$file': $!") if (!$fh);
Branch: 1 branch
BranchTrueFalseTotal
unless $fh 0 0 0
Condition0%0/3
ref $that || $that
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table0%0/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
403 0 my $rc = $that->loadNativeFh($fh,%args,src=>$file);
404 0 ▶ $fh->close() if (!ref($file));
Branch: 1 branch
BranchTrueFalseTotal
unless ref $file 0 0 0
405 0 return $rc;
406 }
407  
408 ##----------------------------------------------------
409 ## Methods: Persistence: Native: String (delegate to FH)
410  
411 ## $str = $obj->saveNativeString(%args)
412 ## + save $obj as native data using object-local method $that->saveNativeFh()
413 ## + calls $obj->saveBinFh($fh,%args)
414 0 ▶sub saveNativeString {
Subroutine saveNativeString: not called CC=2 SCAR=17.9
Pod undocumented
415 0 my ($obj,%args) = @_;
416 0 my $str = '';
417 0 my $fh = Lingua::TT::IO->toString(\$str,%args)->{fh};
418 0 my $rc = $obj->saveNativeFh($fh);
419 0 $fh->close();
420 0 ▶ return $rc ? $str : undef;
Branch: 1 branch
BranchTrueFalseTotal
$rc ? : 0 0 0
421 }
422  
423 ## $obj = $CLASS_OR_OBJ->loadNativeString( $str, %args)
424 ## $obj = $CLASS_OR_OBJ->loadNativeString(\$str, %args)
425 ## + load $obj from native data string
426 ## + calls $obj->loadNativeFh($fh,%args)
427 ## + %args:
428 ## src=>$src_name, ##-- default=(substr($str,0,42).'...')
429 0 ▶sub loadNativeString {
Subroutine loadNativeString: not called CC=3 SCAR=24.8
Pod undocumented
430 0 my ($that,$str,%args) = @_;
431 my $src = (defined($args{src})
432 ? $args{src}
433 0 ▶ : (length($str) <= 42
Branch: 2 branches
BranchTrueFalseTotal
defined $args{'src'} ? : 0 0 0
length $str <= 42 ? : 0 0 0
434 ? $str
435 : (substr($str,0,42).'...')));
436 0 my $fh = Lingua::TT::IO->fromString(\$str,%args)->{fh};
437 0 my $rc = $that->loadNativeFh($fh,src=>$src,%args);
438 0 $fh->close;
439 0 return $rc;
440 }
441  
442 ##----------------------------------------------------
443 ## Methods: Persistence: Native: FH (guts)
444 ## + should be overridden by descendant classes supporting native I/O mode
445  
446 ## $obj_or_undef = $obj->saveNativeFh($fh,%args)
447 ## + save $obj to native data handle
448 ## + %args: ?
449 0 ▶sub saveNativeFh {
Subroutine saveNativeFh: not called CC=1 SCAR=6.9
Pod undocumented
450 0 my ($obj,$fh,%args) = @_;
451 0 confess(ref($obj)."::saveNativeFh(): abstract method called!");
452 }
453  
454 ## $obj = $CLASS_OR_OBJ->loadBinFh($fh, %args)
455 ## + load $obj from native data handle
456 ## + %args: ?
457 0 ▶sub loadNativeFh {
Subroutine loadNativeFh: not called CC=2 SCAR=17.9
Pod undocumented
458 0 my ($that,$fh,%args) = @_;
459 0 ▶ confess((ref($that)||$that)."::loadNativeFh(): abstract method called!");
Condition0%0/3
ref $that || $that
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table0%0/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
460 }
461  
462 ##======================================================================
463 ## Methods: Persistence: Generic
464  
465 ##----------------------------------------------------
466 ## Methods: Persistence: Generic: utils
467  
468 ## $mode = $CLASS_OR_OBJ->guessFileMode($filename)
469 0 ▶sub guessFileMode {
Subroutine guessFileMode: not called CC=4 SCAR=30.0
Pod documented
470 0 my ($that,$filename) = @_;
471 0 ▶ return 'bin' if ($filename =~ /\.(?:sto|bin)$/i);
Branch: 1 branch
BranchTrueFalseTotal
if $filename =~ /\.(?:sto|bin)$/i 0 0 0
472 0 ▶ return 'perl' if ($filename =~ /\.(?:perl|pl|plm|pm|p)$/i);
Branch: 1 branch
BranchTrueFalseTotal
if $filename =~ /\.(?:perl|pl|plm|pm|p)$/i 0 0 0
473 0 ▶ return 'native' if ($that->can('saveNativeFh') ne __PACKAGE__->can('saveNativeFh'));
Branch: 1 branch
BranchTrueFalseTotal
if $that->can("saveNativeFh") ne __PACKAGE__->can("saveNativeFh") 0 0 0
474 0 return 'perl';
475 }
476  
477 ## $rc = $CLASS_OR_OBJ->_io_generic(%args)
478 ## + generic I/O wrapper
479 ## + %args:
480 ## which => $which, ##-- one of: 'load' or 'save' (default)
481 ## mode => $mode, ##-- one of: 'bin' or 'perl' (default: guessFileMode($file))
482 ## type => $type, ##-- one of: 'file', 'fh', or 'string' (default)
483 ## file => $file, ##-- any filename, used to guess mode
484 ## arg0 => $arg0, ##-- first arg to pass to the underlying I/O method (default=none)
485 0 ▶sub _io_generic {
Subroutine _io_generic: not called CC=8 SCAR=42.8
486 0 my ($that,%args) = @_;
487 0 ▶ $args{mode} = $that->guessFileMode($args{file}) if ($args{file} && !$args{mode});
Branch: 1 branch
BranchTrueFalseTotal
if $args{"file"} and not $args{"mode"} 0 0 0
Condition0%0/3
$args{"file"} and not $args{"mode"}
!ll&&!rl&&r
000
MC/DC0%0/2
$args{"file"} and not $args{"mode"}
$args{"file"} not $args{"mode"}
Truth table0%0/3
A and not(B)
A= $args{"file"}B= not $args{"mode"}
ABresult
0X0
100
111
488 0 ▶ $args{which} = 'save' if (!$args{which});
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"which"} 0 0 0
489 0 ▶ $args{type} = 'string' if (!$args{type});
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"type"} 0 0 0
490 0 my $subname = $args{which}.ucfirst(lc($args{mode})).ucfirst(lc($args{type}));
491 0 ▶ my $sub = $that->can($subname)
Branch: 1 branch
BranchTrueFalseTotal
my $sub = $that->can($subname) or confess((ref $that || $that) . "::_io_generic(): no method for '${subname}'") 0 0 0
Condition0%0/3
ref $that || $that
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table0%0/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
492 or confess((ref($that)||$that)."::_io_generic(): no method for '$subname'");
493 0 ▶ return $sub->($that, (exists($args{arg0}) ? $args{arg0} : qw()), %args);
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'arg0'} ? : 0 0 0
494 }
495  
496 ##----------------------------------------------------
497 ## Methods: Persistence: Generic: save
498  
499 ## $obj_or_undef = $CLASS_OR_OBJ->save(%args)
500 ## + %args: see _io_generic()
501 0 ▶sub save {
Subroutine save: not called CC=1 SCAR=6.9
Pod undocumented
502 0 my ($that,%args) = @_;
503 0 return $that->_io_generic(%args,which=>'save');
504 }
505  
506 ## $obj_or_undef = $CLASS_OR_OBJ->saveFile($filename_or_fh,%args)
507 ## + %args: see _io_generic()
508 0 ▶sub saveFile {
Subroutine saveFile: not called CC=1 SCAR=6.9
Pod documented
509 0 my ($that,$file,%args) = @_;
510 0 return $that->_io_generic(file=>$file,%args,which=>'save',type=>'file',arg0=>$file);
511 }
512 1 ▶BEGIN { *saveFh = \&saveFile; }
Subroutine BEGIN: called CC=1 SCAR=0.0
513  
514 ## $obj_or_undef = $CLASS_OR_OBJ->saveString(%args)
515 ## + %args: see _io_generic()
516 0 ▶sub saveString {
Subroutine saveString: not called CC=1 SCAR=6.9
Pod documented
517 0 my ($that,%args) = @_;
518 0 return $that->_io_generic(%args,which=>'save',type=>'string');
519 }
520  
521 ##----------------------------------------------------
522 ## Methods: Persistence: Generic: load
523  
524 ## $obj_or_undef = $CLASS_OR_OBJ->load(%args)
525 ## + %args: see _io_generic()
526 0 ▶sub load {
Subroutine load: not called CC=1 SCAR=6.9
Pod undocumented
527 0 my ($that,%args) = @_;
528 0 return $that->_io_generic(%args,which=>'load');
529 }
530  
531 ## $obj_or_undef = $CLASS_OR_OBJ->loadFile($filename_or_fh,%args)
532 ## + %args: see _io_generic()
533 0 ▶sub loadFile {
Subroutine loadFile: not called CC=1 SCAR=6.9
Pod documented
534 0 my ($that,$file,%args) = @_;
535 0 return $that->_io_generic(file=>$file,%args,which=>'load',type=>'file',arg0=>$file);
536 }
537 1 ▶BEGIN { *loadFh = \&loadFile; }
Subroutine BEGIN: called CC=1 SCAR=0.0
538  
539 ## $obj_or_undef = $CLASS_OR_OBJ->loadString($string,%args)
540 ## + %args: see _io_generic()
541 0 ▶sub loadString {
Subroutine loadString: not called CC=1 SCAR=6.9
Pod documented
542 0 my ($that,$str,%args) = @_;
543 0 return $that->_io_generic(%args,which=>'load',type=>'string');
544 }
545  
546  
547 1 1; ##-- be happy
548  
549 __END__
« TT/Dict/JSON.pm ↑ Summary TT/IO.pm »