NAME
JSON::Streaming::Reader::EventWrapper - Internal utility package for JSON::Streaming::Reader
DESCRIPTION
This package is an internal implementation detail of JSON::Streaming::Reader. It is used to provide an API that looks like it blocks on top of a handle that doesn't block, so the parsing functions can pretend they have a blocking handle.
Instances of this class support enough of the IO::Handle
interface to satisfy JSON::Streaming::Reader and no more. In other words, they support only the read
method and assume that the caller will only ever want 1 character at a time.
This is not a public API. See the event-based API on JSON::Streaming::Reader, which is implemented in terms of this class. This class may go away in future versions, once refactoring renders it no longer necessary.
SYNOPSIS
my
$event_wrapper
= JSON::Streaming::Reader::EventWrapper->new();
$event_wrapper
->feed_buffer(\
$string_of_data
);
$event_wrapper
->begin_reading();
my
$char
;
eval
{
$event_wrapper
->
read
(
$char
, 1);
};
if
($@ == JSON::Streaming::Reader::EventWrapper::UNDERRUN) {
$event_wrapper
->roll_back_reading();
}
else
{
$event_wrapper
->complete_reading();
# Do something with $char
}