| 1 | package DBI::Gofer::Serializer::Base; | ||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||
| 3 | # $Id: Base.pm 9949 2007-09-18 09:38:15Z Tim $ | ||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||
| 5 | # Copyright (c) 2007, Tim Bunce, Ireland | ||||||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||||||
| 7 | # You may distribute under the terms of either the GNU General Public | ||||||||||||||||||||||||||||||||||||||
| 8 | # License or the Artistic License, as specified in the Perl README file. | ||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||
| 10 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||
| 12 | DBI::Gofer::Serializer::Base - base class for Gofer serialization | ||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||
| 14 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||
| 16 | $serializer = $serializer_class->new(); | ||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||
| 18 | $string = $serializer->serialize( $data ); | ||||||||||||||||||||||||||||||||||||||
| 19 | ($string, $deserializer_class) = $serializer->serialize( $data ); | ||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||
| 21 | $data = $serializer->deserialize( $string ); | ||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||
| 23 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||
| 25 | DBI::Gofer::Serializer::* classes implement a very minimal subset of the L<Data::Serializer> API. | ||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||
| 27 | Gofer serializers are expected to be very fast and are not required to deal | ||||||||||||||||||||||||||||||||||||||
| 28 | with anything other than non-blessed references to arrays and hashes, and plain scalars. | ||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||
| 30 | =cut | ||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||
| 33 | 63 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 34 | 63 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||
| 36 | 63 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||
| 38 | our $VERSION = "0.009950"; | ||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||
| 41 | 746 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=1.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=1.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my $deserializer_class = $class->deserializer_class; | |||||||||||||||||||||||||||||||||||||
| 44 | 0 | return bless { deserializer_class => $deserializer_class } => $class; | |||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||
| 47 | 746 | ▶ | sub deserializer_class { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
deserializer_class: called CC=2 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
deserializer_class: not called CC=2 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | my $class = ref($self) || $self; | ||||||||||||||||||||||||||||||||||||
|
Condition16%1/6
ref $self || $self
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||
| 50 | 0 | $class =~ s/^DBI::Gofer::Serializer:://; | |||||||||||||||||||||||||||||||||||||
| 51 | 0 | return $class; | |||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub serialize { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
serialize: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
serialize: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 56 | 0 | croak ref($self)." has not implemented the serialize method"; | |||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub deserialize { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
deserialize: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
deserialize: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 61 | 0 | croak ref($self)." has not implemented the deserialize method"; | |||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||
| 64 | 1; | ||||||||||||||||||||||||||||||||||||||