line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
27
|
use strict;
|
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
161
|
|
2
|
5
|
|
|
5
|
|
26
|
use warnings;
|
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
5056
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Data::ParseBinary::Stream::StringRefReader;
|
5
|
|
|
|
|
|
|
our @ISA = qw{Data::ParseBinary::Stream::Reader};
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
__PACKAGE__->_registerStreamType("StringRef");
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new {
|
10
|
120
|
|
|
120
|
|
188
|
my ($class, $stringref) = @_;
|
11
|
120
|
|
|
|
|
532
|
my $self = {
|
12
|
|
|
|
|
|
|
data => $stringref,
|
13
|
|
|
|
|
|
|
location => 0,
|
14
|
|
|
|
|
|
|
length => length($$stringref),
|
15
|
|
|
|
|
|
|
};
|
16
|
120
|
|
|
|
|
850
|
return bless $self, $class;
|
17
|
|
|
|
|
|
|
}
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub ReadBytes {
|
20
|
359
|
|
|
359
|
|
478
|
my ($self, $count) = @_;
|
21
|
359
|
100
|
|
|
|
993
|
die "not enought bytes in stream" if $self->{location} + $count > $self->{length};
|
22
|
356
|
|
|
|
|
378
|
my $data = substr(${ $self->{data} }, $self->{location}, $count);
|
|
356
|
|
|
|
|
851
|
|
23
|
356
|
|
|
|
|
619
|
$self->{location} += $count;
|
24
|
356
|
|
|
|
|
1155
|
return $data;
|
25
|
|
|
|
|
|
|
}
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub ReadBits {
|
28
|
9
|
|
|
9
|
|
12
|
my ($self, $bitcount) = @_;
|
29
|
9
|
|
|
|
|
31
|
return $self->_readBitsForByteStream($bitcount);
|
30
|
|
|
|
|
|
|
}
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub tell {
|
33
|
31
|
|
|
31
|
|
52
|
my $self = shift;
|
34
|
31
|
|
|
|
|
93
|
return $self->{location};
|
35
|
|
|
|
|
|
|
}
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub seek {
|
38
|
29
|
|
|
29
|
|
46
|
my ($self, $newpos) = @_;
|
39
|
29
|
50
|
|
|
|
68
|
die "can not seek past string's end" if $newpos > $self->{length};
|
40
|
29
|
|
|
|
|
60
|
$self->{location} = $newpos;
|
41
|
|
|
|
|
|
|
}
|
42
|
|
|
|
|
|
|
|
43
|
22
|
|
|
22
|
|
94
|
sub isBitStream { return 0 };
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
package Data::ParseBinary::Stream::StringReader;
|
46
|
|
|
|
|
|
|
our @ISA = qw{Data::ParseBinary::Stream::StringRefReader};
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__PACKAGE__->_registerStreamType("String");
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub new {
|
51
|
113
|
|
|
113
|
|
324
|
my ($class, $string) = @_;
|
52
|
113
|
|
|
|
|
399
|
return $class->SUPER::new(\$string);
|
53
|
|
|
|
|
|
|
}
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
package Data::ParseBinary::Stream::StringRefWriter;
|
56
|
|
|
|
|
|
|
our @ISA = qw{Data::ParseBinary::Stream::Writer};
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__PACKAGE__->_registerStreamType("StringRef");
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub new {
|
61
|
136
|
|
|
136
|
|
230
|
my ($class, $source) = @_;
|
62
|
136
|
50
|
|
|
|
322
|
if (not defined $source) {
|
63
|
0
|
|
|
|
|
0
|
my $data = '';
|
64
|
0
|
|
|
|
|
0
|
$source = \$data;
|
65
|
|
|
|
|
|
|
}
|
66
|
136
|
|
|
|
|
437
|
my $self = {
|
67
|
|
|
|
|
|
|
data => $source,
|
68
|
|
|
|
|
|
|
offset => 0, # minus bytes from the end
|
69
|
|
|
|
|
|
|
};
|
70
|
136
|
|
|
|
|
777
|
return bless $self, $class;
|
71
|
|
|
|
|
|
|
}
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub tell {
|
74
|
128
|
|
|
128
|
|
167
|
my $self = shift;
|
75
|
128
|
|
|
|
|
147
|
return length(${ $self->{data} }) - $self->{offset};
|
|
128
|
|
|
|
|
709
|
|
76
|
|
|
|
|
|
|
}
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub seek {
|
79
|
124
|
|
|
124
|
|
167
|
my ($self, $newpos) = @_;
|
80
|
124
|
100
|
|
|
|
422
|
if ($newpos > length(${ $self->{data} })) {
|
|
124
|
|
|
|
|
494
|
|
81
|
7
|
|
|
|
|
10
|
$self->{offset} = 0;
|
82
|
7
|
|
|
|
|
18
|
${ $self->{data} } .= "\0" x ($newpos - length(${ $self->{data} }))
|
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
35
|
|
83
|
|
|
|
|
|
|
} else {
|
84
|
117
|
|
|
|
|
185
|
$self->{offset} = length(${ $self->{data} }) - $newpos;
|
|
117
|
|
|
|
|
532
|
|
85
|
|
|
|
|
|
|
}
|
86
|
|
|
|
|
|
|
}
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub WriteBytes {
|
89
|
3560
|
|
|
3560
|
|
1045236
|
my ($self, $data) = @_;
|
90
|
3560
|
100
|
|
|
|
7891
|
if ($self->{offset} == 0) {
|
91
|
3074
|
|
|
|
|
3518
|
${ $self->{data} } .= $data;
|
|
3074
|
|
|
|
|
615846
|
|
92
|
3074
|
|
|
|
|
3779
|
return length ${ $self->{data} };
|
|
3074
|
|
|
|
|
9516
|
|
93
|
|
|
|
|
|
|
}
|
94
|
486
|
|
|
|
|
818
|
substr(${ $self->{data} }, -$self->{offset}, length($data), $data);
|
|
486
|
|
|
|
|
1616
|
|
95
|
486
|
100
|
|
|
|
1026
|
if ($self->{offset} <= length($data)) {
|
96
|
1
|
|
|
|
|
4
|
$self->{offset} = 0;
|
97
|
|
|
|
|
|
|
} else {
|
98
|
485
|
|
|
|
|
1168
|
$self->{offset} = $self->{offset} - length($data);
|
99
|
|
|
|
|
|
|
}
|
100
|
486
|
|
|
|
|
3821
|
return length(${ $self->{data} }) - $self->{offset};
|
|
486
|
|
|
|
|
1439
|
|
101
|
|
|
|
|
|
|
}
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub WriteBits {
|
104
|
9
|
|
|
9
|
|
13
|
my ($self, $bitdata) = @_;
|
105
|
9
|
|
|
|
|
34
|
return $self->_writeBitsForByteStream($bitdata);
|
106
|
|
|
|
|
|
|
}
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub Flush {
|
109
|
272
|
|
|
272
|
|
672
|
my $self = shift;
|
110
|
272
|
|
|
|
|
13517
|
return $self->{data};
|
111
|
|
|
|
|
|
|
}
|
112
|
|
|
|
|
|
|
|
113
|
381
|
|
|
381
|
|
1046
|
sub isBitStream { return 0 };
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
package Data::ParseBinary::Stream::StringWriter;
|
116
|
|
|
|
|
|
|
our @ISA = qw{Data::ParseBinary::Stream::StringRefWriter};
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
__PACKAGE__->_registerStreamType("String");
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub new {
|
121
|
134
|
|
|
134
|
|
239
|
my ($class, $source) = @_;
|
122
|
134
|
100
|
|
|
|
352
|
$source = '' unless defined $source;
|
123
|
134
|
|
|
|
|
491
|
return $class->SUPER::new(\$source);
|
124
|
|
|
|
|
|
|
}
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub Flush {
|
127
|
267
|
|
|
267
|
|
353
|
my $self = shift;
|
128
|
267
|
|
|
|
|
633
|
my $data = $self->SUPER::Flush();
|
129
|
267
|
|
|
|
|
1358
|
return $$data;
|
130
|
|
|
|
|
|
|
}
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
1; |