Release 0.40.3
[vala-gnome.git] / vapi / glib-2.0.vapi
blob823d817c2df6b8123fe7d5a6d2d29b06c76678de
1 /* glib-2.0.vala
2  *
3  * Copyright (C) 2006-2014  Jürg Billeter
4  * Copyright (C) 2006-2008  Raffaele Sandrini
5  * Copyright (C) 2007  Mathias Hasselmann
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
20  *
21  * As a special exception, if you use inline functions from this file, this
22  * file does not by itself cause the resulting executable to be covered by
23  * the GNU Lesser General Public License.
24  *
25  * Author:
26  *      Jürg Billeter <j@bitron.ch>
27  *      Raffaele Sandrini <rasa@gmx.ch>
28  *      Mathias Hasselmann <mathias.hasselmann@gmx.de>
29  */
31 [SimpleType]
32 [GIR (name = "gboolean")]
33 [CCode (cname = "gboolean", cheader_filename = "glib.h", type_id = "G_TYPE_BOOLEAN", marshaller_type_name = "BOOLEAN", get_value_function = "g_value_get_boolean", set_value_function = "g_value_set_boolean", default_value = "FALSE", type_signature = "b")]
34 [BooleanType]
35 public struct bool {
36         public string to_string () {
37                 if (this) {
38                         return "true";
39                 } else {
40                         return "false";
41                 }
42         }
44         public static bool parse (string str) {
45                 if (str == "true") {
46                         return true;
47                 } else {
48                         return false;
49                 }
50         }
51         public static bool try_parse (string str, out bool result = null) {
52                 if (str == "true") {
53                         result = true;
54                         return true;
55                 } else if (str == "false") {
56                         result = false;
57                         return true;
58                 } else {
59                         result = false;
60                         return false;
61                 }
62         }
65 [SimpleType]
66 [GIR (name = "gint8")]
67 [CCode (cname = "gchar", cprefix = "g_ascii_", cheader_filename = "glib.h", type_id = "G_TYPE_CHAR", marshaller_type_name = "CHAR", get_value_function = "g_value_get_schar", set_value_function = "g_value_set_schar", default_value = "\'\\0\'", type_signature = "y")]
68 [IntegerType (rank = 2, min = 0, max = 127)]
69 public struct char {
70         [CCode (cname = "g_strdup_printf", instance_pos = -1)]
71         public string to_string (string format = "%c");
72         public bool isalnum ();
73         public bool isalpha ();
74         public bool iscntrl ();
75         public bool isdigit ();
76         public bool isgraph ();
77         public bool islower ();
78         public bool isprint ();
79         public bool ispunct ();
80         public bool isspace ();
81         public bool isupper ();
82         public bool isxdigit ();
83         public int digit_value ();
84         public int xdigit_value ();
85         public char tolower ();
86         public char toupper ();
88         [CCode (cname = "MIN")]
89         public static char min (char a, char b);
90         [CCode (cname = "MAX")]
91         public static char max (char a, char b);
92         [CCode (cname = "CLAMP")]
93         public char clamp (char low, char high);
96 [SimpleType]
97 [GIR (name = "guint8")]
98 [CCode (cname = "guchar", cheader_filename = "glib.h", type_id = "G_TYPE_UCHAR", marshaller_type_name = "UCHAR", get_value_function = "g_value_get_uchar", set_value_function = "g_value_set_uchar", default_value = "\'\\0\'", type_signature = "y")]
99 [IntegerType (rank = 3, min = 0, max = 255)]
100 public struct uchar {
101         [CCode (cname = "g_strdup_printf", instance_pos = -1)]
102         public string to_string (string format = "%hhu");
104         [CCode (cname = "MIN")]
105         public static uchar min (uchar a, uchar b);
106         [CCode (cname = "MAX")]
107         public static uchar max (uchar a, uchar b);
108         [CCode (cname = "CLAMP")]
109         public uchar clamp (uchar low, uchar high);
112 [SimpleType]
113 [GIR (name = "gint")]
114 [CCode (cname = "gint", cheader_filename = "glib.h", type_id = "G_TYPE_INT", marshaller_type_name = "INT", get_value_function = "g_value_get_int", set_value_function = "g_value_set_int", default_value = "0", type_signature = "i")]
115 [IntegerType (rank = 6)]
116 public struct int {
117         [CCode (cname = "G_MININT")]
118         public const int MIN;
119         [CCode (cname = "G_MAXINT")]
120         public const int MAX;
122         [CCode (cname = "g_strdup_printf", instance_pos = -1)]
123         public string to_string (string format = "%i");
125         [CCode (cname = "MIN")]
126         public static int min (int a, int b);
127         [CCode (cname = "MAX")]
128         public static int max (int a, int b);
129         [CCode (cname = "CLAMP")]
130         public int clamp (int low, int high);
132         [CCode (cname = "GINT_TO_POINTER")]
133         public void* to_pointer ();
134         [CCode (cname = "GPOINTER_TO_INT")]
135         public static int from_pointer (void* p);
137         [CCode (cname = "abs", cheader_filename = "stdlib.h")]
138         public int abs ();
140         [CCode (cname = "GINT_TO_BE")]
141         public int to_big_endian ();
142         [CCode (cname = "GINT_TO_LE")]
143         public int to_little_endian ();
145         [CCode (cname = "GINT_FROM_BE")]
146         public static int from_big_endian (int val);
147         [CCode (cname = "GINT_FROM_LE")]
148         public static int from_little_endian (int val);
150         [CCode (cname = "atoi", cheader_filename = "stdlib.h")]
151         public static int parse (string str);
154 [SimpleType]
155 [GIR (name = "guint")]
156 [CCode (cname = "guint", cheader_filename = "glib.h", type_id = "G_TYPE_UINT", marshaller_type_name = "UINT", get_value_function = "g_value_get_uint", set_value_function = "g_value_set_uint", default_value = "0U", type_signature = "u")]
157 [IntegerType (rank = 7)]
158 public struct uint {
159         [CCode (cname = "0")]
160         public const uint MIN;
161         [CCode (cname = "G_MAXUINT")]
162         public const uint MAX;
164         [CCode (cname = "g_strdup_printf", instance_pos = -1)]
165         public string to_string (string format = "%u");
167         [CCode (cname = "MIN")]
168         public static uint min (uint a, uint b);
169         [CCode (cname = "MAX")]
170         public static uint max (uint a, uint b);
171         [CCode (cname = "CLAMP")]
172         public uint clamp (uint low, uint high);
174         [CCode (cname = "GUINT_TO_POINTER")]
175         public void* to_pointer ();
176         [CCode (cname = "GPOINTER_TO_UINT")]
177         public static uint from_pointer (void* p);
179         [CCode (cname = "GUINT_TO_BE")]
180         public uint to_big_endian ();
181         [CCode (cname = "GUINT_TO_LE")]
182         public uint to_little_endian ();
184         [CCode (cname = "GUINT_FROM_BE")]
185         public static uint from_big_endian (uint val);
186         [CCode (cname = "GUINT_FROM_LE")]
187         public static uint from_little_endian (uint val);
190 [SimpleType]
191 [GIR (name = "gshort")]
192 [CCode (cname = "gshort", cheader_filename = "glib.h", type_id = "G_TYPE_INT", marshaller_type_name = "INT", get_value_function = "g_value_get_int", set_value_function = "g_value_set_int", default_value = "0", type_signature = "n")]
193 [IntegerType (rank = 4, min = -32768, max = 32767)]
194 public struct short {
195         [CCode (cname = "G_MINSHORT")]
196         public const short MIN;
197         [CCode (cname = "G_MAXSHORT")]
198         public const short MAX;
200         [CCode (cname = "g_strdup_printf", instance_pos = -1)]
201         public string to_string (string format = "%hi");
203         [CCode (cname = "MIN")]
204         public static short min (short a, short b);
205         [CCode (cname = "MAX")]
206         public static short max (short a, short b);
207         [CCode (cname = "CLAMP")]
208         public short clamp (short low, short high);
209         [CCode (cname = "abs", cheader_filename = "stdlib.h")]
210         public short abs ();
213 [SimpleType]
214 [GIR (name = "gushort")]
215 [CCode (cname = "gushort", cheader_filename = "glib.h", type_id = "G_TYPE_UINT", marshaller_type_name = "UINT", get_value_function = "g_value_get_uint", set_value_function = "g_value_set_uint", default_value = "0U", type_signature = "q")]
216 [IntegerType (rank = 5, min = 0, max = 65535)]
217 public struct ushort {
218         [CCode (cname = "0U")]
219         public const ushort MIN;
220         [CCode (cname = "G_MAXUSHORT")]
221         public const ushort MAX;
223         [CCode (cname = "g_strdup_printf", instance_pos = -1)]
224         public string to_string (string format = "%hu");
226         [CCode (cname = "MIN")]
227         public static ushort min (ushort a, ushort b);
228         [CCode (cname = "MAX")]
229         public static ushort max (ushort a, ushort b);
230         [CCode (cname = "CLAMP")]
231         public ushort clamp (ushort low, ushort high);
234 [SimpleType]
235 [GIR (name = "glong")]
236 [CCode (cname = "glong", cheader_filename = "glib.h", type_id = "G_TYPE_LONG", marshaller_type_name = "LONG", get_value_function = "g_value_get_long", set_value_function = "g_value_set_long", default_value = "0L")]
237 [IntegerType (rank = 8)]
238 public struct long {
239         [CCode (cname = "G_MINLONG")]
240         public const long MIN;
241         [CCode (cname = "G_MAXLONG")]
242         public const long MAX;
244         [CCode (cname = "g_strdup_printf", instance_pos = -1)]
245         public string to_string (string format = "%li");
247         [CCode (cname = "MIN")]
248         public static long min (long a, long b);
249         [CCode (cname = "MAX")]
250         public static long max (long a, long b);
251         [CCode (cname = "CLAMP")]
252         public long clamp (long low, long high);
253         [CCode (cname = "labs", cheader_filename = "stdlib.h")]
254         public long abs ();
256         [CCode (cname = "GLONG_TO_BE")]
257         public long to_big_endian ();
258         [CCode (cname = "GLONG_TO_LE")]
259         public long to_little_endian ();
261         [CCode (cname = "GLONG_FROM_BE")]
262         public static long from_big_endian (long val);
263         [CCode (cname = "GLONG_FROM_LE")]
264         public static long from_little_endian (long val);
266         [CCode (cname = "atol", cheader_filename = "stdlib.h")]
267         public static long parse (string str);
270 [SimpleType]
271 [GIR (name = "gulong")]
272 [CCode (cname = "gulong", cheader_filename = "glib.h", type_id = "G_TYPE_ULONG", marshaller_type_name = "ULONG", get_value_function = "g_value_get_ulong", set_value_function = "g_value_set_ulong", default_value = "0UL")]
273 [IntegerType (rank = 9)]
274 public struct ulong {
275         [CCode (cname = "0UL")]
276         public const ulong MIN;
277         [CCode (cname = "G_MAXULONG")]
278         public const ulong MAX;
280         [CCode (cname = "g_strdup_printf", instance_pos = -1)]
281         public string to_string (string format = "%lu");
283         [CCode (cname = "MIN")]
284         public static ulong min (ulong a, ulong b);
285         [CCode (cname = "MAX")]
286         public static ulong max (ulong a, ulong b);
287         [CCode (cname = "CLAMP")]
288         public ulong clamp (ulong low, ulong high);
290         [CCode (cname = "GULONG_TO_BE")]
291         public ulong to_big_endian ();
292         [CCode (cname = "GULONG_TO_LE")]
293         public ulong to_little_endian ();
295         [CCode (cname = "GULONG_FROM_BE")]
296         public static ulong from_big_endian (ulong val);
297         [CCode (cname = "GULONG_FROM_LE")]
298         public static ulong from_little_endian (ulong val);
301 [SimpleType]
302 [GIR (name = "gulong")]
303 [CCode (cname = "gsize", cheader_filename = "glib.h", type_id = "G_TYPE_ULONG", marshaller_type_name = "ULONG", get_value_function = "g_value_get_ulong", set_value_function = "g_value_set_ulong", default_value = "0UL")]
304 [IntegerType (rank = 9)]
305 public struct size_t {
306         [CCode (cname = "0UL")]
307         public const ulong MIN;
308         [Version (since = "2.4")]
309         [CCode (cname = "G_MAXSIZE")]
310         public const ulong MAX;
312         [Version (since = "2.6")]
313         [CCode (cname = "G_GSIZE_FORMAT")]
314         public const string FORMAT;
315         [Version (since = "2.6")]
316         [CCode (cname = "G_GSIZE_MODIFIER")]
317         public const string FORMAT_MODIFIER;
319         [CCode (cname = "g_strdup_printf", instance_pos = -1)]
320         public string to_string (string format = "%" + FORMAT);
322         [CCode (cname = "GSIZE_TO_POINTER")]
323         public void* to_pointer ();
324         [CCode (cname = "GPOINTER_TO_SIZE")]
325         public static size_t from_pointer (void* p);
327         [CCode (cname = "MIN")]
328         public static size_t min (size_t a, size_t b);
329         [CCode (cname = "MAX")]
330         public static size_t max (size_t a, size_t b);
331         [CCode (cname = "CLAMP")]
332         public size_t clamp (size_t low, size_t high);
335 [SimpleType]
336 [GIR (name = "glong")]
337 [CCode (cname = "gssize", cheader_filename = "glib.h", type_id = "G_TYPE_LONG", marshaller_type_name = "LONG", get_value_function = "g_value_get_long", set_value_function = "g_value_set_long", default_value = "0L")]
338 [IntegerType (rank = 8)]
339 public struct ssize_t {
340         [Version (since = "2.14")]
341         [CCode (cname = "G_MINSSIZE")]
342         public const long MIN;
343         [Version (since = "2.14")]
344         [CCode (cname = "G_MAXSSIZE")]
345         public const long MAX;
347         [Version (since = "2.6")]
348         [CCode (cname = "G_GSSIZE_FORMAT")]
349         public const string FORMAT;
350         [CCode (cname = "G_GSIZE_MODIFIER")]
351         public const string FORMAT_MODIFIER;
353         [CCode (cname = "g_strdup_printf", instance_pos = -1)]
354         public string to_string (string format = "%" + FORMAT);
356         [CCode (cname = "MIN")]
357         public static ssize_t min (ssize_t a, ssize_t b);
358         [CCode (cname = "MAX")]
359         public static ssize_t max (ssize_t a, ssize_t b);
360         [CCode (cname = "CLAMP")]
361         public ssize_t clamp (ssize_t low, ssize_t high);
364 [SimpleType]
365 [GIR (name = "gulong")]
366 [CCode (cname = "guintptr", cheader_filename = "glib.h", type_id = "G_TYPE_ULONG", marshaller_type_name = "ULONG", get_value_function = "g_value_get_ulong", set_value_function = "g_value_set_ulong", default_value = "0UL")]
367 [IntegerType (rank = 9)]
368 public struct uintptr {
369         [CCode (cname = "0UL")]
370         public const ulong MIN;
371         [CCode (cname = "G_MAXSIZE")]
372         public const ulong MAX;
374         [CCode (cname = "G_GUINTPTR_FORMAT")]
375         public const string FORMAT;
376         [CCode (cname = "G_GINTPTR_MODIFIER")]
377         public const string FORMAT_MODIFIER;
379         [CCode (cname = "g_strdup_printf", instance_pos = -1)]
380         public string to_string (string format = "%" + FORMAT);
382         [CCode (cname = "GSIZE_TO_POINTER")]
383         public void* to_pointer ();
384         [CCode (cname = "GPOINTER_TO_SIZE")]
385         public static uintptr from_pointer (void* p);
387         [CCode (cname = "MIN")]
388         public static uintptr min (uintptr a, uintptr b);
389         [CCode (cname = "MAX")]
390         public static uintptr max (uintptr a, uintptr b);
391         [CCode (cname = "CLAMP")]
392         public uintptr clamp (uintptr low, uintptr high);
395 [SimpleType]
396 [GIR (name = "glong")]
397 [CCode (cname = "gintptr", cheader_filename = "glib.h", type_id = "G_TYPE_LONG", marshaller_type_name = "LONG", get_value_function = "g_value_get_long", set_value_function = "g_value_set_long", default_value = "0L")]
398 [IntegerType (rank = 8)]
399 public struct intptr {
400         [CCode (cname = "G_MINSSIZE")]
401         public const long MIN;
402         [CCode (cname = "G_MAXSSIZE")]
403         public const long MAX;
405         [CCode (cname = "G_GINTPTR_FORMAT")]
406         public const string FORMAT;
407         [CCode (cname = "G_GINTPTR_MODIFIER")]
408         public const string FORMAT_MODIFIER;
410         [CCode (cname = "g_strdup_printf", instance_pos = -1)]
411         public string to_string (string format = "%" + FORMAT);
413         [CCode (cname = "MIN")]
414         public static intptr min (intptr a, intptr b);
415         [CCode (cname = "MAX")]
416         public static intptr max (intptr a, intptr b);
417         [CCode (cname = "CLAMP")]
418         public intptr clamp (intptr low, intptr high);
421 [SimpleType]
422 [GIR (name = "gint8")]
423 [CCode (cname = "gint8", cheader_filename = "glib.h", type_id = "G_TYPE_CHAR", marshaller_type_name = "CHAR", get_value_function = "g_value_get_char", set_value_function = "g_value_set_char", default_value = "0", type_signature = "y")]
424 [IntegerType (rank = 1, min = -128, max = 127)]
425 public struct int8 {
426         [Version (since = "2.4")]
427         [CCode (cname = "G_MININT8")]
428         public const int8 MIN;
429         [Version (since = "2.4")]
430         [CCode (cname = "G_MAXINT8")]
431         public const int8 MAX;
433         [CCode (cname = "g_strdup_printf", instance_pos = -1)]
434         public string to_string (string format = "%hhi");
436         [CCode (cname = "MIN")]
437         public static int8 min (int8 a, int8 b);
438         [CCode (cname = "MAX")]
439         public static int8 max (int8 a, int8 b);
440         [CCode (cname = "CLAMP")]
441         public int8 clamp (int8 low, int8 high);
444 [SimpleType]
445 [GIR (name = "guint8")]
446 [CCode (cname = "guint8", cheader_filename = "glib.h", type_id = "G_TYPE_UCHAR", marshaller_type_name = "UCHAR", get_value_function = "g_value_get_uchar", set_value_function = "g_value_set_uchar", default_value = "0U", type_signature = "y")]
447 [IntegerType (rank = 3, min = 0, max = 255)]
448 public struct uint8 {
449         [CCode (cname = "0U")]
450         public const uint8 MIN;
451         [Version (since = "2.4")]
452         [CCode (cname = "G_MAXUINT8")]
453         public const uint8 MAX;
455         [CCode (cname = "g_strdup_printf", instance_pos = -1)]
456         public string to_string (string format = "%hhu");
458         [CCode (cname = "MIN")]
459         public static uint8 min (uint8 a, uint8 b);
460         [CCode (cname = "MAX")]
461         public static uint8 max (uint8 a, uint8 b);
462         [CCode (cname = "CLAMP")]
463         public uint8 clamp (uint8 low, uint8 high);
466 [SimpleType]
467 [GIR (name = "gint16")]
468 [CCode (cname = "gint16", cheader_filename = "glib.h", type_id = "G_TYPE_INT", marshaller_type_name = "INT", get_value_function = "g_value_get_int", set_value_function = "g_value_set_int", default_value = "0", type_signature = "n")]
469 [IntegerType (rank = 4, min = -32768, max = 32767)]
470 public struct int16 {
471         [Version (since = "2.4")]
472         [CCode (cname = "G_MININT16")]
473         public const int16 MIN;
474         [Version (since = "2.4")]
475         [CCode (cname = "G_MAXINT16")]
476         public const int16 MAX;
478         [CCode (cname = "G_GINT16_FORMAT")]
479         public const string FORMAT;
480         [Version (since = "2.4")]
481         [CCode (cname = "G_GINT16_MODIFIER")]
482         public const string FORMAT_MODIFIER;
484         [CCode (cname = "g_strdup_printf", instance_pos = -1)]
485         public string to_string (string format = "%" + FORMAT);
487         [CCode (cname = "MIN")]
488         public static int16 min (int16 a, int16 b);
489         [CCode (cname = "MAX")]
490         public static int16 max (int16 a, int16 b);
491         [CCode (cname = "CLAMP")]
492         public int16 clamp (int16 low, int16 high);
494         [CCode (cname = "GINT16_TO_BE")]
495         public int16 to_big_endian ();
496         [CCode (cname = "GINT16_TO_LE")]
497         public int16 to_little_endian ();
499         [CCode (cname = "GINT16_FROM_BE")]
500         public static int16 from_big_endian (int16 val);
501         [CCode (cname = "GINT16_FROM_LE")]
502         public static int16 from_little_endian (int16 val);
505 [SimpleType]
506 [GIR (name = "guint16")]
507 [CCode (cname = "guint16", cheader_filename = "glib.h", type_id = "G_TYPE_UINT", marshaller_type_name = "UINT", get_value_function = "g_value_get_uint", set_value_function = "g_value_set_uint", default_value = "0U", type_signature = "q")]
508 [IntegerType (rank = 5, min = 0, max = 65535)]
509 public struct uint16 {
510         [CCode (cname = "0U")]
511         public const uint16 MIN;
512         [Version (since = "2.4")]
513         [CCode (cname = "G_MAXUINT16")]
514         public const uint16 MAX;
516         [CCode (cname = "G_GUINT16_FORMAT")]
517         public const string FORMAT;
518         [CCode (cname = "G_GINT16_MODIFIER")]
519         public const string FORMAT_MODIFIER;
521         [CCode (cname = "g_strdup_printf", instance_pos = -1)]
522         public string to_string (string format = "%hu");
524         [CCode (cname = "MIN")]
525         public static uint16 min (uint16 a, uint16 b);
526         [CCode (cname = "MAX")]
527         public static uint16 max (uint16 a, uint16 b);
528         [CCode (cname = "CLAMP")]
529         public uint16 clamp (uint16 low, uint16 high);
531         [CCode (cname = "GUINT16_TO_BE")]
532         public uint16 to_big_endian ();
533         [CCode (cname = "GUINT16_TO_LE")]
534         public uint16 to_little_endian ();
536         [CCode (cname = "GUINT16_FROM_BE")]
537         public static uint16 from_big_endian (uint16 val);
538         [CCode (cname = "GUINT16_FROM_LE")]
539         public static uint16 from_little_endian (uint16 val);
541         [CCode (cname = "g_htons")]
542         public static uint16 to_network (uint16 val);
543         [CCode (cname = "g_ntohs")]
544         public static uint16 from_network (uint16 val);
546         [CCode (cname = "GUINT16_SWAP_BE_PDP")]
547         public uint16 swap_big_endian_pdp ();
548         [CCode (cname = "GUINT16_SWAP_LE_BE")]
549         public uint16 swap_little_endian_big_endian ();
550         [CCode (cname = "GUINT16_SWAP_LE_PDP")]
551         public uint16 swap_little_endian_pdp ();
554 [SimpleType]
555 [GIR (name = "gint32")]
556 [CCode (cname = "gint32", cheader_filename = "glib.h", type_id = "G_TYPE_INT", marshaller_type_name = "INT", get_value_function = "g_value_get_int", set_value_function = "g_value_set_int", default_value = "0", type_signature = "i")]
557 [IntegerType (rank = 6)]
558 public struct int32 {
559         [Version (since = "2.4")]
560         [CCode (cname = "G_MININT32")]
561         public const int32 MIN;
562         [Version (since = "2.4")]
563         [CCode (cname = "G_MAXINT32")]
564         public const int32 MAX;
566         [CCode (cname = "G_GINT32_FORMAT")]
567         public const string FORMAT;
568         [Version (since = "2.4")]
569         [CCode (cname = "G_GINT32_MODIFIER")]
570         public const string FORMAT_MODIFIER;
572         [CCode (cname = "g_strdup_printf", instance_pos = -1)]
573         public string to_string (string format = "%i");
575         [CCode (cname = "MIN")]
576         public static int32 min (int32 a, int32 b);
577         [CCode (cname = "MAX")]
578         public static int32 max (int32 a, int32 b);
579         [CCode (cname = "CLAMP")]
580         public int32 clamp (int32 low, int32 high);
582         [CCode (cname = "GINT32_TO_BE")]
583         public int32 to_big_endian ();
584         [CCode (cname = "GINT32_TO_LE")]
585         public int32 to_little_endian ();
587         [CCode (cname = "GINT32_FROM_BE")]
588         public static int32 from_big_endian (int32 val);
589         [CCode (cname = "GINT32_FROM_LE")]
590         public static int32 from_little_endian (int32 val);
593 [SimpleType]
594 [GIR (name = "guint32")]
595 [CCode (cname = "guint32", cheader_filename = "glib.h", type_id = "G_TYPE_UINT", marshaller_type_name = "UINT", get_value_function = "g_value_get_uint", set_value_function = "g_value_set_uint", default_value = "0U", type_signature = "u")]
596 [IntegerType (rank = 7)]
597 public struct uint32 {
598         [CCode (cname = "0U")]
599         public const uint32 MIN;
600         [Version (since = "2.4")]
601         [CCode (cname = "G_MAXUINT32")]
602         public const uint32 MAX;
604         [CCode (cname = "G_GUINT32_FORMAT")]
605         public const string FORMAT;
606         [CCode (cname = "G_GINT32_MODIFIER")]
607         public const string FORMAT_MODIFIER;
609         [CCode (cname = "g_strdup_printf", instance_pos = -1)]
610         public string to_string (string format = "%u");
612         [CCode (cname = "MIN")]
613         public static uint32 min (uint32 a, uint32 b);
614         [CCode (cname = "MAX")]
615         public static uint32 max (uint32 a, uint32 b);
616         [CCode (cname = "CLAMP")]
617         public uint32 clamp (uint32 low, uint32 high);
619         [CCode (cname = "GUINT32_TO_BE")]
620         public uint32 to_big_endian ();
621         [CCode (cname = "GUINT32_TO_LE")]
622         public uint32 to_little_endian ();
624         [CCode (cname = "GUINT32_FROM_BE")]
625         public static uint32 from_big_endian (uint32 val);
626         [CCode (cname = "GUINT32_FROM_LE")]
627         public static uint32 from_little_endian (uint32 val);
629         [CCode (cname = "g_htonl")]
630         public static uint32 to_network (uint32 val);
631         [CCode (cname = "g_ntohl")]
632         public static uint32 from_network (uint32 val);
634         [CCode (cname = "GUINT32_SWAP_BE_PDP")]
635         public uint32 swap_big_endian_pdp ();
636         [CCode (cname = "GUINT32_SWAP_LE_BE")]
637         public uint32 swap_little_endian_big_endian ();
638         [CCode (cname = "GUINT32_SWAP_LE_PDP")]
639         public uint32 swap_little_endian_pdp ();
642 [SimpleType]
643 [GIR (name = "gint64")]
644 [CCode (cname = "gint64", cheader_filename = "glib.h", type_id = "G_TYPE_INT64", marshaller_type_name = "INT64", get_value_function = "g_value_get_int64", set_value_function = "g_value_set_int64", default_value = "0LL", type_signature = "x")]
645 [IntegerType (rank = 10)]
646 public struct int64 {
647         [CCode (cname = "G_MININT64")]
648         public const int64 MIN;
649         [CCode (cname = "G_MAXINT64")]
650         public const int64 MAX;
652         [CCode (cname = "G_GINT64_FORMAT")]
653         public const string FORMAT;
654         [Version (since = "2.4")]
655         [CCode (cname = "G_GINT64_MODIFIER")]
656         public const string FORMAT_MODIFIER;
658         [CCode (cname = "g_strdup_printf", instance_pos = -1)]
659         public string to_string (string format = "%" + FORMAT);
661         [CCode (cname = "MIN")]
662         public static int64 min (int64 a, int64 b);
663         [CCode (cname = "MAX")]
664         public static int64 max (int64 a, int64 b);
665         [CCode (cname = "CLAMP")]
666         public int64 clamp (int64 low, int64 high);
667         [CCode (cname = "llabs", cheader_filename = "stdlib.h")]
668         public int64 abs ();
670         [CCode (cname = "GINT64_TO_BE")]
671         public int64 to_big_endian ();
672         [CCode (cname = "GINT64_TO_LE")]
673         public int64 to_little_endian ();
675         [CCode (cname = "GINT64_FROM_BE")]
676         public static int64 from_big_endian (int64 val);
677         [CCode (cname = "GINT64_FROM_LE")]
678         public static int64 from_little_endian (int64 val);
680         [CCode (cname = "GUINT64_SWAP_LE_BE")]
681         public uint64 swap_little_endian_big_endian ();
683         [CCode (cname = "g_ascii_strtoll")]
684         static int64 ascii_strtoll (string nptr, out char* endptr, uint _base);
686         [Version (since = "2.12")]
687         public static int64 parse (string str) {
688                 return ascii_strtoll (str, null, 0);
689         }
691         [Version (since = "2.12")]
692         public static bool try_parse (string str, out int64 result = null, out unowned string unparsed = null) {
693                 char* endptr;
694                 result = ascii_strtoll (str, out endptr, 0);
695                 if (endptr == (char*) str + str.length) {
696                         unparsed = "";
697                         return true;
698                 } else {
699                         unparsed = (string) endptr;
700                         return false;
701                 }
702         }
704         [CCode (cname = "g_ascii_string_to_signed")]
705         [Version (since = "2.54")]
706         public static bool from_string (string str, [CCode (pos = 5.1)] out int64 out_num = null, uint @base = 10U, int64 min = int64.MIN, int64 max = int64.MAX) throws GLib.NumberParserError;
709 [SimpleType]
710 [GIR (name = "guint64")]
711 [CCode (cname = "guint64", cheader_filename = "glib.h", type_id = "G_TYPE_UINT64", marshaller_type_name = "UINT64", get_value_function = "g_value_get_uint64", set_value_function = "g_value_set_uint64", default_value = "0ULL", type_signature = "t")]
712 [IntegerType (rank = 11)]
713 public struct uint64 {
714         [CCode (cname = "0ULL")]
715         public const uint64 MIN;
716         [CCode (cname = "G_MAXUINT64")]
717         public const uint64 MAX;
719         [CCode (cname = "G_GUINT64_FORMAT")]
720         public const string FORMAT;
721         [CCode (cname = "G_GINT64_MODIFIER")]
722         public const string FORMAT_MODIFIER;
724         [CCode (cname = "g_strdup_printf", instance_pos = -1)]
725         public string to_string (string format = "%" + FORMAT);
727         [CCode (cname = "MIN")]
728         public static uint64 min (uint64 a, uint64 b);
729         [CCode (cname = "MAX")]
730         public static uint64 max (uint64 a, uint64 b);
731         [CCode (cname = "CLAMP")]
732         public uint64 clamp (uint64 low, uint64 high);
734         [CCode (cname = "GUINT64_TO_BE")]
735         public uint64 to_big_endian ();
736         [CCode (cname = "GUINT64_TO_LE")]
737         public uint64 to_little_endian ();
739         [CCode (cname = "GUINT64_FROM_BE")]
740         public static uint64 from_big_endian (uint64 val);
741         [CCode (cname = "GUINT64_FROM_LE")]
742         public static uint64 from_little_endian (uint64 val);
744         [CCode (cname = "g_ascii_strtoull")]
745         static uint64 ascii_strtoull (string nptr, out char* endptr, uint _base);
747         public static uint64 parse (string str) {
748                 return ascii_strtoull (str, null, 0);
749         }
750         public static bool try_parse (string str, out uint64 result = null, out unowned string unparsed = null) {
751                 char* endptr;
752                 result = ascii_strtoull (str, out endptr, 0);
753                 if (endptr == (char*) str + str.length) {
754                         unparsed = "";
755                         return true;
756                 } else {
757                         unparsed = (string) endptr;
758                         return false;
759                 }
760         }
762         [CCode (cname = "g_ascii_string_to_unsigned")]
763         [Version (since = "2.54")]
764         public static bool from_string (string str, [CCode (pos = 5.1)] out uint64 out_num = null, uint @base = 10U, uint64 min = uint64.MIN, uint64 max = uint64.MAX) throws GLib.NumberParserError;
767 [SimpleType]
768 [GIR (name = "gfloat")]
769 [CCode (cname = "gfloat", cheader_filename = "glib.h,float.h,math.h", type_id = "G_TYPE_FLOAT", marshaller_type_name = "FLOAT", get_value_function = "g_value_get_float", set_value_function = "g_value_set_float", default_value = "0.0F")]
770 [FloatingType (rank = 1)]
771 public struct float {
772         [CCode (cname = "FLT_ROUNDS")]
773         public const int ROUNDS;
774         [CCode (cname = "FLT_RADIX")]
775         public const int RADIX;
776         [CCode (cname = "FLT_MANT_DIG")]
777         public const int MANT_DIG;
778         [CCode (cname = "FLT_DIG")]
779         public const int DIG;
781         [CCode (cname = "FLT_MIN_EXP")]
782         public const int MIN_EXP;
783         [CCode (cname = "FLT_MAX_EXP")]
784         public const int MAX_EXP;
786         [CCode (cname = "FLT_MIN_10_EXP")]
787         public const int MIN_10_EXP;
788         [CCode (cname = "FLT_MAX_10_EXP")]
789         public const int MAX_10_EXP;
791         [CCode (cname = "FLT_EPSILON")]
792         public const float EPSILON;
793         [CCode (cname = "FLT_MIN")]
794         public const float MIN;
795         [CCode (cname = "FLT_MAX")]
796         public const float MAX;
798         [CCode (cname = "NAN")]
799         public const float NAN;
800         [CCode (cname = "INFINITY")]
801         public const float INFINITY;
803         [CCode (cname = "isnan")]
804         public bool is_nan ();
805         [CCode (cname = "isfinite")]
806         public bool is_finite ();
807         [CCode (cname = "isnormal")]
808         public bool is_normal ();
809         [CCode (cname = "isinf")]
810         public int is_infinity ();
812         [CCode (cname = "g_strdup_printf", instance_pos = -1)]
813         public string to_string (string format = "%g");
815         [CCode (cname = "MIN")]
816         public static float min (float a, float b);
817         [CCode (cname = "MAX")]
818         public static float max (float a, float b);
819         [CCode (cname = "CLAMP")]
820         public float clamp (float low, float high);
821         [CCode (cname = "fabsf")]
822         public float abs ();
825 [SimpleType]
826 [GIR (name = "gdouble")]
827 [CCode (cname = "gdouble", cheader_filename = "glib.h,float.h,math.h", type_id = "G_TYPE_DOUBLE", marshaller_type_name = "DOUBLE", get_value_function = "g_value_get_double", set_value_function = "g_value_set_double", default_value = "0.0", type_signature = "d")]
828 [FloatingType (rank = 2)]
829 public struct double {
830         [CCode (cname = "DBL_MANT_DIG")]
831         public const int MANT_DIG;
832         [CCode (cname = "DBL_DIG")]
833         public const int DIG;
835         [CCode (cname = "DBL_MIN_EXP")]
836         public const int MIN_EXP;
837         [CCode (cname = "DBL_MAX_EXP")]
838         public const int MAX_EXP;
840         [CCode (cname = "DBL_MIN_10_EXP")]
841         public const int MIN_10_EXP;
842         [CCode (cname = "DBL_MAX_10_EXP")]
843         public const int MAX_10_EXP;
845         [CCode (cname = "DBL_EPSILON")]
846         public const double EPSILON;
847         [CCode (cname = "DBL_MIN")]
848         public const double MIN;
849         [CCode (cname = "DBL_MAX")]
850         public const double MAX;
852         [CCode (cname = "((double) NAN)")]
853         public const double NAN;
854         [CCode (cname = "((double) INFINITY)")]
855         public const double INFINITY;
857         [CCode (cname = "isnan")]
858         public bool is_nan ();
859         [CCode (cname = "isfinite")]
860         public bool is_finite ();
861         [CCode (cname = "isnormal")]
862         public bool is_normal ();
863         [CCode (cname = "isinf")]
864         public int is_infinity ();
866         [CCode (cname = "MIN")]
867         public static double min (double a, double b);
868         [CCode (cname = "MAX")]
869         public static double max (double a, double b);
870         [CCode (cname = "CLAMP")]
871         public double clamp (double low, double high);
872         [CCode (cname = "fabs")]
873         public double abs ();
875         [CCode (cname = "G_ASCII_DTOSTR_BUF_SIZE")]
876         public const int DTOSTR_BUF_SIZE;
877         [CCode (cname = "g_ascii_dtostr", instance_pos = -1)]
878         public unowned string to_str (char[] buffer);
879         [CCode (cname = "g_ascii_formatd", instance_pos = -1)]
880         public unowned string format (char[] buffer, string format = "%g");
882         public string to_string () {
883                 return this.to_str(new char[DTOSTR_BUF_SIZE]);
884         }
886         [CCode (cname = "g_ascii_strtod")]
887         static double ascii_strtod (string nptr, out char* endptr);
889         public static double parse (string str) {
890                 return ascii_strtod (str, null);
891         }
892         public static bool try_parse (string str, out double result = null, out unowned string unparsed = null) {
893                 char* endptr;
894                 result = ascii_strtod (str, out endptr);
895                 if (endptr == (char*) str + str.length) {
896                         unparsed = "";
897                         return true;
898                 } else {
899                         unparsed = (string) endptr;
900                         return false;
901                 }
902         }
905 [GIR (name = "glong")]
906 [CCode (cheader_filename = "time.h", has_type_id = false, default_value = "0")]
907 [IntegerType (rank = 8)]
908 public struct time_t {
909         [CCode (cname = "time")]
910         public time_t (out time_t result = null);
913 [SimpleType]
914 [CCode (cheader_filename="stdarg.h", cprefix="va_", has_type_id = false, destroy_function = "va_end", lvalue_access = false)]
915 public struct va_list {
916         [CCode (cname = "va_start")]
917         public va_list ();
918         [CCode (cname = "va_copy")]
919         public va_list.copy (va_list src);
920         [CCode (generic_type_pos = 1.1, simple_generics = true)]
921         public unowned G arg<G> ();
924 [SimpleType]
925 [GIR (name = "gunichar")]
926 [CCode (cname = "gunichar", cprefix = "g_unichar_", cheader_filename = "glib.h", type_id = "G_TYPE_UINT", marshaller_type_name = "UINT", get_value_function = "g_value_get_uint", set_value_function = "g_value_set_uint", default_value = "0U", type_signature = "u")]
927 [IntegerType (rank = 7)]
928 public struct unichar {
929         public bool validate ();
930         public bool isalnum ();
931         public bool isalpha ();
932         public bool iscntrl ();
933         public bool isdigit ();
934         public bool isgraph ();
935         public bool islower ();
936         [Version (since = "2.14")]
937         public bool ismark ();
938         public bool isprint ();
939         public bool ispunct ();
940         public bool isspace ();
941         public bool isupper ();
942         public bool isxdigit ();
943         public bool istitle ();
944         public bool isdefined ();
945         public bool iswide ();
946         [Version (since = "2.12")]
947         public bool iswide_cjk ();
948         [Version (since = "2.14")]
949         public bool iszerowidth ();
950         public unichar toupper ();
951         public unichar tolower ();
952         public unichar totitle ();
953         public int digit_value ();
954         public int xdigit_value ();
955         public GLib.UnicodeType type ();
956         public GLib.UnicodeBreakType break_type ();
957         [Version (since = "2.14")]
958         public GLib.UnicodeScript get_script();
960         public int to_utf8 (string? outbuf);
962         public string to_string () {
963                 string str = (string) new char[7];
964                 this.to_utf8 (str);
965                 return str;
966         }
968         [Version (since = "2.30")]
969         public bool compose (unichar b, out unichar ch);
970         [Version (since = "2.30")]
971         public bool decompose (out unichar a, out unichar b);
972         [Version (since = "2.30")]
973         public size_t fully_decompose (bool compat, unichar[] result);
975         [CCode (cname = "MIN")]
976         public static unichar min (unichar a, unichar b);
977         [CCode (cname = "MAX")]
978         public static unichar max (unichar a, unichar b);
979         [CCode (cname = "CLAMP")]
980         public unichar clamp (unichar low, unichar high);
982         [CCode (cname = "G_UNICHAR_MAX_DECOMPOSITION_LENGTH")]
983         public const int MAX_DECOMPOSITION_LENGTH;
985         [CCode (cname = "G_GUINT32_FORMAT")]
986         public const string FORMAT;
987         [CCode (cname = "G_GINT32_MODIFIER")]
988         public const string FORMAT_MODIFIER;
991 [SimpleType]
992 [GIR (name = "guint16")]
993 [CCode (cname = "gunichar2", cheader_filename = "glib.h", default_value = "0U", type_signature = "q", has_type_id = false)]
994 [IntegerType (rank = 5)]
995 public struct unichar2 {
996         [CCode (cname = "G_GUINT16_FORMAT")]
997         public const string FORMAT;
998         [CCode (cname = "G_GINT16_MODIFIER")]
999         public const string FORMAT_MODIFIER;
1002 [Compact]
1003 [Immutable]
1004 [GIR (name = "utf8")]
1005 [CCode (cname = "gchar", const_cname = "const gchar", copy_function = "g_strdup", free_function = "g_free", cheader_filename = "stdlib.h,string.h,glib.h", type_id = "G_TYPE_STRING", marshaller_type_name = "STRING", param_spec_function = "g_param_spec_string", get_value_function = "g_value_get_string", set_value_function = "g_value_set_string", take_value_function = "g_value_take_string", type_signature = "s")]
1006 public class string {
1007         [Version (replacement = "string.index_of")]
1008         [CCode (cname = "strstr")]
1009         public unowned string? str (string needle);
1010         [Version (replacement = "string.last_index_of")]
1011         [CCode (cname = "g_strrstr")]
1012         public unowned string? rstr (string needle);
1013         [CCode (cname = "g_strrstr_len")]
1014         public unowned string? rstr_len (ssize_t haystack_len, string needle);
1016         [CCode (cname = "strstr")]
1017         static char* strstr (char* haystack, char* needle);
1018         [CCode (cname = "g_strrstr")]
1019         static char* strrstr (char* haystack, char* needle);
1020         [CCode (cname = "g_utf8_strchr")]
1021         static char* utf8_strchr (char* str, ssize_t len, unichar c);
1022         [CCode (cname = "g_utf8_strrchr")]
1023         static char* utf8_strrchr (char* str, ssize_t len, unichar c);
1025         public int index_of (string needle, int start_index = 0) {
1026                 char* result = strstr ((char*) this + start_index, (char*) needle);
1028                 if (result != null) {
1029                         return (int) (result - (char*) this);
1030                 } else {
1031                         return -1;
1032                 }
1033         }
1035         public int last_index_of (string needle, int start_index = 0) {
1036                 char* result = strrstr ((char*) this + start_index, (char*) needle);
1038                 if (result != null) {
1039                         return (int) (result - (char*) this);
1040                 } else {
1041                         return -1;
1042                 }
1043         }
1045         public int index_of_char (unichar c, int start_index = 0) {
1046                 char* result = utf8_strchr ((char*) this + start_index, -1, c);
1048                 if (result != null) {
1049                         return (int) (result - (char*) this);
1050                 } else {
1051                         return -1;
1052                 }
1053         }
1055         public int last_index_of_char (unichar c, int start_index = 0) {
1056                 char* result = utf8_strrchr ((char*) this + start_index, -1, c);
1058                 if (result != null) {
1059                         return (int) (result - (char*) this);
1060                 } else {
1061                         return -1;
1062                 }
1063         }
1065         [Version (since = "2.2")]
1066         [CCode (cname = "g_str_has_prefix")]
1067         public bool has_prefix (string prefix);
1068         [Version (since = "2.2")]
1069         [CCode (cname = "g_str_has_suffix")]
1070         public bool has_suffix (string suffix);
1071         [CCode (cname = "g_strdup_printf"), PrintfFormat]
1072         public string printf (...);
1073         [CCode (cname = "g_strdup_vprintf")]
1074         public string vprintf (va_list args);
1075         [CCode (cname = "sscanf", cheader_filename = "stdio.h"), ScanfFormat]
1076         public int scanf (string format, ...);
1077         [CCode (cname = "g_strconcat")]
1078         public string concat (string string2, ...);
1079         [CCode (cname = "g_strescape")]
1080         public string escape (string? exceptions = null);
1081         [CCode (cname = "g_strcompress")]
1082         public string compress ();
1083         [CCode (cname = "g_strsplit", array_length = false, array_null_terminated = true)]
1084         public string[] split (string delimiter, int max_tokens = 0);
1085         [Version (since = "2.4")]
1086         [CCode (cname = "g_strsplit_set", array_length = false, array_null_terminated = true)]
1087         public string[] split_set (string delimiters, int max_tokens = 0);
1088         [CCode (cname = "g_stpcpy")]
1089         private static void* copy_to_buffer (void* dest, string src);
1090         [CCode (cname = "_vala_g_strjoinv")]
1091         public static string joinv (string? separator, string?[]? str_array) {
1092                 if (separator == null) {
1093                         separator = "";
1094                 }
1095                 if (str_array != null && (str_array.length > 0 || (str_array.length == -1 && str_array[0] != null))) {
1096                         int i;
1097                         size_t len = 1;
1098                         for (i = 0 ; (str_array.length != -1 && i < str_array.length) || (str_array.length == -1 && str_array[i] != null) ; i++) {
1099                                 len += (str_array[i] != null) ? ((!) str_array[i]).length : 0;
1100                         }
1101                         if (i == 0) {
1102                                 return "";
1103                         }
1104                         str_array.length = i;
1105                         len += ((!) separator).length * (i - 1);
1107                         string* res = GLib.malloc (len);
1108                         void* ptr = string.copy_to_buffer ((void*) res, (!) str_array[0]);
1109                         for (i = 1 ; i < str_array.length ; i++) {
1110                                 ptr = string.copy_to_buffer (ptr, (!) separator);
1111                                 ptr = string.copy_to_buffer (ptr, (str_array[i] != null) ? ((!) str_array[i]) : "");
1112                         }
1114                         return (owned) res;
1115                 } else {
1116                         return "";
1117                 }
1118         }
1119         [CCode (cname = "g_strjoin")]
1120         public static string join (string separator, ...);
1121         [CCode (cname = "g_strnfill")]
1122         public static string nfill (size_t length, char fill_char);
1124         public char get (long index) {
1125                 return ((char*) this)[index];
1126         }
1128         // checks whether valid string character starts at specified index
1129         // embedded NULs are not supported by the string class
1130         public bool valid_char (int index) {
1131                 uint8 c = ((uint8*) this)[index];
1132                 if (c == 0x00 || (c >= 0x80 && c < 0xc2) || c >= 0xf5) {
1133                         return false;
1134                 } else {
1135                         return true;
1136                 }
1137         }
1139         [CCode (cname = "g_utf8_next_char")]
1140         public unowned string next_char ();
1141         [CCode (cname = "g_utf8_next_char")]
1142         static char* utf8_next_char (char* str);
1143         public bool get_next_char (ref int index, out unichar c) {
1144                 c = utf8_get_char ((char*) this + index);
1145                 if (c != 0) {
1146                         index = (int) (utf8_next_char ((char*) this + index) - (char*) this);
1147                         return true;
1148                 } else {
1149                         return false;
1150                 }
1151         }
1152         [CCode (cname = "g_utf8_get_char")]
1153         static unichar utf8_get_char (char* str);
1154         public unichar get_char (long index = 0) {
1155                 return utf8_get_char ((char*) this + index);
1156         }
1157         [CCode (cname = "g_utf8_get_char_validated")]
1158         public unichar get_char_validated (ssize_t max_len = -1);
1160         [Version (replacement = "string.index_of_nth_char")]
1161         [CCode (cname = "g_utf8_offset_to_pointer")]
1162         public unowned string utf8_offset (long offset);
1163         public unowned string offset (long offset) {
1164                 return (string) ((char*) this + offset);
1165         }
1166         [Version (replacement = "string.char_count")]
1167         public long pointer_to_offset (string pos) {
1168                 return (long) ((char*) pos - (char*) this);
1169         }
1171         [CCode (cname = "g_utf8_offset_to_pointer")]
1172         char* utf8_offset_to_pointer (long offset);
1174         public int index_of_nth_char (long c) {
1175                 return (int) (this.utf8_offset_to_pointer (c) - (char*) this);
1176         }
1178         [CCode (cname = "g_utf8_prev_char")]
1179         public unowned string prev_char ();
1180         [CCode (cname = "g_utf8_prev_char")]
1181         static char* utf8_prev_char (char* str);
1182         public bool get_prev_char (ref int index, out unichar c) {
1183                 if (0 < index) {
1184                         index = (int) (utf8_prev_char ((char*) this + index) - (char*) this);
1185                         c = utf8_get_char ((char*) this + index);
1186                         return true;
1187                 } else {
1188                         c = 0;
1189                         return false;
1190                 }
1191         }
1193         [Version (replacement = "string.length")]
1194         [CCode (cname = "strlen")]
1195         public long len ();
1196         [Version (replacement = "string.index_of_char")]
1197         [CCode (cname = "g_utf8_strchr")]
1198         public unowned string chr (ssize_t len, unichar c);
1199         [Version (replacement = "string.last_index_of_char")]
1200         [CCode (cname = "g_utf8_strrchr")]
1201         public unowned string rchr (ssize_t len, unichar c);
1202         [Version (since = "2.2")]
1203         [CCode (cname = "g_utf8_strreverse")]
1204         public string reverse (ssize_t len = -1);
1205         [CCode (cname = "g_utf8_validate")]
1206         public bool validate (ssize_t max_len = -1, out char* end = null);
1207         [Version (since = "2.52")]
1208         [CCode (cname = "g_utf8_make_valid")]
1209         public string make_valid (ssize_t len = -1);
1210         [CCode (cname = "g_utf8_normalize")]
1211         public string normalize (ssize_t len = -1, GLib.NormalizeMode mode = GLib.NormalizeMode.DEFAULT);
1213         [CCode (cname = "g_utf8_strup")]
1214         public string up (ssize_t len = -1);
1215         [CCode (cname = "g_utf8_strdown")]
1216         public string down (ssize_t len = -1);
1217         [CCode (cname = "g_utf8_casefold")]
1218         public string casefold (ssize_t len = -1);
1219         [CCode (cname = "g_utf8_collate")]
1220         public int collate (string str2);
1221         [CCode (cname = "g_utf8_collate_key")]
1222         public string collate_key (ssize_t len = -1);
1223         [Version (since = "2.8")]
1224         [CCode (cname = "g_utf8_collate_key_for_filename")]
1225         public string collate_key_for_filename (ssize_t len = -1);
1227         [CCode (cname = "g_locale_to_utf8")]
1228         public string locale_to_utf8 (ssize_t len, out size_t bytes_read, out size_t bytes_written, out GLib.Error error = null);
1230         [CCode (cname = "g_strchomp")]
1231         public unowned string _chomp();
1232         public string chomp () {
1233                 string result = this.dup ();
1234                 result._chomp ();
1235                 return result;
1236         }
1238         [CCode (cname = "g_strchug")]
1239         public unowned string _chug();
1240         public string chug () {
1241                 string result = this.dup ();
1242                 result._chug ();
1243                 return result;
1244         }
1246         [CCode (cname = "g_strstrip")]
1247         public unowned string _strip ();
1248         public string strip () {
1249                 string result = this.dup ();
1250                 result._strip ();
1251                 return result;
1252         }
1254         [CCode (cname = "g_strdelimit")]
1255         public unowned string _delimit (string delimiters, char new_delimiter);
1256         public string delimit (string delimiters, char new_delimiter) {
1257                 string result = this.dup ();
1258                 result._delimit (delimiters, new_delimiter);
1259                 return result;
1260         }
1262         [CCode (cname = "g_str_hash")]
1263         public uint hash ();
1265         [Version (since = "2.40")]
1266         [CCode (cname = "g_str_is_ascii")]
1267         public bool is_ascii ();
1268         [Version (since = "2.40")]
1269         [CCode (instance_pos = "1.5", cname = "g_str_match_string")]
1270         public bool match_string (string search_term, bool accept_alternates);
1271         [Version (since = "2.40")]
1272         [CCode (cname = "g_str_to_ascii")]
1273         public string to_ascii (string? from_locale = null);
1274         [Version (replacement = "int.parse")]
1275         [CCode (cname = "atoi")]
1276         public int to_int ();
1277         [Version (replacement = "long.parse")]
1278         [CCode (cname = "strtol")]
1279         public long to_long (out unowned string endptr = null, int _base = 0);
1280         [Version (replacement = "double.parse")]
1281         [CCode (cname = "g_ascii_strtod")]
1282         public double to_double (out unowned string endptr = null);
1283         [Version (replacement = "uint64.parse")]
1284         [CCode (cname = "strtoul")]
1285         public ulong to_ulong (out unowned string endptr = null, int _base = 0);
1286         [Version (replacement = "int64.parse")]
1287         [CCode (cname = "g_ascii_strtoll")]
1288         public int64 to_int64 (out unowned string endptr = null, int _base = 0);
1289         [Version (replacement = "uint64.parse", since = "2.2")]
1290         [CCode (cname = "g_ascii_strtoull")]
1291         public uint64 to_uint64 (out unowned string endptr = null, int _base = 0);
1292         [CCode (cname = "g_str_tokenize_and_fold", array_length = false, array_null_terminated = true)]
1293         [Version (since = "2.40")]
1294         public string[] tokenize_and_fold (string transit_locale, [CCode (array_length = false, array_null_terminated = true)] out string[] ascii_alternates);
1296         [Version (replacement = "bool.parse")]
1297         public bool to_bool () {
1298                 if (this == "true") {
1299                         return true;
1300                 } else {
1301                         return false;
1302                 }
1303         }
1305         [Version (replacement = "string.length")]
1306         [CCode (cname = "strlen")]
1307         public size_t size ();
1309         [CCode (cname = "g_ascii_strcasecmp")]
1310         public int ascii_casecmp (string s2);
1311         [CCode (cname = "g_ascii_strncasecmp")]
1312         public int ascii_ncasecmp (string s2, size_t n);
1313         [CCode (cname = "g_ascii_strup")]
1314         public string ascii_up (ssize_t len = -1);
1315         [CCode (cname = "g_ascii_strdown")]
1316         public string ascii_down (ssize_t len = -1);
1318         [CCode (cname = "g_utf8_skip")]
1319         public static char[] skip;
1321         /* modifies string in place */
1322         [CCode (cname = "g_strcanon")]
1323         public void canon (string valid_chars, char substitutor);
1325         [CCode (cname = "g_strdup")]
1326         public string dup ();
1327         [Version (replacement = "string.substring")]
1328         [CCode (cname = "g_strndup")]
1329         public string ndup (size_t n);
1331         [CCode (cname = "memchr")]
1332         static char* memchr (char* s, int c, size_t n);
1334         // strnlen is not available on all systems
1335         static long strnlen (char* str, long maxlen) {
1336                 char* end = memchr (str, 0, maxlen);
1337                 if (end == null) {
1338                         return maxlen;
1339                 } else {
1340                         return (long) (end - str);
1341                 }
1342         }
1344         [CCode (cname = "g_strndup")]
1345         static string strndup (char* str, size_t n);
1347         public string substring (long offset, long len = -1) {
1348                 long string_length;
1349                 if (offset >= 0 && len >= 0) {
1350                         // avoid scanning whole string
1351                         string_length = strnlen ((char*) this, offset + len);
1352                 } else {
1353                         string_length = this.length;
1354                 }
1356                 if (offset < 0) {
1357                         offset = string_length + offset;
1358                         GLib.return_val_if_fail (offset >= 0, null);
1359                 } else {
1360                         GLib.return_val_if_fail (offset <= string_length, null);
1361                 }
1362                 if (len < 0) {
1363                         len = string_length - offset;
1364                 }
1365                 GLib.return_val_if_fail (offset + len <= string_length, null);
1366                 return strndup ((char*) this + offset, len);
1367         }
1369         public string slice (long start, long end) {
1370                 long string_length = this.length;
1371                 if (start < 0) {
1372                         start = string_length + start;
1373                 }
1374                 if (end < 0) {
1375                         end = string_length + end;
1376                 }
1377                 GLib.return_val_if_fail (start >= 0 && start <= string_length, null);
1378                 GLib.return_val_if_fail (end >= 0 && end <= string_length, null);
1379                 GLib.return_val_if_fail (start <= end, null);
1380                 return strndup ((char*) this + start, end - start);
1381         }
1383         public string splice (long start, long end, string? str = null) {
1384                 long string_length = this.length;
1385                 if (start < 0) {
1386                         start = string_length + start;
1387                 }
1388                 if (end < 0) {
1389                         end = string_length + end;
1390                 }
1391                 GLib.return_val_if_fail (start >= 0 && start <= string_length, null);
1392                 GLib.return_val_if_fail (end >= 0 && end <= string_length, null);
1393                 GLib.return_val_if_fail (start <= end, null);
1395                 size_t str_size;
1396                 if (str == null) {
1397                         str_size = 0;
1398                 } else {
1399                         str_size = ((!)(str)).length;
1400                 }
1402                 string* result = GLib.malloc0 (this.length - (end - start) + str_size + 1);
1404                 char* dest = (char*) result;
1406                 GLib.Memory.copy (dest, this, start);
1407                 dest += start;
1409                 GLib.Memory.copy (dest, str, str_size);
1410                 dest += str_size;
1412                 GLib.Memory.copy (dest, (char*) this + end, string_length - end);
1414                 return (owned) result;
1415         }
1417         public bool contains (string needle) {
1418                 return strstr ((char*) this, (char*) needle) != null;
1419         }
1421         public string replace (string old, string replacement) {
1422                 if (*((char*) this) == '\0' || *((char*) old) == '\0' || old == replacement)
1423                         return this;
1425                 try {
1426                         var regex = new GLib.Regex (GLib.Regex.escape_string (old));
1427                         return regex.replace_literal (this, -1, 0, replacement);
1428                 } catch (GLib.RegexError e) {
1429                         GLib.assert_not_reached ();
1430                 }
1431         }
1433         [CCode (cname = "g_utf8_strlen")]
1434         public int char_count (ssize_t max = -1);
1436         public int length {
1437                 [CCode (cname = "strlen")]
1438                 get;
1439         }
1441         public uint8[] data {
1442                 get {
1443                         unowned uint8[] res = (uint8[]) this;
1444                         res.length = (int) this.length;
1445                         return res;
1446                 }
1447         }
1449         public char[] to_utf8 () {
1450                 char[] result = new char[this.length + 1];
1451                 result.length--;
1452                 GLib.Memory.copy (result, this, this.length);
1453                 return result;
1454         }
1456         public unowned string to_string () {
1457                 return this;
1458         }
1460         [CCode (cname = "g_utf8_to_utf16")]
1461         public string16 to_utf16 (long len = -1, out long? items_read = null, out long? items_written = null) throws GLib.ConvertError;
1462         [CCode (cname = "g_utf8_to_ucs4")]
1463         public string32 to_utf32 (long len = -1, out long? items_read = null, out long? items_written = null) throws GLib.ConvertError;
1464         [CCode (cname = "g_utf8_to_ucs4_fast")]
1465         public string32 to_utf32_fast (long len = -1, out long? items_written = null);
1469 [Compact]
1470 [Immutable]
1471 [GIR (name = "gunichar")]
1472 [CCode (cname = "gunichar", const_cname = "const gunichar", free_function = "g_free", cheader_filename = "glib.h")]
1473 public class string32 {
1474         [CCode (cname = "g_ucs4_to_utf16")]
1475         public string16 to_utf16 (long len = -1, out long? items_read = null, out long? items_written = null) throws GLib.ConvertError;
1476         [CCode (cname = "g_ucs4_to_utf8")]
1477         public string to_utf8 (long len = -1, out long? items_read = null, out long? items_written = null) throws GLib.ConvertError;
1479         public string? to_string () {
1480                 try {
1481                         return this.to_utf8 ();
1482                 } catch (GLib.ConvertError e) {
1483                         return null;
1484                 }
1485         }
1488 [Compact]
1489 [Immutable]
1490 [GIR (name = "guint16")]
1491 [CCode (cname = "gunichar2", const_cname = "const gunichar2", free_function = "g_free", cheader_filename = "glib.h")]
1492 public class string16 {
1493         [CCode (cname = "g_utf16_to_ucs4")]
1494         public string32 to_utf32 (long len = -1, out long? items_read = null, out long? items_written = null) throws GLib.ConvertError;
1495         [CCode (cname = "g_utf16_to_utf8")]
1496         public string to_utf8 (long len = -1, out long? items_read = null, out long? items_written = null) throws GLib.ConvertError;
1498         public string? to_string () {
1499                 try {
1500                         return this.to_utf8 ();
1501                 } catch (GLib.ConvertError e) {
1502                         return null;
1503                 }
1504         }
1507 [CCode (cprefix = "G", lower_case_cprefix = "g_", cheader_filename = "glib.h", gir_namespace = "GLib", gir_version = "2.0")]
1508 namespace GLib {
1509         [CCode (lower_case_cprefix = "", cheader_filename = "math.h")]
1510         namespace Math {
1511                 [CCode (cname = "G_E")]
1512                 public const double E;
1514                 [CCode (cname = "G_PI")]
1515                 public const double PI;
1517                 [CCode (cname = "G_LN2")]
1518                 public const double LN2;
1520                 [CCode (cname = "G_LN10")]
1521                 public const double LN10;
1523                 [CCode (cname = "G_PI_2")]
1524                 public const double PI_2;
1526                 [CCode (cname = "G_PI_4")]
1527                 public const double PI_4;
1529                 [CCode (cname = "G_SQRT2")]
1530                 public const double SQRT2;
1532                 [CCode (cname = "G_LOG_2_BASE_10")]
1533                 public const double LOG_2_BASE_10;
1535                 /* generated from <bits/mathcalls.h> of glibc */
1536                 public static double acos (double x);
1537                 public static float acosf (float x);
1538                 public static double asin (double x);
1539                 public static float asinf (float x);
1540                 public static double atan (double x);
1541                 public static float atanf (float x);
1542                 public static double atan2 (double y, double x);
1543                 public static float atan2f (float y, float x);
1544                 public static double cos (double x);
1545                 public static float cosf (float x);
1546                 public static double sin (double x);
1547                 public static float sinf (float x);
1548                 public static double tan (double x);
1549                 public static float tanf (float x);
1550                 public static double cosh (double x);
1551                 public static float coshf (float x);
1552                 public static double sinh (double x);
1553                 public static float sinhf (float x);
1554                 public static double tanh (double x);
1555                 public static float tanhf (float x);
1556                 public static void sincos (double x, out double sinx, out double cosx);
1557                 public static void sincosf (float x, out float sinx, out float cosx);
1558                 public static double acosh (double x);
1559                 public static float acoshf (float x);
1560                 public static double asinh (double x);
1561                 public static float asinhf (float x);
1562                 public static double atanh (double x);
1563                 public static float atanhf (float x);
1564                 public static double exp (double x);
1565                 public static float expf (float x);
1566                 public static double frexp (double x, out int exponent);
1567                 public static float frexpf (float x, out int exponent);
1568                 public static double ldexp (double x, int exponent);
1569                 public static float ldexpf (float x, int exponent);
1570                 public static double log (double x);
1571                 public static float logf (float x);
1572                 public static double log10 (double x);
1573                 public static float log10f (float x);
1574                 public static double modf (double x, out double iptr);
1575                 public static float modff (float x, out float iptr);
1576                 [CCode (feature_test_macro = "_GNU_SOURCE")]
1577                 public static double exp10 (double x);
1578                 [CCode (feature_test_macro = "_GNU_SOURCE")]
1579                 public static float exp10f (float x);
1580                 [CCode (feature_test_macro = "_GNU_SOURCE")]
1581                 public static double pow10 (double x);
1582                 [CCode (feature_test_macro = "_GNU_SOURCE")]
1583                 public static float pow10f (float x);
1584                 public static double expm1 (double x);
1585                 public static float expm1f (float x);
1586                 public static double log1p (double x);
1587                 public static float log1pf (float x);
1588                 public static double logb (double x);
1589                 public static float logbf (float x);
1590                 public static double exp2 (double x);
1591                 public static float exp2f (float x);
1592                 public static double log2 (double x);
1593                 public static float log2f (float x);
1594                 public static double pow (double x, double y);
1595                 public static float powf (float x, float y);
1596                 public static double sqrt (double x);
1597                 public static float sqrtf (float x);
1598                 public static double hypot (double x, double y);
1599                 public static float hypotf (float x, float y);
1600                 public static double cbrt (double x);
1601                 public static float cbrtf (float x);
1602                 public static double ceil (double x);
1603                 public static float ceilf (float x);
1604                 public static double fabs (double x);
1605                 public static float fabsf (float x);
1606                 public static double floor (double x);
1607                 public static float floorf (float x);
1608                 public static double fmod (double x, double y);
1609                 public static float fmodf (float x, float y);
1610                 public static int isinf (double value);
1611                 public static int isinff (float value);
1612                 public static int finite (double value);
1613                 public static int finitef (float value);
1614                 public static double drem (double x, double y);
1615                 public static float dremf (float x, float y);
1616                 public static double significand (double x);
1617                 public static float significandf (float x);
1618                 public static double copysign (double x, double y);
1619                 public static float copysignf (float x, float y);
1620                 public static double nan (string tagb);
1621                 public static float nanf (string tagb);
1622                 public static int isnan (double value);
1623                 public static int isnanf (float value);
1624                 public static double j0 (double x0);
1625                 public static float j0f (float x0);
1626                 public static double j1 (double x0);
1627                 public static float j1f (float x0);
1628                 public static double jn (int x0, double x1);
1629                 public static float jnf (int x0, float x1);
1630                 public static double y0 (double x0);
1631                 public static float y0f (float x0);
1632                 public static double y1 (double x0);
1633                 public static float y1f (float x0);
1634                 public static double yn (int x0, double x1);
1635                 public static float ynf (int x0, float x1);
1636                 public static double erf (double x0);
1637                 public static float erff (float x0);
1638                 public static double erfc (double x0);
1639                 public static float erfcf (float x0);
1640                 public static double lgamma (double x0);
1641                 public static float lgammaf (float x0);
1642                 public static double tgamma (double x0);
1643                 public static float tgammaf (float x0);
1644                 public static double gamma (double x0);
1645                 public static float gammaf (float x0);
1646                 public static double lgamma_r (double x0, out int signgamp);
1647                 public static float lgamma_rf (float x0, out int signgamp);
1648                 public static double rint (double x);
1649                 public static float rintf (float x);
1650                 public static double nextafter (double x, double y);
1651                 public static float nextafterf (float x, float y);
1652                 public static double nexttoward (double x, double y);
1653                 public static float nexttowardf (float x, double y);
1654                 public static double remainder (double x, double y);
1655                 public static float remainderf (float x, float y);
1656                 public static double scalbn (double x, int n);
1657                 public static float scalbnf (float x, int n);
1658                 public static int ilogb (double x);
1659                 public static int ilogbf (float x);
1660                 public static double scalbln (double x, long n);
1661                 public static float scalblnf (float x, long n);
1662                 public static double nearbyint (double x);
1663                 public static float nearbyintf (float x);
1664                 public static double round (double x);
1665                 public static float roundf (float x);
1666                 public static double trunc (double x);
1667                 public static float truncf (float x);
1668                 public static double remquo (double x, double y, out int quo);
1669                 public static float remquof (float x, float y, out int quo);
1670                 public static long lrint (double x);
1671                 public static long lrintf (float x);
1672                 public static int64 llrint (double x);
1673                 public static int64 llrintf (float x);
1674                 public static long lround (double x);
1675                 public static long lroundf (float x);
1676                 public static int64 llround (double x);
1677                 public static int64 llroundf (float x);
1678                 public static double fdim (double x, double y);
1679                 public static float fdimf (float x, float y);
1680                 public static double fmax (double x, double y);
1681                 public static float fmaxf (float x, float y);
1682                 public static double fmin (double x, double y);
1683                 public static float fminf (float x, float y);
1684                 public static double fma (double x, double y, double z);
1685                 public static float fmaf (float x, float y, float z);
1686                 public static double scalb (double x, double n);
1687                 public static float scalbf (float x, float n);
1688         }
1690         /* Byte order */
1691         [CCode (cprefix = "G_", cname = "int", has_type_id = false)]
1692         public enum ByteOrder {
1693                 [CCode (cname = "G_BYTE_ORDER")]
1694                 HOST,
1695                 LITTLE_ENDIAN,
1696                 BIG_ENDIAN,
1697                 PDP_ENDIAN
1698         }
1700         public const ByteOrder BYTE_ORDER;
1702         /* Atomic Operations */
1704         [Version (since = "2.4")]
1705         namespace AtomicInt {
1706                 public static int get ([CCode (type = "volatile gint *")] ref int atomic);
1707                 public static void set ([CCode (type = "volatile gint *")] ref int atomic, int newval);
1708                 [Version (since = "2.30")]
1709                 public static int add ([CCode (type = "volatile gint *")] ref int atomic, int val);
1710                 [Version (deprecated_since = "2.30", replacement = "add")]
1711                 public static int exchange_and_add ([CCode (type = "volatile gint *")] ref int atomic, int val);
1712                 public static bool compare_and_exchange ([CCode (type = "volatile gint *")] ref int atomic, int oldval, int newval);
1713                 public static void inc ([CCode (type = "volatile gint *")] ref int atomic);
1714                 public static bool dec_and_test ([CCode (type = "volatile gint *")] ref int atomic);
1715         }
1717         [Version (since = "2.4")]
1718         namespace AtomicPointer {
1719                 public static void* get ([CCode (type = "volatile gpointer *")] void** atomic);
1720                 public static void set ([CCode (type = "volatile gpointer *")] void** atomic, void* newval);
1721                 public static bool compare_and_exchange ([CCode (type = "volatile gpointer *")] void** atomic, void* oldval, void* newval);
1722         }
1724         /* The Main Event Loop */
1726         [Compact]
1727         [CCode (ref_function = "g_main_loop_ref", unref_function = "g_main_loop_unref")]
1728         public class MainLoop {
1729                 public MainLoop (MainContext? context = null, bool is_running = false);
1730                 public void run ();
1731                 public void quit ();
1732                 public bool is_running ();
1733                 public unowned MainContext get_context ();
1734         }
1736         namespace Priority {
1737                 public const int HIGH;
1738                 public const int DEFAULT;
1739                 public const int HIGH_IDLE;
1740                 public const int DEFAULT_IDLE;
1741                 public const int LOW;
1742         }
1744         [Compact]
1745         [CCode (ref_function = "g_main_context_ref", unref_function = "g_main_context_unref")]
1746         public class MainContext {
1747                 public MainContext ();
1748                 public static unowned MainContext @default ();
1749                 public bool iteration (bool may_block);
1750                 public bool pending ();
1751                 public unowned Source find_source_by_id (uint source_id);
1752                 public unowned Source find_source_by_user_data (void* user_data);
1753                 public unowned Source find_source_by_funcs_user_data (SourceFuncs funcs, void* user_data);
1754                 public void wakeup ();
1755                 public bool acquire ();
1756                 public void release ();
1757                 [Version (since = "2.10")]
1758                 public bool is_owner ();
1759                 public bool wait (Cond cond, Mutex mutex);
1760                 public bool prepare (out int priority);
1761                 public int query (int max_priority, out int timeout_, PollFD[] fds);
1762                 public bool check (int max_priority, PollFD[] fds);
1763                 public void dispatch ();
1764                 public void set_poll_func (PollFunc func);
1765                 public PollFunc get_poll_func ();
1766                 public void add_poll (ref PollFD fd, int priority);
1767                 public void remove_poll (ref PollFD fd);
1768                 public int depth ();
1769                 [Version (since = "2.12")]
1770                 [CCode (cname = "g_main_current_source")]
1771                 public static unowned Source current_source ();
1772                 [Version (since = "2.22")]
1773                 public static unowned MainContext? get_thread_default ();
1774                 [Version (since = "2.32")]
1775                 public static MainContext ref_thread_default ();
1776                 [Version (since = "2.22")]
1777                 public void push_thread_default ();
1778                 [Version (since = "2.22")]
1779                 public void pop_thread_default ();
1780                 [Version (since = "2.28")]
1781                 [CCode (cname = "g_main_context_invoke_full")]
1782                 public void invoke (owned SourceFunc function, [CCode (pos = 0.1)] int priority = Priority.DEFAULT);
1783                 [Version (since = "2.28")]
1784                 public void invoke_full (int priority, owned SourceFunc function);
1785         }
1787         [CCode (has_target = false)]
1788         public delegate int PollFunc (PollFD[] ufds, int timeout_);
1790         [CCode (cname = "GSource")]
1791         public class TimeoutSource : Source {
1792                 public TimeoutSource (uint interval);
1793                 [Version (since = "2.14")]
1794                 public TimeoutSource.seconds (uint interval);
1795         }
1797         namespace Timeout {
1798                 [CCode (cname = "g_timeout_add_full")]
1799                 public static uint add (uint interval, owned SourceFunc function, [CCode (pos = 0.1)] int priority = Priority.DEFAULT);
1800                 public static uint add_full (int priority, uint interval, owned SourceFunc function);
1801                 [Version (since = "2.14")]
1802                 [CCode (cname = "g_timeout_add_seconds_full")]
1803                 public static uint add_seconds (uint interval, owned SourceFunc function, [CCode (pos = 0.1)] int priority = Priority.DEFAULT);
1804                 [Version (since = "2.14")]
1805                 public static uint add_seconds_full (int priority, uint interval, owned SourceFunc function);
1806         }
1808         [CCode (cname = "GSource")]
1809         public class IdleSource : Source {
1810                 public IdleSource ();
1811         }
1813         namespace Idle {
1814                 [CCode (cname = "g_idle_add_full")]
1815                 public static uint add (owned SourceFunc function, [CCode (pos = 0.1)] int priority = Priority.DEFAULT_IDLE);
1816                 public static uint add_full (int priority, owned SourceFunc function);
1817                 public static bool remove_by_data (void* data);
1818         }
1820         [CCode (type_id = "G_TYPE_INT", marshaller_type_name = "INT", get_value_function = "g_value_get_int", set_value_function = "g_value_set_int", default_value = "0")]
1821         [IntegerType (rank = 6)]
1822         public struct Pid : int {
1823                 [CCode (cname = "G_PID_FORMAT")]
1824                 [Version (since = "2.50")]
1825                 public const string FORMAT;
1826         }
1828         public delegate void ChildWatchFunc (Pid pid, int status);
1830         [CCode (cname = "GSource")]
1831         public class ChildWatchSource : Source {
1832                 public ChildWatchSource (Pid pid);
1833         }
1835         namespace ChildWatch {
1836                 [Version (since = "2.4")]
1837                 [CCode (cname = "g_child_watch_add_full")]
1838                 public static uint add (Pid pid, owned ChildWatchFunc function, [CCode (pos = 0.1)] int priority = Priority.DEFAULT_IDLE);
1839                 [Version (since = "2.4")]
1840                 public static uint add_full (int priority, Pid pid, owned ChildWatchFunc function);
1841         }
1843         public struct PollFD {
1844                 public int fd;
1845                 public IOCondition events;
1846                 public IOCondition revents;
1847         }
1849         [Compact]
1850         [CCode (ref_function = "g_source_ref", unref_function = "g_source_unref")]
1851         public abstract class Source {
1852                 protected Source ();
1853                 [Version (since = "2.12")]
1854                 public void set_funcs (SourceFuncs funcs);
1855                 public uint attach (MainContext? context);
1856                 public void destroy ();
1857                 [Version (since = "2.12")]
1858                 public bool is_destroyed ();
1859                 public void set_priority (int priority);
1860                 public int get_priority ();
1861                 public void set_can_recurse (bool can_recurse);
1862                 public bool get_can_recurse ();
1863                 public uint get_id ();
1864                 [Version (since = "2.26")]
1865                 public unowned string? get_name ();
1866                 [Version (since = "2.26")]
1867                 public void set_name (string? name);
1868                 [Version (since = "2.26")]
1869                 public static void set_name_by_id (uint tag, string? name);
1870                 public unowned MainContext get_context ();
1871                 public void set_callback (owned SourceFunc func);
1872                 public void set_callback_indirect (void* callback_data, SourceCallbackFuncs callback_funcs);
1873                 [Version (since = "2.36")]
1874                 public void* add_unix_fd (int fd, IOCondition events);
1875                 [Version (since = "2.36")]
1876                 public void remove_unix_fd (void* tag);
1877                 [Version (since = "2.36")]
1878                 public void modify_unix_fd (void* tag, IOCondition new_events);
1879                 [Version (since = "2.36")]
1880                 public IOCondition query_unix_fd (void* tag);
1881                 public void add_poll (ref PollFD fd);
1882                 public void remove_poll (ref PollFD fd);
1883                 [Version (since = "2.28")]
1884                 public void add_child_source (Source child_source);
1885                 [Version (since = "2.28")]
1886                 public void remove_child_source (Source child_source);
1887                 [Version (since = "2.28")]
1888                 public int64 get_time ();
1889                 [Version (deprecated_since = "2.28", replacement = "get_time")]
1890                 public void get_current_time (out TimeVal timeval);
1891                 [Version (since = "2.36")]
1892                 public void set_ready_time (int64 ready_time);
1893                 public int64 get_ready_time ();
1894                 public static bool remove (uint id);
1895                 public static bool remove_by_funcs_user_data (void* user_data);
1896                 public static bool remove_by_user_data (void* user_data);
1897                 [Version (since = "2.32")]
1898                 [CCode (cname = "G_SOURCE_CONTINUE")]
1899                 public const bool CONTINUE;
1900                 [Version (since = "2.32")]
1901                 [CCode (cname = "G_SOURCE_REMOVE")]
1902                 public const bool REMOVE;
1904                 protected abstract bool prepare (out int timeout_);
1905                 protected abstract bool check ();
1906                 protected abstract bool dispatch (SourceFunc _callback);
1907         }
1909         [CCode (has_target = false)]
1910         public delegate void SourceDummyMarshal ();
1912         [CCode (has_target = false)]
1913         public delegate bool SourcePrepareFunc (Source source, out int timeout_);
1914         [CCode (has_target = false)]
1915         public delegate bool SourceCheckFunc (Source source);
1916         [CCode (has_target = false)]
1917         public delegate bool SourceDispatchFunc (Source source, SourceFunc _callback);
1918         [CCode (has_target = false)]
1919         public delegate void SourceFinalizeFunc (Source source);
1921         public struct SourceFuncs {
1922                 public SourcePrepareFunc prepare;
1923                 public SourceCheckFunc check;
1924                 public SourceDispatchFunc dispatch;
1925                 public SourceFinalizeFunc finalize;
1926         }
1928         [CCode (has_target = false)]
1929         public delegate void SourceCallbackRefFunc (void* cb_data);
1930         [CCode (has_target = false)]
1931         public delegate void SourceCallbackUnrefFunc (void* cb_data);
1932         [CCode (has_target = false)]
1933         public delegate void SourceCallbackGetFunc (void* cb_data, Source source, SourceFunc func);
1935         [Compact]
1936         public class SourceCallbackFuncs {
1937                 public SourceCallbackRefFunc @ref;
1938                 public SourceCallbackUnrefFunc unref;
1939                 public SourceCallbackGetFunc @get;
1940         }
1942         public delegate bool SourceFunc ();
1944         public errordomain ThreadError {
1945                 AGAIN;
1946                 public static GLib.Quark quark ();
1947         }
1949         /* Thread support */
1951         [CCode (scope = "async")]
1952         public delegate G ThreadFunc<G> ();
1953         public delegate void Func<G> (G data);
1955         [Version (since = "2.36")]
1956         public uint get_num_processors ();
1958         [CCode (has_type_id = false)]
1959         public enum ThreadPriority {
1960                 LOW,
1961                 NORMAL,
1962                 HIGH,
1963                 URGENT
1964         }
1966         [Compact]
1967         [Version (since = "2.32")]
1968         [CCode (ref_function = "g_thread_ref", unref_function = "g_thread_unref")]
1969         public class Thread<T> {
1970                 [Version (since = "2.32")]
1971                 public Thread (string? name, owned ThreadFunc<T> func);
1972                 [Version (since = "2.32")]
1973                 [CCode (cname = "g_thread_try_new")]
1974                 public Thread.try (string? name, owned ThreadFunc<T> func) throws GLib.Error;
1975                 public static bool supported ();
1976                 [Version (deprecated_since = "2.32", replacement = "new Thread<T> ()")]
1977                 [CCode (simple_generics = true)]
1978                 public static unowned Thread<T> create<T> (owned ThreadFunc<T> func, bool joinable) throws ThreadError;
1979                 [Version (deprecated_since = "2.32", replacement = "new Thread<T> ()")]
1980                 [CCode (simple_generics = true)]
1981                 public static unowned Thread<T> create_full<T> (owned ThreadFunc<T> func, ulong stack_size, bool joinable, bool bound, ThreadPriority priority) throws ThreadError;
1982                 [CCode (simple_generics = true)]
1983                 public static unowned Thread<T> self<T> ();
1984                 [DestroysInstance]
1985                 public T join ();
1986                 [Version (deprecated_since = "2.32")]
1987                 public void set_priority (ThreadPriority priority);
1988                 public static void yield ();
1989                 public static void exit (T retval);
1990                 [Version (deprecated_since = "2.32", since = "2.10")]
1991                 public static void @foreach (Func<Thread> thread_func);
1993                 [CCode (cname = "g_usleep")]
1994                 public static void usleep (ulong microseconds);
1995         }
1997         [Version (since = "2.32")]
1998         [CCode (destroy_function = "g_mutex_clear", lvalue_access = false)]
1999         public struct Mutex {
2000                 public Mutex ();
2001                 public void @lock ();
2002                 public bool trylock ();
2003                 public void unlock ();
2004         }
2006         [Version (since = "2.44")]
2007         [CCode (destroy_function = "g_mutex_locker_free")]
2008         public struct MutexLocker {
2009                 public MutexLocker (Mutex mutex);
2010                 public void free ();
2011         }
2013         [Version (since = "2.32")]
2014         [CCode (destroy_function = "g_rec_mutex_clear")]
2015         public struct RecMutex {
2016                 public RecMutex ();
2017                 public void lock ();
2018                 public bool trylock ();
2019                 public void unlock ();
2020         }
2022         [Version (since = "2.32")]
2023         [CCode (destroy_function = "g_rw_lock_clear")]
2024         public struct RWLock {
2025                 public RWLock ();
2026                 public void writer_lock ();
2027                 public bool writer_trylock ();
2028                 public void writer_unlock ();
2029                 public void reader_lock ();
2030                 public bool reader_trylock ();
2031                 public void reader_unlock ();
2032         }
2034         [Version (deprecated_since = "2.32", replacement = "Mutex")]
2035         [CCode (destroy_function = "g_static_mutex_free", default_value = "G_STATIC_MUTEX_INIT")]
2036         public struct StaticMutex {
2037                 public StaticMutex ();
2038                 public void lock ();
2039                 public bool trylock ();
2040                 public void unlock ();
2041                 public void lock_full ();
2042         }
2044         [Version (deprecated_since = "2.32", replacement = "RecMutex")]
2045         [CCode (destroy_function = "g_static_rec_mutex_free", default_value = "G_STATIC_REC_MUTEX_INIT")]
2046         public struct StaticRecMutex {
2047                 public StaticRecMutex ();
2048                 public void lock ();
2049                 public bool trylock ();
2050                 public void unlock ();
2051                 public void lock_full ();
2052         }
2054         [Version (deprecated_since = "2.32", replacement = "RWLock")]
2055         [CCode (destroy_function = "g_static_rw_lock_free", default_value = "G_STATIC_RW_LOCK_INIT")]
2056         public struct StaticRWLock {
2057                 public StaticRWLock ();
2058                 public void reader_lock ();
2059                 public bool reader_trylock ();
2060                 public void reader_unlock ();
2061                 public void writer_lock ();
2062                 public bool writer_trylock ();
2063                 public void writer_unlock ();
2064         }
2066         [Compact]
2067         [CCode (ref_function = "", unref_function = "")]
2068         public class Private {
2069                 public Private (DestroyNotify? destroy_func = null);
2070                 public void* get ();
2071                 public void set (void* data);
2072                 public void replace (void* data);
2073         }
2075         [CCode (destroy_function = "g_static_private_free", default_value = "G_STATIC_PRIVATE_INIT")]
2076         [Version (deprecated_since = "2.32")]
2077         public struct StaticPrivate {
2078                 public StaticPrivate ();
2079                 public void* get ();
2080                 public void set (void* data, DestroyNotify? destroy_func);
2081         }
2083         [Version (since = "2.32")]
2084         [CCode (destroy_function = "g_cond_clear", lvalue_access = false)]
2085         public struct Cond {
2086                 public Cond ();
2087                 public void @signal ();
2088                 public void broadcast ();
2089                 public void wait (Mutex mutex);
2090                 [Version (deprecated_since = "2.32", replacement = "wait_until")]
2091                 public bool timed_wait (Mutex mutex, TimeVal abs_time);
2092                 [Version (since = "2.32")]
2093                 public bool wait_until (Mutex mutex, int64 end_time);
2094         }
2096         [CCode (cname = "GThreadFunc")]
2097         public delegate G OnceFunc<G> ();
2099         [Version (since = "2.4")]
2100         [CCode (default_value = "G_ONCE_INIT")]
2101         public struct Once<G> {
2102                 [CCode (cname = "g_once")]
2103                 public unowned G once (OnceFunc<G> function);
2104                 [Version (since = "2.14")]
2105                 public static bool init_enter ([CCode (ctype="volatile gsize *")] size_t *value);
2106                 [Version (since = "2.14")]
2107                 public static void init_leave ([CCode (ctype="volatile gsize *")] size_t *value, size_t set_value);
2108                 public OnceStatus status;
2109         }
2111         [CCode (cprefix = "G_ONCE_STATUS_", has_type_id = false)]
2112         public enum OnceStatus {
2113                 NOTCALLED,
2114                 PROGRESS,
2115                 READY
2116         }
2118         /* Thread Pools */
2120         [CCode (cname = "GFunc")]
2121         public delegate void ThreadPoolFunc<G> (owned G data);
2123         [Compact]
2124         [CCode (free_function = "g_thread_pool_free")]
2125         public class ThreadPool<T> {
2126                 [Version (deprecated_since = "vala-0.18", replacement = "ThreadPool.with_owned_data")]
2127                 public ThreadPool (Func<T> func, int max_threads, bool exclusive) throws ThreadError;
2128                 [CCode (cname = "g_thread_pool_new")]
2129                 public ThreadPool.with_owned_data (ThreadPoolFunc<T> func, int max_threads, bool exclusive) throws ThreadError;
2130                 [Version (deprecated_since = "vala-0.18", replacement = "add")]
2131                 public void push (T data) throws ThreadError;
2132                 [CCode (cname = "g_thread_pool_push")]
2133                 public void add (owned T data) throws ThreadError;
2134                 public void set_max_threads (int max_threads) throws ThreadError;
2135                 public int get_max_threads ();
2136                 public uint get_num_threads ();
2137                 [Version (since = "2.46")]
2138                 public bool move_to_front (T data);
2139                 public uint unprocessed ();
2140                 [CCode (cname = "g_thread_pool_free")]
2141                 void _free (bool immediate, bool wait);
2142                 [CCode (cname = "vala__g_thread_pool_free_wrapper")]
2143                 public static void free (owned ThreadPool? pool, bool immediate, bool wait) {
2144                         ThreadPool* ptr = (owned) pool;
2145                         if (ptr != null) {
2146                                 ((ThreadPool)ptr)._free (immediate, wait);
2147                         }
2148                 }
2149                 public static void set_max_unused_threads (int max_threads);
2150                 public static int get_max_unused_threads ();
2151                 public static uint get_num_unused_threads ();
2152                 public static void stop_unused_threads ();
2153                 [Version (since = "2.10")]
2154                 public void set_sort_function (CompareDataFunc<T> func);
2155                 [Version (since = "2.10")]
2156                 public static void set_max_idle_time (uint interval);
2157                 [Version (since = "2.10")]
2158                 public static uint get_max_idle_time ();
2159         }
2161         /* Asynchronous Queues */
2163         [Compact]
2164         [CCode (ref_function = "g_async_queue_ref", unref_function = "g_async_queue_unref")]
2165         public class AsyncQueue<G> {
2166                 [Version (since = "2.16")]
2167                 [CCode (cname = "g_async_queue_new_full", simple_generics = true)]
2168                 public AsyncQueue ();
2169                 public void push (owned G data);
2170                 [Version (since = "2.10")]
2171                 public void push_sorted (owned G data, CompareDataFunc<G> func);
2172                 public G pop ();
2173                 public G? try_pop ();
2174                 public G? timed_pop (ref TimeVal end_time);
2175                 public int length ();
2176                 [Version (since = "2.10")]
2177                 public void sort (CompareDataFunc<G> func);
2178                 public void @lock ();
2179                 public void unlock ();
2180                 public void ref_unlocked ();
2181                 public void unref_and_unlock ();
2182                 [Version (since = "2.46")]
2183                 public void push_front (owned G data);
2184                 [Version (since = "2.46")]
2185                 public void push_front_unlocked (owned G data);
2186                 public void push_unlocked (owned G data);
2187                 [Version (since = "2.10")]
2188                 public void push_sorted_unlocked (owned G data, CompareDataFunc<G> func);
2189                 public G pop_unlocked ();
2190                 [Version (since = "2.46")]
2191                 public bool remove (G data);
2192                 [Version (since = "2.46")]
2193                 public bool remove_unlocked (G data);
2194                 public G? try_pop_unlocked ();
2195                 public G? timed_pop_unlocked (ref TimeVal end_time);
2196                 public G? timeout_pop (uint64 timeout);
2197                 public G? timeout_pop_unlocked (uint64 timeout);
2198                 public int length_unlocked ();
2199                 public void sort_unlocked (CompareDataFunc<G> func);
2200         }
2202         /* Memory Allocation */
2204         public static void* malloc (size_t n_bytes);
2205         public static void* malloc0 (size_t n_bytes);
2206         public static void* realloc (void* mem, size_t n_bytes);
2208         public static void* try_malloc (size_t n_bytes);
2209         [Version (since = "2.8")]
2210         public static void* try_malloc0 (size_t n_bytes);
2211         public static void* try_realloc (void* mem, size_t n_bytes);
2213         public static void free (void* mem);
2215         public class MemVTable {
2216         }
2218         [CCode (cname = "glib_mem_profiler_table")]
2219         public static MemVTable mem_profiler_table;
2221         public static void mem_set_vtable (MemVTable vtable);
2222         public static void mem_profile ();
2224         [CCode (cheader_filename = "string.h")]
2225         namespace Memory {
2226                 [CCode (cname = "memcmp")]
2227                 public static int cmp (void* s1, void* s2, size_t n);
2228                 [CCode (cname = "memcpy")]
2229                 public static void* copy (void* dest, void* src, size_t n);
2230                 [CCode (cname = "memset")]
2231                 public static void* set (void* dest, int src, size_t n);
2232                 [CCode (cname = "g_memmove")]
2233                 public static void* move (void* dest, void* src, size_t n);
2234                 [CCode (cname = "g_memdup")]
2235                 public static void* dup (void* mem, uint n);
2236         }
2238         [Version (since = "2.10")]
2239         namespace Slice {
2240                 public static void* alloc (size_t block_size);
2241                 public static void* alloc0 (size_t block_size);
2242                 [Version (since = "2.14")]
2243                 public static void* copy (size_t block_size, void* mem_block);
2244                 [CCode (cname = "g_slice_free1")]
2245                 public static void free (size_t block_size, void* mem_block);
2246                 public static void free_chain_with_offset (size_t block_size, void *mem_chain, size_t next_offset);
2247                 public static int64 get_config (SliceConfig ckey);
2248                 [CCode (array_length_cname = "n_values", array_length_type = "guint")]
2249                 public static int64[] get_config_state (SliceConfig ckey, int64 address);
2250                 public static void set_config (SliceConfig ckey, int64 value);
2251         }
2253         [CCode (cprefix = "G_SLICE_CONFIG_", has_type_id = false)]
2254         public enum SliceConfig {
2255                 ALWAYS_MALLOC,
2256                 BYPASS_MAGAZINES,
2257                 WORKING_SET_MSECS,
2258                 COLOR_INCREMENT,
2259                 CHUNK_SIZES,
2260                 CONTENTION_COUNTER
2261         }
2263         /* IO Channels */
2265         [Compact]
2266         [CCode (ref_function = "g_io_channel_ref", unref_function = "g_io_channel_unref")]
2267         public class IOChannel {
2268                 [CCode (cname = "g_io_channel_unix_new")]
2269                 public IOChannel.unix_new (int fd);
2270                 public int unix_get_fd ();
2271                 [CCode (cname = "g_io_channel_win32_new_fd")]
2272                 public IOChannel.win32_new_fd (int fd);
2273                 [CCode (cname = "g_io_channel_win32_new_socket")]
2274                 public IOChannel.win32_socket (int socket);
2275                 [CCode (cname = "g_io_channel_win32_new_messages")]
2276                 public IOChannel.win32_messages (size_t hwnd);
2277                 public void init ();
2278                 public IOChannel.file (string filename, string mode) throws FileError;
2279                 public IOStatus read_chars (char[] buf, out size_t bytes_read) throws ConvertError, IOChannelError;
2280                 public IOStatus read_unichar (out unichar thechar) throws ConvertError, IOChannelError;
2281                 public IOStatus read_line (out string str_return, out size_t length, out size_t terminator_pos) throws ConvertError, IOChannelError;
2282                 public IOStatus read_line_string (StringBuilder buffer, out size_t terminator_pos) throws ConvertError, IOChannelError;
2283                 public IOStatus read_to_end (out string str_return, out size_t length) throws ConvertError, IOChannelError;
2284                 public IOStatus write_chars (char[] buf, out size_t bytes_written) throws ConvertError, IOChannelError;
2285                 public IOStatus write_unichar (unichar thechar) throws ConvertError, IOChannelError;
2286                 public IOStatus flush () throws IOChannelError;
2287                 public IOStatus seek_position (int64 offset, SeekType type) throws IOChannelError;
2288                 public IOStatus shutdown (bool flush) throws IOChannelError;
2289                 [CCode (cname = "g_io_create_watch")]
2290                 public IOSource create_watch (IOCondition condition);
2291                 [CCode (cname = "g_io_add_watch")]
2292                 public uint add_watch (IOCondition condition, IOFunc func);
2293                 [CCode (cname = "g_io_add_watch_full")]
2294                 public uint add_watch_full (int priority, IOCondition condition, owned IOFunc func);
2295                 public size_t get_buffer_size ();
2296                 public void set_buffer_size (size_t size);
2297                 public IOCondition get_buffer_condition ();
2298                 public IOFlags get_flags ();
2299                 public IOStatus set_flags (IOFlags flags) throws IOChannelError;
2300                 public unowned string get_line_term (out int length);
2301                 public void set_line_term (string line_term, int length);
2302                 public bool get_buffered ();
2303                 public void set_buffered (bool buffered);
2304                 public unowned string get_encoding ();
2305                 public IOStatus set_encoding (string? encoding) throws IOChannelError;
2306                 public bool get_close_on_unref ();
2307                 public void set_close_on_unref (bool do_close);
2308         }
2310         [Compact]
2311         [CCode (cname = "GSource")]
2312         public class IOSource : Source {
2313                 [CCode (cname = "g_io_create_watch")]
2314                 public IOSource (IOChannel channel, IOCondition condition);
2315                 [CCode (cname = "g_source_set_callback")]
2316                 public void set_callback ([CCode (type = "GSourceFunc")] owned IOFunc func);
2317         }
2319         [CCode (cprefix = "G_SEEK_", has_type_id = false)]
2320         public enum SeekType {
2321                 CUR,
2322                 SET,
2323                 END
2324         }
2326         [CCode (has_type_id = false)]
2327         public enum IOStatus {
2328                 ERROR,
2329                 NORMAL,
2330                 EOF,
2331                 AGAIN
2332         }
2334         public errordomain IOChannelError {
2335                 FBIG,
2336                 INVAL,
2337                 IO,
2338                 ISDIR,
2339                 NOSPC,
2340                 NXIO,
2341                 OVERFLOW,
2342                 PIPE,
2343                 FAILED;
2344                 public static GLib.Quark quark ();
2345         }
2347         [Flags]
2348         [CCode (cprefix = "G_IO_")]
2349         public enum IOCondition {
2350                 IN,
2351                 OUT,
2352                 PRI,
2353                 ERR,
2354                 HUP,
2355                 NVAL
2356         }
2358         public delegate bool IOFunc (IOChannel source, IOCondition condition);
2360         [CCode (cprefix = "G_IO_FLAG_", has_type_id = false)]
2361         [Flags]
2362         public enum IOFlags {
2363                 APPEND,
2364                 NONBLOCK,
2365                 IS_READABLE,
2366                 IS_WRITABLE,
2367                 IS_WRITEABLE,
2368                 IS_SEEKABLE,
2369                 MASK,
2370                 GET_MASK,
2371                 SET_MASK
2372         }
2374         /* Error Reporting */
2376         [Compact]
2377         [ErrorBase]
2378         [CCode (copy_function = "g_error_copy", free_function = "g_error_free")]
2379         public class Error {
2380                 [PrintfFormat]
2381                 public Error (Quark domain, int code, string format, ...);
2382                 public Error.literal (Quark domain, int code, string message);
2383                 [PrintfFormat]
2384                 public Error.valist (Quark domain, int code, string format, va_list args);
2385                 public Error copy ();
2386                 public bool matches (Quark domain, int code);
2387                 [CCode (cname = "g_prefix_error")]
2388                 public static void prefix (out Error? dest, string format, ...);
2389                 [CCode (cname = "g_propagate_error")]
2390                 public static void propagate (out Error? dest, owned Error src);
2391                 [CCode (cname = "g_propagate_prefixed_error")]
2392                 public static void propagate_prefixed (out Error? dest, owned Error src, string format, ...);
2393                 [CCode (cname = "g_set_error")]
2394                 public static void @set (out Error? dest, Quark domain, int code, string format, ...);
2395                 [CCode (cname = "g_set_error_literal")]
2396                 public static void set_literal (out Error? dest, Quark domain, int code, string message);
2398                 public Quark domain;
2399                 public int code;
2400                 public string message;
2401         }
2403         /* Message Output and Debugging Functions */
2405         [PrintfFormat]
2406         public static void print (string format, ...);
2407         public static void set_print_handler (PrintFunc func);
2408         [CCode (has_target = false)]
2409         public delegate void PrintFunc (string text);
2410         [PrintfFormat]
2411         public static void printerr (string format, ...);
2412         public static void set_printerr_handler (PrintFunc func);
2414         public static void return_if_fail (bool expr);
2415         [CCode (sentinel = "")]
2416         public static void return_val_if_fail (bool expr, ...);
2417         [NoReturn]
2418         public static void return_if_reached ();
2419         [NoReturn]
2420         [CCode (sentinel = "")]
2421         public static void return_val_if_reached (...);
2422         [Version (since = "2.16")]
2423         public static void warn_if_fail (bool expr);
2424         [Version (since = "2.16")]
2425         public static void warn_if_reached ();
2427         [Assert]
2428         public static void assert (bool expr);
2429         [Assert]
2430         [Version (since = "2.46")]
2431         public static void assert_cmpmem (uint8[] m1, uint8[] m2);
2432         [Assert]
2433         public static void assert_error (Error? error, Quark error_domain, int error_code);
2434         [Assert]
2435         [Version (since = "2.38")]
2436         public static void assert_false (bool expr);
2437         [Assert]
2438         [Version (since = "2.38")]
2439         public static void assert_true (bool expr);
2440         [Assert]
2441         [Version (since = "2.38")]
2442         public static void assert_null (void* expr);
2443         [Assert]
2444         public static void assert_no_error (Error? error);
2445         [Assert]
2446         [Version (since = "2.40")]
2447         public static void assert_nonnull (void* expr);
2448         [NoReturn]
2449         public static void assert_not_reached ();
2451         public static void on_error_query (string? prg_name = null);
2452         public static void on_error_stack_trace (string? prg_name = null);
2453         [CCode (cname = "G_BREAKPOINT")]
2454         public static void breakpoint ();
2456         /* Message Logging */
2458         [CCode (cprefix = "G_LOG_", has_type_id = false)]
2459         [Flags]
2460         public enum LogLevelFlags {
2461                 /* log flags */
2462                 FLAG_RECURSION,
2463                 FLAG_FATAL,
2465                 /* GLib log levels */
2466                 LEVEL_ERROR,
2467                 LEVEL_CRITICAL,
2468                 LEVEL_WARNING,
2469                 LEVEL_MESSAGE,
2470                 LEVEL_INFO,
2471                 LEVEL_DEBUG,
2473                 LEVEL_MASK
2474         }
2476         [CCode (cprefix = "G_LOG_WRITER_", has_type_id = false)]
2477         [Version (since = "2.50")]
2478         public enum LogWriterOutput {
2479                 HANDLED,
2480                 UNHANDLED
2481         }
2483         [CCode (has_type_id = false, simple_generics = true)]
2484         [Version (since = "2.50")]
2485         public struct LogField<T> {
2486                 public unowned string key;
2487                 public unowned T @value;
2488                 public ssize_t length;
2489         }
2491         public void logv (string? log_domain, LogLevelFlags log_level, string format, va_list args);
2492         [Diagnostics]
2493         [PrintfFormat]
2494         public void log (string? log_domain, LogLevelFlags log_level, string format, ...);
2496         [Version (since = "2.50")]
2497         public void log_structured (string? log_domain, LogLevelFlags log_levels, ...);
2498         [Version (since = "2.50")]
2499         public void log_structured_array (LogLevelFlags log_levels, LogField[] fields);
2501         [Version (since = "2.50")]
2502         public void log_variant (string? log_domain, LogLevelFlags log_levels, GLib.Variant fields);
2504         [Diagnostics]
2505         [PrintfFormat]
2506         public void message (string format, ...);
2507         [Diagnostics]
2508         [PrintfFormat]
2509         public void warning (string format, ...);
2510         [Diagnostics]
2511         [PrintfFormat]
2512         public void critical (string format, ...);
2513         [Diagnostics]
2514         [PrintfFormat]
2515         [NoReturn]
2516         public void error (string format, ...);
2517         [Diagnostics]
2518         [PrintfFormat]
2519         [Version (since = "2.6")]
2520         public void debug (string format, ...);
2521         [Diagnostics]
2522         [PrintfFormat]
2523         [Version (since = "2.40")]
2524         public void info (string format, ...);
2525         [CCode (cname = "G_DEBUG_HERE")]
2526         [Version (since = "2.50")]
2527         public void debug_here ();
2529         public delegate void LogFunc (string? log_domain, LogLevelFlags log_levels, string message);
2530         [Version (since = "2.50")]
2531         public delegate LogWriterOutput LogWriterFunc (LogLevelFlags log_level, LogField[] fields);
2533         namespace Log {
2534                 public static uint set_handler (string? log_domain, LogLevelFlags log_levels, LogFunc log_func);
2535                 [Version (since = "2.46")]
2536                 public static void set_handler_full (string? log_domain, LogLevelFlags log_levels, owned LogFunc log_func);
2537                 [Version (since = "2.6")]
2538                 public static void set_default_handler (LogFunc log_func);
2539                 [CCode (delegate_target = false)]
2540                 public static GLib.LogFunc default_handler;
2541                 public static LogLevelFlags set_fatal_mask (string log_domain, LogLevelFlags log_levels);
2542                 public static LogLevelFlags set_always_fatal (LogLevelFlags log_levels);
2543                 public static void remove_handler (string? log_domain, uint handler_id);
2545                 public const string FILE;
2546                 public const int LINE;
2547                 public const string METHOD;
2549                 [Version (since = "2.50")]
2550                 public static void set_writer_func (owned LogWriterFunc func);
2551                 [Version (since = "2.50")]
2552                 public static bool writer_supports_color (int output_fd);
2553                 [Version (since = "2.50")]
2554                 public static bool writer_is_journald (int output_fd);
2555                 [Version (since = "2.50")]
2556                 public static string writer_format_fields (LogLevelFlags log_levels, LogField[] fields, bool use_color);
2557                 [Version (since = "2.50")]
2558                 public static LogWriterOutput writer_journald (LogLevelFlags log_levels, LogField[] fields, void* user_data);
2559                 [Version (since = "2.50")]
2560                 public static LogWriterOutput writer_standard_streams (LogLevelFlags log_levels, LogField[] fields, void* user_data);
2561                 [Version (since = "2.50")]
2562                 public static LogWriterOutput writer_default (LogLevelFlags log_levels, LogField[] fields, void* user_data);
2563         }
2565         [CCode (has_type_id = false)]
2566         public struct DebugKey {
2567                 unowned string key;
2568                 uint value;
2569         }
2571         public uint parse_debug_string (string? debug_string, DebugKey[] keys);
2573         /* String Utility Functions */
2575         public string strdup (string str);
2576         [CCode (array_length = false, array_null_terminated = true)]
2577         public string[] strdupv ([CCode (array_length = false, array_null_terminated = true)] string[] str_array);
2579         public void strfreev (string** str_array);
2580         [Version (since = "2.6")]
2581         public uint strv_length ([CCode (array_length = false, array_null_terminated = true)] string[] str_array);
2582         [Version (since = "2.44")]
2583         public bool strv_contains ([CCode (array_length = false, array_null_terminated = true)] string[] str_array, string str);
2585         [CCode (cname = "errno", cheader_filename = "errno.h")]
2586         public int errno;
2587         public unowned string strerror (int errnum);
2589         /* Character Set Conversions */
2591         public static string convert (string str, ssize_t len, string to_codeset, string from_codeset, out size_t bytes_read = null, out size_t bytes_written = null) throws ConvertError;
2592         public static string convert_with_fallback (string str, ssize_t len, string to_codeset, string from_codeset, string? fallback = null, out size_t bytes_read = null, out size_t bytes_written = null) throws ConvertError;
2593         public static string convert_with_iconv (string str, ssize_t len, IConv converter, out size_t bytes_read = null, out size_t bytes_written = null) throws ConvertError;
2594         public static bool get_charset (out unowned string charset);
2595         public static bool get_filename_charsets ([CCode (array_length = false, array_null_terminated = true)] out unowned string[] charsets);
2597         [SimpleType]
2598         public struct IConv {
2599                 public static IConv open (string to_codeset, string from_codeset);
2600                 [CCode (cname = "g_iconv")]
2601                 public uint iconv (out string inbuf, out uint inbytes_left, out string outbuf, out uint outbytes_left);
2602                 public int close ();
2603         }
2605         namespace Filename {
2606                 public static string to_utf8 (string opsysstring, ssize_t len, out size_t bytes_read, out size_t bytes_written) throws ConvertError;
2607                 public static string from_utf8 (string utf8string, ssize_t len, out size_t bytes_read, out size_t bytes_written) throws ConvertError;
2608                 public static string from_uri (string uri, out string hostname = null) throws ConvertError;
2609                 public static string to_uri (string filename, string? hostname = null) throws ConvertError;
2610                 [Version (since = "2.6")]
2611                 public static string display_name (string filename);
2612                 [Version (since = "2.6")]
2613                 public static string display_basename (string filename);
2614         }
2616         public errordomain ConvertError {
2617                 NO_CONVERSION,
2618                 ILLEGAL_SEQUENCE,
2619                 FAILED,
2620                 PARTIAL_INPUT,
2621                 BAD_URI,
2622                 NOT_ABSOLUTE_PATH;
2623                 public static GLib.Quark quark ();
2624         }
2626         /* Base64 Encoding */
2628         [Version (since = "2.12")]
2629         namespace Base64 {
2630                 public static size_t encode_step (uchar[] _in, bool break_lines, char* _out, ref int state, ref int save);
2631                 public static size_t encode_close (bool break_lines, char* _out, ref int state, ref int save);
2632                 public static string encode (uchar[] data);
2633                 public static size_t decode_step (char[] _in, uchar* _out, ref int state, ref uint save);
2634                 [CCode (array_length_type = "size_t")]
2635                 public static uchar[] decode (string text);
2636         }
2638         /* Data Checksums */
2640         [Version (since = "2.16")]
2641         [CCode (cprefix = "G_CHECKSUM_", has_type_id = false)]
2642         public enum ChecksumType {
2643                 MD5,
2644                 SHA1,
2645                 SHA256,
2646                 [Version (since = "2.52")]
2647                 SHA384,
2648                 [Version (since = "2.36")]
2649                 SHA512;
2651                 public ssize_t get_length ();
2652         }
2654         [Compact]
2655         [Version (since = "2.16")]
2656         [CCode (free_function = "g_checksum_free")]
2657         public class Checksum {
2658                 public Checksum (ChecksumType checksum_type);
2659                 public Checksum copy ();
2660                 public void update ([CCode (array_length = false)] uchar[] data, size_t length);
2661                 public unowned string get_string ();
2662                 public void get_digest ([CCode (array_length = false)] uint8[] buffer, ref size_t digest_len);
2663                 [CCode (cname = "g_compute_checksum_for_data")]
2664                 public static string compute_for_data (ChecksumType checksum_type, uchar[] data);
2665                 [CCode (cname = "g_compute_checksum_for_string")]
2666                 public static string compute_for_string (ChecksumType checksum_type, string str, size_t length = -1);
2667                 [Version (since = "2.34")]
2668                 [CCode (cname = "g_compute_checksum_for_bytes")]
2669                 public static string compute_for_bytes (ChecksumType checksum_type, Bytes data);
2670         }
2672         /* Secure HMAC Digests */
2674         [Compact]
2675         [Version (since = "2.30")]
2676         [CCode (ref_function = "g_hmac_ref", unref_function = "g_hmac_unref")]
2677         public class Hmac {
2678                 public Hmac (ChecksumType digest_type, [CCode (array_length_type = "gsize")] uint8[] key);
2679                 public Hmac copy ();
2680                 public void update ([CCode (array_length_type = "gssize")] uint8[] data);
2681                 public unowned string get_string ();
2682                 public void get_digest ([CCode (array_length = false)] uint8[] buffer, ref size_t digest_len);
2683                 [Version (since = "2.30")]
2684                 [CCode (cname = "g_compute_hmac_for_data")]
2685                 public static string compute_for_data (ChecksumType checksum_type, uint8[] key, uint8[] data);
2686                 [Version (since = "2.30")]
2687                 [CCode (cname = "g_compute_hmac_for_string")]
2688                 public static string compute_for_string (ChecksumType checksum_type, uint8[] key, string str, size_t length = -1);
2689                 [Version (since = "2.50")]
2690                 [CCode (cname = "g_compute_hmac_for_bytes")]
2691                 public static string compute_hmac_for_bytes (ChecksumType checksum_type, Bytes key, Bytes data);
2692         }
2694         /* Date and Time Functions */
2696         [CCode (has_type_id = false)]
2697         public struct TimeVal {
2698                 public long tv_sec;
2699                 public long tv_usec;
2701                 [CCode (cname = "g_get_current_time")]
2702                 public TimeVal ();
2703                 [CCode (cname = "g_get_current_time")]
2704                 public void get_current_time ();
2705                 public void add (long microseconds);
2706                 [Version (since = "2.12")]
2707                 [CCode (instance_pos = -1)]
2708                 public bool from_iso8601 (string iso_date);
2709                 [Version (since = "2.12")]
2710                 public string to_iso8601 ();
2711         }
2713         [Version (since = "2.28")]
2714         public static int64 get_monotonic_time ();
2715         [Version (since = "2.28")]
2716         public static int64 get_real_time ();
2718         public struct DateDay : uchar {
2719                 [CCode (cname = "G_DATE_BAD_DAY")]
2720                 public static DateDay BAD_DAY;
2722                 [CCode (cname = "g_date_valid_day")]
2723                 public bool valid ();
2724         }
2726         [CCode (cprefix = "G_DATE_", has_type_id = false)]
2727         public enum DateMonth {
2728                 BAD_MONTH,
2729                 JANUARY,
2730                 FEBRUARY,
2731                 MARCH,
2732                 APRIL,
2733                 MAY,
2734                 JUNE,
2735                 JULY,
2736                 AUGUST,
2737                 SEPTEMBER,
2738                 OCTOBER,
2739                 NOVEMBER,
2740                 DECEMBER;
2742                 [CCode (cname = "g_date_get_days_in_month")]
2743                 public uchar get_days_in_month (DateYear year);
2744                 [CCode (cname = "g_date_valid_month")]
2745                 public bool valid ();
2746         }
2748         public struct DateYear : ushort {
2749                 [CCode (cname = "G_DATE_BAD_YEAR")]
2750                 public static DateDay BAD_YEAR;
2752                 [CCode (cname = "g_date_is_leap_year")]
2753                 public bool is_leap_year ();
2754                 [CCode (cname = "g_date_get_monday_weeks_in_year")]
2755                 public uchar get_monday_weeks_in_year ();
2756                 [CCode (cname = "g_date_get_sunday_weeks_in_year")]
2757                 public uchar get_sunday_weeks_in_year ();
2758                 [CCode (cname = "g_date_valid_year")]
2759                 public bool valid ();
2760         }
2762         [CCode (cprefix = "G_DATE_", has_type_id = false)]
2763         public enum DateWeekday {
2764                 BAD_WEEKDAY,
2765                 MONDAY,
2766                 TUESDAY,
2767                 WEDNESDAY,
2768                 THURSDAY,
2769                 FRIDAY,
2770                 SATURDAY,
2771                 SUNDAY;
2773                 [CCode (cname = "g_date_valid_weekday")]
2774                 public bool valid ();
2775         }
2777         [CCode (cprefix = "G_DATE_", has_type_id = false)]
2778         public enum DateDMY {
2779                 DAY,
2780                 MONTH,
2781                 YEAR
2782         }
2784         [CCode (type_id = "G_TYPE_DATE")]
2785         public struct Date {
2786                 public void clear (uint n_dates = 1);
2787                 [Version (since = "2.56")]
2788                 public Date copy ();
2789                 public void set_day (DateDay day);
2790                 public void set_month (DateMonth month);
2791                 public void set_year (DateYear year);
2792                 public void set_dmy (DateDay day, int month, DateYear y);
2793                 public void set_julian (uint julian_day);
2794                 [Version (since = "2.10")]
2795                 public void set_time_t (time_t timet);
2796                 [Version (since = "2.10")]
2797                 public void set_time_val (TimeVal timeval);
2798                 public void set_parse (string str);
2799                 public void add_days (uint n_days);
2800                 public void subtract_days (uint n_days);
2801                 public void add_months (uint n_months);
2802                 public void subtract_months (uint n_months);
2803                 public void add_years (uint n_years);
2804                 public void subtract_years (uint n_years);
2805                 public int days_between (Date date2);
2806                 public int compare (Date rhs);
2807                 public void clamp (Date min_date, Date max_date);
2808                 public void order (Date date2);
2809                 public DateDay get_day ();
2810                 public DateMonth get_month ();
2811                 public DateYear get_year ();
2812                 public uint get_julian ();
2813                 public DateWeekday get_weekday ();
2814                 public uint get_day_of_year ();
2815                 public bool is_first_of_month ();
2816                 public bool is_last_of_month ();
2817                 public uint get_monday_week_of_year ();
2818                 public uint get_sunday_week_of_year ();
2819                 [Version (since = "2.6")]
2820                 public uint get_iso8601_week_of_year ();
2821                 [CCode (instance_pos = -1)]
2822                 public size_t strftime (char[] s, string format);
2823                 [CCode (cname = "g_date_to_struct_tm")]
2824                 public void to_time (out Time tm);
2825                 public bool valid ();
2826                 public static uchar get_days_in_month (DateMonth month, DateYear year);
2827                 public static bool valid_day (DateDay day);
2828                 public static bool valid_dmy (DateDay day, DateMonth month, DateYear year);
2829                 public static bool valid_julian (uint julian_date);
2830                 public static bool valid_weekday (DateWeekday weekday);
2831         }
2833         [CCode (cname = "struct tm", cheader_filename = "time.h", has_type_id = false)]
2834         public struct Time {
2835                 [CCode (cname = "tm_sec")]
2836                 public int second;
2837                 [CCode (cname = "tm_min")]
2838                 public int minute;
2839                 [CCode (cname = "tm_hour")]
2840                 public int hour;
2841                 [CCode (cname = "tm_mday")]
2842                 public int day;
2843                 [CCode (cname = "tm_mon")]
2844                 public int month;
2845                 [CCode (cname = "tm_year")]
2846                 public int year;
2847                 [CCode (cname = "tm_wday")]
2848                 public int weekday;
2849                 [CCode (cname = "tm_yday")]
2850                 public int day_of_year;
2851                 [CCode (cname = "tm_isdst")]
2852                 public int isdst;
2854                 [CCode (cname = "gmtime_r")]
2855                 static void gmtime_r (ref time_t time, out Time result);
2856                 [CCode (cname = "localtime_r")]
2857                 static void localtime_r (ref time_t time, out Time result);
2859                 public static Time gm (time_t time) {
2860                         Time result;
2861                         gmtime_r (ref time, out result);
2862                         return result;
2863                 }
2864                 public static Time local (time_t time) {
2865                         Time result;
2866                         localtime_r (ref time, out result);
2867                         return result;
2868                 }
2870                 public string to_string () {
2871                         return "%04d-%02d-%02d %02d:%02d:%02d".printf (year + 1900, month + 1, day, hour, minute, second);
2872                 }
2874                 public string format (string format) {
2875                         var buffer = new char[64];
2876                         this.strftime (buffer, format);
2877                         return (string) buffer;
2878                 }
2880                 [CCode (cname = "mktime")]
2881                 public time_t mktime ();
2883                 [CCode (cname = "strftime", instance_pos = -1)]
2884                 public size_t strftime (char[] s, string format);
2885                 [CCode (cname = "strptime", instance_pos = -1)]
2886                 public unowned string? strptime (string buf, string format);
2887         }
2889         [SimpleType]
2890         [Version (since = "2.26")]
2891         [CCode (cheader_filename = "glib.h", type_id = "G_TYPE_INT64", marshaller_type_name = "INT64", get_value_function = "g_value_get_int64", set_value_function = "g_value_set_int64", default_value = "0LL", type_signature = "x")]
2892         [IntegerType (rank = 10)]
2893         public struct TimeSpan : int64 {
2894                 public const TimeSpan DAY;
2895                 public const TimeSpan HOUR;
2896                 public const TimeSpan MINUTE;
2897                 public const TimeSpan SECOND;
2898                 public const TimeSpan MILLISECOND;
2899         }
2901         [Compact]
2902         [Version (since = "2.26")]
2903         [CCode (ref_function = "g_date_time_ref", unref_function = "g_date_time_unref", type_id = "G_TYPE_DATE_TIME")]
2904         public class DateTime {
2905                 public DateTime.now (TimeZone tz);
2906                 public DateTime.now_local ();
2907                 public DateTime.now_utc ();
2908                 [Version (since = "2.56")]
2909                 public DateTime.from_iso8601 (string text, TimeZone default_tz);
2910                 public DateTime.from_unix_local (int64 t);
2911                 public DateTime.from_unix_utc (int64 t);
2912                 public DateTime.from_timeval_local (TimeVal tv);
2913                 public DateTime.from_timeval_utc (TimeVal tv);
2914                 public DateTime (TimeZone tz, int year, int month, int day, int hour, int minute, double seconds);
2915                 public DateTime.local (int year, int month, int day, int hour, int minute, double seconds);
2916                 public DateTime.utc (int year, int month, int day, int hour, int minute, double seconds);
2917                 public DateTime add (TimeSpan timespan);
2918                 public DateTime add_years (int years);
2919                 public DateTime add_months (int months);
2920                 public DateTime add_weeks (int weeks);
2921                 public DateTime add_days (int days);
2922                 public DateTime add_hours (int hours);
2923                 public DateTime add_minutes (int minutes);
2924                 public DateTime add_seconds (double seconds);
2925                 public DateTime add_full (int years, int months, int days, int hours = 0, int minutes = 0, double seconds = 0);
2926                 public int compare (DateTime dt);
2927                 public TimeSpan difference (DateTime begin);
2928                 public uint hash ();
2929                 public bool equal (DateTime dt);
2930                 public void get_ymd (out int year, out int month, out int day);
2931                 public int get_year ();
2932                 public int get_month ();
2933                 public int get_day_of_month ();
2934                 public int get_week_numbering_year ();
2935                 public int get_week_of_year ();
2936                 public int get_day_of_week ();
2937                 public int get_day_of_year ();
2938                 public int get_hour ();
2939                 public int get_minute ();
2940                 public int get_second ();
2941                 public int get_microsecond ();
2942                 public double get_seconds ();
2943                 public int64 to_unix ();
2944                 public bool to_timeval (out TimeVal tv);
2945                 public TimeSpan get_utc_offset ();
2946                 public unowned string get_timezone_abbreviation ();
2947                 public bool is_daylight_savings ();
2948                 public DateTime to_timezone (TimeZone tz);
2949                 public DateTime to_local ();
2950                 public DateTime to_utc ();
2951                 public string format (string format);
2952                 public string to_string () {
2953                         return this.format ("%FT%H:%M:%S%z");
2954                 }
2955         }
2957         public enum TimeType {
2958                 STANDARD,
2959                 DAYLIGHT,
2960                 UNIVERSAL
2961         }
2963         [Compact]
2964         [Version (since = "2.26")]
2965         [CCode (ref_function = "g_time_zone_ref", unref_function = "g_time_zone_unref")]
2966         public class TimeZone {
2967                 public TimeZone (string identifier);
2968                 public TimeZone.utc ();
2969                 public TimeZone.local ();
2970                 public int find_interval (TimeType type, int64 time);
2971                 public int adjust_time (TimeType type, ref int64 time);
2972                 public unowned string get_abbreviation (int interval);
2973                 public int32 get_offset (int interval);
2974                 public bool is_dst (int interval);
2975         }
2977         /* Random Numbers */
2979         [Compact]
2980         [CCode (copy_function = "g_rand_copy", free_function = "g_rand_free")]
2981         public class Rand {
2982                 public Rand.with_seed (uint32 seed);
2983                 [Version (since = "2.4")]
2984                 public Rand.with_seed_array ([CCode (array_length = false)] uint32[] seed, uint seed_length);
2985                 public Rand ();
2986                 public void set_seed (uint32 seed);
2987                 [Version (since = "2.4")]
2988                 public void set_seed_array ([CCode (array_length = false)] uint32[] seed, uint seed_length);
2989                 public bool boolean ();
2990                 [CCode (cname = "g_rand_int")]
2991                 public uint32 next_int ();
2992                 public int32 int_range (int32 begin, int32 end);
2993                 [CCode (cname = "g_rand_double")]
2994                 public double next_double ();
2995                 public double double_range (double begin, double end);
2996         }
2998         namespace Random {
2999                 public static void set_seed (uint32 seed);
3000                 public static bool boolean ();
3001                 [CCode (cname = "g_random_int")]
3002                 public static uint32 next_int ();
3003                 public static int32 int_range (int32 begin, int32 end);
3004                 [CCode (cname = "g_random_double")]
3005                 public static double next_double ();
3006                 public static double double_range (double begin, double end);
3007         }
3009         namespace Uuid {
3010                 [Version (since = "2.52")]
3011                 public static bool string_is_valid (string str);
3012                 [Version (since = "2.52")]
3013                 public static string string_random ();
3014         }
3016         /* Miscellaneous Utility Functions */
3018         namespace Environment {
3019                 [Version (since = "2.2")]
3020                 [CCode (cname = "g_get_application_name")]
3021                 public static unowned string? get_application_name ();
3022                 [Version (since = "2.2")]
3023                 [CCode (cname = "g_set_application_name")]
3024                 public static void set_application_name (string application_name);
3025                 [CCode (cname = "g_get_prgname")]
3026                 public static unowned string get_prgname ();
3027                 [CCode (cname = "g_set_prgname")]
3028                 public static void set_prgname (string application_name);
3029                 [CCode (cname = "g_getenv")]
3030                 public static unowned string? get_variable (string variable);
3031                 [Version (since = "2.4")]
3032                 [CCode (cname = "g_setenv")]
3033                 public static bool set_variable (string variable, string value, bool overwrite);
3034                 [Version (since = "2.4")]
3035                 [CCode (cname = "g_unsetenv")]
3036                 public static void unset_variable (string variable);
3037                 [Version (since = "2.8")]
3038                 [CCode (cname = "g_listenv", array_length = false, array_null_terminated = true)]
3039                 public static string[] list_variables ();
3040                 [CCode (cname = "g_get_user_name")]
3041                 public static unowned string get_user_name ();
3042                 [CCode (cname = "g_get_real_name")]
3043                 public static unowned string get_real_name ();
3044                 [Version (since = "2.6")]
3045                 [CCode (cname = "g_get_user_cache_dir")]
3046                 public static unowned string get_user_cache_dir ();
3047                 [Version (since = "2.6")]
3048                 [CCode (cname = "g_get_user_data_dir")]
3049                 public static unowned string get_user_data_dir ();
3050                 [Version (since = "2.6")]
3051                 [CCode (cname = "g_get_user_config_dir")]
3052                 public static unowned string get_user_config_dir ();
3053                 [CCode (cname = "g_get_user_runtime_dir")]
3054                 public static unowned string get_user_runtime_dir ();
3055                 [Version (since = "2.14")]
3056                 [CCode (cname = "g_get_user_special_dir")]
3057                 public static unowned string get_user_special_dir (UserDirectory directory);
3058                 [Version (since = "2.6")]
3059                 [CCode (cname = "g_get_system_data_dirs", array_length = false, array_null_terminated = true)]
3060                 public static unowned string[] get_system_data_dirs ();
3061                 [Version (since = "2.6")]
3062                 [CCode (cname = "g_get_system_config_dirs", array_length = false, array_null_terminated = true)]
3063                 public static unowned string[] get_system_config_dirs ();
3064                 [Version (since = "2.8")]
3065                 [CCode (cname = "g_get_host_name")]
3066                 public static unowned string get_host_name ();
3067                 [CCode (cname = "g_get_home_dir")]
3068                 public static unowned string get_home_dir ();
3069                 [CCode (cname = "g_get_tmp_dir")]
3070                 public static unowned string get_tmp_dir ();
3071                 [CCode (cname = "g_get_current_dir")]
3072                 public static string get_current_dir ();
3073                 [CCode (cname = "g_find_program_in_path")]
3074                 public static string? find_program_in_path (string program);
3075                 [Version (deprecated_since = "2.32")]
3076                 [CCode (cname = "g_atexit")]
3077                 public static void atexit (VoidFunc func);
3078                 [Version (since = "2.8")]
3079                 [CCode (cname = "g_chdir")]
3080                 public static int set_current_dir (string path);
3081         }
3083         namespace Environ {
3084                 [Version (since = "2.28")]
3085                 [CCode (cname = "g_get_environ", array_length = false, array_null_terminated = true)]
3086                 public static string[] get ();
3087                 [Version (since = "2.32")]
3088                 [CCode (cname = "g_environ_getenv")]
3089                 public static unowned string? get_variable ([CCode (array_length = false, array_null_terminated = true)] string[]? envp, string variable);
3090                 [Version (since = "2.32")]
3091                 [CCode (cname = "g_environ_setenv", array_length = false, array_null_terminated = true)]
3092                 public static string[] set_variable ([CCode (array_length = false, array_null_terminated = true)] owned string[]? envp, string variable, string value, bool overwrite = true);
3093                 [Version (since = "2.32")]
3094                 [CCode (cname = "g_environ_unsetenv", array_length = false, array_null_terminated = true)]
3095                 public static string[] unset_variable ([CCode (array_length = false, array_null_terminated = true)] owned string[]? envp, string variable);
3096         }
3098         [Version (since = "2.14")]
3099         [CCode (has_type_id = false)]
3100         public enum UserDirectory {
3101                 DESKTOP,
3102                 DOCUMENTS,
3103                 DOWNLOAD,
3104                 MUSIC,
3105                 PICTURES,
3106                 PUBLIC_SHARE,
3107                 TEMPLATES,
3108                 VIDEOS,
3109                 [CCode (cname = "G_USER_N_DIRECTORIES")]
3110                 N_DIRECTORIES
3111         }
3113         namespace Hostname {
3114                 public static bool is_non_ascii (string hostname);
3115                 public static bool is_ascii_encoded (string hostname);
3116                 public static bool is_ip_address (string hostname);
3117                 public static string to_ascii (string hostname);
3118                 public static string to_unicode (string hostname);
3119         }
3121         namespace Path {
3122                 public static bool is_absolute (string file_name);
3123                 public static unowned string skip_root (string file_name);
3124                 public static string get_basename (string file_name);
3125                 public static string get_dirname (string file_name);
3126                 [CCode (cname = "g_build_filename")]
3127                 public static string build_filename (string first_element, ...);
3128                 [Version (since = "2.56")]
3129                 [CCode (cname = "g_build_filename_valist")]
3130                 public static string build_filename_valist (string first_element, va_list args);
3131                 [CCode (cname = "g_build_path")]
3132                 public static string build_path (string separator, string first_element, ...);
3134                 [CCode (cname = "G_DIR_SEPARATOR")]
3135                 public const char DIR_SEPARATOR;
3136                 [CCode (cname = "G_DIR_SEPARATOR_S")]
3137                 public const string DIR_SEPARATOR_S;
3138                 [Version (since = "2.6")]
3139                 [CCode (cname = "G_IS_DIR_SEPARATOR")]
3140                 public static bool is_dir_separator (unichar c);
3141                 [CCode (cname = "G_SEARCHPATH_SEPARATOR")]
3142                 public const char SEARCHPATH_SEPARATOR;
3143                 [CCode (cname = "G_SEARCHPATH_SEPARATOR_S")]
3144                 public const string SEARCHPATH_SEPARATOR_S;
3145         }
3147         namespace Bit {
3148                 public static int nth_lsf (ulong mask, int nth_bit);
3149                 public static int nth_msf (ulong mask, int nth_bit);
3150                 public static uint storage (ulong number);
3151         }
3153         namespace SpacedPrimes {
3154                 public static uint closest (uint num);
3155         }
3157         [CCode (has_target = false)]
3158         public delegate void FreeFunc (void* data);
3159         [CCode (has_target = false)]
3160         public delegate void VoidFunc ();
3162         [Version (deprecated_since = "2.30", replacement = "format_size", since = "2.16")]
3163         public string format_size_for_display (int64 size);
3165         [Version (since = "2.30")]
3166         [CCode (cname = "g_format_size_full")]
3167         public string format_size (uint64 size, FormatSizeFlags flags = FormatSizeFlags.DEFAULT);
3169         [Version (since = "2.30")]
3170         [CCode (cprefix = "G_FORMAT_SIZE_", has_type_id = false)]
3171         [Flags]
3172         public enum FormatSizeFlags {
3173                 DEFAULT,
3174                 LONG_FORMAT,
3175                 IEC_UNITS
3176         }
3178         /* Lexical Scanner */
3179         [CCode (has_target = false)]
3180         public delegate void ScannerMsgFunc (Scanner scanner, string message, bool error);
3182         [Compact]
3183         [CCode (free_function = "g_scanner_destroy")]
3184         public class Scanner {
3185                 public unowned string input_name;
3186                 public TokenType token;
3187                 public TokenValue value;
3188                 public uint line;
3189                 public uint position;
3190                 public TokenType next_token;
3191                 public TokenValue next_value;
3192                 public uint next_line;
3193                 public uint next_position;
3194                 public ScannerMsgFunc msg_handler;
3195                 public ScannerConfig? config;
3196                 public Scanner (ScannerConfig? config_templ);
3197                 public void input_file (int input_fd);
3198                 public void sync_file_offset ();
3199                 public void input_text (string text, uint text_len);
3200                 public TokenType peek_next_token ();
3201                 public TokenType get_next_token ();
3202                 public bool eof ();
3203                 public int cur_line ();
3204                 public int cur_position ();
3205                 public TokenType cur_token ();
3206                 public TokenValue cur_value ();
3207                 public uint set_scope (uint scope_id);
3208                 public void scope_add_symbol (uint scope_id, string symbol, void* value);
3209                 public void scope_foreach_symbol (uint scope_id, HFunc<string, void*> func);
3210                 public void* scope_lookup_symbol (uint scope_id, string symbol);
3211                 public void scope_remove_symbol (uint scope_id, string symbol);
3212                 public void* lookup_symbol (string symbol);
3213                 [PrintfFormat]
3214                 public void warn (string format, ...);
3215                 [PrintfFormat]
3216                 public void error (string format, ...);
3217                 public void unexp_token (TokenType expected_token, string? identifier_spec, string? symbol_spec, string? symbol_name, string? message, bool is_error);
3218         }
3220         public struct ScannerConfig {
3221                 public string* cset_skip_characters;
3222                 public string* cset_identifier_first;
3223                 public string* cset_identifier_nth;
3224                 public string* cpair_comment_single;
3225                 public bool case_sensitive;
3226                 public bool skip_comment_multi;
3227                 public bool skip_comment_single;
3228                 public bool scan_comment_multi;
3229                 public bool scan_identifier;
3230                 public bool scan_identifier_1char;
3231                 public bool scan_identifier_NULL;
3232                 public bool scan_symbols;
3233                 public bool scan_binary;
3234                 public bool scan_octal;
3235                 public bool scan_float;
3236                 public bool scan_hex;
3237                 public bool scan_hex_dollar;
3238                 public bool scan_string_sq;
3239                 public bool scan_string_dq;
3240                 public bool numbers_2_int;
3241                 public bool int_2_float;
3242                 public bool identifier_2_string;
3243                 public bool char_2_token;
3244                 public bool symbol_2_token;
3245                 public bool scope_0_fallback;
3246                 public bool store_int64;
3247         }
3249         [CCode (lower_case_cprefix="G_CSET_")]
3250         namespace CharacterSet {
3251                 public const string A_2_Z;
3252                 public const string a_2_z;
3253                 public const string DIGITS;
3254                 public const string LATINC;
3255                 public const string LATINS;
3256         }
3258         [CCode (cprefix = "G_TOKEN_", has_type_id = false)]
3259         public enum TokenType {
3260                 EOF,
3261                 LEFT_PAREN,
3262                 RIGHT_PAREN,
3263                 LEFT_CURLY,
3264                 RIGHT_CURLY,
3265                 LEFT_BRACE,
3266                 RIGHT_BRACE,
3267                 EQUAL_SIGN,
3268                 COMMA,
3269                 NONE,
3270                 ERROR,
3271                 CHAR,
3272                 BINARY,
3273                 OCTAL,
3274                 INT,
3275                 HEX,
3276                 FLOAT,
3277                 STRING,
3278                 SYMBOL,
3279                 IDENTIFIER,
3280                 IDENTIFIER_NULL,
3281                 COMMENT_SINGLE,
3282                 COMMENT_MULTI,
3283                 LAST
3284         }
3286         [SimpleType]
3287         public struct TokenValue {
3288                 [CCode (cname="v_symbol")]
3289                 public void* symbol;
3290                 [CCode (cname="v_identifier")]
3291                 public unowned string identifier;
3292                 [CCode (cname="v_binary")]
3293                 public ulong binary;
3294                 [CCode (cname="v_octal")]
3295                 public ulong octal;
3296                 [CCode (cname="v_int")]
3297                 public ulong int;
3298                 [CCode (cname="v_int64")]
3299                 public ulong int64;
3300                 [CCode (cname="v_float")]
3301                 public double float;
3302                 [CCode (cname="v_hex")]
3303                 public ulong hex;
3304                 [CCode (cname="v_string")]
3305                 public unowned string string;
3306                 [CCode (cname="v_comment")]
3307                 public unowned string comment;
3308                 [CCode (cname="v_char")]
3309                 public uchar char;
3310                 [CCode (cname="v_error")]
3311                 public uint error;
3312         }
3314         [CCode (cprefix = "G_ERR_", has_type_id = false)]
3315         public enum ErrorType {
3316                 UNKNOWN,
3317                 UNEXP_EOF,
3318                 UNEXP_EOF_IN_STRING,
3319                 UNEXP_EOF_IN_COMMENT,
3320                 NON_DIGIT_IN_CONST,
3321                 DIGIT_RADIX,
3322                 FLOAT_RADIX,
3323                 FLOAT_MALFORMED
3324         }
3326         /* Automatic String Completion */
3328         [Version (deprecated_since = "2.26")]
3329         [Compact]
3330         [CCode (free_function = "g_completion_free")]
3331         public class Completion {
3332                 public Completion (CompletionFunc? func = null);
3333                 public List<void*> items;
3334                 public CompletionFunc func;
3335                 public string prefix;
3336                 public List<void*> cache;
3337                 public CompletionStrncmpFunc strncmp_func;
3338                 public void add_items (List<void*> items);
3339                 public void remove_items (List<void*> items);
3340                 public void clear_items ();
3341                 public unowned List<void*> complete (string prefix, out string? new_prefix = null);
3342                 [Version (since = "2.4")]
3343                 public unowned List<void*> complete_utf8 (string prefix, out string? new_prefix = null);
3344         }
3346         [CCode (has_target = false)]
3347         public delegate string CompletionFunc (void* item);
3348         [CCode (has_target = false)]
3349         public delegate int CompletionStrncmpFunc (string s1, string s2, size_t n);
3351         /* Timers */
3353         [Compact]
3354         [CCode (free_function = "g_timer_destroy")]
3355         public class Timer {
3356                 public Timer ();
3357                 public void start ();
3358                 public void stop ();
3359                 [Version (since = "2.4")]
3360                 public void @continue ();
3361                 public double elapsed (out ulong microseconds = null);
3362                 public void reset ();
3363         }
3365         /* Spawning Processes */
3367         public errordomain SpawnError {
3368                 FORK,
3369                 READ,
3370                 CHDIR,
3371                 ACCES,
3372                 PERM,
3373                 TOO_BIG,
3374                 NOEXEC,
3375                 NAMETOOLONG,
3376                 NOENT,
3377                 NOMEM,
3378                 NOTDIR,
3379                 LOOP,
3380                 TXTBUSY,
3381                 IO,
3382                 NFILE,
3383                 MFILE,
3384                 INVAL,
3385                 ISDIR,
3386                 LIBBAD,
3387                 FAILED;
3388                 public static GLib.Quark quark ();
3389         }
3391         [CCode (cprefix = "G_SPAWN_", has_type_id = false)]
3392         [Flags]
3393         public enum SpawnFlags {
3394                 LEAVE_DESCRIPTORS_OPEN,
3395                 DO_NOT_REAP_CHILD,
3396                 SEARCH_PATH,
3397                 STDOUT_TO_DEV_NULL,
3398                 STDERR_TO_DEV_NULL,
3399                 CHILD_INHERITS_STDIN,
3400                 FILE_AND_ARGV_ZERO,
3401                 SEARCH_PATH_FROM_ENVP
3402         }
3404         public delegate void SpawnChildSetupFunc ();
3405         [CCode (has_target = false, cheader_filename = "signal.h")]
3406         public delegate void SignalHandlerFunc (int signum);
3408         public unowned string strsignal (int signum);
3410         [CCode (lower_case_cprefix = "g_")]
3411         namespace Process {
3412                 public static bool spawn_async_with_pipes (string? working_directory, [CCode (array_length = false, array_null_terminated = true)] string[] argv, [CCode (array_length = false, array_null_terminated = true)] string[]? envp, SpawnFlags _flags, SpawnChildSetupFunc? child_setup, out Pid child_pid, out int standard_input = null, out int standard_output = null, out int standard_error = null) throws SpawnError;
3413                 public static bool spawn_async (string? working_directory, [CCode (array_length = false, array_null_terminated = true)] string[] argv, [CCode (array_length = false, array_null_terminated = true)] string[]? envp, SpawnFlags _flags, SpawnChildSetupFunc? child_setup, out Pid child_pid) throws SpawnError;
3414                 public static bool spawn_sync (string? working_directory, [CCode (array_length = false, array_null_terminated = true)] string[] argv, [CCode (array_length = false, array_null_terminated = true)] string[]? envp, SpawnFlags _flags, SpawnChildSetupFunc? child_setup, out string standard_output = null, out string standard_error = null, out int exit_status = null) throws SpawnError;
3415                 public static bool spawn_command_line_async (string command_line) throws SpawnError;
3416                 public static bool spawn_command_line_sync (string command_line, out string standard_output = null, out string standard_error = null, out int exit_status = null) throws SpawnError;
3417                 [CCode (cname = "g_spawn_close_pid")]
3418                 public static void close_pid (Pid pid);
3419                 [Version (since = "2.34")]
3420                 [CCode (cname = "g_spawn_check_exit_status")]
3421                 public static bool check_exit_status (int exit_status) throws GLib.Error;
3423                 /* these macros are required to examine the exit status of a process */
3424                 [CCode (cname = "WIFEXITED", cheader_filename = "sys/wait.h")]
3425                 public static bool if_exited (int status);
3426                 [CCode (cname = "WEXITSTATUS", cheader_filename = "sys/wait.h")]
3427                 public static int exit_status (int status);
3428                 [CCode (cname = "WIFSIGNALED", cheader_filename = "sys/wait.h")]
3429                 public static bool if_signaled (int status);
3430                 [CCode (cname = "WTERMSIG", cheader_filename = "sys/wait.h")]
3431                 public static ProcessSignal term_sig (int status);
3432                 [CCode (cname = "WCOREDUMP", cheader_filename = "sys/wait.h")]
3433                 public static bool core_dump (int status);
3434                 [CCode (cname = "WIFSTOPPED", cheader_filename = "sys/wait.h")]
3435                 public static bool if_stopped (int status);
3436                 [CCode (cname = "WSTOPSIG", cheader_filename = "sys/wait.h")]
3437                 public static ProcessSignal stop_sig (int status);
3438                 [CCode (cname = "WIFCONTINUED", cheader_filename = "sys/wait.h")]
3439                 public static bool if_continued (int status);
3441                 [NoReturn]
3442                 [CCode (cname = "abort", cheader_filename = "stdlib.h")]
3443                 public void abort ();
3444                 [NoReturn]
3445                 [CCode (cname = "exit", cheader_filename = "stdlib.h")]
3446                 public void exit (int status);
3447                 [CCode (cname = "raise", cheader_filename = "signal.h")]
3448                 public int raise (ProcessSignal sig);
3449                 [CCode (cname = "signal", cheader_filename = "signal.h")]
3450                 public SignalHandlerFunc @signal (ProcessSignal signum, SignalHandlerFunc handler);
3451         }
3453         [CCode (cname = "int", has_type_id = false, cheader_filename = "signal.h", cprefix = "SIG")]
3454         public enum ProcessSignal {
3455                 HUP,
3456                 INT,
3457                 QUIT,
3458                 ILL,
3459                 TRAP,
3460                 ABRT,
3461                 BUS,
3462                 FPE,
3463                 KILL,
3464                 SEGV,
3465                 PIPE,
3466                 ALRM,
3467                 TERM,
3468                 USR1,
3469                 USR2,
3470                 CHLD,
3471                 CONT,
3472                 STOP,
3473                 TSTP,
3474                 TTIN,
3475                 TTOU
3476         }
3479         /* File Utilities */
3481         public errordomain FileError {
3482                 EXIST,
3483                 ISDIR,
3484                 ACCES,
3485                 NAMETOOLONG,
3486                 NOENT,
3487                 NOTDIR,
3488                 NXIO,
3489                 NODEV,
3490                 ROFS,
3491                 TXTBSY,
3492                 FAULT,
3493                 LOOP,
3494                 NOSPC,
3495                 NOMEM,
3496                 MFILE,
3497                 NFILE,
3498                 BADF,
3499                 INVAL,
3500                 PIPE,
3501                 AGAIN,
3502                 INTR,
3503                 IO,
3504                 PERM,
3505                 NOSYS,
3506                 FAILED;
3507                 public static GLib.Quark quark ();
3508         }
3510         [CCode (has_type_id = false)]
3511         [Flags]
3512         public enum FileTest {
3513                 IS_REGULAR,
3514                 IS_SYMLINK,
3515                 IS_DIR,
3516                 IS_EXECUTABLE,
3517                 EXISTS
3518         }
3520         [CCode (cname = "int", cprefix = "SEEK_", has_type_id = false)]
3521         public enum FileSeek {
3522                 SET,
3523                 CUR,
3524                 END
3525         }
3527         [Compact]
3528         [CCode (cname = "FILE", free_function = "fclose", cheader_filename = "stdio.h")]
3529         public class FileStream {
3530                 [CCode (cname = "EOF", cheader_filename = "stdio.h")]
3531                 public const int EOF;
3533                 [Version (since = "2.6")]
3534                 [CCode (cname = "g_fopen", cheader_filename = "glib/gstdio.h")]
3535                 public static FileStream? open (string path, string mode);
3536                 [CCode (cname = "fdopen")]
3537                 public static FileStream? fdopen (int fildes, string mode);
3538                 [CCode (cname = "fprintf")]
3539                 [PrintfFormat ()]
3540                 public void printf (string format, ...);
3541                 [CCode (cname = "vfprintf")]
3542                 public void vprintf (string format, va_list args);
3543                 [CCode (cname = "fputc", instance_pos = -1)]
3544                 public void putc (char c);
3545                 [CCode (cname = "fputs", instance_pos = -1)]
3546                 public void puts (string s);
3547                 [CCode (cname = "fgetc")]
3548                 public int getc ();
3549                 [CCode (cname = "ungetc", instance_pos = -1)]
3550                 public int ungetc (int c);
3551                 [CCode (cname = "fgets", instance_pos = -1)]
3552                 public unowned string? gets (char[] s);
3553                 [CCode (cname = "feof")]
3554                 public bool eof ();
3555                 [CCode (cname = "fscanf"), ScanfFormat]
3556                 public int scanf (string format, ...);
3557                 [CCode (cname = "fflush")]
3558                 public int flush ();
3559                 [CCode (cname = "fseek")]
3560                 public int seek (long offset, FileSeek whence);
3561                 [CCode (cname = "ftell")]
3562                 public long tell ();
3563                 [CCode (cname = "rewind")]
3564                 public void rewind ();
3565                 [CCode (cname = "fileno")]
3566                 public int fileno ();
3567                 [CCode (cname = "ferror")]
3568                 public int error ();
3569                 [CCode (cname = "clearerr")]
3570                 public void clearerr ();
3571                 [CCode (cname = "fread", instance_pos = -1)]
3572                 public size_t read ([CCode (array_length_pos = 2.1)] uint8[] buf, size_t size = 1);
3573                 [CCode (cname = "fwrite", instance_pos = -1)]
3574                 public size_t write ([CCode (array_length_pos = 2.1)] uint8[] buf, size_t size = 1);
3576                 public string? read_line () {
3577                         int c;
3578                         StringBuilder? ret = null;
3579                         while ((c = getc ()) != EOF) {
3580                                 if (ret == null) {
3581                                         ret = new StringBuilder ();
3582                                 }
3583                                 if (c == '\n') {
3584                                         break;
3585                                 }
3586                                 ((!)(ret)).append_c ((char) c);
3587                         }
3588                         if (ret == null) {
3589                                 return null;
3590                         } else {
3591                                 return ((!)(ret)).str;
3592                         }
3593                 }
3594         }
3596         [CCode (cname = "struct utimbuf", cheader_filename = "sys/types.h,utime.h")]
3597         public struct UTimBuf {
3598                 time_t actime;       /* access time */
3599                 time_t modtime;      /* modification time */
3600         }
3602         [CCode (lower_case_cprefix = "g_file_", cheader_filename = "glib/gstdio.h")]
3603         namespace FileUtils {
3604                 public static bool get_contents (string filename, out string contents, out size_t length = null) throws FileError;
3605                 [Version (since = "2.8")]
3606                 public static bool set_contents (string filename, string contents, ssize_t length = -1) throws FileError;
3607                 [CCode (cname = "g_file_get_contents")]
3608                 public static bool get_data (string filename, [CCode (type = "gchar**", array_length_type = "size_t")] out uint8[] contents) throws FileError;
3609                 [CCode (cname = "g_file_set_contents")]
3610                 public static bool set_data (string filename, [CCode (type = "const char*", array_length_type = "size_t")] uint8[] contents) throws FileError;
3611                 public static bool test (string filename, FileTest test);
3612                 public static int open_tmp (string tmpl, out string name_used) throws FileError;
3613                 [Version (since = "2.4")]
3614                 public static string read_link (string filename) throws FileError;
3615                 public static int error_from_errno (int err_no);
3617                 [CCode (cname = "g_mkstemp")]
3618                 public static int mkstemp (string tmpl);
3619                 [Version (since = "2.6")]
3620                 [CCode (cname = "g_rename")]
3621                 public static int rename (string oldfilename, string newfilename);
3622                 [Version (since = "2.6")]
3623                 [CCode (cname = "g_remove")]
3624                 public static int remove (string filename);
3625                 [CCode (cname = "g_unlink")]
3626                 public static int unlink (string filename);
3627                 [Version (since = "2.8")]
3628                 [CCode (cname = "g_chmod")]
3629                 public static int chmod (string filename, int mode);
3630                 [Version (since = "2.18")]
3631                 [CCode (cname = "g_utime")]
3632                 public static int utime (string filename, UTimBuf? times = null);
3634                 [CCode (cname = "symlink", cheader_filename = "unistd.h")]
3635                 public static int symlink (string oldpath, string newpath);
3637                 [CCode (cname = "close", cheader_filename = "unistd.h")]
3638                 public static int close (int fd);
3640                 [Version (since = "2.36")]
3641                 [CCode (cname = "g_close")]
3642                 public static bool close_checked (int fd) throws FileError;
3643         }
3645         [CCode (cname = "struct stat", cheader_filename = "sys/stat.h,glib/gstdio.h")]
3646         public struct Stat {
3647                 public time_t st_atime;
3648                 public time_t st_mtime;
3649                 public time_t st_ctime;
3650                 [CCode (cname = "g_stat", instance_pos = -1)]
3651                 public Stat (string filename);
3652                 [Version (since = "2.6")]
3653                 [CCode (cname = "g_lstat", instance_pos = -1)]
3654                 public Stat.l (string filename);
3655         }
3657         [Compact]
3658         [CCode (free_function = "g_dir_close")]
3659         public class Dir {
3660                 public static Dir open (string filename, uint _flags = 0) throws FileError;
3661                 public unowned string? read_name ();
3662                 public void rewind ();
3663         }
3665         [CCode (cheader_filename = "glib/gstdio.h")]
3666         namespace DirUtils {
3667                 [Version (since = "2.6")]
3668                 [CCode (cname = "g_mkdir")]
3669                 public static int create (string pathname, int mode);
3670                 [Version (since = "2.8")]
3671                 [CCode (cname = "g_mkdir_with_parents")]
3672                 public static int create_with_parents (string pathname, int mode);
3673                 [Version (since = "2.30")]
3674                 [CCode (cname = "mkdtemp")]
3675                 public static string mkdtemp (owned string template);
3676                 [Version (since = "2.30")]
3677                 [CCode (cname = "g_dir_make_tmp")]
3678                 public static string make_tmp (string tmpl) throws FileError;
3679                 [Version (since = "2.6")]
3680                 [CCode (cname = "g_rmdir")]
3681                 public static int remove (string filename);
3682         }
3684         [Compact]
3685         [Version (since = "2.22")]
3686         [CCode (ref_function = "g_mapped_file_ref", unref_function = "g_mapped_file_unref")]
3687         public class MappedFile {
3688                 public MappedFile (string filename, bool writable) throws FileError;
3689                 public size_t get_length ();
3690                 public unowned char* get_contents ();
3691                 [Version (since = "2.34")]
3692                 public Bytes get_bytes ();
3693         }
3695         [CCode (cname = "stdin", cheader_filename = "stdio.h")]
3696         public static FileStream stdin;
3698         [CCode (cname = "stdout", cheader_filename = "stdio.h")]
3699         public static FileStream stdout;
3701         [CCode (cname = "stderr", cheader_filename = "stdio.h")]
3702         public static FileStream stderr;
3704         /* URI Functions */
3706         namespace Uri {
3707                 public const string RESERVED_CHARS_ALLOWED_IN_PATH;
3708                 public const string RESERVED_CHARS_ALLOWED_IN_PATH_ELEMENT;
3709                 public const string RESERVED_CHARS_ALLOWED_IN_USERINFO;
3710                 public const string RESERVED_CHARS_GENERIC_DELIMITERS;
3711                 public const string RESERVED_CHARS_SUBCOMPONENT_DELIMITERS;
3713                 [Version (since = "2.16")]
3714                 public static string? parse_scheme (string uri);
3715                 [Version (since = "2.16")]
3716                 public static string escape_string (string unescaped, string? reserved_chars_allowed = null, bool allow_utf8 = true);
3717                 [Version (since = "2.16")]
3718                 public static string? unescape_string (string escaped_string, string? illegal_characters = null);
3719                 [Version (since = "2.16")]
3720                 public static string? unescape_segment (string? escaped_string, string? escaped_string_end, string? illegal_characters = null);
3721                 [Version (since = "2.6")]
3722                 [CCode (array_length = false, array_null_terminated = true)]
3723                 public static string[] list_extract_uris (string uri_list);
3724         }
3726         /* Shell-related Utilities */
3728         public errordomain ShellError {
3729                 BAD_QUOTING,
3730                 EMPTY_STRING,
3731                 FAILED;
3732                 public static GLib.Quark quark ();
3733         }
3735         namespace Shell {
3736                 public static bool parse_argv (string command_line, [CCode (array_length_pos = 1.9)] out string[] argvp) throws ShellError;
3737                 public static string quote (string unquoted_string);
3738                 public static string unquote (string quoted_string) throws ShellError;
3739         }
3741         /* Commandline option parser */
3743         public errordomain OptionError {
3744                 UNKNOWN_OPTION,
3745                 BAD_VALUE,
3746                 FAILED;
3747                 public static GLib.Quark quark ();
3748         }
3750         [Compact]
3751         [Version (since = "2.6")]
3752         [CCode (free_function = "g_option_context_free")]
3753         public class OptionContext {
3754                 public OptionContext (string? parameter_string = null);
3755                 [Version (since = "2.12")]
3756                 public void set_summary (string summary);
3757                 [Version (since = "2.12")]
3758                 public unowned string get_summary ();
3759                 [Version (since = "2.12")]
3760                 public void set_description (string description);
3761                 [Version (since = "2.12")]
3762                 public unowned string get_description ();
3763                 [Version (since = "2.12")]
3764                 public void set_translate_func (TranslateFunc func, DestroyNotify? destroy_notify);
3765                 [Version (since = "2.12")]
3766                 public void set_translation_domain (string domain);
3767                 public bool parse ([CCode (array_length_pos = 0.9)] ref unowned string[] argv) throws OptionError;
3768                 [Version (since = "2.40")]
3769                 public bool parse_strv ([CCode (array_length = false, array_null_terminated = true)] ref string[] argv) throws OptionError;
3770                 public void set_help_enabled (bool help_enabled);
3771                 public bool get_help_enabled ();
3772                 public void set_ignore_unknown_options (bool ignore_unknown);
3773                 public bool get_ignore_unknown_options ();
3774                 [Version (since = "2.14")]
3775                 public string get_help (bool main_help, OptionGroup? group);
3776                 public void add_main_entries ([CCode (array_length = false, array_null_terminated = true)] OptionEntry[] entries, string? translation_domain);
3777                 public void add_group (owned OptionGroup group);
3778                 public void set_main_group (owned OptionGroup group);
3779                 public unowned OptionGroup get_main_group ();
3780                 [Version (since = "2.44")]
3781                 public void set_strict_posix (bool strict_posix);
3782                 [Version (since = "2.44")]
3783                 public bool get_strict_posix ();
3784         }
3786         public delegate unowned string TranslateFunc (string str);
3788         public const string OPTION_REMAINING;
3790         [CCode (has_type_id = false)]
3791         public enum OptionArg {
3792                 NONE,
3793                 STRING,
3794                 INT,
3795                 CALLBACK,
3796                 FILENAME,
3797                 STRING_ARRAY,
3798                 FILENAME_ARRAY,
3799                 DOUBLE,
3800                 INT64
3801         }
3803         [Flags]
3804         [CCode (cprefix = "G_OPTION_FLAG_", has_type_id = false)]
3805         public enum OptionFlags {
3806                 [Version (since = "2.42")]
3807                 NONE,
3808                 HIDDEN,
3809                 IN_MAIN,
3810                 REVERSE,
3811                 NO_ARG,
3812                 FILENAME,
3813                 OPTIONAL_ARG,
3814                 NOALIAS
3815         }
3817         public struct OptionEntry {
3818                 public unowned string long_name;
3819                 public char short_name;
3820                 public int flags;
3822                 public OptionArg arg;
3823                 public void* arg_data;
3825                 public unowned string description;
3826                 public unowned string? arg_description;
3827         }
3829         [Compact]
3830 #if GLIB_2_44
3831         [Version (since = "2.44")]
3832         [CCode (ref_function = "g_option_group_ref", unref_function = "g_option_group_unref", type_id = "G_TYPE_OPTION_GROUP")]
3833 #else
3834         [Version (since = "2.6")]
3835         [CCode (free_function = "g_option_group_free")]
3836 #endif
3837         public class OptionGroup {
3838                 public OptionGroup (string name, string description, string help_description, void* user_data = null, DestroyNotify? destroy = null);
3839                 public void add_entries ([CCode (array_length = false, array_null_terminated = true)] OptionEntry[] entries);
3840                 public void set_parse_hooks (OptionParseFunc? pre_parse_func, OptionParseFunc? post_parse_hook);
3841                 public void set_error_hook (OptionErrorFunc? error_func);
3842                 public void set_translate_func (owned TranslateFunc? func);
3843                 public void set_translation_domain (string domain);
3844         }
3846         [CCode (has_target = false)]
3847         public delegate bool OptionParseFunc (OptionContext context, OptionGroup group, void* data) throws OptionError;
3848         [CCode (has_target = false)]
3849         public delegate void OptionErrorFunc (OptionContext context, OptionGroup group, void* data, ref Error error);
3850         [CCode (has_target = false)]
3851         public delegate bool OptionArgFunc (string option_name, string val, void* data) throws OptionError;
3853         /* Perl-compatible regular expressions */
3855         [Version (since = "2.14")]
3856         public errordomain RegexError {
3857                 COMPILE,
3858                 OPTIMIZE,
3859                 REPLACE,
3860                 MATCH,
3861                 INTERNAL,
3862                 STRAY_BACKSLASH,
3863                 MISSING_CONTROL_CHAR,
3864                 UNRECOGNIZED_ESCAPE,
3865                 QUANTIFIERS_OUT_OF_ORDER,
3866                 QUANTIFIER_TOO_BIG,
3867                 UNTERMINATED_CHARACTER_CLASS,
3868                 INVALID_ESCAPE_IN_CHARACTER_CLASS,
3869                 RANGE_OUT_OF_ORDER,
3870                 NOTHING_TO_REPEAT,
3871                 UNRECOGNIZED_CHARACTER,
3872                 POSIX_NAMED_CLASS_OUTSIDE_CLASS,
3873                 UNMATCHED_PARENTHESIS,
3874                 INEXISTENT_SUBPATTERN_REFERENCE,
3875                 UNTERMINATED_COMMENT,
3876                 EXPRESSION_TOO_LARGE,
3877                 MEMORY_ERROR,
3878                 VARIABLE_LENGTH_LOOKBEHIND,
3879                 MALFORMED_CONDITION,
3880                 TOO_MANY_CONDITIONAL_BRANCHES,
3881                 ASSERTION_EXPECTED,
3882                 UNKNOWN_POSIX_CLASS_NAME,
3883                 POSIX_COLLATING_ELEMENTS_NOT_SUPPORTED,
3884                 HEX_CODE_TOO_LARGE,
3885                 INVALID_CONDITION,
3886                 SINGLE_BYTE_MATCH_IN_LOOKBEHIND,
3887                 INFINITE_LOOP,
3888                 MISSING_SUBPATTERN_NAME_TERMINATOR,
3889                 DUPLICATE_SUBPATTERN_NAME,
3890                 MALFORMED_PROPERTY,
3891                 UNKNOWN_PROPERTY,
3892                 SUBPATTERN_NAME_TOO_LONG,
3893                 TOO_MANY_SUBPATTERNS,
3894                 INVALID_OCTAL_VALUE,
3895                 TOO_MANY_BRANCHES_IN_DEFINE,
3896                 DEFINE_REPETION,
3897                 INCONSISTENT_NEWLINE_OPTIONS,
3898                 MISSING_BACK_REFERENCE,
3899                 INVALID_RELATIVE_REFERENCE,
3900                 BACKTRACKING_CONTROL_VERB_ARGUMENT_FORBIDDEN,
3901                 UNKNOWN_BACKTRACKING_CONTROL_VERB,
3902                 NUMBER_TOO_BIG,
3903                 MISSING_SUBPATTERN_NAME,
3904                 MISSING_DIGIT,
3905                 INVALID_DATA_CHARACTER,
3906                 EXTRA_SUBPATTERN_NAME,
3907                 BACKTRACKING_CONTROL_VERB_ARGUMENT_REQUIRED,
3908                 INVALID_CONTROL_CHAR,
3909                 MISSING_NAME,
3910                 NOT_SUPPORTED_IN_CLASS,
3911                 TOO_MANY_FORWARD_REFERENCES,
3912                 NAME_TOO_LONG,
3913                 CHARACTER_VALUE_TOO_LARGE;
3914                 public static GLib.Quark quark ();
3915         }
3917         [Version (since = "2.14")]
3918         [CCode (cprefix = "G_REGEX_", has_type_id = false)]
3919         [Flags]
3920         public enum RegexCompileFlags {
3921                 CASELESS,
3922                 MULTILINE,
3923                 DOTALL,
3924                 EXTENDED,
3925                 ANCHORED,
3926                 DOLLAR_ENDONLY,
3927                 UNGREEDY,
3928                 RAW,
3929                 NO_AUTO_CAPTURE,
3930                 OPTIMIZE,
3931                 DUPNAMES,
3932                 NEWLINE_CR,
3933                 NEWLINE_LF,
3934                 NEWLINE_CRLF,
3935                 NEWLINE_ANYCRLF,
3936                 BSR_ANYCRLF,
3937                 JAVASCRIPT_COMPAT
3938         }
3940         [Version (since = "2.14")]
3941         [CCode (cprefix = "G_REGEX_MATCH_", has_type_id = false)]
3942         [Flags]
3943         public enum RegexMatchFlags {
3944                 ANCHORED,
3945                 NOTBOL,
3946                 NOTEOL,
3947                 NOTEMPTY,
3948                 PARTIAL,
3949                 NEWLINE_CR,
3950                 NEWLINE_LF,
3951                 NEWLINE_CRLF,
3952                 NEWLINE_ANY,
3953                 NEWLINE_ANYCRLF,
3954                 BSR_ANYCRLF,
3955                 BSR_ANY,
3956                 PARTIAL_SOFT,
3957                 PARTIAL_HARD,
3958                 NOTEMPTY_ATSTART
3959         }
3961         [Compact]
3962         [Version (since = "2.14")]
3963         [CCode (ref_function = "g_regex_ref", unref_function = "g_regex_unref", type_id = "G_TYPE_REGEX")]
3964         public class Regex {
3965                 public Regex (string pattern, RegexCompileFlags compile_options = 0, RegexMatchFlags match_options = 0) throws RegexError;
3966                 public unowned string get_pattern ();
3967                 [Version (since = "2.26")]
3968                 public RegexCompileFlags get_compile_flags ();
3969                 [Version (since = "2.34")]
3970                 public bool get_has_cr_or_lf ();
3971                 [Version (since = "2.26")]
3972                 public RegexMatchFlags get_match_flags ();
3973                 public int get_max_backref ();
3974                 [Version (since = "2.38")]
3975                 public int get_max_lookbehind ();
3976                 public int get_capture_count ();
3977                 public int get_string_number (string name);
3978                 public static string escape_string (string str, int length = -1);
3979                 public static bool match_simple (string pattern, string str, RegexCompileFlags compile_options = 0, RegexMatchFlags match_options = 0);
3980                 public bool match (string str, RegexMatchFlags match_options = 0, out MatchInfo match_info = null);
3981                 public bool match_full (string str, ssize_t string_len = -1, int start_position = 0, RegexMatchFlags match_options = 0, out MatchInfo match_info = null) throws RegexError;
3982                 public bool match_all (string str, RegexMatchFlags match_options = 0, out MatchInfo match_info = null);
3983                 public bool match_all_full (string str, ssize_t string_len = -1, int start_position = 0, RegexMatchFlags match_options = 0, out MatchInfo match_info = null) throws RegexError;
3984                 [CCode (array_length = false, array_null_terminated = true)]
3985                 public static string[] split_simple (string pattern, string str, RegexCompileFlags compile_options = 0, RegexMatchFlags match_options = 0);
3986                 [CCode (array_length = false, array_null_terminated = true)]
3987                 public string[] split (string str, RegexMatchFlags match_options = 0);
3988                 [CCode (array_length = false, array_null_terminated = true)]
3989                 public string[] split_full (string str, ssize_t string_len = -1, int start_position = 0, RegexMatchFlags match_options = 0, int max_tokens = 0) throws RegexError;
3990                 public string replace (string str, ssize_t string_len, int start_position, string replacement, RegexMatchFlags match_options = 0) throws RegexError;
3991                 public string replace_literal (string str, ssize_t string_len, int start_position, string replacement, RegexMatchFlags match_options = 0) throws RegexError;
3992                 public string replace_eval (string str, ssize_t string_len, int start_position, RegexMatchFlags match_options, RegexEvalCallback eval) throws RegexError;
3993                 public static bool check_replacement (string replacement, out bool has_references = null) throws RegexError;
3994         }
3996         [Version (since = "2.14")]
3997         public delegate bool RegexEvalCallback (MatchInfo match_info, StringBuilder result);
3999         [Compact]
4000         [Version (since = "2.30")]
4001         [CCode (ref_function = "g_match_info_ref", unref_function = "g_match_info_unref", type_id = "G_TYPE_MATCH_INFO")]
4002         public class MatchInfo {
4003                 public unowned Regex get_regex ();
4004                 public unowned string get_string ();
4005                 public bool matches ();
4006                 public bool next () throws RegexError;
4007                 public int get_match_count ();
4008                 public bool is_partial_match ();
4009                 public string expand_references (string string_to_expand) throws RegexError;
4010                 public string? fetch (int match_num);
4011                 public bool fetch_pos (int match_num, out int start_pos, out int end_pos);
4012                 public string? fetch_named (string name);
4013                 public bool fetch_named_pos (string name, out int start_pos, out int end_pos);
4014                 [CCode (array_length = false, array_null_terminated = true)]
4015                 public string[] fetch_all ();
4016         }
4018         /* Simple XML Subset Parser
4019            See http://live.gnome.org/Vala/MarkupSample for an example */
4021         public errordomain MarkupError {
4022                 BAD_UTF8,
4023                 EMPTY,
4024                 PARSE,
4025                 UNKNOWN_ELEMENT,
4026                 UNKNOWN_ATTRIBUTE,
4027                 INVALID_CONTENT,
4028                 MISSING_ATTRIBUTE;
4029                 public static GLib.Quark quark ();
4030         }
4032         [CCode (cprefix = "G_MARKUP_", has_type_id = false)]
4033         [Flags]
4034         public enum MarkupParseFlags {
4035                 TREAT_CDATA_AS_TEXT,
4036                 PREFIX_ERROR_POSITION
4037         }
4039         [Compact]
4040         [Version (since = "2.36")]
4041         [CCode (ref_function = "g_markup_parse_context_ref", unref_function = "g_markup_parse_context_unref", type_id = "G_TYPE_MARKUP_PARSE_CONTEXT")]
4042         public class MarkupParseContext {
4043                 public MarkupParseContext (MarkupParser parser, MarkupParseFlags _flags, void* user_data, DestroyNotify? user_data_dnotify);
4044                 public bool parse (string text, ssize_t text_len) throws MarkupError;
4045                 public bool end_parse () throws MarkupError;
4046                 [Version (since = "2.2")]
4047                 public unowned string get_element ();
4048                 [Version (since = "2.16")]
4049                 public unowned SList<string> get_element_stack ();
4050                 public void get_position (out int line_number, out int char_number);
4051                 [Version (since = "2.18")]
4052                 public void push (MarkupParser parser, void* user_data);
4053                 [Version (since = "2.18")]
4054                 public void* pop ();
4055                 [Version (since = "2.18")]
4056                 public void* get_user_data ();
4057         }
4059         public delegate void MarkupParserStartElementFunc (MarkupParseContext context, string element_name, [CCode (array_length = false, array_null_terminated = true)] string[] attribute_names, [CCode (array_length = false, array_null_terminated = true)] string[] attribute_values) throws MarkupError;
4061         public delegate void MarkupParserEndElementFunc (MarkupParseContext context, string element_name) throws MarkupError;
4063         public delegate void MarkupParserTextFunc (MarkupParseContext context, string text, size_t text_len) throws MarkupError;
4065         public delegate void MarkupParserPassthroughFunc (MarkupParseContext context, string passthrough_text, size_t text_len) throws MarkupError;
4067         public delegate void MarkupParserErrorFunc (MarkupParseContext context, Error error);
4069         public struct MarkupParser {
4070                 [CCode (delegate_target = false)]
4071                 public unowned MarkupParserStartElementFunc start_element;
4072                 [CCode (delegate_target = false)]
4073                 public unowned MarkupParserEndElementFunc end_element;
4074                 [CCode (delegate_target = false)]
4075                 public unowned MarkupParserTextFunc text;
4076                 [CCode (delegate_target = false)]
4077                 public unowned MarkupParserPassthroughFunc passthrough;
4078                 [CCode (delegate_target = false)]
4079                 public unowned MarkupParserErrorFunc error;
4080         }
4082         namespace Markup {
4083                 [CCode (cprefix = "G_MARKUP_COLLECT_", has_type_id = false)]
4084                 public enum CollectType {
4085                         INVALID,
4086                         STRING,
4087                         STRDUP,
4088                         BOOLEAN,
4089                         TRISTATE,
4090                         OPTIONAL
4091                 }
4093                 public static string escape_text (string text, ssize_t length = -1);
4094                 [Version (since = "2.4")]
4095                 [PrintfFormat]
4096                 public static string printf_escaped (string format, ...);
4097                 [Version (since = "2.4")]
4098                 public static string vprintf_escaped (string format, va_list args);
4099                 [Version (since = "2.16")]
4100                 [CCode (sentinel = "G_MARKUP_COLLECT_INVALID")]
4101                 public static bool collect_attributes (string element_name, [CCode (array_length = false, array_null_terminated = true)] string[] attribute_names, [CCode (array_length = false, array_null_terminated = true)] string[] attribute_values, ...) throws MarkupError;
4102         }
4104         /* Key-value file parser */
4106         public errordomain KeyFileError {
4107                 UNKNOWN_ENCODING,
4108                 PARSE,
4109                 NOT_FOUND,
4110                 KEY_NOT_FOUND,
4111                 GROUP_NOT_FOUND,
4112                 INVALID_VALUE;
4113                 public static GLib.Quark quark ();
4114         }
4116         [Compact]
4117         [Version (since = "2.32")]
4118         [CCode (ref_function = "g_key_file_ref", unref_function = "g_key_file_unref", type_id = "G_TYPE_KEY_FILE")]
4119         public class KeyFile {
4120                 public KeyFile ();
4121                 public void set_list_separator (char separator);
4122                 [Version (since = "2.50")]
4123                 public bool load_from_bytes (Bytes bytes, KeyFileFlags @flags) throws KeyFileError;
4124                 public bool load_from_file (string file, KeyFileFlags @flags) throws KeyFileError, FileError;
4125                 [Version (since = "2.14")]
4126                 public bool load_from_dirs (string file, [CCode (array_length = false, array_null_terminated = true)] string[] search_dirs, out string full_path, KeyFileFlags @flags) throws KeyFileError, FileError;
4127                 public bool load_from_data (string data, size_t length, KeyFileFlags @flags) throws KeyFileError;
4128                 public bool load_from_data_dirs (string file, out string full_path, KeyFileFlags @flags) throws KeyFileError, FileError;
4129                 // g_key_file_to_data never throws an error according to the documentation
4130                 public string to_data (out size_t length = null, out GLib.Error error = null);
4131                 public string get_start_group ();
4132                 [CCode (array_length_type = "gsize")]
4133                 public string[] get_groups ();
4134                 [CCode (array_length_type = "gsize")]
4135                 public string[] get_keys (string group_name) throws KeyFileError;
4136                 public bool has_group (string group_name);
4137                 public bool has_key (string group_name, string key) throws KeyFileError;
4138                 public string get_value (string group_name, string key) throws KeyFileError;
4139                 public string get_string (string group_name, string key) throws KeyFileError;
4140                 public string get_locale_string (string group_name, string key, string? locale = null) throws KeyFileError;
4141                 [Version (since = "2.56")]
4142                 public string? get_locale_for_key (string group_name, string key, string? locale = null);
4143                 public bool get_boolean (string group_name, string key) throws KeyFileError;
4144                 public int get_integer (string group_name, string key) throws KeyFileError;
4145                 [Version (since = "2.26")]
4146                 public int64 get_int64 (string group_name, string key) throws KeyFileError;
4147                 [Version (since = "2.26")]
4148                 public uint64 get_uint64 (string group_name, string key) throws KeyFileError;
4149                 [Version (since = "2.12")]
4150                 public double get_double (string group_name, string key) throws KeyFileError;
4151                 [CCode (array_length = true, array_length_type = "gsize", array_null_terminated = true)]
4152                 public string[] get_string_list (string group_name, string key) throws KeyFileError;
4153                 [CCode (array_length_type = "gsize")]
4154                 public string[] get_locale_string_list (string group_name, string key, string? locale = null) throws KeyFileError;
4155                 [CCode (array_length_type = "gsize")]
4156                 public bool[] get_boolean_list (string group_name, string key) throws KeyFileError;
4157                 [CCode (array_length_type = "gsize")]
4158                 public int[] get_integer_list (string group_name, string key) throws KeyFileError;
4159                 [Version (since = "2.12")]
4160                 [CCode (array_length_type = "gsize")]
4161                 public double[] get_double_list (string group_name, string key) throws KeyFileError;
4162                 public string get_comment (string? group_name, string? key) throws KeyFileError;
4163                 [Version (since = "2.40")]
4164                 public bool save_to_file (string filename) throws GLib.FileError;
4165                 public void set_value (string group_name, string key, string value);
4166                 public void set_string (string group_name, string key, string str);
4167                 public void set_locale_string (string group_name, string key, string locale, string str);
4168                 public void set_boolean (string group_name, string key, bool value);
4169                 public void set_integer (string group_name, string key, int value);
4170                 [Version (since = "2.26")]
4171                 public void set_int64 (string group_name, string key, int64 value);
4172                 [Version (since = "2.26")]
4173                 public void set_uint64 (string group_name, string key, uint64 value);
4174                 [Version (since = "2.12")]
4175                 public void set_double (string group_name, string key, double value);
4176                 public void set_string_list (string group_name, string key, [CCode (type = "const gchar* const*")] string[] list);
4177                 public void set_locale_string_list (string group_name, string key, string locale, string[] list);
4178                 public void set_boolean_list (string group_name, string key, bool[] list);
4179                 public void set_integer_list (string group_name, string key, int[] list);
4180                 [Version (since = "2.12")]
4181                 public void set_double_list (string group_name, string key, double[] list);
4182                 public void set_comment (string? group_name, string? key, string comment) throws KeyFileError;
4183                 public void remove_group (string group_name) throws KeyFileError;
4184                 public void remove_key (string group_name, string key) throws KeyFileError;
4185                 public void remove_comment (string group_name, string key) throws KeyFileError;
4186         }
4188         [CCode (cprefix = "G_KEY_FILE_", has_type_id = false)]
4189         [Flags]
4190         public enum KeyFileFlags {
4191                 NONE,
4192                 KEEP_COMMENTS,
4193                 KEEP_TRANSLATIONS
4194         }
4196         [Version (since = "2.14")]
4197         [CCode (cprefix = "G_KEY_FILE_DESKTOP_")]
4198         namespace KeyFileDesktop {
4199                 public const string GROUP;
4200                 public const string KEY_ACTIONS;
4201                 public const string KEY_CATEGORIES;
4202                 public const string KEY_COMMENT;
4203                 public const string KEY_DBUS_ACTIVATABLE;
4204                 public const string KEY_EXEC;
4205                 public const string KEY_FULLNAME;
4206                 public const string KEY_GENERIC_NAME;
4207                 public const string KEY_GETTEXT_DOMAIN;
4208                 public const string KEY_HIDDEN;
4209                 public const string KEY_ICON;
4210                 public const string KEY_KEYWORDS;
4211                 public const string KEY_MIME_TYPE;
4212                 public const string KEY_NAME;
4213                 public const string KEY_NOT_SHOW_IN;
4214                 public const string KEY_NO_DISPLAY;
4215                 public const string KEY_ONLY_SHOW_IN;
4216                 public const string KEY_PATH;
4217                 public const string KEY_STARTUP_NOTIFY;
4218                 public const string KEY_STARTUP_WM_CLASS;
4219                 public const string KEY_TERMINAL;
4220                 public const string KEY_TRY_EXEC;
4221                 public const string KEY_TYPE;
4222                 public const string KEY_URL;
4223                 public const string KEY_VERSION;
4224                 public const string TYPE_APPLICATION;
4225                 public const string TYPE_DIRECTORY;
4226                 public const string TYPE_LINK;
4227         }
4229         /* Bookmark file parser */
4231         [Compact]
4232         [Version (since = "2.12")]
4233         [CCode (free_function = "g_bookmark_file_free")]
4234         public class BookmarkFile {
4235                 public BookmarkFile ();
4236                 public bool load_from_file (string file) throws BookmarkFileError, FileError;
4237                 public bool load_from_data (string data, size_t length) throws BookmarkFileError;
4238                 public bool load_from_data_dirs (string file, out string full_path) throws BookmarkFileError, FileError;
4239                 public string to_data (out size_t length) throws BookmarkFileError;
4240                 public bool to_file (string filename) throws BookmarkFileError, FileError;
4241                 public bool has_item (string uri);
4242                 public bool has_group (string uri, string group) throws BookmarkFileError;
4243                 public bool has_application (string uri, string name) throws BookmarkFileError;
4244                 public int get_size ();
4245                 public string[] get_uris ();
4246                 public string get_title (string uri) throws BookmarkFileError;
4247                 public string get_description (string uri) throws BookmarkFileError;
4248                 public string get_mime_type (string uri) throws BookmarkFileError;
4249                 public bool get_is_private (string uri) throws BookmarkFileError;
4250                 public bool get_icon (string uri, out string href, out string mime_type) throws BookmarkFileError;
4251                 public time_t get_added (string uri) throws BookmarkFileError;
4252                 public time_t get_modified (string uri) throws BookmarkFileError;
4253                 public time_t get_visited (string uri) throws BookmarkFileError;
4254                 public string[] get_groups (string uri) throws BookmarkFileError;
4255                 public string[] get_applications (string uri) throws BookmarkFileError;
4256                 public bool get_app_info (string uri, string name, out string exec, out uint count, out time_t stamp) throws BookmarkFileError;
4257                 public void set_title (string uri, string title);
4258                 public void set_description (string uri, string description);
4259                 public void set_mime_type (string uri, string mime_type);
4260                 public void set_is_private (string uri, bool is_private);
4261                 public void set_icon (string uri, string href, string mime_type);
4262                 public void set_added (string uri, time_t added);
4263                 public void set_groups (string uri, string[] groups);
4264                 public void set_modified (string uri, time_t modified);
4265                 public void set_visited (string uri, time_t visited);
4266                 public bool set_app_info (string uri, string name, string exec, int count, time_t stamp) throws BookmarkFileError;
4267                 public void add_group (string uri, string group);
4268                 public void add_application (string uri, string name, string exec);
4269                 public bool remove_group (string uri, string group) throws BookmarkFileError;
4270                 public bool remove_application (string uri, string name) throws BookmarkFileError;
4271                 public bool remove_item (string uri) throws BookmarkFileError;
4272                 public bool move_item (string old_uri, string new_uri) throws BookmarkFileError;
4273         }
4275         public errordomain BookmarkFileError {
4276                 INVALID_URI,
4277                 INVALID_VALUE,
4278                 APP_NOT_REGISTERED,
4279                 URI_NOT_FOUND,
4280                 READ,
4281                 UNKNOWN_ENCODING,
4282                 WRITE,
4283                 FILE_NOT_FOUND;
4284                 public static GLib.Quark quark ();
4285         }
4287         /* Testing */
4289         namespace Test {
4290                 [CCode (cprefix = "G_TEST_", has_type_id = false)]
4291                 public enum FileType {
4292                         DIST,
4293                         BUILT
4294                 }
4296                 [PrintfFormat]
4297                 [Version (since = "2.16")]
4298                 public static void minimized_result (double minimized_quantity, string format, ...);
4299                 [PrintfFormat]
4300                 [Version (since = "2.16")]
4301                 public static void maximized_result (double maximized_quantity, string format, ...);
4302                 [Version (since = "2.16")]
4303                 public static void init ([CCode (array_length_pos = 0.9)] ref unowned string[] args, ...);
4304                 public static bool quick ();
4305                 public static bool slow ();
4306                 public static bool thorough ();
4307                 public static bool perf ();
4308                 public static bool verbose ();
4309                 public static bool quiet ();
4310                 [Version (since = "2.16")]
4311                 public static int run ();
4312                 [Version (since = "2.16")]
4313                 public static void add_func (string testpath, [CCode (scope = "async")] owned TestFunc test_funcvoid);
4314                 [Version (since = "2.16")]
4315                 public static void add_data_func (string testpath, [CCode (delegate_target_pos = 1.9, scope = "async")] owned TestDataFunc test_funcvoid);
4316                 [Version (since = "2.34")]
4317                 public static void add_data_func_full (string testpath, [CCode (delegate_target_pos = 1.9)] owned TestDataFunc test_func);
4318                 [Version (since = "2.34")]
4319                 public static void assert_expected_messages ();
4320                 [Version (since = "2.38")]
4321                 public static string build_filename (GLib.Test.FileType file_type, params string[] path_segments);
4322                 [Version (since = "2.34")]
4323                 public static void expect_message (string? log_domain, LogLevelFlags log_level, string pattern);
4324                 [Version (since = "2.30")]
4325                 public static void fail ();
4326                 [Version (since = "2.38")]
4327                 public static bool failed ();
4328                 [Version (since = "2.38")]
4329                 public static unowned string get_dir (GLib.Test.FileType file_type);
4330                 [Version (since = "2.38")]
4331                 public static unowned string get_filename (GLib.Test.FileType file_type, params string[] path_segments);
4332                 [Version (since = "2.38")]
4333                 public static void incomplete (string? msg = null);
4334                 [Version (since = "2.36")]
4335                 public static bool initialized ();
4336                 [PrintfFormat]
4337                 [Version (since = "2.16")]
4338                 public static void message (string format, ...);
4339                 [Version (since = "2.38")]
4340                 public static void set_nonfatal_assertions ();
4341                 [Version (since = "2.38")]
4342                 public static void skip (string? msg = null);
4343                 [Version (since = "2.38")]
4344                 public static bool subprocess ();
4345                 [Version (since = "2.16")]
4346                 public static void bug_base (string uri_pattern);
4347                 [Version (since = "2.16")]
4348                 public static void bug (string bug_uri_snippet);
4349                 [Version (since = "2.16")]
4350                 public static void timer_start ();
4351                 [Version (since = "2.16")]
4352                 public static double timer_elapsed ();
4353                 [Version (since = "2.16")]
4354                 public static double timer_last ();
4355                 [Version (since = "2.16", deprecated_since = "2.38", replacement = "trap_subprocess")]
4356                 public static bool trap_fork (uint64 usec_timeout, TestTrapFlags test_trap_flags);
4357                 [Version (since = "2.16")]
4358                 public static bool trap_has_passed ();
4359                 [Version (since = "2.16")]
4360                 public static bool trap_reached_timeout ();
4361                 [Version (since = "2.38")]
4362                 public static void trap_subprocess (string? test_path, uint64 usec_timeout, TestSubprocessFlags test_flags);
4363                 [Version (since = "2.16")]
4364                 public static void trap_assert_passed ();
4365                 [Version (since = "2.16")]
4366                 public static void trap_assert_failed ();
4367                 [Version (since = "2.16")]
4368                 public static void trap_assert_stdout (string soutpattern);
4369                 [Version (since = "2.16")]
4370                 public static void trap_assert_stdout_unmatched (string soutpattern);
4371                 [Version (since = "2.16")]
4372                 public static void trap_assert_stderr (string serrpattern);
4373                 [Version (since = "2.16")]
4374                 public static void trap_assert_stderr_unmatched (string serrpattern);
4375                 [Version (since = "2.16")]
4376                 public static bool rand_bit ();
4377                 [Version (since = "2.16")]
4378                 public static int32 rand_int ();
4379                 [Version (since = "2.16")]
4380                 public static int32 rand_int_range (int32 begin, int32 end);
4381                 [Version (since = "2.16")]
4382                 public static double rand_double ();
4383                 [Version (since = "2.16")]
4384                 public static double rand_double_range (double begin, double end);
4385                 [Version (since = "2.22")]
4386                 public static void log_set_fatal_handler (LogFatalFunc log_func);
4387         }
4389         public delegate bool LogFatalFunc (string? log_domain, LogLevelFlags log_levels, string message);
4391         [Compact]
4392         [CCode (cname = "GTestCase", ref_function = "", unref_function = "")]
4393         public class TestCase {
4394                 [Version (since = "2.16")]
4395                 [CCode (cname = "g_test_create_case")]
4396                 public TestCase (string test_name, [CCode (delegate_target_pos = 1.9)] TestFixtureFunc data_setup, [CCode (delegate_target_pos = 1.9)] TestFixtureFunc data_func, [CCode (delegate_target_pos = 1.9)] TestFixtureFunc data_teardown, [CCode (pos = 1.8)] size_t data_size = 0);
4397         }
4399         [Compact]
4400         [CCode (cname = "GTestSuite", ref_function = "", unref_function = "")]
4401         public class TestSuite {
4402                 [Version (since = "2.16")]
4403                 [CCode (cname = "g_test_create_suite")]
4404                 public TestSuite (string name);
4405                 [Version (since = "2.16")]
4406                 [CCode (cname = "g_test_get_root")]
4407                 public static TestSuite get_root ();
4408                 [Version (since = "2.16")]
4409                 [CCode (cname = "g_test_suite_add")]
4410                 public void add (TestCase test_case);
4411                 [Version (since = "2.16")]
4412                 [CCode (cname = "g_test_suite_add_suite")]
4413                 public void add_suite (TestSuite test_suite);
4414         }
4416         [Version (since = "2.26")]
4417         [CCode (has_target = false)]
4418         public delegate void TestFunc ();
4419         [Version (since = "2.26")]
4420         public delegate void TestDataFunc ();
4421         [Version (since = "2.26")]
4422         public delegate void TestFixtureFunc (void* fixture);
4424         [CCode (cprefix = "G_TEST_SUBPROCESS_INHERIT_", has_type_id = false)]
4425         [Flags]
4426         public enum TestSubprocessFlags {
4427                 STDIN,
4428                 STDOUT,
4429                 STDERR
4430         }
4432         [Flags]
4433         [CCode (cprefix = "G_TEST_TRAP_", has_type_id = false)]
4434         public enum TestTrapFlags {
4435                 SILENCE_STDOUT,
4436                 SILENCE_STDERR,
4437                 INHERIT_STDIN
4438         }
4440         /* Doubly-Linked Lists */
4442         [Compact]
4443         [CCode (dup_function = "g_list_copy", free_function = "g_list_free")]
4444         public class List<G> {
4445                 public List ();
4447                 [ReturnsModifiedPointer ()]
4448                 public void append (owned G data);
4449                 [ReturnsModifiedPointer ()]
4450                 public void prepend (owned G data);
4451                 [ReturnsModifiedPointer ()]
4452                 public void insert (owned G data, int position);
4453                 [ReturnsModifiedPointer ()]
4454                 public void insert_before (List<G> sibling, owned G data);
4455                 [ReturnsModifiedPointer ()]
4456                 public void insert_sorted (owned G data, CompareFunc<G> compare_func);
4457                 [ReturnsModifiedPointer ()]
4458                 public void remove (G data);
4459                 [ReturnsModifiedPointer ()]
4460                 public void remove_link (List<G> llink);
4461                 [ReturnsModifiedPointer ()]
4462                 public void delete_link (List<G> link_);
4463                 [ReturnsModifiedPointer ()]
4464                 public void remove_all (G data);
4466                 public uint length ();
4467                 public List<unowned G> copy ();
4468                 [Version (since = "2.34")]
4469                 public List<G> copy_deep (CopyFunc<G> func);
4470                 [ReturnsModifiedPointer ()]
4471                 public void reverse ();
4472                 [ReturnsModifiedPointer ()]
4473                 public void sort (CompareFunc<G> compare_func);
4474                 [Version (since = "2.10")]
4475                 [ReturnsModifiedPointer ()]
4476                 public void insert_sorted_with_data (owned G data, CompareDataFunc<G> compare_func);
4477                 [ReturnsModifiedPointer ()]
4478                 public void sort_with_data (CompareDataFunc<G> compare_func);
4479                 [ReturnsModifiedPointer ()]
4480                 public void concat (owned List<G> list2);
4481                 public void @foreach (Func<G> func);
4483                 public unowned List<G> first ();
4484                 public unowned List<G> last ();
4485                 public unowned List<G> nth (uint n);
4486                 public unowned G nth_data (uint n);
4487                 public unowned List<G> nth_prev (uint n);
4489                 public unowned List<G> find (G data);
4490                 public unowned List<G> find_custom (G data, CompareFunc<G> func);
4491                 [CCode (cname = "g_list_find_custom", simple_generics = true)]
4492                 public unowned List<G> search<T> (T data, SearchFunc<G,T> func);
4494                 public int position (List<G> llink);
4495                 public int index (G data);
4497                 public G data;
4498                 public List<G> next;
4499                 public unowned List<G> prev;
4500         }
4502         /* Singly-Linked Lists */
4504         [Compact]
4505         [CCode (dup_function = "g_slist_copy", free_function = "g_slist_free")]
4506         public class SList<G> {
4507                 public SList ();
4509                 [ReturnsModifiedPointer ()]
4510                 public void append (owned G data);
4511                 [ReturnsModifiedPointer ()]
4512                 public void prepend (owned G data);
4513                 [ReturnsModifiedPointer ()]
4514                 public void insert (owned G data, int position);
4515                 [ReturnsModifiedPointer ()]
4516                 public void insert_before (SList<G> sibling, owned G data);
4517                 [ReturnsModifiedPointer ()]
4518                 public void insert_sorted (owned G data, CompareFunc<G> compare_func);
4519                 [ReturnsModifiedPointer ()]
4520                 public void remove (G data);
4521                 [ReturnsModifiedPointer ()]
4522                 public void remove_link (SList<G> llink);
4523                 [ReturnsModifiedPointer ()]
4524                 public void delete_link (SList<G> link_);
4525                 [ReturnsModifiedPointer ()]
4526                 public void remove_all (G data);
4528                 public uint length ();
4529                 public SList<unowned G> copy ();
4530                 [Version (since = "2.34")]
4531                 public SList<G> copy_deep (CopyFunc<G> func);
4532                 [ReturnsModifiedPointer ()]
4533                 public void reverse ();
4534                 [Version (since = "2.10")]
4535                 [ReturnsModifiedPointer ()]
4536                 public void insert_sorted_with_data (owned G data, CompareDataFunc<G> compare_func);
4537                 [ReturnsModifiedPointer ()]
4538                 public void sort (CompareFunc<G> compare_func);
4539                 [ReturnsModifiedPointer ()]
4540                 public void sort_with_data (CompareDataFunc<G> compare_func);
4541                 [ReturnsModifiedPointer ()]
4542                 public void concat (owned SList<G> list2);
4543                 public void @foreach (Func<G> func);
4545                 public unowned SList<G> last ();
4546                 public unowned SList<G> nth (uint n);
4547                 public unowned G nth_data (uint n);
4549                 public unowned SList<G> find (G data);
4550                 public unowned SList<G> find_custom (G data, CompareFunc<G> func);
4551                 [CCode (cname = "g_slist_find_custom", simple_generics = true)]
4552                 public unowned SList<G> search<T> (T data, SearchFunc<G,T> func);
4554                 public int position (SList<G> llink);
4555                 public int index (G data);
4557                 public G data;
4558                 public SList<G> next;
4559         }
4561         [CCode (has_target = false)]
4562         public delegate int CompareFunc<G> (G a, G b);
4564         public delegate int CompareDataFunc<G> (G a, G b);
4566         [Version (since = "2.16")]
4567         [CCode (cname = "g_strcmp0")]
4568         public static GLib.CompareFunc<string> strcmp;
4570         public delegate G CopyFunc<G> (G src);
4572         [CCode (cname = "GCompareFunc", has_target = false)]
4573         public delegate int SearchFunc<G,T> (G a, T b);
4575         /* Double-ended Queues */
4577         [Compact]
4578         [CCode (dup_function = "g_queue_copy", free_function = "g_queue_free")]
4579         public class Queue<G> {
4580                 public unowned List<G> head;
4581                 public unowned List<G> tail;
4582                 public uint length;
4584                 public Queue ();
4586                 [Version (since = "2.14")]
4587                 public void clear ();
4588                 public bool is_empty ();
4589                 [Version (since = "2.4")]
4590                 public uint get_length ();
4591                 [Version (since = "2.4")]
4592                 public void reverse ();
4593                 public Queue copy ();
4594                 [Version (since = "2.4")]
4595                 public unowned List<G> find (G data);
4596                 [Version (since = "2.4")]
4597                 public unowned List<G> find_custom (G data, CompareFunc<G> func);
4598                 [CCode (cname = "g_queue_find_custom", simple_generics = true)]
4599                 public unowned List<G> search<T> (T data, SearchFunc<G,T> func);
4600                 [Version (since = "2.4")]
4601                 public void sort (CompareDataFunc<G> compare_func);
4602                 public void push_head (owned G data);
4603                 public void push_tail (owned G data);
4604                 [Version (since = "2.4")]
4605                 public void push_nth (owned G data, int n);
4606                 public G pop_head ();
4607                 public G pop_tail ();
4608                 [Version (since = "2.4")]
4609                 public G pop_nth (uint n);
4610                 public unowned G peek_head ();
4611                 public unowned G peek_tail ();
4612                 [Version (since = "2.4")]
4613                 public unowned G peek_nth (uint n);
4614                 [Version (since = "2.4")]
4615                 public int index (G data);
4616                 [Version (since = "2.4")]
4617                 public void remove (G data);
4618                 [Version (since = "2.4")]
4619                 public void remove_all (G data);
4620                 [Version (since = "2.4")]
4621                 public void delete_link (List<G> link);
4622                 [Version (since = "2.4")]
4623                 public void unlink (List<G> link);
4624                 [Version (since = "2.4")]
4625                 public void insert_before (List<G> sibling, owned G data);
4626                 [Version (since = "2.4")]
4627                 public void insert_after (List<G> sibling, owned G data);
4628                 [Version (since = "2.4")]
4629                 public void insert_sorted (owned G data, CompareDataFunc<G> func);
4630         }
4632         /* Sequences */
4634         [Compact]
4635         [Version (since = "2.14")]
4636         [CCode (free_function = "g_sequence_free")]
4637         public class Sequence<G> {
4638                 [CCode (simple_generics = true)]
4639                 public Sequence ();
4640                 public int get_length ();
4641                 public void @foreach (Func<G> func);
4642                 public void sort (CompareDataFunc<G> cmp_func);
4643                 public void sort_iter (SequenceIterCompareFunc<G> func);
4644                 public SequenceIter<G> get_begin_iter ();
4645                 public SequenceIter<G> get_end_iter ();
4646                 public SequenceIter<G> get_iter_at_pos (int pos);
4647                 public SequenceIter<G> append (owned G data);
4648                 public SequenceIter<G> prepend (owned G data);
4649                 public SequenceIter<G> insert_sorted (owned G data, CompareDataFunc<G> cmp_func);
4650                 [Version (since = "2.48")]
4651                 public bool is_empty ();
4652                 public SequenceIter<G> insert_sorted_iter (owned G data, SequenceIterCompareFunc<G> iter_cmp);
4653                 public SequenceIter<G> search (G data, CompareDataFunc<G> cmp_func);
4654                 public SequenceIter<G> search_iter (G data, SequenceIterCompareFunc<G> iter_cmp);
4655                 [Version (since = "2.28")]
4656                 public SequenceIter<G> lookup (G data, CompareDataFunc<G> cmp_func);
4657                 [Version (since = "2.28")]
4658                 public SequenceIter<G> lookup_iter (G data, SequenceIterCompareFunc<G> iter_cmp);
4660                 [Version (deprecated_since = "vala-0.26", replacement = "SequenceIter.foreach_range")]
4661                 public static void foreach_range (SequenceIter<G> begin, SequenceIter<G> end, Func<G> func);
4662                 [Version (deprecated_since = "vala-0.26", replacement = "SequenceIter.insert_before")]
4663                 public static SequenceIter<G> insert_before (SequenceIter<G> iter, owned G data);
4664                 [Version (deprecated_since = "vala-0.26", replacement = "SequenceIter.move_to")]
4665                 public static void move (SequenceIter<G> src, SequenceIter<G> dest);
4666                 [Version (deprecated_since = "vala-0.26", replacement = "SequenceIter.swap")]
4667                 public static void swap (SequenceIter<G> src, SequenceIter<G> dest);
4668                 [Version (deprecated_since = "vala-0.26", replacement = "SequenceIter.sort_changed")]
4669                 public static void sort_changed (SequenceIter<G> iter, CompareDataFunc<G> cmp_func);
4670                 [Version (deprecated_since = "vala-0.26", replacement = "SequenceIter.sort_changed_iter")]
4671                 public static void sort_changed_iter (SequenceIter<G> iter, SequenceIterCompareFunc<G> iter_cmp);
4672                 [Version (deprecated_since = "vala-0.26", replacement = "SequenceIter.remove")]
4673                 public static void remove (SequenceIter<G> iter);
4674                 [Version (deprecated_since = "vala-0.26", replacement = "SequenceIter.remove_range")]
4675                 public static void remove_range (SequenceIter<G> begin, SequenceIter<G> end);
4676                 [Version (deprecated_since = "vala-0.26", replacement = "SequenceIter.move_range")]
4677                 public static void move_range (SequenceIter<G> dest, SequenceIter<G> begin, SequenceIter<G> end);
4678                 [Version (deprecated_since = "vala-0.26", replacement = "SequenceIter.get")]
4679                 public static unowned G get (SequenceIter<G> iter);
4680                 [Version (deprecated_since = "vala-0.26", replacement = "SequenceIter.set")]
4681                 public static void set (SequenceIter<G> iter, owned G data);
4682                 [Version (deprecated_since = "vala-0.26", replacement = "SequenceIter.range_get_midpoint")]
4683                 public static SequenceIter<G> range_get_midpoint (SequenceIter<G> begin, SequenceIter<G> end);
4684         }
4686         [Compact]
4687         [Version (since = "2.14")]
4688         [CCode (ref_function = "", unref_function = "")]
4689         public class SequenceIter<G> {
4690                 public bool is_begin ();
4691                 public bool is_end ();
4692                 public SequenceIter<G> next ();
4693                 public SequenceIter<G> prev ();
4694                 public int get_position ();
4695                 public SequenceIter<G> move (int delta);
4696                 public unowned Sequence<G> get_sequence ();
4697                 public int compare (SequenceIter<G> other);
4699                 [CCode (cname = "g_sequence_foreach_range")]
4700                 public void foreach_range (SequenceIter<G> end, Func<G> func);
4701                 [CCode (cname = "g_sequence_insert_before")]
4702                 public SequenceIter<G> insert_before (owned G data);
4703                 [CCode (cname = "g_sequence_move")]
4704                 public void move_to (SequenceIter<G> dest);
4705                 [CCode (cname = "g_sequence_swap")]
4706                 public void swap (SequenceIter<G> dest);
4707                 [CCode (cname = "g_sequence_sort_changed")]
4708                 public void sort_changed (CompareDataFunc<G> cmp_func);
4709                 [CCode (cname = "g_sequence_sort_changed_iter")]
4710                 public void sort_changed_iter (SequenceIterCompareFunc<G> iter_cmp);
4711                 [CCode (cname = "g_sequence_remove")]
4712                 public void remove ();
4713                 [CCode (cname = "g_sequence_remove_range")]
4714                 public void remove_range (SequenceIter<G> end);
4715                 [CCode (cname = "g_sequence_move_range")]
4716                 public void move_range (SequenceIter<G> begin, SequenceIter<G> end);
4717                 [CCode (cname = "g_sequence_get")]
4718                 public unowned G get ();
4719                 [CCode (cname = "g_sequence_set")]
4720                 public void set (owned G data);
4721                 [CCode (cname = "g_sequence_range_get_midpoint")]
4722                 public SequenceIter<G> range_get_midpoint (SequenceIter<G> end);
4723         }
4725         public delegate int SequenceIterCompareFunc<G> (SequenceIter<G> a, SequenceIter<G> b);
4727         /* Hash Tables */
4729         [Compact]
4730         [CCode (ref_function = "g_hash_table_ref", unref_function = "g_hash_table_unref", type_id = "G_TYPE_HASH_TABLE", type_signature = "a{%s}")]
4731         public class HashTable<K,V> {
4732                 [CCode (cname = "g_hash_table_new_full", simple_generics = true)]
4733                 public HashTable (HashFunc<K>? hash_func, EqualFunc<K>? key_equal_func);
4734                 public HashTable.full (HashFunc<K>? hash_func, EqualFunc<K>? key_equal_func, DestroyNotify? key_destroy_func, DestroyNotify? value_destroy_func);
4735                 public void insert (owned K key, owned V value);
4736                 public void replace (owned K key, owned V value);
4737                 [Version (since = "2.32", deprecated_since = "vala-0.26", replacement = "GenericSet.add")]
4738                 public void add (owned K key);
4739                 public unowned V? lookup (K key);
4740                 public bool lookup_extended (K lookup_key, out unowned K orig_key, out unowned V value);
4741                 [Version (since = "2.32")]
4742                 public bool contains (K key);
4743                 public bool remove (K key);
4744                 [Version (since = "2.12")]
4745                 public void remove_all ();
4746                 public uint foreach_remove (HRFunc<K,V> predicate);
4747                 [CCode (cname = "g_hash_table_lookup")]
4748                 public unowned V? @get (K key);
4749                 [CCode (cname = "g_hash_table_insert")]
4750                 public void @set (owned K key, owned V value);
4751                 [Version (since = "2.14")]
4752                 public List<unowned K> get_keys ();
4753 #if VALA_0_26
4754                 [Version (since = "2.40")]
4755                 public (unowned K)[] get_keys_as_array ();
4756 #endif
4757                 [Version (since = "2.14")]
4758                 public List<unowned V> get_values ();
4759                 public void @foreach (HFunc<K,V> func);
4760                 [CCode (cname = "g_hash_table_foreach")]
4761                 public void for_each (HFunc<K,V> func);
4762                 [Version (since = "2.4")]
4763                 public unowned V? find (HRFunc<K,V> predicate);
4764                 public uint size ();
4765                 public bool steal (K key);
4766                 [Version (since = "2.12")]
4767                 public void steal_all ();
4768                 [CCode (cname = "_vala_g_hash_table_take")]
4769                 public V? take (K key, out bool exists = null) {
4770                         GLib.HashTable<K,V>? ht = null;
4771                         void** htp = &ht;
4772                         *htp = this.lookup (key);
4773                         exists = this.steal (key);
4774                         return ht;
4775                 }
4776                 public uint length {
4777                         [CCode (cname = "g_hash_table_size")]
4778                         get;
4779                 }
4780         }
4782         [Version (since = "2.16")]
4783         public struct HashTableIter<K,V> {
4784                 public HashTableIter (GLib.HashTable<K,V> table);
4785                 public bool next ([CCode (type = "gpointer*")] out unowned K key, [CCode (type = "gpointer*")] out unowned V value);
4786                 public void remove ();
4787                 public void steal ();
4788                 public unowned GLib.HashTable<K,V> get_hash_table ();
4789         }
4791         [Version (since = "2.32")]
4792         [Compact, CCode (cname = "GHashTable", lower_case_cprefix = "g_hash_table_", ref_function = "g_hash_table_ref", unref_function = "g_hash_table_unref", type_id = "G_TYPE_HASH_TABLE", type_signature = "a{%s}")]
4793         public class GenericSet<T> {
4794                 [CCode (cname = "g_hash_table_new_full", simple_generics = true)]
4795                 public GenericSet (HashFunc<T>? hash_func, EqualFunc<T>? equal_func, GLib.DestroyNotify? always_pass_null_here = null);
4796                 public void add (owned T value);
4797                 public bool contains (T valule);
4798                 public bool remove (T value);
4799                 public void remove_all ();
4800                 public GLib.List<unowned T> get_values ();
4801                 [CCode (cname = "g_hash_table_iter_init", instance_pos = -1)]
4802                 public GLib.GenericSetIter<T> iterator ();
4803                 [CCode (cname = "_vala_g_hash_set_foreach")]
4804                 public void @foreach (GLib.Func<T> func) {
4805                         ((GLib.HashTable<unowned T,T>) this).foreach ((k, v) => func (v));
4806                 }
4807                 public uint length {
4808                         [CCode (cname = "g_hash_table_size")]
4809                         get;
4810                 }
4811         }
4813         [Version (since = "2.32")]
4814         [CCode (cname = "GHashTableIter", lower_case_cprefix = "g_hash_table_iter_")]
4815         public struct GenericSetIter<T> {
4816                 [CCode (cname = "_vala_hash_set_next_value")]
4817                 public unowned T? next_value () {
4818                         void* vi = &this;
4819                         GLib.HashTableIter<unowned T,T>* htp = vi;
4820                         unowned T? value;
4821                         return htp->next (out value, null) ? value : null;
4822                 }
4823                 public void remove ();
4824         }
4826         [CCode (has_target = false)]
4827         public delegate uint HashFunc<K> (K key);
4828         [CCode (has_target = false)]
4829         public delegate bool EqualFunc<G> (G a, G b);
4830         public delegate void HFunc<K,V> (K key, V value);
4831         public delegate bool HRFunc<K,V> (K key, V value);
4833         [CCode (has_target = false)]
4834         public delegate void DestroyNotify (void* data);
4836         [CCode (cname = "g_direct_hash")]
4837         public static GLib.HashFunc<void*> direct_hash;
4838         [CCode (cname = "g_direct_equal")]
4839         public static GLib.EqualFunc<void*> direct_equal;
4840         [CCode (cname = "g_int64_hash")]
4841         public static GLib.HashFunc<int64?> int64_hash;
4842         [Version (since = "2.22")]
4843         [CCode (cname = "g_int64_equal")]
4844         public static GLib.EqualFunc<int64?> int64_equal;
4845         [Version (since = "2.22")]
4846         [CCode (cname = "g_int_hash")]
4847         public static GLib.HashFunc<int?> int_hash;
4848         [CCode (cname = "g_int_equal")]
4849         public static GLib.EqualFunc<int?> int_equal;
4850         [CCode (cname = "g_str_hash")]
4851         public static GLib.HashFunc<string> str_hash;
4852         [CCode (cname = "g_str_equal")]
4853         public static GLib.EqualFunc<string> str_equal;
4854         [CCode (cname = "g_free")]
4855         public static GLib.DestroyNotify g_free;
4856         [CCode (cname = "g_object_unref")]
4857         public static GLib.DestroyNotify g_object_unref;
4858         [CCode (cname = "g_list_free")]
4859         public static GLib.DestroyNotify g_list_free;
4860         [CCode (cname = "((GDestroyNotify) g_variant_unref)")]
4861         public static GLib.DestroyNotify g_variant_unref;
4863         /* Strings */
4865         [Compact]
4866         [GIR (name = "String")]
4867         [CCode (cname = "GString", cprefix = "g_string_", free_function = "g_string_free", type_id = "G_TYPE_GSTRING")]
4868         public class StringBuilder {
4869                 public StringBuilder (string init = "");
4870                 [CCode (cname = "g_string_sized_new")]
4871                 public StringBuilder.sized (size_t dfl_size);
4872                 public unowned StringBuilder assign (string rval);
4873                 public unowned StringBuilder append (string val);
4874                 public unowned StringBuilder append_c (char c);
4875                 public unowned StringBuilder append_unichar (unichar wc);
4876                 public unowned StringBuilder append_len (string val, ssize_t len);
4877                 public unowned StringBuilder prepend (string val);
4878                 public unowned StringBuilder prepend_c (char c);
4879                 public unowned StringBuilder prepend_unichar (unichar wc);
4880                 public unowned StringBuilder prepend_len (string val, ssize_t len);
4881                 public unowned StringBuilder insert (ssize_t pos, string val);
4882                 public unowned StringBuilder insert_len (ssize_t pos, string val, ssize_t len);
4883                 public unowned StringBuilder insert_unichar (ssize_t pos, unichar wc);
4884                 [Version (since = "2.14")]
4885                 public unowned StringBuilder overwrite (size_t pos, string val);
4886                 [Version (since = "2.14")]
4887                 public unowned StringBuilder overwrite_len (size_t pos, string val, ssize_t len);
4888                 public unowned StringBuilder erase (ssize_t pos = 0, ssize_t len = -1);
4889                 public unowned StringBuilder truncate (size_t len = 0);
4891                 [PrintfFormat]
4892                 public void printf (string format, ...);
4893                 [PrintfFormat]
4894                 public void append_printf (string format, ...);
4895                 [Version (since = "2.14")]
4896                 public void vprintf (string format, va_list args);
4897                 [Version (since = "2.14")]
4898                 public void append_vprintf (string format, va_list args);
4900                 public string str;
4901                 public ssize_t len;
4902                 public ssize_t allocated_len;
4904                 public uint8[] data {
4905                         get {
4906                                 unowned uint8[] res = (uint8[]) this.str;
4907                                 res.length = (int) this.len;
4908                                 return res;
4909                         }
4910                 }
4912                 [Version (since = "2.34")]
4913                 public static Bytes free_to_bytes (owned StringBuilder str);
4914         }
4916         /* String Chunks */
4918         [Compact]
4919         [CCode (free_function = "g_string_chunk_free")]
4920         public class StringChunk {
4921                 public StringChunk (size_t size);
4922                 public unowned string insert (string str);
4923                 public unowned string insert_const (string str);
4924                 [Version (since = "2.4")]
4925                 public unowned string insert_len (string str, ssize_t len);
4926                 [Version (since = "2.14")]
4927                 public void clear ();
4928         }
4930         /* Pointer Arrays */
4932         [Compact]
4933         [Version (since = "2.22", deprecated_since = "vala-0.26", replacement="GenericArray")]
4934         [CCode (ref_function = "g_ptr_array_ref", unref_function = "g_ptr_array_unref", type_id = "G_TYPE_PTR_ARRAY")]
4935         public class PtrArray {
4936                 public PtrArray ();
4937                 [Version (since = "2.22")]
4938                 public PtrArray.with_free_func (GLib.DestroyNotify? element_free_func);
4939                 [CCode (cname = "g_ptr_array_sized_new")]
4940                 public PtrArray.sized (uint reserved_size);
4941                 public void add (void* data);
4942                 [Version (since = "2.4")]
4943                 public void foreach (GLib.Func<void*> func);
4944                 [CCode (cname = "g_ptr_array_index")]
4945                 public void* index(uint index);
4946                 public bool remove (void* data);
4947                 public void* remove_index (uint index);
4948                 public bool remove_fast (void *data);
4949                 public void remove_index_fast (uint index);
4950                 [Version (since = "2.4")]
4951                 public void remove_range (uint index, uint length);
4952                 public void sort (CompareFunc<void**> compare_func);
4953                 public void sort_with_data (CompareDataFunc<void**> compare_func);
4954                 [Version (since = "2.22")]
4955                 public void set_free_func (GLib.DestroyNotify? element_free_function);
4956                 public void set_size (int length);
4958                 public uint len;
4959                 public void** pdata;
4960         }
4962         [Compact]
4963         [CCode (cname = "GPtrArray", cprefix = "g_ptr_array_", ref_function = "g_ptr_array_ref", unref_function = "g_ptr_array_unref", type_id = "G_TYPE_PTR_ARRAY")]
4964         [GIR (name = "PtrArray")]
4965         public class GenericArray<G> {
4966                 [Version (since = "2.30")]
4967                 [CCode (cname = "g_ptr_array_new_full", simple_generics = true)]
4968                 public GenericArray (uint reserved_size = 0);
4969                 public void add (owned G data);
4970                 [Version (since = "2.54")]
4971                 public bool find (G needle, out uint index = null);
4972                 [Version (since = "2.54")]
4973                 public bool find_with_equal_func (G needle, GLib.EqualFunc<G>? equal_func, out uint index = null);
4974                 public void foreach (GLib.Func<G> func);
4975                 [CCode (cname = "g_ptr_array_index")]
4976                 public unowned G get (uint index);
4977                 [Version (since = "2.40")]
4978                 public void insert (int index, owned G data);
4979                 public bool remove (G data);
4980                 public void remove_index (uint index);
4981                 public bool remove_fast (G data);
4982                 public void remove_index_fast (uint index);
4983                 public void remove_range (uint index, uint length);
4984                 public void set (uint index, owned G data) {
4985                         this.add ((owned) data);
4986                         this.remove_index_fast (index);
4987                 }
4988                 [CCode (cname = "vala_g_ptr_array_sort")]
4989                 public void sort (GLib.CompareFunc<G> compare_func) {
4990                         this._sort_with_data ((a, b) => {
4991                                 return compare_func ((G**) (*a), (G**) (*b));
4992                         });
4993                 }
4994                 [CCode (cname = "g_ptr_array_sort_with_data")]
4995                 public void _sort_with_data (GLib.CompareDataFunc<G**> compare_func);
4996                 [CCode (cname = "vala_g_ptr_array_sort_with_data")]
4997                 public void sort_with_data (GLib.CompareDataFunc<G> compare_func) {
4998                         this._sort_with_data ((a, b) => {
4999                                 return compare_func ((G**) (*a), (G**) (*b));
5000                         });
5001                 }
5002                 private void set_size (int length);
5004                 public int length {
5005                         get { return (int) this.len; }
5006                         set { this.set_size (value); }
5007                 }
5009                 [CCode (cname = "pdata", array_length_cname = "len", array_length_type = "guint")]
5010                 public G[] data;
5012                 private uint len;
5013         }
5015         [Compact]
5016         [Version (since = "2.32")]
5017         [CCode (cprefix = "g_bytes_", ref_function = "g_bytes_ref", unref_function = "g_bytes_unref", type_id = "G_TYPE_BYTES")]
5018         public class Bytes {
5019                 public Bytes ([CCode (array_length_type = "gsize")] uint8[] data);
5020                 public Bytes.take ([CCode (array_length_type = "gsize")] owned uint8[] data);
5021                 public Bytes.static ([CCode (array_length_type = "gsize")] uint8[] data);
5022                 public Bytes.with_free_func ([CCode (array_length_type = "gsize")] owned uint8[] data, GLib.DestroyNotify? free_func = GLib.g_free);
5023                 public Bytes.from_bytes (GLib.Bytes bytes, size_t offset, size_t length);
5025                 [CCode (cname = "g_bytes_new_with_free_func", simple_generics = true)]
5026                 public static Bytes new_with_owner<T> ([CCode (array_length_type = "gsize")] uint8[] data, [CCode (destroy_notify_pos = 1.9)] owned T? owner = null);
5028                 [CCode (array_length_type = "gsize")]
5029                 public unowned uint8[] get_data ();
5030                 public size_t get_size ();
5031                 public uint hash ();
5032                 public int compare (GLib.Bytes bytes2);
5033                 public static uint8[] unref_to_data (owned GLib.Bytes bytes);
5034                 public static GLib.ByteArray unref_to_array (owned GLib.Bytes bytes);
5036                 [CCode (cname = "_vala_g_bytes_get")]
5037                 public uint8 get (int index) {
5038                         unowned uint8[] data = this.get_data ();
5039                         return data[index];
5040                 }
5042                 [CCode (cname = "_vala_g_bytes_slice")]
5043                 public GLib.Bytes slice (int start, int end) {
5044                         unowned uint8[] data = this.get_data ();
5045                         return new GLib.Bytes (data[start:end]);
5046                 }
5048                 public int length {
5049                         [CCode (cname = "_vala_g_bytes_get_length")]
5050                         get {
5051                                 return (int) this.get_size ();
5052                         }
5053                 }
5054         }
5056         /* Byte Arrays */
5058         [Compact]
5059         [Version (since = "2.22")]
5060         [CCode (cprefix = "g_byte_array_", ref_function = "g_byte_array_ref", unref_function = "g_byte_array_unref", type_id = "G_TYPE_BYTE_ARRAY")]
5061         public class ByteArray {
5062                 public ByteArray ();
5063                 [CCode (cname = "g_byte_array_sized_new")]
5064                 public ByteArray.sized (uint reserved_size);
5065                 [Version (since = "2.32")]
5066                 public ByteArray.take (owned uint8[] data);
5067                 public void append (uint8[] data);
5068                 [Version (since = "2.32")]
5069                 public static GLib.Bytes free_to_bytes (owned GLib.ByteArray array);
5070                 public void prepend (uint8[] data);
5071                 public void remove_index (uint index);
5072                 public void remove_index_fast (uint index);
5073                 [Version (since = "2.4")]
5074                 public void remove_range (uint index, uint length);
5075                 public void sort (CompareFunc<int8> compare_func);
5076                 public void sort_with_data (CompareDataFunc<int8> compare_func);
5077                 public void set_size (uint length);
5079                 public uint len;
5080                 [CCode (array_length_cname = "len", array_length_type = "guint")]
5081                 public uint8[] data;
5082         }
5084         /* N-ary Trees */
5086         public delegate bool NodeTraverseFunc (Node node);
5087         public delegate void NodeForeachFunc (Node node);
5089         [CCode (cprefix = "G_TRAVERSE_")]
5090         public enum TraverseFlags {
5091                 LEAVES,
5092                 NON_LEAVES,
5093                 ALL,
5094                 MASK,
5095                 LEAFS,
5096                 NON_LEAFS
5097         }
5099         [Compact]
5100         [CCode (dup_function = "g_node_copy", free_function = "g_node_destroy")]
5101         public class Node<G> {
5102                 public Node(owned G? data = null);
5103                 public Node<unowned G> copy ();
5104                 public Node<G> copy_deep (CopyFunc<G> copy_func);
5105                 public unowned Node<G> insert (int position, owned Node<G> node);
5106                 public unowned Node<G> insert_before (Node<G> sibling, owned Node<G> node);
5107                 public unowned Node<G> insert_after (Node<G> sibling, owned Node<G> node);
5108                 public unowned Node<G> append (owned Node<G> node);
5109                 public unowned Node<G> prepend (owned Node<G> node);
5110                 public unowned Node<G> insert_data (int position, owned G data);
5111                 public unowned Node<G> insert_data_before (Node<G> sibling, owned G data);
5112                 public unowned Node<G> append_data (owned G data);
5113                 public unowned Node<G> prepend_data (owned G data);
5114                 public void reverse_children ();
5115                 public void traverse (TraverseType order, TraverseFlags flags, int max_depth, NodeTraverseFunc func);
5116                 public void children_foreach (TraverseFlags flags, NodeForeachFunc func);
5117                 public unowned Node<G> get_root ();
5118                 public unowned Node<G> find (TraverseType order, TraverseFlags flags, G data);
5119                 public unowned Node<G> find_child (TraverseFlags flags, G data);
5120                 public int child_index (G data);
5121                 public int child_position (Node<G> child);
5122                 public unowned Node<G> first_child ();
5123                 public unowned Node<G> last_child ();
5124                 public unowned Node<G> nth_child (uint n);
5125                 public unowned Node<G> first_sibling ();
5126                 public unowned Node<G> next_sibling ();
5127                 public unowned Node<G> prev_sibling ();
5128                 public unowned Node<G> last_sibling ();
5130                 [CCode (cname = "G_NODE_IS_LEAF")]
5131                 public bool is_leaf ();
5132                 [CCode (cname = "G_NODE_IS_ROOT")]
5133                 public bool is_root ();
5134                 public bool is_ancestor (Node<G> descendant);
5136                 public uint depth ();
5137                 public uint n_nodes (TraverseFlags flags);
5138                 public uint n_children ();
5139                 public uint max_height ();
5141                 [CCode (cname = "g_node_unlink")]
5142                 public void _unlink ();
5143                 [CCode (cname = "g_node_unlink_vala")]
5144                 public Node<G> unlink ()
5145                 {
5146                         void *ptr = this;
5147                         _unlink ();
5148                         return (Node<G>) (owned) ptr;
5149                 }
5151                 public G data;
5152                 public Node next;
5153                 public Node prev;
5154                 public Node parent;
5155                 public Node children;
5156         }
5158         /* Quarks */
5160         [CCode (type_id = "G_TYPE_UINT")]
5161         public struct Quark : uint32 {
5162                 public static Quark from_string (string str);
5163                 public static Quark try_string (string str);
5164                 public unowned string to_string ();
5165         }
5167         /* Keyed Data Lists */
5169         [CCode (cname = "GData*")]
5170         public struct Datalist<G> {
5171                 public Datalist ();
5172                 public void clear ();
5173                 [Version (since = "2.34")]
5174                 public G id_dup_data (Quark key_id, DuplicateFunc<G> dup_func);
5175                 public unowned G id_get_data (Quark key_id);
5176                 public void id_set_data (Quark key_id, owned G data);
5177                 public void id_set_data_full (Quark key_id, owned G data, DestroyNotify? destroy_func);
5178                 public void id_remove_data (Quark key_id);
5179                 public G id_remove_no_notify (Quark key_id);
5180                 [Version (since = "2.34")]
5181                 public bool id_replace_data (Quark key_id, G oldval, owned G newval, GLib.DestroyNotify? destroy, out GLib.DestroyNotify? old_destroy);
5182                 public void @foreach (DataForeachFunc<G> func);
5183                 public unowned G get_data (string key);
5184                 public void set_data_full (string key, owned G data, DestroyNotify? destry_func);
5185                 public G remove_no_notify (string key);
5186                 public void set_data (string key, owned G data);
5187                 public void remove_data (string key);
5188         }
5190         public delegate void DataForeachFunc<G> (Quark key_id, G data);
5191         public delegate G DuplicateFunc<G> (G data);
5193         /* GArray */
5195         [Compact]
5196         [Version (since = "2.22")]
5197         [CCode (ref_function = "g_array_ref", unref_function = "g_array_unref", type_id = "G_TYPE_ARRAY")]
5198         public class Array<G> {
5199                 [CCode (cname = "len")]
5200                 public uint length;
5201                 [CCode (cname = "data", array_length_cname = "len", array_length_type = "uint")]
5202                 public G[] data;
5204                 public Array (bool zero_terminated = true, bool clear = true, ulong element_size = 0);
5205                 [CCode (cname = "g_array_sized_new")]
5206                 public Array.sized (bool zero_terminated, bool clear, ulong element_size, uint reserved_size);
5207                 public void append_val (owned G value);
5208                 public void append_vals (void* data, uint len);
5209                 public void prepend_val (owned G value);
5210                 public void prepend_vals (void* data, uint len);
5211                 public void insert_val (uint index, owned G value);
5212                 public void insert_vals (uint index, void* data, uint len);
5213                 public void remove_index (uint index);
5214                 public void remove_index_fast (uint index);
5215                 public void remove_range (uint index, uint length);
5216                 public void sort (CompareFunc<G> compare_func);
5217                 public void sort_with_data (CompareDataFunc<G> compare_func);
5218                 [CCode (generic_type_pos = 0.1)]
5219                 public unowned G index (uint index);
5220                 public void set_size (uint length);
5221         }
5223         /* GTree */
5225         public delegate bool TraverseFunc<K,V> (K key, V value);
5227         [CCode (cprefix = "G_", has_type_id = false)]
5228         public enum TraverseType {
5229                 IN_ORDER,
5230                 PRE_ORDER,
5231                 POST_ORDER,
5232                 LEVEL_ORDER
5233         }
5235         public delegate int TreeSearchFunc<K> (K key);
5237         [Compact]
5238         [Version (since = "2.22")]
5239         [CCode (ref_function = "g_tree_ref", unref_function = "g_tree_unref")]
5240         public class Tree<K,V> {
5241                 [CCode (cname = "g_tree_new_full", simple_generics = true)]
5242                 public Tree (CompareDataFunc<K> key_compare_func);
5243                 [Version (deprecated_since = "vala-0.20", replacement = "Tree ()")]
5244                 public Tree.with_data (CompareDataFunc<K> key_compare_func);
5245                 public Tree.full (CompareDataFunc<K> key_compare_func, DestroyNotify? key_destroy_func, DestroyNotify? value_destroy_func);
5246                 public void insert (owned K key, owned V value);
5247                 public void replace (owned K key, owned V value);
5248                 public int nnodes ();
5249                 public int height ();
5250                 public unowned V lookup (K key);
5251                 public bool lookup_extended (K lookup_key, out unowned K orig_key, out unowned V value);
5252                 public void foreach (TraverseFunc<K,V> traverse_func);
5253                 public unowned V search (TreeSearchFunc<K> search_func);
5254                 [CCode (cname = "g_tree_search")]
5255                 public unowned V search_key (CompareFunc<K> search_func, K key);
5256                 public bool remove (K key);
5257                 public bool steal (K key);
5258         }
5260         /* Internationalization */
5262         [Version (since = "2.4")]
5263         [CCode (cname = "_", cheader_filename = "glib.h,glib/gi18n-lib.h")]
5264         public static unowned string _ ([FormatArg] string str);
5265         [Version (since = "2.4")]
5266         [CCode (cname = "Q_", cheader_filename = "glib.h,glib/gi18n-lib.h")]
5267         public static unowned string Q_ ([FormatArg] string str);
5268         [Version (since = "2.4")]
5269         [CCode (cname = "N_", cheader_filename = "glib.h,glib/gi18n-lib.h")]
5270         public static unowned string N_ ([FormatArg] string str);
5271         [Version (since = "2.16")]
5272         [CCode (cname = "C_", cheader_filename = "glib.h,glib/gi18n-lib.h")]
5273         public static unowned string C_ (string context, [FormatArg] string str);
5274         [Version (since = "2.18")]
5275         [CCode (cname = "NC_", cheader_filename = "glib.h,glib/gi18n-lib.h")]
5276         public static unowned string NC_ (string context, [FormatArg] string str);
5277         [CCode (cname = "ngettext", cheader_filename = "glib.h,glib/gi18n-lib.h")]
5278         public static unowned string ngettext (string msgid, [FormatArg] string msgid_plural, ulong n);
5279         [Version (since = "2.18")]
5280         [CCode (cname = "g_dgettext", cheader_filename = "glib/gi18n-lib.h")]
5281         public static unowned string dgettext (string? domain, [FormatArg] string msgid);
5282         [Version (since = "2.26")]
5283         [CCode (cname = "g_dcgettext", cheader_filename = "glib/gi18n-lib.h")]
5284         public static unowned string dcgettext (string? domain, [FormatArg] string msgid, int category);
5285         [Version (since = "2.18")]
5286         [CCode (cname = "g_dngettext", cheader_filename = "glib/gi18n-lib.h")]
5287         public static unowned string dngettext (string? domain, string msgid, [FormatArg] string msgid_plural, ulong n);
5288         [Version (since = "2.16")]
5289         [CCode (cname = "g_dpgettext", cheader_filename = "glib/gi18n-lib.h")]
5290         public static unowned string dpgettext (string? domain, [FormatArg] string msgctxid, size_t msgidoffset);
5291         [Version (since = "2.18")]
5292         [CCode (cname = "g_dpgettext2", cheader_filename = "glib/gi18n-lib.h")]
5293         public static unowned string dpgettext2 (string? domain, string context, [FormatArg] string msgid);
5295         [CCode (cname = "int", cprefix = "LC_", cheader_filename = "locale.h", has_type_id = false)]
5296         public enum LocaleCategory {
5297                 ALL,
5298                 COLLATE,
5299                 CTYPE,
5300                 MESSAGES,
5301                 MONETARY,
5302                 NUMERIC,
5303                 TIME
5304         }
5306         namespace Intl {
5307                 [CCode (cname = "setlocale", cheader_filename = "locale.h")]
5308                 public static unowned string? setlocale (LocaleCategory category = GLib.LocaleCategory.ALL, string? locale = "");
5309                 [CCode (cname = "bindtextdomain", cheader_filename = "glib/gi18n-lib.h")]
5310                 public static unowned string? bindtextdomain (string domainname, string? dirname);
5311                 [CCode (cname = "textdomain", cheader_filename = "glib/gi18n-lib.h")]
5312                 public static unowned string? textdomain (string? domainname);
5313                 [CCode (cname = "bind_textdomain_codeset", cheader_filename = "glib/gi18n-lib.h")]
5314                 public static unowned string? bind_textdomain_codeset (string domainname, string? codeset);
5315                 [Version (since = "2.6")]
5316                 [CCode (cname = "g_get_language_names", array_length = false, array_null_terminated = true)]
5317                 public static unowned string[] get_language_names ();
5318                 [Version (since = "2.4")]
5319                 [CCode (cname = "g_strip_context", cheader_filename = "glib/gi18n-lib.h")]
5320                 public static unowned string strip_context (string msgid, string msgval);
5321         }
5323         [Compact]
5324         public class PatternSpec {
5325                 public PatternSpec (string pattern);
5326                 public bool equal (PatternSpec pspec);
5327                 [CCode (cname = "g_pattern_match")]
5328                 public bool match (uint string_length, string str, string? str_reversed);
5329                 [CCode (cname = "g_pattern_match_string")]
5330                 public bool match_string (string str);
5331                 [CCode (cname = "g_pattern_match_simple")]
5332                 public static bool match_simple (string pattern, string str);
5333         }
5335         [CCode (lower_case_cprefix = "glib_version_")]
5336         namespace Version {
5337                 [CCode (cname = "glib_major_version")]
5338                 public const uint major;
5339                 [CCode (cname = "glib_minor_version")]
5340                 public const uint minor;
5341                 [CCode (cname = "glib_micro_version")]
5342                 public const uint micro;
5343                 [CCode (cname = "glib_check_version")]
5344                 public static unowned string? check (uint required_major, uint required_minor = 0, uint required_micro = 0);
5346                 [CCode (cname = "GLIB_MAJOR_VERSION")]
5347                 public const uint MAJOR;
5348                 [CCode (cname = "GLIB_MINOR_VERSION")]
5349                 public const uint MINOR;
5350                 [CCode (cname = "GLIB_MICRO_VERSION")]
5351                 public const uint MICRO;
5352                 [CCode (cname = "GLIB_CHECK_VERSION")]
5353                 public static bool CHECK (uint required_major, uint required_minor = 0, uint required_micro = 0);
5355                 [CCode (cname = "G_ENCODE_VERSION")]
5356                 public static uint encode (uint major, uint minor);
5358                 public const uint CUR_STABLE;
5359                 public const uint PREV_STABLE;
5360                 public const uint MIN_REQUIRED;
5361                 public const uint MAX_ALLOWED;
5363                 public const uint @2_26;
5364                 public const uint @2_28;
5365                 public const uint @2_30;
5366                 public const uint @2_32;
5367                 public const uint @2_34;
5368                 public const uint @2_36;
5369                 public const uint @2_38;
5370                 public const uint @2_40;
5371                 public const uint @2_42;
5372                 public const uint @2_44;
5373                 public const uint @2_46;
5374                 public const uint @2_48;
5375                 public const uint @2_50;
5376                 public const uint @2_52;
5377                 public const uint @2_54;
5378                 public const uint @2_56;
5380                 [CCode (cname = "glib_binary_age")]
5381                 public const uint binary_age;
5382                 [CCode (cname = "glib_interface_age")]
5383                 public const uint interface_age;
5384         }
5386         namespace Win32 {
5387                 public enum OSType {
5388                         [CCode (cname = "G_WIN32_OS_ANY")]
5389                         ANY,
5390                         [CCode (cname = "G_WIN32_OS_WORKSTATION")]
5391                         WORKSTATION,
5392                         [CCode (cname = "G_WIN32_OS_SERVER")]
5393                         SERVER,
5394                 }
5395                 [Version (since = "2.44")]
5396                 public bool check_windows_version (int major, int minor, int spver, GLib.Win32.OSType os_type);
5398                 public string error_message (int error);
5399                 public string getlocale ();
5400                 [Version (since = "2.16")]
5401                 public string get_package_installation_directory_of_module (void* hmodule);
5402                 public uint get_windows_version ();
5403                 [Version (since = "2.8")]
5404                 public string locale_filename_from_utf8 (string utf8filename);
5405                 [CCode (cname = "G_WIN32_HAVE_WIDECHAR_API")]
5406                 public bool have_widechar_api ();
5407                 [CCode (cname = "G_WIN32_IS_NT_BASED")]
5408                 public bool is_nt_based ();
5409                 [Version (since = "2.40")]
5410                 [CCode (array_length = false, array_null_terminated = true)]
5411                 public string[] get_command_line ();
5412         }
5414         [Compact]
5415         [Immutable]
5416         [Version (since = "2.24")]
5417         [CCode (copy_function = "g_variant_type_copy", free_function = "g_variant_type_free", type_id = "G_TYPE_VARIANT_TYPE")]
5418         public class VariantType {
5419                 [CCode (cname = "G_VARIANT_TYPE_BOOLEAN")]
5420                 public static VariantType BOOLEAN;
5421                 [CCode (cname = "G_VARIANT_TYPE_BYTE")]
5422                 public static VariantType BYTE;
5423                 [CCode (cname = "G_VARIANT_TYPE_INT16")]
5424                 public static VariantType INT16;
5425                 [CCode (cname = "G_VARIANT_TYPE_UINT16")]
5426                 public static VariantType UINT16;
5427                 [CCode (cname = "G_VARIANT_TYPE_INT32")]
5428                 public static VariantType INT32;
5429                 [CCode (cname = "G_VARIANT_TYPE_UINT32")]
5430                 public static VariantType UINT32;
5431                 [CCode (cname = "G_VARIANT_TYPE_INT64")]
5432                 public static VariantType INT64;
5433                 [CCode (cname = "G_VARIANT_TYPE_UINT64")]
5434                 public static VariantType UINT64;
5435                 [CCode (cname = "G_VARIANT_TYPE_HANDLE")]
5436                 public static VariantType HANDLE;
5437                 [CCode (cname = "G_VARIANT_TYPE_DOUBLE")]
5438                 public static VariantType DOUBLE;
5439                 [CCode (cname = "G_VARIANT_TYPE_STRING")]
5440                 public static VariantType STRING;
5441                 [CCode (cname = "G_VARIANT_TYPE_OBJECT_PATH")]
5442                 public static VariantType OBJECT_PATH;
5443                 [CCode (cname = "G_VARIANT_TYPE_SIGNATURE")]
5444                 public static VariantType SIGNATURE;
5445                 [CCode (cname = "G_VARIANT_TYPE_VARIANT")]
5446                 public static VariantType VARIANT;
5447                 [CCode (cname = "G_VARIANT_TYPE_UNIT")]
5448                 public static VariantType UNIT;
5449                 [CCode (cname = "G_VARIANT_TYPE_ANY")]
5450                 public static VariantType ANY;
5451                 [CCode (cname = "G_VARIANT_TYPE_BASIC")]
5452                 public static VariantType BASIC;
5453                 [CCode (cname = "G_VARIANT_TYPE_MAYBE")]
5454                 public static VariantType MAYBE;
5455                 [CCode (cname = "G_VARIANT_TYPE_ARRAY")]
5456                 public static VariantType ARRAY;
5457                 [CCode (cname = "G_VARIANT_TYPE_TUPLE")]
5458                 public static VariantType TUPLE;
5459                 [CCode (cname = "G_VARIANT_TYPE_DICT_ENTRY")]
5460                 public static VariantType DICT_ENTRY;
5461                 [CCode (cname = "G_VARIANT_TYPE_DICTIONARY")]
5462                 public static VariantType DICTIONARY;
5463                 [CCode (cname = "G_VARIANT_TYPE_STRING_ARRAY")]
5464                 public static VariantType STRING_ARRAY;
5465                 [CCode (cname = "G_VARIANT_TYPE_OBJECT_PATH_ARRAY")]
5466                 public static VariantType OBJECT_PATH_ARRAY;
5467                 [CCode (cname = "G_VARIANT_TYPE_BYTESTRING")]
5468                 public static VariantType BYTESTRING;
5469                 [CCode (cname = "G_VARIANT_TYPE_BYTESTRING_ARRAY")]
5470                 public static VariantType BYTESTRING_ARRAY;
5471                 [Version (since = "2.30")]
5472                 [CCode (cname = "G_VARIANT_TYPE_VARDICT")]
5473                 public static VariantType VARDICT;
5475                 public static bool string_is_valid (string type_string);
5476                 public static bool string_scan (string type_string, char *limit, out char* endptr);
5478                 public VariantType (string type_string);
5479                 public size_t get_string_length ();
5480                 public char* peek_string ();
5481                 public string dup_string ();
5483                 public bool is_definite ();
5484                 public bool is_container ();
5485                 public bool is_basic ();
5486                 public bool is_maybe ();
5487                 public bool is_array ();
5488                 public bool is_tuple ();
5489                 public bool is_dict_entry ();
5490                 public bool is_variant ();
5492                 public uint hash ();
5493                 public bool equal (VariantType other);
5494                 public bool is_subtype_of (VariantType supertype);
5496                 public unowned VariantType element ();
5497                 public unowned VariantType first ();
5498                 public unowned VariantType next ();
5499                 public unowned VariantType n_items ();
5500                 public unowned VariantType key ();
5501                 public unowned VariantType value ();
5503                 public VariantType.array (VariantType element);
5504                 public VariantType.maybe (VariantType element);
5505                 public VariantType.tuple (VariantType[] items);
5506                 public VariantType.dict_entry (VariantType key, VariantType value);
5507         }
5509         [Compact]
5510         [Version (since = "2.24")]
5511         [CCode (ref_function = "g_variant_ref", unref_function = "g_variant_unref", ref_sink_function = "g_variant_ref_sink", type_id = "G_TYPE_VARIANT", marshaller_type_name = "VARIANT", param_spec_function = "g_param_spec_variant", get_value_function = "g_value_get_variant", set_value_function = "g_value_set_variant", take_value_function = "g_value_take_variant", type_signature = "v")]
5512         public class Variant {
5513                 [CCode (has_type_id = false)]
5514                 public enum Class {
5515                         BOOLEAN, BYTE, INT16, UINT16, INT32, UINT32, INT64,
5516                         UINT64, HANDLE, DOUBLE, STRING, OBJECT_PATH,
5517                         SIGNATURE, VARIANT, MAYBE, ARRAY, TUPLE, DICT_ENTRY
5518                 }
5520                 public unowned VariantType get_type ();
5521                 public unowned string get_type_string ();
5522                 public bool is_of_type (VariantType type);
5523                 public bool is_container ();
5524                 [Version (since = "2.26")]
5525                 public bool is_floating ();
5526                 public Class classify ();
5527                 [Version (since = "2.26")]
5528                 public int compare (Variant other);
5530                 public Variant.boolean (bool value);
5531                 public Variant.byte (uchar value);
5532                 public Variant.int16 (int16 value);
5533                 public Variant.uint16 (uint16 value);
5534                 public Variant.int32 (int32 value);
5535                 public Variant.uint32 (uint32 value);
5536                 public Variant.int64 (int64 value);
5537                 public Variant.uint64 (uint64 value);
5538                 public Variant.handle (int32 value);
5539                 public Variant.double (double value);
5540                 public Variant.string (string value);
5541                 [Version (since = "2.26")]
5542                 public Variant.bytestring (string value);
5543                 public Variant.object_path (string object_path);
5544                 public static bool is_object_path (string object_path);
5545                 public Variant.signature (string signature);
5546                 public static bool is_signature (string signature);
5548                 public bool get_boolean ();
5549                 public uint8 get_byte ();
5550                 public int16 get_int16 ();
5551                 public uint16 get_uint16 ();
5552                 public int32 get_int32 ();
5553                 public uint32 get_uint32 ();
5554                 public int64 get_int64 ();
5555                 public uint64 get_uint64 ();
5556                 public int32 get_handle ();
5557                 public double get_double ();
5558                 public unowned string get_string (out size_t length = null);
5559                 public string dup_string (out size_t length = null);
5560                 [Version (since = "2.26")]
5561                 public unowned string get_bytestring ();
5562                 [Version (since = "2.26")]
5563                 public string dup_bytestring (out size_t length);
5565                 public Variant.strv (string[] value);
5566                 [CCode (array_length_type = "size_t")]
5567 #if VALA_0_26
5568                 public (unowned string)[] get_strv ();
5569 #else
5570                 public string*[] get_strv ();
5571 #endif
5572                 [CCode (array_length_type = "size_t")]
5573                 public string[] dup_strv ();
5575                 [Version (since = "2.26")]
5576                 public Variant.bytestring_array (string[] value);
5577                 [Version (since = "2.26")]
5578                 [CCode (array_length_type = "size_t")]
5579 #if VALA_0_26
5580                 public (unowned string)[] get_bytestring_array ();
5581 #else
5582                 public string*[] get_bytestring_array ();
5583 #endif
5584                 [Version (since = "2.26")]
5585                 [CCode (array_length_type = "size_t")]
5586                 public string[] dup_bytestring_array ();
5588                 [Version (since = "2.30")]
5589                 public Variant.objv (string[] value);
5590                 [Version (since = "2.30")]
5591                 [CCode (array_length_type = "size_t")]
5592 #if VALA_0_26
5593                 public (unowned string)[] get_objv ();
5594 #else
5595                 public string*[] get_objv ();
5596 #endif
5597                 [Version (since = "2.30")]
5598                 [CCode (array_length_type = "size_t")]
5599                 public string[] dup_objv ();
5601                 public Variant (string format, ...);
5602                 // note: the function changes its behaviour when end_ptr is null, so 'out char *' is wrong
5603                 public Variant.va (string format, char **end_ptr, va_list *app);
5604                 public void get (string format, ...);
5605                 public void get_va (string format, char **end_ptr, va_list *app);
5607                 public Variant.variant (Variant value);
5608                 public Variant.maybe (VariantType? child_type, Variant? child);
5609                 public Variant.array (VariantType? child_type, Variant[] children);
5610                 [Version (since = "2.32")]
5611                 [CCode (simple_generics = true)]
5612                 public static Variant new_fixed_array<T> (VariantType? element_type, [CCode (array_length_type = "gsize")] T[] elements, size_t element_size);
5613                 public Variant.tuple (Variant[] children);
5614                 public Variant.dict_entry (Variant key, Variant value);
5615                 public Variant get_variant ();
5616                 public Variant? get_maybe ();
5618                 public size_t n_children ();
5619                 public Variant get_child_value (size_t index);
5620                 public void get_child (size_t index, string format_string, ...);
5622                 [Version (since = "2.28")]
5623                 public Variant? lookup_value (string key, VariantType? expected_type);
5624                 [Version (since = "2.28")]
5625                 public bool lookup (string key, string format_string, ...);
5627                 public size_t get_size ();
5628                 public void *get_data ();
5629                 public void store (void *data);
5631                 public string print (bool type_annotate);
5632                 public StringBuilder print_string (StringBuilder? builder, bool type_annotate);
5634                 public uint hash ();
5635                 public bool equal (Variant other);
5637                 public Variant byteswap ();
5638                 public Variant get_normal_form ();
5639                 public bool is_normal_form ();
5640                 [CCode (returns_floating_reference = true, simple_generics = true)]
5641                 public static Variant new_from_data<T> (VariantType type, uchar[] data, bool trusted, [CCode (destroy_notify_pos = 3.9)] owned T? owner = null);
5643                 [CCode (cname = "g_variant_iter_new")]
5644                 public VariantIter iterator ();
5646                 public static Variant parse (VariantType? type, string text, char *limit = null, char **endptr = null) throws GLib.VariantParseError;
5647                 public Variant.parsed (string format_string, ...);
5649                 [Version (since = "2.34")]
5650                 public bool check_format_string (string format_string, bool copy_only);
5652                 [Version (since = "2.36")]
5653                 public Variant.from_bytes (VariantType type, Bytes bytes, bool trusted);
5654                 [Version (since = "2.36")]
5655                 public Bytes get_data_as_bytes ();
5657                 [Version (since = "2.38")]
5658                 public Variant.printf (string format_string, ...);
5659                 [Version (since = "2.38")]
5660                 public Variant.take_string (string str);
5662                 [Version (since = "2.40")]
5663                 public static void parse_error_print_context (GLib.VariantParseError error, string source_str);
5664         }
5666         [Version (since = "2.24")]
5667         public errordomain VariantParseError {
5668                 FAILED,
5669                 BASIC_TYPE_EXPECTED,
5670                 CANNOT_INFER_TYPE,
5671                 DEFINITE_TYPE_EXPECTED,
5672                 INPUT_NOT_AT_END,
5673                 INVALID_CHARACTER,
5674                 INVALID_FORMAT_STRING,
5675                 INVALID_OBJECT_PATH,
5676                 INVALID_SIGNATURE,
5677                 INVALID_TYPE_STRING,
5678                 NO_COMMON_TYPE,
5679                 NUMBER_OUT_OF_RANGE,
5680                 NUMBER_TOO_BIG,
5681                 TYPE_ERROR,
5682                 UNEXPECTED_TOKEN,
5683                 UNKNOWN_KEYWORD,
5684                 UNTERMINATED_STRING_CONSTANT,
5685                 VALUE_EXPECTED;
5686                 public static GLib.Quark quark ();
5687         }
5689         [Compact]
5690         [Version (since = "2.24")]
5691         public class VariantIter {
5692                 public VariantIter (Variant value);
5693                 public size_t n_children ();
5694                 public Variant? next_value ();
5695                 public bool next (string format_string, ...);
5696         }
5698         [Compact]
5699         [Version (since = "2.24")]
5700         [CCode (ref_function = "g_variant_builder_ref", unref_function = "g_variant_builder_unref")]
5701         public class VariantBuilder {
5702                 public VariantBuilder (VariantType type);
5703                 public void open (VariantType type);
5704                 public void close ();
5705                 public void add_value (Variant value);
5706                 public void add (string format_string, ...);
5707                 [CCode (returns_floating_reference = true)]
5708                 public Variant end ();
5709         }
5711         [Version (since = "2.40")]
5712         [Compact, CCode (ref_function = "g_variant_dict_ref", unref_function = "g_variant_dict_unref")]
5713         public class VariantDict {
5714                 public VariantDict (GLib.Variant? from_asv = null);
5715                 public bool lookup (string key, string format_string, ...);
5716                 public GLib.Variant lookup_value (string key, GLib.VariantType expected_type);
5717                 public bool contains (string key);
5718                 public void insert (string key, string format_string, ...);
5719                 public void insert_value (string key, GLib.Variant value);
5720                 public bool remove (string key);
5721                 public void clear ();
5722                 [CCode (returns_floating_reference = true)]
5723                 public GLib.Variant end ();
5724         }
5726         [CCode (cname = "char", const_cname = "const char", copy_function = "g_strdup", free_function = "g_free", cheader_filename = "stdlib.h,string.h,glib.h", type_id = "G_TYPE_STRING", marshaller_type_name = "STRING", param_spec_function = "g_param_spec_string", get_value_function = "g_value_get_string", set_value_function = "g_value_set_string", take_value_function = "g_value_take_string", type_signature = "o")]
5727         public class ObjectPath : string {
5728                 [CCode (cname = "g_strdup")]
5729                 public ObjectPath (string path);
5730         }
5732         [CCode (cname = "char", const_cname = "const char", copy_function = "g_strdup", free_function = "g_free", cheader_filename = "stdlib.h,string.h,glib.h", type_id = "G_TYPE_STRING", marshaller_type_name = "STRING", param_spec_function = "g_param_spec_string", get_value_function = "g_value_get_string", set_value_function = "g_value_set_string", take_value_function = "g_value_take_string")]
5733         public class BusName : string {
5734                 [CCode (cname = "g_strdup")]
5735                 public BusName (string bus_name);
5736         }
5738         [CCode (cname = "G_LIKELY", cheader_filename = "glib.h")]
5739         public static bool likely (bool expression);
5740         [CCode (cname = "G_UNLIKELY", cheader_filename = "glib.h")]
5741         public static bool unlikely (bool expression);
5742         [Version (since = "2.20")]
5743         [CCode (cname = "G_STATIC_ASSERT", cheader_filename = "glib.h")]
5744         public static void static_assert (bool expression);
5746         [CCode (simple_generics = true, cname = "g_qsort_with_data")]
5747         private static void _qsort_with_data<T> (T[] elems, size_t size, [CCode (type = "GCompareDataFunc")] GLib.CompareDataFunc<T> compare_func);
5749         [CCode (cname = "_vala_g_qsort_with_data")]
5750         public static void qsort_with_data<T> (T[] elems, size_t size, [CCode (type = "GCompareDataFunc")] GLib.CompareDataFunc<T> compare_func) {
5751                 _qsort_with_data<T*> (elems, size, (a, b) => {
5752                                 return compare_func (*a, *b);
5753                         });
5754         }
5756         [Version (since = "2.54")]
5757         public errordomain NumberParserError {
5758                 INVALID,
5759                 OUT_OF_BOUNDS;
5760                 public static GLib.Quark quark ();
5761         }
5763         /* Unix-specific functions. All of these have to include glib-unix.h. */
5764         namespace Unix {
5765                 [Version (since = "2.30")]
5766                 [CCode (cheader_filename = "glib-unix.h", cname = "g_unix_signal_add_full")]
5767                 public static uint signal_add (int signum, owned GLib.SourceFunc handler, [CCode (pos = 0.9)] int priority = Priority.DEFAULT);
5769                 [CCode (cheader_filename = "glib-unix.h", cname = "GSource")]
5770                 public class SignalSource : GLib.Source {
5771                         public SignalSource (int signum);
5772                 }
5774                 [Version (since = "2.30")]
5775                 [CCode (cheader_filename = "glib-unix.h")]
5776                 public static bool open_pipe ([CCode (array_length = false, array_null_terminated = false)] int[] fds, int flags) throws GLib.Error;
5777                 [Version (since = "2.30")]
5778                 [CCode (cheader_filename = "glib-unix.h")]
5779                 public static bool set_fd_nonblocking (int fd, bool nonblock) throws GLib.Error;
5780         }
5782         [CCode (cname = "GUnicodeScript", cprefix = "G_UNICODE_SCRIPT_", has_type_id = false)]
5783         public enum UnicodeScript {
5784                 INVALID_CODE,
5785                 COMMON,
5786                 INHERITED,
5787                 ARABIC,
5788                 ARMENIAN,
5789                 BENGALI,
5790                 BOPOMOFO,
5791                 CHEROKEE,
5792                 COPTIC,
5793                 CYRILLIC,
5794                 DESERET,
5795                 DEVANAGARI,
5796                 ETHIOPIC,
5797                 GEORGIAN,
5798                 GOTHIC,
5799                 GREEK,
5800                 GUJARATI,
5801                 GURMUKHI,
5802                 HAN,
5803                 HANGUL,
5804                 HEBREW,
5805                 HIRAGANA,
5806                 KANNADA,
5807                 KATAKANA,
5808                 KHMER,
5809                 LAO,
5810                 LATIN,
5811                 MALAYALAM,
5812                 MONGOLIAN,
5813                 MYANMAR,
5814                 OGHAM,
5815                 OLD_ITALIC,
5816                 ORIYA,
5817                 RUNIC,
5818                 SINHALA,
5819                 SYRIAC,
5820                 TAMIL,
5821                 TELUGU,
5822                 THAANA,
5823                 THAI,
5824                 TIBETAN,
5825                 CANADIAN_ABORIGINAL,
5826                 YI,
5827                 TAGALOG,
5828                 HANUNOO,
5829                 BUHID,
5830                 TAGBANWA,
5832                 BRAILLE,
5833                 CYPRIOT,
5834                 LIMBU,
5835                 OSMANYA,
5836                 SHAVIAN,
5837                 LINEAR_B,
5838                 TAI_LE,
5839                 UGARITIC,
5841                 NEW_TAI_LUE,
5842                 BUGINESE,
5843                 GLAGOLITIC,
5844                 TIFINAGH,
5845                 SYLOTI_NAGRI,
5846                 OLD_PERSIAN,
5847                 KHAROSHTHI,
5849                 UNKNOWN,
5850                 BALINESE,
5851                 CUNEIFORM,
5852                 PHOENICIAN,
5853                 PHAGS_PA,
5854                 NKO,
5856                 KAYAH_LI,
5857                 LEPCHA,
5858                 REJANG,
5859                 SUNDANESE,
5860                 SAURASHTRA,
5861                 CHAM,
5862                 OL_CHIKI,
5863                 VAI,
5864                 CARIAN,
5865                 LYCIAN,
5866                 LYDIAN,
5868                 /* Unicode-5.2 additions */
5869                 AVESTAN,                /* Avst */
5870                 BAMUM,                  /* Bamu */
5871                 EGYPTIAN_HIEROGLYPHS,   /* Egyp */
5872                 IMPERIAL_ARAMAIC,       /* Armi */
5873                 INSCRIPTIONAL_PAHLAVI,  /* Phli */
5874                 INSCRIPTIONAL_PARTHIAN, /* Prti */
5875                 JAVANESE,               /* Java */
5876                 KAITHI,                 /* Kthi */
5877                 LISU,                   /* Lisu */
5878                 MEETEI_MAYEK,           /* Mtei */
5879                 OLD_SOUTH_ARABIAN,      /* Sarb */
5880                 OLD_TURKIC,             /* Orkh */
5881                 SAMARITAN,              /* Samr */
5882                 TAI_THAM,               /* Lana */
5883                 TAI_VIET,               /* Tavt */
5885                 /* Unicode-6.0 additions */
5886                 BATAK,                  /* Batk */
5887                 BRAHMI,                 /* Brah */
5888                 MANDAIC,                /* Mand */
5890                 /* Unicode-6.1 additions */
5891                 CHAKMA,                 /* Cakm */
5892                 MEROITIC_CURSIVE,       /* Merc */
5893                 MEROITIC_HIEROGLYPHS,   /* Mero */
5894                 MIAO,                   /* Plrd */
5895                 SHARADA,                /* Shrd */
5896                 SORA_SOMPENG,           /* Sora */
5897                 TAKRI,                  /* Takr */
5899                 /* Unicode 7.0 additions */
5900                 BASSA_VAH,              /* Bass */
5901                 CAUCASIAN_ALBANIAN,     /* Aghb */
5902                 DUPLOYAN,               /* Dupl */
5903                 ELBASAN,                /* Elba */
5904                 GRANTHA,                /* Gran */
5905                 KHOJKI,                 /* Khoj */
5906                 KHUDAWADI,              /* Sind */
5907                 LINEAR_A,               /* Lina */
5908                 MAHAJANI,               /* Mahj */
5909                 MANICHAEAN,             /* Manu */
5910                 MENDE_KIKAKUI,          /* Mend */
5911                 MODI,                   /* Modi */
5912                 MRO,                    /* Mroo */
5913                 NABATAEAN,              /* Nbat */
5914                 OLD_NORTH_ARABIAN,      /* Narb */
5915                 OLD_PERMIC,             /* Perm */
5916                 PAHAWH_HMONG,           /* Hmng */
5917                 PALMYRENE,              /* Palm */
5918                 PAU_CIN_HAU,            /* Pauc */
5919                 PSALTER_PAHLAVI,        /* Phlp */
5920                 SIDDHAM,                /* Sidd */
5921                 TIRHUTA,                /* Tirh */
5922                 WARANG_CITI,            /* Wara */
5924                 /* Unicode 8.0 additions */
5925                 AHOM,                   /* Ahom */
5926                 ANATOLIAN_HIEROGLYPHS,  /* Hluw */
5927                 HATRAN,                 /* Hatr */
5928                 MULTANI,                /* Mult */
5929                 OLD_HUNGARIAN,          /* Hung */
5930                 SIGNWRITING,            /* Sgnw */
5932                 /* Unicode 9.0 additions */
5933                 ADLAM,                  /* Adlm */
5934                 BHAIKSUKI,              /* Bhks */
5935                 MARCHEN,                /* Marc */
5936                 NEWA,                   /* Newa */
5937                 OSAGE,                  /* Osge */
5938                 TANGUT,                 /* Tang */
5940                 /* Unicode 10.0 additions */
5941                 MASARAM_GONDI,          /* Gonm */
5942                 NUSHU,                  /* Nshu */
5943                 SOYOMBO,                /* Soyo */
5944                 ZANABAZAR_SQUARE;       /* Zanb */
5946                 [CCode (cname = "g_unicode_script_to_iso15924")]
5947                 public uint32 to_iso15924 ();
5948                 [CCode (cname = "g_unicode_script_from_iso15924")]
5949                 public static GLib.UnicodeScript from_iso15924 (uint32 iso15924);
5950         }
5952         [CCode (cname = "GUnicodeType", cprefix = "G_UNICODE_", has_type_id = false)]
5953         public enum UnicodeType {
5954                 CONTROL,
5955                 FORMAT,
5956                 UNASSIGNED,
5957                 PRIVATE_USE,
5958                 SURROGATE,
5959                 LOWERCASE_LETTER,
5960                 MODIFIER_LETTER,
5961                 OTHER_LETTER,
5962                 TITLECASE_LETTER,
5963                 UPPERCASE_LETTER,
5964                 COMBINING_MARK,
5965                 ENCLOSING_MARK,
5966                 NON_SPACING_MARK,
5967                 DECIMAL_NUMBER,
5968                 LETTER_NUMBER,
5969                 OTHER_NUMBER,
5970                 CONNECT_PUNCTUATION,
5971                 DASH_PUNCTUATION,
5972                 CLOSE_PUNCTUATION,
5973                 FINAL_PUNCTUATION,
5974                 INITIAL_PUNCTUATION,
5975                 OTHER_PUNCTUATION,
5976                 OPEN_PUNCTUATION,
5977                 CURRENCY_SYMBOL,
5978                 MODIFIER_SYMBOL,
5979                 MATH_SYMBOL,
5980                 OTHER_SYMBOL,
5981                 LINE_SEPARATOR,
5982                 PARAGRAPH_SEPARATOR,
5983                 SPACE_SEPARATOR
5984         }
5986         [CCode (cname = "GUnicodeBreakType", cprefix = "G_UNICODE_BREAK_", has_type_id = false)]
5987         public enum UnicodeBreakType {
5988                 MANDATORY,
5989                 CARRIAGE_RETURN,
5990                 LINE_FEED,
5991                 COMBINING_MARK,
5992                 SURROGATE,
5993                 ZERO_WIDTH_SPACE,
5994                 INSEPARABLE,
5995                 NON_BREAKING_GLUE,
5996                 CONTINGENT,
5997                 SPACE,
5998                 AFTER,
5999                 BEFORE,
6000                 BEFORE_AND_AFTER,
6001                 HYPHEN,
6002                 NON_STARTER,
6003                 OPEN_PUNCTUATION,
6004                 CLOSE_PUNCTUATION,
6005                 QUOTATION,
6006                 EXCLAMATION,
6007                 IDEOGRAPHIC,
6008                 NUMERIC,
6009                 INFIX_SEPARATOR,
6010                 SYMBOL,
6011                 ALPHABETIC,
6012                 PREFIX,
6013                 POSTFIX,
6014                 COMPLEX_CONTEXT,
6015                 AMBIGUOUS,
6016                 UNKNOWN,
6017                 NEXT_LINE,
6018                 WORD_JOINER,
6019                 HANGUL_L_JAMO,
6020                 HANGUL_V_JAMO,
6021                 HANGUL_T_JAMO,
6022                 HANGUL_LV_SYLLABLE,
6023                 HANGUL_LVT_SYLLABLE,
6024                 CLOSE_PARANTHESIS,
6025                 CONDITIONAL_JAPANESE_STARTER,
6026                 HEBREW_LETTER,
6027                 REGIONAL_INDICATOR,
6028                 EMOJI_BASE,
6029                 EMOJI_MODIFIER,
6030                 ZERO_WIDTH_JOINER
6031         }
6033         [CCode (cname = "GNormalizeMode", cprefix = "G_NORMALIZE_", has_type_id = false)]
6034         public enum NormalizeMode {
6035                 DEFAULT,
6036                 NFD,
6037                 DEFAULT_COMPOSE,
6038                 NFC,
6039                 ALL,
6040                 NFKD,
6041                 ALL_COMPOSE,
6042                 NFKC
6043         }