line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::CompactReadonly::V0::Text; |
2
|
|
|
|
|
|
|
our $VERSION = '0.0.6'; |
3
|
|
|
|
|
|
|
|
4
|
9
|
|
|
9
|
|
55
|
use warnings; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
277
|
|
5
|
9
|
|
|
9
|
|
45
|
use strict; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
172
|
|
6
|
9
|
|
|
9
|
|
38
|
use base 'Data::CompactReadonly::V0::Collection'; |
|
9
|
|
|
|
|
29
|
|
|
9
|
|
|
|
|
3837
|
|
7
|
|
|
|
|
|
|
|
8
|
9
|
|
|
9
|
|
4691
|
use Encode qw(encode decode); |
|
9
|
|
|
|
|
81552
|
|
|
9
|
|
|
|
|
2487
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub _init { |
11
|
568
|
|
|
568
|
|
1340
|
my($class, %args) = @_; |
12
|
568
|
|
|
|
|
1172
|
my($root, $offset) = @args{qw(root offset)}; |
13
|
|
|
|
|
|
|
|
14
|
568
|
|
|
|
|
1347
|
my $length = $class->_numeric_type_for_length()->_init(root => $root, offset => $offset); |
15
|
568
|
|
|
|
|
1189
|
my $value = $class->_bytes_to_text($root->_bytes_at_current_offset($length)); |
16
|
|
|
|
|
|
|
|
17
|
568
|
|
|
|
|
72652
|
return $value; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _create { |
21
|
65667
|
|
|
65667
|
|
185352
|
my($class, %args) = @_; |
22
|
65667
|
|
|
|
|
88595
|
my $fh = $args{fh}; |
23
|
65667
|
|
|
|
|
196490
|
$class->_stash_already_seen(%args); |
24
|
65667
|
|
|
|
|
301356
|
(my $scalar_type = $class) =~ s/Text/Scalar/; |
25
|
65667
|
|
|
|
|
178660
|
my $text = $class->_text_to_bytes($args{data}); |
26
|
|
|
|
|
|
|
|
27
|
65667
|
|
|
|
|
2400241
|
print $fh $class->_type_byte_from_class(). |
28
|
|
|
|
|
|
|
$scalar_type->_get_bytes_from_word(length($text)). |
29
|
|
|
|
|
|
|
$text; |
30
|
65667
|
|
|
|
|
439385
|
$class->_set_next_free_ptr(%args); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _bytes_to_text { |
34
|
568
|
|
|
568
|
|
926
|
my($invocant, $bytes) = @_; |
35
|
568
|
|
|
|
|
1357
|
return decode('utf-8', $bytes); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _text_to_bytes { |
39
|
131334
|
|
|
131334
|
|
203586
|
my($invocant,$text) = @_; |
40
|
131334
|
|
|
|
|
285039
|
return encode('utf-8', $text); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |