qaf::HgeInputStream Class Reference

#include <qafHgeInputStream.h>

Inheritance diagram for qaf::HgeInputStream:

qaf::IntegerInputStream List of all members.

Detailed Description

Encapsulates reading from a file stored in an HGE resource pack.


Public Member Functions

 HgeInputStream (const char *filename)
 The constructor will load the resource through hge->Resource_Load(), preparing it for reading.
bool canRead ()
 
Returns:
true if the file has been successfully opened and/or there are more bytes to be read from it.

int getSize ()
 
Returns:
The size of this resource, in bytes.

int seek (long offset, int whence)
 Behaves in the same way as fseek from the standard I/O library.
long tell ()
 
Returns:
The stream's current position indicator.

int getC ()
 
Returns:
The next byte in the stream, or -1 if the end of the stream has been reached.

int read (void *buffer, long itemSize, long itemCount)
 Reads a block of data from the stream.
int skipWhiteSpace ()
 Skips all whitespace characters (' ', '', '
', '') from the current position until either a non-whitespace character is found or the end of the file is reached.
virtual ~HgeInputStream ()
 Destructor: If the resource has been loaded, it will be automatically freed before this object is destroyed.


Constructor & Destructor Documentation

qaf::HgeInputStream::HgeInputStream ( const char *  filename  ) 

The constructor will load the resource through hge->Resource_Load(), preparing it for reading.

Before accessing the stream with its reading methods, it is advisable to check if the operation was successful with canRead().


Member Function Documentation

int qaf::HgeInputStream::seek ( long  offset,
int  whence 
)

Behaves in the same way as fseek from the standard I/O library.

Parameters:
offset Displacement, in bytes, to position the position indicator relative to whence.
whence Can be one of the constants:
  • SEEK_SET: Displacement relative to the beginning of the stream;
  • SEEK_END: Displacement relative to the end of of the stream;
  • SEEK_CUR: Displacement relative to the position indicator's current position.
Returns:
On success, returns 0. Otherwise, returns -1.

int qaf::HgeInputStream::read ( void *  buffer,
long  itemSize,
long  itemCount 
)

Reads a block of data from the stream.

Read count number of items each one with a size of size bytes from the stream and stores it in the specified buffer. The stream's postion indicator is increased by the number of bytes read. Total amount of bytes read is (size x count).

Returns:
The total number of items read.

int qaf::HgeInputStream::skipWhiteSpace (  ) 

Skips all whitespace characters (' ', '', '
', '') from the current position until either a non-whitespace character is found or the end of the file is reached.

Returns:
The number of characters skipped.


The documentation for this class was generated from the following file:
Generated on Sun Mar 25 12:32:14 2007 for Qaf Framework by  doxygen 1.5.1-p1