CLucene - a full-featured, c++ search engine
API Documentation


jstreams::StreamBase< T > Class Template Reference

Base class for stream read access to many different file types. More...

#include <streambase.h>

Inheritance diagram for jstreams::StreamBase< T >:

jstreams::BufferedInputStream< T > jstreams::StringReader< T > jstreams::SubInputStream< T >

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

Detailed Description

template<class T>
class jstreams::StreamBase< T >

Base class for stream read access to many different file types.

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.


Constructor & Destructor Documentation

template<class T>
jstreams::StreamBase< T >::StreamBase (  )  [inline]

template<class T>
virtual jstreams::StreamBase< T >::~StreamBase (  )  [inline, virtual]


Member Function Documentation

template<class T>
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().

template<class T>
StreamStatus jstreams::StreamBase< T >::getStatus (  )  const [inline]

template<class T>
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().

template<class T>
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.

template<class T>
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.

Parameters:
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.
Returns:
the number of characters that were read. If -1 is returned, the end of the stream has been reached. If -2 is returned, an error has occurred.

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().

template<class T>
int64_t jstreams::StreamBase< T >::skip ( int64_t  ntoskip  )  [inline, virtual]

Skip.

Parameters:
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().

template<class T>
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().

template<class T>
int64_t jstreams::StreamBase< T >::mark ( int32_t  readlimit  )  [inline]


Field Documentation

template<class T>
int64_t jstreams::StreamBase< T >::size [protected]

template<class T>
int64_t jstreams::StreamBase< T >::position [protected]

template<class T>
std::string jstreams::StreamBase< T >::error [protected]

template<class T>
StreamStatus jstreams::StreamBase< T >::status [protected]


The documentation for this class was generated from the following file:

clucene.sourceforge.net