Interface for a seekable and readable data stream.
virtual bool Common::SeekableReadStream::seek |
( |
int32 |
offset, |
|
|
int |
whence = SEEK_SET |
|
) |
| |
|
pure virtual |
Set the stream position indicator for the stream.
The new position, measured in bytes, is obtained by adding offset bytes to the position specified by whence. If whence is set to SEEK_SET, SEEK_CUR, or SEEK_END, the offset is relative to the start of the file, the current position indicator, or end-of-stream, respectively. A successful call to the seek() method clears the end-of-stream indicator for the stream.
- Note
- The semantics of any implementation of this method is supposed to match that of ISO C fseek().
- Parameters
-
offset | Relative offset in bytes. |
whence | Seek reference: SEEK_SET, SEEK_CUR, or SEEK_END. |
- Returns
- True on success, false in case of a failure.
virtual char* Common::SeekableReadStream::readLine |
( |
char * |
s, |
|
|
size_t |
bufSize, |
|
|
bool |
handleCR = true |
|
) |
| |
|
virtual |
Read at most one less than the number of characters specified by bufSize
from the stream and store them in the string buffer.
Reading stops when the end of a line is reached (CR, CR/LF, or LF), and at end-of-stream or error. The newline, if any, is retained (CR and CR/LF are translated to LF = 0xA = '\n'
). If any characters are read and there is no error, a \0
character is appended to end the string.
Upon successful completion, return a pointer to the string. If end-of-stream occurs before any characters are read, returns NULL and the buffer contents remain unchanged. If an error occurs, returns NULL and the buffer contents are indeterminate. This method does not distinguish between end-of-stream and error; callers must use err() or eos() to determine which occurred.
- Note
- This method is closely modeled after the standard fgets() function from stdio.h.
- Parameters
-
s | The buffer to store into. |
bufSize | Size of the buffer. |
handleCR | If set (default), then CR and CR/LF are handled, as well as LF. |
- Returns
- Pointer to the read string, or NULL if an error occurred.
virtual String Common::SeekableReadStream::readLine |
( |
bool |
handleCR = true | ) |
|
|
virtual |
Read a full line and returns it as a Common::String.
Reading stops when the end of a line is reached (CR, CR/LF, or LF), and at end-of-stream or error.
Upon successful completion, return a string with the content of the line, without the end of a line marker. This method does not indicate whether an error occurred. Callers must use err() or eos() to determine whether an exception occurred.
- Parameters
-
handleCR | If set (default), then CR and CR/LF are handled, as well as LF. |