Mx support.
[girtod.git] / gtk2 / glib2.d
blob8ddef79af7856cdb42cef4bf3c9cf228d934d7c0
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 ---
95 alias ubyte DateDay;
96 alias ushort DateYear;
98 // A type which is used to hold a process identification.
99 //
100 // On UNIX, processes are identified by a process id (an integer),
101 // while Windows uses process handles (which are pointers).
102 alias int Pid;
104 // A GQuark is a non-zero integer which uniquely identifies a
105 // particular string. A GQuark value of zero is associated to %NULL.
106 alias uint Quark;
107 // A C representable type name for #G_TYPE_STRV.
108 alias void* Strv;
109 alias int Time;
110 // A value representing an interval of time, in microseconds.
111 alias long TimeSpan;
113 // A numerical value which represents the unique identifier of a registered
114 // type.
115 alias size_t Type;
116 enum int ALLOCATOR_LIST = 1;
117 enum int ALLOCATOR_NODE = 3;
118 enum int ALLOCATOR_SLIST = 2;
119 enum int ALLOC_AND_FREE = 2;
120 enum int ALLOC_ONLY = 1;
121 enum int ASCII_DTOSTR_BUF_SIZE = 39;
122 enum int ATOMIC_OP_USE_GCC_BUILTINS = 1;
124 // The #GAllocator struct contains private data. and should only be
125 // accessed using the following functions.
126 struct Allocator {
128 // Frees all of the memory allocated by the #GAllocator.
130 // Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
131 // allocator</link> instead
132 void free()() {
133 g_allocator_free(&this);
136 // Unintrospectable function: new() / g_allocator_new()
137 // Creates a new #GAllocator.
139 // Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
140 // allocator</link> instead
141 // <name>: the name of the #GAllocator. This name is used to set the name of the #GMemChunk used by the #GAllocator, and is only used for debugging.
142 // <n_preallocs>: the number of elements in each block of memory allocated. Larger blocks mean less calls to g_malloc(), but some memory may be wasted. (GLib uses 128 elements per block by default.) The value must be between 1 and 65535.
143 static Allocator* new_()(char* name, uint n_preallocs) {
144 return g_allocator_new(name, n_preallocs);
148 // Contains the public fields of an <link linkend="glib-Arrays">Array</link>.
149 struct Array {
150 char* data;
151 uint len;
154 // Unintrospectable function: append_vals() / g_array_append_vals()
155 // Adds @len elements onto the end of the array.
156 // <array>: a #GArray.
157 // <data>: a pointer to the elements to append to the end of the array.
158 // <len>: the number of elements to append.
159 static Array* append_vals()(Array* array, const(void)* data, uint len) {
160 return g_array_append_vals(array, data, len);
163 // Frees the memory allocated for the #GArray. If @free_segment is
164 // %TRUE it frees the memory block holding the elements as well and
165 // also each element if @array has a @element_free_func set. Pass
166 // %FALSE if you want to free the #GArray wrapper but preserve the
167 // underlying array for use elsewhere. If the reference count of @array
168 // is greater than one, the #GArray wrapper is preserved but the size
169 // of @array will be set to zero.
171 // <note><para>If array elements contain dynamically-allocated memory,
172 // they should be freed separately.</para></note>
173 // <array>: a #GArray.
174 // <free_segment>: if %TRUE the actual element data is freed as well.
175 static char* /*new*/ free()(Array* array, int free_segment) {
176 return g_array_free(array, free_segment);
179 // VERSION: 2.22
180 // Gets the size of the elements in @array.
181 // RETURNS: Size of each element, in bytes.
182 // <array>: A #GArray.
183 static uint get_element_size()(Array* array) {
184 return g_array_get_element_size(array);
187 // Unintrospectable function: insert_vals() / g_array_insert_vals()
188 // Inserts @len elements into a #GArray at the given index.
189 // <array>: a #GArray.
190 // <index_>: the index to place the elements at.
191 // <data>: a pointer to the elements to insert.
192 // <len>: the number of elements to insert.
193 static Array* insert_vals()(Array* array, uint index_, const(void)* data, uint len) {
194 return g_array_insert_vals(array, index_, data, len);
197 // Unintrospectable function: new() / g_array_new()
198 // Creates a new #GArray with a reference count of 1.
199 // <zero_terminated>: %TRUE if the array should have an extra element at the end which is set to 0.
200 // <clear_>: %TRUE if #GArray elements should be automatically cleared to 0 when they are allocated.
201 // <element_size>: the size of each element in bytes.
202 static Array* new_()(int zero_terminated, int clear_, uint element_size) {
203 return g_array_new(zero_terminated, clear_, element_size);
206 // Unintrospectable function: prepend_vals() / g_array_prepend_vals()
207 // Adds @len elements onto the start of the array.
209 // This operation is slower than g_array_append_vals() since the
210 // existing elements in the array have to be moved to make space for
211 // the new elements.
212 // <array>: a #GArray.
213 // <data>: a pointer to the elements to prepend to the start of the array.
214 // <len>: the number of elements to prepend.
215 static Array* prepend_vals()(Array* array, const(void)* data, uint len) {
216 return g_array_prepend_vals(array, data, len);
219 // Unintrospectable function: ref() / g_array_ref()
220 // VERSION: 2.22
221 // Atomically increments the reference count of @array by one. This
222 // function is MT-safe and may be called from any thread.
223 // RETURNS: The passed in #GArray.
224 // <array>: A #GArray.
225 static Array* ref_()(Array* array) {
226 return g_array_ref(array);
229 // Unintrospectable function: remove_index() / g_array_remove_index()
230 // Removes the element at the given index from a #GArray. The following
231 // elements are moved down one place.
232 // <array>: a #GArray.
233 // <index_>: the index of the element to remove.
234 static Array* remove_index()(Array* array, uint index_) {
235 return g_array_remove_index(array, index_);
238 // Unintrospectable function: remove_index_fast() / g_array_remove_index_fast()
239 // Removes the element at the given index from a #GArray. The last
240 // element in the array is used to fill in the space, so this function
241 // does not preserve the order of the #GArray. But it is faster than
242 // g_array_remove_index().
243 // <array>: a @GArray.
244 // <index_>: the index of the element to remove.
245 static Array* remove_index_fast()(Array* array, uint index_) {
246 return g_array_remove_index_fast(array, index_);
249 // Unintrospectable function: remove_range() / g_array_remove_range()
250 // VERSION: 2.4
251 // Removes the given number of elements starting at the given index
252 // from a #GArray. The following elements are moved to close the gap.
253 // <array>: a @GArray.
254 // <index_>: the index of the first element to remove.
255 // <length>: the number of elements to remove.
256 static Array* remove_range()(Array* array, uint index_, uint length) {
257 return g_array_remove_range(array, index_, length);
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 &#8211; i.e.
290 // you want a stable sort &#8211; 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, negative values mean waiting
340 // threads, positive values mean available entries in the
341 // @queue. Actually this function returns the number of data items in
342 // the queue minus the number of waiting threads. Thus a return value
343 // of 0 could mean 'n' entries in the queue and 'n' thread waiting.
344 // That can happen due to locking of the queue or due to
345 // scheduling.
346 // RETURNS: the length of the @queue.
347 int length()() {
348 return g_async_queue_length(&this);
351 // Returns the length of the queue, negative values mean waiting
352 // threads, positive values mean available entries in the
353 // @queue. Actually this function returns the number of data items in
354 // the queue minus the number of waiting threads. Thus a return value
355 // of 0 could mean 'n' entries in the queue and 'n' thread waiting.
356 // That can happen due to locking of the queue or due to
357 // scheduling. This function must be called while holding the @queue's
358 // lock.
359 // RETURNS: the length of the @queue.
360 int length_unlocked()() {
361 return g_async_queue_length_unlocked(&this);
364 // Acquires the @queue's lock. After that you can only call the
365 // <function>g_async_queue_*_unlocked()</function> function variants on that
366 // @queue. Otherwise it will deadlock.
367 void lock()() {
368 g_async_queue_lock(&this);
371 // Unintrospectable method: pop() / g_async_queue_pop()
372 // Pops data from the @queue. This function blocks until data become
373 // available.
374 // RETURNS: data from the queue.
375 void* pop()() {
376 return g_async_queue_pop(&this);
379 // Unintrospectable method: pop_unlocked() / g_async_queue_pop_unlocked()
380 // Pops data from the @queue. This function blocks until data become
381 // available. This function must be called while holding the @queue's
382 // lock.
383 // RETURNS: data from the queue.
384 void* pop_unlocked()() {
385 return g_async_queue_pop_unlocked(&this);
388 // Pushes the @data into the @queue. @data must not be %NULL.
389 // <data>: @data to push into the @queue.
390 void push()(void* data) {
391 g_async_queue_push(&this, data);
394 // Unintrospectable method: push_sorted() / g_async_queue_push_sorted()
395 // VERSION: 2.10
396 // Inserts @data into @queue using @func to determine the new
397 // position.
399 // This function requires that the @queue is sorted before pushing on
400 // new elements.
402 // This function will lock @queue before it sorts the queue and unlock
403 // it when it is finished.
405 // For an example of @func see g_async_queue_sort().
406 // <data>: the @data to push into the @queue
407 // <func>: the #GCompareDataFunc is used to sort @queue. This function is passed two elements of the @queue. The function should return 0 if they are equal, a negative value if the first element should be higher in the @queue or a positive value if the first element should be lower in the @queue than the second element.
408 // <user_data>: user data passed to @func.
409 void push_sorted()(void* data, CompareDataFunc func, void* user_data) {
410 g_async_queue_push_sorted(&this, data, func, user_data);
413 // Unintrospectable method: push_sorted_unlocked() / g_async_queue_push_sorted_unlocked()
414 // VERSION: 2.10
415 // Inserts @data into @queue using @func to determine the new
416 // position.
418 // This function requires that the @queue is sorted before pushing on
419 // new elements.
421 // This function is called while holding the @queue's lock.
423 // For an example of @func see g_async_queue_sort().
424 // <data>: the @data to push into the @queue
425 // <func>: the #GCompareDataFunc is used to sort @queue. This function is passed two elements of the @queue. The function should return 0 if they are equal, a negative value if the first element should be higher in the @queue or a positive value if the first element should be lower in the @queue than the second element.
426 // <user_data>: user data passed to @func.
427 void push_sorted_unlocked()(void* data, CompareDataFunc func, void* user_data) {
428 g_async_queue_push_sorted_unlocked(&this, data, func, user_data);
431 // Pushes the @data into the @queue. @data must not be %NULL. This
432 // function must be called while holding the @queue's lock.
433 // <data>: @data to push into the @queue.
434 void push_unlocked()(void* data) {
435 g_async_queue_push_unlocked(&this, data);
438 // Unintrospectable method: ref() / g_async_queue_ref()
439 // Increases the reference count of the asynchronous @queue by 1. You
440 // do not need to hold the lock to call this function.
441 // RETURNS: the @queue that was passed in (since 2.6)
442 AsyncQueue* ref_()() {
443 return g_async_queue_ref(&this);
446 // Increases the reference count of the asynchronous @queue by 1.
448 // so g_async_queue_ref() can be used regardless of the @queue's
449 // lock.
450 void ref_unlocked()() {
451 g_async_queue_ref_unlocked(&this);
454 // Unintrospectable method: sort() / g_async_queue_sort()
455 // VERSION: 2.10
456 // Sorts @queue using @func.
458 // This function will lock @queue before it sorts the queue and unlock
459 // it when it is finished.
461 // If you were sorting a list of priority numbers to make sure the
462 // lowest priority would be at the top of the queue, you could use:
463 // |[
464 // gint32 id1;
465 // gint32 id2;
467 // id1 = GPOINTER_TO_INT (element1);
468 // id2 = GPOINTER_TO_INT (element2);
470 // return (id1 > id2 ? +1 : id1 == id2 ? 0 : -1);
471 // ]|
472 // <func>: the #GCompareDataFunc is used to sort @queue. This function is passed two elements of the @queue. The function should return 0 if they are equal, a negative value if the first element should be higher in the @queue or a positive value if the first element should be lower in the @queue than the second element.
473 // <user_data>: user data passed to @func
474 void sort()(CompareDataFunc func, void* user_data) {
475 g_async_queue_sort(&this, func, user_data);
478 // Unintrospectable method: sort_unlocked() / g_async_queue_sort_unlocked()
479 // VERSION: 2.10
480 // Sorts @queue using @func.
482 // This function is called while holding the @queue's lock.
483 // <func>: the #GCompareDataFunc is used to sort @queue. This function is passed two elements of the @queue. The function should return 0 if they are equal, a negative value if the first element should be higher in the @queue or a positive value if the first element should be lower in the @queue than the second element.
484 // <user_data>: user data passed to @func
485 void sort_unlocked()(CompareDataFunc func, void* user_data) {
486 g_async_queue_sort_unlocked(&this, func, user_data);
489 // Unintrospectable method: timed_pop() / g_async_queue_timed_pop()
490 // Pops data from the @queue. If no data is received before @end_time,
491 // %NULL is returned.
493 // To easily calculate @end_time a combination of g_get_current_time()
494 // and g_time_val_add() can be used.
496 // received before @end_time.
497 // RETURNS: data from the queue or %NULL, when no data is
498 // <end_time>: a #GTimeVal, determining the final time.
499 void* timed_pop()(TimeVal* end_time) {
500 return g_async_queue_timed_pop(&this, end_time);
503 // Unintrospectable method: timed_pop_unlocked() / g_async_queue_timed_pop_unlocked()
504 // Pops data from the @queue. If no data is received before @end_time,
505 // %NULL is returned. This function must be called while holding the
506 // @queue's lock.
508 // To easily calculate @end_time a combination of g_get_current_time()
509 // and g_time_val_add() can be used.
511 // received before @end_time.
512 // RETURNS: data from the queue or %NULL, when no data is
513 // <end_time>: a #GTimeVal, determining the final time.
514 void* timed_pop_unlocked()(TimeVal* end_time) {
515 return g_async_queue_timed_pop_unlocked(&this, end_time);
518 // Unintrospectable method: try_pop() / g_async_queue_try_pop()
519 // Tries to pop data from the @queue. If no data is available, %NULL is
520 // returned.
522 // available immediately.
523 // RETURNS: data from the queue or %NULL, when no data is
524 void* try_pop()() {
525 return g_async_queue_try_pop(&this);
528 // Unintrospectable method: try_pop_unlocked() / g_async_queue_try_pop_unlocked()
529 // Tries to pop data from the @queue. If no data is available, %NULL is
530 // returned. This function must be called while holding the @queue's
531 // lock.
533 // available immediately.
534 // RETURNS: data from the queue or %NULL, when no data is
535 void* try_pop_unlocked()() {
536 return g_async_queue_try_pop_unlocked(&this);
538 // Releases the queue's lock.
539 void unlock()() {
540 g_async_queue_unlock(&this);
543 // Decreases the reference count of the asynchronous @queue by 1. If
544 // the reference count went to 0, the @queue will be destroyed and the
545 // memory allocated will be freed. So you are not allowed to use the
546 // @queue afterwards, as it might have disappeared. You do not need to
547 // hold the lock to call this function.
548 void unref()() {
549 g_async_queue_unref(&this);
552 // Decreases the reference count of the asynchronous @queue by 1 and
553 // releases the lock. This function must be called while holding the
554 // @queue's lock. If the reference count went to 0, the @queue will be
555 // destroyed and the memory allocated will be freed.
557 // so g_async_queue_unref() can be used regardless of the @queue's
558 // lock.
559 void unref_and_unlock()() {
560 g_async_queue_unref_and_unlock(&this);
563 // Unintrospectable function: new() / g_async_queue_new()
564 // Creates a new asynchronous queue with the initial reference count of 1.
565 // RETURNS: the new #GAsyncQueue.
566 static AsyncQueue* new_()() {
567 return g_async_queue_new();
570 // Unintrospectable function: new_full() / g_async_queue_new_full()
571 // VERSION: 2.16
572 // Creates a new asynchronous queue with an initial reference count of 1 and
573 // sets up a destroy notify function that is used to free any remaining
574 // queue items when the queue is destroyed after the final unref.
575 // RETURNS: the new #GAsyncQueue.
576 // <item_free_func>: function to free queue elements
577 static AsyncQueue* new_full()(DestroyNotify item_free_func) {
578 return g_async_queue_new_full(item_free_func);
582 enum int BIG_ENDIAN = 4321;
584 // The <structname>GBookmarkFile</structname> struct contains only
585 // private data and should not be directly accessed.
586 struct BookmarkFile {
588 // VERSION: 2.12
589 // Adds the application with @name and @exec to the list of
590 // applications that have registered a bookmark for @uri into
591 // @bookmark.
593 // Every bookmark inside a #GBookmarkFile must have at least an
594 // application registered. Each application must provide a name, a
595 // command line useful for launching the bookmark, the number of times
596 // the bookmark has been registered by the application and the last
597 // time the application registered this bookmark.
599 // If @name is %NULL, the name of the application will be the
600 // same returned by g_get_application_name(); if @exec is %NULL, the
601 // command line will be a composition of the program name as
602 // returned by g_get_prgname() and the "%u" modifier, which will be
603 // expanded to the bookmark's URI.
605 // This function will automatically take care of updating the
606 // registrations count and timestamping in case an application
607 // with the same @name had already registered a bookmark for
608 // @uri inside @bookmark.
610 // If no bookmark for @uri is found, one is created.
611 // <uri>: a valid URI
612 // <name>: the name of the application registering the bookmark or %NULL
613 // <exec>: command line to be used to launch the bookmark or %NULL
614 void add_application()(char* uri, char* name, char* exec) {
615 g_bookmark_file_add_application(&this, uri, name, exec);
618 // VERSION: 2.12
619 // Adds @group to the list of groups to which the bookmark for @uri
620 // belongs to.
622 // If no bookmark for @uri is found then it is created.
623 // <uri>: a valid URI
624 // <group>: the group name to be added
625 void add_group()(char* uri, char* group) {
626 g_bookmark_file_add_group(&this, uri, group);
629 // VERSION: 2.12
630 // Frees a #GBookmarkFile.
631 void free()() {
632 g_bookmark_file_free(&this);
635 // VERSION: 2.12
636 // Gets the time the bookmark for @uri was added to @bookmark
638 // In the event the URI cannot be found, -1 is returned and
639 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
640 // RETURNS: a timestamp
641 // <uri>: a valid URI
642 time_t get_added()(char* uri, GLib2.Error** error=null) {
643 return g_bookmark_file_get_added(&this, uri, error);
646 // VERSION: 2.12
647 // Gets the registration informations of @app_name for the bookmark for
648 // @uri. See g_bookmark_file_set_app_info() for more informations about
649 // the returned data.
651 // The string returned in @app_exec must be freed.
653 // In the event the URI cannot be found, %FALSE is returned and
654 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the
655 // event that no application with name @app_name has registered a bookmark
656 // for @uri, %FALSE is returned and error is set to
657 // #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. In the event that unquoting
658 // the command line fails, an error of the #G_SHELL_ERROR domain is
659 // set and %FALSE is returned.
660 // RETURNS: %TRUE on success.
661 // <uri>: a valid URI
662 // <name>: an application's name
663 // <exec>: location for the command line of the application, or %NULL
664 // <count>: return location for the registration count, or %NULL
665 // <stamp>: return location for the last registration time, or %NULL
666 int get_app_info()(char* uri, char* name, char** exec, uint* count, time_t* stamp, GLib2.Error** error=null) {
667 return g_bookmark_file_get_app_info(&this, uri, name, exec, count, stamp, error);
670 // Unintrospectable method: get_applications() / g_bookmark_file_get_applications()
671 // VERSION: 2.12
672 // Retrieves the names of the applications that have registered the
673 // bookmark for @uri.
675 // In the event the URI cannot be found, %NULL is returned and
676 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
678 // Use g_strfreev() to free it.
679 // RETURNS: a newly allocated %NULL-terminated array of strings.
680 // <uri>: a valid URI
681 // <length>: return location of the length of the returned list, or %NULL
682 char** get_applications()(char* uri, size_t* length, GLib2.Error** error=null) {
683 return g_bookmark_file_get_applications(&this, uri, length, error);
686 // VERSION: 2.12
687 // Retrieves the description of the bookmark for @uri.
689 // In the event the URI cannot be found, %NULL is returned and
690 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
692 // URI cannot be found.
693 // RETURNS: a newly allocated string or %NULL if the specified
694 // <uri>: a valid URI
695 char* /*new*/ get_description()(char* uri, GLib2.Error** error=null) {
696 return g_bookmark_file_get_description(&this, uri, error);
699 // Unintrospectable method: get_groups() / g_bookmark_file_get_groups()
700 // VERSION: 2.12
701 // Retrieves the list of group names of the bookmark for @uri.
703 // In the event the URI cannot be found, %NULL is returned and
704 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
706 // The returned array is %NULL terminated, so @length may optionally
707 // be %NULL.
709 // Use g_strfreev() to free it.
710 // RETURNS: a newly allocated %NULL-terminated array of group names.
711 // <uri>: a valid URI
712 // <length>: return location for the length of the returned string, or %NULL
713 char** get_groups()(char* uri, size_t* length, GLib2.Error** error=null) {
714 return g_bookmark_file_get_groups(&this, uri, length, error);
717 // VERSION: 2.12
718 // Gets the icon of the bookmark for @uri.
720 // In the event the URI cannot be found, %FALSE is returned and
721 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
723 // You should free the returned strings.
724 // RETURNS: %TRUE if the icon for the bookmark for the URI was found.
725 // <uri>: a valid URI
726 // <href>: return location for the icon's location or %NULL
727 // <mime_type>: return location for the icon's MIME type or %NULL
728 int get_icon()(char* uri, char** href, char** mime_type, GLib2.Error** error=null) {
729 return g_bookmark_file_get_icon(&this, uri, href, mime_type, error);
732 // VERSION: 2.12
733 // Gets whether the private flag of the bookmark for @uri is set.
735 // In the event the URI cannot be found, %FALSE is returned and
736 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the
737 // event that the private flag cannot be found, %FALSE is returned and
738 // @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
739 // RETURNS: %TRUE if the private flag is set, %FALSE otherwise.
740 // <uri>: a valid URI
741 int get_is_private()(char* uri, GLib2.Error** error=null) {
742 return g_bookmark_file_get_is_private(&this, uri, error);
745 // VERSION: 2.12
746 // Retrieves the MIME type of the resource pointed by @uri.
748 // In the event the URI cannot be found, %NULL is returned and
749 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the
750 // event that the MIME type cannot be found, %NULL is returned and
751 // @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
753 // URI cannot be found.
754 // RETURNS: a newly allocated string or %NULL if the specified
755 // <uri>: a valid URI
756 char* /*new*/ get_mime_type()(char* uri, GLib2.Error** error=null) {
757 return g_bookmark_file_get_mime_type(&this, uri, error);
760 // VERSION: 2.12
761 // Gets the time when the bookmark for @uri was last modified.
763 // In the event the URI cannot be found, -1 is returned and
764 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
765 // RETURNS: a timestamp
766 // <uri>: a valid URI
767 time_t get_modified()(char* uri, GLib2.Error** error=null) {
768 return g_bookmark_file_get_modified(&this, uri, error);
771 // VERSION: 2.12
772 // Gets the number of bookmarks inside @bookmark.
773 // RETURNS: the number of bookmarks
774 int get_size()() {
775 return g_bookmark_file_get_size(&this);
778 // VERSION: 2.12
779 // Returns the title of the bookmark for @uri.
781 // If @uri is %NULL, the title of @bookmark is returned.
783 // In the event the URI cannot be found, %NULL is returned and
784 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
786 // URI cannot be found.
787 // RETURNS: a newly allocated string or %NULL if the specified
788 // <uri>: a valid URI or %NULL
789 char* /*new*/ get_title()(char* uri, GLib2.Error** error=null) {
790 return g_bookmark_file_get_title(&this, uri, error);
793 // Unintrospectable method: get_uris() / g_bookmark_file_get_uris()
794 // VERSION: 2.12
795 // Returns all URIs of the bookmarks in the bookmark file @bookmark.
796 // The array of returned URIs will be %NULL-terminated, so @length may
797 // optionally be %NULL.
799 // Use g_strfreev() to free it.
800 // RETURNS: a newly allocated %NULL-terminated array of strings.
801 // <length>: return location for the number of returned URIs, or %NULL
802 char** get_uris()(size_t* length) {
803 return g_bookmark_file_get_uris(&this, length);
806 // VERSION: 2.12
807 // Gets the time the bookmark for @uri was last visited.
809 // In the event the URI cannot be found, -1 is returned and
810 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
811 // RETURNS: a timestamp.
812 // <uri>: a valid URI
813 time_t get_visited()(char* uri, GLib2.Error** error=null) {
814 return g_bookmark_file_get_visited(&this, uri, error);
817 // VERSION: 2.12
818 // Checks whether the bookmark for @uri inside @bookmark has been
819 // registered by application @name.
821 // In the event the URI cannot be found, %FALSE is returned and
822 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
823 // RETURNS: %TRUE if the application @name was found
824 // <uri>: a valid URI
825 // <name>: the name of the application
826 int has_application()(char* uri, char* name, GLib2.Error** error=null) {
827 return g_bookmark_file_has_application(&this, uri, name, error);
830 // VERSION: 2.12
831 // Checks whether @group appears in the list of groups to which
832 // the bookmark for @uri belongs to.
834 // In the event the URI cannot be found, %FALSE is returned and
835 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
836 // RETURNS: %TRUE if @group was found.
837 // <uri>: a valid URI
838 // <group>: the group name to be searched
839 int has_group()(char* uri, char* group, GLib2.Error** error=null) {
840 return g_bookmark_file_has_group(&this, uri, group, error);
843 // VERSION: 2.12
844 // Looks whether the desktop bookmark has an item with its URI set to @uri.
845 // RETURNS: %TRUE if @uri is inside @bookmark, %FALSE otherwise
846 // <uri>: a valid URI
847 int has_item()(char* uri) {
848 return g_bookmark_file_has_item(&this, uri);
851 // VERSION: 2.12
852 // Loads a bookmark file from memory into an empty #GBookmarkFile
853 // structure. If the object cannot be created then @error is set to a
854 // #GBookmarkFileError.
855 // RETURNS: %TRUE if a desktop bookmark could be loaded.
856 // <data>: desktop bookmarks loaded in memory
857 // <length>: the length of @data in bytes
858 int load_from_data()(char* data, size_t length, GLib2.Error** error=null) {
859 return g_bookmark_file_load_from_data(&this, data, length, error);
862 // VERSION: 2.12
863 // This function looks for a desktop bookmark file named @file in the
864 // paths returned from g_get_user_data_dir() and g_get_system_data_dirs(),
865 // loads the file into @bookmark and returns the file's full path in
866 // @full_path. If the file could not be loaded then an %error is
867 // set to either a #GFileError or #GBookmarkFileError.
868 // RETURNS: %TRUE if a key file could be loaded, %FALSE othewise
869 // <file>: a relative path to a filename to open and parse
870 // <full_path>: return location for a string containing the full path of the file, or %NULL
871 int load_from_data_dirs()(char* file, char** full_path, GLib2.Error** error=null) {
872 return g_bookmark_file_load_from_data_dirs(&this, file, full_path, error);
875 // VERSION: 2.12
876 // Loads a desktop bookmark file into an empty #GBookmarkFile structure.
877 // If the file could not be loaded then @error is set to either a #GFileError
878 // or #GBookmarkFileError.
879 // RETURNS: %TRUE if a desktop bookmark file could be loaded
880 // <filename>: the path of a filename to load, in the GLib file name encoding
881 int load_from_file()(char* filename, GLib2.Error** error=null) {
882 return g_bookmark_file_load_from_file(&this, filename, error);
885 // VERSION: 2.12
886 // Changes the URI of a bookmark item from @old_uri to @new_uri. Any
887 // existing bookmark for @new_uri will be overwritten. If @new_uri is
888 // %NULL, then the bookmark is removed.
890 // In the event the URI cannot be found, %FALSE is returned and
891 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
892 // RETURNS: %TRUE if the URI was successfully changed
893 // <old_uri>: a valid URI
894 // <new_uri>: a valid URI, or %NULL
895 int move_item()(char* old_uri, char* new_uri, GLib2.Error** error=null) {
896 return g_bookmark_file_move_item(&this, old_uri, new_uri, error);
899 // VERSION: 2.12
900 // Removes application registered with @name from the list of applications
901 // that have registered a bookmark for @uri inside @bookmark.
903 // In the event the URI cannot be found, %FALSE is returned and
904 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
905 // In the event that no application with name @app_name has registered
906 // a bookmark for @uri, %FALSE is returned and error is set to
907 // #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED.
908 // RETURNS: %TRUE if the application was successfully removed.
909 // <uri>: a valid URI
910 // <name>: the name of the application
911 int remove_application()(char* uri, char* name, GLib2.Error** error=null) {
912 return g_bookmark_file_remove_application(&this, uri, name, error);
915 // VERSION: 2.12
916 // Removes @group from the list of groups to which the bookmark
917 // for @uri belongs to.
919 // In the event the URI cannot be found, %FALSE is returned and
920 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
921 // In the event no group was defined, %FALSE is returned and
922 // @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
923 // RETURNS: %TRUE if @group was successfully removed.
924 // <uri>: a valid URI
925 // <group>: the group name to be removed
926 int remove_group()(char* uri, char* group, GLib2.Error** error=null) {
927 return g_bookmark_file_remove_group(&this, uri, group, error);
930 // VERSION: 2.12
931 // Removes the bookmark for @uri from the bookmark file @bookmark.
932 // RETURNS: %TRUE if the bookmark was removed successfully.
933 // <uri>: a valid URI
934 int remove_item()(char* uri, GLib2.Error** error=null) {
935 return g_bookmark_file_remove_item(&this, uri, error);
938 // VERSION: 2.12
939 // Sets the time the bookmark for @uri was added into @bookmark.
941 // If no bookmark for @uri is found then it is created.
942 // <uri>: a valid URI
943 // <added>: a timestamp or -1 to use the current time
944 void set_added()(char* uri, time_t added) {
945 g_bookmark_file_set_added(&this, uri, added);
948 // VERSION: 2.12
949 // Sets the meta-data of application @name inside the list of
950 // applications that have registered a bookmark for @uri inside
951 // @bookmark.
953 // You should rarely use this function; use g_bookmark_file_add_application()
954 // and g_bookmark_file_remove_application() instead.
956 // @name can be any UTF-8 encoded string used to identify an
957 // application.
958 // be expanded as the local file name retrieved from the bookmark's
959 // URI; "%u", which will be expanded as the bookmark's URI.
960 // The expansion is done automatically when retrieving the stored
961 // command line using the g_bookmark_file_get_app_info() function.
962 // @count is the number of times the application has registered the
963 // bookmark; if is < 0, the current registration count will be increased
964 // by one, if is 0, the application with @name will be removed from
965 // the list of registered applications.
966 // @stamp is the Unix time of the last registration; if it is -1, the
967 // current time will be used.
969 // If you try to remove an application by setting its registration count to
970 // zero, and no bookmark for @uri is found, %FALSE is returned and
971 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND; similarly,
972 // in the event that no application @name has registered a bookmark
973 // for @uri, %FALSE is returned and error is set to
974 // #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. Otherwise, if no bookmark
975 // for @uri is found, one is created.
977 // changed.
978 // RETURNS: %TRUE if the application's meta-data was successfully
979 // <uri>: a valid URI
980 // <name>: an application's name
981 // <exec>: an application's command line
982 // <count>: the number of registrations done for this application
983 // <stamp>: the time of the last registration for this application
984 int set_app_info()(char* uri, char* name, char* exec, int count, time_t stamp, GLib2.Error** error=null) {
985 return g_bookmark_file_set_app_info(&this, uri, name, exec, count, stamp, error);
988 // VERSION: 2.12
989 // Sets @description as the description of the bookmark for @uri.
991 // If @uri is %NULL, the description of @bookmark is set.
993 // If a bookmark for @uri cannot be found then it is created.
994 // <uri>: a valid URI or %NULL
995 // <description>: a string
996 void set_description()(char* uri, char* description) {
997 g_bookmark_file_set_description(&this, uri, description);
1000 // VERSION: 2.12
1001 // Sets a list of group names for the item with URI @uri. Each previously
1002 // set group name list is removed.
1004 // If @uri cannot be found then an item for it is created.
1005 // <uri>: an item's URI
1006 // <groups>: an array of group names, or %NULL to remove all groups
1007 // <length>: number of group name values in @groups
1008 void set_groups()(char* uri, char** groups, size_t length) {
1009 g_bookmark_file_set_groups(&this, uri, groups, length);
1012 // VERSION: 2.12
1013 // Sets the icon for the bookmark for @uri. If @href is %NULL, unsets
1014 // the currently set icon. @href can either be a full URL for the icon
1015 // file or the icon name following the Icon Naming specification.
1017 // If no bookmark for @uri is found one is created.
1018 // <uri>: a valid URI
1019 // <href>: the URI of the icon for the bookmark, or %NULL
1020 // <mime_type>: the MIME type of the icon for the bookmark
1021 void set_icon()(char* uri, char* href, char* mime_type) {
1022 g_bookmark_file_set_icon(&this, uri, href, mime_type);
1025 // VERSION: 2.12
1026 // Sets the private flag of the bookmark for @uri.
1028 // If a bookmark for @uri cannot be found then it is created.
1029 // <uri>: a valid URI
1030 // <is_private>: %TRUE if the bookmark should be marked as private
1031 void set_is_private()(char* uri, int is_private) {
1032 g_bookmark_file_set_is_private(&this, uri, is_private);
1035 // VERSION: 2.12
1036 // Sets @mime_type as the MIME type of the bookmark for @uri.
1038 // If a bookmark for @uri cannot be found then it is created.
1039 // <uri>: a valid URI
1040 // <mime_type>: a MIME type
1041 void set_mime_type()(char* uri, char* mime_type) {
1042 g_bookmark_file_set_mime_type(&this, uri, mime_type);
1045 // VERSION: 2.12
1046 // Sets the last time the bookmark for @uri was last modified.
1048 // If no bookmark for @uri is found then it is created.
1050 // The "modified" time should only be set when the bookmark's meta-data
1051 // was actually changed. Every function of #GBookmarkFile that
1052 // modifies a bookmark also changes the modification time, except for
1053 // g_bookmark_file_set_visited().
1054 // <uri>: a valid URI
1055 // <modified>: a timestamp or -1 to use the current time
1056 void set_modified()(char* uri, time_t modified) {
1057 g_bookmark_file_set_modified(&this, uri, modified);
1060 // VERSION: 2.12
1061 // Sets @title as the title of the bookmark for @uri inside the
1062 // bookmark file @bookmark.
1064 // If @uri is %NULL, the title of @bookmark is set.
1066 // If a bookmark for @uri cannot be found then it is created.
1067 // <uri>: a valid URI or %NULL
1068 // <title>: a UTF-8 encoded string
1069 void set_title()(char* uri, char* title) {
1070 g_bookmark_file_set_title(&this, uri, title);
1073 // VERSION: 2.12
1074 // Sets the time the bookmark for @uri was last visited.
1076 // If no bookmark for @uri is found then it is created.
1078 // The "visited" time should only be set if the bookmark was launched,
1079 // either using the command line retrieved by g_bookmark_file_get_app_info()
1080 // or by the default application for the bookmark's MIME type, retrieved
1081 // using g_bookmark_file_get_mime_type(). Changing the "visited" time
1082 // does not affect the "modified" time.
1083 // <uri>: a valid URI
1084 // <visited>: a timestamp or -1 to use the current time
1085 void set_visited()(char* uri, time_t visited) {
1086 g_bookmark_file_set_visited(&this, uri, visited);
1089 // VERSION: 2.12
1090 // This function outputs @bookmark as a string.
1092 // the contents of the #GBookmarkFile
1093 // RETURNS: a newly allocated string holding
1094 // <length>: return location for the length of the returned string, or %NULL
1095 char* /*new*/ to_data()(size_t* length, GLib2.Error** error=null) {
1096 return g_bookmark_file_to_data(&this, length, error);
1099 // VERSION: 2.12
1100 // This function outputs @bookmark into a file. The write process is
1101 // guaranteed to be atomic by using g_file_set_contents() internally.
1102 // RETURNS: %TRUE if the file was successfully written.
1103 // <filename>: path of the output file
1104 int to_file()(char* filename, GLib2.Error** error=null) {
1105 return g_bookmark_file_to_file(&this, filename, error);
1107 static Quark error_quark()() {
1108 return g_bookmark_file_error_quark();
1111 // Unintrospectable function: new() / g_bookmark_file_new()
1112 // VERSION: 2.12
1113 // Creates a new empty #GBookmarkFile object.
1115 // Use g_bookmark_file_load_from_file(), g_bookmark_file_load_from_data()
1116 // or g_bookmark_file_load_from_data_dirs() to read an existing bookmark
1117 // file.
1118 // RETURNS: an empty #GBookmarkFile
1119 static BookmarkFile* new_()() {
1120 return g_bookmark_file_new();
1124 // Error codes returned by bookmark file parsing.
1125 enum BookmarkFileError {
1126 INVALID_URI = 0,
1127 INVALID_VALUE = 1,
1128 APP_NOT_REGISTERED = 2,
1129 URI_NOT_FOUND = 3,
1130 READ = 4,
1131 UNKNOWN_ENCODING = 5,
1132 WRITE = 6,
1133 FILE_NOT_FOUND = 7
1136 // The <structname>GByteArray</structname> struct allows access to the
1137 // public fields of a <structname>GByteArray</structname>.
1138 struct ByteArray {
1139 ubyte* data;
1140 uint len;
1143 // Unintrospectable function: append() / g_byte_array_append()
1144 // Adds the given bytes to the end of the #GByteArray. The array will
1145 // grow in size automatically if necessary.
1146 // <array>: a #GByteArray.
1147 // <data>: the byte data to be added.
1148 // <len>: the number of bytes to add.
1149 static ByteArray* append()(ByteArray* array, ubyte* data, uint len) {
1150 return g_byte_array_append(array, data, len);
1153 // Frees the memory allocated by the #GByteArray. If @free_segment is
1154 // %TRUE it frees the actual byte data. If the reference count of
1155 // @array is greater than one, the #GByteArray wrapper is preserved but
1156 // the size of @array will be set to zero.
1157 // <array>: a #GByteArray.
1158 // <free_segment>: if %TRUE the actual byte data is freed as well.
1159 static ubyte* free()(ByteArray* array, int free_segment) {
1160 return g_byte_array_free(array, free_segment);
1163 // Unintrospectable function: new() / g_byte_array_new()
1164 // Creates a new #GByteArray with a reference count of 1.
1165 static ByteArray* new_()() {
1166 return g_byte_array_new();
1169 // Unintrospectable function: prepend() / g_byte_array_prepend()
1170 // Adds the given data to the start of the #GByteArray. The array will
1171 // grow in size automatically if necessary.
1172 // <array>: a #GByteArray.
1173 // <data>: the byte data to be added.
1174 // <len>: the number of bytes to add.
1175 static ByteArray* prepend()(ByteArray* array, ubyte* data, uint len) {
1176 return g_byte_array_prepend(array, data, len);
1179 // Unintrospectable function: ref() / g_byte_array_ref()
1180 // VERSION: 2.22
1181 // Atomically increments the reference count of @array by one. This
1182 // function is MT-safe and may be called from any thread.
1183 // RETURNS: The passed in #GByteArray.
1184 // <array>: A #GByteArray.
1185 static ByteArray* ref_()(ByteArray* array) {
1186 return g_byte_array_ref(array);
1189 // Unintrospectable function: remove_index() / g_byte_array_remove_index()
1190 // Removes the byte at the given index from a #GByteArray. The
1191 // following bytes are moved down one place.
1192 // <array>: a #GByteArray.
1193 // <index_>: the index of the byte to remove.
1194 static ByteArray* remove_index()(ByteArray* array, uint index_) {
1195 return g_byte_array_remove_index(array, index_);
1198 // Unintrospectable function: remove_index_fast() / g_byte_array_remove_index_fast()
1199 // Removes the byte at the given index from a #GByteArray. The last
1200 // element in the array is used to fill in the space, so this function
1201 // does not preserve the order of the #GByteArray. But it is faster
1202 // than g_byte_array_remove_index().
1203 // <array>: a #GByteArray.
1204 // <index_>: the index of the byte to remove.
1205 static ByteArray* remove_index_fast()(ByteArray* array, uint index_) {
1206 return g_byte_array_remove_index_fast(array, index_);
1209 // Unintrospectable function: remove_range() / g_byte_array_remove_range()
1210 // VERSION: 2.4
1211 // Removes the given number of bytes starting at the given index from a
1212 // #GByteArray. The following elements are moved to close the gap.
1213 // <array>: a @GByteArray.
1214 // <index_>: the index of the first byte to remove.
1215 // <length>: the number of bytes to remove.
1216 static ByteArray* remove_range()(ByteArray* array, uint index_, uint length) {
1217 return g_byte_array_remove_range(array, index_, length);
1220 // Unintrospectable function: set_size() / g_byte_array_set_size()
1221 // Sets the size of the #GByteArray, expanding it if necessary.
1222 // <array>: a #GByteArray.
1223 // <length>: the new size of the #GByteArray.
1224 static ByteArray* set_size()(ByteArray* array, uint length) {
1225 return g_byte_array_set_size(array, length);
1228 // Unintrospectable function: sized_new() / g_byte_array_sized_new()
1229 // Creates a new #GByteArray with @reserved_size bytes preallocated.
1230 // This avoids frequent reallocation, if you are going to add many
1231 // bytes to the array. Note however that the size of the array is still
1232 // 0.
1233 // <reserved_size>: number of bytes preallocated.
1234 static ByteArray* sized_new()(uint reserved_size) {
1235 return g_byte_array_sized_new(reserved_size);
1238 // Unintrospectable function: sort() / g_byte_array_sort()
1239 // Sorts a byte array, using @compare_func which should be a
1240 // qsort()-style comparison function (returns less than zero for first
1241 // arg is less than second arg, zero for equal, greater than zero if
1242 // first arg is greater than second arg).
1244 // If two array elements compare equal, their order in the sorted array
1245 // is undefined. If you want equal elements to keep their order &#8211; i.e.
1246 // you want a stable sort &#8211; you can write a comparison function that,
1247 // if two elements would otherwise compare equal, compares them by
1248 // their addresses.
1249 // <array>: a #GByteArray.
1250 // <compare_func>: comparison function.
1251 static void sort()(ByteArray* array, CompareFunc compare_func) {
1252 g_byte_array_sort(array, compare_func);
1255 // Unintrospectable function: sort_with_data() / g_byte_array_sort_with_data()
1256 // Like g_byte_array_sort(), but the comparison function takes an extra
1257 // user data argument.
1258 // <array>: a #GByteArray.
1259 // <compare_func>: comparison function.
1260 // <user_data>: data to pass to @compare_func.
1261 static void sort_with_data()(ByteArray* array, CompareDataFunc compare_func, void* user_data) {
1262 g_byte_array_sort_with_data(array, compare_func, user_data);
1265 // VERSION: 2.22
1266 // Atomically decrements the reference count of @array by one. If the
1267 // reference count drops to 0, all memory allocated by the array is
1268 // released. This function is MT-safe and may be called from any
1269 // thread.
1270 // <array>: A #GByteArray.
1271 static void unref()(ByteArray* array) {
1272 g_byte_array_unref(array);
1276 enum int CAN_INLINE = 1;
1277 enum CSET_A_2_Z = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
1278 enum CSET_DIGITS = "0123456789";
1279 enum CSET_a_2_z = "abcdefghijklmnopqrstuvwxyz";
1281 // The #GCache struct is an opaque data structure containing
1282 // information about a #GCache. It should only be accessed via the
1283 // following functions.
1284 struct Cache {
1286 // Frees the memory allocated for the #GCache.
1288 // Note that it does not destroy the keys and values which were
1289 // contained in the #GCache.
1290 void destroy()() {
1291 g_cache_destroy(&this);
1294 // Unintrospectable method: insert() / g_cache_insert()
1295 // Gets the value corresponding to the given key, creating it if
1296 // necessary. It first checks if the value already exists in the
1297 // #GCache, by using the @key_equal_func function passed to
1298 // g_cache_new(). If it does already exist it is returned, and its
1299 // reference count is increased by one. If the value does not currently
1300 // exist, if is created by calling the @value_new_func. The key is
1301 // duplicated by calling @key_dup_func and the duplicated key and value
1302 // are inserted into the #GCache.
1303 // <key>: a key describing a #GCache object.
1304 void* insert()(void* key) {
1305 return g_cache_insert(&this, key);
1308 // Unintrospectable method: key_foreach() / g_cache_key_foreach()
1309 // Calls the given function for each of the keys in the #GCache.
1311 // NOTE @func is passed three parameters, the value and key of a cache
1312 // entry and the @user_data. The order of value and key is different
1313 // from the order in which g_hash_table_foreach() passes key-value
1314 // pairs to its callback function !
1315 // <func>: the function to call with each #GCache key.
1316 // <user_data>: user data to pass to the function.
1317 void key_foreach()(HFunc func, void* user_data) {
1318 g_cache_key_foreach(&this, func, user_data);
1321 // Decreases the reference count of the given value. If it drops to 0
1322 // then the value and its corresponding key are destroyed, using the
1323 // @value_destroy_func and @key_destroy_func passed to g_cache_new().
1324 // <value>: the value to remove.
1325 void remove()(const(void)* value) {
1326 g_cache_remove(&this, value);
1329 // Unintrospectable method: value_foreach() / g_cache_value_foreach()
1330 // Calls the given function for each of the values in the #GCache.
1332 // Deprecated:2.10: The reason is that it passes pointers to internal
1333 // data structures to @func; use g_cache_key_foreach()
1334 // instead
1335 // <func>: the function to call with each #GCache value.
1336 // <user_data>: user data to pass to the function.
1337 void value_foreach()(HFunc func, void* user_data) {
1338 g_cache_value_foreach(&this, func, user_data);
1341 // Unintrospectable function: new() / g_cache_new()
1342 // Creates a new #GCache.
1343 // <value_new_func>: a function to create a new object given a key. This is called by g_cache_insert() if an object with the given key does not already exist.
1344 // <value_destroy_func>: a function to destroy an object. It is called by g_cache_remove() when the object is no longer needed (i.e. its reference count drops to 0).
1345 // <key_dup_func>: a function to copy a key. It is called by g_cache_insert() if the key does not already exist in the #GCache.
1346 // <key_destroy_func>: a function to destroy a key. It is called by g_cache_remove() when the object is no longer needed (i.e. its reference count drops to 0).
1347 // <hash_key_func>: a function to create a hash value from a key.
1348 // <hash_value_func>: a function to create a hash value from a value.
1349 // <key_equal_func>: a function to compare two keys. It should return %TRUE if the two keys are equivalent.
1350 static Cache* new_()(CacheNewFunc value_new_func, CacheDestroyFunc value_destroy_func, CacheDupFunc key_dup_func, CacheDestroyFunc key_destroy_func, HashFunc hash_key_func, HashFunc hash_value_func, EqualFunc key_equal_func) {
1351 return g_cache_new(value_new_func, value_destroy_func, key_dup_func, key_destroy_func, hash_key_func, hash_value_func, key_equal_func);
1356 // Specifies the type of the @value_destroy_func and @key_destroy_func
1357 // functions passed to g_cache_new(). The functions are passed a
1358 // pointer to the #GCache key or #GCache value and should free any
1359 // memory and other resources associated with it.
1360 // <value>: the #GCache value to destroy.
1361 extern (C) alias void function (void* value) CacheDestroyFunc;
1364 // Unintrospectable callback: CacheDupFunc() / ()
1365 // Specifies the type of the @key_dup_func function passed to
1366 // g_cache_new(). The function is passed a key
1367 // (<emphasis>not</emphasis> a value as the prototype implies) and
1368 // should return a duplicate of the key.
1369 // <value>: the #GCache key to destroy (<emphasis>not</emphasis> a #GCache value as it seems).
1370 extern (C) alias void* function (void* value) CacheDupFunc;
1373 // Unintrospectable callback: CacheNewFunc() / ()
1374 // Specifies the type of the @value_new_func function passed to
1375 // g_cache_new(). It is passed a #GCache key and should create the
1376 // value corresponding to the key.
1377 // <key>: a #GCache key.
1378 extern (C) alias void* function (void* key) CacheNewFunc;
1381 // An opaque structure representing a checksumming operation.
1382 // To create a new GChecksum, use g_checksum_new(). To free
1383 // a GChecksum, use g_checksum_free().
1384 struct Checksum /* Version 2.16 */ {
1386 // Unintrospectable method: copy() / g_checksum_copy()
1387 // VERSION: 2.16
1388 // Copies a #GChecksum. If @checksum has been closed, by calling
1389 // g_checksum_get_string() or g_checksum_get_digest(), the copied
1390 // checksum will be closed as well.
1392 // when finished using it.
1393 // RETURNS: the copy of the passed #GChecksum. Use g_checksum_free()
1394 Checksum* copy()() {
1395 return g_checksum_copy(&this);
1398 // VERSION: 2.16
1399 // Frees the memory allocated for @checksum.
1400 void free()() {
1401 g_checksum_free(&this);
1404 // VERSION: 2.16
1405 // Gets the digest from @checksum as a raw binary vector and places it
1406 // into @buffer. The size of the digest depends on the type of checksum.
1408 // Once this function has been called, the #GChecksum is closed and can
1409 // no longer be updated with g_checksum_update().
1410 // <buffer>: output buffer
1411 // <digest_len>: an inout parameter. The caller initializes it to the size of @buffer. After the call it contains the length of the digest.
1412 void get_digest()(ubyte* buffer, size_t* digest_len) {
1413 g_checksum_get_digest(&this, buffer, digest_len);
1416 // VERSION: 2.16
1417 // Gets the digest as an hexadecimal string.
1419 // Once this function has been called the #GChecksum can no longer be
1420 // updated with g_checksum_update().
1422 // The hexadecimal characters will be lower case.
1424 // returned string is owned by the checksum and should not be modified
1425 // or freed.
1426 // RETURNS: the hexadecimal representation of the checksum. The
1427 char* get_string()() {
1428 return g_checksum_get_string(&this);
1431 // VERSION: 2.18
1432 // Resets the state of the @checksum back to its initial state.
1433 void reset()() {
1434 g_checksum_reset(&this);
1437 // VERSION: 2.16
1438 // Feeds @data into an existing #GChecksum. The checksum must still be
1439 // open, that is g_checksum_get_string() or g_checksum_get_digest() must
1440 // not have been called on @checksum.
1441 // <data>: buffer used to compute the checksum
1442 // <length>: size of the buffer, or -1 if it is a null-terminated string.
1443 void update()(ubyte* data, ssize_t length) {
1444 g_checksum_update(&this, data, length);
1447 // Unintrospectable function: new() / g_checksum_new()
1448 // VERSION: 2.16
1449 // Creates a new #GChecksum, using the checksum algorithm @checksum_type.
1450 // If the @checksum_type is not known, %NULL is returned.
1451 // A #GChecksum can be used to compute the checksum, or digest, of an
1452 // arbitrary binary blob, using different hashing algorithms.
1454 // A #GChecksum works by feeding a binary blob through g_checksum_update()
1455 // until there is data to be checked; the digest can then be extracted
1456 // using g_checksum_get_string(), which will return the checksum as a
1457 // hexadecimal string; or g_checksum_get_digest(), which will return a
1458 // vector of raw bytes. Once either g_checksum_get_string() or
1459 // g_checksum_get_digest() have been called on a #GChecksum, the checksum
1460 // will be closed and it won't be possible to call g_checksum_update()
1461 // on it anymore.
1463 // Use g_checksum_free() to free the memory allocated by it.
1464 // RETURNS: the newly created #GChecksum, or %NULL.
1465 // <checksum_type>: the desired type of checksum
1466 static Checksum* new_()(ChecksumType checksum_type) {
1467 return g_checksum_new(checksum_type);
1470 // VERSION: 2.16
1471 // Gets the length in bytes of digests of type @checksum_type
1473 // not supported.
1474 // RETURNS: the checksum length, or -1 if @checksum_type is
1475 // <checksum_type>: a #GChecksumType
1476 static ssize_t type_get_length()(ChecksumType checksum_type) {
1477 return g_checksum_type_get_length(checksum_type);
1482 // The hashing algorithm to be used by #GChecksum when performing the
1483 // digest of some data.
1485 // Note that the #GChecksumType enumeration may be extended at a later
1486 // date to include new hashing algorithm types.
1487 enum ChecksumType /* Version 2.16 */ {
1488 MD5 = 0,
1489 SHA1 = 1,
1490 SHA256 = 2
1493 // The type of functions to be called when a child exists.
1494 // <pid>: the process id of the child process
1495 // <status>: Status information about the child process, see waitpid(2) for more information about this field
1496 // <user_data>: user data passed to g_child_watch_add()
1497 extern (C) alias void function (Pid pid, int status, void* user_data) ChildWatchFunc;
1500 // Specifies the type of a comparison function used to compare two
1501 // values. The function should return a negative integer if the first
1502 // value comes before the second, 0 if they are equal, or a positive
1503 // integer if the first value comes after the second.
1504 // <a>: a value.
1505 // <b>: a value to compare with.
1506 // <user_data>: user data to pass to comparison function.
1507 extern (C) alias int function (const(void)* a, const(void)* b, void* user_data) CompareDataFunc;
1510 // Specifies the type of a comparison function used to compare two
1511 // values. The function should return a negative integer if the first
1512 // value comes before the second, 0 if they are equal, or a positive
1513 // integer if the first value comes after the second.
1514 // <a>: a value.
1515 // <b>: a value to compare with.
1516 extern (C) alias int function (const(void)* a, const(void)* b) CompareFunc;
1518 // The data structure used for automatic completion.
1519 struct Completion {
1520 GLib2.List* items;
1521 CompletionFunc func;
1522 char* prefix;
1523 GLib2.List* cache;
1524 CompletionStrncmpFunc strncmp_func;
1527 // Unintrospectable method: add_items() / g_completion_add_items()
1528 // DEPRECATED (v2.26) method: add_items - Rarely used API
1529 // Adds items to the #GCompletion.
1530 // <items>: the list of items to add.
1531 void add_items()(GLib2.List* items) {
1532 g_completion_add_items(&this, items);
1535 // DEPRECATED (v2.26) method: clear_items - Rarely used API
1536 // Removes all items from the #GCompletion.
1537 void clear_items()() {
1538 g_completion_clear_items(&this);
1541 // Unintrospectable method: complete() / g_completion_complete()
1542 // DEPRECATED (v2.26) method: complete - Rarely used API
1543 // Attempts to complete the string @prefix using the #GCompletion
1544 // target items.
1545 // <prefix>: the prefix string, typically typed by the user, which is compared with each of the items.
1546 // <new_prefix>: if non-%NULL, returns the longest prefix which is common to all items that matched @prefix, or %NULL if no items matched @prefix. This string should be freed when no longer needed.
1547 GLib2.List* complete()(char* prefix, char** new_prefix) {
1548 return g_completion_complete(&this, prefix, new_prefix);
1551 // VERSION: 2.4
1552 // DEPRECATED (v2.26) method: complete_utf8 - Rarely used API
1553 // Attempts to complete the string @prefix using the #GCompletion target items.
1554 // In contrast to g_completion_complete(), this function returns the largest common
1555 // prefix that is a valid UTF-8 string, omitting a possible common partial
1556 // character.
1558 // You should use this function instead of g_completion_complete() if your
1559 // items are UTF-8 strings.
1561 // not be changed.
1562 // RETURNS: the list of items whose strings begin with @prefix. This should
1563 // <prefix>: the prefix string, typically used by the user, which is compared with each of the items
1564 // <new_prefix>: if non-%NULL, returns the longest prefix which is common to all items that matched @prefix, or %NULL if no items matched @prefix. This string should be freed when no longer needed.
1565 GLib2.List* complete_utf8()(char* prefix, char** new_prefix) {
1566 return g_completion_complete_utf8(&this, prefix, new_prefix);
1569 // DEPRECATED (v2.26) method: free - Rarely used API
1570 // Frees all memory used by the #GCompletion.
1571 void free()() {
1572 g_completion_free(&this);
1575 // Unintrospectable method: remove_items() / g_completion_remove_items()
1576 // DEPRECATED (v2.26) method: remove_items - Rarely used API
1577 // Removes items from a #GCompletion.
1578 // <items>: the items to remove.
1579 void remove_items()(GLib2.List* items) {
1580 g_completion_remove_items(&this, items);
1583 // Unintrospectable method: set_compare() / g_completion_set_compare()
1584 // DEPRECATED (v2.26) method: set_compare - Rarely used API
1585 // Sets the function to use for string comparisons. The default string
1586 // comparison function is strncmp().
1587 // <strncmp_func>: the string comparison function.
1588 void set_compare()(CompletionStrncmpFunc strncmp_func) {
1589 g_completion_set_compare(&this, strncmp_func);
1592 // Unintrospectable function: new() / g_completion_new()
1593 // Creates a new #GCompletion.
1594 // <func>: the function to be called to return the string representing an item in the #GCompletion, or %NULL if strings are going to be used as the #GCompletion items.
1595 static Completion* new_()(CompletionFunc func) {
1596 return g_completion_new(func);
1601 // Specifies the type of the function passed to g_completion_new(). It
1602 // should return the string corresponding to the given target item.
1603 // This is used when you use data structures as #GCompletion items.
1604 extern (C) alias char* /*new*/ function (void* arg_a) CompletionFunc;
1607 // Specifies the type of the function passed to
1608 // g_completion_set_compare(). This is used when you use strings as
1609 // #GCompletion items.
1610 // <s1>: string to compare with @s2.
1611 // <s2>: string to compare with @s1.
1612 // <n>: maximal number of bytes to compare.
1613 extern (C) alias int function (char* s1, char* s2, size_t n) CompletionStrncmpFunc;
1616 // The #GCond struct is an opaque data structure that represents a
1617 // condition. Threads can block on a #GCond if they find a certain
1618 // condition to be false. If other threads change the state of this
1619 // condition they signal the #GCond, and that causes the waiting
1620 // threads to be woken up.
1622 // <example>
1623 // <title>
1624 // Using GCond to block a thread until a condition is satisfied
1625 // </title>
1626 // <programlisting>
1627 // GCond* data_cond = NULL; /<!-- -->* Must be initialized somewhere *<!-- -->/
1628 // GMutex* data_mutex = NULL; /<!-- -->* Must be initialized somewhere *<!-- -->/
1629 // gpointer current_data = NULL;
1631 // void
1632 // push_data (gpointer data)
1633 // {
1634 // g_mutex_lock (data_mutex);
1635 // current_data = data;
1636 // g_cond_signal (data_cond);
1637 // g_mutex_unlock (data_mutex);
1638 // }
1640 // gpointer
1641 // pop_data (void)
1642 // {
1643 // gpointer data;
1645 // g_mutex_lock (data_mutex);
1646 // while (!current_data)
1647 // g_cond_wait (data_cond, data_mutex);
1648 // data = current_data;
1649 // current_data = NULL;
1650 // g_mutex_unlock (data_mutex);
1652 // return data;
1653 // }
1654 // </programlisting>
1655 // </example>
1657 // Whenever a thread calls <function>pop_data()</function> now, it will
1658 // wait until current_data is non-%NULL, i.e. until some other thread
1659 // has called <function>push_data()</function>.
1661 // <note><para>It is important to use the g_cond_wait() and
1662 // g_cond_timed_wait() functions only inside a loop which checks for the
1663 // condition to be true. It is not guaranteed that the waiting thread
1664 // will find the condition fulfilled after it wakes up, even if the
1665 // signaling thread left the condition in that state: another thread may
1666 // have altered the condition before the waiting thread got the chance
1667 // to be woken up, even if the condition itself is protected by a
1668 // #GMutex, like above.</para></note>
1670 // A #GCond should only be accessed via the following functions.
1672 // <note><para>All of the <function>g_cond_*</function> functions are
1673 // actually macros. Apart from taking their addresses, you can however
1674 // use them as if they were functions.</para></note>
1675 struct Cond {
1678 // Error codes returned by character set conversion routines.
1679 enum ConvertError {
1680 NO_CONVERSION = 0,
1681 ILLEGAL_SEQUENCE = 1,
1682 FAILED = 2,
1683 PARTIAL_INPUT = 3,
1684 BAD_URI = 4,
1685 NOT_ABSOLUTE_PATH = 5
1688 // Unintrospectable callback: CopyFunc() / ()
1689 // VERSION: 2.4
1690 // A function of this signature is used to copy the node data
1691 // when doing a deep-copy of a tree.
1692 // RETURNS: A pointer to the copy
1693 // <src>: A pointer to the data which should be copied
1694 // <data>: Additional data
1695 extern (C) alias void* function (const(void)* src, void* data) CopyFunc;
1697 enum int DATALIST_FLAGS_MASK = 3;
1698 enum int DATE_BAD_DAY = 0;
1699 enum int DATE_BAD_JULIAN = 0;
1700 enum int DATE_BAD_YEAR = 0;
1701 enum int DIR_SEPARATOR = 92;
1702 enum DIR_SEPARATOR_S = "\\";
1704 // The #GData struct is an opaque data structure to represent a <link
1705 // linkend="glib-Keyed-Data-Lists">Keyed Data List</link>. It should
1706 // only be accessed via the following functions.
1707 struct Data {
1711 // Specifies the type of function passed to g_dataset_foreach(). It is
1712 // called with each #GQuark id and associated data element, together
1713 // with the @user_data parameter supplied to g_dataset_foreach().
1714 // <key_id>: the #GQuark id to identifying the data element.
1715 // <data>: the data element.
1716 // <user_data>: user data passed to g_dataset_foreach().
1717 extern (C) alias void function (Quark key_id, void* data, void* user_data) DataForeachFunc;
1719 struct Date {
1720 static import std.bitmanip; mixin(std.bitmanip.bitfields!(
1721 uint, "julian_days", 32,
1722 uint, "julian", 1,
1723 uint, "dmy", 1,
1724 uint, "day", 6,
1725 uint, "month", 4,
1726 uint, "year", 16,
1727 uint, "__dummy64A", 4));
1729 static Date* /*new*/ new_()() {
1730 return g_date_new();
1732 static Date* /*new*/ new_dmy()(DateDay day, DateMonth month, DateYear year) {
1733 return g_date_new_dmy(day, month, year);
1735 static Date* /*new*/ new_julian()(uint julian_day) {
1736 return g_date_new_julian(julian_day);
1738 void add_days()(uint n_days) {
1739 g_date_add_days(&this, n_days);
1741 void add_months()(uint n_months) {
1742 g_date_add_months(&this, n_months);
1744 void add_years()(uint n_years) {
1745 g_date_add_years(&this, n_years);
1747 void clamp()(Date* min_date, Date* max_date) {
1748 g_date_clamp(&this, min_date, max_date);
1750 void clear()(uint n_dates) {
1751 g_date_clear(&this, n_dates);
1753 int compare()(Date* rhs) {
1754 return g_date_compare(&this, rhs);
1756 int days_between()(Date* date2) {
1757 return g_date_days_between(&this, date2);
1759 void free()() {
1760 g_date_free(&this);
1762 DateDay get_day()() {
1763 return g_date_get_day(&this);
1765 uint get_day_of_year()() {
1766 return g_date_get_day_of_year(&this);
1769 // VERSION: 2.6
1770 // Returns the week of the year, where weeks are interpreted according
1771 // to ISO 8601.
1772 // RETURNS: ISO 8601 week number of the year.
1773 uint get_iso8601_week_of_year()() {
1774 return g_date_get_iso8601_week_of_year(&this);
1776 uint get_julian()() {
1777 return g_date_get_julian(&this);
1779 uint get_monday_week_of_year()() {
1780 return g_date_get_monday_week_of_year(&this);
1782 DateMonth get_month()() {
1783 return g_date_get_month(&this);
1785 uint get_sunday_week_of_year()() {
1786 return g_date_get_sunday_week_of_year(&this);
1788 DateWeekday get_weekday()() {
1789 return g_date_get_weekday(&this);
1791 DateYear get_year()() {
1792 return g_date_get_year(&this);
1794 int is_first_of_month()() {
1795 return g_date_is_first_of_month(&this);
1797 int is_last_of_month()() {
1798 return g_date_is_last_of_month(&this);
1800 void order()(Date* date2) {
1801 g_date_order(&this, date2);
1803 void set_day()(DateDay day) {
1804 g_date_set_day(&this, day);
1806 void set_dmy()(DateDay day, DateMonth month, DateYear y) {
1807 g_date_set_dmy(&this, day, month, y);
1809 void set_julian()(uint julian_date) {
1810 g_date_set_julian(&this, julian_date);
1812 void set_month()(DateMonth month) {
1813 g_date_set_month(&this, month);
1815 void set_parse()(char* str) {
1816 g_date_set_parse(&this, str);
1819 // DEPRECATED (v2.10) method: set_time - Use g_date_set_time_t() instead.
1820 // Sets the value of a date from a #GTime value.
1821 // The time to date conversion is done using the user's current timezone.
1822 // <time_>: #GTime value to set.
1823 void set_time()(Time time_) {
1824 g_date_set_time(&this, time_);
1827 // VERSION: 2.10
1828 // Sets the value of a date to the date corresponding to a time
1829 // specified as a time_t. The time to date conversion is done using
1830 // the user's current timezone.
1832 // To set the value of a date to the current day, you could write:
1833 // |[
1834 // g_date_set_time_t (date, time (NULL));
1835 // ]|
1836 // <timet>: <type>time_t</type> value to set
1837 void set_time_t()(time_t timet) {
1838 g_date_set_time_t(&this, timet);
1841 // VERSION: 2.10
1842 // Sets the value of a date from a #GTimeVal value. Note that the
1843 // @tv_usec member is ignored, because #GDate can't make use of the
1844 // additional precision.
1846 // The time to date conversion is done using the user's current timezone.
1847 // <timeval>: #GTimeVal value to set
1848 void set_time_val()(TimeVal* timeval) {
1849 g_date_set_time_val(&this, timeval);
1851 void set_year()(DateYear year) {
1852 g_date_set_year(&this, year);
1854 void subtract_days()(uint n_days) {
1855 g_date_subtract_days(&this, n_days);
1857 void subtract_months()(uint n_months) {
1858 g_date_subtract_months(&this, n_months);
1860 void subtract_years()(uint n_years) {
1861 g_date_subtract_years(&this, n_years);
1863 void to_struct_tm()(void** tm) {
1864 g_date_to_struct_tm(&this, tm);
1866 int valid()() {
1867 return g_date_valid(&this);
1869 static ubyte get_days_in_month()(DateMonth month, DateYear year) {
1870 return g_date_get_days_in_month(month, year);
1872 static ubyte get_monday_weeks_in_year()(DateYear year) {
1873 return g_date_get_monday_weeks_in_year(year);
1875 static ubyte get_sunday_weeks_in_year()(DateYear year) {
1876 return g_date_get_sunday_weeks_in_year(year);
1878 static int is_leap_year()(DateYear year) {
1879 return g_date_is_leap_year(year);
1881 static size_t strftime()(char* s, size_t slen, char* format, Date* date) {
1882 return g_date_strftime(s, slen, format, date);
1884 static int valid_day()(DateDay day) {
1885 return g_date_valid_day(day);
1887 static int valid_dmy()(DateDay day, DateMonth month, DateYear year) {
1888 return g_date_valid_dmy(day, month, year);
1890 static int valid_julian()(uint julian_date) {
1891 return g_date_valid_julian(julian_date);
1893 static int valid_month()(DateMonth month) {
1894 return g_date_valid_month(month);
1896 static int valid_weekday()(DateWeekday weekday) {
1897 return g_date_valid_weekday(weekday);
1899 static int valid_year()(DateYear year) {
1900 return g_date_valid_year(year);
1904 enum DateDMY {
1905 DAY = 0,
1906 MONTH = 1,
1907 YEAR = 2
1909 enum DateMonth {
1910 BAD_MONTH = 0,
1911 JANUARY = 1,
1912 FEBRUARY = 2,
1913 MARCH = 3,
1914 APRIL = 4,
1915 MAY = 5,
1916 JUNE = 6,
1917 JULY = 7,
1918 AUGUST = 8,
1919 SEPTEMBER = 9,
1920 OCTOBER = 10,
1921 NOVEMBER = 11,
1922 DECEMBER = 12
1925 // <structname>GDateTime</structname> is an opaque structure whose members
1926 // cannot be accessed directly.
1927 struct DateTime /* Version 2.26 */ {
1929 // VERSION: 2.26
1930 // Creates a new #GDateTime corresponding to the given date and time in
1931 // the time zone @tz.
1933 // The @year must be between 1 and 9999, @month between 1 and 12 and @day
1934 // between 1 and 28, 29, 30 or 31 depending on the month and the year.
1936 // @hour must be between 0 and 23 and @minute must be between 0 and 59.
1938 // @seconds must be at least 0.0 and must be strictly less than 60.0.
1939 // It will be rounded down to the nearest microsecond.
1941 // If the given time is not representable in the given time zone (for
1942 // example, 02:30 on March 14th 2010 in Toronto, due to daylight savings
1943 // time) then the time will be rounded up to the nearest existing time
1944 // (in this case, 03:00). If this matters to you then you should verify
1945 // the return value for containing the same as the numbers you gave.
1947 // In the case that the given time is ambiguous in the given time zone
1948 // (for example, 01:30 on November 7th 2010 in Toronto, due to daylight
1949 // savings time) then the time falling within standard (ie:
1950 // non-daylight) time is taken.
1952 // It not considered a programmer error for the values to this function
1953 // to be out of range, but in the case that they are, the function will
1954 // return %NULL.
1956 // You should release the return value by calling g_date_time_unref()
1957 // when you are done with it.
1958 // RETURNS: a new #GDateTime, or %NULL
1959 // <tz>: a #GTimeZone
1960 // <year>: the year component of the date
1961 // <month>: the month component of the date
1962 // <day>: the day component of the date
1963 // <hour>: the hour component of the date
1964 // <minute>: the minute component of the date
1965 // <seconds>: the number of seconds past the minute
1966 static DateTime* /*new*/ new_()(TimeZone* tz, int year, int month, int day, int hour, int minute, double seconds) {
1967 return g_date_time_new(tz, year, month, day, hour, minute, seconds);
1970 // VERSION: 2.26
1971 // Creates a #GDateTime corresponding to the given #GTimeVal @tv in the
1972 // local time zone.
1974 // The time contained in a #GTimeVal is always stored in the form of
1975 // seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the
1976 // local time offset.
1978 // This call can fail (returning %NULL) if @tv represents a time outside
1979 // of the supported range of #GDateTime.
1981 // You should release the return value by calling g_date_time_unref()
1982 // when you are done with it.
1983 // RETURNS: a new #GDateTime, or %NULL
1984 // <tv>: a #GTimeVal
1985 static DateTime* /*new*/ new_from_timeval_local()(TimeVal* tv) {
1986 return g_date_time_new_from_timeval_local(tv);
1989 // VERSION: 2.26
1990 // Creates a #GDateTime corresponding to the given #GTimeVal @tv in UTC.
1992 // The time contained in a #GTimeVal is always stored in the form of
1993 // seconds elapsed since 1970-01-01 00:00:00 UTC.
1995 // This call can fail (returning %NULL) if @tv represents a time outside
1996 // of the supported range of #GDateTime.
1998 // You should release the return value by calling g_date_time_unref()
1999 // when you are done with it.
2000 // RETURNS: a new #GDateTime, or %NULL
2001 // <tv>: a #GTimeVal
2002 static DateTime* /*new*/ new_from_timeval_utc()(TimeVal* tv) {
2003 return g_date_time_new_from_timeval_utc(tv);
2006 // VERSION: 2.26
2007 // Creates a #GDateTime corresponding to the given Unix time @t in the
2008 // local time zone.
2010 // Unix time is the number of seconds that have elapsed since 1970-01-01
2011 // 00:00:00 UTC, regardless of the local time offset.
2013 // This call can fail (returning %NULL) if @t represents a time outside
2014 // of the supported range of #GDateTime.
2016 // You should release the return value by calling g_date_time_unref()
2017 // when you are done with it.
2018 // RETURNS: a new #GDateTime, or %NULL
2019 // <t>: the Unix time
2020 static DateTime* /*new*/ new_from_unix_local()(long t) {
2021 return g_date_time_new_from_unix_local(t);
2024 // VERSION: 2.26
2025 // Creates a #GDateTime corresponding to the given Unix time @t in UTC.
2027 // Unix time is the number of seconds that have elapsed since 1970-01-01
2028 // 00:00:00 UTC.
2030 // This call can fail (returning %NULL) if @t represents a time outside
2031 // of the supported range of #GDateTime.
2033 // You should release the return value by calling g_date_time_unref()
2034 // when you are done with it.
2035 // RETURNS: a new #GDateTime, or %NULL
2036 // <t>: the Unix time
2037 static DateTime* /*new*/ new_from_unix_utc()(long t) {
2038 return g_date_time_new_from_unix_utc(t);
2041 // VERSION: 2.26.
2042 // Creates a new #GDateTime corresponding to the given date and time in
2043 // the local time zone.
2045 // This call is equivalent to calling g_date_time_new() with the time
2046 // zone returned by g_time_zone_new_local().
2047 // RETURNS: a #GDateTime, or %NULL
2048 // <year>: the year component of the date
2049 // <month>: the month component of the date
2050 // <day>: the day component of the date
2051 // <hour>: the hour component of the date
2052 // <minute>: the minute component of the date
2053 // <seconds>: the number of seconds past the minute
2054 static DateTime* /*new*/ new_local()(int year, int month, int day, int hour, int minute, double seconds) {
2055 return g_date_time_new_local(year, month, day, hour, minute, seconds);
2058 // VERSION: 2.26
2059 // Creates a #GDateTime corresponding to this exact instant in the given
2060 // time zone @tz. The time is as accurate as the system allows, to a
2061 // maximum accuracy of 1 microsecond.
2063 // This function will always succeed unless the system clock is set to
2064 // truly insane values (or unless GLib is still being used after the
2065 // year 9999).
2067 // You should release the return value by calling g_date_time_unref()
2068 // when you are done with it.
2069 // RETURNS: a new #GDateTime, or %NULL
2070 // <tz>: a #GTimeZone
2071 static DateTime* /*new*/ new_now()(TimeZone* tz) {
2072 return g_date_time_new_now(tz);
2075 // VERSION: 2.26
2076 // Creates a #GDateTime corresponding to this exact instant in the local
2077 // time zone.
2079 // This is equivalent to calling g_date_time_new_now() with the time
2080 // zone returned by g_time_zone_new_local().
2081 // RETURNS: a new #GDateTime, or %NULL
2082 static DateTime* /*new*/ new_now_local()() {
2083 return g_date_time_new_now_local();
2086 // VERSION: 2.26
2087 // Creates a #GDateTime corresponding to this exact instant in UTC.
2089 // This is equivalent to calling g_date_time_new_now() with the time
2090 // zone returned by g_time_zone_new_utc().
2091 // RETURNS: a new #GDateTime, or %NULL
2092 static DateTime* /*new*/ new_now_utc()() {
2093 return g_date_time_new_now_utc();
2096 // VERSION: 2.26.
2097 // Creates a new #GDateTime corresponding to the given date and time in
2098 // UTC.
2100 // This call is equivalent to calling g_date_time_new() with the time
2101 // zone returned by g_time_zone_new_utc().
2102 // RETURNS: a #GDateTime, or %NULL
2103 // <year>: the year component of the date
2104 // <month>: the month component of the date
2105 // <day>: the day component of the date
2106 // <hour>: the hour component of the date
2107 // <minute>: the minute component of the date
2108 // <seconds>: the number of seconds past the minute
2109 static DateTime* /*new*/ new_utc()(int year, int month, int day, int hour, int minute, double seconds) {
2110 return g_date_time_new_utc(year, month, day, hour, minute, seconds);
2113 // VERSION: 2.26
2114 // Creates a copy of @datetime and adds the specified timespan to the copy.
2116 // g_date_time_unref().
2117 // RETURNS: the newly created #GDateTime which should be freed with
2118 // <timespan>: a #GTimeSpan
2119 DateTime* /*new*/ add()(TimeSpan timespan) {
2120 return g_date_time_add(&this, timespan);
2123 // VERSION: 2.26
2124 // Creates a copy of @datetime and adds the specified number of days to the
2125 // copy.
2127 // g_date_time_unref().
2128 // RETURNS: the newly created #GDateTime which should be freed with
2129 // <days>: the number of days
2130 DateTime* /*new*/ add_days()(int days) {
2131 return g_date_time_add_days(&this, days);
2134 // VERSION: 2.26
2135 // Creates a new #GDateTime adding the specified values to the current date and
2136 // time in @datetime.
2138 // g_date_time_unref().
2139 // RETURNS: the newly created #GDateTime that should be freed with
2140 // <years>: the number of years to add
2141 // <months>: the number of months to add
2142 // <days>: the number of days to add
2143 // <hours>: the number of hours to add
2144 // <minutes>: the number of minutes to add
2145 // <seconds>: the number of seconds to add
2146 DateTime* /*new*/ add_full()(int years, int months, int days, int hours, int minutes, double seconds) {
2147 return g_date_time_add_full(&this, years, months, days, hours, minutes, seconds);
2150 // VERSION: 2.26
2151 // Creates a copy of @datetime and adds the specified number of hours
2153 // g_date_time_unref().
2154 // RETURNS: the newly created #GDateTime which should be freed with
2155 // <hours>: the number of hours to add
2156 DateTime* /*new*/ add_hours()(int hours) {
2157 return g_date_time_add_hours(&this, hours);
2160 // VERSION: 2.26
2161 // Creates a copy of @datetime adding the specified number of minutes.
2163 // g_date_time_unref().
2164 // RETURNS: the newly created #GDateTime which should be freed with
2165 // <minutes>: the number of minutes to add
2166 DateTime* /*new*/ add_minutes()(int minutes) {
2167 return g_date_time_add_minutes(&this, minutes);
2170 // VERSION: 2.26
2171 // Creates a copy of @datetime and adds the specified number of months to the
2172 // copy.
2174 // g_date_time_unref().
2175 // RETURNS: the newly created #GDateTime which should be freed with
2176 // <months>: the number of months
2177 DateTime* /*new*/ add_months()(int months) {
2178 return g_date_time_add_months(&this, months);
2181 // VERSION: 2.26
2182 // Creates a copy of @datetime and adds the specified number of seconds.
2184 // g_date_time_unref().
2185 // RETURNS: the newly created #GDateTime which should be freed with
2186 // <seconds>: the number of seconds to add
2187 DateTime* /*new*/ add_seconds()(double seconds) {
2188 return g_date_time_add_seconds(&this, seconds);
2191 // VERSION: 2.26
2192 // Creates a copy of @datetime and adds the specified number of weeks to the
2193 // copy.
2195 // g_date_time_unref().
2196 // RETURNS: the newly created #GDateTime which should be freed with
2197 // <weeks>: the number of weeks
2198 DateTime* /*new*/ add_weeks()(int weeks) {
2199 return g_date_time_add_weeks(&this, weeks);
2202 // VERSION: 2.26
2203 // Creates a copy of @datetime and adds the specified number of years to the
2204 // copy.
2206 // g_date_time_unref().
2207 // RETURNS: the newly created #GDateTime which should be freed with
2208 // <years>: the number of years
2209 DateTime* /*new*/ add_years()(int years) {
2210 return g_date_time_add_years(&this, years);
2213 // VERSION: 2.26
2214 // Calculates the difference in time between @end and @begin. The
2215 // #GTimeSpan that is returned is effectively @end - @begin (ie:
2216 // positive if the first simparameter is larger).
2218 // span expressed in microseconds.
2219 // RETURNS: the difference between the two #GDateTime, as a time
2220 // <begin>: a #GDateTime
2221 TimeSpan difference()(DateTime* begin) {
2222 return g_date_time_difference(&this, begin);
2225 // VERSION: 2.26
2226 // Creates a newly allocated string representing the requested @format.
2228 // The format strings understood by this function are a subset of the
2229 // strftime() format language. In contrast to strftime(), this function
2230 // always produces a UTF-8 string, regardless of the current locale.
2231 // Note that the rendering of many formats is locale-dependent and may
2232 // not match the strftime() output exactly.
2234 // The following format specifiers are supported:
2236 // <variablelist>
2237 // <varlistentry><term>
2238 // <literal>%%a</literal>:
2239 // </term><listitem><simpara>
2240 // the abbreviated weekday name according to the current locale
2241 // </simpara></listitem></varlistentry>
2242 // <varlistentry><term>
2243 // <literal>%%A</literal>:
2244 // </term><listitem><simpara>
2245 // the full weekday name according to the current locale
2246 // </simpara></listitem></varlistentry>
2247 // <varlistentry><term>
2248 // <literal>%%b</literal>:
2249 // </term><listitem><simpara>
2250 // the abbreviated month name according to the current locale
2251 // </simpara></listitem></varlistentry>
2252 // <varlistentry><term>
2253 // <literal>%%B</literal>:
2254 // </term><listitem><simpara>
2255 // the full month name according to the current locale
2256 // </simpara></listitem></varlistentry>
2257 // <varlistentry><term>
2258 // <literal>%%d</literal>:
2259 // </term><listitem><simpara>
2260 // the day of the month as a decimal number (range 01 to 31)
2261 // </simpara></listitem></varlistentry>
2262 // <varlistentry><term>
2263 // <literal>%%e</literal>:
2264 // </term><listitem><simpara>
2265 // the day of the month as a decimal number (range 1 to 31)
2266 // </simpara></listitem></varlistentry>
2267 // <varlistentry><term>
2268 // <literal>%%F</literal>:
2269 // </term><listitem><simpara>
2270 // equivalent to <literal>%%Y-%%m-%%d</literal> (the ISO 8601 date
2271 // format)
2272 // </simpara></listitem></varlistentry>
2273 // <varlistentry><term>
2274 // <literal>%%h</literal>:
2275 // </term><listitem><simpara>
2276 // equivalent to <literal>%%b</literal>
2277 // </simpara></listitem></varlistentry>
2278 // <varlistentry><term>
2279 // <literal>%%H</literal>:
2280 // </term><listitem><simpara>
2281 // the hour as a decimal number using a 24-hour clock (range 00 to
2282 // 23)
2283 // </simpara></listitem></varlistentry>
2284 // <varlistentry><term>
2285 // <literal>%%I</literal>:
2286 // </term><listitem><simpara>
2287 // the hour as a decimal number using a 12-hour clock (range 01 to
2288 // 12)
2289 // </simpara></listitem></varlistentry>
2290 // <varlistentry><term>
2291 // <literal>%%j</literal>:
2292 // </term><listitem><simpara>
2293 // the day of the year as a decimal number (range 001 to 366)
2294 // </simpara></listitem></varlistentry>
2295 // <varlistentry><term>
2296 // <literal>%%k</literal>:
2297 // </term><listitem><simpara>
2298 // the hour (24-hour clock) as a decimal number (range 0 to 23);
2299 // single digits are preceded by a blank
2300 // </simpara></listitem></varlistentry>
2301 // <varlistentry><term>
2302 // <literal>%%l</literal>:
2303 // </term><listitem><simpara>
2304 // the hour (12-hour clock) as a decimal number (range 1 to 12);
2305 // single digits are preceded by a blank
2306 // </simpara></listitem></varlistentry>
2307 // <varlistentry><term>
2308 // <literal>%%m</literal>:
2309 // </term><listitem><simpara>
2310 // the month as a decimal number (range 01 to 12)
2311 // </simpara></listitem></varlistentry>
2312 // <varlistentry><term>
2313 // <literal>%%M</literal>:
2314 // </term><listitem><simpara>
2315 // the minute as a decimal number (range 00 to 59)
2316 // </simpara></listitem></varlistentry>
2317 // <varlistentry><term>
2318 // <literal>%%N</literal>:
2319 // </term><listitem><simpara>
2320 // the micro-seconds as a decimal number
2321 // </simpara></listitem></varlistentry>
2322 // <varlistentry><term>
2323 // <literal>%%p</literal>:
2324 // </term><listitem><simpara>
2325 // either "AM" or "PM" according to the given time value, or the
2326 // corresponding strings for the current locale. Noon is treated as
2327 // "PM" and midnight as "AM".
2328 // </simpara></listitem></varlistentry>
2329 // <varlistentry><term>
2330 // <literal>%%P</literal>:
2331 // </term><listitem><simpara>
2332 // like %%p but lowercase: "am" or "pm" or a corresponding string for
2333 // the current locale
2334 // </simpara></listitem></varlistentry>
2335 // <varlistentry><term>
2336 // <literal>%%r</literal>:
2337 // </term><listitem><simpara>
2338 // the time in a.m. or p.m. notation
2339 // </simpara></listitem></varlistentry>
2340 // <varlistentry><term>
2341 // <literal>%%R</literal>:
2342 // </term><listitem><simpara>
2343 // the time in 24-hour notation (<literal>%%H:%%M</literal>)
2344 // </simpara></listitem></varlistentry>
2345 // <varlistentry><term>
2346 // <literal>%%s</literal>:
2347 // </term><listitem><simpara>
2348 // the number of seconds since the Epoch, that is, since 1970-01-01
2349 // 00:00:00 UTC
2350 // </simpara></listitem></varlistentry>
2351 // <varlistentry><term>
2352 // <literal>%%S</literal>:
2353 // </term><listitem><simpara>
2354 // the second as a decimal number (range 00 to 60)
2355 // </simpara></listitem></varlistentry>
2356 // <varlistentry><term>
2357 // <literal>%%t</literal>:
2358 // </term><listitem><simpara>
2359 // a tab character
2360 // </simpara></listitem></varlistentry>
2361 // <varlistentry><term>
2362 // <literal>%%T</literal>:
2363 // </term><listitem><simpara>
2364 // the time in 24-hour notation with seconds (<literal>%%H:%%M:%%S</literal>)
2365 // </simpara></listitem></varlistentry>
2366 // <varlistentry><term>
2367 // <literal>%%u</literal>:
2368 // </term><listitem><simpara>
2369 // the day of the week as a decimal, range 1 to 7, Monday being 1
2370 // </simpara></listitem></varlistentry>
2371 // <varlistentry><term>
2372 // <literal>%%W</literal>:
2373 // </term><listitem><simpara>
2374 // the week number of the current year as a decimal number
2375 // </simpara></listitem></varlistentry>
2376 // <varlistentry><term>
2377 // <literal>%%x</literal>:
2378 // </term><listitem><simpara>
2379 // the preferred date representation for the current locale without
2380 // the time
2381 // </simpara></listitem></varlistentry>
2382 // <varlistentry><term>
2383 // <literal>%%X</literal>:
2384 // </term><listitem><simpara>
2385 // the preferred time representation for the current locale without
2386 // the date
2387 // </simpara></listitem></varlistentry>
2388 // <varlistentry><term>
2389 // <literal>%%y</literal>:
2390 // </term><listitem><simpara>
2391 // the year as a decimal number without the century
2392 // </simpara></listitem></varlistentry>
2393 // <varlistentry><term>
2394 // <literal>%%Y</literal>:
2395 // </term><listitem><simpara>
2396 // the year as a decimal number including the century
2397 // </simpara></listitem></varlistentry>
2398 // <varlistentry><term>
2399 // <literal>%%z</literal>:
2400 // </term><listitem><simpara>
2401 // the time-zone as hour offset from UTC
2402 // </simpara></listitem></varlistentry>
2403 // <varlistentry><term>
2404 // <literal>%%Z</literal>:
2405 // </term><listitem><simpara>
2406 // the time zone or name or abbreviation
2407 // </simpara></listitem></varlistentry>
2408 // <varlistentry><term>
2409 // <literal>%%%</literal>:
2410 // </term><listitem><simpara>
2411 // a literal <literal>%%</literal> character
2412 // </simpara></listitem></varlistentry>
2413 // </variablelist>
2415 // Some conversion specifications can be modified by preceding the
2416 // conversion specifier by one or more modifier characters. The
2417 // following modifiers are supported for many of the numeric
2418 // conversions:
2419 // <variablelist>
2420 // <varlistentry>
2421 // <term>O</term>
2422 // <listitem>
2423 // Use alternative numeric symbols, if the current locale
2424 // supports those.
2425 // </listitem>
2426 // </varlistentry>
2427 // <varlistentry>
2428 // <term>_</term>
2429 // <listitem>
2430 // Pad a numeric result with spaces.
2431 // This overrides the default padding for the specifier.
2432 // </listitem>
2433 // </varlistentry>
2434 // <varlistentry>
2435 // <term>-</term>
2436 // <listitem>
2437 // Do not pad a numeric result.
2438 // This overrides the default padding for the specifier.
2439 // </listitem>
2440 // </varlistentry>
2441 // <varlistentry>
2442 // <term>0</term>
2443 // <listitem>
2444 // Pad a numeric result with zeros.
2445 // This overrides the default padding for the specifier.
2446 // </listitem>
2447 // </varlistentry>
2448 // </variablelist>
2450 // or %NULL in the case that there was an error. The string
2451 // should be freed with g_free().
2452 // RETURNS: a newly allocated string formatted to the requested format
2453 // <format>: a valid UTF-8 string, containing the format for the #GDateTime
2454 char* /*new*/ format()(char* format) {
2455 return g_date_time_format(&this, format);
2458 // VERSION: 2.26
2459 // Retrieves the day of the month represented by @datetime in the gregorian
2460 // calendar.
2461 // RETURNS: the day of the month
2462 int get_day_of_month()() {
2463 return g_date_time_get_day_of_month(&this);
2466 // VERSION: 2.26
2467 // Retrieves the ISO 8601 day of the week on which @datetime falls (1 is
2468 // Monday, 2 is Tuesday... 7 is Sunday).
2469 // RETURNS: the day of the week
2470 int get_day_of_week()() {
2471 return g_date_time_get_day_of_week(&this);
2474 // VERSION: 2.26
2475 // Retrieves the day of the year represented by @datetime in the Gregorian
2476 // calendar.
2477 // RETURNS: the day of the year
2478 int get_day_of_year()() {
2479 return g_date_time_get_day_of_year(&this);
2482 // VERSION: 2.26
2483 // Retrieves the hour of the day represented by @datetime
2484 // RETURNS: the hour of the day
2485 int get_hour()() {
2486 return g_date_time_get_hour(&this);
2489 // VERSION: 2.26
2490 // Retrieves the microsecond of the date represented by @datetime
2491 // RETURNS: the microsecond of the second
2492 int get_microsecond()() {
2493 return g_date_time_get_microsecond(&this);
2496 // VERSION: 2.26
2497 // Retrieves the minute of the hour represented by @datetime
2498 // RETURNS: the minute of the hour
2499 int get_minute()() {
2500 return g_date_time_get_minute(&this);
2503 // VERSION: 2.26
2504 // Retrieves the month of the year represented by @datetime in the Gregorian
2505 // calendar.
2506 // RETURNS: the month represented by @datetime
2507 int get_month()() {
2508 return g_date_time_get_month(&this);
2511 // VERSION: 2.26
2512 // Retrieves the second of the minute represented by @datetime
2513 // RETURNS: the second represented by @datetime
2514 int get_second()() {
2515 return g_date_time_get_second(&this);
2518 // VERSION: 2.26
2519 // Retrieves the number of seconds since the start of the last minute,
2520 // including the fractional part.
2521 // RETURNS: the number of seconds
2522 double get_seconds()() {
2523 return g_date_time_get_seconds(&this);
2526 // VERSION: 2.26
2527 // Determines the time zone abbreviation to be used at the time and in
2528 // the time zone of @datetime.
2530 // For example, in Toronto this is currently "EST" during the winter
2531 // months and "EDT" during the summer months when daylight savings
2532 // time is in effect.
2534 // string is owned by the #GDateTime and it should not be
2535 // modified or freed
2536 // RETURNS: the time zone abbreviation. The returned
2537 char* get_timezone_abbreviation()() {
2538 return g_date_time_get_timezone_abbreviation(&this);
2541 // VERSION: 2.26
2542 // Determines the offset to UTC in effect at the time and in the time
2543 // zone of @datetime.
2545 // The offset is the number of microseconds that you add to UTC time to
2546 // arrive at local time for the time zone (ie: negative numbers for time
2547 // zones west of GMT, positive numbers for east).
2549 // If @datetime represents UTC time, then the offset is always zero.
2551 // get the local time
2552 // RETURNS: the number of microseconds that should be added to UTC to
2553 TimeSpan get_utc_offset()() {
2554 return g_date_time_get_utc_offset(&this);
2557 // VERSION: 2.26
2558 // Returns the ISO 8601 week-numbering year in which the week containing
2559 // @datetime falls.
2561 // This function, taken together with g_date_time_get_week_of_year() and
2562 // g_date_time_get_day_of_week() can be used to determine the full ISO
2563 // week date on which @datetime falls.
2565 // This is usually equal to the normal Gregorian year (as returned by
2566 // g_date_time_get_year()), except as detailed below:
2568 // For Thursday, the week-numbering year is always equal to the usual
2569 // calendar year. For other days, the number is such that every day
2570 // within a complete week (Monday to Sunday) is contained within the
2571 // same week-numbering year.
2573 // For Monday, Tuesday and Wednesday occurring near the end of the year,
2574 // this may mean that the week-numbering year is one greater than the
2575 // calendar year (so that these days have the same week-numbering year
2576 // as the Thursday occurring early in the next year).
2578 // For Friday, Saturaday and Sunday occurring near the start of the year,
2579 // this may mean that the week-numbering year is one less than the
2580 // calendar year (so that these days have the same week-numbering year
2581 // as the Thursday occurring late in the previous year).
2583 // An equivalent description is that the week-numbering year is equal to
2584 // the calendar year containing the majority of the days in the current
2585 // week (Monday to Sunday).
2587 // Note that January 1 0001 in the proleptic Gregorian calendar is a
2588 // Monday, so this function never returns 0.
2589 // RETURNS: the ISO 8601 week-numbering year for @datetime
2590 int get_week_numbering_year()() {
2591 return g_date_time_get_week_numbering_year(&this);
2594 // VERSION: 2.26
2595 // Returns the ISO 8601 week number for the week containing @datetime.
2596 // The ISO 8601 week number is the same for every day of the week (from
2597 // Moday through Sunday). That can produce some unusual results
2598 // (described below).
2600 // The first week of the year is week 1. This is the week that contains
2601 // the first Thursday of the year. Equivalently, this is the first week
2602 // that has more than 4 of its days falling within the calendar year.
2604 // The value 0 is never returned by this function. Days contained
2605 // within a year but occurring before the first ISO 8601 week of that
2606 // year are considered as being contained in the last week of the
2607 // previous year. Similarly, the final days of a calendar year may be
2608 // considered as being part of the first ISO 8601 week of the next year
2609 // if 4 or more days of that week are contained within the new year.
2610 // RETURNS: the ISO 8601 week number for @datetime.
2611 int get_week_of_year()() {
2612 return g_date_time_get_week_of_year(&this);
2615 // VERSION: 2.26
2616 // Retrieves the year represented by @datetime in the Gregorian calendar.
2617 // RETURNS: the year represented by @datetime
2618 int get_year()() {
2619 return g_date_time_get_year(&this);
2622 // VERSION: 2.26
2623 // Retrieves the Gregorian day, month, and year of a given #GDateTime.
2624 // <year>: the return location for the gregorian year, or %NULL.
2625 // <month>: the return location for the month of the year, or %NULL.
2626 // <day>: the return location for the day of the month, or %NULL.
2627 void get_ymd()(/*out*/ int* year, /*out*/ int* month, /*out*/ int* day) {
2628 g_date_time_get_ymd(&this, year, month, day);
2631 // VERSION: 2.26
2632 // Determines if daylight savings time is in effect at the time and in
2633 // the time zone of @datetime.
2634 // RETURNS: %TRUE if daylight savings time is in effect
2635 int is_daylight_savings()() {
2636 return g_date_time_is_daylight_savings(&this);
2639 // VERSION: 2.26
2640 // Atomically increments the reference count of @datetime by one.
2641 // RETURNS: the #GDateTime with the reference count increased
2642 DateTime* /*new*/ ref_()() {
2643 return g_date_time_ref(&this);
2646 // VERSION: 2.26
2647 // Creates a new #GDateTime corresponding to the same instant in time as
2648 // @datetime, but in the local time zone.
2650 // This call is equivalent to calling g_date_time_to_timezone() with the
2651 // time zone returned by g_time_zone_new_local().
2652 // RETURNS: the newly created #GDateTime
2653 DateTime* /*new*/ to_local()() {
2654 return g_date_time_to_local(&this);
2657 // VERSION: 2.26
2658 // Stores the instant in time that @datetime represents into @tv.
2660 // The time contained in a #GTimeVal is always stored in the form of
2661 // seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the time
2662 // zone associated with @datetime.
2664 // On systems where 'long' is 32bit (ie: all 32bit systems and all
2665 // Windows systems), a #GTimeVal is incapable of storing the entire
2666 // range of values that #GDateTime is capable of expressing. On those
2667 // systems, this function returns %FALSE to indicate that the time is
2668 // out of range.
2670 // On systems where 'long' is 64bit, this function never fails.
2671 // RETURNS: %TRUE if successful, else %FALSE
2672 // <tv>: a #GTimeVal to modify
2673 int to_timeval()(TimeVal* tv) {
2674 return g_date_time_to_timeval(&this, tv);
2677 // VERSION: 2.26
2678 // Create a new #GDateTime corresponding to the same instant in time as
2679 // @datetime, but in the time zone @tz.
2681 // This call can fail in the case that the time goes out of bounds. For
2682 // example, converting 0001-01-01 00:00:00 UTC to a time zone west of
2683 // Greenwich will fail (due to the year 0 being out of range).
2685 // You should release the return value by calling g_date_time_unref()
2686 // when you are done with it.
2687 // RETURNS: a new #GDateTime, or %NULL
2688 // <tz>: the new #GTimeZone
2689 DateTime* /*new*/ to_timezone()(TimeZone* tz) {
2690 return g_date_time_to_timezone(&this, tz);
2693 // VERSION: 2.26
2694 // Gives the Unix time corresponding to @datetime, rounding down to the
2695 // nearest second.
2697 // Unix time is the number of seconds that have elapsed since 1970-01-01
2698 // 00:00:00 UTC, regardless of the time zone associated with @datetime.
2699 // RETURNS: the Unix time corresponding to @datetime
2700 long to_unix()() {
2701 return g_date_time_to_unix(&this);
2704 // VERSION: 2.26
2705 // Creates a new #GDateTime corresponding to the same instant in time as
2706 // @datetime, but in UTC.
2708 // This call is equivalent to calling g_date_time_to_timezone() with the
2709 // time zone returned by g_time_zone_new_utc().
2710 // RETURNS: the newly created #GDateTime
2711 DateTime* /*new*/ to_utc()() {
2712 return g_date_time_to_utc(&this);
2715 // VERSION: 2.26
2716 // Atomically decrements the reference count of @datetime by one.
2718 // When the reference count reaches zero, the resources allocated by
2719 // @datetime are freed
2720 void unref()() {
2721 g_date_time_unref(&this);
2724 // VERSION: 2.26
2725 // A comparison function for #GDateTimes that is suitable
2726 // as a #GCompareFunc. Both #GDateTimes must be non-%NULL.
2728 // than @dt2.
2729 // RETURNS: -1, 0 or 1 if @dt1 is less than, equal to or greater
2730 // <dt1>: first #GDateTime to compare
2731 // <dt2>: second #GDateTime to compare
2732 static int compare()(const(void)* dt1, const(void)* dt2) {
2733 return g_date_time_compare(dt1, dt2);
2736 // VERSION: 2.26
2737 // Checks to see if @dt1 and @dt2 are equal.
2739 // Equal here means that they represent the same moment after converting
2740 // them to the same time zone.
2741 // RETURNS: %TRUE if @dt1 and @dt2 are equal
2742 // <dt1>: a #GDateTime
2743 // <dt2>: a #GDateTime
2744 static int equal()(const(void)* dt1, const(void)* dt2) {
2745 return g_date_time_equal(dt1, dt2);
2748 // VERSION: 2.26
2749 // Hashes @datetime into a #guint, suitable for use within #GHashTable.
2750 // RETURNS: a #guint containing the hash
2751 // <datetime>: a #GDateTime
2752 static uint hash()(const(void)* datetime) {
2753 return g_date_time_hash(datetime);
2757 enum DateWeekday {
2758 BAD_WEEKDAY = 0,
2759 MONDAY = 1,
2760 TUESDAY = 2,
2761 WEDNESDAY = 3,
2762 THURSDAY = 4,
2763 FRIDAY = 5,
2764 SATURDAY = 6,
2765 SUNDAY = 7
2768 // Associates a string with a bit flag.
2769 // Used in g_parse_debug_string().
2770 struct DebugKey {
2771 char* key;
2772 uint value;
2776 // Specifies the type of function which is called when a data element
2777 // is destroyed. It is passed the pointer to the data element and
2778 // should free any memory and resources allocated for it.
2779 // <data>: the data element.
2780 extern (C) alias void function (void* data) DestroyNotify;
2782 struct Dir {
2783 // Closes the directory and deallocates all related resources.
2784 void close()() {
2785 g_dir_close(&this);
2788 // Retrieves the name of another entry in the directory, or %NULL.
2789 // The order of entries returned from this function is not defined,
2790 // and may vary by file system or other operating-system dependent
2791 // factors.
2793 // On Unix, the '.' and '..' entries are omitted, and the returned
2794 // name is in the on-disk encoding.
2796 // On Windows, as is true of all GLib functions which operate on
2797 // filenames, the returned name is in UTF-8.
2799 // more entries. The return value is owned by GLib and
2800 // must not be modified or freed.
2801 // RETURNS: The entry's name or %NULL if there are no
2802 char* read_name()() {
2803 return g_dir_read_name(&this);
2806 // Resets the given directory. The next call to g_dir_read_name()
2807 // will return the first entry again.
2808 void rewind()() {
2809 g_dir_rewind(&this);
2812 // VERSION: 2.30
2813 // Creates a subdirectory in the preferred directory for temporary
2814 // files (as returned by g_get_tmp_dir()).
2816 // @tmpl should be a string in the GLib file name encoding containing
2817 // a sequence of six 'X' characters, as the parameter to g_mkstemp().
2818 // However, unlike these functions, the template should only be a
2819 // basename, no directory components are allowed. If template is
2820 // %NULL, a default template is used.
2822 // Note that in contrast to g_mkdtemp() (and mkdtemp()) @tmpl is not
2823 // modified, and might thus be a read-only literal string.
2825 // should be freed with g_free() when not needed any longer and is
2826 // is in the GLib file name encoding. In case of errors, %NULL is
2827 // returned and @error will be set.
2828 // RETURNS: The actual name used. This string
2829 // <tmpl>: Template for directory name, as in g_mkdtemp(), basename only, or %NULL for a default template
2830 static char* /*new*/ make_tmp()(char* tmpl, GLib2.Error** error=null) {
2831 return g_dir_make_tmp(tmpl, error);
2834 // Unintrospectable function: open() / g_dir_open()
2835 // Opens a directory for reading. The names of the files in the
2836 // directory can then be retrieved using g_dir_read_name(). Note
2837 // that the ordering is not defined.
2839 // If non-%NULL, you must free the result with g_dir_close()
2840 // when you are finished with it.
2841 // RETURNS: a newly allocated #GDir on success, %NULL on failure.
2842 // <path>: the path to the directory you are interested in. On Unix in the on-disk encoding. On Windows in UTF-8
2843 // <flags>: Currently must be set to 0. Reserved for future use.
2844 static Dir* open()(char* path, uint flags, GLib2.Error** error=null) {
2845 return g_dir_open(path, flags, error);
2849 union DoubleIEEE754 {
2850 double v_double;
2852 struct mpn {
2853 static import std.bitmanip; mixin(std.bitmanip.bitfields!(
2854 uint, "mantissa_low", 32,
2855 uint, "mantissa_high", 20,
2856 uint, "biased_exponent", 11,
2857 uint, "sign", 1));
2861 enum double E = 2.718282;
2863 // Specifies the type of a function used to test two values for
2864 // equality. The function should return %TRUE if both values are equal
2865 // and %FALSE otherwise.
2866 // <a>: a value.
2867 // <b>: a value to compare with.
2868 extern (C) alias int function (const(void)* a, const(void)* b) EqualFunc;
2871 // The <structname>GError</structname> structure contains
2872 // information about an error that has occurred.
2873 struct Error {
2874 Quark domain;
2875 int code;
2876 char* message;
2879 // Unintrospectable constructor: new() / g_error_new()
2880 // Creates a new #GError with the given @domain and @code,
2881 // and a message formatted with @format.
2882 // RETURNS: a new #GError
2883 // <domain>: error domain
2884 // <code>: error code
2885 // <format>: printf()-style format for error message
2886 alias g_error_new new_; // Variadic
2888 // Creates a new #GError; unlike g_error_new(), @message is
2889 // not a printf()-style format string. Use this function if
2890 // @message contains text you don't have control over,
2891 // that could include printf() escape sequences.
2892 // RETURNS: a new #GError
2893 // <domain>: error domain
2894 // <code>: error code
2895 // <message>: error message
2896 static Error* /*new*/ new_literal()(Quark domain, int code, char* message) {
2897 return g_error_new_literal(domain, code, message);
2900 // Unintrospectable constructor: new_valist() / g_error_new_valist()
2901 // VERSION: 2.22
2902 // Creates a new #GError with the given @domain and @code,
2903 // and a message formatted with @format.
2904 // RETURNS: a new #GError
2905 // <domain>: error domain
2906 // <code>: error code
2907 // <format>: printf()-style format for error message
2908 // <args>: #va_list of parameters for the message format
2909 static Error* /*new*/ new_valist()(Quark domain, int code, char* format, va_list args) {
2910 return g_error_new_valist(domain, code, format, args);
2913 // Makes a copy of @error.
2914 // RETURNS: a new #GError
2915 Error* /*new*/ copy()() {
2916 return g_error_copy(&this);
2918 // Frees a #GError and associated resources.
2919 void free()() {
2920 g_error_free(&this);
2923 // Returns %TRUE if @error matches @domain and @code, %FALSE
2924 // otherwise. In particular, when @error is %NULL, %FALSE will
2925 // be returned.
2926 // RETURNS: whether @error has @domain and @code
2927 // <domain>: an error domain
2928 // <code>: an error code
2929 int matches()(Quark domain, int code) {
2930 return g_error_matches(&this, domain, code);
2934 enum ErrorType {
2935 UNKNOWN = 0,
2936 UNEXP_EOF = 1,
2937 UNEXP_EOF_IN_STRING = 2,
2938 UNEXP_EOF_IN_COMMENT = 3,
2939 NON_DIGIT_IN_CONST = 4,
2940 DIGIT_RADIX = 5,
2941 FLOAT_RADIX = 6,
2942 FLOAT_MALFORMED = 7
2944 enum FileError {
2945 EXIST = 0,
2946 ISDIR = 1,
2947 ACCES = 2,
2948 NAMETOOLONG = 3,
2949 NOENT = 4,
2950 NOTDIR = 5,
2951 NXIO = 6,
2952 NODEV = 7,
2953 ROFS = 8,
2954 TXTBSY = 9,
2955 FAULT = 10,
2956 LOOP = 11,
2957 NOSPC = 12,
2958 NOMEM = 13,
2959 MFILE = 14,
2960 NFILE = 15,
2961 BADF = 16,
2962 INVAL = 17,
2963 PIPE = 18,
2964 AGAIN = 19,
2965 INTR = 20,
2966 IO = 21,
2967 PERM = 22,
2968 NOSYS = 23,
2969 FAILED = 24
2971 enum FileTest {
2972 IS_REGULAR = 1,
2973 IS_SYMLINK = 2,
2974 IS_DIR = 4,
2975 IS_EXECUTABLE = 8,
2976 EXISTS = 16
2978 union FloatIEEE754 {
2979 float v_float;
2981 struct mpn {
2982 static import std.bitmanip; mixin(std.bitmanip.bitfields!(
2983 uint, "mantissa", 23,
2984 uint, "biased_exponent", 8,
2985 uint, "sign", 1));
2990 // Flags to modify the format of the string returned by
2991 // g_format_size_full().
2992 enum FormatSizeFlags {
2993 DEFAULT = 0,
2994 LONG_FORMAT = 1,
2995 IEC_UNITS = 2
2998 // Declares a type of function which takes an arbitrary
2999 // data pointer argument and has no return value. It is
3000 // not currently used in GLib or GTK+.
3001 // <data>: a data pointer
3002 extern (C) alias void function (void* data) FreeFunc;
3005 // Specifies the type of functions passed to g_list_foreach() and
3006 // g_slist_foreach().
3007 // <data>: the element's data.
3008 // <user_data>: user data passed to g_list_foreach() or g_slist_foreach().
3009 extern (C) alias void function (void* data, void* user_data) Func;
3011 enum GINT16_FORMAT = "hi";
3012 enum GINT16_MODIFIER = "h";
3013 enum GINT32_FORMAT = "i";
3014 enum GINT32_MODIFIER = "";
3015 enum GINT64_FORMAT = "lli";
3016 enum GINT64_MODIFIER = "ll";
3017 enum GINTPTR_FORMAT = "i";
3018 enum GINTPTR_MODIFIER = "";
3019 enum GNUC_FUNCTION = "";
3020 enum GNUC_PRETTY_FUNCTION = "";
3021 enum GSIZE_FORMAT = "u";
3022 enum GSIZE_MODIFIER = "";
3023 enum GSSIZE_FORMAT = "i";
3024 enum GUINT16_FORMAT = "hu";
3025 enum GUINT32_FORMAT = "u";
3026 enum GUINT64_FORMAT = "llu";
3027 enum GUINTPTR_FORMAT = "u";
3028 enum int HAVE_GINT64 = 1;
3029 enum int HAVE_GNUC_VARARGS = 1;
3030 enum int HAVE_GNUC_VISIBILITY = 1;
3031 enum int HAVE_GROWING_STACK = 1;
3032 enum int HAVE_INLINE = 1;
3033 enum int HAVE_ISO_VARARGS = 1;
3034 enum int HAVE___INLINE = 1;
3035 enum int HAVE___INLINE__ = 1;
3037 // Specifies the type of the function passed to g_hash_table_foreach().
3038 // It is called with each key/value pair, together with the @user_data
3039 // parameter which is passed to g_hash_table_foreach().
3040 // <key>: a key.
3041 // <value>: the value corresponding to the key.
3042 // <user_data>: user data passed to g_hash_table_foreach().
3043 extern (C) alias void function (void* key, void* value, void* user_data) HFunc;
3045 enum int HOOK_FLAG_USER_SHIFT = 4;
3047 // Specifies the type of the function passed to
3048 // g_hash_table_foreach_remove(). It is called with each key/value
3049 // pair, together with the @user_data parameter passed to
3050 // g_hash_table_foreach_remove(). It should return %TRUE if the
3051 // key/value pair should be removed from the #GHashTable.
3052 // <key>: a key.
3053 // <value>: the value associated with the key.
3054 // <user_data>: user data passed to g_hash_table_remove().
3055 extern (C) alias int function (void* key, void* value, void* user_data) HRFunc;
3058 // Specifies the type of the hash function which is passed to
3059 // g_hash_table_new() when a #GHashTable is created.
3061 // The function is passed a key and should return a #guint hash value.
3062 // The functions g_direct_hash(), g_int_hash() and g_str_hash() provide
3063 // hash functions which can be used when the key is a #gpointer, #gint,
3064 // and #gchar* respectively.
3066 // <!-- FIXME: Need more here. --> The hash values should be evenly
3067 // distributed over a fairly large range? The modulus is taken with the
3068 // hash table size (a prime number) to find the 'bucket' to place each
3069 // key into. The function should also be very fast, since it is called
3070 // for each key lookup.
3071 // <key>: a key.
3072 extern (C) alias uint function (const(void)* key) HashFunc;
3075 // The #GHashTable struct is an opaque data structure to represent a
3076 // <link linkend="glib-Hash-Tables">Hash Table</link>. It should only be
3077 // accessed via the following functions.
3078 struct HashTable {
3080 // Destroys all keys and values in the #GHashTable and decrements its
3081 // reference count by 1. If keys and/or values are dynamically allocated,
3082 // you should either free them first or create the #GHashTable with destroy
3083 // notifiers using g_hash_table_new_full(). In the latter case the destroy
3084 // functions you supplied will be called on all keys and values during the
3085 // destruction phase.
3086 // <hash_table>: a #GHashTable.
3087 static void destroy()(GLib2.HashTable* hash_table) {
3088 g_hash_table_destroy(hash_table);
3091 // Unintrospectable function: find() / g_hash_table_find()
3092 // VERSION: 2.4
3093 // Calls the given function for key/value pairs in the #GHashTable until
3094 // @predicate returns %TRUE. The function is passed the key and value of
3095 // each pair, and the given @user_data parameter. The hash table may not
3096 // be modified while iterating over it (you can't add/remove items).
3098 // Note, that hash tables are really only optimized for forward lookups,
3099 // i.e. g_hash_table_lookup().
3100 // So code that frequently issues g_hash_table_find() or
3101 // g_hash_table_foreach() (e.g. in the order of once per every entry in a
3102 // hash table) should probably be reworked to use additional or different
3103 // data structures for reverse lookups (keep in mind that an O(n) find/foreach
3104 // operation issued for all n values in a hash table ends up needing O(n*n)
3105 // operations).
3107 // for which @predicate evaluates to %TRUE. If no pair with the
3108 // requested property is found, %NULL is returned.
3109 // RETURNS: The value of the first key/value pair is returned,
3110 // <hash_table>: a #GHashTable.
3111 // <predicate>: function to test the key/value pairs for a certain property.
3112 // <user_data>: user data to pass to the function.
3113 static void* find()(GLib2.HashTable* hash_table, HRFunc predicate, void* user_data) {
3114 return g_hash_table_find(hash_table, predicate, user_data);
3117 // Unintrospectable function: foreach() / g_hash_table_foreach()
3118 // Calls the given function for each of the key/value pairs in the
3119 // #GHashTable. The function is passed the key and value of each
3120 // pair, and the given @user_data parameter. The hash table may not
3121 // be modified while iterating over it (you can't add/remove
3122 // items). To remove all items matching a predicate, use
3123 // g_hash_table_foreach_remove().
3125 // See g_hash_table_find() for performance caveats for linear
3126 // order searches in contrast to g_hash_table_lookup().
3127 // <hash_table>: a #GHashTable.
3128 // <func>: the function to call for each key/value pair.
3129 // <user_data>: user data to pass to the function.
3130 static void foreach_()(GLib2.HashTable* hash_table, HFunc func, void* user_data) {
3131 g_hash_table_foreach(hash_table, func, user_data);
3134 // Unintrospectable function: foreach_remove() / g_hash_table_foreach_remove()
3135 // Calls the given function for each key/value pair in the #GHashTable.
3136 // If the function returns %TRUE, then the key/value pair is removed from the
3137 // #GHashTable. If you supplied key or value destroy functions when creating
3138 // the #GHashTable, they are used to free the memory allocated for the removed
3139 // keys and values.
3141 // See #GHashTableIter for an alternative way to loop over the
3142 // key/value pairs in the hash table.
3143 // RETURNS: the number of key/value pairs removed.
3144 // <hash_table>: a #GHashTable.
3145 // <func>: the function to call for each key/value pair.
3146 // <user_data>: user data to pass to the function.
3147 static uint foreach_remove()(GLib2.HashTable* hash_table, HRFunc func, void* user_data) {
3148 return g_hash_table_foreach_remove(hash_table, func, user_data);
3151 // Unintrospectable function: foreach_steal() / g_hash_table_foreach_steal()
3152 // Calls the given function for each key/value pair in the #GHashTable.
3153 // If the function returns %TRUE, then the key/value pair is removed from the
3154 // #GHashTable, but no key or value destroy functions are called.
3156 // See #GHashTableIter for an alternative way to loop over the
3157 // key/value pairs in the hash table.
3158 // RETURNS: the number of key/value pairs removed.
3159 // <hash_table>: a #GHashTable.
3160 // <func>: the function to call for each key/value pair.
3161 // <user_data>: user data to pass to the function.
3162 static uint foreach_steal()(GLib2.HashTable* hash_table, HRFunc func, void* user_data) {
3163 return g_hash_table_foreach_steal(hash_table, func, user_data);
3166 // Unintrospectable function: get_keys() / g_hash_table_get_keys()
3167 // VERSION: 2.14
3168 // Retrieves every key inside @hash_table. The returned data is valid
3169 // until @hash_table is modified.
3171 // table. The content of the list is owned by the hash table and
3172 // should not be modified or freed. Use g_list_free() when done
3173 // using the list.
3174 // RETURNS: a #GList containing all the keys inside the hash
3175 // <hash_table>: a #GHashTable
3176 static GLib2.List* get_keys()(GLib2.HashTable* hash_table) {
3177 return g_hash_table_get_keys(hash_table);
3180 // Unintrospectable function: get_values() / g_hash_table_get_values()
3181 // VERSION: 2.14
3182 // Retrieves every value inside @hash_table. The returned data is
3183 // valid until @hash_table is modified.
3185 // table. The content of the list is owned by the hash table and
3186 // should not be modified or freed. Use g_list_free() when done
3187 // using the list.
3188 // RETURNS: a #GList containing all the values inside the hash
3189 // <hash_table>: a #GHashTable
3190 static GLib2.List* get_values()(GLib2.HashTable* hash_table) {
3191 return g_hash_table_get_values(hash_table);
3194 // Inserts a new key and value into a #GHashTable.
3196 // If the key already exists in the #GHashTable its current value is replaced
3197 // with the new value. If you supplied a @value_destroy_func when creating the
3198 // #GHashTable, the old value is freed using that function. If you supplied
3199 // a @key_destroy_func when creating the #GHashTable, the passed key is freed
3200 // using that function.
3201 // <hash_table>: a #GHashTable.
3202 // <key>: a key to insert.
3203 // <value>: the value to associate with the key.
3204 static void insert()(GLib2.HashTable* hash_table, void* key, void* value) {
3205 g_hash_table_insert(hash_table, key, value);
3208 // Unintrospectable function: lookup() / g_hash_table_lookup()
3209 // Looks up a key in a #GHashTable. Note that this function cannot
3210 // distinguish between a key that is not present and one which is present
3211 // and has the value %NULL. If you need this distinction, use
3212 // g_hash_table_lookup_extended().
3213 // RETURNS: the associated value, or %NULL if the key is not found.
3214 // <hash_table>: a #GHashTable.
3215 // <key>: the key to look up.
3216 static void* lookup()(GLib2.HashTable* hash_table, const(void)* key) {
3217 return g_hash_table_lookup(hash_table, key);
3220 // Looks up a key in the #GHashTable, returning the original key and the
3221 // associated value and a #gboolean which is %TRUE if the key was found. This
3222 // is useful if you need to free the memory allocated for the original key,
3223 // for example before calling g_hash_table_remove().
3225 // You can actually pass %NULL for @lookup_key to test
3226 // whether the %NULL key exists, provided the hash and equal functions
3227 // of @hash_table are %NULL-safe.
3228 // RETURNS: %TRUE if the key was found in the #GHashTable.
3229 // <hash_table>: a #GHashTable
3230 // <lookup_key>: the key to look up
3231 // <orig_key>: return location for the original key, or %NULL
3232 // <value>: return location for the value associated with the key, or %NULL
3233 static int lookup_extended()(GLib2.HashTable* hash_table, const(void)* lookup_key, void** orig_key, void** value) {
3234 return g_hash_table_lookup_extended(hash_table, lookup_key, orig_key, value);
3237 // Unintrospectable function: new() / g_hash_table_new()
3238 // Creates a new #GHashTable with a reference count of 1.
3239 // RETURNS: a new #GHashTable.
3240 // <hash_func>: a function to create a hash value from a key. Hash values are used to determine where keys are stored within the #GHashTable data structure. The g_direct_hash(), g_int_hash(), g_int64_hash(), g_double_hash() and g_str_hash() functions are provided for some common types of keys. If hash_func is %NULL, g_direct_hash() is used.
3241 // <key_equal_func>: a function to check two keys for equality. This is used when looking up keys in the #GHashTable. The g_direct_equal(), g_int_equal(), g_int64_equal(), g_double_equal() and g_str_equal() functions are provided for the most common types of keys. If @key_equal_func is %NULL, keys are compared directly in a similar fashion to g_direct_equal(), but without the overhead of a function call.
3242 static GLib2.HashTable* new_()(HashFunc hash_func, EqualFunc key_equal_func) {
3243 return g_hash_table_new(hash_func, key_equal_func);
3246 // Unintrospectable function: new_full() / g_hash_table_new_full()
3247 // Creates a new #GHashTable like g_hash_table_new() with a reference count
3248 // of 1 and allows to specify functions to free the memory allocated for the
3249 // key and value that get called when removing the entry from the #GHashTable.
3250 // RETURNS: a new #GHashTable.
3251 // <hash_func>: a function to create a hash value from a key.
3252 // <key_equal_func>: a function to check two keys for equality.
3253 // <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.
3254 // <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.
3255 static GLib2.HashTable* new_full()(HashFunc hash_func, EqualFunc key_equal_func, DestroyNotify key_destroy_func, DestroyNotify value_destroy_func) {
3256 return g_hash_table_new_full(hash_func, key_equal_func, key_destroy_func, value_destroy_func);
3259 // Unintrospectable function: ref() / g_hash_table_ref()
3260 // VERSION: 2.10
3261 // Atomically increments the reference count of @hash_table by one.
3262 // This function is MT-safe and may be called from any thread.
3263 // RETURNS: the passed in #GHashTable.
3264 // <hash_table>: a valid #GHashTable.
3265 static GLib2.HashTable* ref_()(GLib2.HashTable* hash_table) {
3266 return g_hash_table_ref(hash_table);
3269 // Removes a key and its associated value from a #GHashTable.
3271 // If the #GHashTable was created using g_hash_table_new_full(), the
3272 // key and value are freed using the supplied destroy functions, otherwise
3273 // you have to make sure that any dynamically allocated values are freed
3274 // yourself.
3275 // RETURNS: %TRUE if the key was found and removed from the #GHashTable.
3276 // <hash_table>: a #GHashTable.
3277 // <key>: the key to remove.
3278 static int remove()(GLib2.HashTable* hash_table, const(void)* key) {
3279 return g_hash_table_remove(hash_table, key);
3282 // VERSION: 2.12
3283 // Removes all keys and their associated values from a #GHashTable.
3285 // If the #GHashTable was created using g_hash_table_new_full(), the keys
3286 // and values are freed using the supplied destroy functions, otherwise you
3287 // have to make sure that any dynamically allocated values are freed
3288 // yourself.
3289 // <hash_table>: a #GHashTable
3290 static void remove_all()(GLib2.HashTable* hash_table) {
3291 g_hash_table_remove_all(hash_table);
3294 // Inserts a new key and value into a #GHashTable similar to
3295 // g_hash_table_insert(). The difference is that if the key already exists
3296 // in the #GHashTable, it gets replaced by the new key. If you supplied a
3297 // @value_destroy_func when creating the #GHashTable, the old value is freed
3298 // using that function. If you supplied a @key_destroy_func when creating the
3299 // #GHashTable, the old key is freed using that function.
3300 // <hash_table>: a #GHashTable.
3301 // <key>: a key to insert.
3302 // <value>: the value to associate with the key.
3303 static void replace()(GLib2.HashTable* hash_table, void* key, void* value) {
3304 g_hash_table_replace(hash_table, key, value);
3307 // Returns the number of elements contained in the #GHashTable.
3308 // RETURNS: the number of key/value pairs in the #GHashTable.
3309 // <hash_table>: a #GHashTable.
3310 static uint size()(GLib2.HashTable* hash_table) {
3311 return g_hash_table_size(hash_table);
3314 // Removes a key and its associated value from a #GHashTable without
3315 // calling the key and value destroy functions.
3316 // RETURNS: %TRUE if the key was found and removed from the #GHashTable.
3317 // <hash_table>: a #GHashTable.
3318 // <key>: the key to remove.
3319 static int steal()(GLib2.HashTable* hash_table, const(void)* key) {
3320 return g_hash_table_steal(hash_table, key);
3323 // VERSION: 2.12
3324 // Removes all keys and their associated values from a #GHashTable
3325 // without calling the key and value destroy functions.
3326 // <hash_table>: a #GHashTable.
3327 static void steal_all()(GLib2.HashTable* hash_table) {
3328 g_hash_table_steal_all(hash_table);
3331 // VERSION: 2.10
3332 // Atomically decrements the reference count of @hash_table by one.
3333 // If the reference count drops to 0, all keys and values will be
3334 // destroyed, and all memory allocated by the hash table is released.
3335 // This function is MT-safe and may be called from any thread.
3336 // <hash_table>: a valid #GHashTable.
3337 static void unref()(GLib2.HashTable* hash_table) {
3338 g_hash_table_unref(hash_table);
3343 // A GHashTableIter structure represents an iterator that can be used
3344 // to iterate over the elements of a #GHashTable. GHashTableIter
3345 // structures are typically allocated on the stack and then initialized
3346 // with g_hash_table_iter_init().
3347 struct HashTableIter {
3348 private void* dummy1, dummy2, dummy3;
3349 private int dummy4;
3350 private int dummy5;
3351 private void* dummy6;
3354 // Unintrospectable method: get_hash_table() / g_hash_table_iter_get_hash_table()
3355 // VERSION: 2.16
3356 // Returns the #GHashTable associated with @iter.
3357 // RETURNS: the #GHashTable associated with @iter.
3358 GLib2.HashTable* get_hash_table()() {
3359 return g_hash_table_iter_get_hash_table(&this);
3362 // VERSION: 2.16
3363 // Initializes a key/value pair iterator and associates it with
3364 // @hash_table. Modifying the hash table after calling this function
3365 // invalidates the returned iterator.
3366 // |[
3367 // GHashTableIter iter;
3368 // gpointer key, value;
3370 // g_hash_table_iter_init (&iter, hash_table);
3371 // while (g_hash_table_iter_next (&iter, &key, &value))
3372 // {
3373 // /&ast; do something with key and value &ast;/
3374 // }
3375 // ]|
3376 // <hash_table>: a #GHashTable.
3377 void init()(GLib2.HashTable* hash_table) {
3378 g_hash_table_iter_init(&this, hash_table);
3381 // VERSION: 2.16
3382 // Advances @iter and retrieves the key and/or value that are now
3383 // pointed to as a result of this advancement. If %FALSE is returned,
3384 // @key and @value are not set, and the iterator becomes invalid.
3385 // RETURNS: %FALSE if the end of the #GHashTable has been reached.
3386 // <key>: a location to store the key, or %NULL.
3387 // <value>: a location to store the value, or %NULL.
3388 int next()(void** key, void** value) {
3389 return g_hash_table_iter_next(&this, key, value);
3392 // VERSION: 2.16
3393 // Removes the key/value pair currently pointed to by the iterator
3394 // from its associated #GHashTable. Can only be called after
3395 // g_hash_table_iter_next() returned %TRUE, and cannot be called more
3396 // than once for the same key/value pair.
3398 // If the #GHashTable was created using g_hash_table_new_full(), the
3399 // key and value are freed using the supplied destroy functions, otherwise
3400 // you have to make sure that any dynamically allocated values are freed
3401 // yourself.
3402 void remove()() {
3403 g_hash_table_iter_remove(&this);
3406 // VERSION: 2.29.9
3407 // Replaces the value currently pointed to by the iterator
3408 // from its associated #GHashTable. Can only be called after
3409 // g_hash_table_iter_next() returned %TRUE.
3411 // If you supplied a @value_destroy_func when creating the #GHashTable,
3412 // the old value is freed using that function.
3413 // <value>: the value to replace with
3414 void replace()(void* value) {
3415 g_hash_table_iter_replace(&this, value);
3418 // VERSION: 2.16
3419 // Removes the key/value pair currently pointed to by the iterator
3420 // from its associated #GHashTable, without calling the key and value
3421 // destroy functions. Can only be called after
3422 // g_hash_table_iter_next() returned %TRUE, and cannot be called more
3423 // than once for the same key/value pair.
3424 void steal()() {
3425 g_hash_table_iter_steal(&this);
3430 // An opaque structure representing a HMAC operation.
3431 // To create a new GHmac, use g_hmac_new(). To free
3432 // a GHmac, use g_hmac_unref().
3433 struct Hmac /* Version 2.30 */ {
3435 // Unintrospectable method: copy() / g_hmac_copy()
3436 // VERSION: 2.30
3437 // Copies a #GHmac. If @hmac has been closed, by calling
3438 // g_hmac_get_string() or g_hmac_get_digest(), the copied
3439 // HMAC will be closed as well.
3441 // when finished using it.
3442 // RETURNS: the copy of the passed #GHmac. Use g_hmac_unref()
3443 Hmac* copy()() {
3444 return g_hmac_copy(&this);
3447 // VERSION: 2.30
3448 // Gets the digest from @checksum as a raw binary array and places it
3449 // into @buffer. The size of the digest depends on the type of checksum.
3451 // Once this function has been called, the #GHmac is closed and can
3452 // no longer be updated with g_checksum_update().
3453 // <buffer>: output buffer
3454 // <digest_len>: an inout parameter. The caller initializes it to the size of @buffer. After the call it contains the length of the digest
3455 void get_digest()(ubyte* buffer, size_t* digest_len) {
3456 g_hmac_get_digest(&this, buffer, digest_len);
3459 // VERSION: 2.30
3460 // Gets the HMAC as an hexadecimal string.
3462 // Once this function has been called the #GHmac can no longer be
3463 // updated with g_hmac_update().
3465 // The hexadecimal characters will be lower case.
3467 // returned string is owned by the HMAC and should not be modified
3468 // or freed.
3469 // RETURNS: the hexadecimal representation of the HMAC. The
3470 char* get_string()() {
3471 return g_hmac_get_string(&this);
3474 // Unintrospectable method: ref() / g_hmac_ref()
3475 // VERSION: 2.30
3476 // Atomically increments the reference count of @hmac by one.
3478 // This function is MT-safe and may be called from any thread.
3479 // RETURNS: the passed in #GHmac.
3480 Hmac* ref_()() {
3481 return g_hmac_ref(&this);
3484 // VERSION: 2.30
3485 // Atomically decrements the reference count of @hmac by one.
3487 // If the reference count drops to 0, all keys and values will be
3488 // destroyed, and all memory allocated by the hash table is released.
3489 // This function is MT-safe and may be called from any thread.
3490 // Frees the memory allocated for @hmac.
3491 void unref()() {
3492 g_hmac_unref(&this);
3495 // VERSION: 2.30
3496 // Feeds @data into an existing #GHmac.
3498 // The HMAC must still be open, that is g_hmac_get_string() or
3499 // g_hmac_get_digest() must not have been called on @hmac.
3500 // <data>: buffer used to compute the checksum
3501 // <length>: size of the buffer, or -1 if it is a nul-terminated string
3502 void update()(ubyte* data, ssize_t length) {
3503 g_hmac_update(&this, data, length);
3506 // Unintrospectable function: new() / g_hmac_new()
3507 // VERSION: 2.30
3508 // Creates a new #GHmac, using the digest algorithm @digest_type.
3509 // If the @digest_type is not known, %NULL is returned.
3510 // A #GHmac can be used to compute the HMAC of a key and an
3511 // arbitrary binary blob, using different hashing algorithms.
3513 // A #GHmac works by feeding a binary blob through g_hmac_update()
3514 // until the data is complete; the digest can then be extracted
3515 // using g_hmac_get_string(), which will return the checksum as a
3516 // hexadecimal string; or g_hmac_get_digest(), which will return a
3517 // array of raw bytes. Once either g_hmac_get_string() or
3518 // g_hmac_get_digest() have been called on a #GHmac, the HMAC
3519 // will be closed and it won't be possible to call g_hmac_update()
3520 // on it anymore.
3522 // Use g_hmac_unref() to free the memory allocated by it.
3523 // RETURNS: the newly created #GHmac, or %NULL.
3524 // <digest_type>: the desired type of digest
3525 // <key>: the key for the HMAC
3526 // <key_len>: the length of the keys
3527 static Hmac* new_()(ChecksumType digest_type, ubyte* key, size_t key_len) {
3528 return g_hmac_new(digest_type, key, key_len);
3532 struct Hook {
3533 void* data;
3534 Hook* next, prev;
3535 uint ref_count;
3536 c_ulong hook_id;
3537 uint flags;
3538 void* func;
3539 DestroyNotify destroy_;
3541 int compare_ids()(Hook* sibling) {
3542 return g_hook_compare_ids(&this, sibling);
3544 // Unintrospectable function: alloc() / g_hook_alloc()
3545 static Hook* alloc()(HookList* hook_list) {
3546 return g_hook_alloc(hook_list);
3548 static int destroy()(HookList* hook_list, c_ulong hook_id) {
3549 return g_hook_destroy(hook_list, hook_id);
3551 static void destroy_link()(HookList* hook_list, Hook* hook) {
3552 g_hook_destroy_link(hook_list, hook);
3554 // Unintrospectable function: find() / g_hook_find()
3555 static Hook* find()(HookList* hook_list, int need_valids, HookFindFunc func, void* data) {
3556 return g_hook_find(hook_list, need_valids, func, data);
3558 // Unintrospectable function: find_data() / g_hook_find_data()
3559 static Hook* find_data()(HookList* hook_list, int need_valids, void* data) {
3560 return g_hook_find_data(hook_list, need_valids, data);
3562 // Unintrospectable function: find_func() / g_hook_find_func()
3563 static Hook* find_func()(HookList* hook_list, int need_valids, void* func) {
3564 return g_hook_find_func(hook_list, need_valids, func);
3566 // Unintrospectable function: find_func_data() / g_hook_find_func_data()
3567 static Hook* find_func_data()(HookList* hook_list, int need_valids, void* func, void* data) {
3568 return g_hook_find_func_data(hook_list, need_valids, func, data);
3570 // Unintrospectable function: first_valid() / g_hook_first_valid()
3571 static Hook* first_valid()(HookList* hook_list, int may_be_in_call) {
3572 return g_hook_first_valid(hook_list, may_be_in_call);
3574 static void free()(HookList* hook_list, Hook* hook) {
3575 g_hook_free(hook_list, hook);
3577 // Unintrospectable function: get() / g_hook_get()
3578 static Hook* get()(HookList* hook_list, c_ulong hook_id) {
3579 return g_hook_get(hook_list, hook_id);
3581 static void insert_before()(HookList* hook_list, Hook* sibling, Hook* hook) {
3582 g_hook_insert_before(hook_list, sibling, hook);
3584 // Unintrospectable function: insert_sorted() / g_hook_insert_sorted()
3585 static void insert_sorted()(HookList* hook_list, Hook* hook, HookCompareFunc func) {
3586 g_hook_insert_sorted(hook_list, hook, func);
3588 // Unintrospectable function: next_valid() / g_hook_next_valid()
3589 static Hook* next_valid()(HookList* hook_list, Hook* hook, int may_be_in_call) {
3590 return g_hook_next_valid(hook_list, hook, may_be_in_call);
3592 static void prepend()(HookList* hook_list, Hook* hook) {
3593 g_hook_prepend(hook_list, hook);
3595 // Unintrospectable function: ref() / g_hook_ref()
3596 static Hook* ref_()(HookList* hook_list, Hook* hook) {
3597 return g_hook_ref(hook_list, hook);
3599 static void unref()(HookList* hook_list, Hook* hook) {
3600 g_hook_unref(hook_list, hook);
3604 extern (C) alias int function (void* data) HookCheckFunc;
3606 extern (C) alias int function (Hook* hook, void* marshal_data) HookCheckMarshaller;
3608 extern (C) alias int function (Hook* new_hook, Hook* sibling) HookCompareFunc;
3610 extern (C) alias void function (HookList* hook_list, Hook* hook) HookFinalizeFunc;
3612 extern (C) alias int function (Hook* hook, void* data) HookFindFunc;
3614 enum HookFlagMask {
3615 ACTIVE = 1,
3616 IN_CALL = 2,
3617 MASK = 15
3619 extern (C) alias void function (void* data) HookFunc;
3621 struct HookList {
3622 c_ulong seq_id;
3623 static import std.bitmanip; mixin(std.bitmanip.bitfields!(
3624 uint, "hook_size", 16,
3625 uint, "is_setup", 1,
3626 uint, "__dummy32A", 15));
3627 Hook* hooks;
3628 void* dummy3;
3629 HookFinalizeFunc finalize_hook;
3630 void*[2] dummy;
3632 void clear()() {
3633 g_hook_list_clear(&this);
3635 void init()(uint hook_size) {
3636 g_hook_list_init(&this, hook_size);
3638 void invoke()(int may_recurse) {
3639 g_hook_list_invoke(&this, may_recurse);
3641 void invoke_check()(int may_recurse) {
3642 g_hook_list_invoke_check(&this, may_recurse);
3644 // Unintrospectable method: marshal() / g_hook_list_marshal()
3645 void marshal()(int may_recurse, HookMarshaller marshaller, void* marshal_data) {
3646 g_hook_list_marshal(&this, may_recurse, marshaller, marshal_data);
3648 // Unintrospectable method: marshal_check() / g_hook_list_marshal_check()
3649 void marshal_check()(int may_recurse, HookCheckMarshaller marshaller, void* marshal_data) {
3650 g_hook_list_marshal_check(&this, may_recurse, marshaller, marshal_data);
3654 extern (C) alias void function (Hook* hook, void* marshal_data) HookMarshaller;
3656 struct IConv {
3658 // Same as the standard UNIX routine iconv(), but
3659 // may be implemented via libiconv on UNIX flavors that lack
3660 // a native implementation.
3662 // GLib provides g_convert() and g_locale_to_utf8() which are likely
3663 // more convenient than the raw iconv wrappers.
3664 // RETURNS: count of non-reversible conversions, or -1 on error
3665 // <inbuf>: bytes to convert
3666 // <inbytes_left>: inout parameter, bytes remaining to convert in @inbuf
3667 // <outbuf>: converted output bytes
3668 // <outbytes_left>: inout parameter, bytes available to fill in @outbuf
3669 size_t /*NAME MISSING IN GIR*/ iconv()(char** inbuf, size_t* inbytes_left, char** outbuf, size_t* outbytes_left) {
3670 return g_iconv(&this, inbuf, inbytes_left, outbuf, outbytes_left);
3673 // Same as the standard UNIX routine iconv_close(), but
3674 // may be implemented via libiconv on UNIX flavors that lack
3675 // a native implementation. Should be called to clean up
3676 // the conversion descriptor from g_iconv_open() when
3677 // you are done converting things.
3679 // GLib provides g_convert() and g_locale_to_utf8() which are likely
3680 // more convenient than the raw iconv wrappers.
3681 // RETURNS: -1 on error, 0 on success
3682 int close()() {
3683 return g_iconv_close(&this);
3686 // Unintrospectable function: open() / g_iconv_open()
3687 // Same as the standard UNIX routine iconv_open(), but
3688 // may be implemented via libiconv on UNIX flavors that lack
3689 // a native implementation.
3691 // GLib provides g_convert() and g_locale_to_utf8() which are likely
3692 // more convenient than the raw iconv wrappers.
3694 // opening the converter failed.
3695 // RETURNS: a "conversion descriptor", or (GIConv)-1 if
3696 // <to_codeset>: destination codeset
3697 // <from_codeset>: source codeset
3698 static IConv open()(char* to_codeset, char* from_codeset) {
3699 return g_iconv_open(to_codeset, from_codeset);
3703 enum int IEEE754_DOUBLE_BIAS = 1023;
3704 enum int IEEE754_FLOAT_BIAS = 127;
3706 // A data structure representing an IO Channel. The fields should be
3707 // considered private and should only be accessed with the following
3708 // functions.
3709 struct IOChannel {
3710 private int ref_count;
3711 private IOFuncs* funcs;
3712 private char* encoding;
3713 private IConv read_cd, write_cd;
3714 private char* line_term;
3715 private uint line_term_len;
3716 private size_t buf_size;
3717 private String* read_buf, encoded_read_buf, write_buf;
3718 private char[6] partial_write_buf;
3719 static import std.bitmanip; mixin(std.bitmanip.bitfields!(
3720 uint, "use_buffer", 1,
3721 uint, "do_encode", 1,
3722 uint, "close_on_unref", 1,
3723 uint, "is_readable", 1,
3724 uint, "is_writeable", 1,
3725 uint, "is_seekable", 1,
3726 uint, "__dummy32A", 26));
3727 private void* reserved1, reserved2;
3730 // Open a file @filename as a #GIOChannel using mode @mode. This
3731 // channel will be closed when the last reference to it is dropped,
3732 // so there is no need to call g_io_channel_close() (though doing
3733 // so will not cause problems, as long as no attempt is made to
3734 // access the channel after it is closed).
3735 // RETURNS: A #GIOChannel on success, %NULL on failure.
3736 // <filename>: A string containing the name of a file
3737 // <mode>: One of "r", "w", "a", "r+", "w+", "a+". These have the same meaning as in fopen()
3738 static IOChannel* /*new*/ new_file()(char* filename, char* mode, GLib2.Error** error=null) {
3739 return g_io_channel_new_file(filename, mode, error);
3742 // Creates a new #GIOChannel given a file descriptor. On UNIX systems
3743 // this works for plain files, pipes, and sockets.
3745 // The returned #GIOChannel has a reference count of 1.
3747 // The default encoding for #GIOChannel is UTF-8. If your application
3748 // is reading output from a command using via pipe, you may need to set
3749 // the encoding to the encoding of the current locale (see
3750 // g_get_charset()) with the g_io_channel_set_encoding() function.
3752 // If you want to read raw binary data without interpretation, then
3753 // call the g_io_channel_set_encoding() function with %NULL for the
3754 // encoding argument.
3756 // This function is available in GLib on Windows, too, but you should
3757 // avoid using it on Windows. The domain of file descriptors and
3758 // sockets overlap. There is no way for GLib to know which one you mean
3759 // in case the argument you pass to this function happens to be both a
3760 // valid file descriptor and socket. If that happens a warning is
3761 // issued, and GLib assumes that it is the file descriptor you mean.
3762 // <fd>: a file descriptor.
3763 static IOChannel* /*new*/ unix_new()(int fd) {
3764 return g_io_channel_unix_new(fd);
3767 // Close an IO channel. Any pending data to be written will be
3768 // flushed, ignoring errors. The channel will not be freed until the
3769 // last reference is dropped using g_io_channel_unref().
3771 // Deprecated:2.2: Use g_io_channel_shutdown() instead.
3772 void close()() {
3773 g_io_channel_close(&this);
3776 // Flushes the write buffer for the GIOChannel.
3778 // #G_IO_STATUS_NORMAL, #G_IO_STATUS_AGAIN, or
3779 // #G_IO_STATUS_ERROR.
3780 // RETURNS: the status of the operation: One of
3781 IOStatus flush()(GLib2.Error** error=null) {
3782 return g_io_channel_flush(&this, error);
3785 // This function returns a #GIOCondition depending on whether there
3786 // is data to be read/space to write data in the internal buffers in
3787 // the #GIOChannel. Only the flags %G_IO_IN and %G_IO_OUT may be set.
3788 // RETURNS: A #GIOCondition
3789 IOCondition get_buffer_condition()() {
3790 return g_io_channel_get_buffer_condition(&this);
3793 // Gets the buffer size.
3794 // RETURNS: the size of the buffer.
3795 size_t get_buffer_size()() {
3796 return g_io_channel_get_buffer_size(&this);
3799 // Returns whether @channel is buffered.
3800 // RETURNS: %TRUE if the @channel is buffered.
3801 int get_buffered()() {
3802 return g_io_channel_get_buffered(&this);
3805 // Returns whether the file/socket/whatever associated with @channel
3806 // will be closed when @channel receives its final unref and is
3807 // destroyed. The default value of this is %TRUE for channels created
3808 // by g_io_channel_new_file (), and %FALSE for all other channels.
3810 // the GIOChannel data structure.
3811 // RETURNS: Whether the channel will be closed on the final unref of
3812 int get_close_on_unref()() {
3813 return g_io_channel_get_close_on_unref(&this);
3816 // Gets the encoding for the input/output of the channel.
3817 // The internal encoding is always UTF-8. The encoding %NULL
3818 // makes the channel safe for binary data.
3820 // owned by GLib and must not be freed.
3821 // RETURNS: A string containing the encoding, this string is
3822 char* get_encoding()() {
3823 return g_io_channel_get_encoding(&this);
3826 // Gets the current flags for a #GIOChannel, including read-only
3827 // flags such as %G_IO_FLAG_IS_READABLE.
3829 // The values of the flags %G_IO_FLAG_IS_READABLE and %G_IO_FLAG_IS_WRITEABLE
3830 // are cached for internal use by the channel when it is created.
3831 // If they should change at some later point (e.g. partial shutdown
3832 // of a socket with the UNIX shutdown() function), the user
3833 // should immediately call g_io_channel_get_flags() to update
3834 // the internal values of these flags.
3835 // RETURNS: the flags which are set on the channel
3836 IOFlags get_flags()() {
3837 return g_io_channel_get_flags(&this);
3840 // This returns the string that #GIOChannel uses to determine
3841 // where in the file a line break occurs. A value of %NULL
3842 // indicates autodetection.
3844 // is owned by GLib and must not be freed.
3845 // RETURNS: The line termination string. This value
3846 // <length>: a location to return the length of the line terminator
3847 char* get_line_term()(int* length) {
3848 return g_io_channel_get_line_term(&this, length);
3851 // Initializes a #GIOChannel struct.
3853 // This is called by each of the above functions when creating a
3854 // #GIOChannel, and so is not often needed by the application
3855 // programmer (unless you are creating a new type of #GIOChannel).
3856 void init()() {
3857 g_io_channel_init(&this);
3860 // Reads data from a #GIOChannel.
3863 // Deprecated:2.2: Use g_io_channel_read_chars() instead.
3864 // RETURNS: %G_IO_ERROR_NONE if the operation was successful.
3865 // <buf>: a buffer to read the data into (which should be at least count bytes long)
3866 // <count>: the number of bytes to read from the #GIOChannel
3867 // <bytes_read>: returns the number of bytes actually read
3868 IOError read()(char* buf, size_t count, size_t* bytes_read) {
3869 return g_io_channel_read(&this, buf, count, bytes_read);
3872 // Replacement for g_io_channel_read() with the new API.
3873 // RETURNS: the status of the operation.
3874 // <buf>: a buffer to read data into
3875 // <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.
3876 // <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.
3877 IOStatus read_chars()(char* buf, size_t count, size_t* bytes_read, GLib2.Error** error=null) {
3878 return g_io_channel_read_chars(&this, buf, count, bytes_read, error);
3881 // Reads a line, including the terminating character(s),
3882 // from a #GIOChannel into a newly-allocated string.
3883 // @str_return will contain allocated memory if the return
3884 // is %G_IO_STATUS_NORMAL.
3885 // RETURNS: the status of the operation.
3886 // <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.
3887 // <length>: location to store length of the read data, or %NULL
3888 // <terminator_pos>: location to store position of line terminator, or %NULL
3889 IOStatus read_line()(char** str_return, size_t* length, size_t* terminator_pos, GLib2.Error** error=null) {
3890 return g_io_channel_read_line(&this, str_return, length, terminator_pos, error);
3893 // Reads a line from a #GIOChannel, using a #GString as a buffer.
3894 // RETURNS: the status of the operation.
3895 // <buffer>: a #GString into which the line will be written. If @buffer already contains data, the old data will be overwritten.
3896 // <terminator_pos>: location to store position of line terminator, or %NULL
3897 IOStatus read_line_string()(String* buffer, size_t* terminator_pos, GLib2.Error** error=null) {
3898 return g_io_channel_read_line_string(&this, buffer, terminator_pos, error);
3901 // Reads all the remaining data from the file.
3903 // This function never returns %G_IO_STATUS_EOF.
3904 // RETURNS: %G_IO_STATUS_NORMAL on success.
3905 // <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.
3906 // <length>: location to store length of the data
3907 IOStatus read_to_end()(char** str_return, size_t* length, GLib2.Error** error=null) {
3908 return g_io_channel_read_to_end(&this, str_return, length, error);
3911 // Reads a Unicode character from @channel.
3912 // This function cannot be called on a channel with %NULL encoding.
3913 // RETURNS: a #GIOStatus
3914 // <thechar>: a location to return a character
3915 IOStatus read_unichar()(dchar* thechar, GLib2.Error** error=null) {
3916 return g_io_channel_read_unichar(&this, thechar, error);
3919 // Increments the reference count of a #GIOChannel.
3920 // RETURNS: the @channel that was passed in (since 2.6)
3921 IOChannel* /*new*/ ref_()() {
3922 return g_io_channel_ref(&this);
3925 // Sets the current position in the #GIOChannel, similar to the standard
3926 // library function fseek().
3929 // Deprecated:2.2: Use g_io_channel_seek_position() instead.
3930 // RETURNS: %G_IO_ERROR_NONE if the operation was successful.
3931 // <offset>: an offset, in bytes, which is added to the position specified by @type
3932 // <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)
3933 IOError seek()(long offset, SeekType type) {
3934 return g_io_channel_seek(&this, offset, type);
3937 // Replacement for g_io_channel_seek() with the new API.
3938 // RETURNS: the status of the operation.
3939 // <offset>: The offset in bytes from the position specified by @type
3940 // <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.
3941 IOStatus seek_position()(long offset, SeekType type, GLib2.Error** error=null) {
3942 return g_io_channel_seek_position(&this, offset, type, error);
3945 // Sets the buffer size.
3946 // <size>: the size of the buffer, or 0 to let GLib pick a good size
3947 void set_buffer_size()(size_t size) {
3948 g_io_channel_set_buffer_size(&this, size);
3951 // The buffering state can only be set if the channel's encoding
3952 // is %NULL. For any other encoding, the channel must be buffered.
3954 // A buffered channel can only be set unbuffered if the channel's
3955 // internal buffers have been flushed. Newly created channels or
3956 // channels which have returned %G_IO_STATUS_EOF
3957 // not require such a flush. For write-only channels, a call to
3958 // g_io_channel_flush () is sufficient. For all other channels,
3959 // the buffers may be flushed by a call to g_io_channel_seek_position ().
3960 // This includes the possibility of seeking with seek type %G_SEEK_CUR
3961 // and an offset of zero. Note that this means that socket-based
3962 // channels cannot be set unbuffered once they have had data
3963 // read from them.
3965 // On unbuffered channels, it is safe to mix read and write
3966 // calls from the new and old APIs, if this is necessary for
3967 // maintaining old code.
3969 // The default state of the channel is buffered.
3970 // <buffered>: whether to set the channel buffered or unbuffered
3971 void set_buffered()(int buffered) {
3972 g_io_channel_set_buffered(&this, buffered);
3975 // Setting this flag to %TRUE for a channel you have already closed
3976 // can cause problems.
3977 // <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.
3978 void set_close_on_unref()(int do_close) {
3979 g_io_channel_set_close_on_unref(&this, do_close);
3982 // Sets the encoding for the input/output of the channel.
3983 // The internal encoding is always UTF-8. The default encoding
3984 // for the external file is UTF-8.
3986 // The encoding %NULL is safe to use with binary data.
3988 // The encoding can only be set if one of the following conditions
3989 // is true:
3990 // <itemizedlist>
3991 // <listitem><para>
3992 // The channel was just created, and has not been written to or read
3993 // from yet.
3994 // </para></listitem>
3995 // <listitem><para>
3996 // The channel is write-only.
3997 // </para></listitem>
3998 // <listitem><para>
3999 // The channel is a file, and the file pointer was just
4000 // repositioned by a call to g_io_channel_seek_position().
4001 // (This flushes all the internal buffers.)
4002 // </para></listitem>
4003 // <listitem><para>
4004 // The current encoding is %NULL or UTF-8.
4005 // </para></listitem>
4006 // <listitem><para>
4007 // One of the (new API) read functions has just returned %G_IO_STATUS_EOF
4008 // (or, in the case of g_io_channel_read_to_end(), %G_IO_STATUS_NORMAL).
4009 // </para></listitem>
4010 // <listitem><para>
4011 // One of the functions g_io_channel_read_chars() or
4012 // g_io_channel_read_unichar() has returned %G_IO_STATUS_AGAIN or
4013 // %G_IO_STATUS_ERROR. This may be useful in the case of
4014 // %G_CONVERT_ERROR_ILLEGAL_SEQUENCE.
4015 // Returning one of these statuses from g_io_channel_read_line(),
4016 // g_io_channel_read_line_string(), or g_io_channel_read_to_end()
4017 // does <emphasis>not</emphasis> guarantee that the encoding can
4018 // be changed.
4019 // </para></listitem>
4020 // </itemizedlist>
4021 // Channels which do not meet one of the above conditions cannot call
4022 // g_io_channel_seek_position() with an offset of %G_SEEK_CUR, and, if
4023 // they are "seekable", cannot call g_io_channel_write_chars() after
4024 // calling one of the API "read" functions.
4025 // RETURNS: %G_IO_STATUS_NORMAL if the encoding was successfully set.
4026 // <encoding>: the encoding type
4027 IOStatus set_encoding()(char* encoding, GLib2.Error** error=null) {
4028 return g_io_channel_set_encoding(&this, encoding, error);
4031 // Sets the (writeable) flags in @channel to (@flags & %G_IO_CHANNEL_SET_MASK).
4032 // RETURNS: the status of the operation.
4033 // <flags>: the flags to set on the IO channel
4034 IOStatus set_flags()(IOFlags flags, GLib2.Error** error=null) {
4035 return g_io_channel_set_flags(&this, flags, error);
4038 // This sets the string that #GIOChannel uses to determine
4039 // where in the file a line break occurs.
4040 // <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.
4041 // <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.
4042 void set_line_term()(char* line_term, int length) {
4043 g_io_channel_set_line_term(&this, line_term, length);
4046 // Close an IO channel. Any pending data to be written will be
4047 // flushed if @flush is %TRUE. The channel will not be freed until the
4048 // last reference is dropped using g_io_channel_unref().
4049 // RETURNS: the status of the operation.
4050 // <flush>: if %TRUE, flush pending
4051 IOStatus shutdown()(int flush, GLib2.Error** error=null) {
4052 return g_io_channel_shutdown(&this, flush, error);
4055 // Returns the file descriptor of the #GIOChannel.
4057 // On Windows this function returns the file descriptor or socket of
4058 // the #GIOChannel.
4059 int unix_get_fd()() {
4060 return g_io_channel_unix_get_fd(&this);
4062 // Decrements the reference count of a #GIOChannel.
4063 void unref()() {
4064 g_io_channel_unref(&this);
4067 // Writes data to a #GIOChannel.
4070 // Deprecated:2.2: Use g_io_channel_write_chars() instead.
4071 // RETURNS: %G_IO_ERROR_NONE if the operation was successful.
4072 // <buf>: the buffer containing the data to write
4073 // <count>: the number of bytes to write
4074 // <bytes_written>: the number of bytes actually written
4075 IOError write()(char* buf, size_t count, size_t* bytes_written) {
4076 return g_io_channel_write(&this, buf, count, bytes_written);
4079 // Replacement for g_io_channel_write() with the new API.
4081 // On seekable channels with encodings other than %NULL or UTF-8, generic
4082 // mixing of reading and writing is not allowed. A call to g_io_channel_write_chars ()
4083 // may only be made on a channel from which data has been read in the
4084 // cases described in the documentation for g_io_channel_set_encoding ().
4085 // RETURNS: the status of the operation.
4086 // <buf>: a buffer to write data from
4087 // <count>: the size of the buffer. If -1, the buffer is taken to be a nul-terminated string.
4088 // <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.
4089 IOStatus write_chars()(char* buf, ssize_t count, size_t* bytes_written, GLib2.Error** error=null) {
4090 return g_io_channel_write_chars(&this, buf, count, bytes_written, error);
4093 // Writes a Unicode character to @channel.
4094 // This function cannot be called on a channel with %NULL encoding.
4095 // RETURNS: a #GIOStatus
4096 // <thechar>: a character
4097 IOStatus write_unichar()(dchar thechar, GLib2.Error** error=null) {
4098 return g_io_channel_write_unichar(&this, thechar, error);
4101 // Converts an <literal>errno</literal> error number to a #GIOChannelError.
4103 // %G_IO_CHANNEL_ERROR_INVAL.
4104 // RETURNS: a #GIOChannelError error number, e.g.
4105 // <en>: an <literal>errno</literal> error number, e.g. %EINVAL
4106 static IOChannelError error_from_errno()(int en) {
4107 return g_io_channel_error_from_errno(en);
4109 // RETURNS: the quark used as %G_IO_CHANNEL_ERROR
4110 static Quark error_quark()() {
4111 return g_io_channel_error_quark();
4115 // Error codes returned by #GIOChannel operations.
4116 enum IOChannelError {
4117 FBIG = 0,
4118 INVAL = 1,
4119 IO = 2,
4120 ISDIR = 3,
4121 NOSPC = 4,
4122 NXIO = 5,
4123 OVERFLOW = 6,
4124 PIPE = 7,
4125 FAILED = 8
4128 // A bitwise combination representing a condition to watch for on an
4129 // event source.
4130 enum IOCondition {
4131 IN = 1,
4132 OUT = 4,
4133 PRI = 2,
4134 ERR = 8,
4135 HUP = 16,
4136 NVAL = 32
4139 // #GIOError is only used by the deprecated functions
4140 // g_io_channel_read(), g_io_channel_write(), and g_io_channel_seek().
4141 enum IOError {
4142 NONE = 0,
4143 AGAIN = 1,
4144 INVAL = 2,
4145 UNKNOWN = 3
4148 // Specifies properties of a #GIOChannel. Some of the flags can only be
4149 // read with g_io_channel_get_flags(), but not changed with
4150 // g_io_channel_set_flags().
4151 enum IOFlags {
4152 APPEND = 1,
4153 NONBLOCK = 2,
4154 IS_READABLE = 4,
4155 IS_WRITEABLE = 8,
4156 IS_SEEKABLE = 16,
4157 MASK = 31,
4158 GET_MASK = 31,
4159 SET_MASK = 3
4162 // Specifies the type of function passed to g_io_add_watch() or
4163 // g_io_add_watch_full(), which is called when the requested condition
4164 // on a #GIOChannel is satisfied.
4165 // <source>: the #GIOChannel event source
4166 // <condition>: the condition which has been satisfied
4167 // <data>: user data set in g_io_add_watch() or g_io_add_watch_full()
4168 extern (C) alias int function (IOChannel* source, IOCondition condition, void* data) IOFunc;
4171 // A table of functions used to handle different types of #GIOChannel
4172 // in a generic way.
4173 struct IOFuncs {
4174 extern (C) IOStatus function (IOChannel* channel, char* buf, size_t count, size_t* bytes_read, GLib2.Error** error=null) io_read;
4175 extern (C) IOStatus function (IOChannel* channel, char* buf, size_t count, size_t* bytes_written, GLib2.Error** error=null) io_write;
4176 extern (C) IOStatus function (IOChannel* channel, long offset, SeekType type, GLib2.Error** error=null) io_seek;
4177 extern (C) IOStatus function (IOChannel* channel, GLib2.Error** error=null) io_close;
4178 extern (C) Source* /*new*/ function (IOChannel* channel, IOCondition condition) io_create_watch;
4179 extern (C) void function (IOChannel* channel) io_free;
4180 extern (C) IOStatus function (IOChannel* channel, IOFlags flags, GLib2.Error** error=null) io_set_flags;
4181 extern (C) IOFlags function (IOChannel* channel) io_get_flags;
4184 // Stati returned by most of the #GIOFuncs functions.
4185 enum IOStatus {
4186 ERROR = 0,
4187 NORMAL = 1,
4188 EOF = 2,
4189 AGAIN = 3
4191 enum KEY_FILE_DESKTOP_GROUP = "Desktop Entry";
4192 enum KEY_FILE_DESKTOP_KEY_CATEGORIES = "Categories";
4193 enum KEY_FILE_DESKTOP_KEY_COMMENT = "Comment";
4194 enum KEY_FILE_DESKTOP_KEY_EXEC = "Exec";
4195 enum KEY_FILE_DESKTOP_KEY_GENERIC_NAME = "GenericName";
4196 enum KEY_FILE_DESKTOP_KEY_HIDDEN = "Hidden";
4197 enum KEY_FILE_DESKTOP_KEY_ICON = "Icon";
4198 enum KEY_FILE_DESKTOP_KEY_MIME_TYPE = "MimeType";
4199 enum KEY_FILE_DESKTOP_KEY_NAME = "Name";
4200 enum KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN = "NotShowIn";
4201 enum KEY_FILE_DESKTOP_KEY_NO_DISPLAY = "NoDisplay";
4202 enum KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN = "OnlyShowIn";
4203 enum KEY_FILE_DESKTOP_KEY_PATH = "Path";
4204 enum KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY = "StartupNotify";
4205 enum KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS = "StartupWMClass";
4206 enum KEY_FILE_DESKTOP_KEY_TERMINAL = "Terminal";
4207 enum KEY_FILE_DESKTOP_KEY_TRY_EXEC = "TryExec";
4208 enum KEY_FILE_DESKTOP_KEY_TYPE = "Type";
4209 enum KEY_FILE_DESKTOP_KEY_URL = "URL";
4210 enum KEY_FILE_DESKTOP_KEY_VERSION = "Version";
4211 enum KEY_FILE_DESKTOP_TYPE_APPLICATION = "Application";
4212 enum KEY_FILE_DESKTOP_TYPE_DIRECTORY = "Directory";
4213 enum KEY_FILE_DESKTOP_TYPE_LINK = "Link";
4214 struct KeyFile {
4216 // VERSION: 2.6
4217 // Frees a #GKeyFile.
4218 void free()() {
4219 g_key_file_free(&this);
4222 // VERSION: 2.6
4223 // Returns the value associated with @key under @group_name as a
4224 // boolean.
4226 // If @key cannot be found then %FALSE is returned and @error is set
4227 // to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value
4228 // associated with @key cannot be interpreted as a boolean then %FALSE
4229 // is returned and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
4231 // or %FALSE if the key was not found or could not be parsed.
4232 // RETURNS: the value associated with the key as a boolean,
4233 // <group_name>: a group name
4234 // <key>: a key
4235 int get_boolean()(char* group_name, char* key, GLib2.Error** error=null) {
4236 return g_key_file_get_boolean(&this, group_name, key, error);
4239 // VERSION: 2.6
4240 // Returns the values associated with @key under @group_name as
4241 // booleans.
4243 // If @key cannot be found then %NULL is returned and @error is set to
4244 // #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
4245 // with @key cannot be interpreted as booleans then %NULL is returned
4246 // and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
4248 // the values associated with the key as a list of booleans, or %NULL if the
4249 // key was not found or could not be parsed. The returned list of booleans
4250 // should be freed with g_free() when no longer needed.
4251 // <group_name>: a group name
4252 // <key>: a key
4253 // <length>: the number of booleans returned
4254 int* /*new container*/ get_boolean_list()(char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error=null) {
4255 return g_key_file_get_boolean_list(&this, group_name, key, length, error);
4258 // VERSION: 2.6
4259 // Retrieves a comment above @key from @group_name.
4260 // If @key is %NULL then @comment will be read from above
4261 // @group_name. If both @key and @group_name are %NULL, then
4262 // @comment will be read from above the first group in the file.
4263 // RETURNS: a comment that should be freed with g_free()
4264 // <group_name>: a group name, or %NULL
4265 // <key>: a key
4266 char* /*new*/ get_comment()(char* group_name, char* key, GLib2.Error** error=null) {
4267 return g_key_file_get_comment(&this, group_name, key, error);
4270 // VERSION: 2.12
4271 // Returns the value associated with @key under @group_name as a
4272 // double. If @group_name is %NULL, the start_group is used.
4274 // If @key cannot be found then 0.0 is returned and @error is set to
4275 // #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated
4276 // with @key cannot be interpreted as a double then 0.0 is returned
4277 // and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
4279 // 0.0 if the key was not found or could not be parsed.
4280 // RETURNS: the value associated with the key as a double, or
4281 // <group_name>: a group name
4282 // <key>: a key
4283 double get_double()(char* group_name, char* key, GLib2.Error** error=null) {
4284 return g_key_file_get_double(&this, group_name, key, error);
4287 // VERSION: 2.12
4288 // Returns the values associated with @key under @group_name as
4289 // doubles.
4291 // If @key cannot be found then %NULL is returned and @error is set to
4292 // #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
4293 // with @key cannot be interpreted as doubles then %NULL is returned
4294 // and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
4296 // the values associated with the key as a list of doubles, or %NULL if the
4297 // key was not found or could not be parsed. The returned list of doubles
4298 // should be freed with g_free() when no longer needed.
4299 // <group_name>: a group name
4300 // <key>: a key
4301 // <length>: the number of doubles returned
4302 double* /*new container*/ get_double_list()(char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error=null) {
4303 return g_key_file_get_double_list(&this, group_name, key, length, error);
4306 // Unintrospectable method: get_groups() / g_key_file_get_groups()
4307 // VERSION: 2.6
4308 // Returns all groups in the key file loaded with @key_file.
4309 // The array of returned groups will be %NULL-terminated, so
4310 // @length may optionally be %NULL.
4312 // Use g_strfreev() to free it.
4313 // RETURNS: a newly-allocated %NULL-terminated array of strings.
4314 // <length>: return location for the number of returned groups, or %NULL
4315 char** get_groups()(size_t* length) {
4316 return g_key_file_get_groups(&this, length);
4319 // VERSION: 2.26
4320 // Returns the value associated with @key under @group_name as a signed
4321 // 64-bit integer. This is similar to g_key_file_get_integer() but can return
4322 // 64-bit results without truncation.
4324 // 0 if the key was not found or could not be parsed.
4325 // RETURNS: the value associated with the key as a signed 64-bit integer, or
4326 // <group_name>: a non-%NULL group name
4327 // <key>: a non-%NULL key
4328 long get_int64()(char* group_name, char* key, GLib2.Error** error=null) {
4329 return g_key_file_get_int64(&this, group_name, key, error);
4332 // VERSION: 2.6
4333 // Returns the value associated with @key under @group_name as an
4334 // integer.
4336 // If @key cannot be found then 0 is returned and @error is set to
4337 // #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated
4338 // with @key cannot be interpreted as an integer then 0 is returned
4339 // and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
4341 // 0 if the key was not found or could not be parsed.
4342 // RETURNS: the value associated with the key as an integer, or
4343 // <group_name>: a group name
4344 // <key>: a key
4345 int get_integer()(char* group_name, char* key, GLib2.Error** error=null) {
4346 return g_key_file_get_integer(&this, group_name, key, error);
4349 // VERSION: 2.6
4350 // Returns the values associated with @key under @group_name as
4351 // integers.
4353 // If @key cannot be found then %NULL is returned and @error is set to
4354 // #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
4355 // with @key cannot be interpreted as integers then %NULL is returned
4356 // and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
4358 // the values associated with the key as a list of integers, or %NULL if
4359 // the key was not found or could not be parsed. The returned list of
4360 // integers should be freed with g_free() when no longer needed.
4361 // <group_name>: a group name
4362 // <key>: a key
4363 // <length>: the number of integers returned
4364 int* /*new container*/ get_integer_list()(char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error=null) {
4365 return g_key_file_get_integer_list(&this, group_name, key, length, error);
4368 // Unintrospectable method: get_keys() / g_key_file_get_keys()
4369 // VERSION: 2.6
4370 // Returns all keys for the group name @group_name. The array of
4371 // returned keys will be %NULL-terminated, so @length may
4372 // optionally be %NULL. In the event that the @group_name cannot
4373 // be found, %NULL is returned and @error is set to
4374 // #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
4376 // Use g_strfreev() to free it.
4377 // RETURNS: a newly-allocated %NULL-terminated array of strings.
4378 // <group_name>: a group name
4379 // <length>: return location for the number of keys returned, or %NULL
4380 char** get_keys()(char* group_name, size_t* length, GLib2.Error** error=null) {
4381 return g_key_file_get_keys(&this, group_name, length, error);
4384 // VERSION: 2.6
4385 // Returns the value associated with @key under @group_name
4386 // translated in the given @locale if available. If @locale is
4387 // %NULL then the current locale is assumed.
4389 // If @key cannot be found then %NULL is returned and @error is set
4390 // to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the value associated
4391 // with @key cannot be interpreted or no suitable translation can
4392 // be found then the untranslated value is returned.
4394 // key cannot be found.
4395 // RETURNS: a newly allocated string or %NULL if the specified
4396 // <group_name>: a group name
4397 // <key>: a key
4398 // <locale>: a locale identifier or %NULL
4399 char* /*new*/ get_locale_string()(char* group_name, char* key, char* locale, GLib2.Error** error=null) {
4400 return g_key_file_get_locale_string(&this, group_name, key, locale, error);
4403 // VERSION: 2.6
4404 // Returns the values associated with @key under @group_name
4405 // translated in the given @locale if available. If @locale is
4406 // %NULL then the current locale is assumed.
4407 // If @key cannot be found then %NULL is returned and @error is set
4408 // to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the values associated
4409 // with @key cannot be interpreted or no suitable translations
4410 // can be found then the untranslated values are returned. The
4411 // returned array is %NULL-terminated, so @length may optionally
4412 // be %NULL.
4414 // or %NULL if the key isn't found. The string array should be freed
4415 // with g_strfreev().
4416 // RETURNS: a newly allocated %NULL-terminated string array
4417 // <group_name>: a group name
4418 // <key>: a key
4419 // <locale>: a locale identifier or %NULL
4420 // <length>: return location for the number of returned strings or %NULL
4421 char** /*new*/ get_locale_string_list()(char* group_name, char* key, char* locale, /*out*/ size_t* length, GLib2.Error** error=null) {
4422 return g_key_file_get_locale_string_list(&this, group_name, key, locale, length, error);
4425 // VERSION: 2.6
4426 // Returns the name of the start group of the file.
4427 // RETURNS: The start group of the key file.
4428 char* /*new*/ get_start_group()() {
4429 return g_key_file_get_start_group(&this);
4432 // VERSION: 2.6
4433 // Returns the string value associated with @key under @group_name.
4434 // Unlike g_key_file_get_value(), this function handles escape sequences
4435 // like \s.
4437 // In the event the key cannot be found, %NULL is returned and
4438 // @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the
4439 // event that the @group_name cannot be found, %NULL is returned
4440 // and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
4442 // key cannot be found.
4443 // RETURNS: a newly allocated string or %NULL if the specified
4444 // <group_name>: a group name
4445 // <key>: a key
4446 char* /*new*/ get_string()(char* group_name, char* key, GLib2.Error** error=null) {
4447 return g_key_file_get_string(&this, group_name, key, error);
4450 // VERSION: 2.6
4451 // Returns the values associated with @key under @group_name.
4453 // In the event the key cannot be found, %NULL is returned and
4454 // @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the
4455 // event that the @group_name cannot be found, %NULL is returned
4456 // and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
4458 // a %NULL-terminated string array or %NULL if the specified
4459 // key cannot be found. The array should be freed with g_strfreev().
4460 // <group_name>: a group name
4461 // <key>: a key
4462 // <length>: return location for the number of returned strings, or %NULL
4463 char** /*new*/ get_string_list()(char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error=null) {
4464 return g_key_file_get_string_list(&this, group_name, key, length, error);
4467 // VERSION: 2.26
4468 // Returns the value associated with @key under @group_name as an unsigned
4469 // 64-bit integer. This is similar to g_key_file_get_integer() but can return
4470 // large positive results without truncation.
4472 // or 0 if the key was not found or could not be parsed.
4473 // RETURNS: the value associated with the key as an unsigned 64-bit integer,
4474 // <group_name>: a non-%NULL group name
4475 // <key>: a non-%NULL key
4476 ulong get_uint64()(char* group_name, char* key, GLib2.Error** error=null) {
4477 return g_key_file_get_uint64(&this, group_name, key, error);
4480 // VERSION: 2.6
4481 // Returns the raw value associated with @key under @group_name.
4482 // Use g_key_file_get_string() to retrieve an unescaped UTF-8 string.
4484 // In the event the key cannot be found, %NULL is returned and
4485 // @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the
4486 // event that the @group_name cannot be found, %NULL is returned
4487 // and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
4490 // key cannot be found.
4491 // RETURNS: a newly allocated string or %NULL if the specified
4492 // <group_name>: a group name
4493 // <key>: a key
4494 char* /*new*/ get_value()(char* group_name, char* key, GLib2.Error** error=null) {
4495 return g_key_file_get_value(&this, group_name, key, error);
4498 // VERSION: 2.6
4499 // Looks whether the key file has the group @group_name.
4501 // otherwise.
4502 // RETURNS: %TRUE if @group_name is a part of @key_file, %FALSE
4503 // <group_name>: a group name
4504 int has_group()(char* group_name) {
4505 return g_key_file_has_group(&this, group_name);
4508 // Unintrospectable method: has_key() / g_key_file_has_key()
4509 // VERSION: 2.6
4510 // Looks whether the key file has the key @key in the group
4511 // @group_name.
4513 // <note>This function does not follow the rules for #GError strictly;
4514 // the return value both carries meaning and signals an error. To use
4515 // this function, you must pass a #GError pointer in @error, and check
4516 // whether it is not %NULL to see if an error occurred.</note>
4518 // Language bindings should use g_key_file_get_value() to test whether
4519 // or not a key exists.
4521 // otherwise.
4522 // RETURNS: %TRUE if @key is a part of @group_name, %FALSE
4523 // <group_name>: a group name
4524 // <key>: a key name
4525 int has_key()(char* group_name, char* key, GLib2.Error** error=null) {
4526 return g_key_file_has_key(&this, group_name, key, error);
4529 // VERSION: 2.6
4530 // Loads a key file from memory into an empty #GKeyFile structure.
4531 // If the object cannot be created then %error is set to a #GKeyFileError.
4532 // RETURNS: %TRUE if a key file could be loaded, %FALSE otherwise
4533 // <data>: key file loaded in memory
4534 // <length>: the length of @data in bytes
4535 // <flags>: flags from #GKeyFileFlags
4536 int load_from_data()(char* data, size_t length, KeyFileFlags flags, GLib2.Error** error=null) {
4537 return g_key_file_load_from_data(&this, data, length, flags, error);
4540 // VERSION: 2.6
4541 // This function looks for a key file named @file in the paths
4542 // returned from g_get_user_data_dir() and g_get_system_data_dirs(),
4543 // loads the file into @key_file and returns the file's full path in
4544 // @full_path. If the file could not be loaded then an %error is
4545 // set to either a #GFileError or #GKeyFileError.
4546 // RETURNS: %TRUE if a key file could be loaded, %FALSE othewise
4547 // <file>: a relative path to a filename to open and parse
4548 // <full_path>: return location for a string containing the full path of the file, or %NULL
4549 // <flags>: flags from #GKeyFileFlags
4550 int load_from_data_dirs()(char* file, char** full_path, KeyFileFlags flags, GLib2.Error** error=null) {
4551 return g_key_file_load_from_data_dirs(&this, file, full_path, flags, error);
4554 // VERSION: 2.14
4555 // This function looks for a key file named @file in the paths
4556 // specified in @search_dirs, loads the file into @key_file and
4557 // returns the file's full path in @full_path. If the file could not
4558 // be loaded then an %error is set to either a #GFileError or
4559 // #GKeyFileError.
4560 // RETURNS: %TRUE if a key file could be loaded, %FALSE otherwise
4561 // <file>: a relative path to a filename to open and parse
4562 // <search_dirs>: %NULL-terminated array of directories to search
4563 // <full_path>: return location for a string containing the full path of the file, or %NULL
4564 // <flags>: flags from #GKeyFileFlags
4565 int load_from_dirs()(char* file, char** search_dirs, char** full_path, KeyFileFlags flags, GLib2.Error** error=null) {
4566 return g_key_file_load_from_dirs(&this, file, search_dirs, full_path, flags, error);
4569 // VERSION: 2.6
4570 // Loads a key file into an empty #GKeyFile structure.
4571 // If the file could not be loaded then %error is set to
4572 // either a #GFileError or #GKeyFileError.
4573 // RETURNS: %TRUE if a key file could be loaded, %FALSE otherwise
4574 // <file>: the path of a filename to load, in the GLib filename encoding
4575 // <flags>: flags from #GKeyFileFlags
4576 int load_from_file()(char* file, KeyFileFlags flags, GLib2.Error** error=null) {
4577 return g_key_file_load_from_file(&this, file, flags, error);
4580 // VERSION: 2.6
4581 // Removes a comment above @key from @group_name.
4582 // If @key is %NULL then @comment will be removed above @group_name.
4583 // If both @key and @group_name are %NULL, then @comment will
4584 // be removed above the first group in the file.
4585 // RETURNS: %TRUE if the comment was removed, %FALSE otherwise
4586 // <group_name>: a group name, or %NULL
4587 // <key>: a key
4588 int remove_comment()(char* group_name, char* key, GLib2.Error** error=null) {
4589 return g_key_file_remove_comment(&this, group_name, key, error);
4592 // VERSION: 2.6
4593 // Removes the specified group, @group_name,
4594 // from the key file.
4595 // RETURNS: %TRUE if the group was removed, %FALSE otherwise
4596 // <group_name>: a group name
4597 int remove_group()(char* group_name, GLib2.Error** error=null) {
4598 return g_key_file_remove_group(&this, group_name, error);
4601 // VERSION: 2.6
4602 // Removes @key in @group_name from the key file.
4603 // RETURNS: %TRUE if the key was removed, %FALSE otherwise
4604 // <group_name>: a group name
4605 // <key>: a key name to remove
4606 int remove_key()(char* group_name, char* key, GLib2.Error** error=null) {
4607 return g_key_file_remove_key(&this, group_name, key, error);
4610 // VERSION: 2.6
4611 // Associates a new boolean value with @key under @group_name.
4612 // If @key cannot be found then it is created.
4613 // <group_name>: a group name
4614 // <key>: a key
4615 // <value>: %TRUE or %FALSE
4616 void set_boolean()(char* group_name, char* key, int value) {
4617 g_key_file_set_boolean(&this, group_name, key, value);
4620 // VERSION: 2.6
4621 // Associates a list of boolean values with @key under @group_name.
4622 // If @key cannot be found then it is created.
4623 // If @group_name is %NULL, the start_group is used.
4624 // <group_name>: a group name
4625 // <key>: a key
4626 // <list>: an array of boolean values
4627 // <length>: length of @list
4628 void set_boolean_list()(char* group_name, char* key, int list, size_t length) {
4629 g_key_file_set_boolean_list(&this, group_name, key, list, length);
4632 // VERSION: 2.6
4633 // Places a comment above @key from @group_name.
4634 // If @key is %NULL then @comment will be written above @group_name.
4635 // If both @key and @group_name are %NULL, then @comment will be
4636 // written above the first group in the file.
4637 // RETURNS: %TRUE if the comment was written, %FALSE otherwise
4638 // <group_name>: a group name, or %NULL
4639 // <key>: a key
4640 // <comment>: a comment
4641 int set_comment()(char* group_name, char* key, char* comment, GLib2.Error** error=null) {
4642 return g_key_file_set_comment(&this, group_name, key, comment, error);
4645 // VERSION: 2.12
4646 // Associates a new double value with @key under @group_name.
4647 // If @key cannot be found then it is created.
4648 // <group_name>: a group name
4649 // <key>: a key
4650 // <value>: an double value
4651 void set_double()(char* group_name, char* key, double value) {
4652 g_key_file_set_double(&this, group_name, key, value);
4655 // VERSION: 2.12
4656 // Associates a list of double values with @key under
4657 // @group_name. If @key cannot be found then it is created.
4658 // <group_name>: a group name
4659 // <key>: a key
4660 // <list>: an array of double values
4661 // <length>: number of double values in @list
4662 void set_double_list()(char* group_name, char* key, double list, size_t length) {
4663 g_key_file_set_double_list(&this, group_name, key, list, length);
4666 // VERSION: 2.26
4667 // Associates a new integer value with @key under @group_name.
4668 // If @key cannot be found then it is created.
4669 // <group_name>: a group name
4670 // <key>: a key
4671 // <value>: an integer value
4672 void set_int64()(char* group_name, char* key, long value) {
4673 g_key_file_set_int64(&this, group_name, key, value);
4676 // VERSION: 2.6
4677 // Associates a new integer value with @key under @group_name.
4678 // If @key cannot be found then it is created.
4679 // <group_name>: a group name
4680 // <key>: a key
4681 // <value>: an integer value
4682 void set_integer()(char* group_name, char* key, int value) {
4683 g_key_file_set_integer(&this, group_name, key, value);
4686 // VERSION: 2.6
4687 // Associates a list of integer values with @key under @group_name.
4688 // If @key cannot be found then it is created.
4689 // <group_name>: a group name
4690 // <key>: a key
4691 // <list>: an array of integer values
4692 // <length>: number of integer values in @list
4693 void set_integer_list()(char* group_name, char* key, int list, size_t length) {
4694 g_key_file_set_integer_list(&this, group_name, key, list, length);
4697 // VERSION: 2.6
4698 // Sets the character which is used to separate
4699 // values in lists. Typically ';' or ',' are used
4700 // as separators. The default list separator is ';'.
4701 // <separator>: the separator
4702 void set_list_separator()(char separator) {
4703 g_key_file_set_list_separator(&this, separator);
4706 // VERSION: 2.6
4707 // Associates a string value for @key and @locale under @group_name.
4708 // If the translation for @key cannot be found then it is created.
4709 // <group_name>: a group name
4710 // <key>: a key
4711 // <locale>: a locale identifier
4712 // <string>: a string
4713 void set_locale_string()(char* group_name, char* key, char* locale, char* string_) {
4714 g_key_file_set_locale_string(&this, group_name, key, locale, string_);
4717 // VERSION: 2.6
4718 // Associates a list of string values for @key and @locale under
4719 // @group_name. If the translation for @key cannot be found then
4720 // it is created.
4721 // <group_name>: a group name
4722 // <key>: a key
4723 // <locale>: a locale identifier
4724 // <list>: a %NULL-terminated array of locale string values
4725 // <length>: the length of @list
4726 void set_locale_string_list()(char* group_name, char* key, char* locale, char* list, size_t length) {
4727 g_key_file_set_locale_string_list(&this, group_name, key, locale, list, length);
4730 // VERSION: 2.6
4731 // Associates a new string value with @key under @group_name.
4732 // If @key cannot be found then it is created.
4733 // If @group_name cannot be found then it is created.
4734 // Unlike g_key_file_set_value(), this function handles characters
4735 // that need escaping, such as newlines.
4736 // <group_name>: a group name
4737 // <key>: a key
4738 // <string>: a string
4739 void set_string()(char* group_name, char* key, char* string_) {
4740 g_key_file_set_string(&this, group_name, key, string_);
4743 // VERSION: 2.6
4744 // Associates a list of string values for @key under @group_name.
4745 // If @key cannot be found then it is created.
4746 // If @group_name cannot be found then it is created.
4747 // <group_name>: a group name
4748 // <key>: a key
4749 // <list>: an array of string values
4750 // <length>: number of string values in @list
4751 void set_string_list()(char* group_name, char* key, char* list, size_t length) {
4752 g_key_file_set_string_list(&this, group_name, key, list, length);
4755 // VERSION: 2.26
4756 // Associates a new integer value with @key under @group_name.
4757 // If @key cannot be found then it is created.
4758 // <group_name>: a group name
4759 // <key>: a key
4760 // <value>: an integer value
4761 void set_uint64()(char* group_name, char* key, ulong value) {
4762 g_key_file_set_uint64(&this, group_name, key, value);
4765 // VERSION: 2.6
4766 // Associates a new value with @key under @group_name.
4768 // If @key cannot be found then it is created. If @group_name cannot
4769 // be found then it is created. To set an UTF-8 string which may contain
4770 // characters that need escaping (such as newlines or spaces), use
4771 // g_key_file_set_string().
4772 // <group_name>: a group name
4773 // <key>: a key
4774 // <value>: a string
4775 void set_value()(char* group_name, char* key, char* value) {
4776 g_key_file_set_value(&this, group_name, key, value);
4779 // VERSION: 2.6
4780 // This function outputs @key_file as a string.
4782 // Note that this function never reports an error,
4783 // so it is safe to pass %NULL as @error.
4785 // the contents of the #GKeyFile
4786 // RETURNS: a newly allocated string holding
4787 // <length>: return location for the length of the returned string, or %NULL
4788 char* /*new*/ to_data()(size_t* length, GLib2.Error** error=null) {
4789 return g_key_file_to_data(&this, length, error);
4791 static Quark error_quark()() {
4792 return g_key_file_error_quark();
4795 // Unintrospectable function: new() / g_key_file_new()
4796 // VERSION: 2.6
4797 // Creates a new empty #GKeyFile object. Use
4798 // g_key_file_load_from_file(), g_key_file_load_from_data(),
4799 // g_key_file_load_from_dirs() or g_key_file_load_from_data_dirs() to
4800 // read an existing key file.
4801 // RETURNS: an empty #GKeyFile.
4802 static KeyFile* new_()() {
4803 return g_key_file_new();
4807 enum KeyFileError {
4808 UNKNOWN_ENCODING = 0,
4809 PARSE = 1,
4810 NOT_FOUND = 2,
4811 KEY_NOT_FOUND = 3,
4812 GROUP_NOT_FOUND = 4,
4813 INVALID_VALUE = 5
4815 enum KeyFileFlags {
4816 NONE = 0,
4817 KEEP_COMMENTS = 1,
4818 KEEP_TRANSLATIONS = 2
4820 enum int LITTLE_ENDIAN = 1234;
4821 enum double LN10 = 2.302585;
4822 enum double LN2 = 0.693147;
4823 enum double LOG_2_BASE_10 = 0.301030;
4824 enum int LOG_FATAL_MASK = 0;
4825 enum int LOG_LEVEL_USER_SHIFT = 8;
4826 // The #GList struct is used for each element in a doubly-linked list.
4827 struct List {
4828 void* data;
4829 GLib2.List* next, prev;
4832 // Unintrospectable function: alloc() / g_list_alloc()
4833 // Allocates space for one #GList element. It is called by
4834 // g_list_append(), g_list_prepend(), g_list_insert() and
4835 // g_list_insert_sorted() and so is rarely used on its own.
4836 static GLib2.List* alloc()() {
4837 return g_list_alloc();
4840 // Unintrospectable function: append() / g_list_append()
4841 // Adds a new element on to the end of the list.
4843 // <note><para>
4844 // The return value is the new start of the list, which
4845 // may have changed, so make sure you store the new value.
4846 // </para></note>
4848 // <note><para>
4849 // Note that g_list_append() has to traverse the entire list
4850 // to find the end, which is inefficient when adding multiple
4851 // elements. A common idiom to avoid the inefficiency is to prepend
4852 // the elements and reverse the list when all elements have been added.
4853 // </para></note>
4855 // |[
4856 // /&ast; Notice that these are initialized to the empty list. &ast;/
4857 // GList *list = NULL, *number_list = NULL;
4859 // /&ast; This is a list of strings. &ast;/
4860 // list = g_list_append (list, "first");
4861 // list = g_list_append (list, "second");
4863 // /&ast; This is a list of integers. &ast;/
4864 // number_list = g_list_append (number_list, GINT_TO_POINTER (27));
4865 // number_list = g_list_append (number_list, GINT_TO_POINTER (14));
4866 // ]|
4867 // RETURNS: the new start of the #GList
4868 // <list>: a pointer to a #GList
4869 // <data>: the data for the new element
4870 static GLib2.List* append()(GLib2.List* list, void* data) {
4871 return g_list_append(list, data);
4874 // Unintrospectable function: concat() / g_list_concat()
4875 // Adds the second #GList onto the end of the first #GList.
4876 // Note that the elements of the second #GList are not copied.
4877 // They are used directly.
4878 // RETURNS: the start of the new #GList
4879 // <list1>: a #GList
4880 // <list2>: the #GList to add to the end of the first #GList
4881 static GLib2.List* concat()(GLib2.List* list1, GLib2.List* list2) {
4882 return g_list_concat(list1, list2);
4885 // Unintrospectable function: copy() / g_list_copy()
4886 // Copies a #GList.
4888 // <note><para>
4889 // Note that this is a "shallow" copy. If the list elements
4890 // consist of pointers to data, the pointers are copied but
4891 // the actual data is not.
4892 // </para></note>
4893 // RETURNS: a copy of @list
4894 // <list>: a #GList
4895 static GLib2.List* copy()(GLib2.List* list) {
4896 return g_list_copy(list);
4899 // Unintrospectable function: delete_link() / g_list_delete_link()
4900 // Removes the node link_ from the list and frees it.
4901 // Compare this to g_list_remove_link() which removes the node
4902 // without freeing it.
4903 // RETURNS: the new head of @list
4904 // <list>: a #GList
4905 // <link_>: node to delete from @list
4906 static GLib2.List* delete_link()(GLib2.List* list, GLib2.List* link_) {
4907 return g_list_delete_link(list, link_);
4910 // Unintrospectable function: find() / g_list_find()
4911 // Finds the element in a #GList which
4912 // contains the given data.
4914 // or %NULL if it is not found
4915 // RETURNS: the found #GList element,
4916 // <list>: a #GList
4917 // <data>: the element data to find
4918 static GLib2.List* find()(GLib2.List* list, const(void)* data) {
4919 return g_list_find(list, data);
4922 // Unintrospectable function: find_custom() / g_list_find_custom()
4923 // Finds an element in a #GList, using a supplied function to
4924 // find the desired element. It iterates over the list, calling
4925 // the given function which should return 0 when the desired
4926 // element is found. The function takes two #gconstpointer arguments,
4927 // the #GList element's data as the first argument and the
4928 // given user data.
4929 // RETURNS: the found #GList element, or %NULL if it is not found
4930 // <list>: a #GList
4931 // <data>: user data passed to the function
4932 // <func>: the function to call for each element. It should return 0 when the desired element is found
4933 static GLib2.List* find_custom()(GLib2.List* list, const(void)* data, CompareFunc func) {
4934 return g_list_find_custom(list, data, func);
4937 // Unintrospectable function: first() / g_list_first()
4938 // Gets the first element in a #GList.
4940 // or %NULL if the #GList has no elements
4941 // RETURNS: the first element in the #GList,
4942 // <list>: a #GList
4943 static GLib2.List* first()(GLib2.List* list) {
4944 return g_list_first(list);
4947 // Unintrospectable function: foreach() / g_list_foreach()
4948 // Calls a function for each element of a #GList.
4949 // <list>: a #GList
4950 // <func>: the function to call with each element's data
4951 // <user_data>: user data to pass to the function
4952 static void foreach_()(GLib2.List* list, Func func, void* user_data) {
4953 g_list_foreach(list, func, user_data);
4956 // Unintrospectable function: free() / g_list_free()
4957 // Frees all of the memory used by a #GList.
4958 // The freed elements are returned to the slice allocator.
4960 // <note><para>
4961 // If list elements contain dynamically-allocated memory,
4962 // you should either use g_list_free_full() or free them manually
4963 // first.
4964 // </para></note>
4965 // <list>: a #GList
4966 static void free()(GLib2.List* list) {
4967 g_list_free(list);
4970 // Unintrospectable function: free_1() / g_list_free_1()
4971 // Frees one #GList element.
4972 // It is usually used after g_list_remove_link().
4973 // <list>: a #GList element
4974 static void free_1()(GLib2.List* list) {
4975 g_list_free_1(list);
4978 // Unintrospectable function: free_full() / g_list_free_full()
4979 // VERSION: 2.28
4980 // Convenience method, which frees all the memory used by a #GList, and
4981 // calls the specified destroy function on every element's data.
4982 // <list>: a pointer to a #GList
4983 // <free_func>: the function to be called to free each element's data
4984 static void free_full()(GLib2.List* list, DestroyNotify free_func) {
4985 g_list_free_full(list, free_func);
4988 // Unintrospectable function: index() / g_list_index()
4989 // Gets the position of the element containing
4990 // the given data (starting from 0).
4992 // or -1 if the data is not found
4993 // RETURNS: the index of the element containing the data,
4994 // <list>: a #GList
4995 // <data>: the data to find
4996 static int index()(GLib2.List* list, const(void)* data) {
4997 return g_list_index(list, data);
5000 // Unintrospectable function: insert() / g_list_insert()
5001 // Inserts a new element into the list at the given position.
5002 // RETURNS: the new start of the #GList
5003 // <list>: a pointer to a #GList
5004 // <data>: the data for the new element
5005 // <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.
5006 static GLib2.List* insert()(GLib2.List* list, void* data, int position) {
5007 return g_list_insert(list, data, position);
5010 // Unintrospectable function: insert_before() / g_list_insert_before()
5011 // Inserts a new element into the list before the given position.
5012 // RETURNS: the new start of the #GList
5013 // <list>: a pointer to a #GList
5014 // <sibling>: the list element before which the new element is inserted or %NULL to insert at the end of the list
5015 // <data>: the data for the new element
5016 static GLib2.List* insert_before()(GLib2.List* list, GLib2.List* sibling, void* data) {
5017 return g_list_insert_before(list, sibling, data);
5020 // Unintrospectable function: insert_sorted() / g_list_insert_sorted()
5021 // Inserts a new element into the list, using the given comparison
5022 // function to determine its position.
5023 // RETURNS: the new start of the #GList
5024 // <list>: a pointer to a #GList
5025 // <data>: the data for the new element
5026 // <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.
5027 static GLib2.List* insert_sorted()(GLib2.List* list, void* data, CompareFunc func) {
5028 return g_list_insert_sorted(list, data, func);
5031 // Unintrospectable function: insert_sorted_with_data() / g_list_insert_sorted_with_data()
5032 // VERSION: 2.10
5033 // Inserts a new element into the list, using the given comparison
5034 // function to determine its position.
5035 // RETURNS: the new start of the #GList
5036 // <list>: a pointer to a #GList
5037 // <data>: the data for the new element
5038 // <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.
5039 // <user_data>: user data to pass to comparison function.
5040 static GLib2.List* insert_sorted_with_data()(GLib2.List* list, void* data, CompareDataFunc func, void* user_data) {
5041 return g_list_insert_sorted_with_data(list, data, func, user_data);
5044 // Unintrospectable function: last() / g_list_last()
5045 // Gets the last element in a #GList.
5047 // or %NULL if the #GList has no elements
5048 // RETURNS: the last element in the #GList,
5049 // <list>: a #GList
5050 static GLib2.List* last()(GLib2.List* list) {
5051 return g_list_last(list);
5054 // Unintrospectable function: length() / g_list_length()
5055 // Gets the number of elements in a #GList.
5057 // <note><para>
5058 // This function iterates over the whole list to
5059 // count its elements.
5060 // </para></note>
5061 // RETURNS: the number of elements in the #GList
5062 // <list>: a #GList
5063 static uint length()(GLib2.List* list) {
5064 return g_list_length(list);
5067 // Unintrospectable function: nth() / g_list_nth()
5068 // Gets the element at the given position in a #GList.
5070 // the end of the #GList
5071 // RETURNS: the element, or %NULL if the position is off
5072 // <list>: a #GList
5073 // <n>: the position of the element, counting from 0
5074 static GLib2.List* nth()(GLib2.List* list, uint n) {
5075 return g_list_nth(list, n);
5078 // Unintrospectable function: nth_data() / g_list_nth_data()
5079 // Gets the data of the element at the given position.
5081 // is off the end of the #GList
5082 // RETURNS: the element's data, or %NULL if the position
5083 // <list>: a #GList
5084 // <n>: the position of the element
5085 static void* nth_data()(GLib2.List* list, uint n) {
5086 return g_list_nth_data(list, n);
5089 // Unintrospectable function: nth_prev() / g_list_nth_prev()
5090 // Gets the element @n places before @list.
5092 // off the end of the #GList
5093 // RETURNS: the element, or %NULL if the position is
5094 // <list>: a #GList
5095 // <n>: the position of the element, counting from 0
5096 static GLib2.List* nth_prev()(GLib2.List* list, uint n) {
5097 return g_list_nth_prev(list, n);
5100 // Restores the previous #GAllocator, used when allocating #GList
5101 // elements.
5103 // Note that this function is not available if GLib has been compiled
5104 // with <option>--disable-mem-pools</option>
5106 // Deprecated:2.10: It does nothing, since #GList has been converted
5107 // to the <link linkend="glib-Memory-Slices">slice
5108 // allocator</link>
5109 static void pop_allocator()() {
5110 g_list_pop_allocator();
5113 // Unintrospectable function: position() / g_list_position()
5114 // Gets the position of the given element
5115 // in the #GList (starting from 0).
5117 // or -1 if the element is not found
5118 // RETURNS: the position of the element in the #GList,
5119 // <list>: a #GList
5120 // <llink>: an element in the #GList
5121 static int position()(GLib2.List* list, GLib2.List* llink) {
5122 return g_list_position(list, llink);
5125 // Unintrospectable function: prepend() / g_list_prepend()
5126 // Adds a new element on to the start of the list.
5128 // <note><para>
5129 // The return value is the new start of the list, which
5130 // may have changed, so make sure you store the new value.
5131 // </para></note>
5133 // |[
5134 // /&ast; Notice that it is initialized to the empty list. &ast;/
5135 // GList *list = NULL;
5136 // list = g_list_prepend (list, "last");
5137 // list = g_list_prepend (list, "first");
5138 // ]|
5139 // RETURNS: the new start of the #GList
5140 // <list>: a pointer to a #GList
5141 // <data>: the data for the new element
5142 static GLib2.List* prepend()(GLib2.List* list, void* data) {
5143 return g_list_prepend(list, data);
5146 // Sets the allocator to use to allocate #GList elements. Use
5147 // g_list_pop_allocator() to restore the previous allocator.
5149 // Note that this function is not available if GLib has been compiled
5150 // with <option>--disable-mem-pools</option>
5152 // Deprecated:2.10: It does nothing, since #GList has been converted
5153 // to the <link linkend="glib-Memory-Slices">slice
5154 // allocator</link>
5155 // <allocator>: the #GAllocator to use when allocating #GList elements.
5156 static void push_allocator()(void* allocator) {
5157 g_list_push_allocator(allocator);
5160 // Unintrospectable function: remove() / g_list_remove()
5161 // Removes an element from a #GList.
5162 // If two elements contain the same data, only the first is removed.
5163 // If none of the elements contain the data, the #GList is unchanged.
5164 // RETURNS: the new start of the #GList
5165 // <list>: a #GList
5166 // <data>: the data of the element to remove
5167 static GLib2.List* remove()(GLib2.List* list, const(void)* data) {
5168 return g_list_remove(list, data);
5171 // Unintrospectable function: remove_all() / g_list_remove_all()
5172 // Removes all list nodes with data equal to @data.
5173 // Returns the new head of the list. Contrast with
5174 // g_list_remove() which removes only the first node
5175 // matching the given data.
5176 // RETURNS: new head of @list
5177 // <list>: a #GList
5178 // <data>: data to remove
5179 static GLib2.List* remove_all()(GLib2.List* list, const(void)* data) {
5180 return g_list_remove_all(list, data);
5183 // Unintrospectable function: remove_link() / g_list_remove_link()
5184 // Removes an element from a #GList, without freeing the element.
5185 // The removed element's prev and next links are set to %NULL, so
5186 // that it becomes a self-contained list with one element.
5187 // RETURNS: the new start of the #GList, without the element
5188 // <list>: a #GList
5189 // <llink>: an element in the #GList
5190 static GLib2.List* remove_link()(GLib2.List* list, GLib2.List* llink) {
5191 return g_list_remove_link(list, llink);
5194 // Unintrospectable function: reverse() / g_list_reverse()
5195 // Reverses a #GList.
5196 // It simply switches the next and prev pointers of each element.
5197 // RETURNS: the start of the reversed #GList
5198 // <list>: a #GList
5199 static GLib2.List* reverse()(GLib2.List* list) {
5200 return g_list_reverse(list);
5203 // Unintrospectable function: sort() / g_list_sort()
5204 // Sorts a #GList using the given comparison function.
5205 // RETURNS: the start of the sorted #GList
5206 // <list>: a #GList
5207 // <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.
5208 static GLib2.List* sort()(GLib2.List* list, CompareFunc compare_func) {
5209 return g_list_sort(list, compare_func);
5212 // Unintrospectable function: sort_with_data() / g_list_sort_with_data()
5213 // Like g_list_sort(), but the comparison function accepts
5214 // a user data argument.
5215 // RETURNS: the new head of @list
5216 // <list>: a #GList
5217 // <compare_func>: comparison function
5218 // <user_data>: user data to pass to comparison function
5219 static GLib2.List* sort_with_data()(GLib2.List* list, CompareDataFunc compare_func, void* user_data) {
5220 return g_list_sort_with_data(list, compare_func, user_data);
5224 extern (C) alias void function (char* log_domain, LogLevelFlags log_level, char* message, void* user_data) LogFunc;
5226 enum LogLevelFlags {
5227 FLAG_RECURSION = 1,
5228 FLAG_FATAL = 2,
5229 LEVEL_ERROR = 4,
5230 LEVEL_CRITICAL = 8,
5231 LEVEL_WARNING = 16,
5232 LEVEL_MESSAGE = 32,
5233 LEVEL_INFO = 64,
5234 LEVEL_DEBUG = 128,
5235 LEVEL_MASK = -4
5237 enum int MAJOR_VERSION = 2;
5238 enum int MICRO_VERSION = 2;
5239 enum int MINOR_VERSION = 30;
5240 enum MODULE_SUFFIX = "so";
5241 enum int MUTEX_DEBUG_MAGIC = cast(int)4175530711;
5243 // The <structname>GMainContext</structname> struct is an opaque data
5244 // type representing a set of sources to be handled in a main loop.
5245 struct MainContext {
5247 // Creates a new #GMainContext structure.
5248 // RETURNS: the new #GMainContext
5249 static MainContext* /*new*/ new_()() {
5250 return g_main_context_new();
5253 // Tries to become the owner of the specified context.
5254 // If some other thread is the owner of the context,
5255 // returns %FALSE immediately. Ownership is properly
5256 // recursive: the owner can require ownership again
5257 // and will release ownership when g_main_context_release()
5258 // is called as many times as g_main_context_acquire().
5260 // You must be the owner of a context before you
5261 // can call g_main_context_prepare(), g_main_context_query(),
5262 // g_main_context_check(), g_main_context_dispatch().
5264 // this thread is now the owner of @context.
5265 // RETURNS: %TRUE if the operation succeeded, and
5266 int acquire()() {
5267 return g_main_context_acquire(&this);
5270 // Adds a file descriptor to the set of file descriptors polled for
5271 // this context. This will very seldom be used directly. Instead
5272 // a typical event source will use g_source_add_poll() instead.
5273 // <fd>: a #GPollFD structure holding information about a file descriptor to watch.
5274 // <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.
5275 void add_poll()(PollFD* fd, int priority) {
5276 g_main_context_add_poll(&this, fd, priority);
5279 // Passes the results of polling back to the main loop.
5280 // RETURNS: %TRUE if some sources are ready to be dispatched.
5281 // <max_priority>: the maximum numerical priority of sources to check
5282 // <fds>: array of #GPollFD's that was passed to the last call to g_main_context_query()
5283 // <n_fds>: return value of g_main_context_query()
5284 int check()(int max_priority, PollFD* fds, int n_fds) {
5285 return g_main_context_check(&this, max_priority, fds, n_fds);
5287 // Dispatches all pending sources.
5288 void dispatch()() {
5289 g_main_context_dispatch(&this);
5292 // Finds a source with the given source functions and user data. If
5293 // multiple sources exist with the same source function and user data,
5294 // the first one found will be returned.
5295 // RETURNS: the source, if one was found, otherwise %NULL
5296 // <funcs>: the @source_funcs passed to g_source_new().
5297 // <user_data>: the user data from the callback.
5298 Source* find_source_by_funcs_user_data()(SourceFuncs* funcs, void* user_data) {
5299 return g_main_context_find_source_by_funcs_user_data(&this, funcs, user_data);
5302 // Finds a #GSource given a pair of context and ID.
5303 // RETURNS: the #GSource if found, otherwise, %NULL
5304 // <source_id>: the source ID, as returned by g_source_get_id().
5305 Source* find_source_by_id()(uint source_id) {
5306 return g_main_context_find_source_by_id(&this, source_id);
5309 // Finds a source with the given user data for the callback. If
5310 // multiple sources exist with the same user data, the first
5311 // one found will be returned.
5312 // RETURNS: the source, if one was found, otherwise %NULL
5313 // <user_data>: the user_data for the callback.
5314 Source* find_source_by_user_data()(void* user_data) {
5315 return g_main_context_find_source_by_user_data(&this, user_data);
5318 // Unintrospectable method: get_poll_func() / g_main_context_get_poll_func()
5319 // Gets the poll function set by g_main_context_set_poll_func().
5320 // RETURNS: the poll function
5321 PollFunc get_poll_func()() {
5322 return g_main_context_get_poll_func(&this);
5325 // Unintrospectable method: invoke() / g_main_context_invoke()
5326 // VERSION: 2.28
5327 // Invokes a function in such a way that @context is owned during the
5328 // invocation of @function.
5330 // If @context is %NULL then the global default main context — as
5331 // returned by g_main_context_default() — is used.
5333 // If @context is owned by the current thread, @function is called
5334 // directly. Otherwise, if @context is the thread-default main context
5335 // of the current thread and g_main_context_acquire() succeeds, then
5336 // @function is called and g_main_context_release() is called
5337 // afterwards.
5339 // In any other case, an idle source is created to call @function and
5340 // that source is attached to @context (presumably to be run in another
5341 // thread). The idle source is attached with #G_PRIORITY_DEFAULT
5342 // priority. If you want a different priority, use
5343 // g_main_context_invoke_full().
5345 // Note that, as with normal idle functions, @function should probably
5346 // return %FALSE. If it returns %TRUE, it will be continuously run in a
5347 // loop (and may prevent this call from returning).
5348 // <function>: function to call
5349 // <data>: data to pass to @function
5350 void invoke()(SourceFunc function_, void* data) {
5351 g_main_context_invoke(&this, function_, data);
5354 // VERSION: 2.28
5355 // Invokes a function in such a way that @context is owned during the
5356 // invocation of @function.
5358 // This function is the same as g_main_context_invoke() except that it
5359 // lets you specify the priority incase @function ends up being
5360 // scheduled as an idle and also lets you give a #GDestroyNotify for @data.
5362 // @notify should not assume that it is called from any particular
5363 // thread or with any particular context acquired.
5364 // <priority>: the priority at which to run @function
5365 // <function>: function to call
5366 // <data>: data to pass to @function
5367 // <notify>: a function to call when @data is no longer in use, or %NULL.
5368 void invoke_full()(int priority, SourceFunc function_, void* data, DestroyNotify notify) {
5369 g_main_context_invoke_full(&this, priority, function_, data, notify);
5372 // VERSION: 2.10
5373 // Determines whether this thread holds the (recursive)
5374 // ownership of this #GMaincontext. This is useful to
5375 // know before waiting on another thread that may be
5376 // blocking to get ownership of @context.
5377 // RETURNS: %TRUE if current thread is owner of @context.
5378 int is_owner()() {
5379 return g_main_context_is_owner(&this);
5382 // Runs a single iteration for the given main loop. This involves
5383 // checking to see if any event sources are ready to be processed,
5384 // then if no events sources are ready and @may_block is %TRUE, waiting
5385 // for a source to become ready, then dispatching the highest priority
5386 // events sources that are ready. Otherwise, if @may_block is %FALSE
5387 // sources are not waited to become ready, only those highest priority
5388 // events sources will be dispatched (if any), that are ready at this
5389 // given moment without further waiting.
5391 // Note that even when @may_block is %TRUE, it is still possible for
5392 // g_main_context_iteration() to return %FALSE, since the the wait may
5393 // be interrupted for other reasons than an event source becoming ready.
5394 // RETURNS: %TRUE if events were dispatched.
5395 // <may_block>: whether the call may block.
5396 int iteration()(int may_block) {
5397 return g_main_context_iteration(&this, may_block);
5400 // Checks if any sources have pending events for the given context.
5401 // RETURNS: %TRUE if events are pending.
5402 int pending()() {
5403 return g_main_context_pending(&this);
5406 // VERSION: 2.22
5407 // Pops @context off the thread-default context stack (verifying that
5408 // it was on the top of the stack).
5409 void pop_thread_default()() {
5410 g_main_context_pop_thread_default(&this);
5413 // Prepares to poll sources within a main loop. The resulting information
5414 // for polling is determined by calling g_main_context_query ().
5416 // prior to polling.
5417 // RETURNS: %TRUE if some source is ready to be dispatched
5418 // <priority>: location to store priority of highest priority source already ready.
5419 int prepare()(int* priority) {
5420 return g_main_context_prepare(&this, priority);
5423 // VERSION: 2.22
5424 // Acquires @context and sets it as the thread-default context for the
5425 // current thread. This will cause certain asynchronous operations
5426 // (such as most <link linkend="gio">gio</link>-based I/O) which are
5427 // started in this thread to run under @context and deliver their
5428 // results to its main loop, rather than running under the global
5429 // default context in the main thread. Note that calling this function
5430 // changes the context returned by
5431 // g_main_context_get_thread_default(), <emphasis>not</emphasis> the
5432 // one returned by g_main_context_default(), so it does not affect the
5433 // context used by functions like g_idle_add().
5435 // Normally you would call this function shortly after creating a new
5436 // thread, passing it a #GMainContext which will be run by a
5437 // #GMainLoop in that thread, to set a new default context for all
5438 // async operations in that thread. (In this case, you don't need to
5439 // ever call g_main_context_pop_thread_default().) In some cases
5440 // however, you may want to schedule a single operation in a
5441 // non-default context, or temporarily use a non-default context in
5442 // the main thread. In that case, you can wrap the call to the
5443 // asynchronous operation inside a
5444 // g_main_context_push_thread_default() /
5445 // g_main_context_pop_thread_default() pair, but it is up to you to
5446 // ensure that no other asynchronous operations accidentally get
5447 // started while the non-default context is active.
5449 // Beware that libraries that predate this function may not correctly
5450 // handle being used from a thread with a thread-default context. Eg,
5451 // see g_file_supports_thread_contexts().
5452 void push_thread_default()() {
5453 g_main_context_push_thread_default(&this);
5456 // Determines information necessary to poll this main loop.
5458 // or, if more than @n_fds records need to be stored, the number
5459 // of records that need to be stored.
5460 // RETURNS: the number of records actually stored in @fds,
5461 // <max_priority>: maximum priority source to check
5462 // <timeout_>: location to store timeout to be used in polling
5463 // <fds>: location to store #GPollFD records that need to be polled.
5464 // <n_fds>: length of @fds.
5465 int query()(int max_priority, /*out*/ int* timeout_, /*out*/ PollFD* fds, /*out*/ int n_fds) {
5466 return g_main_context_query(&this, max_priority, timeout_, fds, n_fds);
5469 // Increases the reference count on a #GMainContext object by one.
5470 // RETURNS: the @context that was passed in (since 2.6)
5471 MainContext* /*new*/ ref_()() {
5472 return g_main_context_ref(&this);
5475 // Releases ownership of a context previously acquired by this thread
5476 // with g_main_context_acquire(). If the context was acquired multiple
5477 // times, the ownership will be released only when g_main_context_release()
5478 // is called as many times as it was acquired.
5479 void release()() {
5480 g_main_context_release(&this);
5483 // Removes file descriptor from the set of file descriptors to be
5484 // polled for a particular context.
5485 // <fd>: a #GPollFD descriptor previously added with g_main_context_add_poll()
5486 void remove_poll()(PollFD* fd) {
5487 g_main_context_remove_poll(&this, fd);
5490 // Unintrospectable method: set_poll_func() / g_main_context_set_poll_func()
5491 // Sets the function to use to handle polling of file descriptors. It
5492 // will be used instead of the poll() system call
5493 // (or GLib's replacement function, which is used where
5494 // poll() isn't available).
5496 // This function could possibly be used to integrate the GLib event
5497 // loop with an external event loop.
5498 // <func>: the function to call to poll all file descriptors
5499 void set_poll_func()(PollFunc func) {
5500 g_main_context_set_poll_func(&this, func);
5503 // Decreases the reference count on a #GMainContext object by one. If
5504 // the result is zero, free the context and free all associated memory.
5505 void unref()() {
5506 g_main_context_unref(&this);
5509 // Tries to become the owner of the specified context,
5510 // as with g_main_context_acquire(). But if another thread
5511 // is the owner, atomically drop @mutex and wait on @cond until
5512 // that owner releases ownership or until @cond is signaled, then
5513 // try again (once) to become the owner.
5515 // this thread is now the owner of @context.
5516 // RETURNS: %TRUE if the operation succeeded, and
5517 // <cond>: a condition variable
5518 // <mutex>: a mutex, currently held
5519 int wait()(Cond* cond, Mutex* mutex) {
5520 return g_main_context_wait(&this, cond, mutex);
5523 // If @context is currently waiting in a poll(), interrupt
5524 // the poll(), and continue the iteration process.
5525 void wakeup()() {
5526 g_main_context_wakeup(&this);
5529 // Returns the global default main context. This is the main context
5530 // used for main loop functions when a main loop is not explicitly
5531 // specified, and corresponds to the "main" main loop. See also
5532 // g_main_context_get_thread_default().
5533 // RETURNS: the global default main context.
5534 static MainContext* default_()() {
5535 return g_main_context_default();
5538 // VERSION: 2.22
5539 // Gets the thread-default #GMainContext for this thread. Asynchronous
5540 // operations that want to be able to be run in contexts other than
5541 // the default one should call this method to get a #GMainContext to
5542 // add their #GSource<!-- -->s to. (Note that even in single-threaded
5543 // programs applications may sometimes want to temporarily push a
5544 // non-default context, so it is not safe to assume that this will
5545 // always return %NULL if threads are not initialized.)
5547 // %NULL if the thread-default context is the global default context.
5548 // RETURNS: the thread-default #GMainContext, or
5549 static MainContext* get_thread_default()() {
5550 return g_main_context_get_thread_default();
5555 // The <structname>GMainLoop</structname> struct is an opaque data type
5556 // representing the main event loop of a GLib or GTK+ application.
5557 struct MainLoop {
5559 // Creates a new #GMainLoop structure.
5560 // RETURNS: a new #GMainLoop.
5561 // <context>: a #GMainContext (if %NULL, the default context will be used).
5562 // <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.
5563 static MainLoop* /*new*/ new_()(MainContext* context, int is_running) {
5564 return g_main_loop_new(context, is_running);
5567 // Returns the #GMainContext of @loop.
5568 // RETURNS: the #GMainContext of @loop
5569 MainContext* get_context()() {
5570 return g_main_loop_get_context(&this);
5573 // Checks to see if the main loop is currently being run via g_main_loop_run().
5574 // RETURNS: %TRUE if the mainloop is currently being run.
5575 int is_running()() {
5576 return g_main_loop_is_running(&this);
5579 // Stops a #GMainLoop from running. Any calls to g_main_loop_run()
5580 // for the loop will return.
5582 // Note that sources that have already been dispatched when
5583 // g_main_loop_quit() is called will still be executed.
5584 void quit()() {
5585 g_main_loop_quit(&this);
5588 // Increases the reference count on a #GMainLoop object by one.
5589 // RETURNS: @loop
5590 MainLoop* /*new*/ ref_()() {
5591 return g_main_loop_ref(&this);
5594 // Runs a main loop until g_main_loop_quit() is called on the loop.
5595 // If this is called for the thread of the loop's #GMainContext,
5596 // it will process events from the loop, otherwise it will
5597 // simply wait.
5598 void run()() {
5599 g_main_loop_run(&this);
5602 // Decreases the reference count on a #GMainLoop object by one. If
5603 // the result is zero, free the loop and free all associated memory.
5604 void unref()() {
5605 g_main_loop_unref(&this);
5609 struct MappedFile {
5611 // VERSION: 2.8
5612 // This call existed before #GMappedFile had refcounting and is currently
5613 // exactly the same as g_mapped_file_unref().
5615 // Deprecated:2.22: Use g_mapped_file_unref() instead.
5616 void free()() {
5617 g_mapped_file_free(&this);
5620 // VERSION: 2.8
5621 // Returns the contents of a #GMappedFile.
5623 // Note that the contents may not be zero-terminated,
5624 // even if the #GMappedFile is backed by a text file.
5626 // If the file is empty then %NULL is returned.
5627 // RETURNS: the contents of @file, or %NULL.
5628 char* /*new*/ get_contents()() {
5629 return g_mapped_file_get_contents(&this);
5632 // VERSION: 2.8
5633 // Returns the length of the contents of a #GMappedFile.
5634 // RETURNS: the length of the contents of @file.
5635 size_t get_length()() {
5636 return g_mapped_file_get_length(&this);
5639 // Unintrospectable method: ref() / g_mapped_file_ref()
5640 // VERSION: 2.22
5641 // Increments the reference count of @file by one. It is safe to call
5642 // this function from any thread.
5643 // RETURNS: the passed in #GMappedFile.
5644 MappedFile* ref_()() {
5645 return g_mapped_file_ref(&this);
5648 // Decrements the reference count of @file by one. If the reference count
5649 // drops to 0, unmaps the buffer of @file and frees it.
5651 // It is safe to call this function from any thread.
5653 // Since 2.22
5654 void unref()() {
5655 g_mapped_file_unref(&this);
5658 // Unintrospectable function: new() / g_mapped_file_new()
5659 // VERSION: 2.8
5660 // Maps a file into memory. On UNIX, this is using the mmap() function.
5662 // If @writable is %TRUE, the mapped buffer may be modified, otherwise
5663 // it is an error to modify the mapped buffer. Modifications to the buffer
5664 // are not visible to other processes mapping the same file, and are not
5665 // written back to the file.
5667 // Note that modifications of the underlying file might affect the contents
5668 // of the #GMappedFile. Therefore, mapping should only be used if the file
5669 // will not be modified, or if all modifications of the file are done
5670 // atomically (e.g. using g_file_set_contents()).
5672 // with g_mapped_file_unref(), or %NULL if the mapping failed.
5673 // RETURNS: a newly allocated #GMappedFile which must be unref'd
5674 // <filename>: The path of the file to load, in the GLib filename encoding
5675 // <writable>: whether the mapping should be writable
5676 static MappedFile* new_()(char* filename, int writable, GLib2.Error** error=null) {
5677 return g_mapped_file_new(filename, writable, error);
5682 // A mixed enumerated type and flags field. You must specify one type
5683 // (string, strdup, boolean, tristate). Additionally, you may optionally
5684 // bitwise OR the type with the flag %G_MARKUP_COLLECT_OPTIONAL.
5686 // It is likely that this enum will be extended in the future to
5687 // support other types.
5688 enum MarkupCollectType {
5689 INVALID = 0,
5690 STRING = 1,
5691 STRDUP = 2,
5692 BOOLEAN = 3,
5693 TRISTATE = 4,
5694 OPTIONAL = 65536
5696 // Error codes returned by markup parsing.
5697 enum MarkupError {
5698 BAD_UTF8 = 0,
5699 EMPTY = 1,
5700 PARSE = 2,
5701 UNKNOWN_ELEMENT = 3,
5702 UNKNOWN_ATTRIBUTE = 4,
5703 INVALID_CONTENT = 5,
5704 MISSING_ATTRIBUTE = 6
5707 // A parse context is used to parse a stream of bytes that
5708 // you expect to contain marked-up text.
5710 // See g_markup_parse_context_new(), #GMarkupParser, and so
5711 // on for more details.
5712 struct MarkupParseContext {
5714 // Signals to the #GMarkupParseContext that all data has been
5715 // fed into the parse context with g_markup_parse_context_parse().
5717 // This function reports an error if the document isn't complete,
5718 // for example if elements are still open.
5719 // RETURNS: %TRUE on success, %FALSE if an error was set
5720 int end_parse()(GLib2.Error** error=null) {
5721 return g_markup_parse_context_end_parse(&this, error);
5724 // Frees a #GMarkupParseContext.
5726 // This function can't be called from inside one of the
5727 // #GMarkupParser functions or while a subparser is pushed.
5728 void free()() {
5729 g_markup_parse_context_free(&this);
5732 // VERSION: 2.2
5733 // Retrieves the name of the currently open element.
5735 // If called from the start_element or end_element handlers this will
5736 // give the element_name as passed to those functions. For the parent
5737 // elements, see g_markup_parse_context_get_element_stack().
5738 // RETURNS: the name of the currently open element, or %NULL
5739 char* get_element()() {
5740 return g_markup_parse_context_get_element(&this);
5743 // Unintrospectable method: get_element_stack() / g_markup_parse_context_get_element_stack()
5744 // VERSION: 2.16
5745 // Retrieves the element stack from the internal state of the parser.
5747 // The returned #GSList is a list of strings where the first item is
5748 // the currently open tag (as would be returned by
5749 // g_markup_parse_context_get_element()) and the next item is its
5750 // immediate parent.
5752 // This function is intended to be used in the start_element and
5753 // end_element handlers where g_markup_parse_context_get_element()
5754 // would merely return the name of the element that is being
5755 // processed.
5756 // RETURNS: the element stack, which must not be modified
5757 GLib2.SList* get_element_stack()() {
5758 return g_markup_parse_context_get_element_stack(&this);
5761 // Retrieves the current line number and the number of the character on
5762 // that line. Intended for use in error messages; there are no strict
5763 // semantics for what constitutes the "current" line number other than
5764 // "the best number we could come up with for error messages."
5765 // <line_number>: return location for a line number, or %NULL
5766 // <char_number>: return location for a char-on-line number, or %NULL
5767 void get_position()(int* line_number=null, int* char_number=null) {
5768 g_markup_parse_context_get_position(&this, line_number, char_number);
5771 // Unintrospectable method: get_user_data() / g_markup_parse_context_get_user_data()
5772 // VERSION: 2.18
5773 // Returns the user_data associated with @context.
5775 // This will either be the user_data that was provided to
5776 // g_markup_parse_context_new() or to the most recent call
5777 // of g_markup_parse_context_push().
5779 // the markup context and will be freed when
5780 // g_markup_parse_context_free() is called.
5781 // RETURNS: the provided user_data. The returned data belongs to
5782 void* get_user_data()() {
5783 return g_markup_parse_context_get_user_data(&this);
5786 // Feed some data to the #GMarkupParseContext.
5788 // The data need not be valid UTF-8; an error will be signaled if
5789 // it's invalid. The data need not be an entire document; you can
5790 // feed a document into the parser incrementally, via multiple calls
5791 // to this function. Typically, as you receive data from a network
5792 // connection or file, you feed each received chunk of data into this
5793 // function, aborting the process if an error occurs. Once an error
5794 // is reported, no further data may be fed to the #GMarkupParseContext;
5795 // all errors are fatal.
5796 // RETURNS: %FALSE if an error occurred, %TRUE on success
5797 // <text>: chunk of text to parse
5798 // <text_len>: length of @text in bytes
5799 int parse()(char* text, ssize_t text_len, GLib2.Error** error=null) {
5800 return g_markup_parse_context_parse(&this, text, text_len, error);
5803 // Unintrospectable method: pop() / g_markup_parse_context_pop()
5804 // VERSION: 2.18
5805 // Completes the process of a temporary sub-parser redirection.
5807 // This function exists to collect the user_data allocated by a
5808 // matching call to g_markup_parse_context_push(). It must be called
5809 // in the end_element handler corresponding to the start_element
5810 // handler during which g_markup_parse_context_push() was called.
5811 // You must not call this function from the error callback -- the
5812 // @user_data is provided directly to the callback in that case.
5814 // This function is not intended to be directly called by users
5815 // interested in invoking subparsers. Instead, it is intended to
5816 // be used by the subparsers themselves to implement a higher-level
5817 // interface.
5818 // RETURNS: the user data passed to g_markup_parse_context_push()
5819 void* pop()() {
5820 return g_markup_parse_context_pop(&this);
5823 // VERSION: 2.18
5824 // Temporarily redirects markup data to a sub-parser.
5826 // This function may only be called from the start_element handler of
5827 // a #GMarkupParser. It must be matched with a corresponding call to
5828 // g_markup_parse_context_pop() in the matching end_element handler
5829 // (except in the case that the parser aborts due to an error).
5831 // All tags, text and other data between the matching tags is
5832 // redirected to the subparser given by @parser. @user_data is used
5833 // as the user_data for that parser. @user_data is also passed to the
5834 // error callback in the event that an error occurs. This includes
5835 // errors that occur in subparsers of the subparser.
5837 // The end tag matching the start tag for which this call was made is
5838 // handled by the previous parser (which is given its own user_data)
5839 // which is why g_markup_parse_context_pop() is provided to allow "one
5840 // last access" to the @user_data provided to this function. In the
5841 // case of error, the @user_data provided here is passed directly to
5842 // the error callback of the subparser and g_markup_parse_context_pop()
5843 // should not be called. In either case, if @user_data was allocated
5844 // then it ought to be freed from both of these locations.
5846 // This function is not intended to be directly called by users
5847 // interested in invoking subparsers. Instead, it is intended to be
5848 // used by the subparsers themselves to implement a higher-level
5849 // interface.
5851 // As an example, see the following implementation of a simple
5852 // parser that counts the number of tags encountered.
5854 // |[
5855 // typedef struct
5856 // {
5857 // gint tag_count;
5858 // } CounterData;
5860 // static void
5861 // counter_start_element (GMarkupParseContext *context,
5862 // const gchar *element_name,
5863 // const gchar **attribute_names,
5864 // const gchar **attribute_values,
5865 // gpointer user_data,
5866 // GError **error)
5867 // {
5868 // CounterData *data = user_data;
5870 // data->tag_count++;
5871 // }
5873 // static void
5874 // counter_error (GMarkupParseContext *context,
5875 // GError *error,
5876 // gpointer user_data)
5877 // {
5878 // CounterData *data = user_data;
5880 // g_slice_free (CounterData, data);
5881 // }
5883 // static GMarkupParser counter_subparser =
5884 // {
5885 // counter_start_element,
5886 // NULL,
5887 // NULL,
5888 // NULL,
5889 // counter_error
5890 // };
5891 // ]|
5893 // In order to allow this parser to be easily used as a subparser, the
5894 // following interface is provided:
5896 // |[
5897 // void
5898 // start_counting (GMarkupParseContext *context)
5899 // {
5900 // CounterData *data = g_slice_new (CounterData);
5902 // data->tag_count = 0;
5903 // g_markup_parse_context_push (context, &counter_subparser, data);
5904 // }
5906 // gint
5907 // end_counting (GMarkupParseContext *context)
5908 // {
5909 // CounterData *data = g_markup_parse_context_pop (context);
5910 // int result;
5912 // result = data->tag_count;
5913 // g_slice_free (CounterData, data);
5915 // return result;
5916 // }
5917 // ]|
5919 // The subparser would then be used as follows:
5921 // |[
5922 // static void start_element (context, element_name, ...)
5923 // {
5924 // if (strcmp (element_name, "count-these") == 0)
5925 // start_counting (context);
5927 // /&ast; else, handle other tags... &ast;/
5928 // }
5930 // static void end_element (context, element_name, ...)
5931 // {
5932 // if (strcmp (element_name, "count-these") == 0)
5933 // g_print ("Counted %d tags\n", end_counting (context));
5935 // /&ast; else, handle other tags... &ast;/
5936 // }
5937 // ]|
5938 // <parser>: a #GMarkupParser
5939 // <user_data>: user data to pass to #GMarkupParser functions
5940 void push()(MarkupParser* parser, void* user_data) {
5941 g_markup_parse_context_push(&this, parser, user_data);
5944 // Unintrospectable function: new() / g_markup_parse_context_new()
5945 // Creates a new parse context. A parse context is used to parse
5946 // marked-up documents. You can feed any number of documents into
5947 // a context, as long as no errors occur; once an error occurs,
5948 // the parse context can't continue to parse text (you have to
5949 // free it and create a new parse context).
5950 // RETURNS: a new #GMarkupParseContext
5951 // <parser>: a #GMarkupParser
5952 // <flags>: one or more #GMarkupParseFlags
5953 // <user_data>: user data to pass to #GMarkupParser functions
5954 // <user_data_dnotify>: user data destroy notifier called when the parse context is freed
5955 static MarkupParseContext* new_()(MarkupParser* parser, MarkupParseFlags flags, void* user_data, DestroyNotify user_data_dnotify) {
5956 return g_markup_parse_context_new(parser, flags, user_data, user_data_dnotify);
5960 // Flags that affect the behaviour of the parser.
5961 enum MarkupParseFlags {
5962 DO_NOT_USE_THIS_UNSUPPORTED_FLAG = 1,
5963 TREAT_CDATA_AS_TEXT = 2,
5964 PREFIX_ERROR_POSITION = 4
5967 // Any of the fields in #GMarkupParser can be %NULL, in which case they
5968 // will be ignored. Except for the @error function, any of these callbacks
5969 // can set an error; in particular the %G_MARKUP_ERROR_UNKNOWN_ELEMENT,
5970 // %G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, and %G_MARKUP_ERROR_INVALID_CONTENT
5971 // errors are intended to be set from these callbacks. If you set an error
5972 // from a callback, g_markup_parse_context_parse() will report that error
5973 // back to its caller.
5974 struct MarkupParser {
5975 extern (C) void function (MarkupParseContext* context, char* element_name, char** attribute_names, char** attribute_values, void* user_data, GLib2.Error** error=null) start_element;
5976 extern (C) void function (MarkupParseContext* context, char* element_name, void* user_data, GLib2.Error** error=null) end_element;
5977 extern (C) void function (MarkupParseContext* context, char* text, size_t text_len, void* user_data, GLib2.Error** error=null) text;
5978 extern (C) void function (MarkupParseContext* context, char* passthrough_text, size_t text_len, void* user_data, GLib2.Error** error=null) passthrough;
5979 extern (C) void function (MarkupParseContext* context, Error* error, void* user_data) error;
5982 struct MatchInfo {
5984 // VERSION: 2.14
5985 // Returns a new string containing the text in @string_to_expand with
5986 // references and escape sequences expanded. References refer to the last
5987 // match done with @string against @regex and have the same syntax used by
5988 // g_regex_replace().
5990 // The @string_to_expand must be UTF-8 encoded even if #G_REGEX_RAW was
5991 // passed to g_regex_new().
5993 // The backreferences are extracted from the string passed to the match
5994 // function, so you cannot call this function after freeing the string.
5996 // @match_info may be %NULL in which case @string_to_expand must not
5997 // contain references. For instance "foo\n" does not refer to an actual
5998 // pattern and '\n' merely will be replaced with \n character,
5999 // while to expand "\0" (whole match) one needs the result of a match.
6000 // Use g_regex_check_replacement() to find out whether @string_to_expand
6001 // contains references.
6002 // RETURNS: the expanded string, or %NULL if an error occurred
6003 // <string_to_expand>: the string to expand
6004 char* /*new*/ expand_references()(char* string_to_expand, GLib2.Error** error=null) {
6005 return g_match_info_expand_references(&this, string_to_expand, error);
6008 // VERSION: 2.14
6009 // Retrieves the text matching the @match_num<!-- -->'th capturing
6010 // parentheses. 0 is the full text of the match, 1 is the first paren
6011 // set, 2 the second, and so on.
6013 // If @match_num is a valid sub pattern but it didn't match anything
6014 // (e.g. sub pattern 1, matching "b" against "(a)?b") then an empty
6015 // string is returned.
6017 // If the match was obtained using the DFA algorithm, that is using
6018 // g_regex_match_all() or g_regex_match_all_full(), the retrieved
6019 // string is not that of a set of parentheses but that of a matched
6020 // substring. Substrings are matched in reverse order of length, so
6021 // 0 is the longest match.
6023 // The string is fetched from the string passed to the match function,
6024 // so you cannot call this function after freeing the string.
6026 // occurred. You have to free the string yourself
6027 // RETURNS: The matched substring, or %NULL if an error
6028 // <match_num>: number of the sub expression
6029 char* /*new*/ fetch()(int match_num) {
6030 return g_match_info_fetch(&this, match_num);
6033 // Unintrospectable method: fetch_all() / g_match_info_fetch_all()
6034 // VERSION: 2.14
6035 // Bundles up pointers to each of the matching substrings from a match
6036 // and stores them in an array of gchar pointers. The first element in
6037 // the returned array is the match number 0, i.e. the entire matched
6038 // text.
6040 // If a sub pattern didn't match anything (e.g. sub pattern 1, matching
6041 // "b" against "(a)?b") then an empty string is inserted.
6043 // If the last match was obtained using the DFA algorithm, that is using
6044 // g_regex_match_all() or g_regex_match_all_full(), the retrieved
6045 // strings are not that matched by sets of parentheses but that of the
6046 // matched substring. Substrings are matched in reverse order of length,
6047 // so the first one is the longest match.
6049 // The strings are fetched from the string passed to the match function,
6050 // so you cannot call this function after freeing the string.
6052 // It must be freed using g_strfreev(). If the previous match failed
6053 // %NULL is returned
6054 // RETURNS: a %NULL-terminated array of gchar * pointers.
6055 char** fetch_all()() {
6056 return g_match_info_fetch_all(&this);
6059 // VERSION: 2.14
6060 // Retrieves the text matching the capturing parentheses named @name.
6062 // If @name is a valid sub pattern name but it didn't match anything
6063 // (e.g. sub pattern "X", matching "b" against "(?P&lt;X&gt;a)?b")
6064 // then an empty string is returned.
6066 // The string is fetched from the string passed to the match function,
6067 // so you cannot call this function after freeing the string.
6069 // occurred. You have to free the string yourself
6070 // RETURNS: The matched substring, or %NULL if an error
6071 // <name>: name of the subexpression
6072 char* /*new*/ fetch_named()(char* name) {
6073 return g_match_info_fetch_named(&this, name);
6076 // VERSION: 2.14
6077 // Retrieves the position in bytes of the capturing parentheses named @name.
6079 // If @name is a valid sub pattern name but it didn't match anything
6080 // (e.g. sub pattern "X", matching "b" against "(?P&lt;X&gt;a)?b")
6081 // then @start_pos and @end_pos are set to -1 and %TRUE is returned.
6083 // If the position cannot be fetched, @start_pos and @end_pos
6084 // are left unchanged.
6085 // RETURNS: %TRUE if the position was fetched, %FALSE otherwise.
6086 // <name>: name of the subexpression
6087 // <start_pos>: pointer to location where to store the start position, or %NULL
6088 // <end_pos>: pointer to location where to store the end position, or %NULL
6089 int fetch_named_pos()(char* name, /*out*/ int* start_pos=null, /*out*/ int* end_pos=null) {
6090 return g_match_info_fetch_named_pos(&this, name, start_pos, end_pos);
6093 // VERSION: 2.14
6094 // Retrieves the position in bytes of the @match_num<!-- -->'th capturing
6095 // parentheses. 0 is the full text of the match, 1 is the first
6096 // paren set, 2 the second, and so on.
6098 // If @match_num is a valid sub pattern but it didn't match anything
6099 // (e.g. sub pattern 1, matching "b" against "(a)?b") then @start_pos
6100 // and @end_pos are set to -1 and %TRUE is returned.
6102 // If the match was obtained using the DFA algorithm, that is using
6103 // g_regex_match_all() or g_regex_match_all_full(), the retrieved
6104 // position is not that of a set of parentheses but that of a matched
6105 // substring. Substrings are matched in reverse order of length, so
6106 // 0 is the longest match.
6108 // the position cannot be fetched, @start_pos and @end_pos are left
6109 // unchanged
6110 // RETURNS: %TRUE if the position was fetched, %FALSE otherwise. If
6111 // <match_num>: number of the sub expression
6112 // <start_pos>: pointer to location where to store the start position, or %NULL
6113 // <end_pos>: pointer to location where to store the end position, or %NULL
6114 int fetch_pos()(int match_num, /*out*/ int* start_pos=null, /*out*/ int* end_pos=null) {
6115 return g_match_info_fetch_pos(&this, match_num, start_pos, end_pos);
6118 // VERSION: 2.14
6119 // If @match_info is not %NULL, calls g_match_info_unref(); otherwise does
6120 // nothing.
6121 void free()() {
6122 g_match_info_free(&this);
6125 // VERSION: 2.14
6126 // Retrieves the number of matched substrings (including substring 0,
6127 // that is the whole matched text), so 1 is returned if the pattern
6128 // has no substrings in it and 0 is returned if the match failed.
6130 // If the last match was obtained using the DFA algorithm, that is
6131 // using g_regex_match_all() or g_regex_match_all_full(), the retrieved
6132 // count is not that of the number of capturing parentheses but that of
6133 // the number of matched substrings.
6134 // RETURNS: Number of matched substrings, or -1 if an error occurred
6135 int get_match_count()() {
6136 return g_match_info_get_match_count(&this);
6139 // VERSION: 2.14
6140 // Returns #GRegex object used in @match_info. It belongs to Glib
6141 // and must not be freed. Use g_regex_ref() if you need to keep it
6142 // after you free @match_info object.
6143 // RETURNS: #GRegex object used in @match_info
6144 Regex* /*new*/ get_regex()() {
6145 return g_match_info_get_regex(&this);
6148 // VERSION: 2.14
6149 // Returns the string searched with @match_info. This is the
6150 // string passed to g_regex_match() or g_regex_replace() so
6151 // you may not free it before calling this function.
6152 // RETURNS: the string searched with @match_info
6153 char* get_string()() {
6154 return g_match_info_get_string(&this);
6157 // VERSION: 2.14
6158 // Usually if the string passed to g_regex_match*() matches as far as
6159 // it goes, but is too short to match the entire pattern, %FALSE is
6160 // returned. There are circumstances where it might be helpful to
6161 // distinguish this case from other cases in which there is no match.
6163 // Consider, for example, an application where a human is required to
6164 // type in data for a field with specific formatting requirements. An
6165 // example might be a date in the form ddmmmyy, defined by the pattern
6166 // "^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$".
6167 // If the application sees the user’s keystrokes one by one, and can
6168 // check that what has been typed so far is potentially valid, it is
6169 // able to raise an error as soon as a mistake is made.
6171 // GRegex supports the concept of partial matching by means of the
6172 // #G_REGEX_MATCH_PARTIAL flag. When this is set the return code for
6173 // g_regex_match() or g_regex_match_full() is, as usual, %TRUE
6174 // for a complete match, %FALSE otherwise. But, when these functions
6175 // return %FALSE, you can check if the match was partial calling
6176 // g_match_info_is_partial_match().
6178 // When using partial matching you cannot use g_match_info_fetch*().
6180 // Because of the way certain internal optimizations are implemented
6181 // the partial matching algorithm cannot be used with all patterns.
6182 // So repeated single characters such as "a{2,4}" and repeated single
6183 // meta-sequences such as "\d+" are not permitted if the maximum number
6184 // of occurrences is greater than one. Optional items such as "\d?"
6185 // (where the maximum is one) are permitted. Quantifiers with any values
6186 // are permitted after parentheses, so the invalid examples above can be
6187 // coded thus "(a){2,4}" and "(\d)+". If #G_REGEX_MATCH_PARTIAL is set
6188 // for a pattern that does not conform to the restrictions, matching
6189 // functions return an error.
6190 // RETURNS: %TRUE if the match was partial, %FALSE otherwise
6191 int is_partial_match()() {
6192 return g_match_info_is_partial_match(&this);
6195 // VERSION: 2.14
6196 // Returns whether the previous match operation succeeded.
6198 // %FALSE otherwise
6199 // RETURNS: %TRUE if the previous match operation succeeded,
6200 int matches()() {
6201 return g_match_info_matches(&this);
6204 // VERSION: 2.14
6205 // Scans for the next match using the same parameters of the previous
6206 // call to g_regex_match_full() or g_regex_match() that returned
6207 // @match_info.
6209 // The match is done on the string passed to the match function, so you
6210 // cannot free it before calling this function.
6211 // RETURNS: %TRUE is the string matched, %FALSE otherwise
6212 int next()(GLib2.Error** error=null) {
6213 return g_match_info_next(&this, error);
6216 // VERSION: 2.30
6217 // Increases reference count of @match_info by 1.
6218 // RETURNS: @match_info
6219 MatchInfo* /*new*/ ref_()() {
6220 return g_match_info_ref(&this);
6223 // VERSION: 2.30
6224 // Decreases reference count of @match_info by 1. When reference count drops
6225 // to zero, it frees all the memory associated with the match_info structure.
6226 void unref()() {
6227 g_match_info_unref(&this);
6232 // The #GMemChunk struct is an opaque data structure representing a
6233 // memory chunk. It should be accessed only through the use of the
6234 // following functions.
6235 struct MemChunk {
6237 // Unintrospectable method: alloc() / g_mem_chunk_alloc()
6238 // Allocates an atom of memory from a #GMemChunk.
6240 // Deprecated:2.10: Use g_slice_alloc() instead
6241 void* alloc()() {
6242 return g_mem_chunk_alloc(&this);
6245 // Unintrospectable method: alloc0() / g_mem_chunk_alloc0()
6246 // Allocates an atom of memory from a #GMemChunk, setting the memory to
6247 // 0.
6249 // Deprecated:2.10: Use g_slice_alloc0() instead
6250 void* alloc0()() {
6251 return g_mem_chunk_alloc0(&this);
6254 // Frees any blocks in a #GMemChunk which are no longer being used.
6256 // Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
6257 // allocator</link> instead
6258 void clean()() {
6259 g_mem_chunk_clean(&this);
6262 // Frees all of the memory allocated for a #GMemChunk.
6264 // Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
6265 // allocator</link> instead
6266 void destroy()() {
6267 g_mem_chunk_destroy(&this);
6270 // Frees an atom in a #GMemChunk. This should only be called if the
6271 // #GMemChunk was created with #G_ALLOC_AND_FREE. Otherwise it will
6272 // simply return.
6274 // Deprecated:2.10: Use g_slice_free1() instead
6275 // <mem>: a pointer to the atom to free.
6276 void free()(void* mem) {
6277 g_mem_chunk_free(&this, mem);
6280 // Outputs debugging information for a #GMemChunk. It outputs the name
6281 // of the #GMemChunk (set with g_mem_chunk_new()), the number of bytes
6282 // used, and the number of blocks of memory allocated.
6284 // Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
6285 // allocator</link> instead
6286 void print()() {
6287 g_mem_chunk_print(&this);
6290 // Resets a GMemChunk to its initial state. It frees all of the
6291 // currently allocated blocks of memory.
6293 // Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
6294 // allocator</link> instead
6295 void reset()() {
6296 g_mem_chunk_reset(&this);
6299 // Outputs debugging information for all #GMemChunk objects currently
6300 // in use. It outputs the number of #GMemChunk objects currently
6301 // allocated, and calls g_mem_chunk_print() to output information on
6302 // each one.
6304 // Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
6305 // allocator</link> instead
6306 static void info()() {
6307 g_mem_chunk_info();
6310 // Unintrospectable function: new() / g_mem_chunk_new()
6311 // Creates a new #GMemChunk.
6313 // Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
6314 // allocator</link> instead
6315 // <name>: a string to identify the #GMemChunk. It is not copied so it should be valid for the lifetime of the #GMemChunk. It is only used in g_mem_chunk_print(), which is used for debugging.
6316 // <atom_size>: the size, in bytes, of each element in the #GMemChunk.
6317 // <area_size>: the size, in bytes, of each block of memory allocated to contain the atoms.
6318 // <type>: the type of the #GMemChunk. #G_ALLOC_AND_FREE is used if the atoms will be freed individually. #G_ALLOC_ONLY should be used if atoms will never be freed individually. #G_ALLOC_ONLY is quicker, since it does not need to track free atoms, but it obviously wastes memory if you no longer need many of the atoms.
6319 static MemChunk* new_()(char* name, int atom_size, size_t area_size, int type) {
6320 return g_mem_chunk_new(name, atom_size, area_size, type);
6325 // A set of functions used to perform memory allocation. The same #GMemVTable must
6326 // be used for all allocations in the same program; a call to g_mem_set_vtable(),
6327 // if it exists, should be prior to any use of GLib.
6328 struct MemVTable {
6329 // Unintrospectable functionp: malloc() / ()
6330 extern (C) void* function (size_t n_bytes) malloc;
6331 // Unintrospectable functionp: realloc() / ()
6332 extern (C) void* function (void* mem, size_t n_bytes) realloc;
6333 extern (C) void function (void* mem) free;
6334 // Unintrospectable functionp: calloc() / ()
6335 extern (C) void* function (size_t n_blocks, size_t n_block_bytes) calloc;
6336 // Unintrospectable functionp: try_malloc() / ()
6337 extern (C) void* function (size_t n_bytes) try_malloc;
6338 // Unintrospectable functionp: try_realloc() / ()
6339 extern (C) void* function (void* mem, size_t n_bytes) try_realloc;
6343 // The #GMutex struct is an opaque data structure to represent a mutex
6344 // (mutual exclusion). It can be used to protect data against shared
6345 // access. Take for example the following function:
6347 // <example>
6348 // <title>A function which will not work in a threaded environment</title>
6349 // <programlisting>
6350 // int
6351 // give_me_next_number (void)
6352 // {
6353 // static int current_number = 0;
6355 // /<!-- -->* now do a very complicated calculation to calculate the new
6356 // * number, this might for example be a random number generator
6357 // *<!-- -->/
6358 // current_number = calc_next_number (current_number);
6360 // return current_number;
6361 // }
6362 // </programlisting>
6363 // </example>
6365 // It is easy to see that this won't work in a multi-threaded
6366 // application. There current_number must be protected against shared
6367 // access. A first naive implementation would be:
6369 // <example>
6370 // <title>The wrong way to write a thread-safe function</title>
6371 // <programlisting>
6372 // int
6373 // give_me_next_number (void)
6374 // {
6375 // static int current_number = 0;
6376 // int ret_val;
6377 // static GMutex * mutex = NULL;
6379 // if (!mutex) mutex = g_mutex_new (<!-- -->);
6381 // g_mutex_lock (mutex);
6382 // ret_val = current_number = calc_next_number (current_number);
6383 // g_mutex_unlock (mutex);
6385 // return ret_val;
6386 // }
6387 // </programlisting>
6388 // </example>
6390 // This looks like it would work, but there is a race condition while
6391 // constructing the mutex and this code cannot work reliable. Please do
6392 // not use such constructs in your own programs! One working solution
6393 // is:
6395 // <example>
6396 // <title>A correct thread-safe function</title>
6397 // <programlisting>
6398 // static GMutex *give_me_next_number_mutex = NULL;
6400 // /<!-- -->* this function must be called before any call to
6401 // * give_me_next_number(<!-- -->)
6402 // *
6403 // * it must be called exactly once.
6404 // *<!-- -->/
6405 // void
6406 // init_give_me_next_number (void)
6407 // {
6408 // g_assert (give_me_next_number_mutex == NULL);
6409 // give_me_next_number_mutex = g_mutex_new (<!-- -->);
6410 // }
6412 // int
6413 // give_me_next_number (void)
6414 // {
6415 // static int current_number = 0;
6416 // int ret_val;
6418 // g_mutex_lock (give_me_next_number_mutex);
6419 // ret_val = current_number = calc_next_number (current_number);
6420 // g_mutex_unlock (give_me_next_number_mutex);
6422 // return ret_val;
6423 // }
6424 // </programlisting>
6425 // </example>
6427 // #GStaticMutex provides a simpler and safer way of doing this.
6429 // If you want to use a mutex, and your code should also work without
6430 // calling g_thread_init() first, then you cannot use a #GMutex, as
6431 // g_mutex_new() requires that the thread system be initialized. Use a
6432 // #GStaticMutex instead.
6434 // A #GMutex should only be accessed via the following functions.
6436 // <note><para>All of the <function>g_mutex_*</function> functions are
6437 // actually macros. Apart from taking their addresses, you can however
6438 // use them as if they were functions.</para></note>
6439 struct Mutex {
6443 // The #GNode struct represents one node in a
6444 // <link linkend="glib-N-ary-Trees">N-ary Tree</link>. fields
6445 struct Node {
6446 void* data;
6447 Node* next, prev, parent, children;
6450 // Gets the position of the first child of a #GNode
6451 // which contains the given data.
6453 // @data, or -1 if the data is not found
6454 // RETURNS: the index of the child of @node which contains
6455 // <data>: the data to find
6456 int child_index()(void* data) {
6457 return g_node_child_index(&this, data);
6460 // Gets the position of a #GNode with respect to its siblings.
6461 // @child must be a child of @node. The first child is numbered 0,
6462 // the second 1, and so on.
6463 // RETURNS: the position of @child with respect to its siblings
6464 // <child>: a child of @node
6465 int child_position()(Node* child) {
6466 return g_node_child_position(&this, child);
6469 // Unintrospectable method: children_foreach() / g_node_children_foreach()
6470 // Calls a function for each of the children of a #GNode.
6471 // Note that it doesn't descend beneath the child nodes.
6472 // <flags>: which types of children are to be visited, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
6473 // <func>: the function to call for each visited node
6474 // <data>: user data to pass to the function
6475 void children_foreach()(TraverseFlags flags, NodeForeachFunc func, void* data) {
6476 g_node_children_foreach(&this, flags, func, data);
6479 // Unintrospectable method: copy() / g_node_copy()
6480 // Recursively copies a #GNode (but does not deep-copy the data inside the
6481 // nodes, see g_node_copy_deep() if you need that).
6482 // RETURNS: a new #GNode containing the same data pointers
6483 Node* copy()() {
6484 return g_node_copy(&this);
6487 // Unintrospectable method: copy_deep() / g_node_copy_deep()
6488 // VERSION: 2.4
6489 // Recursively copies a #GNode and its data.
6490 // RETURNS: a new #GNode containing copies of the data in @node.
6491 // <copy_func>: the function which is called to copy the data inside each node, or %NULL to use the original data.
6492 // <data>: data to pass to @copy_func
6493 Node* copy_deep()(CopyFunc copy_func, void* data) {
6494 return g_node_copy_deep(&this, copy_func, data);
6497 // Gets the depth of a #GNode.
6499 // If @node is %NULL the depth is 0. The root node has a depth of 1.
6500 // For the children of the root node the depth is 2. And so on.
6501 // RETURNS: the depth of the #GNode
6502 uint depth()() {
6503 return g_node_depth(&this);
6506 // Removes @root and its children from the tree, freeing any memory
6507 // allocated.
6508 void destroy()() {
6509 g_node_destroy(&this);
6512 // Unintrospectable method: find() / g_node_find()
6513 // Finds a #GNode in a tree.
6514 // RETURNS: the found #GNode, or %NULL if the data is not found
6515 // <order>: the order in which nodes are visited - %G_IN_ORDER, %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER
6516 // <flags>: which types of children are to be searched, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
6517 // <data>: the data to find
6518 Node* find()(TraverseType order, TraverseFlags flags, void* data) {
6519 return g_node_find(&this, order, flags, data);
6522 // Unintrospectable method: find_child() / g_node_find_child()
6523 // Finds the first child of a #GNode with the given data.
6524 // RETURNS: the found child #GNode, or %NULL if the data is not found
6525 // <flags>: which types of children are to be searched, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
6526 // <data>: the data to find
6527 Node* find_child()(TraverseFlags flags, void* data) {
6528 return g_node_find_child(&this, flags, data);
6531 // Unintrospectable method: first_sibling() / g_node_first_sibling()
6532 // Gets the first sibling of a #GNode.
6533 // This could possibly be the node itself.
6534 // RETURNS: the first sibling of @node
6535 Node* first_sibling()() {
6536 return g_node_first_sibling(&this);
6539 // Unintrospectable method: get_root() / g_node_get_root()
6540 // Gets the root of a tree.
6541 // RETURNS: the root of the tree
6542 Node* get_root()() {
6543 return g_node_get_root(&this);
6546 // Unintrospectable method: insert() / g_node_insert()
6547 // Inserts a #GNode beneath the parent at the given position.
6548 // RETURNS: the inserted #GNode
6549 // <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
6550 // <node>: the #GNode to insert
6551 Node* insert()(int position, Node* node) {
6552 return g_node_insert(&this, position, node);
6555 // Unintrospectable method: insert_after() / g_node_insert_after()
6556 // Inserts a #GNode beneath the parent after the given sibling.
6557 // RETURNS: the inserted #GNode
6558 // <sibling>: the sibling #GNode to place @node after. If sibling is %NULL, the node is inserted as the first child of @parent.
6559 // <node>: the #GNode to insert
6560 Node* insert_after()(Node* sibling, Node* node) {
6561 return g_node_insert_after(&this, sibling, node);
6564 // Unintrospectable method: insert_before() / g_node_insert_before()
6565 // Inserts a #GNode beneath the parent before the given sibling.
6566 // RETURNS: the inserted #GNode
6567 // <sibling>: the sibling #GNode to place @node before. If sibling is %NULL, the node is inserted as the last child of @parent.
6568 // <node>: the #GNode to insert
6569 Node* insert_before()(Node* sibling, Node* node) {
6570 return g_node_insert_before(&this, sibling, node);
6573 // Returns %TRUE if @node is an ancestor of @descendant.
6574 // This is true if node is the parent of @descendant,
6575 // or if node is the grandparent of @descendant etc.
6576 // RETURNS: %TRUE if @node is an ancestor of @descendant
6577 // <descendant>: a #GNode
6578 int is_ancestor()(Node* descendant) {
6579 return g_node_is_ancestor(&this, descendant);
6582 // Unintrospectable method: last_child() / g_node_last_child()
6583 // Gets the last child of a #GNode.
6584 // RETURNS: the last child of @node, or %NULL if @node has no children
6585 Node* last_child()() {
6586 return g_node_last_child(&this);
6589 // Unintrospectable method: last_sibling() / g_node_last_sibling()
6590 // Gets the last sibling of a #GNode.
6591 // This could possibly be the node itself.
6592 // RETURNS: the last sibling of @node
6593 Node* last_sibling()() {
6594 return g_node_last_sibling(&this);
6597 // Gets the maximum height of all branches beneath a #GNode.
6598 // This is the maximum distance from the #GNode to all leaf nodes.
6600 // If @root is %NULL, 0 is returned. If @root has no children,
6601 // 1 is returned. If @root has children, 2 is returned. And so on.
6602 // RETURNS: the maximum height of the tree beneath @root
6603 uint max_height()() {
6604 return g_node_max_height(&this);
6607 // Gets the number of children of a #GNode.
6608 // RETURNS: the number of children of @node
6609 uint n_children()() {
6610 return g_node_n_children(&this);
6613 // Gets the number of nodes in a tree.
6614 // RETURNS: the number of nodes in the tree
6615 // <flags>: which types of children are to be counted, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
6616 uint n_nodes()(TraverseFlags flags) {
6617 return g_node_n_nodes(&this, flags);
6620 // Unintrospectable method: nth_child() / g_node_nth_child()
6621 // Gets a child of a #GNode, using the given index.
6622 // The first child is at index 0. If the index is
6623 // too big, %NULL is returned.
6624 // RETURNS: the child of @node at index @n
6625 // <n>: the index of the desired child
6626 Node* nth_child()(uint n) {
6627 return g_node_nth_child(&this, n);
6630 // Unintrospectable method: prepend() / g_node_prepend()
6631 // Inserts a #GNode as the first child of the given parent.
6632 // RETURNS: the inserted #GNode
6633 // <node>: the #GNode to insert
6634 Node* prepend()(Node* node) {
6635 return g_node_prepend(&this, node);
6638 // Reverses the order of the children of a #GNode.
6639 // (It doesn't change the order of the grandchildren.)
6640 void reverse_children()() {
6641 g_node_reverse_children(&this);
6644 // Unintrospectable method: traverse() / g_node_traverse()
6645 // Traverses a tree starting at the given root #GNode.
6646 // It calls the given function for each node visited.
6647 // The traversal can be halted at any point by returning %TRUE from @func.
6648 // <order>: the order in which nodes are visited - %G_IN_ORDER, %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER.
6649 // <flags>: which types of children are to be visited, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
6650 // <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.
6651 // <func>: the function to call for each visited #GNode
6652 // <data>: user data to pass to the function
6653 void traverse()(TraverseType order, TraverseFlags flags, int max_depth, NodeTraverseFunc func, void* data) {
6654 g_node_traverse(&this, order, flags, max_depth, func, data);
6656 // Unlinks a #GNode from a tree, resulting in two separate trees.
6657 void unlink()() {
6658 g_node_unlink(&this);
6661 // Unintrospectable function: new() / g_node_new()
6662 // Creates a new #GNode containing the given data.
6663 // Used to create the first node in a tree.
6664 // RETURNS: a new #GNode
6665 // <data>: the data of the new node
6666 static Node* new_()(void* data) {
6667 return g_node_new(data);
6670 // Restores the previous #GAllocator, used when allocating #GNode
6671 // elements.
6673 // Note that this function is not available if GLib has been compiled
6674 // with <option>--disable-mem-pools</option>
6676 // Deprecated:2.10: It does nothing, since #GNode has been converted to
6677 // the <link linkend="glib-Memory-Slices">slice
6678 // allocator</link>
6679 static void pop_allocator()() {
6680 g_node_pop_allocator();
6683 // Sets the allocator to use to allocate #GNode elements. Use
6684 // g_node_pop_allocator() to restore the previous allocator.
6686 // Note that this function is not available if GLib has been compiled
6687 // with <option>--disable-mem-pools</option>
6689 // Deprecated:2.10: It does nothing, since #GNode has been converted to
6690 // the <link linkend="glib-Memory-Slices">slice
6691 // allocator</link>
6692 // <dummy>: the #GAllocator to use when allocating #GNode elements.
6693 static void push_allocator()(void* dummy) {
6694 g_node_push_allocator(dummy);
6699 // Specifies the type of function passed to g_node_children_foreach().
6700 // The function is called with each child node, together with the user
6701 // data passed to g_node_children_foreach().
6702 // <node>: a #GNode.
6703 // <data>: user data passed to g_node_children_foreach().
6704 extern (C) alias void function (Node* node, void* data) NodeForeachFunc;
6707 // Specifies the type of function passed to g_node_traverse(). The
6708 // function is called with each of the nodes visited, together with the
6709 // user data passed to g_node_traverse(). If the function returns
6710 // %TRUE, then the traversal is stopped.
6711 // <node>: a #GNode.
6712 // <data>: user data passed to g_node_traverse().
6713 extern (C) alias int function (Node* node, void* data) NodeTraverseFunc;
6716 // Defines how a Unicode string is transformed in a canonical
6717 // form, standardizing such issues as whether a character with
6718 // an accent is represented as a base character and combining
6719 // accent or as a single precomposed character. Unicode strings
6720 // should generally be normalized before comparing them.
6721 enum NormalizeMode {
6722 DEFAULT = 0,
6723 NFD = 0,
6724 DEFAULT_COMPOSE = 1,
6725 NFC = 1,
6726 ALL = 2,
6727 NFKD = 2,
6728 ALL_COMPOSE = 3,
6729 NFKC = 3
6731 enum OPTION_REMAINING = "";
6733 // A #GOnce struct controls a one-time initialization function. Any
6734 // one-time initialization function must have its own unique #GOnce
6735 // struct.
6736 struct Once /* Version 2.4 */ {
6737 OnceStatus status;
6738 void* retval;
6740 // Unintrospectable method: impl() / g_once_impl()
6741 void* impl()(ThreadFunc func, void* arg) {
6742 return g_once_impl(&this, func, arg);
6745 // VERSION: 2.14
6746 // Function to be called when starting a critical initialization
6747 // section. The argument @value_location must point to a static
6748 // 0-initialized variable that will be set to a value other than 0 at
6749 // the end of the initialization section. In combination with
6750 // g_once_init_leave() and the unique address @value_location, it can
6751 // be ensured that an initialization section will be executed only once
6752 // during a program's life time, and that concurrent threads are
6753 // blocked until initialization completed. To be used in constructs
6754 // like this:
6756 // <informalexample>
6757 // <programlisting>
6758 // static gsize initialization_value = 0;
6760 // if (g_once_init_enter (&amp;initialization_value))
6761 // {
6762 // gsize setup_value = 42; /<!-- -->* initialization code here *<!-- -->/
6764 // g_once_init_leave (&amp;initialization_value, setup_value);
6765 // }
6767 // /<!-- -->* use initialization_value here *<!-- -->/
6768 // </programlisting>
6769 // </informalexample>
6770 // <value_location>: location of a static initializable variable containing 0.
6771 static int init_enter()(size_t* value_location) {
6772 return g_once_init_enter(value_location);
6774 static int init_enter_impl()(size_t* value_location) {
6775 return g_once_init_enter_impl(value_location);
6778 // VERSION: 2.14
6779 // Counterpart to g_once_init_enter(). Expects a location of a static
6780 // 0-initialized initialization variable, and an initialization value
6781 // other than 0. Sets the variable to the initialization value, and
6782 // releases concurrent threads blocking in g_once_init_enter() on this
6783 // initialization variable.
6784 // <value_location>: location of a static initializable variable containing 0.
6785 // <initialization_value>: new non-0 value for *@value_location.
6786 static void init_leave()(size_t* value_location, size_t initialization_value) {
6787 g_once_init_leave(value_location, initialization_value);
6792 // The possible statuses of a one-time initialization function
6793 // controlled by a #GOnce struct.
6794 enum OnceStatus /* Version 2.4 */ {
6795 NOTCALLED = 0,
6796 PROGRESS = 1,
6797 READY = 2
6800 // The #GOptionArg enum values determine which type of extra argument the
6801 // options expect to find. If an option expects an extra argument, it
6802 // can be specified in several ways; with a short option:
6803 // <option>-x arg</option>, with a long option: <option>--name arg</option>
6804 // or combined in a single argument: <option>--name=arg</option>.
6805 enum OptionArg {
6806 NONE = 0,
6807 STRING = 1,
6808 INT = 2,
6809 CALLBACK = 3,
6810 FILENAME = 4,
6811 STRING_ARRAY = 5,
6812 FILENAME_ARRAY = 6,
6813 DOUBLE = 7,
6814 INT64 = 8
6817 // The type of function to be passed as callback for %G_OPTION_ARG_CALLBACK
6818 // options.
6820 // occurred, in which case @error should be set with g_set_error()
6821 // RETURNS: %TRUE if the option was successfully parsed, %FALSE if an error
6822 // <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.
6823 // <value>: The value to be parsed.
6824 // <data>: User data added to the #GOptionGroup containing the option when it was created with g_option_group_new()
6825 extern (C) alias int function (char* option_name, char* value, void* data, GLib2.Error** error=null) OptionArgFunc;
6828 // A <structname>GOptionContext</structname> struct defines which options
6829 // are accepted by the commandline option parser. The struct has only private
6830 // fields and should not be directly accessed.
6831 struct OptionContext {
6833 // VERSION: 2.6
6834 // Adds a #GOptionGroup to the @context, so that parsing with @context
6835 // will recognize the options in the group. Note that the group will
6836 // be freed together with the context when g_option_context_free() is
6837 // called, so you must not free the group yourself after adding it
6838 // to a context.
6839 // <group>: the group to add
6840 void add_group()(OptionGroup* group) {
6841 g_option_context_add_group(&this, group);
6844 // VERSION: 2.6
6845 // A convenience function which creates a main group if it doesn't
6846 // exist, adds the @entries to it and sets the translation domain.
6847 // <entries>: a %NULL-terminated array of #GOptionEntry<!-- -->s
6848 // <translation_domain>: a translation domain to use for translating the <option>--help</option> output for the options in @entries with gettext(), or %NULL
6849 void add_main_entries()(OptionEntry* entries, char* translation_domain) {
6850 g_option_context_add_main_entries(&this, entries, translation_domain);
6853 // VERSION: 2.6
6854 // Frees context and all the groups which have been
6855 // added to it.
6857 // Please note that parsed arguments need to be freed separately (see
6858 // #GOptionEntry).
6859 void free()() {
6860 g_option_context_free(&this);
6863 // VERSION: 2.12
6864 // Returns the description. See g_option_context_set_description().
6865 // RETURNS: the description
6866 char* get_description()() {
6867 return g_option_context_get_description(&this);
6870 // VERSION: 2.14
6871 // Returns a formatted, translated help text for the given context.
6872 // To obtain the text produced by <option>--help</option>, call
6873 // <literal>g_option_context_get_help (context, TRUE, NULL)</literal>.
6874 // To obtain the text produced by <option>--help-all</option>, call
6875 // <literal>g_option_context_get_help (context, FALSE, NULL)</literal>.
6876 // To obtain the help text for an option group, call
6877 // <literal>g_option_context_get_help (context, FALSE, group)</literal>.
6878 // RETURNS: A newly allocated string containing the help text
6879 // <main_help>: if %TRUE, only include the main group
6880 // <group>: the #GOptionGroup to create help for, or %NULL
6881 char* /*new*/ get_help()(int main_help, OptionGroup* group) {
6882 return g_option_context_get_help(&this, main_help, group);
6885 // VERSION: 2.6
6886 // Returns whether automatic <option>--help</option> generation
6887 // is turned on for @context. See g_option_context_set_help_enabled().
6888 // RETURNS: %TRUE if automatic help generation is turned on.
6889 int get_help_enabled()() {
6890 return g_option_context_get_help_enabled(&this);
6893 // VERSION: 2.6
6894 // Returns whether unknown options are ignored or not. See
6895 // g_option_context_set_ignore_unknown_options().
6896 // RETURNS: %TRUE if unknown options are ignored.
6897 int get_ignore_unknown_options()() {
6898 return g_option_context_get_ignore_unknown_options(&this);
6901 // Unintrospectable method: get_main_group() / g_option_context_get_main_group()
6902 // VERSION: 2.6
6903 // Returns a pointer to the main group of @context.
6905 // have a main group. Note that group belongs to @context and should
6906 // not be modified or freed.
6907 // RETURNS: the main group of @context, or %NULL if @context doesn't
6908 OptionGroup* get_main_group()() {
6909 return g_option_context_get_main_group(&this);
6912 // VERSION: 2.12
6913 // Returns the summary. See g_option_context_set_summary().
6914 // RETURNS: the summary
6915 char* get_summary()() {
6916 return g_option_context_get_summary(&this);
6919 // VERSION: 2.6
6920 // Parses the command line arguments, recognizing options
6921 // which have been added to @context. A side-effect of
6922 // calling this function is that g_set_prgname() will be
6923 // called.
6925 // If the parsing is successful, any parsed arguments are
6926 // removed from the array and @argc and @argv are updated
6927 // accordingly. A '--' option is stripped from @argv
6928 // unless there are unparsed options before and after it,
6929 // or some of the options after it start with '-'. In case
6930 // of an error, @argc and @argv are left unmodified.
6932 // If automatic <option>--help</option> support is enabled
6933 // (see g_option_context_set_help_enabled()), and the
6934 // @argv array contains one of the recognized help options,
6935 // this function will produce help output to stdout and
6936 // call <literal>exit (0)</literal>.
6938 // Note that function depends on the
6939 // <link linkend="setlocale">current locale</link> for
6940 // automatic character set conversion of string and filename
6941 // arguments.
6943 // %FALSE if an error occurred
6944 // RETURNS: %TRUE if the parsing was successful,
6945 // <argc>: a pointer to the number of command line arguments
6946 // <argv>: a pointer to the array of command line arguments
6947 int parse()(/*inout*/ int* argc, /*inout*/ char*** argv, GLib2.Error** error=null) {
6948 return g_option_context_parse(&this, argc, argv, error);
6951 // VERSION: 2.12
6952 // Adds a string to be displayed in <option>--help</option> output
6953 // after the list of options. This text often includes a bug reporting
6954 // address.
6956 // Note that the summary is translated (see
6957 // g_option_context_set_translate_func()).
6958 // <description>: a string to be shown in <option>--help</option> output after the list of options, or %NULL
6959 void set_description()(char* description) {
6960 g_option_context_set_description(&this, description);
6963 // VERSION: 2.6
6964 // Enables or disables automatic generation of <option>--help</option>
6965 // output. By default, g_option_context_parse() recognizes
6966 // <option>--help</option>, <option>-h</option>,
6967 // <option>-?</option>, <option>--help-all</option>
6968 // and <option>--help-</option><replaceable>groupname</replaceable> and creates
6969 // suitable output to stdout.
6970 // <help_enabled>: %TRUE to enable <option>--help</option>, %FALSE to disable it
6971 void set_help_enabled()(int help_enabled) {
6972 g_option_context_set_help_enabled(&this, help_enabled);
6975 // VERSION: 2.6
6976 // Sets whether to ignore unknown options or not. If an argument is
6977 // ignored, it is left in the @argv array after parsing. By default,
6978 // g_option_context_parse() treats unknown options as error.
6980 // This setting does not affect non-option arguments (i.e. arguments
6981 // which don't start with a dash). But note that GOption cannot reliably
6982 // determine whether a non-option belongs to a preceding unknown option.
6983 // <ignore_unknown>: %TRUE to ignore unknown options, %FALSE to produce an error when unknown options are met
6984 void set_ignore_unknown_options()(int ignore_unknown) {
6985 g_option_context_set_ignore_unknown_options(&this, ignore_unknown);
6988 // VERSION: 2.6
6989 // Sets a #GOptionGroup as main group of the @context.
6990 // This has the same effect as calling g_option_context_add_group(),
6991 // the only difference is that the options in the main group are
6992 // treated differently when generating <option>--help</option> output.
6993 // <group>: the group to set as main group
6994 void set_main_group()(OptionGroup* group) {
6995 g_option_context_set_main_group(&this, group);
6998 // VERSION: 2.12
6999 // Adds a string to be displayed in <option>--help</option> output
7000 // before the list of options. This is typically a summary of the
7001 // program functionality.
7003 // Note that the summary is translated (see
7004 // g_option_context_set_translate_func() and
7005 // g_option_context_set_translation_domain()).
7006 // <summary>: a string to be shown in <option>--help</option> output before the list of options, or %NULL
7007 void set_summary()(char* summary) {
7008 g_option_context_set_summary(&this, summary);
7011 // VERSION: 2.12
7012 // Sets the function which is used to translate the contexts
7013 // user-visible strings, for <option>--help</option> output.
7014 // If @func is %NULL, strings are not translated.
7016 // Note that option groups have their own translation functions,
7017 // this function only affects the @parameter_string (see g_option_context_new()),
7018 // the summary (see g_option_context_set_summary()) and the description
7019 // (see g_option_context_set_description()).
7021 // If you are using gettext(), you only need to set the translation
7022 // domain, see g_option_context_set_translation_domain().
7023 // <func>: the #GTranslateFunc, or %NULL
7024 // <data>: user data to pass to @func, or %NULL
7025 // <destroy_notify>: a function which gets called to free @data, or %NULL
7026 void set_translate_func()(TranslateFunc func, void* data, DestroyNotify destroy_notify) {
7027 g_option_context_set_translate_func(&this, func, data, destroy_notify);
7030 // VERSION: 2.12
7031 // A convenience function to use gettext() for translating
7032 // user-visible strings.
7033 // <domain>: the domain to use
7034 void set_translation_domain()(char* domain) {
7035 g_option_context_set_translation_domain(&this, domain);
7038 // Unintrospectable function: new() / g_option_context_new()
7039 // VERSION: 2.6
7040 // Creates a new option context.
7042 // The @parameter_string can serve multiple purposes. It can be used
7043 // to add descriptions for "rest" arguments, which are not parsed by
7044 // the #GOptionContext, typically something like "FILES" or
7045 // "FILE1 FILE2...". If you are using #G_OPTION_REMAINING for
7046 // collecting "rest" arguments, GLib handles this automatically by
7047 // using the @arg_description of the corresponding #GOptionEntry in
7048 // the usage summary.
7050 // Another usage is to give a short summary of the program
7051 // functionality, like " - frob the strings", which will be displayed
7052 // in the same line as the usage. For a longer description of the
7053 // program functionality that should be displayed as a paragraph
7054 // below the usage line, use g_option_context_set_summary().
7056 // Note that the @parameter_string is translated using the
7057 // function set with g_option_context_set_translate_func(), so
7058 // it should normally be passed untranslated.
7060 // freed with g_option_context_free() after use.
7061 // RETURNS: a newly created #GOptionContext, which must be
7062 // <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>
7063 static OptionContext* new_()(char* parameter_string) {
7064 return g_option_context_new(parameter_string);
7069 // A <structname>GOptionEntry</structname> defines a single option.
7070 // To have an effect, they must be added to a #GOptionGroup with
7071 // g_option_context_add_main_entries() or g_option_group_add_entries().
7072 struct OptionEntry {
7073 char* long_name;
7074 char short_name;
7075 int flags;
7076 OptionArg arg;
7077 void* arg_data;
7078 char* description, arg_description;
7081 // Error codes returned by option parsing.
7082 enum OptionError {
7083 UNKNOWN_OPTION = 0,
7084 BAD_VALUE = 1,
7085 FAILED = 2
7088 // The type of function to be used as callback when a parse error occurs.
7089 // <context>: The active #GOptionContext
7090 // <group>: The group to which the function belongs
7091 // <data>: User data added to the #GOptionGroup containing the option when it was created with g_option_group_new()
7092 extern (C) alias void function (OptionContext* context, OptionGroup* group, void* data, GLib2.Error** error=null) OptionErrorFunc;
7094 // Flags which modify individual options.
7095 enum OptionFlags {
7096 HIDDEN = 1,
7097 IN_MAIN = 2,
7098 REVERSE = 4,
7099 NO_ARG = 8,
7100 FILENAME = 16,
7101 OPTIONAL_ARG = 32,
7102 NOALIAS = 64
7105 // A <structname>GOptionGroup</structname> struct defines the options in a single
7106 // group. The struct has only private fields and should not be directly accessed.
7108 // All options in a group share the same translation function. Libraries which
7109 // need to parse commandline options are expected to provide a function for
7110 // getting a <structname>GOptionGroup</structname> holding their options, which
7111 // the application can then add to its #GOptionContext.
7112 struct OptionGroup {
7114 // VERSION: 2.6
7115 // Adds the options specified in @entries to @group.
7116 // <entries>: a %NULL-terminated array of #GOptionEntry<!-- -->s
7117 void add_entries()(OptionEntry* entries) {
7118 g_option_group_add_entries(&this, entries);
7121 // VERSION: 2.6
7122 // Frees a #GOptionGroup. Note that you must <emphasis>not</emphasis>
7123 // free groups which have been added to a #GOptionContext.
7124 void free()() {
7125 g_option_group_free(&this);
7128 // Unintrospectable method: set_error_hook() / g_option_group_set_error_hook()
7129 // VERSION: 2.6
7130 // Associates a function with @group which will be called
7131 // from g_option_context_parse() when an error occurs.
7133 // Note that the user data to be passed to @error_func can be
7134 // specified when constructing the group with g_option_group_new().
7135 // <error_func>: a function to call when an error occurs
7136 void set_error_hook()(OptionErrorFunc error_func) {
7137 g_option_group_set_error_hook(&this, error_func);
7140 // Unintrospectable method: set_parse_hooks() / g_option_group_set_parse_hooks()
7141 // VERSION: 2.6
7142 // Associates two functions with @group which will be called
7143 // from g_option_context_parse() before the first option is parsed
7144 // and after the last option has been parsed, respectively.
7146 // Note that the user data to be passed to @pre_parse_func and
7147 // @post_parse_func can be specified when constructing the group
7148 // with g_option_group_new().
7149 // <pre_parse_func>: a function to call before parsing, or %NULL
7150 // <post_parse_func>: a function to call after parsing, or %NULL
7151 void set_parse_hooks()(OptionParseFunc pre_parse_func, OptionParseFunc post_parse_func) {
7152 g_option_group_set_parse_hooks(&this, pre_parse_func, post_parse_func);
7155 // VERSION: 2.6
7156 // Sets the function which is used to translate user-visible
7157 // strings, for <option>--help</option> output. Different
7158 // groups can use different #GTranslateFunc<!-- -->s. If @func
7159 // is %NULL, strings are not translated.
7161 // If you are using gettext(), you only need to set the translation
7162 // domain, see g_option_group_set_translation_domain().
7163 // <func>: the #GTranslateFunc, or %NULL
7164 // <data>: user data to pass to @func, or %NULL
7165 // <destroy_notify>: a function which gets called to free @data, or %NULL
7166 void set_translate_func()(TranslateFunc func, void* data, DestroyNotify destroy_notify) {
7167 g_option_group_set_translate_func(&this, func, data, destroy_notify);
7170 // VERSION: 2.6
7171 // A convenience function to use gettext() for translating
7172 // user-visible strings.
7173 // <domain>: the domain to use
7174 void set_translation_domain()(char* domain) {
7175 g_option_group_set_translation_domain(&this, domain);
7178 // Unintrospectable function: new() / g_option_group_new()
7179 // VERSION: 2.6
7180 // Creates a new #GOptionGroup.
7182 // to a #GOptionContext or freed with g_option_group_free().
7183 // RETURNS: a newly created option group. It should be added
7184 // <name>: the name for the option group, this is used to provide help for the options in this group with <option>--help-</option>@name
7185 // <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
7186 // <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
7187 // <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
7188 // <destroy>: a function that will be called to free @user_data, or %NULL
7189 static OptionGroup* new_()(char* name, char* description, char* help_description, void* user_data, DestroyNotify destroy) {
7190 return g_option_group_new(name, description, help_description, user_data, destroy);
7195 // The type of function that can be called before and after parsing.
7197 // occurred, in which case @error should be set with g_set_error()
7198 // RETURNS: %TRUE if the function completed successfully, %FALSE if an error
7199 // <context>: The active #GOptionContext
7200 // <group>: The group to which the function belongs
7201 // <data>: User data added to the #GOptionGroup containing the option when it was created with g_option_group_new()
7202 extern (C) alias int function (OptionContext* context, OptionGroup* group, void* data, GLib2.Error** error=null) OptionParseFunc;
7204 enum int PDP_ENDIAN = 3412;
7205 enum double PI = 3.141593;
7206 enum double PI_2 = 1.570796;
7207 enum double PI_4 = 0.785398;
7208 enum POLLFD_FORMAT = "%#I64x";
7209 enum int PRIORITY_DEFAULT = 0;
7210 enum int PRIORITY_DEFAULT_IDLE = 200;
7211 enum int PRIORITY_HIGH = -100;
7212 enum int PRIORITY_HIGH_IDLE = 100;
7213 enum int PRIORITY_LOW = 300;
7215 // A <structname>GPatternSpec</structname> is the 'compiled' form of a
7216 // pattern. This structure is opaque and its fields cannot be accessed
7217 // directly.
7218 struct PatternSpec {
7220 // Compares two compiled pattern specs and returns whether they will
7221 // match the same set of strings.
7222 // <pspec2>: another #GPatternSpec
7223 int equal()(PatternSpec* pspec2) {
7224 return g_pattern_spec_equal(&this, pspec2);
7226 // Frees the memory allocated for the #GPatternSpec.
7227 void free()() {
7228 g_pattern_spec_free(&this);
7231 // Unintrospectable function: new() / g_pattern_spec_new()
7232 // Compiles a pattern to a #GPatternSpec.
7233 // <pattern>: a zero-terminated UTF-8 encoded string
7234 static PatternSpec* new_()(char* pattern) {
7235 return g_pattern_spec_new(pattern);
7239 struct PollFD {
7240 int fd;
7241 ushort events, revents;
7245 // Specifies the type of function passed to g_main_context_set_poll_func().
7246 // The semantics of the function should match those of the poll() system call.
7248 // reported, or -1 if an error occurred.
7249 // RETURNS: the number of #GPollFD elements which have events or errors
7250 // <ufds>: an array of #GPollFD elements
7251 // <nfsd>: the number of elements in @ufds
7252 // <timeout_>: the maximum time to wait for an event of the file descriptors. A negative value indicates an infinite timeout.
7253 extern (C) alias int function (PollFD* ufds, uint nfsd, int timeout_) PollFunc;
7256 // Specifies the type of the print handler functions.
7257 // These are called with the complete formatted string to output.
7258 // <string>: the message to output
7259 extern (C) alias void function (char* string_) PrintFunc;
7262 // <note><para>
7263 // #GStaticPrivate is a better choice for most uses.
7264 // </para></note>
7266 // The #GPrivate struct is an opaque data structure to represent a
7267 // thread private data key. Threads can thereby obtain and set a
7268 // pointer which is private to the current thread. Take our
7269 // <function>give_me_next_number(<!-- -->)</function> example from
7270 // above. Suppose we don't want <literal>current_number</literal> to be
7271 // shared between the threads, but instead to be private to each thread.
7272 // This can be done as follows:
7274 // <example>
7275 // <title>Using GPrivate for per-thread data</title>
7276 // <programlisting>
7277 // GPrivate* current_number_key = NULL; /<!-- -->* Must be initialized somewhere
7278 // with g_private_new (g_free); *<!-- -->/
7280 // int
7281 // give_me_next_number (void)
7282 // {
7283 // int *current_number = g_private_get (current_number_key);
7285 // if (!current_number)
7286 // {
7287 // current_number = g_new (int, 1);
7288 // *current_number = 0;
7289 // g_private_set (current_number_key, current_number);
7290 // }
7292 // *current_number = calc_next_number (*current_number);
7294 // return *current_number;
7295 // }
7296 // </programlisting>
7297 // </example>
7299 // Here the pointer belonging to the key
7300 // <literal>current_number_key</literal> is read. If it is %NULL, it has
7301 // not been set yet. Then get memory for an integer value, assign this
7302 // memory to the pointer and write the pointer back. Now we have an
7303 // integer value that is private to the current thread.
7305 // The #GPrivate struct should only be accessed via the following
7306 // functions.
7308 // <note><para>All of the <function>g_private_*</function> functions are
7309 // actually macros. Apart from taking their addresses, you can however
7310 // use them as if they were functions.</para></note>
7311 struct Private {
7314 // Contains the public fields of a pointer array.
7315 struct PtrArray {
7316 void** pdata;
7317 uint len;
7320 // Adds a pointer to the end of the pointer array. The array will grow
7321 // in size automatically if necessary.
7322 // <array>: a #GPtrArray.
7323 // <data>: the pointer to add.
7324 static void add()(PtrArray* array, void* data) {
7325 g_ptr_array_add(array, data);
7328 // Unintrospectable function: foreach() / g_ptr_array_foreach()
7329 // VERSION: 2.4
7330 // Calls a function for each element of a #GPtrArray.
7331 // <array>: a #GPtrArray
7332 // <func>: the function to call for each array element
7333 // <user_data>: user data to pass to the function
7334 static void foreach_()(PtrArray* array, Func func, void* user_data) {
7335 g_ptr_array_foreach(array, func, user_data);
7338 // Unintrospectable function: free() / g_ptr_array_free()
7339 // Frees the memory allocated for the #GPtrArray. If @free_seg is %TRUE
7340 // it frees the memory block holding the elements as well. Pass %FALSE
7341 // if you want to free the #GPtrArray wrapper but preserve the
7342 // underlying array for use elsewhere. If the reference count of @array
7343 // is greater than one, the #GPtrArray wrapper is preserved but the
7344 // size of @array will be set to zero.
7346 // <note><para>If array contents point to dynamically-allocated
7347 // memory, they should be freed separately if @free_seg is %TRUE and no
7348 // #GDestroyNotify function has been set for @array.</para></note>
7349 // <array>: a #GPtrArray.
7350 // <free_seg>: if %TRUE the actual pointer array is freed as well.
7351 static void** free()(PtrArray* array, int free_seg) {
7352 return g_ptr_array_free(array, free_seg);
7355 // Unintrospectable function: new() / g_ptr_array_new()
7356 // Creates a new #GPtrArray with a reference count of 1.
7357 static PtrArray* new_()() {
7358 return g_ptr_array_new();
7361 // Unintrospectable function: new_full() / g_ptr_array_new_full()
7362 // VERSION: 2.30
7363 // Creates a new #GPtrArray with @reserved_size pointers preallocated
7364 // and a reference count of 1. This avoids frequent reallocation, if
7365 // you are going to add many pointers to the array. Note however that
7366 // the size of the array is still 0. It also set @element_free_func
7367 // for freeing each element when the array is destroyed either via
7368 // g_ptr_array_unref(), when g_ptr_array_free() is called with @free_segment
7369 // set to %TRUE or when removing elements.
7370 // RETURNS: A new #GPtrArray.
7371 // <reserved_size>: number of pointers preallocated.
7372 // <element_free_func>: A function to free elements with destroy @array or %NULL.
7373 static PtrArray* new_full()(uint reserved_size, DestroyNotify element_free_func) {
7374 return g_ptr_array_new_full(reserved_size, element_free_func);
7377 // Unintrospectable function: new_with_free_func() / g_ptr_array_new_with_free_func()
7378 // VERSION: 2.22
7379 // Creates a new #GPtrArray with a reference count of 1 and use @element_free_func
7380 // for freeing each element when the array is destroyed either via
7381 // g_ptr_array_unref(), when g_ptr_array_free() is called with @free_segment
7382 // set to %TRUE or when removing elements.
7383 // RETURNS: A new #GPtrArray.
7384 // <element_free_func>: A function to free elements with destroy @array or %NULL.
7385 static PtrArray* new_with_free_func()(DestroyNotify element_free_func) {
7386 return g_ptr_array_new_with_free_func(element_free_func);
7389 // Unintrospectable function: ref() / g_ptr_array_ref()
7390 // VERSION: 2.22
7391 // Atomically increments the reference count of @array by one. This
7392 // function is MT-safe and may be called from any thread.
7393 // RETURNS: The passed in #GPtrArray.
7394 // <array>: A #GArray.
7395 static PtrArray* ref_()(PtrArray* array) {
7396 return g_ptr_array_ref(array);
7399 // Removes the first occurrence of the given pointer from the pointer
7400 // array. The following elements are moved down one place. If @array
7401 // has a non-%NULL #GDestroyNotify function it is called for the
7402 // removed element.
7404 // It returns %TRUE if the pointer was removed, or %FALSE if the
7405 // pointer was not found.
7406 // <array>: a #GPtrArray.
7407 // <data>: the pointer to remove.
7408 static int remove()(PtrArray* array, void* data) {
7409 return g_ptr_array_remove(array, data);
7412 // Removes the first occurrence of the given pointer from the pointer
7413 // array. The last element in the array is used to fill in the space,
7414 // so this function does not preserve the order of the array. But it is
7415 // faster than g_ptr_array_remove(). If @array has a non-%NULL
7416 // #GDestroyNotify function it is called for the removed element.
7418 // It returns %TRUE if the pointer was removed, or %FALSE if the
7419 // pointer was not found.
7420 // <array>: a #GPtrArray.
7421 // <data>: the pointer to remove.
7422 static int remove_fast()(PtrArray* array, void* data) {
7423 return g_ptr_array_remove_fast(array, data);
7426 // Unintrospectable function: remove_index() / g_ptr_array_remove_index()
7427 // Removes the pointer at the given index from the pointer array. The
7428 // following elements are moved down one place. If @array has a
7429 // non-%NULL #GDestroyNotify function it is called for the removed
7430 // element.
7431 // <array>: a #GPtrArray.
7432 // <index_>: the index of the pointer to remove.
7433 static void* remove_index()(PtrArray* array, uint index_) {
7434 return g_ptr_array_remove_index(array, index_);
7437 // Unintrospectable function: remove_index_fast() / g_ptr_array_remove_index_fast()
7438 // Removes the pointer at the given index from the pointer array. The
7439 // last element in the array is used to fill in the space, so this
7440 // function does not preserve the order of the array. But it is faster
7441 // than g_ptr_array_remove_index(). If @array has a non-%NULL
7442 // #GDestroyNotify function it is called for the removed element.
7443 // <array>: a #GPtrArray.
7444 // <index_>: the index of the pointer to remove.
7445 static void* remove_index_fast()(PtrArray* array, uint index_) {
7446 return g_ptr_array_remove_index_fast(array, index_);
7449 // VERSION: 2.4
7450 // Removes the given number of pointers starting at the given index
7451 // from a #GPtrArray. The following elements are moved to close the
7452 // gap. If @array has a non-%NULL #GDestroyNotify function it is called
7453 // for the removed elements.
7454 // <array>: a @GPtrArray.
7455 // <index_>: the index of the first pointer to remove.
7456 // <length>: the number of pointers to remove.
7457 static void remove_range()(PtrArray* array, uint index_, uint length) {
7458 g_ptr_array_remove_range(array, index_, length);
7461 // VERSION: 2.22
7462 // Sets a function for freeing each element when @array is destroyed
7463 // either via g_ptr_array_unref(), when g_ptr_array_free() is called
7464 // with @free_segment set to %TRUE or when removing elements.
7465 // <array>: A #GPtrArray.
7466 // <element_free_func>: A function to free elements with destroy @array or %NULL.
7467 static void set_free_func()(PtrArray* array, DestroyNotify element_free_func) {
7468 g_ptr_array_set_free_func(array, element_free_func);
7471 // Sets the size of the array. When making the array larger,
7472 // newly-added elements will be set to %NULL. When making it smaller,
7473 // if @array has a non-%NULL #GDestroyNotify function then it will be
7474 // called for the removed elements.
7475 // <array>: a #GPtrArray.
7476 // <length>: the new length of the pointer array.
7477 static void set_size()(PtrArray* array, int length) {
7478 g_ptr_array_set_size(array, length);
7481 // Unintrospectable function: sized_new() / g_ptr_array_sized_new()
7482 // Creates a new #GPtrArray with @reserved_size pointers preallocated
7483 // and a reference count of 1. This avoids frequent reallocation, if
7484 // you are going to add many pointers to the array. Note however that
7485 // the size of the array is still 0.
7486 // <reserved_size>: number of pointers preallocated.
7487 static PtrArray* sized_new()(uint reserved_size) {
7488 return g_ptr_array_sized_new(reserved_size);
7491 // Unintrospectable function: sort() / g_ptr_array_sort()
7492 // Sorts the array, using @compare_func which should be a qsort()-style
7493 // comparison function (returns less than zero for first arg is less
7494 // than second arg, zero for equal, greater than zero if irst arg is
7495 // greater than second arg).
7497 // If two array elements compare equal, their order in the sorted array
7498 // is undefined. If you want equal elements to keep their order &#8211; i.e.
7499 // you want a stable sort &#8211; you can write a comparison function that,
7500 // if two elements would otherwise compare equal, compares them by
7501 // their addresses.
7503 // <note><para>The comparison function for g_ptr_array_sort() doesn't
7504 // take the pointers from the array as arguments, it takes pointers to
7505 // the pointers in the array.</para></note>
7506 // <array>: a #GPtrArray.
7507 // <compare_func>: comparison function.
7508 static void sort()(PtrArray* array, CompareFunc compare_func) {
7509 g_ptr_array_sort(array, compare_func);
7512 // Unintrospectable function: sort_with_data() / g_ptr_array_sort_with_data()
7513 // Like g_ptr_array_sort(), but the comparison function has an extra
7514 // user data argument.
7516 // <note><para>The comparison function for g_ptr_array_sort_with_data()
7517 // doesn't take the pointers from the array as arguments, it takes
7518 // pointers to the pointers in the array.</para></note>
7519 // <array>: a #GPtrArray.
7520 // <compare_func>: comparison function.
7521 // <user_data>: data to pass to @compare_func.
7522 static void sort_with_data()(PtrArray* array, CompareDataFunc compare_func, void* user_data) {
7523 g_ptr_array_sort_with_data(array, compare_func, user_data);
7526 // VERSION: 2.22
7527 // Atomically decrements the reference count of @array by one. If the
7528 // reference count drops to 0, the effect is the same as calling
7529 // g_ptr_array_free() with @free_segment set to %TRUE. This function
7530 // is MT-safe and may be called from any thread.
7531 // <array>: A #GPtrArray.
7532 static void unref()(PtrArray* array) {
7533 g_ptr_array_unref(array);
7538 // Contains the public fields of a
7539 // <link linkend="glib-Double-ended-Queues">Queue</link>.
7540 struct Queue {
7541 GLib2.List* head, tail;
7542 uint length;
7545 // VERSION: 2.14
7546 // Removes all the elements in @queue. If queue elements contain
7547 // dynamically-allocated memory, they should be freed first.
7548 void clear()() {
7549 g_queue_clear(&this);
7552 // Unintrospectable method: copy() / g_queue_copy()
7553 // VERSION: 2.4
7554 // Copies a @queue. Note that is a shallow copy. If the elements in the
7555 // queue consist of pointers to data, the pointers are copied, but the
7556 // actual data is not.
7557 // RETURNS: A copy of @queue
7558 Queue* copy()() {
7559 return g_queue_copy(&this);
7562 // Unintrospectable method: delete_link() / g_queue_delete_link()
7563 // VERSION: 2.4
7564 // Removes @link_ from @queue and frees it.
7566 // @link_ must be part of @queue.
7567 // <link_>: a #GList link that <emphasis>must</emphasis> be part of @queue
7568 void delete_link()(GLib2.List* link_) {
7569 g_queue_delete_link(&this, link_);
7572 // Unintrospectable method: find() / g_queue_find()
7573 // VERSION: 2.4
7574 // Finds the first link in @queue which contains @data.
7575 // RETURNS: The first link in @queue which contains @data.
7576 // <data>: data to find
7577 GLib2.List* find()(const(void)* data) {
7578 return g_queue_find(&this, data);
7581 // Unintrospectable method: find_custom() / g_queue_find_custom()
7582 // VERSION: 2.4
7583 // Finds an element in a #GQueue, using a supplied function to find the
7584 // desired element. It iterates over the queue, calling the given function
7585 // which should return 0 when the desired element is found. The function
7586 // takes two gconstpointer arguments, the #GQueue element's data as the
7587 // first argument and the given user data as the second argument.
7588 // RETURNS: The found link, or %NULL if it wasn't found
7589 // <data>: user data passed to @func
7590 // <func>: a #GCompareFunc to call for each element. It should return 0 when the desired element is found
7591 GLib2.List* find_custom()(const(void)* data, CompareFunc func) {
7592 return g_queue_find_custom(&this, data, func);
7595 // Unintrospectable method: foreach() / g_queue_foreach()
7596 // VERSION: 2.4
7597 // Calls @func for each element in the queue passing @user_data to the
7598 // function.
7599 // <func>: the function to call for each element's data
7600 // <user_data>: user data to pass to @func
7601 void foreach_()(Func func, void* user_data) {
7602 g_queue_foreach(&this, func, user_data);
7605 // Frees the memory allocated for the #GQueue. Only call this function if
7606 // @queue was created with g_queue_new(). If queue elements contain
7607 // dynamically-allocated memory, they should be freed first.
7608 void free()() {
7609 g_queue_free(&this);
7612 // VERSION: 2.4
7613 // Returns the number of items in @queue.
7614 // RETURNS: The number of items in @queue.
7615 uint get_length()() {
7616 return g_queue_get_length(&this);
7619 // VERSION: 2.4
7620 // Returns the position of the first element in @queue which contains @data.
7621 // RETURNS: The position of the first element in @queue which contains @data, or -1 if no element in @queue contains @data.
7622 // <data>: the data to find.
7623 int index()(const(void)* data) {
7624 return g_queue_index(&this, data);
7627 // VERSION: 2.14
7628 // A statically-allocated #GQueue must be initialized with this function
7629 // before it can be used. Alternatively you can initialize it with
7630 // #G_QUEUE_INIT. It is not necessary to initialize queues created with
7631 // g_queue_new().
7632 void init()() {
7633 g_queue_init(&this);
7636 // Unintrospectable method: insert_after() / g_queue_insert_after()
7637 // VERSION: 2.4
7638 // Inserts @data into @queue after @sibling
7640 // @sibling must be part of @queue
7641 // <sibling>: a #GList link that <emphasis>must</emphasis> be part of @queue
7642 // <data>: the data to insert
7643 void insert_after()(GLib2.List* sibling, void* data) {
7644 g_queue_insert_after(&this, sibling, data);
7647 // Unintrospectable method: insert_before() / g_queue_insert_before()
7648 // VERSION: 2.4
7649 // Inserts @data into @queue before @sibling.
7651 // @sibling must be part of @queue.
7652 // <sibling>: a #GList link that <emphasis>must</emphasis> be part of @queue
7653 // <data>: the data to insert
7654 void insert_before()(GLib2.List* sibling, void* data) {
7655 g_queue_insert_before(&this, sibling, data);
7658 // Unintrospectable method: insert_sorted() / g_queue_insert_sorted()
7659 // VERSION: 2.4
7660 // Inserts @data into @queue using @func to determine the new position.
7661 // <data>: the data to insert
7662 // <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.
7663 // <user_data>: user data passed to @func.
7664 void insert_sorted()(void* data, CompareDataFunc func, void* user_data) {
7665 g_queue_insert_sorted(&this, data, func, user_data);
7668 // Returns %TRUE if the queue is empty.
7669 // RETURNS: %TRUE if the queue is empty.
7670 int is_empty()() {
7671 return g_queue_is_empty(&this);
7674 // Unintrospectable method: link_index() / g_queue_link_index()
7675 // VERSION: 2.4
7676 // Returns the position of @link_ in @queue.
7678 // not part of @queue
7679 // RETURNS: The position of @link_, or -1 if the link is
7680 // <link_>: A #GList link
7681 int link_index()(GLib2.List* link_) {
7682 return g_queue_link_index(&this, link_);
7685 // Unintrospectable method: peek_head() / g_queue_peek_head()
7686 // Returns the first element of the queue.
7688 // is empty.
7689 // RETURNS: the data of the first element in the queue, or %NULL if the queue
7690 void* peek_head()() {
7691 return g_queue_peek_head(&this);
7694 // Unintrospectable method: peek_head_link() / g_queue_peek_head_link()
7695 // VERSION: 2.4
7696 // Returns the first link in @queue
7697 // RETURNS: the first link in @queue, or %NULL if @queue is empty
7698 GLib2.List* peek_head_link()() {
7699 return g_queue_peek_head_link(&this);
7702 // Unintrospectable method: peek_nth() / g_queue_peek_nth()
7703 // VERSION: 2.4
7704 // Returns the @n'th element of @queue.
7706 // off the end of @queue.
7707 // RETURNS: The data for the @n'th element of @queue, or %NULL if @n is
7708 // <n>: the position of the element.
7709 void* peek_nth()(uint n) {
7710 return g_queue_peek_nth(&this, n);
7713 // Unintrospectable method: peek_nth_link() / g_queue_peek_nth_link()
7714 // VERSION: 2.4
7715 // Returns the link at the given position
7717 // end of the list
7718 // RETURNS: The link at the @n'th position, or %NULL if @n is off the
7719 // <n>: the position of the link
7720 GLib2.List* peek_nth_link()(uint n) {
7721 return g_queue_peek_nth_link(&this, n);
7724 // Unintrospectable method: peek_tail() / g_queue_peek_tail()
7725 // Returns the last element of the queue.
7727 // is empty.
7728 // RETURNS: the data of the last element in the queue, or %NULL if the queue
7729 void* peek_tail()() {
7730 return g_queue_peek_tail(&this);
7733 // Unintrospectable method: peek_tail_link() / g_queue_peek_tail_link()
7734 // VERSION: 2.4
7735 // Returns the last link @queue.
7736 // RETURNS: the last link in @queue, or %NULL if @queue is empty
7737 GLib2.List* peek_tail_link()() {
7738 return g_queue_peek_tail_link(&this);
7741 // Unintrospectable method: pop_head() / g_queue_pop_head()
7742 // Removes the first element of the queue.
7744 // is empty.
7745 // RETURNS: the data of the first element in the queue, or %NULL if the queue
7746 void* pop_head()() {
7747 return g_queue_pop_head(&this);
7750 // Unintrospectable method: pop_head_link() / g_queue_pop_head_link()
7751 // Removes the first element of the queue.
7753 // is empty.
7754 // RETURNS: the #GList element at the head of the queue, or %NULL if the queue
7755 GLib2.List* pop_head_link()() {
7756 return g_queue_pop_head_link(&this);
7759 // Unintrospectable method: pop_nth() / g_queue_pop_nth()
7760 // VERSION: 2.4
7761 // Removes the @n'th element of @queue.
7762 // RETURNS: the element's data, or %NULL if @n is off the end of @queue.
7763 // <n>: the position of the element.
7764 void* pop_nth()(uint n) {
7765 return g_queue_pop_nth(&this, n);
7768 // Unintrospectable method: pop_nth_link() / g_queue_pop_nth_link()
7769 // VERSION: 2.4
7770 // Removes and returns the link at the given position.
7771 // RETURNS: The @n'th link, or %NULL if @n is off the end of @queue.
7772 // <n>: the link's position
7773 GLib2.List* pop_nth_link()(uint n) {
7774 return g_queue_pop_nth_link(&this, n);
7777 // Unintrospectable method: pop_tail() / g_queue_pop_tail()
7778 // Removes the last element of the queue.
7780 // is empty.
7781 // RETURNS: the data of the last element in the queue, or %NULL if the queue
7782 void* pop_tail()() {
7783 return g_queue_pop_tail(&this);
7786 // Unintrospectable method: pop_tail_link() / g_queue_pop_tail_link()
7787 // Removes the last element of the queue.
7789 // is empty.
7790 // RETURNS: the #GList element at the tail of the queue, or %NULL if the queue
7791 GLib2.List* pop_tail_link()() {
7792 return g_queue_pop_tail_link(&this);
7795 // Adds a new element at the head of the queue.
7796 // <data>: the data for the new element.
7797 void push_head()(void* data) {
7798 g_queue_push_head(&this, data);
7801 // Unintrospectable method: push_head_link() / g_queue_push_head_link()
7802 // Adds a new element at the head of the queue.
7803 // <link_>: a single #GList element, <emphasis>not</emphasis> a list with more than one element.
7804 void push_head_link()(GLib2.List* link_) {
7805 g_queue_push_head_link(&this, link_);
7808 // VERSION: 2.4
7809 // Inserts a new element into @queue at the given position
7810 // <data>: the data for the new element
7811 // <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.
7812 void push_nth()(void* data, int n) {
7813 g_queue_push_nth(&this, data, n);
7816 // Unintrospectable method: push_nth_link() / g_queue_push_nth_link()
7817 // VERSION: 2.4
7818 // Inserts @link into @queue at the given position.
7819 // <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.
7820 // <link_>: the link to add to @queue
7821 void push_nth_link()(int n, GLib2.List* link_) {
7822 g_queue_push_nth_link(&this, n, link_);
7825 // Adds a new element at the tail of the queue.
7826 // <data>: the data for the new element.
7827 void push_tail()(void* data) {
7828 g_queue_push_tail(&this, data);
7831 // Unintrospectable method: push_tail_link() / g_queue_push_tail_link()
7832 // Adds a new element at the tail of the queue.
7833 // <link_>: a single #GList element, <emphasis>not</emphasis> a list with more than one element.
7834 void push_tail_link()(GLib2.List* link_) {
7835 g_queue_push_tail_link(&this, link_);
7838 // VERSION: 2.4
7839 // Removes the first element in @queue that contains @data.
7840 // RETURNS: %TRUE if @data was found and removed from @queue
7841 // <data>: data to remove.
7842 int remove()(const(void)* data) {
7843 return g_queue_remove(&this, data);
7846 // VERSION: 2.4
7847 // Remove all elements whose data equals @data from @queue.
7848 // RETURNS: the number of elements removed from @queue
7849 // <data>: data to remove
7850 uint remove_all()(const(void)* data) {
7851 return g_queue_remove_all(&this, data);
7854 // VERSION: 2.4
7855 // Reverses the order of the items in @queue.
7856 void reverse()() {
7857 g_queue_reverse(&this);
7860 // Unintrospectable method: sort() / g_queue_sort()
7861 // VERSION: 2.4
7862 // Sorts @queue using @compare_func.
7863 // <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.
7864 // <user_data>: user data passed to @compare_func
7865 void sort()(CompareDataFunc compare_func, void* user_data) {
7866 g_queue_sort(&this, compare_func, user_data);
7869 // Unintrospectable method: unlink() / g_queue_unlink()
7870 // VERSION: 2.4
7871 // Unlinks @link_ so that it will no longer be part of @queue. The link is
7872 // not freed.
7874 // @link_ must be part of @queue,
7875 // <link_>: a #GList link that <emphasis>must</emphasis> be part of @queue
7876 void unlink()(GLib2.List* link_) {
7877 g_queue_unlink(&this, link_);
7880 // Unintrospectable function: new() / g_queue_new()
7881 // Creates a new #GQueue.
7882 // RETURNS: a new #GQueue.
7883 static Queue* new_()() {
7884 return g_queue_new();
7889 // The #GRand struct is an opaque data structure. It should only be
7890 // accessed through the <function>g_rand_*</function> functions.
7891 struct Rand {
7893 // Unintrospectable method: copy() / g_rand_copy()
7894 // VERSION: 2.4
7895 // Copies a #GRand into a new one with the same exact state as before.
7896 // This way you can take a snapshot of the random number generator for
7897 // replaying later.
7898 // RETURNS: the new #GRand.
7899 Rand* copy()() {
7900 return g_rand_copy(&this);
7903 // Returns the next random #gdouble from @rand_ equally distributed over
7904 // the range [0..1).
7905 // RETURNS: A random number.
7906 double double_()() {
7907 return g_rand_double(&this);
7910 // Returns the next random #gdouble from @rand_ equally distributed over
7911 // the range [@begin..@end).
7912 // RETURNS: A random number.
7913 // <begin>: lower closed bound of the interval.
7914 // <end>: upper open bound of the interval.
7915 double double_range()(double begin, double end) {
7916 return g_rand_double_range(&this, begin, end);
7918 // Frees the memory allocated for the #GRand.
7919 void free()() {
7920 g_rand_free(&this);
7923 // Returns the next random #guint32 from @rand_ equally distributed over
7924 // the range [0..2^32-1].
7925 // RETURNS: A random number.
7926 uint int_()() {
7927 return g_rand_int(&this);
7930 // Returns the next random #gint32 from @rand_ equally distributed over
7931 // the range [@begin..@end-1].
7932 // RETURNS: A random number.
7933 // <begin>: lower closed bound of the interval.
7934 // <end>: upper open bound of the interval.
7935 int int_range()(int begin, int end) {
7936 return g_rand_int_range(&this, begin, end);
7939 // Sets the seed for the random number generator #GRand to @seed.
7940 // <seed>: a value to reinitialize the random number generator.
7941 void set_seed()(uint seed) {
7942 g_rand_set_seed(&this, seed);
7945 // VERSION: 2.4
7946 // Initializes the random number generator by an array of
7947 // longs. Array can be of arbitrary size, though only the
7948 // first 624 values are taken. This function is useful
7949 // if you have many low entropy seeds, or if you require more then
7950 // 32bits of actual entropy for your application.
7951 // <seed>: array to initialize with
7952 // <seed_length>: length of array
7953 void set_seed_array()(uint* seed, uint seed_length) {
7954 g_rand_set_seed_array(&this, seed, seed_length);
7957 // Unintrospectable function: new() / g_rand_new()
7958 // Creates a new random number generator initialized with a seed taken
7959 // either from <filename>/dev/urandom</filename> (if existing) or from
7960 // the current time (as a fallback).
7961 // RETURNS: the new #GRand.
7962 static Rand* new_()() {
7963 return g_rand_new();
7966 // Unintrospectable function: new_with_seed() / g_rand_new_with_seed()
7967 // Creates a new random number generator initialized with @seed.
7968 // RETURNS: the new #GRand.
7969 // <seed>: a value to initialize the random number generator.
7970 static Rand* new_with_seed()(uint seed) {
7971 return g_rand_new_with_seed(seed);
7974 // Unintrospectable function: new_with_seed_array() / g_rand_new_with_seed_array()
7975 // VERSION: 2.4
7976 // Creates a new random number generator initialized with @seed.
7977 // RETURNS: the new #GRand.
7978 // <seed>: an array of seeds to initialize the random number generator.
7979 // <seed_length>: an array of seeds to initialize the random number generator.
7980 static Rand* new_with_seed_array()(uint* seed, uint seed_length) {
7981 return g_rand_new_with_seed_array(seed, seed_length);
7986 // The <function>g_regex_*()</function> functions implement regular
7987 // expression pattern matching using syntax and semantics similar to
7988 // Perl regular expression.
7990 // Some functions accept a @start_position argument, setting it differs
7991 // from just passing over a shortened string and setting #G_REGEX_MATCH_NOTBOL
7992 // in the case of a pattern that begins with any kind of lookbehind assertion.
7993 // For example, consider the pattern "\Biss\B" which finds occurrences of "iss"
7994 // in the middle of words. ("\B" matches only if the current position in the
7995 // subject is not a word boundary.) When applied to the string "Mississipi"
7996 // from the fourth byte, namely "issipi", it does not match, because "\B" is
7997 // always false at the start of the subject, which is deemed to be a word
7998 // boundary. However, if the entire string is passed , but with
7999 // @start_position set to 4, it finds the second occurrence of "iss" because
8000 // it is able to look behind the starting point to discover that it is
8001 // preceded by a letter.
8003 // Note that, unless you set the #G_REGEX_RAW flag, all the strings passed
8004 // to these functions must be encoded in UTF-8. The lengths and the positions
8005 // inside the strings are in bytes and not in characters, so, for instance,
8006 // "\xc3\xa0" (i.e. "&agrave;") is two bytes long but it is treated as a
8007 // single character. If you set #G_REGEX_RAW the strings can be non-valid
8008 // UTF-8 strings and a byte is treated as a character, so "\xc3\xa0" is two
8009 // bytes and two characters long.
8011 // When matching a pattern, "\n" matches only against a "\n" character in
8012 // the string, and "\r" matches only a "\r" character. To match any newline
8013 // sequence use "\R". This particular group matches either the two-character
8014 // sequence CR + LF ("\r\n"), or one of the single characters LF (linefeed,
8015 // U+000A, "\n"), VT vertical tab, U+000B, "\v"), FF (formfeed, U+000C, "\f"),
8016 // CR (carriage return, U+000D, "\r"), NEL (next line, U+0085), LS (line
8017 // separator, U+2028), or PS (paragraph separator, U+2029).
8019 // The behaviour of the dot, circumflex, and dollar metacharacters are
8020 // affected by newline characters, the default is to recognize any newline
8021 // character (the same characters recognized by "\R"). This can be changed
8022 // with #G_REGEX_NEWLINE_CR, #G_REGEX_NEWLINE_LF and #G_REGEX_NEWLINE_CRLF
8023 // compile options, and with #G_REGEX_MATCH_NEWLINE_ANY,
8024 // #G_REGEX_MATCH_NEWLINE_CR, #G_REGEX_MATCH_NEWLINE_LF and
8025 // #G_REGEX_MATCH_NEWLINE_CRLF match options. These settings are also
8026 // relevant when compiling a pattern if #G_REGEX_EXTENDED is set, and an
8027 // unescaped "#" outside a character class is encountered. This indicates
8028 // a comment that lasts until after the next newline.
8030 // Creating and manipulating the same #GRegex structure from different
8031 // threads is not a problem as #GRegex does not modify its internal
8032 // state between creation and destruction, on the other hand #GMatchInfo
8033 // is not threadsafe.
8035 // The regular expressions low-level functionalities are obtained through
8036 // the excellent <ulink url="http://www.pcre.org/">PCRE</ulink> library
8037 // written by Philip Hazel.
8038 struct Regex /* Version 2.14 */ {
8040 // VERSION: 2.14
8041 // Compiles the regular expression to an internal form, and does
8042 // the initial setup of the #GRegex structure.
8044 // are done with it
8045 // RETURNS: a #GRegex structure. Call g_regex_unref() when you
8046 // <pattern>: the regular expression
8047 // <compile_options>: compile options for the regular expression, or 0
8048 // <match_options>: match options for the regular expression, or 0
8049 static Regex* /*new*/ new_()(char* pattern, RegexCompileFlags compile_options, RegexMatchFlags match_options, GLib2.Error** error=null) {
8050 return g_regex_new(pattern, compile_options, match_options, error);
8053 // VERSION: 2.14
8054 // Returns the number of capturing subpatterns in the pattern.
8055 // RETURNS: the number of capturing subpatterns
8056 int get_capture_count()() {
8057 return g_regex_get_capture_count(&this);
8060 // VERSION: 2.26
8061 // Returns the compile options that @regex was created with.
8062 // RETURNS: flags from #GRegexCompileFlags
8063 RegexCompileFlags get_compile_flags()() {
8064 return g_regex_get_compile_flags(&this);
8067 // VERSION: 2.26
8068 // Returns the match options that @regex was created with.
8069 // RETURNS: flags from #GRegexMatchFlags
8070 RegexMatchFlags get_match_flags()() {
8071 return g_regex_get_match_flags(&this);
8074 // VERSION: 2.14
8075 // Returns the number of the highest back reference
8076 // in the pattern, or 0 if the pattern does not contain
8077 // back references.
8078 // RETURNS: the number of the highest back reference
8079 int get_max_backref()() {
8080 return g_regex_get_max_backref(&this);
8083 // VERSION: 2.14
8084 // Gets the pattern string associated with @regex, i.e. a copy of
8085 // the string passed to g_regex_new().
8086 // RETURNS: the pattern of @regex
8087 char* get_pattern()() {
8088 return g_regex_get_pattern(&this);
8091 // VERSION: 2.14
8092 // Retrieves the number of the subexpression named @name.
8094 // does not exists
8095 // RETURNS: The number of the subexpression or -1 if @name
8096 // <name>: name of the subexpression
8097 int get_string_number()(char* name) {
8098 return g_regex_get_string_number(&this, name);
8101 // VERSION: 2.14
8102 // Scans for a match in string for the pattern in @regex.
8103 // The @match_options are combined with the match options specified
8104 // when the @regex structure was created, letting you have more
8105 // flexibility in reusing #GRegex structures.
8107 // A #GMatchInfo structure, used to get information on the match,
8108 // is stored in @match_info if not %NULL. Note that if @match_info
8109 // is not %NULL then it is created even if the function returns %FALSE,
8110 // i.e. you must free it regardless if regular expression actually matched.
8112 // To retrieve all the non-overlapping matches of the pattern in
8113 // string you can use g_match_info_next().
8115 // |[
8116 // static void
8117 // print_uppercase_words (const gchar *string)
8118 // {
8119 // /&ast; Print all uppercase-only words. &ast;/
8120 // GRegex *regex;
8121 // GMatchInfo *match_info;
8122 // &nbsp;
8123 // regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
8124 // g_regex_match (regex, string, 0, &amp;match_info);
8125 // while (g_match_info_matches (match_info))
8126 // {
8127 // gchar *word = g_match_info_fetch (match_info, 0);
8128 // g_print ("Found: %s\n", word);
8129 // g_free (word);
8130 // g_match_info_next (match_info, NULL);
8131 // }
8132 // g_match_info_free (match_info);
8133 // g_regex_unref (regex);
8134 // }
8135 // ]|
8137 // @string is not copied and is used in #GMatchInfo internally. If
8138 // you use any #GMatchInfo method (except g_match_info_free()) after
8139 // freeing or modifying @string then the behaviour is undefined.
8140 // RETURNS: %TRUE is the string matched, %FALSE otherwise
8141 // <string>: the string to scan for matches
8142 // <match_options>: match options
8143 // <match_info>: pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
8144 int match()(char* string_, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info=null) {
8145 return g_regex_match(&this, string_, match_options, match_info);
8148 // VERSION: 2.14
8149 // Using the standard algorithm for regular expression matching only
8150 // the longest match in the string is retrieved. This function uses
8151 // a different algorithm so it can retrieve all the possible matches.
8152 // For more documentation see g_regex_match_all_full().
8154 // A #GMatchInfo structure, used to get information on the match, is
8155 // stored in @match_info if not %NULL. Note that if @match_info is
8156 // not %NULL then it is created even if the function returns %FALSE,
8157 // i.e. you must free it regardless if regular expression actually
8158 // matched.
8160 // @string is not copied and is used in #GMatchInfo internally. If
8161 // you use any #GMatchInfo method (except g_match_info_free()) after
8162 // freeing or modifying @string then the behaviour is undefined.
8163 // RETURNS: %TRUE is the string matched, %FALSE otherwise
8164 // <string>: the string to scan for matches
8165 // <match_options>: match options
8166 // <match_info>: pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
8167 int match_all()(char* string_, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info=null) {
8168 return g_regex_match_all(&this, string_, match_options, match_info);
8171 // VERSION: 2.14
8172 // Using the standard algorithm for regular expression matching only
8173 // the longest match in the string is retrieved, it is not possible
8174 // to obtain all the available matches. For instance matching
8175 // "&lt;a&gt; &lt;b&gt; &lt;c&gt;" against the pattern "&lt;.*&gt;"
8176 // you get "&lt;a&gt; &lt;b&gt; &lt;c&gt;".
8178 // This function uses a different algorithm (called DFA, i.e. deterministic
8179 // finite automaton), so it can retrieve all the possible matches, all
8180 // starting at the same point in the string. For instance matching
8181 // "&lt;a&gt; &lt;b&gt; &lt;c&gt;" against the pattern "&lt;.*&gt;"
8182 // you would obtain three matches: "&lt;a&gt; &lt;b&gt; &lt;c&gt;",
8183 // "&lt;a&gt; &lt;b&gt;" and "&lt;a&gt;".
8185 // The number of matched strings is retrieved using
8186 // g_match_info_get_match_count(). To obtain the matched strings and
8187 // their position you can use, respectively, g_match_info_fetch() and
8188 // g_match_info_fetch_pos(). Note that the strings are returned in
8189 // reverse order of length; that is, the longest matching string is
8190 // given first.
8192 // Note that the DFA algorithm is slower than the standard one and it
8193 // is not able to capture substrings, so backreferences do not work.
8195 // Setting @start_position differs from just passing over a shortened
8196 // string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
8197 // that begins with any kind of lookbehind assertion, such as "\b".
8199 // A #GMatchInfo structure, used to get information on the match, is
8200 // stored in @match_info if not %NULL. Note that if @match_info is
8201 // not %NULL then it is created even if the function returns %FALSE,
8202 // i.e. you must free it regardless if regular expression actually
8203 // matched.
8205 // @string is not copied and is used in #GMatchInfo internally. If
8206 // you use any #GMatchInfo method (except g_match_info_free()) after
8207 // freeing or modifying @string then the behaviour is undefined.
8208 // RETURNS: %TRUE is the string matched, %FALSE otherwise
8209 // <string>: the string to scan for matches
8210 // <string_len>: the length of @string, or -1 if @string is nul-terminated
8211 // <start_position>: starting index of the string to match
8212 // <match_options>: match options
8213 // <match_info>: pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
8214 int match_all_full()(char* string_, ssize_t string_len, int start_position, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info, GLib2.Error** error=null) {
8215 return g_regex_match_all_full(&this, string_, string_len, start_position, match_options, match_info, error);
8218 // VERSION: 2.14
8219 // Scans for a match in string for the pattern in @regex.
8220 // The @match_options are combined with the match options specified
8221 // when the @regex structure was created, letting you have more
8222 // flexibility in reusing #GRegex structures.
8224 // Setting @start_position differs from just passing over a shortened
8225 // string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
8226 // that begins with any kind of lookbehind assertion, such as "\b".
8228 // A #GMatchInfo structure, used to get information on the match, is
8229 // stored in @match_info if not %NULL. Note that if @match_info is
8230 // not %NULL then it is created even if the function returns %FALSE,
8231 // i.e. you must free it regardless if regular expression actually
8232 // matched.
8234 // @string is not copied and is used in #GMatchInfo internally. If
8235 // you use any #GMatchInfo method (except g_match_info_free()) after
8236 // freeing or modifying @string then the behaviour is undefined.
8238 // To retrieve all the non-overlapping matches of the pattern in
8239 // string you can use g_match_info_next().
8241 // |[
8242 // static void
8243 // print_uppercase_words (const gchar *string)
8244 // {
8245 // /&ast; Print all uppercase-only words. &ast;/
8246 // GRegex *regex;
8247 // GMatchInfo *match_info;
8248 // GError *error = NULL;
8249 // &nbsp;
8250 // regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
8251 // g_regex_match_full (regex, string, -1, 0, 0, &amp;match_info, &amp;error);
8252 // while (g_match_info_matches (match_info))
8253 // {
8254 // gchar *word = g_match_info_fetch (match_info, 0);
8255 // g_print ("Found: %s\n", word);
8256 // g_free (word);
8257 // g_match_info_next (match_info, &amp;error);
8258 // }
8259 // g_match_info_free (match_info);
8260 // g_regex_unref (regex);
8261 // if (error != NULL)
8262 // {
8263 // g_printerr ("Error while matching: %s\n", error->message);
8264 // g_error_free (error);
8265 // }
8266 // }
8267 // ]|
8268 // RETURNS: %TRUE is the string matched, %FALSE otherwise
8269 // <string>: the string to scan for matches
8270 // <string_len>: the length of @string, or -1 if @string is nul-terminated
8271 // <start_position>: starting index of the string to match
8272 // <match_options>: match options
8273 // <match_info>: pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
8274 int match_full()(char* string_, ssize_t string_len, int start_position, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info, GLib2.Error** error=null) {
8275 return g_regex_match_full(&this, string_, string_len, start_position, match_options, match_info, error);
8278 // VERSION: 2.14
8279 // Increases reference count of @regex by 1.
8280 // RETURNS: @regex
8281 Regex* /*new*/ ref_()() {
8282 return g_regex_ref(&this);
8285 // VERSION: 2.14
8286 // Replaces all occurrences of the pattern in @regex with the
8287 // replacement text. Backreferences of the form '\number' or
8288 // '\g&lt;number&gt;' in the replacement text are interpolated by the
8289 // number-th captured subexpression of the match, '\g&lt;name&gt;' refers
8290 // to the captured subexpression with the given name. '\0' refers to the
8291 // complete match, but '\0' followed by a number is the octal representation
8292 // of a character. To include a literal '\' in the replacement, write '\\'.
8293 // There are also escapes that changes the case of the following text:
8295 // <variablelist>
8296 // <varlistentry><term>\l</term>
8297 // <listitem>
8298 // <para>Convert to lower case the next character</para>
8299 // </listitem>
8300 // </varlistentry>
8301 // <varlistentry><term>\u</term>
8302 // <listitem>
8303 // <para>Convert to upper case the next character</para>
8304 // </listitem>
8305 // </varlistentry>
8306 // <varlistentry><term>\L</term>
8307 // <listitem>
8308 // <para>Convert to lower case till \E</para>
8309 // </listitem>
8310 // </varlistentry>
8311 // <varlistentry><term>\U</term>
8312 // <listitem>
8313 // <para>Convert to upper case till \E</para>
8314 // </listitem>
8315 // </varlistentry>
8316 // <varlistentry><term>\E</term>
8317 // <listitem>
8318 // <para>End case modification</para>
8319 // </listitem>
8320 // </varlistentry>
8321 // </variablelist>
8323 // If you do not need to use backreferences use g_regex_replace_literal().
8325 // The @replacement string must be UTF-8 encoded even if #G_REGEX_RAW was
8326 // passed to g_regex_new(). If you want to use not UTF-8 encoded stings
8327 // you can use g_regex_replace_literal().
8329 // Setting @start_position differs from just passing over a shortened
8330 // string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern that
8331 // begins with any kind of lookbehind assertion, such as "\b".
8332 // RETURNS: a newly allocated string containing the replacements
8333 // <string>: the string to perform matches against
8334 // <string_len>: the length of @string, or -1 if @string is nul-terminated
8335 // <start_position>: starting index of the string to match
8336 // <replacement>: text to replace each match with
8337 // <match_options>: options for the match
8338 char* /*new*/ replace()(char* string_, ssize_t string_len, int start_position, char* replacement, RegexMatchFlags match_options, GLib2.Error** error=null) {
8339 return g_regex_replace(&this, string_, string_len, start_position, replacement, match_options, error);
8342 // Unintrospectable method: replace_eval() / g_regex_replace_eval()
8343 // VERSION: 2.14
8344 // Replaces occurrences of the pattern in regex with the output of
8345 // @eval for that occurrence.
8347 // Setting @start_position differs from just passing over a shortened
8348 // string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
8349 // that begins with any kind of lookbehind assertion, such as "\b".
8351 // The following example uses g_regex_replace_eval() to replace multiple
8352 // strings at once:
8353 // |[
8354 // static gboolean
8355 // eval_cb (const GMatchInfo *info,
8356 // GString *res,
8357 // gpointer data)
8358 // {
8359 // gchar *match;
8360 // gchar *r;
8362 // match = g_match_info_fetch (info, 0);
8363 // r = g_hash_table_lookup ((GHashTable *)data, match);
8364 // g_string_append (res, r);
8365 // g_free (match);
8367 // return FALSE;
8368 // }
8370 // /&ast; ... &ast;/
8372 // GRegex *reg;
8373 // GHashTable *h;
8374 // gchar *res;
8376 // h = g_hash_table_new (g_str_hash, g_str_equal);
8378 // g_hash_table_insert (h, "1", "ONE");
8379 // g_hash_table_insert (h, "2", "TWO");
8380 // g_hash_table_insert (h, "3", "THREE");
8381 // g_hash_table_insert (h, "4", "FOUR");
8383 // reg = g_regex_new ("1|2|3|4", 0, 0, NULL);
8384 // res = g_regex_replace_eval (reg, text, -1, 0, 0, eval_cb, h, NULL);
8385 // g_hash_table_destroy (h);
8387 // /&ast; ... &ast;/
8388 // ]|
8389 // RETURNS: a newly allocated string containing the replacements
8390 // <string>: string to perform matches against
8391 // <string_len>: the length of @string, or -1 if @string is nul-terminated
8392 // <start_position>: starting index of the string to match
8393 // <match_options>: options for the match
8394 // <eval>: a function to call for each match
8395 // <user_data>: user data to pass to the function
8396 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) {
8397 return g_regex_replace_eval(&this, string_, string_len, start_position, match_options, eval, user_data, error);
8400 // VERSION: 2.14
8401 // Replaces all occurrences of the pattern in @regex with the
8402 // replacement text. @replacement is replaced literally, to
8403 // include backreferences use g_regex_replace().
8405 // Setting @start_position differs from just passing over a
8406 // shortened string and setting #G_REGEX_MATCH_NOTBOL in the
8407 // case of a pattern that begins with any kind of lookbehind
8408 // assertion, such as "\b".
8409 // RETURNS: a newly allocated string containing the replacements
8410 // <string>: the string to perform matches against
8411 // <string_len>: the length of @string, or -1 if @string is nul-terminated
8412 // <start_position>: starting index of the string to match
8413 // <replacement>: text to replace each match with
8414 // <match_options>: options for the match
8415 char* /*new*/ replace_literal()(char* string_, ssize_t string_len, int start_position, char* replacement, RegexMatchFlags match_options, GLib2.Error** error=null) {
8416 return g_regex_replace_literal(&this, string_, string_len, start_position, replacement, match_options, error);
8419 // Unintrospectable method: split() / g_regex_split()
8420 // VERSION: 2.14
8421 // Breaks the string on the pattern, and returns an array of the tokens.
8422 // If the pattern contains capturing parentheses, then the text for each
8423 // of the substrings will also be returned. If the pattern does not match
8424 // anywhere in the string, then the whole string is returned as the first
8425 // token.
8427 // As a special case, the result of splitting the empty string "" is an
8428 // empty vector, not a vector containing a single string. The reason for
8429 // this special case is that being able to represent a empty vector is
8430 // typically more useful than consistent handling of empty elements. If
8431 // you do need to represent empty elements, you'll need to check for the
8432 // empty string before calling this function.
8434 // A pattern that can match empty strings splits @string into separate
8435 // characters wherever it matches the empty string between characters.
8436 // For example splitting "ab c" using as a separator "\s*", you will get
8437 // "a", "b" and "c".
8438 // RETURNS: a %NULL-terminated gchar ** array. Free it using g_strfreev()
8439 // <string>: the string to split with the pattern
8440 // <match_options>: match time option flags
8441 char** split()(char* string_, RegexMatchFlags match_options) {
8442 return g_regex_split(&this, string_, match_options);
8445 // Unintrospectable method: split_full() / g_regex_split_full()
8446 // VERSION: 2.14
8447 // Breaks the string on the pattern, and returns an array of the tokens.
8448 // If the pattern contains capturing parentheses, then the text for each
8449 // of the substrings will also be returned. If the pattern does not match
8450 // anywhere in the string, then the whole string is returned as the first
8451 // token.
8453 // As a special case, the result of splitting the empty string "" is an
8454 // empty vector, not a vector containing a single string. The reason for
8455 // this special case is that being able to represent a empty vector is
8456 // typically more useful than consistent handling of empty elements. If
8457 // you do need to represent empty elements, you'll need to check for the
8458 // empty string before calling this function.
8460 // A pattern that can match empty strings splits @string into separate
8461 // characters wherever it matches the empty string between characters.
8462 // For example splitting "ab c" using as a separator "\s*", you will get
8463 // "a", "b" and "c".
8465 // Setting @start_position differs from just passing over a shortened
8466 // string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
8467 // that begins with any kind of lookbehind assertion, such as "\b".
8468 // RETURNS: a %NULL-terminated gchar ** array. Free it using g_strfreev()
8469 // <string>: the string to split with the pattern
8470 // <string_len>: the length of @string, or -1 if @string is nul-terminated
8471 // <start_position>: starting index of the string to match
8472 // <match_options>: match time option flags
8473 // <max_tokens>: the maximum number of tokens to split @string into. If this is less than 1, the string is split completely
8474 char** split_full()(char* string_, ssize_t string_len, int start_position, RegexMatchFlags match_options, int max_tokens, GLib2.Error** error=null) {
8475 return g_regex_split_full(&this, string_, string_len, start_position, match_options, max_tokens, error);
8478 // VERSION: 2.14
8479 // Decreases reference count of @regex by 1. When reference count drops
8480 // to zero, it frees all the memory associated with the regex structure.
8481 void unref()() {
8482 g_regex_unref(&this);
8485 // VERSION: 2.14
8486 // Checks whether @replacement is a valid replacement string
8487 // (see g_regex_replace()), i.e. that all escape sequences in
8488 // it are valid.
8490 // If @has_references is not %NULL then @replacement is checked
8491 // for pattern references. For instance, replacement text 'foo\n'
8492 // does not contain references and may be evaluated without information
8493 // about actual match, but '\0\1' (whole match followed by first
8494 // subpattern) requires valid #GMatchInfo object.
8495 // RETURNS: whether @replacement is a valid replacement string
8496 // <replacement>: the replacement string
8497 // <has_references>: location to store information about references in @replacement or %NULL
8498 static int check_replacement()(char* replacement, /*out*/ int* has_references, GLib2.Error** error=null) {
8499 return g_regex_check_replacement(replacement, has_references, error);
8501 static Quark error_quark()() {
8502 return g_regex_error_quark();
8505 // VERSION: 2.30
8506 // Escapes the nul characters in @string to "\x00". It can be used
8507 // to compile a regex with embedded nul characters.
8509 // For completeness, @length can be -1 for a nul-terminated string.
8510 // In this case the output string will be of course equal to @string.
8511 // RETURNS: a newly-allocated escaped string
8512 // <string>: the string to escape
8513 // <length>: the length of @string
8514 static char* /*new*/ escape_nul()(char* string_, int length) {
8515 return g_regex_escape_nul(string_, length);
8518 // VERSION: 2.14
8519 // Escapes the special characters used for regular expressions
8520 // in @string, for instance "a.b*c" becomes "a\.b\*c". This
8521 // function is useful to dynamically generate regular expressions.
8523 // @string can contain nul characters that are replaced with "\0",
8524 // in this case remember to specify the correct length of @string
8525 // in @length.
8526 // RETURNS: a newly-allocated escaped string
8527 // <string>: the string to escape
8528 // <length>: the length of @string, or -1 if @string is nul-terminated
8529 static char* /*new*/ escape_string()(char* string_, int length) {
8530 return g_regex_escape_string(string_, length);
8533 // VERSION: 2.14
8534 // Scans for a match in @string for @pattern.
8536 // This function is equivalent to g_regex_match() but it does not
8537 // require to compile the pattern with g_regex_new(), avoiding some
8538 // lines of code when you need just to do a match without extracting
8539 // substrings, capture counts, and so on.
8541 // If this function is to be called on the same @pattern more than
8542 // once, it's more efficient to compile the pattern once with
8543 // g_regex_new() and then use g_regex_match().
8544 // RETURNS: %TRUE if the string matched, %FALSE otherwise
8545 // <pattern>: the regular expression
8546 // <string>: the string to scan for matches
8547 // <compile_options>: compile options for the regular expression, or 0
8548 // <match_options>: match options, or 0
8549 static int match_simple()(char* pattern, char* string_, RegexCompileFlags compile_options, RegexMatchFlags match_options) {
8550 return g_regex_match_simple(pattern, string_, compile_options, match_options);
8553 // Unintrospectable function: split_simple() / g_regex_split_simple()
8554 // VERSION: 2.14
8555 // Breaks the string on the pattern, and returns an array of
8556 // the tokens. If the pattern contains capturing parentheses,
8557 // then the text for each of the substrings will also be returned.
8558 // If the pattern does not match anywhere in the string, then the
8559 // whole string is returned as the first token.
8561 // This function is equivalent to g_regex_split() but it does
8562 // not require to compile the pattern with g_regex_new(), avoiding
8563 // some lines of code when you need just to do a split without
8564 // extracting substrings, capture counts, and so on.
8566 // If this function is to be called on the same @pattern more than
8567 // once, it's more efficient to compile the pattern once with
8568 // g_regex_new() and then use g_regex_split().
8570 // As a special case, the result of splitting the empty string ""
8571 // is an empty vector, not a vector containing a single string.
8572 // The reason for this special case is that being able to represent
8573 // a empty vector is typically more useful than consistent handling
8574 // of empty elements. If you do need to represent empty elements,
8575 // you'll need to check for the empty string before calling this
8576 // function.
8578 // A pattern that can match empty strings splits @string into
8579 // separate characters wherever it matches the empty string between
8580 // characters. For example splitting "ab c" using as a separator
8581 // "\s*", you will get "a", "b" and "c".
8582 // RETURNS: a %NULL-terminated array of strings. Free it using g_strfreev()
8583 // <pattern>: the regular expression
8584 // <string>: the string to scan for matches
8585 // <compile_options>: compile options for the regular expression, or 0
8586 // <match_options>: match options, or 0
8587 static char** split_simple()(char* pattern, char* string_, RegexCompileFlags compile_options, RegexMatchFlags match_options) {
8588 return g_regex_split_simple(pattern, string_, compile_options, match_options);
8592 // Flags specifying compile-time options.
8593 enum RegexCompileFlags /* Version 2.14 */ {
8594 CASELESS = 1,
8595 MULTILINE = 2,
8596 DOTALL = 4,
8597 EXTENDED = 8,
8598 ANCHORED = 16,
8599 DOLLAR_ENDONLY = 32,
8600 UNGREEDY = 512,
8601 RAW = 2048,
8602 NO_AUTO_CAPTURE = 4096,
8603 OPTIMIZE = 8192,
8604 DUPNAMES = 524288,
8605 NEWLINE_CR = 1048576,
8606 NEWLINE_LF = 2097152,
8607 NEWLINE_CRLF = 3145728
8609 // Error codes returned by regular expressions functions.
8610 enum RegexError /* Version 2.14 */ {
8611 COMPILE = 0,
8612 OPTIMIZE = 1,
8613 REPLACE = 2,
8614 MATCH = 3,
8615 INTERNAL = 4,
8616 STRAY_BACKSLASH = 101,
8617 MISSING_CONTROL_CHAR = 102,
8618 UNRECOGNIZED_ESCAPE = 103,
8619 QUANTIFIERS_OUT_OF_ORDER = 104,
8620 QUANTIFIER_TOO_BIG = 105,
8621 UNTERMINATED_CHARACTER_CLASS = 106,
8622 INVALID_ESCAPE_IN_CHARACTER_CLASS = 107,
8623 RANGE_OUT_OF_ORDER = 108,
8624 NOTHING_TO_REPEAT = 109,
8625 UNRECOGNIZED_CHARACTER = 112,
8626 POSIX_NAMED_CLASS_OUTSIDE_CLASS = 113,
8627 UNMATCHED_PARENTHESIS = 114,
8628 INEXISTENT_SUBPATTERN_REFERENCE = 115,
8629 UNTERMINATED_COMMENT = 118,
8630 EXPRESSION_TOO_LARGE = 120,
8631 MEMORY_ERROR = 121,
8632 VARIABLE_LENGTH_LOOKBEHIND = 125,
8633 MALFORMED_CONDITION = 126,
8634 TOO_MANY_CONDITIONAL_BRANCHES = 127,
8635 ASSERTION_EXPECTED = 128,
8636 UNKNOWN_POSIX_CLASS_NAME = 130,
8637 POSIX_COLLATING_ELEMENTS_NOT_SUPPORTED = 131,
8638 HEX_CODE_TOO_LARGE = 134,
8639 INVALID_CONDITION = 135,
8640 SINGLE_BYTE_MATCH_IN_LOOKBEHIND = 136,
8641 INFINITE_LOOP = 140,
8642 MISSING_SUBPATTERN_NAME_TERMINATOR = 142,
8643 DUPLICATE_SUBPATTERN_NAME = 143,
8644 MALFORMED_PROPERTY = 146,
8645 UNKNOWN_PROPERTY = 147,
8646 SUBPATTERN_NAME_TOO_LONG = 148,
8647 TOO_MANY_SUBPATTERNS = 149,
8648 INVALID_OCTAL_VALUE = 151,
8649 TOO_MANY_BRANCHES_IN_DEFINE = 154,
8650 DEFINE_REPETION = 155,
8651 INCONSISTENT_NEWLINE_OPTIONS = 156,
8652 MISSING_BACK_REFERENCE = 157
8655 // VERSION: 2.14
8656 // Specifies the type of the function passed to g_regex_replace_eval().
8657 // It is called for each occurrence of the pattern in the string passed
8658 // to g_regex_replace_eval(), and it should append the replacement to
8659 // @result.
8660 // RETURNS: %FALSE to continue the replacement process, %TRUE to stop it
8661 // <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.
8662 // <result>: a #GString containing the new string
8663 // <user_data>: user data passed to g_regex_replace_eval()
8664 extern (C) alias int function (MatchInfo* match_info, String* result, void* user_data) RegexEvalCallback;
8666 // Flags specifying match-time options.
8667 enum RegexMatchFlags /* Version 2.14 */ {
8668 ANCHORED = 16,
8669 NOTBOL = 128,
8670 NOTEOL = 256,
8671 NOTEMPTY = 1024,
8672 PARTIAL = 32768,
8673 NEWLINE_CR = 1048576,
8674 NEWLINE_LF = 2097152,
8675 NEWLINE_CRLF = 3145728,
8676 NEWLINE_ANY = 4194304
8679 // The #GRelation struct is an opaque data structure to represent a
8680 // <link linkend="glib-Relations-and-Tuples">Relation</link>. It should
8681 // only be accessed via the following functions.
8682 struct Relation {
8684 // DEPRECATED (v2.26) method: count - Rarely used API
8685 // Returns the number of tuples in a #GRelation that have the given
8686 // value in the given field.
8687 // <key>: the value to compare with.
8688 // <field>: the field of each record to match.
8689 int count()(const(void)* key, int field) {
8690 return g_relation_count(&this, key, field);
8693 // DEPRECATED (v2.26) method: delete - Rarely used API
8694 // Deletes any records from a #GRelation that have the given key value
8695 // in the given field.
8696 // <key>: the value to compare with.
8697 // <field>: the field of each record to match.
8698 int delete_()(const(void)* key, int field) {
8699 return g_relation_delete(&this, key, field);
8702 // DEPRECATED (v2.26) method: destroy - Rarely used API
8703 // Destroys the #GRelation, freeing all memory allocated. However, it
8704 // does not free memory allocated for the tuple data, so you should
8705 // free that first if appropriate.
8706 void destroy()() {
8707 g_relation_destroy(&this);
8710 // Unintrospectable method: exists() / g_relation_exists()
8711 // DEPRECATED (v2.26) method: exists - Rarely used API
8712 // Returns %TRUE if a record with the given values exists in a
8713 // #GRelation. Note that the values are compared directly, so that, for
8714 // example, two copies of the same string will not match.
8715 /+ Not available -- variadic methods unsupported - use the C function directly.
8716 alias g_relation_exists exists; // Variadic
8719 // Unintrospectable method: index() / g_relation_index()
8720 // DEPRECATED (v2.26) method: index - Rarely used API
8721 // Creates an index on the given field. Note that this must be called
8722 // before any records are added to the #GRelation.
8723 // <field>: the field to index, counting from 0.
8724 // <hash_func>: a function to produce a hash value from the field data.
8725 // <key_equal_func>: a function to compare two values of the given field.
8726 void index()(int field, HashFunc hash_func, EqualFunc key_equal_func) {
8727 g_relation_index(&this, field, hash_func, key_equal_func);
8730 // Unintrospectable method: insert() / g_relation_insert()
8731 // DEPRECATED (v2.26) method: insert - Rarely used API
8732 // Inserts a record into a #GRelation.
8733 /+ Not available -- variadic methods unsupported - use the C function directly.
8734 alias g_relation_insert insert; // Variadic
8737 // DEPRECATED (v2.26) method: print - Rarely used API
8738 // Outputs information about all records in a #GRelation, as well as
8739 // the indexes. It is for debugging.
8740 void print()() {
8741 g_relation_print(&this);
8744 // Unintrospectable method: select() / g_relation_select()
8745 // DEPRECATED (v2.26) method: select - Rarely used API
8746 // Returns all of the tuples which have the given key in the given
8747 // field. Use g_tuples_index() to access the returned records. The
8748 // returned records should be freed with g_tuples_destroy().
8749 // <key>: the value to compare with.
8750 // <field>: the field of each record to match.
8751 Tuples* select()(const(void)* key, int field) {
8752 return g_relation_select(&this, key, field);
8755 // Unintrospectable function: new() / g_relation_new()
8756 // DEPRECATED (v2.26) function: new - Rarely used API
8757 // Creates a new #GRelation with the given number of fields. Note that
8758 // currently the number of fields must be 2.
8759 // <fields>: the number of fields.
8760 static Relation* new_()(int fields) {
8761 return g_relation_new(fields);
8765 enum int SEARCHPATH_SEPARATOR = 59;
8766 enum SEARCHPATH_SEPARATOR_S = ";";
8767 enum int SIZEOF_LONG = 4;
8768 enum int SIZEOF_SIZE_T = 4;
8769 enum int SIZEOF_VOID_P = 4;
8771 // The #GSList struct is used for each element in the singly-linked
8772 // list.
8773 struct SList {
8774 void* data;
8775 GLib2.SList* next;
8778 // Unintrospectable function: alloc() / g_slist_alloc()
8779 // Allocates space for one #GSList element. It is called by the
8780 // g_slist_append(), g_slist_prepend(), g_slist_insert() and
8781 // g_slist_insert_sorted() functions and so is rarely used on its own.
8782 static GLib2.SList* alloc()() {
8783 return g_slist_alloc();
8786 // Unintrospectable function: append() / g_slist_append()
8787 // Adds a new element on to the end of the list.
8789 // <note><para>
8790 // The return value is the new start of the list, which may
8791 // have changed, so make sure you store the new value.
8792 // </para></note>
8794 // <note><para>
8795 // Note that g_slist_append() has to traverse the entire list
8796 // to find the end, which is inefficient when adding multiple
8797 // elements. A common idiom to avoid the inefficiency is to prepend
8798 // the elements and reverse the list when all elements have been added.
8799 // </para></note>
8801 // |[
8802 // /&ast; Notice that these are initialized to the empty list. &ast;/
8803 // GSList *list = NULL, *number_list = NULL;
8805 // /&ast; This is a list of strings. &ast;/
8806 // list = g_slist_append (list, "first");
8807 // list = g_slist_append (list, "second");
8809 // /&ast; This is a list of integers. &ast;/
8810 // number_list = g_slist_append (number_list, GINT_TO_POINTER (27));
8811 // number_list = g_slist_append (number_list, GINT_TO_POINTER (14));
8812 // ]|
8813 // RETURNS: the new start of the #GSList
8814 // <list>: a #GSList
8815 // <data>: the data for the new element
8816 static GLib2.SList* append()(GLib2.SList* list, void* data) {
8817 return g_slist_append(list, data);
8820 // Unintrospectable function: concat() / g_slist_concat()
8821 // Adds the second #GSList onto the end of the first #GSList.
8822 // Note that the elements of the second #GSList are not copied.
8823 // They are used directly.
8824 // RETURNS: the start of the new #GSList
8825 // <list1>: a #GSList
8826 // <list2>: the #GSList to add to the end of the first #GSList
8827 static GLib2.SList* concat()(GLib2.SList* list1, GLib2.SList* list2) {
8828 return g_slist_concat(list1, list2);
8831 // Unintrospectable function: copy() / g_slist_copy()
8832 // Copies a #GSList.
8834 // <note><para>
8835 // Note that this is a "shallow" copy. If the list elements
8836 // consist of pointers to data, the pointers are copied but
8837 // the actual data isn't.
8838 // </para></note>
8839 // RETURNS: a copy of @list
8840 // <list>: a #GSList
8841 static GLib2.SList* copy()(GLib2.SList* list) {
8842 return g_slist_copy(list);
8845 // Unintrospectable function: delete_link() / g_slist_delete_link()
8846 // Removes the node link_ from the list and frees it.
8847 // Compare this to g_slist_remove_link() which removes the node
8848 // without freeing it.
8849 // RETURNS: the new head of @list
8850 // <list>: a #GSList
8851 // <link_>: node to delete
8852 static GLib2.SList* delete_link()(GLib2.SList* list, GLib2.SList* link_) {
8853 return g_slist_delete_link(list, link_);
8856 // Unintrospectable function: find() / g_slist_find()
8857 // Finds the element in a #GSList which
8858 // contains the given data.
8860 // or %NULL if it is not found
8861 // RETURNS: the found #GSList element,
8862 // <list>: a #GSList
8863 // <data>: the element data to find
8864 static GLib2.SList* find()(GLib2.SList* list, const(void)* data) {
8865 return g_slist_find(list, data);
8868 // Unintrospectable function: find_custom() / g_slist_find_custom()
8869 // Finds an element in a #GSList, using a supplied function to
8870 // find the desired element. It iterates over the list, calling
8871 // the given function which should return 0 when the desired
8872 // element is found. The function takes two #gconstpointer arguments,
8873 // the #GSList element's data as the first argument and the
8874 // given user data.
8875 // RETURNS: the found #GSList element, or %NULL if it is not found
8876 // <list>: a #GSList
8877 // <data>: user data passed to the function
8878 // <func>: the function to call for each element. It should return 0 when the desired element is found
8879 static GLib2.SList* find_custom()(GLib2.SList* list, const(void)* data, CompareFunc func) {
8880 return g_slist_find_custom(list, data, func);
8883 // Unintrospectable function: foreach() / g_slist_foreach()
8884 // Calls a function for each element of a #GSList.
8885 // <list>: a #GSList
8886 // <func>: the function to call with each element's data
8887 // <user_data>: user data to pass to the function
8888 static void foreach_()(GLib2.SList* list, Func func, void* user_data) {
8889 g_slist_foreach(list, func, user_data);
8892 // Unintrospectable function: free() / g_slist_free()
8893 // Frees all of the memory used by a #GSList.
8894 // The freed elements are returned to the slice allocator.
8896 // <note><para>
8897 // If list elements contain dynamically-allocated memory,
8898 // you should either use g_slist_free_full() or free them manually
8899 // first.
8900 // </para></note>
8901 // <list>: a #GSList
8902 static void free()(GLib2.SList* list) {
8903 g_slist_free(list);
8906 // Unintrospectable function: free_1() / g_slist_free_1()
8907 // Frees one #GSList element.
8908 // It is usually used after g_slist_remove_link().
8909 // <list>: a #GSList element
8910 static void free_1()(GLib2.SList* list) {
8911 g_slist_free_1(list);
8914 // Unintrospectable function: free_full() / g_slist_free_full()
8915 // VERSION: 2.28
8916 // Convenience method, which frees all the memory used by a #GSList, and
8917 // calls the specified destroy function on every element's data.
8918 // <list>: a pointer to a #GSList
8919 // <free_func>: the function to be called to free each element's data
8920 static void free_full()(GLib2.SList* list, DestroyNotify free_func) {
8921 g_slist_free_full(list, free_func);
8924 // Unintrospectable function: index() / g_slist_index()
8925 // Gets the position of the element containing
8926 // the given data (starting from 0).
8928 // or -1 if the data is not found
8929 // RETURNS: the index of the element containing the data,
8930 // <list>: a #GSList
8931 // <data>: the data to find
8932 static int index()(GLib2.SList* list, const(void)* data) {
8933 return g_slist_index(list, data);
8936 // Unintrospectable function: insert() / g_slist_insert()
8937 // Inserts a new element into the list at the given position.
8938 // RETURNS: the new start of the #GSList
8939 // <list>: a #GSList
8940 // <data>: the data for the new element
8941 // <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.
8942 static GLib2.SList* insert()(GLib2.SList* list, void* data, int position) {
8943 return g_slist_insert(list, data, position);
8946 // Unintrospectable function: insert_before() / g_slist_insert_before()
8947 // Inserts a node before @sibling containing @data.
8948 // RETURNS: the new head of the list.
8949 // <slist>: a #GSList
8950 // <sibling>: node to insert @data before
8951 // <data>: data to put in the newly-inserted node
8952 static GLib2.SList* insert_before()(GLib2.SList* slist, GLib2.SList* sibling, void* data) {
8953 return g_slist_insert_before(slist, sibling, data);
8956 // Unintrospectable function: insert_sorted() / g_slist_insert_sorted()
8957 // Inserts a new element into the list, using the given
8958 // comparison function to determine its position.
8959 // RETURNS: the new start of the #GSList
8960 // <list>: a #GSList
8961 // <data>: the data for the new element
8962 // <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.
8963 static GLib2.SList* insert_sorted()(GLib2.SList* list, void* data, CompareFunc func) {
8964 return g_slist_insert_sorted(list, data, func);
8967 // Unintrospectable function: insert_sorted_with_data() / g_slist_insert_sorted_with_data()
8968 // VERSION: 2.10
8969 // Inserts a new element into the list, using the given
8970 // comparison function to determine its position.
8971 // RETURNS: the new start of the #GSList
8972 // <list>: a #GSList
8973 // <data>: the data for the new element
8974 // <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.
8975 // <user_data>: data to pass to comparison function
8976 static GLib2.SList* insert_sorted_with_data()(GLib2.SList* list, void* data, CompareDataFunc func, void* user_data) {
8977 return g_slist_insert_sorted_with_data(list, data, func, user_data);
8980 // Unintrospectable function: last() / g_slist_last()
8981 // Gets the last element in a #GSList.
8983 // <note><para>
8984 // This function iterates over the whole list.
8985 // </para></note>
8987 // or %NULL if the #GSList has no elements
8988 // RETURNS: the last element in the #GSList,
8989 // <list>: a #GSList
8990 static GLib2.SList* last()(GLib2.SList* list) {
8991 return g_slist_last(list);
8994 // Unintrospectable function: length() / g_slist_length()
8995 // Gets the number of elements in a #GSList.
8997 // <note><para>
8998 // This function iterates over the whole list to
8999 // count its elements.
9000 // </para></note>
9001 // RETURNS: the number of elements in the #GSList
9002 // <list>: a #GSList
9003 static uint length()(GLib2.SList* list) {
9004 return g_slist_length(list);
9007 // Unintrospectable function: nth() / g_slist_nth()
9008 // Gets the element at the given position in a #GSList.
9010 // the end of the #GSList
9011 // RETURNS: the element, or %NULL if the position is off
9012 // <list>: a #GSList
9013 // <n>: the position of the element, counting from 0
9014 static GLib2.SList* nth()(GLib2.SList* list, uint n) {
9015 return g_slist_nth(list, n);
9018 // Unintrospectable function: nth_data() / g_slist_nth_data()
9019 // Gets the data of the element at the given position.
9021 // is off the end of the #GSList
9022 // RETURNS: the element's data, or %NULL if the position
9023 // <list>: a #GSList
9024 // <n>: the position of the element
9025 static void* nth_data()(GLib2.SList* list, uint n) {
9026 return g_slist_nth_data(list, n);
9029 // DEPRECATED (v2.10) function: pop_allocator - It does nothing, since #GSList has been converted
9030 // Restores the previous #GAllocator, used when allocating #GSList
9031 // elements.
9033 // Note that this function is not available if GLib has been compiled
9034 // with <option>--disable-mem-pools</option>
9036 // to the <link linkend="glib-Memory-Slices">slice
9037 // allocator</link>
9038 static void pop_allocator()() {
9039 g_slist_pop_allocator();
9042 // Unintrospectable function: position() / g_slist_position()
9043 // Gets the position of the given element
9044 // in the #GSList (starting from 0).
9046 // or -1 if the element is not found
9047 // RETURNS: the position of the element in the #GSList,
9048 // <list>: a #GSList
9049 // <llink>: an element in the #GSList
9050 static int position()(GLib2.SList* list, GLib2.SList* llink) {
9051 return g_slist_position(list, llink);
9054 // Unintrospectable function: prepend() / g_slist_prepend()
9055 // Adds a new element on to the start of the list.
9057 // <note><para>
9058 // The return value is the new start of the list, which
9059 // may have changed, so make sure you store the new value.
9060 // </para></note>
9062 // |[
9063 // /&ast; Notice that it is initialized to the empty list. &ast;/
9064 // GSList *list = NULL;
9065 // list = g_slist_prepend (list, "last");
9066 // list = g_slist_prepend (list, "first");
9067 // ]|
9068 // RETURNS: the new start of the #GSList
9069 // <list>: a #GSList
9070 // <data>: the data for the new element
9071 static GLib2.SList* prepend()(GLib2.SList* list, void* data) {
9072 return g_slist_prepend(list, data);
9075 // DEPRECATED (v2.10) function: push_allocator - It does nothing, since #GSList has been converted
9076 // Sets the allocator to use to allocate #GSList elements. Use
9077 // g_slist_pop_allocator() to restore the previous allocator.
9079 // Note that this function is not available if GLib has been compiled
9080 // with <option>--disable-mem-pools</option>
9082 // to the <link linkend="glib-Memory-Slices">slice
9083 // allocator</link>
9084 // <dummy>: the #GAllocator to use when allocating #GSList elements.
9085 static void push_allocator()(void* dummy) {
9086 g_slist_push_allocator(dummy);
9089 // Unintrospectable function: remove() / g_slist_remove()
9090 // Removes an element from a #GSList.
9091 // If two elements contain the same data, only the first is removed.
9092 // If none of the elements contain the data, the #GSList is unchanged.
9093 // RETURNS: the new start of the #GSList
9094 // <list>: a #GSList
9095 // <data>: the data of the element to remove
9096 static GLib2.SList* remove()(GLib2.SList* list, const(void)* data) {
9097 return g_slist_remove(list, data);
9100 // Unintrospectable function: remove_all() / g_slist_remove_all()
9101 // Removes all list nodes with data equal to @data.
9102 // Returns the new head of the list. Contrast with
9103 // g_slist_remove() which removes only the first node
9104 // matching the given data.
9105 // RETURNS: new head of @list
9106 // <list>: a #GSList
9107 // <data>: data to remove
9108 static GLib2.SList* remove_all()(GLib2.SList* list, const(void)* data) {
9109 return g_slist_remove_all(list, data);
9112 // Unintrospectable function: remove_link() / g_slist_remove_link()
9113 // Removes an element from a #GSList, without
9114 // freeing the element. The removed element's next
9115 // link is set to %NULL, so that it becomes a
9116 // self-contained list with one element.
9117 // RETURNS: the new start of the #GSList, without the element
9118 // <list>: a #GSList
9119 // <link_>: an element in the #GSList
9120 static GLib2.SList* remove_link()(GLib2.SList* list, GLib2.SList* link_) {
9121 return g_slist_remove_link(list, link_);
9124 // Unintrospectable function: reverse() / g_slist_reverse()
9125 // Reverses a #GSList.
9126 // RETURNS: the start of the reversed #GSList
9127 // <list>: a #GSList
9128 static GLib2.SList* reverse()(GLib2.SList* list) {
9129 return g_slist_reverse(list);
9132 // Unintrospectable function: sort() / g_slist_sort()
9133 // Sorts a #GSList using the given comparison function.
9134 // RETURNS: the start of the sorted #GSList
9135 // <list>: a #GSList
9136 // <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.
9137 static GLib2.SList* sort()(GLib2.SList* list, CompareFunc compare_func) {
9138 return g_slist_sort(list, compare_func);
9141 // Unintrospectable function: sort_with_data() / g_slist_sort_with_data()
9142 // Like g_slist_sort(), but the sort function accepts a user data argument.
9143 // RETURNS: new head of the list
9144 // <list>: a #GSList
9145 // <compare_func>: comparison function
9146 // <user_data>: data to pass to comparison function
9147 static GLib2.SList* sort_with_data()(GLib2.SList* list, CompareDataFunc compare_func, void* user_data) {
9148 return g_slist_sort_with_data(list, compare_func, user_data);
9152 enum double SQRT2 = 1.414214;
9153 enum STR_DELIMITERS = "_-|> <.";
9154 enum int SYSDEF_AF_INET = 2;
9155 enum int SYSDEF_AF_INET6 = 10;
9156 enum int SYSDEF_AF_UNIX = 1;
9157 enum int SYSDEF_MSG_DONTROUTE = 4;
9158 enum int SYSDEF_MSG_OOB = 1;
9159 enum int SYSDEF_MSG_PEEK = 2;
9160 struct Scanner {
9161 void* user_data;
9162 uint max_parse_errors, parse_errors;
9163 char* input_name;
9164 Data* qdata;
9165 ScannerConfig* config;
9166 TokenType token;
9167 TokenValue value;
9168 uint line, position;
9169 TokenType next_token;
9170 TokenValue next_value;
9171 uint next_line, next_position;
9172 GLib2.HashTable* symbol_table;
9173 int input_fd;
9174 char* text, text_end, buffer;
9175 uint scope_id;
9176 ScannerMsgFunc msg_handler;
9178 uint cur_line()() {
9179 return g_scanner_cur_line(&this);
9181 uint cur_position()() {
9182 return g_scanner_cur_position(&this);
9184 TokenType cur_token()() {
9185 return g_scanner_cur_token(&this);
9187 // Unintrospectable method: cur_value() / g_scanner_cur_value()
9188 TokenValue cur_value()() {
9189 return g_scanner_cur_value(&this);
9191 void destroy()() {
9192 g_scanner_destroy(&this);
9194 int eof()() {
9195 return g_scanner_eof(&this);
9197 // Unintrospectable method: error() / g_scanner_error()
9198 /+ Not available -- variadic methods unsupported - use the C function directly.
9199 alias g_scanner_error error; // Variadic
9201 TokenType get_next_token()() {
9202 return g_scanner_get_next_token(&this);
9204 void input_file()(int input_fd) {
9205 g_scanner_input_file(&this, input_fd);
9207 void input_text()(char* text, uint text_len) {
9208 g_scanner_input_text(&this, text, text_len);
9210 // Unintrospectable method: lookup_symbol() / g_scanner_lookup_symbol()
9211 void* lookup_symbol()(char* symbol) {
9212 return g_scanner_lookup_symbol(&this, symbol);
9214 TokenType peek_next_token()() {
9215 return g_scanner_peek_next_token(&this);
9217 void scope_add_symbol()(uint scope_id, char* symbol, void* value) {
9218 g_scanner_scope_add_symbol(&this, scope_id, symbol, value);
9220 // Unintrospectable method: scope_foreach_symbol() / g_scanner_scope_foreach_symbol()
9221 void scope_foreach_symbol()(uint scope_id, HFunc func, void* user_data) {
9222 g_scanner_scope_foreach_symbol(&this, scope_id, func, user_data);
9224 // Unintrospectable method: scope_lookup_symbol() / g_scanner_scope_lookup_symbol()
9225 void* scope_lookup_symbol()(uint scope_id, char* symbol) {
9226 return g_scanner_scope_lookup_symbol(&this, scope_id, symbol);
9228 void scope_remove_symbol()(uint scope_id, char* symbol) {
9229 g_scanner_scope_remove_symbol(&this, scope_id, symbol);
9231 uint set_scope()(uint scope_id) {
9232 return g_scanner_set_scope(&this, scope_id);
9234 void sync_file_offset()() {
9235 g_scanner_sync_file_offset(&this);
9237 void unexp_token()(TokenType expected_token, char* identifier_spec, char* symbol_spec, char* symbol_name, char* message, int is_error) {
9238 g_scanner_unexp_token(&this, expected_token, identifier_spec, symbol_spec, symbol_name, message, is_error);
9240 // Unintrospectable method: warn() / g_scanner_warn()
9241 /+ Not available -- variadic methods unsupported - use the C function directly.
9242 alias g_scanner_warn warn; // Variadic
9244 // Unintrospectable function: new() / g_scanner_new()
9245 static Scanner* new_()(ScannerConfig* config_templ) {
9246 return g_scanner_new(config_templ);
9250 struct ScannerConfig {
9251 char* cset_skip_characters, cset_identifier_first, cset_identifier_nth, cpair_comment_single;
9252 static import std.bitmanip; mixin(std.bitmanip.bitfields!(
9253 uint, "case_sensitive", 1,
9254 uint, "skip_comment_multi", 1,
9255 uint, "skip_comment_single", 1,
9256 uint, "scan_comment_multi", 1,
9257 uint, "scan_identifier", 1,
9258 uint, "scan_identifier_1char", 1,
9259 uint, "scan_identifier_NULL", 1,
9260 uint, "scan_symbols", 1,
9261 uint, "scan_binary", 1,
9262 uint, "scan_octal", 1,
9263 uint, "scan_float", 1,
9264 uint, "scan_hex", 1,
9265 uint, "scan_hex_dollar", 1,
9266 uint, "scan_string_sq", 1,
9267 uint, "scan_string_dq", 1,
9268 uint, "numbers_2_int", 1,
9269 uint, "int_2_float", 1,
9270 uint, "identifier_2_string", 1,
9271 uint, "char_2_token", 1,
9272 uint, "symbol_2_token", 1,
9273 uint, "scope_0_fallback", 1,
9274 uint, "store_int64", 1,
9275 uint, "__dummy32A", 10));
9276 uint padding_dummy;
9279 extern (C) alias void function (Scanner* scanner, char* message, int error) ScannerMsgFunc;
9282 // An enumeration specifying the base position for a
9283 // g_io_channel_seek_position() operation.
9284 enum SeekType {
9285 CUR = 0,
9286 SET = 1,
9287 END = 2
9290 // The #GSequence struct is an opaque data type representing a
9291 // <link linkend="glib-Sequences">Sequence</link> data type.
9292 struct Sequence {
9294 // Unintrospectable method: append() / g_sequence_append()
9295 // VERSION: 2.14
9296 // Adds a new item to the end of @seq.
9297 // RETURNS: an iterator pointing to the new item
9298 // <data>: the data for the new item
9299 SequenceIter* append()(void* data) {
9300 return g_sequence_append(&this, data);
9303 // Unintrospectable method: foreach() / g_sequence_foreach()
9304 // VERSION: 2.14
9305 // Calls @func for each item in the sequence passing @user_data
9306 // to the function.
9307 // <func>: the function to call for each item in @seq
9308 // <user_data>: user data passed to @func
9309 void foreach_()(Func func, void* user_data) {
9310 g_sequence_foreach(&this, func, user_data);
9313 // VERSION: 2.14
9314 // Frees the memory allocated for @seq. If @seq has a data destroy
9315 // function associated with it, that function is called on all items in
9316 // @seq.
9317 void free()() {
9318 g_sequence_free(&this);
9321 // Unintrospectable method: get_begin_iter() / g_sequence_get_begin_iter()
9322 // VERSION: 2.14
9323 // Returns the begin iterator for @seq.
9324 // RETURNS: the begin iterator for @seq.
9325 SequenceIter* get_begin_iter()() {
9326 return g_sequence_get_begin_iter(&this);
9329 // Unintrospectable method: get_end_iter() / g_sequence_get_end_iter()
9330 // VERSION: 2.14
9331 // Returns the end iterator for @seg
9332 // RETURNS: the end iterator for @seq
9333 SequenceIter* get_end_iter()() {
9334 return g_sequence_get_end_iter(&this);
9337 // Unintrospectable method: get_iter_at_pos() / g_sequence_get_iter_at_pos()
9338 // VERSION: 2.14
9339 // Returns the iterator at position @pos. If @pos is negative or larger
9340 // than the number of items in @seq, the end iterator is returned.
9341 // RETURNS: The #GSequenceIter at position @pos
9342 // <pos>: a position in @seq, or -1 for the end.
9343 SequenceIter* get_iter_at_pos()(int pos) {
9344 return g_sequence_get_iter_at_pos(&this, pos);
9347 // VERSION: 2.14
9348 // Returns the length of @seq
9349 // RETURNS: the length of @seq
9350 int get_length()() {
9351 return g_sequence_get_length(&this);
9354 // Unintrospectable method: insert_sorted() / g_sequence_insert_sorted()
9355 // VERSION: 2.14
9356 // Inserts @data into @sequence using @func to determine the new
9357 // position. The sequence must already be sorted according to @cmp_func;
9358 // otherwise the new position of @data is undefined.
9360 // @cmp_func is called with two items of the @seq and @user_data.
9361 // It should return 0 if the items are equal, a negative value
9362 // if the first item comes before the second, and a positive value
9363 // if the second item comes before the first.
9364 // RETURNS: a #GSequenceIter pointing to the new item.
9365 // <data>: the data to insert
9366 // <cmp_func>: the function used to compare items in the sequence
9367 // <cmp_data>: user data passed to @cmp_func.
9368 SequenceIter* insert_sorted()(void* data, CompareDataFunc cmp_func, void* cmp_data) {
9369 return g_sequence_insert_sorted(&this, data, cmp_func, cmp_data);
9372 // Unintrospectable method: insert_sorted_iter() / g_sequence_insert_sorted_iter()
9373 // VERSION: 2.14
9374 // Like g_sequence_insert_sorted(), but uses
9375 // a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as
9376 // the compare function.
9378 // @iter_cmp is called with two iterators pointing into @seq.
9379 // It should return 0 if the iterators are equal, a negative
9380 // value if the first iterator comes before the second, and a
9381 // positive value if the second iterator comes before the first.
9383 // It is called with two iterators pointing into @seq. It should
9384 // return 0 if the iterators are equal, a negative value if the
9385 // first iterator comes before the second, and a positive value
9386 // if the second iterator comes before the first.
9387 // RETURNS: a #GSequenceIter pointing to the new item
9388 // <data>: data for the new item
9389 // <iter_cmp>: the function used to compare iterators in the sequence
9390 // <cmp_data>: user data passed to @cmp_func
9391 SequenceIter* insert_sorted_iter()(void* data, SequenceIterCompareFunc iter_cmp, void* cmp_data) {
9392 return g_sequence_insert_sorted_iter(&this, data, iter_cmp, cmp_data);
9395 // Unintrospectable method: lookup() / g_sequence_lookup()
9396 // VERSION: 2.28
9397 // Returns an iterator pointing to the position of the first item found
9398 // equal to @data according to @cmp_func and @cmp_data. If more than one
9399 // item is equal, it is not guaranteed that it is the first which is
9400 // returned. In that case, you can use g_sequence_iter_next() and
9401 // g_sequence_iter_prev() to get others.
9403 // @cmp_func is called with two items of the @seq and @user_data.
9404 // It should return 0 if the items are equal, a negative value if
9405 // the first item comes before the second, and a positive value if
9406 // the second item comes before the first.
9408 // first item found equal to @data according to @cmp_func and @cmp_data.
9409 // RETURNS: an #GSequenceIter pointing to the position of the
9410 // <data>: data to lookup
9411 // <cmp_func>: the function used to compare items in the sequence
9412 // <cmp_data>: user data passed to @cmp_func.
9413 SequenceIter* lookup()(void* data, CompareDataFunc cmp_func, void* cmp_data) {
9414 return g_sequence_lookup(&this, data, cmp_func, cmp_data);
9417 // Unintrospectable method: lookup_iter() / g_sequence_lookup_iter()
9418 // VERSION: 2.28
9419 // Like g_sequence_lookup(), but uses a #GSequenceIterCompareFunc
9420 // instead of a #GCompareDataFunc as the compare function.
9422 // @iter_cmp is called with two iterators pointing into @seq.
9423 // It should return 0 if the iterators are equal, a negative value
9424 // if the first iterator comes before the second, and a positive
9425 // value if the second iterator comes before the first.
9427 // the first item found equal to @data according to @cmp_func
9428 // and @cmp_data.
9429 // RETURNS: an #GSequenceIter pointing to the position of
9430 // <data>: data to lookup
9431 // <iter_cmp>: the function used to compare iterators in the sequence
9432 // <cmp_data>: user data passed to @iter_cmp
9433 SequenceIter* lookup_iter()(void* data, SequenceIterCompareFunc iter_cmp, void* cmp_data) {
9434 return g_sequence_lookup_iter(&this, data, iter_cmp, cmp_data);
9437 // Unintrospectable method: prepend() / g_sequence_prepend()
9438 // VERSION: 2.14
9439 // Adds a new item to the front of @seq
9440 // RETURNS: an iterator pointing to the new item
9441 // <data>: the data for the new item
9442 SequenceIter* prepend()(void* data) {
9443 return g_sequence_prepend(&this, data);
9446 // Unintrospectable method: search() / g_sequence_search()
9447 // VERSION: 2.14
9448 // Returns an iterator pointing to the position where @data would
9449 // be inserted according to @cmp_func and @cmp_data.
9451 // @cmp_func is called with two items of the @seq and @user_data.
9452 // It should return 0 if the items are equal, a negative value if
9453 // the first item comes before the second, and a positive value if
9454 // the second item comes before the first.
9456 // If you are simply searching for an existing element of the sequence,
9457 // consider using g_sequence_lookup().
9459 // would have been inserted according to @cmp_func and @cmp_data.
9460 // RETURNS: an #GSequenceIter pointing to the position where @data
9461 // <data>: data for the new item
9462 // <cmp_func>: the function used to compare items in the sequence
9463 // <cmp_data>: user data passed to @cmp_func.
9464 SequenceIter* search()(void* data, CompareDataFunc cmp_func, void* cmp_data) {
9465 return g_sequence_search(&this, data, cmp_func, cmp_data);
9468 // Unintrospectable method: search_iter() / g_sequence_search_iter()
9469 // VERSION: 2.14
9470 // Like g_sequence_search(), but uses a #GSequenceIterCompareFunc
9471 // instead of a #GCompareDataFunc as the compare function.
9473 // @iter_cmp is called with two iterators pointing into @seq.
9474 // It should return 0 if the iterators are equal, a negative value
9475 // if the first iterator comes before the second, and a positive
9476 // value if the second iterator comes before the first.
9478 // If you are simply searching for an existing element of the sequence,
9479 // consider using g_sequence_lookup_iter().
9481 // where @data would have been inserted according to @iter_cmp
9482 // and @cmp_data.
9483 // RETURNS: a #GSequenceIter pointing to the position in @seq
9484 // <data>: data for the new item
9485 // <iter_cmp>: the function used to compare iterators in the sequence
9486 // <cmp_data>: user data passed to @iter_cmp
9487 SequenceIter* search_iter()(void* data, SequenceIterCompareFunc iter_cmp, void* cmp_data) {
9488 return g_sequence_search_iter(&this, data, iter_cmp, cmp_data);
9491 // Unintrospectable method: sort() / g_sequence_sort()
9492 // VERSION: 2.14
9493 // Sorts @seq using @cmp_func.
9495 // @cmp_func is passed two items of @seq and should
9496 // return 0 if they are equal, a negative value if the
9497 // first comes before the second, and a positive value
9498 // if the second comes before the first.
9499 // <cmp_func>: the function used to sort the sequence
9500 // <cmp_data>: user data passed to @cmp_func
9501 void sort()(CompareDataFunc cmp_func, void* cmp_data) {
9502 g_sequence_sort(&this, cmp_func, cmp_data);
9505 // Unintrospectable method: sort_iter() / g_sequence_sort_iter()
9506 // VERSION: 2.14
9507 // Like g_sequence_sort(), but uses a #GSequenceIterCompareFunc instead
9508 // of a GCompareDataFunc as the compare function
9510 // @cmp_func is called with two iterators pointing into @seq. It should
9511 // return 0 if the iterators are equal, a negative value if the first
9512 // iterator comes before the second, and a positive value if the second
9513 // iterator comes before the first.
9514 // <cmp_func>: the function used to compare iterators in the sequence
9515 // <cmp_data>: user data passed to @cmp_func
9516 void sort_iter()(SequenceIterCompareFunc cmp_func, void* cmp_data) {
9517 g_sequence_sort_iter(&this, cmp_func, cmp_data);
9520 // Unintrospectable function: foreach_range() / g_sequence_foreach_range()
9521 // VERSION: 2.14
9522 // Calls @func for each item in the range (@begin, @end) passing
9523 // @user_data to the function.
9524 // <begin>: a #GSequenceIter
9525 // <end>: a #GSequenceIter
9526 // <func>: a #GFunc
9527 // <user_data>: user data passed to @func
9528 static void foreach_range()(SequenceIter* begin, SequenceIter* end, Func func, void* user_data) {
9529 g_sequence_foreach_range(begin, end, func, user_data);
9532 // Unintrospectable function: get() / g_sequence_get()
9533 // VERSION: 2.14
9534 // Returns the data that @iter points to.
9535 // RETURNS: the data that @iter points to
9536 // <iter>: a #GSequenceIter
9537 static void* get()(SequenceIter* iter) {
9538 return g_sequence_get(iter);
9541 // Unintrospectable function: insert_before() / g_sequence_insert_before()
9542 // VERSION: 2.14
9543 // Inserts a new item just before the item pointed to by @iter.
9544 // RETURNS: an iterator pointing to the new item
9545 // <iter>: a #GSequenceIter
9546 // <data>: the data for the new item
9547 static SequenceIter* insert_before()(SequenceIter* iter, void* data) {
9548 return g_sequence_insert_before(iter, data);
9551 // VERSION: 2.14
9552 // Moves the item pointed to by @src to the position indicated by @dest.
9553 // After calling this function @dest will point to the position immediately
9554 // after @src. It is allowed for @src and @dest to point into different
9555 // sequences.
9556 // <src>: a #GSequenceIter pointing to the item to move
9557 // <dest>: a #GSequenceIter pointing to the position to which the item is moved.
9558 static void move()(SequenceIter* src, SequenceIter* dest) {
9559 g_sequence_move(src, dest);
9562 // VERSION: 2.14
9563 // Inserts the (@begin, @end) range at the destination pointed to by ptr.
9564 // The @begin and @end iters must point into the same sequence. It is
9565 // allowed for @dest to point to a different sequence than the one pointed
9566 // into by @begin and @end.
9568 // If @dest is NULL, the range indicated by @begin and @end is
9569 // removed from the sequence. If @dest iter points to a place within
9570 // the (@begin, @end) range, the range does not move.
9571 // <dest>: a #GSequenceIter
9572 // <begin>: a #GSequenceIter
9573 // <end>: a #GSequenceIter
9574 static void move_range()(SequenceIter* dest, SequenceIter* begin, SequenceIter* end) {
9575 g_sequence_move_range(dest, begin, end);
9578 // Unintrospectable function: new() / g_sequence_new()
9579 // VERSION: 2.14
9580 // Creates a new GSequence. The @data_destroy function, if non-%NULL will
9581 // be called on all items when the sequence is destroyed and on items that
9582 // are removed from the sequence.
9583 // RETURNS: a new #GSequence
9584 // <data_destroy>: a #GDestroyNotify function, or %NULL
9585 static Sequence* new_()(DestroyNotify data_destroy) {
9586 return g_sequence_new(data_destroy);
9589 // Unintrospectable function: range_get_midpoint() / g_sequence_range_get_midpoint()
9590 // VERSION: 2.14
9591 // Finds an iterator somewhere in the range (@begin, @end). This
9592 // iterator will be close to the middle of the range, but is not
9593 // guaranteed to be <emphasis>exactly</emphasis> in the middle.
9595 // The @begin and @end iterators must both point to the same sequence and
9596 // @begin must come before or be equal to @end in the sequence.
9598 // (@begin, @end) range.
9599 // RETURNS: A #GSequenceIter pointing somewhere in the
9600 // <begin>: a #GSequenceIter
9601 // <end>: a #GSequenceIter
9602 static SequenceIter* range_get_midpoint()(SequenceIter* begin, SequenceIter* end) {
9603 return g_sequence_range_get_midpoint(begin, end);
9606 // VERSION: 2.14
9607 // Removes the item pointed to by @iter. It is an error to pass the
9608 // end iterator to this function.
9610 // If the sequnce has a data destroy function associated with it, this
9611 // function is called on the data for the removed item.
9612 // <iter>: a #GSequenceIter
9613 static void remove()(SequenceIter* iter) {
9614 g_sequence_remove(iter);
9617 // VERSION: 2.14
9618 // Removes all items in the (@begin, @end) range.
9620 // If the sequence has a data destroy function associated with it, this
9621 // function is called on the data for the removed items.
9622 // <begin>: a #GSequenceIter
9623 // <end>: a #GSequenceIter
9624 static void remove_range()(SequenceIter* begin, SequenceIter* end) {
9625 g_sequence_remove_range(begin, end);
9628 // VERSION: 2.14
9629 // Changes the data for the item pointed to by @iter to be @data. If
9630 // the sequence has a data destroy function associated with it, that
9631 // function is called on the existing data that @iter pointed to.
9632 // <iter>: a #GSequenceIter
9633 // <data>: new data for the item
9634 static void set()(SequenceIter* iter, void* data) {
9635 g_sequence_set(iter, data);
9638 // Unintrospectable function: sort_changed() / g_sequence_sort_changed()
9639 // VERSION: 2.14
9640 // Moves the data pointed to a new position as indicated by @cmp_func. This
9641 // function should be called for items in a sequence already sorted according
9642 // to @cmp_func whenever some aspect of an item changes so that @cmp_func
9643 // may return different values for that item.
9645 // @cmp_func is called with two items of the @seq and @user_data.
9646 // It should return 0 if the items are equal, a negative value if
9647 // the first item comes before the second, and a positive value if
9648 // the second item comes before the first.
9649 // <iter>: A #GSequenceIter
9650 // <cmp_func>: the function used to compare items in the sequence
9651 // <cmp_data>: user data passed to @cmp_func.
9652 static void sort_changed()(SequenceIter* iter, CompareDataFunc cmp_func, void* cmp_data) {
9653 g_sequence_sort_changed(iter, cmp_func, cmp_data);
9656 // Unintrospectable function: sort_changed_iter() / g_sequence_sort_changed_iter()
9657 // VERSION: 2.14
9658 // Like g_sequence_sort_changed(), but uses
9659 // a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as
9660 // the compare function.
9662 // @iter_cmp is called with two iterators pointing into @seq. It should
9663 // return 0 if the iterators are equal, a negative value if the first
9664 // iterator comes before the second, and a positive value if the second
9665 // iterator comes before the first.
9666 // <iter>: a #GSequenceIter
9667 // <iter_cmp>: the function used to compare iterators in the sequence
9668 // <cmp_data>: user data passed to @cmp_func
9669 static void sort_changed_iter()(SequenceIter* iter, SequenceIterCompareFunc iter_cmp, void* cmp_data) {
9670 g_sequence_sort_changed_iter(iter, iter_cmp, cmp_data);
9673 // VERSION: 2.14
9674 // Swaps the items pointed to by @a and @b. It is allowed for @a and @b
9675 // to point into difference sequences.
9676 // <a>: a #GSequenceIter
9677 // <b>: a #GSequenceIter
9678 static void swap()(SequenceIter* a, SequenceIter* b) {
9679 g_sequence_swap(a, b);
9684 // The #GSequenceIter struct is an opaque data type representing an
9685 // iterator pointing into a #GSequence.
9686 struct SequenceIter {
9688 // VERSION: 2.14
9689 // Returns a negative number if @a comes before @b, 0 if they are equal,
9690 // and a positive number if @a comes after @b.
9692 // The @a and @b iterators must point into the same sequence.
9694 // equal, and a positive number if @a comes after @b.
9695 // RETURNS: A negative number if @a comes before @b, 0 if they are
9696 // <b>: a #GSequenceIter
9697 int compare()(SequenceIter* b) {
9698 return g_sequence_iter_compare(&this, b);
9701 // VERSION: 2.14
9702 // Returns the position of @iter
9703 // RETURNS: the position of @iter
9704 int get_position()() {
9705 return g_sequence_iter_get_position(&this);
9708 // Unintrospectable method: get_sequence() / g_sequence_iter_get_sequence()
9709 // VERSION: 2.14
9710 // Returns the #GSequence that @iter points into.
9711 // RETURNS: the #GSequence that @iter points into.
9712 Sequence* get_sequence()() {
9713 return g_sequence_iter_get_sequence(&this);
9716 // VERSION: 2.14
9717 // Returns whether @iter is the begin iterator
9718 // RETURNS: whether @iter is the begin iterator
9719 int is_begin()() {
9720 return g_sequence_iter_is_begin(&this);
9723 // VERSION: 2.14
9724 // Returns whether @iter is the end iterator
9725 // RETURNS: Whether @iter is the end iterator.
9726 int is_end()() {
9727 return g_sequence_iter_is_end(&this);
9730 // Unintrospectable method: move() / g_sequence_iter_move()
9731 // VERSION: 2.14
9732 // Returns the #GSequenceIter which is @delta positions away from @iter.
9733 // If @iter is closer than -@delta positions to the beginning of the sequence,
9734 // the begin iterator is returned. If @iter is closer than @delta positions
9735 // to the end of the sequence, the end iterator is returned.
9736 // RETURNS: a #GSequenceIter which is @delta positions away from @iter.
9737 // <delta>: A positive or negative number indicating how many positions away from @iter the returned #GSequenceIter will be.
9738 SequenceIter* move()(int delta) {
9739 return g_sequence_iter_move(&this, delta);
9742 // Unintrospectable method: next() / g_sequence_iter_next()
9743 // VERSION: 2.14
9744 // Returns an iterator pointing to the next position after @iter. If
9745 // @iter is the end iterator, the end iterator is returned.
9746 // RETURNS: a #GSequenceIter pointing to the next position after @iter.
9747 SequenceIter* next()() {
9748 return g_sequence_iter_next(&this);
9751 // Unintrospectable method: prev() / g_sequence_iter_prev()
9752 // VERSION: 2.14
9753 // Returns an iterator pointing to the previous position before @iter. If
9754 // @iter is the begin iterator, the begin iterator is returned.
9756 // @iter.
9757 // RETURNS: a #GSequenceIter pointing to the previous position before
9758 SequenceIter* prev()() {
9759 return g_sequence_iter_prev(&this);
9764 // A #GSequenceIterCompareFunc is a function used to compare iterators.
9765 // It must return zero if the iterators compare equal, a negative value
9766 // if @a comes before @b, and a positive value if @b comes before @a.
9767 // <a>: a #GSequenceIter
9768 // <b>: a #GSequenceIter
9769 // <data>: user data
9770 extern (C) alias int function (SequenceIter* a, SequenceIter* b, void* data) SequenceIterCompareFunc;
9772 // Error codes returned by shell functions.
9773 enum ShellError {
9774 BAD_QUOTING = 0,
9775 EMPTY_STRING = 1,
9776 FAILED = 2
9778 enum SliceConfig {
9779 ALWAYS_MALLOC = 1,
9780 BYPASS_MAGAZINES = 2,
9781 WORKING_SET_MSECS = 3,
9782 COLOR_INCREMENT = 4,
9783 CHUNK_SIZES = 5,
9784 CONTENTION_COUNTER = 6
9787 // The <structname>GSource</structname> struct is an opaque data type
9788 // representing an event source.
9789 struct Source {
9790 private void* callback_data;
9791 private SourceCallbackFuncs* callback_funcs;
9792 private SourceFuncs* source_funcs;
9793 private uint ref_count;
9794 private MainContext* context;
9795 private int priority;
9796 private uint flags, source_id;
9797 private GLib2.SList* poll_fds;
9798 private Source* prev, next;
9799 private char* name;
9800 private SourcePrivate* priv;
9803 // Creates a new #GSource structure. The size is specified to
9804 // allow creating structures derived from #GSource that contain
9805 // additional data. The size passed in must be at least
9806 // <literal>sizeof (GSource)</literal>.
9808 // The source will not initially be associated with any #GMainContext
9809 // and must be added to one with g_source_attach() before it will be
9810 // executed.
9811 // RETURNS: the newly-created #GSource.
9812 // <source_funcs>: structure containing functions that implement the sources behavior.
9813 // <struct_size>: size of the #GSource structure to create.
9814 static Source* /*new*/ new_()(SourceFuncs* source_funcs, uint struct_size) {
9815 return g_source_new(source_funcs, struct_size);
9818 // VERSION: 2.28
9819 // Adds @child_source to @source as a "polled" source; when @source is
9820 // added to a #GMainContext, @child_source will be automatically added
9821 // with the same priority, when @child_source is triggered, it will
9822 // cause @source to dispatch (in addition to calling its own
9823 // callback), and when @source is destroyed, it will destroy
9824 // @child_source as well. (@source will also still be dispatched if
9825 // its own prepare/check functions indicate that it is ready.)
9827 // If you don't need @child_source to do anything on its own when it
9828 // triggers, you can call g_source_set_dummy_callback() on it to set a
9829 // callback that does nothing (except return %TRUE if appropriate).
9831 // @source will hold a reference on @child_source while @child_source
9832 // is attached to it.
9833 // <child_source>: a second #GSource that @source should "poll"
9834 void add_child_source()(Source* child_source) {
9835 g_source_add_child_source(&this, child_source);
9838 // Adds a file descriptor to the set of file descriptors polled for
9839 // this source. This is usually combined with g_source_new() to add an
9840 // event source. The event source's check function will typically test
9841 // the @revents field in the #GPollFD struct and return %TRUE if events need
9842 // to be processed.
9843 // <fd>: a #GPollFD structure holding information about a file descriptor to watch.
9844 void add_poll()(PollFD* fd) {
9845 g_source_add_poll(&this, fd);
9848 // Adds a #GSource to a @context so that it will be executed within
9849 // that context. Remove it by calling g_source_destroy().
9851 // #GMainContext.
9852 // RETURNS: the ID (greater than 0) for the source within the
9853 // <context>: a #GMainContext (if %NULL, the default context will be used)
9854 uint attach()(MainContext* context) {
9855 return g_source_attach(&this, context);
9858 // Removes a source from its #GMainContext, if any, and mark it as
9859 // destroyed. The source cannot be subsequently added to another
9860 // context.
9861 void destroy()() {
9862 g_source_destroy(&this);
9865 // Checks whether a source is allowed to be called recursively.
9866 // see g_source_set_can_recurse().
9867 // RETURNS: whether recursion is allowed.
9868 int get_can_recurse()() {
9869 return g_source_get_can_recurse(&this);
9872 // Gets the #GMainContext with which the source is associated.
9873 // Calling this function on a destroyed source is an error.
9875 // source is associated, or %NULL if the context has not
9876 // yet been added to a source.
9877 // RETURNS: the #GMainContext with which the
9878 MainContext* get_context()() {
9879 return g_source_get_context(&this);
9882 // DEPRECATED (v2.28) method: get_current_time - use g_source_get_time() instead
9883 // Gets the "current time" to be used when checking
9884 // this source. The advantage of calling this function over
9885 // calling g_get_current_time() directly is that when
9886 // checking multiple sources, GLib can cache a single value
9887 // instead of having to repeatedly get the system time.
9888 // <timeval>: #GTimeVal structure in which to store current time.
9889 void get_current_time()(TimeVal* timeval) {
9890 g_source_get_current_time(&this, timeval);
9893 // Returns the numeric ID for a particular source. The ID of a source
9894 // is a positive integer which is unique within a particular main loop
9895 // context. The reverse
9896 // mapping from ID to source is done by g_main_context_find_source_by_id().
9897 // RETURNS: the ID (greater than 0) for the source
9898 uint get_id()() {
9899 return g_source_get_id(&this);
9902 // VERSION: 2.26
9903 // Gets a name for the source, used in debugging and profiling.
9904 // The name may be #NULL if it has never been set with
9905 // g_source_set_name().
9906 // RETURNS: the name of the source
9907 char* get_name()() {
9908 return g_source_get_name(&this);
9911 // Gets the priority of a source.
9912 // RETURNS: the priority of the source
9913 int get_priority()() {
9914 return g_source_get_priority(&this);
9917 // VERSION: 2.28
9918 // Gets the time to be used when checking this source. The advantage of
9919 // calling this function over calling g_get_monotonic_time() directly is
9920 // that when checking multiple sources, GLib can cache a single value
9921 // instead of having to repeatedly get the system monotonic time.
9923 // The time here is the system monotonic time, if available, or some
9924 // other reasonable alternative otherwise. See g_get_monotonic_time().
9925 // RETURNS: the monotonic time in microseconds
9926 long get_time()() {
9927 return g_source_get_time(&this);
9930 // VERSION: 2.12
9931 // Returns whether @source has been destroyed.
9933 // This is important when you operate upon your objects
9934 // from within idle handlers, but may have freed the object
9935 // before the dispatch of your idle handler.
9937 // |[
9938 // static gboolean
9939 // idle_callback (gpointer data)
9940 // {
9941 // SomeWidget *self = data;
9943 // GDK_THREADS_ENTER (<!-- -->);
9944 // /<!-- -->* do stuff with self *<!-- -->/
9945 // self->idle_id = 0;
9946 // GDK_THREADS_LEAVE (<!-- -->);
9948 // return FALSE;
9949 // }
9951 // static void
9952 // some_widget_do_stuff_later (SomeWidget *self)
9953 // {
9954 // self->idle_id = g_idle_add (idle_callback, self);
9955 // }
9957 // static void
9958 // some_widget_finalize (GObject *object)
9959 // {
9960 // SomeWidget *self = SOME_WIDGET (object);
9962 // if (self->idle_id)
9963 // g_source_remove (self->idle_id);
9965 // G_OBJECT_CLASS (parent_class)->finalize (object);
9966 // }
9967 // ]|
9969 // This will fail in a multi-threaded application if the
9970 // widget is destroyed before the idle handler fires due
9971 // to the use after free in the callback. A solution, to
9972 // this particular problem, is to check to if the source
9973 // has already been destroy within the callback.
9975 // |[
9976 // static gboolean
9977 // idle_callback (gpointer data)
9978 // {
9979 // SomeWidget *self = data;
9981 // GDK_THREADS_ENTER ();
9982 // if (!g_source_is_destroyed (g_main_current_source ()))
9983 // {
9984 // /<!-- -->* do stuff with self *<!-- -->/
9985 // }
9986 // GDK_THREADS_LEAVE ();
9988 // return FALSE;
9989 // }
9990 // ]|
9991 // RETURNS: %TRUE if the source has been destroyed
9992 int is_destroyed()() {
9993 return g_source_is_destroyed(&this);
9996 // Increases the reference count on a source by one.
9997 // RETURNS: @source
9998 Source* /*new*/ ref_()() {
9999 return g_source_ref(&this);
10002 // VERSION: 2.28
10003 // Detaches @child_source from @source and destroys it.
10004 // <child_source>: a #GSource previously passed to g_source_add_child_source().
10005 void remove_child_source()(Source* child_source) {
10006 g_source_remove_child_source(&this, child_source);
10009 // Removes a file descriptor from the set of file descriptors polled for
10010 // this source.
10011 // <fd>: a #GPollFD structure previously passed to g_source_add_poll().
10012 void remove_poll()(PollFD* fd) {
10013 g_source_remove_poll(&this, fd);
10016 // Sets the callback function for a source. The callback for a source is
10017 // called from the source's dispatch function.
10019 // The exact type of @func depends on the type of source; ie. you
10020 // should not count on @func being called with @data as its first
10021 // parameter.
10023 // Typically, you won't use this function. Instead use functions specific
10024 // to the type of source you are using.
10025 // <func>: a callback function
10026 // <data>: the data to pass to callback function
10027 // <notify>: a function to call when @data is no longer in use, or %NULL.
10028 void set_callback()(SourceFunc func, void* data, DestroyNotify notify) {
10029 g_source_set_callback(&this, func, data, notify);
10032 // Sets the callback function storing the data as a refcounted callback
10033 // "object". This is used internally. Note that calling
10034 // g_source_set_callback_indirect() assumes
10035 // an initial reference count on @callback_data, and thus
10036 // @callback_funcs->unref will eventually be called once more
10037 // than @callback_funcs->ref.
10038 // <callback_data>: pointer to callback data "object"
10039 // <callback_funcs>: functions for reference counting @callback_data and getting the callback and data
10040 void set_callback_indirect()(void* callback_data, SourceCallbackFuncs* callback_funcs) {
10041 g_source_set_callback_indirect(&this, callback_data, callback_funcs);
10044 // Sets whether a source can be called recursively. If @can_recurse is
10045 // %TRUE, then while the source is being dispatched then this source
10046 // will be processed normally. Otherwise, all processing of this
10047 // source is blocked until the dispatch function returns.
10048 // <can_recurse>: whether recursion is allowed for this source
10049 void set_can_recurse()(int can_recurse) {
10050 g_source_set_can_recurse(&this, can_recurse);
10053 // VERSION: 2.12
10054 // Sets the source functions (can be used to override
10055 // default implementations) of an unattached source.
10056 // <funcs>: the new #GSourceFuncs
10057 void set_funcs()(SourceFuncs* funcs) {
10058 g_source_set_funcs(&this, funcs);
10061 // VERSION: 2.26
10062 // Sets a name for the source, used in debugging and profiling.
10063 // The name defaults to #NULL.
10065 // The source name should describe in a human-readable way
10066 // what the source does. For example, "X11 event queue"
10067 // or "GTK+ repaint idle handler" or whatever it is.
10069 // It is permitted to call this function multiple times, but is not
10070 // recommended due to the potential performance impact. For example,
10071 // one could change the name in the "check" function of a #GSourceFuncs
10072 // to include details like the event type in the source name.
10073 // <name>: debug name for the source
10074 void set_name()(char* name) {
10075 g_source_set_name(&this, name);
10078 // Sets the priority of a source. While the main loop is being run, a
10079 // source will be dispatched if it is ready to be dispatched and no
10080 // sources at a higher (numerically smaller) priority are ready to be
10081 // dispatched.
10082 // <priority>: the new priority.
10083 void set_priority()(int priority) {
10084 g_source_set_priority(&this, priority);
10087 // Decreases the reference count of a source by one. If the
10088 // resulting reference count is zero the source and associated
10089 // memory will be destroyed.
10090 void unref()() {
10091 g_source_unref(&this);
10094 // Removes the source with the given id from the default main context.
10095 // The id of
10096 // a #GSource is given by g_source_get_id(), or will be returned by the
10097 // functions g_source_attach(), g_idle_add(), g_idle_add_full(),
10098 // g_timeout_add(), g_timeout_add_full(), g_child_watch_add(),
10099 // g_child_watch_add_full(), g_io_add_watch(), and g_io_add_watch_full().
10101 // See also g_source_destroy(). You must use g_source_destroy() for sources
10102 // added to a non-default main context.
10103 // RETURNS: %TRUE if the source was found and removed.
10104 // <tag>: the ID of the source to remove.
10105 static int remove()(uint tag) {
10106 return g_source_remove(tag);
10109 // Removes a source from the default main loop context given the
10110 // source functions and user data. If multiple sources exist with the
10111 // same source functions and user data, only one will be destroyed.
10112 // RETURNS: %TRUE if a source was found and removed.
10113 // <funcs>: The @source_funcs passed to g_source_new()
10114 // <user_data>: the user data for the callback
10115 static int remove_by_funcs_user_data()(SourceFuncs* funcs, void* user_data) {
10116 return g_source_remove_by_funcs_user_data(funcs, user_data);
10119 // Removes a source from the default main loop context given the user
10120 // data for the callback. If multiple sources exist with the same user
10121 // data, only one will be destroyed.
10122 // RETURNS: %TRUE if a source was found and removed.
10123 // <user_data>: the user_data for the callback.
10124 static int remove_by_user_data()(void* user_data) {
10125 return g_source_remove_by_user_data(user_data);
10128 // VERSION: 2.26
10129 // Sets the name of a source using its ID.
10131 // This is a convenience utility to set source names from the return
10132 // value of g_idle_add(), g_timeout_add(), etc.
10133 // <tag>: a #GSource ID
10134 // <name>: debug name for the source
10135 static void set_name_by_id()(uint tag, char* name) {
10136 g_source_set_name_by_id(tag, name);
10140 struct SourceCallbackFuncs {
10141 extern (C) void function (void* cb_data) ref_;
10142 extern (C) void function (void* cb_data) unref;
10143 // Unintrospectable functionp: get() / ()
10144 extern (C) void function (void* cb_data, Source* source, SourceFunc* func, void** data) get;
10148 // This is just a placeholder for #GClosureMarshal,
10149 // which cannot be used here for dependency reasons.
10150 extern (C) alias void function () SourceDummyMarshal;
10153 // Specifies the type of function passed to g_timeout_add(),
10154 // g_timeout_add_full(), g_idle_add(), and g_idle_add_full().
10155 // RETURNS: %FALSE if the source should be removed
10156 // <user_data>: data passed to the function, set when the source was created with one of the above functions
10157 extern (C) alias int function (void* user_data) SourceFunc;
10160 // The <structname>GSourceFuncs</structname> struct contains a table of
10161 // functions used to handle event sources in a generic manner.
10163 // For idle sources, the prepare and check functions always return %TRUE
10164 // to indicate that the source is always ready to be processed. The prepare
10165 // function also returns a timeout value of 0 to ensure that the poll() call
10166 // doesn't block (since that would be time wasted which could have been spent
10167 // running the idle function).
10169 // For timeout sources, the prepare and check functions both return %TRUE
10170 // if the timeout interval has expired. The prepare function also returns
10171 // a timeout value to ensure that the poll() call doesn't block too long
10172 // and miss the next timeout.
10174 // For file descriptor sources, the prepare function typically returns %FALSE,
10175 // since it must wait until poll() has been called before it knows whether
10176 // any events need to be processed. It sets the returned timeout to -1 to
10177 // indicate that it doesn't mind how long the poll() call blocks. In the
10178 // check function, it tests the results of the poll() call to see if the
10179 // required condition has been met, and returns %TRUE if so.
10180 struct SourceFuncs {
10181 extern (C) int function (Source* source, int* timeout_) prepare;
10182 extern (C) int function (Source* source) check;
10183 // Unintrospectable functionp: dispatch() / ()
10184 extern (C) int function (Source* source, SourceFunc callback, void* user_data) dispatch;
10185 extern (C) void function (Source* source) finalize;
10186 SourceFunc closure_callback;
10187 SourceDummyMarshal closure_marshal;
10190 struct SourcePrivate {
10194 // Specifies the type of the setup function passed to g_spawn_async(),
10195 // g_spawn_sync() and g_spawn_async_with_pipes(). On POSIX platforms it
10196 // is called in the child after GLib has performed all the setup it plans
10197 // to perform but before calling exec(). On POSIX actions taken in this
10198 // function will thus only affect the child, not the parent.
10200 // Note that POSIX allows only async-signal-safe functions (see signal(7))
10201 // to be called in the child between fork() and exec(), which drastically
10202 // limits the usefulness of child setup functions.
10204 // Also note that modifying the environment from the child setup function
10205 // may not have the intended effect, since it will get overridden by
10206 // a non-%NULL @env argument to the <literal>g_spawn...</literal> functions.
10208 // On Windows the function is called in the parent. Its usefulness on
10209 // Windows is thus questionable. In many cases executing the child setup
10210 // function in the parent can have ill effects, and you should be very
10211 // careful when porting software to Windows that uses child setup
10212 // functions.
10213 // <user_data>: user data to pass to the function.
10214 extern (C) alias void function (void* user_data) SpawnChildSetupFunc;
10216 // Error codes returned by spawning processes.
10217 enum SpawnError {
10218 FORK = 0,
10219 READ = 1,
10220 CHDIR = 2,
10221 ACCES = 3,
10222 PERM = 4,
10223 _2BIG = 5,
10224 NOEXEC = 6,
10225 NAMETOOLONG = 7,
10226 NOENT = 8,
10227 NOMEM = 9,
10228 NOTDIR = 10,
10229 LOOP = 11,
10230 TXTBUSY = 12,
10231 IO = 13,
10232 NFILE = 14,
10233 MFILE = 15,
10234 INVAL = 16,
10235 ISDIR = 17,
10236 LIBBAD = 18,
10237 FAILED = 19
10239 // Flags passed to g_spawn_sync(), g_spawn_async() and g_spawn_async_with_pipes().
10240 enum SpawnFlags {
10241 LEAVE_DESCRIPTORS_OPEN = 1,
10242 DO_NOT_REAP_CHILD = 2,
10243 SEARCH_PATH = 4,
10244 STDOUT_TO_DEV_NULL = 8,
10245 STDERR_TO_DEV_NULL = 16,
10246 CHILD_INHERITS_STDIN = 32,
10247 FILE_AND_ARGV_ZERO = 64
10250 // A type corresponding to the appropriate struct type for the stat
10251 // system call, depending on the platform and/or compiler being used.
10253 // See g_stat() for more information.
10254 struct StatBuf {
10258 // A #GStaticMutex works like a #GMutex, but it has one significant
10259 // advantage. It doesn't need to be created at run-time like a #GMutex,
10260 // but can be defined at compile-time. Here is a shorter, easier and
10261 // safer version of our <function>give_me_next_number()</function>
10262 // example:
10264 // <example>
10265 // <title>
10266 // Using <structname>GStaticMutex</structname>
10267 // to simplify thread-safe programming
10268 // </title>
10269 // <programlisting>
10270 // int
10271 // give_me_next_number (void)
10272 // {
10273 // static int current_number = 0;
10274 // int ret_val;
10275 // static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
10277 // g_static_mutex_lock (&amp;mutex);
10278 // ret_val = current_number = calc_next_number (current_number);
10279 // g_static_mutex_unlock (&amp;mutex);
10281 // return ret_val;
10282 // }
10283 // </programlisting>
10284 // </example>
10286 // Sometimes you would like to dynamically create a mutex. If you don't
10287 // want to require prior calling to g_thread_init(), because your code
10288 // should also be usable in non-threaded programs, you are not able to
10289 // use g_mutex_new() and thus #GMutex, as that requires a prior call to
10290 // g_thread_init(). In theses cases you can also use a #GStaticMutex.
10291 // It must be initialized with g_static_mutex_init() before using it
10292 // and freed with with g_static_mutex_free() when not needed anymore to
10293 // free up any allocated resources.
10295 // Even though #GStaticMutex is not opaque, it should only be used with
10296 // the following functions, as it is defined differently on different
10297 // platforms.
10299 // All of the <function>g_static_mutex_*</function> functions apart
10300 // from <function>g_static_mutex_get_mutex</function> can also be used
10301 // even if g_thread_init() has not yet been called. Then they do
10302 // nothing, apart from <function>g_static_mutex_trylock</function>,
10303 // which does nothing but returning %TRUE.
10305 // <note><para>All of the <function>g_static_mutex_*</function>
10306 // functions are actually macros. Apart from taking their addresses, you
10307 // can however use them as if they were functions.</para></note>
10308 struct StaticMutex {
10309 void** runtime_mutex;
10311 union static_mutex {
10312 char[24] pad;
10313 double dummy_double;
10314 void* dummy_pointer;
10315 c_long dummy_long;
10319 // Releases all resources allocated to @mutex.
10321 // You don't have to call this functions for a #GStaticMutex with an
10322 // unbounded lifetime, i.e. objects declared 'static', but if you have
10323 // a #GStaticMutex as a member of a structure and the structure is
10324 // freed, you should also free the #GStaticMutex.
10326 // <note><para>Calling g_static_mutex_free() on a locked mutex may
10327 // result in undefined behaviour.</para></note>
10328 void free()() {
10329 g_static_mutex_free(&this);
10332 // Initializes @mutex. Alternatively you can initialize it with
10333 // #G_STATIC_MUTEX_INIT.
10334 void init()() {
10335 g_static_mutex_init(&this);
10337 // Unintrospectable function: get_mutex_impl() / g_static_mutex_get_mutex_impl()
10338 static Mutex* get_mutex_impl()(Mutex** mutex) {
10339 return g_static_mutex_get_mutex_impl(mutex);
10344 // A #GStaticPrivate works almost like a #GPrivate, but it has one
10345 // significant advantage. It doesn't need to be created at run-time
10346 // like a #GPrivate, but can be defined at compile-time. This is
10347 // similar to the difference between #GMutex and #GStaticMutex. Now
10348 // look at our <function>give_me_next_number()</function> example with
10349 // #GStaticPrivate:
10351 // <example>
10352 // <title>Using GStaticPrivate for per-thread data</title>
10353 // <programlisting>
10354 // int
10355 // give_me_next_number (<!-- -->)
10356 // {
10357 // static GStaticPrivate current_number_key = G_STATIC_PRIVATE_INIT;
10358 // int *current_number = g_static_private_get (&amp;current_number_key);
10360 // if (!current_number)
10361 // {
10362 // current_number = g_new (int,1);
10363 // *current_number = 0;
10364 // g_static_private_set (&amp;current_number_key, current_number, g_free);
10365 // }
10367 // *current_number = calc_next_number (*current_number);
10369 // return *current_number;
10370 // }
10371 // </programlisting>
10372 // </example>
10373 struct StaticPrivate {
10374 private uint index;
10377 // Releases all resources allocated to @private_key.
10379 // You don't have to call this functions for a #GStaticPrivate with an
10380 // unbounded lifetime, i.e. objects declared 'static', but if you have
10381 // a #GStaticPrivate as a member of a structure and the structure is
10382 // freed, you should also free the #GStaticPrivate.
10383 void free()() {
10384 g_static_private_free(&this);
10387 // Unintrospectable method: get() / g_static_private_get()
10388 // Works like g_private_get() only for a #GStaticPrivate.
10390 // This function works even if g_thread_init() has not yet been called.
10391 void* get()() {
10392 return g_static_private_get(&this);
10395 // Initializes @private_key. Alternatively you can initialize it with
10396 // #G_STATIC_PRIVATE_INIT.
10397 void init()() {
10398 g_static_private_init(&this);
10401 // Sets the pointer keyed to @private_key for the current thread and
10402 // the function @notify to be called with that pointer (%NULL or
10403 // non-%NULL), whenever the pointer is set again or whenever the
10404 // current thread ends.
10406 // This function works even if g_thread_init() has not yet been called.
10407 // If g_thread_init() is called later, the @data keyed to @private_key
10408 // will be inherited only by the main thread, i.e. the one that called
10409 // g_thread_init().
10411 // <note><para>@notify is used quite differently from @destructor in
10412 // g_private_new().</para></note>
10413 // <data>: the new pointer.
10414 // <notify>: a function to be called with the pointer whenever the current thread ends or sets this pointer again.
10415 void set()(void* data, DestroyNotify notify) {
10416 g_static_private_set(&this, data, notify);
10421 // The #GStaticRWLock struct represents a read-write lock. A read-write
10422 // lock can be used for protecting data that some portions of code only
10423 // read from, while others also write. In such situations it is
10424 // desirable that several readers can read at once, whereas of course
10425 // only one writer may write at a time. Take a look at the following
10426 // example:
10428 // <example>
10429 // <title>An array with access functions</title>
10430 // <programlisting>
10431 // GStaticRWLock rwlock = G_STATIC_RW_LOCK_INIT;
10432 // GPtrArray *array;
10434 // gpointer
10435 // my_array_get (guint index)
10436 // {
10437 // gpointer retval = NULL;
10439 // if (!array)
10440 // return NULL;
10442 // g_static_rw_lock_reader_lock (&amp;rwlock);
10443 // if (index &lt; array->len)
10444 // retval = g_ptr_array_index (array, index);
10445 // g_static_rw_lock_reader_unlock (&amp;rwlock);
10447 // return retval;
10448 // }
10450 // void
10451 // my_array_set (guint index, gpointer data)
10452 // {
10453 // g_static_rw_lock_writer_lock (&amp;rwlock);
10455 // if (!array)
10456 // array = g_ptr_array_new (<!-- -->);
10458 // if (index >= array->len)
10459 // g_ptr_array_set_size (array, index+1);
10460 // g_ptr_array_index (array, index) = data;
10462 // g_static_rw_lock_writer_unlock (&amp;rwlock);
10463 // }
10464 // </programlisting>
10465 // </example>
10467 // This example shows an array which can be accessed by many readers
10468 // (the <function>my_array_get()</function> function) simultaneously,
10469 // whereas the writers (the <function>my_array_set()</function>
10470 // function) will only be allowed once at a time and only if no readers
10471 // currently access the array. This is because of the potentially
10472 // dangerous resizing of the array. Using these functions is fully
10473 // multi-thread safe now.
10475 // Most of the time, writers should have precedence over readers. That
10476 // means, for this implementation, that as soon as a writer wants to
10477 // lock the data, no other reader is allowed to lock the data, whereas,
10478 // of course, the readers that already have locked the data are allowed
10479 // to finish their operation. As soon as the last reader unlocks the
10480 // data, the writer will lock it.
10482 // Even though #GStaticRWLock is not opaque, it should only be used
10483 // with the following functions.
10485 // All of the <function>g_static_rw_lock_*</function> functions can be
10486 // used even if g_thread_init() has not been called. Then they do
10487 // nothing, apart from <function>g_static_rw_lock_*_trylock</function>,
10488 // which does nothing but returning %TRUE.
10490 // <note><para>A read-write lock has a higher overhead than a mutex. For
10491 // example, both g_static_rw_lock_reader_lock() and
10492 // g_static_rw_lock_reader_unlock() have to lock and unlock a
10493 // #GStaticMutex, so it takes at least twice the time to lock and unlock
10494 // a #GStaticRWLock that it does to lock and unlock a #GStaticMutex. So
10495 // only data structures that are accessed by multiple readers, and which
10496 // keep the lock for a considerable time justify a #GStaticRWLock. The
10497 // above example most probably would fare better with a
10498 // #GStaticMutex.</para></note>
10499 struct StaticRWLock {
10500 private StaticMutex mutex;
10501 private Cond* read_cond, write_cond;
10502 private uint read_counter;
10503 private int have_writer;
10504 private uint want_to_read, want_to_write;
10507 // Releases all resources allocated to @lock.
10509 // You don't have to call this functions for a #GStaticRWLock with an
10510 // unbounded lifetime, i.e. objects declared 'static', but if you have
10511 // a #GStaticRWLock as a member of a structure, and the structure is
10512 // freed, you should also free the #GStaticRWLock.
10513 void free()() {
10514 g_static_rw_lock_free(&this);
10517 // A #GStaticRWLock must be initialized with this function before it
10518 // can be used. Alternatively you can initialize it with
10519 // #G_STATIC_RW_LOCK_INIT.
10520 void init()() {
10521 g_static_rw_lock_init(&this);
10524 // Locks @lock for reading. There may be unlimited concurrent locks for
10525 // reading of a #GStaticRWLock at the same time. If @lock is already
10526 // locked for writing by another thread or if another thread is already
10527 // waiting to lock @lock for writing, this function will block until
10528 // @lock is unlocked by the other writing thread and no other writing
10529 // threads want to lock @lock. This lock has to be unlocked by
10530 // g_static_rw_lock_reader_unlock().
10532 // #GStaticRWLock is not recursive. It might seem to be possible to
10533 // recursively lock for reading, but that can result in a deadlock, due
10534 // to writer preference.
10535 void reader_lock()() {
10536 g_static_rw_lock_reader_lock(&this);
10539 // Tries to lock @lock for reading. If @lock is already locked for
10540 // writing by another thread or if another thread is already waiting to
10541 // lock @lock for writing, immediately returns %FALSE. Otherwise locks
10542 // @lock for reading and returns %TRUE. This lock has to be unlocked by
10543 // g_static_rw_lock_reader_unlock().
10544 int reader_trylock()() {
10545 return g_static_rw_lock_reader_trylock(&this);
10548 // Unlocks @lock. If a thread waits to lock @lock for writing and all
10549 // locks for reading have been unlocked, the waiting thread is woken up
10550 // and can lock @lock for writing.
10551 void reader_unlock()() {
10552 g_static_rw_lock_reader_unlock(&this);
10555 // Locks @lock for writing. If @lock is already locked for writing or
10556 // reading by other threads, this function will block until @lock is
10557 // completely unlocked and then lock @lock for writing. While this
10558 // functions waits to lock @lock, no other thread can lock @lock for
10559 // reading. When @lock is locked for writing, no other thread can lock
10560 // @lock (neither for reading nor writing). This lock has to be
10561 // unlocked by g_static_rw_lock_writer_unlock().
10562 void writer_lock()() {
10563 g_static_rw_lock_writer_lock(&this);
10566 // Tries to lock @lock for writing. If @lock is already locked (for
10567 // either reading or writing) by another thread, it immediately returns
10568 // %FALSE. Otherwise it locks @lock for writing and returns %TRUE. This
10569 // lock has to be unlocked by g_static_rw_lock_writer_unlock().
10570 int writer_trylock()() {
10571 return g_static_rw_lock_writer_trylock(&this);
10574 // Unlocks @lock. If a thread is waiting to lock @lock for writing and
10575 // all locks for reading have been unlocked, the waiting thread is
10576 // woken up and can lock @lock for writing. If no thread is waiting to
10577 // lock @lock for writing, and some thread or threads are waiting to
10578 // lock @lock for reading, the waiting threads are woken up and can
10579 // lock @lock for reading.
10580 void writer_unlock()() {
10581 g_static_rw_lock_writer_unlock(&this);
10586 // A #GStaticRecMutex works like a #GStaticMutex, but it can be locked
10587 // multiple times by one thread. If you enter it n times, you have to
10588 // unlock it n times again to let other threads lock it. An exception
10589 // is the function g_static_rec_mutex_unlock_full(): that allows you to
10590 // unlock a #GStaticRecMutex completely returning the depth, (i.e. the
10591 // number of times this mutex was locked). The depth can later be used
10592 // to restore the state of the #GStaticRecMutex by calling
10593 // g_static_rec_mutex_lock_full().
10595 // Even though #GStaticRecMutex is not opaque, it should only be used
10596 // with the following functions.
10598 // All of the <function>g_static_rec_mutex_*</function> functions can
10599 // be used even if g_thread_init() has not been called. Then they do
10600 // nothing, apart from <function>g_static_rec_mutex_trylock</function>,
10601 // which does nothing but returning %TRUE.
10602 struct StaticRecMutex {
10603 private StaticMutex mutex;
10604 private uint depth;
10605 private SystemThread owner;
10608 // Releases all resources allocated to a #GStaticRecMutex.
10610 // You don't have to call this functions for a #GStaticRecMutex with an
10611 // unbounded lifetime, i.e. objects declared 'static', but if you have
10612 // a #GStaticRecMutex as a member of a structure and the structure is
10613 // freed, you should also free the #GStaticRecMutex.
10614 void free()() {
10615 g_static_rec_mutex_free(&this);
10618 // A #GStaticRecMutex must be initialized with this function before it
10619 // can be used. Alternatively you can initialize it with
10620 // #G_STATIC_REC_MUTEX_INIT.
10621 void init()() {
10622 g_static_rec_mutex_init(&this);
10625 // Locks @mutex. If @mutex is already locked by another thread, the
10626 // current thread will block until @mutex is unlocked by the other
10627 // thread. If @mutex is already locked by the calling thread, this
10628 // functions increases the depth of @mutex and returns immediately.
10629 void lock()() {
10630 g_static_rec_mutex_lock(&this);
10633 // Works like calling g_static_rec_mutex_lock() for @mutex @depth times.
10634 // <depth>: number of times this mutex has to be unlocked to be completely unlocked.
10635 void lock_full()(uint depth) {
10636 g_static_rec_mutex_lock_full(&this, depth);
10639 // Tries to lock @mutex. If @mutex is already locked by another thread,
10640 // it immediately returns %FALSE. Otherwise it locks @mutex and returns
10641 // %TRUE. If @mutex is already locked by the calling thread, this
10642 // functions increases the depth of @mutex and immediately returns
10643 // %TRUE.
10644 int trylock()() {
10645 return g_static_rec_mutex_trylock(&this);
10648 // Unlocks @mutex. Another thread will be allowed to lock @mutex only
10649 // when it has been unlocked as many times as it had been locked
10650 // before. If @mutex is completely unlocked and another thread is
10651 // blocked in a g_static_rec_mutex_lock() call for @mutex, it will be
10652 // woken and can lock @mutex itself.
10653 void unlock()() {
10654 g_static_rec_mutex_unlock(&this);
10657 // Completely unlocks @mutex. If another thread is blocked in a
10658 // g_static_rec_mutex_lock() call for @mutex, it will be woken and can
10659 // lock @mutex itself. This function returns the number of times that
10660 // @mutex has been locked by the current thread. To restore the state
10661 // before the call to g_static_rec_mutex_unlock_full() you can call
10662 // g_static_rec_mutex_lock_full() with the depth returned by this
10663 // function.
10664 uint unlock_full()() {
10665 return g_static_rec_mutex_unlock_full(&this);
10669 // The #GString struct contains the public fields of a #GString.
10670 struct String {
10671 char* str;
10672 size_t len, allocated_len;
10675 // Adds a string onto the end of a #GString, expanding
10676 // it if necessary.
10677 // RETURNS: @string
10678 // <val>: the string to append onto the end of @string
10679 String* /*new*/ append()(char* val) {
10680 return g_string_append(&this, val);
10683 // Adds a byte onto the end of a #GString, expanding
10684 // it if necessary.
10685 // RETURNS: @string
10686 // <c>: the byte to append onto the end of @string
10687 String* /*new*/ append_c()(char c) {
10688 return g_string_append_c(&this, c);
10691 // Appends @len bytes of @val to @string. Because @len is
10692 // provided, @val may contain embedded nuls and need not
10693 // be nul-terminated.
10695 // Since this function does not stop at nul bytes, it is
10696 // the caller's responsibility to ensure that @val has at
10697 // least @len addressable bytes.
10698 // RETURNS: @string
10699 // <val>: bytes to append
10700 // <len>: number of bytes of @val to use
10701 String* /*new*/ append_len()(char* val, ssize_t len) {
10702 return g_string_append_len(&this, val, len);
10705 // Unintrospectable method: append_printf() / g_string_append_printf()
10706 // Appends a formatted string onto the end of a #GString.
10707 // This function is similar to g_string_printf() except
10708 // that the text is appended to the #GString.
10709 // <format>: the string format. See the printf() documentation
10710 /+ Not available -- variadic methods unsupported - use the C function directly.
10711 alias g_string_append_printf append_printf; // Variadic
10714 // Converts a Unicode character into UTF-8, and appends it
10715 // to the string.
10716 // RETURNS: @string
10717 // <wc>: a Unicode character
10718 String* /*new*/ append_unichar()(dchar wc) {
10719 return g_string_append_unichar(&this, wc);
10722 // VERSION: 2.16
10723 // Appends @unescaped to @string, escaped any characters that
10724 // are reserved in URIs using URI-style escape sequences.
10725 // RETURNS: @string
10726 // <unescaped>: a string
10727 // <reserved_chars_allowed>: a string of reserved characters allowed to be used, or %NULL
10728 // <allow_utf8>: set %TRUE if the escaped string may include UTF8 characters
10729 String* /*new*/ append_uri_escaped()(char* unescaped, char* reserved_chars_allowed, int allow_utf8) {
10730 return g_string_append_uri_escaped(&this, unescaped, reserved_chars_allowed, allow_utf8);
10733 // Unintrospectable method: append_vprintf() / g_string_append_vprintf()
10734 // VERSION: 2.14
10735 // Appends a formatted string onto the end of a #GString.
10736 // This function is similar to g_string_append_printf()
10737 // except that the arguments to the format string are passed
10738 // as a va_list.
10739 // <format>: the string format. See the printf() documentation
10740 // <args>: the list of arguments to insert in the output
10741 void append_vprintf()(char* format, va_list args) {
10742 g_string_append_vprintf(&this, format, args);
10745 // Converts all upper case ASCII letters to lower case ASCII letters.
10747 // characters converted to lower case in place, with
10748 // semantics that exactly match g_ascii_tolower().
10749 // RETURNS: passed-in @string pointer, with all the upper case
10750 String* /*new*/ ascii_down()() {
10751 return g_string_ascii_down(&this);
10754 // Converts all lower case ASCII letters to upper case ASCII letters.
10756 // characters converted to upper case in place, with
10757 // semantics that exactly match g_ascii_toupper().
10758 // RETURNS: passed-in @string pointer, with all the lower case
10759 String* /*new*/ ascii_up()() {
10760 return g_string_ascii_up(&this);
10763 // Copies the bytes from a string into a #GString,
10764 // destroying any previous contents. It is rather like
10765 // the standard strcpy() function, except that you do not
10766 // have to worry about having enough space to copy the string.
10767 // RETURNS: @string
10768 // <rval>: the string to copy into @string
10769 String* /*new*/ assign()(char* rval) {
10770 return g_string_assign(&this, rval);
10773 // Converts a #GString to lowercase.
10776 // Deprecated:2.2: This function uses the locale-specific
10777 // tolower() function, which is almost never the right thing.
10778 // Use g_string_ascii_down() or g_utf8_strdown() instead.
10779 // RETURNS: the #GString.
10780 String* /*new*/ down()() {
10781 return g_string_down(&this);
10784 // Compares two strings for equality, returning %TRUE if they are equal.
10785 // For use with #GHashTable.
10787 // same bytes
10788 // RETURNS: %TRUE if they strings are the same length and contain the
10789 // <v2>: another #GString
10790 int equal()(String* v2) {
10791 return g_string_equal(&this, v2);
10794 // Removes @len bytes from a #GString, starting at position @pos.
10795 // The rest of the #GString is shifted down to fill the gap.
10796 // RETURNS: @string
10797 // <pos>: the position of the content to remove
10798 // <len>: the number of bytes to remove, or -1 to remove all following bytes
10799 String* /*new*/ erase()(ssize_t pos, ssize_t len) {
10800 return g_string_erase(&this, pos, len);
10803 // Frees the memory allocated for the #GString.
10804 // If @free_segment is %TRUE it also frees the character data. If
10805 // it's %FALSE, the caller gains ownership of the buffer and must
10806 // free it after use with g_free().
10808 // (i.e. %NULL if @free_segment is %TRUE)
10809 // RETURNS: the character data of @string
10810 // <free_segment>: if %TRUE the actual character data is freed as well
10811 char* /*new*/ free()(int free_segment) {
10812 return g_string_free(&this, free_segment);
10815 // Creates a hash code for @str; for use with #GHashTable.
10816 // RETURNS: hash code for @str
10817 uint hash()() {
10818 return g_string_hash(&this);
10821 // Inserts a copy of a string into a #GString,
10822 // expanding it if necessary.
10823 // RETURNS: @string
10824 // <pos>: the position to insert the copy of the string
10825 // <val>: the string to insert
10826 String* /*new*/ insert()(ssize_t pos, char* val) {
10827 return g_string_insert(&this, pos, val);
10830 // Inserts a byte into a #GString, expanding it if necessary.
10831 // RETURNS: @string
10832 // <pos>: the position to insert the byte
10833 // <c>: the byte to insert
10834 String* /*new*/ insert_c()(ssize_t pos, char c) {
10835 return g_string_insert_c(&this, pos, c);
10838 // Inserts @len bytes of @val into @string at @pos.
10839 // Because @len is provided, @val may contain embedded
10840 // nuls and need not be nul-terminated. If @pos is -1,
10841 // bytes are inserted at the end of the string.
10843 // Since this function does not stop at nul bytes, it is
10844 // the caller's responsibility to ensure that @val has at
10845 // least @len addressable bytes.
10846 // RETURNS: @string
10847 // <pos>: position in @string where insertion should happen, or -1 for at the end
10848 // <val>: bytes to insert
10849 // <len>: number of bytes of @val to insert
10850 String* /*new*/ insert_len()(ssize_t pos, char* val, ssize_t len) {
10851 return g_string_insert_len(&this, pos, val, len);
10854 // Converts a Unicode character into UTF-8, and insert it
10855 // into the string at the given position.
10856 // RETURNS: @string
10857 // <pos>: the position at which to insert character, or -1 to append at the end of the string
10858 // <wc>: a Unicode character
10859 String* /*new*/ insert_unichar()(ssize_t pos, dchar wc) {
10860 return g_string_insert_unichar(&this, pos, wc);
10863 // VERSION: 2.14
10864 // Overwrites part of a string, lengthening it if necessary.
10865 // RETURNS: @string
10866 // <pos>: the position at which to start overwriting
10867 // <val>: the string that will overwrite the @string starting at @pos
10868 String* /*new*/ overwrite()(size_t pos, char* val) {
10869 return g_string_overwrite(&this, pos, val);
10872 // VERSION: 2.14
10873 // Overwrites part of a string, lengthening it if necessary.
10874 // This function will work with embedded nuls.
10875 // RETURNS: @string
10876 // <pos>: the position at which to start overwriting
10877 // <val>: the string that will overwrite the @string starting at @pos
10878 // <len>: the number of bytes to write from @val
10879 String* /*new*/ overwrite_len()(size_t pos, char* val, ssize_t len) {
10880 return g_string_overwrite_len(&this, pos, val, len);
10883 // Adds a string on to the start of a #GString,
10884 // expanding it if necessary.
10885 // RETURNS: @string
10886 // <val>: the string to prepend on the start of @string
10887 String* /*new*/ prepend()(char* val) {
10888 return g_string_prepend(&this, val);
10891 // Adds a byte onto the start of a #GString,
10892 // expanding it if necessary.
10893 // RETURNS: @string
10894 // <c>: the byte to prepend on the start of the #GString
10895 String* /*new*/ prepend_c()(char c) {
10896 return g_string_prepend_c(&this, c);
10899 // Prepends @len bytes of @val to @string.
10900 // Because @len is provided, @val may contain
10901 // embedded nuls and need not be nul-terminated.
10903 // Since this function does not stop at nul bytes,
10904 // it is the caller's responsibility to ensure that
10905 // @val has at least @len addressable bytes.
10906 // RETURNS: @string
10907 // <val>: bytes to prepend
10908 // <len>: number of bytes in @val to prepend
10909 String* /*new*/ prepend_len()(char* val, ssize_t len) {
10910 return g_string_prepend_len(&this, val, len);
10913 // Converts a Unicode character into UTF-8, and prepends it
10914 // to the string.
10915 // RETURNS: @string
10916 // <wc>: a Unicode character
10917 String* /*new*/ prepend_unichar()(dchar wc) {
10918 return g_string_prepend_unichar(&this, wc);
10921 // Unintrospectable method: printf() / g_string_printf()
10922 // Writes a formatted string into a #GString.
10923 // This is similar to the standard sprintf() function,
10924 // except that the #GString buffer automatically expands
10925 // to contain the results. The previous contents of the
10926 // #GString are destroyed.
10927 // <format>: the string format. See the printf() documentation
10928 /+ Not available -- variadic methods unsupported - use the C function directly.
10929 alias g_string_printf printf; // Variadic
10932 // Sets the length of a #GString. If the length is less than
10933 // the current length, the string will be truncated. If the
10934 // length is greater than the current length, the contents
10935 // of the newly added area are undefined. (However, as
10936 // always, string->str[string->len] will be a nul byte.)
10937 // RETURNS: @string
10938 // <len>: the new length
10939 String* /*new*/ set_size()(size_t len) {
10940 return g_string_set_size(&this, len);
10943 // Cuts off the end of the GString, leaving the first @len bytes.
10944 // RETURNS: @string
10945 // <len>: the new size of @string
10946 String* /*new*/ truncate()(size_t len) {
10947 return g_string_truncate(&this, len);
10950 // Converts a #GString to uppercase.
10953 // Deprecated:2.2: This function uses the locale-specific
10954 // toupper() function, which is almost never the right thing.
10955 // Use g_string_ascii_up() or g_utf8_strup() instead.
10956 // RETURNS: @string
10957 String* /*new*/ up()() {
10958 return g_string_up(&this);
10961 // Unintrospectable method: vprintf() / g_string_vprintf()
10962 // VERSION: 2.14
10963 // Writes a formatted string into a #GString.
10964 // This function is similar to g_string_printf() except that
10965 // the arguments to the format string are passed as a va_list.
10966 // <format>: the string format. See the printf() documentation
10967 // <args>: the parameters to insert into the format string
10968 void vprintf()(char* format, va_list args) {
10969 g_string_vprintf(&this, format, args);
10974 // An opaque data structure representing String Chunks. It should only
10975 // be accessed by using the following functions.
10976 struct StringChunk {
10978 // VERSION: 2.14
10979 // Frees all strings contained within the #GStringChunk.
10980 // After calling g_string_chunk_clear() it is not safe to
10981 // access any of the strings which were contained within it.
10982 void clear()() {
10983 g_string_chunk_clear(&this);
10986 // Frees all memory allocated by the #GStringChunk.
10987 // After calling g_string_chunk_free() it is not safe to
10988 // access any of the strings which were contained within it.
10989 void free()() {
10990 g_string_chunk_free(&this);
10993 // Adds a copy of @string to the #GStringChunk.
10994 // It returns a pointer to the new copy of the string
10995 // in the #GStringChunk. The characters in the string
10996 // can be changed, if necessary, though you should not
10997 // change anything after the end of the string.
10999 // Unlike g_string_chunk_insert_const(), this function
11000 // does not check for duplicates. Also strings added
11001 // with g_string_chunk_insert() will not be searched
11002 // by g_string_chunk_insert_const() when looking for
11003 // duplicates.
11005 // the #GStringChunk
11006 // RETURNS: a pointer to the copy of @string within
11007 // <string>: the string to add
11008 char* /*new*/ insert()(char* string_) {
11009 return g_string_chunk_insert(&this, string_);
11012 // Adds a copy of @string to the #GStringChunk, unless the same
11013 // string has already been added to the #GStringChunk with
11014 // g_string_chunk_insert_const().
11016 // This function is useful if you need to copy a large number
11017 // of strings but do not want to waste space storing duplicates.
11018 // But you must remember that there may be several pointers to
11019 // the same string, and so any changes made to the strings
11020 // should be done very carefully.
11022 // Note that g_string_chunk_insert_const() will not return a
11023 // pointer to a string added with g_string_chunk_insert(), even
11024 // if they do match.
11026 // within the #GStringChunk
11027 // RETURNS: a pointer to the new or existing copy of @string
11028 // <string>: the string to add
11029 char* /*new*/ insert_const()(char* string_) {
11030 return g_string_chunk_insert_const(&this, string_);
11033 // VERSION: 2.4
11034 // Adds a copy of the first @len bytes of @string to the #GStringChunk.
11035 // The copy is nul-terminated.
11037 // Since this function does not stop at nul bytes, it is the caller's
11038 // responsibility to ensure that @string has at least @len addressable
11039 // bytes.
11041 // The characters in the returned string can be changed, if necessary,
11042 // though you should not change anything after the end of the string.
11043 // RETURNS: a pointer to the copy of @string within the #GStringChunk
11044 // <string>: bytes to insert
11045 // <len>: number of bytes of @string to insert, or -1 to insert a nul-terminated string
11046 char* /*new*/ insert_len()(char* string_, ssize_t len) {
11047 return g_string_chunk_insert_len(&this, string_, len);
11050 // Unintrospectable function: new() / g_string_chunk_new()
11051 // Creates a new #GStringChunk.
11052 // RETURNS: a new #GStringChunk
11053 // <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.
11054 static StringChunk* new_()(size_t size) {
11055 return g_string_chunk_new(size);
11059 union SystemThread {
11060 char[4] data;
11061 double dummy_double;
11062 void* dummy_pointer;
11063 c_long dummy_long;
11066 struct TestCase {
11069 struct TestConfig {
11070 int test_initialized, test_quick, test_perf, test_verbose, test_quiet;
11074 // VERSION: 2.28
11075 // The type used for test case functions that take an extra pointer
11076 // argument.
11077 // <user_data>: the data provided when registering the test
11078 extern (C) alias void function (const(void)* user_data) TestDataFunc;
11081 // VERSION: 2.28
11082 // The type used for functions that operate on test fixtures. This is
11083 // used for the fixture setup and teardown functions as well as for the
11084 // testcases themselves.
11086 // @user_data is a pointer to the data that was given when registering
11087 // the test case.
11089 // @fixture will be a pointer to the area of memory allocated by the
11090 // test framework, of the size requested. If the requested size was
11091 // zero then @fixture will be equal to @user_data.
11092 // <fixture>: the test fixture
11093 // <user_data>: the data provided when registering the test
11094 extern (C) alias void function (void* fixture, const(void)* user_data) TestFixtureFunc;
11097 // VERSION: 2.28
11098 // The type used for test case functions.
11099 extern (C) alias void function () TestFunc;
11101 struct TestLogBuffer {
11102 private String* data;
11103 private GLib2.SList* msgs;
11105 // Internal function for gtester to free test log messages, no ABI guarantees provided.
11106 void free()() {
11107 g_test_log_buffer_free(&this);
11110 // Unintrospectable method: pop() / g_test_log_buffer_pop()
11111 // Internal function for gtester to retrieve test log messages, no ABI guarantees provided.
11112 TestLogMsg* pop()() {
11113 return g_test_log_buffer_pop(&this);
11115 // Internal function for gtester to decode test log messages, no ABI guarantees provided.
11116 void push()(uint n_bytes, ubyte* bytes) {
11117 g_test_log_buffer_push(&this, n_bytes, bytes);
11120 // Unintrospectable function: new() / g_test_log_buffer_new()
11121 // Internal function for gtester to decode test log messages, no ABI guarantees provided.
11122 static TestLogBuffer* new_()() {
11123 return g_test_log_buffer_new();
11128 // VERSION: 2.22
11129 // Specifies the prototype of fatal log handler functions.
11130 // RETURNS: %TRUE if the program should abort, %FALSE otherwise
11131 // <log_domain>: the log domain of the message
11132 // <log_level>: the log level of the message (including the fatal and recursion flags)
11133 // <message>: the message to process
11134 // <user_data>: user data, set in g_test_log_set_fatal_handler()
11135 extern (C) alias int function (char* log_domain, LogLevelFlags log_level, char* message, void* user_data) TestLogFatalFunc;
11137 struct TestLogMsg {
11138 TestLogType log_type;
11139 uint n_strings;
11140 char** strings;
11141 uint n_nums;
11142 c_long* nums;
11144 // Internal function for gtester to free test log messages, no ABI guarantees provided.
11145 void free()() {
11146 g_test_log_msg_free(&this);
11150 enum TestLogType {
11151 NONE = 0,
11152 ERROR = 1,
11153 START_BINARY = 2,
11154 LIST_CASE = 3,
11155 SKIP_CASE = 4,
11156 START_CASE = 5,
11157 STOP_CASE = 6,
11158 MIN_RESULT = 7,
11159 MAX_RESULT = 8,
11160 MESSAGE = 9
11162 struct TestSuite {
11164 // VERSION: 2.16
11165 // Adds @test_case to @suite.
11166 // <test_case>: a #GTestCase
11167 void add()(TestCase* test_case) {
11168 g_test_suite_add(&this, test_case);
11171 // VERSION: 2.16
11172 // Adds @nestedsuite to @suite.
11173 // <nestedsuite>: another #GTestSuite
11174 void add_suite()(TestSuite* nestedsuite) {
11175 g_test_suite_add_suite(&this, nestedsuite);
11179 enum TestTrapFlags {
11180 SILENCE_STDOUT = 128,
11181 SILENCE_STDERR = 256,
11182 INHERIT_STDIN = 512
11185 // The #GThread struct represents a running thread. It has three public
11186 // read-only members, but the underlying struct is bigger, so you must
11187 // not copy this struct.
11189 // <note><para>Resources for a joinable thread are not fully released
11190 // until g_thread_join() is called for that thread.</para></note>
11191 struct Thread {
11192 private ThreadFunc func;
11193 private void* data;
11194 private int joinable;
11195 private ThreadPriority priority;
11198 // Unintrospectable method: join() / g_thread_join()
11199 // Waits until @thread finishes, i.e. the function @func, as given to
11200 // g_thread_create(), returns or g_thread_exit() is called by @thread.
11201 // All resources of @thread including the #GThread struct are released.
11202 // @thread must have been created with @joinable=%TRUE in
11203 // g_thread_create(). The value returned by @func or given to
11204 // g_thread_exit() by @thread is returned by this function.
11205 void* join()() {
11206 return g_thread_join(&this);
11209 // Changes the priority of @thread to @priority.
11211 // <note><para>It is not guaranteed that threads with different
11212 // priorities really behave accordingly. On some systems (e.g. Linux)
11213 // there are no thread priorities. On other systems (e.g. Solaris) there
11214 // doesn't seem to be different scheduling for different priorities. All
11215 // in all try to avoid being dependent on priorities.</para></note>
11216 // <priority>: a new priority for @thread.
11217 void set_priority()(ThreadPriority priority) {
11218 g_thread_set_priority(&this, priority);
11221 // Unintrospectable function: create_full() / g_thread_create_full()
11222 // This function creates a new thread with the priority @priority. If
11223 // the underlying thread implementation supports it, the thread gets a
11224 // stack size of @stack_size or the default value for the current
11225 // platform, if @stack_size is 0.
11227 // If @joinable is %TRUE, you can wait for this threads termination
11228 // calling g_thread_join(). Otherwise the thread will just disappear
11229 // when it terminates. If @bound is %TRUE, this thread will be
11230 // scheduled in the system scope, otherwise the implementation is free
11231 // to do scheduling in the process scope. The first variant is more
11232 // expensive resource-wise, but generally faster. On some systems (e.g.
11233 // Linux) all threads are bound.
11235 // The new thread executes the function @func with the argument @data.
11236 // If the thread was created successfully, it is returned.
11238 // @error can be %NULL to ignore errors, or non-%NULL to report errors.
11239 // The error is set, if and only if the function returns %NULL.
11241 // <note><para>It is not guaranteed that threads with different priorities
11242 // really behave accordingly. On some systems (e.g. Linux) there are no
11243 // thread priorities. On other systems (e.g. Solaris) there doesn't
11244 // seem to be different scheduling for different priorities. All in all
11245 // try to avoid being dependent on priorities. Use
11246 // %G_THREAD_PRIORITY_NORMAL here as a default.</para></note>
11248 // <note><para>Only use g_thread_create_full() if you really can't use
11249 // g_thread_create() instead. g_thread_create() does not take
11250 // @stack_size, @bound, and @priority as arguments, as they should only
11251 // be used in cases in which it is unavoidable.</para></note>
11252 // <func>: a function to execute in the new thread.
11253 // <data>: an argument to supply to the new thread.
11254 // <stack_size>: a stack size for the new thread.
11255 // <joinable>: should this thread be joinable?
11256 // <bound>: should this thread be bound to a system thread?
11257 // <priority>: a priority for the thread.
11258 static Thread* create_full()(ThreadFunc func, void* data, c_ulong stack_size, int joinable, int bound, ThreadPriority priority, GLib2.Error** error=null) {
11259 return g_thread_create_full(func, data, stack_size, joinable, bound, priority, error);
11261 static Quark error_quark()() {
11262 return g_thread_error_quark();
11265 // Exits the current thread. If another thread is waiting for that
11266 // thread using g_thread_join() and the current thread is joinable, the
11267 // waiting thread will be woken up and get @retval as the return value
11268 // of g_thread_join(). If the current thread is not joinable, @retval
11269 // is ignored. Calling
11271 // <informalexample>
11272 // <programlisting>
11273 // g_thread_exit (retval);
11274 // </programlisting>
11275 // </informalexample>
11277 // is equivalent to returning @retval from the function @func, as given
11278 // to g_thread_create().
11280 // <note><para>Never call g_thread_exit() from within a thread of a
11281 // #GThreadPool, as that will mess up the bookkeeping and lead to funny
11282 // and unwanted results.</para></note>
11283 // <retval>: the return value of this thread.
11284 static void exit()(void* retval) {
11285 g_thread_exit(retval);
11288 // Unintrospectable function: foreach() / g_thread_foreach()
11289 // VERSION: 2.10
11290 // Call @thread_func on all existing #GThread structures. Note that
11291 // threads may decide to exit while @thread_func is running, so
11292 // without intimate knowledge about the lifetime of foreign threads,
11293 // @thread_func shouldn't access the GThread* pointer passed in as
11294 // first argument. However, @thread_func will not be called for threads
11295 // which are known to have exited already.
11297 // Due to thread lifetime checks, this function has an execution complexity
11298 // which is quadratic in the number of existing threads.
11299 // <thread_func>: function to call for all GThread structures
11300 // <user_data>: second argument to @thread_func
11301 static void foreach_()(Func thread_func, void* user_data) {
11302 g_thread_foreach(thread_func, user_data);
11305 // VERSION: 2.20
11306 // Indicates if g_thread_init() has been called.
11307 // RETURNS: %TRUE if threads have been initialized.
11308 static int get_initialized()() {
11309 return g_thread_get_initialized();
11312 // If you use GLib from more than one thread, you must initialize the
11313 // thread system by calling g_thread_init(). Most of the time you will
11314 // only have to call <literal>g_thread_init (NULL)</literal>.
11316 // <note><para>Do not call g_thread_init() with a non-%NULL parameter unless
11317 // you really know what you are doing.</para></note>
11319 // <note><para>g_thread_init() must not be called directly or indirectly as a
11320 // callback from GLib. Also no mutexes may be currently locked while
11321 // calling g_thread_init().</para></note>
11323 // <note><para>g_thread_init() changes the way in which #GTimer measures
11324 // elapsed time. As a consequence, timers that are running while
11325 // g_thread_init() is called may report unreliable times.</para></note>
11327 // Calling g_thread_init() multiple times is allowed (since version
11328 // 2.24), but nothing happens except for the first call. If the
11329 // argument is non-%NULL on such a call a warning will be printed, but
11330 // otherwise the argument is ignored.
11332 // If no thread system is available and @vtable is %NULL or if not all
11333 // elements of @vtable are non-%NULL, then g_thread_init() will abort.
11335 // <note><para>To use g_thread_init() in your program, you have to link with
11336 // the libraries that the command <command>pkg-config --libs
11337 // gthread-2.0</command> outputs. This is not the case for all the
11338 // other thread related functions of GLib. Those can be used without
11339 // having to link with the thread libraries.</para></note>
11340 // <vtable>: a function table of type #GThreadFunctions, that provides the entry points to the thread system to be used.
11341 static void init()(ThreadFunctions* vtable) {
11342 g_thread_init(vtable);
11344 static void init_with_errorcheck_mutexes()(ThreadFunctions* vtable) {
11345 g_thread_init_with_errorcheck_mutexes(vtable);
11348 // Unintrospectable function: self() / g_thread_self()
11349 // This functions returns the #GThread corresponding to the calling
11350 // thread.
11351 static Thread* self()() {
11352 return g_thread_self();
11356 // Possible errors of thread related functions.
11357 enum ThreadError {
11358 THREAD_ERROR_AGAIN = 0
11361 // Unintrospectable callback: ThreadFunc() / ()
11362 // Specifies the type of the @func functions passed to
11363 // g_thread_create() or g_thread_create_full().
11364 // <data>: data passed to the thread.
11365 extern (C) alias void* function (void* data) ThreadFunc;
11368 // This function table is used by g_thread_init() to initialize the
11369 // thread system. The functions in the table are directly used by their
11370 // g_* prepended counterparts (described in this document). For
11371 // example, if you call g_mutex_new() then mutex_new() from the table
11372 // provided to g_thread_init() will be called.
11374 // <note><para>Do not use this struct unless you know what you are
11375 // doing.</para></note>
11376 struct ThreadFunctions {
11377 // Unintrospectable functionp: mutex_new() / ()
11378 extern (C) Mutex* function () mutex_new;
11379 extern (C) void function (Mutex* mutex) mutex_lock;
11380 extern (C) int function (Mutex* mutex) mutex_trylock;
11381 extern (C) void function (Mutex* mutex) mutex_unlock;
11382 extern (C) void function (Mutex* mutex) mutex_free;
11383 // Unintrospectable functionp: cond_new() / ()
11384 extern (C) Cond* function () cond_new;
11385 extern (C) void function (Cond* cond) cond_signal;
11386 extern (C) void function (Cond* cond) cond_broadcast;
11387 extern (C) void function (Cond* cond, Mutex* mutex) cond_wait;
11388 extern (C) int function (Cond* cond, Mutex* mutex, TimeVal* end_time) cond_timed_wait;
11389 extern (C) void function (Cond* cond) cond_free;
11390 // Unintrospectable functionp: private_new() / ()
11391 extern (C) Private* function (DestroyNotify destructor) private_new;
11392 // Unintrospectable functionp: private_get() / ()
11393 extern (C) void* function (Private* private_key) private_get;
11394 extern (C) void function (Private* private_key, void* data) private_set;
11395 // Unintrospectable functionp: thread_create() / ()
11396 extern (C) void function (ThreadFunc func, void* data, c_ulong stack_size, int joinable, int bound, ThreadPriority priority, void* thread, GLib2.Error** error=null) thread_create;
11397 extern (C) void function () thread_yield;
11398 extern (C) void function (void* thread) thread_join;
11399 extern (C) void function () thread_exit;
11400 extern (C) void function (void* thread, ThreadPriority priority) thread_set_priority;
11401 extern (C) void function (void* thread) thread_self;
11402 extern (C) int function (void* thread1, void* thread2) thread_equal;
11406 // The #GThreadPool struct represents a thread pool. It has three
11407 // public read-only members, but the underlying struct is bigger, so
11408 // you must not copy this struct.
11409 struct ThreadPool {
11410 Func func;
11411 void* user_data;
11412 int exclusive;
11415 // Frees all resources allocated for @pool.
11417 // If @immediate is %TRUE, no new task is processed for
11418 // @pool. Otherwise @pool is not freed before the last task is
11419 // processed. Note however, that no thread of this pool is
11420 // interrupted, while processing a task. Instead at least all still
11421 // running threads can finish their tasks before the @pool is freed.
11423 // If @wait_ is %TRUE, the functions does not return before all tasks
11424 // to be processed (dependent on @immediate, whether all or only the
11425 // currently running) are ready. Otherwise the function returns immediately.
11427 // After calling this function @pool must not be used anymore.
11428 // <immediate>: should @pool shut down immediately?
11429 // <wait_>: should the function wait for all tasks to be finished?
11430 void free()(int immediate, int wait_) {
11431 g_thread_pool_free(&this, immediate, wait_);
11434 // Returns the maximal number of threads for @pool.
11435 // RETURNS: the maximal number of threads
11436 int get_max_threads()() {
11437 return g_thread_pool_get_max_threads(&this);
11440 // Returns the number of threads currently running in @pool.
11441 // RETURNS: the number of threads currently running
11442 uint get_num_threads()() {
11443 return g_thread_pool_get_num_threads(&this);
11446 // Inserts @data into the list of tasks to be executed by @pool. When
11447 // the number of currently running threads is lower than the maximal
11448 // allowed number of threads, a new thread is started (or reused) with
11449 // the properties given to g_thread_pool_new (). Otherwise @data stays
11450 // in the queue until a thread in this pool finishes its previous task
11451 // and processes @data.
11453 // @error can be %NULL to ignore errors, or non-%NULL to report
11454 // errors. An error can only occur when a new thread couldn't be
11455 // created. In that case @data is simply appended to the queue of work
11456 // to do.
11457 // <data>: a new task for @pool
11458 void push()(void* data, GLib2.Error** error=null) {
11459 g_thread_pool_push(&this, data, error);
11462 // Sets the maximal allowed number of threads for @pool. A value of -1
11463 // means, that the maximal number of threads is unlimited.
11465 // Setting @max_threads to 0 means stopping all work for @pool. It is
11466 // effectively frozen until @max_threads is set to a non-zero value
11467 // again.
11469 // A thread is never terminated while calling @func, as supplied by
11470 // g_thread_pool_new (). Instead the maximal number of threads only
11471 // has effect for the allocation of new threads in g_thread_pool_push().
11472 // A new thread is allocated, whenever the number of currently
11473 // running threads in @pool is smaller than the maximal number.
11475 // @error can be %NULL to ignore errors, or non-%NULL to report
11476 // errors. An error can only occur when a new thread couldn't be
11477 // created.
11478 // <max_threads>: a new maximal number of threads for @pool
11479 void set_max_threads()(int max_threads, GLib2.Error** error=null) {
11480 g_thread_pool_set_max_threads(&this, max_threads, error);
11483 // Unintrospectable method: set_sort_function() / g_thread_pool_set_sort_function()
11484 // VERSION: 2.10
11485 // Sets the function used to sort the list of tasks. This allows the
11486 // tasks to be processed by a priority determined by @func, and not
11487 // just in the order in which they were added to the pool.
11489 // Note, if the maximum number of threads is more than 1, the order
11490 // that threads are executed cannot be guaranteed 100%. Threads are
11491 // scheduled by the operating system and are executed at random. It
11492 // cannot be assumed that threads are executed in the order they are
11493 // created.
11494 // <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.
11495 // <user_data>: user data passed to @func.
11496 void set_sort_function()(CompareDataFunc func, void* user_data) {
11497 g_thread_pool_set_sort_function(&this, func, user_data);
11500 // Returns the number of tasks still unprocessed in @pool.
11501 // RETURNS: the number of unprocessed tasks
11502 uint unprocessed()() {
11503 return g_thread_pool_unprocessed(&this);
11506 // VERSION: 2.10
11507 // This function will return the maximum @interval that a thread will
11508 // wait in the thread pool for new tasks before being stopped.
11510 // If this function returns 0, threads waiting in the thread pool for
11511 // new work are not stopped.
11513 // thread pool before stopping the thread (1/1000ths of a second).
11514 // RETURNS: the maximum @interval to wait for new tasks in the
11515 static uint get_max_idle_time()() {
11516 return g_thread_pool_get_max_idle_time();
11519 // Returns the maximal allowed number of unused threads.
11520 // RETURNS: the maximal number of unused threads
11521 static int get_max_unused_threads()() {
11522 return g_thread_pool_get_max_unused_threads();
11525 // Returns the number of currently unused threads.
11526 // RETURNS: the number of currently unused threads
11527 static uint get_num_unused_threads()() {
11528 return g_thread_pool_get_num_unused_threads();
11531 // Unintrospectable function: new() / g_thread_pool_new()
11532 // This function creates a new thread pool.
11534 // Whenever you call g_thread_pool_push(), either a new thread is
11535 // created or an unused one is reused. At most @max_threads threads
11536 // are running concurrently for this thread pool. @max_threads = -1
11537 // allows unlimited threads to be created for this thread pool. The
11538 // newly created or reused thread now executes the function @func with
11539 // the two arguments. The first one is the parameter to
11540 // g_thread_pool_push() and the second one is @user_data.
11542 // The parameter @exclusive determines, whether the thread pool owns
11543 // all threads exclusive or whether the threads are shared
11544 // globally. If @exclusive is %TRUE, @max_threads threads are started
11545 // immediately and they will run exclusively for this thread pool until
11546 // it is destroyed by g_thread_pool_free(). If @exclusive is %FALSE,
11547 // threads are created, when needed and shared between all
11548 // non-exclusive thread pools. This implies that @max_threads may not
11549 // be -1 for exclusive thread pools.
11551 // @error can be %NULL to ignore errors, or non-%NULL to report
11552 // errors. An error can only occur when @exclusive is set to %TRUE and
11553 // not all @max_threads threads could be created.
11554 // RETURNS: the new #GThreadPool
11555 // <func>: a function to execute in the threads of the new thread pool
11556 // <user_data>: user data that is handed over to @func every time it is called
11557 // <max_threads>: the maximal number of threads to execute concurrently in the new thread pool, -1 means no limit
11558 // <exclusive>: should this thread pool be exclusive?
11559 static ThreadPool* new_()(Func func, void* user_data, int max_threads, int exclusive, GLib2.Error** error=null) {
11560 return g_thread_pool_new(func, user_data, max_threads, exclusive, error);
11563 // VERSION: 2.10
11564 // This function will set the maximum @interval that a thread waiting
11565 // in the pool for new tasks can be idle for before being
11566 // stopped. This function is similar to calling
11567 // g_thread_pool_stop_unused_threads() on a regular timeout, except,
11568 // this is done on a per thread basis.
11570 // By setting @interval to 0, idle threads will not be stopped.
11572 // This function makes use of g_async_queue_timed_pop () using
11573 // @interval.
11574 // <interval>: the maximum @interval (1/1000ths of a second) a thread can be idle.
11575 static void set_max_idle_time()(uint interval) {
11576 g_thread_pool_set_max_idle_time(interval);
11579 // Sets the maximal number of unused threads to @max_threads. If
11580 // @max_threads is -1, no limit is imposed on the number of unused
11581 // threads.
11582 // <max_threads>: maximal number of unused threads
11583 static void set_max_unused_threads()(int max_threads) {
11584 g_thread_pool_set_max_unused_threads(max_threads);
11587 // Stops all currently unused threads. This does not change the
11588 // maximal number of unused threads. This function can be used to
11589 // regularly stop all unused threads e.g. from g_timeout_add().
11590 static void stop_unused_threads()() {
11591 g_thread_pool_stop_unused_threads();
11596 // Specifies the priority of a thread.
11598 // <note><para>It is not guaranteed that threads with different priorities
11599 // really behave accordingly. On some systems (e.g. Linux) there are no
11600 // thread priorities. On other systems (e.g. Solaris) there doesn't
11601 // seem to be different scheduling for different priorities. All in all
11602 // try to avoid being dependent on priorities.</para></note>
11603 enum ThreadPriority {
11604 LOW = 0,
11605 NORMAL = 1,
11606 HIGH = 2,
11607 URGENT = 3
11610 // Disambiguates a given time in two ways.
11612 // First, specifies if the given time is in universal or local time.
11614 // Second, if the time is in local time, specifies if it is local
11615 // standard time or local daylight time. This is important for the case
11616 // where the same local time occurs twice (during daylight savings time
11617 // transitions, for example).
11618 enum TimeType {
11619 STANDARD = 0,
11620 DAYLIGHT = 1,
11621 UNIVERSAL = 2
11623 struct TimeVal {
11624 c_long tv_sec, tv_usec;
11627 // Adds the given number of microseconds to @time_. @microseconds can
11628 // also be negative to decrease the value of @time_.
11629 // <microseconds>: number of microseconds to add to @time
11630 void add()(c_long microseconds) {
11631 g_time_val_add(&this, microseconds);
11634 // VERSION: 2.12
11635 // Converts @time_ into an ISO 8601 encoded string, relative to the
11636 // Coordinated Universal Time (UTC).
11637 // RETURNS: a newly allocated string containing an ISO 8601 date
11638 char* /*new*/ to_iso8601()() {
11639 return g_time_val_to_iso8601(&this);
11642 // VERSION: 2.12
11643 // Converts a string containing an ISO 8601 encoded date and time
11644 // to a #GTimeVal and puts it into @time_.
11645 // RETURNS: %TRUE if the conversion was successful.
11646 // <iso_date>: an ISO 8601 encoded date string
11647 // <time_>: a #GTimeVal
11648 static int from_iso8601()(char* iso_date, TimeVal* time_) {
11649 return g_time_val_from_iso8601(iso_date, time_);
11654 // #GDateTime is an opaque structure whose members cannot be accessed
11655 // directly.
11656 struct TimeZone /* Version 2.26 */ {
11658 // VERSION: 2.26
11659 // Finds an interval within @tz that corresponds to the given @time_,
11660 // possibly adjusting @time_ if required to fit into an interval.
11661 // The meaning of @time_ depends on @type.
11663 // This function is similar to g_time_zone_find_interval(), with the
11664 // difference that it always succeeds (by making the adjustments
11665 // described below).
11667 // In any of the cases where g_time_zone_find_interval() succeeds then
11668 // this function returns the same value, without modifying @time_.
11670 // This function may, however, modify @time_ in order to deal with
11671 // non-existent times. If the non-existent local @time_ of 02:30 were
11672 // requested on March 13th 2010 in Toronto then this function would
11673 // adjust @time_ to be 03:00 and return the interval containing the
11674 // adjusted time.
11675 // RETURNS: the interval containing @time_, never -1
11676 // <type>: the #GTimeType of @time_
11677 // <time_>: a pointer to a number of seconds since January 1, 1970
11678 int adjust_time()(TimeType type, long* time_) {
11679 return g_time_zone_adjust_time(&this, type, time_);
11682 // VERSION: 2.26
11683 // Finds an the interval within @tz that corresponds to the given @time_.
11684 // The meaning of @time_ depends on @type.
11686 // If @type is %G_TIME_TYPE_UNIVERSAL then this function will always
11687 // succeed (since universal time is monotonic and continuous).
11689 // Otherwise @time_ is treated is local time. The distinction between
11690 // %G_TIME_TYPE_STANDARD and %G_TIME_TYPE_DAYLIGHT is ignored except in
11691 // the case that the given @time_ is ambiguous. In Toronto, for example,
11692 // 01:30 on November 7th 2010 occurred twice (once inside of daylight
11693 // savings time and the next, an hour later, outside of daylight savings
11694 // time). In this case, the different value of @type would result in a
11695 // different interval being returned.
11697 // It is still possible for this function to fail. In Toronto, for
11698 // example, 02:00 on March 14th 2010 does not exist (due to the leap
11699 // forward to begin daylight savings time). -1 is returned in that
11700 // case.
11701 // RETURNS: the interval containing @time_, or -1 in case of failure
11702 // <type>: the #GTimeType of @time_
11703 // <time_>: a number of seconds since January 1, 1970
11704 int find_interval()(TimeType type, long time_) {
11705 return g_time_zone_find_interval(&this, type, time_);
11708 // VERSION: 2.26
11709 // Determines the time zone abbreviation to be used during a particular
11710 // @interval of time in the time zone @tz.
11712 // For example, in Toronto this is currently "EST" during the winter
11713 // months and "EDT" during the summer months when daylight savings time
11714 // is in effect.
11715 // RETURNS: the time zone abbreviation, which belongs to @tz
11716 // <interval>: an interval within the timezone
11717 char* get_abbreviation()(int interval) {
11718 return g_time_zone_get_abbreviation(&this, interval);
11721 // VERSION: 2.26
11722 // Determines the offset to UTC in effect during a particular @interval
11723 // of time in the time zone @tz.
11725 // The offset is the number of seconds that you add to UTC time to
11726 // arrive at local time for @tz (ie: negative numbers for time zones
11727 // west of GMT, positive numbers for east).
11729 // local time in @tz
11730 // RETURNS: the number of seconds that should be added to UTC to get the
11731 // <interval>: an interval within the timezone
11732 int get_offset()(int interval) {
11733 return g_time_zone_get_offset(&this, interval);
11736 // VERSION: 2.26
11737 // Determines if daylight savings time is in effect during a particular
11738 // @interval of time in the time zone @tz.
11739 // RETURNS: %TRUE if daylight savings time is in effect
11740 // <interval>: an interval within the timezone
11741 int is_dst()(int interval) {
11742 return g_time_zone_is_dst(&this, interval);
11745 // Unintrospectable method: ref() / g_time_zone_ref()
11746 // VERSION: 2.26
11747 // Increases the reference count on @tz.
11748 // RETURNS: a new reference to @tz.
11749 TimeZone* ref_()() {
11750 return g_time_zone_ref(&this);
11753 // VERSION: 2.26
11754 // Decreases the reference count on @tz.
11755 void unref()() {
11756 g_time_zone_unref(&this);
11759 // Unintrospectable function: new() / g_time_zone_new()
11760 // VERSION: 2.26
11761 // Creates a #GTimeZone corresponding to @identifier.
11763 // @identifier can either be an RFC3339/ISO 8601 time offset or
11764 // something that would pass as a valid value for the
11765 // <varname>TZ</varname> environment variable (including %NULL).
11767 // Valid RFC3339 time offsets are <literal>"Z"</literal> (for UTC) or
11768 // <literal>"±hh:mm"</literal>. ISO 8601 additionally specifies
11769 // <literal>"±hhmm"</literal> and <literal>"±hh"</literal>.
11771 // The <varname>TZ</varname> environment variable typically corresponds
11772 // to the name of a file in the zoneinfo database, but there are many
11773 // other possibilities. Note that those other possibilities are not
11774 // currently implemented, but are planned.
11776 // g_time_zone_new_local() calls this function with the value of the
11777 // <varname>TZ</varname> environment variable. This function itself is
11778 // independent of the value of <varname>TZ</varname>, but if @identifier
11779 // is %NULL then <filename>/etc/localtime</filename> will be consulted
11780 // to discover the correct timezone.
11782 // See <ulink
11783 // url='http://tools.ietf.org/html/rfc3339#section-5.6'>RFC3339
11784 // §5.6</ulink> for a precise definition of valid RFC3339 time offsets
11785 // (the <varname>time-offset</varname> expansion) and ISO 8601 for the
11786 // full list of valid time offsets. See <ulink
11787 // url='http://www.gnu.org/s/libc/manual/html_node/TZ-Variable.html'>The
11788 // GNU C Library manual</ulink> for an explanation of the possible
11789 // values of the <varname>TZ</varname> environment variable.
11791 // You should release the return value by calling g_time_zone_unref()
11792 // when you are done with it.
11793 // RETURNS: the requested timezone
11794 // <identifier>: a timezone identifier
11795 static TimeZone* new_()(char* identifier=null) {
11796 return g_time_zone_new(identifier);
11799 // Unintrospectable function: new_local() / g_time_zone_new_local()
11800 // VERSION: 2.26
11801 // Creates a #GTimeZone corresponding to local time. The local time
11802 // zone may change between invocations to this function; for example,
11803 // if the system administrator changes it.
11805 // This is equivalent to calling g_time_zone_new() with the value of the
11806 // <varname>TZ</varname> environment variable (including the possibility
11807 // of %NULL).
11809 // You should release the return value by calling g_time_zone_unref()
11810 // when you are done with it.
11811 // RETURNS: the local timezone
11812 static TimeZone* new_local()() {
11813 return g_time_zone_new_local();
11816 // Unintrospectable function: new_utc() / g_time_zone_new_utc()
11817 // VERSION: 2.26
11818 // Creates a #GTimeZone corresponding to UTC.
11820 // This is equivalent to calling g_time_zone_new() with a value like
11821 // "Z", "UTC", "+00", etc.
11823 // You should release the return value by calling g_time_zone_unref()
11824 // when you are done with it.
11825 // RETURNS: the universal timezone
11826 static TimeZone* new_utc()() {
11827 return g_time_zone_new_utc();
11831 // Opaque datatype that records a start time.
11832 struct Timer {
11834 // VERSION: 2.4
11835 // Resumes a timer that has previously been stopped with
11836 // g_timer_stop(). g_timer_stop() must be called before using this
11837 // function.
11838 void continue_()() {
11839 g_timer_continue(&this);
11841 // Destroys a timer, freeing associated resources.
11842 void destroy()() {
11843 g_timer_destroy(&this);
11846 // If @timer has been started but not stopped, obtains the time since
11847 // the timer was started. If @timer has been stopped, obtains the
11848 // elapsed time between the time it was started and the time it was
11849 // stopped. The return value is the number of seconds elapsed,
11850 // including any fractional part. The @microseconds out parameter is
11851 // essentially useless.
11853 // <warning><para>
11854 // Calling initialization functions, in particular g_thread_init(), while a
11855 // timer is running will cause invalid return values from this function.
11856 // </para></warning>
11857 // <microseconds>: return location for the fractional part of seconds elapsed, in microseconds (that is, the total number of microseconds elapsed, modulo 1000000), or %NULL
11858 double elapsed()(c_ulong* microseconds) {
11859 return g_timer_elapsed(&this, microseconds);
11862 // This function is useless; it's fine to call g_timer_start() on an
11863 // already-started timer to reset the start time, so g_timer_reset()
11864 // serves no purpose.
11865 void reset()() {
11866 g_timer_reset(&this);
11869 // Marks a start time, so that future calls to g_timer_elapsed() will
11870 // report the time since g_timer_start() was called. g_timer_new()
11871 // automatically marks the start time, so no need to call
11872 // g_timer_start() immediately after creating the timer.
11873 void start()() {
11874 g_timer_start(&this);
11877 // Marks an end time, so calls to g_timer_elapsed() will return the
11878 // difference between this end time and the start time.
11879 void stop()() {
11880 g_timer_stop(&this);
11883 // Unintrospectable function: new() / g_timer_new()
11884 // Creates a new timer, and starts timing (i.e. g_timer_start() is
11885 // implicitly called for you).
11886 static Timer* new_()() {
11887 return g_timer_new();
11891 enum TokenType {
11892 EOF = 0,
11893 LEFT_PAREN = 40,
11894 RIGHT_PAREN = 41,
11895 LEFT_CURLY = 123,
11896 RIGHT_CURLY = 125,
11897 LEFT_BRACE = 91,
11898 RIGHT_BRACE = 93,
11899 EQUAL_SIGN = 61,
11900 COMMA = 44,
11901 NONE = 256,
11902 ERROR = 257,
11903 CHAR = 258,
11904 BINARY = 259,
11905 OCTAL = 260,
11906 INT = 261,
11907 HEX = 262,
11908 FLOAT = 263,
11909 STRING = 264,
11910 SYMBOL = 265,
11911 IDENTIFIER = 266,
11912 IDENTIFIER_NULL = 267,
11913 COMMENT_SINGLE = 268,
11914 COMMENT_MULTI = 269,
11915 LAST = 270
11917 union TokenValue {
11918 void* v_symbol;
11919 char* v_identifier;
11920 c_ulong v_binary, v_octal, v_int;
11921 ulong v_int64;
11922 double v_float;
11923 c_ulong v_hex;
11924 char* v_string, v_comment;
11925 ubyte v_char;
11926 uint v_error;
11930 // The type of functions which are used to translate user-visible
11931 // strings, for <option>--help</option> output.
11933 // The returned string is owned by GLib and must not be freed.
11934 // RETURNS: a translation of the string for the current locale.
11935 // <str>: the untranslated string
11936 // <data>: user data specified when installing the function, e.g. in g_option_group_set_translate_func()
11937 extern (C) alias char* function (char* str, void* data) TranslateFunc;
11939 struct TrashStack {
11940 TrashStack* next;
11942 static uint height()(TrashStack** stack_p) {
11943 return g_trash_stack_height(stack_p);
11945 // Unintrospectable function: peek() / g_trash_stack_peek()
11946 static void* peek()(TrashStack** stack_p) {
11947 return g_trash_stack_peek(stack_p);
11949 // Unintrospectable function: pop() / g_trash_stack_pop()
11950 static void* pop()(TrashStack** stack_p) {
11951 return g_trash_stack_pop(stack_p);
11953 static void push()(TrashStack** stack_p, void* data_p) {
11954 g_trash_stack_push(stack_p, data_p);
11959 // Specifies which nodes are visited during several of the tree
11960 // functions, including g_node_traverse() and g_node_find().
11961 enum TraverseFlags {
11962 LEAVES = 1,
11963 NON_LEAVES = 2,
11964 ALL = 3,
11965 MASK = 3,
11966 LEAFS = 1,
11967 NON_LEAFS = 2
11970 // Specifies the type of function passed to g_tree_traverse(). It is
11971 // passed the key and value of each node, together with the @user_data
11972 // parameter passed to g_tree_traverse(). If the function returns
11973 // %TRUE, the traversal is stopped.
11974 // <key>: a key of a #GTree node.
11975 // <value>: the value corresponding to the key.
11976 // <data>: user data passed to g_tree_traverse().
11977 extern (C) alias int function (void* key, void* value, void* data) TraverseFunc;
11980 // Specifies the type of traveral performed by g_tree_traverse(),
11981 // g_node_traverse() and g_node_find().
11982 enum TraverseType {
11983 IN_ORDER = 0,
11984 PRE_ORDER = 1,
11985 POST_ORDER = 2,
11986 LEVEL_ORDER = 3
11989 // The <structname>GTree</structname> struct is an opaque data
11990 // structure representing a <link
11991 // linkend="glib-Balanced-Binary-Trees">Balanced Binary Tree</link>. It
11992 // should be accessed only by using the following functions.
11993 struct Tree {
11995 // Removes all keys and values from the #GTree and decreases its
11996 // reference count by one. If keys and/or values are dynamically
11997 // allocated, you should either free them first or create the #GTree
11998 // using g_tree_new_full(). In the latter case the destroy functions
11999 // you supplied will be called on all keys and values before destroying
12000 // the #GTree.
12001 void destroy()() {
12002 g_tree_destroy(&this);
12005 // Unintrospectable method: foreach() / g_tree_foreach()
12006 // Calls the given function for each of the key/value pairs in the #GTree.
12007 // The function is passed the key and value of each pair, and the given
12008 // @data parameter. The tree is traversed in sorted order.
12010 // The tree may not be modified while iterating over it (you can't
12011 // add/remove items). To remove all items matching a predicate, you need
12012 // to add each item to a list in your #GTraverseFunc as you walk over
12013 // the tree, then walk the list and remove each item.
12014 // <func>: the function to call for each node visited. If this function returns %TRUE, the traversal is stopped.
12015 // <user_data>: user data to pass to the function.
12016 void foreach_()(TraverseFunc func, void* user_data) {
12017 g_tree_foreach(&this, func, user_data);
12020 // Gets the height of a #GTree.
12022 // If the #GTree contains no nodes, the height is 0.
12023 // If the #GTree contains only one root node the height is 1.
12024 // If the root node has children the height is 2, etc.
12025 // RETURNS: the height of the #GTree.
12026 int height()() {
12027 return g_tree_height(&this);
12030 // Inserts a key/value pair into a #GTree. If the given key already exists
12031 // in the #GTree its corresponding value is set to the new value. If you
12032 // supplied a value_destroy_func when creating the #GTree, the old value is
12033 // freed using that function. If you supplied a @key_destroy_func when
12034 // creating the #GTree, the passed key is freed using that function.
12036 // The tree is automatically 'balanced' as new key/value pairs are added,
12037 // so that the distance from the root to every leaf is as small as possible.
12038 // <key>: the key to insert.
12039 // <value>: the value corresponding to the key.
12040 void insert()(void* key, void* value) {
12041 g_tree_insert(&this, key, value);
12044 // Unintrospectable method: lookup() / g_tree_lookup()
12045 // Gets the value corresponding to the given key. Since a #GTree is
12046 // automatically balanced as key/value pairs are added, key lookup is very
12047 // fast.
12049 // not found.
12050 // RETURNS: the value corresponding to the key, or %NULL if the key was
12051 // <key>: the key to look up.
12052 void* lookup()(const(void)* key) {
12053 return g_tree_lookup(&this, key);
12056 // Looks up a key in the #GTree, returning the original key and the
12057 // associated value and a #gboolean which is %TRUE if the key was found. This
12058 // is useful if you need to free the memory allocated for the original key,
12059 // for example before calling g_tree_remove().
12060 // RETURNS: %TRUE if the key was found in the #GTree.
12061 // <lookup_key>: the key to look up.
12062 // <orig_key>: returns the original key.
12063 // <value>: returns the value associated with the key.
12064 int lookup_extended()(const(void)* lookup_key, void** orig_key, void** value) {
12065 return g_tree_lookup_extended(&this, lookup_key, orig_key, value);
12068 // Gets the number of nodes in a #GTree.
12069 // RETURNS: the number of nodes in the #GTree.
12070 int nnodes()() {
12071 return g_tree_nnodes(&this);
12074 // Unintrospectable method: ref() / g_tree_ref()
12075 // VERSION: 2.22
12076 // Increments the reference count of @tree by one. It is safe to call
12077 // this function from any thread.
12078 // RETURNS: the passed in #GTree.
12079 Tree* ref_()() {
12080 return g_tree_ref(&this);
12083 // Removes a key/value pair from a #GTree.
12085 // If the #GTree was created using g_tree_new_full(), the key and value
12086 // are freed using the supplied destroy functions, otherwise you have to
12087 // make sure that any dynamically allocated values are freed yourself.
12088 // If the key does not exist in the #GTree, the function does nothing.
12090 // nothing)
12091 // RETURNS: %TRUE if the key was found (prior to 2.8, this function returned
12092 // <key>: the key to remove.
12093 int remove()(const(void)* key) {
12094 return g_tree_remove(&this, key);
12097 // Inserts a new key and value into a #GTree similar to g_tree_insert().
12098 // The difference is that if the key already exists in the #GTree, it gets
12099 // replaced by the new key. If you supplied a @value_destroy_func when
12100 // creating the #GTree, the old value is freed using that function. If you
12101 // supplied a @key_destroy_func when creating the #GTree, the old key is
12102 // freed using that function.
12104 // The tree is automatically 'balanced' as new key/value pairs are added,
12105 // so that the distance from the root to every leaf is as small as possible.
12106 // <key>: the key to insert.
12107 // <value>: the value corresponding to the key.
12108 void replace()(void* key, void* value) {
12109 g_tree_replace(&this, key, value);
12112 // Unintrospectable method: search() / g_tree_search()
12113 // Searches a #GTree using @search_func.
12115 // The @search_func is called with a pointer to the key of a key/value
12116 // pair in the tree, and the passed in @user_data. If @search_func returns
12117 // 0 for a key/value pair, then the corresponding value is returned as
12118 // the result of g_tree_search(). If @search_func returns -1, searching
12119 // will proceed among the key/value pairs that have a smaller key; if
12120 // @search_func returns 1, searching will proceed among the key/value
12121 // pairs that have a larger key.
12123 // the key was not found.
12124 // RETURNS: the value corresponding to the found key, or %NULL if
12125 // <search_func>: a function used to search the #GTree
12126 // <user_data>: the data passed as the second argument to @search_func
12127 void* search()(CompareFunc search_func, const(void)* user_data) {
12128 return g_tree_search(&this, search_func, user_data);
12131 // Removes a key and its associated value from a #GTree without calling
12132 // the key and value destroy functions.
12134 // If the key does not exist in the #GTree, the function does nothing.
12136 // nothing)
12137 // RETURNS: %TRUE if the key was found (prior to 2.8, this function returned
12138 // <key>: the key to remove.
12139 int steal()(const(void)* key) {
12140 return g_tree_steal(&this, key);
12143 // Unintrospectable method: traverse() / g_tree_traverse()
12144 // Calls the given function for each node in the #GTree.
12146 // Deprecated:2.2: The order of a balanced tree is somewhat arbitrary. If you
12147 // just want to visit all nodes in sorted order, use g_tree_foreach()
12148 // instead. If you really need to visit nodes in a different order, consider
12149 // using an <link linkend="glib-N-ary-Trees">N-ary Tree</link>.
12150 // <traverse_func>: the function to call for each node visited. If this function returns %TRUE, the traversal is stopped.
12151 // <traverse_type>: the order in which nodes are visited, one of %G_IN_ORDER, %G_PRE_ORDER and %G_POST_ORDER.
12152 // <user_data>: user data to pass to the function.
12153 void traverse()(TraverseFunc traverse_func, TraverseType traverse_type, void* user_data) {
12154 g_tree_traverse(&this, traverse_func, traverse_type, user_data);
12157 // VERSION: 2.22
12158 // Decrements the reference count of @tree by one. If the reference count
12159 // drops to 0, all keys and values will be destroyed (if destroy
12160 // functions were specified) and all memory allocated by @tree will be
12161 // released.
12163 // It is safe to call this function from any thread.
12164 void unref()() {
12165 g_tree_unref(&this);
12168 // Unintrospectable function: new() / g_tree_new()
12169 // Creates a new #GTree.
12170 // RETURNS: a new #GTree.
12171 // <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.
12172 static Tree* new_()(CompareFunc key_compare_func) {
12173 return g_tree_new(key_compare_func);
12176 // Unintrospectable function: new_full() / g_tree_new_full()
12177 // Creates a new #GTree like g_tree_new() and allows to specify functions
12178 // to free the memory allocated for the key and value that get called when
12179 // removing the entry from the #GTree.
12180 // RETURNS: a new #GTree.
12181 // <key_compare_func>: qsort()-style comparison function.
12182 // <key_compare_data>: data to pass to comparison function.
12183 // <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.
12184 // <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.
12185 static Tree* new_full()(CompareDataFunc key_compare_func, void* key_compare_data, DestroyNotify key_destroy_func, DestroyNotify value_destroy_func) {
12186 return g_tree_new_full(key_compare_func, key_compare_data, key_destroy_func, value_destroy_func);
12189 // Unintrospectable function: new_with_data() / g_tree_new_with_data()
12190 // Creates a new #GTree with a comparison function that accepts user data.
12191 // See g_tree_new() for more details.
12192 // RETURNS: a new #GTree.
12193 // <key_compare_func>: qsort()-style comparison function.
12194 // <key_compare_data>: data to pass to comparison function.
12195 static Tree* new_with_data()(CompareDataFunc key_compare_func, void* key_compare_data) {
12196 return g_tree_new_with_data(key_compare_func, key_compare_data);
12201 // The #GTuples struct is used to return records (or tuples) from the
12202 // #GRelation by g_relation_select(). It only contains one public
12203 // member - the number of records that matched. To access the matched
12204 // records, you must use g_tuples_index().
12205 struct Tuples {
12206 uint len;
12209 // DEPRECATED (v2.26) method: destroy - Rarely used API
12210 // Frees the records which were returned by g_relation_select(). This
12211 // should always be called after g_relation_select() when you are
12212 // finished with the records. The records are not removed from the
12213 // #GRelation.
12214 void destroy()() {
12215 g_tuples_destroy(&this);
12218 // Unintrospectable method: index() / g_tuples_index()
12219 // DEPRECATED (v2.26) method: index - Rarely used API
12220 // Gets a field from the records returned by g_relation_select(). It
12221 // returns the given field of the record at the given index. The
12222 // returned value should not be changed.
12223 // <index_>: the index of the record.
12224 // <field>: the field to return.
12225 void* index()(int index_, int field) {
12226 return g_tuples_index(&this, index_, field);
12230 enum URI_RESERVED_CHARS_GENERIC_DELIMITERS = ":/?#[]@";
12231 enum URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS = "!$&'()*+,;=";
12232 enum int USEC_PER_SEC = 1000000;
12234 // These are the possible line break classifications.
12236 // The five Hangul types were added in Unicode 4.1, so, has been
12237 // introduced in GLib 2.10. Note that new types may be added in the future.
12238 // Applications should be ready to handle unknown values.
12239 // They may be regarded as %G_UNICODE_BREAK_UNKNOWN.
12241 // See <ulink url="http://www.unicode.org/unicode/reports/tr14/">http://www.unicode.org/unicode/reports/tr14/</ulink>.
12242 enum UnicodeBreakType {
12243 MANDATORY = 0,
12244 CARRIAGE_RETURN = 1,
12245 LINE_FEED = 2,
12246 COMBINING_MARK = 3,
12247 SURROGATE = 4,
12248 ZERO_WIDTH_SPACE = 5,
12249 INSEPARABLE = 6,
12250 NON_BREAKING_GLUE = 7,
12251 CONTINGENT = 8,
12252 SPACE = 9,
12253 AFTER = 10,
12254 BEFORE = 11,
12255 BEFORE_AND_AFTER = 12,
12256 HYPHEN = 13,
12257 NON_STARTER = 14,
12258 OPEN_PUNCTUATION = 15,
12259 CLOSE_PUNCTUATION = 16,
12260 QUOTATION = 17,
12261 EXCLAMATION = 18,
12262 IDEOGRAPHIC = 19,
12263 NUMERIC = 20,
12264 INFIX_SEPARATOR = 21,
12265 SYMBOL = 22,
12266 ALPHABETIC = 23,
12267 PREFIX = 24,
12268 POSTFIX = 25,
12269 COMPLEX_CONTEXT = 26,
12270 AMBIGUOUS = 27,
12271 UNKNOWN = 28,
12272 NEXT_LINE = 29,
12273 WORD_JOINER = 30,
12274 HANGUL_L_JAMO = 31,
12275 HANGUL_V_JAMO = 32,
12276 HANGUL_T_JAMO = 33,
12277 HANGUL_LV_SYLLABLE = 34,
12278 HANGUL_LVT_SYLLABLE = 35,
12279 CLOSE_PARANTHESIS = 36
12282 // The #GUnicodeScript enumeration identifies different writing
12283 // systems. The values correspond to the names as defined in the
12284 // Unicode standard. The enumeration has been added in GLib 2.14,
12285 // and is interchangeable with #PangoScript.
12287 // Note that new types may be added in the future. Applications
12288 // should be ready to handle unknown values.
12289 // See <ulink
12290 // url="http://www.unicode.org/reports/tr24/">Unicode Standard Annex
12291 // #24: Script names</ulink>.
12292 enum UnicodeScript {
12293 INVALID_CODE = -1,
12294 COMMON = 0,
12295 INHERITED = 1,
12296 ARABIC = 2,
12297 ARMENIAN = 3,
12298 BENGALI = 4,
12299 BOPOMOFO = 5,
12300 CHEROKEE = 6,
12301 COPTIC = 7,
12302 CYRILLIC = 8,
12303 DESERET = 9,
12304 DEVANAGARI = 10,
12305 ETHIOPIC = 11,
12306 GEORGIAN = 12,
12307 GOTHIC = 13,
12308 GREEK = 14,
12309 GUJARATI = 15,
12310 GURMUKHI = 16,
12311 HAN = 17,
12312 HANGUL = 18,
12313 HEBREW = 19,
12314 HIRAGANA = 20,
12315 KANNADA = 21,
12316 KATAKANA = 22,
12317 KHMER = 23,
12318 LAO = 24,
12319 LATIN = 25,
12320 MALAYALAM = 26,
12321 MONGOLIAN = 27,
12322 MYANMAR = 28,
12323 OGHAM = 29,
12324 OLD_ITALIC = 30,
12325 ORIYA = 31,
12326 RUNIC = 32,
12327 SINHALA = 33,
12328 SYRIAC = 34,
12329 TAMIL = 35,
12330 TELUGU = 36,
12331 THAANA = 37,
12332 THAI = 38,
12333 TIBETAN = 39,
12334 CANADIAN_ABORIGINAL = 40,
12335 YI = 41,
12336 TAGALOG = 42,
12337 HANUNOO = 43,
12338 BUHID = 44,
12339 TAGBANWA = 45,
12340 BRAILLE = 46,
12341 CYPRIOT = 47,
12342 LIMBU = 48,
12343 OSMANYA = 49,
12344 SHAVIAN = 50,
12345 LINEAR_B = 51,
12346 TAI_LE = 52,
12347 UGARITIC = 53,
12348 NEW_TAI_LUE = 54,
12349 BUGINESE = 55,
12350 GLAGOLITIC = 56,
12351 TIFINAGH = 57,
12352 SYLOTI_NAGRI = 58,
12353 OLD_PERSIAN = 59,
12354 KHAROSHTHI = 60,
12355 UNKNOWN = 61,
12356 BALINESE = 62,
12357 CUNEIFORM = 63,
12358 PHOENICIAN = 64,
12359 PHAGS_PA = 65,
12360 NKO = 66,
12361 KAYAH_LI = 67,
12362 LEPCHA = 68,
12363 REJANG = 69,
12364 SUNDANESE = 70,
12365 SAURASHTRA = 71,
12366 CHAM = 72,
12367 OL_CHIKI = 73,
12368 VAI = 74,
12369 CARIAN = 75,
12370 LYCIAN = 76,
12371 LYDIAN = 77,
12372 AVESTAN = 78,
12373 BAMUM = 79,
12374 EGYPTIAN_HIEROGLYPHS = 80,
12375 IMPERIAL_ARAMAIC = 81,
12376 INSCRIPTIONAL_PAHLAVI = 82,
12377 INSCRIPTIONAL_PARTHIAN = 83,
12378 JAVANESE = 84,
12379 KAITHI = 85,
12380 LISU = 86,
12381 MEETEI_MAYEK = 87,
12382 OLD_SOUTH_ARABIAN = 88,
12383 OLD_TURKIC = 89,
12384 SAMARITAN = 90,
12385 TAI_THAM = 91,
12386 TAI_VIET = 92,
12387 BATAK = 93,
12388 BRAHMI = 94,
12389 MANDAIC = 95
12392 // These are the possible character classifications from the
12393 // Unicode specification.
12394 // See <ulink url="http://www.unicode.org/Public/UNIDATA/UnicodeData.html">http://www.unicode.org/Public/UNIDATA/UnicodeData.html</ulink>.
12395 enum UnicodeType {
12396 CONTROL = 0,
12397 FORMAT = 1,
12398 UNASSIGNED = 2,
12399 PRIVATE_USE = 3,
12400 SURROGATE = 4,
12401 LOWERCASE_LETTER = 5,
12402 MODIFIER_LETTER = 6,
12403 OTHER_LETTER = 7,
12404 TITLECASE_LETTER = 8,
12405 UPPERCASE_LETTER = 9,
12406 SPACING_MARK = 10,
12407 ENCLOSING_MARK = 11,
12408 NON_SPACING_MARK = 12,
12409 DECIMAL_NUMBER = 13,
12410 LETTER_NUMBER = 14,
12411 OTHER_NUMBER = 15,
12412 CONNECT_PUNCTUATION = 16,
12413 DASH_PUNCTUATION = 17,
12414 CLOSE_PUNCTUATION = 18,
12415 FINAL_PUNCTUATION = 19,
12416 INITIAL_PUNCTUATION = 20,
12417 OTHER_PUNCTUATION = 21,
12418 OPEN_PUNCTUATION = 22,
12419 CURRENCY_SYMBOL = 23,
12420 MODIFIER_SYMBOL = 24,
12421 MATH_SYMBOL = 25,
12422 OTHER_SYMBOL = 26,
12423 LINE_SEPARATOR = 27,
12424 PARAGRAPH_SEPARATOR = 28,
12425 SPACE_SEPARATOR = 29
12428 // These are logical ids for special directories which are defined
12429 // depending on the platform used. You should use g_get_user_special_dir()
12430 // to retrieve the full path associated to the logical id.
12432 // The #GUserDirectory enumeration can be extended at later date. Not
12433 // every platform has a directory for every logical id in this
12434 // enumeration.
12435 enum UserDirectory /* Version 2.14 */ {
12436 DIRECTORY_DESKTOP = 0,
12437 DIRECTORY_DOCUMENTS = 1,
12438 DIRECTORY_DOWNLOAD = 2,
12439 DIRECTORY_MUSIC = 3,
12440 DIRECTORY_PICTURES = 4,
12441 DIRECTORY_PUBLIC_SHARE = 5,
12442 DIRECTORY_TEMPLATES = 6,
12443 DIRECTORY_VIDEOS = 7,
12444 N_DIRECTORIES = 8
12447 // #GVariant is a variant datatype; it stores a value along with
12448 // information about the type of that value. The range of possible
12449 // values is determined by the type. The type system used by #GVariant
12450 // is #GVariantType.
12452 // #GVariant instances always have a type and a value (which are given
12453 // at construction time). The type and value of a #GVariant instance
12454 // can never change other than by the #GVariant itself being
12455 // destroyed. A #GVariant cannot contain a pointer.
12457 // #GVariant is reference counted using g_variant_ref() and
12458 // g_variant_unref(). #GVariant also has floating reference counts --
12459 // see g_variant_ref_sink().
12461 // #GVariant is completely threadsafe. A #GVariant instance can be
12462 // concurrently accessed in any way from any number of threads without
12463 // problems.
12465 // #GVariant is heavily optimised for dealing with data in serialised
12466 // form. It works particularly well with data located in memory-mapped
12467 // files. It can perform nearly all deserialisation operations in a
12468 // small constant time, usually touching only a single memory page.
12469 // Serialised #GVariant data can also be sent over the network.
12471 // #GVariant is largely compatible with D-Bus. Almost all types of
12472 // #GVariant instances can be sent over D-Bus. See #GVariantType for
12473 // exceptions.
12475 // For convenience to C programmers, #GVariant features powerful
12476 // varargs-based value construction and destruction. This feature is
12477 // designed to be embedded in other libraries.
12479 // There is a Python-inspired text language for describing #GVariant
12480 // values. #GVariant includes a printer for this language and a parser
12481 // with type inferencing.
12483 // <refsect2>
12484 // <title>Memory Use</title>
12485 // <para>
12486 // #GVariant tries to be quite efficient with respect to memory use.
12487 // This section gives a rough idea of how much memory is used by the
12488 // current implementation. The information here is subject to change
12489 // in the future.
12490 // </para>
12491 // <para>
12492 // The memory allocated by #GVariant can be grouped into 4 broad
12493 // purposes: memory for serialised data, memory for the type
12494 // information cache, buffer management memory and memory for the
12495 // #GVariant structure itself.
12496 // </para>
12497 // <refsect3>
12498 // <title>Serialised Data Memory</title>
12499 // <para>
12500 // This is the memory that is used for storing GVariant data in
12501 // serialised form. This is what would be sent over the network or
12502 // what would end up on disk.
12503 // </para>
12504 // <para>
12505 // The amount of memory required to store a boolean is 1 byte. 16,
12506 // 32 and 64 bit integers and double precision floating point numbers
12507 // use their "natural" size. Strings (including object path and
12508 // signature strings) are stored with a nul terminator, and as such
12509 // use the length of the string plus 1 byte.
12510 // </para>
12511 // <para>
12512 // Maybe types use no space at all to represent the null value and
12513 // use the same amount of space (sometimes plus one byte) as the
12514 // equivalent non-maybe-typed value to represent the non-null case.
12515 // </para>
12516 // <para>
12517 // Arrays use the amount of space required to store each of their
12518 // members, concatenated. Additionally, if the items stored in an
12519 // array are not of a fixed-size (ie: strings, other arrays, etc)
12520 // then an additional framing offset is stored for each item. The
12521 // size of this offset is either 1, 2 or 4 bytes depending on the
12522 // overall size of the container. Additionally, extra padding bytes
12523 // are added as required for alignment of child values.
12524 // </para>
12525 // <para>
12526 // Tuples (including dictionary entries) use the amount of space
12527 // required to store each of their members, concatenated, plus one
12528 // framing offset (as per arrays) for each non-fixed-sized item in
12529 // the tuple, except for the last one. Additionally, extra padding
12530 // bytes are added as required for alignment of child values.
12531 // </para>
12532 // <para>
12533 // Variants use the same amount of space as the item inside of the
12534 // variant, plus 1 byte, plus the length of the type string for the
12535 // item inside the variant.
12536 // </para>
12537 // <para>
12538 // As an example, consider a dictionary mapping strings to variants.
12539 // In the case that the dictionary is empty, 0 bytes are required for
12540 // the serialisation.
12541 // </para>
12542 // <para>
12543 // If we add an item "width" that maps to the int32 value of 500 then
12544 // we will use 4 byte to store the int32 (so 6 for the variant
12545 // containing it) and 6 bytes for the string. The variant must be
12546 // aligned to 8 after the 6 bytes of the string, so that's 2 extra
12547 // bytes. 6 (string) + 2 (padding) + 6 (variant) is 14 bytes used
12548 // for the dictionary entry. An additional 1 byte is added to the
12549 // array as a framing offset making a total of 15 bytes.
12550 // </para>
12551 // <para>
12552 // If we add another entry, "title" that maps to a nullable string
12553 // that happens to have a value of null, then we use 0 bytes for the
12554 // null value (and 3 bytes for the variant to contain it along with
12555 // its type string) plus 6 bytes for the string. Again, we need 2
12556 // padding bytes. That makes a total of 6 + 2 + 3 = 11 bytes.
12557 // </para>
12558 // <para>
12559 // We now require extra padding between the two items in the array.
12560 // After the 14 bytes of the first item, that's 2 bytes required. We
12561 // now require 2 framing offsets for an extra two bytes. 14 + 2 + 11
12562 // + 2 = 29 bytes to encode the entire two-item dictionary.
12563 // </para>
12564 // </refsect3>
12565 // <refsect3>
12566 // <title>Type Information Cache</title>
12567 // <para>
12568 // For each GVariant type that currently exists in the program a type
12569 // information structure is kept in the type information cache. The
12570 // type information structure is required for rapid deserialisation.
12571 // </para>
12572 // <para>
12573 // Continuing with the above example, if a #GVariant exists with the
12574 // type "a{sv}" then a type information struct will exist for
12575 // "a{sv}", "{sv}", "s", and "v". Multiple uses of the same type
12576 // will share the same type information. Additionally, all
12577 // single-digit types are stored in read-only static memory and do
12578 // not contribute to the writable memory footprint of a program using
12579 // #GVariant.
12580 // </para>
12581 // <para>
12582 // Aside from the type information structures stored in read-only
12583 // memory, there are two forms of type information. One is used for
12584 // container types where there is a single element type: arrays and
12585 // maybe types. The other is used for container types where there
12586 // are multiple element types: tuples and dictionary entries.
12587 // </para>
12588 // <para>
12589 // Array type info structures are 6 * sizeof (void *), plus the
12590 // memory required to store the type string itself. This means that
12591 // on 32bit systems, the cache entry for "a{sv}" would require 30
12592 // bytes of memory (plus malloc overhead).
12593 // </para>
12594 // <para>
12595 // Tuple type info structures are 6 * sizeof (void *), plus 4 *
12596 // sizeof (void *) for each item in the tuple, plus the memory
12597 // required to store the type string itself. A 2-item tuple, for
12598 // example, would have a type information structure that consumed
12599 // writable memory in the size of 14 * sizeof (void *) (plus type
12600 // string) This means that on 32bit systems, the cache entry for
12601 // "{sv}" would require 61 bytes of memory (plus malloc overhead).
12602 // </para>
12603 // <para>
12604 // This means that in total, for our "a{sv}" example, 91 bytes of
12605 // type information would be allocated.
12606 // </para>
12607 // <para>
12608 // The type information cache, additionally, uses a #GHashTable to
12609 // store and lookup the cached items and stores a pointer to this
12610 // hash table in static storage. The hash table is freed when there
12611 // are zero items in the type cache.
12612 // </para>
12613 // <para>
12614 // Although these sizes may seem large it is important to remember
12615 // that a program will probably only have a very small number of
12616 // different types of values in it and that only one type information
12617 // structure is required for many different values of the same type.
12618 // </para>
12619 // </refsect3>
12620 // <refsect3>
12621 // <title>Buffer Management Memory</title>
12622 // <para>
12623 // #GVariant uses an internal buffer management structure to deal
12624 // with the various different possible sources of serialised data
12625 // that it uses. The buffer is responsible for ensuring that the
12626 // correct call is made when the data is no longer in use by
12627 // #GVariant. This may involve a g_free() or a g_slice_free() or
12628 // even g_mapped_file_unref().
12629 // </para>
12630 // <para>
12631 // One buffer management structure is used for each chunk of
12632 // serialised data. The size of the buffer management structure is 4
12633 // * (void *). On 32bit systems, that's 16 bytes.
12634 // </para>
12635 // </refsect3>
12636 // <refsect3>
12637 // <title>GVariant structure</title>
12638 // <para>
12639 // The size of a #GVariant structure is 6 * (void *). On 32 bit
12640 // systems, that's 24 bytes.
12641 // </para>
12642 // <para>
12643 // #GVariant structures only exist if they are explicitly created
12644 // with API calls. For example, if a #GVariant is constructed out of
12645 // serialised data for the example given above (with the dictionary)
12646 // then although there are 9 individual values that comprise the
12647 // entire dictionary (two keys, two values, two variants containing
12648 // the values, two dictionary entries, plus the dictionary itself),
12649 // only 1 #GVariant instance exists -- the one referring to the
12650 // dictionary.
12651 // </para>
12652 // <para>
12653 // If calls are made to start accessing the other values then
12654 // #GVariant instances will exist for those values only for as long
12655 // as they are in use (ie: until you call g_variant_unref()). The
12656 // type information is shared. The serialised data and the buffer
12657 // management structure for that serialised data is shared by the
12658 // child.
12659 // </para>
12660 // </refsect3>
12661 // <refsect3>
12662 // <title>Summary</title>
12663 // <para>
12664 // To put the entire example together, for our dictionary mapping
12665 // strings to variants (with two entries, as given above), we are
12666 // using 91 bytes of memory for type information, 29 byes of memory
12667 // for the serialised data, 16 bytes for buffer management and 24
12668 // bytes for the #GVariant instance, or a total of 160 bytes, plus
12669 // malloc overhead. If we were to use g_variant_get_child_value() to
12670 // access the two dictionary entries, we would use an additional 48
12671 // bytes. If we were to have other dictionaries of the same type, we
12672 // would use more memory for the serialised data and buffer
12673 // management for those dictionaries, but the type information would
12674 // be shared.
12675 // </para>
12676 // </refsect3>
12677 // </refsect2>
12678 struct Variant /* Version 2.24 */ {
12680 // Unintrospectable constructor: new() / g_variant_new()
12681 // VERSION: 2.24
12682 // Creates a new #GVariant instance.
12684 // Think of this function as an analogue to g_strdup_printf().
12686 // The type of the created instance and the arguments that are
12687 // expected by this function are determined by @format_string. See the
12688 // section on <link linkend='gvariant-format-strings'>GVariant Format
12689 // Strings</link>. Please note that the syntax of the format string is
12690 // very likely to be extended in the future.
12692 // The first character of the format string must not be '*' '?' '@' or
12693 // 'r'; in essence, a new #GVariant must always be constructed by this
12694 // function (and not merely passed through it unmodified).
12695 // RETURNS: a new floating #GVariant instance
12696 // <format_string>: a #GVariant format string
12697 alias g_variant_new new_; // Variadic
12699 // VERSION: 2.24
12700 // Creates a new #GVariant array from @children.
12702 // @child_type must be non-%NULL if @n_children is zero. Otherwise, the
12703 // child type is determined by inspecting the first element of the
12704 // @children array. If @child_type is non-%NULL then it must be a
12705 // definite type.
12707 // The items of the array are taken from the @children array. No entry
12708 // in the @children array may be %NULL.
12710 // All items in the array must have the same type, which must be the
12711 // same as @child_type, if given.
12713 // If the @children are floating references (see g_variant_ref_sink()), the
12714 // new instance takes ownership of them as if via g_variant_ref_sink().
12715 // RETURNS: a floating reference to a new #GVariant array
12716 // <child_type>: the element type of the new array
12717 // <children>: an array of #GVariant pointers, the children
12718 // <n_children>: the length of @children
12719 static Variant* new_array()(VariantType* child_type, Variant** children, size_t n_children) {
12720 return g_variant_new_array(child_type, children, n_children);
12723 // VERSION: 2.24
12724 // Creates a new boolean #GVariant instance -- either %TRUE or %FALSE.
12725 // RETURNS: a floating reference to a new boolean #GVariant instance
12726 // <value>: a #gboolean value
12727 static Variant* new_boolean()(int value) {
12728 return g_variant_new_boolean(value);
12731 // VERSION: 2.24
12732 // Creates a new byte #GVariant instance.
12733 // RETURNS: a floating reference to a new byte #GVariant instance
12734 // <value>: a #guint8 value
12735 static Variant* new_byte()(ubyte value) {
12736 return g_variant_new_byte(value);
12739 // VERSION: 2.26
12740 // Creates an array-of-bytes #GVariant with the contents of @string.
12741 // This function is just like g_variant_new_string() except that the
12742 // string need not be valid utf8.
12744 // The nul terminator character at the end of the string is stored in
12745 // the array.
12746 // RETURNS: a floating reference to a new bytestring #GVariant instance
12747 // <string>: a normal nul-terminated string in no particular encoding
12748 static Variant* new_bytestring()(ubyte* string_) {
12749 return g_variant_new_bytestring(string_);
12752 // VERSION: 2.26
12753 // Constructs an array of bytestring #GVariant from the given array of
12754 // strings.
12756 // If @length is -1 then @strv is %NULL-terminated.
12757 // RETURNS: a new floating #GVariant instance
12758 // <strv>: an array of strings
12759 // <length>: the length of @strv, or -1
12760 static Variant* new_bytestring_array()(char** strv, ssize_t length) {
12761 return g_variant_new_bytestring_array(strv, length);
12764 // VERSION: 2.24
12765 // Creates a new dictionary entry #GVariant. @key and @value must be
12766 // non-%NULL. @key must be a value of a basic type (ie: not a container).
12768 // If the @key or @value are floating references (see g_variant_ref_sink()),
12769 // the new instance takes ownership of them as if via g_variant_ref_sink().
12770 // RETURNS: a floating reference to a new dictionary entry #GVariant
12771 // <key>: a basic #GVariant, the key
12772 // <value>: a #GVariant, the value
12773 static Variant* new_dict_entry()(Variant* key, Variant* value) {
12774 return g_variant_new_dict_entry(key, value);
12777 // VERSION: 2.24
12778 // Creates a new double #GVariant instance.
12779 // RETURNS: a floating reference to a new double #GVariant instance
12780 // <value>: a #gdouble floating point value
12781 static Variant* new_double()(double value) {
12782 return g_variant_new_double(value);
12785 // VERSION: 2.24
12786 // Creates a new #GVariant instance from serialised data.
12788 // @type is the type of #GVariant instance that will be constructed.
12789 // The interpretation of @data depends on knowing the type.
12791 // @data is not modified by this function and must remain valid with an
12792 // unchanging value until such a time as @notify is called with
12793 // @user_data. If the contents of @data change before that time then
12794 // the result is undefined.
12796 // If @data is trusted to be serialised data in normal form then
12797 // @trusted should be %TRUE. This applies to serialised data created
12798 // within this process or read from a trusted location on the disk (such
12799 // as a file installed in /usr/lib alongside your application). You
12800 // should set trusted to %FALSE if @data is read from the network, a
12801 // file in the user's home directory, etc.
12803 // @notify will be called with @user_data when @data is no longer
12804 // needed. The exact time of this call is unspecified and might even be
12805 // before this function returns.
12806 // RETURNS: a new floating #GVariant of type @type
12807 // <type>: a definite #GVariantType
12808 // <data>: the serialised data
12809 // <size>: the size of @data
12810 // <trusted>: %TRUE if @data is definitely in normal form
12811 // <notify>: function to call when @data is no longer needed
12812 // <user_data>: data for @notify
12813 static Variant* new_from_data()(VariantType* type, const(ubyte)* data, size_t size, int trusted, DestroyNotify notify, void* user_data) {
12814 return g_variant_new_from_data(type, data, size, trusted, notify, user_data);
12817 // VERSION: 2.24
12818 // Creates a new handle #GVariant instance.
12820 // By convention, handles are indexes into an array of file descriptors
12821 // that are sent alongside a D-Bus message. If you're not interacting
12822 // with D-Bus, you probably don't need them.
12823 // RETURNS: a floating reference to a new handle #GVariant instance
12824 // <value>: a #gint32 value
12825 static Variant* new_handle()(int value) {
12826 return g_variant_new_handle(value);
12829 // VERSION: 2.24
12830 // Creates a new int16 #GVariant instance.
12831 // RETURNS: a floating reference to a new int16 #GVariant instance
12832 // <value>: a #gint16 value
12833 static Variant* new_int16()(short value) {
12834 return g_variant_new_int16(value);
12837 // VERSION: 2.24
12838 // Creates a new int32 #GVariant instance.
12839 // RETURNS: a floating reference to a new int32 #GVariant instance
12840 // <value>: a #gint32 value
12841 static Variant* new_int32()(int value) {
12842 return g_variant_new_int32(value);
12845 // VERSION: 2.24
12846 // Creates a new int64 #GVariant instance.
12847 // RETURNS: a floating reference to a new int64 #GVariant instance
12848 // <value>: a #gint64 value
12849 static Variant* new_int64()(long value) {
12850 return g_variant_new_int64(value);
12853 // VERSION: 2.24
12854 // Depending on if @child is %NULL, either wraps @child inside of a
12855 // maybe container or creates a Nothing instance for the given @type.
12857 // At least one of @child_type and @child must be non-%NULL.
12858 // If @child_type is non-%NULL then it must be a definite type.
12859 // If they are both non-%NULL then @child_type must be the type
12860 // of @child.
12862 // If @child is a floating reference (see g_variant_ref_sink()), the new
12863 // instance takes ownership of @child.
12864 // RETURNS: a floating reference to a new #GVariant maybe instance
12865 // <child_type>: the #GVariantType of the child, or %NULL
12866 // <child>: the child value, or %NULL
12867 static Variant* new_maybe()(VariantType* child_type=null, Variant* child=null) {
12868 return g_variant_new_maybe(child_type, child);
12871 // VERSION: 2.24
12872 // Creates a D-Bus object path #GVariant with the contents of @string.
12873 // @string must be a valid D-Bus object path. Use
12874 // g_variant_is_object_path() if you're not sure.
12875 // RETURNS: a floating reference to a new object path #GVariant instance
12876 // <object_path>: a normal C nul-terminated string
12877 static Variant* new_object_path()(char* object_path) {
12878 return g_variant_new_object_path(object_path);
12881 // VERSION: 2.30
12882 // Constructs an array of object paths #GVariant from the given array of
12883 // strings.
12885 // Each string must be a valid #GVariant object path; see
12886 // g_variant_is_object_path().
12888 // If @length is -1 then @strv is %NULL-terminated.
12889 // RETURNS: a new floating #GVariant instance
12890 // <strv>: an array of strings
12891 // <length>: the length of @strv, or -1
12892 static Variant* new_objv()(char** strv, ssize_t length) {
12893 return g_variant_new_objv(strv, length);
12896 // Unintrospectable constructor: new_parsed() / g_variant_new_parsed()
12897 // Parses @format and returns the result.
12899 // point that a value may appear in the text, a '%' character followed
12900 // by a GVariant format string (as per g_variant_new()) may appear. In
12901 // that case, the same arguments are collected from the argument list as
12902 // g_variant_new() would have collected.
12904 // Consider this simple example:
12906 // <informalexample><programlisting>
12907 // g_variant_new_parsed ("[('one', 1), ('two', %i), (%s, 3)]", 2, "three");
12908 // </programlisting></informalexample>
12910 // In the example, the variable argument parameters are collected and
12911 // filled in as if they were part of the original string to produce the
12912 // result of <code>[('one', 1), ('two', 2), ('three', 3)]</code>.
12914 // This function is intended only to be used with @format as a string
12915 // literal. Any parse error is fatal to the calling process. If you
12916 // want to parse data from untrusted sources, use g_variant_parse().
12918 // You may not use this function to return, unmodified, a single
12919 // #GVariant pointer from the argument list. ie: @format may not solely
12920 // be anything along the lines of "%*", "%?", "%r", or anything starting
12921 // with "%@".
12922 // RETURNS: a new floating #GVariant instance
12923 // <format>: a text format #GVariant
12924 alias g_variant_new_parsed new_parsed; // Variadic
12926 // Unintrospectable constructor: new_parsed_va() / g_variant_new_parsed_va()
12927 // Parses @format and returns the result.
12929 // This is the version of g_variant_new_parsed() intended to be used
12930 // from libraries.
12932 // The return value will be floating if it was a newly created GVariant
12933 // instance. In the case that @format simply specified the collection
12934 // of a #GVariant pointer (eg: @format was "%*") then the collected
12935 // #GVariant pointer will be returned unmodified, without adding any
12936 // additional references.
12938 // In order to behave correctly in all cases it is necessary for the
12939 // calling function to g_variant_ref_sink() the return result before
12940 // returning control to the user that originally provided the pointer.
12941 // At this point, the caller will have their own full reference to the
12942 // result. This can also be done by adding the result to a container,
12943 // or by passing it to another g_variant_new() call.
12944 // RETURNS: a new, usually floating, #GVariant
12945 // <format>: a text format #GVariant
12946 // <app>: a pointer to a #va_list
12947 static Variant* /*new*/ new_parsed_va()(char* format, va_list* app) {
12948 return g_variant_new_parsed_va(format, app);
12951 // VERSION: 2.24
12952 // Creates a D-Bus type signature #GVariant with the contents of
12953 // @string. @string must be a valid D-Bus type signature. Use
12954 // g_variant_is_signature() if you're not sure.
12955 // RETURNS: a floating reference to a new signature #GVariant instance
12956 // <signature>: a normal C nul-terminated string
12957 static Variant* new_signature()(char* signature) {
12958 return g_variant_new_signature(signature);
12961 // VERSION: 2.24
12962 // Creates a string #GVariant with the contents of @string.
12964 // @string must be valid utf8.
12965 // RETURNS: a floating reference to a new string #GVariant instance
12966 // <string>: a normal utf8 nul-terminated string
12967 static Variant* new_string()(char* string_) {
12968 return g_variant_new_string(string_);
12971 // VERSION: 2.24
12972 // Constructs an array of strings #GVariant from the given array of
12973 // strings.
12975 // If @length is -1 then @strv is %NULL-terminated.
12976 // RETURNS: a new floating #GVariant instance
12977 // <strv>: an array of strings
12978 // <length>: the length of @strv, or -1
12979 static Variant* new_strv()(char** strv, ssize_t length) {
12980 return g_variant_new_strv(strv, length);
12983 // VERSION: 2.24
12984 // Creates a new tuple #GVariant out of the items in @children. The
12985 // type is determined from the types of @children. No entry in the
12986 // @children array may be %NULL.
12988 // If @n_children is 0 then the unit tuple is constructed.
12990 // If the @children are floating references (see g_variant_ref_sink()), the
12991 // new instance takes ownership of them as if via g_variant_ref_sink().
12992 // RETURNS: a floating reference to a new #GVariant tuple
12993 // <children>: the items to make the tuple out of
12994 // <n_children>: the length of @children
12995 static Variant* new_tuple()(Variant** children, size_t n_children) {
12996 return g_variant_new_tuple(children, n_children);
12999 // VERSION: 2.24
13000 // Creates a new uint16 #GVariant instance.
13001 // RETURNS: a floating reference to a new uint16 #GVariant instance
13002 // <value>: a #guint16 value
13003 static Variant* new_uint16()(ushort value) {
13004 return g_variant_new_uint16(value);
13007 // VERSION: 2.24
13008 // Creates a new uint32 #GVariant instance.
13009 // RETURNS: a floating reference to a new uint32 #GVariant instance
13010 // <value>: a #guint32 value
13011 static Variant* new_uint32()(uint value) {
13012 return g_variant_new_uint32(value);
13015 // VERSION: 2.24
13016 // Creates a new uint64 #GVariant instance.
13017 // RETURNS: a floating reference to a new uint64 #GVariant instance
13018 // <value>: a #guint64 value
13019 static Variant* new_uint64()(ulong value) {
13020 return g_variant_new_uint64(value);
13023 // Unintrospectable constructor: new_va() / g_variant_new_va()
13024 // VERSION: 2.24
13025 // This function is intended to be used by libraries based on
13026 // #GVariant that want to provide g_variant_new()-like functionality
13027 // to their users.
13029 // The API is more general than g_variant_new() to allow a wider range
13030 // of possible uses.
13032 // @format_string must still point to a valid format string, but it only
13033 // needs to be nul-terminated if @endptr is %NULL. If @endptr is
13034 // non-%NULL then it is updated to point to the first character past the
13035 // end of the format string.
13037 // @app is a pointer to a #va_list. The arguments, according to
13038 // @format_string, are collected from this #va_list and the list is left
13039 // pointing to the argument following the last.
13041 // These two generalisations allow mixing of multiple calls to
13042 // g_variant_new_va() and g_variant_get_va() within a single actual
13043 // varargs call by the user.
13045 // The return value will be floating if it was a newly created GVariant
13046 // instance (for example, if the format string was "(ii)"). In the case
13047 // that the format_string was '*', '?', 'r', or a format starting with
13048 // '@' then the collected #GVariant pointer will be returned unmodified,
13049 // without adding any additional references.
13051 // In order to behave correctly in all cases it is necessary for the
13052 // calling function to g_variant_ref_sink() the return result before
13053 // returning control to the user that originally provided the pointer.
13054 // At this point, the caller will have their own full reference to the
13055 // result. This can also be done by adding the result to a container,
13056 // or by passing it to another g_variant_new() call.
13057 // RETURNS: a new, usually floating, #GVariant
13058 // <format_string>: a string that is prefixed with a format string
13059 // <endptr>: location to store the end pointer, or %NULL
13060 // <app>: a pointer to a #va_list
13061 static Variant* /*new*/ new_va()(char* format_string, char** endptr, va_list* app) {
13062 return g_variant_new_va(format_string, endptr, app);
13065 // VERSION: 2.24
13066 // Boxes @value. The result is a #GVariant instance representing a
13067 // variant containing the original value.
13069 // If @child is a floating reference (see g_variant_ref_sink()), the new
13070 // instance takes ownership of @child.
13071 // RETURNS: a floating reference to a new variant #GVariant instance
13072 // <value>: a #GVariant instance
13073 static Variant* new_variant()(Variant* value) {
13074 return g_variant_new_variant(value);
13077 // VERSION: 2.24
13078 // Performs a byteswapping operation on the contents of @value. The
13079 // result is that all multi-byte numeric data contained in @value is
13080 // byteswapped. That includes 16, 32, and 64bit signed and unsigned
13081 // integers as well as file handles and double precision floating point
13082 // values.
13084 // This function is an identity mapping on any value that does not
13085 // contain multi-byte numeric data. That include strings, booleans,
13086 // bytes and containers containing only these things (recursively).
13088 // The returned value is always in normal form and is marked as trusted.
13089 // RETURNS: the byteswapped form of @value
13090 Variant* /*new*/ byteswap()() {
13091 return g_variant_byteswap(&this);
13094 // VERSION: 2.24
13095 // Classifies @value according to its top-level type.
13096 // RETURNS: the #GVariantClass of @value
13097 VariantClass classify()() {
13098 return g_variant_classify(&this);
13101 // VERSION: 2.26
13102 // Compares @one and @two.
13104 // The types of @one and @two are #gconstpointer only to allow use of
13105 // this function with #GTree, #GPtrArray, etc. They must each be a
13106 // #GVariant.
13108 // Comparison is only defined for basic types (ie: booleans, numbers,
13109 // strings). For booleans, %FALSE is less than %TRUE. Numbers are
13110 // ordered in the usual way. Strings are in ASCII lexographical order.
13112 // It is a programmer error to attempt to compare container values or
13113 // two values that have types that are not exactly equal. For example,
13114 // you cannot compare a 32-bit signed integer with a 32-bit unsigned
13115 // integer. Also note that this function is not particularly
13116 // well-behaved when it comes to comparison of doubles; in particular,
13117 // the handling of incomparable values (ie: NaN) is undefined.
13119 // If you only require an equality comparison, g_variant_equal() is more
13120 // general.
13121 // RETURNS: negative value if a &lt; b; zero if a = b; positive value if a &gt; b.
13122 // <two>: a #GVariant instance of the same type
13123 int compare()(const(Variant)* two) {
13124 return g_variant_compare(&this, two);
13127 // VERSION: 2.26
13128 // Similar to g_variant_get_bytestring() except that instead of
13129 // returning a constant string, the string is duplicated.
13131 // The return value must be freed using g_free().
13132 // RETURNS: a newly allocated string
13133 // <length>: a pointer to a #gsize, to store the length (not including the nul terminator)
13134 ubyte* /*new*/ dup_bytestring()(/*out*/ size_t* length=null) {
13135 return g_variant_dup_bytestring(&this, length);
13138 // VERSION: 2.26
13139 // Gets the contents of an array of array of bytes #GVariant. This call
13140 // makes a deep copy; the return result should be released with
13141 // g_strfreev().
13143 // If @length is non-%NULL then the number of elements in the result is
13144 // stored there. In any case, the resulting array will be
13145 // %NULL-terminated.
13147 // For an empty array, @length will be set to 0 and a pointer to a
13148 // %NULL pointer will be returned.
13149 // RETURNS: an array of strings
13150 // <length>: the length of the result, or %NULL
13151 char** /*new*/ dup_bytestring_array()(/*out*/ size_t* length=null) {
13152 return g_variant_dup_bytestring_array(&this, length);
13155 // VERSION: 2.30
13156 // Gets the contents of an array of object paths #GVariant. This call
13157 // makes a deep copy; the return result should be released with
13158 // g_strfreev().
13160 // If @length is non-%NULL then the number of elements in the result
13161 // is stored there. In any case, the resulting array will be
13162 // %NULL-terminated.
13164 // For an empty array, @length will be set to 0 and a pointer to a
13165 // %NULL pointer will be returned.
13166 // RETURNS: an array of strings
13167 // <length>: the length of the result, or %NULL
13168 char** /*new*/ dup_objv()(/*out*/ size_t* length=null) {
13169 return g_variant_dup_objv(&this, length);
13172 // VERSION: 2.24
13173 // Similar to g_variant_get_string() except that instead of returning
13174 // a constant string, the string is duplicated.
13176 // The string will always be utf8 encoded.
13178 // The return value must be freed using g_free().
13179 // RETURNS: a newly allocated string, utf8 encoded
13180 // <length>: a pointer to a #gsize, to store the length
13181 char* /*new*/ dup_string()(/*out*/ size_t* length) {
13182 return g_variant_dup_string(&this, length);
13185 // VERSION: 2.24
13186 // Gets the contents of an array of strings #GVariant. This call
13187 // makes a deep copy; the return result should be released with
13188 // g_strfreev().
13190 // If @length is non-%NULL then the number of elements in the result
13191 // is stored there. In any case, the resulting array will be
13192 // %NULL-terminated.
13194 // For an empty array, @length will be set to 0 and a pointer to a
13195 // %NULL pointer will be returned.
13196 // RETURNS: an array of strings
13197 // <length>: the length of the result, or %NULL
13198 char** /*new*/ dup_strv()(/*out*/ size_t* length=null) {
13199 return g_variant_dup_strv(&this, length);
13202 // VERSION: 2.24
13203 // Checks if @one and @two have the same type and value.
13205 // The types of @one and @two are #gconstpointer only to allow use of
13206 // this function with #GHashTable. They must each be a #GVariant.
13207 // RETURNS: %TRUE if @one and @two are equal
13208 // <two>: a #GVariant instance
13209 int equal()(const(Variant)* two) {
13210 return g_variant_equal(&this, two);
13213 // Unintrospectable method: get() / g_variant_get()
13214 // VERSION: 2.24
13215 // Deconstructs a #GVariant instance.
13217 // Think of this function as an analogue to scanf().
13219 // The arguments that are expected by this function are entirely
13220 // determined by @format_string. @format_string also restricts the
13221 // permissible types of @value. It is an error to give a value with
13222 // an incompatible type. See the section on <link
13223 // linkend='gvariant-format-strings'>GVariant Format Strings</link>.
13224 // Please note that the syntax of the format string is very likely to be
13225 // extended in the future.
13226 // <format_string>: a #GVariant format string
13227 /+ Not available -- variadic methods unsupported - use the C function directly.
13228 alias g_variant_get get; // Variadic
13231 // VERSION: 2.24
13232 // Returns the boolean value of @value.
13234 // It is an error to call this function with a @value of any type
13235 // other than %G_VARIANT_TYPE_BOOLEAN.
13236 // RETURNS: %TRUE or %FALSE
13237 int get_boolean()() {
13238 return g_variant_get_boolean(&this);
13241 // VERSION: 2.24
13242 // Returns the byte value of @value.
13244 // It is an error to call this function with a @value of any type
13245 // other than %G_VARIANT_TYPE_BYTE.
13246 // RETURNS: a #guchar
13247 ubyte get_byte()() {
13248 return g_variant_get_byte(&this);
13251 // VERSION: 2.26
13252 // Returns the string value of a #GVariant instance with an
13253 // array-of-bytes type. The string has no particular encoding.
13255 // If the array does not end with a nul terminator character, the empty
13256 // string is returned. For this reason, you can always trust that a
13257 // non-%NULL nul-terminated string will be returned by this function.
13259 // If the array contains a nul terminator character somewhere other than
13260 // the last byte then the returned string is the string, up to the first
13261 // such nul character.
13263 // It is an error to call this function with a @value that is not an
13264 // array of bytes.
13266 // The return value remains valid as long as @value exists.
13267 // RETURNS: the constant string
13268 ubyte* get_bytestring()() {
13269 return g_variant_get_bytestring(&this);
13272 // VERSION: 2.26
13273 // Gets the contents of an array of array of bytes #GVariant. This call
13274 // makes a shallow copy; the return result should be released with
13275 // g_free(), but the individual strings must not be modified.
13277 // If @length is non-%NULL then the number of elements in the result is
13278 // stored there. In any case, the resulting array will be
13279 // %NULL-terminated.
13281 // For an empty array, @length will be set to 0 and a pointer to a
13282 // %NULL pointer will be returned.
13283 // RETURNS: an array of constant strings
13284 // <length>: the length of the result, or %NULL
13285 char** /*new container*/ get_bytestring_array()(/*out*/ size_t* length=null) {
13286 return g_variant_get_bytestring_array(&this, length);
13289 // Unintrospectable method: get_child() / g_variant_get_child()
13290 // VERSION: 2.24
13291 // Reads a child item out of a container #GVariant instance and
13292 // deconstructs it according to @format_string. This call is
13293 // essentially a combination of g_variant_get_child_value() and
13294 // g_variant_get().
13295 // <index_>: the index of the child to deconstruct
13296 // <format_string>: a #GVariant format string
13297 /+ Not available -- variadic methods unsupported - use the C function directly.
13298 alias g_variant_get_child get_child; // Variadic
13301 // VERSION: 2.24
13302 // Reads a child item out of a container #GVariant instance. This
13303 // includes variants, maybes, arrays, tuples and dictionary
13304 // entries. It is an error to call this function on any other type of
13305 // #GVariant.
13307 // It is an error if @index_ is greater than the number of child items
13308 // in the container. See g_variant_n_children().
13310 // This function is O(1).
13311 // RETURNS: the child at the specified index
13312 // <index_>: the index of the child to fetch
13313 Variant* /*new*/ get_child_value()(size_t index_) {
13314 return g_variant_get_child_value(&this, index_);
13317 // VERSION: 2.24
13318 // Returns a pointer to the serialised form of a #GVariant instance.
13319 // The returned data may not be in fully-normalised form if read from an
13320 // untrusted source. The returned data must not be freed; it remains
13321 // valid for as long as @value exists.
13323 // If @value is a fixed-sized value that was deserialised from a
13324 // corrupted serialised container then %NULL may be returned. In this
13325 // case, the proper thing to do is typically to use the appropriate
13326 // number of nul bytes in place of @value. If @value is not fixed-sized
13327 // then %NULL is never returned.
13329 // In the case that @value is already in serialised form, this function
13330 // is O(1). If the value is not already in serialised form,
13331 // serialisation occurs implicitly and is approximately O(n) in the size
13332 // of the result.
13333 // RETURNS: the serialised form of @value, or %NULL
13334 const(void)* get_data()() {
13335 return g_variant_get_data(&this);
13338 // VERSION: 2.24
13339 // Returns the double precision floating point value of @value.
13341 // It is an error to call this function with a @value of any type
13342 // other than %G_VARIANT_TYPE_DOUBLE.
13343 // RETURNS: a #gdouble
13344 double get_double()() {
13345 return g_variant_get_double(&this);
13348 // VERSION: 2.24
13349 // Provides access to the serialised data for an array of fixed-sized
13350 // items.
13352 // @value must be an array with fixed-sized elements. Numeric types are
13353 // fixed-size as are tuples containing only other fixed-sized types.
13355 // @element_size must be the size of a single element in the array. For
13356 // example, if calling this function for an array of 32 bit integers,
13357 // you might say <code>sizeof (gint32)</code>. This value isn't used
13358 // except for the purpose of a double-check that the form of the
13359 // seralised data matches the caller's expectation.
13361 // @n_elements, which must be non-%NULL is set equal to the number of
13362 // items in the array.
13363 // RETURNS: a pointer to the fixed array
13364 // <n_elements>: a pointer to the location to store the number of items
13365 // <element_size>: the size of each element
13366 const(void)* get_fixed_array()(/*out*/ size_t* n_elements, size_t element_size) {
13367 return g_variant_get_fixed_array(&this, n_elements, element_size);
13370 // VERSION: 2.24
13371 // Returns the 32-bit signed integer value of @value.
13373 // It is an error to call this function with a @value of any type other
13374 // than %G_VARIANT_TYPE_HANDLE.
13376 // By convention, handles are indexes into an array of file descriptors
13377 // that are sent alongside a D-Bus message. If you're not interacting
13378 // with D-Bus, you probably don't need them.
13379 // RETURNS: a #gint32
13380 int get_handle()() {
13381 return g_variant_get_handle(&this);
13384 // VERSION: 2.24
13385 // Returns the 16-bit signed integer value of @value.
13387 // It is an error to call this function with a @value of any type
13388 // other than %G_VARIANT_TYPE_INT16.
13389 // RETURNS: a #gint16
13390 short get_int16()() {
13391 return g_variant_get_int16(&this);
13394 // VERSION: 2.24
13395 // Returns the 32-bit signed integer value of @value.
13397 // It is an error to call this function with a @value of any type
13398 // other than %G_VARIANT_TYPE_INT32.
13399 // RETURNS: a #gint32
13400 int get_int32()() {
13401 return g_variant_get_int32(&this);
13404 // VERSION: 2.24
13405 // Returns the 64-bit signed integer value of @value.
13407 // It is an error to call this function with a @value of any type
13408 // other than %G_VARIANT_TYPE_INT64.
13409 // RETURNS: a #gint64
13410 long get_int64()() {
13411 return g_variant_get_int64(&this);
13414 // VERSION: 2.24
13415 // Given a maybe-typed #GVariant instance, extract its value. If the
13416 // value is Nothing, then this function returns %NULL.
13417 // RETURNS: the contents of @value, or %NULL
13418 Variant* /*new*/ get_maybe()() {
13419 return g_variant_get_maybe(&this);
13422 // VERSION: 2.24
13423 // Gets a #GVariant instance that has the same value as @value and is
13424 // trusted to be in normal form.
13426 // If @value is already trusted to be in normal form then a new
13427 // reference to @value is returned.
13429 // If @value is not already trusted, then it is scanned to check if it
13430 // is in normal form. If it is found to be in normal form then it is
13431 // marked as trusted and a new reference to it is returned.
13433 // If @value is found not to be in normal form then a new trusted
13434 // #GVariant is created with the same value as @value.
13436 // It makes sense to call this function if you've received #GVariant
13437 // data from untrusted sources and you want to ensure your serialised
13438 // output is definitely in normal form.
13439 // RETURNS: a trusted #GVariant
13440 Variant* /*new*/ get_normal_form()() {
13441 return g_variant_get_normal_form(&this);
13444 // VERSION: 2.30
13445 // Gets the contents of an array of object paths #GVariant. This call
13446 // makes a shallow copy; the return result should be released with
13447 // g_free(), but the individual strings must not be modified.
13449 // If @length is non-%NULL then the number of elements in the result
13450 // is stored there. In any case, the resulting array will be
13451 // %NULL-terminated.
13453 // For an empty array, @length will be set to 0 and a pointer to a
13454 // %NULL pointer will be returned.
13455 // RETURNS: an array of constant strings
13456 // <length>: the length of the result, or %NULL
13457 char** /*new container*/ get_objv()(/*out*/ size_t* length=null) {
13458 return g_variant_get_objv(&this, length);
13461 // VERSION: 2.24
13462 // Determines the number of bytes that would be required to store @value
13463 // with g_variant_store().
13465 // If @value has a fixed-sized type then this function always returned
13466 // that fixed size.
13468 // In the case that @value is already in serialised form or the size has
13469 // already been calculated (ie: this function has been called before)
13470 // then this function is O(1). Otherwise, the size is calculated, an
13471 // operation which is approximately O(n) in the number of values
13472 // involved.
13473 // RETURNS: the serialised size of @value
13474 size_t get_size()() {
13475 return g_variant_get_size(&this);
13478 // VERSION: 2.24
13479 // Returns the string value of a #GVariant instance with a string
13480 // type. This includes the types %G_VARIANT_TYPE_STRING,
13481 // %G_VARIANT_TYPE_OBJECT_PATH and %G_VARIANT_TYPE_SIGNATURE.
13483 // The string will always be utf8 encoded.
13485 // If @length is non-%NULL then the length of the string (in bytes) is
13486 // returned there. For trusted values, this information is already
13487 // known. For untrusted values, a strlen() will be performed.
13489 // It is an error to call this function with a @value of any type
13490 // other than those three.
13492 // The return value remains valid as long as @value exists.
13493 // RETURNS: the constant string, utf8 encoded
13494 // <length>: a pointer to a #gsize, to store the length
13495 char* get_string()(/*out*/ size_t* length=null) {
13496 return g_variant_get_string(&this, length);
13499 // VERSION: 2.24
13500 // Gets the contents of an array of strings #GVariant. This call
13501 // makes a shallow copy; the return result should be released with
13502 // g_free(), but the individual strings must not be modified.
13504 // If @length is non-%NULL then the number of elements in the result
13505 // is stored there. In any case, the resulting array will be
13506 // %NULL-terminated.
13508 // For an empty array, @length will be set to 0 and a pointer to a
13509 // %NULL pointer will be returned.
13510 // RETURNS: an array of constant strings
13511 // <length>: the length of the result, or %NULL
13512 char** /*new container*/ get_strv()(/*out*/ size_t* length=null) {
13513 return g_variant_get_strv(&this, length);
13516 // VERSION: 2.24
13517 // Returns the type string of @value. Unlike the result of calling
13518 // g_variant_type_peek_string(), this string is nul-terminated. This
13519 // string belongs to #GVariant and must not be freed.
13520 // RETURNS: the type string for the type of @value
13521 char* get_type_string()() {
13522 return g_variant_get_type_string(&this);
13525 // VERSION: 2.24
13526 // Returns the 16-bit unsigned integer value of @value.
13528 // It is an error to call this function with a @value of any type
13529 // other than %G_VARIANT_TYPE_UINT16.
13530 // RETURNS: a #guint16
13531 ushort get_uint16()() {
13532 return g_variant_get_uint16(&this);
13535 // VERSION: 2.24
13536 // Returns the 32-bit unsigned integer value of @value.
13538 // It is an error to call this function with a @value of any type
13539 // other than %G_VARIANT_TYPE_UINT32.
13540 // RETURNS: a #guint32
13541 uint get_uint32()() {
13542 return g_variant_get_uint32(&this);
13545 // VERSION: 2.24
13546 // Returns the 64-bit unsigned integer value of @value.
13548 // It is an error to call this function with a @value of any type
13549 // other than %G_VARIANT_TYPE_UINT64.
13550 // RETURNS: a #guint64
13551 ulong get_uint64()() {
13552 return g_variant_get_uint64(&this);
13555 // Unintrospectable method: get_va() / g_variant_get_va()
13556 // VERSION: 2.24
13557 // This function is intended to be used by libraries based on #GVariant
13558 // that want to provide g_variant_get()-like functionality to their
13559 // users.
13561 // The API is more general than g_variant_get() to allow a wider range
13562 // of possible uses.
13564 // @format_string must still point to a valid format string, but it only
13565 // need to be nul-terminated if @endptr is %NULL. If @endptr is
13566 // non-%NULL then it is updated to point to the first character past the
13567 // end of the format string.
13569 // @app is a pointer to a #va_list. The arguments, according to
13570 // @format_string, are collected from this #va_list and the list is left
13571 // pointing to the argument following the last.
13573 // These two generalisations allow mixing of multiple calls to
13574 // g_variant_new_va() and g_variant_get_va() within a single actual
13575 // varargs call by the user.
13576 // <format_string>: a string that is prefixed with a format string
13577 // <endptr>: location to store the end pointer, or %NULL
13578 // <app>: a pointer to a #va_list
13579 void get_va()(char* format_string, char** endptr, va_list* app) {
13580 g_variant_get_va(&this, format_string, endptr, app);
13583 // VERSION: 2.24
13584 // Unboxes @value. The result is the #GVariant instance that was
13585 // contained in @value.
13586 // RETURNS: the item contained in the variant
13587 Variant* /*new*/ get_variant()() {
13588 return g_variant_get_variant(&this);
13591 // VERSION: 2.24
13592 // Generates a hash value for a #GVariant instance.
13594 // The output of this function is guaranteed to be the same for a given
13595 // value only per-process. It may change between different processor
13596 // architectures or even different versions of GLib. Do not use this
13597 // function as a basis for building protocols or file formats.
13599 // The type of @value is #gconstpointer only to allow use of this
13600 // function with #GHashTable. @value must be a #GVariant.
13601 // RETURNS: a hash value corresponding to @value
13602 uint hash()() {
13603 return g_variant_hash(&this);
13606 // Checks if @value is a container.
13607 // RETURNS: %TRUE if @value is a container
13608 int is_container()() {
13609 return g_variant_is_container(&this);
13612 // VERSION: 2.26
13613 // Checks whether @value has a floating reference count.
13615 // This function should only ever be used to assert that a given variant
13616 // is or is not floating, or for debug purposes. To acquire a reference
13617 // to a variant that might be floating, always use g_variant_ref_sink()
13618 // or g_variant_take_ref().
13620 // See g_variant_ref_sink() for more information about floating reference
13621 // counts.
13622 // RETURNS: whether @value is floating
13623 int is_floating()() {
13624 return g_variant_is_floating(&this);
13627 // VERSION: 2.24
13628 // Checks if @value is in normal form.
13630 // The main reason to do this is to detect if a given chunk of
13631 // serialised data is in normal form: load the data into a #GVariant
13632 // using g_variant_new_from_data() and then use this function to
13633 // check.
13635 // If @value is found to be in normal form then it will be marked as
13636 // being trusted. If the value was already marked as being trusted then
13637 // this function will immediately return %TRUE.
13638 // RETURNS: %TRUE if @value is in normal form
13639 int is_normal_form()() {
13640 return g_variant_is_normal_form(&this);
13643 // VERSION: 2.24
13644 // Checks if a value has a type matching the provided type.
13645 // RETURNS: %TRUE if the type of @value matches @type
13646 // <type>: a #GVariantType
13647 int is_of_type()(VariantType* type) {
13648 return g_variant_is_of_type(&this, type);
13651 // Unintrospectable method: iter_new() / g_variant_iter_new()
13652 // VERSION: 2.24
13653 // Creates a heap-allocated #GVariantIter for iterating over the items
13654 // in @value.
13656 // Use g_variant_iter_free() to free the return value when you no longer
13657 // need it.
13659 // A reference is taken to @value and will be released only when
13660 // g_variant_iter_free() is called.
13661 // RETURNS: a new heap-allocated #GVariantIter
13662 VariantIter* /*new*/ iter_new()() {
13663 return g_variant_iter_new(&this);
13666 // Unintrospectable method: lookup() / g_variant_lookup()
13667 // VERSION: 2.28
13668 // Looks up a value in a dictionary #GVariant.
13670 // This function is a wrapper around g_variant_lookup_value() and
13671 // g_variant_get(). In the case that %NULL would have been returned,
13672 // this function returns %FALSE. Otherwise, it unpacks the returned
13673 // value and returns %TRUE.
13675 // See g_variant_get() for information about @format_string.
13676 // RETURNS: %TRUE if a value was unpacked
13677 // <key>: the key to lookup in the dictionary
13678 // <format_string>: a GVariant format string
13679 /+ Not available -- variadic methods unsupported - use the C function directly.
13680 alias g_variant_lookup lookup; // Variadic
13683 // VERSION: 2.28
13684 // Looks up a value in a dictionary #GVariant.
13686 // This function works with dictionaries of the type
13687 // <literal>a{s*}</literal> (and equally well with type
13688 // <literal>a{o*}</literal>, but we only further discuss the string case
13689 // for sake of clarity).
13691 // In the event that @dictionary has the type <literal>a{sv}</literal>,
13692 // the @expected_type string specifies what type of value is expected to
13693 // be inside of the variant. If the value inside the variant has a
13694 // different type then %NULL is returned. In the event that @dictionary
13695 // has a value type other than <literal>v</literal> then @expected_type
13696 // must directly match the key type and it is used to unpack the value
13697 // directly or an error occurs.
13699 // In either case, if @key is not found in @dictionary, %NULL is
13700 // returned.
13702 // If the key is found and the value has the correct type, it is
13703 // returned. If @expected_type was specified then any non-%NULL return
13704 // value will have this type.
13705 // RETURNS: the value of the dictionary key, or %NULL
13706 // <key>: the key to lookup in the dictionary
13707 // <expected_type>: a #GVariantType, or %NULL
13708 Variant* /*new*/ lookup_value()(char* key, VariantType* expected_type=null) {
13709 return g_variant_lookup_value(&this, key, expected_type);
13712 // VERSION: 2.24
13713 // Determines the number of children in a container #GVariant instance.
13714 // This includes variants, maybes, arrays, tuples and dictionary
13715 // entries. It is an error to call this function on any other type of
13716 // #GVariant.
13718 // For variants, the return value is always 1. For values with maybe
13719 // types, it is always zero or one. For arrays, it is the length of the
13720 // array. For tuples it is the number of tuple items (which depends
13721 // only on the type). For dictionary entries, it is always 2
13723 // This function is O(1).
13724 // RETURNS: the number of children in the container
13725 size_t n_children()() {
13726 return g_variant_n_children(&this);
13729 // Pretty-prints @value in the format understood by g_variant_parse().
13731 // The format is described <link linkend='gvariant-text'>here</link>.
13733 // If @type_annotate is %TRUE, then type information is included in
13734 // the output.
13735 // RETURNS: a newly-allocated string holding the result.
13736 // <type_annotate>: %TRUE if type information should be included in the output
13737 char* /*new*/ print()(int type_annotate) {
13738 return g_variant_print(&this, type_annotate);
13741 // Unintrospectable method: print_string() / g_variant_print_string()
13742 // VERSION: 2.24
13743 // Behaves as g_variant_print(), but operates on a #GString.
13745 // If @string is non-%NULL then it is appended to and returned. Else,
13746 // a new empty #GString is allocated and it is returned.
13747 // RETURNS: a #GString containing the string
13748 // <string>: a #GString, or %NULL
13749 // <type_annotate>: %TRUE if type information should be included in the output
13750 String* /*new*/ print_string()(String* string_, int type_annotate) {
13751 return g_variant_print_string(&this, string_, type_annotate);
13754 // VERSION: 2.24
13755 // Increases the reference count of @value.
13756 // RETURNS: the same @value
13757 Variant* /*new*/ ref_()() {
13758 return g_variant_ref(&this);
13761 // VERSION: 2.24
13762 // #GVariant uses a floating reference count system. All functions with
13763 // names starting with <literal>g_variant_new_</literal> return floating
13764 // references.
13766 // Calling g_variant_ref_sink() on a #GVariant with a floating reference
13767 // will convert the floating reference into a full reference. Calling
13768 // g_variant_ref_sink() on a non-floating #GVariant results in an
13769 // additional normal reference being added.
13771 // In other words, if the @value is floating, then this call "assumes
13772 // ownership" of the floating reference, converting it to a normal
13773 // reference. If the @value is not floating, then this call adds a
13774 // new normal reference increasing the reference count by one.
13776 // All calls that result in a #GVariant instance being inserted into a
13777 // container will call g_variant_ref_sink() on the instance. This means
13778 // that if the value was just created (and has only its floating
13779 // reference) then the container will assume sole ownership of the value
13780 // at that point and the caller will not need to unreference it. This
13781 // makes certain common styles of programming much easier while still
13782 // maintaining normal refcounting semantics in situations where values
13783 // are not floating.
13784 // RETURNS: the same @value
13785 Variant* /*new*/ ref_sink()() {
13786 return g_variant_ref_sink(&this);
13789 // VERSION: 2.24
13790 // Stores the serialised form of @value at @data. @data should be
13791 // large enough. See g_variant_get_size().
13793 // The stored data is in machine native byte order but may not be in
13794 // fully-normalised form if read from an untrusted source. See
13795 // g_variant_get_normal_form() for a solution.
13797 // This function is approximately O(n) in the size of @data.
13798 // <data>: the location to store the serialised data at
13799 void store()(void* data) {
13800 g_variant_store(&this, data);
13803 // If @value is floating, sink it. Otherwise, do nothing.
13805 // Typically you want to use g_variant_ref_sink() in order to
13806 // automatically do the correct thing with respect to floating or
13807 // non-floating references, but there is one specific scenario where
13808 // this function is helpful.
13810 // The situation where this function is helpful is when creating an API
13811 // that allows the user to provide a callback function that returns a
13812 // #GVariant. We certainly want to allow the user the flexibility to
13813 // return a non-floating reference from this callback (for the case
13814 // where the value that is being returned already exists).
13816 // At the same time, the style of the #GVariant API makes it likely that
13817 // for newly-created #GVariant instances, the user can be saved some
13818 // typing if they are allowed to return a #GVariant with a floating
13819 // reference.
13821 // Using this function on the return value of the user's callback allows
13822 // the user to do whichever is more convenient for them. The caller
13823 // will alway receives exactly one full reference to the value: either
13824 // the one that was returned in the first place, or a floating reference
13825 // that has been converted to a full reference.
13827 // This function has an odd interaction when combined with
13828 // g_variant_ref_sink() running at the same time in another thread on
13829 // the same #GVariant instance. If g_variant_ref_sink() runs first then
13830 // the result will be that the floating reference is converted to a hard
13831 // reference. If g_variant_take_ref() runs first then the result will
13832 // be that the floating reference is converted to a hard reference and
13833 // an additional reference on top of that one is added. It is best to
13834 // avoid this situation.
13835 // RETURNS: the same @value
13836 Variant* /*new*/ take_ref()() {
13837 return g_variant_take_ref(&this);
13840 // VERSION: 2.24
13841 // Decreases the reference count of @value. When its reference count
13842 // drops to 0, the memory used by the variant is freed.
13843 void unref()() {
13844 g_variant_unref(&this);
13847 // VERSION: 2.24
13848 // Determines if a given string is a valid D-Bus object path. You
13849 // should ensure that a string is a valid D-Bus object path before
13850 // passing it to g_variant_new_object_path().
13852 // A valid object path starts with '/' followed by zero or more
13853 // sequences of characters separated by '/' characters. Each sequence
13854 // must contain only the characters "[A-Z][a-z][0-9]_". No sequence
13855 // (including the one following the final '/' character) may be empty.
13856 // RETURNS: %TRUE if @string is a D-Bus object path
13857 // <string>: a normal C nul-terminated string
13858 static int is_object_path()(char* string_) {
13859 return g_variant_is_object_path(string_);
13862 // VERSION: 2.24
13863 // Determines if a given string is a valid D-Bus type signature. You
13864 // should ensure that a string is a valid D-Bus type signature before
13865 // passing it to g_variant_new_signature().
13867 // D-Bus type signatures consist of zero or more definite #GVariantType
13868 // strings in sequence.
13869 // RETURNS: %TRUE if @string is a D-Bus type signature
13870 // <string>: a normal C nul-terminated string
13871 static int is_signature()(char* string_) {
13872 return g_variant_is_signature(string_);
13875 // Parses a #GVariant from a text representation.
13877 // A single #GVariant is parsed from the content of @text.
13879 // The format is described <link linkend='gvariant-text'>here</link>.
13881 // The memory at @limit will never be accessed and the parser behaves as
13882 // if the character at @limit is the nul terminator. This has the
13883 // effect of bounding @text.
13885 // If @endptr is non-%NULL then @text is permitted to contain data
13886 // following the value that this function parses and @endptr will be
13887 // updated to point to the first character past the end of the text
13888 // parsed by this function. If @endptr is %NULL and there is extra data
13889 // then an error is returned.
13891 // If @type is non-%NULL then the value will be parsed to have that
13892 // type. This may result in additional parse errors (in the case that
13893 // the parsed value doesn't fit the type) but may also result in fewer
13894 // errors (in the case that the type would have been ambiguous, such as
13895 // with empty arrays).
13897 // In the event that the parsing is successful, the resulting #GVariant
13898 // is returned.
13900 // In case of any error, %NULL will be returned. If @error is non-%NULL
13901 // then it will be set to reflect the error that occurred.
13903 // Officially, the language understood by the parser is "any string
13904 // produced by g_variant_print()".
13905 // <type>: a #GVariantType, or %NULL
13906 // <text>: a string containing a GVariant in text form
13907 // <limit>: a pointer to the end of @text, or %NULL
13908 // <endptr>: a location to store the end pointer, or %NULL
13909 static Variant* /*new*/ parse()(VariantType* type, char* text, char* limit, char** endptr, GLib2.Error** error=null) {
13910 return g_variant_parse(type, text, limit, endptr, error);
13912 static Quark parser_get_error_quark()() {
13913 return g_variant_parser_get_error_quark();
13918 // A utility type for constructing container-type #GVariant instances.
13920 // This is an opaque structure and may only be accessed using the
13921 // following functions.
13923 // #GVariantBuilder is not threadsafe in any way. Do not attempt to
13924 // access it from more than one thread.
13925 struct VariantBuilder {
13926 private size_t[16] x;
13929 // VERSION: 2.24
13930 // Allocates and initialises a new #GVariantBuilder.
13932 // You should call g_variant_builder_unref() on the return value when it
13933 // is no longer needed. The memory will not be automatically freed by
13934 // any other call.
13936 // In most cases it is easier to place a #GVariantBuilder directly on
13937 // the stack of the calling function and initialise it with
13938 // g_variant_builder_init().
13939 // RETURNS: a #GVariantBuilder
13940 // <type>: a container type
13941 static VariantBuilder* /*new*/ new_()(VariantType* type) {
13942 return g_variant_builder_new(type);
13945 // Unintrospectable method: add() / g_variant_builder_add()
13946 // VERSION: 2.24
13947 // Adds to a #GVariantBuilder.
13949 // This call is a convenience wrapper that is exactly equivalent to
13950 // calling g_variant_new() followed by g_variant_builder_add_value().
13952 // This function might be used as follows:
13954 // <programlisting>
13955 // GVariant *
13956 // make_pointless_dictionary (void)
13957 // {
13958 // GVariantBuilder *builder;
13959 // int i;
13961 // builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
13962 // for (i = 0; i < 16; i++)
13963 // {
13964 // gchar buf[3];
13966 // sprintf (buf, "%d", i);
13967 // g_variant_builder_add (builder, "{is}", i, buf);
13968 // }
13970 // return g_variant_builder_end (builder);
13971 // }
13972 // </programlisting>
13973 // <format_string>: a #GVariant varargs format string
13974 /+ Not available -- variadic methods unsupported - use the C function directly.
13975 alias g_variant_builder_add add; // Variadic
13978 // Unintrospectable method: add_parsed() / g_variant_builder_add_parsed()
13979 // VERSION: 2.26
13980 // Adds to a #GVariantBuilder.
13982 // This call is a convenience wrapper that is exactly equivalent to
13983 // calling g_variant_new_parsed() followed by
13984 // g_variant_builder_add_value().
13986 // This function might be used as follows:
13988 // <programlisting>
13989 // GVariant *
13990 // make_pointless_dictionary (void)
13991 // {
13992 // GVariantBuilder *builder;
13993 // int i;
13995 // builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
13996 // g_variant_builder_add_parsed (builder, "{'width', <%i>}", 600);
13997 // g_variant_builder_add_parsed (builder, "{'title', <%s>}", "foo");
13998 // g_variant_builder_add_parsed (builder, "{'transparency', <0.5>}");
13999 // return g_variant_builder_end (builder);
14000 // }
14001 // </programlisting>
14002 // <format>: a text format #GVariant
14003 /+ Not available -- variadic methods unsupported - use the C function directly.
14004 alias g_variant_builder_add_parsed add_parsed; // Variadic
14007 // VERSION: 2.24
14008 // Adds @value to @builder.
14010 // It is an error to call this function in any way that would create an
14011 // inconsistent value to be constructed. Some examples of this are
14012 // putting different types of items into an array, putting the wrong
14013 // types or number of items in a tuple, putting more than one value into
14014 // a variant, etc.
14016 // If @value is a floating reference (see g_variant_ref_sink()),
14017 // the @builder instance takes ownership of @value.
14018 // <value>: a #GVariant
14019 void add_value()(Variant* value) {
14020 g_variant_builder_add_value(&this, value);
14023 // Unintrospectable method: clear() / g_variant_builder_clear()
14024 // VERSION: 2.24
14025 // Releases all memory associated with a #GVariantBuilder without
14026 // freeing the #GVariantBuilder structure itself.
14028 // It typically only makes sense to do this on a stack-allocated
14029 // #GVariantBuilder if you want to abort building the value part-way
14030 // through. This function need not be called if you call
14031 // g_variant_builder_end() and it also doesn't need to be called on
14032 // builders allocated with g_variant_builder_new (see
14033 // g_variant_builder_unref() for that).
14035 // This function leaves the #GVariantBuilder structure set to all-zeros.
14036 // It is valid to call this function on either an initialised
14037 // #GVariantBuilder or one that is set to all-zeros but it is not valid
14038 // to call this function on uninitialised memory.
14039 void clear()() {
14040 g_variant_builder_clear(&this);
14043 // VERSION: 2.24
14044 // Closes the subcontainer inside the given @builder that was opened by
14045 // the most recent call to g_variant_builder_open().
14047 // It is an error to call this function in any way that would create an
14048 // inconsistent value to be constructed (ie: too few values added to the
14049 // subcontainer).
14050 void close()() {
14051 g_variant_builder_close(&this);
14054 // VERSION: 2.24
14055 // Ends the builder process and returns the constructed value.
14057 // It is not permissible to use @builder in any way after this call
14058 // except for reference counting operations (in the case of a
14059 // heap-allocated #GVariantBuilder) or by reinitialising it with
14060 // g_variant_builder_init() (in the case of stack-allocated).
14062 // It is an error to call this function in any way that would create an
14063 // inconsistent value to be constructed (ie: insufficient number of
14064 // items added to a container with a specific number of children
14065 // required). It is also an error to call this function if the builder
14066 // was created with an indefinite array or maybe type and no children
14067 // have been added; in this case it is impossible to infer the type of
14068 // the empty array.
14069 // RETURNS: a new, floating, #GVariant
14070 Variant* end()() {
14071 return g_variant_builder_end(&this);
14074 // Unintrospectable method: init() / g_variant_builder_init()
14075 // VERSION: 2.24
14076 // Initialises a #GVariantBuilder structure.
14078 // @type must be non-%NULL. It specifies the type of container to
14079 // construct. It can be an indefinite type such as
14080 // %G_VARIANT_TYPE_ARRAY or a definite type such as "as" or "(ii)".
14081 // Maybe, array, tuple, dictionary entry and variant-typed values may be
14082 // constructed.
14084 // After the builder is initialised, values are added using
14085 // g_variant_builder_add_value() or g_variant_builder_add().
14087 // After all the child values are added, g_variant_builder_end() frees
14088 // the memory associated with the builder and returns the #GVariant that
14089 // was created.
14091 // This function completely ignores the previous contents of @builder.
14092 // On one hand this means that it is valid to pass in completely
14093 // uninitialised memory. On the other hand, this means that if you are
14094 // initialising over top of an existing #GVariantBuilder you need to
14095 // first call g_variant_builder_clear() in order to avoid leaking
14096 // memory.
14098 // You must not call g_variant_builder_ref() or
14099 // g_variant_builder_unref() on a #GVariantBuilder that was initialised
14100 // with this function. If you ever pass a reference to a
14101 // #GVariantBuilder outside of the control of your own code then you
14102 // should assume that the person receiving that reference may try to use
14103 // reference counting; you should use g_variant_builder_new() instead of
14104 // this function.
14105 // <type>: a container type
14106 void init()(VariantType* type) {
14107 g_variant_builder_init(&this, type);
14110 // VERSION: 2.24
14111 // Opens a subcontainer inside the given @builder. When done adding
14112 // items to the subcontainer, g_variant_builder_close() must be called.
14114 // It is an error to call this function in any way that would cause an
14115 // inconsistent value to be constructed (ie: adding too many values or
14116 // a value of an incorrect type).
14117 // <type>: a #GVariantType
14118 void open()(VariantType* type) {
14119 g_variant_builder_open(&this, type);
14122 // VERSION: 2.24
14123 // Increases the reference count on @builder.
14125 // Don't call this on stack-allocated #GVariantBuilder instances or bad
14126 // things will happen.
14127 // RETURNS: a new reference to @builder
14128 VariantBuilder* /*new*/ ref_()() {
14129 return g_variant_builder_ref(&this);
14132 // VERSION: 2.24
14133 // Decreases the reference count on @builder.
14135 // In the event that there are no more references, releases all memory
14136 // associated with the #GVariantBuilder.
14138 // Don't call this on stack-allocated #GVariantBuilder instances or bad
14139 // things will happen.
14140 void unref()() {
14141 g_variant_builder_unref(&this);
14145 // The range of possible top-level types of #GVariant instances.
14146 enum VariantClass /* Version 2.24 */ {
14147 BOOLEAN = 98,
14148 BYTE = 121,
14149 INT16 = 110,
14150 UINT16 = 113,
14151 INT32 = 105,
14152 UINT32 = 117,
14153 INT64 = 120,
14154 UINT64 = 116,
14155 HANDLE = 104,
14156 DOUBLE = 100,
14157 STRING = 115,
14158 OBJECT_PATH = 111,
14159 SIGNATURE = 103,
14160 VARIANT = 118,
14161 MAYBE = 109,
14162 ARRAY = 97,
14163 TUPLE = 40,
14164 DICT_ENTRY = 123
14167 // #GVariantIter is an opaque data structure and can only be accessed
14168 // using the following functions.
14169 struct VariantIter {
14170 private size_t[16] x;
14173 // Unintrospectable method: copy() / g_variant_iter_copy()
14174 // VERSION: 2.24
14175 // Creates a new heap-allocated #GVariantIter to iterate over the
14176 // container that was being iterated over by @iter. Iteration begins on
14177 // the new iterator from the current position of the old iterator but
14178 // the two copies are independent past that point.
14180 // Use g_variant_iter_free() to free the return value when you no longer
14181 // need it.
14183 // A reference is taken to the container that @iter is iterating over
14184 // and will be releated only when g_variant_iter_free() is called.
14185 // RETURNS: a new heap-allocated #GVariantIter
14186 VariantIter* /*new*/ copy()() {
14187 return g_variant_iter_copy(&this);
14190 // VERSION: 2.24
14191 // Frees a heap-allocated #GVariantIter. Only call this function on
14192 // iterators that were returned by g_variant_iter_new() or
14193 // g_variant_iter_copy().
14194 void free()() {
14195 g_variant_iter_free(&this);
14198 // Unintrospectable method: init() / g_variant_iter_init()
14199 // VERSION: 2.24
14200 // Initialises (without allocating) a #GVariantIter. @iter may be
14201 // completely uninitialised prior to this call; its old value is
14202 // ignored.
14204 // The iterator remains valid for as long as @value exists, and need not
14205 // be freed in any way.
14206 // RETURNS: the number of items in @value
14207 // <value>: a container #GVariant
14208 size_t init()(Variant* value) {
14209 return g_variant_iter_init(&this, value);
14212 // Unintrospectable method: loop() / g_variant_iter_loop()
14213 // VERSION: 2.24
14214 // Gets the next item in the container and unpacks it into the variable
14215 // argument list according to @format_string, returning %TRUE.
14217 // If no more items remain then %FALSE is returned.
14219 // On the first call to this function, the pointers appearing on the
14220 // variable argument list are assumed to point at uninitialised memory.
14221 // On the second and later calls, it is assumed that the same pointers
14222 // will be given and that they will point to the memory as set by the
14223 // previous call to this function. This allows the previous values to
14224 // be freed, as appropriate.
14226 // This function is intended to be used with a while loop as
14227 // demonstrated in the following example. This function can only be
14228 // used when iterating over an array. It is only valid to call this
14229 // function with a string constant for the format string and the same
14230 // string constant must be used each time. Mixing calls to this
14231 // function and g_variant_iter_next() or g_variant_iter_next_value() on
14232 // the same iterator is not recommended.
14234 // See the section on <link linkend='gvariant-format-strings'>GVariant
14235 // Format Strings</link>.
14237 // <example>
14238 // <title>Memory management with g_variant_iter_loop()</title>
14239 // <programlisting>
14240 // /<!-- -->* Iterates a dictionary of type 'a{sv}' *<!-- -->/
14241 // void
14242 // iterate_dictionary (GVariant *dictionary)
14243 // {
14244 // GVariantIter iter;
14245 // GVariant *value;
14246 // gchar *key;
14248 // g_variant_iter_init (&iter, dictionary);
14249 // while (g_variant_iter_loop (&iter, "{sv}", &key, &value))
14250 // {
14251 // g_print ("Item '%s' has type '%s'\n", key,
14252 // g_variant_get_type_string (value));
14254 // /<!-- -->* no need to free 'key' and 'value' here *<!-- -->/
14255 // }
14256 // }
14257 // </programlisting>
14258 // </example>
14260 // For most cases you should use g_variant_iter_next().
14262 // This function is really only useful when unpacking into #GVariant or
14263 // #GVariantIter in order to allow you to skip the call to
14264 // g_variant_unref() or g_variant_iter_free().
14266 // For example, if you are only looping over simple integer and string
14267 // types, g_variant_iter_next() is definitely preferred. For string
14268 // types, use the '&' prefix to avoid allocating any memory at all (and
14269 // thereby avoiding the need to free anything as well).
14270 // RETURNS: %TRUE if a value was unpacked, or %FALSE if there as no value
14271 // <format_string>: a GVariant format string
14272 /+ Not available -- variadic methods unsupported - use the C function directly.
14273 alias g_variant_iter_loop loop; // Variadic
14276 // VERSION: 2.24
14277 // Queries the number of child items in the container that we are
14278 // iterating over. This is the total number of items -- not the number
14279 // of items remaining.
14281 // This function might be useful for preallocation of arrays.
14282 // RETURNS: the number of children in the container
14283 size_t n_children()() {
14284 return g_variant_iter_n_children(&this);
14287 // Unintrospectable method: next() / g_variant_iter_next()
14288 // VERSION: 2.24
14289 // Gets the next item in the container and unpacks it into the variable
14290 // argument list according to @format_string, returning %TRUE.
14292 // If no more items remain then %FALSE is returned.
14294 // All of the pointers given on the variable arguments list of this
14295 // function are assumed to point at uninitialised memory. It is the
14296 // responsibility of the caller to free all of the values returned by
14297 // the unpacking process.
14299 // See the section on <link linkend='gvariant-format-strings'>GVariant
14300 // Format Strings</link>.
14302 // <example>
14303 // <title>Memory management with g_variant_iter_next()</title>
14304 // <programlisting>
14305 // /<!-- -->* Iterates a dictionary of type 'a{sv}' *<!-- -->/
14306 // void
14307 // iterate_dictionary (GVariant *dictionary)
14308 // {
14309 // GVariantIter iter;
14310 // GVariant *value;
14311 // gchar *key;
14313 // g_variant_iter_init (&iter, dictionary);
14314 // while (g_variant_iter_next (&iter, "{sv}", &key, &value))
14315 // {
14316 // g_print ("Item '%s' has type '%s'\n", key,
14317 // g_variant_get_type_string (value));
14319 // /<!-- -->* must free data for ourselves *<!-- -->/
14320 // g_variant_unref (value);
14321 // g_free (key);
14322 // }
14323 // }
14324 // </programlisting>
14325 // </example>
14327 // For a solution that is likely to be more convenient to C programmers
14328 // when dealing with loops, see g_variant_iter_loop().
14329 // RETURNS: %TRUE if a value was unpacked, or %FALSE if there as no value
14330 // <format_string>: a GVariant format string
14331 /+ Not available -- variadic methods unsupported - use the C function directly.
14332 alias g_variant_iter_next next; // Variadic
14335 // VERSION: 2.24
14336 // Gets the next item in the container. If no more items remain then
14337 // %NULL is returned.
14339 // Use g_variant_unref() to drop your reference on the return value when
14340 // you no longer need it.
14342 // <example>
14343 // <title>Iterating with g_variant_iter_next_value()</title>
14344 // <programlisting>
14345 // /<!-- -->* recursively iterate a container *<!-- -->/
14346 // void
14347 // iterate_container_recursive (GVariant *container)
14348 // {
14349 // GVariantIter iter;
14350 // GVariant *child;
14352 // g_variant_iter_init (&iter, container);
14353 // while ((child = g_variant_iter_next_value (&iter)))
14354 // {
14355 // g_print ("type '%s'\n", g_variant_get_type_string (child));
14357 // if (g_variant_is_container (child))
14358 // iterate_container_recursive (child);
14360 // g_variant_unref (child);
14361 // }
14362 // }
14363 // </programlisting>
14364 // </example>
14365 // RETURNS: a #GVariant, or %NULL
14366 Variant* /*new*/ next_value()() {
14367 return g_variant_iter_next_value(&this);
14371 // Error codes returned by parsing text-format GVariants.
14372 enum VariantParseError {
14373 FAILED = 0,
14374 BASIC_TYPE_EXPECTED = 1,
14375 CANNOT_INFER_TYPE = 2,
14376 DEFINITE_TYPE_EXPECTED = 3,
14377 INPUT_NOT_AT_END = 4,
14378 INVALID_CHARACTER = 5,
14379 INVALID_FORMAT_STRING = 6,
14380 INVALID_OBJECT_PATH = 7,
14381 INVALID_SIGNATURE = 8,
14382 INVALID_TYPE_STRING = 9,
14383 NO_COMMON_TYPE = 10,
14384 NUMBER_OUT_OF_RANGE = 11,
14385 NUMBER_TOO_BIG = 12,
14386 TYPE_ERROR = 13,
14387 UNEXPECTED_TOKEN = 14,
14388 UNKNOWN_KEYWORD = 15,
14389 UNTERMINATED_STRING_CONSTANT = 16,
14390 VALUE_EXPECTED = 17
14393 // This section introduces the GVariant type system. It is based, in
14394 // large part, on the D-Bus type system, with two major changes and some minor
14395 // lifting of restrictions. The <ulink
14396 // url='http://dbus.freedesktop.org/doc/dbus-specification.html'>DBus
14397 // specification</ulink>, therefore, provides a significant amount of
14398 // information that is useful when working with GVariant.
14400 // The first major change with respect to the D-Bus type system is the
14401 // introduction of maybe (or "nullable") types. Any type in GVariant can be
14402 // converted to a maybe type, in which case, "nothing" (or "null") becomes a
14403 // valid value. Maybe types have been added by introducing the
14404 // character "<literal>m</literal>" to type strings.
14406 // The second major change is that the GVariant type system supports the
14407 // concept of "indefinite types" -- types that are less specific than
14408 // the normal types found in D-Bus. For example, it is possible to speak
14409 // of "an array of any type" in GVariant, where the D-Bus type system
14410 // would require you to speak of "an array of integers" or "an array of
14411 // strings". Indefinite types have been added by introducing the
14412 // characters "<literal>*</literal>", "<literal>?</literal>" and
14413 // "<literal>r</literal>" to type strings.
14415 // Finally, all arbitrary restrictions relating to the complexity of
14416 // types are lifted along with the restriction that dictionary entries
14417 // may only appear nested inside of arrays.
14419 // Just as in D-Bus, GVariant types are described with strings ("type
14420 // strings"). Subject to the differences mentioned above, these strings
14421 // are of the same form as those found in DBus. Note, however: D-Bus
14422 // always works in terms of messages and therefore individual type
14423 // strings appear nowhere in its interface. Instead, "signatures"
14424 // are a concatenation of the strings of the type of each argument in a
14425 // message. GVariant deals with single values directly so GVariant type
14426 // strings always describe the type of exactly one value. This means
14427 // that a D-Bus signature string is generally not a valid GVariant type
14428 // string -- except in the case that it is the signature of a message
14429 // containing exactly one argument.
14431 // An indefinite type is similar in spirit to what may be called an
14432 // abstract type in other type systems. No value can exist that has an
14433 // indefinite type as its type, but values can exist that have types
14434 // that are subtypes of indefinite types. That is to say,
14435 // g_variant_get_type() will never return an indefinite type, but
14436 // calling g_variant_is_of_type() with an indefinite type may return
14437 // %TRUE. For example, you cannot have a value that represents "an
14438 // array of no particular type", but you can have an "array of integers"
14439 // which certainly matches the type of "an array of no particular type",
14440 // since "array of integers" is a subtype of "array of no particular
14441 // type".
14443 // This is similar to how instances of abstract classes may not
14444 // directly exist in other type systems, but instances of their
14445 // non-abstract subtypes may. For example, in GTK, no object that has
14446 // the type of #GtkBin can exist (since #GtkBin is an abstract class),
14447 // but a #GtkWindow can certainly be instantiated, and you would say
14448 // that the #GtkWindow is a #GtkBin (since #GtkWindow is a subclass of
14449 // #GtkBin).
14451 // A detailed description of GVariant type strings is given here:
14453 // <refsect2 id='gvariant-typestrings'>
14454 // <title>GVariant Type Strings</title>
14455 // <para>
14456 // A GVariant type string can be any of the following:
14457 // </para>
14458 // <itemizedlist>
14459 // <listitem>
14460 // <para>
14461 // any basic type string (listed below)
14462 // </para>
14463 // </listitem>
14464 // <listitem>
14465 // <para>
14466 // "<literal>v</literal>", "<literal>r</literal>" or
14467 // "<literal>*</literal>"
14468 // </para>
14469 // </listitem>
14470 // <listitem>
14471 // <para>
14472 // one of the characters '<literal>a</literal>' or
14473 // '<literal>m</literal>', followed by another type string
14474 // </para>
14475 // </listitem>
14476 // <listitem>
14477 // <para>
14478 // the character '<literal>(</literal>', followed by a concatenation
14479 // of zero or more other type strings, followed by the character
14480 // '<literal>)</literal>'
14481 // </para>
14482 // </listitem>
14483 // <listitem>
14484 // <para>
14485 // the character '<literal>{</literal>', followed by a basic type
14486 // string (see below), followed by another type string, followed by
14487 // the character '<literal>}</literal>'
14488 // </para>
14489 // </listitem>
14490 // </itemizedlist>
14491 // <para>
14492 // A basic type string describes a basic type (as per
14493 // g_variant_type_is_basic()) and is always a single
14494 // character in length. The valid basic type strings are
14495 // "<literal>b</literal>", "<literal>y</literal>",
14496 // "<literal>n</literal>", "<literal>q</literal>",
14497 // "<literal>i</literal>", "<literal>u</literal>",
14498 // "<literal>x</literal>", "<literal>t</literal>",
14499 // "<literal>h</literal>", "<literal>d</literal>",
14500 // "<literal>s</literal>", "<literal>o</literal>",
14501 // "<literal>g</literal>" and "<literal>?</literal>".
14502 // </para>
14503 // <para>
14504 // The above definition is recursive to arbitrary depth.
14505 // "<literal>aaaaai</literal>" and "<literal>(ui(nq((y)))s)</literal>"
14506 // are both valid type strings, as is
14507 // "<literal>a(aa(ui)(qna{ya(yd)}))</literal>".
14508 // </para>
14509 // <para>
14510 // The meaning of each of the characters is as follows:
14511 // </para>
14512 // <informaltable>
14513 // <tgroup cols='2'>
14514 // <tbody>
14515 // <row>
14516 // <entry>
14517 // <para>
14518 // <emphasis role='strong'>Character</emphasis>
14519 // </para>
14520 // </entry>
14521 // <entry>
14522 // <para>
14523 // <emphasis role='strong'>Meaning</emphasis>
14524 // </para>
14525 // </entry>
14526 // </row>
14527 // <row>
14528 // <entry>
14529 // <para>
14530 // <literal>b</literal>
14531 // </para>
14532 // </entry>
14533 // <entry>
14534 // <para>
14535 // the type string of %G_VARIANT_TYPE_BOOLEAN; a boolean value.
14536 // </para>
14537 // </entry>
14538 // </row>
14539 // <row>
14540 // <entry>
14541 // <para>
14542 // <literal>y</literal>
14543 // </para>
14544 // </entry>
14545 // <entry>
14546 // <para>
14547 // the type string of %G_VARIANT_TYPE_BYTE; a byte.
14548 // </para>
14549 // </entry>
14550 // </row>
14551 // <row>
14552 // <entry>
14553 // <para>
14554 // <literal>n</literal>
14555 // </para>
14556 // </entry>
14557 // <entry>
14558 // <para>
14559 // the type string of %G_VARIANT_TYPE_INT16; a signed 16 bit
14560 // integer.
14561 // </para>
14562 // </entry>
14563 // </row>
14564 // <row>
14565 // <entry>
14566 // <para>
14567 // <literal>q</literal>
14568 // </para>
14569 // </entry>
14570 // <entry>
14571 // <para>
14572 // the type string of %G_VARIANT_TYPE_UINT16; an unsigned 16 bit
14573 // integer.
14574 // </para>
14575 // </entry>
14576 // </row>
14577 // <row>
14578 // <entry>
14579 // <para>
14580 // <literal>i</literal>
14581 // </para>
14582 // </entry>
14583 // <entry>
14584 // <para>
14585 // the type string of %G_VARIANT_TYPE_INT32; a signed 32 bit
14586 // integer.
14587 // </para>
14588 // </entry>
14589 // </row>
14590 // <row>
14591 // <entry>
14592 // <para>
14593 // <literal>u</literal>
14594 // </para>
14595 // </entry>
14596 // <entry>
14597 // <para>
14598 // the type string of %G_VARIANT_TYPE_UINT32; an unsigned 32 bit
14599 // integer.
14600 // </para>
14601 // </entry>
14602 // </row>
14603 // <row>
14604 // <entry>
14605 // <para>
14606 // <literal>x</literal>
14607 // </para>
14608 // </entry>
14609 // <entry>
14610 // <para>
14611 // the type string of %G_VARIANT_TYPE_INT64; a signed 64 bit
14612 // integer.
14613 // </para>
14614 // </entry>
14615 // </row>
14616 // <row>
14617 // <entry>
14618 // <para>
14619 // <literal>t</literal>
14620 // </para>
14621 // </entry>
14622 // <entry>
14623 // <para>
14624 // the type string of %G_VARIANT_TYPE_UINT64; an unsigned 64 bit
14625 // integer.
14626 // </para>
14627 // </entry>
14628 // </row>
14629 // <row>
14630 // <entry>
14631 // <para>
14632 // <literal>h</literal>
14633 // </para>
14634 // </entry>
14635 // <entry>
14636 // <para>
14637 // the type string of %G_VARIANT_TYPE_HANDLE; a signed 32 bit
14638 // value that, by convention, is used as an index into an array
14639 // of file descriptors that are sent alongside a D-Bus message.
14640 // </para>
14641 // </entry>
14642 // </row>
14643 // <row>
14644 // <entry>
14645 // <para>
14646 // <literal>d</literal>
14647 // </para>
14648 // </entry>
14649 // <entry>
14650 // <para>
14651 // the type string of %G_VARIANT_TYPE_DOUBLE; a double precision
14652 // floating point value.
14653 // </para>
14654 // </entry>
14655 // </row>
14656 // <row>
14657 // <entry>
14658 // <para>
14659 // <literal>s</literal>
14660 // </para>
14661 // </entry>
14662 // <entry>
14663 // <para>
14664 // the type string of %G_VARIANT_TYPE_STRING; a string.
14665 // </para>
14666 // </entry>
14667 // </row>
14668 // <row>
14669 // <entry>
14670 // <para>
14671 // <literal>o</literal>
14672 // </para>
14673 // </entry>
14674 // <entry>
14675 // <para>
14676 // the type string of %G_VARIANT_TYPE_OBJECT_PATH; a string in
14677 // the form of a D-Bus object path.
14678 // </para>
14679 // </entry>
14680 // </row>
14681 // <row>
14682 // <entry>
14683 // <para>
14684 // <literal>g</literal>
14685 // </para>
14686 // </entry>
14687 // <entry>
14688 // <para>
14689 // the type string of %G_VARIANT_TYPE_STRING; a string in the
14690 // form of a D-Bus type signature.
14691 // </para>
14692 // </entry>
14693 // </row>
14694 // <row>
14695 // <entry>
14696 // <para>
14697 // <literal>?</literal>
14698 // </para>
14699 // </entry>
14700 // <entry>
14701 // <para>
14702 // the type string of %G_VARIANT_TYPE_BASIC; an indefinite type
14703 // that is a supertype of any of the basic types.
14704 // </para>
14705 // </entry>
14706 // </row>
14707 // <row>
14708 // <entry>
14709 // <para>
14710 // <literal>v</literal>
14711 // </para>
14712 // </entry>
14713 // <entry>
14714 // <para>
14715 // the type string of %G_VARIANT_TYPE_VARIANT; a container type
14716 // that contain any other type of value.
14717 // </para>
14718 // </entry>
14719 // </row>
14720 // <row>
14721 // <entry>
14722 // <para>
14723 // <literal>a</literal>
14724 // </para>
14725 // </entry>
14726 // <entry>
14727 // <para>
14728 // used as a prefix on another type string to mean an array of
14729 // that type; the type string "<literal>ai</literal>", for
14730 // example, is the type of an array of 32 bit signed integers.
14731 // </para>
14732 // </entry>
14733 // </row>
14734 // <row>
14735 // <entry>
14736 // <para>
14737 // <literal>m</literal>
14738 // </para>
14739 // </entry>
14740 // <entry>
14741 // <para>
14742 // used as a prefix on another type string to mean a "maybe", or
14743 // "nullable", version of that type; the type string
14744 // "<literal>ms</literal>", for example, is the type of a value
14745 // that maybe contains a string, or maybe contains nothing.
14746 // </para>
14747 // </entry>
14748 // </row>
14749 // <row>
14750 // <entry>
14751 // <para>
14752 // <literal>()</literal>
14753 // </para>
14754 // </entry>
14755 // <entry>
14756 // <para>
14757 // used to enclose zero or more other concatenated type strings
14758 // to create a tuple type; the type string
14759 // "<literal>(is)</literal>", for example, is the type of a pair
14760 // of an integer and a string.
14761 // </para>
14762 // </entry>
14763 // </row>
14764 // <row>
14765 // <entry>
14766 // <para>
14767 // <literal>r</literal>
14768 // </para>
14769 // </entry>
14770 // <entry>
14771 // <para>
14772 // the type string of %G_VARIANT_TYPE_TUPLE; an indefinite type
14773 // that is a supertype of any tuple type, regardless of the
14774 // number of items.
14775 // </para>
14776 // </entry>
14777 // </row>
14778 // <row>
14779 // <entry>
14780 // <para>
14781 // <literal>{}</literal>
14782 // </para>
14783 // </entry>
14784 // <entry>
14785 // <para>
14786 // used to enclose a basic type string concatenated with another
14787 // type string to create a dictionary entry type, which usually
14788 // appears inside of an array to form a dictionary; the type
14789 // string "<literal>a{sd}</literal>", for example, is the type of
14790 // a dictionary that maps strings to double precision floating
14791 // point values.
14792 // </para>
14793 // <para>
14794 // The first type (the basic type) is the key type and the second
14795 // type is the value type. The reason that the first type is
14796 // restricted to being a basic type is so that it can easily be
14797 // hashed.
14798 // </para>
14799 // </entry>
14800 // </row>
14801 // <row>
14802 // <entry>
14803 // <para>
14804 // <literal>*</literal>
14805 // </para>
14806 // </entry>
14807 // <entry>
14808 // <para>
14809 // the type string of %G_VARIANT_TYPE_ANY; the indefinite type
14810 // that is a supertype of all types. Note that, as with all type
14811 // strings, this character represents exactly one type. It
14812 // cannot be used inside of tuples to mean "any number of items".
14813 // </para>
14814 // </entry>
14815 // </row>
14816 // </tbody>
14817 // </tgroup>
14818 // </informaltable>
14819 // <para>
14820 // Any type string of a container that contains an indefinite type is,
14821 // itself, an indefinite type. For example, the type string
14822 // "<literal>a*</literal>" (corresponding to %G_VARIANT_TYPE_ARRAY) is
14823 // an indefinite type that is a supertype of every array type.
14824 // "<literal>(*s)</literal>" is a supertype of all tuples that
14825 // contain exactly two items where the second item is a string.
14826 // </para>
14827 // <para>
14828 // "<literal>a{?*}</literal>" is an indefinite type that is a
14829 // supertype of all arrays containing dictionary entries where the key
14830 // is any basic type and the value is any type at all. This is, by
14831 // definition, a dictionary, so this type string corresponds to
14832 // %G_VARIANT_TYPE_DICTIONARY. Note that, due to the restriction that
14833 // the key of a dictionary entry must be a basic type,
14834 // "<literal>{**}</literal>" is not a valid type string.
14835 // </para>
14836 // </refsect2>
14837 struct VariantType {
14839 // VERSION: 2.24
14840 // Creates a new #GVariantType corresponding to the type string given
14841 // by @type_string. It is appropriate to call g_variant_type_free() on
14842 // the return value.
14844 // It is a programmer error to call this function with an invalid type
14845 // string. Use g_variant_type_string_is_valid() if you are unsure.
14846 // RETURNS: a new #GVariantType
14847 // <type_string>: a valid GVariant type string
14848 static VariantType* /*new*/ new_()(char* type_string) {
14849 return g_variant_type_new(type_string);
14852 // Constructs a new tuple type, from @items.
14854 // @length is the number of items in @items, or -1 to indicate that
14855 // @items is %NULL-terminated.
14857 // It is appropriate to call g_variant_type_free() on the return value.
14859 // Since 2.24
14860 // RETURNS: a new tuple #GVariantType
14861 // <items>: an array of #GVariantTypes, one for each item
14862 // <length>: the length of @items, or -1
14863 static VariantType* /*new*/ new_tuple()(VariantType** items, int length) {
14864 return g_variant_type_new_tuple(items, length);
14867 // Makes a copy of a #GVariantType. It is appropriate to call
14868 // g_variant_type_free() on the return value. @type may not be %NULL.
14870 // Since 2.24
14871 // RETURNS: a new #GVariantType
14872 VariantType* /*new*/ copy()() {
14873 return g_variant_type_copy(&this);
14876 // Returns a newly-allocated copy of the type string corresponding to
14877 // @type. The returned string is nul-terminated. It is appropriate to
14878 // call g_free() on the return value.
14880 // Since 2.24
14881 // RETURNS: the corresponding type string
14882 char* /*new*/ dup_string()() {
14883 return g_variant_type_dup_string(&this);
14886 // Determines the element type of an array or maybe type.
14888 // This function may only be used with array or maybe types.
14890 // Since 2.24
14891 // RETURNS: the element type of @type
14892 VariantType* element()() {
14893 return g_variant_type_element(&this);
14896 // Compares @type1 and @type2 for equality.
14898 // Only returns %TRUE if the types are exactly equal. Even if one type
14899 // is an indefinite type and the other is a subtype of it, %FALSE will
14900 // be returned if they are not exactly equal. If you want to check for
14901 // subtypes, use g_variant_type_is_subtype_of().
14903 // The argument types of @type1 and @type2 are only #gconstpointer to
14904 // allow use with #GHashTable without function pointer casting. For
14905 // both arguments, a valid #GVariantType must be provided.
14907 // Since 2.24
14908 // RETURNS: %TRUE if @type1 and @type2 are exactly equal
14909 // <type2>: a #GVariantType
14910 int equal()(const(VariantType)* type2) {
14911 return g_variant_type_equal(&this, type2);
14914 // Determines the first item type of a tuple or dictionary entry
14915 // type.
14917 // This function may only be used with tuple or dictionary entry types,
14918 // but must not be used with the generic tuple type
14919 // %G_VARIANT_TYPE_TUPLE.
14921 // In the case of a dictionary entry type, this returns the type of
14922 // the key.
14924 // %NULL is returned in case of @type being %G_VARIANT_TYPE_UNIT.
14926 // This call, together with g_variant_type_next() provides an iterator
14927 // interface over tuple and dictionary entry types.
14929 // Since 2.24
14930 // RETURNS: the first item type of @type, or %NULL
14931 VariantType* first()() {
14932 return g_variant_type_first(&this);
14935 // Frees a #GVariantType that was allocated with
14936 // g_variant_type_copy(), g_variant_type_new() or one of the container
14937 // type constructor functions.
14939 // In the case that @type is %NULL, this function does nothing.
14941 // Since 2.24
14942 void free()() {
14943 g_variant_type_free(&this);
14946 // Returns the length of the type string corresponding to the given
14947 // @type. This function must be used to determine the valid extent of
14948 // the memory region returned by g_variant_type_peek_string().
14950 // Since 2.24
14951 // RETURNS: the length of the corresponding type string
14952 size_t get_string_length()() {
14953 return g_variant_type_get_string_length(&this);
14956 // Hashes @type.
14958 // The argument type of @type is only #gconstpointer to allow use with
14959 // #GHashTable without function pointer casting. A valid
14960 // #GVariantType must be provided.
14962 // Since 2.24
14963 // RETURNS: the hash value
14964 uint hash()() {
14965 return g_variant_type_hash(&this);
14968 // Determines if the given @type is an array type. This is true if the
14969 // type string for @type starts with an 'a'.
14971 // This function returns %TRUE for any indefinite type for which every
14972 // definite subtype is an array type -- %G_VARIANT_TYPE_ARRAY, for
14973 // example.
14975 // Since 2.24
14976 // RETURNS: %TRUE if @type is an array type
14977 int is_array()() {
14978 return g_variant_type_is_array(&this);
14981 // Determines if the given @type is a basic type.
14983 // Basic types are booleans, bytes, integers, doubles, strings, object
14984 // paths and signatures.
14986 // Only a basic type may be used as the key of a dictionary entry.
14988 // This function returns %FALSE for all indefinite types except
14989 // %G_VARIANT_TYPE_BASIC.
14991 // Since 2.24
14992 // RETURNS: %TRUE if @type is a basic type
14993 int is_basic()() {
14994 return g_variant_type_is_basic(&this);
14997 // Determines if the given @type is a container type.
14999 // Container types are any array, maybe, tuple, or dictionary
15000 // entry types plus the variant type.
15002 // This function returns %TRUE for any indefinite type for which every
15003 // definite subtype is a container -- %G_VARIANT_TYPE_ARRAY, for
15004 // example.
15006 // Since 2.24
15007 // RETURNS: %TRUE if @type is a container type
15008 int is_container()() {
15009 return g_variant_type_is_container(&this);
15012 // Determines if the given @type is definite (ie: not indefinite).
15014 // A type is definite if its type string does not contain any indefinite
15015 // type characters ('*', '?', or 'r').
15017 // A #GVariant instance may not have an indefinite type, so calling
15018 // this function on the result of g_variant_get_type() will always
15019 // result in %TRUE being returned. Calling this function on an
15020 // indefinite type like %G_VARIANT_TYPE_ARRAY, however, will result in
15021 // %FALSE being returned.
15023 // Since 2.24
15024 // RETURNS: %TRUE if @type is definite
15025 int is_definite()() {
15026 return g_variant_type_is_definite(&this);
15029 // Determines if the given @type is a dictionary entry type. This is
15030 // true if the type string for @type starts with a '{'.
15032 // This function returns %TRUE for any indefinite type for which every
15033 // definite subtype is a dictionary entry type --
15034 // %G_VARIANT_TYPE_DICT_ENTRY, for example.
15036 // Since 2.24
15037 // RETURNS: %TRUE if @type is a dictionary entry type
15038 int is_dict_entry()() {
15039 return g_variant_type_is_dict_entry(&this);
15042 // Determines if the given @type is a maybe type. This is true if the
15043 // type string for @type starts with an 'm'.
15045 // This function returns %TRUE for any indefinite type for which every
15046 // definite subtype is a maybe type -- %G_VARIANT_TYPE_MAYBE, for
15047 // example.
15049 // Since 2.24
15050 // RETURNS: %TRUE if @type is a maybe type
15051 int is_maybe()() {
15052 return g_variant_type_is_maybe(&this);
15055 // Checks if @type is a subtype of @supertype.
15057 // This function returns %TRUE if @type is a subtype of @supertype. All
15058 // types are considered to be subtypes of themselves. Aside from that,
15059 // only indefinite types can have subtypes.
15061 // Since 2.24
15062 // RETURNS: %TRUE if @type is a subtype of @supertype
15063 // <supertype>: a #GVariantType
15064 int is_subtype_of()(VariantType* supertype) {
15065 return g_variant_type_is_subtype_of(&this, supertype);
15068 // Determines if the given @type is a tuple type. This is true if the
15069 // type string for @type starts with a '(' or if @type is
15070 // %G_VARIANT_TYPE_TUPLE.
15072 // This function returns %TRUE for any indefinite type for which every
15073 // definite subtype is a tuple type -- %G_VARIANT_TYPE_TUPLE, for
15074 // example.
15076 // Since 2.24
15077 // RETURNS: %TRUE if @type is a tuple type
15078 int is_tuple()() {
15079 return g_variant_type_is_tuple(&this);
15082 // Determines if the given @type is the variant type.
15084 // Since 2.24
15085 // RETURNS: %TRUE if @type is the variant type
15086 int is_variant()() {
15087 return g_variant_type_is_variant(&this);
15090 // Determines the key type of a dictionary entry type.
15092 // This function may only be used with a dictionary entry type. Other
15093 // than the additional restriction, this call is equivalent to
15094 // g_variant_type_first().
15096 // Since 2.24
15097 // RETURNS: the key type of the dictionary entry
15098 VariantType* key()() {
15099 return g_variant_type_key(&this);
15102 // Determines the number of items contained in a tuple or
15103 // dictionary entry type.
15105 // This function may only be used with tuple or dictionary entry types,
15106 // but must not be used with the generic tuple type
15107 // %G_VARIANT_TYPE_TUPLE.
15109 // In the case of a dictionary entry type, this function will always
15110 // return 2.
15112 // Since 2.24
15113 // RETURNS: the number of items in @type
15114 size_t n_items()() {
15115 return g_variant_type_n_items(&this);
15118 // Constructs the type corresponding to an array of elements of the
15119 // type @type.
15121 // It is appropriate to call g_variant_type_free() on the return value.
15123 // Since 2.24
15124 // RETURNS: a new array #GVariantType
15125 VariantType* /*new*/ new_array()() {
15126 return g_variant_type_new_array(&this);
15129 // Constructs the type corresponding to a dictionary entry with a key
15130 // of type @key and a value of type @value.
15132 // It is appropriate to call g_variant_type_free() on the return value.
15134 // Since 2.24
15135 // RETURNS: a new dictionary entry #GVariantType
15136 // <value>: a #GVariantType
15137 VariantType* /*new*/ new_dict_entry()(VariantType* value) {
15138 return g_variant_type_new_dict_entry(&this, value);
15141 // Constructs the type corresponding to a maybe instance containing
15142 // type @type or Nothing.
15144 // It is appropriate to call g_variant_type_free() on the return value.
15146 // Since 2.24
15147 // RETURNS: a new maybe #GVariantType
15148 VariantType* /*new*/ new_maybe()() {
15149 return g_variant_type_new_maybe(&this);
15152 // Determines the next item type of a tuple or dictionary entry
15153 // type.
15155 // @type must be the result of a previous call to
15156 // g_variant_type_first() or g_variant_type_next().
15158 // If called on the key type of a dictionary entry then this call
15159 // returns the value type. If called on the value type of a dictionary
15160 // entry then this call returns %NULL.
15162 // For tuples, %NULL is returned when @type is the last item in a tuple.
15164 // Since 2.24
15165 // RETURNS: the next #GVariantType after @type, or %NULL
15166 VariantType* next()() {
15167 return g_variant_type_next(&this);
15170 // Unintrospectable method: peek_string() / g_variant_type_peek_string()
15171 // Returns the type string corresponding to the given @type. The
15172 // result is not nul-terminated; in order to determine its length you
15173 // must call g_variant_type_get_string_length().
15175 // To get a nul-terminated string, see g_variant_type_dup_string().
15177 // Since 2.24
15178 // RETURNS: the corresponding type string (not nul-terminated)
15179 char* peek_string()() {
15180 return g_variant_type_peek_string(&this);
15183 // Determines the value type of a dictionary entry type.
15185 // This function may only be used with a dictionary entry type.
15187 // Since 2.24
15188 // RETURNS: the value type of the dictionary entry
15189 VariantType* value()() {
15190 return g_variant_type_value(&this);
15192 static VariantType* checked_()(char* arg_a) {
15193 return g_variant_type_checked_(arg_a);
15196 // Checks if @type_string is a valid GVariant type string. This call is
15197 // equivalent to calling g_variant_type_string_scan() and confirming
15198 // that the following character is a nul terminator.
15200 // Since 2.24
15201 // RETURNS: %TRUE if @type_string is exactly one valid type string
15202 // <type_string>: a pointer to any string
15203 static int string_is_valid()(char* type_string) {
15204 return g_variant_type_string_is_valid(type_string);
15207 // VERSION: 2.24
15208 // Scan for a single complete and valid GVariant type string in @string.
15209 // The memory pointed to by @limit (or bytes beyond it) is never
15210 // accessed.
15212 // If a valid type string is found, @endptr is updated to point to the
15213 // first character past the end of the string that was found and %TRUE
15214 // is returned.
15216 // If there is no valid type string starting at @string, or if the type
15217 // string does not end before @limit then %FALSE is returned.
15219 // For the simple case of checking if a string is a valid type string,
15220 // see g_variant_type_string_is_valid().
15221 // RETURNS: %TRUE if a valid type string was found
15222 // <string>: a pointer to any string
15223 // <limit>: the end of @string, or %NULL
15224 // <endptr>: location to store the end pointer, or %NULL
15225 static int string_scan()(char* string_, char* limit=null, /*out*/ char** endptr=null) {
15226 return g_variant_type_string_scan(string_, limit, endptr);
15231 // Declares a type of function which takes no arguments
15232 // and has no return value. It is used to specify the type
15233 // function passed to g_atexit().
15234 extern (C) alias void function () VoidFunc;
15236 enum int WIN32_MSG_HANDLE = 19981206;
15238 // VERSION: 2.8
15239 // A wrapper for the POSIX access() function. This function is used to
15240 // test a pathname for one or several of read, write or execute
15241 // permissions, or just existence.
15243 // On Windows, the file protection mechanism is not at all POSIX-like,
15244 // and the underlying function in the C library only checks the
15245 // FAT-style READONLY attribute, and does not look at the ACL of a
15246 // file at all. This function is this in practise almost useless on
15247 // Windows. Software that needs to handle file permissions on Windows
15248 // more exactly should use the Win32 API.
15250 // See your C library manual for more details about access().
15252 // object that has all the tested permissions, or -1 otherwise or on
15253 // error.
15254 // RETURNS: zero if the pathname refers to an existing file system
15255 // <filename>: a pathname in the GLib file name encoding (UTF-8 on Windows)
15256 // <mode>: as in access()
15257 static int access()(char* filename, int mode) {
15258 return g_access(filename, mode);
15262 // MOVED TO: Array.free
15263 // Frees the memory allocated for the #GArray. If @free_segment is
15264 // %TRUE it frees the memory block holding the elements as well and
15265 // also each element if @array has a @element_free_func set. Pass
15266 // %FALSE if you want to free the #GArray wrapper but preserve the
15267 // underlying array for use elsewhere. If the reference count of @array
15268 // is greater than one, the #GArray wrapper is preserved but the size
15269 // of @array will be set to zero.
15271 // <note><para>If array elements contain dynamically-allocated memory,
15272 // they should be freed separately.</para></note>
15273 // <array>: a #GArray.
15274 // <free_segment>: if %TRUE the actual element data is freed as well.
15275 static char* /*new*/ array_free()(Array* array, int free_segment) {
15276 return g_array_free(array, free_segment);
15280 // VERSION: 2.22
15281 // MOVED TO: Array.get_element_size
15282 // Gets the size of the elements in @array.
15283 // RETURNS: Size of each element, in bytes.
15284 // <array>: A #GArray.
15285 static uint array_get_element_size()(Array* array) {
15286 return g_array_get_element_size(array);
15290 // VERSION: 2.22
15291 // MOVED TO: Array.unref
15292 // Atomically decrements the reference count of @array by one. If the
15293 // reference count drops to 0, all memory allocated by the array is
15294 // released. This function is MT-safe and may be called from any
15295 // thread.
15296 // <array>: A #GArray.
15297 static void array_unref()(Array* array) {
15298 g_array_unref(array);
15302 // Determines the numeric value of a character as a decimal
15303 // digit. Differs from g_unichar_digit_value() because it takes
15304 // a char, so there's no worry about sign extension if characters
15305 // are signed.
15307 // g_ascii_isdigit()), its numeric value. Otherwise, -1.
15308 // RETURNS: If @c is a decimal digit (according to
15309 // <c>: an ASCII character.
15310 static int ascii_digit_value()(char c) {
15311 return g_ascii_digit_value(c);
15315 // Converts a #gdouble to a string, using the '.' as
15316 // decimal point.
15318 // This functions generates enough precision that converting
15319 // the string back using g_ascii_strtod() gives the same machine-number
15320 // (on machines with IEEE compatible 64bit doubles). It is
15321 // guaranteed that the size of the resulting string will never
15322 // be larger than @G_ASCII_DTOSTR_BUF_SIZE bytes.
15323 // RETURNS: The pointer to the buffer with the converted string.
15324 // <buffer>: A buffer to place the resulting string in
15325 // <buf_len>: The length of the buffer.
15326 // <d>: The #gdouble to convert
15327 static char* /*new*/ ascii_dtostr()(char* buffer, int buf_len, double d) {
15328 return g_ascii_dtostr(buffer, buf_len, d);
15332 // Converts a #gdouble to a string, using the '.' as
15333 // decimal point. To format the number you pass in
15334 // a printf()-style format string. Allowed conversion
15335 // specifiers are 'e', 'E', 'f', 'F', 'g' and 'G'.
15337 // If you just want to want to serialize the value into a
15338 // string, use g_ascii_dtostr().
15339 // RETURNS: The pointer to the buffer with the converted string.
15340 // <buffer>: A buffer to place the resulting string in
15341 // <buf_len>: The length of the buffer.
15342 // <format>: The printf()-style format to use for the code to use for converting.
15343 // <d>: The #gdouble to convert
15344 static char* /*new*/ ascii_formatd()(char* buffer, int buf_len, char* format, double d) {
15345 return g_ascii_formatd(buffer, buf_len, format, d);
15349 // Compare two strings, ignoring the case of ASCII characters.
15351 // Unlike the BSD strcasecmp() function, this only recognizes standard
15352 // ASCII letters and ignores the locale, treating all non-ASCII
15353 // bytes as if they are not letters.
15355 // This function should be used only on strings that are known to be
15356 // in encodings where the bytes corresponding to ASCII letters always
15357 // represent themselves. This includes UTF-8 and the ISO-8859-*
15358 // charsets, but not for instance double-byte encodings like the
15359 // Windows Codepage 932, where the trailing bytes of double-byte
15360 // characters include all ASCII letters. If you compare two CP932
15361 // strings using this function, you will get false matches.
15363 // or a positive value if @s1 &gt; @s2.
15364 // RETURNS: 0 if the strings match, a negative value if @s1 &lt; @s2,
15365 // <s1>: string to compare with @s2.
15366 // <s2>: string to compare with @s1.
15367 static int ascii_strcasecmp()(char* s1, char* s2) {
15368 return g_ascii_strcasecmp(s1, s2);
15372 // Converts all upper case ASCII letters to lower case ASCII letters.
15374 // characters in @str converted to lower case, with
15375 // semantics that exactly match g_ascii_tolower(). (Note
15376 // that this is unlike the old g_strdown(), which modified
15377 // the string in place.)
15378 // RETURNS: a newly-allocated string, with all the upper case
15379 // <str>: a string.
15380 // <len>: length of @str in bytes, or -1 if @str is nul-terminated.
15381 static char* /*new*/ ascii_strdown()(char* str, ssize_t len) {
15382 return g_ascii_strdown(str, len);
15386 // Compare @s1 and @s2, ignoring the case of ASCII characters and any
15387 // characters after the first @n in each string.
15389 // Unlike the BSD strcasecmp() function, this only recognizes standard
15390 // ASCII letters and ignores the locale, treating all non-ASCII
15391 // characters as if they are not letters.
15393 // The same warning as in g_ascii_strcasecmp() applies: Use this
15394 // function only on strings known to be in encodings where bytes
15395 // corresponding to ASCII letters always represent themselves.
15397 // or a positive value if @s1 &gt; @s2.
15398 // RETURNS: 0 if the strings match, a negative value if @s1 &lt; @s2,
15399 // <s1>: string to compare with @s2.
15400 // <s2>: string to compare with @s1.
15401 // <n>: number of characters to compare.
15402 static int ascii_strncasecmp()(char* s1, char* s2, size_t n) {
15403 return g_ascii_strncasecmp(s1, s2, n);
15407 // Converts a string to a #gdouble value.
15409 // This function behaves like the standard strtod() function
15410 // does in the C locale. It does this without actually changing
15411 // the current locale, since that would not be thread-safe.
15412 // A limitation of the implementation is that this function
15413 // will still accept localized versions of infinities and NANs.
15415 // This function is typically used when reading configuration
15416 // files or other non-user input that should be locale independent.
15417 // To handle input from the user you should normally use the
15418 // locale-sensitive system strtod() function.
15420 // To convert from a #gdouble to a string in a locale-insensitive
15421 // way, use g_ascii_dtostr().
15423 // If the correct value would cause overflow, plus or minus %HUGE_VAL
15424 // is returned (according to the sign of the value), and %ERANGE is
15425 // stored in %errno. If the correct value would cause underflow,
15426 // zero is returned and %ERANGE is stored in %errno.
15428 // This function resets %errno before calling strtod() so that
15429 // you can reliably detect overflow and underflow.
15430 // RETURNS: the #gdouble value.
15431 // <nptr>: the string to convert to a numeric value.
15432 // <endptr>: if non-%NULL, it returns the character after the last character used in the conversion.
15433 static double ascii_strtod()(char* nptr, char** endptr) {
15434 return g_ascii_strtod(nptr, endptr);
15438 // VERSION: 2.12
15439 // Converts a string to a #gint64 value.
15440 // This function behaves like the standard strtoll() function
15441 // does in the C locale. It does this without actually
15442 // changing the current locale, since that would not be
15443 // thread-safe.
15445 // This function is typically used when reading configuration
15446 // files or other non-user input that should be locale independent.
15447 // To handle input from the user you should normally use the
15448 // locale-sensitive system strtoll() function.
15450 // If the correct value would cause overflow, %G_MAXINT64 or %G_MININT64
15451 // is returned, and %ERANGE is stored in %errno. If the base is
15452 // outside the valid range, zero is returned, and %EINVAL is stored
15453 // in %errno. If the string conversion fails, zero is returned, and
15454 // @endptr returns @nptr (if @endptr is non-%NULL).
15455 // RETURNS: the #gint64 value or zero on error.
15456 // <nptr>: the string to convert to a numeric value.
15457 // <endptr>: if non-%NULL, it returns the character after the last character used in the conversion.
15458 // <base>: to be used for the conversion, 2..36 or 0
15459 static long ascii_strtoll()(char* nptr, char** endptr, uint base) {
15460 return g_ascii_strtoll(nptr, endptr, base);
15464 // VERSION: 2.2
15465 // Converts a string to a #guint64 value.
15466 // This function behaves like the standard strtoull() function
15467 // does in the C locale. It does this without actually
15468 // changing the current locale, since that would not be
15469 // thread-safe.
15471 // This function is typically used when reading configuration
15472 // files or other non-user input that should be locale independent.
15473 // To handle input from the user you should normally use the
15474 // locale-sensitive system strtoull() function.
15476 // If the correct value would cause overflow, %G_MAXUINT64
15477 // is returned, and %ERANGE is stored in %errno. If the base is
15478 // outside the valid range, zero is returned, and %EINVAL is stored
15479 // in %errno. If the string conversion fails, zero is returned, and
15480 // @endptr returns @nptr (if @endptr is non-%NULL).
15481 // RETURNS: the #guint64 value or zero on error.
15482 // <nptr>: the string to convert to a numeric value.
15483 // <endptr>: if non-%NULL, it returns the character after the last character used in the conversion.
15484 // <base>: to be used for the conversion, 2..36 or 0
15485 static ulong ascii_strtoull()(char* nptr, char** endptr, uint base) {
15486 return g_ascii_strtoull(nptr, endptr, base);
15490 // Converts all lower case ASCII letters to upper case ASCII letters.
15492 // characters in @str converted to upper case, with
15493 // semantics that exactly match g_ascii_toupper(). (Note
15494 // that this is unlike the old g_strup(), which modified
15495 // the string in place.)
15496 // RETURNS: a newly allocated string, with all the lower case
15497 // <str>: a string.
15498 // <len>: length of @str in bytes, or -1 if @str is nul-terminated.
15499 static char* /*new*/ ascii_strup()(char* str, ssize_t len) {
15500 return g_ascii_strup(str, len);
15504 // Convert a character to ASCII lower case.
15506 // Unlike the standard C library tolower() function, this only
15507 // recognizes standard ASCII letters and ignores the locale, returning
15508 // all non-ASCII characters unchanged, even if they are lower case
15509 // letters in a particular character set. Also unlike the standard
15510 // library function, this takes and returns a char, not an int, so
15511 // don't call it on %EOF but no need to worry about casting to #guchar
15512 // before passing a possibly non-ASCII character in.
15514 // If @c is not an ASCII upper case letter,
15515 // @c is returned unchanged.
15516 // RETURNS: the result of converting @c to lower case.
15517 // <c>: any character.
15518 static char ascii_tolower()(char c) {
15519 return g_ascii_tolower(c);
15523 // Convert a character to ASCII upper case.
15525 // Unlike the standard C library toupper() function, this only
15526 // recognizes standard ASCII letters and ignores the locale, returning
15527 // all non-ASCII characters unchanged, even if they are upper case
15528 // letters in a particular character set. Also unlike the standard
15529 // library function, this takes and returns a char, not an int, so
15530 // don't call it on %EOF but no need to worry about casting to #guchar
15531 // before passing a possibly non-ASCII character in.
15533 // If @c is not an ASCII lower case letter,
15534 // @c is returned unchanged.
15535 // RETURNS: the result of converting @c to upper case.
15536 // <c>: any character.
15537 static char ascii_toupper()(char c) {
15538 return g_ascii_toupper(c);
15542 // Determines the numeric value of a character as a hexidecimal
15543 // digit. Differs from g_unichar_xdigit_value() because it takes
15544 // a char, so there's no worry about sign extension if characters
15545 // are signed.
15547 // g_ascii_isxdigit()), its numeric value. Otherwise, -1.
15548 // RETURNS: If @c is a hex digit (according to
15549 // <c>: an ASCII character.
15550 static int ascii_xdigit_value()(char c) {
15551 return g_ascii_xdigit_value(c);
15554 static void assert_warning()(char* log_domain, char* file, int line, char* pretty_function, char* expression) {
15555 g_assert_warning(log_domain, file, line, pretty_function, expression);
15558 static void assertion_message()(char* domain, char* file, int line, char* func, char* message) {
15559 g_assertion_message(domain, file, line, func, message);
15562 // Unintrospectable function: assertion_message_cmpnum() / g_assertion_message_cmpnum()
15563 static void assertion_message_cmpnum()(char* domain, char* file, int line, char* func, char* expr, real arg1, char* cmp, real arg2, char numtype) {
15564 g_assertion_message_cmpnum(domain, file, line, func, expr, arg1, cmp, arg2, numtype);
15567 static void assertion_message_cmpstr()(char* domain, char* file, int line, char* func, char* expr, char* arg1, char* cmp, char* arg2) {
15568 g_assertion_message_cmpstr(domain, file, line, func, expr, arg1, cmp, arg2);
15571 static void assertion_message_error()(char* domain, char* file, int line, char* func, char* expr, Error* error, Quark error_domain, int error_code) {
15572 g_assertion_message_error(domain, file, line, func, expr, error, error_domain, error_code);
15575 static void assertion_message_expr()(char* domain, char* file, int line, char* func, char* expr) {
15576 g_assertion_message_expr(domain, file, line, func, expr);
15580 // Specifies a function to be called at normal program termination.
15582 // Since GLib 2.8.2, on Windows g_atexit() actually is a preprocessor
15583 // macro that maps to a call to the atexit() function in the C
15584 // library. This means that in case the code that calls g_atexit(),
15585 // i.e. atexit(), is in a DLL, the function will be called when the
15586 // DLL is detached from the program. This typically makes more sense
15587 // than that the function is called when the GLib DLL is detached,
15588 // which happened earlier when g_atexit() was a function in the GLib
15589 // DLL.
15591 // The behaviour of atexit() in the context of dynamically loaded
15592 // modules is not formally specified and varies wildly.
15594 // On POSIX systems, calling g_atexit() (or atexit()) in a dynamically
15595 // loaded module which is unloaded before the program terminates might
15596 // well cause a crash at program exit.
15598 // Some POSIX systems implement atexit() like Windows, and have each
15599 // dynamically loaded module maintain an own atexit chain that is
15600 // called when the module is unloaded.
15602 // On other POSIX systems, before a dynamically loaded module is
15603 // unloaded, the registered atexit functions (if any) residing in that
15604 // module are called, regardless where the code that registered them
15605 // resided. This is presumably the most robust approach.
15607 // As can be seen from the above, for portability it's best to avoid
15608 // calling g_atexit() (or atexit()) except in the main executable of a
15609 // program.
15610 // <func>: the function to call on normal program termination.
15611 static void atexit()(VoidFunc func) {
15612 g_atexit(func);
15616 // VERSION: 2.4
15617 // Atomically adds @val to the value of @atomic.
15619 // Think of this operation as an atomic version of
15620 // <literal>{ tmp = *atomic; *@atomic += @val; return tmp; }</literal>
15622 // This call acts as a full compiler and hardware memory barrier.
15624 // Before version 2.30, this function did not return a value
15625 // (but g_atomic_int_exchange_and_add() did, and had the same meaning).
15626 // RETURNS: the value of @atomic before the add, signed
15627 // <atomic>: a pointer to a #gint or #guint
15628 // <val>: the value to add
15629 static int atomic_int_add()(int* atomic, int val) {
15630 return g_atomic_int_add(atomic, val);
15634 // VERSION: 2.30
15635 // Performs an atomic bitwise 'and' of the value of @atomic and @val,
15636 // storing the result back in @atomic.
15638 // This call acts as a full compiler and hardware memory barrier.
15640 // Think of this operation as an atomic version of
15641 // <literal>{ tmp = *atomic; *@atomic &= @val; return tmp; }</literal>
15642 // RETURNS: the value of @atomic before the operation, unsigned
15643 // <atomic>: a pointer to a #gint or #guint
15644 // <val>: the value to 'and'
15645 static uint atomic_int_and()(uint* atomic, uint val) {
15646 return g_atomic_int_and(atomic, val);
15650 // VERSION: 2.4
15651 // Compares @atomic to @oldval and, if equal, sets it to @newval.
15652 // If @atomic was not equal to @oldval then no change occurs.
15654 // This compare and exchange is done atomically.
15656 // Think of this operation as an atomic version of
15657 // <literal>{ if (*@atomic == @oldval) { *@atomic = @newval; return TRUE; } else return FALSE; }</literal>
15659 // This call acts as a full compiler and hardware memory barrier.
15660 // RETURNS: %TRUE if the exchange took place
15661 // <atomic>: a pointer to a #gint or #guint
15662 // <oldval>: the value to compare with
15663 // <newval>: the value to conditionally replace with
15664 static int atomic_int_compare_and_exchange()(int* atomic, int oldval, int newval) {
15665 return g_atomic_int_compare_and_exchange(atomic, oldval, newval);
15669 // VERSION: 2.4
15670 // Decrements the value of @atomic by 1.
15672 // Think of this operation as an atomic version of
15673 // <literal>{ *@atomic -= 1; return (*@atomic == 0); }</literal>
15675 // This call acts as a full compiler and hardware memory barrier.
15676 // RETURNS: %TRUE if the resultant value is zero
15677 // <atomic>: a pointer to a #gint or #guint
15678 static int atomic_int_dec_and_test()(int* atomic) {
15679 return g_atomic_int_dec_and_test(atomic);
15683 // VERSION: 2.4
15684 // DEPRECATED (v2.30) function: atomic_int_exchange_and_add - Use g_atomic_int_add() instead.
15685 // This function existed before g_atomic_int_add() returned the prior
15686 // value of the integer (which it now does). It is retained only for
15687 // compatibility reasons. Don't use this function in new code.
15688 // RETURNS: the value of @atomic before the add, signed
15689 // <atomic>: a pointer to a #gint
15690 // <val>: the value to add
15691 static int atomic_int_exchange_and_add()(int* atomic, int val) {
15692 return g_atomic_int_exchange_and_add(atomic, val);
15696 // VERSION: 2.4
15697 // Gets the current value of @atomic.
15699 // This call acts as a full compiler and hardware
15700 // memory barrier (before the get).
15701 // RETURNS: the value of the integer
15702 // <atomic>: a pointer to a #gint or #guint
15703 static int atomic_int_get()(int* atomic) {
15704 return g_atomic_int_get(atomic);
15708 // VERSION: 2.4
15709 // Increments the value of @atomic by 1.
15711 // Think of this operation as an atomic version of
15712 // <literal>{ *@atomic += 1; }</literal>
15714 // This call acts as a full compiler and hardware memory barrier.
15715 // <atomic>: a pointer to a #gint or #guint
15716 static void atomic_int_inc()(int* atomic) {
15717 g_atomic_int_inc(atomic);
15721 // VERSION: 2.30
15722 // Performs an atomic bitwise 'or' of the value of @atomic and @val,
15723 // storing the result back in @atomic.
15725 // Think of this operation as an atomic version of
15726 // <literal>{ tmp = *atomic; *@atomic |= @val; return tmp; }</literal>
15728 // This call acts as a full compiler and hardware memory barrier.
15729 // RETURNS: the value of @atomic before the operation, unsigned
15730 // <atomic>: a pointer to a #gint or #guint
15731 // <val>: the value to 'or'
15732 static uint atomic_int_or()(uint* atomic, uint val) {
15733 return g_atomic_int_or(atomic, val);
15737 // VERSION: 2.4
15738 // Sets the value of @atomic to @newval.
15740 // This call acts as a full compiler and hardware
15741 // memory barrier (after the set).
15742 // <atomic>: a pointer to a #gint or #guint
15743 // <newval>: a new value to store
15744 static void atomic_int_set()(int* atomic, int newval) {
15745 g_atomic_int_set(atomic, newval);
15749 // VERSION: 2.30
15750 // Performs an atomic bitwise 'xor' of the value of @atomic and @val,
15751 // storing the result back in @atomic.
15753 // Think of this operation as an atomic version of
15754 // <literal>{ tmp = *atomic; *@atomic ^= @val; return tmp; }</literal>
15756 // This call acts as a full compiler and hardware memory barrier.
15757 // RETURNS: the value of @atomic before the operation, unsigned
15758 // <atomic>: a pointer to a #gint or #guint
15759 // <val>: the value to 'xor'
15760 static uint atomic_int_xor()(uint* atomic, uint val) {
15761 return g_atomic_int_xor(atomic, val);
15765 // VERSION: 2.30
15766 // Atomically adds @val to the value of @atomic.
15768 // Think of this operation as an atomic version of
15769 // <literal>{ tmp = *atomic; *@atomic += @val; return tmp; }</literal>
15771 // This call acts as a full compiler and hardware memory barrier.
15772 // RETURNS: the value of @atomic before the add, signed
15773 // <atomic>: a pointer to a #gpointer-sized value
15774 // <val>: the value to add
15775 static ssize_t atomic_pointer_add()(void* atomic, ssize_t val) {
15776 return g_atomic_pointer_add(atomic, val);
15780 // VERSION: 2.30
15781 // Performs an atomic bitwise 'and' of the value of @atomic and @val,
15782 // storing the result back in @atomic.
15784 // Think of this operation as an atomic version of
15785 // <literal>{ tmp = *atomic; *@atomic &= @val; return tmp; }</literal>
15787 // This call acts as a full compiler and hardware memory barrier.
15788 // RETURNS: the value of @atomic before the operation, unsigned
15789 // <atomic>: a pointer to a #gpointer-sized value
15790 // <val>: the value to 'and'
15791 static size_t atomic_pointer_and()(void* atomic, size_t val) {
15792 return g_atomic_pointer_and(atomic, val);
15796 // VERSION: 2.4
15797 // Compares @atomic to @oldval and, if equal, sets it to @newval.
15798 // If @atomic was not equal to @oldval then no change occurs.
15800 // This compare and exchange is done atomically.
15802 // Think of this operation as an atomic version of
15803 // <literal>{ if (*@atomic == @oldval) { *@atomic = @newval; return TRUE; } else return FALSE; }</literal>
15805 // This call acts as a full compiler and hardware memory barrier.
15806 // RETURNS: %TRUE if the exchange took place
15807 // <atomic>: a pointer to a #gpointer-sized value
15808 // <oldval>: the value to compare with
15809 // <newval>: the value to conditionally replace with
15810 static int atomic_pointer_compare_and_exchange()(void* atomic, void* oldval, void* newval) {
15811 return g_atomic_pointer_compare_and_exchange(atomic, oldval, newval);
15815 // Unintrospectable function: atomic_pointer_get() / g_atomic_pointer_get()
15816 // VERSION: 2.4
15817 // Gets the current value of @atomic.
15819 // This call acts as a full compiler and hardware
15820 // memory barrier (before the get).
15821 // RETURNS: the value of the pointer
15822 // <atomic>: a pointer to a #gpointer-sized value
15823 static void* atomic_pointer_get()(void* atomic) {
15824 return g_atomic_pointer_get(atomic);
15828 // VERSION: 2.30
15829 // Performs an atomic bitwise 'or' of the value of @atomic and @val,
15830 // storing the result back in @atomic.
15832 // Think of this operation as an atomic version of
15833 // <literal>{ tmp = *atomic; *@atomic |= @val; return tmp; }</literal>
15835 // This call acts as a full compiler and hardware memory barrier.
15836 // RETURNS: the value of @atomic before the operation, unsigned
15837 // <atomic>: a pointer to a #gpointer-sized value
15838 // <val>: the value to 'or'
15839 static size_t atomic_pointer_or()(void* atomic, size_t val) {
15840 return g_atomic_pointer_or(atomic, val);
15844 // VERSION: 2.4
15845 // Sets the value of @atomic to @newval.
15847 // This call acts as a full compiler and hardware
15848 // memory barrier (after the set).
15849 // <atomic>: a pointer to a #gpointer-sized value
15850 // <newval>: a new value to store
15851 static void atomic_pointer_set()(void* atomic, void* newval) {
15852 g_atomic_pointer_set(atomic, newval);
15856 // VERSION: 2.30
15857 // Performs an atomic bitwise 'xor' of the value of @atomic and @val,
15858 // storing the result back in @atomic.
15860 // Think of this operation as an atomic version of
15861 // <literal>{ tmp = *atomic; *@atomic ^= @val; return tmp; }</literal>
15863 // This call acts as a full compiler and hardware memory barrier.
15864 // RETURNS: the value of @atomic before the operation, unsigned
15865 // <atomic>: a pointer to a #gpointer-sized value
15866 // <val>: the value to 'xor'
15867 static size_t atomic_pointer_xor()(void* atomic, size_t val) {
15868 return g_atomic_pointer_xor(atomic, val);
15872 // VERSION: 2.12
15873 // Decode a sequence of Base-64 encoded text into binary data
15875 // newly allocated buffer containing the binary data
15876 // that @text represents. The returned buffer must
15877 // be freed with g_free().
15878 // <text>: zero-terminated string with base64 text to decode
15879 // <out_len>: The length of the decoded data is written here
15880 static ubyte* /*new*/ base64_decode()(char* text, /*out*/ size_t* out_len) {
15881 return g_base64_decode(text, out_len);
15885 // VERSION: 2.20
15886 // Decode a sequence of Base-64 encoded text into binary data
15887 // by overwriting the input data.
15889 // is the same as the input @text.
15890 // RETURNS: The binary data that @text responds. This pointer
15891 // <text>: zero-terminated string with base64 text to decode
15892 // <out_len>: The length of the decoded data is written here
15893 static ubyte* base64_decode_inplace()(/*inout*/ ubyte* text, /*inout*/ size_t* out_len) {
15894 return g_base64_decode_inplace(text, out_len);
15898 // VERSION: 2.12
15899 // Incrementally decode a sequence of binary data from its Base-64 stringified
15900 // representation. By calling this function multiple times you can convert
15901 // data in chunks to avoid having to have the full encoded data in memory.
15903 // The output buffer must be large enough to fit all the data that will
15904 // be written to it. Since base64 encodes 3 bytes in 4 chars you need
15905 // at least: (@len / 4) * 3 + 3 bytes (+ 3 may be needed in case of non-zero
15906 // state).
15907 // RETURNS: The number of bytes of output that was written
15908 // <in>: binary input data
15909 // <len>: max length of @in data to decode
15910 // <out>: output buffer
15911 // <state>: Saved state between steps, initialize to 0
15912 // <save>: Saved state between steps, initialize to 0
15913 static size_t base64_decode_step()(ubyte* in_, size_t len, /*out*/ ubyte* out_, /*inout*/ int* state, /*inout*/ uint* save) {
15914 return g_base64_decode_step(in_, len, out_, state, save);
15918 // VERSION: 2.12
15919 // Encode a sequence of binary data into its Base-64 stringified
15920 // representation.
15922 // encoded string representing @data. The returned string must
15923 // be freed with g_free().
15924 // RETURNS: a newly allocated, zero-terminated Base-64
15925 // <data>: the binary data to encode
15926 // <len>: the length of @data
15927 static char* /*new*/ base64_encode()(ubyte* data, size_t len) {
15928 return g_base64_encode(data, len);
15932 // VERSION: 2.12
15933 // Flush the status from a sequence of calls to g_base64_encode_step().
15935 // The output buffer must be large enough to fit all the data that will
15936 // be written to it. It will need up to 4 bytes, or up to 5 bytes if
15937 // line-breaking is enabled.
15938 // RETURNS: The number of bytes of output that was written
15939 // <break_lines>: whether to break long lines
15940 // <out>: pointer to destination buffer
15941 // <state>: Saved state from g_base64_encode_step()
15942 // <save>: Saved state from g_base64_encode_step()
15943 static size_t base64_encode_close()(int break_lines, /*out*/ ubyte* out_, /*inout*/ int* state, /*inout*/ int* save) {
15944 return g_base64_encode_close(break_lines, out_, state, save);
15948 // VERSION: 2.12
15949 // Incrementally encode a sequence of binary data into its Base-64 stringified
15950 // representation. By calling this function multiple times you can convert
15951 // data in chunks to avoid having to have the full encoded data in memory.
15953 // When all of the data has been converted you must call
15954 // g_base64_encode_close() to flush the saved state.
15956 // The output buffer must be large enough to fit all the data that will
15957 // be written to it. Due to the way base64 encodes you will need
15958 // at least: (@len / 3 + 1) * 4 + 4 bytes (+ 4 may be needed in case of
15959 // non-zero state). If you enable line-breaking you will need at least:
15960 // ((@len / 3 + 1) * 4 + 4) / 72 + 1 bytes of extra space.
15962 // @break_lines is typically used when putting base64-encoded data in emails.
15963 // It breaks the lines at 72 columns instead of putting all of the text on
15964 // the same line. This avoids problems with long lines in the email system.
15965 // RETURNS: The number of bytes of output that was written
15966 // <in>: the binary data to encode
15967 // <len>: the length of @in
15968 // <break_lines>: whether to break long lines
15969 // <out>: pointer to destination buffer
15970 // <state>: Saved state between steps, initialize to 0
15971 // <save>: Saved state between steps, initialize to 0
15972 static size_t base64_encode_step()(ubyte* in_, size_t len, int break_lines, /*out*/ ubyte* out_, /*inout*/ int* state, /*inout*/ int* save) {
15973 return g_base64_encode_step(in_, len, break_lines, out_, state, save);
15977 // Gets the name of the file without any leading directory components.
15978 // It returns a pointer into the given file name string.
15981 // Deprecated:2.2: Use g_path_get_basename() instead, but notice that
15982 // g_path_get_basename() allocates new memory for the returned string, unlike
15983 // this function which returns a pointer into the argument.
15984 // RETURNS: the name of the file without any leading directory components.
15985 // <file_name>: the name of the file.
15986 static char* basename()(char* file_name) {
15987 return g_basename(file_name);
15991 // VERSION: 2.24
15992 // Sets the indicated @lock_bit in @address. If the bit is already
15993 // set, this call will block until g_bit_unlock() unsets the
15994 // corresponding bit.
15996 // Attempting to lock on two different bits within the same integer is
15997 // not supported and will very probably cause deadlocks.
15999 // The value of the bit that is set is (1u << @bit). If @bit is not
16000 // between 0 and 31 then the result is undefined.
16002 // This function accesses @address atomically. All other accesses to
16003 // @address must be atomic in order for this function to work
16004 // reliably.
16005 // <address>: a pointer to an integer
16006 // <lock_bit>: a bit value between 0 and 31
16007 static void bit_lock()(int* address, int lock_bit) {
16008 g_bit_lock(address, lock_bit);
16012 // Find the position of the first bit set in @mask, searching
16013 // from (but not including) @nth_bit upwards. Bits are numbered
16014 // from 0 (least significant) to sizeof(#gulong) * 8 - 1 (31 or 63,
16015 // usually). To start searching from the 0th bit, set @nth_bit to -1.
16016 // RETURNS: the index of the first bit set which is higher than @nth_bit
16017 // <mask>: a #gulong containing flags
16018 // <nth_bit>: the index of the bit to start the search from
16019 static int bit_nth_lsf()(c_ulong mask, int nth_bit) {
16020 return g_bit_nth_lsf(mask, nth_bit);
16024 // Find the position of the first bit set in @mask, searching
16025 // from (but not including) @nth_bit downwards. Bits are numbered
16026 // from 0 (least significant) to sizeof(#gulong) * 8 - 1 (31 or 63,
16027 // usually). To start searching from the last bit, set @nth_bit to
16028 // -1 or GLIB_SIZEOF_LONG * 8.
16029 // RETURNS: the index of the first bit set which is lower than @nth_bit
16030 // <mask>: a #gulong containing flags
16031 // <nth_bit>: the index of the bit to start the search from
16032 static int bit_nth_msf()(c_ulong mask, int nth_bit) {
16033 return g_bit_nth_msf(mask, nth_bit);
16037 // Gets the number of bits used to hold @number,
16038 // e.g. if @number is 4, 3 bits are needed.
16039 // RETURNS: the number of bits used to hold @number
16040 // <number>: a #guint
16041 static uint bit_storage()(c_ulong number) {
16042 return g_bit_storage(number);
16046 // VERSION: 2.24
16047 // Sets the indicated @lock_bit in @address, returning %TRUE if
16048 // successful. If the bit is already set, returns %FALSE immediately.
16050 // Attempting to lock on two different bits within the same integer is
16051 // not supported.
16053 // The value of the bit that is set is (1u << @bit). If @bit is not
16054 // between 0 and 31 then the result is undefined.
16056 // This function accesses @address atomically. All other accesses to
16057 // @address must be atomic in order for this function to work
16058 // reliably.
16059 // RETURNS: %TRUE if the lock was acquired
16060 // <address>: a pointer to an integer
16061 // <lock_bit>: a bit value between 0 and 31
16062 static int bit_trylock()(int* address, int lock_bit) {
16063 return g_bit_trylock(address, lock_bit);
16067 // VERSION: 2.24
16068 // Clears the indicated @lock_bit in @address. If another thread is
16069 // currently blocked in g_bit_lock() on this same bit then it will be
16070 // woken up.
16072 // This function accesses @address atomically. All other accesses to
16073 // @address must be atomic in order for this function to work
16074 // reliably.
16075 // <address>: a pointer to an integer
16076 // <lock_bit>: a bit value between 0 and 31
16077 static void bit_unlock()(int* address, int lock_bit) {
16078 g_bit_unlock(address, lock_bit);
16082 // Calls g_mem_chunk_clean() on all #GMemChunk objects.
16084 // Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
16085 // allocator</link> instead
16086 static void blow_chunks()() {
16087 g_blow_chunks();
16090 // MOVED TO: BookmarkFile.error_quark
16091 static Quark bookmark_file_error_quark()() {
16092 return g_bookmark_file_error_quark();
16096 // Unintrospectable function: build_filename() / g_build_filename()
16097 // Creates a filename from a series of elements using the correct
16098 // separator for filenames.
16100 // On Unix, this function behaves identically to <literal>g_build_path
16101 // (G_DIR_SEPARATOR_S, first_element, ....)</literal>.
16103 // On Windows, it takes into account that either the backslash
16104 // (<literal>\</literal> or slash (<literal>/</literal>) can be used
16105 // as separator in filenames, but otherwise behaves as on Unix. When
16106 // file pathname separators need to be inserted, the one that last
16107 // previously occurred in the parameters (reading from left to right)
16108 // is used.
16110 // No attempt is made to force the resulting filename to be an absolute
16111 // path. If the first element is a relative path, the result will
16112 // be a relative path.
16113 // RETURNS: a newly-allocated string that must be freed with g_free().
16114 // <first_element>: the first element in the path
16115 alias g_build_filename build_filename; // Variadic
16118 // VERSION: 2.8
16119 // Behaves exactly like g_build_filename(), but takes the path elements
16120 // as a string array, instead of varargs. This function is mainly
16121 // meant for language bindings.
16122 // RETURNS: a newly-allocated string that must be freed with g_free().
16123 // <args>: %NULL-terminated array of strings containing the path elements.
16124 static char* /*new*/ build_filenamev()(char** args) {
16125 return g_build_filenamev(args);
16129 // Unintrospectable function: build_path() / g_build_path()
16130 // Creates a path from a series of elements using @separator as the
16131 // separator between elements. At the boundary between two elements,
16132 // any trailing occurrences of separator in the first element, or
16133 // leading occurrences of separator in the second element are removed
16134 // and exactly one copy of the separator is inserted.
16136 // Empty elements are ignored.
16138 // The number of leading copies of the separator on the result is
16139 // the same as the number of leading copies of the separator on
16140 // the first non-empty element.
16142 // The number of trailing copies of the separator on the result is
16143 // the same as the number of trailing copies of the separator on
16144 // the last non-empty element. (Determination of the number of
16145 // trailing copies is done without stripping leading copies, so
16146 // if the separator is <literal>ABA</literal>, <literal>ABABA</literal>
16147 // has 1 trailing copy.)
16149 // However, if there is only a single non-empty element, and there
16150 // are no characters in that element not part of the leading or
16151 // trailing separators, then the result is exactly the original value
16152 // of that element.
16154 // Other than for determination of the number of leading and trailing
16155 // copies of the separator, elements consisting only of copies
16156 // of the separator are ignored.
16157 // RETURNS: a newly-allocated string that must be freed with g_free().
16158 // <separator>: a string used to separator the elements of the path.
16159 // <first_element>: the first element in the path
16160 alias g_build_path build_path; // Variadic
16163 // VERSION: 2.8
16164 // Behaves exactly like g_build_path(), but takes the path elements
16165 // as a string array, instead of varargs. This function is mainly
16166 // meant for language bindings.
16167 // RETURNS: a newly-allocated string that must be freed with g_free().
16168 // <separator>: a string used to separator the elements of the path.
16169 // <args>: %NULL-terminated array of strings containing the path elements.
16170 static char* /*new*/ build_pathv()(char* separator, char** args) {
16171 return g_build_pathv(separator, args);
16175 // MOVED TO: ByteArray.free
16176 // Frees the memory allocated by the #GByteArray. If @free_segment is
16177 // %TRUE it frees the actual byte data. If the reference count of
16178 // @array is greater than one, the #GByteArray wrapper is preserved but
16179 // the size of @array will be set to zero.
16180 // <array>: a #GByteArray.
16181 // <free_segment>: if %TRUE the actual byte data is freed as well.
16182 static ubyte* byte_array_free()(ByteArray* array, int free_segment) {
16183 return g_byte_array_free(array, free_segment);
16187 // VERSION: 2.22
16188 // MOVED TO: ByteArray.unref
16189 // Atomically decrements the reference count of @array by one. If the
16190 // reference count drops to 0, all memory allocated by the array is
16191 // released. This function is MT-safe and may be called from any
16192 // thread.
16193 // <array>: A #GByteArray.
16194 static void byte_array_unref()(ByteArray* array) {
16195 g_byte_array_unref(array);
16199 // VERSION: 2.8
16200 // A wrapper for the POSIX chdir() function. The function changes the
16201 // current directory of the process to @path.
16203 // See your C library manual for more details about chdir().
16204 // RETURNS: 0 on success, -1 if an error occurred.
16205 // <path>: a pathname in the GLib file name encoding (UTF-8 on Windows)
16206 static int chdir()(char* path) {
16207 return g_chdir(path);
16211 // VERSION: 2.6
16212 // Checks that the GLib library in use is compatible with the
16213 // given version. Generally you would pass in the constants
16214 // #GLIB_MAJOR_VERSION, #GLIB_MINOR_VERSION, #GLIB_MICRO_VERSION
16215 // as the three arguments to this function; that produces
16216 // a check that the library in use is compatible with
16217 // the version of GLib the application or module was compiled
16218 // against.
16220 // Compatibility is defined by two things: first the version
16221 // of the running library is newer than the version
16222 // @required_major.required_minor.@required_micro. Second
16223 // the running library must be binary compatible with the
16224 // version @required_major.required_minor.@required_micro
16225 // (same major version.)
16227 // given version, or a string describing the version mismatch.
16228 // The returned string is owned by GLib and must not be modified
16229 // or freed.
16230 // RETURNS: %NULL if the GLib library is compatible with the
16231 // <required_major>: the required major version.
16232 // <required_minor>: the required minor version.
16233 // <required_micro>: the required micro version.
16234 static char* check_version()(uint required_major, uint required_minor, uint required_micro) {
16235 return glib_check_version(required_major, required_minor, required_micro);
16239 // VERSION: 2.16
16240 // MOVED TO: Checksum.type_get_length
16241 // Gets the length in bytes of digests of type @checksum_type
16243 // not supported.
16244 // RETURNS: the checksum length, or -1 if @checksum_type is
16245 // <checksum_type>: a #GChecksumType
16246 static ssize_t checksum_type_get_length()(ChecksumType checksum_type) {
16247 return g_checksum_type_get_length(checksum_type);
16251 // Unintrospectable function: child_watch_add() / g_child_watch_add()
16252 // VERSION: 2.4
16253 // Sets a function to be called when the child indicated by @pid
16254 // exits, at a default priority, #G_PRIORITY_DEFAULT.
16256 // If you obtain @pid from g_spawn_async() or g_spawn_async_with_pipes()
16257 // you will need to pass #G_SPAWN_DO_NOT_REAP_CHILD as flag to
16258 // the spawn function for the child watching to work.
16260 // Note that on platforms where #GPid must be explicitly closed
16261 // (see g_spawn_close_pid()) @pid must not be closed while the
16262 // source is still active. Typically, you will want to call
16263 // g_spawn_close_pid() in the callback function for the source.
16265 // GLib supports only a single callback per process id.
16267 // This internally creates a main loop source using
16268 // g_child_watch_source_new() and attaches it to the main loop context
16269 // using g_source_attach(). You can do these steps manually if you
16270 // need greater control.
16271 // RETURNS: the ID (greater than 0) of the event source.
16272 // <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).
16273 // <function>: function to call
16274 // <data>: data to pass to @function
16275 static uint child_watch_add()(Pid pid, ChildWatchFunc function_, void* data) {
16276 return g_child_watch_add(pid, function_, data);
16280 // VERSION: 2.4
16281 // Sets a function to be called when the child indicated by @pid
16282 // exits, at the priority @priority.
16284 // If you obtain @pid from g_spawn_async() or g_spawn_async_with_pipes()
16285 // you will need to pass #G_SPAWN_DO_NOT_REAP_CHILD as flag to
16286 // the spawn function for the child watching to work.
16288 // Note that on platforms where #GPid must be explicitly closed
16289 // (see g_spawn_close_pid()) @pid must not be closed while the
16290 // source is still active. Typically, you will want to call
16291 // g_spawn_close_pid() in the callback function for the source.
16293 // GLib supports only a single callback per process id.
16295 // This internally creates a main loop source using
16296 // g_child_watch_source_new() and attaches it to the main loop context
16297 // using g_source_attach(). You can do these steps manually if you
16298 // need greater control.
16299 // RETURNS: the ID (greater than 0) of the event source.
16300 // <priority>: the priority of the idle source. Typically this will be in the range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.
16301 // <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).
16302 // <function>: function to call
16303 // <data>: data to pass to @function
16304 // <notify>: function to call when the idle is removed, or %NULL
16305 static uint child_watch_add_full()(int priority, Pid pid, ChildWatchFunc function_, void* data, DestroyNotify notify) {
16306 return g_child_watch_add_full(priority, pid, function_, data, notify);
16310 // VERSION: 2.4
16311 // Creates a new child_watch source.
16313 // The source will not initially be associated with any #GMainContext
16314 // and must be added to one with g_source_attach() before it will be
16315 // executed.
16317 // Note that child watch sources can only be used in conjunction with
16318 // <literal>g_spawn...</literal> when the %G_SPAWN_DO_NOT_REAP_CHILD
16319 // flag is used.
16321 // Note that on platforms where #GPid must be explicitly closed
16322 // (see g_spawn_close_pid()) @pid must not be closed while the
16323 // source is still active. Typically, you will want to call
16324 // g_spawn_close_pid() in the callback function for the source.
16326 // Note further that using g_child_watch_source_new() is not
16327 // compatible with calling <literal>waitpid(-1)</literal> in
16328 // the application. Calling waitpid() for individual pids will
16329 // still work fine.
16330 // RETURNS: the newly-created child watch source
16331 // <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).
16332 static Source* /*new*/ child_watch_source_new()(Pid pid) {
16333 return g_child_watch_source_new(pid);
16337 // If @err is %NULL, does nothing. If @err is non-%NULL,
16338 // calls g_error_free() on *@err and sets *@err to %NULL.
16339 static void clear_error()(GLib2.Error** error=null) {
16340 g_clear_error(error);
16344 // VERSION: 2.16
16345 // Computes the checksum for a binary @data of @length. This is a
16346 // convenience wrapper for g_checksum_new(), g_checksum_get_string()
16347 // and g_checksum_free().
16349 // The hexadecimal string returned will be in lower case.
16351 // The returned string should be freed with g_free() when done using it.
16352 // RETURNS: the digest of the binary data as a string in hexadecimal.
16353 // <checksum_type>: a #GChecksumType
16354 // <data>: binary blob to compute the digest of
16355 // <length>: length of @data
16356 static char* /*new*/ compute_checksum_for_data()(ChecksumType checksum_type, ubyte* data, size_t length) {
16357 return g_compute_checksum_for_data(checksum_type, data, length);
16361 // VERSION: 2.16
16362 // Computes the checksum of a string.
16364 // The hexadecimal string returned will be in lower case.
16366 // should be freed with g_free() when done using it.
16367 // RETURNS: the checksum as a hexadecimal string. The returned string
16368 // <checksum_type>: a #GChecksumType
16369 // <str>: the string to compute the checksum of
16370 // <length>: the length of the string, or -1 if the string is null-terminated.
16371 static char* /*new*/ compute_checksum_for_string()(ChecksumType checksum_type, char* str, ssize_t length) {
16372 return g_compute_checksum_for_string(checksum_type, str, length);
16376 // VERSION: 2.30
16377 // Computes the HMAC for a binary @data of @length. This is a
16378 // convenience wrapper for g_hmac_new(), g_hmac_get_string()
16379 // and g_hmac_unref().
16381 // The hexadecimal string returned will be in lower case.
16383 // The returned string should be freed with g_free() when done using it.
16384 // RETURNS: the HMAC of the binary data as a string in hexadecimal.
16385 // <digest_type>: a #GChecksumType to use for the HMAC
16386 // <key>: the key to use in the HMAC
16387 // <key_len>: the length of the key
16388 // <data>: binary blob to compute the HMAC of
16389 // <length>: length of @data
16390 static char* /*new*/ compute_hmac_for_data()(ChecksumType digest_type, ubyte* key, size_t key_len, ubyte* data, size_t length) {
16391 return g_compute_hmac_for_data(digest_type, key, key_len, data, length);
16395 // VERSION: 2.30
16396 // Computes the HMAC for a string.
16398 // The hexadecimal string returned will be in lower case.
16400 // The returned string should be freed with g_free()
16401 // when done using it.
16402 // RETURNS: the HMAC as a hexadecimal string.
16403 // <digest_type>: a #GChecksumType to use for the HMAC
16404 // <key>: the key to use in the HMAC
16405 // <key_len>: the length of the key
16406 // <str>: the string to compute the HMAC for
16407 // <length>: the length of the string, or -1 if the string is nul-terminated
16408 static char* /*new*/ compute_hmac_for_string()(ChecksumType digest_type, ubyte* key, size_t key_len, char* str, ssize_t length) {
16409 return g_compute_hmac_for_string(digest_type, key, key_len, str, length);
16413 // Converts a string from one character set to another.
16415 // Note that you should use g_iconv() for streaming
16416 // conversions<footnoteref linkend="streaming-state"/>.
16418 // nul-terminated string, which must be freed with
16419 // g_free(). Otherwise %NULL and @error will be set.
16420 // RETURNS: If the conversion was successful, a newly allocated
16421 // <str>: the string to convert
16422 // <len>: the length of the string, or -1 if the string is nul-terminated<footnote id="nul-unsafe">
16423 // <to_codeset>: name of character set into which to convert @str
16424 // <from_codeset>: character set of @str.
16425 // <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.
16426 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
16427 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) {
16428 return g_convert(str, len, to_codeset, from_codeset, bytes_read, bytes_written, error);
16431 static Quark convert_error_quark()() {
16432 return g_convert_error_quark();
16436 // Converts a string from one character set to another, possibly
16437 // including fallback sequences for characters not representable
16438 // in the output. Note that it is not guaranteed that the specification
16439 // for the fallback sequences in @fallback will be honored. Some
16440 // systems may do an approximate conversion from @from_codeset
16441 // to @to_codeset in their iconv() functions,
16442 // in which case GLib will simply return that approximate conversion.
16444 // Note that you should use g_iconv() for streaming
16445 // conversions<footnoteref linkend="streaming-state"/>.
16447 // nul-terminated string, which must be freed with
16448 // g_free(). Otherwise %NULL and @error will be set.
16449 // RETURNS: If the conversion was successful, a newly allocated
16450 // <str>: the string to convert
16451 // <len>: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
16452 // <to_codeset>: name of character set into which to convert @str
16453 // <from_codeset>: character set of @str.
16454 // <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).
16455 // <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.
16456 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
16457 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) {
16458 return g_convert_with_fallback(str, len, to_codeset, from_codeset, fallback, bytes_read, bytes_written, error);
16462 // Converts a string from one character set to another.
16464 // Note that you should use g_iconv() for streaming
16465 // conversions<footnote id="streaming-state">
16466 // <para>
16467 // Despite the fact that @byes_read can return information about partial
16468 // characters, the <literal>g_convert_...</literal> functions
16469 // are not generally suitable for streaming. If the underlying converter
16470 // being used maintains internal state, then this won't be preserved
16471 // across successive calls to g_convert(), g_convert_with_iconv() or
16472 // g_convert_with_fallback(). (An example of this is the GNU C converter
16473 // for CP1255 which does not emit a base character until it knows that
16474 // the next character is not a mark that could combine with the base
16475 // character.)
16476 // </para>
16477 // </footnote>.
16479 // nul-terminated string, which must be freed with
16480 // g_free(). Otherwise %NULL and @error will be set.
16481 // RETURNS: If the conversion was successful, a newly allocated
16482 // <str>: the string to convert
16483 // <len>: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
16484 // <converter>: conversion descriptor from g_iconv_open()
16485 // <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.
16486 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
16487 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) {
16488 return g_convert_with_iconv(str, len, converter, bytes_read, bytes_written, error);
16492 // Frees all the data elements of the datalist.
16493 // The data elements' destroy functions are called
16494 // if they have been set.
16495 // <datalist>: a datalist.
16496 static void datalist_clear()(Data** datalist) {
16497 g_datalist_clear(datalist);
16501 // Unintrospectable function: datalist_foreach() / g_datalist_foreach()
16502 // Calls the given function for each data element of the datalist. The
16503 // function is called with each data element's #GQuark id and data,
16504 // together with the given @user_data parameter. Note that this
16505 // function is NOT thread-safe. So unless @datalist can be protected
16506 // from any modifications during invocation of this function, it should
16507 // not be called.
16508 // <datalist>: a datalist.
16509 // <func>: the function to call for each data element.
16510 // <user_data>: user data to pass to the function.
16511 static void datalist_foreach()(Data** datalist, DataForeachFunc func, void* user_data) {
16512 g_datalist_foreach(datalist, func, user_data);
16516 // Unintrospectable function: datalist_get_data() / g_datalist_get_data()
16517 // Gets a data element, using its string identifer. This is slower than
16518 // g_datalist_id_get_data() because it compares strings.
16519 // <datalist>: a datalist.
16520 // <key>: the string identifying a data element.
16521 static void* datalist_get_data()(Data** datalist, char* key) {
16522 return g_datalist_get_data(datalist, key);
16526 // VERSION: 2.8
16527 // Gets flags values packed in together with the datalist.
16528 // See g_datalist_set_flags().
16529 // RETURNS: the flags of the datalist
16530 // <datalist>: pointer to the location that holds a list
16531 static uint datalist_get_flags()(Data** datalist) {
16532 return g_datalist_get_flags(datalist);
16536 // Unintrospectable function: datalist_id_get_data() / g_datalist_id_get_data()
16537 // Retrieves the data element corresponding to @key_id.
16538 // <datalist>: a datalist.
16539 // <key_id>: the #GQuark identifying a data element.
16540 static void* datalist_id_get_data()(Data** datalist, Quark key_id) {
16541 return g_datalist_id_get_data(datalist, key_id);
16545 // Unintrospectable function: datalist_id_remove_no_notify() / g_datalist_id_remove_no_notify()
16546 // Removes an element, without calling its destroy notification
16547 // function.
16548 // <datalist>: a datalist.
16549 // <key_id>: the #GQuark identifying a data element.
16550 static void* datalist_id_remove_no_notify()(Data** datalist, Quark key_id) {
16551 return g_datalist_id_remove_no_notify(datalist, key_id);
16555 // Sets the data corresponding to the given #GQuark id, and the
16556 // function to be called when the element is removed from the datalist.
16557 // Any previous data with the same key is removed, and its destroy
16558 // function is called.
16559 // <datalist>: a datalist.
16560 // <key_id>: the #GQuark to identify the data element.
16561 // <data>: the data element or %NULL to remove any previous element corresponding to @key_id.
16562 // <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.
16563 static void datalist_id_set_data_full()(Data** datalist, Quark key_id, void* data, DestroyNotify destroy_func) {
16564 g_datalist_id_set_data_full(datalist, key_id, data, destroy_func);
16568 // Resets the datalist to %NULL. It does not free any memory or call
16569 // any destroy functions.
16570 // <datalist>: a pointer to a pointer to a datalist.
16571 static void datalist_init()(Data** datalist) {
16572 g_datalist_init(datalist);
16576 // VERSION: 2.8
16577 // Turns on flag values for a data list. This function is used
16578 // to keep a small number of boolean flags in an object with
16579 // a data list without using any additional space. It is
16580 // not generally useful except in circumstances where space
16581 // is very tight. (It is used in the base #GObject type, for
16582 // example.)
16583 // <datalist>: pointer to the location that holds a list
16584 // <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.
16585 static void datalist_set_flags()(Data** datalist, uint flags) {
16586 g_datalist_set_flags(datalist, flags);
16590 // VERSION: 2.8
16591 // Turns off flag values for a data list. See g_datalist_unset_flags()
16592 // <datalist>: pointer to the location that holds a list
16593 // <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.
16594 static void datalist_unset_flags()(Data** datalist, uint flags) {
16595 g_datalist_unset_flags(datalist, flags);
16599 // Destroys the dataset, freeing all memory allocated, and calling any
16600 // destroy functions set for data elements.
16601 // <dataset_location>: the location identifying the dataset.
16602 static void dataset_destroy()(const(void)* dataset_location) {
16603 g_dataset_destroy(dataset_location);
16607 // Unintrospectable function: dataset_foreach() / g_dataset_foreach()
16608 // Calls the given function for each data element which is associated
16609 // with the given location. Note that this function is NOT thread-safe.
16610 // So unless @datalist can be protected from any modifications during
16611 // invocation of this function, it should not be called.
16612 // <dataset_location>: the location identifying the dataset.
16613 // <func>: the function to call for each data element.
16614 // <user_data>: user data to pass to the function.
16615 static void dataset_foreach()(const(void)* dataset_location, DataForeachFunc func, void* user_data) {
16616 g_dataset_foreach(dataset_location, func, user_data);
16620 // Unintrospectable function: dataset_id_get_data() / g_dataset_id_get_data()
16621 // Gets the data element corresponding to a #GQuark.
16622 // <dataset_location>: the location identifying the dataset.
16623 // <key_id>: the #GQuark id to identify the data element.
16624 static void* dataset_id_get_data()(const(void)* dataset_location, Quark key_id) {
16625 return g_dataset_id_get_data(dataset_location, key_id);
16629 // Unintrospectable function: dataset_id_remove_no_notify() / g_dataset_id_remove_no_notify()
16630 // Removes an element, without calling its destroy notification
16631 // function.
16632 // <dataset_location>: the location identifying the dataset.
16633 // <key_id>: the #GQuark ID identifying the data element.
16634 static void* dataset_id_remove_no_notify()(const(void)* dataset_location, Quark key_id) {
16635 return g_dataset_id_remove_no_notify(dataset_location, key_id);
16639 // Sets the data element associated with the given #GQuark id, and also
16640 // the function to call when the data element is destroyed. Any
16641 // previous data with the same key is removed, and its destroy function
16642 // is called.
16643 // <dataset_location>: the location identifying the dataset.
16644 // <key_id>: the #GQuark id to identify the data element.
16645 // <data>: the data element.
16646 // <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.
16647 static void dataset_id_set_data_full()(const(void)* dataset_location, Quark key_id, void* data, DestroyNotify destroy_func) {
16648 g_dataset_id_set_data_full(dataset_location, key_id, data, destroy_func);
16651 // MOVED TO: Date.get_days_in_month
16652 static ubyte date_get_days_in_month()(DateMonth month, DateYear year) {
16653 return g_date_get_days_in_month(month, year);
16656 // MOVED TO: Date.get_monday_weeks_in_year
16657 static ubyte date_get_monday_weeks_in_year()(DateYear year) {
16658 return g_date_get_monday_weeks_in_year(year);
16661 // MOVED TO: Date.get_sunday_weeks_in_year
16662 static ubyte date_get_sunday_weeks_in_year()(DateYear year) {
16663 return g_date_get_sunday_weeks_in_year(year);
16666 // MOVED TO: Date.is_leap_year
16667 static int date_is_leap_year()(DateYear year) {
16668 return g_date_is_leap_year(year);
16671 // MOVED TO: Date.strftime
16672 static size_t date_strftime()(char* s, size_t slen, char* format, Date* date) {
16673 return g_date_strftime(s, slen, format, date);
16677 // VERSION: 2.26
16678 // MOVED TO: DateTime.compare
16679 // A comparison function for #GDateTimes that is suitable
16680 // as a #GCompareFunc. Both #GDateTimes must be non-%NULL.
16682 // than @dt2.
16683 // RETURNS: -1, 0 or 1 if @dt1 is less than, equal to or greater
16684 // <dt1>: first #GDateTime to compare
16685 // <dt2>: second #GDateTime to compare
16686 static int date_time_compare()(const(void)* dt1, const(void)* dt2) {
16687 return g_date_time_compare(dt1, dt2);
16691 // VERSION: 2.26
16692 // MOVED TO: DateTime.equal
16693 // Checks to see if @dt1 and @dt2 are equal.
16695 // Equal here means that they represent the same moment after converting
16696 // them to the same time zone.
16697 // RETURNS: %TRUE if @dt1 and @dt2 are equal
16698 // <dt1>: a #GDateTime
16699 // <dt2>: a #GDateTime
16700 static int date_time_equal()(const(void)* dt1, const(void)* dt2) {
16701 return g_date_time_equal(dt1, dt2);
16705 // VERSION: 2.26
16706 // MOVED TO: DateTime.hash
16707 // Hashes @datetime into a #guint, suitable for use within #GHashTable.
16708 // RETURNS: a #guint containing the hash
16709 // <datetime>: a #GDateTime
16710 static uint date_time_hash()(const(void)* datetime) {
16711 return g_date_time_hash(datetime);
16714 // MOVED TO: Date.valid_day
16715 static int date_valid_day()(DateDay day) {
16716 return g_date_valid_day(day);
16719 // MOVED TO: Date.valid_dmy
16720 static int date_valid_dmy()(DateDay day, DateMonth month, DateYear year) {
16721 return g_date_valid_dmy(day, month, year);
16724 // MOVED TO: Date.valid_julian
16725 static int date_valid_julian()(uint julian_date) {
16726 return g_date_valid_julian(julian_date);
16729 // MOVED TO: Date.valid_month
16730 static int date_valid_month()(DateMonth month) {
16731 return g_date_valid_month(month);
16734 // MOVED TO: Date.valid_weekday
16735 static int date_valid_weekday()(DateWeekday weekday) {
16736 return g_date_valid_weekday(weekday);
16739 // MOVED TO: Date.valid_year
16740 static int date_valid_year()(DateYear year) {
16741 return g_date_valid_year(year);
16745 // VERSION: 2.26
16746 // This is a variant of g_dgettext() that allows specifying a locale
16747 // category instead of always using %LC_MESSAGES. See g_dgettext() for
16748 // more information about how this functions differs from calling
16749 // dcgettext() directly.
16750 // RETURNS: the translated string for the given locale category
16751 // <domain>: the translation domain to use, or %NULL to use the domain set with textdomain()
16752 // <msgid>: message to translate
16753 // <category>: a locale category
16754 static char* dcgettext()(char* domain, char* msgid, int category) {
16755 return g_dcgettext(domain, msgid, category);
16759 // VERSION: 2.18
16760 // This function is a wrapper of dgettext() which does not translate
16761 // the message if the default domain as set with textdomain() has no
16762 // translations for the current locale.
16764 // The advantage of using this function over dgettext() proper is that
16765 // libraries using this function (like GTK+) will not use translations
16766 // if the application using the library does not have translations for
16767 // the current locale. This results in a consistent English-only
16768 // interface instead of one having partial translations. For this
16769 // feature to work, the call to textdomain() and setlocale() should
16770 // precede any g_dgettext() invocations. For GTK+, it means calling
16771 // textdomain() before gtk_init or its variants.
16773 // This function disables translations if and only if upon its first
16774 // call all the following conditions hold:
16775 // <itemizedlist>
16776 // <listitem>@domain is not %NULL</listitem>
16777 // <listitem>textdomain() has been called to set a default text domain</listitem>
16778 // <listitem>there is no translations available for the default text domain
16779 // and the current locale</listitem>
16780 // <listitem>current locale is not "C" or any English locales (those
16781 // starting with "en_")</listitem>
16782 // </itemizedlist>
16784 // Note that this behavior may not be desired for example if an application
16785 // has its untranslated messages in a language other than English. In those
16786 // cases the application should call textdomain() after initializing GTK+.
16788 // Applications should normally not use this function directly,
16789 // but use the _() macro for translations.
16790 // RETURNS: The translated string
16791 // <domain>: the translation domain to use, or %NULL to use the domain set with textdomain()
16792 // <msgid>: message to translate
16793 static char* dgettext()(char* domain, char* msgid) {
16794 return g_dgettext(domain, msgid);
16798 // VERSION: 2.30
16799 // MOVED TO: Dir.make_tmp
16800 // Creates a subdirectory in the preferred directory for temporary
16801 // files (as returned by g_get_tmp_dir()).
16803 // @tmpl should be a string in the GLib file name encoding containing
16804 // a sequence of six 'X' characters, as the parameter to g_mkstemp().
16805 // However, unlike these functions, the template should only be a
16806 // basename, no directory components are allowed. If template is
16807 // %NULL, a default template is used.
16809 // Note that in contrast to g_mkdtemp() (and mkdtemp()) @tmpl is not
16810 // modified, and might thus be a read-only literal string.
16812 // should be freed with g_free() when not needed any longer and is
16813 // is in the GLib file name encoding. In case of errors, %NULL is
16814 // returned and @error will be set.
16815 // RETURNS: The actual name used. This string
16816 // <tmpl>: Template for directory name, as in g_mkdtemp(), basename only, or %NULL for a default template
16817 static char* /*new*/ dir_make_tmp()(char* tmpl, GLib2.Error** error=null) {
16818 return g_dir_make_tmp(tmpl, error);
16822 // Compares two #gpointer arguments and returns %TRUE if they are equal.
16823 // It can be passed to g_hash_table_new() as the @key_equal_func
16824 // parameter, when using pointers as keys in a #GHashTable.
16825 // RETURNS: %TRUE if the two keys match.
16826 // <v1>: a key.
16827 // <v2>: a key to compare with @v1.
16828 static int direct_equal()(const(void)* v1, const(void)* v2) {
16829 return g_direct_equal(v1, v2);
16833 // Converts a gpointer to a hash value.
16834 // It can be passed to g_hash_table_new() as the @hash_func parameter,
16835 // when using pointers as keys in a #GHashTable.
16836 // RETURNS: a hash value corresponding to the key.
16837 // <v>: a #gpointer key
16838 static uint direct_hash()(const(void)* v) {
16839 return g_direct_hash(v);
16843 // VERSION: 2.18
16844 // This function is a wrapper of dngettext() which does not translate
16845 // the message if the default domain as set with textdomain() has no
16846 // translations for the current locale.
16848 // See g_dgettext() for details of how this differs from dngettext()
16849 // proper.
16850 // RETURNS: The translated string
16851 // <domain>: the translation domain to use, or %NULL to use the domain set with textdomain()
16852 // <msgid>: message to translate
16853 // <msgid_plural>: plural form of the message
16854 // <n>: the quantity for which translation is needed
16855 static char* dngettext()(char* domain, char* msgid, char* msgid_plural, c_ulong n) {
16856 return g_dngettext(domain, msgid, msgid_plural, n);
16860 // VERSION: 2.22
16861 // Compares the two #gdouble values being pointed to and returns
16862 // %TRUE if they are equal.
16863 // It can be passed to g_hash_table_new() as the @key_equal_func
16864 // parameter, when using pointers to doubles as keys in a #GHashTable.
16865 // RETURNS: %TRUE if the two keys match.
16866 // <v1>: a pointer to a #gdouble key.
16867 // <v2>: a pointer to a #gdouble key to compare with @v1.
16868 static int double_equal()(const(void)* v1, const(void)* v2) {
16869 return g_double_equal(v1, v2);
16873 // VERSION: 2.22
16874 // Converts a pointer to a #gdouble to a hash value.
16875 // It can be passed to g_hash_table_new() as the @hash_func parameter,
16876 // when using pointers to doubles as keys in a #GHashTable.
16877 // RETURNS: a hash value corresponding to the key.
16878 // <v>: a pointer to a #gdouble key
16879 static uint double_hash()(const(void)* v) {
16880 return g_double_hash(v);
16884 // VERSION: 2.16
16885 // This function is a variant of g_dgettext() which supports
16886 // a disambiguating message context. GNU gettext uses the
16887 // '\004' character to separate the message context and
16888 // message id in @msgctxtid.
16889 // If 0 is passed as @msgidoffset, this function will fall back to
16890 // trying to use the deprecated convention of using "|" as a separation
16891 // character.
16893 // This uses g_dgettext() internally. See that functions for differences
16894 // with dgettext() proper.
16896 // Applications should normally not use this function directly,
16897 // but use the C_() macro for translations with context.
16898 // RETURNS: The translated string
16899 // <domain>: the translation domain to use, or %NULL to use the domain set with textdomain()
16900 // <msgctxtid>: a combined message context and message id, separated by a \004 character
16901 // <msgidoffset>: the offset of the message id in @msgctxid
16902 static char* dpgettext()(char* domain, char* msgctxtid, size_t msgidoffset) {
16903 return g_dpgettext(domain, msgctxtid, msgidoffset);
16907 // VERSION: 2.18
16908 // This function is a variant of g_dgettext() which supports
16909 // a disambiguating message context. GNU gettext uses the
16910 // '\004' character to separate the message context and
16911 // message id in @msgctxtid.
16913 // This uses g_dgettext() internally. See that functions for differences
16914 // with dgettext() proper.
16916 // This function differs from C_() in that it is not a macro and
16917 // thus you may use non-string-literals as context and msgid arguments.
16918 // RETURNS: The translated string
16919 // <domain>: the translation domain to use, or %NULL to use the domain set with textdomain()
16920 // <context>: the message context
16921 // <msgid>: the message
16922 static char* dpgettext2()(char* domain, char* context, char* msgid) {
16923 return g_dpgettext2(domain, context, msgid);
16927 // function "dummy_decl" removed: Causes link failures - missing in library.
16930 // Gets a #GFileError constant based on the passed-in @errno.
16931 // For example, if you pass in %EEXIST this function returns
16932 // #G_FILE_ERROR_EXIST. Unlike @errno values, you can portably
16933 // assume that all #GFileError values will exist.
16935 // Normally a #GFileError value goes into a #GError returned
16936 // from a function that manipulates files. So you would use
16937 // g_file_error_from_errno() when constructing a #GError.
16938 // RETURNS: #GFileError corresponding to the given @errno
16939 // <err_no>: an "errno" value
16940 static FileError file_error_from_errno()(int err_no) {
16941 return g_file_error_from_errno(err_no);
16944 static Quark file_error_quark()() {
16945 return g_file_error_quark();
16949 // Reads an entire file into allocated memory, with good error
16950 // checking.
16952 // If the call was successful, it returns %TRUE and sets @contents to the file
16953 // contents and @length to the length of the file contents in bytes. The string
16954 // stored in @contents will be nul-terminated, so for text files you can pass
16955 // %NULL for the @length argument. If the call was not successful, it returns
16956 // %FALSE and sets @error. The error domain is #G_FILE_ERROR. Possible error
16957 // codes are those in the #GFileError enumeration. In the error case,
16958 // @contents is set to %NULL and @length is set to zero.
16959 // RETURNS: %TRUE on success, %FALSE if an error occurred
16960 // <filename>: name of a file to read contents from, in the GLib file name encoding
16961 // <contents>: location to store an allocated string, use g_free() to free the returned string
16962 // <length>: location to store length in bytes of the contents, or %NULL
16963 static int file_get_contents()(char* filename, /*out*/ ubyte** contents, /*out*/ size_t* length, GLib2.Error** error=null) {
16964 return g_file_get_contents(filename, contents, length, error);
16968 // Opens a file for writing in the preferred directory for temporary
16969 // files (as returned by g_get_tmp_dir()).
16971 // @tmpl should be a string in the GLib file name encoding containing
16972 // a sequence of six 'X' characters, as the parameter to g_mkstemp().
16973 // However, unlike these functions, the template should only be a
16974 // basename, no directory components are allowed. If template is
16975 // %NULL, a default template is used.
16977 // Note that in contrast to g_mkstemp() (and mkstemp()) @tmpl is not
16978 // modified, and might thus be a read-only literal string.
16980 // Upon success, and if @name_used is non-%NULL, the actual name used
16981 // is returned in @name_used. This string should be freed with g_free()
16982 // when not needed any longer. The returned name is in the GLib file
16983 // name encoding.
16985 // reading and writing. The file is opened in binary mode on platforms
16986 // where there is a difference. The file handle should be closed with
16987 // close(). In case of errors, -1 is returned and @error will be set.
16988 // RETURNS: A file handle (as from open()) to the file opened for
16989 // <tmpl>: Template for file name, as in g_mkstemp(), basename only, or %NULL for a default template
16990 // <name_used>: location to store actual name used, or %NULL
16991 static int file_open_tmp()(char* tmpl, /*out*/ char** name_used, GLib2.Error** error=null) {
16992 return g_file_open_tmp(tmpl, name_used, error);
16996 // VERSION: 2.4
16997 // Reads the contents of the symbolic link @filename like the POSIX
16998 // readlink() function. The returned string is in the encoding used
16999 // for filenames. Use g_filename_to_utf8() to convert it to UTF-8.
17001 // or %NULL if an error occurred.
17002 // RETURNS: A newly-allocated string with the contents of the symbolic link,
17003 // <filename>: the symbolic link
17004 static char* /*new*/ file_read_link()(char* filename, GLib2.Error** error=null) {
17005 return g_file_read_link(filename, error);
17009 // VERSION: 2.8
17010 // Writes all of @contents to a file named @filename, with good error checking.
17011 // If a file called @filename already exists it will be overwritten.
17013 // This write is atomic in the sense that it is first written to a temporary
17014 // file which is then renamed to the final name. Notes:
17015 // <itemizedlist>
17016 // <listitem>
17017 // On Unix, if @filename already exists hard links to @filename will break.
17018 // Also since the file is recreated, existing permissions, access control
17019 // lists, metadata etc. may be lost. If @filename is a symbolic link,
17020 // the link itself will be replaced, not the linked file.
17021 // </listitem>
17022 // <listitem>
17023 // On Windows renaming a file will not remove an existing file with the
17024 // new name, so on Windows there is a race condition between the existing
17025 // file being removed and the temporary file being renamed.
17026 // </listitem>
17027 // <listitem>
17028 // On Windows there is no way to remove a file that is open to some
17029 // process, or mapped into memory. Thus, this function will fail if
17030 // @filename already exists and is open.
17031 // </listitem>
17032 // </itemizedlist>
17034 // If the call was successful, it returns %TRUE. If the call was not successful,
17035 // it returns %FALSE and sets @error. The error domain is #G_FILE_ERROR.
17036 // Possible error codes are those in the #GFileError enumeration.
17038 // Note that the name for the temporary file is constructed by appending up
17039 // to 7 characters to @filename.
17040 // RETURNS: %TRUE on success, %FALSE if an error occurred
17041 // <filename>: name of a file to write @contents to, in the GLib file name encoding
17042 // <contents>: string to write to the file
17043 // <length>: length of @contents, or -1 if @contents is a nul-terminated string
17044 static int file_set_contents()(char* filename, ubyte* contents, ssize_t length, GLib2.Error** error=null) {
17045 return g_file_set_contents(filename, contents, length, error);
17049 // Returns %TRUE if any of the tests in the bitfield @test are
17050 // %TRUE. For example, <literal>(G_FILE_TEST_EXISTS |
17051 // G_FILE_TEST_IS_DIR)</literal> will return %TRUE if the file exists;
17052 // the check whether it's a directory doesn't matter since the existence
17053 // test is %TRUE. With the current set of available tests, there's no point
17054 // passing in more than one test at a time.
17056 // Apart from %G_FILE_TEST_IS_SYMLINK all tests follow symbolic links,
17057 // so for a symbolic link to a regular file g_file_test() will return
17058 // %TRUE for both %G_FILE_TEST_IS_SYMLINK and %G_FILE_TEST_IS_REGULAR.
17060 // Note, that for a dangling symbolic link g_file_test() will return
17061 // %TRUE for %G_FILE_TEST_IS_SYMLINK and %FALSE for all other flags.
17063 // You should never use g_file_test() to test whether it is safe
17064 // to perform an operation, because there is always the possibility
17065 // of the condition changing before you actually perform the operation.
17066 // For example, you might think you could use %G_FILE_TEST_IS_SYMLINK
17067 // to know whether it is safe to write to a file without being
17068 // tricked into writing into a different location. It doesn't work!
17069 // |[
17070 // /&ast; DON'T DO THIS &ast;/
17071 // if (!g_file_test (filename, G_FILE_TEST_IS_SYMLINK))
17072 // {
17073 // fd = g_open (filename, O_WRONLY);
17074 // /&ast; write to fd &ast;/
17075 // }
17076 // ]|
17078 // Another thing to note is that %G_FILE_TEST_EXISTS and
17079 // %G_FILE_TEST_IS_EXECUTABLE are implemented using the access()
17080 // system call. This usually doesn't matter, but if your program
17081 // is setuid or setgid it means that these tests will give you
17082 // the answer for the real user ID and group ID, rather than the
17083 // effective user ID and group ID.
17085 // On Windows, there are no symlinks, so testing for
17086 // %G_FILE_TEST_IS_SYMLINK will always return %FALSE. Testing for
17087 // %G_FILE_TEST_IS_EXECUTABLE will just check that the file exists and
17088 // its name indicates that it is executable, checking for well-known
17089 // extensions and those listed in the %PATHEXT environment variable.
17090 // RETURNS: whether a test was %TRUE
17091 // <filename>: a filename to test in the GLib file name encoding
17092 // <test>: bitfield of #GFileTest flags
17093 static int file_test()(char* filename, FileTest test) {
17094 return g_file_test(filename, test);
17098 // VERSION: 2.6
17099 // Returns the display basename for the particular filename, guaranteed
17100 // to be valid UTF-8. The display name might not be identical to the filename,
17101 // for instance there might be problems converting it to UTF-8, and some files
17102 // can be translated in the display.
17104 // If GLib cannot make sense of the encoding of @filename, as a last resort it
17105 // replaces unknown characters with U+FFFD, the Unicode replacement character.
17106 // You can search the result for the UTF-8 encoding of this character (which is
17107 // "\357\277\275" in octal notation) to find out if @filename was in an invalid
17108 // encoding.
17110 // You must pass the whole absolute pathname to this functions so that
17111 // translation of well known locations can be done.
17113 // This function is preferred over g_filename_display_name() if you know the
17114 // whole path, as it allows translation.
17116 // a rendition of the basename of the filename in valid UTF-8
17117 // RETURNS: a newly allocated string containing
17118 // <filename>: an absolute pathname in the GLib file name encoding
17119 static char* /*new*/ filename_display_basename()(char* filename) {
17120 return g_filename_display_basename(filename);
17124 // VERSION: 2.6
17125 // Converts a filename into a valid UTF-8 string. The conversion is
17126 // not necessarily reversible, so you should keep the original around
17127 // and use the return value of this function only for display purposes.
17128 // Unlike g_filename_to_utf8(), the result is guaranteed to be non-%NULL
17129 // even if the filename actually isn't in the GLib file name encoding.
17131 // If GLib cannot make sense of the encoding of @filename, as a last resort it
17132 // replaces unknown characters with U+FFFD, the Unicode replacement character.
17133 // You can search the result for the UTF-8 encoding of this character (which is
17134 // "\357\277\275" in octal notation) to find out if @filename was in an invalid
17135 // encoding.
17137 // If you know the whole pathname of the file you should use
17138 // g_filename_display_basename(), since that allows location-based
17139 // translation of filenames.
17141 // a rendition of the filename in valid UTF-8
17142 // RETURNS: a newly allocated string containing
17143 // <filename>: a pathname hopefully in the GLib file name encoding
17144 static char* /*new*/ filename_display_name()(char* filename) {
17145 return g_filename_display_name(filename);
17149 // Converts an escaped ASCII-encoded URI to a local filename in the
17150 // encoding used for filenames.
17152 // filename, or %NULL on an error.
17153 // RETURNS: a newly-allocated string holding the resulting
17154 // <uri>: a uri describing a filename (escaped, encoded in ASCII).
17155 // <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.
17156 static char* /*new*/ filename_from_uri()(char* uri, char** hostname, GLib2.Error** error=null) {
17157 return g_filename_from_uri(uri, hostname, error);
17161 // Converts a string from UTF-8 to the encoding GLib uses for
17162 // filenames. Note that on Windows GLib uses UTF-8 for filenames;
17163 // on other platforms, this function indirectly depends on the
17164 // <link linkend="setlocale">current locale</link>.
17165 // RETURNS: The converted string, or %NULL on an error.
17166 // <utf8string>: a UTF-8 encoded string.
17167 // <len>: the length of the string, or -1 if the string is nul-terminated.
17168 // <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.
17169 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
17170 static char* /*new*/ filename_from_utf8()(char* utf8string, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error=null) {
17171 return g_filename_from_utf8(utf8string, len, bytes_read, bytes_written, error);
17175 // Converts an absolute filename to an escaped ASCII-encoded URI, with the path
17176 // component following Section 3.3. of RFC 2396.
17178 // URI, or %NULL on an error.
17179 // RETURNS: a newly-allocated string holding the resulting
17180 // <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
17181 // <hostname>: A UTF-8 encoded hostname, or %NULL for none.
17182 static char* /*new*/ filename_to_uri()(char* filename, char* hostname, GLib2.Error** error=null) {
17183 return g_filename_to_uri(filename, hostname, error);
17187 // Converts a string which is in the encoding used by GLib for
17188 // filenames into a UTF-8 string. Note that on Windows GLib uses UTF-8
17189 // for filenames; on other platforms, this function indirectly depends on
17190 // the <link linkend="setlocale">current locale</link>.
17191 // RETURNS: The converted string, or %NULL on an error.
17192 // <opsysstring>: a string in the encoding for filenames
17193 // <len>: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
17194 // <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.
17195 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
17196 static char* /*new*/ filename_to_utf8()(char* opsysstring, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error=null) {
17197 return g_filename_to_utf8(opsysstring, len, bytes_read, bytes_written, error);
17201 // Locates the first executable named @program in the user's path, in the
17202 // same way that execvp() would locate it. Returns an allocated string
17203 // with the absolute path name, or %NULL if the program is not found in
17204 // the path. If @program is already an absolute path, returns a copy of
17205 // @program if @program exists and is executable, and %NULL otherwise.
17207 // On Windows, if @program does not have a file type suffix, tries
17208 // with the suffixes .exe, .cmd, .bat and .com, and the suffixes in
17209 // the <envar>PATHEXT</envar> environment variable.
17211 // On Windows, it looks for the file in the same way as CreateProcess()
17212 // would. This means first in the directory where the executing
17213 // program was loaded from, then in the current directory, then in the
17214 // Windows 32-bit system directory, then in the Windows directory, and
17215 // finally in the directories in the <envar>PATH</envar> environment
17216 // variable. If the program is found, the return value contains the
17217 // full name including the type suffix.
17218 // RETURNS: absolute path, or %NULL
17219 // <program>: a program name in the GLib file name encoding
17220 static char* /*new*/ find_program_in_path()(char* program) {
17221 return g_find_program_in_path(program);
17225 // VERSION: 2.30
17226 // Formats a size (for example the size of a file) into a human readable
17227 // string. Sizes are rounded to the nearest size prefix (kB, MB, GB)
17228 // and are displayed rounded to the nearest tenth. E.g. the file size
17229 // 3292528 bytes will be converted into the string "3.2 MB".
17231 // The prefix units base is 1000 (i.e. 1 kB is 1000 bytes).
17233 // This string should be freed with g_free() when not needed any longer.
17235 // See g_format_size_full() for more options about how the size might be
17236 // formatted.
17238 // file size.
17239 // RETURNS: a newly-allocated formatted string containing a human readable
17240 // <size>: a size in bytes
17241 static char* /*new*/ format_size()(ulong size) {
17242 return g_format_size(size);
17246 // VERSION: 2.16
17247 // Formats a size (for example the size of a file) into a human readable string.
17248 // Sizes are rounded to the nearest size prefix (KB, MB, GB) and are displayed
17249 // rounded to the nearest tenth. E.g. the file size 3292528 bytes will be
17250 // converted into the string "3.1 MB".
17252 // The prefix units base is 1024 (i.e. 1 KB is 1024 bytes).
17254 // This string should be freed with g_free() when not needed any longer.
17256 // file size.
17258 // Deprecated:2.30: This function is broken due to its use of SI
17259 // suffixes to denote IEC units. Use g_format_size()
17260 // instead.
17261 // RETURNS: a newly-allocated formatted string containing a human readable
17262 // <size>: a size in bytes.
17263 static char* /*new*/ format_size_for_display()(long size) {
17264 return g_format_size_for_display(size);
17268 // VERSION: 2.30
17269 // Formats a size.
17271 // This function is similar to g_format_size() but allows for flags that
17272 // modify the output. See #GFormatSizeFlags.
17274 // readable file size.
17275 // RETURNS: a newly-allocated formatted string containing a human
17276 // <size>: a size in bytes
17277 // <flags>: #GFormatSizeFlags to modify the output
17278 static char* /*new*/ format_size_full()(ulong size, FormatSizeFlags flags) {
17279 return g_format_size_full(size, flags);
17283 // Unintrospectable function: fprintf() / g_fprintf()
17284 // VERSION: 2.2
17285 // An implementation of the standard fprintf() function which supports
17286 // positional parameters, as specified in the Single Unix Specification.
17287 // RETURNS: the number of bytes printed.
17288 // <file>: the stream to write to.
17289 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
17290 alias g_fprintf fprintf; // Variadic
17293 // Frees the memory pointed to by @mem.
17294 // If @mem is %NULL it simply returns.
17295 // <mem>: the memory to free
17296 static void free()(void* mem) {
17297 g_free(mem);
17301 // VERSION: 2.2
17302 // Gets a human-readable name for the application, as set by
17303 // g_set_application_name(). This name should be localized if
17304 // possible, and is intended for display to the user. Contrast with
17305 // g_get_prgname(), which gets a non-localized name. If
17306 // g_set_application_name() has not been called, returns the result of
17307 // g_get_prgname() (which may be %NULL if g_set_prgname() has also not
17308 // been called).
17309 // RETURNS: human-readable application name. may return %NULL
17310 static char* get_application_name()() {
17311 return g_get_application_name();
17315 // Obtains the character set for the <link linkend="setlocale">current
17316 // locale</link>; you might use this character set as an argument to
17317 // g_convert(), to convert from the current locale's encoding to some
17318 // other encoding. (Frequently g_locale_to_utf8() and g_locale_from_utf8()
17319 // are nice shortcuts, though.)
17321 // On Windows the character set returned by this function is the
17322 // so-called system default ANSI code-page. That is the character set
17323 // used by the "narrow" versions of C library and Win32 functions that
17324 // handle file names. It might be different from the character set
17325 // used by the C library's current locale.
17327 // The return value is %TRUE if the locale's encoding is UTF-8, in that
17328 // case you can perhaps avoid calling g_convert().
17330 // The string returned in @charset is not allocated, and should not be
17331 // freed.
17332 // RETURNS: %TRUE if the returned charset is UTF-8
17333 // <charset>: return location for character set name
17334 static int get_charset()(char** charset) {
17335 return g_get_charset(charset);
17339 // Gets the current directory.
17340 // The returned string should be freed when no longer needed. The encoding
17341 // of the returned string is system defined. On Windows, it is always UTF-8.
17342 // RETURNS: the current directory.
17343 static char* /*new*/ get_current_dir()() {
17344 return g_get_current_dir();
17348 // Equivalent to the UNIX gettimeofday() function, but portable.
17350 // You may find g_get_real_time() to be more convenient.
17351 // <result>: #GTimeVal structure in which to store current time.
17352 static void get_current_time()(TimeVal* result) {
17353 g_get_current_time(result);
17357 // VERSION: 2.28
17358 // Gets the list of environment variables for the current process. The
17359 // list is %NULL terminated and each item in the list is of the form
17360 // 'NAME=VALUE'.
17362 // This is equivalent to direct access to the 'environ' global variable,
17363 // except portable.
17365 // The return value is freshly allocated and it should be freed with
17366 // g_strfreev() when it is no longer needed.
17367 // RETURNS: the list of environment variables
17368 static char** /*new*/ get_environ()() {
17369 return g_get_environ();
17373 // VERSION: 2.6
17374 // Determines the preferred character sets used for filenames.
17375 // The first character set from the @charsets is the filename encoding, the
17376 // subsequent character sets are used when trying to generate a displayable
17377 // representation of a filename, see g_filename_display_name().
17379 // On Unix, the character sets are determined by consulting the
17380 // environment variables <envar>G_FILENAME_ENCODING</envar> and
17381 // <envar>G_BROKEN_FILENAMES</envar>. On Windows, the character set
17382 // used in the GLib API is always UTF-8 and said environment variables
17383 // have no effect.
17385 // <envar>G_FILENAME_ENCODING</envar> may be set to a comma-separated list
17386 // of character set names. The special token "&commat;locale" is taken to
17387 // mean the character set for the <link linkend="setlocale">current
17388 // locale</link>. If <envar>G_FILENAME_ENCODING</envar> is not set, but
17389 // <envar>G_BROKEN_FILENAMES</envar> is, the character set of the current
17390 // locale is taken as the filename encoding. If neither environment variable
17391 // is set, UTF-8 is taken as the filename encoding, but the character
17392 // set of the current locale is also put in the list of encodings.
17394 // The returned @charsets belong to GLib and must not be freed.
17396 // Note that on Unix, regardless of the locale character set or
17397 // <envar>G_FILENAME_ENCODING</envar> value, the actual file names present
17398 // on a system might be in any random encoding or just gibberish.
17399 // RETURNS: %TRUE if the filename encoding is UTF-8.
17400 // <charsets>: return location for the %NULL-terminated list of encoding names
17401 static int get_filename_charsets()(char*** charsets) {
17402 return g_get_filename_charsets(charsets);
17406 // Gets the current user's home directory as defined in the
17407 // password database.
17409 // Note that in contrast to traditional UNIX tools, this function
17410 // prefers <filename>passwd</filename> entries over the <envar>HOME</envar>
17411 // environment variable.
17413 // One of the reasons for this decision is that applications in many
17414 // cases need special handling to deal with the case where
17415 // <envar>HOME</envar> is
17416 // <simplelist>
17417 // <member>Not owned by the user</member>
17418 // <member>Not writeable</member>
17419 // <member>Not even readable</member>
17420 // </simplelist>
17421 // Since applications are in general <emphasis>not</emphasis> written
17422 // to deal with these situations it was considered better to make
17423 // g_get_home_dir() not pay attention to <envar>HOME</envar> and to
17424 // return the real home directory for the user. If applications
17425 // want to pay attention to <envar>HOME</envar>, they can do:
17426 // |[
17427 // const char *homedir = g_getenv ("HOME");
17428 // if (!homedir)
17429 // homedir = g_get_home_dir (<!-- -->);
17430 // ]|
17431 // RETURNS: the current user's home directory
17432 static char* get_home_dir()() {
17433 return g_get_home_dir();
17437 // VERSION: 2.8
17438 // Return a name for the machine.
17440 // The returned name is not necessarily a fully-qualified domain name,
17441 // or even present in DNS or some other name service at all. It need
17442 // not even be unique on your local network or site, but usually it
17443 // is. Callers should not rely on the return value having any specific
17444 // properties like uniqueness for security purposes. Even if the name
17445 // of the machine is changed while an application is running, the
17446 // return value from this function does not change. The returned
17447 // string is owned by GLib and should not be modified or freed. If no
17448 // name can be determined, a default fixed string "localhost" is
17449 // returned.
17450 // RETURNS: the host name of the machine.
17451 static char* get_host_name()() {
17452 return g_get_host_name();
17456 // VERSION: 2.6
17457 // Computes a list of applicable locale names, which can be used to
17458 // e.g. construct locale-dependent filenames or search paths. The returned
17459 // list is sorted from most desirable to least desirable and always contains
17460 // the default locale "C".
17462 // For example, if LANGUAGE=de:en_US, then the returned list is
17463 // "de", "en_US", "en", "C".
17465 // This function consults the environment variables <envar>LANGUAGE</envar>,
17466 // <envar>LC_ALL</envar>, <envar>LC_MESSAGES</envar> and <envar>LANG</envar>
17467 // to find the list of locales specified by the user.
17469 // that must not be modified or freed.
17470 // RETURNS: a %NULL-terminated array of strings owned by GLib
17471 static char** get_language_names()() {
17472 return g_get_language_names();
17476 // VERSION: 2.28
17477 // Returns a list of derived variants of @locale, which can be used to
17478 // e.g. construct locale-dependent filenames or search paths. The returned
17479 // list is sorted from most desirable to least desirable.
17480 // This function handles territory, charset and extra locale modifiers.
17482 // For example, if @locale is "fr_BE", then the returned list
17483 // is "fr_BE", "fr".
17485 // If you need the list of variants for the <emphasis>current locale</emphasis>,
17486 // use g_get_language_names().
17488 // allocated array of newly allocated strings with the locale variants. Free with
17489 // g_strfreev().
17490 // RETURNS: a newly
17491 // <locale>: a locale identifier
17492 static char** /*new*/ get_locale_variants()(char* locale) {
17493 return g_get_locale_variants(locale);
17497 // VERSION: 2.28
17498 // Queries the system monotonic time, if available.
17500 // On POSIX systems with clock_gettime() and %CLOCK_MONOTONIC this call
17501 // is a very shallow wrapper for that. Otherwise, we make a best effort
17502 // that probably involves returning the wall clock time (with at least
17503 // microsecond accuracy, subject to the limitations of the OS kernel).
17505 // It's important to note that POSIX %CLOCK_MONOTONIC does not count
17506 // time spent while the machine is suspended.
17508 // On Windows, "limitations of the OS kernel" is a rather substantial
17509 // statement. Depending on the configuration of the system, the wall
17510 // clock time is updated as infrequently as 64 times a second (which
17511 // is approximately every 16ms).
17512 // RETURNS: the monotonic time, in microseconds
17513 static long get_monotonic_time()() {
17514 return g_get_monotonic_time();
17518 // Gets the name of the program. This name should <emphasis>not</emphasis>
17519 // be localized, contrast with g_get_application_name().
17520 // (If you are using GDK or GTK+ the program name is set in gdk_init(),
17521 // which is called by gtk_init(). The program name is found by taking
17522 // the last component of <literal>argv[0]</literal>.)
17524 // to GLib and must not be modified or freed.
17525 // RETURNS: the name of the program. The returned string belongs
17526 static char* /*new*/ get_prgname()() {
17527 return g_get_prgname();
17531 // Gets the real name of the user. This usually comes from the user's entry
17532 // in the <filename>passwd</filename> file. The encoding of the returned
17533 // string is system-defined. (On Windows, it is, however, always UTF-8.)
17534 // If the real user name cannot be determined, the string "Unknown" is
17535 // returned.
17536 // RETURNS: the user's real name.
17537 static char* get_real_name()() {
17538 return g_get_real_name();
17542 // VERSION: 2.28
17543 // Queries the system wall-clock time.
17545 // This call is functionally equivalent to g_get_current_time() except
17546 // that the return value is often more convenient than dealing with a
17547 // #GTimeVal.
17549 // You should only use this call if you are actually interested in the real
17550 // wall-clock time. g_get_monotonic_time() is probably more useful for
17551 // measuring intervals.
17552 // RETURNS: the number of microseconds since January 1, 1970 UTC.
17553 static long get_real_time()() {
17554 return g_get_real_time();
17558 // VERSION: 2.6
17559 // Returns an ordered list of base directories in which to access
17560 // system-wide configuration information.
17562 // On UNIX platforms this is determined using the mechanisms described in
17563 // the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
17564 // XDG Base Directory Specification</ulink>.
17565 // In this case the list of directories retrieved will be XDG_CONFIG_DIRS.
17567 // On Windows is the directory that contains application data for all users.
17568 // A typical path is C:\Documents and Settings\All Users\Application Data.
17569 // This folder is used for application data that is not user specific.
17570 // For example, an application can store a spell-check dictionary, a database
17571 // of clip art, or a log file in the CSIDL_COMMON_APPDATA folder.
17572 // This information will not roam and is available to anyone using the computer.
17574 // not be modified or freed.
17575 // RETURNS: a %NULL-terminated array of strings owned by GLib that must
17576 static char** get_system_config_dirs()() {
17577 return g_get_system_config_dirs();
17581 // VERSION: 2.6
17582 // Returns an ordered list of base directories in which to access
17583 // system-wide application data.
17585 // On UNIX platforms this is determined using the mechanisms described in
17586 // the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
17587 // XDG Base Directory Specification</ulink>
17588 // In this case the list of directories retrieved will be XDG_DATA_DIRS.
17590 // On Windows the first elements in the list are the Application Data
17591 // and Documents folders for All Users. (These can be determined only
17592 // on Windows 2000 or later and are not present in the list on other
17593 // Windows versions.) See documentation for CSIDL_COMMON_APPDATA and
17594 // CSIDL_COMMON_DOCUMENTS.
17596 // Then follows the "share" subfolder in the installation folder for
17597 // the package containing the DLL that calls this function, if it can
17598 // be determined.
17600 // Finally the list contains the "share" subfolder in the installation
17601 // folder for GLib, and in the installation folder for the package the
17602 // application's .exe file belongs to.
17604 // The installation folders above are determined by looking up the
17605 // folder where the module (DLL or EXE) in question is located. If the
17606 // folder's name is "bin", its parent is used, otherwise the folder
17607 // itself.
17609 // Note that on Windows the returned list can vary depending on where
17610 // this function is called.
17612 // not be modified or freed.
17613 // RETURNS: a %NULL-terminated array of strings owned by GLib that must
17614 static char** get_system_data_dirs()() {
17615 return g_get_system_data_dirs();
17619 // Gets the directory to use for temporary files. This is found from
17620 // inspecting the environment variables <envar>TMPDIR</envar>,
17621 // <envar>TMP</envar>, and <envar>TEMP</envar> in that order. If none
17622 // of those are defined "/tmp" is returned on UNIX and "C:\" on Windows.
17623 // The encoding of the returned string is system-defined. On Windows,
17624 // it is always UTF-8. The return value is never %NULL or the empty string.
17625 // RETURNS: the directory to use for temporary files.
17626 static char* get_tmp_dir()() {
17627 return g_get_tmp_dir();
17631 // VERSION: 2.6
17632 // Returns a base directory in which to store non-essential, cached
17633 // data specific to particular user.
17635 // On UNIX platforms this is determined using the mechanisms described in
17636 // the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
17637 // XDG Base Directory Specification</ulink>.
17638 // In this case the directory retrieved will be XDG_CACHE_HOME.
17640 // On Windows is the directory that serves as a common repository for
17641 // temporary Internet files. A typical path is
17642 // C:\Documents and Settings\username\Local Settings\Temporary Internet Files.
17643 // See documentation for CSIDL_INTERNET_CACHE.
17645 // or freed.
17646 // RETURNS: a string owned by GLib that must not be modified
17647 static char* get_user_cache_dir()() {
17648 return g_get_user_cache_dir();
17652 // VERSION: 2.6
17653 // Returns a base directory in which to store user-specific application
17654 // configuration information such as user preferences and settings.
17656 // On UNIX platforms this is determined using the mechanisms described in
17657 // the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
17658 // XDG Base Directory Specification</ulink>.
17659 // In this case the directory retrieved will be XDG_CONFIG_HOME.
17661 // On Windows this is the folder to use for local (as opposed to
17662 // roaming) application data. See documentation for
17663 // CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
17664 // what g_get_user_data_dir() returns.
17666 // or freed.
17667 // RETURNS: a string owned by GLib that must not be modified
17668 static char* get_user_config_dir()() {
17669 return g_get_user_config_dir();
17673 // VERSION: 2.6
17674 // Returns a base directory in which to access application data such
17675 // as icons that is customized for a particular user.
17677 // On UNIX platforms this is determined using the mechanisms described in
17678 // the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
17679 // XDG Base Directory Specification</ulink>.
17680 // In this case the directory retrieved will be XDG_DATA_HOME.
17682 // On Windows this is the folder to use for local (as opposed to
17683 // roaming) application data. See documentation for
17684 // CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
17685 // what g_get_user_config_dir() returns.
17687 // or freed.
17688 // RETURNS: a string owned by GLib that must not be modified
17689 static char* get_user_data_dir()() {
17690 return g_get_user_data_dir();
17694 // Gets the user name of the current user. The encoding of the returned
17695 // string is system-defined. On UNIX, it might be the preferred file name
17696 // encoding, or something else, and there is no guarantee that it is even
17697 // consistent on a machine. On Windows, it is always UTF-8.
17698 // RETURNS: the user name of the current user.
17699 static char* get_user_name()() {
17700 return g_get_user_name();
17704 // VERSION: 2.28
17705 // Returns a directory that is unique to the current user on the local
17706 // system.
17708 // On UNIX platforms this is determined using the mechanisms described in
17709 // the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
17710 // XDG Base Directory Specification</ulink>. This is the directory
17711 // specified in the <envar>XDG_RUNTIME_DIR</envar> environment variable.
17712 // In the case that this variable is not set, GLib will issue a warning
17713 // message to stderr and return the value of g_get_user_cache_dir().
17715 // On Windows this is the folder to use for local (as opposed to
17716 // roaming) application data. See documentation for
17717 // CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
17718 // what g_get_user_config_dir() returns.
17719 // RETURNS: a string owned by GLib that must not be modified or freed.
17720 static char* get_user_runtime_dir()() {
17721 return g_get_user_runtime_dir();
17725 // VERSION: 2.14
17726 // Returns the full path of a special directory using its logical id.
17728 // On Unix this is done using the XDG special user directories.
17729 // For compatibility with existing practise, %G_USER_DIRECTORY_DESKTOP
17730 // falls back to <filename>$HOME/Desktop</filename> when XDG special
17731 // user directories have not been set up.
17733 // Depending on the platform, the user might be able to change the path
17734 // of the special directory without requiring the session to restart; GLib
17735 // will not reflect any change once the special directories are loaded.
17737 // if the logical id was not found. The returned string is owned by
17738 // GLib and should not be modified or freed.
17739 // RETURNS: the path to the specified special directory, or %NULL
17740 // <directory>: the logical id of special directory
17741 static char* get_user_special_dir()(UserDirectory directory) {
17742 return g_get_user_special_dir(directory);
17746 // Returns the value of an environment variable. The name and value
17747 // are in the GLib file name encoding. On UNIX, this means the actual
17748 // bytes which might or might not be in some consistent character set
17749 // and encoding. On Windows, it is in UTF-8. On Windows, in case the
17750 // environment variable's value contains references to other
17751 // environment variables, they are expanded.
17753 // the environment variable is not found. The returned string may be
17754 // overwritten by the next call to g_getenv(), g_setenv() or
17755 // g_unsetenv().
17756 // RETURNS: the value of the environment variable, or %NULL if
17757 // <variable>: the environment variable to get, in the GLib file name encoding.
17758 static char* getenv()(char* variable) {
17759 return g_getenv(variable);
17763 // MOVED TO: HashTable.destroy
17764 // Destroys all keys and values in the #GHashTable and decrements its
17765 // reference count by 1. If keys and/or values are dynamically allocated,
17766 // you should either free them first or create the #GHashTable with destroy
17767 // notifiers using g_hash_table_new_full(). In the latter case the destroy
17768 // functions you supplied will be called on all keys and values during the
17769 // destruction phase.
17770 // <hash_table>: a #GHashTable.
17771 static void hash_table_destroy()(GLib2.HashTable* hash_table) {
17772 g_hash_table_destroy(hash_table);
17776 // MOVED TO: HashTable.insert
17777 // Inserts a new key and value into a #GHashTable.
17779 // If the key already exists in the #GHashTable its current value is replaced
17780 // with the new value. If you supplied a @value_destroy_func when creating the
17781 // #GHashTable, the old value is freed using that function. If you supplied
17782 // a @key_destroy_func when creating the #GHashTable, the passed key is freed
17783 // using that function.
17784 // <hash_table>: a #GHashTable.
17785 // <key>: a key to insert.
17786 // <value>: the value to associate with the key.
17787 static void hash_table_insert()(GLib2.HashTable* hash_table, void* key, void* value) {
17788 g_hash_table_insert(hash_table, key, value);
17792 // MOVED TO: HashTable.lookup_extended
17793 // Looks up a key in the #GHashTable, returning the original key and the
17794 // associated value and a #gboolean which is %TRUE if the key was found. This
17795 // is useful if you need to free the memory allocated for the original key,
17796 // for example before calling g_hash_table_remove().
17798 // You can actually pass %NULL for @lookup_key to test
17799 // whether the %NULL key exists, provided the hash and equal functions
17800 // of @hash_table are %NULL-safe.
17801 // RETURNS: %TRUE if the key was found in the #GHashTable.
17802 // <hash_table>: a #GHashTable
17803 // <lookup_key>: the key to look up
17804 // <orig_key>: return location for the original key, or %NULL
17805 // <value>: return location for the value associated with the key, or %NULL
17806 static int hash_table_lookup_extended()(GLib2.HashTable* hash_table, const(void)* lookup_key, void** orig_key, void** value) {
17807 return g_hash_table_lookup_extended(hash_table, lookup_key, orig_key, value);
17811 // MOVED TO: HashTable.remove
17812 // Removes a key and its associated value from a #GHashTable.
17814 // If the #GHashTable was created using g_hash_table_new_full(), the
17815 // key and value are freed using the supplied destroy functions, otherwise
17816 // you have to make sure that any dynamically allocated values are freed
17817 // yourself.
17818 // RETURNS: %TRUE if the key was found and removed from the #GHashTable.
17819 // <hash_table>: a #GHashTable.
17820 // <key>: the key to remove.
17821 static int hash_table_remove()(GLib2.HashTable* hash_table, const(void)* key) {
17822 return g_hash_table_remove(hash_table, key);
17826 // VERSION: 2.12
17827 // MOVED TO: HashTable.remove_all
17828 // Removes all keys and their associated values from a #GHashTable.
17830 // If the #GHashTable was created using g_hash_table_new_full(), the keys
17831 // and values are freed using the supplied destroy functions, otherwise you
17832 // have to make sure that any dynamically allocated values are freed
17833 // yourself.
17834 // <hash_table>: a #GHashTable
17835 static void hash_table_remove_all()(GLib2.HashTable* hash_table) {
17836 g_hash_table_remove_all(hash_table);
17840 // MOVED TO: HashTable.replace
17841 // Inserts a new key and value into a #GHashTable similar to
17842 // g_hash_table_insert(). The difference is that if the key already exists
17843 // in the #GHashTable, it gets replaced by the new key. If you supplied a
17844 // @value_destroy_func when creating the #GHashTable, the old value is freed
17845 // using that function. If you supplied a @key_destroy_func when creating the
17846 // #GHashTable, the old key is freed using that function.
17847 // <hash_table>: a #GHashTable.
17848 // <key>: a key to insert.
17849 // <value>: the value to associate with the key.
17850 static void hash_table_replace()(GLib2.HashTable* hash_table, void* key, void* value) {
17851 g_hash_table_replace(hash_table, key, value);
17855 // MOVED TO: HashTable.size
17856 // Returns the number of elements contained in the #GHashTable.
17857 // RETURNS: the number of key/value pairs in the #GHashTable.
17858 // <hash_table>: a #GHashTable.
17859 static uint hash_table_size()(GLib2.HashTable* hash_table) {
17860 return g_hash_table_size(hash_table);
17864 // MOVED TO: HashTable.steal
17865 // Removes a key and its associated value from a #GHashTable without
17866 // calling the key and value destroy functions.
17867 // RETURNS: %TRUE if the key was found and removed from the #GHashTable.
17868 // <hash_table>: a #GHashTable.
17869 // <key>: the key to remove.
17870 static int hash_table_steal()(GLib2.HashTable* hash_table, const(void)* key) {
17871 return g_hash_table_steal(hash_table, key);
17875 // VERSION: 2.12
17876 // MOVED TO: HashTable.steal_all
17877 // Removes all keys and their associated values from a #GHashTable
17878 // without calling the key and value destroy functions.
17879 // <hash_table>: a #GHashTable.
17880 static void hash_table_steal_all()(GLib2.HashTable* hash_table) {
17881 g_hash_table_steal_all(hash_table);
17885 // VERSION: 2.10
17886 // MOVED TO: HashTable.unref
17887 // Atomically decrements the reference count of @hash_table by one.
17888 // If the reference count drops to 0, all keys and values will be
17889 // destroyed, and all memory allocated by the hash table is released.
17890 // This function is MT-safe and may be called from any thread.
17891 // <hash_table>: a valid #GHashTable.
17892 static void hash_table_unref()(GLib2.HashTable* hash_table) {
17893 g_hash_table_unref(hash_table);
17896 // MOVED TO: Hook.destroy
17897 static int hook_destroy()(HookList* hook_list, c_ulong hook_id) {
17898 return g_hook_destroy(hook_list, hook_id);
17901 // MOVED TO: Hook.destroy_link
17902 static void hook_destroy_link()(HookList* hook_list, Hook* hook) {
17903 g_hook_destroy_link(hook_list, hook);
17906 // MOVED TO: Hook.free
17907 static void hook_free()(HookList* hook_list, Hook* hook) {
17908 g_hook_free(hook_list, hook);
17911 // MOVED TO: Hook.insert_before
17912 static void hook_insert_before()(HookList* hook_list, Hook* sibling, Hook* hook) {
17913 g_hook_insert_before(hook_list, sibling, hook);
17916 // MOVED TO: Hook.prepend
17917 static void hook_prepend()(HookList* hook_list, Hook* hook) {
17918 g_hook_prepend(hook_list, hook);
17921 // MOVED TO: Hook.unref
17922 static void hook_unref()(HookList* hook_list, Hook* hook) {
17923 g_hook_unref(hook_list, hook);
17927 // VERSION: 2.22
17928 // Tests if @hostname contains segments with an ASCII-compatible
17929 // encoding of an Internationalized Domain Name. If this returns
17930 // %TRUE, you should decode the hostname with g_hostname_to_unicode()
17931 // before displaying it to the user.
17933 // Note that a hostname might contain a mix of encoded and unencoded
17934 // segments, and so it is possible for g_hostname_is_non_ascii() and
17935 // g_hostname_is_ascii_encoded() to both return %TRUE for a name.
17937 // segments.
17938 // RETURNS: %TRUE if @hostname contains any ASCII-encoded
17939 // <hostname>: a hostname
17940 static int hostname_is_ascii_encoded()(char* hostname) {
17941 return g_hostname_is_ascii_encoded(hostname);
17945 // VERSION: 2.22
17946 // Tests if @hostname is the string form of an IPv4 or IPv6 address.
17947 // (Eg, "192.168.0.1".)
17948 // RETURNS: %TRUE if @hostname is an IP address
17949 // <hostname>: a hostname (or IP address in string form)
17950 static int hostname_is_ip_address()(char* hostname) {
17951 return g_hostname_is_ip_address(hostname);
17955 // VERSION: 2.22
17956 // Tests if @hostname contains Unicode characters. If this returns
17957 // %TRUE, you need to encode the hostname with g_hostname_to_ascii()
17958 // before using it in non-IDN-aware contexts.
17960 // Note that a hostname might contain a mix of encoded and unencoded
17961 // segments, and so it is possible for g_hostname_is_non_ascii() and
17962 // g_hostname_is_ascii_encoded() to both return %TRUE for a name.
17963 // RETURNS: %TRUE if @hostname contains any non-ASCII characters
17964 // <hostname>: a hostname
17965 static int hostname_is_non_ascii()(char* hostname) {
17966 return g_hostname_is_non_ascii(hostname);
17970 // VERSION: 2.22
17971 // Converts @hostname to its canonical ASCII form; an ASCII-only
17972 // string containing no uppercase letters and not ending with a
17973 // trailing dot.
17975 // @hostname is in some way invalid.
17976 // RETURNS: an ASCII hostname, which must be freed, or %NULL if
17977 // <hostname>: a valid UTF-8 or ASCII hostname
17978 static char* /*new*/ hostname_to_ascii()(char* hostname) {
17979 return g_hostname_to_ascii(hostname);
17983 // VERSION: 2.22
17984 // Converts @hostname to its canonical presentation form; a UTF-8
17985 // string in Unicode normalization form C, containing no uppercase
17986 // letters, no forbidden characters, and no ASCII-encoded segments,
17987 // and not ending with a trailing dot.
17989 // Of course if @hostname is not an internationalized hostname, then
17990 // the canonical presentation form will be entirely ASCII.
17992 // @hostname is in some way invalid.
17993 // RETURNS: a UTF-8 hostname, which must be freed, or %NULL if
17994 // <hostname>: a valid UTF-8 or ASCII hostname
17995 static char* /*new*/ hostname_to_unicode()(char* hostname) {
17996 return g_hostname_to_unicode(hostname);
18000 // Unintrospectable function: idle_add() / g_idle_add()
18001 // Adds a function to be called whenever there are no higher priority
18002 // events pending to the default main loop. The function is given the
18003 // default idle priority, #G_PRIORITY_DEFAULT_IDLE. If the function
18004 // returns %FALSE it is automatically removed from the list of event
18005 // sources and will not be called again.
18007 // This internally creates a main loop source using g_idle_source_new()
18008 // and attaches it to the main loop context using g_source_attach().
18009 // You can do these steps manually if you need greater control.
18010 // RETURNS: the ID (greater than 0) of the event source.
18011 // <function>: function to call
18012 // <data>: data to pass to @function.
18013 static uint idle_add()(SourceFunc function_, void* data) {
18014 return g_idle_add(function_, data);
18018 // Adds a function to be called whenever there are no higher priority
18019 // events pending. If the function returns %FALSE it is automatically
18020 // removed from the list of event sources and will not be called again.
18022 // This internally creates a main loop source using g_idle_source_new()
18023 // and attaches it to the main loop context using g_source_attach().
18024 // You can do these steps manually if you need greater control.
18025 // RETURNS: the ID (greater than 0) of the event source.
18026 // <priority>: the priority of the idle source. Typically this will be in the range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.
18027 // <function>: function to call
18028 // <data>: data to pass to @function
18029 // <notify>: function to call when the idle is removed, or %NULL
18030 static uint idle_add_full()(int priority, SourceFunc function_, void* data, DestroyNotify notify) {
18031 return g_idle_add_full(priority, function_, data, notify);
18035 // Removes the idle function with the given data.
18036 // RETURNS: %TRUE if an idle source was found and removed.
18037 // <data>: the data for the idle source's callback.
18038 static int idle_remove_by_data()(void* data) {
18039 return g_idle_remove_by_data(data);
18043 // Creates a new idle source.
18045 // The source will not initially be associated with any #GMainContext
18046 // and must be added to one with g_source_attach() before it will be
18047 // executed. Note that the default priority for idle sources is
18048 // %G_PRIORITY_DEFAULT_IDLE, as compared to other sources which
18049 // have a default priority of %G_PRIORITY_DEFAULT.
18050 // RETURNS: the newly-created idle source
18051 static Source* /*new*/ idle_source_new()() {
18052 return g_idle_source_new();
18056 // VERSION: 2.22
18057 // Compares the two #gint64 values being pointed to and returns
18058 // %TRUE if they are equal.
18059 // It can be passed to g_hash_table_new() as the @key_equal_func
18060 // parameter, when using pointers to 64-bit integers as keys in a #GHashTable.
18061 // RETURNS: %TRUE if the two keys match.
18062 // <v1>: a pointer to a #gint64 key.
18063 // <v2>: a pointer to a #gint64 key to compare with @v1.
18064 static int int64_equal()(const(void)* v1, const(void)* v2) {
18065 return g_int64_equal(v1, v2);
18069 // VERSION: 2.22
18070 // Converts a pointer to a #gint64 to a hash value.
18071 // It can be passed to g_hash_table_new() as the @hash_func parameter,
18072 // when using pointers to 64-bit integers values as keys in a #GHashTable.
18073 // RETURNS: a hash value corresponding to the key.
18074 // <v>: a pointer to a #gint64 key
18075 static uint int64_hash()(const(void)* v) {
18076 return g_int64_hash(v);
18080 // Compares the two #gint values being pointed to and returns
18081 // %TRUE if they are equal.
18082 // It can be passed to g_hash_table_new() as the @key_equal_func
18083 // parameter, when using pointers to integers as keys in a #GHashTable.
18084 // RETURNS: %TRUE if the two keys match.
18085 // <v1>: a pointer to a #gint key.
18086 // <v2>: a pointer to a #gint key to compare with @v1.
18087 static int int_equal()(const(void)* v1, const(void)* v2) {
18088 return g_int_equal(v1, v2);
18092 // Converts a pointer to a #gint to a hash value.
18093 // It can be passed to g_hash_table_new() as the @hash_func parameter,
18094 // when using pointers to integers values as keys in a #GHashTable.
18095 // RETURNS: a hash value corresponding to the key.
18096 // <v>: a pointer to a #gint key
18097 static uint int_hash()(const(void)* v) {
18098 return g_int_hash(v);
18102 // VERSION: 2.10
18103 // Returns a canonical representation for @string. Interned strings can
18104 // be compared for equality by comparing the pointers, instead of using strcmp().
18105 // g_intern_static_string() does not copy the string, therefore @string must
18106 // not be freed or modified.
18107 // RETURNS: a canonical representation for the string
18108 // <string>: a static string
18109 static char* intern_static_string()(char* string_=null) {
18110 return g_intern_static_string(string_);
18114 // VERSION: 2.10
18115 // Returns a canonical representation for @string. Interned strings can
18116 // be compared for equality by comparing the pointers, instead of using strcmp().
18117 // RETURNS: a canonical representation for the string
18118 // <string>: a string
18119 static char* intern_string()(char* string_=null) {
18120 return g_intern_string(string_);
18124 // Unintrospectable function: io_add_watch() / g_io_add_watch()
18125 // Adds the #GIOChannel into the default main loop context
18126 // with the default priority.
18127 // RETURNS: the event source id
18128 // <channel>: a #GIOChannel
18129 // <condition>: the condition to watch for
18130 // <func>: the function to call when the condition is satisfied
18131 // <user_data>: user data to pass to @func
18132 static uint io_add_watch()(IOChannel* channel, IOCondition condition, IOFunc func, void* user_data) {
18133 return g_io_add_watch(channel, condition, func, user_data);
18137 // Adds the #GIOChannel into the default main loop context
18138 // with the given priority.
18140 // This internally creates a main loop source using g_io_create_watch()
18141 // and attaches it to the main loop context with g_source_attach().
18142 // You can do these steps manually if you need greater control.
18143 // RETURNS: the event source id
18144 // <channel>: a #GIOChannel
18145 // <priority>: the priority of the #GIOChannel source
18146 // <condition>: the condition to watch for
18147 // <func>: the function to call when the condition is satisfied
18148 // <user_data>: user data to pass to @func
18149 // <notify>: the function to call when the source is removed
18150 static uint io_add_watch_full()(IOChannel* channel, int priority, IOCondition condition, IOFunc func, void* user_data, DestroyNotify notify) {
18151 return g_io_add_watch_full(channel, priority, condition, func, user_data, notify);
18155 // MOVED TO: IOChannel.error_from_errno
18156 // Converts an <literal>errno</literal> error number to a #GIOChannelError.
18158 // %G_IO_CHANNEL_ERROR_INVAL.
18159 // RETURNS: a #GIOChannelError error number, e.g.
18160 // <en>: an <literal>errno</literal> error number, e.g. %EINVAL
18161 static IOChannelError io_channel_error_from_errno()(int en) {
18162 return g_io_channel_error_from_errno(en);
18166 // MOVED TO: IOChannel.error_quark
18168 // RETURNS: the quark used as %G_IO_CHANNEL_ERROR
18169 static Quark io_channel_error_quark()() {
18170 return g_io_channel_error_quark();
18174 // Creates a #GSource that's dispatched when @condition is met for the
18175 // given @channel. For example, if condition is #G_IO_IN, the source will
18176 // be dispatched when there's data available for reading.
18178 // g_io_add_watch() is a simpler interface to this same functionality, for
18179 // the case where you want to add the source to the default main loop context
18180 // at the default priority.
18182 // On Windows, polling a #GSource created to watch a channel for a socket
18183 // puts the socket in non-blocking mode. This is a side-effect of the
18184 // implementation and unavoidable.
18185 // RETURNS: a new #GSource
18186 // <channel>: a #GIOChannel to watch
18187 // <condition>: conditions to watch for
18188 static Source* /*new*/ io_create_watch()(IOChannel* channel, IOCondition condition) {
18189 return g_io_create_watch(channel, condition);
18192 // MOVED TO: KeyFile.error_quark
18193 static Quark key_file_error_quark()() {
18194 return g_key_file_error_quark();
18198 // MOVED TO: List.pop_allocator
18199 // Restores the previous #GAllocator, used when allocating #GList
18200 // elements.
18202 // Note that this function is not available if GLib has been compiled
18203 // with <option>--disable-mem-pools</option>
18205 // Deprecated:2.10: It does nothing, since #GList has been converted
18206 // to the <link linkend="glib-Memory-Slices">slice
18207 // allocator</link>
18208 static void list_pop_allocator()() {
18209 g_list_pop_allocator();
18213 // MOVED TO: List.push_allocator
18214 // Sets the allocator to use to allocate #GList elements. Use
18215 // g_list_pop_allocator() to restore the previous allocator.
18217 // Note that this function is not available if GLib has been compiled
18218 // with <option>--disable-mem-pools</option>
18220 // Deprecated:2.10: It does nothing, since #GList has been converted
18221 // to the <link linkend="glib-Memory-Slices">slice
18222 // allocator</link>
18223 // <allocator>: the #GAllocator to use when allocating #GList elements.
18224 static void list_push_allocator()(void* allocator) {
18225 g_list_push_allocator(allocator);
18229 // VERSION: 2.8
18230 // Gets the names of all variables set in the environment.
18232 // with g_strfreev().
18234 // Programs that want to be portable to Windows should typically use
18235 // this function and g_getenv() instead of using the environ array
18236 // from the C library directly. On Windows, the strings in the environ
18237 // array are in system codepage encoding, while in most of the typical
18238 // use cases for environment variables in GLib-using programs you want
18239 // the UTF-8 encoding that this function and g_getenv() provide.
18240 // RETURNS: a %NULL-terminated list of strings which must be freed
18241 static char** /*new*/ listenv()() {
18242 return g_listenv();
18246 // Converts a string from UTF-8 to the encoding used for strings by
18247 // the C runtime (usually the same as that used by the operating
18248 // system) in the <link linkend="setlocale">current locale</link>. On
18249 // Windows this means the system codepage.
18250 // RETURNS: The converted string, or %NULL on an error.
18251 // <utf8string>: a UTF-8 encoded string
18252 // <len>: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
18253 // <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.
18254 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
18255 static char* /*new*/ locale_from_utf8()(char* utf8string, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error=null) {
18256 return g_locale_from_utf8(utf8string, len, bytes_read, bytes_written, error);
18260 // Converts a string which is in the encoding used for strings by
18261 // the C runtime (usually the same as that used by the operating
18262 // system) in the <link linkend="setlocale">current locale</link> into a
18263 // UTF-8 string.
18264 // RETURNS: The converted string, or %NULL on an error.
18265 // <opsysstring>: a string in the encoding of the current locale. On Windows this means the system codepage.
18266 // <len>: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
18267 // <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.
18268 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
18269 static char* /*new*/ locale_to_utf8()(char* opsysstring, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error=null) {
18270 return g_locale_to_utf8(opsysstring, len, bytes_read, bytes_written, error);
18273 // Unintrospectable function: log() / g_log()
18274 alias g_log log; // Variadic
18276 static void log_default_handler()(char* log_domain, LogLevelFlags log_level, char* message, void* unused_data) {
18277 g_log_default_handler(log_domain, log_level, message, unused_data);
18280 static void log_remove_handler()(char* log_domain, uint handler_id) {
18281 g_log_remove_handler(log_domain, handler_id);
18284 static LogLevelFlags log_set_always_fatal()(LogLevelFlags fatal_mask) {
18285 return g_log_set_always_fatal(fatal_mask);
18288 // Unintrospectable function: log_set_default_handler() / g_log_set_default_handler()
18289 static LogFunc log_set_default_handler()(LogFunc log_func, void* user_data) {
18290 return g_log_set_default_handler(log_func, user_data);
18293 static LogLevelFlags log_set_fatal_mask()(char* log_domain, LogLevelFlags fatal_mask) {
18294 return g_log_set_fatal_mask(log_domain, fatal_mask);
18297 // Unintrospectable function: log_set_handler() / g_log_set_handler()
18298 static uint log_set_handler()(char* log_domain, LogLevelFlags log_levels, LogFunc log_func, void* user_data) {
18299 return g_log_set_handler(log_domain, log_levels, log_func, user_data);
18302 // Unintrospectable function: logv() / g_logv()
18303 static void logv()(char* log_domain, LogLevelFlags log_level, char* format, va_list args) {
18304 g_logv(log_domain, log_level, format, args);
18308 // MOVED TO: MainContext.default
18309 // Returns the global default main context. This is the main context
18310 // used for main loop functions when a main loop is not explicitly
18311 // specified, and corresponds to the "main" main loop. See also
18312 // g_main_context_get_thread_default().
18313 // RETURNS: the global default main context.
18314 static MainContext* main_context_default()() {
18315 return g_main_context_default();
18319 // VERSION: 2.22
18320 // MOVED TO: MainContext.get_thread_default
18321 // Gets the thread-default #GMainContext for this thread. Asynchronous
18322 // operations that want to be able to be run in contexts other than
18323 // the default one should call this method to get a #GMainContext to
18324 // add their #GSource<!-- -->s to. (Note that even in single-threaded
18325 // programs applications may sometimes want to temporarily push a
18326 // non-default context, so it is not safe to assume that this will
18327 // always return %NULL if threads are not initialized.)
18329 // %NULL if the thread-default context is the global default context.
18330 // RETURNS: the thread-default #GMainContext, or
18331 static MainContext* main_context_get_thread_default()() {
18332 return g_main_context_get_thread_default();
18336 // VERSION: 2.12
18337 // Returns the currently firing source for this thread.
18338 // RETURNS: The currently firing source or %NULL.
18339 static Source* main_current_source()() {
18340 return g_main_current_source();
18344 // Returns the depth of the stack of calls to
18345 // g_main_context_dispatch() on any #GMainContext in the current thread.
18346 // That is, when called from the toplevel, it gives 0. When
18347 // called from within a callback from g_main_context_iteration()
18348 // (or g_main_loop_run(), etc.) it returns 1. When called from within
18349 // a callback to a recursive call to g_main_context_iteration(),
18350 // it returns 2. And so forth.
18352 // This function is useful in a situation like the following:
18353 // Imagine an extremely simple "garbage collected" system.
18355 // |[
18356 // static GList *free_list;
18358 // gpointer
18359 // allocate_memory (gsize size)
18360 // {
18361 // gpointer result = g_malloc (size);
18362 // free_list = g_list_prepend (free_list, result);
18363 // return result;
18364 // }
18366 // void
18367 // free_allocated_memory (void)
18368 // {
18369 // GList *l;
18370 // for (l = free_list; l; l = l->next);
18371 // g_free (l->data);
18372 // g_list_free (free_list);
18373 // free_list = NULL;
18374 // }
18376 // [...]
18378 // while (TRUE);
18379 // {
18380 // g_main_context_iteration (NULL, TRUE);
18381 // free_allocated_memory();
18382 // }
18383 // ]|
18385 // This works from an application, however, if you want to do the same
18386 // thing from a library, it gets more difficult, since you no longer
18387 // control the main loop. You might think you can simply use an idle
18388 // function to make the call to free_allocated_memory(), but that
18389 // doesn't work, since the idle function could be called from a
18390 // recursive callback. This can be fixed by using g_main_depth()
18392 // |[
18393 // gpointer
18394 // allocate_memory (gsize size)
18395 // {
18396 // FreeListBlock *block = g_new (FreeListBlock, 1);
18397 // block->mem = g_malloc (size);
18398 // block->depth = g_main_depth ();
18399 // free_list = g_list_prepend (free_list, block);
18400 // return block->mem;
18401 // }
18403 // void
18404 // free_allocated_memory (void)
18405 // {
18406 // GList *l;
18408 // int depth = g_main_depth ();
18409 // for (l = free_list; l; );
18410 // {
18411 // GList *next = l->next;
18412 // FreeListBlock *block = l->data;
18413 // if (block->depth > depth)
18414 // {
18415 // g_free (block->mem);
18416 // g_free (block);
18417 // free_list = g_list_delete_link (free_list, l);
18418 // }
18420 // l = next;
18421 // }
18422 // }
18423 // ]|
18425 // There is a temptation to use g_main_depth() to solve
18426 // problems with reentrancy. For instance, while waiting for data
18427 // to be received from the network in response to a menu item,
18428 // the menu item might be selected again. It might seem that
18429 // one could make the menu item's callback return immediately
18430 // and do nothing if g_main_depth() returns a value greater than 1.
18431 // However, this should be avoided since the user then sees selecting
18432 // the menu item do nothing. Furthermore, you'll find yourself adding
18433 // these checks all over your code, since there are doubtless many,
18434 // many things that the user could do. Instead, you can use the
18435 // following techniques:
18437 // <orderedlist>
18438 // <listitem>
18439 // <para>
18440 // Use gtk_widget_set_sensitive() or modal dialogs to prevent
18441 // the user from interacting with elements while the main
18442 // loop is recursing.
18443 // </para>
18444 // </listitem>
18445 // <listitem>
18446 // <para>
18447 // Avoid main loop recursion in situations where you can't handle
18448 // arbitrary callbacks. Instead, structure your code so that you
18449 // simply return to the main loop and then get called again when
18450 // there is more work to do.
18451 // </para>
18452 // </listitem>
18453 // </orderedlist>
18454 // RETURNS: The main loop recursion level in the current thread
18455 static int main_depth()() {
18456 return g_main_depth();
18460 // Unintrospectable function: malloc() / g_malloc()
18461 // Allocates @n_bytes bytes of memory.
18462 // If @n_bytes is 0 it returns %NULL.
18463 // RETURNS: a pointer to the allocated memory
18464 // <n_bytes>: the number of bytes to allocate
18465 static void* malloc()(size_t n_bytes) {
18466 return g_malloc(n_bytes);
18470 // Unintrospectable function: malloc0() / g_malloc0()
18471 // Allocates @n_bytes bytes of memory, initialized to 0's.
18472 // If @n_bytes is 0 it returns %NULL.
18473 // RETURNS: a pointer to the allocated memory
18474 // <n_bytes>: the number of bytes to allocate
18475 static void* malloc0()(size_t n_bytes) {
18476 return g_malloc0(n_bytes);
18480 // Unintrospectable function: malloc0_n() / g_malloc0_n()
18481 // VERSION: 2.24
18482 // This function is similar to g_malloc0(), allocating (@n_blocks * @n_block_bytes) bytes,
18483 // but care is taken to detect possible overflow during multiplication.
18484 // RETURNS: a pointer to the allocated memory
18485 // <n_blocks>: the number of blocks to allocate
18486 // <n_block_bytes>: the size of each block in bytes
18487 static void* malloc0_n()(size_t n_blocks, size_t n_block_bytes) {
18488 return g_malloc0_n(n_blocks, n_block_bytes);
18492 // Unintrospectable function: malloc_n() / g_malloc_n()
18493 // VERSION: 2.24
18494 // This function is similar to g_malloc(), allocating (@n_blocks * @n_block_bytes) bytes,
18495 // but care is taken to detect possible overflow during multiplication.
18496 // RETURNS: a pointer to the allocated memory
18497 // <n_blocks>: the number of blocks to allocate
18498 // <n_block_bytes>: the size of each block in bytes
18499 static void* malloc_n()(size_t n_blocks, size_t n_block_bytes) {
18500 return g_malloc_n(n_blocks, n_block_bytes);
18504 // Unintrospectable function: markup_collect_attributes() / g_markup_collect_attributes()
18505 // VERSION: 2.16
18506 // Collects the attributes of the element from the data passed to the
18507 // #GMarkupParser start_element function, dealing with common error
18508 // conditions and supporting boolean values.
18510 // This utility function is not required to write a parser but can save
18511 // a lot of typing.
18513 // The @element_name, @attribute_names, @attribute_values and @error
18514 // parameters passed to the start_element callback should be passed
18515 // unmodified to this function.
18517 // Following these arguments is a list of "supported" attributes to collect.
18518 // It is an error to specify multiple attributes with the same name. If any
18519 // attribute not in the list appears in the @attribute_names array then an
18520 // unknown attribute error will result.
18522 // The #GMarkupCollectType field allows specifying the type of collection
18523 // to perform and if a given attribute must appear or is optional.
18525 // The attribute name is simply the name of the attribute to collect.
18527 // The pointer should be of the appropriate type (see the descriptions
18528 // under #GMarkupCollectType) and may be %NULL in case a particular
18529 // attribute is to be allowed but ignored.
18531 // This function deals with issuing errors for missing attributes
18532 // (of type %G_MARKUP_ERROR_MISSING_ATTRIBUTE), unknown attributes
18533 // (of type %G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE) and duplicate
18534 // attributes (of type %G_MARKUP_ERROR_INVALID_CONTENT) as well
18535 // as parse errors for boolean-valued attributes (again of type
18536 // %G_MARKUP_ERROR_INVALID_CONTENT). In all of these cases %FALSE
18537 // will be returned and @error will be set as appropriate.
18538 // RETURNS: %TRUE if successful
18539 // <element_name>: the current tag name
18540 // <attribute_names>: the attribute names
18541 // <attribute_values>: the attribute values
18542 // <error>: a pointer to a #GError or %NULL
18543 // <first_type>: the #GMarkupCollectType of the first attribute
18544 // <first_attr>: the name of the first attribute
18545 alias g_markup_collect_attributes markup_collect_attributes; // Variadic
18547 static Quark markup_error_quark()() {
18548 return g_markup_error_quark();
18552 // Escapes text so that the markup parser will parse it verbatim.
18553 // Less than, greater than, ampersand, etc. are replaced with the
18554 // corresponding entities. This function would typically be used
18555 // when writing out a file to be parsed with the markup parser.
18557 // Note that this function doesn't protect whitespace and line endings
18558 // from being processed according to the XML rules for normalization
18559 // of line endings and attribute values.
18561 // Note also that this function will produce character references in
18562 // the range of &amp;#x1; ... &amp;#x1f; for all control sequences
18563 // except for tabstop, newline and carriage return. The character
18564 // references in this range are not valid XML 1.0, but they are
18565 // valid XML 1.1 and will be accepted by the GMarkup parser.
18566 // RETURNS: a newly allocated string with the escaped text
18567 // <text>: some valid UTF-8 text
18568 // <length>: length of @text in bytes, or -1 if the text is nul-terminated
18569 static char* /*new*/ markup_escape_text()(char* text, ssize_t length) {
18570 return g_markup_escape_text(text, length);
18574 // Unintrospectable function: markup_printf_escaped() / g_markup_printf_escaped()
18575 // VERSION: 2.4
18576 // Formats arguments according to @format, escaping
18577 // all string and character arguments in the fashion
18578 // of g_markup_escape_text(). This is useful when you
18579 // want to insert literal strings into XML-style markup
18580 // output, without having to worry that the strings
18581 // might themselves contain markup.
18583 // |[
18584 // const char *store = "Fortnum &amp; Mason";
18585 // const char *item = "Tea";
18586 // char *output;
18587 // &nbsp;
18588 // output = g_markup_printf_escaped ("&lt;purchase&gt;"
18589 // "&lt;store&gt;&percnt;s&lt;/store&gt;"
18590 // "&lt;item&gt;&percnt;s&lt;/item&gt;"
18591 // "&lt;/purchase&gt;",
18592 // store, item);
18593 // ]|
18595 // operation. Free with g_free().
18596 // RETURNS: newly allocated result from formatting
18597 // <format>: printf() style format string
18598 alias g_markup_printf_escaped markup_printf_escaped; // Variadic
18601 // Unintrospectable function: markup_vprintf_escaped() / g_markup_vprintf_escaped()
18602 // VERSION: 2.4
18603 // Formats the data in @args according to @format, escaping
18604 // all string and character arguments in the fashion
18605 // of g_markup_escape_text(). See g_markup_printf_escaped().
18607 // operation. Free with g_free().
18608 // RETURNS: newly allocated result from formatting
18609 // <format>: printf() style format string
18610 // <args>: variable argument list, similar to vprintf()
18611 static char* /*new*/ markup_vprintf_escaped()(char* format, va_list args) {
18612 return g_markup_vprintf_escaped(format, args);
18616 // MOVED TO: MemChunk.info
18617 // Outputs debugging information for all #GMemChunk objects currently
18618 // in use. It outputs the number of #GMemChunk objects currently
18619 // allocated, and calls g_mem_chunk_print() to output information on
18620 // each one.
18622 // Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
18623 // allocator</link> instead
18624 static void mem_chunk_info()() {
18625 g_mem_chunk_info();
18629 // Checks whether the allocator used by g_malloc() is the system's
18630 // malloc implementation. If it returns %TRUE memory allocated with
18631 // malloc() can be used interchangeable with memory allocated using g_malloc().
18632 // This function is useful for avoiding an extra copy of allocated memory returned
18633 // by a non-GLib-based API.
18635 // A different allocator can be set using g_mem_set_vtable().
18636 // RETURNS: if %TRUE, malloc() and g_malloc() can be mixed.
18637 static int mem_is_system_malloc()() {
18638 return g_mem_is_system_malloc();
18642 // Outputs a summary of memory usage.
18644 // It outputs the frequency of allocations of different sizes,
18645 // the total number of bytes which have been allocated,
18646 // the total number of bytes which have been freed,
18647 // and the difference between the previous two values, i.e. the number of bytes
18648 // still in use.
18650 // Note that this function will not output anything unless you have
18651 // previously installed the #glib_mem_profiler_table with g_mem_set_vtable().
18652 static void mem_profile()() {
18653 g_mem_profile();
18657 // Sets the #GMemVTable to use for memory allocation. You can use this to provide
18658 // custom memory allocation routines. <emphasis>This function must be called
18659 // before using any other GLib functions.</emphasis> The @vtable only needs to
18660 // provide malloc(), realloc(), and free() functions; GLib can provide default
18661 // implementations of the others. The malloc() and realloc() implementations
18662 // should return %NULL on failure, GLib will handle error-checking for you.
18663 // @vtable is copied, so need not persist after this function has been called.
18664 // <vtable>: table of memory allocation routines.
18665 static void mem_set_vtable()(MemVTable* vtable) {
18666 g_mem_set_vtable(vtable);
18670 // Unintrospectable function: memdup() / g_memdup()
18671 // Allocates @byte_size bytes of memory, and copies @byte_size bytes into it
18672 // from @mem. If @mem is %NULL it returns %NULL.
18674 // is %NULL.
18675 // RETURNS: a pointer to the newly-allocated copy of the memory, or %NULL if @mem
18676 // <mem>: the memory to copy.
18677 // <byte_size>: the number of bytes to copy.
18678 static void* memdup()(const(void)* mem, uint byte_size) {
18679 return g_memdup(mem, byte_size);
18683 // VERSION: 2.8
18684 // Create a directory if it doesn't already exist. Create intermediate
18685 // parent directories as needed, too.
18687 // created. Returns -1 if an error occurred, with errno set.
18688 // RETURNS: 0 if the directory already exists, or was successfully
18689 // <pathname>: a pathname in the GLib file name encoding
18690 // <mode>: permissions to use for newly created directories
18691 static int mkdir_with_parents()(char* pathname, int mode) {
18692 return g_mkdir_with_parents(pathname, mode);
18696 // VERSION: 2.26
18697 // Creates a temporary directory. See the mkdtemp() documentation
18698 // on most UNIX-like systems.
18700 // The parameter is a string that should follow the rules for
18701 // mkdtemp() templates, i.e. contain the string "XXXXXX".
18702 // g_mkdtemp() is slightly more flexible than mkdtemp() in that the
18703 // sequence does not have to occur at the very end of the template
18704 // and you can pass a @mode and additional @flags. The X string will
18705 // be modified to form the name of a directory that didn't exist.
18706 // The string should be in the GLib file name encoding. Most importantly,
18707 // on Windows it should be in UTF-8.
18709 // to hold the directory name. In case of errors, %NULL is
18710 // returned and %errno will be set.
18711 // RETURNS: A pointer to @tmpl, which has been modified
18712 // <tmpl>: template directory name
18713 static char* /*new*/ mkdtemp()(char* tmpl) {
18714 return g_mkdtemp(tmpl);
18718 // VERSION: 2.26
18719 // Creates a temporary directory. See the mkdtemp() documentation
18720 // on most UNIX-like systems.
18722 // The parameter is a string that should follow the rules for
18723 // mkdtemp() templates, i.e. contain the string "XXXXXX".
18724 // g_mkdtemp() is slightly more flexible than mkdtemp() in that the
18725 // sequence does not have to occur at the very end of the template
18726 // and you can pass a @mode. The X string will be modified to form
18727 // the name of a directory that didn't exist. The string should be
18728 // in the GLib file name encoding. Most importantly, on Windows it
18729 // should be in UTF-8.
18731 // to hold the directory name. In case of errors, %NULL is
18732 // returned, and %errno will be set.
18733 // RETURNS: A pointer to @tmpl, which has been modified
18734 // <tmpl>: template directory name
18735 // <mode>: permissions to create the temporary directory with
18736 static char* /*new*/ mkdtemp_full()(char* tmpl, int mode) {
18737 return g_mkdtemp_full(tmpl, mode);
18741 // Opens a temporary file. See the mkstemp() documentation
18742 // on most UNIX-like systems.
18744 // The parameter is a string that should follow the rules for
18745 // mkstemp() templates, i.e. contain the string "XXXXXX".
18746 // g_mkstemp() is slightly more flexible than mkstemp() in that the
18747 // sequence does not have to occur at the very end of the template.
18748 // The X string will be modified to form the name of a file that
18749 // didn't exist. The string should be in the GLib file name encoding.
18750 // Most importantly, on Windows it should be in UTF-8.
18752 // opened for reading and writing. The file is opened in binary
18753 // mode on platforms where there is a difference. The file handle
18754 // should be closed with close(). In case of errors, -1 is
18755 // returned and %errno will be set.
18756 // RETURNS: A file handle (as from open()) to the file
18757 // <tmpl>: template filename
18758 static int mkstemp()(char* tmpl) {
18759 return g_mkstemp(tmpl);
18763 // VERSION: 2.22
18764 // Opens a temporary file. See the mkstemp() documentation
18765 // on most UNIX-like systems.
18767 // The parameter is a string that should follow the rules for
18768 // mkstemp() templates, i.e. contain the string "XXXXXX".
18769 // g_mkstemp_full() is slightly more flexible than mkstemp()
18770 // in that the sequence does not have to occur at the very end of the
18771 // template and you can pass a @mode and additional @flags. The X
18772 // string will be modified to form the name of a file that didn't exist.
18773 // The string should be in the GLib file name encoding. Most importantly,
18774 // on Windows it should be in UTF-8.
18776 // opened for reading and writing. The file handle should be
18777 // closed with close(). In case of errors, -1 is returned
18778 // and %errno will be set.
18779 // RETURNS: A file handle (as from open()) to the file
18780 // <tmpl>: template filename
18781 // <flags>: flags to pass to an open() call in addition to O_EXCL and O_CREAT, which are passed automatically
18782 // <mode>: permissions to create the temporary file with
18783 static int mkstemp_full()(char* tmpl, int flags, int mode) {
18784 return g_mkstemp_full(tmpl, flags, mode);
18788 // MOVED TO: Node.pop_allocator
18789 // Restores the previous #GAllocator, used when allocating #GNode
18790 // elements.
18792 // Note that this function is not available if GLib has been compiled
18793 // with <option>--disable-mem-pools</option>
18795 // Deprecated:2.10: It does nothing, since #GNode has been converted to
18796 // the <link linkend="glib-Memory-Slices">slice
18797 // allocator</link>
18798 static void node_pop_allocator()() {
18799 g_node_pop_allocator();
18803 // MOVED TO: Node.push_allocator
18804 // Sets the allocator to use to allocate #GNode elements. Use
18805 // g_node_pop_allocator() to restore the previous allocator.
18807 // Note that this function is not available if GLib has been compiled
18808 // with <option>--disable-mem-pools</option>
18810 // Deprecated:2.10: It does nothing, since #GNode has been converted to
18811 // the <link linkend="glib-Memory-Slices">slice
18812 // allocator</link>
18813 // <dummy>: the #GAllocator to use when allocating #GNode elements.
18814 static void node_push_allocator()(void* dummy) {
18815 g_node_push_allocator(dummy);
18819 // Set the pointer at the specified location to %NULL.
18820 // <nullify_location>: the memory address of the pointer.
18821 static void nullify_pointer()(void** nullify_location) {
18822 g_nullify_pointer(nullify_location);
18826 // Prompts the user with
18827 // <computeroutput>[E]xit, [H]alt, show [S]tack trace or [P]roceed</computeroutput>.
18828 // This function is intended to be used for debugging use only.
18829 // The following example shows how it can be used together with
18830 // the g_log() functions.
18832 // |[
18833 // &num;include &lt;glib.h&gt;
18835 // static void
18836 // log_handler (const gchar *log_domain,
18837 // GLogLevelFlags log_level,
18838 // const gchar *message,
18839 // gpointer user_data)
18840 // {
18841 // g_log_default_handler (log_domain, log_level, message, user_data);
18843 // g_on_error_query (MY_PROGRAM_NAME);
18844 // }
18846 // int
18847 // main (int argc, char *argv[])
18848 // {
18849 // g_log_set_handler (MY_LOG_DOMAIN,
18850 // G_LOG_LEVEL_WARNING |
18851 // G_LOG_LEVEL_ERROR |
18852 // G_LOG_LEVEL_CRITICAL,
18853 // log_handler,
18854 // NULL);
18855 // /&ast; ... &ast;/
18856 // ]|
18858 // If [E]xit is selected, the application terminates with a call
18859 // to <literal>_exit(0)</literal>.
18861 // If [S]tack trace is selected, g_on_error_stack_trace() is called.
18862 // This invokes <command>gdb</command>, which attaches to the current
18863 // process and shows a stack trace. The prompt is then shown again.
18865 // If [P]roceed is selected, the function returns.
18867 // This function may cause different actions on non-UNIX platforms.
18868 // <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)
18869 static void on_error_query()(char* prg_name) {
18870 g_on_error_query(prg_name);
18874 // Invokes <command>gdb</command>, which attaches to the current
18875 // process and shows a stack trace. Called by g_on_error_query()
18876 // when the [S]tack trace option is selected.
18878 // This function may cause different actions on non-UNIX platforms.
18879 // <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)
18880 static void on_error_stack_trace()(char* prg_name) {
18881 g_on_error_stack_trace(prg_name);
18885 // VERSION: 2.14
18886 // MOVED TO: Once.init_enter
18887 // Function to be called when starting a critical initialization
18888 // section. The argument @value_location must point to a static
18889 // 0-initialized variable that will be set to a value other than 0 at
18890 // the end of the initialization section. In combination with
18891 // g_once_init_leave() and the unique address @value_location, it can
18892 // be ensured that an initialization section will be executed only once
18893 // during a program's life time, and that concurrent threads are
18894 // blocked until initialization completed. To be used in constructs
18895 // like this:
18897 // <informalexample>
18898 // <programlisting>
18899 // static gsize initialization_value = 0;
18901 // if (g_once_init_enter (&amp;initialization_value))
18902 // {
18903 // gsize setup_value = 42; /<!-- -->* initialization code here *<!-- -->/
18905 // g_once_init_leave (&amp;initialization_value, setup_value);
18906 // }
18908 // /<!-- -->* use initialization_value here *<!-- -->/
18909 // </programlisting>
18910 // </informalexample>
18911 // <value_location>: location of a static initializable variable containing 0.
18912 static int once_init_enter()(size_t* value_location) {
18913 return g_once_init_enter(value_location);
18916 // MOVED TO: Once.init_enter_impl
18917 static int once_init_enter_impl()(size_t* value_location) {
18918 return g_once_init_enter_impl(value_location);
18922 // VERSION: 2.14
18923 // MOVED TO: Once.init_leave
18924 // Counterpart to g_once_init_enter(). Expects a location of a static
18925 // 0-initialized initialization variable, and an initialization value
18926 // other than 0. Sets the variable to the initialization value, and
18927 // releases concurrent threads blocking in g_once_init_enter() on this
18928 // initialization variable.
18929 // <value_location>: location of a static initializable variable containing 0.
18930 // <initialization_value>: new non-0 value for *@value_location.
18931 static void once_init_leave()(size_t* value_location, size_t initialization_value) {
18932 g_once_init_leave(value_location, initialization_value);
18935 static Quark option_error_quark()() {
18936 return g_option_error_quark();
18940 // Parses a string containing debugging options
18941 // into a %guint containing bit flags. This is used
18942 // within GDK and GTK+ to parse the debug options passed on the
18943 // command line or through environment variables.
18945 // If @string is equal to "all", all flags are set. If @string
18946 // is equal to "help", all the available keys in @keys are printed
18947 // out to standard error.
18948 // RETURNS: the combined set of bit flags.
18949 // <string>: a list of debug options separated by colons, spaces, or commas, or %NULL.
18950 // <keys>: pointer to an array of #GDebugKey which associate strings with bit flags.
18951 // <nkeys>: the number of #GDebugKey<!-- -->s in the array.
18952 static uint parse_debug_string()(char* string_, DebugKey* keys, uint nkeys) {
18953 return g_parse_debug_string(string_, keys, nkeys);
18957 // Gets the last component of the filename. If @file_name ends with a
18958 // directory separator it gets the component before the last slash. If
18959 // @file_name consists only of directory separators (and on Windows,
18960 // possibly a drive letter), a single separator is returned. If
18961 // @file_name is empty, it gets ".".
18963 // the filename.
18964 // RETURNS: a newly allocated string containing the last component of
18965 // <file_name>: the name of the file.
18966 static char* /*new*/ path_get_basename()(char* file_name) {
18967 return g_path_get_basename(file_name);
18971 // Gets the directory components of a file name. If the file name has no
18972 // directory components "." is returned. The returned string should be
18973 // freed when no longer needed.
18974 // RETURNS: the directory components of the file.
18975 // <file_name>: the name of the file.
18976 static char* /*new*/ path_get_dirname()(char* file_name) {
18977 return g_path_get_dirname(file_name);
18981 // Returns %TRUE if the given @file_name is an absolute file name.
18982 // Note that this is a somewhat vague concept on Windows.
18984 // On POSIX systems, an absolute file name is well-defined. It always
18985 // starts from the single root directory. For example "/usr/local".
18987 // On Windows, the concepts of current drive and drive-specific
18988 // current directory introduce vagueness. This function interprets as
18989 // an absolute file name one that either begins with a directory
18990 // separator such as "\Users\tml" or begins with the root on a drive,
18991 // for example "C:\Windows". The first case also includes UNC paths
18992 // such as "\\myserver\docs\foo". In all cases, either slashes or
18993 // backslashes are accepted.
18995 // Note that a file name relative to the current drive root does not
18996 // truly specify a file uniquely over time and across processes, as
18997 // the current drive is a per-process value and can be changed.
18999 // File names relative the current directory on some specific drive,
19000 // such as "D:foo/bar", are not interpreted as absolute by this
19001 // function, but they obviously are not relative to the normal current
19002 // directory as returned by getcwd() or g_get_current_dir()
19003 // either. Such paths should be avoided, or need to be handled using
19004 // Windows-specific code.
19005 // RETURNS: %TRUE if @file_name is absolute.
19006 // <file_name>: a file name.
19007 static int path_is_absolute()(char* file_name) {
19008 return g_path_is_absolute(file_name);
19012 // Returns a pointer into @file_name after the root component, i.e. after
19013 // the "/" in UNIX or "C:\" under Windows. If @file_name is not an absolute
19014 // path it returns %NULL.
19015 // RETURNS: a pointer into @file_name after the root component.
19016 // <file_name>: a file name.
19017 static char* path_skip_root()(char* file_name) {
19018 return g_path_skip_root(file_name);
19022 // Matches a string against a compiled pattern. Passing the correct
19023 // length of the string given is mandatory. The reversed string can be
19024 // omitted by passing %NULL, this is more efficient if the reversed
19025 // version of the string to be matched is not at hand, as
19026 // g_pattern_match() will only construct it if the compiled pattern
19027 // requires reverse matches.
19029 // Note that, if the user code will (possibly) match a string against a
19030 // multitude of patterns containing wildcards, chances are high that
19031 // some patterns will require a reversed string. In this case, it's
19032 // more efficient to provide the reversed string to avoid multiple
19033 // constructions thereof in the various calls to g_pattern_match().
19035 // Note also that the reverse of a UTF-8 encoded string can in general
19036 // <emphasis>not</emphasis> be obtained by g_strreverse(). This works
19037 // only if the string doesn't contain any multibyte characters. GLib
19038 // offers the g_utf8_strreverse() function to reverse UTF-8 encoded
19039 // strings.
19040 // <pspec>: a #GPatternSpec
19041 // <string_length>: the length of @string (in bytes, i.e. strlen(), <emphasis>not</emphasis> g_utf8_strlen())
19042 // <string>: the UTF-8 encoded string to match
19043 // <string_reversed>: the reverse of @string or %NULL
19044 static int pattern_match()(PatternSpec* pspec, uint string_length, char* string_, char* string_reversed) {
19045 return g_pattern_match(pspec, string_length, string_, string_reversed);
19049 // Matches a string against a pattern given as a string. If this
19050 // function is to be called in a loop, it's more efficient to compile
19051 // the pattern once with g_pattern_spec_new() and call
19052 // g_pattern_match_string() repeatedly.
19053 // <pattern>: the UTF-8 encoded pattern
19054 // <string>: the UTF-8 encoded string to match
19055 static int pattern_match_simple()(char* pattern, char* string_) {
19056 return g_pattern_match_simple(pattern, string_);
19060 // Matches a string against a compiled pattern. If the string is to be
19061 // matched against more than one pattern, consider using
19062 // g_pattern_match() instead while supplying the reversed string.
19063 // <pspec>: a #GPatternSpec
19064 // <string>: the UTF-8 encoded string to match
19065 static int pattern_match_string()(PatternSpec* pspec, char* string_) {
19066 return g_pattern_match_string(pspec, string_);
19070 // VERSION: 2.30
19071 // This is equivalent to g_bit_lock, but working on pointers (or other
19072 // pointer-sized values).
19074 // For portability reasons, you may only lock on the bottom 32 bits of
19075 // the pointer.
19076 // <address>: a pointer to a #gpointer-sized value
19077 // <lock_bit>: a bit value between 0 and 31
19078 static void pointer_bit_lock()(void* address, int lock_bit) {
19079 g_pointer_bit_lock(address, lock_bit);
19083 // VERSION: 2.30
19084 // This is equivalent to g_bit_trylock, but working on pointers (or
19085 // other pointer-sized values).
19087 // For portability reasons, you may only lock on the bottom 32 bits of
19088 // the pointer.
19089 // RETURNS: %TRUE if the lock was acquired
19090 // <address>: a pointer to a #gpointer-sized value
19091 // <lock_bit>: a bit value between 0 and 31
19092 static int pointer_bit_trylock()(void* address, int lock_bit) {
19093 return g_pointer_bit_trylock(address, lock_bit);
19097 // VERSION: 2.30
19098 // This is equivalent to g_bit_unlock, but working on pointers (or other
19099 // pointer-sized values).
19101 // For portability reasons, you may only lock on the bottom 32 bits of
19102 // the pointer.
19103 // <address>: a pointer to a #gpointer-sized value
19104 // <lock_bit>: a bit value between 0 and 31
19105 static void pointer_bit_unlock()(void* address, int lock_bit) {
19106 g_pointer_bit_unlock(address, lock_bit);
19110 // VERSION: 2.20
19111 // Polls @fds, as with the poll() system call, but portably. (On
19112 // systems that don't have poll(), it is emulated using select().)
19113 // This is used internally by #GMainContext, but it can be called
19114 // directly if you need to block until a file descriptor is ready, but
19115 // don't want to run the full main loop.
19117 // Each element of @fds is a #GPollFD describing a single file
19118 // descriptor to poll. The %fd field indicates the file descriptor,
19119 // and the %events field indicates the events to poll for. On return,
19120 // the %revents fields will be filled with the events that actually
19121 // occurred.
19123 // On POSIX systems, the file descriptors in @fds can be any sort of
19124 // file descriptor, but the situation is much more complicated on
19125 // Windows. If you need to use g_poll() in code that has to run on
19126 // Windows, the easiest solution is to construct all of your
19127 // #GPollFD<!-- -->s with g_io_channel_win32_make_pollfd().
19129 // were filled in, or 0 if the operation timed out, or -1 on error or
19130 // if the call was interrupted.
19131 // RETURNS: the number of entries in @fds whose %revents fields
19132 // <fds>: file descriptors to poll
19133 // <nfds>: the number of file descriptors in @fds
19134 // <timeout>: amount of time to wait, in milliseconds, or -1 to wait forever
19135 static int poll()(PollFD* fds, uint nfds, int timeout) {
19136 return g_poll(fds, nfds, timeout);
19140 // Unintrospectable function: prefix_error() / g_prefix_error()
19141 // VERSION: 2.16
19142 // Formats a string according to @format and
19143 // prefix it to an existing error message. If
19144 // nothing.
19146 // If *@err is %NULL (ie: an error variable is
19147 // present but there is no error condition) then
19148 // also do nothing. Whether or not it makes
19149 // sense to take advantage of this feature is up
19150 // to you.
19151 // <err>: a return location for a #GError, or %NULL
19152 // <format>: printf()-style format string
19153 alias g_prefix_error prefix_error; // Variadic
19156 // Unintrospectable function: print() / g_print()
19157 // Outputs a formatted message via the print handler.
19158 // The default print handler simply outputs the message to stdout.
19160 // g_print() should not be used from within libraries for debugging
19161 // messages, since it may be redirected by applications to special
19162 // purpose message windows or even files. Instead, libraries should
19163 // use g_log(), or the convenience functions g_message(), g_warning()
19164 // and g_error().
19165 // <format>: the message format. See the printf() documentation
19166 alias g_print print; // Variadic
19169 // Unintrospectable function: printerr() / g_printerr()
19170 // Outputs a formatted message via the error message handler.
19171 // The default handler simply outputs the message to stderr.
19173 // g_printerr() should not be used from within libraries.
19174 // Instead g_log() should be used, or the convenience functions
19175 // g_message(), g_warning() and g_error().
19176 // <format>: the message format. See the printf() documentation
19177 alias g_printerr printerr; // Variadic
19180 // Unintrospectable function: printf() / g_printf()
19181 // VERSION: 2.2
19182 // An implementation of the standard printf() function which supports
19183 // positional parameters, as specified in the Single Unix Specification.
19184 // RETURNS: the number of bytes printed.
19185 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
19186 alias g_printf printf; // Variadic
19188 // Unintrospectable function: printf_string_upper_bound() / g_printf_string_upper_bound()
19189 static size_t printf_string_upper_bound()(char* format, va_list args) {
19190 return g_printf_string_upper_bound(format, args);
19194 // If @dest is %NULL, free @src; otherwise, moves @src into *@dest.
19195 // The error variable @dest points to must be %NULL.
19196 // <dest>: error return location
19197 // <src>: error to move into the return location
19198 static void propagate_error()(Error** dest, Error* src) {
19199 g_propagate_error(dest, src);
19203 // Unintrospectable function: propagate_prefixed_error() / g_propagate_prefixed_error()
19204 // VERSION: 2.16
19205 // If @dest is %NULL, free @src; otherwise,
19206 // moves @src into *@dest. *@dest must be %NULL.
19207 // After the move, add a prefix as with
19208 // g_prefix_error().
19209 // <dest>: error return location
19210 // <src>: error to move into the return location
19211 // <format>: printf()-style format string
19212 alias g_propagate_prefixed_error propagate_prefixed_error; // Variadic
19215 // MOVED TO: PtrArray.add
19216 // Adds a pointer to the end of the pointer array. The array will grow
19217 // in size automatically if necessary.
19218 // <array>: a #GPtrArray.
19219 // <data>: the pointer to add.
19220 static void ptr_array_add()(PtrArray* array, void* data) {
19221 g_ptr_array_add(array, data);
19225 // MOVED TO: PtrArray.remove
19226 // Removes the first occurrence of the given pointer from the pointer
19227 // array. The following elements are moved down one place. If @array
19228 // has a non-%NULL #GDestroyNotify function it is called for the
19229 // removed element.
19231 // It returns %TRUE if the pointer was removed, or %FALSE if the
19232 // pointer was not found.
19233 // <array>: a #GPtrArray.
19234 // <data>: the pointer to remove.
19235 static int ptr_array_remove()(PtrArray* array, void* data) {
19236 return g_ptr_array_remove(array, data);
19240 // MOVED TO: PtrArray.remove_fast
19241 // Removes the first occurrence of the given pointer from the pointer
19242 // array. The last element in the array is used to fill in the space,
19243 // so this function does not preserve the order of the array. But it is
19244 // faster than g_ptr_array_remove(). If @array has a non-%NULL
19245 // #GDestroyNotify function it is called for the removed element.
19247 // It returns %TRUE if the pointer was removed, or %FALSE if the
19248 // pointer was not found.
19249 // <array>: a #GPtrArray.
19250 // <data>: the pointer to remove.
19251 static int ptr_array_remove_fast()(PtrArray* array, void* data) {
19252 return g_ptr_array_remove_fast(array, data);
19256 // VERSION: 2.4
19257 // MOVED TO: PtrArray.remove_range
19258 // Removes the given number of pointers starting at the given index
19259 // from a #GPtrArray. The following elements are moved to close the
19260 // gap. If @array has a non-%NULL #GDestroyNotify function it is called
19261 // for the removed elements.
19262 // <array>: a @GPtrArray.
19263 // <index_>: the index of the first pointer to remove.
19264 // <length>: the number of pointers to remove.
19265 static void ptr_array_remove_range()(PtrArray* array, uint index_, uint length) {
19266 g_ptr_array_remove_range(array, index_, length);
19270 // VERSION: 2.22
19271 // MOVED TO: PtrArray.set_free_func
19272 // Sets a function for freeing each element when @array is destroyed
19273 // either via g_ptr_array_unref(), when g_ptr_array_free() is called
19274 // with @free_segment set to %TRUE or when removing elements.
19275 // <array>: A #GPtrArray.
19276 // <element_free_func>: A function to free elements with destroy @array or %NULL.
19277 static void ptr_array_set_free_func()(PtrArray* array, DestroyNotify element_free_func) {
19278 g_ptr_array_set_free_func(array, element_free_func);
19282 // MOVED TO: PtrArray.set_size
19283 // Sets the size of the array. When making the array larger,
19284 // newly-added elements will be set to %NULL. When making it smaller,
19285 // if @array has a non-%NULL #GDestroyNotify function then it will be
19286 // called for the removed elements.
19287 // <array>: a #GPtrArray.
19288 // <length>: the new length of the pointer array.
19289 static void ptr_array_set_size()(PtrArray* array, int length) {
19290 g_ptr_array_set_size(array, length);
19294 // VERSION: 2.22
19295 // MOVED TO: PtrArray.unref
19296 // Atomically decrements the reference count of @array by one. If the
19297 // reference count drops to 0, the effect is the same as calling
19298 // g_ptr_array_free() with @free_segment set to %TRUE. This function
19299 // is MT-safe and may be called from any thread.
19300 // <array>: A #GPtrArray.
19301 static void ptr_array_unref()(PtrArray* array) {
19302 g_ptr_array_unref(array);
19306 // Unintrospectable function: qsort_with_data() / g_qsort_with_data()
19307 // This is just like the standard C qsort() function, but
19308 // the comparison routine accepts a user data argument.
19309 // <pbase>: start of array to sort
19310 // <total_elems>: elements in the array
19311 // <size>: size of each element
19312 // <compare_func>: function to compare elements
19313 // <user_data>: data to pass to @compare_func
19314 static void qsort_with_data()(const(void)* pbase, int total_elems, size_t size, CompareDataFunc compare_func, void* user_data) {
19315 g_qsort_with_data(pbase, total_elems, size, compare_func, user_data);
19319 // Gets the #GQuark identifying the given (static) string. If the
19320 // string does not currently have an associated #GQuark, a new #GQuark
19321 // is created, linked to the given string.
19323 // Note that this function is identical to g_quark_from_string() except
19324 // that if a new #GQuark is created the string itself is used rather
19325 // than a copy. This saves memory, but can only be used if the string
19326 // will <emphasis>always</emphasis> exist. It can be used with
19327 // statically allocated strings in the main program, but not with
19328 // statically allocated memory in dynamically loaded modules, if you
19329 // expect to ever unload the module again (e.g. do not use this
19330 // function in GTK+ theme engines).
19331 // <string>: a string.
19332 static Quark quark_from_static_string()(char* string_=null) {
19333 return g_quark_from_static_string(string_);
19337 // Gets the #GQuark identifying the given string. If the string does
19338 // not currently have an associated #GQuark, a new #GQuark is created,
19339 // using a copy of the string.
19340 // <string>: a string.
19341 static Quark quark_from_string()(char* string_=null) {
19342 return g_quark_from_string(string_);
19346 // Gets the string associated with the given #GQuark.
19347 // <quark>: a #GQuark.
19348 static char* quark_to_string()(Quark quark) {
19349 return g_quark_to_string(quark);
19353 // Gets the #GQuark associated with the given string, or 0 if string is
19354 // %NULL or it has no associated #GQuark.
19356 // If you want the GQuark to be created if it doesn't already exist,
19357 // use g_quark_from_string() or g_quark_from_static_string().
19358 // <string>: a string.
19359 static Quark quark_try_string()(char* string_=null) {
19360 return g_quark_try_string(string_);
19364 // Returns a random #gdouble equally distributed over the range [0..1).
19365 // RETURNS: A random number.
19366 static double random_double()() {
19367 return g_random_double();
19371 // Returns a random #gdouble equally distributed over the range [@begin..@end).
19372 // RETURNS: A random number.
19373 // <begin>: lower closed bound of the interval.
19374 // <end>: upper open bound of the interval.
19375 static double random_double_range()(double begin, double end) {
19376 return g_random_double_range(begin, end);
19380 // Return a random #guint32 equally distributed over the range
19381 // [0..2^32-1].
19382 // RETURNS: A random number.
19383 static uint random_int()() {
19384 return g_random_int();
19388 // Returns a random #gint32 equally distributed over the range
19389 // [@begin..@end-1].
19390 // RETURNS: A random number.
19391 // <begin>: lower closed bound of the interval.
19392 // <end>: upper open bound of the interval.
19393 static int random_int_range()(int begin, int end) {
19394 return g_random_int_range(begin, end);
19398 // Sets the seed for the global random number generator, which is used
19399 // by the <function>g_random_*</function> functions, to @seed.
19400 // <seed>: a value to reinitialize the global random number generator.
19401 static void random_set_seed()(uint seed) {
19402 g_random_set_seed(seed);
19406 // Unintrospectable function: realloc() / g_realloc()
19407 // Reallocates the memory pointed to by @mem, so that it now has space for
19408 // @n_bytes bytes of memory. It returns the new address of the memory, which may
19409 // have been moved. @mem may be %NULL, in which case it's considered to
19410 // have zero-length. @n_bytes may be 0, in which case %NULL will be returned
19411 // and @mem will be freed unless it is %NULL.
19412 // RETURNS: the new address of the allocated memory
19413 // <mem>: the memory to reallocate
19414 // <n_bytes>: new size of the memory in bytes
19415 static void* realloc()(void* mem, size_t n_bytes) {
19416 return g_realloc(mem, n_bytes);
19420 // Unintrospectable function: realloc_n() / g_realloc_n()
19421 // VERSION: 2.24
19422 // This function is similar to g_realloc(), allocating (@n_blocks * @n_block_bytes) bytes,
19423 // but care is taken to detect possible overflow during multiplication.
19424 // RETURNS: the new address of the allocated memory
19425 // <mem>: the memory to reallocate
19426 // <n_blocks>: the number of blocks to allocate
19427 // <n_block_bytes>: the size of each block in bytes
19428 static void* realloc_n()(void* mem, size_t n_blocks, size_t n_block_bytes) {
19429 return g_realloc_n(mem, n_blocks, n_block_bytes);
19433 // VERSION: 2.14
19434 // MOVED TO: Regex.check_replacement
19435 // Checks whether @replacement is a valid replacement string
19436 // (see g_regex_replace()), i.e. that all escape sequences in
19437 // it are valid.
19439 // If @has_references is not %NULL then @replacement is checked
19440 // for pattern references. For instance, replacement text 'foo\n'
19441 // does not contain references and may be evaluated without information
19442 // about actual match, but '\0\1' (whole match followed by first
19443 // subpattern) requires valid #GMatchInfo object.
19444 // RETURNS: whether @replacement is a valid replacement string
19445 // <replacement>: the replacement string
19446 // <has_references>: location to store information about references in @replacement or %NULL
19447 static int regex_check_replacement()(char* replacement, /*out*/ int* has_references, GLib2.Error** error=null) {
19448 return g_regex_check_replacement(replacement, has_references, error);
19451 // MOVED TO: Regex.error_quark
19452 static Quark regex_error_quark()() {
19453 return g_regex_error_quark();
19457 // VERSION: 2.30
19458 // MOVED TO: Regex.escape_nul
19459 // Escapes the nul characters in @string to "\x00". It can be used
19460 // to compile a regex with embedded nul characters.
19462 // For completeness, @length can be -1 for a nul-terminated string.
19463 // In this case the output string will be of course equal to @string.
19464 // RETURNS: a newly-allocated escaped string
19465 // <string>: the string to escape
19466 // <length>: the length of @string
19467 static char* /*new*/ regex_escape_nul()(char* string_, int length) {
19468 return g_regex_escape_nul(string_, length);
19472 // VERSION: 2.14
19473 // MOVED TO: Regex.escape_string
19474 // Escapes the special characters used for regular expressions
19475 // in @string, for instance "a.b*c" becomes "a\.b\*c". This
19476 // function is useful to dynamically generate regular expressions.
19478 // @string can contain nul characters that are replaced with "\0",
19479 // in this case remember to specify the correct length of @string
19480 // in @length.
19481 // RETURNS: a newly-allocated escaped string
19482 // <string>: the string to escape
19483 // <length>: the length of @string, or -1 if @string is nul-terminated
19484 static char* /*new*/ regex_escape_string()(char* string_, int length) {
19485 return g_regex_escape_string(string_, length);
19489 // VERSION: 2.14
19490 // MOVED TO: Regex.match_simple
19491 // Scans for a match in @string for @pattern.
19493 // This function is equivalent to g_regex_match() but it does not
19494 // require to compile the pattern with g_regex_new(), avoiding some
19495 // lines of code when you need just to do a match without extracting
19496 // substrings, capture counts, and so on.
19498 // If this function is to be called on the same @pattern more than
19499 // once, it's more efficient to compile the pattern once with
19500 // g_regex_new() and then use g_regex_match().
19501 // RETURNS: %TRUE if the string matched, %FALSE otherwise
19502 // <pattern>: the regular expression
19503 // <string>: the string to scan for matches
19504 // <compile_options>: compile options for the regular expression, or 0
19505 // <match_options>: match options, or 0
19506 static int regex_match_simple()(char* pattern, char* string_, RegexCompileFlags compile_options, RegexMatchFlags match_options) {
19507 return g_regex_match_simple(pattern, string_, compile_options, match_options);
19511 // VERSION: 2.22
19512 // Resets the cache used for g_get_user_special_dir(), so
19513 // that the latest on-disk version is used. Call this only
19514 // if you just changed the data on disk yourself.
19516 // Due to threadsafety issues this may cause leaking of strings
19517 // that were previously returned from g_get_user_special_dir()
19518 // that can't be freed. We ensure to only leak the data for
19519 // the directories that actually changed value though.
19520 static void reload_user_special_dirs_cache()() {
19521 g_reload_user_special_dirs_cache();
19524 static void return_if_fail_warning()(char* log_domain, char* pretty_function, char* expression) {
19525 g_return_if_fail_warning(log_domain, pretty_function, expression);
19529 // VERSION: 2.6
19530 // A wrapper for the POSIX rmdir() function. The rmdir() function
19531 // deletes a directory from the filesystem.
19533 // See your C library manual for more details about how rmdir() works
19534 // on your system.
19536 // occurred
19537 // RETURNS: 0 if the directory was successfully removed, -1 if an error
19538 // <filename>: a pathname in the GLib file name encoding (UTF-8 on Windows)
19539 static int rmdir()(char* filename) {
19540 return g_rmdir(filename);
19544 // VERSION: 2.14
19545 // MOVED TO: Sequence.move
19546 // Moves the item pointed to by @src to the position indicated by @dest.
19547 // After calling this function @dest will point to the position immediately
19548 // after @src. It is allowed for @src and @dest to point into different
19549 // sequences.
19550 // <src>: a #GSequenceIter pointing to the item to move
19551 // <dest>: a #GSequenceIter pointing to the position to which the item is moved.
19552 static void sequence_move()(SequenceIter* src, SequenceIter* dest) {
19553 g_sequence_move(src, dest);
19557 // VERSION: 2.14
19558 // MOVED TO: Sequence.move_range
19559 // Inserts the (@begin, @end) range at the destination pointed to by ptr.
19560 // The @begin and @end iters must point into the same sequence. It is
19561 // allowed for @dest to point to a different sequence than the one pointed
19562 // into by @begin and @end.
19564 // If @dest is NULL, the range indicated by @begin and @end is
19565 // removed from the sequence. If @dest iter points to a place within
19566 // the (@begin, @end) range, the range does not move.
19567 // <dest>: a #GSequenceIter
19568 // <begin>: a #GSequenceIter
19569 // <end>: a #GSequenceIter
19570 static void sequence_move_range()(SequenceIter* dest, SequenceIter* begin, SequenceIter* end) {
19571 g_sequence_move_range(dest, begin, end);
19575 // VERSION: 2.14
19576 // MOVED TO: Sequence.remove
19577 // Removes the item pointed to by @iter. It is an error to pass the
19578 // end iterator to this function.
19580 // If the sequnce has a data destroy function associated with it, this
19581 // function is called on the data for the removed item.
19582 // <iter>: a #GSequenceIter
19583 static void sequence_remove()(SequenceIter* iter) {
19584 g_sequence_remove(iter);
19588 // VERSION: 2.14
19589 // MOVED TO: Sequence.remove_range
19590 // Removes all items in the (@begin, @end) range.
19592 // If the sequence has a data destroy function associated with it, this
19593 // function is called on the data for the removed items.
19594 // <begin>: a #GSequenceIter
19595 // <end>: a #GSequenceIter
19596 static void sequence_remove_range()(SequenceIter* begin, SequenceIter* end) {
19597 g_sequence_remove_range(begin, end);
19601 // VERSION: 2.14
19602 // MOVED TO: Sequence.set
19603 // Changes the data for the item pointed to by @iter to be @data. If
19604 // the sequence has a data destroy function associated with it, that
19605 // function is called on the existing data that @iter pointed to.
19606 // <iter>: a #GSequenceIter
19607 // <data>: new data for the item
19608 static void sequence_set()(SequenceIter* iter, void* data) {
19609 g_sequence_set(iter, data);
19613 // VERSION: 2.14
19614 // MOVED TO: Sequence.swap
19615 // Swaps the items pointed to by @a and @b. It is allowed for @a and @b
19616 // to point into difference sequences.
19617 // <a>: a #GSequenceIter
19618 // <b>: a #GSequenceIter
19619 static void sequence_swap()(SequenceIter* a, SequenceIter* b) {
19620 g_sequence_swap(a, b);
19624 // VERSION: 2.2
19625 // Sets a human-readable name for the application. This name should be
19626 // localized if possible, and is intended for display to the user.
19627 // Contrast with g_set_prgname(), which sets a non-localized name.
19628 // g_set_prgname() will be called automatically by gtk_init(),
19629 // but g_set_application_name() will not.
19631 // Note that for thread safety reasons, this function can only
19632 // be called once.
19634 // The application name will be used in contexts such as error messages,
19635 // or when displaying an application's name in the task list.
19636 // <application_name>: localized name of the application
19637 static void set_application_name()(char* application_name) {
19638 g_set_application_name(application_name);
19642 // Unintrospectable function: set_error() / g_set_error()
19643 // Does nothing if @err is %NULL; if @err is non-%NULL, then *@err
19644 // must be %NULL. A new #GError is created and assigned to *@err.
19645 // <err>: a return location for a #GError, or %NULL
19646 // <domain>: error domain
19647 // <code>: error code
19648 // <format>: printf()-style format
19649 alias g_set_error set_error; // Variadic
19652 // VERSION: 2.18
19653 // Does nothing if @err is %NULL; if @err is non-%NULL, then *@err
19654 // must be %NULL. A new #GError is created and assigned to *@err.
19655 // Unlike g_set_error(), @message is not a printf()-style format string.
19656 // Use this function if @message contains text you don't have control over,
19657 // that could include printf() escape sequences.
19658 // <err>: a return location for a #GError, or %NULL
19659 // <domain>: error domain
19660 // <code>: error code
19661 // <message>: error message
19662 static void set_error_literal()(Error** err, Quark domain, int code, char* message) {
19663 g_set_error_literal(err, domain, code, message);
19667 // Sets the name of the program. This name should <emphasis>not</emphasis>
19668 // be localized, contrast with g_set_application_name(). Note that for
19669 // thread-safety reasons this function can only be called once.
19670 // <prgname>: the name of the program.
19671 static void set_prgname()(char* prgname) {
19672 g_set_prgname(prgname);
19676 // Unintrospectable function: set_print_handler() / g_set_print_handler()
19677 // Sets the print handler.
19679 // Any messages passed to g_print() will be output via
19680 // the new handler. The default handler simply outputs
19681 // the message to stdout. By providing your own handler
19682 // you can redirect the output, to a GTK+ widget or a
19683 // log file for example.
19684 // RETURNS: the old print handler
19685 // <func>: the new print handler
19686 static PrintFunc set_print_handler()(PrintFunc func) {
19687 return g_set_print_handler(func);
19691 // Unintrospectable function: set_printerr_handler() / g_set_printerr_handler()
19692 // Sets the handler for printing error messages.
19694 // Any messages passed to g_printerr() will be output via
19695 // the new handler. The default handler simply outputs the
19696 // message to stderr. By providing your own handler you can
19697 // redirect the output, to a GTK+ widget or a log file for
19698 // example.
19699 // RETURNS: the old error message handler
19700 // <func>: the new error message handler
19701 static PrintFunc set_printerr_handler()(PrintFunc func) {
19702 return g_set_printerr_handler(func);
19706 // VERSION: 2.4
19707 // Sets an environment variable. Both the variable's name and value
19708 // should be in the GLib file name encoding. On UNIX, this means that
19709 // they can be any sequence of bytes. On Windows, they should be in
19710 // UTF-8.
19712 // Note that on some systems, when variables are overwritten, the memory
19713 // used for the previous variables and its value isn't reclaimed.
19714 // RETURNS: %FALSE if the environment variable couldn't be set.
19715 // <variable>: the environment variable to set, must not contain '='.
19716 // <value>: the value for to set the variable to.
19717 // <overwrite>: whether to change the variable if it already exists.
19718 static int setenv()(char* variable, char* value, int overwrite) {
19719 return g_setenv(variable, value, overwrite);
19722 static Quark shell_error_quark()() {
19723 return g_shell_error_quark();
19727 // Parses a command line into an argument vector, in much the same way
19728 // the shell would, but without many of the expansions the shell would
19729 // perform (variable expansion, globs, operators, filename expansion,
19730 // etc. are not supported). The results are defined to be the same as
19731 // those you would get from a UNIX98 /bin/sh, as long as the input
19732 // contains none of the unsupported shell expansions. If the input
19733 // does contain such expansions, they are passed through
19734 // literally. Possible errors are those from the #G_SHELL_ERROR
19735 // domain. Free the returned vector with g_strfreev().
19736 // RETURNS: %TRUE on success, %FALSE if error set
19737 // <command_line>: command line to parse
19738 // <argcp>: return location for number of args
19739 // <argvp>: return location for array of args
19740 static int shell_parse_argv()(char* command_line, /*out*/ int* argcp, /*out*/ char*** argvp, GLib2.Error** error=null) {
19741 return g_shell_parse_argv(command_line, argcp, argvp, error);
19745 // Quotes a string so that the shell (/bin/sh) will interpret the
19746 // quoted string to mean @unquoted_string. If you pass a filename to
19747 // the shell, for example, you should first quote it with this
19748 // function. The return value must be freed with g_free(). The
19749 // quoting style used is undefined (single or double quotes may be
19750 // used).
19751 // RETURNS: quoted string
19752 // <unquoted_string>: a literal string
19753 static char* /*new*/ shell_quote()(char* unquoted_string) {
19754 return g_shell_quote(unquoted_string);
19758 // Unquotes a string as the shell (/bin/sh) would. Only handles
19759 // quotes; if a string contains file globs, arithmetic operators,
19760 // variables, backticks, redirections, or other special-to-the-shell
19761 // features, the result will be different from the result a real shell
19762 // would produce (the variables, backticks, etc. will be passed
19763 // through literally instead of being expanded). This function is
19764 // guaranteed to succeed if applied to the result of
19765 // g_shell_quote(). If it fails, it returns %NULL and sets the
19766 // error. The @quoted_string need not actually contain quoted or
19767 // escaped text; g_shell_unquote() simply goes through the string and
19768 // unquotes/unescapes anything that the shell would. Both single and
19769 // double quotes are handled, as are escapes including escaped
19770 // newlines. The return value must be freed with g_free(). Possible
19771 // errors are in the #G_SHELL_ERROR domain.
19773 // Shell quoting rules are a bit strange. Single quotes preserve the
19774 // literal string exactly. escape sequences are not allowed; not even
19775 // \' - if you want a ' in the quoted text, you have to do something
19776 // like 'foo'\''bar'. Double quotes allow $, `, ", \, and newline to
19777 // be escaped with backslash. Otherwise double quotes preserve things
19778 // literally.
19779 // RETURNS: an unquoted string
19780 // <quoted_string>: shell-quoted string
19781 static char* /*new*/ shell_unquote()(char* quoted_string, GLib2.Error** error=null) {
19782 return g_shell_unquote(quoted_string, error);
19785 // Unintrospectable function: slice_alloc() / g_slice_alloc()
19786 static void* slice_alloc()(size_t block_size) {
19787 return g_slice_alloc(block_size);
19790 // Unintrospectable function: slice_alloc0() / g_slice_alloc0()
19791 static void* slice_alloc0()(size_t block_size) {
19792 return g_slice_alloc0(block_size);
19795 // Unintrospectable function: slice_copy() / g_slice_copy()
19796 static void* slice_copy()(size_t block_size, const(void)* mem_block) {
19797 return g_slice_copy(block_size, mem_block);
19800 static void slice_free1()(size_t block_size, void* mem_block) {
19801 g_slice_free1(block_size, mem_block);
19804 static void slice_free_chain_with_offset()(size_t block_size, void* mem_chain, size_t next_offset) {
19805 g_slice_free_chain_with_offset(block_size, mem_chain, next_offset);
19808 static long slice_get_config()(SliceConfig ckey) {
19809 return g_slice_get_config(ckey);
19812 static long* slice_get_config_state()(SliceConfig ckey, long address, uint* n_values) {
19813 return g_slice_get_config_state(ckey, address, n_values);
19816 static void slice_set_config()(SliceConfig ckey, long value) {
19817 g_slice_set_config(ckey, value);
19821 // DEPRECATED (v2.10) function: slist_pop_allocator - It does nothing, since #GSList has been converted
19822 // MOVED TO: SList.pop_allocator
19823 // Restores the previous #GAllocator, used when allocating #GSList
19824 // elements.
19826 // Note that this function is not available if GLib has been compiled
19827 // with <option>--disable-mem-pools</option>
19829 // to the <link linkend="glib-Memory-Slices">slice
19830 // allocator</link>
19831 static void slist_pop_allocator()() {
19832 g_slist_pop_allocator();
19836 // DEPRECATED (v2.10) function: slist_push_allocator - It does nothing, since #GSList has been converted
19837 // MOVED TO: SList.push_allocator
19838 // Sets the allocator to use to allocate #GSList elements. Use
19839 // g_slist_pop_allocator() to restore the previous allocator.
19841 // Note that this function is not available if GLib has been compiled
19842 // with <option>--disable-mem-pools</option>
19844 // to the <link linkend="glib-Memory-Slices">slice
19845 // allocator</link>
19846 // <dummy>: the #GAllocator to use when allocating #GSList elements.
19847 static void slist_push_allocator()(void* dummy) {
19848 g_slist_push_allocator(dummy);
19852 // Unintrospectable function: snprintf() / g_snprintf()
19853 // A safer form of the standard sprintf() function. The output is guaranteed
19854 // to not exceed @n characters (including the terminating nul character), so
19855 // it is easy to ensure that a buffer overflow cannot occur.
19857 // See also g_strdup_printf().
19859 // In versions of GLib prior to 1.2.3, this function may return -1 if the
19860 // output was truncated, and the truncated string may not be nul-terminated.
19861 // In versions prior to 1.3.12, this function returns the length of the output
19862 // string.
19864 // The return value of g_snprintf() conforms to the snprintf()
19865 // function as standardized in ISO C99. Note that this is different from
19866 // traditional snprintf(), which returns the length of the output string.
19868 // The format string may contain positional parameters, as specified in
19869 // the Single Unix Specification.
19871 // was large enough.
19872 // RETURNS: the number of bytes which would be produced if the buffer
19873 // <string>: the buffer to hold the output.
19874 // <n>: the maximum number of bytes to produce (including the terminating nul character).
19875 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
19876 alias g_snprintf snprintf; // Variadic
19879 // MOVED TO: Source.remove
19880 // Removes the source with the given id from the default main context.
19881 // The id of
19882 // a #GSource is given by g_source_get_id(), or will be returned by the
19883 // functions g_source_attach(), g_idle_add(), g_idle_add_full(),
19884 // g_timeout_add(), g_timeout_add_full(), g_child_watch_add(),
19885 // g_child_watch_add_full(), g_io_add_watch(), and g_io_add_watch_full().
19887 // See also g_source_destroy(). You must use g_source_destroy() for sources
19888 // added to a non-default main context.
19889 // RETURNS: %TRUE if the source was found and removed.
19890 // <tag>: the ID of the source to remove.
19891 static int source_remove()(uint tag) {
19892 return g_source_remove(tag);
19896 // MOVED TO: Source.remove_by_funcs_user_data
19897 // Removes a source from the default main loop context given the
19898 // source functions and user data. If multiple sources exist with the
19899 // same source functions and user data, only one will be destroyed.
19900 // RETURNS: %TRUE if a source was found and removed.
19901 // <funcs>: The @source_funcs passed to g_source_new()
19902 // <user_data>: the user data for the callback
19903 static int source_remove_by_funcs_user_data()(SourceFuncs* funcs, void* user_data) {
19904 return g_source_remove_by_funcs_user_data(funcs, user_data);
19908 // MOVED TO: Source.remove_by_user_data
19909 // Removes a source from the default main loop context given the user
19910 // data for the callback. If multiple sources exist with the same user
19911 // data, only one will be destroyed.
19912 // RETURNS: %TRUE if a source was found and removed.
19913 // <user_data>: the user_data for the callback.
19914 static int source_remove_by_user_data()(void* user_data) {
19915 return g_source_remove_by_user_data(user_data);
19919 // VERSION: 2.26
19920 // MOVED TO: Source.set_name_by_id
19921 // Sets the name of a source using its ID.
19923 // This is a convenience utility to set source names from the return
19924 // value of g_idle_add(), g_timeout_add(), etc.
19925 // <tag>: a #GSource ID
19926 // <name>: debug name for the source
19927 static void source_set_name_by_id()(uint tag, char* name) {
19928 g_source_set_name_by_id(tag, name);
19932 // Gets the smallest prime number from a built-in array of primes which
19933 // is larger than @num. This is used within GLib to calculate the optimum
19934 // size of a #GHashTable.
19936 // The built-in array of primes ranges from 11 to 13845163 such that
19937 // each prime is approximately 1.5-2 times the previous prime.
19939 // which is larger than @num
19940 // RETURNS: the smallest prime number from a built-in array of primes
19941 // <num>: a #guint
19942 static uint spaced_primes_closest()(uint num) {
19943 return g_spaced_primes_closest(num);
19947 // See g_spawn_async_with_pipes() for a full description; this function
19948 // simply calls the g_spawn_async_with_pipes() without any pipes.
19950 // You should call g_spawn_close_pid() on the returned child process
19951 // reference when you don't need it any more.
19953 // <note><para>
19954 // If you are writing a GTK+ application, and the program you
19955 // are spawning is a graphical application, too, then you may
19956 // want to use gdk_spawn_on_screen() instead to ensure that
19957 // the spawned program opens its windows on the right screen.
19958 // </para></note>
19960 // <note><para> Note that the returned @child_pid on Windows is a
19961 // handle to the child process and not its identifier. Process handles
19962 // and process identifiers are different concepts on Windows.
19963 // </para></note>
19964 // RETURNS: %TRUE on success, %FALSE if error is set
19965 // <working_directory>: child's current working directory, or %NULL to inherit parent's
19966 // <argv>: child's argument vector
19967 // <envp>: child's environment, or %NULL to inherit parent's
19968 // <flags>: flags from #GSpawnFlags
19969 // <child_setup>: function to run in the child just before exec()
19970 // <user_data>: user data for @child_setup
19971 // <child_pid>: return location for child process reference, or %NULL
19972 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) {
19973 return g_spawn_async(working_directory, argv, envp, flags, child_setup, user_data, child_pid, error);
19977 // Executes a child program asynchronously (your program will not
19978 // block waiting for the child to exit). The child program is
19979 // specified by the only argument that must be provided, @argv. @argv
19980 // should be a %NULL-terminated array of strings, to be passed as the
19981 // argument vector for the child. The first string in @argv is of
19982 // course the name of the program to execute. By default, the name of
19983 // the program must be a full path; the <envar>PATH</envar> shell variable
19984 // will only be searched if you pass the %G_SPAWN_SEARCH_PATH flag.
19986 // On Windows, note that all the string or string vector arguments to
19987 // this function and the other g_spawn*() functions are in UTF-8, the
19988 // GLib file name encoding. Unicode characters that are not part of
19989 // the system codepage passed in these arguments will be correctly
19990 // available in the spawned program only if it uses wide character API
19991 // to retrieve its command line. For C programs built with Microsoft's
19992 // tools it is enough to make the program have a wmain() instead of
19993 // main(). wmain() has a wide character argument vector as parameter.
19995 // At least currently, mingw doesn't support wmain(), so if you use
19996 // mingw to develop the spawned program, it will have to call the
19997 // undocumented function __wgetmainargs() to get the wide character
19998 // argument vector and environment. See gspawn-win32-helper.c in the
19999 // GLib sources or init.c in the mingw runtime sources for a prototype
20000 // for that function. Alternatively, you can retrieve the Win32 system
20001 // level wide character command line passed to the spawned program
20002 // using the GetCommandLineW() function.
20004 // On Windows the low-level child process creation API
20005 // <function>CreateProcess()</function> doesn't use argument vectors,
20006 // but a command line. The C runtime library's
20007 // <function>spawn*()</function> family of functions (which
20008 // g_spawn_async_with_pipes() eventually calls) paste the argument
20009 // vector elements together into a command line, and the C runtime startup code
20010 // does a corresponding reconstruction of an argument vector from the
20011 // command line, to be passed to main(). Complications arise when you have
20012 // argument vector elements that contain spaces of double quotes. The
20013 // <function>spawn*()</function> functions don't do any quoting or
20014 // escaping, but on the other hand the startup code does do unquoting
20015 // and unescaping in order to enable receiving arguments with embedded
20016 // spaces or double quotes. To work around this asymmetry,
20017 // g_spawn_async_with_pipes() will do quoting and escaping on argument
20018 // vector elements that need it before calling the C runtime
20019 // spawn() function.
20021 // The returned @child_pid on Windows is a handle to the child
20022 // process, not its identifier. Process handles and process
20023 // identifiers are different concepts on Windows.
20025 // @envp is a %NULL-terminated array of strings, where each string
20026 // has the form <literal>KEY=VALUE</literal>. This will become
20027 // the child's environment. If @envp is %NULL, the child inherits its
20028 // parent's environment.
20030 // @flags should be the bitwise OR of any flags you want to affect the
20031 // function's behaviour. The %G_SPAWN_DO_NOT_REAP_CHILD means that
20032 // the child will not automatically be reaped; you must use a
20033 // #GChildWatch source to be notified about the death of the child
20034 // process. Eventually you must call g_spawn_close_pid() on the
20035 // @child_pid, in order to free resources which may be associated
20036 // with the child process. (On Unix, using a #GChildWatch source is
20037 // equivalent to calling waitpid() or handling the %SIGCHLD signal
20038 // manually. On Windows, calling g_spawn_close_pid() is equivalent
20039 // to calling CloseHandle() on the process handle returned in
20040 // @child_pid).
20042 // %G_SPAWN_LEAVE_DESCRIPTORS_OPEN means that the parent's open file
20043 // descriptors will be inherited by the child; otherwise all
20044 // descriptors except stdin/stdout/stderr will be closed before
20045 // calling exec() in the child. %G_SPAWN_SEARCH_PATH
20046 // means that <literal>argv[0]</literal> need not be an absolute path, it
20047 // will be looked for in the user's <envar>PATH</envar>.
20048 // %G_SPAWN_STDOUT_TO_DEV_NULL means that the child's standard output will
20049 // be discarded, instead of going to the same location as the parent's
20050 // standard output. If you use this flag, @standard_output must be %NULL.
20051 // %G_SPAWN_STDERR_TO_DEV_NULL means that the child's standard error
20052 // will be discarded, instead of going to the same location as the parent's
20053 // standard error. If you use this flag, @standard_error must be %NULL.
20054 // %G_SPAWN_CHILD_INHERITS_STDIN means that the child will inherit the parent's
20055 // standard input (by default, the child's standard input is attached to
20056 // /dev/null). If you use this flag, @standard_input must be %NULL.
20057 // %G_SPAWN_FILE_AND_ARGV_ZERO means that the first element of @argv is
20058 // the file to execute, while the remaining elements are the
20059 // actual argument vector to pass to the file. Normally
20060 // g_spawn_async_with_pipes() uses @argv[0] as the file to execute, and
20061 // passes all of @argv to the child.
20063 // @child_setup and @user_data are a function and user data. On POSIX
20064 // platforms, the function is called in the child after GLib has
20065 // performed all the setup it plans to perform (including creating
20066 // pipes, closing file descriptors, etc.) but before calling
20067 // exec(). That is, @child_setup is called just
20068 // before calling exec() in the child. Obviously
20069 // actions taken in this function will only affect the child, not the
20070 // parent.
20072 // On Windows, there is no separate fork() and exec()
20073 // functionality. Child processes are created and run with a single
20074 // API call, CreateProcess(). There is no sensible thing @child_setup
20075 // could be used for on Windows so it is ignored and not called.
20077 // If non-%NULL, @child_pid will on Unix be filled with the child's
20078 // process ID. You can use the process ID to send signals to the
20079 // child, or to use g_child_watch_add() (or waitpid()) if you specified the
20080 // %G_SPAWN_DO_NOT_REAP_CHILD flag. On Windows, @child_pid will be
20081 // filled with a handle to the child process only if you specified the
20082 // %G_SPAWN_DO_NOT_REAP_CHILD flag. You can then access the child
20083 // process using the Win32 API, for example wait for its termination
20084 // with the <function>WaitFor*()</function> functions, or examine its
20085 // exit code with GetExitCodeProcess(). You should close the handle
20086 // with CloseHandle() or g_spawn_close_pid() when you no longer need it.
20088 // If non-%NULL, the @standard_input, @standard_output, @standard_error
20089 // locations will be filled with file descriptors for writing to the child's
20090 // standard input or reading from its standard output or standard error.
20091 // The caller of g_spawn_async_with_pipes() must close these file descriptors
20092 // when they are no longer in use. If these parameters are %NULL, the corresponding
20093 // pipe won't be created.
20095 // If @standard_input is NULL, the child's standard input is attached to
20096 // /dev/null unless %G_SPAWN_CHILD_INHERITS_STDIN is set.
20098 // If @standard_error is NULL, the child's standard error goes to the same
20099 // location as the parent's standard error unless %G_SPAWN_STDERR_TO_DEV_NULL
20100 // is set.
20102 // If @standard_output is NULL, the child's standard output goes to the same
20103 // location as the parent's standard output unless %G_SPAWN_STDOUT_TO_DEV_NULL
20104 // is set.
20106 // @error can be %NULL to ignore errors, or non-%NULL to report errors.
20107 // If an error is set, the function returns %FALSE. Errors
20108 // are reported even if they occur in the child (for example if the
20109 // executable in <literal>argv[0]</literal> is not found). Typically
20110 // the <literal>message</literal> field of returned errors should be displayed
20111 // to users. Possible errors are those from the #G_SPAWN_ERROR domain.
20113 // If an error occurs, @child_pid, @standard_input, @standard_output,
20114 // and @standard_error will not be filled with valid values.
20116 // If @child_pid is not %NULL and an error does not occur then the returned
20117 // process reference must be closed using g_spawn_close_pid().
20119 // <note><para>
20120 // If you are writing a GTK+ application, and the program you
20121 // are spawning is a graphical application, too, then you may
20122 // want to use gdk_spawn_on_screen_with_pipes() instead to ensure that
20123 // the spawned program opens its windows on the right screen.
20124 // </para></note>
20125 // RETURNS: %TRUE on success, %FALSE if an error was set
20126 // <working_directory>: child's current working directory, or %NULL to inherit parent's, in the GLib file name encoding
20127 // <argv>: child's argument vector, in the GLib file name encoding
20128 // <envp>: child's environment, or %NULL to inherit parent's, in the GLib file name encoding
20129 // <flags>: flags from #GSpawnFlags
20130 // <child_setup>: function to run in the child just before exec()
20131 // <user_data>: user data for @child_setup
20132 // <child_pid>: return location for child process ID, or %NULL
20133 // <standard_input>: return location for file descriptor to write to child's stdin, or %NULL
20134 // <standard_output>: return location for file descriptor to read child's stdout, or %NULL
20135 // <standard_error>: return location for file descriptor to read child's stderr, or %NULL
20136 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) {
20137 return g_spawn_async_with_pipes(working_directory, argv, envp, flags, child_setup, user_data, child_pid, standard_input, standard_output, standard_error, error);
20141 // On some platforms, notably Windows, the #GPid type represents a resource
20142 // which must be closed to prevent resource leaking. g_spawn_close_pid()
20143 // is provided for this purpose. It should be used on all platforms, even
20144 // though it doesn't do anything under UNIX.
20145 // <pid>: The process reference to close
20146 static void spawn_close_pid()(Pid pid) {
20147 g_spawn_close_pid(pid);
20151 // A simple version of g_spawn_async() that parses a command line with
20152 // g_shell_parse_argv() and passes it to g_spawn_async(). Runs a
20153 // command line in the background. Unlike g_spawn_async(), the
20154 // %G_SPAWN_SEARCH_PATH flag is enabled, other flags are not. Note
20155 // that %G_SPAWN_SEARCH_PATH can have security implications, so
20156 // consider using g_spawn_async() directly if appropriate. Possible
20157 // errors are those from g_shell_parse_argv() and g_spawn_async().
20159 // The same concerns on Windows apply as for g_spawn_command_line_sync().
20160 // RETURNS: %TRUE on success, %FALSE if error is set.
20161 // <command_line>: a command line
20162 static int spawn_command_line_async()(char* command_line, GLib2.Error** error=null) {
20163 return g_spawn_command_line_async(command_line, error);
20167 // A simple version of g_spawn_sync() with little-used parameters
20168 // removed, taking a command line instead of an argument vector. See
20169 // g_spawn_sync() for full details. @command_line will be parsed by
20170 // g_shell_parse_argv(). Unlike g_spawn_sync(), the %G_SPAWN_SEARCH_PATH flag
20171 // is enabled. Note that %G_SPAWN_SEARCH_PATH can have security
20172 // implications, so consider using g_spawn_sync() directly if
20173 // appropriate. Possible errors are those from g_spawn_sync() and those
20174 // from g_shell_parse_argv().
20176 // If @exit_status is non-%NULL, the exit status of the child is stored there as
20177 // it would be returned by waitpid(); standard UNIX macros such as WIFEXITED()
20178 // and WEXITSTATUS() must be used to evaluate the exit status.
20180 // On Windows, please note the implications of g_shell_parse_argv()
20181 // parsing @command_line. Parsing is done according to Unix shell rules, not
20182 // Windows command interpreter rules.
20183 // Space is a separator, and backslashes are
20184 // special. Thus you cannot simply pass a @command_line containing
20185 // canonical Windows paths, like "c:\\program files\\app\\app.exe", as
20186 // the backslashes will be eaten, and the space will act as a
20187 // separator. You need to enclose such paths with single quotes, like
20188 // "'c:\\program files\\app\\app.exe' 'e:\\folder\\argument.txt'".
20189 // RETURNS: %TRUE on success, %FALSE if an error was set
20190 // <command_line>: a command line
20191 // <standard_output>: return location for child output
20192 // <standard_error>: return location for child errors
20193 // <exit_status>: return location for child exit status, as returned by waitpid()
20194 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) {
20195 return g_spawn_command_line_sync(command_line, standard_output, standard_error, exit_status, error);
20198 static Quark spawn_error_quark()() {
20199 return g_spawn_error_quark();
20203 // Executes a child synchronously (waits for the child to exit before returning).
20204 // All output from the child is stored in @standard_output and @standard_error,
20205 // if those parameters are non-%NULL. Note that you must set the
20206 // %G_SPAWN_STDOUT_TO_DEV_NULL and %G_SPAWN_STDERR_TO_DEV_NULL flags when
20207 // passing %NULL for @standard_output and @standard_error.
20208 // If @exit_status is non-%NULL, the exit status of the child is stored
20209 // there as it would be returned by waitpid(); standard UNIX macros such
20210 // as WIFEXITED() and WEXITSTATUS() must be used to evaluate the exit status.
20211 // Note that this function call waitpid() even if @exit_status is %NULL, and
20212 // does not accept the %G_SPAWN_DO_NOT_REAP_CHILD flag.
20213 // If an error occurs, no data is returned in @standard_output,
20214 // @standard_error, or @exit_status.
20216 // This function calls g_spawn_async_with_pipes() internally; see that
20217 // function for full details on the other parameters and details on
20218 // how these functions work on Windows.
20219 // RETURNS: %TRUE on success, %FALSE if an error was set.
20220 // <working_directory>: child's current working directory, or %NULL to inherit parent's
20221 // <argv>: child's argument vector
20222 // <envp>: child's environment, or %NULL to inherit parent's
20223 // <flags>: flags from #GSpawnFlags
20224 // <child_setup>: function to run in the child just before exec()
20225 // <user_data>: user data for @child_setup
20226 // <standard_output>: return location for child output, or %NULL
20227 // <standard_error>: return location for child error messages, or %NULL
20228 // <exit_status>: return location for child exit status, as returned by waitpid(), or %NULL
20229 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) {
20230 return g_spawn_sync(working_directory, argv, envp, flags, child_setup, user_data, standard_output, standard_error, exit_status, error);
20234 // Unintrospectable function: sprintf() / g_sprintf()
20235 // VERSION: 2.2
20236 // An implementation of the standard sprintf() function which supports
20237 // positional parameters, as specified in the Single Unix Specification.
20239 // Note that it is usually better to use g_snprintf(), to avoid the
20240 // risk of buffer overflow.
20242 // See also g_strdup_printf().
20243 // RETURNS: the number of bytes printed.
20244 // <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
20245 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
20246 alias g_sprintf sprintf; // Variadic
20249 // Copies a nul-terminated string into the dest buffer, include the
20250 // trailing nul, and return a pointer to the trailing nul byte.
20251 // This is useful for concatenating multiple strings together
20252 // without having to repeatedly scan for the end.
20253 // RETURNS: a pointer to trailing nul byte.
20254 // <dest>: destination buffer.
20255 // <src>: source string.
20256 static char* /*new*/ stpcpy()(char* dest, char* src) {
20257 return g_stpcpy(dest, src);
20261 // Compares two strings for byte-by-byte equality and returns %TRUE
20262 // if they are equal. It can be passed to g_hash_table_new() as the
20263 // @key_equal_func parameter, when using strings as keys in a #GHashTable.
20265 // Note that this function is primarily meant as a hash table comparison
20266 // function. For a general-purpose, %NULL-safe string comparison function,
20267 // see g_strcmp0().
20268 // RETURNS: %TRUE if the two keys match
20269 // <v1>: a key
20270 // <v2>: a key to compare with @v1
20271 static int str_equal()(const(void)* v1, const(void)* v2) {
20272 return g_str_equal(v1, v2);
20276 // VERSION: 2.2
20277 // Looks whether the string @str begins with @prefix.
20278 // RETURNS: %TRUE if @str begins with @prefix, %FALSE otherwise.
20279 // <str>: a nul-terminated string.
20280 // <prefix>: the nul-terminated prefix to look for.
20281 static int str_has_prefix()(char* str, char* prefix) {
20282 return g_str_has_prefix(str, prefix);
20286 // VERSION: 2.2
20287 // Looks whether the string @str ends with @suffix.
20288 // RETURNS: %TRUE if @str end with @suffix, %FALSE otherwise.
20289 // <str>: a nul-terminated string.
20290 // <suffix>: the nul-terminated suffix to look for.
20291 static int str_has_suffix()(char* str, char* suffix) {
20292 return g_str_has_suffix(str, suffix);
20296 // Converts a string to a hash value.
20298 // This function implements the widely used "djb" hash apparently posted
20299 // by Daniel Bernstein to comp.lang.c some time ago. The 32 bit
20300 // unsigned hash value starts at 5381 and for each byte 'c' in the
20301 // string, is updated: <literal>hash = hash * 33 + c</literal>. This
20302 // function uses the signed value of each byte.
20304 // It can be passed to g_hash_table_new() as the @hash_func parameter,
20305 // when using strings as keys in a #GHashTable.
20306 // RETURNS: a hash value corresponding to the key
20307 // <v>: a string key
20308 static uint str_hash()(const(void)* v) {
20309 return g_str_hash(v);
20312 static char* /*new*/ strcanon()(char* string_, char* valid_chars, char substitutor) {
20313 return g_strcanon(string_, valid_chars, substitutor);
20317 // A case-insensitive string comparison, corresponding to the standard
20318 // strcasecmp() function on platforms which support it.
20320 // or a positive value if @s1 &gt; @s2.
20322 // Deprecated:2.2: See g_strncasecmp() for a discussion of why this function
20323 // is deprecated and how to replace it.
20324 // RETURNS: 0 if the strings match, a negative value if @s1 &lt; @s2,
20325 // <s1>: a string.
20326 // <s2>: a string to compare with @s1.
20327 static int strcasecmp()(char* s1, char* s2) {
20328 return g_strcasecmp(s1, s2);
20331 static char* /*new*/ strchomp()(char* string_) {
20332 return g_strchomp(string_);
20335 static char* /*new*/ strchug()(char* string_) {
20336 return g_strchug(string_);
20340 // VERSION: 2.16
20341 // Compares @str1 and @str2 like strcmp(). Handles %NULL
20342 // gracefully by sorting it before non-%NULL strings.
20343 // Comparing two %NULL pointers returns 0.
20344 // RETURNS: -1, 0 or 1, if @str1 is <, == or > than @str2.
20345 // <str1>: a C string or %NULL
20346 // <str2>: another C string or %NULL
20347 static int strcmp0()(char* str1, char* str2) {
20348 return g_strcmp0(str1, str2);
20351 static char* /*new*/ strcompress()(char* source) {
20352 return g_strcompress(source);
20356 // Unintrospectable function: strconcat() / g_strconcat()
20357 // Concatenates all of the given strings into one long string.
20358 // The returned string should be freed with g_free() when no longer needed.
20360 // Note that this function is usually not the right function to use to
20361 // assemble a translated message from pieces, since proper translation
20362 // often requires the pieces to be reordered.
20364 // <warning><para>The variable argument list <emphasis>must</emphasis> end
20365 // with %NULL. If you forget the %NULL, g_strconcat() will start appending
20366 // random memory junk to your string.</para></warning>
20367 // RETURNS: a newly-allocated string containing all the string arguments
20368 // <string1>: the first string to add, which must not be %NULL
20369 alias g_strconcat strconcat; // Variadic
20371 static char* /*new*/ strdelimit()(char* string_, char* delimiters, char new_delimiter) {
20372 return g_strdelimit(string_, delimiters, new_delimiter);
20376 // Converts a string to lower case.
20379 // Deprecated:2.2: This function is totally broken for the reasons discussed
20380 // in the g_strncasecmp() docs - use g_ascii_strdown() or g_utf8_strdown()
20381 // instead.
20382 // RETURNS: the string
20383 // <string>: the string to convert.
20384 static char* /*new*/ strdown()(char* string_) {
20385 return g_strdown(string_);
20389 // Duplicates a string. If @str is %NULL it returns %NULL.
20390 // The returned string should be freed with g_free()
20391 // when no longer needed.
20392 // RETURNS: a newly-allocated copy of @str
20393 // <str>: the string to duplicate
20394 static char* /*new*/ strdup()(char* str) {
20395 return g_strdup(str);
20399 // Unintrospectable function: strdup_printf() / g_strdup_printf()
20400 // Similar to the standard C sprintf() function but safer, since it
20401 // calculates the maximum space required and allocates memory to hold
20402 // the result. The returned string should be freed with g_free() when no
20403 // longer needed.
20404 // RETURNS: a newly-allocated string holding the result
20405 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>
20406 alias g_strdup_printf strdup_printf; // Variadic
20409 // Unintrospectable function: strdup_vprintf() / g_strdup_vprintf()
20410 // Similar to the standard C vsprintf() function but safer, since it
20411 // calculates the maximum space required and allocates memory to hold
20412 // the result. The returned string should be freed with g_free() when
20413 // no longer needed.
20415 // See also g_vasprintf(), which offers the same functionality, but
20416 // additionally returns the length of the allocated string.
20417 // RETURNS: a newly-allocated string holding the result
20418 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>
20419 // <args>: the list of parameters to insert into the format string
20420 static char* /*new*/ strdup_vprintf()(char* format, va_list args) {
20421 return g_strdup_vprintf(format, args);
20425 // Unintrospectable function: strdupv() / g_strdupv()
20426 // Copies %NULL-terminated array of strings. The copy is a deep copy;
20427 // the new array should be freed by first freeing each string, then
20428 // the array itself. g_strfreev() does this for you. If called
20429 // on a %NULL value, g_strdupv() simply returns %NULL.
20430 // RETURNS: a new %NULL-terminated array of strings.
20431 // <str_array>: %NULL-terminated array of strings.
20432 static char** strdupv()(char** str_array) {
20433 return g_strdupv(str_array);
20437 // Returns a string corresponding to the given error code, e.g.
20438 // "no such process". You should use this function in preference to
20439 // strerror(), because it returns a string in UTF-8 encoding, and since
20440 // not all platforms support the strerror() function.
20442 // is unknown, it returns "unknown error (&lt;code&gt;)". The string
20443 // can only be used until the next call to g_strerror()
20444 // RETURNS: a UTF-8 string describing the error code. If the error code
20445 // <errnum>: the system error number. See the standard C %errno documentation
20446 static char* strerror()(int errnum) {
20447 return g_strerror(errnum);
20450 static char* /*new*/ strescape()(char* source, char* exceptions) {
20451 return g_strescape(source, exceptions);
20454 // <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.
20455 static void strfreev()(char** str_array) {
20456 g_strfreev(str_array);
20460 // Creates a new #GString, initialized with the given string.
20461 // RETURNS: the new #GString
20462 // <init>: the initial text to copy into the string
20463 static String* /*new*/ string_new()(char* init) {
20464 return g_string_new(init);
20468 // Creates a new #GString with @len bytes of the @init buffer.
20469 // Because a length is provided, @init need not be nul-terminated,
20470 // and can contain embedded nul bytes.
20472 // Since this function does not stop at nul bytes, it is the caller's
20473 // responsibility to ensure that @init has at least @len addressable
20474 // bytes.
20475 // RETURNS: a new #GString
20476 // <init>: initial contents of the string
20477 // <len>: length of @init to use
20478 static String* /*new*/ string_new_len()(char* init, ssize_t len) {
20479 return g_string_new_len(init, len);
20483 // Creates a new #GString, with enough space for @dfl_size
20484 // bytes. This is useful if you are going to add a lot of
20485 // text to the string and don't want it to be reallocated
20486 // too often.
20487 // RETURNS: the new #GString
20488 // <dfl_size>: the default size of the space allocated to hold the string
20489 static String* /*new*/ string_sized_new()(size_t dfl_size) {
20490 return g_string_sized_new(dfl_size);
20494 // VERSION: 2.4
20495 // An auxiliary function for gettext() support (see Q_()).
20497 // a '|' character, in which case a pointer to the substring of msgid after
20498 // the first '|' character is returned.
20499 // RETURNS: @msgval, unless @msgval is identical to @msgid and contains
20500 // <msgid>: a string
20501 // <msgval>: another string
20502 static char* strip_context()(char* msgid, char* msgval) {
20503 return g_strip_context(msgid, msgval);
20507 // Unintrospectable function: strjoin() / g_strjoin()
20508 // Joins a number of strings together to form one long string, with the
20509 // optional @separator inserted between each of them. The returned string
20510 // should be freed with g_free().
20512 // together, with @separator between them
20513 // RETURNS: a newly-allocated string containing all of the strings joined
20514 // <separator>: a string to insert between each of the strings, or %NULL
20515 alias g_strjoin strjoin; // Variadic
20518 // Joins a number of strings together to form one long string, with the
20519 // optional @separator inserted between each of them. The returned string
20520 // should be freed with g_free().
20522 // together, with @separator between them
20523 // RETURNS: a newly-allocated string containing all of the strings joined
20524 // <separator>: a string to insert between each of the strings, or %NULL
20525 // <str_array>: a %NULL-terminated array of strings to join
20526 static char* /*new*/ strjoinv()(char* separator, char** str_array) {
20527 return g_strjoinv(separator, str_array);
20531 // Portability wrapper that calls strlcat() on systems which have it,
20532 // and emulates it otherwise. Appends nul-terminated @src string to @dest,
20533 // guaranteeing nul-termination for @dest. The total size of @dest won't
20534 // exceed @dest_size.
20536 // At most dest_size - 1 characters will be copied.
20537 // Unlike strncat, dest_size is the full size of dest, not the space left over.
20538 // This function does NOT allocate memory.
20539 // This always NUL terminates (unless siz == 0 or there were no NUL characters
20540 // in the dest_size characters of dest to start with).
20542 // <note><para>Caveat: this is supposedly a more secure alternative to
20543 // strcat() or strncat(), but for real security g_strconcat() is harder
20544 // to mess up.</para></note>
20546 // (original dest)) + strlen (src), so if retval >= dest_size,
20547 // truncation occurred.
20548 // RETURNS: size of attempted result, which is MIN (dest_size, strlen
20549 // <dest>: destination buffer, already containing one nul-terminated string
20550 // <src>: source buffer
20551 // <dest_size>: length of @dest buffer in bytes (not length of existing string inside @dest)
20552 static size_t strlcat()(char* dest, char* src, size_t dest_size) {
20553 return g_strlcat(dest, src, dest_size);
20557 // Portability wrapper that calls strlcpy() on systems which have it,
20558 // and emulates strlcpy() otherwise. Copies @src to @dest; @dest is
20559 // guaranteed to be nul-terminated; @src must be nul-terminated;
20560 // @dest_size is the buffer size, not the number of chars to copy.
20562 // At most dest_size - 1 characters will be copied. Always nul-terminates
20563 // (unless dest_size == 0). This function does <emphasis>not</emphasis>
20564 // allocate memory. Unlike strncpy(), this function doesn't pad dest (so
20565 // it's often faster). It returns the size of the attempted result,
20566 // strlen (src), so if @retval >= @dest_size, truncation occurred.
20568 // <note><para>Caveat: strlcpy() is supposedly more secure than
20569 // strcpy() or strncpy(), but if you really want to avoid screwups,
20570 // g_strdup() is an even better idea.</para></note>
20571 // RETURNS: length of @src
20572 // <dest>: destination buffer
20573 // <src>: source buffer
20574 // <dest_size>: length of @dest in bytes
20575 static size_t strlcpy()(char* dest, char* src, size_t dest_size) {
20576 return g_strlcpy(dest, src, dest_size);
20580 // A case-insensitive string comparison, corresponding to the standard
20581 // strncasecmp() function on platforms which support it.
20582 // It is similar to g_strcasecmp() except it only compares the first @n
20583 // characters of the strings.
20585 // or a positive value if @s1 &gt; @s2.
20587 // Deprecated:2.2: The problem with g_strncasecmp() is that it does the
20588 // comparison by calling toupper()/tolower(). These functions are
20589 // locale-specific and operate on single bytes. However, it is impossible
20590 // to handle things correctly from an I18N standpoint by operating on
20591 // bytes, since characters may be multibyte. Thus g_strncasecmp() is
20592 // broken if your string is guaranteed to be ASCII, since it's
20593 // locale-sensitive, and it's broken if your string is localized, since
20594 // it doesn't work on many encodings at all, including UTF-8, EUC-JP,
20595 // etc.
20597 // There are therefore two replacement functions: g_ascii_strncasecmp(),
20598 // which only works on ASCII and is not locale-sensitive, and
20599 // g_utf8_casefold(), which is good for case-insensitive sorting of UTF-8.
20600 // RETURNS: 0 if the strings match, a negative value if @s1 &lt; @s2,
20601 // <s1>: a string.
20602 // <s2>: a string to compare with @s1.
20603 // <n>: the maximum number of characters to compare.
20604 static int strncasecmp()(char* s1, char* s2, uint n) {
20605 return g_strncasecmp(s1, s2, n);
20609 // Duplicates the first @n bytes of a string, returning a newly-allocated
20610 // buffer @n + 1 bytes long which will always be nul-terminated.
20611 // If @str is less than @n bytes long the buffer is padded with nuls.
20612 // If @str is %NULL it returns %NULL.
20613 // The returned value should be freed when no longer needed.
20615 // <note><para>
20616 // To copy a number of characters from a UTF-8 encoded string, use
20617 // g_utf8_strncpy() instead.
20618 // </para></note>
20620 // of @str, nul-terminated
20621 // RETURNS: a newly-allocated buffer containing the first @n bytes
20622 // <str>: the string to duplicate
20623 // <n>: the maximum number of bytes to copy from @str
20624 static char* /*new*/ strndup()(char* str, size_t n) {
20625 return g_strndup(str, n);
20629 // Creates a new string @length bytes long filled with @fill_char.
20630 // The returned string should be freed when no longer needed.
20631 // RETURNS: a newly-allocated string filled the @fill_char
20632 // <length>: the length of the new string
20633 // <fill_char>: the byte to fill the string with
20634 static char* /*new*/ strnfill()(size_t length, char fill_char) {
20635 return g_strnfill(length, fill_char);
20639 // Reverses all of the bytes in a string. For example,
20640 // <literal>g_strreverse ("abcdef")</literal> will result
20641 // in "fedcba".
20643 // Note that g_strreverse() doesn't work on UTF-8 strings
20644 // containing multibyte characters. For that purpose, use
20645 // g_utf8_strreverse().
20646 // RETURNS: the same pointer passed in as @string
20647 // <string>: the string to reverse
20648 static char* /*new*/ strreverse()(char* string_) {
20649 return g_strreverse(string_);
20653 // Searches the string @haystack for the last occurrence
20654 // of the string @needle.
20656 // %NULL if not found.
20657 // RETURNS: a pointer to the found occurrence, or
20658 // <haystack>: a nul-terminated string.
20659 // <needle>: the nul-terminated string to search for.
20660 static char* /*new*/ strrstr()(char* haystack, char* needle) {
20661 return g_strrstr(haystack, needle);
20665 // Searches the string @haystack for the last occurrence
20666 // of the string @needle, limiting the length of the search
20667 // to @haystack_len.
20669 // %NULL if not found.
20670 // RETURNS: a pointer to the found occurrence, or
20671 // <haystack>: a nul-terminated string.
20672 // <haystack_len>: the maximum length of @haystack.
20673 // <needle>: the nul-terminated string to search for.
20674 static char* /*new*/ strrstr_len()(char* haystack, ssize_t haystack_len, char* needle) {
20675 return g_strrstr_len(haystack, haystack_len, needle);
20679 // Returns a string describing the given signal, e.g. "Segmentation fault".
20680 // You should use this function in preference to strsignal(), because it
20681 // returns a string in UTF-8 encoding, and since not all platforms support
20682 // the strsignal() function.
20684 // it returns "unknown signal (&lt;signum&gt;)". The string can only be
20685 // used until the next call to g_strsignal()
20686 // RETURNS: a UTF-8 string describing the signal. If the signal is unknown,
20687 // <signum>: the signal number. See the <literal>signal</literal> documentation
20688 static char* strsignal()(int signum) {
20689 return g_strsignal(signum);
20693 // Unintrospectable function: strsplit() / g_strsplit()
20694 // Splits a string into a maximum of @max_tokens pieces, using the given
20695 // @delimiter. If @max_tokens is reached, the remainder of @string is appended
20696 // to the last token.
20698 // As a special case, the result of splitting the empty string "" is an empty
20699 // vector, not a vector containing a single string. The reason for this
20700 // special case is that being able to represent a empty vector is typically
20701 // more useful than consistent handling of empty elements. If you do need
20702 // to represent empty elements, you'll need to check for the empty string
20703 // before calling g_strsplit().
20705 // g_strfreev() to free it.
20706 // RETURNS: a newly-allocated %NULL-terminated array of strings. Use
20707 // <string>: a string to split.
20708 // <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.
20709 // <max_tokens>: the maximum number of pieces to split @string into. If this is less than 1, the string is split completely.
20710 static char** strsplit()(char* string_, char* delimiter, int max_tokens) {
20711 return g_strsplit(string_, delimiter, max_tokens);
20715 // Unintrospectable function: strsplit_set() / g_strsplit_set()
20716 // VERSION: 2.4
20717 // Splits @string into a number of tokens not containing any of the characters
20718 // in @delimiter. A token is the (possibly empty) longest string that does not
20719 // contain any of the characters in @delimiters. If @max_tokens is reached, the
20720 // remainder is appended to the last token.
20722 // For example the result of g_strsplit_set ("abc:def/ghi", ":/", -1) is a
20723 // %NULL-terminated vector containing the three strings "abc", "def",
20724 // and "ghi".
20726 // The result if g_strsplit_set (":def/ghi:", ":/", -1) is a %NULL-terminated
20727 // vector containing the four strings "", "def", "ghi", and "".
20729 // As a special case, the result of splitting the empty string "" is an empty
20730 // vector, not a vector containing a single string. The reason for this
20731 // special case is that being able to represent a empty vector is typically
20732 // more useful than consistent handling of empty elements. If you do need
20733 // to represent empty elements, you'll need to check for the empty string
20734 // before calling g_strsplit_set().
20736 // Note that this function works on bytes not characters, so it can't be used
20737 // to delimit UTF-8 strings for anything but ASCII characters.
20739 // g_strfreev() to free it.
20740 // RETURNS: a newly-allocated %NULL-terminated array of strings. Use
20741 // <string>: The string to be tokenized
20742 // <delimiters>: A nul-terminated string containing bytes that are used to split the string.
20743 // <max_tokens>: The maximum number of tokens to split @string into. If this is less than 1, the string is split completely
20744 static char** strsplit_set()(char* string_, char* delimiters, int max_tokens) {
20745 return g_strsplit_set(string_, delimiters, max_tokens);
20749 // Searches the string @haystack for the first occurrence
20750 // of the string @needle, limiting the length of the search
20751 // to @haystack_len.
20753 // %NULL if not found.
20754 // RETURNS: a pointer to the found occurrence, or
20755 // <haystack>: a string.
20756 // <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.
20757 // <needle>: the string to search for.
20758 static char* /*new*/ strstr_len()(char* haystack, ssize_t haystack_len, char* needle) {
20759 return g_strstr_len(haystack, haystack_len, needle);
20763 // Converts a string to a #gdouble value.
20764 // It calls the standard strtod() function to handle the conversion, but
20765 // if the string is not completely converted it attempts the conversion
20766 // again with g_ascii_strtod(), and returns the best match.
20768 // This function should seldom be used. The normal situation when reading
20769 // numbers not for human consumption is to use g_ascii_strtod(). Only when
20770 // you know that you must expect both locale formatted and C formatted numbers
20771 // should you use this. Make sure that you don't pass strings such as comma
20772 // separated lists of values, since the commas may be interpreted as a decimal
20773 // point in some locales, causing unexpected results.
20774 // RETURNS: the #gdouble value.
20775 // <nptr>: the string to convert to a numeric value.
20776 // <endptr>: if non-%NULL, it returns the character after the last character used in the conversion.
20777 static double strtod()(char* nptr, char** endptr) {
20778 return g_strtod(nptr, endptr);
20782 // Converts a string to upper case.
20785 // Deprecated:2.2: This function is totally broken for the reasons discussed
20786 // in the g_strncasecmp() docs - use g_ascii_strup() or g_utf8_strup() instead.
20787 // RETURNS: the string
20788 // <string>: the string to convert.
20789 static char* /*new*/ strup()(char* string_) {
20790 return g_strup(string_);
20793 static Type strv_get_type()() {
20794 return g_strv_get_type();
20798 // VERSION: 2.6
20799 // Returns the length of the given %NULL-terminated
20800 // string array @str_array.
20801 // RETURNS: length of @str_array.
20802 // <str_array>: a %NULL-terminated array of strings.
20803 static uint strv_length()(char** str_array) {
20804 return g_strv_length(str_array);
20808 // Unintrospectable function: test_add_data_func() / g_test_add_data_func()
20809 // VERSION: 2.16
20810 // Create a new test case, similar to g_test_create_case(). However
20811 // the test is assumed to use no fixture, and test suites are automatically
20812 // created on the fly and added to the root fixture, based on the
20813 // slash-separated portions of @testpath. The @test_data argument
20814 // will be passed as first argument to @test_func.
20815 // <testpath>: Slash-separated test case path name for the test.
20816 // <test_data>: Test data argument for the test function.
20817 // <test_func>: The test function to invoke for this test.
20818 static void test_add_data_func()(char* testpath, const(void)* test_data, TestDataFunc test_func) {
20819 g_test_add_data_func(testpath, test_data, test_func);
20823 // Unintrospectable function: test_add_func() / g_test_add_func()
20824 // VERSION: 2.16
20825 // Create a new test case, similar to g_test_create_case(). However
20826 // the test is assumed to use no fixture, and test suites are automatically
20827 // created on the fly and added to the root fixture, based on the
20828 // slash-separated portions of @testpath.
20829 // <testpath>: Slash-separated test case path name for the test.
20830 // <test_func>: The test function to invoke for this test.
20831 static void test_add_func()(char* testpath, TestFunc test_func) {
20832 g_test_add_func(testpath, test_func);
20835 // Unintrospectable function: test_add_vtable() / g_test_add_vtable()
20836 static void test_add_vtable()(char* testpath, size_t data_size, const(void)* test_data, TestFixtureFunc data_setup, TestFixtureFunc data_test, TestFixtureFunc data_teardown) {
20837 g_test_add_vtable(testpath, data_size, test_data, data_setup, data_test, data_teardown);
20841 // VERSION: 2.16
20842 // This function adds a message to test reports that
20843 // associates a bug URI with a test case.
20844 // Bug URIs are constructed from a base URI set with g_test_bug_base()
20845 // and @bug_uri_snippet.
20846 // <bug_uri_snippet>: Bug specific bug tracker URI portion.
20847 static void test_bug()(char* bug_uri_snippet) {
20848 g_test_bug(bug_uri_snippet);
20852 // VERSION: 2.16
20853 // Specify the base URI for bug reports.
20855 // The base URI is used to construct bug report messages for
20856 // g_test_message() when g_test_bug() is called.
20857 // Calling this function outside of a test case sets the
20858 // default base URI for all test cases. Calling it from within
20859 // a test case changes the base URI for the scope of the test
20860 // case only.
20861 // Bug URIs are constructed by appending a bug specific URI
20862 // portion to @uri_pattern, or by replacing the special string
20863 // '%s' within @uri_pattern if that is present.
20864 // <uri_pattern>: the base pattern for bug URIs
20865 static void test_bug_base()(char* uri_pattern) {
20866 g_test_bug_base(uri_pattern);
20870 // Unintrospectable function: test_create_case() / g_test_create_case()
20871 // VERSION: 2.16
20872 // Create a new #GTestCase, named @test_name, this API is fairly
20873 // low level, calling g_test_add() or g_test_add_func() is preferable.
20874 // When this test is executed, a fixture structure of size @data_size
20875 // will be allocated and filled with 0s. Then data_setup() is called
20876 // to initialize the fixture. After fixture setup, the actual test
20877 // function data_test() is called. Once the test run completed, the
20878 // fixture structure is torn down by calling data_teardown() and
20879 // after that the memory is released.
20881 // Splitting up a test run into fixture setup, test function and
20882 // fixture teardown is most usful if the same fixture is used for
20883 // multiple tests. In this cases, g_test_create_case() will be
20884 // called with the same fixture, but varying @test_name and
20885 // @data_test arguments.
20886 // RETURNS: a newly allocated #GTestCase.
20887 // <test_name>: the name for the test case
20888 // <data_size>: the size of the fixture data structure
20889 // <test_data>: test data argument for the test functions
20890 // <data_setup>: the function to set up the fixture data
20891 // <data_test>: the actual test function
20892 // <data_teardown>: the function to teardown the fixture data
20893 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) {
20894 return g_test_create_case(test_name, data_size, test_data, data_setup, data_test, data_teardown);
20898 // Unintrospectable function: test_create_suite() / g_test_create_suite()
20899 // VERSION: 2.16
20900 // Create a new test suite with the name @suite_name.
20901 // RETURNS: A newly allocated #GTestSuite instance.
20902 // <suite_name>: a name for the suite
20903 static TestSuite* test_create_suite()(char* suite_name) {
20904 return g_test_create_suite(suite_name);
20908 // VERSION: 2.30
20909 // Indicates that a test failed. This function can be called
20910 // multiple times from the same test. You can use this function
20911 // if your test failed in a recoverable way.
20913 // Do not use this function if the failure of a test could cause
20914 // other tests to malfunction.
20916 // Calling this function will not stop the test from running, you
20917 // need to return from the test function yourself. So you can
20918 // produce additional diagnostic messages or even continue running
20919 // the test.
20921 // If not called from inside a test, this function does nothing.
20922 static void test_fail()() {
20923 g_test_fail();
20927 // Unintrospectable function: test_get_root() / g_test_get_root()
20928 // VERSION: 2.16
20929 // Get the toplevel test suite for the test path API.
20930 // RETURNS: the toplevel #GTestSuite
20931 static TestSuite* test_get_root()() {
20932 return g_test_get_root();
20936 // Unintrospectable function: test_init() / g_test_init()
20937 // VERSION: 2.16
20938 // Initialize the GLib testing framework, e.g. by seeding the
20939 // test random number generator, the name for g_get_prgname()
20940 // and parsing test related command line args.
20941 // So far, the following arguments are understood:
20942 // <variablelist>
20943 // <varlistentry>
20944 // <term><option>-l</option></term>
20945 // <listitem><para>
20946 // list test cases available in a test executable.
20947 // </para></listitem>
20948 // </varlistentry>
20949 // <varlistentry>
20950 // <term><option>--seed=<replaceable>RANDOMSEED</replaceable></option></term>
20951 // <listitem><para>
20952 // provide a random seed to reproduce test runs using random numbers.
20953 // </para></listitem>
20954 // </varlistentry>
20955 // <varlistentry>
20956 // <term><option>--verbose</option></term>
20957 // <listitem><para>run tests verbosely.</para></listitem>
20958 // </varlistentry>
20959 // <varlistentry>
20960 // <term><option>-q</option>, <option>--quiet</option></term>
20961 // <listitem><para>run tests quietly.</para></listitem>
20962 // </varlistentry>
20963 // <varlistentry>
20964 // <term><option>-p <replaceable>TESTPATH</replaceable></option></term>
20965 // <listitem><para>
20966 // execute all tests matching <replaceable>TESTPATH</replaceable>.
20967 // </para></listitem>
20968 // </varlistentry>
20969 // <varlistentry>
20970 // <term><option>-m {perf|slow|thorough|quick}</option></term>
20971 // <listitem><para>
20972 // execute tests according to these test modes:
20973 // <variablelist>
20974 // <varlistentry>
20975 // <term>perf</term>
20976 // <listitem><para>
20977 // performance tests, may take long and report results.
20978 // </para></listitem>
20979 // </varlistentry>
20980 // <varlistentry>
20981 // <term>slow, thorough</term>
20982 // <listitem><para>
20983 // slow and thorough tests, may take quite long and
20984 // maximize coverage.
20985 // </para></listitem>
20986 // </varlistentry>
20987 // <varlistentry>
20988 // <term>quick</term>
20989 // <listitem><para>
20990 // quick tests, should run really quickly and give good coverage.
20991 // </para></listitem>
20992 // </varlistentry>
20993 // </variablelist>
20994 // </para></listitem>
20995 // </varlistentry>
20996 // <varlistentry>
20997 // <term><option>--debug-log</option></term>
20998 // <listitem><para>debug test logging output.</para></listitem>
20999 // </varlistentry>
21000 // <varlistentry>
21001 // <term><option>-k</option>, <option>--keep-going</option></term>
21002 // <listitem><para>gtester-specific argument.</para></listitem>
21003 // </varlistentry>
21004 // <varlistentry>
21005 // <term><option>--GTestLogFD <replaceable>N</replaceable></option></term>
21006 // <listitem><para>gtester-specific argument.</para></listitem>
21007 // </varlistentry>
21008 // <varlistentry>
21009 // <term><option>--GTestSkipCount <replaceable>N</replaceable></option></term>
21010 // <listitem><para>gtester-specific argument.</para></listitem>
21011 // </varlistentry>
21012 // </variablelist>
21013 // <argc>: Address of the @argc parameter of the main() function. Changed if any arguments were handled.
21014 // <argv>: Address of the @argv parameter of main(). Any parameters understood by g_test_init() stripped before return.
21015 alias g_test_init test_init; // Variadic
21018 // Unintrospectable function: test_log_set_fatal_handler() / g_test_log_set_fatal_handler()
21019 // VERSION: 2.22
21020 // Installs a non-error fatal log handler which can be
21021 // used to decide whether log messages which are counted
21022 // as fatal abort the program.
21024 // The use case here is that you are running a test case
21025 // that depends on particular libraries or circumstances
21026 // and cannot prevent certain known critical or warning
21027 // messages. So you install a handler that compares the
21028 // domain and message to precisely not abort in such a case.
21030 // Note that the handler is reset at the beginning of
21031 // any test case, so you have to set it inside each test
21032 // function which needs the special behavior.
21034 // This handler has no effect on g_error messages.
21035 // <log_func>: the log handler function.
21036 // <user_data>: data passed to the log handler.
21037 static void test_log_set_fatal_handler()(TestLogFatalFunc log_func, void* user_data) {
21038 g_test_log_set_fatal_handler(log_func, user_data);
21041 static char* test_log_type_name()(TestLogType log_type) {
21042 return g_test_log_type_name(log_type);
21046 // Unintrospectable function: test_maximized_result() / g_test_maximized_result()
21047 // VERSION: 2.16
21048 // Report the result of a performance or measurement test.
21049 // The test should generally strive to maximize the reported
21050 // quantities (larger values are better than smaller ones),
21051 // this and @maximized_quantity can determine sorting
21052 // order for test result reports.
21053 // <maximized_quantity>: the reported value
21054 // <format>: the format string of the report message
21055 alias g_test_maximized_result test_maximized_result; // Variadic
21058 // Unintrospectable function: test_message() / g_test_message()
21059 // VERSION: 2.16
21060 // Add a message to the test report.
21061 // <format>: the format string
21062 alias g_test_message test_message; // Variadic
21065 // Unintrospectable function: test_minimized_result() / g_test_minimized_result()
21066 // VERSION: 2.16
21067 // Report the result of a performance or measurement test.
21068 // The test should generally strive to minimize the reported
21069 // quantities (smaller values are better than larger ones),
21070 // this and @minimized_quantity can determine sorting
21071 // order for test result reports.
21072 // <minimized_quantity>: the reported value
21073 // <format>: the format string of the report message
21074 alias g_test_minimized_result test_minimized_result; // Variadic
21077 // VERSION: 2.16
21078 // This function enqueus a callback @destroy_func() to be executed
21079 // during the next test case teardown phase. This is most useful
21080 // to auto destruct allocted test resources at the end of a test run.
21081 // Resources are released in reverse queue order, that means enqueueing
21082 // callback A before callback B will cause B() to be called before
21083 // A() during teardown.
21084 // <destroy_func>: Destroy callback for teardown phase.
21085 // <destroy_data>: Destroy callback data.
21086 static void test_queue_destroy()(DestroyNotify destroy_func, void* destroy_data) {
21087 g_test_queue_destroy(destroy_func, destroy_data);
21091 // VERSION: 2.16
21092 // Enqueue a pointer to be released with g_free() during the next
21093 // teardown phase. This is equivalent to calling g_test_queue_destroy()
21094 // with a destroy callback of g_free().
21095 // <gfree_pointer>: the pointer to be stored.
21096 static void test_queue_free()(void* gfree_pointer) {
21097 g_test_queue_free(gfree_pointer);
21101 // VERSION: 2.16
21102 // Get a reproducible random floating point number,
21103 // see g_test_rand_int() for details on test case random numbers.
21104 // RETURNS: a random number from the seeded random number generator.
21105 static double test_rand_double()() {
21106 return g_test_rand_double();
21110 // VERSION: 2.16
21111 // Get a reproducible random floating pointer number out of a specified range,
21112 // see g_test_rand_int() for details on test case random numbers.
21113 // RETURNS: a number with @range_start <= number < @range_end.
21114 // <range_start>: the minimum value returned by this function
21115 // <range_end>: the minimum value not returned by this function
21116 static double test_rand_double_range()(double range_start, double range_end) {
21117 return g_test_rand_double_range(range_start, range_end);
21121 // VERSION: 2.16
21122 // Get a reproducible random integer number.
21124 // The random numbers generated by the g_test_rand_*() family of functions
21125 // change with every new test program start, unless the --seed option is
21126 // given when starting test programs.
21128 // For individual test cases however, the random number generator is
21129 // reseeded, to avoid dependencies between tests and to make --seed
21130 // effective for all test cases.
21131 // RETURNS: a random number from the seeded random number generator.
21132 static int test_rand_int()() {
21133 return g_test_rand_int();
21137 // VERSION: 2.16
21138 // Get a reproducible random integer number out of a specified range,
21139 // see g_test_rand_int() for details on test case random numbers.
21140 // RETURNS: a number with @begin <= number < @end.
21141 // <begin>: the minimum value returned by this function
21142 // <end>: the smallest value not to be returned by this function
21143 static int test_rand_int_range()(int begin, int end) {
21144 return g_test_rand_int_range(begin, end);
21148 // VERSION: 2.16
21149 // Runs all tests under the toplevel suite which can be retrieved
21150 // with g_test_get_root(). Similar to g_test_run_suite(), the test
21151 // cases to be run are filtered according to
21152 // test path arguments (-p <replaceable>testpath</replaceable>) as
21153 // parsed by g_test_init().
21154 // g_test_run_suite() or g_test_run() may only be called once
21155 // in a program.
21156 // RETURNS: 0 on success
21157 static int test_run()() {
21158 return g_test_run();
21162 // VERSION: 2.16
21163 // Execute the tests within @suite and all nested #GTestSuites.
21164 // The test suites to be executed are filtered according to
21165 // test path arguments (-p <replaceable>testpath</replaceable>)
21166 // as parsed by g_test_init().
21167 // g_test_run_suite() or g_test_run() may only be called once
21168 // in a program.
21169 // RETURNS: 0 on success
21170 // <suite>: a #GTestSuite
21171 static int test_run_suite()(TestSuite* suite) {
21172 return g_test_run_suite(suite);
21176 // VERSION: 2.16
21177 // Get the time since the last start of the timer with g_test_timer_start().
21178 // RETURNS: the time since the last start of the timer, as a double
21179 static double test_timer_elapsed()() {
21180 return g_test_timer_elapsed();
21184 // VERSION: 2.16
21185 // Report the last result of g_test_timer_elapsed().
21186 // RETURNS: the last result of g_test_timer_elapsed(), as a double
21187 static double test_timer_last()() {
21188 return g_test_timer_last();
21192 // VERSION: 2.16
21193 // Start a timing test. Call g_test_timer_elapsed() when the task is supposed
21194 // to be done. Call this function again to restart the timer.
21195 static void test_timer_start()() {
21196 g_test_timer_start();
21199 static void test_trap_assertions()(char* domain, char* file, int line, char* func, ulong assertion_flags, char* pattern) {
21200 g_test_trap_assertions(domain, file, line, func, assertion_flags, pattern);
21204 // VERSION: 2.16
21205 // Fork the current test program to execute a test case that might
21206 // not return or that might abort. The forked test case is aborted
21207 // and considered failing if its run time exceeds @usec_timeout.
21209 // The forking behavior can be configured with the #GTestTrapFlags flags.
21211 // In the following example, the test code forks, the forked child
21212 // process produces some sample output and exits successfully.
21213 // The forking parent process then asserts successful child program
21214 // termination and validates child program outputs.
21216 // |[
21217 // static void
21218 // test_fork_patterns (void)
21219 // {
21220 // if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
21221 // {
21222 // g_print ("some stdout text: somagic17\n");
21223 // g_printerr ("some stderr text: semagic43\n");
21224 // exit (0); /&ast; successful test run &ast;/
21225 // }
21226 // g_test_trap_assert_passed();
21227 // g_test_trap_assert_stdout ("*somagic17*");
21228 // g_test_trap_assert_stderr ("*semagic43*");
21229 // }
21230 // ]|
21232 // This function is implemented only on Unix platforms.
21233 // RETURNS: %TRUE for the forked child and %FALSE for the executing parent process.
21234 // <usec_timeout>: Timeout for the forked test in micro seconds.
21235 // <test_trap_flags>: Flags to modify forking behaviour.
21236 static int test_trap_fork()(ulong usec_timeout, TestTrapFlags test_trap_flags) {
21237 return g_test_trap_fork(usec_timeout, test_trap_flags);
21241 // VERSION: 2.16
21242 // Check the result of the last g_test_trap_fork() call.
21243 // RETURNS: %TRUE if the last forked child terminated successfully.
21244 static int test_trap_has_passed()() {
21245 return g_test_trap_has_passed();
21249 // VERSION: 2.16
21250 // Check the result of the last g_test_trap_fork() call.
21251 // RETURNS: %TRUE if the last forked child got killed due to a fork timeout.
21252 static int test_trap_reached_timeout()() {
21253 return g_test_trap_reached_timeout();
21256 // MOVED TO: Thread.error_quark
21257 static Quark thread_error_quark()() {
21258 return g_thread_error_quark();
21262 // MOVED TO: Thread.exit
21263 // Exits the current thread. If another thread is waiting for that
21264 // thread using g_thread_join() and the current thread is joinable, the
21265 // waiting thread will be woken up and get @retval as the return value
21266 // of g_thread_join(). If the current thread is not joinable, @retval
21267 // is ignored. Calling
21269 // <informalexample>
21270 // <programlisting>
21271 // g_thread_exit (retval);
21272 // </programlisting>
21273 // </informalexample>
21275 // is equivalent to returning @retval from the function @func, as given
21276 // to g_thread_create().
21278 // <note><para>Never call g_thread_exit() from within a thread of a
21279 // #GThreadPool, as that will mess up the bookkeeping and lead to funny
21280 // and unwanted results.</para></note>
21281 // <retval>: the return value of this thread.
21282 static void thread_exit()(void* retval) {
21283 g_thread_exit(retval);
21287 // VERSION: 2.20
21288 // MOVED TO: Thread.get_initialized
21289 // Indicates if g_thread_init() has been called.
21290 // RETURNS: %TRUE if threads have been initialized.
21291 static int thread_get_initialized()() {
21292 return g_thread_get_initialized();
21296 // MOVED TO: Thread.init
21297 // If you use GLib from more than one thread, you must initialize the
21298 // thread system by calling g_thread_init(). Most of the time you will
21299 // only have to call <literal>g_thread_init (NULL)</literal>.
21301 // <note><para>Do not call g_thread_init() with a non-%NULL parameter unless
21302 // you really know what you are doing.</para></note>
21304 // <note><para>g_thread_init() must not be called directly or indirectly as a
21305 // callback from GLib. Also no mutexes may be currently locked while
21306 // calling g_thread_init().</para></note>
21308 // <note><para>g_thread_init() changes the way in which #GTimer measures
21309 // elapsed time. As a consequence, timers that are running while
21310 // g_thread_init() is called may report unreliable times.</para></note>
21312 // Calling g_thread_init() multiple times is allowed (since version
21313 // 2.24), but nothing happens except for the first call. If the
21314 // argument is non-%NULL on such a call a warning will be printed, but
21315 // otherwise the argument is ignored.
21317 // If no thread system is available and @vtable is %NULL or if not all
21318 // elements of @vtable are non-%NULL, then g_thread_init() will abort.
21320 // <note><para>To use g_thread_init() in your program, you have to link with
21321 // the libraries that the command <command>pkg-config --libs
21322 // gthread-2.0</command> outputs. This is not the case for all the
21323 // other thread related functions of GLib. Those can be used without
21324 // having to link with the thread libraries.</para></note>
21325 // <vtable>: a function table of type #GThreadFunctions, that provides the entry points to the thread system to be used.
21326 static void thread_init()(ThreadFunctions* vtable) {
21327 g_thread_init(vtable);
21330 // MOVED TO: Thread.init_with_errorcheck_mutexes
21331 static void thread_init_with_errorcheck_mutexes()(ThreadFunctions* vtable) {
21332 g_thread_init_with_errorcheck_mutexes(vtable);
21336 // VERSION: 2.10
21337 // MOVED TO: ThreadPool.get_max_idle_time
21338 // This function will return the maximum @interval that a thread will
21339 // wait in the thread pool for new tasks before being stopped.
21341 // If this function returns 0, threads waiting in the thread pool for
21342 // new work are not stopped.
21344 // thread pool before stopping the thread (1/1000ths of a second).
21345 // RETURNS: the maximum @interval to wait for new tasks in the
21346 static uint thread_pool_get_max_idle_time()() {
21347 return g_thread_pool_get_max_idle_time();
21351 // MOVED TO: ThreadPool.get_max_unused_threads
21352 // Returns the maximal allowed number of unused threads.
21353 // RETURNS: the maximal number of unused threads
21354 static int thread_pool_get_max_unused_threads()() {
21355 return g_thread_pool_get_max_unused_threads();
21359 // MOVED TO: ThreadPool.get_num_unused_threads
21360 // Returns the number of currently unused threads.
21361 // RETURNS: the number of currently unused threads
21362 static uint thread_pool_get_num_unused_threads()() {
21363 return g_thread_pool_get_num_unused_threads();
21367 // VERSION: 2.10
21368 // MOVED TO: ThreadPool.set_max_idle_time
21369 // This function will set the maximum @interval that a thread waiting
21370 // in the pool for new tasks can be idle for before being
21371 // stopped. This function is similar to calling
21372 // g_thread_pool_stop_unused_threads() on a regular timeout, except,
21373 // this is done on a per thread basis.
21375 // By setting @interval to 0, idle threads will not be stopped.
21377 // This function makes use of g_async_queue_timed_pop () using
21378 // @interval.
21379 // <interval>: the maximum @interval (1/1000ths of a second) a thread can be idle.
21380 static void thread_pool_set_max_idle_time()(uint interval) {
21381 g_thread_pool_set_max_idle_time(interval);
21385 // MOVED TO: ThreadPool.set_max_unused_threads
21386 // Sets the maximal number of unused threads to @max_threads. If
21387 // @max_threads is -1, no limit is imposed on the number of unused
21388 // threads.
21389 // <max_threads>: maximal number of unused threads
21390 static void thread_pool_set_max_unused_threads()(int max_threads) {
21391 g_thread_pool_set_max_unused_threads(max_threads);
21395 // MOVED TO: ThreadPool.stop_unused_threads
21396 // Stops all currently unused threads. This does not change the
21397 // maximal number of unused threads. This function can be used to
21398 // regularly stop all unused threads e.g. from g_timeout_add().
21399 static void thread_pool_stop_unused_threads()() {
21400 g_thread_pool_stop_unused_threads();
21404 // VERSION: 2.12
21405 // MOVED TO: TimeVal.from_iso8601
21406 // Converts a string containing an ISO 8601 encoded date and time
21407 // to a #GTimeVal and puts it into @time_.
21408 // RETURNS: %TRUE if the conversion was successful.
21409 // <iso_date>: an ISO 8601 encoded date string
21410 // <time_>: a #GTimeVal
21411 static int time_val_from_iso8601()(char* iso_date, TimeVal* time_) {
21412 return g_time_val_from_iso8601(iso_date, time_);
21416 // Unintrospectable function: timeout_add() / g_timeout_add()
21417 // Sets a function to be called at regular intervals, with the default
21418 // priority, #G_PRIORITY_DEFAULT. The function is called repeatedly
21419 // until it returns %FALSE, at which point the timeout is automatically
21420 // destroyed and the function will not be called again. The first call
21421 // to the function will be at the end of the first @interval.
21423 // Note that timeout functions may be delayed, due to the processing of other
21424 // event sources. Thus they should not be relied on for precise timing.
21425 // After each call to the timeout function, the time of the next
21426 // timeout is recalculated based on the current time and the given interval
21427 // (it does not try to 'catch up' time lost in delays).
21429 // If you want to have a timer in the "seconds" range and do not care
21430 // about the exact time of the first call of the timer, use the
21431 // g_timeout_add_seconds() function; this function allows for more
21432 // optimizations and more efficient system power usage.
21434 // This internally creates a main loop source using g_timeout_source_new()
21435 // and attaches it to the main loop context using g_source_attach(). You can
21436 // do these steps manually if you need greater control.
21438 // The interval given is in terms of monotonic time, not wall clock
21439 // time. See g_get_monotonic_time().
21440 // RETURNS: the ID (greater than 0) of the event source.
21441 // <interval>: the time between calls to the function, in milliseconds (1/1000ths of a second)
21442 // <function>: function to call
21443 // <data>: data to pass to @function
21444 static uint timeout_add()(uint interval, SourceFunc function_, void* data) {
21445 return g_timeout_add(interval, function_, data);
21449 // Sets a function to be called at regular intervals, with the given
21450 // priority. The function is called repeatedly until it returns
21451 // %FALSE, at which point the timeout is automatically destroyed and
21452 // the function will not be called again. The @notify function is
21453 // called when the timeout is destroyed. The first call to the
21454 // function will be at the end of the first @interval.
21456 // Note that timeout functions may be delayed, due to the processing of other
21457 // event sources. Thus they should not be relied on for precise timing.
21458 // After each call to the timeout function, the time of the next
21459 // timeout is recalculated based on the current time and the given interval
21460 // (it does not try to 'catch up' time lost in delays).
21462 // This internally creates a main loop source using g_timeout_source_new()
21463 // and attaches it to the main loop context using g_source_attach(). You can
21464 // do these steps manually if you need greater control.
21466 // The interval given in terms of monotonic time, not wall clock time.
21467 // See g_get_monotonic_time().
21468 // RETURNS: the ID (greater than 0) of the event source.
21469 // <priority>: the priority of the timeout source. Typically this will be in the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
21470 // <interval>: the time between calls to the function, in milliseconds (1/1000ths of a second)
21471 // <function>: function to call
21472 // <data>: data to pass to @function
21473 // <notify>: function to call when the timeout is removed, or %NULL
21474 static uint timeout_add_full()(int priority, uint interval, SourceFunc function_, void* data, DestroyNotify notify) {
21475 return g_timeout_add_full(priority, interval, function_, data, notify);
21479 // Unintrospectable function: timeout_add_seconds() / g_timeout_add_seconds()
21480 // VERSION: 2.14
21481 // Sets a function to be called at regular intervals with the default
21482 // priority, #G_PRIORITY_DEFAULT. The function is called repeatedly until
21483 // it returns %FALSE, at which point the timeout is automatically destroyed
21484 // and the function will not be called again.
21486 // This internally creates a main loop source using
21487 // g_timeout_source_new_seconds() and attaches it to the main loop context
21488 // using g_source_attach(). You can do these steps manually if you need
21489 // greater control. Also see g_timeout_add_seconds_full().
21491 // Note that the first call of the timer may not be precise for timeouts
21492 // of one second. If you need finer precision and have such a timeout,
21493 // you may want to use g_timeout_add() instead.
21495 // The interval given is in terms of monotonic time, not wall clock
21496 // time. See g_get_monotonic_time().
21497 // RETURNS: the ID (greater than 0) of the event source.
21498 // <interval>: the time between calls to the function, in seconds
21499 // <function>: function to call
21500 // <data>: data to pass to @function
21501 static uint timeout_add_seconds()(uint interval, SourceFunc function_, void* data) {
21502 return g_timeout_add_seconds(interval, function_, data);
21506 // VERSION: 2.14
21507 // Sets a function to be called at regular intervals, with @priority.
21508 // The function is called repeatedly until it returns %FALSE, at which
21509 // point the timeout is automatically destroyed and the function will
21510 // not be called again.
21512 // Unlike g_timeout_add(), this function operates at whole second granularity.
21513 // The initial starting point of the timer is determined by the implementation
21514 // and the implementation is expected to group multiple timers together so that
21515 // they fire all at the same time.
21516 // To allow this grouping, the @interval to the first timer is rounded
21517 // and can deviate up to one second from the specified interval.
21518 // Subsequent timer iterations will generally run at the specified interval.
21520 // Note that timeout functions may be delayed, due to the processing of other
21521 // event sources. Thus they should not be relied on for precise timing.
21522 // After each call to the timeout function, the time of the next
21523 // timeout is recalculated based on the current time and the given @interval
21525 // If you want timing more precise than whole seconds, use g_timeout_add()
21526 // instead.
21528 // The grouping of timers to fire at the same time results in a more power
21529 // and CPU efficient behavior so if your timer is in multiples of seconds
21530 // and you don't require the first timer exactly one second from now, the
21531 // use of g_timeout_add_seconds() is preferred over g_timeout_add().
21533 // This internally creates a main loop source using
21534 // g_timeout_source_new_seconds() and attaches it to the main loop context
21535 // using g_source_attach(). You can do these steps manually if you need
21536 // greater control.
21538 // The interval given is in terms of monotonic time, not wall clock
21539 // time. See g_get_monotonic_time().
21540 // RETURNS: the ID (greater than 0) of the event source.
21541 // <priority>: the priority of the timeout source. Typically this will be in the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
21542 // <interval>: the time between calls to the function, in seconds
21543 // <function>: function to call
21544 // <data>: data to pass to @function
21545 // <notify>: function to call when the timeout is removed, or %NULL
21546 static uint timeout_add_seconds_full()(int priority, uint interval, SourceFunc function_, void* data, DestroyNotify notify) {
21547 return g_timeout_add_seconds_full(priority, interval, function_, data, notify);
21551 // Creates a new timeout source.
21553 // The source will not initially be associated with any #GMainContext
21554 // and must be added to one with g_source_attach() before it will be
21555 // executed.
21557 // The interval given is in terms of monotonic time, not wall clock
21558 // time. See g_get_monotonic_time().
21559 // RETURNS: the newly-created timeout source
21560 // <interval>: the timeout interval in milliseconds.
21561 static Source* /*new*/ timeout_source_new()(uint interval) {
21562 return g_timeout_source_new(interval);
21566 // VERSION: 2.14
21567 // Creates a new timeout source.
21569 // The source will not initially be associated with any #GMainContext
21570 // and must be added to one with g_source_attach() before it will be
21571 // executed.
21573 // The scheduling granularity/accuracy of this timeout source will be
21574 // in seconds.
21576 // The interval given in terms of monotonic time, not wall clock time.
21577 // See g_get_monotonic_time().
21578 // RETURNS: the newly-created timeout source
21579 // <interval>: the timeout interval in seconds
21580 static Source* /*new*/ timeout_source_new_seconds()(uint interval) {
21581 return g_timeout_source_new_seconds(interval);
21584 // MOVED TO: TrashStack.height
21585 static uint trash_stack_height()(TrashStack** stack_p) {
21586 return g_trash_stack_height(stack_p);
21589 // MOVED TO: TrashStack.push
21590 static void trash_stack_push()(TrashStack** stack_p, void* data_p) {
21591 g_trash_stack_push(stack_p, data_p);
21595 // Unintrospectable function: try_malloc() / g_try_malloc()
21596 // Attempts to allocate @n_bytes, and returns %NULL on failure.
21597 // Contrast with g_malloc(), which aborts the program on failure.
21598 // RETURNS: the allocated memory, or %NULL.
21599 // <n_bytes>: number of bytes to allocate.
21600 static void* try_malloc()(size_t n_bytes) {
21601 return g_try_malloc(n_bytes);
21605 // Unintrospectable function: try_malloc0() / g_try_malloc0()
21606 // VERSION: 2.8
21607 // Attempts to allocate @n_bytes, initialized to 0's, and returns %NULL on
21608 // failure. Contrast with g_malloc0(), which aborts the program on failure.
21609 // RETURNS: the allocated memory, or %NULL
21610 // <n_bytes>: number of bytes to allocate
21611 static void* try_malloc0()(size_t n_bytes) {
21612 return g_try_malloc0(n_bytes);
21616 // Unintrospectable function: try_malloc0_n() / g_try_malloc0_n()
21617 // VERSION: 2.24
21618 // This function is similar to g_try_malloc0(), allocating (@n_blocks * @n_block_bytes) bytes,
21619 // but care is taken to detect possible overflow during multiplication.
21620 // RETURNS: the allocated memory, or %NULL
21621 // <n_blocks>: the number of blocks to allocate
21622 // <n_block_bytes>: the size of each block in bytes
21623 static void* try_malloc0_n()(size_t n_blocks, size_t n_block_bytes) {
21624 return g_try_malloc0_n(n_blocks, n_block_bytes);
21628 // Unintrospectable function: try_malloc_n() / g_try_malloc_n()
21629 // VERSION: 2.24
21630 // This function is similar to g_try_malloc(), allocating (@n_blocks * @n_block_bytes) bytes,
21631 // but care is taken to detect possible overflow during multiplication.
21632 // RETURNS: the allocated memory, or %NULL.
21633 // <n_blocks>: the number of blocks to allocate
21634 // <n_block_bytes>: the size of each block in bytes
21635 static void* try_malloc_n()(size_t n_blocks, size_t n_block_bytes) {
21636 return g_try_malloc_n(n_blocks, n_block_bytes);
21640 // Unintrospectable function: try_realloc() / g_try_realloc()
21641 // Attempts to realloc @mem to a new size, @n_bytes, and returns %NULL
21642 // on failure. Contrast with g_realloc(), which aborts the program
21643 // on failure. If @mem is %NULL, behaves the same as g_try_malloc().
21644 // RETURNS: the allocated memory, or %NULL.
21645 // <mem>: previously-allocated memory, or %NULL.
21646 // <n_bytes>: number of bytes to allocate.
21647 static void* try_realloc()(void* mem, size_t n_bytes) {
21648 return g_try_realloc(mem, n_bytes);
21652 // Unintrospectable function: try_realloc_n() / g_try_realloc_n()
21653 // VERSION: 2.24
21654 // This function is similar to g_try_realloc(), allocating (@n_blocks * @n_block_bytes) bytes,
21655 // but care is taken to detect possible overflow during multiplication.
21656 // RETURNS: the allocated memory, or %NULL.
21657 // <mem>: previously-allocated memory, or %NULL.
21658 // <n_blocks>: the number of blocks to allocate
21659 // <n_block_bytes>: the size of each block in bytes
21660 static void* try_realloc_n()(void* mem, size_t n_blocks, size_t n_block_bytes) {
21661 return g_try_realloc_n(mem, n_blocks, n_block_bytes);
21665 // Convert a string from UCS-4 to UTF-16. A 0 character will be
21666 // added to the result after the converted text.
21668 // This value must be freed with g_free(). If an
21669 // error occurs, %NULL will be returned and
21670 // @error set.
21671 // RETURNS: a pointer to a newly allocated UTF-16 string.
21672 // <str>: a UCS-4 encoded string
21673 // <len>: the maximum length (number of characters) of @str to use. If @len < 0, then the string is nul-terminated.
21674 // <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.
21675 // <items_written>: location to store number of <type>gunichar2</type> written, or %NULL. The value stored here does not include the trailing 0.
21676 static wchar* ucs4_to_utf16()(dchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error=null) {
21677 return g_ucs4_to_utf16(str, len, items_read, items_written, error);
21681 // Convert a string from a 32-bit fixed width representation as UCS-4.
21682 // to UTF-8. The result will be terminated with a 0 byte.
21684 // This value must be freed with g_free(). If an
21685 // error occurs, %NULL will be returned and
21686 // @error set. In that case, @items_read will be
21687 // set to the position of the first invalid input
21688 // character.
21689 // RETURNS: a pointer to a newly allocated UTF-8 string.
21690 // <str>: a UCS-4 encoded string
21691 // <len>: the maximum length (number of characters) of @str to use. If @len < 0, then the string is nul-terminated.
21692 // <items_read>: location to store number of characters read, or %NULL.
21693 // <items_written>: location to store number of bytes written or %NULL. The value here stored does not include the trailing 0 byte.
21694 static char* /*new*/ ucs4_to_utf8()(dchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error=null) {
21695 return g_ucs4_to_utf8(str, len, items_read, items_written, error);
21699 // Determines the break type of @c. @c should be a Unicode character
21700 // (to derive a character from UTF-8 encoded text, use
21701 // g_utf8_get_char()). The break type is used to find word and line
21702 // breaks ("text boundaries"), Pango implements the Unicode boundary
21703 // resolution algorithms and normally you would use a function such
21704 // as pango_break() instead of caring about break types yourself.
21705 // RETURNS: the break type of @c
21706 // <c>: a Unicode character
21707 static UnicodeBreakType unichar_break_type()(dchar c) {
21708 return g_unichar_break_type(c);
21712 // VERSION: 2.14
21713 // Determines the canonical combining class of a Unicode character.
21714 // RETURNS: the combining class of the character
21715 // <uc>: a Unicode character
21716 static int unichar_combining_class()(dchar uc) {
21717 return g_unichar_combining_class(uc);
21721 // VERSION: 2.30
21722 // Performs a single composition step of the
21723 // Unicode canonical composition algorithm.
21725 // This function does not perform algorithmic composition
21726 // for Hangul characters, and does not include compatibility
21727 // compositions. It does, however, include 'singleton'
21728 // compositions which replace a character by a single
21729 // other character. To obtain these, pass zero for @b.
21731 // This function includes algorithmic Hangul Jamo composition.
21733 // If @a and @b do not compose a new character, @ch is set to zero.
21735 // See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
21736 // for details.
21737 // RETURNS: %TRUE if the characters could be composed
21738 // <a>: a Unicode character
21739 // <b>: a Unicode character
21740 // <ch>: return location for the composed character
21741 static int unichar_compose()(dchar a, dchar b, dchar* ch) {
21742 return g_unichar_compose(a, b, ch);
21746 // VERSION: 2.30
21747 // Performs a single decomposition step of the
21748 // Unicode canonical decomposition algorithm.
21750 // This function does not include compatibility
21751 // decompositions. It does, however, include algorithmic
21752 // Hangul Jamo decomposition, as well as 'singleton'
21753 // decompositions which replace a character by a single
21754 // other character. In the case of singletons *@b will
21755 // be set to zero.
21757 // If @ch is not decomposable, *@a is set to @ch and *@b
21758 // is set to zero.
21760 // Note that the way Unicode decomposition pairs are
21761 // defined, it is guaranteed that @b would not decompose
21762 // further, but @a may itself decompose. To get the full
21763 // canonical decomposition for @ch, one would need to
21764 // recursively call this function on @a. Or use
21765 // g_unichar_fully_decompose().
21767 // See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
21768 // for details.
21769 // RETURNS: %TRUE if the character could be decomposed
21770 // <ch>: a Unicode character
21771 // <a>: return location for the first component of @ch
21772 // <b>: return location for the second component of @ch
21773 static int unichar_decompose()(dchar ch, dchar* a, dchar* b) {
21774 return g_unichar_decompose(ch, a, b);
21778 // Determines the numeric value of a character as a decimal
21779 // digit.
21781 // g_unichar_isdigit()), its numeric value. Otherwise, -1.
21782 // RETURNS: If @c is a decimal digit (according to
21783 // <c>: a Unicode character
21784 static int unichar_digit_value()(dchar c) {
21785 return g_unichar_digit_value(c);
21789 // VERSION: 2.30
21790 // Computes the canonical or compatibility decomposition of a
21791 // Unicode character. For compatibility decomposition,
21792 // pass %TRUE for @compat; for canonical decomposition
21793 // pass %FALSE for @compat.
21795 // The decomposed sequence is placed in @result. Only up to
21796 // @result_len characters are written into @result. The length
21797 // of the full decomposition (irrespective of @result_len) is
21798 // returned by the function. For canonical decomposition,
21799 // currently all decompositions are of length at most 4, but
21800 // this may change in the future (very unlikely though).
21801 // At any rate, Unicode does guarantee that a buffer of length
21802 // 18 is always enough for both compatibility and canonical
21803 // decompositions.
21805 // See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
21806 // for details.
21807 // RETURNS: the length of the full decomposition.
21808 // <ch>: a Unicode character.
21809 // <compat>: whether perform canonical or compatibility decomposition
21810 // <result>: location to store decomposed result, or %NULL
21811 // <result_len>: length of @result
21812 static size_t unichar_fully_decompose()(dchar ch, int compat, dchar* result, size_t result_len) {
21813 return g_unichar_fully_decompose(ch, compat, result, result_len);
21817 // VERSION: 2.4
21818 // In Unicode, some characters are <firstterm>mirrored</firstterm>. This
21819 // means that their images are mirrored horizontally in text that is laid
21820 // out from right to left. For instance, "(" would become its mirror image,
21821 // ")", in right-to-left text.
21823 // If @ch has the Unicode mirrored property and there is another unicode
21824 // character that typically has a glyph that is the mirror image of @ch's
21825 // glyph and @mirrored_ch is set, it puts that character in the address
21826 // pointed to by @mirrored_ch. Otherwise the original character is put.
21827 // RETURNS: %TRUE if @ch has a mirrored character, %FALSE otherwise
21828 // <ch>: a Unicode character
21829 // <mirrored_ch>: location to store the mirrored character
21830 static int unichar_get_mirror_char()(dchar ch, dchar* mirrored_ch) {
21831 return g_unichar_get_mirror_char(ch, mirrored_ch);
21835 // VERSION: 2.14
21836 // Looks up the #GUnicodeScript for a particular character (as defined
21837 // by Unicode Standard Annex #24). No check is made for @ch being a
21838 // valid Unicode character; if you pass in invalid character, the
21839 // result is undefined.
21841 // This function is equivalent to pango_script_for_unichar() and the
21842 // two are interchangeable.
21843 // RETURNS: the #GUnicodeScript for the character.
21844 // <ch>: a Unicode character
21845 static UnicodeScript unichar_get_script()(dchar ch) {
21846 return g_unichar_get_script(ch);
21850 // Determines whether a character is alphanumeric.
21851 // Given some UTF-8 text, obtain a character value
21852 // with g_utf8_get_char().
21853 // RETURNS: %TRUE if @c is an alphanumeric character
21854 // <c>: a Unicode character
21855 static int unichar_isalnum()(dchar c) {
21856 return g_unichar_isalnum(c);
21860 // Determines whether a character is alphabetic (i.e. a letter).
21861 // Given some UTF-8 text, obtain a character value with
21862 // g_utf8_get_char().
21863 // RETURNS: %TRUE if @c is an alphabetic character
21864 // <c>: a Unicode character
21865 static int unichar_isalpha()(dchar c) {
21866 return g_unichar_isalpha(c);
21870 // Determines whether a character is a control character.
21871 // Given some UTF-8 text, obtain a character value with
21872 // g_utf8_get_char().
21873 // RETURNS: %TRUE if @c is a control character
21874 // <c>: a Unicode character
21875 static int unichar_iscntrl()(dchar c) {
21876 return g_unichar_iscntrl(c);
21880 // Determines if a given character is assigned in the Unicode
21881 // standard.
21882 // RETURNS: %TRUE if the character has an assigned value
21883 // <c>: a Unicode character
21884 static int unichar_isdefined()(dchar c) {
21885 return g_unichar_isdefined(c);
21889 // Determines whether a character is numeric (i.e. a digit). This
21890 // covers ASCII 0-9 and also digits in other languages/scripts. Given
21891 // some UTF-8 text, obtain a character value with g_utf8_get_char().
21892 // RETURNS: %TRUE if @c is a digit
21893 // <c>: a Unicode character
21894 static int unichar_isdigit()(dchar c) {
21895 return g_unichar_isdigit(c);
21899 // Determines whether a character is printable and not a space
21900 // (returns %FALSE for control characters, format characters, and
21901 // spaces). g_unichar_isprint() is similar, but returns %TRUE for
21902 // spaces. Given some UTF-8 text, obtain a character value with
21903 // g_utf8_get_char().
21904 // RETURNS: %TRUE if @c is printable unless it's a space
21905 // <c>: a Unicode character
21906 static int unichar_isgraph()(dchar c) {
21907 return g_unichar_isgraph(c);
21911 // Determines whether a character is a lowercase letter.
21912 // Given some UTF-8 text, obtain a character value with
21913 // g_utf8_get_char().
21914 // RETURNS: %TRUE if @c is a lowercase letter
21915 // <c>: a Unicode character
21916 static int unichar_islower()(dchar c) {
21917 return g_unichar_islower(c);
21921 // VERSION: 2.14
21922 // Determines whether a character is a mark (non-spacing mark,
21923 // combining mark, or enclosing mark in Unicode speak).
21924 // Given some UTF-8 text, obtain a character value
21925 // with g_utf8_get_char().
21927 // Note: in most cases where isalpha characters are allowed,
21928 // ismark characters should be allowed to as they are essential
21929 // for writing most European languages as well as many non-Latin
21930 // scripts.
21931 // RETURNS: %TRUE if @c is a mark character
21932 // <c>: a Unicode character
21933 static int unichar_ismark()(dchar c) {
21934 return g_unichar_ismark(c);
21938 // Determines whether a character is printable.
21939 // Unlike g_unichar_isgraph(), returns %TRUE for spaces.
21940 // Given some UTF-8 text, obtain a character value with
21941 // g_utf8_get_char().
21942 // RETURNS: %TRUE if @c is printable
21943 // <c>: a Unicode character
21944 static int unichar_isprint()(dchar c) {
21945 return g_unichar_isprint(c);
21949 // Determines whether a character is punctuation or a symbol.
21950 // Given some UTF-8 text, obtain a character value with
21951 // g_utf8_get_char().
21952 // RETURNS: %TRUE if @c is a punctuation or symbol character
21953 // <c>: a Unicode character
21954 static int unichar_ispunct()(dchar c) {
21955 return g_unichar_ispunct(c);
21959 // Determines whether a character is a space, tab, or line separator
21960 // (newline, carriage return, etc.). Given some UTF-8 text, obtain a
21961 // character value with g_utf8_get_char().
21963 // (Note: don't use this to do word breaking; you have to use
21964 // Pango or equivalent to get word breaking right, the algorithm
21965 // is fairly complex.)
21966 // RETURNS: %TRUE if @c is a space character
21967 // <c>: a Unicode character
21968 static int unichar_isspace()(dchar c) {
21969 return g_unichar_isspace(c);
21973 // Determines if a character is titlecase. Some characters in
21974 // Unicode which are composites, such as the DZ digraph
21975 // have three case variants instead of just two. The titlecase
21976 // form is used at the beginning of a word where only the
21977 // first letter is capitalized. The titlecase form of the DZ
21978 // digraph is U+01F2 LATIN CAPITAL LETTTER D WITH SMALL LETTER Z.
21979 // RETURNS: %TRUE if the character is titlecase
21980 // <c>: a Unicode character
21981 static int unichar_istitle()(dchar c) {
21982 return g_unichar_istitle(c);
21986 // Determines if a character is uppercase.
21987 // RETURNS: %TRUE if @c is an uppercase character
21988 // <c>: a Unicode character
21989 static int unichar_isupper()(dchar c) {
21990 return g_unichar_isupper(c);
21994 // Determines if a character is typically rendered in a double-width
21995 // cell.
21996 // RETURNS: %TRUE if the character is wide
21997 // <c>: a Unicode character
21998 static int unichar_iswide()(dchar c) {
21999 return g_unichar_iswide(c);
22003 // VERSION: 2.12
22004 // Determines if a character is typically rendered in a double-width
22005 // cell under legacy East Asian locales. If a character is wide according to
22006 // g_unichar_iswide(), then it is also reported wide with this function, but
22007 // the converse is not necessarily true. See the
22008 // <ulink url="http://www.unicode.org/reports/tr11/">Unicode Standard
22009 // Annex #11</ulink> for details.
22011 // If a character passes the g_unichar_iswide() test then it will also pass
22012 // this test, but not the other way around. Note that some characters may
22013 // pas both this test and g_unichar_iszerowidth().
22014 // RETURNS: %TRUE if the character is wide in legacy East Asian locales
22015 // <c>: a Unicode character
22016 static int unichar_iswide_cjk()(dchar c) {
22017 return g_unichar_iswide_cjk(c);
22021 // Determines if a character is a hexidecimal digit.
22022 // RETURNS: %TRUE if the character is a hexadecimal digit
22023 // <c>: a Unicode character.
22024 static int unichar_isxdigit()(dchar c) {
22025 return g_unichar_isxdigit(c);
22029 // VERSION: 2.14
22030 // Determines if a given character typically takes zero width when rendered.
22031 // The return value is %TRUE for all non-spacing and enclosing marks
22032 // (e.g., combining accents), format characters, zero-width
22033 // space, but not U+00AD SOFT HYPHEN.
22035 // A typical use of this function is with one of g_unichar_iswide() or
22036 // g_unichar_iswide_cjk() to determine the number of cells a string occupies
22037 // when displayed on a grid display (terminals). However, note that not all
22038 // terminals support zero-width rendering of zero-width marks.
22039 // RETURNS: %TRUE if the character has zero width
22040 // <c>: a Unicode character
22041 static int unichar_iszerowidth()(dchar c) {
22042 return g_unichar_iszerowidth(c);
22046 // Converts a single character to UTF-8.
22047 // RETURNS: number of bytes written
22048 // <c>: a Unicode character code
22049 // <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.
22050 static int unichar_to_utf8()(dchar c, char* outbuf) {
22051 return g_unichar_to_utf8(c, outbuf);
22055 // Converts a character to lower case.
22057 // If @c is not an upperlower or titlecase character,
22058 // or has no lowercase equivalent @c is returned unchanged.
22059 // RETURNS: the result of converting @c to lower case.
22060 // <c>: a Unicode character.
22061 static dchar unichar_tolower()(dchar c) {
22062 return g_unichar_tolower(c);
22066 // Converts a character to the titlecase.
22068 // If @c is not an uppercase or lowercase character,
22069 // @c is returned unchanged.
22070 // RETURNS: the result of converting @c to titlecase.
22071 // <c>: a Unicode character
22072 static dchar unichar_totitle()(dchar c) {
22073 return g_unichar_totitle(c);
22077 // Converts a character to uppercase.
22079 // If @c is not an lowercase or titlecase character,
22080 // or has no upper case equivalent @c is returned unchanged.
22081 // RETURNS: the result of converting @c to uppercase.
22082 // <c>: a Unicode character
22083 static dchar unichar_toupper()(dchar c) {
22084 return g_unichar_toupper(c);
22088 // Classifies a Unicode character by type.
22089 // RETURNS: the type of the character.
22090 // <c>: a Unicode character
22091 static UnicodeType unichar_type()(dchar c) {
22092 return g_unichar_type(c);
22096 // Checks whether @ch is a valid Unicode character. Some possible
22097 // integer values of @ch will not be valid. 0 is considered a valid
22098 // character, though it's normally a string terminator.
22099 // RETURNS: %TRUE if @ch is a valid Unicode character
22100 // <ch>: a Unicode character
22101 static int unichar_validate()(dchar ch) {
22102 return g_unichar_validate(ch);
22106 // Determines the numeric value of a character as a hexidecimal
22107 // digit.
22109 // g_unichar_isxdigit()), its numeric value. Otherwise, -1.
22110 // RETURNS: If @c is a hex digit (according to
22111 // <c>: a Unicode character
22112 static int unichar_xdigit_value()(dchar c) {
22113 return g_unichar_xdigit_value(c);
22117 // DEPRECATED (v2.30) function: unicode_canonical_decomposition - Use the more flexible g_unichar_fully_decompose()
22118 // Computes the canonical decomposition of a Unicode character.
22120 // @result_len is set to the resulting length of the string.
22122 // instead.
22123 // RETURNS: a newly allocated string of Unicode characters.
22124 // <ch>: a Unicode character.
22125 // <result_len>: location to store the length of the return value.
22126 static dchar* unicode_canonical_decomposition()(dchar ch, size_t* result_len) {
22127 return g_unicode_canonical_decomposition(ch, result_len);
22131 // Computes the canonical ordering of a string in-place.
22132 // This rearranges decomposed characters in the string
22133 // according to their combining classes. See the Unicode
22134 // manual for more information.
22135 // <string>: a UCS-4 encoded string.
22136 // <len>: the maximum length of @string to use.
22137 static void unicode_canonical_ordering()(dchar* string_, size_t len) {
22138 g_unicode_canonical_ordering(string_, len);
22142 // VERSION: 2.30
22143 // Looks up the Unicode script for @iso15924. ISO 15924 assigns four-letter
22144 // codes to scripts. For example, the code for Arabic is 'Arab'.
22145 // This function accepts four letter codes encoded as a @guint32 in a
22146 // big-endian fashion. That is, the code expected for Arabic is
22147 // 0x41726162 (0x41 is ASCII code for 'A', 0x72 is ASCII code for 'r', etc).
22149 // See <ulink url="http://unicode.org/iso15924/codelists.html">Codes for the
22150 // representation of names of scripts</ulink> for details.
22152 // of %G_UNICODE_SCRIPT_INVALID_CODE if @iso15924 is zero and
22153 // %G_UNICODE_SCRIPT_UNKNOWN if @iso15924 is unknown.
22154 // RETURNS: the Unicode script for @iso15924, or
22155 // <iso15924>: a Unicode script
22156 static UnicodeScript unicode_script_from_iso15924()(uint iso15924) {
22157 return g_unicode_script_from_iso15924(iso15924);
22161 // VERSION: 2.30
22162 // Looks up the ISO 15924 code for @script. ISO 15924 assigns four-letter
22163 // codes to scripts. For example, the code for Arabic is 'Arab'. The
22164 // four letter codes are encoded as a @guint32 by this function in a
22165 // big-endian fashion. That is, the code returned for Arabic is
22166 // 0x41726162 (0x41 is ASCII code for 'A', 0x72 is ASCII code for 'r', etc).
22168 // See <ulink url="http://unicode.org/iso15924/codelists.html">Codes for the
22169 // representation of names of scripts</ulink> for details.
22171 // of zero if @script is %G_UNICODE_SCRIPT_INVALID_CODE or
22172 // ISO 15924 code 'Zzzz' (script code for UNKNOWN) if @script is not understood.
22173 // RETURNS: the ISO 15924 code for @script, encoded as an integer,
22174 // <script>: a Unicode script
22175 static uint unicode_script_to_iso15924()(UnicodeScript script) {
22176 return g_unicode_script_to_iso15924(script);
22180 // VERSION: 2.6
22181 // A wrapper for the POSIX unlink() function. The unlink() function
22182 // deletes a name from the filesystem. If this was the last link to the
22183 // file and no processes have it opened, the diskspace occupied by the
22184 // file is freed.
22186 // See your C library manual for more details about unlink(). Note
22187 // that on Windows, it is in general not possible to delete files that
22188 // are open to some process, or mapped into memory.
22190 // occurred
22191 // RETURNS: 0 if the name was successfully deleted, -1 if an error
22192 // <filename>: a pathname in the GLib file name encoding (UTF-8 on Windows)
22193 static int unlink()(char* filename) {
22194 return g_unlink(filename);
22198 // VERSION: 2.4
22199 // Removes an environment variable from the environment.
22201 // Note that on some systems, when variables are overwritten, the memory
22202 // used for the previous variables and its value isn't reclaimed.
22203 // Furthermore, this function can't be guaranteed to operate in a
22204 // threadsafe way.
22205 // <variable>: the environment variable to remove, must not contain '='.
22206 static void unsetenv()(char* variable) {
22207 g_unsetenv(variable);
22211 // VERSION: 2.16
22212 // Escapes a string for use in a URI.
22214 // Normally all characters that are not "unreserved" (i.e. ASCII alphanumerical
22215 // characters plus dash, dot, underscore and tilde) are escaped.
22216 // But if you specify characters in @reserved_chars_allowed they are not
22217 // escaped. This is useful for the "reserved" characters in the URI
22218 // specification, since those are allowed unescaped in some portions of
22219 // a URI.
22221 // freed when no longer needed.
22222 // RETURNS: an escaped version of @unescaped. The returned string should be
22223 // <unescaped>: the unescaped input string.
22224 // <reserved_chars_allowed>: a string of reserved characters that are allowed to be used, or %NULL.
22225 // <allow_utf8>: %TRUE if the result can include UTF-8 characters.
22226 static char* /*new*/ uri_escape_string()(char* unescaped, char* reserved_chars_allowed, int allow_utf8) {
22227 return g_uri_escape_string(unescaped, reserved_chars_allowed, allow_utf8);
22231 // Unintrospectable function: uri_list_extract_uris() / g_uri_list_extract_uris()
22232 // VERSION: 2.6
22233 // Splits an URI list conforming to the text/uri-list
22234 // mime type defined in RFC 2483 into individual URIs,
22235 // discarding any comments. The URIs are not validated.
22237 // strings holding the individual URIs. The array should
22238 // be freed with g_strfreev().
22239 // RETURNS: a newly allocated %NULL-terminated list of
22240 // <uri_list>: an URI list
22241 static char** uri_list_extract_uris()(char* uri_list) {
22242 return g_uri_list_extract_uris(uri_list);
22246 // VERSION: 2.16
22247 // Gets the scheme portion of a URI string. RFC 3986 decodes the scheme as:
22248 // <programlisting>
22249 // URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
22250 // </programlisting>
22251 // Common schemes include "file", "http", "svn+ssh", etc.
22253 // The returned string should be freed when no longer needed.
22254 // RETURNS: The "Scheme" component of the URI, or %NULL on error.
22255 // <uri>: a valid URI.
22256 static char* /*new*/ uri_parse_scheme()(char* uri) {
22257 return g_uri_parse_scheme(uri);
22261 // VERSION: 2.16
22262 // Unescapes a segment of an escaped string.
22264 // If any of the characters in @illegal_characters or the character zero appears
22265 // as an escaped character in @escaped_string then that is an error and %NULL
22266 // will be returned. This is useful it you want to avoid for instance having a
22267 // slash being expanded in an escaped path element, which might confuse pathname
22268 // handling.
22270 // The returned string should be freed when no longer needed.
22271 // RETURNS: an unescaped version of @escaped_string or %NULL on error.
22272 // <escaped_string>: a string.
22273 // <escaped_string_end>: a string.
22274 // <illegal_characters>: an optional string of illegal characters not to be allowed.
22275 static char* /*new*/ uri_unescape_segment()(char* escaped_string, char* escaped_string_end, char* illegal_characters) {
22276 return g_uri_unescape_segment(escaped_string, escaped_string_end, illegal_characters);
22280 // VERSION: 2.16
22281 // Unescapes a whole escaped string.
22283 // If any of the characters in @illegal_characters or the character zero appears
22284 // as an escaped character in @escaped_string then that is an error and %NULL
22285 // will be returned. This is useful it you want to avoid for instance having a
22286 // slash being expanded in an escaped path element, which might confuse pathname
22287 // handling.
22289 // should be freed when no longer needed.
22290 // RETURNS: an unescaped version of @escaped_string. The returned string
22291 // <escaped_string>: an escaped string to be unescaped.
22292 // <illegal_characters>: an optional string of illegal characters not to be allowed.
22293 static char* /*new*/ uri_unescape_string()(char* escaped_string, char* illegal_characters) {
22294 return g_uri_unescape_string(escaped_string, illegal_characters);
22297 static void usleep()(c_ulong microseconds) {
22298 g_usleep(microseconds);
22302 // Convert a string from UTF-16 to UCS-4. The result will be
22303 // nul-terminated.
22305 // This value must be freed with g_free(). If an
22306 // error occurs, %NULL will be returned and
22307 // @error set.
22308 // RETURNS: a pointer to a newly allocated UCS-4 string.
22309 // <str>: a UTF-16 encoded string
22310 // <len>: the maximum length (number of <type>gunichar2</type>) of @str to use. If @len < 0, then the string is nul-terminated.
22311 // <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.
22312 // <items_written>: location to store number of characters written, or %NULL. The value stored here does not include the trailing 0 character.
22313 static dchar* utf16_to_ucs4()(wchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error=null) {
22314 return g_utf16_to_ucs4(str, len, items_read, items_written, error);
22318 // Convert a string from UTF-16 to UTF-8. The result will be
22319 // terminated with a 0 byte.
22321 // Note that the input is expected to be already in native endianness,
22322 // an initial byte-order-mark character is not handled specially.
22323 // g_convert() can be used to convert a byte buffer of UTF-16 data of
22324 // ambiguous endianess.
22326 // Further note that this function does not validate the result
22327 // string; it may e.g. include embedded NUL characters. The only
22328 // validation done by this function is to ensure that the input can
22329 // be correctly interpreted as UTF-16, i.e. it doesn't contain
22330 // things unpaired surrogates.
22332 // This value must be freed with g_free(). If an
22333 // error occurs, %NULL will be returned and
22334 // @error set.
22335 // RETURNS: a pointer to a newly allocated UTF-8 string.
22336 // <str>: a UTF-16 encoded string
22337 // <len>: the maximum length (number of <type>gunichar2</type>) of @str to use. If @len < 0, then the string is nul-terminated.
22338 // <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.
22339 // <items_written>: location to store number of bytes written, or %NULL. The value stored here does not include the trailing 0 byte.
22340 static char* /*new*/ utf16_to_utf8()(wchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error=null) {
22341 return g_utf16_to_utf8(str, len, items_read, items_written, error);
22345 // Converts a string into a form that is independent of case. The
22346 // result will not correspond to any particular case, but can be
22347 // compared for equality or ordered with the results of calling
22348 // g_utf8_casefold() on other strings.
22350 // Note that calling g_utf8_casefold() followed by g_utf8_collate() is
22351 // only an approximation to the correct linguistic case insensitive
22352 // ordering, though it is a fairly good one. Getting this exactly
22353 // right would require a more sophisticated collation function that
22354 // takes case sensitivity into account. GLib does not currently
22355 // provide such a function.
22357 // case independent form of @str.
22358 // RETURNS: a newly allocated string, that is a
22359 // <str>: a UTF-8 encoded string
22360 // <len>: length of @str, in bytes, or -1 if @str is nul-terminated.
22361 static char* /*new*/ utf8_casefold()(char* str, ssize_t len) {
22362 return g_utf8_casefold(str, len);
22366 // Compares two strings for ordering using the linguistically
22367 // correct rules for the <link linkend="setlocale">current locale</link>.
22368 // When sorting a large number of strings, it will be significantly
22369 // faster to obtain collation keys with g_utf8_collate_key() and
22370 // compare the keys with strcmp() when sorting instead of sorting
22371 // the original strings.
22373 // 0 if they compare equal, &gt; 0 if @str1 compares after @str2.
22374 // RETURNS: &lt; 0 if @str1 compares before @str2,
22375 // <str1>: a UTF-8 encoded string
22376 // <str2>: a UTF-8 encoded string
22377 static int utf8_collate()(char* str1, char* str2) {
22378 return g_utf8_collate(str1, str2);
22382 // Converts a string into a collation key that can be compared
22383 // with other collation keys produced by the same function using
22384 // strcmp().
22386 // The results of comparing the collation keys of two strings
22387 // with strcmp() will always be the same as comparing the two
22388 // original keys with g_utf8_collate().
22390 // Note that this function depends on the
22391 // <link linkend="setlocale">current locale</link>.
22393 // be freed with g_free() when you are done with it.
22394 // RETURNS: a newly allocated string. This string should
22395 // <str>: a UTF-8 encoded string.
22396 // <len>: length of @str, in bytes, or -1 if @str is nul-terminated.
22397 static char* /*new*/ utf8_collate_key()(char* str, ssize_t len) {
22398 return g_utf8_collate_key(str, len);
22402 // VERSION: 2.8
22403 // Converts a string into a collation key that can be compared
22404 // with other collation keys produced by the same function using strcmp().
22406 // In order to sort filenames correctly, this function treats the dot '.'
22407 // as a special case. Most dictionary orderings seem to consider it
22408 // insignificant, thus producing the ordering "event.c" "eventgenerator.c"
22409 // "event.h" instead of "event.c" "event.h" "eventgenerator.c". Also, we
22410 // would like to treat numbers intelligently so that "file1" "file10" "file5"
22411 // is sorted as "file1" "file5" "file10".
22413 // Note that this function depends on the
22414 // <link linkend="setlocale">current locale</link>.
22416 // be freed with g_free() when you are done with it.
22417 // RETURNS: a newly allocated string. This string should
22418 // <str>: a UTF-8 encoded string.
22419 // <len>: length of @str, in bytes, or -1 if @str is nul-terminated.
22420 static char* /*new*/ utf8_collate_key_for_filename()(char* str, ssize_t len) {
22421 return g_utf8_collate_key_for_filename(str, len);
22425 // Finds the start of the next UTF-8 character in the string after @p.
22427 // @p does not have to be at the beginning of a UTF-8 character. No check
22428 // is made to see if the character found is actually valid other than
22429 // it starts with an appropriate byte.
22430 // RETURNS: a pointer to the found character or %NULL
22431 // <p>: a pointer to a position within a UTF-8 encoded string
22432 // <end>: a pointer to the byte following the end of the string, or %NULL to indicate that the string is nul-terminated.
22433 static char* /*new*/ utf8_find_next_char()(char* p, char* end) {
22434 return g_utf8_find_next_char(p, end);
22438 // Given a position @p with a UTF-8 encoded string @str, find the start
22439 // of the previous UTF-8 character starting before @p. Returns %NULL if no
22440 // UTF-8 characters are present in @str before @p.
22442 // @p does not have to be at the beginning of a UTF-8 character. No check
22443 // is made to see if the character found is actually valid other than
22444 // it starts with an appropriate byte.
22445 // RETURNS: a pointer to the found character or %NULL.
22446 // <str>: pointer to the beginning of a UTF-8 encoded string
22447 // <p>: pointer to some position within @str
22448 static char* /*new*/ utf8_find_prev_char()(char* str, char* p) {
22449 return g_utf8_find_prev_char(str, p);
22453 // Converts a sequence of bytes encoded as UTF-8 to a Unicode character.
22454 // If @p does not point to a valid UTF-8 encoded character, results are
22455 // undefined. If you are not sure that the bytes are complete
22456 // valid Unicode characters, you should use g_utf8_get_char_validated()
22457 // instead.
22458 // RETURNS: the resulting character
22459 // <p>: a pointer to Unicode character encoded as UTF-8
22460 static dchar utf8_get_char()(char* p) {
22461 return g_utf8_get_char(p);
22465 // Convert a sequence of bytes encoded as UTF-8 to a Unicode character.
22466 // This function checks for incomplete characters, for invalid characters
22467 // such as characters that are out of the range of Unicode, and for
22468 // overlong encodings of valid characters.
22470 // sequence at the end of a string that could begin a valid
22471 // character (or if @max_len is zero), returns (gunichar)-2;
22472 // otherwise, if @p does not point to a valid UTF-8 encoded
22473 // Unicode character, returns (gunichar)-1.
22474 // RETURNS: the resulting character. If @p points to a partial
22475 // <p>: a pointer to Unicode character encoded as UTF-8
22476 // <max_len>: the maximum number of bytes to read, or -1, for no maximum or if @p is nul-terminated
22477 static dchar utf8_get_char_validated()(char* p, ssize_t max_len) {
22478 return g_utf8_get_char_validated(p, max_len);
22482 // Converts a string into canonical form, standardizing
22483 // such issues as whether a character with an accent
22484 // is represented as a base character and combining
22485 // accent or as a single precomposed character. The
22486 // string has to be valid UTF-8, otherwise %NULL is
22487 // returned. You should generally call g_utf8_normalize()
22488 // before comparing two Unicode strings.
22490 // The normalization mode %G_NORMALIZE_DEFAULT only
22491 // standardizes differences that do not affect the
22492 // text content, such as the above-mentioned accent
22493 // representation. %G_NORMALIZE_ALL also standardizes
22494 // the "compatibility" characters in Unicode, such
22495 // as SUPERSCRIPT THREE to the standard forms
22496 // (in this case DIGIT THREE). Formatting information
22497 // may be lost but for most text operations such
22498 // characters should be considered the same.
22500 // %G_NORMALIZE_DEFAULT_COMPOSE and %G_NORMALIZE_ALL_COMPOSE
22501 // are like %G_NORMALIZE_DEFAULT and %G_NORMALIZE_ALL,
22502 // but returned a result with composed forms rather
22503 // than a maximally decomposed form. This is often
22504 // useful if you intend to convert the string to
22505 // a legacy encoding or pass it to a system with
22506 // less capable Unicode handling.
22508 // normalized form of @str, or %NULL if @str is not
22509 // valid UTF-8.
22510 // RETURNS: a newly allocated string, that is the
22511 // <str>: a UTF-8 encoded string.
22512 // <len>: length of @str, in bytes, or -1 if @str is nul-terminated.
22513 // <mode>: the type of normalization to perform.
22514 static char* /*new*/ utf8_normalize()(char* str, ssize_t len, NormalizeMode mode) {
22515 return g_utf8_normalize(str, len, mode);
22519 // Converts from an integer character offset to a pointer to a position
22520 // within the string.
22522 // Since 2.10, this function allows to pass a negative @offset to
22523 // step backwards. It is usually worth stepping backwards from the end
22524 // instead of forwards if @offset is in the last fourth of the string,
22525 // since moving forward is about 3 times faster than moving backward.
22527 // <note><para>
22528 // This function doesn't abort when reaching the end of @str. Therefore
22529 // you should be sure that @offset is within string boundaries before
22530 // calling that function. Call g_utf8_strlen() when unsure.
22532 // This limitation exists as this function is called frequently during
22533 // text rendering and therefore has to be as fast as possible.
22534 // </para></note>
22535 // RETURNS: the resulting pointer
22536 // <str>: a UTF-8 encoded string
22537 // <offset>: a character offset within @str
22538 static char* /*new*/ utf8_offset_to_pointer()(char* str, c_long offset) {
22539 return g_utf8_offset_to_pointer(str, offset);
22543 // Converts from a pointer to position within a string to a integer
22544 // character offset.
22546 // Since 2.10, this function allows @pos to be before @str, and returns
22547 // a negative offset in this case.
22548 // RETURNS: the resulting character offset
22549 // <str>: a UTF-8 encoded string
22550 // <pos>: a pointer to a position within @str
22551 static c_long utf8_pointer_to_offset()(char* str, char* pos) {
22552 return g_utf8_pointer_to_offset(str, pos);
22556 // Finds the previous UTF-8 character in the string before @p.
22558 // @p does not have to be at the beginning of a UTF-8 character. No check
22559 // is made to see if the character found is actually valid other than
22560 // it starts with an appropriate byte. If @p might be the first
22561 // character of the string, you must use g_utf8_find_prev_char() instead.
22562 // RETURNS: a pointer to the found character.
22563 // <p>: a pointer to a position within a UTF-8 encoded string
22564 static char* /*new*/ utf8_prev_char()(char* p) {
22565 return g_utf8_prev_char(p);
22569 // Finds the leftmost occurrence of the given Unicode character
22570 // in a UTF-8 encoded string, while limiting the search to @len bytes.
22571 // If @len is -1, allow unbounded search.
22573 // otherwise, a pointer to the start of the leftmost occurrence of
22574 // the character in the string.
22575 // RETURNS: %NULL if the string does not contain the character,
22576 // <p>: a nul-terminated UTF-8 encoded string
22577 // <len>: the maximum length of @p
22578 // <c>: a Unicode character
22579 static char* /*new*/ utf8_strchr()(char* p, ssize_t len, dchar c) {
22580 return g_utf8_strchr(p, len, c);
22584 // Converts all Unicode characters in the string that have a case
22585 // to lowercase. The exact manner that this is done depends
22586 // on the current locale, and may result in the number of
22587 // characters in the string changing.
22589 // converted to lowercase.
22590 // RETURNS: a newly allocated string, with all characters
22591 // <str>: a UTF-8 encoded string
22592 // <len>: length of @str, in bytes, or -1 if @str is nul-terminated.
22593 static char* /*new*/ utf8_strdown()(char* str, ssize_t len) {
22594 return g_utf8_strdown(str, len);
22598 // Computes the length of the string in characters, not including
22599 // the terminating nul character.
22600 // RETURNS: the length of the string in characters
22601 // <p>: pointer to the start of a UTF-8 encoded string
22602 // <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.
22603 static c_long utf8_strlen()(char* p, ssize_t max) {
22604 return g_utf8_strlen(p, max);
22608 // Like the standard C strncpy() function, but
22609 // copies a given number of characters instead of a given number of
22610 // bytes. The @src string must be valid UTF-8 encoded text.
22611 // (Use g_utf8_validate() on all text before trying to use UTF-8
22612 // utility functions with it.)
22613 // RETURNS: @dest
22614 // <dest>: buffer to fill with characters from @src
22615 // <src>: UTF-8 encoded string
22616 // <n>: character count
22617 static char* /*new*/ utf8_strncpy()(char* dest, char* src, size_t n) {
22618 return g_utf8_strncpy(dest, src, n);
22622 // Find the rightmost occurrence of the given Unicode character
22623 // in a UTF-8 encoded string, while limiting the search to @len bytes.
22624 // If @len is -1, allow unbounded search.
22626 // otherwise, a pointer to the start of the rightmost occurrence of the
22627 // character in the string.
22628 // RETURNS: %NULL if the string does not contain the character,
22629 // <p>: a nul-terminated UTF-8 encoded string
22630 // <len>: the maximum length of @p
22631 // <c>: a Unicode character
22632 static char* /*new*/ utf8_strrchr()(char* p, ssize_t len, dchar c) {
22633 return g_utf8_strrchr(p, len, c);
22637 // VERSION: 2.2
22638 // Reverses a UTF-8 string. @str must be valid UTF-8 encoded text.
22639 // (Use g_utf8_validate() on all text before trying to use UTF-8
22640 // utility functions with it.)
22642 // This function is intended for programmatic uses of reversed strings.
22643 // It pays no attention to decomposed characters, combining marks, byte
22644 // order marks, directional indicators (LRM, LRO, etc) and similar
22645 // characters which might need special handling when reversing a string
22646 // for display purposes.
22648 // Note that unlike g_strreverse(), this function returns
22649 // newly-allocated memory, which should be freed with g_free() when
22650 // no longer needed.
22651 // RETURNS: a newly-allocated string which is the reverse of @str.
22652 // <str>: a UTF-8 encoded string
22653 // <len>: the maximum length of @str to use, in bytes. If @len < 0, then the string is nul-terminated.
22654 static char* /*new*/ utf8_strreverse()(char* str, ssize_t len) {
22655 return g_utf8_strreverse(str, len);
22659 // Converts all Unicode characters in the string that have a case
22660 // to uppercase. The exact manner that this is done depends
22661 // on the current locale, and may result in the number of
22662 // characters in the string increasing. (For instance, the
22663 // German ess-zet will be changed to SS.)
22665 // converted to uppercase.
22666 // RETURNS: a newly allocated string, with all characters
22667 // <str>: a UTF-8 encoded string
22668 // <len>: length of @str, in bytes, or -1 if @str is nul-terminated.
22669 static char* /*new*/ utf8_strup()(char* str, ssize_t len) {
22670 return g_utf8_strup(str, len);
22674 // VERSION: 2.30
22675 // Copies a substring out of a UTF-8 encoded string.
22676 // The substring will contain @end_pos - @start_pos
22677 // characters.
22679 // substring. Free with g_free() when no longer needed.
22680 // RETURNS: a newly allocated copy of the requested
22681 // <str>: a UTF-8 encoded string
22682 // <start_pos>: a character offset within @str
22683 // <end_pos>: another character offset within @str
22684 static char* /*new*/ utf8_substring()(char* str, c_long start_pos, c_long end_pos) {
22685 return g_utf8_substring(str, start_pos, end_pos);
22689 // Convert a string from UTF-8 to a 32-bit fixed width
22690 // representation as UCS-4. A trailing 0 character will be added to the
22691 // string after the converted text.
22693 // This value must be freed with g_free(). If an
22694 // error occurs, %NULL will be returned and
22695 // @error set.
22696 // RETURNS: a pointer to a newly allocated UCS-4 string.
22697 // <str>: a UTF-8 encoded string
22698 // <len>: the maximum length of @str to use, in bytes. If @len < 0, then the string is nul-terminated.
22699 // <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.
22700 // <items_written>: location to store number of characters written or %NULL. The value here stored does not include the trailing 0 character.
22701 static dchar* utf8_to_ucs4()(char* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error=null) {
22702 return g_utf8_to_ucs4(str, len, items_read, items_written, error);
22706 // Convert a string from UTF-8 to a 32-bit fixed width
22707 // representation as UCS-4, assuming valid UTF-8 input.
22708 // This function is roughly twice as fast as g_utf8_to_ucs4()
22709 // but does no error checking on the input. A trailing 0 character
22710 // will be added to the string after the converted text.
22712 // This value must be freed with g_free().
22713 // RETURNS: a pointer to a newly allocated UCS-4 string.
22714 // <str>: a UTF-8 encoded string
22715 // <len>: the maximum length of @str to use, in bytes. If @len < 0, then the string is nul-terminated.
22716 // <items_written>: location to store the number of characters in the result, or %NULL.
22717 static dchar* utf8_to_ucs4_fast()(char* str, c_long len, c_long* items_written) {
22718 return g_utf8_to_ucs4_fast(str, len, items_written);
22722 // Convert a string from UTF-8 to UTF-16. A 0 character will be
22723 // added to the result after the converted text.
22725 // This value must be freed with g_free(). If an
22726 // error occurs, %NULL will be returned and
22727 // @error set.
22728 // RETURNS: a pointer to a newly allocated UTF-16 string.
22729 // <str>: a UTF-8 encoded string
22730 // <len>: the maximum length (number of bytes) of @str to use. If @len < 0, then the string is nul-terminated.
22731 // <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.
22732 // <items_written>: location to store number of <type>gunichar2</type> written, or %NULL. The value stored here does not include the trailing 0.
22733 static wchar* utf8_to_utf16()(char* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error=null) {
22734 return g_utf8_to_utf16(str, len, items_read, items_written, error);
22738 // Validates UTF-8 encoded text. @str is the text to validate;
22739 // if @str is nul-terminated, then @max_len can be -1, otherwise
22740 // @max_len should be the number of bytes to validate.
22741 // If @end is non-%NULL, then the end of the valid range
22742 // will be stored there (i.e. the start of the first invalid
22743 // character if some bytes were invalid, or the end of the text
22744 // being validated otherwise).
22746 // Note that g_utf8_validate() returns %FALSE if @max_len is
22747 // positive and NUL is met before @max_len bytes have been read.
22749 // Returns %TRUE if all of @str was valid. Many GLib and GTK+
22750 // routines <emphasis>require</emphasis> valid UTF-8 as input;
22751 // so data read from a file or the network should be checked
22752 // with g_utf8_validate() before doing anything else with it.
22753 // RETURNS: %TRUE if the text was valid UTF-8
22754 // <str>: a pointer to character data
22755 // <max_len>: max bytes to validate, or -1 to go until NUL
22756 // <end>: return location for end of valid data
22757 static int utf8_validate()(char* str, ssize_t max_len, /*out*/ char** end=null) {
22758 return g_utf8_validate(str, max_len, end);
22761 static Type variant_get_gtype()() {
22762 return g_variant_get_gtype();
22766 // VERSION: 2.24
22767 // Determines the type of @value.
22769 // The return value is valid for the lifetime of @value and must not
22770 // be freed.
22771 // RETURNS: a #GVariantType
22772 // <value>: a #GVariant
22773 static VariantType* variant_get_type()(Variant* value) {
22774 return g_variant_get_type(value);
22778 // VERSION: 2.24
22779 // MOVED TO: Variant.is_object_path
22780 // Determines if a given string is a valid D-Bus object path. You
22781 // should ensure that a string is a valid D-Bus object path before
22782 // passing it to g_variant_new_object_path().
22784 // A valid object path starts with '/' followed by zero or more
22785 // sequences of characters separated by '/' characters. Each sequence
22786 // must contain only the characters "[A-Z][a-z][0-9]_". No sequence
22787 // (including the one following the final '/' character) may be empty.
22788 // RETURNS: %TRUE if @string is a D-Bus object path
22789 // <string>: a normal C nul-terminated string
22790 static int variant_is_object_path()(char* string_) {
22791 return g_variant_is_object_path(string_);
22795 // VERSION: 2.24
22796 // MOVED TO: Variant.is_signature
22797 // Determines if a given string is a valid D-Bus type signature. You
22798 // should ensure that a string is a valid D-Bus type signature before
22799 // passing it to g_variant_new_signature().
22801 // D-Bus type signatures consist of zero or more definite #GVariantType
22802 // strings in sequence.
22803 // RETURNS: %TRUE if @string is a D-Bus type signature
22804 // <string>: a normal C nul-terminated string
22805 static int variant_is_signature()(char* string_) {
22806 return g_variant_is_signature(string_);
22810 // MOVED TO: Variant.parse
22811 // Parses a #GVariant from a text representation.
22813 // A single #GVariant is parsed from the content of @text.
22815 // The format is described <link linkend='gvariant-text'>here</link>.
22817 // The memory at @limit will never be accessed and the parser behaves as
22818 // if the character at @limit is the nul terminator. This has the
22819 // effect of bounding @text.
22821 // If @endptr is non-%NULL then @text is permitted to contain data
22822 // following the value that this function parses and @endptr will be
22823 // updated to point to the first character past the end of the text
22824 // parsed by this function. If @endptr is %NULL and there is extra data
22825 // then an error is returned.
22827 // If @type is non-%NULL then the value will be parsed to have that
22828 // type. This may result in additional parse errors (in the case that
22829 // the parsed value doesn't fit the type) but may also result in fewer
22830 // errors (in the case that the type would have been ambiguous, such as
22831 // with empty arrays).
22833 // In the event that the parsing is successful, the resulting #GVariant
22834 // is returned.
22836 // In case of any error, %NULL will be returned. If @error is non-%NULL
22837 // then it will be set to reflect the error that occurred.
22839 // Officially, the language understood by the parser is "any string
22840 // produced by g_variant_print()".
22841 // <type>: a #GVariantType, or %NULL
22842 // <text>: a string containing a GVariant in text form
22843 // <limit>: a pointer to the end of @text, or %NULL
22844 // <endptr>: a location to store the end pointer, or %NULL
22845 static Variant* /*new*/ variant_parse()(VariantType* type, char* text, char* limit, char** endptr, GLib2.Error** error=null) {
22846 return g_variant_parse(type, text, limit, endptr, error);
22849 // MOVED TO: Variant.parser_get_error_quark
22850 static Quark variant_parser_get_error_quark()() {
22851 return g_variant_parser_get_error_quark();
22854 // MOVED TO: VariantType.checked_
22855 static VariantType* variant_type_checked_()(char* arg_a) {
22856 return g_variant_type_checked_(arg_a);
22860 // MOVED TO: VariantType.string_is_valid
22861 // Checks if @type_string is a valid GVariant type string. This call is
22862 // equivalent to calling g_variant_type_string_scan() and confirming
22863 // that the following character is a nul terminator.
22865 // Since 2.24
22866 // RETURNS: %TRUE if @type_string is exactly one valid type string
22867 // <type_string>: a pointer to any string
22868 static int variant_type_string_is_valid()(char* type_string) {
22869 return g_variant_type_string_is_valid(type_string);
22873 // VERSION: 2.24
22874 // MOVED TO: VariantType.string_scan
22875 // Scan for a single complete and valid GVariant type string in @string.
22876 // The memory pointed to by @limit (or bytes beyond it) is never
22877 // accessed.
22879 // If a valid type string is found, @endptr is updated to point to the
22880 // first character past the end of the string that was found and %TRUE
22881 // is returned.
22883 // If there is no valid type string starting at @string, or if the type
22884 // string does not end before @limit then %FALSE is returned.
22886 // For the simple case of checking if a string is a valid type string,
22887 // see g_variant_type_string_is_valid().
22888 // RETURNS: %TRUE if a valid type string was found
22889 // <string>: a pointer to any string
22890 // <limit>: the end of @string, or %NULL
22891 // <endptr>: location to store the end pointer, or %NULL
22892 static int variant_type_string_scan()(char* string_, char* limit=null, /*out*/ char** endptr=null) {
22893 return g_variant_type_string_scan(string_, limit, endptr);
22897 // Unintrospectable function: vasprintf() / g_vasprintf()
22898 // VERSION: 2.4
22899 // An implementation of the GNU vasprintf() function which supports
22900 // positional parameters, as specified in the Single Unix Specification.
22901 // This function is similar to g_vsprintf(), except that it allocates a
22902 // string to hold the output, instead of putting the output in a buffer
22903 // you allocate in advance.
22904 // RETURNS: the number of bytes printed.
22905 // <string>: the return location for the newly-allocated string.
22906 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
22907 // <args>: the list of arguments to insert in the output.
22908 static int vasprintf()(char** string_, char* format, va_list args) {
22909 return g_vasprintf(string_, format, args);
22913 // Unintrospectable function: vfprintf() / g_vfprintf()
22914 // VERSION: 2.2
22915 // An implementation of the standard fprintf() function which supports
22916 // positional parameters, as specified in the Single Unix Specification.
22917 // RETURNS: the number of bytes printed.
22918 // <file>: the stream to write to.
22919 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
22920 // <args>: the list of arguments to insert in the output.
22921 static int vfprintf()(FILE* file, char* format, va_list args) {
22922 return g_vfprintf(file, format, args);
22926 // Unintrospectable function: vprintf() / g_vprintf()
22927 // VERSION: 2.2
22928 // An implementation of the standard vprintf() function which supports
22929 // positional parameters, as specified in the Single Unix Specification.
22930 // RETURNS: the number of bytes printed.
22931 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
22932 // <args>: the list of arguments to insert in the output.
22933 static int vprintf()(char* format, va_list args) {
22934 return g_vprintf(format, args);
22938 // Unintrospectable function: vsnprintf() / g_vsnprintf()
22939 // A safer form of the standard vsprintf() function. The output is guaranteed
22940 // to not exceed @n characters (including the terminating nul character), so
22941 // it is easy to ensure that a buffer overflow cannot occur.
22943 // See also g_strdup_vprintf().
22945 // In versions of GLib prior to 1.2.3, this function may return -1 if the
22946 // output was truncated, and the truncated string may not be nul-terminated.
22947 // In versions prior to 1.3.12, this function returns the length of the output
22948 // string.
22950 // The return value of g_vsnprintf() conforms to the vsnprintf() function
22951 // as standardized in ISO C99. Note that this is different from traditional
22952 // vsnprintf(), which returns the length of the output string.
22954 // The format string may contain positional parameters, as specified in
22955 // the Single Unix Specification.
22957 // was large enough.
22958 // RETURNS: the number of bytes which would be produced if the buffer
22959 // <string>: the buffer to hold the output.
22960 // <n>: the maximum number of bytes to produce (including the terminating nul character).
22961 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
22962 // <args>: the list of arguments to insert in the output.
22963 static int vsnprintf()(char* string_, c_ulong n, char* format, va_list args) {
22964 return g_vsnprintf(string_, n, format, args);
22968 // Unintrospectable function: vsprintf() / g_vsprintf()
22969 // VERSION: 2.2
22970 // An implementation of the standard vsprintf() function which supports
22971 // positional parameters, as specified in the Single Unix Specification.
22972 // RETURNS: the number of bytes printed.
22973 // <string>: the buffer to hold the output.
22974 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
22975 // <args>: the list of arguments to insert in the output.
22976 static int vsprintf()(char* string_, char* format, va_list args) {
22977 return g_vsprintf(string_, format, args);
22980 static void warn_message()(char* domain, char* file, int line, char* func, char* warnexpr) {
22981 g_warn_message(domain, file, line, func, warnexpr);
22985 // C prototypes:
22987 extern (C) {
22988 void g_allocator_free(Allocator* this_);
22989 Allocator* g_allocator_new(char* name, uint n_preallocs);
22990 Array* g_array_append_vals(Array* array, const(void)* data, uint len);
22991 char* /*new*/ g_array_free(Array* array, int free_segment);
22992 uint g_array_get_element_size(Array* array);
22993 Array* g_array_insert_vals(Array* array, uint index_, const(void)* data, uint len);
22994 Array* g_array_new(int zero_terminated, int clear_, uint element_size);
22995 Array* g_array_prepend_vals(Array* array, const(void)* data, uint len);
22996 Array* g_array_ref(Array* array);
22997 Array* g_array_remove_index(Array* array, uint index_);
22998 Array* g_array_remove_index_fast(Array* array, uint index_);
22999 Array* g_array_remove_range(Array* array, uint index_, uint length);
23000 Array* g_array_set_size(Array* array, uint length);
23001 Array* g_array_sized_new(int zero_terminated, int clear_, uint element_size, uint reserved_size);
23002 void g_array_sort(Array* array, CompareFunc compare_func);
23003 void g_array_sort_with_data(Array* array, CompareDataFunc compare_func, void* user_data);
23004 void g_array_unref(Array* array);
23005 int g_async_queue_length(AsyncQueue* this_);
23006 int g_async_queue_length_unlocked(AsyncQueue* this_);
23007 void g_async_queue_lock(AsyncQueue* this_);
23008 void* g_async_queue_pop(AsyncQueue* this_);
23009 void* g_async_queue_pop_unlocked(AsyncQueue* this_);
23010 void g_async_queue_push(AsyncQueue* this_, void* data);
23011 void g_async_queue_push_sorted(AsyncQueue* this_, void* data, CompareDataFunc func, void* user_data);
23012 void g_async_queue_push_sorted_unlocked(AsyncQueue* this_, void* data, CompareDataFunc func, void* user_data);
23013 void g_async_queue_push_unlocked(AsyncQueue* this_, void* data);
23014 AsyncQueue* g_async_queue_ref(AsyncQueue* this_);
23015 void g_async_queue_ref_unlocked(AsyncQueue* this_);
23016 void g_async_queue_sort(AsyncQueue* this_, CompareDataFunc func, void* user_data);
23017 void g_async_queue_sort_unlocked(AsyncQueue* this_, CompareDataFunc func, void* user_data);
23018 void* g_async_queue_timed_pop(AsyncQueue* this_, TimeVal* end_time);
23019 void* g_async_queue_timed_pop_unlocked(AsyncQueue* this_, TimeVal* end_time);
23020 void* g_async_queue_try_pop(AsyncQueue* this_);
23021 void* g_async_queue_try_pop_unlocked(AsyncQueue* this_);
23022 void g_async_queue_unlock(AsyncQueue* this_);
23023 void g_async_queue_unref(AsyncQueue* this_);
23024 void g_async_queue_unref_and_unlock(AsyncQueue* this_);
23025 AsyncQueue* g_async_queue_new();
23026 AsyncQueue* g_async_queue_new_full(DestroyNotify item_free_func);
23027 void g_bookmark_file_add_application(BookmarkFile* this_, char* uri, char* name, char* exec);
23028 void g_bookmark_file_add_group(BookmarkFile* this_, char* uri, char* group);
23029 void g_bookmark_file_free(BookmarkFile* this_);
23030 time_t g_bookmark_file_get_added(BookmarkFile* this_, char* uri, GLib2.Error** error);
23031 int g_bookmark_file_get_app_info(BookmarkFile* this_, char* uri, char* name, char** exec, uint* count, time_t* stamp, GLib2.Error** error);
23032 char** g_bookmark_file_get_applications(BookmarkFile* this_, char* uri, size_t* length, GLib2.Error** error);
23033 char* /*new*/ g_bookmark_file_get_description(BookmarkFile* this_, char* uri, GLib2.Error** error);
23034 char** g_bookmark_file_get_groups(BookmarkFile* this_, char* uri, size_t* length, GLib2.Error** error);
23035 int g_bookmark_file_get_icon(BookmarkFile* this_, char* uri, char** href, char** mime_type, GLib2.Error** error);
23036 int g_bookmark_file_get_is_private(BookmarkFile* this_, char* uri, GLib2.Error** error);
23037 char* /*new*/ g_bookmark_file_get_mime_type(BookmarkFile* this_, char* uri, GLib2.Error** error);
23038 time_t g_bookmark_file_get_modified(BookmarkFile* this_, char* uri, GLib2.Error** error);
23039 int g_bookmark_file_get_size(BookmarkFile* this_);
23040 char* /*new*/ g_bookmark_file_get_title(BookmarkFile* this_, char* uri, GLib2.Error** error);
23041 char** g_bookmark_file_get_uris(BookmarkFile* this_, size_t* length);
23042 time_t g_bookmark_file_get_visited(BookmarkFile* this_, char* uri, GLib2.Error** error);
23043 int g_bookmark_file_has_application(BookmarkFile* this_, char* uri, char* name, GLib2.Error** error);
23044 int g_bookmark_file_has_group(BookmarkFile* this_, char* uri, char* group, GLib2.Error** error);
23045 int g_bookmark_file_has_item(BookmarkFile* this_, char* uri);
23046 int g_bookmark_file_load_from_data(BookmarkFile* this_, char* data, size_t length, GLib2.Error** error);
23047 int g_bookmark_file_load_from_data_dirs(BookmarkFile* this_, char* file, char** full_path, GLib2.Error** error);
23048 int g_bookmark_file_load_from_file(BookmarkFile* this_, char* filename, GLib2.Error** error);
23049 int g_bookmark_file_move_item(BookmarkFile* this_, char* old_uri, char* new_uri, GLib2.Error** error);
23050 int g_bookmark_file_remove_application(BookmarkFile* this_, char* uri, char* name, GLib2.Error** error);
23051 int g_bookmark_file_remove_group(BookmarkFile* this_, char* uri, char* group, GLib2.Error** error);
23052 int g_bookmark_file_remove_item(BookmarkFile* this_, char* uri, GLib2.Error** error);
23053 void g_bookmark_file_set_added(BookmarkFile* this_, char* uri, time_t added);
23054 int g_bookmark_file_set_app_info(BookmarkFile* this_, char* uri, char* name, char* exec, int count, time_t stamp, GLib2.Error** error);
23055 void g_bookmark_file_set_description(BookmarkFile* this_, char* uri, char* description);
23056 void g_bookmark_file_set_groups(BookmarkFile* this_, char* uri, char** groups, size_t length);
23057 void g_bookmark_file_set_icon(BookmarkFile* this_, char* uri, char* href, char* mime_type);
23058 void g_bookmark_file_set_is_private(BookmarkFile* this_, char* uri, int is_private);
23059 void g_bookmark_file_set_mime_type(BookmarkFile* this_, char* uri, char* mime_type);
23060 void g_bookmark_file_set_modified(BookmarkFile* this_, char* uri, time_t modified);
23061 void g_bookmark_file_set_title(BookmarkFile* this_, char* uri, char* title);
23062 void g_bookmark_file_set_visited(BookmarkFile* this_, char* uri, time_t visited);
23063 char* /*new*/ g_bookmark_file_to_data(BookmarkFile* this_, size_t* length, GLib2.Error** error);
23064 int g_bookmark_file_to_file(BookmarkFile* this_, char* filename, GLib2.Error** error);
23065 Quark g_bookmark_file_error_quark();
23066 BookmarkFile* g_bookmark_file_new();
23067 ByteArray* g_byte_array_append(ByteArray* array, ubyte* data, uint len);
23068 ubyte* g_byte_array_free(ByteArray* array, int free_segment);
23069 ByteArray* g_byte_array_new();
23070 ByteArray* g_byte_array_prepend(ByteArray* array, ubyte* data, uint len);
23071 ByteArray* g_byte_array_ref(ByteArray* array);
23072 ByteArray* g_byte_array_remove_index(ByteArray* array, uint index_);
23073 ByteArray* g_byte_array_remove_index_fast(ByteArray* array, uint index_);
23074 ByteArray* g_byte_array_remove_range(ByteArray* array, uint index_, uint length);
23075 ByteArray* g_byte_array_set_size(ByteArray* array, uint length);
23076 ByteArray* g_byte_array_sized_new(uint reserved_size);
23077 void g_byte_array_sort(ByteArray* array, CompareFunc compare_func);
23078 void g_byte_array_sort_with_data(ByteArray* array, CompareDataFunc compare_func, void* user_data);
23079 void g_byte_array_unref(ByteArray* array);
23080 void g_cache_destroy(Cache* this_);
23081 void* g_cache_insert(Cache* this_, void* key);
23082 void g_cache_key_foreach(Cache* this_, HFunc func, void* user_data);
23083 void g_cache_remove(Cache* this_, const(void)* value);
23084 void g_cache_value_foreach(Cache* this_, HFunc func, void* user_data);
23085 Cache* g_cache_new(CacheNewFunc value_new_func, CacheDestroyFunc value_destroy_func, CacheDupFunc key_dup_func, CacheDestroyFunc key_destroy_func, HashFunc hash_key_func, HashFunc hash_value_func, EqualFunc key_equal_func);
23086 Checksum* g_checksum_copy(Checksum* this_);
23087 void g_checksum_free(Checksum* this_);
23088 void g_checksum_get_digest(Checksum* this_, ubyte* buffer, size_t* digest_len);
23089 char* g_checksum_get_string(Checksum* this_);
23090 void g_checksum_reset(Checksum* this_);
23091 void g_checksum_update(Checksum* this_, ubyte* data, ssize_t length);
23092 Checksum* g_checksum_new(ChecksumType checksum_type);
23093 ssize_t g_checksum_type_get_length(ChecksumType checksum_type);
23094 void g_completion_add_items(Completion* this_, GLib2.List* items);
23095 void g_completion_clear_items(Completion* this_);
23096 GLib2.List* g_completion_complete(Completion* this_, char* prefix, char** new_prefix);
23097 GLib2.List* g_completion_complete_utf8(Completion* this_, char* prefix, char** new_prefix);
23098 void g_completion_free(Completion* this_);
23099 void g_completion_remove_items(Completion* this_, GLib2.List* items);
23100 void g_completion_set_compare(Completion* this_, CompletionStrncmpFunc strncmp_func);
23101 Completion* g_completion_new(CompletionFunc func);
23102 Date* /*new*/ g_date_new();
23103 Date* /*new*/ g_date_new_dmy(DateDay day, DateMonth month, DateYear year);
23104 Date* /*new*/ g_date_new_julian(uint julian_day);
23105 void g_date_add_days(Date* this_, uint n_days);
23106 void g_date_add_months(Date* this_, uint n_months);
23107 void g_date_add_years(Date* this_, uint n_years);
23108 void g_date_clamp(Date* this_, Date* min_date, Date* max_date);
23109 void g_date_clear(Date* this_, uint n_dates);
23110 int g_date_compare(Date* this_, Date* rhs);
23111 int g_date_days_between(Date* this_, Date* date2);
23112 void g_date_free(Date* this_);
23113 DateDay g_date_get_day(Date* this_);
23114 uint g_date_get_day_of_year(Date* this_);
23115 uint g_date_get_iso8601_week_of_year(Date* this_);
23116 uint g_date_get_julian(Date* this_);
23117 uint g_date_get_monday_week_of_year(Date* this_);
23118 DateMonth g_date_get_month(Date* this_);
23119 uint g_date_get_sunday_week_of_year(Date* this_);
23120 DateWeekday g_date_get_weekday(Date* this_);
23121 DateYear g_date_get_year(Date* this_);
23122 int g_date_is_first_of_month(Date* this_);
23123 int g_date_is_last_of_month(Date* this_);
23124 void g_date_order(Date* this_, Date* date2);
23125 void g_date_set_day(Date* this_, DateDay day);
23126 void g_date_set_dmy(Date* this_, DateDay day, DateMonth month, DateYear y);
23127 void g_date_set_julian(Date* this_, uint julian_date);
23128 void g_date_set_month(Date* this_, DateMonth month);
23129 void g_date_set_parse(Date* this_, char* str);
23130 void g_date_set_time(Date* this_, Time time_);
23131 void g_date_set_time_t(Date* this_, time_t timet);
23132 void g_date_set_time_val(Date* this_, TimeVal* timeval);
23133 void g_date_set_year(Date* this_, DateYear year);
23134 void g_date_subtract_days(Date* this_, uint n_days);
23135 void g_date_subtract_months(Date* this_, uint n_months);
23136 void g_date_subtract_years(Date* this_, uint n_years);
23137 void g_date_to_struct_tm(Date* this_, void** tm);
23138 int g_date_valid(Date* this_);
23139 ubyte g_date_get_days_in_month(DateMonth month, DateYear year);
23140 ubyte g_date_get_monday_weeks_in_year(DateYear year);
23141 ubyte g_date_get_sunday_weeks_in_year(DateYear year);
23142 int g_date_is_leap_year(DateYear year);
23143 size_t g_date_strftime(char* s, size_t slen, char* format, Date* date);
23144 int g_date_valid_day(DateDay day);
23145 int g_date_valid_dmy(DateDay day, DateMonth month, DateYear year);
23146 int g_date_valid_julian(uint julian_date);
23147 int g_date_valid_month(DateMonth month);
23148 int g_date_valid_weekday(DateWeekday weekday);
23149 int g_date_valid_year(DateYear year);
23150 DateTime* /*new*/ g_date_time_new(TimeZone* tz, int year, int month, int day, int hour, int minute, double seconds);
23151 DateTime* /*new*/ g_date_time_new_from_timeval_local(TimeVal* tv);
23152 DateTime* /*new*/ g_date_time_new_from_timeval_utc(TimeVal* tv);
23153 DateTime* /*new*/ g_date_time_new_from_unix_local(long t);
23154 DateTime* /*new*/ g_date_time_new_from_unix_utc(long t);
23155 DateTime* /*new*/ g_date_time_new_local(int year, int month, int day, int hour, int minute, double seconds);
23156 DateTime* /*new*/ g_date_time_new_now(TimeZone* tz);
23157 DateTime* /*new*/ g_date_time_new_now_local();
23158 DateTime* /*new*/ g_date_time_new_now_utc();
23159 DateTime* /*new*/ g_date_time_new_utc(int year, int month, int day, int hour, int minute, double seconds);
23160 DateTime* /*new*/ g_date_time_add(DateTime* this_, TimeSpan timespan);
23161 DateTime* /*new*/ g_date_time_add_days(DateTime* this_, int days);
23162 DateTime* /*new*/ g_date_time_add_full(DateTime* this_, int years, int months, int days, int hours, int minutes, double seconds);
23163 DateTime* /*new*/ g_date_time_add_hours(DateTime* this_, int hours);
23164 DateTime* /*new*/ g_date_time_add_minutes(DateTime* this_, int minutes);
23165 DateTime* /*new*/ g_date_time_add_months(DateTime* this_, int months);
23166 DateTime* /*new*/ g_date_time_add_seconds(DateTime* this_, double seconds);
23167 DateTime* /*new*/ g_date_time_add_weeks(DateTime* this_, int weeks);
23168 DateTime* /*new*/ g_date_time_add_years(DateTime* this_, int years);
23169 TimeSpan g_date_time_difference(DateTime* this_, DateTime* begin);
23170 char* /*new*/ g_date_time_format(DateTime* this_, char* format);
23171 int g_date_time_get_day_of_month(DateTime* this_);
23172 int g_date_time_get_day_of_week(DateTime* this_);
23173 int g_date_time_get_day_of_year(DateTime* this_);
23174 int g_date_time_get_hour(DateTime* this_);
23175 int g_date_time_get_microsecond(DateTime* this_);
23176 int g_date_time_get_minute(DateTime* this_);
23177 int g_date_time_get_month(DateTime* this_);
23178 int g_date_time_get_second(DateTime* this_);
23179 double g_date_time_get_seconds(DateTime* this_);
23180 char* g_date_time_get_timezone_abbreviation(DateTime* this_);
23181 TimeSpan g_date_time_get_utc_offset(DateTime* this_);
23182 int g_date_time_get_week_numbering_year(DateTime* this_);
23183 int g_date_time_get_week_of_year(DateTime* this_);
23184 int g_date_time_get_year(DateTime* this_);
23185 void g_date_time_get_ymd(DateTime* this_, /*out*/ int* year, /*out*/ int* month, /*out*/ int* day);
23186 int g_date_time_is_daylight_savings(DateTime* this_);
23187 DateTime* /*new*/ g_date_time_ref(DateTime* this_);
23188 DateTime* /*new*/ g_date_time_to_local(DateTime* this_);
23189 int g_date_time_to_timeval(DateTime* this_, TimeVal* tv);
23190 DateTime* /*new*/ g_date_time_to_timezone(DateTime* this_, TimeZone* tz);
23191 long g_date_time_to_unix(DateTime* this_);
23192 DateTime* /*new*/ g_date_time_to_utc(DateTime* this_);
23193 void g_date_time_unref(DateTime* this_);
23194 int g_date_time_compare(const(void)* dt1, const(void)* dt2);
23195 int g_date_time_equal(const(void)* dt1, const(void)* dt2);
23196 uint g_date_time_hash(const(void)* datetime);
23197 void g_dir_close(Dir* this_);
23198 char* g_dir_read_name(Dir* this_);
23199 void g_dir_rewind(Dir* this_);
23200 char* /*new*/ g_dir_make_tmp(char* tmpl, GLib2.Error** error);
23201 Dir* g_dir_open(char* path, uint flags, GLib2.Error** error);
23202 Error* /*new*/ g_error_new(Quark domain, int code, char* format, ...);
23203 Error* /*new*/ g_error_new_literal(Quark domain, int code, char* message);
23204 Error* /*new*/ g_error_new_valist(Quark domain, int code, char* format, va_list args);
23205 Error* /*new*/ g_error_copy(Error* this_);
23206 void g_error_free(Error* this_);
23207 int g_error_matches(Error* this_, Quark domain, int code);
23208 void g_hash_table_destroy(GLib2.HashTable* hash_table);
23209 void* g_hash_table_find(GLib2.HashTable* hash_table, HRFunc predicate, void* user_data);
23210 void g_hash_table_foreach(GLib2.HashTable* hash_table, HFunc func, void* user_data);
23211 uint g_hash_table_foreach_remove(GLib2.HashTable* hash_table, HRFunc func, void* user_data);
23212 uint g_hash_table_foreach_steal(GLib2.HashTable* hash_table, HRFunc func, void* user_data);
23213 GLib2.List* g_hash_table_get_keys(GLib2.HashTable* hash_table);
23214 GLib2.List* g_hash_table_get_values(GLib2.HashTable* hash_table);
23215 void g_hash_table_insert(GLib2.HashTable* hash_table, void* key, void* value);
23216 void* g_hash_table_lookup(GLib2.HashTable* hash_table, const(void)* key);
23217 int g_hash_table_lookup_extended(GLib2.HashTable* hash_table, const(void)* lookup_key, void** orig_key, void** value);
23218 GLib2.HashTable* g_hash_table_new(HashFunc hash_func, EqualFunc key_equal_func);
23219 GLib2.HashTable* g_hash_table_new_full(HashFunc hash_func, EqualFunc key_equal_func, DestroyNotify key_destroy_func, DestroyNotify value_destroy_func);
23220 GLib2.HashTable* g_hash_table_ref(GLib2.HashTable* hash_table);
23221 int g_hash_table_remove(GLib2.HashTable* hash_table, const(void)* key);
23222 void g_hash_table_remove_all(GLib2.HashTable* hash_table);
23223 void g_hash_table_replace(GLib2.HashTable* hash_table, void* key, void* value);
23224 uint g_hash_table_size(GLib2.HashTable* hash_table);
23225 int g_hash_table_steal(GLib2.HashTable* hash_table, const(void)* key);
23226 void g_hash_table_steal_all(GLib2.HashTable* hash_table);
23227 void g_hash_table_unref(GLib2.HashTable* hash_table);
23228 GLib2.HashTable* g_hash_table_iter_get_hash_table(HashTableIter* this_);
23229 void g_hash_table_iter_init(HashTableIter* this_, GLib2.HashTable* hash_table);
23230 int g_hash_table_iter_next(HashTableIter* this_, void** key, void** value);
23231 void g_hash_table_iter_remove(HashTableIter* this_);
23232 void g_hash_table_iter_replace(HashTableIter* this_, void* value);
23233 void g_hash_table_iter_steal(HashTableIter* this_);
23234 Hmac* g_hmac_copy(Hmac* this_);
23235 void g_hmac_get_digest(Hmac* this_, ubyte* buffer, size_t* digest_len);
23236 char* g_hmac_get_string(Hmac* this_);
23237 Hmac* g_hmac_ref(Hmac* this_);
23238 void g_hmac_unref(Hmac* this_);
23239 void g_hmac_update(Hmac* this_, ubyte* data, ssize_t length);
23240 Hmac* g_hmac_new(ChecksumType digest_type, ubyte* key, size_t key_len);
23241 int g_hook_compare_ids(Hook* this_, Hook* sibling);
23242 Hook* g_hook_alloc(HookList* hook_list);
23243 int g_hook_destroy(HookList* hook_list, c_ulong hook_id);
23244 void g_hook_destroy_link(HookList* hook_list, Hook* hook);
23245 Hook* g_hook_find(HookList* hook_list, int need_valids, HookFindFunc func, void* data);
23246 Hook* g_hook_find_data(HookList* hook_list, int need_valids, void* data);
23247 Hook* g_hook_find_func(HookList* hook_list, int need_valids, void* func);
23248 Hook* g_hook_find_func_data(HookList* hook_list, int need_valids, void* func, void* data);
23249 Hook* g_hook_first_valid(HookList* hook_list, int may_be_in_call);
23250 void g_hook_free(HookList* hook_list, Hook* hook);
23251 Hook* g_hook_get(HookList* hook_list, c_ulong hook_id);
23252 void g_hook_insert_before(HookList* hook_list, Hook* sibling, Hook* hook);
23253 void g_hook_insert_sorted(HookList* hook_list, Hook* hook, HookCompareFunc func);
23254 Hook* g_hook_next_valid(HookList* hook_list, Hook* hook, int may_be_in_call);
23255 void g_hook_prepend(HookList* hook_list, Hook* hook);
23256 Hook* g_hook_ref(HookList* hook_list, Hook* hook);
23257 void g_hook_unref(HookList* hook_list, Hook* hook);
23258 void g_hook_list_clear(HookList* this_);
23259 void g_hook_list_init(HookList* this_, uint hook_size);
23260 void g_hook_list_invoke(HookList* this_, int may_recurse);
23261 void g_hook_list_invoke_check(HookList* this_, int may_recurse);
23262 void g_hook_list_marshal(HookList* this_, int may_recurse, HookMarshaller marshaller, void* marshal_data);
23263 void g_hook_list_marshal_check(HookList* this_, int may_recurse, HookCheckMarshaller marshaller, void* marshal_data);
23264 size_t g_iconv(IConv* this_, char** inbuf, size_t* inbytes_left, char** outbuf, size_t* outbytes_left);
23265 int g_iconv_close(IConv* this_);
23266 IConv g_iconv_open(char* to_codeset, char* from_codeset);
23267 IOChannel* /*new*/ g_io_channel_new_file(char* filename, char* mode, GLib2.Error** error);
23268 IOChannel* /*new*/ g_io_channel_unix_new(int fd);
23269 void g_io_channel_close(IOChannel* this_);
23270 IOStatus g_io_channel_flush(IOChannel* this_, GLib2.Error** error);
23271 IOCondition g_io_channel_get_buffer_condition(IOChannel* this_);
23272 size_t g_io_channel_get_buffer_size(IOChannel* this_);
23273 int g_io_channel_get_buffered(IOChannel* this_);
23274 int g_io_channel_get_close_on_unref(IOChannel* this_);
23275 char* g_io_channel_get_encoding(IOChannel* this_);
23276 IOFlags g_io_channel_get_flags(IOChannel* this_);
23277 char* g_io_channel_get_line_term(IOChannel* this_, int* length);
23278 void g_io_channel_init(IOChannel* this_);
23279 IOError g_io_channel_read(IOChannel* this_, char* buf, size_t count, size_t* bytes_read);
23280 IOStatus g_io_channel_read_chars(IOChannel* this_, char* buf, size_t count, size_t* bytes_read, GLib2.Error** error);
23281 IOStatus g_io_channel_read_line(IOChannel* this_, char** str_return, size_t* length, size_t* terminator_pos, GLib2.Error** error);
23282 IOStatus g_io_channel_read_line_string(IOChannel* this_, String* buffer, size_t* terminator_pos, GLib2.Error** error);
23283 IOStatus g_io_channel_read_to_end(IOChannel* this_, char** str_return, size_t* length, GLib2.Error** error);
23284 IOStatus g_io_channel_read_unichar(IOChannel* this_, dchar* thechar, GLib2.Error** error);
23285 IOChannel* /*new*/ g_io_channel_ref(IOChannel* this_);
23286 IOError g_io_channel_seek(IOChannel* this_, long offset, SeekType type);
23287 IOStatus g_io_channel_seek_position(IOChannel* this_, long offset, SeekType type, GLib2.Error** error);
23288 void g_io_channel_set_buffer_size(IOChannel* this_, size_t size);
23289 void g_io_channel_set_buffered(IOChannel* this_, int buffered);
23290 void g_io_channel_set_close_on_unref(IOChannel* this_, int do_close);
23291 IOStatus g_io_channel_set_encoding(IOChannel* this_, char* encoding, GLib2.Error** error);
23292 IOStatus g_io_channel_set_flags(IOChannel* this_, IOFlags flags, GLib2.Error** error);
23293 void g_io_channel_set_line_term(IOChannel* this_, char* line_term, int length);
23294 IOStatus g_io_channel_shutdown(IOChannel* this_, int flush, GLib2.Error** error);
23295 int g_io_channel_unix_get_fd(IOChannel* this_);
23296 void g_io_channel_unref(IOChannel* this_);
23297 IOError g_io_channel_write(IOChannel* this_, char* buf, size_t count, size_t* bytes_written);
23298 IOStatus g_io_channel_write_chars(IOChannel* this_, char* buf, ssize_t count, size_t* bytes_written, GLib2.Error** error);
23299 IOStatus g_io_channel_write_unichar(IOChannel* this_, dchar thechar, GLib2.Error** error);
23300 IOChannelError g_io_channel_error_from_errno(int en);
23301 Quark g_io_channel_error_quark();
23302 void g_key_file_free(KeyFile* this_);
23303 int g_key_file_get_boolean(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
23304 int* /*new container*/ g_key_file_get_boolean_list(KeyFile* this_, char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error);
23305 char* /*new*/ g_key_file_get_comment(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
23306 double g_key_file_get_double(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
23307 double* /*new container*/ g_key_file_get_double_list(KeyFile* this_, char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error);
23308 char** g_key_file_get_groups(KeyFile* this_, size_t* length);
23309 long g_key_file_get_int64(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
23310 int g_key_file_get_integer(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
23311 int* /*new container*/ g_key_file_get_integer_list(KeyFile* this_, char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error);
23312 char** g_key_file_get_keys(KeyFile* this_, char* group_name, size_t* length, GLib2.Error** error);
23313 char* /*new*/ g_key_file_get_locale_string(KeyFile* this_, char* group_name, char* key, char* locale, GLib2.Error** error);
23314 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);
23315 char* /*new*/ g_key_file_get_start_group(KeyFile* this_);
23316 char* /*new*/ g_key_file_get_string(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
23317 char** /*new*/ g_key_file_get_string_list(KeyFile* this_, char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error);
23318 ulong g_key_file_get_uint64(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
23319 char* /*new*/ g_key_file_get_value(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
23320 int g_key_file_has_group(KeyFile* this_, char* group_name);
23321 int g_key_file_has_key(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
23322 int g_key_file_load_from_data(KeyFile* this_, char* data, size_t length, KeyFileFlags flags, GLib2.Error** error);
23323 int g_key_file_load_from_data_dirs(KeyFile* this_, char* file, char** full_path, KeyFileFlags flags, GLib2.Error** error);
23324 int g_key_file_load_from_dirs(KeyFile* this_, char* file, char** search_dirs, char** full_path, KeyFileFlags flags, GLib2.Error** error);
23325 int g_key_file_load_from_file(KeyFile* this_, char* file, KeyFileFlags flags, GLib2.Error** error);
23326 int g_key_file_remove_comment(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
23327 int g_key_file_remove_group(KeyFile* this_, char* group_name, GLib2.Error** error);
23328 int g_key_file_remove_key(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
23329 void g_key_file_set_boolean(KeyFile* this_, char* group_name, char* key, int value);
23330 void g_key_file_set_boolean_list(KeyFile* this_, char* group_name, char* key, int list, size_t length);
23331 int g_key_file_set_comment(KeyFile* this_, char* group_name, char* key, char* comment, GLib2.Error** error);
23332 void g_key_file_set_double(KeyFile* this_, char* group_name, char* key, double value);
23333 void g_key_file_set_double_list(KeyFile* this_, char* group_name, char* key, double list, size_t length);
23334 void g_key_file_set_int64(KeyFile* this_, char* group_name, char* key, long value);
23335 void g_key_file_set_integer(KeyFile* this_, char* group_name, char* key, int value);
23336 void g_key_file_set_integer_list(KeyFile* this_, char* group_name, char* key, int list, size_t length);
23337 void g_key_file_set_list_separator(KeyFile* this_, char separator);
23338 void g_key_file_set_locale_string(KeyFile* this_, char* group_name, char* key, char* locale, char* string_);
23339 void g_key_file_set_locale_string_list(KeyFile* this_, char* group_name, char* key, char* locale, char* list, size_t length);
23340 void g_key_file_set_string(KeyFile* this_, char* group_name, char* key, char* string_);
23341 void g_key_file_set_string_list(KeyFile* this_, char* group_name, char* key, char* list, size_t length);
23342 void g_key_file_set_uint64(KeyFile* this_, char* group_name, char* key, ulong value);
23343 void g_key_file_set_value(KeyFile* this_, char* group_name, char* key, char* value);
23344 char* /*new*/ g_key_file_to_data(KeyFile* this_, size_t* length, GLib2.Error** error);
23345 Quark g_key_file_error_quark();
23346 KeyFile* g_key_file_new();
23347 GLib2.List* g_list_alloc();
23348 GLib2.List* g_list_append(GLib2.List* list, void* data);
23349 GLib2.List* g_list_concat(GLib2.List* list1, GLib2.List* list2);
23350 GLib2.List* g_list_copy(GLib2.List* list);
23351 GLib2.List* g_list_delete_link(GLib2.List* list, GLib2.List* link_);
23352 GLib2.List* g_list_find(GLib2.List* list, const(void)* data);
23353 GLib2.List* g_list_find_custom(GLib2.List* list, const(void)* data, CompareFunc func);
23354 GLib2.List* g_list_first(GLib2.List* list);
23355 void g_list_foreach(GLib2.List* list, Func func, void* user_data);
23356 void g_list_free(GLib2.List* list);
23357 void g_list_free_1(GLib2.List* list);
23358 void g_list_free_full(GLib2.List* list, DestroyNotify free_func);
23359 int g_list_index(GLib2.List* list, const(void)* data);
23360 GLib2.List* g_list_insert(GLib2.List* list, void* data, int position);
23361 GLib2.List* g_list_insert_before(GLib2.List* list, GLib2.List* sibling, void* data);
23362 GLib2.List* g_list_insert_sorted(GLib2.List* list, void* data, CompareFunc func);
23363 GLib2.List* g_list_insert_sorted_with_data(GLib2.List* list, void* data, CompareDataFunc func, void* user_data);
23364 GLib2.List* g_list_last(GLib2.List* list);
23365 uint g_list_length(GLib2.List* list);
23366 GLib2.List* g_list_nth(GLib2.List* list, uint n);
23367 void* g_list_nth_data(GLib2.List* list, uint n);
23368 GLib2.List* g_list_nth_prev(GLib2.List* list, uint n);
23369 void g_list_pop_allocator();
23370 int g_list_position(GLib2.List* list, GLib2.List* llink);
23371 GLib2.List* g_list_prepend(GLib2.List* list, void* data);
23372 void g_list_push_allocator(void* allocator);
23373 GLib2.List* g_list_remove(GLib2.List* list, const(void)* data);
23374 GLib2.List* g_list_remove_all(GLib2.List* list, const(void)* data);
23375 GLib2.List* g_list_remove_link(GLib2.List* list, GLib2.List* llink);
23376 GLib2.List* g_list_reverse(GLib2.List* list);
23377 GLib2.List* g_list_sort(GLib2.List* list, CompareFunc compare_func);
23378 GLib2.List* g_list_sort_with_data(GLib2.List* list, CompareDataFunc compare_func, void* user_data);
23379 MainContext* /*new*/ g_main_context_new();
23380 int g_main_context_acquire(MainContext* this_);
23381 void g_main_context_add_poll(MainContext* this_, PollFD* fd, int priority);
23382 int g_main_context_check(MainContext* this_, int max_priority, PollFD* fds, int n_fds);
23383 void g_main_context_dispatch(MainContext* this_);
23384 Source* g_main_context_find_source_by_funcs_user_data(MainContext* this_, SourceFuncs* funcs, void* user_data);
23385 Source* g_main_context_find_source_by_id(MainContext* this_, uint source_id);
23386 Source* g_main_context_find_source_by_user_data(MainContext* this_, void* user_data);
23387 PollFunc g_main_context_get_poll_func(MainContext* this_);
23388 void g_main_context_invoke(MainContext* this_, SourceFunc function_, void* data);
23389 void g_main_context_invoke_full(MainContext* this_, int priority, SourceFunc function_, void* data, DestroyNotify notify);
23390 int g_main_context_is_owner(MainContext* this_);
23391 int g_main_context_iteration(MainContext* this_, int may_block);
23392 int g_main_context_pending(MainContext* this_);
23393 void g_main_context_pop_thread_default(MainContext* this_);
23394 int g_main_context_prepare(MainContext* this_, int* priority);
23395 void g_main_context_push_thread_default(MainContext* this_);
23396 int g_main_context_query(MainContext* this_, int max_priority, /*out*/ int* timeout_, /*out*/ PollFD* fds, /*out*/ int n_fds);
23397 MainContext* /*new*/ g_main_context_ref(MainContext* this_);
23398 void g_main_context_release(MainContext* this_);
23399 void g_main_context_remove_poll(MainContext* this_, PollFD* fd);
23400 void g_main_context_set_poll_func(MainContext* this_, PollFunc func);
23401 void g_main_context_unref(MainContext* this_);
23402 int g_main_context_wait(MainContext* this_, Cond* cond, Mutex* mutex);
23403 void g_main_context_wakeup(MainContext* this_);
23404 MainContext* g_main_context_default();
23405 MainContext* g_main_context_get_thread_default();
23406 MainLoop* /*new*/ g_main_loop_new(MainContext* context, int is_running);
23407 MainContext* g_main_loop_get_context(MainLoop* this_);
23408 int g_main_loop_is_running(MainLoop* this_);
23409 void g_main_loop_quit(MainLoop* this_);
23410 MainLoop* /*new*/ g_main_loop_ref(MainLoop* this_);
23411 void g_main_loop_run(MainLoop* this_);
23412 void g_main_loop_unref(MainLoop* this_);
23413 void g_mapped_file_free(MappedFile* this_);
23414 char* /*new*/ g_mapped_file_get_contents(MappedFile* this_);
23415 size_t g_mapped_file_get_length(MappedFile* this_);
23416 MappedFile* g_mapped_file_ref(MappedFile* this_);
23417 void g_mapped_file_unref(MappedFile* this_);
23418 MappedFile* g_mapped_file_new(char* filename, int writable, GLib2.Error** error);
23419 int g_markup_parse_context_end_parse(MarkupParseContext* this_, GLib2.Error** error);
23420 void g_markup_parse_context_free(MarkupParseContext* this_);
23421 char* g_markup_parse_context_get_element(MarkupParseContext* this_);
23422 GLib2.SList* g_markup_parse_context_get_element_stack(MarkupParseContext* this_);
23423 void g_markup_parse_context_get_position(MarkupParseContext* this_, int* line_number=null, int* char_number=null);
23424 void* g_markup_parse_context_get_user_data(MarkupParseContext* this_);
23425 int g_markup_parse_context_parse(MarkupParseContext* this_, char* text, ssize_t text_len, GLib2.Error** error);
23426 void* g_markup_parse_context_pop(MarkupParseContext* this_);
23427 void g_markup_parse_context_push(MarkupParseContext* this_, MarkupParser* parser, void* user_data);
23428 MarkupParseContext* g_markup_parse_context_new(MarkupParser* parser, MarkupParseFlags flags, void* user_data, DestroyNotify user_data_dnotify);
23429 char* /*new*/ g_match_info_expand_references(MatchInfo* this_, char* string_to_expand, GLib2.Error** error);
23430 char* /*new*/ g_match_info_fetch(MatchInfo* this_, int match_num);
23431 char** g_match_info_fetch_all(MatchInfo* this_);
23432 char* /*new*/ g_match_info_fetch_named(MatchInfo* this_, char* name);
23433 int g_match_info_fetch_named_pos(MatchInfo* this_, char* name, /*out*/ int* start_pos=null, /*out*/ int* end_pos=null);
23434 int g_match_info_fetch_pos(MatchInfo* this_, int match_num, /*out*/ int* start_pos=null, /*out*/ int* end_pos=null);
23435 void g_match_info_free(MatchInfo* this_);
23436 int g_match_info_get_match_count(MatchInfo* this_);
23437 Regex* /*new*/ g_match_info_get_regex(MatchInfo* this_);
23438 char* g_match_info_get_string(MatchInfo* this_);
23439 int g_match_info_is_partial_match(MatchInfo* this_);
23440 int g_match_info_matches(MatchInfo* this_);
23441 int g_match_info_next(MatchInfo* this_, GLib2.Error** error);
23442 MatchInfo* /*new*/ g_match_info_ref(MatchInfo* this_);
23443 void g_match_info_unref(MatchInfo* this_);
23444 void* g_mem_chunk_alloc(MemChunk* this_);
23445 void* g_mem_chunk_alloc0(MemChunk* this_);
23446 void g_mem_chunk_clean(MemChunk* this_);
23447 void g_mem_chunk_destroy(MemChunk* this_);
23448 void g_mem_chunk_free(MemChunk* this_, void* mem);
23449 void g_mem_chunk_print(MemChunk* this_);
23450 void g_mem_chunk_reset(MemChunk* this_);
23451 void g_mem_chunk_info();
23452 MemChunk* g_mem_chunk_new(char* name, int atom_size, size_t area_size, int type);
23453 int g_node_child_index(Node* this_, void* data);
23454 int g_node_child_position(Node* this_, Node* child);
23455 void g_node_children_foreach(Node* this_, TraverseFlags flags, NodeForeachFunc func, void* data);
23456 Node* g_node_copy(Node* this_);
23457 Node* g_node_copy_deep(Node* this_, CopyFunc copy_func, void* data);
23458 uint g_node_depth(Node* this_);
23459 void g_node_destroy(Node* this_);
23460 Node* g_node_find(Node* this_, TraverseType order, TraverseFlags flags, void* data);
23461 Node* g_node_find_child(Node* this_, TraverseFlags flags, void* data);
23462 Node* g_node_first_sibling(Node* this_);
23463 Node* g_node_get_root(Node* this_);
23464 Node* g_node_insert(Node* this_, int position, Node* node);
23465 Node* g_node_insert_after(Node* this_, Node* sibling, Node* node);
23466 Node* g_node_insert_before(Node* this_, Node* sibling, Node* node);
23467 int g_node_is_ancestor(Node* this_, Node* descendant);
23468 Node* g_node_last_child(Node* this_);
23469 Node* g_node_last_sibling(Node* this_);
23470 uint g_node_max_height(Node* this_);
23471 uint g_node_n_children(Node* this_);
23472 uint g_node_n_nodes(Node* this_, TraverseFlags flags);
23473 Node* g_node_nth_child(Node* this_, uint n);
23474 Node* g_node_prepend(Node* this_, Node* node);
23475 void g_node_reverse_children(Node* this_);
23476 void g_node_traverse(Node* this_, TraverseType order, TraverseFlags flags, int max_depth, NodeTraverseFunc func, void* data);
23477 void g_node_unlink(Node* this_);
23478 Node* g_node_new(void* data);
23479 void g_node_pop_allocator();
23480 void g_node_push_allocator(void* dummy);
23481 void* g_once_impl(Once* this_, ThreadFunc func, void* arg);
23482 int g_once_init_enter(size_t* value_location);
23483 int g_once_init_enter_impl(size_t* value_location);
23484 void g_once_init_leave(size_t* value_location, size_t initialization_value);
23485 void g_option_context_add_group(OptionContext* this_, OptionGroup* group);
23486 void g_option_context_add_main_entries(OptionContext* this_, OptionEntry* entries, char* translation_domain);
23487 void g_option_context_free(OptionContext* this_);
23488 char* g_option_context_get_description(OptionContext* this_);
23489 char* /*new*/ g_option_context_get_help(OptionContext* this_, int main_help, OptionGroup* group);
23490 int g_option_context_get_help_enabled(OptionContext* this_);
23491 int g_option_context_get_ignore_unknown_options(OptionContext* this_);
23492 OptionGroup* g_option_context_get_main_group(OptionContext* this_);
23493 char* g_option_context_get_summary(OptionContext* this_);
23494 int g_option_context_parse(OptionContext* this_, /*inout*/ int* argc, /*inout*/ char*** argv, GLib2.Error** error);
23495 void g_option_context_set_description(OptionContext* this_, char* description);
23496 void g_option_context_set_help_enabled(OptionContext* this_, int help_enabled);
23497 void g_option_context_set_ignore_unknown_options(OptionContext* this_, int ignore_unknown);
23498 void g_option_context_set_main_group(OptionContext* this_, OptionGroup* group);
23499 void g_option_context_set_summary(OptionContext* this_, char* summary);
23500 void g_option_context_set_translate_func(OptionContext* this_, TranslateFunc func, void* data, DestroyNotify destroy_notify);
23501 void g_option_context_set_translation_domain(OptionContext* this_, char* domain);
23502 OptionContext* g_option_context_new(char* parameter_string);
23503 void g_option_group_add_entries(OptionGroup* this_, OptionEntry* entries);
23504 void g_option_group_free(OptionGroup* this_);
23505 void g_option_group_set_error_hook(OptionGroup* this_, OptionErrorFunc error_func);
23506 void g_option_group_set_parse_hooks(OptionGroup* this_, OptionParseFunc pre_parse_func, OptionParseFunc post_parse_func);
23507 void g_option_group_set_translate_func(OptionGroup* this_, TranslateFunc func, void* data, DestroyNotify destroy_notify);
23508 void g_option_group_set_translation_domain(OptionGroup* this_, char* domain);
23509 OptionGroup* g_option_group_new(char* name, char* description, char* help_description, void* user_data, DestroyNotify destroy);
23510 int g_pattern_spec_equal(PatternSpec* this_, PatternSpec* pspec2);
23511 void g_pattern_spec_free(PatternSpec* this_);
23512 PatternSpec* g_pattern_spec_new(char* pattern);
23513 void g_ptr_array_add(PtrArray* array, void* data);
23514 void g_ptr_array_foreach(PtrArray* array, Func func, void* user_data);
23515 void** g_ptr_array_free(PtrArray* array, int free_seg);
23516 PtrArray* g_ptr_array_new();
23517 PtrArray* g_ptr_array_new_full(uint reserved_size, DestroyNotify element_free_func);
23518 PtrArray* g_ptr_array_new_with_free_func(DestroyNotify element_free_func);
23519 PtrArray* g_ptr_array_ref(PtrArray* array);
23520 int g_ptr_array_remove(PtrArray* array, void* data);
23521 int g_ptr_array_remove_fast(PtrArray* array, void* data);
23522 void* g_ptr_array_remove_index(PtrArray* array, uint index_);
23523 void* g_ptr_array_remove_index_fast(PtrArray* array, uint index_);
23524 void g_ptr_array_remove_range(PtrArray* array, uint index_, uint length);
23525 void g_ptr_array_set_free_func(PtrArray* array, DestroyNotify element_free_func);
23526 void g_ptr_array_set_size(PtrArray* array, int length);
23527 PtrArray* g_ptr_array_sized_new(uint reserved_size);
23528 void g_ptr_array_sort(PtrArray* array, CompareFunc compare_func);
23529 void g_ptr_array_sort_with_data(PtrArray* array, CompareDataFunc compare_func, void* user_data);
23530 void g_ptr_array_unref(PtrArray* array);
23531 void g_queue_clear(Queue* this_);
23532 Queue* g_queue_copy(Queue* this_);
23533 void g_queue_delete_link(Queue* this_, GLib2.List* link_);
23534 GLib2.List* g_queue_find(Queue* this_, const(void)* data);
23535 GLib2.List* g_queue_find_custom(Queue* this_, const(void)* data, CompareFunc func);
23536 void g_queue_foreach(Queue* this_, Func func, void* user_data);
23537 void g_queue_free(Queue* this_);
23538 uint g_queue_get_length(Queue* this_);
23539 int g_queue_index(Queue* this_, const(void)* data);
23540 void g_queue_init(Queue* this_);
23541 void g_queue_insert_after(Queue* this_, GLib2.List* sibling, void* data);
23542 void g_queue_insert_before(Queue* this_, GLib2.List* sibling, void* data);
23543 void g_queue_insert_sorted(Queue* this_, void* data, CompareDataFunc func, void* user_data);
23544 int g_queue_is_empty(Queue* this_);
23545 int g_queue_link_index(Queue* this_, GLib2.List* link_);
23546 void* g_queue_peek_head(Queue* this_);
23547 GLib2.List* g_queue_peek_head_link(Queue* this_);
23548 void* g_queue_peek_nth(Queue* this_, uint n);
23549 GLib2.List* g_queue_peek_nth_link(Queue* this_, uint n);
23550 void* g_queue_peek_tail(Queue* this_);
23551 GLib2.List* g_queue_peek_tail_link(Queue* this_);
23552 void* g_queue_pop_head(Queue* this_);
23553 GLib2.List* g_queue_pop_head_link(Queue* this_);
23554 void* g_queue_pop_nth(Queue* this_, uint n);
23555 GLib2.List* g_queue_pop_nth_link(Queue* this_, uint n);
23556 void* g_queue_pop_tail(Queue* this_);
23557 GLib2.List* g_queue_pop_tail_link(Queue* this_);
23558 void g_queue_push_head(Queue* this_, void* data);
23559 void g_queue_push_head_link(Queue* this_, GLib2.List* link_);
23560 void g_queue_push_nth(Queue* this_, void* data, int n);
23561 void g_queue_push_nth_link(Queue* this_, int n, GLib2.List* link_);
23562 void g_queue_push_tail(Queue* this_, void* data);
23563 void g_queue_push_tail_link(Queue* this_, GLib2.List* link_);
23564 int g_queue_remove(Queue* this_, const(void)* data);
23565 uint g_queue_remove_all(Queue* this_, const(void)* data);
23566 void g_queue_reverse(Queue* this_);
23567 void g_queue_sort(Queue* this_, CompareDataFunc compare_func, void* user_data);
23568 void g_queue_unlink(Queue* this_, GLib2.List* link_);
23569 Queue* g_queue_new();
23570 Rand* g_rand_copy(Rand* this_);
23571 double g_rand_double(Rand* this_);
23572 double g_rand_double_range(Rand* this_, double begin, double end);
23573 void g_rand_free(Rand* this_);
23574 uint g_rand_int(Rand* this_);
23575 int g_rand_int_range(Rand* this_, int begin, int end);
23576 void g_rand_set_seed(Rand* this_, uint seed);
23577 void g_rand_set_seed_array(Rand* this_, uint* seed, uint seed_length);
23578 Rand* g_rand_new();
23579 Rand* g_rand_new_with_seed(uint seed);
23580 Rand* g_rand_new_with_seed_array(uint* seed, uint seed_length);
23581 Regex* /*new*/ g_regex_new(char* pattern, RegexCompileFlags compile_options, RegexMatchFlags match_options, GLib2.Error** error);
23582 int g_regex_get_capture_count(Regex* this_);
23583 RegexCompileFlags g_regex_get_compile_flags(Regex* this_);
23584 RegexMatchFlags g_regex_get_match_flags(Regex* this_);
23585 int g_regex_get_max_backref(Regex* this_);
23586 char* g_regex_get_pattern(Regex* this_);
23587 int g_regex_get_string_number(Regex* this_, char* name);
23588 int g_regex_match(Regex* this_, char* string_, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info=null);
23589 int g_regex_match_all(Regex* this_, char* string_, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info=null);
23590 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);
23591 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);
23592 Regex* /*new*/ g_regex_ref(Regex* this_);
23593 char* /*new*/ g_regex_replace(Regex* this_, char* string_, ssize_t string_len, int start_position, char* replacement, RegexMatchFlags match_options, GLib2.Error** error);
23594 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);
23595 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);
23596 char** g_regex_split(Regex* this_, char* string_, RegexMatchFlags match_options);
23597 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);
23598 void g_regex_unref(Regex* this_);
23599 int g_regex_check_replacement(char* replacement, /*out*/ int* has_references, GLib2.Error** error);
23600 Quark g_regex_error_quark();
23601 char* /*new*/ g_regex_escape_nul(char* string_, int length);
23602 char* /*new*/ g_regex_escape_string(char* string_, int length);
23603 int g_regex_match_simple(char* pattern, char* string_, RegexCompileFlags compile_options, RegexMatchFlags match_options);
23604 char** g_regex_split_simple(char* pattern, char* string_, RegexCompileFlags compile_options, RegexMatchFlags match_options);
23605 int g_relation_count(Relation* this_, const(void)* key, int field);
23606 int g_relation_delete(Relation* this_, const(void)* key, int field);
23607 void g_relation_destroy(Relation* this_);
23608 int g_relation_exists(Relation* this_, ...);
23609 void g_relation_index(Relation* this_, int field, HashFunc hash_func, EqualFunc key_equal_func);
23610 void g_relation_insert(Relation* this_, ...);
23611 void g_relation_print(Relation* this_);
23612 Tuples* g_relation_select(Relation* this_, const(void)* key, int field);
23613 Relation* g_relation_new(int fields);
23614 GLib2.SList* g_slist_alloc();
23615 GLib2.SList* g_slist_append(GLib2.SList* list, void* data);
23616 GLib2.SList* g_slist_concat(GLib2.SList* list1, GLib2.SList* list2);
23617 GLib2.SList* g_slist_copy(GLib2.SList* list);
23618 GLib2.SList* g_slist_delete_link(GLib2.SList* list, GLib2.SList* link_);
23619 GLib2.SList* g_slist_find(GLib2.SList* list, const(void)* data);
23620 GLib2.SList* g_slist_find_custom(GLib2.SList* list, const(void)* data, CompareFunc func);
23621 void g_slist_foreach(GLib2.SList* list, Func func, void* user_data);
23622 void g_slist_free(GLib2.SList* list);
23623 void g_slist_free_1(GLib2.SList* list);
23624 void g_slist_free_full(GLib2.SList* list, DestroyNotify free_func);
23625 int g_slist_index(GLib2.SList* list, const(void)* data);
23626 GLib2.SList* g_slist_insert(GLib2.SList* list, void* data, int position);
23627 GLib2.SList* g_slist_insert_before(GLib2.SList* slist, GLib2.SList* sibling, void* data);
23628 GLib2.SList* g_slist_insert_sorted(GLib2.SList* list, void* data, CompareFunc func);
23629 GLib2.SList* g_slist_insert_sorted_with_data(GLib2.SList* list, void* data, CompareDataFunc func, void* user_data);
23630 GLib2.SList* g_slist_last(GLib2.SList* list);
23631 uint g_slist_length(GLib2.SList* list);
23632 GLib2.SList* g_slist_nth(GLib2.SList* list, uint n);
23633 void* g_slist_nth_data(GLib2.SList* list, uint n);
23634 void g_slist_pop_allocator();
23635 int g_slist_position(GLib2.SList* list, GLib2.SList* llink);
23636 GLib2.SList* g_slist_prepend(GLib2.SList* list, void* data);
23637 void g_slist_push_allocator(void* dummy);
23638 GLib2.SList* g_slist_remove(GLib2.SList* list, const(void)* data);
23639 GLib2.SList* g_slist_remove_all(GLib2.SList* list, const(void)* data);
23640 GLib2.SList* g_slist_remove_link(GLib2.SList* list, GLib2.SList* link_);
23641 GLib2.SList* g_slist_reverse(GLib2.SList* list);
23642 GLib2.SList* g_slist_sort(GLib2.SList* list, CompareFunc compare_func);
23643 GLib2.SList* g_slist_sort_with_data(GLib2.SList* list, CompareDataFunc compare_func, void* user_data);
23644 uint g_scanner_cur_line(Scanner* this_);
23645 uint g_scanner_cur_position(Scanner* this_);
23646 TokenType g_scanner_cur_token(Scanner* this_);
23647 TokenValue g_scanner_cur_value(Scanner* this_);
23648 void g_scanner_destroy(Scanner* this_);
23649 int g_scanner_eof(Scanner* this_);
23650 void g_scanner_error(Scanner* this_, char* format, ...);
23651 TokenType g_scanner_get_next_token(Scanner* this_);
23652 void g_scanner_input_file(Scanner* this_, int input_fd);
23653 void g_scanner_input_text(Scanner* this_, char* text, uint text_len);
23654 void* g_scanner_lookup_symbol(Scanner* this_, char* symbol);
23655 TokenType g_scanner_peek_next_token(Scanner* this_);
23656 void g_scanner_scope_add_symbol(Scanner* this_, uint scope_id, char* symbol, void* value);
23657 void g_scanner_scope_foreach_symbol(Scanner* this_, uint scope_id, HFunc func, void* user_data);
23658 void* g_scanner_scope_lookup_symbol(Scanner* this_, uint scope_id, char* symbol);
23659 void g_scanner_scope_remove_symbol(Scanner* this_, uint scope_id, char* symbol);
23660 uint g_scanner_set_scope(Scanner* this_, uint scope_id);
23661 void g_scanner_sync_file_offset(Scanner* this_);
23662 void g_scanner_unexp_token(Scanner* this_, TokenType expected_token, char* identifier_spec, char* symbol_spec, char* symbol_name, char* message, int is_error);
23663 void g_scanner_warn(Scanner* this_, char* format, ...);
23664 Scanner* g_scanner_new(ScannerConfig* config_templ);
23665 SequenceIter* g_sequence_append(Sequence* this_, void* data);
23666 void g_sequence_foreach(Sequence* this_, Func func, void* user_data);
23667 void g_sequence_free(Sequence* this_);
23668 SequenceIter* g_sequence_get_begin_iter(Sequence* this_);
23669 SequenceIter* g_sequence_get_end_iter(Sequence* this_);
23670 SequenceIter* g_sequence_get_iter_at_pos(Sequence* this_, int pos);
23671 int g_sequence_get_length(Sequence* this_);
23672 SequenceIter* g_sequence_insert_sorted(Sequence* this_, void* data, CompareDataFunc cmp_func, void* cmp_data);
23673 SequenceIter* g_sequence_insert_sorted_iter(Sequence* this_, void* data, SequenceIterCompareFunc iter_cmp, void* cmp_data);
23674 SequenceIter* g_sequence_lookup(Sequence* this_, void* data, CompareDataFunc cmp_func, void* cmp_data);
23675 SequenceIter* g_sequence_lookup_iter(Sequence* this_, void* data, SequenceIterCompareFunc iter_cmp, void* cmp_data);
23676 SequenceIter* g_sequence_prepend(Sequence* this_, void* data);
23677 SequenceIter* g_sequence_search(Sequence* this_, void* data, CompareDataFunc cmp_func, void* cmp_data);
23678 SequenceIter* g_sequence_search_iter(Sequence* this_, void* data, SequenceIterCompareFunc iter_cmp, void* cmp_data);
23679 void g_sequence_sort(Sequence* this_, CompareDataFunc cmp_func, void* cmp_data);
23680 void g_sequence_sort_iter(Sequence* this_, SequenceIterCompareFunc cmp_func, void* cmp_data);
23681 void g_sequence_foreach_range(SequenceIter* begin, SequenceIter* end, Func func, void* user_data);
23682 void* g_sequence_get(SequenceIter* iter);
23683 SequenceIter* g_sequence_insert_before(SequenceIter* iter, void* data);
23684 void g_sequence_move(SequenceIter* src, SequenceIter* dest);
23685 void g_sequence_move_range(SequenceIter* dest, SequenceIter* begin, SequenceIter* end);
23686 Sequence* g_sequence_new(DestroyNotify data_destroy);
23687 SequenceIter* g_sequence_range_get_midpoint(SequenceIter* begin, SequenceIter* end);
23688 void g_sequence_remove(SequenceIter* iter);
23689 void g_sequence_remove_range(SequenceIter* begin, SequenceIter* end);
23690 void g_sequence_set(SequenceIter* iter, void* data);
23691 void g_sequence_sort_changed(SequenceIter* iter, CompareDataFunc cmp_func, void* cmp_data);
23692 void g_sequence_sort_changed_iter(SequenceIter* iter, SequenceIterCompareFunc iter_cmp, void* cmp_data);
23693 void g_sequence_swap(SequenceIter* a, SequenceIter* b);
23694 int g_sequence_iter_compare(SequenceIter* this_, SequenceIter* b);
23695 int g_sequence_iter_get_position(SequenceIter* this_);
23696 Sequence* g_sequence_iter_get_sequence(SequenceIter* this_);
23697 int g_sequence_iter_is_begin(SequenceIter* this_);
23698 int g_sequence_iter_is_end(SequenceIter* this_);
23699 SequenceIter* g_sequence_iter_move(SequenceIter* this_, int delta);
23700 SequenceIter* g_sequence_iter_next(SequenceIter* this_);
23701 SequenceIter* g_sequence_iter_prev(SequenceIter* this_);
23702 Source* /*new*/ g_source_new(SourceFuncs* source_funcs, uint struct_size);
23703 void g_source_add_child_source(Source* this_, Source* child_source);
23704 void g_source_add_poll(Source* this_, PollFD* fd);
23705 uint g_source_attach(Source* this_, MainContext* context);
23706 void g_source_destroy(Source* this_);
23707 int g_source_get_can_recurse(Source* this_);
23708 MainContext* g_source_get_context(Source* this_);
23709 void g_source_get_current_time(Source* this_, TimeVal* timeval);
23710 uint g_source_get_id(Source* this_);
23711 char* g_source_get_name(Source* this_);
23712 int g_source_get_priority(Source* this_);
23713 long g_source_get_time(Source* this_);
23714 int g_source_is_destroyed(Source* this_);
23715 Source* /*new*/ g_source_ref(Source* this_);
23716 void g_source_remove_child_source(Source* this_, Source* child_source);
23717 void g_source_remove_poll(Source* this_, PollFD* fd);
23718 void g_source_set_callback(Source* this_, SourceFunc func, void* data, DestroyNotify notify);
23719 void g_source_set_callback_indirect(Source* this_, void* callback_data, SourceCallbackFuncs* callback_funcs);
23720 void g_source_set_can_recurse(Source* this_, int can_recurse);
23721 void g_source_set_funcs(Source* this_, SourceFuncs* funcs);
23722 void g_source_set_name(Source* this_, char* name);
23723 void g_source_set_priority(Source* this_, int priority);
23724 void g_source_unref(Source* this_);
23725 int g_source_remove(uint tag);
23726 int g_source_remove_by_funcs_user_data(SourceFuncs* funcs, void* user_data);
23727 int g_source_remove_by_user_data(void* user_data);
23728 void g_source_set_name_by_id(uint tag, char* name);
23729 void g_static_mutex_free(StaticMutex* this_);
23730 void g_static_mutex_init(StaticMutex* this_);
23731 Mutex* g_static_mutex_get_mutex_impl(Mutex** mutex);
23732 void g_static_private_free(StaticPrivate* this_);
23733 void* g_static_private_get(StaticPrivate* this_);
23734 void g_static_private_init(StaticPrivate* this_);
23735 void g_static_private_set(StaticPrivate* this_, void* data, DestroyNotify notify);
23736 void g_static_rw_lock_free(StaticRWLock* this_);
23737 void g_static_rw_lock_init(StaticRWLock* this_);
23738 void g_static_rw_lock_reader_lock(StaticRWLock* this_);
23739 int g_static_rw_lock_reader_trylock(StaticRWLock* this_);
23740 void g_static_rw_lock_reader_unlock(StaticRWLock* this_);
23741 void g_static_rw_lock_writer_lock(StaticRWLock* this_);
23742 int g_static_rw_lock_writer_trylock(StaticRWLock* this_);
23743 void g_static_rw_lock_writer_unlock(StaticRWLock* this_);
23744 void g_static_rec_mutex_free(StaticRecMutex* this_);
23745 void g_static_rec_mutex_init(StaticRecMutex* this_);
23746 void g_static_rec_mutex_lock(StaticRecMutex* this_);
23747 void g_static_rec_mutex_lock_full(StaticRecMutex* this_, uint depth);
23748 int g_static_rec_mutex_trylock(StaticRecMutex* this_);
23749 void g_static_rec_mutex_unlock(StaticRecMutex* this_);
23750 uint g_static_rec_mutex_unlock_full(StaticRecMutex* this_);
23751 String* /*new*/ g_string_append(String* this_, char* val);
23752 String* /*new*/ g_string_append_c(String* this_, char c);
23753 String* /*new*/ g_string_append_len(String* this_, char* val, ssize_t len);
23754 void g_string_append_printf(String* this_, char* format, ...);
23755 String* /*new*/ g_string_append_unichar(String* this_, dchar wc);
23756 String* /*new*/ g_string_append_uri_escaped(String* this_, char* unescaped, char* reserved_chars_allowed, int allow_utf8);
23757 void g_string_append_vprintf(String* this_, char* format, va_list args);
23758 String* /*new*/ g_string_ascii_down(String* this_);
23759 String* /*new*/ g_string_ascii_up(String* this_);
23760 String* /*new*/ g_string_assign(String* this_, char* rval);
23761 String* /*new*/ g_string_down(String* this_);
23762 int g_string_equal(String* this_, String* v2);
23763 String* /*new*/ g_string_erase(String* this_, ssize_t pos, ssize_t len);
23764 char* /*new*/ g_string_free(String* this_, int free_segment);
23765 uint g_string_hash(String* this_);
23766 String* /*new*/ g_string_insert(String* this_, ssize_t pos, char* val);
23767 String* /*new*/ g_string_insert_c(String* this_, ssize_t pos, char c);
23768 String* /*new*/ g_string_insert_len(String* this_, ssize_t pos, char* val, ssize_t len);
23769 String* /*new*/ g_string_insert_unichar(String* this_, ssize_t pos, dchar wc);
23770 String* /*new*/ g_string_overwrite(String* this_, size_t pos, char* val);
23771 String* /*new*/ g_string_overwrite_len(String* this_, size_t pos, char* val, ssize_t len);
23772 String* /*new*/ g_string_prepend(String* this_, char* val);
23773 String* /*new*/ g_string_prepend_c(String* this_, char c);
23774 String* /*new*/ g_string_prepend_len(String* this_, char* val, ssize_t len);
23775 String* /*new*/ g_string_prepend_unichar(String* this_, dchar wc);
23776 void g_string_printf(String* this_, char* format, ...);
23777 String* /*new*/ g_string_set_size(String* this_, size_t len);
23778 String* /*new*/ g_string_truncate(String* this_, size_t len);
23779 String* /*new*/ g_string_up(String* this_);
23780 void g_string_vprintf(String* this_, char* format, va_list args);
23781 void g_string_chunk_clear(StringChunk* this_);
23782 void g_string_chunk_free(StringChunk* this_);
23783 char* /*new*/ g_string_chunk_insert(StringChunk* this_, char* string_);
23784 char* /*new*/ g_string_chunk_insert_const(StringChunk* this_, char* string_);
23785 char* /*new*/ g_string_chunk_insert_len(StringChunk* this_, char* string_, ssize_t len);
23786 StringChunk* g_string_chunk_new(size_t size);
23787 void g_test_log_buffer_free(TestLogBuffer* this_);
23788 TestLogMsg* g_test_log_buffer_pop(TestLogBuffer* this_);
23789 void g_test_log_buffer_push(TestLogBuffer* this_, uint n_bytes, ubyte* bytes);
23790 TestLogBuffer* g_test_log_buffer_new();
23791 void g_test_log_msg_free(TestLogMsg* this_);
23792 void g_test_suite_add(TestSuite* this_, TestCase* test_case);
23793 void g_test_suite_add_suite(TestSuite* this_, TestSuite* nestedsuite);
23794 void* g_thread_join(Thread* this_);
23795 void g_thread_set_priority(Thread* this_, ThreadPriority priority);
23796 Thread* g_thread_create_full(ThreadFunc func, void* data, c_ulong stack_size, int joinable, int bound, ThreadPriority priority, GLib2.Error** error);
23797 Quark g_thread_error_quark();
23798 void g_thread_exit(void* retval);
23799 void g_thread_foreach(Func thread_func, void* user_data);
23800 int g_thread_get_initialized();
23801 void g_thread_init(ThreadFunctions* vtable);
23802 void g_thread_init_with_errorcheck_mutexes(ThreadFunctions* vtable);
23803 Thread* g_thread_self();
23804 void g_thread_pool_free(ThreadPool* this_, int immediate, int wait_);
23805 int g_thread_pool_get_max_threads(ThreadPool* this_);
23806 uint g_thread_pool_get_num_threads(ThreadPool* this_);
23807 void g_thread_pool_push(ThreadPool* this_, void* data, GLib2.Error** error);
23808 void g_thread_pool_set_max_threads(ThreadPool* this_, int max_threads, GLib2.Error** error);
23809 void g_thread_pool_set_sort_function(ThreadPool* this_, CompareDataFunc func, void* user_data);
23810 uint g_thread_pool_unprocessed(ThreadPool* this_);
23811 uint g_thread_pool_get_max_idle_time();
23812 int g_thread_pool_get_max_unused_threads();
23813 uint g_thread_pool_get_num_unused_threads();
23814 ThreadPool* g_thread_pool_new(Func func, void* user_data, int max_threads, int exclusive, GLib2.Error** error);
23815 void g_thread_pool_set_max_idle_time(uint interval);
23816 void g_thread_pool_set_max_unused_threads(int max_threads);
23817 void g_thread_pool_stop_unused_threads();
23818 void g_time_val_add(TimeVal* this_, c_long microseconds);
23819 char* /*new*/ g_time_val_to_iso8601(TimeVal* this_);
23820 int g_time_val_from_iso8601(char* iso_date, TimeVal* time_);
23821 int g_time_zone_adjust_time(TimeZone* this_, TimeType type, long* time_);
23822 int g_time_zone_find_interval(TimeZone* this_, TimeType type, long time_);
23823 char* g_time_zone_get_abbreviation(TimeZone* this_, int interval);
23824 int g_time_zone_get_offset(TimeZone* this_, int interval);
23825 int g_time_zone_is_dst(TimeZone* this_, int interval);
23826 TimeZone* g_time_zone_ref(TimeZone* this_);
23827 void g_time_zone_unref(TimeZone* this_);
23828 TimeZone* g_time_zone_new(char* identifier=null);
23829 TimeZone* g_time_zone_new_local();
23830 TimeZone* g_time_zone_new_utc();
23831 void g_timer_continue(Timer* this_);
23832 void g_timer_destroy(Timer* this_);
23833 double g_timer_elapsed(Timer* this_, c_ulong* microseconds);
23834 void g_timer_reset(Timer* this_);
23835 void g_timer_start(Timer* this_);
23836 void g_timer_stop(Timer* this_);
23837 Timer* g_timer_new();
23838 uint g_trash_stack_height(TrashStack** stack_p);
23839 void* g_trash_stack_peek(TrashStack** stack_p);
23840 void* g_trash_stack_pop(TrashStack** stack_p);
23841 void g_trash_stack_push(TrashStack** stack_p, void* data_p);
23842 void g_tree_destroy(Tree* this_);
23843 void g_tree_foreach(Tree* this_, TraverseFunc func, void* user_data);
23844 int g_tree_height(Tree* this_);
23845 void g_tree_insert(Tree* this_, void* key, void* value);
23846 void* g_tree_lookup(Tree* this_, const(void)* key);
23847 int g_tree_lookup_extended(Tree* this_, const(void)* lookup_key, void** orig_key, void** value);
23848 int g_tree_nnodes(Tree* this_);
23849 Tree* g_tree_ref(Tree* this_);
23850 int g_tree_remove(Tree* this_, const(void)* key);
23851 void g_tree_replace(Tree* this_, void* key, void* value);
23852 void* g_tree_search(Tree* this_, CompareFunc search_func, const(void)* user_data);
23853 int g_tree_steal(Tree* this_, const(void)* key);
23854 void g_tree_traverse(Tree* this_, TraverseFunc traverse_func, TraverseType traverse_type, void* user_data);
23855 void g_tree_unref(Tree* this_);
23856 Tree* g_tree_new(CompareFunc key_compare_func);
23857 Tree* g_tree_new_full(CompareDataFunc key_compare_func, void* key_compare_data, DestroyNotify key_destroy_func, DestroyNotify value_destroy_func);
23858 Tree* g_tree_new_with_data(CompareDataFunc key_compare_func, void* key_compare_data);
23859 void g_tuples_destroy(Tuples* this_);
23860 void* g_tuples_index(Tuples* this_, int index_, int field);
23861 Variant* /*new*/ g_variant_new(char* format_string, ...);
23862 Variant* g_variant_new_array(VariantType* child_type, Variant** children, size_t n_children);
23863 Variant* g_variant_new_boolean(int value);
23864 Variant* g_variant_new_byte(ubyte value);
23865 Variant* g_variant_new_bytestring(ubyte* string_);
23866 Variant* g_variant_new_bytestring_array(char** strv, ssize_t length);
23867 Variant* g_variant_new_dict_entry(Variant* key, Variant* value);
23868 Variant* g_variant_new_double(double value);
23869 Variant* g_variant_new_from_data(VariantType* type, const(ubyte)* data, size_t size, int trusted, DestroyNotify notify, void* user_data);
23870 Variant* g_variant_new_handle(int value);
23871 Variant* g_variant_new_int16(short value);
23872 Variant* g_variant_new_int32(int value);
23873 Variant* g_variant_new_int64(long value);
23874 Variant* g_variant_new_maybe(VariantType* child_type=null, Variant* child=null);
23875 Variant* g_variant_new_object_path(char* object_path);
23876 Variant* g_variant_new_objv(char** strv, ssize_t length);
23877 Variant* /*new*/ g_variant_new_parsed(char* format, ...);
23878 Variant* /*new*/ g_variant_new_parsed_va(char* format, va_list* app);
23879 Variant* g_variant_new_signature(char* signature);
23880 Variant* g_variant_new_string(char* string_);
23881 Variant* g_variant_new_strv(char** strv, ssize_t length);
23882 Variant* g_variant_new_tuple(Variant** children, size_t n_children);
23883 Variant* g_variant_new_uint16(ushort value);
23884 Variant* g_variant_new_uint32(uint value);
23885 Variant* g_variant_new_uint64(ulong value);
23886 Variant* /*new*/ g_variant_new_va(char* format_string, char** endptr, va_list* app);
23887 Variant* g_variant_new_variant(Variant* value);
23888 Variant* /*new*/ g_variant_byteswap(Variant* this_);
23889 VariantClass g_variant_classify(Variant* this_);
23890 int g_variant_compare(Variant* this_, const(Variant)* two);
23891 ubyte* /*new*/ g_variant_dup_bytestring(Variant* this_, /*out*/ size_t* length=null);
23892 char** /*new*/ g_variant_dup_bytestring_array(Variant* this_, /*out*/ size_t* length=null);
23893 char** /*new*/ g_variant_dup_objv(Variant* this_, /*out*/ size_t* length=null);
23894 char* /*new*/ g_variant_dup_string(Variant* this_, /*out*/ size_t* length);
23895 char** /*new*/ g_variant_dup_strv(Variant* this_, /*out*/ size_t* length=null);
23896 int g_variant_equal(Variant* this_, const(Variant)* two);
23897 void g_variant_get(Variant* this_, char* format_string, ...);
23898 int g_variant_get_boolean(Variant* this_);
23899 ubyte g_variant_get_byte(Variant* this_);
23900 ubyte* g_variant_get_bytestring(Variant* this_);
23901 char** /*new container*/ g_variant_get_bytestring_array(Variant* this_, /*out*/ size_t* length=null);
23902 void g_variant_get_child(Variant* this_, size_t index_, char* format_string, ...);
23903 Variant* /*new*/ g_variant_get_child_value(Variant* this_, size_t index_);
23904 const(void)* g_variant_get_data(Variant* this_);
23905 double g_variant_get_double(Variant* this_);
23906 const(void)* g_variant_get_fixed_array(Variant* this_, /*out*/ size_t* n_elements, size_t element_size);
23907 int g_variant_get_handle(Variant* this_);
23908 short g_variant_get_int16(Variant* this_);
23909 int g_variant_get_int32(Variant* this_);
23910 long g_variant_get_int64(Variant* this_);
23911 Variant* /*new*/ g_variant_get_maybe(Variant* this_);
23912 Variant* /*new*/ g_variant_get_normal_form(Variant* this_);
23913 char** /*new container*/ g_variant_get_objv(Variant* this_, /*out*/ size_t* length=null);
23914 size_t g_variant_get_size(Variant* this_);
23915 char* g_variant_get_string(Variant* this_, /*out*/ size_t* length=null);
23916 char** /*new container*/ g_variant_get_strv(Variant* this_, /*out*/ size_t* length=null);
23917 char* g_variant_get_type_string(Variant* this_);
23918 ushort g_variant_get_uint16(Variant* this_);
23919 uint g_variant_get_uint32(Variant* this_);
23920 ulong g_variant_get_uint64(Variant* this_);
23921 void g_variant_get_va(Variant* this_, char* format_string, char** endptr, va_list* app);
23922 Variant* /*new*/ g_variant_get_variant(Variant* this_);
23923 uint g_variant_hash(Variant* this_);
23924 int g_variant_is_container(Variant* this_);
23925 int g_variant_is_floating(Variant* this_);
23926 int g_variant_is_normal_form(Variant* this_);
23927 int g_variant_is_of_type(Variant* this_, VariantType* type);
23928 VariantIter* /*new*/ g_variant_iter_new(Variant* this_);
23929 int g_variant_lookup(Variant* this_, char* key, char* format_string, ...);
23930 Variant* /*new*/ g_variant_lookup_value(Variant* this_, char* key, VariantType* expected_type=null);
23931 size_t g_variant_n_children(Variant* this_);
23932 char* /*new*/ g_variant_print(Variant* this_, int type_annotate);
23933 String* /*new*/ g_variant_print_string(Variant* this_, String* string_, int type_annotate);
23934 Variant* /*new*/ g_variant_ref(Variant* this_);
23935 Variant* /*new*/ g_variant_ref_sink(Variant* this_);
23936 void g_variant_store(Variant* this_, void* data);
23937 Variant* /*new*/ g_variant_take_ref(Variant* this_);
23938 void g_variant_unref(Variant* this_);
23939 int g_variant_is_object_path(char* string_);
23940 int g_variant_is_signature(char* string_);
23941 Variant* /*new*/ g_variant_parse(VariantType* type, char* text, char* limit, char** endptr, GLib2.Error** error);
23942 Quark g_variant_parser_get_error_quark();
23943 VariantBuilder* /*new*/ g_variant_builder_new(VariantType* type);
23944 void g_variant_builder_add(VariantBuilder* this_, char* format_string, ...);
23945 void g_variant_builder_add_parsed(VariantBuilder* this_, char* format, ...);
23946 void g_variant_builder_add_value(VariantBuilder* this_, Variant* value);
23947 void g_variant_builder_clear(VariantBuilder* this_);
23948 void g_variant_builder_close(VariantBuilder* this_);
23949 Variant* g_variant_builder_end(VariantBuilder* this_);
23950 void g_variant_builder_init(VariantBuilder* this_, VariantType* type);
23951 void g_variant_builder_open(VariantBuilder* this_, VariantType* type);
23952 VariantBuilder* /*new*/ g_variant_builder_ref(VariantBuilder* this_);
23953 void g_variant_builder_unref(VariantBuilder* this_);
23954 VariantIter* /*new*/ g_variant_iter_copy(VariantIter* this_);
23955 void g_variant_iter_free(VariantIter* this_);
23956 size_t g_variant_iter_init(VariantIter* this_, Variant* value);
23957 int g_variant_iter_loop(VariantIter* this_, char* format_string, ...);
23958 size_t g_variant_iter_n_children(VariantIter* this_);
23959 int g_variant_iter_next(VariantIter* this_, char* format_string, ...);
23960 Variant* /*new*/ g_variant_iter_next_value(VariantIter* this_);
23961 VariantType* /*new*/ g_variant_type_new(char* type_string);
23962 VariantType* /*new*/ g_variant_type_new_tuple(VariantType** items, int length);
23963 VariantType* /*new*/ g_variant_type_copy(VariantType* this_);
23964 char* /*new*/ g_variant_type_dup_string(VariantType* this_);
23965 VariantType* g_variant_type_element(VariantType* this_);
23966 int g_variant_type_equal(VariantType* this_, const(VariantType)* type2);
23967 VariantType* g_variant_type_first(VariantType* this_);
23968 void g_variant_type_free(VariantType* this_);
23969 size_t g_variant_type_get_string_length(VariantType* this_);
23970 uint g_variant_type_hash(VariantType* this_);
23971 int g_variant_type_is_array(VariantType* this_);
23972 int g_variant_type_is_basic(VariantType* this_);
23973 int g_variant_type_is_container(VariantType* this_);
23974 int g_variant_type_is_definite(VariantType* this_);
23975 int g_variant_type_is_dict_entry(VariantType* this_);
23976 int g_variant_type_is_maybe(VariantType* this_);
23977 int g_variant_type_is_subtype_of(VariantType* this_, VariantType* supertype);
23978 int g_variant_type_is_tuple(VariantType* this_);
23979 int g_variant_type_is_variant(VariantType* this_);
23980 VariantType* g_variant_type_key(VariantType* this_);
23981 size_t g_variant_type_n_items(VariantType* this_);
23982 VariantType* /*new*/ g_variant_type_new_array(VariantType* this_);
23983 VariantType* /*new*/ g_variant_type_new_dict_entry(VariantType* this_, VariantType* value);
23984 VariantType* /*new*/ g_variant_type_new_maybe(VariantType* this_);
23985 VariantType* g_variant_type_next(VariantType* this_);
23986 char* g_variant_type_peek_string(VariantType* this_);
23987 VariantType* g_variant_type_value(VariantType* this_);
23988 VariantType* g_variant_type_checked_(char* arg_a);
23989 int g_variant_type_string_is_valid(char* type_string);
23990 int g_variant_type_string_scan(char* string_, char* limit=null, /*out*/ char** endptr=null);
23991 int g_access(char* filename, int mode);
23992 int g_ascii_digit_value(char c);
23993 char* /*new*/ g_ascii_dtostr(char* buffer, int buf_len, double d);
23994 char* /*new*/ g_ascii_formatd(char* buffer, int buf_len, char* format, double d);
23995 int g_ascii_strcasecmp(char* s1, char* s2);
23996 char* /*new*/ g_ascii_strdown(char* str, ssize_t len);
23997 int g_ascii_strncasecmp(char* s1, char* s2, size_t n);
23998 double g_ascii_strtod(char* nptr, char** endptr);
23999 long g_ascii_strtoll(char* nptr, char** endptr, uint base);
24000 ulong g_ascii_strtoull(char* nptr, char** endptr, uint base);
24001 char* /*new*/ g_ascii_strup(char* str, ssize_t len);
24002 char g_ascii_tolower(char c);
24003 char g_ascii_toupper(char c);
24004 int g_ascii_xdigit_value(char c);
24005 void g_assert_warning(char* log_domain, char* file, int line, char* pretty_function, char* expression);
24006 void g_assertion_message(char* domain, char* file, int line, char* func, char* message);
24007 void g_assertion_message_cmpnum(char* domain, char* file, int line, char* func, char* expr, real arg1, char* cmp, real arg2, char numtype);
24008 void g_assertion_message_cmpstr(char* domain, char* file, int line, char* func, char* expr, char* arg1, char* cmp, char* arg2);
24009 void g_assertion_message_error(char* domain, char* file, int line, char* func, char* expr, Error* error, Quark error_domain, int error_code);
24010 void g_assertion_message_expr(char* domain, char* file, int line, char* func, char* expr);
24011 void g_atexit(VoidFunc func);
24012 int g_atomic_int_add(int* atomic, int val);
24013 uint g_atomic_int_and(uint* atomic, uint val);
24014 int g_atomic_int_compare_and_exchange(int* atomic, int oldval, int newval);
24015 int g_atomic_int_dec_and_test(int* atomic);
24016 int g_atomic_int_exchange_and_add(int* atomic, int val);
24017 int g_atomic_int_get(int* atomic);
24018 void g_atomic_int_inc(int* atomic);
24019 uint g_atomic_int_or(uint* atomic, uint val);
24020 void g_atomic_int_set(int* atomic, int newval);
24021 uint g_atomic_int_xor(uint* atomic, uint val);
24022 ssize_t g_atomic_pointer_add(void* atomic, ssize_t val);
24023 size_t g_atomic_pointer_and(void* atomic, size_t val);
24024 int g_atomic_pointer_compare_and_exchange(void* atomic, void* oldval, void* newval);
24025 void* g_atomic_pointer_get(void* atomic);
24026 size_t g_atomic_pointer_or(void* atomic, size_t val);
24027 void g_atomic_pointer_set(void* atomic, void* newval);
24028 size_t g_atomic_pointer_xor(void* atomic, size_t val);
24029 ubyte* /*new*/ g_base64_decode(char* text, /*out*/ size_t* out_len);
24030 ubyte* g_base64_decode_inplace(/*inout*/ ubyte* text, /*inout*/ size_t* out_len);
24031 size_t g_base64_decode_step(ubyte* in_, size_t len, /*out*/ ubyte* out_, /*inout*/ int* state, /*inout*/ uint* save);
24032 char* /*new*/ g_base64_encode(ubyte* data, size_t len);
24033 size_t g_base64_encode_close(int break_lines, /*out*/ ubyte* out_, /*inout*/ int* state, /*inout*/ int* save);
24034 size_t g_base64_encode_step(ubyte* in_, size_t len, int break_lines, /*out*/ ubyte* out_, /*inout*/ int* state, /*inout*/ int* save);
24035 char* g_basename(char* file_name);
24036 void g_bit_lock(int* address, int lock_bit);
24037 int g_bit_nth_lsf(c_ulong mask, int nth_bit);
24038 int g_bit_nth_msf(c_ulong mask, int nth_bit);
24039 uint g_bit_storage(c_ulong number);
24040 int g_bit_trylock(int* address, int lock_bit);
24041 void g_bit_unlock(int* address, int lock_bit);
24042 void g_blow_chunks();
24043 char* /*new*/ g_build_filename(char* first_element, ...);
24044 char* /*new*/ g_build_filenamev(char** args);
24045 char* /*new*/ g_build_path(char* separator, char* first_element, ...);
24046 char* /*new*/ g_build_pathv(char* separator, char** args);
24047 int g_chdir(char* path);
24048 char* glib_check_version(uint required_major, uint required_minor, uint required_micro);
24049 uint g_child_watch_add(Pid pid, ChildWatchFunc function_, void* data);
24050 uint g_child_watch_add_full(int priority, Pid pid, ChildWatchFunc function_, void* data, DestroyNotify notify);
24051 Source* /*new*/ g_child_watch_source_new(Pid pid);
24052 void g_clear_error(GLib2.Error** error);
24053 char* /*new*/ g_compute_checksum_for_data(ChecksumType checksum_type, ubyte* data, size_t length);
24054 char* /*new*/ g_compute_checksum_for_string(ChecksumType checksum_type, char* str, ssize_t length);
24055 char* /*new*/ g_compute_hmac_for_data(ChecksumType digest_type, ubyte* key, size_t key_len, ubyte* data, size_t length);
24056 char* /*new*/ g_compute_hmac_for_string(ChecksumType digest_type, ubyte* key, size_t key_len, char* str, ssize_t length);
24057 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);
24058 Quark g_convert_error_quark();
24059 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);
24060 char* /*new*/ g_convert_with_iconv(char* str, ssize_t len, IConv converter, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error);
24061 void g_datalist_clear(Data** datalist);
24062 void g_datalist_foreach(Data** datalist, DataForeachFunc func, void* user_data);
24063 void* g_datalist_get_data(Data** datalist, char* key);
24064 uint g_datalist_get_flags(Data** datalist);
24065 void* g_datalist_id_get_data(Data** datalist, Quark key_id);
24066 void* g_datalist_id_remove_no_notify(Data** datalist, Quark key_id);
24067 void g_datalist_id_set_data_full(Data** datalist, Quark key_id, void* data, DestroyNotify destroy_func);
24068 void g_datalist_init(Data** datalist);
24069 void g_datalist_set_flags(Data** datalist, uint flags);
24070 void g_datalist_unset_flags(Data** datalist, uint flags);
24071 void g_dataset_destroy(const(void)* dataset_location);
24072 void g_dataset_foreach(const(void)* dataset_location, DataForeachFunc func, void* user_data);
24073 void* g_dataset_id_get_data(const(void)* dataset_location, Quark key_id);
24074 void* g_dataset_id_remove_no_notify(const(void)* dataset_location, Quark key_id);
24075 void g_dataset_id_set_data_full(const(void)* dataset_location, Quark key_id, void* data, DestroyNotify destroy_func);
24076 char* g_dcgettext(char* domain, char* msgid, int category);
24077 char* g_dgettext(char* domain, char* msgid);
24078 int g_direct_equal(const(void)* v1, const(void)* v2);
24079 uint g_direct_hash(const(void)* v);
24080 char* g_dngettext(char* domain, char* msgid, char* msgid_plural, c_ulong n);
24081 int g_double_equal(const(void)* v1, const(void)* v2);
24082 uint g_double_hash(const(void)* v);
24083 char* g_dpgettext(char* domain, char* msgctxtid, size_t msgidoffset);
24084 char* g_dpgettext2(char* domain, char* context, char* msgid);
24085 void glib_dummy_decl();
24086 FileError g_file_error_from_errno(int err_no);
24087 Quark g_file_error_quark();
24088 int g_file_get_contents(char* filename, /*out*/ ubyte** contents, /*out*/ size_t* length, GLib2.Error** error);
24089 int g_file_open_tmp(char* tmpl, /*out*/ char** name_used, GLib2.Error** error);
24090 char* /*new*/ g_file_read_link(char* filename, GLib2.Error** error);
24091 int g_file_set_contents(char* filename, ubyte* contents, ssize_t length, GLib2.Error** error);
24092 int g_file_test(char* filename, FileTest test);
24093 char* /*new*/ g_filename_display_basename(char* filename);
24094 char* /*new*/ g_filename_display_name(char* filename);
24095 char* /*new*/ g_filename_from_uri(char* uri, char** hostname, GLib2.Error** error);
24096 char* /*new*/ g_filename_from_utf8(char* utf8string, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error);
24097 char* /*new*/ g_filename_to_uri(char* filename, char* hostname, GLib2.Error** error);
24098 char* /*new*/ g_filename_to_utf8(char* opsysstring, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error);
24099 char* /*new*/ g_find_program_in_path(char* program);
24100 char* /*new*/ g_format_size(ulong size);
24101 char* /*new*/ g_format_size_for_display(long size);
24102 char* /*new*/ g_format_size_full(ulong size, FormatSizeFlags flags);
24103 int g_fprintf(FILE* file, char* format, ...);
24104 void g_free(void* mem);
24105 char* g_get_application_name();
24106 int g_get_charset(char** charset);
24107 char* /*new*/ g_get_current_dir();
24108 void g_get_current_time(TimeVal* result);
24109 char** /*new*/ g_get_environ();
24110 int g_get_filename_charsets(char*** charsets);
24111 char* g_get_home_dir();
24112 char* g_get_host_name();
24113 char** g_get_language_names();
24114 char** /*new*/ g_get_locale_variants(char* locale);
24115 long g_get_monotonic_time();
24116 char* /*new*/ g_get_prgname();
24117 char* g_get_real_name();
24118 long g_get_real_time();
24119 char** g_get_system_config_dirs();
24120 char** g_get_system_data_dirs();
24121 char* g_get_tmp_dir();
24122 char* g_get_user_cache_dir();
24123 char* g_get_user_config_dir();
24124 char* g_get_user_data_dir();
24125 char* g_get_user_name();
24126 char* g_get_user_runtime_dir();
24127 char* g_get_user_special_dir(UserDirectory directory);
24128 char* g_getenv(char* variable);
24129 int g_hostname_is_ascii_encoded(char* hostname);
24130 int g_hostname_is_ip_address(char* hostname);
24131 int g_hostname_is_non_ascii(char* hostname);
24132 char* /*new*/ g_hostname_to_ascii(char* hostname);
24133 char* /*new*/ g_hostname_to_unicode(char* hostname);
24134 uint g_idle_add(SourceFunc function_, void* data);
24135 uint g_idle_add_full(int priority, SourceFunc function_, void* data, DestroyNotify notify);
24136 int g_idle_remove_by_data(void* data);
24137 Source* /*new*/ g_idle_source_new();
24138 int g_int64_equal(const(void)* v1, const(void)* v2);
24139 uint g_int64_hash(const(void)* v);
24140 int g_int_equal(const(void)* v1, const(void)* v2);
24141 uint g_int_hash(const(void)* v);
24142 char* g_intern_static_string(char* string_=null);
24143 char* g_intern_string(char* string_=null);
24144 uint g_io_add_watch(IOChannel* channel, IOCondition condition, IOFunc func, void* user_data);
24145 uint g_io_add_watch_full(IOChannel* channel, int priority, IOCondition condition, IOFunc func, void* user_data, DestroyNotify notify);
24146 Source* /*new*/ g_io_create_watch(IOChannel* channel, IOCondition condition);
24147 char** /*new*/ g_listenv();
24148 char* /*new*/ g_locale_from_utf8(char* utf8string, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error);
24149 char* /*new*/ g_locale_to_utf8(char* opsysstring, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error);
24150 void g_log(char* log_domain, LogLevelFlags log_level, char* format, ...);
24151 void g_log_default_handler(char* log_domain, LogLevelFlags log_level, char* message, void* unused_data);
24152 void g_log_remove_handler(char* log_domain, uint handler_id);
24153 LogLevelFlags g_log_set_always_fatal(LogLevelFlags fatal_mask);
24154 LogFunc g_log_set_default_handler(LogFunc log_func, void* user_data);
24155 LogLevelFlags g_log_set_fatal_mask(char* log_domain, LogLevelFlags fatal_mask);
24156 uint g_log_set_handler(char* log_domain, LogLevelFlags log_levels, LogFunc log_func, void* user_data);
24157 void g_logv(char* log_domain, LogLevelFlags log_level, char* format, va_list args);
24158 Source* g_main_current_source();
24159 int g_main_depth();
24160 void* g_malloc(size_t n_bytes);
24161 void* g_malloc0(size_t n_bytes);
24162 void* g_malloc0_n(size_t n_blocks, size_t n_block_bytes);
24163 void* g_malloc_n(size_t n_blocks, size_t n_block_bytes);
24164 int g_markup_collect_attributes(char* element_name, char** attribute_names, char** attribute_values, Error** error, MarkupCollectType first_type, char* first_attr, ...);
24165 Quark g_markup_error_quark();
24166 char* /*new*/ g_markup_escape_text(char* text, ssize_t length);
24167 char* /*new*/ g_markup_printf_escaped(char* format, ...);
24168 char* /*new*/ g_markup_vprintf_escaped(char* format, va_list args);
24169 int g_mem_is_system_malloc();
24170 void g_mem_profile();
24171 void g_mem_set_vtable(MemVTable* vtable);
24172 void* g_memdup(const(void)* mem, uint byte_size);
24173 int g_mkdir_with_parents(char* pathname, int mode);
24174 char* /*new*/ g_mkdtemp(char* tmpl);
24175 char* /*new*/ g_mkdtemp_full(char* tmpl, int mode);
24176 int g_mkstemp(char* tmpl);
24177 int g_mkstemp_full(char* tmpl, int flags, int mode);
24178 void g_nullify_pointer(void** nullify_location);
24179 void g_on_error_query(char* prg_name);
24180 void g_on_error_stack_trace(char* prg_name);
24181 Quark g_option_error_quark();
24182 uint g_parse_debug_string(char* string_, DebugKey* keys, uint nkeys);
24183 char* /*new*/ g_path_get_basename(char* file_name);
24184 char* /*new*/ g_path_get_dirname(char* file_name);
24185 int g_path_is_absolute(char* file_name);
24186 char* g_path_skip_root(char* file_name);
24187 int g_pattern_match(PatternSpec* pspec, uint string_length, char* string_, char* string_reversed);
24188 int g_pattern_match_simple(char* pattern, char* string_);
24189 int g_pattern_match_string(PatternSpec* pspec, char* string_);
24190 void g_pointer_bit_lock(void* address, int lock_bit);
24191 int g_pointer_bit_trylock(void* address, int lock_bit);
24192 void g_pointer_bit_unlock(void* address, int lock_bit);
24193 int g_poll(PollFD* fds, uint nfds, int timeout);
24194 void g_prefix_error(Error** err, char* format, ...);
24195 void g_print(char* format, ...);
24196 void g_printerr(char* format, ...);
24197 int g_printf(char* format, ...);
24198 size_t g_printf_string_upper_bound(char* format, va_list args);
24199 void g_propagate_error(Error** dest, Error* src);
24200 void g_propagate_prefixed_error(Error** dest, Error* src, char* format, ...);
24201 void g_qsort_with_data(const(void)* pbase, int total_elems, size_t size, CompareDataFunc compare_func, void* user_data);
24202 Quark g_quark_from_static_string(char* string_=null);
24203 Quark g_quark_from_string(char* string_=null);
24204 char* g_quark_to_string(Quark quark);
24205 Quark g_quark_try_string(char* string_=null);
24206 double g_random_double();
24207 double g_random_double_range(double begin, double end);
24208 uint g_random_int();
24209 int g_random_int_range(int begin, int end);
24210 void g_random_set_seed(uint seed);
24211 void* g_realloc(void* mem, size_t n_bytes);
24212 void* g_realloc_n(void* mem, size_t n_blocks, size_t n_block_bytes);
24213 void g_reload_user_special_dirs_cache();
24214 void g_return_if_fail_warning(char* log_domain, char* pretty_function, char* expression);
24215 int g_rmdir(char* filename);
24216 void g_set_application_name(char* application_name);
24217 void g_set_error(Error** err, Quark domain, int code, char* format, ...);
24218 void g_set_error_literal(Error** err, Quark domain, int code, char* message);
24219 void g_set_prgname(char* prgname);
24220 PrintFunc g_set_print_handler(PrintFunc func);
24221 PrintFunc g_set_printerr_handler(PrintFunc func);
24222 int g_setenv(char* variable, char* value, int overwrite);
24223 Quark g_shell_error_quark();
24224 int g_shell_parse_argv(char* command_line, /*out*/ int* argcp, /*out*/ char*** argvp, GLib2.Error** error);
24225 char* /*new*/ g_shell_quote(char* unquoted_string);
24226 char* /*new*/ g_shell_unquote(char* quoted_string, GLib2.Error** error);
24227 void* g_slice_alloc(size_t block_size);
24228 void* g_slice_alloc0(size_t block_size);
24229 void* g_slice_copy(size_t block_size, const(void)* mem_block);
24230 void g_slice_free1(size_t block_size, void* mem_block);
24231 void g_slice_free_chain_with_offset(size_t block_size, void* mem_chain, size_t next_offset);
24232 long g_slice_get_config(SliceConfig ckey);
24233 long* g_slice_get_config_state(SliceConfig ckey, long address, uint* n_values);
24234 void g_slice_set_config(SliceConfig ckey, long value);
24235 int g_snprintf(char* string_, c_ulong n, char* format, ...);
24236 uint g_spaced_primes_closest(uint num);
24237 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);
24238 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);
24239 void g_spawn_close_pid(Pid pid);
24240 int g_spawn_command_line_async(char* command_line, GLib2.Error** error);
24241 int g_spawn_command_line_sync(char* command_line, /*out*/ ubyte** standard_output, /*out*/ ubyte** standard_error, /*out*/ int* exit_status, GLib2.Error** error);
24242 Quark g_spawn_error_quark();
24243 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);
24244 int g_sprintf(char* string_, char* format, ...);
24245 char* /*new*/ g_stpcpy(char* dest, char* src);
24246 int g_str_equal(const(void)* v1, const(void)* v2);
24247 int g_str_has_prefix(char* str, char* prefix);
24248 int g_str_has_suffix(char* str, char* suffix);
24249 uint g_str_hash(const(void)* v);
24250 char* /*new*/ g_strcanon(char* string_, char* valid_chars, char substitutor);
24251 int g_strcasecmp(char* s1, char* s2);
24252 char* /*new*/ g_strchomp(char* string_);
24253 char* /*new*/ g_strchug(char* string_);
24254 int g_strcmp0(char* str1, char* str2);
24255 char* /*new*/ g_strcompress(char* source);
24256 char* /*new*/ g_strconcat(char* string1, ...);
24257 char* /*new*/ g_strdelimit(char* string_, char* delimiters, char new_delimiter);
24258 char* /*new*/ g_strdown(char* string_);
24259 char* /*new*/ g_strdup(char* str);
24260 char* /*new*/ g_strdup_printf(char* format, ...);
24261 char* /*new*/ g_strdup_vprintf(char* format, va_list args);
24262 char** g_strdupv(char** str_array);
24263 char* g_strerror(int errnum);
24264 char* /*new*/ g_strescape(char* source, char* exceptions);
24265 void g_strfreev(char** str_array);
24266 String* /*new*/ g_string_new(char* init);
24267 String* /*new*/ g_string_new_len(char* init, ssize_t len);
24268 String* /*new*/ g_string_sized_new(size_t dfl_size);
24269 char* g_strip_context(char* msgid, char* msgval);
24270 char* /*new*/ g_strjoin(char* separator, ...);
24271 char* /*new*/ g_strjoinv(char* separator, char** str_array);
24272 size_t g_strlcat(char* dest, char* src, size_t dest_size);
24273 size_t g_strlcpy(char* dest, char* src, size_t dest_size);
24274 int g_strncasecmp(char* s1, char* s2, uint n);
24275 char* /*new*/ g_strndup(char* str, size_t n);
24276 char* /*new*/ g_strnfill(size_t length, char fill_char);
24277 char* /*new*/ g_strreverse(char* string_);
24278 char* /*new*/ g_strrstr(char* haystack, char* needle);
24279 char* /*new*/ g_strrstr_len(char* haystack, ssize_t haystack_len, char* needle);
24280 char* g_strsignal(int signum);
24281 char** g_strsplit(char* string_, char* delimiter, int max_tokens);
24282 char** g_strsplit_set(char* string_, char* delimiters, int max_tokens);
24283 char* /*new*/ g_strstr_len(char* haystack, ssize_t haystack_len, char* needle);
24284 double g_strtod(char* nptr, char** endptr);
24285 char* /*new*/ g_strup(char* string_);
24286 Type g_strv_get_type();
24287 uint g_strv_length(char** str_array);
24288 void g_test_add_data_func(char* testpath, const(void)* test_data, TestDataFunc test_func);
24289 void g_test_add_func(char* testpath, TestFunc test_func);
24290 void g_test_add_vtable(char* testpath, size_t data_size, const(void)* test_data, TestFixtureFunc data_setup, TestFixtureFunc data_test, TestFixtureFunc data_teardown);
24291 void g_test_bug(char* bug_uri_snippet);
24292 void g_test_bug_base(char* uri_pattern);
24293 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);
24294 TestSuite* g_test_create_suite(char* suite_name);
24295 void g_test_fail();
24296 TestSuite* g_test_get_root();
24297 void g_test_init(int* argc, char*** argv, ...);
24298 void g_test_log_set_fatal_handler(TestLogFatalFunc log_func, void* user_data);
24299 char* g_test_log_type_name(TestLogType log_type);
24300 void g_test_maximized_result(double maximized_quantity, char* format, ...);
24301 void g_test_message(char* format, ...);
24302 void g_test_minimized_result(double minimized_quantity, char* format, ...);
24303 void g_test_queue_destroy(DestroyNotify destroy_func, void* destroy_data);
24304 void g_test_queue_free(void* gfree_pointer);
24305 double g_test_rand_double();
24306 double g_test_rand_double_range(double range_start, double range_end);
24307 int g_test_rand_int();
24308 int g_test_rand_int_range(int begin, int end);
24309 int g_test_run();
24310 int g_test_run_suite(TestSuite* suite);
24311 double g_test_timer_elapsed();
24312 double g_test_timer_last();
24313 void g_test_timer_start();
24314 void g_test_trap_assertions(char* domain, char* file, int line, char* func, ulong assertion_flags, char* pattern);
24315 int g_test_trap_fork(ulong usec_timeout, TestTrapFlags test_trap_flags);
24316 int g_test_trap_has_passed();
24317 int g_test_trap_reached_timeout();
24318 uint g_timeout_add(uint interval, SourceFunc function_, void* data);
24319 uint g_timeout_add_full(int priority, uint interval, SourceFunc function_, void* data, DestroyNotify notify);
24320 uint g_timeout_add_seconds(uint interval, SourceFunc function_, void* data);
24321 uint g_timeout_add_seconds_full(int priority, uint interval, SourceFunc function_, void* data, DestroyNotify notify);
24322 Source* /*new*/ g_timeout_source_new(uint interval);
24323 Source* /*new*/ g_timeout_source_new_seconds(uint interval);
24324 void* g_try_malloc(size_t n_bytes);
24325 void* g_try_malloc0(size_t n_bytes);
24326 void* g_try_malloc0_n(size_t n_blocks, size_t n_block_bytes);
24327 void* g_try_malloc_n(size_t n_blocks, size_t n_block_bytes);
24328 void* g_try_realloc(void* mem, size_t n_bytes);
24329 void* g_try_realloc_n(void* mem, size_t n_blocks, size_t n_block_bytes);
24330 wchar* g_ucs4_to_utf16(dchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error);
24331 char* /*new*/ g_ucs4_to_utf8(dchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error);
24332 UnicodeBreakType g_unichar_break_type(dchar c);
24333 int g_unichar_combining_class(dchar uc);
24334 int g_unichar_compose(dchar a, dchar b, dchar* ch);
24335 int g_unichar_decompose(dchar ch, dchar* a, dchar* b);
24336 int g_unichar_digit_value(dchar c);
24337 size_t g_unichar_fully_decompose(dchar ch, int compat, dchar* result, size_t result_len);
24338 int g_unichar_get_mirror_char(dchar ch, dchar* mirrored_ch);
24339 UnicodeScript g_unichar_get_script(dchar ch);
24340 int g_unichar_isalnum(dchar c);
24341 int g_unichar_isalpha(dchar c);
24342 int g_unichar_iscntrl(dchar c);
24343 int g_unichar_isdefined(dchar c);
24344 int g_unichar_isdigit(dchar c);
24345 int g_unichar_isgraph(dchar c);
24346 int g_unichar_islower(dchar c);
24347 int g_unichar_ismark(dchar c);
24348 int g_unichar_isprint(dchar c);
24349 int g_unichar_ispunct(dchar c);
24350 int g_unichar_isspace(dchar c);
24351 int g_unichar_istitle(dchar c);
24352 int g_unichar_isupper(dchar c);
24353 int g_unichar_iswide(dchar c);
24354 int g_unichar_iswide_cjk(dchar c);
24355 int g_unichar_isxdigit(dchar c);
24356 int g_unichar_iszerowidth(dchar c);
24357 int g_unichar_to_utf8(dchar c, char* outbuf);
24358 dchar g_unichar_tolower(dchar c);
24359 dchar g_unichar_totitle(dchar c);
24360 dchar g_unichar_toupper(dchar c);
24361 UnicodeType g_unichar_type(dchar c);
24362 int g_unichar_validate(dchar ch);
24363 int g_unichar_xdigit_value(dchar c);
24364 dchar* g_unicode_canonical_decomposition(dchar ch, size_t* result_len);
24365 void g_unicode_canonical_ordering(dchar* string_, size_t len);
24366 UnicodeScript g_unicode_script_from_iso15924(uint iso15924);
24367 uint g_unicode_script_to_iso15924(UnicodeScript script);
24368 int g_unlink(char* filename);
24369 void g_unsetenv(char* variable);
24370 char* /*new*/ g_uri_escape_string(char* unescaped, char* reserved_chars_allowed, int allow_utf8);
24371 char** g_uri_list_extract_uris(char* uri_list);
24372 char* /*new*/ g_uri_parse_scheme(char* uri);
24373 char* /*new*/ g_uri_unescape_segment(char* escaped_string, char* escaped_string_end, char* illegal_characters);
24374 char* /*new*/ g_uri_unescape_string(char* escaped_string, char* illegal_characters);
24375 void g_usleep(c_ulong microseconds);
24376 dchar* g_utf16_to_ucs4(wchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error);
24377 char* /*new*/ g_utf16_to_utf8(wchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error);
24378 char* /*new*/ g_utf8_casefold(char* str, ssize_t len);
24379 int g_utf8_collate(char* str1, char* str2);
24380 char* /*new*/ g_utf8_collate_key(char* str, ssize_t len);
24381 char* /*new*/ g_utf8_collate_key_for_filename(char* str, ssize_t len);
24382 char* /*new*/ g_utf8_find_next_char(char* p, char* end);
24383 char* /*new*/ g_utf8_find_prev_char(char* str, char* p);
24384 dchar g_utf8_get_char(char* p);
24385 dchar g_utf8_get_char_validated(char* p, ssize_t max_len);
24386 char* /*new*/ g_utf8_normalize(char* str, ssize_t len, NormalizeMode mode);
24387 char* /*new*/ g_utf8_offset_to_pointer(char* str, c_long offset);
24388 c_long g_utf8_pointer_to_offset(char* str, char* pos);
24389 char* /*new*/ g_utf8_prev_char(char* p);
24390 char* /*new*/ g_utf8_strchr(char* p, ssize_t len, dchar c);
24391 char* /*new*/ g_utf8_strdown(char* str, ssize_t len);
24392 c_long g_utf8_strlen(char* p, ssize_t max);
24393 char* /*new*/ g_utf8_strncpy(char* dest, char* src, size_t n);
24394 char* /*new*/ g_utf8_strrchr(char* p, ssize_t len, dchar c);
24395 char* /*new*/ g_utf8_strreverse(char* str, ssize_t len);
24396 char* /*new*/ g_utf8_strup(char* str, ssize_t len);
24397 char* /*new*/ g_utf8_substring(char* str, c_long start_pos, c_long end_pos);
24398 dchar* g_utf8_to_ucs4(char* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error);
24399 dchar* g_utf8_to_ucs4_fast(char* str, c_long len, c_long* items_written);
24400 wchar* g_utf8_to_utf16(char* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error);
24401 int g_utf8_validate(char* str, ssize_t max_len, /*out*/ char** end=null);
24402 Type g_variant_get_gtype();
24403 VariantType* g_variant_get_type(Variant* value);
24404 int g_vasprintf(char** string_, char* format, va_list args);
24405 int g_vfprintf(FILE* file, char* format, va_list args);
24406 int g_vprintf(char* format, va_list args);
24407 int g_vsnprintf(char* string_, c_ulong n, char* format, va_list args);
24408 int g_vsprintf(char* string_, char* format, va_list args);
24409 void g_warn_message(char* domain, char* file, int line, char* func, char* warnexpr);