AMF-Perl
view release on metacpan or search on metacpan
lib/AMF/Perl/IO/Deserializer.pm view on Meta::CPAN
package AMF::Perl::IO::Deserializer;
# 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::Deserializer
=head1 DESCRIPTION
Package used to turn the binary data into physical perl objects.
=head1 CHANGES
=head2 Sun Sep 19 13:01:35 EDT 2004
=item Patch from Kostas Chatzikokolakis about error checking of input data length.
=head2 Sat Mar 13 16:31:31 EST 2004
=item Patch from Kostas Chatzikokolakis handling encoding.
=head2 Sun Mar 9 18:17:31 EST 2003
=item The return value of readArray should be \@ret, not @ret.
=head2 Tue Mar 11 21:55:41 EST 2003
=item Fixed reading keys of objects.
=item Added floor(), as Perl lacks it.
=head2 Sun Apr 6 14:24:00 2003
=item Added code to read objects of type 8. Useful for decoding real AMF server packages, but hardly anywhere else.
=cut
use strict;
use Encode qw/from_to/;
# the number of headers in the packet
my $header_count;
# the content of the headers
my $headers;
# the number of body elements
my $body_count;
# the content of the body
my $body;
sub floor
{
my $n = shift;
return int($n) - ($n < 0 ? 1: 0) * ($n != int($n) ? 1 : 0);
}
#******************** PUBLIC METHODS ****************************/
# constructor that also dserializes the raw data
sub new
{
my ($proto, $is, $encoding)=@_;
my $self = {};
bless $self, $proto;
# the object to store the deserialized data
$self->{amfdata} = new AMF::Perl::Util::Object();
# save the input stream in this object
$self->{inputStream} = $is;
# save the encoding in this object
$self->{encoding} = $encoding;
# read the binary header
$self->readHeader();
# read the binary body
$self->readBody();
( run in 1.264 second using v1.01-cache-2.11-cpan-39bf76dae61 )