• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDE Support
  • Sitemap
  • Contact Us
 

strigi/src/streams

Strigi::StreamBase

Strigi::StreamBase< T > Class Template Reference

Base class for stream read access to a data source. More...

#include <streambase.h>

Inheritance diagram for Strigi::StreamBase< T >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 StreamBase ()
virtual ~StreamBase ()
virtual int32_t read (const T *&start, int32_t min, int32_t max)=0
virtual int64_t reset (int64_t pos)=0
virtual int64_t skip (int64_t ntoskip)

Detailed Description

template<class T>
class Strigi::StreamBase< T >

Base class for stream read access to a data source.

This class is based on the interface java.io.InputStream. It provides a uniform interface for accessing 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 filters or transformers.

Definition at line 114 of file streambase.h.


Constructor & Destructor Documentation

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

Definition at line 116 of file streambase.h.

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

Definition at line 117 of file streambase.h.


Member Function Documentation

template<class T>
virtual int32_t Strigi::StreamBase< T >::read ( const T *&  start,
int32_t  min,
int32_t  max 
) [pure virtual]

Reads items from the stream and sets start to point to the first item that was read.

Note: unless stated otherwise in the documentation for that method, this pointer will no longer be valid after calling another method of this class. The pointer will also no longer be valid after the class is destroyed.

The functions inherited from StreamBaseBase do not invalidate the pointer.

At least min items will be read from the stream, unless an error occurs or the end of the stream is reached. Under no circumstances will more than max items be read.

If the end of the stream is reached before min items are read, the read is still considered successful and the number of items read will be returned.

Parameters:
start pointer passed by reference that will be set to point to the retrieved array of items. If the end of the stream is encountered or an error occurs, the value of start is undefined
min the minimal number of items to read from the stream. This value should be larger than 0. If it is 0 or smaller, the result is undefined
max the maximal number of items to read from the stream. If this value is smaller than min, there is no limit on the number of items that can be read
Returns:
the number of items that were read. -1 is returned if end of the stream has already been reached. -2 is returned if an error has occurred

Implemented in Strigi::BufferedStream< T >, Strigi::FileReader, Strigi::StringStream< T >, Strigi::BufferedStream< wchar_t >, and Strigi::BufferedStream< char >.

template<class T>
virtual int64_t Strigi::StreamBase< T >::reset ( int64_t  pos  )  [pure 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

Implemented in Strigi::BufferedStream< T >, Strigi::DataEventInputStream, Strigi::FileReader, Strigi::StringStream< T >, Strigi::StringTerminatedSubStream, Strigi::SubInputStream, Strigi::BufferedStream< wchar_t >, and Strigi::BufferedStream< char >.

template<class T >
int64_t Strigi::StreamBase< T >::skip ( int64_t  ntoskip  )  [inline, 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 in Strigi::BufferedStream< T >, Strigi::DataEventInputStream, Strigi::StringStream< T >, Strigi::SubInputStream, Strigi::BufferedStream< wchar_t >, and Strigi::BufferedStream< char >.

Definition at line 204 of file streambase.h.


The documentation for this class was generated from the following file:
  • streambase.h

strigi/src/streams

Skip menu "strigi/src/streams"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

KDE Support

Skip menu "KDE Support"
  • akonadi
  • Decibel
  • grantlee
  • kdewin
  • phonon
  •     Backend
  • polkit-qt
  • qca
  • qimageblitz
  • soprano
  • strigi
  •     searchclient
  •     streamanalyzer
  •     streams
Generated for KDE Support by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal