Iterating through character data and style sets

You can iterate through the data in a text object with either the TTextIterator or the TCharacterIterator class. TTextIterator lets you sequentially access individual characters and their associated styles. TCharacterIterator provides faster iteration if you only need to access the character data.

TCharacterIterator iteration functions return a UniChar. TTextIterator iteration functions are overloaded to return a UniChar, a TStyleSet, or both.


NOTE Reuse a TCharacterIterator or TTextIterator by calling SetText to iterate over a different text object.

These classes form the basis for other text iterator classes that search for text patterns--for example, finding a substring within a text instance. See Chapter 8, "Text analysis," for information on text pattern iterators.

You can also iterate through the contents of a style set object using a TStyleSetIterator object. Because style sets can be modified only through TStyleSet protocol, this iterator is read-only. It returns constant references and does not allow modification or removal of any style data. You can bind this iterator to a specific style category to limit the types of styles it returns.



[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