dslinux/user/perl/lib/DBM_Filter Changes compress.pm encode.pm int32.pm null.pm utf8.pm
cayenne
dslinux_cayenne at user.in-berlin.de
Tue Dec 5 05:27:07 CET 2006
Update of /cvsroot/dslinux/dslinux/user/perl/lib/DBM_Filter
In directory antilope:/tmp/cvs-serv7729/lib/DBM_Filter
Added Files:
Changes compress.pm encode.pm int32.pm null.pm utf8.pm
Log Message:
Adding fresh perl source to HEAD to branch from
--- NEW FILE: encode.pm ---
package DBM_Filter::encode ;
use strict;
use warnings;
use Carp;
our $VERSION = '0.01';
BEGIN
{
eval { require Encode; };
croak "Encode module not found.\n"
if $@;
}
sub Filter
{
my $encoding_name = shift || "utf8";
my $encoding = Encode::find_encoding($encoding_name) ;
croak "Encoding '$encoding_name' is not available"
unless $encoding;
return {
Store => sub {
$_ = $encoding->encode($_)
if defined $_ ;
},
Fetch => sub {
$_ = $encoding->decode($_)
if defined $_ ;
}
} ;
}
1;
__END__
=head1 DBM_Filter::encode
=head1 SYNOPSIS
use SDBM_File; # or DB_File, or GDBM_File, or NDBM_File, or ODBM_File
use DBM_Filter ;
$db = tie %hash, ...
$db->Filter_Push('encode' => 'iso-8859-16');
=head1 DESCRIPTION
This DBM filter allows you to choose the character encoding will be
store in the DBM file. The usage is
$db->Filter_Push('encode' => ENCODING);
where "ENCODING" must be a valid encoding name that the Encode module
recognises.
A fatal error will be thrown if:
=over 5
=item 1
The Encode module is not available.
=item 2
The encoding requested is not supported by the Encode module.
=back
=head1 SEE ALSO
L<DBM_Filter>, L<perldbmfilter>, L<Encode>
=head1 AUTHOR
Paul Marquess pmqs at cpan.org
--- NEW FILE: compress.pm ---
package DBM_Filter::compress ;
use strict;
use warnings;
use Carp;
our $VERSION = '0.01';
BEGIN
{
eval { require Compress::Zlib; Compress::Zlib->import() };
croak "Compress::Zlib module not found.\n"
if $@;
}
sub Store { $_ = compress($_) }
sub Fetch { $_ = uncompress($_) }
1;
__END__
=head1 DBM_Filter::compress
=head1 SYNOPSIS
use SDBM_File; # or DB_File, or GDBM_File, or NDBM_File, or ODBM_File
use DBM_Filter ;
$db = tie %hash, ...
$db->Filter_Push('compress');
=head1 DESCRIPTION
This DBM filter will compress all data before it is written to the database
and uncompressed it on reading.
A fatal error will be thrown if the Compress::Zlib module is not
available.
=head1 SEE ALSO
L<DBM_Filter>, L<perldbmfilter>, L<Compress::Zlib>
=head1 AUTHOR
Paul Marquess pmqs at cpan.org
--- NEW FILE: int32.pm ---
package DBM_Filter::int32 ;
use strict;
use warnings;
our $VERSION = '0.01';
# todo get Filter to figure endian.
sub Store
{
$_ = 0 if ! defined $_ || $_ eq "" ;
$_ = pack("i", $_);
}
sub Fetch
{
no warnings 'uninitialized';
$_ = unpack("i", $_);
}
1;
__END__
=head1 DBM_Filter::int32
=head1 SYNOPSIS
use SDBM_File; # or DB_File, or GDBM_File, or NDBM_File, or ODBM_File
use DBM_Filter ;
$db = tie %hash, ...
$db->Filter_Push('int32');
=head1 DESCRIPTION
This DBM filter is used when interoperating with a C/C++ application
that uses a C int as either the key and/or value in the DBM file.
=head1 SEE ALSO
L<DBM_Filter>, L<perldbmfilter>
=head1 AUTHOR
Paul Marquess pmqs at cpan.org
--- NEW FILE: utf8.pm ---
package DBM_Filter::utf8 ;
use strict;
use warnings;
use Carp;
our $VERSION = '0.01';
BEGIN
{
eval { require Encode; };
croak "Encode module not found.\n"
if $@;
}
sub Store { $_ = Encode::encode_utf8($_) if defined $_ }
sub Fetch { $_ = Encode::decode_utf8($_) if defined $_ }
1;
__END__
=head1 DBM_Filter::utf8
=head1 SYNOPSIS
use SDBM_File; # or DB_File, or GDBM_File, or NDBM_File, or ODBM_File
use DBM_Filter ;
$db = tie %hash, ...
$db->Filter_Push('utf8');
=head1 DESCRIPTION
This Filter will ensure that all data written to the DBM will be encoded
in UTF-8.
This module uses the Encode module.
=head1 SEE ALSO
L<DBM_Filter>, L<perldbmfilter>, L<Encode>
=head1 AUTHOR
Paul Marquess pmqs at cpan.org
--- NEW FILE: null.pm ---
package DBM_Filter::null ;
use strict;
use warnings;
our $VERSION = '0.01';
sub Store
{
no warnings 'uninitialized';
$_ .= "\x00" ;
}
sub Fetch
{
no warnings 'uninitialized';
s/\x00$// ;
}
1;
__END__
=head1 DBM_Filter::null
=head1 SYNOPSIS
use SDBM_File; # or DB_File, or GDBM_File, or NDBM_File, or ODBM_File
use DBM_Filter ;
$db = tie %hash, ...
$db->Filter_Push('null');
=head1 DESCRIPTION
This filter ensures that all data written to the DBM file is null
terminated. This is useful when you have a perl script that needs
to interoperate with a DBM file that a C program also uses. A fairly
common issue is for the C application to include the terminating null
in a string when it writes to the DBM file. This filter will ensure that
all data written to the DBM file can be read by the C application.
=head1 SEE ALSO
L<DBM_Filter>, L<perldbmfilter>
=head1 AUTHOR
Paul Marquess pmqs at cpan.org
--- NEW FILE: Changes ---
Revision history for Perl extension DBM_Filter.
0.01 Sat, 17 Jan 2004
* Original version created.
More information about the dslinux-commit
mailing list