<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html><head><title>QByteArrayMatcher Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } td.postheader { font-family: sans-serif } tr.address { font-family: sans-serif } body { background: #ffffff; color: black; } </style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QByteArrayMatcher Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1><p>The QByteArrayMatcher class holds a sequence of bytes that can be quickly matched in a byte array. <a href="#details">More...</a></p> <h3>Methods</h3><ul><li><div class="fn" /><b><a href="qbytearraymatcher.html#QByteArrayMatcher">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qbytearraymatcher.html#QByteArrayMatcher-2">__init__</a></b> (<i>self</i>, QByteArray <i>pattern</i>)</li><li><div class="fn" /><b><a href="qbytearraymatcher.html#QByteArrayMatcher-3">__init__</a></b> (<i>self</i>, QByteArrayMatcher <i>other</i>)</li><li><div class="fn" />int <b><a href="qbytearraymatcher.html#indexIn">indexIn</a></b> (<i>self</i>, QByteArray <i>ba</i>, int <i>from</i> = 0)</li><li><div class="fn" />QByteArray <b><a href="qbytearraymatcher.html#pattern">pattern</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qbytearraymatcher.html#setPattern">setPattern</a></b> (<i>self</i>, QByteArray <i>pattern</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QByteArrayMatcher class holds a sequence of bytes that can be quickly matched in a byte array.</p> <p>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 <a href="qbytearraymatcher.html#indexIn">indexIn</a>() is faster than matching a plain <a href="qbytearray.html">QByteArray</a> with <a href="qbytearray.html#indexOf">QByteArray.indexOf</a>() if repeated matching takes place. This class offers no benefit if you are doing one-off byte array matches.</p> <p>Create the QByteArrayMatcher with the <a href="qbytearray.html">QByteArray</a> you want to search for. Then call <a href="qbytearraymatcher.html#indexIn">indexIn</a>() on the <a href="qbytearray.html">QByteArray</a> that you want to search.</p> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QByteArrayMatcher" />QByteArrayMatcher.__init__ (<i>self</i>)</h3><p>Constructs an empty byte array matcher that won't match anything. Call <a href="qbytearraymatcher.html#setPattern">setPattern</a>() to give it a pattern to match.</p> <h3 class="fn"><a name="QByteArrayMatcher-2" />QByteArrayMatcher.__init__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a> <i>pattern</i>)</h3><p>Constructs a byte array matcher that will search for <i>pattern</i>. Call <a href="qbytearraymatcher.html#indexIn">indexIn</a>() to perform a search.</p> <h3 class="fn"><a name="QByteArrayMatcher-3" />QByteArrayMatcher.__init__ (<i>self</i>, <a href="qbytearraymatcher.html">QByteArrayMatcher</a> <i>other</i>)</h3><p>Constructs a byte array matcher from <i>pattern</i>. <i>pattern</i> has the given <i>length</i>. <i>pattern</i> must remain in scope, but the destructor does not delete <i>pattern</i>.</p> <h3 class="fn"><a name="indexIn" />int QByteArrayMatcher.indexIn (<i>self</i>, <a href="qbytearray.html">QByteArray</a> <i>ba</i>, int <i>from</i> = 0)</h3><p>Searches the byte array <i>ba</i>, from byte position <i>from</i> (default 0, i.e. from the first byte), for the byte array <a href="qbytearraymatcher.html#pattern">pattern</a>() that was set in the constructor or in the most recent call to <a href="qbytearraymatcher.html#setPattern">setPattern</a>(). Returns the position where the <a href="qbytearraymatcher.html#pattern">pattern</a>() matched in <i>ba</i>, or -1 if no match was found.</p> <h3 class="fn"><a name="pattern" /><a href="qbytearray.html">QByteArray</a> QByteArrayMatcher.pattern (<i>self</i>)</h3><p>Returns the byte array pattern that this byte array matcher will search for.</p> <p><b>See also</b> <a href="qbytearraymatcher.html#setPattern">setPattern</a>().</p> <h3 class="fn"><a name="setPattern" />QByteArrayMatcher.setPattern (<i>self</i>, <a href="qbytearray.html">QByteArray</a> <i>pattern</i>)</h3><p>Sets the byte array that this byte array matcher will search for to <i>pattern</i>.</p> <p><b>See also</b> <a href="qbytearraymatcher.html#pattern">pattern</a>() and <a href="qbytearraymatcher.html#indexIn">indexIn</a>().</p> <address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>