blib/lib/Uplug/IO/Storable.pm untested

filter: Statementstmt 0.0% 0 / 37 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 52 CC 4 SCAR 17.6
CC
4
Cov
0%
read
12.0
write
6.0
BEGIN
2.0
CRAP 5.8
1 # Copyright (C) 2004 Jörg Tiedemann <joerg@stp.ling.uu.se>
2 #
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 #####################################################################
17 #
18 # XML
19 #
20 #####################################################################
21 # $Author$
22 # $Id$
23 #
24 # Note: XML without encoding-specification will be treated as latin1!
25 # (look at readFromHandle)
26 #
27  
28 package Uplug::IO::Storable;
29  
30 use strict;
31 use vars qw(@ISA $STOREMAX);
32  
33 use Storable;
34 # $Storable::drop_utf8=1;
35  
36 use Uplug::Encoding;
37 use Uplug::IO;
38  
39 @ISA = qw( Uplug::IO::Text );
40 $STOREMAX = 5000;
41  
42  
43 sub read{
44 my $self=shift;
45 my $data=shift;
46 if (not ref($data)){return 0;}
47 # $data->init;
48 my $fh=$self->{'FileHandle'};
49 binmode($fh);
50 $data->{__STORED__}=Storable::fd_retrieve($fh);
51 if (not ref($data->{__STORED__})){return 0;}
52 foreach (keys %{$data->{__STORED__}}){
53 $data->{$_}=$data->{__STORED__}->{$_};
54 }
55 return 1;
56 }
57  
58  
59 sub write{
60 my $self=shift;
61 my $data=shift;
62 if (not ref($data)){return 0;}
63 my $fh=$self->{'FileHandle'};
64 binmode($fh);
65 my $ref=Storable::store_fd($data,$fh);
66 }
67  
68