NAME

Data::TagDB::Iterator - Work with Tag databases

VERSION

version v0.06

SYNOPSIS

use Data::TagDB;

Generic iterator for database entries

METHODS

new

my Data::TagDB::Iterator = XXX->new(...);

Returns a new iterator. Maybe called in sub-packages implementing actual iterators.

db

my Data::TagDB $db = $db->db;

Returns the current Data::TagDB object

next

my $entry = $iter->next;

Returns the next element or undef when there is no next element.

Needs to be implemented.

finish

$iter->finish;

Tells the iterator that you're done reading. May allow early freeing of backend data.

Needs to be implemented.

foreach

$iter->foreach(sub {
    my ($entry) = @_;
    # ...
});

Runs a function for each entry. Automatically finishes the iterator.

one

my $entry = $iter->one;

Returns one entry from the iterator and finishes. This is most useful when you expect there to be exactly one entry. This function dies if no entry is returned. So It is guaranteed that this function returns non-undef.

collect

my @list = $iter->collect;
# or:
my @list = $iter->collect('method');
# or:
my @list = $iter->collect(sub { ... });

Reads all entries from an iterator and finishes. The entries are returned as a list. Optionally a filter can be applied. If the filter is a simple string it is as a method name to be called on the object.

AUTHOR

Löwenfelsen UG (haftungsbeschränkt) <support@loewenfelsen.net>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2024 by Löwenfelsen UG (haftungsbeschränkt) <support@loewenfelsen.net>.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)