<?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>QDBusArgument 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">QDBusArgument Class Reference<br /><sup><sup>[<a href="qtdbus.html">QtDBus</a> module]</sup></sup></h1><p>The QDBusArgument class is used to marshall and demarshall D-Bus arguments. <a href="#details">More...</a></p> <h3>Methods</h3><ul><li><div class="fn" /><b><a href="qdbusargument.html#QDBusArgument">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qdbusargument.html#QDBusArgument-2">__init__</a></b> (<i>self</i>, QDBusArgument <i>other</i>)</li><li><div class="fn" /><b><a href="qdbusargument.html#QDBusArgument-3">__init__</a></b> (<i>self</i>, object <i>arg</i>, int <i>id</i> = QMetaType.Int)</li><li><div class="fn" /> <b><a href="qdbusargument.html#add">add</a></b> (<i>self</i>, object <i>arg</i>, int <i>id</i> = QMetaType.Int)</li><li><div class="fn" /><b><a href="qdbusargument.html#beginArray">beginArray</a></b> (<i>self</i>, int <i>id</i>)</li><li><div class="fn" /><b><a href="qdbusargument.html#beginMap">beginMap</a></b> (<i>self</i>, int <i>kid</i>, int <i>vid</i>)</li><li><div class="fn" /><b><a href="qdbusargument.html#beginMapEntry">beginMapEntry</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qdbusargument.html#beginStructure">beginStructure</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qdbusargument.html#endArray">endArray</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qdbusargument.html#endMap">endMap</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qdbusargument.html#endMapEntry">endMapEntry</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qdbusargument.html#endStructure">endStructure</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p> In C++ the QDBusArgument class is used to marshall and demarshall DBus collection types, i.e. arrays, structures and maps. In PyQt values are de-marshalled automatically and QDBusArgument is only used to marshall values. In C++ marshalling is done using overloaded left shift operators. In PyQt the single add() function is used. </p> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QDBusArgument" />QDBusArgument.__init__ (<i>self</i>)</h3><p>Constructs an empty <a href="qdbusargument.html">QDBusArgument</a> argument.</p> <p>An empty <a href="qdbusargument.html">QDBusArgument</a> object does not allow either reading or writing to be performed.</p> <h3 class="fn"><a name="QDBusArgument-2" />QDBusArgument.__init__ (<i>self</i>, <a href="qdbusargument.html">QDBusArgument</a> <i>other</i>)</h3><p>Constructs a copy of the <i>other</i> <a href="qdbusargument.html">QDBusArgument</a> object.</p> <p>Both objects will therefore contain the same state from this point forward. QDBusArguments are explicitly shared and, therefore, any modification to either copy will affect the other one too.</p> <h3 class="fn"><a name="QDBusArgument-3" />QDBusArgument.__init__ (<i>self</i>, object <i>arg</i>, int <i>id</i> = QMetaType.Int)</h3><h3 class="fn"><a name="add" /> QDBusArgument.add (<i>self</i>, object <i>arg</i>, int <i>id</i> = QMetaType.Int)</h3><h3 class="fn"><a name="beginArray" />QDBusArgument.beginArray (<i>self</i>, int <i>id</i>)</h3><p>Opens a new D-Bus array suitable for appending elements of meta-type <i>id</i>.</p> <p>This function is used usually in <tt>operator<<</tt> streaming operators, as in the following example:</p> <pre class="cpp"> <span class="comment">// append an array of MyElement types</span> <span class="type"><a href="qdbusargument.html">QDBusArgument</a></span> <span class="operator">&</span><span class="keyword">operator</span><span class="operator"><</span><span class="operator"><</span>(<span class="type"><a href="qdbusargument.html">QDBusArgument</a></span> <span class="operator">&</span>argument<span class="operator">,</span> <span class="keyword">const</span> MyArray <span class="operator">&</span>myarray) { argument<span class="operator">.</span>beginArray( <a href="qmetatype.html#qMetaTypeId">qMetaTypeId</a><span class="operator"><</span>MyElement<span class="operator">></span>() ); <span class="keyword">for</span> ( <span class="type">int</span> i <span class="operator">=</span> <span class="number">0</span>; i <span class="operator"><</span> myarray<span class="operator">.</span>length; <span class="operator">+</span><span class="operator">+</span>i ) argument <span class="operator"><</span><span class="operator"><</span> myarray<span class="operator">.</span>elements<span class="operator">[</span>i<span class="operator">]</span>; argument<span class="operator">.</span>endArray(); <span class="keyword">return</span> argument; } </pre> <p>If the type you want to marshall is a <a href="qlist.html">QList</a>, <a href="qvector.html">QVector</a> or any of the Qt's <a href="containers.html">Container Classes</a> that take one template parameter, you need not declare an <tt>operator<<</tt> function for it, since <a href="qtdbus.html">QtDBus</a> provides generic templates to do the job of marshalling the data. The same applies for STL's sequence containers, such as <tt>std.list</tt>, <tt>std.vector</tt>, etc.</p> <p><b>See also</b> <a href="qdbusargument.html#endArray">endArray</a>(), <a href="qdbusargument.html#beginStructure">beginStructure</a>(), and <a href="qdbusargument.html#beginMap">beginMap</a>().</p> <h3 class="fn"><a name="beginMap" />QDBusArgument.beginMap (<i>self</i>, int <i>kid</i>, int <i>vid</i>)</h3><p>Opens a new D-Bus map suitable for appending elements. Maps are containers that associate one entry (the key) to another (the value), such as Qt's <a href="qmap.html">QMap</a> or <a href="qhash.html">QHash</a>. The ids of the map's key and value meta types must be passed in <i>kid</i> and <i>vid</i> respectively.</p> <p>This function is used usually in <tt>operator<<</tt> streaming operators, as in the following example:</p> <pre class="cpp"> <span class="comment">// append a dictionary that associates ints to MyValue types</span> <span class="type"><a href="qdbusargument.html">QDBusArgument</a></span> <span class="operator">&</span><span class="keyword">operator</span><span class="operator"><</span><span class="operator"><</span>(<span class="type"><a href="qdbusargument.html">QDBusArgument</a></span> <span class="operator">&</span>argument<span class="operator">,</span> <span class="keyword">const</span> MyDictionary <span class="operator">&</span>mydict) { argument<span class="operator">.</span>beginMap( <span class="type"><a href="qvariant.html">QVariant</a></span><span class="operator">.</span>Int<span class="operator">,</span> <a href="qmetatype.html#qMetaTypeId">qMetaTypeId</a><span class="operator"><</span>MyValue<span class="operator">></span>() ); <span class="keyword">for</span> ( <span class="type">int</span> i <span class="operator">=</span> <span class="number">0</span>; i <span class="operator"><</span> mydict<span class="operator">.</span>length; <span class="operator">+</span><span class="operator">+</span>i ) { argument<span class="operator">.</span>beginMapEntry(); argument <span class="operator"><</span><span class="operator"><</span> mydict<span class="operator">.</span>data<span class="operator">[</span>i<span class="operator">]</span><span class="operator">.</span>key <span class="operator"><</span><span class="operator"><</span> mydict<span class="operator">.</span>data<span class="operator">[</span>i<span class="operator">]</span><span class="operator">.</span>value; argument<span class="operator">.</span>endMapEntry(); } argument<span class="operator">.</span>endMap(); <span class="keyword">return</span> argument; } </pre> <p>If the type you want to marshall is a <a href="qmap.html">QMap</a> or <a href="qhash.html">QHash</a>, you need not declare an <tt>operator<<</tt> function for it, since <a href="qtdbus.html">QtDBus</a> provides generic templates to do the job of marshalling the data.</p> <p><b>See also</b> <a href="qdbusargument.html#endMap">endMap</a>(), <a href="qdbusargument.html#beginStructure">beginStructure</a>(), <a href="qdbusargument.html#beginArray">beginArray</a>(), and <a href="qdbusargument.html#beginMapEntry">beginMapEntry</a>().</p> <h3 class="fn"><a name="beginMapEntry" />QDBusArgument.beginMapEntry (<i>self</i>)</h3><p>Opens a D-Bus map entry suitable for appending the key and value entries. This function is only valid when a map has been opened with <a href="qdbusargument.html#beginMap">beginMap</a>().</p> <p>See <a href="qdbusargument.html#beginMap">beginMap</a>() for an example of usage of this function.</p> <p><b>See also</b> <a href="qdbusargument.html#endMapEntry">endMapEntry</a>() and <a href="qdbusargument.html#beginMap">beginMap</a>().</p> <h3 class="fn"><a name="beginStructure" />QDBusArgument.beginStructure (<i>self</i>)</h3><p>Opens a new D-Bus structure suitable for appending new arguments.</p> <p>This function is used usually in <tt>operator<<</tt> streaming operators, as in the following example:</p> <pre class="cpp"> <span class="type"><a href="qdbusargument.html">QDBusArgument</a></span> <span class="operator">&</span><span class="keyword">operator</span><span class="operator"><</span><span class="operator"><</span>(<span class="type"><a href="qdbusargument.html">QDBusArgument</a></span> <span class="operator">&</span>argument<span class="operator">,</span> <span class="keyword">const</span> MyStructure <span class="operator">&</span>mystruct) { argument<span class="operator">.</span>beginStructure(); argument <span class="operator"><</span><span class="operator"><</span> mystruct<span class="operator">.</span>member1 <span class="operator"><</span><span class="operator"><</span> mystruct<span class="operator">.</span>member2 <span class="operator"><</span><span class="operator"><</span> <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span> ; argument<span class="operator">.</span>endStructure(); <span class="keyword">return</span> argument; } </pre> <p>Structures can contain other structures, so the following code is also valid:</p> <pre class="cpp"> <span class="type"><a href="qdbusargument.html">QDBusArgument</a></span> <span class="operator">&</span><span class="keyword">operator</span><span class="operator"><</span><span class="operator"><</span>(<span class="type"><a href="qdbusargument.html">QDBusArgument</a></span> <span class="operator">&</span>argument<span class="operator">,</span> <span class="keyword">const</span> MyStructure <span class="operator">&</span>mystruct) { argument<span class="operator">.</span>beginStructure(); argument <span class="operator"><</span><span class="operator"><</span> mystruct<span class="operator">.</span>member1 <span class="operator"><</span><span class="operator"><</span> mystruct<span class="operator">.</span>member2; argument<span class="operator">.</span>beginStructure(); argument <span class="operator"><</span><span class="operator"><</span> mystruct<span class="operator">.</span>member3<span class="operator">.</span>subMember1 <span class="operator"><</span><span class="operator"><</span> mystruct<span class="operator">.</span>member3<span class="operator">.</span>subMember2; argument<span class="operator">.</span>endStructure(); argument <span class="operator"><</span><span class="operator"><</span> mystruct<span class="operator">.</span>member4; argument<span class="operator">.</span>endStructure(); <span class="keyword">return</span> argument; } </pre> <p><b>See also</b> <a href="qdbusargument.html#endStructure">endStructure</a>(), <a href="qdbusargument.html#beginArray">beginArray</a>(), and <a href="qdbusargument.html#beginMap">beginMap</a>().</p> <h3 class="fn"><a name="endArray" />QDBusArgument.endArray (<i>self</i>)</h3><p>Closes a D-Bus array opened with <a href="qdbusargument.html#beginArray">beginArray</a>(). This function must be called same number of times that <a href="qdbusargument.html#beginArray">beginArray</a>() is called.</p> <p><b>See also</b> <a href="qdbusargument.html#beginArray">beginArray</a>(), <a href="qdbusargument.html#endStructure">endStructure</a>(), and <a href="qdbusargument.html#endMap">endMap</a>().</p> <h3 class="fn"><a name="endMap" />QDBusArgument.endMap (<i>self</i>)</h3><p>Closes a D-Bus map opened with <a href="qdbusargument.html#beginMap">beginMap</a>(). This function must be called same number of times that <a href="qdbusargument.html#beginMap">beginMap</a>() is called.</p> <p><b>See also</b> <a href="qdbusargument.html#beginMap">beginMap</a>(), <a href="qdbusargument.html#endStructure">endStructure</a>(), and <a href="qdbusargument.html#endArray">endArray</a>().</p> <h3 class="fn"><a name="endMapEntry" />QDBusArgument.endMapEntry (<i>self</i>)</h3><p>Closes a D-Bus map entry opened with <a href="qdbusargument.html#beginMapEntry">beginMapEntry</a>(). This function must be called same number of times that <a href="qdbusargument.html#beginMapEntry">beginMapEntry</a>() is called.</p> <p><b>See also</b> <a href="qdbusargument.html#beginMapEntry">beginMapEntry</a>().</p> <h3 class="fn"><a name="endStructure" />QDBusArgument.endStructure (<i>self</i>)</h3><p>Closes a D-Bus structure opened with <a href="qdbusargument.html#beginStructure">beginStructure</a>(). This function must be called same number of times that <a href="qdbusargument.html#beginStructure">beginStructure</a>() is called.</p> <p><b>See also</b> <a href="qdbusargument.html#beginStructure">beginStructure</a>(), <a href="qdbusargument.html#endArray">endArray</a>(), and <a href="qdbusargument.html#endMap">endMap</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>