CopperSpice API
1.9.2
|
Provides a way of finding Unicode text boundaries in a string. More...
Public Typedefs | |
using | BoundaryReasons = QFlags< BoundaryReason > |
Public Types | |
enum | BoundaryReason |
enum | BoundaryType |
Public Methods | |
QTextBoundaryFinder () | |
QTextBoundaryFinder (BoundaryType type, const QString &str) | |
QTextBoundaryFinder (const QTextBoundaryFinder &other) | |
QTextBoundaryFinder (QTextBoundaryFinder &&other) | |
~QTextBoundaryFinder () | |
BoundaryReasons | boundaryReasons () const |
bool | isAtBoundary () const |
QTextBoundaryFinder & | operator= (const QTextBoundaryFinder &other) |
QTextBoundaryFinder & | operator= (QTextBoundaryFinder &&other) |
int | position () const |
void | setPosition (int position) |
QString | string () const |
void | toEnd () |
int | toNextBoundary () |
int | toPreviousBoundary () |
void | toStart () |
BoundaryType | type () const |
The QTextBoundaryFinder class provides a way of finding Unicode text boundaries in a string. This class supports finding boundaries in a string using the rules defined by the Unicode standard. Refer to http://www.unicode.org/reports/tr29 for additional information.
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.
Typedef for QFlags<BoundaryReason> which contains an OR combination of BoundaryReason values.
Refer to QTextBoundaryFinder::BoundaryReason for the enum documentation.
Constant | Value | Description |
---|---|---|
QTextBoundaryFinder::NotAtBoundary | 0x00 | Not at a boundary position |
QTextBoundaryFinder::BreakOpportunity | 0x1f | At a break opportunity position, might also be an item boundary (either StartOfItem, EndOfItem, or combination of both), a mandatory line break, or a soft hyphen |
QTextBoundaryFinder::StartOfItem | 0x20 | At the start of a grapheme, a word, a sentence, or a line |
QTextBoundaryFinder::EndOfItem | 0x30 | At the end of a grapheme, a word, a sentence, or a line |
QTextBoundaryFinder::MandatoryBreak | 0x80 | At the end of line, occurs for a Line boundary type only |
QTextBoundaryFinder::SoftHyphen | 0x100 | At the soft hyphen, occurs for a Line boundary type only |
Constant | Value | Description |
---|---|---|
QTextBoundaryFinder::Grapheme | 0 | Finds a grapheme which is the smallest boundary, includes letters, punctuation marks, numerals, etc |
QTextBoundaryFinder::Word | 1 | Finds a word |
QTextBoundaryFinder::Line | 2 | Finds possible positions for breaking the text into multiple lines |
QTextBoundaryFinder::Sentence | 3 | Finds sentence boundaries, include periods, question marks, etc |
QTextBoundaryFinder::QTextBoundaryFinder | ( | ) |
Constructs an empty QTextBoundaryFinder object.
QTextBoundaryFinder::QTextBoundaryFinder | ( | const QTextBoundaryFinder & | other | ) |
Copy constructs a new QTextBoundaryFinder from other.
QTextBoundaryFinder::QTextBoundaryFinder | ( | QTextBoundaryFinder && | other | ) |
Move constructs a new QTextBoundaryFinder from other.
QTextBoundaryFinder::QTextBoundaryFinder | ( | BoundaryType | type, |
const QString & | str | ||
) |
Creates a QTextBoundaryFinder object of type operating on string.
QTextBoundaryFinder::~QTextBoundaryFinder | ( | ) |
Destructs the QTextBoundaryFinder object.
BoundaryReasons QTextBoundaryFinder::boundaryReasons | ( | ) | const |
Returns the reasons for the boundary finder to have chosen the current position as a boundary.
bool QTextBoundaryFinder::isAtBoundary | ( | ) | const |
Returns true if the object's position() is currently at a valid text boundary.
QTextBoundaryFinder & QTextBoundaryFinder::operator= | ( | const QTextBoundaryFinder & | other | ) |
Copy assigns from other and returns a reference to this object.
QTextBoundaryFinder & QTextBoundaryFinder::operator= | ( | QTextBoundaryFinder && | other | ) |
Move assigns from other and returns a reference to this object.
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.
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.
QString QTextBoundaryFinder::string | ( | ) | const |
Returns the string the QTextBoundaryFinder object operates on.
void QTextBoundaryFinder::toEnd | ( | ) |
Moves the finder to the end of the string. This is equivalent to setPosition(string.length()).
int QTextBoundaryFinder::toNextBoundary | ( | ) |
Moves the QTextBoundaryFinder to the next boundary position and returns that position.
Returns -1 if there is no next boundary.
int QTextBoundaryFinder::toPreviousBoundary | ( | ) |
Moves the QTextBoundaryFinder to the previous boundary position and returns that position. Returns -1 if there is no previous boundary.
void QTextBoundaryFinder::toStart | ( | ) |
Moves the finder to the start of the string. Equivalent to setPosition(0).
|
inline |
Returns the type of the QTextBoundaryFinder.