summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2010-03-31 17:04:23 +1100
committerDanielle Madeley <danielle.madeley@collabora.co.uk>2010-03-31 17:04:23 +1100
commitccacbef435701f1bdada1d50332df628a3c269f2 (patch)
tree7fce77d56a583102238664ef078d93c2be90b3fb
parent7a930b161471c4df76d040c495524b690cd6dd90 (diff)
Struct unpacking example
-rw-r--r--docs/book/C/basics.xml16
1 files changed, 14 insertions, 2 deletions
diff --git a/docs/book/C/basics.xml b/docs/book/C/basics.xml
index 8ad7bac..2934922 100644
--- a/docs/book/C/basics.xml
+++ b/docs/book/C/basics.xml
@@ -1368,12 +1368,24 @@ for (i = 0; i < channels->len; i++)
<function>g_value_array_get_nth</function> plus the appropriate
<function>g_value_get_...</function> function for the returned
<classname>GValue</classname>.
- <xref linkend="ex.basics.language-bindings.telepathy-glib.variant-unpack"/>
- in the next section shows how this is done. Similar to using
+ <xref linkend="ex.basics.language-bindings.telepathy-glib.unpacking-us"/>
+ shows how this is done. Similar to using
<function>tp_value_array_unpack</function>, this value is not
copied or referenced, however GLib provides several
<function>g_value_dup_...</function> functions that do make copies.
</para>
+ <example id="ex.basics.language-bindings.telepathy-glib.unpacking-us">
+ <title>Unpacking oa{sv}</title>
+ <programlisting language="c">
+<![CDATA[GValueArray *channel = ...; /* contains a struct of type (oa{sv}) */
+
+char *object_path;
+GHashTable *map;
+
+object_path = g_value_get_boxed (g_value_array_get_nth (channel, 0));
+map = g_value_get_boxed (g_value_array_get_nth (channel, 1));]]></programlisting>
+ </example>
+
</sect3>