NAME

Data::Scan - Stackfree arbitrary data scanner

VERSION

version 0.008

SYNOPSIS

    use strict;
    use warnings FATAL => 'all';
    use Data::Scan;
    use Data::Scan::Impl::Printer;  # A Data::Printer implementation example

    my $this = bless([ 'var1', 'var2', {'a' => 'b', 'c' => 'd'}, \undef, \\undef, [] ], 'TEST');
    my $consumer = Data::Scan::Impl::Printer->new;
    Data::Scan->new(consumer => $consumer)->process($this);

DESCRIPTION

Data::Scan is a stackfree scanner of arbitrary data. It has no other intelligence but scanning its arguments and asking for a consumer to deal with every item.

CONSTRUCTOR OPTIONS

consumer

A object instance that is consuming the Data::Scan::Role::Consumer role. Data::Scan::Printer is an example of an implementation consuming this role.

SUBROUTINES/METHODS

$class->new(consumer => ConsumerOf['Data::Scan::Role::Consumer'])

Instantiate a new Data::Scan object. Takes as parameter a required consumer, that is consuming the Data::Scan::Role::Consumer role.

$self->process(Any @arguments)

Scan over all items in @arguments and will call the consumer with these five methods/signatures:

$consumer->dsstart(Any @arguments)

Indicates to the consumer that scanning is starting. All initial arguments are sent to this method. Return value is ignored.

$consumer->dsopen(Any $item)

Indicates to the consumer that an unfold of $item is starting. Return value is ignored.

$consumer->dsread(Any $item)

Indicates to the consumer that he should take over $item. If the consumer is deciding to unfold it (typically when this is an ARRAY or a HASH reference), it should return an array reference containing the unfolded content. Anything but an an array reference means it has not been unfolded.

The consumer has full control on the workflow and can decide to unfold or not whatever is meaningful to him.

$consumer->dsclose(Any $item)

Indicates to the consumer that an unfold of $item is ending. Return value is ignored.

$consumer->dsend()

Indicates to the consumer that scanning is ending. Return value of consumer->end() will be the return value of $self->process(@arguments).

SEE ALSO

Data::Scan::Role::Consumer, Data::Scan::Printer

SUPPORT

Bugs / Feature Requests

Please report any bugs or feature requests through the issue tracker at https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Scan. You will be notified automatically of any progress on your issue.

Source Code

This is open source software. The code repository is available for public review and contribution under the terms of the license.

https://github.com/jddurand/data-scan

  git clone git://github.com/jddurand/data-scan.git

AUTHOR

Jean-Damien Durand <jeandamiendurand@free.fr>

CONTRIBUTOR

Mohammad S Anwar <mohammad.anwar@yahoo.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by Jean-Damien Durand.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.