Initial Commit
This commit is contained in:
64
database/perl/vendor/lib/DBI/Gofer/Serializer/Base.pm
vendored
Normal file
64
database/perl/vendor/lib/DBI/Gofer/Serializer/Base.pm
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
package DBI::Gofer::Serializer::Base;
|
||||
|
||||
# $Id: Base.pm 9949 2007-09-18 09:38:15Z Tim $
|
||||
#
|
||||
# Copyright (c) 2007, Tim Bunce, Ireland
|
||||
#
|
||||
# You may distribute under the terms of either the GNU General Public
|
||||
# License or the Artistic License, as specified in the Perl README file.
|
||||
|
||||
=head1 NAME
|
||||
|
||||
DBI::Gofer::Serializer::Base - base class for Gofer serialization
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
$serializer = $serializer_class->new();
|
||||
|
||||
$string = $serializer->serialize( $data );
|
||||
($string, $deserializer_class) = $serializer->serialize( $data );
|
||||
|
||||
$data = $serializer->deserialize( $string );
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
DBI::Gofer::Serializer::* classes implement a very minimal subset of the L<Data::Serializer> API.
|
||||
|
||||
Gofer serializers are expected to be very fast and are not required to deal
|
||||
with anything other than non-blessed references to arrays and hashes, and plain scalars.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Carp qw(croak);
|
||||
|
||||
our $VERSION = "0.009950";
|
||||
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $deserializer_class = $class->deserializer_class;
|
||||
return bless { deserializer_class => $deserializer_class } => $class;
|
||||
}
|
||||
|
||||
sub deserializer_class {
|
||||
my $self = shift;
|
||||
my $class = ref($self) || $self;
|
||||
$class =~ s/^DBI::Gofer::Serializer:://;
|
||||
return $class;
|
||||
}
|
||||
|
||||
sub serialize {
|
||||
my $self = shift;
|
||||
croak ref($self)." has not implemented the serialize method";
|
||||
}
|
||||
|
||||
sub deserialize {
|
||||
my $self = shift;
|
||||
croak ref($self)." has not implemented the deserialize method";
|
||||
}
|
||||
|
||||
1;
|
||||
53
database/perl/vendor/lib/DBI/Gofer/Serializer/DataDumper.pm
vendored
Normal file
53
database/perl/vendor/lib/DBI/Gofer/Serializer/DataDumper.pm
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
package DBI::Gofer::Serializer::DataDumper;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
our $VERSION = "0.009950";
|
||||
|
||||
# $Id: DataDumper.pm 9949 2007-09-18 09:38:15Z Tim $
|
||||
#
|
||||
# Copyright (c) 2007, Tim Bunce, Ireland
|
||||
#
|
||||
# You may distribute under the terms of either the GNU General Public
|
||||
# License or the Artistic License, as specified in the Perl README file.
|
||||
|
||||
=head1 NAME
|
||||
|
||||
DBI::Gofer::Serializer::DataDumper - Gofer serialization using DataDumper
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
$serializer = DBI::Gofer::Serializer::DataDumper->new();
|
||||
|
||||
$string = $serializer->serialize( $data );
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Uses DataDumper to serialize. Deserialization is not supported.
|
||||
The output of this class is only meant for human consumption.
|
||||
|
||||
See also L<DBI::Gofer::Serializer::Base>.
|
||||
|
||||
=cut
|
||||
|
||||
use Data::Dumper;
|
||||
|
||||
use base qw(DBI::Gofer::Serializer::Base);
|
||||
|
||||
|
||||
sub serialize {
|
||||
my $self = shift;
|
||||
local $Data::Dumper::Indent = 1;
|
||||
local $Data::Dumper::Terse = 1;
|
||||
local $Data::Dumper::Useqq = 0; # enabling this disables xs
|
||||
local $Data::Dumper::Sortkeys = 1;
|
||||
local $Data::Dumper::Quotekeys = 0;
|
||||
local $Data::Dumper::Deparse = 0;
|
||||
local $Data::Dumper::Purity = 0;
|
||||
my $frozen = Data::Dumper::Dumper(shift);
|
||||
return $frozen unless wantarray;
|
||||
return ($frozen, $self->{deserializer_class});
|
||||
}
|
||||
|
||||
1;
|
||||
60
database/perl/vendor/lib/DBI/Gofer/Serializer/Storable.pm
vendored
Normal file
60
database/perl/vendor/lib/DBI/Gofer/Serializer/Storable.pm
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
package DBI::Gofer::Serializer::Storable;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base qw(DBI::Gofer::Serializer::Base);
|
||||
|
||||
# $Id: Storable.pm 15585 2013-03-22 20:31:22Z Tim $
|
||||
#
|
||||
# Copyright (c) 2007, Tim Bunce, Ireland
|
||||
#
|
||||
# You may distribute under the terms of either the GNU General Public
|
||||
# License or the Artistic License, as specified in the Perl README file.
|
||||
|
||||
=head1 NAME
|
||||
|
||||
DBI::Gofer::Serializer::Storable - Gofer serialization using Storable
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
$serializer = DBI::Gofer::Serializer::Storable->new();
|
||||
|
||||
$string = $serializer->serialize( $data );
|
||||
($string, $deserializer_class) = $serializer->serialize( $data );
|
||||
|
||||
$data = $serializer->deserialize( $string );
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Uses Storable::nfreeze() to serialize and Storable::thaw() to deserialize.
|
||||
|
||||
The serialize() method sets local $Storable::forgive_me = 1; so it doesn't
|
||||
croak if it encounters any data types that can't be serialized, such as code refs.
|
||||
|
||||
See also L<DBI::Gofer::Serializer::Base>.
|
||||
|
||||
=cut
|
||||
|
||||
use Storable qw(nfreeze thaw);
|
||||
|
||||
our $VERSION = "0.015586";
|
||||
|
||||
use base qw(DBI::Gofer::Serializer::Base);
|
||||
|
||||
|
||||
sub serialize {
|
||||
my $self = shift;
|
||||
local $Storable::forgive_me = 1; # for CODE refs etc
|
||||
local $Storable::canonical = 1; # for go_cache
|
||||
my $frozen = nfreeze(shift);
|
||||
return $frozen unless wantarray;
|
||||
return ($frozen, $self->{deserializer_class});
|
||||
}
|
||||
|
||||
sub deserialize {
|
||||
my $self = shift;
|
||||
return thaw(shift);
|
||||
}
|
||||
|
||||
1;
|
||||
Reference in New Issue
Block a user