line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: class to tie hashes for Type::Tie::Aggregate |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
###################################################################### |
4
|
|
|
|
|
|
|
# Copyright (C) 2021 Asher Gordon # |
5
|
|
|
|
|
|
|
# # |
6
|
|
|
|
|
|
|
# This program is free software: you can redistribute it and/or # |
7
|
|
|
|
|
|
|
# modify it under the terms of the GNU General Public License as # |
8
|
|
|
|
|
|
|
# published by the Free Software Foundation, either version 3 of # |
9
|
|
|
|
|
|
|
# the License, or (at your option) any later version. # |
10
|
|
|
|
|
|
|
# # |
11
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, # |
12
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of # |
13
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # |
14
|
|
|
|
|
|
|
# General Public License for more details. # |
15
|
|
|
|
|
|
|
# # |
16
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License # |
17
|
|
|
|
|
|
|
# along with this program. If not, see # |
18
|
|
|
|
|
|
|
# . # |
19
|
|
|
|
|
|
|
###################################################################### |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
package Type::Tie::Aggregate::Hash; |
22
|
|
|
|
|
|
|
$Type::Tie::Aggregate::Hash::VERSION = '0.001'; |
23
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
24
|
|
|
|
|
|
|
#pod |
25
|
|
|
|
|
|
|
#pod This class is used to tie hashes. This class is internal to |
26
|
|
|
|
|
|
|
#pod L. |
27
|
|
|
|
|
|
|
#pod |
28
|
|
|
|
|
|
|
#pod =cut |
29
|
|
|
|
|
|
|
|
30
|
5
|
|
|
5
|
|
80
|
use v5.6.0; |
|
5
|
|
|
|
|
18
|
|
31
|
5
|
|
|
5
|
|
30
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
128
|
|
32
|
5
|
|
|
5
|
|
26
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
182
|
|
33
|
5
|
|
|
5
|
|
30
|
use namespace::autoclean; |
|
5
|
|
|
|
|
20
|
|
|
5
|
|
|
|
|
42
|
|
34
|
5
|
|
|
5
|
|
438
|
use Carp; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
355
|
|
35
|
5
|
|
|
5
|
|
39
|
use parent 'Type::Tie::Aggregate::Base'; |
|
5
|
|
|
|
|
21
|
|
|
5
|
|
|
|
|
48
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _create_ref { |
38
|
12
|
|
|
12
|
|
24
|
shift; |
39
|
12
|
50
|
|
|
|
49
|
if (@_ % 2) { |
40
|
0
|
|
|
|
|
0
|
carp 'Odd number of elements in hash initialization'; |
41
|
0
|
|
|
|
|
0
|
push @_, undef; |
42
|
|
|
|
|
|
|
} |
43
|
12
|
|
|
|
|
57
|
+{ @_ }; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _check_value { |
47
|
6
|
|
|
6
|
|
18
|
my (undef, $value) = @_; |
48
|
6
|
50
|
|
|
|
22
|
return 'Not a HASH reference' unless ref $value eq 'HASH'; |
49
|
6
|
|
|
|
|
19
|
return; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
111
|
|
|
111
|
|
265
|
sub TIEHASH { my $class = shift; $class->_new(@_) } |
|
111
|
|
|
|
|
468
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__PACKAGE__->_install_methods( |
55
|
|
|
|
|
|
|
{ mutates => 1 }, |
56
|
|
|
|
|
|
|
STORE => '$ref->{$_[0]} = $_[1]', |
57
|
|
|
|
|
|
|
DELETE => 'delete $ref->{$_[0]}', |
58
|
|
|
|
|
|
|
CLEAR => '%$ref = ()', |
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__PACKAGE__->_install_methods( |
62
|
|
|
|
|
|
|
{ mutates => 0 }, |
63
|
|
|
|
|
|
|
FETCH => '$ref->{$_[0]}', |
64
|
|
|
|
|
|
|
FIRSTKEY => 'scalar keys %$ref; each %$ref', |
65
|
|
|
|
|
|
|
NEXTKEY => 'each %$ref', |
66
|
|
|
|
|
|
|
EXISTS => 'exists $ref->{$_[0]}', |
67
|
|
|
|
|
|
|
SCALAR => 'scalar %$ref', |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
#pod =head1 SEE ALSO |
71
|
|
|
|
|
|
|
#pod |
72
|
|
|
|
|
|
|
#pod =for :list |
73
|
|
|
|
|
|
|
#pod * L |
74
|
|
|
|
|
|
|
#pod |
75
|
|
|
|
|
|
|
#pod =cut |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |