strigi/src/streams
Strigi::StringTerminatedSubStream Class Reference
Reads a stream up to a given terminator. More...
#include <stringterminatedsubstream.h>

Public Member Functions | |
| StringTerminatedSubStream (InputStream *i, const std::string &terminator) | |
| ~StringTerminatedSubStream () | |
| int64_t | offset () const |
| int32_t | read (const char *&start, int32_t min=0, int32_t max=0) |
| int64_t | reset (int64_t pos) |
Detailed Description
Reads a stream up to a given terminator.
This class stops reading data when either the end of the underlying stream is reacher, or a given terminator is encountered in the the stream.
Definition at line 35 of file stringterminatedsubstream.h.
Constructor & Destructor Documentation
| StringTerminatedSubStream::StringTerminatedSubStream | ( | InputStream * | i, | |
| const std::string & | terminator | |||
| ) |
Create a stream from an InputStream that stops when it reaches the given terminator.
- Parameters:
-
i the underlying InputStream to read the data from terminator the terminator indicating the end of this substream
Definition at line 45 of file stringterminatedsubstream.cpp.
| StringTerminatedSubStream::~StringTerminatedSubStream | ( | ) |
Definition at line 48 of file stringterminatedsubstream.cpp.
Member Function Documentation
| int64_t StringTerminatedSubStream::offset | ( | ) | const |
Finds the offset in the underlying substream.
If the underlying InputStream had already been read from before it was passed to the constructor of this class, it will have a different position to this InputStream. This function returns the different between the start of the underlying stream and the start of this stream.
To get the current position in the underlying substream, you should do
- Returns:
- the different between the start of the underlying stream and the start of this stream
Definition at line 52 of file stringterminatedsubstream.cpp.
Definition at line 56 of file stringterminatedsubstream.cpp.
| int64_t StringTerminatedSubStream::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 137 of file stringterminatedsubstream.cpp.
The documentation for this class was generated from the following files:
KDE 4.4 API Reference