| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Data::CompactReadonly::V0::Text; |
|
2
|
|
|
|
|
|
|
our $VERSION = '0.1.0'; |
|
3
|
|
|
|
|
|
|
|
|
4
|
10
|
|
|
10
|
|
78
|
use warnings; |
|
|
10
|
|
|
|
|
25
|
|
|
|
10
|
|
|
|
|
745
|
|
|
5
|
10
|
|
|
10
|
|
61
|
use strict; |
|
|
10
|
|
|
|
|
26
|
|
|
|
10
|
|
|
|
|
391
|
|
|
6
|
10
|
|
|
10
|
|
67
|
use base 'Data::CompactReadonly::V0::Collection'; |
|
|
10
|
|
|
|
|
18
|
|
|
|
10
|
|
|
|
|
5939
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
10
|
|
|
10
|
|
6901
|
use Encode qw(encode decode); |
|
|
10
|
|
|
|
|
194724
|
|
|
|
10
|
|
|
|
|
4992
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub _init { |
|
11
|
618
|
|
|
618
|
|
2533
|
my($class, %args) = @_; |
|
12
|
618
|
|
|
|
|
1798
|
my($root, $offset) = @args{qw(root offset)}; |
|
13
|
|
|
|
|
|
|
|
|
14
|
618
|
|
|
|
|
2347
|
my $length = $class->_numeric_type_for_length()->_init(root => $root, offset => $offset); |
|
15
|
618
|
|
|
|
|
2127
|
my $value = $class->_bytes_to_text($root->_bytes_at_current_offset($length)); |
|
16
|
|
|
|
|
|
|
|
|
17
|
618
|
|
|
|
|
98055
|
return $value; |
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _create { |
|
21
|
65676
|
|
|
65676
|
|
331073
|
my($class, %args) = @_; |
|
22
|
65676
|
|
|
|
|
126643
|
my $fh = $args{fh}; |
|
23
|
65676
|
|
|
|
|
288920
|
$class->_stash_already_seen(%args); |
|
24
|
65676
|
|
|
|
|
414654
|
(my $scalar_type = $class) =~ s/Text/Scalar/; |
|
25
|
65676
|
|
|
|
|
235074
|
my $text = $class->_text_to_bytes($args{data}); |
|
26
|
|
|
|
|
|
|
|
|
27
|
65676
|
|
|
|
|
2461483
|
print $fh $class->_type_byte_from_class(). |
|
28
|
|
|
|
|
|
|
$scalar_type->_get_bytes_from_word(length($text)). |
|
29
|
|
|
|
|
|
|
$text; |
|
30
|
65676
|
|
|
|
|
468904
|
$class->_set_next_free_ptr(%args); |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _bytes_to_text { |
|
34
|
618
|
|
|
618
|
|
1608
|
my($invocant, $bytes) = @_; |
|
35
|
618
|
|
|
|
|
4702
|
return decode('utf-8', $bytes); |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _text_to_bytes { |
|
39
|
131352
|
|
|
131352
|
|
268116
|
my($invocant,$text) = @_; |
|
40
|
131352
|
|
|
|
|
837620
|
return encode('utf-8', $text); |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |