| 1 | # Copyrights 2001-2023 by [Mark Overmeer <markov@cpan.org>]. | ||||||||||||||||||||
| 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.03. | ||||||||||||||||||||
| 5 | # This code is part of distribution Mail-Message. 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::Message::Field::Fast; | ||||||||||||||||||||
| 10 | 43 | ▶ | use vars '$VERSION'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 43 | $VERSION = '3.013'; | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 43 | ▶ | use base 'Mail::Message::Field'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 43 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | 43 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | #------------------------------------------ | ||||||||||||||||||||
| 20 | # | ||||||||||||||||||||
| 21 | # The DATA is stored as: [ NAME, FOLDED-BODY ] | ||||||||||||||||||||
| 22 | # The body is kept in a folded fashion, where each line starts with | ||||||||||||||||||||
| 23 | # a single blank. | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | sub new($;$@) | ||||||||||||||||||||
| 27 | 947 | ▶ | { my $class = shift; | ||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 947 | ▶ | my ($name, $body) = $class->consume(@_==1 ? (shift) : (shift, shift)); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 30 | 947 | ▶ | return () unless defined $body; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 947 | my $self = bless [$name, $body], $class; | |||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | # Attributes | ||||||||||||||||||||
| 35 | 947 | ▶ | $self->comment(shift) if @_==1; # one attribute line | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 36 | 947 | ▶ | $self->attribute(shift, shift) while @_ > 1; # attribute pairs | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 947 | $self; | |||||||||||||||||||
| 39 | } | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | sub clone() | ||||||||||||||||||||
| 42 | 1522 | ▶ | { my $self = shift; | ||||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 43 | 1522 | bless [ @$self ], ref $self; | |||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | sub length() | ||||||||||||||||||||
| 47 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||
|
Subroutine
length: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 48 | 0 | length($self->[0]) + 1 + length($self->[1]); | |||||||||||||||||||
| 49 | } | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 1664 | ▶ | sub name() { lc shift->[0] } | ||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 52 | 16 | ▶ | sub Name() { shift->[0] } | ||||||||||||||||||
|
Subroutine
Name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | sub folded() | ||||||||||||||||||||
| 55 | 263 | ▶ | { my $self = shift; | ||||||||||||||||||
|
Subroutine
folded: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 56 | 263 | ▶ | return $self->[0].':'.$self->[1] | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 57 | unless wantarray; | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 52 | my @lines = $self->foldedBody; | |||||||||||||||||||
| 60 | 52 | my $first = $self->[0]. ':'. shift @lines; | |||||||||||||||||||
| 61 | 52 | ($first, @lines); | |||||||||||||||||||
| 62 | } | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | sub unfoldedBody($;@) | ||||||||||||||||||||
| 65 | 1829 | ▶ | { my $self = shift; | ||||||||||||||||||
|
Subroutine
unfoldedBody: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 1829 | ▶ | $self->[1] = $self->fold($self->[0], @_) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 68 | if @_; | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | 1829 | $self->unfold($self->[1]); | |||||||||||||||||||
| 71 | } | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | sub foldedBody($) | ||||||||||||||||||||
| 74 | 205 | ▶ | { my ($self, $body) = @_; | ||||||||||||||||||
|
Subroutine
foldedBody: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||
| 75 | 205 | ▶ | if(@_==2) { $self->[1] = $body } | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 76 | 201 | else { $body = $self->[1] } | |||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | 205 | ▶ | wantarray ? (split m/^/, $body) : $body; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 79 | } | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | # For performance reasons only | ||||||||||||||||||||
| 82 | sub print(;$) | ||||||||||||||||||||
| 83 | 107 | ▶ | { my $self = shift; | ||||||||||||||||||
|
Subroutine
print: called CC=3 SCAR=12.3
Pod
documented
| |||||||||||||||||||||
| 84 | 107 | ▶ | my $fh = shift || select; | ||||||||||||||||||
|
Condition33%1/3
shift() || select()
MC/DC0%0/2
shift() || select()
shift()
select()
Truth table33%1/3
A || B
A= shift()B= select()
| |||||||||||||||||||||
| 85 | 107 | ▶ | if(ref $fh eq 'GLOB') { print $fh $self->[0].':'.$self->[1] } | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 86 | 107 | else { $fh->print($self->[0].':'.$self->[1]) } | |||||||||||||||||||
| 87 | 107 | $self; | |||||||||||||||||||
| 88 | } | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | 43 | 1; | |||||||||||||||||||