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