3 * Copyright (C) 2006-2014 Jürg Billeter
4 * Copyright (C) 2006-2008 Raffaele Sandrini
5 * Copyright (C) 2007 Mathias Hasselmann
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.
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.
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
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.
26 * Jürg Billeter <j@bitron.ch>
27 * Raffaele Sandrini <rasa@gmx.ch>
28 * Mathias Hasselmann <mathias.hasselmann@gmx.de>
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")]
36 public string to_string () {
44 public static bool parse (string str) {
51 public static bool try_parse (string str, out bool result = null) {
55 } else if (str == "false") {
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)]
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);
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);
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)]
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")]
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);
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)]
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);
191 [GIR (name = "gshort")]
192 [CCode (cname = "gshort", cheader_filename = "glib.h", has_type_id = false, 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")]
214 [GIR (name = "gushort")]
215 [CCode (cname = "gushort", cheader_filename = "glib.h", has_type_id = false, 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);
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)]
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")]
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);
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);
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);
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);
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);
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);
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)]
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);
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);
467 [GIR (name = "gint16")]
468 [CCode (cname = "gint16", cheader_filename = "glib.h", default_value = "0", type_signature = "n", has_type_id = false)]
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);
506 [GIR (name = "guint16")]
507 [CCode (cname = "guint16", cheader_filename = "glib.h", default_value = "0U", type_signature = "q", has_type_id = false)]
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 ();
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);
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 ();
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")]
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);
691 [Version (since = "2.12")]
692 public static bool try_parse (string str, out int64 result = null) {
694 result = ascii_strtoll (str, out endptr, 0);
695 if (endptr == (char*) str + str.length) {
704 [GIR (name = "guint64")]
705 [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")]
706 [IntegerType (rank = 11)]
707 public struct uint64 {
708 [CCode (cname = "0ULL")]
709 public const uint64 MIN;
710 [CCode (cname = "G_MAXUINT64")]
711 public const uint64 MAX;
713 [CCode (cname = "G_GUINT64_FORMAT")]
714 public const string FORMAT;
715 [CCode (cname = "G_GINT64_MODIFIER")]
716 public const string FORMAT_MODIFIER;
718 [CCode (cname = "g_strdup_printf", instance_pos = -1)]
719 public string to_string (string format = "%" + FORMAT);
721 [CCode (cname = "MIN")]
722 public static uint64 min (uint64 a, uint64 b);
723 [CCode (cname = "MAX")]
724 public static uint64 max (uint64 a, uint64 b);
725 [CCode (cname = "CLAMP")]
726 public uint64 clamp (uint64 low, uint64 high);
728 [CCode (cname = "GUINT64_TO_BE")]
729 public uint64 to_big_endian ();
730 [CCode (cname = "GUINT64_TO_LE")]
731 public uint64 to_little_endian ();
733 [CCode (cname = "GUINT64_FROM_BE")]
734 public static uint64 from_big_endian (uint64 val);
735 [CCode (cname = "GUINT64_FROM_LE")]
736 public static uint64 from_little_endian (uint64 val);
738 [CCode (cname = "g_ascii_strtoull")]
739 static uint64 ascii_strtoull (string nptr, out char* endptr, uint _base);
741 public static uint64 parse (string str) {
742 return ascii_strtoull (str, null, 0);
744 public static bool try_parse (string str, out uint64 result = null) {
746 result = ascii_strtoull (str, out endptr, 0);
747 if (endptr == (char*) str + str.length) {
756 [GIR (name = "gfloat")]
757 [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")]
758 [FloatingType (rank = 1)]
759 public struct float {
760 [CCode (cname = "FLT_ROUNDS")]
761 public const int ROUNDS;
762 [CCode (cname = "FLT_RADIX")]
763 public const int RADIX;
764 [CCode (cname = "FLT_MANT_DIG")]
765 public const int MANT_DIG;
766 [CCode (cname = "FLT_DIG")]
767 public const int DIG;
769 [CCode (cname = "FLT_MIN_EXP")]
770 public const int MIN_EXP;
771 [CCode (cname = "FLT_MAX_EXP")]
772 public const int MAX_EXP;
774 [CCode (cname = "FLT_MIN_10_EXP")]
775 public const int MIN_10_EXP;
776 [CCode (cname = "FLT_MAX_10_EXP")]
777 public const int MAX_10_EXP;
779 [CCode (cname = "FLT_EPSILON")]
780 public const float EPSILON;
781 [CCode (cname = "FLT_MIN")]
782 public const float MIN;
783 [CCode (cname = "FLT_MAX")]
784 public const float MAX;
786 [CCode (cname = "NAN")]
787 public const float NAN;
788 [CCode (cname = "INFINITY")]
789 public const float INFINITY;
791 [CCode (cname = "isnan")]
792 public bool is_nan ();
793 [CCode (cname = "isfinite")]
794 public bool is_finite ();
795 [CCode (cname = "isnormal")]
796 public bool is_normal ();
797 [CCode (cname = "isinf")]
798 public int is_infinity ();
800 [CCode (cname = "g_strdup_printf", instance_pos = -1)]
801 public string to_string (string format = "%g");
803 [CCode (cname = "MIN")]
804 public static float min (float a, float b);
805 [CCode (cname = "MAX")]
806 public static float max (float a, float b);
807 [CCode (cname = "CLAMP")]
808 public float clamp (float low, float high);
809 [CCode (cname = "fabsf")]
814 [GIR (name = "gdouble")]
815 [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")]
816 [FloatingType (rank = 2)]
817 public struct double {
818 [CCode (cname = "DBL_MANT_DIG")]
819 public const int MANT_DIG;
820 [CCode (cname = "DBL_DIG")]
821 public const int DIG;
823 [CCode (cname = "DBL_MIN_EXP")]
824 public const int MIN_EXP;
825 [CCode (cname = "DBL_MAX_EXP")]
826 public const int MAX_EXP;
828 [CCode (cname = "DBL_MIN_10_EXP")]
829 public const int MIN_10_EXP;
830 [CCode (cname = "DBL_MAX_10_EXP")]
831 public const int MAX_10_EXP;
833 [CCode (cname = "DBL_EPSILON")]
834 public const double EPSILON;
835 [CCode (cname = "DBL_MIN")]
836 public const double MIN;
837 [CCode (cname = "DBL_MAX")]
838 public const double MAX;
840 [CCode (cname = "((double) NAN)")]
841 public const double NAN;
842 [CCode (cname = "((double) INFINITY)")]
843 public const double INFINITY;
845 [CCode (cname = "isnan")]
846 public bool is_nan ();
847 [CCode (cname = "isfinite")]
848 public bool is_finite ();
849 [CCode (cname = "isnormal")]
850 public bool is_normal ();
851 [CCode (cname = "isinf")]
852 public int is_infinity ();
854 [CCode (cname = "MIN")]
855 public static double min (double a, double b);
856 [CCode (cname = "MAX")]
857 public static double max (double a, double b);
858 [CCode (cname = "CLAMP")]
859 public double clamp (double low, double high);
860 [CCode (cname = "fabs")]
861 public double abs ();
863 [CCode (cname = "G_ASCII_DTOSTR_BUF_SIZE")]
864 public const int DTOSTR_BUF_SIZE;
865 [CCode (cname = "g_ascii_dtostr", instance_pos = -1)]
866 public unowned string to_str (char[] buffer);
867 [CCode (cname = "g_ascii_formatd", instance_pos = -1)]
868 public unowned string format (char[] buffer, string format = "%g");
870 public string to_string () {
871 return this.to_str(new char[DTOSTR_BUF_SIZE]);
874 [CCode (cname = "g_ascii_strtod")]
875 static double ascii_strtod (string nptr, out char* endptr);
877 public static double parse (string str) {
878 return ascii_strtod (str, null);
880 public static bool try_parse (string str, out double result = null) {
882 result = ascii_strtod (str, out endptr);
883 if (endptr == (char*) str + str.length) {
891 [GIR (name = "glong")]
892 [CCode (cheader_filename = "time.h", has_type_id = false, default_value = "0")]
893 [IntegerType (rank = 8)]
894 public struct time_t {
895 [CCode (cname = "time")]
896 public time_t (out time_t result = null);
900 [CCode (cheader_filename="stdarg.h", cprefix="va_", has_type_id = false, destroy_function = "va_end", lvalue_access = false)]
901 public struct va_list {
902 [CCode (cname = "va_start")]
904 [CCode (cname = "va_copy")]
905 public va_list.copy (va_list src);
906 [CCode (generic_type_pos = 1.1, simple_generics = true)]
907 public unowned G arg<G> ();
911 [GIR (name = "gunichar")]
912 [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")]
913 [IntegerType (rank = 7)]
914 public struct unichar {
915 public bool validate ();
916 public bool isalnum ();
917 public bool isalpha ();
918 public bool iscntrl ();
919 public bool isdigit ();
920 public bool isgraph ();
921 public bool islower ();
922 [Version (since = "2.14")]
923 public bool ismark ();
924 public bool isprint ();
925 public bool ispunct ();
926 public bool isspace ();
927 public bool isupper ();
928 public bool isxdigit ();
929 public bool istitle ();
930 public bool isdefined ();
931 public bool iswide ();
932 [Version (since = "2.12")]
933 public bool iswide_cjk ();
934 [Version (since = "2.14")]
935 public bool iszerowidth ();
936 public unichar toupper ();
937 public unichar tolower ();
938 public unichar totitle ();
939 public int digit_value ();
940 public int xdigit_value ();
941 public GLib.UnicodeType type ();
942 public GLib.UnicodeBreakType break_type ();
943 [Version (since = "2.14")]
944 public GLib.UnicodeScript get_script();
946 public int to_utf8 (string? outbuf);
948 public string to_string () {
949 string str = (string) new char[7];
954 [Version (since = "2.30")]
955 public bool compose (unichar b, out unichar ch);
956 [Version (since = "2.30")]
957 public bool decompose (out unichar a, out unichar b);
958 [Version (since = "2.30")]
959 public size_t fully_decompose (bool compat, unichar[] result);
961 [CCode (cname = "MIN")]
962 public static unichar min (unichar a, unichar b);
963 [CCode (cname = "MAX")]
964 public static unichar max (unichar a, unichar b);
965 [CCode (cname = "CLAMP")]
966 public unichar clamp (unichar low, unichar high);
968 [CCode (cname = "G_UNICHAR_MAX_DECOMPOSITION_LENGTH")]
969 public const int MAX_DECOMPOSITION_LENGTH;
971 [CCode (cname = "G_GUINT32_FORMAT")]
972 public const string FORMAT;
973 [CCode (cname = "G_GINT32_MODIFIER")]
974 public const string FORMAT_MODIFIER;
978 [GIR (name = "guint16")]
979 [CCode (cname = "gunichar2", cheader_filename = "glib.h", default_value = "0U", type_signature = "q", has_type_id = false)]
980 [IntegerType (rank = 5)]
981 public struct unichar2 {
982 [CCode (cname = "G_GUINT16_FORMAT")]
983 public const string FORMAT;
984 [CCode (cname = "G_GINT16_MODIFIER")]
985 public const string FORMAT_MODIFIER;
990 [GIR (name = "utf8")]
991 [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")]
992 public class string {
993 [Version (replacement = "string.index_of")]
994 [CCode (cname = "strstr")]
995 public unowned string? str (string needle);
996 [Version (replacement = "string.last_index_of")]
997 [CCode (cname = "g_strrstr")]
998 public unowned string? rstr (string needle);
999 [CCode (cname = "g_strrstr_len")]
1000 public unowned string? rstr_len (ssize_t haystack_len, string needle);
1002 [CCode (cname = "strstr")]
1003 static char* strstr (char* haystack, char* needle);
1004 [CCode (cname = "g_strrstr")]
1005 static char* strrstr (char* haystack, char* needle);
1006 [CCode (cname = "g_utf8_strchr")]
1007 static char* utf8_strchr (char* str, ssize_t len, unichar c);
1008 [CCode (cname = "g_utf8_strrchr")]
1009 static char* utf8_strrchr (char* str, ssize_t len, unichar c);
1011 public int index_of (string needle, int start_index = 0) {
1012 char* result = strstr ((char*) this + start_index, (char*) needle);
1014 if (result != null) {
1015 return (int) (result - (char*) this);
1021 public int last_index_of (string needle, int start_index = 0) {
1022 char* result = strrstr ((char*) this + start_index, (char*) needle);
1024 if (result != null) {
1025 return (int) (result - (char*) this);
1031 public int index_of_char (unichar c, int start_index = 0) {
1032 char* result = utf8_strchr ((char*) this + start_index, -1, c);
1034 if (result != null) {
1035 return (int) (result - (char*) this);
1041 public int last_index_of_char (unichar c, int start_index = 0) {
1042 char* result = utf8_strrchr ((char*) this + start_index, -1, c);
1044 if (result != null) {
1045 return (int) (result - (char*) this);
1051 [Version (since = "2.2")]
1052 [CCode (cname = "g_str_has_prefix")]
1053 public bool has_prefix (string prefix);
1054 [Version (since = "2.2")]
1055 [CCode (cname = "g_str_has_suffix")]
1056 public bool has_suffix (string suffix);
1057 [CCode (cname = "g_strdup_printf"), PrintfFormat]
1058 public string printf (...);
1059 [CCode (cname = "g_strdup_vprintf")]
1060 public string vprintf (va_list args);
1061 [CCode (cname = "sscanf", cheader_filename = "stdio.h"), ScanfFormat]
1062 public int scanf (string format, ...);
1063 [CCode (cname = "g_strconcat")]
1064 public string concat (string string2, ...);
1065 [CCode (cname = "g_strescape")]
1066 public string escape (string? exceptions = null);
1067 [CCode (cname = "g_strcompress")]
1068 public string compress ();
1069 [CCode (cname = "g_strsplit", array_length = false, array_null_terminated = true)]
1070 public string[] split (string delimiter, int max_tokens = 0);
1071 [Version (since = "2.4")]
1072 [CCode (cname = "g_strsplit_set", array_length = false, array_null_terminated = true)]
1073 public string[] split_set (string delimiters, int max_tokens = 0);
1074 [CCode (cname = "g_stpcpy")]
1075 private static void* copy_to_buffer (void* dest, string src);
1076 [CCode (cname = "_vala_g_strjoinv")]
1077 public static string joinv (string? separator, string?[]? str_array) {
1078 if (separator == null) {
1081 if (str_array != null && (str_array.length > 0 || (str_array.length == -1 && str_array[0] != null))) {
1084 for (i = 0 ; (str_array.length != -1 && i < str_array.length) || (str_array.length == -1 && str_array[i] != null) ; i++) {
1085 len += (str_array[i] != null) ? ((!) str_array[i]).length : 0;
1090 str_array.length = i;
1091 len += ((!) separator).length * (i - 1);
1093 string* res = GLib.malloc (len);
1094 void* ptr = string.copy_to_buffer ((void*) res, (!) str_array[0]);
1095 for (i = 1 ; i < str_array.length ; i++) {
1096 ptr = string.copy_to_buffer (ptr, (!) separator);
1097 ptr = string.copy_to_buffer (ptr, (str_array[i] != null) ? ((!) str_array[i]) : "");
1105 [CCode (cname = "g_strjoin")]
1106 public static string join (string separator, ...);
1107 [CCode (cname = "g_strnfill")]
1108 public static string nfill (size_t length, char fill_char);
1110 public char get (long index) {
1111 return ((char*) this)[index];
1114 // checks whether valid string character starts at specified index
1115 // embedded NULs are not supported by the string class
1116 public bool valid_char (int index) {
1117 uint8 c = ((uint8*) this)[index];
1118 if (c == 0x00 || (c >= 0x80 && c < 0xc2) || c >= 0xf5) {
1125 [CCode (cname = "g_utf8_next_char")]
1126 public unowned string next_char ();
1127 [CCode (cname = "g_utf8_next_char")]
1128 static char* utf8_next_char (char* str);
1129 public bool get_next_char (ref int index, out unichar c) {
1130 c = utf8_get_char ((char*) this + index);
1132 index = (int) (utf8_next_char ((char*) this + index) - (char*) this);
1138 [CCode (cname = "g_utf8_get_char")]
1139 static unichar utf8_get_char (char* str);
1140 public unichar get_char (long index = 0) {
1141 return utf8_get_char ((char*) this + index);
1143 [CCode (cname = "g_utf8_get_char_validated")]
1144 public unichar get_char_validated (ssize_t max_len = -1);
1146 [Version (replacement = "string.index_of_nth_char")]
1147 [CCode (cname = "g_utf8_offset_to_pointer")]
1148 public unowned string utf8_offset (long offset);
1149 public unowned string offset (long offset) {
1150 return (string) ((char*) this + offset);
1152 [Version (replacement = "string.char_count")]
1153 public long pointer_to_offset (string pos) {
1154 return (long) ((char*) pos - (char*) this);
1157 [CCode (cname = "g_utf8_offset_to_pointer")]
1158 char* utf8_offset_to_pointer (long offset);
1160 public int index_of_nth_char (long c) {
1161 return (int) (this.utf8_offset_to_pointer (c) - (char*) this);
1164 [CCode (cname = "g_utf8_prev_char")]
1165 public unowned string prev_char ();
1166 [CCode (cname = "g_utf8_prev_char")]
1167 static char* utf8_prev_char (char* str);
1168 public bool get_prev_char (ref int index, out unichar c) {
1170 index = (int) (utf8_prev_char ((char*) this + index) - (char*) this);
1171 c = utf8_get_char ((char*) this + index);
1179 [Version (replacement = "string.length")]
1180 [CCode (cname = "strlen")]
1182 [Version (replacement = "string.index_of_char")]
1183 [CCode (cname = "g_utf8_strchr")]
1184 public unowned string chr (ssize_t len, unichar c);
1185 [Version (replacement = "string.last_index_of_char")]
1186 [CCode (cname = "g_utf8_strrchr")]
1187 public unowned string rchr (ssize_t len, unichar c);
1188 [Version (since = "2.2")]
1189 [CCode (cname = "g_utf8_strreverse")]
1190 public string reverse (ssize_t len = -1);
1191 [CCode (cname = "g_utf8_validate")]
1192 public bool validate (ssize_t max_len = -1, out char* end = null);
1193 [Version (since = "2.52")]
1194 [CCode (cname = "g_utf8_make_valid")]
1195 public string make_valid (ssize_t len = -1);
1196 [CCode (cname = "g_utf8_normalize")]
1197 public string normalize (ssize_t len = -1, GLib.NormalizeMode mode = GLib.NormalizeMode.DEFAULT);
1199 [CCode (cname = "g_utf8_strup")]
1200 public string up (ssize_t len = -1);
1201 [CCode (cname = "g_utf8_strdown")]
1202 public string down (ssize_t len = -1);
1203 [CCode (cname = "g_utf8_casefold")]
1204 public string casefold (ssize_t len = -1);
1205 [CCode (cname = "g_utf8_collate")]
1206 public int collate (string str2);
1207 [CCode (cname = "g_utf8_collate_key")]
1208 public string collate_key (ssize_t len = -1);
1209 [Version (since = "2.8")]
1210 [CCode (cname = "g_utf8_collate_key_for_filename")]
1211 public string collate_key_for_filename (ssize_t len = -1);
1213 [CCode (cname = "g_locale_to_utf8")]
1214 public string locale_to_utf8 (ssize_t len, out size_t bytes_read, out size_t bytes_written, out GLib.Error error = null);
1216 [CCode (cname = "g_strchomp")]
1217 public unowned string _chomp();
1218 public string chomp () {
1219 string result = this.dup ();
1224 [CCode (cname = "g_strchug")]
1225 public unowned string _chug();
1226 public string chug () {
1227 string result = this.dup ();
1232 [CCode (cname = "g_strstrip")]
1233 public unowned string _strip ();
1234 public string strip () {
1235 string result = this.dup ();
1240 [CCode (cname = "g_strdelimit")]
1241 public unowned string _delimit (string delimiters, char new_delimiter);
1242 public string delimit (string delimiters, char new_delimiter) {
1243 string result = this.dup ();
1244 result._delimit (delimiters, new_delimiter);
1248 [CCode (cname = "g_str_hash")]
1249 public uint hash ();
1251 [Version (since = "2.40")]
1252 [CCode (cname = "g_str_is_ascii")]
1253 public bool is_ascii ();
1254 [Version (since = "2.40")]
1255 [CCode (instance_pos = "1.5", cname = "g_str_match_string")]
1256 public bool match_string (string search_term, bool accept_alternates);
1257 [Version (since = "2.40")]
1258 [CCode (cname = "g_str_to_ascii")]
1259 public string to_ascii (string? from_locale = null);
1260 [Version (replacement = "int.parse")]
1261 [CCode (cname = "atoi")]
1262 public int to_int ();
1263 [Version (replacement = "long.parse")]
1264 [CCode (cname = "strtol")]
1265 public long to_long (out unowned string endptr = null, int _base = 0);
1266 [Version (replacement = "double.parse")]
1267 [CCode (cname = "g_ascii_strtod")]
1268 public double to_double (out unowned string endptr = null);
1269 [Version (replacement = "uint64.parse")]
1270 [CCode (cname = "strtoul")]
1271 public ulong to_ulong (out unowned string endptr = null, int _base = 0);
1272 [Version (replacement = "int64.parse")]
1273 [CCode (cname = "g_ascii_strtoll")]
1274 public int64 to_int64 (out unowned string endptr = null, int _base = 0);
1275 [Version (replacement = "uint64.parse", since = "2.2")]
1276 [CCode (cname = "g_ascii_strtoull")]
1277 public uint64 to_uint64 (out unowned string endptr = null, int _base = 0);
1278 [CCode (cname = "g_str_tokenize_and_fold", array_length = false, array_null_terminated = true)]
1279 [Version (since = "2.40")]
1280 public string[] tokenize_and_fold (string transit_locale, [CCode (array_length = false, array_null_terminated = true)] out string[] ascii_alternates);
1282 [Version (replacement = "bool.parse")]
1283 public bool to_bool () {
1284 if (this == "true") {
1291 [Version (replacement = "string.length")]
1292 [CCode (cname = "strlen")]
1293 public size_t size ();
1295 [CCode (cname = "g_ascii_strcasecmp")]
1296 public int ascii_casecmp (string s2);
1297 [CCode (cname = "g_ascii_strncasecmp")]
1298 public int ascii_ncasecmp (string s2, size_t n);
1299 [CCode (cname = "g_ascii_strup")]
1300 public string ascii_up (ssize_t len = -1);
1301 [CCode (cname = "g_ascii_strdown")]
1302 public string ascii_down (ssize_t len = -1);
1304 [CCode (cname = "g_utf8_skip")]
1305 public static char[] skip;
1307 /* modifies string in place */
1308 [CCode (cname = "g_strcanon")]
1309 public void canon (string valid_chars, char substitutor);
1311 [CCode (cname = "g_strdup")]
1312 public string dup ();
1313 [Version (replacement = "string.substring")]
1314 [CCode (cname = "g_strndup")]
1315 public string ndup (size_t n);
1317 [CCode (cname = "memchr")]
1318 static char* memchr (char* s, int c, size_t n);
1320 // strnlen is not available on all systems
1321 static long strnlen (char* str, long maxlen) {
1322 char* end = memchr (str, 0, maxlen);
1326 return (long) (end - str);
1330 [CCode (cname = "g_strndup")]
1331 static string strndup (char* str, size_t n);
1333 public string substring (long offset, long len = -1) {
1335 if (offset >= 0 && len >= 0) {
1336 // avoid scanning whole string
1337 string_length = strnlen ((char*) this, offset + len);
1339 string_length = this.length;
1343 offset = string_length + offset;
1344 GLib.return_val_if_fail (offset >= 0, null);
1346 GLib.return_val_if_fail (offset <= string_length, null);
1349 len = string_length - offset;
1351 GLib.return_val_if_fail (offset + len <= string_length, null);
1352 return strndup ((char*) this + offset, len);
1355 public string slice (long start, long end) {
1356 long string_length = this.length;
1358 start = string_length + start;
1361 end = string_length + end;
1363 GLib.return_val_if_fail (start >= 0 && start <= string_length, null);
1364 GLib.return_val_if_fail (end >= 0 && end <= string_length, null);
1365 GLib.return_val_if_fail (start <= end, null);
1366 return strndup ((char*) this + start, end - start);
1369 public string splice (long start, long end, string? str = null) {
1370 long string_length = this.length;
1372 start = string_length + start;
1375 end = string_length + end;
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);
1385 str_size = ((!)(str)).length;
1388 string* result = GLib.malloc0 (this.length - (end - start) + str_size + 1);
1390 char* dest = (char*) result;
1392 GLib.Memory.copy (dest, this, start);
1395 GLib.Memory.copy (dest, str, str_size);
1398 GLib.Memory.copy (dest, (char*) this + end, string_length - end);
1400 return (owned) result;
1403 public bool contains (string needle) {
1404 return strstr ((char*) this, (char*) needle) != null;
1407 public string replace (string old, string replacement) {
1408 if (*((char*) this) == '\0' || *((char*) old) == '\0' || old == replacement)
1412 var regex = new GLib.Regex (GLib.Regex.escape_string (old));
1413 return regex.replace_literal (this, -1, 0, replacement);
1414 } catch (GLib.RegexError e) {
1415 GLib.assert_not_reached ();
1419 [CCode (cname = "g_utf8_strlen")]
1420 public int char_count (ssize_t max = -1);
1423 [CCode (cname = "strlen")]
1427 public uint8[] data {
1429 unowned uint8[] res = (uint8[]) this;
1430 res.length = (int) this.length;
1435 public char[] to_utf8 () {
1436 char[] result = new char[this.length + 1];
1438 GLib.Memory.copy (result, this, this.length);
1442 public unowned string to_string () {
1446 [CCode (cname = "g_utf8_to_utf16")]
1447 public string16 to_utf16 (long len = -1, out long? items_read = null, out long? items_written = null) throws GLib.ConvertError;
1448 [CCode (cname = "g_utf8_to_ucs4")]
1449 public string32 to_utf32 (long len = -1, out long? items_read = null, out long? items_written = null) throws GLib.ConvertError;
1450 [CCode (cname = "g_utf8_to_ucs4_fast")]
1451 public string32 to_utf32_fast (long len = -1, out long? items_written = null);
1457 [GIR (name = "gunichar")]
1458 [CCode (cname = "gunichar", const_cname = "const gunichar", free_function = "g_free", cheader_filename = "glib.h")]
1459 public class string32 {
1460 [CCode (cname = "g_ucs4_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_ucs4_to_utf8")]
1463 public string to_utf8 (long len = -1, out long? items_read = null, out long? items_written = null) throws GLib.ConvertError;
1465 public string? to_string () {
1467 return this.to_utf8 ();
1468 } catch (GLib.ConvertError e) {
1476 [GIR (name = "guint16")]
1477 [CCode (cname = "gunichar2", const_cname = "const gunichar2", free_function = "g_free", cheader_filename = "glib.h")]
1478 public class string16 {
1479 [CCode (cname = "g_utf16_to_ucs4")]
1480 public string32 to_utf32 (long len = -1, out long? items_read = null, out long? items_written = null) throws GLib.ConvertError;
1481 [CCode (cname = "g_utf16_to_utf8")]
1482 public string to_utf8 (long len = -1, out long? items_read = null, out long? items_written = null) throws GLib.ConvertError;
1484 public string? to_string () {
1486 return this.to_utf8 ();
1487 } catch (GLib.ConvertError e) {
1493 [CCode (cprefix = "G", lower_case_cprefix = "g_", cheader_filename = "glib.h", gir_namespace = "GLib", gir_version = "2.0")]
1495 [CCode (lower_case_cprefix = "", cheader_filename = "math.h")]
1497 [CCode (cname = "G_E")]
1498 public const double E;
1500 [CCode (cname = "G_PI")]
1501 public const double PI;
1503 [CCode (cname = "G_LN2")]
1504 public const double LN2;
1506 [CCode (cname = "G_LN10")]
1507 public const double LN10;
1509 [CCode (cname = "G_PI_2")]
1510 public const double PI_2;
1512 [CCode (cname = "G_PI_4")]
1513 public const double PI_4;
1515 [CCode (cname = "G_SQRT2")]
1516 public const double SQRT2;
1518 [CCode (cname = "G_LOG_2_BASE_10")]
1519 public const double LOG_2_BASE_10;
1521 /* generated from <bits/mathcalls.h> of glibc */
1522 public static double acos (double x);
1523 public static float acosf (float x);
1524 public static double asin (double x);
1525 public static float asinf (float x);
1526 public static double atan (double x);
1527 public static float atanf (float x);
1528 public static double atan2 (double y, double x);
1529 public static float atan2f (float y, float x);
1530 public static double cos (double x);
1531 public static float cosf (float x);
1532 public static double sin (double x);
1533 public static float sinf (float x);
1534 public static double tan (double x);
1535 public static float tanf (float x);
1536 public static double cosh (double x);
1537 public static float coshf (float x);
1538 public static double sinh (double x);
1539 public static float sinhf (float x);
1540 public static double tanh (double x);
1541 public static float tanhf (float x);
1542 public static void sincos (double x, out double sinx, out double cosx);
1543 public static void sincosf (float x, out float sinx, out float cosx);
1544 public static double acosh (double x);
1545 public static float acoshf (float x);
1546 public static double asinh (double x);
1547 public static float asinhf (float x);
1548 public static double atanh (double x);
1549 public static float atanhf (float x);
1550 public static double exp (double x);
1551 public static float expf (float x);
1552 public static double frexp (double x, out int exponent);
1553 public static float frexpf (float x, out int exponent);
1554 public static double ldexp (double x, int exponent);
1555 public static float ldexpf (float x, int exponent);
1556 public static double log (double x);
1557 public static float logf (float x);
1558 public static double log10 (double x);
1559 public static float log10f (float x);
1560 public static double modf (double x, out double iptr);
1561 public static float modff (float x, out float iptr);
1562 public static double exp10 (double x);
1563 public static float exp10f (float x);
1564 public static double pow10 (double x);
1565 public static float pow10f (float x);
1566 public static double expm1 (double x);
1567 public static float expm1f (float x);
1568 public static double log1p (double x);
1569 public static float log1pf (float x);
1570 public static double logb (double x);
1571 public static float logbf (float x);
1572 public static double exp2 (double x);
1573 public static float exp2f (float x);
1574 public static double log2 (double x);
1575 public static float log2f (float x);
1576 public static double pow (double x, double y);
1577 public static float powf (float x, float y);
1578 public static double sqrt (double x);
1579 public static float sqrtf (float x);
1580 public static double hypot (double x, double y);
1581 public static float hypotf (float x, float y);
1582 public static double cbrt (double x);
1583 public static float cbrtf (float x);
1584 public static double ceil (double x);
1585 public static float ceilf (float x);
1586 public static double fabs (double x);
1587 public static float fabsf (float x);
1588 public static double floor (double x);
1589 public static float floorf (float x);
1590 public static double fmod (double x, double y);
1591 public static float fmodf (float x, float y);
1592 public static int isinf (double value);
1593 public static int isinff (float value);
1594 public static int finite (double value);
1595 public static int finitef (float value);
1596 public static double drem (double x, double y);
1597 public static float dremf (float x, float y);
1598 public static double significand (double x);
1599 public static float significandf (float x);
1600 public static double copysign (double x, double y);
1601 public static float copysignf (float x, float y);
1602 public static double nan (string tagb);
1603 public static float nanf (string tagb);
1604 public static int isnan (double value);
1605 public static int isnanf (float value);
1606 public static double j0 (double x0);
1607 public static float j0f (float x0);
1608 public static double j1 (double x0);
1609 public static float j1f (float x0);
1610 public static double jn (int x0, double x1);
1611 public static float jnf (int x0, float x1);
1612 public static double y0 (double x0);
1613 public static float y0f (float x0);
1614 public static double y1 (double x0);
1615 public static float y1f (float x0);
1616 public static double yn (int x0, double x1);
1617 public static float ynf (int x0, float x1);
1618 public static double erf (double x0);
1619 public static float erff (float x0);
1620 public static double erfc (double x0);
1621 public static float erfcf (float x0);
1622 public static double lgamma (double x0);
1623 public static float lgammaf (float x0);
1624 public static double tgamma (double x0);
1625 public static float tgammaf (float x0);
1626 public static double gamma (double x0);
1627 public static float gammaf (float x0);
1628 public static double lgamma_r (double x0, out int signgamp);
1629 public static float lgamma_rf (float x0, out int signgamp);
1630 public static double rint (double x);
1631 public static float rintf (float x);
1632 public static double nextafter (double x, double y);
1633 public static float nextafterf (float x, float y);
1634 public static double nexttoward (double x, double y);
1635 public static float nexttowardf (float x, double y);
1636 public static double remainder (double x, double y);
1637 public static float remainderf (float x, float y);
1638 public static double scalbn (double x, int n);
1639 public static float scalbnf (float x, int n);
1640 public static int ilogb (double x);
1641 public static int ilogbf (float x);
1642 public static double scalbln (double x, long n);
1643 public static float scalblnf (float x, long n);
1644 public static double nearbyint (double x);
1645 public static float nearbyintf (float x);
1646 public static double round (double x);
1647 public static float roundf (float x);
1648 public static double trunc (double x);
1649 public static float truncf (float x);
1650 public static double remquo (double x, double y, out int quo);
1651 public static float remquof (float x, float y, out int quo);
1652 public static long lrint (double x);
1653 public static long lrintf (float x);
1654 public static int64 llrint (double x);
1655 public static int64 llrintf (float x);
1656 public static long lround (double x);
1657 public static long lroundf (float x);
1658 public static int64 llround (double x);
1659 public static int64 llroundf (float x);
1660 public static double fdim (double x, double y);
1661 public static float fdimf (float x, float y);
1662 public static double fmax (double x, double y);
1663 public static float fmaxf (float x, float y);
1664 public static double fmin (double x, double y);
1665 public static float fminf (float x, float y);
1666 public static double fma (double x, double y, double z);
1667 public static float fmaf (float x, float y, float z);
1668 public static double scalb (double x, double n);
1669 public static float scalbf (float x, float n);
1673 [CCode (cprefix = "G_", cname = "int", has_type_id = false)]
1674 public enum ByteOrder {
1675 [CCode (cname = "G_BYTE_ORDER")]
1682 public const ByteOrder BYTE_ORDER;
1684 /* Atomic Operations */
1686 [Version (since = "2.4")]
1687 namespace AtomicInt {
1688 public static int get ([CCode (type = "volatile gint *")] ref int atomic);
1689 public static void set ([CCode (type = "volatile gint *")] ref int atomic, int newval);
1690 [Version (since = "2.30")]
1691 public static int add ([CCode (type = "volatile gint *")] ref int atomic, int val);
1692 [Version (deprecated_since = "2.30", replacement = "add")]
1693 public static int exchange_and_add ([CCode (type = "volatile gint *")] ref int atomic, int val);
1694 public static bool compare_and_exchange ([CCode (type = "volatile gint *")] ref int atomic, int oldval, int newval);
1695 public static void inc ([CCode (type = "volatile gint *")] ref int atomic);
1696 public static bool dec_and_test ([CCode (type = "volatile gint *")] ref int atomic);
1699 [Version (since = "2.4")]
1700 namespace AtomicPointer {
1701 public static void* get ([CCode (type = "volatile gpointer *")] void** atomic);
1702 public static void set ([CCode (type = "volatile gpointer *")] void** atomic, void* newval);
1703 public static bool compare_and_exchange ([CCode (type = "volatile gpointer *")] void** atomic, void* oldval, void* newval);
1706 /* The Main Event Loop */
1709 [CCode (ref_function = "g_main_loop_ref", unref_function = "g_main_loop_unref")]
1710 public class MainLoop {
1711 public MainLoop (MainContext? context = null, bool is_running = false);
1713 public void quit ();
1714 public bool is_running ();
1715 public unowned MainContext get_context ();
1718 namespace Priority {
1719 public const int HIGH;
1720 public const int DEFAULT;
1721 public const int HIGH_IDLE;
1722 public const int DEFAULT_IDLE;
1723 public const int LOW;
1727 [CCode (ref_function = "g_main_context_ref", unref_function = "g_main_context_unref")]
1728 public class MainContext {
1729 public MainContext ();
1730 public static unowned MainContext @default ();
1731 public bool iteration (bool may_block);
1732 public bool pending ();
1733 public unowned Source find_source_by_id (uint source_id);
1734 public unowned Source find_source_by_user_data (void* user_data);
1735 public unowned Source find_source_by_funcs_user_data (SourceFuncs funcs, void* user_data);
1736 public void wakeup ();
1737 public bool acquire ();
1738 public void release ();
1739 [Version (since = "2.10")]
1740 public bool is_owner ();
1741 public bool wait (Cond cond, Mutex mutex);
1742 public bool prepare (out int priority);
1743 public int query (int max_priority, out int timeout_, PollFD[] fds);
1744 public bool check (int max_priority, PollFD[] fds);
1745 public void dispatch ();
1746 public void set_poll_func (PollFunc func);
1747 public PollFunc get_poll_func ();
1748 public void add_poll (ref PollFD fd, int priority);
1749 public void remove_poll (ref PollFD fd);
1750 public int depth ();
1751 [Version (since = "2.12")]
1752 [CCode (cname = "g_main_current_source")]
1753 public static unowned Source current_source ();
1754 [Version (since = "2.22")]
1755 public static unowned MainContext? get_thread_default ();
1756 [Version (since = "2.32")]
1757 public static MainContext ref_thread_default ();
1758 [Version (since = "2.22")]
1759 public void push_thread_default ();
1760 [Version (since = "2.22")]
1761 public void pop_thread_default ();
1762 [Version (since = "2.28")]
1763 [CCode (cname = "g_main_context_invoke_full")]
1764 public void invoke (owned SourceFunc function, [CCode (pos = 0.1)] int priority = Priority.DEFAULT);
1765 [Version (since = "2.28")]
1766 public void invoke_full (int priority, owned SourceFunc function);
1769 [CCode (has_target = false)]
1770 public delegate int PollFunc (PollFD[] ufds, int timeout_);
1772 [CCode (cname = "GSource")]
1773 public class TimeoutSource : Source {
1774 public TimeoutSource (uint interval);
1775 [Version (since = "2.14")]
1776 public TimeoutSource.seconds (uint interval);
1780 [CCode (cname = "g_timeout_add_full")]
1781 public static uint add (uint interval, owned SourceFunc function, [CCode (pos = 0.1)] int priority = Priority.DEFAULT);
1782 public static uint add_full (int priority, uint interval, owned SourceFunc function);
1783 [Version (since = "2.14")]
1784 [CCode (cname = "g_timeout_add_seconds_full")]
1785 public static uint add_seconds (uint interval, owned SourceFunc function, [CCode (pos = 0.1)] int priority = Priority.DEFAULT);
1786 [Version (since = "2.14")]
1787 public static uint add_seconds_full (int priority, uint interval, owned SourceFunc function);
1790 [CCode (cname = "GSource")]
1791 public class IdleSource : Source {
1792 public IdleSource ();
1796 [CCode (cname = "g_idle_add_full")]
1797 public static uint add (owned SourceFunc function, [CCode (pos = 0.1)] int priority = Priority.DEFAULT_IDLE);
1798 public static uint add_full (int priority, owned SourceFunc function);
1799 public static bool remove_by_data (void* data);
1802 [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")]
1803 [IntegerType (rank = 6)]
1804 public struct Pid : int {
1805 [CCode (cname = "G_PID_FORMAT")]
1806 [Version (since = "2.50")]
1807 public const string FORMAT;
1810 public delegate void ChildWatchFunc (Pid pid, int status);
1812 [CCode (cname = "GSource")]
1813 public class ChildWatchSource : Source {
1814 public ChildWatchSource (Pid pid);
1817 namespace ChildWatch {
1818 [Version (since = "2.4")]
1819 [CCode (cname = "g_child_watch_add_full")]
1820 public static uint add (Pid pid, owned ChildWatchFunc function, [CCode (pos = 0.1)] int priority = Priority.DEFAULT_IDLE);
1821 [Version (since = "2.4")]
1822 public static uint add_full (int priority, Pid pid, owned ChildWatchFunc function);
1825 public struct PollFD {
1827 public IOCondition events;
1828 public IOCondition revents;
1832 [CCode (ref_function = "g_source_ref", unref_function = "g_source_unref")]
1833 public abstract class Source {
1834 protected Source ();
1835 [Version (since = "2.12")]
1836 public void set_funcs (SourceFuncs funcs);
1837 public uint attach (MainContext? context);
1838 public void destroy ();
1839 [Version (since = "2.12")]
1840 public bool is_destroyed ();
1841 public void set_priority (int priority);
1842 public int get_priority ();
1843 public void set_can_recurse (bool can_recurse);
1844 public bool get_can_recurse ();
1845 public uint get_id ();
1846 [Version (since = "2.26")]
1847 public unowned string? get_name ();
1848 [Version (since = "2.26")]
1849 public void set_name (string? name);
1850 [Version (since = "2.26")]
1851 public static void set_name_by_id (uint tag, string? name);
1852 public unowned MainContext get_context ();
1853 public void set_callback (owned SourceFunc func);
1854 public void set_callback_indirect (void* callback_data, SourceCallbackFuncs callback_funcs);
1855 [Version (since = "2.36")]
1856 public void* add_unix_fd (int fd, IOCondition events);
1857 [Version (since = "2.36")]
1858 public void remove_unix_fd (void* tag);
1859 [Version (since = "2.36")]
1860 public void modify_unix_fd (void* tag, IOCondition new_events);
1861 [Version (since = "2.36")]
1862 public IOCondition query_unix_fd (void* tag);
1863 public void add_poll (ref PollFD fd);
1864 public void remove_poll (ref PollFD fd);
1865 [Version (since = "2.28")]
1866 public void add_child_source (Source child_source);
1867 [Version (since = "2.28")]
1868 public void remove_child_source (Source child_source);
1869 [Version (since = "2.28")]
1870 public int64 get_time ();
1871 [Version (deprecated_since = "2.28", replacement = "get_time")]
1872 public void get_current_time (out TimeVal timeval);
1873 [Version (since = "2.36")]
1874 public void set_ready_time (int64 ready_time);
1875 public int64 get_ready_time ();
1876 public static bool remove (uint id);
1877 public static bool remove_by_funcs_user_data (void* user_data);
1878 public static bool remove_by_user_data (void* user_data);
1879 [Version (since = "2.32")]
1880 [CCode (cname = "G_SOURCE_CONTINUE")]
1881 public const bool CONTINUE;
1882 [Version (since = "2.32")]
1883 [CCode (cname = "G_SOURCE_REMOVE")]
1884 public const bool REMOVE;
1886 protected abstract bool prepare (out int timeout_);
1887 protected abstract bool check ();
1888 protected abstract bool dispatch (SourceFunc _callback);
1891 [CCode (has_target = false)]
1892 public delegate void SourceDummyMarshal ();
1894 [CCode (has_target = false)]
1895 public delegate bool SourcePrepareFunc (Source source, out int timeout_);
1896 [CCode (has_target = false)]
1897 public delegate bool SourceCheckFunc (Source source);
1898 [CCode (has_target = false)]
1899 public delegate bool SourceDispatchFunc (Source source, SourceFunc _callback);
1900 [CCode (has_target = false)]
1901 public delegate void SourceFinalizeFunc (Source source);
1903 public struct SourceFuncs {
1904 public SourcePrepareFunc prepare;
1905 public SourceCheckFunc check;
1906 public SourceDispatchFunc dispatch;
1907 public SourceFinalizeFunc finalize;
1910 [CCode (has_target = false)]
1911 public delegate void SourceCallbackRefFunc (void* cb_data);
1912 [CCode (has_target = false)]
1913 public delegate void SourceCallbackUnrefFunc (void* cb_data);
1914 [CCode (has_target = false)]
1915 public delegate void SourceCallbackGetFunc (void* cb_data, Source source, SourceFunc func);
1918 public class SourceCallbackFuncs {
1919 public SourceCallbackRefFunc @ref;
1920 public SourceCallbackUnrefFunc unref;
1921 public SourceCallbackGetFunc @get;
1924 public delegate bool SourceFunc ();
1926 public errordomain ThreadError {
1928 public static GLib.Quark quark ();
1931 /* Thread support */
1933 [CCode (scope = "async")]
1934 public delegate G ThreadFunc<G> ();
1935 public delegate void Func<G> (G data);
1937 [Version (since = "2.36")]
1938 public uint get_num_processors ();
1940 [CCode (has_type_id = false)]
1941 public enum ThreadPriority {
1949 [Version (since = "2.32")]
1950 [CCode (ref_function = "g_thread_ref", unref_function = "g_thread_unref")]
1951 public class Thread<T> {
1952 [Version (since = "2.32")]
1953 public Thread (string? name, owned ThreadFunc<T> func);
1954 [Version (since = "2.32")]
1955 [CCode (cname = "g_thread_try_new")]
1956 public Thread.try (string? name, owned ThreadFunc<T> func) throws GLib.Error;
1957 public static bool supported ();
1958 [Version (deprecated_since = "2.32", replacement = "new Thread<T> ()")]
1959 [CCode (simple_generics = true)]
1960 public static unowned Thread<T> create<T> (owned ThreadFunc<T> func, bool joinable) throws ThreadError;
1961 [Version (deprecated_since = "2.32", replacement = "new Thread<T> ()")]
1962 [CCode (simple_generics = true)]
1963 public static unowned Thread<T> create_full<T> (owned ThreadFunc<T> func, ulong stack_size, bool joinable, bool bound, ThreadPriority priority) throws ThreadError;
1964 [CCode (simple_generics = true)]
1965 public static unowned Thread<T> self<T> ();
1968 [Version (deprecated_since = "2.32")]
1969 public void set_priority (ThreadPriority priority);
1970 public static void yield ();
1971 public static void exit (T retval);
1972 [Version (deprecated_since = "2.32", since = "2.10")]
1973 public static void @foreach (Func<Thread> thread_func);
1975 [CCode (cname = "g_usleep")]
1976 public static void usleep (ulong microseconds);
1979 [Version (since = "2.32")]
1980 [CCode (destroy_function = "g_mutex_clear", lvalue_access = false)]
1981 public struct Mutex {
1983 public void @lock ();
1984 public bool trylock ();
1985 public void unlock ();
1988 [Version (since = "2.44")]
1989 [CCode (destroy_function = "g_mutex_locker_free")]
1990 public struct MutexLocker {
1991 public MutexLocker (Mutex mutex);
1992 public void free ();
1995 [Version (since = "2.32")]
1996 [CCode (destroy_function = "g_rec_mutex_clear")]
1997 public struct RecMutex {
1999 public void lock ();
2000 public bool trylock ();
2001 public void unlock ();
2004 [Version (since = "2.32")]
2005 [CCode (destroy_function = "g_rw_lock_clear")]
2006 public struct RWLock {
2008 public void writer_lock ();
2009 public bool writer_trylock ();
2010 public void writer_unlock ();
2011 public void reader_lock ();
2012 public bool reader_trylock ();
2013 public void reader_unlock ();
2016 [Version (deprecated_since = "2.32", replacement = "Mutex")]
2017 [CCode (destroy_function = "g_static_mutex_free", default_value = "G_STATIC_MUTEX_INIT")]
2018 public struct StaticMutex {
2019 public StaticMutex ();
2020 public void lock ();
2021 public bool trylock ();
2022 public void unlock ();
2023 public void lock_full ();
2026 [Version (deprecated_since = "2.32", replacement = "RecMutex")]
2027 [CCode (destroy_function = "g_static_rec_mutex_free", default_value = "G_STATIC_REC_MUTEX_INIT")]
2028 public struct StaticRecMutex {
2029 public StaticRecMutex ();
2030 public void lock ();
2031 public bool trylock ();
2032 public void unlock ();
2033 public void lock_full ();
2036 [Version (deprecated_since = "2.32", replacement = "RWLock")]
2037 [CCode (destroy_function = "g_static_rw_lock_free", default_value = "G_STATIC_RW_LOCK_INIT")]
2038 public struct StaticRWLock {
2039 public StaticRWLock ();
2040 public void reader_lock ();
2041 public bool reader_trylock ();
2042 public void reader_unlock ();
2043 public void writer_lock ();
2044 public bool writer_trylock ();
2045 public void writer_unlock ();
2049 [CCode (ref_function = "", unref_function = "")]
2050 public class Private {
2051 public Private (DestroyNotify? destroy_func = null);
2052 public void* get ();
2053 public void set (void* data);
2054 public void replace (void* data);
2057 [CCode (destroy_function = "g_static_private_free", default_value = "G_STATIC_PRIVATE_INIT")]
2058 [Version (deprecated_since = "2.32")]
2059 public struct StaticPrivate {
2060 public StaticPrivate ();
2061 public void* get ();
2062 public void set (void* data, DestroyNotify? destroy_func);
2065 [Version (since = "2.32")]
2066 [CCode (destroy_function = "g_cond_clear", lvalue_access = false)]
2067 public struct Cond {
2069 public void @signal ();
2070 public void broadcast ();
2071 public void wait (Mutex mutex);
2072 [Version (deprecated_since = "2.32", replacement = "wait_until")]
2073 public bool timed_wait (Mutex mutex, TimeVal abs_time);
2074 [Version (since = "2.32")]
2075 public bool wait_until (Mutex mutex, int64 end_time);
2078 [CCode (cname = "GThreadFunc")]
2079 public delegate G OnceFunc<G> ();
2081 [Version (since = "2.4")]
2082 [CCode (default_value = "G_ONCE_INIT")]
2083 public struct Once<G> {
2084 [CCode (cname = "g_once")]
2085 public unowned G once (OnceFunc<G> function);
2086 [Version (since = "2.14")]
2087 public static bool init_enter ([CCode (ctype="volatile gsize *")] size_t *value);
2088 [Version (since = "2.14")]
2089 public static void init_leave ([CCode (ctype="volatile gsize *")] size_t *value, size_t set_value);
2090 public OnceStatus status;
2093 [CCode (cprefix = "G_ONCE_STATUS_", has_type_id = false)]
2094 public enum OnceStatus {
2102 [CCode (cname = "GFunc")]
2103 public delegate void ThreadPoolFunc<G> (owned G data);
2106 [CCode (free_function = "g_thread_pool_free")]
2107 public class ThreadPool<T> {
2108 [Version (deprecated_since = "vala-0.18", replacement = "ThreadPool.with_owned_data")]
2109 public ThreadPool (Func<T> func, int max_threads, bool exclusive) throws ThreadError;
2110 [CCode (cname = "g_thread_pool_new")]
2111 public ThreadPool.with_owned_data (ThreadPoolFunc<T> func, int max_threads, bool exclusive) throws ThreadError;
2112 [Version (deprecated_since = "vala-0.18", replacement = "add")]
2113 public void push (T data) throws ThreadError;
2114 [CCode (cname = "g_thread_pool_push")]
2115 public void add (owned T data) throws ThreadError;
2116 public void set_max_threads (int max_threads) throws ThreadError;
2117 public int get_max_threads ();
2118 public uint get_num_threads ();
2119 [Version (since = "2.46")]
2120 public bool move_to_front (T data);
2121 public uint unprocessed ();
2122 [CCode (cname = "g_thread_pool_free")]
2123 void _free (bool immediate, bool wait);
2124 [CCode (cname = "vala__g_thread_pool_free_wrapper")]
2125 public static void free (owned ThreadPool? pool, bool immediate, bool wait) {
2126 ThreadPool* ptr = (owned) pool;
2128 ((ThreadPool)ptr)._free (immediate, wait);
2131 public static void set_max_unused_threads (int max_threads);
2132 public static int get_max_unused_threads ();
2133 public static uint get_num_unused_threads ();
2134 public static void stop_unused_threads ();
2135 [Version (since = "2.10")]
2136 public void set_sort_function (CompareDataFunc<T> func);
2137 [Version (since = "2.10")]
2138 public static void set_max_idle_time (uint interval);
2139 [Version (since = "2.10")]
2140 public static uint get_max_idle_time ();
2143 /* Asynchronous Queues */
2146 [CCode (ref_function = "g_async_queue_ref", unref_function = "g_async_queue_unref")]
2147 public class AsyncQueue<G> {
2148 [Version (since = "2.16")]
2149 [CCode (cname = "g_async_queue_new_full", simple_generics = true)]
2150 public AsyncQueue ();
2151 public void push (owned G data);
2152 [Version (since = "2.10")]
2153 public void push_sorted (owned G data, CompareDataFunc<G> func);
2155 public G? try_pop ();
2156 public G? timed_pop (ref TimeVal end_time);
2157 public int length ();
2158 [Version (since = "2.10")]
2159 public void sort (CompareDataFunc<G> func);
2160 public void @lock ();
2161 public void unlock ();
2162 public void ref_unlocked ();
2163 public void unref_and_unlock ();
2164 [Version (since = "2.46")]
2165 public void push_front (owned G data);
2166 [Version (since = "2.46")]
2167 public void push_front_unlocked (owned G data);
2168 public void push_unlocked (owned G data);
2169 [Version (since = "2.10")]
2170 public void push_sorted_unlocked (owned G data, CompareDataFunc<G> func);
2171 public G pop_unlocked ();
2172 [Version (since = "2.46")]
2173 public bool remove (G data);
2174 [Version (since = "2.46")]
2175 public bool remove_unlocked (G data);
2176 public G? try_pop_unlocked ();
2177 public G? timed_pop_unlocked (ref TimeVal end_time);
2178 public G? timeout_pop (uint64 timeout);
2179 public G? timeout_pop_unlocked (uint64 timeout);
2180 public int length_unlocked ();
2181 public void sort_unlocked (CompareDataFunc<G> func);
2184 /* Memory Allocation */
2186 public static void* malloc (size_t n_bytes);
2187 public static void* malloc0 (size_t n_bytes);
2188 public static void* realloc (void* mem, size_t n_bytes);
2190 public static void* try_malloc (size_t n_bytes);
2191 [Version (since = "2.8")]
2192 public static void* try_malloc0 (size_t n_bytes);
2193 public static void* try_realloc (void* mem, size_t n_bytes);
2195 public static void free (void* mem);
2197 public class MemVTable {
2200 [CCode (cname = "glib_mem_profiler_table")]
2201 public static MemVTable mem_profiler_table;
2203 public static void mem_set_vtable (MemVTable vtable);
2204 public static void mem_profile ();
2206 [CCode (cheader_filename = "string.h")]
2208 [CCode (cname = "memcmp")]
2209 public static int cmp (void* s1, void* s2, size_t n);
2210 [CCode (cname = "memcpy")]
2211 public static void* copy (void* dest, void* src, size_t n);
2212 [CCode (cname = "memset")]
2213 public static void* set (void* dest, int src, size_t n);
2214 [CCode (cname = "g_memmove")]
2215 public static void* move (void* dest, void* src, size_t n);
2216 [CCode (cname = "g_memdup")]
2217 public static void* dup (void* mem, uint n);
2220 [Version (since = "2.10")]
2222 public static void* alloc (size_t block_size);
2223 public static void* alloc0 (size_t block_size);
2224 [Version (since = "2.14")]
2225 public static void* copy (size_t block_size, void* mem_block);
2226 [CCode (cname = "g_slice_free1")]
2227 public static void free (size_t block_size, void* mem_block);
2228 public static void free_chain_with_offset (size_t block_size, void *mem_chain, size_t next_offset);
2229 public static int64 get_config (SliceConfig ckey);
2230 [CCode (array_length_cname = "n_values", array_length_type = "guint")]
2231 public static int64[] get_config_state (SliceConfig ckey, int64 address);
2232 public static void set_config (SliceConfig ckey, int64 value);
2235 [CCode (cprefix = "G_SLICE_CONFIG_", has_type_id = false)]
2236 public enum SliceConfig {
2248 [CCode (ref_function = "g_io_channel_ref", unref_function = "g_io_channel_unref")]
2249 public class IOChannel {
2250 [CCode (cname = "g_io_channel_unix_new")]
2251 public IOChannel.unix_new (int fd);
2252 public int unix_get_fd ();
2253 [CCode (cname = "g_io_channel_win32_new_fd")]
2254 public IOChannel.win32_new_fd (int fd);
2255 [CCode (cname = "g_io_channel_win32_new_socket")]
2256 public IOChannel.win32_socket (int socket);
2257 [CCode (cname = "g_io_channel_win32_new_messages")]
2258 public IOChannel.win32_messages (size_t hwnd);
2259 public void init ();
2260 public IOChannel.file (string filename, string mode) throws FileError;
2261 public IOStatus read_chars (char[] buf, out size_t bytes_read) throws ConvertError, IOChannelError;
2262 public IOStatus read_unichar (out unichar thechar) throws ConvertError, IOChannelError;
2263 public IOStatus read_line (out string str_return, out size_t length, out size_t terminator_pos) throws ConvertError, IOChannelError;
2264 public IOStatus read_line_string (StringBuilder buffer, out size_t terminator_pos) throws ConvertError, IOChannelError;
2265 public IOStatus read_to_end (out string str_return, out size_t length) throws ConvertError, IOChannelError;
2266 public IOStatus write_chars (char[] buf, out size_t bytes_written) throws ConvertError, IOChannelError;
2267 public IOStatus write_unichar (unichar thechar) throws ConvertError, IOChannelError;
2268 public IOStatus flush () throws IOChannelError;
2269 public IOStatus seek_position (int64 offset, SeekType type) throws IOChannelError;
2270 public IOStatus shutdown (bool flush) throws IOChannelError;
2271 [CCode (cname = "g_io_create_watch")]
2272 public IOSource create_watch (IOCondition condition);
2273 [CCode (cname = "g_io_add_watch")]
2274 public uint add_watch (IOCondition condition, IOFunc func);
2275 [CCode (cname = "g_io_add_watch_full")]
2276 public uint add_watch_full (int priority, IOCondition condition, owned IOFunc func);
2277 public size_t get_buffer_size ();
2278 public void set_buffer_size (size_t size);
2279 public IOCondition get_buffer_condition ();
2280 public IOFlags get_flags ();
2281 public IOStatus set_flags (IOFlags flags) throws IOChannelError;
2282 public unowned string get_line_term (out int length);
2283 public void set_line_term (string line_term, int length);
2284 public bool get_buffered ();
2285 public void set_buffered (bool buffered);
2286 public unowned string get_encoding ();
2287 public IOStatus set_encoding (string? encoding) throws IOChannelError;
2288 public bool get_close_on_unref ();
2289 public void set_close_on_unref (bool do_close);
2293 [CCode (cname = "GSource")]
2294 public class IOSource : Source {
2295 [CCode (cname = "g_io_create_watch")]
2296 public IOSource (IOChannel channel, IOCondition condition);
2297 [CCode (cname = "g_source_set_callback")]
2298 public void set_callback ([CCode (type = "GSourceFunc")] owned IOFunc func);
2301 [CCode (cprefix = "G_SEEK_", has_type_id = false)]
2302 public enum SeekType {
2308 [CCode (has_type_id = false)]
2309 public enum IOStatus {
2316 public errordomain IOChannelError {
2326 public static GLib.Quark quark ();
2330 [CCode (cprefix = "G_IO_")]
2331 public enum IOCondition {
2340 public delegate bool IOFunc (IOChannel source, IOCondition condition);
2342 [CCode (cprefix = "G_IO_FLAG_", has_type_id = false)]
2344 public enum IOFlags {
2356 /* Error Reporting */
2360 [CCode (copy_function = "g_error_copy", free_function = "g_error_free")]
2361 public class Error {
2363 public Error (Quark domain, int code, string format, ...);
2364 public Error.literal (Quark domain, int code, string message);
2366 public Error.valist (Quark domain, int code, string format, va_list args);
2367 public Error copy ();
2368 public bool matches (Quark domain, int code);
2369 [CCode (cname = "g_prefix_error")]
2370 public static void prefix (out Error? dest, string format, ...);
2371 [CCode (cname = "g_propagate_error")]
2372 public static void propagate (out Error? dest, owned Error src);
2373 [CCode (cname = "g_propagate_prefixed_error")]
2374 public static void propagate_prefixed (out Error? dest, owned Error src, string format, ...);
2375 [CCode (cname = "g_set_error")]
2376 public static void @set (out Error? dest, Quark domain, int code, string format, ...);
2377 [CCode (cname = "g_set_error_literal")]
2378 public static void set_literal (out Error? dest, Quark domain, int code, string message);
2380 public Quark domain;
2382 public string message;
2385 /* Message Output and Debugging Functions */
2388 public static void print (string format, ...);
2389 public static void set_print_handler (PrintFunc func);
2390 [CCode (has_target = false)]
2391 public delegate void PrintFunc (string text);
2393 public static void printerr (string format, ...);
2394 public static void set_printerr_handler (PrintFunc func);
2396 public static void return_if_fail (bool expr);
2397 [CCode (sentinel = "")]
2398 public static void return_val_if_fail (bool expr, ...);
2400 public static void return_if_reached ();
2402 [CCode (sentinel = "")]
2403 public static void return_val_if_reached (...);
2404 [Version (since = "2.16")]
2405 public static void warn_if_fail (bool expr);
2406 [Version (since = "2.16")]
2407 public static void warn_if_reached ();
2410 public static void assert (bool expr);
2412 [Version (since = "2.46")]
2413 public static void assert_cmpmem (uint8[] m1, uint8[] m2);
2415 public static void assert_error (Error? error, Quark error_domain, int error_code);
2417 [Version (since = "2.38")]
2418 public static void assert_false (bool expr);
2420 [Version (since = "2.38")]
2421 public static void assert_true (bool expr);
2423 [Version (since = "2.38")]
2424 public static void assert_null (void* expr);
2426 public static void assert_no_error (Error? error);
2428 [Version (since = "2.40")]
2429 public static void assert_nonnull (void* expr);
2431 public static void assert_not_reached ();
2433 public static void on_error_query (string? prg_name = null);
2434 public static void on_error_stack_trace (string? prg_name = null);
2435 [CCode (cname = "G_BREAKPOINT")]
2436 public static void breakpoint ();
2438 /* Message Logging */
2440 [CCode (cprefix = "G_LOG_", has_type_id = false)]
2442 public enum LogLevelFlags {
2447 /* GLib log levels */
2458 [CCode (cprefix = "G_LOG_WRITER_", has_type_id = false)]
2459 [Version (since = "2.50")]
2460 public enum LogWriterOutput {
2465 [CCode (has_type_id = false, simple_generics = true)]
2466 [Version (since = "2.50")]
2467 public struct LogField<T> {
2468 public unowned string key;
2469 public unowned T @value;
2470 public ssize_t length;
2473 public void logv (string? log_domain, LogLevelFlags log_level, string format, va_list args);
2476 public void log (string? log_domain, LogLevelFlags log_level, string format, ...);
2478 [Version (since = "2.50")]
2479 public void log_structured (string? log_domain, LogLevelFlags log_levels, ...);
2480 [Version (since = "2.50")]
2481 public void log_structured_array (LogLevelFlags log_levels, LogField[] fields);
2483 [Version (since = "2.50")]
2484 public void log_variant (string? log_domain, LogLevelFlags log_levels, GLib.Variant fields);
2488 public void message (string format, ...);
2491 public void warning (string format, ...);
2494 public void critical (string format, ...);
2498 public void error (string format, ...);
2501 [Version (since = "2.6")]
2502 public void debug (string format, ...);
2505 [Version (since = "2.40")]
2506 public void info (string format, ...);
2507 [CCode (cname = "G_DEBUG_HERE")]
2508 [Version (since = "2.50")]
2509 public void debug_here ();
2511 public delegate void LogFunc (string? log_domain, LogLevelFlags log_levels, string message);
2512 [Version (since = "2.50")]
2513 public delegate LogWriterOutput LogWriterFunc (LogLevelFlags log_level, LogField[] fields);
2516 public static uint set_handler (string? log_domain, LogLevelFlags log_levels, LogFunc log_func);
2517 [Version (since = "2.46")]
2518 public static void set_handler_full (string? log_domain, LogLevelFlags log_levels, owned LogFunc log_func);
2519 [Version (since = "2.6")]
2520 public static void set_default_handler (LogFunc log_func);
2521 [CCode (delegate_target = false)]
2522 public static GLib.LogFunc default_handler;
2523 public static LogLevelFlags set_fatal_mask (string log_domain, LogLevelFlags log_levels);
2524 public static LogLevelFlags set_always_fatal (LogLevelFlags log_levels);
2525 public static void remove_handler (string? log_domain, uint handler_id);
2527 public const string FILE;
2528 public const int LINE;
2529 public const string METHOD;
2531 [Version (since = "2.50")]
2532 public static void set_writer_func (owned LogWriterFunc func);
2533 [Version (since = "2.50")]
2534 public static bool writer_supports_color (int output_fd);
2535 [Version (since = "2.50")]
2536 public static bool writer_is_journald (int output_fd);
2537 [Version (since = "2.50")]
2538 public static string writer_format_fields (LogLevelFlags log_levels, LogField[] fields, bool use_color);
2539 [Version (since = "2.50")]
2540 public static LogWriterOutput writer_journald (LogLevelFlags log_levels, LogField[] fields, void* user_data);
2541 [Version (since = "2.50")]
2542 public static LogWriterOutput writer_standard_streams (LogLevelFlags log_levels, LogField[] fields, void* user_data);
2543 [Version (since = "2.50")]
2544 public static LogWriterOutput writer_default (LogLevelFlags log_levels, LogField[] fields, void* user_data);
2547 [CCode (has_type_id = false)]
2548 public struct DebugKey {
2553 public uint parse_debug_string (string? debug_string, DebugKey[] keys);
2555 /* String Utility Functions */
2557 public string strdup (string str);
2558 [CCode (array_length = false, array_null_terminated = true)]
2559 public string[] strdupv ([CCode (array_length = false, array_null_terminated = true)] string[] str_array);
2561 public void strfreev (string** str_array);
2562 [Version (since = "2.6")]
2563 public uint strv_length ([CCode (array_length = false, array_null_terminated = true)] string[] str_array);
2564 [Version (since = "2.44")]
2565 public bool strv_contains ([CCode (array_length = false, array_null_terminated = true)] string[] str_array, string str);
2567 [CCode (cname = "errno", cheader_filename = "errno.h")]
2569 public unowned string strerror (int errnum);
2571 /* Character Set Conversions */
2573 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;
2574 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;
2575 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;
2576 public static bool get_charset (out unowned string charset);
2577 public static bool get_filename_charsets ([CCode (array_length = false, array_null_terminated = true)] out unowned string[] charsets);
2580 public struct IConv {
2581 public static IConv open (string to_codeset, string from_codeset);
2582 [CCode (cname = "g_iconv")]
2583 public size_t iconv ([CCode (array_length = false)] ref char[] inbuf, ref size_t inbytes_left, [CCode (array_length = false)] ref char[] outbuf, ref size_t outbytes_left);
2584 public int close ();
2587 namespace Filename {
2588 public static string to_utf8 (string opsysstring, ssize_t len, out size_t bytes_read, out size_t bytes_written) throws ConvertError;
2589 public static string from_utf8 (string utf8string, ssize_t len, out size_t bytes_read, out size_t bytes_written) throws ConvertError;
2590 public static string from_uri (string uri, out string hostname = null) throws ConvertError;
2591 public static string to_uri (string filename, string? hostname = null) throws ConvertError;
2592 [Version (since = "2.6")]
2593 public static string display_name (string filename);
2594 [Version (since = "2.6")]
2595 public static string display_basename (string filename);
2598 public errordomain ConvertError {
2605 public static GLib.Quark quark ();
2608 /* Base64 Encoding */
2610 [Version (since = "2.12")]
2612 public static size_t encode_step (uchar[] _in, bool break_lines, char* _out, ref int state, ref int save);
2613 public static size_t encode_close (bool break_lines, char* _out, ref int state, ref int save);
2614 public static string encode (uchar[] data);
2615 public static size_t decode_step (char[] _in, uchar* _out, ref int state, ref uint save);
2616 [CCode (array_length_type = "size_t")]
2617 public static uchar[] decode (string text);
2620 /* Data Checksums */
2622 [Version (since = "2.16")]
2623 [CCode (cprefix = "G_CHECKSUM_", has_type_id = false)]
2624 public enum ChecksumType {
2628 [Version (since = "2.52")]
2630 [Version (since = "2.36")]
2633 public ssize_t get_length ();
2637 [Version (since = "2.16")]
2638 [CCode (free_function = "g_checksum_free")]
2639 public class Checksum {
2640 public Checksum (ChecksumType checksum_type);
2641 public Checksum copy ();
2642 public void update ([CCode (array_length = false)] uchar[] data, size_t length);
2643 public unowned string get_string ();
2644 public void get_digest ([CCode (array_length = false)] uint8[] buffer, ref size_t digest_len);
2645 [CCode (cname = "g_compute_checksum_for_data")]
2646 public static string compute_for_data (ChecksumType checksum_type, uchar[] data);
2647 [CCode (cname = "g_compute_checksum_for_string")]
2648 public static string compute_for_string (ChecksumType checksum_type, string str, size_t length = -1);
2649 [Version (since = "2.34")]
2650 [CCode (cname = "g_compute_checksum_for_bytes")]
2651 public static string compute_for_bytes (ChecksumType checksum_type, Bytes data);
2654 /* Secure HMAC Digests */
2657 [Version (since = "2.30")]
2658 [CCode (ref_function = "g_hmac_ref", unref_function = "g_hmac_unref")]
2660 public Hmac (ChecksumType digest_type, [CCode (array_length_type = "gsize")] uint8[] key);
2661 public Hmac copy ();
2662 public void update ([CCode (array_length_type = "gssize")] uint8[] data);
2663 public unowned string get_string ();
2664 public void get_digest ([CCode (array_length = false)] uint8[] buffer, ref size_t digest_len);
2665 [Version (since = "2.30")]
2666 [CCode (cname = "g_compute_hmac_for_data")]
2667 public static string compute_for_data (ChecksumType checksum_type, uint8[] key, uint8[] data);
2668 [Version (since = "2.30")]
2669 [CCode (cname = "g_compute_hmac_for_string")]
2670 public static string compute_for_string (ChecksumType checksum_type, uint8[] key, string str, size_t length = -1);
2671 [Version (since = "2.50")]
2672 [CCode (cname = "g_compute_hmac_for_bytes")]
2673 public static string compute_hmac_for_bytes (ChecksumType checksum_type, Bytes key, Bytes data);
2676 /* Date and Time Functions */
2678 [CCode (has_type_id = false)]
2679 public struct TimeVal {
2681 public long tv_usec;
2683 [CCode (cname = "g_get_current_time")]
2685 [CCode (cname = "g_get_current_time")]
2686 public void get_current_time ();
2687 public void add (long microseconds);
2688 [Version (since = "2.12")]
2689 [CCode (instance_pos = -1)]
2690 public bool from_iso8601 (string iso_date);
2691 [Version (since = "2.12")]
2692 public string to_iso8601 ();
2695 [Version (since = "2.28")]
2696 public static int64 get_monotonic_time ();
2697 [Version (since = "2.28")]
2698 public static int64 get_real_time ();
2700 public struct DateDay : uchar {
2701 [CCode (cname = "G_DATE_BAD_DAY")]
2702 public static DateDay BAD_DAY;
2704 [CCode (cname = "g_date_valid_day")]
2705 public bool valid ();
2708 [CCode (cprefix = "G_DATE_", has_type_id = false)]
2709 public enum DateMonth {
2724 [CCode (cname = "g_date_get_days_in_month")]
2725 public uchar get_days_in_month (DateYear year);
2726 [CCode (cname = "g_date_valid_month")]
2727 public bool valid ();
2730 public struct DateYear : ushort {
2731 [CCode (cname = "G_DATE_BAD_YEAR")]
2732 public static DateDay BAD_YEAR;
2734 [CCode (cname = "g_date_is_leap_year")]
2735 public bool is_leap_year ();
2736 [CCode (cname = "g_date_get_monday_weeks_in_year")]
2737 public uchar get_monday_weeks_in_year ();
2738 [CCode (cname = "g_date_get_sunday_weeks_in_year")]
2739 public uchar get_sunday_weeks_in_year ();
2740 [CCode (cname = "g_date_valid_year")]
2741 public bool valid ();
2744 [CCode (cprefix = "G_DATE_", has_type_id = false)]
2745 public enum DateWeekday {
2755 [CCode (cname = "g_date_valid_weekday")]
2756 public bool valid ();
2759 [CCode (cprefix = "G_DATE_", has_type_id = false)]
2760 public enum DateDMY {
2766 [CCode (type_id = "G_TYPE_DATE")]
2767 public struct Date {
2768 public void clear (uint n_dates = 1);
2769 public void set_day (DateDay day);
2770 public void set_month (DateMonth month);
2771 public void set_year (DateYear year);
2772 public void set_dmy (DateDay day, int month, DateYear y);
2773 public void set_julian (uint julian_day);
2774 [Version (since = "2.10")]
2775 public void set_time_t (time_t timet);
2776 [Version (since = "2.10")]
2777 public void set_time_val (TimeVal timeval);
2778 public void set_parse (string str);
2779 public void add_days (uint n_days);
2780 public void subtract_days (uint n_days);
2781 public void add_months (uint n_months);
2782 public void subtract_months (uint n_months);
2783 public void add_years (uint n_years);
2784 public void subtract_years (uint n_years);
2785 public int days_between (Date date2);
2786 public int compare (Date rhs);
2787 public void clamp (Date min_date, Date max_date);
2788 public void order (Date date2);
2789 public DateDay get_day ();
2790 public DateMonth get_month ();
2791 public DateYear get_year ();
2792 public uint get_julian ();
2793 public DateWeekday get_weekday ();
2794 public uint get_day_of_year ();
2795 public bool is_first_of_month ();
2796 public bool is_last_of_month ();
2797 public uint get_monday_week_of_year ();
2798 public uint get_sunday_week_of_year ();
2799 [Version (since = "2.6")]
2800 public uint get_iso8601_week_of_year ();
2801 [CCode (instance_pos = -1)]
2802 public size_t strftime (char[] s, string format);
2803 [CCode (cname = "g_date_to_struct_tm")]
2804 public void to_time (out Time tm);
2805 public bool valid ();
2806 public static uchar get_days_in_month (DateMonth month, DateYear year);
2807 public static bool valid_day (DateDay day);
2808 public static bool valid_dmy (DateDay day, DateMonth month, DateYear year);
2809 public static bool valid_julian (uint julian_date);
2810 public static bool valid_weekday (DateWeekday weekday);
2813 [CCode (cname = "struct tm", cheader_filename = "time.h", has_type_id = false)]
2814 public struct Time {
2815 [CCode (cname = "tm_sec")]
2817 [CCode (cname = "tm_min")]
2819 [CCode (cname = "tm_hour")]
2821 [CCode (cname = "tm_mday")]
2823 [CCode (cname = "tm_mon")]
2825 [CCode (cname = "tm_year")]
2827 [CCode (cname = "tm_wday")]
2829 [CCode (cname = "tm_yday")]
2830 public int day_of_year;
2831 [CCode (cname = "tm_isdst")]
2834 [CCode (cname = "gmtime_r")]
2835 static void gmtime_r (ref time_t time, out Time result);
2836 [CCode (cname = "localtime_r")]
2837 static void localtime_r (ref time_t time, out Time result);
2839 public static Time gm (time_t time) {
2841 gmtime_r (ref time, out result);
2844 public static Time local (time_t time) {
2846 localtime_r (ref time, out result);
2850 public string to_string () {
2851 return "%04d-%02d-%02d %02d:%02d:%02d".printf (year + 1900, month + 1, day, hour, minute, second);
2854 public string format (string format) {
2855 var buffer = new char[64];
2856 this.strftime (buffer, format);
2857 return (string) buffer;
2860 [CCode (cname = "mktime")]
2861 public time_t mktime ();
2863 [CCode (cname = "strftime", instance_pos = -1)]
2864 public size_t strftime (char[] s, string format);
2865 [CCode (cname = "strptime", instance_pos = -1)]
2866 public unowned string? strptime (string buf, string format);
2870 [Version (since = "2.26")]
2871 [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")]
2872 [IntegerType (rank = 10)]
2873 public struct TimeSpan : int64 {
2874 public const TimeSpan DAY;
2875 public const TimeSpan HOUR;
2876 public const TimeSpan MINUTE;
2877 public const TimeSpan SECOND;
2878 public const TimeSpan MILLISECOND;
2882 [Version (since = "2.26")]
2883 [CCode (ref_function = "g_date_time_ref", unref_function = "g_date_time_unref", type_id = "G_TYPE_DATE_TIME")]
2884 public class DateTime {
2885 public DateTime.now (TimeZone tz);
2886 public DateTime.now_local ();
2887 public DateTime.now_utc ();
2888 public DateTime.from_unix_local (int64 t);
2889 public DateTime.from_unix_utc (int64 t);
2890 public DateTime.from_timeval_local (TimeVal tv);
2891 public DateTime.from_timeval_utc (TimeVal tv);
2892 public DateTime (TimeZone tz, int year, int month, int day, int hour, int minute, double seconds);
2893 public DateTime.local (int year, int month, int day, int hour, int minute, double seconds);
2894 public DateTime.utc (int year, int month, int day, int hour, int minute, double seconds);
2895 public DateTime add (TimeSpan timespan);
2896 public DateTime add_years (int years);
2897 public DateTime add_months (int months);
2898 public DateTime add_weeks (int weeks);
2899 public DateTime add_days (int days);
2900 public DateTime add_hours (int hours);
2901 public DateTime add_minutes (int minutes);
2902 public DateTime add_seconds (double seconds);
2903 public DateTime add_full (int years, int months, int days, int hours = 0, int minutes = 0, double seconds = 0);
2904 public int compare (DateTime dt);
2905 public TimeSpan difference (DateTime begin);
2906 public uint hash ();
2907 public bool equal (DateTime dt);
2908 public void get_ymd (out int year, out int month, out int day);
2909 public int get_year ();
2910 public int get_month ();
2911 public int get_day_of_month ();
2912 public int get_week_numbering_year ();
2913 public int get_week_of_year ();
2914 public int get_day_of_week ();
2915 public int get_day_of_year ();
2916 public int get_hour ();
2917 public int get_minute ();
2918 public int get_second ();
2919 public int get_microsecond ();
2920 public double get_seconds ();
2921 public int64 to_unix ();
2922 public bool to_timeval (out TimeVal tv);
2923 public TimeSpan get_utc_offset ();
2924 public unowned string get_timezone_abbreviation ();
2925 public bool is_daylight_savings ();
2926 public DateTime to_timezone (TimeZone tz);
2927 public DateTime to_local ();
2928 public DateTime to_utc ();
2929 public string format (string format);
2930 public string to_string () {
2931 return this.format ("%FT%H:%M:%S%z");
2935 public enum TimeType {
2942 [Version (since = "2.26")]
2943 [CCode (ref_function = "g_time_zone_ref", unref_function = "g_time_zone_unref")]
2944 public class TimeZone {
2945 public TimeZone (string identifier);
2946 public TimeZone.utc ();
2947 public TimeZone.local ();
2948 public int find_interval (TimeType type, int64 time);
2949 public int adjust_time (TimeType type, ref int64 time);
2950 public unowned string get_abbreviation (int interval);
2951 public int32 get_offset (int interval);
2952 public bool is_dst (int interval);
2955 /* Random Numbers */
2958 [CCode (copy_function = "g_rand_copy", free_function = "g_rand_free")]
2960 public Rand.with_seed (uint32 seed);
2961 [Version (since = "2.4")]
2962 public Rand.with_seed_array ([CCode (array_length = false)] uint32[] seed, uint seed_length);
2964 public void set_seed (uint32 seed);
2965 [Version (since = "2.4")]
2966 public void set_seed_array ([CCode (array_length = false)] uint32[] seed, uint seed_length);
2967 public bool boolean ();
2968 [CCode (cname = "g_rand_int")]
2969 public uint32 next_int ();
2970 public int32 int_range (int32 begin, int32 end);
2971 [CCode (cname = "g_rand_double")]
2972 public double next_double ();
2973 public double double_range (double begin, double end);
2977 public static void set_seed (uint32 seed);
2978 public static bool boolean ();
2979 [CCode (cname = "g_random_int")]
2980 public static uint32 next_int ();
2981 public static int32 int_range (int32 begin, int32 end);
2982 [CCode (cname = "g_random_double")]
2983 public static double next_double ();
2984 public static double double_range (double begin, double end);
2988 [Version (since = "2.52")]
2989 public static bool string_is_valid (string str);
2990 [Version (since = "2.52")]
2991 public static string string_random ();
2994 /* Miscellaneous Utility Functions */
2996 namespace Environment {
2997 [Version (since = "2.2")]
2998 [CCode (cname = "g_get_application_name")]
2999 public static unowned string? get_application_name ();
3000 [Version (since = "2.2")]
3001 [CCode (cname = "g_set_application_name")]
3002 public static void set_application_name (string application_name);
3003 [CCode (cname = "g_get_prgname")]
3004 public static unowned string get_prgname ();
3005 [CCode (cname = "g_set_prgname")]
3006 public static void set_prgname (string application_name);
3007 [CCode (cname = "g_getenv")]
3008 public static unowned string? get_variable (string variable);
3009 [Version (since = "2.4")]
3010 [CCode (cname = "g_setenv")]
3011 public static bool set_variable (string variable, string value, bool overwrite);
3012 [Version (since = "2.4")]
3013 [CCode (cname = "g_unsetenv")]
3014 public static void unset_variable (string variable);
3015 [Version (since = "2.8")]
3016 [CCode (cname = "g_listenv", array_length = false, array_null_terminated = true)]
3017 public static string[] list_variables ();
3018 [CCode (cname = "g_get_user_name")]
3019 public static unowned string get_user_name ();
3020 [CCode (cname = "g_get_real_name")]
3021 public static unowned string get_real_name ();
3022 [Version (since = "2.6")]
3023 [CCode (cname = "g_get_user_cache_dir")]
3024 public static unowned string get_user_cache_dir ();
3025 [Version (since = "2.6")]
3026 [CCode (cname = "g_get_user_data_dir")]
3027 public static unowned string get_user_data_dir ();
3028 [Version (since = "2.6")]
3029 [CCode (cname = "g_get_user_config_dir")]
3030 public static unowned string get_user_config_dir ();
3031 [CCode (cname = "g_get_user_runtime_dir")]
3032 public static unowned string get_user_runtime_dir ();
3033 [Version (since = "2.14")]
3034 [CCode (cname = "g_get_user_special_dir")]
3035 public static unowned string get_user_special_dir (UserDirectory directory);
3036 [Version (since = "2.6")]
3037 [CCode (cname = "g_get_system_data_dirs", array_length = false, array_null_terminated = true)]
3038 public static unowned string[] get_system_data_dirs ();
3039 [Version (since = "2.6")]
3040 [CCode (cname = "g_get_system_config_dirs", array_length = false, array_null_terminated = true)]
3041 public static unowned string[] get_system_config_dirs ();
3042 [Version (since = "2.8")]
3043 [CCode (cname = "g_get_host_name")]
3044 public static unowned string get_host_name ();
3045 [CCode (cname = "g_get_home_dir")]
3046 public static unowned string get_home_dir ();
3047 [CCode (cname = "g_get_tmp_dir")]
3048 public static unowned string get_tmp_dir ();
3049 [CCode (cname = "g_get_current_dir")]
3050 public static string get_current_dir ();
3051 [CCode (cname = "g_find_program_in_path")]
3052 public static string? find_program_in_path (string program);
3053 [Version (deprecated_since = "2.32")]
3054 [CCode (cname = "g_atexit")]
3055 public static void atexit (VoidFunc func);
3056 [Version (since = "2.8")]
3057 [CCode (cname = "g_chdir")]
3058 public static int set_current_dir (string path);
3062 [Version (since = "2.28")]
3063 [CCode (cname = "g_get_environ", array_length = false, array_null_terminated = true)]
3064 public static string[] get ();
3065 [Version (since = "2.32")]
3066 [CCode (cname = "g_environ_getenv")]
3067 public static unowned string? get_variable ([CCode (array_length = false, array_null_terminated = true)] string[]? envp, string variable);
3068 [Version (since = "2.32")]
3069 [CCode (cname = "g_environ_setenv", array_length = false, array_null_terminated = true)]
3070 public static string[] set_variable ([CCode (array_length = false, array_null_terminated = true)] owned string[]? envp, string variable, string value, bool overwrite = true);
3071 [Version (since = "2.32")]
3072 [CCode (cname = "g_environ_unsetenv", array_length = false, array_null_terminated = true)]
3073 public static string[] unset_variable ([CCode (array_length = false, array_null_terminated = true)] owned string[]? envp, string variable);
3076 [Version (since = "2.14")]
3077 [CCode (has_type_id = false)]
3078 public enum UserDirectory {
3087 [CCode (cname = "G_USER_N_DIRECTORIES")]
3091 namespace Hostname {
3092 public static bool is_non_ascii (string hostname);
3093 public static bool is_ascii_encoded (string hostname);
3094 public static bool is_ip_address (string hostname);
3095 public static string to_ascii (string hostname);
3096 public static string to_unicode (string hostname);
3100 public static bool is_absolute (string file_name);
3101 public static unowned string skip_root (string file_name);
3102 public static string get_basename (string file_name);
3103 public static string get_dirname (string file_name);
3104 [CCode (cname = "g_build_filename")]
3105 public static string build_filename (string first_element, ...);
3106 [CCode (cname = "g_build_path")]
3107 public static string build_path (string separator, string first_element, ...);
3109 [CCode (cname = "G_DIR_SEPARATOR")]
3110 public const char DIR_SEPARATOR;
3111 [CCode (cname = "G_DIR_SEPARATOR_S")]
3112 public const string DIR_SEPARATOR_S;
3113 [Version (since = "2.6")]
3114 [CCode (cname = "G_IS_DIR_SEPARATOR")]
3115 public static bool is_dir_separator (unichar c);
3116 [CCode (cname = "G_SEARCHPATH_SEPARATOR")]
3117 public const char SEARCHPATH_SEPARATOR;
3118 [CCode (cname = "G_SEARCHPATH_SEPARATOR_S")]
3119 public const string SEARCHPATH_SEPARATOR_S;
3123 public static int nth_lsf (ulong mask, int nth_bit);
3124 public static int nth_msf (ulong mask, int nth_bit);
3125 public static uint storage (ulong number);
3128 namespace SpacedPrimes {
3129 public static uint closest (uint num);
3132 [CCode (has_target = false)]
3133 public delegate void FreeFunc (void* data);
3134 [CCode (has_target = false)]
3135 public delegate void VoidFunc ();
3137 [Version (deprecated_since = "2.30", replacement = "format_size", since = "2.16")]
3138 public string format_size_for_display (int64 size);
3140 [Version (since = "2.30")]
3141 [CCode (cname = "g_format_size_full")]
3142 public string format_size (uint64 size, FormatSizeFlags flags = FormatSizeFlags.DEFAULT);
3144 [Version (since = "2.30")]
3145 [CCode (cprefix = "G_FORMAT_SIZE_", has_type_id = false)]
3147 public enum FormatSizeFlags {
3153 /* Lexical Scanner */
3154 [CCode (has_target = false)]
3155 public delegate void ScannerMsgFunc (Scanner scanner, string message, bool error);
3158 [CCode (free_function = "g_scanner_destroy")]
3159 public class Scanner {
3160 public unowned string input_name;
3161 public TokenType token;
3162 public TokenValue value;
3164 public uint position;
3165 public TokenType next_token;
3166 public TokenValue next_value;
3167 public uint next_line;
3168 public uint next_position;
3169 public ScannerMsgFunc msg_handler;
3170 public ScannerConfig? config;
3171 public Scanner (ScannerConfig? config_templ);
3172 public void input_file (int input_fd);
3173 public void sync_file_offset ();
3174 public void input_text (string text, uint text_len);
3175 public TokenType peek_next_token ();
3176 public TokenType get_next_token ();
3178 public int cur_line ();
3179 public int cur_position ();
3180 public TokenType cur_token ();
3181 public TokenValue cur_value ();
3182 public uint set_scope (uint scope_id);
3183 public void scope_add_symbol (uint scope_id, string symbol, void* value);
3184 public void scope_foreach_symbol (uint scope_id, HFunc<string, void*> func);
3185 public void* scope_lookup_symbol (uint scope_id, string symbol);
3186 public void scope_remove_symbol (uint scope_id, string symbol);
3187 public void* lookup_symbol (string symbol);
3189 public void warn (string format, ...);
3191 public void error (string format, ...);
3192 public void unexp_token (TokenType expected_token, string? identifier_spec, string? symbol_spec, string? symbol_name, string? message, bool is_error);
3195 public struct ScannerConfig {
3196 public string* cset_skip_characters;
3197 public string* cset_identifier_first;
3198 public string* cset_identifier_nth;
3199 public string* cpair_comment_single;
3200 public bool case_sensitive;
3201 public bool skip_comment_multi;
3202 public bool skip_comment_single;
3203 public bool scan_comment_multi;
3204 public bool scan_identifier;
3205 public bool scan_identifier_1char;
3206 public bool scan_identifier_NULL;
3207 public bool scan_symbols;
3208 public bool scan_binary;
3209 public bool scan_octal;
3210 public bool scan_float;
3211 public bool scan_hex;
3212 public bool scan_hex_dollar;
3213 public bool scan_string_sq;
3214 public bool scan_string_dq;
3215 public bool numbers_2_int;
3216 public bool int_2_float;
3217 public bool identifier_2_string;
3218 public bool char_2_token;
3219 public bool symbol_2_token;
3220 public bool scope_0_fallback;
3221 public bool store_int64;
3224 [CCode (lower_case_cprefix="G_CSET_")]
3225 namespace CharacterSet {
3226 public const string A_2_Z;
3227 public const string a_2_z;
3228 public const string DIGITS;
3229 public const string LATINC;
3230 public const string LATINS;
3233 [CCode (cprefix = "G_TOKEN_", has_type_id = false)]
3234 public enum TokenType {
3262 public struct TokenValue {
3263 [CCode (cname="v_symbol")]
3264 public void* symbol;
3265 [CCode (cname="v_identifier")]
3266 public unowned string identifier;
3267 [CCode (cname="v_binary")]
3268 public ulong binary;
3269 [CCode (cname="v_octal")]
3271 [CCode (cname="v_int")]
3273 [CCode (cname="v_int64")]
3275 [CCode (cname="v_float")]
3276 public double float;
3277 [CCode (cname="v_hex")]
3279 [CCode (cname="v_string")]
3280 public unowned string string;
3281 [CCode (cname="v_comment")]
3282 public unowned string comment;
3283 [CCode (cname="v_char")]
3285 [CCode (cname="v_error")]
3289 [CCode (cprefix = "G_ERR_", has_type_id = false)]
3290 public enum ErrorType {
3293 UNEXP_EOF_IN_STRING,
3294 UNEXP_EOF_IN_COMMENT,
3301 /* Automatic String Completion */
3303 [Version (deprecated_since = "2.26")]
3305 [CCode (free_function = "g_completion_free")]
3306 public class Completion {
3307 public Completion (CompletionFunc? func = null);
3308 public List<void*> items;
3309 public CompletionFunc func;
3310 public string prefix;
3311 public List<void*> cache;
3312 public CompletionStrncmpFunc strncmp_func;
3313 public void add_items (List<void*> items);
3314 public void remove_items (List<void*> items);
3315 public void clear_items ();
3316 public unowned List<void*> complete (string prefix, out string? new_prefix = null);
3317 [Version (since = "2.4")]
3318 public unowned List<void*> complete_utf8 (string prefix, out string? new_prefix = null);
3321 [CCode (has_target = false)]
3322 public delegate string CompletionFunc (void* item);
3323 [CCode (has_target = false)]
3324 public delegate int CompletionStrncmpFunc (string s1, string s2, size_t n);
3329 [CCode (free_function = "g_timer_destroy")]
3330 public class Timer {
3332 public void start ();
3333 public void stop ();
3334 [Version (since = "2.4")]
3335 public void @continue ();
3336 public double elapsed (out ulong microseconds = null);
3337 public void reset ();
3340 /* Spawning Processes */
3342 public errordomain SpawnError {
3363 public static GLib.Quark quark ();
3366 [CCode (cprefix = "G_SPAWN_", has_type_id = false)]
3368 public enum SpawnFlags {
3369 LEAVE_DESCRIPTORS_OPEN,
3374 CHILD_INHERITS_STDIN,
3376 SEARCH_PATH_FROM_ENVP
3379 public delegate void SpawnChildSetupFunc ();
3380 [CCode (has_target = false, cheader_filename = "signal.h")]
3381 public delegate void SignalHandlerFunc (int signum);
3383 public unowned string strsignal (int signum);
3385 [CCode (lower_case_cprefix = "g_")]
3387 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;
3388 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;
3389 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;
3390 public static bool spawn_command_line_async (string command_line) throws SpawnError;
3391 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;
3392 [CCode (cname = "g_spawn_close_pid")]
3393 public static void close_pid (Pid pid);
3394 [Version (since = "2.34")]
3395 [CCode (cname = "g_spawn_check_exit_status")]
3396 public static bool check_exit_status (int exit_status) throws GLib.Error;
3398 /* these macros are required to examine the exit status of a process */
3399 [CCode (cname = "WIFEXITED", cheader_filename = "sys/wait.h")]
3400 public static bool if_exited (int status);
3401 [CCode (cname = "WEXITSTATUS", cheader_filename = "sys/wait.h")]
3402 public static int exit_status (int status);
3403 [CCode (cname = "WIFSIGNALED", cheader_filename = "sys/wait.h")]
3404 public static bool if_signaled (int status);
3405 [CCode (cname = "WTERMSIG", cheader_filename = "sys/wait.h")]
3406 public static ProcessSignal term_sig (int status);
3407 [CCode (cname = "WCOREDUMP", cheader_filename = "sys/wait.h")]
3408 public static bool core_dump (int status);
3409 [CCode (cname = "WIFSTOPPED", cheader_filename = "sys/wait.h")]
3410 public static bool if_stopped (int status);
3411 [CCode (cname = "WSTOPSIG", cheader_filename = "sys/wait.h")]
3412 public static ProcessSignal stop_sig (int status);
3413 [CCode (cname = "WIFCONTINUED", cheader_filename = "sys/wait.h")]
3414 public static bool if_continued (int status);
3417 [CCode (cname = "abort", cheader_filename = "stdlib.h")]
3418 public void abort ();
3420 [CCode (cname = "exit", cheader_filename = "stdlib.h")]
3421 public void exit (int status);
3422 [CCode (cname = "raise", cheader_filename = "signal.h")]
3423 public int raise (ProcessSignal sig);
3424 [CCode (cname = "signal", cheader_filename = "signal.h")]
3425 public SignalHandlerFunc @signal (ProcessSignal signum, SignalHandlerFunc handler);
3428 [CCode (cname = "int", has_type_id = false, cheader_filename = "signal.h", cprefix = "SIG")]
3429 public enum ProcessSignal {
3454 /* File Utilities */
3456 public errordomain FileError {
3482 public static GLib.Quark quark ();
3485 [CCode (has_type_id = false)]
3487 public enum FileTest {
3495 [CCode (cname = "int", cprefix = "SEEK_", has_type_id = false)]
3496 public enum FileSeek {
3503 [CCode (cname = "FILE", free_function = "fclose", cheader_filename = "stdio.h")]
3504 public class FileStream {
3505 [CCode (cname = "EOF", cheader_filename = "stdio.h")]
3506 public const int EOF;
3508 [Version (since = "2.6")]
3509 [CCode (cname = "g_fopen", cheader_filename = "glib/gstdio.h")]
3510 public static FileStream? open (string path, string mode);
3511 [CCode (cname = "fdopen")]
3512 public static FileStream? fdopen (int fildes, string mode);
3513 [CCode (cname = "fprintf")]
3515 public void printf (string format, ...);
3516 [CCode (cname = "vfprintf")]
3517 public void vprintf (string format, va_list args);
3518 [CCode (cname = "fputc", instance_pos = -1)]
3519 public void putc (char c);
3520 [CCode (cname = "fputs", instance_pos = -1)]
3521 public void puts (string s);
3522 [CCode (cname = "fgetc")]
3524 [CCode (cname = "ungetc", instance_pos = -1)]
3525 public int ungetc (int c);
3526 [CCode (cname = "fgets", instance_pos = -1)]
3527 public unowned string? gets (char[] s);
3528 [CCode (cname = "feof")]
3530 [CCode (cname = "fscanf"), ScanfFormat]
3531 public int scanf (string format, ...);
3532 [CCode (cname = "fflush")]
3533 public int flush ();
3534 [CCode (cname = "fseek")]
3535 public int seek (long offset, FileSeek whence);
3536 [CCode (cname = "ftell")]
3537 public long tell ();
3538 [CCode (cname = "rewind")]
3539 public void rewind ();
3540 [CCode (cname = "fileno")]
3541 public int fileno ();
3542 [CCode (cname = "ferror")]
3543 public int error ();
3544 [CCode (cname = "clearerr")]
3545 public void clearerr ();
3546 [CCode (cname = "fread", instance_pos = -1)]
3547 public size_t read ([CCode (array_length_pos = 2.1)] uint8[] buf, size_t size = 1);
3548 [CCode (cname = "fwrite", instance_pos = -1)]
3549 public size_t write ([CCode (array_length_pos = 2.1)] uint8[] buf, size_t size = 1);
3551 public string? read_line () {
3553 StringBuilder? ret = null;
3554 while ((c = getc ()) != EOF) {
3556 ret = new StringBuilder ();
3561 ((!)(ret)).append_c ((char) c);
3566 return ((!)(ret)).str;
3571 [CCode (cname = "struct utimbuf", cheader_filename = "sys/types.h,utime.h")]
3572 public struct UTimBuf {
3573 time_t actime; /* access time */
3574 time_t modtime; /* modification time */
3577 [CCode (lower_case_cprefix = "g_file_", cheader_filename = "glib/gstdio.h")]
3578 namespace FileUtils {
3579 public static bool get_contents (string filename, out string contents, out size_t length = null) throws FileError;
3580 [Version (since = "2.8")]
3581 public static bool set_contents (string filename, string contents, ssize_t length = -1) throws FileError;
3582 [CCode (cname = "g_file_get_contents")]
3583 public static bool get_data (string filename, [CCode (type = "gchar**", array_length_type = "size_t")] out uint8[] contents) throws FileError;
3584 [CCode (cname = "g_file_set_contents")]
3585 public static bool set_data (string filename, [CCode (type = "const char*", array_length_type = "size_t")] uint8[] contents) throws FileError;
3586 public static bool test (string filename, FileTest test);
3587 public static int open_tmp (string tmpl, out string name_used) throws FileError;
3588 [Version (since = "2.4")]
3589 public static string read_link (string filename) throws FileError;
3590 public static int error_from_errno (int err_no);
3592 [CCode (cname = "g_mkstemp")]
3593 public static int mkstemp (string tmpl);
3594 [Version (since = "2.6")]
3595 [CCode (cname = "g_rename")]
3596 public static int rename (string oldfilename, string newfilename);
3597 [Version (since = "2.6")]
3598 [CCode (cname = "g_remove")]
3599 public static int remove (string filename);
3600 [CCode (cname = "g_unlink")]
3601 public static int unlink (string filename);
3602 [Version (since = "2.8")]
3603 [CCode (cname = "g_chmod")]
3604 public static int chmod (string filename, int mode);
3605 [Version (since = "2.18")]
3606 [CCode (cname = "g_utime")]
3607 public static int utime (string filename, UTimBuf? times = null);
3609 [CCode (cname = "symlink", cheader_filename = "unistd.h")]
3610 public static int symlink (string oldpath, string newpath);
3612 [CCode (cname = "close", cheader_filename = "unistd.h")]
3613 public static int close (int fd);
3615 [Version (since = "2.36")]
3616 [CCode (cname = "g_close")]
3617 public static bool close_checked (int fd) throws FileError;
3620 [CCode (cname = "struct stat", cheader_filename = "sys/stat.h,glib/gstdio.h")]
3621 public struct Stat {
3622 [CCode (cname = "g_stat", instance_pos = -1)]
3623 public Stat (string filename);
3624 [Version (since = "2.6")]
3625 [CCode (cname = "g_lstat", instance_pos = -1)]
3626 public Stat.l (string filename);
3630 [CCode (free_function = "g_dir_close")]
3632 public static Dir open (string filename, uint _flags = 0) throws FileError;
3633 public unowned string? read_name ();
3634 public void rewind ();
3637 [CCode (cheader_filename = "glib/gstdio.h")]
3638 namespace DirUtils {
3639 [Version (since = "2.6")]
3640 [CCode (cname = "g_mkdir")]
3641 public static int create (string pathname, int mode);
3642 [Version (since = "2.8")]
3643 [CCode (cname = "g_mkdir_with_parents")]
3644 public static int create_with_parents (string pathname, int mode);
3645 [Version (since = "2.30")]
3646 [CCode (cname = "mkdtemp")]
3647 public static string mkdtemp (owned string template);
3648 [Version (since = "2.30")]
3649 [CCode (cname = "g_dir_make_tmp")]
3650 public static string make_tmp (string tmpl) throws FileError;
3651 [Version (since = "2.6")]
3652 [CCode (cname = "g_rmdir")]
3653 public static int remove (string filename);
3657 [Version (since = "2.22")]
3658 [CCode (ref_function = "g_mapped_file_ref", unref_function = "g_mapped_file_unref")]
3659 public class MappedFile {
3660 public MappedFile (string filename, bool writable) throws FileError;
3661 public size_t get_length ();
3662 public unowned char* get_contents ();
3663 [Version (since = "2.34")]
3664 public Bytes get_bytes ();
3667 [CCode (cname = "stdin", cheader_filename = "stdio.h")]
3668 public static FileStream stdin;
3670 [CCode (cname = "stdout", cheader_filename = "stdio.h")]
3671 public static FileStream stdout;
3673 [CCode (cname = "stderr", cheader_filename = "stdio.h")]
3674 public static FileStream stderr;
3679 public const string RESERVED_CHARS_ALLOWED_IN_PATH;
3680 public const string RESERVED_CHARS_ALLOWED_IN_PATH_ELEMENT;
3681 public const string RESERVED_CHARS_ALLOWED_IN_USERINFO;
3682 public const string RESERVED_CHARS_GENERIC_DELIMITERS;
3683 public const string RESERVED_CHARS_SUBCOMPONENT_DELIMITERS;
3685 [Version (since = "2.16")]
3686 public static string? parse_scheme (string uri);
3687 [Version (since = "2.16")]
3688 public static string escape_string (string unescaped, string? reserved_chars_allowed = null, bool allow_utf8 = true);
3689 [Version (since = "2.16")]
3690 public static string? unescape_string (string escaped_string, string? illegal_characters = null);
3691 [Version (since = "2.16")]
3692 public static string? unescape_segment (string? escaped_string, string? escaped_string_end, string? illegal_characters = null);
3693 [Version (since = "2.6")]
3694 [CCode (array_length = false, array_null_terminated = true)]
3695 public static string[] list_extract_uris (string uri_list);
3698 /* Shell-related Utilities */
3700 public errordomain ShellError {
3704 public static GLib.Quark quark ();
3708 public static bool parse_argv (string command_line, [CCode (array_length_pos = 1.9)] out string[] argvp) throws ShellError;
3709 public static string quote (string unquoted_string);
3710 public static string unquote (string quoted_string) throws ShellError;
3713 /* Commandline option parser */
3715 public errordomain OptionError {
3719 public static GLib.Quark quark ();
3723 [Version (since = "2.6")]
3724 [CCode (free_function = "g_option_context_free")]
3725 public class OptionContext {
3726 public OptionContext (string? parameter_string = null);
3727 [Version (since = "2.12")]
3728 public void set_summary (string summary);
3729 [Version (since = "2.12")]
3730 public unowned string get_summary ();
3731 [Version (since = "2.12")]
3732 public void set_description (string description);
3733 [Version (since = "2.12")]
3734 public unowned string get_description ();
3735 [Version (since = "2.12")]
3736 public void set_translate_func (TranslateFunc func, DestroyNotify? destroy_notify);
3737 [Version (since = "2.12")]
3738 public void set_translation_domain (string domain);
3739 public bool parse ([CCode (array_length_pos = 0.9)] ref unowned string[] argv) throws OptionError;
3740 [Version (since = "2.40")]
3741 public bool parse_strv ([CCode (array_length = false, array_null_terminated = true)] ref string[] argv) throws OptionError;
3742 public void set_help_enabled (bool help_enabled);
3743 public bool get_help_enabled ();
3744 public void set_ignore_unknown_options (bool ignore_unknown);
3745 public bool get_ignore_unknown_options ();
3746 [Version (since = "2.14")]
3747 public string get_help (bool main_help, OptionGroup? group);
3748 public void add_main_entries ([CCode (array_length = false, array_null_terminated = true)] OptionEntry[] entries, string? translation_domain);
3749 public void add_group (owned OptionGroup group);
3750 public void set_main_group (owned OptionGroup group);
3751 public unowned OptionGroup get_main_group ();
3752 [Version (since = "2.44")]
3753 public void set_strict_posix (bool strict_posix);
3754 [Version (since = "2.44")]
3755 public bool get_strict_posix ();
3758 public delegate unowned string TranslateFunc (string str);
3760 public const string OPTION_REMAINING;
3762 [CCode (has_type_id = false)]
3763 public enum OptionArg {
3776 [CCode (cprefix = "G_OPTION_FLAG_", has_type_id = false)]
3777 public enum OptionFlags {
3778 [Version (since = "2.42")]
3789 public struct OptionEntry {
3790 public unowned string long_name;
3791 public char short_name;
3794 public OptionArg arg;
3795 public void* arg_data;
3797 public unowned string description;
3798 public unowned string? arg_description;
3803 [Version (since = "2.44")]
3804 [CCode (ref_function = "g_option_group_ref", unref_function = "g_option_group_unref", type_id = "G_TYPE_OPTION_GROUP")]
3806 [Version (since = "2.6")]
3807 [CCode (free_function = "g_option_group_free")]
3809 public class OptionGroup {
3810 public OptionGroup (string name, string description, string help_description, void* user_data = null, DestroyNotify? destroy = null);
3811 public void add_entries ([CCode (array_length = false, array_null_terminated = true)] OptionEntry[] entries);
3812 public void set_parse_hooks (OptionParseFunc? pre_parse_func, OptionParseFunc? post_parse_hook);
3813 public void set_error_hook (OptionErrorFunc? error_func);
3814 public void set_translate_func (owned TranslateFunc? func);
3815 public void set_translation_domain (string domain);
3818 [CCode (has_target = false)]
3819 public delegate bool OptionParseFunc (OptionContext context, OptionGroup group, void* data) throws OptionError;
3820 [CCode (has_target = false)]
3821 public delegate void OptionErrorFunc (OptionContext context, OptionGroup group, void* data, ref Error error);
3823 /* Perl-compatible regular expressions */
3825 [Version (since = "2.14")]
3826 public errordomain RegexError {
3833 MISSING_CONTROL_CHAR,
3834 UNRECOGNIZED_ESCAPE,
3835 QUANTIFIERS_OUT_OF_ORDER,
3837 UNTERMINATED_CHARACTER_CLASS,
3838 INVALID_ESCAPE_IN_CHARACTER_CLASS,
3841 UNRECOGNIZED_CHARACTER,
3842 POSIX_NAMED_CLASS_OUTSIDE_CLASS,
3843 UNMATCHED_PARENTHESIS,
3844 INEXISTENT_SUBPATTERN_REFERENCE,
3845 UNTERMINATED_COMMENT,
3846 EXPRESSION_TOO_LARGE,
3848 VARIABLE_LENGTH_LOOKBEHIND,
3849 MALFORMED_CONDITION,
3850 TOO_MANY_CONDITIONAL_BRANCHES,
3852 UNKNOWN_POSIX_CLASS_NAME,
3853 POSIX_COLLATING_ELEMENTS_NOT_SUPPORTED,
3856 SINGLE_BYTE_MATCH_IN_LOOKBEHIND,
3858 MISSING_SUBPATTERN_NAME_TERMINATOR,
3859 DUPLICATE_SUBPATTERN_NAME,
3862 SUBPATTERN_NAME_TOO_LONG,
3863 TOO_MANY_SUBPATTERNS,
3864 INVALID_OCTAL_VALUE,
3865 TOO_MANY_BRANCHES_IN_DEFINE,
3867 INCONSISTENT_NEWLINE_OPTIONS,
3868 MISSING_BACK_REFERENCE,
3869 INVALID_RELATIVE_REFERENCE,
3870 BACKTRACKING_CONTROL_VERB_ARGUMENT_FORBIDDEN,
3871 UNKNOWN_BACKTRACKING_CONTROL_VERB,
3873 MISSING_SUBPATTERN_NAME,
3875 INVALID_DATA_CHARACTER,
3876 EXTRA_SUBPATTERN_NAME,
3877 BACKTRACKING_CONTROL_VERB_ARGUMENT_REQUIRED,
3878 INVALID_CONTROL_CHAR,
3880 NOT_SUPPORTED_IN_CLASS,
3881 TOO_MANY_FORWARD_REFERENCES,
3883 CHARACTER_VALUE_TOO_LARGE;
3884 public static GLib.Quark quark ();
3887 [Version (since = "2.14")]
3888 [CCode (cprefix = "G_REGEX_", has_type_id = false)]
3890 public enum RegexCompileFlags {
3910 [Version (since = "2.14")]
3911 [CCode (cprefix = "G_REGEX_MATCH_", has_type_id = false)]
3913 public enum RegexMatchFlags {
3932 [Version (since = "2.14")]
3933 [CCode (ref_function = "g_regex_ref", unref_function = "g_regex_unref", type_id = "G_TYPE_REGEX")]
3934 public class Regex {
3935 public Regex (string pattern, RegexCompileFlags compile_options = 0, RegexMatchFlags match_options = 0) throws RegexError;
3936 public unowned string get_pattern ();
3937 [Version (since = "2.26")]
3938 public RegexCompileFlags get_compile_flags ();
3939 [Version (since = "2.34")]
3940 public bool get_has_cr_or_lf ();
3941 [Version (since = "2.26")]
3942 public RegexMatchFlags get_match_flags ();
3943 public int get_max_backref ();
3944 [Version (since = "2.38")]
3945 public int get_max_lookbehind ();
3946 public int get_capture_count ();
3947 public int get_string_number (string name);
3948 public static string escape_string (string str, int length = -1);
3949 public static bool match_simple (string pattern, string str, RegexCompileFlags compile_options = 0, RegexMatchFlags match_options = 0);
3950 public bool match (string str, RegexMatchFlags match_options = 0, out MatchInfo match_info = null);
3951 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;
3952 public bool match_all (string str, RegexMatchFlags match_options = 0, out MatchInfo match_info = null);
3953 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;
3954 [CCode (array_length = false, array_null_terminated = true)]
3955 public static string[] split_simple (string pattern, string str, RegexCompileFlags compile_options = 0, RegexMatchFlags match_options = 0);
3956 [CCode (array_length = false, array_null_terminated = true)]
3957 public string[] split (string str, RegexMatchFlags match_options = 0);
3958 [CCode (array_length = false, array_null_terminated = true)]
3959 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;
3960 public string replace (string str, ssize_t string_len, int start_position, string replacement, RegexMatchFlags match_options = 0) throws RegexError;
3961 public string replace_literal (string str, ssize_t string_len, int start_position, string replacement, RegexMatchFlags match_options = 0) throws RegexError;
3962 public string replace_eval (string str, ssize_t string_len, int start_position, RegexMatchFlags match_options, RegexEvalCallback eval) throws RegexError;
3963 public static bool check_replacement (string replacement, out bool has_references = null) throws RegexError;
3966 [Version (since = "2.14")]
3967 public delegate bool RegexEvalCallback (MatchInfo match_info, StringBuilder result);
3970 [Version (since = "2.30")]
3971 [CCode (ref_function = "g_match_info_ref", unref_function = "g_match_info_unref", type_id = "G_TYPE_MATCH_INFO")]
3972 public class MatchInfo {
3973 public unowned Regex get_regex ();
3974 public unowned string get_string ();
3975 public bool matches ();
3976 public bool next () throws RegexError;
3977 public int get_match_count ();
3978 public bool is_partial_match ();
3979 public string expand_references (string string_to_expand) throws RegexError;
3980 public string? fetch (int match_num);
3981 public bool fetch_pos (int match_num, out int start_pos, out int end_pos);
3982 public string? fetch_named (string name);
3983 public bool fetch_named_pos (string name, out int start_pos, out int end_pos);
3984 [CCode (array_length = false, array_null_terminated = true)]
3985 public string[] fetch_all ();
3988 /* Simple XML Subset Parser
3989 See http://live.gnome.org/Vala/MarkupSample for an example */
3991 public errordomain MarkupError {
3999 public static GLib.Quark quark ();
4002 [CCode (cprefix = "G_MARKUP_", has_type_id = false)]
4004 public enum MarkupParseFlags {
4005 TREAT_CDATA_AS_TEXT,
4006 PREFIX_ERROR_POSITION
4011 [Version (since = "2.36")]
4012 [CCode (ref_function = "g_markup_parse_context_ref", unref_function = "g_markup_parse_context_unref", type_id = "G_TYPE_MARKUP_PARSE_CONTEXT")]
4014 [CCode (free_function = "g_markup_parse_context_free")]
4016 public class MarkupParseContext {
4017 public MarkupParseContext (MarkupParser parser, MarkupParseFlags _flags, void* user_data, DestroyNotify? user_data_dnotify);
4018 public bool parse (string text, ssize_t text_len) throws MarkupError;
4019 public bool end_parse () throws MarkupError;
4020 [Version (since = "2.2")]
4021 public unowned string get_element ();
4022 [Version (since = "2.16")]
4023 public unowned SList<string> get_element_stack ();
4024 public void get_position (out int line_number, out int char_number);
4025 [Version (since = "2.18")]
4026 public void push (MarkupParser parser, void* user_data);
4027 [Version (since = "2.18")]
4028 public void* pop ();
4029 [Version (since = "2.18")]
4030 public void* get_user_data ();
4033 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;
4035 public delegate void MarkupParserEndElementFunc (MarkupParseContext context, string element_name) throws MarkupError;
4037 public delegate void MarkupParserTextFunc (MarkupParseContext context, string text, size_t text_len) throws MarkupError;
4039 public delegate void MarkupParserPassthroughFunc (MarkupParseContext context, string passthrough_text, size_t text_len) throws MarkupError;
4041 public delegate void MarkupParserErrorFunc (MarkupParseContext context, Error error);
4043 public struct MarkupParser {
4044 [CCode (delegate_target = false)]
4045 public unowned MarkupParserStartElementFunc start_element;
4046 [CCode (delegate_target = false)]
4047 public unowned MarkupParserEndElementFunc end_element;
4048 [CCode (delegate_target = false)]
4049 public unowned MarkupParserTextFunc text;
4050 [CCode (delegate_target = false)]
4051 public unowned MarkupParserPassthroughFunc passthrough;
4052 [CCode (delegate_target = false)]
4053 public unowned MarkupParserErrorFunc error;
4057 [CCode (cprefix = "G_MARKUP_COLLECT_", has_type_id = false)]
4058 public enum CollectType {
4067 public static string escape_text (string text, ssize_t length = -1);
4068 [Version (since = "2.4")]
4070 public static string printf_escaped (string format, ...);
4071 [Version (since = "2.4")]
4072 public static string vprintf_escaped (string format, va_list args);
4073 [Version (since = "2.16")]
4074 [CCode (sentinel = "G_MARKUP_COLLECT_INVALID")]
4075 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;
4078 /* Key-value file parser */
4080 public errordomain KeyFileError {
4087 public static GLib.Quark quark ();
4091 [Version (since = "2.32")]
4092 [CCode (ref_function = "g_key_file_ref", unref_function = "g_key_file_unref", type_id = "G_TYPE_KEY_FILE")]
4093 public class KeyFile {
4095 public void set_list_separator (char separator);
4096 [Version (since = "2.50")]
4097 public bool load_from_bytes (Bytes bytes, KeyFileFlags @flags) throws KeyFileError;
4098 public bool load_from_file (string file, KeyFileFlags @flags) throws KeyFileError, FileError;
4099 [Version (since = "2.14")]
4100 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;
4101 public bool load_from_data (string data, size_t length, KeyFileFlags @flags) throws KeyFileError;
4102 public bool load_from_data_dirs (string file, out string full_path, KeyFileFlags @flags) throws KeyFileError, FileError;
4103 // g_key_file_to_data never throws an error according to the documentation
4104 public string to_data (out size_t length = null, out GLib.Error error = null);
4105 public string get_start_group ();
4106 [CCode (array_length_type = "gsize")]
4107 public string[] get_groups ();
4108 [CCode (array_length_type = "gsize")]
4109 public string[] get_keys (string group_name) throws KeyFileError;
4110 public bool has_group (string group_name);
4111 public bool has_key (string group_name, string key) throws KeyFileError;
4112 public string get_value (string group_name, string key) throws KeyFileError;
4113 public string get_string (string group_name, string key) throws KeyFileError;
4114 public string get_locale_string (string group_name, string key, string? locale = null) throws KeyFileError;
4115 public bool get_boolean (string group_name, string key) throws KeyFileError;
4116 public int get_integer (string group_name, string key) throws KeyFileError;
4117 [Version (since = "2.26")]
4118 public int64 get_int64 (string group_name, string key) throws KeyFileError;
4119 [Version (since = "2.26")]
4120 public uint64 get_uint64 (string group_name, string key) throws KeyFileError;
4121 [Version (since = "2.12")]
4122 public double get_double (string group_name, string key) throws KeyFileError;
4123 [CCode (array_length = true, array_length_type = "gsize", array_null_terminated = true)]
4124 public string[] get_string_list (string group_name, string key) throws KeyFileError;
4125 [CCode (array_length_type = "gsize")]
4126 public string[] get_locale_string_list (string group_name, string key, string? locale = null) throws KeyFileError;
4127 [CCode (array_length_type = "gsize")]
4128 public bool[] get_boolean_list (string group_name, string key) throws KeyFileError;
4129 [CCode (array_length_type = "gsize")]
4130 public int[] get_integer_list (string group_name, string key) throws KeyFileError;
4131 [Version (since = "2.12")]
4132 [CCode (array_length_type = "gsize")]
4133 public double[] get_double_list (string group_name, string key) throws KeyFileError;
4134 public string get_comment (string? group_name, string? key) throws KeyFileError;
4135 [Version (since = "2.40")]
4136 public bool save_to_file (string filename) throws GLib.FileError;
4137 public void set_value (string group_name, string key, string value);
4138 public void set_string (string group_name, string key, string str);
4139 public void set_locale_string (string group_name, string key, string locale, string str);
4140 public void set_boolean (string group_name, string key, bool value);
4141 public void set_integer (string group_name, string key, int value);
4142 [Version (since = "2.26")]
4143 public void set_int64 (string group_name, string key, int64 value);
4144 [Version (since = "2.26")]
4145 public void set_uint64 (string group_name, string key, uint64 value);
4146 [Version (since = "2.12")]
4147 public void set_double (string group_name, string key, double value);
4148 public void set_string_list (string group_name, string key, [CCode (type = "const gchar* const*")] string[] list);
4149 public void set_locale_string_list (string group_name, string key, string locale, string[] list);
4150 public void set_boolean_list (string group_name, string key, bool[] list);
4151 public void set_integer_list (string group_name, string key, int[] list);
4152 [Version (since = "2.12")]
4153 public void set_double_list (string group_name, string key, double[] list);
4154 public void set_comment (string? group_name, string? key, string comment) throws KeyFileError;
4155 public void remove_group (string group_name) throws KeyFileError;
4156 public void remove_key (string group_name, string key) throws KeyFileError;
4157 public void remove_comment (string group_name, string key) throws KeyFileError;
4160 [CCode (cprefix = "G_KEY_FILE_", has_type_id = false)]
4162 public enum KeyFileFlags {
4168 [Version (since = "2.14")]
4169 [CCode (cprefix = "G_KEY_FILE_DESKTOP_")]
4170 namespace KeyFileDesktop {
4171 public const string GROUP;
4172 public const string KEY_ACTIONS;
4173 public const string KEY_CATEGORIES;
4174 public const string KEY_COMMENT;
4175 public const string KEY_DBUS_ACTIVATABLE;
4176 public const string KEY_EXEC;
4177 public const string KEY_FULLNAME;
4178 public const string KEY_GENERIC_NAME;
4179 public const string KEY_GETTEXT_DOMAIN;
4180 public const string KEY_HIDDEN;
4181 public const string KEY_ICON;
4182 public const string KEY_KEYWORDS;
4183 public const string KEY_MIME_TYPE;
4184 public const string KEY_NAME;
4185 public const string KEY_NOT_SHOW_IN;
4186 public const string KEY_NO_DISPLAY;
4187 public const string KEY_ONLY_SHOW_IN;
4188 public const string KEY_PATH;
4189 public const string KEY_STARTUP_NOTIFY;
4190 public const string KEY_STARTUP_WM_CLASS;
4191 public const string KEY_TERMINAL;
4192 public const string KEY_TRY_EXEC;
4193 public const string KEY_TYPE;
4194 public const string KEY_URL;
4195 public const string KEY_VERSION;
4196 public const string TYPE_APPLICATION;
4197 public const string TYPE_DIRECTORY;
4198 public const string TYPE_LINK;
4201 /* Bookmark file parser */
4204 [Version (since = "2.12")]
4205 [CCode (free_function = "g_bookmark_file_free")]
4206 public class BookmarkFile {
4207 public BookmarkFile ();
4208 public bool load_from_file (string file) throws BookmarkFileError, FileError;
4209 public bool load_from_data (string data, size_t length) throws BookmarkFileError;
4210 public bool load_from_data_dirs (string file, out string full_path) throws BookmarkFileError, FileError;
4211 public string to_data (out size_t length) throws BookmarkFileError;
4212 public bool to_file (string filename) throws BookmarkFileError, FileError;
4213 public bool has_item (string uri);
4214 public bool has_group (string uri, string group) throws BookmarkFileError;
4215 public bool has_application (string uri, string name) throws BookmarkFileError;
4216 public int get_size ();
4217 public string[] get_uris ();
4218 public string get_title (string uri) throws BookmarkFileError;
4219 public string get_description (string uri) throws BookmarkFileError;
4220 public string get_mime_type (string uri) throws BookmarkFileError;
4221 public bool get_is_private (string uri) throws BookmarkFileError;
4222 public bool get_icon (string uri, out string href, out string mime_type) throws BookmarkFileError;
4223 public time_t get_added (string uri) throws BookmarkFileError;
4224 public time_t get_modified (string uri) throws BookmarkFileError;
4225 public time_t get_visited (string uri) throws BookmarkFileError;
4226 public string[] get_groups (string uri) throws BookmarkFileError;
4227 public string[] get_applications (string uri) throws BookmarkFileError;
4228 public bool get_app_info (string uri, string name, out string exec, out uint count, out time_t stamp) throws BookmarkFileError;
4229 public void set_title (string uri, string title);
4230 public void set_description (string uri, string description);
4231 public void set_mime_type (string uri, string mime_type);
4232 public void set_is_private (string uri, bool is_private);
4233 public void set_icon (string uri, string href, string mime_type);
4234 public void set_added (string uri, time_t added);
4235 public void set_groups (string uri, string[] groups);
4236 public void set_modified (string uri, time_t modified);
4237 public void set_visited (string uri, time_t visited);
4238 public bool set_app_info (string uri, string name, string exec, int count, time_t stamp) throws BookmarkFileError;
4239 public void add_group (string uri, string group);
4240 public void add_application (string uri, string name, string exec);
4241 public bool remove_group (string uri, string group) throws BookmarkFileError;
4242 public bool remove_application (string uri, string name) throws BookmarkFileError;
4243 public bool remove_item (string uri) throws BookmarkFileError;
4244 public bool move_item (string old_uri, string new_uri) throws BookmarkFileError;
4247 public errordomain BookmarkFileError {
4256 public static GLib.Quark quark ();
4262 [CCode (cprefix = "G_TEST_", has_type_id = false)]
4263 public enum FileType {
4269 [Version (since = "2.16")]
4270 public static void minimized_result (double minimized_quantity, string format, ...);
4272 [Version (since = "2.16")]
4273 public static void maximized_result (double maximized_quantity, string format, ...);
4274 [Version (since = "2.16")]
4275 public static void init ([CCode (array_length_pos = 0.9)] ref unowned string[] args, ...);
4276 public static bool quick ();
4277 public static bool slow ();
4278 public static bool thorough ();
4279 public static bool perf ();
4280 public static bool verbose ();
4281 public static bool quiet ();
4282 [Version (since = "2.16")]
4283 public static int run ();
4284 [Version (since = "2.16")]
4285 public static void add_func (string testpath, [CCode (scope = "async")] owned TestFunc test_funcvoid);
4286 [Version (since = "2.16")]
4287 public static void add_data_func (string testpath, [CCode (delegate_target_pos = 1.9, scope = "async")] owned TestDataFunc test_funcvoid);
4288 [Version (since = "2.34")]
4289 public static void add_data_func_full (string testpath, [CCode (delegate_target_pos = 1.9)] owned TestDataFunc test_func);
4290 [Version (since = "2.34")]
4291 public static void assert_expected_messages ();
4292 [Version (since = "2.38")]
4293 public static string build_filename (GLib.Test.FileType file_type, params string[] path_segments);
4294 [Version (since = "2.34")]
4295 public static void expect_message (string? log_domain, LogLevelFlags log_level, string pattern);
4296 [Version (since = "2.30")]
4297 public static void fail ();
4298 [Version (since = "2.38")]
4299 public static bool failed ();
4300 [Version (since = "2.38")]
4301 public static unowned string get_dir (GLib.Test.FileType file_type);
4302 [Version (since = "2.38")]
4303 public static unowned string get_filename (GLib.Test.FileType file_type, params string[] path_segments);
4304 [Version (since = "2.38")]
4305 public static void incomplete (string? msg = null);
4306 [Version (since = "2.36")]
4307 public static bool initialized ();
4309 [Version (since = "2.16")]
4310 public static void message (string format, ...);
4311 [Version (since = "2.38")]
4312 public static void set_nonfatal_assertions ();
4313 [Version (since = "2.38")]
4314 public static void skip (string? msg = null);
4315 [Version (since = "2.38")]
4316 public static bool subprocess ();
4317 [Version (since = "2.16")]
4318 public static void bug_base (string uri_pattern);
4319 [Version (since = "2.16")]
4320 public static void bug (string bug_uri_snippet);
4321 [Version (since = "2.16")]
4322 public static void timer_start ();
4323 [Version (since = "2.16")]
4324 public static double timer_elapsed ();
4325 [Version (since = "2.16")]
4326 public static double timer_last ();
4327 [Version (since = "2.16", deprecated_since = "2.38", replacement = "trap_subprocess")]
4328 public static bool trap_fork (uint64 usec_timeout, TestTrapFlags test_trap_flags);
4329 [Version (since = "2.16")]
4330 public static bool trap_has_passed ();
4331 [Version (since = "2.16")]
4332 public static bool trap_reached_timeout ();
4333 [Version (since = "2.38")]
4334 public static void trap_subprocess (string? test_path, uint64 usec_timeout, TestSubprocessFlags test_flags);
4335 [Version (since = "2.16")]
4336 public static void trap_assert_passed ();
4337 [Version (since = "2.16")]
4338 public static void trap_assert_failed ();
4339 [Version (since = "2.16")]
4340 public static void trap_assert_stdout (string soutpattern);
4341 [Version (since = "2.16")]
4342 public static void trap_assert_stdout_unmatched (string soutpattern);
4343 [Version (since = "2.16")]
4344 public static void trap_assert_stderr (string serrpattern);
4345 [Version (since = "2.16")]
4346 public static void trap_assert_stderr_unmatched (string serrpattern);
4347 [Version (since = "2.16")]
4348 public static bool rand_bit ();
4349 [Version (since = "2.16")]
4350 public static int32 rand_int ();
4351 [Version (since = "2.16")]
4352 public static int32 rand_int_range (int32 begin, int32 end);
4353 [Version (since = "2.16")]
4354 public static double rand_double ();
4355 [Version (since = "2.16")]
4356 public static double rand_double_range (double begin, double end);
4357 [Version (since = "2.22")]
4358 public static void log_set_fatal_handler (LogFatalFunc log_func);
4361 public delegate bool LogFatalFunc (string? log_domain, LogLevelFlags log_levels, string message);
4364 [CCode (cname = "GTestCase", ref_function = "", unref_function = "")]
4365 public class TestCase {
4366 [Version (since = "2.16")]
4367 [CCode (cname = "g_test_create_case")]
4368 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);
4372 [CCode (cname = "GTestSuite", ref_function = "", unref_function = "")]
4373 public class TestSuite {
4374 [Version (since = "2.16")]
4375 [CCode (cname = "g_test_create_suite")]
4376 public TestSuite (string name);
4377 [Version (since = "2.16")]
4378 [CCode (cname = "g_test_get_root")]
4379 public static TestSuite get_root ();
4380 [Version (since = "2.16")]
4381 [CCode (cname = "g_test_suite_add")]
4382 public void add (TestCase test_case);
4383 [Version (since = "2.16")]
4384 [CCode (cname = "g_test_suite_add_suite")]
4385 public void add_suite (TestSuite test_suite);
4388 [Version (since = "2.26")]
4389 [CCode (has_target = false)]
4390 public delegate void TestFunc ();
4391 [Version (since = "2.26")]
4392 public delegate void TestDataFunc ();
4393 [Version (since = "2.26")]
4394 public delegate void TestFixtureFunc (void* fixture);
4396 [CCode (cprefix = "G_TEST_SUBPROCESS_INHERIT_", has_type_id = false)]
4398 public enum TestSubprocessFlags {
4405 [CCode (cprefix = "G_TEST_TRAP_", has_type_id = false)]
4406 public enum TestTrapFlags {
4412 /* Doubly-Linked Lists */
4415 [CCode (dup_function = "g_list_copy", free_function = "g_list_free")]
4416 public class List<G> {
4419 [ReturnsModifiedPointer ()]
4420 public void append (owned G data);
4421 [ReturnsModifiedPointer ()]
4422 public void prepend (owned G data);
4423 [ReturnsModifiedPointer ()]
4424 public void insert (owned G data, int position);
4425 [ReturnsModifiedPointer ()]
4426 public void insert_before (List<G> sibling, owned G data);
4427 [ReturnsModifiedPointer ()]
4428 public void insert_sorted (owned G data, CompareFunc<G> compare_func);
4429 [ReturnsModifiedPointer ()]
4430 public void remove (G data);
4431 [ReturnsModifiedPointer ()]
4432 public void remove_link (List<G> llink);
4433 [ReturnsModifiedPointer ()]
4434 public void delete_link (List<G> link_);
4435 [ReturnsModifiedPointer ()]
4436 public void remove_all (G data);
4438 public uint length ();
4439 public List<unowned G> copy ();
4440 [Version (since = "2.34")]
4441 public List<G> copy_deep (CopyFunc<G> func);
4442 [ReturnsModifiedPointer ()]
4443 public void reverse ();
4444 [ReturnsModifiedPointer ()]
4445 public void sort (CompareFunc<G> compare_func);
4446 [Version (since = "2.10")]
4447 [ReturnsModifiedPointer ()]
4448 public void insert_sorted_with_data (owned G data, CompareDataFunc<G> compare_func);
4449 [ReturnsModifiedPointer ()]
4450 public void sort_with_data (CompareDataFunc<G> compare_func);
4451 [ReturnsModifiedPointer ()]
4452 public void concat (owned List<G> list2);
4453 public void @foreach (Func<G> func);
4455 public unowned List<G> first ();
4456 public unowned List<G> last ();
4457 public unowned List<G> nth (uint n);
4458 public unowned G nth_data (uint n);
4459 public unowned List<G> nth_prev (uint n);
4461 public unowned List<G> find (G data);
4462 public unowned List<G> find_custom (G data, CompareFunc<G> func);
4463 [CCode (cname = "g_list_find_custom", simple_generics = true)]
4464 public unowned List<G> search<T> (T data, SearchFunc<G,T> func);
4466 public int position (List<G> llink);
4467 public int index (G data);
4470 public List<G> next;
4471 public unowned List<G> prev;
4474 /* Singly-Linked Lists */
4477 [CCode (dup_function = "g_slist_copy", free_function = "g_slist_free")]
4478 public class SList<G> {
4481 [ReturnsModifiedPointer ()]
4482 public void append (owned G data);
4483 [ReturnsModifiedPointer ()]
4484 public void prepend (owned G data);
4485 [ReturnsModifiedPointer ()]
4486 public void insert (owned G data, int position);
4487 [ReturnsModifiedPointer ()]
4488 public void insert_before (SList<G> sibling, owned G data);
4489 [ReturnsModifiedPointer ()]
4490 public void insert_sorted (owned G data, CompareFunc<G> compare_func);
4491 [ReturnsModifiedPointer ()]
4492 public void remove (G data);
4493 [ReturnsModifiedPointer ()]
4494 public void remove_link (SList<G> llink);
4495 [ReturnsModifiedPointer ()]
4496 public void delete_link (SList<G> link_);
4497 [ReturnsModifiedPointer ()]
4498 public void remove_all (G data);
4500 public uint length ();
4501 public SList<unowned G> copy ();
4502 [Version (since = "2.34")]
4503 public SList<G> copy_deep (CopyFunc<G> func);
4504 [ReturnsModifiedPointer ()]
4505 public void reverse ();
4506 [Version (since = "2.10")]
4507 [ReturnsModifiedPointer ()]
4508 public void insert_sorted_with_data (owned G data, CompareDataFunc<G> compare_func);
4509 [ReturnsModifiedPointer ()]
4510 public void sort (CompareFunc<G> compare_func);
4511 [ReturnsModifiedPointer ()]
4512 public void sort_with_data (CompareDataFunc<G> compare_func);
4513 [ReturnsModifiedPointer ()]
4514 public void concat (owned SList<G> list2);
4515 public void @foreach (Func<G> func);
4517 public unowned SList<G> last ();
4518 public unowned SList<G> nth (uint n);
4519 public unowned G nth_data (uint n);
4521 public unowned SList<G> find (G data);
4522 public unowned SList<G> find_custom (G data, CompareFunc<G> func);
4523 [CCode (cname = "g_slist_find_custom", simple_generics = true)]
4524 public unowned SList<G> search<T> (T data, SearchFunc<G,T> func);
4526 public int position (SList<G> llink);
4527 public int index (G data);
4530 public SList<G> next;
4533 [CCode (has_target = false)]
4534 public delegate int CompareFunc<G> (G a, G b);
4536 public delegate int CompareDataFunc<G> (G a, G b);
4538 [Version (since = "2.16")]
4539 [CCode (cname = "g_strcmp0")]
4540 public static GLib.CompareFunc<string> strcmp;
4542 public delegate G CopyFunc<G> (G src);
4544 [CCode (cname = "GCompareFunc", has_target = false)]
4545 public delegate int SearchFunc<G,T> (G a, T b);
4547 /* Double-ended Queues */
4550 [CCode (dup_function = "g_queue_copy", free_function = "g_queue_free")]
4551 public class Queue<G> {
4552 public unowned List<G> head;
4553 public unowned List<G> tail;
4558 [Version (since = "2.14")]
4559 public void clear ();
4560 public bool is_empty ();
4561 [Version (since = "2.4")]
4562 public uint get_length ();
4563 [Version (since = "2.4")]
4564 public void reverse ();
4565 public Queue copy ();
4566 [Version (since = "2.4")]
4567 public unowned List<G> find (G data);
4568 [Version (since = "2.4")]
4569 public unowned List<G> find_custom (G data, CompareFunc<G> func);
4570 [CCode (cname = "g_queue_find_custom", simple_generics = true)]
4571 public unowned List<G> search<T> (T data, SearchFunc<G,T> func);
4572 [Version (since = "2.4")]
4573 public void sort (CompareDataFunc<G> compare_func);
4574 public void push_head (owned G data);
4575 public void push_tail (owned G data);
4576 [Version (since = "2.4")]
4577 public void push_nth (owned G data, int n);
4578 public G pop_head ();
4579 public G pop_tail ();
4580 [Version (since = "2.4")]
4581 public G pop_nth (uint n);
4582 public unowned G peek_head ();
4583 public unowned G peek_tail ();
4584 [Version (since = "2.4")]
4585 public unowned G peek_nth (uint n);
4586 [Version (since = "2.4")]
4587 public int index (G data);
4588 [Version (since = "2.4")]
4589 public void remove (G data);
4590 [Version (since = "2.4")]
4591 public void remove_all (G data);
4592 [Version (since = "2.4")]
4593 public void delete_link (List<G> link);
4594 [Version (since = "2.4")]
4595 public void unlink (List<G> link);
4596 [Version (since = "2.4")]
4597 public void insert_before (List<G> sibling, owned G data);
4598 [Version (since = "2.4")]
4599 public void insert_after (List<G> sibling, owned G data);
4600 [Version (since = "2.4")]
4601 public void insert_sorted (owned G data, CompareDataFunc<G> func);
4607 [Version (since = "2.14")]
4608 [CCode (free_function = "g_sequence_free")]
4609 public class Sequence<G> {
4610 [CCode (simple_generics = true)]
4612 public int get_length ();
4613 public void @foreach (Func<G> func);
4614 public void sort (CompareDataFunc<G> cmp_func);
4615 public void sort_iter (SequenceIterCompareFunc<G> func);
4616 public SequenceIter<G> get_begin_iter ();
4617 public SequenceIter<G> get_end_iter ();
4618 public SequenceIter<G> get_iter_at_pos (int pos);
4619 public SequenceIter<G> append (owned G data);
4620 public SequenceIter<G> prepend (owned G data);
4621 public SequenceIter<G> insert_sorted (owned G data, CompareDataFunc<G> cmp_func);
4622 [Version (since = "2.48")]
4623 public bool is_empty ();
4624 public SequenceIter<G> insert_sorted_iter (owned G data, SequenceIterCompareFunc<G> iter_cmp);
4625 public SequenceIter<G> search (G data, CompareDataFunc<G> cmp_func);
4626 public SequenceIter<G> search_iter (G data, SequenceIterCompareFunc<G> iter_cmp);
4627 [Version (since = "2.28")]
4628 public SequenceIter<G> lookup (G data, CompareDataFunc<G> cmp_func);
4629 [Version (since = "2.28")]
4630 public SequenceIter<G> lookup_iter (G data, SequenceIterCompareFunc<G> iter_cmp);
4632 [Version (deprecated_since = "vala-0.26", replacement = "SequenceIter.foreach_range")]
4633 public static void foreach_range (SequenceIter<G> begin, SequenceIter<G> end, Func<G> func);
4634 [Version (deprecated_since = "vala-0.26", replacement = "SequenceIter.insert_before")]
4635 public static SequenceIter<G> insert_before (SequenceIter<G> iter, owned G data);
4636 [Version (deprecated_since = "vala-0.26", replacement = "SequenceIter.move_to")]
4637 public static void move (SequenceIter<G> src, SequenceIter<G> dest);
4638 [Version (deprecated_since = "vala-0.26", replacement = "SequenceIter.swap")]
4639 public static void swap (SequenceIter<G> src, SequenceIter<G> dest);
4640 [Version (deprecated_since = "vala-0.26", replacement = "SequenceIter.sort_changed")]
4641 public static void sort_changed (SequenceIter<G> iter, CompareDataFunc<G> cmp_func);
4642 [Version (deprecated_since = "vala-0.26", replacement = "SequenceIter.sort_changed_iter")]
4643 public static void sort_changed_iter (SequenceIter<G> iter, SequenceIterCompareFunc<G> iter_cmp);
4644 [Version (deprecated_since = "vala-0.26", replacement = "SequenceIter.remove")]
4645 public static void remove (SequenceIter<G> iter);
4646 [Version (deprecated_since = "vala-0.26", replacement = "SequenceIter.remove_range")]
4647 public static void remove_range (SequenceIter<G> begin, SequenceIter<G> end);
4648 [Version (deprecated_since = "vala-0.26", replacement = "SequenceIter.move_range")]
4649 public static void move_range (SequenceIter<G> dest, SequenceIter<G> begin, SequenceIter<G> end);
4650 [Version (deprecated_since = "vala-0.26", replacement = "SequenceIter.get")]
4651 public static unowned G get (SequenceIter<G> iter);
4652 [Version (deprecated_since = "vala-0.26", replacement = "SequenceIter.set")]
4653 public static void set (SequenceIter<G> iter, owned G data);
4654 [Version (deprecated_since = "vala-0.26", replacement = "SequenceIter.range_get_midpoint")]
4655 public static SequenceIter<G> range_get_midpoint (SequenceIter<G> begin, SequenceIter<G> end);
4659 [Version (since = "2.14")]
4660 [CCode (ref_function = "", unref_function = "")]
4661 public class SequenceIter<G> {
4662 public bool is_begin ();
4663 public bool is_end ();
4664 public SequenceIter<G> next ();
4665 public SequenceIter<G> prev ();
4666 public int get_position ();
4667 public SequenceIter<G> move (int delta);
4668 public unowned Sequence<G> get_sequence ();
4669 public int compare (SequenceIter<G> other);
4671 [CCode (cname = "g_sequence_foreach_range")]
4672 public void foreach_range (SequenceIter<G> end, Func<G> func);
4673 [CCode (cname = "g_sequence_insert_before")]
4674 public SequenceIter<G> insert_before (owned G data);
4675 [CCode (cname = "g_sequence_move")]
4676 public void move_to (SequenceIter<G> dest);
4677 [CCode (cname = "g_sequence_swap")]
4678 public void swap (SequenceIter<G> dest);
4679 [CCode (cname = "g_sequence_sort_changed")]
4680 public void sort_changed (CompareDataFunc<G> cmp_func);
4681 [CCode (cname = "g_sequence_sort_changed_iter")]
4682 public void sort_changed_iter (SequenceIterCompareFunc<G> iter_cmp);
4683 [CCode (cname = "g_sequence_remove")]
4684 public void remove ();
4685 [CCode (cname = "g_sequence_remove_range")]
4686 public void remove_range (SequenceIter<G> end);
4687 [CCode (cname = "g_sequence_move_range")]
4688 public void move_range (SequenceIter<G> begin, SequenceIter<G> end);
4689 [CCode (cname = "g_sequence_get")]
4690 public unowned G get ();
4691 [CCode (cname = "g_sequence_set")]
4692 public void set (owned G data);
4693 [CCode (cname = "g_sequence_range_get_midpoint")]
4694 public SequenceIter<G> range_get_midpoint (SequenceIter<G> end);
4697 public delegate int SequenceIterCompareFunc<G> (SequenceIter<G> a, SequenceIter<G> b);
4702 [CCode (ref_function = "g_hash_table_ref", unref_function = "g_hash_table_unref", type_id = "G_TYPE_HASH_TABLE", type_signature = "a{%s}")]
4703 public class HashTable<K,V> {
4704 [CCode (cname = "g_hash_table_new_full", simple_generics = true)]
4705 public HashTable (HashFunc<K>? hash_func, EqualFunc<K>? key_equal_func);
4706 public HashTable.full (HashFunc<K>? hash_func, EqualFunc<K>? key_equal_func, DestroyNotify? key_destroy_func, DestroyNotify? value_destroy_func);
4707 public void insert (owned K key, owned V value);
4708 public void replace (owned K key, owned V value);
4709 [Version (since = "2.32", deprecated_since = "vala-0.26", replacement = "GenericSet.add")]
4710 public void add (owned K key);
4711 public unowned V? lookup (K key);
4712 public bool lookup_extended (K lookup_key, out unowned K orig_key, out unowned V value);
4713 [Version (since = "2.32")]
4714 public bool contains (K key);
4715 public bool remove (K key);
4716 [Version (since = "2.12")]
4717 public void remove_all ();
4718 public uint foreach_remove (HRFunc<K,V> predicate);
4719 [CCode (cname = "g_hash_table_lookup")]
4720 public unowned V? @get (K key);
4721 [CCode (cname = "g_hash_table_insert")]
4722 public void @set (owned K key, owned V value);
4723 [Version (since = "2.14")]
4724 public List<unowned K> get_keys ();
4726 [Version (since = "2.40")]
4727 public (unowned K)[] get_keys_as_array ();
4729 [Version (since = "2.14")]
4730 public List<unowned V> get_values ();
4731 public void @foreach (HFunc<K,V> func);
4732 [CCode (cname = "g_hash_table_foreach")]
4733 public void for_each (HFunc<K,V> func);
4734 [Version (since = "2.4")]
4735 public unowned V? find (HRFunc<K,V> predicate);
4736 public uint size ();
4737 public bool steal (K key);
4738 [Version (since = "2.12")]
4739 public void steal_all ();
4740 [CCode (cname = "_vala_g_hash_table_take")]
4741 public V? take (K key, out bool exists = null) {
4742 GLib.HashTable<K,V>? ht = null;
4744 *htp = this.lookup (key);
4745 exists = this.steal (key);
4748 public uint length {
4749 [CCode (cname = "g_hash_table_size")]
4754 [Version (since = "2.16")]
4755 public struct HashTableIter<K,V> {
4756 public HashTableIter (GLib.HashTable<K,V> table);
4757 public bool next ([CCode (type = "gpointer*")] out unowned K key, [CCode (type = "gpointer*")] out unowned V value);
4758 public void remove ();
4759 public void steal ();
4760 public unowned GLib.HashTable<K,V> get_hash_table ();
4763 [Version (since = "2.32")]
4764 [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}")]
4765 public class GenericSet<T> {
4766 [CCode (cname = "g_hash_table_new_full", simple_generics = true)]
4767 public GenericSet (HashFunc<T>? hash_func, EqualFunc<T>? equal_func, GLib.DestroyNotify? always_pass_null_here = null);
4768 public void add (owned T value);
4769 public bool contains (T valule);
4770 public bool remove (T value);
4771 public void remove_all ();
4772 public GLib.List<unowned T> get_values ();
4773 [CCode (cname = "g_hash_table_iter_init", instance_pos = -1)]
4774 public GLib.GenericSetIter<T> iterator ();
4775 [CCode (cname = "_vala_g_hash_set_foreach")]
4776 public void @foreach (GLib.Func<T> func) {
4777 ((GLib.HashTable<unowned T,T>) this).foreach ((k, v) => func (v));
4779 public uint length {
4780 [CCode (cname = "g_hash_table_size")]
4785 [Version (since = "2.32")]
4786 [CCode (cname = "GHashTableIter", lower_case_cprefix = "g_hash_table_iter_")]
4787 public struct GenericSetIter<T> {
4788 [CCode (cname = "_vala_hash_set_next_value")]
4789 public unowned T? next_value () {
4791 GLib.HashTableIter<unowned T,T>* htp = vi;
4793 return htp->next (out value, null) ? value : null;
4795 public void remove ();
4798 [CCode (has_target = false)]
4799 public delegate uint HashFunc<K> (K key);
4800 [CCode (has_target = false)]
4801 public delegate bool EqualFunc<G> (G a, G b);
4802 public delegate void HFunc<K,V> (K key, V value);
4803 public delegate bool HRFunc<K,V> (K key, V value);
4805 [CCode (has_target = false)]
4806 public delegate void DestroyNotify (void* data);
4808 [CCode (cname = "g_direct_hash")]
4809 public static GLib.HashFunc<void*> direct_hash;
4810 [CCode (cname = "g_direct_equal")]
4811 public static GLib.EqualFunc<void*> direct_equal;
4812 [CCode (cname = "g_int64_hash")]
4813 public static GLib.HashFunc<int64?> int64_hash;
4814 [Version (since = "2.22")]
4815 [CCode (cname = "g_int64_equal")]
4816 public static GLib.EqualFunc<int64?> int64_equal;
4817 [Version (since = "2.22")]
4818 [CCode (cname = "g_int_hash")]
4819 public static GLib.HashFunc<int?> int_hash;
4820 [CCode (cname = "g_int_equal")]
4821 public static GLib.EqualFunc<int?> int_equal;
4822 [CCode (cname = "g_str_hash")]
4823 public static GLib.HashFunc<string> str_hash;
4824 [CCode (cname = "g_str_equal")]
4825 public static GLib.EqualFunc<string> str_equal;
4826 [CCode (cname = "g_free")]
4827 public static GLib.DestroyNotify g_free;
4828 [CCode (cname = "g_object_unref")]
4829 public static GLib.DestroyNotify g_object_unref;
4830 [CCode (cname = "g_list_free")]
4831 public static GLib.DestroyNotify g_list_free;
4832 [CCode (cname = "((GDestroyNotify) g_variant_unref)")]
4833 public static GLib.DestroyNotify g_variant_unref;
4838 [GIR (name = "String")]
4839 [CCode (cname = "GString", cprefix = "g_string_", free_function = "g_string_free", type_id = "G_TYPE_GSTRING")]
4840 public class StringBuilder {
4841 public StringBuilder (string init = "");
4842 [CCode (cname = "g_string_sized_new")]
4843 public StringBuilder.sized (size_t dfl_size);
4844 public unowned StringBuilder assign (string rval);
4845 public unowned StringBuilder append (string val);
4846 public unowned StringBuilder append_c (char c);
4847 public unowned StringBuilder append_unichar (unichar wc);
4848 public unowned StringBuilder append_len (string val, ssize_t len);
4849 public unowned StringBuilder prepend (string val);
4850 public unowned StringBuilder prepend_c (char c);
4851 public unowned StringBuilder prepend_unichar (unichar wc);
4852 public unowned StringBuilder prepend_len (string val, ssize_t len);
4853 public unowned StringBuilder insert (ssize_t pos, string val);
4854 public unowned StringBuilder insert_len (ssize_t pos, string val, ssize_t len);
4855 public unowned StringBuilder insert_unichar (ssize_t pos, unichar wc);
4856 [Version (since = "2.14")]
4857 public unowned StringBuilder overwrite (size_t pos, string val);
4858 [Version (since = "2.14")]
4859 public unowned StringBuilder overwrite_len (size_t pos, string val, ssize_t len);
4860 public unowned StringBuilder erase (ssize_t pos = 0, ssize_t len = -1);
4861 public unowned StringBuilder truncate (size_t len = 0);
4864 public void printf (string format, ...);
4866 public void append_printf (string format, ...);
4867 [Version (since = "2.14")]
4868 public void vprintf (string format, va_list args);
4869 [Version (since = "2.14")]
4870 public void append_vprintf (string format, va_list args);
4874 public ssize_t allocated_len;
4876 public uint8[] data {
4878 unowned uint8[] res = (uint8[]) this.str;
4879 res.length = (int) this.len;
4884 [Version (since = "2.34")]
4885 public static Bytes free_to_bytes (owned StringBuilder str);
4891 [CCode (free_function = "g_string_chunk_free")]
4892 public class StringChunk {
4893 public StringChunk (size_t size);
4894 public unowned string insert (string str);
4895 public unowned string insert_const (string str);
4896 [Version (since = "2.4")]
4897 public unowned string insert_len (string str, ssize_t len);
4898 [Version (since = "2.14")]
4899 public void clear ();
4902 /* Pointer Arrays */
4905 [Version (since = "2.22", deprecated_since = "vala-0.26", replacement="GenericArray")]
4906 [CCode (ref_function = "g_ptr_array_ref", unref_function = "g_ptr_array_unref", type_id = "G_TYPE_PTR_ARRAY")]
4907 public class PtrArray {
4909 [Version (since = "2.22")]
4910 public PtrArray.with_free_func (GLib.DestroyNotify? element_free_func);
4911 [CCode (cname = "g_ptr_array_sized_new")]
4912 public PtrArray.sized (uint reserved_size);
4913 public void add (void* data);
4914 [Version (since = "2.4")]
4915 public void foreach (GLib.Func<void*> func);
4916 [CCode (cname = "g_ptr_array_index")]
4917 public void* index(uint index);
4918 public bool remove (void* data);
4919 public void* remove_index (uint index);
4920 public bool remove_fast (void *data);
4921 public void remove_index_fast (uint index);
4922 [Version (since = "2.4")]
4923 public void remove_range (uint index, uint length);
4924 public void sort (CompareFunc<void**> compare_func);
4925 public void sort_with_data (CompareDataFunc<void**> compare_func);
4926 [Version (since = "2.22")]
4927 public void set_free_func (GLib.DestroyNotify? element_free_function);
4928 public void set_size (int length);
4931 public void** pdata;
4935 [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")]
4936 [GIR (name = "PtrArray")]
4937 public class GenericArray<G> {
4938 [Version (since = "2.30")]
4939 [CCode (cname = "g_ptr_array_new_full", simple_generics = true)]
4940 public GenericArray (uint reserved_size = 0);
4941 public void add (owned G data);
4942 public void foreach (GLib.Func<G> func);
4943 [CCode (cname = "g_ptr_array_index")]
4944 public unowned G get (uint index);
4945 [Version (since = "2.40")]
4946 public void insert (int index, owned G data);
4947 public bool remove (G data);
4948 public void remove_index (uint index);
4949 public bool remove_fast (G data);
4950 public void remove_index_fast (uint index);
4951 public void remove_range (uint index, uint length);
4952 public void set (uint index, owned G data) {
4953 this.add ((owned) data);
4954 this.remove_index_fast (index);
4956 [CCode (cname = "vala_g_ptr_array_sort")]
4957 public void sort (GLib.CompareFunc<G> compare_func) {
4958 this._sort_with_data ((a, b) => {
4959 return compare_func ((G**) (*a), (G**) (*b));
4962 [CCode (cname = "g_ptr_array_sort_with_data")]
4963 public void _sort_with_data (GLib.CompareDataFunc<G**> compare_func);
4964 [CCode (cname = "vala_g_ptr_array_sort_with_data")]
4965 public void sort_with_data (GLib.CompareDataFunc<G> compare_func) {
4966 this._sort_with_data ((a, b) => {
4967 return compare_func ((G**) (*a), (G**) (*b));
4970 private void set_size (int length);
4973 get { return (int) this.len; }
4974 set { this.set_size (value); }
4977 [CCode (cname = "pdata", array_length_cname = "len", array_length_type = "guint")]
4984 [Version (since = "2.32")]
4985 [CCode (cprefix = "g_bytes_", ref_function = "g_bytes_ref", unref_function = "g_bytes_unref", type_id = "G_TYPE_BYTES")]
4986 public class Bytes {
4987 public Bytes ([CCode (array_length_type = "gsize")] uint8[] data);
4988 public Bytes.take ([CCode (array_length_type = "gsize")] owned uint8[] data);
4989 public Bytes.static ([CCode (array_length_type = "gsize")] uint8[] data);
4990 public Bytes.with_free_func ([CCode (array_length_type = "gsize")] owned uint8[] data, GLib.DestroyNotify? free_func = GLib.g_free);
4991 public Bytes.from_bytes (GLib.Bytes bytes, size_t offset, size_t length);
4993 [CCode (cname = "g_bytes_new_with_free_func", simple_generics = true)]
4994 public static Bytes new_with_owner<T> ([CCode (array_length_type = "gsize")] uint8[] data, [CCode (destroy_notify_pos = 1.9)] owned T? owner = null);
4996 [CCode (array_length_type = "gsize")]
4997 public unowned uint8[] get_data ();
4998 public size_t get_size ();
4999 public uint hash ();
5000 public int compare (GLib.Bytes bytes2);
5001 public static uint8[] unref_to_data (owned GLib.Bytes bytes);
5002 public static GLib.ByteArray unref_to_array (owned GLib.Bytes bytes);
5004 [CCode (cname = "_vala_g_bytes_get")]
5005 public uint8 get (int index) {
5006 unowned uint8[] data = this.get_data ();
5010 [CCode (cname = "_vala_g_bytes_slice")]
5011 public GLib.Bytes slice (int start, int end) {
5012 unowned uint8[] data = this.get_data ();
5013 return new GLib.Bytes (data[start:end]);
5017 [CCode (cname = "_vala_g_bytes_get_length")]
5019 return (int) this.get_size ();
5027 [Version (since = "2.22")]
5028 [CCode (cprefix = "g_byte_array_", ref_function = "g_byte_array_ref", unref_function = "g_byte_array_unref", type_id = "G_TYPE_BYTE_ARRAY")]
5029 public class ByteArray {
5030 public ByteArray ();
5031 [CCode (cname = "g_byte_array_sized_new")]
5032 public ByteArray.sized (uint reserved_size);
5033 [Version (since = "2.32")]
5034 public ByteArray.take (owned uint8[] data);
5035 public void append (uint8[] data);
5036 [Version (since = "2.32")]
5037 public static GLib.Bytes free_to_bytes (owned GLib.ByteArray array);
5038 public void prepend (uint8[] data);
5039 public void remove_index (uint index);
5040 public void remove_index_fast (uint index);
5041 [Version (since = "2.4")]
5042 public void remove_range (uint index, uint length);
5043 public void sort (CompareFunc<int8> compare_func);
5044 public void sort_with_data (CompareDataFunc<int8> compare_func);
5045 public void set_size (uint length);
5048 [CCode (array_length_cname = "len", array_length_type = "guint")]
5049 public uint8[] data;
5054 public delegate bool NodeTraverseFunc (Node node);
5055 public delegate void NodeForeachFunc (Node node);
5057 [CCode (cprefix = "G_TRAVERSE_")]
5058 public enum TraverseFlags {
5068 [CCode (dup_function = "g_node_copy", free_function = "g_node_destroy")]
5069 public class Node<G> {
5070 public Node(owned G? data = null);
5071 public Node<unowned G> copy ();
5072 public Node<G> copy_deep (CopyFunc<G> copy_func);
5073 public unowned Node<G> insert (int position, owned Node<G> node);
5074 public unowned Node<G> insert_before (Node<G> sibling, owned Node<G> node);
5075 public unowned Node<G> insert_after (Node<G> sibling, owned Node<G> node);
5076 public unowned Node<G> append (owned Node<G> node);
5077 public unowned Node<G> prepend (owned Node<G> node);
5078 public unowned Node<G> insert_data (int position, owned G data);
5079 public unowned Node<G> insert_data_before (Node<G> sibling, owned G data);
5080 public unowned Node<G> append_data (owned G data);
5081 public unowned Node<G> prepend_data (owned G data);
5082 public void reverse_children ();
5083 public void traverse (TraverseType order, TraverseFlags flags, int max_depth, NodeTraverseFunc func);
5084 public void children_foreach (TraverseFlags flags, NodeForeachFunc func);
5085 public unowned Node<G> get_root ();
5086 public unowned Node<G> find (TraverseType order, TraverseFlags flags, G data);
5087 public unowned Node<G> find_child (TraverseFlags flags, G data);
5088 public int child_index (G data);
5089 public int child_position (Node<G> child);
5090 public unowned Node<G> first_child ();
5091 public unowned Node<G> last_child ();
5092 public unowned Node<G> nth_child (uint n);
5093 public unowned Node<G> first_sibling ();
5094 public unowned Node<G> next_sibling ();
5095 public unowned Node<G> prev_sibling ();
5096 public unowned Node<G> last_sibling ();
5098 [CCode (cname = "G_NODE_IS_LEAF")]
5099 public bool is_leaf ();
5100 [CCode (cname = "G_NODE_IS_ROOT")]
5101 public bool is_root ();
5102 public bool is_ancestor (Node<G> descendant);
5104 public uint depth ();
5105 public uint n_nodes (TraverseFlags flags);
5106 public uint n_children ();
5107 public uint max_height ();
5109 [CCode (cname = "g_node_unlink")]
5110 public void _unlink ();
5111 [CCode (cname = "g_node_unlink_vala")]
5112 public Node<G> unlink ()
5116 return (Node<G>) (owned) ptr;
5123 public Node children;
5128 [CCode (type_id = "G_TYPE_UINT")]
5129 public struct Quark : uint32 {
5130 public static Quark from_string (string str);
5131 public static Quark try_string (string str);
5132 public unowned string to_string ();
5135 /* Keyed Data Lists */
5137 [CCode (cname = "GData*")]
5138 public struct Datalist<G> {
5140 public void clear ();
5141 [Version (since = "2.34")]
5142 public G id_dup_data (Quark key_id, DuplicateFunc<G> dup_func);
5143 public unowned G id_get_data (Quark key_id);
5144 public void id_set_data (Quark key_id, owned G data);
5145 public void id_set_data_full (Quark key_id, owned G data, DestroyNotify? destroy_func);
5146 public void id_remove_data (Quark key_id);
5147 public G id_remove_no_notify (Quark key_id);
5148 [Version (since = "2.34")]
5149 public bool id_replace_data (Quark key_id, G oldval, owned G newval, GLib.DestroyNotify? destroy, out GLib.DestroyNotify? old_destroy);
5150 public void @foreach (DataForeachFunc<G> func);
5151 public unowned G get_data (string key);
5152 public void set_data_full (string key, owned G data, DestroyNotify? destry_func);
5153 public G remove_no_notify (string key);
5154 public void set_data (string key, owned G data);
5155 public void remove_data (string key);
5158 public delegate void DataForeachFunc<G> (Quark key_id, G data);
5159 public delegate G DuplicateFunc<G> (G data);
5164 [Version (since = "2.22")]
5165 [CCode (ref_function = "g_array_ref", unref_function = "g_array_unref", type_id = "G_TYPE_ARRAY")]
5166 public class Array<G> {
5167 [CCode (cname = "len")]
5169 [CCode (cname = "data", array_length_cname = "len", array_length_type = "uint")]
5172 public Array (bool zero_terminated = true, bool clear = true, ulong element_size = 0);
5173 [CCode (cname = "g_array_sized_new")]
5174 public Array.sized (bool zero_terminated, bool clear, ulong element_size, uint reserved_size);
5175 public void append_val (owned G value);
5176 public void append_vals (void* data, uint len);
5177 public void prepend_val (owned G value);
5178 public void prepend_vals (void* data, uint len);
5179 public void insert_val (uint index, owned G value);
5180 public void insert_vals (uint index, void* data, uint len);
5181 public void remove_index (uint index);
5182 public void remove_index_fast (uint index);
5183 public void remove_range (uint index, uint length);
5184 public void sort (CompareFunc<G> compare_func);
5185 public void sort_with_data (CompareDataFunc<G> compare_func);
5186 [CCode (generic_type_pos = 0.1)]
5187 public unowned G index (uint index);
5188 public void set_size (uint length);
5193 public delegate bool TraverseFunc<K,V> (K key, V value);
5195 [CCode (cprefix = "G_", has_type_id = false)]
5196 public enum TraverseType {
5203 public delegate int TreeSearchFunc<K> (K key);
5206 [Version (since = "2.22")]
5207 [CCode (ref_function = "g_tree_ref", unref_function = "g_tree_unref")]
5208 public class Tree<K,V> {
5209 [CCode (cname = "g_tree_new_full", simple_generics = true)]
5210 public Tree (CompareDataFunc<K> key_compare_func);
5211 [Version (deprecated_since = "vala-0.20", replacement = "Tree ()")]
5212 public Tree.with_data (CompareDataFunc<K> key_compare_func);
5213 public Tree.full (CompareDataFunc<K> key_compare_func, DestroyNotify? key_destroy_func, DestroyNotify? value_destroy_func);
5214 public void insert (owned K key, owned V value);
5215 public void replace (owned K key, owned V value);
5216 public int nnodes ();
5217 public int height ();
5218 public unowned V lookup (K key);
5219 public bool lookup_extended (K lookup_key, out unowned K orig_key, out unowned V value);
5220 public void foreach (TraverseFunc<K,V> traverse_func);
5221 public unowned V search (TreeSearchFunc<K> search_func);
5222 [CCode (cname = "g_tree_search")]
5223 public unowned V search_key (CompareFunc<K> search_func, K key);
5224 public bool remove (K key);
5225 public bool steal (K key);
5228 /* Internationalization */
5230 [Version (since = "2.4")]
5231 [CCode (cname = "_", cheader_filename = "glib.h,glib/gi18n-lib.h")]
5232 public static unowned string _ ([FormatArg] string str);
5233 [Version (since = "2.4")]
5234 [CCode (cname = "Q_", cheader_filename = "glib.h,glib/gi18n-lib.h")]
5235 public static unowned string Q_ ([FormatArg] string str);
5236 [Version (since = "2.4")]
5237 [CCode (cname = "N_", cheader_filename = "glib.h,glib/gi18n-lib.h")]
5238 public static unowned string N_ ([FormatArg] string str);
5239 [Version (since = "2.16")]
5240 [CCode (cname = "C_", cheader_filename = "glib.h,glib/gi18n-lib.h")]
5241 public static unowned string C_ (string context, [FormatArg] string str);
5242 [Version (since = "2.18")]
5243 [CCode (cname = "NC_", cheader_filename = "glib.h,glib/gi18n-lib.h")]
5244 public static unowned string NC_ (string context, [FormatArg] string str);
5245 [CCode (cname = "ngettext", cheader_filename = "glib.h,glib/gi18n-lib.h")]
5246 public static unowned string ngettext (string msgid, [FormatArg] string msgid_plural, ulong n);
5247 [Version (since = "2.18")]
5248 [CCode (cname = "g_dgettext", cheader_filename = "glib/gi18n-lib.h")]
5249 public static unowned string dgettext (string? domain, [FormatArg] string msgid);
5250 [Version (since = "2.26")]
5251 [CCode (cname = "g_dcgettext", cheader_filename = "glib/gi18n-lib.h")]
5252 public static unowned string dcgettext (string? domain, [FormatArg] string msgid, int category);
5253 [Version (since = "2.18")]
5254 [CCode (cname = "g_dngettext", cheader_filename = "glib/gi18n-lib.h")]
5255 public static unowned string dngettext (string? domain, string msgid, [FormatArg] string msgid_plural, ulong n);
5256 [Version (since = "2.16")]
5257 [CCode (cname = "g_dpgettext", cheader_filename = "glib/gi18n-lib.h")]
5258 public static unowned string dpgettext (string? domain, [FormatArg] string msgctxid, size_t msgidoffset);
5259 [Version (since = "2.18")]
5260 [CCode (cname = "g_dpgettext2", cheader_filename = "glib/gi18n-lib.h")]
5261 public static unowned string dpgettext2 (string? domain, string context, [FormatArg] string msgid);
5263 [CCode (cname = "int", cprefix = "LC_", cheader_filename = "locale.h", has_type_id = false)]
5264 public enum LocaleCategory {
5275 [CCode (cname = "setlocale", cheader_filename = "locale.h")]
5276 public static unowned string? setlocale (LocaleCategory category = GLib.LocaleCategory.ALL, string? locale = "");
5277 [CCode (cname = "bindtextdomain", cheader_filename = "glib/gi18n-lib.h")]
5278 public static unowned string? bindtextdomain (string domainname, string? dirname);
5279 [CCode (cname = "textdomain", cheader_filename = "glib/gi18n-lib.h")]
5280 public static unowned string? textdomain (string? domainname);
5281 [CCode (cname = "bind_textdomain_codeset", cheader_filename = "glib/gi18n-lib.h")]
5282 public static unowned string? bind_textdomain_codeset (string domainname, string? codeset);
5283 [Version (since = "2.6")]
5284 [CCode (cname = "g_get_language_names", array_length = false, array_null_terminated = true)]
5285 public static unowned string[] get_language_names ();
5286 [Version (since = "2.4")]
5287 [CCode (cname = "g_strip_context", cheader_filename = "glib/gi18n-lib.h")]
5288 public static unowned string strip_context (string msgid, string msgval);
5292 public class PatternSpec {
5293 public PatternSpec (string pattern);
5294 public bool equal (PatternSpec pspec);
5295 [CCode (cname = "g_pattern_match")]
5296 public bool match (uint string_length, string str, string? str_reversed);
5297 [CCode (cname = "g_pattern_match_string")]
5298 public bool match_string (string str);
5299 [CCode (cname = "g_pattern_match_simple")]
5300 public static bool match_simple (string pattern, string str);
5303 [CCode (lower_case_cprefix = "glib_version_")]
5305 [CCode (cname = "glib_major_version")]
5306 public const uint major;
5307 [CCode (cname = "glib_minor_version")]
5308 public const uint minor;
5309 [CCode (cname = "glib_micro_version")]
5310 public const uint micro;
5311 [CCode (cname = "glib_check_version")]
5312 public static unowned string? check (uint required_major, uint required_minor = 0, uint required_micro = 0);
5314 [CCode (cname = "GLIB_MAJOR_VERSION")]
5315 public const uint MAJOR;
5316 [CCode (cname = "GLIB_MINOR_VERSION")]
5317 public const uint MINOR;
5318 [CCode (cname = "GLIB_MICRO_VERSION")]
5319 public const uint MICRO;
5320 [CCode (cname = "GLIB_CHECK_VERSION")]
5321 public static bool CHECK (uint required_major, uint required_minor = 0, uint required_micro = 0);
5323 [CCode (cname = "G_ENCODE_VERSION")]
5324 public static uint encode (uint major, uint minor);
5326 public const uint CUR_STABLE;
5327 public const uint PREV_STABLE;
5328 public const uint MIN_REQUIRED;
5329 public const uint MAX_ALLOWED;
5331 public const uint @2_26;
5332 public const uint @2_28;
5333 public const uint @2_30;
5334 public const uint @2_32;
5335 public const uint @2_34;
5336 public const uint @2_36;
5337 public const uint @2_38;
5338 public const uint @2_40;
5339 public const uint @2_42;
5340 public const uint @2_44;
5341 public const uint @2_46;
5342 public const uint @2_48;
5343 public const uint @2_50;
5344 public const uint @2_52;
5346 [CCode (cname = "glib_binary_age")]
5347 public const uint binary_age;
5348 [CCode (cname = "glib_interface_age")]
5349 public const uint interface_age;
5353 public enum OSType {
5354 [CCode (cname = "G_WIN32_OS_ANY")]
5356 [CCode (cname = "G_WIN32_OS_WORKSTATION")]
5358 [CCode (cname = "G_WIN32_OS_SERVER")]
5361 [Version (since = "2.44")]
5362 public bool check_windows_version (int major, int minor, int spver, GLib.Win32.OSType os_type);
5364 public string error_message (int error);
5365 public string getlocale ();
5366 [Version (since = "2.16")]
5367 public string get_package_installation_directory_of_module (void* hmodule);
5368 public uint get_windows_version ();
5369 [Version (since = "2.8")]
5370 public string locale_filename_from_utf8 (string utf8filename);
5371 [CCode (cname = "G_WIN32_HAVE_WIDECHAR_API")]
5372 public bool have_widechar_api ();
5373 [CCode (cname = "G_WIN32_IS_NT_BASED")]
5374 public bool is_nt_based ();
5375 [Version (since = "2.40")]
5376 [CCode (array_length = false, array_null_terminated = true)]
5377 public string[] get_command_line ();
5382 [Version (since = "2.24")]
5383 [CCode (copy_function = "g_variant_type_copy", free_function = "g_variant_type_free", type_id = "G_TYPE_VARIANT_TYPE")]
5384 public class VariantType {
5385 [CCode (cname = "G_VARIANT_TYPE_BOOLEAN")]
5386 public static VariantType BOOLEAN;
5387 [CCode (cname = "G_VARIANT_TYPE_BYTE")]
5388 public static VariantType BYTE;
5389 [CCode (cname = "G_VARIANT_TYPE_INT16")]
5390 public static VariantType INT16;
5391 [CCode (cname = "G_VARIANT_TYPE_UINT16")]
5392 public static VariantType UINT16;
5393 [CCode (cname = "G_VARIANT_TYPE_INT32")]
5394 public static VariantType INT32;
5395 [CCode (cname = "G_VARIANT_TYPE_UINT32")]
5396 public static VariantType UINT32;
5397 [CCode (cname = "G_VARIANT_TYPE_INT64")]
5398 public static VariantType INT64;
5399 [CCode (cname = "G_VARIANT_TYPE_UINT64")]
5400 public static VariantType UINT64;
5401 [CCode (cname = "G_VARIANT_TYPE_HANDLE")]
5402 public static VariantType HANDLE;
5403 [CCode (cname = "G_VARIANT_TYPE_DOUBLE")]
5404 public static VariantType DOUBLE;
5405 [CCode (cname = "G_VARIANT_TYPE_STRING")]
5406 public static VariantType STRING;
5407 [CCode (cname = "G_VARIANT_TYPE_OBJECT_PATH")]
5408 public static VariantType OBJECT_PATH;
5409 [CCode (cname = "G_VARIANT_TYPE_SIGNATURE")]
5410 public static VariantType SIGNATURE;
5411 [CCode (cname = "G_VARIANT_TYPE_VARIANT")]
5412 public static VariantType VARIANT;
5413 [CCode (cname = "G_VARIANT_TYPE_UNIT")]
5414 public static VariantType UNIT;
5415 [CCode (cname = "G_VARIANT_TYPE_ANY")]
5416 public static VariantType ANY;
5417 [CCode (cname = "G_VARIANT_TYPE_BASIC")]
5418 public static VariantType BASIC;
5419 [CCode (cname = "G_VARIANT_TYPE_MAYBE")]
5420 public static VariantType MAYBE;
5421 [CCode (cname = "G_VARIANT_TYPE_ARRAY")]
5422 public static VariantType ARRAY;
5423 [CCode (cname = "G_VARIANT_TYPE_TUPLE")]
5424 public static VariantType TUPLE;
5425 [CCode (cname = "G_VARIANT_TYPE_DICT_ENTRY")]
5426 public static VariantType DICT_ENTRY;
5427 [CCode (cname = "G_VARIANT_TYPE_DICTIONARY")]
5428 public static VariantType DICTIONARY;
5429 [CCode (cname = "G_VARIANT_TYPE_STRING_ARRAY")]
5430 public static VariantType STRING_ARRAY;
5431 [CCode (cname = "G_VARIANT_TYPE_OBJECT_PATH_ARRAY")]
5432 public static VariantType OBJECT_PATH_ARRAY;
5433 [CCode (cname = "G_VARIANT_TYPE_BYTESTRING")]
5434 public static VariantType BYTESTRING;
5435 [CCode (cname = "G_VARIANT_TYPE_BYTESTRING_ARRAY")]
5436 public static VariantType BYTESTRING_ARRAY;
5437 [Version (since = "2.30")]
5438 [CCode (cname = "G_VARIANT_TYPE_VARDICT")]
5439 public static VariantType VARDICT;
5441 public static bool string_is_valid (string type_string);
5442 public static bool string_scan (string type_string, char *limit, out char* endptr);
5444 public VariantType (string type_string);
5445 public size_t get_string_length ();
5446 public char* peek_string ();
5447 public string dup_string ();
5449 public bool is_definite ();
5450 public bool is_container ();
5451 public bool is_basic ();
5452 public bool is_maybe ();
5453 public bool is_array ();
5454 public bool is_tuple ();
5455 public bool is_dict_entry ();
5456 public bool is_variant ();
5458 public uint hash ();
5459 public bool equal (VariantType other);
5460 public bool is_subtype_of (VariantType supertype);
5462 public unowned VariantType element ();
5463 public unowned VariantType first ();
5464 public unowned VariantType next ();
5465 public unowned VariantType n_items ();
5466 public unowned VariantType key ();
5467 public unowned VariantType value ();
5469 public VariantType.array (VariantType element);
5470 public VariantType.maybe (VariantType element);
5471 public VariantType.tuple (VariantType[] items);
5472 public VariantType.dict_entry (VariantType key, VariantType value);
5476 [Version (since = "2.24")]
5477 [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")]
5478 public class Variant {
5479 [CCode (has_type_id = false)]
5481 BOOLEAN, BYTE, INT16, UINT16, INT32, UINT32, INT64,
5482 UINT64, HANDLE, DOUBLE, STRING, OBJECT_PATH,
5483 SIGNATURE, VARIANT, MAYBE, ARRAY, TUPLE, DICT_ENTRY
5486 public unowned VariantType get_type ();
5487 public unowned string get_type_string ();
5488 public bool is_of_type (VariantType type);
5489 public bool is_container ();
5490 [Version (since = "2.26")]
5491 public bool is_floating ();
5492 public Class classify ();
5493 [Version (since = "2.26")]
5494 public int compare (Variant other);
5496 public Variant.boolean (bool value);
5497 public Variant.byte (uchar value);
5498 public Variant.int16 (int16 value);
5499 public Variant.uint16 (uint16 value);
5500 public Variant.int32 (int32 value);
5501 public Variant.uint32 (uint32 value);
5502 public Variant.int64 (int64 value);
5503 public Variant.uint64 (uint64 value);
5504 public Variant.handle (int32 value);
5505 public Variant.double (double value);
5506 public Variant.string (string value);
5507 [Version (since = "2.26")]
5508 public Variant.bytestring (string value);
5509 public Variant.object_path (string object_path);
5510 public static bool is_object_path (string object_path);
5511 public Variant.signature (string signature);
5512 public static bool is_signature (string signature);
5514 public bool get_boolean ();
5515 public uint8 get_byte ();
5516 public int16 get_int16 ();
5517 public uint16 get_uint16 ();
5518 public int32 get_int32 ();
5519 public uint32 get_uint32 ();
5520 public int64 get_int64 ();
5521 public uint64 get_uint64 ();
5522 public int32 get_handle ();
5523 public double get_double ();
5524 public unowned string get_string (out size_t length = null);
5525 public string dup_string (out size_t length = null);
5526 [Version (since = "2.26")]
5527 public unowned string get_bytestring ();
5528 [Version (since = "2.26")]
5529 public string dup_bytestring (out size_t length);
5531 public Variant.strv (string[] value);
5532 [CCode (array_length_type = "size_t")]
5534 public (unowned string)[] get_strv ();
5536 public string*[] get_strv ();
5538 [CCode (array_length_type = "size_t")]
5539 public string[] dup_strv ();
5541 [Version (since = "2.26")]
5542 public Variant.bytestring_array (string[] value);
5543 [Version (since = "2.26")]
5544 [CCode (array_length_type = "size_t")]
5546 public (unowned string)[] get_bytestring_array ();
5548 public string*[] get_bytestring_array ();
5550 [Version (since = "2.26")]
5551 [CCode (array_length_type = "size_t")]
5552 public string[] dup_bytestring_array ();
5554 [Version (since = "2.30")]
5555 public Variant.objv (string[] value);
5556 [Version (since = "2.30")]
5557 [CCode (array_length_type = "size_t")]
5559 public (unowned string)[] get_objv ();
5561 public string*[] get_objv ();
5563 [Version (since = "2.30")]
5564 [CCode (array_length_type = "size_t")]
5565 public string[] dup_objv ();
5567 public Variant (string format, ...);
5568 // note: the function changes its behaviour when end_ptr is null, so 'out char *' is wrong
5569 public Variant.va (string format, char **end_ptr, va_list *app);
5570 public void get (string format, ...);
5571 public void get_va (string format, char **end_ptr, va_list *app);
5573 public Variant.variant (Variant value);
5574 public Variant.maybe (VariantType? child_type, Variant? child);
5575 public Variant.array (VariantType? child_type, Variant[] children);
5576 [Version (since = "2.32")]
5577 [CCode (simple_generics = true)]
5578 public static Variant new_fixed_array<T> (VariantType? element_type, [CCode (array_length_type = "gsize")] T[] elements, size_t element_size);
5579 public Variant.tuple (Variant[] children);
5580 public Variant.dict_entry (Variant key, Variant value);
5581 public Variant get_variant ();
5582 public Variant? get_maybe ();
5584 public size_t n_children ();
5585 public Variant get_child_value (size_t index);
5586 public void get_child (size_t index, string format_string, ...);
5588 [Version (since = "2.28")]
5589 public Variant? lookup_value (string key, VariantType? expected_type);
5590 [Version (since = "2.28")]
5591 public bool lookup (string key, string format_string, ...);
5593 public size_t get_size ();
5594 public void *get_data ();
5595 public void store (void *data);
5597 public string print (bool type_annotate);
5598 public StringBuilder print_string (StringBuilder? builder, bool type_annotate);
5600 public uint hash ();
5601 public bool equal (Variant other);
5603 public Variant byteswap ();
5604 public Variant get_normal_form ();
5605 public bool is_normal_form ();
5606 [CCode (returns_floating_reference = true, simple_generics = true)]
5607 public static Variant new_from_data<T> (VariantType type, uchar[] data, bool trusted, [CCode (destroy_notify_pos = 3.9)] owned T? owner = null);
5609 [CCode (cname = "g_variant_iter_new")]
5610 public VariantIter iterator ();
5612 public static Variant parse (VariantType? type, string text, char *limit = null, char **endptr = null) throws GLib.VariantParseError;
5613 public Variant.parsed (string format_string, ...);
5615 [Version (since = "2.34")]
5616 public bool check_format_string (string format_string, bool copy_only);
5618 [Version (since = "2.36")]
5619 public Variant.from_bytes (VariantType type, Bytes bytes, bool trusted);
5620 [Version (since = "2.36")]
5621 public Bytes get_data_as_bytes ();
5623 [Version (since = "2.38")]
5624 public Variant.printf (string format_string, ...);
5625 [Version (since = "2.38")]
5626 public Variant.take_string (owned string str);
5628 [Version (since = "2.40")]
5629 public static void parse_error_print_context (GLib.VariantParseError error, string source_str);
5632 [Version (since = "2.24")]
5633 public errordomain VariantParseError {
5635 BASIC_TYPE_EXPECTED,
5637 DEFINITE_TYPE_EXPECTED,
5640 INVALID_FORMAT_STRING,
5641 INVALID_OBJECT_PATH,
5643 INVALID_TYPE_STRING,
5645 NUMBER_OUT_OF_RANGE,
5650 UNTERMINATED_STRING_CONSTANT,
5652 public static GLib.Quark quark ();
5656 [Version (since = "2.24")]
5657 public class VariantIter {
5658 public VariantIter (Variant value);
5659 public size_t n_children ();
5660 public Variant? next_value ();
5661 public bool next (string format_string, ...);
5665 [Version (since = "2.24")]
5666 [CCode (ref_function = "g_variant_builder_ref", unref_function = "g_variant_builder_unref")]
5667 public class VariantBuilder {
5668 public VariantBuilder (VariantType type);
5669 public void open (VariantType type);
5670 public void close ();
5671 public void add_value (Variant value);
5672 public void add (string format_string, ...);
5673 [CCode (returns_floating_reference = true)]
5674 public Variant end ();
5677 [Version (since = "2.40")]
5678 [Compact, CCode (ref_function = "g_variant_dict_ref", unref_function = "g_variant_dict_unref")]
5679 public class VariantDict {
5680 public VariantDict (GLib.Variant? from_asv = null);
5681 public bool lookup (string key, string format_string, ...);
5682 public GLib.Variant lookup_value (string key, GLib.VariantType expected_type);
5683 public bool contains (string key);
5684 public void insert (string key, string format_string, ...);
5685 public void insert_value (string key, GLib.Variant value);
5686 public bool remove (string key);
5687 public void clear ();
5688 [CCode (returns_floating_reference = true)]
5689 public GLib.Variant end ();
5692 [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")]
5693 public class ObjectPath : string {
5694 [CCode (cname = "g_strdup")]
5695 public ObjectPath (string path);
5698 [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")]
5699 public class BusName : string {
5700 [CCode (cname = "g_strdup")]
5701 public BusName (string bus_name);
5704 [CCode (cname = "G_LIKELY", cheader_filename = "glib.h")]
5705 public static bool likely (bool expression);
5706 [CCode (cname = "G_UNLIKELY", cheader_filename = "glib.h")]
5707 public static bool unlikely (bool expression);
5708 [Version (since = "2.20")]
5709 [CCode (cname = "G_STATIC_ASSERT", cheader_filename = "glib.h")]
5710 public static void static_assert (bool expression);
5712 [CCode (simple_generics = true, cname = "g_qsort_with_data")]
5713 private static void _qsort_with_data<T> (T[] elems, size_t size, [CCode (type = "GCompareDataFunc")] GLib.CompareDataFunc<T> compare_func);
5715 [CCode (cname = "_vala_g_qsort_with_data")]
5716 public static void qsort_with_data<T> (T[] elems, size_t size, [CCode (type = "GCompareDataFunc")] GLib.CompareDataFunc<T> compare_func) {
5717 _qsort_with_data<T*> (elems, size, (a, b) => {
5718 return compare_func (*a, *b);
5722 /* Unix-specific functions. All of these have to include glib-unix.h. */
5724 [Version (since = "2.30")]
5725 [CCode (cheader_filename = "glib-unix.h", cname = "g_unix_signal_add_full")]
5726 public static uint signal_add (int signum, owned GLib.SourceFunc handler, [CCode (pos = 0.9)] int priority = Priority.DEFAULT);
5728 [CCode (cheader_filename = "glib-unix.h", cname = "GSource")]
5729 public class SignalSource : GLib.Source {
5730 public SignalSource (int signum);
5733 [Version (since = "2.30")]
5734 [CCode (cheader_filename = "glib-unix.h")]
5735 public static bool open_pipe ([CCode (array_length = false, array_null_terminated = false)] int[] fds, int flags) throws GLib.Error;
5736 [Version (since = "2.30")]
5737 [CCode (cheader_filename = "glib-unix.h")]
5738 public static bool set_fd_nonblocking (int fd, bool nonblock) throws GLib.Error;
5741 [CCode (cname = "GUnicodeScript", cprefix = "G_UNICODE_SCRIPT_", has_type_id = false)]
5742 public enum UnicodeScript {
5784 CANADIAN_ABORIGINAL,
5827 /* Unicode-5.2 additions */
5830 EGYPTIAN_HIEROGLYPHS, /* Egyp */
5831 IMPERIAL_ARAMAIC, /* Armi */
5832 INSCRIPTIONAL_PAHLAVI, /* Phli */
5833 INSCRIPTIONAL_PARTHIAN, /* Prti */
5834 JAVANESE, /* Java */
5837 MEETEI_MAYEK, /* Mtei */
5838 OLD_SOUTH_ARABIAN, /* Sarb */
5839 OLD_TURKIC, /* Orkh */
5840 SAMARITAN, /* Samr */
5841 TAI_THAM, /* Lana */
5842 TAI_VIET, /* Tavt */
5844 /* Unicode-6.0 additions */
5849 /* Unicode-6.1 additions */
5851 MEROITIC_CURSIVE, /* Merc */
5852 MEROITIC_HIEROGLYPHS, /* Mero */
5855 SORA_SOMPENG, /* Sora */
5858 /* Unicode 7.0 additions */
5859 BASSA_VAH, /* Bass */
5860 CAUCASIAN_ALBANIAN, /* Aghb */
5861 DUPLOYAN, /* Dupl */
5865 KHUDAWADI, /* Sind */
5866 LINEAR_A, /* Lina */
5867 MAHAJANI, /* Mahj */
5868 MANICHAEAN, /* Manu */
5869 MENDE_KIKAKUI, /* Mend */
5872 NABATAEAN, /* Nbat */
5873 OLD_NORTH_ARABIAN, /* Narb */
5874 OLD_PERMIC, /* Perm */
5875 PAHAWH_HMONG, /* Hmng */
5876 PALMYRENE, /* Palm */
5877 PAU_CIN_HAU, /* Pauc */
5878 PSALTER_PAHLAVI, /* Phlp */
5881 WARANG_CITI, /* Wara */
5883 /* Unicode 8.0 additions */
5885 ANATOLIAN_HIEROGLYPHS, /* Hluw */
5888 OLD_HUNGARIAN, /* Hung */
5889 SIGNWRITING, /* Sgnw */
5891 /* Unicode 9.0 additions */
5893 BHAIKSUKI, /* Bhks */
5899 [CCode (cname = "g_unicode_script_to_iso15924")]
5900 public uint32 to_iso15924 ();
5901 [CCode (cname = "g_unicode_script_from_iso15924")]
5902 public static GLib.UnicodeScript from_iso15924 (uint32 iso15924);
5905 [CCode (cname = "GUnicodeType", cprefix = "G_UNICODE_", has_type_id = false)]
5906 public enum UnicodeType {
5923 CONNECT_PUNCTUATION,
5927 INITIAL_PUNCTUATION,
5935 PARAGRAPH_SEPARATOR,
5939 [CCode (cname = "GUnicodeBreakType", cprefix = "G_UNICODE_BREAK_", has_type_id = false)]
5940 public enum UnicodeBreakType {
5976 HANGUL_LVT_SYLLABLE,
5978 CONDITIONAL_JAPANESE_STARTER,
5986 [CCode (cname = "GNormalizeMode", cprefix = "G_NORMALIZE_", has_type_id = false)]
5987 public enum NormalizeMode {