QStaticByteArrayMatcher Class
template <size_t N> class QStaticByteArrayMatcherQStaticByteArrayMatcher 클래스는 QByteArrayMatcher 의 컴파일 타임 버전입니다. 더 보기...
| 헤더: | #include <QStaticByteArrayMatcher> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
| qmake: | QT += core |
- 상속된 멤버를 포함한 모든 멤버 목록
- QStaticByteArrayMatcher는 문자열 데이터용 클래스의 일부입니다.
공개 함수
| qsizetype | indexIn(const QByteArray &haystack, qsizetype from = 0) const |
| qsizetype | indexIn(const char *haystack, qsizetype hlen, qsizetype from = 0) const |
| QByteArray | pattern() const |
관련 비멤버
| QStaticByteArrayMatcher<N> | qMakeStaticByteArrayMatcher(const char (&pattern)[N]) |
상세 설명
QStaticByteArrayMatcher<N>은 템플릿 클래스로, 여기서 N 은 검색할 바이트 배열 패턴의 길이입니다(문자열 리터럴의 널 종결자 포함). 이 클래스는 일련의 바이트를 특정 바이트 배열과 반복적으로(예: 루프에서) 비교해야 할 때나, 동일한 바이트 배열에서 동일한 바이트 시퀀스를 여러 번 검색해야 할 때 유용합니다. 매처 객체와 ` indexIn()`를 사용하는 것은 ` QByteArray::indexOf()`를 사용하여 일반 ` QByteArray `를 매칭하는 것보다 빠르며, 특히 반복적인 매칭이 이루어지는 경우에 더욱 그렇습니다.
QByteArrayMatcher 과 달리, 이 클래스는 컴파일 시점에 내부 표현을 계산하므로, 단 한 번만 바이트 배열 매칭을 수행하는 경우에도 성능상의 이점을 얻을 수 있습니다.
qMakeStaticByteArrayMatcher()를 호출하여 QStaticByteArrayMatcher를 생성하고, 검색하려는 C 문자열 리터럴을 전달합니다. 해당 함수의 반환 값을 static const auto 변수에 저장하면, N 템플릿 매개변수를 명시적으로 전달할 필요가 없습니다:
static const auto matcher = qMakeStaticByteArrayMatcher("needle");그런 다음 QByteArrayMatcher 와 마찬가지로, 검색을 수행할 QByteArray 에 대해 indexIn()를 호출합니다.
이 클래스는 컴파일 시점에 모든 사전 계산을 수행하도록 설계되었기 때문에 setPattern() 메서드를 제공하지 않습니다.
QByteArrayMatcher 및 QStringMatcher도 참조하십시오 .
멤버 함수 문서
[noexcept] qsizetype QStaticByteArrayMatcher::indexIn(const QByteArray &haystack, qsizetype from = 0) const
바이트 위치 from (기본값 0, 즉 첫 번째 바이트부터)에서 문자열 haystack 을 검색하여, 생성자에서 설정된 바이트 배열 pattern()을 찾습니다.
pattern()이 haystack 에서 일치한 위치를 반환하며, 일치하는 부분이 없으면 -1을 반환합니다.
[noexcept] qsizetype QStaticByteArrayMatcher::indexIn(const char *haystack, qsizetype hlen, qsizetype from = 0) const
길이 hlen 인 문자열 haystack 을, 바이트 위치 from (기본값 0, 즉 첫 번째 바이트부터)에서 시작하여, 생성자에서 설정된 바이트 배열 pattern()을 검색합니다.
pattern()이 haystack 에서 일치한 위치를 반환하며, 일치하는 부분이 없으면 -1을 반환합니다.
QByteArray QStaticByteArrayMatcher::pattern() const
이 바이트 배열 매처가 검색할 바이트 배열 패턴을 반환합니다.
QByteArrayMatcher::setPattern()도 참조하십시오 .
관련 비멤버
[constexpr noexcept] template <size_t N> QStaticByteArrayMatcher<N> qMakeStaticByteArrayMatcher(const char (&pattern)[N])
전달된 pattern 에서 자동으로 결정된 올바른 N 를 포함하는 QStaticByteArrayMatcher 를 반환합니다.
이 함수의 기능을 최대한 활용하려면, 결과를 auto 변수에 할당하십시오:
static const auto matcher = qMakeStaticByteArrayMatcher("needle");© 2026 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.