summaryrefslogtreecommitdiff
path: root/perl/lib/Data/MessagePack/Unpacker.pod
blob: 04cb0a47aa01aee8f8dc301d1134c0eb8a498b26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
=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>