mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-20 21:39:53 +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;
|
use Data::Dumper;
|
||||||
my $up = Data::MessagePack::Unpacker->new;
|
my $up = Data::MessagePack::Unpacker->new;
|
||||||
my $ret = $up->execute($v, 0);
|
|
||||||
if ($ret != length($v)) {
|
open my $fh, $data or die $!;
|
||||||
fail "extra bytes";
|
|
||||||
|
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
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
@ -22,7 +27,7 @@ This is a streaming deserializer for messagepack.
|
|||||||
|
|
||||||
=item my $up = Data::MessagePack::Unpacker->new()
|
=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])
|
=item $up->utf8([$bool])
|
||||||
|
|
||||||
@ -37,14 +42,15 @@ The utf8 mode is disabled by default.
|
|||||||
|
|
||||||
returns the utf8 mode flag of I<$up>.
|
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);
|
parses unpacked I<$data> from I<$offset> to I<$limit>.
|
||||||
$up->execute($data, 3);
|
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();
|
=item my $bool = $up->is_finished();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user