line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MaxMind::DB::Types; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
6
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
42
|
|
4
|
2
|
|
|
2
|
|
5
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
59
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.040001'; |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
6
|
use Carp qw( confess ); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
86
|
|
9
|
2
|
|
|
2
|
|
6
|
use Exporter qw( import ); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
38
|
|
10
|
2
|
|
|
2
|
|
1019
|
use List::AllUtils; |
|
2
|
|
|
|
|
28162
|
|
|
2
|
|
|
|
|
166
|
|
11
|
2
|
|
|
2
|
|
18
|
use Scalar::Util (); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
41
|
|
12
|
2
|
|
|
2
|
|
1279
|
use Sub::Quote qw( quote_sub ); |
|
2
|
|
|
|
|
4685
|
|
|
2
|
|
|
|
|
90
|
|
13
|
2
|
|
|
2
|
|
9
|
use overload (); |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
612
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
16
|
|
|
|
|
|
|
ArrayRefOfStr |
17
|
|
|
|
|
|
|
Bool |
18
|
|
|
|
|
|
|
Decoder |
19
|
|
|
|
|
|
|
Epoch |
20
|
|
|
|
|
|
|
FileHandle |
21
|
|
|
|
|
|
|
HashRef |
22
|
|
|
|
|
|
|
HashRefOfStr |
23
|
|
|
|
|
|
|
Int |
24
|
|
|
|
|
|
|
Metadata |
25
|
|
|
|
|
|
|
Str |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
## no critic (NamingConventions::Capitalization, ValuesAndExpressions::ProhibitImplicitNewlines) |
29
|
|
|
|
|
|
|
{ |
30
|
|
|
|
|
|
|
my $t = quote_sub( |
31
|
|
|
|
|
|
|
q{ |
32
|
|
|
|
|
|
|
( |
33
|
|
|
|
|
|
|
defined $_[0] |
34
|
|
|
|
|
|
|
&& Scalar::Util::reftype( $_[0] ) eq 'ARRAY' |
35
|
|
|
|
|
|
|
&& List::AllUtils::all( |
36
|
|
|
|
|
|
|
sub { defined $_ && !ref $_ }, |
37
|
|
|
|
|
|
|
@{ $_[0] } |
38
|
|
|
|
|
|
|
) |
39
|
|
|
|
|
|
|
) |
40
|
|
|
|
|
|
|
or MaxMind::DB::Types::_confess( |
41
|
|
|
|
|
|
|
'%s is not an arrayref', |
42
|
|
|
|
|
|
|
$_[0] |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
2
|
|
|
2
|
0
|
11
|
sub ArrayRefOfStr () { $t } |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
{ |
51
|
|
|
|
|
|
|
my $t = quote_sub( |
52
|
|
|
|
|
|
|
q{ |
53
|
|
|
|
|
|
|
( !defined $_[0] || $_[0] eq q{} || "$_[0]" eq '1' || "$_[0]" eq '0' ) |
54
|
|
|
|
|
|
|
or MaxMind::DB::Types::_confess( |
55
|
|
|
|
|
|
|
'%s is not a boolean', |
56
|
|
|
|
|
|
|
$_[0] |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
0
|
0
|
0
|
sub Bool () { $t } |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
{ |
65
|
|
|
|
|
|
|
my $t = _object_isa_type('MaxMind::DB::Reader::Decoder'); |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
0
|
0
|
0
|
sub Decoder () { $t } |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
{ |
71
|
|
|
|
|
|
|
my $t = quote_sub( |
72
|
|
|
|
|
|
|
q{ |
73
|
|
|
|
|
|
|
( |
74
|
|
|
|
|
|
|
defined $_[0] && ( ( !ref $_[0] && $_[0] =~ /^[0-9]+$/ ) |
75
|
|
|
|
|
|
|
|| ( Scalar::Util::blessed( $_[0] ) |
76
|
|
|
|
|
|
|
&& ( $_[0]->isa('Math::UInt128') || $_[0]->isa('Math::BigInt') ) ) |
77
|
|
|
|
|
|
|
) |
78
|
|
|
|
|
|
|
) |
79
|
|
|
|
|
|
|
or MaxMind::DB::Types::_confess( |
80
|
|
|
|
|
|
|
'%s is not an integer, a Math::UInt128 object, or a Math::BigInt object', |
81
|
|
|
|
|
|
|
$_[0] |
82
|
|
|
|
|
|
|
); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
); |
85
|
|
|
|
|
|
|
|
86
|
2
|
|
|
2
|
0
|
6
|
sub Epoch () { $t } |
87
|
|
|
|
|
|
|
|
88
|
10
|
|
|
10
|
0
|
31
|
sub Int () { $t } |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
{ |
92
|
|
|
|
|
|
|
my $t = quote_sub( |
93
|
|
|
|
|
|
|
q{ |
94
|
|
|
|
|
|
|
( ( defined $_[0] && Scalar::Util::openhandle( $_[0] ) ) |
95
|
|
|
|
|
|
|
|| ( Scalar::Util::blessed( $_[0] ) && $_[0]->isa('IO::Handle') ) ) |
96
|
|
|
|
|
|
|
or MaxMind::DB::Types::_confess( |
97
|
|
|
|
|
|
|
'%s is not a file handle', |
98
|
|
|
|
|
|
|
$_[0] |
99
|
|
|
|
|
|
|
); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
); |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
0
|
0
|
0
|
sub FileHandle () { $t } |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
{ |
107
|
|
|
|
|
|
|
my $t = quote_sub( |
108
|
|
|
|
|
|
|
q{ |
109
|
|
|
|
|
|
|
( defined $_[0] && Scalar::Util::reftype( $_[0] ) eq 'HASH' ) |
110
|
|
|
|
|
|
|
or MaxMind::DB::Types::_confess( |
111
|
|
|
|
|
|
|
'%s is not a hashref', |
112
|
|
|
|
|
|
|
$_[0] |
113
|
|
|
|
|
|
|
); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
); |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
0
|
0
|
0
|
sub HashRef () { $t } |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
{ |
121
|
|
|
|
|
|
|
my $t = quote_sub( |
122
|
|
|
|
|
|
|
q{ |
123
|
|
|
|
|
|
|
( |
124
|
|
|
|
|
|
|
defined $_[0] |
125
|
|
|
|
|
|
|
&& Scalar::Util::reftype( $_[0] ) eq 'HASH' |
126
|
|
|
|
|
|
|
&& &List::AllUtils::all( |
127
|
|
|
|
|
|
|
sub { defined $_ && !ref $_ }, values %{ $_[0] } |
128
|
|
|
|
|
|
|
) |
129
|
|
|
|
|
|
|
) |
130
|
|
|
|
|
|
|
or MaxMind::DB::Types::_confess( |
131
|
|
|
|
|
|
|
'%s is not a hashref of strings', |
132
|
|
|
|
|
|
|
$_[0] |
133
|
|
|
|
|
|
|
); |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
); |
136
|
|
|
|
|
|
|
|
137
|
2
|
|
|
2
|
0
|
5
|
sub HashRefOfStr () { $t } |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
{ |
141
|
|
|
|
|
|
|
my $t = _object_isa_type('MaxMind::DB::Metadata'); |
142
|
|
|
|
|
|
|
|
143
|
0
|
|
|
0
|
0
|
0
|
sub Metadata () { $t } |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
{ |
147
|
|
|
|
|
|
|
my $t = quote_sub( |
148
|
|
|
|
|
|
|
q{ |
149
|
|
|
|
|
|
|
( defined $_[0] && !ref $_[0] ) |
150
|
|
|
|
|
|
|
or MaxMind::DB::Types::_confess( '%s is not a string', $_[0] ); |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
); |
153
|
|
|
|
|
|
|
|
154
|
2
|
|
|
2
|
0
|
5
|
sub Str () { $t } |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub _object_isa_type { |
158
|
4
|
|
|
4
|
|
5
|
my $class = shift; |
159
|
|
|
|
|
|
|
|
160
|
4
|
|
|
|
|
10
|
return quote_sub( |
161
|
|
|
|
|
|
|
qq{ |
162
|
|
|
|
|
|
|
( Scalar::Util::blessed( \$_[0] ) && \$_[0]->isa('$class') ) |
163
|
|
|
|
|
|
|
or MaxMind::DB::Types::_confess( |
164
|
|
|
|
|
|
|
'%s is not a $class object', |
165
|
|
|
|
|
|
|
\$_[0] |
166
|
|
|
|
|
|
|
); |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
); |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
## use critic |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
173
|
|
|
|
|
|
|
sub _confess { |
174
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitCallsToUnexportedSubs) |
175
|
0
|
0
|
|
0
|
|
|
confess sprintf( |
176
|
|
|
|
|
|
|
$_[0], |
177
|
|
|
|
|
|
|
defined $_[1] ? overload::StrVal( $_[1] ) : 'undef' |
178
|
|
|
|
|
|
|
); |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
## use critic |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
1; |