strigi/src/streams
Strigi::FileReader Class Reference
Reads and decodes a text file into a Unicode stream. More...
#include <filereader.h>

Public Member Functions | |
| FileReader (const char *fname, const char *encoding_scheme=NULL, const int32_t cachelen=13, const int32_t cachebuff=14) | |
| ~FileReader () | |
| int32_t | read (const wchar_t *&start, int32_t min, int32_t max) |
| int64_t | reset (int64_t pos) |
Detailed Description
Reads and decodes a text file into a Unicode stream.
Definition at line 33 of file filereader.h.
Constructor & Destructor Documentation
| FileReader::FileReader | ( | const char * | fname, | |
| const char * | encoding_scheme = NULL, |
|||
| const int32_t | cachelen = 13, |
|||
| const int32_t | cachebuff = 14 | |||
| ) | [explicit] |
Create a FileReader for a text file.
- Parameters:
-
fname the name of the text file to decode encoding_scheme the encoding of the file cachelen the buffer size to use when reading the file cachebuff currently unused
Definition at line 27 of file filereader.cpp.
| FileReader::~FileReader | ( | ) |
Destructor.
Definition at line 32 of file filereader.cpp.
Member Function Documentation
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 startis undefinedmin 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.
-1is returned if end of the stream has already been reached.-2is returned if an error has occurred
Implements Strigi::StreamBase< wchar_t >.
Definition at line 37 of file filereader.cpp.
| int64_t FileReader::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< wchar_t >.
Definition at line 49 of file filereader.cpp.
The documentation for this class was generated from the following files:
KDE 4.4 API Reference