line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CBOR::Free::SequenceDecoder; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
120577
|
use strict; |
|
5
|
|
|
|
|
20
|
|
|
5
|
|
|
|
|
147
|
|
4
|
5
|
|
|
5
|
|
25
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
179
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=encoding utf-8 |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
CBOR::Free::SequenceDecoder |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $decoder = CBOR::Free::SequenceDecoder->new(); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
if ( my $got_sr = $decoder->give( $some_cbor ) ) { |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Do something with your decoded CBOR. |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
while (my $got_sr = $decoder->get()) { |
22
|
|
|
|
|
|
|
# Do something with your decoded CBOR. |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 DESCRIPTION |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
This module implements a parser for CBOR Sequences |
28
|
|
|
|
|
|
|
(L). |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
33
|
|
|
|
|
|
|
|
34
|
5
|
|
|
5
|
|
33
|
use parent qw( CBOR::Free::Decoder::Base ); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
26
|
|
35
|
|
|
|
|
|
|
|
36
|
5
|
|
|
5
|
|
758
|
use CBOR::Free; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
193
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 METHODS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
This module implements the following methods in common |
43
|
|
|
|
|
|
|
with L: |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=over |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item * C |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=item * C |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=item * C |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item * C |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=item * C |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item * C |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item * C |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=back |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Additionally, the following exist: |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 $got_sr = I->give( $CBOR ); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Adds some bytes ($CBOR) to the decoder’s internal CBOR buffer. |
68
|
|
|
|
|
|
|
Returns either: |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=over |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item * a B to the (parsed) first CBOR document in the |
73
|
|
|
|
|
|
|
internal buffer |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item * undef, if there is no such document |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=back |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Note that if your decoded CBOR document’s root element is already a reference |
80
|
|
|
|
|
|
|
(e.g., an array or hash reference), then the return value is a reference |
81
|
|
|
|
|
|
|
B that reference. So, for example, if you expect all documents in your |
82
|
|
|
|
|
|
|
stream to be array references, you could do: |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
if ( my $got_sr = $decoder->give( $some_cbor ) ) { |
85
|
|
|
|
|
|
|
my @decoded_array = @{ $$got_sr }; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# … |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 $got_sr = I->get(); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Like C but doesn’t append onto the internal CBOR buffer. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |