AMF-Perl
view release on metacpan or search on metacpan
lib/AMF/Perl/IO/Serializer.pm view on Meta::CPAN
package AMF::Perl::IO::Serializer;
# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
# The code is based on the -PHP project (http://amfphp.sourceforge.net/)
=head1 NAME
AMF::Perl::IO::Serializer
=head1 DESCRIPTION
Class used to convert physical perl objects into binary data.
=head1 CHANGES
=head2 Sun May 23 12:35:19 EDT 2004
=item Changed deduceType() to return the value too, as it may be changed inside, and to
handle empty string ('') as a string.
=head2 Wed Apr 14 11:06:28 EDT 2004
=item Made basic data type determination work for both scalars and scalarrefs.
=item Now we check if we are sending a recordset and setting column types accordingly.
=head2 Sat Mar 13 16:25:00 EST 2004
=item Patch from Tilghman Lesher that detects numbers and dates in strings
and sets return type accordingly.
=item Patch from Kostas Chatzikokolakis handling encoding and sending null value.
=head2 Sun May 11 16:43:05 EDT 2003
=item Changed writeData to set type to "NULL" when the incoming data is undef. Previously
it became a String, just like other scalars.
=item Changed PHP's writeRecordset to a generic writeAMFObject. Verified Recordset support.
=head2 Sun Mar 9 18:20:16 EST 2003
=item Function writeObject should return the same as writeHash. This assumes that all meaningful data
are stored as hash keys.
=cut
use strict;
use Encode qw/from_to/;
use DBI;
# holder for the data
my $data;
sub new
{
my ($proto, $stream, $encoding) = @_;
# save
my $self={};
bless $self, $proto;
$self->{out} = $stream;
$self->{encoding} = $encoding;
return $self;
}
sub serialize
{
my ($self, $d) = @_;
$self->{amfout} = $d;
# write the version ???
$self->{out}->writeInt(0);
# get the header count
my $count = $self->{amfout}->numHeader();
# write header count
$self->{out}->writeInt($count);
( run in 1.211 second using v1.01-cache-2.11-cpan-39bf76dae61 )