line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::KeePass::KDBX::Tie::Hash; |
2
|
|
|
|
|
|
|
# ABSTRACT: Hash base class |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
932
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
55
|
|
5
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
37
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
8
|
use parent 'Tie::Hash'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
12
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.901'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
15
|
|
|
15
|
0
|
51
|
sub getters { +{} } |
12
|
0
|
|
|
0
|
0
|
0
|
sub setters { +{} } |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub keys { |
15
|
562
|
|
|
562
|
0
|
642
|
my $self = shift; |
16
|
562
|
|
|
|
|
606
|
return [keys %{$self->getters}]; |
|
562
|
|
|
|
|
872
|
|
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
140
|
0
|
|
sub default_getter {} |
20
|
|
|
|
193
|
0
|
|
sub default_setter {} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub TIEHASH { |
23
|
224
|
|
|
224
|
|
384
|
my $class = shift; |
24
|
224
|
|
|
|
|
721
|
return bless [@_], $class; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub FIRSTKEY { |
28
|
93
|
|
|
93
|
|
43100
|
my ($self) = @_; |
29
|
93
|
|
|
|
|
251
|
return $self->keys->[0]; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub NEXTKEY { |
33
|
407
|
|
|
407
|
|
696
|
my ($self, $last_key) = @_; |
34
|
407
|
|
|
|
|
432
|
my @keys = @{$self->keys}; |
|
407
|
|
|
|
|
531
|
|
35
|
407
|
|
|
|
|
1130
|
for (my $i = 0; $i < @keys; ++$i) { |
36
|
4067
|
100
|
|
|
|
7866
|
return $keys[$i + 1] if $keys[$i] eq $last_key; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub EXISTS { |
41
|
181
|
|
|
181
|
|
9845
|
my ($self, $key) = @_; |
42
|
181
|
|
|
|
|
205
|
return !!grep { $_ eq $key } @{$self->keys}; |
|
2993
|
|
|
|
|
4164
|
|
|
181
|
|
|
|
|
264
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub FETCH { |
46
|
3966
|
|
|
3966
|
|
68701
|
my ($self, $key) = @_; |
47
|
3966
|
100
|
|
|
|
6602
|
return $self->[0] if $key eq '__object'; |
48
|
3957
|
|
100
|
|
|
6658
|
my $getter = $self->getters->{$key} // $self->default_getter($key); |
49
|
3957
|
100
|
|
|
|
9260
|
return $getter->(@$self) if $getter; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub STORE { |
53
|
638
|
|
|
638
|
|
2245
|
my ($self, $key, $value) = @_; |
54
|
638
|
|
66
|
|
|
1371
|
my $setter = $self->setters->{$key} // $self->default_setter($key); |
55
|
638
|
|
|
|
|
1038
|
local $_ = $value; |
56
|
638
|
100
|
|
|
|
1762
|
$setter->(@$self) if $setter; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |