Sophie

Sophie

distrib > * > 2009.0 > i586 > by-pkgid > a6711891ce757817bba854bf3f25205a > files > 1965

qtjambi-doc-4.3.3-3mdv2008.1.i586.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- /home/gvatteka/dev/qt-4.3/doc/src/qdbusadaptors.qdoc -->
<head>
  <title>The QtDBus Type System</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1 align="center">The QtDBus Type System<br /><small></small></h1>
<p>D-Bus has an extensible type system based on a few primitives and composition of the primitives in arrays and structures. <a href="intro-to-dbus.html#qtdbus"><tt>QtDBus</tt></a> implements the interface to that type system through the QDBusArgument class, allowing user programs to send and receive practically every C++ type over the bus.</p>
<a name="primitive-types"></a>
<h2>Primitive Types</h2>
<p>The primitive types are supported natively by QDBusArgument and need no special customization to be sent or received. They are listed below, along with the C++ class they relate to:</p>
<p><table align="center" cellpadding="2" cellspacing="1" border="0">
<thead><tr valign="top" class="qt-style"><th>Qt type</th><th>D-Bus equivalent type</th></tr></thead>
<tr valign="top" class="odd"><td>uchar</td><td>BYTE</td></tr>
<tr valign="top" class="even"><td>bool</td><td>BOOLEAN</td></tr>
<tr valign="top" class="odd"><td>short</td><td>INT16</td></tr>
<tr valign="top" class="even"><td>ushort</td><td>UINT16</td></tr>
<tr valign="top" class="odd"><td>int</td><td>INT32</td></tr>
<tr valign="top" class="even"><td>uint</td><td>UINT32</td></tr>
<tr valign="top" class="odd"><td>qlonglong</td><td>INT64</td></tr>
<tr valign="top" class="even"><td>qulonglong</td><td>UINT64</td></tr>
<tr valign="top" class="odd"><td>double</td><td>DOUBLE</td></tr>
<tr valign="top" class="even"><td><a href="porting4.html#qstring"><tt>QString</tt></a></td><td>STRING</td></tr>
<tr valign="top" class="odd"><td>QDBusVariant</td><td>VARIANT</td></tr>
<tr valign="top" class="even"><td>QDBusObjectPath</td><td><a href="intro-to-dbus.html#object-paths"><tt>OBJECT_PATH</tt></a></td></tr>
<tr valign="top" class="odd"><td>QDBusSignature</td><td>SIGNATURE</td></tr>
</table></p>
<p>Aside from the primitive types, QDBusArgument also supports two non-primitive types natively, due to their widespread use in Qt applications: <a href="porting4.html#qstringlist"><tt>QStringList</tt></a> and <a href="core/QByteArray.html"><tt>QByteArray</tt></a>.</p>
<a name="compound-types"></a>
<h2>Compound Types</h2>
<p>D-Bus specifies three types of aggregations of primitive types that allow one to create compound types. They are <tt>ARRAY</tt>, <tt>STRUCT</tt> and maps/dictionaries.</p>
<p>Arrays are sets of zero or more elements of the same type, while structures are a set of a fixed number of elements, each of any type. Maps or dictionaries are implemented as arrays of a pair of elements, so there can be zero or more elements in one map.</p>
<a name="extending-the-type-system"></a>
<h2>Extending the Type System</h2>
<p>In order to use one's own type with <a href="intro-to-dbus.html#qtdbus"><tt>QtDBus</tt></a>, the type has to be declared as a Qt meta-type with the Q_DECLARE_METATYPE() macro and registered with the qDBusRegisterMetaType() function. The streaming operators <tt>operator&gt;&gt;</tt> and <tt>operator&lt;&lt;</tt> will be automatically found by the registration system.</p>
<p><a href="intro-to-dbus.html#qtdbus"><tt>QtDBus</tt></a> provides template specializations for arrays and maps for use with Qt's container classes</tt>, such as QMap and QList, so it is not necessary to write the streaming operator functions for those. For other types, and specially for types implementing structures, the operators have to be explicitly implemented.</p>
<p>See the documentation for QDBusArgument for examples for structures, arrays and maps.</p>
<a name="the-type-system-in-use"></a>
<h2>The Type System in Use</h2>
<p>All of the <a href="intro-to-dbus.html#qtdbus"><tt>QtDBus</tt></a> types (primitives and user-defined alike) can be used to send and receive messages of all types over the bus.</p>
<p><b>Warning:</b> You may not use any type that is not on the list above, including <tt>typedefs</tt> to the types listed. This also includes QList&lt;<a href="porting4.html#qvariant"><tt>QVariant</tt></a>&gt; and QMap&lt;<a href="porting4.html#qstring"><tt>QString</tt></a>,<a href="porting4.html#qvariant"><tt>QVariant</tt></a>&gt;.</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright &copy; 2007 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt Jambi </div></td>
</tr></table></div></address></body>
</html>