To iterate through a TPropertySet use the TPropertySetIterator, and to iterate through a TPropertyIDSet use the TPropertyIDSetIterator.
You construct an iterator using the set appropriate to that iterator. Both TPropertySetIterator and TPropertyIDSetIterator function provide the same functions. Each defines:
Returns the first property or property identifier in the set. Returns TPropertySetIterator::kEndOfIterator if this set is empty.
Returns the next property or property identifier in the set. Returns TPropertySetIterator::kEndOfIterator when the end of this iterator is reached.
Unless you know the value of a property, you cannot perform operations on a property returned from a TPropertySetIterator. TPropertyIDSetIterators are different--because you have the property identifier, you know the type of value, and you can then perform operations on the identifier.
This example uses a TPropertySetIterator constructed with a TPropertySet, and iterates through the set, getting the name of each property (via the identifier) and printing it out. This code calls a user-defined function named PrintName which is not defined here.
TPropertySetIterator iterator(aPropertySet);
for (TProperty property = iterator.First();
property != TPropertySetIterator::kEndOfIteration;
property = iterator.Next() )
{
TPropertyID identifier = property.GetID();
identifier.GetName(TPropertyName propName);
PrintName(propName, " ", "\n");
}
[Contents]
[Previous]
[Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.
Generated with WebMaker