77 lines
1.4 KiB
Plaintext
Raw Normal View History

2009-04-15 12:55:41 +09:00
=head1 NAME
Data::MessagePack::Unpacker - messagepack streaming deserializer
=head1 SYNOPSIS
use Data::Dumper;
my $up = Data::MessagePack::Unpacker->new;
2010-10-28 17:26:04 +09:00
open my $fh, $data or die $!;
my $offset = 0;
while( read($fh, my $buf, 1024) ) {
$offset = $up->execute($buf, $offset);
if($up->is_finished) {
print Dumper($up->data);
}
2009-04-15 12:55:41 +09:00
}
=head1 DESCRIPTION
This is a streaming deserializer for messagepack.
2009-04-15 12:55:41 +09:00
=head1 METHODS
=over 4
=item my $up = Data::MessagePack::Unpacker->new()
2010-10-28 17:26:04 +09:00
creates a new instance of the stream deserializer.
2009-04-15 12:55:41 +09:00
=item $up->utf8([$bool])
sets utf8 mode. true if I<$bool> is omitted.
returns I<$up> itself.
If utf8 mode is enabled, strings will be decoded as UTF-8.
2010-10-05 17:47:27 +09:00
The utf8 mode is disabled by default.
=item my $ret = $up->get_utf8()
returns the utf8 mode flag of I<$up>.
2010-10-28 17:26:04 +09:00
=item $offset = $up->execute($data, $offset);
2009-04-15 12:55:41 +09:00
2010-10-28 17:26:04 +09:00
=item $offset = $up->execute_limit($data, $offset, $limit)
2009-04-15 12:55:41 +09:00
2010-10-28 17:26:04 +09:00
parses unpacked I<$data> from I<$offset> to I<$limit>.
returns a new offset of I<$data>, which is for the next <execute()>.
2010-05-03 01:09:21 +09:00
2010-10-28 17:26:04 +09:00
If I<$data> is insufficient, I<$offset> does not change, saving
I<$data> in internal buffers.
2010-05-03 01:09:21 +09:00
=item my $bool = $up->is_finished();
2009-04-15 12:55:41 +09:00
is this deserializer finished?
2010-05-03 01:09:21 +09:00
=item my $data = $up->data();
2009-04-15 12:55:41 +09:00
returns the deserialized object.
2009-04-15 12:55:41 +09:00
2010-05-03 01:09:21 +09:00
=item $up->reset();
2009-04-15 12:55:41 +09:00
resets the stream deserializer, without memory zone.
2009-04-15 12:55:41 +09:00
=back
=head1 AUTHORS
Tokuhiro Matsuno
=head1 SEE ALSO
L<Data::MessagePack>