1 package TAP::Parser::Iterator;
6 use base 'TAP::Object';
10 TAP::Parser::Iterator - Base class for TAP source iterators
18 our $VERSION = '3.42';
23 use TAP::Parser::Iterator ();
24 use base 'TAP::Parser::Iterator';
35 This is a simple iterator base class that defines L<TAP::Parser>'s iterator
36 API. Iterators are typically created from L<TAP::Parser::SourceHandler>s.
44 Create an iterator. Provided by L<TAP::Object>.
46 =head2 Instance Methods
50 while ( my $item = $iter->next ) { ... }
52 Iterate through it, of course.
56 B<Note:> this method is abstract and should be overridden.
58 while ( my $item = $iter->next_raw ) { ... }
60 Iterate raw input without applying any fixes for quirky input syntax.
66 my $line = $self->next_raw;
68 # vms nit: When encountering 'not ok', vms often has the 'not' on a line
72 if ( defined($line) and $line =~ /^\s*not\s*$/ ) {
73 $line .= ( $self->next_raw || '' );
81 my $msg = Carp::longmess('abstract method called directly!');
85 =head3 C<handle_unicode>
87 If necessary switch the input stream to handle unicode. This only has
88 any effect for I/O handle based streams.
90 The default implementation does nothing.
94 sub handle_unicode { }
96 =head3 C<get_select_handles>
98 Return a list of filehandles that may be used upstream in a select()
99 call to signal that this Iterator is ready. Iterators that are not
100 handle-based should return an empty list.
102 The default implementation does nothing.
106 sub get_select_handles {
112 B<Note:> this method is abstract and should be overridden.
114 my $wait_status = $iter->wait;
116 Return the C<wait> status for this iterator.
120 B<Note:> this method is abstract and should be overridden.
122 my $wait_status = $iter->exit;
124 Return the C<exit> status for this iterator.
130 my $msg = Carp::longmess('abstract method called directly!');
136 my $msg = Carp::longmess('abstract method called directly!');
144 Please see L<TAP::Parser/SUBCLASSING> for a subclassing overview.
146 You must override the abstract methods as noted above.
150 L<TAP::Parser::Iterator::Array> is probably the easiest example to follow.
151 There's not much point repeating it here.
157 L<TAP::Parser::Iterator::Array>,
158 L<TAP::Parser::Iterator::Stream>,
159 L<TAP::Parser::Iterator::Process>,