Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ZResFileReader Class Reference

class to read resource files written by a ZResFileWriter. More...

#include <ZResource.h>

Inheritance diagram for ZResFileReader::

ZResReader List of all members.

Public Methods

 ZResFileReader ()
 default constructor. More...

 ZResFileReader (const QString &fileName)
 constructor taking a file name as an argument. More...

virtual ~ZResFileReader ()
 destructor. More...

bool setFileName (const QString &fileName)
 sets the filename for this resource reader. More...

const QString& fileName () const
 return the filename used by this resource reader. More...

virtual bool exists (const QString &ID) const
 return a value indicating whether or not a given string ID exists. More...

virtual bool get (const QString &ID, unsigned char **ppOutData, int *pOutLength) const
 get data for a resource. More...

virtual QString getFirstID ()
 get the first resource ID in this resource reader. More...

virtual QString getNextID ()
 get the next resource ID in this resource reader. More...


Protected Methods

void init (const QString &fileName)
 init is called by the constructors. More...

void reset ()
 reset resets the object state. More...

bool load ()
QString getID (unsigned hashTableEntryNum) const
 getID return the resource ID for a given hash table entry number. More...

const ZResHTEntry* getHashTableEntry (const QString &ID) const
 returns a pointer to a hashTableEntry for a given ID. More...

bool getDataAtOffset (unsigned offset, unsigned char **ppOutData, int *pOutLength) const
 returns a pointer to the data at a given file offset returns false if an error occurs. More...

bool getDataAtOffset (unsigned offset, QString &resourceFileName, unsigned char **ppOutData, int *pOutLength) const

Protected Attributes

bool bLoadFailed
 load actually loads the resource table. More...

QString m_fileName
 the name of the resource file. More...

bool loaded
int fd
unsigned int fileLength
unsigned char* pResources
unsigned char* pIDs
unsigned hashTableSize
ZResHTEntry* pHashTable
unsigned char* pData
unsigned char* pEnd
unsigned currentIteratorEntry

Detailed Description

class to read resource files written by a ZResFileWriter.

Use ZResFileReader to read QPixmaps or other data from a single resource file. If you want to use the current application skin (which is made of a number of resource files, see ZSkin.

Note:
you can see what resources are in a resource file by opening the file with a text editor. The beginning of the file contains an easily readable list of resource names.


Constructor & Destructor Documentation

ZResFileReader::ZResFileReader ( )
 

default constructor.

ZResFileReader::ZResFileReader ( const QString & fileName )
 

constructor taking a file name as an argument.

ZResFileReader::~ZResFileReader ( ) [virtual]
 

destructor.


Member Function Documentation

bool ZResFileReader::exists ( const QString & ID ) const [virtual]
 

return a value indicating whether or not a given string ID exists.

Returns:
bool indicating whether or not a resource exists

Reimplemented from ZResReader.

const QString & ZResFileReader::fileName ( ) const
 

return the filename used by this resource reader.

bool ZResFileReader::get ( const QString & ID,
unsigned char ** ppOutData,
int * pOutLength ) const [virtual]
 

get data for a resource.

Parameters:
ID   the resource ID for the resource
ppOutData   out-pointer for the resource data
pOutLength   out-integer for the size in bytes of the data

Note:
Do not delete/de-allocate the pointer returned from this function.

Reimplemented from ZResReader.

bool ZResFileReader::getDataAtOffset ( unsigned offset,
QString & resourceFileName,
unsigned char ** ppOutData,
int * pOutLength ) const [protected]
 

bool ZResFileReader::getDataAtOffset ( unsigned offset,
unsigned char ** ppOutData,
int * pOutLength ) const [protected]
 

returns a pointer to the data at a given file offset returns false if an error occurs.

QString ZResFileReader::getFirstID ( ) [virtual]
 

get the first resource ID in this resource reader.

Note:
this function is not thread safe
Returns:
first resource ID

Reimplemented from ZResReader.

const ZResHTEntry * ZResFileReader::getHashTableEntry ( const QString & ID ) const [protected]
 

returns a pointer to a hashTableEntry for a given ID.

QString ZResFileReader::getID ( unsigned hashTableEntryNum ) const [protected]
 

getID return the resource ID for a given hash table entry number.

QString ZResFileReader::getNextID ( ) [virtual]
 

get the next resource ID in this resource reader.

Note:
this function in not thread safe
Returns:
current resource ID, increments iterator

Reimplemented from ZResReader.

void ZResFileReader::init ( const QString & fileName ) [protected]
 

init is called by the constructors.

bool ZResFileReader::load ( ) [protected]
 

void ZResFileReader::reset ( ) [protected]
 

reset resets the object state.

bool ZResFileReader::setFileName ( const QString & fileName )
 

sets the filename for this resource reader.

This causes any previously opened resource file to be closed.

Parameters:
fileName   the filename to open
Returns:
true if the file was successfully openend, false otherwise

Note:
any pointers returned from this object before calling this function should be considered invalid


Member Data Documentation

bool ZResFileReader::bLoadFailed [protected]
 

load actually loads the resource table.

unsigned ZResFileReader::currentIteratorEntry [protected]
 

int ZResFileReader::fd [protected]
 

unsigned int ZResFileReader::fileLength [protected]
 

unsigned ZResFileReader::hashTableSize [protected]
 

bool ZResFileReader::loaded [protected]
 

QString ZResFileReader::m_fileName [protected]
 

the name of the resource file.

unsigned char * ZResFileReader::pData [protected]
 

unsigned char * ZResFileReader::pEnd [protected]
 

ZResHTEntry * ZResFileReader::pHashTable [protected]
 

unsigned char * ZResFileReader::pIDs [protected]
 

unsigned char * ZResFileReader::pResources [protected]
 


The documentation for this class was generated from the following file:
Generated at Wed Mar 3 13:23:05 2004 by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001