Several of the COM interfaces use "collections." A collection is a list of elements of some more-primitive type. An example of a collection is "ICodeWarriorComponentEventCollection.".
Collections are zero-based lists. In other words, the first element is referred to as the "zeroth element" instead of starting with the ordinal number 1 (one).
All collections share a common group of methods you can call to manipulate information for the collection, including the following:
This method returns the count of the number of elements in the collection. This allows you to iterate to a specified bound since you know how many items to process in the collection.
See Listing 3.12 for an example of how to use this.
The return type for Count is type long.
This method indicates whether the elements in the collection are modifiable or not.
The return type for ReadOnly is type VARIANT_BOOL.
This method returns the indicated element, or item, in the collection.
See Listing 3.12 for an example of how to use this.
The return type for Item is a pointer to the interface, as in:
[interface *] Item( [in] long index );
An example of a value for [interface*] is ICodeWarriorProjectCollection if you are expecting a pointer to an ICodeWarriorProject.
This method allows you to add an element to the collection.
The return type for Add is a pointer to the interface, as in:
Add([in] [interface*] pval );
An example of a value for [interface*] is ICodeWarriorProjectCollection if you are expecting a pointer to an ICodeWarriorProject.
This method allows you to delete an element from the collection.
The return type for Add is a pointer to the interface, as in:
Remove([in] [interface*] pval );
An example of a value for [interface*] is ICodeWarriorProjectCollection if you are expecting a pointer to an ICodeWarriorProject.