#include <resource.h>
Inheritance diagram for TResourceFile::
Public Methods | |
TResourceFile (fpstream *aStream) | |
~TResourceFile () | |
short | count () |
void | remove (const char *key) |
void | flush () |
void* | get (const char *key) |
const char* | keyAt (short i) |
void | put (TStreamable *item, const char *key) |
fpstream* | switchTo (fpstream *aStream, Boolean pack) |
Protected Attributes | |
fpstream* | stream |
Boolean | modified |
long | basePos |
long | indexPos |
TResourceCollection* | index |
To provide fast and efficient access to the objects stored in a resource file, TResourceFile objects store the keys in a sorted string collection (using TResourceCollection) along with the position and size of the resource data in the resource file.
Definition at line 243 of file resource.h.
|
Initializes a resource file using the stream given by `aStream' and sets the modified data member to False. The stream must have already been initialized. During initialization, the TResourceFile constructor looks for a resource file header at the current position of the stream. If a header is not found, the constructor assumes that a new resource file is being created together with a new resource collection. |
|
Flushes the resource file, using flush() and then deletes index and stream data members. |
|
Calls index->getCount() to return the number of resource items stored in the associated @reg TResourceCollection.
|
|
If the resource file has not been modified since the last flush (that is, if modified is False), flush() does nothing. Otherwise, flush() stores the updated index at the end of the stream and updates the resource header at the beginning of the stream. It then calls stream->flush() and resets modified to False. |
|
Searches for the given key in the associated resource file collection (given by the pointer index). Returns 0 if the key is not found. |
|
Uses index->at(i) to return the string key of the i'th resource in the resource file.
|
|
Adds the streamable object given by `item' to the resource file with the key string given by `key' and sets modified to True. If the index already contains the key, then the new object replaces the old object; otherwise, the new object is appended in the correct indexed position of the resource file. |
|
If the resource indexed by `key' is not found, remove does nothing. Otherwise it calls index->free() to remove the resource. |
|
Undocumented. |
|
The base position of the stream (ignoring header information). Definition at line 323 of file resource.h. |
|
A pointer to the associated TResourceCollection object. Definition at line 331 of file resource.h. |
|
The current position of the stream relative to the base position. Definition at line 327 of file resource.h. |
|
Set True if the resource file has been modified since the last flush call; otherwise False. Definition at line 319 of file resource.h. |
|
Pointer to the file stream associated with this resource file. Definition at line 314 of file resource.h. |