| 1 | # Copyrights 2001-2020 by [Mark Overmeer]. | ||||||||||||||||||||||||||||
| 2 | # For other contributors see ChangeLog. | ||||||||||||||||||||||||||||
| 3 | # See the manual pages for details on the licensing terms. | ||||||||||||||||||||||||||||
| 4 | # Pod stripped from pm file by OODoc 2.02. | ||||||||||||||||||||||||||||
| 5 | # This code is part of distribution Mail-Box. Meta-POD processed with | ||||||||||||||||||||||||||||
| 6 | # OODoc into POD and HTML manual-pages. See README.md | ||||||||||||||||||||||||||||
| 7 | # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | package Mail::Box::Tie::HASH; | ||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 2 | $VERSION = '3.009'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | sub TIEHASH(@) | ||||||||||||||||||||||||||||
| 21 | 0 | ▶ | { my ($class, $folder) = @_; | ||||||||||||||||||||||||||
|
Subroutine
TIEHASH: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | croak "No folder specified to tie to." | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $folder and $folder->isa("Mail::Box")
MC/DC0%0/2
ref $folder and $folder->isa("Mail::Box")
ref $folder
$folder->isa("Mail::Box")
Truth table0%0/3
A and B
A= ref $folderB= $folder->isa("Mail::Box")
| |||||||||||||||||||||||||||||
| 23 | unless ref $folder && $folder->isa('Mail::Box'); | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | bless { MBT_folder => $folder, MBT_type => 'HASH' }, $class; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | #------------------------------------------- | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | sub FETCH($) { shift->{MBT_folder}->messageId(shift) } | ||||||||||||||||||||||||||
|
Subroutine
FETCH: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | sub STORE($$) | ||||||||||||||||||||||||||||
| 34 | 0 | ▶ | { my ($self, $key, $basicmsg) = @_; | ||||||||||||||||||||||||||
|
Subroutine
STORE: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | carp "Use undef as key, because the message-id of the message is used." | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $key and $key ne "undef"
MC/DC0%0/2
defined $key and $key ne "undef"
defined $key
$key ne "undef"
Truth table0%0/3
A and B
A= defined $keyB= $key ne "undef"
| |||||||||||||||||||||||||||||
| 37 | if defined $key && $key ne 'undef'; | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | $self->{MBT_folder}->addMessages($basicmsg); | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | sub FIRSTKEY() | ||||||||||||||||||||||||||||
| 44 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
FIRSTKEY: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 45 | 0 | my $folder = $self->{MBT_folder}; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | $self->{MBT_each_index} = 0; | |||||||||||||||||||||||||||
| 48 | 0 | $self->NEXTKEY(); | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | #------------------------------------------- | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | sub NEXTKEY($) | ||||||||||||||||||||||||||||
| 55 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
NEXTKEY: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 56 | 0 | my $folder = $self->{MBT_folder}; | |||||||||||||||||||||||||||
| 57 | 0 | my $nrmsgs = $folder->messages; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | my $msg; | |||||||||||||||||||||||||||
| 60 | 0 | while(1) | |||||||||||||||||||||||||||
| 61 | 0 | { my $index = $self->{MBT_each_index}++; | |||||||||||||||||||||||||||
| 62 | 0 | ▶ | return undef if $index >= $nrmsgs; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 0 | $msg = $folder->message($index); | |||||||||||||||||||||||||||
| 65 | 0 | ▶ | last unless $msg->isDeleted; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | $msg->messageId; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | sub EXISTS($) | ||||||||||||||||||||||||||||
| 73 | 0 | ▶ | { my $folder = shift->{MBT_folder}; | ||||||||||||||||||||||||||
|
Subroutine
EXISTS: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 74 | 0 | my $msgid = shift; | |||||||||||||||||||||||||||
| 75 | 0 | my $msg = $folder->messageId($msgid); | |||||||||||||||||||||||||||
| 76 | 0 | ▶ | defined $msg && ! $msg->isDeleted; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | sub DELETE($) | ||||||||||||||||||||||||||||
| 81 | 0 | ▶ | { my ($self, $msgid) = @_; | ||||||||||||||||||||||||||
|
Subroutine
DELETE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 82 | 0 | $self->{MBT_folder}->messageId($msgid)->delete; | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | #------------------------------------------- | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | sub CLEAR() | ||||||||||||||||||||||||||||
| 89 | 0 | ▶ | { my $folder = shift->{MBT_folder}; | ||||||||||||||||||||||||||
|
Subroutine
CLEAR: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 90 | 0 | $_->delete foreach $folder->messages; | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | #------------------------------------------- | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 2 | 1; | |||||||||||||||||||||||||||