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

strigi/src/streams

Strigi::StringStream

Strigi::StringStream< T > Class Template Reference

#include <stringstream.h>

Inheritance diagram for Strigi::StringStream< T >:

Inheritance graph
[legend]

List of all members.


Detailed Description

template<class T>
class Strigi::StringStream< T >

Provides access to in-memory data thorugh the StreamBase API.

Definition at line 38 of file stringstream.h.


Public Member Functions

int32_t read (const T *&start, int32_t min, int32_t max)
int64_t reset (int64_t pos)
int64_t skip (int64_t ntoskip)
 StringStream (const T *value, int32_t length=-1, bool copy=true)
 ~StringStream ()

Constructor & Destructor Documentation

template<class T>
Strigi::StringStream< T >::StringStream ( const T *  value,
int32_t  length = -1,
bool  copy = true 
) [inline]

Create a StringStream from a given string.

If the string you provide is not null-terminated, or may not be null-terminated, you need to provide a length. Note that if a length is provided, null characters have no special meaning.

If the string is created on the stack and may go out of scope before the StringStream is destroyed, or if it is created with new and may be destroyed before the StringStream, you should set copy to true.

Parameters:
value pointer to the data for this StringStream
length the length of the data at the pointer. If length is -1, it is assumed value is null-terminated, and this is used to find the end of the string
copy if true a copy of the string will be used, if false a pointer to the original data will be used

Definition at line 80 of file stringstream.h.

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

Definition at line 100 of file stringstream.h.


Member Function Documentation

template<class T>
int32_t Strigi::StringStream< T >::read ( const T *&  start,
int32_t  min,
int32_t  max 
) [inline, 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

Implements Strigi::StreamBase< T >.

Definition at line 107 of file stringstream.h.

template<class T>
int64_t Strigi::StringStream< T >::reset ( int64_t  pos  )  [inline, 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 131 of file stringstream.h.

template<class T>
int64_t Strigi::StringStream< 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 from Strigi::StreamBase< T >.

Definition at line 124 of file stringstream.h.


The documentation for this class was generated from the following file:
  • stringstream.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

API Reference

Skip menu "API Reference"
  •   server
  • Decibel
  • eigen
  • Eigen2
  • kdewin32
  • Phonon
  •     Backend
  • qca
  • qimageblitz
  • soprano
  • strigi
  •     searchclient
  •     streamanalyzer
  •     streams
Generated for API Reference by doxygen 1.5.4
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