| 1 | # Copyright (c) 2024-2026 Philipp Schafft | ||||||||||
| 2 | |||||||||||
| 3 | # licensed under Artistic License 2.0 (see LICENSE file) | ||||||||||
| 4 | |||||||||||
| 5 | # ABSTRACT: Work with Tag databases | ||||||||||
| 6 | |||||||||||
| 7 | package Data::TagDB::MultiIterator; | ||||||||||
| 8 | |||||||||||
| 9 | 4 | ▶ | use v5.10; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 4 | ▶ | use parent 'Data::TagDB::Iterator'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 4 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | 4 | our $VERSION = v0.16; | |||||||||
| 18 | |||||||||||
| 19 | |||||||||||
| 20 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 21 | 0 | my ($pkg, %opts) = @_; | |||||||||
| 22 | |||||||||||
| 23 | 0 | foreach my $required (qw(db iterators)) { | |||||||||
| 24 | 0 | ▶ | croak 'Missing required member: '.$required unless defined $opts{$required}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 0 | return bless \%opts, $pkg; | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | 0 | ▶ | sub next { | ||||||||
|
Subroutine
next: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 31 | 0 | my ($self) = @_; | |||||||||
| 32 | 0 | my $iterators = $self->{iterators}; | |||||||||
| 33 | |||||||||||
| 34 | 0 | ▶ | while (scalar @{$iterators}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 0 | my $entry = $iterators->[0]->next; | |||||||||
| 36 | 0 | ▶ | return $entry if defined $entry; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | 0 | $iterators->[0]->finish; | |||||||||
| 38 | 0 | shift(@{$iterators}); | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 0 | return undef; | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 0 | ▶ | sub finish { | ||||||||
|
Subroutine
finish: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 45 | 0 | my ($self) = @_; | |||||||||
| 46 | 0 | foreach my $iter (@{$self->{iterators}}) { | |||||||||
| 47 | 0 | $iter->finish; | |||||||||
| 48 | } | ||||||||||
| 49 | 0 | @{$self->{iterators}} = (); | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | 4 | 1; | |||||||||
| 53 | |||||||||||
| 54 | __END__ | ||||||||||