mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-20 13:33:51 +01:00
perl: update Unpacker.pod
This commit is contained in:
parent
ea36ef3107
commit
c320e44a23
@ -6,11 +6,16 @@ Data::MessagePack::Unpacker - messagepack streaming deserializer
|
||||
|
||||
use Data::Dumper;
|
||||
my $up = Data::MessagePack::Unpacker->new;
|
||||
my $ret = $up->execute($v, 0);
|
||||
if ($ret != length($v)) {
|
||||
fail "extra bytes";
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
return Dumper($up->data);
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
@ -22,7 +27,7 @@ This is a streaming deserializer for messagepack.
|
||||
|
||||
=item my $up = Data::MessagePack::Unpacker->new()
|
||||
|
||||
creates a new instance of stream deserializer.
|
||||
creates a new instance of the stream deserializer.
|
||||
|
||||
=item $up->utf8([$bool])
|
||||
|
||||
@ -37,14 +42,15 @@ The utf8 mode is disabled by default.
|
||||
|
||||
returns the utf8 mode flag of I<$up>.
|
||||
|
||||
=item my $ret = $up->execute($data, $offset);
|
||||
=item $offset = $up->execute($data, $offset);
|
||||
|
||||
=item my $ret = $up->execute_limit($data, $offset, $limit)
|
||||
=item $offset = $up->execute_limit($data, $offset, $limit)
|
||||
|
||||
$up->execute(substr($data, 0, 3), 0);
|
||||
$up->execute($data, 3);
|
||||
parses unpacked I<$data> from I<$offset> to I<$limit>.
|
||||
returns a new offset of I<$data>, which is for the next <execute()>.
|
||||
|
||||
$offset is the offset of $data.
|
||||
If I<$data> is insufficient, I<$offset> does not change, saving
|
||||
I<$data> in internal buffers.
|
||||
|
||||
=item my $bool = $up->is_finished();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user