[Overview][Resource strings][Constants][Types][Classes][Index] Reference for unit 'resource' (#fcl-res)

TResources

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

A collection of resources

Declaration

Source position: resource.pp line 209

type TResources = class end;

public

  constructor Create;

  

Creates a new TResources object

  destructor Destroy; override;

  

Destroys the object

  procedure Add();

  

Adds a resource

  function AddAutoID();

  

Adds a resource and gives it a new autogenerated name

  procedure Clear;

  

Deletes all resources

  function Find();

  

Searches for a resource

  class function FindReader();

  

Searches for a suitable resource reader

  procedure MoveFrom();

  

Moves all resources of another TResources object to itself

  function Remove();

  

Removes a resource

  procedure LoadFromStream();

  

Loads the contents of the object from a stream

  procedure LoadFromFile();

  

Loads the contents of the object from a file

  class procedure RegisterReader();

  

Registers a resource reader class

  class procedure RegisterWriter();

  

Registers a resource writer class

  procedure WriteToStream();

  

Writes the contents of the object to a stream

  procedure WriteToFile();

  

Writes the contents of the object to a file

  property Count: LongWord; [r]

  

The number of resources in the object

  property Items: TAbstractResource; default; [r]

  

Indexed array of resources in the object

  property CacheData: Boolean; [rw]

  

Controls the copy-on-write behaviour of all resources

Inheritance

TResources

  

A collection of resources

|

TObject

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.

Remark: 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 TResources.LoadFromStream and TResources.LoadFromFile.

See also

TAbstractResource

  

Base abstract resource class

TAbstractResourceReader

  

Base abstract resource reader class

TAbstractResourceWriter

  

Base abstract resource writer class


Documentation generated on: Nov 14 2015