Implements an ordered tree of resources

This unit implements classes that represent an ordered tree of resources.

Such a tree is used internally by TResources to speed up operations, and by certain resource readers and writers that deal with resource formats where data is stored as ordered trees of resources. For this reason, only implementors of resource readers and writers should be interested in these classes.

A tree begins with a root node, which is an instance of . The root node contains type nodes, that contain name nodes, that contain language id nodes. Finally, a language id node contains a resource.

Each node contains its sub nodes in two lists: a Named list for nodes identified by a name (a string), and an ID list for nodes identified by an ID (an integer). In each list, nodes are sorted in ascending order.

Many resource formats (PECOFF, ELF, Mach-O, and external resource files) use this exact format to store resource information.

When a tree is destroyed, the resources it references aren't destroyed.
Abstract class representing a resource tree node.

This class represents a node in a resource tree.

An object of this class should never be directly instantiated. To create a node, call CreateSubNode method of an already existing node.
Destroys the object. Only root nodes (instances of ) should be destroyed. Children nodes are destroyed by their parent when needed. Adds a new resource to the tree

This method adds a new resource to the tree, creating all needed sub nodes

This method should only be called on root nodes (instances of ).

If a resource with the same type, name and language ID already exists, an EResourceDuplicateException exception is raised.

The resource to add Creates a subnode

This method creates a subnode, identified by the given resource description.

The newly created sub node The description of the sub node Creates a new resource

This method creates a new resource.

A new resource is created and its type, name and language id are determined from the ancestor nodes in the tree hierarchy.

Usually CreateResource is called by resource readers that read files in which resources are stored as trees.

This method is meaningful only when called on leaf nodes (language id nodes).
The newly created resource Destroys all sub nodes

This method destroys all sub nodes of the node.

Removes a resource from the tree

This method searches for the specified resource and removes it from the tree. If a language ID is not provided, the first resource found that matches aType and aName is returned. The removed resource is then returned.

If no resource is found, nil is returned.

This method should only be called on root nodes (instances of ).
The removed resource, or nil if not found The type of the resource to remove The name of the resource to remove The language ID of the resource to remove Searches for a resource

This method searches for a resource with the given type and name in the tree. If a language ID is not provided, the first resource found that matches aType and aName is returned.

If no resource is found, nil is returned.

This method should only be called on root nodes (instances of ).
The resource that matches the search criteria The type of the resource to search for The name of the resource to search for The language ID of the resource to search for Find a free ID to be used as a resource name

This method is used to find an available ID to be used as a name for a resource, given a resource type. It is used internally by AddAutoID method of TResources.

This method should only be called on root nodes (instances of ).

If there are no free ids left for the given resource type, an ENoMoreFreeIDsException is raised.

A new resource ID The type of the resource Reports whether the node is a leaf node.

Returns true if the node is a leaf node. A leaf node is a language ID node.

True if the node is a leaf node The description of the node

The description of a node identifies that node. According to the type of the node, it can be a resource type, name or language id.

The number of named sub nodes of the node Indexed array of named sub nodes of the node

This property can be used to access all named sub nodes in the node.

This array is 0-based: valid elements range from 0 to NamedCount-1.
The number of ID sub nodes of the node Indexed array of ID sub nodes of the node

This property can be used to access all ID sub nodes in the node.

This array is 0-based: valid elements range from 0 to IDCount-1.
To be used by readers and writers

This property can be freely used by resource readers and writers to store a file offset or address needed to load or write other data, since it isn't used by or TResources.

Do not rely on the value of this property when accessing a new tree: other readers or writers could have changed it for their internal operations.
To be used by readers and writers

This property can be freely used by resource readers and writers to store a file offset or address needed to load or write other data, since it isn't used by or TResources.

Do not rely on the value of this property when accessing a new tree: other readers or writers could have changed it for their internal operations.
To be used by readers and writers

This property can be freely used by resource readers and writers to store a file offset or address needed to load or write other data, since it isn't used by or TResources.

Do not rely on the value of this property when accessing a new tree: other readers or writers could have changed it for their internal operations.
The resource contained in this node

This property references the resource contained in this node.

This property is meaningful only on leaf nodes (language id nodes).
The root node in a resource tree

This node represents the root node of a resource tree.

It is the only node which must be created with its constructor: other nodes in the tree are automatically created when adding a resource, or calling CreateSubNode method of their parent.

Normally all search, add and delete operations on the tree are performed by calling methods of this node.

Creates a new root node

This method creates a new tree, represented by a root node without children.

Other nodes in the tree are automatically created when adding a resource, or calling CreateSubNode method of their parent.