Regenerate, with newer Clutter and GLib versions.
[girtod.git] / gtk2 / glib2.d
blob69fd1233943e19c1ffd4f3388b9dc4282f753847
1 // *** DO NOT EDIT ***
2 // Automatically generated from "/usr/share/gir-1.0/GLib-2.0.gir"
4 module GLib2;
6 // package: "glib-2.0";
7 // C header: "glib.h";
9 // c:symbol-prefixes: ["g", "glib"]
10 // c:identifier-prefixes: ["G"]
12 // module GLib2;
14 // --- mixin/GLib2__MODULE_HEAD.d --->
16 import core.stdc.limits: c_long, c_ulong;
17 alias int c_int; // Assumes 32-bit wide int.
18 alias uint c_uint; // Assumes 32-bit wide int.
20 import core.sys.posix.sys.types : time_t, ssize_t;
21 import std.c.stdarg : va_list;
22 import std.c.stdio : FILE;
24 alias int gboolean;
27 // A wrapper that makes type <S> behave like a reference type.
29 struct Ref(S) {
30 S* __refpointer;
32 alias __refpointer this;
34 this(S:S)(ref S s) { __refpointer = &s; }
35 this(SP:S*)(SP s) { __refpointer = s; }
36 this(A...)(A s) { __refpointer = new S(s); }
38 void toString(FT)(scope void delegate(const(char)[]) sink, FT fmt) {
39 import std.format;
40 formatValue(sink, *__refpointer, fmt);
44 // Helpers; used by gtk.init, clutter.init etc.
46 auto argvToC(string argv[]) {
47 alias char* GTK_STRING;
48 GTK_STRING[] c_argv = new GTK_STRING[argv.length];
50 foreach (i, arg; argv)
51 c_argv[i] = cast(GTK_STRING)arg.ptr;
53 return c_argv.ptr;
56 string[] argvFromC(int argc, const(char*)* argv) {
57 import std.string;
58 string[] result = new string[argc];
60 for(int i=0; i<argc; i++) {
61 auto len = indexOf(argv[i][0..int.max], '\0');
62 result[i] = cast(string)argv[i][0..len];
65 return result;
69 // Debugging helper.
71 void _dumpObj(T)(T o, bool deep=0) {
72 import std.stdio;
73 auto ts = o.tupleof;
74 write(typeid(o), " {");
76 static if (is(typeof(*T)==union)) {
77 write(*o, "}\n");
78 return;
80 else
81 writeln();
83 foreach (i, t; ts) {
84 write(" (", typeid(t), ") ", t);
85 if (deep)
86 static if (is(typeof(*t)))
87 if (ts[i])
88 write(" {", *ts[i], "}");
89 write(i!=ts.length-1 ? "\n" : "\n}\n");
93 // <--- mixin/GLib2__MODULE_HEAD.d ---
96 // Integer representing a day of the month; between 1 and
97 // 31. #G_DATE_BAD_DAY represents an invalid day of the month.
98 alias ubyte DateDay;
100 // Integer representing a year; #G_DATE_BAD_YEAR is the invalid
101 // value. The year must be 1 or higher; negative (BC) years are not
102 // allowed. The year is represented with four digits.
103 alias ushort DateYear;
105 // A type which is used to hold a process identification.
107 // On UNIX, processes are identified by a process id (an integer),
108 // while Windows uses process handles (which are pointers).
110 // GPid is used in GLib only for descendant processes spawned with
111 // the g_spawn functions.
112 alias int Pid;
114 // A GQuark is a non-zero integer which uniquely identifies a
115 // particular string. A GQuark value of zero is associated to %NULL.
116 alias uint Quark;
117 // A C representable type name for #G_TYPE_STRV.
118 alias void* Strv;
120 // Simply a replacement for <type>time_t</type>. It has been deprecated
121 // since it is <emphasis>not</emphasis> equivalent to <type>time_t</type>
122 // on 64-bit platforms with a 64-bit <type>time_t</type>.
123 // Unrelated to #GTimer.
125 // Note that <type>GTime</type> is defined to always be a 32bit integer,
126 // unlike <type>time_t</type> which may be 64bit on some systems.
127 // Therefore, <type>GTime</type> will overflow in the year 2038, and
128 // you cannot use the address of a <type>GTime</type> variable as argument
129 // to the UNIX time() function. Instead, do the following:
130 // |[
131 // time_t ttime;
132 // GTime gtime;
134 // time (&amp;ttime);
135 // gtime = (GTime)ttime;
136 // ]|
137 alias int Time;
138 // A value representing an interval of time, in microseconds.
139 alias long TimeSpan;
141 // A numerical value which represents the unique identifier of a registered
142 // type.
143 alias size_t Type;
144 enum int ASCII_DTOSTR_BUF_SIZE = 39;
145 // Contains the public fields of an <link linkend="glib-Arrays">Array</link>.
146 struct Array {
147 char* data;
148 uint len;
151 // Unintrospectable function: append_vals() / g_array_append_vals()
152 // Adds @len elements onto the end of the array.
153 // <array>: a #GArray.
154 // <data>: a pointer to the elements to append to the end of the array.
155 // <len>: the number of elements to append.
156 static Array* append_vals()(Array* array, const(void)* data, uint len) {
157 return g_array_append_vals(array, data, len);
160 // Frees the memory allocated for the #GArray. If @free_segment is
161 // %TRUE it frees the memory block holding the elements as well and
162 // also each element if @array has a @element_free_func set. Pass
163 // %FALSE if you want to free the #GArray wrapper but preserve the
164 // underlying array for use elsewhere. If the reference count of @array
165 // is greater than one, the #GArray wrapper is preserved but the size
166 // of @array will be set to zero.
168 // <note><para>If array elements contain dynamically-allocated memory,
169 // they should be freed separately.</para></note>
170 // <array>: a #GArray.
171 // <free_segment>: if %TRUE the actual element data is freed as well.
172 static char* /*new*/ free()(Array* array, int free_segment) {
173 return g_array_free(array, free_segment);
176 // VERSION: 2.22
177 // Gets the size of the elements in @array.
178 // RETURNS: Size of each element, in bytes.
179 // <array>: A #GArray.
180 static uint get_element_size()(Array* array) {
181 return g_array_get_element_size(array);
184 // Unintrospectable function: insert_vals() / g_array_insert_vals()
185 // Inserts @len elements into a #GArray at the given index.
186 // <array>: a #GArray.
187 // <index_>: the index to place the elements at.
188 // <data>: a pointer to the elements to insert.
189 // <len>: the number of elements to insert.
190 static Array* insert_vals()(Array* array, uint index_, const(void)* data, uint len) {
191 return g_array_insert_vals(array, index_, data, len);
194 // Unintrospectable function: new() / g_array_new()
195 // Creates a new #GArray with a reference count of 1.
196 // <zero_terminated>: %TRUE if the array should have an extra element at the end which is set to 0.
197 // <clear_>: %TRUE if #GArray elements should be automatically cleared to 0 when they are allocated.
198 // <element_size>: the size of each element in bytes.
199 static Array* new_()(int zero_terminated, int clear_, uint element_size) {
200 return g_array_new(zero_terminated, clear_, element_size);
203 // Unintrospectable function: prepend_vals() / g_array_prepend_vals()
204 // Adds @len elements onto the start of the array.
206 // This operation is slower than g_array_append_vals() since the
207 // existing elements in the array have to be moved to make space for
208 // the new elements.
209 // <array>: a #GArray.
210 // <data>: a pointer to the elements to prepend to the start of the array.
211 // <len>: the number of elements to prepend.
212 static Array* prepend_vals()(Array* array, const(void)* data, uint len) {
213 return g_array_prepend_vals(array, data, len);
216 // Unintrospectable function: ref() / g_array_ref()
217 // VERSION: 2.22
218 // Atomically increments the reference count of @array by one. This
219 // function is MT-safe and may be called from any thread.
220 // RETURNS: The passed in #GArray.
221 // <array>: A #GArray.
222 static Array* ref_()(Array* array) {
223 return g_array_ref(array);
226 // Unintrospectable function: remove_index() / g_array_remove_index()
227 // Removes the element at the given index from a #GArray. The following
228 // elements are moved down one place.
229 // <array>: a #GArray.
230 // <index_>: the index of the element to remove.
231 static Array* remove_index()(Array* array, uint index_) {
232 return g_array_remove_index(array, index_);
235 // Unintrospectable function: remove_index_fast() / g_array_remove_index_fast()
236 // Removes the element at the given index from a #GArray. The last
237 // element in the array is used to fill in the space, so this function
238 // does not preserve the order of the #GArray. But it is faster than
239 // g_array_remove_index().
240 // <array>: a @GArray.
241 // <index_>: the index of the element to remove.
242 static Array* remove_index_fast()(Array* array, uint index_) {
243 return g_array_remove_index_fast(array, index_);
246 // Unintrospectable function: remove_range() / g_array_remove_range()
247 // VERSION: 2.4
248 // Removes the given number of elements starting at the given index
249 // from a #GArray. The following elements are moved to close the gap.
250 // <array>: a @GArray.
251 // <index_>: the index of the first element to remove.
252 // <length>: the number of elements to remove.
253 static Array* remove_range()(Array* array, uint index_, uint length) {
254 return g_array_remove_range(array, index_, length);
256 static void set_clear_func()(Array* array, DestroyNotify clear_func) {
257 g_array_set_clear_func(array, clear_func);
260 // Unintrospectable function: set_size() / g_array_set_size()
261 // Sets the size of the array, expanding it if necessary. If the array
262 // was created with @clear_ set to %TRUE, the new elements are set to 0.
263 // <array>: a #GArray.
264 // <length>: the new size of the #GArray.
265 static Array* set_size()(Array* array, uint length) {
266 return g_array_set_size(array, length);
269 // Unintrospectable function: sized_new() / g_array_sized_new()
270 // Creates a new #GArray with @reserved_size elements preallocated and
271 // a reference count of 1. This avoids frequent reallocation, if you
272 // are going to add many elements to the array. Note however that the
273 // size of the array is still 0.
274 // <zero_terminated>: %TRUE if the array should have an extra element at the end with all bits cleared.
275 // <clear_>: %TRUE if all bits in the array should be cleared to 0 on allocation.
276 // <element_size>: size of each element in the array.
277 // <reserved_size>: number of elements preallocated.
278 static Array* sized_new()(int zero_terminated, int clear_, uint element_size, uint reserved_size) {
279 return g_array_sized_new(zero_terminated, clear_, element_size, reserved_size);
282 // Unintrospectable function: sort() / g_array_sort()
283 // Sorts a #GArray using @compare_func which should be a qsort()-style
284 // comparison function (returns less than zero for first arg is less
285 // than second arg, zero for equal, greater zero if first arg is
286 // greater than second arg).
288 // If two array elements compare equal, their order in the sorted array
289 // is undefined. If you want equal elements to keep their order (i.e.
290 // you want a stable sort) you can write a comparison function that,
291 // if two elements would otherwise compare equal, compares them by
292 // their addresses.
293 // <array>: a #GArray.
294 // <compare_func>: comparison function.
295 static void sort()(Array* array, CompareFunc compare_func) {
296 g_array_sort(array, compare_func);
299 // Unintrospectable function: sort_with_data() / g_array_sort_with_data()
300 // Like g_array_sort(), but the comparison function receives an extra
301 // user data argument.
302 // <array>: a #GArray.
303 // <compare_func>: comparison function.
304 // <user_data>: data to pass to @compare_func.
305 static void sort_with_data()(Array* array, CompareDataFunc compare_func, void* user_data) {
306 g_array_sort_with_data(array, compare_func, user_data);
309 // VERSION: 2.22
310 // Atomically decrements the reference count of @array by one. If the
311 // reference count drops to 0, all memory allocated by the array is
312 // released. This function is MT-safe and may be called from any
313 // thread.
314 // <array>: A #GArray.
315 static void unref()(Array* array) {
316 g_array_unref(array);
320 enum AsciiType {
321 ALNUM = 1,
322 ALPHA = 2,
323 CNTRL = 4,
324 DIGIT = 8,
325 GRAPH = 16,
326 LOWER = 32,
327 PRINT = 64,
328 PUNCT = 128,
329 SPACE = 256,
330 UPPER = 512,
331 XDIGIT = 1024
334 // The GAsyncQueue struct is an opaque data structure which represents
335 // an asynchronous queue. It should only be accessed through the
336 // <function>g_async_queue_*</function> functions.
337 struct AsyncQueue {
339 // Returns the length of the queue.
341 // Actually this function returns the number of data items in
342 // the queue minus the number of waiting threads, so a negative
343 // value means waiting threads, and a positive value means available
344 // entries in the @queue. A return value of 0 could mean n entries
345 // in the queue and n threads waiting. This can happen due to locking
346 // of the queue or due to scheduling.
347 // RETURNS: the length of the @queue
348 int length()() {
349 return g_async_queue_length(&this);
352 // Returns the length of the queue.
354 // Actually this function returns the number of data items in
355 // the queue minus the number of waiting threads, so a negative
356 // value means waiting threads, and a positive value means available
357 // entries in the @queue. A return value of 0 could mean n entries
358 // in the queue and n threads waiting. This can happen due to locking
359 // of the queue or due to scheduling.
361 // This function must be called while holding the @queue's lock.
362 // RETURNS: the length of the @queue.
363 int length_unlocked()() {
364 return g_async_queue_length_unlocked(&this);
367 // Acquires the @queue's lock. If another thread is already
368 // holding the lock, this call will block until the lock
369 // becomes available.
371 // Call g_async_queue_unlock() to drop the lock again.
373 // While holding the lock, you can only call the
374 // <function>g_async_queue_*_unlocked()</function> functions
375 // on @queue. Otherwise, deadlock may occur.
376 void lock()() {
377 g_async_queue_lock(&this);
380 // Unintrospectable method: pop() / g_async_queue_pop()
381 // Pops data from the @queue. If @queue is empty, this function
382 // blocks until data becomes available.
383 // RETURNS: data from the queue
384 void* pop()() {
385 return g_async_queue_pop(&this);
388 // Unintrospectable method: pop_unlocked() / g_async_queue_pop_unlocked()
389 // Pops data from the @queue. If @queue is empty, this function
390 // blocks until data becomes available.
392 // This function must be called while holding the @queue's lock.
393 // RETURNS: data from the queue.
394 void* pop_unlocked()() {
395 return g_async_queue_pop_unlocked(&this);
398 // Pushes the @data into the @queue. @data must not be %NULL.
399 // <data>: @data to push into the @queue
400 void push()(void* data) {
401 g_async_queue_push(&this, data);
404 // Unintrospectable method: push_sorted() / g_async_queue_push_sorted()
405 // VERSION: 2.10
406 // Inserts @data into @queue using @func to determine the new
407 // position.
409 // This function requires that the @queue is sorted before pushing on
410 // new elements, see g_async_queue_sort().
412 // This function will lock @queue before it sorts the queue and unlock
413 // it when it is finished.
415 // For an example of @func see g_async_queue_sort().
416 // <data>: the @data to push into the @queue
417 // <func>: the #GCompareDataFunc is used to sort @queue
418 // <user_data>: user data passed to @func.
419 void push_sorted()(void* data, CompareDataFunc func, void* user_data) {
420 g_async_queue_push_sorted(&this, data, func, user_data);
423 // Unintrospectable method: push_sorted_unlocked() / g_async_queue_push_sorted_unlocked()
424 // VERSION: 2.10
425 // Inserts @data into @queue using @func to determine the new
426 // position.
428 // The sort function @func is passed two elements of the @queue.
429 // It should return 0 if they are equal, a negative value if the
430 // first element should be higher in the @queue or a positive value
431 // if the first element should be lower in the @queue than the second
432 // element.
434 // This function requires that the @queue is sorted before pushing on
435 // new elements, see g_async_queue_sort().
437 // This function must be called while holding the @queue's lock.
439 // For an example of @func see g_async_queue_sort().
440 // <data>: the @data to push into the @queue
441 // <func>: the #GCompareDataFunc is used to sort @queue
442 // <user_data>: user data passed to @func.
443 void push_sorted_unlocked()(void* data, CompareDataFunc func, void* user_data) {
444 g_async_queue_push_sorted_unlocked(&this, data, func, user_data);
447 // Pushes the @data into the @queue. @data must not be %NULL.
449 // This function must be called while holding the @queue's lock.
450 // <data>: @data to push into the @queue
451 void push_unlocked()(void* data) {
452 g_async_queue_push_unlocked(&this, data);
455 // Unintrospectable method: ref() / g_async_queue_ref()
456 // Increases the reference count of the asynchronous @queue by 1.
457 // You do not need to hold the lock to call this function.
458 // RETURNS: the @queue that was passed in (since 2.6)
459 AsyncQueue* ref_()() {
460 return g_async_queue_ref(&this);
463 // Increases the reference count of the asynchronous @queue by 1.
465 // so g_async_queue_ref() can be used regardless of the @queue's
466 // lock.
467 void ref_unlocked()() {
468 g_async_queue_ref_unlocked(&this);
471 // Unintrospectable method: sort() / g_async_queue_sort()
472 // VERSION: 2.10
473 // Sorts @queue using @func.
475 // The sort function @func is passed two elements of the @queue.
476 // It should return 0 if they are equal, a negative value if the
477 // first element should be higher in the @queue or a positive value
478 // if the first element should be lower in the @queue than the second
479 // element.
481 // This function will lock @queue before it sorts the queue and unlock
482 // it when it is finished.
484 // If you were sorting a list of priority numbers to make sure the
485 // lowest priority would be at the top of the queue, you could use:
486 // |[
487 // gint32 id1;
488 // gint32 id2;
490 // id1 = GPOINTER_TO_INT (element1);
491 // id2 = GPOINTER_TO_INT (element2);
493 // return (id1 > id2 ? +1 : id1 == id2 ? 0 : -1);
494 // ]|
495 // <func>: the #GCompareDataFunc is used to sort @queue
496 // <user_data>: user data passed to @func
497 void sort()(CompareDataFunc func, void* user_data) {
498 g_async_queue_sort(&this, func, user_data);
501 // Unintrospectable method: sort_unlocked() / g_async_queue_sort_unlocked()
502 // VERSION: 2.10
503 // Sorts @queue using @func.
505 // The sort function @func is passed two elements of the @queue.
506 // It should return 0 if they are equal, a negative value if the
507 // first element should be higher in the @queue or a positive value
508 // if the first element should be lower in the @queue than the second
509 // element.
511 // This function must be called while holding the @queue's lock.
512 // <func>: the #GCompareDataFunc is used to sort @queue
513 // <user_data>: user data passed to @func
514 void sort_unlocked()(CompareDataFunc func, void* user_data) {
515 g_async_queue_sort_unlocked(&this, func, user_data);
518 // Unintrospectable method: timed_pop() / g_async_queue_timed_pop()
519 // Pops data from the @queue. If the queue is empty, blocks until
520 // @end_time or until data becomes available.
522 // If no data is received before @end_time, %NULL is returned.
524 // To easily calculate @end_time, a combination of g_get_current_time()
525 // and g_time_val_add() can be used.
527 // received before @end_time.
528 // RETURNS: data from the queue or %NULL, when no data is
529 // <end_time>: a #GTimeVal, determining the final time
530 void* timed_pop()(TimeVal* end_time) {
531 return g_async_queue_timed_pop(&this, end_time);
534 // Unintrospectable method: timed_pop_unlocked() / g_async_queue_timed_pop_unlocked()
535 // Pops data from the @queue. If the queue is empty, blocks until
536 // @end_time or until data becomes available.
538 // If no data is received before @end_time, %NULL is returned.
540 // To easily calculate @end_time, a combination of g_get_current_time()
541 // and g_time_val_add() can be used.
543 // This function must be called while holding the @queue's lock.
545 // received before @end_time.
546 // RETURNS: data from the queue or %NULL, when no data is
547 // <end_time>: a #GTimeVal, determining the final time
548 void* timed_pop_unlocked()(TimeVal* end_time) {
549 return g_async_queue_timed_pop_unlocked(&this, end_time);
552 // Unintrospectable method: try_pop() / g_async_queue_try_pop()
553 // Tries to pop data from the @queue. If no data is available,
554 // %NULL is returned.
556 // available immediately.
557 // RETURNS: data from the queue or %NULL, when no data is
558 void* try_pop()() {
559 return g_async_queue_try_pop(&this);
562 // Unintrospectable method: try_pop_unlocked() / g_async_queue_try_pop_unlocked()
563 // Tries to pop data from the @queue. If no data is available,
564 // %NULL is returned.
566 // This function must be called while holding the @queue's lock.
568 // available immediately.
569 // RETURNS: data from the queue or %NULL, when no data is
570 void* try_pop_unlocked()() {
571 return g_async_queue_try_pop_unlocked(&this);
574 // Releases the queue's lock.
576 // Calling this function when you have not acquired
577 // the with g_async_queue_lock() leads to undefined
578 // behaviour.
579 void unlock()() {
580 g_async_queue_unlock(&this);
583 // Decreases the reference count of the asynchronous @queue by 1.
585 // If the reference count went to 0, the @queue will be destroyed
586 // and the memory allocated will be freed. So you are not allowed
587 // to use the @queue afterwards, as it might have disappeared.
588 // You do not need to hold the lock to call this function.
589 void unref()() {
590 g_async_queue_unref(&this);
593 // Decreases the reference count of the asynchronous @queue by 1
594 // and releases the lock. This function must be called while holding
595 // the @queue's lock. If the reference count went to 0, the @queue
596 // will be destroyed and the memory allocated will be freed.
598 // so g_async_queue_unref() can be used regardless of the @queue's
599 // lock.
600 void unref_and_unlock()() {
601 g_async_queue_unref_and_unlock(&this);
604 // Unintrospectable function: new() / g_async_queue_new()
605 // Creates a new asynchronous queue.
606 // RETURNS: a new #GAsyncQueue. Free with g_async_queue_unref()
607 static AsyncQueue* new_()() {
608 return g_async_queue_new();
611 // Unintrospectable function: new_full() / g_async_queue_new_full()
612 // VERSION: 2.16
613 // Creates a new asynchronous queue and sets up a destroy notify
614 // function that is used to free any remaining queue items when
615 // the queue is destroyed after the final unref.
616 // RETURNS: a new #GAsyncQueue. Free with g_async_queue_unref()
617 // <item_free_func>: function to free queue elements
618 static AsyncQueue* new_full()(DestroyNotify item_free_func) {
619 return g_async_queue_new_full(item_free_func);
623 enum int BIG_ENDIAN = 4321;
625 // The <structname>GBookmarkFile</structname> struct contains only
626 // private data and should not be directly accessed.
627 struct BookmarkFile {
629 // VERSION: 2.12
630 // Adds the application with @name and @exec to the list of
631 // applications that have registered a bookmark for @uri into
632 // @bookmark.
634 // Every bookmark inside a #GBookmarkFile must have at least an
635 // application registered. Each application must provide a name, a
636 // command line useful for launching the bookmark, the number of times
637 // the bookmark has been registered by the application and the last
638 // time the application registered this bookmark.
640 // If @name is %NULL, the name of the application will be the
641 // same returned by g_get_application_name(); if @exec is %NULL, the
642 // command line will be a composition of the program name as
643 // returned by g_get_prgname() and the "\%u" modifier, which will be
644 // expanded to the bookmark's URI.
646 // This function will automatically take care of updating the
647 // registrations count and timestamping in case an application
648 // with the same @name had already registered a bookmark for
649 // @uri inside @bookmark.
651 // If no bookmark for @uri is found, one is created.
652 // <uri>: a valid URI
653 // <name>: the name of the application registering the bookmark or %NULL
654 // <exec>: command line to be used to launch the bookmark or %NULL
655 void add_application()(char* uri, char* name, char* exec) {
656 g_bookmark_file_add_application(&this, uri, name, exec);
659 // VERSION: 2.12
660 // Adds @group to the list of groups to which the bookmark for @uri
661 // belongs to.
663 // If no bookmark for @uri is found then it is created.
664 // <uri>: a valid URI
665 // <group>: the group name to be added
666 void add_group()(char* uri, char* group) {
667 g_bookmark_file_add_group(&this, uri, group);
670 // VERSION: 2.12
671 // Frees a #GBookmarkFile.
672 void free()() {
673 g_bookmark_file_free(&this);
676 // VERSION: 2.12
677 // Gets the time the bookmark for @uri was added to @bookmark
679 // In the event the URI cannot be found, -1 is returned and
680 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
681 // RETURNS: a timestamp
682 // <uri>: a valid URI
683 time_t get_added()(char* uri, GLib2.Error** error=null) {
684 return g_bookmark_file_get_added(&this, uri, error);
687 // VERSION: 2.12
688 // Gets the registration informations of @app_name for the bookmark for
689 // @uri. See g_bookmark_file_set_app_info() for more informations about
690 // the returned data.
692 // The string returned in @app_exec must be freed.
694 // In the event the URI cannot be found, %FALSE is returned and
695 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the
696 // event that no application with name @app_name has registered a bookmark
697 // for @uri, %FALSE is returned and error is set to
698 // #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. In the event that unquoting
699 // the command line fails, an error of the #G_SHELL_ERROR domain is
700 // set and %FALSE is returned.
701 // RETURNS: %TRUE on success.
702 // <uri>: a valid URI
703 // <name>: an application's name
704 // <exec>: location for the command line of the application, or %NULL
705 // <count>: return location for the registration count, or %NULL
706 // <stamp>: return location for the last registration time, or %NULL
707 int get_app_info()(char* uri, char* name, char** exec, uint* count, time_t* stamp, GLib2.Error** error=null) {
708 return g_bookmark_file_get_app_info(&this, uri, name, exec, count, stamp, error);
711 // Unintrospectable method: get_applications() / g_bookmark_file_get_applications()
712 // VERSION: 2.12
713 // Retrieves the names of the applications that have registered the
714 // bookmark for @uri.
716 // In the event the URI cannot be found, %NULL is returned and
717 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
719 // Use g_strfreev() to free it.
720 // RETURNS: a newly allocated %NULL-terminated array of strings.
721 // <uri>: a valid URI
722 // <length>: return location of the length of the returned list, or %NULL
723 char** get_applications()(char* uri, size_t* length, GLib2.Error** error=null) {
724 return g_bookmark_file_get_applications(&this, uri, length, error);
727 // VERSION: 2.12
728 // Retrieves the description of the bookmark for @uri.
730 // In the event the URI cannot be found, %NULL is returned and
731 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
733 // URI cannot be found.
734 // RETURNS: a newly allocated string or %NULL if the specified
735 // <uri>: a valid URI
736 char* /*new*/ get_description()(char* uri, GLib2.Error** error=null) {
737 return g_bookmark_file_get_description(&this, uri, error);
740 // Unintrospectable method: get_groups() / g_bookmark_file_get_groups()
741 // VERSION: 2.12
742 // Retrieves the list of group names of the bookmark for @uri.
744 // In the event the URI cannot be found, %NULL is returned and
745 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
747 // The returned array is %NULL terminated, so @length may optionally
748 // be %NULL.
750 // Use g_strfreev() to free it.
751 // RETURNS: a newly allocated %NULL-terminated array of group names.
752 // <uri>: a valid URI
753 // <length>: return location for the length of the returned string, or %NULL
754 char** get_groups()(char* uri, size_t* length, GLib2.Error** error=null) {
755 return g_bookmark_file_get_groups(&this, uri, length, error);
758 // VERSION: 2.12
759 // Gets the icon of the bookmark for @uri.
761 // In the event the URI cannot be found, %FALSE is returned and
762 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
764 // You should free the returned strings.
765 // RETURNS: %TRUE if the icon for the bookmark for the URI was found.
766 // <uri>: a valid URI
767 // <href>: return location for the icon's location or %NULL
768 // <mime_type>: return location for the icon's MIME type or %NULL
769 int get_icon()(char* uri, char** href, char** mime_type, GLib2.Error** error=null) {
770 return g_bookmark_file_get_icon(&this, uri, href, mime_type, error);
773 // VERSION: 2.12
774 // Gets whether the private flag of the bookmark for @uri is set.
776 // In the event the URI cannot be found, %FALSE is returned and
777 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the
778 // event that the private flag cannot be found, %FALSE is returned and
779 // @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
780 // RETURNS: %TRUE if the private flag is set, %FALSE otherwise.
781 // <uri>: a valid URI
782 int get_is_private()(char* uri, GLib2.Error** error=null) {
783 return g_bookmark_file_get_is_private(&this, uri, error);
786 // VERSION: 2.12
787 // Retrieves the MIME type of the resource pointed by @uri.
789 // In the event the URI cannot be found, %NULL is returned and
790 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the
791 // event that the MIME type cannot be found, %NULL is returned and
792 // @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
794 // URI cannot be found.
795 // RETURNS: a newly allocated string or %NULL if the specified
796 // <uri>: a valid URI
797 char* /*new*/ get_mime_type()(char* uri, GLib2.Error** error=null) {
798 return g_bookmark_file_get_mime_type(&this, uri, error);
801 // VERSION: 2.12
802 // Gets the time when the bookmark for @uri was last modified.
804 // In the event the URI cannot be found, -1 is returned and
805 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
806 // RETURNS: a timestamp
807 // <uri>: a valid URI
808 time_t get_modified()(char* uri, GLib2.Error** error=null) {
809 return g_bookmark_file_get_modified(&this, uri, error);
812 // VERSION: 2.12
813 // Gets the number of bookmarks inside @bookmark.
814 // RETURNS: the number of bookmarks
815 int get_size()() {
816 return g_bookmark_file_get_size(&this);
819 // VERSION: 2.12
820 // Returns the title of the bookmark for @uri.
822 // If @uri is %NULL, the title of @bookmark is returned.
824 // In the event the URI cannot be found, %NULL is returned and
825 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
827 // URI cannot be found.
828 // RETURNS: a newly allocated string or %NULL if the specified
829 // <uri>: a valid URI or %NULL
830 char* /*new*/ get_title()(char* uri, GLib2.Error** error=null) {
831 return g_bookmark_file_get_title(&this, uri, error);
834 // Unintrospectable method: get_uris() / g_bookmark_file_get_uris()
835 // VERSION: 2.12
836 // Returns all URIs of the bookmarks in the bookmark file @bookmark.
837 // The array of returned URIs will be %NULL-terminated, so @length may
838 // optionally be %NULL.
840 // Use g_strfreev() to free it.
841 // RETURNS: a newly allocated %NULL-terminated array of strings.
842 // <length>: return location for the number of returned URIs, or %NULL
843 char** get_uris()(size_t* length) {
844 return g_bookmark_file_get_uris(&this, length);
847 // VERSION: 2.12
848 // Gets the time the bookmark for @uri was last visited.
850 // In the event the URI cannot be found, -1 is returned and
851 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
852 // RETURNS: a timestamp.
853 // <uri>: a valid URI
854 time_t get_visited()(char* uri, GLib2.Error** error=null) {
855 return g_bookmark_file_get_visited(&this, uri, error);
858 // VERSION: 2.12
859 // Checks whether the bookmark for @uri inside @bookmark has been
860 // registered by application @name.
862 // In the event the URI cannot be found, %FALSE is returned and
863 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
864 // RETURNS: %TRUE if the application @name was found
865 // <uri>: a valid URI
866 // <name>: the name of the application
867 int has_application()(char* uri, char* name, GLib2.Error** error=null) {
868 return g_bookmark_file_has_application(&this, uri, name, error);
871 // VERSION: 2.12
872 // Checks whether @group appears in the list of groups to which
873 // the bookmark for @uri belongs to.
875 // In the event the URI cannot be found, %FALSE is returned and
876 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
877 // RETURNS: %TRUE if @group was found.
878 // <uri>: a valid URI
879 // <group>: the group name to be searched
880 int has_group()(char* uri, char* group, GLib2.Error** error=null) {
881 return g_bookmark_file_has_group(&this, uri, group, error);
884 // VERSION: 2.12
885 // Looks whether the desktop bookmark has an item with its URI set to @uri.
886 // RETURNS: %TRUE if @uri is inside @bookmark, %FALSE otherwise
887 // <uri>: a valid URI
888 int has_item()(char* uri) {
889 return g_bookmark_file_has_item(&this, uri);
892 // VERSION: 2.12
893 // Loads a bookmark file from memory into an empty #GBookmarkFile
894 // structure. If the object cannot be created then @error is set to a
895 // #GBookmarkFileError.
896 // RETURNS: %TRUE if a desktop bookmark could be loaded.
897 // <data>: desktop bookmarks loaded in memory
898 // <length>: the length of @data in bytes
899 int load_from_data()(char* data, size_t length, GLib2.Error** error=null) {
900 return g_bookmark_file_load_from_data(&this, data, length, error);
903 // VERSION: 2.12
904 // This function looks for a desktop bookmark file named @file in the
905 // paths returned from g_get_user_data_dir() and g_get_system_data_dirs(),
906 // loads the file into @bookmark and returns the file's full path in
907 // @full_path. If the file could not be loaded then an %error is
908 // set to either a #GFileError or #GBookmarkFileError.
909 // RETURNS: %TRUE if a key file could be loaded, %FALSE othewise
910 // <file>: a relative path to a filename to open and parse
911 // <full_path>: return location for a string containing the full path of the file, or %NULL
912 int load_from_data_dirs()(char* file, char** full_path, GLib2.Error** error=null) {
913 return g_bookmark_file_load_from_data_dirs(&this, file, full_path, error);
916 // VERSION: 2.12
917 // Loads a desktop bookmark file into an empty #GBookmarkFile structure.
918 // If the file could not be loaded then @error is set to either a #GFileError
919 // or #GBookmarkFileError.
920 // RETURNS: %TRUE if a desktop bookmark file could be loaded
921 // <filename>: the path of a filename to load, in the GLib file name encoding
922 int load_from_file()(char* filename, GLib2.Error** error=null) {
923 return g_bookmark_file_load_from_file(&this, filename, error);
926 // VERSION: 2.12
927 // Changes the URI of a bookmark item from @old_uri to @new_uri. Any
928 // existing bookmark for @new_uri will be overwritten. If @new_uri is
929 // %NULL, then the bookmark is removed.
931 // In the event the URI cannot be found, %FALSE is returned and
932 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
933 // RETURNS: %TRUE if the URI was successfully changed
934 // <old_uri>: a valid URI
935 // <new_uri>: a valid URI, or %NULL
936 int move_item()(char* old_uri, char* new_uri, GLib2.Error** error=null) {
937 return g_bookmark_file_move_item(&this, old_uri, new_uri, error);
940 // VERSION: 2.12
941 // Removes application registered with @name from the list of applications
942 // that have registered a bookmark for @uri inside @bookmark.
944 // In the event the URI cannot be found, %FALSE is returned and
945 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
946 // In the event that no application with name @app_name has registered
947 // a bookmark for @uri, %FALSE is returned and error is set to
948 // #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED.
949 // RETURNS: %TRUE if the application was successfully removed.
950 // <uri>: a valid URI
951 // <name>: the name of the application
952 int remove_application()(char* uri, char* name, GLib2.Error** error=null) {
953 return g_bookmark_file_remove_application(&this, uri, name, error);
956 // VERSION: 2.12
957 // Removes @group from the list of groups to which the bookmark
958 // for @uri belongs to.
960 // In the event the URI cannot be found, %FALSE is returned and
961 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
962 // In the event no group was defined, %FALSE is returned and
963 // @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
964 // RETURNS: %TRUE if @group was successfully removed.
965 // <uri>: a valid URI
966 // <group>: the group name to be removed
967 int remove_group()(char* uri, char* group, GLib2.Error** error=null) {
968 return g_bookmark_file_remove_group(&this, uri, group, error);
971 // VERSION: 2.12
972 // Removes the bookmark for @uri from the bookmark file @bookmark.
973 // RETURNS: %TRUE if the bookmark was removed successfully.
974 // <uri>: a valid URI
975 int remove_item()(char* uri, GLib2.Error** error=null) {
976 return g_bookmark_file_remove_item(&this, uri, error);
979 // VERSION: 2.12
980 // Sets the time the bookmark for @uri was added into @bookmark.
982 // If no bookmark for @uri is found then it is created.
983 // <uri>: a valid URI
984 // <added>: a timestamp or -1 to use the current time
985 void set_added()(char* uri, time_t added) {
986 g_bookmark_file_set_added(&this, uri, added);
989 // VERSION: 2.12
990 // Sets the meta-data of application @name inside the list of
991 // applications that have registered a bookmark for @uri inside
992 // @bookmark.
994 // You should rarely use this function; use g_bookmark_file_add_application()
995 // and g_bookmark_file_remove_application() instead.
997 // @name can be any UTF-8 encoded string used to identify an
998 // application.
999 // be expanded as the local file name retrieved from the bookmark's
1000 // URI; "\%u", which will be expanded as the bookmark's URI.
1001 // The expansion is done automatically when retrieving the stored
1002 // command line using the g_bookmark_file_get_app_info() function.
1003 // @count is the number of times the application has registered the
1004 // bookmark; if is < 0, the current registration count will be increased
1005 // by one, if is 0, the application with @name will be removed from
1006 // the list of registered applications.
1007 // @stamp is the Unix time of the last registration; if it is -1, the
1008 // current time will be used.
1010 // If you try to remove an application by setting its registration count to
1011 // zero, and no bookmark for @uri is found, %FALSE is returned and
1012 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND; similarly,
1013 // in the event that no application @name has registered a bookmark
1014 // for @uri, %FALSE is returned and error is set to
1015 // #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. Otherwise, if no bookmark
1016 // for @uri is found, one is created.
1018 // changed.
1019 // RETURNS: %TRUE if the application's meta-data was successfully
1020 // <uri>: a valid URI
1021 // <name>: an application's name
1022 // <exec>: an application's command line
1023 // <count>: the number of registrations done for this application
1024 // <stamp>: the time of the last registration for this application
1025 int set_app_info()(char* uri, char* name, char* exec, int count, time_t stamp, GLib2.Error** error=null) {
1026 return g_bookmark_file_set_app_info(&this, uri, name, exec, count, stamp, error);
1029 // VERSION: 2.12
1030 // Sets @description as the description of the bookmark for @uri.
1032 // If @uri is %NULL, the description of @bookmark is set.
1034 // If a bookmark for @uri cannot be found then it is created.
1035 // <uri>: a valid URI or %NULL
1036 // <description>: a string
1037 void set_description()(char* uri, char* description) {
1038 g_bookmark_file_set_description(&this, uri, description);
1041 // VERSION: 2.12
1042 // Sets a list of group names for the item with URI @uri. Each previously
1043 // set group name list is removed.
1045 // If @uri cannot be found then an item for it is created.
1046 // <uri>: an item's URI
1047 // <groups>: an array of group names, or %NULL to remove all groups
1048 // <length>: number of group name values in @groups
1049 void set_groups()(char* uri, char** groups, size_t length) {
1050 g_bookmark_file_set_groups(&this, uri, groups, length);
1053 // VERSION: 2.12
1054 // Sets the icon for the bookmark for @uri. If @href is %NULL, unsets
1055 // the currently set icon. @href can either be a full URL for the icon
1056 // file or the icon name following the Icon Naming specification.
1058 // If no bookmark for @uri is found one is created.
1059 // <uri>: a valid URI
1060 // <href>: the URI of the icon for the bookmark, or %NULL
1061 // <mime_type>: the MIME type of the icon for the bookmark
1062 void set_icon()(char* uri, char* href, char* mime_type) {
1063 g_bookmark_file_set_icon(&this, uri, href, mime_type);
1066 // VERSION: 2.12
1067 // Sets the private flag of the bookmark for @uri.
1069 // If a bookmark for @uri cannot be found then it is created.
1070 // <uri>: a valid URI
1071 // <is_private>: %TRUE if the bookmark should be marked as private
1072 void set_is_private()(char* uri, int is_private) {
1073 g_bookmark_file_set_is_private(&this, uri, is_private);
1076 // VERSION: 2.12
1077 // Sets @mime_type as the MIME type of the bookmark for @uri.
1079 // If a bookmark for @uri cannot be found then it is created.
1080 // <uri>: a valid URI
1081 // <mime_type>: a MIME type
1082 void set_mime_type()(char* uri, char* mime_type) {
1083 g_bookmark_file_set_mime_type(&this, uri, mime_type);
1086 // VERSION: 2.12
1087 // Sets the last time the bookmark for @uri was last modified.
1089 // If no bookmark for @uri is found then it is created.
1091 // The "modified" time should only be set when the bookmark's meta-data
1092 // was actually changed. Every function of #GBookmarkFile that
1093 // modifies a bookmark also changes the modification time, except for
1094 // g_bookmark_file_set_visited().
1095 // <uri>: a valid URI
1096 // <modified>: a timestamp or -1 to use the current time
1097 void set_modified()(char* uri, time_t modified) {
1098 g_bookmark_file_set_modified(&this, uri, modified);
1101 // VERSION: 2.12
1102 // Sets @title as the title of the bookmark for @uri inside the
1103 // bookmark file @bookmark.
1105 // If @uri is %NULL, the title of @bookmark is set.
1107 // If a bookmark for @uri cannot be found then it is created.
1108 // <uri>: a valid URI or %NULL
1109 // <title>: a UTF-8 encoded string
1110 void set_title()(char* uri, char* title) {
1111 g_bookmark_file_set_title(&this, uri, title);
1114 // VERSION: 2.12
1115 // Sets the time the bookmark for @uri was last visited.
1117 // If no bookmark for @uri is found then it is created.
1119 // The "visited" time should only be set if the bookmark was launched,
1120 // either using the command line retrieved by g_bookmark_file_get_app_info()
1121 // or by the default application for the bookmark's MIME type, retrieved
1122 // using g_bookmark_file_get_mime_type(). Changing the "visited" time
1123 // does not affect the "modified" time.
1124 // <uri>: a valid URI
1125 // <visited>: a timestamp or -1 to use the current time
1126 void set_visited()(char* uri, time_t visited) {
1127 g_bookmark_file_set_visited(&this, uri, visited);
1130 // VERSION: 2.12
1131 // This function outputs @bookmark as a string.
1133 // the contents of the #GBookmarkFile
1134 // RETURNS: a newly allocated string holding
1135 // <length>: return location for the length of the returned string, or %NULL
1136 char* /*new*/ to_data()(size_t* length, GLib2.Error** error=null) {
1137 return g_bookmark_file_to_data(&this, length, error);
1140 // VERSION: 2.12
1141 // This function outputs @bookmark into a file. The write process is
1142 // guaranteed to be atomic by using g_file_set_contents() internally.
1143 // RETURNS: %TRUE if the file was successfully written.
1144 // <filename>: path of the output file
1145 int to_file()(char* filename, GLib2.Error** error=null) {
1146 return g_bookmark_file_to_file(&this, filename, error);
1148 static Quark error_quark()() {
1149 return g_bookmark_file_error_quark();
1152 // Unintrospectable function: new() / g_bookmark_file_new()
1153 // VERSION: 2.12
1154 // Creates a new empty #GBookmarkFile object.
1156 // Use g_bookmark_file_load_from_file(), g_bookmark_file_load_from_data()
1157 // or g_bookmark_file_load_from_data_dirs() to read an existing bookmark
1158 // file.
1159 // RETURNS: an empty #GBookmarkFile
1160 static BookmarkFile* new_()() {
1161 return g_bookmark_file_new();
1165 // Error codes returned by bookmark file parsing.
1166 enum BookmarkFileError {
1167 INVALID_URI = 0,
1168 INVALID_VALUE = 1,
1169 APP_NOT_REGISTERED = 2,
1170 URI_NOT_FOUND = 3,
1171 READ = 4,
1172 UNKNOWN_ENCODING = 5,
1173 WRITE = 6,
1174 FILE_NOT_FOUND = 7
1177 // The <structname>GByteArray</structname> struct allows access to the
1178 // public fields of a <structname>GByteArray</structname>.
1179 struct ByteArray {
1180 ubyte* data;
1181 uint len;
1184 // Unintrospectable function: append() / g_byte_array_append()
1185 // Adds the given bytes to the end of the #GByteArray. The array will
1186 // grow in size automatically if necessary.
1187 // <array>: a #GByteArray.
1188 // <data>: the byte data to be added.
1189 // <len>: the number of bytes to add.
1190 static ByteArray* append()(ByteArray* array, ubyte* data, uint len) {
1191 return g_byte_array_append(array, data, len);
1194 // Frees the memory allocated by the #GByteArray. If @free_segment is
1195 // %TRUE it frees the actual byte data. If the reference count of
1196 // @array is greater than one, the #GByteArray wrapper is preserved but
1197 // the size of @array will be set to zero.
1198 // <array>: a #GByteArray.
1199 // <free_segment>: if %TRUE the actual byte data is freed as well.
1200 static ubyte* free()(ByteArray* array, int free_segment) {
1201 return g_byte_array_free(array, free_segment);
1204 // VERSION: 2.32
1205 // Transfers the data from the #GByteArray into a new immutable #GBytes.
1207 // The #GByteArray is freed unless the reference count of @array is greater
1208 // than one, the #GByteArray wrapper is preserved but the size of @array
1209 // will be set to zero.
1211 // This is identical to using g_bytes_new_take() and g_byte_array_free()
1212 // together.
1215 // data that was in the array
1216 // RETURNS: a new immutable #GBytes representing same byte
1217 // <array>: a #GByteArray
1218 static Bytes* /*new*/ free_to_bytes()(ByteArray* array) {
1219 return g_byte_array_free_to_bytes(array);
1222 // Unintrospectable function: new() / g_byte_array_new()
1223 // Creates a new #GByteArray with a reference count of 1.
1224 static ByteArray* new_()() {
1225 return g_byte_array_new();
1228 // VERSION: 2.32
1229 // Create byte array containing the data. The data will be owned by the array
1230 // and will be freed with g_free(), i.e. it could be allocated using g_strdup().
1231 // RETURNS: a new #GByteArray
1232 // <data>: byte data for the array
1233 // <len>: length of @data
1234 static ByteArray* /*new*/ new_take()(ubyte* data, size_t len) {
1235 return g_byte_array_new_take(data, len);
1238 // Unintrospectable function: prepend() / g_byte_array_prepend()
1239 // Adds the given data to the start of the #GByteArray. The array will
1240 // grow in size automatically if necessary.
1241 // <array>: a #GByteArray.
1242 // <data>: the byte data to be added.
1243 // <len>: the number of bytes to add.
1244 static ByteArray* prepend()(ByteArray* array, ubyte* data, uint len) {
1245 return g_byte_array_prepend(array, data, len);
1248 // Unintrospectable function: ref() / g_byte_array_ref()
1249 // VERSION: 2.22
1250 // Atomically increments the reference count of @array by one. This
1251 // function is MT-safe and may be called from any thread.
1252 // RETURNS: The passed in #GByteArray.
1253 // <array>: A #GByteArray.
1254 static ByteArray* ref_()(ByteArray* array) {
1255 return g_byte_array_ref(array);
1258 // Unintrospectable function: remove_index() / g_byte_array_remove_index()
1259 // Removes the byte at the given index from a #GByteArray. The
1260 // following bytes are moved down one place.
1261 // <array>: a #GByteArray.
1262 // <index_>: the index of the byte to remove.
1263 static ByteArray* remove_index()(ByteArray* array, uint index_) {
1264 return g_byte_array_remove_index(array, index_);
1267 // Unintrospectable function: remove_index_fast() / g_byte_array_remove_index_fast()
1268 // Removes the byte at the given index from a #GByteArray. The last
1269 // element in the array is used to fill in the space, so this function
1270 // does not preserve the order of the #GByteArray. But it is faster
1271 // than g_byte_array_remove_index().
1272 // <array>: a #GByteArray.
1273 // <index_>: the index of the byte to remove.
1274 static ByteArray* remove_index_fast()(ByteArray* array, uint index_) {
1275 return g_byte_array_remove_index_fast(array, index_);
1278 // Unintrospectable function: remove_range() / g_byte_array_remove_range()
1279 // VERSION: 2.4
1280 // Removes the given number of bytes starting at the given index from a
1281 // #GByteArray. The following elements are moved to close the gap.
1282 // <array>: a @GByteArray.
1283 // <index_>: the index of the first byte to remove.
1284 // <length>: the number of bytes to remove.
1285 static ByteArray* remove_range()(ByteArray* array, uint index_, uint length) {
1286 return g_byte_array_remove_range(array, index_, length);
1289 // Unintrospectable function: set_size() / g_byte_array_set_size()
1290 // Sets the size of the #GByteArray, expanding it if necessary.
1291 // <array>: a #GByteArray.
1292 // <length>: the new size of the #GByteArray.
1293 static ByteArray* set_size()(ByteArray* array, uint length) {
1294 return g_byte_array_set_size(array, length);
1297 // Unintrospectable function: sized_new() / g_byte_array_sized_new()
1298 // Creates a new #GByteArray with @reserved_size bytes preallocated.
1299 // This avoids frequent reallocation, if you are going to add many
1300 // bytes to the array. Note however that the size of the array is still
1301 // 0.
1302 // <reserved_size>: number of bytes preallocated.
1303 static ByteArray* sized_new()(uint reserved_size) {
1304 return g_byte_array_sized_new(reserved_size);
1307 // Unintrospectable function: sort() / g_byte_array_sort()
1308 // Sorts a byte array, using @compare_func which should be a
1309 // qsort()-style comparison function (returns less than zero for first
1310 // arg is less than second arg, zero for equal, greater than zero if
1311 // first arg is greater than second arg).
1313 // If two array elements compare equal, their order in the sorted array
1314 // is undefined. If you want equal elements to keep their order (i.e.
1315 // you want a stable sort) you can write a comparison function that,
1316 // if two elements would otherwise compare equal, compares them by
1317 // their addresses.
1318 // <array>: a #GByteArray.
1319 // <compare_func>: comparison function.
1320 static void sort()(ByteArray* array, CompareFunc compare_func) {
1321 g_byte_array_sort(array, compare_func);
1324 // Unintrospectable function: sort_with_data() / g_byte_array_sort_with_data()
1325 // Like g_byte_array_sort(), but the comparison function takes an extra
1326 // user data argument.
1327 // <array>: a #GByteArray.
1328 // <compare_func>: comparison function.
1329 // <user_data>: data to pass to @compare_func.
1330 static void sort_with_data()(ByteArray* array, CompareDataFunc compare_func, void* user_data) {
1331 g_byte_array_sort_with_data(array, compare_func, user_data);
1334 // VERSION: 2.22
1335 // Atomically decrements the reference count of @array by one. If the
1336 // reference count drops to 0, all memory allocated by the array is
1337 // released. This function is MT-safe and may be called from any
1338 // thread.
1339 // <array>: A #GByteArray.
1340 static void unref()(ByteArray* array) {
1341 g_byte_array_unref(array);
1346 // A simple refcounted data type representing an immutable byte sequence
1347 // from an unspecified origin.
1349 // The purpose of a #GBytes is to keep the memory region that it holds
1350 // alive for as long as anyone holds a reference to the bytes. When
1351 // the last reference count is dropped, the memory is released. Multiple
1352 // unrelated callers can use byte data in the #GBytes without coordinating
1353 // their activities, resting assured that the byte data will not change or
1354 // move while they hold a reference.
1356 // A #GBytes can come from many different origins that may have
1357 // different procedures for freeing the memory region. Examples are
1358 // memory from g_malloc(), from memory slices, from a #GMappedFile or
1359 // memory from other allocators.
1361 // #GBytes work well as keys in #GHashTable. Use g_bytes_equal() and
1362 // g_bytes_hash() as parameters to g_hash_table_new() or g_hash_table_new_full().
1363 // #GBytes can also be used as keys in a #GTree by passing the g_bytes_compare()
1364 // function to g_tree_new().
1366 // The data pointed to by this bytes must not be modified. For a mutable
1367 // array of bytes see #GByteArray. Use g_bytes_unref_to_array() to create a
1368 // mutable array for a #GBytes sequence. To create an immutable #GBytes from
1369 // a mutable #GByteArray, use the g_byte_array_free_to_bytes() function.
1370 struct Bytes /* Version 2.32 */ {
1372 // VERSION: 2.32
1373 // Creates a new #GBytes from @data.
1375 // @data is copied.
1376 // RETURNS: a new #GBytes
1377 // <data>: the data to be used for the bytes
1378 // <size>: the size of @data
1379 static Bytes* /*new*/ new_()(const(void)* data, size_t size) {
1380 return g_bytes_new(data, size);
1383 // VERSION: 2.32
1384 // Creates a new #GBytes from static data.
1385 // RETURNS: a new #GBytes
1386 // <data>: the data to be used for the bytes
1387 // <size>: the size of @data
1388 static Bytes* /*new*/ new_static()(const(void)* data, size_t size) {
1389 return g_bytes_new_static(data, size);
1392 // VERSION: 2.32
1393 // Creates a new #GBytes from @data.
1395 // After this call, @data belongs to the bytes and may no longer be
1396 // modified by the caller. g_free() will be called on @data when the
1397 // bytes is no longer in use. Because of this @data must have been created by
1398 // a call to g_malloc(), g_malloc0() or g_realloc() or by one of the many
1399 // functions that wrap these calls (such as g_new(), g_strdup(), etc).
1401 // For creating #GBytes with memory from other allocators, see
1402 // g_bytes_new_with_free_func().
1403 // RETURNS: a new #GBytes
1404 // <data>: the data to be used for the bytes
1405 // <size>: the size of @data
1406 static Bytes* /*new*/ new_take()(void* data, size_t size) {
1407 return g_bytes_new_take(data, size);
1410 // VERSION: 2.32
1411 // Creates a #GBytes from @data.
1413 // When the last reference is dropped, @free_func will be called with the
1414 // @user_data argument.
1416 // @data must not be modified after this call is made until @free_func has
1417 // been called to indicate that the bytes is no longer in use.
1418 // RETURNS: a new #GBytes
1419 // <data>: the data to be used for the bytes
1420 // <size>: the size of @data
1421 // <free_func>: the function to call to release the data
1422 // <user_data>: data to pass to @free_func
1423 static Bytes* /*new*/ new_with_free_func()(const(void)* data, size_t size, DestroyNotify free_func, void* user_data) {
1424 return g_bytes_new_with_free_func(data, size, free_func, user_data);
1427 // VERSION: 2.32
1428 // Compares the two #GBytes values.
1430 // This function can be used to sort GBytes instances in lexographical order.
1432 // greater, and zero if bytes2 is equal to bytes1
1433 // RETURNS: a negative value if bytes2 is lesser, a positive value if bytes2 is
1434 // <bytes2>: a pointer to a #GBytes to compare with @bytes1
1435 int compare()(const(Bytes)* bytes2) {
1436 return g_bytes_compare(&this, bytes2);
1439 // VERSION: 2.32
1440 // Compares the two #GBytes values being pointed to and returns
1441 // %TRUE if they are equal.
1443 // This function can be passed to g_hash_table_new() as the @key_equal_func
1444 // parameter, when using non-%NULL #GBytes pointers as keys in a #GHashTable.
1445 // RETURNS: %TRUE if the two keys match.
1446 // <bytes2>: a pointer to a #GBytes to compare with @bytes1
1447 int equal()(const(Bytes)* bytes2) {
1448 return g_bytes_equal(&this, bytes2);
1451 // Unintrospectable method: get_data() / g_bytes_get_data()
1452 // VERSION: 2.32
1453 // Get the byte data in the #GBytes. This data should not be modified.
1455 // This function will always return the same pointer for a given #GBytes.
1456 // RETURNS: a pointer to the byte data
1457 // <size>: location to return size of byte data
1458 const(ubyte)* get_data()(/*out*/ size_t* size=null) {
1459 return g_bytes_get_data(&this, size);
1462 // VERSION: 2.32
1463 // Get the size of the byte data in the #GBytes.
1465 // This function will always return the same value for a given #GBytes.
1466 // RETURNS: the size
1467 size_t get_size()() {
1468 return g_bytes_get_size(&this);
1471 // VERSION: 2.32
1472 // Creates an integer hash code for the byte data in the #GBytes.
1474 // This function can be passed to g_hash_table_new() as the @key_equal_func
1475 // parameter, when using non-%NULL #GBytes pointers as keys in a #GHashTable.
1476 // RETURNS: a hash value corresponding to the key.
1477 uint hash()() {
1478 return g_bytes_hash(&this);
1481 // VERSION: 2.32
1482 // Creates a #GBytes which is a subsection of another #GBytes. The @offset +
1483 // @length may not be longer than the size of @bytes.
1485 // A reference to @bytes will be held by the newly created #GBytes until
1486 // the byte data is no longer needed.
1487 // RETURNS: a new #GBytes
1488 // <offset>: offset which subsection starts at
1489 // <length>: length of subsection
1490 Bytes* /*new*/ new_from_bytes()(size_t offset, size_t length) {
1491 return g_bytes_new_from_bytes(&this, offset, length);
1494 // VERSION: 2.32
1495 // Increase the reference count on @bytes.
1496 // RETURNS: the #GBytes
1497 Bytes* /*new*/ ref_()() {
1498 return g_bytes_ref(&this);
1501 // VERSION: 2.32
1502 // Releases a reference on @bytes. This may result in the bytes being
1503 // freed.
1504 void unref()() {
1505 g_bytes_unref(&this);
1508 // VERSION: 2.32
1509 // Unreferences the bytes, and returns a new mutable #GByteArray containing
1510 // the same byte data.
1512 // As an optimization, the byte data is transferred to the array without copying
1513 // if this was the last reference to bytes and bytes was created with
1514 // g_bytes_new(), g_bytes_new_take() or g_byte_array_free_to_bytes(). In all
1515 // other cases the data is copied.
1516 // RETURNS: a new mutable #GByteArray containing the same byte data
1517 ByteArray* /*new*/ unref_to_array()() {
1518 return g_bytes_unref_to_array(&this);
1521 // VERSION: 2.32
1522 // Unreferences the bytes, and returns a pointer the same byte data
1523 // contents.
1525 // As an optimization, the byte data is returned without copying if this was
1526 // the last reference to bytes and bytes was created with g_bytes_new(),
1527 // g_bytes_new_take() or g_byte_array_free_to_bytes(). In all other cases the
1528 // data is copied.
1530 // be freed with g_free()
1531 // RETURNS: a pointer to the same byte data, which should
1532 // <size>: location to place the length of the returned data
1533 void* /*new*/ unref_to_data()(size_t* size) {
1534 return g_bytes_unref_to_data(&this, size);
1538 enum int CAN_INLINE = 1;
1539 enum CSET_A_2_Z = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
1540 enum CSET_DIGITS = "0123456789";
1541 enum CSET_a_2_z = "abcdefghijklmnopqrstuvwxyz";
1543 // An opaque structure representing a checksumming operation.
1544 // To create a new GChecksum, use g_checksum_new(). To free
1545 // a GChecksum, use g_checksum_free().
1546 struct Checksum /* Version 2.16 */ {
1548 // Unintrospectable method: copy() / g_checksum_copy()
1549 // VERSION: 2.16
1550 // Copies a #GChecksum. If @checksum has been closed, by calling
1551 // g_checksum_get_string() or g_checksum_get_digest(), the copied
1552 // checksum will be closed as well.
1554 // when finished using it.
1555 // RETURNS: the copy of the passed #GChecksum. Use g_checksum_free()
1556 Checksum* copy()() {
1557 return g_checksum_copy(&this);
1560 // VERSION: 2.16
1561 // Frees the memory allocated for @checksum.
1562 void free()() {
1563 g_checksum_free(&this);
1566 // VERSION: 2.16
1567 // Gets the digest from @checksum as a raw binary vector and places it
1568 // into @buffer. The size of the digest depends on the type of checksum.
1570 // Once this function has been called, the #GChecksum is closed and can
1571 // no longer be updated with g_checksum_update().
1572 // <buffer>: output buffer
1573 // <digest_len>: an inout parameter. The caller initializes it to the size of @buffer. After the call it contains the length of the digest.
1574 void get_digest()(ubyte* buffer, size_t* digest_len) {
1575 g_checksum_get_digest(&this, buffer, digest_len);
1578 // VERSION: 2.16
1579 // Gets the digest as an hexadecimal string.
1581 // Once this function has been called the #GChecksum can no longer be
1582 // updated with g_checksum_update().
1584 // The hexadecimal characters will be lower case.
1586 // returned string is owned by the checksum and should not be modified
1587 // or freed.
1588 // RETURNS: the hexadecimal representation of the checksum. The
1589 char* get_string()() {
1590 return g_checksum_get_string(&this);
1593 // VERSION: 2.18
1594 // Resets the state of the @checksum back to its initial state.
1595 void reset()() {
1596 g_checksum_reset(&this);
1599 // VERSION: 2.16
1600 // Feeds @data into an existing #GChecksum. The checksum must still be
1601 // open, that is g_checksum_get_string() or g_checksum_get_digest() must
1602 // not have been called on @checksum.
1603 // <data>: buffer used to compute the checksum
1604 // <length>: size of the buffer, or -1 if it is a null-terminated string.
1605 void update()(ubyte* data, ssize_t length) {
1606 g_checksum_update(&this, data, length);
1609 // Unintrospectable function: new() / g_checksum_new()
1610 // VERSION: 2.16
1611 // Creates a new #GChecksum, using the checksum algorithm @checksum_type.
1612 // If the @checksum_type is not known, %NULL is returned.
1613 // A #GChecksum can be used to compute the checksum, or digest, of an
1614 // arbitrary binary blob, using different hashing algorithms.
1616 // A #GChecksum works by feeding a binary blob through g_checksum_update()
1617 // until there is data to be checked; the digest can then be extracted
1618 // using g_checksum_get_string(), which will return the checksum as a
1619 // hexadecimal string; or g_checksum_get_digest(), which will return a
1620 // vector of raw bytes. Once either g_checksum_get_string() or
1621 // g_checksum_get_digest() have been called on a #GChecksum, the checksum
1622 // will be closed and it won't be possible to call g_checksum_update()
1623 // on it anymore.
1625 // Use g_checksum_free() to free the memory allocated by it.
1626 // RETURNS: the newly created #GChecksum, or %NULL.
1627 // <checksum_type>: the desired type of checksum
1628 static Checksum* new_()(ChecksumType checksum_type) {
1629 return g_checksum_new(checksum_type);
1632 // VERSION: 2.16
1633 // Gets the length in bytes of digests of type @checksum_type
1635 // not supported.
1636 // RETURNS: the checksum length, or -1 if @checksum_type is
1637 // <checksum_type>: a #GChecksumType
1638 static ssize_t type_get_length()(ChecksumType checksum_type) {
1639 return g_checksum_type_get_length(checksum_type);
1644 // The hashing algorithm to be used by #GChecksum when performing the
1645 // digest of some data.
1647 // Note that the #GChecksumType enumeration may be extended at a later
1648 // date to include new hashing algorithm types.
1649 enum ChecksumType /* Version 2.16 */ {
1650 MD5 = 0,
1651 SHA1 = 1,
1652 SHA256 = 2
1655 // The type of functions to be called when a child exists.
1656 // <pid>: the process id of the child process
1657 // <status>: Status information about the child process, see waitpid(2) for more information about this field
1658 // <user_data>: user data passed to g_child_watch_add()
1659 extern (C) alias void function (Pid pid, int status, void* user_data) ChildWatchFunc;
1662 // Specifies the type of a comparison function used to compare two
1663 // values. The function should return a negative integer if the first
1664 // value comes before the second, 0 if they are equal, or a positive
1665 // integer if the first value comes after the second.
1666 // <a>: a value.
1667 // <b>: a value to compare with.
1668 // <user_data>: user data to pass to comparison function.
1669 extern (C) alias int function (const(void)* a, const(void)* b, void* user_data) CompareDataFunc;
1672 // Specifies the type of a comparison function used to compare two
1673 // values. The function should return a negative integer if the first
1674 // value comes before the second, 0 if they are equal, or a positive
1675 // integer if the first value comes after the second.
1676 // <a>: a value.
1677 // <b>: a value to compare with.
1678 extern (C) alias int function (const(void)* a, const(void)* b) CompareFunc;
1681 // The #GCond struct is an opaque data structure that represents a
1682 // condition. Threads can block on a #GCond if they find a certain
1683 // condition to be false. If other threads change the state of this
1684 // condition they signal the #GCond, and that causes the waiting
1685 // threads to be woken up.
1687 // Consider the following example of a shared variable. One or more
1688 // threads can wait for data to be published to the variable and when
1689 // another thread publishes the data, it can signal one of the waiting
1690 // threads to wake up to collect the data.
1692 // <example>
1693 // <title>
1694 // Using GCond to block a thread until a condition is satisfied
1695 // </title>
1696 // <programlisting>
1697 // gpointer current_data = NULL;
1698 // GMutex data_mutex;
1699 // GCond data_cond;
1701 // void
1702 // push_data (gpointer data)
1703 // {
1704 // g_mutex_lock (&data_mutex);
1705 // current_data = data;
1706 // g_cond_signal (&data_cond);
1707 // g_mutex_unlock (&data_mutex);
1708 // }
1710 // gpointer
1711 // pop_data (void)
1712 // {
1713 // gpointer data;
1715 // g_mutex_lock (&data_mutex);
1716 // while (!current_data)
1717 // g_cond_wait (&data_cond, &data_mutex);
1718 // data = current_data;
1719 // current_data = NULL;
1720 // g_mutex_unlock (&data_mutex);
1722 // return data;
1723 // }
1724 // </programlisting>
1725 // </example>
1727 // Whenever a thread calls pop_data() now, it will wait until
1728 // current_data is non-%NULL, i.e. until some other thread
1729 // has called push_data().
1731 // The example shows that use of a condition variable must always be
1732 // paired with a mutex. Without the use of a mutex, there would be a
1733 // race between the check of <varname>current_data</varname> by the
1734 // while loop in <function>pop_data</function> and waiting.
1735 // Specifically, another thread could set <varname>pop_data</varname>
1736 // after the check, and signal the cond (with nobody waiting on it)
1737 // before the first thread goes to sleep. #GCond is specifically useful
1738 // for its ability to release the mutex and go to sleep atomically.
1740 // It is also important to use the g_cond_wait() and g_cond_wait_until()
1741 // functions only inside a loop which checks for the condition to be
1742 // true. See g_cond_wait() for an explanation of why the condition may
1743 // not be true even after it returns.
1745 // If a #GCond is allocated in static storage then it can be used
1746 // without initialisation. Otherwise, you should call g_cond_init() on
1747 // it and g_cond_clear() when done.
1749 // A #GCond should only be accessed via the <function>g_cond_</function>
1750 // functions.
1751 struct Cond {
1752 private void* p;
1753 private uint[2] i;
1756 // If threads are waiting for @cond, all of them are unblocked.
1757 // If no threads are waiting for @cond, this function has no effect.
1758 // It is good practice to lock the same mutex as the waiting threads
1759 // while calling this function, though not required.
1760 void broadcast()() {
1761 g_cond_broadcast(&this);
1764 // VERSION: 2.32
1765 // Frees the resources allocated to a #GCond with g_cond_init().
1767 // This function should not be used with a #GCond that has been
1768 // statically allocated.
1770 // Calling g_cond_clear() for a #GCond on which threads are
1771 // blocking leads to undefined behaviour.
1772 void clear()() {
1773 g_cond_clear(&this);
1776 // VERSION: 2.32
1777 // Initialises a #GCond so that it can be used.
1779 // This function is useful to initialise a #GCond that has been
1780 // allocated as part of a larger structure. It is not necessary to
1781 // initialise a #GCond that has been statically allocated.
1783 // To undo the effect of g_cond_init() when a #GCond is no longer
1784 // needed, use g_cond_clear().
1786 // Calling g_cond_init() on an already-initialised #GCond leads
1787 // to undefined behaviour.
1788 void init()() {
1789 g_cond_init(&this);
1792 // If threads are waiting for @cond, at least one of them is unblocked.
1793 // If no threads are waiting for @cond, this function has no effect.
1794 // It is good practice to hold the same lock as the waiting thread
1795 // while calling this function, though not required.
1796 void signal()() {
1797 g_cond_signal(&this);
1800 // Atomically releases @mutex and waits until @cond is signalled.
1802 // When using condition variables, it is possible that a spurious wakeup
1803 // may occur (ie: g_cond_wait() returns even though g_cond_signal() was
1804 // not called). It's also possible that a stolen wakeup may occur.
1805 // This is when g_cond_signal() is called, but another thread acquires
1806 // @mutex before this thread and modifies the state of the program in
1807 // such a way that when g_cond_wait() is able to return, the expected
1808 // condition is no longer met.
1810 // For this reason, g_cond_wait() must always be used in a loop. See
1811 // the documentation for #GCond for a complete example.
1812 // <mutex>: a #GMutex that is currently locked
1813 void wait()(Mutex* mutex) {
1814 g_cond_wait(&this, mutex);
1817 // VERSION: 2.32
1818 // Waits until either @cond is signalled or @end_time has passed.
1820 // As with g_cond_wait() it is possible that a spurious or stolen wakeup
1821 // could occur. For that reason, waiting on a condition variable should
1822 // always be in a loop, based on an explicitly-checked predicate.
1824 // %TRUE is returned if the condition variable was signalled (or in the
1825 // case of a spurious wakeup). %FALSE is returned if @end_time has
1826 // passed.
1828 // The following code shows how to correctly perform a timed wait on a
1829 // condition variable (extended the example presented in the
1830 // documentation for #GCond):
1832 // |[
1833 // gpointer
1834 // pop_data_timed (void)
1835 // {
1836 // gint64 end_time;
1837 // gpointer data;
1839 // g_mutex_lock (&data_mutex);
1841 // end_time = g_get_monotonic_time () + 5 * G_TIME_SPAN_SECOND;
1842 // while (!current_data)
1843 // if (!g_cond_wait_until (&data_cond, &data_mutex, end_time))
1844 // {
1845 // // timeout has passed.
1846 // g_mutex_unlock (&data_mutex);
1847 // return NULL;
1848 // }
1850 // // there is data for us
1851 // data = current_data;
1852 // current_data = NULL;
1854 // g_mutex_unlock (&data_mutex);
1856 // return data;
1857 // }
1858 // ]|
1860 // Notice that the end time is calculated once, before entering the
1861 // loop and reused. This is the motivation behind the use of absolute
1862 // time on this API -- if a relative time of 5 seconds were passed
1863 // directly to the call and a spurious wakeup occured, the program would
1864 // have to start over waiting again (which would lead to a total wait
1865 // time of more than 5 seconds).
1866 // RETURNS: %TRUE on a signal, %FALSE on a timeout
1867 // <mutex>: a #GMutex that is currently locked
1868 // <end_time>: the monotonic time to wait until
1869 int wait_until()(Mutex* mutex, long end_time) {
1870 return g_cond_wait_until(&this, mutex, end_time);
1874 // Error codes returned by character set conversion routines.
1875 enum ConvertError {
1876 NO_CONVERSION = 0,
1877 ILLEGAL_SEQUENCE = 1,
1878 FAILED = 2,
1879 PARTIAL_INPUT = 3,
1880 BAD_URI = 4,
1881 NOT_ABSOLUTE_PATH = 5
1884 // Unintrospectable callback: CopyFunc() / ()
1885 // VERSION: 2.4
1886 // A function of this signature is used to copy the node data
1887 // when doing a deep-copy of a tree.
1888 // RETURNS: A pointer to the copy
1889 // <src>: A pointer to the data which should be copied
1890 // <data>: Additional data
1891 extern (C) alias void* function (const(void)* src, void* data) CopyFunc;
1893 enum int DATALIST_FLAGS_MASK = 3;
1894 enum int DATE_BAD_DAY = 0;
1895 enum int DATE_BAD_JULIAN = 0;
1896 enum int DATE_BAD_YEAR = 0;
1897 enum int DIR_SEPARATOR = 92;
1898 enum DIR_SEPARATOR_S = "\\";
1900 // The #GData struct is an opaque data structure to represent a <link
1901 // linkend="glib-Keyed-Data-Lists">Keyed Data List</link>. It should
1902 // only be accessed via the following functions.
1903 struct Data {
1907 // Specifies the type of function passed to g_dataset_foreach(). It is
1908 // called with each #GQuark id and associated data element, together
1909 // with the @user_data parameter supplied to g_dataset_foreach().
1910 // <key_id>: the #GQuark id to identifying the data element.
1911 // <data>: the data element.
1912 // <user_data>: user data passed to g_dataset_foreach().
1913 extern (C) alias void function (Quark key_id, void* data, void* user_data) DataForeachFunc;
1916 // Represents a day between January 1, Year 1 and a few thousand years in
1917 // the future. None of its members should be accessed directly. If the
1918 // <structname>GDate</structname> is obtained from g_date_new(), it will
1919 // be safe to mutate but invalid and thus not safe for calendrical
1920 // computations. If it's declared on the stack, it will contain garbage
1921 // so must be initialized with g_date_clear(). g_date_clear() makes the
1922 // date invalid but sane. An invalid date doesn't represent a day, it's
1923 // "empty." A date becomes valid after you set it to a Julian day or you
1924 // set a day, month, and year.
1925 struct Date {
1926 static import std.bitmanip; mixin(std.bitmanip.bitfields!(
1927 uint, "julian_days", 32,
1928 uint, "julian", 1,
1929 uint, "dmy", 1,
1930 uint, "day", 6,
1931 uint, "month", 4,
1932 uint, "year", 16,
1933 uint, "__dummy64A", 4));
1936 // Allocates a #GDate and initializes
1937 // it to a sane state. The new date will
1938 // be cleared (as if you'd called g_date_clear()) but invalid (it won't
1939 // represent an existing day). Free the return value with g_date_free().
1940 // RETURNS: a newly-allocated #GDate
1941 static Date* /*new*/ new_()() {
1942 return g_date_new();
1945 // Like g_date_new(), but also sets the value of the date. Assuming the
1946 // day-month-year triplet you pass in represents an existing day, the
1947 // returned date will be valid.
1948 // RETURNS: a newly-allocated #GDate initialized with @day, @month, and @year
1949 // <day>: day of the month
1950 // <month>: month of the year
1951 // <year>: year
1952 static Date* /*new*/ new_dmy()(DateDay day, DateMonth month, DateYear year) {
1953 return g_date_new_dmy(day, month, year);
1956 // Like g_date_new(), but also sets the value of the date. Assuming the
1957 // Julian day number you pass in is valid (greater than 0, less than an
1958 // unreasonably large number), the returned date will be valid.
1959 // RETURNS: a newly-allocated #GDate initialized with @julian_day
1960 // <julian_day>: days since January 1, Year 1
1961 static Date* /*new*/ new_julian()(uint julian_day) {
1962 return g_date_new_julian(julian_day);
1965 // Increments a date some number of days.
1966 // To move forward by weeks, add weeks*7 days.
1967 // The date must be valid.
1968 // <n_days>: number of days to move the date forward
1969 void add_days()(uint n_days) {
1970 g_date_add_days(&this, n_days);
1973 // Increments a date by some number of months.
1974 // If the day of the month is greater than 28,
1975 // this routine may change the day of the month
1976 // (because the destination month may not have
1977 // the current day in it). The date must be valid.
1978 // <n_months>: number of months to move forward
1979 void add_months()(uint n_months) {
1980 g_date_add_months(&this, n_months);
1983 // Increments a date by some number of years.
1984 // If the date is February 29, and the destination
1985 // year is not a leap year, the date will be changed
1986 // to February 28. The date must be valid.
1987 // <n_years>: number of years to move forward
1988 void add_years()(uint n_years) {
1989 g_date_add_years(&this, n_years);
1992 // If @date is prior to @min_date, sets @date equal to @min_date.
1993 // If @date falls after @max_date, sets @date equal to @max_date.
1994 // Otherwise, @date is unchanged.
1995 // Either of @min_date and @max_date may be %NULL.
1996 // All non-%NULL dates must be valid.
1997 // <min_date>: minimum accepted value for @date
1998 // <max_date>: maximum accepted value for @date
1999 void clamp()(Date* min_date, Date* max_date) {
2000 g_date_clamp(&this, min_date, max_date);
2003 // Initializes one or more #GDate structs to a sane but invalid
2004 // state. The cleared dates will not represent an existing date, but will
2005 // not contain garbage. Useful to init a date declared on the stack.
2006 // Validity can be tested with g_date_valid().
2007 // <n_dates>: number of dates to clear
2008 void clear()(uint n_dates) {
2009 g_date_clear(&this, n_dates);
2012 // qsort()-style comparsion function for dates.
2013 // Both dates must be valid.
2015 // greater than zero if @lhs is greater than @rhs
2016 // RETURNS: 0 for equal, less than zero if @lhs is less than @rhs,
2017 // <rhs>: second date to compare
2018 int compare()(Date* rhs) {
2019 return g_date_compare(&this, rhs);
2022 // Computes the number of days between two dates.
2023 // If @date2 is prior to @date1, the returned value is negative.
2024 // Both dates must be valid.
2025 // RETURNS: the number of days between @date1 and @date2
2026 // <date2>: the second date
2027 int days_between()(Date* date2) {
2028 return g_date_days_between(&this, date2);
2030 // Frees a #GDate returned from g_date_new().
2031 void free()() {
2032 g_date_free(&this);
2035 // Returns the day of the month. The date must be valid.
2036 // RETURNS: day of the month
2037 DateDay get_day()() {
2038 return g_date_get_day(&this);
2041 // Returns the day of the year, where Jan 1 is the first day of the
2042 // year. The date must be valid.
2043 // RETURNS: day of the year
2044 uint get_day_of_year()() {
2045 return g_date_get_day_of_year(&this);
2048 // VERSION: 2.6
2049 // Returns the week of the year, where weeks are interpreted according
2050 // to ISO 8601.
2051 // RETURNS: ISO 8601 week number of the year.
2052 uint get_iso8601_week_of_year()() {
2053 return g_date_get_iso8601_week_of_year(&this);
2056 // Returns the Julian day or "serial number" of the #GDate. The
2057 // Julian day is simply the number of days since January 1, Year 1; i.e.,
2058 // January 1, Year 1 is Julian day 1; January 2, Year 1 is Julian day 2,
2059 // etc. The date must be valid.
2060 // RETURNS: Julian day
2061 uint get_julian()() {
2062 return g_date_get_julian(&this);
2065 // Returns the week of the year, where weeks are understood to start on
2066 // Monday. If the date is before the first Monday of the year, return
2067 // 0. The date must be valid.
2068 // RETURNS: week of the year
2069 uint get_monday_week_of_year()() {
2070 return g_date_get_monday_week_of_year(&this);
2073 // Returns the month of the year. The date must be valid.
2074 // RETURNS: month of the year as a #GDateMonth
2075 DateMonth get_month()() {
2076 return g_date_get_month(&this);
2079 // Returns the week of the year during which this date falls, if weeks
2080 // are understood to being on Sunday. The date must be valid. Can return
2081 // 0 if the day is before the first Sunday of the year.
2082 // RETURNS: week number
2083 uint get_sunday_week_of_year()() {
2084 return g_date_get_sunday_week_of_year(&this);
2087 // Returns the day of the week for a #GDate. The date must be valid.
2088 // RETURNS: day of the week as a #GDateWeekday.
2089 DateWeekday get_weekday()() {
2090 return g_date_get_weekday(&this);
2093 // Returns the year of a #GDate. The date must be valid.
2094 // RETURNS: year in which the date falls
2095 DateYear get_year()() {
2096 return g_date_get_year(&this);
2099 // Returns %TRUE if the date is on the first of a month.
2100 // The date must be valid.
2101 // RETURNS: %TRUE if the date is the first of the month
2102 int is_first_of_month()() {
2103 return g_date_is_first_of_month(&this);
2106 // Returns %TRUE if the date is the last day of the month.
2107 // The date must be valid.
2108 // RETURNS: %TRUE if the date is the last day of the month
2109 int is_last_of_month()() {
2110 return g_date_is_last_of_month(&this);
2113 // Checks if @date1 is less than or equal to @date2,
2114 // and swap the values if this is not the case.
2115 // <date2>: the second date
2116 void order()(Date* date2) {
2117 g_date_order(&this, date2);
2120 // Sets the day of the month for a #GDate. If the resulting
2121 // day-month-year triplet is invalid, the date will be invalid.
2122 // <day>: day to set
2123 void set_day()(DateDay day) {
2124 g_date_set_day(&this, day);
2127 // Sets the value of a #GDate from a day, month, and year.
2128 // The day-month-year triplet must be valid; if you aren't
2129 // sure it is, call g_date_valid_dmy() to check before you
2130 // set it.
2131 // <day>: day
2132 // <month>: month
2133 // <y>: year
2134 void set_dmy()(DateDay day, DateMonth month, DateYear y) {
2135 g_date_set_dmy(&this, day, month, y);
2138 // Sets the value of a #GDate from a Julian day number.
2139 // <julian_date>: Julian day number (days since January 1, Year 1)
2140 void set_julian()(uint julian_date) {
2141 g_date_set_julian(&this, julian_date);
2144 // Sets the month of the year for a #GDate. If the resulting
2145 // day-month-year triplet is invalid, the date will be invalid.
2146 // <month>: month to set
2147 void set_month()(DateMonth month) {
2148 g_date_set_month(&this, month);
2151 // Parses a user-inputted string @str, and try to figure out what date it
2152 // represents, taking the <link linkend="setlocale">current locale</link>
2153 // into account. If the string is successfully parsed, the date will be
2154 // valid after the call. Otherwise, it will be invalid. You should check
2155 // using g_date_valid() to see whether the parsing succeeded.
2157 // This function is not appropriate for file formats and the like; it
2158 // isn't very precise, and its exact behavior varies with the locale.
2159 // It's intended to be a heuristic routine that guesses what the user
2160 // means by a given string (and it does work pretty well in that
2161 // capacity).
2162 // <str>: string to parse
2163 void set_parse()(char* str) {
2164 g_date_set_parse(&this, str);
2167 // DEPRECATED (v2.10) method: set_time - Use g_date_set_time_t() instead.
2168 // Sets the value of a date from a #GTime value.
2169 // The time to date conversion is done using the user's current timezone.
2170 // <time_>: #GTime value to set.
2171 void set_time()(Time time_) {
2172 g_date_set_time(&this, time_);
2175 // VERSION: 2.10
2176 // Sets the value of a date to the date corresponding to a time
2177 // specified as a time_t. The time to date conversion is done using
2178 // the user's current timezone.
2180 // To set the value of a date to the current day, you could write:
2181 // |[
2182 // g_date_set_time_t (date, time (NULL));
2183 // ]|
2184 // <timet>: <type>time_t</type> value to set
2185 void set_time_t()(time_t timet) {
2186 g_date_set_time_t(&this, timet);
2189 // VERSION: 2.10
2190 // Sets the value of a date from a #GTimeVal value. Note that the
2191 // @tv_usec member is ignored, because #GDate can't make use of the
2192 // additional precision.
2194 // The time to date conversion is done using the user's current timezone.
2195 // <timeval>: #GTimeVal value to set
2196 void set_time_val()(TimeVal* timeval) {
2197 g_date_set_time_val(&this, timeval);
2200 // Sets the year for a #GDate. If the resulting day-month-year
2201 // triplet is invalid, the date will be invalid.
2202 // <year>: year to set
2203 void set_year()(DateYear year) {
2204 g_date_set_year(&this, year);
2207 // Moves a date some number of days into the past.
2208 // To move by weeks, just move by weeks*7 days.
2209 // The date must be valid.
2210 // <n_days>: number of days to move
2211 void subtract_days()(uint n_days) {
2212 g_date_subtract_days(&this, n_days);
2215 // Moves a date some number of months into the past.
2216 // If the current day of the month doesn't exist in
2217 // the destination month, the day of the month
2218 // may change. The date must be valid.
2219 // <n_months>: number of months to move
2220 void subtract_months()(uint n_months) {
2221 g_date_subtract_months(&this, n_months);
2224 // Moves a date some number of years into the past.
2225 // If the current day doesn't exist in the destination
2226 // year (i.e. it's February 29 and you move to a non-leap-year)
2227 // then the day is changed to February 29. The date
2228 // must be valid.
2229 // <n_years>: number of years to move
2230 void subtract_years()(uint n_years) {
2231 g_date_subtract_years(&this, n_years);
2234 // Fills in the date-related bits of a <structname>struct tm</structname>
2235 // using the @date value. Initializes the non-date parts with something
2236 // sane but meaningless.
2237 // <tm>: <structname>struct tm</structname> to fill
2238 void to_struct_tm()(void** tm) {
2239 g_date_to_struct_tm(&this, tm);
2242 // Returns %TRUE if the #GDate represents an existing day. The date must not
2243 // contain garbage; it should have been initialized with g_date_clear()
2244 // if it wasn't allocated by one of the g_date_new() variants.
2245 // RETURNS: Whether the date is valid
2246 int valid()() {
2247 return g_date_valid(&this);
2250 // Returns the number of days in a month, taking leap
2251 // years into account.
2252 // RETURNS: number of days in @month during the @year
2253 // <month>: month
2254 // <year>: year
2255 static ubyte get_days_in_month()(DateMonth month, DateYear year) {
2256 return g_date_get_days_in_month(month, year);
2259 // Returns the number of weeks in the year, where weeks
2260 // are taken to start on Monday. Will be 52 or 53. The
2261 // date must be valid. (Years always have 52 7-day periods,
2262 // plus 1 or 2 extra days depending on whether it's a leap
2263 // year. This function is basically telling you how many
2264 // Mondays are in the year, i.e. there are 53 Mondays if
2265 // one of the extra days happens to be a Monday.)
2266 // RETURNS: number of Mondays in the year
2267 // <year>: a year
2268 static ubyte get_monday_weeks_in_year()(DateYear year) {
2269 return g_date_get_monday_weeks_in_year(year);
2272 // Returns the number of weeks in the year, where weeks
2273 // are taken to start on Sunday. Will be 52 or 53. The
2274 // date must be valid. (Years always have 52 7-day periods,
2275 // plus 1 or 2 extra days depending on whether it's a leap
2276 // year. This function is basically telling you how many
2277 // Sundays are in the year, i.e. there are 53 Sundays if
2278 // one of the extra days happens to be a Sunday.)
2279 // RETURNS: the number of weeks in @year
2280 // <year>: year to count weeks in
2281 static ubyte get_sunday_weeks_in_year()(DateYear year) {
2282 return g_date_get_sunday_weeks_in_year(year);
2285 // Returns %TRUE if the year is a leap year.
2286 // <footnote><para>For the purposes of this function,
2287 // leap year is every year divisible by 4 unless that year
2288 // is divisible by 100. If it is divisible by 100 it would
2289 // be a leap year only if that year is also divisible
2290 // by 400.</para></footnote>
2291 // RETURNS: %TRUE if the year is a leap year
2292 // <year>: year to check
2293 static int is_leap_year()(DateYear year) {
2294 return g_date_is_leap_year(year);
2297 // Generates a printed representation of the date, in a
2298 // <link linkend="setlocale">locale</link>-specific way.
2299 // Works just like the platform's C library strftime() function,
2300 // but only accepts date-related formats; time-related formats
2301 // give undefined results. Date must be valid. Unlike strftime()
2302 // (which uses the locale encoding), works on a UTF-8 format
2303 // string and stores a UTF-8 result.
2305 // This function does not provide any conversion specifiers in
2306 // addition to those implemented by the platform's C library.
2307 // For example, don't expect that using g_date_strftime() would
2308 // make the \%F provided by the C99 strftime() work on Windows
2309 // where the C library only complies to C89.
2310 // RETURNS: number of characters written to the buffer, or 0 the buffer was too small
2311 // <s>: destination buffer
2312 // <slen>: buffer size
2313 // <format>: format string
2314 // <date>: valid #GDate
2315 static size_t strftime()(char* s, size_t slen, char* format, Date* date) {
2316 return g_date_strftime(s, slen, format, date);
2319 // Returns %TRUE if the day of the month is valid (a day is valid if it's
2320 // between 1 and 31 inclusive).
2321 // RETURNS: %TRUE if the day is valid
2322 // <day>: day to check
2323 static int valid_day()(DateDay day) {
2324 return g_date_valid_day(day);
2327 // Returns %TRUE if the day-month-year triplet forms a valid, existing day
2328 // in the range of days #GDate understands (Year 1 or later, no more than
2329 // a few thousand years in the future).
2330 // RETURNS: %TRUE if the date is a valid one
2331 // <day>: day
2332 // <month>: month
2333 // <year>: year
2334 static int valid_dmy()(DateDay day, DateMonth month, DateYear year) {
2335 return g_date_valid_dmy(day, month, year);
2338 // Returns %TRUE if the Julian day is valid. Anything greater than zero
2339 // is basically a valid Julian, though there is a 32-bit limit.
2340 // RETURNS: %TRUE if the Julian day is valid
2341 // <julian_date>: Julian day to check
2342 static int valid_julian()(uint julian_date) {
2343 return g_date_valid_julian(julian_date);
2346 // Returns %TRUE if the month value is valid. The 12 #GDateMonth
2347 // enumeration values are the only valid months.
2348 // RETURNS: %TRUE if the month is valid
2349 // <month>: month
2350 static int valid_month()(DateMonth month) {
2351 return g_date_valid_month(month);
2354 // Returns %TRUE if the weekday is valid. The seven #GDateWeekday enumeration
2355 // values are the only valid weekdays.
2356 // RETURNS: %TRUE if the weekday is valid
2357 // <weekday>: weekday
2358 static int valid_weekday()(DateWeekday weekday) {
2359 return g_date_valid_weekday(weekday);
2362 // Returns %TRUE if the year is valid. Any year greater than 0 is valid,
2363 // though there is a 16-bit limit to what #GDate will understand.
2364 // RETURNS: %TRUE if the year is valid
2365 // <year>: year
2366 static int valid_year()(DateYear year) {
2367 return g_date_valid_year(year);
2372 // This enumeration isn't used in the API, but may be useful if you need
2373 // to mark a number as a day, month, or year.
2374 enum DateDMY {
2375 DAY = 0,
2376 MONTH = 1,
2377 YEAR = 2
2380 // Enumeration representing a month; values are #G_DATE_JANUARY,
2381 // #G_DATE_FEBRUARY, etc. #G_DATE_BAD_MONTH is the invalid value.
2382 enum DateMonth {
2383 BAD_MONTH = 0,
2384 JANUARY = 1,
2385 FEBRUARY = 2,
2386 MARCH = 3,
2387 APRIL = 4,
2388 MAY = 5,
2389 JUNE = 6,
2390 JULY = 7,
2391 AUGUST = 8,
2392 SEPTEMBER = 9,
2393 OCTOBER = 10,
2394 NOVEMBER = 11,
2395 DECEMBER = 12
2398 // <structname>GDateTime</structname> is an opaque structure whose members
2399 // cannot be accessed directly.
2400 struct DateTime /* Version 2.26 */ {
2402 // VERSION: 2.26
2403 // Creates a new #GDateTime corresponding to the given date and time in
2404 // the time zone @tz.
2406 // The @year must be between 1 and 9999, @month between 1 and 12 and @day
2407 // between 1 and 28, 29, 30 or 31 depending on the month and the year.
2409 // @hour must be between 0 and 23 and @minute must be between 0 and 59.
2411 // @seconds must be at least 0.0 and must be strictly less than 60.0.
2412 // It will be rounded down to the nearest microsecond.
2414 // If the given time is not representable in the given time zone (for
2415 // example, 02:30 on March 14th 2010 in Toronto, due to daylight savings
2416 // time) then the time will be rounded up to the nearest existing time
2417 // (in this case, 03:00). If this matters to you then you should verify
2418 // the return value for containing the same as the numbers you gave.
2420 // In the case that the given time is ambiguous in the given time zone
2421 // (for example, 01:30 on November 7th 2010 in Toronto, due to daylight
2422 // savings time) then the time falling within standard (ie:
2423 // non-daylight) time is taken.
2425 // It not considered a programmer error for the values to this function
2426 // to be out of range, but in the case that they are, the function will
2427 // return %NULL.
2429 // You should release the return value by calling g_date_time_unref()
2430 // when you are done with it.
2431 // RETURNS: a new #GDateTime, or %NULL
2432 // <tz>: a #GTimeZone
2433 // <year>: the year component of the date
2434 // <month>: the month component of the date
2435 // <day>: the day component of the date
2436 // <hour>: the hour component of the date
2437 // <minute>: the minute component of the date
2438 // <seconds>: the number of seconds past the minute
2439 static DateTime* /*new*/ new_()(TimeZone* tz, int year, int month, int day, int hour, int minute, double seconds) {
2440 return g_date_time_new(tz, year, month, day, hour, minute, seconds);
2443 // VERSION: 2.26
2444 // Creates a #GDateTime corresponding to the given #GTimeVal @tv in the
2445 // local time zone.
2447 // The time contained in a #GTimeVal is always stored in the form of
2448 // seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the
2449 // local time offset.
2451 // This call can fail (returning %NULL) if @tv represents a time outside
2452 // of the supported range of #GDateTime.
2454 // You should release the return value by calling g_date_time_unref()
2455 // when you are done with it.
2456 // RETURNS: a new #GDateTime, or %NULL
2457 // <tv>: a #GTimeVal
2458 static DateTime* /*new*/ new_from_timeval_local()(TimeVal* tv) {
2459 return g_date_time_new_from_timeval_local(tv);
2462 // VERSION: 2.26
2463 // Creates a #GDateTime corresponding to the given #GTimeVal @tv in UTC.
2465 // The time contained in a #GTimeVal is always stored in the form of
2466 // seconds elapsed since 1970-01-01 00:00:00 UTC.
2468 // This call can fail (returning %NULL) if @tv represents a time outside
2469 // of the supported range of #GDateTime.
2471 // You should release the return value by calling g_date_time_unref()
2472 // when you are done with it.
2473 // RETURNS: a new #GDateTime, or %NULL
2474 // <tv>: a #GTimeVal
2475 static DateTime* /*new*/ new_from_timeval_utc()(TimeVal* tv) {
2476 return g_date_time_new_from_timeval_utc(tv);
2479 // VERSION: 2.26
2480 // Creates a #GDateTime corresponding to the given Unix time @t in the
2481 // local time zone.
2483 // Unix time is the number of seconds that have elapsed since 1970-01-01
2484 // 00:00:00 UTC, regardless of the local time offset.
2486 // This call can fail (returning %NULL) if @t represents a time outside
2487 // of the supported range of #GDateTime.
2489 // You should release the return value by calling g_date_time_unref()
2490 // when you are done with it.
2491 // RETURNS: a new #GDateTime, or %NULL
2492 // <t>: the Unix time
2493 static DateTime* /*new*/ new_from_unix_local()(long t) {
2494 return g_date_time_new_from_unix_local(t);
2497 // VERSION: 2.26
2498 // Creates a #GDateTime corresponding to the given Unix time @t in UTC.
2500 // Unix time is the number of seconds that have elapsed since 1970-01-01
2501 // 00:00:00 UTC.
2503 // This call can fail (returning %NULL) if @t represents a time outside
2504 // of the supported range of #GDateTime.
2506 // You should release the return value by calling g_date_time_unref()
2507 // when you are done with it.
2508 // RETURNS: a new #GDateTime, or %NULL
2509 // <t>: the Unix time
2510 static DateTime* /*new*/ new_from_unix_utc()(long t) {
2511 return g_date_time_new_from_unix_utc(t);
2514 // VERSION: 2.26.
2515 // Creates a new #GDateTime corresponding to the given date and time in
2516 // the local time zone.
2518 // This call is equivalent to calling g_date_time_new() with the time
2519 // zone returned by g_time_zone_new_local().
2520 // RETURNS: a #GDateTime, or %NULL
2521 // <year>: the year component of the date
2522 // <month>: the month component of the date
2523 // <day>: the day component of the date
2524 // <hour>: the hour component of the date
2525 // <minute>: the minute component of the date
2526 // <seconds>: the number of seconds past the minute
2527 static DateTime* /*new*/ new_local()(int year, int month, int day, int hour, int minute, double seconds) {
2528 return g_date_time_new_local(year, month, day, hour, minute, seconds);
2531 // VERSION: 2.26
2532 // Creates a #GDateTime corresponding to this exact instant in the given
2533 // time zone @tz. The time is as accurate as the system allows, to a
2534 // maximum accuracy of 1 microsecond.
2536 // This function will always succeed unless the system clock is set to
2537 // truly insane values (or unless GLib is still being used after the
2538 // year 9999).
2540 // You should release the return value by calling g_date_time_unref()
2541 // when you are done with it.
2542 // RETURNS: a new #GDateTime, or %NULL
2543 // <tz>: a #GTimeZone
2544 static DateTime* /*new*/ new_now()(TimeZone* tz) {
2545 return g_date_time_new_now(tz);
2548 // VERSION: 2.26
2549 // Creates a #GDateTime corresponding to this exact instant in the local
2550 // time zone.
2552 // This is equivalent to calling g_date_time_new_now() with the time
2553 // zone returned by g_time_zone_new_local().
2554 // RETURNS: a new #GDateTime, or %NULL
2555 static DateTime* /*new*/ new_now_local()() {
2556 return g_date_time_new_now_local();
2559 // VERSION: 2.26
2560 // Creates a #GDateTime corresponding to this exact instant in UTC.
2562 // This is equivalent to calling g_date_time_new_now() with the time
2563 // zone returned by g_time_zone_new_utc().
2564 // RETURNS: a new #GDateTime, or %NULL
2565 static DateTime* /*new*/ new_now_utc()() {
2566 return g_date_time_new_now_utc();
2569 // VERSION: 2.26.
2570 // Creates a new #GDateTime corresponding to the given date and time in
2571 // UTC.
2573 // This call is equivalent to calling g_date_time_new() with the time
2574 // zone returned by g_time_zone_new_utc().
2575 // RETURNS: a #GDateTime, or %NULL
2576 // <year>: the year component of the date
2577 // <month>: the month component of the date
2578 // <day>: the day component of the date
2579 // <hour>: the hour component of the date
2580 // <minute>: the minute component of the date
2581 // <seconds>: the number of seconds past the minute
2582 static DateTime* /*new*/ new_utc()(int year, int month, int day, int hour, int minute, double seconds) {
2583 return g_date_time_new_utc(year, month, day, hour, minute, seconds);
2586 // VERSION: 2.26
2587 // Creates a copy of @datetime and adds the specified timespan to the copy.
2589 // g_date_time_unref().
2590 // RETURNS: the newly created #GDateTime which should be freed with
2591 // <timespan>: a #GTimeSpan
2592 DateTime* /*new*/ add()(TimeSpan timespan) {
2593 return g_date_time_add(&this, timespan);
2596 // VERSION: 2.26
2597 // Creates a copy of @datetime and adds the specified number of days to the
2598 // copy.
2600 // g_date_time_unref().
2601 // RETURNS: the newly created #GDateTime which should be freed with
2602 // <days>: the number of days
2603 DateTime* /*new*/ add_days()(int days) {
2604 return g_date_time_add_days(&this, days);
2607 // VERSION: 2.26
2608 // Creates a new #GDateTime adding the specified values to the current date and
2609 // time in @datetime.
2611 // g_date_time_unref().
2612 // RETURNS: the newly created #GDateTime that should be freed with
2613 // <years>: the number of years to add
2614 // <months>: the number of months to add
2615 // <days>: the number of days to add
2616 // <hours>: the number of hours to add
2617 // <minutes>: the number of minutes to add
2618 // <seconds>: the number of seconds to add
2619 DateTime* /*new*/ add_full()(int years, int months, int days, int hours, int minutes, double seconds) {
2620 return g_date_time_add_full(&this, years, months, days, hours, minutes, seconds);
2623 // VERSION: 2.26
2624 // Creates a copy of @datetime and adds the specified number of hours
2626 // g_date_time_unref().
2627 // RETURNS: the newly created #GDateTime which should be freed with
2628 // <hours>: the number of hours to add
2629 DateTime* /*new*/ add_hours()(int hours) {
2630 return g_date_time_add_hours(&this, hours);
2633 // VERSION: 2.26
2634 // Creates a copy of @datetime adding the specified number of minutes.
2636 // g_date_time_unref().
2637 // RETURNS: the newly created #GDateTime which should be freed with
2638 // <minutes>: the number of minutes to add
2639 DateTime* /*new*/ add_minutes()(int minutes) {
2640 return g_date_time_add_minutes(&this, minutes);
2643 // VERSION: 2.26
2644 // Creates a copy of @datetime and adds the specified number of months to the
2645 // copy.
2647 // g_date_time_unref().
2648 // RETURNS: the newly created #GDateTime which should be freed with
2649 // <months>: the number of months
2650 DateTime* /*new*/ add_months()(int months) {
2651 return g_date_time_add_months(&this, months);
2654 // VERSION: 2.26
2655 // Creates a copy of @datetime and adds the specified number of seconds.
2657 // g_date_time_unref().
2658 // RETURNS: the newly created #GDateTime which should be freed with
2659 // <seconds>: the number of seconds to add
2660 DateTime* /*new*/ add_seconds()(double seconds) {
2661 return g_date_time_add_seconds(&this, seconds);
2664 // VERSION: 2.26
2665 // Creates a copy of @datetime and adds the specified number of weeks to the
2666 // copy.
2668 // g_date_time_unref().
2669 // RETURNS: the newly created #GDateTime which should be freed with
2670 // <weeks>: the number of weeks
2671 DateTime* /*new*/ add_weeks()(int weeks) {
2672 return g_date_time_add_weeks(&this, weeks);
2675 // VERSION: 2.26
2676 // Creates a copy of @datetime and adds the specified number of years to the
2677 // copy.
2679 // g_date_time_unref().
2680 // RETURNS: the newly created #GDateTime which should be freed with
2681 // <years>: the number of years
2682 DateTime* /*new*/ add_years()(int years) {
2683 return g_date_time_add_years(&this, years);
2686 // VERSION: 2.26
2687 // Calculates the difference in time between @end and @begin. The
2688 // #GTimeSpan that is returned is effectively @end - @begin (ie:
2689 // positive if the first simparameter is larger).
2691 // span expressed in microseconds.
2692 // RETURNS: the difference between the two #GDateTime, as a time
2693 // <begin>: a #GDateTime
2694 TimeSpan difference()(DateTime* begin) {
2695 return g_date_time_difference(&this, begin);
2698 // VERSION: 2.26
2699 // Creates a newly allocated string representing the requested @format.
2701 // The format strings understood by this function are a subset of the
2702 // strftime() format language as specified by C99. The \%D, \%U and \%W
2703 // conversions are not supported, nor is the 'E' modifier. The GNU
2704 // extensions \%k, \%l, \%s and \%P are supported, however, as are the
2705 // '0', '_' and '-' modifiers.
2707 // In contrast to strftime(), this function always produces a UTF-8
2708 // string, regardless of the current locale. Note that the rendering of
2709 // many formats is locale-dependent and may not match the strftime()
2710 // output exactly.
2712 // The following format specifiers are supported:
2714 // <variablelist>
2715 // <varlistentry><term>
2716 // <literal>\%a</literal>:
2717 // </term><listitem><simpara>
2718 // the abbreviated weekday name according to the current locale
2719 // </simpara></listitem></varlistentry>
2720 // <varlistentry><term>
2721 // <literal>\%A</literal>:
2722 // </term><listitem><simpara>
2723 // the full weekday name according to the current locale
2724 // </simpara></listitem></varlistentry>
2725 // <varlistentry><term>
2726 // <literal>\%b</literal>:
2727 // </term><listitem><simpara>
2728 // the abbreviated month name according to the current locale
2729 // </simpara></listitem></varlistentry>
2730 // <varlistentry><term>
2731 // <literal>\%B</literal>:
2732 // </term><listitem><simpara>
2733 // the full month name according to the current locale
2734 // </simpara></listitem></varlistentry>
2735 // <varlistentry><term>
2736 // <literal>\%c</literal>:
2737 // </term><listitem><simpara>
2738 // the preferred date and time representation for the current locale
2739 // </simpara></listitem></varlistentry>
2740 // <varlistentry><term>
2741 // <literal>\%C</literal>:
2742 // </term><listitem><simpara>
2743 // The century number (year/100) as a 2-digit integer (00-99)
2744 // </simpara></listitem></varlistentry>
2745 // <varlistentry><term>
2746 // <literal>\%d</literal>:
2747 // </term><listitem><simpara>
2748 // the day of the month as a decimal number (range 01 to 31)
2749 // </simpara></listitem></varlistentry>
2750 // <varlistentry><term>
2751 // <literal>\%e</literal>:
2752 // </term><listitem><simpara>
2753 // the day of the month as a decimal number (range 1 to 31)
2754 // </simpara></listitem></varlistentry>
2755 // <varlistentry><term>
2756 // <literal>\%F</literal>:
2757 // </term><listitem><simpara>
2758 // equivalent to <literal>\%Y-\%m-\%d</literal> (the ISO 8601 date
2759 // format)
2760 // </simpara></listitem></varlistentry>
2761 // <varlistentry><term>
2762 // <literal>\%g</literal>:
2763 // </term><listitem><simpara>
2764 // the last two digits of the ISO 8601 week-based year as a decimal
2765 // number (00-99). This works well with \%V and \%u.
2766 // </simpara></listitem></varlistentry>
2767 // <varlistentry><term>
2768 // <literal>\%G</literal>:
2769 // </term><listitem><simpara>
2770 // the ISO 8601 week-based year as a decimal number. This works well
2771 // with \%V and \%u.
2772 // </simpara></listitem></varlistentry>
2773 // <varlistentry><term>
2774 // <literal>\%h</literal>:
2775 // </term><listitem><simpara>
2776 // equivalent to <literal>\%b</literal>
2777 // </simpara></listitem></varlistentry>
2778 // <varlistentry><term>
2779 // <literal>\%H</literal>:
2780 // </term><listitem><simpara>
2781 // the hour as a decimal number using a 24-hour clock (range 00 to
2782 // 23)
2783 // </simpara></listitem></varlistentry>
2784 // <varlistentry><term>
2785 // <literal>\%I</literal>:
2786 // </term><listitem><simpara>
2787 // the hour as a decimal number using a 12-hour clock (range 01 to
2788 // 12)
2789 // </simpara></listitem></varlistentry>
2790 // <varlistentry><term>
2791 // <literal>\%j</literal>:
2792 // </term><listitem><simpara>
2793 // the day of the year as a decimal number (range 001 to 366)
2794 // </simpara></listitem></varlistentry>
2795 // <varlistentry><term>
2796 // <literal>\%k</literal>:
2797 // </term><listitem><simpara>
2798 // the hour (24-hour clock) as a decimal number (range 0 to 23);
2799 // single digits are preceded by a blank
2800 // </simpara></listitem></varlistentry>
2801 // <varlistentry><term>
2802 // <literal>\%l</literal>:
2803 // </term><listitem><simpara>
2804 // the hour (12-hour clock) as a decimal number (range 1 to 12);
2805 // single digits are preceded by a blank
2806 // </simpara></listitem></varlistentry>
2807 // <varlistentry><term>
2808 // <literal>\%m</literal>:
2809 // </term><listitem><simpara>
2810 // the month as a decimal number (range 01 to 12)
2811 // </simpara></listitem></varlistentry>
2812 // <varlistentry><term>
2813 // <literal>\%M</literal>:
2814 // </term><listitem><simpara>
2815 // the minute as a decimal number (range 00 to 59)
2816 // </simpara></listitem></varlistentry>
2817 // <varlistentry><term>
2818 // <literal>\%p</literal>:
2819 // </term><listitem><simpara>
2820 // either "AM" or "PM" according to the given time value, or the
2821 // corresponding strings for the current locale. Noon is treated as
2822 // "PM" and midnight as "AM".
2823 // </simpara></listitem></varlistentry>
2824 // <varlistentry><term>
2825 // <literal>\%P</literal>:
2826 // </term><listitem><simpara>
2827 // like \%p but lowercase: "am" or "pm" or a corresponding string for
2828 // the current locale
2829 // </simpara></listitem></varlistentry>
2830 // <varlistentry><term>
2831 // <literal>\%r</literal>:
2832 // </term><listitem><simpara>
2833 // the time in a.m. or p.m. notation
2834 // </simpara></listitem></varlistentry>
2835 // <varlistentry><term>
2836 // <literal>\%R</literal>:
2837 // </term><listitem><simpara>
2838 // the time in 24-hour notation (<literal>\%H:\%M</literal>)
2839 // </simpara></listitem></varlistentry>
2840 // <varlistentry><term>
2841 // <literal>\%s</literal>:
2842 // </term><listitem><simpara>
2843 // the number of seconds since the Epoch, that is, since 1970-01-01
2844 // 00:00:00 UTC
2845 // </simpara></listitem></varlistentry>
2846 // <varlistentry><term>
2847 // <literal>\%S</literal>:
2848 // </term><listitem><simpara>
2849 // the second as a decimal number (range 00 to 60)
2850 // </simpara></listitem></varlistentry>
2851 // <varlistentry><term>
2852 // <literal>\%t</literal>:
2853 // </term><listitem><simpara>
2854 // a tab character
2855 // </simpara></listitem></varlistentry>
2856 // <varlistentry><term>
2857 // <literal>\%T</literal>:
2858 // </term><listitem><simpara>
2859 // the time in 24-hour notation with seconds (<literal>\%H:\%M:\%S</literal>)
2860 // </simpara></listitem></varlistentry>
2861 // <varlistentry><term>
2862 // <literal>\%u</literal>:
2863 // </term><listitem><simpara>
2864 // the ISO 8601 standard day of the week as a decimal, range 1 to 7,
2865 // Monday being 1. This works well with \%G and \%V.
2866 // </simpara></listitem></varlistentry>
2867 // <varlistentry><term>
2868 // <literal>\%V</literal>:
2869 // </term><listitem><simpara>
2870 // the ISO 8601 standard week number of the current year as a decimal
2871 // number, range 01 to 53, where week 1 is the first week that has at
2872 // least 4 days in the new year. See g_date_time_get_week_of_year().
2873 // This works well with \%G and \%u.
2874 // </simpara></listitem></varlistentry>
2875 // <varlistentry><term>
2876 // <literal>\%w</literal>:
2877 // </term><listitem><simpara>
2878 // the day of the week as a decimal, range 0 to 6, Sunday being 0.
2879 // This is not the ISO 8601 standard format -- use \%u instead.
2880 // </simpara></listitem></varlistentry>
2881 // <varlistentry><term>
2882 // <literal>\%x</literal>:
2883 // </term><listitem><simpara>
2884 // the preferred date representation for the current locale without
2885 // the time
2886 // </simpara></listitem></varlistentry>
2887 // <varlistentry><term>
2888 // <literal>\%X</literal>:
2889 // </term><listitem><simpara>
2890 // the preferred time representation for the current locale without
2891 // the date
2892 // </simpara></listitem></varlistentry>
2893 // <varlistentry><term>
2894 // <literal>\%y</literal>:
2895 // </term><listitem><simpara>
2896 // the year as a decimal number without the century
2897 // </simpara></listitem></varlistentry>
2898 // <varlistentry><term>
2899 // <literal>\%Y</literal>:
2900 // </term><listitem><simpara>
2901 // the year as a decimal number including the century
2902 // </simpara></listitem></varlistentry>
2903 // <varlistentry><term>
2904 // <literal>\%z</literal>:
2905 // </term><listitem><simpara>
2906 // the time-zone as hour offset from UTC
2907 // </simpara></listitem></varlistentry>
2908 // <varlistentry><term>
2909 // <literal>\%Z</literal>:
2910 // </term><listitem><simpara>
2911 // the time zone or name or abbreviation
2912 // </simpara></listitem></varlistentry>
2913 // <varlistentry><term>
2914 // <literal>\%\%</literal>:
2915 // </term><listitem><simpara>
2916 // a literal <literal>\%</literal> character
2917 // </simpara></listitem></varlistentry>
2918 // </variablelist>
2920 // Some conversion specifications can be modified by preceding the
2921 // conversion specifier by one or more modifier characters. The
2922 // following modifiers are supported for many of the numeric
2923 // conversions:
2924 // <variablelist>
2925 // <varlistentry>
2926 // <term>O</term>
2927 // <listitem>
2928 // Use alternative numeric symbols, if the current locale
2929 // supports those.
2930 // </listitem>
2931 // </varlistentry>
2932 // <varlistentry>
2933 // <term>_</term>
2934 // <listitem>
2935 // Pad a numeric result with spaces.
2936 // This overrides the default padding for the specifier.
2937 // </listitem>
2938 // </varlistentry>
2939 // <varlistentry>
2940 // <term>-</term>
2941 // <listitem>
2942 // Do not pad a numeric result.
2943 // This overrides the default padding for the specifier.
2944 // </listitem>
2945 // </varlistentry>
2946 // <varlistentry>
2947 // <term>0</term>
2948 // <listitem>
2949 // Pad a numeric result with zeros.
2950 // This overrides the default padding for the specifier.
2951 // </listitem>
2952 // </varlistentry>
2953 // </variablelist>
2955 // or %NULL in the case that there was an error. The string
2956 // should be freed with g_free().
2957 // RETURNS: a newly allocated string formatted to the requested format
2958 // <format>: a valid UTF-8 string, containing the format for the #GDateTime
2959 char* /*new*/ format()(char* format) {
2960 return g_date_time_format(&this, format);
2963 // VERSION: 2.26
2964 // Retrieves the day of the month represented by @datetime in the gregorian
2965 // calendar.
2966 // RETURNS: the day of the month
2967 int get_day_of_month()() {
2968 return g_date_time_get_day_of_month(&this);
2971 // VERSION: 2.26
2972 // Retrieves the ISO 8601 day of the week on which @datetime falls (1 is
2973 // Monday, 2 is Tuesday... 7 is Sunday).
2974 // RETURNS: the day of the week
2975 int get_day_of_week()() {
2976 return g_date_time_get_day_of_week(&this);
2979 // VERSION: 2.26
2980 // Retrieves the day of the year represented by @datetime in the Gregorian
2981 // calendar.
2982 // RETURNS: the day of the year
2983 int get_day_of_year()() {
2984 return g_date_time_get_day_of_year(&this);
2987 // VERSION: 2.26
2988 // Retrieves the hour of the day represented by @datetime
2989 // RETURNS: the hour of the day
2990 int get_hour()() {
2991 return g_date_time_get_hour(&this);
2994 // VERSION: 2.26
2995 // Retrieves the microsecond of the date represented by @datetime
2996 // RETURNS: the microsecond of the second
2997 int get_microsecond()() {
2998 return g_date_time_get_microsecond(&this);
3001 // VERSION: 2.26
3002 // Retrieves the minute of the hour represented by @datetime
3003 // RETURNS: the minute of the hour
3004 int get_minute()() {
3005 return g_date_time_get_minute(&this);
3008 // VERSION: 2.26
3009 // Retrieves the month of the year represented by @datetime in the Gregorian
3010 // calendar.
3011 // RETURNS: the month represented by @datetime
3012 int get_month()() {
3013 return g_date_time_get_month(&this);
3016 // VERSION: 2.26
3017 // Retrieves the second of the minute represented by @datetime
3018 // RETURNS: the second represented by @datetime
3019 int get_second()() {
3020 return g_date_time_get_second(&this);
3023 // VERSION: 2.26
3024 // Retrieves the number of seconds since the start of the last minute,
3025 // including the fractional part.
3026 // RETURNS: the number of seconds
3027 double get_seconds()() {
3028 return g_date_time_get_seconds(&this);
3031 // VERSION: 2.26
3032 // Determines the time zone abbreviation to be used at the time and in
3033 // the time zone of @datetime.
3035 // For example, in Toronto this is currently "EST" during the winter
3036 // months and "EDT" during the summer months when daylight savings
3037 // time is in effect.
3039 // string is owned by the #GDateTime and it should not be
3040 // modified or freed
3041 // RETURNS: the time zone abbreviation. The returned
3042 char* get_timezone_abbreviation()() {
3043 return g_date_time_get_timezone_abbreviation(&this);
3046 // VERSION: 2.26
3047 // Determines the offset to UTC in effect at the time and in the time
3048 // zone of @datetime.
3050 // The offset is the number of microseconds that you add to UTC time to
3051 // arrive at local time for the time zone (ie: negative numbers for time
3052 // zones west of GMT, positive numbers for east).
3054 // If @datetime represents UTC time, then the offset is always zero.
3056 // get the local time
3057 // RETURNS: the number of microseconds that should be added to UTC to
3058 TimeSpan get_utc_offset()() {
3059 return g_date_time_get_utc_offset(&this);
3062 // VERSION: 2.26
3063 // Returns the ISO 8601 week-numbering year in which the week containing
3064 // @datetime falls.
3066 // This function, taken together with g_date_time_get_week_of_year() and
3067 // g_date_time_get_day_of_week() can be used to determine the full ISO
3068 // week date on which @datetime falls.
3070 // This is usually equal to the normal Gregorian year (as returned by
3071 // g_date_time_get_year()), except as detailed below:
3073 // For Thursday, the week-numbering year is always equal to the usual
3074 // calendar year. For other days, the number is such that every day
3075 // within a complete week (Monday to Sunday) is contained within the
3076 // same week-numbering year.
3078 // For Monday, Tuesday and Wednesday occurring near the end of the year,
3079 // this may mean that the week-numbering year is one greater than the
3080 // calendar year (so that these days have the same week-numbering year
3081 // as the Thursday occurring early in the next year).
3083 // For Friday, Saturaday and Sunday occurring near the start of the year,
3084 // this may mean that the week-numbering year is one less than the
3085 // calendar year (so that these days have the same week-numbering year
3086 // as the Thursday occurring late in the previous year).
3088 // An equivalent description is that the week-numbering year is equal to
3089 // the calendar year containing the majority of the days in the current
3090 // week (Monday to Sunday).
3092 // Note that January 1 0001 in the proleptic Gregorian calendar is a
3093 // Monday, so this function never returns 0.
3094 // RETURNS: the ISO 8601 week-numbering year for @datetime
3095 int get_week_numbering_year()() {
3096 return g_date_time_get_week_numbering_year(&this);
3099 // VERSION: 2.26
3100 // Returns the ISO 8601 week number for the week containing @datetime.
3101 // The ISO 8601 week number is the same for every day of the week (from
3102 // Moday through Sunday). That can produce some unusual results
3103 // (described below).
3105 // The first week of the year is week 1. This is the week that contains
3106 // the first Thursday of the year. Equivalently, this is the first week
3107 // that has more than 4 of its days falling within the calendar year.
3109 // The value 0 is never returned by this function. Days contained
3110 // within a year but occurring before the first ISO 8601 week of that
3111 // year are considered as being contained in the last week of the
3112 // previous year. Similarly, the final days of a calendar year may be
3113 // considered as being part of the first ISO 8601 week of the next year
3114 // if 4 or more days of that week are contained within the new year.
3115 // RETURNS: the ISO 8601 week number for @datetime.
3116 int get_week_of_year()() {
3117 return g_date_time_get_week_of_year(&this);
3120 // VERSION: 2.26
3121 // Retrieves the year represented by @datetime in the Gregorian calendar.
3122 // RETURNS: the year represented by @datetime
3123 int get_year()() {
3124 return g_date_time_get_year(&this);
3127 // VERSION: 2.26
3128 // Retrieves the Gregorian day, month, and year of a given #GDateTime.
3129 // <year>: the return location for the gregorian year, or %NULL.
3130 // <month>: the return location for the month of the year, or %NULL.
3131 // <day>: the return location for the day of the month, or %NULL.
3132 void get_ymd()(/*out*/ int* year, /*out*/ int* month, /*out*/ int* day) {
3133 g_date_time_get_ymd(&this, year, month, day);
3136 // VERSION: 2.26
3137 // Determines if daylight savings time is in effect at the time and in
3138 // the time zone of @datetime.
3139 // RETURNS: %TRUE if daylight savings time is in effect
3140 int is_daylight_savings()() {
3141 return g_date_time_is_daylight_savings(&this);
3144 // VERSION: 2.26
3145 // Atomically increments the reference count of @datetime by one.
3146 // RETURNS: the #GDateTime with the reference count increased
3147 DateTime* /*new*/ ref_()() {
3148 return g_date_time_ref(&this);
3151 // VERSION: 2.26
3152 // Creates a new #GDateTime corresponding to the same instant in time as
3153 // @datetime, but in the local time zone.
3155 // This call is equivalent to calling g_date_time_to_timezone() with the
3156 // time zone returned by g_time_zone_new_local().
3157 // RETURNS: the newly created #GDateTime
3158 DateTime* /*new*/ to_local()() {
3159 return g_date_time_to_local(&this);
3162 // VERSION: 2.26
3163 // Stores the instant in time that @datetime represents into @tv.
3165 // The time contained in a #GTimeVal is always stored in the form of
3166 // seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the time
3167 // zone associated with @datetime.
3169 // On systems where 'long' is 32bit (ie: all 32bit systems and all
3170 // Windows systems), a #GTimeVal is incapable of storing the entire
3171 // range of values that #GDateTime is capable of expressing. On those
3172 // systems, this function returns %FALSE to indicate that the time is
3173 // out of range.
3175 // On systems where 'long' is 64bit, this function never fails.
3176 // RETURNS: %TRUE if successful, else %FALSE
3177 // <tv>: a #GTimeVal to modify
3178 int to_timeval()(TimeVal* tv) {
3179 return g_date_time_to_timeval(&this, tv);
3182 // VERSION: 2.26
3183 // Create a new #GDateTime corresponding to the same instant in time as
3184 // @datetime, but in the time zone @tz.
3186 // This call can fail in the case that the time goes out of bounds. For
3187 // example, converting 0001-01-01 00:00:00 UTC to a time zone west of
3188 // Greenwich will fail (due to the year 0 being out of range).
3190 // You should release the return value by calling g_date_time_unref()
3191 // when you are done with it.
3192 // RETURNS: a new #GDateTime, or %NULL
3193 // <tz>: the new #GTimeZone
3194 DateTime* /*new*/ to_timezone()(TimeZone* tz) {
3195 return g_date_time_to_timezone(&this, tz);
3198 // VERSION: 2.26
3199 // Gives the Unix time corresponding to @datetime, rounding down to the
3200 // nearest second.
3202 // Unix time is the number of seconds that have elapsed since 1970-01-01
3203 // 00:00:00 UTC, regardless of the time zone associated with @datetime.
3204 // RETURNS: the Unix time corresponding to @datetime
3205 long to_unix()() {
3206 return g_date_time_to_unix(&this);
3209 // VERSION: 2.26
3210 // Creates a new #GDateTime corresponding to the same instant in time as
3211 // @datetime, but in UTC.
3213 // This call is equivalent to calling g_date_time_to_timezone() with the
3214 // time zone returned by g_time_zone_new_utc().
3215 // RETURNS: the newly created #GDateTime
3216 DateTime* /*new*/ to_utc()() {
3217 return g_date_time_to_utc(&this);
3220 // VERSION: 2.26
3221 // Atomically decrements the reference count of @datetime by one.
3223 // When the reference count reaches zero, the resources allocated by
3224 // @datetime are freed
3225 void unref()() {
3226 g_date_time_unref(&this);
3229 // VERSION: 2.26
3230 // A comparison function for #GDateTimes that is suitable
3231 // as a #GCompareFunc. Both #GDateTimes must be non-%NULL.
3233 // than @dt2.
3234 // RETURNS: -1, 0 or 1 if @dt1 is less than, equal to or greater
3235 // <dt1>: first #GDateTime to compare
3236 // <dt2>: second #GDateTime to compare
3237 static int compare()(const(void)* dt1, const(void)* dt2) {
3238 return g_date_time_compare(dt1, dt2);
3241 // VERSION: 2.26
3242 // Checks to see if @dt1 and @dt2 are equal.
3244 // Equal here means that they represent the same moment after converting
3245 // them to the same time zone.
3246 // RETURNS: %TRUE if @dt1 and @dt2 are equal
3247 // <dt1>: a #GDateTime
3248 // <dt2>: a #GDateTime
3249 static int equal()(const(void)* dt1, const(void)* dt2) {
3250 return g_date_time_equal(dt1, dt2);
3253 // VERSION: 2.26
3254 // Hashes @datetime into a #guint, suitable for use within #GHashTable.
3255 // RETURNS: a #guint containing the hash
3256 // <datetime>: a #GDateTime
3257 static uint hash()(const(void)* datetime) {
3258 return g_date_time_hash(datetime);
3263 // Enumeration representing a day of the week; #G_DATE_MONDAY,
3264 // #G_DATE_TUESDAY, etc. #G_DATE_BAD_WEEKDAY is an invalid weekday.
3265 enum DateWeekday {
3266 BAD_WEEKDAY = 0,
3267 MONDAY = 1,
3268 TUESDAY = 2,
3269 WEDNESDAY = 3,
3270 THURSDAY = 4,
3271 FRIDAY = 5,
3272 SATURDAY = 6,
3273 SUNDAY = 7
3276 // Associates a string with a bit flag.
3277 // Used in g_parse_debug_string().
3278 struct DebugKey {
3279 char* key;
3280 uint value;
3284 // Specifies the type of function which is called when a data element
3285 // is destroyed. It is passed the pointer to the data element and
3286 // should free any memory and resources allocated for it.
3287 // <data>: the data element.
3288 extern (C) alias void function (void* data) DestroyNotify;
3290 // An opaque structure representing an opened directory.
3291 struct Dir {
3292 // Closes the directory and deallocates all related resources.
3293 void close()() {
3294 g_dir_close(&this);
3297 // Retrieves the name of another entry in the directory, or %NULL.
3298 // The order of entries returned from this function is not defined,
3299 // and may vary by file system or other operating-system dependent
3300 // factors.
3302 // On Unix, the '.' and '..' entries are omitted, and the returned
3303 // name is in the on-disk encoding.
3305 // On Windows, as is true of all GLib functions which operate on
3306 // filenames, the returned name is in UTF-8.
3308 // more entries. The return value is owned by GLib and
3309 // must not be modified or freed.
3310 // RETURNS: The entry's name or %NULL if there are no
3311 char* read_name()() {
3312 return g_dir_read_name(&this);
3315 // Resets the given directory. The next call to g_dir_read_name()
3316 // will return the first entry again.
3317 void rewind()() {
3318 g_dir_rewind(&this);
3321 // VERSION: 2.30
3322 // Creates a subdirectory in the preferred directory for temporary
3323 // files (as returned by g_get_tmp_dir()).
3325 // @tmpl should be a string in the GLib file name encoding containing
3326 // a sequence of six 'X' characters, as the parameter to g_mkstemp().
3327 // However, unlike these functions, the template should only be a
3328 // basename, no directory components are allowed. If template is
3329 // %NULL, a default template is used.
3331 // Note that in contrast to g_mkdtemp() (and mkdtemp()) @tmpl is not
3332 // modified, and might thus be a read-only literal string.
3334 // should be freed with g_free() when not needed any longer and is
3335 // is in the GLib file name encoding. In case of errors, %NULL is
3336 // returned and @error will be set.
3337 // RETURNS: The actual name used. This string
3338 // <tmpl>: Template for directory name, as in g_mkdtemp(), basename only, or %NULL for a default template
3339 static char* /*new*/ make_tmp()(char* tmpl, GLib2.Error** error=null) {
3340 return g_dir_make_tmp(tmpl, error);
3343 // Unintrospectable function: open() / g_dir_open()
3344 // Opens a directory for reading. The names of the files in the
3345 // directory can then be retrieved using g_dir_read_name(). Note
3346 // that the ordering is not defined.
3348 // If non-%NULL, you must free the result with g_dir_close()
3349 // when you are finished with it.
3350 // RETURNS: a newly allocated #GDir on success, %NULL on failure.
3351 // <path>: the path to the directory you are interested in. On Unix in the on-disk encoding. On Windows in UTF-8
3352 // <flags>: Currently must be set to 0. Reserved for future use.
3353 static Dir* open()(char* path, uint flags, GLib2.Error** error=null) {
3354 return g_dir_open(path, flags, error);
3359 // The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the sign,
3360 // mantissa and exponent of IEEE floats and doubles. These unions are defined
3361 // as appropriate for a given platform. IEEE floats and doubles are supported
3362 // (used for storage) by at least Intel, PPC and Sparc.
3363 union DoubleIEEE754 {
3364 double v_double;
3366 struct mpn {
3367 static import std.bitmanip; mixin(std.bitmanip.bitfields!(
3368 uint, "mantissa_low", 32,
3369 uint, "mantissa_high", 20,
3370 uint, "biased_exponent", 11,
3371 uint, "sign", 1));
3375 enum double E = 2.718282;
3377 // Specifies the type of a function used to test two values for
3378 // equality. The function should return %TRUE if both values are equal
3379 // and %FALSE otherwise.
3380 // RETURNS: %TRUE if @a = @b; %FALSE otherwise
3381 // <a>: a value
3382 // <b>: a value to compare with
3383 extern (C) alias int function (const(void)* a, const(void)* b) EqualFunc;
3386 // The <structname>GError</structname> structure contains
3387 // information about an error that has occurred.
3388 struct Error {
3389 Quark domain;
3390 int code;
3391 char* message;
3394 // Unintrospectable constructor: new() / g_error_new()
3395 // Creates a new #GError with the given @domain and @code,
3396 // and a message formatted with @format.
3397 // RETURNS: a new #GError
3398 // <domain>: error domain
3399 // <code>: error code
3400 // <format>: printf()-style format for error message
3401 alias g_error_new new_; // Variadic
3403 // Creates a new #GError; unlike g_error_new(), @message is
3404 // not a printf()-style format string. Use this function if
3405 // @message contains text you don't have control over,
3406 // that could include printf() escape sequences.
3407 // RETURNS: a new #GError
3408 // <domain>: error domain
3409 // <code>: error code
3410 // <message>: error message
3411 static Error* /*new*/ new_literal()(Quark domain, int code, char* message) {
3412 return g_error_new_literal(domain, code, message);
3415 // Unintrospectable constructor: new_valist() / g_error_new_valist()
3416 // VERSION: 2.22
3417 // Creates a new #GError with the given @domain and @code,
3418 // and a message formatted with @format.
3419 // RETURNS: a new #GError
3420 // <domain>: error domain
3421 // <code>: error code
3422 // <format>: printf()-style format for error message
3423 // <args>: #va_list of parameters for the message format
3424 static Error* /*new*/ new_valist()(Quark domain, int code, char* format, va_list args) {
3425 return g_error_new_valist(domain, code, format, args);
3428 // Makes a copy of @error.
3429 // RETURNS: a new #GError
3430 Error* /*new*/ copy()() {
3431 return g_error_copy(&this);
3433 // Frees a #GError and associated resources.
3434 void free()() {
3435 g_error_free(&this);
3438 // Returns %TRUE if @error matches @domain and @code, %FALSE
3439 // otherwise. In particular, when @error is %NULL, %FALSE will
3440 // be returned.
3441 // RETURNS: whether @error has @domain and @code
3442 // <domain>: an error domain
3443 // <code>: an error code
3444 int matches()(Quark domain, int code) {
3445 return g_error_matches(&this, domain, code);
3450 // The possible errors, used in the @v_error field
3451 // of #GTokenValue, when the token is a %G_TOKEN_ERROR.
3452 enum ErrorType {
3453 UNKNOWN = 0,
3454 UNEXP_EOF = 1,
3455 UNEXP_EOF_IN_STRING = 2,
3456 UNEXP_EOF_IN_COMMENT = 3,
3457 NON_DIGIT_IN_CONST = 4,
3458 DIGIT_RADIX = 5,
3459 FLOAT_RADIX = 6,
3460 FLOAT_MALFORMED = 7
3463 // Values corresponding to @errno codes returned from file operations
3464 // on UNIX. Unlike @errno codes, GFileError values are available on
3465 // all systems, even Windows. The exact meaning of each code depends
3466 // on what sort of file operation you were performing; the UNIX
3467 // documentation gives more details. The following error code descriptions
3468 // come from the GNU C Library manual, and are under the copyright
3469 // of that manual.
3471 // It's not very portable to make detailed assumptions about exactly
3472 // which errors will be returned from a given operation. Some errors
3473 // don't occur on some systems, etc., sometimes there are subtle
3474 // differences in when a system will report a given error, etc.
3475 enum FileError {
3476 EXIST = 0,
3477 ISDIR = 1,
3478 ACCES = 2,
3479 NAMETOOLONG = 3,
3480 NOENT = 4,
3481 NOTDIR = 5,
3482 NXIO = 6,
3483 NODEV = 7,
3484 ROFS = 8,
3485 TXTBSY = 9,
3486 FAULT = 10,
3487 LOOP = 11,
3488 NOSPC = 12,
3489 NOMEM = 13,
3490 MFILE = 14,
3491 NFILE = 15,
3492 BADF = 16,
3493 INVAL = 17,
3494 PIPE = 18,
3495 AGAIN = 19,
3496 INTR = 20,
3497 IO = 21,
3498 PERM = 22,
3499 NOSYS = 23,
3500 FAILED = 24
3502 // A test to perform on a file using g_file_test().
3503 enum FileTest {
3504 IS_REGULAR = 1,
3505 IS_SYMLINK = 2,
3506 IS_DIR = 4,
3507 IS_EXECUTABLE = 8,
3508 EXISTS = 16
3511 // The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the sign,
3512 // mantissa and exponent of IEEE floats and doubles. These unions are defined
3513 // as appropriate for a given platform. IEEE floats and doubles are supported
3514 // (used for storage) by at least Intel, PPC and Sparc.
3515 union FloatIEEE754 {
3516 float v_float;
3518 struct mpn {
3519 static import std.bitmanip; mixin(std.bitmanip.bitfields!(
3520 uint, "mantissa", 23,
3521 uint, "biased_exponent", 8,
3522 uint, "sign", 1));
3526 // Flags to modify the format of the string returned by g_format_size_full().
3527 enum FormatSizeFlags {
3528 DEFAULT = 0,
3529 LONG_FORMAT = 1,
3530 IEC_UNITS = 2
3533 // Declares a type of function which takes an arbitrary
3534 // data pointer argument and has no return value. It is
3535 // not currently used in GLib or GTK+.
3536 // <data>: a data pointer
3537 extern (C) alias void function (void* data) FreeFunc;
3540 // Specifies the type of functions passed to g_list_foreach() and
3541 // g_slist_foreach().
3542 // <data>: the element's data.
3543 // <user_data>: user data passed to g_list_foreach() or g_slist_foreach().
3544 extern (C) alias void function (void* data, void* user_data) Func;
3546 enum GINT16_FORMAT = "hi";
3547 enum GINT16_MODIFIER = "h";
3548 enum GINT32_FORMAT = "i";
3549 enum GINT32_MODIFIER = "";
3550 enum GINT64_FORMAT = "lli";
3551 enum GINT64_MODIFIER = "ll";
3552 enum GINTPTR_FORMAT = "i";
3553 enum GINTPTR_MODIFIER = "";
3554 enum GNUC_FUNCTION = "";
3555 enum GNUC_PRETTY_FUNCTION = "";
3556 enum GSIZE_FORMAT = "u";
3557 enum GSIZE_MODIFIER = "";
3558 enum GSSIZE_FORMAT = "i";
3559 enum GUINT16_FORMAT = "hu";
3560 enum GUINT32_FORMAT = "u";
3561 enum GUINT64_FORMAT = "llu";
3562 enum GUINTPTR_FORMAT = "u";
3563 enum int HAVE_GINT64 = 1;
3564 enum int HAVE_GNUC_VARARGS = 1;
3565 enum int HAVE_GNUC_VISIBILITY = 1;
3566 enum int HAVE_GROWING_STACK = 1;
3567 enum int HAVE_INLINE = 1;
3568 enum int HAVE_ISO_VARARGS = 1;
3569 enum int HAVE___INLINE = 1;
3570 enum int HAVE___INLINE__ = 1;
3572 // Specifies the type of the function passed to g_hash_table_foreach().
3573 // It is called with each key/value pair, together with the @user_data
3574 // parameter which is passed to g_hash_table_foreach().
3575 // <key>: a key
3576 // <value>: the value corresponding to the key
3577 // <user_data>: user data passed to g_hash_table_foreach()
3578 extern (C) alias void function (void* key, void* value, void* user_data) HFunc;
3580 enum int HOOK_FLAG_USER_SHIFT = 4;
3582 // Specifies the type of the function passed to
3583 // g_hash_table_foreach_remove(). It is called with each key/value
3584 // pair, together with the @user_data parameter passed to
3585 // g_hash_table_foreach_remove(). It should return %TRUE if the
3586 // key/value pair should be removed from the #GHashTable.
3588 // #GHashTable
3589 // RETURNS: %TRUE if the key/value pair should be removed from the
3590 // <key>: a key
3591 // <value>: the value associated with the key
3592 // <user_data>: user data passed to g_hash_table_remove()
3593 extern (C) alias int function (void* key, void* value, void* user_data) HRFunc;
3596 // Specifies the type of the hash function which is passed to
3597 // g_hash_table_new() when a #GHashTable is created.
3599 // The function is passed a key and should return a #guint hash value.
3600 // The functions g_direct_hash(), g_int_hash() and g_str_hash() provide
3601 // hash functions which can be used when the key is a #gpointer, #gint*,
3602 // and #gchar* respectively.
3604 // g_direct_hash() is also the appropriate hash function for keys
3605 // of the form <literal>GINT_TO_POINTER (n)</literal> (or similar macros).
3607 // <!-- FIXME: Need more here. --> The hash values should be evenly
3608 // distributed over a fairly large range? The modulus is taken with the
3609 // hash table size (a prime number) to find the 'bucket' to place each
3610 // key into. The function should also be very fast, since it is called
3611 // for each key lookup.
3612 // RETURNS: the hash value corresponding to the key
3613 // <key>: a key
3614 extern (C) alias uint function (const(void)* key) HashFunc;
3617 // The #GHashTable struct is an opaque data structure to represent a
3618 // <link linkend="glib-Hash-Tables">Hash Table</link>. It should only be
3619 // accessed via the following functions.
3620 struct HashTable {
3622 // VERSION: 2.32
3623 // This is a convenience function for using a #GHashTable as a set. It
3624 // is equivalent to calling g_hash_table_replace() with @key as both the
3625 // key and the value.
3627 // When a hash table only ever contains keys that have themselves as the
3628 // corresponding value it is able to be stored more efficiently. See
3629 // the discussion in the section description.
3630 // <hash_table>: a #GHashTable
3631 // <key>: a key to insert
3632 static void add()(GLib2.HashTable* hash_table, void* key) {
3633 g_hash_table_add(hash_table, key);
3636 // VERSION: 2.32
3637 // Checks if @key is in @hash_table.
3638 // <hash_table>: a #GHashTable
3639 static int contains()(GLib2.HashTable* hash_table, const(void)* lookup_key) {
3640 return g_hash_table_contains(hash_table, lookup_key);
3643 // Destroys all keys and values in the #GHashTable and decrements its
3644 // reference count by 1. If keys and/or values are dynamically allocated,
3645 // you should either free them first or create the #GHashTable with destroy
3646 // notifiers using g_hash_table_new_full(). In the latter case the destroy
3647 // functions you supplied will be called on all keys and values during the
3648 // destruction phase.
3649 // <hash_table>: a #GHashTable
3650 static void destroy()(GLib2.HashTable* hash_table) {
3651 g_hash_table_destroy(hash_table);
3654 // Unintrospectable function: find() / g_hash_table_find()
3655 // VERSION: 2.4
3656 // Calls the given function for key/value pairs in the #GHashTable
3657 // until @predicate returns %TRUE. The function is passed the key
3658 // and value of each pair, and the given @user_data parameter. The
3659 // hash table may not be modified while iterating over it (you can't
3660 // add/remove items).
3662 // Note, that hash tables are really only optimized for forward
3663 // lookups, i.e. g_hash_table_lookup(). So code that frequently issues
3664 // g_hash_table_find() or g_hash_table_foreach() (e.g. in the order of
3665 // once per every entry in a hash table) should probably be reworked
3666 // to use additional or different data structures for reverse lookups
3667 // (keep in mind that an O(n) find/foreach operation issued for all n
3668 // values in a hash table ends up needing O(n*n) operations).
3670 // for which @predicate evaluates to %TRUE. If no pair with the
3671 // requested property is found, %NULL is returned.
3672 // RETURNS: The value of the first key/value pair is returned,
3673 // <hash_table>: a #GHashTable
3674 // <predicate>: function to test the key/value pairs for a certain property
3675 // <user_data>: user data to pass to the function
3676 static void* find()(GLib2.HashTable* hash_table, HRFunc predicate, void* user_data) {
3677 return g_hash_table_find(hash_table, predicate, user_data);
3680 // Unintrospectable function: foreach() / g_hash_table_foreach()
3681 // Calls the given function for each of the key/value pairs in the
3682 // #GHashTable. The function is passed the key and value of each
3683 // pair, and the given @user_data parameter. The hash table may not
3684 // be modified while iterating over it (you can't add/remove
3685 // items). To remove all items matching a predicate, use
3686 // g_hash_table_foreach_remove().
3688 // See g_hash_table_find() for performance caveats for linear
3689 // order searches in contrast to g_hash_table_lookup().
3690 // <hash_table>: a #GHashTable
3691 // <func>: the function to call for each key/value pair
3692 // <user_data>: user data to pass to the function
3693 static void foreach_()(GLib2.HashTable* hash_table, HFunc func, void* user_data) {
3694 g_hash_table_foreach(hash_table, func, user_data);
3697 // Unintrospectable function: foreach_remove() / g_hash_table_foreach_remove()
3698 // Calls the given function for each key/value pair in the
3699 // #GHashTable. If the function returns %TRUE, then the key/value
3700 // pair is removed from the #GHashTable. If you supplied key or
3701 // value destroy functions when creating the #GHashTable, they are
3702 // used to free the memory allocated for the removed keys and values.
3704 // See #GHashTableIter for an alternative way to loop over the
3705 // key/value pairs in the hash table.
3706 // RETURNS: the number of key/value pairs removed
3707 // <hash_table>: a #GHashTable
3708 // <func>: the function to call for each key/value pair
3709 // <user_data>: user data to pass to the function
3710 static uint foreach_remove()(GLib2.HashTable* hash_table, HRFunc func, void* user_data) {
3711 return g_hash_table_foreach_remove(hash_table, func, user_data);
3714 // Unintrospectable function: foreach_steal() / g_hash_table_foreach_steal()
3715 // Calls the given function for each key/value pair in the
3716 // #GHashTable. If the function returns %TRUE, then the key/value
3717 // pair is removed from the #GHashTable, but no key or value
3718 // destroy functions are called.
3720 // See #GHashTableIter for an alternative way to loop over the
3721 // key/value pairs in the hash table.
3722 // RETURNS: the number of key/value pairs removed.
3723 // <hash_table>: a #GHashTable
3724 // <func>: the function to call for each key/value pair
3725 // <user_data>: user data to pass to the function
3726 static uint foreach_steal()(GLib2.HashTable* hash_table, HRFunc func, void* user_data) {
3727 return g_hash_table_foreach_steal(hash_table, func, user_data);
3730 // Unintrospectable function: get_keys() / g_hash_table_get_keys()
3731 // VERSION: 2.14
3732 // Retrieves every key inside @hash_table. The returned data
3733 // is valid until @hash_table is modified.
3735 // table. The content of the list is owned by the hash table and
3736 // should not be modified or freed. Use g_list_free() when done
3737 // using the list.
3738 // RETURNS: a #GList containing all the keys inside the hash
3739 // <hash_table>: a #GHashTable
3740 static GLib2.List* get_keys()(GLib2.HashTable* hash_table) {
3741 return g_hash_table_get_keys(hash_table);
3744 // Unintrospectable function: get_values() / g_hash_table_get_values()
3745 // VERSION: 2.14
3746 // Retrieves every value inside @hash_table. The returned data
3747 // is valid until @hash_table is modified.
3749 // table. The content of the list is owned by the hash table and
3750 // should not be modified or freed. Use g_list_free() when done
3751 // using the list.
3752 // RETURNS: a #GList containing all the values inside the hash
3753 // <hash_table>: a #GHashTable
3754 static GLib2.List* get_values()(GLib2.HashTable* hash_table) {
3755 return g_hash_table_get_values(hash_table);
3758 // Inserts a new key and value into a #GHashTable.
3760 // If the key already exists in the #GHashTable its current
3761 // value is replaced with the new value. If you supplied a
3762 // @value_destroy_func when creating the #GHashTable, the old
3763 // value is freed using that function. If you supplied a
3764 // @key_destroy_func when creating the #GHashTable, the passed
3765 // key is freed using that function.
3766 // <hash_table>: a #GHashTable
3767 // <key>: a key to insert
3768 // <value>: the value to associate with the key
3769 static void insert()(GLib2.HashTable* hash_table, void* key, void* value) {
3770 g_hash_table_insert(hash_table, key, value);
3773 // Unintrospectable function: lookup() / g_hash_table_lookup()
3774 // Looks up a key in a #GHashTable. Note that this function cannot
3775 // distinguish between a key that is not present and one which is present
3776 // and has the value %NULL. If you need this distinction, use
3777 // g_hash_table_lookup_extended().
3778 // RETURNS: the associated value, or %NULL if the key is not found
3779 // <hash_table>: a #GHashTable
3780 // <key>: the key to look up
3781 static void* lookup()(GLib2.HashTable* hash_table, const(void)* key) {
3782 return g_hash_table_lookup(hash_table, key);
3785 // Looks up a key in the #GHashTable, returning the original key and the
3786 // associated value and a #gboolean which is %TRUE if the key was found. This
3787 // is useful if you need to free the memory allocated for the original key,
3788 // for example before calling g_hash_table_remove().
3790 // You can actually pass %NULL for @lookup_key to test
3791 // whether the %NULL key exists, provided the hash and equal functions
3792 // of @hash_table are %NULL-safe.
3793 // RETURNS: %TRUE if the key was found in the #GHashTable
3794 // <hash_table>: a #GHashTable
3795 // <lookup_key>: the key to look up
3796 // <orig_key>: return location for the original key, or %NULL
3797 // <value>: return location for the value associated with the key, or %NULL
3798 static int lookup_extended()(GLib2.HashTable* hash_table, const(void)* lookup_key, void** orig_key=null, void** value=null) {
3799 return g_hash_table_lookup_extended(hash_table, lookup_key, orig_key, value);
3802 // Unintrospectable function: new() / g_hash_table_new()
3803 // Creates a new #GHashTable with a reference count of 1.
3805 // Hash values returned by @hash_func are used to determine where keys
3806 // are stored within the #GHashTable data structure. The g_direct_hash(),
3807 // g_int_hash(), g_int64_hash(), g_double_hash() and g_str_hash()
3808 // functions are provided for some common types of keys.
3809 // If @hash_func is %NULL, g_direct_hash() is used.
3811 // @key_equal_func is used when looking up keys in the #GHashTable.
3812 // The g_direct_equal(), g_int_equal(), g_int64_equal(), g_double_equal()
3813 // and g_str_equal() functions are provided for the most common types
3814 // of keys. If @key_equal_func is %NULL, keys are compared directly in
3815 // a similar fashion to g_direct_equal(), but without the overhead of
3816 // a function call.
3817 // RETURNS: a new #GHashTable
3818 // <hash_func>: a function to create a hash value from a key
3819 // <key_equal_func>: a function to check two keys for equality
3820 static GLib2.HashTable* new_()(HashFunc hash_func, EqualFunc key_equal_func) {
3821 return g_hash_table_new(hash_func, key_equal_func);
3824 // Unintrospectable function: new_full() / g_hash_table_new_full()
3825 // Creates a new #GHashTable like g_hash_table_new() with a reference
3826 // count of 1 and allows to specify functions to free the memory
3827 // allocated for the key and value that get called when removing the
3828 // entry from the #GHashTable.
3829 // RETURNS: a new #GHashTable
3830 // <hash_func>: a function to create a hash value from a key
3831 // <key_equal_func>: a function to check two keys for equality
3832 // <key_destroy_func>: a function to free the memory allocated for the key used when removing the entry from the #GHashTable, or %NULL if you don't want to supply such a function.
3833 // <value_destroy_func>: a function to free the memory allocated for the value used when removing the entry from the #GHashTable, or %NULL if you don't want to supply such a function.
3834 static GLib2.HashTable* new_full()(HashFunc hash_func, EqualFunc key_equal_func, DestroyNotify key_destroy_func, DestroyNotify value_destroy_func) {
3835 return g_hash_table_new_full(hash_func, key_equal_func, key_destroy_func, value_destroy_func);
3838 // Unintrospectable function: ref() / g_hash_table_ref()
3839 // VERSION: 2.10
3840 // Atomically increments the reference count of @hash_table by one.
3841 // This function is MT-safe and may be called from any thread.
3842 // RETURNS: the passed in #GHashTable
3843 // <hash_table>: a valid #GHashTable
3844 static GLib2.HashTable* ref_()(GLib2.HashTable* hash_table) {
3845 return g_hash_table_ref(hash_table);
3848 // Removes a key and its associated value from a #GHashTable.
3850 // If the #GHashTable was created using g_hash_table_new_full(), the
3851 // key and value are freed using the supplied destroy functions, otherwise
3852 // you have to make sure that any dynamically allocated values are freed
3853 // yourself.
3854 // RETURNS: %TRUE if the key was found and removed from the #GHashTable
3855 // <hash_table>: a #GHashTable
3856 // <key>: the key to remove
3857 static int remove()(GLib2.HashTable* hash_table, const(void)* key) {
3858 return g_hash_table_remove(hash_table, key);
3861 // VERSION: 2.12
3862 // Removes all keys and their associated values from a #GHashTable.
3864 // If the #GHashTable was created using g_hash_table_new_full(),
3865 // the keys and values are freed using the supplied destroy functions,
3866 // otherwise you have to make sure that any dynamically allocated
3867 // values are freed yourself.
3868 // <hash_table>: a #GHashTable
3869 static void remove_all()(GLib2.HashTable* hash_table) {
3870 g_hash_table_remove_all(hash_table);
3873 // Inserts a new key and value into a #GHashTable similar to
3874 // g_hash_table_insert(). The difference is that if the key
3875 // already exists in the #GHashTable, it gets replaced by the
3876 // new key. If you supplied a @value_destroy_func when creating
3877 // the #GHashTable, the old value is freed using that function.
3878 // If you supplied a @key_destroy_func when creating the
3879 // #GHashTable, the old key is freed using that function.
3880 // <hash_table>: a #GHashTable
3881 // <key>: a key to insert
3882 // <value>: the value to associate with the key
3883 static void replace()(GLib2.HashTable* hash_table, void* key, void* value) {
3884 g_hash_table_replace(hash_table, key, value);
3887 // Returns the number of elements contained in the #GHashTable.
3888 // RETURNS: the number of key/value pairs in the #GHashTable.
3889 // <hash_table>: a #GHashTable
3890 static uint size()(GLib2.HashTable* hash_table) {
3891 return g_hash_table_size(hash_table);
3894 // Removes a key and its associated value from a #GHashTable without
3895 // calling the key and value destroy functions.
3896 // RETURNS: %TRUE if the key was found and removed from the #GHashTable
3897 // <hash_table>: a #GHashTable
3898 // <key>: the key to remove
3899 static int steal()(GLib2.HashTable* hash_table, const(void)* key) {
3900 return g_hash_table_steal(hash_table, key);
3903 // VERSION: 2.12
3904 // Removes all keys and their associated values from a #GHashTable
3905 // without calling the key and value destroy functions.
3906 // <hash_table>: a #GHashTable
3907 static void steal_all()(GLib2.HashTable* hash_table) {
3908 g_hash_table_steal_all(hash_table);
3911 // VERSION: 2.10
3912 // Atomically decrements the reference count of @hash_table by one.
3913 // If the reference count drops to 0, all keys and values will be
3914 // destroyed, and all memory allocated by the hash table is released.
3915 // This function is MT-safe and may be called from any thread.
3916 // <hash_table>: a valid #GHashTable
3917 static void unref()(GLib2.HashTable* hash_table) {
3918 g_hash_table_unref(hash_table);
3923 // A GHashTableIter structure represents an iterator that can be used
3924 // to iterate over the elements of a #GHashTable. GHashTableIter
3925 // structures are typically allocated on the stack and then initialized
3926 // with g_hash_table_iter_init().
3927 struct HashTableIter {
3928 private void* dummy1, dummy2, dummy3;
3929 private int dummy4;
3930 private int dummy5;
3931 private void* dummy6;
3934 // Unintrospectable method: get_hash_table() / g_hash_table_iter_get_hash_table()
3935 // VERSION: 2.16
3936 // Returns the #GHashTable associated with @iter.
3937 // RETURNS: the #GHashTable associated with @iter.
3938 GLib2.HashTable* get_hash_table()() {
3939 return g_hash_table_iter_get_hash_table(&this);
3942 // VERSION: 2.16
3943 // Initializes a key/value pair iterator and associates it with
3944 // @hash_table. Modifying the hash table after calling this function
3945 // invalidates the returned iterator.
3946 // |[
3947 // GHashTableIter iter;
3948 // gpointer key, value;
3950 // g_hash_table_iter_init (&iter, hash_table);
3951 // while (g_hash_table_iter_next (&iter, &key, &value))
3952 // {
3953 // /&ast; do something with key and value &ast;/
3954 // }
3955 // ]|
3956 // <hash_table>: a #GHashTable
3957 void init()(GLib2.HashTable* hash_table) {
3958 g_hash_table_iter_init(&this, hash_table);
3961 // VERSION: 2.16
3962 // Advances @iter and retrieves the key and/or value that are now
3963 // pointed to as a result of this advancement. If %FALSE is returned,
3964 // @key and @value are not set, and the iterator becomes invalid.
3965 // RETURNS: %FALSE if the end of the #GHashTable has been reached.
3966 // <key>: a location to store the key, or %NULL
3967 // <value>: a location to store the value, or %NULL
3968 int next()(void** key, void** value) {
3969 return g_hash_table_iter_next(&this, key, value);
3972 // VERSION: 2.16
3973 // Removes the key/value pair currently pointed to by the iterator
3974 // from its associated #GHashTable. Can only be called after
3975 // g_hash_table_iter_next() returned %TRUE, and cannot be called
3976 // more than once for the same key/value pair.
3978 // If the #GHashTable was created using g_hash_table_new_full(),
3979 // the key and value are freed using the supplied destroy functions,
3980 // otherwise you have to make sure that any dynamically allocated
3981 // values are freed yourself.
3982 void remove()() {
3983 g_hash_table_iter_remove(&this);
3986 // VERSION: 2.30
3987 // Replaces the value currently pointed to by the iterator
3988 // from its associated #GHashTable. Can only be called after
3989 // g_hash_table_iter_next() returned %TRUE.
3991 // If you supplied a @value_destroy_func when creating the
3992 // #GHashTable, the old value is freed using that function.
3993 // <value>: the value to replace with
3994 void replace()(void* value) {
3995 g_hash_table_iter_replace(&this, value);
3998 // VERSION: 2.16
3999 // Removes the key/value pair currently pointed to by the
4000 // iterator from its associated #GHashTable, without calling
4001 // the key and value destroy functions. Can only be called
4002 // after g_hash_table_iter_next() returned %TRUE, and cannot
4003 // be called more than once for the same key/value pair.
4004 void steal()() {
4005 g_hash_table_iter_steal(&this);
4010 // An opaque structure representing a HMAC operation.
4011 // To create a new GHmac, use g_hmac_new(). To free
4012 // a GHmac, use g_hmac_unref().
4013 struct Hmac /* Version 2.30 */ {
4015 // Unintrospectable method: copy() / g_hmac_copy()
4016 // VERSION: 2.30
4017 // Copies a #GHmac. If @hmac has been closed, by calling
4018 // g_hmac_get_string() or g_hmac_get_digest(), the copied
4019 // HMAC will be closed as well.
4021 // when finished using it.
4022 // RETURNS: the copy of the passed #GHmac. Use g_hmac_unref()
4023 Hmac* copy()() {
4024 return g_hmac_copy(&this);
4027 // VERSION: 2.30
4028 // Gets the digest from @checksum as a raw binary array and places it
4029 // into @buffer. The size of the digest depends on the type of checksum.
4031 // Once this function has been called, the #GHmac is closed and can
4032 // no longer be updated with g_checksum_update().
4033 // <buffer>: output buffer
4034 // <digest_len>: an inout parameter. The caller initializes it to the size of @buffer. After the call it contains the length of the digest
4035 void get_digest()(ubyte* buffer, size_t* digest_len) {
4036 g_hmac_get_digest(&this, buffer, digest_len);
4039 // VERSION: 2.30
4040 // Gets the HMAC as an hexadecimal string.
4042 // Once this function has been called the #GHmac can no longer be
4043 // updated with g_hmac_update().
4045 // The hexadecimal characters will be lower case.
4047 // returned string is owned by the HMAC and should not be modified
4048 // or freed.
4049 // RETURNS: the hexadecimal representation of the HMAC. The
4050 char* get_string()() {
4051 return g_hmac_get_string(&this);
4054 // Unintrospectable method: ref() / g_hmac_ref()
4055 // VERSION: 2.30
4056 // Atomically increments the reference count of @hmac by one.
4058 // This function is MT-safe and may be called from any thread.
4059 // RETURNS: the passed in #GHmac.
4060 Hmac* ref_()() {
4061 return g_hmac_ref(&this);
4064 // VERSION: 2.30
4065 // Atomically decrements the reference count of @hmac by one.
4067 // If the reference count drops to 0, all keys and values will be
4068 // destroyed, and all memory allocated by the hash table is released.
4069 // This function is MT-safe and may be called from any thread.
4070 // Frees the memory allocated for @hmac.
4071 void unref()() {
4072 g_hmac_unref(&this);
4075 // VERSION: 2.30
4076 // Feeds @data into an existing #GHmac.
4078 // The HMAC must still be open, that is g_hmac_get_string() or
4079 // g_hmac_get_digest() must not have been called on @hmac.
4080 // <data>: buffer used to compute the checksum
4081 // <length>: size of the buffer, or -1 if it is a nul-terminated string
4082 void update()(ubyte* data, ssize_t length) {
4083 g_hmac_update(&this, data, length);
4086 // Unintrospectable function: new() / g_hmac_new()
4087 // VERSION: 2.30
4088 // Creates a new #GHmac, using the digest algorithm @digest_type.
4089 // If the @digest_type is not known, %NULL is returned.
4090 // A #GHmac can be used to compute the HMAC of a key and an
4091 // arbitrary binary blob, using different hashing algorithms.
4093 // A #GHmac works by feeding a binary blob through g_hmac_update()
4094 // until the data is complete; the digest can then be extracted
4095 // using g_hmac_get_string(), which will return the checksum as a
4096 // hexadecimal string; or g_hmac_get_digest(), which will return a
4097 // array of raw bytes. Once either g_hmac_get_string() or
4098 // g_hmac_get_digest() have been called on a #GHmac, the HMAC
4099 // will be closed and it won't be possible to call g_hmac_update()
4100 // on it anymore.
4102 // Use g_hmac_unref() to free the memory allocated by it.
4103 // RETURNS: the newly created #GHmac, or %NULL.
4104 // <digest_type>: the desired type of digest
4105 // <key>: the key for the HMAC
4106 // <key_len>: the length of the keys
4107 static Hmac* new_()(ChecksumType digest_type, ubyte* key, size_t key_len) {
4108 return g_hmac_new(digest_type, key, key_len);
4113 // The <structname>GHook</structname> struct represents a single hook
4114 // function in a #GHookList.
4115 struct Hook {
4116 void* data;
4117 Hook* next, prev;
4118 uint ref_count;
4119 c_ulong hook_id;
4120 uint flags;
4121 void* func;
4122 DestroyNotify destroy_;
4125 // Compares the ids of two #GHook elements, returning a negative value
4126 // if the second id is greater than the first.
4127 // RETURNS: a value &lt;= 0 if the id of @sibling is >= the id of @new_hook
4128 // <sibling>: a #GHook to compare with @new_hook
4129 int compare_ids()(Hook* sibling) {
4130 return g_hook_compare_ids(&this, sibling);
4133 // Unintrospectable function: alloc() / g_hook_alloc()
4134 // Allocates space for a #GHook and initializes it.
4135 // RETURNS: a new #GHook
4136 // <hook_list>: a #GHookList
4137 static Hook* alloc()(HookList* hook_list) {
4138 return g_hook_alloc(hook_list);
4141 // Destroys a #GHook, given its ID.
4142 // RETURNS: %TRUE if the #GHook was found in the #GHookList and destroyed
4143 // <hook_list>: a #GHookList
4144 // <hook_id>: a hook ID
4145 static int destroy()(HookList* hook_list, c_ulong hook_id) {
4146 return g_hook_destroy(hook_list, hook_id);
4149 // Removes one #GHook from a #GHookList, marking it
4150 // inactive and calling g_hook_unref() on it.
4151 // <hook_list>: a #GHookList
4152 // <hook>: the #GHook to remove
4153 static void destroy_link()(HookList* hook_list, Hook* hook) {
4154 g_hook_destroy_link(hook_list, hook);
4157 // Unintrospectable function: find() / g_hook_find()
4158 // Finds a #GHook in a #GHookList using the given function to
4159 // test for a match.
4160 // RETURNS: the found #GHook or %NULL if no matching #GHook is found
4161 // <hook_list>: a #GHookList
4162 // <need_valids>: %TRUE if #GHook elements which have been destroyed should be skipped
4163 // <func>: the function to call for each #GHook, which should return %TRUE when the #GHook has been found
4164 // <data>: the data to pass to @func
4165 static Hook* find()(HookList* hook_list, int need_valids, HookFindFunc func, void* data) {
4166 return g_hook_find(hook_list, need_valids, func, data);
4169 // Unintrospectable function: find_data() / g_hook_find_data()
4170 // Finds a #GHook in a #GHookList with the given data.
4172 // #GHook is found
4173 // RETURNS: the #GHook with the given @data or %NULL if no matching
4174 // <hook_list>: a #GHookList
4175 // <need_valids>: %TRUE if #GHook elements which have been destroyed should be skipped
4176 // <data>: the data to find
4177 static Hook* find_data()(HookList* hook_list, int need_valids, void* data) {
4178 return g_hook_find_data(hook_list, need_valids, data);
4181 // Unintrospectable function: find_func() / g_hook_find_func()
4182 // Finds a #GHook in a #GHookList with the given function.
4184 // #GHook is found
4185 // RETURNS: the #GHook with the given @func or %NULL if no matching
4186 // <hook_list>: a #GHookList
4187 // <need_valids>: %TRUE if #GHook elements which have been destroyed should be skipped
4188 // <func>: the function to find
4189 static Hook* find_func()(HookList* hook_list, int need_valids, void* func) {
4190 return g_hook_find_func(hook_list, need_valids, func);
4193 // Unintrospectable function: find_func_data() / g_hook_find_func_data()
4194 // Finds a #GHook in a #GHookList with the given function and data.
4196 // no matching #GHook is found
4197 // RETURNS: the #GHook with the given @func and @data or %NULL if
4198 // <hook_list>: a #GHookList
4199 // <need_valids>: %TRUE if #GHook elements which have been destroyed should be skipped
4200 // <func>: the function to find
4201 // <data>: the data to find
4202 static Hook* find_func_data()(HookList* hook_list, int need_valids, void* func, void* data) {
4203 return g_hook_find_func_data(hook_list, need_valids, func, data);
4206 // Unintrospectable function: first_valid() / g_hook_first_valid()
4207 // Returns the first #GHook in a #GHookList which has not been destroyed.
4208 // The reference count for the #GHook is incremented, so you must call
4209 // g_hook_unref() to restore it when no longer needed. (Or call
4210 // g_hook_next_valid() if you are stepping through the #GHookList.)
4211 // RETURNS: the first valid #GHook, or %NULL if none are valid
4212 // <hook_list>: a #GHookList
4213 // <may_be_in_call>: %TRUE if hooks which are currently running (e.g. in another thread) are considered valid. If set to %FALSE, these are skipped
4214 static Hook* first_valid()(HookList* hook_list, int may_be_in_call) {
4215 return g_hook_first_valid(hook_list, may_be_in_call);
4218 // Calls the #GHookList @finalize_hook function if it exists,
4219 // and frees the memory allocated for the #GHook.
4220 // <hook_list>: a #GHookList
4221 // <hook>: the #GHook to free
4222 static void free()(HookList* hook_list, Hook* hook) {
4223 g_hook_free(hook_list, hook);
4226 // Unintrospectable function: get() / g_hook_get()
4227 // Returns the #GHook with the given id, or %NULL if it is not found.
4228 // RETURNS: the #GHook with the given id, or %NULL if it is not found
4229 // <hook_list>: a #GHookList
4230 // <hook_id>: a hook id
4231 static Hook* get()(HookList* hook_list, c_ulong hook_id) {
4232 return g_hook_get(hook_list, hook_id);
4235 // Inserts a #GHook into a #GHookList, before a given #GHook.
4236 // <hook_list>: a #GHookList
4237 // <sibling>: the #GHook to insert the new #GHook before
4238 // <hook>: the #GHook to insert
4239 static void insert_before()(HookList* hook_list, Hook* sibling, Hook* hook) {
4240 g_hook_insert_before(hook_list, sibling, hook);
4243 // Unintrospectable function: insert_sorted() / g_hook_insert_sorted()
4244 // Inserts a #GHook into a #GHookList, sorted by the given function.
4245 // <hook_list>: a #GHookList
4246 // <hook>: the #GHook to insert
4247 // <func>: the comparison function used to sort the #GHook elements
4248 static void insert_sorted()(HookList* hook_list, Hook* hook, HookCompareFunc func) {
4249 g_hook_insert_sorted(hook_list, hook, func);
4252 // Unintrospectable function: next_valid() / g_hook_next_valid()
4253 // Returns the next #GHook in a #GHookList which has not been destroyed.
4254 // The reference count for the #GHook is incremented, so you must call
4255 // g_hook_unref() to restore it when no longer needed. (Or continue to call
4256 // g_hook_next_valid() until %NULL is returned.)
4257 // RETURNS: the next valid #GHook, or %NULL if none are valid
4258 // <hook_list>: a #GHookList
4259 // <hook>: the current #GHook
4260 // <may_be_in_call>: %TRUE if hooks which are currently running (e.g. in another thread) are considered valid. If set to %FALSE, these are skipped
4261 static Hook* next_valid()(HookList* hook_list, Hook* hook, int may_be_in_call) {
4262 return g_hook_next_valid(hook_list, hook, may_be_in_call);
4265 // Prepends a #GHook on the start of a #GHookList.
4266 // <hook_list>: a #GHookList
4267 // <hook>: the #GHook to add to the start of @hook_list
4268 static void prepend()(HookList* hook_list, Hook* hook) {
4269 g_hook_prepend(hook_list, hook);
4272 // Unintrospectable function: ref() / g_hook_ref()
4273 // Increments the reference count for a #GHook.
4274 // RETURNS: the @hook that was passed in (since 2.6)
4275 // <hook_list>: a #GHookList
4276 // <hook>: the #GHook to increment the reference count of
4277 static Hook* ref_()(HookList* hook_list, Hook* hook) {
4278 return g_hook_ref(hook_list, hook);
4281 // Decrements the reference count of a #GHook.
4282 // If the reference count falls to 0, the #GHook is removed
4283 // from the #GHookList and g_hook_free() is called to free it.
4284 // <hook_list>: a #GHookList
4285 // <hook>: the #GHook to unref
4286 static void unref()(HookList* hook_list, Hook* hook) {
4287 g_hook_unref(hook_list, hook);
4292 // Defines the type of a hook function that can be invoked
4293 // by g_hook_list_invoke_check().
4294 // RETURNS: %FALSE if the #GHook should be destroyed
4295 // <data>: the data field of the #GHook is passed to the hook function here
4296 extern (C) alias int function (void* data) HookCheckFunc;
4299 // Defines the type of function used by g_hook_list_marshal_check().
4300 // RETURNS: %FALSE if @hook should be destroyed
4301 // <hook>: a #GHook
4302 // <marshal_data>: user data
4303 extern (C) alias int function (Hook* hook, void* marshal_data) HookCheckMarshaller;
4306 // Defines the type of function used to compare #GHook elements in
4307 // g_hook_insert_sorted().
4308 // RETURNS: a value &lt;= 0 if @new_hook should be before @sibling
4309 // <new_hook>: the #GHook being inserted
4310 // <sibling>: the #GHook to compare with @new_hook
4311 extern (C) alias int function (Hook* new_hook, Hook* sibling) HookCompareFunc;
4314 // Defines the type of function to be called when a hook in a
4315 // list of hooks gets finalized.
4316 // <hook_list>: a #GHookList
4317 // <hook>: the hook in @hook_list that gets finalized
4318 extern (C) alias void function (HookList* hook_list, Hook* hook) HookFinalizeFunc;
4321 // Defines the type of the function passed to g_hook_find().
4322 // RETURNS: %TRUE if the required #GHook has been found
4323 // <hook>: a #GHook
4324 // <data>: user data passed to g_hook_find_func()
4325 extern (C) alias int function (Hook* hook, void* data) HookFindFunc;
4327 // Flags used internally in the #GHook implementation.
4328 enum HookFlagMask {
4329 ACTIVE = 1,
4330 IN_CALL = 2,
4331 MASK = 15
4334 // Defines the type of a hook function that can be invoked
4335 // by g_hook_list_invoke().
4336 // <data>: the data field of the #GHook is passed to the hook function here
4337 extern (C) alias void function (void* data) HookFunc;
4340 // The <structname>GHookList</structname> struct represents a
4341 // list of hook functions.
4342 struct HookList {
4343 c_ulong seq_id;
4344 static import std.bitmanip; mixin(std.bitmanip.bitfields!(
4345 uint, "hook_size", 16,
4346 uint, "is_setup", 1,
4347 uint, "__dummy32A", 15));
4348 Hook* hooks;
4349 void* dummy3;
4350 HookFinalizeFunc finalize_hook;
4351 void*[2] dummy;
4353 // Removes all the #GHook elements from a #GHookList.
4354 void clear()() {
4355 g_hook_list_clear(&this);
4358 // Initializes a #GHookList.
4359 // This must be called before the #GHookList is used.
4360 // <hook_size>: the size of each element in the #GHookList, typically <literal>sizeof (GHook)</literal>
4361 void init()(uint hook_size) {
4362 g_hook_list_init(&this, hook_size);
4365 // Calls all of the #GHook functions in a #GHookList.
4366 // <may_recurse>: %TRUE if functions which are already running (e.g. in another thread) can be called. If set to %FALSE, these are skipped
4367 void invoke()(int may_recurse) {
4368 g_hook_list_invoke(&this, may_recurse);
4371 // Calls all of the #GHook functions in a #GHookList.
4372 // Any function which returns %FALSE is removed from the #GHookList.
4373 // <may_recurse>: %TRUE if functions which are already running (e.g. in another thread) can be called. If set to %FALSE, these are skipped
4374 void invoke_check()(int may_recurse) {
4375 g_hook_list_invoke_check(&this, may_recurse);
4378 // Unintrospectable method: marshal() / g_hook_list_marshal()
4379 // Calls a function on each valid #GHook.
4380 // <may_recurse>: %TRUE if hooks which are currently running (e.g. in another thread) are considered valid. If set to %FALSE, these are skipped
4381 // <marshaller>: the function to call for each #GHook
4382 // <marshal_data>: data to pass to @marshaller
4383 void marshal()(int may_recurse, HookMarshaller marshaller, void* marshal_data) {
4384 g_hook_list_marshal(&this, may_recurse, marshaller, marshal_data);
4387 // Unintrospectable method: marshal_check() / g_hook_list_marshal_check()
4388 // Calls a function on each valid #GHook and destroys it if the
4389 // function returns %FALSE.
4390 // <may_recurse>: %TRUE if hooks which are currently running (e.g. in another thread) are considered valid. If set to %FALSE, these are skipped
4391 // <marshaller>: the function to call for each #GHook
4392 // <marshal_data>: data to pass to @marshaller
4393 void marshal_check()(int may_recurse, HookCheckMarshaller marshaller, void* marshal_data) {
4394 g_hook_list_marshal_check(&this, may_recurse, marshaller, marshal_data);
4399 // Defines the type of function used by g_hook_list_marshal().
4400 // <hook>: a #GHook
4401 // <marshal_data>: user data
4402 extern (C) alias void function (Hook* hook, void* marshal_data) HookMarshaller;
4404 struct IConv {
4406 // Same as the standard UNIX routine iconv(), but
4407 // may be implemented via libiconv on UNIX flavors that lack
4408 // a native implementation.
4410 // GLib provides g_convert() and g_locale_to_utf8() which are likely
4411 // more convenient than the raw iconv wrappers.
4412 // RETURNS: count of non-reversible conversions, or -1 on error
4413 // <inbuf>: bytes to convert
4414 // <inbytes_left>: inout parameter, bytes remaining to convert in @inbuf
4415 // <outbuf>: converted output bytes
4416 // <outbytes_left>: inout parameter, bytes available to fill in @outbuf
4417 size_t /*NAME MISSING IN GIR*/ iconv()(char** inbuf, size_t* inbytes_left, char** outbuf, size_t* outbytes_left) {
4418 return g_iconv(&this, inbuf, inbytes_left, outbuf, outbytes_left);
4421 // Same as the standard UNIX routine iconv_close(), but
4422 // may be implemented via libiconv on UNIX flavors that lack
4423 // a native implementation. Should be called to clean up
4424 // the conversion descriptor from g_iconv_open() when
4425 // you are done converting things.
4427 // GLib provides g_convert() and g_locale_to_utf8() which are likely
4428 // more convenient than the raw iconv wrappers.
4429 // RETURNS: -1 on error, 0 on success
4430 int close()() {
4431 return g_iconv_close(&this);
4434 // Unintrospectable function: open() / g_iconv_open()
4435 // Same as the standard UNIX routine iconv_open(), but
4436 // may be implemented via libiconv on UNIX flavors that lack
4437 // a native implementation.
4439 // GLib provides g_convert() and g_locale_to_utf8() which are likely
4440 // more convenient than the raw iconv wrappers.
4442 // opening the converter failed.
4443 // RETURNS: a "conversion descriptor", or (GIConv)-1 if
4444 // <to_codeset>: destination codeset
4445 // <from_codeset>: source codeset
4446 static IConv open()(char* to_codeset, char* from_codeset) {
4447 return g_iconv_open(to_codeset, from_codeset);
4451 enum int IEEE754_DOUBLE_BIAS = 1023;
4452 enum int IEEE754_FLOAT_BIAS = 127;
4454 // A data structure representing an IO Channel. The fields should be
4455 // considered private and should only be accessed with the following
4456 // functions.
4457 struct IOChannel {
4458 private int ref_count;
4459 private IOFuncs* funcs;
4460 private char* encoding;
4461 private IConv read_cd, write_cd;
4462 private char* line_term;
4463 private uint line_term_len;
4464 private size_t buf_size;
4465 private String* read_buf, encoded_read_buf, write_buf;
4466 private char[6] partial_write_buf;
4467 static import std.bitmanip; mixin(std.bitmanip.bitfields!(
4468 uint, "use_buffer", 1,
4469 uint, "do_encode", 1,
4470 uint, "close_on_unref", 1,
4471 uint, "is_readable", 1,
4472 uint, "is_writeable", 1,
4473 uint, "is_seekable", 1,
4474 uint, "__dummy32A", 26));
4475 private void* reserved1, reserved2;
4478 // Open a file @filename as a #GIOChannel using mode @mode. This
4479 // channel will be closed when the last reference to it is dropped,
4480 // so there is no need to call g_io_channel_close() (though doing
4481 // so will not cause problems, as long as no attempt is made to
4482 // access the channel after it is closed).
4483 // RETURNS: A #GIOChannel on success, %NULL on failure.
4484 // <filename>: A string containing the name of a file
4485 // <mode>: One of "r", "w", "a", "r+", "w+", "a+". These have the same meaning as in fopen()
4486 static IOChannel* /*new*/ new_file()(char* filename, char* mode, GLib2.Error** error=null) {
4487 return g_io_channel_new_file(filename, mode, error);
4490 // Creates a new #GIOChannel given a file descriptor. On UNIX systems
4491 // this works for plain files, pipes, and sockets.
4493 // The returned #GIOChannel has a reference count of 1.
4495 // The default encoding for #GIOChannel is UTF-8. If your application
4496 // is reading output from a command using via pipe, you may need to set
4497 // the encoding to the encoding of the current locale (see
4498 // g_get_charset()) with the g_io_channel_set_encoding() function.
4500 // If you want to read raw binary data without interpretation, then
4501 // call the g_io_channel_set_encoding() function with %NULL for the
4502 // encoding argument.
4504 // This function is available in GLib on Windows, too, but you should
4505 // avoid using it on Windows. The domain of file descriptors and
4506 // sockets overlap. There is no way for GLib to know which one you mean
4507 // in case the argument you pass to this function happens to be both a
4508 // valid file descriptor and socket. If that happens a warning is
4509 // issued, and GLib assumes that it is the file descriptor you mean.
4510 // <fd>: a file descriptor.
4511 static IOChannel* /*new*/ unix_new()(int fd) {
4512 return g_io_channel_unix_new(fd);
4515 // Close an IO channel. Any pending data to be written will be
4516 // flushed, ignoring errors. The channel will not be freed until the
4517 // last reference is dropped using g_io_channel_unref().
4519 // Deprecated:2.2: Use g_io_channel_shutdown() instead.
4520 void close()() {
4521 g_io_channel_close(&this);
4524 // Flushes the write buffer for the GIOChannel.
4526 // #G_IO_STATUS_NORMAL, #G_IO_STATUS_AGAIN, or
4527 // #G_IO_STATUS_ERROR.
4528 // RETURNS: the status of the operation: One of
4529 IOStatus flush()(GLib2.Error** error=null) {
4530 return g_io_channel_flush(&this, error);
4533 // This function returns a #GIOCondition depending on whether there
4534 // is data to be read/space to write data in the internal buffers in
4535 // the #GIOChannel. Only the flags %G_IO_IN and %G_IO_OUT may be set.
4536 // RETURNS: A #GIOCondition
4537 IOCondition get_buffer_condition()() {
4538 return g_io_channel_get_buffer_condition(&this);
4541 // Gets the buffer size.
4542 // RETURNS: the size of the buffer.
4543 size_t get_buffer_size()() {
4544 return g_io_channel_get_buffer_size(&this);
4547 // Returns whether @channel is buffered.
4548 // RETURNS: %TRUE if the @channel is buffered.
4549 int get_buffered()() {
4550 return g_io_channel_get_buffered(&this);
4553 // Returns whether the file/socket/whatever associated with @channel
4554 // will be closed when @channel receives its final unref and is
4555 // destroyed. The default value of this is %TRUE for channels created
4556 // by g_io_channel_new_file (), and %FALSE for all other channels.
4558 // the GIOChannel data structure.
4559 // RETURNS: Whether the channel will be closed on the final unref of
4560 int get_close_on_unref()() {
4561 return g_io_channel_get_close_on_unref(&this);
4564 // Gets the encoding for the input/output of the channel.
4565 // The internal encoding is always UTF-8. The encoding %NULL
4566 // makes the channel safe for binary data.
4568 // owned by GLib and must not be freed.
4569 // RETURNS: A string containing the encoding, this string is
4570 char* get_encoding()() {
4571 return g_io_channel_get_encoding(&this);
4574 // Gets the current flags for a #GIOChannel, including read-only
4575 // flags such as %G_IO_FLAG_IS_READABLE.
4577 // The values of the flags %G_IO_FLAG_IS_READABLE and %G_IO_FLAG_IS_WRITABLE
4578 // are cached for internal use by the channel when it is created.
4579 // If they should change at some later point (e.g. partial shutdown
4580 // of a socket with the UNIX shutdown() function), the user
4581 // should immediately call g_io_channel_get_flags() to update
4582 // the internal values of these flags.
4583 // RETURNS: the flags which are set on the channel
4584 IOFlags get_flags()() {
4585 return g_io_channel_get_flags(&this);
4588 // This returns the string that #GIOChannel uses to determine
4589 // where in the file a line break occurs. A value of %NULL
4590 // indicates autodetection.
4592 // is owned by GLib and must not be freed.
4593 // RETURNS: The line termination string. This value
4594 // <length>: a location to return the length of the line terminator
4595 char* get_line_term()(int* length) {
4596 return g_io_channel_get_line_term(&this, length);
4599 // Initializes a #GIOChannel struct.
4601 // This is called by each of the above functions when creating a
4602 // #GIOChannel, and so is not often needed by the application
4603 // programmer (unless you are creating a new type of #GIOChannel).
4604 void init()() {
4605 g_io_channel_init(&this);
4608 // Reads data from a #GIOChannel.
4611 // Deprecated:2.2: Use g_io_channel_read_chars() instead.
4612 // RETURNS: %G_IO_ERROR_NONE if the operation was successful.
4613 // <buf>: a buffer to read the data into (which should be at least count bytes long)
4614 // <count>: the number of bytes to read from the #GIOChannel
4615 // <bytes_read>: returns the number of bytes actually read
4616 IOError read()(char* buf, size_t count, size_t* bytes_read) {
4617 return g_io_channel_read(&this, buf, count, bytes_read);
4620 // Replacement for g_io_channel_read() with the new API.
4621 // RETURNS: the status of the operation.
4622 // <buf>: a buffer to read data into
4623 // <count>: the size of the buffer. Note that the buffer may not be complelely filled even if there is data in the buffer if the remaining data is not a complete character.
4624 // <bytes_read>: The number of bytes read. This may be zero even on success if count < 6 and the channel's encoding is non-%NULL. This indicates that the next UTF-8 character is too wide for the buffer.
4625 IOStatus read_chars()(char* buf, size_t count, size_t* bytes_read, GLib2.Error** error=null) {
4626 return g_io_channel_read_chars(&this, buf, count, bytes_read, error);
4629 // Reads a line, including the terminating character(s),
4630 // from a #GIOChannel into a newly-allocated string.
4631 // @str_return will contain allocated memory if the return
4632 // is %G_IO_STATUS_NORMAL.
4633 // RETURNS: the status of the operation.
4634 // <str_return>: The line read from the #GIOChannel, including the line terminator. This data should be freed with g_free() when no longer needed. This is a nul-terminated string. If a @length of zero is returned, this will be %NULL instead.
4635 // <length>: location to store length of the read data, or %NULL
4636 // <terminator_pos>: location to store position of line terminator, or %NULL
4637 IOStatus read_line()(char** str_return, size_t* length, size_t* terminator_pos, GLib2.Error** error=null) {
4638 return g_io_channel_read_line(&this, str_return, length, terminator_pos, error);
4641 // Reads a line from a #GIOChannel, using a #GString as a buffer.
4642 // RETURNS: the status of the operation.
4643 // <buffer>: a #GString into which the line will be written. If @buffer already contains data, the old data will be overwritten.
4644 // <terminator_pos>: location to store position of line terminator, or %NULL
4645 IOStatus read_line_string()(String* buffer, size_t* terminator_pos, GLib2.Error** error=null) {
4646 return g_io_channel_read_line_string(&this, buffer, terminator_pos, error);
4649 // Reads all the remaining data from the file.
4651 // This function never returns %G_IO_STATUS_EOF.
4652 // RETURNS: %G_IO_STATUS_NORMAL on success.
4653 // <str_return>: Location to store a pointer to a string holding the remaining data in the #GIOChannel. This data should be freed with g_free() when no longer needed. This data is terminated by an extra nul character, but there may be other nuls in the intervening data.
4654 // <length>: location to store length of the data
4655 IOStatus read_to_end()(char** str_return, size_t* length, GLib2.Error** error=null) {
4656 return g_io_channel_read_to_end(&this, str_return, length, error);
4659 // Reads a Unicode character from @channel.
4660 // This function cannot be called on a channel with %NULL encoding.
4661 // RETURNS: a #GIOStatus
4662 // <thechar>: a location to return a character
4663 IOStatus read_unichar()(dchar* thechar, GLib2.Error** error=null) {
4664 return g_io_channel_read_unichar(&this, thechar, error);
4667 // Increments the reference count of a #GIOChannel.
4668 // RETURNS: the @channel that was passed in (since 2.6)
4669 IOChannel* /*new*/ ref_()() {
4670 return g_io_channel_ref(&this);
4673 // Sets the current position in the #GIOChannel, similar to the standard
4674 // library function fseek().
4677 // Deprecated:2.2: Use g_io_channel_seek_position() instead.
4678 // RETURNS: %G_IO_ERROR_NONE if the operation was successful.
4679 // <offset>: an offset, in bytes, which is added to the position specified by @type
4680 // <type>: the position in the file, which can be %G_SEEK_CUR (the current position), %G_SEEK_SET (the start of the file), or %G_SEEK_END (the end of the file)
4681 IOError seek()(long offset, SeekType type) {
4682 return g_io_channel_seek(&this, offset, type);
4685 // Replacement for g_io_channel_seek() with the new API.
4686 // RETURNS: the status of the operation.
4687 // <offset>: The offset in bytes from the position specified by @type
4688 // <type>: a #GSeekType. The type %G_SEEK_CUR is only allowed in those cases where a call to g_io_channel_set_encoding () is allowed. See the documentation for g_io_channel_set_encoding () for details.
4689 IOStatus seek_position()(long offset, SeekType type, GLib2.Error** error=null) {
4690 return g_io_channel_seek_position(&this, offset, type, error);
4693 // Sets the buffer size.
4694 // <size>: the size of the buffer, or 0 to let GLib pick a good size
4695 void set_buffer_size()(size_t size) {
4696 g_io_channel_set_buffer_size(&this, size);
4699 // The buffering state can only be set if the channel's encoding
4700 // is %NULL. For any other encoding, the channel must be buffered.
4702 // A buffered channel can only be set unbuffered if the channel's
4703 // internal buffers have been flushed. Newly created channels or
4704 // channels which have returned %G_IO_STATUS_EOF
4705 // not require such a flush. For write-only channels, a call to
4706 // g_io_channel_flush () is sufficient. For all other channels,
4707 // the buffers may be flushed by a call to g_io_channel_seek_position ().
4708 // This includes the possibility of seeking with seek type %G_SEEK_CUR
4709 // and an offset of zero. Note that this means that socket-based
4710 // channels cannot be set unbuffered once they have had data
4711 // read from them.
4713 // On unbuffered channels, it is safe to mix read and write
4714 // calls from the new and old APIs, if this is necessary for
4715 // maintaining old code.
4717 // The default state of the channel is buffered.
4718 // <buffered>: whether to set the channel buffered or unbuffered
4719 void set_buffered()(int buffered) {
4720 g_io_channel_set_buffered(&this, buffered);
4723 // Setting this flag to %TRUE for a channel you have already closed
4724 // can cause problems.
4725 // <do_close>: Whether to close the channel on the final unref of the GIOChannel data structure. The default value of this is %TRUE for channels created by g_io_channel_new_file (), and %FALSE for all other channels.
4726 void set_close_on_unref()(int do_close) {
4727 g_io_channel_set_close_on_unref(&this, do_close);
4730 // Sets the encoding for the input/output of the channel.
4731 // The internal encoding is always UTF-8. The default encoding
4732 // for the external file is UTF-8.
4734 // The encoding %NULL is safe to use with binary data.
4736 // The encoding can only be set if one of the following conditions
4737 // is true:
4738 // <itemizedlist>
4739 // <listitem><para>
4740 // The channel was just created, and has not been written to or read
4741 // from yet.
4742 // </para></listitem>
4743 // <listitem><para>
4744 // The channel is write-only.
4745 // </para></listitem>
4746 // <listitem><para>
4747 // The channel is a file, and the file pointer was just
4748 // repositioned by a call to g_io_channel_seek_position().
4749 // (This flushes all the internal buffers.)
4750 // </para></listitem>
4751 // <listitem><para>
4752 // The current encoding is %NULL or UTF-8.
4753 // </para></listitem>
4754 // <listitem><para>
4755 // One of the (new API) read functions has just returned %G_IO_STATUS_EOF
4756 // (or, in the case of g_io_channel_read_to_end(), %G_IO_STATUS_NORMAL).
4757 // </para></listitem>
4758 // <listitem><para>
4759 // One of the functions g_io_channel_read_chars() or
4760 // g_io_channel_read_unichar() has returned %G_IO_STATUS_AGAIN or
4761 // %G_IO_STATUS_ERROR. This may be useful in the case of
4762 // %G_CONVERT_ERROR_ILLEGAL_SEQUENCE.
4763 // Returning one of these statuses from g_io_channel_read_line(),
4764 // g_io_channel_read_line_string(), or g_io_channel_read_to_end()
4765 // does <emphasis>not</emphasis> guarantee that the encoding can
4766 // be changed.
4767 // </para></listitem>
4768 // </itemizedlist>
4769 // Channels which do not meet one of the above conditions cannot call
4770 // g_io_channel_seek_position() with an offset of %G_SEEK_CUR, and, if
4771 // they are "seekable", cannot call g_io_channel_write_chars() after
4772 // calling one of the API "read" functions.
4773 // RETURNS: %G_IO_STATUS_NORMAL if the encoding was successfully set.
4774 // <encoding>: the encoding type
4775 IOStatus set_encoding()(char* encoding, GLib2.Error** error=null) {
4776 return g_io_channel_set_encoding(&this, encoding, error);
4779 // Sets the (writeable) flags in @channel to (@flags & %G_IO_FLAG_SET_MASK).
4780 // RETURNS: the status of the operation.
4781 // <flags>: the flags to set on the IO channel
4782 IOStatus set_flags()(IOFlags flags, GLib2.Error** error=null) {
4783 return g_io_channel_set_flags(&this, flags, error);
4786 // This sets the string that #GIOChannel uses to determine
4787 // where in the file a line break occurs.
4788 // <line_term>: The line termination string. Use %NULL for autodetect. Autodetection breaks on "\n", "\r\n", "\r", "\0", and the Unicode paragraph separator. Autodetection should not be used for anything other than file-based channels.
4789 // <length>: The length of the termination string. If -1 is passed, the string is assumed to be nul-terminated. This option allows termination strings with embedded nuls.
4790 void set_line_term()(char* line_term, int length) {
4791 g_io_channel_set_line_term(&this, line_term, length);
4794 // Close an IO channel. Any pending data to be written will be
4795 // flushed if @flush is %TRUE. The channel will not be freed until the
4796 // last reference is dropped using g_io_channel_unref().
4797 // RETURNS: the status of the operation.
4798 // <flush>: if %TRUE, flush pending
4799 IOStatus shutdown()(int flush, GLib2.Error** error=null) {
4800 return g_io_channel_shutdown(&this, flush, error);
4803 // Returns the file descriptor of the #GIOChannel.
4805 // On Windows this function returns the file descriptor or socket of
4806 // the #GIOChannel.
4807 int unix_get_fd()() {
4808 return g_io_channel_unix_get_fd(&this);
4810 // Decrements the reference count of a #GIOChannel.
4811 void unref()() {
4812 g_io_channel_unref(&this);
4815 // Writes data to a #GIOChannel.
4818 // Deprecated:2.2: Use g_io_channel_write_chars() instead.
4819 // RETURNS: %G_IO_ERROR_NONE if the operation was successful.
4820 // <buf>: the buffer containing the data to write
4821 // <count>: the number of bytes to write
4822 // <bytes_written>: the number of bytes actually written
4823 IOError write()(char* buf, size_t count, size_t* bytes_written) {
4824 return g_io_channel_write(&this, buf, count, bytes_written);
4827 // Replacement for g_io_channel_write() with the new API.
4829 // On seekable channels with encodings other than %NULL or UTF-8, generic
4830 // mixing of reading and writing is not allowed. A call to g_io_channel_write_chars ()
4831 // may only be made on a channel from which data has been read in the
4832 // cases described in the documentation for g_io_channel_set_encoding ().
4833 // RETURNS: the status of the operation.
4834 // <buf>: a buffer to write data from
4835 // <count>: the size of the buffer. If -1, the buffer is taken to be a nul-terminated string.
4836 // <bytes_written>: The number of bytes written. This can be nonzero even if the return value is not %G_IO_STATUS_NORMAL. If the return value is %G_IO_STATUS_NORMAL and the channel is blocking, this will always be equal to @count if @count >= 0.
4837 IOStatus write_chars()(char* buf, ssize_t count, size_t* bytes_written, GLib2.Error** error=null) {
4838 return g_io_channel_write_chars(&this, buf, count, bytes_written, error);
4841 // Writes a Unicode character to @channel.
4842 // This function cannot be called on a channel with %NULL encoding.
4843 // RETURNS: a #GIOStatus
4844 // <thechar>: a character
4845 IOStatus write_unichar()(dchar thechar, GLib2.Error** error=null) {
4846 return g_io_channel_write_unichar(&this, thechar, error);
4849 // Converts an <literal>errno</literal> error number to a #GIOChannelError.
4851 // %G_IO_CHANNEL_ERROR_INVAL.
4852 // RETURNS: a #GIOChannelError error number, e.g.
4853 // <en>: an <literal>errno</literal> error number, e.g. <literal>EINVAL</literal>
4854 static IOChannelError error_from_errno()(int en) {
4855 return g_io_channel_error_from_errno(en);
4857 // RETURNS: the quark used as %G_IO_CHANNEL_ERROR
4858 static Quark error_quark()() {
4859 return g_io_channel_error_quark();
4863 // Error codes returned by #GIOChannel operations.
4864 enum IOChannelError {
4865 FBIG = 0,
4866 INVAL = 1,
4867 IO = 2,
4868 ISDIR = 3,
4869 NOSPC = 4,
4870 NXIO = 5,
4871 OVERFLOW = 6,
4872 PIPE = 7,
4873 FAILED = 8
4876 // A bitwise combination representing a condition to watch for on an
4877 // event source.
4878 enum IOCondition {
4879 IN = 1,
4880 OUT = 4,
4881 PRI = 2,
4882 ERR = 8,
4883 HUP = 16,
4884 NVAL = 32
4887 // #GIOError is only used by the deprecated functions
4888 // g_io_channel_read(), g_io_channel_write(), and g_io_channel_seek().
4889 enum IOError {
4890 NONE = 0,
4891 AGAIN = 1,
4892 INVAL = 2,
4893 UNKNOWN = 3
4896 // Specifies properties of a #GIOChannel. Some of the flags can only be
4897 // read with g_io_channel_get_flags(), but not changed with
4898 // g_io_channel_set_flags().
4899 enum IOFlags {
4900 APPEND = 1,
4901 NONBLOCK = 2,
4902 IS_READABLE = 4,
4903 IS_WRITABLE = 8,
4904 IS_SEEKABLE = 16,
4905 MASK = 31,
4906 GET_MASK = 31,
4907 SET_MASK = 3
4910 // Specifies the type of function passed to g_io_add_watch() or
4911 // g_io_add_watch_full(), which is called when the requested condition
4912 // on a #GIOChannel is satisfied.
4913 // <source>: the #GIOChannel event source
4914 // <condition>: the condition which has been satisfied
4915 // <data>: user data set in g_io_add_watch() or g_io_add_watch_full()
4916 extern (C) alias int function (IOChannel* source, IOCondition condition, void* data) IOFunc;
4919 // A table of functions used to handle different types of #GIOChannel
4920 // in a generic way.
4921 struct IOFuncs {
4922 extern (C) IOStatus function (IOChannel* channel, char* buf, size_t count, size_t* bytes_read, GLib2.Error** error=null) io_read;
4923 extern (C) IOStatus function (IOChannel* channel, char* buf, size_t count, size_t* bytes_written, GLib2.Error** error=null) io_write;
4924 extern (C) IOStatus function (IOChannel* channel, long offset, SeekType type, GLib2.Error** error=null) io_seek;
4925 extern (C) IOStatus function (IOChannel* channel, GLib2.Error** error=null) io_close;
4926 extern (C) Source* /*new*/ function (IOChannel* channel, IOCondition condition) io_create_watch;
4927 extern (C) void function (IOChannel* channel) io_free;
4928 extern (C) IOStatus function (IOChannel* channel, IOFlags flags, GLib2.Error** error=null) io_set_flags;
4929 extern (C) IOFlags function (IOChannel* channel) io_get_flags;
4932 // Stati returned by most of the #GIOFuncs functions.
4933 enum IOStatus {
4934 ERROR = 0,
4935 NORMAL = 1,
4936 EOF = 2,
4937 AGAIN = 3
4939 enum KEY_FILE_DESKTOP_GROUP = "Desktop Entry";
4940 enum KEY_FILE_DESKTOP_KEY_CATEGORIES = "Categories";
4941 enum KEY_FILE_DESKTOP_KEY_COMMENT = "Comment";
4942 enum KEY_FILE_DESKTOP_KEY_EXEC = "Exec";
4943 enum KEY_FILE_DESKTOP_KEY_GENERIC_NAME = "GenericName";
4944 enum KEY_FILE_DESKTOP_KEY_HIDDEN = "Hidden";
4945 enum KEY_FILE_DESKTOP_KEY_ICON = "Icon";
4946 enum KEY_FILE_DESKTOP_KEY_MIME_TYPE = "MimeType";
4947 enum KEY_FILE_DESKTOP_KEY_NAME = "Name";
4948 enum KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN = "NotShowIn";
4949 enum KEY_FILE_DESKTOP_KEY_NO_DISPLAY = "NoDisplay";
4950 enum KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN = "OnlyShowIn";
4951 enum KEY_FILE_DESKTOP_KEY_PATH = "Path";
4952 enum KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY = "StartupNotify";
4953 enum KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS = "StartupWMClass";
4954 enum KEY_FILE_DESKTOP_KEY_TERMINAL = "Terminal";
4955 enum KEY_FILE_DESKTOP_KEY_TRY_EXEC = "TryExec";
4956 enum KEY_FILE_DESKTOP_KEY_TYPE = "Type";
4957 enum KEY_FILE_DESKTOP_KEY_URL = "URL";
4958 enum KEY_FILE_DESKTOP_KEY_VERSION = "Version";
4959 enum KEY_FILE_DESKTOP_TYPE_APPLICATION = "Application";
4960 enum KEY_FILE_DESKTOP_TYPE_DIRECTORY = "Directory";
4961 enum KEY_FILE_DESKTOP_TYPE_LINK = "Link";
4963 // The GKeyFile struct contains only private data
4964 // and should not be accessed directly.
4965 struct KeyFile {
4967 // VERSION: 2.6
4968 // Creates a new empty #GKeyFile object. Use
4969 // g_key_file_load_from_file(), g_key_file_load_from_data(),
4970 // g_key_file_load_from_dirs() or g_key_file_load_from_data_dirs() to
4971 // read an existing key file.
4972 // RETURNS: an empty #GKeyFile.
4973 static KeyFile* /*new*/ new_()() {
4974 return g_key_file_new();
4977 // Unintrospectable method: free() / g_key_file_free()
4978 // VERSION: 2.6
4979 // Clears all keys and groups from @key_file, and decreases the
4980 // reference count by 1. If the reference count reaches zero,
4981 // frees the key file and all its allocated memory.
4982 void free()() {
4983 g_key_file_free(&this);
4986 // VERSION: 2.6
4987 // Returns the value associated with @key under @group_name as a
4988 // boolean.
4990 // If @key cannot be found then %FALSE is returned and @error is set
4991 // to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value
4992 // associated with @key cannot be interpreted as a boolean then %FALSE
4993 // is returned and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
4995 // or %FALSE if the key was not found or could not be parsed.
4996 // RETURNS: the value associated with the key as a boolean,
4997 // <group_name>: a group name
4998 // <key>: a key
4999 int get_boolean()(char* group_name, char* key, GLib2.Error** error=null) {
5000 return g_key_file_get_boolean(&this, group_name, key, error);
5003 // VERSION: 2.6
5004 // Returns the values associated with @key under @group_name as
5005 // booleans.
5007 // If @key cannot be found then %NULL is returned and @error is set to
5008 // #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
5009 // with @key cannot be interpreted as booleans then %NULL is returned
5010 // and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
5012 // the values associated with the key as a list of booleans, or %NULL if the
5013 // key was not found or could not be parsed. The returned list of booleans
5014 // should be freed with g_free() when no longer needed.
5015 // <group_name>: a group name
5016 // <key>: a key
5017 // <length>: the number of booleans returned
5018 int* /*new container*/ get_boolean_list()(char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error=null) {
5019 return g_key_file_get_boolean_list(&this, group_name, key, length, error);
5022 // VERSION: 2.6
5023 // Retrieves a comment above @key from @group_name.
5024 // If @key is %NULL then @comment will be read from above
5025 // @group_name. If both @key and @group_name are %NULL, then
5026 // @comment will be read from above the first group in the file.
5027 // RETURNS: a comment that should be freed with g_free()
5028 // <group_name>: a group name, or %NULL
5029 // <key>: a key
5030 char* /*new*/ get_comment()(char* group_name, char* key, GLib2.Error** error=null) {
5031 return g_key_file_get_comment(&this, group_name, key, error);
5034 // VERSION: 2.12
5035 // Returns the value associated with @key under @group_name as a
5036 // double. If @group_name is %NULL, the start_group is used.
5038 // If @key cannot be found then 0.0 is returned and @error is set to
5039 // #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated
5040 // with @key cannot be interpreted as a double then 0.0 is returned
5041 // and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
5043 // 0.0 if the key was not found or could not be parsed.
5044 // RETURNS: the value associated with the key as a double, or
5045 // <group_name>: a group name
5046 // <key>: a key
5047 double get_double()(char* group_name, char* key, GLib2.Error** error=null) {
5048 return g_key_file_get_double(&this, group_name, key, error);
5051 // VERSION: 2.12
5052 // Returns the values associated with @key under @group_name as
5053 // doubles.
5055 // If @key cannot be found then %NULL is returned and @error is set to
5056 // #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
5057 // with @key cannot be interpreted as doubles then %NULL is returned
5058 // and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
5060 // the values associated with the key as a list of doubles, or %NULL if the
5061 // key was not found or could not be parsed. The returned list of doubles
5062 // should be freed with g_free() when no longer needed.
5063 // <group_name>: a group name
5064 // <key>: a key
5065 // <length>: the number of doubles returned
5066 double* /*new container*/ get_double_list()(char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error=null) {
5067 return g_key_file_get_double_list(&this, group_name, key, length, error);
5070 // VERSION: 2.6
5071 // Returns all groups in the key file loaded with @key_file.
5072 // The array of returned groups will be %NULL-terminated, so
5073 // @length may optionally be %NULL.
5075 // Use g_strfreev() to free it.
5076 // RETURNS: a newly-allocated %NULL-terminated array of strings.
5077 // <length>: return location for the number of returned groups, or %NULL
5078 char** /*new*/ get_groups()(/*out*/ size_t* length=null) {
5079 return g_key_file_get_groups(&this, length);
5082 // VERSION: 2.26
5083 // Returns the value associated with @key under @group_name as a signed
5084 // 64-bit integer. This is similar to g_key_file_get_integer() but can return
5085 // 64-bit results without truncation.
5087 // 0 if the key was not found or could not be parsed.
5088 // RETURNS: the value associated with the key as a signed 64-bit integer, or
5089 // <group_name>: a non-%NULL group name
5090 // <key>: a non-%NULL key
5091 long get_int64()(char* group_name, char* key, GLib2.Error** error=null) {
5092 return g_key_file_get_int64(&this, group_name, key, error);
5095 // VERSION: 2.6
5096 // Returns the value associated with @key under @group_name as an
5097 // integer.
5099 // If @key cannot be found then 0 is returned and @error is set to
5100 // #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated
5101 // with @key cannot be interpreted as an integer then 0 is returned
5102 // and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
5104 // 0 if the key was not found or could not be parsed.
5105 // RETURNS: the value associated with the key as an integer, or
5106 // <group_name>: a group name
5107 // <key>: a key
5108 int get_integer()(char* group_name, char* key, GLib2.Error** error=null) {
5109 return g_key_file_get_integer(&this, group_name, key, error);
5112 // VERSION: 2.6
5113 // Returns the values associated with @key under @group_name as
5114 // integers.
5116 // If @key cannot be found then %NULL is returned and @error is set to
5117 // #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
5118 // with @key cannot be interpreted as integers then %NULL is returned
5119 // and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
5121 // the values associated with the key as a list of integers, or %NULL if
5122 // the key was not found or could not be parsed. The returned list of
5123 // integers should be freed with g_free() when no longer needed.
5124 // <group_name>: a group name
5125 // <key>: a key
5126 // <length>: the number of integers returned
5127 int* /*new container*/ get_integer_list()(char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error=null) {
5128 return g_key_file_get_integer_list(&this, group_name, key, length, error);
5131 // VERSION: 2.6
5132 // Returns all keys for the group name @group_name. The array of
5133 // returned keys will be %NULL-terminated, so @length may
5134 // optionally be %NULL. In the event that the @group_name cannot
5135 // be found, %NULL is returned and @error is set to
5136 // #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
5138 // Use g_strfreev() to free it.
5139 // RETURNS: a newly-allocated %NULL-terminated array of strings.
5140 // <group_name>: a group name
5141 // <length>: return location for the number of keys returned, or %NULL
5142 char** /*new*/ get_keys()(char* group_name, /*out*/ size_t* length, GLib2.Error** error=null) {
5143 return g_key_file_get_keys(&this, group_name, length, error);
5146 // VERSION: 2.6
5147 // Returns the value associated with @key under @group_name
5148 // translated in the given @locale if available. If @locale is
5149 // %NULL then the current locale is assumed.
5151 // If @key cannot be found then %NULL is returned and @error is set
5152 // to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the value associated
5153 // with @key cannot be interpreted or no suitable translation can
5154 // be found then the untranslated value is returned.
5156 // key cannot be found.
5157 // RETURNS: a newly allocated string or %NULL if the specified
5158 // <group_name>: a group name
5159 // <key>: a key
5160 // <locale>: a locale identifier or %NULL
5161 char* /*new*/ get_locale_string()(char* group_name, char* key, char* locale, GLib2.Error** error=null) {
5162 return g_key_file_get_locale_string(&this, group_name, key, locale, error);
5165 // VERSION: 2.6
5166 // Returns the values associated with @key under @group_name
5167 // translated in the given @locale if available. If @locale is
5168 // %NULL then the current locale is assumed.
5169 // If @key cannot be found then %NULL is returned and @error is set
5170 // to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the values associated
5171 // with @key cannot be interpreted or no suitable translations
5172 // can be found then the untranslated values are returned. The
5173 // returned array is %NULL-terminated, so @length may optionally
5174 // be %NULL.
5176 // or %NULL if the key isn't found. The string array should be freed
5177 // with g_strfreev().
5178 // RETURNS: a newly allocated %NULL-terminated string array
5179 // <group_name>: a group name
5180 // <key>: a key
5181 // <locale>: a locale identifier or %NULL
5182 // <length>: return location for the number of returned strings or %NULL
5183 char** /*new*/ get_locale_string_list()(char* group_name, char* key, char* locale, /*out*/ size_t* length, GLib2.Error** error=null) {
5184 return g_key_file_get_locale_string_list(&this, group_name, key, locale, length, error);
5187 // VERSION: 2.6
5188 // Returns the name of the start group of the file.
5189 // RETURNS: The start group of the key file.
5190 char* /*new*/ get_start_group()() {
5191 return g_key_file_get_start_group(&this);
5194 // VERSION: 2.6
5195 // Returns the string value associated with @key under @group_name.
5196 // Unlike g_key_file_get_value(), this function handles escape sequences
5197 // like \s.
5199 // In the event the key cannot be found, %NULL is returned and
5200 // @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the
5201 // event that the @group_name cannot be found, %NULL is returned
5202 // and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
5204 // key cannot be found.
5205 // RETURNS: a newly allocated string or %NULL if the specified
5206 // <group_name>: a group name
5207 // <key>: a key
5208 char* /*new*/ get_string()(char* group_name, char* key, GLib2.Error** error=null) {
5209 return g_key_file_get_string(&this, group_name, key, error);
5212 // VERSION: 2.6
5213 // Returns the values associated with @key under @group_name.
5215 // In the event the key cannot be found, %NULL is returned and
5216 // @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the
5217 // event that the @group_name cannot be found, %NULL is returned
5218 // and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
5220 // a %NULL-terminated string array or %NULL if the specified
5221 // key cannot be found. The array should be freed with g_strfreev().
5222 // <group_name>: a group name
5223 // <key>: a key
5224 // <length>: return location for the number of returned strings, or %NULL
5225 char** /*new*/ get_string_list()(char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error=null) {
5226 return g_key_file_get_string_list(&this, group_name, key, length, error);
5229 // VERSION: 2.26
5230 // Returns the value associated with @key under @group_name as an unsigned
5231 // 64-bit integer. This is similar to g_key_file_get_integer() but can return
5232 // large positive results without truncation.
5234 // or 0 if the key was not found or could not be parsed.
5235 // RETURNS: the value associated with the key as an unsigned 64-bit integer,
5236 // <group_name>: a non-%NULL group name
5237 // <key>: a non-%NULL key
5238 ulong get_uint64()(char* group_name, char* key, GLib2.Error** error=null) {
5239 return g_key_file_get_uint64(&this, group_name, key, error);
5242 // VERSION: 2.6
5243 // Returns the raw value associated with @key under @group_name.
5244 // Use g_key_file_get_string() to retrieve an unescaped UTF-8 string.
5246 // In the event the key cannot be found, %NULL is returned and
5247 // @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the
5248 // event that the @group_name cannot be found, %NULL is returned
5249 // and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
5252 // key cannot be found.
5253 // RETURNS: a newly allocated string or %NULL if the specified
5254 // <group_name>: a group name
5255 // <key>: a key
5256 char* /*new*/ get_value()(char* group_name, char* key, GLib2.Error** error=null) {
5257 return g_key_file_get_value(&this, group_name, key, error);
5260 // VERSION: 2.6
5261 // Looks whether the key file has the group @group_name.
5263 // otherwise.
5264 // RETURNS: %TRUE if @group_name is a part of @key_file, %FALSE
5265 // <group_name>: a group name
5266 int has_group()(char* group_name) {
5267 return g_key_file_has_group(&this, group_name);
5270 // Unintrospectable method: has_key() / g_key_file_has_key()
5271 // VERSION: 2.6
5272 // Looks whether the key file has the key @key in the group
5273 // @group_name.
5275 // <note>This function does not follow the rules for #GError strictly;
5276 // the return value both carries meaning and signals an error. To use
5277 // this function, you must pass a #GError pointer in @error, and check
5278 // whether it is not %NULL to see if an error occurred.</note>
5280 // Language bindings should use g_key_file_get_value() to test whether
5281 // or not a key exists.
5283 // otherwise.
5284 // RETURNS: %TRUE if @key is a part of @group_name, %FALSE
5285 // <group_name>: a group name
5286 // <key>: a key name
5287 int has_key()(char* group_name, char* key, GLib2.Error** error=null) {
5288 return g_key_file_has_key(&this, group_name, key, error);
5291 // VERSION: 2.6
5292 // Loads a key file from memory into an empty #GKeyFile structure.
5293 // If the object cannot be created then %error is set to a #GKeyFileError.
5294 // RETURNS: %TRUE if a key file could be loaded, %FALSE otherwise
5295 // <data>: key file loaded in memory
5296 // <length>: the length of @data in bytes
5297 // <flags>: flags from #GKeyFileFlags
5298 int load_from_data()(char* data, size_t length, KeyFileFlags flags, GLib2.Error** error=null) {
5299 return g_key_file_load_from_data(&this, data, length, flags, error);
5302 // VERSION: 2.6
5303 // This function looks for a key file named @file in the paths
5304 // returned from g_get_user_data_dir() and g_get_system_data_dirs(),
5305 // loads the file into @key_file and returns the file's full path in
5306 // @full_path. If the file could not be loaded then an %error is
5307 // set to either a #GFileError or #GKeyFileError.
5308 // RETURNS: %TRUE if a key file could be loaded, %FALSE othewise
5309 // <file>: a relative path to a filename to open and parse
5310 // <full_path>: return location for a string containing the full path of the file, or %NULL
5311 // <flags>: flags from #GKeyFileFlags
5312 int load_from_data_dirs()(char* file, /*out*/ char** full_path, KeyFileFlags flags, GLib2.Error** error=null) {
5313 return g_key_file_load_from_data_dirs(&this, file, full_path, flags, error);
5316 // VERSION: 2.14
5317 // This function looks for a key file named @file in the paths
5318 // specified in @search_dirs, loads the file into @key_file and
5319 // returns the file's full path in @full_path. If the file could not
5320 // be loaded then an %error is set to either a #GFileError or
5321 // #GKeyFileError.
5322 // RETURNS: %TRUE if a key file could be loaded, %FALSE otherwise
5323 // <file>: a relative path to a filename to open and parse
5324 // <search_dirs>: %NULL-terminated array of directories to search
5325 // <full_path>: return location for a string containing the full path of the file, or %NULL
5326 // <flags>: flags from #GKeyFileFlags
5327 int load_from_dirs()(char* file, char** search_dirs, /*out*/ char** full_path, KeyFileFlags flags, GLib2.Error** error=null) {
5328 return g_key_file_load_from_dirs(&this, file, search_dirs, full_path, flags, error);
5331 // VERSION: 2.6
5332 // Loads a key file into an empty #GKeyFile structure.
5333 // If the file could not be loaded then %error is set to
5334 // either a #GFileError or #GKeyFileError.
5335 // RETURNS: %TRUE if a key file could be loaded, %FALSE otherwise
5336 // <file>: the path of a filename to load, in the GLib filename encoding
5337 // <flags>: flags from #GKeyFileFlags
5338 int load_from_file()(char* file, KeyFileFlags flags, GLib2.Error** error=null) {
5339 return g_key_file_load_from_file(&this, file, flags, error);
5342 // Unintrospectable method: ref() / g_key_file_ref()
5343 // VERSION: 2.32
5344 // Increases the reference count of @key_file.
5345 // RETURNS: the same @key_file.
5346 KeyFile* /*new*/ ref_()() {
5347 return g_key_file_ref(&this);
5350 // VERSION: 2.6
5351 // Removes a comment above @key from @group_name.
5352 // If @key is %NULL then @comment will be removed above @group_name.
5353 // If both @key and @group_name are %NULL, then @comment will
5354 // be removed above the first group in the file.
5355 // RETURNS: %TRUE if the comment was removed, %FALSE otherwise
5356 // <group_name>: a group name, or %NULL
5357 // <key>: a key
5358 int remove_comment()(char* group_name, char* key, GLib2.Error** error=null) {
5359 return g_key_file_remove_comment(&this, group_name, key, error);
5362 // VERSION: 2.6
5363 // Removes the specified group, @group_name,
5364 // from the key file.
5365 // RETURNS: %TRUE if the group was removed, %FALSE otherwise
5366 // <group_name>: a group name
5367 int remove_group()(char* group_name, GLib2.Error** error=null) {
5368 return g_key_file_remove_group(&this, group_name, error);
5371 // VERSION: 2.6
5372 // Removes @key in @group_name from the key file.
5373 // RETURNS: %TRUE if the key was removed, %FALSE otherwise
5374 // <group_name>: a group name
5375 // <key>: a key name to remove
5376 int remove_key()(char* group_name, char* key, GLib2.Error** error=null) {
5377 return g_key_file_remove_key(&this, group_name, key, error);
5380 // VERSION: 2.6
5381 // Associates a new boolean value with @key under @group_name.
5382 // If @key cannot be found then it is created.
5383 // <group_name>: a group name
5384 // <key>: a key
5385 // <value>: %TRUE or %FALSE
5386 void set_boolean()(char* group_name, char* key, int value) {
5387 g_key_file_set_boolean(&this, group_name, key, value);
5390 // VERSION: 2.6
5391 // Associates a list of boolean values with @key under @group_name.
5392 // If @key cannot be found then it is created.
5393 // If @group_name is %NULL, the start_group is used.
5394 // <group_name>: a group name
5395 // <key>: a key
5396 // <list>: an array of boolean values
5397 // <length>: length of @list
5398 void set_boolean_list()(char* group_name, char* key, int list, size_t length) {
5399 g_key_file_set_boolean_list(&this, group_name, key, list, length);
5402 // VERSION: 2.6
5403 // Places a comment above @key from @group_name.
5404 // If @key is %NULL then @comment will be written above @group_name.
5405 // If both @key and @group_name are %NULL, then @comment will be
5406 // written above the first group in the file.
5407 // RETURNS: %TRUE if the comment was written, %FALSE otherwise
5408 // <group_name>: a group name, or %NULL
5409 // <key>: a key
5410 // <comment>: a comment
5411 int set_comment()(char* group_name, char* key, char* comment, GLib2.Error** error=null) {
5412 return g_key_file_set_comment(&this, group_name, key, comment, error);
5415 // VERSION: 2.12
5416 // Associates a new double value with @key under @group_name.
5417 // If @key cannot be found then it is created.
5418 // <group_name>: a group name
5419 // <key>: a key
5420 // <value>: an double value
5421 void set_double()(char* group_name, char* key, double value) {
5422 g_key_file_set_double(&this, group_name, key, value);
5425 // VERSION: 2.12
5426 // Associates a list of double values with @key under
5427 // @group_name. If @key cannot be found then it is created.
5428 // <group_name>: a group name
5429 // <key>: a key
5430 // <list>: an array of double values
5431 // <length>: number of double values in @list
5432 void set_double_list()(char* group_name, char* key, double list, size_t length) {
5433 g_key_file_set_double_list(&this, group_name, key, list, length);
5436 // VERSION: 2.26
5437 // Associates a new integer value with @key under @group_name.
5438 // If @key cannot be found then it is created.
5439 // <group_name>: a group name
5440 // <key>: a key
5441 // <value>: an integer value
5442 void set_int64()(char* group_name, char* key, long value) {
5443 g_key_file_set_int64(&this, group_name, key, value);
5446 // VERSION: 2.6
5447 // Associates a new integer value with @key under @group_name.
5448 // If @key cannot be found then it is created.
5449 // <group_name>: a group name
5450 // <key>: a key
5451 // <value>: an integer value
5452 void set_integer()(char* group_name, char* key, int value) {
5453 g_key_file_set_integer(&this, group_name, key, value);
5456 // VERSION: 2.6
5457 // Associates a list of integer values with @key under @group_name.
5458 // If @key cannot be found then it is created.
5459 // <group_name>: a group name
5460 // <key>: a key
5461 // <list>: an array of integer values
5462 // <length>: number of integer values in @list
5463 void set_integer_list()(char* group_name, char* key, int list, size_t length) {
5464 g_key_file_set_integer_list(&this, group_name, key, list, length);
5467 // VERSION: 2.6
5468 // Sets the character which is used to separate
5469 // values in lists. Typically ';' or ',' are used
5470 // as separators. The default list separator is ';'.
5471 // <separator>: the separator
5472 void set_list_separator()(char separator) {
5473 g_key_file_set_list_separator(&this, separator);
5476 // VERSION: 2.6
5477 // Associates a string value for @key and @locale under @group_name.
5478 // If the translation for @key cannot be found then it is created.
5479 // <group_name>: a group name
5480 // <key>: a key
5481 // <locale>: a locale identifier
5482 // <string>: a string
5483 void set_locale_string()(char* group_name, char* key, char* locale, char* string_) {
5484 g_key_file_set_locale_string(&this, group_name, key, locale, string_);
5487 // VERSION: 2.6
5488 // Associates a list of string values for @key and @locale under
5489 // @group_name. If the translation for @key cannot be found then
5490 // it is created.
5491 // <group_name>: a group name
5492 // <key>: a key
5493 // <locale>: a locale identifier
5494 // <list>: a %NULL-terminated array of locale string values
5495 // <length>: the length of @list
5496 void set_locale_string_list()(char* group_name, char* key, char* locale, char* list, size_t length) {
5497 g_key_file_set_locale_string_list(&this, group_name, key, locale, list, length);
5500 // VERSION: 2.6
5501 // Associates a new string value with @key under @group_name.
5502 // If @key cannot be found then it is created.
5503 // If @group_name cannot be found then it is created.
5504 // Unlike g_key_file_set_value(), this function handles characters
5505 // that need escaping, such as newlines.
5506 // <group_name>: a group name
5507 // <key>: a key
5508 // <string>: a string
5509 void set_string()(char* group_name, char* key, char* string_) {
5510 g_key_file_set_string(&this, group_name, key, string_);
5513 // VERSION: 2.6
5514 // Associates a list of string values for @key under @group_name.
5515 // If @key cannot be found then it is created.
5516 // If @group_name cannot be found then it is created.
5517 // <group_name>: a group name
5518 // <key>: a key
5519 // <list>: an array of string values
5520 // <length>: number of string values in @list
5521 void set_string_list()(char* group_name, char* key, char* list, size_t length) {
5522 g_key_file_set_string_list(&this, group_name, key, list, length);
5525 // VERSION: 2.26
5526 // Associates a new integer value with @key under @group_name.
5527 // If @key cannot be found then it is created.
5528 // <group_name>: a group name
5529 // <key>: a key
5530 // <value>: an integer value
5531 void set_uint64()(char* group_name, char* key, ulong value) {
5532 g_key_file_set_uint64(&this, group_name, key, value);
5535 // VERSION: 2.6
5536 // Associates a new value with @key under @group_name.
5538 // If @key cannot be found then it is created. If @group_name cannot
5539 // be found then it is created. To set an UTF-8 string which may contain
5540 // characters that need escaping (such as newlines or spaces), use
5541 // g_key_file_set_string().
5542 // <group_name>: a group name
5543 // <key>: a key
5544 // <value>: a string
5545 void set_value()(char* group_name, char* key, char* value) {
5546 g_key_file_set_value(&this, group_name, key, value);
5549 // VERSION: 2.6
5550 // This function outputs @key_file as a string.
5552 // Note that this function never reports an error,
5553 // so it is safe to pass %NULL as @error.
5555 // the contents of the #GKeyFile
5556 // RETURNS: a newly allocated string holding
5557 // <length>: return location for the length of the returned string, or %NULL
5558 char* /*new*/ to_data()(/*out*/ size_t* length, GLib2.Error** error=null) {
5559 return g_key_file_to_data(&this, length, error);
5562 // VERSION: 2.32
5563 // Decreases the reference count of @key_file by 1. If the reference count
5564 // reaches zero, frees the key file and all its allocated memory.
5565 void unref()() {
5566 g_key_file_unref(&this);
5568 static Quark error_quark()() {
5569 return g_key_file_error_quark();
5573 // Error codes returned by key file parsing.
5574 enum KeyFileError {
5575 UNKNOWN_ENCODING = 0,
5576 PARSE = 1,
5577 NOT_FOUND = 2,
5578 KEY_NOT_FOUND = 3,
5579 GROUP_NOT_FOUND = 4,
5580 INVALID_VALUE = 5
5582 // Flags which influence the parsing.
5583 enum KeyFileFlags {
5584 NONE = 0,
5585 KEEP_COMMENTS = 1,
5586 KEEP_TRANSLATIONS = 2
5588 enum int LITTLE_ENDIAN = 1234;
5589 enum double LN10 = 2.302585;
5590 enum double LN2 = 0.693147;
5591 enum double LOG_2_BASE_10 = 0.301030;
5592 enum int LOG_FATAL_MASK = 0;
5593 enum int LOG_LEVEL_USER_SHIFT = 8;
5594 // The #GList struct is used for each element in a doubly-linked list.
5595 struct List {
5596 void* data;
5597 GLib2.List* next, prev;
5600 // Unintrospectable function: alloc() / g_list_alloc()
5601 // Allocates space for one #GList element. It is called by
5602 // g_list_append(), g_list_prepend(), g_list_insert() and
5603 // g_list_insert_sorted() and so is rarely used on its own.
5604 static GLib2.List* alloc()() {
5605 return g_list_alloc();
5608 // Unintrospectable function: append() / g_list_append()
5609 // Adds a new element on to the end of the list.
5611 // <note><para>
5612 // The return value is the new start of the list, which
5613 // may have changed, so make sure you store the new value.
5614 // </para></note>
5616 // <note><para>
5617 // Note that g_list_append() has to traverse the entire list
5618 // to find the end, which is inefficient when adding multiple
5619 // elements. A common idiom to avoid the inefficiency is to prepend
5620 // the elements and reverse the list when all elements have been added.
5621 // </para></note>
5623 // |[
5624 // /&ast; Notice that these are initialized to the empty list. &ast;/
5625 // GList *list = NULL, *number_list = NULL;
5627 // /&ast; This is a list of strings. &ast;/
5628 // list = g_list_append (list, "first");
5629 // list = g_list_append (list, "second");
5631 // /&ast; This is a list of integers. &ast;/
5632 // number_list = g_list_append (number_list, GINT_TO_POINTER (27));
5633 // number_list = g_list_append (number_list, GINT_TO_POINTER (14));
5634 // ]|
5635 // RETURNS: the new start of the #GList
5636 // <list>: a pointer to a #GList
5637 // <data>: the data for the new element
5638 static GLib2.List* append()(GLib2.List* list, void* data) {
5639 return g_list_append(list, data);
5642 // Unintrospectable function: concat() / g_list_concat()
5643 // Adds the second #GList onto the end of the first #GList.
5644 // Note that the elements of the second #GList are not copied.
5645 // They are used directly.
5646 // RETURNS: the start of the new #GList
5647 // <list1>: a #GList
5648 // <list2>: the #GList to add to the end of the first #GList
5649 static GLib2.List* concat()(GLib2.List* list1, GLib2.List* list2) {
5650 return g_list_concat(list1, list2);
5653 // Unintrospectable function: copy() / g_list_copy()
5654 // Copies a #GList.
5656 // <note><para>
5657 // Note that this is a "shallow" copy. If the list elements
5658 // consist of pointers to data, the pointers are copied but
5659 // the actual data is not.
5660 // </para></note>
5661 // RETURNS: a copy of @list
5662 // <list>: a #GList
5663 static GLib2.List* copy()(GLib2.List* list) {
5664 return g_list_copy(list);
5667 // Unintrospectable function: delete_link() / g_list_delete_link()
5668 // Removes the node link_ from the list and frees it.
5669 // Compare this to g_list_remove_link() which removes the node
5670 // without freeing it.
5671 // RETURNS: the new head of @list
5672 // <list>: a #GList
5673 // <link_>: node to delete from @list
5674 static GLib2.List* delete_link()(GLib2.List* list, GLib2.List* link_) {
5675 return g_list_delete_link(list, link_);
5678 // Unintrospectable function: find() / g_list_find()
5679 // Finds the element in a #GList which
5680 // contains the given data.
5682 // or %NULL if it is not found
5683 // RETURNS: the found #GList element,
5684 // <list>: a #GList
5685 // <data>: the element data to find
5686 static GLib2.List* find()(GLib2.List* list, const(void)* data) {
5687 return g_list_find(list, data);
5690 // Unintrospectable function: find_custom() / g_list_find_custom()
5691 // Finds an element in a #GList, using a supplied function to
5692 // find the desired element. It iterates over the list, calling
5693 // the given function which should return 0 when the desired
5694 // element is found. The function takes two #gconstpointer arguments,
5695 // the #GList element's data as the first argument and the
5696 // given user data.
5697 // RETURNS: the found #GList element, or %NULL if it is not found
5698 // <list>: a #GList
5699 // <data>: user data passed to the function
5700 // <func>: the function to call for each element. It should return 0 when the desired element is found
5701 static GLib2.List* find_custom()(GLib2.List* list, const(void)* data, CompareFunc func) {
5702 return g_list_find_custom(list, data, func);
5705 // Unintrospectable function: first() / g_list_first()
5706 // Gets the first element in a #GList.
5708 // or %NULL if the #GList has no elements
5709 // RETURNS: the first element in the #GList,
5710 // <list>: a #GList
5711 static GLib2.List* first()(GLib2.List* list) {
5712 return g_list_first(list);
5715 // Unintrospectable function: foreach() / g_list_foreach()
5716 // Calls a function for each element of a #GList.
5717 // <list>: a #GList
5718 // <func>: the function to call with each element's data
5719 // <user_data>: user data to pass to the function
5720 static void foreach_()(GLib2.List* list, Func func, void* user_data) {
5721 g_list_foreach(list, func, user_data);
5724 // Unintrospectable function: free() / g_list_free()
5725 // Frees all of the memory used by a #GList.
5726 // The freed elements are returned to the slice allocator.
5728 // <note><para>
5729 // If list elements contain dynamically-allocated memory,
5730 // you should either use g_list_free_full() or free them manually
5731 // first.
5732 // </para></note>
5733 // <list>: a #GList
5734 static void free()(GLib2.List* list) {
5735 g_list_free(list);
5738 // Unintrospectable function: free_1() / g_list_free_1()
5739 // Frees one #GList element.
5740 // It is usually used after g_list_remove_link().
5741 // <list>: a #GList element
5742 static void free_1()(GLib2.List* list) {
5743 g_list_free_1(list);
5746 // Unintrospectable function: free_full() / g_list_free_full()
5747 // VERSION: 2.28
5748 // Convenience method, which frees all the memory used by a #GList, and
5749 // calls the specified destroy function on every element's data.
5750 // <list>: a pointer to a #GList
5751 // <free_func>: the function to be called to free each element's data
5752 static void free_full()(GLib2.List* list, DestroyNotify free_func) {
5753 g_list_free_full(list, free_func);
5756 // Unintrospectable function: index() / g_list_index()
5757 // Gets the position of the element containing
5758 // the given data (starting from 0).
5760 // or -1 if the data is not found
5761 // RETURNS: the index of the element containing the data,
5762 // <list>: a #GList
5763 // <data>: the data to find
5764 static int index()(GLib2.List* list, const(void)* data) {
5765 return g_list_index(list, data);
5768 // Unintrospectable function: insert() / g_list_insert()
5769 // Inserts a new element into the list at the given position.
5770 // RETURNS: the new start of the #GList
5771 // <list>: a pointer to a #GList
5772 // <data>: the data for the new element
5773 // <position>: the position to insert the element. If this is negative, or is larger than the number of elements in the list, the new element is added on to the end of the list.
5774 static GLib2.List* insert()(GLib2.List* list, void* data, int position) {
5775 return g_list_insert(list, data, position);
5778 // Unintrospectable function: insert_before() / g_list_insert_before()
5779 // Inserts a new element into the list before the given position.
5780 // RETURNS: the new start of the #GList
5781 // <list>: a pointer to a #GList
5782 // <sibling>: the list element before which the new element is inserted or %NULL to insert at the end of the list
5783 // <data>: the data for the new element
5784 static GLib2.List* insert_before()(GLib2.List* list, GLib2.List* sibling, void* data) {
5785 return g_list_insert_before(list, sibling, data);
5788 // Unintrospectable function: insert_sorted() / g_list_insert_sorted()
5789 // Inserts a new element into the list, using the given comparison
5790 // function to determine its position.
5791 // RETURNS: the new start of the #GList
5792 // <list>: a pointer to a #GList
5793 // <data>: the data for the new element
5794 // <func>: the function to compare elements in the list. It should return a number > 0 if the first parameter comes after the second parameter in the sort order.
5795 static GLib2.List* insert_sorted()(GLib2.List* list, void* data, CompareFunc func) {
5796 return g_list_insert_sorted(list, data, func);
5799 // Unintrospectable function: insert_sorted_with_data() / g_list_insert_sorted_with_data()
5800 // VERSION: 2.10
5801 // Inserts a new element into the list, using the given comparison
5802 // function to determine its position.
5803 // RETURNS: the new start of the #GList
5804 // <list>: a pointer to a #GList
5805 // <data>: the data for the new element
5806 // <func>: the function to compare elements in the list. It should return a number > 0 if the first parameter comes after the second parameter in the sort order.
5807 // <user_data>: user data to pass to comparison function.
5808 static GLib2.List* insert_sorted_with_data()(GLib2.List* list, void* data, CompareDataFunc func, void* user_data) {
5809 return g_list_insert_sorted_with_data(list, data, func, user_data);
5812 // Unintrospectable function: last() / g_list_last()
5813 // Gets the last element in a #GList.
5815 // or %NULL if the #GList has no elements
5816 // RETURNS: the last element in the #GList,
5817 // <list>: a #GList
5818 static GLib2.List* last()(GLib2.List* list) {
5819 return g_list_last(list);
5822 // Unintrospectable function: length() / g_list_length()
5823 // Gets the number of elements in a #GList.
5825 // <note><para>
5826 // This function iterates over the whole list to
5827 // count its elements.
5828 // </para></note>
5829 // RETURNS: the number of elements in the #GList
5830 // <list>: a #GList
5831 static uint length()(GLib2.List* list) {
5832 return g_list_length(list);
5835 // Unintrospectable function: nth() / g_list_nth()
5836 // Gets the element at the given position in a #GList.
5838 // the end of the #GList
5839 // RETURNS: the element, or %NULL if the position is off
5840 // <list>: a #GList
5841 // <n>: the position of the element, counting from 0
5842 static GLib2.List* nth()(GLib2.List* list, uint n) {
5843 return g_list_nth(list, n);
5846 // Unintrospectable function: nth_data() / g_list_nth_data()
5847 // Gets the data of the element at the given position.
5849 // is off the end of the #GList
5850 // RETURNS: the element's data, or %NULL if the position
5851 // <list>: a #GList
5852 // <n>: the position of the element
5853 static void* nth_data()(GLib2.List* list, uint n) {
5854 return g_list_nth_data(list, n);
5857 // Unintrospectable function: nth_prev() / g_list_nth_prev()
5858 // Gets the element @n places before @list.
5860 // off the end of the #GList
5861 // RETURNS: the element, or %NULL if the position is
5862 // <list>: a #GList
5863 // <n>: the position of the element, counting from 0
5864 static GLib2.List* nth_prev()(GLib2.List* list, uint n) {
5865 return g_list_nth_prev(list, n);
5868 // Unintrospectable function: position() / g_list_position()
5869 // Gets the position of the given element
5870 // in the #GList (starting from 0).
5872 // or -1 if the element is not found
5873 // RETURNS: the position of the element in the #GList,
5874 // <list>: a #GList
5875 // <llink>: an element in the #GList
5876 static int position()(GLib2.List* list, GLib2.List* llink) {
5877 return g_list_position(list, llink);
5880 // Unintrospectable function: prepend() / g_list_prepend()
5881 // Adds a new element on to the start of the list.
5883 // <note><para>
5884 // The return value is the new start of the list, which
5885 // may have changed, so make sure you store the new value.
5886 // </para></note>
5888 // |[
5889 // /&ast; Notice that it is initialized to the empty list. &ast;/
5890 // GList *list = NULL;
5891 // list = g_list_prepend (list, "last");
5892 // list = g_list_prepend (list, "first");
5893 // ]|
5894 // RETURNS: the new start of the #GList
5895 // <list>: a pointer to a #GList
5896 // <data>: the data for the new element
5897 static GLib2.List* prepend()(GLib2.List* list, void* data) {
5898 return g_list_prepend(list, data);
5901 // Unintrospectable function: remove() / g_list_remove()
5902 // Removes an element from a #GList.
5903 // If two elements contain the same data, only the first is removed.
5904 // If none of the elements contain the data, the #GList is unchanged.
5905 // RETURNS: the new start of the #GList
5906 // <list>: a #GList
5907 // <data>: the data of the element to remove
5908 static GLib2.List* remove()(GLib2.List* list, const(void)* data) {
5909 return g_list_remove(list, data);
5912 // Unintrospectable function: remove_all() / g_list_remove_all()
5913 // Removes all list nodes with data equal to @data.
5914 // Returns the new head of the list. Contrast with
5915 // g_list_remove() which removes only the first node
5916 // matching the given data.
5917 // RETURNS: new head of @list
5918 // <list>: a #GList
5919 // <data>: data to remove
5920 static GLib2.List* remove_all()(GLib2.List* list, const(void)* data) {
5921 return g_list_remove_all(list, data);
5924 // Unintrospectable function: remove_link() / g_list_remove_link()
5925 // Removes an element from a #GList, without freeing the element.
5926 // The removed element's prev and next links are set to %NULL, so
5927 // that it becomes a self-contained list with one element.
5928 // RETURNS: the new start of the #GList, without the element
5929 // <list>: a #GList
5930 // <llink>: an element in the #GList
5931 static GLib2.List* remove_link()(GLib2.List* list, GLib2.List* llink) {
5932 return g_list_remove_link(list, llink);
5935 // Unintrospectable function: reverse() / g_list_reverse()
5936 // Reverses a #GList.
5937 // It simply switches the next and prev pointers of each element.
5938 // RETURNS: the start of the reversed #GList
5939 // <list>: a #GList
5940 static GLib2.List* reverse()(GLib2.List* list) {
5941 return g_list_reverse(list);
5944 // Unintrospectable function: sort() / g_list_sort()
5945 // Sorts a #GList using the given comparison function. The algorithm
5946 // used is a stable sort.
5947 // RETURNS: the start of the sorted #GList
5948 // <list>: a #GList
5949 // <compare_func>: the comparison function used to sort the #GList. This function is passed the data from 2 elements of the #GList and should return 0 if they are equal, a negative value if the first element comes before the second, or a positive value if the first element comes after the second.
5950 static GLib2.List* sort()(GLib2.List* list, CompareFunc compare_func) {
5951 return g_list_sort(list, compare_func);
5954 // Unintrospectable function: sort_with_data() / g_list_sort_with_data()
5955 // Like g_list_sort(), but the comparison function accepts
5956 // a user data argument.
5957 // RETURNS: the new head of @list
5958 // <list>: a #GList
5959 // <compare_func>: comparison function
5960 // <user_data>: user data to pass to comparison function
5961 static GLib2.List* sort_with_data()(GLib2.List* list, CompareDataFunc compare_func, void* user_data) {
5962 return g_list_sort_with_data(list, compare_func, user_data);
5967 // Specifies the prototype of log handler functions.
5968 // <log_domain>: the log domain of the message
5969 // <log_level>: the log level of the message (including the fatal and recursion flags)
5970 // <message>: the message to process
5971 // <user_data>: user data, set in g_log_set_handler()
5972 extern (C) alias void function (char* log_domain, LogLevelFlags log_level, char* message, void* user_data) LogFunc;
5975 // Flags specifying the level of log messages.
5977 // It is possible to change how GLib treats messages of the various
5978 // levels using g_log_set_handler() and g_log_set_fatal_mask().
5979 enum LogLevelFlags {
5980 FLAG_RECURSION = 1,
5981 FLAG_FATAL = 2,
5982 LEVEL_ERROR = 4,
5983 LEVEL_CRITICAL = 8,
5984 LEVEL_WARNING = 16,
5985 LEVEL_MESSAGE = 32,
5986 LEVEL_INFO = 64,
5987 LEVEL_DEBUG = 128,
5988 LEVEL_MASK = -4
5990 enum int MAJOR_VERSION = 2;
5991 enum int MICRO_VERSION = 16;
5992 enum int MINOR_VERSION = 31;
5993 enum MODULE_SUFFIX = "so";
5995 // The <structname>GMainContext</structname> struct is an opaque data
5996 // type representing a set of sources to be handled in a main loop.
5997 struct MainContext {
5999 // Creates a new #GMainContext structure.
6000 // RETURNS: the new #GMainContext
6001 static MainContext* /*new*/ new_()() {
6002 return g_main_context_new();
6005 // Tries to become the owner of the specified context.
6006 // If some other thread is the owner of the context,
6007 // returns %FALSE immediately. Ownership is properly
6008 // recursive: the owner can require ownership again
6009 // and will release ownership when g_main_context_release()
6010 // is called as many times as g_main_context_acquire().
6012 // You must be the owner of a context before you
6013 // can call g_main_context_prepare(), g_main_context_query(),
6014 // g_main_context_check(), g_main_context_dispatch().
6016 // this thread is now the owner of @context.
6017 // RETURNS: %TRUE if the operation succeeded, and
6018 int acquire()() {
6019 return g_main_context_acquire(&this);
6022 // Adds a file descriptor to the set of file descriptors polled for
6023 // this context. This will very seldom be used directly. Instead
6024 // a typical event source will use g_source_add_poll() instead.
6025 // <fd>: a #GPollFD structure holding information about a file descriptor to watch.
6026 // <priority>: the priority for this file descriptor which should be the same as the priority used for g_source_attach() to ensure that the file descriptor is polled whenever the results may be needed.
6027 void add_poll()(PollFD* fd, int priority) {
6028 g_main_context_add_poll(&this, fd, priority);
6031 // Passes the results of polling back to the main loop.
6032 // RETURNS: %TRUE if some sources are ready to be dispatched.
6033 // <max_priority>: the maximum numerical priority of sources to check
6034 // <fds>: array of #GPollFD's that was passed to the last call to g_main_context_query()
6035 // <n_fds>: return value of g_main_context_query()
6036 int check()(int max_priority, PollFD* fds, int n_fds) {
6037 return g_main_context_check(&this, max_priority, fds, n_fds);
6039 // Dispatches all pending sources.
6040 void dispatch()() {
6041 g_main_context_dispatch(&this);
6044 // Finds a source with the given source functions and user data. If
6045 // multiple sources exist with the same source function and user data,
6046 // the first one found will be returned.
6047 // RETURNS: the source, if one was found, otherwise %NULL
6048 // <funcs>: the @source_funcs passed to g_source_new().
6049 // <user_data>: the user data from the callback.
6050 Source* find_source_by_funcs_user_data()(SourceFuncs* funcs, void* user_data) {
6051 return g_main_context_find_source_by_funcs_user_data(&this, funcs, user_data);
6054 // Finds a #GSource given a pair of context and ID.
6055 // RETURNS: the #GSource if found, otherwise, %NULL
6056 // <source_id>: the source ID, as returned by g_source_get_id().
6057 Source* find_source_by_id()(uint source_id) {
6058 return g_main_context_find_source_by_id(&this, source_id);
6061 // Finds a source with the given user data for the callback. If
6062 // multiple sources exist with the same user data, the first
6063 // one found will be returned.
6064 // RETURNS: the source, if one was found, otherwise %NULL
6065 // <user_data>: the user_data for the callback.
6066 Source* find_source_by_user_data()(void* user_data) {
6067 return g_main_context_find_source_by_user_data(&this, user_data);
6070 // Unintrospectable method: get_poll_func() / g_main_context_get_poll_func()
6071 // Gets the poll function set by g_main_context_set_poll_func().
6072 // RETURNS: the poll function
6073 PollFunc get_poll_func()() {
6074 return g_main_context_get_poll_func(&this);
6077 // Unintrospectable method: invoke() / g_main_context_invoke()
6078 // VERSION: 2.28
6079 // Invokes a function in such a way that @context is owned during the
6080 // invocation of @function.
6082 // If @context is %NULL then the global default main context — as
6083 // returned by g_main_context_default() — is used.
6085 // If @context is owned by the current thread, @function is called
6086 // directly. Otherwise, if @context is the thread-default main context
6087 // of the current thread and g_main_context_acquire() succeeds, then
6088 // @function is called and g_main_context_release() is called
6089 // afterwards.
6091 // In any other case, an idle source is created to call @function and
6092 // that source is attached to @context (presumably to be run in another
6093 // thread). The idle source is attached with #G_PRIORITY_DEFAULT
6094 // priority. If you want a different priority, use
6095 // g_main_context_invoke_full().
6097 // Note that, as with normal idle functions, @function should probably
6098 // return %FALSE. If it returns %TRUE, it will be continuously run in a
6099 // loop (and may prevent this call from returning).
6100 // <function>: function to call
6101 // <data>: data to pass to @function
6102 void invoke()(SourceFunc function_, void* data) {
6103 g_main_context_invoke(&this, function_, data);
6106 // VERSION: 2.28
6107 // Invokes a function in such a way that @context is owned during the
6108 // invocation of @function.
6110 // This function is the same as g_main_context_invoke() except that it
6111 // lets you specify the priority incase @function ends up being
6112 // scheduled as an idle and also lets you give a #GDestroyNotify for @data.
6114 // @notify should not assume that it is called from any particular
6115 // thread or with any particular context acquired.
6116 // <priority>: the priority at which to run @function
6117 // <function>: function to call
6118 // <data>: data to pass to @function
6119 // <notify>: a function to call when @data is no longer in use, or %NULL.
6120 void invoke_full()(int priority, SourceFunc function_, void* data, DestroyNotify notify) {
6121 g_main_context_invoke_full(&this, priority, function_, data, notify);
6124 // VERSION: 2.10
6125 // Determines whether this thread holds the (recursive)
6126 // ownership of this #GMainContext. This is useful to
6127 // know before waiting on another thread that may be
6128 // blocking to get ownership of @context.
6129 // RETURNS: %TRUE if current thread is owner of @context.
6130 int is_owner()() {
6131 return g_main_context_is_owner(&this);
6134 // Runs a single iteration for the given main loop. This involves
6135 // checking to see if any event sources are ready to be processed,
6136 // then if no events sources are ready and @may_block is %TRUE, waiting
6137 // for a source to become ready, then dispatching the highest priority
6138 // events sources that are ready. Otherwise, if @may_block is %FALSE
6139 // sources are not waited to become ready, only those highest priority
6140 // events sources will be dispatched (if any), that are ready at this
6141 // given moment without further waiting.
6143 // Note that even when @may_block is %TRUE, it is still possible for
6144 // g_main_context_iteration() to return %FALSE, since the the wait may
6145 // be interrupted for other reasons than an event source becoming ready.
6146 // RETURNS: %TRUE if events were dispatched.
6147 // <may_block>: whether the call may block.
6148 int iteration()(int may_block) {
6149 return g_main_context_iteration(&this, may_block);
6152 // Checks if any sources have pending events for the given context.
6153 // RETURNS: %TRUE if events are pending.
6154 int pending()() {
6155 return g_main_context_pending(&this);
6158 // VERSION: 2.22
6159 // Pops @context off the thread-default context stack (verifying that
6160 // it was on the top of the stack).
6161 void pop_thread_default()() {
6162 g_main_context_pop_thread_default(&this);
6165 // Prepares to poll sources within a main loop. The resulting information
6166 // for polling is determined by calling g_main_context_query ().
6168 // prior to polling.
6169 // RETURNS: %TRUE if some source is ready to be dispatched
6170 // <priority>: location to store priority of highest priority source already ready.
6171 int prepare()(int* priority) {
6172 return g_main_context_prepare(&this, priority);
6175 // VERSION: 2.22
6176 // Acquires @context and sets it as the thread-default context for the
6177 // current thread. This will cause certain asynchronous operations
6178 // (such as most <link linkend="gio">gio</link>-based I/O) which are
6179 // started in this thread to run under @context and deliver their
6180 // results to its main loop, rather than running under the global
6181 // default context in the main thread. Note that calling this function
6182 // changes the context returned by
6183 // g_main_context_get_thread_default(), <emphasis>not</emphasis> the
6184 // one returned by g_main_context_default(), so it does not affect the
6185 // context used by functions like g_idle_add().
6187 // Normally you would call this function shortly after creating a new
6188 // thread, passing it a #GMainContext which will be run by a
6189 // #GMainLoop in that thread, to set a new default context for all
6190 // async operations in that thread. (In this case, you don't need to
6191 // ever call g_main_context_pop_thread_default().) In some cases
6192 // however, you may want to schedule a single operation in a
6193 // non-default context, or temporarily use a non-default context in
6194 // the main thread. In that case, you can wrap the call to the
6195 // asynchronous operation inside a
6196 // g_main_context_push_thread_default() /
6197 // g_main_context_pop_thread_default() pair, but it is up to you to
6198 // ensure that no other asynchronous operations accidentally get
6199 // started while the non-default context is active.
6201 // Beware that libraries that predate this function may not correctly
6202 // handle being used from a thread with a thread-default context. Eg,
6203 // see g_file_supports_thread_contexts().
6204 void push_thread_default()() {
6205 g_main_context_push_thread_default(&this);
6208 // Determines information necessary to poll this main loop.
6210 // or, if more than @n_fds records need to be stored, the number
6211 // of records that need to be stored.
6212 // RETURNS: the number of records actually stored in @fds,
6213 // <max_priority>: maximum priority source to check
6214 // <timeout_>: location to store timeout to be used in polling
6215 // <fds>: location to store #GPollFD records that need to be polled.
6216 // <n_fds>: length of @fds.
6217 int query()(int max_priority, /*out*/ int* timeout_, /*out*/ PollFD* fds, /*out*/ int n_fds) {
6218 return g_main_context_query(&this, max_priority, timeout_, fds, n_fds);
6221 // Increases the reference count on a #GMainContext object by one.
6222 // RETURNS: the @context that was passed in (since 2.6)
6223 MainContext* /*new*/ ref_()() {
6224 return g_main_context_ref(&this);
6227 // Releases ownership of a context previously acquired by this thread
6228 // with g_main_context_acquire(). If the context was acquired multiple
6229 // times, the ownership will be released only when g_main_context_release()
6230 // is called as many times as it was acquired.
6231 void release()() {
6232 g_main_context_release(&this);
6235 // Removes file descriptor from the set of file descriptors to be
6236 // polled for a particular context.
6237 // <fd>: a #GPollFD descriptor previously added with g_main_context_add_poll()
6238 void remove_poll()(PollFD* fd) {
6239 g_main_context_remove_poll(&this, fd);
6242 // Unintrospectable method: set_poll_func() / g_main_context_set_poll_func()
6243 // Sets the function to use to handle polling of file descriptors. It
6244 // will be used instead of the poll() system call
6245 // (or GLib's replacement function, which is used where
6246 // poll() isn't available).
6248 // This function could possibly be used to integrate the GLib event
6249 // loop with an external event loop.
6250 // <func>: the function to call to poll all file descriptors
6251 void set_poll_func()(PollFunc func) {
6252 g_main_context_set_poll_func(&this, func);
6255 // Decreases the reference count on a #GMainContext object by one. If
6256 // the result is zero, free the context and free all associated memory.
6257 void unref()() {
6258 g_main_context_unref(&this);
6261 // Tries to become the owner of the specified context,
6262 // as with g_main_context_acquire(). But if another thread
6263 // is the owner, atomically drop @mutex and wait on @cond until
6264 // that owner releases ownership or until @cond is signaled, then
6265 // try again (once) to become the owner.
6267 // this thread is now the owner of @context.
6268 // RETURNS: %TRUE if the operation succeeded, and
6269 // <cond>: a condition variable
6270 // <mutex>: a mutex, currently held
6271 int wait()(Cond* cond, Mutex* mutex) {
6272 return g_main_context_wait(&this, cond, mutex);
6275 // If @context is currently waiting in a poll(), interrupt
6276 // the poll(), and continue the iteration process.
6277 void wakeup()() {
6278 g_main_context_wakeup(&this);
6281 // Returns the global default main context. This is the main context
6282 // used for main loop functions when a main loop is not explicitly
6283 // specified, and corresponds to the "main" main loop. See also
6284 // g_main_context_get_thread_default().
6285 // RETURNS: the global default main context.
6286 static MainContext* default_()() {
6287 return g_main_context_default();
6290 // VERSION: 2.22
6291 // Gets the thread-default #GMainContext for this thread. Asynchronous
6292 // operations that want to be able to be run in contexts other than
6293 // the default one should call this method or
6294 // g_main_context_ref_thread_default() to get a #GMainContext to add
6295 // their #GSource<!-- -->s to. (Note that even in single-threaded
6296 // programs applications may sometimes want to temporarily push a
6297 // non-default context, so it is not safe to assume that this will
6298 // always return %NULL if you are running in the default thread.)
6300 // If you need to hold a reference on the context, use
6301 // g_main_context_ref_thread_default() instead.
6303 // %NULL if the thread-default context is the global default context.
6304 // RETURNS: the thread-default #GMainContext, or
6305 static MainContext* get_thread_default()() {
6306 return g_main_context_get_thread_default();
6309 // VERSION: 2.32
6310 // Gets the thread-default #GMainContext for this thread, as with
6311 // g_main_context_get_thread_default(), but also adds a reference to
6312 // it with g_main_context_ref(). In addition, unlike
6313 // g_main_context_get_thread_default(), if the thread-default context
6314 // is the global default context, this will return that #GMainContext
6315 // (with a ref added to it) rather than returning %NULL.
6317 // with g_main_context_unref() when you are done with it.
6318 // RETURNS: the thread-default #GMainContext. Unref
6319 static MainContext* /*new*/ ref_thread_default()() {
6320 return g_main_context_ref_thread_default();
6325 // The <structname>GMainLoop</structname> struct is an opaque data type
6326 // representing the main event loop of a GLib or GTK+ application.
6327 struct MainLoop {
6329 // Creates a new #GMainLoop structure.
6330 // RETURNS: a new #GMainLoop.
6331 // <context>: a #GMainContext (if %NULL, the default context will be used).
6332 // <is_running>: set to %TRUE to indicate that the loop is running. This is not very important since calling g_main_loop_run() will set this to %TRUE anyway.
6333 static MainLoop* /*new*/ new_()(MainContext* context, int is_running) {
6334 return g_main_loop_new(context, is_running);
6337 // Returns the #GMainContext of @loop.
6338 // RETURNS: the #GMainContext of @loop
6339 MainContext* get_context()() {
6340 return g_main_loop_get_context(&this);
6343 // Checks to see if the main loop is currently being run via g_main_loop_run().
6344 // RETURNS: %TRUE if the mainloop is currently being run.
6345 int is_running()() {
6346 return g_main_loop_is_running(&this);
6349 // Stops a #GMainLoop from running. Any calls to g_main_loop_run()
6350 // for the loop will return.
6352 // Note that sources that have already been dispatched when
6353 // g_main_loop_quit() is called will still be executed.
6354 void quit()() {
6355 g_main_loop_quit(&this);
6358 // Increases the reference count on a #GMainLoop object by one.
6359 // RETURNS: @loop
6360 MainLoop* /*new*/ ref_()() {
6361 return g_main_loop_ref(&this);
6364 // Runs a main loop until g_main_loop_quit() is called on the loop.
6365 // If this is called for the thread of the loop's #GMainContext,
6366 // it will process events from the loop, otherwise it will
6367 // simply wait.
6368 void run()() {
6369 g_main_loop_run(&this);
6372 // Decreases the reference count on a #GMainLoop object by one. If
6373 // the result is zero, free the loop and free all associated memory.
6374 void unref()() {
6375 g_main_loop_unref(&this);
6380 // The #GMappedFile represents a file mapping created with
6381 // g_mapped_file_new(). It has only private members and should
6382 // not be accessed directly.
6383 struct MappedFile {
6385 // VERSION: 2.8
6386 // This call existed before #GMappedFile had refcounting and is currently
6387 // exactly the same as g_mapped_file_unref().
6389 // Deprecated:2.22: Use g_mapped_file_unref() instead.
6390 void free()() {
6391 g_mapped_file_free(&this);
6394 // VERSION: 2.8
6395 // Returns the contents of a #GMappedFile.
6397 // Note that the contents may not be zero-terminated,
6398 // even if the #GMappedFile is backed by a text file.
6400 // If the file is empty then %NULL is returned.
6401 // RETURNS: the contents of @file, or %NULL.
6402 char* /*new*/ get_contents()() {
6403 return g_mapped_file_get_contents(&this);
6406 // VERSION: 2.8
6407 // Returns the length of the contents of a #GMappedFile.
6408 // RETURNS: the length of the contents of @file.
6409 size_t get_length()() {
6410 return g_mapped_file_get_length(&this);
6413 // Unintrospectable method: ref() / g_mapped_file_ref()
6414 // VERSION: 2.22
6415 // Increments the reference count of @file by one. It is safe to call
6416 // this function from any thread.
6417 // RETURNS: the passed in #GMappedFile.
6418 MappedFile* ref_()() {
6419 return g_mapped_file_ref(&this);
6422 // Decrements the reference count of @file by one. If the reference count
6423 // drops to 0, unmaps the buffer of @file and frees it.
6425 // It is safe to call this function from any thread.
6427 // Since 2.22
6428 void unref()() {
6429 g_mapped_file_unref(&this);
6432 // Unintrospectable function: new() / g_mapped_file_new()
6433 // VERSION: 2.8
6434 // Maps a file into memory. On UNIX, this is using the mmap() function.
6436 // If @writable is %TRUE, the mapped buffer may be modified, otherwise
6437 // it is an error to modify the mapped buffer. Modifications to the buffer
6438 // are not visible to other processes mapping the same file, and are not
6439 // written back to the file.
6441 // Note that modifications of the underlying file might affect the contents
6442 // of the #GMappedFile. Therefore, mapping should only be used if the file
6443 // will not be modified, or if all modifications of the file are done
6444 // atomically (e.g. using g_file_set_contents()).
6446 // If @filename is the name of an empty, regular file, the function
6447 // will successfully return an empty #GMappedFile. In other cases of
6448 // size 0 (e.g. device files such as /dev/null), @error will be set
6449 // to the #GFileError value #G_FILE_ERROR_INVAL.
6451 // with g_mapped_file_unref(), or %NULL if the mapping failed.
6452 // RETURNS: a newly allocated #GMappedFile which must be unref'd
6453 // <filename>: The path of the file to load, in the GLib filename encoding
6454 // <writable>: whether the mapping should be writable
6455 static MappedFile* new_()(char* filename, int writable, GLib2.Error** error=null) {
6456 return g_mapped_file_new(filename, writable, error);
6459 // Unintrospectable function: new_from_fd() / g_mapped_file_new_from_fd()
6460 // VERSION: 2.30
6461 // Maps a file into memory. On UNIX, this is using the mmap() function.
6463 // If @writable is %TRUE, the mapped buffer may be modified, otherwise
6464 // it is an error to modify the mapped buffer. Modifications to the buffer
6465 // are not visible to other processes mapping the same file, and are not
6466 // written back to the file.
6468 // Note that modifications of the underlying file might affect the contents
6469 // of the #GMappedFile. Therefore, mapping should only be used if the file
6470 // will not be modified, or if all modifications of the file are done
6471 // atomically (e.g. using g_file_set_contents()).
6473 // with g_mapped_file_unref(), or %NULL if the mapping failed.
6474 // RETURNS: a newly allocated #GMappedFile which must be unref'd
6475 // <fd>: The file descriptor of the file to load
6476 // <writable>: whether the mapping should be writable
6477 static MappedFile* new_from_fd()(int fd, int writable, GLib2.Error** error=null) {
6478 return g_mapped_file_new_from_fd(fd, writable, error);
6483 // A mixed enumerated type and flags field. You must specify one type
6484 // (string, strdup, boolean, tristate). Additionally, you may optionally
6485 // bitwise OR the type with the flag %G_MARKUP_COLLECT_OPTIONAL.
6487 // It is likely that this enum will be extended in the future to
6488 // support other types.
6489 enum MarkupCollectType {
6490 INVALID = 0,
6491 STRING = 1,
6492 STRDUP = 2,
6493 BOOLEAN = 3,
6494 TRISTATE = 4,
6495 OPTIONAL = 65536
6497 // Error codes returned by markup parsing.
6498 enum MarkupError {
6499 BAD_UTF8 = 0,
6500 EMPTY = 1,
6501 PARSE = 2,
6502 UNKNOWN_ELEMENT = 3,
6503 UNKNOWN_ATTRIBUTE = 4,
6504 INVALID_CONTENT = 5,
6505 MISSING_ATTRIBUTE = 6
6508 // A parse context is used to parse a stream of bytes that
6509 // you expect to contain marked-up text.
6511 // See g_markup_parse_context_new(), #GMarkupParser, and so
6512 // on for more details.
6513 struct MarkupParseContext {
6515 // Signals to the #GMarkupParseContext that all data has been
6516 // fed into the parse context with g_markup_parse_context_parse().
6518 // This function reports an error if the document isn't complete,
6519 // for example if elements are still open.
6520 // RETURNS: %TRUE on success, %FALSE if an error was set
6521 int end_parse()(GLib2.Error** error=null) {
6522 return g_markup_parse_context_end_parse(&this, error);
6525 // Frees a #GMarkupParseContext.
6527 // This function can't be called from inside one of the
6528 // #GMarkupParser functions or while a subparser is pushed.
6529 void free()() {
6530 g_markup_parse_context_free(&this);
6533 // VERSION: 2.2
6534 // Retrieves the name of the currently open element.
6536 // If called from the start_element or end_element handlers this will
6537 // give the element_name as passed to those functions. For the parent
6538 // elements, see g_markup_parse_context_get_element_stack().
6539 // RETURNS: the name of the currently open element, or %NULL
6540 char* get_element()() {
6541 return g_markup_parse_context_get_element(&this);
6544 // Unintrospectable method: get_element_stack() / g_markup_parse_context_get_element_stack()
6545 // VERSION: 2.16
6546 // Retrieves the element stack from the internal state of the parser.
6548 // The returned #GSList is a list of strings where the first item is
6549 // the currently open tag (as would be returned by
6550 // g_markup_parse_context_get_element()) and the next item is its
6551 // immediate parent.
6553 // This function is intended to be used in the start_element and
6554 // end_element handlers where g_markup_parse_context_get_element()
6555 // would merely return the name of the element that is being
6556 // processed.
6557 // RETURNS: the element stack, which must not be modified
6558 GLib2.SList* get_element_stack()() {
6559 return g_markup_parse_context_get_element_stack(&this);
6562 // Retrieves the current line number and the number of the character on
6563 // that line. Intended for use in error messages; there are no strict
6564 // semantics for what constitutes the "current" line number other than
6565 // "the best number we could come up with for error messages."
6566 // <line_number>: return location for a line number, or %NULL
6567 // <char_number>: return location for a char-on-line number, or %NULL
6568 void get_position()(int* line_number=null, int* char_number=null) {
6569 g_markup_parse_context_get_position(&this, line_number, char_number);
6572 // Unintrospectable method: get_user_data() / g_markup_parse_context_get_user_data()
6573 // VERSION: 2.18
6574 // Returns the user_data associated with @context.
6576 // This will either be the user_data that was provided to
6577 // g_markup_parse_context_new() or to the most recent call
6578 // of g_markup_parse_context_push().
6580 // the markup context and will be freed when
6581 // g_markup_parse_context_free() is called.
6582 // RETURNS: the provided user_data. The returned data belongs to
6583 void* get_user_data()() {
6584 return g_markup_parse_context_get_user_data(&this);
6587 // Feed some data to the #GMarkupParseContext.
6589 // The data need not be valid UTF-8; an error will be signaled if
6590 // it's invalid. The data need not be an entire document; you can
6591 // feed a document into the parser incrementally, via multiple calls
6592 // to this function. Typically, as you receive data from a network
6593 // connection or file, you feed each received chunk of data into this
6594 // function, aborting the process if an error occurs. Once an error
6595 // is reported, no further data may be fed to the #GMarkupParseContext;
6596 // all errors are fatal.
6597 // RETURNS: %FALSE if an error occurred, %TRUE on success
6598 // <text>: chunk of text to parse
6599 // <text_len>: length of @text in bytes
6600 int parse()(char* text, ssize_t text_len, GLib2.Error** error=null) {
6601 return g_markup_parse_context_parse(&this, text, text_len, error);
6604 // Unintrospectable method: pop() / g_markup_parse_context_pop()
6605 // VERSION: 2.18
6606 // Completes the process of a temporary sub-parser redirection.
6608 // This function exists to collect the user_data allocated by a
6609 // matching call to g_markup_parse_context_push(). It must be called
6610 // in the end_element handler corresponding to the start_element
6611 // handler during which g_markup_parse_context_push() was called.
6612 // You must not call this function from the error callback -- the
6613 // @user_data is provided directly to the callback in that case.
6615 // This function is not intended to be directly called by users
6616 // interested in invoking subparsers. Instead, it is intended to
6617 // be used by the subparsers themselves to implement a higher-level
6618 // interface.
6619 // RETURNS: the user data passed to g_markup_parse_context_push()
6620 void* pop()() {
6621 return g_markup_parse_context_pop(&this);
6624 // VERSION: 2.18
6625 // Temporarily redirects markup data to a sub-parser.
6627 // This function may only be called from the start_element handler of
6628 // a #GMarkupParser. It must be matched with a corresponding call to
6629 // g_markup_parse_context_pop() in the matching end_element handler
6630 // (except in the case that the parser aborts due to an error).
6632 // All tags, text and other data between the matching tags is
6633 // redirected to the subparser given by @parser. @user_data is used
6634 // as the user_data for that parser. @user_data is also passed to the
6635 // error callback in the event that an error occurs. This includes
6636 // errors that occur in subparsers of the subparser.
6638 // The end tag matching the start tag for which this call was made is
6639 // handled by the previous parser (which is given its own user_data)
6640 // which is why g_markup_parse_context_pop() is provided to allow "one
6641 // last access" to the @user_data provided to this function. In the
6642 // case of error, the @user_data provided here is passed directly to
6643 // the error callback of the subparser and g_markup_parse_context_pop()
6644 // should not be called. In either case, if @user_data was allocated
6645 // then it ought to be freed from both of these locations.
6647 // This function is not intended to be directly called by users
6648 // interested in invoking subparsers. Instead, it is intended to be
6649 // used by the subparsers themselves to implement a higher-level
6650 // interface.
6652 // As an example, see the following implementation of a simple
6653 // parser that counts the number of tags encountered.
6655 // |[
6656 // typedef struct
6657 // {
6658 // gint tag_count;
6659 // } CounterData;
6661 // static void
6662 // counter_start_element (GMarkupParseContext *context,
6663 // const gchar *element_name,
6664 // const gchar **attribute_names,
6665 // const gchar **attribute_values,
6666 // gpointer user_data,
6667 // GError **error)
6668 // {
6669 // CounterData *data = user_data;
6671 // data->tag_count++;
6672 // }
6674 // static void
6675 // counter_error (GMarkupParseContext *context,
6676 // GError *error,
6677 // gpointer user_data)
6678 // {
6679 // CounterData *data = user_data;
6681 // g_slice_free (CounterData, data);
6682 // }
6684 // static GMarkupParser counter_subparser =
6685 // {
6686 // counter_start_element,
6687 // NULL,
6688 // NULL,
6689 // NULL,
6690 // counter_error
6691 // };
6692 // ]|
6694 // In order to allow this parser to be easily used as a subparser, the
6695 // following interface is provided:
6697 // |[
6698 // void
6699 // start_counting (GMarkupParseContext *context)
6700 // {
6701 // CounterData *data = g_slice_new (CounterData);
6703 // data->tag_count = 0;
6704 // g_markup_parse_context_push (context, &counter_subparser, data);
6705 // }
6707 // gint
6708 // end_counting (GMarkupParseContext *context)
6709 // {
6710 // CounterData *data = g_markup_parse_context_pop (context);
6711 // int result;
6713 // result = data->tag_count;
6714 // g_slice_free (CounterData, data);
6716 // return result;
6717 // }
6718 // ]|
6720 // The subparser would then be used as follows:
6722 // |[
6723 // static void start_element (context, element_name, ...)
6724 // {
6725 // if (strcmp (element_name, "count-these") == 0)
6726 // start_counting (context);
6728 // /&ast; else, handle other tags... &ast;/
6729 // }
6731 // static void end_element (context, element_name, ...)
6732 // {
6733 // if (strcmp (element_name, "count-these") == 0)
6734 // g_print ("Counted %d tags\n", end_counting (context));
6736 // /&ast; else, handle other tags... &ast;/
6737 // }
6738 // ]|
6739 // <parser>: a #GMarkupParser
6740 // <user_data>: user data to pass to #GMarkupParser functions
6741 void push()(MarkupParser* parser, void* user_data) {
6742 g_markup_parse_context_push(&this, parser, user_data);
6745 // Unintrospectable function: new() / g_markup_parse_context_new()
6746 // Creates a new parse context. A parse context is used to parse
6747 // marked-up documents. You can feed any number of documents into
6748 // a context, as long as no errors occur; once an error occurs,
6749 // the parse context can't continue to parse text (you have to
6750 // free it and create a new parse context).
6751 // RETURNS: a new #GMarkupParseContext
6752 // <parser>: a #GMarkupParser
6753 // <flags>: one or more #GMarkupParseFlags
6754 // <user_data>: user data to pass to #GMarkupParser functions
6755 // <user_data_dnotify>: user data destroy notifier called when the parse context is freed
6756 static MarkupParseContext* new_()(MarkupParser* parser, MarkupParseFlags flags, void* user_data, DestroyNotify user_data_dnotify) {
6757 return g_markup_parse_context_new(parser, flags, user_data, user_data_dnotify);
6761 // Flags that affect the behaviour of the parser.
6762 enum MarkupParseFlags {
6763 DO_NOT_USE_THIS_UNSUPPORTED_FLAG = 1,
6764 TREAT_CDATA_AS_TEXT = 2,
6765 PREFIX_ERROR_POSITION = 4
6768 // Any of the fields in #GMarkupParser can be %NULL, in which case they
6769 // will be ignored. Except for the @error function, any of these callbacks
6770 // can set an error; in particular the %G_MARKUP_ERROR_UNKNOWN_ELEMENT,
6771 // %G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, and %G_MARKUP_ERROR_INVALID_CONTENT
6772 // errors are intended to be set from these callbacks. If you set an error
6773 // from a callback, g_markup_parse_context_parse() will report that error
6774 // back to its caller.
6775 struct MarkupParser {
6776 extern (C) void function (MarkupParseContext* context, char* element_name, char** attribute_names, char** attribute_values, void* user_data, GLib2.Error** error=null) start_element;
6777 extern (C) void function (MarkupParseContext* context, char* element_name, void* user_data, GLib2.Error** error=null) end_element;
6778 extern (C) void function (MarkupParseContext* context, char* text, size_t text_len, void* user_data, GLib2.Error** error=null) text;
6779 extern (C) void function (MarkupParseContext* context, char* passthrough_text, size_t text_len, void* user_data, GLib2.Error** error=null) passthrough;
6780 extern (C) void function (MarkupParseContext* context, Error* error, void* user_data) error;
6783 struct MatchInfo {
6785 // VERSION: 2.14
6786 // Returns a new string containing the text in @string_to_expand with
6787 // references and escape sequences expanded. References refer to the last
6788 // match done with @string against @regex and have the same syntax used by
6789 // g_regex_replace().
6791 // The @string_to_expand must be UTF-8 encoded even if #G_REGEX_RAW was
6792 // passed to g_regex_new().
6794 // The backreferences are extracted from the string passed to the match
6795 // function, so you cannot call this function after freeing the string.
6797 // @match_info may be %NULL in which case @string_to_expand must not
6798 // contain references. For instance "foo\n" does not refer to an actual
6799 // pattern and '\n' merely will be replaced with \n character,
6800 // while to expand "\0" (whole match) one needs the result of a match.
6801 // Use g_regex_check_replacement() to find out whether @string_to_expand
6802 // contains references.
6803 // RETURNS: the expanded string, or %NULL if an error occurred
6804 // <string_to_expand>: the string to expand
6805 char* /*new*/ expand_references()(char* string_to_expand, GLib2.Error** error=null) {
6806 return g_match_info_expand_references(&this, string_to_expand, error);
6809 // VERSION: 2.14
6810 // Retrieves the text matching the @match_num<!-- -->'th capturing
6811 // parentheses. 0 is the full text of the match, 1 is the first paren
6812 // set, 2 the second, and so on.
6814 // If @match_num is a valid sub pattern but it didn't match anything
6815 // (e.g. sub pattern 1, matching "b" against "(a)?b") then an empty
6816 // string is returned.
6818 // If the match was obtained using the DFA algorithm, that is using
6819 // g_regex_match_all() or g_regex_match_all_full(), the retrieved
6820 // string is not that of a set of parentheses but that of a matched
6821 // substring. Substrings are matched in reverse order of length, so
6822 // 0 is the longest match.
6824 // The string is fetched from the string passed to the match function,
6825 // so you cannot call this function after freeing the string.
6827 // occurred. You have to free the string yourself
6828 // RETURNS: The matched substring, or %NULL if an error
6829 // <match_num>: number of the sub expression
6830 char* /*new*/ fetch()(int match_num) {
6831 return g_match_info_fetch(&this, match_num);
6834 // Unintrospectable method: fetch_all() / g_match_info_fetch_all()
6835 // VERSION: 2.14
6836 // Bundles up pointers to each of the matching substrings from a match
6837 // and stores them in an array of gchar pointers. The first element in
6838 // the returned array is the match number 0, i.e. the entire matched
6839 // text.
6841 // If a sub pattern didn't match anything (e.g. sub pattern 1, matching
6842 // "b" against "(a)?b") then an empty string is inserted.
6844 // If the last match was obtained using the DFA algorithm, that is using
6845 // g_regex_match_all() or g_regex_match_all_full(), the retrieved
6846 // strings are not that matched by sets of parentheses but that of the
6847 // matched substring. Substrings are matched in reverse order of length,
6848 // so the first one is the longest match.
6850 // The strings are fetched from the string passed to the match function,
6851 // so you cannot call this function after freeing the string.
6853 // It must be freed using g_strfreev(). If the previous match failed
6854 // %NULL is returned
6855 // RETURNS: a %NULL-terminated array of gchar * pointers.
6856 char** fetch_all()() {
6857 return g_match_info_fetch_all(&this);
6860 // VERSION: 2.14
6861 // Retrieves the text matching the capturing parentheses named @name.
6863 // If @name is a valid sub pattern name but it didn't match anything
6864 // (e.g. sub pattern "X", matching "b" against "(?P&lt;X&gt;a)?b")
6865 // then an empty string is returned.
6867 // The string is fetched from the string passed to the match function,
6868 // so you cannot call this function after freeing the string.
6870 // occurred. You have to free the string yourself
6871 // RETURNS: The matched substring, or %NULL if an error
6872 // <name>: name of the subexpression
6873 char* /*new*/ fetch_named()(char* name) {
6874 return g_match_info_fetch_named(&this, name);
6877 // VERSION: 2.14
6878 // Retrieves the position in bytes of the capturing parentheses named @name.
6880 // If @name is a valid sub pattern name but it didn't match anything
6881 // (e.g. sub pattern "X", matching "b" against "(?P&lt;X&gt;a)?b")
6882 // then @start_pos and @end_pos are set to -1 and %TRUE is returned.
6884 // If the position cannot be fetched, @start_pos and @end_pos
6885 // are left unchanged.
6886 // RETURNS: %TRUE if the position was fetched, %FALSE otherwise.
6887 // <name>: name of the subexpression
6888 // <start_pos>: pointer to location where to store the start position, or %NULL
6889 // <end_pos>: pointer to location where to store the end position, or %NULL
6890 int fetch_named_pos()(char* name, /*out*/ int* start_pos=null, /*out*/ int* end_pos=null) {
6891 return g_match_info_fetch_named_pos(&this, name, start_pos, end_pos);
6894 // VERSION: 2.14
6895 // Retrieves the position in bytes of the @match_num<!-- -->'th capturing
6896 // parentheses. 0 is the full text of the match, 1 is the first
6897 // paren set, 2 the second, and so on.
6899 // If @match_num is a valid sub pattern but it didn't match anything
6900 // (e.g. sub pattern 1, matching "b" against "(a)?b") then @start_pos
6901 // and @end_pos are set to -1 and %TRUE is returned.
6903 // If the match was obtained using the DFA algorithm, that is using
6904 // g_regex_match_all() or g_regex_match_all_full(), the retrieved
6905 // position is not that of a set of parentheses but that of a matched
6906 // substring. Substrings are matched in reverse order of length, so
6907 // 0 is the longest match.
6909 // the position cannot be fetched, @start_pos and @end_pos are left
6910 // unchanged
6911 // RETURNS: %TRUE if the position was fetched, %FALSE otherwise. If
6912 // <match_num>: number of the sub expression
6913 // <start_pos>: pointer to location where to store the start position, or %NULL
6914 // <end_pos>: pointer to location where to store the end position, or %NULL
6915 int fetch_pos()(int match_num, /*out*/ int* start_pos=null, /*out*/ int* end_pos=null) {
6916 return g_match_info_fetch_pos(&this, match_num, start_pos, end_pos);
6919 // VERSION: 2.14
6920 // If @match_info is not %NULL, calls g_match_info_unref(); otherwise does
6921 // nothing.
6922 void free()() {
6923 g_match_info_free(&this);
6926 // VERSION: 2.14
6927 // Retrieves the number of matched substrings (including substring 0,
6928 // that is the whole matched text), so 1 is returned if the pattern
6929 // has no substrings in it and 0 is returned if the match failed.
6931 // If the last match was obtained using the DFA algorithm, that is
6932 // using g_regex_match_all() or g_regex_match_all_full(), the retrieved
6933 // count is not that of the number of capturing parentheses but that of
6934 // the number of matched substrings.
6935 // RETURNS: Number of matched substrings, or -1 if an error occurred
6936 int get_match_count()() {
6937 return g_match_info_get_match_count(&this);
6940 // VERSION: 2.14
6941 // Returns #GRegex object used in @match_info. It belongs to Glib
6942 // and must not be freed. Use g_regex_ref() if you need to keep it
6943 // after you free @match_info object.
6944 // RETURNS: #GRegex object used in @match_info
6945 Regex* /*new*/ get_regex()() {
6946 return g_match_info_get_regex(&this);
6949 // VERSION: 2.14
6950 // Returns the string searched with @match_info. This is the
6951 // string passed to g_regex_match() or g_regex_replace() so
6952 // you may not free it before calling this function.
6953 // RETURNS: the string searched with @match_info
6954 char* get_string()() {
6955 return g_match_info_get_string(&this);
6958 // VERSION: 2.14
6959 // Usually if the string passed to g_regex_match*() matches as far as
6960 // it goes, but is too short to match the entire pattern, %FALSE is
6961 // returned. There are circumstances where it might be helpful to
6962 // distinguish this case from other cases in which there is no match.
6964 // Consider, for example, an application where a human is required to
6965 // type in data for a field with specific formatting requirements. An
6966 // example might be a date in the form ddmmmyy, defined by the pattern
6967 // "^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$".
6968 // If the application sees the user’s keystrokes one by one, and can
6969 // check that what has been typed so far is potentially valid, it is
6970 // able to raise an error as soon as a mistake is made.
6972 // GRegex supports the concept of partial matching by means of the
6973 // #G_REGEX_MATCH_PARTIAL flag. When this is set the return code for
6974 // g_regex_match() or g_regex_match_full() is, as usual, %TRUE
6975 // for a complete match, %FALSE otherwise. But, when these functions
6976 // return %FALSE, you can check if the match was partial calling
6977 // g_match_info_is_partial_match().
6979 // When using partial matching you cannot use g_match_info_fetch*().
6981 // Because of the way certain internal optimizations are implemented
6982 // the partial matching algorithm cannot be used with all patterns.
6983 // So repeated single characters such as "a{2,4}" and repeated single
6984 // meta-sequences such as "\d+" are not permitted if the maximum number
6985 // of occurrences is greater than one. Optional items such as "\d?"
6986 // (where the maximum is one) are permitted. Quantifiers with any values
6987 // are permitted after parentheses, so the invalid examples above can be
6988 // coded thus "(a){2,4}" and "(\d)+". If #G_REGEX_MATCH_PARTIAL is set
6989 // for a pattern that does not conform to the restrictions, matching
6990 // functions return an error.
6991 // RETURNS: %TRUE if the match was partial, %FALSE otherwise
6992 int is_partial_match()() {
6993 return g_match_info_is_partial_match(&this);
6996 // VERSION: 2.14
6997 // Returns whether the previous match operation succeeded.
6999 // %FALSE otherwise
7000 // RETURNS: %TRUE if the previous match operation succeeded,
7001 int matches()() {
7002 return g_match_info_matches(&this);
7005 // VERSION: 2.14
7006 // Scans for the next match using the same parameters of the previous
7007 // call to g_regex_match_full() or g_regex_match() that returned
7008 // @match_info.
7010 // The match is done on the string passed to the match function, so you
7011 // cannot free it before calling this function.
7012 // RETURNS: %TRUE is the string matched, %FALSE otherwise
7013 int next()(GLib2.Error** error=null) {
7014 return g_match_info_next(&this, error);
7017 // VERSION: 2.30
7018 // Increases reference count of @match_info by 1.
7019 // RETURNS: @match_info
7020 MatchInfo* /*new*/ ref_()() {
7021 return g_match_info_ref(&this);
7024 // VERSION: 2.30
7025 // Decreases reference count of @match_info by 1. When reference count drops
7026 // to zero, it frees all the memory associated with the match_info structure.
7027 void unref()() {
7028 g_match_info_unref(&this);
7033 // A set of functions used to perform memory allocation. The same #GMemVTable must
7034 // be used for all allocations in the same program; a call to g_mem_set_vtable(),
7035 // if it exists, should be prior to any use of GLib.
7036 struct MemVTable {
7037 // Unintrospectable functionp: malloc() / ()
7038 extern (C) void* function (size_t n_bytes) malloc;
7039 // Unintrospectable functionp: realloc() / ()
7040 extern (C) void* function (void* mem, size_t n_bytes) realloc;
7041 extern (C) void function (void* mem) free;
7042 // Unintrospectable functionp: calloc() / ()
7043 extern (C) void* function (size_t n_blocks, size_t n_block_bytes) calloc;
7044 // Unintrospectable functionp: try_malloc() / ()
7045 extern (C) void* function (size_t n_bytes) try_malloc;
7046 // Unintrospectable functionp: try_realloc() / ()
7047 extern (C) void* function (void* mem, size_t n_bytes) try_realloc;
7051 // The #GMutex struct is an opaque data structure to represent a mutex
7052 // (mutual exclusion). It can be used to protect data against shared
7053 // access. Take for example the following function:
7055 // <example>
7056 // <title>A function which will not work in a threaded environment</title>
7057 // <programlisting>
7058 // int
7059 // give_me_next_number (void)
7060 // {
7061 // static int current_number = 0;
7063 // /<!-- -->* now do a very complicated calculation to calculate the new
7064 // * number, this might for example be a random number generator
7065 // *<!-- -->/
7066 // current_number = calc_next_number (current_number);
7068 // return current_number;
7069 // }
7070 // </programlisting>
7071 // </example>
7073 // It is easy to see that this won't work in a multi-threaded
7074 // application. There current_number must be protected against shared
7075 // access. A #GMutex can be used as a solution to this problem:
7077 // <example>
7078 // <title>Using GMutex to protected a shared variable</title>
7079 // <programlisting>
7080 // int
7081 // give_me_next_number (void)
7082 // {
7083 // static GMutex mutex;
7084 // static int current_number = 0;
7085 // int ret_val;
7087 // g_mutex_lock (&amp;mutex);
7088 // ret_val = current_number = calc_next_number (current_number);
7089 // g_mutex_unlock (&amp;mutex);
7091 // return ret_val;
7092 // }
7093 // </programlisting>
7094 // </example>
7096 // Notice that the #GMutex is not initialised to any particular value.
7097 // Its placement in static storage ensures that it will be initialised
7098 // to all-zeros, which is appropriate.
7100 // If a #GMutex is placed in other contexts (eg: embedded in a struct)
7101 // then it must be explicitly initialised using g_mutex_init().
7103 // A #GMutex should only be accessed via <function>g_mutex_</function>
7104 // functions.
7105 union Mutex {
7106 private void* p;
7107 private uint[2] i;
7110 // Frees the resources allocated to a mutex with g_mutex_init().
7112 // This function should not be used with a #GMutex that has been
7113 // statically allocated.
7115 // Calling g_mutex_clear() on a locked mutex leads to undefined
7116 // behaviour.
7118 // Sine: 2.32
7119 void clear()() {
7120 g_mutex_clear(&this);
7123 // VERSION: 2.32
7124 // Initializes a #GMutex so that it can be used.
7126 // This function is useful to initialize a mutex that has been
7127 // allocated on the stack, or as part of a larger structure.
7128 // It is not necessary to initialize a mutex that has been
7129 // created that has been statically allocated.
7131 // |[
7132 // typedef struct {
7133 // GMutex m;
7134 // ...
7135 // } Blob;
7137 // Blob *b;
7139 // b = g_new (Blob, 1);
7140 // g_mutex_init (&b->m);
7141 // ]|
7143 // To undo the effect of g_mutex_init() when a mutex is no longer
7144 // needed, use g_mutex_clear().
7146 // Calling g_mutex_init() on an already initialized #GMutex leads
7147 // to undefined behaviour.
7148 void init()() {
7149 g_mutex_init(&this);
7152 // Locks @mutex. If @mutex is already locked by another thread, the
7153 // current thread will block until @mutex is unlocked by the other
7154 // thread.
7156 // <note>#GMutex is neither guaranteed to be recursive nor to be
7157 // non-recursive. As such, calling g_mutex_lock() on a #GMutex that has
7158 // already been locked by the same thread results in undefined behaviour
7159 // (including but not limited to deadlocks).</note>
7160 void lock()() {
7161 g_mutex_lock(&this);
7164 // Tries to lock @mutex. If @mutex is already locked by another thread,
7165 // it immediately returns %FALSE. Otherwise it locks @mutex and returns
7166 // %TRUE.
7168 // <note>#GMutex is neither guaranteed to be recursive nor to be
7169 // non-recursive. As such, calling g_mutex_lock() on a #GMutex that has
7170 // already been locked by the same thread results in undefined behaviour
7171 // (including but not limited to deadlocks or arbitrary return values).
7172 // </note>
7173 // RETURNS: %TRUE if @mutex could be locked
7174 int trylock()() {
7175 return g_mutex_trylock(&this);
7178 // Unlocks @mutex. If another thread is blocked in a g_mutex_lock()
7179 // call for @mutex, it will become unblocked and can lock @mutex itself.
7181 // Calling g_mutex_unlock() on a mutex that is not locked by the
7182 // current thread leads to undefined behaviour.
7183 void unlock()() {
7184 g_mutex_unlock(&this);
7189 // The #GNode struct represents one node in a
7190 // <link linkend="glib-N-ary-Trees">N-ary Tree</link>. fields
7191 struct Node {
7192 void* data;
7193 Node* next, prev, parent, children;
7196 // Gets the position of the first child of a #GNode
7197 // which contains the given data.
7199 // @data, or -1 if the data is not found
7200 // RETURNS: the index of the child of @node which contains
7201 // <data>: the data to find
7202 int child_index()(void* data) {
7203 return g_node_child_index(&this, data);
7206 // Gets the position of a #GNode with respect to its siblings.
7207 // @child must be a child of @node. The first child is numbered 0,
7208 // the second 1, and so on.
7209 // RETURNS: the position of @child with respect to its siblings
7210 // <child>: a child of @node
7211 int child_position()(Node* child) {
7212 return g_node_child_position(&this, child);
7215 // Unintrospectable method: children_foreach() / g_node_children_foreach()
7216 // Calls a function for each of the children of a #GNode.
7217 // Note that it doesn't descend beneath the child nodes.
7218 // <flags>: which types of children are to be visited, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
7219 // <func>: the function to call for each visited node
7220 // <data>: user data to pass to the function
7221 void children_foreach()(TraverseFlags flags, NodeForeachFunc func, void* data) {
7222 g_node_children_foreach(&this, flags, func, data);
7225 // Unintrospectable method: copy() / g_node_copy()
7226 // Recursively copies a #GNode (but does not deep-copy the data inside the
7227 // nodes, see g_node_copy_deep() if you need that).
7228 // RETURNS: a new #GNode containing the same data pointers
7229 Node* copy()() {
7230 return g_node_copy(&this);
7233 // Unintrospectable method: copy_deep() / g_node_copy_deep()
7234 // VERSION: 2.4
7235 // Recursively copies a #GNode and its data.
7236 // RETURNS: a new #GNode containing copies of the data in @node.
7237 // <copy_func>: the function which is called to copy the data inside each node, or %NULL to use the original data.
7238 // <data>: data to pass to @copy_func
7239 Node* copy_deep()(CopyFunc copy_func, void* data) {
7240 return g_node_copy_deep(&this, copy_func, data);
7243 // Gets the depth of a #GNode.
7245 // If @node is %NULL the depth is 0. The root node has a depth of 1.
7246 // For the children of the root node the depth is 2. And so on.
7247 // RETURNS: the depth of the #GNode
7248 uint depth()() {
7249 return g_node_depth(&this);
7252 // Removes @root and its children from the tree, freeing any memory
7253 // allocated.
7254 void destroy()() {
7255 g_node_destroy(&this);
7258 // Unintrospectable method: find() / g_node_find()
7259 // Finds a #GNode in a tree.
7260 // RETURNS: the found #GNode, or %NULL if the data is not found
7261 // <order>: the order in which nodes are visited - %G_IN_ORDER, %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER
7262 // <flags>: which types of children are to be searched, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
7263 // <data>: the data to find
7264 Node* find()(TraverseType order, TraverseFlags flags, void* data) {
7265 return g_node_find(&this, order, flags, data);
7268 // Unintrospectable method: find_child() / g_node_find_child()
7269 // Finds the first child of a #GNode with the given data.
7270 // RETURNS: the found child #GNode, or %NULL if the data is not found
7271 // <flags>: which types of children are to be searched, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
7272 // <data>: the data to find
7273 Node* find_child()(TraverseFlags flags, void* data) {
7274 return g_node_find_child(&this, flags, data);
7277 // Unintrospectable method: first_sibling() / g_node_first_sibling()
7278 // Gets the first sibling of a #GNode.
7279 // This could possibly be the node itself.
7280 // RETURNS: the first sibling of @node
7281 Node* first_sibling()() {
7282 return g_node_first_sibling(&this);
7285 // Unintrospectable method: get_root() / g_node_get_root()
7286 // Gets the root of a tree.
7287 // RETURNS: the root of the tree
7288 Node* get_root()() {
7289 return g_node_get_root(&this);
7292 // Unintrospectable method: insert() / g_node_insert()
7293 // Inserts a #GNode beneath the parent at the given position.
7294 // RETURNS: the inserted #GNode
7295 // <position>: the position to place @node at, with respect to its siblings If position is -1, @node is inserted as the last child of @parent
7296 // <node>: the #GNode to insert
7297 Node* insert()(int position, Node* node) {
7298 return g_node_insert(&this, position, node);
7301 // Unintrospectable method: insert_after() / g_node_insert_after()
7302 // Inserts a #GNode beneath the parent after the given sibling.
7303 // RETURNS: the inserted #GNode
7304 // <sibling>: the sibling #GNode to place @node after. If sibling is %NULL, the node is inserted as the first child of @parent.
7305 // <node>: the #GNode to insert
7306 Node* insert_after()(Node* sibling, Node* node) {
7307 return g_node_insert_after(&this, sibling, node);
7310 // Unintrospectable method: insert_before() / g_node_insert_before()
7311 // Inserts a #GNode beneath the parent before the given sibling.
7312 // RETURNS: the inserted #GNode
7313 // <sibling>: the sibling #GNode to place @node before. If sibling is %NULL, the node is inserted as the last child of @parent.
7314 // <node>: the #GNode to insert
7315 Node* insert_before()(Node* sibling, Node* node) {
7316 return g_node_insert_before(&this, sibling, node);
7319 // Returns %TRUE if @node is an ancestor of @descendant.
7320 // This is true if node is the parent of @descendant,
7321 // or if node is the grandparent of @descendant etc.
7322 // RETURNS: %TRUE if @node is an ancestor of @descendant
7323 // <descendant>: a #GNode
7324 int is_ancestor()(Node* descendant) {
7325 return g_node_is_ancestor(&this, descendant);
7328 // Unintrospectable method: last_child() / g_node_last_child()
7329 // Gets the last child of a #GNode.
7330 // RETURNS: the last child of @node, or %NULL if @node has no children
7331 Node* last_child()() {
7332 return g_node_last_child(&this);
7335 // Unintrospectable method: last_sibling() / g_node_last_sibling()
7336 // Gets the last sibling of a #GNode.
7337 // This could possibly be the node itself.
7338 // RETURNS: the last sibling of @node
7339 Node* last_sibling()() {
7340 return g_node_last_sibling(&this);
7343 // Gets the maximum height of all branches beneath a #GNode.
7344 // This is the maximum distance from the #GNode to all leaf nodes.
7346 // If @root is %NULL, 0 is returned. If @root has no children,
7347 // 1 is returned. If @root has children, 2 is returned. And so on.
7348 // RETURNS: the maximum height of the tree beneath @root
7349 uint max_height()() {
7350 return g_node_max_height(&this);
7353 // Gets the number of children of a #GNode.
7354 // RETURNS: the number of children of @node
7355 uint n_children()() {
7356 return g_node_n_children(&this);
7359 // Gets the number of nodes in a tree.
7360 // RETURNS: the number of nodes in the tree
7361 // <flags>: which types of children are to be counted, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
7362 uint n_nodes()(TraverseFlags flags) {
7363 return g_node_n_nodes(&this, flags);
7366 // Unintrospectable method: nth_child() / g_node_nth_child()
7367 // Gets a child of a #GNode, using the given index.
7368 // The first child is at index 0. If the index is
7369 // too big, %NULL is returned.
7370 // RETURNS: the child of @node at index @n
7371 // <n>: the index of the desired child
7372 Node* nth_child()(uint n) {
7373 return g_node_nth_child(&this, n);
7376 // Unintrospectable method: prepend() / g_node_prepend()
7377 // Inserts a #GNode as the first child of the given parent.
7378 // RETURNS: the inserted #GNode
7379 // <node>: the #GNode to insert
7380 Node* prepend()(Node* node) {
7381 return g_node_prepend(&this, node);
7384 // Reverses the order of the children of a #GNode.
7385 // (It doesn't change the order of the grandchildren.)
7386 void reverse_children()() {
7387 g_node_reverse_children(&this);
7390 // Unintrospectable method: traverse() / g_node_traverse()
7391 // Traverses a tree starting at the given root #GNode.
7392 // It calls the given function for each node visited.
7393 // The traversal can be halted at any point by returning %TRUE from @func.
7394 // <order>: the order in which nodes are visited - %G_IN_ORDER, %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER.
7395 // <flags>: which types of children are to be visited, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
7396 // <max_depth>: the maximum depth of the traversal. Nodes below this depth will not be visited. If max_depth is -1 all nodes in the tree are visited. If depth is 1, only the root is visited. If depth is 2, the root and its children are visited. And so on.
7397 // <func>: the function to call for each visited #GNode
7398 // <data>: user data to pass to the function
7399 void traverse()(TraverseType order, TraverseFlags flags, int max_depth, NodeTraverseFunc func, void* data) {
7400 g_node_traverse(&this, order, flags, max_depth, func, data);
7402 // Unlinks a #GNode from a tree, resulting in two separate trees.
7403 void unlink()() {
7404 g_node_unlink(&this);
7407 // Unintrospectable function: new() / g_node_new()
7408 // Creates a new #GNode containing the given data.
7409 // Used to create the first node in a tree.
7410 // RETURNS: a new #GNode
7411 // <data>: the data of the new node
7412 static Node* new_()(void* data) {
7413 return g_node_new(data);
7418 // Specifies the type of function passed to g_node_children_foreach().
7419 // The function is called with each child node, together with the user
7420 // data passed to g_node_children_foreach().
7421 // <node>: a #GNode.
7422 // <data>: user data passed to g_node_children_foreach().
7423 extern (C) alias void function (Node* node, void* data) NodeForeachFunc;
7426 // Specifies the type of function passed to g_node_traverse(). The
7427 // function is called with each of the nodes visited, together with the
7428 // user data passed to g_node_traverse(). If the function returns
7429 // %TRUE, then the traversal is stopped.
7430 // <node>: a #GNode.
7431 // <data>: user data passed to g_node_traverse().
7432 extern (C) alias int function (Node* node, void* data) NodeTraverseFunc;
7435 // Defines how a Unicode string is transformed in a canonical
7436 // form, standardizing such issues as whether a character with
7437 // an accent is represented as a base character and combining
7438 // accent or as a single precomposed character. Unicode strings
7439 // should generally be normalized before comparing them.
7440 enum NormalizeMode {
7441 DEFAULT = 0,
7442 NFD = 0,
7443 DEFAULT_COMPOSE = 1,
7444 NFC = 1,
7445 ALL = 2,
7446 NFKD = 2,
7447 ALL_COMPOSE = 3,
7448 NFKC = 3
7450 enum OPTION_REMAINING = "";
7452 // A #GOnce struct controls a one-time initialization function. Any
7453 // one-time initialization function must have its own unique #GOnce
7454 // struct.
7455 struct Once /* Version 2.4 */ {
7456 OnceStatus status;
7457 void* retval;
7459 // Unintrospectable method: impl() / g_once_impl()
7460 void* impl()(ThreadFunc func, void* arg) {
7461 return g_once_impl(&this, func, arg);
7464 // VERSION: 2.14
7465 // Function to be called when starting a critical initialization
7466 // section. The argument @location must point to a static
7467 // 0-initialized variable that will be set to a value other than 0 at
7468 // the end of the initialization section. In combination with
7469 // g_once_init_leave() and the unique address @value_location, it can
7470 // be ensured that an initialization section will be executed only once
7471 // during a program's life time, and that concurrent threads are
7472 // blocked until initialization completed. To be used in constructs
7473 // like this:
7475 // |[
7476 // static gsize initialization_value = 0;
7478 // if (g_once_init_enter (&amp;initialization_value))
7479 // {
7480 // gsize setup_value = 42; /&ast;* initialization code here *&ast;/
7482 // g_once_init_leave (&amp;initialization_value, setup_value);
7483 // }
7485 // /&ast;* use initialization_value here *&ast;/
7486 // ]|
7488 // %FALSE and blocks otherwise
7489 // RETURNS: %TRUE if the initialization section should be entered,
7490 // <location>: location of a static initializable variable containing 0
7491 static int init_enter()(void* location) {
7492 return g_once_init_enter(location);
7495 // VERSION: 2.14
7496 // Counterpart to g_once_init_enter(). Expects a location of a static
7497 // 0-initialized initialization variable, and an initialization value
7498 // other than 0. Sets the variable to the initialization value, and
7499 // releases concurrent threads blocking in g_once_init_enter() on this
7500 // initialization variable.
7501 // <location>: location of a static initializable variable containing 0
7502 // <result>: new non-0 value for *@value_location
7503 static void init_leave()(void* location, size_t result) {
7504 g_once_init_leave(location, result);
7509 // The possible statuses of a one-time initialization function
7510 // controlled by a #GOnce struct.
7511 enum OnceStatus /* Version 2.4 */ {
7512 NOTCALLED = 0,
7513 PROGRESS = 1,
7514 READY = 2
7517 // The #GOptionArg enum values determine which type of extra argument the
7518 // options expect to find. If an option expects an extra argument, it
7519 // can be specified in several ways; with a short option:
7520 // <option>-x arg</option>, with a long option: <option>--name arg</option>
7521 // or combined in a single argument: <option>--name=arg</option>.
7522 enum OptionArg {
7523 NONE = 0,
7524 STRING = 1,
7525 INT = 2,
7526 CALLBACK = 3,
7527 FILENAME = 4,
7528 STRING_ARRAY = 5,
7529 FILENAME_ARRAY = 6,
7530 DOUBLE = 7,
7531 INT64 = 8
7534 // The type of function to be passed as callback for %G_OPTION_ARG_CALLBACK
7535 // options.
7537 // occurred, in which case @error should be set with g_set_error()
7538 // RETURNS: %TRUE if the option was successfully parsed, %FALSE if an error
7539 // <option_name>: The name of the option being parsed. This will be either a single dash followed by a single letter (for a short name) or two dashes followed by a long option name.
7540 // <value>: The value to be parsed.
7541 // <data>: User data added to the #GOptionGroup containing the option when it was created with g_option_group_new()
7542 extern (C) alias int function (char* option_name, char* value, void* data, GLib2.Error** error=null) OptionArgFunc;
7545 // A <structname>GOptionContext</structname> struct defines which options
7546 // are accepted by the commandline option parser. The struct has only private
7547 // fields and should not be directly accessed.
7548 struct OptionContext {
7550 // VERSION: 2.6
7551 // Adds a #GOptionGroup to the @context, so that parsing with @context
7552 // will recognize the options in the group. Note that the group will
7553 // be freed together with the context when g_option_context_free() is
7554 // called, so you must not free the group yourself after adding it
7555 // to a context.
7556 // <group>: the group to add
7557 void add_group()(OptionGroup* group) {
7558 g_option_context_add_group(&this, group);
7561 // VERSION: 2.6
7562 // A convenience function which creates a main group if it doesn't
7563 // exist, adds the @entries to it and sets the translation domain.
7564 // <entries>: a %NULL-terminated array of #GOptionEntry<!-- -->s
7565 // <translation_domain>: a translation domain to use for translating the <option>--help</option> output for the options in @entries with gettext(), or %NULL
7566 void add_main_entries()(OptionEntry* entries, char* translation_domain) {
7567 g_option_context_add_main_entries(&this, entries, translation_domain);
7570 // VERSION: 2.6
7571 // Frees context and all the groups which have been
7572 // added to it.
7574 // Please note that parsed arguments need to be freed separately (see
7575 // #GOptionEntry).
7576 void free()() {
7577 g_option_context_free(&this);
7580 // VERSION: 2.12
7581 // Returns the description. See g_option_context_set_description().
7582 // RETURNS: the description
7583 char* get_description()() {
7584 return g_option_context_get_description(&this);
7587 // VERSION: 2.14
7588 // Returns a formatted, translated help text for the given context.
7589 // To obtain the text produced by <option>--help</option>, call
7590 // <literal>g_option_context_get_help (context, TRUE, NULL)</literal>.
7591 // To obtain the text produced by <option>--help-all</option>, call
7592 // <literal>g_option_context_get_help (context, FALSE, NULL)</literal>.
7593 // To obtain the help text for an option group, call
7594 // <literal>g_option_context_get_help (context, FALSE, group)</literal>.
7595 // RETURNS: A newly allocated string containing the help text
7596 // <main_help>: if %TRUE, only include the main group
7597 // <group>: the #GOptionGroup to create help for, or %NULL
7598 char* /*new*/ get_help()(int main_help, OptionGroup* group) {
7599 return g_option_context_get_help(&this, main_help, group);
7602 // VERSION: 2.6
7603 // Returns whether automatic <option>--help</option> generation
7604 // is turned on for @context. See g_option_context_set_help_enabled().
7605 // RETURNS: %TRUE if automatic help generation is turned on.
7606 int get_help_enabled()() {
7607 return g_option_context_get_help_enabled(&this);
7610 // VERSION: 2.6
7611 // Returns whether unknown options are ignored or not. See
7612 // g_option_context_set_ignore_unknown_options().
7613 // RETURNS: %TRUE if unknown options are ignored.
7614 int get_ignore_unknown_options()() {
7615 return g_option_context_get_ignore_unknown_options(&this);
7618 // Unintrospectable method: get_main_group() / g_option_context_get_main_group()
7619 // VERSION: 2.6
7620 // Returns a pointer to the main group of @context.
7622 // have a main group. Note that group belongs to @context and should
7623 // not be modified or freed.
7624 // RETURNS: the main group of @context, or %NULL if @context doesn't
7625 OptionGroup* get_main_group()() {
7626 return g_option_context_get_main_group(&this);
7629 // VERSION: 2.12
7630 // Returns the summary. See g_option_context_set_summary().
7631 // RETURNS: the summary
7632 char* get_summary()() {
7633 return g_option_context_get_summary(&this);
7636 // VERSION: 2.6
7637 // Parses the command line arguments, recognizing options
7638 // which have been added to @context. A side-effect of
7639 // calling this function is that g_set_prgname() will be
7640 // called.
7642 // If the parsing is successful, any parsed arguments are
7643 // removed from the array and @argc and @argv are updated
7644 // accordingly. A '--' option is stripped from @argv
7645 // unless there are unparsed options before and after it,
7646 // or some of the options after it start with '-'. In case
7647 // of an error, @argc and @argv are left unmodified.
7649 // If automatic <option>--help</option> support is enabled
7650 // (see g_option_context_set_help_enabled()), and the
7651 // @argv array contains one of the recognized help options,
7652 // this function will produce help output to stdout and
7653 // call <literal>exit (0)</literal>.
7655 // Note that function depends on the
7656 // <link linkend="setlocale">current locale</link> for
7657 // automatic character set conversion of string and filename
7658 // arguments.
7660 // %FALSE if an error occurred
7661 // RETURNS: %TRUE if the parsing was successful,
7662 // <argc>: a pointer to the number of command line arguments
7663 // <argv>: a pointer to the array of command line arguments
7664 int parse()(/*inout*/ int* argc, /*inout*/ char*** argv, GLib2.Error** error=null) {
7665 return g_option_context_parse(&this, argc, argv, error);
7668 // VERSION: 2.12
7669 // Adds a string to be displayed in <option>--help</option> output
7670 // after the list of options. This text often includes a bug reporting
7671 // address.
7673 // Note that the summary is translated (see
7674 // g_option_context_set_translate_func()).
7675 // <description>: a string to be shown in <option>--help</option> output after the list of options, or %NULL
7676 void set_description()(char* description) {
7677 g_option_context_set_description(&this, description);
7680 // VERSION: 2.6
7681 // Enables or disables automatic generation of <option>--help</option>
7682 // output. By default, g_option_context_parse() recognizes
7683 // <option>--help</option>, <option>-h</option>,
7684 // <option>-?</option>, <option>--help-all</option>
7685 // and <option>--help-</option><replaceable>groupname</replaceable> and creates
7686 // suitable output to stdout.
7687 // <help_enabled>: %TRUE to enable <option>--help</option>, %FALSE to disable it
7688 void set_help_enabled()(int help_enabled) {
7689 g_option_context_set_help_enabled(&this, help_enabled);
7692 // VERSION: 2.6
7693 // Sets whether to ignore unknown options or not. If an argument is
7694 // ignored, it is left in the @argv array after parsing. By default,
7695 // g_option_context_parse() treats unknown options as error.
7697 // This setting does not affect non-option arguments (i.e. arguments
7698 // which don't start with a dash). But note that GOption cannot reliably
7699 // determine whether a non-option belongs to a preceding unknown option.
7700 // <ignore_unknown>: %TRUE to ignore unknown options, %FALSE to produce an error when unknown options are met
7701 void set_ignore_unknown_options()(int ignore_unknown) {
7702 g_option_context_set_ignore_unknown_options(&this, ignore_unknown);
7705 // VERSION: 2.6
7706 // Sets a #GOptionGroup as main group of the @context.
7707 // This has the same effect as calling g_option_context_add_group(),
7708 // the only difference is that the options in the main group are
7709 // treated differently when generating <option>--help</option> output.
7710 // <group>: the group to set as main group
7711 void set_main_group()(OptionGroup* group) {
7712 g_option_context_set_main_group(&this, group);
7715 // VERSION: 2.12
7716 // Adds a string to be displayed in <option>--help</option> output
7717 // before the list of options. This is typically a summary of the
7718 // program functionality.
7720 // Note that the summary is translated (see
7721 // g_option_context_set_translate_func() and
7722 // g_option_context_set_translation_domain()).
7723 // <summary>: a string to be shown in <option>--help</option> output before the list of options, or %NULL
7724 void set_summary()(char* summary) {
7725 g_option_context_set_summary(&this, summary);
7728 // VERSION: 2.12
7729 // Sets the function which is used to translate the contexts
7730 // user-visible strings, for <option>--help</option> output.
7731 // If @func is %NULL, strings are not translated.
7733 // Note that option groups have their own translation functions,
7734 // this function only affects the @parameter_string (see g_option_context_new()),
7735 // the summary (see g_option_context_set_summary()) and the description
7736 // (see g_option_context_set_description()).
7738 // If you are using gettext(), you only need to set the translation
7739 // domain, see g_option_context_set_translation_domain().
7740 // <func>: the #GTranslateFunc, or %NULL
7741 // <data>: user data to pass to @func, or %NULL
7742 // <destroy_notify>: a function which gets called to free @data, or %NULL
7743 void set_translate_func()(TranslateFunc func, void* data, DestroyNotify destroy_notify) {
7744 g_option_context_set_translate_func(&this, func, data, destroy_notify);
7747 // VERSION: 2.12
7748 // A convenience function to use gettext() for translating
7749 // user-visible strings.
7750 // <domain>: the domain to use
7751 void set_translation_domain()(char* domain) {
7752 g_option_context_set_translation_domain(&this, domain);
7755 // Unintrospectable function: new() / g_option_context_new()
7756 // VERSION: 2.6
7757 // Creates a new option context.
7759 // The @parameter_string can serve multiple purposes. It can be used
7760 // to add descriptions for "rest" arguments, which are not parsed by
7761 // the #GOptionContext, typically something like "FILES" or
7762 // "FILE1 FILE2...". If you are using #G_OPTION_REMAINING for
7763 // collecting "rest" arguments, GLib handles this automatically by
7764 // using the @arg_description of the corresponding #GOptionEntry in
7765 // the usage summary.
7767 // Another usage is to give a short summary of the program
7768 // functionality, like " - frob the strings", which will be displayed
7769 // in the same line as the usage. For a longer description of the
7770 // program functionality that should be displayed as a paragraph
7771 // below the usage line, use g_option_context_set_summary().
7773 // Note that the @parameter_string is translated using the
7774 // function set with g_option_context_set_translate_func(), so
7775 // it should normally be passed untranslated.
7777 // freed with g_option_context_free() after use.
7778 // RETURNS: a newly created #GOptionContext, which must be
7779 // <parameter_string>: a string which is displayed in the first line of <option>--help</option> output, after the usage summary <literal><replaceable>programname</replaceable> [OPTION...]</literal>
7780 static OptionContext* new_()(char* parameter_string) {
7781 return g_option_context_new(parameter_string);
7786 // A <structname>GOptionEntry</structname> defines a single option.
7787 // To have an effect, they must be added to a #GOptionGroup with
7788 // g_option_context_add_main_entries() or g_option_group_add_entries().
7789 struct OptionEntry {
7790 char* long_name;
7791 char short_name;
7792 int flags;
7793 OptionArg arg;
7794 void* arg_data;
7795 char* description, arg_description;
7798 // Error codes returned by option parsing.
7799 enum OptionError {
7800 UNKNOWN_OPTION = 0,
7801 BAD_VALUE = 1,
7802 FAILED = 2
7805 // The type of function to be used as callback when a parse error occurs.
7806 // <context>: The active #GOptionContext
7807 // <group>: The group to which the function belongs
7808 // <data>: User data added to the #GOptionGroup containing the option when it was created with g_option_group_new()
7809 extern (C) alias void function (OptionContext* context, OptionGroup* group, void* data, GLib2.Error** error=null) OptionErrorFunc;
7811 // Flags which modify individual options.
7812 enum OptionFlags {
7813 HIDDEN = 1,
7814 IN_MAIN = 2,
7815 REVERSE = 4,
7816 NO_ARG = 8,
7817 FILENAME = 16,
7818 OPTIONAL_ARG = 32,
7819 NOALIAS = 64
7822 // A <structname>GOptionGroup</structname> struct defines the options in a single
7823 // group. The struct has only private fields and should not be directly accessed.
7825 // All options in a group share the same translation function. Libraries which
7826 // need to parse commandline options are expected to provide a function for
7827 // getting a <structname>GOptionGroup</structname> holding their options, which
7828 // the application can then add to its #GOptionContext.
7829 struct OptionGroup {
7831 // VERSION: 2.6
7832 // Adds the options specified in @entries to @group.
7833 // <entries>: a %NULL-terminated array of #GOptionEntry<!-- -->s
7834 void add_entries()(OptionEntry* entries) {
7835 g_option_group_add_entries(&this, entries);
7838 // VERSION: 2.6
7839 // Frees a #GOptionGroup. Note that you must <emphasis>not</emphasis>
7840 // free groups which have been added to a #GOptionContext.
7841 void free()() {
7842 g_option_group_free(&this);
7845 // Unintrospectable method: set_error_hook() / g_option_group_set_error_hook()
7846 // VERSION: 2.6
7847 // Associates a function with @group which will be called
7848 // from g_option_context_parse() when an error occurs.
7850 // Note that the user data to be passed to @error_func can be
7851 // specified when constructing the group with g_option_group_new().
7852 // <error_func>: a function to call when an error occurs
7853 void set_error_hook()(OptionErrorFunc error_func) {
7854 g_option_group_set_error_hook(&this, error_func);
7857 // Unintrospectable method: set_parse_hooks() / g_option_group_set_parse_hooks()
7858 // VERSION: 2.6
7859 // Associates two functions with @group which will be called
7860 // from g_option_context_parse() before the first option is parsed
7861 // and after the last option has been parsed, respectively.
7863 // Note that the user data to be passed to @pre_parse_func and
7864 // @post_parse_func can be specified when constructing the group
7865 // with g_option_group_new().
7866 // <pre_parse_func>: a function to call before parsing, or %NULL
7867 // <post_parse_func>: a function to call after parsing, or %NULL
7868 void set_parse_hooks()(OptionParseFunc pre_parse_func, OptionParseFunc post_parse_func) {
7869 g_option_group_set_parse_hooks(&this, pre_parse_func, post_parse_func);
7872 // VERSION: 2.6
7873 // Sets the function which is used to translate user-visible
7874 // strings, for <option>--help</option> output. Different
7875 // groups can use different #GTranslateFunc<!-- -->s. If @func
7876 // is %NULL, strings are not translated.
7878 // If you are using gettext(), you only need to set the translation
7879 // domain, see g_option_group_set_translation_domain().
7880 // <func>: the #GTranslateFunc, or %NULL
7881 // <data>: user data to pass to @func, or %NULL
7882 // <destroy_notify>: a function which gets called to free @data, or %NULL
7883 void set_translate_func()(TranslateFunc func, void* data, DestroyNotify destroy_notify) {
7884 g_option_group_set_translate_func(&this, func, data, destroy_notify);
7887 // VERSION: 2.6
7888 // A convenience function to use gettext() for translating
7889 // user-visible strings.
7890 // <domain>: the domain to use
7891 void set_translation_domain()(char* domain) {
7892 g_option_group_set_translation_domain(&this, domain);
7895 // Unintrospectable function: new() / g_option_group_new()
7896 // VERSION: 2.6
7897 // Creates a new #GOptionGroup.
7899 // to a #GOptionContext or freed with g_option_group_free().
7900 // RETURNS: a newly created option group. It should be added
7901 // <name>: the name for the option group, this is used to provide help for the options in this group with <option>--help-</option>@name
7902 // <description>: a description for this group to be shown in <option>--help</option>. This string is translated using the translation domain or translation function of the group
7903 // <help_description>: a description for the <option>--help-</option>@name option. This string is translated using the translation domain or translation function of the group
7904 // <user_data>: user data that will be passed to the pre- and post-parse hooks, the error hook and to callbacks of %G_OPTION_ARG_CALLBACK options, or %NULL
7905 // <destroy>: a function that will be called to free @user_data, or %NULL
7906 static OptionGroup* new_()(char* name, char* description, char* help_description, void* user_data, DestroyNotify destroy) {
7907 return g_option_group_new(name, description, help_description, user_data, destroy);
7912 // The type of function that can be called before and after parsing.
7914 // occurred, in which case @error should be set with g_set_error()
7915 // RETURNS: %TRUE if the function completed successfully, %FALSE if an error
7916 // <context>: The active #GOptionContext
7917 // <group>: The group to which the function belongs
7918 // <data>: User data added to the #GOptionGroup containing the option when it was created with g_option_group_new()
7919 extern (C) alias int function (OptionContext* context, OptionGroup* group, void* data, GLib2.Error** error=null) OptionParseFunc;
7921 enum int PDP_ENDIAN = 3412;
7922 enum double PI = 3.141593;
7923 enum double PI_2 = 1.570796;
7924 enum double PI_4 = 0.785398;
7925 enum POLLFD_FORMAT = "%#I64x";
7926 enum int PRIORITY_DEFAULT = 0;
7927 enum int PRIORITY_DEFAULT_IDLE = 200;
7928 enum int PRIORITY_HIGH = -100;
7929 enum int PRIORITY_HIGH_IDLE = 100;
7930 enum int PRIORITY_LOW = 300;
7932 // A <structname>GPatternSpec</structname> is the 'compiled' form of a
7933 // pattern. This structure is opaque and its fields cannot be accessed
7934 // directly.
7935 struct PatternSpec {
7937 // Compares two compiled pattern specs and returns whether they will
7938 // match the same set of strings.
7939 // <pspec2>: another #GPatternSpec
7940 int equal()(PatternSpec* pspec2) {
7941 return g_pattern_spec_equal(&this, pspec2);
7943 // Frees the memory allocated for the #GPatternSpec.
7944 void free()() {
7945 g_pattern_spec_free(&this);
7948 // Unintrospectable function: new() / g_pattern_spec_new()
7949 // Compiles a pattern to a #GPatternSpec.
7950 // <pattern>: a zero-terminated UTF-8 encoded string
7951 static PatternSpec* new_()(char* pattern) {
7952 return g_pattern_spec_new(pattern);
7957 // Represents a file descriptor, which events to poll for, and which events
7958 // occurred.
7959 struct PollFD {
7960 int fd;
7961 ushort events, revents;
7965 // Specifies the type of function passed to g_main_context_set_poll_func().
7966 // The semantics of the function should match those of the poll() system call.
7968 // reported, or -1 if an error occurred.
7969 // RETURNS: the number of #GPollFD elements which have events or errors
7970 // <ufds>: an array of #GPollFD elements
7971 // <nfsd>: the number of elements in @ufds
7972 // <timeout_>: the maximum time to wait for an event of the file descriptors. A negative value indicates an infinite timeout.
7973 extern (C) alias int function (PollFD* ufds, uint nfsd, int timeout_) PollFunc;
7976 // Specifies the type of the print handler functions.
7977 // These are called with the complete formatted string to output.
7978 // <string>: the message to output
7979 extern (C) alias void function (char* string_) PrintFunc;
7982 // The #GPrivate struct is an opaque data structure to represent a
7983 // thread-local data key. It is approximately equivalent to the
7984 // pthread_setspecific()/pthread_getspecific() APIs on POSIX and to
7985 // TlsSetValue()/TlsGetValue() on Windows.
7987 // If you don't already know why you might want this functionality,
7988 // then you probably don't need it.
7990 // #GPrivate is a very limited resource (as far as 128 per program,
7991 // shared between all libraries). It is also not possible to destroy a
7992 // #GPrivate after it has been used. As such, it is only ever acceptable
7993 // to use #GPrivate in static scope, and even then sparingly so.
7995 // See G_PRIVATE_INIT() for a couple of examples.
7997 // The #GPrivate structure should be considered opaque. It should only
7998 // be accessed via the <function>g_private_</function> functions.
7999 struct Private {
8000 private void* p;
8001 private DestroyNotify notify;
8002 private void*[2] future;
8005 // Unintrospectable method: get() / g_private_get()
8006 // Returns the current value of the thread local variable @key.
8008 // If the value has not yet been set in this thread, %NULL is returned.
8009 // Values are never copied between threads (when a new thread is
8010 // created, for example).
8011 // RETURNS: the thread-local value
8012 void* get()() {
8013 return g_private_get(&this);
8016 // VERSION: 2.32
8017 // Sets the thread local variable @key to have the value @value in the
8018 // current thread.
8020 // This function differs from g_private_set() in the following way: if
8021 // the previous value was non-%NULL then the #GDestroyNotify handler for
8022 // @key is run on it.
8023 // <value>: the new value
8024 void replace()(void* value) {
8025 g_private_replace(&this, value);
8028 // Sets the thread local variable @key to have the value @value in the
8029 // current thread.
8031 // This function differs from g_private_replace() in the following way:
8032 // the #GDestroyNotify for @key is not called on the old value.
8033 // <value>: the new value
8034 void set()(void* value) {
8035 g_private_set(&this, value);
8039 // Contains the public fields of a pointer array.
8040 struct PtrArray {
8041 void** pdata;
8042 uint len;
8045 // Adds a pointer to the end of the pointer array. The array will grow
8046 // in size automatically if necessary.
8047 // <array>: a #GPtrArray.
8048 // <data>: the pointer to add.
8049 static void add()(PtrArray* array, void* data) {
8050 g_ptr_array_add(array, data);
8053 // Unintrospectable function: foreach() / g_ptr_array_foreach()
8054 // VERSION: 2.4
8055 // Calls a function for each element of a #GPtrArray.
8056 // <array>: a #GPtrArray
8057 // <func>: the function to call for each array element
8058 // <user_data>: user data to pass to the function
8059 static void foreach_()(PtrArray* array, Func func, void* user_data) {
8060 g_ptr_array_foreach(array, func, user_data);
8063 // Unintrospectable function: free() / g_ptr_array_free()
8064 // Frees the memory allocated for the #GPtrArray. If @free_seg is %TRUE
8065 // it frees the memory block holding the elements as well. Pass %FALSE
8066 // if you want to free the #GPtrArray wrapper but preserve the
8067 // underlying array for use elsewhere. If the reference count of @array
8068 // is greater than one, the #GPtrArray wrapper is preserved but the
8069 // size of @array will be set to zero.
8071 // <note><para>If array contents point to dynamically-allocated
8072 // memory, they should be freed separately if @free_seg is %TRUE and no
8073 // #GDestroyNotify function has been set for @array.</para></note>
8074 // <array>: a #GPtrArray.
8075 // <free_seg>: if %TRUE the actual pointer array is freed as well.
8076 static void** free()(PtrArray* array, int free_seg) {
8077 return g_ptr_array_free(array, free_seg);
8080 // Unintrospectable function: new() / g_ptr_array_new()
8081 // Creates a new #GPtrArray with a reference count of 1.
8082 static PtrArray* new_()() {
8083 return g_ptr_array_new();
8086 // Unintrospectable function: new_full() / g_ptr_array_new_full()
8087 // VERSION: 2.30
8088 // Creates a new #GPtrArray with @reserved_size pointers preallocated
8089 // and a reference count of 1. This avoids frequent reallocation, if
8090 // you are going to add many pointers to the array. Note however that
8091 // the size of the array is still 0. It also set @element_free_func
8092 // for freeing each element when the array is destroyed either via
8093 // g_ptr_array_unref(), when g_ptr_array_free() is called with @free_segment
8094 // set to %TRUE or when removing elements.
8095 // RETURNS: A new #GPtrArray.
8096 // <reserved_size>: number of pointers preallocated.
8097 // <element_free_func>: A function to free elements with destroy @array or %NULL.
8098 static PtrArray* new_full()(uint reserved_size, DestroyNotify element_free_func) {
8099 return g_ptr_array_new_full(reserved_size, element_free_func);
8102 // Unintrospectable function: new_with_free_func() / g_ptr_array_new_with_free_func()
8103 // VERSION: 2.22
8104 // Creates a new #GPtrArray with a reference count of 1 and use @element_free_func
8105 // for freeing each element when the array is destroyed either via
8106 // g_ptr_array_unref(), when g_ptr_array_free() is called with @free_segment
8107 // set to %TRUE or when removing elements.
8108 // RETURNS: A new #GPtrArray.
8109 // <element_free_func>: A function to free elements with destroy @array or %NULL.
8110 static PtrArray* new_with_free_func()(DestroyNotify element_free_func) {
8111 return g_ptr_array_new_with_free_func(element_free_func);
8114 // Unintrospectable function: ref() / g_ptr_array_ref()
8115 // VERSION: 2.22
8116 // Atomically increments the reference count of @array by one. This
8117 // function is MT-safe and may be called from any thread.
8118 // RETURNS: The passed in #GPtrArray.
8119 // <array>: A #GArray.
8120 static PtrArray* ref_()(PtrArray* array) {
8121 return g_ptr_array_ref(array);
8124 // Removes the first occurrence of the given pointer from the pointer
8125 // array. The following elements are moved down one place. If @array
8126 // has a non-%NULL #GDestroyNotify function it is called for the
8127 // removed element.
8129 // It returns %TRUE if the pointer was removed, or %FALSE if the
8130 // pointer was not found.
8131 // <array>: a #GPtrArray.
8132 // <data>: the pointer to remove.
8133 static int remove()(PtrArray* array, void* data) {
8134 return g_ptr_array_remove(array, data);
8137 // Removes the first occurrence of the given pointer from the pointer
8138 // array. The last element in the array is used to fill in the space,
8139 // so this function does not preserve the order of the array. But it is
8140 // faster than g_ptr_array_remove(). If @array has a non-%NULL
8141 // #GDestroyNotify function it is called for the removed element.
8143 // It returns %TRUE if the pointer was removed, or %FALSE if the
8144 // pointer was not found.
8145 // <array>: a #GPtrArray.
8146 // <data>: the pointer to remove.
8147 static int remove_fast()(PtrArray* array, void* data) {
8148 return g_ptr_array_remove_fast(array, data);
8151 // Unintrospectable function: remove_index() / g_ptr_array_remove_index()
8152 // Removes the pointer at the given index from the pointer array. The
8153 // following elements are moved down one place. If @array has a
8154 // non-%NULL #GDestroyNotify function it is called for the removed
8155 // element.
8156 // <array>: a #GPtrArray.
8157 // <index_>: the index of the pointer to remove.
8158 static void* remove_index()(PtrArray* array, uint index_) {
8159 return g_ptr_array_remove_index(array, index_);
8162 // Unintrospectable function: remove_index_fast() / g_ptr_array_remove_index_fast()
8163 // Removes the pointer at the given index from the pointer array. The
8164 // last element in the array is used to fill in the space, so this
8165 // function does not preserve the order of the array. But it is faster
8166 // than g_ptr_array_remove_index(). If @array has a non-%NULL
8167 // #GDestroyNotify function it is called for the removed element.
8168 // <array>: a #GPtrArray.
8169 // <index_>: the index of the pointer to remove.
8170 static void* remove_index_fast()(PtrArray* array, uint index_) {
8171 return g_ptr_array_remove_index_fast(array, index_);
8174 // VERSION: 2.4
8175 // Removes the given number of pointers starting at the given index
8176 // from a #GPtrArray. The following elements are moved to close the
8177 // gap. If @array has a non-%NULL #GDestroyNotify function it is called
8178 // for the removed elements.
8179 // <array>: a @GPtrArray.
8180 // <index_>: the index of the first pointer to remove.
8181 // <length>: the number of pointers to remove.
8182 static void remove_range()(PtrArray* array, uint index_, uint length) {
8183 g_ptr_array_remove_range(array, index_, length);
8186 // VERSION: 2.22
8187 // Sets a function for freeing each element when @array is destroyed
8188 // either via g_ptr_array_unref(), when g_ptr_array_free() is called
8189 // with @free_segment set to %TRUE or when removing elements.
8190 // <array>: A #GPtrArray.
8191 // <element_free_func>: A function to free elements with destroy @array or %NULL.
8192 static void set_free_func()(PtrArray* array, DestroyNotify element_free_func) {
8193 g_ptr_array_set_free_func(array, element_free_func);
8196 // Sets the size of the array. When making the array larger,
8197 // newly-added elements will be set to %NULL. When making it smaller,
8198 // if @array has a non-%NULL #GDestroyNotify function then it will be
8199 // called for the removed elements.
8200 // <array>: a #GPtrArray.
8201 // <length>: the new length of the pointer array.
8202 static void set_size()(PtrArray* array, int length) {
8203 g_ptr_array_set_size(array, length);
8206 // Unintrospectable function: sized_new() / g_ptr_array_sized_new()
8207 // Creates a new #GPtrArray with @reserved_size pointers preallocated
8208 // and a reference count of 1. This avoids frequent reallocation, if
8209 // you are going to add many pointers to the array. Note however that
8210 // the size of the array is still 0.
8211 // <reserved_size>: number of pointers preallocated.
8212 static PtrArray* sized_new()(uint reserved_size) {
8213 return g_ptr_array_sized_new(reserved_size);
8216 // Unintrospectable function: sort() / g_ptr_array_sort()
8217 // Sorts the array, using @compare_func which should be a qsort()-style
8218 // comparison function (returns less than zero for first arg is less
8219 // than second arg, zero for equal, greater than zero if irst arg is
8220 // greater than second arg).
8222 // If two array elements compare equal, their order in the sorted array
8223 // is undefined. If you want equal elements to keep their order (i.e.
8224 // you want a stable sort) you can write a comparison function that,
8225 // if two elements would otherwise compare equal, compares them by
8226 // their addresses.
8228 // <note><para>The comparison function for g_ptr_array_sort() doesn't
8229 // take the pointers from the array as arguments, it takes pointers to
8230 // the pointers in the array.</para></note>
8231 // <array>: a #GPtrArray.
8232 // <compare_func>: comparison function.
8233 static void sort()(PtrArray* array, CompareFunc compare_func) {
8234 g_ptr_array_sort(array, compare_func);
8237 // Unintrospectable function: sort_with_data() / g_ptr_array_sort_with_data()
8238 // Like g_ptr_array_sort(), but the comparison function has an extra
8239 // user data argument.
8241 // <note><para>The comparison function for g_ptr_array_sort_with_data()
8242 // doesn't take the pointers from the array as arguments, it takes
8243 // pointers to the pointers in the array.</para></note>
8244 // <array>: a #GPtrArray.
8245 // <compare_func>: comparison function.
8246 // <user_data>: data to pass to @compare_func.
8247 static void sort_with_data()(PtrArray* array, CompareDataFunc compare_func, void* user_data) {
8248 g_ptr_array_sort_with_data(array, compare_func, user_data);
8251 // VERSION: 2.22
8252 // Atomically decrements the reference count of @array by one. If the
8253 // reference count drops to 0, the effect is the same as calling
8254 // g_ptr_array_free() with @free_segment set to %TRUE. This function
8255 // is MT-safe and may be called from any thread.
8256 // <array>: A #GPtrArray.
8257 static void unref()(PtrArray* array) {
8258 g_ptr_array_unref(array);
8263 // Contains the public fields of a
8264 // <link linkend="glib-Double-ended-Queues">Queue</link>.
8265 struct Queue {
8266 GLib2.List* head, tail;
8267 uint length;
8270 // VERSION: 2.14
8271 // Removes all the elements in @queue. If queue elements contain
8272 // dynamically-allocated memory, they should be freed first.
8273 void clear()() {
8274 g_queue_clear(&this);
8277 // Unintrospectable method: copy() / g_queue_copy()
8278 // VERSION: 2.4
8279 // Copies a @queue. Note that is a shallow copy. If the elements in the
8280 // queue consist of pointers to data, the pointers are copied, but the
8281 // actual data is not.
8282 // RETURNS: A copy of @queue
8283 Queue* copy()() {
8284 return g_queue_copy(&this);
8287 // Unintrospectable method: delete_link() / g_queue_delete_link()
8288 // VERSION: 2.4
8289 // Removes @link_ from @queue and frees it.
8291 // @link_ must be part of @queue.
8292 // <link_>: a #GList link that <emphasis>must</emphasis> be part of @queue
8293 void delete_link()(GLib2.List* link_) {
8294 g_queue_delete_link(&this, link_);
8297 // Unintrospectable method: find() / g_queue_find()
8298 // VERSION: 2.4
8299 // Finds the first link in @queue which contains @data.
8300 // RETURNS: The first link in @queue which contains @data.
8301 // <data>: data to find
8302 GLib2.List* find()(const(void)* data) {
8303 return g_queue_find(&this, data);
8306 // Unintrospectable method: find_custom() / g_queue_find_custom()
8307 // VERSION: 2.4
8308 // Finds an element in a #GQueue, using a supplied function to find the
8309 // desired element. It iterates over the queue, calling the given function
8310 // which should return 0 when the desired element is found. The function
8311 // takes two gconstpointer arguments, the #GQueue element's data as the
8312 // first argument and the given user data as the second argument.
8313 // RETURNS: The found link, or %NULL if it wasn't found
8314 // <data>: user data passed to @func
8315 // <func>: a #GCompareFunc to call for each element. It should return 0 when the desired element is found
8316 GLib2.List* find_custom()(const(void)* data, CompareFunc func) {
8317 return g_queue_find_custom(&this, data, func);
8320 // Unintrospectable method: foreach() / g_queue_foreach()
8321 // VERSION: 2.4
8322 // Calls @func for each element in the queue passing @user_data to the
8323 // function.
8324 // <func>: the function to call for each element's data
8325 // <user_data>: user data to pass to @func
8326 void foreach_()(Func func, void* user_data) {
8327 g_queue_foreach(&this, func, user_data);
8330 // Frees the memory allocated for the #GQueue. Only call this function if
8331 // @queue was created with g_queue_new(). If queue elements contain
8332 // dynamically-allocated memory, they should be freed first.
8334 // <note><para>
8335 // If queue elements contain dynamically-allocated memory,
8336 // you should either use g_queue_free_full() or free them manually
8337 // first.
8338 // </para></note>
8339 void free()() {
8340 g_queue_free(&this);
8343 // VERSION: 2.32
8344 // Convenience method, which frees all the memory used by a #GQueue, and
8345 // calls the specified destroy function on every element's data.
8346 // <free_func>: the function to be called to free each element's data
8347 void free_full()(DestroyNotify free_func) {
8348 g_queue_free_full(&this, free_func);
8351 // VERSION: 2.4
8352 // Returns the number of items in @queue.
8353 // RETURNS: The number of items in @queue.
8354 uint get_length()() {
8355 return g_queue_get_length(&this);
8358 // VERSION: 2.4
8359 // Returns the position of the first element in @queue which contains @data.
8360 // RETURNS: The position of the first element in @queue which contains @data, or -1 if no element in @queue contains @data.
8361 // <data>: the data to find.
8362 int index()(const(void)* data) {
8363 return g_queue_index(&this, data);
8366 // VERSION: 2.14
8367 // A statically-allocated #GQueue must be initialized with this function
8368 // before it can be used. Alternatively you can initialize it with
8369 // #G_QUEUE_INIT. It is not necessary to initialize queues created with
8370 // g_queue_new().
8371 void init()() {
8372 g_queue_init(&this);
8375 // Unintrospectable method: insert_after() / g_queue_insert_after()
8376 // VERSION: 2.4
8377 // Inserts @data into @queue after @sibling
8379 // @sibling must be part of @queue
8380 // <sibling>: a #GList link that <emphasis>must</emphasis> be part of @queue
8381 // <data>: the data to insert
8382 void insert_after()(GLib2.List* sibling, void* data) {
8383 g_queue_insert_after(&this, sibling, data);
8386 // Unintrospectable method: insert_before() / g_queue_insert_before()
8387 // VERSION: 2.4
8388 // Inserts @data into @queue before @sibling.
8390 // @sibling must be part of @queue.
8391 // <sibling>: a #GList link that <emphasis>must</emphasis> be part of @queue
8392 // <data>: the data to insert
8393 void insert_before()(GLib2.List* sibling, void* data) {
8394 g_queue_insert_before(&this, sibling, data);
8397 // Unintrospectable method: insert_sorted() / g_queue_insert_sorted()
8398 // VERSION: 2.4
8399 // Inserts @data into @queue using @func to determine the new position.
8400 // <data>: the data to insert
8401 // <func>: the #GCompareDataFunc used to compare elements in the queue. It is called with two elements of the @queue and @user_data. It should return 0 if the elements are equal, a negative value if the first element comes before the second, and a positive value if the second element comes before the first.
8402 // <user_data>: user data passed to @func.
8403 void insert_sorted()(void* data, CompareDataFunc func, void* user_data) {
8404 g_queue_insert_sorted(&this, data, func, user_data);
8407 // Returns %TRUE if the queue is empty.
8408 // RETURNS: %TRUE if the queue is empty.
8409 int is_empty()() {
8410 return g_queue_is_empty(&this);
8413 // Unintrospectable method: link_index() / g_queue_link_index()
8414 // VERSION: 2.4
8415 // Returns the position of @link_ in @queue.
8417 // not part of @queue
8418 // RETURNS: The position of @link_, or -1 if the link is
8419 // <link_>: A #GList link
8420 int link_index()(GLib2.List* link_) {
8421 return g_queue_link_index(&this, link_);
8424 // Unintrospectable method: peek_head() / g_queue_peek_head()
8425 // Returns the first element of the queue.
8427 // is empty.
8428 // RETURNS: the data of the first element in the queue, or %NULL if the queue
8429 void* peek_head()() {
8430 return g_queue_peek_head(&this);
8433 // Unintrospectable method: peek_head_link() / g_queue_peek_head_link()
8434 // VERSION: 2.4
8435 // Returns the first link in @queue
8436 // RETURNS: the first link in @queue, or %NULL if @queue is empty
8437 GLib2.List* peek_head_link()() {
8438 return g_queue_peek_head_link(&this);
8441 // Unintrospectable method: peek_nth() / g_queue_peek_nth()
8442 // VERSION: 2.4
8443 // Returns the @n'th element of @queue.
8445 // off the end of @queue.
8446 // RETURNS: The data for the @n'th element of @queue, or %NULL if @n is
8447 // <n>: the position of the element.
8448 void* peek_nth()(uint n) {
8449 return g_queue_peek_nth(&this, n);
8452 // Unintrospectable method: peek_nth_link() / g_queue_peek_nth_link()
8453 // VERSION: 2.4
8454 // Returns the link at the given position
8456 // end of the list
8457 // RETURNS: The link at the @n'th position, or %NULL if @n is off the
8458 // <n>: the position of the link
8459 GLib2.List* peek_nth_link()(uint n) {
8460 return g_queue_peek_nth_link(&this, n);
8463 // Unintrospectable method: peek_tail() / g_queue_peek_tail()
8464 // Returns the last element of the queue.
8466 // is empty.
8467 // RETURNS: the data of the last element in the queue, or %NULL if the queue
8468 void* peek_tail()() {
8469 return g_queue_peek_tail(&this);
8472 // Unintrospectable method: peek_tail_link() / g_queue_peek_tail_link()
8473 // VERSION: 2.4
8474 // Returns the last link @queue.
8475 // RETURNS: the last link in @queue, or %NULL if @queue is empty
8476 GLib2.List* peek_tail_link()() {
8477 return g_queue_peek_tail_link(&this);
8480 // Unintrospectable method: pop_head() / g_queue_pop_head()
8481 // Removes the first element of the queue.
8483 // is empty.
8484 // RETURNS: the data of the first element in the queue, or %NULL if the queue
8485 void* pop_head()() {
8486 return g_queue_pop_head(&this);
8489 // Unintrospectable method: pop_head_link() / g_queue_pop_head_link()
8490 // Removes the first element of the queue.
8492 // is empty.
8493 // RETURNS: the #GList element at the head of the queue, or %NULL if the queue
8494 GLib2.List* pop_head_link()() {
8495 return g_queue_pop_head_link(&this);
8498 // Unintrospectable method: pop_nth() / g_queue_pop_nth()
8499 // VERSION: 2.4
8500 // Removes the @n'th element of @queue.
8501 // RETURNS: the element's data, or %NULL if @n is off the end of @queue.
8502 // <n>: the position of the element.
8503 void* pop_nth()(uint n) {
8504 return g_queue_pop_nth(&this, n);
8507 // Unintrospectable method: pop_nth_link() / g_queue_pop_nth_link()
8508 // VERSION: 2.4
8509 // Removes and returns the link at the given position.
8510 // RETURNS: The @n'th link, or %NULL if @n is off the end of @queue.
8511 // <n>: the link's position
8512 GLib2.List* pop_nth_link()(uint n) {
8513 return g_queue_pop_nth_link(&this, n);
8516 // Unintrospectable method: pop_tail() / g_queue_pop_tail()
8517 // Removes the last element of the queue.
8519 // is empty.
8520 // RETURNS: the data of the last element in the queue, or %NULL if the queue
8521 void* pop_tail()() {
8522 return g_queue_pop_tail(&this);
8525 // Unintrospectable method: pop_tail_link() / g_queue_pop_tail_link()
8526 // Removes the last element of the queue.
8528 // is empty.
8529 // RETURNS: the #GList element at the tail of the queue, or %NULL if the queue
8530 GLib2.List* pop_tail_link()() {
8531 return g_queue_pop_tail_link(&this);
8534 // Adds a new element at the head of the queue.
8535 // <data>: the data for the new element.
8536 void push_head()(void* data) {
8537 g_queue_push_head(&this, data);
8540 // Unintrospectable method: push_head_link() / g_queue_push_head_link()
8541 // Adds a new element at the head of the queue.
8542 // <link_>: a single #GList element, <emphasis>not</emphasis> a list with more than one element.
8543 void push_head_link()(GLib2.List* link_) {
8544 g_queue_push_head_link(&this, link_);
8547 // VERSION: 2.4
8548 // Inserts a new element into @queue at the given position
8549 // <data>: the data for the new element
8550 // <n>: the position to insert the new element. If @n is negative or larger than the number of elements in the @queue, the element is added to the end of the queue.
8551 void push_nth()(void* data, int n) {
8552 g_queue_push_nth(&this, data, n);
8555 // Unintrospectable method: push_nth_link() / g_queue_push_nth_link()
8556 // VERSION: 2.4
8557 // Inserts @link into @queue at the given position.
8558 // <n>: the position to insert the link. If this is negative or larger than the number of elements in @queue, the link is added to the end of @queue.
8559 // <link_>: the link to add to @queue
8560 void push_nth_link()(int n, GLib2.List* link_) {
8561 g_queue_push_nth_link(&this, n, link_);
8564 // Adds a new element at the tail of the queue.
8565 // <data>: the data for the new element.
8566 void push_tail()(void* data) {
8567 g_queue_push_tail(&this, data);
8570 // Unintrospectable method: push_tail_link() / g_queue_push_tail_link()
8571 // Adds a new element at the tail of the queue.
8572 // <link_>: a single #GList element, <emphasis>not</emphasis> a list with more than one element.
8573 void push_tail_link()(GLib2.List* link_) {
8574 g_queue_push_tail_link(&this, link_);
8577 // VERSION: 2.4
8578 // Removes the first element in @queue that contains @data.
8579 // RETURNS: %TRUE if @data was found and removed from @queue
8580 // <data>: data to remove.
8581 int remove()(const(void)* data) {
8582 return g_queue_remove(&this, data);
8585 // VERSION: 2.4
8586 // Remove all elements whose data equals @data from @queue.
8587 // RETURNS: the number of elements removed from @queue
8588 // <data>: data to remove
8589 uint remove_all()(const(void)* data) {
8590 return g_queue_remove_all(&this, data);
8593 // VERSION: 2.4
8594 // Reverses the order of the items in @queue.
8595 void reverse()() {
8596 g_queue_reverse(&this);
8599 // Unintrospectable method: sort() / g_queue_sort()
8600 // VERSION: 2.4
8601 // Sorts @queue using @compare_func.
8602 // <compare_func>: the #GCompareDataFunc used to sort @queue. This function is passed two elements of the queue and should return 0 if they are equal, a negative value if the first comes before the second, and a positive value if the second comes before the first.
8603 // <user_data>: user data passed to @compare_func
8604 void sort()(CompareDataFunc compare_func, void* user_data) {
8605 g_queue_sort(&this, compare_func, user_data);
8608 // Unintrospectable method: unlink() / g_queue_unlink()
8609 // VERSION: 2.4
8610 // Unlinks @link_ so that it will no longer be part of @queue. The link is
8611 // not freed.
8613 // @link_ must be part of @queue,
8614 // <link_>: a #GList link that <emphasis>must</emphasis> be part of @queue
8615 void unlink()(GLib2.List* link_) {
8616 g_queue_unlink(&this, link_);
8619 // Unintrospectable function: new() / g_queue_new()
8620 // Creates a new #GQueue.
8621 // RETURNS: a new #GQueue.
8622 static Queue* new_()() {
8623 return g_queue_new();
8628 // The GRWLock struct is an opaque data structure to represent a
8629 // reader-writer lock. It is similar to a #GMutex in that it allows
8630 // multiple threads to coordinate access to a shared resource.
8632 // The difference to a mutex is that a reader-writer lock discriminates
8633 // between read-only ('reader') and full ('writer') access. While only
8634 // one thread at a time is allowed write access (by holding the 'writer'
8635 // lock via g_rw_lock_writer_lock()), multiple threads can gain
8636 // simultaneous read-only access (by holding the 'reader' lock via
8637 // g_rw_lock_reader_lock()).
8639 // <example>
8640 // <title>An array with access functions</title>
8641 // <programlisting>
8642 // GRWLock lock;
8643 // GPtrArray *array;
8645 // gpointer
8646 // my_array_get (guint index)
8647 // {
8648 // gpointer retval = NULL;
8650 // if (!array)
8651 // return NULL;
8653 // g_rw_lock_reader_lock (&amp;lock);
8654 // if (index &lt; array->len)
8655 // retval = g_ptr_array_index (array, index);
8656 // g_rw_lock_reader_unlock (&amp;lock);
8658 // return retval;
8659 // }
8661 // void
8662 // my_array_set (guint index, gpointer data)
8663 // {
8664 // g_rw_lock_writer_lock (&amp;lock);
8666 // if (!array)
8667 // array = g_ptr_array_new (<!-- -->);
8669 // if (index >= array->len)
8670 // g_ptr_array_set_size (array, index+1);
8671 // g_ptr_array_index (array, index) = data;
8673 // g_rw_lock_writer_unlock (&amp;lock);
8674 // }
8675 // </programlisting>
8676 // <para>
8677 // This example shows an array which can be accessed by many readers
8678 // (the <function>my_array_get()</function> function) simultaneously,
8679 // whereas the writers (the <function>my_array_set()</function>
8680 // function) will only be allowed once at a time and only if no readers
8681 // currently access the array. This is because of the potentially
8682 // dangerous resizing of the array. Using these functions is fully
8683 // multi-thread safe now.
8684 // </para>
8685 // </example>
8687 // If a #GRWLock is allocated in static storage then it can be used
8688 // without initialisation. Otherwise, you should call
8689 // g_rw_lock_init() on it and g_rw_lock_clear() when done.
8691 // A GRWLock should only be accessed with the
8692 // <function>g_rw_lock_</function> functions.
8693 struct RWLock /* Version 2.32 */ {
8694 private void* p;
8695 private uint[2] i;
8698 // Frees the resources allocated to a lock with g_rw_lock_init().
8700 // This function should not be used with a #GRWLock that has been
8701 // statically allocated.
8703 // Calling g_rw_lock_clear() when any thread holds the lock
8704 // leads to undefined behaviour.
8706 // Sine: 2.32
8707 void clear()() {
8708 g_rw_lock_clear(&this);
8711 // VERSION: 2.32
8712 // Initializes a #GRWLock so that it can be used.
8714 // This function is useful to initialize a lock that has been
8715 // allocated on the stack, or as part of a larger structure. It is not
8716 // necessary to initialise a reader-writer lock that has been statically
8717 // allocated.
8719 // |[
8720 // typedef struct {
8721 // GRWLock l;
8722 // ...
8723 // } Blob;
8725 // Blob *b;
8727 // b = g_new (Blob, 1);
8728 // g_rw_lock_init (&b->l);
8729 // ]|
8731 // To undo the effect of g_rw_lock_init() when a lock is no longer
8732 // needed, use g_rw_lock_clear().
8734 // Calling g_rw_lock_init() on an already initialized #GRWLock leads
8735 // to undefined behaviour.
8736 void init()() {
8737 g_rw_lock_init(&this);
8740 // VERSION: 2.32
8741 // Obtain a read lock on @rw_lock. If another thread currently holds
8742 // the write lock on @rw_lock or blocks waiting for it, the current
8743 // thread will block. Read locks can be taken recursively.
8745 // It is implementation-defined how many threads are allowed to
8746 // hold read locks on the same lock simultaneously.
8747 void reader_lock()() {
8748 g_rw_lock_reader_lock(&this);
8751 // VERSION: 2.32
8752 // Tries to obtain a read lock on @rw_lock and returns %TRUE if
8753 // the read lock was successfully obtained. Otherwise it
8754 // returns %FALSE.
8755 // RETURNS: %TRUE if @rw_lock could be locked
8756 int reader_trylock()() {
8757 return g_rw_lock_reader_trylock(&this);
8760 // VERSION: 2.32
8761 // Release a read lock on @rw_lock.
8763 // Calling g_rw_lock_reader_unlock() on a lock that is not held
8764 // by the current thread leads to undefined behaviour.
8765 void reader_unlock()() {
8766 g_rw_lock_reader_unlock(&this);
8769 // VERSION: 2.32
8770 // Obtain a write lock on @rw_lock. If any thread already holds
8771 // a read or write lock on @rw_lock, the current thread will block
8772 // until all other threads have dropped their locks on @rw_lock.
8773 void writer_lock()() {
8774 g_rw_lock_writer_lock(&this);
8777 // VERSION: 2.32
8778 // Tries to obtain a write lock on @rw_lock. If any other thread holds
8779 // a read or write lock on @rw_lock, it immediately returns %FALSE.
8780 // Otherwise it locks @rw_lock and returns %TRUE.
8781 // RETURNS: %TRUE if @rw_lock could be locked
8782 int writer_trylock()() {
8783 return g_rw_lock_writer_trylock(&this);
8786 // VERSION: 2.32
8787 // Release a write lock on @rw_lock.
8789 // Calling g_rw_lock_writer_unlock() on a lock that is not held
8790 // by the current thread leads to undefined behaviour.
8791 void writer_unlock()() {
8792 g_rw_lock_writer_unlock(&this);
8797 // The #GRand struct is an opaque data structure. It should only be
8798 // accessed through the <function>g_rand_*</function> functions.
8799 struct Rand {
8801 // Unintrospectable method: copy() / g_rand_copy()
8802 // VERSION: 2.4
8803 // Copies a #GRand into a new one with the same exact state as before.
8804 // This way you can take a snapshot of the random number generator for
8805 // replaying later.
8806 // RETURNS: the new #GRand.
8807 Rand* copy()() {
8808 return g_rand_copy(&this);
8811 // Returns the next random #gdouble from @rand_ equally distributed over
8812 // the range [0..1).
8813 // RETURNS: A random number.
8814 double double_()() {
8815 return g_rand_double(&this);
8818 // Returns the next random #gdouble from @rand_ equally distributed over
8819 // the range [@begin..@end).
8820 // RETURNS: A random number.
8821 // <begin>: lower closed bound of the interval.
8822 // <end>: upper open bound of the interval.
8823 double double_range()(double begin, double end) {
8824 return g_rand_double_range(&this, begin, end);
8826 // Frees the memory allocated for the #GRand.
8827 void free()() {
8828 g_rand_free(&this);
8831 // Returns the next random #guint32 from @rand_ equally distributed over
8832 // the range [0..2^32-1].
8833 // RETURNS: A random number.
8834 uint int_()() {
8835 return g_rand_int(&this);
8838 // Returns the next random #gint32 from @rand_ equally distributed over
8839 // the range [@begin..@end-1].
8840 // RETURNS: A random number.
8841 // <begin>: lower closed bound of the interval.
8842 // <end>: upper open bound of the interval.
8843 int int_range()(int begin, int end) {
8844 return g_rand_int_range(&this, begin, end);
8847 // Sets the seed for the random number generator #GRand to @seed.
8848 // <seed>: a value to reinitialize the random number generator.
8849 void set_seed()(uint seed) {
8850 g_rand_set_seed(&this, seed);
8853 // VERSION: 2.4
8854 // Initializes the random number generator by an array of
8855 // longs. Array can be of arbitrary size, though only the
8856 // first 624 values are taken. This function is useful
8857 // if you have many low entropy seeds, or if you require more then
8858 // 32bits of actual entropy for your application.
8859 // <seed>: array to initialize with
8860 // <seed_length>: length of array
8861 void set_seed_array()(uint* seed, uint seed_length) {
8862 g_rand_set_seed_array(&this, seed, seed_length);
8865 // Unintrospectable function: new() / g_rand_new()
8866 // Creates a new random number generator initialized with a seed taken
8867 // either from <filename>/dev/urandom</filename> (if existing) or from
8868 // the current time (as a fallback).
8869 // RETURNS: the new #GRand.
8870 static Rand* new_()() {
8871 return g_rand_new();
8874 // Unintrospectable function: new_with_seed() / g_rand_new_with_seed()
8875 // Creates a new random number generator initialized with @seed.
8876 // RETURNS: the new #GRand.
8877 // <seed>: a value to initialize the random number generator.
8878 static Rand* new_with_seed()(uint seed) {
8879 return g_rand_new_with_seed(seed);
8882 // Unintrospectable function: new_with_seed_array() / g_rand_new_with_seed_array()
8883 // VERSION: 2.4
8884 // Creates a new random number generator initialized with @seed.
8885 // RETURNS: the new #GRand.
8886 // <seed>: an array of seeds to initialize the random number generator.
8887 // <seed_length>: an array of seeds to initialize the random number generator.
8888 static Rand* new_with_seed_array()(uint* seed, uint seed_length) {
8889 return g_rand_new_with_seed_array(seed, seed_length);
8894 // The GRecMutex struct is an opaque data structure to represent a
8895 // recursive mutex. It is similar to a #GMutex with the difference
8896 // that it is possible to lock a GRecMutex multiple times in the same
8897 // thread without deadlock. When doing so, care has to be taken to
8898 // unlock the recursive mutex as often as it has been locked.
8900 // If a #GRecMutex is allocated in static storage then it can be used
8901 // without initialisation. Otherwise, you should call
8902 // g_rec_mutex_init() on it and g_rec_mutex_clear() when done.
8904 // A GRecMutex should only be accessed with the
8905 // <function>g_rec_mutex_</function> functions.
8906 struct RecMutex /* Version 2.32 */ {
8907 private void* p;
8908 private uint[2] i;
8911 // Frees the resources allocated to a recursive mutex with
8912 // g_rec_mutex_init().
8914 // This function should not be used with a #GRecMutex that has been
8915 // statically allocated.
8917 // Calling g_rec_mutex_clear() on a locked recursive mutex leads
8918 // to undefined behaviour.
8920 // Sine: 2.32
8921 void clear()() {
8922 g_rec_mutex_clear(&this);
8925 // VERSION: 2.32
8926 // Initializes a #GRecMutex so that it can be used.
8928 // This function is useful to initialize a recursive mutex
8929 // that has been allocated on the stack, or as part of a larger
8930 // structure.
8932 // It is not necessary to initialise a recursive mutex that has been
8933 // statically allocated.
8935 // |[
8936 // typedef struct {
8937 // GRecMutex m;
8938 // ...
8939 // } Blob;
8941 // Blob *b;
8943 // b = g_new (Blob, 1);
8944 // g_rec_mutex_init (&b->m);
8945 // ]|
8947 // Calling g_rec_mutex_init() on an already initialized #GRecMutex
8948 // leads to undefined behaviour.
8950 // To undo the effect of g_rec_mutex_init() when a recursive mutex
8951 // is no longer needed, use g_rec_mutex_clear().
8952 void init()() {
8953 g_rec_mutex_init(&this);
8956 // VERSION: 2.32
8957 // Locks @rec_mutex. If @rec_mutex is already locked by another
8958 // thread, the current thread will block until @rec_mutex is
8959 // unlocked by the other thread. If @rec_mutex is already locked
8960 // by the current thread, the 'lock count' of @rec_mutex is increased.
8961 // The mutex will only become available again when it is unlocked
8962 // as many times as it has been locked.
8963 void lock()() {
8964 g_rec_mutex_lock(&this);
8967 // VERSION: 2.32
8968 // Tries to lock @rec_mutex. If @rec_mutex is already locked
8969 // by another thread, it immediately returns %FALSE. Otherwise
8970 // it locks @rec_mutex and returns %TRUE.
8971 // RETURNS: %TRUE if @rec_mutex could be locked
8972 int trylock()() {
8973 return g_rec_mutex_trylock(&this);
8976 // VERSION: 2.32
8977 // Unlocks @rec_mutex. If another thread is blocked in a
8978 // g_rec_mutex_lock() call for @rec_mutex, it will become unblocked
8979 // and can lock @rec_mutex itself.
8981 // Calling g_rec_mutex_unlock() on a recursive mutex that is not
8982 // locked by the current thread leads to undefined behaviour.
8983 void unlock()() {
8984 g_rec_mutex_unlock(&this);
8989 // The <function>g_regex_*()</function> functions implement regular
8990 // expression pattern matching using syntax and semantics similar to
8991 // Perl regular expression.
8993 // Some functions accept a @start_position argument, setting it differs
8994 // from just passing over a shortened string and setting #G_REGEX_MATCH_NOTBOL
8995 // in the case of a pattern that begins with any kind of lookbehind assertion.
8996 // For example, consider the pattern "\Biss\B" which finds occurrences of "iss"
8997 // in the middle of words. ("\B" matches only if the current position in the
8998 // subject is not a word boundary.) When applied to the string "Mississipi"
8999 // from the fourth byte, namely "issipi", it does not match, because "\B" is
9000 // always false at the start of the subject, which is deemed to be a word
9001 // boundary. However, if the entire string is passed , but with
9002 // @start_position set to 4, it finds the second occurrence of "iss" because
9003 // it is able to look behind the starting point to discover that it is
9004 // preceded by a letter.
9006 // Note that, unless you set the #G_REGEX_RAW flag, all the strings passed
9007 // to these functions must be encoded in UTF-8. The lengths and the positions
9008 // inside the strings are in bytes and not in characters, so, for instance,
9009 // "\xc3\xa0" (i.e. "&agrave;") is two bytes long but it is treated as a
9010 // single character. If you set #G_REGEX_RAW the strings can be non-valid
9011 // UTF-8 strings and a byte is treated as a character, so "\xc3\xa0" is two
9012 // bytes and two characters long.
9014 // When matching a pattern, "\n" matches only against a "\n" character in
9015 // the string, and "\r" matches only a "\r" character. To match any newline
9016 // sequence use "\R". This particular group matches either the two-character
9017 // sequence CR + LF ("\r\n"), or one of the single characters LF (linefeed,
9018 // U+000A, "\n"), VT vertical tab, U+000B, "\v"), FF (formfeed, U+000C, "\f"),
9019 // CR (carriage return, U+000D, "\r"), NEL (next line, U+0085), LS (line
9020 // separator, U+2028), or PS (paragraph separator, U+2029).
9022 // The behaviour of the dot, circumflex, and dollar metacharacters are
9023 // affected by newline characters, the default is to recognize any newline
9024 // character (the same characters recognized by "\R"). This can be changed
9025 // with #G_REGEX_NEWLINE_CR, #G_REGEX_NEWLINE_LF and #G_REGEX_NEWLINE_CRLF
9026 // compile options, and with #G_REGEX_MATCH_NEWLINE_ANY,
9027 // #G_REGEX_MATCH_NEWLINE_CR, #G_REGEX_MATCH_NEWLINE_LF and
9028 // #G_REGEX_MATCH_NEWLINE_CRLF match options. These settings are also
9029 // relevant when compiling a pattern if #G_REGEX_EXTENDED is set, and an
9030 // unescaped "#" outside a character class is encountered. This indicates
9031 // a comment that lasts until after the next newline.
9033 // Creating and manipulating the same #GRegex structure from different
9034 // threads is not a problem as #GRegex does not modify its internal
9035 // state between creation and destruction, on the other hand #GMatchInfo
9036 // is not threadsafe.
9038 // The regular expressions low-level functionalities are obtained through
9039 // the excellent <ulink url="http://www.pcre.org/">PCRE</ulink> library
9040 // written by Philip Hazel.
9041 struct Regex /* Version 2.14 */ {
9043 // VERSION: 2.14
9044 // Compiles the regular expression to an internal form, and does
9045 // the initial setup of the #GRegex structure.
9047 // are done with it
9048 // RETURNS: a #GRegex structure. Call g_regex_unref() when you
9049 // <pattern>: the regular expression
9050 // <compile_options>: compile options for the regular expression, or 0
9051 // <match_options>: match options for the regular expression, or 0
9052 static Regex* /*new*/ new_()(char* pattern, RegexCompileFlags compile_options, RegexMatchFlags match_options, GLib2.Error** error=null) {
9053 return g_regex_new(pattern, compile_options, match_options, error);
9056 // VERSION: 2.14
9057 // Returns the number of capturing subpatterns in the pattern.
9058 // RETURNS: the number of capturing subpatterns
9059 int get_capture_count()() {
9060 return g_regex_get_capture_count(&this);
9063 // VERSION: 2.26
9064 // Returns the compile options that @regex was created with.
9065 // RETURNS: flags from #GRegexCompileFlags
9066 RegexCompileFlags get_compile_flags()() {
9067 return g_regex_get_compile_flags(&this);
9070 // VERSION: 2.26
9071 // Returns the match options that @regex was created with.
9072 // RETURNS: flags from #GRegexMatchFlags
9073 RegexMatchFlags get_match_flags()() {
9074 return g_regex_get_match_flags(&this);
9077 // VERSION: 2.14
9078 // Returns the number of the highest back reference
9079 // in the pattern, or 0 if the pattern does not contain
9080 // back references.
9081 // RETURNS: the number of the highest back reference
9082 int get_max_backref()() {
9083 return g_regex_get_max_backref(&this);
9086 // VERSION: 2.14
9087 // Gets the pattern string associated with @regex, i.e. a copy of
9088 // the string passed to g_regex_new().
9089 // RETURNS: the pattern of @regex
9090 char* get_pattern()() {
9091 return g_regex_get_pattern(&this);
9094 // VERSION: 2.14
9095 // Retrieves the number of the subexpression named @name.
9097 // does not exists
9098 // RETURNS: The number of the subexpression or -1 if @name
9099 // <name>: name of the subexpression
9100 int get_string_number()(char* name) {
9101 return g_regex_get_string_number(&this, name);
9104 // VERSION: 2.14
9105 // Scans for a match in string for the pattern in @regex.
9106 // The @match_options are combined with the match options specified
9107 // when the @regex structure was created, letting you have more
9108 // flexibility in reusing #GRegex structures.
9110 // A #GMatchInfo structure, used to get information on the match,
9111 // is stored in @match_info if not %NULL. Note that if @match_info
9112 // is not %NULL then it is created even if the function returns %FALSE,
9113 // i.e. you must free it regardless if regular expression actually matched.
9115 // To retrieve all the non-overlapping matches of the pattern in
9116 // string you can use g_match_info_next().
9118 // |[
9119 // static void
9120 // print_uppercase_words (const gchar *string)
9121 // {
9122 // /&ast; Print all uppercase-only words. &ast;/
9123 // GRegex *regex;
9124 // GMatchInfo *match_info;
9125 // &nbsp;
9126 // regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
9127 // g_regex_match (regex, string, 0, &amp;match_info);
9128 // while (g_match_info_matches (match_info))
9129 // {
9130 // gchar *word = g_match_info_fetch (match_info, 0);
9131 // g_print ("Found: %s\n", word);
9132 // g_free (word);
9133 // g_match_info_next (match_info, NULL);
9134 // }
9135 // g_match_info_free (match_info);
9136 // g_regex_unref (regex);
9137 // }
9138 // ]|
9140 // @string is not copied and is used in #GMatchInfo internally. If
9141 // you use any #GMatchInfo method (except g_match_info_free()) after
9142 // freeing or modifying @string then the behaviour is undefined.
9143 // RETURNS: %TRUE is the string matched, %FALSE otherwise
9144 // <string>: the string to scan for matches
9145 // <match_options>: match options
9146 // <match_info>: pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
9147 int match()(char* string_, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info=null) {
9148 return g_regex_match(&this, string_, match_options, match_info);
9151 // VERSION: 2.14
9152 // Using the standard algorithm for regular expression matching only
9153 // the longest match in the string is retrieved. This function uses
9154 // a different algorithm so it can retrieve all the possible matches.
9155 // For more documentation see g_regex_match_all_full().
9157 // A #GMatchInfo structure, used to get information on the match, is
9158 // stored in @match_info if not %NULL. Note that if @match_info is
9159 // not %NULL then it is created even if the function returns %FALSE,
9160 // i.e. you must free it regardless if regular expression actually
9161 // matched.
9163 // @string is not copied and is used in #GMatchInfo internally. If
9164 // you use any #GMatchInfo method (except g_match_info_free()) after
9165 // freeing or modifying @string then the behaviour is undefined.
9166 // RETURNS: %TRUE is the string matched, %FALSE otherwise
9167 // <string>: the string to scan for matches
9168 // <match_options>: match options
9169 // <match_info>: pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
9170 int match_all()(char* string_, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info=null) {
9171 return g_regex_match_all(&this, string_, match_options, match_info);
9174 // VERSION: 2.14
9175 // Using the standard algorithm for regular expression matching only
9176 // the longest match in the string is retrieved, it is not possible
9177 // to obtain all the available matches. For instance matching
9178 // "&lt;a&gt; &lt;b&gt; &lt;c&gt;" against the pattern "&lt;.*&gt;"
9179 // you get "&lt;a&gt; &lt;b&gt; &lt;c&gt;".
9181 // This function uses a different algorithm (called DFA, i.e. deterministic
9182 // finite automaton), so it can retrieve all the possible matches, all
9183 // starting at the same point in the string. For instance matching
9184 // "&lt;a&gt; &lt;b&gt; &lt;c&gt;" against the pattern "&lt;.*&gt;"
9185 // you would obtain three matches: "&lt;a&gt; &lt;b&gt; &lt;c&gt;",
9186 // "&lt;a&gt; &lt;b&gt;" and "&lt;a&gt;".
9188 // The number of matched strings is retrieved using
9189 // g_match_info_get_match_count(). To obtain the matched strings and
9190 // their position you can use, respectively, g_match_info_fetch() and
9191 // g_match_info_fetch_pos(). Note that the strings are returned in
9192 // reverse order of length; that is, the longest matching string is
9193 // given first.
9195 // Note that the DFA algorithm is slower than the standard one and it
9196 // is not able to capture substrings, so backreferences do not work.
9198 // Setting @start_position differs from just passing over a shortened
9199 // string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
9200 // that begins with any kind of lookbehind assertion, such as "\b".
9202 // A #GMatchInfo structure, used to get information on the match, is
9203 // stored in @match_info if not %NULL. Note that if @match_info is
9204 // not %NULL then it is created even if the function returns %FALSE,
9205 // i.e. you must free it regardless if regular expression actually
9206 // matched.
9208 // @string is not copied and is used in #GMatchInfo internally. If
9209 // you use any #GMatchInfo method (except g_match_info_free()) after
9210 // freeing or modifying @string then the behaviour is undefined.
9211 // RETURNS: %TRUE is the string matched, %FALSE otherwise
9212 // <string>: the string to scan for matches
9213 // <string_len>: the length of @string, or -1 if @string is nul-terminated
9214 // <start_position>: starting index of the string to match
9215 // <match_options>: match options
9216 // <match_info>: pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
9217 int match_all_full()(char* string_, ssize_t string_len, int start_position, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info, GLib2.Error** error=null) {
9218 return g_regex_match_all_full(&this, string_, string_len, start_position, match_options, match_info, error);
9221 // VERSION: 2.14
9222 // Scans for a match in string for the pattern in @regex.
9223 // The @match_options are combined with the match options specified
9224 // when the @regex structure was created, letting you have more
9225 // flexibility in reusing #GRegex structures.
9227 // Setting @start_position differs from just passing over a shortened
9228 // string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
9229 // that begins with any kind of lookbehind assertion, such as "\b".
9231 // A #GMatchInfo structure, used to get information on the match, is
9232 // stored in @match_info if not %NULL. Note that if @match_info is
9233 // not %NULL then it is created even if the function returns %FALSE,
9234 // i.e. you must free it regardless if regular expression actually
9235 // matched.
9237 // @string is not copied and is used in #GMatchInfo internally. If
9238 // you use any #GMatchInfo method (except g_match_info_free()) after
9239 // freeing or modifying @string then the behaviour is undefined.
9241 // To retrieve all the non-overlapping matches of the pattern in
9242 // string you can use g_match_info_next().
9244 // |[
9245 // static void
9246 // print_uppercase_words (const gchar *string)
9247 // {
9248 // /&ast; Print all uppercase-only words. &ast;/
9249 // GRegex *regex;
9250 // GMatchInfo *match_info;
9251 // GError *error = NULL;
9252 // &nbsp;
9253 // regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
9254 // g_regex_match_full (regex, string, -1, 0, 0, &amp;match_info, &amp;error);
9255 // while (g_match_info_matches (match_info))
9256 // {
9257 // gchar *word = g_match_info_fetch (match_info, 0);
9258 // g_print ("Found: %s\n", word);
9259 // g_free (word);
9260 // g_match_info_next (match_info, &amp;error);
9261 // }
9262 // g_match_info_free (match_info);
9263 // g_regex_unref (regex);
9264 // if (error != NULL)
9265 // {
9266 // g_printerr ("Error while matching: %s\n", error->message);
9267 // g_error_free (error);
9268 // }
9269 // }
9270 // ]|
9271 // RETURNS: %TRUE is the string matched, %FALSE otherwise
9272 // <string>: the string to scan for matches
9273 // <string_len>: the length of @string, or -1 if @string is nul-terminated
9274 // <start_position>: starting index of the string to match
9275 // <match_options>: match options
9276 // <match_info>: pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
9277 int match_full()(char* string_, ssize_t string_len, int start_position, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info, GLib2.Error** error=null) {
9278 return g_regex_match_full(&this, string_, string_len, start_position, match_options, match_info, error);
9281 // VERSION: 2.14
9282 // Increases reference count of @regex by 1.
9283 // RETURNS: @regex
9284 Regex* /*new*/ ref_()() {
9285 return g_regex_ref(&this);
9288 // VERSION: 2.14
9289 // Replaces all occurrences of the pattern in @regex with the
9290 // replacement text. Backreferences of the form '\number' or
9291 // '\g&lt;number&gt;' in the replacement text are interpolated by the
9292 // number-th captured subexpression of the match, '\g&lt;name&gt;' refers
9293 // to the captured subexpression with the given name. '\0' refers to the
9294 // complete match, but '\0' followed by a number is the octal representation
9295 // of a character. To include a literal '\' in the replacement, write '\\'.
9296 // There are also escapes that changes the case of the following text:
9298 // <variablelist>
9299 // <varlistentry><term>\l</term>
9300 // <listitem>
9301 // <para>Convert to lower case the next character</para>
9302 // </listitem>
9303 // </varlistentry>
9304 // <varlistentry><term>\u</term>
9305 // <listitem>
9306 // <para>Convert to upper case the next character</para>
9307 // </listitem>
9308 // </varlistentry>
9309 // <varlistentry><term>\L</term>
9310 // <listitem>
9311 // <para>Convert to lower case till \E</para>
9312 // </listitem>
9313 // </varlistentry>
9314 // <varlistentry><term>\U</term>
9315 // <listitem>
9316 // <para>Convert to upper case till \E</para>
9317 // </listitem>
9318 // </varlistentry>
9319 // <varlistentry><term>\E</term>
9320 // <listitem>
9321 // <para>End case modification</para>
9322 // </listitem>
9323 // </varlistentry>
9324 // </variablelist>
9326 // If you do not need to use backreferences use g_regex_replace_literal().
9328 // The @replacement string must be UTF-8 encoded even if #G_REGEX_RAW was
9329 // passed to g_regex_new(). If you want to use not UTF-8 encoded stings
9330 // you can use g_regex_replace_literal().
9332 // Setting @start_position differs from just passing over a shortened
9333 // string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern that
9334 // begins with any kind of lookbehind assertion, such as "\b".
9335 // RETURNS: a newly allocated string containing the replacements
9336 // <string>: the string to perform matches against
9337 // <string_len>: the length of @string, or -1 if @string is nul-terminated
9338 // <start_position>: starting index of the string to match
9339 // <replacement>: text to replace each match with
9340 // <match_options>: options for the match
9341 char* /*new*/ replace()(char* string_, ssize_t string_len, int start_position, char* replacement, RegexMatchFlags match_options, GLib2.Error** error=null) {
9342 return g_regex_replace(&this, string_, string_len, start_position, replacement, match_options, error);
9345 // Unintrospectable method: replace_eval() / g_regex_replace_eval()
9346 // VERSION: 2.14
9347 // Replaces occurrences of the pattern in regex with the output of
9348 // @eval for that occurrence.
9350 // Setting @start_position differs from just passing over a shortened
9351 // string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
9352 // that begins with any kind of lookbehind assertion, such as "\b".
9354 // The following example uses g_regex_replace_eval() to replace multiple
9355 // strings at once:
9356 // |[
9357 // static gboolean
9358 // eval_cb (const GMatchInfo *info,
9359 // GString *res,
9360 // gpointer data)
9361 // {
9362 // gchar *match;
9363 // gchar *r;
9365 // match = g_match_info_fetch (info, 0);
9366 // r = g_hash_table_lookup ((GHashTable *)data, match);
9367 // g_string_append (res, r);
9368 // g_free (match);
9370 // return FALSE;
9371 // }
9373 // /&ast; ... &ast;/
9375 // GRegex *reg;
9376 // GHashTable *h;
9377 // gchar *res;
9379 // h = g_hash_table_new (g_str_hash, g_str_equal);
9381 // g_hash_table_insert (h, "1", "ONE");
9382 // g_hash_table_insert (h, "2", "TWO");
9383 // g_hash_table_insert (h, "3", "THREE");
9384 // g_hash_table_insert (h, "4", "FOUR");
9386 // reg = g_regex_new ("1|2|3|4", 0, 0, NULL);
9387 // res = g_regex_replace_eval (reg, text, -1, 0, 0, eval_cb, h, NULL);
9388 // g_hash_table_destroy (h);
9390 // /&ast; ... &ast;/
9391 // ]|
9392 // RETURNS: a newly allocated string containing the replacements
9393 // <string>: string to perform matches against
9394 // <string_len>: the length of @string, or -1 if @string is nul-terminated
9395 // <start_position>: starting index of the string to match
9396 // <match_options>: options for the match
9397 // <eval>: a function to call for each match
9398 // <user_data>: user data to pass to the function
9399 char* /*new*/ replace_eval()(char* string_, ssize_t string_len, int start_position, RegexMatchFlags match_options, RegexEvalCallback eval, void* user_data, GLib2.Error** error=null) {
9400 return g_regex_replace_eval(&this, string_, string_len, start_position, match_options, eval, user_data, error);
9403 // VERSION: 2.14
9404 // Replaces all occurrences of the pattern in @regex with the
9405 // replacement text. @replacement is replaced literally, to
9406 // include backreferences use g_regex_replace().
9408 // Setting @start_position differs from just passing over a
9409 // shortened string and setting #G_REGEX_MATCH_NOTBOL in the
9410 // case of a pattern that begins with any kind of lookbehind
9411 // assertion, such as "\b".
9412 // RETURNS: a newly allocated string containing the replacements
9413 // <string>: the string to perform matches against
9414 // <string_len>: the length of @string, or -1 if @string is nul-terminated
9415 // <start_position>: starting index of the string to match
9416 // <replacement>: text to replace each match with
9417 // <match_options>: options for the match
9418 char* /*new*/ replace_literal()(char* string_, ssize_t string_len, int start_position, char* replacement, RegexMatchFlags match_options, GLib2.Error** error=null) {
9419 return g_regex_replace_literal(&this, string_, string_len, start_position, replacement, match_options, error);
9422 // Unintrospectable method: split() / g_regex_split()
9423 // VERSION: 2.14
9424 // Breaks the string on the pattern, and returns an array of the tokens.
9425 // If the pattern contains capturing parentheses, then the text for each
9426 // of the substrings will also be returned. If the pattern does not match
9427 // anywhere in the string, then the whole string is returned as the first
9428 // token.
9430 // As a special case, the result of splitting the empty string "" is an
9431 // empty vector, not a vector containing a single string. The reason for
9432 // this special case is that being able to represent a empty vector is
9433 // typically more useful than consistent handling of empty elements. If
9434 // you do need to represent empty elements, you'll need to check for the
9435 // empty string before calling this function.
9437 // A pattern that can match empty strings splits @string into separate
9438 // characters wherever it matches the empty string between characters.
9439 // For example splitting "ab c" using as a separator "\s*", you will get
9440 // "a", "b" and "c".
9441 // RETURNS: a %NULL-terminated gchar ** array. Free it using g_strfreev()
9442 // <string>: the string to split with the pattern
9443 // <match_options>: match time option flags
9444 char** split()(char* string_, RegexMatchFlags match_options) {
9445 return g_regex_split(&this, string_, match_options);
9448 // Unintrospectable method: split_full() / g_regex_split_full()
9449 // VERSION: 2.14
9450 // Breaks the string on the pattern, and returns an array of the tokens.
9451 // If the pattern contains capturing parentheses, then the text for each
9452 // of the substrings will also be returned. If the pattern does not match
9453 // anywhere in the string, then the whole string is returned as the first
9454 // token.
9456 // As a special case, the result of splitting the empty string "" is an
9457 // empty vector, not a vector containing a single string. The reason for
9458 // this special case is that being able to represent a empty vector is
9459 // typically more useful than consistent handling of empty elements. If
9460 // you do need to represent empty elements, you'll need to check for the
9461 // empty string before calling this function.
9463 // A pattern that can match empty strings splits @string into separate
9464 // characters wherever it matches the empty string between characters.
9465 // For example splitting "ab c" using as a separator "\s*", you will get
9466 // "a", "b" and "c".
9468 // Setting @start_position differs from just passing over a shortened
9469 // string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
9470 // that begins with any kind of lookbehind assertion, such as "\b".
9471 // RETURNS: a %NULL-terminated gchar ** array. Free it using g_strfreev()
9472 // <string>: the string to split with the pattern
9473 // <string_len>: the length of @string, or -1 if @string is nul-terminated
9474 // <start_position>: starting index of the string to match
9475 // <match_options>: match time option flags
9476 // <max_tokens>: the maximum number of tokens to split @string into. If this is less than 1, the string is split completely
9477 char** split_full()(char* string_, ssize_t string_len, int start_position, RegexMatchFlags match_options, int max_tokens, GLib2.Error** error=null) {
9478 return g_regex_split_full(&this, string_, string_len, start_position, match_options, max_tokens, error);
9481 // VERSION: 2.14
9482 // Decreases reference count of @regex by 1. When reference count drops
9483 // to zero, it frees all the memory associated with the regex structure.
9484 void unref()() {
9485 g_regex_unref(&this);
9488 // VERSION: 2.14
9489 // Checks whether @replacement is a valid replacement string
9490 // (see g_regex_replace()), i.e. that all escape sequences in
9491 // it are valid.
9493 // If @has_references is not %NULL then @replacement is checked
9494 // for pattern references. For instance, replacement text 'foo\n'
9495 // does not contain references and may be evaluated without information
9496 // about actual match, but '\0\1' (whole match followed by first
9497 // subpattern) requires valid #GMatchInfo object.
9498 // RETURNS: whether @replacement is a valid replacement string
9499 // <replacement>: the replacement string
9500 // <has_references>: location to store information about references in @replacement or %NULL
9501 static int check_replacement()(char* replacement, /*out*/ int* has_references, GLib2.Error** error=null) {
9502 return g_regex_check_replacement(replacement, has_references, error);
9504 static Quark error_quark()() {
9505 return g_regex_error_quark();
9508 // VERSION: 2.30
9509 // Escapes the nul characters in @string to "\x00". It can be used
9510 // to compile a regex with embedded nul characters.
9512 // For completeness, @length can be -1 for a nul-terminated string.
9513 // In this case the output string will be of course equal to @string.
9514 // RETURNS: a newly-allocated escaped string
9515 // <string>: the string to escape
9516 // <length>: the length of @string
9517 static char* /*new*/ escape_nul()(char* string_, int length) {
9518 return g_regex_escape_nul(string_, length);
9521 // VERSION: 2.14
9522 // Escapes the special characters used for regular expressions
9523 // in @string, for instance "a.b*c" becomes "a\.b\*c". This
9524 // function is useful to dynamically generate regular expressions.
9526 // @string can contain nul characters that are replaced with "\0",
9527 // in this case remember to specify the correct length of @string
9528 // in @length.
9529 // RETURNS: a newly-allocated escaped string
9530 // <string>: the string to escape
9531 // <length>: the length of @string, or -1 if @string is nul-terminated
9532 static char* /*new*/ escape_string()(char* string_, int length) {
9533 return g_regex_escape_string(string_, length);
9536 // VERSION: 2.14
9537 // Scans for a match in @string for @pattern.
9539 // This function is equivalent to g_regex_match() but it does not
9540 // require to compile the pattern with g_regex_new(), avoiding some
9541 // lines of code when you need just to do a match without extracting
9542 // substrings, capture counts, and so on.
9544 // If this function is to be called on the same @pattern more than
9545 // once, it's more efficient to compile the pattern once with
9546 // g_regex_new() and then use g_regex_match().
9547 // RETURNS: %TRUE if the string matched, %FALSE otherwise
9548 // <pattern>: the regular expression
9549 // <string>: the string to scan for matches
9550 // <compile_options>: compile options for the regular expression, or 0
9551 // <match_options>: match options, or 0
9552 static int match_simple()(char* pattern, char* string_, RegexCompileFlags compile_options, RegexMatchFlags match_options) {
9553 return g_regex_match_simple(pattern, string_, compile_options, match_options);
9556 // Unintrospectable function: split_simple() / g_regex_split_simple()
9557 // VERSION: 2.14
9558 // Breaks the string on the pattern, and returns an array of
9559 // the tokens. If the pattern contains capturing parentheses,
9560 // then the text for each of the substrings will also be returned.
9561 // If the pattern does not match anywhere in the string, then the
9562 // whole string is returned as the first token.
9564 // This function is equivalent to g_regex_split() but it does
9565 // not require to compile the pattern with g_regex_new(), avoiding
9566 // some lines of code when you need just to do a split without
9567 // extracting substrings, capture counts, and so on.
9569 // If this function is to be called on the same @pattern more than
9570 // once, it's more efficient to compile the pattern once with
9571 // g_regex_new() and then use g_regex_split().
9573 // As a special case, the result of splitting the empty string ""
9574 // is an empty vector, not a vector containing a single string.
9575 // The reason for this special case is that being able to represent
9576 // a empty vector is typically more useful than consistent handling
9577 // of empty elements. If you do need to represent empty elements,
9578 // you'll need to check for the empty string before calling this
9579 // function.
9581 // A pattern that can match empty strings splits @string into
9582 // separate characters wherever it matches the empty string between
9583 // characters. For example splitting "ab c" using as a separator
9584 // "\s*", you will get "a", "b" and "c".
9585 // RETURNS: a %NULL-terminated array of strings. Free it using g_strfreev()
9586 // <pattern>: the regular expression
9587 // <string>: the string to scan for matches
9588 // <compile_options>: compile options for the regular expression, or 0
9589 // <match_options>: match options, or 0
9590 static char** split_simple()(char* pattern, char* string_, RegexCompileFlags compile_options, RegexMatchFlags match_options) {
9591 return g_regex_split_simple(pattern, string_, compile_options, match_options);
9595 // Flags specifying compile-time options.
9596 enum RegexCompileFlags /* Version 2.14 */ {
9597 CASELESS = 1,
9598 MULTILINE = 2,
9599 DOTALL = 4,
9600 EXTENDED = 8,
9601 ANCHORED = 16,
9602 DOLLAR_ENDONLY = 32,
9603 UNGREEDY = 512,
9604 RAW = 2048,
9605 NO_AUTO_CAPTURE = 4096,
9606 OPTIMIZE = 8192,
9607 DUPNAMES = 524288,
9608 NEWLINE_CR = 1048576,
9609 NEWLINE_LF = 2097152,
9610 NEWLINE_CRLF = 3145728
9612 // Error codes returned by regular expressions functions.
9613 enum RegexError /* Version 2.14 */ {
9614 COMPILE = 0,
9615 OPTIMIZE = 1,
9616 REPLACE = 2,
9617 MATCH = 3,
9618 INTERNAL = 4,
9619 STRAY_BACKSLASH = 101,
9620 MISSING_CONTROL_CHAR = 102,
9621 UNRECOGNIZED_ESCAPE = 103,
9622 QUANTIFIERS_OUT_OF_ORDER = 104,
9623 QUANTIFIER_TOO_BIG = 105,
9624 UNTERMINATED_CHARACTER_CLASS = 106,
9625 INVALID_ESCAPE_IN_CHARACTER_CLASS = 107,
9626 RANGE_OUT_OF_ORDER = 108,
9627 NOTHING_TO_REPEAT = 109,
9628 UNRECOGNIZED_CHARACTER = 112,
9629 POSIX_NAMED_CLASS_OUTSIDE_CLASS = 113,
9630 UNMATCHED_PARENTHESIS = 114,
9631 INEXISTENT_SUBPATTERN_REFERENCE = 115,
9632 UNTERMINATED_COMMENT = 118,
9633 EXPRESSION_TOO_LARGE = 120,
9634 MEMORY_ERROR = 121,
9635 VARIABLE_LENGTH_LOOKBEHIND = 125,
9636 MALFORMED_CONDITION = 126,
9637 TOO_MANY_CONDITIONAL_BRANCHES = 127,
9638 ASSERTION_EXPECTED = 128,
9639 UNKNOWN_POSIX_CLASS_NAME = 130,
9640 POSIX_COLLATING_ELEMENTS_NOT_SUPPORTED = 131,
9641 HEX_CODE_TOO_LARGE = 134,
9642 INVALID_CONDITION = 135,
9643 SINGLE_BYTE_MATCH_IN_LOOKBEHIND = 136,
9644 INFINITE_LOOP = 140,
9645 MISSING_SUBPATTERN_NAME_TERMINATOR = 142,
9646 DUPLICATE_SUBPATTERN_NAME = 143,
9647 MALFORMED_PROPERTY = 146,
9648 UNKNOWN_PROPERTY = 147,
9649 SUBPATTERN_NAME_TOO_LONG = 148,
9650 TOO_MANY_SUBPATTERNS = 149,
9651 INVALID_OCTAL_VALUE = 151,
9652 TOO_MANY_BRANCHES_IN_DEFINE = 154,
9653 DEFINE_REPETION = 155,
9654 INCONSISTENT_NEWLINE_OPTIONS = 156,
9655 MISSING_BACK_REFERENCE = 157
9658 // VERSION: 2.14
9659 // Specifies the type of the function passed to g_regex_replace_eval().
9660 // It is called for each occurrence of the pattern in the string passed
9661 // to g_regex_replace_eval(), and it should append the replacement to
9662 // @result.
9663 // RETURNS: %FALSE to continue the replacement process, %TRUE to stop it
9664 // <match_info>: the #GMatchInfo generated by the match. Use g_match_info_get_regex() and g_match_info_get_string() if you need the #GRegex or the matched string.
9665 // <result>: a #GString containing the new string
9666 // <user_data>: user data passed to g_regex_replace_eval()
9667 extern (C) alias int function (MatchInfo* match_info, String* result, void* user_data) RegexEvalCallback;
9669 // Flags specifying match-time options.
9670 enum RegexMatchFlags /* Version 2.14 */ {
9671 ANCHORED = 16,
9672 NOTBOL = 128,
9673 NOTEOL = 256,
9674 NOTEMPTY = 1024,
9675 PARTIAL = 32768,
9676 NEWLINE_CR = 1048576,
9677 NEWLINE_LF = 2097152,
9678 NEWLINE_CRLF = 3145728,
9679 NEWLINE_ANY = 4194304
9681 enum int SEARCHPATH_SEPARATOR = 59;
9682 enum SEARCHPATH_SEPARATOR_S = ";";
9683 enum int SIZEOF_LONG = 4;
9684 enum int SIZEOF_SIZE_T = 4;
9685 enum int SIZEOF_VOID_P = 4;
9687 // The #GSList struct is used for each element in the singly-linked
9688 // list.
9689 struct SList {
9690 void* data;
9691 GLib2.SList* next;
9694 // Unintrospectable function: alloc() / g_slist_alloc()
9695 // Allocates space for one #GSList element. It is called by the
9696 // g_slist_append(), g_slist_prepend(), g_slist_insert() and
9697 // g_slist_insert_sorted() functions and so is rarely used on its own.
9698 static GLib2.SList* alloc()() {
9699 return g_slist_alloc();
9702 // Unintrospectable function: append() / g_slist_append()
9703 // Adds a new element on to the end of the list.
9705 // <note><para>
9706 // The return value is the new start of the list, which may
9707 // have changed, so make sure you store the new value.
9708 // </para></note>
9710 // <note><para>
9711 // Note that g_slist_append() has to traverse the entire list
9712 // to find the end, which is inefficient when adding multiple
9713 // elements. A common idiom to avoid the inefficiency is to prepend
9714 // the elements and reverse the list when all elements have been added.
9715 // </para></note>
9717 // |[
9718 // /&ast; Notice that these are initialized to the empty list. &ast;/
9719 // GSList *list = NULL, *number_list = NULL;
9721 // /&ast; This is a list of strings. &ast;/
9722 // list = g_slist_append (list, "first");
9723 // list = g_slist_append (list, "second");
9725 // /&ast; This is a list of integers. &ast;/
9726 // number_list = g_slist_append (number_list, GINT_TO_POINTER (27));
9727 // number_list = g_slist_append (number_list, GINT_TO_POINTER (14));
9728 // ]|
9729 // RETURNS: the new start of the #GSList
9730 // <list>: a #GSList
9731 // <data>: the data for the new element
9732 static GLib2.SList* append()(GLib2.SList* list, void* data) {
9733 return g_slist_append(list, data);
9736 // Unintrospectable function: concat() / g_slist_concat()
9737 // Adds the second #GSList onto the end of the first #GSList.
9738 // Note that the elements of the second #GSList are not copied.
9739 // They are used directly.
9740 // RETURNS: the start of the new #GSList
9741 // <list1>: a #GSList
9742 // <list2>: the #GSList to add to the end of the first #GSList
9743 static GLib2.SList* concat()(GLib2.SList* list1, GLib2.SList* list2) {
9744 return g_slist_concat(list1, list2);
9747 // Unintrospectable function: copy() / g_slist_copy()
9748 // Copies a #GSList.
9750 // <note><para>
9751 // Note that this is a "shallow" copy. If the list elements
9752 // consist of pointers to data, the pointers are copied but
9753 // the actual data isn't.
9754 // </para></note>
9755 // RETURNS: a copy of @list
9756 // <list>: a #GSList
9757 static GLib2.SList* copy()(GLib2.SList* list) {
9758 return g_slist_copy(list);
9761 // Unintrospectable function: delete_link() / g_slist_delete_link()
9762 // Removes the node link_ from the list and frees it.
9763 // Compare this to g_slist_remove_link() which removes the node
9764 // without freeing it.
9765 // RETURNS: the new head of @list
9766 // <list>: a #GSList
9767 // <link_>: node to delete
9768 static GLib2.SList* delete_link()(GLib2.SList* list, GLib2.SList* link_) {
9769 return g_slist_delete_link(list, link_);
9772 // Unintrospectable function: find() / g_slist_find()
9773 // Finds the element in a #GSList which
9774 // contains the given data.
9776 // or %NULL if it is not found
9777 // RETURNS: the found #GSList element,
9778 // <list>: a #GSList
9779 // <data>: the element data to find
9780 static GLib2.SList* find()(GLib2.SList* list, const(void)* data) {
9781 return g_slist_find(list, data);
9784 // Unintrospectable function: find_custom() / g_slist_find_custom()
9785 // Finds an element in a #GSList, using a supplied function to
9786 // find the desired element. It iterates over the list, calling
9787 // the given function which should return 0 when the desired
9788 // element is found. The function takes two #gconstpointer arguments,
9789 // the #GSList element's data as the first argument and the
9790 // given user data.
9791 // RETURNS: the found #GSList element, or %NULL if it is not found
9792 // <list>: a #GSList
9793 // <data>: user data passed to the function
9794 // <func>: the function to call for each element. It should return 0 when the desired element is found
9795 static GLib2.SList* find_custom()(GLib2.SList* list, const(void)* data, CompareFunc func) {
9796 return g_slist_find_custom(list, data, func);
9799 // Unintrospectable function: foreach() / g_slist_foreach()
9800 // Calls a function for each element of a #GSList.
9801 // <list>: a #GSList
9802 // <func>: the function to call with each element's data
9803 // <user_data>: user data to pass to the function
9804 static void foreach_()(GLib2.SList* list, Func func, void* user_data) {
9805 g_slist_foreach(list, func, user_data);
9808 // Unintrospectable function: free() / g_slist_free()
9809 // Frees all of the memory used by a #GSList.
9810 // The freed elements are returned to the slice allocator.
9812 // <note><para>
9813 // If list elements contain dynamically-allocated memory,
9814 // you should either use g_slist_free_full() or free them manually
9815 // first.
9816 // </para></note>
9817 // <list>: a #GSList
9818 static void free()(GLib2.SList* list) {
9819 g_slist_free(list);
9822 // Unintrospectable function: free_1() / g_slist_free_1()
9823 // Frees one #GSList element.
9824 // It is usually used after g_slist_remove_link().
9825 // <list>: a #GSList element
9826 static void free_1()(GLib2.SList* list) {
9827 g_slist_free_1(list);
9830 // Unintrospectable function: free_full() / g_slist_free_full()
9831 // VERSION: 2.28
9832 // Convenience method, which frees all the memory used by a #GSList, and
9833 // calls the specified destroy function on every element's data.
9834 // <list>: a pointer to a #GSList
9835 // <free_func>: the function to be called to free each element's data
9836 static void free_full()(GLib2.SList* list, DestroyNotify free_func) {
9837 g_slist_free_full(list, free_func);
9840 // Unintrospectable function: index() / g_slist_index()
9841 // Gets the position of the element containing
9842 // the given data (starting from 0).
9844 // or -1 if the data is not found
9845 // RETURNS: the index of the element containing the data,
9846 // <list>: a #GSList
9847 // <data>: the data to find
9848 static int index()(GLib2.SList* list, const(void)* data) {
9849 return g_slist_index(list, data);
9852 // Unintrospectable function: insert() / g_slist_insert()
9853 // Inserts a new element into the list at the given position.
9854 // RETURNS: the new start of the #GSList
9855 // <list>: a #GSList
9856 // <data>: the data for the new element
9857 // <position>: the position to insert the element. If this is negative, or is larger than the number of elements in the list, the new element is added on to the end of the list.
9858 static GLib2.SList* insert()(GLib2.SList* list, void* data, int position) {
9859 return g_slist_insert(list, data, position);
9862 // Unintrospectable function: insert_before() / g_slist_insert_before()
9863 // Inserts a node before @sibling containing @data.
9864 // RETURNS: the new head of the list.
9865 // <slist>: a #GSList
9866 // <sibling>: node to insert @data before
9867 // <data>: data to put in the newly-inserted node
9868 static GLib2.SList* insert_before()(GLib2.SList* slist, GLib2.SList* sibling, void* data) {
9869 return g_slist_insert_before(slist, sibling, data);
9872 // Unintrospectable function: insert_sorted() / g_slist_insert_sorted()
9873 // Inserts a new element into the list, using the given
9874 // comparison function to determine its position.
9875 // RETURNS: the new start of the #GSList
9876 // <list>: a #GSList
9877 // <data>: the data for the new element
9878 // <func>: the function to compare elements in the list. It should return a number > 0 if the first parameter comes after the second parameter in the sort order.
9879 static GLib2.SList* insert_sorted()(GLib2.SList* list, void* data, CompareFunc func) {
9880 return g_slist_insert_sorted(list, data, func);
9883 // Unintrospectable function: insert_sorted_with_data() / g_slist_insert_sorted_with_data()
9884 // VERSION: 2.10
9885 // Inserts a new element into the list, using the given
9886 // comparison function to determine its position.
9887 // RETURNS: the new start of the #GSList
9888 // <list>: a #GSList
9889 // <data>: the data for the new element
9890 // <func>: the function to compare elements in the list. It should return a number > 0 if the first parameter comes after the second parameter in the sort order.
9891 // <user_data>: data to pass to comparison function
9892 static GLib2.SList* insert_sorted_with_data()(GLib2.SList* list, void* data, CompareDataFunc func, void* user_data) {
9893 return g_slist_insert_sorted_with_data(list, data, func, user_data);
9896 // Unintrospectable function: last() / g_slist_last()
9897 // Gets the last element in a #GSList.
9899 // <note><para>
9900 // This function iterates over the whole list.
9901 // </para></note>
9903 // or %NULL if the #GSList has no elements
9904 // RETURNS: the last element in the #GSList,
9905 // <list>: a #GSList
9906 static GLib2.SList* last()(GLib2.SList* list) {
9907 return g_slist_last(list);
9910 // Unintrospectable function: length() / g_slist_length()
9911 // Gets the number of elements in a #GSList.
9913 // <note><para>
9914 // This function iterates over the whole list to
9915 // count its elements.
9916 // </para></note>
9917 // RETURNS: the number of elements in the #GSList
9918 // <list>: a #GSList
9919 static uint length()(GLib2.SList* list) {
9920 return g_slist_length(list);
9923 // Unintrospectable function: nth() / g_slist_nth()
9924 // Gets the element at the given position in a #GSList.
9926 // the end of the #GSList
9927 // RETURNS: the element, or %NULL if the position is off
9928 // <list>: a #GSList
9929 // <n>: the position of the element, counting from 0
9930 static GLib2.SList* nth()(GLib2.SList* list, uint n) {
9931 return g_slist_nth(list, n);
9934 // Unintrospectable function: nth_data() / g_slist_nth_data()
9935 // Gets the data of the element at the given position.
9937 // is off the end of the #GSList
9938 // RETURNS: the element's data, or %NULL if the position
9939 // <list>: a #GSList
9940 // <n>: the position of the element
9941 static void* nth_data()(GLib2.SList* list, uint n) {
9942 return g_slist_nth_data(list, n);
9945 // Unintrospectable function: position() / g_slist_position()
9946 // Gets the position of the given element
9947 // in the #GSList (starting from 0).
9949 // or -1 if the element is not found
9950 // RETURNS: the position of the element in the #GSList,
9951 // <list>: a #GSList
9952 // <llink>: an element in the #GSList
9953 static int position()(GLib2.SList* list, GLib2.SList* llink) {
9954 return g_slist_position(list, llink);
9957 // Unintrospectable function: prepend() / g_slist_prepend()
9958 // Adds a new element on to the start of the list.
9960 // <note><para>
9961 // The return value is the new start of the list, which
9962 // may have changed, so make sure you store the new value.
9963 // </para></note>
9965 // |[
9966 // /&ast; Notice that it is initialized to the empty list. &ast;/
9967 // GSList *list = NULL;
9968 // list = g_slist_prepend (list, "last");
9969 // list = g_slist_prepend (list, "first");
9970 // ]|
9971 // RETURNS: the new start of the #GSList
9972 // <list>: a #GSList
9973 // <data>: the data for the new element
9974 static GLib2.SList* prepend()(GLib2.SList* list, void* data) {
9975 return g_slist_prepend(list, data);
9978 // Unintrospectable function: remove() / g_slist_remove()
9979 // Removes an element from a #GSList.
9980 // If two elements contain the same data, only the first is removed.
9981 // If none of the elements contain the data, the #GSList is unchanged.
9982 // RETURNS: the new start of the #GSList
9983 // <list>: a #GSList
9984 // <data>: the data of the element to remove
9985 static GLib2.SList* remove()(GLib2.SList* list, const(void)* data) {
9986 return g_slist_remove(list, data);
9989 // Unintrospectable function: remove_all() / g_slist_remove_all()
9990 // Removes all list nodes with data equal to @data.
9991 // Returns the new head of the list. Contrast with
9992 // g_slist_remove() which removes only the first node
9993 // matching the given data.
9994 // RETURNS: new head of @list
9995 // <list>: a #GSList
9996 // <data>: data to remove
9997 static GLib2.SList* remove_all()(GLib2.SList* list, const(void)* data) {
9998 return g_slist_remove_all(list, data);
10001 // Unintrospectable function: remove_link() / g_slist_remove_link()
10002 // Removes an element from a #GSList, without
10003 // freeing the element. The removed element's next
10004 // link is set to %NULL, so that it becomes a
10005 // self-contained list with one element.
10006 // RETURNS: the new start of the #GSList, without the element
10007 // <list>: a #GSList
10008 // <link_>: an element in the #GSList
10009 static GLib2.SList* remove_link()(GLib2.SList* list, GLib2.SList* link_) {
10010 return g_slist_remove_link(list, link_);
10013 // Unintrospectable function: reverse() / g_slist_reverse()
10014 // Reverses a #GSList.
10015 // RETURNS: the start of the reversed #GSList
10016 // <list>: a #GSList
10017 static GLib2.SList* reverse()(GLib2.SList* list) {
10018 return g_slist_reverse(list);
10021 // Unintrospectable function: sort() / g_slist_sort()
10022 // Sorts a #GSList using the given comparison function.
10023 // RETURNS: the start of the sorted #GSList
10024 // <list>: a #GSList
10025 // <compare_func>: the comparison function used to sort the #GSList. This function is passed the data from 2 elements of the #GSList and should return 0 if they are equal, a negative value if the first element comes before the second, or a positive value if the first element comes after the second.
10026 static GLib2.SList* sort()(GLib2.SList* list, CompareFunc compare_func) {
10027 return g_slist_sort(list, compare_func);
10030 // Unintrospectable function: sort_with_data() / g_slist_sort_with_data()
10031 // Like g_slist_sort(), but the sort function accepts a user data argument.
10032 // RETURNS: new head of the list
10033 // <list>: a #GSList
10034 // <compare_func>: comparison function
10035 // <user_data>: data to pass to comparison function
10036 static GLib2.SList* sort_with_data()(GLib2.SList* list, CompareDataFunc compare_func, void* user_data) {
10037 return g_slist_sort_with_data(list, compare_func, user_data);
10041 enum double SQRT2 = 1.414214;
10042 enum STR_DELIMITERS = "_-|> <.";
10043 enum int SYSDEF_AF_INET = 2;
10044 enum int SYSDEF_AF_INET6 = 10;
10045 enum int SYSDEF_AF_UNIX = 1;
10046 enum int SYSDEF_MSG_DONTROUTE = 4;
10047 enum int SYSDEF_MSG_OOB = 1;
10048 enum int SYSDEF_MSG_PEEK = 2;
10050 // The data structure representing a lexical scanner.
10052 // You should set @input_name after creating the scanner, since
10053 // it is used by the default message handler when displaying
10054 // warnings and errors. If you are scanning a file, the filename
10055 // would be a good choice.
10057 // The @user_data and @max_parse_errors fields are not used.
10058 // If you need to associate extra data with the scanner you
10059 // can place them here.
10061 // If you want to use your own message handler you can set the
10062 // @msg_handler field. The type of the message handler function
10063 // is declared by #GScannerMsgFunc.
10064 struct Scanner {
10065 void* user_data;
10066 uint max_parse_errors, parse_errors;
10067 char* input_name;
10068 Data* qdata;
10069 ScannerConfig* config;
10070 TokenType token;
10071 TokenValue value;
10072 uint line, position;
10073 TokenType next_token;
10074 TokenValue next_value;
10075 uint next_line, next_position;
10076 private GLib2.HashTable* symbol_table;
10077 private int input_fd;
10078 private char* text, text_end, buffer;
10079 private uint scope_id;
10080 ScannerMsgFunc msg_handler;
10083 // Returns the current line in the input stream (counting
10084 // from 1). This is the line of the last token parsed via
10085 // g_scanner_get_next_token().
10086 // RETURNS: the current line
10087 uint cur_line()() {
10088 return g_scanner_cur_line(&this);
10091 // Returns the current position in the current line (counting
10092 // from 0). This is the position of the last token parsed via
10093 // g_scanner_get_next_token().
10094 // RETURNS: the current position on the line
10095 uint cur_position()() {
10096 return g_scanner_cur_position(&this);
10099 // Gets the current token type. This is simply the @token
10100 // field in the #GScanner structure.
10101 // RETURNS: the current token type
10102 TokenType cur_token()() {
10103 return g_scanner_cur_token(&this);
10106 // Unintrospectable method: cur_value() / g_scanner_cur_value()
10107 // Gets the current token value. This is simply the @value
10108 // field in the #GScanner structure.
10109 // RETURNS: the current token value
10110 TokenValue cur_value()() {
10111 return g_scanner_cur_value(&this);
10113 // Frees all memory used by the #GScanner.
10114 void destroy()() {
10115 g_scanner_destroy(&this);
10118 // Returns %TRUE if the scanner has reached the end of
10119 // the file or text buffer.
10121 // the file or text buffer
10122 // RETURNS: %TRUE if the scanner has reached the end of
10123 int eof()() {
10124 return g_scanner_eof(&this);
10127 // Unintrospectable method: error() / g_scanner_error()
10128 // Outputs an error message, via the #GScanner message handler.
10129 // <format>: the message format. See the printf() documentation
10130 /+ Not available -- variadic methods unsupported - use the C function directly.
10131 alias g_scanner_error error; // Variadic
10134 // Parses the next token just like g_scanner_peek_next_token()
10135 // and also removes it from the input stream. The token data is
10136 // placed in the @token, @value, @line, and @position fields of
10137 // the #GScanner structure.
10138 // RETURNS: the type of the token
10139 TokenType get_next_token()() {
10140 return g_scanner_get_next_token(&this);
10143 // Prepares to scan a file.
10144 // <input_fd>: a file descriptor
10145 void input_file()(int input_fd) {
10146 g_scanner_input_file(&this, input_fd);
10149 // Prepares to scan a text buffer.
10150 // <text>: the text buffer to scan
10151 // <text_len>: the length of the text buffer
10152 void input_text()(char* text, uint text_len) {
10153 g_scanner_input_text(&this, text, text_len);
10156 // Unintrospectable method: lookup_symbol() / g_scanner_lookup_symbol()
10157 // Looks up a symbol in the current scope and return its value.
10158 // If the symbol is not bound in the current scope, %NULL is
10159 // returned.
10161 // if @symbol is not bound in the current scope
10162 // RETURNS: the value of @symbol in the current scope, or %NULL
10163 // <symbol>: the symbol to look up
10164 void* lookup_symbol()(char* symbol) {
10165 return g_scanner_lookup_symbol(&this, symbol);
10168 // Parses the next token, without removing it from the input stream.
10169 // The token data is placed in the @next_token, @next_value, @next_line,
10170 // and @next_position fields of the #GScanner structure.
10172 // Note that, while the token is not removed from the input stream
10173 // (i.e. the next call to g_scanner_get_next_token() will return the
10174 // same token), it will not be reevaluated. This can lead to surprising
10175 // results when changing scope or the scanner configuration after peeking
10176 // the next token. Getting the next token after switching the scope or
10177 // configuration will return whatever was peeked before, regardless of
10178 // any symbols that may have been added or removed in the new scope.
10179 // RETURNS: the type of the token
10180 TokenType peek_next_token()() {
10181 return g_scanner_peek_next_token(&this);
10184 // Adds a symbol to the given scope.
10185 // <scope_id>: the scope id
10186 // <symbol>: the symbol to add
10187 // <value>: the value of the symbol
10188 void scope_add_symbol()(uint scope_id, char* symbol, void* value) {
10189 g_scanner_scope_add_symbol(&this, scope_id, symbol, value);
10192 // Unintrospectable method: scope_foreach_symbol() / g_scanner_scope_foreach_symbol()
10193 // Calls the given function for each of the symbol/value pairs
10194 // in the given scope of the #GScanner. The function is passed
10195 // the symbol and value of each pair, and the given @user_data
10196 // parameter.
10197 // <scope_id>: the scope id
10198 // <func>: the function to call for each symbol/value pair
10199 // <user_data>: user data to pass to the function
10200 void scope_foreach_symbol()(uint scope_id, HFunc func, void* user_data) {
10201 g_scanner_scope_foreach_symbol(&this, scope_id, func, user_data);
10204 // Unintrospectable method: scope_lookup_symbol() / g_scanner_scope_lookup_symbol()
10205 // Looks up a symbol in a scope and return its value. If the
10206 // symbol is not bound in the scope, %NULL is returned.
10208 // if @symbol is not bound in the given scope.
10209 // RETURNS: the value of @symbol in the given scope, or %NULL
10210 // <scope_id>: the scope id
10211 // <symbol>: the symbol to look up
10212 void* scope_lookup_symbol()(uint scope_id, char* symbol) {
10213 return g_scanner_scope_lookup_symbol(&this, scope_id, symbol);
10216 // Removes a symbol from a scope.
10217 // <scope_id>: the scope id
10218 // <symbol>: the symbol to remove
10219 void scope_remove_symbol()(uint scope_id, char* symbol) {
10220 g_scanner_scope_remove_symbol(&this, scope_id, symbol);
10223 // Sets the current scope.
10224 // RETURNS: the old scope id
10225 // <scope_id>: the new scope id
10226 uint set_scope()(uint scope_id) {
10227 return g_scanner_set_scope(&this, scope_id);
10230 // Rewinds the filedescriptor to the current buffer position
10231 // and blows the file read ahead buffer. This is useful for
10232 // third party uses of the scanners filedescriptor, which hooks
10233 // onto the current scanning position.
10234 void sync_file_offset()() {
10235 g_scanner_sync_file_offset(&this);
10238 // Outputs a message through the scanner's msg_handler,
10239 // resulting from an unexpected token in the input stream.
10240 // Note that you should not call g_scanner_peek_next_token()
10241 // followed by g_scanner_unexp_token() without an intermediate
10242 // call to g_scanner_get_next_token(), as g_scanner_unexp_token()
10243 // evaluates the scanner's current token (not the peeked token)
10244 // to construct part of the message.
10245 // <expected_token>: the expected token
10246 // <identifier_spec>: a string describing how the scanner's user refers to identifiers (%NULL defaults to "identifier"). This is used if @expected_token is %G_TOKEN_IDENTIFIER or %G_TOKEN_IDENTIFIER_NULL.
10247 // <symbol_spec>: a string describing how the scanner's user refers to symbols (%NULL defaults to "symbol"). This is used if @expected_token is %G_TOKEN_SYMBOL or any token value greater than %G_TOKEN_LAST.
10248 // <symbol_name>: the name of the symbol, if the scanner's current token is a symbol.
10249 // <message>: a message string to output at the end of the warning/error, or %NULL.
10250 // <is_error>: if %TRUE it is output as an error. If %FALSE it is output as a warning.
10251 void unexp_token()(TokenType expected_token, char* identifier_spec, char* symbol_spec, char* symbol_name, char* message, int is_error) {
10252 g_scanner_unexp_token(&this, expected_token, identifier_spec, symbol_spec, symbol_name, message, is_error);
10255 // Unintrospectable method: warn() / g_scanner_warn()
10256 // Outputs a warning message, via the #GScanner message handler.
10257 // <format>: the message format. See the printf() documentation
10258 /+ Not available -- variadic methods unsupported - use the C function directly.
10259 alias g_scanner_warn warn; // Variadic
10262 // Unintrospectable function: new() / g_scanner_new()
10263 // Creates a new #GScanner.
10265 // The @config_templ structure specifies the initial settings
10266 // of the scanner, which are copied into the #GScanner
10267 // @config field. If you pass %NULL then the default settings
10268 // are used.
10269 // RETURNS: the new #GScanner
10270 // <config_templ>: the initial scanner settings
10271 static Scanner* new_()(ScannerConfig* config_templ) {
10272 return g_scanner_new(config_templ);
10277 // Specifies the #GScanner parser configuration. Most settings can
10278 // be changed during the parsing phase and will affect the lexical
10279 // parsing of the next unpeeked token.
10280 struct ScannerConfig {
10281 char* cset_skip_characters, cset_identifier_first, cset_identifier_nth, cpair_comment_single;
10282 static import std.bitmanip; mixin(std.bitmanip.bitfields!(
10283 uint, "case_sensitive", 1,
10284 uint, "skip_comment_multi", 1,
10285 uint, "skip_comment_single", 1,
10286 uint, "scan_comment_multi", 1,
10287 uint, "scan_identifier", 1,
10288 uint, "scan_identifier_1char", 1,
10289 uint, "scan_identifier_NULL", 1,
10290 uint, "scan_symbols", 1,
10291 uint, "scan_binary", 1,
10292 uint, "scan_octal", 1,
10293 uint, "scan_float", 1,
10294 uint, "scan_hex", 1,
10295 uint, "scan_hex_dollar", 1,
10296 uint, "scan_string_sq", 1,
10297 uint, "scan_string_dq", 1,
10298 uint, "numbers_2_int", 1,
10299 uint, "int_2_float", 1,
10300 uint, "identifier_2_string", 1,
10301 uint, "char_2_token", 1,
10302 uint, "symbol_2_token", 1,
10303 uint, "scope_0_fallback", 1,
10304 uint, "store_int64", 1,
10305 uint, "__dummy32A", 10));
10306 private uint padding_dummy;
10310 // Specifies the type of the message handler function.
10311 // <scanner>: a #GScanner
10312 // <message>: the message
10313 // <error>: %TRUE if the message signals an error, %FALSE if it signals a warning.
10314 extern (C) alias void function (Scanner* scanner, char* message, int error) ScannerMsgFunc;
10317 // An enumeration specifying the base position for a
10318 // g_io_channel_seek_position() operation.
10319 enum SeekType {
10320 CUR = 0,
10321 SET = 1,
10322 END = 2
10325 // The #GSequence struct is an opaque data type representing a
10326 // <link linkend="glib-Sequences">Sequence</link> data type.
10327 struct Sequence {
10329 // Unintrospectable method: append() / g_sequence_append()
10330 // VERSION: 2.14
10331 // Adds a new item to the end of @seq.
10332 // RETURNS: an iterator pointing to the new item
10333 // <data>: the data for the new item
10334 SequenceIter* append()(void* data) {
10335 return g_sequence_append(&this, data);
10338 // Unintrospectable method: foreach() / g_sequence_foreach()
10339 // VERSION: 2.14
10340 // Calls @func for each item in the sequence passing @user_data
10341 // to the function.
10342 // <func>: the function to call for each item in @seq
10343 // <user_data>: user data passed to @func
10344 void foreach_()(Func func, void* user_data) {
10345 g_sequence_foreach(&this, func, user_data);
10348 // VERSION: 2.14
10349 // Frees the memory allocated for @seq. If @seq has a data destroy
10350 // function associated with it, that function is called on all items in
10351 // @seq.
10352 void free()() {
10353 g_sequence_free(&this);
10356 // Unintrospectable method: get_begin_iter() / g_sequence_get_begin_iter()
10357 // VERSION: 2.14
10358 // Returns the begin iterator for @seq.
10359 // RETURNS: the begin iterator for @seq.
10360 SequenceIter* get_begin_iter()() {
10361 return g_sequence_get_begin_iter(&this);
10364 // Unintrospectable method: get_end_iter() / g_sequence_get_end_iter()
10365 // VERSION: 2.14
10366 // Returns the end iterator for @seg
10367 // RETURNS: the end iterator for @seq
10368 SequenceIter* get_end_iter()() {
10369 return g_sequence_get_end_iter(&this);
10372 // Unintrospectable method: get_iter_at_pos() / g_sequence_get_iter_at_pos()
10373 // VERSION: 2.14
10374 // Returns the iterator at position @pos. If @pos is negative or larger
10375 // than the number of items in @seq, the end iterator is returned.
10376 // RETURNS: The #GSequenceIter at position @pos
10377 // <pos>: a position in @seq, or -1 for the end.
10378 SequenceIter* get_iter_at_pos()(int pos) {
10379 return g_sequence_get_iter_at_pos(&this, pos);
10382 // VERSION: 2.14
10383 // Returns the length of @seq
10384 // RETURNS: the length of @seq
10385 int get_length()() {
10386 return g_sequence_get_length(&this);
10389 // Unintrospectable method: insert_sorted() / g_sequence_insert_sorted()
10390 // VERSION: 2.14
10391 // Inserts @data into @sequence using @func to determine the new
10392 // position. The sequence must already be sorted according to @cmp_func;
10393 // otherwise the new position of @data is undefined.
10395 // @cmp_func is called with two items of the @seq and @user_data.
10396 // It should return 0 if the items are equal, a negative value
10397 // if the first item comes before the second, and a positive value
10398 // if the second item comes before the first.
10399 // RETURNS: a #GSequenceIter pointing to the new item.
10400 // <data>: the data to insert
10401 // <cmp_func>: the function used to compare items in the sequence
10402 // <cmp_data>: user data passed to @cmp_func.
10403 SequenceIter* insert_sorted()(void* data, CompareDataFunc cmp_func, void* cmp_data) {
10404 return g_sequence_insert_sorted(&this, data, cmp_func, cmp_data);
10407 // Unintrospectable method: insert_sorted_iter() / g_sequence_insert_sorted_iter()
10408 // VERSION: 2.14
10409 // Like g_sequence_insert_sorted(), but uses
10410 // a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as
10411 // the compare function.
10413 // @iter_cmp is called with two iterators pointing into @seq.
10414 // It should return 0 if the iterators are equal, a negative
10415 // value if the first iterator comes before the second, and a
10416 // positive value if the second iterator comes before the first.
10418 // It is called with two iterators pointing into @seq. It should
10419 // return 0 if the iterators are equal, a negative value if the
10420 // first iterator comes before the second, and a positive value
10421 // if the second iterator comes before the first.
10422 // RETURNS: a #GSequenceIter pointing to the new item
10423 // <data>: data for the new item
10424 // <iter_cmp>: the function used to compare iterators in the sequence
10425 // <cmp_data>: user data passed to @cmp_func
10426 SequenceIter* insert_sorted_iter()(void* data, SequenceIterCompareFunc iter_cmp, void* cmp_data) {
10427 return g_sequence_insert_sorted_iter(&this, data, iter_cmp, cmp_data);
10430 // Unintrospectable method: lookup() / g_sequence_lookup()
10431 // VERSION: 2.28
10432 // Returns an iterator pointing to the position of the first item found
10433 // equal to @data according to @cmp_func and @cmp_data. If more than one
10434 // item is equal, it is not guaranteed that it is the first which is
10435 // returned. In that case, you can use g_sequence_iter_next() and
10436 // g_sequence_iter_prev() to get others.
10438 // @cmp_func is called with two items of the @seq and @user_data.
10439 // It should return 0 if the items are equal, a negative value if
10440 // the first item comes before the second, and a positive value if
10441 // the second item comes before the first.
10443 // first item found equal to @data according to @cmp_func and @cmp_data.
10444 // RETURNS: an #GSequenceIter pointing to the position of the
10445 // <data>: data to lookup
10446 // <cmp_func>: the function used to compare items in the sequence
10447 // <cmp_data>: user data passed to @cmp_func.
10448 SequenceIter* lookup()(void* data, CompareDataFunc cmp_func, void* cmp_data) {
10449 return g_sequence_lookup(&this, data, cmp_func, cmp_data);
10452 // Unintrospectable method: lookup_iter() / g_sequence_lookup_iter()
10453 // VERSION: 2.28
10454 // Like g_sequence_lookup(), but uses a #GSequenceIterCompareFunc
10455 // instead of a #GCompareDataFunc as the compare function.
10457 // @iter_cmp is called with two iterators pointing into @seq.
10458 // It should return 0 if the iterators are equal, a negative value
10459 // if the first iterator comes before the second, and a positive
10460 // value if the second iterator comes before the first.
10462 // the first item found equal to @data according to @cmp_func
10463 // and @cmp_data.
10464 // RETURNS: an #GSequenceIter pointing to the position of
10465 // <data>: data to lookup
10466 // <iter_cmp>: the function used to compare iterators in the sequence
10467 // <cmp_data>: user data passed to @iter_cmp
10468 SequenceIter* lookup_iter()(void* data, SequenceIterCompareFunc iter_cmp, void* cmp_data) {
10469 return g_sequence_lookup_iter(&this, data, iter_cmp, cmp_data);
10472 // Unintrospectable method: prepend() / g_sequence_prepend()
10473 // VERSION: 2.14
10474 // Adds a new item to the front of @seq
10475 // RETURNS: an iterator pointing to the new item
10476 // <data>: the data for the new item
10477 SequenceIter* prepend()(void* data) {
10478 return g_sequence_prepend(&this, data);
10481 // Unintrospectable method: search() / g_sequence_search()
10482 // VERSION: 2.14
10483 // Returns an iterator pointing to the position where @data would
10484 // be inserted according to @cmp_func and @cmp_data.
10486 // @cmp_func is called with two items of the @seq and @user_data.
10487 // It should return 0 if the items are equal, a negative value if
10488 // the first item comes before the second, and a positive value if
10489 // the second item comes before the first.
10491 // If you are simply searching for an existing element of the sequence,
10492 // consider using g_sequence_lookup().
10494 // would have been inserted according to @cmp_func and @cmp_data.
10495 // RETURNS: an #GSequenceIter pointing to the position where @data
10496 // <data>: data for the new item
10497 // <cmp_func>: the function used to compare items in the sequence
10498 // <cmp_data>: user data passed to @cmp_func.
10499 SequenceIter* search()(void* data, CompareDataFunc cmp_func, void* cmp_data) {
10500 return g_sequence_search(&this, data, cmp_func, cmp_data);
10503 // Unintrospectable method: search_iter() / g_sequence_search_iter()
10504 // VERSION: 2.14
10505 // Like g_sequence_search(), but uses a #GSequenceIterCompareFunc
10506 // instead of a #GCompareDataFunc as the compare function.
10508 // @iter_cmp is called with two iterators pointing into @seq.
10509 // It should return 0 if the iterators are equal, a negative value
10510 // if the first iterator comes before the second, and a positive
10511 // value if the second iterator comes before the first.
10513 // If you are simply searching for an existing element of the sequence,
10514 // consider using g_sequence_lookup_iter().
10516 // where @data would have been inserted according to @iter_cmp
10517 // and @cmp_data.
10518 // RETURNS: a #GSequenceIter pointing to the position in @seq
10519 // <data>: data for the new item
10520 // <iter_cmp>: the function used to compare iterators in the sequence
10521 // <cmp_data>: user data passed to @iter_cmp
10522 SequenceIter* search_iter()(void* data, SequenceIterCompareFunc iter_cmp, void* cmp_data) {
10523 return g_sequence_search_iter(&this, data, iter_cmp, cmp_data);
10526 // Unintrospectable method: sort() / g_sequence_sort()
10527 // VERSION: 2.14
10528 // Sorts @seq using @cmp_func.
10530 // @cmp_func is passed two items of @seq and should
10531 // return 0 if they are equal, a negative value if the
10532 // first comes before the second, and a positive value
10533 // if the second comes before the first.
10534 // <cmp_func>: the function used to sort the sequence
10535 // <cmp_data>: user data passed to @cmp_func
10536 void sort()(CompareDataFunc cmp_func, void* cmp_data) {
10537 g_sequence_sort(&this, cmp_func, cmp_data);
10540 // Unintrospectable method: sort_iter() / g_sequence_sort_iter()
10541 // VERSION: 2.14
10542 // Like g_sequence_sort(), but uses a #GSequenceIterCompareFunc instead
10543 // of a GCompareDataFunc as the compare function
10545 // @cmp_func is called with two iterators pointing into @seq. It should
10546 // return 0 if the iterators are equal, a negative value if the first
10547 // iterator comes before the second, and a positive value if the second
10548 // iterator comes before the first.
10549 // <cmp_func>: the function used to compare iterators in the sequence
10550 // <cmp_data>: user data passed to @cmp_func
10551 void sort_iter()(SequenceIterCompareFunc cmp_func, void* cmp_data) {
10552 g_sequence_sort_iter(&this, cmp_func, cmp_data);
10555 // Unintrospectable function: foreach_range() / g_sequence_foreach_range()
10556 // VERSION: 2.14
10557 // Calls @func for each item in the range (@begin, @end) passing
10558 // @user_data to the function.
10559 // <begin>: a #GSequenceIter
10560 // <end>: a #GSequenceIter
10561 // <func>: a #GFunc
10562 // <user_data>: user data passed to @func
10563 static void foreach_range()(SequenceIter* begin, SequenceIter* end, Func func, void* user_data) {
10564 g_sequence_foreach_range(begin, end, func, user_data);
10567 // Unintrospectable function: get() / g_sequence_get()
10568 // VERSION: 2.14
10569 // Returns the data that @iter points to.
10570 // RETURNS: the data that @iter points to
10571 // <iter>: a #GSequenceIter
10572 static void* get()(SequenceIter* iter) {
10573 return g_sequence_get(iter);
10576 // Unintrospectable function: insert_before() / g_sequence_insert_before()
10577 // VERSION: 2.14
10578 // Inserts a new item just before the item pointed to by @iter.
10579 // RETURNS: an iterator pointing to the new item
10580 // <iter>: a #GSequenceIter
10581 // <data>: the data for the new item
10582 static SequenceIter* insert_before()(SequenceIter* iter, void* data) {
10583 return g_sequence_insert_before(iter, data);
10586 // VERSION: 2.14
10587 // Moves the item pointed to by @src to the position indicated by @dest.
10588 // After calling this function @dest will point to the position immediately
10589 // after @src. It is allowed for @src and @dest to point into different
10590 // sequences.
10591 // <src>: a #GSequenceIter pointing to the item to move
10592 // <dest>: a #GSequenceIter pointing to the position to which the item is moved.
10593 static void move()(SequenceIter* src, SequenceIter* dest) {
10594 g_sequence_move(src, dest);
10597 // VERSION: 2.14
10598 // Inserts the (@begin, @end) range at the destination pointed to by ptr.
10599 // The @begin and @end iters must point into the same sequence. It is
10600 // allowed for @dest to point to a different sequence than the one pointed
10601 // into by @begin and @end.
10603 // If @dest is NULL, the range indicated by @begin and @end is
10604 // removed from the sequence. If @dest iter points to a place within
10605 // the (@begin, @end) range, the range does not move.
10606 // <dest>: a #GSequenceIter
10607 // <begin>: a #GSequenceIter
10608 // <end>: a #GSequenceIter
10609 static void move_range()(SequenceIter* dest, SequenceIter* begin, SequenceIter* end) {
10610 g_sequence_move_range(dest, begin, end);
10613 // Unintrospectable function: new() / g_sequence_new()
10614 // VERSION: 2.14
10615 // Creates a new GSequence. The @data_destroy function, if non-%NULL will
10616 // be called on all items when the sequence is destroyed and on items that
10617 // are removed from the sequence.
10618 // RETURNS: a new #GSequence
10619 // <data_destroy>: a #GDestroyNotify function, or %NULL
10620 static Sequence* new_()(DestroyNotify data_destroy) {
10621 return g_sequence_new(data_destroy);
10624 // Unintrospectable function: range_get_midpoint() / g_sequence_range_get_midpoint()
10625 // VERSION: 2.14
10626 // Finds an iterator somewhere in the range (@begin, @end). This
10627 // iterator will be close to the middle of the range, but is not
10628 // guaranteed to be <emphasis>exactly</emphasis> in the middle.
10630 // The @begin and @end iterators must both point to the same sequence and
10631 // @begin must come before or be equal to @end in the sequence.
10633 // (@begin, @end) range.
10634 // RETURNS: A #GSequenceIter pointing somewhere in the
10635 // <begin>: a #GSequenceIter
10636 // <end>: a #GSequenceIter
10637 static SequenceIter* range_get_midpoint()(SequenceIter* begin, SequenceIter* end) {
10638 return g_sequence_range_get_midpoint(begin, end);
10641 // VERSION: 2.14
10642 // Removes the item pointed to by @iter. It is an error to pass the
10643 // end iterator to this function.
10645 // If the sequnce has a data destroy function associated with it, this
10646 // function is called on the data for the removed item.
10647 // <iter>: a #GSequenceIter
10648 static void remove()(SequenceIter* iter) {
10649 g_sequence_remove(iter);
10652 // VERSION: 2.14
10653 // Removes all items in the (@begin, @end) range.
10655 // If the sequence has a data destroy function associated with it, this
10656 // function is called on the data for the removed items.
10657 // <begin>: a #GSequenceIter
10658 // <end>: a #GSequenceIter
10659 static void remove_range()(SequenceIter* begin, SequenceIter* end) {
10660 g_sequence_remove_range(begin, end);
10663 // VERSION: 2.14
10664 // Changes the data for the item pointed to by @iter to be @data. If
10665 // the sequence has a data destroy function associated with it, that
10666 // function is called on the existing data that @iter pointed to.
10667 // <iter>: a #GSequenceIter
10668 // <data>: new data for the item
10669 static void set()(SequenceIter* iter, void* data) {
10670 g_sequence_set(iter, data);
10673 // Unintrospectable function: sort_changed() / g_sequence_sort_changed()
10674 // VERSION: 2.14
10675 // Moves the data pointed to a new position as indicated by @cmp_func. This
10676 // function should be called for items in a sequence already sorted according
10677 // to @cmp_func whenever some aspect of an item changes so that @cmp_func
10678 // may return different values for that item.
10680 // @cmp_func is called with two items of the @seq and @user_data.
10681 // It should return 0 if the items are equal, a negative value if
10682 // the first item comes before the second, and a positive value if
10683 // the second item comes before the first.
10684 // <iter>: A #GSequenceIter
10685 // <cmp_func>: the function used to compare items in the sequence
10686 // <cmp_data>: user data passed to @cmp_func.
10687 static void sort_changed()(SequenceIter* iter, CompareDataFunc cmp_func, void* cmp_data) {
10688 g_sequence_sort_changed(iter, cmp_func, cmp_data);
10691 // Unintrospectable function: sort_changed_iter() / g_sequence_sort_changed_iter()
10692 // VERSION: 2.14
10693 // Like g_sequence_sort_changed(), but uses
10694 // a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as
10695 // the compare function.
10697 // @iter_cmp is called with two iterators pointing into @seq. It should
10698 // return 0 if the iterators are equal, a negative value if the first
10699 // iterator comes before the second, and a positive value if the second
10700 // iterator comes before the first.
10701 // <iter>: a #GSequenceIter
10702 // <iter_cmp>: the function used to compare iterators in the sequence
10703 // <cmp_data>: user data passed to @cmp_func
10704 static void sort_changed_iter()(SequenceIter* iter, SequenceIterCompareFunc iter_cmp, void* cmp_data) {
10705 g_sequence_sort_changed_iter(iter, iter_cmp, cmp_data);
10708 // VERSION: 2.14
10709 // Swaps the items pointed to by @a and @b. It is allowed for @a and @b
10710 // to point into difference sequences.
10711 // <a>: a #GSequenceIter
10712 // <b>: a #GSequenceIter
10713 static void swap()(SequenceIter* a, SequenceIter* b) {
10714 g_sequence_swap(a, b);
10719 // The #GSequenceIter struct is an opaque data type representing an
10720 // iterator pointing into a #GSequence.
10721 struct SequenceIter {
10723 // VERSION: 2.14
10724 // Returns a negative number if @a comes before @b, 0 if they are equal,
10725 // and a positive number if @a comes after @b.
10727 // The @a and @b iterators must point into the same sequence.
10729 // equal, and a positive number if @a comes after @b.
10730 // RETURNS: A negative number if @a comes before @b, 0 if they are
10731 // <b>: a #GSequenceIter
10732 int compare()(SequenceIter* b) {
10733 return g_sequence_iter_compare(&this, b);
10736 // VERSION: 2.14
10737 // Returns the position of @iter
10738 // RETURNS: the position of @iter
10739 int get_position()() {
10740 return g_sequence_iter_get_position(&this);
10743 // Unintrospectable method: get_sequence() / g_sequence_iter_get_sequence()
10744 // VERSION: 2.14
10745 // Returns the #GSequence that @iter points into.
10746 // RETURNS: the #GSequence that @iter points into.
10747 Sequence* get_sequence()() {
10748 return g_sequence_iter_get_sequence(&this);
10751 // VERSION: 2.14
10752 // Returns whether @iter is the begin iterator
10753 // RETURNS: whether @iter is the begin iterator
10754 int is_begin()() {
10755 return g_sequence_iter_is_begin(&this);
10758 // VERSION: 2.14
10759 // Returns whether @iter is the end iterator
10760 // RETURNS: Whether @iter is the end iterator.
10761 int is_end()() {
10762 return g_sequence_iter_is_end(&this);
10765 // Unintrospectable method: move() / g_sequence_iter_move()
10766 // VERSION: 2.14
10767 // Returns the #GSequenceIter which is @delta positions away from @iter.
10768 // If @iter is closer than -@delta positions to the beginning of the sequence,
10769 // the begin iterator is returned. If @iter is closer than @delta positions
10770 // to the end of the sequence, the end iterator is returned.
10771 // RETURNS: a #GSequenceIter which is @delta positions away from @iter.
10772 // <delta>: A positive or negative number indicating how many positions away from @iter the returned #GSequenceIter will be.
10773 SequenceIter* move()(int delta) {
10774 return g_sequence_iter_move(&this, delta);
10777 // Unintrospectable method: next() / g_sequence_iter_next()
10778 // VERSION: 2.14
10779 // Returns an iterator pointing to the next position after @iter. If
10780 // @iter is the end iterator, the end iterator is returned.
10781 // RETURNS: a #GSequenceIter pointing to the next position after @iter.
10782 SequenceIter* next()() {
10783 return g_sequence_iter_next(&this);
10786 // Unintrospectable method: prev() / g_sequence_iter_prev()
10787 // VERSION: 2.14
10788 // Returns an iterator pointing to the previous position before @iter. If
10789 // @iter is the begin iterator, the begin iterator is returned.
10791 // @iter.
10792 // RETURNS: a #GSequenceIter pointing to the previous position before
10793 SequenceIter* prev()() {
10794 return g_sequence_iter_prev(&this);
10799 // A #GSequenceIterCompareFunc is a function used to compare iterators.
10800 // It must return zero if the iterators compare equal, a negative value
10801 // if @a comes before @b, and a positive value if @b comes before @a.
10802 // <a>: a #GSequenceIter
10803 // <b>: a #GSequenceIter
10804 // <data>: user data
10805 extern (C) alias int function (SequenceIter* a, SequenceIter* b, void* data) SequenceIterCompareFunc;
10807 // Error codes returned by shell functions.
10808 enum ShellError {
10809 BAD_QUOTING = 0,
10810 EMPTY_STRING = 1,
10811 FAILED = 2
10813 enum SliceConfig {
10814 ALWAYS_MALLOC = 1,
10815 BYPASS_MAGAZINES = 2,
10816 WORKING_SET_MSECS = 3,
10817 COLOR_INCREMENT = 4,
10818 CHUNK_SIZES = 5,
10819 CONTENTION_COUNTER = 6
10822 // The <structname>GSource</structname> struct is an opaque data type
10823 // representing an event source.
10824 struct Source {
10825 private void* callback_data;
10826 private SourceCallbackFuncs* callback_funcs;
10827 private SourceFuncs* source_funcs;
10828 private uint ref_count;
10829 private MainContext* context;
10830 private int priority;
10831 private uint flags, source_id;
10832 private GLib2.SList* poll_fds;
10833 private Source* prev, next;
10834 private char* name;
10835 private SourcePrivate* priv;
10838 // Creates a new #GSource structure. The size is specified to
10839 // allow creating structures derived from #GSource that contain
10840 // additional data. The size passed in must be at least
10841 // <literal>sizeof (GSource)</literal>.
10843 // The source will not initially be associated with any #GMainContext
10844 // and must be added to one with g_source_attach() before it will be
10845 // executed.
10846 // RETURNS: the newly-created #GSource.
10847 // <source_funcs>: structure containing functions that implement the sources behavior.
10848 // <struct_size>: size of the #GSource structure to create.
10849 static Source* /*new*/ new_()(SourceFuncs* source_funcs, uint struct_size) {
10850 return g_source_new(source_funcs, struct_size);
10853 // VERSION: 2.28
10854 // Adds @child_source to @source as a "polled" source; when @source is
10855 // added to a #GMainContext, @child_source will be automatically added
10856 // with the same priority, when @child_source is triggered, it will
10857 // cause @source to dispatch (in addition to calling its own
10858 // callback), and when @source is destroyed, it will destroy
10859 // @child_source as well. (@source will also still be dispatched if
10860 // its own prepare/check functions indicate that it is ready.)
10862 // If you don't need @child_source to do anything on its own when it
10863 // triggers, you can call g_source_set_dummy_callback() on it to set a
10864 // callback that does nothing (except return %TRUE if appropriate).
10866 // @source will hold a reference on @child_source while @child_source
10867 // is attached to it.
10868 // <child_source>: a second #GSource that @source should "poll"
10869 void add_child_source()(Source* child_source) {
10870 g_source_add_child_source(&this, child_source);
10873 // Adds a file descriptor to the set of file descriptors polled for
10874 // this source. This is usually combined with g_source_new() to add an
10875 // event source. The event source's check function will typically test
10876 // the @revents field in the #GPollFD struct and return %TRUE if events need
10877 // to be processed.
10878 // <fd>: a #GPollFD structure holding information about a file descriptor to watch.
10879 void add_poll()(PollFD* fd) {
10880 g_source_add_poll(&this, fd);
10883 // Adds a #GSource to a @context so that it will be executed within
10884 // that context. Remove it by calling g_source_destroy().
10886 // #GMainContext.
10887 // RETURNS: the ID (greater than 0) for the source within the
10888 // <context>: a #GMainContext (if %NULL, the default context will be used)
10889 uint attach()(MainContext* context=null) {
10890 return g_source_attach(&this, context);
10893 // Removes a source from its #GMainContext, if any, and mark it as
10894 // destroyed. The source cannot be subsequently added to another
10895 // context.
10896 void destroy()() {
10897 g_source_destroy(&this);
10900 // Checks whether a source is allowed to be called recursively.
10901 // see g_source_set_can_recurse().
10902 // RETURNS: whether recursion is allowed.
10903 int get_can_recurse()() {
10904 return g_source_get_can_recurse(&this);
10907 // Gets the #GMainContext with which the source is associated.
10908 // Calling this function on a destroyed source is an error.
10910 // source is associated, or %NULL if the context has not
10911 // yet been added to a source.
10912 // RETURNS: the #GMainContext with which the
10913 MainContext* get_context()() {
10914 return g_source_get_context(&this);
10917 // DEPRECATED (v2.28) method: get_current_time - use g_source_get_time() instead
10918 // This function ignores @source and is otherwise the same as
10919 // g_get_current_time().
10920 // <timeval>: #GTimeVal structure in which to store current time.
10921 void get_current_time()(TimeVal* timeval) {
10922 g_source_get_current_time(&this, timeval);
10925 // Returns the numeric ID for a particular source. The ID of a source
10926 // is a positive integer which is unique within a particular main loop
10927 // context. The reverse
10928 // mapping from ID to source is done by g_main_context_find_source_by_id().
10929 // RETURNS: the ID (greater than 0) for the source
10930 uint get_id()() {
10931 return g_source_get_id(&this);
10934 // VERSION: 2.26
10935 // Gets a name for the source, used in debugging and profiling.
10936 // The name may be #NULL if it has never been set with
10937 // g_source_set_name().
10938 // RETURNS: the name of the source
10939 char* get_name()() {
10940 return g_source_get_name(&this);
10943 // Gets the priority of a source.
10944 // RETURNS: the priority of the source
10945 int get_priority()() {
10946 return g_source_get_priority(&this);
10949 // VERSION: 2.28
10950 // Gets the time to be used when checking this source. The advantage of
10951 // calling this function over calling g_get_monotonic_time() directly is
10952 // that when checking multiple sources, GLib can cache a single value
10953 // instead of having to repeatedly get the system monotonic time.
10955 // The time here is the system monotonic time, if available, or some
10956 // other reasonable alternative otherwise. See g_get_monotonic_time().
10957 // RETURNS: the monotonic time in microseconds
10958 long get_time()() {
10959 return g_source_get_time(&this);
10962 // VERSION: 2.12
10963 // Returns whether @source has been destroyed.
10965 // This is important when you operate upon your objects
10966 // from within idle handlers, but may have freed the object
10967 // before the dispatch of your idle handler.
10969 // |[
10970 // static gboolean
10971 // idle_callback (gpointer data)
10972 // {
10973 // SomeWidget *self = data;
10975 // GDK_THREADS_ENTER (<!-- -->);
10976 // /<!-- -->* do stuff with self *<!-- -->/
10977 // self->idle_id = 0;
10978 // GDK_THREADS_LEAVE (<!-- -->);
10980 // return FALSE;
10981 // }
10983 // static void
10984 // some_widget_do_stuff_later (SomeWidget *self)
10985 // {
10986 // self->idle_id = g_idle_add (idle_callback, self);
10987 // }
10989 // static void
10990 // some_widget_finalize (GObject *object)
10991 // {
10992 // SomeWidget *self = SOME_WIDGET (object);
10994 // if (self->idle_id)
10995 // g_source_remove (self->idle_id);
10997 // G_OBJECT_CLASS (parent_class)->finalize (object);
10998 // }
10999 // ]|
11001 // This will fail in a multi-threaded application if the
11002 // widget is destroyed before the idle handler fires due
11003 // to the use after free in the callback. A solution, to
11004 // this particular problem, is to check to if the source
11005 // has already been destroy within the callback.
11007 // |[
11008 // static gboolean
11009 // idle_callback (gpointer data)
11010 // {
11011 // SomeWidget *self = data;
11013 // GDK_THREADS_ENTER ();
11014 // if (!g_source_is_destroyed (g_main_current_source ()))
11015 // {
11016 // /<!-- -->* do stuff with self *<!-- -->/
11017 // }
11018 // GDK_THREADS_LEAVE ();
11020 // return FALSE;
11021 // }
11022 // ]|
11023 // RETURNS: %TRUE if the source has been destroyed
11024 int is_destroyed()() {
11025 return g_source_is_destroyed(&this);
11028 // Increases the reference count on a source by one.
11029 // RETURNS: @source
11030 Source* /*new*/ ref_()() {
11031 return g_source_ref(&this);
11034 // VERSION: 2.28
11035 // Detaches @child_source from @source and destroys it.
11036 // <child_source>: a #GSource previously passed to g_source_add_child_source().
11037 void remove_child_source()(Source* child_source) {
11038 g_source_remove_child_source(&this, child_source);
11041 // Removes a file descriptor from the set of file descriptors polled for
11042 // this source.
11043 // <fd>: a #GPollFD structure previously passed to g_source_add_poll().
11044 void remove_poll()(PollFD* fd) {
11045 g_source_remove_poll(&this, fd);
11048 // Sets the callback function for a source. The callback for a source is
11049 // called from the source's dispatch function.
11051 // The exact type of @func depends on the type of source; ie. you
11052 // should not count on @func being called with @data as its first
11053 // parameter.
11055 // Typically, you won't use this function. Instead use functions specific
11056 // to the type of source you are using.
11057 // <func>: a callback function
11058 // <data>: the data to pass to callback function
11059 // <notify>: a function to call when @data is no longer in use, or %NULL.
11060 void set_callback()(SourceFunc func, void* data, DestroyNotify notify) {
11061 g_source_set_callback(&this, func, data, notify);
11064 // Sets the callback function storing the data as a refcounted callback
11065 // "object". This is used internally. Note that calling
11066 // g_source_set_callback_indirect() assumes
11067 // an initial reference count on @callback_data, and thus
11068 // @callback_funcs->unref will eventually be called once more
11069 // than @callback_funcs->ref.
11070 // <callback_data>: pointer to callback data "object"
11071 // <callback_funcs>: functions for reference counting @callback_data and getting the callback and data
11072 void set_callback_indirect()(void* callback_data, SourceCallbackFuncs* callback_funcs) {
11073 g_source_set_callback_indirect(&this, callback_data, callback_funcs);
11076 // Sets whether a source can be called recursively. If @can_recurse is
11077 // %TRUE, then while the source is being dispatched then this source
11078 // will be processed normally. Otherwise, all processing of this
11079 // source is blocked until the dispatch function returns.
11080 // <can_recurse>: whether recursion is allowed for this source
11081 void set_can_recurse()(int can_recurse) {
11082 g_source_set_can_recurse(&this, can_recurse);
11085 // VERSION: 2.12
11086 // Sets the source functions (can be used to override
11087 // default implementations) of an unattached source.
11088 // <funcs>: the new #GSourceFuncs
11089 void set_funcs()(SourceFuncs* funcs) {
11090 g_source_set_funcs(&this, funcs);
11093 // VERSION: 2.26
11094 // Sets a name for the source, used in debugging and profiling.
11095 // The name defaults to #NULL.
11097 // The source name should describe in a human-readable way
11098 // what the source does. For example, "X11 event queue"
11099 // or "GTK+ repaint idle handler" or whatever it is.
11101 // It is permitted to call this function multiple times, but is not
11102 // recommended due to the potential performance impact. For example,
11103 // one could change the name in the "check" function of a #GSourceFuncs
11104 // to include details like the event type in the source name.
11105 // <name>: debug name for the source
11106 void set_name()(char* name) {
11107 g_source_set_name(&this, name);
11110 // Sets the priority of a source. While the main loop is being run, a
11111 // source will be dispatched if it is ready to be dispatched and no
11112 // sources at a higher (numerically smaller) priority are ready to be
11113 // dispatched.
11114 // <priority>: the new priority.
11115 void set_priority()(int priority) {
11116 g_source_set_priority(&this, priority);
11119 // Decreases the reference count of a source by one. If the
11120 // resulting reference count is zero the source and associated
11121 // memory will be destroyed.
11122 void unref()() {
11123 g_source_unref(&this);
11126 // Removes the source with the given id from the default main context.
11127 // The id of
11128 // a #GSource is given by g_source_get_id(), or will be returned by the
11129 // functions g_source_attach(), g_idle_add(), g_idle_add_full(),
11130 // g_timeout_add(), g_timeout_add_full(), g_child_watch_add(),
11131 // g_child_watch_add_full(), g_io_add_watch(), and g_io_add_watch_full().
11133 // See also g_source_destroy(). You must use g_source_destroy() for sources
11134 // added to a non-default main context.
11135 // RETURNS: %TRUE if the source was found and removed.
11136 // <tag>: the ID of the source to remove.
11137 static int remove()(uint tag) {
11138 return g_source_remove(tag);
11141 // Removes a source from the default main loop context given the
11142 // source functions and user data. If multiple sources exist with the
11143 // same source functions and user data, only one will be destroyed.
11144 // RETURNS: %TRUE if a source was found and removed.
11145 // <funcs>: The @source_funcs passed to g_source_new()
11146 // <user_data>: the user data for the callback
11147 static int remove_by_funcs_user_data()(SourceFuncs* funcs, void* user_data) {
11148 return g_source_remove_by_funcs_user_data(funcs, user_data);
11151 // Removes a source from the default main loop context given the user
11152 // data for the callback. If multiple sources exist with the same user
11153 // data, only one will be destroyed.
11154 // RETURNS: %TRUE if a source was found and removed.
11155 // <user_data>: the user_data for the callback.
11156 static int remove_by_user_data()(void* user_data) {
11157 return g_source_remove_by_user_data(user_data);
11160 // VERSION: 2.26
11161 // Sets the name of a source using its ID.
11163 // This is a convenience utility to set source names from the return
11164 // value of g_idle_add(), g_timeout_add(), etc.
11165 // <tag>: a #GSource ID
11166 // <name>: debug name for the source
11167 static void set_name_by_id()(uint tag, char* name) {
11168 g_source_set_name_by_id(tag, name);
11172 struct SourceCallbackFuncs {
11173 extern (C) void function (void* cb_data) ref_;
11174 extern (C) void function (void* cb_data) unref;
11175 // Unintrospectable functionp: get() / ()
11176 extern (C) void function (void* cb_data, Source* source, SourceFunc* func, void** data) get;
11180 // This is just a placeholder for #GClosureMarshal,
11181 // which cannot be used here for dependency reasons.
11182 extern (C) alias void function () SourceDummyMarshal;
11185 // Specifies the type of function passed to g_timeout_add(),
11186 // g_timeout_add_full(), g_idle_add(), and g_idle_add_full().
11187 // RETURNS: %FALSE if the source should be removed
11188 // <user_data>: data passed to the function, set when the source was created with one of the above functions
11189 extern (C) alias int function (void* user_data) SourceFunc;
11192 // The <structname>GSourceFuncs</structname> struct contains a table of
11193 // functions used to handle event sources in a generic manner.
11195 // For idle sources, the prepare and check functions always return %TRUE
11196 // to indicate that the source is always ready to be processed. The prepare
11197 // function also returns a timeout value of 0 to ensure that the poll() call
11198 // doesn't block (since that would be time wasted which could have been spent
11199 // running the idle function).
11201 // For timeout sources, the prepare and check functions both return %TRUE
11202 // if the timeout interval has expired. The prepare function also returns
11203 // a timeout value to ensure that the poll() call doesn't block too long
11204 // and miss the next timeout.
11206 // For file descriptor sources, the prepare function typically returns %FALSE,
11207 // since it must wait until poll() has been called before it knows whether
11208 // any events need to be processed. It sets the returned timeout to -1 to
11209 // indicate that it doesn't mind how long the poll() call blocks. In the
11210 // check function, it tests the results of the poll() call to see if the
11211 // required condition has been met, and returns %TRUE if so.
11212 struct SourceFuncs {
11213 extern (C) int function (Source* source, int* timeout_) prepare;
11214 extern (C) int function (Source* source) check;
11215 // Unintrospectable functionp: dispatch() / ()
11216 extern (C) int function (Source* source, SourceFunc callback, void* user_data) dispatch;
11217 extern (C) void function (Source* source) finalize;
11218 private SourceFunc closure_callback;
11219 private SourceDummyMarshal closure_marshal;
11222 struct SourcePrivate {
11226 // Specifies the type of the setup function passed to g_spawn_async(),
11227 // g_spawn_sync() and g_spawn_async_with_pipes(), which can, in very
11228 // limited ways, be used to affect the child's execution.
11230 // On POSIX platforms, the function is called in the child after GLib
11231 // has performed all the setup it plans to perform, but before calling
11232 // exec(). Actions taken in this function will only affect the child,
11233 // not the parent.
11235 // On Windows, the function is called in the parent. Its usefulness on
11236 // Windows is thus questionable. In many cases executing the child setup
11237 // function in the parent can have ill effects, and you should be very
11238 // careful when porting software to Windows that uses child setup
11239 // functions.
11241 // However, even on POSIX, you are extremely limited in what you can
11242 // safely do from a #GSpawnChildSetupFunc, because any mutexes that
11243 // were held by other threads in the parent process at the time of the
11244 // fork() will still be locked in the child process, and they will
11245 // never be unlocked (since the threads that held them don't exist in
11246 // the child). POSIX allows only async-signal-safe functions (see
11247 // <citerefentry><refentrytitle>signal</refentrytitle><manvolnum>7</manvolnum></citerefentry>)
11248 // to be called in the child between fork() and exec(), which
11249 // drastically limits the usefulness of child setup functions.
11251 // In particular, it is not safe to call any function which may
11252 // call malloc(), which includes POSIX functions such as setenv().
11253 // If you need to set up the child environment differently from
11254 // the parent, you should use g_get_environ(), g_environ_setenv(),
11255 // and g_environ_unsetenv(), and then pass the complete environment
11256 // list to the <literal>g_spawn...</literal> function.
11257 // <user_data>: user data to pass to the function.
11258 extern (C) alias void function (void* user_data) SpawnChildSetupFunc;
11260 // Error codes returned by spawning processes.
11261 enum SpawnError {
11262 FORK = 0,
11263 READ = 1,
11264 CHDIR = 2,
11265 ACCES = 3,
11266 PERM = 4,
11267 _2BIG = 5,
11268 NOEXEC = 6,
11269 NAMETOOLONG = 7,
11270 NOENT = 8,
11271 NOMEM = 9,
11272 NOTDIR = 10,
11273 LOOP = 11,
11274 TXTBUSY = 12,
11275 IO = 13,
11276 NFILE = 14,
11277 MFILE = 15,
11278 INVAL = 16,
11279 ISDIR = 17,
11280 LIBBAD = 18,
11281 FAILED = 19
11283 // Flags passed to g_spawn_sync(), g_spawn_async() and g_spawn_async_with_pipes().
11284 enum SpawnFlags {
11285 LEAVE_DESCRIPTORS_OPEN = 1,
11286 DO_NOT_REAP_CHILD = 2,
11287 SEARCH_PATH = 4,
11288 STDOUT_TO_DEV_NULL = 8,
11289 STDERR_TO_DEV_NULL = 16,
11290 CHILD_INHERITS_STDIN = 32,
11291 FILE_AND_ARGV_ZERO = 64
11294 // A type corresponding to the appropriate struct type for the stat
11295 // system call, depending on the platform and/or compiler being used.
11297 // See g_stat() for more information.
11298 struct StatBuf {
11301 // The GString struct contains the public fields of a GString.
11302 struct String {
11303 char* str;
11304 size_t len, allocated_len;
11307 // Adds a string onto the end of a #GString, expanding
11308 // it if necessary.
11309 // RETURNS: @string
11310 // <val>: the string to append onto the end of @string
11311 String* /*new*/ append()(char* val) {
11312 return g_string_append(&this, val);
11315 // Adds a byte onto the end of a #GString, expanding
11316 // it if necessary.
11317 // RETURNS: @string
11318 // <c>: the byte to append onto the end of @string
11319 String* /*new*/ append_c()(char c) {
11320 return g_string_append_c(&this, c);
11323 // Appends @len bytes of @val to @string. Because @len is
11324 // provided, @val may contain embedded nuls and need not
11325 // be nul-terminated.
11327 // Since this function does not stop at nul bytes, it is
11328 // the caller's responsibility to ensure that @val has at
11329 // least @len addressable bytes.
11330 // RETURNS: @string
11331 // <val>: bytes to append
11332 // <len>: number of bytes of @val to use
11333 String* /*new*/ append_len()(char* val, ssize_t len) {
11334 return g_string_append_len(&this, val, len);
11337 // Unintrospectable method: append_printf() / g_string_append_printf()
11338 // Appends a formatted string onto the end of a #GString.
11339 // This function is similar to g_string_printf() except
11340 // that the text is appended to the #GString.
11341 // <format>: the string format. See the printf() documentation
11342 /+ Not available -- variadic methods unsupported - use the C function directly.
11343 alias g_string_append_printf append_printf; // Variadic
11346 // Converts a Unicode character into UTF-8, and appends it
11347 // to the string.
11348 // RETURNS: @string
11349 // <wc>: a Unicode character
11350 String* /*new*/ append_unichar()(dchar wc) {
11351 return g_string_append_unichar(&this, wc);
11354 // VERSION: 2.16
11355 // Appends @unescaped to @string, escaped any characters that
11356 // are reserved in URIs using URI-style escape sequences.
11357 // RETURNS: @string
11358 // <unescaped>: a string
11359 // <reserved_chars_allowed>: a string of reserved characters allowed to be used, or %NULL
11360 // <allow_utf8>: set %TRUE if the escaped string may include UTF8 characters
11361 String* /*new*/ append_uri_escaped()(char* unescaped, char* reserved_chars_allowed, int allow_utf8) {
11362 return g_string_append_uri_escaped(&this, unescaped, reserved_chars_allowed, allow_utf8);
11365 // Unintrospectable method: append_vprintf() / g_string_append_vprintf()
11366 // VERSION: 2.14
11367 // Appends a formatted string onto the end of a #GString.
11368 // This function is similar to g_string_append_printf()
11369 // except that the arguments to the format string are passed
11370 // as a va_list.
11371 // <format>: the string format. See the printf() documentation
11372 // <args>: the list of arguments to insert in the output
11373 void append_vprintf()(char* format, va_list args) {
11374 g_string_append_vprintf(&this, format, args);
11377 // Converts all uppercase ASCII letters to lowercase ASCII letters.
11379 // uppercase characters converted to lowercase in place,
11380 // with semantics that exactly match g_ascii_tolower().
11381 // RETURNS: passed-in @string pointer, with all the
11382 String* /*new*/ ascii_down()() {
11383 return g_string_ascii_down(&this);
11386 // Converts all lowercase ASCII letters to uppercase ASCII letters.
11388 // lowercase characters converted to uppercase in place,
11389 // with semantics that exactly match g_ascii_toupper().
11390 // RETURNS: passed-in @string pointer, with all the
11391 String* /*new*/ ascii_up()() {
11392 return g_string_ascii_up(&this);
11395 // Copies the bytes from a string into a #GString,
11396 // destroying any previous contents. It is rather like
11397 // the standard strcpy() function, except that you do not
11398 // have to worry about having enough space to copy the string.
11399 // RETURNS: @string
11400 // <rval>: the string to copy into @string
11401 String* /*new*/ assign()(char* rval) {
11402 return g_string_assign(&this, rval);
11405 // Converts a #GString to lowercase.
11408 // Deprecated:2.2: This function uses the locale-specific
11409 // tolower() function, which is almost never the right thing.
11410 // Use g_string_ascii_down() or g_utf8_strdown() instead.
11411 // RETURNS: the #GString
11412 String* /*new*/ down()() {
11413 return g_string_down(&this);
11416 // Compares two strings for equality, returning %TRUE if they are equal.
11417 // For use with #GHashTable.
11419 // same bytes
11420 // RETURNS: %TRUE if they strings are the same length and contain the
11421 // <v2>: another #GString
11422 int equal()(String* v2) {
11423 return g_string_equal(&this, v2);
11426 // Removes @len bytes from a #GString, starting at position @pos.
11427 // The rest of the #GString is shifted down to fill the gap.
11428 // RETURNS: @string
11429 // <pos>: the position of the content to remove
11430 // <len>: the number of bytes to remove, or -1 to remove all following bytes
11431 String* /*new*/ erase()(ssize_t pos, ssize_t len) {
11432 return g_string_erase(&this, pos, len);
11435 // Frees the memory allocated for the #GString.
11436 // If @free_segment is %TRUE it also frees the character data. If
11437 // it's %FALSE, the caller gains ownership of the buffer and must
11438 // free it after use with g_free().
11440 // (i.e. %NULL if @free_segment is %TRUE)
11441 // RETURNS: the character data of @string
11442 // <free_segment>: if %TRUE, the actual character data is freed as well
11443 char* /*new*/ free()(int free_segment) {
11444 return g_string_free(&this, free_segment);
11447 // Creates a hash code for @str; for use with #GHashTable.
11448 // RETURNS: hash code for @str
11449 uint hash()() {
11450 return g_string_hash(&this);
11453 // Inserts a copy of a string into a #GString,
11454 // expanding it if necessary.
11455 // RETURNS: @string
11456 // <pos>: the position to insert the copy of the string
11457 // <val>: the string to insert
11458 String* /*new*/ insert()(ssize_t pos, char* val) {
11459 return g_string_insert(&this, pos, val);
11462 // Inserts a byte into a #GString, expanding it if necessary.
11463 // RETURNS: @string
11464 // <pos>: the position to insert the byte
11465 // <c>: the byte to insert
11466 String* /*new*/ insert_c()(ssize_t pos, char c) {
11467 return g_string_insert_c(&this, pos, c);
11470 // Inserts @len bytes of @val into @string at @pos.
11471 // Because @len is provided, @val may contain embedded
11472 // nuls and need not be nul-terminated. If @pos is -1,
11473 // bytes are inserted at the end of the string.
11475 // Since this function does not stop at nul bytes, it is
11476 // the caller's responsibility to ensure that @val has at
11477 // least @len addressable bytes.
11478 // RETURNS: @string
11479 // <pos>: position in @string where insertion should happen, or -1 for at the end
11480 // <val>: bytes to insert
11481 // <len>: number of bytes of @val to insert
11482 String* /*new*/ insert_len()(ssize_t pos, char* val, ssize_t len) {
11483 return g_string_insert_len(&this, pos, val, len);
11486 // Converts a Unicode character into UTF-8, and insert it
11487 // into the string at the given position.
11488 // RETURNS: @string
11489 // <pos>: the position at which to insert character, or -1 to append at the end of the string
11490 // <wc>: a Unicode character
11491 String* /*new*/ insert_unichar()(ssize_t pos, dchar wc) {
11492 return g_string_insert_unichar(&this, pos, wc);
11495 // VERSION: 2.14
11496 // Overwrites part of a string, lengthening it if necessary.
11497 // RETURNS: @string
11498 // <pos>: the position at which to start overwriting
11499 // <val>: the string that will overwrite the @string starting at @pos
11500 String* /*new*/ overwrite()(size_t pos, char* val) {
11501 return g_string_overwrite(&this, pos, val);
11504 // VERSION: 2.14
11505 // Overwrites part of a string, lengthening it if necessary.
11506 // This function will work with embedded nuls.
11507 // RETURNS: @string
11508 // <pos>: the position at which to start overwriting
11509 // <val>: the string that will overwrite the @string starting at @pos
11510 // <len>: the number of bytes to write from @val
11511 String* /*new*/ overwrite_len()(size_t pos, char* val, ssize_t len) {
11512 return g_string_overwrite_len(&this, pos, val, len);
11515 // Adds a string on to the start of a #GString,
11516 // expanding it if necessary.
11517 // RETURNS: @string
11518 // <val>: the string to prepend on the start of @string
11519 String* /*new*/ prepend()(char* val) {
11520 return g_string_prepend(&this, val);
11523 // Adds a byte onto the start of a #GString,
11524 // expanding it if necessary.
11525 // RETURNS: @string
11526 // <c>: the byte to prepend on the start of the #GString
11527 String* /*new*/ prepend_c()(char c) {
11528 return g_string_prepend_c(&this, c);
11531 // Prepends @len bytes of @val to @string.
11532 // Because @len is provided, @val may contain
11533 // embedded nuls and need not be nul-terminated.
11535 // Since this function does not stop at nul bytes,
11536 // it is the caller's responsibility to ensure that
11537 // @val has at least @len addressable bytes.
11538 // RETURNS: @string
11539 // <val>: bytes to prepend
11540 // <len>: number of bytes in @val to prepend
11541 String* /*new*/ prepend_len()(char* val, ssize_t len) {
11542 return g_string_prepend_len(&this, val, len);
11545 // Converts a Unicode character into UTF-8, and prepends it
11546 // to the string.
11547 // RETURNS: @string
11548 // <wc>: a Unicode character
11549 String* /*new*/ prepend_unichar()(dchar wc) {
11550 return g_string_prepend_unichar(&this, wc);
11553 // Unintrospectable method: printf() / g_string_printf()
11554 // Writes a formatted string into a #GString.
11555 // This is similar to the standard sprintf() function,
11556 // except that the #GString buffer automatically expands
11557 // to contain the results. The previous contents of the
11558 // #GString are destroyed.
11559 // <format>: the string format. See the printf() documentation
11560 /+ Not available -- variadic methods unsupported - use the C function directly.
11561 alias g_string_printf printf; // Variadic
11564 // Sets the length of a #GString. If the length is less than
11565 // the current length, the string will be truncated. If the
11566 // length is greater than the current length, the contents
11567 // of the newly added area are undefined. (However, as
11568 // always, string->str[string->len] will be a nul byte.)
11569 // RETURNS: @string
11570 // <len>: the new length
11571 String* /*new*/ set_size()(size_t len) {
11572 return g_string_set_size(&this, len);
11575 // Cuts off the end of the GString, leaving the first @len bytes.
11576 // RETURNS: @string
11577 // <len>: the new size of @string
11578 String* /*new*/ truncate()(size_t len) {
11579 return g_string_truncate(&this, len);
11582 // Converts a #GString to uppercase.
11585 // Deprecated:2.2: This function uses the locale-specific
11586 // toupper() function, which is almost never the right thing.
11587 // Use g_string_ascii_up() or g_utf8_strup() instead.
11588 // RETURNS: @string
11589 String* /*new*/ up()() {
11590 return g_string_up(&this);
11593 // Unintrospectable method: vprintf() / g_string_vprintf()
11594 // VERSION: 2.14
11595 // Writes a formatted string into a #GString.
11596 // This function is similar to g_string_printf() except that
11597 // the arguments to the format string are passed as a va_list.
11598 // <format>: the string format. See the printf() documentation
11599 // <args>: the parameters to insert into the format string
11600 void vprintf()(char* format, va_list args) {
11601 g_string_vprintf(&this, format, args);
11606 // An opaque data structure representing String Chunks.
11607 // It should only be accessed by using the following functions.
11608 struct StringChunk {
11610 // VERSION: 2.14
11611 // Frees all strings contained within the #GStringChunk.
11612 // After calling g_string_chunk_clear() it is not safe to
11613 // access any of the strings which were contained within it.
11614 void clear()() {
11615 g_string_chunk_clear(&this);
11618 // Frees all memory allocated by the #GStringChunk.
11619 // After calling g_string_chunk_free() it is not safe to
11620 // access any of the strings which were contained within it.
11621 void free()() {
11622 g_string_chunk_free(&this);
11625 // Adds a copy of @string to the #GStringChunk.
11626 // It returns a pointer to the new copy of the string
11627 // in the #GStringChunk. The characters in the string
11628 // can be changed, if necessary, though you should not
11629 // change anything after the end of the string.
11631 // Unlike g_string_chunk_insert_const(), this function
11632 // does not check for duplicates. Also strings added
11633 // with g_string_chunk_insert() will not be searched
11634 // by g_string_chunk_insert_const() when looking for
11635 // duplicates.
11637 // the #GStringChunk
11638 // RETURNS: a pointer to the copy of @string within
11639 // <string>: the string to add
11640 char* /*new*/ insert()(char* string_) {
11641 return g_string_chunk_insert(&this, string_);
11644 // Adds a copy of @string to the #GStringChunk, unless the same
11645 // string has already been added to the #GStringChunk with
11646 // g_string_chunk_insert_const().
11648 // This function is useful if you need to copy a large number
11649 // of strings but do not want to waste space storing duplicates.
11650 // But you must remember that there may be several pointers to
11651 // the same string, and so any changes made to the strings
11652 // should be done very carefully.
11654 // Note that g_string_chunk_insert_const() will not return a
11655 // pointer to a string added with g_string_chunk_insert(), even
11656 // if they do match.
11658 // within the #GStringChunk
11659 // RETURNS: a pointer to the new or existing copy of @string
11660 // <string>: the string to add
11661 char* /*new*/ insert_const()(char* string_) {
11662 return g_string_chunk_insert_const(&this, string_);
11665 // VERSION: 2.4
11666 // Adds a copy of the first @len bytes of @string to the #GStringChunk.
11667 // The copy is nul-terminated.
11669 // Since this function does not stop at nul bytes, it is the caller's
11670 // responsibility to ensure that @string has at least @len addressable
11671 // bytes.
11673 // The characters in the returned string can be changed, if necessary,
11674 // though you should not change anything after the end of the string.
11675 // RETURNS: a pointer to the copy of @string within the #GStringChunk
11676 // <string>: bytes to insert
11677 // <len>: number of bytes of @string to insert, or -1 to insert a nul-terminated string
11678 char* /*new*/ insert_len()(char* string_, ssize_t len) {
11679 return g_string_chunk_insert_len(&this, string_, len);
11682 // Unintrospectable function: new() / g_string_chunk_new()
11683 // Creates a new #GStringChunk.
11684 // RETURNS: a new #GStringChunk
11685 // <size>: the default size of the blocks of memory which are allocated to store the strings. If a particular string is larger than this default size, a larger block of memory will be allocated for it.
11686 static StringChunk* new_()(size_t size) {
11687 return g_string_chunk_new(size);
11691 // An opaque structure representing a test case.
11692 struct TestCase {
11695 struct TestConfig {
11696 int test_initialized, test_quick, test_perf, test_verbose, test_quiet, test_undefined;
11700 // VERSION: 2.28
11701 // The type used for test case functions that take an extra pointer
11702 // argument.
11703 // <user_data>: the data provided when registering the test
11704 extern (C) alias void function (const(void)* user_data) TestDataFunc;
11707 // VERSION: 2.28
11708 // The type used for functions that operate on test fixtures. This is
11709 // used for the fixture setup and teardown functions as well as for the
11710 // testcases themselves.
11712 // @user_data is a pointer to the data that was given when registering
11713 // the test case.
11715 // @fixture will be a pointer to the area of memory allocated by the
11716 // test framework, of the size requested. If the requested size was
11717 // zero then @fixture will be equal to @user_data.
11718 // <fixture>: the test fixture
11719 // <user_data>: the data provided when registering the test
11720 extern (C) alias void function (void* fixture, const(void)* user_data) TestFixtureFunc;
11723 // VERSION: 2.28
11724 // The type used for test case functions.
11725 extern (C) alias void function () TestFunc;
11727 struct TestLogBuffer {
11728 private String* data;
11729 private GLib2.SList* msgs;
11731 // Internal function for gtester to free test log messages, no ABI guarantees provided.
11732 void free()() {
11733 g_test_log_buffer_free(&this);
11736 // Unintrospectable method: pop() / g_test_log_buffer_pop()
11737 // Internal function for gtester to retrieve test log messages, no ABI guarantees provided.
11738 TestLogMsg* pop()() {
11739 return g_test_log_buffer_pop(&this);
11741 // Internal function for gtester to decode test log messages, no ABI guarantees provided.
11742 void push()(uint n_bytes, ubyte* bytes) {
11743 g_test_log_buffer_push(&this, n_bytes, bytes);
11746 // Unintrospectable function: new() / g_test_log_buffer_new()
11747 // Internal function for gtester to decode test log messages, no ABI guarantees provided.
11748 static TestLogBuffer* new_()() {
11749 return g_test_log_buffer_new();
11754 // VERSION: 2.22
11755 // Specifies the prototype of fatal log handler functions.
11756 // RETURNS: %TRUE if the program should abort, %FALSE otherwise
11757 // <log_domain>: the log domain of the message
11758 // <log_level>: the log level of the message (including the fatal and recursion flags)
11759 // <message>: the message to process
11760 // <user_data>: user data, set in g_test_log_set_fatal_handler()
11761 extern (C) alias int function (char* log_domain, LogLevelFlags log_level, char* message, void* user_data) TestLogFatalFunc;
11763 struct TestLogMsg {
11764 TestLogType log_type;
11765 uint n_strings;
11766 char** strings;
11767 uint n_nums;
11768 c_long* nums;
11770 // Internal function for gtester to free test log messages, no ABI guarantees provided.
11771 void free()() {
11772 g_test_log_msg_free(&this);
11776 enum TestLogType {
11777 NONE = 0,
11778 ERROR = 1,
11779 START_BINARY = 2,
11780 LIST_CASE = 3,
11781 SKIP_CASE = 4,
11782 START_CASE = 5,
11783 STOP_CASE = 6,
11784 MIN_RESULT = 7,
11785 MAX_RESULT = 8,
11786 MESSAGE = 9
11788 // An opaque structure representing a test suite.
11789 struct TestSuite {
11791 // VERSION: 2.16
11792 // Adds @test_case to @suite.
11793 // <test_case>: a #GTestCase
11794 void add()(TestCase* test_case) {
11795 g_test_suite_add(&this, test_case);
11798 // VERSION: 2.16
11799 // Adds @nestedsuite to @suite.
11800 // <nestedsuite>: another #GTestSuite
11801 void add_suite()(TestSuite* nestedsuite) {
11802 g_test_suite_add_suite(&this, nestedsuite);
11807 // Test traps are guards around forked tests.
11808 // These flags determine what traps to set.
11809 enum TestTrapFlags {
11810 SILENCE_STDOUT = 128,
11811 SILENCE_STDERR = 256,
11812 INHERIT_STDIN = 512
11815 // The #GThread struct represents a running thread. This struct
11816 // is returned by g_thread_new() or g_thread_try_new(). You can
11817 // obtain the #GThread struct representing the current thead by
11818 // calling g_thread_self().
11820 // GThread is refcounted, see g_thread_ref() and g_thread_unref().
11821 // The thread represented by it holds a reference while it is running,
11822 // and g_thread_join() consumes the reference that it is given, so
11823 // it is normally not necessary to manage GThread references
11824 // explicitly.
11826 // The structure is opaque -- none of its fields may be directly
11827 // accessed.
11828 struct Thread {
11830 // Unintrospectable method: join() / g_thread_join()
11831 // Waits until @thread finishes, i.e. the function @func, as
11832 // given to g_thread_new(), returns or g_thread_exit() is called.
11833 // If @thread has already terminated, then g_thread_join()
11834 // returns immediately.
11836 // Any thread can wait for any other thread by calling g_thread_join(),
11837 // not just its 'creator'. Calling g_thread_join() from multiple threads
11838 // for the same @thread leads to undefined behaviour.
11840 // The value returned by @func or given to g_thread_exit() is
11841 // returned by this function.
11843 // g_thread_join() consumes the reference to the passed-in @thread.
11844 // This will usually cause the #GThread struct and associated resources
11845 // to be freed. Use g_thread_ref() to obtain an extra reference if you
11846 // want to keep the GThread alive beyond the g_thread_join() call.
11847 // RETURNS: the return value of the thread
11848 void* join()() {
11849 return g_thread_join(&this);
11852 // Unintrospectable method: ref() / g_thread_ref()
11853 // VERSION: 2.32
11854 // Increase the reference count on @thread.
11855 // RETURNS: a new reference to @thread
11856 Thread* ref_()() {
11857 return g_thread_ref(&this);
11860 // VERSION: 2.32
11861 // Decrease the reference count on @thread, possibly freeing all
11862 // resources associated with it.
11864 // Note that each thread holds a reference to its #GThread while
11865 // it is running, so it is safe to drop your own reference to it
11866 // if you don't need it anymore.
11867 void unref()() {
11868 g_thread_unref(&this);
11870 static Quark error_quark()() {
11871 return g_thread_error_quark();
11874 // Terminates the current thread.
11876 // If another thread is waiting for us using g_thread_join() then the
11877 // waiting thread will be woken up and get @retval as the return value
11878 // of g_thread_join().
11880 // Calling <literal>g_thread_exit (retval)</literal> is equivalent to
11881 // returning @retval from the function @func, as given to g_thread_new().
11883 // <note><para>
11884 // You must only call g_thread_exit() from a thread that you created
11885 // yourself with g_thread_new() or related APIs. You must not call
11886 // this function from a thread created with another threading library
11887 // or or from within a #GThreadPool.
11888 // </para></note>
11889 // <retval>: the return value of this thread
11890 static void exit()(void* retval) {
11891 g_thread_exit(retval);
11894 // Unintrospectable function: new() / g_thread_new()
11895 // VERSION: 2.32
11896 // This function creates a new thread. The new thread starts by invoking
11897 // @func with the argument data. The thread will run until @func returns
11898 // or until g_thread_exit() is called from the new thread. The return value
11899 // of @func becomes the return value of the thread, which can be obtained
11900 // with g_thread_join().
11902 // The @name can be useful for discriminating threads in a debugger.
11903 // Some systems restrict the length of @name to 16 bytes.
11905 // If the thread can not be created the program aborts. See
11906 // g_thread_try_new() if you want to attempt to deal with failures.
11908 // To free the struct returned by this function, use g_thread_unref().
11909 // Note that g_thread_join() implicitly unrefs the #GThread as well.
11910 // RETURNS: the new #GThread
11911 // <name>: a name for the new thread
11912 // <func>: a function to execute in the new thread
11913 // <data>: an argument to supply to the new thread
11914 static Thread* new_()(char* name, ThreadFunc func, void* data) {
11915 return g_thread_new(name, func, data);
11918 // Unintrospectable function: self() / g_thread_self()
11919 // This functions returns the #GThread corresponding to the
11920 // current thread. Note that this function does not increase
11921 // the reference count of the returned struct.
11923 // This function will return a #GThread even for threads that
11924 // were not created by GLib (i.e. those created by other threading
11925 // APIs). This may be useful for thread identification purposes
11926 // (i.e. comparisons) but you must not use GLib functions (such
11927 // as g_thread_join()) on these threads.
11928 // RETURNS: the #GThread representing the current thread
11929 static Thread* self()() {
11930 return g_thread_self();
11933 // Unintrospectable function: try_new() / g_thread_try_new()
11934 // VERSION: 2.32
11935 // This function is the same as g_thread_new() except that
11936 // it allows for the possibility of failure.
11938 // If a thread can not be created (due to resource limits),
11939 // @error is set and %NULL is returned.
11940 // RETURNS: the new #GThread, or %NULL if an error occurred
11941 // <name>: a name for the new thread
11942 // <func>: a function to execute in the new thread
11943 // <data>: an argument to supply to the new thread
11944 static Thread* try_new()(char* name, ThreadFunc func, void* data, GLib2.Error** error=null) {
11945 return g_thread_try_new(name, func, data, error);
11948 // Causes the calling thread to voluntarily relinquish the CPU, so
11949 // that other threads can run.
11951 // This function is often used as a method to make busy wait less evil.
11952 static void yield()() {
11953 g_thread_yield();
11957 // Possible errors of thread related functions.
11958 enum ThreadError {
11959 THREAD_ERROR_AGAIN = 0
11962 // Unintrospectable callback: ThreadFunc() / ()
11963 // Specifies the type of the @func functions passed to g_thread_new()
11964 // or g_thread_try_new().
11965 // RETURNS: the return value of the thread
11966 // <data>: data passed to the thread
11967 extern (C) alias void* function (void* data) ThreadFunc;
11970 // The #GThreadPool struct represents a thread pool. It has three
11971 // public read-only members, but the underlying struct is bigger,
11972 // so you must not copy this struct.
11973 struct ThreadPool {
11974 Func func;
11975 void* user_data;
11976 int exclusive;
11979 // Frees all resources allocated for @pool.
11981 // If @immediate is %TRUE, no new task is processed for @pool.
11982 // Otherwise @pool is not freed before the last task is processed.
11983 // Note however, that no thread of this pool is interrupted while
11984 // processing a task. Instead at least all still running threads
11985 // can finish their tasks before the @pool is freed.
11987 // If @wait_ is %TRUE, the functions does not return before all
11988 // tasks to be processed (dependent on @immediate, whether all
11989 // or only the currently running) are ready.
11990 // Otherwise the function returns immediately.
11992 // After calling this function @pool must not be used anymore.
11993 // <immediate>: should @pool shut down immediately?
11994 // <wait_>: should the function wait for all tasks to be finished?
11995 void free()(int immediate, int wait_) {
11996 g_thread_pool_free(&this, immediate, wait_);
11999 // Returns the maximal number of threads for @pool.
12000 // RETURNS: the maximal number of threads
12001 int get_max_threads()() {
12002 return g_thread_pool_get_max_threads(&this);
12005 // Returns the number of threads currently running in @pool.
12006 // RETURNS: the number of threads currently running
12007 uint get_num_threads()() {
12008 return g_thread_pool_get_num_threads(&this);
12011 // Inserts @data into the list of tasks to be executed by @pool.
12013 // When the number of currently running threads is lower than the
12014 // maximal allowed number of threads, a new thread is started (or
12015 // reused) with the properties given to g_thread_pool_new().
12016 // Otherwise, @data stays in the queue until a thread in this pool
12017 // finishes its previous task and processes @data.
12019 // @error can be %NULL to ignore errors, or non-%NULL to report
12020 // errors. An error can only occur when a new thread couldn't be
12021 // created. In that case @data is simply appended to the queue of
12022 // work to do.
12024 // Before version 2.32, this function did not return a success status.
12025 // RETURNS: %TRUE on success, %FALSE if an error occurred
12026 // <data>: a new task for @pool
12027 int push()(void* data, GLib2.Error** error=null) {
12028 return g_thread_pool_push(&this, data, error);
12031 // Sets the maximal allowed number of threads for @pool.
12032 // A value of -1 means that the maximal number of threads
12033 // is unlimited. If @pool is an exclusive thread pool, setting
12034 // the maximal number of threads to -1 is not allowed.
12036 // Setting @max_threads to 0 means stopping all work for @pool.
12037 // It is effectively frozen until @max_threads is set to a non-zero
12038 // value again.
12040 // A thread is never terminated while calling @func, as supplied by
12041 // g_thread_pool_new(). Instead the maximal number of threads only
12042 // has effect for the allocation of new threads in g_thread_pool_push().
12043 // A new thread is allocated, whenever the number of currently
12044 // running threads in @pool is smaller than the maximal number.
12046 // @error can be %NULL to ignore errors, or non-%NULL to report
12047 // errors. An error can only occur when a new thread couldn't be
12048 // created.
12050 // Before version 2.32, this function did not return a success status.
12051 // RETURNS: %TRUE on success, %FALSE if an error occurred
12052 // <max_threads>: a new maximal number of threads for @pool, or -1 for unlimited
12053 int set_max_threads()(int max_threads, GLib2.Error** error=null) {
12054 return g_thread_pool_set_max_threads(&this, max_threads, error);
12057 // Unintrospectable method: set_sort_function() / g_thread_pool_set_sort_function()
12058 // VERSION: 2.10
12059 // Sets the function used to sort the list of tasks. This allows the
12060 // tasks to be processed by a priority determined by @func, and not
12061 // just in the order in which they were added to the pool.
12063 // Note, if the maximum number of threads is more than 1, the order
12064 // that threads are executed cannot be guaranteed 100%. Threads are
12065 // scheduled by the operating system and are executed at random. It
12066 // cannot be assumed that threads are executed in the order they are
12067 // created.
12068 // <func>: the #GCompareDataFunc used to sort the list of tasks. This function is passed two tasks. It should return 0 if the order in which they are handled does not matter, a negative value if the first task should be processed before the second or a positive value if the second task should be processed first.
12069 // <user_data>: user data passed to @func
12070 void set_sort_function()(CompareDataFunc func, void* user_data) {
12071 g_thread_pool_set_sort_function(&this, func, user_data);
12074 // Returns the number of tasks still unprocessed in @pool.
12075 // RETURNS: the number of unprocessed tasks
12076 uint unprocessed()() {
12077 return g_thread_pool_unprocessed(&this);
12080 // VERSION: 2.10
12081 // This function will return the maximum @interval that a
12082 // thread will wait in the thread pool for new tasks before
12083 // being stopped.
12085 // If this function returns 0, threads waiting in the thread
12086 // pool for new work are not stopped.
12088 // for new tasks in the thread pool before stopping the
12089 // thread
12090 // RETURNS: the maximum @interval (milliseconds) to wait
12091 static uint get_max_idle_time()() {
12092 return g_thread_pool_get_max_idle_time();
12095 // Returns the maximal allowed number of unused threads.
12096 // RETURNS: the maximal number of unused threads
12097 static int get_max_unused_threads()() {
12098 return g_thread_pool_get_max_unused_threads();
12101 // Returns the number of currently unused threads.
12102 // RETURNS: the number of currently unused threads
12103 static uint get_num_unused_threads()() {
12104 return g_thread_pool_get_num_unused_threads();
12107 // Unintrospectable function: new() / g_thread_pool_new()
12108 // This function creates a new thread pool.
12110 // Whenever you call g_thread_pool_push(), either a new thread is
12111 // created or an unused one is reused. At most @max_threads threads
12112 // are running concurrently for this thread pool. @max_threads = -1
12113 // allows unlimited threads to be created for this thread pool. The
12114 // newly created or reused thread now executes the function @func
12115 // with the two arguments. The first one is the parameter to
12116 // g_thread_pool_push() and the second one is @user_data.
12118 // The parameter @exclusive determines whether the thread pool owns
12119 // all threads exclusive or shares them with other thread pools.
12120 // If @exclusive is %TRUE, @max_threads threads are started
12121 // immediately and they will run exclusively for this thread pool
12122 // until it is destroyed by g_thread_pool_free(). If @exclusive is
12123 // %FALSE, threads are created when needed and shared between all
12124 // non-exclusive thread pools. This implies that @max_threads may
12125 // not be -1 for exclusive thread pools.
12127 // @error can be %NULL to ignore errors, or non-%NULL to report
12128 // errors. An error can only occur when @exclusive is set to %TRUE
12129 // and not all @max_threads threads could be created.
12130 // RETURNS: the new #GThreadPool
12131 // <func>: a function to execute in the threads of the new thread pool
12132 // <user_data>: user data that is handed over to @func every time it is called
12133 // <max_threads>: the maximal number of threads to execute concurrently in the new thread pool, -1 means no limit
12134 // <exclusive>: should this thread pool be exclusive?
12135 static ThreadPool* new_()(Func func, void* user_data, int max_threads, int exclusive, GLib2.Error** error=null) {
12136 return g_thread_pool_new(func, user_data, max_threads, exclusive, error);
12139 // VERSION: 2.10
12140 // This function will set the maximum @interval that a thread
12141 // waiting in the pool for new tasks can be idle for before
12142 // being stopped. This function is similar to calling
12143 // g_thread_pool_stop_unused_threads() on a regular timeout,
12144 // except this is done on a per thread basis.
12146 // By setting @interval to 0, idle threads will not be stopped.
12148 // This function makes use of g_async_queue_timed_pop () using
12149 // @interval.
12150 // <interval>: the maximum @interval (in milliseconds) a thread can be idle
12151 static void set_max_idle_time()(uint interval) {
12152 g_thread_pool_set_max_idle_time(interval);
12155 // Sets the maximal number of unused threads to @max_threads.
12156 // If @max_threads is -1, no limit is imposed on the number
12157 // of unused threads.
12158 // <max_threads>: maximal number of unused threads
12159 static void set_max_unused_threads()(int max_threads) {
12160 g_thread_pool_set_max_unused_threads(max_threads);
12163 // Stops all currently unused threads. This does not change the
12164 // maximal number of unused threads. This function can be used to
12165 // regularly stop all unused threads e.g. from g_timeout_add().
12166 static void stop_unused_threads()() {
12167 g_thread_pool_stop_unused_threads();
12172 // Disambiguates a given time in two ways.
12174 // First, specifies if the given time is in universal or local time.
12176 // Second, if the time is in local time, specifies if it is local
12177 // standard time or local daylight time. This is important for the case
12178 // where the same local time occurs twice (during daylight savings time
12179 // transitions, for example).
12180 enum TimeType {
12181 STANDARD = 0,
12182 DAYLIGHT = 1,
12183 UNIVERSAL = 2
12186 // Represents a precise time, with seconds and microseconds.
12187 // Similar to the <structname>struct timeval</structname> returned by
12188 // the gettimeofday() UNIX system call.
12190 // GLib is attempting to unify around the use of 64bit integers to
12191 // represent microsecond-precision time. As such, this type will be
12192 // removed from a future version of GLib.
12193 struct TimeVal {
12194 c_long tv_sec, tv_usec;
12197 // Adds the given number of microseconds to @time_. @microseconds can
12198 // also be negative to decrease the value of @time_.
12199 // <microseconds>: number of microseconds to add to @time
12200 void add()(c_long microseconds) {
12201 g_time_val_add(&this, microseconds);
12204 // VERSION: 2.12
12205 // Converts @time_ into an RFC 3339 encoded string, relative to the
12206 // Coordinated Universal Time (UTC). This is one of the many formats
12207 // allowed by ISO 8601.
12209 // ISO 8601 allows a large number of date/time formats, with or without
12210 // punctuation and optional elements. The format returned by this function
12211 // is a complete date and time, with optional punctuation included, the
12212 // UTC time zone represented as "Z", and the @tv_usec part included if
12213 // and only if it is nonzero, i.e. either
12214 // "YYYY-MM-DDTHH:MM:SSZ" or "YYYY-MM-DDTHH:MM:SS.fffffZ".
12216 // This corresponds to the Internet date/time format defined by
12217 // <ulink url="https://www.ietf.org/rfc/rfc3339.txt">RFC 3339</ulink>, and
12218 // to either of the two most-precise formats defined by
12219 // <ulink url="http://www.w3.org/TR/NOTE-datetime-19980827">the W3C Note
12220 // "Date and Time Formats"</ulink>. Both of these documents are profiles of
12221 // ISO 8601.
12223 // Use g_date_time_format() or g_strdup_printf() if a different
12224 // variation of ISO 8601 format is required.
12225 // RETURNS: a newly allocated string containing an ISO 8601 date
12226 char* /*new*/ to_iso8601()() {
12227 return g_time_val_to_iso8601(&this);
12230 // VERSION: 2.12
12231 // Converts a string containing an ISO 8601 encoded date and time
12232 // to a #GTimeVal and puts it into @time_.
12234 // @iso_date must include year, month, day, hours, minutes, and
12235 // seconds. It can optionally include fractions of a second and a time
12236 // zone indicator. (In the absence of any time zone indication, the
12237 // timestamp is assumed to be in local time.)
12238 // RETURNS: %TRUE if the conversion was successful.
12239 // <iso_date>: an ISO 8601 encoded date string
12240 // <time_>: a #GTimeVal
12241 static int from_iso8601()(char* iso_date, /*out*/ TimeVal* time_) {
12242 return g_time_val_from_iso8601(iso_date, time_);
12247 // #GDateTime is an opaque structure whose members cannot be accessed
12248 // directly.
12249 struct TimeZone /* Version 2.26 */ {
12251 // VERSION: 2.26
12252 // Finds an interval within @tz that corresponds to the given @time_,
12253 // possibly adjusting @time_ if required to fit into an interval.
12254 // The meaning of @time_ depends on @type.
12256 // This function is similar to g_time_zone_find_interval(), with the
12257 // difference that it always succeeds (by making the adjustments
12258 // described below).
12260 // In any of the cases where g_time_zone_find_interval() succeeds then
12261 // this function returns the same value, without modifying @time_.
12263 // This function may, however, modify @time_ in order to deal with
12264 // non-existent times. If the non-existent local @time_ of 02:30 were
12265 // requested on March 13th 2010 in Toronto then this function would
12266 // adjust @time_ to be 03:00 and return the interval containing the
12267 // adjusted time.
12268 // RETURNS: the interval containing @time_, never -1
12269 // <type>: the #GTimeType of @time_
12270 // <time_>: a pointer to a number of seconds since January 1, 1970
12271 int adjust_time()(TimeType type, long* time_) {
12272 return g_time_zone_adjust_time(&this, type, time_);
12275 // VERSION: 2.26
12276 // Finds an the interval within @tz that corresponds to the given @time_.
12277 // The meaning of @time_ depends on @type.
12279 // If @type is %G_TIME_TYPE_UNIVERSAL then this function will always
12280 // succeed (since universal time is monotonic and continuous).
12282 // Otherwise @time_ is treated is local time. The distinction between
12283 // %G_TIME_TYPE_STANDARD and %G_TIME_TYPE_DAYLIGHT is ignored except in
12284 // the case that the given @time_ is ambiguous. In Toronto, for example,
12285 // 01:30 on November 7th 2010 occurred twice (once inside of daylight
12286 // savings time and the next, an hour later, outside of daylight savings
12287 // time). In this case, the different value of @type would result in a
12288 // different interval being returned.
12290 // It is still possible for this function to fail. In Toronto, for
12291 // example, 02:00 on March 14th 2010 does not exist (due to the leap
12292 // forward to begin daylight savings time). -1 is returned in that
12293 // case.
12294 // RETURNS: the interval containing @time_, or -1 in case of failure
12295 // <type>: the #GTimeType of @time_
12296 // <time_>: a number of seconds since January 1, 1970
12297 int find_interval()(TimeType type, long time_) {
12298 return g_time_zone_find_interval(&this, type, time_);
12301 // VERSION: 2.26
12302 // Determines the time zone abbreviation to be used during a particular
12303 // @interval of time in the time zone @tz.
12305 // For example, in Toronto this is currently "EST" during the winter
12306 // months and "EDT" during the summer months when daylight savings time
12307 // is in effect.
12308 // RETURNS: the time zone abbreviation, which belongs to @tz
12309 // <interval>: an interval within the timezone
12310 char* get_abbreviation()(int interval) {
12311 return g_time_zone_get_abbreviation(&this, interval);
12314 // VERSION: 2.26
12315 // Determines the offset to UTC in effect during a particular @interval
12316 // of time in the time zone @tz.
12318 // The offset is the number of seconds that you add to UTC time to
12319 // arrive at local time for @tz (ie: negative numbers for time zones
12320 // west of GMT, positive numbers for east).
12322 // local time in @tz
12323 // RETURNS: the number of seconds that should be added to UTC to get the
12324 // <interval>: an interval within the timezone
12325 int get_offset()(int interval) {
12326 return g_time_zone_get_offset(&this, interval);
12329 // VERSION: 2.26
12330 // Determines if daylight savings time is in effect during a particular
12331 // @interval of time in the time zone @tz.
12332 // RETURNS: %TRUE if daylight savings time is in effect
12333 // <interval>: an interval within the timezone
12334 int is_dst()(int interval) {
12335 return g_time_zone_is_dst(&this, interval);
12338 // Unintrospectable method: ref() / g_time_zone_ref()
12339 // VERSION: 2.26
12340 // Increases the reference count on @tz.
12341 // RETURNS: a new reference to @tz.
12342 TimeZone* ref_()() {
12343 return g_time_zone_ref(&this);
12346 // VERSION: 2.26
12347 // Decreases the reference count on @tz.
12348 void unref()() {
12349 g_time_zone_unref(&this);
12352 // Unintrospectable function: new() / g_time_zone_new()
12353 // VERSION: 2.26
12354 // Creates a #GTimeZone corresponding to @identifier.
12356 // @identifier can either be an RFC3339/ISO 8601 time offset or
12357 // something that would pass as a valid value for the
12358 // <varname>TZ</varname> environment variable (including %NULL).
12360 // Valid RFC3339 time offsets are <literal>"Z"</literal> (for UTC) or
12361 // <literal>"±hh:mm"</literal>. ISO 8601 additionally specifies
12362 // <literal>"±hhmm"</literal> and <literal>"±hh"</literal>.
12364 // The <varname>TZ</varname> environment variable typically corresponds
12365 // to the name of a file in the zoneinfo database, but there are many
12366 // other possibilities. Note that those other possibilities are not
12367 // currently implemented, but are planned.
12369 // g_time_zone_new_local() calls this function with the value of the
12370 // <varname>TZ</varname> environment variable. This function itself is
12371 // independent of the value of <varname>TZ</varname>, but if @identifier
12372 // is %NULL then <filename>/etc/localtime</filename> will be consulted
12373 // to discover the correct timezone.
12375 // See <ulink
12376 // url='http://tools.ietf.org/html/rfc3339#section-5.6'>RFC3339
12377 // §5.6</ulink> for a precise definition of valid RFC3339 time offsets
12378 // (the <varname>time-offset</varname> expansion) and ISO 8601 for the
12379 // full list of valid time offsets. See <ulink
12380 // url='http://www.gnu.org/s/libc/manual/html_node/TZ-Variable.html'>The
12381 // GNU C Library manual</ulink> for an explanation of the possible
12382 // values of the <varname>TZ</varname> environment variable.
12384 // You should release the return value by calling g_time_zone_unref()
12385 // when you are done with it.
12386 // RETURNS: the requested timezone
12387 // <identifier>: a timezone identifier
12388 static TimeZone* new_()(char* identifier=null) {
12389 return g_time_zone_new(identifier);
12392 // Unintrospectable function: new_local() / g_time_zone_new_local()
12393 // VERSION: 2.26
12394 // Creates a #GTimeZone corresponding to local time. The local time
12395 // zone may change between invocations to this function; for example,
12396 // if the system administrator changes it.
12398 // This is equivalent to calling g_time_zone_new() with the value of the
12399 // <varname>TZ</varname> environment variable (including the possibility
12400 // of %NULL).
12402 // You should release the return value by calling g_time_zone_unref()
12403 // when you are done with it.
12404 // RETURNS: the local timezone
12405 static TimeZone* new_local()() {
12406 return g_time_zone_new_local();
12409 // Unintrospectable function: new_utc() / g_time_zone_new_utc()
12410 // VERSION: 2.26
12411 // Creates a #GTimeZone corresponding to UTC.
12413 // This is equivalent to calling g_time_zone_new() with a value like
12414 // "Z", "UTC", "+00", etc.
12416 // You should release the return value by calling g_time_zone_unref()
12417 // when you are done with it.
12418 // RETURNS: the universal timezone
12419 static TimeZone* new_utc()() {
12420 return g_time_zone_new_utc();
12424 // Opaque datatype that records a start time.
12425 struct Timer {
12427 // VERSION: 2.4
12428 // Resumes a timer that has previously been stopped with
12429 // g_timer_stop(). g_timer_stop() must be called before using this
12430 // function.
12431 void continue_()() {
12432 g_timer_continue(&this);
12434 // Destroys a timer, freeing associated resources.
12435 void destroy()() {
12436 g_timer_destroy(&this);
12439 // If @timer has been started but not stopped, obtains the time since
12440 // the timer was started. If @timer has been stopped, obtains the
12441 // elapsed time between the time it was started and the time it was
12442 // stopped. The return value is the number of seconds elapsed,
12443 // including any fractional part. The @microseconds out parameter is
12444 // essentially useless.
12445 // <microseconds>: return location for the fractional part of seconds elapsed, in microseconds (that is, the total number of microseconds elapsed, modulo 1000000), or %NULL
12446 double elapsed()(c_ulong* microseconds) {
12447 return g_timer_elapsed(&this, microseconds);
12450 // This function is useless; it's fine to call g_timer_start() on an
12451 // already-started timer to reset the start time, so g_timer_reset()
12452 // serves no purpose.
12453 void reset()() {
12454 g_timer_reset(&this);
12457 // Marks a start time, so that future calls to g_timer_elapsed() will
12458 // report the time since g_timer_start() was called. g_timer_new()
12459 // automatically marks the start time, so no need to call
12460 // g_timer_start() immediately after creating the timer.
12461 void start()() {
12462 g_timer_start(&this);
12465 // Marks an end time, so calls to g_timer_elapsed() will return the
12466 // difference between this end time and the start time.
12467 void stop()() {
12468 g_timer_stop(&this);
12471 // Unintrospectable function: new() / g_timer_new()
12472 // Creates a new timer, and starts timing (i.e. g_timer_start() is
12473 // implicitly called for you).
12474 static Timer* new_()() {
12475 return g_timer_new();
12480 // The possible types of token returned from each
12481 // g_scanner_get_next_token() call.
12482 enum TokenType {
12483 EOF = 0,
12484 LEFT_PAREN = 40,
12485 RIGHT_PAREN = 41,
12486 LEFT_CURLY = 123,
12487 RIGHT_CURLY = 125,
12488 LEFT_BRACE = 91,
12489 RIGHT_BRACE = 93,
12490 EQUAL_SIGN = 61,
12491 COMMA = 44,
12492 NONE = 256,
12493 ERROR = 257,
12494 CHAR = 258,
12495 BINARY = 259,
12496 OCTAL = 260,
12497 INT = 261,
12498 HEX = 262,
12499 FLOAT = 263,
12500 STRING = 264,
12501 SYMBOL = 265,
12502 IDENTIFIER = 266,
12503 IDENTIFIER_NULL = 267,
12504 COMMENT_SINGLE = 268,
12505 COMMENT_MULTI = 269
12507 // A union holding the value of the token.
12508 union TokenValue {
12509 void* v_symbol;
12510 char* v_identifier;
12511 c_ulong v_binary, v_octal, v_int;
12512 ulong v_int64;
12513 double v_float;
12514 c_ulong v_hex;
12515 char* v_string, v_comment;
12516 ubyte v_char;
12517 uint v_error;
12521 // The type of functions which are used to translate user-visible
12522 // strings, for <option>--help</option> output.
12524 // The returned string is owned by GLib and must not be freed.
12525 // RETURNS: a translation of the string for the current locale.
12526 // <str>: the untranslated string
12527 // <data>: user data specified when installing the function, e.g. in g_option_group_set_translate_func()
12528 extern (C) alias char* function (char* str, void* data) TranslateFunc;
12531 // Each piece of memory that is pushed onto the stack
12532 // is cast to a <structname>GTrashStack*</structname>.
12533 struct TrashStack {
12534 TrashStack* next;
12537 // Returns the height of a #GTrashStack.
12539 // Note that execution of this function is of O(N) complexity
12540 // where N denotes the number of items on the stack.
12541 // RETURNS: the height of the stack
12542 // <stack_p>: a #GTrashStack
12543 static uint height()(TrashStack** stack_p) {
12544 return g_trash_stack_height(stack_p);
12547 // Unintrospectable function: peek() / g_trash_stack_peek()
12548 // Returns the element at the top of a #GTrashStack
12549 // which may be %NULL.
12550 // RETURNS: the element at the top of the stack
12551 // <stack_p>: a #GTrashStack
12552 static void* peek()(TrashStack** stack_p) {
12553 return g_trash_stack_peek(stack_p);
12556 // Unintrospectable function: pop() / g_trash_stack_pop()
12557 // Pops a piece of memory off a #GTrashStack.
12558 // RETURNS: the element at the top of the stack
12559 // <stack_p>: a #GTrashStack
12560 static void* pop()(TrashStack** stack_p) {
12561 return g_trash_stack_pop(stack_p);
12564 // Pushes a piece of memory onto a #GTrashStack.
12565 // <stack_p>: a #GTrashStack
12566 // <data_p>: the piece of memory to push on the stack
12567 static void push()(TrashStack** stack_p, void* data_p) {
12568 g_trash_stack_push(stack_p, data_p);
12573 // Specifies which nodes are visited during several of the tree
12574 // functions, including g_node_traverse() and g_node_find().
12575 enum TraverseFlags {
12576 LEAVES = 1,
12577 NON_LEAVES = 2,
12578 ALL = 3,
12579 MASK = 3,
12580 LEAFS = 1,
12581 NON_LEAFS = 2
12584 // Specifies the type of function passed to g_tree_traverse(). It is
12585 // passed the key and value of each node, together with the @user_data
12586 // parameter passed to g_tree_traverse(). If the function returns
12587 // %TRUE, the traversal is stopped.
12588 // <key>: a key of a #GTree node.
12589 // <value>: the value corresponding to the key.
12590 // <data>: user data passed to g_tree_traverse().
12591 extern (C) alias int function (void* key, void* value, void* data) TraverseFunc;
12594 // Specifies the type of traveral performed by g_tree_traverse(),
12595 // g_node_traverse() and g_node_find().
12596 enum TraverseType {
12597 IN_ORDER = 0,
12598 PRE_ORDER = 1,
12599 POST_ORDER = 2,
12600 LEVEL_ORDER = 3
12603 // The <structname>GTree</structname> struct is an opaque data
12604 // structure representing a <link
12605 // linkend="glib-Balanced-Binary-Trees">Balanced Binary Tree</link>. It
12606 // should be accessed only by using the following functions.
12607 struct Tree {
12609 // Removes all keys and values from the #GTree and decreases its
12610 // reference count by one. If keys and/or values are dynamically
12611 // allocated, you should either free them first or create the #GTree
12612 // using g_tree_new_full(). In the latter case the destroy functions
12613 // you supplied will be called on all keys and values before destroying
12614 // the #GTree.
12615 void destroy()() {
12616 g_tree_destroy(&this);
12619 // Unintrospectable method: foreach() / g_tree_foreach()
12620 // Calls the given function for each of the key/value pairs in the #GTree.
12621 // The function is passed the key and value of each pair, and the given
12622 // @data parameter. The tree is traversed in sorted order.
12624 // The tree may not be modified while iterating over it (you can't
12625 // add/remove items). To remove all items matching a predicate, you need
12626 // to add each item to a list in your #GTraverseFunc as you walk over
12627 // the tree, then walk the list and remove each item.
12628 // <func>: the function to call for each node visited. If this function returns %TRUE, the traversal is stopped.
12629 // <user_data>: user data to pass to the function.
12630 void foreach_()(TraverseFunc func, void* user_data) {
12631 g_tree_foreach(&this, func, user_data);
12634 // Gets the height of a #GTree.
12636 // If the #GTree contains no nodes, the height is 0.
12637 // If the #GTree contains only one root node the height is 1.
12638 // If the root node has children the height is 2, etc.
12639 // RETURNS: the height of the #GTree.
12640 int height()() {
12641 return g_tree_height(&this);
12644 // Inserts a key/value pair into a #GTree. If the given key already exists
12645 // in the #GTree its corresponding value is set to the new value. If you
12646 // supplied a value_destroy_func when creating the #GTree, the old value is
12647 // freed using that function. If you supplied a @key_destroy_func when
12648 // creating the #GTree, the passed key is freed using that function.
12650 // The tree is automatically 'balanced' as new key/value pairs are added,
12651 // so that the distance from the root to every leaf is as small as possible.
12652 // <key>: the key to insert.
12653 // <value>: the value corresponding to the key.
12654 void insert()(void* key, void* value) {
12655 g_tree_insert(&this, key, value);
12658 // Unintrospectable method: lookup() / g_tree_lookup()
12659 // Gets the value corresponding to the given key. Since a #GTree is
12660 // automatically balanced as key/value pairs are added, key lookup is very
12661 // fast.
12663 // not found.
12664 // RETURNS: the value corresponding to the key, or %NULL if the key was
12665 // <key>: the key to look up.
12666 void* lookup()(const(void)* key) {
12667 return g_tree_lookup(&this, key);
12670 // Looks up a key in the #GTree, returning the original key and the
12671 // associated value and a #gboolean which is %TRUE if the key was found. This
12672 // is useful if you need to free the memory allocated for the original key,
12673 // for example before calling g_tree_remove().
12674 // RETURNS: %TRUE if the key was found in the #GTree.
12675 // <lookup_key>: the key to look up.
12676 // <orig_key>: returns the original key.
12677 // <value>: returns the value associated with the key.
12678 int lookup_extended()(const(void)* lookup_key, void** orig_key, void** value) {
12679 return g_tree_lookup_extended(&this, lookup_key, orig_key, value);
12682 // Gets the number of nodes in a #GTree.
12683 // RETURNS: the number of nodes in the #GTree.
12684 int nnodes()() {
12685 return g_tree_nnodes(&this);
12688 // Unintrospectable method: ref() / g_tree_ref()
12689 // VERSION: 2.22
12690 // Increments the reference count of @tree by one. It is safe to call
12691 // this function from any thread.
12692 // RETURNS: the passed in #GTree.
12693 Tree* ref_()() {
12694 return g_tree_ref(&this);
12697 // Removes a key/value pair from a #GTree.
12699 // If the #GTree was created using g_tree_new_full(), the key and value
12700 // are freed using the supplied destroy functions, otherwise you have to
12701 // make sure that any dynamically allocated values are freed yourself.
12702 // If the key does not exist in the #GTree, the function does nothing.
12704 // nothing)
12705 // RETURNS: %TRUE if the key was found (prior to 2.8, this function returned
12706 // <key>: the key to remove.
12707 int remove()(const(void)* key) {
12708 return g_tree_remove(&this, key);
12711 // Inserts a new key and value into a #GTree similar to g_tree_insert().
12712 // The difference is that if the key already exists in the #GTree, it gets
12713 // replaced by the new key. If you supplied a @value_destroy_func when
12714 // creating the #GTree, the old value is freed using that function. If you
12715 // supplied a @key_destroy_func when creating the #GTree, the old key is
12716 // freed using that function.
12718 // The tree is automatically 'balanced' as new key/value pairs are added,
12719 // so that the distance from the root to every leaf is as small as possible.
12720 // <key>: the key to insert.
12721 // <value>: the value corresponding to the key.
12722 void replace()(void* key, void* value) {
12723 g_tree_replace(&this, key, value);
12726 // Unintrospectable method: search() / g_tree_search()
12727 // Searches a #GTree using @search_func.
12729 // The @search_func is called with a pointer to the key of a key/value
12730 // pair in the tree, and the passed in @user_data. If @search_func returns
12731 // 0 for a key/value pair, then the corresponding value is returned as
12732 // the result of g_tree_search(). If @search_func returns -1, searching
12733 // will proceed among the key/value pairs that have a smaller key; if
12734 // @search_func returns 1, searching will proceed among the key/value
12735 // pairs that have a larger key.
12737 // the key was not found.
12738 // RETURNS: the value corresponding to the found key, or %NULL if
12739 // <search_func>: a function used to search the #GTree
12740 // <user_data>: the data passed as the second argument to @search_func
12741 void* search()(CompareFunc search_func, const(void)* user_data) {
12742 return g_tree_search(&this, search_func, user_data);
12745 // Removes a key and its associated value from a #GTree without calling
12746 // the key and value destroy functions.
12748 // If the key does not exist in the #GTree, the function does nothing.
12750 // nothing)
12751 // RETURNS: %TRUE if the key was found (prior to 2.8, this function returned
12752 // <key>: the key to remove.
12753 int steal()(const(void)* key) {
12754 return g_tree_steal(&this, key);
12757 // Unintrospectable method: traverse() / g_tree_traverse()
12758 // Calls the given function for each node in the #GTree.
12760 // Deprecated:2.2: The order of a balanced tree is somewhat arbitrary. If you
12761 // just want to visit all nodes in sorted order, use g_tree_foreach()
12762 // instead. If you really need to visit nodes in a different order, consider
12763 // using an <link linkend="glib-N-ary-Trees">N-ary Tree</link>.
12764 // <traverse_func>: the function to call for each node visited. If this function returns %TRUE, the traversal is stopped.
12765 // <traverse_type>: the order in which nodes are visited, one of %G_IN_ORDER, %G_PRE_ORDER and %G_POST_ORDER.
12766 // <user_data>: user data to pass to the function.
12767 void traverse()(TraverseFunc traverse_func, TraverseType traverse_type, void* user_data) {
12768 g_tree_traverse(&this, traverse_func, traverse_type, user_data);
12771 // VERSION: 2.22
12772 // Decrements the reference count of @tree by one. If the reference count
12773 // drops to 0, all keys and values will be destroyed (if destroy
12774 // functions were specified) and all memory allocated by @tree will be
12775 // released.
12777 // It is safe to call this function from any thread.
12778 void unref()() {
12779 g_tree_unref(&this);
12782 // Unintrospectable function: new() / g_tree_new()
12783 // Creates a new #GTree.
12784 // RETURNS: a new #GTree.
12785 // <key_compare_func>: the function used to order the nodes in the #GTree. It should return values similar to the standard strcmp() function - 0 if the two arguments are equal, a negative value if the first argument comes before the second, or a positive value if the first argument comes after the second.
12786 static Tree* new_()(CompareFunc key_compare_func) {
12787 return g_tree_new(key_compare_func);
12790 // Unintrospectable function: new_full() / g_tree_new_full()
12791 // Creates a new #GTree like g_tree_new() and allows to specify functions
12792 // to free the memory allocated for the key and value that get called when
12793 // removing the entry from the #GTree.
12794 // RETURNS: a new #GTree.
12795 // <key_compare_func>: qsort()-style comparison function.
12796 // <key_compare_data>: data to pass to comparison function.
12797 // <key_destroy_func>: a function to free the memory allocated for the key used when removing the entry from the #GTree or %NULL if you don't want to supply such a function.
12798 // <value_destroy_func>: a function to free the memory allocated for the value used when removing the entry from the #GTree or %NULL if you don't want to supply such a function.
12799 static Tree* new_full()(CompareDataFunc key_compare_func, void* key_compare_data, DestroyNotify key_destroy_func, DestroyNotify value_destroy_func) {
12800 return g_tree_new_full(key_compare_func, key_compare_data, key_destroy_func, value_destroy_func);
12803 // Unintrospectable function: new_with_data() / g_tree_new_with_data()
12804 // Creates a new #GTree with a comparison function that accepts user data.
12805 // See g_tree_new() for more details.
12806 // RETURNS: a new #GTree.
12807 // <key_compare_func>: qsort()-style comparison function.
12808 // <key_compare_data>: data to pass to comparison function.
12809 static Tree* new_with_data()(CompareDataFunc key_compare_func, void* key_compare_data) {
12810 return g_tree_new_with_data(key_compare_func, key_compare_data);
12814 enum int UNICHAR_MAX_DECOMPOSITION_LENGTH = 18;
12815 enum URI_RESERVED_CHARS_GENERIC_DELIMITERS = ":/?#[]@";
12816 enum URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS = "!$&'()*+,;=";
12817 enum int USEC_PER_SEC = 1000000;
12819 // These are the possible line break classifications.
12821 // The five Hangul types were added in Unicode 4.1, so, has been
12822 // introduced in GLib 2.10. Note that new types may be added in the future.
12823 // Applications should be ready to handle unknown values.
12824 // They may be regarded as %G_UNICODE_BREAK_UNKNOWN.
12826 // See <ulink url="http://www.unicode.org/unicode/reports/tr14/">http://www.unicode.org/unicode/reports/tr14/</ulink>.
12827 enum UnicodeBreakType {
12828 MANDATORY = 0,
12829 CARRIAGE_RETURN = 1,
12830 LINE_FEED = 2,
12831 COMBINING_MARK = 3,
12832 SURROGATE = 4,
12833 ZERO_WIDTH_SPACE = 5,
12834 INSEPARABLE = 6,
12835 NON_BREAKING_GLUE = 7,
12836 CONTINGENT = 8,
12837 SPACE = 9,
12838 AFTER = 10,
12839 BEFORE = 11,
12840 BEFORE_AND_AFTER = 12,
12841 HYPHEN = 13,
12842 NON_STARTER = 14,
12843 OPEN_PUNCTUATION = 15,
12844 CLOSE_PUNCTUATION = 16,
12845 QUOTATION = 17,
12846 EXCLAMATION = 18,
12847 IDEOGRAPHIC = 19,
12848 NUMERIC = 20,
12849 INFIX_SEPARATOR = 21,
12850 SYMBOL = 22,
12851 ALPHABETIC = 23,
12852 PREFIX = 24,
12853 POSTFIX = 25,
12854 COMPLEX_CONTEXT = 26,
12855 AMBIGUOUS = 27,
12856 UNKNOWN = 28,
12857 NEXT_LINE = 29,
12858 WORD_JOINER = 30,
12859 HANGUL_L_JAMO = 31,
12860 HANGUL_V_JAMO = 32,
12861 HANGUL_T_JAMO = 33,
12862 HANGUL_LV_SYLLABLE = 34,
12863 HANGUL_LVT_SYLLABLE = 35,
12864 CLOSE_PARANTHESIS = 36
12867 // The #GUnicodeScript enumeration identifies different writing
12868 // systems. The values correspond to the names as defined in the
12869 // Unicode standard. The enumeration has been added in GLib 2.14,
12870 // and is interchangeable with #PangoScript.
12872 // Note that new types may be added in the future. Applications
12873 // should be ready to handle unknown values.
12874 // See <ulink
12875 // url="http://www.unicode.org/reports/tr24/">Unicode Standard Annex
12876 // #24: Script names</ulink>.
12877 enum UnicodeScript {
12878 INVALID_CODE = -1,
12879 COMMON = 0,
12880 INHERITED = 1,
12881 ARABIC = 2,
12882 ARMENIAN = 3,
12883 BENGALI = 4,
12884 BOPOMOFO = 5,
12885 CHEROKEE = 6,
12886 COPTIC = 7,
12887 CYRILLIC = 8,
12888 DESERET = 9,
12889 DEVANAGARI = 10,
12890 ETHIOPIC = 11,
12891 GEORGIAN = 12,
12892 GOTHIC = 13,
12893 GREEK = 14,
12894 GUJARATI = 15,
12895 GURMUKHI = 16,
12896 HAN = 17,
12897 HANGUL = 18,
12898 HEBREW = 19,
12899 HIRAGANA = 20,
12900 KANNADA = 21,
12901 KATAKANA = 22,
12902 KHMER = 23,
12903 LAO = 24,
12904 LATIN = 25,
12905 MALAYALAM = 26,
12906 MONGOLIAN = 27,
12907 MYANMAR = 28,
12908 OGHAM = 29,
12909 OLD_ITALIC = 30,
12910 ORIYA = 31,
12911 RUNIC = 32,
12912 SINHALA = 33,
12913 SYRIAC = 34,
12914 TAMIL = 35,
12915 TELUGU = 36,
12916 THAANA = 37,
12917 THAI = 38,
12918 TIBETAN = 39,
12919 CANADIAN_ABORIGINAL = 40,
12920 YI = 41,
12921 TAGALOG = 42,
12922 HANUNOO = 43,
12923 BUHID = 44,
12924 TAGBANWA = 45,
12925 BRAILLE = 46,
12926 CYPRIOT = 47,
12927 LIMBU = 48,
12928 OSMANYA = 49,
12929 SHAVIAN = 50,
12930 LINEAR_B = 51,
12931 TAI_LE = 52,
12932 UGARITIC = 53,
12933 NEW_TAI_LUE = 54,
12934 BUGINESE = 55,
12935 GLAGOLITIC = 56,
12936 TIFINAGH = 57,
12937 SYLOTI_NAGRI = 58,
12938 OLD_PERSIAN = 59,
12939 KHAROSHTHI = 60,
12940 UNKNOWN = 61,
12941 BALINESE = 62,
12942 CUNEIFORM = 63,
12943 PHOENICIAN = 64,
12944 PHAGS_PA = 65,
12945 NKO = 66,
12946 KAYAH_LI = 67,
12947 LEPCHA = 68,
12948 REJANG = 69,
12949 SUNDANESE = 70,
12950 SAURASHTRA = 71,
12951 CHAM = 72,
12952 OL_CHIKI = 73,
12953 VAI = 74,
12954 CARIAN = 75,
12955 LYCIAN = 76,
12956 LYDIAN = 77,
12957 AVESTAN = 78,
12958 BAMUM = 79,
12959 EGYPTIAN_HIEROGLYPHS = 80,
12960 IMPERIAL_ARAMAIC = 81,
12961 INSCRIPTIONAL_PAHLAVI = 82,
12962 INSCRIPTIONAL_PARTHIAN = 83,
12963 JAVANESE = 84,
12964 KAITHI = 85,
12965 LISU = 86,
12966 MEETEI_MAYEK = 87,
12967 OLD_SOUTH_ARABIAN = 88,
12968 OLD_TURKIC = 89,
12969 SAMARITAN = 90,
12970 TAI_THAM = 91,
12971 TAI_VIET = 92,
12972 BATAK = 93,
12973 BRAHMI = 94,
12974 MANDAIC = 95
12977 // These are the possible character classifications from the
12978 // Unicode specification.
12979 // See <ulink url="http://www.unicode.org/Public/UNIDATA/UnicodeData.html">http://www.unicode.org/Public/UNIDATA/UnicodeData.html</ulink>.
12980 enum UnicodeType {
12981 CONTROL = 0,
12982 FORMAT = 1,
12983 UNASSIGNED = 2,
12984 PRIVATE_USE = 3,
12985 SURROGATE = 4,
12986 LOWERCASE_LETTER = 5,
12987 MODIFIER_LETTER = 6,
12988 OTHER_LETTER = 7,
12989 TITLECASE_LETTER = 8,
12990 UPPERCASE_LETTER = 9,
12991 SPACING_MARK = 10,
12992 ENCLOSING_MARK = 11,
12993 NON_SPACING_MARK = 12,
12994 DECIMAL_NUMBER = 13,
12995 LETTER_NUMBER = 14,
12996 OTHER_NUMBER = 15,
12997 CONNECT_PUNCTUATION = 16,
12998 DASH_PUNCTUATION = 17,
12999 CLOSE_PUNCTUATION = 18,
13000 FINAL_PUNCTUATION = 19,
13001 INITIAL_PUNCTUATION = 20,
13002 OTHER_PUNCTUATION = 21,
13003 OPEN_PUNCTUATION = 22,
13004 CURRENCY_SYMBOL = 23,
13005 MODIFIER_SYMBOL = 24,
13006 MATH_SYMBOL = 25,
13007 OTHER_SYMBOL = 26,
13008 LINE_SEPARATOR = 27,
13009 PARAGRAPH_SEPARATOR = 28,
13010 SPACE_SEPARATOR = 29
13013 // These are logical ids for special directories which are defined
13014 // depending on the platform used. You should use g_get_user_special_dir()
13015 // to retrieve the full path associated to the logical id.
13017 // The #GUserDirectory enumeration can be extended at later date. Not
13018 // every platform has a directory for every logical id in this
13019 // enumeration.
13020 enum UserDirectory /* Version 2.14 */ {
13021 DIRECTORY_DESKTOP = 0,
13022 DIRECTORY_DOCUMENTS = 1,
13023 DIRECTORY_DOWNLOAD = 2,
13024 DIRECTORY_MUSIC = 3,
13025 DIRECTORY_PICTURES = 4,
13026 DIRECTORY_PUBLIC_SHARE = 5,
13027 DIRECTORY_TEMPLATES = 6,
13028 DIRECTORY_VIDEOS = 7,
13029 N_DIRECTORIES = 8
13032 // #GVariant is a variant datatype; it stores a value along with
13033 // information about the type of that value. The range of possible
13034 // values is determined by the type. The type system used by #GVariant
13035 // is #GVariantType.
13037 // #GVariant instances always have a type and a value (which are given
13038 // at construction time). The type and value of a #GVariant instance
13039 // can never change other than by the #GVariant itself being
13040 // destroyed. A #GVariant cannot contain a pointer.
13042 // #GVariant is reference counted using g_variant_ref() and
13043 // g_variant_unref(). #GVariant also has floating reference counts --
13044 // see g_variant_ref_sink().
13046 // #GVariant is completely threadsafe. A #GVariant instance can be
13047 // concurrently accessed in any way from any number of threads without
13048 // problems.
13050 // #GVariant is heavily optimised for dealing with data in serialised
13051 // form. It works particularly well with data located in memory-mapped
13052 // files. It can perform nearly all deserialisation operations in a
13053 // small constant time, usually touching only a single memory page.
13054 // Serialised #GVariant data can also be sent over the network.
13056 // #GVariant is largely compatible with D-Bus. Almost all types of
13057 // #GVariant instances can be sent over D-Bus. See #GVariantType for
13058 // exceptions. (However, #GVariant's serialisation format is not the same
13059 // as the serialisation format of a D-Bus message body: use #GDBusMessage,
13060 // in the gio library, for those.)
13062 // For space-efficiency, the #GVariant serialisation format does not
13063 // automatically include the variant's type or endianness, which must
13064 // either be implied from context (such as knowledge that a particular
13065 // file format always contains a little-endian %G_VARIANT_TYPE_VARIANT)
13066 // or supplied out-of-band (for instance, a type and/or endianness
13067 // indicator could be placed at the beginning of a file, network message
13068 // or network stream).
13070 // A #GVariant's size is limited mainly by any lower level operating
13071 // system constraints, such as the number of bits in #gsize. For
13072 // example, it is reasonable to have a 2GB file mapped into memory
13073 // with #GMappedFile, and call g_variant_new_from_data() on it.
13075 // For convenience to C programmers, #GVariant features powerful
13076 // varargs-based value construction and destruction. This feature is
13077 // designed to be embedded in other libraries.
13079 // There is a Python-inspired text language for describing #GVariant
13080 // values. #GVariant includes a printer for this language and a parser
13081 // with type inferencing.
13083 // <refsect2>
13084 // <title>Memory Use</title>
13085 // <para>
13086 // #GVariant tries to be quite efficient with respect to memory use.
13087 // This section gives a rough idea of how much memory is used by the
13088 // current implementation. The information here is subject to change
13089 // in the future.
13090 // </para>
13091 // <para>
13092 // The memory allocated by #GVariant can be grouped into 4 broad
13093 // purposes: memory for serialised data, memory for the type
13094 // information cache, buffer management memory and memory for the
13095 // #GVariant structure itself.
13096 // </para>
13097 // <refsect3 id="gvariant-serialised-data-memory">
13098 // <title>Serialised Data Memory</title>
13099 // <para>
13100 // This is the memory that is used for storing GVariant data in
13101 // serialised form. This is what would be sent over the network or
13102 // what would end up on disk.
13103 // </para>
13104 // <para>
13105 // The amount of memory required to store a boolean is 1 byte. 16,
13106 // 32 and 64 bit integers and double precision floating point numbers
13107 // use their "natural" size. Strings (including object path and
13108 // signature strings) are stored with a nul terminator, and as such
13109 // use the length of the string plus 1 byte.
13110 // </para>
13111 // <para>
13112 // Maybe types use no space at all to represent the null value and
13113 // use the same amount of space (sometimes plus one byte) as the
13114 // equivalent non-maybe-typed value to represent the non-null case.
13115 // </para>
13116 // <para>
13117 // Arrays use the amount of space required to store each of their
13118 // members, concatenated. Additionally, if the items stored in an
13119 // array are not of a fixed-size (ie: strings, other arrays, etc)
13120 // then an additional framing offset is stored for each item. The
13121 // size of this offset is either 1, 2 or 4 bytes depending on the
13122 // overall size of the container. Additionally, extra padding bytes
13123 // are added as required for alignment of child values.
13124 // </para>
13125 // <para>
13126 // Tuples (including dictionary entries) use the amount of space
13127 // required to store each of their members, concatenated, plus one
13128 // framing offset (as per arrays) for each non-fixed-sized item in
13129 // the tuple, except for the last one. Additionally, extra padding
13130 // bytes are added as required for alignment of child values.
13131 // </para>
13132 // <para>
13133 // Variants use the same amount of space as the item inside of the
13134 // variant, plus 1 byte, plus the length of the type string for the
13135 // item inside the variant.
13136 // </para>
13137 // <para>
13138 // As an example, consider a dictionary mapping strings to variants.
13139 // In the case that the dictionary is empty, 0 bytes are required for
13140 // the serialisation.
13141 // </para>
13142 // <para>
13143 // If we add an item "width" that maps to the int32 value of 500 then
13144 // we will use 4 byte to store the int32 (so 6 for the variant
13145 // containing it) and 6 bytes for the string. The variant must be
13146 // aligned to 8 after the 6 bytes of the string, so that's 2 extra
13147 // bytes. 6 (string) + 2 (padding) + 6 (variant) is 14 bytes used
13148 // for the dictionary entry. An additional 1 byte is added to the
13149 // array as a framing offset making a total of 15 bytes.
13150 // </para>
13151 // <para>
13152 // If we add another entry, "title" that maps to a nullable string
13153 // that happens to have a value of null, then we use 0 bytes for the
13154 // null value (and 3 bytes for the variant to contain it along with
13155 // its type string) plus 6 bytes for the string. Again, we need 2
13156 // padding bytes. That makes a total of 6 + 2 + 3 = 11 bytes.
13157 // </para>
13158 // <para>
13159 // We now require extra padding between the two items in the array.
13160 // After the 14 bytes of the first item, that's 2 bytes required. We
13161 // now require 2 framing offsets for an extra two bytes. 14 + 2 + 11
13162 // + 2 = 29 bytes to encode the entire two-item dictionary.
13163 // </para>
13164 // </refsect3>
13165 // <refsect3>
13166 // <title>Type Information Cache</title>
13167 // <para>
13168 // For each GVariant type that currently exists in the program a type
13169 // information structure is kept in the type information cache. The
13170 // type information structure is required for rapid deserialisation.
13171 // </para>
13172 // <para>
13173 // Continuing with the above example, if a #GVariant exists with the
13174 // type "a{sv}" then a type information struct will exist for
13175 // "a{sv}", "{sv}", "s", and "v". Multiple uses of the same type
13176 // will share the same type information. Additionally, all
13177 // single-digit types are stored in read-only static memory and do
13178 // not contribute to the writable memory footprint of a program using
13179 // #GVariant.
13180 // </para>
13181 // <para>
13182 // Aside from the type information structures stored in read-only
13183 // memory, there are two forms of type information. One is used for
13184 // container types where there is a single element type: arrays and
13185 // maybe types. The other is used for container types where there
13186 // are multiple element types: tuples and dictionary entries.
13187 // </para>
13188 // <para>
13189 // Array type info structures are 6 * sizeof (void *), plus the
13190 // memory required to store the type string itself. This means that
13191 // on 32bit systems, the cache entry for "a{sv}" would require 30
13192 // bytes of memory (plus malloc overhead).
13193 // </para>
13194 // <para>
13195 // Tuple type info structures are 6 * sizeof (void *), plus 4 *
13196 // sizeof (void *) for each item in the tuple, plus the memory
13197 // required to store the type string itself. A 2-item tuple, for
13198 // example, would have a type information structure that consumed
13199 // writable memory in the size of 14 * sizeof (void *) (plus type
13200 // string) This means that on 32bit systems, the cache entry for
13201 // "{sv}" would require 61 bytes of memory (plus malloc overhead).
13202 // </para>
13203 // <para>
13204 // This means that in total, for our "a{sv}" example, 91 bytes of
13205 // type information would be allocated.
13206 // </para>
13207 // <para>
13208 // The type information cache, additionally, uses a #GHashTable to
13209 // store and lookup the cached items and stores a pointer to this
13210 // hash table in static storage. The hash table is freed when there
13211 // are zero items in the type cache.
13212 // </para>
13213 // <para>
13214 // Although these sizes may seem large it is important to remember
13215 // that a program will probably only have a very small number of
13216 // different types of values in it and that only one type information
13217 // structure is required for many different values of the same type.
13218 // </para>
13219 // </refsect3>
13220 // <refsect3>
13221 // <title>Buffer Management Memory</title>
13222 // <para>
13223 // #GVariant uses an internal buffer management structure to deal
13224 // with the various different possible sources of serialised data
13225 // that it uses. The buffer is responsible for ensuring that the
13226 // correct call is made when the data is no longer in use by
13227 // #GVariant. This may involve a g_free() or a g_slice_free() or
13228 // even g_mapped_file_unref().
13229 // </para>
13230 // <para>
13231 // One buffer management structure is used for each chunk of
13232 // serialised data. The size of the buffer management structure is 4
13233 // * (void *). On 32bit systems, that's 16 bytes.
13234 // </para>
13235 // </refsect3>
13236 // <refsect3>
13237 // <title>GVariant structure</title>
13238 // <para>
13239 // The size of a #GVariant structure is 6 * (void *). On 32 bit
13240 // systems, that's 24 bytes.
13241 // </para>
13242 // <para>
13243 // #GVariant structures only exist if they are explicitly created
13244 // with API calls. For example, if a #GVariant is constructed out of
13245 // serialised data for the example given above (with the dictionary)
13246 // then although there are 9 individual values that comprise the
13247 // entire dictionary (two keys, two values, two variants containing
13248 // the values, two dictionary entries, plus the dictionary itself),
13249 // only 1 #GVariant instance exists -- the one referring to the
13250 // dictionary.
13251 // </para>
13252 // <para>
13253 // If calls are made to start accessing the other values then
13254 // #GVariant instances will exist for those values only for as long
13255 // as they are in use (ie: until you call g_variant_unref()). The
13256 // type information is shared. The serialised data and the buffer
13257 // management structure for that serialised data is shared by the
13258 // child.
13259 // </para>
13260 // </refsect3>
13261 // <refsect3>
13262 // <title>Summary</title>
13263 // <para>
13264 // To put the entire example together, for our dictionary mapping
13265 // strings to variants (with two entries, as given above), we are
13266 // using 91 bytes of memory for type information, 29 byes of memory
13267 // for the serialised data, 16 bytes for buffer management and 24
13268 // bytes for the #GVariant instance, or a total of 160 bytes, plus
13269 // malloc overhead. If we were to use g_variant_get_child_value() to
13270 // access the two dictionary entries, we would use an additional 48
13271 // bytes. If we were to have other dictionaries of the same type, we
13272 // would use more memory for the serialised data and buffer
13273 // management for those dictionaries, but the type information would
13274 // be shared.
13275 // </para>
13276 // </refsect3>
13277 // </refsect2>
13278 struct Variant /* Version 2.24 */ {
13280 // Unintrospectable constructor: new() / g_variant_new()
13281 // VERSION: 2.24
13282 // Creates a new #GVariant instance.
13284 // Think of this function as an analogue to g_strdup_printf().
13286 // The type of the created instance and the arguments that are
13287 // expected by this function are determined by @format_string. See the
13288 // section on <link linkend='gvariant-format-strings'>GVariant Format
13289 // Strings</link>. Please note that the syntax of the format string is
13290 // very likely to be extended in the future.
13292 // The first character of the format string must not be '*' '?' '@' or
13293 // 'r'; in essence, a new #GVariant must always be constructed by this
13294 // function (and not merely passed through it unmodified).
13295 // RETURNS: a new floating #GVariant instance
13296 // <format_string>: a #GVariant format string
13297 alias g_variant_new new_; // Variadic
13299 // VERSION: 2.24
13300 // Creates a new #GVariant array from @children.
13302 // @child_type must be non-%NULL if @n_children is zero. Otherwise, the
13303 // child type is determined by inspecting the first element of the
13304 // @children array. If @child_type is non-%NULL then it must be a
13305 // definite type.
13307 // The items of the array are taken from the @children array. No entry
13308 // in the @children array may be %NULL.
13310 // All items in the array must have the same type, which must be the
13311 // same as @child_type, if given.
13313 // If the @children are floating references (see g_variant_ref_sink()), the
13314 // new instance takes ownership of them as if via g_variant_ref_sink().
13315 // RETURNS: a floating reference to a new #GVariant array
13316 // <child_type>: the element type of the new array
13317 // <children>: an array of #GVariant pointers, the children
13318 // <n_children>: the length of @children
13319 static Variant* new_array()(VariantType* child_type, Variant** children, size_t n_children) {
13320 return g_variant_new_array(child_type, children, n_children);
13323 // VERSION: 2.24
13324 // Creates a new boolean #GVariant instance -- either %TRUE or %FALSE.
13325 // RETURNS: a floating reference to a new boolean #GVariant instance
13326 // <value>: a #gboolean value
13327 static Variant* new_boolean()(int value) {
13328 return g_variant_new_boolean(value);
13331 // VERSION: 2.24
13332 // Creates a new byte #GVariant instance.
13333 // RETURNS: a floating reference to a new byte #GVariant instance
13334 // <value>: a #guint8 value
13335 static Variant* new_byte()(ubyte value) {
13336 return g_variant_new_byte(value);
13339 // VERSION: 2.26
13340 // Creates an array-of-bytes #GVariant with the contents of @string.
13341 // This function is just like g_variant_new_string() except that the
13342 // string need not be valid utf8.
13344 // The nul terminator character at the end of the string is stored in
13345 // the array.
13346 // RETURNS: a floating reference to a new bytestring #GVariant instance
13347 // <string>: a normal nul-terminated string in no particular encoding
13348 static Variant* new_bytestring()(ubyte* string_) {
13349 return g_variant_new_bytestring(string_);
13352 // VERSION: 2.26
13353 // Constructs an array of bytestring #GVariant from the given array of
13354 // strings.
13356 // If @length is -1 then @strv is %NULL-terminated.
13357 // RETURNS: a new floating #GVariant instance
13358 // <strv>: an array of strings
13359 // <length>: the length of @strv, or -1
13360 static Variant* new_bytestring_array()(char** strv, ssize_t length) {
13361 return g_variant_new_bytestring_array(strv, length);
13364 // VERSION: 2.24
13365 // Creates a new dictionary entry #GVariant. @key and @value must be
13366 // non-%NULL. @key must be a value of a basic type (ie: not a container).
13368 // If the @key or @value are floating references (see g_variant_ref_sink()),
13369 // the new instance takes ownership of them as if via g_variant_ref_sink().
13370 // RETURNS: a floating reference to a new dictionary entry #GVariant
13371 // <key>: a basic #GVariant, the key
13372 // <value>: a #GVariant, the value
13373 static Variant* new_dict_entry()(Variant* key, Variant* value) {
13374 return g_variant_new_dict_entry(key, value);
13377 // VERSION: 2.24
13378 // Creates a new double #GVariant instance.
13379 // RETURNS: a floating reference to a new double #GVariant instance
13380 // <value>: a #gdouble floating point value
13381 static Variant* new_double()(double value) {
13382 return g_variant_new_double(value);
13385 // VERSION: 2.32
13386 // Provides access to the serialised data for an array of fixed-sized
13387 // items.
13389 // @value must be an array with fixed-sized elements. Numeric types are
13390 // fixed-size as are tuples containing only other fixed-sized types.
13392 // @element_size must be the size of a single element in the array. For
13393 // example, if calling this function for an array of 32 bit integers,
13394 // you might say <code>sizeof (gint32)</code>. This value isn't used
13395 // except for the purpose of a double-check that the form of the
13396 // serialised data matches the caller's expectation.
13398 // @n_elements, which must be non-%NULL is set equal to the number of
13399 // items in the array.
13400 // RETURNS: a floating reference to a new array #GVariant instance
13401 // <element_type>: the #GVariantType of each element
13402 // <elements>: a pointer to the fixed array of contiguous elements
13403 // <n_elements>: the number of elements
13404 // <element_size>: the size of each element
13405 static Variant* new_fixed_array()(VariantType* element_type, const(void)* elements, size_t n_elements, size_t element_size) {
13406 return g_variant_new_fixed_array(element_type, elements, n_elements, element_size);
13409 // VERSION: 2.24
13410 // Creates a new #GVariant instance from serialised data.
13412 // @type is the type of #GVariant instance that will be constructed.
13413 // The interpretation of @data depends on knowing the type.
13415 // @data is not modified by this function and must remain valid with an
13416 // unchanging value until such a time as @notify is called with
13417 // @user_data. If the contents of @data change before that time then
13418 // the result is undefined.
13420 // If @data is trusted to be serialised data in normal form then
13421 // @trusted should be %TRUE. This applies to serialised data created
13422 // within this process or read from a trusted location on the disk (such
13423 // as a file installed in /usr/lib alongside your application). You
13424 // should set trusted to %FALSE if @data is read from the network, a
13425 // file in the user's home directory, etc.
13427 // If @data was not stored in this machine's native endianness, any multi-byte
13428 // numeric values in the returned variant will also be in non-native
13429 // endianness. g_variant_byteswap() can be used to recover the original values.
13431 // @notify will be called with @user_data when @data is no longer
13432 // needed. The exact time of this call is unspecified and might even be
13433 // before this function returns.
13434 // RETURNS: a new floating #GVariant of type @type
13435 // <type>: a definite #GVariantType
13436 // <data>: the serialised data
13437 // <size>: the size of @data
13438 // <trusted>: %TRUE if @data is definitely in normal form
13439 // <notify>: function to call when @data is no longer needed
13440 // <user_data>: data for @notify
13441 static Variant* new_from_data()(VariantType* type, const(ubyte)* data, size_t size, int trusted, DestroyNotify notify, void* user_data) {
13442 return g_variant_new_from_data(type, data, size, trusted, notify, user_data);
13445 // VERSION: 2.24
13446 // Creates a new handle #GVariant instance.
13448 // By convention, handles are indexes into an array of file descriptors
13449 // that are sent alongside a D-Bus message. If you're not interacting
13450 // with D-Bus, you probably don't need them.
13451 // RETURNS: a floating reference to a new handle #GVariant instance
13452 // <value>: a #gint32 value
13453 static Variant* new_handle()(int value) {
13454 return g_variant_new_handle(value);
13457 // VERSION: 2.24
13458 // Creates a new int16 #GVariant instance.
13459 // RETURNS: a floating reference to a new int16 #GVariant instance
13460 // <value>: a #gint16 value
13461 static Variant* new_int16()(short value) {
13462 return g_variant_new_int16(value);
13465 // VERSION: 2.24
13466 // Creates a new int32 #GVariant instance.
13467 // RETURNS: a floating reference to a new int32 #GVariant instance
13468 // <value>: a #gint32 value
13469 static Variant* new_int32()(int value) {
13470 return g_variant_new_int32(value);
13473 // VERSION: 2.24
13474 // Creates a new int64 #GVariant instance.
13475 // RETURNS: a floating reference to a new int64 #GVariant instance
13476 // <value>: a #gint64 value
13477 static Variant* new_int64()(long value) {
13478 return g_variant_new_int64(value);
13481 // VERSION: 2.24
13482 // Depending on if @child is %NULL, either wraps @child inside of a
13483 // maybe container or creates a Nothing instance for the given @type.
13485 // At least one of @child_type and @child must be non-%NULL.
13486 // If @child_type is non-%NULL then it must be a definite type.
13487 // If they are both non-%NULL then @child_type must be the type
13488 // of @child.
13490 // If @child is a floating reference (see g_variant_ref_sink()), the new
13491 // instance takes ownership of @child.
13492 // RETURNS: a floating reference to a new #GVariant maybe instance
13493 // <child_type>: the #GVariantType of the child, or %NULL
13494 // <child>: the child value, or %NULL
13495 static Variant* new_maybe()(VariantType* child_type=null, Variant* child=null) {
13496 return g_variant_new_maybe(child_type, child);
13499 // VERSION: 2.24
13500 // Creates a D-Bus object path #GVariant with the contents of @string.
13501 // @string must be a valid D-Bus object path. Use
13502 // g_variant_is_object_path() if you're not sure.
13503 // RETURNS: a floating reference to a new object path #GVariant instance
13504 // <object_path>: a normal C nul-terminated string
13505 static Variant* new_object_path()(char* object_path) {
13506 return g_variant_new_object_path(object_path);
13509 // VERSION: 2.30
13510 // Constructs an array of object paths #GVariant from the given array of
13511 // strings.
13513 // Each string must be a valid #GVariant object path; see
13514 // g_variant_is_object_path().
13516 // If @length is -1 then @strv is %NULL-terminated.
13517 // RETURNS: a new floating #GVariant instance
13518 // <strv>: an array of strings
13519 // <length>: the length of @strv, or -1
13520 static Variant* new_objv()(char** strv, ssize_t length) {
13521 return g_variant_new_objv(strv, length);
13524 // Unintrospectable constructor: new_parsed() / g_variant_new_parsed()
13525 // Parses @format and returns the result.
13527 // point that a value may appear in the text, a '%' character followed
13528 // by a GVariant format string (as per g_variant_new()) may appear. In
13529 // that case, the same arguments are collected from the argument list as
13530 // g_variant_new() would have collected.
13532 // Consider this simple example:
13534 // <informalexample><programlisting>
13535 // g_variant_new_parsed ("[('one', 1), ('two', %i), (%s, 3)]", 2, "three");
13536 // </programlisting></informalexample>
13538 // In the example, the variable argument parameters are collected and
13539 // filled in as if they were part of the original string to produce the
13540 // result of <code>[('one', 1), ('two', 2), ('three', 3)]</code>.
13542 // This function is intended only to be used with @format as a string
13543 // literal. Any parse error is fatal to the calling process. If you
13544 // want to parse data from untrusted sources, use g_variant_parse().
13546 // You may not use this function to return, unmodified, a single
13547 // #GVariant pointer from the argument list. ie: @format may not solely
13548 // be anything along the lines of "%*", "%?", "\%r", or anything starting
13549 // with "%@".
13550 // RETURNS: a new floating #GVariant instance
13551 // <format>: a text format #GVariant
13552 alias g_variant_new_parsed new_parsed; // Variadic
13554 // Unintrospectable constructor: new_parsed_va() / g_variant_new_parsed_va()
13555 // Parses @format and returns the result.
13557 // This is the version of g_variant_new_parsed() intended to be used
13558 // from libraries.
13560 // The return value will be floating if it was a newly created GVariant
13561 // instance. In the case that @format simply specified the collection
13562 // of a #GVariant pointer (eg: @format was "%*") then the collected
13563 // #GVariant pointer will be returned unmodified, without adding any
13564 // additional references.
13566 // In order to behave correctly in all cases it is necessary for the
13567 // calling function to g_variant_ref_sink() the return result before
13568 // returning control to the user that originally provided the pointer.
13569 // At this point, the caller will have their own full reference to the
13570 // result. This can also be done by adding the result to a container,
13571 // or by passing it to another g_variant_new() call.
13572 // RETURNS: a new, usually floating, #GVariant
13573 // <format>: a text format #GVariant
13574 // <app>: a pointer to a #va_list
13575 static Variant* /*new*/ new_parsed_va()(char* format, va_list* app) {
13576 return g_variant_new_parsed_va(format, app);
13579 // VERSION: 2.24
13580 // Creates a D-Bus type signature #GVariant with the contents of
13581 // @string. @string must be a valid D-Bus type signature. Use
13582 // g_variant_is_signature() if you're not sure.
13583 // RETURNS: a floating reference to a new signature #GVariant instance
13584 // <signature>: a normal C nul-terminated string
13585 static Variant* new_signature()(char* signature) {
13586 return g_variant_new_signature(signature);
13589 // VERSION: 2.24
13590 // Creates a string #GVariant with the contents of @string.
13592 // @string must be valid utf8.
13593 // RETURNS: a floating reference to a new string #GVariant instance
13594 // <string>: a normal utf8 nul-terminated string
13595 static Variant* new_string()(char* string_) {
13596 return g_variant_new_string(string_);
13599 // VERSION: 2.24
13600 // Constructs an array of strings #GVariant from the given array of
13601 // strings.
13603 // If @length is -1 then @strv is %NULL-terminated.
13604 // RETURNS: a new floating #GVariant instance
13605 // <strv>: an array of strings
13606 // <length>: the length of @strv, or -1
13607 static Variant* new_strv()(char** strv, ssize_t length) {
13608 return g_variant_new_strv(strv, length);
13611 // VERSION: 2.24
13612 // Creates a new tuple #GVariant out of the items in @children. The
13613 // type is determined from the types of @children. No entry in the
13614 // @children array may be %NULL.
13616 // If @n_children is 0 then the unit tuple is constructed.
13618 // If the @children are floating references (see g_variant_ref_sink()), the
13619 // new instance takes ownership of them as if via g_variant_ref_sink().
13620 // RETURNS: a floating reference to a new #GVariant tuple
13621 // <children>: the items to make the tuple out of
13622 // <n_children>: the length of @children
13623 static Variant* new_tuple()(Variant** children, size_t n_children) {
13624 return g_variant_new_tuple(children, n_children);
13627 // VERSION: 2.24
13628 // Creates a new uint16 #GVariant instance.
13629 // RETURNS: a floating reference to a new uint16 #GVariant instance
13630 // <value>: a #guint16 value
13631 static Variant* new_uint16()(ushort value) {
13632 return g_variant_new_uint16(value);
13635 // VERSION: 2.24
13636 // Creates a new uint32 #GVariant instance.
13637 // RETURNS: a floating reference to a new uint32 #GVariant instance
13638 // <value>: a #guint32 value
13639 static Variant* new_uint32()(uint value) {
13640 return g_variant_new_uint32(value);
13643 // VERSION: 2.24
13644 // Creates a new uint64 #GVariant instance.
13645 // RETURNS: a floating reference to a new uint64 #GVariant instance
13646 // <value>: a #guint64 value
13647 static Variant* new_uint64()(ulong value) {
13648 return g_variant_new_uint64(value);
13651 // Unintrospectable constructor: new_va() / g_variant_new_va()
13652 // VERSION: 2.24
13653 // This function is intended to be used by libraries based on
13654 // #GVariant that want to provide g_variant_new()-like functionality
13655 // to their users.
13657 // The API is more general than g_variant_new() to allow a wider range
13658 // of possible uses.
13660 // @format_string must still point to a valid format string, but it only
13661 // needs to be nul-terminated if @endptr is %NULL. If @endptr is
13662 // non-%NULL then it is updated to point to the first character past the
13663 // end of the format string.
13665 // @app is a pointer to a #va_list. The arguments, according to
13666 // @format_string, are collected from this #va_list and the list is left
13667 // pointing to the argument following the last.
13669 // These two generalisations allow mixing of multiple calls to
13670 // g_variant_new_va() and g_variant_get_va() within a single actual
13671 // varargs call by the user.
13673 // The return value will be floating if it was a newly created GVariant
13674 // instance (for example, if the format string was "(ii)"). In the case
13675 // that the format_string was '*', '?', 'r', or a format starting with
13676 // '@' then the collected #GVariant pointer will be returned unmodified,
13677 // without adding any additional references.
13679 // In order to behave correctly in all cases it is necessary for the
13680 // calling function to g_variant_ref_sink() the return result before
13681 // returning control to the user that originally provided the pointer.
13682 // At this point, the caller will have their own full reference to the
13683 // result. This can also be done by adding the result to a container,
13684 // or by passing it to another g_variant_new() call.
13685 // RETURNS: a new, usually floating, #GVariant
13686 // <format_string>: a string that is prefixed with a format string
13687 // <endptr>: location to store the end pointer, or %NULL
13688 // <app>: a pointer to a #va_list
13689 static Variant* /*new*/ new_va()(char* format_string, char** endptr, va_list* app) {
13690 return g_variant_new_va(format_string, endptr, app);
13693 // VERSION: 2.24
13694 // Boxes @value. The result is a #GVariant instance representing a
13695 // variant containing the original value.
13697 // If @child is a floating reference (see g_variant_ref_sink()), the new
13698 // instance takes ownership of @child.
13699 // RETURNS: a floating reference to a new variant #GVariant instance
13700 // <value>: a #GVariant instance
13701 static Variant* new_variant()(Variant* value) {
13702 return g_variant_new_variant(value);
13705 // VERSION: 2.24
13706 // Performs a byteswapping operation on the contents of @value. The
13707 // result is that all multi-byte numeric data contained in @value is
13708 // byteswapped. That includes 16, 32, and 64bit signed and unsigned
13709 // integers as well as file handles and double precision floating point
13710 // values.
13712 // This function is an identity mapping on any value that does not
13713 // contain multi-byte numeric data. That include strings, booleans,
13714 // bytes and containers containing only these things (recursively).
13716 // The returned value is always in normal form and is marked as trusted.
13717 // RETURNS: the byteswapped form of @value
13718 Variant* /*new*/ byteswap()() {
13719 return g_variant_byteswap(&this);
13722 // VERSION: 2.24
13723 // Classifies @value according to its top-level type.
13724 // RETURNS: the #GVariantClass of @value
13725 VariantClass classify()() {
13726 return g_variant_classify(&this);
13729 // VERSION: 2.26
13730 // Compares @one and @two.
13732 // The types of @one and @two are #gconstpointer only to allow use of
13733 // this function with #GTree, #GPtrArray, etc. They must each be a
13734 // #GVariant.
13736 // Comparison is only defined for basic types (ie: booleans, numbers,
13737 // strings). For booleans, %FALSE is less than %TRUE. Numbers are
13738 // ordered in the usual way. Strings are in ASCII lexographical order.
13740 // It is a programmer error to attempt to compare container values or
13741 // two values that have types that are not exactly equal. For example,
13742 // you cannot compare a 32-bit signed integer with a 32-bit unsigned
13743 // integer. Also note that this function is not particularly
13744 // well-behaved when it comes to comparison of doubles; in particular,
13745 // the handling of incomparable values (ie: NaN) is undefined.
13747 // If you only require an equality comparison, g_variant_equal() is more
13748 // general.
13750 // zero if a = b;
13751 // positive value if a &gt; b.
13752 // RETURNS: negative value if a &lt; b;
13753 // <two>: a #GVariant instance of the same type
13754 int compare()(const(Variant)* two) {
13755 return g_variant_compare(&this, two);
13758 // VERSION: 2.26
13759 // Similar to g_variant_get_bytestring() except that instead of
13760 // returning a constant string, the string is duplicated.
13762 // The return value must be freed using g_free().
13764 // (element-type guint8): a newly allocated string
13765 // RETURNS: (transfer full) (array zero-terminated=1 length=length)
13766 // <length>: a pointer to a #gsize, to store the length (not including the nul terminator)
13767 char* /*new*/ dup_bytestring()(/*out*/ size_t* length=null) {
13768 return g_variant_dup_bytestring(&this, length);
13771 // VERSION: 2.26
13772 // Gets the contents of an array of array of bytes #GVariant. This call
13773 // makes a deep copy; the return result should be released with
13774 // g_strfreev().
13776 // If @length is non-%NULL then the number of elements in the result is
13777 // stored there. In any case, the resulting array will be
13778 // %NULL-terminated.
13780 // For an empty array, @length will be set to 0 and a pointer to a
13781 // %NULL pointer will be returned.
13782 // RETURNS: an array of strings
13783 // <length>: the length of the result, or %NULL
13784 char** /*new*/ dup_bytestring_array()(/*out*/ size_t* length=null) {
13785 return g_variant_dup_bytestring_array(&this, length);
13788 // VERSION: 2.30
13789 // Gets the contents of an array of object paths #GVariant. This call
13790 // makes a deep copy; the return result should be released with
13791 // g_strfreev().
13793 // If @length is non-%NULL then the number of elements in the result
13794 // is stored there. In any case, the resulting array will be
13795 // %NULL-terminated.
13797 // For an empty array, @length will be set to 0 and a pointer to a
13798 // %NULL pointer will be returned.
13799 // RETURNS: an array of strings
13800 // <length>: the length of the result, or %NULL
13801 char** /*new*/ dup_objv()(/*out*/ size_t* length=null) {
13802 return g_variant_dup_objv(&this, length);
13805 // VERSION: 2.24
13806 // Similar to g_variant_get_string() except that instead of returning
13807 // a constant string, the string is duplicated.
13809 // The string will always be utf8 encoded.
13811 // The return value must be freed using g_free().
13812 // RETURNS: a newly allocated string, utf8 encoded
13813 // <length>: a pointer to a #gsize, to store the length
13814 char* /*new*/ dup_string()(/*out*/ size_t* length) {
13815 return g_variant_dup_string(&this, length);
13818 // VERSION: 2.24
13819 // Gets the contents of an array of strings #GVariant. This call
13820 // makes a deep copy; the return result should be released with
13821 // g_strfreev().
13823 // If @length is non-%NULL then the number of elements in the result
13824 // is stored there. In any case, the resulting array will be
13825 // %NULL-terminated.
13827 // For an empty array, @length will be set to 0 and a pointer to a
13828 // %NULL pointer will be returned.
13829 // RETURNS: an array of strings
13830 // <length>: the length of the result, or %NULL
13831 char** /*new*/ dup_strv()(/*out*/ size_t* length=null) {
13832 return g_variant_dup_strv(&this, length);
13835 // VERSION: 2.24
13836 // Checks if @one and @two have the same type and value.
13838 // The types of @one and @two are #gconstpointer only to allow use of
13839 // this function with #GHashTable. They must each be a #GVariant.
13840 // RETURNS: %TRUE if @one and @two are equal
13841 // <two>: a #GVariant instance
13842 int equal()(const(Variant)* two) {
13843 return g_variant_equal(&this, two);
13846 // Unintrospectable method: get() / g_variant_get()
13847 // VERSION: 2.24
13848 // Deconstructs a #GVariant instance.
13850 // Think of this function as an analogue to scanf().
13852 // The arguments that are expected by this function are entirely
13853 // determined by @format_string. @format_string also restricts the
13854 // permissible types of @value. It is an error to give a value with
13855 // an incompatible type. See the section on <link
13856 // linkend='gvariant-format-strings'>GVariant Format Strings</link>.
13857 // Please note that the syntax of the format string is very likely to be
13858 // extended in the future.
13859 // <format_string>: a #GVariant format string
13860 /+ Not available -- variadic methods unsupported - use the C function directly.
13861 alias g_variant_get get; // Variadic
13864 // VERSION: 2.24
13865 // Returns the boolean value of @value.
13867 // It is an error to call this function with a @value of any type
13868 // other than %G_VARIANT_TYPE_BOOLEAN.
13869 // RETURNS: %TRUE or %FALSE
13870 int get_boolean()() {
13871 return g_variant_get_boolean(&this);
13874 // VERSION: 2.24
13875 // Returns the byte value of @value.
13877 // It is an error to call this function with a @value of any type
13878 // other than %G_VARIANT_TYPE_BYTE.
13879 // RETURNS: a #guchar
13880 ubyte get_byte()() {
13881 return g_variant_get_byte(&this);
13884 // VERSION: 2.26
13885 // Returns the string value of a #GVariant instance with an
13886 // array-of-bytes type. The string has no particular encoding.
13888 // If the array does not end with a nul terminator character, the empty
13889 // string is returned. For this reason, you can always trust that a
13890 // non-%NULL nul-terminated string will be returned by this function.
13892 // If the array contains a nul terminator character somewhere other than
13893 // the last byte then the returned string is the string, up to the first
13894 // such nul character.
13896 // It is an error to call this function with a @value that is not an
13897 // array of bytes.
13899 // The return value remains valid as long as @value exists.
13901 // the constant string
13902 ubyte* get_bytestring()() {
13903 return g_variant_get_bytestring(&this);
13906 // VERSION: 2.26
13907 // Gets the contents of an array of array of bytes #GVariant. This call
13908 // makes a shallow copy; the return result should be released with
13909 // g_free(), but the individual strings must not be modified.
13911 // If @length is non-%NULL then the number of elements in the result is
13912 // stored there. In any case, the resulting array will be
13913 // %NULL-terminated.
13915 // For an empty array, @length will be set to 0 and a pointer to a
13916 // %NULL pointer will be returned.
13917 // RETURNS: an array of constant strings
13918 // <length>: the length of the result, or %NULL
13919 char** /*new container*/ get_bytestring_array()(/*out*/ size_t* length=null) {
13920 return g_variant_get_bytestring_array(&this, length);
13923 // Unintrospectable method: get_child() / g_variant_get_child()
13924 // VERSION: 2.24
13925 // Reads a child item out of a container #GVariant instance and
13926 // deconstructs it according to @format_string. This call is
13927 // essentially a combination of g_variant_get_child_value() and
13928 // g_variant_get().
13929 // <index_>: the index of the child to deconstruct
13930 // <format_string>: a #GVariant format string
13931 /+ Not available -- variadic methods unsupported - use the C function directly.
13932 alias g_variant_get_child get_child; // Variadic
13935 // VERSION: 2.24
13936 // Reads a child item out of a container #GVariant instance. This
13937 // includes variants, maybes, arrays, tuples and dictionary
13938 // entries. It is an error to call this function on any other type of
13939 // #GVariant.
13941 // It is an error if @index_ is greater than the number of child items
13942 // in the container. See g_variant_n_children().
13944 // The returned value is never floating. You should free it with
13945 // g_variant_unref() when you're done with it.
13947 // This function is O(1).
13948 // RETURNS: the child at the specified index
13949 // <index_>: the index of the child to fetch
13950 Variant* /*new*/ get_child_value()(size_t index_) {
13951 return g_variant_get_child_value(&this, index_);
13954 // VERSION: 2.24
13955 // Returns a pointer to the serialised form of a #GVariant instance.
13956 // The returned data may not be in fully-normalised form if read from an
13957 // untrusted source. The returned data must not be freed; it remains
13958 // valid for as long as @value exists.
13960 // If @value is a fixed-sized value that was deserialised from a
13961 // corrupted serialised container then %NULL may be returned. In this
13962 // case, the proper thing to do is typically to use the appropriate
13963 // number of nul bytes in place of @value. If @value is not fixed-sized
13964 // then %NULL is never returned.
13966 // In the case that @value is already in serialised form, this function
13967 // is O(1). If the value is not already in serialised form,
13968 // serialisation occurs implicitly and is approximately O(n) in the size
13969 // of the result.
13971 // To deserialise the data returned by this function, in addition to the
13972 // serialised data, you must know the type of the #GVariant, and (if the
13973 // machine might be different) the endianness of the machine that stored
13974 // it. As a result, file formats or network messages that incorporate
13975 // serialised #GVariant<!---->s must include this information either
13976 // implicitly (for instance "the file always contains a
13977 // %G_VARIANT_TYPE_VARIANT and it is always in little-endian order") or
13978 // explicitly (by storing the type and/or endianness in addition to the
13979 // serialised data).
13980 // RETURNS: the serialised form of @value, or %NULL
13981 const(void)* get_data()() {
13982 return g_variant_get_data(&this);
13985 // VERSION: 2.24
13986 // Returns the double precision floating point value of @value.
13988 // It is an error to call this function with a @value of any type
13989 // other than %G_VARIANT_TYPE_DOUBLE.
13990 // RETURNS: a #gdouble
13991 double get_double()() {
13992 return g_variant_get_double(&this);
13995 // VERSION: 2.24
13996 // Provides access to the serialised data for an array of fixed-sized
13997 // items.
13999 // @value must be an array with fixed-sized elements. Numeric types are
14000 // fixed-size, as are tuples containing only other fixed-sized types.
14002 // @element_size must be the size of a single element in the array,
14003 // as given by the section on
14004 // <link linkend='gvariant-serialised-data-memory'>Serialised Data
14005 // Memory</link>.
14007 // In particular, arrays of these fixed-sized types can be interpreted
14008 // as an array of the given C type, with @element_size set to
14009 // <code>sizeof</code> the appropriate type:
14011 // <informaltable>
14012 // <tgroup cols='2'>
14013 // <thead><row><entry>element type</entry> <entry>C type</entry></row></thead>
14014 // <tbody>
14015 // <row><entry>%G_VARIANT_TYPE_INT16 (etc.)</entry>
14016 // <entry>#gint16 (etc.)</entry></row>
14017 // <row><entry>%G_VARIANT_TYPE_BOOLEAN</entry>
14018 // <entry>#guchar (not #gboolean!)</entry></row>
14019 // <row><entry>%G_VARIANT_TYPE_BYTE</entry> <entry>#guchar</entry></row>
14020 // <row><entry>%G_VARIANT_TYPE_HANDLE</entry> <entry>#guint32</entry></row>
14021 // <row><entry>%G_VARIANT_TYPE_DOUBLE</entry> <entry>#gdouble</entry></row>
14022 // </tbody>
14023 // </tgroup>
14024 // </informaltable>
14026 // For example, if calling this function for an array of 32 bit integers,
14027 // you might say <code>sizeof (gint32)</code>. This value isn't used
14028 // except for the purpose of a double-check that the form of the
14029 // serialised data matches the caller's expectation.
14031 // @n_elements, which must be non-%NULL is set equal to the number of
14032 // items in the array.
14034 // the fixed array
14035 // RETURNS: a pointer to
14036 // <n_elements>: a pointer to the location to store the number of items
14037 // <element_size>: the size of each element
14038 const(void)* get_fixed_array()(/*out*/ size_t* n_elements, size_t element_size) {
14039 return g_variant_get_fixed_array(&this, n_elements, element_size);
14042 // VERSION: 2.24
14043 // Returns the 32-bit signed integer value of @value.
14045 // It is an error to call this function with a @value of any type other
14046 // than %G_VARIANT_TYPE_HANDLE.
14048 // By convention, handles are indexes into an array of file descriptors
14049 // that are sent alongside a D-Bus message. If you're not interacting
14050 // with D-Bus, you probably don't need them.
14051 // RETURNS: a #gint32
14052 int get_handle()() {
14053 return g_variant_get_handle(&this);
14056 // VERSION: 2.24
14057 // Returns the 16-bit signed integer value of @value.
14059 // It is an error to call this function with a @value of any type
14060 // other than %G_VARIANT_TYPE_INT16.
14061 // RETURNS: a #gint16
14062 short get_int16()() {
14063 return g_variant_get_int16(&this);
14066 // VERSION: 2.24
14067 // Returns the 32-bit signed integer value of @value.
14069 // It is an error to call this function with a @value of any type
14070 // other than %G_VARIANT_TYPE_INT32.
14071 // RETURNS: a #gint32
14072 int get_int32()() {
14073 return g_variant_get_int32(&this);
14076 // VERSION: 2.24
14077 // Returns the 64-bit signed integer value of @value.
14079 // It is an error to call this function with a @value of any type
14080 // other than %G_VARIANT_TYPE_INT64.
14081 // RETURNS: a #gint64
14082 long get_int64()() {
14083 return g_variant_get_int64(&this);
14086 // VERSION: 2.24
14087 // Given a maybe-typed #GVariant instance, extract its value. If the
14088 // value is Nothing, then this function returns %NULL.
14089 // RETURNS: the contents of @value, or %NULL
14090 Variant* /*new*/ get_maybe()() {
14091 return g_variant_get_maybe(&this);
14094 // VERSION: 2.24
14095 // Gets a #GVariant instance that has the same value as @value and is
14096 // trusted to be in normal form.
14098 // If @value is already trusted to be in normal form then a new
14099 // reference to @value is returned.
14101 // If @value is not already trusted, then it is scanned to check if it
14102 // is in normal form. If it is found to be in normal form then it is
14103 // marked as trusted and a new reference to it is returned.
14105 // If @value is found not to be in normal form then a new trusted
14106 // #GVariant is created with the same value as @value.
14108 // It makes sense to call this function if you've received #GVariant
14109 // data from untrusted sources and you want to ensure your serialised
14110 // output is definitely in normal form.
14111 // RETURNS: a trusted #GVariant
14112 Variant* /*new*/ get_normal_form()() {
14113 return g_variant_get_normal_form(&this);
14116 // VERSION: 2.30
14117 // Gets the contents of an array of object paths #GVariant. This call
14118 // makes a shallow copy; the return result should be released with
14119 // g_free(), but the individual strings must not be modified.
14121 // If @length is non-%NULL then the number of elements in the result
14122 // is stored there. In any case, the resulting array will be
14123 // %NULL-terminated.
14125 // For an empty array, @length will be set to 0 and a pointer to a
14126 // %NULL pointer will be returned.
14127 // RETURNS: an array of constant strings
14128 // <length>: the length of the result, or %NULL
14129 char** /*new container*/ get_objv()(/*out*/ size_t* length=null) {
14130 return g_variant_get_objv(&this, length);
14133 // VERSION: 2.24
14134 // Determines the number of bytes that would be required to store @value
14135 // with g_variant_store().
14137 // If @value has a fixed-sized type then this function always returned
14138 // that fixed size.
14140 // In the case that @value is already in serialised form or the size has
14141 // already been calculated (ie: this function has been called before)
14142 // then this function is O(1). Otherwise, the size is calculated, an
14143 // operation which is approximately O(n) in the number of values
14144 // involved.
14145 // RETURNS: the serialised size of @value
14146 size_t get_size()() {
14147 return g_variant_get_size(&this);
14150 // VERSION: 2.24
14151 // Returns the string value of a #GVariant instance with a string
14152 // type. This includes the types %G_VARIANT_TYPE_STRING,
14153 // %G_VARIANT_TYPE_OBJECT_PATH and %G_VARIANT_TYPE_SIGNATURE.
14155 // The string will always be utf8 encoded.
14157 // If @length is non-%NULL then the length of the string (in bytes) is
14158 // returned there. For trusted values, this information is already
14159 // known. For untrusted values, a strlen() will be performed.
14161 // It is an error to call this function with a @value of any type
14162 // other than those three.
14164 // The return value remains valid as long as @value exists.
14165 // RETURNS: the constant string, utf8 encoded
14166 // <length>: a pointer to a #gsize, to store the length
14167 char* get_string()(/*out*/ size_t* length=null) {
14168 return g_variant_get_string(&this, length);
14171 // VERSION: 2.24
14172 // Gets the contents of an array of strings #GVariant. This call
14173 // makes a shallow copy; the return result should be released with
14174 // g_free(), but the individual strings must not be modified.
14176 // If @length is non-%NULL then the number of elements in the result
14177 // is stored there. In any case, the resulting array will be
14178 // %NULL-terminated.
14180 // For an empty array, @length will be set to 0 and a pointer to a
14181 // %NULL pointer will be returned.
14182 // RETURNS: an array of constant strings
14183 // <length>: the length of the result, or %NULL
14184 char** /*new container*/ get_strv()(/*out*/ size_t* length=null) {
14185 return g_variant_get_strv(&this, length);
14188 // VERSION: 2.24
14189 // Returns the type string of @value. Unlike the result of calling
14190 // g_variant_type_peek_string(), this string is nul-terminated. This
14191 // string belongs to #GVariant and must not be freed.
14192 // RETURNS: the type string for the type of @value
14193 char* get_type_string()() {
14194 return g_variant_get_type_string(&this);
14197 // VERSION: 2.24
14198 // Returns the 16-bit unsigned integer value of @value.
14200 // It is an error to call this function with a @value of any type
14201 // other than %G_VARIANT_TYPE_UINT16.
14202 // RETURNS: a #guint16
14203 ushort get_uint16()() {
14204 return g_variant_get_uint16(&this);
14207 // VERSION: 2.24
14208 // Returns the 32-bit unsigned integer value of @value.
14210 // It is an error to call this function with a @value of any type
14211 // other than %G_VARIANT_TYPE_UINT32.
14212 // RETURNS: a #guint32
14213 uint get_uint32()() {
14214 return g_variant_get_uint32(&this);
14217 // VERSION: 2.24
14218 // Returns the 64-bit unsigned integer value of @value.
14220 // It is an error to call this function with a @value of any type
14221 // other than %G_VARIANT_TYPE_UINT64.
14222 // RETURNS: a #guint64
14223 ulong get_uint64()() {
14224 return g_variant_get_uint64(&this);
14227 // Unintrospectable method: get_va() / g_variant_get_va()
14228 // VERSION: 2.24
14229 // This function is intended to be used by libraries based on #GVariant
14230 // that want to provide g_variant_get()-like functionality to their
14231 // users.
14233 // The API is more general than g_variant_get() to allow a wider range
14234 // of possible uses.
14236 // @format_string must still point to a valid format string, but it only
14237 // need to be nul-terminated if @endptr is %NULL. If @endptr is
14238 // non-%NULL then it is updated to point to the first character past the
14239 // end of the format string.
14241 // @app is a pointer to a #va_list. The arguments, according to
14242 // @format_string, are collected from this #va_list and the list is left
14243 // pointing to the argument following the last.
14245 // These two generalisations allow mixing of multiple calls to
14246 // g_variant_new_va() and g_variant_get_va() within a single actual
14247 // varargs call by the user.
14248 // <format_string>: a string that is prefixed with a format string
14249 // <endptr>: location to store the end pointer, or %NULL
14250 // <app>: a pointer to a #va_list
14251 void get_va()(char* format_string, char** endptr, va_list* app) {
14252 g_variant_get_va(&this, format_string, endptr, app);
14255 // VERSION: 2.24
14256 // Unboxes @value. The result is the #GVariant instance that was
14257 // contained in @value.
14258 // RETURNS: the item contained in the variant
14259 Variant* /*new*/ get_variant()() {
14260 return g_variant_get_variant(&this);
14263 // VERSION: 2.24
14264 // Generates a hash value for a #GVariant instance.
14266 // The output of this function is guaranteed to be the same for a given
14267 // value only per-process. It may change between different processor
14268 // architectures or even different versions of GLib. Do not use this
14269 // function as a basis for building protocols or file formats.
14271 // The type of @value is #gconstpointer only to allow use of this
14272 // function with #GHashTable. @value must be a #GVariant.
14273 // RETURNS: a hash value corresponding to @value
14274 uint hash()() {
14275 return g_variant_hash(&this);
14278 // VERSION: 2.24
14279 // Checks if @value is a container.
14280 // RETURNS: %TRUE if @value is a container
14281 int is_container()() {
14282 return g_variant_is_container(&this);
14285 // VERSION: 2.26
14286 // Checks whether @value has a floating reference count.
14288 // This function should only ever be used to assert that a given variant
14289 // is or is not floating, or for debug purposes. To acquire a reference
14290 // to a variant that might be floating, always use g_variant_ref_sink()
14291 // or g_variant_take_ref().
14293 // See g_variant_ref_sink() for more information about floating reference
14294 // counts.
14295 // RETURNS: whether @value is floating
14296 int is_floating()() {
14297 return g_variant_is_floating(&this);
14300 // VERSION: 2.24
14301 // Checks if @value is in normal form.
14303 // The main reason to do this is to detect if a given chunk of
14304 // serialised data is in normal form: load the data into a #GVariant
14305 // using g_variant_new_from_data() and then use this function to
14306 // check.
14308 // If @value is found to be in normal form then it will be marked as
14309 // being trusted. If the value was already marked as being trusted then
14310 // this function will immediately return %TRUE.
14311 // RETURNS: %TRUE if @value is in normal form
14312 int is_normal_form()() {
14313 return g_variant_is_normal_form(&this);
14316 // VERSION: 2.24
14317 // Checks if a value has a type matching the provided type.
14318 // RETURNS: %TRUE if the type of @value matches @type
14319 // <type>: a #GVariantType
14320 int is_of_type()(VariantType* type) {
14321 return g_variant_is_of_type(&this, type);
14324 // Unintrospectable method: iter_new() / g_variant_iter_new()
14325 // VERSION: 2.24
14326 // Creates a heap-allocated #GVariantIter for iterating over the items
14327 // in @value.
14329 // Use g_variant_iter_free() to free the return value when you no longer
14330 // need it.
14332 // A reference is taken to @value and will be released only when
14333 // g_variant_iter_free() is called.
14334 // RETURNS: a new heap-allocated #GVariantIter
14335 VariantIter* /*new*/ iter_new()() {
14336 return g_variant_iter_new(&this);
14339 // Unintrospectable method: lookup() / g_variant_lookup()
14340 // VERSION: 2.28
14341 // Looks up a value in a dictionary #GVariant.
14343 // This function is a wrapper around g_variant_lookup_value() and
14344 // g_variant_get(). In the case that %NULL would have been returned,
14345 // this function returns %FALSE. Otherwise, it unpacks the returned
14346 // value and returns %TRUE.
14348 // See g_variant_get() for information about @format_string.
14349 // RETURNS: %TRUE if a value was unpacked
14350 // <key>: the key to lookup in the dictionary
14351 // <format_string>: a GVariant format string
14352 /+ Not available -- variadic methods unsupported - use the C function directly.
14353 alias g_variant_lookup lookup; // Variadic
14356 // VERSION: 2.28
14357 // Looks up a value in a dictionary #GVariant.
14359 // This function works with dictionaries of the type
14360 // <literal>a{s*}</literal> (and equally well with type
14361 // <literal>a{o*}</literal>, but we only further discuss the string case
14362 // for sake of clarity).
14364 // In the event that @dictionary has the type <literal>a{sv}</literal>,
14365 // the @expected_type string specifies what type of value is expected to
14366 // be inside of the variant. If the value inside the variant has a
14367 // different type then %NULL is returned. In the event that @dictionary
14368 // has a value type other than <literal>v</literal> then @expected_type
14369 // must directly match the key type and it is used to unpack the value
14370 // directly or an error occurs.
14372 // In either case, if @key is not found in @dictionary, %NULL is
14373 // returned.
14375 // If the key is found and the value has the correct type, it is
14376 // returned. If @expected_type was specified then any non-%NULL return
14377 // value will have this type.
14378 // RETURNS: the value of the dictionary key, or %NULL
14379 // <key>: the key to lookup in the dictionary
14380 // <expected_type>: a #GVariantType, or %NULL
14381 Variant* /*new*/ lookup_value()(char* key, VariantType* expected_type=null) {
14382 return g_variant_lookup_value(&this, key, expected_type);
14385 // VERSION: 2.24
14386 // Determines the number of children in a container #GVariant instance.
14387 // This includes variants, maybes, arrays, tuples and dictionary
14388 // entries. It is an error to call this function on any other type of
14389 // #GVariant.
14391 // For variants, the return value is always 1. For values with maybe
14392 // types, it is always zero or one. For arrays, it is the length of the
14393 // array. For tuples it is the number of tuple items (which depends
14394 // only on the type). For dictionary entries, it is always 2
14396 // This function is O(1).
14397 // RETURNS: the number of children in the container
14398 size_t n_children()() {
14399 return g_variant_n_children(&this);
14402 // VERSION: 2.24
14403 // Pretty-prints @value in the format understood by g_variant_parse().
14405 // The format is described <link linkend='gvariant-text'>here</link>.
14407 // If @type_annotate is %TRUE, then type information is included in
14408 // the output.
14409 // RETURNS: a newly-allocated string holding the result.
14410 // <type_annotate>: %TRUE if type information should be included in the output
14411 char* /*new*/ print()(int type_annotate) {
14412 return g_variant_print(&this, type_annotate);
14415 // Unintrospectable method: print_string() / g_variant_print_string()
14416 // VERSION: 2.24
14417 // Behaves as g_variant_print(), but operates on a #GString.
14419 // If @string is non-%NULL then it is appended to and returned. Else,
14420 // a new empty #GString is allocated and it is returned.
14421 // RETURNS: a #GString containing the string
14422 // <string>: a #GString, or %NULL
14423 // <type_annotate>: %TRUE if type information should be included in the output
14424 String* /*new*/ print_string()(String* string_, int type_annotate) {
14425 return g_variant_print_string(&this, string_, type_annotate);
14428 // VERSION: 2.24
14429 // Increases the reference count of @value.
14430 // RETURNS: the same @value
14431 Variant* /*new*/ ref_()() {
14432 return g_variant_ref(&this);
14435 // VERSION: 2.24
14436 // #GVariant uses a floating reference count system. All functions with
14437 // names starting with <literal>g_variant_new_</literal> return floating
14438 // references.
14440 // Calling g_variant_ref_sink() on a #GVariant with a floating reference
14441 // will convert the floating reference into a full reference. Calling
14442 // g_variant_ref_sink() on a non-floating #GVariant results in an
14443 // additional normal reference being added.
14445 // In other words, if the @value is floating, then this call "assumes
14446 // ownership" of the floating reference, converting it to a normal
14447 // reference. If the @value is not floating, then this call adds a
14448 // new normal reference increasing the reference count by one.
14450 // All calls that result in a #GVariant instance being inserted into a
14451 // container will call g_variant_ref_sink() on the instance. This means
14452 // that if the value was just created (and has only its floating
14453 // reference) then the container will assume sole ownership of the value
14454 // at that point and the caller will not need to unreference it. This
14455 // makes certain common styles of programming much easier while still
14456 // maintaining normal refcounting semantics in situations where values
14457 // are not floating.
14458 // RETURNS: the same @value
14459 Variant* /*new*/ ref_sink()() {
14460 return g_variant_ref_sink(&this);
14463 // VERSION: 2.24
14464 // Stores the serialised form of @value at @data. @data should be
14465 // large enough. See g_variant_get_size().
14467 // The stored data is in machine native byte order but may not be in
14468 // fully-normalised form if read from an untrusted source. See
14469 // g_variant_get_normal_form() for a solution.
14471 // As with g_variant_get_data(), to be able to deserialise the
14472 // serialised variant successfully, its type and (if the destination
14473 // machine might be different) its endianness must also be available.
14475 // This function is approximately O(n) in the size of @data.
14476 // <data>: the location to store the serialised data at
14477 void store()(void* data) {
14478 g_variant_store(&this, data);
14481 // If @value is floating, sink it. Otherwise, do nothing.
14483 // Typically you want to use g_variant_ref_sink() in order to
14484 // automatically do the correct thing with respect to floating or
14485 // non-floating references, but there is one specific scenario where
14486 // this function is helpful.
14488 // The situation where this function is helpful is when creating an API
14489 // that allows the user to provide a callback function that returns a
14490 // #GVariant. We certainly want to allow the user the flexibility to
14491 // return a non-floating reference from this callback (for the case
14492 // where the value that is being returned already exists).
14494 // At the same time, the style of the #GVariant API makes it likely that
14495 // for newly-created #GVariant instances, the user can be saved some
14496 // typing if they are allowed to return a #GVariant with a floating
14497 // reference.
14499 // Using this function on the return value of the user's callback allows
14500 // the user to do whichever is more convenient for them. The caller
14501 // will alway receives exactly one full reference to the value: either
14502 // the one that was returned in the first place, or a floating reference
14503 // that has been converted to a full reference.
14505 // This function has an odd interaction when combined with
14506 // g_variant_ref_sink() running at the same time in another thread on
14507 // the same #GVariant instance. If g_variant_ref_sink() runs first then
14508 // the result will be that the floating reference is converted to a hard
14509 // reference. If g_variant_take_ref() runs first then the result will
14510 // be that the floating reference is converted to a hard reference and
14511 // an additional reference on top of that one is added. It is best to
14512 // avoid this situation.
14513 // RETURNS: the same @value
14514 Variant* /*new*/ take_ref()() {
14515 return g_variant_take_ref(&this);
14518 // VERSION: 2.24
14519 // Decreases the reference count of @value. When its reference count
14520 // drops to 0, the memory used by the variant is freed.
14521 void unref()() {
14522 g_variant_unref(&this);
14525 // VERSION: 2.24
14526 // Determines if a given string is a valid D-Bus object path. You
14527 // should ensure that a string is a valid D-Bus object path before
14528 // passing it to g_variant_new_object_path().
14530 // A valid object path starts with '/' followed by zero or more
14531 // sequences of characters separated by '/' characters. Each sequence
14532 // must contain only the characters "[A-Z][a-z][0-9]_". No sequence
14533 // (including the one following the final '/' character) may be empty.
14534 // RETURNS: %TRUE if @string is a D-Bus object path
14535 // <string>: a normal C nul-terminated string
14536 static int is_object_path()(char* string_) {
14537 return g_variant_is_object_path(string_);
14540 // VERSION: 2.24
14541 // Determines if a given string is a valid D-Bus type signature. You
14542 // should ensure that a string is a valid D-Bus type signature before
14543 // passing it to g_variant_new_signature().
14545 // D-Bus type signatures consist of zero or more definite #GVariantType
14546 // strings in sequence.
14547 // RETURNS: %TRUE if @string is a D-Bus type signature
14548 // <string>: a normal C nul-terminated string
14549 static int is_signature()(char* string_) {
14550 return g_variant_is_signature(string_);
14553 // Parses a #GVariant from a text representation.
14555 // A single #GVariant is parsed from the content of @text.
14557 // The format is described <link linkend='gvariant-text'>here</link>.
14559 // The memory at @limit will never be accessed and the parser behaves as
14560 // if the character at @limit is the nul terminator. This has the
14561 // effect of bounding @text.
14563 // If @endptr is non-%NULL then @text is permitted to contain data
14564 // following the value that this function parses and @endptr will be
14565 // updated to point to the first character past the end of the text
14566 // parsed by this function. If @endptr is %NULL and there is extra data
14567 // then an error is returned.
14569 // If @type is non-%NULL then the value will be parsed to have that
14570 // type. This may result in additional parse errors (in the case that
14571 // the parsed value doesn't fit the type) but may also result in fewer
14572 // errors (in the case that the type would have been ambiguous, such as
14573 // with empty arrays).
14575 // In the event that the parsing is successful, the resulting #GVariant
14576 // is returned.
14578 // In case of any error, %NULL will be returned. If @error is non-%NULL
14579 // then it will be set to reflect the error that occurred.
14581 // Officially, the language understood by the parser is "any string
14582 // produced by g_variant_print()".
14583 // <type>: a #GVariantType, or %NULL
14584 // <text>: a string containing a GVariant in text form
14585 // <limit>: a pointer to the end of @text, or %NULL
14586 // <endptr>: a location to store the end pointer, or %NULL
14587 static Variant* /*new*/ parse()(VariantType* type, char* text, char* limit, char** endptr, GLib2.Error** error=null) {
14588 return g_variant_parse(type, text, limit, endptr, error);
14590 static Quark parser_get_error_quark()() {
14591 return g_variant_parser_get_error_quark();
14596 // A utility type for constructing container-type #GVariant instances.
14598 // This is an opaque structure and may only be accessed using the
14599 // following functions.
14601 // #GVariantBuilder is not threadsafe in any way. Do not attempt to
14602 // access it from more than one thread.
14603 struct VariantBuilder {
14604 private size_t[16] x;
14607 // VERSION: 2.24
14608 // Allocates and initialises a new #GVariantBuilder.
14610 // You should call g_variant_builder_unref() on the return value when it
14611 // is no longer needed. The memory will not be automatically freed by
14612 // any other call.
14614 // In most cases it is easier to place a #GVariantBuilder directly on
14615 // the stack of the calling function and initialise it with
14616 // g_variant_builder_init().
14617 // RETURNS: a #GVariantBuilder
14618 // <type>: a container type
14619 static VariantBuilder* /*new*/ new_()(VariantType* type) {
14620 return g_variant_builder_new(type);
14623 // Unintrospectable method: add() / g_variant_builder_add()
14624 // VERSION: 2.24
14625 // Adds to a #GVariantBuilder.
14627 // This call is a convenience wrapper that is exactly equivalent to
14628 // calling g_variant_new() followed by g_variant_builder_add_value().
14630 // This function might be used as follows:
14632 // <programlisting>
14633 // GVariant *
14634 // make_pointless_dictionary (void)
14635 // {
14636 // GVariantBuilder *builder;
14637 // int i;
14639 // builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
14640 // for (i = 0; i < 16; i++)
14641 // {
14642 // gchar buf[3];
14644 // sprintf (buf, "%d", i);
14645 // g_variant_builder_add (builder, "{is}", i, buf);
14646 // }
14648 // return g_variant_builder_end (builder);
14649 // }
14650 // </programlisting>
14651 // <format_string>: a #GVariant varargs format string
14652 /+ Not available -- variadic methods unsupported - use the C function directly.
14653 alias g_variant_builder_add add; // Variadic
14656 // Unintrospectable method: add_parsed() / g_variant_builder_add_parsed()
14657 // VERSION: 2.26
14658 // Adds to a #GVariantBuilder.
14660 // This call is a convenience wrapper that is exactly equivalent to
14661 // calling g_variant_new_parsed() followed by
14662 // g_variant_builder_add_value().
14664 // This function might be used as follows:
14666 // <programlisting>
14667 // GVariant *
14668 // make_pointless_dictionary (void)
14669 // {
14670 // GVariantBuilder *builder;
14671 // int i;
14673 // builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
14674 // g_variant_builder_add_parsed (builder, "{'width', <%i>}", 600);
14675 // g_variant_builder_add_parsed (builder, "{'title', <%s>}", "foo");
14676 // g_variant_builder_add_parsed (builder, "{'transparency', <0.5>}");
14677 // return g_variant_builder_end (builder);
14678 // }
14679 // </programlisting>
14680 // <format>: a text format #GVariant
14681 /+ Not available -- variadic methods unsupported - use the C function directly.
14682 alias g_variant_builder_add_parsed add_parsed; // Variadic
14685 // VERSION: 2.24
14686 // Adds @value to @builder.
14688 // It is an error to call this function in any way that would create an
14689 // inconsistent value to be constructed. Some examples of this are
14690 // putting different types of items into an array, putting the wrong
14691 // types or number of items in a tuple, putting more than one value into
14692 // a variant, etc.
14694 // If @value is a floating reference (see g_variant_ref_sink()),
14695 // the @builder instance takes ownership of @value.
14696 // <value>: a #GVariant
14697 void add_value()(Variant* value) {
14698 g_variant_builder_add_value(&this, value);
14701 // Unintrospectable method: clear() / g_variant_builder_clear()
14702 // VERSION: 2.24
14703 // Releases all memory associated with a #GVariantBuilder without
14704 // freeing the #GVariantBuilder structure itself.
14706 // It typically only makes sense to do this on a stack-allocated
14707 // #GVariantBuilder if you want to abort building the value part-way
14708 // through. This function need not be called if you call
14709 // g_variant_builder_end() and it also doesn't need to be called on
14710 // builders allocated with g_variant_builder_new (see
14711 // g_variant_builder_unref() for that).
14713 // This function leaves the #GVariantBuilder structure set to all-zeros.
14714 // It is valid to call this function on either an initialised
14715 // #GVariantBuilder or one that is set to all-zeros but it is not valid
14716 // to call this function on uninitialised memory.
14717 void clear()() {
14718 g_variant_builder_clear(&this);
14721 // VERSION: 2.24
14722 // Closes the subcontainer inside the given @builder that was opened by
14723 // the most recent call to g_variant_builder_open().
14725 // It is an error to call this function in any way that would create an
14726 // inconsistent value to be constructed (ie: too few values added to the
14727 // subcontainer).
14728 void close()() {
14729 g_variant_builder_close(&this);
14732 // VERSION: 2.24
14733 // Ends the builder process and returns the constructed value.
14735 // It is not permissible to use @builder in any way after this call
14736 // except for reference counting operations (in the case of a
14737 // heap-allocated #GVariantBuilder) or by reinitialising it with
14738 // g_variant_builder_init() (in the case of stack-allocated).
14740 // It is an error to call this function in any way that would create an
14741 // inconsistent value to be constructed (ie: insufficient number of
14742 // items added to a container with a specific number of children
14743 // required). It is also an error to call this function if the builder
14744 // was created with an indefinite array or maybe type and no children
14745 // have been added; in this case it is impossible to infer the type of
14746 // the empty array.
14747 // RETURNS: a new, floating, #GVariant
14748 Variant* end()() {
14749 return g_variant_builder_end(&this);
14752 // Unintrospectable method: init() / g_variant_builder_init()
14753 // VERSION: 2.24
14754 // Initialises a #GVariantBuilder structure.
14756 // @type must be non-%NULL. It specifies the type of container to
14757 // construct. It can be an indefinite type such as
14758 // %G_VARIANT_TYPE_ARRAY or a definite type such as "as" or "(ii)".
14759 // Maybe, array, tuple, dictionary entry and variant-typed values may be
14760 // constructed.
14762 // After the builder is initialised, values are added using
14763 // g_variant_builder_add_value() or g_variant_builder_add().
14765 // After all the child values are added, g_variant_builder_end() frees
14766 // the memory associated with the builder and returns the #GVariant that
14767 // was created.
14769 // This function completely ignores the previous contents of @builder.
14770 // On one hand this means that it is valid to pass in completely
14771 // uninitialised memory. On the other hand, this means that if you are
14772 // initialising over top of an existing #GVariantBuilder you need to
14773 // first call g_variant_builder_clear() in order to avoid leaking
14774 // memory.
14776 // You must not call g_variant_builder_ref() or
14777 // g_variant_builder_unref() on a #GVariantBuilder that was initialised
14778 // with this function. If you ever pass a reference to a
14779 // #GVariantBuilder outside of the control of your own code then you
14780 // should assume that the person receiving that reference may try to use
14781 // reference counting; you should use g_variant_builder_new() instead of
14782 // this function.
14783 // <type>: a container type
14784 void init()(VariantType* type) {
14785 g_variant_builder_init(&this, type);
14788 // VERSION: 2.24
14789 // Opens a subcontainer inside the given @builder. When done adding
14790 // items to the subcontainer, g_variant_builder_close() must be called.
14792 // It is an error to call this function in any way that would cause an
14793 // inconsistent value to be constructed (ie: adding too many values or
14794 // a value of an incorrect type).
14795 // <type>: a #GVariantType
14796 void open()(VariantType* type) {
14797 g_variant_builder_open(&this, type);
14800 // VERSION: 2.24
14801 // Increases the reference count on @builder.
14803 // Don't call this on stack-allocated #GVariantBuilder instances or bad
14804 // things will happen.
14805 // RETURNS: a new reference to @builder
14806 VariantBuilder* /*new*/ ref_()() {
14807 return g_variant_builder_ref(&this);
14810 // VERSION: 2.24
14811 // Decreases the reference count on @builder.
14813 // In the event that there are no more references, releases all memory
14814 // associated with the #GVariantBuilder.
14816 // Don't call this on stack-allocated #GVariantBuilder instances or bad
14817 // things will happen.
14818 void unref()() {
14819 g_variant_builder_unref(&this);
14823 // The range of possible top-level types of #GVariant instances.
14824 enum VariantClass /* Version 2.24 */ {
14825 BOOLEAN = 98,
14826 BYTE = 121,
14827 INT16 = 110,
14828 UINT16 = 113,
14829 INT32 = 105,
14830 UINT32 = 117,
14831 INT64 = 120,
14832 UINT64 = 116,
14833 HANDLE = 104,
14834 DOUBLE = 100,
14835 STRING = 115,
14836 OBJECT_PATH = 111,
14837 SIGNATURE = 103,
14838 VARIANT = 118,
14839 MAYBE = 109,
14840 ARRAY = 97,
14841 TUPLE = 40,
14842 DICT_ENTRY = 123
14845 // #GVariantIter is an opaque data structure and can only be accessed
14846 // using the following functions.
14847 struct VariantIter {
14848 private size_t[16] x;
14851 // Unintrospectable method: copy() / g_variant_iter_copy()
14852 // VERSION: 2.24
14853 // Creates a new heap-allocated #GVariantIter to iterate over the
14854 // container that was being iterated over by @iter. Iteration begins on
14855 // the new iterator from the current position of the old iterator but
14856 // the two copies are independent past that point.
14858 // Use g_variant_iter_free() to free the return value when you no longer
14859 // need it.
14861 // A reference is taken to the container that @iter is iterating over
14862 // and will be releated only when g_variant_iter_free() is called.
14863 // RETURNS: a new heap-allocated #GVariantIter
14864 VariantIter* /*new*/ copy()() {
14865 return g_variant_iter_copy(&this);
14868 // VERSION: 2.24
14869 // Frees a heap-allocated #GVariantIter. Only call this function on
14870 // iterators that were returned by g_variant_iter_new() or
14871 // g_variant_iter_copy().
14872 void free()() {
14873 g_variant_iter_free(&this);
14876 // Unintrospectable method: init() / g_variant_iter_init()
14877 // VERSION: 2.24
14878 // Initialises (without allocating) a #GVariantIter. @iter may be
14879 // completely uninitialised prior to this call; its old value is
14880 // ignored.
14882 // The iterator remains valid for as long as @value exists, and need not
14883 // be freed in any way.
14884 // RETURNS: the number of items in @value
14885 // <value>: a container #GVariant
14886 size_t init()(Variant* value) {
14887 return g_variant_iter_init(&this, value);
14890 // Unintrospectable method: loop() / g_variant_iter_loop()
14891 // VERSION: 2.24
14892 // Gets the next item in the container and unpacks it into the variable
14893 // argument list according to @format_string, returning %TRUE.
14895 // If no more items remain then %FALSE is returned.
14897 // On the first call to this function, the pointers appearing on the
14898 // variable argument list are assumed to point at uninitialised memory.
14899 // On the second and later calls, it is assumed that the same pointers
14900 // will be given and that they will point to the memory as set by the
14901 // previous call to this function. This allows the previous values to
14902 // be freed, as appropriate.
14904 // This function is intended to be used with a while loop as
14905 // demonstrated in the following example. This function can only be
14906 // used when iterating over an array. It is only valid to call this
14907 // function with a string constant for the format string and the same
14908 // string constant must be used each time. Mixing calls to this
14909 // function and g_variant_iter_next() or g_variant_iter_next_value() on
14910 // the same iterator causes undefined behavior.
14912 // If you break out of a such a while loop using g_variant_iter_loop() then
14913 // you must free or unreference all the unpacked values as you would with
14914 // g_variant_get(). Failure to do so will cause a memory leak.
14916 // See the section on <link linkend='gvariant-format-strings'>GVariant
14917 // Format Strings</link>.
14919 // <example>
14920 // <title>Memory management with g_variant_iter_loop()</title>
14921 // <programlisting>
14922 // /<!-- -->* Iterates a dictionary of type 'a{sv}' *<!-- -->/
14923 // void
14924 // iterate_dictionary (GVariant *dictionary)
14925 // {
14926 // GVariantIter iter;
14927 // GVariant *value;
14928 // gchar *key;
14930 // g_variant_iter_init (&iter, dictionary);
14931 // while (g_variant_iter_loop (&iter, "{sv}", &key, &value))
14932 // {
14933 // g_print ("Item '%s' has type '%s'\n", key,
14934 // g_variant_get_type_string (value));
14936 // /<!-- -->* no need to free 'key' and 'value' here *<!-- -->/
14937 // /<!-- -->* unless breaking out of this loop *<!-- -->/
14938 // }
14939 // }
14940 // </programlisting>
14941 // </example>
14943 // For most cases you should use g_variant_iter_next().
14945 // This function is really only useful when unpacking into #GVariant or
14946 // #GVariantIter in order to allow you to skip the call to
14947 // g_variant_unref() or g_variant_iter_free().
14949 // For example, if you are only looping over simple integer and string
14950 // types, g_variant_iter_next() is definitely preferred. For string
14951 // types, use the '&' prefix to avoid allocating any memory at all (and
14952 // thereby avoiding the need to free anything as well).
14954 // value
14955 // RETURNS: %TRUE if a value was unpacked, or %FALSE if there was no
14956 // <format_string>: a GVariant format string
14957 /+ Not available -- variadic methods unsupported - use the C function directly.
14958 alias g_variant_iter_loop loop; // Variadic
14961 // VERSION: 2.24
14962 // Queries the number of child items in the container that we are
14963 // iterating over. This is the total number of items -- not the number
14964 // of items remaining.
14966 // This function might be useful for preallocation of arrays.
14967 // RETURNS: the number of children in the container
14968 size_t n_children()() {
14969 return g_variant_iter_n_children(&this);
14972 // Unintrospectable method: next() / g_variant_iter_next()
14973 // VERSION: 2.24
14974 // Gets the next item in the container and unpacks it into the variable
14975 // argument list according to @format_string, returning %TRUE.
14977 // If no more items remain then %FALSE is returned.
14979 // All of the pointers given on the variable arguments list of this
14980 // function are assumed to point at uninitialised memory. It is the
14981 // responsibility of the caller to free all of the values returned by
14982 // the unpacking process.
14984 // See the section on <link linkend='gvariant-format-strings'>GVariant
14985 // Format Strings</link>.
14987 // <example>
14988 // <title>Memory management with g_variant_iter_next()</title>
14989 // <programlisting>
14990 // /<!-- -->* Iterates a dictionary of type 'a{sv}' *<!-- -->/
14991 // void
14992 // iterate_dictionary (GVariant *dictionary)
14993 // {
14994 // GVariantIter iter;
14995 // GVariant *value;
14996 // gchar *key;
14998 // g_variant_iter_init (&iter, dictionary);
14999 // while (g_variant_iter_next (&iter, "{sv}", &key, &value))
15000 // {
15001 // g_print ("Item '%s' has type '%s'\n", key,
15002 // g_variant_get_type_string (value));
15004 // /<!-- -->* must free data for ourselves *<!-- -->/
15005 // g_variant_unref (value);
15006 // g_free (key);
15007 // }
15008 // }
15009 // </programlisting>
15010 // </example>
15012 // For a solution that is likely to be more convenient to C programmers
15013 // when dealing with loops, see g_variant_iter_loop().
15014 // RETURNS: %TRUE if a value was unpacked, or %FALSE if there as no value
15015 // <format_string>: a GVariant format string
15016 /+ Not available -- variadic methods unsupported - use the C function directly.
15017 alias g_variant_iter_next next; // Variadic
15020 // VERSION: 2.24
15021 // Gets the next item in the container. If no more items remain then
15022 // %NULL is returned.
15024 // Use g_variant_unref() to drop your reference on the return value when
15025 // you no longer need it.
15027 // <example>
15028 // <title>Iterating with g_variant_iter_next_value()</title>
15029 // <programlisting>
15030 // /<!-- -->* recursively iterate a container *<!-- -->/
15031 // void
15032 // iterate_container_recursive (GVariant *container)
15033 // {
15034 // GVariantIter iter;
15035 // GVariant *child;
15037 // g_variant_iter_init (&iter, container);
15038 // while ((child = g_variant_iter_next_value (&iter)))
15039 // {
15040 // g_print ("type '%s'\n", g_variant_get_type_string (child));
15042 // if (g_variant_is_container (child))
15043 // iterate_container_recursive (child);
15045 // g_variant_unref (child);
15046 // }
15047 // }
15048 // </programlisting>
15049 // </example>
15050 // RETURNS: a #GVariant, or %NULL
15051 Variant* /*new*/ next_value()() {
15052 return g_variant_iter_next_value(&this);
15056 // Error codes returned by parsing text-format GVariants.
15057 enum VariantParseError {
15058 FAILED = 0,
15059 BASIC_TYPE_EXPECTED = 1,
15060 CANNOT_INFER_TYPE = 2,
15061 DEFINITE_TYPE_EXPECTED = 3,
15062 INPUT_NOT_AT_END = 4,
15063 INVALID_CHARACTER = 5,
15064 INVALID_FORMAT_STRING = 6,
15065 INVALID_OBJECT_PATH = 7,
15066 INVALID_SIGNATURE = 8,
15067 INVALID_TYPE_STRING = 9,
15068 NO_COMMON_TYPE = 10,
15069 NUMBER_OUT_OF_RANGE = 11,
15070 NUMBER_TOO_BIG = 12,
15071 TYPE_ERROR = 13,
15072 UNEXPECTED_TOKEN = 14,
15073 UNKNOWN_KEYWORD = 15,
15074 UNTERMINATED_STRING_CONSTANT = 16,
15075 VALUE_EXPECTED = 17
15078 // This section introduces the GVariant type system. It is based, in
15079 // large part, on the D-Bus type system, with two major changes and some minor
15080 // lifting of restrictions. The <ulink
15081 // url='http://dbus.freedesktop.org/doc/dbus-specification.html'>DBus
15082 // specification</ulink>, therefore, provides a significant amount of
15083 // information that is useful when working with GVariant.
15085 // The first major change with respect to the D-Bus type system is the
15086 // introduction of maybe (or "nullable") types. Any type in GVariant can be
15087 // converted to a maybe type, in which case, "nothing" (or "null") becomes a
15088 // valid value. Maybe types have been added by introducing the
15089 // character "<literal>m</literal>" to type strings.
15091 // The second major change is that the GVariant type system supports the
15092 // concept of "indefinite types" -- types that are less specific than
15093 // the normal types found in D-Bus. For example, it is possible to speak
15094 // of "an array of any type" in GVariant, where the D-Bus type system
15095 // would require you to speak of "an array of integers" or "an array of
15096 // strings". Indefinite types have been added by introducing the
15097 // characters "<literal>*</literal>", "<literal>?</literal>" and
15098 // "<literal>r</literal>" to type strings.
15100 // Finally, all arbitrary restrictions relating to the complexity of
15101 // types are lifted along with the restriction that dictionary entries
15102 // may only appear nested inside of arrays.
15104 // Just as in D-Bus, GVariant types are described with strings ("type
15105 // strings"). Subject to the differences mentioned above, these strings
15106 // are of the same form as those found in DBus. Note, however: D-Bus
15107 // always works in terms of messages and therefore individual type
15108 // strings appear nowhere in its interface. Instead, "signatures"
15109 // are a concatenation of the strings of the type of each argument in a
15110 // message. GVariant deals with single values directly so GVariant type
15111 // strings always describe the type of exactly one value. This means
15112 // that a D-Bus signature string is generally not a valid GVariant type
15113 // string -- except in the case that it is the signature of a message
15114 // containing exactly one argument.
15116 // An indefinite type is similar in spirit to what may be called an
15117 // abstract type in other type systems. No value can exist that has an
15118 // indefinite type as its type, but values can exist that have types
15119 // that are subtypes of indefinite types. That is to say,
15120 // g_variant_get_type() will never return an indefinite type, but
15121 // calling g_variant_is_of_type() with an indefinite type may return
15122 // %TRUE. For example, you cannot have a value that represents "an
15123 // array of no particular type", but you can have an "array of integers"
15124 // which certainly matches the type of "an array of no particular type",
15125 // since "array of integers" is a subtype of "array of no particular
15126 // type".
15128 // This is similar to how instances of abstract classes may not
15129 // directly exist in other type systems, but instances of their
15130 // non-abstract subtypes may. For example, in GTK, no object that has
15131 // the type of #GtkBin can exist (since #GtkBin is an abstract class),
15132 // but a #GtkWindow can certainly be instantiated, and you would say
15133 // that the #GtkWindow is a #GtkBin (since #GtkWindow is a subclass of
15134 // #GtkBin).
15136 // A detailed description of GVariant type strings is given here:
15138 // <refsect2 id='gvariant-typestrings'>
15139 // <title>GVariant Type Strings</title>
15140 // <para>
15141 // A GVariant type string can be any of the following:
15142 // </para>
15143 // <itemizedlist>
15144 // <listitem>
15145 // <para>
15146 // any basic type string (listed below)
15147 // </para>
15148 // </listitem>
15149 // <listitem>
15150 // <para>
15151 // "<literal>v</literal>", "<literal>r</literal>" or
15152 // "<literal>*</literal>"
15153 // </para>
15154 // </listitem>
15155 // <listitem>
15156 // <para>
15157 // one of the characters '<literal>a</literal>' or
15158 // '<literal>m</literal>', followed by another type string
15159 // </para>
15160 // </listitem>
15161 // <listitem>
15162 // <para>
15163 // the character '<literal>(</literal>', followed by a concatenation
15164 // of zero or more other type strings, followed by the character
15165 // '<literal>)</literal>'
15166 // </para>
15167 // </listitem>
15168 // <listitem>
15169 // <para>
15170 // the character '<literal>{</literal>', followed by a basic type
15171 // string (see below), followed by another type string, followed by
15172 // the character '<literal>}</literal>'
15173 // </para>
15174 // </listitem>
15175 // </itemizedlist>
15176 // <para>
15177 // A basic type string describes a basic type (as per
15178 // g_variant_type_is_basic()) and is always a single
15179 // character in length. The valid basic type strings are
15180 // "<literal>b</literal>", "<literal>y</literal>",
15181 // "<literal>n</literal>", "<literal>q</literal>",
15182 // "<literal>i</literal>", "<literal>u</literal>",
15183 // "<literal>x</literal>", "<literal>t</literal>",
15184 // "<literal>h</literal>", "<literal>d</literal>",
15185 // "<literal>s</literal>", "<literal>o</literal>",
15186 // "<literal>g</literal>" and "<literal>?</literal>".
15187 // </para>
15188 // <para>
15189 // The above definition is recursive to arbitrary depth.
15190 // "<literal>aaaaai</literal>" and "<literal>(ui(nq((y)))s)</literal>"
15191 // are both valid type strings, as is
15192 // "<literal>a(aa(ui)(qna{ya(yd)}))</literal>".
15193 // </para>
15194 // <para>
15195 // The meaning of each of the characters is as follows:
15196 // </para>
15197 // <informaltable>
15198 // <tgroup cols='2'>
15199 // <tbody>
15200 // <row>
15201 // <entry>
15202 // <para>
15203 // <emphasis role='strong'>Character</emphasis>
15204 // </para>
15205 // </entry>
15206 // <entry>
15207 // <para>
15208 // <emphasis role='strong'>Meaning</emphasis>
15209 // </para>
15210 // </entry>
15211 // </row>
15212 // <row>
15213 // <entry>
15214 // <para>
15215 // <literal>b</literal>
15216 // </para>
15217 // </entry>
15218 // <entry>
15219 // <para>
15220 // the type string of %G_VARIANT_TYPE_BOOLEAN; a boolean value.
15221 // </para>
15222 // </entry>
15223 // </row>
15224 // <row>
15225 // <entry>
15226 // <para>
15227 // <literal>y</literal>
15228 // </para>
15229 // </entry>
15230 // <entry>
15231 // <para>
15232 // the type string of %G_VARIANT_TYPE_BYTE; a byte.
15233 // </para>
15234 // </entry>
15235 // </row>
15236 // <row>
15237 // <entry>
15238 // <para>
15239 // <literal>n</literal>
15240 // </para>
15241 // </entry>
15242 // <entry>
15243 // <para>
15244 // the type string of %G_VARIANT_TYPE_INT16; a signed 16 bit
15245 // integer.
15246 // </para>
15247 // </entry>
15248 // </row>
15249 // <row>
15250 // <entry>
15251 // <para>
15252 // <literal>q</literal>
15253 // </para>
15254 // </entry>
15255 // <entry>
15256 // <para>
15257 // the type string of %G_VARIANT_TYPE_UINT16; an unsigned 16 bit
15258 // integer.
15259 // </para>
15260 // </entry>
15261 // </row>
15262 // <row>
15263 // <entry>
15264 // <para>
15265 // <literal>i</literal>
15266 // </para>
15267 // </entry>
15268 // <entry>
15269 // <para>
15270 // the type string of %G_VARIANT_TYPE_INT32; a signed 32 bit
15271 // integer.
15272 // </para>
15273 // </entry>
15274 // </row>
15275 // <row>
15276 // <entry>
15277 // <para>
15278 // <literal>u</literal>
15279 // </para>
15280 // </entry>
15281 // <entry>
15282 // <para>
15283 // the type string of %G_VARIANT_TYPE_UINT32; an unsigned 32 bit
15284 // integer.
15285 // </para>
15286 // </entry>
15287 // </row>
15288 // <row>
15289 // <entry>
15290 // <para>
15291 // <literal>x</literal>
15292 // </para>
15293 // </entry>
15294 // <entry>
15295 // <para>
15296 // the type string of %G_VARIANT_TYPE_INT64; a signed 64 bit
15297 // integer.
15298 // </para>
15299 // </entry>
15300 // </row>
15301 // <row>
15302 // <entry>
15303 // <para>
15304 // <literal>t</literal>
15305 // </para>
15306 // </entry>
15307 // <entry>
15308 // <para>
15309 // the type string of %G_VARIANT_TYPE_UINT64; an unsigned 64 bit
15310 // integer.
15311 // </para>
15312 // </entry>
15313 // </row>
15314 // <row>
15315 // <entry>
15316 // <para>
15317 // <literal>h</literal>
15318 // </para>
15319 // </entry>
15320 // <entry>
15321 // <para>
15322 // the type string of %G_VARIANT_TYPE_HANDLE; a signed 32 bit
15323 // value that, by convention, is used as an index into an array
15324 // of file descriptors that are sent alongside a D-Bus message.
15325 // </para>
15326 // </entry>
15327 // </row>
15328 // <row>
15329 // <entry>
15330 // <para>
15331 // <literal>d</literal>
15332 // </para>
15333 // </entry>
15334 // <entry>
15335 // <para>
15336 // the type string of %G_VARIANT_TYPE_DOUBLE; a double precision
15337 // floating point value.
15338 // </para>
15339 // </entry>
15340 // </row>
15341 // <row>
15342 // <entry>
15343 // <para>
15344 // <literal>s</literal>
15345 // </para>
15346 // </entry>
15347 // <entry>
15348 // <para>
15349 // the type string of %G_VARIANT_TYPE_STRING; a string.
15350 // </para>
15351 // </entry>
15352 // </row>
15353 // <row>
15354 // <entry>
15355 // <para>
15356 // <literal>o</literal>
15357 // </para>
15358 // </entry>
15359 // <entry>
15360 // <para>
15361 // the type string of %G_VARIANT_TYPE_OBJECT_PATH; a string in
15362 // the form of a D-Bus object path.
15363 // </para>
15364 // </entry>
15365 // </row>
15366 // <row>
15367 // <entry>
15368 // <para>
15369 // <literal>g</literal>
15370 // </para>
15371 // </entry>
15372 // <entry>
15373 // <para>
15374 // the type string of %G_VARIANT_TYPE_STRING; a string in the
15375 // form of a D-Bus type signature.
15376 // </para>
15377 // </entry>
15378 // </row>
15379 // <row>
15380 // <entry>
15381 // <para>
15382 // <literal>?</literal>
15383 // </para>
15384 // </entry>
15385 // <entry>
15386 // <para>
15387 // the type string of %G_VARIANT_TYPE_BASIC; an indefinite type
15388 // that is a supertype of any of the basic types.
15389 // </para>
15390 // </entry>
15391 // </row>
15392 // <row>
15393 // <entry>
15394 // <para>
15395 // <literal>v</literal>
15396 // </para>
15397 // </entry>
15398 // <entry>
15399 // <para>
15400 // the type string of %G_VARIANT_TYPE_VARIANT; a container type
15401 // that contain any other type of value.
15402 // </para>
15403 // </entry>
15404 // </row>
15405 // <row>
15406 // <entry>
15407 // <para>
15408 // <literal>a</literal>
15409 // </para>
15410 // </entry>
15411 // <entry>
15412 // <para>
15413 // used as a prefix on another type string to mean an array of
15414 // that type; the type string "<literal>ai</literal>", for
15415 // example, is the type of an array of 32 bit signed integers.
15416 // </para>
15417 // </entry>
15418 // </row>
15419 // <row>
15420 // <entry>
15421 // <para>
15422 // <literal>m</literal>
15423 // </para>
15424 // </entry>
15425 // <entry>
15426 // <para>
15427 // used as a prefix on another type string to mean a "maybe", or
15428 // "nullable", version of that type; the type string
15429 // "<literal>ms</literal>", for example, is the type of a value
15430 // that maybe contains a string, or maybe contains nothing.
15431 // </para>
15432 // </entry>
15433 // </row>
15434 // <row>
15435 // <entry>
15436 // <para>
15437 // <literal>()</literal>
15438 // </para>
15439 // </entry>
15440 // <entry>
15441 // <para>
15442 // used to enclose zero or more other concatenated type strings
15443 // to create a tuple type; the type string
15444 // "<literal>(is)</literal>", for example, is the type of a pair
15445 // of an integer and a string.
15446 // </para>
15447 // </entry>
15448 // </row>
15449 // <row>
15450 // <entry>
15451 // <para>
15452 // <literal>r</literal>
15453 // </para>
15454 // </entry>
15455 // <entry>
15456 // <para>
15457 // the type string of %G_VARIANT_TYPE_TUPLE; an indefinite type
15458 // that is a supertype of any tuple type, regardless of the
15459 // number of items.
15460 // </para>
15461 // </entry>
15462 // </row>
15463 // <row>
15464 // <entry>
15465 // <para>
15466 // <literal>{}</literal>
15467 // </para>
15468 // </entry>
15469 // <entry>
15470 // <para>
15471 // used to enclose a basic type string concatenated with another
15472 // type string to create a dictionary entry type, which usually
15473 // appears inside of an array to form a dictionary; the type
15474 // string "<literal>a{sd}</literal>", for example, is the type of
15475 // a dictionary that maps strings to double precision floating
15476 // point values.
15477 // </para>
15478 // <para>
15479 // The first type (the basic type) is the key type and the second
15480 // type is the value type. The reason that the first type is
15481 // restricted to being a basic type is so that it can easily be
15482 // hashed.
15483 // </para>
15484 // </entry>
15485 // </row>
15486 // <row>
15487 // <entry>
15488 // <para>
15489 // <literal>*</literal>
15490 // </para>
15491 // </entry>
15492 // <entry>
15493 // <para>
15494 // the type string of %G_VARIANT_TYPE_ANY; the indefinite type
15495 // that is a supertype of all types. Note that, as with all type
15496 // strings, this character represents exactly one type. It
15497 // cannot be used inside of tuples to mean "any number of items".
15498 // </para>
15499 // </entry>
15500 // </row>
15501 // </tbody>
15502 // </tgroup>
15503 // </informaltable>
15504 // <para>
15505 // Any type string of a container that contains an indefinite type is,
15506 // itself, an indefinite type. For example, the type string
15507 // "<literal>a*</literal>" (corresponding to %G_VARIANT_TYPE_ARRAY) is
15508 // an indefinite type that is a supertype of every array type.
15509 // "<literal>(*s)</literal>" is a supertype of all tuples that
15510 // contain exactly two items where the second item is a string.
15511 // </para>
15512 // <para>
15513 // "<literal>a{?*}</literal>" is an indefinite type that is a
15514 // supertype of all arrays containing dictionary entries where the key
15515 // is any basic type and the value is any type at all. This is, by
15516 // definition, a dictionary, so this type string corresponds to
15517 // %G_VARIANT_TYPE_DICTIONARY. Note that, due to the restriction that
15518 // the key of a dictionary entry must be a basic type,
15519 // "<literal>{**}</literal>" is not a valid type string.
15520 // </para>
15521 // </refsect2>
15522 struct VariantType {
15524 // VERSION: 2.24
15525 // Creates a new #GVariantType corresponding to the type string given
15526 // by @type_string. It is appropriate to call g_variant_type_free() on
15527 // the return value.
15529 // It is a programmer error to call this function with an invalid type
15530 // string. Use g_variant_type_string_is_valid() if you are unsure.
15531 // RETURNS: a new #GVariantType
15532 // <type_string>: a valid GVariant type string
15533 static VariantType* /*new*/ new_()(char* type_string) {
15534 return g_variant_type_new(type_string);
15537 // Constructs a new tuple type, from @items.
15539 // @length is the number of items in @items, or -1 to indicate that
15540 // @items is %NULL-terminated.
15542 // It is appropriate to call g_variant_type_free() on the return value.
15545 // Since 2.24
15546 // RETURNS: a new tuple #GVariantType
15547 // <items>: an array of #GVariantTypes, one for each item
15548 // <length>: the length of @items, or -1
15549 static VariantType* /*new*/ new_tuple()(VariantType** items, int length) {
15550 return g_variant_type_new_tuple(items, length);
15553 // Makes a copy of a #GVariantType. It is appropriate to call
15554 // g_variant_type_free() on the return value. @type may not be %NULL.
15557 // Since 2.24
15558 // RETURNS: a new #GVariantType
15559 VariantType* /*new*/ copy()() {
15560 return g_variant_type_copy(&this);
15563 // Returns a newly-allocated copy of the type string corresponding to
15564 // @type. The returned string is nul-terminated. It is appropriate to
15565 // call g_free() on the return value.
15568 // Since 2.24
15569 // RETURNS: the corresponding type string
15570 char* /*new*/ dup_string()() {
15571 return g_variant_type_dup_string(&this);
15574 // Determines the element type of an array or maybe type.
15576 // This function may only be used with array or maybe types.
15579 // Since 2.24
15580 // RETURNS: the element type of @type
15581 VariantType* element()() {
15582 return g_variant_type_element(&this);
15585 // Compares @type1 and @type2 for equality.
15587 // Only returns %TRUE if the types are exactly equal. Even if one type
15588 // is an indefinite type and the other is a subtype of it, %FALSE will
15589 // be returned if they are not exactly equal. If you want to check for
15590 // subtypes, use g_variant_type_is_subtype_of().
15592 // The argument types of @type1 and @type2 are only #gconstpointer to
15593 // allow use with #GHashTable without function pointer casting. For
15594 // both arguments, a valid #GVariantType must be provided.
15597 // Since 2.24
15598 // RETURNS: %TRUE if @type1 and @type2 are exactly equal
15599 // <type2>: a #GVariantType
15600 int equal()(const(VariantType)* type2) {
15601 return g_variant_type_equal(&this, type2);
15604 // Determines the first item type of a tuple or dictionary entry
15605 // type.
15607 // This function may only be used with tuple or dictionary entry types,
15608 // but must not be used with the generic tuple type
15609 // %G_VARIANT_TYPE_TUPLE.
15611 // In the case of a dictionary entry type, this returns the type of
15612 // the key.
15614 // %NULL is returned in case of @type being %G_VARIANT_TYPE_UNIT.
15616 // This call, together with g_variant_type_next() provides an iterator
15617 // interface over tuple and dictionary entry types.
15620 // Since 2.24
15621 // RETURNS: the first item type of @type, or %NULL
15622 VariantType* first()() {
15623 return g_variant_type_first(&this);
15626 // Frees a #GVariantType that was allocated with
15627 // g_variant_type_copy(), g_variant_type_new() or one of the container
15628 // type constructor functions.
15630 // In the case that @type is %NULL, this function does nothing.
15632 // Since 2.24
15633 void free()() {
15634 g_variant_type_free(&this);
15637 // Returns the length of the type string corresponding to the given
15638 // @type. This function must be used to determine the valid extent of
15639 // the memory region returned by g_variant_type_peek_string().
15642 // Since 2.24
15643 // RETURNS: the length of the corresponding type string
15644 size_t get_string_length()() {
15645 return g_variant_type_get_string_length(&this);
15648 // Hashes @type.
15650 // The argument type of @type is only #gconstpointer to allow use with
15651 // #GHashTable without function pointer casting. A valid
15652 // #GVariantType must be provided.
15655 // Since 2.24
15656 // RETURNS: the hash value
15657 uint hash()() {
15658 return g_variant_type_hash(&this);
15661 // Determines if the given @type is an array type. This is true if the
15662 // type string for @type starts with an 'a'.
15664 // This function returns %TRUE for any indefinite type for which every
15665 // definite subtype is an array type -- %G_VARIANT_TYPE_ARRAY, for
15666 // example.
15669 // Since 2.24
15670 // RETURNS: %TRUE if @type is an array type
15671 int is_array()() {
15672 return g_variant_type_is_array(&this);
15675 // Determines if the given @type is a basic type.
15677 // Basic types are booleans, bytes, integers, doubles, strings, object
15678 // paths and signatures.
15680 // Only a basic type may be used as the key of a dictionary entry.
15682 // This function returns %FALSE for all indefinite types except
15683 // %G_VARIANT_TYPE_BASIC.
15686 // Since 2.24
15687 // RETURNS: %TRUE if @type is a basic type
15688 int is_basic()() {
15689 return g_variant_type_is_basic(&this);
15692 // Determines if the given @type is a container type.
15694 // Container types are any array, maybe, tuple, or dictionary
15695 // entry types plus the variant type.
15697 // This function returns %TRUE for any indefinite type for which every
15698 // definite subtype is a container -- %G_VARIANT_TYPE_ARRAY, for
15699 // example.
15702 // Since 2.24
15703 // RETURNS: %TRUE if @type is a container type
15704 int is_container()() {
15705 return g_variant_type_is_container(&this);
15708 // Determines if the given @type is definite (ie: not indefinite).
15710 // A type is definite if its type string does not contain any indefinite
15711 // type characters ('*', '?', or 'r').
15713 // A #GVariant instance may not have an indefinite type, so calling
15714 // this function on the result of g_variant_get_type() will always
15715 // result in %TRUE being returned. Calling this function on an
15716 // indefinite type like %G_VARIANT_TYPE_ARRAY, however, will result in
15717 // %FALSE being returned.
15720 // Since 2.24
15721 // RETURNS: %TRUE if @type is definite
15722 int is_definite()() {
15723 return g_variant_type_is_definite(&this);
15726 // Determines if the given @type is a dictionary entry type. This is
15727 // true if the type string for @type starts with a '{'.
15729 // This function returns %TRUE for any indefinite type for which every
15730 // definite subtype is a dictionary entry type --
15731 // %G_VARIANT_TYPE_DICT_ENTRY, for example.
15734 // Since 2.24
15735 // RETURNS: %TRUE if @type is a dictionary entry type
15736 int is_dict_entry()() {
15737 return g_variant_type_is_dict_entry(&this);
15740 // Determines if the given @type is a maybe type. This is true if the
15741 // type string for @type starts with an 'm'.
15743 // This function returns %TRUE for any indefinite type for which every
15744 // definite subtype is a maybe type -- %G_VARIANT_TYPE_MAYBE, for
15745 // example.
15748 // Since 2.24
15749 // RETURNS: %TRUE if @type is a maybe type
15750 int is_maybe()() {
15751 return g_variant_type_is_maybe(&this);
15754 // Checks if @type is a subtype of @supertype.
15756 // This function returns %TRUE if @type is a subtype of @supertype. All
15757 // types are considered to be subtypes of themselves. Aside from that,
15758 // only indefinite types can have subtypes.
15761 // Since 2.24
15762 // RETURNS: %TRUE if @type is a subtype of @supertype
15763 // <supertype>: a #GVariantType
15764 int is_subtype_of()(VariantType* supertype) {
15765 return g_variant_type_is_subtype_of(&this, supertype);
15768 // Determines if the given @type is a tuple type. This is true if the
15769 // type string for @type starts with a '(' or if @type is
15770 // %G_VARIANT_TYPE_TUPLE.
15772 // This function returns %TRUE for any indefinite type for which every
15773 // definite subtype is a tuple type -- %G_VARIANT_TYPE_TUPLE, for
15774 // example.
15777 // Since 2.24
15778 // RETURNS: %TRUE if @type is a tuple type
15779 int is_tuple()() {
15780 return g_variant_type_is_tuple(&this);
15783 // Determines if the given @type is the variant type.
15786 // Since 2.24
15787 // RETURNS: %TRUE if @type is the variant type
15788 int is_variant()() {
15789 return g_variant_type_is_variant(&this);
15792 // Determines the key type of a dictionary entry type.
15794 // This function may only be used with a dictionary entry type. Other
15795 // than the additional restriction, this call is equivalent to
15796 // g_variant_type_first().
15799 // Since 2.24
15800 // RETURNS: the key type of the dictionary entry
15801 VariantType* key()() {
15802 return g_variant_type_key(&this);
15805 // Determines the number of items contained in a tuple or
15806 // dictionary entry type.
15808 // This function may only be used with tuple or dictionary entry types,
15809 // but must not be used with the generic tuple type
15810 // %G_VARIANT_TYPE_TUPLE.
15812 // In the case of a dictionary entry type, this function will always
15813 // return 2.
15816 // Since 2.24
15817 // RETURNS: the number of items in @type
15818 size_t n_items()() {
15819 return g_variant_type_n_items(&this);
15822 // Constructs the type corresponding to an array of elements of the
15823 // type @type.
15825 // It is appropriate to call g_variant_type_free() on the return value.
15828 // Since 2.24
15829 // RETURNS: a new array #GVariantType
15830 VariantType* /*new*/ new_array()() {
15831 return g_variant_type_new_array(&this);
15834 // Constructs the type corresponding to a dictionary entry with a key
15835 // of type @key and a value of type @value.
15837 // It is appropriate to call g_variant_type_free() on the return value.
15840 // Since 2.24
15841 // RETURNS: a new dictionary entry #GVariantType
15842 // <value>: a #GVariantType
15843 VariantType* /*new*/ new_dict_entry()(VariantType* value) {
15844 return g_variant_type_new_dict_entry(&this, value);
15847 // Constructs the type corresponding to a maybe instance containing
15848 // type @type or Nothing.
15850 // It is appropriate to call g_variant_type_free() on the return value.
15853 // Since 2.24
15854 // RETURNS: a new maybe #GVariantType
15855 VariantType* /*new*/ new_maybe()() {
15856 return g_variant_type_new_maybe(&this);
15859 // Determines the next item type of a tuple or dictionary entry
15860 // type.
15862 // @type must be the result of a previous call to
15863 // g_variant_type_first() or g_variant_type_next().
15865 // If called on the key type of a dictionary entry then this call
15866 // returns the value type. If called on the value type of a dictionary
15867 // entry then this call returns %NULL.
15869 // For tuples, %NULL is returned when @type is the last item in a tuple.
15872 // Since 2.24
15873 // RETURNS: the next #GVariantType after @type, or %NULL
15874 VariantType* next()() {
15875 return g_variant_type_next(&this);
15878 // Unintrospectable method: peek_string() / g_variant_type_peek_string()
15879 // Returns the type string corresponding to the given @type. The
15880 // result is not nul-terminated; in order to determine its length you
15881 // must call g_variant_type_get_string_length().
15883 // To get a nul-terminated string, see g_variant_type_dup_string().
15886 // Since 2.24
15887 // RETURNS: the corresponding type string (not nul-terminated)
15888 char* peek_string()() {
15889 return g_variant_type_peek_string(&this);
15892 // Determines the value type of a dictionary entry type.
15894 // This function may only be used with a dictionary entry type.
15897 // Since 2.24
15898 // RETURNS: the value type of the dictionary entry
15899 VariantType* value()() {
15900 return g_variant_type_value(&this);
15902 static VariantType* checked_()(char* arg_a) {
15903 return g_variant_type_checked_(arg_a);
15906 // Checks if @type_string is a valid GVariant type string. This call is
15907 // equivalent to calling g_variant_type_string_scan() and confirming
15908 // that the following character is a nul terminator.
15911 // Since 2.24
15912 // RETURNS: %TRUE if @type_string is exactly one valid type string
15913 // <type_string>: a pointer to any string
15914 static int string_is_valid()(char* type_string) {
15915 return g_variant_type_string_is_valid(type_string);
15918 // VERSION: 2.24
15919 // Scan for a single complete and valid GVariant type string in @string.
15920 // The memory pointed to by @limit (or bytes beyond it) is never
15921 // accessed.
15923 // If a valid type string is found, @endptr is updated to point to the
15924 // first character past the end of the string that was found and %TRUE
15925 // is returned.
15927 // If there is no valid type string starting at @string, or if the type
15928 // string does not end before @limit then %FALSE is returned.
15930 // For the simple case of checking if a string is a valid type string,
15931 // see g_variant_type_string_is_valid().
15932 // RETURNS: %TRUE if a valid type string was found
15933 // <string>: a pointer to any string
15934 // <limit>: the end of @string, or %NULL
15935 // <endptr>: location to store the end pointer, or %NULL
15936 static int string_scan()(char* string_, char* limit=null, /*out*/ char** endptr=null) {
15937 return g_variant_type_string_scan(string_, limit, endptr);
15942 // Declares a type of function which takes no arguments
15943 // and has no return value. It is used to specify the type
15944 // function passed to g_atexit().
15945 extern (C) alias void function () VoidFunc;
15947 enum int WIN32_MSG_HANDLE = 19981206;
15949 // VERSION: 2.8
15950 // A wrapper for the POSIX access() function. This function is used to
15951 // test a pathname for one or several of read, write or execute
15952 // permissions, or just existence.
15954 // On Windows, the file protection mechanism is not at all POSIX-like,
15955 // and the underlying function in the C library only checks the
15956 // FAT-style READONLY attribute, and does not look at the ACL of a
15957 // file at all. This function is this in practise almost useless on
15958 // Windows. Software that needs to handle file permissions on Windows
15959 // more exactly should use the Win32 API.
15961 // See your C library manual for more details about access().
15963 // object that has all the tested permissions, or -1 otherwise or on
15964 // error.
15965 // RETURNS: zero if the pathname refers to an existing file system
15966 // <filename>: a pathname in the GLib file name encoding (UTF-8 on Windows)
15967 // <mode>: as in access()
15968 static int access()(char* filename, int mode) {
15969 return g_access(filename, mode);
15973 // MOVED TO: Array.free
15974 // Frees the memory allocated for the #GArray. If @free_segment is
15975 // %TRUE it frees the memory block holding the elements as well and
15976 // also each element if @array has a @element_free_func set. Pass
15977 // %FALSE if you want to free the #GArray wrapper but preserve the
15978 // underlying array for use elsewhere. If the reference count of @array
15979 // is greater than one, the #GArray wrapper is preserved but the size
15980 // of @array will be set to zero.
15982 // <note><para>If array elements contain dynamically-allocated memory,
15983 // they should be freed separately.</para></note>
15984 // <array>: a #GArray.
15985 // <free_segment>: if %TRUE the actual element data is freed as well.
15986 static char* /*new*/ array_free()(Array* array, int free_segment) {
15987 return g_array_free(array, free_segment);
15991 // VERSION: 2.22
15992 // MOVED TO: Array.get_element_size
15993 // Gets the size of the elements in @array.
15994 // RETURNS: Size of each element, in bytes.
15995 // <array>: A #GArray.
15996 static uint array_get_element_size()(Array* array) {
15997 return g_array_get_element_size(array);
16000 // MOVED TO: Array.set_clear_func
16001 static void array_set_clear_func()(Array* array, DestroyNotify clear_func) {
16002 g_array_set_clear_func(array, clear_func);
16006 // VERSION: 2.22
16007 // MOVED TO: Array.unref
16008 // Atomically decrements the reference count of @array by one. If the
16009 // reference count drops to 0, all memory allocated by the array is
16010 // released. This function is MT-safe and may be called from any
16011 // thread.
16012 // <array>: A #GArray.
16013 static void array_unref()(Array* array) {
16014 g_array_unref(array);
16018 // Determines the numeric value of a character as a decimal
16019 // digit. Differs from g_unichar_digit_value() because it takes
16020 // a char, so there's no worry about sign extension if characters
16021 // are signed.
16023 // g_ascii_isdigit()), its numeric value. Otherwise, -1.
16024 // RETURNS: If @c is a decimal digit (according to
16025 // <c>: an ASCII character.
16026 static int ascii_digit_value()(char c) {
16027 return g_ascii_digit_value(c);
16031 // Converts a #gdouble to a string, using the '.' as
16032 // decimal point.
16034 // This functions generates enough precision that converting
16035 // the string back using g_ascii_strtod() gives the same machine-number
16036 // (on machines with IEEE compatible 64bit doubles). It is
16037 // guaranteed that the size of the resulting string will never
16038 // be larger than @G_ASCII_DTOSTR_BUF_SIZE bytes.
16039 // RETURNS: The pointer to the buffer with the converted string.
16040 // <buffer>: A buffer to place the resulting string in
16041 // <buf_len>: The length of the buffer.
16042 // <d>: The #gdouble to convert
16043 static char* /*new*/ ascii_dtostr()(char* buffer, int buf_len, double d) {
16044 return g_ascii_dtostr(buffer, buf_len, d);
16048 // Converts a #gdouble to a string, using the '.' as
16049 // decimal point. To format the number you pass in
16050 // a printf()-style format string. Allowed conversion
16051 // specifiers are 'e', 'E', 'f', 'F', 'g' and 'G'.
16053 // If you just want to want to serialize the value into a
16054 // string, use g_ascii_dtostr().
16055 // RETURNS: The pointer to the buffer with the converted string.
16056 // <buffer>: A buffer to place the resulting string in
16057 // <buf_len>: The length of the buffer.
16058 // <format>: The printf()-style format to use for the code to use for converting.
16059 // <d>: The #gdouble to convert
16060 static char* /*new*/ ascii_formatd()(char* buffer, int buf_len, char* format, double d) {
16061 return g_ascii_formatd(buffer, buf_len, format, d);
16065 // Compare two strings, ignoring the case of ASCII characters.
16067 // Unlike the BSD strcasecmp() function, this only recognizes standard
16068 // ASCII letters and ignores the locale, treating all non-ASCII
16069 // bytes as if they are not letters.
16071 // This function should be used only on strings that are known to be
16072 // in encodings where the bytes corresponding to ASCII letters always
16073 // represent themselves. This includes UTF-8 and the ISO-8859-*
16074 // charsets, but not for instance double-byte encodings like the
16075 // Windows Codepage 932, where the trailing bytes of double-byte
16076 // characters include all ASCII letters. If you compare two CP932
16077 // strings using this function, you will get false matches.
16079 // or a positive value if @s1 &gt; @s2.
16080 // RETURNS: 0 if the strings match, a negative value if @s1 &lt; @s2,
16081 // <s1>: string to compare with @s2.
16082 // <s2>: string to compare with @s1.
16083 static int ascii_strcasecmp()(char* s1, char* s2) {
16084 return g_ascii_strcasecmp(s1, s2);
16088 // Converts all upper case ASCII letters to lower case ASCII letters.
16090 // characters in @str converted to lower case, with
16091 // semantics that exactly match g_ascii_tolower(). (Note
16092 // that this is unlike the old g_strdown(), which modified
16093 // the string in place.)
16094 // RETURNS: a newly-allocated string, with all the upper case
16095 // <str>: a string.
16096 // <len>: length of @str in bytes, or -1 if @str is nul-terminated.
16097 static char* /*new*/ ascii_strdown()(char* str, ssize_t len) {
16098 return g_ascii_strdown(str, len);
16102 // Compare @s1 and @s2, ignoring the case of ASCII characters and any
16103 // characters after the first @n in each string.
16105 // Unlike the BSD strcasecmp() function, this only recognizes standard
16106 // ASCII letters and ignores the locale, treating all non-ASCII
16107 // characters as if they are not letters.
16109 // The same warning as in g_ascii_strcasecmp() applies: Use this
16110 // function only on strings known to be in encodings where bytes
16111 // corresponding to ASCII letters always represent themselves.
16113 // or a positive value if @s1 &gt; @s2.
16114 // RETURNS: 0 if the strings match, a negative value if @s1 &lt; @s2,
16115 // <s1>: string to compare with @s2.
16116 // <s2>: string to compare with @s1.
16117 // <n>: number of characters to compare.
16118 static int ascii_strncasecmp()(char* s1, char* s2, size_t n) {
16119 return g_ascii_strncasecmp(s1, s2, n);
16123 // Converts a string to a #gdouble value.
16125 // This function behaves like the standard strtod() function
16126 // does in the C locale. It does this without actually changing
16127 // the current locale, since that would not be thread-safe.
16128 // A limitation of the implementation is that this function
16129 // will still accept localized versions of infinities and NANs.
16131 // This function is typically used when reading configuration
16132 // files or other non-user input that should be locale independent.
16133 // To handle input from the user you should normally use the
16134 // locale-sensitive system strtod() function.
16136 // To convert from a #gdouble to a string in a locale-insensitive
16137 // way, use g_ascii_dtostr().
16139 // If the correct value would cause overflow, plus or minus <literal>HUGE_VAL</literal>
16140 // is returned (according to the sign of the value), and <literal>ERANGE</literal> is
16141 // stored in <literal>errno</literal>. If the correct value would cause underflow,
16142 // zero is returned and <literal>ERANGE</literal> is stored in <literal>errno</literal>.
16144 // This function resets <literal>errno</literal> before calling strtod() so that
16145 // you can reliably detect overflow and underflow.
16146 // RETURNS: the #gdouble value.
16147 // <nptr>: the string to convert to a numeric value.
16148 // <endptr>: if non-%NULL, it returns the character after the last character used in the conversion.
16149 static double ascii_strtod()(char* nptr, char** endptr) {
16150 return g_ascii_strtod(nptr, endptr);
16154 // VERSION: 2.12
16155 // Converts a string to a #gint64 value.
16156 // This function behaves like the standard strtoll() function
16157 // does in the C locale. It does this without actually
16158 // changing the current locale, since that would not be
16159 // thread-safe.
16161 // This function is typically used when reading configuration
16162 // files or other non-user input that should be locale independent.
16163 // To handle input from the user you should normally use the
16164 // locale-sensitive system strtoll() function.
16166 // If the correct value would cause overflow, %G_MAXINT64 or %G_MININT64
16167 // is returned, and <literal>ERANGE</literal> is stored in <literal>errno</literal>.
16168 // If the base is outside the valid range, zero is returned, and
16169 // <literal>EINVAL</literal> is stored in <literal>errno</literal>. If the
16170 // string conversion fails, zero is returned, and @endptr returns @nptr
16171 // (if @endptr is non-%NULL).
16172 // RETURNS: the #gint64 value or zero on error.
16173 // <nptr>: the string to convert to a numeric value.
16174 // <endptr>: if non-%NULL, it returns the character after the last character used in the conversion.
16175 // <base>: to be used for the conversion, 2..36 or 0
16176 static long ascii_strtoll()(char* nptr, char** endptr, uint base) {
16177 return g_ascii_strtoll(nptr, endptr, base);
16181 // VERSION: 2.2
16182 // Converts a string to a #guint64 value.
16183 // This function behaves like the standard strtoull() function
16184 // does in the C locale. It does this without actually
16185 // changing the current locale, since that would not be
16186 // thread-safe.
16188 // This function is typically used when reading configuration
16189 // files or other non-user input that should be locale independent.
16190 // To handle input from the user you should normally use the
16191 // locale-sensitive system strtoull() function.
16193 // If the correct value would cause overflow, %G_MAXUINT64
16194 // is returned, and <literal>ERANGE</literal> is stored in <literal>errno</literal>.
16195 // If the base is outside the valid range, zero is returned, and
16196 // <literal>EINVAL</literal> is stored in <literal>errno</literal>.
16197 // If the string conversion fails, zero is returned, and @endptr returns
16198 // @nptr (if @endptr is non-%NULL).
16199 // RETURNS: the #guint64 value or zero on error.
16200 // <nptr>: the string to convert to a numeric value.
16201 // <endptr>: if non-%NULL, it returns the character after the last character used in the conversion.
16202 // <base>: to be used for the conversion, 2..36 or 0
16203 static ulong ascii_strtoull()(char* nptr, char** endptr, uint base) {
16204 return g_ascii_strtoull(nptr, endptr, base);
16208 // Converts all lower case ASCII letters to upper case ASCII letters.
16210 // characters in @str converted to upper case, with
16211 // semantics that exactly match g_ascii_toupper(). (Note
16212 // that this is unlike the old g_strup(), which modified
16213 // the string in place.)
16214 // RETURNS: a newly allocated string, with all the lower case
16215 // <str>: a string.
16216 // <len>: length of @str in bytes, or -1 if @str is nul-terminated.
16217 static char* /*new*/ ascii_strup()(char* str, ssize_t len) {
16218 return g_ascii_strup(str, len);
16222 // Convert a character to ASCII lower case.
16224 // Unlike the standard C library tolower() function, this only
16225 // recognizes standard ASCII letters and ignores the locale, returning
16226 // all non-ASCII characters unchanged, even if they are lower case
16227 // letters in a particular character set. Also unlike the standard
16228 // library function, this takes and returns a char, not an int, so
16229 // don't call it on <literal>EOF</literal> but no need to worry about casting to #guchar
16230 // before passing a possibly non-ASCII character in.
16232 // If @c is not an ASCII upper case letter,
16233 // @c is returned unchanged.
16234 // RETURNS: the result of converting @c to lower case.
16235 // <c>: any character.
16236 static char ascii_tolower()(char c) {
16237 return g_ascii_tolower(c);
16241 // Convert a character to ASCII upper case.
16243 // Unlike the standard C library toupper() function, this only
16244 // recognizes standard ASCII letters and ignores the locale, returning
16245 // all non-ASCII characters unchanged, even if they are upper case
16246 // letters in a particular character set. Also unlike the standard
16247 // library function, this takes and returns a char, not an int, so
16248 // don't call it on <literal>EOF</literal> but no need to worry about casting to #guchar
16249 // before passing a possibly non-ASCII character in.
16251 // If @c is not an ASCII lower case letter,
16252 // @c is returned unchanged.
16253 // RETURNS: the result of converting @c to upper case.
16254 // <c>: any character.
16255 static char ascii_toupper()(char c) {
16256 return g_ascii_toupper(c);
16260 // Determines the numeric value of a character as a hexidecimal
16261 // digit. Differs from g_unichar_xdigit_value() because it takes
16262 // a char, so there's no worry about sign extension if characters
16263 // are signed.
16265 // g_ascii_isxdigit()), its numeric value. Otherwise, -1.
16266 // RETURNS: If @c is a hex digit (according to
16267 // <c>: an ASCII character.
16268 static int ascii_xdigit_value()(char c) {
16269 return g_ascii_xdigit_value(c);
16272 static void assert_warning()(char* log_domain, char* file, int line, char* pretty_function, char* expression) {
16273 g_assert_warning(log_domain, file, line, pretty_function, expression);
16276 static void assertion_message()(char* domain, char* file, int line, char* func, char* message) {
16277 g_assertion_message(domain, file, line, func, message);
16280 // Unintrospectable function: assertion_message_cmpnum() / g_assertion_message_cmpnum()
16281 static void assertion_message_cmpnum()(char* domain, char* file, int line, char* func, char* expr, real arg1, char* cmp, real arg2, char numtype) {
16282 g_assertion_message_cmpnum(domain, file, line, func, expr, arg1, cmp, arg2, numtype);
16285 static void assertion_message_cmpstr()(char* domain, char* file, int line, char* func, char* expr, char* arg1, char* cmp, char* arg2) {
16286 g_assertion_message_cmpstr(domain, file, line, func, expr, arg1, cmp, arg2);
16289 static void assertion_message_error()(char* domain, char* file, int line, char* func, char* expr, Error* error, Quark error_domain, int error_code) {
16290 g_assertion_message_error(domain, file, line, func, expr, error, error_domain, error_code);
16293 static void assertion_message_expr()(char* domain, char* file, int line, char* func, char* expr) {
16294 g_assertion_message_expr(domain, file, line, func, expr);
16298 // Specifies a function to be called at normal program termination.
16300 // Since GLib 2.8.2, on Windows g_atexit() actually is a preprocessor
16301 // macro that maps to a call to the atexit() function in the C
16302 // library. This means that in case the code that calls g_atexit(),
16303 // i.e. atexit(), is in a DLL, the function will be called when the
16304 // DLL is detached from the program. This typically makes more sense
16305 // than that the function is called when the GLib DLL is detached,
16306 // which happened earlier when g_atexit() was a function in the GLib
16307 // DLL.
16309 // The behaviour of atexit() in the context of dynamically loaded
16310 // modules is not formally specified and varies wildly.
16312 // On POSIX systems, calling g_atexit() (or atexit()) in a dynamically
16313 // loaded module which is unloaded before the program terminates might
16314 // well cause a crash at program exit.
16316 // Some POSIX systems implement atexit() like Windows, and have each
16317 // dynamically loaded module maintain an own atexit chain that is
16318 // called when the module is unloaded.
16320 // On other POSIX systems, before a dynamically loaded module is
16321 // unloaded, the registered atexit functions (if any) residing in that
16322 // module are called, regardless where the code that registered them
16323 // resided. This is presumably the most robust approach.
16325 // As can be seen from the above, for portability it's best to avoid
16326 // calling g_atexit() (or atexit()) except in the main executable of a
16327 // program.
16329 // Deprecated:2.32: It is best to avoid g_atexit().
16330 // <func>: the function to call on normal program termination.
16331 static void atexit()(VoidFunc func) {
16332 g_atexit(func);
16336 // VERSION: 2.4
16337 // Atomically adds @val to the value of @atomic.
16339 // Think of this operation as an atomic version of
16340 // <literal>{ tmp = *atomic; *@atomic += @val; return tmp; }</literal>
16342 // This call acts as a full compiler and hardware memory barrier.
16344 // Before version 2.30, this function did not return a value
16345 // (but g_atomic_int_exchange_and_add() did, and had the same meaning).
16346 // RETURNS: the value of @atomic before the add, signed
16347 // <atomic>: a pointer to a #gint or #guint
16348 // <val>: the value to add
16349 static int atomic_int_add()(int* atomic, int val) {
16350 return g_atomic_int_add(atomic, val);
16354 // VERSION: 2.30
16355 // Performs an atomic bitwise 'and' of the value of @atomic and @val,
16356 // storing the result back in @atomic.
16358 // This call acts as a full compiler and hardware memory barrier.
16360 // Think of this operation as an atomic version of
16361 // <literal>{ tmp = *atomic; *@atomic &= @val; return tmp; }</literal>
16362 // RETURNS: the value of @atomic before the operation, unsigned
16363 // <atomic>: a pointer to a #gint or #guint
16364 // <val>: the value to 'and'
16365 static uint atomic_int_and()(uint* atomic, uint val) {
16366 return g_atomic_int_and(atomic, val);
16370 // VERSION: 2.4
16371 // Compares @atomic to @oldval and, if equal, sets it to @newval.
16372 // If @atomic was not equal to @oldval then no change occurs.
16374 // This compare and exchange is done atomically.
16376 // Think of this operation as an atomic version of
16377 // <literal>{ if (*@atomic == @oldval) { *@atomic = @newval; return TRUE; } else return FALSE; }</literal>
16379 // This call acts as a full compiler and hardware memory barrier.
16380 // RETURNS: %TRUE if the exchange took place
16381 // <atomic>: a pointer to a #gint or #guint
16382 // <oldval>: the value to compare with
16383 // <newval>: the value to conditionally replace with
16384 static int atomic_int_compare_and_exchange()(int* atomic, int oldval, int newval) {
16385 return g_atomic_int_compare_and_exchange(atomic, oldval, newval);
16389 // VERSION: 2.4
16390 // Decrements the value of @atomic by 1.
16392 // Think of this operation as an atomic version of
16393 // <literal>{ *@atomic -= 1; return (*@atomic == 0); }</literal>
16395 // This call acts as a full compiler and hardware memory barrier.
16396 // RETURNS: %TRUE if the resultant value is zero
16397 // <atomic>: a pointer to a #gint or #guint
16398 static int atomic_int_dec_and_test()(int* atomic) {
16399 return g_atomic_int_dec_and_test(atomic);
16403 // VERSION: 2.4
16404 // DEPRECATED (v2.30) function: atomic_int_exchange_and_add - Use g_atomic_int_add() instead.
16405 // This function existed before g_atomic_int_add() returned the prior
16406 // value of the integer (which it now does). It is retained only for
16407 // compatibility reasons. Don't use this function in new code.
16408 // RETURNS: the value of @atomic before the add, signed
16409 // <atomic>: a pointer to a #gint
16410 // <val>: the value to add
16411 static int atomic_int_exchange_and_add()(int* atomic, int val) {
16412 return g_atomic_int_exchange_and_add(atomic, val);
16416 // VERSION: 2.4
16417 // Gets the current value of @atomic.
16419 // This call acts as a full compiler and hardware
16420 // memory barrier (before the get).
16421 // RETURNS: the value of the integer
16422 // <atomic>: a pointer to a #gint or #guint
16423 static int atomic_int_get()(int* atomic) {
16424 return g_atomic_int_get(atomic);
16428 // VERSION: 2.4
16429 // Increments the value of @atomic by 1.
16431 // Think of this operation as an atomic version of
16432 // <literal>{ *@atomic += 1; }</literal>
16434 // This call acts as a full compiler and hardware memory barrier.
16435 // <atomic>: a pointer to a #gint or #guint
16436 static void atomic_int_inc()(int* atomic) {
16437 g_atomic_int_inc(atomic);
16441 // VERSION: 2.30
16442 // Performs an atomic bitwise 'or' of the value of @atomic and @val,
16443 // storing the result back in @atomic.
16445 // Think of this operation as an atomic version of
16446 // <literal>{ tmp = *atomic; *@atomic |= @val; return tmp; }</literal>
16448 // This call acts as a full compiler and hardware memory barrier.
16449 // RETURNS: the value of @atomic before the operation, unsigned
16450 // <atomic>: a pointer to a #gint or #guint
16451 // <val>: the value to 'or'
16452 static uint atomic_int_or()(uint* atomic, uint val) {
16453 return g_atomic_int_or(atomic, val);
16457 // VERSION: 2.4
16458 // Sets the value of @atomic to @newval.
16460 // This call acts as a full compiler and hardware
16461 // memory barrier (after the set).
16462 // <atomic>: a pointer to a #gint or #guint
16463 // <newval>: a new value to store
16464 static void atomic_int_set()(int* atomic, int newval) {
16465 g_atomic_int_set(atomic, newval);
16469 // VERSION: 2.30
16470 // Performs an atomic bitwise 'xor' of the value of @atomic and @val,
16471 // storing the result back in @atomic.
16473 // Think of this operation as an atomic version of
16474 // <literal>{ tmp = *atomic; *@atomic ^= @val; return tmp; }</literal>
16476 // This call acts as a full compiler and hardware memory barrier.
16477 // RETURNS: the value of @atomic before the operation, unsigned
16478 // <atomic>: a pointer to a #gint or #guint
16479 // <val>: the value to 'xor'
16480 static uint atomic_int_xor()(uint* atomic, uint val) {
16481 return g_atomic_int_xor(atomic, val);
16485 // VERSION: 2.30
16486 // Atomically adds @val to the value of @atomic.
16488 // Think of this operation as an atomic version of
16489 // <literal>{ tmp = *atomic; *@atomic += @val; return tmp; }</literal>
16491 // This call acts as a full compiler and hardware memory barrier.
16492 // RETURNS: the value of @atomic before the add, signed
16493 // <atomic>: a pointer to a #gpointer-sized value
16494 // <val>: the value to add
16495 static ssize_t atomic_pointer_add()(void* atomic, ssize_t val) {
16496 return g_atomic_pointer_add(atomic, val);
16500 // VERSION: 2.30
16501 // Performs an atomic bitwise 'and' of the value of @atomic and @val,
16502 // storing the result back in @atomic.
16504 // Think of this operation as an atomic version of
16505 // <literal>{ tmp = *atomic; *@atomic &= @val; return tmp; }</literal>
16507 // This call acts as a full compiler and hardware memory barrier.
16508 // RETURNS: the value of @atomic before the operation, unsigned
16509 // <atomic>: a pointer to a #gpointer-sized value
16510 // <val>: the value to 'and'
16511 static size_t atomic_pointer_and()(void* atomic, size_t val) {
16512 return g_atomic_pointer_and(atomic, val);
16516 // VERSION: 2.4
16517 // Compares @atomic to @oldval and, if equal, sets it to @newval.
16518 // If @atomic was not equal to @oldval then no change occurs.
16520 // This compare and exchange is done atomically.
16522 // Think of this operation as an atomic version of
16523 // <literal>{ if (*@atomic == @oldval) { *@atomic = @newval; return TRUE; } else return FALSE; }</literal>
16525 // This call acts as a full compiler and hardware memory barrier.
16526 // RETURNS: %TRUE if the exchange took place
16527 // <atomic>: a pointer to a #gpointer-sized value
16528 // <oldval>: the value to compare with
16529 // <newval>: the value to conditionally replace with
16530 static int atomic_pointer_compare_and_exchange()(void* atomic, void* oldval, void* newval) {
16531 return g_atomic_pointer_compare_and_exchange(atomic, oldval, newval);
16535 // Unintrospectable function: atomic_pointer_get() / g_atomic_pointer_get()
16536 // VERSION: 2.4
16537 // Gets the current value of @atomic.
16539 // This call acts as a full compiler and hardware
16540 // memory barrier (before the get).
16541 // RETURNS: the value of the pointer
16542 // <atomic>: a pointer to a #gpointer-sized value
16543 static void* atomic_pointer_get()(void* atomic) {
16544 return g_atomic_pointer_get(atomic);
16548 // VERSION: 2.30
16549 // Performs an atomic bitwise 'or' of the value of @atomic and @val,
16550 // storing the result back in @atomic.
16552 // Think of this operation as an atomic version of
16553 // <literal>{ tmp = *atomic; *@atomic |= @val; return tmp; }</literal>
16555 // This call acts as a full compiler and hardware memory barrier.
16556 // RETURNS: the value of @atomic before the operation, unsigned
16557 // <atomic>: a pointer to a #gpointer-sized value
16558 // <val>: the value to 'or'
16559 static size_t atomic_pointer_or()(void* atomic, size_t val) {
16560 return g_atomic_pointer_or(atomic, val);
16564 // VERSION: 2.4
16565 // Sets the value of @atomic to @newval.
16567 // This call acts as a full compiler and hardware
16568 // memory barrier (after the set).
16569 // <atomic>: a pointer to a #gpointer-sized value
16570 // <newval>: a new value to store
16571 static void atomic_pointer_set()(void* atomic, void* newval) {
16572 g_atomic_pointer_set(atomic, newval);
16576 // VERSION: 2.30
16577 // Performs an atomic bitwise 'xor' of the value of @atomic and @val,
16578 // storing the result back in @atomic.
16580 // Think of this operation as an atomic version of
16581 // <literal>{ tmp = *atomic; *@atomic ^= @val; return tmp; }</literal>
16583 // This call acts as a full compiler and hardware memory barrier.
16584 // RETURNS: the value of @atomic before the operation, unsigned
16585 // <atomic>: a pointer to a #gpointer-sized value
16586 // <val>: the value to 'xor'
16587 static size_t atomic_pointer_xor()(void* atomic, size_t val) {
16588 return g_atomic_pointer_xor(atomic, val);
16592 // VERSION: 2.12
16593 // Decode a sequence of Base-64 encoded text into binary data
16595 // newly allocated buffer containing the binary data
16596 // that @text represents. The returned buffer must
16597 // be freed with g_free().
16598 // <text>: zero-terminated string with base64 text to decode
16599 // <out_len>: The length of the decoded data is written here
16600 static ubyte* /*new*/ base64_decode()(char* text, /*out*/ size_t* out_len) {
16601 return g_base64_decode(text, out_len);
16605 // VERSION: 2.20
16606 // Decode a sequence of Base-64 encoded text into binary data
16607 // by overwriting the input data.
16609 // is the same as the input @text.
16610 // RETURNS: The binary data that @text responds. This pointer
16611 // <text>: zero-terminated string with base64 text to decode
16612 // <out_len>: The length of the decoded data is written here
16613 static ubyte* base64_decode_inplace()(/*inout*/ ubyte* text, /*inout*/ size_t* out_len) {
16614 return g_base64_decode_inplace(text, out_len);
16618 // VERSION: 2.12
16619 // Incrementally decode a sequence of binary data from its Base-64 stringified
16620 // representation. By calling this function multiple times you can convert
16621 // data in chunks to avoid having to have the full encoded data in memory.
16623 // The output buffer must be large enough to fit all the data that will
16624 // be written to it. Since base64 encodes 3 bytes in 4 chars you need
16625 // at least: (@len / 4) * 3 + 3 bytes (+ 3 may be needed in case of non-zero
16626 // state).
16627 // RETURNS: The number of bytes of output that was written
16628 // <in>: binary input data
16629 // <len>: max length of @in data to decode
16630 // <out>: output buffer
16631 // <state>: Saved state between steps, initialize to 0
16632 // <save>: Saved state between steps, initialize to 0
16633 static size_t base64_decode_step()(ubyte* in_, size_t len, /*out*/ ubyte* out_, /*inout*/ int* state, /*inout*/ uint* save) {
16634 return g_base64_decode_step(in_, len, out_, state, save);
16638 // VERSION: 2.12
16639 // Encode a sequence of binary data into its Base-64 stringified
16640 // representation.
16642 // encoded string representing @data. The returned string must
16643 // be freed with g_free().
16644 // RETURNS: a newly allocated, zero-terminated Base-64
16645 // <data>: the binary data to encode
16646 // <len>: the length of @data
16647 static char* /*new*/ base64_encode()(ubyte* data, size_t len) {
16648 return g_base64_encode(data, len);
16652 // VERSION: 2.12
16653 // Flush the status from a sequence of calls to g_base64_encode_step().
16655 // The output buffer must be large enough to fit all the data that will
16656 // be written to it. It will need up to 4 bytes, or up to 5 bytes if
16657 // line-breaking is enabled.
16658 // RETURNS: The number of bytes of output that was written
16659 // <break_lines>: whether to break long lines
16660 // <out>: pointer to destination buffer
16661 // <state>: Saved state from g_base64_encode_step()
16662 // <save>: Saved state from g_base64_encode_step()
16663 static size_t base64_encode_close()(int break_lines, /*out*/ ubyte* out_, /*inout*/ int* state, /*inout*/ int* save) {
16664 return g_base64_encode_close(break_lines, out_, state, save);
16668 // VERSION: 2.12
16669 // Incrementally encode a sequence of binary data into its Base-64 stringified
16670 // representation. By calling this function multiple times you can convert
16671 // data in chunks to avoid having to have the full encoded data in memory.
16673 // When all of the data has been converted you must call
16674 // g_base64_encode_close() to flush the saved state.
16676 // The output buffer must be large enough to fit all the data that will
16677 // be written to it. Due to the way base64 encodes you will need
16678 // at least: (@len / 3 + 1) * 4 + 4 bytes (+ 4 may be needed in case of
16679 // non-zero state). If you enable line-breaking you will need at least:
16680 // ((@len / 3 + 1) * 4 + 4) / 72 + 1 bytes of extra space.
16682 // @break_lines is typically used when putting base64-encoded data in emails.
16683 // It breaks the lines at 72 columns instead of putting all of the text on
16684 // the same line. This avoids problems with long lines in the email system.
16685 // Note however that it breaks the lines with <literal>LF</literal>
16686 // characters, not <literal>CR LF</literal> sequences, so the result cannot
16687 // be passed directly to SMTP or certain other protocols.
16688 // RETURNS: The number of bytes of output that was written
16689 // <in>: the binary data to encode
16690 // <len>: the length of @in
16691 // <break_lines>: whether to break long lines
16692 // <out>: pointer to destination buffer
16693 // <state>: Saved state between steps, initialize to 0
16694 // <save>: Saved state between steps, initialize to 0
16695 static size_t base64_encode_step()(ubyte* in_, size_t len, int break_lines, /*out*/ ubyte* out_, /*inout*/ int* state, /*inout*/ int* save) {
16696 return g_base64_encode_step(in_, len, break_lines, out_, state, save);
16700 // Gets the name of the file without any leading directory
16701 // components. It returns a pointer into the given file name
16702 // string.
16704 // directory components
16706 // Deprecated:2.2: Use g_path_get_basename() instead, but notice
16707 // that g_path_get_basename() allocates new memory for the
16708 // returned string, unlike this function which returns a pointer
16709 // into the argument.
16710 // RETURNS: the name of the file without any leading
16711 // <file_name>: the name of the file
16712 static char* basename()(char* file_name) {
16713 return g_basename(file_name);
16717 // VERSION: 2.24
16718 // Sets the indicated @lock_bit in @address. If the bit is already
16719 // set, this call will block until g_bit_unlock() unsets the
16720 // corresponding bit.
16722 // Attempting to lock on two different bits within the same integer is
16723 // not supported and will very probably cause deadlocks.
16725 // The value of the bit that is set is (1u << @bit). If @bit is not
16726 // between 0 and 31 then the result is undefined.
16728 // This function accesses @address atomically. All other accesses to
16729 // @address must be atomic in order for this function to work
16730 // reliably.
16731 // <address>: a pointer to an integer
16732 // <lock_bit>: a bit value between 0 and 31
16733 static void bit_lock()(int* address, int lock_bit) {
16734 g_bit_lock(address, lock_bit);
16738 // Find the position of the first bit set in @mask, searching
16739 // from (but not including) @nth_bit upwards. Bits are numbered
16740 // from 0 (least significant) to sizeof(#gulong) * 8 - 1 (31 or 63,
16741 // usually). To start searching from the 0th bit, set @nth_bit to -1.
16742 // RETURNS: the index of the first bit set which is higher than @nth_bit
16743 // <mask>: a #gulong containing flags
16744 // <nth_bit>: the index of the bit to start the search from
16745 static int bit_nth_lsf()(c_ulong mask, int nth_bit) {
16746 return g_bit_nth_lsf(mask, nth_bit);
16750 // Find the position of the first bit set in @mask, searching
16751 // from (but not including) @nth_bit downwards. Bits are numbered
16752 // from 0 (least significant) to sizeof(#gulong) * 8 - 1 (31 or 63,
16753 // usually). To start searching from the last bit, set @nth_bit to
16754 // -1 or GLIB_SIZEOF_LONG * 8.
16755 // RETURNS: the index of the first bit set which is lower than @nth_bit
16756 // <mask>: a #gulong containing flags
16757 // <nth_bit>: the index of the bit to start the search from
16758 static int bit_nth_msf()(c_ulong mask, int nth_bit) {
16759 return g_bit_nth_msf(mask, nth_bit);
16763 // Gets the number of bits used to hold @number,
16764 // e.g. if @number is 4, 3 bits are needed.
16765 // RETURNS: the number of bits used to hold @number
16766 // <number>: a #guint
16767 static uint bit_storage()(c_ulong number) {
16768 return g_bit_storage(number);
16772 // VERSION: 2.24
16773 // Sets the indicated @lock_bit in @address, returning %TRUE if
16774 // successful. If the bit is already set, returns %FALSE immediately.
16776 // Attempting to lock on two different bits within the same integer is
16777 // not supported.
16779 // The value of the bit that is set is (1u << @bit). If @bit is not
16780 // between 0 and 31 then the result is undefined.
16782 // This function accesses @address atomically. All other accesses to
16783 // @address must be atomic in order for this function to work
16784 // reliably.
16785 // RETURNS: %TRUE if the lock was acquired
16786 // <address>: a pointer to an integer
16787 // <lock_bit>: a bit value between 0 and 31
16788 static int bit_trylock()(int* address, int lock_bit) {
16789 return g_bit_trylock(address, lock_bit);
16793 // VERSION: 2.24
16794 // Clears the indicated @lock_bit in @address. If another thread is
16795 // currently blocked in g_bit_lock() on this same bit then it will be
16796 // woken up.
16798 // This function accesses @address atomically. All other accesses to
16799 // @address must be atomic in order for this function to work
16800 // reliably.
16801 // <address>: a pointer to an integer
16802 // <lock_bit>: a bit value between 0 and 31
16803 static void bit_unlock()(int* address, int lock_bit) {
16804 g_bit_unlock(address, lock_bit);
16807 // MOVED TO: BookmarkFile.error_quark
16808 static Quark bookmark_file_error_quark()() {
16809 return g_bookmark_file_error_quark();
16813 // Unintrospectable function: build_filename() / g_build_filename()
16814 // Creates a filename from a series of elements using the correct
16815 // separator for filenames.
16817 // On Unix, this function behaves identically to <literal>g_build_path
16818 // (G_DIR_SEPARATOR_S, first_element, ....)</literal>.
16820 // On Windows, it takes into account that either the backslash
16821 // (<literal>\</literal> or slash (<literal>/</literal>) can be used
16822 // as separator in filenames, but otherwise behaves as on Unix. When
16823 // file pathname separators need to be inserted, the one that last
16824 // previously occurred in the parameters (reading from left to right)
16825 // is used.
16827 // No attempt is made to force the resulting filename to be an absolute
16828 // path. If the first element is a relative path, the result will
16829 // be a relative path.
16830 // RETURNS: a newly-allocated string that must be freed with g_free().
16831 // <first_element>: the first element in the path
16832 alias g_build_filename build_filename; // Variadic
16835 // VERSION: 2.8
16836 // Behaves exactly like g_build_filename(), but takes the path elements
16837 // as a string array, instead of varargs. This function is mainly
16838 // meant for language bindings.
16839 // RETURNS: a newly-allocated string that must be freed with g_free().
16840 // <args>: %NULL-terminated array of strings containing the path elements.
16841 static char* /*new*/ build_filenamev()(char** args) {
16842 return g_build_filenamev(args);
16846 // Unintrospectable function: build_path() / g_build_path()
16847 // Creates a path from a series of elements using @separator as the
16848 // separator between elements. At the boundary between two elements,
16849 // any trailing occurrences of separator in the first element, or
16850 // leading occurrences of separator in the second element are removed
16851 // and exactly one copy of the separator is inserted.
16853 // Empty elements are ignored.
16855 // The number of leading copies of the separator on the result is
16856 // the same as the number of leading copies of the separator on
16857 // the first non-empty element.
16859 // The number of trailing copies of the separator on the result is
16860 // the same as the number of trailing copies of the separator on
16861 // the last non-empty element. (Determination of the number of
16862 // trailing copies is done without stripping leading copies, so
16863 // if the separator is <literal>ABA</literal>, <literal>ABABA</literal>
16864 // has 1 trailing copy.)
16866 // However, if there is only a single non-empty element, and there
16867 // are no characters in that element not part of the leading or
16868 // trailing separators, then the result is exactly the original value
16869 // of that element.
16871 // Other than for determination of the number of leading and trailing
16872 // copies of the separator, elements consisting only of copies
16873 // of the separator are ignored.
16874 // RETURNS: a newly-allocated string that must be freed with g_free().
16875 // <separator>: a string used to separator the elements of the path.
16876 // <first_element>: the first element in the path
16877 alias g_build_path build_path; // Variadic
16880 // VERSION: 2.8
16881 // Behaves exactly like g_build_path(), but takes the path elements
16882 // as a string array, instead of varargs. This function is mainly
16883 // meant for language bindings.
16884 // RETURNS: a newly-allocated string that must be freed with g_free().
16885 // <separator>: a string used to separator the elements of the path.
16886 // <args>: %NULL-terminated array of strings containing the path elements.
16887 static char* /*new*/ build_pathv()(char* separator, char** args) {
16888 return g_build_pathv(separator, args);
16892 // MOVED TO: ByteArray.free
16893 // Frees the memory allocated by the #GByteArray. If @free_segment is
16894 // %TRUE it frees the actual byte data. If the reference count of
16895 // @array is greater than one, the #GByteArray wrapper is preserved but
16896 // the size of @array will be set to zero.
16897 // <array>: a #GByteArray.
16898 // <free_segment>: if %TRUE the actual byte data is freed as well.
16899 static ubyte* byte_array_free()(ByteArray* array, int free_segment) {
16900 return g_byte_array_free(array, free_segment);
16904 // VERSION: 2.32
16905 // MOVED TO: ByteArray.free_to_bytes
16906 // Transfers the data from the #GByteArray into a new immutable #GBytes.
16908 // The #GByteArray is freed unless the reference count of @array is greater
16909 // than one, the #GByteArray wrapper is preserved but the size of @array
16910 // will be set to zero.
16912 // This is identical to using g_bytes_new_take() and g_byte_array_free()
16913 // together.
16916 // data that was in the array
16917 // RETURNS: a new immutable #GBytes representing same byte
16918 // <array>: a #GByteArray
16919 static Bytes* /*new*/ byte_array_free_to_bytes()(ByteArray* array) {
16920 return g_byte_array_free_to_bytes(array);
16924 // VERSION: 2.32
16925 // MOVED TO: ByteArray.new_take
16926 // Create byte array containing the data. The data will be owned by the array
16927 // and will be freed with g_free(), i.e. it could be allocated using g_strdup().
16928 // RETURNS: a new #GByteArray
16929 // <data>: byte data for the array
16930 // <len>: length of @data
16931 static ByteArray* /*new*/ byte_array_new_take()(ubyte* data, size_t len) {
16932 return g_byte_array_new_take(data, len);
16936 // VERSION: 2.22
16937 // MOVED TO: ByteArray.unref
16938 // Atomically decrements the reference count of @array by one. If the
16939 // reference count drops to 0, all memory allocated by the array is
16940 // released. This function is MT-safe and may be called from any
16941 // thread.
16942 // <array>: A #GByteArray.
16943 static void byte_array_unref()(ByteArray* array) {
16944 g_byte_array_unref(array);
16948 // VERSION: 2.8
16949 // A wrapper for the POSIX chdir() function. The function changes the
16950 // current directory of the process to @path.
16952 // See your C library manual for more details about chdir().
16953 // RETURNS: 0 on success, -1 if an error occurred.
16954 // <path>: a pathname in the GLib file name encoding (UTF-8 on Windows)
16955 static int chdir()(char* path) {
16956 return g_chdir(path);
16960 // VERSION: 2.6
16961 // Checks that the GLib library in use is compatible with the
16962 // given version. Generally you would pass in the constants
16963 // #GLIB_MAJOR_VERSION, #GLIB_MINOR_VERSION, #GLIB_MICRO_VERSION
16964 // as the three arguments to this function; that produces
16965 // a check that the library in use is compatible with
16966 // the version of GLib the application or module was compiled
16967 // against.
16969 // Compatibility is defined by two things: first the version
16970 // of the running library is newer than the version
16971 // @required_major.required_minor.@required_micro. Second
16972 // the running library must be binary compatible with the
16973 // version @required_major.required_minor.@required_micro
16974 // (same major version.)
16976 // given version, or a string describing the version mismatch.
16977 // The returned string is owned by GLib and must not be modified
16978 // or freed.
16979 // RETURNS: %NULL if the GLib library is compatible with the
16980 // <required_major>: the required major version.
16981 // <required_minor>: the required minor version.
16982 // <required_micro>: the required micro version.
16983 static char* check_version()(uint required_major, uint required_minor, uint required_micro) {
16984 return glib_check_version(required_major, required_minor, required_micro);
16988 // VERSION: 2.16
16989 // MOVED TO: Checksum.type_get_length
16990 // Gets the length in bytes of digests of type @checksum_type
16992 // not supported.
16993 // RETURNS: the checksum length, or -1 if @checksum_type is
16994 // <checksum_type>: a #GChecksumType
16995 static ssize_t checksum_type_get_length()(ChecksumType checksum_type) {
16996 return g_checksum_type_get_length(checksum_type);
17000 // Unintrospectable function: child_watch_add() / g_child_watch_add()
17001 // VERSION: 2.4
17002 // Sets a function to be called when the child indicated by @pid
17003 // exits, at a default priority, #G_PRIORITY_DEFAULT.
17005 // If you obtain @pid from g_spawn_async() or g_spawn_async_with_pipes()
17006 // you will need to pass #G_SPAWN_DO_NOT_REAP_CHILD as flag to
17007 // the spawn function for the child watching to work.
17009 // Note that on platforms where #GPid must be explicitly closed
17010 // (see g_spawn_close_pid()) @pid must not be closed while the
17011 // source is still active. Typically, you will want to call
17012 // g_spawn_close_pid() in the callback function for the source.
17014 // GLib supports only a single callback per process id.
17016 // This internally creates a main loop source using
17017 // g_child_watch_source_new() and attaches it to the main loop context
17018 // using g_source_attach(). You can do these steps manually if you
17019 // need greater control.
17020 // RETURNS: the ID (greater than 0) of the event source.
17021 // <pid>: process id to watch. On POSIX the pid of a child process. On Windows a handle for a process (which doesn't have to be a child).
17022 // <function>: function to call
17023 // <data>: data to pass to @function
17024 static uint child_watch_add()(Pid pid, ChildWatchFunc function_, void* data) {
17025 return g_child_watch_add(pid, function_, data);
17029 // VERSION: 2.4
17030 // Sets a function to be called when the child indicated by @pid
17031 // exits, at the priority @priority.
17033 // If you obtain @pid from g_spawn_async() or g_spawn_async_with_pipes()
17034 // you will need to pass #G_SPAWN_DO_NOT_REAP_CHILD as flag to
17035 // the spawn function for the child watching to work.
17037 // Note that on platforms where #GPid must be explicitly closed
17038 // (see g_spawn_close_pid()) @pid must not be closed while the
17039 // source is still active. Typically, you will want to call
17040 // g_spawn_close_pid() in the callback function for the source.
17042 // GLib supports only a single callback per process id.
17044 // This internally creates a main loop source using
17045 // g_child_watch_source_new() and attaches it to the main loop context
17046 // using g_source_attach(). You can do these steps manually if you
17047 // need greater control.
17048 // RETURNS: the ID (greater than 0) of the event source.
17049 // <priority>: the priority of the idle source. Typically this will be in the range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.
17050 // <pid>: process to watch. On POSIX the pid of a child process. On Windows a handle for a process (which doesn't have to be a child).
17051 // <function>: function to call
17052 // <data>: data to pass to @function
17053 // <notify>: function to call when the idle is removed, or %NULL
17054 static uint child_watch_add_full()(int priority, Pid pid, ChildWatchFunc function_, void* data, DestroyNotify notify) {
17055 return g_child_watch_add_full(priority, pid, function_, data, notify);
17059 // VERSION: 2.4
17060 // Creates a new child_watch source.
17062 // The source will not initially be associated with any #GMainContext
17063 // and must be added to one with g_source_attach() before it will be
17064 // executed.
17066 // Note that child watch sources can only be used in conjunction with
17067 // <literal>g_spawn...</literal> when the %G_SPAWN_DO_NOT_REAP_CHILD
17068 // flag is used.
17070 // Note that on platforms where #GPid must be explicitly closed
17071 // (see g_spawn_close_pid()) @pid must not be closed while the
17072 // source is still active. Typically, you will want to call
17073 // g_spawn_close_pid() in the callback function for the source.
17075 // Note further that using g_child_watch_source_new() is not
17076 // compatible with calling <literal>waitpid(-1)</literal> in
17077 // the application. Calling waitpid() for individual pids will
17078 // still work fine.
17079 // RETURNS: the newly-created child watch source
17080 // <pid>: process to watch. On POSIX the pid of a child process. On Windows a handle for a process (which doesn't have to be a child).
17081 static Source* /*new*/ child_watch_source_new()(Pid pid) {
17082 return g_child_watch_source_new(pid);
17086 // If @err is %NULL, does nothing. If @err is non-%NULL,
17087 // calls g_error_free() on *@err and sets *@err to %NULL.
17088 static void clear_error()(GLib2.Error** error=null) {
17089 g_clear_error(error);
17093 // VERSION: 2.16
17094 // Computes the checksum for a binary @data of @length. This is a
17095 // convenience wrapper for g_checksum_new(), g_checksum_get_string()
17096 // and g_checksum_free().
17098 // The hexadecimal string returned will be in lower case.
17100 // The returned string should be freed with g_free() when done using it.
17101 // RETURNS: the digest of the binary data as a string in hexadecimal.
17102 // <checksum_type>: a #GChecksumType
17103 // <data>: binary blob to compute the digest of
17104 // <length>: length of @data
17105 static char* /*new*/ compute_checksum_for_data()(ChecksumType checksum_type, ubyte* data, size_t length) {
17106 return g_compute_checksum_for_data(checksum_type, data, length);
17110 // VERSION: 2.16
17111 // Computes the checksum of a string.
17113 // The hexadecimal string returned will be in lower case.
17115 // should be freed with g_free() when done using it.
17116 // RETURNS: the checksum as a hexadecimal string. The returned string
17117 // <checksum_type>: a #GChecksumType
17118 // <str>: the string to compute the checksum of
17119 // <length>: the length of the string, or -1 if the string is null-terminated.
17120 static char* /*new*/ compute_checksum_for_string()(ChecksumType checksum_type, char* str, ssize_t length) {
17121 return g_compute_checksum_for_string(checksum_type, str, length);
17125 // VERSION: 2.30
17126 // Computes the HMAC for a binary @data of @length. This is a
17127 // convenience wrapper for g_hmac_new(), g_hmac_get_string()
17128 // and g_hmac_unref().
17130 // The hexadecimal string returned will be in lower case.
17132 // The returned string should be freed with g_free() when done using it.
17133 // RETURNS: the HMAC of the binary data as a string in hexadecimal.
17134 // <digest_type>: a #GChecksumType to use for the HMAC
17135 // <key>: the key to use in the HMAC
17136 // <key_len>: the length of the key
17137 // <data>: binary blob to compute the HMAC of
17138 // <length>: length of @data
17139 static char* /*new*/ compute_hmac_for_data()(ChecksumType digest_type, ubyte* key, size_t key_len, ubyte* data, size_t length) {
17140 return g_compute_hmac_for_data(digest_type, key, key_len, data, length);
17144 // VERSION: 2.30
17145 // Computes the HMAC for a string.
17147 // The hexadecimal string returned will be in lower case.
17149 // The returned string should be freed with g_free()
17150 // when done using it.
17151 // RETURNS: the HMAC as a hexadecimal string.
17152 // <digest_type>: a #GChecksumType to use for the HMAC
17153 // <key>: the key to use in the HMAC
17154 // <key_len>: the length of the key
17155 // <str>: the string to compute the HMAC for
17156 // <length>: the length of the string, or -1 if the string is nul-terminated
17157 static char* /*new*/ compute_hmac_for_string()(ChecksumType digest_type, ubyte* key, size_t key_len, char* str, ssize_t length) {
17158 return g_compute_hmac_for_string(digest_type, key, key_len, str, length);
17162 // Converts a string from one character set to another.
17164 // Note that you should use g_iconv() for streaming
17165 // conversions<footnoteref linkend="streaming-state"/>.
17167 // nul-terminated string, which must be freed with
17168 // g_free(). Otherwise %NULL and @error will be set.
17169 // RETURNS: If the conversion was successful, a newly allocated
17170 // <str>: the string to convert
17171 // <len>: the length of the string, or -1 if the string is nul-terminated<footnote id="nul-unsafe">
17172 // <to_codeset>: name of character set into which to convert @str
17173 // <from_codeset>: character set of @str.
17174 // <bytes_read>: location to store the number of bytes in the input string that were successfully converted, or %NULL. Even if the conversion was successful, this may be less than @len if there were partial characters at the end of the input. If the error #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value stored will the byte offset after the last valid input sequence.
17175 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
17176 static char* /*new*/ convert()(char* str, ssize_t len, char* to_codeset, char* from_codeset, /*out*/ size_t* bytes_read, /*out*/ size_t* bytes_written, GLib2.Error** error=null) {
17177 return g_convert(str, len, to_codeset, from_codeset, bytes_read, bytes_written, error);
17180 static Quark convert_error_quark()() {
17181 return g_convert_error_quark();
17185 // Converts a string from one character set to another, possibly
17186 // including fallback sequences for characters not representable
17187 // in the output. Note that it is not guaranteed that the specification
17188 // for the fallback sequences in @fallback will be honored. Some
17189 // systems may do an approximate conversion from @from_codeset
17190 // to @to_codeset in their iconv() functions,
17191 // in which case GLib will simply return that approximate conversion.
17193 // Note that you should use g_iconv() for streaming
17194 // conversions<footnoteref linkend="streaming-state"/>.
17196 // nul-terminated string, which must be freed with
17197 // g_free(). Otherwise %NULL and @error will be set.
17198 // RETURNS: If the conversion was successful, a newly allocated
17199 // <str>: the string to convert
17200 // <len>: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
17201 // <to_codeset>: name of character set into which to convert @str
17202 // <from_codeset>: character set of @str.
17203 // <fallback>: UTF-8 string to use in place of character not present in the target encoding. (The string must be representable in the target encoding).
17204 // <bytes_read>: location to store the number of bytes in the input string that were successfully converted, or %NULL. Even if the conversion was successful, this may be less than @len if there were partial characters at the end of the input.
17205 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
17206 static char* /*new*/ convert_with_fallback()(char* str, ssize_t len, char* to_codeset, char* from_codeset, char* fallback, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error=null) {
17207 return g_convert_with_fallback(str, len, to_codeset, from_codeset, fallback, bytes_read, bytes_written, error);
17211 // Converts a string from one character set to another.
17213 // Note that you should use g_iconv() for streaming
17214 // conversions<footnote id="streaming-state">
17215 // <para>
17216 // Despite the fact that @byes_read can return information about partial
17217 // characters, the <literal>g_convert_...</literal> functions
17218 // are not generally suitable for streaming. If the underlying converter
17219 // being used maintains internal state, then this won't be preserved
17220 // across successive calls to g_convert(), g_convert_with_iconv() or
17221 // g_convert_with_fallback(). (An example of this is the GNU C converter
17222 // for CP1255 which does not emit a base character until it knows that
17223 // the next character is not a mark that could combine with the base
17224 // character.)
17225 // </para>
17226 // </footnote>.
17228 // nul-terminated string, which must be freed with
17229 // g_free(). Otherwise %NULL and @error will be set.
17230 // RETURNS: If the conversion was successful, a newly allocated
17231 // <str>: the string to convert
17232 // <len>: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
17233 // <converter>: conversion descriptor from g_iconv_open()
17234 // <bytes_read>: location to store the number of bytes in the input string that were successfully converted, or %NULL. Even if the conversion was successful, this may be less than @len if there were partial characters at the end of the input. If the error #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value stored will the byte offset after the last valid input sequence.
17235 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
17236 static char* /*new*/ convert_with_iconv()(char* str, ssize_t len, IConv converter, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error=null) {
17237 return g_convert_with_iconv(str, len, converter, bytes_read, bytes_written, error);
17241 // Frees all the data elements of the datalist.
17242 // The data elements' destroy functions are called
17243 // if they have been set.
17244 // <datalist>: a datalist.
17245 static void datalist_clear()(Data** datalist) {
17246 g_datalist_clear(datalist);
17250 // Unintrospectable function: datalist_foreach() / g_datalist_foreach()
17251 // Calls the given function for each data element of the datalist. The
17252 // function is called with each data element's #GQuark id and data,
17253 // together with the given @user_data parameter. Note that this
17254 // function is NOT thread-safe. So unless @datalist can be protected
17255 // from any modifications during invocation of this function, it should
17256 // not be called.
17257 // <datalist>: a datalist.
17258 // <func>: the function to call for each data element.
17259 // <user_data>: user data to pass to the function.
17260 static void datalist_foreach()(Data** datalist, DataForeachFunc func, void* user_data) {
17261 g_datalist_foreach(datalist, func, user_data);
17265 // Unintrospectable function: datalist_get_data() / g_datalist_get_data()
17266 // Gets a data element, using its string identifer. This is slower than
17267 // g_datalist_id_get_data() because it compares strings.
17268 // <datalist>: a datalist.
17269 // <key>: the string identifying a data element.
17270 static void* datalist_get_data()(Data** datalist, char* key) {
17271 return g_datalist_get_data(datalist, key);
17275 // VERSION: 2.8
17276 // Gets flags values packed in together with the datalist.
17277 // See g_datalist_set_flags().
17278 // RETURNS: the flags of the datalist
17279 // <datalist>: pointer to the location that holds a list
17280 static uint datalist_get_flags()(Data** datalist) {
17281 return g_datalist_get_flags(datalist);
17285 // Unintrospectable function: datalist_id_get_data() / g_datalist_id_get_data()
17286 // Retrieves the data element corresponding to @key_id.
17287 // <datalist>: a datalist.
17288 // <key_id>: the #GQuark identifying a data element.
17289 static void* datalist_id_get_data()(Data** datalist, Quark key_id) {
17290 return g_datalist_id_get_data(datalist, key_id);
17294 // Unintrospectable function: datalist_id_remove_no_notify() / g_datalist_id_remove_no_notify()
17295 // Removes an element, without calling its destroy notification
17296 // function.
17297 // <datalist>: a datalist.
17298 // <key_id>: the #GQuark identifying a data element.
17299 static void* datalist_id_remove_no_notify()(Data** datalist, Quark key_id) {
17300 return g_datalist_id_remove_no_notify(datalist, key_id);
17304 // Sets the data corresponding to the given #GQuark id, and the
17305 // function to be called when the element is removed from the datalist.
17306 // Any previous data with the same key is removed, and its destroy
17307 // function is called.
17308 // <datalist>: a datalist.
17309 // <key_id>: the #GQuark to identify the data element.
17310 // <data>: the data element or %NULL to remove any previous element corresponding to @key_id.
17311 // <destroy_func>: the function to call when the data element is removed. This function will be called with the data element and can be used to free any memory allocated for it. If @data is %NULL, then @destroy_func must also be %NULL.
17312 static void datalist_id_set_data_full()(Data** datalist, Quark key_id, void* data, DestroyNotify destroy_func) {
17313 g_datalist_id_set_data_full(datalist, key_id, data, destroy_func);
17317 // Resets the datalist to %NULL. It does not free any memory or call
17318 // any destroy functions.
17319 // <datalist>: a pointer to a pointer to a datalist.
17320 static void datalist_init()(Data** datalist) {
17321 g_datalist_init(datalist);
17325 // VERSION: 2.8
17326 // Turns on flag values for a data list. This function is used
17327 // to keep a small number of boolean flags in an object with
17328 // a data list without using any additional space. It is
17329 // not generally useful except in circumstances where space
17330 // is very tight. (It is used in the base #GObject type, for
17331 // example.)
17332 // <datalist>: pointer to the location that holds a list
17333 // <flags>: the flags to turn on. The values of the flags are restricted by %G_DATALIST_FLAGS_MASK (currently 3; giving two possible boolean flags). A value for @flags that doesn't fit within the mask is an error.
17334 static void datalist_set_flags()(Data** datalist, uint flags) {
17335 g_datalist_set_flags(datalist, flags);
17339 // VERSION: 2.8
17340 // Turns off flag values for a data list. See g_datalist_unset_flags()
17341 // <datalist>: pointer to the location that holds a list
17342 // <flags>: the flags to turn off. The values of the flags are restricted by %G_DATALIST_FLAGS_MASK (currently 3: giving two possible boolean flags). A value for @flags that doesn't fit within the mask is an error.
17343 static void datalist_unset_flags()(Data** datalist, uint flags) {
17344 g_datalist_unset_flags(datalist, flags);
17348 // Destroys the dataset, freeing all memory allocated, and calling any
17349 // destroy functions set for data elements.
17350 // <dataset_location>: the location identifying the dataset.
17351 static void dataset_destroy()(const(void)* dataset_location) {
17352 g_dataset_destroy(dataset_location);
17356 // Unintrospectable function: dataset_foreach() / g_dataset_foreach()
17357 // Calls the given function for each data element which is associated
17358 // with the given location. Note that this function is NOT thread-safe.
17359 // So unless @datalist can be protected from any modifications during
17360 // invocation of this function, it should not be called.
17361 // <dataset_location>: the location identifying the dataset.
17362 // <func>: the function to call for each data element.
17363 // <user_data>: user data to pass to the function.
17364 static void dataset_foreach()(const(void)* dataset_location, DataForeachFunc func, void* user_data) {
17365 g_dataset_foreach(dataset_location, func, user_data);
17369 // Unintrospectable function: dataset_id_get_data() / g_dataset_id_get_data()
17370 // Gets the data element corresponding to a #GQuark.
17371 // <dataset_location>: the location identifying the dataset.
17372 // <key_id>: the #GQuark id to identify the data element.
17373 static void* dataset_id_get_data()(const(void)* dataset_location, Quark key_id) {
17374 return g_dataset_id_get_data(dataset_location, key_id);
17378 // Unintrospectable function: dataset_id_remove_no_notify() / g_dataset_id_remove_no_notify()
17379 // Removes an element, without calling its destroy notification
17380 // function.
17381 // <dataset_location>: the location identifying the dataset.
17382 // <key_id>: the #GQuark ID identifying the data element.
17383 static void* dataset_id_remove_no_notify()(const(void)* dataset_location, Quark key_id) {
17384 return g_dataset_id_remove_no_notify(dataset_location, key_id);
17388 // Sets the data element associated with the given #GQuark id, and also
17389 // the function to call when the data element is destroyed. Any
17390 // previous data with the same key is removed, and its destroy function
17391 // is called.
17392 // <dataset_location>: the location identifying the dataset.
17393 // <key_id>: the #GQuark id to identify the data element.
17394 // <data>: the data element.
17395 // <destroy_func>: the function to call when the data element is removed. This function will be called with the data element and can be used to free any memory allocated for it.
17396 static void dataset_id_set_data_full()(const(void)* dataset_location, Quark key_id, void* data, DestroyNotify destroy_func) {
17397 g_dataset_id_set_data_full(dataset_location, key_id, data, destroy_func);
17401 // MOVED TO: Date.get_days_in_month
17402 // Returns the number of days in a month, taking leap
17403 // years into account.
17404 // RETURNS: number of days in @month during the @year
17405 // <month>: month
17406 // <year>: year
17407 static ubyte date_get_days_in_month()(DateMonth month, DateYear year) {
17408 return g_date_get_days_in_month(month, year);
17412 // MOVED TO: Date.get_monday_weeks_in_year
17413 // Returns the number of weeks in the year, where weeks
17414 // are taken to start on Monday. Will be 52 or 53. The
17415 // date must be valid. (Years always have 52 7-day periods,
17416 // plus 1 or 2 extra days depending on whether it's a leap
17417 // year. This function is basically telling you how many
17418 // Mondays are in the year, i.e. there are 53 Mondays if
17419 // one of the extra days happens to be a Monday.)
17420 // RETURNS: number of Mondays in the year
17421 // <year>: a year
17422 static ubyte date_get_monday_weeks_in_year()(DateYear year) {
17423 return g_date_get_monday_weeks_in_year(year);
17427 // MOVED TO: Date.get_sunday_weeks_in_year
17428 // Returns the number of weeks in the year, where weeks
17429 // are taken to start on Sunday. Will be 52 or 53. The
17430 // date must be valid. (Years always have 52 7-day periods,
17431 // plus 1 or 2 extra days depending on whether it's a leap
17432 // year. This function is basically telling you how many
17433 // Sundays are in the year, i.e. there are 53 Sundays if
17434 // one of the extra days happens to be a Sunday.)
17435 // RETURNS: the number of weeks in @year
17436 // <year>: year to count weeks in
17437 static ubyte date_get_sunday_weeks_in_year()(DateYear year) {
17438 return g_date_get_sunday_weeks_in_year(year);
17442 // MOVED TO: Date.is_leap_year
17443 // Returns %TRUE if the year is a leap year.
17444 // <footnote><para>For the purposes of this function,
17445 // leap year is every year divisible by 4 unless that year
17446 // is divisible by 100. If it is divisible by 100 it would
17447 // be a leap year only if that year is also divisible
17448 // by 400.</para></footnote>
17449 // RETURNS: %TRUE if the year is a leap year
17450 // <year>: year to check
17451 static int date_is_leap_year()(DateYear year) {
17452 return g_date_is_leap_year(year);
17456 // MOVED TO: Date.strftime
17457 // Generates a printed representation of the date, in a
17458 // <link linkend="setlocale">locale</link>-specific way.
17459 // Works just like the platform's C library strftime() function,
17460 // but only accepts date-related formats; time-related formats
17461 // give undefined results. Date must be valid. Unlike strftime()
17462 // (which uses the locale encoding), works on a UTF-8 format
17463 // string and stores a UTF-8 result.
17465 // This function does not provide any conversion specifiers in
17466 // addition to those implemented by the platform's C library.
17467 // For example, don't expect that using g_date_strftime() would
17468 // make the \%F provided by the C99 strftime() work on Windows
17469 // where the C library only complies to C89.
17470 // RETURNS: number of characters written to the buffer, or 0 the buffer was too small
17471 // <s>: destination buffer
17472 // <slen>: buffer size
17473 // <format>: format string
17474 // <date>: valid #GDate
17475 static size_t date_strftime()(char* s, size_t slen, char* format, Date* date) {
17476 return g_date_strftime(s, slen, format, date);
17480 // VERSION: 2.26
17481 // MOVED TO: DateTime.compare
17482 // A comparison function for #GDateTimes that is suitable
17483 // as a #GCompareFunc. Both #GDateTimes must be non-%NULL.
17485 // than @dt2.
17486 // RETURNS: -1, 0 or 1 if @dt1 is less than, equal to or greater
17487 // <dt1>: first #GDateTime to compare
17488 // <dt2>: second #GDateTime to compare
17489 static int date_time_compare()(const(void)* dt1, const(void)* dt2) {
17490 return g_date_time_compare(dt1, dt2);
17494 // VERSION: 2.26
17495 // MOVED TO: DateTime.equal
17496 // Checks to see if @dt1 and @dt2 are equal.
17498 // Equal here means that they represent the same moment after converting
17499 // them to the same time zone.
17500 // RETURNS: %TRUE if @dt1 and @dt2 are equal
17501 // <dt1>: a #GDateTime
17502 // <dt2>: a #GDateTime
17503 static int date_time_equal()(const(void)* dt1, const(void)* dt2) {
17504 return g_date_time_equal(dt1, dt2);
17508 // VERSION: 2.26
17509 // MOVED TO: DateTime.hash
17510 // Hashes @datetime into a #guint, suitable for use within #GHashTable.
17511 // RETURNS: a #guint containing the hash
17512 // <datetime>: a #GDateTime
17513 static uint date_time_hash()(const(void)* datetime) {
17514 return g_date_time_hash(datetime);
17518 // MOVED TO: Date.valid_day
17519 // Returns %TRUE if the day of the month is valid (a day is valid if it's
17520 // between 1 and 31 inclusive).
17521 // RETURNS: %TRUE if the day is valid
17522 // <day>: day to check
17523 static int date_valid_day()(DateDay day) {
17524 return g_date_valid_day(day);
17528 // MOVED TO: Date.valid_dmy
17529 // Returns %TRUE if the day-month-year triplet forms a valid, existing day
17530 // in the range of days #GDate understands (Year 1 or later, no more than
17531 // a few thousand years in the future).
17532 // RETURNS: %TRUE if the date is a valid one
17533 // <day>: day
17534 // <month>: month
17535 // <year>: year
17536 static int date_valid_dmy()(DateDay day, DateMonth month, DateYear year) {
17537 return g_date_valid_dmy(day, month, year);
17541 // MOVED TO: Date.valid_julian
17542 // Returns %TRUE if the Julian day is valid. Anything greater than zero
17543 // is basically a valid Julian, though there is a 32-bit limit.
17544 // RETURNS: %TRUE if the Julian day is valid
17545 // <julian_date>: Julian day to check
17546 static int date_valid_julian()(uint julian_date) {
17547 return g_date_valid_julian(julian_date);
17551 // MOVED TO: Date.valid_month
17552 // Returns %TRUE if the month value is valid. The 12 #GDateMonth
17553 // enumeration values are the only valid months.
17554 // RETURNS: %TRUE if the month is valid
17555 // <month>: month
17556 static int date_valid_month()(DateMonth month) {
17557 return g_date_valid_month(month);
17561 // MOVED TO: Date.valid_weekday
17562 // Returns %TRUE if the weekday is valid. The seven #GDateWeekday enumeration
17563 // values are the only valid weekdays.
17564 // RETURNS: %TRUE if the weekday is valid
17565 // <weekday>: weekday
17566 static int date_valid_weekday()(DateWeekday weekday) {
17567 return g_date_valid_weekday(weekday);
17571 // MOVED TO: Date.valid_year
17572 // Returns %TRUE if the year is valid. Any year greater than 0 is valid,
17573 // though there is a 16-bit limit to what #GDate will understand.
17574 // RETURNS: %TRUE if the year is valid
17575 // <year>: year
17576 static int date_valid_year()(DateYear year) {
17577 return g_date_valid_year(year);
17581 // VERSION: 2.26
17582 // This is a variant of g_dgettext() that allows specifying a locale
17583 // category instead of always using <envar>LC_MESSAGES</envar>. See g_dgettext() for
17584 // more information about how this functions differs from calling
17585 // dcgettext() directly.
17586 // RETURNS: the translated string for the given locale category
17587 // <domain>: the translation domain to use, or %NULL to use the domain set with textdomain()
17588 // <msgid>: message to translate
17589 // <category>: a locale category
17590 static char* dcgettext()(char* domain, char* msgid, int category) {
17591 return g_dcgettext(domain, msgid, category);
17595 // VERSION: 2.18
17596 // This function is a wrapper of dgettext() which does not translate
17597 // the message if the default domain as set with textdomain() has no
17598 // translations for the current locale.
17600 // The advantage of using this function over dgettext() proper is that
17601 // libraries using this function (like GTK+) will not use translations
17602 // if the application using the library does not have translations for
17603 // the current locale. This results in a consistent English-only
17604 // interface instead of one having partial translations. For this
17605 // feature to work, the call to textdomain() and setlocale() should
17606 // precede any g_dgettext() invocations. For GTK+, it means calling
17607 // textdomain() before gtk_init or its variants.
17609 // This function disables translations if and only if upon its first
17610 // call all the following conditions hold:
17611 // <itemizedlist>
17612 // <listitem>@domain is not %NULL</listitem>
17613 // <listitem>textdomain() has been called to set a default text domain</listitem>
17614 // <listitem>there is no translations available for the default text domain
17615 // and the current locale</listitem>
17616 // <listitem>current locale is not "C" or any English locales (those
17617 // starting with "en_")</listitem>
17618 // </itemizedlist>
17620 // Note that this behavior may not be desired for example if an application
17621 // has its untranslated messages in a language other than English. In those
17622 // cases the application should call textdomain() after initializing GTK+.
17624 // Applications should normally not use this function directly,
17625 // but use the _() macro for translations.
17626 // RETURNS: The translated string
17627 // <domain>: the translation domain to use, or %NULL to use the domain set with textdomain()
17628 // <msgid>: message to translate
17629 static char* dgettext()(char* domain, char* msgid) {
17630 return g_dgettext(domain, msgid);
17634 // VERSION: 2.30
17635 // MOVED TO: Dir.make_tmp
17636 // Creates a subdirectory in the preferred directory for temporary
17637 // files (as returned by g_get_tmp_dir()).
17639 // @tmpl should be a string in the GLib file name encoding containing
17640 // a sequence of six 'X' characters, as the parameter to g_mkstemp().
17641 // However, unlike these functions, the template should only be a
17642 // basename, no directory components are allowed. If template is
17643 // %NULL, a default template is used.
17645 // Note that in contrast to g_mkdtemp() (and mkdtemp()) @tmpl is not
17646 // modified, and might thus be a read-only literal string.
17648 // should be freed with g_free() when not needed any longer and is
17649 // is in the GLib file name encoding. In case of errors, %NULL is
17650 // returned and @error will be set.
17651 // RETURNS: The actual name used. This string
17652 // <tmpl>: Template for directory name, as in g_mkdtemp(), basename only, or %NULL for a default template
17653 static char* /*new*/ dir_make_tmp()(char* tmpl, GLib2.Error** error=null) {
17654 return g_dir_make_tmp(tmpl, error);
17658 // Compares two #gpointer arguments and returns %TRUE if they are equal.
17659 // It can be passed to g_hash_table_new() as the @key_equal_func
17660 // parameter, when using opaque pointers compared by pointer value as keys
17661 // in a #GHashTable.
17663 // This equality function is also appropriate for keys that are integers stored
17664 // in pointers, such as <literal>GINT_TO_POINTER (n)</literal>.
17665 // RETURNS: %TRUE if the two keys match.
17666 // <v1>: a key
17667 // <v2>: a key to compare with @v1
17668 static int direct_equal()(const(void)* v1=null, const(void)* v2=null) {
17669 return g_direct_equal(v1, v2);
17673 // Converts a gpointer to a hash value.
17674 // It can be passed to g_hash_table_new() as the @hash_func parameter,
17675 // when using opaque pointers compared by pointer value as keys in a
17676 // #GHashTable.
17678 // This hash function is also appropriate for keys that are integers stored
17679 // in pointers, such as <literal>GINT_TO_POINTER (n)</literal>.
17680 // RETURNS: a hash value corresponding to the key.
17681 // <v>: a #gpointer key
17682 static uint direct_hash()(const(void)* v=null) {
17683 return g_direct_hash(v);
17687 // VERSION: 2.18
17688 // This function is a wrapper of dngettext() which does not translate
17689 // the message if the default domain as set with textdomain() has no
17690 // translations for the current locale.
17692 // See g_dgettext() for details of how this differs from dngettext()
17693 // proper.
17694 // RETURNS: The translated string
17695 // <domain>: the translation domain to use, or %NULL to use the domain set with textdomain()
17696 // <msgid>: message to translate
17697 // <msgid_plural>: plural form of the message
17698 // <n>: the quantity for which translation is needed
17699 static char* dngettext()(char* domain, char* msgid, char* msgid_plural, c_ulong n) {
17700 return g_dngettext(domain, msgid, msgid_plural, n);
17704 // VERSION: 2.22
17705 // Compares the two #gdouble values being pointed to and returns
17706 // %TRUE if they are equal.
17707 // It can be passed to g_hash_table_new() as the @key_equal_func
17708 // parameter, when using non-%NULL pointers to doubles as keys in a
17709 // #GHashTable.
17710 // RETURNS: %TRUE if the two keys match.
17711 // <v1>: a pointer to a #gdouble key
17712 // <v2>: a pointer to a #gdouble key to compare with @v1
17713 static int double_equal()(const(void)* v1, const(void)* v2) {
17714 return g_double_equal(v1, v2);
17718 // VERSION: 2.22
17719 // Converts a pointer to a #gdouble to a hash value.
17720 // It can be passed to g_hash_table_new() as the @hash_func parameter,
17721 // It can be passed to g_hash_table_new() as the @hash_func parameter,
17722 // when using non-%NULL pointers to doubles as keys in a #GHashTable.
17723 // RETURNS: a hash value corresponding to the key.
17724 // <v>: a pointer to a #gdouble key
17725 static uint double_hash()(const(void)* v) {
17726 return g_double_hash(v);
17730 // VERSION: 2.16
17731 // This function is a variant of g_dgettext() which supports
17732 // a disambiguating message context. GNU gettext uses the
17733 // '\004' character to separate the message context and
17734 // message id in @msgctxtid.
17735 // If 0 is passed as @msgidoffset, this function will fall back to
17736 // trying to use the deprecated convention of using "|" as a separation
17737 // character.
17739 // This uses g_dgettext() internally. See that functions for differences
17740 // with dgettext() proper.
17742 // Applications should normally not use this function directly,
17743 // but use the C_() macro for translations with context.
17744 // RETURNS: The translated string
17745 // <domain>: the translation domain to use, or %NULL to use the domain set with textdomain()
17746 // <msgctxtid>: a combined message context and message id, separated by a \004 character
17747 // <msgidoffset>: the offset of the message id in @msgctxid
17748 static char* dpgettext()(char* domain, char* msgctxtid, size_t msgidoffset) {
17749 return g_dpgettext(domain, msgctxtid, msgidoffset);
17753 // VERSION: 2.18
17754 // This function is a variant of g_dgettext() which supports
17755 // a disambiguating message context. GNU gettext uses the
17756 // '\004' character to separate the message context and
17757 // message id in @msgctxtid.
17759 // This uses g_dgettext() internally. See that functions for differences
17760 // with dgettext() proper.
17762 // This function differs from C_() in that it is not a macro and
17763 // thus you may use non-string-literals as context and msgid arguments.
17764 // RETURNS: The translated string
17765 // <domain>: the translation domain to use, or %NULL to use the domain set with textdomain()
17766 // <context>: the message context
17767 // <msgid>: the message
17768 static char* dpgettext2()(char* domain, char* context, char* msgid) {
17769 return g_dpgettext2(domain, context, msgid);
17773 // VERSION: 2.32
17774 // Returns the value of the environment variable @variable in the
17775 // provided list @envp.
17777 // The name and value are in the GLib file name encoding.
17778 // On UNIX, this means the actual bytes which might or might not
17779 // be in some consistent character set and encoding. On Windows,
17780 // it is in UTF-8. On Windows, in case the environment variable's
17781 // value contains references to other environment variables, they
17782 // are expanded.
17784 // the environment variable is not set in @envp. The returned
17785 // string is owned by @envp, and will be freed if @variable is
17786 // set or unset again.
17787 // RETURNS: the value of the environment variable, or %NULL if
17788 // <envp>: an environment list (eg, as returned from g_get_environ())
17789 // <variable>: the environment variable to get, in the GLib file name encoding
17790 static char* environ_getenv()(char** envp, char* variable) {
17791 return g_environ_getenv(envp, variable);
17795 // VERSION: 2.32
17796 // Sets the environment variable @variable in the provided list
17797 // @envp to @value.
17799 // Both the variable's name and value should be in the GLib
17800 // file name encoding. On UNIX, this means that they can be
17801 // arbitrary byte strings. On Windows, they should be in UTF-8.
17803 // updated environment
17804 // RETURNS: the
17805 // <envp>: an environment list (eg, as returned from g_get_environ())
17806 // <variable>: the environment variable to set, must not contain '='
17807 // <value>: the value for to set the variable to
17808 // <overwrite>: whether to change the variable if it already exists
17809 static char** /*new*/ environ_setenv()(char** envp, char* variable, char* value, int overwrite) {
17810 return g_environ_setenv(envp, variable, value, overwrite);
17814 // VERSION: 2.32
17815 // Removes the environment variable @variable from the provided
17816 // environment @envp.
17818 // updated environment
17819 // RETURNS: the
17820 // <envp>: an environment list (eg, as returned from g_get_environ())
17821 // <variable>: the environment variable to remove, must not contain '='
17822 static char** /*new*/ environ_unsetenv()(char** envp, char* variable) {
17823 return g_environ_unsetenv(envp, variable);
17827 // Gets a #GFileError constant based on the passed-in @err_no.
17828 // For example, if you pass in <literal>EEXIST</literal> this function returns
17829 // #G_FILE_ERROR_EXIST. Unlike <literal>errno</literal> values, you can portably
17830 // assume that all #GFileError values will exist.
17832 // Normally a #GFileError value goes into a #GError returned
17833 // from a function that manipulates files. So you would use
17834 // g_file_error_from_errno() when constructing a #GError.
17835 // RETURNS: #GFileError corresponding to the given @errno
17836 // <err_no>: an "errno" value
17837 static FileError file_error_from_errno()(int err_no) {
17838 return g_file_error_from_errno(err_no);
17841 static Quark file_error_quark()() {
17842 return g_file_error_quark();
17846 // Reads an entire file into allocated memory, with good error
17847 // checking.
17849 // If the call was successful, it returns %TRUE and sets @contents to the file
17850 // contents and @length to the length of the file contents in bytes. The string
17851 // stored in @contents will be nul-terminated, so for text files you can pass
17852 // %NULL for the @length argument. If the call was not successful, it returns
17853 // %FALSE and sets @error. The error domain is #G_FILE_ERROR. Possible error
17854 // codes are those in the #GFileError enumeration. In the error case,
17855 // @contents is set to %NULL and @length is set to zero.
17856 // RETURNS: %TRUE on success, %FALSE if an error occurred
17857 // <filename>: name of a file to read contents from, in the GLib file name encoding
17858 // <contents>: location to store an allocated string, use g_free() to free the returned string
17859 // <length>: location to store length in bytes of the contents, or %NULL
17860 static int file_get_contents()(char* filename, /*out*/ ubyte** contents, /*out*/ size_t* length, GLib2.Error** error=null) {
17861 return g_file_get_contents(filename, contents, length, error);
17865 // Opens a file for writing in the preferred directory for temporary
17866 // files (as returned by g_get_tmp_dir()).
17868 // @tmpl should be a string in the GLib file name encoding containing
17869 // a sequence of six 'X' characters, as the parameter to g_mkstemp().
17870 // However, unlike these functions, the template should only be a
17871 // basename, no directory components are allowed. If template is
17872 // %NULL, a default template is used.
17874 // Note that in contrast to g_mkstemp() (and mkstemp()) @tmpl is not
17875 // modified, and might thus be a read-only literal string.
17877 // Upon success, and if @name_used is non-%NULL, the actual name used
17878 // is returned in @name_used. This string should be freed with g_free()
17879 // when not needed any longer. The returned name is in the GLib file
17880 // name encoding.
17882 // reading and writing. The file is opened in binary mode on platforms
17883 // where there is a difference. The file handle should be closed with
17884 // close(). In case of errors, -1 is returned and @error will be set.
17885 // RETURNS: A file handle (as from open()) to the file opened for
17886 // <tmpl>: Template for file name, as in g_mkstemp(), basename only, or %NULL for a default template
17887 // <name_used>: location to store actual name used, or %NULL
17888 static int file_open_tmp()(char* tmpl, /*out*/ char** name_used, GLib2.Error** error=null) {
17889 return g_file_open_tmp(tmpl, name_used, error);
17893 // VERSION: 2.4
17894 // Reads the contents of the symbolic link @filename like the POSIX
17895 // readlink() function. The returned string is in the encoding used
17896 // for filenames. Use g_filename_to_utf8() to convert it to UTF-8.
17898 // or %NULL if an error occurred.
17899 // RETURNS: A newly-allocated string with the contents of the symbolic link,
17900 // <filename>: the symbolic link
17901 static char* /*new*/ file_read_link()(char* filename, GLib2.Error** error=null) {
17902 return g_file_read_link(filename, error);
17906 // VERSION: 2.8
17907 // Writes all of @contents to a file named @filename, with good error checking.
17908 // If a file called @filename already exists it will be overwritten.
17910 // This write is atomic in the sense that it is first written to a temporary
17911 // file which is then renamed to the final name. Notes:
17912 // <itemizedlist>
17913 // <listitem>
17914 // On Unix, if @filename already exists hard links to @filename will break.
17915 // Also since the file is recreated, existing permissions, access control
17916 // lists, metadata etc. may be lost. If @filename is a symbolic link,
17917 // the link itself will be replaced, not the linked file.
17918 // </listitem>
17919 // <listitem>
17920 // On Windows renaming a file will not remove an existing file with the
17921 // new name, so on Windows there is a race condition between the existing
17922 // file being removed and the temporary file being renamed.
17923 // </listitem>
17924 // <listitem>
17925 // On Windows there is no way to remove a file that is open to some
17926 // process, or mapped into memory. Thus, this function will fail if
17927 // @filename already exists and is open.
17928 // </listitem>
17929 // </itemizedlist>
17931 // If the call was successful, it returns %TRUE. If the call was not successful,
17932 // it returns %FALSE and sets @error. The error domain is #G_FILE_ERROR.
17933 // Possible error codes are those in the #GFileError enumeration.
17935 // Note that the name for the temporary file is constructed by appending up
17936 // to 7 characters to @filename.
17937 // RETURNS: %TRUE on success, %FALSE if an error occurred
17938 // <filename>: name of a file to write @contents to, in the GLib file name encoding
17939 // <contents>: string to write to the file
17940 // <length>: length of @contents, or -1 if @contents is a nul-terminated string
17941 static int file_set_contents()(char* filename, ubyte* contents, ssize_t length, GLib2.Error** error=null) {
17942 return g_file_set_contents(filename, contents, length, error);
17946 // Returns %TRUE if any of the tests in the bitfield @test are
17947 // %TRUE. For example, <literal>(G_FILE_TEST_EXISTS |
17948 // G_FILE_TEST_IS_DIR)</literal> will return %TRUE if the file exists;
17949 // the check whether it's a directory doesn't matter since the existence
17950 // test is %TRUE. With the current set of available tests, there's no point
17951 // passing in more than one test at a time.
17953 // Apart from %G_FILE_TEST_IS_SYMLINK all tests follow symbolic links,
17954 // so for a symbolic link to a regular file g_file_test() will return
17955 // %TRUE for both %G_FILE_TEST_IS_SYMLINK and %G_FILE_TEST_IS_REGULAR.
17957 // Note, that for a dangling symbolic link g_file_test() will return
17958 // %TRUE for %G_FILE_TEST_IS_SYMLINK and %FALSE for all other flags.
17960 // You should never use g_file_test() to test whether it is safe
17961 // to perform an operation, because there is always the possibility
17962 // of the condition changing before you actually perform the operation.
17963 // For example, you might think you could use %G_FILE_TEST_IS_SYMLINK
17964 // to know whether it is safe to write to a file without being
17965 // tricked into writing into a different location. It doesn't work!
17966 // |[
17967 // /&ast; DON'T DO THIS &ast;/
17968 // if (!g_file_test (filename, G_FILE_TEST_IS_SYMLINK))
17969 // {
17970 // fd = g_open (filename, O_WRONLY);
17971 // /&ast; write to fd &ast;/
17972 // }
17973 // ]|
17975 // Another thing to note is that %G_FILE_TEST_EXISTS and
17976 // %G_FILE_TEST_IS_EXECUTABLE are implemented using the access()
17977 // system call. This usually doesn't matter, but if your program
17978 // is setuid or setgid it means that these tests will give you
17979 // the answer for the real user ID and group ID, rather than the
17980 // effective user ID and group ID.
17982 // On Windows, there are no symlinks, so testing for
17983 // %G_FILE_TEST_IS_SYMLINK will always return %FALSE. Testing for
17984 // %G_FILE_TEST_IS_EXECUTABLE will just check that the file exists and
17985 // its name indicates that it is executable, checking for well-known
17986 // extensions and those listed in the <envar>PATHEXT</envar> environment variable.
17987 // RETURNS: whether a test was %TRUE
17988 // <filename>: a filename to test in the GLib file name encoding
17989 // <test>: bitfield of #GFileTest flags
17990 static int file_test()(char* filename, FileTest test) {
17991 return g_file_test(filename, test);
17995 // VERSION: 2.6
17996 // Returns the display basename for the particular filename, guaranteed
17997 // to be valid UTF-8. The display name might not be identical to the filename,
17998 // for instance there might be problems converting it to UTF-8, and some files
17999 // can be translated in the display.
18001 // If GLib cannot make sense of the encoding of @filename, as a last resort it
18002 // replaces unknown characters with U+FFFD, the Unicode replacement character.
18003 // You can search the result for the UTF-8 encoding of this character (which is
18004 // "\357\277\275" in octal notation) to find out if @filename was in an invalid
18005 // encoding.
18007 // You must pass the whole absolute pathname to this functions so that
18008 // translation of well known locations can be done.
18010 // This function is preferred over g_filename_display_name() if you know the
18011 // whole path, as it allows translation.
18013 // a rendition of the basename of the filename in valid UTF-8
18014 // RETURNS: a newly allocated string containing
18015 // <filename>: an absolute pathname in the GLib file name encoding
18016 static char* /*new*/ filename_display_basename()(char* filename) {
18017 return g_filename_display_basename(filename);
18021 // VERSION: 2.6
18022 // Converts a filename into a valid UTF-8 string. The conversion is
18023 // not necessarily reversible, so you should keep the original around
18024 // and use the return value of this function only for display purposes.
18025 // Unlike g_filename_to_utf8(), the result is guaranteed to be non-%NULL
18026 // even if the filename actually isn't in the GLib file name encoding.
18028 // If GLib cannot make sense of the encoding of @filename, as a last resort it
18029 // replaces unknown characters with U+FFFD, the Unicode replacement character.
18030 // You can search the result for the UTF-8 encoding of this character (which is
18031 // "\357\277\275" in octal notation) to find out if @filename was in an invalid
18032 // encoding.
18034 // If you know the whole pathname of the file you should use
18035 // g_filename_display_basename(), since that allows location-based
18036 // translation of filenames.
18038 // a rendition of the filename in valid UTF-8
18039 // RETURNS: a newly allocated string containing
18040 // <filename>: a pathname hopefully in the GLib file name encoding
18041 static char* /*new*/ filename_display_name()(char* filename) {
18042 return g_filename_display_name(filename);
18046 // Converts an escaped ASCII-encoded URI to a local filename in the
18047 // encoding used for filenames.
18049 // filename, or %NULL on an error.
18050 // RETURNS: a newly-allocated string holding the resulting
18051 // <uri>: a uri describing a filename (escaped, encoded in ASCII).
18052 // <hostname>: Location to store hostname for the URI, or %NULL. If there is no hostname in the URI, %NULL will be stored in this location.
18053 static char* /*new*/ filename_from_uri()(char* uri, char** hostname, GLib2.Error** error=null) {
18054 return g_filename_from_uri(uri, hostname, error);
18058 // Converts a string from UTF-8 to the encoding GLib uses for
18059 // filenames. Note that on Windows GLib uses UTF-8 for filenames;
18060 // on other platforms, this function indirectly depends on the
18061 // <link linkend="setlocale">current locale</link>.
18062 // RETURNS: The converted string, or %NULL on an error.
18063 // <utf8string>: a UTF-8 encoded string.
18064 // <len>: the length of the string, or -1 if the string is nul-terminated.
18065 // <bytes_read>: location to store the number of bytes in the input string that were successfully converted, or %NULL. Even if the conversion was successful, this may be less than @len if there were partial characters at the end of the input. If the error #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value stored will the byte offset after the last valid input sequence.
18066 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
18067 static char* /*new*/ filename_from_utf8()(char* utf8string, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error=null) {
18068 return g_filename_from_utf8(utf8string, len, bytes_read, bytes_written, error);
18072 // Converts an absolute filename to an escaped ASCII-encoded URI, with the path
18073 // component following Section 3.3. of RFC 2396.
18075 // URI, or %NULL on an error.
18076 // RETURNS: a newly-allocated string holding the resulting
18077 // <filename>: an absolute filename specified in the GLib file name encoding, which is the on-disk file name bytes on Unix, and UTF-8 on Windows
18078 // <hostname>: A UTF-8 encoded hostname, or %NULL for none.
18079 static char* /*new*/ filename_to_uri()(char* filename, char* hostname, GLib2.Error** error=null) {
18080 return g_filename_to_uri(filename, hostname, error);
18084 // Converts a string which is in the encoding used by GLib for
18085 // filenames into a UTF-8 string. Note that on Windows GLib uses UTF-8
18086 // for filenames; on other platforms, this function indirectly depends on
18087 // the <link linkend="setlocale">current locale</link>.
18088 // RETURNS: The converted string, or %NULL on an error.
18089 // <opsysstring>: a string in the encoding for filenames
18090 // <len>: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
18091 // <bytes_read>: location to store the number of bytes in the input string that were successfully converted, or %NULL. Even if the conversion was successful, this may be less than @len if there were partial characters at the end of the input. If the error #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value stored will the byte offset after the last valid input sequence.
18092 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
18093 static char* /*new*/ filename_to_utf8()(char* opsysstring, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error=null) {
18094 return g_filename_to_utf8(opsysstring, len, bytes_read, bytes_written, error);
18098 // Locates the first executable named @program in the user's path, in the
18099 // same way that execvp() would locate it. Returns an allocated string
18100 // with the absolute path name, or %NULL if the program is not found in
18101 // the path. If @program is already an absolute path, returns a copy of
18102 // @program if @program exists and is executable, and %NULL otherwise.
18104 // On Windows, if @program does not have a file type suffix, tries
18105 // with the suffixes .exe, .cmd, .bat and .com, and the suffixes in
18106 // the <envar>PATHEXT</envar> environment variable.
18108 // On Windows, it looks for the file in the same way as CreateProcess()
18109 // would. This means first in the directory where the executing
18110 // program was loaded from, then in the current directory, then in the
18111 // Windows 32-bit system directory, then in the Windows directory, and
18112 // finally in the directories in the <envar>PATH</envar> environment
18113 // variable. If the program is found, the return value contains the
18114 // full name including the type suffix.
18115 // RETURNS: absolute path, or %NULL
18116 // <program>: a program name in the GLib file name encoding
18117 static char* /*new*/ find_program_in_path()(char* program) {
18118 return g_find_program_in_path(program);
18122 // VERSION: 2.30
18123 // Formats a size (for example the size of a file) into a human readable
18124 // string. Sizes are rounded to the nearest size prefix (kB, MB, GB)
18125 // and are displayed rounded to the nearest tenth. E.g. the file size
18126 // 3292528 bytes will be converted into the string "3.2 MB".
18128 // The prefix units base is 1000 (i.e. 1 kB is 1000 bytes).
18130 // This string should be freed with g_free() when not needed any longer.
18132 // See g_format_size_full() for more options about how the size might be
18133 // formatted.
18135 // file size
18136 // RETURNS: a newly-allocated formatted string containing a human readable
18137 // <size>: a size in bytes
18138 static char* /*new*/ format_size()(ulong size) {
18139 return g_format_size(size);
18143 // VERSION: 2.16
18144 // Formats a size (for example the size of a file) into a human
18145 // readable string. Sizes are rounded to the nearest size prefix
18146 // (KB, MB, GB) and are displayed rounded to the nearest tenth.
18147 // E.g. the file size 3292528 bytes will be converted into the
18148 // string "3.1 MB".
18150 // The prefix units base is 1024 (i.e. 1 KB is 1024 bytes).
18152 // This string should be freed with g_free() when not needed any longer.
18154 // readable file size
18157 // Deprecated:2.30: This function is broken due to its use of SI
18158 // suffixes to denote IEC units. Use g_format_size() instead.
18159 // RETURNS: a newly-allocated formatted string containing a human
18160 // <size>: a size in bytes
18161 static char* /*new*/ format_size_for_display()(long size) {
18162 return g_format_size_for_display(size);
18166 // VERSION: 2.30
18167 // Formats a size.
18169 // This function is similar to g_format_size() but allows for flags
18170 // that modify the output. See #GFormatSizeFlags.
18172 // readable file size
18173 // RETURNS: a newly-allocated formatted string containing a human
18174 // <size>: a size in bytes
18175 // <flags>: #GFormatSizeFlags to modify the output
18176 static char* /*new*/ format_size_full()(ulong size, FormatSizeFlags flags) {
18177 return g_format_size_full(size, flags);
18181 // Unintrospectable function: fprintf() / g_fprintf()
18182 // VERSION: 2.2
18183 // An implementation of the standard fprintf() function which supports
18184 // positional parameters, as specified in the Single Unix Specification.
18185 // RETURNS: the number of bytes printed.
18186 // <file>: the stream to write to.
18187 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
18188 alias g_fprintf fprintf; // Variadic
18191 // Frees the memory pointed to by @mem.
18192 // If @mem is %NULL it simply returns.
18193 // <mem>: the memory to free
18194 static void free()(void* mem) {
18195 g_free(mem);
18199 // VERSION: 2.2
18200 // Gets a human-readable name for the application, as set by
18201 // g_set_application_name(). This name should be localized if
18202 // possible, and is intended for display to the user. Contrast with
18203 // g_get_prgname(), which gets a non-localized name. If
18204 // g_set_application_name() has not been called, returns the result of
18205 // g_get_prgname() (which may be %NULL if g_set_prgname() has also not
18206 // been called).
18207 // RETURNS: human-readable application name. may return %NULL
18208 static char* get_application_name()() {
18209 return g_get_application_name();
18213 // Obtains the character set for the <link linkend="setlocale">current
18214 // locale</link>; you might use this character set as an argument to
18215 // g_convert(), to convert from the current locale's encoding to some
18216 // other encoding. (Frequently g_locale_to_utf8() and g_locale_from_utf8()
18217 // are nice shortcuts, though.)
18219 // On Windows the character set returned by this function is the
18220 // so-called system default ANSI code-page. That is the character set
18221 // used by the "narrow" versions of C library and Win32 functions that
18222 // handle file names. It might be different from the character set
18223 // used by the C library's current locale.
18225 // The return value is %TRUE if the locale's encoding is UTF-8, in that
18226 // case you can perhaps avoid calling g_convert().
18228 // The string returned in @charset is not allocated, and should not be
18229 // freed.
18230 // RETURNS: %TRUE if the returned charset is UTF-8
18231 // <charset>: return location for character set name
18232 static int get_charset()(char** charset) {
18233 return g_get_charset(charset);
18237 // Gets the character set for the current locale.
18239 // of the character set. This string must be freed with g_free().
18240 // RETURNS: a newly allocated string containing the name
18241 static char* /*new*/ get_codeset()() {
18242 return g_get_codeset();
18246 // Gets the current directory.
18248 // The returned string should be freed when no longer needed.
18249 // The encoding of the returned string is system defined.
18250 // On Windows, it is always UTF-8.
18251 // RETURNS: the current directory
18252 static char* /*new*/ get_current_dir()() {
18253 return g_get_current_dir();
18257 // Equivalent to the UNIX gettimeofday() function, but portable.
18259 // You may find g_get_real_time() to be more convenient.
18260 // <result>: #GTimeVal structure in which to store current time.
18261 static void get_current_time()(TimeVal* result) {
18262 g_get_current_time(result);
18266 // VERSION: 2.28
18267 // Gets the list of environment variables for the current process.
18269 // The list is %NULL terminated and each item in the list is of the
18270 // form 'NAME=VALUE'.
18272 // This is equivalent to direct access to the 'environ' global variable,
18273 // except portable.
18275 // The return value is freshly allocated and it should be freed with
18276 // g_strfreev() when it is no longer needed.
18278 // environment variables
18279 // RETURNS: the list of
18280 static char** /*new*/ get_environ()() {
18281 return g_get_environ();
18285 // VERSION: 2.6
18286 // Determines the preferred character sets used for filenames.
18287 // The first character set from the @charsets is the filename encoding, the
18288 // subsequent character sets are used when trying to generate a displayable
18289 // representation of a filename, see g_filename_display_name().
18291 // On Unix, the character sets are determined by consulting the
18292 // environment variables <envar>G_FILENAME_ENCODING</envar> and
18293 // <envar>G_BROKEN_FILENAMES</envar>. On Windows, the character set
18294 // used in the GLib API is always UTF-8 and said environment variables
18295 // have no effect.
18297 // <envar>G_FILENAME_ENCODING</envar> may be set to a comma-separated list
18298 // of character set names. The special token "&commat;locale" is taken to
18299 // mean the character set for the <link linkend="setlocale">current
18300 // locale</link>. If <envar>G_FILENAME_ENCODING</envar> is not set, but
18301 // <envar>G_BROKEN_FILENAMES</envar> is, the character set of the current
18302 // locale is taken as the filename encoding. If neither environment variable
18303 // is set, UTF-8 is taken as the filename encoding, but the character
18304 // set of the current locale is also put in the list of encodings.
18306 // The returned @charsets belong to GLib and must not be freed.
18308 // Note that on Unix, regardless of the locale character set or
18309 // <envar>G_FILENAME_ENCODING</envar> value, the actual file names present
18310 // on a system might be in any random encoding or just gibberish.
18311 // RETURNS: %TRUE if the filename encoding is UTF-8.
18312 // <charsets>: return location for the %NULL-terminated list of encoding names
18313 static int get_filename_charsets()(char*** charsets) {
18314 return g_get_filename_charsets(charsets);
18318 // Gets the current user's home directory as defined in the
18319 // password database.
18321 // Note that in contrast to traditional UNIX tools, this function
18322 // prefers <filename>passwd</filename> entries over the <envar>HOME</envar>
18323 // environment variable.
18325 // One of the reasons for this decision is that applications in many
18326 // cases need special handling to deal with the case where
18327 // <envar>HOME</envar> is
18328 // <simplelist>
18329 // <member>Not owned by the user</member>
18330 // <member>Not writeable</member>
18331 // <member>Not even readable</member>
18332 // </simplelist>
18333 // Since applications are in general <emphasis>not</emphasis> written
18334 // to deal with these situations it was considered better to make
18335 // g_get_home_dir() not pay attention to <envar>HOME</envar> and to
18336 // return the real home directory for the user. If applications
18337 // want to pay attention to <envar>HOME</envar>, they can do:
18338 // |[
18339 // const char *homedir = g_getenv ("HOME");
18340 // if (!homedir)
18341 // homedir = g_get_home_dir (<!-- -->);
18342 // ]|
18343 // RETURNS: the current user's home directory
18344 static char* get_home_dir()() {
18345 return g_get_home_dir();
18349 // VERSION: 2.8
18350 // Return a name for the machine.
18352 // The returned name is not necessarily a fully-qualified domain name,
18353 // or even present in DNS or some other name service at all. It need
18354 // not even be unique on your local network or site, but usually it
18355 // is. Callers should not rely on the return value having any specific
18356 // properties like uniqueness for security purposes. Even if the name
18357 // of the machine is changed while an application is running, the
18358 // return value from this function does not change. The returned
18359 // string is owned by GLib and should not be modified or freed. If no
18360 // name can be determined, a default fixed string "localhost" is
18361 // returned.
18362 // RETURNS: the host name of the machine.
18363 static char* get_host_name()() {
18364 return g_get_host_name();
18368 // VERSION: 2.6
18369 // Computes a list of applicable locale names, which can be used to
18370 // e.g. construct locale-dependent filenames or search paths. The returned
18371 // list is sorted from most desirable to least desirable and always contains
18372 // the default locale "C".
18374 // For example, if LANGUAGE=de:en_US, then the returned list is
18375 // "de", "en_US", "en", "C".
18377 // This function consults the environment variables <envar>LANGUAGE</envar>,
18378 // <envar>LC_ALL</envar>, <envar>LC_MESSAGES</envar> and <envar>LANG</envar>
18379 // to find the list of locales specified by the user.
18381 // that must not be modified or freed.
18382 // RETURNS: a %NULL-terminated array of strings owned by GLib
18383 static char** get_language_names()() {
18384 return g_get_language_names();
18388 // VERSION: 2.28
18389 // Returns a list of derived variants of @locale, which can be used to
18390 // e.g. construct locale-dependent filenames or search paths. The returned
18391 // list is sorted from most desirable to least desirable.
18392 // This function handles territory, charset and extra locale modifiers.
18394 // For example, if @locale is "fr_BE", then the returned list
18395 // is "fr_BE", "fr".
18397 // If you need the list of variants for the <emphasis>current locale</emphasis>,
18398 // use g_get_language_names().
18400 // allocated array of newly allocated strings with the locale variants. Free with
18401 // g_strfreev().
18402 // RETURNS: a newly
18403 // <locale>: a locale identifier
18404 static char** /*new*/ get_locale_variants()(char* locale) {
18405 return g_get_locale_variants(locale);
18409 // VERSION: 2.28
18410 // Queries the system monotonic time, if available.
18412 // On POSIX systems with clock_gettime() and <literal>CLOCK_MONOTONIC</literal> this call
18413 // is a very shallow wrapper for that. Otherwise, we make a best effort
18414 // that probably involves returning the wall clock time (with at least
18415 // microsecond accuracy, subject to the limitations of the OS kernel).
18417 // It's important to note that POSIX <literal>CLOCK_MONOTONIC</literal> does
18418 // not count time spent while the machine is suspended.
18420 // On Windows, "limitations of the OS kernel" is a rather substantial
18421 // statement. Depending on the configuration of the system, the wall
18422 // clock time is updated as infrequently as 64 times a second (which
18423 // is approximately every 16ms). Also, the on XP (not on Vista or later)
18424 // the monitonic clock is locally monotonic, but may differ in exact
18425 // value between processes due to timer wrap handling.
18426 // RETURNS: the monotonic time, in microseconds
18427 static long get_monotonic_time()() {
18428 return g_get_monotonic_time();
18432 // Gets the name of the program. This name should <emphasis>not</emphasis>
18433 // be localized, contrast with g_get_application_name().
18434 // (If you are using GDK or GTK+ the program name is set in gdk_init(),
18435 // which is called by gtk_init(). The program name is found by taking
18436 // the last component of <literal>argv[0]</literal>.)
18438 // to GLib and must not be modified or freed.
18439 // RETURNS: the name of the program. The returned string belongs
18440 static char* /*new*/ get_prgname()() {
18441 return g_get_prgname();
18445 // Gets the real name of the user. This usually comes from the user's entry
18446 // in the <filename>passwd</filename> file. The encoding of the returned
18447 // string is system-defined. (On Windows, it is, however, always UTF-8.)
18448 // If the real user name cannot be determined, the string "Unknown" is
18449 // returned.
18450 // RETURNS: the user's real name.
18451 static char* get_real_name()() {
18452 return g_get_real_name();
18456 // VERSION: 2.28
18457 // Queries the system wall-clock time.
18459 // This call is functionally equivalent to g_get_current_time() except
18460 // that the return value is often more convenient than dealing with a
18461 // #GTimeVal.
18463 // You should only use this call if you are actually interested in the real
18464 // wall-clock time. g_get_monotonic_time() is probably more useful for
18465 // measuring intervals.
18466 // RETURNS: the number of microseconds since January 1, 1970 UTC.
18467 static long get_real_time()() {
18468 return g_get_real_time();
18472 // VERSION: 2.6
18473 // Returns an ordered list of base directories in which to access
18474 // system-wide configuration information.
18476 // On UNIX platforms this is determined using the mechanisms described in
18477 // the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
18478 // XDG Base Directory Specification</ulink>.
18479 // In this case the list of directories retrieved will be XDG_CONFIG_DIRS.
18481 // On Windows is the directory that contains application data for all users.
18482 // A typical path is C:\Documents and Settings\All Users\Application Data.
18483 // This folder is used for application data that is not user specific.
18484 // For example, an application can store a spell-check dictionary, a database
18485 // of clip art, or a log file in the CSIDL_COMMON_APPDATA folder.
18486 // This information will not roam and is available to anyone using the computer.
18488 // not be modified or freed.
18489 // RETURNS: a %NULL-terminated array of strings owned by GLib that must
18490 static char** get_system_config_dirs()() {
18491 return g_get_system_config_dirs();
18495 // VERSION: 2.6
18496 // Returns an ordered list of base directories in which to access
18497 // system-wide application data.
18499 // On UNIX platforms this is determined using the mechanisms described in
18500 // the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
18501 // XDG Base Directory Specification</ulink>
18502 // In this case the list of directories retrieved will be XDG_DATA_DIRS.
18504 // On Windows the first elements in the list are the Application Data
18505 // and Documents folders for All Users. (These can be determined only
18506 // on Windows 2000 or later and are not present in the list on other
18507 // Windows versions.) See documentation for CSIDL_COMMON_APPDATA and
18508 // CSIDL_COMMON_DOCUMENTS.
18510 // Then follows the "share" subfolder in the installation folder for
18511 // the package containing the DLL that calls this function, if it can
18512 // be determined.
18514 // Finally the list contains the "share" subfolder in the installation
18515 // folder for GLib, and in the installation folder for the package the
18516 // application's .exe file belongs to.
18518 // The installation folders above are determined by looking up the
18519 // folder where the module (DLL or EXE) in question is located. If the
18520 // folder's name is "bin", its parent is used, otherwise the folder
18521 // itself.
18523 // Note that on Windows the returned list can vary depending on where
18524 // this function is called.
18526 // not be modified or freed.
18527 // RETURNS: a %NULL-terminated array of strings owned by GLib that must
18528 static char** get_system_data_dirs()() {
18529 return g_get_system_data_dirs();
18533 // Gets the directory to use for temporary files. This is found from
18534 // inspecting the environment variables <envar>TMPDIR</envar>,
18535 // <envar>TMP</envar>, and <envar>TEMP</envar> in that order. If none
18536 // of those are defined "/tmp" is returned on UNIX and "C:\" on Windows.
18537 // The encoding of the returned string is system-defined. On Windows,
18538 // it is always UTF-8. The return value is never %NULL or the empty string.
18539 // RETURNS: the directory to use for temporary files.
18540 static char* get_tmp_dir()() {
18541 return g_get_tmp_dir();
18545 // VERSION: 2.6
18546 // Returns a base directory in which to store non-essential, cached
18547 // data specific to particular user.
18549 // On UNIX platforms this is determined using the mechanisms described in
18550 // the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
18551 // XDG Base Directory Specification</ulink>.
18552 // In this case the directory retrieved will be XDG_CACHE_HOME.
18554 // On Windows is the directory that serves as a common repository for
18555 // temporary Internet files. A typical path is
18556 // C:\Documents and Settings\username\Local Settings\Temporary Internet Files.
18557 // See documentation for CSIDL_INTERNET_CACHE.
18559 // or freed.
18560 // RETURNS: a string owned by GLib that must not be modified
18561 static char* get_user_cache_dir()() {
18562 return g_get_user_cache_dir();
18566 // VERSION: 2.6
18567 // Returns a base directory in which to store user-specific application
18568 // configuration information such as user preferences and settings.
18570 // On UNIX platforms this is determined using the mechanisms described in
18571 // the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
18572 // XDG Base Directory Specification</ulink>.
18573 // In this case the directory retrieved will be XDG_CONFIG_HOME.
18575 // On Windows this is the folder to use for local (as opposed to
18576 // roaming) application data. See documentation for
18577 // CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
18578 // what g_get_user_data_dir() returns.
18580 // or freed.
18581 // RETURNS: a string owned by GLib that must not be modified
18582 static char* get_user_config_dir()() {
18583 return g_get_user_config_dir();
18587 // VERSION: 2.6
18588 // Returns a base directory in which to access application data such
18589 // as icons that is customized for a particular user.
18591 // On UNIX platforms this is determined using the mechanisms described in
18592 // the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
18593 // XDG Base Directory Specification</ulink>.
18594 // In this case the directory retrieved will be XDG_DATA_HOME.
18596 // On Windows this is the folder to use for local (as opposed to
18597 // roaming) application data. See documentation for
18598 // CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
18599 // what g_get_user_config_dir() returns.
18601 // or freed.
18602 // RETURNS: a string owned by GLib that must not be modified
18603 static char* get_user_data_dir()() {
18604 return g_get_user_data_dir();
18608 // Gets the user name of the current user. The encoding of the returned
18609 // string is system-defined. On UNIX, it might be the preferred file name
18610 // encoding, or something else, and there is no guarantee that it is even
18611 // consistent on a machine. On Windows, it is always UTF-8.
18612 // RETURNS: the user name of the current user.
18613 static char* get_user_name()() {
18614 return g_get_user_name();
18618 // VERSION: 2.28
18619 // Returns a directory that is unique to the current user on the local
18620 // system.
18622 // On UNIX platforms this is determined using the mechanisms described in
18623 // the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
18624 // XDG Base Directory Specification</ulink>. This is the directory
18625 // specified in the <envar>XDG_RUNTIME_DIR</envar> environment variable.
18626 // In the case that this variable is not set, GLib will issue a warning
18627 // message to stderr and return the value of g_get_user_cache_dir().
18629 // On Windows this is the folder to use for local (as opposed to
18630 // roaming) application data. See documentation for
18631 // CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
18632 // what g_get_user_config_dir() returns.
18633 // RETURNS: a string owned by GLib that must not be modified or freed.
18634 static char* get_user_runtime_dir()() {
18635 return g_get_user_runtime_dir();
18639 // VERSION: 2.14
18640 // Returns the full path of a special directory using its logical id.
18642 // On Unix this is done using the XDG special user directories.
18643 // For compatibility with existing practise, %G_USER_DIRECTORY_DESKTOP
18644 // falls back to <filename>$HOME/Desktop</filename> when XDG special
18645 // user directories have not been set up.
18647 // Depending on the platform, the user might be able to change the path
18648 // of the special directory without requiring the session to restart; GLib
18649 // will not reflect any change once the special directories are loaded.
18651 // if the logical id was not found. The returned string is owned by
18652 // GLib and should not be modified or freed.
18653 // RETURNS: the path to the specified special directory, or %NULL
18654 // <directory>: the logical id of special directory
18655 static char* get_user_special_dir()(UserDirectory directory) {
18656 return g_get_user_special_dir(directory);
18660 // Returns the value of an environment variable.
18662 // The name and value are in the GLib file name encoding. On UNIX,
18663 // this means the actual bytes which might or might not be in some
18664 // consistent character set and encoding. On Windows, it is in UTF-8.
18665 // On Windows, in case the environment variable's value contains
18666 // references to other environment variables, they are expanded.
18668 // the environment variable is not found. The returned string
18669 // may be overwritten by the next call to g_getenv(), g_setenv()
18670 // or g_unsetenv().
18671 // RETURNS: the value of the environment variable, or %NULL if
18672 // <variable>: the environment variable to get, in the GLib file name encoding
18673 static char* getenv()(char* variable) {
18674 return g_getenv(variable);
18678 // VERSION: 2.32
18679 // MOVED TO: HashTable.add
18680 // This is a convenience function for using a #GHashTable as a set. It
18681 // is equivalent to calling g_hash_table_replace() with @key as both the
18682 // key and the value.
18684 // When a hash table only ever contains keys that have themselves as the
18685 // corresponding value it is able to be stored more efficiently. See
18686 // the discussion in the section description.
18687 // <hash_table>: a #GHashTable
18688 // <key>: a key to insert
18689 static void hash_table_add()(GLib2.HashTable* hash_table, void* key) {
18690 g_hash_table_add(hash_table, key);
18694 // VERSION: 2.32
18695 // MOVED TO: HashTable.contains
18696 // Checks if @key is in @hash_table.
18697 // <hash_table>: a #GHashTable
18698 static int hash_table_contains()(GLib2.HashTable* hash_table, const(void)* lookup_key) {
18699 return g_hash_table_contains(hash_table, lookup_key);
18703 // MOVED TO: HashTable.destroy
18704 // Destroys all keys and values in the #GHashTable and decrements its
18705 // reference count by 1. If keys and/or values are dynamically allocated,
18706 // you should either free them first or create the #GHashTable with destroy
18707 // notifiers using g_hash_table_new_full(). In the latter case the destroy
18708 // functions you supplied will be called on all keys and values during the
18709 // destruction phase.
18710 // <hash_table>: a #GHashTable
18711 static void hash_table_destroy()(GLib2.HashTable* hash_table) {
18712 g_hash_table_destroy(hash_table);
18716 // MOVED TO: HashTable.insert
18717 // Inserts a new key and value into a #GHashTable.
18719 // If the key already exists in the #GHashTable its current
18720 // value is replaced with the new value. If you supplied a
18721 // @value_destroy_func when creating the #GHashTable, the old
18722 // value is freed using that function. If you supplied a
18723 // @key_destroy_func when creating the #GHashTable, the passed
18724 // key is freed using that function.
18725 // <hash_table>: a #GHashTable
18726 // <key>: a key to insert
18727 // <value>: the value to associate with the key
18728 static void hash_table_insert()(GLib2.HashTable* hash_table, void* key, void* value) {
18729 g_hash_table_insert(hash_table, key, value);
18733 // MOVED TO: HashTable.lookup_extended
18734 // Looks up a key in the #GHashTable, returning the original key and the
18735 // associated value and a #gboolean which is %TRUE if the key was found. This
18736 // is useful if you need to free the memory allocated for the original key,
18737 // for example before calling g_hash_table_remove().
18739 // You can actually pass %NULL for @lookup_key to test
18740 // whether the %NULL key exists, provided the hash and equal functions
18741 // of @hash_table are %NULL-safe.
18742 // RETURNS: %TRUE if the key was found in the #GHashTable
18743 // <hash_table>: a #GHashTable
18744 // <lookup_key>: the key to look up
18745 // <orig_key>: return location for the original key, or %NULL
18746 // <value>: return location for the value associated with the key, or %NULL
18747 static int hash_table_lookup_extended()(GLib2.HashTable* hash_table, const(void)* lookup_key, void** orig_key=null, void** value=null) {
18748 return g_hash_table_lookup_extended(hash_table, lookup_key, orig_key, value);
18752 // MOVED TO: HashTable.remove
18753 // Removes a key and its associated value from a #GHashTable.
18755 // If the #GHashTable was created using g_hash_table_new_full(), the
18756 // key and value are freed using the supplied destroy functions, otherwise
18757 // you have to make sure that any dynamically allocated values are freed
18758 // yourself.
18759 // RETURNS: %TRUE if the key was found and removed from the #GHashTable
18760 // <hash_table>: a #GHashTable
18761 // <key>: the key to remove
18762 static int hash_table_remove()(GLib2.HashTable* hash_table, const(void)* key) {
18763 return g_hash_table_remove(hash_table, key);
18767 // VERSION: 2.12
18768 // MOVED TO: HashTable.remove_all
18769 // Removes all keys and their associated values from a #GHashTable.
18771 // If the #GHashTable was created using g_hash_table_new_full(),
18772 // the keys and values are freed using the supplied destroy functions,
18773 // otherwise you have to make sure that any dynamically allocated
18774 // values are freed yourself.
18775 // <hash_table>: a #GHashTable
18776 static void hash_table_remove_all()(GLib2.HashTable* hash_table) {
18777 g_hash_table_remove_all(hash_table);
18781 // MOVED TO: HashTable.replace
18782 // Inserts a new key and value into a #GHashTable similar to
18783 // g_hash_table_insert(). The difference is that if the key
18784 // already exists in the #GHashTable, it gets replaced by the
18785 // new key. If you supplied a @value_destroy_func when creating
18786 // the #GHashTable, the old value is freed using that function.
18787 // If you supplied a @key_destroy_func when creating the
18788 // #GHashTable, the old key is freed using that function.
18789 // <hash_table>: a #GHashTable
18790 // <key>: a key to insert
18791 // <value>: the value to associate with the key
18792 static void hash_table_replace()(GLib2.HashTable* hash_table, void* key, void* value) {
18793 g_hash_table_replace(hash_table, key, value);
18797 // MOVED TO: HashTable.size
18798 // Returns the number of elements contained in the #GHashTable.
18799 // RETURNS: the number of key/value pairs in the #GHashTable.
18800 // <hash_table>: a #GHashTable
18801 static uint hash_table_size()(GLib2.HashTable* hash_table) {
18802 return g_hash_table_size(hash_table);
18806 // MOVED TO: HashTable.steal
18807 // Removes a key and its associated value from a #GHashTable without
18808 // calling the key and value destroy functions.
18809 // RETURNS: %TRUE if the key was found and removed from the #GHashTable
18810 // <hash_table>: a #GHashTable
18811 // <key>: the key to remove
18812 static int hash_table_steal()(GLib2.HashTable* hash_table, const(void)* key) {
18813 return g_hash_table_steal(hash_table, key);
18817 // VERSION: 2.12
18818 // MOVED TO: HashTable.steal_all
18819 // Removes all keys and their associated values from a #GHashTable
18820 // without calling the key and value destroy functions.
18821 // <hash_table>: a #GHashTable
18822 static void hash_table_steal_all()(GLib2.HashTable* hash_table) {
18823 g_hash_table_steal_all(hash_table);
18827 // VERSION: 2.10
18828 // MOVED TO: HashTable.unref
18829 // Atomically decrements the reference count of @hash_table by one.
18830 // If the reference count drops to 0, all keys and values will be
18831 // destroyed, and all memory allocated by the hash table is released.
18832 // This function is MT-safe and may be called from any thread.
18833 // <hash_table>: a valid #GHashTable
18834 static void hash_table_unref()(GLib2.HashTable* hash_table) {
18835 g_hash_table_unref(hash_table);
18839 // MOVED TO: Hook.destroy
18840 // Destroys a #GHook, given its ID.
18841 // RETURNS: %TRUE if the #GHook was found in the #GHookList and destroyed
18842 // <hook_list>: a #GHookList
18843 // <hook_id>: a hook ID
18844 static int hook_destroy()(HookList* hook_list, c_ulong hook_id) {
18845 return g_hook_destroy(hook_list, hook_id);
18849 // MOVED TO: Hook.destroy_link
18850 // Removes one #GHook from a #GHookList, marking it
18851 // inactive and calling g_hook_unref() on it.
18852 // <hook_list>: a #GHookList
18853 // <hook>: the #GHook to remove
18854 static void hook_destroy_link()(HookList* hook_list, Hook* hook) {
18855 g_hook_destroy_link(hook_list, hook);
18859 // MOVED TO: Hook.free
18860 // Calls the #GHookList @finalize_hook function if it exists,
18861 // and frees the memory allocated for the #GHook.
18862 // <hook_list>: a #GHookList
18863 // <hook>: the #GHook to free
18864 static void hook_free()(HookList* hook_list, Hook* hook) {
18865 g_hook_free(hook_list, hook);
18869 // MOVED TO: Hook.insert_before
18870 // Inserts a #GHook into a #GHookList, before a given #GHook.
18871 // <hook_list>: a #GHookList
18872 // <sibling>: the #GHook to insert the new #GHook before
18873 // <hook>: the #GHook to insert
18874 static void hook_insert_before()(HookList* hook_list, Hook* sibling, Hook* hook) {
18875 g_hook_insert_before(hook_list, sibling, hook);
18879 // MOVED TO: Hook.prepend
18880 // Prepends a #GHook on the start of a #GHookList.
18881 // <hook_list>: a #GHookList
18882 // <hook>: the #GHook to add to the start of @hook_list
18883 static void hook_prepend()(HookList* hook_list, Hook* hook) {
18884 g_hook_prepend(hook_list, hook);
18888 // MOVED TO: Hook.unref
18889 // Decrements the reference count of a #GHook.
18890 // If the reference count falls to 0, the #GHook is removed
18891 // from the #GHookList and g_hook_free() is called to free it.
18892 // <hook_list>: a #GHookList
18893 // <hook>: the #GHook to unref
18894 static void hook_unref()(HookList* hook_list, Hook* hook) {
18895 g_hook_unref(hook_list, hook);
18899 // VERSION: 2.22
18900 // Tests if @hostname contains segments with an ASCII-compatible
18901 // encoding of an Internationalized Domain Name. If this returns
18902 // %TRUE, you should decode the hostname with g_hostname_to_unicode()
18903 // before displaying it to the user.
18905 // Note that a hostname might contain a mix of encoded and unencoded
18906 // segments, and so it is possible for g_hostname_is_non_ascii() and
18907 // g_hostname_is_ascii_encoded() to both return %TRUE for a name.
18909 // segments.
18910 // RETURNS: %TRUE if @hostname contains any ASCII-encoded
18911 // <hostname>: a hostname
18912 static int hostname_is_ascii_encoded()(char* hostname) {
18913 return g_hostname_is_ascii_encoded(hostname);
18917 // VERSION: 2.22
18918 // Tests if @hostname is the string form of an IPv4 or IPv6 address.
18919 // (Eg, "192.168.0.1".)
18920 // RETURNS: %TRUE if @hostname is an IP address
18921 // <hostname>: a hostname (or IP address in string form)
18922 static int hostname_is_ip_address()(char* hostname) {
18923 return g_hostname_is_ip_address(hostname);
18927 // VERSION: 2.22
18928 // Tests if @hostname contains Unicode characters. If this returns
18929 // %TRUE, you need to encode the hostname with g_hostname_to_ascii()
18930 // before using it in non-IDN-aware contexts.
18932 // Note that a hostname might contain a mix of encoded and unencoded
18933 // segments, and so it is possible for g_hostname_is_non_ascii() and
18934 // g_hostname_is_ascii_encoded() to both return %TRUE for a name.
18935 // RETURNS: %TRUE if @hostname contains any non-ASCII characters
18936 // <hostname>: a hostname
18937 static int hostname_is_non_ascii()(char* hostname) {
18938 return g_hostname_is_non_ascii(hostname);
18942 // VERSION: 2.22
18943 // Converts @hostname to its canonical ASCII form; an ASCII-only
18944 // string containing no uppercase letters and not ending with a
18945 // trailing dot.
18947 // @hostname is in some way invalid.
18948 // RETURNS: an ASCII hostname, which must be freed, or %NULL if
18949 // <hostname>: a valid UTF-8 or ASCII hostname
18950 static char* /*new*/ hostname_to_ascii()(char* hostname) {
18951 return g_hostname_to_ascii(hostname);
18955 // VERSION: 2.22
18956 // Converts @hostname to its canonical presentation form; a UTF-8
18957 // string in Unicode normalization form C, containing no uppercase
18958 // letters, no forbidden characters, and no ASCII-encoded segments,
18959 // and not ending with a trailing dot.
18961 // Of course if @hostname is not an internationalized hostname, then
18962 // the canonical presentation form will be entirely ASCII.
18964 // @hostname is in some way invalid.
18965 // RETURNS: a UTF-8 hostname, which must be freed, or %NULL if
18966 // <hostname>: a valid UTF-8 or ASCII hostname
18967 static char* /*new*/ hostname_to_unicode()(char* hostname) {
18968 return g_hostname_to_unicode(hostname);
18972 // Unintrospectable function: idle_add() / g_idle_add()
18973 // Adds a function to be called whenever there are no higher priority
18974 // events pending to the default main loop. The function is given the
18975 // default idle priority, #G_PRIORITY_DEFAULT_IDLE. If the function
18976 // returns %FALSE it is automatically removed from the list of event
18977 // sources and will not be called again.
18979 // This internally creates a main loop source using g_idle_source_new()
18980 // and attaches it to the main loop context using g_source_attach().
18981 // You can do these steps manually if you need greater control.
18982 // RETURNS: the ID (greater than 0) of the event source.
18983 // <function>: function to call
18984 // <data>: data to pass to @function.
18985 static uint idle_add()(SourceFunc function_, void* data) {
18986 return g_idle_add(function_, data);
18990 // Adds a function to be called whenever there are no higher priority
18991 // events pending. If the function returns %FALSE it is automatically
18992 // removed from the list of event sources and will not be called again.
18994 // This internally creates a main loop source using g_idle_source_new()
18995 // and attaches it to the main loop context using g_source_attach().
18996 // You can do these steps manually if you need greater control.
18997 // RETURNS: the ID (greater than 0) of the event source.
18998 // <priority>: the priority of the idle source. Typically this will be in the range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.
18999 // <function>: function to call
19000 // <data>: data to pass to @function
19001 // <notify>: function to call when the idle is removed, or %NULL
19002 static uint idle_add_full()(int priority, SourceFunc function_, void* data, DestroyNotify notify) {
19003 return g_idle_add_full(priority, function_, data, notify);
19007 // Removes the idle function with the given data.
19008 // RETURNS: %TRUE if an idle source was found and removed.
19009 // <data>: the data for the idle source's callback.
19010 static int idle_remove_by_data()(void* data) {
19011 return g_idle_remove_by_data(data);
19015 // Creates a new idle source.
19017 // The source will not initially be associated with any #GMainContext
19018 // and must be added to one with g_source_attach() before it will be
19019 // executed. Note that the default priority for idle sources is
19020 // %G_PRIORITY_DEFAULT_IDLE, as compared to other sources which
19021 // have a default priority of %G_PRIORITY_DEFAULT.
19022 // RETURNS: the newly-created idle source
19023 static Source* /*new*/ idle_source_new()() {
19024 return g_idle_source_new();
19028 // VERSION: 2.22
19029 // Compares the two #gint64 values being pointed to and returns
19030 // %TRUE if they are equal.
19031 // It can be passed to g_hash_table_new() as the @key_equal_func
19032 // parameter, when using non-%NULL pointers to 64-bit integers as keys in a
19033 // #GHashTable.
19034 // RETURNS: %TRUE if the two keys match.
19035 // <v1>: a pointer to a #gint64 key
19036 // <v2>: a pointer to a #gint64 key to compare with @v1
19037 static int int64_equal()(const(void)* v1, const(void)* v2) {
19038 return g_int64_equal(v1, v2);
19042 // VERSION: 2.22
19043 // Converts a pointer to a #gint64 to a hash value.
19045 // It can be passed to g_hash_table_new() as the @hash_func parameter,
19046 // when using non-%NULL pointers to 64-bit integer values as keys in a
19047 // #GHashTable.
19048 // RETURNS: a hash value corresponding to the key.
19049 // <v>: a pointer to a #gint64 key
19050 static uint int64_hash()(const(void)* v) {
19051 return g_int64_hash(v);
19055 // Compares the two #gint values being pointed to and returns
19056 // %TRUE if they are equal.
19057 // It can be passed to g_hash_table_new() as the @key_equal_func
19058 // parameter, when using non-%NULL pointers to integers as keys in a
19059 // #GHashTable.
19061 // Note that this function acts on pointers to #gint, not on #gint directly:
19062 // if your hash table's keys are of the form
19063 // <literal>GINT_TO_POINTER (n)</literal>, use g_direct_equal() instead.
19064 // RETURNS: %TRUE if the two keys match.
19065 // <v1>: a pointer to a #gint key
19066 // <v2>: a pointer to a #gint key to compare with @v1
19067 static int int_equal()(const(void)* v1, const(void)* v2) {
19068 return g_int_equal(v1, v2);
19072 // Converts a pointer to a #gint to a hash value.
19073 // It can be passed to g_hash_table_new() as the @hash_func parameter,
19074 // when using non-%NULL pointers to integer values as keys in a #GHashTable.
19076 // Note that this function acts on pointers to #gint, not on #gint directly:
19077 // if your hash table's keys are of the form
19078 // <literal>GINT_TO_POINTER (n)</literal>, use g_direct_hash() instead.
19079 // RETURNS: a hash value corresponding to the key.
19080 // <v>: a pointer to a #gint key
19081 static uint int_hash()(const(void)* v) {
19082 return g_int_hash(v);
19086 // VERSION: 2.10
19087 // Returns a canonical representation for @string. Interned strings can
19088 // be compared for equality by comparing the pointers, instead of using strcmp().
19089 // g_intern_static_string() does not copy the string, therefore @string must
19090 // not be freed or modified.
19091 // RETURNS: a canonical representation for the string
19092 // <string>: a static string
19093 static char* intern_static_string()(char* string_=null) {
19094 return g_intern_static_string(string_);
19098 // VERSION: 2.10
19099 // Returns a canonical representation for @string. Interned strings can
19100 // be compared for equality by comparing the pointers, instead of using strcmp().
19101 // RETURNS: a canonical representation for the string
19102 // <string>: a string
19103 static char* intern_string()(char* string_=null) {
19104 return g_intern_string(string_);
19108 // Unintrospectable function: io_add_watch() / g_io_add_watch()
19109 // Adds the #GIOChannel into the default main loop context
19110 // with the default priority.
19111 // RETURNS: the event source id
19112 // <channel>: a #GIOChannel
19113 // <condition>: the condition to watch for
19114 // <func>: the function to call when the condition is satisfied
19115 // <user_data>: user data to pass to @func
19116 static uint io_add_watch()(IOChannel* channel, IOCondition condition, IOFunc func, void* user_data) {
19117 return g_io_add_watch(channel, condition, func, user_data);
19121 // Adds the #GIOChannel into the default main loop context
19122 // with the given priority.
19124 // This internally creates a main loop source using g_io_create_watch()
19125 // and attaches it to the main loop context with g_source_attach().
19126 // You can do these steps manually if you need greater control.
19127 // RETURNS: the event source id
19128 // <channel>: a #GIOChannel
19129 // <priority>: the priority of the #GIOChannel source
19130 // <condition>: the condition to watch for
19131 // <func>: the function to call when the condition is satisfied
19132 // <user_data>: user data to pass to @func
19133 // <notify>: the function to call when the source is removed
19134 static uint io_add_watch_full()(IOChannel* channel, int priority, IOCondition condition, IOFunc func, void* user_data, DestroyNotify notify) {
19135 return g_io_add_watch_full(channel, priority, condition, func, user_data, notify);
19139 // MOVED TO: IOChannel.error_from_errno
19140 // Converts an <literal>errno</literal> error number to a #GIOChannelError.
19142 // %G_IO_CHANNEL_ERROR_INVAL.
19143 // RETURNS: a #GIOChannelError error number, e.g.
19144 // <en>: an <literal>errno</literal> error number, e.g. <literal>EINVAL</literal>
19145 static IOChannelError io_channel_error_from_errno()(int en) {
19146 return g_io_channel_error_from_errno(en);
19150 // MOVED TO: IOChannel.error_quark
19152 // RETURNS: the quark used as %G_IO_CHANNEL_ERROR
19153 static Quark io_channel_error_quark()() {
19154 return g_io_channel_error_quark();
19158 // Creates a #GSource that's dispatched when @condition is met for the
19159 // given @channel. For example, if condition is #G_IO_IN, the source will
19160 // be dispatched when there's data available for reading.
19162 // g_io_add_watch() is a simpler interface to this same functionality, for
19163 // the case where you want to add the source to the default main loop context
19164 // at the default priority.
19166 // On Windows, polling a #GSource created to watch a channel for a socket
19167 // puts the socket in non-blocking mode. This is a side-effect of the
19168 // implementation and unavoidable.
19169 // RETURNS: a new #GSource
19170 // <channel>: a #GIOChannel to watch
19171 // <condition>: conditions to watch for
19172 static Source* /*new*/ io_create_watch()(IOChannel* channel, IOCondition condition) {
19173 return g_io_create_watch(channel, condition);
19176 // MOVED TO: KeyFile.error_quark
19177 static Quark key_file_error_quark()() {
19178 return g_key_file_error_quark();
19182 // VERSION: 2.8
19183 // Gets the names of all variables set in the environment.
19185 // Programs that want to be portable to Windows should typically use
19186 // this function and g_getenv() instead of using the environ array
19187 // from the C library directly. On Windows, the strings in the environ
19188 // array are in system codepage encoding, while in most of the typical
19189 // use cases for environment variables in GLib-using programs you want
19190 // the UTF-8 encoding that this function and g_getenv() provide.
19192 // list of strings which must be freed with g_strfreev().
19193 // RETURNS: a %NULL-terminated
19194 static char** /*new*/ listenv()() {
19195 return g_listenv();
19199 // Converts a string from UTF-8 to the encoding used for strings by
19200 // the C runtime (usually the same as that used by the operating
19201 // system) in the <link linkend="setlocale">current locale</link>. On
19202 // Windows this means the system codepage.
19203 // RETURNS: The converted string, or %NULL on an error.
19204 // <utf8string>: a UTF-8 encoded string
19205 // <len>: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
19206 // <bytes_read>: location to store the number of bytes in the input string that were successfully converted, or %NULL. Even if the conversion was successful, this may be less than @len if there were partial characters at the end of the input. If the error #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value stored will the byte offset after the last valid input sequence.
19207 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
19208 static char* /*new*/ locale_from_utf8()(char* utf8string, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error=null) {
19209 return g_locale_from_utf8(utf8string, len, bytes_read, bytes_written, error);
19213 // Converts a string which is in the encoding used for strings by
19214 // the C runtime (usually the same as that used by the operating
19215 // system) in the <link linkend="setlocale">current locale</link> into a
19216 // UTF-8 string.
19217 // RETURNS: The converted string, or %NULL on an error.
19218 // <opsysstring>: a string in the encoding of the current locale. On Windows this means the system codepage.
19219 // <len>: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
19220 // <bytes_read>: location to store the number of bytes in the input string that were successfully converted, or %NULL. Even if the conversion was successful, this may be less than @len if there were partial characters at the end of the input. If the error #G_CONVERT_ERROR_ILLEGAL_SEQUENCE occurs, the value stored will the byte offset after the last valid input sequence.
19221 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
19222 static char* /*new*/ locale_to_utf8()(char* opsysstring, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error=null) {
19223 return g_locale_to_utf8(opsysstring, len, bytes_read, bytes_written, error);
19227 // Unintrospectable function: log() / g_log()
19228 // Logs an error or debugging message.
19230 // If the log level has been set as fatal, the abort()
19231 // function is called to terminate the program.
19232 // <log_domain>: the log domain, usually #G_LOG_DOMAIN
19233 // <log_level>: the log level, either from #GLogLevelFlags or a user-defined level
19234 // <format>: the message format. See the printf() documentation
19235 alias g_log log; // Variadic
19238 // The default log handler set up by GLib; g_log_set_default_handler()
19239 // allows to install an alternate default log handler.
19240 // This is used if no log handler has been set for the particular log
19241 // domain and log level combination. It outputs the message to stderr
19242 // or stdout and if the log level is fatal it calls abort().
19244 // The behavior of this log handler can be influenced by a number of
19245 // environment variables:
19246 // <variablelist>
19247 // <varlistentry>
19248 // <term><envar>G_MESSAGES_PREFIXED</envar></term>
19249 // <listitem>
19250 // A :-separated list of log levels for which messages should
19251 // be prefixed by the program name and PID of the aplication.
19252 // </listitem>
19253 // </varlistentry>
19254 // <varlistentry>
19255 // <term><envar>G_MESSAGES_DEBUG</envar></term>
19256 // <listitem>
19257 // A space-separated list of log domains for which debug and
19258 // informational messages are printed. By default these
19259 // messages are not printed.
19260 // </listitem>
19261 // </varlistentry>
19262 // </variablelist>
19264 // stderr is used for levels %G_LOG_LEVEL_ERROR, %G_LOG_LEVEL_CRITICAL,
19265 // %G_LOG_LEVEL_WARNING and %G_LOG_LEVEL_MESSAGE. stdout is used for
19266 // the rest.
19267 // <log_domain>: the log domain of the message
19268 // <log_level>: the level of the message
19269 // <message>: the message
19270 // <unused_data>: data passed from g_log() which is unused
19271 static void log_default_handler()(char* log_domain, LogLevelFlags log_level, char* message, void* unused_data) {
19272 g_log_default_handler(log_domain, log_level, message, unused_data);
19276 // Removes the log handler.
19277 // <log_domain>: the log domain
19278 // <handler_id>: the id of the handler, which was returned in g_log_set_handler()
19279 static void log_remove_handler()(char* log_domain, uint handler_id) {
19280 g_log_remove_handler(log_domain, handler_id);
19284 // Sets the message levels which are always fatal, in any log domain.
19285 // When a message with any of these levels is logged the program terminates.
19286 // You can only set the levels defined by GLib to be fatal.
19287 // %G_LOG_LEVEL_ERROR is always fatal.
19289 // You can also make some message levels fatal at runtime by setting
19290 // the <envar>G_DEBUG</envar> environment variable (see
19291 // <ulink url="glib-running.html">Running GLib Applications</ulink>).
19292 // RETURNS: the old fatal mask
19293 // <fatal_mask>: the mask containing bits set for each level of error which is to be fatal
19294 static LogLevelFlags log_set_always_fatal()(LogLevelFlags fatal_mask) {
19295 return g_log_set_always_fatal(fatal_mask);
19299 // Unintrospectable function: log_set_default_handler() / g_log_set_default_handler()
19300 // VERSION: 2.6
19301 // Installs a default log handler which is used if no
19302 // log handler has been set for the particular log domain
19303 // and log level combination. By default, GLib uses
19304 // g_log_default_handler() as default log handler.
19305 // RETURNS: the previous default log handler
19306 // <log_func>: the log handler function
19307 // <user_data>: data passed to the log handler
19308 static LogFunc log_set_default_handler()(LogFunc log_func, void* user_data) {
19309 return g_log_set_default_handler(log_func, user_data);
19313 // Sets the log levels which are fatal in the given domain.
19314 // %G_LOG_LEVEL_ERROR is always fatal.
19315 // RETURNS: the old fatal mask for the log domain
19316 // <log_domain>: the log domain
19317 // <fatal_mask>: the new fatal mask
19318 static LogLevelFlags log_set_fatal_mask()(char* log_domain, LogLevelFlags fatal_mask) {
19319 return g_log_set_fatal_mask(log_domain, fatal_mask);
19323 // Unintrospectable function: log_set_handler() / g_log_set_handler()
19324 // Sets the log handler for a domain and a set of log levels.
19325 // To handle fatal and recursive messages the @log_levels parameter
19326 // must be combined with the #G_LOG_FLAG_FATAL and #G_LOG_FLAG_RECURSION
19327 // bit flags.
19329 // Note that since the #G_LOG_LEVEL_ERROR log level is always fatal, if
19330 // you want to set a handler for this log level you must combine it with
19331 // #G_LOG_FLAG_FATAL.
19333 // <example>
19334 // <title>Adding a log handler for all warning messages in the default
19335 // (application) domain</title>
19336 // <programlisting>
19337 // g_log_set_handler (NULL, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
19338 // | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
19339 // </programlisting>
19340 // </example>
19342 // <example>
19343 // <title>Adding a log handler for all critical messages from GTK+</title>
19344 // <programlisting>
19345 // g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL
19346 // | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
19347 // </programlisting>
19348 // </example>
19350 // <example>
19351 // <title>Adding a log handler for <emphasis>all</emphasis> messages from
19352 // GLib</title>
19353 // <programlisting>
19354 // g_log_set_handler ("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
19355 // | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
19356 // </programlisting>
19357 // </example>
19358 // RETURNS: the id of the new handler
19359 // <log_domain>: the log domain, or %NULL for the default "" application domain
19360 // <log_levels>: the log levels to apply the log handler for. To handle fatal and recursive messages as well, combine the log levels with the #G_LOG_FLAG_FATAL and #G_LOG_FLAG_RECURSION bit flags.
19361 // <log_func>: the log handler function
19362 // <user_data>: data passed to the log handler
19363 static uint log_set_handler()(char* log_domain, LogLevelFlags log_levels, LogFunc log_func, void* user_data) {
19364 return g_log_set_handler(log_domain, log_levels, log_func, user_data);
19368 // Unintrospectable function: logv() / g_logv()
19369 // Logs an error or debugging message.
19371 // If the log level has been set as fatal, the abort()
19372 // function is called to terminate the program.
19373 // <log_domain>: the log domain
19374 // <log_level>: the log level
19375 // <format>: the message format. See the printf() documentation
19376 // <args>: the parameters to insert into the format string
19377 static void logv()(char* log_domain, LogLevelFlags log_level, char* format, va_list args) {
19378 g_logv(log_domain, log_level, format, args);
19382 // MOVED TO: MainContext.default
19383 // Returns the global default main context. This is the main context
19384 // used for main loop functions when a main loop is not explicitly
19385 // specified, and corresponds to the "main" main loop. See also
19386 // g_main_context_get_thread_default().
19387 // RETURNS: the global default main context.
19388 static MainContext* main_context_default()() {
19389 return g_main_context_default();
19393 // VERSION: 2.22
19394 // MOVED TO: MainContext.get_thread_default
19395 // Gets the thread-default #GMainContext for this thread. Asynchronous
19396 // operations that want to be able to be run in contexts other than
19397 // the default one should call this method or
19398 // g_main_context_ref_thread_default() to get a #GMainContext to add
19399 // their #GSource<!-- -->s to. (Note that even in single-threaded
19400 // programs applications may sometimes want to temporarily push a
19401 // non-default context, so it is not safe to assume that this will
19402 // always return %NULL if you are running in the default thread.)
19404 // If you need to hold a reference on the context, use
19405 // g_main_context_ref_thread_default() instead.
19407 // %NULL if the thread-default context is the global default context.
19408 // RETURNS: the thread-default #GMainContext, or
19409 static MainContext* main_context_get_thread_default()() {
19410 return g_main_context_get_thread_default();
19414 // VERSION: 2.32
19415 // MOVED TO: MainContext.ref_thread_default
19416 // Gets the thread-default #GMainContext for this thread, as with
19417 // g_main_context_get_thread_default(), but also adds a reference to
19418 // it with g_main_context_ref(). In addition, unlike
19419 // g_main_context_get_thread_default(), if the thread-default context
19420 // is the global default context, this will return that #GMainContext
19421 // (with a ref added to it) rather than returning %NULL.
19423 // with g_main_context_unref() when you are done with it.
19424 // RETURNS: the thread-default #GMainContext. Unref
19425 static MainContext* /*new*/ main_context_ref_thread_default()() {
19426 return g_main_context_ref_thread_default();
19430 // VERSION: 2.12
19431 // Returns the currently firing source for this thread.
19432 // RETURNS: The currently firing source or %NULL.
19433 static Source* main_current_source()() {
19434 return g_main_current_source();
19438 // Returns the depth of the stack of calls to
19439 // g_main_context_dispatch() on any #GMainContext in the current thread.
19440 // That is, when called from the toplevel, it gives 0. When
19441 // called from within a callback from g_main_context_iteration()
19442 // (or g_main_loop_run(), etc.) it returns 1. When called from within
19443 // a callback to a recursive call to g_main_context_iteration(),
19444 // it returns 2. And so forth.
19446 // This function is useful in a situation like the following:
19447 // Imagine an extremely simple "garbage collected" system.
19449 // |[
19450 // static GList *free_list;
19452 // gpointer
19453 // allocate_memory (gsize size)
19454 // {
19455 // gpointer result = g_malloc (size);
19456 // free_list = g_list_prepend (free_list, result);
19457 // return result;
19458 // }
19460 // void
19461 // free_allocated_memory (void)
19462 // {
19463 // GList *l;
19464 // for (l = free_list; l; l = l->next);
19465 // g_free (l->data);
19466 // g_list_free (free_list);
19467 // free_list = NULL;
19468 // }
19470 // [...]
19472 // while (TRUE);
19473 // {
19474 // g_main_context_iteration (NULL, TRUE);
19475 // free_allocated_memory();
19476 // }
19477 // ]|
19479 // This works from an application, however, if you want to do the same
19480 // thing from a library, it gets more difficult, since you no longer
19481 // control the main loop. You might think you can simply use an idle
19482 // function to make the call to free_allocated_memory(), but that
19483 // doesn't work, since the idle function could be called from a
19484 // recursive callback. This can be fixed by using g_main_depth()
19486 // |[
19487 // gpointer
19488 // allocate_memory (gsize size)
19489 // {
19490 // FreeListBlock *block = g_new (FreeListBlock, 1);
19491 // block->mem = g_malloc (size);
19492 // block->depth = g_main_depth ();
19493 // free_list = g_list_prepend (free_list, block);
19494 // return block->mem;
19495 // }
19497 // void
19498 // free_allocated_memory (void)
19499 // {
19500 // GList *l;
19502 // int depth = g_main_depth ();
19503 // for (l = free_list; l; );
19504 // {
19505 // GList *next = l->next;
19506 // FreeListBlock *block = l->data;
19507 // if (block->depth > depth)
19508 // {
19509 // g_free (block->mem);
19510 // g_free (block);
19511 // free_list = g_list_delete_link (free_list, l);
19512 // }
19514 // l = next;
19515 // }
19516 // }
19517 // ]|
19519 // There is a temptation to use g_main_depth() to solve
19520 // problems with reentrancy. For instance, while waiting for data
19521 // to be received from the network in response to a menu item,
19522 // the menu item might be selected again. It might seem that
19523 // one could make the menu item's callback return immediately
19524 // and do nothing if g_main_depth() returns a value greater than 1.
19525 // However, this should be avoided since the user then sees selecting
19526 // the menu item do nothing. Furthermore, you'll find yourself adding
19527 // these checks all over your code, since there are doubtless many,
19528 // many things that the user could do. Instead, you can use the
19529 // following techniques:
19531 // <orderedlist>
19532 // <listitem>
19533 // <para>
19534 // Use gtk_widget_set_sensitive() or modal dialogs to prevent
19535 // the user from interacting with elements while the main
19536 // loop is recursing.
19537 // </para>
19538 // </listitem>
19539 // <listitem>
19540 // <para>
19541 // Avoid main loop recursion in situations where you can't handle
19542 // arbitrary callbacks. Instead, structure your code so that you
19543 // simply return to the main loop and then get called again when
19544 // there is more work to do.
19545 // </para>
19546 // </listitem>
19547 // </orderedlist>
19548 // RETURNS: The main loop recursion level in the current thread
19549 static int main_depth()() {
19550 return g_main_depth();
19554 // Unintrospectable function: malloc() / g_malloc()
19555 // Allocates @n_bytes bytes of memory.
19556 // If @n_bytes is 0 it returns %NULL.
19557 // RETURNS: a pointer to the allocated memory
19558 // <n_bytes>: the number of bytes to allocate
19559 static void* malloc()(size_t n_bytes) {
19560 return g_malloc(n_bytes);
19564 // Unintrospectable function: malloc0() / g_malloc0()
19565 // Allocates @n_bytes bytes of memory, initialized to 0's.
19566 // If @n_bytes is 0 it returns %NULL.
19567 // RETURNS: a pointer to the allocated memory
19568 // <n_bytes>: the number of bytes to allocate
19569 static void* malloc0()(size_t n_bytes) {
19570 return g_malloc0(n_bytes);
19574 // Unintrospectable function: malloc0_n() / g_malloc0_n()
19575 // VERSION: 2.24
19576 // This function is similar to g_malloc0(), allocating (@n_blocks * @n_block_bytes) bytes,
19577 // but care is taken to detect possible overflow during multiplication.
19578 // RETURNS: a pointer to the allocated memory
19579 // <n_blocks>: the number of blocks to allocate
19580 // <n_block_bytes>: the size of each block in bytes
19581 static void* malloc0_n()(size_t n_blocks, size_t n_block_bytes) {
19582 return g_malloc0_n(n_blocks, n_block_bytes);
19586 // Unintrospectable function: malloc_n() / g_malloc_n()
19587 // VERSION: 2.24
19588 // This function is similar to g_malloc(), allocating (@n_blocks * @n_block_bytes) bytes,
19589 // but care is taken to detect possible overflow during multiplication.
19590 // RETURNS: a pointer to the allocated memory
19591 // <n_blocks>: the number of blocks to allocate
19592 // <n_block_bytes>: the size of each block in bytes
19593 static void* malloc_n()(size_t n_blocks, size_t n_block_bytes) {
19594 return g_malloc_n(n_blocks, n_block_bytes);
19598 // Unintrospectable function: markup_collect_attributes() / g_markup_collect_attributes()
19599 // VERSION: 2.16
19600 // Collects the attributes of the element from the data passed to the
19601 // #GMarkupParser start_element function, dealing with common error
19602 // conditions and supporting boolean values.
19604 // This utility function is not required to write a parser but can save
19605 // a lot of typing.
19607 // The @element_name, @attribute_names, @attribute_values and @error
19608 // parameters passed to the start_element callback should be passed
19609 // unmodified to this function.
19611 // Following these arguments is a list of "supported" attributes to collect.
19612 // It is an error to specify multiple attributes with the same name. If any
19613 // attribute not in the list appears in the @attribute_names array then an
19614 // unknown attribute error will result.
19616 // The #GMarkupCollectType field allows specifying the type of collection
19617 // to perform and if a given attribute must appear or is optional.
19619 // The attribute name is simply the name of the attribute to collect.
19621 // The pointer should be of the appropriate type (see the descriptions
19622 // under #GMarkupCollectType) and may be %NULL in case a particular
19623 // attribute is to be allowed but ignored.
19625 // This function deals with issuing errors for missing attributes
19626 // (of type %G_MARKUP_ERROR_MISSING_ATTRIBUTE), unknown attributes
19627 // (of type %G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE) and duplicate
19628 // attributes (of type %G_MARKUP_ERROR_INVALID_CONTENT) as well
19629 // as parse errors for boolean-valued attributes (again of type
19630 // %G_MARKUP_ERROR_INVALID_CONTENT). In all of these cases %FALSE
19631 // will be returned and @error will be set as appropriate.
19632 // RETURNS: %TRUE if successful
19633 // <element_name>: the current tag name
19634 // <attribute_names>: the attribute names
19635 // <attribute_values>: the attribute values
19636 // <error>: a pointer to a #GError or %NULL
19637 // <first_type>: the #GMarkupCollectType of the first attribute
19638 // <first_attr>: the name of the first attribute
19639 alias g_markup_collect_attributes markup_collect_attributes; // Variadic
19641 static Quark markup_error_quark()() {
19642 return g_markup_error_quark();
19646 // Escapes text so that the markup parser will parse it verbatim.
19647 // Less than, greater than, ampersand, etc. are replaced with the
19648 // corresponding entities. This function would typically be used
19649 // when writing out a file to be parsed with the markup parser.
19651 // Note that this function doesn't protect whitespace and line endings
19652 // from being processed according to the XML rules for normalization
19653 // of line endings and attribute values.
19655 // Note also that this function will produce character references in
19656 // the range of &amp;#x1; ... &amp;#x1f; for all control sequences
19657 // except for tabstop, newline and carriage return. The character
19658 // references in this range are not valid XML 1.0, but they are
19659 // valid XML 1.1 and will be accepted by the GMarkup parser.
19660 // RETURNS: a newly allocated string with the escaped text
19661 // <text>: some valid UTF-8 text
19662 // <length>: length of @text in bytes, or -1 if the text is nul-terminated
19663 static char* /*new*/ markup_escape_text()(char* text, ssize_t length) {
19664 return g_markup_escape_text(text, length);
19668 // Unintrospectable function: markup_printf_escaped() / g_markup_printf_escaped()
19669 // VERSION: 2.4
19670 // Formats arguments according to @format, escaping
19671 // all string and character arguments in the fashion
19672 // of g_markup_escape_text(). This is useful when you
19673 // want to insert literal strings into XML-style markup
19674 // output, without having to worry that the strings
19675 // might themselves contain markup.
19677 // |[
19678 // const char *store = "Fortnum &amp; Mason";
19679 // const char *item = "Tea";
19680 // char *output;
19681 // &nbsp;
19682 // output = g_markup_printf_escaped ("&lt;purchase&gt;"
19683 // "&lt;store&gt;&percnt;s&lt;/store&gt;"
19684 // "&lt;item&gt;&percnt;s&lt;/item&gt;"
19685 // "&lt;/purchase&gt;",
19686 // store, item);
19687 // ]|
19689 // operation. Free with g_free().
19690 // RETURNS: newly allocated result from formatting
19691 // <format>: printf() style format string
19692 alias g_markup_printf_escaped markup_printf_escaped; // Variadic
19695 // Unintrospectable function: markup_vprintf_escaped() / g_markup_vprintf_escaped()
19696 // VERSION: 2.4
19697 // Formats the data in @args according to @format, escaping
19698 // all string and character arguments in the fashion
19699 // of g_markup_escape_text(). See g_markup_printf_escaped().
19701 // operation. Free with g_free().
19702 // RETURNS: newly allocated result from formatting
19703 // <format>: printf() style format string
19704 // <args>: variable argument list, similar to vprintf()
19705 static char* /*new*/ markup_vprintf_escaped()(char* format, va_list args) {
19706 return g_markup_vprintf_escaped(format, args);
19710 // Checks whether the allocator used by g_malloc() is the system's
19711 // malloc implementation. If it returns %TRUE memory allocated with
19712 // malloc() can be used interchangeable with memory allocated using g_malloc().
19713 // This function is useful for avoiding an extra copy of allocated memory returned
19714 // by a non-GLib-based API.
19716 // A different allocator can be set using g_mem_set_vtable().
19717 // RETURNS: if %TRUE, malloc() and g_malloc() can be mixed.
19718 static int mem_is_system_malloc()() {
19719 return g_mem_is_system_malloc();
19723 // Outputs a summary of memory usage.
19725 // It outputs the frequency of allocations of different sizes,
19726 // the total number of bytes which have been allocated,
19727 // the total number of bytes which have been freed,
19728 // and the difference between the previous two values, i.e. the number of bytes
19729 // still in use.
19731 // Note that this function will not output anything unless you have
19732 // previously installed the #glib_mem_profiler_table with g_mem_set_vtable().
19733 static void mem_profile()() {
19734 g_mem_profile();
19738 // Sets the #GMemVTable to use for memory allocation. You can use this to provide
19739 // custom memory allocation routines. <emphasis>This function must be called
19740 // before using any other GLib functions.</emphasis> The @vtable only needs to
19741 // provide malloc(), realloc(), and free() functions; GLib can provide default
19742 // implementations of the others. The malloc() and realloc() implementations
19743 // should return %NULL on failure, GLib will handle error-checking for you.
19744 // @vtable is copied, so need not persist after this function has been called.
19745 // <vtable>: table of memory allocation routines.
19746 static void mem_set_vtable()(MemVTable* vtable) {
19747 g_mem_set_vtable(vtable);
19751 // Unintrospectable function: memdup() / g_memdup()
19752 // Allocates @byte_size bytes of memory, and copies @byte_size bytes into it
19753 // from @mem. If @mem is %NULL it returns %NULL.
19755 // is %NULL.
19756 // RETURNS: a pointer to the newly-allocated copy of the memory, or %NULL if @mem
19757 // <mem>: the memory to copy.
19758 // <byte_size>: the number of bytes to copy.
19759 static void* memdup()(const(void)* mem, uint byte_size) {
19760 return g_memdup(mem, byte_size);
19764 // VERSION: 2.8
19765 // Create a directory if it doesn't already exist. Create intermediate
19766 // parent directories as needed, too.
19768 // created. Returns -1 if an error occurred, with errno set.
19769 // RETURNS: 0 if the directory already exists, or was successfully
19770 // <pathname>: a pathname in the GLib file name encoding
19771 // <mode>: permissions to use for newly created directories
19772 static int mkdir_with_parents()(char* pathname, int mode) {
19773 return g_mkdir_with_parents(pathname, mode);
19777 // VERSION: 2.30
19778 // Creates a temporary directory. See the mkdtemp() documentation
19779 // on most UNIX-like systems.
19781 // The parameter is a string that should follow the rules for
19782 // mkdtemp() templates, i.e. contain the string "XXXXXX".
19783 // g_mkdtemp() is slightly more flexible than mkdtemp() in that the
19784 // sequence does not have to occur at the very end of the template
19785 // and you can pass a @mode and additional @flags. The X string will
19786 // be modified to form the name of a directory that didn't exist.
19787 // The string should be in the GLib file name encoding. Most importantly,
19788 // on Windows it should be in UTF-8.
19790 // to hold the directory name. In case of errors, %NULL is
19791 // returned and %errno will be set.
19792 // RETURNS: A pointer to @tmpl, which has been modified
19793 // <tmpl>: template directory name
19794 static char* /*new*/ mkdtemp()(char* tmpl) {
19795 return g_mkdtemp(tmpl);
19799 // VERSION: 2.30
19800 // Creates a temporary directory. See the mkdtemp() documentation
19801 // on most UNIX-like systems.
19803 // The parameter is a string that should follow the rules for
19804 // mkdtemp() templates, i.e. contain the string "XXXXXX".
19805 // g_mkdtemp() is slightly more flexible than mkdtemp() in that the
19806 // sequence does not have to occur at the very end of the template
19807 // and you can pass a @mode. The X string will be modified to form
19808 // the name of a directory that didn't exist. The string should be
19809 // in the GLib file name encoding. Most importantly, on Windows it
19810 // should be in UTF-8.
19812 // to hold the directory name. In case of errors, %NULL is
19813 // returned, and %errno will be set.
19814 // RETURNS: A pointer to @tmpl, which has been modified
19815 // <tmpl>: template directory name
19816 // <mode>: permissions to create the temporary directory with
19817 static char* /*new*/ mkdtemp_full()(char* tmpl, int mode) {
19818 return g_mkdtemp_full(tmpl, mode);
19822 // Opens a temporary file. See the mkstemp() documentation
19823 // on most UNIX-like systems.
19825 // The parameter is a string that should follow the rules for
19826 // mkstemp() templates, i.e. contain the string "XXXXXX".
19827 // g_mkstemp() is slightly more flexible than mkstemp() in that the
19828 // sequence does not have to occur at the very end of the template.
19829 // The X string will be modified to form the name of a file that
19830 // didn't exist. The string should be in the GLib file name encoding.
19831 // Most importantly, on Windows it should be in UTF-8.
19833 // opened for reading and writing. The file is opened in binary
19834 // mode on platforms where there is a difference. The file handle
19835 // should be closed with close(). In case of errors, -1 is
19836 // returned and %errno will be set.
19837 // RETURNS: A file handle (as from open()) to the file
19838 // <tmpl>: template filename
19839 static int mkstemp()(char* tmpl) {
19840 return g_mkstemp(tmpl);
19844 // VERSION: 2.22
19845 // Opens a temporary file. See the mkstemp() documentation
19846 // on most UNIX-like systems.
19848 // The parameter is a string that should follow the rules for
19849 // mkstemp() templates, i.e. contain the string "XXXXXX".
19850 // g_mkstemp_full() is slightly more flexible than mkstemp()
19851 // in that the sequence does not have to occur at the very end of the
19852 // template and you can pass a @mode and additional @flags. The X
19853 // string will be modified to form the name of a file that didn't exist.
19854 // The string should be in the GLib file name encoding. Most importantly,
19855 // on Windows it should be in UTF-8.
19857 // opened for reading and writing. The file handle should be
19858 // closed with close(). In case of errors, -1 is returned
19859 // and %errno will be set.
19860 // RETURNS: A file handle (as from open()) to the file
19861 // <tmpl>: template filename
19862 // <flags>: flags to pass to an open() call in addition to O_EXCL and O_CREAT, which are passed automatically
19863 // <mode>: permissions to create the temporary file with
19864 static int mkstemp_full()(char* tmpl, int flags, int mode) {
19865 return g_mkstemp_full(tmpl, flags, mode);
19869 // Set the pointer at the specified location to %NULL.
19870 // <nullify_location>: the memory address of the pointer.
19871 static void nullify_pointer()(void** nullify_location) {
19872 g_nullify_pointer(nullify_location);
19876 // Prompts the user with
19877 // <computeroutput>[E]xit, [H]alt, show [S]tack trace or [P]roceed</computeroutput>.
19878 // This function is intended to be used for debugging use only.
19879 // The following example shows how it can be used together with
19880 // the g_log() functions.
19882 // |[
19883 // &num;include &lt;glib.h&gt;
19885 // static void
19886 // log_handler (const gchar *log_domain,
19887 // GLogLevelFlags log_level,
19888 // const gchar *message,
19889 // gpointer user_data)
19890 // {
19891 // g_log_default_handler (log_domain, log_level, message, user_data);
19893 // g_on_error_query (MY_PROGRAM_NAME);
19894 // }
19896 // int
19897 // main (int argc, char *argv[])
19898 // {
19899 // g_log_set_handler (MY_LOG_DOMAIN,
19900 // G_LOG_LEVEL_WARNING |
19901 // G_LOG_LEVEL_ERROR |
19902 // G_LOG_LEVEL_CRITICAL,
19903 // log_handler,
19904 // NULL);
19905 // /&ast; ... &ast;/
19906 // ]|
19908 // If [E]xit is selected, the application terminates with a call
19909 // to <literal>_exit(0)</literal>.
19911 // If [S]tack trace is selected, g_on_error_stack_trace() is called.
19912 // This invokes <command>gdb</command>, which attaches to the current
19913 // process and shows a stack trace. The prompt is then shown again.
19915 // If [P]roceed is selected, the function returns.
19917 // This function may cause different actions on non-UNIX platforms.
19918 // <prg_name>: the program name, needed by <command>gdb</command> for the [S]tack trace option. If @prg_name is %NULL, g_get_prgname() is called to get the program name (which will work correctly if gdk_init() or gtk_init() has been called)
19919 static void on_error_query()(char* prg_name) {
19920 g_on_error_query(prg_name);
19924 // Invokes <command>gdb</command>, which attaches to the current
19925 // process and shows a stack trace. Called by g_on_error_query()
19926 // when the [S]tack trace option is selected. You can get the current
19927 // process's "program name" with g_get_prgname(), assuming that you
19928 // have called gtk_init() or gdk_init().
19930 // This function may cause different actions on non-UNIX platforms.
19931 // <prg_name>: the program name, needed by <command>gdb</command> for the [S]tack trace option.
19932 static void on_error_stack_trace()(char* prg_name) {
19933 g_on_error_stack_trace(prg_name);
19937 // VERSION: 2.14
19938 // MOVED TO: Once.init_enter
19939 // Function to be called when starting a critical initialization
19940 // section. The argument @location must point to a static
19941 // 0-initialized variable that will be set to a value other than 0 at
19942 // the end of the initialization section. In combination with
19943 // g_once_init_leave() and the unique address @value_location, it can
19944 // be ensured that an initialization section will be executed only once
19945 // during a program's life time, and that concurrent threads are
19946 // blocked until initialization completed. To be used in constructs
19947 // like this:
19949 // |[
19950 // static gsize initialization_value = 0;
19952 // if (g_once_init_enter (&amp;initialization_value))
19953 // {
19954 // gsize setup_value = 42; /&ast;* initialization code here *&ast;/
19956 // g_once_init_leave (&amp;initialization_value, setup_value);
19957 // }
19959 // /&ast;* use initialization_value here *&ast;/
19960 // ]|
19962 // %FALSE and blocks otherwise
19963 // RETURNS: %TRUE if the initialization section should be entered,
19964 // <location>: location of a static initializable variable containing 0
19965 static int once_init_enter()(void* location) {
19966 return g_once_init_enter(location);
19970 // VERSION: 2.14
19971 // MOVED TO: Once.init_leave
19972 // Counterpart to g_once_init_enter(). Expects a location of a static
19973 // 0-initialized initialization variable, and an initialization value
19974 // other than 0. Sets the variable to the initialization value, and
19975 // releases concurrent threads blocking in g_once_init_enter() on this
19976 // initialization variable.
19977 // <location>: location of a static initializable variable containing 0
19978 // <result>: new non-0 value for *@value_location
19979 static void once_init_leave()(void* location, size_t result) {
19980 g_once_init_leave(location, result);
19983 static Quark option_error_quark()() {
19984 return g_option_error_quark();
19988 // Parses a string containing debugging options
19989 // into a %guint containing bit flags. This is used
19990 // within GDK and GTK+ to parse the debug options passed on the
19991 // command line or through environment variables.
19993 // If @string is equal to <code>"all"</code>, all flags are set. Any flags
19994 // specified along with <code>"all"</code> in @string are inverted; thus,
19995 // <code>"all,foo,bar"</code> or <code>"foo,bar,all"</code> sets all flags
19996 // except those corresponding to <code>"foo"</code> and <code>"bar"</code>.
19998 // If @string is equal to <code>"help"</code>, all the available keys in @keys
19999 // are printed out to standard error.
20000 // RETURNS: the combined set of bit flags.
20001 // <string>: a list of debug options separated by colons, spaces, or commas, or %NULL.
20002 // <keys>: pointer to an array of #GDebugKey which associate strings with bit flags.
20003 // <nkeys>: the number of #GDebugKey<!-- -->s in the array.
20004 static uint parse_debug_string()(char* string_, DebugKey* keys, uint nkeys) {
20005 return g_parse_debug_string(string_, keys, nkeys);
20009 // Gets the last component of the filename.
20011 // If @file_name ends with a directory separator it gets the component
20012 // before the last slash. If @file_name consists only of directory
20013 // separators (and on Windows, possibly a drive letter), a single
20014 // separator is returned. If @file_name is empty, it gets ".".
20016 // component of the filename
20017 // RETURNS: a newly allocated string containing the last
20018 // <file_name>: the name of the file
20019 static char* /*new*/ path_get_basename()(char* file_name) {
20020 return g_path_get_basename(file_name);
20024 // Gets the directory components of a file name.
20026 // If the file name has no directory components "." is returned.
20027 // The returned string should be freed when no longer needed.
20028 // RETURNS: the directory components of the file
20029 // <file_name>: the name of the file
20030 static char* /*new*/ path_get_dirname()(char* file_name) {
20031 return g_path_get_dirname(file_name);
20035 // Returns %TRUE if the given @file_name is an absolute file name.
20036 // Note that this is a somewhat vague concept on Windows.
20038 // On POSIX systems, an absolute file name is well-defined. It always
20039 // starts from the single root directory. For example "/usr/local".
20041 // On Windows, the concepts of current drive and drive-specific
20042 // current directory introduce vagueness. This function interprets as
20043 // an absolute file name one that either begins with a directory
20044 // separator such as "\Users\tml" or begins with the root on a drive,
20045 // for example "C:\Windows". The first case also includes UNC paths
20046 // such as "\\myserver\docs\foo". In all cases, either slashes or
20047 // backslashes are accepted.
20049 // Note that a file name relative to the current drive root does not
20050 // truly specify a file uniquely over time and across processes, as
20051 // the current drive is a per-process value and can be changed.
20053 // File names relative the current directory on some specific drive,
20054 // such as "D:foo/bar", are not interpreted as absolute by this
20055 // function, but they obviously are not relative to the normal current
20056 // directory as returned by getcwd() or g_get_current_dir()
20057 // either. Such paths should be avoided, or need to be handled using
20058 // Windows-specific code.
20059 // RETURNS: %TRUE if @file_name is absolute
20060 // <file_name>: a file name
20061 static int path_is_absolute()(char* file_name) {
20062 return g_path_is_absolute(file_name);
20066 // Returns a pointer into @file_name after the root component,
20067 // i.e. after the "/" in UNIX or "C:\" under Windows. If @file_name
20068 // is not an absolute path it returns %NULL.
20069 // RETURNS: a pointer into @file_name after the root component
20070 // <file_name>: a file name
20071 static char* path_skip_root()(char* file_name) {
20072 return g_path_skip_root(file_name);
20076 // Matches a string against a compiled pattern. Passing the correct
20077 // length of the string given is mandatory. The reversed string can be
20078 // omitted by passing %NULL, this is more efficient if the reversed
20079 // version of the string to be matched is not at hand, as
20080 // g_pattern_match() will only construct it if the compiled pattern
20081 // requires reverse matches.
20083 // Note that, if the user code will (possibly) match a string against a
20084 // multitude of patterns containing wildcards, chances are high that
20085 // some patterns will require a reversed string. In this case, it's
20086 // more efficient to provide the reversed string to avoid multiple
20087 // constructions thereof in the various calls to g_pattern_match().
20089 // Note also that the reverse of a UTF-8 encoded string can in general
20090 // <emphasis>not</emphasis> be obtained by g_strreverse(). This works
20091 // only if the string doesn't contain any multibyte characters. GLib
20092 // offers the g_utf8_strreverse() function to reverse UTF-8 encoded
20093 // strings.
20094 // <pspec>: a #GPatternSpec
20095 // <string_length>: the length of @string (in bytes, i.e. strlen(), <emphasis>not</emphasis> g_utf8_strlen())
20096 // <string>: the UTF-8 encoded string to match
20097 // <string_reversed>: the reverse of @string or %NULL
20098 static int pattern_match()(PatternSpec* pspec, uint string_length, char* string_, char* string_reversed) {
20099 return g_pattern_match(pspec, string_length, string_, string_reversed);
20103 // Matches a string against a pattern given as a string. If this
20104 // function is to be called in a loop, it's more efficient to compile
20105 // the pattern once with g_pattern_spec_new() and call
20106 // g_pattern_match_string() repeatedly.
20107 // <pattern>: the UTF-8 encoded pattern
20108 // <string>: the UTF-8 encoded string to match
20109 static int pattern_match_simple()(char* pattern, char* string_) {
20110 return g_pattern_match_simple(pattern, string_);
20114 // Matches a string against a compiled pattern. If the string is to be
20115 // matched against more than one pattern, consider using
20116 // g_pattern_match() instead while supplying the reversed string.
20117 // <pspec>: a #GPatternSpec
20118 // <string>: the UTF-8 encoded string to match
20119 static int pattern_match_string()(PatternSpec* pspec, char* string_) {
20120 return g_pattern_match_string(pspec, string_);
20124 // VERSION: 2.30
20125 // This is equivalent to g_bit_lock, but working on pointers (or other
20126 // pointer-sized values).
20128 // For portability reasons, you may only lock on the bottom 32 bits of
20129 // the pointer.
20130 // <address>: a pointer to a #gpointer-sized value
20131 // <lock_bit>: a bit value between 0 and 31
20132 static void pointer_bit_lock()(void* address, int lock_bit) {
20133 g_pointer_bit_lock(address, lock_bit);
20137 // VERSION: 2.30
20138 // This is equivalent to g_bit_trylock, but working on pointers (or
20139 // other pointer-sized values).
20141 // For portability reasons, you may only lock on the bottom 32 bits of
20142 // the pointer.
20143 // RETURNS: %TRUE if the lock was acquired
20144 // <address>: a pointer to a #gpointer-sized value
20145 // <lock_bit>: a bit value between 0 and 31
20146 static int pointer_bit_trylock()(void* address, int lock_bit) {
20147 return g_pointer_bit_trylock(address, lock_bit);
20151 // VERSION: 2.30
20152 // This is equivalent to g_bit_unlock, but working on pointers (or other
20153 // pointer-sized values).
20155 // For portability reasons, you may only lock on the bottom 32 bits of
20156 // the pointer.
20157 // <address>: a pointer to a #gpointer-sized value
20158 // <lock_bit>: a bit value between 0 and 31
20159 static void pointer_bit_unlock()(void* address, int lock_bit) {
20160 g_pointer_bit_unlock(address, lock_bit);
20164 // VERSION: 2.20
20165 // Polls @fds, as with the poll() system call, but portably. (On
20166 // systems that don't have poll(), it is emulated using select().)
20167 // This is used internally by #GMainContext, but it can be called
20168 // directly if you need to block until a file descriptor is ready, but
20169 // don't want to run the full main loop.
20171 // Each element of @fds is a #GPollFD describing a single file
20172 // descriptor to poll. The %fd field indicates the file descriptor,
20173 // and the %events field indicates the events to poll for. On return,
20174 // the %revents fields will be filled with the events that actually
20175 // occurred.
20177 // On POSIX systems, the file descriptors in @fds can be any sort of
20178 // file descriptor, but the situation is much more complicated on
20179 // Windows. If you need to use g_poll() in code that has to run on
20180 // Windows, the easiest solution is to construct all of your
20181 // #GPollFD<!-- -->s with g_io_channel_win32_make_pollfd().
20183 // were filled in, or 0 if the operation timed out, or -1 on error or
20184 // if the call was interrupted.
20185 // RETURNS: the number of entries in @fds whose %revents fields
20186 // <fds>: file descriptors to poll
20187 // <nfds>: the number of file descriptors in @fds
20188 // <timeout>: amount of time to wait, in milliseconds, or -1 to wait forever
20189 static int poll()(PollFD* fds, uint nfds, int timeout) {
20190 return g_poll(fds, nfds, timeout);
20194 // Unintrospectable function: prefix_error() / g_prefix_error()
20195 // VERSION: 2.16
20196 // Formats a string according to @format and
20197 // prefix it to an existing error message. If
20198 // nothing.
20200 // If *@err is %NULL (ie: an error variable is
20201 // present but there is no error condition) then
20202 // also do nothing. Whether or not it makes
20203 // sense to take advantage of this feature is up
20204 // to you.
20205 // <err>: a return location for a #GError, or %NULL
20206 // <format>: printf()-style format string
20207 alias g_prefix_error prefix_error; // Variadic
20210 // Unintrospectable function: print() / g_print()
20211 // Outputs a formatted message via the print handler.
20212 // The default print handler simply outputs the message to stdout.
20214 // g_print() should not be used from within libraries for debugging
20215 // messages, since it may be redirected by applications to special
20216 // purpose message windows or even files. Instead, libraries should
20217 // use g_log(), or the convenience functions g_message(), g_warning()
20218 // and g_error().
20219 // <format>: the message format. See the printf() documentation
20220 alias g_print print; // Variadic
20223 // Unintrospectable function: printerr() / g_printerr()
20224 // Outputs a formatted message via the error message handler.
20225 // The default handler simply outputs the message to stderr.
20227 // g_printerr() should not be used from within libraries.
20228 // Instead g_log() should be used, or the convenience functions
20229 // g_message(), g_warning() and g_error().
20230 // <format>: the message format. See the printf() documentation
20231 alias g_printerr printerr; // Variadic
20234 // Unintrospectable function: printf() / g_printf()
20235 // VERSION: 2.2
20236 // An implementation of the standard printf() function which supports
20237 // positional parameters, as specified in the Single Unix Specification.
20238 // RETURNS: the number of bytes printed.
20239 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
20240 alias g_printf printf; // Variadic
20243 // Unintrospectable function: printf_string_upper_bound() / g_printf_string_upper_bound()
20244 // Calculates the maximum space needed to store the output
20245 // of the sprintf() function.
20246 // RETURNS: the maximum space needed to store the formatted string
20247 // <format>: the format string. See the printf() documentation
20248 // <args>: the parameters to be inserted into the format string
20249 static size_t printf_string_upper_bound()(char* format, va_list args) {
20250 return g_printf_string_upper_bound(format, args);
20254 // If @dest is %NULL, free @src; otherwise, moves @src into *@dest.
20255 // The error variable @dest points to must be %NULL.
20256 // <dest>: error return location
20257 // <src>: error to move into the return location
20258 static void propagate_error()(Error** dest, Error* src) {
20259 g_propagate_error(dest, src);
20263 // Unintrospectable function: propagate_prefixed_error() / g_propagate_prefixed_error()
20264 // VERSION: 2.16
20265 // If @dest is %NULL, free @src; otherwise,
20266 // moves @src into *@dest. *@dest must be %NULL.
20267 // After the move, add a prefix as with
20268 // g_prefix_error().
20269 // <dest>: error return location
20270 // <src>: error to move into the return location
20271 // <format>: printf()-style format string
20272 alias g_propagate_prefixed_error propagate_prefixed_error; // Variadic
20275 // MOVED TO: PtrArray.add
20276 // Adds a pointer to the end of the pointer array. The array will grow
20277 // in size automatically if necessary.
20278 // <array>: a #GPtrArray.
20279 // <data>: the pointer to add.
20280 static void ptr_array_add()(PtrArray* array, void* data) {
20281 g_ptr_array_add(array, data);
20285 // MOVED TO: PtrArray.remove
20286 // Removes the first occurrence of the given pointer from the pointer
20287 // array. The following elements are moved down one place. If @array
20288 // has a non-%NULL #GDestroyNotify function it is called for the
20289 // removed element.
20291 // It returns %TRUE if the pointer was removed, or %FALSE if the
20292 // pointer was not found.
20293 // <array>: a #GPtrArray.
20294 // <data>: the pointer to remove.
20295 static int ptr_array_remove()(PtrArray* array, void* data) {
20296 return g_ptr_array_remove(array, data);
20300 // MOVED TO: PtrArray.remove_fast
20301 // Removes the first occurrence of the given pointer from the pointer
20302 // array. The last element in the array is used to fill in the space,
20303 // so this function does not preserve the order of the array. But it is
20304 // faster than g_ptr_array_remove(). If @array has a non-%NULL
20305 // #GDestroyNotify function it is called for the removed element.
20307 // It returns %TRUE if the pointer was removed, or %FALSE if the
20308 // pointer was not found.
20309 // <array>: a #GPtrArray.
20310 // <data>: the pointer to remove.
20311 static int ptr_array_remove_fast()(PtrArray* array, void* data) {
20312 return g_ptr_array_remove_fast(array, data);
20316 // VERSION: 2.4
20317 // MOVED TO: PtrArray.remove_range
20318 // Removes the given number of pointers starting at the given index
20319 // from a #GPtrArray. The following elements are moved to close the
20320 // gap. If @array has a non-%NULL #GDestroyNotify function it is called
20321 // for the removed elements.
20322 // <array>: a @GPtrArray.
20323 // <index_>: the index of the first pointer to remove.
20324 // <length>: the number of pointers to remove.
20325 static void ptr_array_remove_range()(PtrArray* array, uint index_, uint length) {
20326 g_ptr_array_remove_range(array, index_, length);
20330 // VERSION: 2.22
20331 // MOVED TO: PtrArray.set_free_func
20332 // Sets a function for freeing each element when @array is destroyed
20333 // either via g_ptr_array_unref(), when g_ptr_array_free() is called
20334 // with @free_segment set to %TRUE or when removing elements.
20335 // <array>: A #GPtrArray.
20336 // <element_free_func>: A function to free elements with destroy @array or %NULL.
20337 static void ptr_array_set_free_func()(PtrArray* array, DestroyNotify element_free_func) {
20338 g_ptr_array_set_free_func(array, element_free_func);
20342 // MOVED TO: PtrArray.set_size
20343 // Sets the size of the array. When making the array larger,
20344 // newly-added elements will be set to %NULL. When making it smaller,
20345 // if @array has a non-%NULL #GDestroyNotify function then it will be
20346 // called for the removed elements.
20347 // <array>: a #GPtrArray.
20348 // <length>: the new length of the pointer array.
20349 static void ptr_array_set_size()(PtrArray* array, int length) {
20350 g_ptr_array_set_size(array, length);
20354 // VERSION: 2.22
20355 // MOVED TO: PtrArray.unref
20356 // Atomically decrements the reference count of @array by one. If the
20357 // reference count drops to 0, the effect is the same as calling
20358 // g_ptr_array_free() with @free_segment set to %TRUE. This function
20359 // is MT-safe and may be called from any thread.
20360 // <array>: A #GPtrArray.
20361 static void ptr_array_unref()(PtrArray* array) {
20362 g_ptr_array_unref(array);
20366 // Unintrospectable function: qsort_with_data() / g_qsort_with_data()
20367 // This is just like the standard C qsort() function, but
20368 // the comparison routine accepts a user data argument.
20369 // <pbase>: start of array to sort
20370 // <total_elems>: elements in the array
20371 // <size>: size of each element
20372 // <compare_func>: function to compare elements
20373 // <user_data>: data to pass to @compare_func
20374 static void qsort_with_data()(const(void)* pbase, int total_elems, size_t size, CompareDataFunc compare_func, void* user_data) {
20375 g_qsort_with_data(pbase, total_elems, size, compare_func, user_data);
20379 // Gets the #GQuark identifying the given (static) string. If the
20380 // string does not currently have an associated #GQuark, a new #GQuark
20381 // is created, linked to the given string.
20383 // Note that this function is identical to g_quark_from_string() except
20384 // that if a new #GQuark is created the string itself is used rather
20385 // than a copy. This saves memory, but can only be used if the string
20386 // will <emphasis>always</emphasis> exist. It can be used with
20387 // statically allocated strings in the main program, but not with
20388 // statically allocated memory in dynamically loaded modules, if you
20389 // expect to ever unload the module again (e.g. do not use this
20390 // function in GTK+ theme engines).
20391 // <string>: a string.
20392 static Quark quark_from_static_string()(char* string_=null) {
20393 return g_quark_from_static_string(string_);
20397 // Gets the #GQuark identifying the given string. If the string does
20398 // not currently have an associated #GQuark, a new #GQuark is created,
20399 // using a copy of the string.
20400 // <string>: a string.
20401 static Quark quark_from_string()(char* string_=null) {
20402 return g_quark_from_string(string_);
20406 // Gets the string associated with the given #GQuark.
20407 // <quark>: a #GQuark.
20408 static char* quark_to_string()(Quark quark) {
20409 return g_quark_to_string(quark);
20413 // Gets the #GQuark associated with the given string, or 0 if string is
20414 // %NULL or it has no associated #GQuark.
20416 // If you want the GQuark to be created if it doesn't already exist,
20417 // use g_quark_from_string() or g_quark_from_static_string().
20418 // <string>: a string.
20419 static Quark quark_try_string()(char* string_=null) {
20420 return g_quark_try_string(string_);
20424 // Returns a random #gdouble equally distributed over the range [0..1).
20425 // RETURNS: A random number.
20426 static double random_double()() {
20427 return g_random_double();
20431 // Returns a random #gdouble equally distributed over the range [@begin..@end).
20432 // RETURNS: A random number.
20433 // <begin>: lower closed bound of the interval.
20434 // <end>: upper open bound of the interval.
20435 static double random_double_range()(double begin, double end) {
20436 return g_random_double_range(begin, end);
20440 // Return a random #guint32 equally distributed over the range
20441 // [0..2^32-1].
20442 // RETURNS: A random number.
20443 static uint random_int()() {
20444 return g_random_int();
20448 // Returns a random #gint32 equally distributed over the range
20449 // [@begin..@end-1].
20450 // RETURNS: A random number.
20451 // <begin>: lower closed bound of the interval.
20452 // <end>: upper open bound of the interval.
20453 static int random_int_range()(int begin, int end) {
20454 return g_random_int_range(begin, end);
20458 // Sets the seed for the global random number generator, which is used
20459 // by the <function>g_random_*</function> functions, to @seed.
20460 // <seed>: a value to reinitialize the global random number generator.
20461 static void random_set_seed()(uint seed) {
20462 g_random_set_seed(seed);
20466 // Unintrospectable function: realloc() / g_realloc()
20467 // Reallocates the memory pointed to by @mem, so that it now has space for
20468 // @n_bytes bytes of memory. It returns the new address of the memory, which may
20469 // have been moved. @mem may be %NULL, in which case it's considered to
20470 // have zero-length. @n_bytes may be 0, in which case %NULL will be returned
20471 // and @mem will be freed unless it is %NULL.
20472 // RETURNS: the new address of the allocated memory
20473 // <mem>: the memory to reallocate
20474 // <n_bytes>: new size of the memory in bytes
20475 static void* realloc()(void* mem, size_t n_bytes) {
20476 return g_realloc(mem, n_bytes);
20480 // Unintrospectable function: realloc_n() / g_realloc_n()
20481 // VERSION: 2.24
20482 // This function is similar to g_realloc(), allocating (@n_blocks * @n_block_bytes) bytes,
20483 // but care is taken to detect possible overflow during multiplication.
20484 // RETURNS: the new address of the allocated memory
20485 // <mem>: the memory to reallocate
20486 // <n_blocks>: the number of blocks to allocate
20487 // <n_block_bytes>: the size of each block in bytes
20488 static void* realloc_n()(void* mem, size_t n_blocks, size_t n_block_bytes) {
20489 return g_realloc_n(mem, n_blocks, n_block_bytes);
20493 // VERSION: 2.14
20494 // MOVED TO: Regex.check_replacement
20495 // Checks whether @replacement is a valid replacement string
20496 // (see g_regex_replace()), i.e. that all escape sequences in
20497 // it are valid.
20499 // If @has_references is not %NULL then @replacement is checked
20500 // for pattern references. For instance, replacement text 'foo\n'
20501 // does not contain references and may be evaluated without information
20502 // about actual match, but '\0\1' (whole match followed by first
20503 // subpattern) requires valid #GMatchInfo object.
20504 // RETURNS: whether @replacement is a valid replacement string
20505 // <replacement>: the replacement string
20506 // <has_references>: location to store information about references in @replacement or %NULL
20507 static int regex_check_replacement()(char* replacement, /*out*/ int* has_references, GLib2.Error** error=null) {
20508 return g_regex_check_replacement(replacement, has_references, error);
20511 // MOVED TO: Regex.error_quark
20512 static Quark regex_error_quark()() {
20513 return g_regex_error_quark();
20517 // VERSION: 2.30
20518 // MOVED TO: Regex.escape_nul
20519 // Escapes the nul characters in @string to "\x00". It can be used
20520 // to compile a regex with embedded nul characters.
20522 // For completeness, @length can be -1 for a nul-terminated string.
20523 // In this case the output string will be of course equal to @string.
20524 // RETURNS: a newly-allocated escaped string
20525 // <string>: the string to escape
20526 // <length>: the length of @string
20527 static char* /*new*/ regex_escape_nul()(char* string_, int length) {
20528 return g_regex_escape_nul(string_, length);
20532 // VERSION: 2.14
20533 // MOVED TO: Regex.escape_string
20534 // Escapes the special characters used for regular expressions
20535 // in @string, for instance "a.b*c" becomes "a\.b\*c". This
20536 // function is useful to dynamically generate regular expressions.
20538 // @string can contain nul characters that are replaced with "\0",
20539 // in this case remember to specify the correct length of @string
20540 // in @length.
20541 // RETURNS: a newly-allocated escaped string
20542 // <string>: the string to escape
20543 // <length>: the length of @string, or -1 if @string is nul-terminated
20544 static char* /*new*/ regex_escape_string()(char* string_, int length) {
20545 return g_regex_escape_string(string_, length);
20549 // VERSION: 2.14
20550 // MOVED TO: Regex.match_simple
20551 // Scans for a match in @string for @pattern.
20553 // This function is equivalent to g_regex_match() but it does not
20554 // require to compile the pattern with g_regex_new(), avoiding some
20555 // lines of code when you need just to do a match without extracting
20556 // substrings, capture counts, and so on.
20558 // If this function is to be called on the same @pattern more than
20559 // once, it's more efficient to compile the pattern once with
20560 // g_regex_new() and then use g_regex_match().
20561 // RETURNS: %TRUE if the string matched, %FALSE otherwise
20562 // <pattern>: the regular expression
20563 // <string>: the string to scan for matches
20564 // <compile_options>: compile options for the regular expression, or 0
20565 // <match_options>: match options, or 0
20566 static int regex_match_simple()(char* pattern, char* string_, RegexCompileFlags compile_options, RegexMatchFlags match_options) {
20567 return g_regex_match_simple(pattern, string_, compile_options, match_options);
20571 // VERSION: 2.22
20572 // Resets the cache used for g_get_user_special_dir(), so
20573 // that the latest on-disk version is used. Call this only
20574 // if you just changed the data on disk yourself.
20576 // Due to threadsafety issues this may cause leaking of strings
20577 // that were previously returned from g_get_user_special_dir()
20578 // that can't be freed. We ensure to only leak the data for
20579 // the directories that actually changed value though.
20580 static void reload_user_special_dirs_cache()() {
20581 g_reload_user_special_dirs_cache();
20584 static void return_if_fail_warning()(char* log_domain, char* pretty_function, char* expression) {
20585 g_return_if_fail_warning(log_domain, pretty_function, expression);
20589 // VERSION: 2.6
20590 // A wrapper for the POSIX rmdir() function. The rmdir() function
20591 // deletes a directory from the filesystem.
20593 // See your C library manual for more details about how rmdir() works
20594 // on your system.
20596 // occurred
20597 // RETURNS: 0 if the directory was successfully removed, -1 if an error
20598 // <filename>: a pathname in the GLib file name encoding (UTF-8 on Windows)
20599 static int rmdir()(char* filename) {
20600 return g_rmdir(filename);
20604 // VERSION: 2.14
20605 // MOVED TO: Sequence.move
20606 // Moves the item pointed to by @src to the position indicated by @dest.
20607 // After calling this function @dest will point to the position immediately
20608 // after @src. It is allowed for @src and @dest to point into different
20609 // sequences.
20610 // <src>: a #GSequenceIter pointing to the item to move
20611 // <dest>: a #GSequenceIter pointing to the position to which the item is moved.
20612 static void sequence_move()(SequenceIter* src, SequenceIter* dest) {
20613 g_sequence_move(src, dest);
20617 // VERSION: 2.14
20618 // MOVED TO: Sequence.move_range
20619 // Inserts the (@begin, @end) range at the destination pointed to by ptr.
20620 // The @begin and @end iters must point into the same sequence. It is
20621 // allowed for @dest to point to a different sequence than the one pointed
20622 // into by @begin and @end.
20624 // If @dest is NULL, the range indicated by @begin and @end is
20625 // removed from the sequence. If @dest iter points to a place within
20626 // the (@begin, @end) range, the range does not move.
20627 // <dest>: a #GSequenceIter
20628 // <begin>: a #GSequenceIter
20629 // <end>: a #GSequenceIter
20630 static void sequence_move_range()(SequenceIter* dest, SequenceIter* begin, SequenceIter* end) {
20631 g_sequence_move_range(dest, begin, end);
20635 // VERSION: 2.14
20636 // MOVED TO: Sequence.remove
20637 // Removes the item pointed to by @iter. It is an error to pass the
20638 // end iterator to this function.
20640 // If the sequnce has a data destroy function associated with it, this
20641 // function is called on the data for the removed item.
20642 // <iter>: a #GSequenceIter
20643 static void sequence_remove()(SequenceIter* iter) {
20644 g_sequence_remove(iter);
20648 // VERSION: 2.14
20649 // MOVED TO: Sequence.remove_range
20650 // Removes all items in the (@begin, @end) range.
20652 // If the sequence has a data destroy function associated with it, this
20653 // function is called on the data for the removed items.
20654 // <begin>: a #GSequenceIter
20655 // <end>: a #GSequenceIter
20656 static void sequence_remove_range()(SequenceIter* begin, SequenceIter* end) {
20657 g_sequence_remove_range(begin, end);
20661 // VERSION: 2.14
20662 // MOVED TO: Sequence.set
20663 // Changes the data for the item pointed to by @iter to be @data. If
20664 // the sequence has a data destroy function associated with it, that
20665 // function is called on the existing data that @iter pointed to.
20666 // <iter>: a #GSequenceIter
20667 // <data>: new data for the item
20668 static void sequence_set()(SequenceIter* iter, void* data) {
20669 g_sequence_set(iter, data);
20673 // VERSION: 2.14
20674 // MOVED TO: Sequence.swap
20675 // Swaps the items pointed to by @a and @b. It is allowed for @a and @b
20676 // to point into difference sequences.
20677 // <a>: a #GSequenceIter
20678 // <b>: a #GSequenceIter
20679 static void sequence_swap()(SequenceIter* a, SequenceIter* b) {
20680 g_sequence_swap(a, b);
20684 // VERSION: 2.2
20685 // Sets a human-readable name for the application. This name should be
20686 // localized if possible, and is intended for display to the user.
20687 // Contrast with g_set_prgname(), which sets a non-localized name.
20688 // g_set_prgname() will be called automatically by gtk_init(),
20689 // but g_set_application_name() will not.
20691 // Note that for thread safety reasons, this function can only
20692 // be called once.
20694 // The application name will be used in contexts such as error messages,
20695 // or when displaying an application's name in the task list.
20696 // <application_name>: localized name of the application
20697 static void set_application_name()(char* application_name) {
20698 g_set_application_name(application_name);
20702 // Unintrospectable function: set_error() / g_set_error()
20703 // Does nothing if @err is %NULL; if @err is non-%NULL, then *@err
20704 // must be %NULL. A new #GError is created and assigned to *@err.
20705 // <err>: a return location for a #GError, or %NULL
20706 // <domain>: error domain
20707 // <code>: error code
20708 // <format>: printf()-style format
20709 alias g_set_error set_error; // Variadic
20712 // VERSION: 2.18
20713 // Does nothing if @err is %NULL; if @err is non-%NULL, then *@err
20714 // must be %NULL. A new #GError is created and assigned to *@err.
20715 // Unlike g_set_error(), @message is not a printf()-style format string.
20716 // Use this function if @message contains text you don't have control over,
20717 // that could include printf() escape sequences.
20718 // <err>: a return location for a #GError, or %NULL
20719 // <domain>: error domain
20720 // <code>: error code
20721 // <message>: error message
20722 static void set_error_literal()(Error** err, Quark domain, int code, char* message) {
20723 g_set_error_literal(err, domain, code, message);
20727 // Sets the name of the program. This name should <emphasis>not</emphasis>
20728 // be localized, contrast with g_set_application_name(). Note that for
20729 // thread-safety reasons this function can only be called once.
20730 // <prgname>: the name of the program.
20731 static void set_prgname()(char* prgname) {
20732 g_set_prgname(prgname);
20736 // Unintrospectable function: set_print_handler() / g_set_print_handler()
20737 // Sets the print handler.
20739 // Any messages passed to g_print() will be output via
20740 // the new handler. The default handler simply outputs
20741 // the message to stdout. By providing your own handler
20742 // you can redirect the output, to a GTK+ widget or a
20743 // log file for example.
20744 // RETURNS: the old print handler
20745 // <func>: the new print handler
20746 static PrintFunc set_print_handler()(PrintFunc func) {
20747 return g_set_print_handler(func);
20751 // Unintrospectable function: set_printerr_handler() / g_set_printerr_handler()
20752 // Sets the handler for printing error messages.
20754 // Any messages passed to g_printerr() will be output via
20755 // the new handler. The default handler simply outputs the
20756 // message to stderr. By providing your own handler you can
20757 // redirect the output, to a GTK+ widget or a log file for
20758 // example.
20759 // RETURNS: the old error message handler
20760 // <func>: the new error message handler
20761 static PrintFunc set_printerr_handler()(PrintFunc func) {
20762 return g_set_printerr_handler(func);
20766 // VERSION: 2.4
20767 // Sets an environment variable. Both the variable's name and value
20768 // should be in the GLib file name encoding. On UNIX, this means that
20769 // they can be arbitrary byte strings. On Windows, they should be in
20770 // UTF-8.
20772 // Note that on some systems, when variables are overwritten, the memory
20773 // used for the previous variables and its value isn't reclaimed.
20775 // <warning><para>
20776 // Environment variable handling in UNIX is not thread-safe, and your
20777 // program may crash if one thread calls g_setenv() while another
20778 // thread is calling getenv(). (And note that many functions, such as
20779 // gettext(), call getenv() internally.) This function is only safe to
20780 // use at the very start of your program, before creating any other
20781 // threads (or creating objects that create worker threads of their
20782 // own).
20783 // </para><para>
20784 // If you need to set up the environment for a child process, you can
20785 // use g_get_environ() to get an environment array, modify that with
20786 // g_environ_setenv() and g_environ_unsetenv(), and then pass that
20787 // array directly to execvpe(), g_spawn_async(), or the like.
20788 // </para></warning>
20789 // RETURNS: %FALSE if the environment variable couldn't be set.
20790 // <variable>: the environment variable to set, must not contain '='.
20791 // <value>: the value for to set the variable to.
20792 // <overwrite>: whether to change the variable if it already exists.
20793 static int setenv()(char* variable, char* value, int overwrite) {
20794 return g_setenv(variable, value, overwrite);
20797 static Quark shell_error_quark()() {
20798 return g_shell_error_quark();
20802 // Parses a command line into an argument vector, in much the same way
20803 // the shell would, but without many of the expansions the shell would
20804 // perform (variable expansion, globs, operators, filename expansion,
20805 // etc. are not supported). The results are defined to be the same as
20806 // those you would get from a UNIX98 /bin/sh, as long as the input
20807 // contains none of the unsupported shell expansions. If the input
20808 // does contain such expansions, they are passed through
20809 // literally. Possible errors are those from the #G_SHELL_ERROR
20810 // domain. Free the returned vector with g_strfreev().
20811 // RETURNS: %TRUE on success, %FALSE if error set
20812 // <command_line>: command line to parse
20813 // <argcp>: return location for number of args
20814 // <argvp>: return location for array of args
20815 static int shell_parse_argv()(char* command_line, /*out*/ int* argcp, /*out*/ char*** argvp, GLib2.Error** error=null) {
20816 return g_shell_parse_argv(command_line, argcp, argvp, error);
20820 // Quotes a string so that the shell (/bin/sh) will interpret the
20821 // quoted string to mean @unquoted_string. If you pass a filename to
20822 // the shell, for example, you should first quote it with this
20823 // function. The return value must be freed with g_free(). The
20824 // quoting style used is undefined (single or double quotes may be
20825 // used).
20826 // RETURNS: quoted string
20827 // <unquoted_string>: a literal string
20828 static char* /*new*/ shell_quote()(char* unquoted_string) {
20829 return g_shell_quote(unquoted_string);
20833 // Unquotes a string as the shell (/bin/sh) would. Only handles
20834 // quotes; if a string contains file globs, arithmetic operators,
20835 // variables, backticks, redirections, or other special-to-the-shell
20836 // features, the result will be different from the result a real shell
20837 // would produce (the variables, backticks, etc. will be passed
20838 // through literally instead of being expanded). This function is
20839 // guaranteed to succeed if applied to the result of
20840 // g_shell_quote(). If it fails, it returns %NULL and sets the
20841 // error. The @quoted_string need not actually contain quoted or
20842 // escaped text; g_shell_unquote() simply goes through the string and
20843 // unquotes/unescapes anything that the shell would. Both single and
20844 // double quotes are handled, as are escapes including escaped
20845 // newlines. The return value must be freed with g_free(). Possible
20846 // errors are in the #G_SHELL_ERROR domain.
20848 // Shell quoting rules are a bit strange. Single quotes preserve the
20849 // literal string exactly. escape sequences are not allowed; not even
20850 // \' - if you want a ' in the quoted text, you have to do something
20851 // like 'foo'\''bar'. Double quotes allow $, `, ", \, and newline to
20852 // be escaped with backslash. Otherwise double quotes preserve things
20853 // literally.
20854 // RETURNS: an unquoted string
20855 // <quoted_string>: shell-quoted string
20856 static char* /*new*/ shell_unquote()(char* quoted_string, GLib2.Error** error=null) {
20857 return g_shell_unquote(quoted_string, error);
20861 // Unintrospectable function: slice_alloc() / g_slice_alloc()
20862 // VERSION: 2.10
20863 // Allocates a block of memory from the slice allocator.
20864 // The block adress handed out can be expected to be aligned
20865 // to at least <literal>1 * sizeof (void*)</literal>,
20866 // though in general slices are 2 * sizeof (void*) bytes aligned,
20867 // if a malloc() fallback implementation is used instead,
20868 // the alignment may be reduced in a libc dependent fashion.
20869 // Note that the underlying slice allocation mechanism can
20870 // be changed with the <link linkend="G_SLICE">G_SLICE=always-malloc</link>
20871 // environment variable.
20872 // RETURNS: a pointer to the allocated memory block
20873 // <block_size>: the number of bytes to allocate
20874 static void* slice_alloc()(size_t block_size) {
20875 return g_slice_alloc(block_size);
20879 // Unintrospectable function: slice_alloc0() / g_slice_alloc0()
20880 // VERSION: 2.10
20881 // Allocates a block of memory via g_slice_alloc() and initializes
20882 // the returned memory to 0. Note that the underlying slice allocation
20883 // mechanism can be changed with the
20884 // <link linkend="G_SLICE">G_SLICE=always-malloc</link>
20885 // environment variable.
20886 // RETURNS: a pointer to the allocated block
20887 // <block_size>: the number of bytes to allocate
20888 static void* slice_alloc0()(size_t block_size) {
20889 return g_slice_alloc0(block_size);
20893 // Unintrospectable function: slice_copy() / g_slice_copy()
20894 // VERSION: 2.14
20895 // Allocates a block of memory from the slice allocator
20896 // and copies @block_size bytes into it from @mem_block.
20897 // RETURNS: a pointer to the allocated memory block
20898 // <block_size>: the number of bytes to allocate
20899 // <mem_block>: the memory to copy
20900 static void* slice_copy()(size_t block_size, const(void)* mem_block) {
20901 return g_slice_copy(block_size, mem_block);
20905 // VERSION: 2.10
20906 // Frees a block of memory.
20908 // The memory must have been allocated via g_slice_alloc() or
20909 // g_slice_alloc0() and the @block_size has to match the size
20910 // specified upon allocation. Note that the exact release behaviour
20911 // can be changed with the
20912 // <link linkend="G_DEBUG">G_DEBUG=gc-friendly</link> environment
20913 // variable, also see <link linkend="G_SLICE">G_SLICE</link> for
20914 // related debugging options.
20915 // <block_size>: the size of the block
20916 // <mem_block>: a pointer to the block to free
20917 static void slice_free1()(size_t block_size, void* mem_block) {
20918 g_slice_free1(block_size, mem_block);
20922 // VERSION: 2.10
20923 // Frees a linked list of memory blocks of structure type @type.
20925 // The memory blocks must be equal-sized, allocated via
20926 // g_slice_alloc() or g_slice_alloc0() and linked together by a
20927 // @next pointer (similar to #GSList). The offset of the @next
20928 // field in each block is passed as third argument.
20929 // Note that the exact release behaviour can be changed with the
20930 // <link linkend="G_DEBUG">G_DEBUG=gc-friendly</link> environment
20931 // variable, also see <link linkend="G_SLICE">G_SLICE</link> for
20932 // related debugging options.
20933 // <block_size>: the size of the blocks
20934 // <mem_chain>: a pointer to the first block of the chain
20935 // <next_offset>: the offset of the @next field in the blocks
20936 static void slice_free_chain_with_offset()(size_t block_size, void* mem_chain, size_t next_offset) {
20937 g_slice_free_chain_with_offset(block_size, mem_chain, next_offset);
20940 static long slice_get_config()(SliceConfig ckey) {
20941 return g_slice_get_config(ckey);
20944 static long* slice_get_config_state()(SliceConfig ckey, long address, uint* n_values) {
20945 return g_slice_get_config_state(ckey, address, n_values);
20948 static void slice_set_config()(SliceConfig ckey, long value) {
20949 g_slice_set_config(ckey, value);
20953 // Unintrospectable function: snprintf() / g_snprintf()
20954 // A safer form of the standard sprintf() function. The output is guaranteed
20955 // to not exceed @n characters (including the terminating nul character), so
20956 // it is easy to ensure that a buffer overflow cannot occur.
20958 // See also g_strdup_printf().
20960 // In versions of GLib prior to 1.2.3, this function may return -1 if the
20961 // output was truncated, and the truncated string may not be nul-terminated.
20962 // In versions prior to 1.3.12, this function returns the length of the output
20963 // string.
20965 // The return value of g_snprintf() conforms to the snprintf()
20966 // function as standardized in ISO C99. Note that this is different from
20967 // traditional snprintf(), which returns the length of the output string.
20969 // The format string may contain positional parameters, as specified in
20970 // the Single Unix Specification.
20972 // was large enough.
20973 // RETURNS: the number of bytes which would be produced if the buffer
20974 // <string>: the buffer to hold the output.
20975 // <n>: the maximum number of bytes to produce (including the terminating nul character).
20976 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
20977 alias g_snprintf snprintf; // Variadic
20980 // MOVED TO: Source.remove
20981 // Removes the source with the given id from the default main context.
20982 // The id of
20983 // a #GSource is given by g_source_get_id(), or will be returned by the
20984 // functions g_source_attach(), g_idle_add(), g_idle_add_full(),
20985 // g_timeout_add(), g_timeout_add_full(), g_child_watch_add(),
20986 // g_child_watch_add_full(), g_io_add_watch(), and g_io_add_watch_full().
20988 // See also g_source_destroy(). You must use g_source_destroy() for sources
20989 // added to a non-default main context.
20990 // RETURNS: %TRUE if the source was found and removed.
20991 // <tag>: the ID of the source to remove.
20992 static int source_remove()(uint tag) {
20993 return g_source_remove(tag);
20997 // MOVED TO: Source.remove_by_funcs_user_data
20998 // Removes a source from the default main loop context given the
20999 // source functions and user data. If multiple sources exist with the
21000 // same source functions and user data, only one will be destroyed.
21001 // RETURNS: %TRUE if a source was found and removed.
21002 // <funcs>: The @source_funcs passed to g_source_new()
21003 // <user_data>: the user data for the callback
21004 static int source_remove_by_funcs_user_data()(SourceFuncs* funcs, void* user_data) {
21005 return g_source_remove_by_funcs_user_data(funcs, user_data);
21009 // MOVED TO: Source.remove_by_user_data
21010 // Removes a source from the default main loop context given the user
21011 // data for the callback. If multiple sources exist with the same user
21012 // data, only one will be destroyed.
21013 // RETURNS: %TRUE if a source was found and removed.
21014 // <user_data>: the user_data for the callback.
21015 static int source_remove_by_user_data()(void* user_data) {
21016 return g_source_remove_by_user_data(user_data);
21020 // VERSION: 2.26
21021 // MOVED TO: Source.set_name_by_id
21022 // Sets the name of a source using its ID.
21024 // This is a convenience utility to set source names from the return
21025 // value of g_idle_add(), g_timeout_add(), etc.
21026 // <tag>: a #GSource ID
21027 // <name>: debug name for the source
21028 static void source_set_name_by_id()(uint tag, char* name) {
21029 g_source_set_name_by_id(tag, name);
21033 // Gets the smallest prime number from a built-in array of primes which
21034 // is larger than @num. This is used within GLib to calculate the optimum
21035 // size of a #GHashTable.
21037 // The built-in array of primes ranges from 11 to 13845163 such that
21038 // each prime is approximately 1.5-2 times the previous prime.
21040 // which is larger than @num
21041 // RETURNS: the smallest prime number from a built-in array of primes
21042 // <num>: a #guint
21043 static uint spaced_primes_closest()(uint num) {
21044 return g_spaced_primes_closest(num);
21048 // See g_spawn_async_with_pipes() for a full description; this function
21049 // simply calls the g_spawn_async_with_pipes() without any pipes.
21051 // You should call g_spawn_close_pid() on the returned child process
21052 // reference when you don't need it any more.
21054 // <note><para>
21055 // If you are writing a GTK+ application, and the program you
21056 // are spawning is a graphical application, too, then you may
21057 // want to use gdk_spawn_on_screen() instead to ensure that
21058 // the spawned program opens its windows on the right screen.
21059 // </para></note>
21061 // <note><para> Note that the returned @child_pid on Windows is a
21062 // handle to the child process and not its identifier. Process handles
21063 // and process identifiers are different concepts on Windows.
21064 // </para></note>
21065 // RETURNS: %TRUE on success, %FALSE if error is set
21066 // <working_directory>: child's current working directory, or %NULL to inherit parent's
21067 // <argv>: child's argument vector
21068 // <envp>: child's environment, or %NULL to inherit parent's
21069 // <flags>: flags from #GSpawnFlags
21070 // <child_setup>: function to run in the child just before exec()
21071 // <user_data>: user data for @child_setup
21072 // <child_pid>: return location for child process reference, or %NULL
21073 static int spawn_async()(char* working_directory, char** argv, char** envp, SpawnFlags flags, SpawnChildSetupFunc child_setup, void* user_data, /*out*/ Pid* child_pid, GLib2.Error** error=null) {
21074 return g_spawn_async(working_directory, argv, envp, flags, child_setup, user_data, child_pid, error);
21078 // Executes a child program asynchronously (your program will not
21079 // block waiting for the child to exit). The child program is
21080 // specified by the only argument that must be provided, @argv. @argv
21081 // should be a %NULL-terminated array of strings, to be passed as the
21082 // argument vector for the child. The first string in @argv is of
21083 // course the name of the program to execute. By default, the name of
21084 // the program must be a full path; the <envar>PATH</envar> shell variable
21085 // will only be searched if you pass the %G_SPAWN_SEARCH_PATH flag.
21086 // If the program name is not a full path and %G_SPAWN_SEARCH_PATH flag is not
21087 // used, then the program will be run from the current directory (or
21088 // @working_directory, if specified); this might be unexpected or even
21089 // dangerous in some cases when the current directory is world-writable.
21091 // On Windows, note that all the string or string vector arguments to
21092 // this function and the other g_spawn*() functions are in UTF-8, the
21093 // GLib file name encoding. Unicode characters that are not part of
21094 // the system codepage passed in these arguments will be correctly
21095 // available in the spawned program only if it uses wide character API
21096 // to retrieve its command line. For C programs built with Microsoft's
21097 // tools it is enough to make the program have a wmain() instead of
21098 // main(). wmain() has a wide character argument vector as parameter.
21100 // At least currently, mingw doesn't support wmain(), so if you use
21101 // mingw to develop the spawned program, it will have to call the
21102 // undocumented function __wgetmainargs() to get the wide character
21103 // argument vector and environment. See gspawn-win32-helper.c in the
21104 // GLib sources or init.c in the mingw runtime sources for a prototype
21105 // for that function. Alternatively, you can retrieve the Win32 system
21106 // level wide character command line passed to the spawned program
21107 // using the GetCommandLineW() function.
21109 // On Windows the low-level child process creation API
21110 // <function>CreateProcess()</function> doesn't use argument vectors,
21111 // but a command line. The C runtime library's
21112 // <function>spawn*()</function> family of functions (which
21113 // g_spawn_async_with_pipes() eventually calls) paste the argument
21114 // vector elements together into a command line, and the C runtime startup code
21115 // does a corresponding reconstruction of an argument vector from the
21116 // command line, to be passed to main(). Complications arise when you have
21117 // argument vector elements that contain spaces of double quotes. The
21118 // <function>spawn*()</function> functions don't do any quoting or
21119 // escaping, but on the other hand the startup code does do unquoting
21120 // and unescaping in order to enable receiving arguments with embedded
21121 // spaces or double quotes. To work around this asymmetry,
21122 // g_spawn_async_with_pipes() will do quoting and escaping on argument
21123 // vector elements that need it before calling the C runtime
21124 // spawn() function.
21126 // The returned @child_pid on Windows is a handle to the child
21127 // process, not its identifier. Process handles and process
21128 // identifiers are different concepts on Windows.
21130 // @envp is a %NULL-terminated array of strings, where each string
21131 // has the form <literal>KEY=VALUE</literal>. This will become
21132 // the child's environment. If @envp is %NULL, the child inherits its
21133 // parent's environment.
21135 // @flags should be the bitwise OR of any flags you want to affect the
21136 // function's behaviour. The %G_SPAWN_DO_NOT_REAP_CHILD means that the
21137 // child will not automatically be reaped; you must use a child watch to
21138 // be notified about the death of the child process. Eventually you must
21139 // call g_spawn_close_pid() on the @child_pid, in order to free
21140 // resources which may be associated with the child process. (On Unix,
21141 // using a child watch is equivalent to calling waitpid() or handling
21142 // the <literal>SIGCHLD</literal> signal manually. On Windows, calling g_spawn_close_pid()
21143 // is equivalent to calling CloseHandle() on the process handle returned
21144 // in @child_pid). See g_child_watch_add().
21146 // %G_SPAWN_LEAVE_DESCRIPTORS_OPEN means that the parent's open file
21147 // descriptors will be inherited by the child; otherwise all
21148 // descriptors except stdin/stdout/stderr will be closed before
21149 // calling exec() in the child. %G_SPAWN_SEARCH_PATH
21150 // means that <literal>argv[0]</literal> need not be an absolute path, it
21151 // will be looked for in the user's <envar>PATH</envar>.
21152 // %G_SPAWN_STDOUT_TO_DEV_NULL means that the child's standard output will
21153 // be discarded, instead of going to the same location as the parent's
21154 // standard output. If you use this flag, @standard_output must be %NULL.
21155 // %G_SPAWN_STDERR_TO_DEV_NULL means that the child's standard error
21156 // will be discarded, instead of going to the same location as the parent's
21157 // standard error. If you use this flag, @standard_error must be %NULL.
21158 // %G_SPAWN_CHILD_INHERITS_STDIN means that the child will inherit the parent's
21159 // standard input (by default, the child's standard input is attached to
21160 // /dev/null). If you use this flag, @standard_input must be %NULL.
21161 // %G_SPAWN_FILE_AND_ARGV_ZERO means that the first element of @argv is
21162 // the file to execute, while the remaining elements are the
21163 // actual argument vector to pass to the file. Normally
21164 // g_spawn_async_with_pipes() uses @argv[0] as the file to execute, and
21165 // passes all of @argv to the child.
21167 // @child_setup and @user_data are a function and user data. On POSIX
21168 // platforms, the function is called in the child after GLib has
21169 // performed all the setup it plans to perform (including creating
21170 // pipes, closing file descriptors, etc.) but before calling
21171 // exec(). That is, @child_setup is called just
21172 // before calling exec() in the child. Obviously
21173 // actions taken in this function will only affect the child, not the
21174 // parent.
21176 // On Windows, there is no separate fork() and exec()
21177 // functionality. Child processes are created and run with a single
21178 // API call, CreateProcess(). There is no sensible thing @child_setup
21179 // could be used for on Windows so it is ignored and not called.
21181 // If non-%NULL, @child_pid will on Unix be filled with the child's
21182 // process ID. You can use the process ID to send signals to the
21183 // child, or to use g_child_watch_add() (or waitpid()) if you specified the
21184 // %G_SPAWN_DO_NOT_REAP_CHILD flag. On Windows, @child_pid will be
21185 // filled with a handle to the child process only if you specified the
21186 // %G_SPAWN_DO_NOT_REAP_CHILD flag. You can then access the child
21187 // process using the Win32 API, for example wait for its termination
21188 // with the <function>WaitFor*()</function> functions, or examine its
21189 // exit code with GetExitCodeProcess(). You should close the handle
21190 // with CloseHandle() or g_spawn_close_pid() when you no longer need it.
21192 // If non-%NULL, the @standard_input, @standard_output, @standard_error
21193 // locations will be filled with file descriptors for writing to the child's
21194 // standard input or reading from its standard output or standard error.
21195 // The caller of g_spawn_async_with_pipes() must close these file descriptors
21196 // when they are no longer in use. If these parameters are %NULL, the corresponding
21197 // pipe won't be created.
21199 // If @standard_input is NULL, the child's standard input is attached to
21200 // /dev/null unless %G_SPAWN_CHILD_INHERITS_STDIN is set.
21202 // If @standard_error is NULL, the child's standard error goes to the same
21203 // location as the parent's standard error unless %G_SPAWN_STDERR_TO_DEV_NULL
21204 // is set.
21206 // If @standard_output is NULL, the child's standard output goes to the same
21207 // location as the parent's standard output unless %G_SPAWN_STDOUT_TO_DEV_NULL
21208 // is set.
21210 // @error can be %NULL to ignore errors, or non-%NULL to report errors.
21211 // If an error is set, the function returns %FALSE. Errors
21212 // are reported even if they occur in the child (for example if the
21213 // executable in <literal>argv[0]</literal> is not found). Typically
21214 // the <literal>message</literal> field of returned errors should be displayed
21215 // to users. Possible errors are those from the #G_SPAWN_ERROR domain.
21217 // If an error occurs, @child_pid, @standard_input, @standard_output,
21218 // and @standard_error will not be filled with valid values.
21220 // If @child_pid is not %NULL and an error does not occur then the returned
21221 // process reference must be closed using g_spawn_close_pid().
21223 // <note><para>
21224 // If you are writing a GTK+ application, and the program you
21225 // are spawning is a graphical application, too, then you may
21226 // want to use gdk_spawn_on_screen_with_pipes() instead to ensure that
21227 // the spawned program opens its windows on the right screen.
21228 // </para></note>
21229 // RETURNS: %TRUE on success, %FALSE if an error was set
21230 // <working_directory>: child's current working directory, or %NULL to inherit parent's, in the GLib file name encoding
21231 // <argv>: child's argument vector, in the GLib file name encoding
21232 // <envp>: child's environment, or %NULL to inherit parent's, in the GLib file name encoding
21233 // <flags>: flags from #GSpawnFlags
21234 // <child_setup>: function to run in the child just before exec()
21235 // <user_data>: user data for @child_setup
21236 // <child_pid>: return location for child process ID, or %NULL
21237 // <standard_input>: return location for file descriptor to write to child's stdin, or %NULL
21238 // <standard_output>: return location for file descriptor to read child's stdout, or %NULL
21239 // <standard_error>: return location for file descriptor to read child's stderr, or %NULL
21240 static int spawn_async_with_pipes()(char* working_directory, char** argv, char** envp, SpawnFlags flags, SpawnChildSetupFunc child_setup, void* user_data, /*out*/ Pid* child_pid, /*out*/ int* standard_input, /*out*/ int* standard_output, /*out*/ int* standard_error, GLib2.Error** error=null) {
21241 return g_spawn_async_with_pipes(working_directory, argv, envp, flags, child_setup, user_data, child_pid, standard_input, standard_output, standard_error, error);
21245 // On some platforms, notably Windows, the #GPid type represents a resource
21246 // which must be closed to prevent resource leaking. g_spawn_close_pid()
21247 // is provided for this purpose. It should be used on all platforms, even
21248 // though it doesn't do anything under UNIX.
21249 // <pid>: The process reference to close
21250 static void spawn_close_pid()(Pid pid) {
21251 g_spawn_close_pid(pid);
21255 // A simple version of g_spawn_async() that parses a command line with
21256 // g_shell_parse_argv() and passes it to g_spawn_async(). Runs a
21257 // command line in the background. Unlike g_spawn_async(), the
21258 // %G_SPAWN_SEARCH_PATH flag is enabled, other flags are not. Note
21259 // that %G_SPAWN_SEARCH_PATH can have security implications, so
21260 // consider using g_spawn_async() directly if appropriate. Possible
21261 // errors are those from g_shell_parse_argv() and g_spawn_async().
21263 // The same concerns on Windows apply as for g_spawn_command_line_sync().
21264 // RETURNS: %TRUE on success, %FALSE if error is set.
21265 // <command_line>: a command line
21266 static int spawn_command_line_async()(char* command_line, GLib2.Error** error=null) {
21267 return g_spawn_command_line_async(command_line, error);
21271 // A simple version of g_spawn_sync() with little-used parameters
21272 // removed, taking a command line instead of an argument vector. See
21273 // g_spawn_sync() for full details. @command_line will be parsed by
21274 // g_shell_parse_argv(). Unlike g_spawn_sync(), the %G_SPAWN_SEARCH_PATH flag
21275 // is enabled. Note that %G_SPAWN_SEARCH_PATH can have security
21276 // implications, so consider using g_spawn_sync() directly if
21277 // appropriate. Possible errors are those from g_spawn_sync() and those
21278 // from g_shell_parse_argv().
21280 // If @exit_status is non-%NULL, the exit status of the child is stored there as
21281 // it would be returned by waitpid(); standard UNIX macros such as WIFEXITED()
21282 // and WEXITSTATUS() must be used to evaluate the exit status.
21284 // On Windows, please note the implications of g_shell_parse_argv()
21285 // parsing @command_line. Parsing is done according to Unix shell rules, not
21286 // Windows command interpreter rules.
21287 // Space is a separator, and backslashes are
21288 // special. Thus you cannot simply pass a @command_line containing
21289 // canonical Windows paths, like "c:\\program files\\app\\app.exe", as
21290 // the backslashes will be eaten, and the space will act as a
21291 // separator. You need to enclose such paths with single quotes, like
21292 // "'c:\\program files\\app\\app.exe' 'e:\\folder\\argument.txt'".
21293 // RETURNS: %TRUE on success, %FALSE if an error was set
21294 // <command_line>: a command line
21295 // <standard_output>: return location for child output
21296 // <standard_error>: return location for child errors
21297 // <exit_status>: return location for child exit status, as returned by waitpid()
21298 static int spawn_command_line_sync()(char* command_line, /*out*/ ubyte** standard_output, /*out*/ ubyte** standard_error, /*out*/ int* exit_status, GLib2.Error** error=null) {
21299 return g_spawn_command_line_sync(command_line, standard_output, standard_error, exit_status, error);
21302 static Quark spawn_error_quark()() {
21303 return g_spawn_error_quark();
21307 // Executes a child synchronously (waits for the child to exit before returning).
21308 // All output from the child is stored in @standard_output and @standard_error,
21309 // if those parameters are non-%NULL. Note that you must set the
21310 // %G_SPAWN_STDOUT_TO_DEV_NULL and %G_SPAWN_STDERR_TO_DEV_NULL flags when
21311 // passing %NULL for @standard_output and @standard_error.
21312 // If @exit_status is non-%NULL, the exit status of the child is stored
21313 // there as it would be returned by waitpid(); standard UNIX macros such
21314 // as WIFEXITED() and WEXITSTATUS() must be used to evaluate the exit status.
21315 // Note that this function call waitpid() even if @exit_status is %NULL, and
21316 // does not accept the %G_SPAWN_DO_NOT_REAP_CHILD flag.
21317 // If an error occurs, no data is returned in @standard_output,
21318 // @standard_error, or @exit_status.
21320 // This function calls g_spawn_async_with_pipes() internally; see that
21321 // function for full details on the other parameters and details on
21322 // how these functions work on Windows.
21323 // RETURNS: %TRUE on success, %FALSE if an error was set.
21324 // <working_directory>: child's current working directory, or %NULL to inherit parent's
21325 // <argv>: child's argument vector
21326 // <envp>: child's environment, or %NULL to inherit parent's
21327 // <flags>: flags from #GSpawnFlags
21328 // <child_setup>: function to run in the child just before exec()
21329 // <user_data>: user data for @child_setup
21330 // <standard_output>: return location for child output, or %NULL
21331 // <standard_error>: return location for child error messages, or %NULL
21332 // <exit_status>: return location for child exit status, as returned by waitpid(), or %NULL
21333 static int spawn_sync()(char* working_directory, char** argv, char** envp, SpawnFlags flags, SpawnChildSetupFunc child_setup, void* user_data, /*out*/ ubyte** standard_output, /*out*/ ubyte** standard_error, /*out*/ int* exit_status, GLib2.Error** error=null) {
21334 return g_spawn_sync(working_directory, argv, envp, flags, child_setup, user_data, standard_output, standard_error, exit_status, error);
21338 // Unintrospectable function: sprintf() / g_sprintf()
21339 // VERSION: 2.2
21340 // An implementation of the standard sprintf() function which supports
21341 // positional parameters, as specified in the Single Unix Specification.
21343 // Note that it is usually better to use g_snprintf(), to avoid the
21344 // risk of buffer overflow.
21346 // See also g_strdup_printf().
21347 // RETURNS: the number of bytes printed.
21348 // <string>: A pointer to a memory buffer to contain the resulting string. It is up to the caller to ensure that the allocated buffer is large enough to hold the formatted result
21349 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
21350 alias g_sprintf sprintf; // Variadic
21353 // Copies a nul-terminated string into the dest buffer, include the
21354 // trailing nul, and return a pointer to the trailing nul byte.
21355 // This is useful for concatenating multiple strings together
21356 // without having to repeatedly scan for the end.
21357 // RETURNS: a pointer to trailing nul byte.
21358 // <dest>: destination buffer.
21359 // <src>: source string.
21360 static char* /*new*/ stpcpy()(char* dest, char* src) {
21361 return g_stpcpy(dest, src);
21365 // Compares two strings for byte-by-byte equality and returns %TRUE
21366 // if they are equal. It can be passed to g_hash_table_new() as the
21367 // @key_equal_func parameter, when using non-%NULL strings as keys in a
21368 // #GHashTable.
21370 // Note that this function is primarily meant as a hash table comparison
21371 // function. For a general-purpose, %NULL-safe string comparison function,
21372 // see g_strcmp0().
21373 // RETURNS: %TRUE if the two keys match
21374 // <v1>: a key
21375 // <v2>: a key to compare with @v1
21376 static int str_equal()(const(void)* v1, const(void)* v2) {
21377 return g_str_equal(v1, v2);
21381 // VERSION: 2.2
21382 // Looks whether the string @str begins with @prefix.
21383 // RETURNS: %TRUE if @str begins with @prefix, %FALSE otherwise.
21384 // <str>: a nul-terminated string
21385 // <prefix>: the nul-terminated prefix to look for
21386 static int str_has_prefix()(char* str, char* prefix) {
21387 return g_str_has_prefix(str, prefix);
21391 // VERSION: 2.2
21392 // Looks whether the string @str ends with @suffix.
21393 // RETURNS: %TRUE if @str end with @suffix, %FALSE otherwise.
21394 // <str>: a nul-terminated string
21395 // <suffix>: the nul-terminated suffix to look for
21396 static int str_has_suffix()(char* str, char* suffix) {
21397 return g_str_has_suffix(str, suffix);
21401 // Converts a string to a hash value.
21403 // This function implements the widely used "djb" hash apparently posted
21404 // by Daniel Bernstein to comp.lang.c some time ago. The 32 bit
21405 // unsigned hash value starts at 5381 and for each byte 'c' in the
21406 // string, is updated: <literal>hash = hash * 33 + c</literal>. This
21407 // function uses the signed value of each byte.
21409 // It can be passed to g_hash_table_new() as the @hash_func parameter,
21410 // when using non-%NULL strings as keys in a #GHashTable.
21411 // RETURNS: a hash value corresponding to the key
21412 // <v>: a string key
21413 static uint str_hash()(const(void)* v) {
21414 return g_str_hash(v);
21418 // For each character in @string, if the character is not in
21419 // @valid_chars, replaces the character with @substitutor.
21420 // Modifies @string in place, and return @string itself, not
21421 // a copy. The return value is to allow nesting such as
21422 // |[
21423 // g_ascii_strup (g_strcanon (str, "abc", '?'))
21424 // ]|
21425 // RETURNS: @string
21426 // <string>: a nul-terminated array of bytes
21427 // <valid_chars>: bytes permitted in @string
21428 // <substitutor>: replacement character for disallowed bytes
21429 static char* /*new*/ strcanon()(char* string_, char* valid_chars, char substitutor) {
21430 return g_strcanon(string_, valid_chars, substitutor);
21434 // A case-insensitive string comparison, corresponding to the standard
21435 // strcasecmp() function on platforms which support it.
21437 // or a positive value if @s1 &gt; @s2.
21439 // Deprecated:2.2: See g_strncasecmp() for a discussion of why this function
21440 // is deprecated and how to replace it.
21441 // RETURNS: 0 if the strings match, a negative value if @s1 &lt; @s2,
21442 // <s1>: a string.
21443 // <s2>: a string to compare with @s1.
21444 static int strcasecmp()(char* s1, char* s2) {
21445 return g_strcasecmp(s1, s2);
21449 // Removes trailing whitespace from a string.
21451 // This function doesn't allocate or reallocate any memory;
21452 // it modifies @string in place. The pointer to @string is
21453 // returned to allow the nesting of functions.
21455 // Also see g_strchug() and g_strstrip().
21456 // RETURNS: @string.
21457 // <string>: a string to remove the trailing whitespace from
21458 static char* /*new*/ strchomp()(char* string_) {
21459 return g_strchomp(string_);
21463 // Removes leading whitespace from a string, by moving the rest
21464 // of the characters forward.
21466 // This function doesn't allocate or reallocate any memory;
21467 // it modifies @string in place. The pointer to @string is
21468 // returned to allow the nesting of functions.
21470 // Also see g_strchomp() and g_strstrip().
21471 // RETURNS: @string
21472 // <string>: a string to remove the leading whitespace from
21473 static char* /*new*/ strchug()(char* string_) {
21474 return g_strchug(string_);
21478 // VERSION: 2.16
21479 // Compares @str1 and @str2 like strcmp(). Handles %NULL
21480 // gracefully by sorting it before non-%NULL strings.
21481 // Comparing two %NULL pointers returns 0.
21482 // RETURNS: -1, 0 or 1, if @str1 is <, == or > than @str2.
21483 // <str1>: a C string or %NULL
21484 // <str2>: another C string or %NULL
21485 static int strcmp0()(char* str1, char* str2) {
21486 return g_strcmp0(str1, str2);
21490 // Replaces all escaped characters with their one byte equivalent.
21492 // This function does the reverse conversion of g_strescape().
21494 // character compressed
21495 // RETURNS: a newly-allocated copy of @source with all escaped
21496 // <source>: a string to compress
21497 static char* /*new*/ strcompress()(char* source) {
21498 return g_strcompress(source);
21502 // Unintrospectable function: strconcat() / g_strconcat()
21503 // Concatenates all of the given strings into one long string.
21504 // The returned string should be freed with g_free() when no longer needed.
21506 // Note that this function is usually not the right function to use to
21507 // assemble a translated message from pieces, since proper translation
21508 // often requires the pieces to be reordered.
21510 // <warning><para>The variable argument list <emphasis>must</emphasis> end
21511 // with %NULL. If you forget the %NULL, g_strconcat() will start appending
21512 // random memory junk to your string.</para></warning>
21513 // RETURNS: a newly-allocated string containing all the string arguments
21514 // <string1>: the first string to add, which must not be %NULL
21515 alias g_strconcat strconcat; // Variadic
21518 // Converts any delimiter characters in @string to @new_delimiter.
21519 // Any characters in @string which are found in @delimiters are
21520 // changed to the @new_delimiter character. Modifies @string in place,
21521 // and returns @string itself, not a copy. The return value is to
21522 // allow nesting such as
21523 // |[
21524 // g_ascii_strup (g_strdelimit (str, "abc", '?'))
21525 // ]|
21526 // RETURNS: @string
21527 // <string>: the string to convert
21528 // <delimiters>: a string containing the current delimiters, or %NULL to use the standard delimiters defined in #G_STR_DELIMITERS
21529 // <new_delimiter>: the new delimiter character
21530 static char* /*new*/ strdelimit()(char* string_, char* delimiters, char new_delimiter) {
21531 return g_strdelimit(string_, delimiters, new_delimiter);
21535 // Converts a string to lower case.
21538 // Deprecated:2.2: This function is totally broken for the reasons discussed
21539 // in the g_strncasecmp() docs - use g_ascii_strdown() or g_utf8_strdown()
21540 // instead.
21541 // RETURNS: the string
21542 // <string>: the string to convert.
21543 static char* /*new*/ strdown()(char* string_) {
21544 return g_strdown(string_);
21548 // Duplicates a string. If @str is %NULL it returns %NULL.
21549 // The returned string should be freed with g_free()
21550 // when no longer needed.
21551 // RETURNS: a newly-allocated copy of @str
21552 // <str>: the string to duplicate
21553 static char* /*new*/ strdup()(char* str) {
21554 return g_strdup(str);
21558 // Unintrospectable function: strdup_printf() / g_strdup_printf()
21559 // Similar to the standard C sprintf() function but safer, since it
21560 // calculates the maximum space required and allocates memory to hold
21561 // the result. The returned string should be freed with g_free() when no
21562 // longer needed.
21563 // RETURNS: a newly-allocated string holding the result
21564 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>
21565 alias g_strdup_printf strdup_printf; // Variadic
21568 // Unintrospectable function: strdup_vprintf() / g_strdup_vprintf()
21569 // Similar to the standard C vsprintf() function but safer, since it
21570 // calculates the maximum space required and allocates memory to hold
21571 // the result. The returned string should be freed with g_free() when
21572 // no longer needed.
21574 // See also g_vasprintf(), which offers the same functionality, but
21575 // additionally returns the length of the allocated string.
21576 // RETURNS: a newly-allocated string holding the result
21577 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>
21578 // <args>: the list of parameters to insert into the format string
21579 static char* /*new*/ strdup_vprintf()(char* format, va_list args) {
21580 return g_strdup_vprintf(format, args);
21584 // Unintrospectable function: strdupv() / g_strdupv()
21585 // Copies %NULL-terminated array of strings. The copy is a deep copy;
21586 // the new array should be freed by first freeing each string, then
21587 // the array itself. g_strfreev() does this for you. If called
21588 // on a %NULL value, g_strdupv() simply returns %NULL.
21589 // RETURNS: a new %NULL-terminated array of strings.
21590 // <str_array>: a %NULL-terminated array of strings
21591 static char** strdupv()(char** str_array) {
21592 return g_strdupv(str_array);
21596 // Returns a string corresponding to the given error code, e.g.
21597 // "no such process". You should use this function in preference to
21598 // strerror(), because it returns a string in UTF-8 encoding, and since
21599 // not all platforms support the strerror() function.
21601 // is unknown, it returns "unknown error (&lt;code&gt;)".
21602 // RETURNS: a UTF-8 string describing the error code. If the error code
21603 // <errnum>: the system error number. See the standard C %errno documentation
21604 static char* strerror()(int errnum) {
21605 return g_strerror(errnum);
21609 // Escapes the special characters '\b', '\f', '\n', '\r', '\t', '\v', '\'
21610 // and '&quot;' in the string @source by inserting a '\' before
21611 // them. Additionally all characters in the range 0x01-0x1F (everything
21612 // below SPACE) and in the range 0x7F-0xFF (all non-ASCII chars) are
21613 // replaced with a '\' followed by their octal representation.
21614 // Characters supplied in @exceptions are not escaped.
21616 // g_strcompress() does the reverse conversion.
21618 // characters escaped. See above.
21619 // RETURNS: a newly-allocated copy of @source with certain
21620 // <source>: a string to escape
21621 // <exceptions>: a string of characters not to escape in @source
21622 static char* /*new*/ strescape()(char* source, char* exceptions) {
21623 return g_strescape(source, exceptions);
21626 // <str_array>: a %NULL-terminated array of strings to free Frees a %NULL-terminated array of strings, and the array itself. If called on a %NULL value, g_strfreev() simply returns.
21627 static void strfreev()(char** str_array) {
21628 g_strfreev(str_array);
21632 // Creates a new #GString, initialized with the given string.
21633 // RETURNS: the new #GString
21634 // <init>: the initial text to copy into the string
21635 static String* /*new*/ string_new()(char* init) {
21636 return g_string_new(init);
21640 // Creates a new #GString with @len bytes of the @init buffer.
21641 // Because a length is provided, @init need not be nul-terminated,
21642 // and can contain embedded nul bytes.
21644 // Since this function does not stop at nul bytes, it is the caller's
21645 // responsibility to ensure that @init has at least @len addressable
21646 // bytes.
21647 // RETURNS: a new #GString
21648 // <init>: initial contents of the string
21649 // <len>: length of @init to use
21650 static String* /*new*/ string_new_len()(char* init, ssize_t len) {
21651 return g_string_new_len(init, len);
21655 // Creates a new #GString, with enough space for @dfl_size
21656 // bytes. This is useful if you are going to add a lot of
21657 // text to the string and don't want it to be reallocated
21658 // too often.
21659 // RETURNS: the new #GString
21660 // <dfl_size>: the default size of the space allocated to hold the string
21661 static String* /*new*/ string_sized_new()(size_t dfl_size) {
21662 return g_string_sized_new(dfl_size);
21666 // VERSION: 2.4
21667 // An auxiliary function for gettext() support (see Q_()).
21669 // and contains a '|' character, in which case a pointer to
21670 // the substring of msgid after the first '|' character is returned.
21671 // RETURNS: @msgval, unless @msgval is identical to @msgid
21672 // <msgid>: a string
21673 // <msgval>: another string
21674 static char* strip_context()(char* msgid, char* msgval) {
21675 return g_strip_context(msgid, msgval);
21679 // Unintrospectable function: strjoin() / g_strjoin()
21680 // Joins a number of strings together to form one long string, with the
21681 // optional @separator inserted between each of them. The returned string
21682 // should be freed with g_free().
21684 // together, with @separator between them
21685 // RETURNS: a newly-allocated string containing all of the strings joined
21686 // <separator>: a string to insert between each of the strings, or %NULL
21687 alias g_strjoin strjoin; // Variadic
21690 // Joins a number of strings together to form one long string, with the
21691 // optional @separator inserted between each of them. The returned string
21692 // should be freed with g_free().
21694 // together, with @separator between them
21695 // RETURNS: a newly-allocated string containing all of the strings joined
21696 // <separator>: a string to insert between each of the strings, or %NULL
21697 // <str_array>: a %NULL-terminated array of strings to join
21698 static char* /*new*/ strjoinv()(char* separator, char** str_array) {
21699 return g_strjoinv(separator, str_array);
21703 // Portability wrapper that calls strlcat() on systems which have it,
21704 // and emulates it otherwise. Appends nul-terminated @src string to @dest,
21705 // guaranteeing nul-termination for @dest. The total size of @dest won't
21706 // exceed @dest_size.
21708 // At most dest_size - 1 characters will be copied.
21709 // Unlike strncat, dest_size is the full size of dest, not the space left over.
21710 // This function does NOT allocate memory.
21711 // This always NUL terminates (unless siz == 0 or there were no NUL characters
21712 // in the dest_size characters of dest to start with).
21714 // <note><para>Caveat: this is supposedly a more secure alternative to
21715 // strcat() or strncat(), but for real security g_strconcat() is harder
21716 // to mess up.</para></note>
21718 // (original dest)) + strlen (src), so if retval >= dest_size,
21719 // truncation occurred.
21720 // RETURNS: size of attempted result, which is MIN (dest_size, strlen
21721 // <dest>: destination buffer, already containing one nul-terminated string
21722 // <src>: source buffer
21723 // <dest_size>: length of @dest buffer in bytes (not length of existing string inside @dest)
21724 static size_t strlcat()(char* dest, char* src, size_t dest_size) {
21725 return g_strlcat(dest, src, dest_size);
21729 // Portability wrapper that calls strlcpy() on systems which have it,
21730 // and emulates strlcpy() otherwise. Copies @src to @dest; @dest is
21731 // guaranteed to be nul-terminated; @src must be nul-terminated;
21732 // @dest_size is the buffer size, not the number of chars to copy.
21734 // At most dest_size - 1 characters will be copied. Always nul-terminates
21735 // (unless dest_size == 0). This function does <emphasis>not</emphasis>
21736 // allocate memory. Unlike strncpy(), this function doesn't pad dest (so
21737 // it's often faster). It returns the size of the attempted result,
21738 // strlen (src), so if @retval >= @dest_size, truncation occurred.
21740 // <note><para>Caveat: strlcpy() is supposedly more secure than
21741 // strcpy() or strncpy(), but if you really want to avoid screwups,
21742 // g_strdup() is an even better idea.</para></note>
21743 // RETURNS: length of @src
21744 // <dest>: destination buffer
21745 // <src>: source buffer
21746 // <dest_size>: length of @dest in bytes
21747 static size_t strlcpy()(char* dest, char* src, size_t dest_size) {
21748 return g_strlcpy(dest, src, dest_size);
21752 // A case-insensitive string comparison, corresponding to the standard
21753 // strncasecmp() function on platforms which support it.
21754 // It is similar to g_strcasecmp() except it only compares the first @n
21755 // characters of the strings.
21757 // or a positive value if @s1 &gt; @s2.
21759 // Deprecated:2.2: The problem with g_strncasecmp() is that it does the
21760 // comparison by calling toupper()/tolower(). These functions are
21761 // locale-specific and operate on single bytes. However, it is impossible
21762 // to handle things correctly from an I18N standpoint by operating on
21763 // bytes, since characters may be multibyte. Thus g_strncasecmp() is
21764 // broken if your string is guaranteed to be ASCII, since it's
21765 // locale-sensitive, and it's broken if your string is localized, since
21766 // it doesn't work on many encodings at all, including UTF-8, EUC-JP,
21767 // etc.
21769 // There are therefore two replacement functions: g_ascii_strncasecmp(),
21770 // which only works on ASCII and is not locale-sensitive, and
21771 // g_utf8_casefold(), which is good for case-insensitive sorting of UTF-8.
21772 // RETURNS: 0 if the strings match, a negative value if @s1 &lt; @s2,
21773 // <s1>: a string.
21774 // <s2>: a string to compare with @s1.
21775 // <n>: the maximum number of characters to compare.
21776 static int strncasecmp()(char* s1, char* s2, uint n) {
21777 return g_strncasecmp(s1, s2, n);
21781 // Duplicates the first @n bytes of a string, returning a newly-allocated
21782 // buffer @n + 1 bytes long which will always be nul-terminated.
21783 // If @str is less than @n bytes long the buffer is padded with nuls.
21784 // If @str is %NULL it returns %NULL.
21785 // The returned value should be freed when no longer needed.
21787 // <note><para>
21788 // To copy a number of characters from a UTF-8 encoded string, use
21789 // g_utf8_strncpy() instead.
21790 // </para></note>
21792 // of @str, nul-terminated
21793 // RETURNS: a newly-allocated buffer containing the first @n bytes
21794 // <str>: the string to duplicate
21795 // <n>: the maximum number of bytes to copy from @str
21796 static char* /*new*/ strndup()(char* str, size_t n) {
21797 return g_strndup(str, n);
21801 // Creates a new string @length bytes long filled with @fill_char.
21802 // The returned string should be freed when no longer needed.
21803 // RETURNS: a newly-allocated string filled the @fill_char
21804 // <length>: the length of the new string
21805 // <fill_char>: the byte to fill the string with
21806 static char* /*new*/ strnfill()(size_t length, char fill_char) {
21807 return g_strnfill(length, fill_char);
21811 // Reverses all of the bytes in a string. For example,
21812 // <literal>g_strreverse ("abcdef")</literal> will result
21813 // in "fedcba".
21815 // Note that g_strreverse() doesn't work on UTF-8 strings
21816 // containing multibyte characters. For that purpose, use
21817 // g_utf8_strreverse().
21818 // RETURNS: the same pointer passed in as @string
21819 // <string>: the string to reverse
21820 static char* /*new*/ strreverse()(char* string_) {
21821 return g_strreverse(string_);
21825 // Searches the string @haystack for the last occurrence
21826 // of the string @needle.
21828 // %NULL if not found.
21829 // RETURNS: a pointer to the found occurrence, or
21830 // <haystack>: a nul-terminated string
21831 // <needle>: the nul-terminated string to search for
21832 static char* /*new*/ strrstr()(char* haystack, char* needle) {
21833 return g_strrstr(haystack, needle);
21837 // Searches the string @haystack for the last occurrence
21838 // of the string @needle, limiting the length of the search
21839 // to @haystack_len.
21841 // %NULL if not found.
21842 // RETURNS: a pointer to the found occurrence, or
21843 // <haystack>: a nul-terminated string
21844 // <haystack_len>: the maximum length of @haystack
21845 // <needle>: the nul-terminated string to search for
21846 static char* /*new*/ strrstr_len()(char* haystack, ssize_t haystack_len, char* needle) {
21847 return g_strrstr_len(haystack, haystack_len, needle);
21851 // Returns a string describing the given signal, e.g. "Segmentation fault".
21852 // You should use this function in preference to strsignal(), because it
21853 // returns a string in UTF-8 encoding, and since not all platforms support
21854 // the strsignal() function.
21856 // it returns "unknown signal (&lt;signum&gt;)".
21857 // RETURNS: a UTF-8 string describing the signal. If the signal is unknown,
21858 // <signum>: the signal number. See the <literal>signal</literal> documentation
21859 static char* strsignal()(int signum) {
21860 return g_strsignal(signum);
21864 // Unintrospectable function: strsplit() / g_strsplit()
21865 // Splits a string into a maximum of @max_tokens pieces, using the given
21866 // @delimiter. If @max_tokens is reached, the remainder of @string is
21867 // appended to the last token.
21869 // As a special case, the result of splitting the empty string "" is an empty
21870 // vector, not a vector containing a single string. The reason for this
21871 // special case is that being able to represent a empty vector is typically
21872 // more useful than consistent handling of empty elements. If you do need
21873 // to represent empty elements, you'll need to check for the empty string
21874 // before calling g_strsplit().
21876 // g_strfreev() to free it.
21877 // RETURNS: a newly-allocated %NULL-terminated array of strings. Use
21878 // <string>: a string to split
21879 // <delimiter>: a string which specifies the places at which to split the string. The delimiter is not included in any of the resulting strings, unless @max_tokens is reached.
21880 // <max_tokens>: the maximum number of pieces to split @string into. If this is less than 1, the string is split completely.
21881 static char** strsplit()(char* string_, char* delimiter, int max_tokens) {
21882 return g_strsplit(string_, delimiter, max_tokens);
21886 // Unintrospectable function: strsplit_set() / g_strsplit_set()
21887 // VERSION: 2.4
21888 // Splits @string into a number of tokens not containing any of the characters
21889 // in @delimiter. A token is the (possibly empty) longest string that does not
21890 // contain any of the characters in @delimiters. If @max_tokens is reached, the
21891 // remainder is appended to the last token.
21893 // For example the result of g_strsplit_set ("abc:def/ghi", ":/", -1) is a
21894 // %NULL-terminated vector containing the three strings "abc", "def",
21895 // and "ghi".
21897 // The result if g_strsplit_set (":def/ghi:", ":/", -1) is a %NULL-terminated
21898 // vector containing the four strings "", "def", "ghi", and "".
21900 // As a special case, the result of splitting the empty string "" is an empty
21901 // vector, not a vector containing a single string. The reason for this
21902 // special case is that being able to represent a empty vector is typically
21903 // more useful than consistent handling of empty elements. If you do need
21904 // to represent empty elements, you'll need to check for the empty string
21905 // before calling g_strsplit_set().
21907 // Note that this function works on bytes not characters, so it can't be used
21908 // to delimit UTF-8 strings for anything but ASCII characters.
21910 // g_strfreev() to free it.
21911 // RETURNS: a newly-allocated %NULL-terminated array of strings. Use
21912 // <string>: The string to be tokenized
21913 // <delimiters>: A nul-terminated string containing bytes that are used to split the string.
21914 // <max_tokens>: The maximum number of tokens to split @string into. If this is less than 1, the string is split completely
21915 static char** strsplit_set()(char* string_, char* delimiters, int max_tokens) {
21916 return g_strsplit_set(string_, delimiters, max_tokens);
21920 // Searches the string @haystack for the first occurrence
21921 // of the string @needle, limiting the length of the search
21922 // to @haystack_len.
21924 // %NULL if not found.
21925 // RETURNS: a pointer to the found occurrence, or
21926 // <haystack>: a string
21927 // <haystack_len>: the maximum length of @haystack. Note that -1 is a valid length, if @haystack is nul-terminated, meaning it will search through the whole string.
21928 // <needle>: the string to search for
21929 static char* /*new*/ strstr_len()(char* haystack, ssize_t haystack_len, char* needle) {
21930 return g_strstr_len(haystack, haystack_len, needle);
21934 // Converts a string to a #gdouble value.
21935 // It calls the standard strtod() function to handle the conversion, but
21936 // if the string is not completely converted it attempts the conversion
21937 // again with g_ascii_strtod(), and returns the best match.
21939 // This function should seldom be used. The normal situation when reading
21940 // numbers not for human consumption is to use g_ascii_strtod(). Only when
21941 // you know that you must expect both locale formatted and C formatted numbers
21942 // should you use this. Make sure that you don't pass strings such as comma
21943 // separated lists of values, since the commas may be interpreted as a decimal
21944 // point in some locales, causing unexpected results.
21945 // RETURNS: the #gdouble value.
21946 // <nptr>: the string to convert to a numeric value.
21947 // <endptr>: if non-%NULL, it returns the character after the last character used in the conversion.
21948 static double strtod()(char* nptr, char** endptr) {
21949 return g_strtod(nptr, endptr);
21953 // Converts a string to upper case.
21956 // Deprecated:2.2: This function is totally broken for the reasons discussed
21957 // in the g_strncasecmp() docs - use g_ascii_strup() or g_utf8_strup() instead.
21958 // RETURNS: the string
21959 // <string>: the string to convert.
21960 static char* /*new*/ strup()(char* string_) {
21961 return g_strup(string_);
21964 static Type strv_get_type()() {
21965 return g_strv_get_type();
21969 // VERSION: 2.6
21970 // Returns the length of the given %NULL-terminated
21971 // string array @str_array.
21972 // RETURNS: length of @str_array.
21973 // <str_array>: a %NULL-terminated array of strings
21974 static uint strv_length()(char** str_array) {
21975 return g_strv_length(str_array);
21979 // Unintrospectable function: test_add_data_func() / g_test_add_data_func()
21980 // VERSION: 2.16
21981 // Create a new test case, similar to g_test_create_case(). However
21982 // the test is assumed to use no fixture, and test suites are automatically
21983 // created on the fly and added to the root fixture, based on the
21984 // slash-separated portions of @testpath. The @test_data argument
21985 // will be passed as first argument to @test_func.
21986 // <testpath>: Slash-separated test case path name for the test.
21987 // <test_data>: Test data argument for the test function.
21988 // <test_func>: The test function to invoke for this test.
21989 static void test_add_data_func()(char* testpath, const(void)* test_data, TestDataFunc test_func) {
21990 g_test_add_data_func(testpath, test_data, test_func);
21994 // Unintrospectable function: test_add_func() / g_test_add_func()
21995 // VERSION: 2.16
21996 // Create a new test case, similar to g_test_create_case(). However
21997 // the test is assumed to use no fixture, and test suites are automatically
21998 // created on the fly and added to the root fixture, based on the
21999 // slash-separated portions of @testpath.
22000 // <testpath>: Slash-separated test case path name for the test.
22001 // <test_func>: The test function to invoke for this test.
22002 static void test_add_func()(char* testpath, TestFunc test_func) {
22003 g_test_add_func(testpath, test_func);
22006 // Unintrospectable function: test_add_vtable() / g_test_add_vtable()
22007 static void test_add_vtable()(char* testpath, size_t data_size, const(void)* test_data, TestFixtureFunc data_setup, TestFixtureFunc data_test, TestFixtureFunc data_teardown) {
22008 g_test_add_vtable(testpath, data_size, test_data, data_setup, data_test, data_teardown);
22012 // VERSION: 2.16
22013 // This function adds a message to test reports that
22014 // associates a bug URI with a test case.
22015 // Bug URIs are constructed from a base URI set with g_test_bug_base()
22016 // and @bug_uri_snippet.
22017 // <bug_uri_snippet>: Bug specific bug tracker URI portion.
22018 static void test_bug()(char* bug_uri_snippet) {
22019 g_test_bug(bug_uri_snippet);
22023 // VERSION: 2.16
22024 // Specify the base URI for bug reports.
22026 // The base URI is used to construct bug report messages for
22027 // g_test_message() when g_test_bug() is called.
22028 // Calling this function outside of a test case sets the
22029 // default base URI for all test cases. Calling it from within
22030 // a test case changes the base URI for the scope of the test
22031 // case only.
22032 // Bug URIs are constructed by appending a bug specific URI
22033 // portion to @uri_pattern, or by replacing the special string
22034 // '\%s' within @uri_pattern if that is present.
22035 // <uri_pattern>: the base pattern for bug URIs
22036 static void test_bug_base()(char* uri_pattern) {
22037 g_test_bug_base(uri_pattern);
22041 // Unintrospectable function: test_create_case() / g_test_create_case()
22042 // VERSION: 2.16
22043 // Create a new #GTestCase, named @test_name, this API is fairly
22044 // low level, calling g_test_add() or g_test_add_func() is preferable.
22045 // When this test is executed, a fixture structure of size @data_size
22046 // will be allocated and filled with 0s. Then @data_setup is called
22047 // to initialize the fixture. After fixture setup, the actual test
22048 // function @data_test is called. Once the test run completed, the
22049 // fixture structure is torn down by calling @data_teardown and
22050 // after that the memory is released.
22052 // Splitting up a test run into fixture setup, test function and
22053 // fixture teardown is most usful if the same fixture is used for
22054 // multiple tests. In this cases, g_test_create_case() will be
22055 // called with the same fixture, but varying @test_name and
22056 // @data_test arguments.
22057 // RETURNS: a newly allocated #GTestCase.
22058 // <test_name>: the name for the test case
22059 // <data_size>: the size of the fixture data structure
22060 // <test_data>: test data argument for the test functions
22061 // <data_setup>: the function to set up the fixture data
22062 // <data_test>: the actual test function
22063 // <data_teardown>: the function to teardown the fixture data
22064 static TestCase* test_create_case()(char* test_name, size_t data_size, const(void)* test_data, TestFixtureFunc data_setup, TestFixtureFunc data_test, TestFixtureFunc data_teardown) {
22065 return g_test_create_case(test_name, data_size, test_data, data_setup, data_test, data_teardown);
22069 // Unintrospectable function: test_create_suite() / g_test_create_suite()
22070 // VERSION: 2.16
22071 // Create a new test suite with the name @suite_name.
22072 // RETURNS: A newly allocated #GTestSuite instance.
22073 // <suite_name>: a name for the suite
22074 static TestSuite* test_create_suite()(char* suite_name) {
22075 return g_test_create_suite(suite_name);
22079 // VERSION: 2.30
22080 // Indicates that a test failed. This function can be called
22081 // multiple times from the same test. You can use this function
22082 // if your test failed in a recoverable way.
22084 // Do not use this function if the failure of a test could cause
22085 // other tests to malfunction.
22087 // Calling this function will not stop the test from running, you
22088 // need to return from the test function yourself. So you can
22089 // produce additional diagnostic messages or even continue running
22090 // the test.
22092 // If not called from inside a test, this function does nothing.
22093 static void test_fail()() {
22094 g_test_fail();
22098 // Unintrospectable function: test_get_root() / g_test_get_root()
22099 // VERSION: 2.16
22100 // Get the toplevel test suite for the test path API.
22101 // RETURNS: the toplevel #GTestSuite
22102 static TestSuite* test_get_root()() {
22103 return g_test_get_root();
22107 // Unintrospectable function: test_init() / g_test_init()
22108 // VERSION: 2.16
22109 // Initialize the GLib testing framework, e.g. by seeding the
22110 // test random number generator, the name for g_get_prgname()
22111 // and parsing test related command line args.
22112 // So far, the following arguments are understood:
22113 // <variablelist>
22114 // <varlistentry>
22115 // <term><option>-l</option></term>
22116 // <listitem><para>
22117 // list test cases available in a test executable.
22118 // </para></listitem>
22119 // </varlistentry>
22120 // <varlistentry>
22121 // <term><option>--seed=<replaceable>RANDOMSEED</replaceable></option></term>
22122 // <listitem><para>
22123 // provide a random seed to reproduce test runs using random numbers.
22124 // </para></listitem>
22125 // </varlistentry>
22126 // <varlistentry>
22127 // <term><option>--verbose</option></term>
22128 // <listitem><para>run tests verbosely.</para></listitem>
22129 // </varlistentry>
22130 // <varlistentry>
22131 // <term><option>-q</option>, <option>--quiet</option></term>
22132 // <listitem><para>run tests quietly.</para></listitem>
22133 // </varlistentry>
22134 // <varlistentry>
22135 // <term><option>-p <replaceable>TESTPATH</replaceable></option></term>
22136 // <listitem><para>
22137 // execute all tests matching <replaceable>TESTPATH</replaceable>.
22138 // </para></listitem>
22139 // </varlistentry>
22140 // <varlistentry>
22141 // <term><option>-m {perf|slow|thorough|quick|undefined|no-undefined}</option></term>
22142 // <listitem><para>
22143 // execute tests according to these test modes:
22144 // <variablelist>
22145 // <varlistentry>
22146 // <term>perf</term>
22147 // <listitem><para>
22148 // performance tests, may take long and report results.
22149 // </para></listitem>
22150 // </varlistentry>
22151 // <varlistentry>
22152 // <term>slow, thorough</term>
22153 // <listitem><para>
22154 // slow and thorough tests, may take quite long and
22155 // maximize coverage.
22156 // </para></listitem>
22157 // </varlistentry>
22158 // <varlistentry>
22159 // <term>quick</term>
22160 // <listitem><para>
22161 // quick tests, should run really quickly and give good coverage.
22162 // </para></listitem>
22163 // </varlistentry>
22164 // <varlistentry>
22165 // <term>undefined</term>
22166 // <listitem><para>
22167 // tests for undefined behaviour, may provoke programming errors
22168 // under g_test_trap_fork() to check that appropriate assertions
22169 // or warnings are given
22170 // </para></listitem>
22171 // </varlistentry>
22172 // <varlistentry>
22173 // <term>no-undefined</term>
22174 // <listitem><para>
22175 // avoid tests for undefined behaviour
22176 // </para></listitem>
22177 // </varlistentry>
22178 // </variablelist>
22179 // </para></listitem>
22180 // </varlistentry>
22181 // <varlistentry>
22182 // <term><option>--debug-log</option></term>
22183 // <listitem><para>debug test logging output.</para></listitem>
22184 // </varlistentry>
22185 // <varlistentry>
22186 // <term><option>-k</option>, <option>--keep-going</option></term>
22187 // <listitem><para>gtester-specific argument.</para></listitem>
22188 // </varlistentry>
22189 // <varlistentry>
22190 // <term><option>--GTestLogFD <replaceable>N</replaceable></option></term>
22191 // <listitem><para>gtester-specific argument.</para></listitem>
22192 // </varlistentry>
22193 // <varlistentry>
22194 // <term><option>--GTestSkipCount <replaceable>N</replaceable></option></term>
22195 // <listitem><para>gtester-specific argument.</para></listitem>
22196 // </varlistentry>
22197 // </variablelist>
22198 // <argc>: Address of the @argc parameter of the main() function. Changed if any arguments were handled.
22199 // <argv>: Address of the @argv parameter of main(). Any parameters understood by g_test_init() stripped before return.
22200 alias g_test_init test_init; // Variadic
22203 // Unintrospectable function: test_log_set_fatal_handler() / g_test_log_set_fatal_handler()
22204 // VERSION: 2.22
22205 // Installs a non-error fatal log handler which can be
22206 // used to decide whether log messages which are counted
22207 // as fatal abort the program.
22209 // The use case here is that you are running a test case
22210 // that depends on particular libraries or circumstances
22211 // and cannot prevent certain known critical or warning
22212 // messages. So you install a handler that compares the
22213 // domain and message to precisely not abort in such a case.
22215 // Note that the handler is reset at the beginning of
22216 // any test case, so you have to set it inside each test
22217 // function which needs the special behavior.
22219 // This handler has no effect on g_error messages.
22220 // <log_func>: the log handler function.
22221 // <user_data>: data passed to the log handler.
22222 static void test_log_set_fatal_handler()(TestLogFatalFunc log_func, void* user_data) {
22223 g_test_log_set_fatal_handler(log_func, user_data);
22226 static char* test_log_type_name()(TestLogType log_type) {
22227 return g_test_log_type_name(log_type);
22231 // Unintrospectable function: test_maximized_result() / g_test_maximized_result()
22232 // VERSION: 2.16
22233 // Report the result of a performance or measurement test.
22234 // The test should generally strive to maximize the reported
22235 // quantities (larger values are better than smaller ones),
22236 // this and @maximized_quantity can determine sorting
22237 // order for test result reports.
22238 // <maximized_quantity>: the reported value
22239 // <format>: the format string of the report message
22240 alias g_test_maximized_result test_maximized_result; // Variadic
22243 // Unintrospectable function: test_message() / g_test_message()
22244 // VERSION: 2.16
22245 // Add a message to the test report.
22246 // <format>: the format string
22247 alias g_test_message test_message; // Variadic
22250 // Unintrospectable function: test_minimized_result() / g_test_minimized_result()
22251 // VERSION: 2.16
22252 // Report the result of a performance or measurement test.
22253 // The test should generally strive to minimize the reported
22254 // quantities (smaller values are better than larger ones),
22255 // this and @minimized_quantity can determine sorting
22256 // order for test result reports.
22257 // <minimized_quantity>: the reported value
22258 // <format>: the format string of the report message
22259 alias g_test_minimized_result test_minimized_result; // Variadic
22262 // VERSION: 2.16
22263 // This function enqueus a callback @destroy_func to be executed
22264 // during the next test case teardown phase. This is most useful
22265 // to auto destruct allocted test resources at the end of a test run.
22266 // Resources are released in reverse queue order, that means enqueueing
22267 // callback A before callback B will cause B() to be called before
22268 // A() during teardown.
22269 // <destroy_func>: Destroy callback for teardown phase.
22270 // <destroy_data>: Destroy callback data.
22271 static void test_queue_destroy()(DestroyNotify destroy_func, void* destroy_data) {
22272 g_test_queue_destroy(destroy_func, destroy_data);
22276 // VERSION: 2.16
22277 // Enqueue a pointer to be released with g_free() during the next
22278 // teardown phase. This is equivalent to calling g_test_queue_destroy()
22279 // with a destroy callback of g_free().
22280 // <gfree_pointer>: the pointer to be stored.
22281 static void test_queue_free()(void* gfree_pointer) {
22282 g_test_queue_free(gfree_pointer);
22286 // VERSION: 2.16
22287 // Get a reproducible random floating point number,
22288 // see g_test_rand_int() for details on test case random numbers.
22289 // RETURNS: a random number from the seeded random number generator.
22290 static double test_rand_double()() {
22291 return g_test_rand_double();
22295 // VERSION: 2.16
22296 // Get a reproducible random floating pointer number out of a specified range,
22297 // see g_test_rand_int() for details on test case random numbers.
22298 // RETURNS: a number with @range_start <= number < @range_end.
22299 // <range_start>: the minimum value returned by this function
22300 // <range_end>: the minimum value not returned by this function
22301 static double test_rand_double_range()(double range_start, double range_end) {
22302 return g_test_rand_double_range(range_start, range_end);
22306 // VERSION: 2.16
22307 // Get a reproducible random integer number.
22309 // The random numbers generated by the g_test_rand_*() family of functions
22310 // change with every new test program start, unless the --seed option is
22311 // given when starting test programs.
22313 // For individual test cases however, the random number generator is
22314 // reseeded, to avoid dependencies between tests and to make --seed
22315 // effective for all test cases.
22316 // RETURNS: a random number from the seeded random number generator.
22317 static int test_rand_int()() {
22318 return g_test_rand_int();
22322 // VERSION: 2.16
22323 // Get a reproducible random integer number out of a specified range,
22324 // see g_test_rand_int() for details on test case random numbers.
22325 // RETURNS: a number with @begin <= number < @end.
22326 // <begin>: the minimum value returned by this function
22327 // <end>: the smallest value not to be returned by this function
22328 static int test_rand_int_range()(int begin, int end) {
22329 return g_test_rand_int_range(begin, end);
22333 // VERSION: 2.16
22334 // Runs all tests under the toplevel suite which can be retrieved
22335 // with g_test_get_root(). Similar to g_test_run_suite(), the test
22336 // cases to be run are filtered according to
22337 // test path arguments (-p <replaceable>testpath</replaceable>) as
22338 // parsed by g_test_init().
22339 // g_test_run_suite() or g_test_run() may only be called once
22340 // in a program.
22341 // RETURNS: 0 on success
22342 static int test_run()() {
22343 return g_test_run();
22347 // VERSION: 2.16
22348 // Execute the tests within @suite and all nested #GTestSuites.
22349 // The test suites to be executed are filtered according to
22350 // test path arguments (-p <replaceable>testpath</replaceable>)
22351 // as parsed by g_test_init().
22352 // g_test_run_suite() or g_test_run() may only be called once
22353 // in a program.
22354 // RETURNS: 0 on success
22355 // <suite>: a #GTestSuite
22356 static int test_run_suite()(TestSuite* suite) {
22357 return g_test_run_suite(suite);
22361 // VERSION: 2.16
22362 // Get the time since the last start of the timer with g_test_timer_start().
22363 // RETURNS: the time since the last start of the timer, as a double
22364 static double test_timer_elapsed()() {
22365 return g_test_timer_elapsed();
22369 // VERSION: 2.16
22370 // Report the last result of g_test_timer_elapsed().
22371 // RETURNS: the last result of g_test_timer_elapsed(), as a double
22372 static double test_timer_last()() {
22373 return g_test_timer_last();
22377 // VERSION: 2.16
22378 // Start a timing test. Call g_test_timer_elapsed() when the task is supposed
22379 // to be done. Call this function again to restart the timer.
22380 static void test_timer_start()() {
22381 g_test_timer_start();
22384 static void test_trap_assertions()(char* domain, char* file, int line, char* func, ulong assertion_flags, char* pattern) {
22385 g_test_trap_assertions(domain, file, line, func, assertion_flags, pattern);
22389 // VERSION: 2.16
22390 // Fork the current test program to execute a test case that might
22391 // not return or that might abort. The forked test case is aborted
22392 // and considered failing if its run time exceeds @usec_timeout.
22394 // The forking behavior can be configured with the #GTestTrapFlags flags.
22396 // In the following example, the test code forks, the forked child
22397 // process produces some sample output and exits successfully.
22398 // The forking parent process then asserts successful child program
22399 // termination and validates child program outputs.
22401 // |[
22402 // static void
22403 // test_fork_patterns (void)
22404 // {
22405 // if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
22406 // {
22407 // g_print ("some stdout text: somagic17\n");
22408 // g_printerr ("some stderr text: semagic43\n");
22409 // exit (0); /&ast; successful test run &ast;/
22410 // }
22411 // g_test_trap_assert_passed();
22412 // g_test_trap_assert_stdout ("*somagic17*");
22413 // g_test_trap_assert_stderr ("*semagic43*");
22414 // }
22415 // ]|
22417 // This function is implemented only on Unix platforms.
22418 // RETURNS: %TRUE for the forked child and %FALSE for the executing parent process.
22419 // <usec_timeout>: Timeout for the forked test in micro seconds.
22420 // <test_trap_flags>: Flags to modify forking behaviour.
22421 static int test_trap_fork()(ulong usec_timeout, TestTrapFlags test_trap_flags) {
22422 return g_test_trap_fork(usec_timeout, test_trap_flags);
22426 // VERSION: 2.16
22427 // Check the result of the last g_test_trap_fork() call.
22428 // RETURNS: %TRUE if the last forked child terminated successfully.
22429 static int test_trap_has_passed()() {
22430 return g_test_trap_has_passed();
22434 // VERSION: 2.16
22435 // Check the result of the last g_test_trap_fork() call.
22436 // RETURNS: %TRUE if the last forked child got killed due to a fork timeout.
22437 static int test_trap_reached_timeout()() {
22438 return g_test_trap_reached_timeout();
22441 // MOVED TO: Thread.error_quark
22442 static Quark thread_error_quark()() {
22443 return g_thread_error_quark();
22447 // MOVED TO: Thread.exit
22448 // Terminates the current thread.
22450 // If another thread is waiting for us using g_thread_join() then the
22451 // waiting thread will be woken up and get @retval as the return value
22452 // of g_thread_join().
22454 // Calling <literal>g_thread_exit (retval)</literal> is equivalent to
22455 // returning @retval from the function @func, as given to g_thread_new().
22457 // <note><para>
22458 // You must only call g_thread_exit() from a thread that you created
22459 // yourself with g_thread_new() or related APIs. You must not call
22460 // this function from a thread created with another threading library
22461 // or or from within a #GThreadPool.
22462 // </para></note>
22463 // <retval>: the return value of this thread
22464 static void thread_exit()(void* retval) {
22465 g_thread_exit(retval);
22469 // VERSION: 2.10
22470 // MOVED TO: ThreadPool.get_max_idle_time
22471 // This function will return the maximum @interval that a
22472 // thread will wait in the thread pool for new tasks before
22473 // being stopped.
22475 // If this function returns 0, threads waiting in the thread
22476 // pool for new work are not stopped.
22478 // for new tasks in the thread pool before stopping the
22479 // thread
22480 // RETURNS: the maximum @interval (milliseconds) to wait
22481 static uint thread_pool_get_max_idle_time()() {
22482 return g_thread_pool_get_max_idle_time();
22486 // MOVED TO: ThreadPool.get_max_unused_threads
22487 // Returns the maximal allowed number of unused threads.
22488 // RETURNS: the maximal number of unused threads
22489 static int thread_pool_get_max_unused_threads()() {
22490 return g_thread_pool_get_max_unused_threads();
22494 // MOVED TO: ThreadPool.get_num_unused_threads
22495 // Returns the number of currently unused threads.
22496 // RETURNS: the number of currently unused threads
22497 static uint thread_pool_get_num_unused_threads()() {
22498 return g_thread_pool_get_num_unused_threads();
22502 // VERSION: 2.10
22503 // MOVED TO: ThreadPool.set_max_idle_time
22504 // This function will set the maximum @interval that a thread
22505 // waiting in the pool for new tasks can be idle for before
22506 // being stopped. This function is similar to calling
22507 // g_thread_pool_stop_unused_threads() on a regular timeout,
22508 // except this is done on a per thread basis.
22510 // By setting @interval to 0, idle threads will not be stopped.
22512 // This function makes use of g_async_queue_timed_pop () using
22513 // @interval.
22514 // <interval>: the maximum @interval (in milliseconds) a thread can be idle
22515 static void thread_pool_set_max_idle_time()(uint interval) {
22516 g_thread_pool_set_max_idle_time(interval);
22520 // MOVED TO: ThreadPool.set_max_unused_threads
22521 // Sets the maximal number of unused threads to @max_threads.
22522 // If @max_threads is -1, no limit is imposed on the number
22523 // of unused threads.
22524 // <max_threads>: maximal number of unused threads
22525 static void thread_pool_set_max_unused_threads()(int max_threads) {
22526 g_thread_pool_set_max_unused_threads(max_threads);
22530 // MOVED TO: ThreadPool.stop_unused_threads
22531 // Stops all currently unused threads. This does not change the
22532 // maximal number of unused threads. This function can be used to
22533 // regularly stop all unused threads e.g. from g_timeout_add().
22534 static void thread_pool_stop_unused_threads()() {
22535 g_thread_pool_stop_unused_threads();
22539 // MOVED TO: Thread.yield
22540 // Causes the calling thread to voluntarily relinquish the CPU, so
22541 // that other threads can run.
22543 // This function is often used as a method to make busy wait less evil.
22544 static void thread_yield()() {
22545 g_thread_yield();
22549 // VERSION: 2.12
22550 // MOVED TO: TimeVal.from_iso8601
22551 // Converts a string containing an ISO 8601 encoded date and time
22552 // to a #GTimeVal and puts it into @time_.
22554 // @iso_date must include year, month, day, hours, minutes, and
22555 // seconds. It can optionally include fractions of a second and a time
22556 // zone indicator. (In the absence of any time zone indication, the
22557 // timestamp is assumed to be in local time.)
22558 // RETURNS: %TRUE if the conversion was successful.
22559 // <iso_date>: an ISO 8601 encoded date string
22560 // <time_>: a #GTimeVal
22561 static int time_val_from_iso8601()(char* iso_date, /*out*/ TimeVal* time_) {
22562 return g_time_val_from_iso8601(iso_date, time_);
22566 // Unintrospectable function: timeout_add() / g_timeout_add()
22567 // Sets a function to be called at regular intervals, with the default
22568 // priority, #G_PRIORITY_DEFAULT. The function is called repeatedly
22569 // until it returns %FALSE, at which point the timeout is automatically
22570 // destroyed and the function will not be called again. The first call
22571 // to the function will be at the end of the first @interval.
22573 // Note that timeout functions may be delayed, due to the processing of other
22574 // event sources. Thus they should not be relied on for precise timing.
22575 // After each call to the timeout function, the time of the next
22576 // timeout is recalculated based on the current time and the given interval
22577 // (it does not try to 'catch up' time lost in delays).
22579 // If you want to have a timer in the "seconds" range and do not care
22580 // about the exact time of the first call of the timer, use the
22581 // g_timeout_add_seconds() function; this function allows for more
22582 // optimizations and more efficient system power usage.
22584 // This internally creates a main loop source using g_timeout_source_new()
22585 // and attaches it to the main loop context using g_source_attach(). You can
22586 // do these steps manually if you need greater control.
22588 // The interval given is in terms of monotonic time, not wall clock
22589 // time. See g_get_monotonic_time().
22590 // RETURNS: the ID (greater than 0) of the event source.
22591 // <interval>: the time between calls to the function, in milliseconds (1/1000ths of a second)
22592 // <function>: function to call
22593 // <data>: data to pass to @function
22594 static uint timeout_add()(uint interval, SourceFunc function_, void* data) {
22595 return g_timeout_add(interval, function_, data);
22599 // Sets a function to be called at regular intervals, with the given
22600 // priority. The function is called repeatedly until it returns
22601 // %FALSE, at which point the timeout is automatically destroyed and
22602 // the function will not be called again. The @notify function is
22603 // called when the timeout is destroyed. The first call to the
22604 // function will be at the end of the first @interval.
22606 // Note that timeout functions may be delayed, due to the processing of other
22607 // event sources. Thus they should not be relied on for precise timing.
22608 // After each call to the timeout function, the time of the next
22609 // timeout is recalculated based on the current time and the given interval
22610 // (it does not try to 'catch up' time lost in delays).
22612 // This internally creates a main loop source using g_timeout_source_new()
22613 // and attaches it to the main loop context using g_source_attach(). You can
22614 // do these steps manually if you need greater control.
22616 // The interval given in terms of monotonic time, not wall clock time.
22617 // See g_get_monotonic_time().
22618 // RETURNS: the ID (greater than 0) of the event source.
22619 // <priority>: the priority of the timeout source. Typically this will be in the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
22620 // <interval>: the time between calls to the function, in milliseconds (1/1000ths of a second)
22621 // <function>: function to call
22622 // <data>: data to pass to @function
22623 // <notify>: function to call when the timeout is removed, or %NULL
22624 static uint timeout_add_full()(int priority, uint interval, SourceFunc function_, void* data, DestroyNotify notify) {
22625 return g_timeout_add_full(priority, interval, function_, data, notify);
22629 // Unintrospectable function: timeout_add_seconds() / g_timeout_add_seconds()
22630 // VERSION: 2.14
22631 // Sets a function to be called at regular intervals with the default
22632 // priority, #G_PRIORITY_DEFAULT. The function is called repeatedly until
22633 // it returns %FALSE, at which point the timeout is automatically destroyed
22634 // and the function will not be called again.
22636 // This internally creates a main loop source using
22637 // g_timeout_source_new_seconds() and attaches it to the main loop context
22638 // using g_source_attach(). You can do these steps manually if you need
22639 // greater control. Also see g_timeout_add_seconds_full().
22641 // Note that the first call of the timer may not be precise for timeouts
22642 // of one second. If you need finer precision and have such a timeout,
22643 // you may want to use g_timeout_add() instead.
22645 // The interval given is in terms of monotonic time, not wall clock
22646 // time. See g_get_monotonic_time().
22647 // RETURNS: the ID (greater than 0) of the event source.
22648 // <interval>: the time between calls to the function, in seconds
22649 // <function>: function to call
22650 // <data>: data to pass to @function
22651 static uint timeout_add_seconds()(uint interval, SourceFunc function_, void* data) {
22652 return g_timeout_add_seconds(interval, function_, data);
22656 // VERSION: 2.14
22657 // Sets a function to be called at regular intervals, with @priority.
22658 // The function is called repeatedly until it returns %FALSE, at which
22659 // point the timeout is automatically destroyed and the function will
22660 // not be called again.
22662 // Unlike g_timeout_add(), this function operates at whole second granularity.
22663 // The initial starting point of the timer is determined by the implementation
22664 // and the implementation is expected to group multiple timers together so that
22665 // they fire all at the same time.
22666 // To allow this grouping, the @interval to the first timer is rounded
22667 // and can deviate up to one second from the specified interval.
22668 // Subsequent timer iterations will generally run at the specified interval.
22670 // Note that timeout functions may be delayed, due to the processing of other
22671 // event sources. Thus they should not be relied on for precise timing.
22672 // After each call to the timeout function, the time of the next
22673 // timeout is recalculated based on the current time and the given @interval
22675 // If you want timing more precise than whole seconds, use g_timeout_add()
22676 // instead.
22678 // The grouping of timers to fire at the same time results in a more power
22679 // and CPU efficient behavior so if your timer is in multiples of seconds
22680 // and you don't require the first timer exactly one second from now, the
22681 // use of g_timeout_add_seconds() is preferred over g_timeout_add().
22683 // This internally creates a main loop source using
22684 // g_timeout_source_new_seconds() and attaches it to the main loop context
22685 // using g_source_attach(). You can do these steps manually if you need
22686 // greater control.
22688 // The interval given is in terms of monotonic time, not wall clock
22689 // time. See g_get_monotonic_time().
22690 // RETURNS: the ID (greater than 0) of the event source.
22691 // <priority>: the priority of the timeout source. Typically this will be in the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
22692 // <interval>: the time between calls to the function, in seconds
22693 // <function>: function to call
22694 // <data>: data to pass to @function
22695 // <notify>: function to call when the timeout is removed, or %NULL
22696 static uint timeout_add_seconds_full()(int priority, uint interval, SourceFunc function_, void* data, DestroyNotify notify) {
22697 return g_timeout_add_seconds_full(priority, interval, function_, data, notify);
22701 // Creates a new timeout source.
22703 // The source will not initially be associated with any #GMainContext
22704 // and must be added to one with g_source_attach() before it will be
22705 // executed.
22707 // The interval given is in terms of monotonic time, not wall clock
22708 // time. See g_get_monotonic_time().
22709 // RETURNS: the newly-created timeout source
22710 // <interval>: the timeout interval in milliseconds.
22711 static Source* /*new*/ timeout_source_new()(uint interval) {
22712 return g_timeout_source_new(interval);
22716 // VERSION: 2.14
22717 // Creates a new timeout source.
22719 // The source will not initially be associated with any #GMainContext
22720 // and must be added to one with g_source_attach() before it will be
22721 // executed.
22723 // The scheduling granularity/accuracy of this timeout source will be
22724 // in seconds.
22726 // The interval given in terms of monotonic time, not wall clock time.
22727 // See g_get_monotonic_time().
22728 // RETURNS: the newly-created timeout source
22729 // <interval>: the timeout interval in seconds
22730 static Source* /*new*/ timeout_source_new_seconds()(uint interval) {
22731 return g_timeout_source_new_seconds(interval);
22735 // MOVED TO: TrashStack.height
22736 // Returns the height of a #GTrashStack.
22738 // Note that execution of this function is of O(N) complexity
22739 // where N denotes the number of items on the stack.
22740 // RETURNS: the height of the stack
22741 // <stack_p>: a #GTrashStack
22742 static uint trash_stack_height()(TrashStack** stack_p) {
22743 return g_trash_stack_height(stack_p);
22747 // MOVED TO: TrashStack.push
22748 // Pushes a piece of memory onto a #GTrashStack.
22749 // <stack_p>: a #GTrashStack
22750 // <data_p>: the piece of memory to push on the stack
22751 static void trash_stack_push()(TrashStack** stack_p, void* data_p) {
22752 g_trash_stack_push(stack_p, data_p);
22756 // Unintrospectable function: try_malloc() / g_try_malloc()
22757 // Attempts to allocate @n_bytes, and returns %NULL on failure.
22758 // Contrast with g_malloc(), which aborts the program on failure.
22759 // RETURNS: the allocated memory, or %NULL.
22760 // <n_bytes>: number of bytes to allocate.
22761 static void* try_malloc()(size_t n_bytes) {
22762 return g_try_malloc(n_bytes);
22766 // Unintrospectable function: try_malloc0() / g_try_malloc0()
22767 // VERSION: 2.8
22768 // Attempts to allocate @n_bytes, initialized to 0's, and returns %NULL on
22769 // failure. Contrast with g_malloc0(), which aborts the program on failure.
22770 // RETURNS: the allocated memory, or %NULL
22771 // <n_bytes>: number of bytes to allocate
22772 static void* try_malloc0()(size_t n_bytes) {
22773 return g_try_malloc0(n_bytes);
22777 // Unintrospectable function: try_malloc0_n() / g_try_malloc0_n()
22778 // VERSION: 2.24
22779 // This function is similar to g_try_malloc0(), allocating (@n_blocks * @n_block_bytes) bytes,
22780 // but care is taken to detect possible overflow during multiplication.
22781 // RETURNS: the allocated memory, or %NULL
22782 // <n_blocks>: the number of blocks to allocate
22783 // <n_block_bytes>: the size of each block in bytes
22784 static void* try_malloc0_n()(size_t n_blocks, size_t n_block_bytes) {
22785 return g_try_malloc0_n(n_blocks, n_block_bytes);
22789 // Unintrospectable function: try_malloc_n() / g_try_malloc_n()
22790 // VERSION: 2.24
22791 // This function is similar to g_try_malloc(), allocating (@n_blocks * @n_block_bytes) bytes,
22792 // but care is taken to detect possible overflow during multiplication.
22793 // RETURNS: the allocated memory, or %NULL.
22794 // <n_blocks>: the number of blocks to allocate
22795 // <n_block_bytes>: the size of each block in bytes
22796 static void* try_malloc_n()(size_t n_blocks, size_t n_block_bytes) {
22797 return g_try_malloc_n(n_blocks, n_block_bytes);
22801 // Unintrospectable function: try_realloc() / g_try_realloc()
22802 // Attempts to realloc @mem to a new size, @n_bytes, and returns %NULL
22803 // on failure. Contrast with g_realloc(), which aborts the program
22804 // on failure. If @mem is %NULL, behaves the same as g_try_malloc().
22805 // RETURNS: the allocated memory, or %NULL.
22806 // <mem>: previously-allocated memory, or %NULL.
22807 // <n_bytes>: number of bytes to allocate.
22808 static void* try_realloc()(void* mem, size_t n_bytes) {
22809 return g_try_realloc(mem, n_bytes);
22813 // Unintrospectable function: try_realloc_n() / g_try_realloc_n()
22814 // VERSION: 2.24
22815 // This function is similar to g_try_realloc(), allocating (@n_blocks * @n_block_bytes) bytes,
22816 // but care is taken to detect possible overflow during multiplication.
22817 // RETURNS: the allocated memory, or %NULL.
22818 // <mem>: previously-allocated memory, or %NULL.
22819 // <n_blocks>: the number of blocks to allocate
22820 // <n_block_bytes>: the size of each block in bytes
22821 static void* try_realloc_n()(void* mem, size_t n_blocks, size_t n_block_bytes) {
22822 return g_try_realloc_n(mem, n_blocks, n_block_bytes);
22826 // Convert a string from UCS-4 to UTF-16. A 0 character will be
22827 // added to the result after the converted text.
22829 // This value must be freed with g_free(). If an
22830 // error occurs, %NULL will be returned and
22831 // @error set.
22832 // RETURNS: a pointer to a newly allocated UTF-16 string.
22833 // <str>: a UCS-4 encoded string
22834 // <len>: the maximum length (number of characters) of @str to use. If @len < 0, then the string is nul-terminated.
22835 // <items_read>: location to store number of bytes read, or %NULL. If an error occurs then the index of the invalid input is stored here.
22836 // <items_written>: location to store number of <type>gunichar2</type> written, or %NULL. The value stored here does not include the trailing 0.
22837 static wchar* ucs4_to_utf16()(dchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error=null) {
22838 return g_ucs4_to_utf16(str, len, items_read, items_written, error);
22842 // Convert a string from a 32-bit fixed width representation as UCS-4.
22843 // to UTF-8. The result will be terminated with a 0 byte.
22845 // This value must be freed with g_free(). If an
22846 // error occurs, %NULL will be returned and
22847 // @error set. In that case, @items_read will be
22848 // set to the position of the first invalid input
22849 // character.
22850 // RETURNS: a pointer to a newly allocated UTF-8 string.
22851 // <str>: a UCS-4 encoded string
22852 // <len>: the maximum length (number of characters) of @str to use. If @len < 0, then the string is nul-terminated.
22853 // <items_read>: location to store number of characters read, or %NULL.
22854 // <items_written>: location to store number of bytes written or %NULL. The value here stored does not include the trailing 0 byte.
22855 static char* /*new*/ ucs4_to_utf8()(dchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error=null) {
22856 return g_ucs4_to_utf8(str, len, items_read, items_written, error);
22860 // Determines the break type of @c. @c should be a Unicode character
22861 // (to derive a character from UTF-8 encoded text, use
22862 // g_utf8_get_char()). The break type is used to find word and line
22863 // breaks ("text boundaries"), Pango implements the Unicode boundary
22864 // resolution algorithms and normally you would use a function such
22865 // as pango_break() instead of caring about break types yourself.
22866 // RETURNS: the break type of @c
22867 // <c>: a Unicode character
22868 static UnicodeBreakType unichar_break_type()(dchar c) {
22869 return g_unichar_break_type(c);
22873 // VERSION: 2.14
22874 // Determines the canonical combining class of a Unicode character.
22875 // RETURNS: the combining class of the character
22876 // <uc>: a Unicode character
22877 static int unichar_combining_class()(dchar uc) {
22878 return g_unichar_combining_class(uc);
22882 // VERSION: 2.30
22883 // Performs a single composition step of the
22884 // Unicode canonical composition algorithm.
22886 // This function includes algorithmic Hangul Jamo composition,
22887 // but it is not exactly the inverse of g_unichar_decompose().
22888 // No composition can have either of @a or @b equal to zero.
22889 // To be precise, this function composes if and only if
22890 // there exists a Primary Composite P which is canonically
22891 // equivalent to the sequence <@a,@b>. See the Unicode
22892 // Standard for the definition of Primary Composite.
22894 // If @a and @b do not compose a new character, @ch is set to zero.
22896 // See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
22897 // for details.
22898 // RETURNS: %TRUE if the characters could be composed
22899 // <a>: a Unicode character
22900 // <b>: a Unicode character
22901 // <ch>: return location for the composed character
22902 static int unichar_compose()(dchar a, dchar b, dchar* ch) {
22903 return g_unichar_compose(a, b, ch);
22907 // VERSION: 2.30
22908 // Performs a single decomposition step of the
22909 // Unicode canonical decomposition algorithm.
22911 // This function does not include compatibility
22912 // decompositions. It does, however, include algorithmic
22913 // Hangul Jamo decomposition, as well as 'singleton'
22914 // decompositions which replace a character by a single
22915 // other character. In the case of singletons *@b will
22916 // be set to zero.
22918 // If @ch is not decomposable, *@a is set to @ch and *@b
22919 // is set to zero.
22921 // Note that the way Unicode decomposition pairs are
22922 // defined, it is guaranteed that @b would not decompose
22923 // further, but @a may itself decompose. To get the full
22924 // canonical decomposition for @ch, one would need to
22925 // recursively call this function on @a. Or use
22926 // g_unichar_fully_decompose().
22928 // See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
22929 // for details.
22930 // RETURNS: %TRUE if the character could be decomposed
22931 // <ch>: a Unicode character
22932 // <a>: return location for the first component of @ch
22933 // <b>: return location for the second component of @ch
22934 static int unichar_decompose()(dchar ch, dchar* a, dchar* b) {
22935 return g_unichar_decompose(ch, a, b);
22939 // Determines the numeric value of a character as a decimal
22940 // digit.
22942 // g_unichar_isdigit()), its numeric value. Otherwise, -1.
22943 // RETURNS: If @c is a decimal digit (according to
22944 // <c>: a Unicode character
22945 static int unichar_digit_value()(dchar c) {
22946 return g_unichar_digit_value(c);
22950 // VERSION: 2.30
22951 // Computes the canonical or compatibility decomposition of a
22952 // Unicode character. For compatibility decomposition,
22953 // pass %TRUE for @compat; for canonical decomposition
22954 // pass %FALSE for @compat.
22956 // The decomposed sequence is placed in @result. Only up to
22957 // @result_len characters are written into @result. The length
22958 // of the full decomposition (irrespective of @result_len) is
22959 // returned by the function. For canonical decomposition,
22960 // currently all decompositions are of length at most 4, but
22961 // this may change in the future (very unlikely though).
22962 // At any rate, Unicode does guarantee that a buffer of length
22963 // 18 is always enough for both compatibility and canonical
22964 // decompositions, so that is the size recommended. This is provided
22965 // as %G_UNICHAR_MAX_DECOMPOSITION_LENGTH.
22967 // See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
22968 // for details.
22969 // RETURNS: the length of the full decomposition.
22970 // <ch>: a Unicode character.
22971 // <compat>: whether perform canonical or compatibility decomposition
22972 // <result>: location to store decomposed result, or %NULL
22973 // <result_len>: length of @result
22974 static size_t unichar_fully_decompose()(dchar ch, int compat, dchar* result, size_t result_len) {
22975 return g_unichar_fully_decompose(ch, compat, result, result_len);
22979 // VERSION: 2.4
22980 // In Unicode, some characters are <firstterm>mirrored</firstterm>. This
22981 // means that their images are mirrored horizontally in text that is laid
22982 // out from right to left. For instance, "(" would become its mirror image,
22983 // ")", in right-to-left text.
22985 // If @ch has the Unicode mirrored property and there is another unicode
22986 // character that typically has a glyph that is the mirror image of @ch's
22987 // glyph and @mirrored_ch is set, it puts that character in the address
22988 // pointed to by @mirrored_ch. Otherwise the original character is put.
22989 // RETURNS: %TRUE if @ch has a mirrored character, %FALSE otherwise
22990 // <ch>: a Unicode character
22991 // <mirrored_ch>: location to store the mirrored character
22992 static int unichar_get_mirror_char()(dchar ch, dchar* mirrored_ch) {
22993 return g_unichar_get_mirror_char(ch, mirrored_ch);
22997 // VERSION: 2.14
22998 // Looks up the #GUnicodeScript for a particular character (as defined
22999 // by Unicode Standard Annex \#24). No check is made for @ch being a
23000 // valid Unicode character; if you pass in invalid character, the
23001 // result is undefined.
23003 // This function is equivalent to pango_script_for_unichar() and the
23004 // two are interchangeable.
23005 // RETURNS: the #GUnicodeScript for the character.
23006 // <ch>: a Unicode character
23007 static UnicodeScript unichar_get_script()(dchar ch) {
23008 return g_unichar_get_script(ch);
23012 // Determines whether a character is alphanumeric.
23013 // Given some UTF-8 text, obtain a character value
23014 // with g_utf8_get_char().
23015 // RETURNS: %TRUE if @c is an alphanumeric character
23016 // <c>: a Unicode character
23017 static int unichar_isalnum()(dchar c) {
23018 return g_unichar_isalnum(c);
23022 // Determines whether a character is alphabetic (i.e. a letter).
23023 // Given some UTF-8 text, obtain a character value with
23024 // g_utf8_get_char().
23025 // RETURNS: %TRUE if @c is an alphabetic character
23026 // <c>: a Unicode character
23027 static int unichar_isalpha()(dchar c) {
23028 return g_unichar_isalpha(c);
23032 // Determines whether a character is a control character.
23033 // Given some UTF-8 text, obtain a character value with
23034 // g_utf8_get_char().
23035 // RETURNS: %TRUE if @c is a control character
23036 // <c>: a Unicode character
23037 static int unichar_iscntrl()(dchar c) {
23038 return g_unichar_iscntrl(c);
23042 // Determines if a given character is assigned in the Unicode
23043 // standard.
23044 // RETURNS: %TRUE if the character has an assigned value
23045 // <c>: a Unicode character
23046 static int unichar_isdefined()(dchar c) {
23047 return g_unichar_isdefined(c);
23051 // Determines whether a character is numeric (i.e. a digit). This
23052 // covers ASCII 0-9 and also digits in other languages/scripts. Given
23053 // some UTF-8 text, obtain a character value with g_utf8_get_char().
23054 // RETURNS: %TRUE if @c is a digit
23055 // <c>: a Unicode character
23056 static int unichar_isdigit()(dchar c) {
23057 return g_unichar_isdigit(c);
23061 // Determines whether a character is printable and not a space
23062 // (returns %FALSE for control characters, format characters, and
23063 // spaces). g_unichar_isprint() is similar, but returns %TRUE for
23064 // spaces. Given some UTF-8 text, obtain a character value with
23065 // g_utf8_get_char().
23066 // RETURNS: %TRUE if @c is printable unless it's a space
23067 // <c>: a Unicode character
23068 static int unichar_isgraph()(dchar c) {
23069 return g_unichar_isgraph(c);
23073 // Determines whether a character is a lowercase letter.
23074 // Given some UTF-8 text, obtain a character value with
23075 // g_utf8_get_char().
23076 // RETURNS: %TRUE if @c is a lowercase letter
23077 // <c>: a Unicode character
23078 static int unichar_islower()(dchar c) {
23079 return g_unichar_islower(c);
23083 // VERSION: 2.14
23084 // Determines whether a character is a mark (non-spacing mark,
23085 // combining mark, or enclosing mark in Unicode speak).
23086 // Given some UTF-8 text, obtain a character value
23087 // with g_utf8_get_char().
23089 // Note: in most cases where isalpha characters are allowed,
23090 // ismark characters should be allowed to as they are essential
23091 // for writing most European languages as well as many non-Latin
23092 // scripts.
23093 // RETURNS: %TRUE if @c is a mark character
23094 // <c>: a Unicode character
23095 static int unichar_ismark()(dchar c) {
23096 return g_unichar_ismark(c);
23100 // Determines whether a character is printable.
23101 // Unlike g_unichar_isgraph(), returns %TRUE for spaces.
23102 // Given some UTF-8 text, obtain a character value with
23103 // g_utf8_get_char().
23104 // RETURNS: %TRUE if @c is printable
23105 // <c>: a Unicode character
23106 static int unichar_isprint()(dchar c) {
23107 return g_unichar_isprint(c);
23111 // Determines whether a character is punctuation or a symbol.
23112 // Given some UTF-8 text, obtain a character value with
23113 // g_utf8_get_char().
23114 // RETURNS: %TRUE if @c is a punctuation or symbol character
23115 // <c>: a Unicode character
23116 static int unichar_ispunct()(dchar c) {
23117 return g_unichar_ispunct(c);
23121 // Determines whether a character is a space, tab, or line separator
23122 // (newline, carriage return, etc.). Given some UTF-8 text, obtain a
23123 // character value with g_utf8_get_char().
23125 // (Note: don't use this to do word breaking; you have to use
23126 // Pango or equivalent to get word breaking right, the algorithm
23127 // is fairly complex.)
23128 // RETURNS: %TRUE if @c is a space character
23129 // <c>: a Unicode character
23130 static int unichar_isspace()(dchar c) {
23131 return g_unichar_isspace(c);
23135 // Determines if a character is titlecase. Some characters in
23136 // Unicode which are composites, such as the DZ digraph
23137 // have three case variants instead of just two. The titlecase
23138 // form is used at the beginning of a word where only the
23139 // first letter is capitalized. The titlecase form of the DZ
23140 // digraph is U+01F2 LATIN CAPITAL LETTTER D WITH SMALL LETTER Z.
23141 // RETURNS: %TRUE if the character is titlecase
23142 // <c>: a Unicode character
23143 static int unichar_istitle()(dchar c) {
23144 return g_unichar_istitle(c);
23148 // Determines if a character is uppercase.
23149 // RETURNS: %TRUE if @c is an uppercase character
23150 // <c>: a Unicode character
23151 static int unichar_isupper()(dchar c) {
23152 return g_unichar_isupper(c);
23156 // Determines if a character is typically rendered in a double-width
23157 // cell.
23158 // RETURNS: %TRUE if the character is wide
23159 // <c>: a Unicode character
23160 static int unichar_iswide()(dchar c) {
23161 return g_unichar_iswide(c);
23165 // VERSION: 2.12
23166 // Determines if a character is typically rendered in a double-width
23167 // cell under legacy East Asian locales. If a character is wide according to
23168 // g_unichar_iswide(), then it is also reported wide with this function, but
23169 // the converse is not necessarily true. See the
23170 // <ulink url="http://www.unicode.org/reports/tr11/">Unicode Standard
23171 // Annex #11</ulink> for details.
23173 // If a character passes the g_unichar_iswide() test then it will also pass
23174 // this test, but not the other way around. Note that some characters may
23175 // pas both this test and g_unichar_iszerowidth().
23176 // RETURNS: %TRUE if the character is wide in legacy East Asian locales
23177 // <c>: a Unicode character
23178 static int unichar_iswide_cjk()(dchar c) {
23179 return g_unichar_iswide_cjk(c);
23183 // Determines if a character is a hexidecimal digit.
23184 // RETURNS: %TRUE if the character is a hexadecimal digit
23185 // <c>: a Unicode character.
23186 static int unichar_isxdigit()(dchar c) {
23187 return g_unichar_isxdigit(c);
23191 // VERSION: 2.14
23192 // Determines if a given character typically takes zero width when rendered.
23193 // The return value is %TRUE for all non-spacing and enclosing marks
23194 // (e.g., combining accents), format characters, zero-width
23195 // space, but not U+00AD SOFT HYPHEN.
23197 // A typical use of this function is with one of g_unichar_iswide() or
23198 // g_unichar_iswide_cjk() to determine the number of cells a string occupies
23199 // when displayed on a grid display (terminals). However, note that not all
23200 // terminals support zero-width rendering of zero-width marks.
23201 // RETURNS: %TRUE if the character has zero width
23202 // <c>: a Unicode character
23203 static int unichar_iszerowidth()(dchar c) {
23204 return g_unichar_iszerowidth(c);
23208 // Converts a single character to UTF-8.
23209 // RETURNS: number of bytes written
23210 // <c>: a Unicode character code
23211 // <outbuf>: output buffer, must have at least 6 bytes of space. If %NULL, the length will be computed and returned and nothing will be written to @outbuf.
23212 static int unichar_to_utf8()(dchar c, char* outbuf) {
23213 return g_unichar_to_utf8(c, outbuf);
23217 // Converts a character to lower case.
23219 // If @c is not an upperlower or titlecase character,
23220 // or has no lowercase equivalent @c is returned unchanged.
23221 // RETURNS: the result of converting @c to lower case.
23222 // <c>: a Unicode character.
23223 static dchar unichar_tolower()(dchar c) {
23224 return g_unichar_tolower(c);
23228 // Converts a character to the titlecase.
23230 // If @c is not an uppercase or lowercase character,
23231 // @c is returned unchanged.
23232 // RETURNS: the result of converting @c to titlecase.
23233 // <c>: a Unicode character
23234 static dchar unichar_totitle()(dchar c) {
23235 return g_unichar_totitle(c);
23239 // Converts a character to uppercase.
23241 // If @c is not an lowercase or titlecase character,
23242 // or has no upper case equivalent @c is returned unchanged.
23243 // RETURNS: the result of converting @c to uppercase.
23244 // <c>: a Unicode character
23245 static dchar unichar_toupper()(dchar c) {
23246 return g_unichar_toupper(c);
23250 // Classifies a Unicode character by type.
23251 // RETURNS: the type of the character.
23252 // <c>: a Unicode character
23253 static UnicodeType unichar_type()(dchar c) {
23254 return g_unichar_type(c);
23258 // Checks whether @ch is a valid Unicode character. Some possible
23259 // integer values of @ch will not be valid. 0 is considered a valid
23260 // character, though it's normally a string terminator.
23261 // RETURNS: %TRUE if @ch is a valid Unicode character
23262 // <ch>: a Unicode character
23263 static int unichar_validate()(dchar ch) {
23264 return g_unichar_validate(ch);
23268 // Determines the numeric value of a character as a hexidecimal
23269 // digit.
23271 // g_unichar_isxdigit()), its numeric value. Otherwise, -1.
23272 // RETURNS: If @c is a hex digit (according to
23273 // <c>: a Unicode character
23274 static int unichar_xdigit_value()(dchar c) {
23275 return g_unichar_xdigit_value(c);
23279 // DEPRECATED (v2.30) function: unicode_canonical_decomposition - Use the more flexible g_unichar_fully_decompose()
23280 // Computes the canonical decomposition of a Unicode character.
23282 // @result_len is set to the resulting length of the string.
23284 // instead.
23285 // RETURNS: a newly allocated string of Unicode characters.
23286 // <ch>: a Unicode character.
23287 // <result_len>: location to store the length of the return value.
23288 static dchar* unicode_canonical_decomposition()(dchar ch, size_t* result_len) {
23289 return g_unicode_canonical_decomposition(ch, result_len);
23293 // Computes the canonical ordering of a string in-place.
23294 // This rearranges decomposed characters in the string
23295 // according to their combining classes. See the Unicode
23296 // manual for more information.
23297 // <string>: a UCS-4 encoded string.
23298 // <len>: the maximum length of @string to use.
23299 static void unicode_canonical_ordering()(dchar* string_, size_t len) {
23300 g_unicode_canonical_ordering(string_, len);
23304 // VERSION: 2.30
23305 // Looks up the Unicode script for @iso15924. ISO 15924 assigns four-letter
23306 // codes to scripts. For example, the code for Arabic is 'Arab'.
23307 // This function accepts four letter codes encoded as a @guint32 in a
23308 // big-endian fashion. That is, the code expected for Arabic is
23309 // 0x41726162 (0x41 is ASCII code for 'A', 0x72 is ASCII code for 'r', etc).
23311 // See <ulink url="http://unicode.org/iso15924/codelists.html">Codes for the
23312 // representation of names of scripts</ulink> for details.
23314 // of %G_UNICODE_SCRIPT_INVALID_CODE if @iso15924 is zero and
23315 // %G_UNICODE_SCRIPT_UNKNOWN if @iso15924 is unknown.
23316 // RETURNS: the Unicode script for @iso15924, or
23317 // <iso15924>: a Unicode script
23318 static UnicodeScript unicode_script_from_iso15924()(uint iso15924) {
23319 return g_unicode_script_from_iso15924(iso15924);
23323 // VERSION: 2.30
23324 // Looks up the ISO 15924 code for @script. ISO 15924 assigns four-letter
23325 // codes to scripts. For example, the code for Arabic is 'Arab'. The
23326 // four letter codes are encoded as a @guint32 by this function in a
23327 // big-endian fashion. That is, the code returned for Arabic is
23328 // 0x41726162 (0x41 is ASCII code for 'A', 0x72 is ASCII code for 'r', etc).
23330 // See <ulink url="http://unicode.org/iso15924/codelists.html">Codes for the
23331 // representation of names of scripts</ulink> for details.
23333 // of zero if @script is %G_UNICODE_SCRIPT_INVALID_CODE or
23334 // ISO 15924 code 'Zzzz' (script code for UNKNOWN) if @script is not understood.
23335 // RETURNS: the ISO 15924 code for @script, encoded as an integer,
23336 // <script>: a Unicode script
23337 static uint unicode_script_to_iso15924()(UnicodeScript script) {
23338 return g_unicode_script_to_iso15924(script);
23342 // VERSION: 2.6
23343 // A wrapper for the POSIX unlink() function. The unlink() function
23344 // deletes a name from the filesystem. If this was the last link to the
23345 // file and no processes have it opened, the diskspace occupied by the
23346 // file is freed.
23348 // See your C library manual for more details about unlink(). Note
23349 // that on Windows, it is in general not possible to delete files that
23350 // are open to some process, or mapped into memory.
23352 // occurred
23353 // RETURNS: 0 if the name was successfully deleted, -1 if an error
23354 // <filename>: a pathname in the GLib file name encoding (UTF-8 on Windows)
23355 static int unlink()(char* filename) {
23356 return g_unlink(filename);
23360 // VERSION: 2.4
23361 // Removes an environment variable from the environment.
23363 // Note that on some systems, when variables are overwritten, the
23364 // memory used for the previous variables and its value isn't reclaimed.
23366 // <warning><para>
23367 // Environment variable handling in UNIX is not thread-safe, and your
23368 // program may crash if one thread calls g_unsetenv() while another
23369 // thread is calling getenv(). (And note that many functions, such as
23370 // gettext(), call getenv() internally.) This function is only safe
23371 // to use at the very start of your program, before creating any other
23372 // threads (or creating objects that create worker threads of their
23373 // own).
23374 // </para><para>
23375 // If you need to set up the environment for a child process, you can
23376 // use g_get_environ() to get an environment array, modify that with
23377 // g_environ_setenv() and g_environ_unsetenv(), and then pass that
23378 // array directly to execvpe(), g_spawn_async(), or the like.
23379 // </para></warning>
23380 // <variable>: the environment variable to remove, must not contain '='
23381 static void unsetenv()(char* variable) {
23382 g_unsetenv(variable);
23386 // VERSION: 2.16
23387 // Escapes a string for use in a URI.
23389 // Normally all characters that are not "unreserved" (i.e. ASCII alphanumerical
23390 // characters plus dash, dot, underscore and tilde) are escaped.
23391 // But if you specify characters in @reserved_chars_allowed they are not
23392 // escaped. This is useful for the "reserved" characters in the URI
23393 // specification, since those are allowed unescaped in some portions of
23394 // a URI.
23396 // freed when no longer needed.
23397 // RETURNS: an escaped version of @unescaped. The returned string should be
23398 // <unescaped>: the unescaped input string.
23399 // <reserved_chars_allowed>: a string of reserved characters that are allowed to be used, or %NULL.
23400 // <allow_utf8>: %TRUE if the result can include UTF-8 characters.
23401 static char* /*new*/ uri_escape_string()(char* unescaped, char* reserved_chars_allowed, int allow_utf8) {
23402 return g_uri_escape_string(unescaped, reserved_chars_allowed, allow_utf8);
23406 // Unintrospectable function: uri_list_extract_uris() / g_uri_list_extract_uris()
23407 // VERSION: 2.6
23408 // Splits an URI list conforming to the text/uri-list
23409 // mime type defined in RFC 2483 into individual URIs,
23410 // discarding any comments. The URIs are not validated.
23412 // strings holding the individual URIs. The array should
23413 // be freed with g_strfreev().
23414 // RETURNS: a newly allocated %NULL-terminated list of
23415 // <uri_list>: an URI list
23416 static char** uri_list_extract_uris()(char* uri_list) {
23417 return g_uri_list_extract_uris(uri_list);
23421 // VERSION: 2.16
23422 // Gets the scheme portion of a URI string. RFC 3986 decodes the scheme as:
23423 // <programlisting>
23424 // URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
23425 // </programlisting>
23426 // Common schemes include "file", "http", "svn+ssh", etc.
23428 // The returned string should be freed when no longer needed.
23429 // RETURNS: The "Scheme" component of the URI, or %NULL on error.
23430 // <uri>: a valid URI.
23431 static char* /*new*/ uri_parse_scheme()(char* uri) {
23432 return g_uri_parse_scheme(uri);
23436 // VERSION: 2.16
23437 // Unescapes a segment of an escaped string.
23439 // If any of the characters in @illegal_characters or the character zero appears
23440 // as an escaped character in @escaped_string then that is an error and %NULL
23441 // will be returned. This is useful it you want to avoid for instance having a
23442 // slash being expanded in an escaped path element, which might confuse pathname
23443 // handling.
23445 // The returned string should be freed when no longer needed.
23446 // RETURNS: an unescaped version of @escaped_string or %NULL on error.
23447 // <escaped_string>: a string.
23448 // <escaped_string_end>: a string.
23449 // <illegal_characters>: an optional string of illegal characters not to be allowed.
23450 static char* /*new*/ uri_unescape_segment()(char* escaped_string, char* escaped_string_end, char* illegal_characters) {
23451 return g_uri_unescape_segment(escaped_string, escaped_string_end, illegal_characters);
23455 // VERSION: 2.16
23456 // Unescapes a whole escaped string.
23458 // If any of the characters in @illegal_characters or the character zero appears
23459 // as an escaped character in @escaped_string then that is an error and %NULL
23460 // will be returned. This is useful it you want to avoid for instance having a
23461 // slash being expanded in an escaped path element, which might confuse pathname
23462 // handling.
23464 // should be freed when no longer needed.
23465 // RETURNS: an unescaped version of @escaped_string. The returned string
23466 // <escaped_string>: an escaped string to be unescaped.
23467 // <illegal_characters>: an optional string of illegal characters not to be allowed.
23468 static char* /*new*/ uri_unescape_string()(char* escaped_string, char* illegal_characters) {
23469 return g_uri_unescape_string(escaped_string, illegal_characters);
23473 // Pauses the current thread for the given number of microseconds.
23475 // There are 1 million microseconds per second (represented by the
23476 // #G_USEC_PER_SEC macro). g_usleep() may have limited precision,
23477 // depending on hardware and operating system; don't rely on the exact
23478 // length of the sleep.
23479 // <microseconds>: number of microseconds to pause
23480 static void usleep()(c_ulong microseconds) {
23481 g_usleep(microseconds);
23485 // Convert a string from UTF-16 to UCS-4. The result will be
23486 // nul-terminated.
23488 // This value must be freed with g_free(). If an
23489 // error occurs, %NULL will be returned and
23490 // @error set.
23491 // RETURNS: a pointer to a newly allocated UCS-4 string.
23492 // <str>: a UTF-16 encoded string
23493 // <len>: the maximum length (number of <type>gunichar2</type>) of @str to use. If @len < 0, then the string is nul-terminated.
23494 // <items_read>: location to store number of words read, or %NULL. If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be returned in case @str contains a trailing partial character. If an error occurs then the index of the invalid input is stored here.
23495 // <items_written>: location to store number of characters written, or %NULL. The value stored here does not include the trailing 0 character.
23496 static dchar* utf16_to_ucs4()(wchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error=null) {
23497 return g_utf16_to_ucs4(str, len, items_read, items_written, error);
23501 // Convert a string from UTF-16 to UTF-8. The result will be
23502 // terminated with a 0 byte.
23504 // Note that the input is expected to be already in native endianness,
23505 // an initial byte-order-mark character is not handled specially.
23506 // g_convert() can be used to convert a byte buffer of UTF-16 data of
23507 // ambiguous endianess.
23509 // Further note that this function does not validate the result
23510 // string; it may e.g. include embedded NUL characters. The only
23511 // validation done by this function is to ensure that the input can
23512 // be correctly interpreted as UTF-16, i.e. it doesn't contain
23513 // things unpaired surrogates.
23515 // This value must be freed with g_free(). If an
23516 // error occurs, %NULL will be returned and
23517 // @error set.
23518 // RETURNS: a pointer to a newly allocated UTF-8 string.
23519 // <str>: a UTF-16 encoded string
23520 // <len>: the maximum length (number of <type>gunichar2</type>) of @str to use. If @len < 0, then the string is nul-terminated.
23521 // <items_read>: location to store number of words read, or %NULL. If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be returned in case @str contains a trailing partial character. If an error occurs then the index of the invalid input is stored here.
23522 // <items_written>: location to store number of bytes written, or %NULL. The value stored here does not include the trailing 0 byte.
23523 static char* /*new*/ utf16_to_utf8()(wchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error=null) {
23524 return g_utf16_to_utf8(str, len, items_read, items_written, error);
23528 // Converts a string into a form that is independent of case. The
23529 // result will not correspond to any particular case, but can be
23530 // compared for equality or ordered with the results of calling
23531 // g_utf8_casefold() on other strings.
23533 // Note that calling g_utf8_casefold() followed by g_utf8_collate() is
23534 // only an approximation to the correct linguistic case insensitive
23535 // ordering, though it is a fairly good one. Getting this exactly
23536 // right would require a more sophisticated collation function that
23537 // takes case sensitivity into account. GLib does not currently
23538 // provide such a function.
23540 // case independent form of @str.
23541 // RETURNS: a newly allocated string, that is a
23542 // <str>: a UTF-8 encoded string
23543 // <len>: length of @str, in bytes, or -1 if @str is nul-terminated.
23544 static char* /*new*/ utf8_casefold()(char* str, ssize_t len) {
23545 return g_utf8_casefold(str, len);
23549 // Compares two strings for ordering using the linguistically
23550 // correct rules for the <link linkend="setlocale">current locale</link>.
23551 // When sorting a large number of strings, it will be significantly
23552 // faster to obtain collation keys with g_utf8_collate_key() and
23553 // compare the keys with strcmp() when sorting instead of sorting
23554 // the original strings.
23556 // 0 if they compare equal, &gt; 0 if @str1 compares after @str2.
23557 // RETURNS: &lt; 0 if @str1 compares before @str2,
23558 // <str1>: a UTF-8 encoded string
23559 // <str2>: a UTF-8 encoded string
23560 static int utf8_collate()(char* str1, char* str2) {
23561 return g_utf8_collate(str1, str2);
23565 // Converts a string into a collation key that can be compared
23566 // with other collation keys produced by the same function using
23567 // strcmp().
23569 // The results of comparing the collation keys of two strings
23570 // with strcmp() will always be the same as comparing the two
23571 // original keys with g_utf8_collate().
23573 // Note that this function depends on the
23574 // <link linkend="setlocale">current locale</link>.
23576 // be freed with g_free() when you are done with it.
23577 // RETURNS: a newly allocated string. This string should
23578 // <str>: a UTF-8 encoded string.
23579 // <len>: length of @str, in bytes, or -1 if @str is nul-terminated.
23580 static char* /*new*/ utf8_collate_key()(char* str, ssize_t len) {
23581 return g_utf8_collate_key(str, len);
23585 // VERSION: 2.8
23586 // Converts a string into a collation key that can be compared
23587 // with other collation keys produced by the same function using strcmp().
23589 // In order to sort filenames correctly, this function treats the dot '.'
23590 // as a special case. Most dictionary orderings seem to consider it
23591 // insignificant, thus producing the ordering "event.c" "eventgenerator.c"
23592 // "event.h" instead of "event.c" "event.h" "eventgenerator.c". Also, we
23593 // would like to treat numbers intelligently so that "file1" "file10" "file5"
23594 // is sorted as "file1" "file5" "file10".
23596 // Note that this function depends on the
23597 // <link linkend="setlocale">current locale</link>.
23599 // be freed with g_free() when you are done with it.
23600 // RETURNS: a newly allocated string. This string should
23601 // <str>: a UTF-8 encoded string.
23602 // <len>: length of @str, in bytes, or -1 if @str is nul-terminated.
23603 static char* /*new*/ utf8_collate_key_for_filename()(char* str, ssize_t len) {
23604 return g_utf8_collate_key_for_filename(str, len);
23608 // Finds the start of the next UTF-8 character in the string after @p.
23610 // @p does not have to be at the beginning of a UTF-8 character. No check
23611 // is made to see if the character found is actually valid other than
23612 // it starts with an appropriate byte.
23613 // RETURNS: a pointer to the found character or %NULL
23614 // <p>: a pointer to a position within a UTF-8 encoded string
23615 // <end>: a pointer to the byte following the end of the string, or %NULL to indicate that the string is nul-terminated.
23616 static char* /*new*/ utf8_find_next_char()(char* p, char* end) {
23617 return g_utf8_find_next_char(p, end);
23621 // Given a position @p with a UTF-8 encoded string @str, find the start
23622 // of the previous UTF-8 character starting before @p. Returns %NULL if no
23623 // UTF-8 characters are present in @str before @p.
23625 // @p does not have to be at the beginning of a UTF-8 character. No check
23626 // is made to see if the character found is actually valid other than
23627 // it starts with an appropriate byte.
23628 // RETURNS: a pointer to the found character or %NULL.
23629 // <str>: pointer to the beginning of a UTF-8 encoded string
23630 // <p>: pointer to some position within @str
23631 static char* /*new*/ utf8_find_prev_char()(char* str, char* p) {
23632 return g_utf8_find_prev_char(str, p);
23636 // Converts a sequence of bytes encoded as UTF-8 to a Unicode character.
23637 // If @p does not point to a valid UTF-8 encoded character, results are
23638 // undefined. If you are not sure that the bytes are complete
23639 // valid Unicode characters, you should use g_utf8_get_char_validated()
23640 // instead.
23641 // RETURNS: the resulting character
23642 // <p>: a pointer to Unicode character encoded as UTF-8
23643 static dchar utf8_get_char()(char* p) {
23644 return g_utf8_get_char(p);
23648 // Convert a sequence of bytes encoded as UTF-8 to a Unicode character.
23649 // This function checks for incomplete characters, for invalid characters
23650 // such as characters that are out of the range of Unicode, and for
23651 // overlong encodings of valid characters.
23653 // sequence at the end of a string that could begin a valid
23654 // character (or if @max_len is zero), returns (gunichar)-2;
23655 // otherwise, if @p does not point to a valid UTF-8 encoded
23656 // Unicode character, returns (gunichar)-1.
23657 // RETURNS: the resulting character. If @p points to a partial
23658 // <p>: a pointer to Unicode character encoded as UTF-8
23659 // <max_len>: the maximum number of bytes to read, or -1, for no maximum or if @p is nul-terminated
23660 static dchar utf8_get_char_validated()(char* p, ssize_t max_len) {
23661 return g_utf8_get_char_validated(p, max_len);
23665 // Converts a string into canonical form, standardizing
23666 // such issues as whether a character with an accent
23667 // is represented as a base character and combining
23668 // accent or as a single precomposed character. The
23669 // string has to be valid UTF-8, otherwise %NULL is
23670 // returned. You should generally call g_utf8_normalize()
23671 // before comparing two Unicode strings.
23673 // The normalization mode %G_NORMALIZE_DEFAULT only
23674 // standardizes differences that do not affect the
23675 // text content, such as the above-mentioned accent
23676 // representation. %G_NORMALIZE_ALL also standardizes
23677 // the "compatibility" characters in Unicode, such
23678 // as SUPERSCRIPT THREE to the standard forms
23679 // (in this case DIGIT THREE). Formatting information
23680 // may be lost but for most text operations such
23681 // characters should be considered the same.
23683 // %G_NORMALIZE_DEFAULT_COMPOSE and %G_NORMALIZE_ALL_COMPOSE
23684 // are like %G_NORMALIZE_DEFAULT and %G_NORMALIZE_ALL,
23685 // but returned a result with composed forms rather
23686 // than a maximally decomposed form. This is often
23687 // useful if you intend to convert the string to
23688 // a legacy encoding or pass it to a system with
23689 // less capable Unicode handling.
23691 // normalized form of @str, or %NULL if @str is not
23692 // valid UTF-8.
23693 // RETURNS: a newly allocated string, that is the
23694 // <str>: a UTF-8 encoded string.
23695 // <len>: length of @str, in bytes, or -1 if @str is nul-terminated.
23696 // <mode>: the type of normalization to perform.
23697 static char* /*new*/ utf8_normalize()(char* str, ssize_t len, NormalizeMode mode) {
23698 return g_utf8_normalize(str, len, mode);
23702 // Converts from an integer character offset to a pointer to a position
23703 // within the string.
23705 // Since 2.10, this function allows to pass a negative @offset to
23706 // step backwards. It is usually worth stepping backwards from the end
23707 // instead of forwards if @offset is in the last fourth of the string,
23708 // since moving forward is about 3 times faster than moving backward.
23710 // <note><para>
23711 // This function doesn't abort when reaching the end of @str. Therefore
23712 // you should be sure that @offset is within string boundaries before
23713 // calling that function. Call g_utf8_strlen() when unsure.
23715 // This limitation exists as this function is called frequently during
23716 // text rendering and therefore has to be as fast as possible.
23717 // </para></note>
23718 // RETURNS: the resulting pointer
23719 // <str>: a UTF-8 encoded string
23720 // <offset>: a character offset within @str
23721 static char* /*new*/ utf8_offset_to_pointer()(char* str, c_long offset) {
23722 return g_utf8_offset_to_pointer(str, offset);
23726 // Converts from a pointer to position within a string to a integer
23727 // character offset.
23729 // Since 2.10, this function allows @pos to be before @str, and returns
23730 // a negative offset in this case.
23731 // RETURNS: the resulting character offset
23732 // <str>: a UTF-8 encoded string
23733 // <pos>: a pointer to a position within @str
23734 static c_long utf8_pointer_to_offset()(char* str, char* pos) {
23735 return g_utf8_pointer_to_offset(str, pos);
23739 // Finds the previous UTF-8 character in the string before @p.
23741 // @p does not have to be at the beginning of a UTF-8 character. No check
23742 // is made to see if the character found is actually valid other than
23743 // it starts with an appropriate byte. If @p might be the first
23744 // character of the string, you must use g_utf8_find_prev_char() instead.
23745 // RETURNS: a pointer to the found character.
23746 // <p>: a pointer to a position within a UTF-8 encoded string
23747 static char* /*new*/ utf8_prev_char()(char* p) {
23748 return g_utf8_prev_char(p);
23752 // Finds the leftmost occurrence of the given Unicode character
23753 // in a UTF-8 encoded string, while limiting the search to @len bytes.
23754 // If @len is -1, allow unbounded search.
23756 // otherwise, a pointer to the start of the leftmost occurrence of
23757 // the character in the string.
23758 // RETURNS: %NULL if the string does not contain the character,
23759 // <p>: a nul-terminated UTF-8 encoded string
23760 // <len>: the maximum length of @p
23761 // <c>: a Unicode character
23762 static char* /*new*/ utf8_strchr()(char* p, ssize_t len, dchar c) {
23763 return g_utf8_strchr(p, len, c);
23767 // Converts all Unicode characters in the string that have a case
23768 // to lowercase. The exact manner that this is done depends
23769 // on the current locale, and may result in the number of
23770 // characters in the string changing.
23772 // converted to lowercase.
23773 // RETURNS: a newly allocated string, with all characters
23774 // <str>: a UTF-8 encoded string
23775 // <len>: length of @str, in bytes, or -1 if @str is nul-terminated.
23776 static char* /*new*/ utf8_strdown()(char* str, ssize_t len) {
23777 return g_utf8_strdown(str, len);
23781 // Computes the length of the string in characters, not including
23782 // the terminating nul character. If the @max'th byte falls in the
23783 // middle of a character, the last (partial) character is not counted.
23784 // RETURNS: the length of the string in characters
23785 // <p>: pointer to the start of a UTF-8 encoded string
23786 // <max>: the maximum number of bytes to examine. If @max is less than 0, then the string is assumed to be nul-terminated. If @max is 0, @p will not be examined and may be %NULL. If @max is greater than 0, up to @max bytes are examined
23787 static c_long utf8_strlen()(char* p, ssize_t max) {
23788 return g_utf8_strlen(p, max);
23792 // Like the standard C strncpy() function, but
23793 // copies a given number of characters instead of a given number of
23794 // bytes. The @src string must be valid UTF-8 encoded text.
23795 // (Use g_utf8_validate() on all text before trying to use UTF-8
23796 // utility functions with it.)
23797 // RETURNS: @dest
23798 // <dest>: buffer to fill with characters from @src
23799 // <src>: UTF-8 encoded string
23800 // <n>: character count
23801 static char* /*new*/ utf8_strncpy()(char* dest, char* src, size_t n) {
23802 return g_utf8_strncpy(dest, src, n);
23806 // Find the rightmost occurrence of the given Unicode character
23807 // in a UTF-8 encoded string, while limiting the search to @len bytes.
23808 // If @len is -1, allow unbounded search.
23810 // otherwise, a pointer to the start of the rightmost occurrence of the
23811 // character in the string.
23812 // RETURNS: %NULL if the string does not contain the character,
23813 // <p>: a nul-terminated UTF-8 encoded string
23814 // <len>: the maximum length of @p
23815 // <c>: a Unicode character
23816 static char* /*new*/ utf8_strrchr()(char* p, ssize_t len, dchar c) {
23817 return g_utf8_strrchr(p, len, c);
23821 // VERSION: 2.2
23822 // Reverses a UTF-8 string. @str must be valid UTF-8 encoded text.
23823 // (Use g_utf8_validate() on all text before trying to use UTF-8
23824 // utility functions with it.)
23826 // This function is intended for programmatic uses of reversed strings.
23827 // It pays no attention to decomposed characters, combining marks, byte
23828 // order marks, directional indicators (LRM, LRO, etc) and similar
23829 // characters which might need special handling when reversing a string
23830 // for display purposes.
23832 // Note that unlike g_strreverse(), this function returns
23833 // newly-allocated memory, which should be freed with g_free() when
23834 // no longer needed.
23835 // RETURNS: a newly-allocated string which is the reverse of @str.
23836 // <str>: a UTF-8 encoded string
23837 // <len>: the maximum length of @str to use, in bytes. If @len < 0, then the string is nul-terminated.
23838 static char* /*new*/ utf8_strreverse()(char* str, ssize_t len) {
23839 return g_utf8_strreverse(str, len);
23843 // Converts all Unicode characters in the string that have a case
23844 // to uppercase. The exact manner that this is done depends
23845 // on the current locale, and may result in the number of
23846 // characters in the string increasing. (For instance, the
23847 // German ess-zet will be changed to SS.)
23849 // converted to uppercase.
23850 // RETURNS: a newly allocated string, with all characters
23851 // <str>: a UTF-8 encoded string
23852 // <len>: length of @str, in bytes, or -1 if @str is nul-terminated.
23853 static char* /*new*/ utf8_strup()(char* str, ssize_t len) {
23854 return g_utf8_strup(str, len);
23858 // VERSION: 2.30
23859 // Copies a substring out of a UTF-8 encoded string.
23860 // The substring will contain @end_pos - @start_pos
23861 // characters.
23863 // substring. Free with g_free() when no longer needed.
23864 // RETURNS: a newly allocated copy of the requested
23865 // <str>: a UTF-8 encoded string
23866 // <start_pos>: a character offset within @str
23867 // <end_pos>: another character offset within @str
23868 static char* /*new*/ utf8_substring()(char* str, c_long start_pos, c_long end_pos) {
23869 return g_utf8_substring(str, start_pos, end_pos);
23873 // Convert a string from UTF-8 to a 32-bit fixed width
23874 // representation as UCS-4. A trailing 0 character will be added to the
23875 // string after the converted text.
23877 // This value must be freed with g_free(). If an
23878 // error occurs, %NULL will be returned and
23879 // @error set.
23880 // RETURNS: a pointer to a newly allocated UCS-4 string.
23881 // <str>: a UTF-8 encoded string
23882 // <len>: the maximum length of @str to use, in bytes. If @len < 0, then the string is nul-terminated.
23883 // <items_read>: location to store number of bytes read, or %NULL. If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be returned in case @str contains a trailing partial character. If an error occurs then the index of the invalid input is stored here.
23884 // <items_written>: location to store number of characters written or %NULL. The value here stored does not include the trailing 0 character.
23885 static dchar* utf8_to_ucs4()(char* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error=null) {
23886 return g_utf8_to_ucs4(str, len, items_read, items_written, error);
23890 // Convert a string from UTF-8 to a 32-bit fixed width
23891 // representation as UCS-4, assuming valid UTF-8 input.
23892 // This function is roughly twice as fast as g_utf8_to_ucs4()
23893 // but does no error checking on the input. A trailing 0 character
23894 // will be added to the string after the converted text.
23896 // This value must be freed with g_free().
23897 // RETURNS: a pointer to a newly allocated UCS-4 string.
23898 // <str>: a UTF-8 encoded string
23899 // <len>: the maximum length of @str to use, in bytes. If @len < 0, then the string is nul-terminated.
23900 // <items_written>: location to store the number of characters in the result, or %NULL.
23901 static dchar* utf8_to_ucs4_fast()(char* str, c_long len, c_long* items_written) {
23902 return g_utf8_to_ucs4_fast(str, len, items_written);
23906 // Convert a string from UTF-8 to UTF-16. A 0 character will be
23907 // added to the result after the converted text.
23909 // This value must be freed with g_free(). If an
23910 // error occurs, %NULL will be returned and
23911 // @error set.
23912 // RETURNS: a pointer to a newly allocated UTF-16 string.
23913 // <str>: a UTF-8 encoded string
23914 // <len>: the maximum length (number of bytes) of @str to use. If @len < 0, then the string is nul-terminated.
23915 // <items_read>: location to store number of bytes read, or %NULL. If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be returned in case @str contains a trailing partial character. If an error occurs then the index of the invalid input is stored here.
23916 // <items_written>: location to store number of <type>gunichar2</type> written, or %NULL. The value stored here does not include the trailing 0.
23917 static wchar* utf8_to_utf16()(char* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error=null) {
23918 return g_utf8_to_utf16(str, len, items_read, items_written, error);
23922 // Validates UTF-8 encoded text. @str is the text to validate;
23923 // if @str is nul-terminated, then @max_len can be -1, otherwise
23924 // @max_len should be the number of bytes to validate.
23925 // If @end is non-%NULL, then the end of the valid range
23926 // will be stored there (i.e. the start of the first invalid
23927 // character if some bytes were invalid, or the end of the text
23928 // being validated otherwise).
23930 // Note that g_utf8_validate() returns %FALSE if @max_len is
23931 // positive and any of the @max_len bytes are NUL.
23933 // Returns %TRUE if all of @str was valid. Many GLib and GTK+
23934 // routines <emphasis>require</emphasis> valid UTF-8 as input;
23935 // so data read from a file or the network should be checked
23936 // with g_utf8_validate() before doing anything else with it.
23937 // RETURNS: %TRUE if the text was valid UTF-8
23938 // <str>: a pointer to character data
23939 // <max_len>: max bytes to validate, or -1 to go until NUL
23940 // <end>: return location for end of valid data
23941 static int utf8_validate()(char* str, ssize_t max_len, /*out*/ char** end=null) {
23942 return g_utf8_validate(str, max_len, end);
23945 static Type variant_get_gtype()() {
23946 return g_variant_get_gtype();
23950 // VERSION: 2.24
23951 // Determines the type of @value.
23953 // The return value is valid for the lifetime of @value and must not
23954 // be freed.
23955 // RETURNS: a #GVariantType
23956 // <value>: a #GVariant
23957 static VariantType* variant_get_type()(Variant* value) {
23958 return g_variant_get_type(value);
23962 // VERSION: 2.24
23963 // MOVED TO: Variant.is_object_path
23964 // Determines if a given string is a valid D-Bus object path. You
23965 // should ensure that a string is a valid D-Bus object path before
23966 // passing it to g_variant_new_object_path().
23968 // A valid object path starts with '/' followed by zero or more
23969 // sequences of characters separated by '/' characters. Each sequence
23970 // must contain only the characters "[A-Z][a-z][0-9]_". No sequence
23971 // (including the one following the final '/' character) may be empty.
23972 // RETURNS: %TRUE if @string is a D-Bus object path
23973 // <string>: a normal C nul-terminated string
23974 static int variant_is_object_path()(char* string_) {
23975 return g_variant_is_object_path(string_);
23979 // VERSION: 2.24
23980 // MOVED TO: Variant.is_signature
23981 // Determines if a given string is a valid D-Bus type signature. You
23982 // should ensure that a string is a valid D-Bus type signature before
23983 // passing it to g_variant_new_signature().
23985 // D-Bus type signatures consist of zero or more definite #GVariantType
23986 // strings in sequence.
23987 // RETURNS: %TRUE if @string is a D-Bus type signature
23988 // <string>: a normal C nul-terminated string
23989 static int variant_is_signature()(char* string_) {
23990 return g_variant_is_signature(string_);
23994 // MOVED TO: Variant.parse
23995 // Parses a #GVariant from a text representation.
23997 // A single #GVariant is parsed from the content of @text.
23999 // The format is described <link linkend='gvariant-text'>here</link>.
24001 // The memory at @limit will never be accessed and the parser behaves as
24002 // if the character at @limit is the nul terminator. This has the
24003 // effect of bounding @text.
24005 // If @endptr is non-%NULL then @text is permitted to contain data
24006 // following the value that this function parses and @endptr will be
24007 // updated to point to the first character past the end of the text
24008 // parsed by this function. If @endptr is %NULL and there is extra data
24009 // then an error is returned.
24011 // If @type is non-%NULL then the value will be parsed to have that
24012 // type. This may result in additional parse errors (in the case that
24013 // the parsed value doesn't fit the type) but may also result in fewer
24014 // errors (in the case that the type would have been ambiguous, such as
24015 // with empty arrays).
24017 // In the event that the parsing is successful, the resulting #GVariant
24018 // is returned.
24020 // In case of any error, %NULL will be returned. If @error is non-%NULL
24021 // then it will be set to reflect the error that occurred.
24023 // Officially, the language understood by the parser is "any string
24024 // produced by g_variant_print()".
24025 // <type>: a #GVariantType, or %NULL
24026 // <text>: a string containing a GVariant in text form
24027 // <limit>: a pointer to the end of @text, or %NULL
24028 // <endptr>: a location to store the end pointer, or %NULL
24029 static Variant* /*new*/ variant_parse()(VariantType* type, char* text, char* limit, char** endptr, GLib2.Error** error=null) {
24030 return g_variant_parse(type, text, limit, endptr, error);
24033 // MOVED TO: Variant.parser_get_error_quark
24034 static Quark variant_parser_get_error_quark()() {
24035 return g_variant_parser_get_error_quark();
24038 // MOVED TO: VariantType.checked_
24039 static VariantType* variant_type_checked_()(char* arg_a) {
24040 return g_variant_type_checked_(arg_a);
24044 // MOVED TO: VariantType.string_is_valid
24045 // Checks if @type_string is a valid GVariant type string. This call is
24046 // equivalent to calling g_variant_type_string_scan() and confirming
24047 // that the following character is a nul terminator.
24050 // Since 2.24
24051 // RETURNS: %TRUE if @type_string is exactly one valid type string
24052 // <type_string>: a pointer to any string
24053 static int variant_type_string_is_valid()(char* type_string) {
24054 return g_variant_type_string_is_valid(type_string);
24058 // VERSION: 2.24
24059 // MOVED TO: VariantType.string_scan
24060 // Scan for a single complete and valid GVariant type string in @string.
24061 // The memory pointed to by @limit (or bytes beyond it) is never
24062 // accessed.
24064 // If a valid type string is found, @endptr is updated to point to the
24065 // first character past the end of the string that was found and %TRUE
24066 // is returned.
24068 // If there is no valid type string starting at @string, or if the type
24069 // string does not end before @limit then %FALSE is returned.
24071 // For the simple case of checking if a string is a valid type string,
24072 // see g_variant_type_string_is_valid().
24073 // RETURNS: %TRUE if a valid type string was found
24074 // <string>: a pointer to any string
24075 // <limit>: the end of @string, or %NULL
24076 // <endptr>: location to store the end pointer, or %NULL
24077 static int variant_type_string_scan()(char* string_, char* limit=null, /*out*/ char** endptr=null) {
24078 return g_variant_type_string_scan(string_, limit, endptr);
24082 // Unintrospectable function: vasprintf() / g_vasprintf()
24083 // VERSION: 2.4
24084 // An implementation of the GNU vasprintf() function which supports
24085 // positional parameters, as specified in the Single Unix Specification.
24086 // This function is similar to g_vsprintf(), except that it allocates a
24087 // string to hold the output, instead of putting the output in a buffer
24088 // you allocate in advance.
24089 // RETURNS: the number of bytes printed.
24090 // <string>: the return location for the newly-allocated string.
24091 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
24092 // <args>: the list of arguments to insert in the output.
24093 static int vasprintf()(char** string_, char* format, va_list args) {
24094 return g_vasprintf(string_, format, args);
24098 // Unintrospectable function: vfprintf() / g_vfprintf()
24099 // VERSION: 2.2
24100 // An implementation of the standard fprintf() function which supports
24101 // positional parameters, as specified in the Single Unix Specification.
24102 // RETURNS: the number of bytes printed.
24103 // <file>: the stream to write to.
24104 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
24105 // <args>: the list of arguments to insert in the output.
24106 static int vfprintf()(FILE* file, char* format, va_list args) {
24107 return g_vfprintf(file, format, args);
24111 // Unintrospectable function: vprintf() / g_vprintf()
24112 // VERSION: 2.2
24113 // An implementation of the standard vprintf() function which supports
24114 // positional parameters, as specified in the Single Unix Specification.
24115 // RETURNS: the number of bytes printed.
24116 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
24117 // <args>: the list of arguments to insert in the output.
24118 static int vprintf()(char* format, va_list args) {
24119 return g_vprintf(format, args);
24123 // Unintrospectable function: vsnprintf() / g_vsnprintf()
24124 // A safer form of the standard vsprintf() function. The output is guaranteed
24125 // to not exceed @n characters (including the terminating nul character), so
24126 // it is easy to ensure that a buffer overflow cannot occur.
24128 // See also g_strdup_vprintf().
24130 // In versions of GLib prior to 1.2.3, this function may return -1 if the
24131 // output was truncated, and the truncated string may not be nul-terminated.
24132 // In versions prior to 1.3.12, this function returns the length of the output
24133 // string.
24135 // The return value of g_vsnprintf() conforms to the vsnprintf() function
24136 // as standardized in ISO C99. Note that this is different from traditional
24137 // vsnprintf(), which returns the length of the output string.
24139 // The format string may contain positional parameters, as specified in
24140 // the Single Unix Specification.
24142 // was large enough.
24143 // RETURNS: the number of bytes which would be produced if the buffer
24144 // <string>: the buffer to hold the output.
24145 // <n>: the maximum number of bytes to produce (including the terminating nul character).
24146 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
24147 // <args>: the list of arguments to insert in the output.
24148 static int vsnprintf()(char* string_, c_ulong n, char* format, va_list args) {
24149 return g_vsnprintf(string_, n, format, args);
24153 // Unintrospectable function: vsprintf() / g_vsprintf()
24154 // VERSION: 2.2
24155 // An implementation of the standard vsprintf() function which supports
24156 // positional parameters, as specified in the Single Unix Specification.
24157 // RETURNS: the number of bytes printed.
24158 // <string>: the buffer to hold the output.
24159 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
24160 // <args>: the list of arguments to insert in the output.
24161 static int vsprintf()(char* string_, char* format, va_list args) {
24162 return g_vsprintf(string_, format, args);
24165 static void warn_message()(char* domain, char* file, int line, char* func, char* warnexpr) {
24166 g_warn_message(domain, file, line, func, warnexpr);
24170 // C prototypes:
24172 extern (C) {
24173 Array* g_array_append_vals(Array* array, const(void)* data, uint len);
24174 char* /*new*/ g_array_free(Array* array, int free_segment);
24175 uint g_array_get_element_size(Array* array);
24176 Array* g_array_insert_vals(Array* array, uint index_, const(void)* data, uint len);
24177 Array* g_array_new(int zero_terminated, int clear_, uint element_size);
24178 Array* g_array_prepend_vals(Array* array, const(void)* data, uint len);
24179 Array* g_array_ref(Array* array);
24180 Array* g_array_remove_index(Array* array, uint index_);
24181 Array* g_array_remove_index_fast(Array* array, uint index_);
24182 Array* g_array_remove_range(Array* array, uint index_, uint length);
24183 void g_array_set_clear_func(Array* array, DestroyNotify clear_func);
24184 Array* g_array_set_size(Array* array, uint length);
24185 Array* g_array_sized_new(int zero_terminated, int clear_, uint element_size, uint reserved_size);
24186 void g_array_sort(Array* array, CompareFunc compare_func);
24187 void g_array_sort_with_data(Array* array, CompareDataFunc compare_func, void* user_data);
24188 void g_array_unref(Array* array);
24189 int g_async_queue_length(AsyncQueue* this_);
24190 int g_async_queue_length_unlocked(AsyncQueue* this_);
24191 void g_async_queue_lock(AsyncQueue* this_);
24192 void* g_async_queue_pop(AsyncQueue* this_);
24193 void* g_async_queue_pop_unlocked(AsyncQueue* this_);
24194 void g_async_queue_push(AsyncQueue* this_, void* data);
24195 void g_async_queue_push_sorted(AsyncQueue* this_, void* data, CompareDataFunc func, void* user_data);
24196 void g_async_queue_push_sorted_unlocked(AsyncQueue* this_, void* data, CompareDataFunc func, void* user_data);
24197 void g_async_queue_push_unlocked(AsyncQueue* this_, void* data);
24198 AsyncQueue* g_async_queue_ref(AsyncQueue* this_);
24199 void g_async_queue_ref_unlocked(AsyncQueue* this_);
24200 void g_async_queue_sort(AsyncQueue* this_, CompareDataFunc func, void* user_data);
24201 void g_async_queue_sort_unlocked(AsyncQueue* this_, CompareDataFunc func, void* user_data);
24202 void* g_async_queue_timed_pop(AsyncQueue* this_, TimeVal* end_time);
24203 void* g_async_queue_timed_pop_unlocked(AsyncQueue* this_, TimeVal* end_time);
24204 void* g_async_queue_try_pop(AsyncQueue* this_);
24205 void* g_async_queue_try_pop_unlocked(AsyncQueue* this_);
24206 void g_async_queue_unlock(AsyncQueue* this_);
24207 void g_async_queue_unref(AsyncQueue* this_);
24208 void g_async_queue_unref_and_unlock(AsyncQueue* this_);
24209 AsyncQueue* g_async_queue_new();
24210 AsyncQueue* g_async_queue_new_full(DestroyNotify item_free_func);
24211 void g_bookmark_file_add_application(BookmarkFile* this_, char* uri, char* name, char* exec);
24212 void g_bookmark_file_add_group(BookmarkFile* this_, char* uri, char* group);
24213 void g_bookmark_file_free(BookmarkFile* this_);
24214 time_t g_bookmark_file_get_added(BookmarkFile* this_, char* uri, GLib2.Error** error);
24215 int g_bookmark_file_get_app_info(BookmarkFile* this_, char* uri, char* name, char** exec, uint* count, time_t* stamp, GLib2.Error** error);
24216 char** g_bookmark_file_get_applications(BookmarkFile* this_, char* uri, size_t* length, GLib2.Error** error);
24217 char* /*new*/ g_bookmark_file_get_description(BookmarkFile* this_, char* uri, GLib2.Error** error);
24218 char** g_bookmark_file_get_groups(BookmarkFile* this_, char* uri, size_t* length, GLib2.Error** error);
24219 int g_bookmark_file_get_icon(BookmarkFile* this_, char* uri, char** href, char** mime_type, GLib2.Error** error);
24220 int g_bookmark_file_get_is_private(BookmarkFile* this_, char* uri, GLib2.Error** error);
24221 char* /*new*/ g_bookmark_file_get_mime_type(BookmarkFile* this_, char* uri, GLib2.Error** error);
24222 time_t g_bookmark_file_get_modified(BookmarkFile* this_, char* uri, GLib2.Error** error);
24223 int g_bookmark_file_get_size(BookmarkFile* this_);
24224 char* /*new*/ g_bookmark_file_get_title(BookmarkFile* this_, char* uri, GLib2.Error** error);
24225 char** g_bookmark_file_get_uris(BookmarkFile* this_, size_t* length);
24226 time_t g_bookmark_file_get_visited(BookmarkFile* this_, char* uri, GLib2.Error** error);
24227 int g_bookmark_file_has_application(BookmarkFile* this_, char* uri, char* name, GLib2.Error** error);
24228 int g_bookmark_file_has_group(BookmarkFile* this_, char* uri, char* group, GLib2.Error** error);
24229 int g_bookmark_file_has_item(BookmarkFile* this_, char* uri);
24230 int g_bookmark_file_load_from_data(BookmarkFile* this_, char* data, size_t length, GLib2.Error** error);
24231 int g_bookmark_file_load_from_data_dirs(BookmarkFile* this_, char* file, char** full_path, GLib2.Error** error);
24232 int g_bookmark_file_load_from_file(BookmarkFile* this_, char* filename, GLib2.Error** error);
24233 int g_bookmark_file_move_item(BookmarkFile* this_, char* old_uri, char* new_uri, GLib2.Error** error);
24234 int g_bookmark_file_remove_application(BookmarkFile* this_, char* uri, char* name, GLib2.Error** error);
24235 int g_bookmark_file_remove_group(BookmarkFile* this_, char* uri, char* group, GLib2.Error** error);
24236 int g_bookmark_file_remove_item(BookmarkFile* this_, char* uri, GLib2.Error** error);
24237 void g_bookmark_file_set_added(BookmarkFile* this_, char* uri, time_t added);
24238 int g_bookmark_file_set_app_info(BookmarkFile* this_, char* uri, char* name, char* exec, int count, time_t stamp, GLib2.Error** error);
24239 void g_bookmark_file_set_description(BookmarkFile* this_, char* uri, char* description);
24240 void g_bookmark_file_set_groups(BookmarkFile* this_, char* uri, char** groups, size_t length);
24241 void g_bookmark_file_set_icon(BookmarkFile* this_, char* uri, char* href, char* mime_type);
24242 void g_bookmark_file_set_is_private(BookmarkFile* this_, char* uri, int is_private);
24243 void g_bookmark_file_set_mime_type(BookmarkFile* this_, char* uri, char* mime_type);
24244 void g_bookmark_file_set_modified(BookmarkFile* this_, char* uri, time_t modified);
24245 void g_bookmark_file_set_title(BookmarkFile* this_, char* uri, char* title);
24246 void g_bookmark_file_set_visited(BookmarkFile* this_, char* uri, time_t visited);
24247 char* /*new*/ g_bookmark_file_to_data(BookmarkFile* this_, size_t* length, GLib2.Error** error);
24248 int g_bookmark_file_to_file(BookmarkFile* this_, char* filename, GLib2.Error** error);
24249 Quark g_bookmark_file_error_quark();
24250 BookmarkFile* g_bookmark_file_new();
24251 ByteArray* g_byte_array_append(ByteArray* array, ubyte* data, uint len);
24252 ubyte* g_byte_array_free(ByteArray* array, int free_segment);
24253 Bytes* /*new*/ g_byte_array_free_to_bytes(ByteArray* array);
24254 ByteArray* g_byte_array_new();
24255 ByteArray* /*new*/ g_byte_array_new_take(ubyte* data, size_t len);
24256 ByteArray* g_byte_array_prepend(ByteArray* array, ubyte* data, uint len);
24257 ByteArray* g_byte_array_ref(ByteArray* array);
24258 ByteArray* g_byte_array_remove_index(ByteArray* array, uint index_);
24259 ByteArray* g_byte_array_remove_index_fast(ByteArray* array, uint index_);
24260 ByteArray* g_byte_array_remove_range(ByteArray* array, uint index_, uint length);
24261 ByteArray* g_byte_array_set_size(ByteArray* array, uint length);
24262 ByteArray* g_byte_array_sized_new(uint reserved_size);
24263 void g_byte_array_sort(ByteArray* array, CompareFunc compare_func);
24264 void g_byte_array_sort_with_data(ByteArray* array, CompareDataFunc compare_func, void* user_data);
24265 void g_byte_array_unref(ByteArray* array);
24266 Bytes* /*new*/ g_bytes_new(const(void)* data, size_t size);
24267 Bytes* /*new*/ g_bytes_new_static(const(void)* data, size_t size);
24268 Bytes* /*new*/ g_bytes_new_take(void* data, size_t size);
24269 Bytes* /*new*/ g_bytes_new_with_free_func(const(void)* data, size_t size, DestroyNotify free_func, void* user_data);
24270 int g_bytes_compare(Bytes* this_, const(Bytes)* bytes2);
24271 int g_bytes_equal(Bytes* this_, const(Bytes)* bytes2);
24272 const(ubyte)* g_bytes_get_data(Bytes* this_, /*out*/ size_t* size=null);
24273 size_t g_bytes_get_size(Bytes* this_);
24274 uint g_bytes_hash(Bytes* this_);
24275 Bytes* /*new*/ g_bytes_new_from_bytes(Bytes* this_, size_t offset, size_t length);
24276 Bytes* /*new*/ g_bytes_ref(Bytes* this_);
24277 void g_bytes_unref(Bytes* this_);
24278 ByteArray* /*new*/ g_bytes_unref_to_array(Bytes* this_);
24279 void* /*new*/ g_bytes_unref_to_data(Bytes* this_, size_t* size);
24280 Checksum* g_checksum_copy(Checksum* this_);
24281 void g_checksum_free(Checksum* this_);
24282 void g_checksum_get_digest(Checksum* this_, ubyte* buffer, size_t* digest_len);
24283 char* g_checksum_get_string(Checksum* this_);
24284 void g_checksum_reset(Checksum* this_);
24285 void g_checksum_update(Checksum* this_, ubyte* data, ssize_t length);
24286 Checksum* g_checksum_new(ChecksumType checksum_type);
24287 ssize_t g_checksum_type_get_length(ChecksumType checksum_type);
24288 void g_cond_broadcast(Cond* this_);
24289 void g_cond_clear(Cond* this_);
24290 void g_cond_init(Cond* this_);
24291 void g_cond_signal(Cond* this_);
24292 void g_cond_wait(Cond* this_, Mutex* mutex);
24293 int g_cond_wait_until(Cond* this_, Mutex* mutex, long end_time);
24294 Date* /*new*/ g_date_new();
24295 Date* /*new*/ g_date_new_dmy(DateDay day, DateMonth month, DateYear year);
24296 Date* /*new*/ g_date_new_julian(uint julian_day);
24297 void g_date_add_days(Date* this_, uint n_days);
24298 void g_date_add_months(Date* this_, uint n_months);
24299 void g_date_add_years(Date* this_, uint n_years);
24300 void g_date_clamp(Date* this_, Date* min_date, Date* max_date);
24301 void g_date_clear(Date* this_, uint n_dates);
24302 int g_date_compare(Date* this_, Date* rhs);
24303 int g_date_days_between(Date* this_, Date* date2);
24304 void g_date_free(Date* this_);
24305 DateDay g_date_get_day(Date* this_);
24306 uint g_date_get_day_of_year(Date* this_);
24307 uint g_date_get_iso8601_week_of_year(Date* this_);
24308 uint g_date_get_julian(Date* this_);
24309 uint g_date_get_monday_week_of_year(Date* this_);
24310 DateMonth g_date_get_month(Date* this_);
24311 uint g_date_get_sunday_week_of_year(Date* this_);
24312 DateWeekday g_date_get_weekday(Date* this_);
24313 DateYear g_date_get_year(Date* this_);
24314 int g_date_is_first_of_month(Date* this_);
24315 int g_date_is_last_of_month(Date* this_);
24316 void g_date_order(Date* this_, Date* date2);
24317 void g_date_set_day(Date* this_, DateDay day);
24318 void g_date_set_dmy(Date* this_, DateDay day, DateMonth month, DateYear y);
24319 void g_date_set_julian(Date* this_, uint julian_date);
24320 void g_date_set_month(Date* this_, DateMonth month);
24321 void g_date_set_parse(Date* this_, char* str);
24322 void g_date_set_time(Date* this_, Time time_);
24323 void g_date_set_time_t(Date* this_, time_t timet);
24324 void g_date_set_time_val(Date* this_, TimeVal* timeval);
24325 void g_date_set_year(Date* this_, DateYear year);
24326 void g_date_subtract_days(Date* this_, uint n_days);
24327 void g_date_subtract_months(Date* this_, uint n_months);
24328 void g_date_subtract_years(Date* this_, uint n_years);
24329 void g_date_to_struct_tm(Date* this_, void** tm);
24330 int g_date_valid(Date* this_);
24331 ubyte g_date_get_days_in_month(DateMonth month, DateYear year);
24332 ubyte g_date_get_monday_weeks_in_year(DateYear year);
24333 ubyte g_date_get_sunday_weeks_in_year(DateYear year);
24334 int g_date_is_leap_year(DateYear year);
24335 size_t g_date_strftime(char* s, size_t slen, char* format, Date* date);
24336 int g_date_valid_day(DateDay day);
24337 int g_date_valid_dmy(DateDay day, DateMonth month, DateYear year);
24338 int g_date_valid_julian(uint julian_date);
24339 int g_date_valid_month(DateMonth month);
24340 int g_date_valid_weekday(DateWeekday weekday);
24341 int g_date_valid_year(DateYear year);
24342 DateTime* /*new*/ g_date_time_new(TimeZone* tz, int year, int month, int day, int hour, int minute, double seconds);
24343 DateTime* /*new*/ g_date_time_new_from_timeval_local(TimeVal* tv);
24344 DateTime* /*new*/ g_date_time_new_from_timeval_utc(TimeVal* tv);
24345 DateTime* /*new*/ g_date_time_new_from_unix_local(long t);
24346 DateTime* /*new*/ g_date_time_new_from_unix_utc(long t);
24347 DateTime* /*new*/ g_date_time_new_local(int year, int month, int day, int hour, int minute, double seconds);
24348 DateTime* /*new*/ g_date_time_new_now(TimeZone* tz);
24349 DateTime* /*new*/ g_date_time_new_now_local();
24350 DateTime* /*new*/ g_date_time_new_now_utc();
24351 DateTime* /*new*/ g_date_time_new_utc(int year, int month, int day, int hour, int minute, double seconds);
24352 DateTime* /*new*/ g_date_time_add(DateTime* this_, TimeSpan timespan);
24353 DateTime* /*new*/ g_date_time_add_days(DateTime* this_, int days);
24354 DateTime* /*new*/ g_date_time_add_full(DateTime* this_, int years, int months, int days, int hours, int minutes, double seconds);
24355 DateTime* /*new*/ g_date_time_add_hours(DateTime* this_, int hours);
24356 DateTime* /*new*/ g_date_time_add_minutes(DateTime* this_, int minutes);
24357 DateTime* /*new*/ g_date_time_add_months(DateTime* this_, int months);
24358 DateTime* /*new*/ g_date_time_add_seconds(DateTime* this_, double seconds);
24359 DateTime* /*new*/ g_date_time_add_weeks(DateTime* this_, int weeks);
24360 DateTime* /*new*/ g_date_time_add_years(DateTime* this_, int years);
24361 TimeSpan g_date_time_difference(DateTime* this_, DateTime* begin);
24362 char* /*new*/ g_date_time_format(DateTime* this_, char* format);
24363 int g_date_time_get_day_of_month(DateTime* this_);
24364 int g_date_time_get_day_of_week(DateTime* this_);
24365 int g_date_time_get_day_of_year(DateTime* this_);
24366 int g_date_time_get_hour(DateTime* this_);
24367 int g_date_time_get_microsecond(DateTime* this_);
24368 int g_date_time_get_minute(DateTime* this_);
24369 int g_date_time_get_month(DateTime* this_);
24370 int g_date_time_get_second(DateTime* this_);
24371 double g_date_time_get_seconds(DateTime* this_);
24372 char* g_date_time_get_timezone_abbreviation(DateTime* this_);
24373 TimeSpan g_date_time_get_utc_offset(DateTime* this_);
24374 int g_date_time_get_week_numbering_year(DateTime* this_);
24375 int g_date_time_get_week_of_year(DateTime* this_);
24376 int g_date_time_get_year(DateTime* this_);
24377 void g_date_time_get_ymd(DateTime* this_, /*out*/ int* year, /*out*/ int* month, /*out*/ int* day);
24378 int g_date_time_is_daylight_savings(DateTime* this_);
24379 DateTime* /*new*/ g_date_time_ref(DateTime* this_);
24380 DateTime* /*new*/ g_date_time_to_local(DateTime* this_);
24381 int g_date_time_to_timeval(DateTime* this_, TimeVal* tv);
24382 DateTime* /*new*/ g_date_time_to_timezone(DateTime* this_, TimeZone* tz);
24383 long g_date_time_to_unix(DateTime* this_);
24384 DateTime* /*new*/ g_date_time_to_utc(DateTime* this_);
24385 void g_date_time_unref(DateTime* this_);
24386 int g_date_time_compare(const(void)* dt1, const(void)* dt2);
24387 int g_date_time_equal(const(void)* dt1, const(void)* dt2);
24388 uint g_date_time_hash(const(void)* datetime);
24389 void g_dir_close(Dir* this_);
24390 char* g_dir_read_name(Dir* this_);
24391 void g_dir_rewind(Dir* this_);
24392 char* /*new*/ g_dir_make_tmp(char* tmpl, GLib2.Error** error);
24393 Dir* g_dir_open(char* path, uint flags, GLib2.Error** error);
24394 Error* /*new*/ g_error_new(Quark domain, int code, char* format, ...);
24395 Error* /*new*/ g_error_new_literal(Quark domain, int code, char* message);
24396 Error* /*new*/ g_error_new_valist(Quark domain, int code, char* format, va_list args);
24397 Error* /*new*/ g_error_copy(Error* this_);
24398 void g_error_free(Error* this_);
24399 int g_error_matches(Error* this_, Quark domain, int code);
24400 void g_hash_table_add(GLib2.HashTable* hash_table, void* key);
24401 int g_hash_table_contains(GLib2.HashTable* hash_table, const(void)* lookup_key);
24402 void g_hash_table_destroy(GLib2.HashTable* hash_table);
24403 void* g_hash_table_find(GLib2.HashTable* hash_table, HRFunc predicate, void* user_data);
24404 void g_hash_table_foreach(GLib2.HashTable* hash_table, HFunc func, void* user_data);
24405 uint g_hash_table_foreach_remove(GLib2.HashTable* hash_table, HRFunc func, void* user_data);
24406 uint g_hash_table_foreach_steal(GLib2.HashTable* hash_table, HRFunc func, void* user_data);
24407 GLib2.List* g_hash_table_get_keys(GLib2.HashTable* hash_table);
24408 GLib2.List* g_hash_table_get_values(GLib2.HashTable* hash_table);
24409 void g_hash_table_insert(GLib2.HashTable* hash_table, void* key, void* value);
24410 void* g_hash_table_lookup(GLib2.HashTable* hash_table, const(void)* key);
24411 int g_hash_table_lookup_extended(GLib2.HashTable* hash_table, const(void)* lookup_key, void** orig_key=null, void** value=null);
24412 GLib2.HashTable* g_hash_table_new(HashFunc hash_func, EqualFunc key_equal_func);
24413 GLib2.HashTable* g_hash_table_new_full(HashFunc hash_func, EqualFunc key_equal_func, DestroyNotify key_destroy_func, DestroyNotify value_destroy_func);
24414 GLib2.HashTable* g_hash_table_ref(GLib2.HashTable* hash_table);
24415 int g_hash_table_remove(GLib2.HashTable* hash_table, const(void)* key);
24416 void g_hash_table_remove_all(GLib2.HashTable* hash_table);
24417 void g_hash_table_replace(GLib2.HashTable* hash_table, void* key, void* value);
24418 uint g_hash_table_size(GLib2.HashTable* hash_table);
24419 int g_hash_table_steal(GLib2.HashTable* hash_table, const(void)* key);
24420 void g_hash_table_steal_all(GLib2.HashTable* hash_table);
24421 void g_hash_table_unref(GLib2.HashTable* hash_table);
24422 GLib2.HashTable* g_hash_table_iter_get_hash_table(HashTableIter* this_);
24423 void g_hash_table_iter_init(HashTableIter* this_, GLib2.HashTable* hash_table);
24424 int g_hash_table_iter_next(HashTableIter* this_, void** key, void** value);
24425 void g_hash_table_iter_remove(HashTableIter* this_);
24426 void g_hash_table_iter_replace(HashTableIter* this_, void* value);
24427 void g_hash_table_iter_steal(HashTableIter* this_);
24428 Hmac* g_hmac_copy(Hmac* this_);
24429 void g_hmac_get_digest(Hmac* this_, ubyte* buffer, size_t* digest_len);
24430 char* g_hmac_get_string(Hmac* this_);
24431 Hmac* g_hmac_ref(Hmac* this_);
24432 void g_hmac_unref(Hmac* this_);
24433 void g_hmac_update(Hmac* this_, ubyte* data, ssize_t length);
24434 Hmac* g_hmac_new(ChecksumType digest_type, ubyte* key, size_t key_len);
24435 int g_hook_compare_ids(Hook* this_, Hook* sibling);
24436 Hook* g_hook_alloc(HookList* hook_list);
24437 int g_hook_destroy(HookList* hook_list, c_ulong hook_id);
24438 void g_hook_destroy_link(HookList* hook_list, Hook* hook);
24439 Hook* g_hook_find(HookList* hook_list, int need_valids, HookFindFunc func, void* data);
24440 Hook* g_hook_find_data(HookList* hook_list, int need_valids, void* data);
24441 Hook* g_hook_find_func(HookList* hook_list, int need_valids, void* func);
24442 Hook* g_hook_find_func_data(HookList* hook_list, int need_valids, void* func, void* data);
24443 Hook* g_hook_first_valid(HookList* hook_list, int may_be_in_call);
24444 void g_hook_free(HookList* hook_list, Hook* hook);
24445 Hook* g_hook_get(HookList* hook_list, c_ulong hook_id);
24446 void g_hook_insert_before(HookList* hook_list, Hook* sibling, Hook* hook);
24447 void g_hook_insert_sorted(HookList* hook_list, Hook* hook, HookCompareFunc func);
24448 Hook* g_hook_next_valid(HookList* hook_list, Hook* hook, int may_be_in_call);
24449 void g_hook_prepend(HookList* hook_list, Hook* hook);
24450 Hook* g_hook_ref(HookList* hook_list, Hook* hook);
24451 void g_hook_unref(HookList* hook_list, Hook* hook);
24452 void g_hook_list_clear(HookList* this_);
24453 void g_hook_list_init(HookList* this_, uint hook_size);
24454 void g_hook_list_invoke(HookList* this_, int may_recurse);
24455 void g_hook_list_invoke_check(HookList* this_, int may_recurse);
24456 void g_hook_list_marshal(HookList* this_, int may_recurse, HookMarshaller marshaller, void* marshal_data);
24457 void g_hook_list_marshal_check(HookList* this_, int may_recurse, HookCheckMarshaller marshaller, void* marshal_data);
24458 size_t g_iconv(IConv* this_, char** inbuf, size_t* inbytes_left, char** outbuf, size_t* outbytes_left);
24459 int g_iconv_close(IConv* this_);
24460 IConv g_iconv_open(char* to_codeset, char* from_codeset);
24461 IOChannel* /*new*/ g_io_channel_new_file(char* filename, char* mode, GLib2.Error** error);
24462 IOChannel* /*new*/ g_io_channel_unix_new(int fd);
24463 void g_io_channel_close(IOChannel* this_);
24464 IOStatus g_io_channel_flush(IOChannel* this_, GLib2.Error** error);
24465 IOCondition g_io_channel_get_buffer_condition(IOChannel* this_);
24466 size_t g_io_channel_get_buffer_size(IOChannel* this_);
24467 int g_io_channel_get_buffered(IOChannel* this_);
24468 int g_io_channel_get_close_on_unref(IOChannel* this_);
24469 char* g_io_channel_get_encoding(IOChannel* this_);
24470 IOFlags g_io_channel_get_flags(IOChannel* this_);
24471 char* g_io_channel_get_line_term(IOChannel* this_, int* length);
24472 void g_io_channel_init(IOChannel* this_);
24473 IOError g_io_channel_read(IOChannel* this_, char* buf, size_t count, size_t* bytes_read);
24474 IOStatus g_io_channel_read_chars(IOChannel* this_, char* buf, size_t count, size_t* bytes_read, GLib2.Error** error);
24475 IOStatus g_io_channel_read_line(IOChannel* this_, char** str_return, size_t* length, size_t* terminator_pos, GLib2.Error** error);
24476 IOStatus g_io_channel_read_line_string(IOChannel* this_, String* buffer, size_t* terminator_pos, GLib2.Error** error);
24477 IOStatus g_io_channel_read_to_end(IOChannel* this_, char** str_return, size_t* length, GLib2.Error** error);
24478 IOStatus g_io_channel_read_unichar(IOChannel* this_, dchar* thechar, GLib2.Error** error);
24479 IOChannel* /*new*/ g_io_channel_ref(IOChannel* this_);
24480 IOError g_io_channel_seek(IOChannel* this_, long offset, SeekType type);
24481 IOStatus g_io_channel_seek_position(IOChannel* this_, long offset, SeekType type, GLib2.Error** error);
24482 void g_io_channel_set_buffer_size(IOChannel* this_, size_t size);
24483 void g_io_channel_set_buffered(IOChannel* this_, int buffered);
24484 void g_io_channel_set_close_on_unref(IOChannel* this_, int do_close);
24485 IOStatus g_io_channel_set_encoding(IOChannel* this_, char* encoding, GLib2.Error** error);
24486 IOStatus g_io_channel_set_flags(IOChannel* this_, IOFlags flags, GLib2.Error** error);
24487 void g_io_channel_set_line_term(IOChannel* this_, char* line_term, int length);
24488 IOStatus g_io_channel_shutdown(IOChannel* this_, int flush, GLib2.Error** error);
24489 int g_io_channel_unix_get_fd(IOChannel* this_);
24490 void g_io_channel_unref(IOChannel* this_);
24491 IOError g_io_channel_write(IOChannel* this_, char* buf, size_t count, size_t* bytes_written);
24492 IOStatus g_io_channel_write_chars(IOChannel* this_, char* buf, ssize_t count, size_t* bytes_written, GLib2.Error** error);
24493 IOStatus g_io_channel_write_unichar(IOChannel* this_, dchar thechar, GLib2.Error** error);
24494 IOChannelError g_io_channel_error_from_errno(int en);
24495 Quark g_io_channel_error_quark();
24496 KeyFile* /*new*/ g_key_file_new();
24497 void g_key_file_free(KeyFile* this_);
24498 int g_key_file_get_boolean(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
24499 int* /*new container*/ g_key_file_get_boolean_list(KeyFile* this_, char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error);
24500 char* /*new*/ g_key_file_get_comment(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
24501 double g_key_file_get_double(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
24502 double* /*new container*/ g_key_file_get_double_list(KeyFile* this_, char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error);
24503 char** /*new*/ g_key_file_get_groups(KeyFile* this_, /*out*/ size_t* length=null);
24504 long g_key_file_get_int64(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
24505 int g_key_file_get_integer(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
24506 int* /*new container*/ g_key_file_get_integer_list(KeyFile* this_, char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error);
24507 char** /*new*/ g_key_file_get_keys(KeyFile* this_, char* group_name, /*out*/ size_t* length, GLib2.Error** error);
24508 char* /*new*/ g_key_file_get_locale_string(KeyFile* this_, char* group_name, char* key, char* locale, GLib2.Error** error);
24509 char** /*new*/ g_key_file_get_locale_string_list(KeyFile* this_, char* group_name, char* key, char* locale, /*out*/ size_t* length, GLib2.Error** error);
24510 char* /*new*/ g_key_file_get_start_group(KeyFile* this_);
24511 char* /*new*/ g_key_file_get_string(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
24512 char** /*new*/ g_key_file_get_string_list(KeyFile* this_, char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error);
24513 ulong g_key_file_get_uint64(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
24514 char* /*new*/ g_key_file_get_value(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
24515 int g_key_file_has_group(KeyFile* this_, char* group_name);
24516 int g_key_file_has_key(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
24517 int g_key_file_load_from_data(KeyFile* this_, char* data, size_t length, KeyFileFlags flags, GLib2.Error** error);
24518 int g_key_file_load_from_data_dirs(KeyFile* this_, char* file, /*out*/ char** full_path, KeyFileFlags flags, GLib2.Error** error);
24519 int g_key_file_load_from_dirs(KeyFile* this_, char* file, char** search_dirs, /*out*/ char** full_path, KeyFileFlags flags, GLib2.Error** error);
24520 int g_key_file_load_from_file(KeyFile* this_, char* file, KeyFileFlags flags, GLib2.Error** error);
24521 KeyFile* /*new*/ g_key_file_ref(KeyFile* this_);
24522 int g_key_file_remove_comment(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
24523 int g_key_file_remove_group(KeyFile* this_, char* group_name, GLib2.Error** error);
24524 int g_key_file_remove_key(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
24525 void g_key_file_set_boolean(KeyFile* this_, char* group_name, char* key, int value);
24526 void g_key_file_set_boolean_list(KeyFile* this_, char* group_name, char* key, int list, size_t length);
24527 int g_key_file_set_comment(KeyFile* this_, char* group_name, char* key, char* comment, GLib2.Error** error);
24528 void g_key_file_set_double(KeyFile* this_, char* group_name, char* key, double value);
24529 void g_key_file_set_double_list(KeyFile* this_, char* group_name, char* key, double list, size_t length);
24530 void g_key_file_set_int64(KeyFile* this_, char* group_name, char* key, long value);
24531 void g_key_file_set_integer(KeyFile* this_, char* group_name, char* key, int value);
24532 void g_key_file_set_integer_list(KeyFile* this_, char* group_name, char* key, int list, size_t length);
24533 void g_key_file_set_list_separator(KeyFile* this_, char separator);
24534 void g_key_file_set_locale_string(KeyFile* this_, char* group_name, char* key, char* locale, char* string_);
24535 void g_key_file_set_locale_string_list(KeyFile* this_, char* group_name, char* key, char* locale, char* list, size_t length);
24536 void g_key_file_set_string(KeyFile* this_, char* group_name, char* key, char* string_);
24537 void g_key_file_set_string_list(KeyFile* this_, char* group_name, char* key, char* list, size_t length);
24538 void g_key_file_set_uint64(KeyFile* this_, char* group_name, char* key, ulong value);
24539 void g_key_file_set_value(KeyFile* this_, char* group_name, char* key, char* value);
24540 char* /*new*/ g_key_file_to_data(KeyFile* this_, /*out*/ size_t* length, GLib2.Error** error);
24541 void g_key_file_unref(KeyFile* this_);
24542 Quark g_key_file_error_quark();
24543 GLib2.List* g_list_alloc();
24544 GLib2.List* g_list_append(GLib2.List* list, void* data);
24545 GLib2.List* g_list_concat(GLib2.List* list1, GLib2.List* list2);
24546 GLib2.List* g_list_copy(GLib2.List* list);
24547 GLib2.List* g_list_delete_link(GLib2.List* list, GLib2.List* link_);
24548 GLib2.List* g_list_find(GLib2.List* list, const(void)* data);
24549 GLib2.List* g_list_find_custom(GLib2.List* list, const(void)* data, CompareFunc func);
24550 GLib2.List* g_list_first(GLib2.List* list);
24551 void g_list_foreach(GLib2.List* list, Func func, void* user_data);
24552 void g_list_free(GLib2.List* list);
24553 void g_list_free_1(GLib2.List* list);
24554 void g_list_free_full(GLib2.List* list, DestroyNotify free_func);
24555 int g_list_index(GLib2.List* list, const(void)* data);
24556 GLib2.List* g_list_insert(GLib2.List* list, void* data, int position);
24557 GLib2.List* g_list_insert_before(GLib2.List* list, GLib2.List* sibling, void* data);
24558 GLib2.List* g_list_insert_sorted(GLib2.List* list, void* data, CompareFunc func);
24559 GLib2.List* g_list_insert_sorted_with_data(GLib2.List* list, void* data, CompareDataFunc func, void* user_data);
24560 GLib2.List* g_list_last(GLib2.List* list);
24561 uint g_list_length(GLib2.List* list);
24562 GLib2.List* g_list_nth(GLib2.List* list, uint n);
24563 void* g_list_nth_data(GLib2.List* list, uint n);
24564 GLib2.List* g_list_nth_prev(GLib2.List* list, uint n);
24565 int g_list_position(GLib2.List* list, GLib2.List* llink);
24566 GLib2.List* g_list_prepend(GLib2.List* list, void* data);
24567 GLib2.List* g_list_remove(GLib2.List* list, const(void)* data);
24568 GLib2.List* g_list_remove_all(GLib2.List* list, const(void)* data);
24569 GLib2.List* g_list_remove_link(GLib2.List* list, GLib2.List* llink);
24570 GLib2.List* g_list_reverse(GLib2.List* list);
24571 GLib2.List* g_list_sort(GLib2.List* list, CompareFunc compare_func);
24572 GLib2.List* g_list_sort_with_data(GLib2.List* list, CompareDataFunc compare_func, void* user_data);
24573 MainContext* /*new*/ g_main_context_new();
24574 int g_main_context_acquire(MainContext* this_);
24575 void g_main_context_add_poll(MainContext* this_, PollFD* fd, int priority);
24576 int g_main_context_check(MainContext* this_, int max_priority, PollFD* fds, int n_fds);
24577 void g_main_context_dispatch(MainContext* this_);
24578 Source* g_main_context_find_source_by_funcs_user_data(MainContext* this_, SourceFuncs* funcs, void* user_data);
24579 Source* g_main_context_find_source_by_id(MainContext* this_, uint source_id);
24580 Source* g_main_context_find_source_by_user_data(MainContext* this_, void* user_data);
24581 PollFunc g_main_context_get_poll_func(MainContext* this_);
24582 void g_main_context_invoke(MainContext* this_, SourceFunc function_, void* data);
24583 void g_main_context_invoke_full(MainContext* this_, int priority, SourceFunc function_, void* data, DestroyNotify notify);
24584 int g_main_context_is_owner(MainContext* this_);
24585 int g_main_context_iteration(MainContext* this_, int may_block);
24586 int g_main_context_pending(MainContext* this_);
24587 void g_main_context_pop_thread_default(MainContext* this_);
24588 int g_main_context_prepare(MainContext* this_, int* priority);
24589 void g_main_context_push_thread_default(MainContext* this_);
24590 int g_main_context_query(MainContext* this_, int max_priority, /*out*/ int* timeout_, /*out*/ PollFD* fds, /*out*/ int n_fds);
24591 MainContext* /*new*/ g_main_context_ref(MainContext* this_);
24592 void g_main_context_release(MainContext* this_);
24593 void g_main_context_remove_poll(MainContext* this_, PollFD* fd);
24594 void g_main_context_set_poll_func(MainContext* this_, PollFunc func);
24595 void g_main_context_unref(MainContext* this_);
24596 int g_main_context_wait(MainContext* this_, Cond* cond, Mutex* mutex);
24597 void g_main_context_wakeup(MainContext* this_);
24598 MainContext* g_main_context_default();
24599 MainContext* g_main_context_get_thread_default();
24600 MainContext* /*new*/ g_main_context_ref_thread_default();
24601 MainLoop* /*new*/ g_main_loop_new(MainContext* context, int is_running);
24602 MainContext* g_main_loop_get_context(MainLoop* this_);
24603 int g_main_loop_is_running(MainLoop* this_);
24604 void g_main_loop_quit(MainLoop* this_);
24605 MainLoop* /*new*/ g_main_loop_ref(MainLoop* this_);
24606 void g_main_loop_run(MainLoop* this_);
24607 void g_main_loop_unref(MainLoop* this_);
24608 void g_mapped_file_free(MappedFile* this_);
24609 char* /*new*/ g_mapped_file_get_contents(MappedFile* this_);
24610 size_t g_mapped_file_get_length(MappedFile* this_);
24611 MappedFile* g_mapped_file_ref(MappedFile* this_);
24612 void g_mapped_file_unref(MappedFile* this_);
24613 MappedFile* g_mapped_file_new(char* filename, int writable, GLib2.Error** error);
24614 MappedFile* g_mapped_file_new_from_fd(int fd, int writable, GLib2.Error** error);
24615 int g_markup_parse_context_end_parse(MarkupParseContext* this_, GLib2.Error** error);
24616 void g_markup_parse_context_free(MarkupParseContext* this_);
24617 char* g_markup_parse_context_get_element(MarkupParseContext* this_);
24618 GLib2.SList* g_markup_parse_context_get_element_stack(MarkupParseContext* this_);
24619 void g_markup_parse_context_get_position(MarkupParseContext* this_, int* line_number=null, int* char_number=null);
24620 void* g_markup_parse_context_get_user_data(MarkupParseContext* this_);
24621 int g_markup_parse_context_parse(MarkupParseContext* this_, char* text, ssize_t text_len, GLib2.Error** error);
24622 void* g_markup_parse_context_pop(MarkupParseContext* this_);
24623 void g_markup_parse_context_push(MarkupParseContext* this_, MarkupParser* parser, void* user_data);
24624 MarkupParseContext* g_markup_parse_context_new(MarkupParser* parser, MarkupParseFlags flags, void* user_data, DestroyNotify user_data_dnotify);
24625 char* /*new*/ g_match_info_expand_references(MatchInfo* this_, char* string_to_expand, GLib2.Error** error);
24626 char* /*new*/ g_match_info_fetch(MatchInfo* this_, int match_num);
24627 char** g_match_info_fetch_all(MatchInfo* this_);
24628 char* /*new*/ g_match_info_fetch_named(MatchInfo* this_, char* name);
24629 int g_match_info_fetch_named_pos(MatchInfo* this_, char* name, /*out*/ int* start_pos=null, /*out*/ int* end_pos=null);
24630 int g_match_info_fetch_pos(MatchInfo* this_, int match_num, /*out*/ int* start_pos=null, /*out*/ int* end_pos=null);
24631 void g_match_info_free(MatchInfo* this_);
24632 int g_match_info_get_match_count(MatchInfo* this_);
24633 Regex* /*new*/ g_match_info_get_regex(MatchInfo* this_);
24634 char* g_match_info_get_string(MatchInfo* this_);
24635 int g_match_info_is_partial_match(MatchInfo* this_);
24636 int g_match_info_matches(MatchInfo* this_);
24637 int g_match_info_next(MatchInfo* this_, GLib2.Error** error);
24638 MatchInfo* /*new*/ g_match_info_ref(MatchInfo* this_);
24639 void g_match_info_unref(MatchInfo* this_);
24640 void g_mutex_clear(Mutex* this_);
24641 void g_mutex_init(Mutex* this_);
24642 void g_mutex_lock(Mutex* this_);
24643 int g_mutex_trylock(Mutex* this_);
24644 void g_mutex_unlock(Mutex* this_);
24645 int g_node_child_index(Node* this_, void* data);
24646 int g_node_child_position(Node* this_, Node* child);
24647 void g_node_children_foreach(Node* this_, TraverseFlags flags, NodeForeachFunc func, void* data);
24648 Node* g_node_copy(Node* this_);
24649 Node* g_node_copy_deep(Node* this_, CopyFunc copy_func, void* data);
24650 uint g_node_depth(Node* this_);
24651 void g_node_destroy(Node* this_);
24652 Node* g_node_find(Node* this_, TraverseType order, TraverseFlags flags, void* data);
24653 Node* g_node_find_child(Node* this_, TraverseFlags flags, void* data);
24654 Node* g_node_first_sibling(Node* this_);
24655 Node* g_node_get_root(Node* this_);
24656 Node* g_node_insert(Node* this_, int position, Node* node);
24657 Node* g_node_insert_after(Node* this_, Node* sibling, Node* node);
24658 Node* g_node_insert_before(Node* this_, Node* sibling, Node* node);
24659 int g_node_is_ancestor(Node* this_, Node* descendant);
24660 Node* g_node_last_child(Node* this_);
24661 Node* g_node_last_sibling(Node* this_);
24662 uint g_node_max_height(Node* this_);
24663 uint g_node_n_children(Node* this_);
24664 uint g_node_n_nodes(Node* this_, TraverseFlags flags);
24665 Node* g_node_nth_child(Node* this_, uint n);
24666 Node* g_node_prepend(Node* this_, Node* node);
24667 void g_node_reverse_children(Node* this_);
24668 void g_node_traverse(Node* this_, TraverseType order, TraverseFlags flags, int max_depth, NodeTraverseFunc func, void* data);
24669 void g_node_unlink(Node* this_);
24670 Node* g_node_new(void* data);
24671 void* g_once_impl(Once* this_, ThreadFunc func, void* arg);
24672 int g_once_init_enter(void* location);
24673 void g_once_init_leave(void* location, size_t result);
24674 void g_option_context_add_group(OptionContext* this_, OptionGroup* group);
24675 void g_option_context_add_main_entries(OptionContext* this_, OptionEntry* entries, char* translation_domain);
24676 void g_option_context_free(OptionContext* this_);
24677 char* g_option_context_get_description(OptionContext* this_);
24678 char* /*new*/ g_option_context_get_help(OptionContext* this_, int main_help, OptionGroup* group);
24679 int g_option_context_get_help_enabled(OptionContext* this_);
24680 int g_option_context_get_ignore_unknown_options(OptionContext* this_);
24681 OptionGroup* g_option_context_get_main_group(OptionContext* this_);
24682 char* g_option_context_get_summary(OptionContext* this_);
24683 int g_option_context_parse(OptionContext* this_, /*inout*/ int* argc, /*inout*/ char*** argv, GLib2.Error** error);
24684 void g_option_context_set_description(OptionContext* this_, char* description);
24685 void g_option_context_set_help_enabled(OptionContext* this_, int help_enabled);
24686 void g_option_context_set_ignore_unknown_options(OptionContext* this_, int ignore_unknown);
24687 void g_option_context_set_main_group(OptionContext* this_, OptionGroup* group);
24688 void g_option_context_set_summary(OptionContext* this_, char* summary);
24689 void g_option_context_set_translate_func(OptionContext* this_, TranslateFunc func, void* data, DestroyNotify destroy_notify);
24690 void g_option_context_set_translation_domain(OptionContext* this_, char* domain);
24691 OptionContext* g_option_context_new(char* parameter_string);
24692 void g_option_group_add_entries(OptionGroup* this_, OptionEntry* entries);
24693 void g_option_group_free(OptionGroup* this_);
24694 void g_option_group_set_error_hook(OptionGroup* this_, OptionErrorFunc error_func);
24695 void g_option_group_set_parse_hooks(OptionGroup* this_, OptionParseFunc pre_parse_func, OptionParseFunc post_parse_func);
24696 void g_option_group_set_translate_func(OptionGroup* this_, TranslateFunc func, void* data, DestroyNotify destroy_notify);
24697 void g_option_group_set_translation_domain(OptionGroup* this_, char* domain);
24698 OptionGroup* g_option_group_new(char* name, char* description, char* help_description, void* user_data, DestroyNotify destroy);
24699 int g_pattern_spec_equal(PatternSpec* this_, PatternSpec* pspec2);
24700 void g_pattern_spec_free(PatternSpec* this_);
24701 PatternSpec* g_pattern_spec_new(char* pattern);
24702 void* g_private_get(Private* this_);
24703 void g_private_replace(Private* this_, void* value);
24704 void g_private_set(Private* this_, void* value);
24705 void g_ptr_array_add(PtrArray* array, void* data);
24706 void g_ptr_array_foreach(PtrArray* array, Func func, void* user_data);
24707 void** g_ptr_array_free(PtrArray* array, int free_seg);
24708 PtrArray* g_ptr_array_new();
24709 PtrArray* g_ptr_array_new_full(uint reserved_size, DestroyNotify element_free_func);
24710 PtrArray* g_ptr_array_new_with_free_func(DestroyNotify element_free_func);
24711 PtrArray* g_ptr_array_ref(PtrArray* array);
24712 int g_ptr_array_remove(PtrArray* array, void* data);
24713 int g_ptr_array_remove_fast(PtrArray* array, void* data);
24714 void* g_ptr_array_remove_index(PtrArray* array, uint index_);
24715 void* g_ptr_array_remove_index_fast(PtrArray* array, uint index_);
24716 void g_ptr_array_remove_range(PtrArray* array, uint index_, uint length);
24717 void g_ptr_array_set_free_func(PtrArray* array, DestroyNotify element_free_func);
24718 void g_ptr_array_set_size(PtrArray* array, int length);
24719 PtrArray* g_ptr_array_sized_new(uint reserved_size);
24720 void g_ptr_array_sort(PtrArray* array, CompareFunc compare_func);
24721 void g_ptr_array_sort_with_data(PtrArray* array, CompareDataFunc compare_func, void* user_data);
24722 void g_ptr_array_unref(PtrArray* array);
24723 void g_queue_clear(Queue* this_);
24724 Queue* g_queue_copy(Queue* this_);
24725 void g_queue_delete_link(Queue* this_, GLib2.List* link_);
24726 GLib2.List* g_queue_find(Queue* this_, const(void)* data);
24727 GLib2.List* g_queue_find_custom(Queue* this_, const(void)* data, CompareFunc func);
24728 void g_queue_foreach(Queue* this_, Func func, void* user_data);
24729 void g_queue_free(Queue* this_);
24730 void g_queue_free_full(Queue* this_, DestroyNotify free_func);
24731 uint g_queue_get_length(Queue* this_);
24732 int g_queue_index(Queue* this_, const(void)* data);
24733 void g_queue_init(Queue* this_);
24734 void g_queue_insert_after(Queue* this_, GLib2.List* sibling, void* data);
24735 void g_queue_insert_before(Queue* this_, GLib2.List* sibling, void* data);
24736 void g_queue_insert_sorted(Queue* this_, void* data, CompareDataFunc func, void* user_data);
24737 int g_queue_is_empty(Queue* this_);
24738 int g_queue_link_index(Queue* this_, GLib2.List* link_);
24739 void* g_queue_peek_head(Queue* this_);
24740 GLib2.List* g_queue_peek_head_link(Queue* this_);
24741 void* g_queue_peek_nth(Queue* this_, uint n);
24742 GLib2.List* g_queue_peek_nth_link(Queue* this_, uint n);
24743 void* g_queue_peek_tail(Queue* this_);
24744 GLib2.List* g_queue_peek_tail_link(Queue* this_);
24745 void* g_queue_pop_head(Queue* this_);
24746 GLib2.List* g_queue_pop_head_link(Queue* this_);
24747 void* g_queue_pop_nth(Queue* this_, uint n);
24748 GLib2.List* g_queue_pop_nth_link(Queue* this_, uint n);
24749 void* g_queue_pop_tail(Queue* this_);
24750 GLib2.List* g_queue_pop_tail_link(Queue* this_);
24751 void g_queue_push_head(Queue* this_, void* data);
24752 void g_queue_push_head_link(Queue* this_, GLib2.List* link_);
24753 void g_queue_push_nth(Queue* this_, void* data, int n);
24754 void g_queue_push_nth_link(Queue* this_, int n, GLib2.List* link_);
24755 void g_queue_push_tail(Queue* this_, void* data);
24756 void g_queue_push_tail_link(Queue* this_, GLib2.List* link_);
24757 int g_queue_remove(Queue* this_, const(void)* data);
24758 uint g_queue_remove_all(Queue* this_, const(void)* data);
24759 void g_queue_reverse(Queue* this_);
24760 void g_queue_sort(Queue* this_, CompareDataFunc compare_func, void* user_data);
24761 void g_queue_unlink(Queue* this_, GLib2.List* link_);
24762 Queue* g_queue_new();
24763 void g_rw_lock_clear(RWLock* this_);
24764 void g_rw_lock_init(RWLock* this_);
24765 void g_rw_lock_reader_lock(RWLock* this_);
24766 int g_rw_lock_reader_trylock(RWLock* this_);
24767 void g_rw_lock_reader_unlock(RWLock* this_);
24768 void g_rw_lock_writer_lock(RWLock* this_);
24769 int g_rw_lock_writer_trylock(RWLock* this_);
24770 void g_rw_lock_writer_unlock(RWLock* this_);
24771 Rand* g_rand_copy(Rand* this_);
24772 double g_rand_double(Rand* this_);
24773 double g_rand_double_range(Rand* this_, double begin, double end);
24774 void g_rand_free(Rand* this_);
24775 uint g_rand_int(Rand* this_);
24776 int g_rand_int_range(Rand* this_, int begin, int end);
24777 void g_rand_set_seed(Rand* this_, uint seed);
24778 void g_rand_set_seed_array(Rand* this_, uint* seed, uint seed_length);
24779 Rand* g_rand_new();
24780 Rand* g_rand_new_with_seed(uint seed);
24781 Rand* g_rand_new_with_seed_array(uint* seed, uint seed_length);
24782 void g_rec_mutex_clear(RecMutex* this_);
24783 void g_rec_mutex_init(RecMutex* this_);
24784 void g_rec_mutex_lock(RecMutex* this_);
24785 int g_rec_mutex_trylock(RecMutex* this_);
24786 void g_rec_mutex_unlock(RecMutex* this_);
24787 Regex* /*new*/ g_regex_new(char* pattern, RegexCompileFlags compile_options, RegexMatchFlags match_options, GLib2.Error** error);
24788 int g_regex_get_capture_count(Regex* this_);
24789 RegexCompileFlags g_regex_get_compile_flags(Regex* this_);
24790 RegexMatchFlags g_regex_get_match_flags(Regex* this_);
24791 int g_regex_get_max_backref(Regex* this_);
24792 char* g_regex_get_pattern(Regex* this_);
24793 int g_regex_get_string_number(Regex* this_, char* name);
24794 int g_regex_match(Regex* this_, char* string_, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info=null);
24795 int g_regex_match_all(Regex* this_, char* string_, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info=null);
24796 int g_regex_match_all_full(Regex* this_, char* string_, ssize_t string_len, int start_position, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info, GLib2.Error** error);
24797 int g_regex_match_full(Regex* this_, char* string_, ssize_t string_len, int start_position, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info, GLib2.Error** error);
24798 Regex* /*new*/ g_regex_ref(Regex* this_);
24799 char* /*new*/ g_regex_replace(Regex* this_, char* string_, ssize_t string_len, int start_position, char* replacement, RegexMatchFlags match_options, GLib2.Error** error);
24800 char* /*new*/ g_regex_replace_eval(Regex* this_, char* string_, ssize_t string_len, int start_position, RegexMatchFlags match_options, RegexEvalCallback eval, void* user_data, GLib2.Error** error);
24801 char* /*new*/ g_regex_replace_literal(Regex* this_, char* string_, ssize_t string_len, int start_position, char* replacement, RegexMatchFlags match_options, GLib2.Error** error);
24802 char** g_regex_split(Regex* this_, char* string_, RegexMatchFlags match_options);
24803 char** g_regex_split_full(Regex* this_, char* string_, ssize_t string_len, int start_position, RegexMatchFlags match_options, int max_tokens, GLib2.Error** error);
24804 void g_regex_unref(Regex* this_);
24805 int g_regex_check_replacement(char* replacement, /*out*/ int* has_references, GLib2.Error** error);
24806 Quark g_regex_error_quark();
24807 char* /*new*/ g_regex_escape_nul(char* string_, int length);
24808 char* /*new*/ g_regex_escape_string(char* string_, int length);
24809 int g_regex_match_simple(char* pattern, char* string_, RegexCompileFlags compile_options, RegexMatchFlags match_options);
24810 char** g_regex_split_simple(char* pattern, char* string_, RegexCompileFlags compile_options, RegexMatchFlags match_options);
24811 GLib2.SList* g_slist_alloc();
24812 GLib2.SList* g_slist_append(GLib2.SList* list, void* data);
24813 GLib2.SList* g_slist_concat(GLib2.SList* list1, GLib2.SList* list2);
24814 GLib2.SList* g_slist_copy(GLib2.SList* list);
24815 GLib2.SList* g_slist_delete_link(GLib2.SList* list, GLib2.SList* link_);
24816 GLib2.SList* g_slist_find(GLib2.SList* list, const(void)* data);
24817 GLib2.SList* g_slist_find_custom(GLib2.SList* list, const(void)* data, CompareFunc func);
24818 void g_slist_foreach(GLib2.SList* list, Func func, void* user_data);
24819 void g_slist_free(GLib2.SList* list);
24820 void g_slist_free_1(GLib2.SList* list);
24821 void g_slist_free_full(GLib2.SList* list, DestroyNotify free_func);
24822 int g_slist_index(GLib2.SList* list, const(void)* data);
24823 GLib2.SList* g_slist_insert(GLib2.SList* list, void* data, int position);
24824 GLib2.SList* g_slist_insert_before(GLib2.SList* slist, GLib2.SList* sibling, void* data);
24825 GLib2.SList* g_slist_insert_sorted(GLib2.SList* list, void* data, CompareFunc func);
24826 GLib2.SList* g_slist_insert_sorted_with_data(GLib2.SList* list, void* data, CompareDataFunc func, void* user_data);
24827 GLib2.SList* g_slist_last(GLib2.SList* list);
24828 uint g_slist_length(GLib2.SList* list);
24829 GLib2.SList* g_slist_nth(GLib2.SList* list, uint n);
24830 void* g_slist_nth_data(GLib2.SList* list, uint n);
24831 int g_slist_position(GLib2.SList* list, GLib2.SList* llink);
24832 GLib2.SList* g_slist_prepend(GLib2.SList* list, void* data);
24833 GLib2.SList* g_slist_remove(GLib2.SList* list, const(void)* data);
24834 GLib2.SList* g_slist_remove_all(GLib2.SList* list, const(void)* data);
24835 GLib2.SList* g_slist_remove_link(GLib2.SList* list, GLib2.SList* link_);
24836 GLib2.SList* g_slist_reverse(GLib2.SList* list);
24837 GLib2.SList* g_slist_sort(GLib2.SList* list, CompareFunc compare_func);
24838 GLib2.SList* g_slist_sort_with_data(GLib2.SList* list, CompareDataFunc compare_func, void* user_data);
24839 uint g_scanner_cur_line(Scanner* this_);
24840 uint g_scanner_cur_position(Scanner* this_);
24841 TokenType g_scanner_cur_token(Scanner* this_);
24842 TokenValue g_scanner_cur_value(Scanner* this_);
24843 void g_scanner_destroy(Scanner* this_);
24844 int g_scanner_eof(Scanner* this_);
24845 void g_scanner_error(Scanner* this_, char* format, ...);
24846 TokenType g_scanner_get_next_token(Scanner* this_);
24847 void g_scanner_input_file(Scanner* this_, int input_fd);
24848 void g_scanner_input_text(Scanner* this_, char* text, uint text_len);
24849 void* g_scanner_lookup_symbol(Scanner* this_, char* symbol);
24850 TokenType g_scanner_peek_next_token(Scanner* this_);
24851 void g_scanner_scope_add_symbol(Scanner* this_, uint scope_id, char* symbol, void* value);
24852 void g_scanner_scope_foreach_symbol(Scanner* this_, uint scope_id, HFunc func, void* user_data);
24853 void* g_scanner_scope_lookup_symbol(Scanner* this_, uint scope_id, char* symbol);
24854 void g_scanner_scope_remove_symbol(Scanner* this_, uint scope_id, char* symbol);
24855 uint g_scanner_set_scope(Scanner* this_, uint scope_id);
24856 void g_scanner_sync_file_offset(Scanner* this_);
24857 void g_scanner_unexp_token(Scanner* this_, TokenType expected_token, char* identifier_spec, char* symbol_spec, char* symbol_name, char* message, int is_error);
24858 void g_scanner_warn(Scanner* this_, char* format, ...);
24859 Scanner* g_scanner_new(ScannerConfig* config_templ);
24860 SequenceIter* g_sequence_append(Sequence* this_, void* data);
24861 void g_sequence_foreach(Sequence* this_, Func func, void* user_data);
24862 void g_sequence_free(Sequence* this_);
24863 SequenceIter* g_sequence_get_begin_iter(Sequence* this_);
24864 SequenceIter* g_sequence_get_end_iter(Sequence* this_);
24865 SequenceIter* g_sequence_get_iter_at_pos(Sequence* this_, int pos);
24866 int g_sequence_get_length(Sequence* this_);
24867 SequenceIter* g_sequence_insert_sorted(Sequence* this_, void* data, CompareDataFunc cmp_func, void* cmp_data);
24868 SequenceIter* g_sequence_insert_sorted_iter(Sequence* this_, void* data, SequenceIterCompareFunc iter_cmp, void* cmp_data);
24869 SequenceIter* g_sequence_lookup(Sequence* this_, void* data, CompareDataFunc cmp_func, void* cmp_data);
24870 SequenceIter* g_sequence_lookup_iter(Sequence* this_, void* data, SequenceIterCompareFunc iter_cmp, void* cmp_data);
24871 SequenceIter* g_sequence_prepend(Sequence* this_, void* data);
24872 SequenceIter* g_sequence_search(Sequence* this_, void* data, CompareDataFunc cmp_func, void* cmp_data);
24873 SequenceIter* g_sequence_search_iter(Sequence* this_, void* data, SequenceIterCompareFunc iter_cmp, void* cmp_data);
24874 void g_sequence_sort(Sequence* this_, CompareDataFunc cmp_func, void* cmp_data);
24875 void g_sequence_sort_iter(Sequence* this_, SequenceIterCompareFunc cmp_func, void* cmp_data);
24876 void g_sequence_foreach_range(SequenceIter* begin, SequenceIter* end, Func func, void* user_data);
24877 void* g_sequence_get(SequenceIter* iter);
24878 SequenceIter* g_sequence_insert_before(SequenceIter* iter, void* data);
24879 void g_sequence_move(SequenceIter* src, SequenceIter* dest);
24880 void g_sequence_move_range(SequenceIter* dest, SequenceIter* begin, SequenceIter* end);
24881 Sequence* g_sequence_new(DestroyNotify data_destroy);
24882 SequenceIter* g_sequence_range_get_midpoint(SequenceIter* begin, SequenceIter* end);
24883 void g_sequence_remove(SequenceIter* iter);
24884 void g_sequence_remove_range(SequenceIter* begin, SequenceIter* end);
24885 void g_sequence_set(SequenceIter* iter, void* data);
24886 void g_sequence_sort_changed(SequenceIter* iter, CompareDataFunc cmp_func, void* cmp_data);
24887 void g_sequence_sort_changed_iter(SequenceIter* iter, SequenceIterCompareFunc iter_cmp, void* cmp_data);
24888 void g_sequence_swap(SequenceIter* a, SequenceIter* b);
24889 int g_sequence_iter_compare(SequenceIter* this_, SequenceIter* b);
24890 int g_sequence_iter_get_position(SequenceIter* this_);
24891 Sequence* g_sequence_iter_get_sequence(SequenceIter* this_);
24892 int g_sequence_iter_is_begin(SequenceIter* this_);
24893 int g_sequence_iter_is_end(SequenceIter* this_);
24894 SequenceIter* g_sequence_iter_move(SequenceIter* this_, int delta);
24895 SequenceIter* g_sequence_iter_next(SequenceIter* this_);
24896 SequenceIter* g_sequence_iter_prev(SequenceIter* this_);
24897 Source* /*new*/ g_source_new(SourceFuncs* source_funcs, uint struct_size);
24898 void g_source_add_child_source(Source* this_, Source* child_source);
24899 void g_source_add_poll(Source* this_, PollFD* fd);
24900 uint g_source_attach(Source* this_, MainContext* context=null);
24901 void g_source_destroy(Source* this_);
24902 int g_source_get_can_recurse(Source* this_);
24903 MainContext* g_source_get_context(Source* this_);
24904 void g_source_get_current_time(Source* this_, TimeVal* timeval);
24905 uint g_source_get_id(Source* this_);
24906 char* g_source_get_name(Source* this_);
24907 int g_source_get_priority(Source* this_);
24908 long g_source_get_time(Source* this_);
24909 int g_source_is_destroyed(Source* this_);
24910 Source* /*new*/ g_source_ref(Source* this_);
24911 void g_source_remove_child_source(Source* this_, Source* child_source);
24912 void g_source_remove_poll(Source* this_, PollFD* fd);
24913 void g_source_set_callback(Source* this_, SourceFunc func, void* data, DestroyNotify notify);
24914 void g_source_set_callback_indirect(Source* this_, void* callback_data, SourceCallbackFuncs* callback_funcs);
24915 void g_source_set_can_recurse(Source* this_, int can_recurse);
24916 void g_source_set_funcs(Source* this_, SourceFuncs* funcs);
24917 void g_source_set_name(Source* this_, char* name);
24918 void g_source_set_priority(Source* this_, int priority);
24919 void g_source_unref(Source* this_);
24920 int g_source_remove(uint tag);
24921 int g_source_remove_by_funcs_user_data(SourceFuncs* funcs, void* user_data);
24922 int g_source_remove_by_user_data(void* user_data);
24923 void g_source_set_name_by_id(uint tag, char* name);
24924 String* /*new*/ g_string_append(String* this_, char* val);
24925 String* /*new*/ g_string_append_c(String* this_, char c);
24926 String* /*new*/ g_string_append_len(String* this_, char* val, ssize_t len);
24927 void g_string_append_printf(String* this_, char* format, ...);
24928 String* /*new*/ g_string_append_unichar(String* this_, dchar wc);
24929 String* /*new*/ g_string_append_uri_escaped(String* this_, char* unescaped, char* reserved_chars_allowed, int allow_utf8);
24930 void g_string_append_vprintf(String* this_, char* format, va_list args);
24931 String* /*new*/ g_string_ascii_down(String* this_);
24932 String* /*new*/ g_string_ascii_up(String* this_);
24933 String* /*new*/ g_string_assign(String* this_, char* rval);
24934 String* /*new*/ g_string_down(String* this_);
24935 int g_string_equal(String* this_, String* v2);
24936 String* /*new*/ g_string_erase(String* this_, ssize_t pos, ssize_t len);
24937 char* /*new*/ g_string_free(String* this_, int free_segment);
24938 uint g_string_hash(String* this_);
24939 String* /*new*/ g_string_insert(String* this_, ssize_t pos, char* val);
24940 String* /*new*/ g_string_insert_c(String* this_, ssize_t pos, char c);
24941 String* /*new*/ g_string_insert_len(String* this_, ssize_t pos, char* val, ssize_t len);
24942 String* /*new*/ g_string_insert_unichar(String* this_, ssize_t pos, dchar wc);
24943 String* /*new*/ g_string_overwrite(String* this_, size_t pos, char* val);
24944 String* /*new*/ g_string_overwrite_len(String* this_, size_t pos, char* val, ssize_t len);
24945 String* /*new*/ g_string_prepend(String* this_, char* val);
24946 String* /*new*/ g_string_prepend_c(String* this_, char c);
24947 String* /*new*/ g_string_prepend_len(String* this_, char* val, ssize_t len);
24948 String* /*new*/ g_string_prepend_unichar(String* this_, dchar wc);
24949 void g_string_printf(String* this_, char* format, ...);
24950 String* /*new*/ g_string_set_size(String* this_, size_t len);
24951 String* /*new*/ g_string_truncate(String* this_, size_t len);
24952 String* /*new*/ g_string_up(String* this_);
24953 void g_string_vprintf(String* this_, char* format, va_list args);
24954 void g_string_chunk_clear(StringChunk* this_);
24955 void g_string_chunk_free(StringChunk* this_);
24956 char* /*new*/ g_string_chunk_insert(StringChunk* this_, char* string_);
24957 char* /*new*/ g_string_chunk_insert_const(StringChunk* this_, char* string_);
24958 char* /*new*/ g_string_chunk_insert_len(StringChunk* this_, char* string_, ssize_t len);
24959 StringChunk* g_string_chunk_new(size_t size);
24960 void g_test_log_buffer_free(TestLogBuffer* this_);
24961 TestLogMsg* g_test_log_buffer_pop(TestLogBuffer* this_);
24962 void g_test_log_buffer_push(TestLogBuffer* this_, uint n_bytes, ubyte* bytes);
24963 TestLogBuffer* g_test_log_buffer_new();
24964 void g_test_log_msg_free(TestLogMsg* this_);
24965 void g_test_suite_add(TestSuite* this_, TestCase* test_case);
24966 void g_test_suite_add_suite(TestSuite* this_, TestSuite* nestedsuite);
24967 void* g_thread_join(Thread* this_);
24968 Thread* g_thread_ref(Thread* this_);
24969 void g_thread_unref(Thread* this_);
24970 Quark g_thread_error_quark();
24971 void g_thread_exit(void* retval);
24972 Thread* g_thread_new(char* name, ThreadFunc func, void* data);
24973 Thread* g_thread_self();
24974 Thread* g_thread_try_new(char* name, ThreadFunc func, void* data, GLib2.Error** error);
24975 void g_thread_yield();
24976 void g_thread_pool_free(ThreadPool* this_, int immediate, int wait_);
24977 int g_thread_pool_get_max_threads(ThreadPool* this_);
24978 uint g_thread_pool_get_num_threads(ThreadPool* this_);
24979 int g_thread_pool_push(ThreadPool* this_, void* data, GLib2.Error** error);
24980 int g_thread_pool_set_max_threads(ThreadPool* this_, int max_threads, GLib2.Error** error);
24981 void g_thread_pool_set_sort_function(ThreadPool* this_, CompareDataFunc func, void* user_data);
24982 uint g_thread_pool_unprocessed(ThreadPool* this_);
24983 uint g_thread_pool_get_max_idle_time();
24984 int g_thread_pool_get_max_unused_threads();
24985 uint g_thread_pool_get_num_unused_threads();
24986 ThreadPool* g_thread_pool_new(Func func, void* user_data, int max_threads, int exclusive, GLib2.Error** error);
24987 void g_thread_pool_set_max_idle_time(uint interval);
24988 void g_thread_pool_set_max_unused_threads(int max_threads);
24989 void g_thread_pool_stop_unused_threads();
24990 void g_time_val_add(TimeVal* this_, c_long microseconds);
24991 char* /*new*/ g_time_val_to_iso8601(TimeVal* this_);
24992 int g_time_val_from_iso8601(char* iso_date, /*out*/ TimeVal* time_);
24993 int g_time_zone_adjust_time(TimeZone* this_, TimeType type, long* time_);
24994 int g_time_zone_find_interval(TimeZone* this_, TimeType type, long time_);
24995 char* g_time_zone_get_abbreviation(TimeZone* this_, int interval);
24996 int g_time_zone_get_offset(TimeZone* this_, int interval);
24997 int g_time_zone_is_dst(TimeZone* this_, int interval);
24998 TimeZone* g_time_zone_ref(TimeZone* this_);
24999 void g_time_zone_unref(TimeZone* this_);
25000 TimeZone* g_time_zone_new(char* identifier=null);
25001 TimeZone* g_time_zone_new_local();
25002 TimeZone* g_time_zone_new_utc();
25003 void g_timer_continue(Timer* this_);
25004 void g_timer_destroy(Timer* this_);
25005 double g_timer_elapsed(Timer* this_, c_ulong* microseconds);
25006 void g_timer_reset(Timer* this_);
25007 void g_timer_start(Timer* this_);
25008 void g_timer_stop(Timer* this_);
25009 Timer* g_timer_new();
25010 uint g_trash_stack_height(TrashStack** stack_p);
25011 void* g_trash_stack_peek(TrashStack** stack_p);
25012 void* g_trash_stack_pop(TrashStack** stack_p);
25013 void g_trash_stack_push(TrashStack** stack_p, void* data_p);
25014 void g_tree_destroy(Tree* this_);
25015 void g_tree_foreach(Tree* this_, TraverseFunc func, void* user_data);
25016 int g_tree_height(Tree* this_);
25017 void g_tree_insert(Tree* this_, void* key, void* value);
25018 void* g_tree_lookup(Tree* this_, const(void)* key);
25019 int g_tree_lookup_extended(Tree* this_, const(void)* lookup_key, void** orig_key, void** value);
25020 int g_tree_nnodes(Tree* this_);
25021 Tree* g_tree_ref(Tree* this_);
25022 int g_tree_remove(Tree* this_, const(void)* key);
25023 void g_tree_replace(Tree* this_, void* key, void* value);
25024 void* g_tree_search(Tree* this_, CompareFunc search_func, const(void)* user_data);
25025 int g_tree_steal(Tree* this_, const(void)* key);
25026 void g_tree_traverse(Tree* this_, TraverseFunc traverse_func, TraverseType traverse_type, void* user_data);
25027 void g_tree_unref(Tree* this_);
25028 Tree* g_tree_new(CompareFunc key_compare_func);
25029 Tree* g_tree_new_full(CompareDataFunc key_compare_func, void* key_compare_data, DestroyNotify key_destroy_func, DestroyNotify value_destroy_func);
25030 Tree* g_tree_new_with_data(CompareDataFunc key_compare_func, void* key_compare_data);
25031 Variant* /*new*/ g_variant_new(char* format_string, ...);
25032 Variant* g_variant_new_array(VariantType* child_type, Variant** children, size_t n_children);
25033 Variant* g_variant_new_boolean(int value);
25034 Variant* g_variant_new_byte(ubyte value);
25035 Variant* g_variant_new_bytestring(ubyte* string_);
25036 Variant* g_variant_new_bytestring_array(char** strv, ssize_t length);
25037 Variant* g_variant_new_dict_entry(Variant* key, Variant* value);
25038 Variant* g_variant_new_double(double value);
25039 Variant* g_variant_new_fixed_array(VariantType* element_type, const(void)* elements, size_t n_elements, size_t element_size);
25040 Variant* g_variant_new_from_data(VariantType* type, const(ubyte)* data, size_t size, int trusted, DestroyNotify notify, void* user_data);
25041 Variant* g_variant_new_handle(int value);
25042 Variant* g_variant_new_int16(short value);
25043 Variant* g_variant_new_int32(int value);
25044 Variant* g_variant_new_int64(long value);
25045 Variant* g_variant_new_maybe(VariantType* child_type=null, Variant* child=null);
25046 Variant* g_variant_new_object_path(char* object_path);
25047 Variant* g_variant_new_objv(char** strv, ssize_t length);
25048 Variant* /*new*/ g_variant_new_parsed(char* format, ...);
25049 Variant* /*new*/ g_variant_new_parsed_va(char* format, va_list* app);
25050 Variant* g_variant_new_signature(char* signature);
25051 Variant* g_variant_new_string(char* string_);
25052 Variant* g_variant_new_strv(char** strv, ssize_t length);
25053 Variant* g_variant_new_tuple(Variant** children, size_t n_children);
25054 Variant* g_variant_new_uint16(ushort value);
25055 Variant* g_variant_new_uint32(uint value);
25056 Variant* g_variant_new_uint64(ulong value);
25057 Variant* /*new*/ g_variant_new_va(char* format_string, char** endptr, va_list* app);
25058 Variant* g_variant_new_variant(Variant* value);
25059 Variant* /*new*/ g_variant_byteswap(Variant* this_);
25060 VariantClass g_variant_classify(Variant* this_);
25061 int g_variant_compare(Variant* this_, const(Variant)* two);
25062 char* /*new*/ g_variant_dup_bytestring(Variant* this_, /*out*/ size_t* length=null);
25063 char** /*new*/ g_variant_dup_bytestring_array(Variant* this_, /*out*/ size_t* length=null);
25064 char** /*new*/ g_variant_dup_objv(Variant* this_, /*out*/ size_t* length=null);
25065 char* /*new*/ g_variant_dup_string(Variant* this_, /*out*/ size_t* length);
25066 char** /*new*/ g_variant_dup_strv(Variant* this_, /*out*/ size_t* length=null);
25067 int g_variant_equal(Variant* this_, const(Variant)* two);
25068 void g_variant_get(Variant* this_, char* format_string, ...);
25069 int g_variant_get_boolean(Variant* this_);
25070 ubyte g_variant_get_byte(Variant* this_);
25071 ubyte* g_variant_get_bytestring(Variant* this_);
25072 char** /*new container*/ g_variant_get_bytestring_array(Variant* this_, /*out*/ size_t* length=null);
25073 void g_variant_get_child(Variant* this_, size_t index_, char* format_string, ...);
25074 Variant* /*new*/ g_variant_get_child_value(Variant* this_, size_t index_);
25075 const(void)* g_variant_get_data(Variant* this_);
25076 double g_variant_get_double(Variant* this_);
25077 const(void)* g_variant_get_fixed_array(Variant* this_, /*out*/ size_t* n_elements, size_t element_size);
25078 int g_variant_get_handle(Variant* this_);
25079 short g_variant_get_int16(Variant* this_);
25080 int g_variant_get_int32(Variant* this_);
25081 long g_variant_get_int64(Variant* this_);
25082 Variant* /*new*/ g_variant_get_maybe(Variant* this_);
25083 Variant* /*new*/ g_variant_get_normal_form(Variant* this_);
25084 char** /*new container*/ g_variant_get_objv(Variant* this_, /*out*/ size_t* length=null);
25085 size_t g_variant_get_size(Variant* this_);
25086 char* g_variant_get_string(Variant* this_, /*out*/ size_t* length=null);
25087 char** /*new container*/ g_variant_get_strv(Variant* this_, /*out*/ size_t* length=null);
25088 char* g_variant_get_type_string(Variant* this_);
25089 ushort g_variant_get_uint16(Variant* this_);
25090 uint g_variant_get_uint32(Variant* this_);
25091 ulong g_variant_get_uint64(Variant* this_);
25092 void g_variant_get_va(Variant* this_, char* format_string, char** endptr, va_list* app);
25093 Variant* /*new*/ g_variant_get_variant(Variant* this_);
25094 uint g_variant_hash(Variant* this_);
25095 int g_variant_is_container(Variant* this_);
25096 int g_variant_is_floating(Variant* this_);
25097 int g_variant_is_normal_form(Variant* this_);
25098 int g_variant_is_of_type(Variant* this_, VariantType* type);
25099 VariantIter* /*new*/ g_variant_iter_new(Variant* this_);
25100 int g_variant_lookup(Variant* this_, char* key, char* format_string, ...);
25101 Variant* /*new*/ g_variant_lookup_value(Variant* this_, char* key, VariantType* expected_type=null);
25102 size_t g_variant_n_children(Variant* this_);
25103 char* /*new*/ g_variant_print(Variant* this_, int type_annotate);
25104 String* /*new*/ g_variant_print_string(Variant* this_, String* string_, int type_annotate);
25105 Variant* /*new*/ g_variant_ref(Variant* this_);
25106 Variant* /*new*/ g_variant_ref_sink(Variant* this_);
25107 void g_variant_store(Variant* this_, void* data);
25108 Variant* /*new*/ g_variant_take_ref(Variant* this_);
25109 void g_variant_unref(Variant* this_);
25110 int g_variant_is_object_path(char* string_);
25111 int g_variant_is_signature(char* string_);
25112 Variant* /*new*/ g_variant_parse(VariantType* type, char* text, char* limit, char** endptr, GLib2.Error** error);
25113 Quark g_variant_parser_get_error_quark();
25114 VariantBuilder* /*new*/ g_variant_builder_new(VariantType* type);
25115 void g_variant_builder_add(VariantBuilder* this_, char* format_string, ...);
25116 void g_variant_builder_add_parsed(VariantBuilder* this_, char* format, ...);
25117 void g_variant_builder_add_value(VariantBuilder* this_, Variant* value);
25118 void g_variant_builder_clear(VariantBuilder* this_);
25119 void g_variant_builder_close(VariantBuilder* this_);
25120 Variant* g_variant_builder_end(VariantBuilder* this_);
25121 void g_variant_builder_init(VariantBuilder* this_, VariantType* type);
25122 void g_variant_builder_open(VariantBuilder* this_, VariantType* type);
25123 VariantBuilder* /*new*/ g_variant_builder_ref(VariantBuilder* this_);
25124 void g_variant_builder_unref(VariantBuilder* this_);
25125 VariantIter* /*new*/ g_variant_iter_copy(VariantIter* this_);
25126 void g_variant_iter_free(VariantIter* this_);
25127 size_t g_variant_iter_init(VariantIter* this_, Variant* value);
25128 int g_variant_iter_loop(VariantIter* this_, char* format_string, ...);
25129 size_t g_variant_iter_n_children(VariantIter* this_);
25130 int g_variant_iter_next(VariantIter* this_, char* format_string, ...);
25131 Variant* /*new*/ g_variant_iter_next_value(VariantIter* this_);
25132 VariantType* /*new*/ g_variant_type_new(char* type_string);
25133 VariantType* /*new*/ g_variant_type_new_tuple(VariantType** items, int length);
25134 VariantType* /*new*/ g_variant_type_copy(VariantType* this_);
25135 char* /*new*/ g_variant_type_dup_string(VariantType* this_);
25136 VariantType* g_variant_type_element(VariantType* this_);
25137 int g_variant_type_equal(VariantType* this_, const(VariantType)* type2);
25138 VariantType* g_variant_type_first(VariantType* this_);
25139 void g_variant_type_free(VariantType* this_);
25140 size_t g_variant_type_get_string_length(VariantType* this_);
25141 uint g_variant_type_hash(VariantType* this_);
25142 int g_variant_type_is_array(VariantType* this_);
25143 int g_variant_type_is_basic(VariantType* this_);
25144 int g_variant_type_is_container(VariantType* this_);
25145 int g_variant_type_is_definite(VariantType* this_);
25146 int g_variant_type_is_dict_entry(VariantType* this_);
25147 int g_variant_type_is_maybe(VariantType* this_);
25148 int g_variant_type_is_subtype_of(VariantType* this_, VariantType* supertype);
25149 int g_variant_type_is_tuple(VariantType* this_);
25150 int g_variant_type_is_variant(VariantType* this_);
25151 VariantType* g_variant_type_key(VariantType* this_);
25152 size_t g_variant_type_n_items(VariantType* this_);
25153 VariantType* /*new*/ g_variant_type_new_array(VariantType* this_);
25154 VariantType* /*new*/ g_variant_type_new_dict_entry(VariantType* this_, VariantType* value);
25155 VariantType* /*new*/ g_variant_type_new_maybe(VariantType* this_);
25156 VariantType* g_variant_type_next(VariantType* this_);
25157 char* g_variant_type_peek_string(VariantType* this_);
25158 VariantType* g_variant_type_value(VariantType* this_);
25159 VariantType* g_variant_type_checked_(char* arg_a);
25160 int g_variant_type_string_is_valid(char* type_string);
25161 int g_variant_type_string_scan(char* string_, char* limit=null, /*out*/ char** endptr=null);
25162 int g_access(char* filename, int mode);
25163 int g_ascii_digit_value(char c);
25164 char* /*new*/ g_ascii_dtostr(char* buffer, int buf_len, double d);
25165 char* /*new*/ g_ascii_formatd(char* buffer, int buf_len, char* format, double d);
25166 int g_ascii_strcasecmp(char* s1, char* s2);
25167 char* /*new*/ g_ascii_strdown(char* str, ssize_t len);
25168 int g_ascii_strncasecmp(char* s1, char* s2, size_t n);
25169 double g_ascii_strtod(char* nptr, char** endptr);
25170 long g_ascii_strtoll(char* nptr, char** endptr, uint base);
25171 ulong g_ascii_strtoull(char* nptr, char** endptr, uint base);
25172 char* /*new*/ g_ascii_strup(char* str, ssize_t len);
25173 char g_ascii_tolower(char c);
25174 char g_ascii_toupper(char c);
25175 int g_ascii_xdigit_value(char c);
25176 void g_assert_warning(char* log_domain, char* file, int line, char* pretty_function, char* expression);
25177 void g_assertion_message(char* domain, char* file, int line, char* func, char* message);
25178 void g_assertion_message_cmpnum(char* domain, char* file, int line, char* func, char* expr, real arg1, char* cmp, real arg2, char numtype);
25179 void g_assertion_message_cmpstr(char* domain, char* file, int line, char* func, char* expr, char* arg1, char* cmp, char* arg2);
25180 void g_assertion_message_error(char* domain, char* file, int line, char* func, char* expr, Error* error, Quark error_domain, int error_code);
25181 void g_assertion_message_expr(char* domain, char* file, int line, char* func, char* expr);
25182 void g_atexit(VoidFunc func);
25183 int g_atomic_int_add(int* atomic, int val);
25184 uint g_atomic_int_and(uint* atomic, uint val);
25185 int g_atomic_int_compare_and_exchange(int* atomic, int oldval, int newval);
25186 int g_atomic_int_dec_and_test(int* atomic);
25187 int g_atomic_int_exchange_and_add(int* atomic, int val);
25188 int g_atomic_int_get(int* atomic);
25189 void g_atomic_int_inc(int* atomic);
25190 uint g_atomic_int_or(uint* atomic, uint val);
25191 void g_atomic_int_set(int* atomic, int newval);
25192 uint g_atomic_int_xor(uint* atomic, uint val);
25193 ssize_t g_atomic_pointer_add(void* atomic, ssize_t val);
25194 size_t g_atomic_pointer_and(void* atomic, size_t val);
25195 int g_atomic_pointer_compare_and_exchange(void* atomic, void* oldval, void* newval);
25196 void* g_atomic_pointer_get(void* atomic);
25197 size_t g_atomic_pointer_or(void* atomic, size_t val);
25198 void g_atomic_pointer_set(void* atomic, void* newval);
25199 size_t g_atomic_pointer_xor(void* atomic, size_t val);
25200 ubyte* /*new*/ g_base64_decode(char* text, /*out*/ size_t* out_len);
25201 ubyte* g_base64_decode_inplace(/*inout*/ ubyte* text, /*inout*/ size_t* out_len);
25202 size_t g_base64_decode_step(ubyte* in_, size_t len, /*out*/ ubyte* out_, /*inout*/ int* state, /*inout*/ uint* save);
25203 char* /*new*/ g_base64_encode(ubyte* data, size_t len);
25204 size_t g_base64_encode_close(int break_lines, /*out*/ ubyte* out_, /*inout*/ int* state, /*inout*/ int* save);
25205 size_t g_base64_encode_step(ubyte* in_, size_t len, int break_lines, /*out*/ ubyte* out_, /*inout*/ int* state, /*inout*/ int* save);
25206 char* g_basename(char* file_name);
25207 void g_bit_lock(int* address, int lock_bit);
25208 int g_bit_nth_lsf(c_ulong mask, int nth_bit);
25209 int g_bit_nth_msf(c_ulong mask, int nth_bit);
25210 uint g_bit_storage(c_ulong number);
25211 int g_bit_trylock(int* address, int lock_bit);
25212 void g_bit_unlock(int* address, int lock_bit);
25213 char* /*new*/ g_build_filename(char* first_element, ...);
25214 char* /*new*/ g_build_filenamev(char** args);
25215 char* /*new*/ g_build_path(char* separator, char* first_element, ...);
25216 char* /*new*/ g_build_pathv(char* separator, char** args);
25217 int g_chdir(char* path);
25218 char* glib_check_version(uint required_major, uint required_minor, uint required_micro);
25219 uint g_child_watch_add(Pid pid, ChildWatchFunc function_, void* data);
25220 uint g_child_watch_add_full(int priority, Pid pid, ChildWatchFunc function_, void* data, DestroyNotify notify);
25221 Source* /*new*/ g_child_watch_source_new(Pid pid);
25222 void g_clear_error(GLib2.Error** error);
25223 char* /*new*/ g_compute_checksum_for_data(ChecksumType checksum_type, ubyte* data, size_t length);
25224 char* /*new*/ g_compute_checksum_for_string(ChecksumType checksum_type, char* str, ssize_t length);
25225 char* /*new*/ g_compute_hmac_for_data(ChecksumType digest_type, ubyte* key, size_t key_len, ubyte* data, size_t length);
25226 char* /*new*/ g_compute_hmac_for_string(ChecksumType digest_type, ubyte* key, size_t key_len, char* str, ssize_t length);
25227 char* /*new*/ g_convert(char* str, ssize_t len, char* to_codeset, char* from_codeset, /*out*/ size_t* bytes_read, /*out*/ size_t* bytes_written, GLib2.Error** error);
25228 Quark g_convert_error_quark();
25229 char* /*new*/ g_convert_with_fallback(char* str, ssize_t len, char* to_codeset, char* from_codeset, char* fallback, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error);
25230 char* /*new*/ g_convert_with_iconv(char* str, ssize_t len, IConv converter, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error);
25231 void g_datalist_clear(Data** datalist);
25232 void g_datalist_foreach(Data** datalist, DataForeachFunc func, void* user_data);
25233 void* g_datalist_get_data(Data** datalist, char* key);
25234 uint g_datalist_get_flags(Data** datalist);
25235 void* g_datalist_id_get_data(Data** datalist, Quark key_id);
25236 void* g_datalist_id_remove_no_notify(Data** datalist, Quark key_id);
25237 void g_datalist_id_set_data_full(Data** datalist, Quark key_id, void* data, DestroyNotify destroy_func);
25238 void g_datalist_init(Data** datalist);
25239 void g_datalist_set_flags(Data** datalist, uint flags);
25240 void g_datalist_unset_flags(Data** datalist, uint flags);
25241 void g_dataset_destroy(const(void)* dataset_location);
25242 void g_dataset_foreach(const(void)* dataset_location, DataForeachFunc func, void* user_data);
25243 void* g_dataset_id_get_data(const(void)* dataset_location, Quark key_id);
25244 void* g_dataset_id_remove_no_notify(const(void)* dataset_location, Quark key_id);
25245 void g_dataset_id_set_data_full(const(void)* dataset_location, Quark key_id, void* data, DestroyNotify destroy_func);
25246 char* g_dcgettext(char* domain, char* msgid, int category);
25247 char* g_dgettext(char* domain, char* msgid);
25248 int g_direct_equal(const(void)* v1=null, const(void)* v2=null);
25249 uint g_direct_hash(const(void)* v=null);
25250 char* g_dngettext(char* domain, char* msgid, char* msgid_plural, c_ulong n);
25251 int g_double_equal(const(void)* v1, const(void)* v2);
25252 uint g_double_hash(const(void)* v);
25253 char* g_dpgettext(char* domain, char* msgctxtid, size_t msgidoffset);
25254 char* g_dpgettext2(char* domain, char* context, char* msgid);
25255 char* g_environ_getenv(char** envp, char* variable);
25256 char** /*new*/ g_environ_setenv(char** envp, char* variable, char* value, int overwrite);
25257 char** /*new*/ g_environ_unsetenv(char** envp, char* variable);
25258 FileError g_file_error_from_errno(int err_no);
25259 Quark g_file_error_quark();
25260 int g_file_get_contents(char* filename, /*out*/ ubyte** contents, /*out*/ size_t* length, GLib2.Error** error);
25261 int g_file_open_tmp(char* tmpl, /*out*/ char** name_used, GLib2.Error** error);
25262 char* /*new*/ g_file_read_link(char* filename, GLib2.Error** error);
25263 int g_file_set_contents(char* filename, ubyte* contents, ssize_t length, GLib2.Error** error);
25264 int g_file_test(char* filename, FileTest test);
25265 char* /*new*/ g_filename_display_basename(char* filename);
25266 char* /*new*/ g_filename_display_name(char* filename);
25267 char* /*new*/ g_filename_from_uri(char* uri, char** hostname, GLib2.Error** error);
25268 char* /*new*/ g_filename_from_utf8(char* utf8string, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error);
25269 char* /*new*/ g_filename_to_uri(char* filename, char* hostname, GLib2.Error** error);
25270 char* /*new*/ g_filename_to_utf8(char* opsysstring, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error);
25271 char* /*new*/ g_find_program_in_path(char* program);
25272 char* /*new*/ g_format_size(ulong size);
25273 char* /*new*/ g_format_size_for_display(long size);
25274 char* /*new*/ g_format_size_full(ulong size, FormatSizeFlags flags);
25275 int g_fprintf(FILE* file, char* format, ...);
25276 void g_free(void* mem);
25277 char* g_get_application_name();
25278 int g_get_charset(char** charset);
25279 char* /*new*/ g_get_codeset();
25280 char* /*new*/ g_get_current_dir();
25281 void g_get_current_time(TimeVal* result);
25282 char** /*new*/ g_get_environ();
25283 int g_get_filename_charsets(char*** charsets);
25284 char* g_get_home_dir();
25285 char* g_get_host_name();
25286 char** g_get_language_names();
25287 char** /*new*/ g_get_locale_variants(char* locale);
25288 long g_get_monotonic_time();
25289 char* /*new*/ g_get_prgname();
25290 char* g_get_real_name();
25291 long g_get_real_time();
25292 char** g_get_system_config_dirs();
25293 char** g_get_system_data_dirs();
25294 char* g_get_tmp_dir();
25295 char* g_get_user_cache_dir();
25296 char* g_get_user_config_dir();
25297 char* g_get_user_data_dir();
25298 char* g_get_user_name();
25299 char* g_get_user_runtime_dir();
25300 char* g_get_user_special_dir(UserDirectory directory);
25301 char* g_getenv(char* variable);
25302 int g_hostname_is_ascii_encoded(char* hostname);
25303 int g_hostname_is_ip_address(char* hostname);
25304 int g_hostname_is_non_ascii(char* hostname);
25305 char* /*new*/ g_hostname_to_ascii(char* hostname);
25306 char* /*new*/ g_hostname_to_unicode(char* hostname);
25307 uint g_idle_add(SourceFunc function_, void* data);
25308 uint g_idle_add_full(int priority, SourceFunc function_, void* data, DestroyNotify notify);
25309 int g_idle_remove_by_data(void* data);
25310 Source* /*new*/ g_idle_source_new();
25311 int g_int64_equal(const(void)* v1, const(void)* v2);
25312 uint g_int64_hash(const(void)* v);
25313 int g_int_equal(const(void)* v1, const(void)* v2);
25314 uint g_int_hash(const(void)* v);
25315 char* g_intern_static_string(char* string_=null);
25316 char* g_intern_string(char* string_=null);
25317 uint g_io_add_watch(IOChannel* channel, IOCondition condition, IOFunc func, void* user_data);
25318 uint g_io_add_watch_full(IOChannel* channel, int priority, IOCondition condition, IOFunc func, void* user_data, DestroyNotify notify);
25319 Source* /*new*/ g_io_create_watch(IOChannel* channel, IOCondition condition);
25320 char** /*new*/ g_listenv();
25321 char* /*new*/ g_locale_from_utf8(char* utf8string, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error);
25322 char* /*new*/ g_locale_to_utf8(char* opsysstring, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error);
25323 void g_log(char* log_domain, LogLevelFlags log_level, char* format, ...);
25324 void g_log_default_handler(char* log_domain, LogLevelFlags log_level, char* message, void* unused_data);
25325 void g_log_remove_handler(char* log_domain, uint handler_id);
25326 LogLevelFlags g_log_set_always_fatal(LogLevelFlags fatal_mask);
25327 LogFunc g_log_set_default_handler(LogFunc log_func, void* user_data);
25328 LogLevelFlags g_log_set_fatal_mask(char* log_domain, LogLevelFlags fatal_mask);
25329 uint g_log_set_handler(char* log_domain, LogLevelFlags log_levels, LogFunc log_func, void* user_data);
25330 void g_logv(char* log_domain, LogLevelFlags log_level, char* format, va_list args);
25331 Source* g_main_current_source();
25332 int g_main_depth();
25333 void* g_malloc(size_t n_bytes);
25334 void* g_malloc0(size_t n_bytes);
25335 void* g_malloc0_n(size_t n_blocks, size_t n_block_bytes);
25336 void* g_malloc_n(size_t n_blocks, size_t n_block_bytes);
25337 int g_markup_collect_attributes(char* element_name, char** attribute_names, char** attribute_values, Error** error, MarkupCollectType first_type, char* first_attr, ...);
25338 Quark g_markup_error_quark();
25339 char* /*new*/ g_markup_escape_text(char* text, ssize_t length);
25340 char* /*new*/ g_markup_printf_escaped(char* format, ...);
25341 char* /*new*/ g_markup_vprintf_escaped(char* format, va_list args);
25342 int g_mem_is_system_malloc();
25343 void g_mem_profile();
25344 void g_mem_set_vtable(MemVTable* vtable);
25345 void* g_memdup(const(void)* mem, uint byte_size);
25346 int g_mkdir_with_parents(char* pathname, int mode);
25347 char* /*new*/ g_mkdtemp(char* tmpl);
25348 char* /*new*/ g_mkdtemp_full(char* tmpl, int mode);
25349 int g_mkstemp(char* tmpl);
25350 int g_mkstemp_full(char* tmpl, int flags, int mode);
25351 void g_nullify_pointer(void** nullify_location);
25352 void g_on_error_query(char* prg_name);
25353 void g_on_error_stack_trace(char* prg_name);
25354 Quark g_option_error_quark();
25355 uint g_parse_debug_string(char* string_, DebugKey* keys, uint nkeys);
25356 char* /*new*/ g_path_get_basename(char* file_name);
25357 char* /*new*/ g_path_get_dirname(char* file_name);
25358 int g_path_is_absolute(char* file_name);
25359 char* g_path_skip_root(char* file_name);
25360 int g_pattern_match(PatternSpec* pspec, uint string_length, char* string_, char* string_reversed);
25361 int g_pattern_match_simple(char* pattern, char* string_);
25362 int g_pattern_match_string(PatternSpec* pspec, char* string_);
25363 void g_pointer_bit_lock(void* address, int lock_bit);
25364 int g_pointer_bit_trylock(void* address, int lock_bit);
25365 void g_pointer_bit_unlock(void* address, int lock_bit);
25366 int g_poll(PollFD* fds, uint nfds, int timeout);
25367 void g_prefix_error(Error** err, char* format, ...);
25368 void g_print(char* format, ...);
25369 void g_printerr(char* format, ...);
25370 int g_printf(char* format, ...);
25371 size_t g_printf_string_upper_bound(char* format, va_list args);
25372 void g_propagate_error(Error** dest, Error* src);
25373 void g_propagate_prefixed_error(Error** dest, Error* src, char* format, ...);
25374 void g_qsort_with_data(const(void)* pbase, int total_elems, size_t size, CompareDataFunc compare_func, void* user_data);
25375 Quark g_quark_from_static_string(char* string_=null);
25376 Quark g_quark_from_string(char* string_=null);
25377 char* g_quark_to_string(Quark quark);
25378 Quark g_quark_try_string(char* string_=null);
25379 double g_random_double();
25380 double g_random_double_range(double begin, double end);
25381 uint g_random_int();
25382 int g_random_int_range(int begin, int end);
25383 void g_random_set_seed(uint seed);
25384 void* g_realloc(void* mem, size_t n_bytes);
25385 void* g_realloc_n(void* mem, size_t n_blocks, size_t n_block_bytes);
25386 void g_reload_user_special_dirs_cache();
25387 void g_return_if_fail_warning(char* log_domain, char* pretty_function, char* expression);
25388 int g_rmdir(char* filename);
25389 void g_set_application_name(char* application_name);
25390 void g_set_error(Error** err, Quark domain, int code, char* format, ...);
25391 void g_set_error_literal(Error** err, Quark domain, int code, char* message);
25392 void g_set_prgname(char* prgname);
25393 PrintFunc g_set_print_handler(PrintFunc func);
25394 PrintFunc g_set_printerr_handler(PrintFunc func);
25395 int g_setenv(char* variable, char* value, int overwrite);
25396 Quark g_shell_error_quark();
25397 int g_shell_parse_argv(char* command_line, /*out*/ int* argcp, /*out*/ char*** argvp, GLib2.Error** error);
25398 char* /*new*/ g_shell_quote(char* unquoted_string);
25399 char* /*new*/ g_shell_unquote(char* quoted_string, GLib2.Error** error);
25400 void* g_slice_alloc(size_t block_size);
25401 void* g_slice_alloc0(size_t block_size);
25402 void* g_slice_copy(size_t block_size, const(void)* mem_block);
25403 void g_slice_free1(size_t block_size, void* mem_block);
25404 void g_slice_free_chain_with_offset(size_t block_size, void* mem_chain, size_t next_offset);
25405 long g_slice_get_config(SliceConfig ckey);
25406 long* g_slice_get_config_state(SliceConfig ckey, long address, uint* n_values);
25407 void g_slice_set_config(SliceConfig ckey, long value);
25408 int g_snprintf(char* string_, c_ulong n, char* format, ...);
25409 uint g_spaced_primes_closest(uint num);
25410 int g_spawn_async(char* working_directory, char** argv, char** envp, SpawnFlags flags, SpawnChildSetupFunc child_setup, void* user_data, /*out*/ Pid* child_pid, GLib2.Error** error);
25411 int g_spawn_async_with_pipes(char* working_directory, char** argv, char** envp, SpawnFlags flags, SpawnChildSetupFunc child_setup, void* user_data, /*out*/ Pid* child_pid, /*out*/ int* standard_input, /*out*/ int* standard_output, /*out*/ int* standard_error, GLib2.Error** error);
25412 void g_spawn_close_pid(Pid pid);
25413 int g_spawn_command_line_async(char* command_line, GLib2.Error** error);
25414 int g_spawn_command_line_sync(char* command_line, /*out*/ ubyte** standard_output, /*out*/ ubyte** standard_error, /*out*/ int* exit_status, GLib2.Error** error);
25415 Quark g_spawn_error_quark();
25416 int g_spawn_sync(char* working_directory, char** argv, char** envp, SpawnFlags flags, SpawnChildSetupFunc child_setup, void* user_data, /*out*/ ubyte** standard_output, /*out*/ ubyte** standard_error, /*out*/ int* exit_status, GLib2.Error** error);
25417 int g_sprintf(char* string_, char* format, ...);
25418 char* /*new*/ g_stpcpy(char* dest, char* src);
25419 int g_str_equal(const(void)* v1, const(void)* v2);
25420 int g_str_has_prefix(char* str, char* prefix);
25421 int g_str_has_suffix(char* str, char* suffix);
25422 uint g_str_hash(const(void)* v);
25423 char* /*new*/ g_strcanon(char* string_, char* valid_chars, char substitutor);
25424 int g_strcasecmp(char* s1, char* s2);
25425 char* /*new*/ g_strchomp(char* string_);
25426 char* /*new*/ g_strchug(char* string_);
25427 int g_strcmp0(char* str1, char* str2);
25428 char* /*new*/ g_strcompress(char* source);
25429 char* /*new*/ g_strconcat(char* string1, ...);
25430 char* /*new*/ g_strdelimit(char* string_, char* delimiters, char new_delimiter);
25431 char* /*new*/ g_strdown(char* string_);
25432 char* /*new*/ g_strdup(char* str);
25433 char* /*new*/ g_strdup_printf(char* format, ...);
25434 char* /*new*/ g_strdup_vprintf(char* format, va_list args);
25435 char** g_strdupv(char** str_array);
25436 char* g_strerror(int errnum);
25437 char* /*new*/ g_strescape(char* source, char* exceptions);
25438 void g_strfreev(char** str_array);
25439 String* /*new*/ g_string_new(char* init);
25440 String* /*new*/ g_string_new_len(char* init, ssize_t len);
25441 String* /*new*/ g_string_sized_new(size_t dfl_size);
25442 char* g_strip_context(char* msgid, char* msgval);
25443 char* /*new*/ g_strjoin(char* separator, ...);
25444 char* /*new*/ g_strjoinv(char* separator, char** str_array);
25445 size_t g_strlcat(char* dest, char* src, size_t dest_size);
25446 size_t g_strlcpy(char* dest, char* src, size_t dest_size);
25447 int g_strncasecmp(char* s1, char* s2, uint n);
25448 char* /*new*/ g_strndup(char* str, size_t n);
25449 char* /*new*/ g_strnfill(size_t length, char fill_char);
25450 char* /*new*/ g_strreverse(char* string_);
25451 char* /*new*/ g_strrstr(char* haystack, char* needle);
25452 char* /*new*/ g_strrstr_len(char* haystack, ssize_t haystack_len, char* needle);
25453 char* g_strsignal(int signum);
25454 char** g_strsplit(char* string_, char* delimiter, int max_tokens);
25455 char** g_strsplit_set(char* string_, char* delimiters, int max_tokens);
25456 char* /*new*/ g_strstr_len(char* haystack, ssize_t haystack_len, char* needle);
25457 double g_strtod(char* nptr, char** endptr);
25458 char* /*new*/ g_strup(char* string_);
25459 Type g_strv_get_type();
25460 uint g_strv_length(char** str_array);
25461 void g_test_add_data_func(char* testpath, const(void)* test_data, TestDataFunc test_func);
25462 void g_test_add_func(char* testpath, TestFunc test_func);
25463 void g_test_add_vtable(char* testpath, size_t data_size, const(void)* test_data, TestFixtureFunc data_setup, TestFixtureFunc data_test, TestFixtureFunc data_teardown);
25464 void g_test_bug(char* bug_uri_snippet);
25465 void g_test_bug_base(char* uri_pattern);
25466 TestCase* g_test_create_case(char* test_name, size_t data_size, const(void)* test_data, TestFixtureFunc data_setup, TestFixtureFunc data_test, TestFixtureFunc data_teardown);
25467 TestSuite* g_test_create_suite(char* suite_name);
25468 void g_test_fail();
25469 TestSuite* g_test_get_root();
25470 void g_test_init(int* argc, char*** argv, ...);
25471 void g_test_log_set_fatal_handler(TestLogFatalFunc log_func, void* user_data);
25472 char* g_test_log_type_name(TestLogType log_type);
25473 void g_test_maximized_result(double maximized_quantity, char* format, ...);
25474 void g_test_message(char* format, ...);
25475 void g_test_minimized_result(double minimized_quantity, char* format, ...);
25476 void g_test_queue_destroy(DestroyNotify destroy_func, void* destroy_data);
25477 void g_test_queue_free(void* gfree_pointer);
25478 double g_test_rand_double();
25479 double g_test_rand_double_range(double range_start, double range_end);
25480 int g_test_rand_int();
25481 int g_test_rand_int_range(int begin, int end);
25482 int g_test_run();
25483 int g_test_run_suite(TestSuite* suite);
25484 double g_test_timer_elapsed();
25485 double g_test_timer_last();
25486 void g_test_timer_start();
25487 void g_test_trap_assertions(char* domain, char* file, int line, char* func, ulong assertion_flags, char* pattern);
25488 int g_test_trap_fork(ulong usec_timeout, TestTrapFlags test_trap_flags);
25489 int g_test_trap_has_passed();
25490 int g_test_trap_reached_timeout();
25491 uint g_timeout_add(uint interval, SourceFunc function_, void* data);
25492 uint g_timeout_add_full(int priority, uint interval, SourceFunc function_, void* data, DestroyNotify notify);
25493 uint g_timeout_add_seconds(uint interval, SourceFunc function_, void* data);
25494 uint g_timeout_add_seconds_full(int priority, uint interval, SourceFunc function_, void* data, DestroyNotify notify);
25495 Source* /*new*/ g_timeout_source_new(uint interval);
25496 Source* /*new*/ g_timeout_source_new_seconds(uint interval);
25497 void* g_try_malloc(size_t n_bytes);
25498 void* g_try_malloc0(size_t n_bytes);
25499 void* g_try_malloc0_n(size_t n_blocks, size_t n_block_bytes);
25500 void* g_try_malloc_n(size_t n_blocks, size_t n_block_bytes);
25501 void* g_try_realloc(void* mem, size_t n_bytes);
25502 void* g_try_realloc_n(void* mem, size_t n_blocks, size_t n_block_bytes);
25503 wchar* g_ucs4_to_utf16(dchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error);
25504 char* /*new*/ g_ucs4_to_utf8(dchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error);
25505 UnicodeBreakType g_unichar_break_type(dchar c);
25506 int g_unichar_combining_class(dchar uc);
25507 int g_unichar_compose(dchar a, dchar b, dchar* ch);
25508 int g_unichar_decompose(dchar ch, dchar* a, dchar* b);
25509 int g_unichar_digit_value(dchar c);
25510 size_t g_unichar_fully_decompose(dchar ch, int compat, dchar* result, size_t result_len);
25511 int g_unichar_get_mirror_char(dchar ch, dchar* mirrored_ch);
25512 UnicodeScript g_unichar_get_script(dchar ch);
25513 int g_unichar_isalnum(dchar c);
25514 int g_unichar_isalpha(dchar c);
25515 int g_unichar_iscntrl(dchar c);
25516 int g_unichar_isdefined(dchar c);
25517 int g_unichar_isdigit(dchar c);
25518 int g_unichar_isgraph(dchar c);
25519 int g_unichar_islower(dchar c);
25520 int g_unichar_ismark(dchar c);
25521 int g_unichar_isprint(dchar c);
25522 int g_unichar_ispunct(dchar c);
25523 int g_unichar_isspace(dchar c);
25524 int g_unichar_istitle(dchar c);
25525 int g_unichar_isupper(dchar c);
25526 int g_unichar_iswide(dchar c);
25527 int g_unichar_iswide_cjk(dchar c);
25528 int g_unichar_isxdigit(dchar c);
25529 int g_unichar_iszerowidth(dchar c);
25530 int g_unichar_to_utf8(dchar c, char* outbuf);
25531 dchar g_unichar_tolower(dchar c);
25532 dchar g_unichar_totitle(dchar c);
25533 dchar g_unichar_toupper(dchar c);
25534 UnicodeType g_unichar_type(dchar c);
25535 int g_unichar_validate(dchar ch);
25536 int g_unichar_xdigit_value(dchar c);
25537 dchar* g_unicode_canonical_decomposition(dchar ch, size_t* result_len);
25538 void g_unicode_canonical_ordering(dchar* string_, size_t len);
25539 UnicodeScript g_unicode_script_from_iso15924(uint iso15924);
25540 uint g_unicode_script_to_iso15924(UnicodeScript script);
25541 int g_unlink(char* filename);
25542 void g_unsetenv(char* variable);
25543 char* /*new*/ g_uri_escape_string(char* unescaped, char* reserved_chars_allowed, int allow_utf8);
25544 char** g_uri_list_extract_uris(char* uri_list);
25545 char* /*new*/ g_uri_parse_scheme(char* uri);
25546 char* /*new*/ g_uri_unescape_segment(char* escaped_string, char* escaped_string_end, char* illegal_characters);
25547 char* /*new*/ g_uri_unescape_string(char* escaped_string, char* illegal_characters);
25548 void g_usleep(c_ulong microseconds);
25549 dchar* g_utf16_to_ucs4(wchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error);
25550 char* /*new*/ g_utf16_to_utf8(wchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error);
25551 char* /*new*/ g_utf8_casefold(char* str, ssize_t len);
25552 int g_utf8_collate(char* str1, char* str2);
25553 char* /*new*/ g_utf8_collate_key(char* str, ssize_t len);
25554 char* /*new*/ g_utf8_collate_key_for_filename(char* str, ssize_t len);
25555 char* /*new*/ g_utf8_find_next_char(char* p, char* end);
25556 char* /*new*/ g_utf8_find_prev_char(char* str, char* p);
25557 dchar g_utf8_get_char(char* p);
25558 dchar g_utf8_get_char_validated(char* p, ssize_t max_len);
25559 char* /*new*/ g_utf8_normalize(char* str, ssize_t len, NormalizeMode mode);
25560 char* /*new*/ g_utf8_offset_to_pointer(char* str, c_long offset);
25561 c_long g_utf8_pointer_to_offset(char* str, char* pos);
25562 char* /*new*/ g_utf8_prev_char(char* p);
25563 char* /*new*/ g_utf8_strchr(char* p, ssize_t len, dchar c);
25564 char* /*new*/ g_utf8_strdown(char* str, ssize_t len);
25565 c_long g_utf8_strlen(char* p, ssize_t max);
25566 char* /*new*/ g_utf8_strncpy(char* dest, char* src, size_t n);
25567 char* /*new*/ g_utf8_strrchr(char* p, ssize_t len, dchar c);
25568 char* /*new*/ g_utf8_strreverse(char* str, ssize_t len);
25569 char* /*new*/ g_utf8_strup(char* str, ssize_t len);
25570 char* /*new*/ g_utf8_substring(char* str, c_long start_pos, c_long end_pos);
25571 dchar* g_utf8_to_ucs4(char* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error);
25572 dchar* g_utf8_to_ucs4_fast(char* str, c_long len, c_long* items_written);
25573 wchar* g_utf8_to_utf16(char* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error);
25574 int g_utf8_validate(char* str, ssize_t max_len, /*out*/ char** end=null);
25575 Type g_variant_get_gtype();
25576 VariantType* g_variant_get_type(Variant* value);
25577 int g_vasprintf(char** string_, char* format, va_list args);
25578 int g_vfprintf(FILE* file, char* format, va_list args);
25579 int g_vprintf(char* format, va_list args);
25580 int g_vsnprintf(char* string_, c_ulong n, char* format, va_list args);
25581 int g_vsprintf(char* string_, char* format, va_list args);
25582 void g_warn_message(char* domain, char* file, int line, char* func, char* warnexpr);