line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TOML::Tiny::Util; |
2
|
|
|
|
|
|
|
# ABSTRACT: utility functions used by TOML::Tiny |
3
|
|
|
|
|
|
|
$TOML::Tiny::Util::VERSION = '0.14'; |
4
|
285
|
|
|
285
|
|
2286
|
use strict; |
|
285
|
|
|
|
|
621
|
|
|
285
|
|
|
|
|
9020
|
|
5
|
285
|
|
|
285
|
|
1523
|
use warnings; |
|
285
|
|
|
|
|
607
|
|
|
285
|
|
|
|
|
8288
|
|
6
|
285
|
|
|
285
|
|
1480
|
no warnings 'experimental'; |
|
285
|
|
|
|
|
608
|
|
|
285
|
|
|
|
|
9622
|
|
7
|
285
|
|
|
285
|
|
3503
|
use v5.18; |
|
285
|
|
|
|
|
1032
|
|
8
|
|
|
|
|
|
|
|
9
|
285
|
|
|
285
|
|
137630
|
use TOML::Tiny::Grammar; |
|
285
|
|
|
|
|
912
|
|
|
285
|
|
|
|
|
77976
|
|
10
|
|
|
|
|
|
|
|
11
|
285
|
|
|
285
|
|
2696
|
use parent 'Exporter'; |
|
285
|
|
|
|
|
624
|
|
|
285
|
|
|
|
|
1415
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
14
|
|
|
|
|
|
|
is_strict_array |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub is_strict_array { |
18
|
0
|
|
|
0
|
0
|
|
my $arr = shift; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my @types = map{ |
21
|
0
|
|
|
|
|
|
my $value = $_; |
|
0
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
my $type; |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
for (ref $value) { |
25
|
0
|
|
|
|
|
|
$type = 'array' when 'ARRAY'; |
26
|
0
|
|
|
|
|
|
$type = 'table' when 'HASH'; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Do a little heuristic guess-work |
29
|
0
|
|
|
|
|
|
$type = 'float' when /Float/; |
30
|
0
|
|
|
|
|
|
$type = 'integer' when /Int/; |
31
|
0
|
|
|
|
|
|
$type = 'bool' when /Boolean/; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
when ('') { |
34
|
0
|
|
|
|
|
|
for ($value) { |
35
|
0
|
|
|
|
|
|
$type = 'bool' when /^$Boolean/; |
36
|
0
|
|
|
|
|
|
$type = 'float' when /^$Float/; |
37
|
0
|
|
|
|
|
|
$type = 'integer' when /^$Integer/; |
38
|
0
|
|
|
|
|
|
$type = 'datetime' when /^$DateTime/; |
39
|
0
|
|
|
|
|
|
default{ $type = 'string' }; |
|
0
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
default{ |
44
|
0
|
|
|
|
|
|
$type = $_; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
$type; |
49
|
|
|
|
|
|
|
} @$arr; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $t = shift @types; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
for (@types) { |
54
|
0
|
0
|
|
|
|
|
return (undef, "expected value of type $t, but found $_") |
55
|
|
|
|
|
|
|
if $_ ne $t; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
return (1, undef); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=pod |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=encoding UTF-8 |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 NAME |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
TOML::Tiny::Util - utility functions used by TOML::Tiny |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 VERSION |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
version 0.14 |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AUTHOR |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Jeff Ober <sysread@fastmail.fm> |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Jeff Ober. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
86
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |