strigi/src/streams
Strigi::SubInputStream Class Reference
Provides access to part of an InputStream only. More...
#include <subinputstream.h>

Public Member Functions | |
| SubInputStream (InputStream *input, int64_t size=-1) | |
| 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
Provides access to part of an InputStream only.
This class allows you to treat a part of in InputStream as a stream in its own right. For example, substream.position() will return a value relative to the point that the underlying stream was at when the SubInputStream was created.
It will prevent data being read from before the point at which the underlying stream was when the substream was created. Optionally, it can limit the size of the sub stream, preventing data from being read past a certain point even if the underlying stream has more data.
Definition at line 42 of file subinputstream.h.
Constructor & Destructor Documentation
| SubInputStream::SubInputStream | ( | InputStream * | input, | |
| int64_t | size = -1 | |||
| ) | [explicit] |
Create a SubInputStream from an InputStream.
If the size parameter is not given, or is -1, there is no limit on the amount of data that can be read from the stream other than the amount of data remaining in the underlying stream.
If size is less than -1, behaviour is undefined.
- Parameters:
-
input the stream to be used as the source of the data for this substream size the maximum amount of data that may be read from this substream
Definition at line 28 of file subinputstream.cpp.
Member Function Documentation
Definition at line 35 of file subinputstream.cpp.
| int64_t SubInputStream::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 79 of file subinputstream.cpp.
| int64_t SubInputStream::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 96 of file subinputstream.cpp.
The documentation for this class was generated from the following files:
KDE 4.4 API Reference