![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
\inmodule QtCore More...
#include <qtextboundaryfinder.h>
Public Types | |
enum | BoundaryReason { NotAtBoundary = 0 , BreakOpportunity = 0x1f , StartOfItem = 0x20 , EndOfItem = 0x40 , MandatoryBreak = 0x80 , SoftHyphen = 0x100 } |
\value NotAtBoundary The boundary finder is not at a boundary position. More... |
Public Member Functions | |
QTextBoundaryFinder () | |
Constructs an invalid QTextBoundaryFinder object. | |
QTextBoundaryFinder (const QTextBoundaryFinder &other) | |
Copies the QTextBoundaryFinder object, other. | |
QTextBoundaryFinder (QTextBoundaryFinder &&other) noexcept | |
QTextBoundaryFinder & | operator= (const QTextBoundaryFinder &other) |
Assigns the object, other, to another QTextBoundaryFinder object. | |
~QTextBoundaryFinder () | |
Destructs the QTextBoundaryFinder object. | |
void | swap (QTextBoundaryFinder &other) noexcept |
enum BoundaryType | QT7_ONLY (:quint8) |
QTextBoundaryFinder (BoundaryType type, const QString &string) | |
Creates a QTextBoundaryFinder object of type operating on string. | |
QTextBoundaryFinder (BoundaryType type, const QChar *chars, qsizetype length, unsigned char *buffer=nullptr, qsizetype bufferSize=0) | |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.The same as QTextBoundaryFinder(type, QStringView(chars, length), buffer, bufferSize). | |
QTextBoundaryFinder (BoundaryType type, QStringView str, unsigned char *buffer=nullptr, qsizetype bufferSize=0) | |
Creates a QTextBoundaryFinder object of type operating on string. | |
bool | isValid () const |
Returns true if the text boundary finder is valid; otherwise returns false . | |
BoundaryType | type () const |
Returns the type of the QTextBoundaryFinder. | |
QString | string () const |
Returns the string the QTextBoundaryFinder object operates on. | |
void | toStart () |
Moves the finder to the start of the string. | |
void | toEnd () |
Moves the finder to the end of the string. | |
qsizetype | position () const |
Returns the current position of the QTextBoundaryFinder. | |
void | setPosition (qsizetype position) |
Sets the current position of the QTextBoundaryFinder to position. | |
qsizetype | toNextBoundary () |
Moves the QTextBoundaryFinder to the next boundary position and returns that position. | |
qsizetype | toPreviousBoundary () |
Moves the QTextBoundaryFinder to the previous boundary position and returns that position. | |
bool | isAtBoundary () const |
Returns true if the object's position() is currently at a valid text boundary. | |
BoundaryReasons | boundaryReasons () const |
Returns the reasons for the boundary finder to have chosen the current position as a boundary. |
\inmodule QtCore
The QTextBoundaryFinder class provides a way of finding Unicode text boundaries in a string.
\reentrant
QTextBoundaryFinder allows to find Unicode text boundaries in a string, accordingly to the Unicode text boundary specification (see \l{https://www.unicode.org/reports/tr14/}{Unicode Standard Annex #14} and \l{https://www.unicode.org/reports/tr29/}{Unicode Standard Annex #29}).
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 (see \l{https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries}).
Word boundaries are there to locate the start and end of what a language considers to be a word (see \l{https://www.unicode.org/reports/tr29/#Word_Boundaries}).
Line break boundaries give possible places where a line break might happen and sentence boundaries will show the beginning and end of whole sentences (see \l{https://www.unicode.org/reports/tr29/#Sentence_Boundaries} and \l{https://www.unicode.org/reports/tr14/}).
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 19 of file qtextboundaryfinder.h.
\value NotAtBoundary The boundary finder is not at a boundary position.
\value BreakOpportunity The boundary finder is at a break opportunity position. Such a break opportunity might also be an item boundary (either StartOfItem, EndOfItem, or combination of both), a mandatory line break, or a soft hyphen. \value [since 5.0] StartOfItem The boundary finder is at the start of a grapheme, a word, a sentence, or a line. \value [since 5.0] EndOfItem The boundary finder is at the end of a grapheme, a word, a sentence, or a line. \value [since 5.0] MandatoryBreak The boundary finder is at the end of line (can occur for a Line boundary type only). \value SoftHyphen The boundary finder is at the soft hyphen (can occur for a Line boundary type only).
Enumerator | |
---|---|
NotAtBoundary | |
BreakOpportunity | |
StartOfItem | |
EndOfItem | |
MandatoryBreak | |
SoftHyphen |
Definition at line 56 of file qtextboundaryfinder.h.
QTextBoundaryFinder::QTextBoundaryFinder | ( | ) |
Constructs an invalid QTextBoundaryFinder object.
Definition at line 105 of file qtextboundaryfinder.cpp.
QTextBoundaryFinder::QTextBoundaryFinder | ( | const QTextBoundaryFinder & | other | ) |
Copies the QTextBoundaryFinder object, other.
Definition at line 112 of file qtextboundaryfinder.cpp.
|
inlinenoexcept |
Move-constructs a new QTextBoundaryFinder from other.
Definition at line 24 of file qtextboundaryfinder.h.
QTextBoundaryFinder::~QTextBoundaryFinder | ( | ) |
Destructs the QTextBoundaryFinder object.
Definition at line 182 of file qtextboundaryfinder.cpp.
QTextBoundaryFinder::QTextBoundaryFinder | ( | BoundaryType | type, |
const QString & | string ) |
Creates a QTextBoundaryFinder object of type operating on string.
Definition at line 197 of file qtextboundaryfinder.cpp.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.The same as QTextBoundaryFinder(type, QStringView(chars, length), buffer, bufferSize).
Definition at line 67 of file qtextboundaryfinder.h.
QTextBoundaryFinder::QTextBoundaryFinder | ( | BoundaryType | type, |
QStringView | string, | ||
unsigned char * | buffer = nullptr, | ||
qsizetype | bufferSize = 0 ) |
Creates a QTextBoundaryFinder object of type operating on string.
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 (bufferSize >= length + 1), it will use this instead of allocating its own buffer.
Definition at line 229 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 409 of file qtextboundaryfinder.cpp.
bool QTextBoundaryFinder::isAtBoundary | ( | ) | const |
Returns true
if the object's position() is currently at a valid text boundary.
Definition at line 387 of file qtextboundaryfinder.cpp.
|
inline |
Returns true
if the text boundary finder is valid; otherwise returns false
.
A default QTextBoundaryFinder is invalid.
Definition at line 72 of file qtextboundaryfinder.h.
QTextBoundaryFinder & QTextBoundaryFinder::operator= | ( | const QTextBoundaryFinder & | other | ) |
Assigns the object, other, to another QTextBoundaryFinder object.
Move-assigns other to this QTextBoundaryFinder instance.
Definition at line 138 of file qtextboundaryfinder.cpp.
qsizetype 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 273 of file qtextboundaryfinder.cpp.
|
inline |
Definition at line 49 of file qtextboundaryfinder.h.
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 287 of file qtextboundaryfinder.cpp.
QString QTextBoundaryFinder::string | ( | ) | const |
Returns the string the QTextBoundaryFinder object operates on.
Definition at line 306 of file qtextboundaryfinder.cpp.
|
inlinenoexcept |
void QTextBoundaryFinder::toEnd | ( | ) |
Moves the finder to the end of the string.
This is equivalent to setPosition(string.length()).
Definition at line 260 of file qtextboundaryfinder.cpp.
qsizetype 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 319 of file qtextboundaryfinder.cpp.
qsizetype 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 354 of file qtextboundaryfinder.cpp.
void QTextBoundaryFinder::toStart | ( | ) |
Moves the finder to the start of the string.
This is equivalent to setPosition(0).
Definition at line 250 of file qtextboundaryfinder.cpp.
|
inline |
Returns the type of the QTextBoundaryFinder.
Definition at line 74 of file qtextboundaryfinder.h.