#include <brkiter.h>
Class diagram for BreakIterator:
Public Members | |||
![]() | ![]() | virtual | ~BreakIterator () |
![]() | ![]() | virtual bool_t | operator== (const BreakIterator&) const = 0 |
![]() | ![]() | Return true if another object is semantically equal to this one. More... | |
![]() | ![]() | bool_t | operator!= (const BreakIterator& rhs) const |
![]() | ![]() | Returns the complement of the result of operator==. More... | |
![]() | ![]() | virtual BreakIterator* | clone (void) const = 0 |
![]() | ![]() | Return a polymorphic copy of this object. More... | |
![]() | ![]() | virtual UClassID | getDynamicClassID (void) const = 0 |
![]() | ![]() | Return a polymorphic class ID for this object. More... | |
![]() | ![]() | virtual const CharacterIterator& | getText (void) const = 0 |
![]() | ![]() | Return a CharacterIterator over the text being analyzed. More... | |
![]() | ![]() | virtual CharacterIterator* | createText (void) const = 0 |
![]() | ![]() | Get the text for which this object is finding the boundaries. More... | |
![]() | ![]() | virtual void | setText (const UnicodeString* it) = 0 |
![]() | ![]() | Change the text over which this operates. More... | |
![]() | ![]() | virtual void | adoptText (CharacterIterator* it) = 0 |
![]() | ![]() | Change the text over which this operates. More... | |
![]() | ![]() | virtual UTextOffset | first (void) = 0 |
![]() | ![]() | Return the index of the first character in the text being scanned. More... | |
![]() | ![]() | virtual UTextOffset | last (void) = 0 |
![]() | ![]() | Return the index immediately BEYOND the last character in the text being scanned. More... | |
![]() | ![]() | virtual UTextOffset | previous (void) = 0 |
![]() | ![]() | Return the boundary preceding the current boundary. More... | |
![]() | ![]() | virtual UTextOffset | next (void) = 0 |
![]() | ![]() | Return the boundary following the current boundary. More... | |
![]() | ![]() | virtual UTextOffset | current (void) const = 0 |
![]() | ![]() | Return character index of the text boundary that was most recently returned by next(), previous(), first(), or last(). More... | |
![]() | ![]() | virtual UTextOffset | following (UTextOffset offset) = 0 |
![]() | ![]() | Return the first boundary following the specified offset. More... | |
![]() | ![]() | virtual UTextOffset | preceding (UTextOffset offset) = 0 |
![]() | ![]() | Return the first boundary preceding the specified offset. More... | |
![]() | ![]() | virtual bool_t | isBoundary (UTextOffset offset) = 0 |
![]() | ![]() | Return true if the specfied position is a boundary position. More... | |
![]() | ![]() | virtual UTextOffset | next (int32_t n) = 0 |
![]() | ![]() | Return the nth boundary from the current boundary. More... | |
Static Public Members | |||
![]() | ![]() | BreakIterator* | createWordInstance (const Locale& where, UErrorCode& status) |
![]() | ![]() | Create BreakIterator for word-breaks using the given locale. More... | |
![]() | ![]() | BreakIterator* | createLineInstance (const Locale& where, UErrorCode& status) |
![]() | ![]() | Create BreakIterator for line-breaks using specified locale. More... | |
![]() | ![]() | BreakIterator* | createCharacterInstance (const Locale& where, UErrorCode& status) |
![]() | ![]() | Create BreakIterator for character-breaks using specified locale Returns an instance of a BreakIterator implementing character breaks. More... | |
![]() | ![]() | BreakIterator* | createSentenceInstance (const Locale& where, UErrorCode& status) |
![]() | ![]() | Create BreakIterator for sentence-breaks using specified locale Returns an instance of a BreakIterator implementing sentence breaks. More... | |
![]() | ![]() | const Locale* | getAvailableLocales (int32_t& count) |
![]() | ![]() | Get the set of Locales for which TextBoundaries are installed. More... | |
![]() | ![]() | UnicodeString& | getDisplayName (const Locale& objectLocale, const Locale& displayLocale, UnicodeString& name) |
![]() | ![]() | Get name of the object for the desired Locale, in the desired langauge. More... | |
![]() | ![]() | UnicodeString& | getDisplayName (const Locale& objectLocale, UnicodeString& name) |
![]() | ![]() | Get name of the object for the desired Locale, in the langauge of the default locale. More... | |
![]() | ![]() | const UTextOffset | DONE |
![]() | ![]() | DONE is returned by previous() and next() after all valid boundaries have been returned. More... | |
Protected Members | |||
![]() | ![]() | BreakIterator () |
BreakIterator is an abstract base class. Instances of BreakIterator maintain a current position and scan over text returning the index of characters where boundaries occur.
Line boundary analysis determines where a text string can be broken when line-wrapping. The mechanism correctly handles punctuation and hyphenated words.
Sentence boundary analysis allows selection with correct interpretation of periods within numbers and abbreviations, and trailing punctuation marks such as quotation marks and parentheses.
Word boundary analysis is used by search and replace functions, as well as within text editing applications that allow the user to select words with a double click. Word selection provides correct interpretation of punctuation marks within and following words. Characters that are not part of a word, such as symbols or punctuation marks, have word-breaks on both sides.
Character boundary analysis allows users to interact with characters as they expect to, for example, when moving the cursor through a text string. Character boundary analysis provides correct navigation of through character strings, regardless of how the character is stored. For example, an accented character might be stored as a base character and a diacritical mark. What users consider to be a character can differ between languages.
This is the interface for all text boundaries.
Examples:
Helper function to output text
. void printTextRange( BreakIterator& iterator, UTextOffset start, UTextOffset end ) . { . UnicodeString textBuffer, temp; . CharacterIterator *strIter = iterator.createText(); . strIter->getText(temp); . cout << " " << start << " " << end << " |" . << temp.extractBetween(start, end, textBuffer) . << "|" << endl; . delete strIter; . }
. void printEachForward( BreakIterator& boundary) . { . UTextOffset start = boundary.first(); . for (UTextOffset end = boundary.next(); . end != BreakIterator::DONE; . start = end, end = boundary.next()) . { . printTextRange( boundary, start, end ); . } . }
. void printEachBackward( BreakIterator& boundary) . { . UTextOffset end = boundary.last(); . for (UTextOffset start = boundary.previous(); . start != BreakIterator::DONE; . end = start, start = boundary.previous()) . { . printTextRange( boundary, start, end ); . } . }
. void printFirst(BreakIterator& boundary) . { . UTextOffset start = boundary.first(); . UTextOffset end = boundary.next(); . printTextRange( boundary, start, end ); . }
. void printLast(BreakIterator& boundary) . { . UTextOffset end = boundary.last(); . UTextOffset start = boundary.previous(); . printTextRange( boundary, start, end ); . }
. void printAt(BreakIterator &boundary, UTextOffset pos ) . { . UTextOffset end = boundary.following(pos); . UTextOffset start = boundary.previous(); . printTextRange( boundary, start, end ); . }
. void BreakIterator_Example( void ) . { . BreakIterator* boundary; . UnicodeString stringToExamine("Aaa bbb ccc. Ddd eee fff."); . cout << "Examining: " << stringToExamine << endl; . . //print each sentence in forward and reverse order . boundary = BreakIterator::createSentenceInstance( Locale::US ); . boundary->setText(&stringToExamine); . cout << "----- forward: -----------" << endl; . printEachForward(*boundary); . cout << "----- backward: ----------" << endl; . printEachBackward(*boundary); . delete boundary; . . //print each word in order . boundary = BreakIterator::createWordInstance(); . boundary->setText(&stringToExamine); . cout << "----- forward: -----------" << endl; . printEachForward(*boundary); . //print first element . cout << "----- first: -------------" << endl; . printFirst(*boundary); . //print last element . cout << "----- last: --------------" << endl; . printLast(*boundary); . //print word at charpos 10 . cout << "----- at pos 10: ---------" << endl; . printAt(*boundary, 10 ); . . delete boundary; . }
virtual BreakIterator::~BreakIterator () [virtual]
|
virtual bool_t BreakIterator::operator== (const BreakIterator & that) const [pure virtual]
|
Return true if another object is semantically equal to this one.
The other object should be an instance of the same subclass of BreakIterator. Objects of different subclasses are considered unequal.
Return true if this BreakIterator is at the same position in the same text, and is the same class and type (word, line, etc.) of BreakIterator, as the argument. Text is considered the same if it contains the same characters, it need not be the same object, and styles are not considered.
Reimplemented in RuleBasedBreakIterator.
bool_t BreakIterator::operator!= (const BreakIterator & that) const [inline]
|
Returns the complement of the result of operator==.
Reimplemented in RuleBasedBreakIterator.
virtual BreakIterator * BreakIterator::clone (void) const [pure virtual]
|
Return a polymorphic copy of this object.
This is an abstract method which subclasses implement.
Reimplemented in DictionaryBasedBreakIterator, and RuleBasedBreakIterator.
virtual UClassID BreakIterator::getDynamicClassID (void) const [pure virtual]
|
Return a polymorphic class ID for this object.
Different subclasses will return distinct unequal values.
Reimplemented in DictionaryBasedBreakIterator, and RuleBasedBreakIterator.
virtual const CharacterIterator & BreakIterator::getText (void) const [pure virtual]
|
Return a CharacterIterator over the text being analyzed.
Reimplemented in RuleBasedBreakIterator.
virtual CharacterIterator * BreakIterator::createText (void) const [pure virtual]
|
Get the text for which this object is finding the boundaries.
Reimplemented in RuleBasedBreakIterator.
virtual void BreakIterator::setText (const UnicodeString * newText) [pure virtual]
|
Change the text over which this operates.
The text boundary is reset to the start.
Reimplemented in RuleBasedBreakIterator.
virtual void BreakIterator::adoptText (CharacterIterator * newText) [pure virtual]
|
Change the text over which this operates.
The text boundary is reset to the start.
Reimplemented in RuleBasedBreakIterator.
virtual UTextOffset BreakIterator::first (void) [pure virtual]
|
Return the index of the first character in the text being scanned.
Reimplemented in RuleBasedBreakIterator.
virtual UTextOffset BreakIterator::last (void) [pure virtual]
|
Return the index immediately BEYOND the last character in the text being scanned.
Reimplemented in RuleBasedBreakIterator.
virtual UTextOffset BreakIterator::previous (void) [pure virtual]
|
Return the boundary preceding the current boundary.
Reimplemented in DictionaryBasedBreakIterator, and RuleBasedBreakIterator.
virtual UTextOffset BreakIterator::next (void) [pure virtual]
|
Return the boundary following the current boundary.
Reimplemented in RuleBasedBreakIterator.
virtual UTextOffset BreakIterator::current (void) const [pure virtual]
|
Return character index of the text boundary that was most recently returned by next(), previous(), first(), or last().
Reimplemented in RuleBasedBreakIterator.
virtual UTextOffset BreakIterator::following (UTextOffset offset) [pure virtual]
|
Return the first boundary following the specified offset.
The value returned is always greater than the offset or the value BreakIterator.DONE
offset | the offset to begin scanning. |
virtual UTextOffset BreakIterator::preceding (UTextOffset offset) [pure virtual]
|
Return the first boundary preceding the specified offset.
The value returned is always smaller than the offset or the value BreakIterator.DONE
offset | the offset to begin scanning. |
virtual bool_t BreakIterator::isBoundary (UTextOffset offset) [pure virtual]
|
Return true if the specfied position is a boundary position.
offset | the offset to check. |
virtual UTextOffset BreakIterator::next (int32_t n) [pure virtual]
|
Return the nth boundary from the current boundary.
n | which boundary to return. A value of 0 does nothing. Negative values move to previous boundaries and positive values move to later boundaries. |
Reimplemented in RuleBasedBreakIterator.
BreakIterator * BreakIterator::createWordInstance (const Locale & where, UErrorCode & status) [static]
|
Create BreakIterator for word-breaks using the given locale.
Returns an instance of a BreakIterator implementing word breaks. WordBreak is useful for word selection (ex. double click)
where | the locale. |
status | the error code |
BreakIterator * BreakIterator::createLineInstance (const Locale & where, UErrorCode & status) [static]
|
Create BreakIterator for line-breaks using specified locale.
Returns an instance of a BreakIterator implementing line breaks. Line breaks are logically possible line breaks, actual line breaks are usually determined based on display width. LineBreak is useful for word wrapping text.
where | the locale. . |
BreakIterator * BreakIterator::createCharacterInstance (const Locale & where, UErrorCode & status) [static]
|
Create BreakIterator for character-breaks using specified locale Returns an instance of a BreakIterator implementing character breaks.
Character breaks are boundaries of combining character sequences.
where | the locale. |
BreakIterator * BreakIterator::createSentenceInstance (const Locale & where, UErrorCode & status) [static]
|
Create BreakIterator for sentence-breaks using specified locale Returns an instance of a BreakIterator implementing sentence breaks.
where | the locale. |
const Locale * BreakIterator::getAvailableLocales (int32_t & count) [static]
|
Get the set of Locales for which TextBoundaries are installed.
count | the output parameter of number of elements in the locale list |
UnicodeString & BreakIterator::getDisplayName (const Locale & objectLocale, const Locale & displayLocale, UnicodeString & name) [static]
|
Get name of the object for the desired Locale, in the desired langauge.
objectLocale | must be from getAvailableLocales. |
displayLocale | specifies the desired locale for output. |
name | the fill-in parameter of the return value Uses best match. |
UnicodeString & BreakIterator::getDisplayName (const Locale & objectLocale, UnicodeString & name) [static]
|
Get name of the object for the desired Locale, in the langauge of the default locale.
objectLocale | must be from getMatchingLocales |
name | the fill-in parameter of the return value |
BreakIterator::BreakIterator () [protected]
|
const UTextOffset BreakIterator::DONE [static]
|