mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-19 21:18:23 +01:00
77 lines
1.4 KiB
Plaintext
77 lines
1.4 KiB
Plaintext
=head1 NAME
|
|
|
|
Data::MessagePack::Unpacker - messagepack streaming deserializer
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
use Data::Dumper;
|
|
my $up = Data::MessagePack::Unpacker->new;
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
This is a streaming deserializer for messagepack.
|
|
|
|
=head1 METHODS
|
|
|
|
=over 4
|
|
|
|
=item my $up = Data::MessagePack::Unpacker->new()
|
|
|
|
creates a new instance of the stream deserializer.
|
|
|
|
=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.
|
|
|
|
The utf8 mode is disabled by default.
|
|
|
|
=item my $ret = $up->get_utf8()
|
|
|
|
returns the utf8 mode flag of I<$up>.
|
|
|
|
=item $offset = $up->execute($data, $offset);
|
|
|
|
=item $offset = $up->execute_limit($data, $offset, $limit)
|
|
|
|
parses unpacked I<$data> from I<$offset> to I<$limit>.
|
|
returns a new offset of I<$data>, which is for the next <execute()>.
|
|
|
|
If I<$data> is insufficient, I<$offset> does not change, saving
|
|
I<$data> in internal buffers.
|
|
|
|
=item my $bool = $up->is_finished();
|
|
|
|
is this deserializer finished?
|
|
|
|
=item my $data = $up->data();
|
|
|
|
returns the deserialized object.
|
|
|
|
=item $up->reset();
|
|
|
|
resets the stream deserializer, without memory zone.
|
|
|
|
=back
|
|
|
|
=head1 AUTHORS
|
|
|
|
Tokuhiro Matsuno
|
|
|
|
=head1 SEE ALSO
|
|
|
|
L<Data::MessagePack>
|
|
|