Home · All Classes · Main Classes · Deprecated |
MBreakIterator allows to iterate strings in order to get the indexes of word boundaries and possible line breaks. More...
Public Types | |
enum | Type { LineIterator, WordIterator, CharacterIterator, SentenceIterator, TitleIterator } |
Public Member Functions | |
MBreakIterator (const MLocale &locale, const QString &text, Type type=WordIterator) | |
MBreakIterator (const QString &text, Type type=WordIterator) | |
virtual | ~MBreakIterator () |
bool | hasNext () const |
bool | hasPrevious () const |
int | next () |
int | next (int index) |
int | peekNext () |
int | peekPrevious () |
int | previous () |
int | previous (int index) |
int | previousInclusive () |
int | previousInclusive (int index) |
void | toBack () |
void | toFront () |
int | index () const |
void | setIndex (int index) |
bool | isBoundary () |
bool | isBoundary (int index) |
MBreakIterator allows to iterate strings in order to get the indexes of word boundaries and possible line breaks.
Example to iterate string:
MLocale locale; // default QString text("This is a string to iterate"); MBreakIterator it(locale, text, MBreakIterator::WordIterator); while (it.hasNext()) { int index = it.next(); mDebug() << "index at " << i; }
Another common use is to get indexes around cursor:
MLocale locale; // default QString text("This is a string to iterate"); MBreakIterator it(locale, text, MBreakIterator::WordIterator); int cursor = 12; int previous = it.previousInclusive(cursor); int next = it.next(cursor);
enum MBreakIterator::Type |
MBreakIterator::MBreakIterator | ( | const MLocale & | locale, | |
const QString & | text, | |||
Type | type = WordIterator | |||
) |
Creates a MBreakIterator for a string based on rules derived from the given locale.
The index is set to be before the actual string so next() returns the first index.
locale | used locale | |
text | text to iterate. SHOULD NOT be changed while iterating. | |
type | (optional) type of iterator. Default is word iterator |
! Creates a MBreakIterator using the default locale
MBreakIterator::~MBreakIterator | ( | ) | [virtual] |
Destructor.
bool MBreakIterator::hasNext | ( | ) | const |
returns true if a boundary exists after current index
bool MBreakIterator::hasPrevious | ( | ) | const |
returns true if boundary exists before current index
int MBreakIterator::index | ( | ) | const |
returns the current index
bool MBreakIterator::isBoundary | ( | int | index | ) |
Checks if given index is a boundary.
bool MBreakIterator::isBoundary | ( | ) |
Checks if current index is a boundary.
int MBreakIterator::next | ( | int | index | ) |
returns the next boundary after the given index.
Returns the boundary or -1 if none exists. Updates the current index to the resulting value.
int MBreakIterator::next | ( | ) |
returns the next boundary index after the current index or -1 if none exists.
current index is updated to the resulting value.
int MBreakIterator::peekNext | ( | ) |
returns the next boundary index value. The current index is not updated.
int MBreakIterator::peekPrevious | ( | ) |
returns the previous boundary index value. The current index is not updated.
int MBreakIterator::previous | ( | int | index | ) |
returns the previous boundary from the given index value or -1 if none exists.
The current index is updated to the resulting value.
int MBreakIterator::previous | ( | ) |
returns the previous boundary index or -1 if none exists.
The current index is updated to the resulting value.
int MBreakIterator::previousInclusive | ( | ) |
returns the previous boundary including the current index in the search.
If current index is a boundary, it is returned and current is decreased by one, otherwise works as previous()
int MBreakIterator::previousInclusive | ( | int | index | ) |
returns the previous boundary from given index, including the index in the search.
If index is a boundary, it is returned and current is decreased by one, otherwise works as previous()
void MBreakIterator::setIndex | ( | int | index | ) |
Sets the current index to the given value.
void MBreakIterator::toBack | ( | ) |
Sets the current index to the end of the string.
void MBreakIterator::toFront | ( | ) |
Sets the current index to the beginning of the string.
Copyright © 2010 Nokia Corporation | MeeGo Touch |