strigi/src/streams
Strigi::DataEventInputStream Class Reference
An InputStream that makes parallel handling of incoming data easier. More...
#include <dataeventinputstream.h>

Public Member Functions | |
| DataEventInputStream (InputStream *input, DataEventHandler &handler) | |
| int32_t | read (const char *&start, int32_t min, int32_t max) |
| int64_t | reset (int64_t pos) |
| int64_t | skip (int64_t ntoskip) |
Detailed Description
An InputStream that makes parallel handling of incoming data easier.
When you read from this InputStream, it sends out data events to a registered handler. The data events cover all bytes in the inputstream and they are sent out in the same order as they occur in the stream. Each byte occurs in one event only. Rewinding this stream and rereading parts of it will not send a new event for the same data.
Multiple DataEventInputStreams can be linked in series to send events to several handlers:
DataEventHandler handler1, handler2, handler3; InputStream inputStream; DataEventInputStream handlerStream1(inputStream, handler1); DataEventInputStream handlerStream2(handlerStream1, handler1); DataEventInputStream handlerStream3(handlerStream2, handler1); int nRead = handlerStream3.read(start, min, max);
Definition at line 94 of file dataeventinputstream.h.
Constructor & Destructor Documentation
| DataEventInputStream::DataEventInputStream | ( | InputStream * | input, | |
| DataEventHandler & | handler | |||
| ) | [explicit] |
Creates a DataEventInputStream with a given InputStream as the data source.
Each instace of a DataEventHandler should only be passed to one DataEventInputStream. Behaviour is undefined otherwise.
- Parameters:
-
input the InputStream to use as the data source handler the DataEventHandler that should be sent the data events
Definition at line 28 of file dataeventinputstream.cpp.
Member Function Documentation
Definition at line 37 of file dataeventinputstream.cpp.
| int64_t DataEventInputStream::reset | ( | int64_t | pos | ) | [virtual] |
Repositions this stream to a given position.
A call to StreamBase::reset is only guaranteed to be successful when the requested position lies within the segment of a stream corresponding to a valid pointer obtained from StreamBase::read. In this case, the pointer will not be invalidated.
Calling this function invalidates the data pointer that was obtained from StreamBase::read unless the conditions outlined above apply.
To read n items, leaving the stream at the same position as before, you can do the following:
int64_t start = stream.position(); if ( stream.read(data, min, max) > 0 ) { stream.reset(start); // The data pointer is still valid here }
- Parameters:
-
pos the position in the stream you want to go to, relative to the start of the stream
- Returns:
- the new position in the stream
Implements Strigi::StreamBase< T >.
Definition at line 87 of file dataeventinputstream.cpp.
| int64_t DataEventInputStream::skip | ( | int64_t | ntoskip | ) | [virtual] |
Skip ntoskip items.
If an error occurs, or the end of the stream is encountered, fewer than ntoskip items may be skipped. This can be checked by comparing the return value to ntoskip.
Calling this function invalidates the data pointer that was obtained from StreamBase::read.
- Parameters:
-
ntoskip the number of items that should be skipped
- Returns:
- the number of items skipped
Reimplemented from Strigi::StreamBase< T >.
Definition at line 77 of file dataeventinputstream.cpp.
The documentation for this class was generated from the following files:
KDE 4.4 API Reference