QTextBoundaryFinder Class

QTextBoundaryFinder クラスは、文字列内の Unicode テキスト境界を見つける方法を提供します。詳細...

ヘッダー #include <QTextBoundaryFinder>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core

注意:このクラスの関数はすべてリエントラントです。

パブリック型

enum BoundaryReason { NotAtBoundary, BreakOpportunity, StartOfItem, EndOfItem, MandatoryBreak, SoftHyphen }
flags BoundaryReasons
enum BoundaryType { Grapheme, Word, Line, Sentence }

パブリック関数

QTextBoundaryFinder()
QTextBoundaryFinder(QTextBoundaryFinder::BoundaryType type, const QString &string)
(since 6.0) QTextBoundaryFinder(QTextBoundaryFinder::BoundaryType type, QStringView string, unsigned char *buffer = nullptr, qsizetype bufferSize = 0)
QTextBoundaryFinder(QTextBoundaryFinder::BoundaryType type, const QChar *chars, qsizetype length, unsigned char *buffer = nullptr, qsizetype bufferSize = 0)
QTextBoundaryFinder(const QTextBoundaryFinder &other)
~QTextBoundaryFinder()
QTextBoundaryFinder::BoundaryReasons boundaryReasons() const
bool isAtBoundary() const
bool isValid() const
qsizetype position() const
void setPosition(qsizetype position)
QString string() const
void toEnd()
qsizetype toNextBoundary()
qsizetype toPreviousBoundary()
void toStart()
QTextBoundaryFinder::BoundaryType type() const
QTextBoundaryFinder &operator=(const QTextBoundaryFinder &other)

詳細説明

QTextBoundaryFinder は、Unicode テキスト境界仕様(Unicode Standard Annex #14およびUnicode Standard Annex #29 を参照)に従って、文字列内の Unicode テキスト境界を見つけることができます。

QTextBoundaryFinder は、BoundaryType の値に応じて 4 つのモードでQString を操作することができます。

ユーザが考える文字や言語の基本単位を構成するユニコード文字の単位を、ここでは書記素クラスタと呼びます。たとえば2つのユニコード文字'A'+diaresisは、ユーザーが1つの文字として考えているように1つの書記素クラスタを形成していますが、この場合は2つのユニコードコードポイントで表現されています(https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries 参照)

単語境界は、その言語が単語とみなすものの開始と終了を示すものです(https://www.unicode.org/reports/tr29/#Word_Boundaries 参照)

改行境界は改行が起こりうる場所を示し、文境界は文全体の始まりと終わりを示します(https://www.unicode.org/reports/tr29/#Sentence_Boundarieshttps://www.unicode.org/reports/tr14/ を 参照)。

文字列の最初の位置は常に有効な境界であり、最初の文字の前の位置を指す。文字列の長さの最後の位置も有効で、最後の文字の後の位置を指す。

メンバ型ドキュメント

enum QTextBoundaryFinder::BoundaryReason
flags QTextBoundaryFinder::BoundaryReasons

定数説明
QTextBoundaryFinder::NotAtBoundary0境界ファインダは境界位置にありません。
QTextBoundaryFinder::BreakOpportunity0x1f境界ファインダは区切りの位置にあります。このようなブレークチャンスは、アイテムの境界(StartOfItem、EndOfItemのいずれか、または両方の組み合わせ)、強制改行、またはソフトハイフンである可能性もあります。
QTextBoundaryFinder::StartOfItem (since Qt 5.0)0x20境界ファインダは、書記素、単語、文、または行の先頭にある。
QTextBoundaryFinder::EndOfItem (since Qt 5.0)0x40境界ファインダは、書記素、単語、文、または行の末尾にある。
QTextBoundaryFinder::MandatoryBreak (since Qt 5.0)0x80境界ファインダが行末にある(Line boundary typeにのみ起こりうる)。
QTextBoundaryFinder::SoftHyphen0x100境界ファインダがソフトハイフンにある(Line boundary typeでのみ発生可能)。

BoundaryReasons型はQFlags<BoundaryReason>のtypedefである。BoundaryReason 値の OR の組み合わせを格納します。

enum QTextBoundaryFinder::BoundaryType

定数説明
QTextBoundaryFinder::Grapheme0最小の境界である書記素を見つける。文字、句読点、数字などを含む。
QTextBoundaryFinder::Word1単語を検索します。
QTextBoundaryFinder::Line3テキストを複数行に分割できる位置を検索します。
QTextBoundaryFinder::Sentence2文の境界を検索します。ピリオド、疑問符などが含まれる。

メンバー関数ドキュメント

QTextBoundaryFinder::QTextBoundaryFinder()

無効な QTextBoundaryFinder オブジェクトを構築します。

QTextBoundaryFinder::QTextBoundaryFinder(QTextBoundaryFinder::BoundaryType type, const QString &string)

string で動作するtype の QTextBoundaryFinder オブジェクトを作成します。

[since 6.0] QTextBoundaryFinder::QTextBoundaryFinder(QTextBoundaryFinder::BoundaryType type, QStringView string, unsigned char *buffer = nullptr, qsizetype bufferSize = 0)

string で動作するtype の QTextBoundaryFinder オブジェクトを作成します。

buffer は、QTextBoundaryFinder に渡すことができるサイズ のオプションの作業バッファです。バッファが必要な作業データを保持するのに十分な大きさ(bufferSize >= length + 1)であれば、独自のバッファを確保する代わりにこれを使用します。bufferSize

警告 QTextBoundaryFinder はstring のコピーを作成しません。QTextBoundaryFinder オブジェクトが生きている限り、配列が確保されるようにするのはアプリケーションプログラマーの責任です。buffer も同様です。

この関数は Qt 6.0 で導入されました。

QTextBoundaryFinder::QTextBoundaryFinder(QTextBoundaryFinder::BoundaryType type, const QChar *chars, qsizetype length, unsigned char *buffer = nullptr, qsizetype bufferSize = 0)

これはオーバーロードされた関数です。

QTextBoundaryFinder(type,QStringView(chars, length), buffer, bufferSize) と同じです。

QTextBoundaryFinder::QTextBoundaryFinder(const QTextBoundaryFinder &other)

QTextBoundaryFinder オブジェクトをコピーします。other.

[noexcept] QTextBoundaryFinder::~QTextBoundaryFinder()

QTextBoundaryFinder オブジェクトを破棄します。

QTextBoundaryFinder::BoundaryReasons QTextBoundaryFinder::boundaryReasons() const

境界ファインダーが現在の位置を境界として選択した理由を返します。

bool QTextBoundaryFinder::isAtBoundary() const

オブジェクトのposition() が現在有効なテキスト境界にある場合、true を返す。

bool QTextBoundaryFinder::isValid() const

テキスト境界ファインダが有効な場合はtrue を返し、そうでない場合はfalse を返す。デフォルトのQTextBoundaryFinder は無効である。

qsizetype QTextBoundaryFinder::position() const

QTextBoundaryFinder の現在の位置を返す。

0 (文字列の先頭) から文字列の長さまでの範囲。

setPosition()も参照

void QTextBoundaryFinder::setPosition(qsizetype position)

QTextBoundaryFinder の現在位置をposition に設定する。

position が範囲外の場合、有効な位置のみにバインドされる。この場合、有効な位置は 0 から文字列の長さまでとなる。

position()も参照のこと

QString QTextBoundaryFinder::string() const

QTextBoundaryFinder オブジェクトが操作する文字列を返します。

void QTextBoundaryFinder::toEnd()

ファインダーを文字列の末尾に移動する。これはsetPosition(string.length()) と等価である。

setPosition() およびposition()も参照

qsizetype QTextBoundaryFinder::toNextBoundary()

QTextBoundaryFinder を次の境界位置に移動し、その位置を返す。

次の境界がない場合は -1 を返す。

qsizetype QTextBoundaryFinder::toPreviousBoundary()

QTextBoundaryFinder を前の境界位置に移動し、その位置を返す。

前の境界がない場合は-1を返す。

void QTextBoundaryFinder::toStart()

ファインダーを文字列の先頭に移動する。これはsetPosition(0) と等価である。

setPosition() およびposition()も参照

QTextBoundaryFinder::BoundaryType QTextBoundaryFinder::type() const

QTextBoundaryFinder の型を返す。

QTextBoundaryFinder &QTextBoundaryFinder::operator=(const QTextBoundaryFinder &other)

オブジェクトother を別のQTextBoundaryFinder オブジェクトに割り当てる。

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.