line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::KeePass::KDBX::Tie::Hash; |
2
|
|
|
|
|
|
|
# ABSTRACT: Hash base class |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
907
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
57
|
|
5
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
37
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
7
|
use parent 'Tie::Hash'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.900'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
19
|
|
|
19
|
0
|
80
|
sub getters { +{} } |
12
|
0
|
|
|
0
|
0
|
0
|
sub setters { +{} } |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub keys { |
15
|
568
|
|
|
568
|
0
|
691
|
my $self = shift; |
16
|
568
|
|
|
|
|
685
|
return [keys %{$self->getters}]; |
|
568
|
|
|
|
|
994
|
|
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
140
|
0
|
|
sub default_getter {} |
20
|
|
|
|
193
|
0
|
|
sub default_setter {} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub TIEHASH { |
23
|
228
|
|
|
228
|
|
440
|
my $class = shift; |
24
|
228
|
|
|
|
|
759
|
return bless [@_], $class; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub FIRSTKEY { |
28
|
95
|
|
|
95
|
|
48338
|
my ($self) = @_; |
29
|
95
|
|
|
|
|
271
|
return $self->keys->[0]; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub NEXTKEY { |
33
|
411
|
|
|
411
|
|
783
|
my ($self, $last_key) = @_; |
34
|
411
|
|
|
|
|
449
|
my @keys = @{$self->keys}; |
|
411
|
|
|
|
|
576
|
|
35
|
411
|
|
|
|
|
1252
|
for (my $i = 0; $i < @keys; ++$i) { |
36
|
4073
|
100
|
|
|
|
8444
|
return $keys[$i + 1] if $keys[$i] eq $last_key; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub EXISTS { |
41
|
191
|
|
|
191
|
|
11713
|
my ($self, $key) = @_; |
42
|
191
|
|
|
|
|
236
|
return !!grep { $_ eq $key } @{$self->keys}; |
|
3151
|
|
|
|
|
5040
|
|
|
191
|
|
|
|
|
302
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub FETCH { |
46
|
3976
|
|
|
3976
|
|
68792
|
my ($self, $key) = @_; |
47
|
3976
|
100
|
|
|
|
6629
|
return $self->[0] if $key eq '__object'; |
48
|
3967
|
|
100
|
|
|
6675
|
my $getter = $self->getters->{$key} // $self->default_getter($key); |
49
|
3967
|
100
|
|
|
|
9975
|
return $getter->(@$self) if $getter; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub STORE { |
53
|
638
|
|
|
638
|
|
1849
|
my ($self, $key, $value) = @_; |
54
|
638
|
|
66
|
|
|
1267
|
my $setter = $self->setters->{$key} // $self->default_setter($key); |
55
|
638
|
|
|
|
|
1087
|
local $_ = $value; |
56
|
638
|
100
|
|
|
|
1928
|
$setter->(@$self) if $setter; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |