| 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<Data::Plist::Reader> 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<Data::Plist>. | ||||||||||
| 22 | |||||||||||
| 23 | =cut | ||||||||||
| 24 | |||||||||||
| 25 | package Data::Plist::Reader; | ||||||||||
| 26 | |||||||||||
| 27 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 29 | |||||||||||
| 30 | =head1 METHODS | ||||||||||
| 31 | |||||||||||
| 32 | =head2 new | ||||||||||
| 33 | |||||||||||
| 34 | Create a new reader. | ||||||||||
| 35 | |||||||||||
| 36 | =cut | ||||||||||
| 37 | |||||||||||
| 38 | 30 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 39 | 30 | my $class = shift; | |||||||||
| 40 | 30 | 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</open_fh>. | ||||||||||
| 47 | |||||||||||
| 48 | =cut | ||||||||||
| 49 | |||||||||||
| 50 | 46 | ▶ | sub open_string { | ||||||||
|
Subroutine
open_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 51 | 46 | my $self = shift; | |||||||||
| 52 | 46 | my ($content) = @_; | |||||||||
| 53 | |||||||||||
| 54 | 46 | my $fh; | |||||||||
| 55 | 46 | open( $fh, "<", \$content ); | |||||||||
| 56 | 46 | 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</open_fh>. | ||||||||||
| 63 | |||||||||||
| 64 | =cut | ||||||||||
| 65 | |||||||||||
| 66 | 4 | ▶ | sub open_file { | ||||||||
|
Subroutine
open_file: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 67 | 4 | my $self = shift; | |||||||||
| 68 | 4 | my ($filename) = @_; | |||||||||
| 69 | |||||||||||
| 70 | 4 | my $fh; | |||||||||
| 71 | 4 | ▶ | open( $fh, "<", $filename ) or die "can't open $filename for conversion"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 72 | 4 | binmode($fh); | |||||||||
| 73 | 4 | 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 | 0 | ▶ | sub open_fh { | ||||||||
|
Subroutine
open_fh: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 84 | 0 | my $self = shift; | |||||||||
| 85 | |||||||||||
| 86 | 0 | die "Unimplemented!"; | |||||||||
| 87 | } | ||||||||||
| 88 | |||||||||||
| 89 | 4 | 1; | |||||||||