line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Data::Plist::Reader - Abstract superclass for BinaryReader |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# Create new |
8
|
|
|
|
|
|
|
$read = Data::Plist::BinaryReader->new; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# Reading from a string C<$str> |
11
|
|
|
|
|
|
|
my $plist = $read->open_string($str); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Writing from file C<$filename> |
14
|
|
|
|
|
|
|
$plist = $read->read($filename); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
C is an abstract superclass of |
19
|
|
|
|
|
|
|
BinaryReader. Takes either a string or a filehandle containing data |
20
|
|
|
|
|
|
|
formatted as an Apple property list and returns it as a |
21
|
|
|
|
|
|
|
C. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
package Data::Plist::Reader; |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
4
|
|
19
|
use strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
111
|
|
28
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
744
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 METHODS |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 new |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Create a new reader. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub new { |
39
|
28
|
|
|
28
|
1
|
205
|
my $class = shift; |
40
|
28
|
|
|
|
|
77
|
return bless {} => $class; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 open_string $content |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Takes binary data C<$content> and reads it into a |
46
|
|
|
|
|
|
|
filehandle. Then passes that filehandle to L. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub open_string { |
51
|
45
|
|
|
45
|
1
|
52
|
my $self = shift; |
52
|
45
|
|
|
|
|
59
|
my ($content) = @_; |
53
|
|
|
|
|
|
|
|
54
|
45
|
|
|
|
|
46
|
my $fh; |
55
|
45
|
|
|
1
|
|
394
|
open( $fh, "<", \$content ); |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
56
|
45
|
|
|
|
|
1490
|
return $self->open_fh($fh); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 open_file $filename |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Takes a filename C<$filename> and reads its data into a |
62
|
|
|
|
|
|
|
filehandle. Then passes the filehandle to L. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub open_file { |
67
|
3
|
|
|
3
|
1
|
1124
|
my $self = shift; |
68
|
3
|
|
|
|
|
5
|
my ($filename) = @_; |
69
|
|
|
|
|
|
|
|
70
|
3
|
|
|
|
|
2
|
my $fh; |
71
|
3
|
50
|
|
|
|
142
|
open( $fh, "<", $filename ) or die "can't open $filename for conversion"; |
72
|
3
|
|
|
|
|
5
|
binmode($fh); |
73
|
3
|
|
|
|
|
10
|
return $self->open_fh($fh); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 open_fh |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Place-holder method for Reader's subclass. Currently |
79
|
|
|
|
|
|
|
unimplemented. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub open_fh { |
84
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
0
|
die "Unimplemented!"; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |