<?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>QUuid 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">QUuid Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1><p>The QUuid class stores a Universally Unique Identifier (UUID). <a href="#details">More...</a></p> <h3>Types</h3><ul><li><div class="fn" />enum <b><a href="quuid.html#Variant-enum">Variant</a></b> { VarUnknown, NCS, DCE, Microsoft, Reserved }</li><li><div class="fn" />enum <b><a href="quuid.html#Version-enum">Version</a></b> { VerUnknown, Time, EmbeddedPOSIX, Name, Random }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="quuid.html#QUuid">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="quuid.html#QUuid-2">__init__</a></b> (<i>self</i>, int <i>l</i>, int <i>w1</i>, int <i>w2</i>, str <i>b1</i>, str <i>b2</i>, str <i>b3</i>, str <i>b4</i>, str <i>b5</i>, str <i>b6</i>, str <i>b7</i>, str <i>b8</i>)</li><li><div class="fn" /><b><a href="quuid.html#QUuid-3">__init__</a></b> (<i>self</i>, QString)</li><li><div class="fn" /><b><a href="quuid.html#QUuid-4">__init__</a></b> (<i>self</i>, QByteArray)</li><li><div class="fn" /><b><a href="quuid.html#QUuid-5">__init__</a></b> (<i>self</i>, QUuid)</li><li><div class="fn" />bool <b><a href="quuid.html#isNull">isNull</a></b> (<i>self</i>)</li><li><div class="fn" />QByteArray <b><a href="quuid.html#toByteArray">toByteArray</a></b> (<i>self</i>)</li><li><div class="fn" />QByteArray <b><a href="quuid.html#toRfc4122">toRfc4122</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="quuid.html#toString">toString</a></b> (<i>self</i>)</li><li><div class="fn" />Variant <b><a href="quuid.html#variant">variant</a></b> (<i>self</i>)</li><li><div class="fn" />Version <b><a href="quuid.html#version">version</a></b> (<i>self</i>)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />QUuid <b><a href="quuid.html#createUuid">createUuid</a></b> ()</li><li><div class="fn" />QUuid <b><a href="quuid.html#fromRfc4122">fromRfc4122</a></b> (QByteArray)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />bool <b><a href="quuid.html#__eq__">__eq__</a></b> (<i>self</i>, QUuid <i>orig</i>)</li><li><div class="fn" />bool <b><a href="quuid.html#__ge__">__ge__</a></b> (<i>self</i>, QUuid <i>other</i>)</li><li><div class="fn" />bool <b><a href="quuid.html#__gt__">__gt__</a></b> (<i>self</i>, QUuid <i>other</i>)</li><li><div class="fn" />bool <b><a href="quuid.html#__le__">__le__</a></b> (<i>self</i>, QUuid <i>other</i>)</li><li><div class="fn" />bool <b><a href="quuid.html#__lt__">__lt__</a></b> (<i>self</i>, QUuid <i>other</i>)</li><li><div class="fn" />bool <b><a href="quuid.html#__ne__">__ne__</a></b> (<i>self</i>, QUuid <i>orig</i>)</li><li><div class="fn" />str <b><a href="quuid.html#__repr__">__repr__</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QUuid class stores a Universally Unique Identifier (UUID).</p> <p>Using <i>U</i>niversally <i>U</i>nique <i>ID</i>entifiers (UUID) is a standard way to uniquely identify entities in a distributed computing environment. A UUID is a 16-byte (128-bit) number generated by some algorithm that is meant to guarantee that the UUID will be unique in the distributed computing environment where it is used. The acronym GUID is often used instead, <i>G</i>lobally <i>U</i>nique <i>ID</i>entifiers, but it refers to the same thing.</p> <a id="variant-field" name="variant-field" /> <p>Actually, the GUID is one <i>variant</i> of UUID. Multiple variants are in use. Each UUID contains a bit field that specifies which type (variant) of UUID it is. Call <a href="quuid.html#variant">variant</a>() to discover which type of UUID an instance of QUuid contains. It extracts the three most signifcant bits of byte 8 of the 16 bytes. In QUuid, byte 8 is <tt>QUuid.data4[0]</tt>. If you create instances of QUuid using the constructor that accepts all the numeric values as parameters, use the following table to set the three most significant bits of parameter <tt>b1</tt>, which becomes <tt>QUuid.data4[0]</tt> and contains the variant field in its three most significant bits. In the table, 'x' means <i>don't care</i>.</p> <table class="generic"> <thead> <tr class="qt-style"> <th>msb0</th> <th>msb1</th> <th>msb2</th> <th>Variant</th> </tr> </thead> <tr class="odd" valign="top"> <td>0</td> <td>x</td> <td>x</td> <td>NCS (Network Computing System)</td> </tr> <tr class="even" valign="top"> <td>1</td> <td>0</td> <td>x</td> <td>DCE (Distributed Computing Environment)</td> </tr> <tr class="odd" valign="top"> <td>1</td> <td>1</td> <td>0</td> <td>Microsoft (GUID)</td> </tr> <tr class="even" valign="top"> <td>1</td> <td>1</td> <td>1</td> <td>Reserved for future expansion</td> </tr> </table> <a id="version-field" name="version-field" /> <p>If <a href="quuid.html#variant">variant</a>() returns <a href="quuid.html#Variant-enum">QUuid.DCE</a>, the UUID also contains a <i>version</i> field in the four most significant bits of <tt>QUuid.data3</tt>, and you can call <a href="quuid.html#version">version</a>() to discover which version your QUuid contains. If you create instances of QUuid using the constructor that accepts all the numeric values as parameters, use the following table to set the four most significant bits of parameter <tt>w2</tt>, which becomes <tt>QUuid.data3</tt> and contains the version field in its four most significant bits.</p> <table class="generic"> <thead> <tr class="qt-style"> <th>msb0</th> <th>msb1</th> <th>msb2</th> <th>msb3</th> <th>Version</th> </tr> </thead> <tr class="odd" valign="top"> <td>0</td> <td>0</td> <td>0</td> <td>1</td> <td>Time</td> </tr> <tr class="even" valign="top"> <td>0</td> <td>0</td> <td>1</td> <td>0</td> <td>Embedded POSIX</td> </tr> <tr class="odd" valign="top"> <td>0</td> <td>0</td> <td>1</td> <td>1</td> <td>Name</td> </tr> <tr class="even" valign="top"> <td>0</td> <td>1</td> <td>0</td> <td>0</td> <td>Random</td> </tr> </table> <p>The field layouts for the DCE versions listed in the table above are specified in the <a href="http://www.ietf.org/rfc/rfc4122.txt">Network Working Group UUID Specification</a>.</p> <p>Most platforms provide a tool for generating new UUIDs, e.g. <tt>uuidgen</tt> and <tt>guidgen</tt>. You can also use <a href="quuid.html#createUuid">createUuid</a>(). UUIDs generated by <a href="quuid.html#createUuid">createUuid</a>() are of the random type. Their <a href="quuid.html#Version-enum">QUuid.Version</a> bits are set to <a href="quuid.html#Version-enum">QUuid.Random</a>, and their <a href="quuid.html#Variant-enum">QUuid.Variant</a> bits are set to <a href="quuid.html#Variant-enum">QUuid.DCE</a>. The rest of the UUID is composed of random numbers. Theoretically, this means there is a small chance that a UUID generated by <a href="quuid.html#createUuid">createUuid</a>() will not be unique. But it is <a href="http://en.wikipedia.org/wiki/Universally_Unique_Identifier#Random_UUID_probability_of_duplicates"> a <i>very</i> small chance</a>.</p> <p>UUIDs can be constructed from numeric values or from strings, or using the static <a href="quuid.html#createUuid">createUuid</a>() function. They can be converted to a string with <a href="quuid.html#toString">toString</a>(). UUIDs have a <a href="quuid.html#variant">variant</a>() and a <a href="quuid.html#version">version</a>(), and null UUIDs return true from <a href="quuid.html#isNull">isNull</a>().</p> <hr /><h2>Type Documentation</h2><h3 class="fn"><a name="Variant-enum" />QUuid.Variant</h3><p>This enum defines the values used in the <a href="quuid.html#variant-field">variant field</a> of the UUID. The value in the variant field determines the layout of the 128-bit value.</p> <table class="valuelist"> <tr class="odd" valign="top"> <th class="tblConst">Constant</th> <th class="tblval">Value</th> <th class="tbldscr">Description</th> </tr> <tr> <td class="topAlign"><tt>QUuid.VarUnknown</tt></td> <td class="topAlign"><tt>-1</tt></td> <td class="topAlign">Variant is unknown</td> </tr> <tr> <td class="topAlign"><tt>QUuid.NCS</tt></td> <td class="topAlign"><tt>0</tt></td> <td class="topAlign">Reserved for NCS (Network Computing System) backward compatibility</td> </tr> <tr> <td class="topAlign"><tt>QUuid.DCE</tt></td> <td class="topAlign"><tt>2</tt></td> <td class="topAlign">Distributed Computing Environment, the scheme used by <a href="quuid.html">QUuid</a></td> </tr> <tr> <td class="topAlign"><tt>QUuid.Microsoft</tt></td> <td class="topAlign"><tt>6</tt></td> <td class="topAlign">Reserved for Microsoft backward compatibility (GUID)</td> </tr> <tr> <td class="topAlign"><tt>QUuid.Reserved</tt></td> <td class="topAlign"><tt>7</tt></td> <td class="topAlign">Reserved for future definition</td> </tr> </table> <h3 class="fn"><a name="Version-enum" />QUuid.Version</h3><p>This enum defines the values used in the <a href="quuid.html#version-field">version field</a> of the UUID. The version field is meaningful only if the value in the <a href="quuid.html#variant-field">variant field</a> is <a href="quuid.html#Variant-enum">QUuid.DCE</a>.</p> <table class="valuelist"> <tr class="odd" valign="top"> <th class="tblConst">Constant</th> <th class="tblval">Value</th> <th class="tbldscr">Description</th> </tr> <tr> <td class="topAlign"><tt>QUuid.VerUnknown</tt></td> <td class="topAlign"><tt>-1</tt></td> <td class="topAlign">Version is unknown</td> </tr> <tr> <td class="topAlign"><tt>QUuid.Time</tt></td> <td class="topAlign"><tt>1</tt></td> <td class="topAlign">Time-based, by using timestamp, clock sequence, and MAC network card address (if available) for the node sections</td> </tr> <tr> <td class="topAlign"><tt>QUuid.EmbeddedPOSIX</tt></td> <td class="topAlign"><tt>2</tt></td> <td class="topAlign">DCE Security version, with embedded POSIX UUIDs</td> </tr> <tr> <td class="topAlign"><tt>QUuid.Name</tt></td> <td class="topAlign"><tt>3</tt></td> <td class="topAlign">Name-based, by using values from a name for all sections</td> </tr> <tr> <td class="topAlign"><tt>QUuid.Random</tt></td> <td class="topAlign"><tt>4</tt></td> <td class="topAlign">Random-based, by using random numbers for all sections</td> </tr> </table> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QUuid" />QUuid.__init__ (<i>self</i>)</h3><p>Creates the null UUID. <a href="quuid.html#toString">toString</a>() will output the null UUID as "{00000000-0000-0000-0000-000000000000}".</p> <h3 class="fn"><a name="QUuid-2" />QUuid.__init__ (<i>self</i>, int <i>l</i>, int <i>w1</i>, int <i>w2</i>, str <i>b1</i>, str <i>b2</i>, str <i>b3</i>, str <i>b4</i>, str <i>b5</i>, str <i>b6</i>, str <i>b7</i>, str <i>b8</i>)</h3><p>Creates a UUID with the value specified by the parameters, <i>l</i>, <i>w1</i>, <i>w2</i>, <i>b1</i>, <i>b2</i>, <i>b3</i>, <i>b4</i>, <i>b5</i>, <i>b6</i>, <i>b7</i>, <i>b8</i>.</p> <p>Example:</p> <pre class="cpp"> <span class="comment">// {67C8770B-44F1-410A-AB9A-F9B5446F13EE}</span> <span class="type"><a href="quuid.html">QUuid</a></span> IID_MyInterface(<span class="number">0x67c8770b</span><span class="operator">,</span> <span class="number">0x44f1</span><span class="operator">,</span> <span class="number">0x410a</span><span class="operator">,</span> <span class="number">0xab</span><span class="operator">,</span> <span class="number">0x9a</span><span class="operator">,</span> <span class="number">0xf9</span><span class="operator">,</span> <span class="number">0xb5</span><span class="operator">,</span> <span class="number">0x44</span><span class="operator">,</span> <span class="number">0x6f</span><span class="operator">,</span> <span class="number">0x13</span><span class="operator">,</span> <span class="number">0xee</span>) </pre> <h3 class="fn"><a name="QUuid-3" />QUuid.__init__ (<i>self</i>, QString)</h3><p>Creates a <a href="quuid.html">QUuid</a> object from the string <i>text</i>, which must be formatted as five hex fields separated by '-', e.g., "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" where 'x' is a hex digit. The curly braces shown here are optional, but it is normal to include them. If the conversion fails, a null UUID is created. See <a href="quuid.html#toString">toString</a>() for an explanation of how the five hex fields map to the public data members in <a href="quuid.html">QUuid</a>.</p> <p><b>See also</b> <a href="quuid.html#toString">toString</a>() and <a href="quuid.html#QUuid">QUuid</a>().</p> <h3 class="fn"><a name="QUuid-4" />QUuid.__init__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>)</h3><h3 class="fn"><a name="QUuid-5" />QUuid.__init__ (<i>self</i>, <a href="quuid.html">QUuid</a>)</h3><p>Creates a <a href="quuid.html">QUuid</a> object from the <a href="qbytearray.html">QByteArray</a> <i>text</i>, which must be formatted as five hex fields separated by '-', e.g., "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" where 'x' is a hex digit. The curly braces shown here are optional, but it is normal to include them. If the conversion fails, a null UUID is created. See <a href="quuid.html#toByteArray">toByteArray</a>() for an explanation of how the five hex fields map to the public data members in <a href="quuid.html">QUuid</a>.</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="quuid.html#toByteArray">toByteArray</a>() and <a href="quuid.html#QUuid">QUuid</a>().</p> <h3 class="fn"><a name="createUuid" /><a href="quuid.html">QUuid</a> QUuid.createUuid ()</h3><p>On any platform other than Windows, this function returns a new UUID with variant <a href="quuid.html#Variant-enum">QUuid.DCE</a> and version <a href="quuid.html#Version-enum">QUuid.Random</a>. If the /dev/urandom device exists, then the numbers used to construct the UUID will be of cryptographic quality, which will make the UUID unique. Otherwise, the numbers of the UUID will be obtained from the local pseudo-random number generator (<a href="qtcore.html#qrand">qrand</a>(), which is seeded by <a href="qtcore.html#qsrand">qsrand</a>()) which is usually not of cryptograhic quality, which means that the UUID can't be guaranteed to be unique.</p> <p>On a Windows platform, a GUID is generated, which almost certainly <i>will</i> be unique, on this or any other system, networked or not.</p> <p><b>See also</b> <a href="quuid.html#variant">variant</a>() and <a href="quuid.html#version">version</a>().</p> <h3 class="fn"><a name="fromRfc4122" /><a href="quuid.html">QUuid</a> QUuid.fromRfc4122 (<a href="qbytearray.html">QByteArray</a>)</h3><p>Creates a <a href="quuid.html">QUuid</a> object from the binary representation of the UUID given by <i>bytes</i>, as specified by RFC 4122 section 4.1.2. See <a href="quuid.html#toRfc4122">toRfc4122</a>() for a further explanation of the order of bytes required.</p> <p>The byte array accepted is <i>not</i> a human readable format.</p> <p>If the conversion fails, a null UUID is created.</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="quuid.html#toRfc4122">toRfc4122</a>() and <a href="quuid.html#QUuid">QUuid</a>().</p> <h3 class="fn"><a name="isNull" />bool QUuid.isNull (<i>self</i>)</h3><p>Returns true if this is the null UUID {00000000-0000-0000-0000-000000000000}; otherwise returns false.</p> <h3 class="fn"><a name="toByteArray" /><a href="qbytearray.html">QByteArray</a> QUuid.toByteArray (<i>self</i>)</h3><p>Returns the binary representation of this <a href="quuid.html">QUuid</a>. The byte array is formatted as five hex fields separated by '-' and enclosed in curly braces, i.e., "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" where 'x' is a hex digit. From left to right, the five hex fields are obtained from the four public data members in <a href="quuid.html">QUuid</a> as follows:</p> <table class="generic"> <thead> <tr class="qt-style"> <th>Field #</th> <th>Source</th> </tr> </thead> <tr class="odd" valign="top"> <td>1</td> <td>data1</td> </tr> <tr class="even" valign="top"> <td>2</td> <td>data2</td> </tr> <tr class="odd" valign="top"> <td>3</td> <td>data3</td> </tr> <tr class="even" valign="top"> <td>4</td> <td>data4[0] .. data4[1]</td> </tr> <tr class="odd" valign="top"> <td>5</td> <td>data4[2] .. data4[7]</td> </tr> </table> <p>This function was introduced in Qt 4.8.</p> <h3 class="fn"><a name="toRfc4122" /><a href="qbytearray.html">QByteArray</a> QUuid.toRfc4122 (<i>self</i>)</h3><p>Returns the binary representation of this <a href="quuid.html">QUuid</a>. The byte array is in big endian format, and formatted according to RFC 4122, section 4.1.2 - "Layout and byte order".</p> <p>The order is as follows:</p> <table class="generic"> <thead> <tr class="qt-style"> <th>Field #</th> <th>Source</th> </tr> </thead> <tr class="odd" valign="top"> <td>1</td> <td>data1</td> </tr> <tr class="even" valign="top"> <td>2</td> <td>data2</td> </tr> <tr class="odd" valign="top"> <td>3</td> <td>data3</td> </tr> <tr class="even" valign="top"> <td>4</td> <td>data4[0] .. data4[7]</td> </tr> </table> <p>This function was introduced in Qt 4.8.</p> <h3 class="fn"><a name="toString" />QString QUuid.toString (<i>self</i>)</h3><p>Returns the string representation of this <a href="quuid.html">QUuid</a>. The string is formatted as five hex fields separated by '-' and enclosed in curly braces, i.e., "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" where 'x' is a hex digit. From left to right, the five hex fields are obtained from the four public data members in <a href="quuid.html">QUuid</a> as follows:</p> <table class="generic"> <thead> <tr class="qt-style"> <th>Field #</th> <th>Source</th> </tr> </thead> <tr class="odd" valign="top"> <td>1</td> <td>data1</td> </tr> <tr class="even" valign="top"> <td>2</td> <td>data2</td> </tr> <tr class="odd" valign="top"> <td>3</td> <td>data3</td> </tr> <tr class="even" valign="top"> <td>4</td> <td>data4[0] .. data4[1]</td> </tr> <tr class="odd" valign="top"> <td>5</td> <td>data4[2] .. data4[7]</td> </tr> </table> <h3 class="fn"><a name="variant" /><a href="quuid.html#Variant-enum">Variant</a> QUuid.variant (<i>self</i>)</h3><p>Returns the value in the <a href="quuid.html#variant-field">variant field</a> of the UUID. If the return value is <a href="quuid.html#Variant-enum">QUuid.DCE</a>, call <a href="quuid.html#version">version</a>() to see which layout it uses. The null UUID is considered to be of an unknown variant.</p> <p><b>See also</b> <a href="quuid.html#version">version</a>().</p> <h3 class="fn"><a name="version" /><a href="quuid.html#Version-enum">Version</a> QUuid.version (<i>self</i>)</h3><p>Returns the <a href="quuid.html#version-field">version field</a> of the UUID, if the UUID's <a href="quuid.html#variant-field">variant field</a> is <a href="quuid.html#Variant-enum">QUuid.DCE</a>. Otherwise it returns <a href="quuid.html#Version-enum">QUuid.VerUnknown</a>.</p> <p><b>See also</b> <a href="quuid.html#variant">variant</a>().</p> <h3 class="fn"><a name="__eq__" />bool QUuid.__eq__ (<i>self</i>, <a href="quuid.html">QUuid</a> <i>orig</i>)</h3><h3 class="fn"><a name="__ge__" />bool QUuid.__ge__ (<i>self</i>, <a href="quuid.html">QUuid</a> <i>other</i>)</h3><h3 class="fn"><a name="__gt__" />bool QUuid.__gt__ (<i>self</i>, <a href="quuid.html">QUuid</a> <i>other</i>)</h3><h3 class="fn"><a name="__le__" />bool QUuid.__le__ (<i>self</i>, <a href="quuid.html">QUuid</a> <i>other</i>)</h3><h3 class="fn"><a name="__lt__" />bool QUuid.__lt__ (<i>self</i>, <a href="quuid.html">QUuid</a> <i>other</i>)</h3><h3 class="fn"><a name="__ne__" />bool QUuid.__ne__ (<i>self</i>, <a href="quuid.html">QUuid</a> <i>orig</i>)</h3><h3 class="fn"><a name="__repr__" />str QUuid.__repr__ (<i>self</i>)</h3><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>