Warning, file /include/QtCore/qtextboundaryfinder.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004 #ifndef QTEXTBOUNDARYFINDER_H
0005 #define QTEXTBOUNDARYFINDER_H
0006
0007 #include <QtCore/qchar.h>
0008 #include <QtCore/qstring.h>
0009
0010 QT_BEGIN_NAMESPACE
0011
0012
0013 struct QCharAttributes;
0014
0015 class Q_CORE_EXPORT QTextBoundaryFinder
0016 {
0017 public:
0018 QTextBoundaryFinder();
0019 QTextBoundaryFinder(const QTextBoundaryFinder &other);
0020 QTextBoundaryFinder &operator=(const QTextBoundaryFinder &other);
0021 ~QTextBoundaryFinder();
0022
0023 enum BoundaryType {
0024 Grapheme,
0025 Word,
0026 Sentence,
0027 Line
0028 };
0029
0030 enum BoundaryReason {
0031 NotAtBoundary = 0,
0032 BreakOpportunity = 0x1f,
0033 StartOfItem = 0x20,
0034 EndOfItem = 0x40,
0035 MandatoryBreak = 0x80,
0036 SoftHyphen = 0x100
0037 };
0038 Q_DECLARE_FLAGS( BoundaryReasons, BoundaryReason )
0039
0040 QTextBoundaryFinder(BoundaryType type, const QString &string);
0041 QTextBoundaryFinder(BoundaryType type, const QChar *chars, qsizetype length, unsigned char *buffer = nullptr, qsizetype bufferSize = 0)
0042 : QTextBoundaryFinder(type, QStringView(chars, length), buffer, bufferSize)
0043 {}
0044 QTextBoundaryFinder(BoundaryType type, QStringView str, unsigned char *buffer = nullptr, qsizetype bufferSize = 0);
0045
0046 inline bool isValid() const { return attributes; }
0047
0048 inline BoundaryType type() const { return t; }
0049 QString string() const;
0050
0051 void toStart();
0052 void toEnd();
0053 qsizetype position() const;
0054 void setPosition(qsizetype position);
0055
0056 qsizetype toNextBoundary();
0057 qsizetype toPreviousBoundary();
0058
0059 bool isAtBoundary() const;
0060 BoundaryReasons boundaryReasons() const;
0061
0062 private:
0063 BoundaryType t = Grapheme;
0064 QString s;
0065 QStringView sv;
0066 qsizetype pos = 0;
0067 uint freeBuffer : 1;
0068 uint unused : 31;
0069 QCharAttributes *attributes = nullptr;
0070 };
0071
0072 Q_DECLARE_OPERATORS_FOR_FLAGS(QTextBoundaryFinder::BoundaryReasons)
0073
0074 QT_END_NAMESPACE
0075
0076 #endif
0077