Table Of Contents

Previous topic

QCryptographicHash

Next topic

QBitArray

QByteArrayMatcher

Synopsis

Functions

Detailed Description

The PySide.QtCore.QByteArrayMatcher class holds a sequence of bytes that can be quickly matched in a byte array.

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 PySide.QtCore.QByteArrayMatcher.indexIn() is faster than matching a plain PySide.QtCore.QByteArray with QByteArray.indexOf() if repeated matching takes place. This class offers no benefit if you are doing one-off byte array matches.

Create the PySide.QtCore.QByteArrayMatcher with the PySide.QtCore.QByteArray you want to search for. Then call PySide.QtCore.QByteArrayMatcher.indexIn() on the PySide.QtCore.QByteArray that you want to search.

See also

PySide.QtCore.QByteArray QStringMatcher

class PySide.QtCore.QByteArrayMatcher
class PySide.QtCore.QByteArrayMatcher(pattern)
class PySide.QtCore.QByteArrayMatcher(other)
class PySide.QtCore.QByteArrayMatcher(pattern, length)
Parameters:

Constructs an empty byte array matcher that won’t match anything. Call PySide.QtCore.QByteArrayMatcher.setPattern() to give it a pattern to match.

Constructs a byte array matcher that will search for pattern . Call PySide.QtCore.QByteArrayMatcher.indexIn() to perform a search.

Copies the other byte array matcher to this byte array matcher.

Constructs a byte array matcher from pattern . pattern has the given length . pattern must remain in scope, but the destructor does not delete pattern .

PySide.QtCore.QByteArrayMatcher.indexIn(str, len[, from=0])
Parameters:
  • str – str
  • lenPySide.QtCore.int
  • fromPySide.QtCore.int
Return type:

PySide.QtCore.int

Searches the char string str , which has length len , from byte position from (default 0, i.e. from the first byte), for the byte array PySide.QtCore.QByteArrayMatcher.pattern() that was set in the constructor or in the most recent call to PySide.QtCore.QByteArrayMatcher.setPattern() . Returns the position where the PySide.QtCore.QByteArrayMatcher.pattern() matched in str , or -1 if no match was found.

PySide.QtCore.QByteArrayMatcher.indexIn(ba[, from=0])
Parameters:
Return type:

PySide.QtCore.int

Searches the byte array ba , from byte position from (default 0, i.e. from the first byte), for the byte array PySide.QtCore.QByteArrayMatcher.pattern() that was set in the constructor or in the most recent call to PySide.QtCore.QByteArrayMatcher.setPattern() . Returns the position where the PySide.QtCore.QByteArrayMatcher.pattern() matched in ba , or -1 if no match was found.

PySide.QtCore.QByteArrayMatcher.pattern()
Return type:PySide.QtCore.QByteArray

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

PySide.QtCore.QByteArrayMatcher.setPattern(pattern)
Parameters:patternPySide.QtCore.QByteArray

Sets the byte array that this byte array matcher will search for to pattern .