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