ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

Common::SeekableReadStream Class Reference

Interface for a seekable & readable data stream. More...

#include <stream.h>

Inheritance diagram for Common::SeekableReadStream:
Collaboration diagram for Common::SeekableReadStream:

List of all members.

Public Member Functions

virtual int32 pos () const =0
 Obtains the current value of the stream position indicator of the stream.
virtual int32 size () const =0
 Obtains the total size of the stream, measured in bytes.
virtual bool seek (int32 offset, int whence=SEEK_SET)=0
 Sets the stream position indicator for the stream.
virtual bool skip (uint32 offset)
 TODO: Get rid of this??? Or keep it and document it.
virtual char * readLine (char *s, size_t bufSize)
 Reads at most one less than the number of characters specified by bufSize from the and stores them in the string buf.
virtual String readLine ()
 Reads a full line and returns it as a Common::String.
void hexdump (int len, int bytesPerLine=16, int startOffset=0)
 Print a hexdump of the stream while maintaing position.

Detailed Description

Interface for a seekable & readable data stream.

Todo:
Get rid of SEEK_SET, SEEK_CUR, or SEEK_END, use our own constants

Definition at line 561 of file stream.h.


Member Function Documentation

void Common::SeekableReadStream::hexdump ( int  len,
int  bytesPerLine = 16,
int  startOffset = 0 
)

Print a hexdump of the stream while maintaing position.

The number of bytes per line is customizable.

Parameters:
len the length of that data
bytesPerLine number of bytes to print per line (default: 16)
startOffset shift the shown offsets by the starting offset (default: 0)

Definition at line 246 of file stream.cpp.

virtual int32 Common::SeekableReadStream::pos (  )  const [pure virtual]

Obtains the current value of the stream position indicator of the stream.

Returns:
the current position indicator, or -1 if an error occurred.

Implemented in Common::MemoryReadStream, Common::SeekableSubReadStream, Common::GZipReadStream, Grim::PatchedFile, and Grim::PackFile.

char * Common::SeekableReadStream::readLine ( char *  s,
size_t  bufSize 
) [virtual]

Reads at most one less than the number of characters specified by bufSize from the and stores them in the string buf.

Reading stops when the end of a line is reached (CR, CR/LF or LF), and at end-of-file or error. The newline, if any, is retained (CR and CR/LF are translated to LF = 0xA = '
'). If any characters are read and there is no error, a `' character is appended to end the string.

Upon successful completion, return a pointer to the string. If end-of-file 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-file and error; callers must use err() or eos() to determine which occurred.

Note:
This methods is closely modeled after the standard fgets() function from stdio.h.
Parameters:
s the buffer to store into
bufSize the size of the buffer
Returns:
a pointer to the read string, or NULL if an error occurred

Definition at line 112 of file stream.cpp.

String Common::SeekableReadStream::readLine (  )  [virtual]

Reads 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-file 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.

Definition at line 175 of file stream.cpp.

virtual bool Common::SeekableReadStream::seek ( int32  offset,
int  whence = SEEK_SET 
) [pure virtual]

Sets 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-file, respectively. A successful call to the seek() method clears the end-of-file indicator for the stream.

Note:
The semantics of any implementation of this method are supposed to match those of ISO C fseek().
Parameters:
offset the relative offset in bytes
whence the seek reference: SEEK_SET, SEEK_CUR, or SEEK_END
Returns:
true on success, false in case of a failure

Implemented in Common::MemoryReadStream, Common::SeekableSubReadStream, Common::GZipReadStream, Grim::PatchedFile, and Grim::PackFile.

virtual int32 Common::SeekableReadStream::size (  )  const [pure virtual]

Obtains the total size of the stream, measured in bytes.

If this value is unknown or can not be computed, -1 is returned.

Returns:
the size of the stream, or -1 if an error occurred

Implemented in Common::MemoryReadStream, Common::SeekableSubReadStream, Common::GZipReadStream, Grim::PatchedFile, and Grim::PackFile.

virtual bool Common::SeekableReadStream::skip ( uint32  offset  )  [inline, virtual]

TODO: Get rid of this??? Or keep it and document it.

Returns:
true on success, false in case of a failure

Definition at line 601 of file stream.h.


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


Generated on Sat Sep 21 2019 05:03:26 for ResidualVM by doxygen 1.7.1
curved edge   curved edge