QStaticLatin1StringMatcher Class
template <Qt::CaseSensitivity CS, size_t N> class QStaticLatin1StringMatcherQStaticLatin1StringMatcherクラスは、QLatin1StringMatcher のコンパイル時バージョンである。
ヘッダー | #include <QStaticLatin1StringMatcher> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
以来: | Qt 6.7 |
- 継承されたメンバを含む、すべてのメンバの一覧
- QStaticLatin1StringMatcher は、文字列データのクラスに属しています。
パブリック関数
qsizetype | indexIn(QLatin1StringView haystack, qsizetype from = 0) const |
qsizetype | indexIn(QStringView haystack, qsizetype from = 0) const |
関連する非メンバー
(since 6.7) auto | qMakeStaticCaseInsensitiveLatin1StringMatcher(const char (&)[N] patternToMatch) |
(since 6.7) auto | qMakeStaticCaseSensitiveLatin1StringMatcher(const char (&)[N] patternToMatch) |
詳細な説明
このクラスは、コンパイル時に既知の部分文字列をLatin-1文字列から効率的に検索する必要がある場合に便利です。これは、例えばパーサーでは一般的です。特に、検索する文字列を繰り返し検索する場合や、検索する部分文字列の接頭辞に一致する文字列が多数含まれる可能性のある大きな Latin-1 文字列内で検索する場合は、検索する文字列の indexOf() メンバメソッドを使用するよりも matcher オブジェクトのindexIn() を使用する方が高速です。
QLatin1StringMatcher とは異なり、このクラスはコンパイル時に内部表現を計算するので、1 回限りの Latin-1 文字列マッチを行う場合でも有益です。
QStaticLatin1StringMatcher を作成するには、qMakeStaticCaseSensitiveLatin1StringMatcher() またはqMakeStaticCaseInsensitiveLatin1StringMatcher() を呼び出し、検索する Latin-1 文字列を C 文字列リテラルとして渡します。その関数の返り値をstatic constexpr auto
変数に格納するので、N
テンプレート・パラメータを明示的に渡す必要はありません。
そして、QLatin1StringMatcher と同じように、検索したいQLatin1StringView に対してindexIn() を呼び出します。
このクラスは、コンパイル時にすべての先行計算を行うように設計されているため、 setPattern() メソッドや setCaseSensitivity() メソッドは提供されません。
注意: INTEGRITY オペレーティング・システムは現在サポートされていません。
QLatin1StringMatcher 、QStaticByteArrayMatcher 、QByteArrayMatcherも参照のこと 。
メンバ関数ドキュメント
[constexpr noexcept]
qsizetype QStaticLatin1StringMatcher::indexIn(QLatin1StringView haystack, qsizetype from = 0) const
[constexpr noexcept]
qsizetype QStaticLatin1StringMatcher::indexIn(QStringView haystack, qsizetype from = 0) const
QLatin1StringView haystack を、コンストラクタで設定されたQLatin1StringView pattern()に対して、バイト位置from (デフォルト 0、つまり最初のバイトから)から検索する。コンストラクタで設定した大文字小文字の区別を使用します。
haystack で pattern() がマッチした位置を返すか、マッチしなかった場合は -1 を返す。
関連する非メンバー
[constexpr noexcept, since 6.7]
template <size_t N> auto qMakeStaticCaseInsensitiveLatin1StringMatcher(const char (&)[N] patternToMatch)
渡されたpatternToMatch から正しいN
を自動的に決定し、大文字小文字を区別しないQStaticLatin1StringMatcher を返す。
この関数を最大限に活用するには、結果をstatic constexpr auto
変数に代入してください:
static constexpr auto matcher = qMakeStaticCaseInsensitiveLatin1StringViewMatcher("needle");
この関数は Qt 6.7 で導入されました。
[constexpr noexcept, since 6.7]
template <size_t N> auto qMakeStaticCaseSensitiveLatin1StringMatcher(const char (&)[N] patternToMatch)
渡されたpatternToMatch から正しいN
を自動的に決定し、大文字小文字を区別したQStaticLatin1StringMatcher を返す。
この関数を最大限に活用するには、結果をstatic constexpr auto
変数に代入してください:
static constexpr auto matcher = qMakeStaticCaseSensitiveLatin1StringViewMatcher("needle");
この関数は Qt 6.7 で導入されました。
© 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.