re88.html 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5. <title>&lt;GVariantType&gt;: </title>
  6. <meta name="generator" content="DocBook XSL Stylesheets V1.79.2">
  7. <link rel="home" href="index.html" title="">
  8. <link rel="up" href="ch01.html" title="GLib">
  9. <link rel="prev" href="re87.html" title="&lt;%GLibVariantParseError&gt;">
  10. <link rel="next" href="re89.html" title="Functions">
  11. <meta name="generator" content="GTK-Doc V1.33.1 (XML mode)">
  12. <link rel="stylesheet" href="style.css" type="text/css">
  13. </head>
  14. <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
  15. <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
  16. <td width="100%" align="left" class="shortcuts"></td>
  17. <td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
  18. <td><img src="up-insensitive.png" width="16" height="16" border="0"></td>
  19. <td><a accesskey="p" href="re87.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
  20. <td><a accesskey="n" href="re89.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
  21. </tr></table>
  22. <div class="refentry">
  23. <a name="id-1.1.89"></a><div class="titlepage"></div>
  24. <div class="refnamediv">
  25. <h2>&lt;GVariantType&gt;</h2>
  26. <p>&lt;GVariantType&gt;</p>
  27. </div>
  28. <div class="refsect1">
  29. <a name="id-1.1.89.2"></a><h2>Description</h2>
  30. <p>This section introduces the GVariant type system. It is based, in
  31. large part, on the D-Bus type system, with two major changes and
  32. some minor lifting of restrictions. The
  33. [D-Bus specification](http://dbus.freedesktop.org/doc/dbus-specification.html),
  34. therefore, provides a significant amount of
  35. information that is useful when working with GVariant.
  36. </p>
  37. <p>The first major change with respect to the D-Bus type system is the
  38. introduction of maybe (or "nullable") types. Any type in GVariant can be
  39. converted to a maybe type, in which case, "nothing" (or "null") becomes a
  40. valid value. Maybe types have been added by introducing the
  41. character "m" to type strings.
  42. </p>
  43. <p>The second major change is that the GVariant type system supports the
  44. concept of "indefinite types" -- types that are less specific than
  45. the normal types found in D-Bus. For example, it is possible to speak
  46. of "an array of any type" in GVariant, where the D-Bus type system
  47. would require you to speak of "an array of integers" or "an array of
  48. strings". Indefinite types have been added by introducing the
  49. characters "*", "?" and "r" to type strings.
  50. </p>
  51. <p>Finally, all arbitrary restrictions relating to the complexity of
  52. types are lifted along with the restriction that dictionary entries
  53. may only appear nested inside of arrays.
  54. </p>
  55. <p>Just as in D-Bus, GVariant types are described with strings ("type
  56. strings"). Subject to the differences mentioned above, these strings
  57. are of the same form as those found in DBus. Note, however: D-Bus
  58. always works in terms of messages and therefore individual type
  59. strings appear nowhere in its interface. Instead, "signatures"
  60. are a concatenation of the strings of the type of each argument in a
  61. message. GVariant deals with single values directly so GVariant type
  62. strings always describe the type of exactly one value. This means
  63. that a D-Bus signature string is generally not a valid GVariant type
  64. string -- except in the case that it is the signature of a message
  65. containing exactly one argument.
  66. </p>
  67. <p>An indefinite type is similar in spirit to what may be called an
  68. abstract type in other type systems. No value can exist that has an
  69. indefinite type as its type, but values can exist that have types
  70. that are subtypes of indefinite types. That is to say,
  71. <code class="function">g_variant_get_type()</code> will never return an indefinite type, but
  72. calling <code class="function">g_variant_is_of_type()</code> with an indefinite type may return
  73. <code class="constant">TRUE</code>. For example, you cannot have a value that represents "an
  74. array of no particular type", but you can have an "array of integers"
  75. which certainly matches the type of "an array of no particular type",
  76. since "array of integers" is a subtype of "array of no particular
  77. type".
  78. </p>
  79. <p>This is similar to how instances of abstract classes may not
  80. directly exist in other type systems, but instances of their
  81. non-abstract subtypes may. For example, in GTK, no object that has
  82. the type of <span class="type">GtkBin</span> can exist (since <span class="type">GtkBin</span> is an abstract class),
  83. but a <span class="type">GtkWindow</span> can certainly be instantiated, and you would say
  84. that the <span class="type">GtkWindow</span> is a <span class="type">GtkBin</span> (since <span class="type">GtkWindow</span> is a subclass of
  85. <span class="type">GtkBin</span>).
  86. </p>
  87. <div class="refsect2">
  88. <a name="id-1.1.89.2.9"></a><h3>GVariant Type Strings</h3>
  89. <p>A GVariant type string can be any of the following:
  90. </p>
  91. <p>- any basic type string (listed below)
  92. </p>
  93. <p>- "v", "r" or "*"
  94. </p>
  95. <p>- one of the characters 'a' or 'm', followed by another type string
  96. </p>
  97. <p>- the character '(', followed by a concatenation of zero or more other
  98. type strings, followed by the character ')'
  99. </p>
  100. <p>- the character '{', followed by a basic type string (see below),
  101. followed by another type string, followed by the character '}'
  102. </p>
  103. <p>A basic type string describes a basic type (as per
  104. <code class="function">g_variant_type_is_basic()</code>) and is always a single character in length.
  105. The valid basic type strings are "b", "y", "n", "q", "i", "u", "x", "t",
  106. "h", "d", "s", "o", "g" and "?".
  107. </p>
  108. <p>The above definition is recursive to arbitrary depth. "aaaaai" and
  109. "(ui(nq((y)))s)" are both valid type strings, as is
  110. "a(aa(ui)(qna{ya(yd)}))". In order to not hit memory limits, <span class="type">GVariant</span>
  111. imposes a limit on recursion depth of 65 nested containers. This is the
  112. limit in the D-Bus specification (64) plus one to allow a <span class="type">GDBusMessage</span> to
  113. be nested in a top-level tuple.
  114. </p>
  115. <p>The meaning of each of the characters is as follows:
  116. - <code class="code">b</code>: the type string of <code class="constant">G_VARIANT_TYPE_BOOLEAN</code>; a boolean value.
  117. - <code class="code">y</code>: the type string of <code class="constant">G_VARIANT_TYPE_BYTE</code>; a byte.
  118. - <code class="code">n</code>: the type string of <code class="constant">G_VARIANT_TYPE_INT16</code>; a signed 16 bit integer.
  119. - <code class="code">q</code>: the type string of <code class="constant">G_VARIANT_TYPE_UINT16</code>; an unsigned 16 bit integer.
  120. - <code class="code">i</code>: the type string of <code class="constant">G_VARIANT_TYPE_INT32</code>; a signed 32 bit integer.
  121. - <code class="code">u</code>: the type string of <code class="constant">G_VARIANT_TYPE_UINT32</code>; an unsigned 32 bit integer.
  122. - <code class="code">x</code>: the type string of <code class="constant">G_VARIANT_TYPE_INT64</code>; a signed 64 bit integer.
  123. - <code class="code">t</code>: the type string of <code class="constant">G_VARIANT_TYPE_UINT64</code>; an unsigned 64 bit integer.
  124. - <code class="code">h</code>: the type string of <code class="constant">G_VARIANT_TYPE_HANDLE</code>; a signed 32 bit value
  125. that, by convention, is used as an index into an array of file
  126. descriptors that are sent alongside a D-Bus message.
  127. - <code class="code">d</code>: the type string of <code class="constant">G_VARIANT_TYPE_DOUBLE</code>; a double precision
  128. floating point value.
  129. - <code class="code">s</code>: the type string of <code class="constant">G_VARIANT_TYPE_STRING</code>; a string.
  130. - <code class="code">o</code>: the type string of <code class="constant">G_VARIANT_TYPE_OBJECT_PATH</code>; a string in the form
  131. of a D-Bus object path.
  132. - <code class="code">g</code>: the type string of <code class="constant">G_VARIANT_TYPE_SIGNATURE</code>; a string in the form of
  133. a D-Bus type signature.
  134. - <code class="code">?</code>: the type string of <code class="constant">G_VARIANT_TYPE_BASIC</code>; an indefinite type that
  135. is a supertype of any of the basic types.
  136. - <code class="code">v</code>: the type string of <code class="constant">G_VARIANT_TYPE_VARIANT</code>; a container type that
  137. contain any other type of value.
  138. - <code class="code">a</code>: used as a prefix on another type string to mean an array of that
  139. type; the type string "ai", for example, is the type of an array of
  140. signed 32-bit integers.
  141. - <code class="code">m</code>: used as a prefix on another type string to mean a "maybe", or
  142. "nullable", version of that type; the type string "ms", for example,
  143. is the type of a value that maybe contains a string, or maybe contains
  144. nothing.
  145. - <code class="code">()</code>: used to enclose zero or more other concatenated type strings to
  146. create a tuple type; the type string "(is)", for example, is the type of
  147. a pair of an integer and a string.
  148. - <code class="code">r</code>: the type string of <code class="constant">G_VARIANT_TYPE_TUPLE</code>; an indefinite type that is
  149. a supertype of any tuple type, regardless of the number of items.
  150. - <code class="code">{}</code>: used to enclose a basic type string concatenated with another type
  151. string to create a dictionary entry type, which usually appears inside of
  152. an array to form a dictionary; the type string "a{sd}", for example, is
  153. the type of a dictionary that maps strings to double precision floating
  154. point values.
  155. </p>
  156. <p>The first type (the basic type) is the key type and the second type is
  157. the value type. The reason that the first type is restricted to being a
  158. basic type is so that it can easily be hashed.
  159. - <code class="code">*</code>: the type string of <code class="constant">G_VARIANT_TYPE_ANY</code>; the indefinite type that is
  160. a supertype of all types. Note that, as with all type strings, this
  161. character represents exactly one type. It cannot be used inside of tuples
  162. to mean "any number of items".
  163. </p>
  164. <p>Any type string of a container that contains an indefinite type is,
  165. itself, an indefinite type. For example, the type string "a*"
  166. (corresponding to <code class="constant">G_VARIANT_TYPE_ARRAY</code>) is an indefinite type
  167. that is a supertype of every array type. "(*s)" is a supertype
  168. of all tuples that contain exactly two items where the second
  169. item is a string.
  170. </p>
  171. <p>"a{?*}" is an indefinite type that is a supertype of all arrays
  172. containing dictionary entries where the key is any basic type and
  173. the value is any type at all. This is, by definition, a dictionary,
  174. so this type string corresponds to <code class="constant">G_VARIANT_TYPE_DICTIONARY</code>. Note
  175. that, due to the restriction that the key of a dictionary entry must
  176. be a basic type, "{**}" is not a valid type string.</p>
  177. </div>
  178. </div>
  179. <div class="refsect1">
  180. <a name="id-1.1.89.3"></a><h2>Functions</h2>
  181. <div class="refsect2">
  182. <a name="id-1.1.89.3.2"></a><h3>copy</h3>
  183. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:copy self))
  184. </pre></div>
  185. <p>Makes a copy of a <span class="type">GVariantType</span>. It is appropriate to call
  186. <code class="function">g_variant_type_free()</code> on the return value. <em class="parameter"><code>type</code></em> may not be <code class="constant">NULL</code>.</p>
  187. <div class="refsect3">
  188. <a name="id-1.1.89.3.2.4"></a><h4>Parameters</h4>
  189. <div class="informaltable"><table><tr>
  190. <td class="parameter_name"><p>type</p></td>
  191. <td class="parameter_description">
  192. <p>a <span class="type">GVariantType</span></p>
  193. <p>Passed as <code class="code">self</code></p>
  194. </td>
  195. </tr></table></div>
  196. </div>
  197. </div>
  198. <div class="refsect2">
  199. <a name="id-1.1.89.3.3"></a><h3>dup-string</h3>
  200. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:dup-string self))
  201. </pre></div>
  202. <p>Returns a newly-allocated copy of the type string corresponding to
  203. <em class="parameter"><code>type</code></em>. The returned string is nul-terminated. It is appropriate to
  204. call <code class="function">g_free()</code> on the return value.</p>
  205. <div class="refsect3">
  206. <a name="id-1.1.89.3.3.4"></a><h4>Parameters</h4>
  207. <div class="informaltable"><table><tr>
  208. <td class="parameter_name"><p>type</p></td>
  209. <td class="parameter_description">
  210. <p>a <span class="type">GVariantType</span></p>
  211. <p>Passed as <code class="code">self</code></p>
  212. </td>
  213. </tr></table></div>
  214. </div>
  215. </div>
  216. <div class="refsect2">
  217. <a name="id-1.1.89.3.4"></a><h3>element</h3>
  218. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:element self))
  219. </pre></div>
  220. <p>Determines the element type of an array or maybe type.
  221. </p>
  222. <p>This function may only be used with array or maybe types.</p>
  223. <div class="refsect3">
  224. <a name="id-1.1.89.3.4.5"></a><h4>Parameters</h4>
  225. <div class="informaltable"><table><tr>
  226. <td class="parameter_name"><p>type</p></td>
  227. <td class="parameter_description">
  228. <p>an array or maybe <span class="type">GVariantType</span></p>
  229. <p>Passed as <code class="code">self</code></p>
  230. </td>
  231. </tr></table></div>
  232. </div>
  233. </div>
  234. <div class="refsect2">
  235. <a name="id-1.1.89.3.5"></a><h3>equal?</h3>
  236. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:equal? self type2))
  237. </pre></div>
  238. <p>Compares <em class="parameter"><code>type1</code></em> and <em class="parameter"><code>type2</code></em> for equality.
  239. </p>
  240. <p>Only returns <code class="constant">TRUE</code> if the types are exactly equal. Even if one type
  241. is an indefinite type and the other is a subtype of it, <code class="constant">FALSE</code> will
  242. be returned if they are not exactly equal. If you want to check for
  243. subtypes, use <code class="function">g_variant_type_is_subtype_of()</code>.
  244. </p>
  245. <p>The argument types of <em class="parameter"><code>type1</code></em> and <em class="parameter"><code>type2</code></em> are only <span class="type">gconstpointer</span> to
  246. allow use with <span class="type">GHashTable</span> without function pointer casting. For
  247. both arguments, a valid <span class="type">GVariantType</span> must be provided.</p>
  248. <div class="refsect3">
  249. <a name="id-1.1.89.3.5.6"></a><h4>Parameters</h4>
  250. <div class="informaltable"><table>
  251. <tr>
  252. <td class="parameter_name"><p>type1</p></td>
  253. <td class="parameter_description">
  254. <p>a <span class="type">GVariantType</span></p>
  255. <p>Passed as <code class="code">self</code></p>
  256. </td>
  257. </tr>
  258. <tr>
  259. <td class="parameter_name"><p>type2</p></td>
  260. <td class="parameter_description">
  261. <p>a <span class="type">GVariantType</span></p>
  262. <p>Passed as <code class="code">type2</code></p>
  263. </td>
  264. </tr>
  265. </table></div>
  266. </div>
  267. </div>
  268. <div class="refsect2">
  269. <a name="id-1.1.89.3.6"></a><h3>first</h3>
  270. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:first self))
  271. </pre></div>
  272. <p>Determines the first item type of a tuple or dictionary entry
  273. type.
  274. </p>
  275. <p>This function may only be used with tuple or dictionary entry types,
  276. but must not be used with the generic tuple type
  277. <code class="constant">G_VARIANT_TYPE_TUPLE</code>.
  278. </p>
  279. <p>In the case of a dictionary entry type, this returns the type of
  280. the key.
  281. </p>
  282. <p><code class="constant">NULL</code> is returned in case of <em class="parameter"><code>type</code></em> being <code class="constant">G_VARIANT_TYPE_UNIT</code>.
  283. </p>
  284. <p>This call, together with <code class="function">g_variant_type_next()</code> provides an iterator
  285. interface over tuple and dictionary entry types.</p>
  286. <div class="refsect3">
  287. <a name="id-1.1.89.3.6.8"></a><h4>Parameters</h4>
  288. <div class="informaltable"><table><tr>
  289. <td class="parameter_name"><p>type</p></td>
  290. <td class="parameter_description">
  291. <p>a tuple or dictionary entry <span class="type">GVariantType</span></p>
  292. <p>Passed as <code class="code">self</code></p>
  293. </td>
  294. </tr></table></div>
  295. </div>
  296. </div>
  297. <div class="refsect2">
  298. <a name="id-1.1.89.3.7"></a><h3>free</h3>
  299. <div class="informalexample"><pre class="programlisting">(define-values () (variant-type:free self))
  300. </pre></div>
  301. <p>Frees a <span class="type">GVariantType</span> that was allocated with
  302. <code class="function">g_variant_type_copy()</code>, <code class="function">g_variant_type_new()</code> or one of the container
  303. type constructor functions.
  304. </p>
  305. <p>In the case that <em class="parameter"><code>type</code></em> is <code class="constant">NULL</code>, this function does nothing.
  306. </p>
  307. <p>Since 2.24</p>
  308. <div class="refsect3">
  309. <a name="id-1.1.89.3.7.6"></a><h4>Parameters</h4>
  310. <div class="informaltable"><table><tr>
  311. <td class="parameter_name"><p>type</p></td>
  312. <td class="parameter_description">
  313. <p>a <span class="type">GVariantType</span>, or <code class="constant">NULL</code></p>
  314. <p>Passed as <code class="code">self</code></p>
  315. </td>
  316. </tr></table></div>
  317. </div>
  318. </div>
  319. <div class="refsect2">
  320. <a name="id-1.1.89.3.8"></a><h3>get-string-length</h3>
  321. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:get-string-length self))
  322. </pre></div>
  323. <p>Returns the length of the type string corresponding to the given
  324. <em class="parameter"><code>type</code></em>. This function must be used to determine the valid extent of
  325. the memory region returned by <code class="function">g_variant_type_peek_string()</code>.</p>
  326. <div class="refsect3">
  327. <a name="id-1.1.89.3.8.4"></a><h4>Parameters</h4>
  328. <div class="informaltable"><table><tr>
  329. <td class="parameter_name"><p>type</p></td>
  330. <td class="parameter_description">
  331. <p>a <span class="type">GVariantType</span></p>
  332. <p>Passed as <code class="code">self</code></p>
  333. </td>
  334. </tr></table></div>
  335. </div>
  336. </div>
  337. <div class="refsect2">
  338. <a name="id-1.1.89.3.9"></a><h3>hash</h3>
  339. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:hash self))
  340. </pre></div>
  341. <p>Hashes <em class="parameter"><code>type</code></em>.
  342. </p>
  343. <p>The argument type of <em class="parameter"><code>type</code></em> is only <span class="type">gconstpointer</span> to allow use with
  344. <span class="type">GHashTable</span> without function pointer casting. A valid
  345. <span class="type">GVariantType</span> must be provided.</p>
  346. <div class="refsect3">
  347. <a name="id-1.1.89.3.9.5"></a><h4>Parameters</h4>
  348. <div class="informaltable"><table><tr>
  349. <td class="parameter_name"><p>type</p></td>
  350. <td class="parameter_description">
  351. <p>a <span class="type">GVariantType</span></p>
  352. <p>Passed as <code class="code">self</code></p>
  353. </td>
  354. </tr></table></div>
  355. </div>
  356. </div>
  357. <div class="refsect2">
  358. <a name="id-1.1.89.3.10"></a><h3>is-array?</h3>
  359. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:is-array? self))
  360. </pre></div>
  361. <p>Determines if the given <em class="parameter"><code>type</code></em> is an array type. This is true if the
  362. type string for <em class="parameter"><code>type</code></em> starts with an 'a'.
  363. </p>
  364. <p>This function returns <code class="constant">TRUE</code> for any indefinite type for which every
  365. definite subtype is an array type -- <code class="constant">G_VARIANT_TYPE_ARRAY</code>, for
  366. example.</p>
  367. <div class="refsect3">
  368. <a name="id-1.1.89.3.10.5"></a><h4>Parameters</h4>
  369. <div class="informaltable"><table><tr>
  370. <td class="parameter_name"><p>type</p></td>
  371. <td class="parameter_description">
  372. <p>a <span class="type">GVariantType</span></p>
  373. <p>Passed as <code class="code">self</code></p>
  374. </td>
  375. </tr></table></div>
  376. </div>
  377. </div>
  378. <div class="refsect2">
  379. <a name="id-1.1.89.3.11"></a><h3>is-basic?</h3>
  380. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:is-basic? self))
  381. </pre></div>
  382. <p>Determines if the given <em class="parameter"><code>type</code></em> is a basic type.
  383. </p>
  384. <p>Basic types are booleans, bytes, integers, doubles, strings, object
  385. paths and signatures.
  386. </p>
  387. <p>Only a basic type may be used as the key of a dictionary entry.
  388. </p>
  389. <p>This function returns <code class="constant">FALSE</code> for all indefinite types except
  390. <code class="constant">G_VARIANT_TYPE_BASIC</code>.</p>
  391. <div class="refsect3">
  392. <a name="id-1.1.89.3.11.7"></a><h4>Parameters</h4>
  393. <div class="informaltable"><table><tr>
  394. <td class="parameter_name"><p>type</p></td>
  395. <td class="parameter_description">
  396. <p>a <span class="type">GVariantType</span></p>
  397. <p>Passed as <code class="code">self</code></p>
  398. </td>
  399. </tr></table></div>
  400. </div>
  401. </div>
  402. <div class="refsect2">
  403. <a name="id-1.1.89.3.12"></a><h3>is-container?</h3>
  404. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:is-container? self))
  405. </pre></div>
  406. <p>Determines if the given <em class="parameter"><code>type</code></em> is a container type.
  407. </p>
  408. <p>Container types are any array, maybe, tuple, or dictionary
  409. entry types plus the variant type.
  410. </p>
  411. <p>This function returns <code class="constant">TRUE</code> for any indefinite type for which every
  412. definite subtype is a container -- <code class="constant">G_VARIANT_TYPE_ARRAY</code>, for
  413. example.</p>
  414. <div class="refsect3">
  415. <a name="id-1.1.89.3.12.6"></a><h4>Parameters</h4>
  416. <div class="informaltable"><table><tr>
  417. <td class="parameter_name"><p>type</p></td>
  418. <td class="parameter_description">
  419. <p>a <span class="type">GVariantType</span></p>
  420. <p>Passed as <code class="code">self</code></p>
  421. </td>
  422. </tr></table></div>
  423. </div>
  424. </div>
  425. <div class="refsect2">
  426. <a name="id-1.1.89.3.13"></a><h3>is-definite?</h3>
  427. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:is-definite? self))
  428. </pre></div>
  429. <p>Determines if the given <em class="parameter"><code>type</code></em> is definite (ie: not indefinite).
  430. </p>
  431. <p>A type is definite if its type string does not contain any indefinite
  432. type characters ('*', '?', or 'r').
  433. </p>
  434. <p>A <span class="type">GVariant</span> instance may not have an indefinite type, so calling
  435. this function on the result of <code class="function">g_variant_get_type()</code> will always
  436. result in <code class="constant">TRUE</code> being returned. Calling this function on an
  437. indefinite type like <code class="constant">G_VARIANT_TYPE_ARRAY</code>, however, will result in
  438. <code class="constant">FALSE</code> being returned.</p>
  439. <div class="refsect3">
  440. <a name="id-1.1.89.3.13.6"></a><h4>Parameters</h4>
  441. <div class="informaltable"><table><tr>
  442. <td class="parameter_name"><p>type</p></td>
  443. <td class="parameter_description">
  444. <p>a <span class="type">GVariantType</span></p>
  445. <p>Passed as <code class="code">self</code></p>
  446. </td>
  447. </tr></table></div>
  448. </div>
  449. </div>
  450. <div class="refsect2">
  451. <a name="id-1.1.89.3.14"></a><h3>is-dict-entry?</h3>
  452. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:is-dict-entry? self))
  453. </pre></div>
  454. <p>Determines if the given <em class="parameter"><code>type</code></em> is a dictionary entry type. This is
  455. true if the type string for <em class="parameter"><code>type</code></em> starts with a '{'.
  456. </p>
  457. <p>This function returns <code class="constant">TRUE</code> for any indefinite type for which every
  458. definite subtype is a dictionary entry type --
  459. <code class="constant">G_VARIANT_TYPE_DICT_ENTRY</code>, for example.</p>
  460. <div class="refsect3">
  461. <a name="id-1.1.89.3.14.5"></a><h4>Parameters</h4>
  462. <div class="informaltable"><table><tr>
  463. <td class="parameter_name"><p>type</p></td>
  464. <td class="parameter_description">
  465. <p>a <span class="type">GVariantType</span></p>
  466. <p>Passed as <code class="code">self</code></p>
  467. </td>
  468. </tr></table></div>
  469. </div>
  470. </div>
  471. <div class="refsect2">
  472. <a name="id-1.1.89.3.15"></a><h3>is-maybe?</h3>
  473. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:is-maybe? self))
  474. </pre></div>
  475. <p>Determines if the given <em class="parameter"><code>type</code></em> is a maybe type. This is true if the
  476. type string for <em class="parameter"><code>type</code></em> starts with an 'm'.
  477. </p>
  478. <p>This function returns <code class="constant">TRUE</code> for any indefinite type for which every
  479. definite subtype is a maybe type -- <code class="constant">G_VARIANT_TYPE_MAYBE</code>, for
  480. example.</p>
  481. <div class="refsect3">
  482. <a name="id-1.1.89.3.15.5"></a><h4>Parameters</h4>
  483. <div class="informaltable"><table><tr>
  484. <td class="parameter_name"><p>type</p></td>
  485. <td class="parameter_description">
  486. <p>a <span class="type">GVariantType</span></p>
  487. <p>Passed as <code class="code">self</code></p>
  488. </td>
  489. </tr></table></div>
  490. </div>
  491. </div>
  492. <div class="refsect2">
  493. <a name="id-1.1.89.3.16"></a><h3>is-subtype-of?</h3>
  494. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:is-subtype-of? self supertype))
  495. </pre></div>
  496. <p>Checks if <em class="parameter"><code>type</code></em> is a subtype of <em class="parameter"><code>supertype</code></em>.
  497. </p>
  498. <p>This function returns <code class="constant">TRUE</code> if <em class="parameter"><code>type</code></em> is a subtype of <em class="parameter"><code>supertype</code></em>. All
  499. types are considered to be subtypes of themselves. Aside from that,
  500. only indefinite types can have subtypes.</p>
  501. <div class="refsect3">
  502. <a name="id-1.1.89.3.16.5"></a><h4>Parameters</h4>
  503. <div class="informaltable"><table>
  504. <tr>
  505. <td class="parameter_name"><p>type</p></td>
  506. <td class="parameter_description">
  507. <p>a <span class="type">GVariantType</span></p>
  508. <p>Passed as <code class="code">self</code></p>
  509. </td>
  510. </tr>
  511. <tr>
  512. <td class="parameter_name"><p>supertype</p></td>
  513. <td class="parameter_description">
  514. <p>a <span class="type">GVariantType</span></p>
  515. <p>Passed as <code class="code">supertype</code></p>
  516. </td>
  517. </tr>
  518. </table></div>
  519. </div>
  520. </div>
  521. <div class="refsect2">
  522. <a name="id-1.1.89.3.17"></a><h3>is-tuple?</h3>
  523. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:is-tuple? self))
  524. </pre></div>
  525. <p>Determines if the given <em class="parameter"><code>type</code></em> is a tuple type. This is true if the
  526. type string for <em class="parameter"><code>type</code></em> starts with a '(' or if <em class="parameter"><code>type</code></em> is
  527. <code class="constant">G_VARIANT_TYPE_TUPLE</code>.
  528. </p>
  529. <p>This function returns <code class="constant">TRUE</code> for any indefinite type for which every
  530. definite subtype is a tuple type -- <code class="constant">G_VARIANT_TYPE_TUPLE</code>, for
  531. example.</p>
  532. <div class="refsect3">
  533. <a name="id-1.1.89.3.17.5"></a><h4>Parameters</h4>
  534. <div class="informaltable"><table><tr>
  535. <td class="parameter_name"><p>type</p></td>
  536. <td class="parameter_description">
  537. <p>a <span class="type">GVariantType</span></p>
  538. <p>Passed as <code class="code">self</code></p>
  539. </td>
  540. </tr></table></div>
  541. </div>
  542. </div>
  543. <div class="refsect2">
  544. <a name="id-1.1.89.3.18"></a><h3>is-variant?</h3>
  545. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:is-variant? self))
  546. </pre></div>
  547. <p>Determines if the given <em class="parameter"><code>type</code></em> is the variant type.</p>
  548. <div class="refsect3">
  549. <a name="id-1.1.89.3.18.4"></a><h4>Parameters</h4>
  550. <div class="informaltable"><table><tr>
  551. <td class="parameter_name"><p>type</p></td>
  552. <td class="parameter_description">
  553. <p>a <span class="type">GVariantType</span></p>
  554. <p>Passed as <code class="code">self</code></p>
  555. </td>
  556. </tr></table></div>
  557. </div>
  558. </div>
  559. <div class="refsect2">
  560. <a name="id-1.1.89.3.19"></a><h3>key</h3>
  561. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:key self))
  562. </pre></div>
  563. <p>Determines the key type of a dictionary entry type.
  564. </p>
  565. <p>This function may only be used with a dictionary entry type. Other
  566. than the additional restriction, this call is equivalent to
  567. <code class="function">g_variant_type_first()</code>.</p>
  568. <div class="refsect3">
  569. <a name="id-1.1.89.3.19.5"></a><h4>Parameters</h4>
  570. <div class="informaltable"><table><tr>
  571. <td class="parameter_name"><p>type</p></td>
  572. <td class="parameter_description">
  573. <p>a dictionary entry <span class="type">GVariantType</span></p>
  574. <p>Passed as <code class="code">self</code></p>
  575. </td>
  576. </tr></table></div>
  577. </div>
  578. </div>
  579. <div class="refsect2">
  580. <a name="id-1.1.89.3.20"></a><h3>n-items</h3>
  581. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:n-items self))
  582. </pre></div>
  583. <p>Determines the number of items contained in a tuple or
  584. dictionary entry type.
  585. </p>
  586. <p>This function may only be used with tuple or dictionary entry types,
  587. but must not be used with the generic tuple type
  588. <code class="constant">G_VARIANT_TYPE_TUPLE</code>.
  589. </p>
  590. <p>In the case of a dictionary entry type, this function will always
  591. return 2.</p>
  592. <div class="refsect3">
  593. <a name="id-1.1.89.3.20.6"></a><h4>Parameters</h4>
  594. <div class="informaltable"><table><tr>
  595. <td class="parameter_name"><p>type</p></td>
  596. <td class="parameter_description">
  597. <p>a tuple or dictionary entry <span class="type">GVariantType</span></p>
  598. <p>Passed as <code class="code">self</code></p>
  599. </td>
  600. </tr></table></div>
  601. </div>
  602. </div>
  603. <div class="refsect2">
  604. <a name="id-1.1.89.3.21"></a><h3>next</h3>
  605. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:next self))
  606. </pre></div>
  607. <p>Determines the next item type of a tuple or dictionary entry
  608. type.
  609. </p>
  610. <p><em class="parameter"><code>type</code></em> must be the result of a previous call to
  611. <code class="function">g_variant_type_first()</code> or <code class="function">g_variant_type_next()</code>.
  612. </p>
  613. <p>If called on the key type of a dictionary entry then this call
  614. returns the value type. If called on the value type of a dictionary
  615. entry then this call returns <code class="constant">NULL</code>.
  616. </p>
  617. <p>For tuples, <code class="constant">NULL</code> is returned when <em class="parameter"><code>type</code></em> is the last item in a tuple.</p>
  618. <div class="refsect3">
  619. <a name="id-1.1.89.3.21.7"></a><h4>Parameters</h4>
  620. <div class="informaltable"><table><tr>
  621. <td class="parameter_name"><p>type</p></td>
  622. <td class="parameter_description">
  623. <p>a <span class="type">GVariantType</span> from a previous call</p>
  624. <p>Passed as <code class="code">self</code></p>
  625. </td>
  626. </tr></table></div>
  627. </div>
  628. </div>
  629. <div class="refsect2">
  630. <a name="id-1.1.89.3.22"></a><h3>value</h3>
  631. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:value self))
  632. </pre></div>
  633. <p>Determines the value type of a dictionary entry type.
  634. </p>
  635. <p>This function may only be used with a dictionary entry type.</p>
  636. <div class="refsect3">
  637. <a name="id-1.1.89.3.22.5"></a><h4>Parameters</h4>
  638. <div class="informaltable"><table><tr>
  639. <td class="parameter_name"><p>type</p></td>
  640. <td class="parameter_description">
  641. <p>a dictionary entry <span class="type">GVariantType</span></p>
  642. <p>Passed as <code class="code">self</code></p>
  643. </td>
  644. </tr></table></div>
  645. </div>
  646. </div>
  647. <div class="refsect2">
  648. <a name="id-1.1.89.3.23"></a><h3>variant-type:new-tuple</h3>
  649. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:new-tuple items))
  650. </pre></div>
  651. <p>Undocumented</p>
  652. <div class="refsect3">
  653. <a name="id-1.1.89.3.23.4"></a><h4>Parameters</h4>
  654. <div class="informaltable"><table>
  655. <tr>
  656. <td class="parameter_name"><p>items</p></td>
  657. <td class="parameter_description">
  658. <p></p>
  659. <p>Passed as <code class="code">items</code></p>
  660. </td>
  661. </tr>
  662. <tr>
  663. <td class="parameter_name"><p>length</p></td>
  664. <td class="parameter_description">
  665. <p></p>
  666. <p>Inferred from <code class="code">items</code></p>
  667. </td>
  668. </tr>
  669. </table></div>
  670. </div>
  671. </div>
  672. <div class="refsect2">
  673. <a name="id-1.1.89.3.24"></a><h3>variant-type:new-maybe</h3>
  674. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:new-maybe element))
  675. </pre></div>
  676. <p>Undocumented</p>
  677. <div class="refsect3">
  678. <a name="id-1.1.89.3.24.4"></a><h4>Parameters</h4>
  679. <div class="informaltable"><table><tr>
  680. <td class="parameter_name"><p>element</p></td>
  681. <td class="parameter_description">
  682. <p></p>
  683. <p>Passed as <code class="code">element</code></p>
  684. </td>
  685. </tr></table></div>
  686. </div>
  687. </div>
  688. <div class="refsect2">
  689. <a name="id-1.1.89.3.25"></a><h3>variant-type:new-dict-entry</h3>
  690. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:new-dict-entry key value))
  691. </pre></div>
  692. <p>Undocumented</p>
  693. <div class="refsect3">
  694. <a name="id-1.1.89.3.25.4"></a><h4>Parameters</h4>
  695. <div class="informaltable"><table>
  696. <tr>
  697. <td class="parameter_name"><p>key</p></td>
  698. <td class="parameter_description">
  699. <p></p>
  700. <p>Passed as <code class="code">key</code></p>
  701. </td>
  702. </tr>
  703. <tr>
  704. <td class="parameter_name"><p>value</p></td>
  705. <td class="parameter_description">
  706. <p></p>
  707. <p>Passed as <code class="code">value</code></p>
  708. </td>
  709. </tr>
  710. </table></div>
  711. </div>
  712. </div>
  713. <div class="refsect2">
  714. <a name="id-1.1.89.3.26"></a><h3>variant-type:new-array</h3>
  715. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:new-array element))
  716. </pre></div>
  717. <p>Undocumented</p>
  718. <div class="refsect3">
  719. <a name="id-1.1.89.3.26.4"></a><h4>Parameters</h4>
  720. <div class="informaltable"><table><tr>
  721. <td class="parameter_name"><p>element</p></td>
  722. <td class="parameter_description">
  723. <p></p>
  724. <p>Passed as <code class="code">element</code></p>
  725. </td>
  726. </tr></table></div>
  727. </div>
  728. </div>
  729. <div class="refsect2">
  730. <a name="id-1.1.89.3.27"></a><h3>variant-type:new</h3>
  731. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:new type-string))
  732. </pre></div>
  733. <p>Undocumented</p>
  734. <div class="refsect3">
  735. <a name="id-1.1.89.3.27.4"></a><h4>Parameters</h4>
  736. <div class="informaltable"><table><tr>
  737. <td class="parameter_name"><p>type_string</p></td>
  738. <td class="parameter_description">
  739. <p></p>
  740. <p>Passed as <code class="code">type-string</code></p>
  741. </td>
  742. </tr></table></div>
  743. </div>
  744. </div>
  745. <div class="refsect2">
  746. <a name="id-1.1.89.3.28"></a><h3>variant-type:checked-</h3>
  747. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:checked- arg0))
  748. </pre></div>
  749. <p>Undocumented</p>
  750. <div class="refsect3">
  751. <a name="id-1.1.89.3.28.4"></a><h4>Parameters</h4>
  752. <div class="informaltable"><table><tr>
  753. <td class="parameter_name"><p>arg0</p></td>
  754. <td class="parameter_description">
  755. <p></p>
  756. <p>Passed as <code class="code">arg0</code></p>
  757. </td>
  758. </tr></table></div>
  759. </div>
  760. </div>
  761. <div class="refsect2">
  762. <a name="id-1.1.89.3.29"></a><h3>variant-type:string-get-depth-</h3>
  763. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:string-get-depth- type-string))
  764. </pre></div>
  765. <p>Undocumented</p>
  766. <div class="refsect3">
  767. <a name="id-1.1.89.3.29.4"></a><h4>Parameters</h4>
  768. <div class="informaltable"><table><tr>
  769. <td class="parameter_name"><p>type_string</p></td>
  770. <td class="parameter_description">
  771. <p></p>
  772. <p>Passed as <code class="code">type-string</code></p>
  773. </td>
  774. </tr></table></div>
  775. </div>
  776. </div>
  777. <div class="refsect2">
  778. <a name="id-1.1.89.3.30"></a><h3>variant-type:string-is-valid?</h3>
  779. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type:string-is-valid? type-string))
  780. </pre></div>
  781. <p>Checks if <em class="parameter"><code>type_string</code></em> is a valid GVariant type string. This call is
  782. equivalent to calling <code class="function">g_variant_type_string_scan()</code> and confirming
  783. that the following character is a nul terminator.</p>
  784. <div class="refsect3">
  785. <a name="id-1.1.89.3.30.4"></a><h4>Parameters</h4>
  786. <div class="informaltable"><table><tr>
  787. <td class="parameter_name"><p>type_string</p></td>
  788. <td class="parameter_description">
  789. <p>a pointer to any string</p>
  790. <p>Passed as <code class="code">type-string</code></p>
  791. </td>
  792. </tr></table></div>
  793. </div>
  794. </div>
  795. <div class="refsect2">
  796. <a name="id-1.1.89.3.31"></a><h3>variant-type:string-scan</h3>
  797. <div class="informalexample"><pre class="programlisting">(define-values (%return endptr) (variant-type:string-scan string limit))
  798. </pre></div>
  799. <p>Scan for a single complete and valid GVariant type string in <em class="parameter"><code>string</code></em>.
  800. The memory pointed to by <em class="parameter"><code>limit</code></em> (or bytes beyond it) is never
  801. accessed.
  802. </p>
  803. <p>If a valid type string is found, <em class="parameter"><code>endptr</code></em> is updated to point to the
  804. first character past the end of the string that was found and <code class="constant">TRUE</code>
  805. is returned.
  806. </p>
  807. <p>If there is no valid type string starting at <em class="parameter"><code>string</code></em>, or if the type
  808. string does not end before <em class="parameter"><code>limit</code></em> then <code class="constant">FALSE</code> is returned.
  809. </p>
  810. <p>For the simple case of checking if a string is a valid type string,
  811. see <code class="function">g_variant_type_string_is_valid()</code>.</p>
  812. <div class="refsect3">
  813. <a name="id-1.1.89.3.31.7"></a><h4>Parameters</h4>
  814. <div class="informaltable"><table>
  815. <tr>
  816. <td class="parameter_name"><p>string</p></td>
  817. <td class="parameter_description">
  818. <p>a pointer to any string</p>
  819. <p>Passed as <code class="code">string</code></p>
  820. </td>
  821. </tr>
  822. <tr>
  823. <td class="parameter_name"><p>limit</p></td>
  824. <td class="parameter_description">
  825. <p>the end of <em class="parameter"><code>string</code></em>, or <code class="constant">NULL</code></p>
  826. <p>Passed as <code class="code">limit</code></p>
  827. </td>
  828. </tr>
  829. <tr>
  830. <td class="parameter_name"><p>endptr</p></td>
  831. <td class="parameter_description">
  832. <p>location to store the end pointer, or <code class="constant">NULL</code></p>
  833. <p>Passed as <code class="code">endptr</code></p>
  834. </td>
  835. </tr>
  836. </table></div>
  837. </div>
  838. </div>
  839. </div>
  840. </div>
  841. <div class="footer">
  842. <hr>Generated by GTK-Doc V1.33.1</div>
  843. </body>
  844. </html>