Qt 4.8
|
The QByteArrayMatcher class holds a sequence of bytes that can be quickly matched in a byte array. More...
#include <qbytearraymatcher.h>
Classes | |
struct | Data |
Public Functions | |
int | indexIn (const QByteArray &ba, int from=0) const |
Searches the byte array ba, from byte position from (default 0, i.e. More... | |
int | indexIn (const char *str, int len, int from=0) const |
Searches the char string str, which has length len, from byte position from (default 0, i.e. More... | |
QByteArrayMatcher & | operator= (const QByteArrayMatcher &other) |
Assigns the other byte array matcher to this byte array matcher. More... | |
QByteArray | pattern () const |
Returns the byte array pattern that this byte array matcher will search for. More... | |
QByteArrayMatcher () | |
Constructs an empty byte array matcher that won't match anything. More... | |
QByteArrayMatcher (const QByteArray &pattern) | |
Constructs a byte array matcher that will search for pattern. More... | |
QByteArrayMatcher (const char *pattern, int length) | |
Constructs a byte array matcher from pattern. More... | |
QByteArrayMatcher (const QByteArrayMatcher &other) | |
Copies the other byte array matcher to this byte array matcher. More... | |
void | setPattern (const QByteArray &pattern) |
Sets the byte array that this byte array matcher will search for to pattern. More... | |
~QByteArrayMatcher () | |
Destroys the byte array matcher. More... | |
Properties | |
union { | |
uint dummy [256] | |
Data p | |
}; | |
QByteArrayMatcherPrivate * | d |
QByteArray | q_pattern |
The 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 indexIn() is faster than matching a plain 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 QByteArrayMatcher with the QByteArray you want to search for. Then call indexIn() on the QByteArray that you want to search.
Definition at line 55 of file qbytearraymatcher.h.
QByteArrayMatcher::QByteArrayMatcher | ( | ) |
Constructs an empty byte array matcher that won't match anything.
Call setPattern() to give it a pattern to match.
Definition at line 122 of file qbytearraymatcher.cpp.
|
explicit |
Constructs a byte array matcher that will search for pattern.
Call indexIn() to perform a search.
Definition at line 147 of file qbytearraymatcher.cpp.
|
explicit |
Constructs a byte array matcher from pattern.
pattern has the given length. pattern must remain in scope, but the destructor does not delete pattern.
Definition at line 135 of file qbytearraymatcher.cpp.
QByteArrayMatcher::QByteArrayMatcher | ( | const QByteArrayMatcher & | other | ) |
Copies the other byte array matcher to this byte array matcher.
Definition at line 158 of file qbytearraymatcher.cpp.
QByteArrayMatcher::~QByteArrayMatcher | ( | ) |
int QByteArrayMatcher::indexIn | ( | const QByteArray & | ba, |
int | from = 0 |
||
) | const |
Searches the byte array ba, from byte position from (default 0, i.e.
from the first byte), for the byte array pattern() that was set in the constructor or in the most recent call to setPattern(). Returns the position where the pattern() matched in ba, or -1 if no match was found.
Definition at line 202 of file qbytearraymatcher.cpp.
Referenced by QByteArray::count(), QHttpNetworkReplyPrivate::parseHeader(), and QByteArray::replace().
int QByteArrayMatcher::indexIn | ( | const char * | str, |
int | len, | ||
int | from = 0 |
||
) | const |
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 pattern() that was set in the constructor or in the most recent call to setPattern(). Returns the position where the pattern() matched in str, or -1 if no match was found.
Definition at line 217 of file qbytearraymatcher.cpp.
QByteArrayMatcher & QByteArrayMatcher::operator= | ( | const QByteArrayMatcher & | other | ) |
Assigns the other byte array matcher to this byte array matcher.
Definition at line 174 of file qbytearraymatcher.cpp.
Referenced by QByteArrayMatcher().
|
inline |
Returns the byte array pattern that this byte array matcher will search for.
Definition at line 70 of file qbytearraymatcher.h.
Referenced by QByteArrayMatcher(), and setPattern().
void QByteArrayMatcher::setPattern | ( | const QByteArray & | pattern | ) |
Sets the byte array that this byte array matcher will search for to pattern.
Definition at line 187 of file qbytearraymatcher.cpp.
union { ... } |
|
private |
Definition at line 78 of file qbytearraymatcher.h.
uint QByteArrayMatcher::dummy[256] |
Definition at line 91 of file qbytearraymatcher.h.
Data QByteArrayMatcher::p |
Definition at line 92 of file qbytearraymatcher.h.
Referenced by indexIn(), operator=(), QByteArrayMatcher(), and setPattern().
|
private |
Definition at line 79 of file qbytearraymatcher.h.
Referenced by operator=(), and setPattern().