Sign in Join
FPDoc Onlineexperiment

TResources class

In unit resource

A collection of resources

Declaration

pascal
TResources = class

Description

This class represents a format-independent view of a resource file. It holds a collection of resources (TAbstractResource descendants).

Typically, a TResource object is loaded from and written to a stream via format-dependent readers and writers, which are descendants of TAbstractResourceReader and TAbstractResourceWriter, respectively.

Single resources can be added, removed, searched and modified: a resource compiler or editor probably will create resources, set their data, and add them to a TResources object which can then be written to file in the desired format.

This class also provides some class methods to register and find resource readers and writers: these classes, once registered, will be used by a TResources object when it is asked to load or save itself to a stream and the user didn't specify a reader or writer.

Because of the copy-on-write mechanism of TAbstractResource, care should be taken when loading resources, since by default resource data isn't immediately read from the stream: resources hold a reference to the original stream because they need it when their data is requested. For further information, see LoadFromStream and LoadFromFile.

See also

Properties

CountpublicThe number of resources in the object
ItemspublicIndexed array of resources in the object
CacheDatapublicControls the copy-on-write behaviour of all resources

Methods

CreatepublicCreates a new TResources object
DestroypublicDestroys the object
AddpublicAdds a resource
AddAutoIDpublicAdds a resource and gives it a new autogenerated name
ClearpublicDeletes all resources
FindpublicSearches for a resource
FindReaderpublicSearches for a suitable resource reader
MoveFrompublicMoves all resources of another TResources object to itself
RemovepublicRemoves a resource
LoadFromStreampublicLoads the contents of the object from a stream
LoadFromFilepublicLoads the contents of the object from a file
RegisterReaderpublicRegisters a resource reader class
RegisterWriterpublicRegisters a resource writer class
WriteToStreampublicWrites the contents of the object to a stream
WriteToFilepublicWrites the contents of the object to a file

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.