line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::CompactReadonly::V0::Text; |
2
|
|
|
|
|
|
|
our $VERSION = '0.1.0'; |
3
|
|
|
|
|
|
|
|
4
|
9
|
|
|
9
|
|
68
|
use warnings; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
385
|
|
5
|
9
|
|
|
9
|
|
51
|
use strict; |
|
9
|
|
|
|
|
25
|
|
|
9
|
|
|
|
|
211
|
|
6
|
9
|
|
|
9
|
|
44
|
use base 'Data::CompactReadonly::V0::Collection'; |
|
9
|
|
|
|
|
24
|
|
|
9
|
|
|
|
|
4447
|
|
7
|
|
|
|
|
|
|
|
8
|
9
|
|
|
9
|
|
5291
|
use Encode qw(encode decode); |
|
9
|
|
|
|
|
96700
|
|
|
9
|
|
|
|
|
3004
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub _init { |
11
|
590
|
|
|
590
|
|
1745
|
my($class, %args) = @_; |
12
|
590
|
|
|
|
|
1496
|
my($root, $offset) = @args{qw(root offset)}; |
13
|
|
|
|
|
|
|
|
14
|
590
|
|
|
|
|
1682
|
my $length = $class->_numeric_type_for_length()->_init(root => $root, offset => $offset); |
15
|
590
|
|
|
|
|
1554
|
my $value = $class->_bytes_to_text($root->_bytes_at_current_offset($length)); |
16
|
|
|
|
|
|
|
|
17
|
590
|
|
|
|
|
82933
|
return $value; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _create { |
21
|
65680
|
|
|
65680
|
|
234083
|
my($class, %args) = @_; |
22
|
65680
|
|
|
|
|
132204
|
my $fh = $args{fh}; |
23
|
65680
|
|
|
|
|
259273
|
$class->_stash_already_seen(%args); |
24
|
65680
|
|
|
|
|
420914
|
(my $scalar_type = $class) =~ s/Text/Scalar/; |
25
|
65680
|
|
|
|
|
216267
|
my $text = $class->_text_to_bytes($args{data}); |
26
|
|
|
|
|
|
|
|
27
|
65680
|
|
|
|
|
3088812
|
print $fh $class->_type_byte_from_class(). |
28
|
|
|
|
|
|
|
$scalar_type->_get_bytes_from_word(length($text)). |
29
|
|
|
|
|
|
|
$text; |
30
|
65680
|
|
|
|
|
557598
|
$class->_set_next_free_ptr(%args); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _bytes_to_text { |
34
|
590
|
|
|
590
|
|
1234
|
my($invocant, $bytes) = @_; |
35
|
590
|
|
|
|
|
1659
|
return decode('utf-8', $bytes); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _text_to_bytes { |
39
|
131360
|
|
|
131360
|
|
248230
|
my($invocant,$text) = @_; |
40
|
131360
|
|
|
|
|
377385
|
return encode('utf-8', $text); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |