IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QStaticByteArrayMatcher Class

The https:// class is a compile-time version of QByteArrayMatcher.

This class was introduced in Qt 5.9.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QStaticByteArrayMatcher Class▲

  • Header: QStaticByteArrayMatcher

  • Since: Qt 5.9

  • qmake: QT += core

  • Group: QStaticByteArrayMatcher is part of tools, string-processing

Detailed Description▲

This class is useful when you have a sequence of bytes that you want to repeatedly match against some byte arrays (perhaps in a loop), or when you want to search for the same sequence of bytes multiple times in the same byte array. Using a matcher object and https://() is faster than matching a plain QByteArray with QByteArray::indexOf(), in particular if repeated matching takes place.

Unlike QByteArrayMatcher, this class calculates the internal representation at compile-time, if your compiler supports C++14-level constexpr (C++11 is not sufficient), so it can even benefit if you are doing one-off byte array matches.

Create the https:// by calling qMakeStaticByteArrayMatcher(), passing it the C string literal you want to search for. Store the return value of that function in a static const auto variable, so you don't need to pass the N template parameter explicitly:

 
Sélectionnez
static const auto matcher = qMakeStaticByteArrayMatcher("needle");

Then call https://() on the QByteArray in which you want to search, just like with QByteArrayMatcher.

Since this class is designed to do all the up-front calculations at compile-time, it does not offer a setPattern() method.

Qt detects the necessary C++14 compiler support by way of the feature test recommendations from https://.

See Also▲

See also QByteArrayMatcher, QStringMatcher

Member Function Documentation▲

 

int QStaticByteArrayMatcher::indexIn(const QByteArray &haystack, int from = 0) const▲

Searches the char string haystack, from byte position from (default 0, i.e. from the first byte), for the byte array https://() that was set in the constructor.

Returns the position where the https://() matched in haystack, or -1 if no match was found.

int QStaticByteArrayMatcher::indexIn(const char *haystack, int hlen, int from = 0) const▲

Searches the char string haystack, which has length hlen, from byte position from (default 0, i.e. from the first byte), for the byte array https://() that was set in the constructor.

Returns the position where the https://() matched in haystack, or -1 if no match was found.

QByteArray QStaticByteArrayMatcher::pattern() const▲

Returns the byte array pattern that this byte array matcher will search for.

See Also▲

See also QByteArrayMatcher::setPattern()

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+   

Ce document est disponible sous la licence https:// telle que publiée par la Free Software Foundation.