CLucene - a full-featured, c++ search engine
API Documentation
#include <streambase.h>
Public Member Functions | |
StreamBase () | |
virtual | ~StreamBase () |
const char * | getError () const |
Return a string representation of the last error. | |
StreamStatus | getStatus () const |
int64_t | getPosition () const |
Get the current position in the stream. | |
int64_t | getSize () const |
Return the size of the stream. | |
virtual int32_t | read (const T *&start, int32_t min, int32_t max)=0 |
Reads characters from the stream and sets start to the first character that was read. | |
virtual int64_t | skip (int64_t ntoskip) |
Skip. | |
virtual int64_t | reset (int64_t pos)=0 |
Repositions this stream to given requested position. | |
int64_t | mark (int32_t readlimit) |
Protected Attributes | |
int64_t | size |
int64_t | position |
std::string | error |
StreamStatus | status |
This class is based on the interface java.io.InputStream. It allows for uniform access to streamed resources. The main difference with the java equivalent is a performance improvement. When reading data, data is not copied into a buffer provided by the caller, but a pointer to the read data is provided. This makes this interface especially useful for deriving from it and implementing filterers or transformers.
jstreams::StreamBase< T >::StreamBase | ( | ) | [inline] |
virtual jstreams::StreamBase< T >::~StreamBase | ( | ) | [inline, virtual] |
const char* jstreams::StreamBase< T >::getError | ( | ) | const [inline] |
Return a string representation of the last error.
If no error has occurred, an empty string is returned.
Referenced by lucene::util::Reader::mark(), lucene::util::Reader::read(), lucene::util::Reader::reset(), and lucene::util::Reader::skip().
StreamStatus jstreams::StreamBase< T >::getStatus | ( | ) | const [inline] |
int64_t jstreams::StreamBase< T >::getPosition | ( | ) | const [inline] |
Get the current position in the stream.
The value obtained from this function can be used to reset the stream.
Referenced by jstreams::StreamBase< char >::mark().
int64_t jstreams::StreamBase< T >::getSize | ( | ) | const [inline] |
Return the size of the stream.
If the size of the stream is unknown, -1 is returned. If the end of the stream has been reached the size is always known.
virtual int32_t jstreams::StreamBase< T >::read | ( | const T *& | start, | |
int32_t | min, | |||
int32_t | max | |||
) | [pure virtual] |
Reads characters from the stream and sets start to the first character that was read.
If ntoread
is 0
, then at least one character will be read.
start | Pointer passed by reference that will be set to point to the retrieved array of characters. If the end of the stream is encountered or an error occurs, the value of start is undefined. | |
min | The number of characters to read from the stream. | |
max | The maximum number of characters to read from the stream. |
Implemented in jstreams::BufferedInputStream< T >, jstreams::StringReader< T >, jstreams::SubInputStream< T >, jstreams::BufferedInputStream< TCHAR >, and jstreams::BufferedInputStream< char >.
Referenced by jstreams::StreamBase< char >::mark(), lucene::util::Reader::read(), and jstreams::StreamBase< T >::skip().
int64_t jstreams::StreamBase< T >::skip | ( | int64_t | ntoskip | ) | [inline, virtual] |
Skip.
ntoskip | bytes. Unless an error occurs or the end of file is encountered, this amount of bytes is skipped. This function returns new position in the stream. |
Reimplemented in jstreams::BufferedInputStream< T >, jstreams::StringReader< T >, jstreams::SubInputStream< T >, jstreams::BufferedInputStream< TCHAR >, and jstreams::BufferedInputStream< char >.
References jstreams::StreamBase< T >::read(), and SKIPSTEP.
Referenced by lucene::util::Reader::skip().
virtual int64_t jstreams::StreamBase< T >::reset | ( | int64_t | pos | ) | [pure virtual] |
Repositions this stream to given requested position.
Reset is guaranteed to work after a successful call to read(), when the new position is in the range of the data returned by read(). This means that pos
must lie between than the position corresponding to the start parameter (x) of the read function and the position corresponding to the last position in the returned buffer (x + nread).
Implemented in jstreams::BufferedInputStream< T >, jstreams::StringReader< T >, jstreams::SubInputStream< T >, jstreams::BufferedInputStream< TCHAR >, and jstreams::BufferedInputStream< char >.
Referenced by jstreams::StreamBase< char >::mark(), and lucene::util::Reader::reset().
int64_t jstreams::StreamBase< T >::mark | ( | int32_t | readlimit | ) | [inline] |
Referenced by lucene::util::Reader::mark().
int64_t jstreams::StreamBase< T >::size [protected] |
Referenced by jstreams::StreamBase< char >::getSize().
int64_t jstreams::StreamBase< T >::position [protected] |
Referenced by jstreams::StreamBase< char >::getPosition().
std::string jstreams::StreamBase< T >::error [protected] |
Referenced by jstreams::StreamBase< char >::getError().
StreamStatus jstreams::StreamBase< T >::status [protected] |
Referenced by jstreams::StreamBase< char >::getStatus().