Qt 4.8
|
The QTextBoundaryFinder class provides a way of finding Unicode text boundaries in a string. More...
#include <qtextboundaryfinder.h>
Public Types | |
enum | BoundaryReason { NotAtBoundary = 0, StartWord = 1, EndWord = 2 } |
enum | BoundaryType { Grapheme, Word, Line, Sentence } |
Public Functions | |
BoundaryReasons | boundaryReasons () const |
Returns the reasons for the boundary finder to have chosen the current position as a boundary. More... | |
bool | isAtBoundary () const |
Returns true if the object's position() is currently at a valid text boundary. More... | |
bool | isValid () const |
Returns true if the text boundary finder is valid; otherwise returns false. More... | |
QTextBoundaryFinder & | operator= (const QTextBoundaryFinder &other) |
Assigns the object, other, to another QTextBoundaryFinder object. More... | |
int | position () const |
Returns the current position of the QTextBoundaryFinder. More... | |
QTextBoundaryFinder () | |
Constructs an invalid QTextBoundaryFinder object. More... | |
QTextBoundaryFinder (const QTextBoundaryFinder &other) | |
Copies the QTextBoundaryFinder object, other. More... | |
QTextBoundaryFinder (BoundaryType type, const QString &string) | |
Creates a QTextBoundaryFinder object of type operating on string. More... | |
QTextBoundaryFinder (BoundaryType type, const QChar *chars, int length, unsigned char *buffer=0, int bufferSize=0) | |
Creates a QTextBoundaryFinder object of type operating on chars with length. More... | |
void | setPosition (int position) |
Sets the current position of the QTextBoundaryFinder to position. More... | |
QString | string () const |
Returns the string the QTextBoundaryFinder object operates on. More... | |
void | toEnd () |
Moves the finder to the end of the string. More... | |
int | toNextBoundary () |
Moves the QTextBoundaryFinder to the next boundary position and returns that position. More... | |
int | toPreviousBoundary () |
Moves the QTextBoundaryFinder to the previous boundary position and returns that position. More... | |
void | toStart () |
Moves the finder to the start of the string. More... | |
BoundaryType | type () const |
Returns the type of the QTextBoundaryFinder. More... | |
~QTextBoundaryFinder () | |
Destructs the QTextBoundaryFinder object. More... | |
Properties | |
const QChar * | chars |
QTextBoundaryFinderPrivate * | d |
uint | freePrivate: 1 |
int | length |
int | pos |
QString | s |
BoundaryType | t |
uint | unused: 31 |
The QTextBoundaryFinder class provides a way of finding Unicode text boundaries in a string.
QTextBoundaryFinder allows to find Unicode text boundaries in a string, similar to the Unicode text boundary specification (see http://www.unicode.org/reports/tr29/tr29-11.html).
QTextBoundaryFinder can operate on a QString in four possible modes depending on the value of BoundaryType.
Units of Unicode characters that make up what the user thinks of as a character or basic unit of the language are here called Grapheme clusters. The two unicode characters 'A' + diaeresis do for example form one grapheme cluster as the user thinks of them as one character, yet it is in this case represented by two unicode code points.
Word boundaries are there to locate the start and end of what a language considers to be a word.
Line break boundaries give possible places where a line break might happen and sentence boundaries will show the beginning and end of whole sentences.
The first position in a string is always a valid boundary and refers to the position before the first character. The last position at the length of the string is also valid and refers to the position after the last character.
Definition at line 56 of file qtextboundaryfinder.h.
Enumerator | |
---|---|
NotAtBoundary | |
StartWord | |
EndWord |
Definition at line 71 of file qtextboundaryfinder.h.
Enumerator | |
---|---|
Grapheme | |
Word | |
Line | |
Sentence |
Definition at line 64 of file qtextboundaryfinder.h.
QTextBoundaryFinder::QTextBoundaryFinder | ( | ) |
Constructs an invalid QTextBoundaryFinder object.
Definition at line 167 of file qtextboundaryfinder.cpp.
QTextBoundaryFinder::QTextBoundaryFinder | ( | const QTextBoundaryFinder & | other | ) |
Copies the QTextBoundaryFinder object, other.
Definition at line 179 of file qtextboundaryfinder.cpp.
QTextBoundaryFinder::~QTextBoundaryFinder | ( | ) |
QTextBoundaryFinder::QTextBoundaryFinder | ( | BoundaryType | type, |
const QString & | string | ||
) |
Creates a QTextBoundaryFinder object of type operating on string.
Definition at line 228 of file qtextboundaryfinder.cpp.
QTextBoundaryFinder::QTextBoundaryFinder | ( | BoundaryType | type, |
const QChar * | chars, | ||
int | length, | ||
unsigned char * | buffer = 0 , |
||
int | bufferSize = 0 |
||
) |
Creates a QTextBoundaryFinder object of type operating on chars with length.
buffer is an optional working buffer of size bufferSize you can pass to the QTextBoundaryFinder. If the buffer is large enough to hold the working data required, it will use this instead of allocating its own buffer.
Definition at line 254 of file qtextboundaryfinder.cpp.
QTextBoundaryFinder::BoundaryReasons QTextBoundaryFinder::boundaryReasons | ( | ) | const |
Returns the reasons for the boundary finder to have chosen the current position as a boundary.
Definition at line 458 of file qtextboundaryfinder.cpp.
Referenced by QDeclarativeTextInput::moveCursorSelection().
bool QTextBoundaryFinder::isAtBoundary | ( | ) | const |
Returns true if the object's position() is currently at a valid text boundary.
Definition at line 434 of file qtextboundaryfinder.cpp.
Referenced by boundaryReasons(), qTextAtOffsetFromString(), and qTextBeforeOffsetFromString().
|
inline |
Returns true if the text boundary finder is valid; otherwise returns false.
A default QTextBoundaryFinder is invalid.
Definition at line 82 of file qtextboundaryfinder.h.
QTextBoundaryFinder & QTextBoundaryFinder::operator= | ( | const QTextBoundaryFinder & | other | ) |
Assigns the object, other, to another QTextBoundaryFinder object.
Definition at line 195 of file qtextboundaryfinder.cpp.
int QTextBoundaryFinder::position | ( | ) | const |
Returns the current position of the QTextBoundaryFinder.
The range is from 0 (the beginning of the string) to the length of the string inclusive.
Definition at line 299 of file qtextboundaryfinder.cpp.
Referenced by QDeclarativeTextInput::moveCursorSelection(), qTextAfterOffsetFromString(), qTextAtOffsetFromString(), and qTextBeforeOffsetFromString().
void QTextBoundaryFinder::setPosition | ( | int | position | ) |
Sets the current position of the QTextBoundaryFinder to position.
If position is out of bounds, it will be bound to only valid positions. In this case, valid positions are from 0 to the length of the string inclusive.
Definition at line 313 of file qtextboundaryfinder.cpp.
Referenced by QDeclarativeTextInput::moveCursorSelection(), qTextAfterOffsetFromString(), qTextAtOffsetFromString(), and qTextBeforeOffsetFromString().
QString QTextBoundaryFinder::string | ( | ) | const |
Returns the string the QTextBoundaryFinder object operates on.
Definition at line 338 of file qtextboundaryfinder.cpp.
void QTextBoundaryFinder::toEnd | ( | ) |
Moves the finder to the end of the string.
This is equivalent to setPosition(string.length()).
Definition at line 286 of file qtextboundaryfinder.cpp.
int QTextBoundaryFinder::toNextBoundary | ( | ) |
Moves the QTextBoundaryFinder to the next boundary position and returns that position.
Returns -1 if there is no next boundary.
Definition at line 351 of file qtextboundaryfinder.cpp.
Referenced by QDeclarativeTextInput::moveCursorSelection(), qTextAfterOffsetFromString(), qTextAtOffsetFromString(), and qTextBeforeOffsetFromString().
int QTextBoundaryFinder::toPreviousBoundary | ( | ) |
Moves the QTextBoundaryFinder to the previous boundary position and returns that position.
Returns -1 if there is no previous boundary.
Definition at line 394 of file qtextboundaryfinder.cpp.
Referenced by QDeclarativeTextInput::moveCursorSelection(), qTextAtOffsetFromString(), and qTextBeforeOffsetFromString().
void QTextBoundaryFinder::toStart | ( | ) |
Moves the finder to the start of the string.
This is equivalent to setPosition(0).
Definition at line 276 of file qtextboundaryfinder.cpp.
|
inline |
|
private |
Definition at line 101 of file qtextboundaryfinder.h.
Referenced by operator=(), QTextBoundaryFinder(), and string().
|
private |
Definition at line 106 of file qtextboundaryfinder.h.
Referenced by boundaryReasons(), isAtBoundary(), operator=(), QTextBoundaryFinder(), toNextBoundary(), toPreviousBoundary(), and ~QTextBoundaryFinder().
|
private |
Definition at line 104 of file qtextboundaryfinder.h.
Referenced by operator=(), QTextBoundaryFinder(), and ~QTextBoundaryFinder().
|
private |
Definition at line 102 of file qtextboundaryfinder.h.
Referenced by boundaryReasons(), isAtBoundary(), operator=(), QTextBoundaryFinder(), setPosition(), string(), toEnd(), toNextBoundary(), and toPreviousBoundary().
|
private |
Definition at line 103 of file qtextboundaryfinder.h.
Referenced by boundaryReasons(), isAtBoundary(), operator=(), position(), setPosition(), toEnd(), toNextBoundary(), toPreviousBoundary(), and toStart().
|
private |
Definition at line 100 of file qtextboundaryfinder.h.
Referenced by operator=(), and string().
|
private |
Definition at line 99 of file qtextboundaryfinder.h.
Referenced by isAtBoundary(), operator=(), QTextBoundaryFinder(), toNextBoundary(), and toPreviousBoundary().
|
private |
Definition at line 105 of file qtextboundaryfinder.h.