Support pre-GTK3 GLibs too.
[girtod.git] / gtk2 / glib2.d
blobedf4e9e47f5b7734e648fe567f3d4ea5d1a82368
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 helpers.
71 void _dumpObj(T)(T o, bool deep=0) {
72 auto ts = o.tupleof;
73 _print(typeid(o), " {");
75 static if (is(typeof(*T)==union)) {
76 _print(*o, "}\n");
77 return;
79 else {
80 _println();
82 foreach (i, t; ts) {
83 string fieldName = T.tupleof[i].stringof;
84 // Skip everything until the first '.'.
85 foreach (i, c; fieldName)
86 if (c=='.') {
87 fieldName = fieldName[i+1..$];
88 break;
91 _print(" (", typeid(t), " ", fieldName, ") ", t);
92 if (deep)
93 static if (is(typeof(*t)))
94 if (ts[i])
95 _print(" {", *ts[i], "}");
96 _print(i!=ts.length-1 ? "\n" : "\n}\n");
101 void _println(A...)(A a) {
102 import std.stdio;
103 try writeln(a); catch (Exception e) {}
105 void _printf(A...)(A a) {
106 import std.stdio;
107 try writef(a); catch (Exception e) {}
109 void _print(A...)(A a) {
110 import std.stdio;
111 try write(a); catch (Exception e) {}
114 // Template helpers.
115 // Give the user at least a chance to figure out what's wrong when a template
116 // constraint doesn't match - print both the found and the expected types.
117 bool _ttmm(T, E)() {
118 pragma(msg, "\nExpected: '" ~ E.stringof ~"';\n found: '" ~ T.stringof ~"'.\n");
119 return 0;
122 // <--- mixin/GLib2__MODULE_HEAD.d ---
125 // Integer representing a day of the month; between 1 and
126 // 31. #G_DATE_BAD_DAY represents an invalid day of the month.
127 alias ubyte DateDay;
129 // Integer representing a year; #G_DATE_BAD_YEAR is the invalid
130 // value. The year must be 1 or higher; negative (BC) years are not
131 // allowed. The year is represented with four digits.
132 alias ushort DateYear;
134 // A type which is used to hold a process identification.
136 // On UNIX, processes are identified by a process id (an integer),
137 // while Windows uses process handles (which are pointers).
139 // GPid is used in GLib only for descendant processes spawned with
140 // the g_spawn functions.
141 alias int Pid;
143 // A GQuark is a non-zero integer which uniquely identifies a
144 // particular string. A GQuark value of zero is associated to %NULL.
145 alias uint Quark;
146 // A C representable type name for #G_TYPE_STRV.
147 alias void* Strv;
149 // Simply a replacement for <type>time_t</type>. It has been deprecated
150 // since it is <emphasis>not</emphasis> equivalent to <type>time_t</type>
151 // on 64-bit platforms with a 64-bit <type>time_t</type>.
152 // Unrelated to #GTimer.
154 // Note that <type>GTime</type> is defined to always be a 32bit integer,
155 // unlike <type>time_t</type> which may be 64bit on some systems.
156 // Therefore, <type>GTime</type> will overflow in the year 2038, and
157 // you cannot use the address of a <type>GTime</type> variable as argument
158 // to the UNIX time() function. Instead, do the following:
159 // |[
160 // time_t ttime;
161 // GTime gtime;
163 // time (&amp;ttime);
164 // gtime = (GTime)ttime;
165 // ]|
166 alias int Time;
167 // A value representing an interval of time, in microseconds.
168 alias long TimeSpan;
170 // A numerical value which represents the unique identifier of a registered
171 // type.
172 alias size_t Type;
173 enum int ASCII_DTOSTR_BUF_SIZE = 39;
174 // Contains the public fields of an <link linkend="glib-Arrays">Array</link>.
175 struct Array {
176 char* data;
177 uint len;
180 // Unintrospectable function: append_vals() / g_array_append_vals()
181 // Adds @len elements onto the end of the array.
182 // <array>: a #GArray.
183 // <data>: a pointer to the elements to append to the end of the array.
184 // <len>: the number of elements to append.
185 static Array* append_vals()(Array* array, const(void)* data, uint len) nothrow {
186 return g_array_append_vals(array, data, len);
189 // Frees the memory allocated for the #GArray. If @free_segment is
190 // %TRUE it frees the memory block holding the elements as well and
191 // also each element if @array has a @element_free_func set. Pass
192 // %FALSE if you want to free the #GArray wrapper but preserve the
193 // underlying array for use elsewhere. If the reference count of @array
194 // is greater than one, the #GArray wrapper is preserved but the size
195 // of @array will be set to zero.
197 // <note><para>If array elements contain dynamically-allocated memory,
198 // they should be freed separately.</para></note>
199 // <array>: a #GArray.
200 // <free_segment>: if %TRUE the actual element data is freed as well.
201 static char* /*new*/ free()(Array* array, int free_segment) nothrow {
202 return g_array_free(array, free_segment);
205 // VERSION: 2.22
206 // Gets the size of the elements in @array.
207 // RETURNS: Size of each element, in bytes.
208 // <array>: A #GArray.
209 static uint get_element_size()(Array* array) nothrow {
210 return g_array_get_element_size(array);
213 // Unintrospectable function: insert_vals() / g_array_insert_vals()
214 // Inserts @len elements into a #GArray at the given index.
215 // <array>: a #GArray.
216 // <index_>: the index to place the elements at.
217 // <data>: a pointer to the elements to insert.
218 // <len>: the number of elements to insert.
219 static Array* insert_vals()(Array* array, uint index_, const(void)* data, uint len) nothrow {
220 return g_array_insert_vals(array, index_, data, len);
223 // Unintrospectable function: new() / g_array_new()
224 // Creates a new #GArray with a reference count of 1.
225 // <zero_terminated>: %TRUE if the array should have an extra element at the end which is set to 0.
226 // <clear_>: %TRUE if #GArray elements should be automatically cleared to 0 when they are allocated.
227 // <element_size>: the size of each element in bytes.
228 static Array* new_()(int zero_terminated, int clear_, uint element_size) nothrow {
229 return g_array_new(zero_terminated, clear_, element_size);
232 // Unintrospectable function: prepend_vals() / g_array_prepend_vals()
233 // Adds @len elements onto the start of the array.
235 // This operation is slower than g_array_append_vals() since the
236 // existing elements in the array have to be moved to make space for
237 // the new elements.
238 // <array>: a #GArray.
239 // <data>: a pointer to the elements to prepend to the start of the array.
240 // <len>: the number of elements to prepend.
241 static Array* prepend_vals()(Array* array, const(void)* data, uint len) nothrow {
242 return g_array_prepend_vals(array, data, len);
245 // Unintrospectable function: ref() / g_array_ref()
246 // VERSION: 2.22
247 // Atomically increments the reference count of @array by one. This
248 // function is MT-safe and may be called from any thread.
249 // RETURNS: The passed in #GArray.
250 // <array>: A #GArray.
251 static Array* ref_()(Array* array) nothrow {
252 return g_array_ref(array);
255 // Unintrospectable function: remove_index() / g_array_remove_index()
256 // Removes the element at the given index from a #GArray. The following
257 // elements are moved down one place.
258 // <array>: a #GArray.
259 // <index_>: the index of the element to remove.
260 static Array* remove_index()(Array* array, uint index_) nothrow {
261 return g_array_remove_index(array, index_);
264 // Unintrospectable function: remove_index_fast() / g_array_remove_index_fast()
265 // Removes the element at the given index from a #GArray. The last
266 // element in the array is used to fill in the space, so this function
267 // does not preserve the order of the #GArray. But it is faster than
268 // g_array_remove_index().
269 // <array>: a @GArray.
270 // <index_>: the index of the element to remove.
271 static Array* remove_index_fast()(Array* array, uint index_) nothrow {
272 return g_array_remove_index_fast(array, index_);
275 // Unintrospectable function: remove_range() / g_array_remove_range()
276 // VERSION: 2.4
277 // Removes the given number of elements starting at the given index
278 // from a #GArray. The following elements are moved to close the gap.
279 // <array>: a @GArray.
280 // <index_>: the index of the first element to remove.
281 // <length>: the number of elements to remove.
282 static Array* remove_range()(Array* array, uint index_, uint length) nothrow {
283 return g_array_remove_range(array, index_, length);
285 static void set_clear_func()(Array* array, DestroyNotify clear_func) nothrow {
286 g_array_set_clear_func(array, clear_func);
289 // Unintrospectable function: set_size() / g_array_set_size()
290 // Sets the size of the array, expanding it if necessary. If the array
291 // was created with @clear_ set to %TRUE, the new elements are set to 0.
292 // <array>: a #GArray.
293 // <length>: the new size of the #GArray.
294 static Array* set_size()(Array* array, uint length) nothrow {
295 return g_array_set_size(array, length);
298 // Unintrospectable function: sized_new() / g_array_sized_new()
299 // Creates a new #GArray with @reserved_size elements preallocated and
300 // a reference count of 1. This avoids frequent reallocation, if you
301 // are going to add many elements to the array. Note however that the
302 // size of the array is still 0.
303 // <zero_terminated>: %TRUE if the array should have an extra element at the end with all bits cleared.
304 // <clear_>: %TRUE if all bits in the array should be cleared to 0 on allocation.
305 // <element_size>: size of each element in the array.
306 // <reserved_size>: number of elements preallocated.
307 static Array* sized_new()(int zero_terminated, int clear_, uint element_size, uint reserved_size) nothrow {
308 return g_array_sized_new(zero_terminated, clear_, element_size, reserved_size);
311 // Unintrospectable function: sort() / g_array_sort()
312 // Sorts a #GArray using @compare_func which should be a qsort()-style
313 // comparison function (returns less than zero for first arg is less
314 // than second arg, zero for equal, greater zero if first arg is
315 // greater than second arg).
317 // If two array elements compare equal, their order in the sorted array
318 // is undefined. If you want equal elements to keep their order (i.e.
319 // you want a stable sort) you can write a comparison function that,
320 // if two elements would otherwise compare equal, compares them by
321 // their addresses.
322 // <array>: a #GArray.
323 // <compare_func>: comparison function.
324 static void sort()(Array* array, CompareFunc compare_func) nothrow {
325 g_array_sort(array, compare_func);
328 // Unintrospectable function: sort_with_data() / g_array_sort_with_data()
329 // Like g_array_sort(), but the comparison function receives an extra
330 // user data argument.
331 // <array>: a #GArray.
332 // <compare_func>: comparison function.
333 // <user_data>: data to pass to @compare_func.
334 static void sort_with_data()(Array* array, CompareDataFunc compare_func, void* user_data) nothrow {
335 g_array_sort_with_data(array, compare_func, user_data);
338 // VERSION: 2.22
339 // Atomically decrements the reference count of @array by one. If the
340 // reference count drops to 0, all memory allocated by the array is
341 // released. This function is MT-safe and may be called from any
342 // thread.
343 // <array>: A #GArray.
344 static void unref()(Array* array) nothrow {
345 g_array_unref(array);
349 enum AsciiType {
350 ALNUM = 1,
351 ALPHA = 2,
352 CNTRL = 4,
353 DIGIT = 8,
354 GRAPH = 16,
355 LOWER = 32,
356 PRINT = 64,
357 PUNCT = 128,
358 SPACE = 256,
359 UPPER = 512,
360 XDIGIT = 1024
363 // The GAsyncQueue struct is an opaque data structure which represents
364 // an asynchronous queue. It should only be accessed through the
365 // <function>g_async_queue_*</function> functions.
366 struct AsyncQueue {
368 // Returns the length of the queue.
370 // Actually this function returns the number of data items in
371 // the queue minus the number of waiting threads, so a negative
372 // value means waiting threads, and a positive value means available
373 // entries in the @queue. A return value of 0 could mean n entries
374 // in the queue and n threads waiting. This can happen due to locking
375 // of the queue or due to scheduling.
376 // RETURNS: the length of the @queue
377 int length()() nothrow {
378 return g_async_queue_length(&this);
381 // Returns the length of the queue.
383 // Actually this function returns the number of data items in
384 // the queue minus the number of waiting threads, so a negative
385 // value means waiting threads, and a positive value means available
386 // entries in the @queue. A return value of 0 could mean n entries
387 // in the queue and n threads waiting. This can happen due to locking
388 // of the queue or due to scheduling.
390 // This function must be called while holding the @queue's lock.
391 // RETURNS: the length of the @queue.
392 int length_unlocked()() nothrow {
393 return g_async_queue_length_unlocked(&this);
396 // Acquires the @queue's lock. If another thread is already
397 // holding the lock, this call will block until the lock
398 // becomes available.
400 // Call g_async_queue_unlock() to drop the lock again.
402 // While holding the lock, you can only call the
403 // <function>g_async_queue_*_unlocked()</function> functions
404 // on @queue. Otherwise, deadlock may occur.
405 void lock()() nothrow {
406 g_async_queue_lock(&this);
409 // Unintrospectable method: pop() / g_async_queue_pop()
410 // Pops data from the @queue. If @queue is empty, this function
411 // blocks until data becomes available.
412 // RETURNS: data from the queue
413 void* pop()() nothrow {
414 return g_async_queue_pop(&this);
417 // Unintrospectable method: pop_unlocked() / g_async_queue_pop_unlocked()
418 // Pops data from the @queue. If @queue is empty, this function
419 // blocks until data becomes available.
421 // This function must be called while holding the @queue's lock.
422 // RETURNS: data from the queue.
423 void* pop_unlocked()() nothrow {
424 return g_async_queue_pop_unlocked(&this);
427 // Pushes the @data into the @queue. @data must not be %NULL.
428 // <data>: @data to push into the @queue
429 void push()(void* data) nothrow {
430 g_async_queue_push(&this, data);
433 // Unintrospectable method: push_sorted() / g_async_queue_push_sorted()
434 // VERSION: 2.10
435 // Inserts @data into @queue using @func to determine the new
436 // position.
438 // This function requires that the @queue is sorted before pushing on
439 // new elements, see g_async_queue_sort().
441 // This function will lock @queue before it sorts the queue and unlock
442 // it when it is finished.
444 // For an example of @func see g_async_queue_sort().
445 // <data>: the @data to push into the @queue
446 // <func>: the #GCompareDataFunc is used to sort @queue
447 // <user_data>: user data passed to @func.
448 void push_sorted()(void* data, CompareDataFunc func, void* user_data) nothrow {
449 g_async_queue_push_sorted(&this, data, func, user_data);
452 // Unintrospectable method: push_sorted_unlocked() / g_async_queue_push_sorted_unlocked()
453 // VERSION: 2.10
454 // Inserts @data into @queue using @func to determine the new
455 // position.
457 // The sort function @func is passed two elements of the @queue.
458 // It should return 0 if they are equal, a negative value if the
459 // first element should be higher in the @queue or a positive value
460 // if the first element should be lower in the @queue than the second
461 // element.
463 // This function requires that the @queue is sorted before pushing on
464 // new elements, see g_async_queue_sort().
466 // This function must be called while holding the @queue's lock.
468 // For an example of @func see g_async_queue_sort().
469 // <data>: the @data to push into the @queue
470 // <func>: the #GCompareDataFunc is used to sort @queue
471 // <user_data>: user data passed to @func.
472 void push_sorted_unlocked()(void* data, CompareDataFunc func, void* user_data) nothrow {
473 g_async_queue_push_sorted_unlocked(&this, data, func, user_data);
476 // Pushes the @data into the @queue. @data must not be %NULL.
478 // This function must be called while holding the @queue's lock.
479 // <data>: @data to push into the @queue
480 void push_unlocked()(void* data) nothrow {
481 g_async_queue_push_unlocked(&this, data);
484 // Unintrospectable method: ref() / g_async_queue_ref()
485 // Increases the reference count of the asynchronous @queue by 1.
486 // You do not need to hold the lock to call this function.
487 // RETURNS: the @queue that was passed in (since 2.6)
488 AsyncQueue* ref_()() nothrow {
489 return g_async_queue_ref(&this);
492 // Increases the reference count of the asynchronous @queue by 1.
494 // so g_async_queue_ref() can be used regardless of the @queue's
495 // lock.
496 void ref_unlocked()() nothrow {
497 g_async_queue_ref_unlocked(&this);
500 // Unintrospectable method: sort() / g_async_queue_sort()
501 // VERSION: 2.10
502 // Sorts @queue using @func.
504 // The sort function @func is passed two elements of the @queue.
505 // It should return 0 if they are equal, a negative value if the
506 // first element should be higher in the @queue or a positive value
507 // if the first element should be lower in the @queue than the second
508 // element.
510 // This function will lock @queue before it sorts the queue and unlock
511 // it when it is finished.
513 // If you were sorting a list of priority numbers to make sure the
514 // lowest priority would be at the top of the queue, you could use:
515 // |[
516 // gint32 id1;
517 // gint32 id2;
519 // id1 = GPOINTER_TO_INT (element1);
520 // id2 = GPOINTER_TO_INT (element2);
522 // return (id1 > id2 ? +1 : id1 == id2 ? 0 : -1);
523 // ]|
524 // <func>: the #GCompareDataFunc is used to sort @queue
525 // <user_data>: user data passed to @func
526 void sort()(CompareDataFunc func, void* user_data) nothrow {
527 g_async_queue_sort(&this, func, user_data);
530 // Unintrospectable method: sort_unlocked() / g_async_queue_sort_unlocked()
531 // VERSION: 2.10
532 // Sorts @queue using @func.
534 // The sort function @func is passed two elements of the @queue.
535 // It should return 0 if they are equal, a negative value if the
536 // first element should be higher in the @queue or a positive value
537 // if the first element should be lower in the @queue than the second
538 // element.
540 // This function must be called while holding the @queue's lock.
541 // <func>: the #GCompareDataFunc is used to sort @queue
542 // <user_data>: user data passed to @func
543 void sort_unlocked()(CompareDataFunc func, void* user_data) nothrow {
544 g_async_queue_sort_unlocked(&this, func, user_data);
547 // Unintrospectable method: timed_pop() / g_async_queue_timed_pop()
548 // Pops data from the @queue. If the queue is empty, blocks until
549 // @end_time or until data becomes available.
551 // If no data is received before @end_time, %NULL is returned.
553 // To easily calculate @end_time, a combination of g_get_current_time()
554 // and g_time_val_add() can be used.
556 // received before @end_time.
557 // RETURNS: data from the queue or %NULL, when no data is
558 // <end_time>: a #GTimeVal, determining the final time
559 void* timed_pop()(TimeVal* end_time) nothrow {
560 return g_async_queue_timed_pop(&this, end_time);
563 // Unintrospectable method: timed_pop_unlocked() / g_async_queue_timed_pop_unlocked()
564 // Pops data from the @queue. If the queue is empty, blocks until
565 // @end_time or until data becomes available.
567 // If no data is received before @end_time, %NULL is returned.
569 // To easily calculate @end_time, a combination of g_get_current_time()
570 // and g_time_val_add() can be used.
572 // This function must be called while holding the @queue's lock.
574 // received before @end_time.
575 // RETURNS: data from the queue or %NULL, when no data is
576 // <end_time>: a #GTimeVal, determining the final time
577 void* timed_pop_unlocked()(TimeVal* end_time) nothrow {
578 return g_async_queue_timed_pop_unlocked(&this, end_time);
581 // Unintrospectable method: try_pop() / g_async_queue_try_pop()
582 // Tries to pop data from the @queue. If no data is available,
583 // %NULL is returned.
585 // available immediately.
586 // RETURNS: data from the queue or %NULL, when no data is
587 void* try_pop()() nothrow {
588 return g_async_queue_try_pop(&this);
591 // Unintrospectable method: try_pop_unlocked() / g_async_queue_try_pop_unlocked()
592 // Tries to pop data from the @queue. If no data is available,
593 // %NULL is returned.
595 // This function must be called while holding the @queue's lock.
597 // available immediately.
598 // RETURNS: data from the queue or %NULL, when no data is
599 void* try_pop_unlocked()() nothrow {
600 return g_async_queue_try_pop_unlocked(&this);
603 // Releases the queue's lock.
605 // Calling this function when you have not acquired
606 // the with g_async_queue_lock() leads to undefined
607 // behaviour.
608 void unlock()() nothrow {
609 g_async_queue_unlock(&this);
612 // Decreases the reference count of the asynchronous @queue by 1.
614 // If the reference count went to 0, the @queue will be destroyed
615 // and the memory allocated will be freed. So you are not allowed
616 // to use the @queue afterwards, as it might have disappeared.
617 // You do not need to hold the lock to call this function.
618 void unref()() nothrow {
619 g_async_queue_unref(&this);
622 // Decreases the reference count of the asynchronous @queue by 1
623 // and releases the lock. This function must be called while holding
624 // the @queue's lock. If the reference count went to 0, the @queue
625 // will be destroyed and the memory allocated will be freed.
627 // so g_async_queue_unref() can be used regardless of the @queue's
628 // lock.
629 void unref_and_unlock()() nothrow {
630 g_async_queue_unref_and_unlock(&this);
633 // Unintrospectable function: new() / g_async_queue_new()
634 // Creates a new asynchronous queue.
635 // RETURNS: a new #GAsyncQueue. Free with g_async_queue_unref()
636 static AsyncQueue* new_()() nothrow {
637 return g_async_queue_new();
640 // Unintrospectable function: new_full() / g_async_queue_new_full()
641 // VERSION: 2.16
642 // Creates a new asynchronous queue and sets up a destroy notify
643 // function that is used to free any remaining queue items when
644 // the queue is destroyed after the final unref.
645 // RETURNS: a new #GAsyncQueue. Free with g_async_queue_unref()
646 // <item_free_func>: function to free queue elements
647 static AsyncQueue* new_full()(DestroyNotify item_free_func) nothrow {
648 return g_async_queue_new_full(item_free_func);
652 enum int BIG_ENDIAN = 4321;
654 // The <structname>GBookmarkFile</structname> struct contains only
655 // private data and should not be directly accessed.
656 struct BookmarkFile {
658 // VERSION: 2.12
659 // Adds the application with @name and @exec to the list of
660 // applications that have registered a bookmark for @uri into
661 // @bookmark.
663 // Every bookmark inside a #GBookmarkFile must have at least an
664 // application registered. Each application must provide a name, a
665 // command line useful for launching the bookmark, the number of times
666 // the bookmark has been registered by the application and the last
667 // time the application registered this bookmark.
669 // If @name is %NULL, the name of the application will be the
670 // same returned by g_get_application_name(); if @exec is %NULL, the
671 // command line will be a composition of the program name as
672 // returned by g_get_prgname() and the "\%u" modifier, which will be
673 // expanded to the bookmark's URI.
675 // This function will automatically take care of updating the
676 // registrations count and timestamping in case an application
677 // with the same @name had already registered a bookmark for
678 // @uri inside @bookmark.
680 // If no bookmark for @uri is found, one is created.
681 // <uri>: a valid URI
682 // <name>: the name of the application registering the bookmark or %NULL
683 // <exec>: command line to be used to launch the bookmark or %NULL
684 void add_application()(char* uri, char* name, char* exec) nothrow {
685 g_bookmark_file_add_application(&this, uri, name, exec);
688 // VERSION: 2.12
689 // Adds @group to the list of groups to which the bookmark for @uri
690 // belongs to.
692 // If no bookmark for @uri is found then it is created.
693 // <uri>: a valid URI
694 // <group>: the group name to be added
695 void add_group()(char* uri, char* group) nothrow {
696 g_bookmark_file_add_group(&this, uri, group);
699 // VERSION: 2.12
700 // Frees a #GBookmarkFile.
701 void free()() nothrow {
702 g_bookmark_file_free(&this);
705 // VERSION: 2.12
706 // Gets the time the bookmark for @uri was added to @bookmark
708 // In the event the URI cannot be found, -1 is returned and
709 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
710 // RETURNS: a timestamp
711 // <uri>: a valid URI
712 time_t get_added()(char* uri, GLib2.Error** error=null) nothrow {
713 return g_bookmark_file_get_added(&this, uri, error);
716 // VERSION: 2.12
717 // Gets the registration informations of @app_name for the bookmark for
718 // @uri. See g_bookmark_file_set_app_info() for more informations about
719 // the returned data.
721 // The string returned in @app_exec must be freed.
723 // In the event the URI cannot be found, %FALSE is returned and
724 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the
725 // event that no application with name @app_name has registered a bookmark
726 // for @uri, %FALSE is returned and error is set to
727 // #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. In the event that unquoting
728 // the command line fails, an error of the #G_SHELL_ERROR domain is
729 // set and %FALSE is returned.
730 // RETURNS: %TRUE on success.
731 // <uri>: a valid URI
732 // <name>: an application's name
733 // <exec>: location for the command line of the application, or %NULL
734 // <count>: return location for the registration count, or %NULL
735 // <stamp>: return location for the last registration time, or %NULL
736 int get_app_info()(char* uri, char* name, char** exec, uint* count, time_t* stamp, GLib2.Error** error=null) nothrow {
737 return g_bookmark_file_get_app_info(&this, uri, name, exec, count, stamp, error);
740 // Unintrospectable method: get_applications() / g_bookmark_file_get_applications()
741 // VERSION: 2.12
742 // Retrieves the names of the applications that have registered the
743 // bookmark for @uri.
745 // In the event the URI cannot be found, %NULL is returned and
746 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
748 // Use g_strfreev() to free it.
749 // RETURNS: a newly allocated %NULL-terminated array of strings.
750 // <uri>: a valid URI
751 // <length>: return location of the length of the returned list, or %NULL
752 char** get_applications()(char* uri, size_t* length, GLib2.Error** error=null) nothrow {
753 return g_bookmark_file_get_applications(&this, uri, length, error);
756 // VERSION: 2.12
757 // Retrieves the description of the bookmark for @uri.
759 // In the event the URI cannot be found, %NULL is returned and
760 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
762 // URI cannot be found.
763 // RETURNS: a newly allocated string or %NULL if the specified
764 // <uri>: a valid URI
765 char* /*new*/ get_description()(char* uri, GLib2.Error** error=null) nothrow {
766 return g_bookmark_file_get_description(&this, uri, error);
769 // Unintrospectable method: get_groups() / g_bookmark_file_get_groups()
770 // VERSION: 2.12
771 // Retrieves the list of group names of the bookmark for @uri.
773 // In the event the URI cannot be found, %NULL is returned and
774 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
776 // The returned array is %NULL terminated, so @length may optionally
777 // be %NULL.
779 // Use g_strfreev() to free it.
780 // RETURNS: a newly allocated %NULL-terminated array of group names.
781 // <uri>: a valid URI
782 // <length>: return location for the length of the returned string, or %NULL
783 char** get_groups()(char* uri, size_t* length, GLib2.Error** error=null) nothrow {
784 return g_bookmark_file_get_groups(&this, uri, length, error);
787 // VERSION: 2.12
788 // Gets the icon of the bookmark for @uri.
790 // In the event the URI cannot be found, %FALSE is returned and
791 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
793 // You should free the returned strings.
794 // RETURNS: %TRUE if the icon for the bookmark for the URI was found.
795 // <uri>: a valid URI
796 // <href>: return location for the icon's location or %NULL
797 // <mime_type>: return location for the icon's MIME type or %NULL
798 int get_icon()(char* uri, char** href, char** mime_type, GLib2.Error** error=null) nothrow {
799 return g_bookmark_file_get_icon(&this, uri, href, mime_type, error);
802 // VERSION: 2.12
803 // Gets whether the private flag of the bookmark for @uri is set.
805 // In the event the URI cannot be found, %FALSE is returned and
806 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the
807 // event that the private flag cannot be found, %FALSE is returned and
808 // @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
809 // RETURNS: %TRUE if the private flag is set, %FALSE otherwise.
810 // <uri>: a valid URI
811 int get_is_private()(char* uri, GLib2.Error** error=null) nothrow {
812 return g_bookmark_file_get_is_private(&this, uri, error);
815 // VERSION: 2.12
816 // Retrieves the MIME type of the resource pointed by @uri.
818 // In the event the URI cannot be found, %NULL is returned and
819 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the
820 // event that the MIME type cannot be found, %NULL is returned and
821 // @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
823 // URI cannot be found.
824 // RETURNS: a newly allocated string or %NULL if the specified
825 // <uri>: a valid URI
826 char* /*new*/ get_mime_type()(char* uri, GLib2.Error** error=null) nothrow {
827 return g_bookmark_file_get_mime_type(&this, uri, error);
830 // VERSION: 2.12
831 // Gets the time when the bookmark for @uri was last modified.
833 // In the event the URI cannot be found, -1 is returned and
834 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
835 // RETURNS: a timestamp
836 // <uri>: a valid URI
837 time_t get_modified()(char* uri, GLib2.Error** error=null) nothrow {
838 return g_bookmark_file_get_modified(&this, uri, error);
841 // VERSION: 2.12
842 // Gets the number of bookmarks inside @bookmark.
843 // RETURNS: the number of bookmarks
844 int get_size()() nothrow {
845 return g_bookmark_file_get_size(&this);
848 // VERSION: 2.12
849 // Returns the title of the bookmark for @uri.
851 // If @uri is %NULL, the title of @bookmark is returned.
853 // In the event the URI cannot be found, %NULL is returned and
854 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
856 // URI cannot be found.
857 // RETURNS: a newly allocated string or %NULL if the specified
858 // <uri>: a valid URI or %NULL
859 char* /*new*/ get_title()(char* uri, GLib2.Error** error=null) nothrow {
860 return g_bookmark_file_get_title(&this, uri, error);
863 // Unintrospectable method: get_uris() / g_bookmark_file_get_uris()
864 // VERSION: 2.12
865 // Returns all URIs of the bookmarks in the bookmark file @bookmark.
866 // The array of returned URIs will be %NULL-terminated, so @length may
867 // optionally be %NULL.
869 // Use g_strfreev() to free it.
870 // RETURNS: a newly allocated %NULL-terminated array of strings.
871 // <length>: return location for the number of returned URIs, or %NULL
872 char** get_uris()(size_t* length) nothrow {
873 return g_bookmark_file_get_uris(&this, length);
876 // VERSION: 2.12
877 // Gets the time the bookmark for @uri was last visited.
879 // In the event the URI cannot be found, -1 is returned and
880 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
881 // RETURNS: a timestamp.
882 // <uri>: a valid URI
883 time_t get_visited()(char* uri, GLib2.Error** error=null) nothrow {
884 return g_bookmark_file_get_visited(&this, uri, error);
887 // VERSION: 2.12
888 // Checks whether the bookmark for @uri inside @bookmark has been
889 // registered by application @name.
891 // In the event the URI cannot be found, %FALSE is returned and
892 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
893 // RETURNS: %TRUE if the application @name was found
894 // <uri>: a valid URI
895 // <name>: the name of the application
896 int has_application()(char* uri, char* name, GLib2.Error** error=null) nothrow {
897 return g_bookmark_file_has_application(&this, uri, name, error);
900 // VERSION: 2.12
901 // Checks whether @group appears in the list of groups to which
902 // the bookmark for @uri belongs to.
904 // In the event the URI cannot be found, %FALSE is returned and
905 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
906 // RETURNS: %TRUE if @group was found.
907 // <uri>: a valid URI
908 // <group>: the group name to be searched
909 int has_group()(char* uri, char* group, GLib2.Error** error=null) nothrow {
910 return g_bookmark_file_has_group(&this, uri, group, error);
913 // VERSION: 2.12
914 // Looks whether the desktop bookmark has an item with its URI set to @uri.
915 // RETURNS: %TRUE if @uri is inside @bookmark, %FALSE otherwise
916 // <uri>: a valid URI
917 int has_item()(char* uri) nothrow {
918 return g_bookmark_file_has_item(&this, uri);
921 // VERSION: 2.12
922 // Loads a bookmark file from memory into an empty #GBookmarkFile
923 // structure. If the object cannot be created then @error is set to a
924 // #GBookmarkFileError.
925 // RETURNS: %TRUE if a desktop bookmark could be loaded.
926 // <data>: desktop bookmarks loaded in memory
927 // <length>: the length of @data in bytes
928 int load_from_data()(char* data, size_t length, GLib2.Error** error=null) nothrow {
929 return g_bookmark_file_load_from_data(&this, data, length, error);
932 // VERSION: 2.12
933 // This function looks for a desktop bookmark file named @file in the
934 // paths returned from g_get_user_data_dir() and g_get_system_data_dirs(),
935 // loads the file into @bookmark and returns the file's full path in
936 // @full_path. If the file could not be loaded then an %error is
937 // set to either a #GFileError or #GBookmarkFileError.
938 // RETURNS: %TRUE if a key file could be loaded, %FALSE othewise
939 // <file>: a relative path to a filename to open and parse
940 // <full_path>: return location for a string containing the full path of the file, or %NULL
941 int load_from_data_dirs()(char* file, char** full_path, GLib2.Error** error=null) nothrow {
942 return g_bookmark_file_load_from_data_dirs(&this, file, full_path, error);
945 // VERSION: 2.12
946 // Loads a desktop bookmark file into an empty #GBookmarkFile structure.
947 // If the file could not be loaded then @error is set to either a #GFileError
948 // or #GBookmarkFileError.
949 // RETURNS: %TRUE if a desktop bookmark file could be loaded
950 // <filename>: the path of a filename to load, in the GLib file name encoding
951 int load_from_file()(char* filename, GLib2.Error** error=null) nothrow {
952 return g_bookmark_file_load_from_file(&this, filename, error);
955 // VERSION: 2.12
956 // Changes the URI of a bookmark item from @old_uri to @new_uri. Any
957 // existing bookmark for @new_uri will be overwritten. If @new_uri is
958 // %NULL, then the bookmark is removed.
960 // In the event the URI cannot be found, %FALSE is returned and
961 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
962 // RETURNS: %TRUE if the URI was successfully changed
963 // <old_uri>: a valid URI
964 // <new_uri>: a valid URI, or %NULL
965 int move_item()(char* old_uri, char* new_uri, GLib2.Error** error=null) nothrow {
966 return g_bookmark_file_move_item(&this, old_uri, new_uri, error);
969 // VERSION: 2.12
970 // Removes application registered with @name from the list of applications
971 // that have registered a bookmark for @uri inside @bookmark.
973 // In the event the URI cannot be found, %FALSE is returned and
974 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
975 // In the event that no application with name @app_name has registered
976 // a bookmark for @uri, %FALSE is returned and error is set to
977 // #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED.
978 // RETURNS: %TRUE if the application was successfully removed.
979 // <uri>: a valid URI
980 // <name>: the name of the application
981 int remove_application()(char* uri, char* name, GLib2.Error** error=null) nothrow {
982 return g_bookmark_file_remove_application(&this, uri, name, error);
985 // VERSION: 2.12
986 // Removes @group from the list of groups to which the bookmark
987 // for @uri belongs to.
989 // In the event the URI cannot be found, %FALSE is returned and
990 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
991 // In the event no group was defined, %FALSE is returned and
992 // @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
993 // RETURNS: %TRUE if @group was successfully removed.
994 // <uri>: a valid URI
995 // <group>: the group name to be removed
996 int remove_group()(char* uri, char* group, GLib2.Error** error=null) nothrow {
997 return g_bookmark_file_remove_group(&this, uri, group, error);
1000 // VERSION: 2.12
1001 // Removes the bookmark for @uri from the bookmark file @bookmark.
1002 // RETURNS: %TRUE if the bookmark was removed successfully.
1003 // <uri>: a valid URI
1004 int remove_item()(char* uri, GLib2.Error** error=null) nothrow {
1005 return g_bookmark_file_remove_item(&this, uri, error);
1008 // VERSION: 2.12
1009 // Sets the time the bookmark for @uri was added into @bookmark.
1011 // If no bookmark for @uri is found then it is created.
1012 // <uri>: a valid URI
1013 // <added>: a timestamp or -1 to use the current time
1014 void set_added()(char* uri, time_t added) nothrow {
1015 g_bookmark_file_set_added(&this, uri, added);
1018 // VERSION: 2.12
1019 // Sets the meta-data of application @name inside the list of
1020 // applications that have registered a bookmark for @uri inside
1021 // @bookmark.
1023 // You should rarely use this function; use g_bookmark_file_add_application()
1024 // and g_bookmark_file_remove_application() instead.
1026 // @name can be any UTF-8 encoded string used to identify an
1027 // application.
1028 // be expanded as the local file name retrieved from the bookmark's
1029 // URI; "\%u", which will be expanded as the bookmark's URI.
1030 // The expansion is done automatically when retrieving the stored
1031 // command line using the g_bookmark_file_get_app_info() function.
1032 // @count is the number of times the application has registered the
1033 // bookmark; if is < 0, the current registration count will be increased
1034 // by one, if is 0, the application with @name will be removed from
1035 // the list of registered applications.
1036 // @stamp is the Unix time of the last registration; if it is -1, the
1037 // current time will be used.
1039 // If you try to remove an application by setting its registration count to
1040 // zero, and no bookmark for @uri is found, %FALSE is returned and
1041 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND; similarly,
1042 // in the event that no application @name has registered a bookmark
1043 // for @uri, %FALSE is returned and error is set to
1044 // #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. Otherwise, if no bookmark
1045 // for @uri is found, one is created.
1047 // changed.
1048 // RETURNS: %TRUE if the application's meta-data was successfully
1049 // <uri>: a valid URI
1050 // <name>: an application's name
1051 // <exec>: an application's command line
1052 // <count>: the number of registrations done for this application
1053 // <stamp>: the time of the last registration for this application
1054 int set_app_info()(char* uri, char* name, char* exec, int count, time_t stamp, GLib2.Error** error=null) nothrow {
1055 return g_bookmark_file_set_app_info(&this, uri, name, exec, count, stamp, error);
1058 // VERSION: 2.12
1059 // Sets @description as the description of the bookmark for @uri.
1061 // If @uri is %NULL, the description of @bookmark is set.
1063 // If a bookmark for @uri cannot be found then it is created.
1064 // <uri>: a valid URI or %NULL
1065 // <description>: a string
1066 void set_description()(char* uri, char* description) nothrow {
1067 g_bookmark_file_set_description(&this, uri, description);
1070 // VERSION: 2.12
1071 // Sets a list of group names for the item with URI @uri. Each previously
1072 // set group name list is removed.
1074 // If @uri cannot be found then an item for it is created.
1075 // <uri>: an item's URI
1076 // <groups>: an array of group names, or %NULL to remove all groups
1077 // <length>: number of group name values in @groups
1078 void set_groups()(char* uri, char** groups, size_t length) nothrow {
1079 g_bookmark_file_set_groups(&this, uri, groups, length);
1082 // VERSION: 2.12
1083 // Sets the icon for the bookmark for @uri. If @href is %NULL, unsets
1084 // the currently set icon. @href can either be a full URL for the icon
1085 // file or the icon name following the Icon Naming specification.
1087 // If no bookmark for @uri is found one is created.
1088 // <uri>: a valid URI
1089 // <href>: the URI of the icon for the bookmark, or %NULL
1090 // <mime_type>: the MIME type of the icon for the bookmark
1091 void set_icon()(char* uri, char* href, char* mime_type) nothrow {
1092 g_bookmark_file_set_icon(&this, uri, href, mime_type);
1095 // VERSION: 2.12
1096 // Sets the private flag of the bookmark for @uri.
1098 // If a bookmark for @uri cannot be found then it is created.
1099 // <uri>: a valid URI
1100 // <is_private>: %TRUE if the bookmark should be marked as private
1101 void set_is_private()(char* uri, int is_private) nothrow {
1102 g_bookmark_file_set_is_private(&this, uri, is_private);
1105 // VERSION: 2.12
1106 // Sets @mime_type as the MIME type of the bookmark for @uri.
1108 // If a bookmark for @uri cannot be found then it is created.
1109 // <uri>: a valid URI
1110 // <mime_type>: a MIME type
1111 void set_mime_type()(char* uri, char* mime_type) nothrow {
1112 g_bookmark_file_set_mime_type(&this, uri, mime_type);
1115 // VERSION: 2.12
1116 // Sets the last time the bookmark for @uri was last modified.
1118 // If no bookmark for @uri is found then it is created.
1120 // The "modified" time should only be set when the bookmark's meta-data
1121 // was actually changed. Every function of #GBookmarkFile that
1122 // modifies a bookmark also changes the modification time, except for
1123 // g_bookmark_file_set_visited().
1124 // <uri>: a valid URI
1125 // <modified>: a timestamp or -1 to use the current time
1126 void set_modified()(char* uri, time_t modified) nothrow {
1127 g_bookmark_file_set_modified(&this, uri, modified);
1130 // VERSION: 2.12
1131 // Sets @title as the title of the bookmark for @uri inside the
1132 // bookmark file @bookmark.
1134 // If @uri is %NULL, the title of @bookmark is set.
1136 // If a bookmark for @uri cannot be found then it is created.
1137 // <uri>: a valid URI or %NULL
1138 // <title>: a UTF-8 encoded string
1139 void set_title()(char* uri, char* title) nothrow {
1140 g_bookmark_file_set_title(&this, uri, title);
1143 // VERSION: 2.12
1144 // Sets the time the bookmark for @uri was last visited.
1146 // If no bookmark for @uri is found then it is created.
1148 // The "visited" time should only be set if the bookmark was launched,
1149 // either using the command line retrieved by g_bookmark_file_get_app_info()
1150 // or by the default application for the bookmark's MIME type, retrieved
1151 // using g_bookmark_file_get_mime_type(). Changing the "visited" time
1152 // does not affect the "modified" time.
1153 // <uri>: a valid URI
1154 // <visited>: a timestamp or -1 to use the current time
1155 void set_visited()(char* uri, time_t visited) nothrow {
1156 g_bookmark_file_set_visited(&this, uri, visited);
1159 // VERSION: 2.12
1160 // This function outputs @bookmark as a string.
1162 // the contents of the #GBookmarkFile
1163 // RETURNS: a newly allocated string holding
1164 // <length>: return location for the length of the returned string, or %NULL
1165 char* /*new*/ to_data()(size_t* length, GLib2.Error** error=null) nothrow {
1166 return g_bookmark_file_to_data(&this, length, error);
1169 // VERSION: 2.12
1170 // This function outputs @bookmark into a file. The write process is
1171 // guaranteed to be atomic by using g_file_set_contents() internally.
1172 // RETURNS: %TRUE if the file was successfully written.
1173 // <filename>: path of the output file
1174 int to_file()(char* filename, GLib2.Error** error=null) nothrow {
1175 return g_bookmark_file_to_file(&this, filename, error);
1177 static Quark error_quark()() nothrow {
1178 return g_bookmark_file_error_quark();
1181 // Unintrospectable function: new() / g_bookmark_file_new()
1182 // VERSION: 2.12
1183 // Creates a new empty #GBookmarkFile object.
1185 // Use g_bookmark_file_load_from_file(), g_bookmark_file_load_from_data()
1186 // or g_bookmark_file_load_from_data_dirs() to read an existing bookmark
1187 // file.
1188 // RETURNS: an empty #GBookmarkFile
1189 static BookmarkFile* new_()() nothrow {
1190 return g_bookmark_file_new();
1194 // Error codes returned by bookmark file parsing.
1195 enum BookmarkFileError {
1196 INVALID_URI = 0,
1197 INVALID_VALUE = 1,
1198 APP_NOT_REGISTERED = 2,
1199 URI_NOT_FOUND = 3,
1200 READ = 4,
1201 UNKNOWN_ENCODING = 5,
1202 WRITE = 6,
1203 FILE_NOT_FOUND = 7
1206 // The <structname>GByteArray</structname> struct allows access to the
1207 // public fields of a <structname>GByteArray</structname>.
1208 struct ByteArray {
1209 ubyte* data;
1210 uint len;
1213 // Unintrospectable function: append() / g_byte_array_append()
1214 // Adds the given bytes to the end of the #GByteArray. The array will
1215 // grow in size automatically if necessary.
1216 // <array>: a #GByteArray.
1217 // <data>: the byte data to be added.
1218 // <len>: the number of bytes to add.
1219 static ByteArray* append()(ByteArray* array, ubyte* data, uint len) nothrow {
1220 return g_byte_array_append(array, data, len);
1223 // Frees the memory allocated by the #GByteArray. If @free_segment is
1224 // %TRUE it frees the actual byte data. If the reference count of
1225 // @array is greater than one, the #GByteArray wrapper is preserved but
1226 // the size of @array will be set to zero.
1227 // <array>: a #GByteArray.
1228 // <free_segment>: if %TRUE the actual byte data is freed as well.
1229 static ubyte* free()(ByteArray* array, int free_segment) nothrow {
1230 return g_byte_array_free(array, free_segment);
1233 // VERSION: 2.32
1234 // Transfers the data from the #GByteArray into a new immutable #GBytes.
1236 // The #GByteArray is freed unless the reference count of @array is greater
1237 // than one, the #GByteArray wrapper is preserved but the size of @array
1238 // will be set to zero.
1240 // This is identical to using g_bytes_new_take() and g_byte_array_free()
1241 // together.
1244 // data that was in the array
1245 // RETURNS: a new immutable #GBytes representing same byte
1246 // <array>: a #GByteArray
1247 static Bytes* /*new*/ free_to_bytes()(ByteArray* array) nothrow {
1248 return g_byte_array_free_to_bytes(array);
1251 // Unintrospectable function: new() / g_byte_array_new()
1252 // Creates a new #GByteArray with a reference count of 1.
1253 static ByteArray* new_()() nothrow {
1254 return g_byte_array_new();
1257 // VERSION: 2.32
1258 // Create byte array containing the data. The data will be owned by the array
1259 // and will be freed with g_free(), i.e. it could be allocated using g_strdup().
1260 // RETURNS: a new #GByteArray
1261 // <data>: byte data for the array
1262 // <len>: length of @data
1263 static ByteArray* /*new*/ new_take()(ubyte* data, size_t len) nothrow {
1264 return g_byte_array_new_take(data, len);
1267 // Unintrospectable function: prepend() / g_byte_array_prepend()
1268 // Adds the given data to the start of the #GByteArray. The array will
1269 // grow in size automatically if necessary.
1270 // <array>: a #GByteArray.
1271 // <data>: the byte data to be added.
1272 // <len>: the number of bytes to add.
1273 static ByteArray* prepend()(ByteArray* array, ubyte* data, uint len) nothrow {
1274 return g_byte_array_prepend(array, data, len);
1277 // Unintrospectable function: ref() / g_byte_array_ref()
1278 // VERSION: 2.22
1279 // Atomically increments the reference count of @array by one. This
1280 // function is MT-safe and may be called from any thread.
1281 // RETURNS: The passed in #GByteArray.
1282 // <array>: A #GByteArray.
1283 static ByteArray* ref_()(ByteArray* array) nothrow {
1284 return g_byte_array_ref(array);
1287 // Unintrospectable function: remove_index() / g_byte_array_remove_index()
1288 // Removes the byte at the given index from a #GByteArray. The
1289 // following bytes are moved down one place.
1290 // <array>: a #GByteArray.
1291 // <index_>: the index of the byte to remove.
1292 static ByteArray* remove_index()(ByteArray* array, uint index_) nothrow {
1293 return g_byte_array_remove_index(array, index_);
1296 // Unintrospectable function: remove_index_fast() / g_byte_array_remove_index_fast()
1297 // Removes the byte at the given index from a #GByteArray. The last
1298 // element in the array is used to fill in the space, so this function
1299 // does not preserve the order of the #GByteArray. But it is faster
1300 // than g_byte_array_remove_index().
1301 // <array>: a #GByteArray.
1302 // <index_>: the index of the byte to remove.
1303 static ByteArray* remove_index_fast()(ByteArray* array, uint index_) nothrow {
1304 return g_byte_array_remove_index_fast(array, index_);
1307 // Unintrospectable function: remove_range() / g_byte_array_remove_range()
1308 // VERSION: 2.4
1309 // Removes the given number of bytes starting at the given index from a
1310 // #GByteArray. The following elements are moved to close the gap.
1311 // <array>: a @GByteArray.
1312 // <index_>: the index of the first byte to remove.
1313 // <length>: the number of bytes to remove.
1314 static ByteArray* remove_range()(ByteArray* array, uint index_, uint length) nothrow {
1315 return g_byte_array_remove_range(array, index_, length);
1318 // Unintrospectable function: set_size() / g_byte_array_set_size()
1319 // Sets the size of the #GByteArray, expanding it if necessary.
1320 // <array>: a #GByteArray.
1321 // <length>: the new size of the #GByteArray.
1322 static ByteArray* set_size()(ByteArray* array, uint length) nothrow {
1323 return g_byte_array_set_size(array, length);
1326 // Unintrospectable function: sized_new() / g_byte_array_sized_new()
1327 // Creates a new #GByteArray with @reserved_size bytes preallocated.
1328 // This avoids frequent reallocation, if you are going to add many
1329 // bytes to the array. Note however that the size of the array is still
1330 // 0.
1331 // <reserved_size>: number of bytes preallocated.
1332 static ByteArray* sized_new()(uint reserved_size) nothrow {
1333 return g_byte_array_sized_new(reserved_size);
1336 // Unintrospectable function: sort() / g_byte_array_sort()
1337 // Sorts a byte array, using @compare_func which should be a
1338 // qsort()-style comparison function (returns less than zero for first
1339 // arg is less than second arg, zero for equal, greater than zero if
1340 // first arg is greater than second arg).
1342 // If two array elements compare equal, their order in the sorted array
1343 // is undefined. If you want equal elements to keep their order (i.e.
1344 // you want a stable sort) you can write a comparison function that,
1345 // if two elements would otherwise compare equal, compares them by
1346 // their addresses.
1347 // <array>: a #GByteArray.
1348 // <compare_func>: comparison function.
1349 static void sort()(ByteArray* array, CompareFunc compare_func) nothrow {
1350 g_byte_array_sort(array, compare_func);
1353 // Unintrospectable function: sort_with_data() / g_byte_array_sort_with_data()
1354 // Like g_byte_array_sort(), but the comparison function takes an extra
1355 // user data argument.
1356 // <array>: a #GByteArray.
1357 // <compare_func>: comparison function.
1358 // <user_data>: data to pass to @compare_func.
1359 static void sort_with_data()(ByteArray* array, CompareDataFunc compare_func, void* user_data) nothrow {
1360 g_byte_array_sort_with_data(array, compare_func, user_data);
1363 // VERSION: 2.22
1364 // Atomically decrements the reference count of @array by one. If the
1365 // reference count drops to 0, all memory allocated by the array is
1366 // released. This function is MT-safe and may be called from any
1367 // thread.
1368 // <array>: A #GByteArray.
1369 static void unref()(ByteArray* array) nothrow {
1370 g_byte_array_unref(array);
1375 // A simple refcounted data type representing an immutable byte sequence
1376 // from an unspecified origin.
1378 // The purpose of a #GBytes is to keep the memory region that it holds
1379 // alive for as long as anyone holds a reference to the bytes. When
1380 // the last reference count is dropped, the memory is released. Multiple
1381 // unrelated callers can use byte data in the #GBytes without coordinating
1382 // their activities, resting assured that the byte data will not change or
1383 // move while they hold a reference.
1385 // A #GBytes can come from many different origins that may have
1386 // different procedures for freeing the memory region. Examples are
1387 // memory from g_malloc(), from memory slices, from a #GMappedFile or
1388 // memory from other allocators.
1390 // #GBytes work well as keys in #GHashTable. Use g_bytes_equal() and
1391 // g_bytes_hash() as parameters to g_hash_table_new() or g_hash_table_new_full().
1392 // #GBytes can also be used as keys in a #GTree by passing the g_bytes_compare()
1393 // function to g_tree_new().
1395 // The data pointed to by this bytes must not be modified. For a mutable
1396 // array of bytes see #GByteArray. Use g_bytes_unref_to_array() to create a
1397 // mutable array for a #GBytes sequence. To create an immutable #GBytes from
1398 // a mutable #GByteArray, use the g_byte_array_free_to_bytes() function.
1399 struct Bytes /* Version 2.32 */ {
1401 // VERSION: 2.32
1402 // Creates a new #GBytes from @data.
1404 // @data is copied.
1405 // RETURNS: a new #GBytes
1406 // <data>: the data to be used for the bytes
1407 // <size>: the size of @data
1408 static Bytes* /*new*/ new_()(const(void)* data, size_t size) nothrow {
1409 return g_bytes_new(data, size);
1411 alias new_!() opCall;
1413 // VERSION: 2.32
1414 // Creates a new #GBytes from static data.
1415 // RETURNS: a new #GBytes
1416 // <data>: the data to be used for the bytes
1417 // <size>: the size of @data
1418 static Bytes* /*new*/ new_static()(const(void)* data, size_t size) nothrow {
1419 return g_bytes_new_static(data, size);
1421 alias new_static!() opCall;
1423 // VERSION: 2.32
1424 // Creates a new #GBytes from @data.
1426 // After this call, @data belongs to the bytes and may no longer be
1427 // modified by the caller. g_free() will be called on @data when the
1428 // bytes is no longer in use. Because of this @data must have been created by
1429 // a call to g_malloc(), g_malloc0() or g_realloc() or by one of the many
1430 // functions that wrap these calls (such as g_new(), g_strdup(), etc).
1432 // For creating #GBytes with memory from other allocators, see
1433 // g_bytes_new_with_free_func().
1434 // RETURNS: a new #GBytes
1435 // <data>: the data to be used for the bytes
1436 // <size>: the size of @data
1437 static Bytes* /*new*/ new_take()(void* data, size_t size) nothrow {
1438 return g_bytes_new_take(data, size);
1440 alias new_take!() opCall;
1442 // VERSION: 2.32
1443 // Creates a #GBytes from @data.
1445 // When the last reference is dropped, @free_func will be called with the
1446 // @user_data argument.
1448 // @data must not be modified after this call is made until @free_func has
1449 // been called to indicate that the bytes is no longer in use.
1450 // RETURNS: a new #GBytes
1451 // <data>: the data to be used for the bytes
1452 // <size>: the size of @data
1453 // <free_func>: the function to call to release the data
1454 // <user_data>: data to pass to @free_func
1455 static Bytes* /*new*/ new_with_free_func()(const(void)* data, size_t size, DestroyNotify free_func, void* user_data) nothrow {
1456 return g_bytes_new_with_free_func(data, size, free_func, user_data);
1458 alias new_with_free_func!() opCall;
1460 // VERSION: 2.32
1461 // Compares the two #GBytes values.
1463 // This function can be used to sort GBytes instances in lexographical order.
1465 // greater, and zero if bytes2 is equal to bytes1
1466 // RETURNS: a negative value if bytes2 is lesser, a positive value if bytes2 is
1467 // <bytes2>: a pointer to a #GBytes to compare with @bytes1
1468 int compare()(const(Bytes)* bytes2) nothrow {
1469 return g_bytes_compare(&this, bytes2);
1472 // VERSION: 2.32
1473 // Compares the two #GBytes values being pointed to and returns
1474 // %TRUE if they are equal.
1476 // This function can be passed to g_hash_table_new() as the @key_equal_func
1477 // parameter, when using non-%NULL #GBytes pointers as keys in a #GHashTable.
1478 // RETURNS: %TRUE if the two keys match.
1479 // <bytes2>: a pointer to a #GBytes to compare with @bytes1
1480 int equal()(const(Bytes)* bytes2) nothrow {
1481 return g_bytes_equal(&this, bytes2);
1484 // Unintrospectable method: get_data() / g_bytes_get_data()
1485 // VERSION: 2.32
1486 // Get the byte data in the #GBytes. This data should not be modified.
1488 // This function will always return the same pointer for a given #GBytes.
1489 // RETURNS: a pointer to the byte data
1490 // <size>: location to return size of byte data
1491 const(ubyte)* get_data()(/*out*/ size_t* size=null) nothrow {
1492 return g_bytes_get_data(&this, size);
1495 // VERSION: 2.32
1496 // Get the size of the byte data in the #GBytes.
1498 // This function will always return the same value for a given #GBytes.
1499 // RETURNS: the size
1500 size_t get_size()() nothrow {
1501 return g_bytes_get_size(&this);
1504 // VERSION: 2.32
1505 // Creates an integer hash code for the byte data in the #GBytes.
1507 // This function can be passed to g_hash_table_new() as the @key_equal_func
1508 // parameter, when using non-%NULL #GBytes pointers as keys in a #GHashTable.
1509 // RETURNS: a hash value corresponding to the key.
1510 uint hash()() nothrow {
1511 return g_bytes_hash(&this);
1514 // VERSION: 2.32
1515 // Creates a #GBytes which is a subsection of another #GBytes. The @offset +
1516 // @length may not be longer than the size of @bytes.
1518 // A reference to @bytes will be held by the newly created #GBytes until
1519 // the byte data is no longer needed.
1520 // RETURNS: a new #GBytes
1521 // <offset>: offset which subsection starts at
1522 // <length>: length of subsection
1523 Bytes* /*new*/ new_from_bytes()(size_t offset, size_t length) nothrow {
1524 return g_bytes_new_from_bytes(&this, offset, length);
1527 // VERSION: 2.32
1528 // Increase the reference count on @bytes.
1529 // RETURNS: the #GBytes
1530 Bytes* /*new*/ ref_()() nothrow {
1531 return g_bytes_ref(&this);
1534 // VERSION: 2.32
1535 // Releases a reference on @bytes. This may result in the bytes being
1536 // freed.
1537 void unref()() nothrow {
1538 g_bytes_unref(&this);
1541 // VERSION: 2.32
1542 // Unreferences the bytes, and returns a new mutable #GByteArray containing
1543 // the same byte data.
1545 // As an optimization, the byte data is transferred to the array without copying
1546 // if this was the last reference to bytes and bytes was created with
1547 // g_bytes_new(), g_bytes_new_take() or g_byte_array_free_to_bytes(). In all
1548 // other cases the data is copied.
1549 // RETURNS: a new mutable #GByteArray containing the same byte data
1550 ByteArray* /*new*/ unref_to_array()() nothrow {
1551 return g_bytes_unref_to_array(&this);
1554 // VERSION: 2.32
1555 // Unreferences the bytes, and returns a pointer the same byte data
1556 // contents.
1558 // As an optimization, the byte data is returned without copying if this was
1559 // the last reference to bytes and bytes was created with g_bytes_new(),
1560 // g_bytes_new_take() or g_byte_array_free_to_bytes(). In all other cases the
1561 // data is copied.
1563 // be freed with g_free()
1564 // RETURNS: a pointer to the same byte data, which should
1565 // <size>: location to place the length of the returned data
1566 void* /*new*/ unref_to_data()(size_t* size) nothrow {
1567 return g_bytes_unref_to_data(&this, size);
1571 enum int CAN_INLINE = 1;
1572 enum CSET_A_2_Z = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
1573 enum CSET_DIGITS = "0123456789";
1574 enum CSET_a_2_z = "abcdefghijklmnopqrstuvwxyz";
1576 // An opaque structure representing a checksumming operation.
1577 // To create a new GChecksum, use g_checksum_new(). To free
1578 // a GChecksum, use g_checksum_free().
1579 struct Checksum /* Version 2.16 */ {
1581 // Unintrospectable method: copy() / g_checksum_copy()
1582 // VERSION: 2.16
1583 // Copies a #GChecksum. If @checksum has been closed, by calling
1584 // g_checksum_get_string() or g_checksum_get_digest(), the copied
1585 // checksum will be closed as well.
1587 // when finished using it.
1588 // RETURNS: the copy of the passed #GChecksum. Use g_checksum_free()
1589 Checksum* copy()() nothrow {
1590 return g_checksum_copy(&this);
1593 // VERSION: 2.16
1594 // Frees the memory allocated for @checksum.
1595 void free()() nothrow {
1596 g_checksum_free(&this);
1599 // VERSION: 2.16
1600 // Gets the digest from @checksum as a raw binary vector and places it
1601 // into @buffer. The size of the digest depends on the type of checksum.
1603 // Once this function has been called, the #GChecksum is closed and can
1604 // no longer be updated with g_checksum_update().
1605 // <buffer>: output buffer
1606 // <digest_len>: an inout parameter. The caller initializes it to the size of @buffer. After the call it contains the length of the digest.
1607 void get_digest()(ubyte* buffer, size_t* digest_len) nothrow {
1608 g_checksum_get_digest(&this, buffer, digest_len);
1611 // VERSION: 2.16
1612 // Gets the digest as an hexadecimal string.
1614 // Once this function has been called the #GChecksum can no longer be
1615 // updated with g_checksum_update().
1617 // The hexadecimal characters will be lower case.
1619 // returned string is owned by the checksum and should not be modified
1620 // or freed.
1621 // RETURNS: the hexadecimal representation of the checksum. The
1622 char* get_string()() nothrow {
1623 return g_checksum_get_string(&this);
1626 // VERSION: 2.18
1627 // Resets the state of the @checksum back to its initial state.
1628 void reset()() nothrow {
1629 g_checksum_reset(&this);
1632 // VERSION: 2.16
1633 // Feeds @data into an existing #GChecksum. The checksum must still be
1634 // open, that is g_checksum_get_string() or g_checksum_get_digest() must
1635 // not have been called on @checksum.
1636 // <data>: buffer used to compute the checksum
1637 // <length>: size of the buffer, or -1 if it is a null-terminated string.
1638 void update()(ubyte* data, ssize_t length) nothrow {
1639 g_checksum_update(&this, data, length);
1642 // Unintrospectable function: new() / g_checksum_new()
1643 // VERSION: 2.16
1644 // Creates a new #GChecksum, using the checksum algorithm @checksum_type.
1645 // If the @checksum_type is not known, %NULL is returned.
1646 // A #GChecksum can be used to compute the checksum, or digest, of an
1647 // arbitrary binary blob, using different hashing algorithms.
1649 // A #GChecksum works by feeding a binary blob through g_checksum_update()
1650 // until there is data to be checked; the digest can then be extracted
1651 // using g_checksum_get_string(), which will return the checksum as a
1652 // hexadecimal string; or g_checksum_get_digest(), which will return a
1653 // vector of raw bytes. Once either g_checksum_get_string() or
1654 // g_checksum_get_digest() have been called on a #GChecksum, the checksum
1655 // will be closed and it won't be possible to call g_checksum_update()
1656 // on it anymore.
1658 // Use g_checksum_free() to free the memory allocated by it.
1659 // RETURNS: the newly created #GChecksum, or %NULL.
1660 // <checksum_type>: the desired type of checksum
1661 static Checksum* new_()(ChecksumType checksum_type) nothrow {
1662 return g_checksum_new(checksum_type);
1665 // VERSION: 2.16
1666 // Gets the length in bytes of digests of type @checksum_type
1668 // not supported.
1669 // RETURNS: the checksum length, or -1 if @checksum_type is
1670 // <checksum_type>: a #GChecksumType
1671 static ssize_t type_get_length()(ChecksumType checksum_type) nothrow {
1672 return g_checksum_type_get_length(checksum_type);
1677 // The hashing algorithm to be used by #GChecksum when performing the
1678 // digest of some data.
1680 // Note that the #GChecksumType enumeration may be extended at a later
1681 // date to include new hashing algorithm types.
1682 enum ChecksumType /* Version 2.16 */ {
1683 MD5 = 0,
1684 SHA1 = 1,
1685 SHA256 = 2
1688 // The type of functions to be called when a child exists.
1689 // <pid>: the process id of the child process
1690 // <status>: Status information about the child process, see waitpid(2) for more information about this field
1691 // <user_data>: user data passed to g_child_watch_add()
1692 extern (C) alias void function (Pid pid, int status, void* user_data) nothrow ChildWatchFunc;
1695 // Specifies the type of a comparison function used to compare two
1696 // values. The function should return a negative integer if the first
1697 // value comes before the second, 0 if they are equal, or a positive
1698 // integer if the first value comes after the second.
1699 // <a>: a value.
1700 // <b>: a value to compare with.
1701 // <user_data>: user data to pass to comparison function.
1702 extern (C) alias int function (const(void)* a, const(void)* b, void* user_data) nothrow CompareDataFunc;
1705 // Specifies the type of a comparison function used to compare two
1706 // values. The function should return a negative integer if the first
1707 // value comes before the second, 0 if they are equal, or a positive
1708 // integer if the first value comes after the second.
1709 // <a>: a value.
1710 // <b>: a value to compare with.
1711 extern (C) alias int function (const(void)* a, const(void)* b) nothrow CompareFunc;
1714 // The #GCond struct is an opaque data structure that represents a
1715 // condition. Threads can block on a #GCond if they find a certain
1716 // condition to be false. If other threads change the state of this
1717 // condition they signal the #GCond, and that causes the waiting
1718 // threads to be woken up.
1720 // Consider the following example of a shared variable. One or more
1721 // threads can wait for data to be published to the variable and when
1722 // another thread publishes the data, it can signal one of the waiting
1723 // threads to wake up to collect the data.
1725 // <example>
1726 // <title>
1727 // Using GCond to block a thread until a condition is satisfied
1728 // </title>
1729 // <programlisting>
1730 // gpointer current_data = NULL;
1731 // GMutex data_mutex;
1732 // GCond data_cond;
1734 // void
1735 // push_data (gpointer data)
1736 // {
1737 // g_mutex_lock (&data_mutex);
1738 // current_data = data;
1739 // g_cond_signal (&data_cond);
1740 // g_mutex_unlock (&data_mutex);
1741 // }
1743 // gpointer
1744 // pop_data (void)
1745 // {
1746 // gpointer data;
1748 // g_mutex_lock (&data_mutex);
1749 // while (!current_data)
1750 // g_cond_wait (&data_cond, &data_mutex);
1751 // data = current_data;
1752 // current_data = NULL;
1753 // g_mutex_unlock (&data_mutex);
1755 // return data;
1756 // }
1757 // </programlisting>
1758 // </example>
1760 // Whenever a thread calls pop_data() now, it will wait until
1761 // current_data is non-%NULL, i.e. until some other thread
1762 // has called push_data().
1764 // The example shows that use of a condition variable must always be
1765 // paired with a mutex. Without the use of a mutex, there would be a
1766 // race between the check of <varname>current_data</varname> by the
1767 // while loop in <function>pop_data</function> and waiting.
1768 // Specifically, another thread could set <varname>pop_data</varname>
1769 // after the check, and signal the cond (with nobody waiting on it)
1770 // before the first thread goes to sleep. #GCond is specifically useful
1771 // for its ability to release the mutex and go to sleep atomically.
1773 // It is also important to use the g_cond_wait() and g_cond_wait_until()
1774 // functions only inside a loop which checks for the condition to be
1775 // true. See g_cond_wait() for an explanation of why the condition may
1776 // not be true even after it returns.
1778 // If a #GCond is allocated in static storage then it can be used
1779 // without initialisation. Otherwise, you should call g_cond_init() on
1780 // it and g_cond_clear() when done.
1782 // A #GCond should only be accessed via the <function>g_cond_</function>
1783 // functions.
1784 struct Cond {
1785 private void* p;
1786 private uint[2] i;
1789 // If threads are waiting for @cond, all of them are unblocked.
1790 // If no threads are waiting for @cond, this function has no effect.
1791 // It is good practice to lock the same mutex as the waiting threads
1792 // while calling this function, though not required.
1793 void broadcast()() nothrow {
1794 g_cond_broadcast(&this);
1797 // VERSION: 2.32
1798 // Frees the resources allocated to a #GCond with g_cond_init().
1800 // This function should not be used with a #GCond that has been
1801 // statically allocated.
1803 // Calling g_cond_clear() for a #GCond on which threads are
1804 // blocking leads to undefined behaviour.
1805 void clear()() nothrow {
1806 g_cond_clear(&this);
1809 // VERSION: 2.32
1810 // Initialises a #GCond so that it can be used.
1812 // This function is useful to initialise a #GCond that has been
1813 // allocated as part of a larger structure. It is not necessary to
1814 // initialise a #GCond that has been statically allocated.
1816 // To undo the effect of g_cond_init() when a #GCond is no longer
1817 // needed, use g_cond_clear().
1819 // Calling g_cond_init() on an already-initialised #GCond leads
1820 // to undefined behaviour.
1821 void init()() nothrow {
1822 g_cond_init(&this);
1825 // If threads are waiting for @cond, at least one of them is unblocked.
1826 // If no threads are waiting for @cond, this function has no effect.
1827 // It is good practice to hold the same lock as the waiting thread
1828 // while calling this function, though not required.
1829 void signal()() nothrow {
1830 g_cond_signal(&this);
1833 // Atomically releases @mutex and waits until @cond is signalled.
1835 // When using condition variables, it is possible that a spurious wakeup
1836 // may occur (ie: g_cond_wait() returns even though g_cond_signal() was
1837 // not called). It's also possible that a stolen wakeup may occur.
1838 // This is when g_cond_signal() is called, but another thread acquires
1839 // @mutex before this thread and modifies the state of the program in
1840 // such a way that when g_cond_wait() is able to return, the expected
1841 // condition is no longer met.
1843 // For this reason, g_cond_wait() must always be used in a loop. See
1844 // the documentation for #GCond for a complete example.
1845 // <mutex>: a #GMutex that is currently locked
1846 void wait()(Mutex* mutex) nothrow {
1847 g_cond_wait(&this, mutex);
1850 // VERSION: 2.32
1851 // Waits until either @cond is signalled or @end_time has passed.
1853 // As with g_cond_wait() it is possible that a spurious or stolen wakeup
1854 // could occur. For that reason, waiting on a condition variable should
1855 // always be in a loop, based on an explicitly-checked predicate.
1857 // %TRUE is returned if the condition variable was signalled (or in the
1858 // case of a spurious wakeup). %FALSE is returned if @end_time has
1859 // passed.
1861 // The following code shows how to correctly perform a timed wait on a
1862 // condition variable (extended the example presented in the
1863 // documentation for #GCond):
1865 // |[
1866 // gpointer
1867 // pop_data_timed (void)
1868 // {
1869 // gint64 end_time;
1870 // gpointer data;
1872 // g_mutex_lock (&data_mutex);
1874 // end_time = g_get_monotonic_time () + 5 * G_TIME_SPAN_SECOND;
1875 // while (!current_data)
1876 // if (!g_cond_wait_until (&data_cond, &data_mutex, end_time))
1877 // {
1878 // // timeout has passed.
1879 // g_mutex_unlock (&data_mutex);
1880 // return NULL;
1881 // }
1883 // // there is data for us
1884 // data = current_data;
1885 // current_data = NULL;
1887 // g_mutex_unlock (&data_mutex);
1889 // return data;
1890 // }
1891 // ]|
1893 // Notice that the end time is calculated once, before entering the
1894 // loop and reused. This is the motivation behind the use of absolute
1895 // time on this API -- if a relative time of 5 seconds were passed
1896 // directly to the call and a spurious wakeup occured, the program would
1897 // have to start over waiting again (which would lead to a total wait
1898 // time of more than 5 seconds).
1899 // RETURNS: %TRUE on a signal, %FALSE on a timeout
1900 // <mutex>: a #GMutex that is currently locked
1901 // <end_time>: the monotonic time to wait until
1902 int wait_until()(Mutex* mutex, long end_time) nothrow {
1903 return g_cond_wait_until(&this, mutex, end_time);
1907 // Error codes returned by character set conversion routines.
1908 enum ConvertError {
1909 NO_CONVERSION = 0,
1910 ILLEGAL_SEQUENCE = 1,
1911 FAILED = 2,
1912 PARTIAL_INPUT = 3,
1913 BAD_URI = 4,
1914 NOT_ABSOLUTE_PATH = 5
1917 // Unintrospectable callback: CopyFunc() / ()
1918 // VERSION: 2.4
1919 // A function of this signature is used to copy the node data
1920 // when doing a deep-copy of a tree.
1921 // RETURNS: A pointer to the copy
1922 // <src>: A pointer to the data which should be copied
1923 // <data>: Additional data
1924 extern (C) alias void* function (const(void)* src, void* data) nothrow CopyFunc;
1926 enum int DATALIST_FLAGS_MASK = 3;
1927 enum int DATE_BAD_DAY = 0;
1928 enum int DATE_BAD_JULIAN = 0;
1929 enum int DATE_BAD_YEAR = 0;
1930 enum int DIR_SEPARATOR = 92;
1931 enum DIR_SEPARATOR_S = "\\";
1933 // The #GData struct is an opaque data structure to represent a <link
1934 // linkend="glib-Keyed-Data-Lists">Keyed Data List</link>. It should
1935 // only be accessed via the following functions.
1936 struct Data {
1940 // Specifies the type of function passed to g_dataset_foreach(). It is
1941 // called with each #GQuark id and associated data element, together
1942 // with the @user_data parameter supplied to g_dataset_foreach().
1943 // <key_id>: the #GQuark id to identifying the data element.
1944 // <data>: the data element.
1945 // <user_data>: user data passed to g_dataset_foreach().
1946 extern (C) alias void function (Quark key_id, void* data, void* user_data) nothrow DataForeachFunc;
1949 // Represents a day between January 1, Year 1 and a few thousand years in
1950 // the future. None of its members should be accessed directly. If the
1951 // <structname>GDate</structname> is obtained from g_date_new(), it will
1952 // be safe to mutate but invalid and thus not safe for calendrical
1953 // computations. If it's declared on the stack, it will contain garbage
1954 // so must be initialized with g_date_clear(). g_date_clear() makes the
1955 // date invalid but sane. An invalid date doesn't represent a day, it's
1956 // "empty." A date becomes valid after you set it to a Julian day or you
1957 // set a day, month, and year.
1958 struct Date {
1959 static import std.bitmanip; mixin(std.bitmanip.bitfields!(
1960 uint, "julian_days", 32,
1961 uint, "julian", 1,
1962 uint, "dmy", 1,
1963 uint, "day", 6,
1964 uint, "month", 4,
1965 uint, "year", 16,
1966 uint, "__dummy64A", 4));
1969 // Allocates a #GDate and initializes
1970 // it to a sane state. The new date will
1971 // be cleared (as if you'd called g_date_clear()) but invalid (it won't
1972 // represent an existing day). Free the return value with g_date_free().
1973 // RETURNS: a newly-allocated #GDate
1974 static Date* /*new*/ new_()() nothrow {
1975 return g_date_new();
1977 alias new_!() opCall;
1979 // Like g_date_new(), but also sets the value of the date. Assuming the
1980 // day-month-year triplet you pass in represents an existing day, the
1981 // returned date will be valid.
1982 // RETURNS: a newly-allocated #GDate initialized with @day, @month, and @year
1983 // <day>: day of the month
1984 // <month>: month of the year
1985 // <year>: year
1986 static Date* /*new*/ new_dmy()(DateDay day, DateMonth month, DateYear year) nothrow {
1987 return g_date_new_dmy(day, month, year);
1989 alias new_dmy!() opCall;
1991 // Like g_date_new(), but also sets the value of the date. Assuming the
1992 // Julian day number you pass in is valid (greater than 0, less than an
1993 // unreasonably large number), the returned date will be valid.
1994 // RETURNS: a newly-allocated #GDate initialized with @julian_day
1995 // <julian_day>: days since January 1, Year 1
1996 static Date* /*new*/ new_julian()(uint julian_day) nothrow {
1997 return g_date_new_julian(julian_day);
1999 alias new_julian!() opCall;
2001 // Increments a date some number of days.
2002 // To move forward by weeks, add weeks*7 days.
2003 // The date must be valid.
2004 // <n_days>: number of days to move the date forward
2005 void add_days()(uint n_days) nothrow {
2006 g_date_add_days(&this, n_days);
2009 // Increments a date by some number of months.
2010 // If the day of the month is greater than 28,
2011 // this routine may change the day of the month
2012 // (because the destination month may not have
2013 // the current day in it). The date must be valid.
2014 // <n_months>: number of months to move forward
2015 void add_months()(uint n_months) nothrow {
2016 g_date_add_months(&this, n_months);
2019 // Increments a date by some number of years.
2020 // If the date is February 29, and the destination
2021 // year is not a leap year, the date will be changed
2022 // to February 28. The date must be valid.
2023 // <n_years>: number of years to move forward
2024 void add_years()(uint n_years) nothrow {
2025 g_date_add_years(&this, n_years);
2028 // If @date is prior to @min_date, sets @date equal to @min_date.
2029 // If @date falls after @max_date, sets @date equal to @max_date.
2030 // Otherwise, @date is unchanged.
2031 // Either of @min_date and @max_date may be %NULL.
2032 // All non-%NULL dates must be valid.
2033 // <min_date>: minimum accepted value for @date
2034 // <max_date>: maximum accepted value for @date
2035 void clamp()(Date* min_date, Date* max_date) nothrow {
2036 g_date_clamp(&this, min_date, max_date);
2039 // Initializes one or more #GDate structs to a sane but invalid
2040 // state. The cleared dates will not represent an existing date, but will
2041 // not contain garbage. Useful to init a date declared on the stack.
2042 // Validity can be tested with g_date_valid().
2043 // <n_dates>: number of dates to clear
2044 void clear()(uint n_dates) nothrow {
2045 g_date_clear(&this, n_dates);
2048 // qsort()-style comparsion function for dates.
2049 // Both dates must be valid.
2051 // greater than zero if @lhs is greater than @rhs
2052 // RETURNS: 0 for equal, less than zero if @lhs is less than @rhs,
2053 // <rhs>: second date to compare
2054 int compare()(Date* rhs) nothrow {
2055 return g_date_compare(&this, rhs);
2058 // Computes the number of days between two dates.
2059 // If @date2 is prior to @date1, the returned value is negative.
2060 // Both dates must be valid.
2061 // RETURNS: the number of days between @date1 and @date2
2062 // <date2>: the second date
2063 int days_between()(Date* date2) nothrow {
2064 return g_date_days_between(&this, date2);
2066 // Frees a #GDate returned from g_date_new().
2067 void free()() nothrow {
2068 g_date_free(&this);
2071 // Returns the day of the month. The date must be valid.
2072 // RETURNS: day of the month
2073 DateDay get_day()() nothrow {
2074 return g_date_get_day(&this);
2077 // Returns the day of the year, where Jan 1 is the first day of the
2078 // year. The date must be valid.
2079 // RETURNS: day of the year
2080 uint get_day_of_year()() nothrow {
2081 return g_date_get_day_of_year(&this);
2084 // VERSION: 2.6
2085 // Returns the week of the year, where weeks are interpreted according
2086 // to ISO 8601.
2087 // RETURNS: ISO 8601 week number of the year.
2088 uint get_iso8601_week_of_year()() nothrow {
2089 return g_date_get_iso8601_week_of_year(&this);
2092 // Returns the Julian day or "serial number" of the #GDate. The
2093 // Julian day is simply the number of days since January 1, Year 1; i.e.,
2094 // January 1, Year 1 is Julian day 1; January 2, Year 1 is Julian day 2,
2095 // etc. The date must be valid.
2096 // RETURNS: Julian day
2097 uint get_julian()() nothrow {
2098 return g_date_get_julian(&this);
2101 // Returns the week of the year, where weeks are understood to start on
2102 // Monday. If the date is before the first Monday of the year, return
2103 // 0. The date must be valid.
2104 // RETURNS: week of the year
2105 uint get_monday_week_of_year()() nothrow {
2106 return g_date_get_monday_week_of_year(&this);
2109 // Returns the month of the year. The date must be valid.
2110 // RETURNS: month of the year as a #GDateMonth
2111 DateMonth get_month()() nothrow {
2112 return g_date_get_month(&this);
2115 // Returns the week of the year during which this date falls, if weeks
2116 // are understood to being on Sunday. The date must be valid. Can return
2117 // 0 if the day is before the first Sunday of the year.
2118 // RETURNS: week number
2119 uint get_sunday_week_of_year()() nothrow {
2120 return g_date_get_sunday_week_of_year(&this);
2123 // Returns the day of the week for a #GDate. The date must be valid.
2124 // RETURNS: day of the week as a #GDateWeekday.
2125 DateWeekday get_weekday()() nothrow {
2126 return g_date_get_weekday(&this);
2129 // Returns the year of a #GDate. The date must be valid.
2130 // RETURNS: year in which the date falls
2131 DateYear get_year()() nothrow {
2132 return g_date_get_year(&this);
2135 // Returns %TRUE if the date is on the first of a month.
2136 // The date must be valid.
2137 // RETURNS: %TRUE if the date is the first of the month
2138 int is_first_of_month()() nothrow {
2139 return g_date_is_first_of_month(&this);
2142 // Returns %TRUE if the date is the last day of the month.
2143 // The date must be valid.
2144 // RETURNS: %TRUE if the date is the last day of the month
2145 int is_last_of_month()() nothrow {
2146 return g_date_is_last_of_month(&this);
2149 // Checks if @date1 is less than or equal to @date2,
2150 // and swap the values if this is not the case.
2151 // <date2>: the second date
2152 void order()(Date* date2) nothrow {
2153 g_date_order(&this, date2);
2156 // Sets the day of the month for a #GDate. If the resulting
2157 // day-month-year triplet is invalid, the date will be invalid.
2158 // <day>: day to set
2159 void set_day()(DateDay day) nothrow {
2160 g_date_set_day(&this, day);
2163 // Sets the value of a #GDate from a day, month, and year.
2164 // The day-month-year triplet must be valid; if you aren't
2165 // sure it is, call g_date_valid_dmy() to check before you
2166 // set it.
2167 // <day>: day
2168 // <month>: month
2169 // <y>: year
2170 void set_dmy()(DateDay day, DateMonth month, DateYear y) nothrow {
2171 g_date_set_dmy(&this, day, month, y);
2174 // Sets the value of a #GDate from a Julian day number.
2175 // <julian_date>: Julian day number (days since January 1, Year 1)
2176 void set_julian()(uint julian_date) nothrow {
2177 g_date_set_julian(&this, julian_date);
2180 // Sets the month of the year for a #GDate. If the resulting
2181 // day-month-year triplet is invalid, the date will be invalid.
2182 // <month>: month to set
2183 void set_month()(DateMonth month) nothrow {
2184 g_date_set_month(&this, month);
2187 // Parses a user-inputted string @str, and try to figure out what date it
2188 // represents, taking the <link linkend="setlocale">current locale</link>
2189 // into account. If the string is successfully parsed, the date will be
2190 // valid after the call. Otherwise, it will be invalid. You should check
2191 // using g_date_valid() to see whether the parsing succeeded.
2193 // This function is not appropriate for file formats and the like; it
2194 // isn't very precise, and its exact behavior varies with the locale.
2195 // It's intended to be a heuristic routine that guesses what the user
2196 // means by a given string (and it does work pretty well in that
2197 // capacity).
2198 // <str>: string to parse
2199 void set_parse()(char* str) nothrow {
2200 g_date_set_parse(&this, str);
2203 // DEPRECATED (v2.10) method: set_time - Use g_date_set_time_t() instead.
2204 // Sets the value of a date from a #GTime value.
2205 // The time to date conversion is done using the user's current timezone.
2206 // <time_>: #GTime value to set.
2207 void set_time()(Time time_) nothrow {
2208 g_date_set_time(&this, time_);
2211 // VERSION: 2.10
2212 // Sets the value of a date to the date corresponding to a time
2213 // specified as a time_t. The time to date conversion is done using
2214 // the user's current timezone.
2216 // To set the value of a date to the current day, you could write:
2217 // |[
2218 // g_date_set_time_t (date, time (NULL));
2219 // ]|
2220 // <timet>: <type>time_t</type> value to set
2221 void set_time_t()(time_t timet) nothrow {
2222 g_date_set_time_t(&this, timet);
2225 // VERSION: 2.10
2226 // Sets the value of a date from a #GTimeVal value. Note that the
2227 // @tv_usec member is ignored, because #GDate can't make use of the
2228 // additional precision.
2230 // The time to date conversion is done using the user's current timezone.
2231 // <timeval>: #GTimeVal value to set
2232 void set_time_val()(TimeVal* timeval) nothrow {
2233 g_date_set_time_val(&this, timeval);
2236 // Sets the year for a #GDate. If the resulting day-month-year
2237 // triplet is invalid, the date will be invalid.
2238 // <year>: year to set
2239 void set_year()(DateYear year) nothrow {
2240 g_date_set_year(&this, year);
2243 // Moves a date some number of days into the past.
2244 // To move by weeks, just move by weeks*7 days.
2245 // The date must be valid.
2246 // <n_days>: number of days to move
2247 void subtract_days()(uint n_days) nothrow {
2248 g_date_subtract_days(&this, n_days);
2251 // Moves a date some number of months into the past.
2252 // If the current day of the month doesn't exist in
2253 // the destination month, the day of the month
2254 // may change. The date must be valid.
2255 // <n_months>: number of months to move
2256 void subtract_months()(uint n_months) nothrow {
2257 g_date_subtract_months(&this, n_months);
2260 // Moves a date some number of years into the past.
2261 // If the current day doesn't exist in the destination
2262 // year (i.e. it's February 29 and you move to a non-leap-year)
2263 // then the day is changed to February 29. The date
2264 // must be valid.
2265 // <n_years>: number of years to move
2266 void subtract_years()(uint n_years) nothrow {
2267 g_date_subtract_years(&this, n_years);
2270 // Fills in the date-related bits of a <structname>struct tm</structname>
2271 // using the @date value. Initializes the non-date parts with something
2272 // sane but meaningless.
2273 // <tm>: <structname>struct tm</structname> to fill
2274 void to_struct_tm()(void** tm) nothrow {
2275 g_date_to_struct_tm(&this, tm);
2278 // Returns %TRUE if the #GDate represents an existing day. The date must not
2279 // contain garbage; it should have been initialized with g_date_clear()
2280 // if it wasn't allocated by one of the g_date_new() variants.
2281 // RETURNS: Whether the date is valid
2282 int valid()() nothrow {
2283 return g_date_valid(&this);
2286 // Returns the number of days in a month, taking leap
2287 // years into account.
2288 // RETURNS: number of days in @month during the @year
2289 // <month>: month
2290 // <year>: year
2291 static ubyte get_days_in_month()(DateMonth month, DateYear year) nothrow {
2292 return g_date_get_days_in_month(month, year);
2295 // Returns the number of weeks in the year, where weeks
2296 // are taken to start on Monday. Will be 52 or 53. The
2297 // date must be valid. (Years always have 52 7-day periods,
2298 // plus 1 or 2 extra days depending on whether it's a leap
2299 // year. This function is basically telling you how many
2300 // Mondays are in the year, i.e. there are 53 Mondays if
2301 // one of the extra days happens to be a Monday.)
2302 // RETURNS: number of Mondays in the year
2303 // <year>: a year
2304 static ubyte get_monday_weeks_in_year()(DateYear year) nothrow {
2305 return g_date_get_monday_weeks_in_year(year);
2308 // Returns the number of weeks in the year, where weeks
2309 // are taken to start on Sunday. Will be 52 or 53. The
2310 // date must be valid. (Years always have 52 7-day periods,
2311 // plus 1 or 2 extra days depending on whether it's a leap
2312 // year. This function is basically telling you how many
2313 // Sundays are in the year, i.e. there are 53 Sundays if
2314 // one of the extra days happens to be a Sunday.)
2315 // RETURNS: the number of weeks in @year
2316 // <year>: year to count weeks in
2317 static ubyte get_sunday_weeks_in_year()(DateYear year) nothrow {
2318 return g_date_get_sunday_weeks_in_year(year);
2321 // Returns %TRUE if the year is a leap year.
2322 // <footnote><para>For the purposes of this function,
2323 // leap year is every year divisible by 4 unless that year
2324 // is divisible by 100. If it is divisible by 100 it would
2325 // be a leap year only if that year is also divisible
2326 // by 400.</para></footnote>
2327 // RETURNS: %TRUE if the year is a leap year
2328 // <year>: year to check
2329 static int is_leap_year()(DateYear year) nothrow {
2330 return g_date_is_leap_year(year);
2333 // Generates a printed representation of the date, in a
2334 // <link linkend="setlocale">locale</link>-specific way.
2335 // Works just like the platform's C library strftime() function,
2336 // but only accepts date-related formats; time-related formats
2337 // give undefined results. Date must be valid. Unlike strftime()
2338 // (which uses the locale encoding), works on a UTF-8 format
2339 // string and stores a UTF-8 result.
2341 // This function does not provide any conversion specifiers in
2342 // addition to those implemented by the platform's C library.
2343 // For example, don't expect that using g_date_strftime() would
2344 // make the \%F provided by the C99 strftime() work on Windows
2345 // where the C library only complies to C89.
2346 // RETURNS: number of characters written to the buffer, or 0 the buffer was too small
2347 // <s>: destination buffer
2348 // <slen>: buffer size
2349 // <format>: format string
2350 // <date>: valid #GDate
2351 static size_t strftime()(char* s, size_t slen, char* format, Date* date) nothrow {
2352 return g_date_strftime(s, slen, format, date);
2355 // Returns %TRUE if the day of the month is valid (a day is valid if it's
2356 // between 1 and 31 inclusive).
2357 // RETURNS: %TRUE if the day is valid
2358 // <day>: day to check
2359 static int valid_day()(DateDay day) nothrow {
2360 return g_date_valid_day(day);
2363 // Returns %TRUE if the day-month-year triplet forms a valid, existing day
2364 // in the range of days #GDate understands (Year 1 or later, no more than
2365 // a few thousand years in the future).
2366 // RETURNS: %TRUE if the date is a valid one
2367 // <day>: day
2368 // <month>: month
2369 // <year>: year
2370 static int valid_dmy()(DateDay day, DateMonth month, DateYear year) nothrow {
2371 return g_date_valid_dmy(day, month, year);
2374 // Returns %TRUE if the Julian day is valid. Anything greater than zero
2375 // is basically a valid Julian, though there is a 32-bit limit.
2376 // RETURNS: %TRUE if the Julian day is valid
2377 // <julian_date>: Julian day to check
2378 static int valid_julian()(uint julian_date) nothrow {
2379 return g_date_valid_julian(julian_date);
2382 // Returns %TRUE if the month value is valid. The 12 #GDateMonth
2383 // enumeration values are the only valid months.
2384 // RETURNS: %TRUE if the month is valid
2385 // <month>: month
2386 static int valid_month()(DateMonth month) nothrow {
2387 return g_date_valid_month(month);
2390 // Returns %TRUE if the weekday is valid. The seven #GDateWeekday enumeration
2391 // values are the only valid weekdays.
2392 // RETURNS: %TRUE if the weekday is valid
2393 // <weekday>: weekday
2394 static int valid_weekday()(DateWeekday weekday) nothrow {
2395 return g_date_valid_weekday(weekday);
2398 // Returns %TRUE if the year is valid. Any year greater than 0 is valid,
2399 // though there is a 16-bit limit to what #GDate will understand.
2400 // RETURNS: %TRUE if the year is valid
2401 // <year>: year
2402 static int valid_year()(DateYear year) nothrow {
2403 return g_date_valid_year(year);
2408 // This enumeration isn't used in the API, but may be useful if you need
2409 // to mark a number as a day, month, or year.
2410 enum DateDMY {
2411 DAY = 0,
2412 MONTH = 1,
2413 YEAR = 2
2416 // Enumeration representing a month; values are #G_DATE_JANUARY,
2417 // #G_DATE_FEBRUARY, etc. #G_DATE_BAD_MONTH is the invalid value.
2418 enum DateMonth {
2419 BAD_MONTH = 0,
2420 JANUARY = 1,
2421 FEBRUARY = 2,
2422 MARCH = 3,
2423 APRIL = 4,
2424 MAY = 5,
2425 JUNE = 6,
2426 JULY = 7,
2427 AUGUST = 8,
2428 SEPTEMBER = 9,
2429 OCTOBER = 10,
2430 NOVEMBER = 11,
2431 DECEMBER = 12
2434 // <structname>GDateTime</structname> is an opaque structure whose members
2435 // cannot be accessed directly.
2436 struct DateTime /* Version 2.26 */ {
2438 // VERSION: 2.26
2439 // Creates a new #GDateTime corresponding to the given date and time in
2440 // the time zone @tz.
2442 // The @year must be between 1 and 9999, @month between 1 and 12 and @day
2443 // between 1 and 28, 29, 30 or 31 depending on the month and the year.
2445 // @hour must be between 0 and 23 and @minute must be between 0 and 59.
2447 // @seconds must be at least 0.0 and must be strictly less than 60.0.
2448 // It will be rounded down to the nearest microsecond.
2450 // If the given time is not representable in the given time zone (for
2451 // example, 02:30 on March 14th 2010 in Toronto, due to daylight savings
2452 // time) then the time will be rounded up to the nearest existing time
2453 // (in this case, 03:00). If this matters to you then you should verify
2454 // the return value for containing the same as the numbers you gave.
2456 // In the case that the given time is ambiguous in the given time zone
2457 // (for example, 01:30 on November 7th 2010 in Toronto, due to daylight
2458 // savings time) then the time falling within standard (ie:
2459 // non-daylight) time is taken.
2461 // It not considered a programmer error for the values to this function
2462 // to be out of range, but in the case that they are, the function will
2463 // return %NULL.
2465 // You should release the return value by calling g_date_time_unref()
2466 // when you are done with it.
2467 // RETURNS: a new #GDateTime, or %NULL
2468 // <tz>: a #GTimeZone
2469 // <year>: the year component of the date
2470 // <month>: the month component of the date
2471 // <day>: the day component of the date
2472 // <hour>: the hour component of the date
2473 // <minute>: the minute component of the date
2474 // <seconds>: the number of seconds past the minute
2475 static DateTime* /*new*/ new_()(TimeZone* tz, int year, int month, int day, int hour, int minute, double seconds) nothrow {
2476 return g_date_time_new(tz, year, month, day, hour, minute, seconds);
2478 alias new_!() opCall;
2480 // VERSION: 2.26
2481 // Creates a #GDateTime corresponding to the given #GTimeVal @tv in the
2482 // local time zone.
2484 // The time contained in a #GTimeVal is always stored in the form of
2485 // seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the
2486 // local time offset.
2488 // This call can fail (returning %NULL) if @tv represents a time outside
2489 // of the supported range of #GDateTime.
2491 // You should release the return value by calling g_date_time_unref()
2492 // when you are done with it.
2493 // RETURNS: a new #GDateTime, or %NULL
2494 // <tv>: a #GTimeVal
2495 static DateTime* /*new*/ new_from_timeval_local()(TimeVal* tv) nothrow {
2496 return g_date_time_new_from_timeval_local(tv);
2498 alias new_from_timeval_local!() opCall;
2500 // VERSION: 2.26
2501 // Creates a #GDateTime corresponding to the given #GTimeVal @tv in UTC.
2503 // The time contained in a #GTimeVal is always stored in the form of
2504 // seconds elapsed since 1970-01-01 00:00:00 UTC.
2506 // This call can fail (returning %NULL) if @tv represents a time outside
2507 // of the supported range of #GDateTime.
2509 // You should release the return value by calling g_date_time_unref()
2510 // when you are done with it.
2511 // RETURNS: a new #GDateTime, or %NULL
2512 // <tv>: a #GTimeVal
2513 static DateTime* /*new*/ new_from_timeval_utc()(TimeVal* tv) nothrow {
2514 return g_date_time_new_from_timeval_utc(tv);
2516 alias new_from_timeval_utc!() opCall;
2518 // VERSION: 2.26
2519 // Creates a #GDateTime corresponding to the given Unix time @t in the
2520 // local time zone.
2522 // Unix time is the number of seconds that have elapsed since 1970-01-01
2523 // 00:00:00 UTC, regardless of the local time offset.
2525 // This call can fail (returning %NULL) if @t represents a time outside
2526 // of the supported range of #GDateTime.
2528 // You should release the return value by calling g_date_time_unref()
2529 // when you are done with it.
2530 // RETURNS: a new #GDateTime, or %NULL
2531 // <t>: the Unix time
2532 static DateTime* /*new*/ new_from_unix_local()(long t) nothrow {
2533 return g_date_time_new_from_unix_local(t);
2535 alias new_from_unix_local!() opCall;
2537 // VERSION: 2.26
2538 // Creates a #GDateTime corresponding to the given Unix time @t in UTC.
2540 // Unix time is the number of seconds that have elapsed since 1970-01-01
2541 // 00:00:00 UTC.
2543 // This call can fail (returning %NULL) if @t represents a time outside
2544 // of the supported range of #GDateTime.
2546 // You should release the return value by calling g_date_time_unref()
2547 // when you are done with it.
2548 // RETURNS: a new #GDateTime, or %NULL
2549 // <t>: the Unix time
2550 static DateTime* /*new*/ new_from_unix_utc()(long t) nothrow {
2551 return g_date_time_new_from_unix_utc(t);
2553 alias new_from_unix_utc!() opCall;
2555 // VERSION: 2.26.
2556 // Creates a new #GDateTime corresponding to the given date and time in
2557 // the local time zone.
2559 // This call is equivalent to calling g_date_time_new() with the time
2560 // zone returned by g_time_zone_new_local().
2561 // RETURNS: a #GDateTime, or %NULL
2562 // <year>: the year component of the date
2563 // <month>: the month component of the date
2564 // <day>: the day component of the date
2565 // <hour>: the hour component of the date
2566 // <minute>: the minute component of the date
2567 // <seconds>: the number of seconds past the minute
2568 static DateTime* /*new*/ new_local()(int year, int month, int day, int hour, int minute, double seconds) nothrow {
2569 return g_date_time_new_local(year, month, day, hour, minute, seconds);
2571 alias new_local!() opCall;
2573 // VERSION: 2.26
2574 // Creates a #GDateTime corresponding to this exact instant in the given
2575 // time zone @tz. The time is as accurate as the system allows, to a
2576 // maximum accuracy of 1 microsecond.
2578 // This function will always succeed unless the system clock is set to
2579 // truly insane values (or unless GLib is still being used after the
2580 // year 9999).
2582 // You should release the return value by calling g_date_time_unref()
2583 // when you are done with it.
2584 // RETURNS: a new #GDateTime, or %NULL
2585 // <tz>: a #GTimeZone
2586 static DateTime* /*new*/ new_now()(TimeZone* tz) nothrow {
2587 return g_date_time_new_now(tz);
2589 alias new_now!() opCall;
2591 // VERSION: 2.26
2592 // Creates a #GDateTime corresponding to this exact instant in the local
2593 // time zone.
2595 // This is equivalent to calling g_date_time_new_now() with the time
2596 // zone returned by g_time_zone_new_local().
2597 // RETURNS: a new #GDateTime, or %NULL
2598 static DateTime* /*new*/ new_now_local()() nothrow {
2599 return g_date_time_new_now_local();
2602 // VERSION: 2.26
2603 // Creates a #GDateTime corresponding to this exact instant in UTC.
2605 // This is equivalent to calling g_date_time_new_now() with the time
2606 // zone returned by g_time_zone_new_utc().
2607 // RETURNS: a new #GDateTime, or %NULL
2608 static DateTime* /*new*/ new_now_utc()() nothrow {
2609 return g_date_time_new_now_utc();
2612 // VERSION: 2.26.
2613 // Creates a new #GDateTime corresponding to the given date and time in
2614 // UTC.
2616 // This call is equivalent to calling g_date_time_new() with the time
2617 // zone returned by g_time_zone_new_utc().
2618 // RETURNS: a #GDateTime, or %NULL
2619 // <year>: the year component of the date
2620 // <month>: the month component of the date
2621 // <day>: the day component of the date
2622 // <hour>: the hour component of the date
2623 // <minute>: the minute component of the date
2624 // <seconds>: the number of seconds past the minute
2625 static DateTime* /*new*/ new_utc()(int year, int month, int day, int hour, int minute, double seconds) nothrow {
2626 return g_date_time_new_utc(year, month, day, hour, minute, seconds);
2628 alias new_utc!() opCall;
2630 // VERSION: 2.26
2631 // Creates a copy of @datetime and adds the specified timespan to the copy.
2633 // g_date_time_unref().
2634 // RETURNS: the newly created #GDateTime which should be freed with
2635 // <timespan>: a #GTimeSpan
2636 DateTime* /*new*/ add()(TimeSpan timespan) nothrow {
2637 return g_date_time_add(&this, timespan);
2640 // VERSION: 2.26
2641 // Creates a copy of @datetime and adds the specified number of days to the
2642 // copy.
2644 // g_date_time_unref().
2645 // RETURNS: the newly created #GDateTime which should be freed with
2646 // <days>: the number of days
2647 DateTime* /*new*/ add_days()(int days) nothrow {
2648 return g_date_time_add_days(&this, days);
2651 // VERSION: 2.26
2652 // Creates a new #GDateTime adding the specified values to the current date and
2653 // time in @datetime.
2655 // g_date_time_unref().
2656 // RETURNS: the newly created #GDateTime that should be freed with
2657 // <years>: the number of years to add
2658 // <months>: the number of months to add
2659 // <days>: the number of days to add
2660 // <hours>: the number of hours to add
2661 // <minutes>: the number of minutes to add
2662 // <seconds>: the number of seconds to add
2663 DateTime* /*new*/ add_full()(int years, int months, int days, int hours, int minutes, double seconds) nothrow {
2664 return g_date_time_add_full(&this, years, months, days, hours, minutes, seconds);
2667 // VERSION: 2.26
2668 // Creates a copy of @datetime and adds the specified number of hours
2670 // g_date_time_unref().
2671 // RETURNS: the newly created #GDateTime which should be freed with
2672 // <hours>: the number of hours to add
2673 DateTime* /*new*/ add_hours()(int hours) nothrow {
2674 return g_date_time_add_hours(&this, hours);
2677 // VERSION: 2.26
2678 // Creates a copy of @datetime adding the specified number of minutes.
2680 // g_date_time_unref().
2681 // RETURNS: the newly created #GDateTime which should be freed with
2682 // <minutes>: the number of minutes to add
2683 DateTime* /*new*/ add_minutes()(int minutes) nothrow {
2684 return g_date_time_add_minutes(&this, minutes);
2687 // VERSION: 2.26
2688 // Creates a copy of @datetime and adds the specified number of months to the
2689 // copy.
2691 // g_date_time_unref().
2692 // RETURNS: the newly created #GDateTime which should be freed with
2693 // <months>: the number of months
2694 DateTime* /*new*/ add_months()(int months) nothrow {
2695 return g_date_time_add_months(&this, months);
2698 // VERSION: 2.26
2699 // Creates a copy of @datetime and adds the specified number of seconds.
2701 // g_date_time_unref().
2702 // RETURNS: the newly created #GDateTime which should be freed with
2703 // <seconds>: the number of seconds to add
2704 DateTime* /*new*/ add_seconds()(double seconds) nothrow {
2705 return g_date_time_add_seconds(&this, seconds);
2708 // VERSION: 2.26
2709 // Creates a copy of @datetime and adds the specified number of weeks to the
2710 // copy.
2712 // g_date_time_unref().
2713 // RETURNS: the newly created #GDateTime which should be freed with
2714 // <weeks>: the number of weeks
2715 DateTime* /*new*/ add_weeks()(int weeks) nothrow {
2716 return g_date_time_add_weeks(&this, weeks);
2719 // VERSION: 2.26
2720 // Creates a copy of @datetime and adds the specified number of years to the
2721 // copy.
2723 // g_date_time_unref().
2724 // RETURNS: the newly created #GDateTime which should be freed with
2725 // <years>: the number of years
2726 DateTime* /*new*/ add_years()(int years) nothrow {
2727 return g_date_time_add_years(&this, years);
2730 // VERSION: 2.26
2731 // Calculates the difference in time between @end and @begin. The
2732 // #GTimeSpan that is returned is effectively @end - @begin (ie:
2733 // positive if the first simparameter is larger).
2735 // span expressed in microseconds.
2736 // RETURNS: the difference between the two #GDateTime, as a time
2737 // <begin>: a #GDateTime
2738 TimeSpan difference()(DateTime* begin) nothrow {
2739 return g_date_time_difference(&this, begin);
2742 // VERSION: 2.26
2743 // Creates a newly allocated string representing the requested @format.
2745 // The format strings understood by this function are a subset of the
2746 // strftime() format language as specified by C99. The \%D, \%U and \%W
2747 // conversions are not supported, nor is the 'E' modifier. The GNU
2748 // extensions \%k, \%l, \%s and \%P are supported, however, as are the
2749 // '0', '_' and '-' modifiers.
2751 // In contrast to strftime(), this function always produces a UTF-8
2752 // string, regardless of the current locale. Note that the rendering of
2753 // many formats is locale-dependent and may not match the strftime()
2754 // output exactly.
2756 // The following format specifiers are supported:
2758 // <variablelist>
2759 // <varlistentry><term>
2760 // <literal>\%a</literal>:
2761 // </term><listitem><simpara>
2762 // the abbreviated weekday name according to the current locale
2763 // </simpara></listitem></varlistentry>
2764 // <varlistentry><term>
2765 // <literal>\%A</literal>:
2766 // </term><listitem><simpara>
2767 // the full weekday name according to the current locale
2768 // </simpara></listitem></varlistentry>
2769 // <varlistentry><term>
2770 // <literal>\%b</literal>:
2771 // </term><listitem><simpara>
2772 // the abbreviated month name according to the current locale
2773 // </simpara></listitem></varlistentry>
2774 // <varlistentry><term>
2775 // <literal>\%B</literal>:
2776 // </term><listitem><simpara>
2777 // the full month name according to the current locale
2778 // </simpara></listitem></varlistentry>
2779 // <varlistentry><term>
2780 // <literal>\%c</literal>:
2781 // </term><listitem><simpara>
2782 // the preferred date and time representation for the current locale
2783 // </simpara></listitem></varlistentry>
2784 // <varlistentry><term>
2785 // <literal>\%C</literal>:
2786 // </term><listitem><simpara>
2787 // The century number (year/100) as a 2-digit integer (00-99)
2788 // </simpara></listitem></varlistentry>
2789 // <varlistentry><term>
2790 // <literal>\%d</literal>:
2791 // </term><listitem><simpara>
2792 // the day of the month as a decimal number (range 01 to 31)
2793 // </simpara></listitem></varlistentry>
2794 // <varlistentry><term>
2795 // <literal>\%e</literal>:
2796 // </term><listitem><simpara>
2797 // the day of the month as a decimal number (range 1 to 31)
2798 // </simpara></listitem></varlistentry>
2799 // <varlistentry><term>
2800 // <literal>\%F</literal>:
2801 // </term><listitem><simpara>
2802 // equivalent to <literal>\%Y-\%m-\%d</literal> (the ISO 8601 date
2803 // format)
2804 // </simpara></listitem></varlistentry>
2805 // <varlistentry><term>
2806 // <literal>\%g</literal>:
2807 // </term><listitem><simpara>
2808 // the last two digits of the ISO 8601 week-based year as a decimal
2809 // number (00-99). This works well with \%V and \%u.
2810 // </simpara></listitem></varlistentry>
2811 // <varlistentry><term>
2812 // <literal>\%G</literal>:
2813 // </term><listitem><simpara>
2814 // the ISO 8601 week-based year as a decimal number. This works well
2815 // with \%V and \%u.
2816 // </simpara></listitem></varlistentry>
2817 // <varlistentry><term>
2818 // <literal>\%h</literal>:
2819 // </term><listitem><simpara>
2820 // equivalent to <literal>\%b</literal>
2821 // </simpara></listitem></varlistentry>
2822 // <varlistentry><term>
2823 // <literal>\%H</literal>:
2824 // </term><listitem><simpara>
2825 // the hour as a decimal number using a 24-hour clock (range 00 to
2826 // 23)
2827 // </simpara></listitem></varlistentry>
2828 // <varlistentry><term>
2829 // <literal>\%I</literal>:
2830 // </term><listitem><simpara>
2831 // the hour as a decimal number using a 12-hour clock (range 01 to
2832 // 12)
2833 // </simpara></listitem></varlistentry>
2834 // <varlistentry><term>
2835 // <literal>\%j</literal>:
2836 // </term><listitem><simpara>
2837 // the day of the year as a decimal number (range 001 to 366)
2838 // </simpara></listitem></varlistentry>
2839 // <varlistentry><term>
2840 // <literal>\%k</literal>:
2841 // </term><listitem><simpara>
2842 // the hour (24-hour clock) as a decimal number (range 0 to 23);
2843 // single digits are preceded by a blank
2844 // </simpara></listitem></varlistentry>
2845 // <varlistentry><term>
2846 // <literal>\%l</literal>:
2847 // </term><listitem><simpara>
2848 // the hour (12-hour clock) as a decimal number (range 1 to 12);
2849 // single digits are preceded by a blank
2850 // </simpara></listitem></varlistentry>
2851 // <varlistentry><term>
2852 // <literal>\%m</literal>:
2853 // </term><listitem><simpara>
2854 // the month as a decimal number (range 01 to 12)
2855 // </simpara></listitem></varlistentry>
2856 // <varlistentry><term>
2857 // <literal>\%M</literal>:
2858 // </term><listitem><simpara>
2859 // the minute as a decimal number (range 00 to 59)
2860 // </simpara></listitem></varlistentry>
2861 // <varlistentry><term>
2862 // <literal>\%p</literal>:
2863 // </term><listitem><simpara>
2864 // either "AM" or "PM" according to the given time value, or the
2865 // corresponding strings for the current locale. Noon is treated as
2866 // "PM" and midnight as "AM".
2867 // </simpara></listitem></varlistentry>
2868 // <varlistentry><term>
2869 // <literal>\%P</literal>:
2870 // </term><listitem><simpara>
2871 // like \%p but lowercase: "am" or "pm" or a corresponding string for
2872 // the current locale
2873 // </simpara></listitem></varlistentry>
2874 // <varlistentry><term>
2875 // <literal>\%r</literal>:
2876 // </term><listitem><simpara>
2877 // the time in a.m. or p.m. notation
2878 // </simpara></listitem></varlistentry>
2879 // <varlistentry><term>
2880 // <literal>\%R</literal>:
2881 // </term><listitem><simpara>
2882 // the time in 24-hour notation (<literal>\%H:\%M</literal>)
2883 // </simpara></listitem></varlistentry>
2884 // <varlistentry><term>
2885 // <literal>\%s</literal>:
2886 // </term><listitem><simpara>
2887 // the number of seconds since the Epoch, that is, since 1970-01-01
2888 // 00:00:00 UTC
2889 // </simpara></listitem></varlistentry>
2890 // <varlistentry><term>
2891 // <literal>\%S</literal>:
2892 // </term><listitem><simpara>
2893 // the second as a decimal number (range 00 to 60)
2894 // </simpara></listitem></varlistentry>
2895 // <varlistentry><term>
2896 // <literal>\%t</literal>:
2897 // </term><listitem><simpara>
2898 // a tab character
2899 // </simpara></listitem></varlistentry>
2900 // <varlistentry><term>
2901 // <literal>\%T</literal>:
2902 // </term><listitem><simpara>
2903 // the time in 24-hour notation with seconds (<literal>\%H:\%M:\%S</literal>)
2904 // </simpara></listitem></varlistentry>
2905 // <varlistentry><term>
2906 // <literal>\%u</literal>:
2907 // </term><listitem><simpara>
2908 // the ISO 8601 standard day of the week as a decimal, range 1 to 7,
2909 // Monday being 1. This works well with \%G and \%V.
2910 // </simpara></listitem></varlistentry>
2911 // <varlistentry><term>
2912 // <literal>\%V</literal>:
2913 // </term><listitem><simpara>
2914 // the ISO 8601 standard week number of the current year as a decimal
2915 // number, range 01 to 53, where week 1 is the first week that has at
2916 // least 4 days in the new year. See g_date_time_get_week_of_year().
2917 // This works well with \%G and \%u.
2918 // </simpara></listitem></varlistentry>
2919 // <varlistentry><term>
2920 // <literal>\%w</literal>:
2921 // </term><listitem><simpara>
2922 // the day of the week as a decimal, range 0 to 6, Sunday being 0.
2923 // This is not the ISO 8601 standard format -- use \%u instead.
2924 // </simpara></listitem></varlistentry>
2925 // <varlistentry><term>
2926 // <literal>\%x</literal>:
2927 // </term><listitem><simpara>
2928 // the preferred date representation for the current locale without
2929 // the time
2930 // </simpara></listitem></varlistentry>
2931 // <varlistentry><term>
2932 // <literal>\%X</literal>:
2933 // </term><listitem><simpara>
2934 // the preferred time representation for the current locale without
2935 // the date
2936 // </simpara></listitem></varlistentry>
2937 // <varlistentry><term>
2938 // <literal>\%y</literal>:
2939 // </term><listitem><simpara>
2940 // the year as a decimal number without the century
2941 // </simpara></listitem></varlistentry>
2942 // <varlistentry><term>
2943 // <literal>\%Y</literal>:
2944 // </term><listitem><simpara>
2945 // the year as a decimal number including the century
2946 // </simpara></listitem></varlistentry>
2947 // <varlistentry><term>
2948 // <literal>\%z</literal>:
2949 // </term><listitem><simpara>
2950 // the time-zone as hour offset from UTC
2951 // </simpara></listitem></varlistentry>
2952 // <varlistentry><term>
2953 // <literal>\%Z</literal>:
2954 // </term><listitem><simpara>
2955 // the time zone or name or abbreviation
2956 // </simpara></listitem></varlistentry>
2957 // <varlistentry><term>
2958 // <literal>\%\%</literal>:
2959 // </term><listitem><simpara>
2960 // a literal <literal>\%</literal> character
2961 // </simpara></listitem></varlistentry>
2962 // </variablelist>
2964 // Some conversion specifications can be modified by preceding the
2965 // conversion specifier by one or more modifier characters. The
2966 // following modifiers are supported for many of the numeric
2967 // conversions:
2968 // <variablelist>
2969 // <varlistentry>
2970 // <term>O</term>
2971 // <listitem>
2972 // Use alternative numeric symbols, if the current locale
2973 // supports those.
2974 // </listitem>
2975 // </varlistentry>
2976 // <varlistentry>
2977 // <term>_</term>
2978 // <listitem>
2979 // Pad a numeric result with spaces.
2980 // This overrides the default padding for the specifier.
2981 // </listitem>
2982 // </varlistentry>
2983 // <varlistentry>
2984 // <term>-</term>
2985 // <listitem>
2986 // Do not pad a numeric result.
2987 // This overrides the default padding for the specifier.
2988 // </listitem>
2989 // </varlistentry>
2990 // <varlistentry>
2991 // <term>0</term>
2992 // <listitem>
2993 // Pad a numeric result with zeros.
2994 // This overrides the default padding for the specifier.
2995 // </listitem>
2996 // </varlistentry>
2997 // </variablelist>
2999 // or %NULL in the case that there was an error. The string
3000 // should be freed with g_free().
3001 // RETURNS: a newly allocated string formatted to the requested format
3002 // <format>: a valid UTF-8 string, containing the format for the #GDateTime
3003 char* /*new*/ format()(char* format) nothrow {
3004 return g_date_time_format(&this, format);
3007 // VERSION: 2.26
3008 // Retrieves the day of the month represented by @datetime in the gregorian
3009 // calendar.
3010 // RETURNS: the day of the month
3011 int get_day_of_month()() nothrow {
3012 return g_date_time_get_day_of_month(&this);
3015 // VERSION: 2.26
3016 // Retrieves the ISO 8601 day of the week on which @datetime falls (1 is
3017 // Monday, 2 is Tuesday... 7 is Sunday).
3018 // RETURNS: the day of the week
3019 int get_day_of_week()() nothrow {
3020 return g_date_time_get_day_of_week(&this);
3023 // VERSION: 2.26
3024 // Retrieves the day of the year represented by @datetime in the Gregorian
3025 // calendar.
3026 // RETURNS: the day of the year
3027 int get_day_of_year()() nothrow {
3028 return g_date_time_get_day_of_year(&this);
3031 // VERSION: 2.26
3032 // Retrieves the hour of the day represented by @datetime
3033 // RETURNS: the hour of the day
3034 int get_hour()() nothrow {
3035 return g_date_time_get_hour(&this);
3038 // VERSION: 2.26
3039 // Retrieves the microsecond of the date represented by @datetime
3040 // RETURNS: the microsecond of the second
3041 int get_microsecond()() nothrow {
3042 return g_date_time_get_microsecond(&this);
3045 // VERSION: 2.26
3046 // Retrieves the minute of the hour represented by @datetime
3047 // RETURNS: the minute of the hour
3048 int get_minute()() nothrow {
3049 return g_date_time_get_minute(&this);
3052 // VERSION: 2.26
3053 // Retrieves the month of the year represented by @datetime in the Gregorian
3054 // calendar.
3055 // RETURNS: the month represented by @datetime
3056 int get_month()() nothrow {
3057 return g_date_time_get_month(&this);
3060 // VERSION: 2.26
3061 // Retrieves the second of the minute represented by @datetime
3062 // RETURNS: the second represented by @datetime
3063 int get_second()() nothrow {
3064 return g_date_time_get_second(&this);
3067 // VERSION: 2.26
3068 // Retrieves the number of seconds since the start of the last minute,
3069 // including the fractional part.
3070 // RETURNS: the number of seconds
3071 double get_seconds()() nothrow {
3072 return g_date_time_get_seconds(&this);
3075 // VERSION: 2.26
3076 // Determines the time zone abbreviation to be used at the time and in
3077 // the time zone of @datetime.
3079 // For example, in Toronto this is currently "EST" during the winter
3080 // months and "EDT" during the summer months when daylight savings
3081 // time is in effect.
3083 // string is owned by the #GDateTime and it should not be
3084 // modified or freed
3085 // RETURNS: the time zone abbreviation. The returned
3086 char* get_timezone_abbreviation()() nothrow {
3087 return g_date_time_get_timezone_abbreviation(&this);
3090 // VERSION: 2.26
3091 // Determines the offset to UTC in effect at the time and in the time
3092 // zone of @datetime.
3094 // The offset is the number of microseconds that you add to UTC time to
3095 // arrive at local time for the time zone (ie: negative numbers for time
3096 // zones west of GMT, positive numbers for east).
3098 // If @datetime represents UTC time, then the offset is always zero.
3100 // get the local time
3101 // RETURNS: the number of microseconds that should be added to UTC to
3102 TimeSpan get_utc_offset()() nothrow {
3103 return g_date_time_get_utc_offset(&this);
3106 // VERSION: 2.26
3107 // Returns the ISO 8601 week-numbering year in which the week containing
3108 // @datetime falls.
3110 // This function, taken together with g_date_time_get_week_of_year() and
3111 // g_date_time_get_day_of_week() can be used to determine the full ISO
3112 // week date on which @datetime falls.
3114 // This is usually equal to the normal Gregorian year (as returned by
3115 // g_date_time_get_year()), except as detailed below:
3117 // For Thursday, the week-numbering year is always equal to the usual
3118 // calendar year. For other days, the number is such that every day
3119 // within a complete week (Monday to Sunday) is contained within the
3120 // same week-numbering year.
3122 // For Monday, Tuesday and Wednesday occurring near the end of the year,
3123 // this may mean that the week-numbering year is one greater than the
3124 // calendar year (so that these days have the same week-numbering year
3125 // as the Thursday occurring early in the next year).
3127 // For Friday, Saturaday and Sunday occurring near the start of the year,
3128 // this may mean that the week-numbering year is one less than the
3129 // calendar year (so that these days have the same week-numbering year
3130 // as the Thursday occurring late in the previous year).
3132 // An equivalent description is that the week-numbering year is equal to
3133 // the calendar year containing the majority of the days in the current
3134 // week (Monday to Sunday).
3136 // Note that January 1 0001 in the proleptic Gregorian calendar is a
3137 // Monday, so this function never returns 0.
3138 // RETURNS: the ISO 8601 week-numbering year for @datetime
3139 int get_week_numbering_year()() nothrow {
3140 return g_date_time_get_week_numbering_year(&this);
3143 // VERSION: 2.26
3144 // Returns the ISO 8601 week number for the week containing @datetime.
3145 // The ISO 8601 week number is the same for every day of the week (from
3146 // Moday through Sunday). That can produce some unusual results
3147 // (described below).
3149 // The first week of the year is week 1. This is the week that contains
3150 // the first Thursday of the year. Equivalently, this is the first week
3151 // that has more than 4 of its days falling within the calendar year.
3153 // The value 0 is never returned by this function. Days contained
3154 // within a year but occurring before the first ISO 8601 week of that
3155 // year are considered as being contained in the last week of the
3156 // previous year. Similarly, the final days of a calendar year may be
3157 // considered as being part of the first ISO 8601 week of the next year
3158 // if 4 or more days of that week are contained within the new year.
3159 // RETURNS: the ISO 8601 week number for @datetime.
3160 int get_week_of_year()() nothrow {
3161 return g_date_time_get_week_of_year(&this);
3164 // VERSION: 2.26
3165 // Retrieves the year represented by @datetime in the Gregorian calendar.
3166 // RETURNS: the year represented by @datetime
3167 int get_year()() nothrow {
3168 return g_date_time_get_year(&this);
3171 // VERSION: 2.26
3172 // Retrieves the Gregorian day, month, and year of a given #GDateTime.
3173 // <year>: the return location for the gregorian year, or %NULL.
3174 // <month>: the return location for the month of the year, or %NULL.
3175 // <day>: the return location for the day of the month, or %NULL.
3176 void get_ymd()(/*out*/ int* year, /*out*/ int* month, /*out*/ int* day) nothrow {
3177 g_date_time_get_ymd(&this, year, month, day);
3180 // VERSION: 2.26
3181 // Determines if daylight savings time is in effect at the time and in
3182 // the time zone of @datetime.
3183 // RETURNS: %TRUE if daylight savings time is in effect
3184 int is_daylight_savings()() nothrow {
3185 return g_date_time_is_daylight_savings(&this);
3188 // VERSION: 2.26
3189 // Atomically increments the reference count of @datetime by one.
3190 // RETURNS: the #GDateTime with the reference count increased
3191 DateTime* /*new*/ ref_()() nothrow {
3192 return g_date_time_ref(&this);
3195 // VERSION: 2.26
3196 // Creates a new #GDateTime corresponding to the same instant in time as
3197 // @datetime, but in the local time zone.
3199 // This call is equivalent to calling g_date_time_to_timezone() with the
3200 // time zone returned by g_time_zone_new_local().
3201 // RETURNS: the newly created #GDateTime
3202 DateTime* /*new*/ to_local()() nothrow {
3203 return g_date_time_to_local(&this);
3206 // VERSION: 2.26
3207 // Stores the instant in time that @datetime represents into @tv.
3209 // The time contained in a #GTimeVal is always stored in the form of
3210 // seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the time
3211 // zone associated with @datetime.
3213 // On systems where 'long' is 32bit (ie: all 32bit systems and all
3214 // Windows systems), a #GTimeVal is incapable of storing the entire
3215 // range of values that #GDateTime is capable of expressing. On those
3216 // systems, this function returns %FALSE to indicate that the time is
3217 // out of range.
3219 // On systems where 'long' is 64bit, this function never fails.
3220 // RETURNS: %TRUE if successful, else %FALSE
3221 // <tv>: a #GTimeVal to modify
3222 int to_timeval()(TimeVal* tv) nothrow {
3223 return g_date_time_to_timeval(&this, tv);
3226 // VERSION: 2.26
3227 // Create a new #GDateTime corresponding to the same instant in time as
3228 // @datetime, but in the time zone @tz.
3230 // This call can fail in the case that the time goes out of bounds. For
3231 // example, converting 0001-01-01 00:00:00 UTC to a time zone west of
3232 // Greenwich will fail (due to the year 0 being out of range).
3234 // You should release the return value by calling g_date_time_unref()
3235 // when you are done with it.
3236 // RETURNS: a new #GDateTime, or %NULL
3237 // <tz>: the new #GTimeZone
3238 DateTime* /*new*/ to_timezone()(TimeZone* tz) nothrow {
3239 return g_date_time_to_timezone(&this, tz);
3242 // VERSION: 2.26
3243 // Gives the Unix time corresponding to @datetime, rounding down to the
3244 // nearest second.
3246 // Unix time is the number of seconds that have elapsed since 1970-01-01
3247 // 00:00:00 UTC, regardless of the time zone associated with @datetime.
3248 // RETURNS: the Unix time corresponding to @datetime
3249 long to_unix()() nothrow {
3250 return g_date_time_to_unix(&this);
3253 // VERSION: 2.26
3254 // Creates a new #GDateTime corresponding to the same instant in time as
3255 // @datetime, but in UTC.
3257 // This call is equivalent to calling g_date_time_to_timezone() with the
3258 // time zone returned by g_time_zone_new_utc().
3259 // RETURNS: the newly created #GDateTime
3260 DateTime* /*new*/ to_utc()() nothrow {
3261 return g_date_time_to_utc(&this);
3264 // VERSION: 2.26
3265 // Atomically decrements the reference count of @datetime by one.
3267 // When the reference count reaches zero, the resources allocated by
3268 // @datetime are freed
3269 void unref()() nothrow {
3270 g_date_time_unref(&this);
3273 // VERSION: 2.26
3274 // A comparison function for #GDateTimes that is suitable
3275 // as a #GCompareFunc. Both #GDateTimes must be non-%NULL.
3277 // than @dt2.
3278 // RETURNS: -1, 0 or 1 if @dt1 is less than, equal to or greater
3279 // <dt1>: first #GDateTime to compare
3280 // <dt2>: second #GDateTime to compare
3281 static int compare()(const(void)* dt1, const(void)* dt2) nothrow {
3282 return g_date_time_compare(dt1, dt2);
3285 // VERSION: 2.26
3286 // Checks to see if @dt1 and @dt2 are equal.
3288 // Equal here means that they represent the same moment after converting
3289 // them to the same time zone.
3290 // RETURNS: %TRUE if @dt1 and @dt2 are equal
3291 // <dt1>: a #GDateTime
3292 // <dt2>: a #GDateTime
3293 static int equal()(const(void)* dt1, const(void)* dt2) nothrow {
3294 return g_date_time_equal(dt1, dt2);
3297 // VERSION: 2.26
3298 // Hashes @datetime into a #guint, suitable for use within #GHashTable.
3299 // RETURNS: a #guint containing the hash
3300 // <datetime>: a #GDateTime
3301 static uint hash()(const(void)* datetime) nothrow {
3302 return g_date_time_hash(datetime);
3307 // Enumeration representing a day of the week; #G_DATE_MONDAY,
3308 // #G_DATE_TUESDAY, etc. #G_DATE_BAD_WEEKDAY is an invalid weekday.
3309 enum DateWeekday {
3310 BAD_WEEKDAY = 0,
3311 MONDAY = 1,
3312 TUESDAY = 2,
3313 WEDNESDAY = 3,
3314 THURSDAY = 4,
3315 FRIDAY = 5,
3316 SATURDAY = 6,
3317 SUNDAY = 7
3320 // Associates a string with a bit flag.
3321 // Used in g_parse_debug_string().
3322 struct DebugKey {
3323 char* key;
3324 uint value;
3328 // Specifies the type of function which is called when a data element
3329 // is destroyed. It is passed the pointer to the data element and
3330 // should free any memory and resources allocated for it.
3331 // <data>: the data element.
3332 extern (C) alias void function (void* data) nothrow DestroyNotify;
3334 // An opaque structure representing an opened directory.
3335 struct Dir {
3336 // Closes the directory and deallocates all related resources.
3337 void close()() nothrow {
3338 g_dir_close(&this);
3341 // Retrieves the name of another entry in the directory, or %NULL.
3342 // The order of entries returned from this function is not defined,
3343 // and may vary by file system or other operating-system dependent
3344 // factors.
3346 // On Unix, the '.' and '..' entries are omitted, and the returned
3347 // name is in the on-disk encoding.
3349 // On Windows, as is true of all GLib functions which operate on
3350 // filenames, the returned name is in UTF-8.
3352 // more entries. The return value is owned by GLib and
3353 // must not be modified or freed.
3354 // RETURNS: The entry's name or %NULL if there are no
3355 char* read_name()() nothrow {
3356 return g_dir_read_name(&this);
3359 // Resets the given directory. The next call to g_dir_read_name()
3360 // will return the first entry again.
3361 void rewind()() nothrow {
3362 g_dir_rewind(&this);
3365 // VERSION: 2.30
3366 // Creates a subdirectory in the preferred directory for temporary
3367 // files (as returned by g_get_tmp_dir()).
3369 // @tmpl should be a string in the GLib file name encoding containing
3370 // a sequence of six 'X' characters, as the parameter to g_mkstemp().
3371 // However, unlike these functions, the template should only be a
3372 // basename, no directory components are allowed. If template is
3373 // %NULL, a default template is used.
3375 // Note that in contrast to g_mkdtemp() (and mkdtemp()) @tmpl is not
3376 // modified, and might thus be a read-only literal string.
3378 // should be freed with g_free() when not needed any longer and is
3379 // is in the GLib file name encoding. In case of errors, %NULL is
3380 // returned and @error will be set.
3381 // RETURNS: The actual name used. This string
3382 // <tmpl>: Template for directory name, as in g_mkdtemp(), basename only, or %NULL for a default template
3383 static char* /*new*/ make_tmp()(char* tmpl, GLib2.Error** error=null) nothrow {
3384 return g_dir_make_tmp(tmpl, error);
3387 // Unintrospectable function: open() / g_dir_open()
3388 // Opens a directory for reading. The names of the files in the
3389 // directory can then be retrieved using g_dir_read_name(). Note
3390 // that the ordering is not defined.
3392 // If non-%NULL, you must free the result with g_dir_close()
3393 // when you are finished with it.
3394 // RETURNS: a newly allocated #GDir on success, %NULL on failure.
3395 // <path>: the path to the directory you are interested in. On Unix in the on-disk encoding. On Windows in UTF-8
3396 // <flags>: Currently must be set to 0. Reserved for future use.
3397 static Dir* open()(char* path, uint flags, GLib2.Error** error=null) nothrow {
3398 return g_dir_open(path, flags, error);
3403 // The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the sign,
3404 // mantissa and exponent of IEEE floats and doubles. These unions are defined
3405 // as appropriate for a given platform. IEEE floats and doubles are supported
3406 // (used for storage) by at least Intel, PPC and Sparc.
3407 union DoubleIEEE754 {
3408 double v_double;
3410 struct mpn {
3411 static import std.bitmanip; mixin(std.bitmanip.bitfields!(
3412 uint, "mantissa_low", 32,
3413 uint, "mantissa_high", 20,
3414 uint, "biased_exponent", 11,
3415 uint, "sign", 1));
3419 enum double E = 2.718282;
3421 // Specifies the type of a function used to test two values for
3422 // equality. The function should return %TRUE if both values are equal
3423 // and %FALSE otherwise.
3424 // RETURNS: %TRUE if @a = @b; %FALSE otherwise
3425 // <a>: a value
3426 // <b>: a value to compare with
3427 extern (C) alias int function (const(void)* a, const(void)* b) nothrow EqualFunc;
3430 // The <structname>GError</structname> structure contains
3431 // information about an error that has occurred.
3432 struct Error {
3433 Quark domain;
3434 int code;
3435 char* message;
3438 // Unintrospectable constructor: new() / g_error_new()
3439 // Creates a new #GError with the given @domain and @code,
3440 // and a message formatted with @format.
3441 // RETURNS: a new #GError
3442 // <domain>: error domain
3443 // <code>: error code
3444 // <format>: printf()-style format for error message
3445 alias g_error_new new_; // Variadic
3447 // Creates a new #GError; unlike g_error_new(), @message is
3448 // not a printf()-style format string. Use this function if
3449 // @message contains text you don't have control over,
3450 // that could include printf() escape sequences.
3451 // RETURNS: a new #GError
3452 // <domain>: error domain
3453 // <code>: error code
3454 // <message>: error message
3455 static Error* /*new*/ new_literal()(Quark domain, int code, char* message) nothrow {
3456 return g_error_new_literal(domain, code, message);
3458 alias new_literal!() opCall;
3460 // Unintrospectable constructor: new_valist() / g_error_new_valist()
3461 // VERSION: 2.22
3462 // Creates a new #GError with the given @domain and @code,
3463 // and a message formatted with @format.
3464 // RETURNS: a new #GError
3465 // <domain>: error domain
3466 // <code>: error code
3467 // <format>: printf()-style format for error message
3468 // <args>: #va_list of parameters for the message format
3469 static Error* /*new*/ new_valist()(Quark domain, int code, char* format, va_list args) nothrow {
3470 return g_error_new_valist(domain, code, format, args);
3472 alias new_valist!() opCall;
3474 // Makes a copy of @error.
3475 // RETURNS: a new #GError
3476 Error* /*new*/ copy()() nothrow {
3477 return g_error_copy(&this);
3479 // Frees a #GError and associated resources.
3480 void free()() nothrow {
3481 g_error_free(&this);
3484 // Returns %TRUE if @error matches @domain and @code, %FALSE
3485 // otherwise. In particular, when @error is %NULL, %FALSE will
3486 // be returned.
3487 // RETURNS: whether @error has @domain and @code
3488 // <domain>: an error domain
3489 // <code>: an error code
3490 int matches()(Quark domain, int code) nothrow {
3491 return g_error_matches(&this, domain, code);
3496 // The possible errors, used in the @v_error field
3497 // of #GTokenValue, when the token is a %G_TOKEN_ERROR.
3498 enum ErrorType {
3499 UNKNOWN = 0,
3500 UNEXP_EOF = 1,
3501 UNEXP_EOF_IN_STRING = 2,
3502 UNEXP_EOF_IN_COMMENT = 3,
3503 NON_DIGIT_IN_CONST = 4,
3504 DIGIT_RADIX = 5,
3505 FLOAT_RADIX = 6,
3506 FLOAT_MALFORMED = 7
3509 // Values corresponding to @errno codes returned from file operations
3510 // on UNIX. Unlike @errno codes, GFileError values are available on
3511 // all systems, even Windows. The exact meaning of each code depends
3512 // on what sort of file operation you were performing; the UNIX
3513 // documentation gives more details. The following error code descriptions
3514 // come from the GNU C Library manual, and are under the copyright
3515 // of that manual.
3517 // It's not very portable to make detailed assumptions about exactly
3518 // which errors will be returned from a given operation. Some errors
3519 // don't occur on some systems, etc., sometimes there are subtle
3520 // differences in when a system will report a given error, etc.
3521 enum FileError {
3522 EXIST = 0,
3523 ISDIR = 1,
3524 ACCES = 2,
3525 NAMETOOLONG = 3,
3526 NOENT = 4,
3527 NOTDIR = 5,
3528 NXIO = 6,
3529 NODEV = 7,
3530 ROFS = 8,
3531 TXTBSY = 9,
3532 FAULT = 10,
3533 LOOP = 11,
3534 NOSPC = 12,
3535 NOMEM = 13,
3536 MFILE = 14,
3537 NFILE = 15,
3538 BADF = 16,
3539 INVAL = 17,
3540 PIPE = 18,
3541 AGAIN = 19,
3542 INTR = 20,
3543 IO = 21,
3544 PERM = 22,
3545 NOSYS = 23,
3546 FAILED = 24
3548 // A test to perform on a file using g_file_test().
3549 enum FileTest {
3550 IS_REGULAR = 1,
3551 IS_SYMLINK = 2,
3552 IS_DIR = 4,
3553 IS_EXECUTABLE = 8,
3554 EXISTS = 16
3557 // The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the sign,
3558 // mantissa and exponent of IEEE floats and doubles. These unions are defined
3559 // as appropriate for a given platform. IEEE floats and doubles are supported
3560 // (used for storage) by at least Intel, PPC and Sparc.
3561 union FloatIEEE754 {
3562 float v_float;
3564 struct mpn {
3565 static import std.bitmanip; mixin(std.bitmanip.bitfields!(
3566 uint, "mantissa", 23,
3567 uint, "biased_exponent", 8,
3568 uint, "sign", 1));
3572 // Flags to modify the format of the string returned by g_format_size_full().
3573 enum FormatSizeFlags {
3574 DEFAULT = 0,
3575 LONG_FORMAT = 1,
3576 IEC_UNITS = 2
3579 // Declares a type of function which takes an arbitrary
3580 // data pointer argument and has no return value. It is
3581 // not currently used in GLib or GTK+.
3582 // <data>: a data pointer
3583 extern (C) alias void function (void* data) nothrow FreeFunc;
3586 // Specifies the type of functions passed to g_list_foreach() and
3587 // g_slist_foreach().
3588 // <data>: the element's data.
3589 // <user_data>: user data passed to g_list_foreach() or g_slist_foreach().
3590 extern (C) alias void function (void* data, void* user_data) nothrow Func;
3592 enum GINT16_FORMAT = "hi";
3593 enum GINT16_MODIFIER = "h";
3594 enum GINT32_FORMAT = "i";
3595 enum GINT32_MODIFIER = "";
3596 enum GINT64_FORMAT = "lli";
3597 enum GINT64_MODIFIER = "ll";
3598 enum GINTPTR_FORMAT = "i";
3599 enum GINTPTR_MODIFIER = "";
3600 enum GNUC_FUNCTION = "";
3601 enum GNUC_PRETTY_FUNCTION = "";
3602 enum GSIZE_FORMAT = "u";
3603 enum GSIZE_MODIFIER = "";
3604 enum GSSIZE_FORMAT = "i";
3605 enum GUINT16_FORMAT = "hu";
3606 enum GUINT32_FORMAT = "u";
3607 enum GUINT64_FORMAT = "llu";
3608 enum GUINTPTR_FORMAT = "u";
3609 enum int HAVE_GINT64 = 1;
3610 enum int HAVE_GNUC_VARARGS = 1;
3611 enum int HAVE_GNUC_VISIBILITY = 1;
3612 enum int HAVE_GROWING_STACK = 1;
3613 enum int HAVE_INLINE = 1;
3614 enum int HAVE_ISO_VARARGS = 1;
3615 enum int HAVE___INLINE = 1;
3616 enum int HAVE___INLINE__ = 1;
3618 // Specifies the type of the function passed to g_hash_table_foreach().
3619 // It is called with each key/value pair, together with the @user_data
3620 // parameter which is passed to g_hash_table_foreach().
3621 // <key>: a key
3622 // <value>: the value corresponding to the key
3623 // <user_data>: user data passed to g_hash_table_foreach()
3624 extern (C) alias void function (void* key, void* value, void* user_data) nothrow HFunc;
3626 enum int HOOK_FLAG_USER_SHIFT = 4;
3628 // Specifies the type of the function passed to
3629 // g_hash_table_foreach_remove(). It is called with each key/value
3630 // pair, together with the @user_data parameter passed to
3631 // g_hash_table_foreach_remove(). It should return %TRUE if the
3632 // key/value pair should be removed from the #GHashTable.
3634 // #GHashTable
3635 // RETURNS: %TRUE if the key/value pair should be removed from the
3636 // <key>: a key
3637 // <value>: the value associated with the key
3638 // <user_data>: user data passed to g_hash_table_remove()
3639 extern (C) alias int function (void* key, void* value, void* user_data) nothrow HRFunc;
3642 // Specifies the type of the hash function which is passed to
3643 // g_hash_table_new() when a #GHashTable is created.
3645 // The function is passed a key and should return a #guint hash value.
3646 // The functions g_direct_hash(), g_int_hash() and g_str_hash() provide
3647 // hash functions which can be used when the key is a #gpointer, #gint*,
3648 // and #gchar* respectively.
3650 // g_direct_hash() is also the appropriate hash function for keys
3651 // of the form <literal>GINT_TO_POINTER (n)</literal> (or similar macros).
3653 // <!-- FIXME: Need more here. --> The hash values should be evenly
3654 // distributed over a fairly large range? The modulus is taken with the
3655 // hash table size (a prime number) to find the 'bucket' to place each
3656 // key into. The function should also be very fast, since it is called
3657 // for each key lookup.
3658 // RETURNS: the hash value corresponding to the key
3659 // <key>: a key
3660 extern (C) alias uint function (const(void)* key) nothrow HashFunc;
3663 // The #GHashTable struct is an opaque data structure to represent a
3664 // <link linkend="glib-Hash-Tables">Hash Table</link>. It should only be
3665 // accessed via the following functions.
3666 struct HashTable {
3668 // VERSION: 2.32
3669 // This is a convenience function for using a #GHashTable as a set. It
3670 // is equivalent to calling g_hash_table_replace() with @key as both the
3671 // key and the value.
3673 // When a hash table only ever contains keys that have themselves as the
3674 // corresponding value it is able to be stored more efficiently. See
3675 // the discussion in the section description.
3676 // <hash_table>: a #GHashTable
3677 // <key>: a key to insert
3678 static void add()(GLib2.HashTable* hash_table, void* key) nothrow {
3679 g_hash_table_add(hash_table, key);
3682 // VERSION: 2.32
3683 // Checks if @key is in @hash_table.
3684 // <hash_table>: a #GHashTable
3685 static int contains()(GLib2.HashTable* hash_table, const(void)* lookup_key) nothrow {
3686 return g_hash_table_contains(hash_table, lookup_key);
3689 // Destroys all keys and values in the #GHashTable and decrements its
3690 // reference count by 1. If keys and/or values are dynamically allocated,
3691 // you should either free them first or create the #GHashTable with destroy
3692 // notifiers using g_hash_table_new_full(). In the latter case the destroy
3693 // functions you supplied will be called on all keys and values during the
3694 // destruction phase.
3695 // <hash_table>: a #GHashTable
3696 static void destroy()(GLib2.HashTable* hash_table) nothrow {
3697 g_hash_table_destroy(hash_table);
3700 // Unintrospectable function: find() / g_hash_table_find()
3701 // VERSION: 2.4
3702 // Calls the given function for key/value pairs in the #GHashTable
3703 // until @predicate returns %TRUE. The function is passed the key
3704 // and value of each pair, and the given @user_data parameter. The
3705 // hash table may not be modified while iterating over it (you can't
3706 // add/remove items).
3708 // Note, that hash tables are really only optimized for forward
3709 // lookups, i.e. g_hash_table_lookup(). So code that frequently issues
3710 // g_hash_table_find() or g_hash_table_foreach() (e.g. in the order of
3711 // once per every entry in a hash table) should probably be reworked
3712 // to use additional or different data structures for reverse lookups
3713 // (keep in mind that an O(n) find/foreach operation issued for all n
3714 // values in a hash table ends up needing O(n*n) operations).
3716 // for which @predicate evaluates to %TRUE. If no pair with the
3717 // requested property is found, %NULL is returned.
3718 // RETURNS: The value of the first key/value pair is returned,
3719 // <hash_table>: a #GHashTable
3720 // <predicate>: function to test the key/value pairs for a certain property
3721 // <user_data>: user data to pass to the function
3722 static void* find()(GLib2.HashTable* hash_table, HRFunc predicate, void* user_data) nothrow {
3723 return g_hash_table_find(hash_table, predicate, user_data);
3726 // Unintrospectable function: foreach() / g_hash_table_foreach()
3727 // Calls the given function for each of the key/value pairs in the
3728 // #GHashTable. The function is passed the key and value of each
3729 // pair, and the given @user_data parameter. The hash table may not
3730 // be modified while iterating over it (you can't add/remove
3731 // items). To remove all items matching a predicate, use
3732 // g_hash_table_foreach_remove().
3734 // See g_hash_table_find() for performance caveats for linear
3735 // order searches in contrast to g_hash_table_lookup().
3736 // <hash_table>: a #GHashTable
3737 // <func>: the function to call for each key/value pair
3738 // <user_data>: user data to pass to the function
3739 static void foreach_()(GLib2.HashTable* hash_table, HFunc func, void* user_data) nothrow {
3740 g_hash_table_foreach(hash_table, func, user_data);
3743 // Unintrospectable function: foreach_remove() / g_hash_table_foreach_remove()
3744 // Calls the given function for each key/value pair in the
3745 // #GHashTable. If the function returns %TRUE, then the key/value
3746 // pair is removed from the #GHashTable. If you supplied key or
3747 // value destroy functions when creating the #GHashTable, they are
3748 // used to free the memory allocated for the removed keys and values.
3750 // See #GHashTableIter for an alternative way to loop over the
3751 // key/value pairs in the hash table.
3752 // RETURNS: the number of key/value pairs removed
3753 // <hash_table>: a #GHashTable
3754 // <func>: the function to call for each key/value pair
3755 // <user_data>: user data to pass to the function
3756 static uint foreach_remove()(GLib2.HashTable* hash_table, HRFunc func, void* user_data) nothrow {
3757 return g_hash_table_foreach_remove(hash_table, func, user_data);
3760 // Unintrospectable function: foreach_steal() / g_hash_table_foreach_steal()
3761 // Calls the given function for each key/value pair in the
3762 // #GHashTable. If the function returns %TRUE, then the key/value
3763 // pair is removed from the #GHashTable, but no key or value
3764 // destroy functions are called.
3766 // See #GHashTableIter for an alternative way to loop over the
3767 // key/value pairs in the hash table.
3768 // RETURNS: the number of key/value pairs removed.
3769 // <hash_table>: a #GHashTable
3770 // <func>: the function to call for each key/value pair
3771 // <user_data>: user data to pass to the function
3772 static uint foreach_steal()(GLib2.HashTable* hash_table, HRFunc func, void* user_data) nothrow {
3773 return g_hash_table_foreach_steal(hash_table, func, user_data);
3776 // Unintrospectable function: get_keys() / g_hash_table_get_keys()
3777 // VERSION: 2.14
3778 // Retrieves every key inside @hash_table. The returned data
3779 // is valid until @hash_table is modified.
3781 // table. The content of the list is owned by the hash table and
3782 // should not be modified or freed. Use g_list_free() when done
3783 // using the list.
3784 // RETURNS: a #GList containing all the keys inside the hash
3785 // <hash_table>: a #GHashTable
3786 static GLib2.List* get_keys()(GLib2.HashTable* hash_table) nothrow {
3787 return g_hash_table_get_keys(hash_table);
3790 // Unintrospectable function: get_values() / g_hash_table_get_values()
3791 // VERSION: 2.14
3792 // Retrieves every value inside @hash_table. The returned data
3793 // is valid until @hash_table is modified.
3795 // table. The content of the list is owned by the hash table and
3796 // should not be modified or freed. Use g_list_free() when done
3797 // using the list.
3798 // RETURNS: a #GList containing all the values inside the hash
3799 // <hash_table>: a #GHashTable
3800 static GLib2.List* get_values()(GLib2.HashTable* hash_table) nothrow {
3801 return g_hash_table_get_values(hash_table);
3804 // Inserts a new key and value into a #GHashTable.
3806 // If the key already exists in the #GHashTable its current
3807 // value is replaced with the new value. If you supplied a
3808 // @value_destroy_func when creating the #GHashTable, the old
3809 // value is freed using that function. If you supplied a
3810 // @key_destroy_func when creating the #GHashTable, the passed
3811 // key is freed using that function.
3812 // <hash_table>: a #GHashTable
3813 // <key>: a key to insert
3814 // <value>: the value to associate with the key
3815 static void insert()(GLib2.HashTable* hash_table, void* key, void* value) nothrow {
3816 g_hash_table_insert(hash_table, key, value);
3819 // Unintrospectable function: lookup() / g_hash_table_lookup()
3820 // Looks up a key in a #GHashTable. Note that this function cannot
3821 // distinguish between a key that is not present and one which is present
3822 // and has the value %NULL. If you need this distinction, use
3823 // g_hash_table_lookup_extended().
3824 // RETURNS: the associated value, or %NULL if the key is not found
3825 // <hash_table>: a #GHashTable
3826 // <key>: the key to look up
3827 static void* lookup()(GLib2.HashTable* hash_table, const(void)* key) nothrow {
3828 return g_hash_table_lookup(hash_table, key);
3831 // Looks up a key in the #GHashTable, returning the original key and the
3832 // associated value and a #gboolean which is %TRUE if the key was found. This
3833 // is useful if you need to free the memory allocated for the original key,
3834 // for example before calling g_hash_table_remove().
3836 // You can actually pass %NULL for @lookup_key to test
3837 // whether the %NULL key exists, provided the hash and equal functions
3838 // of @hash_table are %NULL-safe.
3839 // RETURNS: %TRUE if the key was found in the #GHashTable
3840 // <hash_table>: a #GHashTable
3841 // <lookup_key>: the key to look up
3842 // <orig_key>: return location for the original key, or %NULL
3843 // <value>: return location for the value associated with the key, or %NULL
3844 static int lookup_extended()(GLib2.HashTable* hash_table, const(void)* lookup_key, void** orig_key=null, void** value=null) nothrow {
3845 return g_hash_table_lookup_extended(hash_table, lookup_key, orig_key, value);
3848 // Unintrospectable function: new() / g_hash_table_new()
3849 // Creates a new #GHashTable with a reference count of 1.
3851 // Hash values returned by @hash_func are used to determine where keys
3852 // are stored within the #GHashTable data structure. The g_direct_hash(),
3853 // g_int_hash(), g_int64_hash(), g_double_hash() and g_str_hash()
3854 // functions are provided for some common types of keys.
3855 // If @hash_func is %NULL, g_direct_hash() is used.
3857 // @key_equal_func is used when looking up keys in the #GHashTable.
3858 // The g_direct_equal(), g_int_equal(), g_int64_equal(), g_double_equal()
3859 // and g_str_equal() functions are provided for the most common types
3860 // of keys. If @key_equal_func is %NULL, keys are compared directly in
3861 // a similar fashion to g_direct_equal(), but without the overhead of
3862 // a function call.
3863 // RETURNS: a new #GHashTable
3864 // <hash_func>: a function to create a hash value from a key
3865 // <key_equal_func>: a function to check two keys for equality
3866 static GLib2.HashTable* new_()(HashFunc hash_func, EqualFunc key_equal_func) nothrow {
3867 return g_hash_table_new(hash_func, key_equal_func);
3870 // Unintrospectable function: new_full() / g_hash_table_new_full()
3871 // Creates a new #GHashTable like g_hash_table_new() with a reference
3872 // count of 1 and allows to specify functions to free the memory
3873 // allocated for the key and value that get called when removing the
3874 // entry from the #GHashTable.
3875 // RETURNS: a new #GHashTable
3876 // <hash_func>: a function to create a hash value from a key
3877 // <key_equal_func>: a function to check two keys for equality
3878 // <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.
3879 // <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.
3880 static GLib2.HashTable* new_full()(HashFunc hash_func, EqualFunc key_equal_func, DestroyNotify key_destroy_func, DestroyNotify value_destroy_func) nothrow {
3881 return g_hash_table_new_full(hash_func, key_equal_func, key_destroy_func, value_destroy_func);
3884 // Unintrospectable function: ref() / g_hash_table_ref()
3885 // VERSION: 2.10
3886 // Atomically increments the reference count of @hash_table by one.
3887 // This function is MT-safe and may be called from any thread.
3888 // RETURNS: the passed in #GHashTable
3889 // <hash_table>: a valid #GHashTable
3890 static GLib2.HashTable* ref_()(GLib2.HashTable* hash_table) nothrow {
3891 return g_hash_table_ref(hash_table);
3894 // Removes a key and its associated value from a #GHashTable.
3896 // If the #GHashTable was created using g_hash_table_new_full(), the
3897 // key and value are freed using the supplied destroy functions, otherwise
3898 // you have to make sure that any dynamically allocated values are freed
3899 // yourself.
3900 // RETURNS: %TRUE if the key was found and removed from the #GHashTable
3901 // <hash_table>: a #GHashTable
3902 // <key>: the key to remove
3903 static int remove()(GLib2.HashTable* hash_table, const(void)* key) nothrow {
3904 return g_hash_table_remove(hash_table, key);
3907 // VERSION: 2.12
3908 // Removes all keys and their associated values from a #GHashTable.
3910 // If the #GHashTable was created using g_hash_table_new_full(),
3911 // the keys and values are freed using the supplied destroy functions,
3912 // otherwise you have to make sure that any dynamically allocated
3913 // values are freed yourself.
3914 // <hash_table>: a #GHashTable
3915 static void remove_all()(GLib2.HashTable* hash_table) nothrow {
3916 g_hash_table_remove_all(hash_table);
3919 // Inserts a new key and value into a #GHashTable similar to
3920 // g_hash_table_insert(). The difference is that if the key
3921 // already exists in the #GHashTable, it gets replaced by the
3922 // new key. If you supplied a @value_destroy_func when creating
3923 // the #GHashTable, the old value is freed using that function.
3924 // If you supplied a @key_destroy_func when creating the
3925 // #GHashTable, the old key is freed using that function.
3926 // <hash_table>: a #GHashTable
3927 // <key>: a key to insert
3928 // <value>: the value to associate with the key
3929 static void replace()(GLib2.HashTable* hash_table, void* key, void* value) nothrow {
3930 g_hash_table_replace(hash_table, key, value);
3933 // Returns the number of elements contained in the #GHashTable.
3934 // RETURNS: the number of key/value pairs in the #GHashTable.
3935 // <hash_table>: a #GHashTable
3936 static uint size()(GLib2.HashTable* hash_table) nothrow {
3937 return g_hash_table_size(hash_table);
3940 // Removes a key and its associated value from a #GHashTable without
3941 // calling the key and value destroy functions.
3942 // RETURNS: %TRUE if the key was found and removed from the #GHashTable
3943 // <hash_table>: a #GHashTable
3944 // <key>: the key to remove
3945 static int steal()(GLib2.HashTable* hash_table, const(void)* key) nothrow {
3946 return g_hash_table_steal(hash_table, key);
3949 // VERSION: 2.12
3950 // Removes all keys and their associated values from a #GHashTable
3951 // without calling the key and value destroy functions.
3952 // <hash_table>: a #GHashTable
3953 static void steal_all()(GLib2.HashTable* hash_table) nothrow {
3954 g_hash_table_steal_all(hash_table);
3957 // VERSION: 2.10
3958 // Atomically decrements the reference count of @hash_table by one.
3959 // If the reference count drops to 0, all keys and values will be
3960 // destroyed, and all memory allocated by the hash table is released.
3961 // This function is MT-safe and may be called from any thread.
3962 // <hash_table>: a valid #GHashTable
3963 static void unref()(GLib2.HashTable* hash_table) nothrow {
3964 g_hash_table_unref(hash_table);
3969 // A GHashTableIter structure represents an iterator that can be used
3970 // to iterate over the elements of a #GHashTable. GHashTableIter
3971 // structures are typically allocated on the stack and then initialized
3972 // with g_hash_table_iter_init().
3973 struct HashTableIter {
3974 private void* dummy1, dummy2, dummy3;
3975 private int dummy4;
3976 private int dummy5;
3977 private void* dummy6;
3980 // Unintrospectable method: get_hash_table() / g_hash_table_iter_get_hash_table()
3981 // VERSION: 2.16
3982 // Returns the #GHashTable associated with @iter.
3983 // RETURNS: the #GHashTable associated with @iter.
3984 GLib2.HashTable* get_hash_table()() nothrow {
3985 return g_hash_table_iter_get_hash_table(&this);
3988 // VERSION: 2.16
3989 // Initializes a key/value pair iterator and associates it with
3990 // @hash_table. Modifying the hash table after calling this function
3991 // invalidates the returned iterator.
3992 // |[
3993 // GHashTableIter iter;
3994 // gpointer key, value;
3996 // g_hash_table_iter_init (&iter, hash_table);
3997 // while (g_hash_table_iter_next (&iter, &key, &value))
3998 // {
3999 // /&ast; do something with key and value &ast;/
4000 // }
4001 // ]|
4002 // <hash_table>: a #GHashTable
4003 void init()(GLib2.HashTable* hash_table) nothrow {
4004 g_hash_table_iter_init(&this, hash_table);
4007 // VERSION: 2.16
4008 // Advances @iter and retrieves the key and/or value that are now
4009 // pointed to as a result of this advancement. If %FALSE is returned,
4010 // @key and @value are not set, and the iterator becomes invalid.
4011 // RETURNS: %FALSE if the end of the #GHashTable has been reached.
4012 // <key>: a location to store the key, or %NULL
4013 // <value>: a location to store the value, or %NULL
4014 int next()(void** key, void** value) nothrow {
4015 return g_hash_table_iter_next(&this, key, value);
4018 // VERSION: 2.16
4019 // Removes the key/value pair currently pointed to by the iterator
4020 // from its associated #GHashTable. Can only be called after
4021 // g_hash_table_iter_next() returned %TRUE, and cannot be called
4022 // more than once for the same key/value pair.
4024 // If the #GHashTable was created using g_hash_table_new_full(),
4025 // the key and value are freed using the supplied destroy functions,
4026 // otherwise you have to make sure that any dynamically allocated
4027 // values are freed yourself.
4028 void remove()() nothrow {
4029 g_hash_table_iter_remove(&this);
4032 // VERSION: 2.30
4033 // Replaces the value currently pointed to by the iterator
4034 // from its associated #GHashTable. Can only be called after
4035 // g_hash_table_iter_next() returned %TRUE.
4037 // If you supplied a @value_destroy_func when creating the
4038 // #GHashTable, the old value is freed using that function.
4039 // <value>: the value to replace with
4040 void replace()(void* value) nothrow {
4041 g_hash_table_iter_replace(&this, value);
4044 // VERSION: 2.16
4045 // Removes the key/value pair currently pointed to by the
4046 // iterator from its associated #GHashTable, without calling
4047 // the key and value destroy functions. Can only be called
4048 // after g_hash_table_iter_next() returned %TRUE, and cannot
4049 // be called more than once for the same key/value pair.
4050 void steal()() nothrow {
4051 g_hash_table_iter_steal(&this);
4056 // An opaque structure representing a HMAC operation.
4057 // To create a new GHmac, use g_hmac_new(). To free
4058 // a GHmac, use g_hmac_unref().
4059 struct Hmac /* Version 2.30 */ {
4061 // Unintrospectable method: copy() / g_hmac_copy()
4062 // VERSION: 2.30
4063 // Copies a #GHmac. If @hmac has been closed, by calling
4064 // g_hmac_get_string() or g_hmac_get_digest(), the copied
4065 // HMAC will be closed as well.
4067 // when finished using it.
4068 // RETURNS: the copy of the passed #GHmac. Use g_hmac_unref()
4069 Hmac* copy()() nothrow {
4070 return g_hmac_copy(&this);
4073 // VERSION: 2.30
4074 // Gets the digest from @checksum as a raw binary array and places it
4075 // into @buffer. The size of the digest depends on the type of checksum.
4077 // Once this function has been called, the #GHmac is closed and can
4078 // no longer be updated with g_checksum_update().
4079 // <buffer>: output buffer
4080 // <digest_len>: an inout parameter. The caller initializes it to the size of @buffer. After the call it contains the length of the digest
4081 void get_digest()(ubyte* buffer, size_t* digest_len) nothrow {
4082 g_hmac_get_digest(&this, buffer, digest_len);
4085 // VERSION: 2.30
4086 // Gets the HMAC as an hexadecimal string.
4088 // Once this function has been called the #GHmac can no longer be
4089 // updated with g_hmac_update().
4091 // The hexadecimal characters will be lower case.
4093 // returned string is owned by the HMAC and should not be modified
4094 // or freed.
4095 // RETURNS: the hexadecimal representation of the HMAC. The
4096 char* get_string()() nothrow {
4097 return g_hmac_get_string(&this);
4100 // Unintrospectable method: ref() / g_hmac_ref()
4101 // VERSION: 2.30
4102 // Atomically increments the reference count of @hmac by one.
4104 // This function is MT-safe and may be called from any thread.
4105 // RETURNS: the passed in #GHmac.
4106 Hmac* ref_()() nothrow {
4107 return g_hmac_ref(&this);
4110 // VERSION: 2.30
4111 // Atomically decrements the reference count of @hmac by one.
4113 // If the reference count drops to 0, all keys and values will be
4114 // destroyed, and all memory allocated by the hash table is released.
4115 // This function is MT-safe and may be called from any thread.
4116 // Frees the memory allocated for @hmac.
4117 void unref()() nothrow {
4118 g_hmac_unref(&this);
4121 // VERSION: 2.30
4122 // Feeds @data into an existing #GHmac.
4124 // The HMAC must still be open, that is g_hmac_get_string() or
4125 // g_hmac_get_digest() must not have been called on @hmac.
4126 // <data>: buffer used to compute the checksum
4127 // <length>: size of the buffer, or -1 if it is a nul-terminated string
4128 void update()(ubyte* data, ssize_t length) nothrow {
4129 g_hmac_update(&this, data, length);
4132 // Unintrospectable function: new() / g_hmac_new()
4133 // VERSION: 2.30
4134 // Creates a new #GHmac, using the digest algorithm @digest_type.
4135 // If the @digest_type is not known, %NULL is returned.
4136 // A #GHmac can be used to compute the HMAC of a key and an
4137 // arbitrary binary blob, using different hashing algorithms.
4139 // A #GHmac works by feeding a binary blob through g_hmac_update()
4140 // until the data is complete; the digest can then be extracted
4141 // using g_hmac_get_string(), which will return the checksum as a
4142 // hexadecimal string; or g_hmac_get_digest(), which will return a
4143 // array of raw bytes. Once either g_hmac_get_string() or
4144 // g_hmac_get_digest() have been called on a #GHmac, the HMAC
4145 // will be closed and it won't be possible to call g_hmac_update()
4146 // on it anymore.
4148 // Use g_hmac_unref() to free the memory allocated by it.
4149 // RETURNS: the newly created #GHmac, or %NULL.
4150 // <digest_type>: the desired type of digest
4151 // <key>: the key for the HMAC
4152 // <key_len>: the length of the keys
4153 static Hmac* new_()(ChecksumType digest_type, ubyte* key, size_t key_len) nothrow {
4154 return g_hmac_new(digest_type, key, key_len);
4159 // The <structname>GHook</structname> struct represents a single hook
4160 // function in a #GHookList.
4161 struct Hook {
4162 void* data;
4163 Hook* next, prev;
4164 uint ref_count;
4165 c_ulong hook_id;
4166 uint flags;
4167 void* func;
4168 DestroyNotify destroy_;
4171 // Compares the ids of two #GHook elements, returning a negative value
4172 // if the second id is greater than the first.
4173 // RETURNS: a value &lt;= 0 if the id of @sibling is >= the id of @new_hook
4174 // <sibling>: a #GHook to compare with @new_hook
4175 int compare_ids()(Hook* sibling) nothrow {
4176 return g_hook_compare_ids(&this, sibling);
4179 // Unintrospectable function: alloc() / g_hook_alloc()
4180 // Allocates space for a #GHook and initializes it.
4181 // RETURNS: a new #GHook
4182 // <hook_list>: a #GHookList
4183 static Hook* alloc()(HookList* hook_list) nothrow {
4184 return g_hook_alloc(hook_list);
4187 // Destroys a #GHook, given its ID.
4188 // RETURNS: %TRUE if the #GHook was found in the #GHookList and destroyed
4189 // <hook_list>: a #GHookList
4190 // <hook_id>: a hook ID
4191 static int destroy()(HookList* hook_list, c_ulong hook_id) nothrow {
4192 return g_hook_destroy(hook_list, hook_id);
4195 // Removes one #GHook from a #GHookList, marking it
4196 // inactive and calling g_hook_unref() on it.
4197 // <hook_list>: a #GHookList
4198 // <hook>: the #GHook to remove
4199 static void destroy_link()(HookList* hook_list, Hook* hook) nothrow {
4200 g_hook_destroy_link(hook_list, hook);
4203 // Unintrospectable function: find() / g_hook_find()
4204 // Finds a #GHook in a #GHookList using the given function to
4205 // test for a match.
4206 // RETURNS: the found #GHook or %NULL if no matching #GHook is found
4207 // <hook_list>: a #GHookList
4208 // <need_valids>: %TRUE if #GHook elements which have been destroyed should be skipped
4209 // <func>: the function to call for each #GHook, which should return %TRUE when the #GHook has been found
4210 // <data>: the data to pass to @func
4211 static Hook* find()(HookList* hook_list, int need_valids, HookFindFunc func, void* data) nothrow {
4212 return g_hook_find(hook_list, need_valids, func, data);
4215 // Unintrospectable function: find_data() / g_hook_find_data()
4216 // Finds a #GHook in a #GHookList with the given data.
4218 // #GHook is found
4219 // RETURNS: the #GHook with the given @data or %NULL if no matching
4220 // <hook_list>: a #GHookList
4221 // <need_valids>: %TRUE if #GHook elements which have been destroyed should be skipped
4222 // <data>: the data to find
4223 static Hook* find_data()(HookList* hook_list, int need_valids, void* data) nothrow {
4224 return g_hook_find_data(hook_list, need_valids, data);
4227 // Unintrospectable function: find_func() / g_hook_find_func()
4228 // Finds a #GHook in a #GHookList with the given function.
4230 // #GHook is found
4231 // RETURNS: the #GHook with the given @func or %NULL if no matching
4232 // <hook_list>: a #GHookList
4233 // <need_valids>: %TRUE if #GHook elements which have been destroyed should be skipped
4234 // <func>: the function to find
4235 static Hook* find_func()(HookList* hook_list, int need_valids, void* func) nothrow {
4236 return g_hook_find_func(hook_list, need_valids, func);
4239 // Unintrospectable function: find_func_data() / g_hook_find_func_data()
4240 // Finds a #GHook in a #GHookList with the given function and data.
4242 // no matching #GHook is found
4243 // RETURNS: the #GHook with the given @func and @data or %NULL if
4244 // <hook_list>: a #GHookList
4245 // <need_valids>: %TRUE if #GHook elements which have been destroyed should be skipped
4246 // <func>: the function to find
4247 // <data>: the data to find
4248 static Hook* find_func_data()(HookList* hook_list, int need_valids, void* func, void* data) nothrow {
4249 return g_hook_find_func_data(hook_list, need_valids, func, data);
4252 // Unintrospectable function: first_valid() / g_hook_first_valid()
4253 // Returns the first #GHook in a #GHookList which has not been destroyed.
4254 // The reference count for the #GHook is incremented, so you must call
4255 // g_hook_unref() to restore it when no longer needed. (Or call
4256 // g_hook_next_valid() if you are stepping through the #GHookList.)
4257 // RETURNS: the first valid #GHook, or %NULL if none are valid
4258 // <hook_list>: a #GHookList
4259 // <may_be_in_call>: %TRUE if hooks which are currently running (e.g. in another thread) are considered valid. If set to %FALSE, these are skipped
4260 static Hook* first_valid()(HookList* hook_list, int may_be_in_call) nothrow {
4261 return g_hook_first_valid(hook_list, may_be_in_call);
4264 // Calls the #GHookList @finalize_hook function if it exists,
4265 // and frees the memory allocated for the #GHook.
4266 // <hook_list>: a #GHookList
4267 // <hook>: the #GHook to free
4268 static void free()(HookList* hook_list, Hook* hook) nothrow {
4269 g_hook_free(hook_list, hook);
4272 // Unintrospectable function: get() / g_hook_get()
4273 // Returns the #GHook with the given id, or %NULL if it is not found.
4274 // RETURNS: the #GHook with the given id, or %NULL if it is not found
4275 // <hook_list>: a #GHookList
4276 // <hook_id>: a hook id
4277 static Hook* get()(HookList* hook_list, c_ulong hook_id) nothrow {
4278 return g_hook_get(hook_list, hook_id);
4281 // Inserts a #GHook into a #GHookList, before a given #GHook.
4282 // <hook_list>: a #GHookList
4283 // <sibling>: the #GHook to insert the new #GHook before
4284 // <hook>: the #GHook to insert
4285 static void insert_before()(HookList* hook_list, Hook* sibling, Hook* hook) nothrow {
4286 g_hook_insert_before(hook_list, sibling, hook);
4289 // Unintrospectable function: insert_sorted() / g_hook_insert_sorted()
4290 // Inserts a #GHook into a #GHookList, sorted by the given function.
4291 // <hook_list>: a #GHookList
4292 // <hook>: the #GHook to insert
4293 // <func>: the comparison function used to sort the #GHook elements
4294 static void insert_sorted()(HookList* hook_list, Hook* hook, HookCompareFunc func) nothrow {
4295 g_hook_insert_sorted(hook_list, hook, func);
4298 // Unintrospectable function: next_valid() / g_hook_next_valid()
4299 // Returns the next #GHook in a #GHookList which has not been destroyed.
4300 // The reference count for the #GHook is incremented, so you must call
4301 // g_hook_unref() to restore it when no longer needed. (Or continue to call
4302 // g_hook_next_valid() until %NULL is returned.)
4303 // RETURNS: the next valid #GHook, or %NULL if none are valid
4304 // <hook_list>: a #GHookList
4305 // <hook>: the current #GHook
4306 // <may_be_in_call>: %TRUE if hooks which are currently running (e.g. in another thread) are considered valid. If set to %FALSE, these are skipped
4307 static Hook* next_valid()(HookList* hook_list, Hook* hook, int may_be_in_call) nothrow {
4308 return g_hook_next_valid(hook_list, hook, may_be_in_call);
4311 // Prepends a #GHook on the start of a #GHookList.
4312 // <hook_list>: a #GHookList
4313 // <hook>: the #GHook to add to the start of @hook_list
4314 static void prepend()(HookList* hook_list, Hook* hook) nothrow {
4315 g_hook_prepend(hook_list, hook);
4318 // Unintrospectable function: ref() / g_hook_ref()
4319 // Increments the reference count for a #GHook.
4320 // RETURNS: the @hook that was passed in (since 2.6)
4321 // <hook_list>: a #GHookList
4322 // <hook>: the #GHook to increment the reference count of
4323 static Hook* ref_()(HookList* hook_list, Hook* hook) nothrow {
4324 return g_hook_ref(hook_list, hook);
4327 // Decrements the reference count of a #GHook.
4328 // If the reference count falls to 0, the #GHook is removed
4329 // from the #GHookList and g_hook_free() is called to free it.
4330 // <hook_list>: a #GHookList
4331 // <hook>: the #GHook to unref
4332 static void unref()(HookList* hook_list, Hook* hook) nothrow {
4333 g_hook_unref(hook_list, hook);
4338 // Defines the type of a hook function that can be invoked
4339 // by g_hook_list_invoke_check().
4340 // RETURNS: %FALSE if the #GHook should be destroyed
4341 // <data>: the data field of the #GHook is passed to the hook function here
4342 extern (C) alias int function (void* data) nothrow HookCheckFunc;
4345 // Defines the type of function used by g_hook_list_marshal_check().
4346 // RETURNS: %FALSE if @hook should be destroyed
4347 // <hook>: a #GHook
4348 // <marshal_data>: user data
4349 extern (C) alias int function (Hook* hook, void* marshal_data) nothrow HookCheckMarshaller;
4352 // Defines the type of function used to compare #GHook elements in
4353 // g_hook_insert_sorted().
4354 // RETURNS: a value &lt;= 0 if @new_hook should be before @sibling
4355 // <new_hook>: the #GHook being inserted
4356 // <sibling>: the #GHook to compare with @new_hook
4357 extern (C) alias int function (Hook* new_hook, Hook* sibling) nothrow HookCompareFunc;
4360 // Defines the type of function to be called when a hook in a
4361 // list of hooks gets finalized.
4362 // <hook_list>: a #GHookList
4363 // <hook>: the hook in @hook_list that gets finalized
4364 extern (C) alias void function (HookList* hook_list, Hook* hook) nothrow HookFinalizeFunc;
4367 // Defines the type of the function passed to g_hook_find().
4368 // RETURNS: %TRUE if the required #GHook has been found
4369 // <hook>: a #GHook
4370 // <data>: user data passed to g_hook_find_func()
4371 extern (C) alias int function (Hook* hook, void* data) nothrow HookFindFunc;
4373 // Flags used internally in the #GHook implementation.
4374 enum HookFlagMask {
4375 ACTIVE = 1,
4376 IN_CALL = 2,
4377 MASK = 15
4380 // Defines the type of a hook function that can be invoked
4381 // by g_hook_list_invoke().
4382 // <data>: the data field of the #GHook is passed to the hook function here
4383 extern (C) alias void function (void* data) nothrow HookFunc;
4386 // The <structname>GHookList</structname> struct represents a
4387 // list of hook functions.
4388 struct HookList {
4389 c_ulong seq_id;
4390 static import std.bitmanip; mixin(std.bitmanip.bitfields!(
4391 uint, "hook_size", 16,
4392 uint, "is_setup", 1,
4393 uint, "__dummy32A", 15));
4394 Hook* hooks;
4395 void* dummy3;
4396 HookFinalizeFunc finalize_hook;
4397 void*[2] dummy;
4399 // Removes all the #GHook elements from a #GHookList.
4400 void clear()() nothrow {
4401 g_hook_list_clear(&this);
4404 // Initializes a #GHookList.
4405 // This must be called before the #GHookList is used.
4406 // <hook_size>: the size of each element in the #GHookList, typically <literal>sizeof (GHook)</literal>
4407 void init()(uint hook_size) nothrow {
4408 g_hook_list_init(&this, hook_size);
4411 // Calls all of the #GHook functions in a #GHookList.
4412 // <may_recurse>: %TRUE if functions which are already running (e.g. in another thread) can be called. If set to %FALSE, these are skipped
4413 void invoke()(int may_recurse) nothrow {
4414 g_hook_list_invoke(&this, may_recurse);
4417 // Calls all of the #GHook functions in a #GHookList.
4418 // Any function which returns %FALSE is removed from the #GHookList.
4419 // <may_recurse>: %TRUE if functions which are already running (e.g. in another thread) can be called. If set to %FALSE, these are skipped
4420 void invoke_check()(int may_recurse) nothrow {
4421 g_hook_list_invoke_check(&this, may_recurse);
4424 // Unintrospectable method: marshal() / g_hook_list_marshal()
4425 // Calls a function on each valid #GHook.
4426 // <may_recurse>: %TRUE if hooks which are currently running (e.g. in another thread) are considered valid. If set to %FALSE, these are skipped
4427 // <marshaller>: the function to call for each #GHook
4428 // <marshal_data>: data to pass to @marshaller
4429 void marshal()(int may_recurse, HookMarshaller marshaller, void* marshal_data) nothrow {
4430 g_hook_list_marshal(&this, may_recurse, marshaller, marshal_data);
4433 // Unintrospectable method: marshal_check() / g_hook_list_marshal_check()
4434 // Calls a function on each valid #GHook and destroys it if the
4435 // function returns %FALSE.
4436 // <may_recurse>: %TRUE if hooks which are currently running (e.g. in another thread) are considered valid. If set to %FALSE, these are skipped
4437 // <marshaller>: the function to call for each #GHook
4438 // <marshal_data>: data to pass to @marshaller
4439 void marshal_check()(int may_recurse, HookCheckMarshaller marshaller, void* marshal_data) nothrow {
4440 g_hook_list_marshal_check(&this, may_recurse, marshaller, marshal_data);
4445 // Defines the type of function used by g_hook_list_marshal().
4446 // <hook>: a #GHook
4447 // <marshal_data>: user data
4448 extern (C) alias void function (Hook* hook, void* marshal_data) nothrow HookMarshaller;
4450 struct IConv {
4452 // Same as the standard UNIX routine iconv(), but
4453 // may be implemented via libiconv on UNIX flavors that lack
4454 // a native implementation.
4456 // GLib provides g_convert() and g_locale_to_utf8() which are likely
4457 // more convenient than the raw iconv wrappers.
4458 // RETURNS: count of non-reversible conversions, or -1 on error
4459 // <inbuf>: bytes to convert
4460 // <inbytes_left>: inout parameter, bytes remaining to convert in @inbuf
4461 // <outbuf>: converted output bytes
4462 // <outbytes_left>: inout parameter, bytes available to fill in @outbuf
4463 size_t /*NAME MISSING IN GIR*/ iconv()(char** inbuf, size_t* inbytes_left, char** outbuf, size_t* outbytes_left) nothrow {
4464 return g_iconv(&this, inbuf, inbytes_left, outbuf, outbytes_left);
4467 // Same as the standard UNIX routine iconv_close(), but
4468 // may be implemented via libiconv on UNIX flavors that lack
4469 // a native implementation. Should be called to clean up
4470 // the conversion descriptor from g_iconv_open() when
4471 // you are done converting things.
4473 // GLib provides g_convert() and g_locale_to_utf8() which are likely
4474 // more convenient than the raw iconv wrappers.
4475 // RETURNS: -1 on error, 0 on success
4476 int close()() nothrow {
4477 return g_iconv_close(&this);
4480 // Unintrospectable function: open() / g_iconv_open()
4481 // Same as the standard UNIX routine iconv_open(), but
4482 // may be implemented via libiconv on UNIX flavors that lack
4483 // a native implementation.
4485 // GLib provides g_convert() and g_locale_to_utf8() which are likely
4486 // more convenient than the raw iconv wrappers.
4488 // opening the converter failed.
4489 // RETURNS: a "conversion descriptor", or (GIConv)-1 if
4490 // <to_codeset>: destination codeset
4491 // <from_codeset>: source codeset
4492 static IConv open()(char* to_codeset, char* from_codeset) nothrow {
4493 return g_iconv_open(to_codeset, from_codeset);
4497 enum int IEEE754_DOUBLE_BIAS = 1023;
4498 enum int IEEE754_FLOAT_BIAS = 127;
4500 // A data structure representing an IO Channel. The fields should be
4501 // considered private and should only be accessed with the following
4502 // functions.
4503 struct IOChannel {
4504 private int ref_count;
4505 private IOFuncs* funcs;
4506 private char* encoding;
4507 private IConv read_cd, write_cd;
4508 private char* line_term;
4509 private uint line_term_len;
4510 private size_t buf_size;
4511 private String* read_buf, encoded_read_buf, write_buf;
4512 private char[6] partial_write_buf;
4513 static import std.bitmanip; mixin(std.bitmanip.bitfields!(
4514 uint, "use_buffer", 1,
4515 uint, "do_encode", 1,
4516 uint, "close_on_unref", 1,
4517 uint, "is_readable", 1,
4518 uint, "is_writeable", 1,
4519 uint, "is_seekable", 1,
4520 uint, "__dummy32A", 26));
4521 private void* reserved1, reserved2;
4524 // Open a file @filename as a #GIOChannel using mode @mode. This
4525 // channel will be closed when the last reference to it is dropped,
4526 // so there is no need to call g_io_channel_close() (though doing
4527 // so will not cause problems, as long as no attempt is made to
4528 // access the channel after it is closed).
4529 // RETURNS: A #GIOChannel on success, %NULL on failure.
4530 // <filename>: A string containing the name of a file
4531 // <mode>: One of "r", "w", "a", "r+", "w+", "a+". These have the same meaning as in fopen()
4532 static IOChannel* /*new*/ new_file()(char* filename, char* mode, GLib2.Error** error=null) nothrow {
4533 return g_io_channel_new_file(filename, mode, error);
4535 alias new_file!() opCall;
4537 // Creates a new #GIOChannel given a file descriptor. On UNIX systems
4538 // this works for plain files, pipes, and sockets.
4540 // The returned #GIOChannel has a reference count of 1.
4542 // The default encoding for #GIOChannel is UTF-8. If your application
4543 // is reading output from a command using via pipe, you may need to set
4544 // the encoding to the encoding of the current locale (see
4545 // g_get_charset()) with the g_io_channel_set_encoding() function.
4547 // If you want to read raw binary data without interpretation, then
4548 // call the g_io_channel_set_encoding() function with %NULL for the
4549 // encoding argument.
4551 // This function is available in GLib on Windows, too, but you should
4552 // avoid using it on Windows. The domain of file descriptors and
4553 // sockets overlap. There is no way for GLib to know which one you mean
4554 // in case the argument you pass to this function happens to be both a
4555 // valid file descriptor and socket. If that happens a warning is
4556 // issued, and GLib assumes that it is the file descriptor you mean.
4557 // <fd>: a file descriptor.
4558 static IOChannel* /*new*/ unix_new()(int fd) nothrow {
4559 return g_io_channel_unix_new(fd);
4561 alias unix_new!() opCall;
4563 // Close an IO channel. Any pending data to be written will be
4564 // flushed, ignoring errors. The channel will not be freed until the
4565 // last reference is dropped using g_io_channel_unref().
4567 // Deprecated:2.2: Use g_io_channel_shutdown() instead.
4568 void close()() nothrow {
4569 g_io_channel_close(&this);
4572 // Flushes the write buffer for the GIOChannel.
4574 // #G_IO_STATUS_NORMAL, #G_IO_STATUS_AGAIN, or
4575 // #G_IO_STATUS_ERROR.
4576 // RETURNS: the status of the operation: One of
4577 IOStatus flush()(GLib2.Error** error=null) nothrow {
4578 return g_io_channel_flush(&this, error);
4581 // This function returns a #GIOCondition depending on whether there
4582 // is data to be read/space to write data in the internal buffers in
4583 // the #GIOChannel. Only the flags %G_IO_IN and %G_IO_OUT may be set.
4584 // RETURNS: A #GIOCondition
4585 IOCondition get_buffer_condition()() nothrow {
4586 return g_io_channel_get_buffer_condition(&this);
4589 // Gets the buffer size.
4590 // RETURNS: the size of the buffer.
4591 size_t get_buffer_size()() nothrow {
4592 return g_io_channel_get_buffer_size(&this);
4595 // Returns whether @channel is buffered.
4596 // RETURNS: %TRUE if the @channel is buffered.
4597 int get_buffered()() nothrow {
4598 return g_io_channel_get_buffered(&this);
4601 // Returns whether the file/socket/whatever associated with @channel
4602 // will be closed when @channel receives its final unref and is
4603 // destroyed. The default value of this is %TRUE for channels created
4604 // by g_io_channel_new_file (), and %FALSE for all other channels.
4606 // the GIOChannel data structure.
4607 // RETURNS: Whether the channel will be closed on the final unref of
4608 int get_close_on_unref()() nothrow {
4609 return g_io_channel_get_close_on_unref(&this);
4612 // Gets the encoding for the input/output of the channel.
4613 // The internal encoding is always UTF-8. The encoding %NULL
4614 // makes the channel safe for binary data.
4616 // owned by GLib and must not be freed.
4617 // RETURNS: A string containing the encoding, this string is
4618 char* get_encoding()() nothrow {
4619 return g_io_channel_get_encoding(&this);
4622 // Gets the current flags for a #GIOChannel, including read-only
4623 // flags such as %G_IO_FLAG_IS_READABLE.
4625 // The values of the flags %G_IO_FLAG_IS_READABLE and %G_IO_FLAG_IS_WRITABLE
4626 // are cached for internal use by the channel when it is created.
4627 // If they should change at some later point (e.g. partial shutdown
4628 // of a socket with the UNIX shutdown() function), the user
4629 // should immediately call g_io_channel_get_flags() to update
4630 // the internal values of these flags.
4631 // RETURNS: the flags which are set on the channel
4632 IOFlags get_flags()() nothrow {
4633 return g_io_channel_get_flags(&this);
4636 // This returns the string that #GIOChannel uses to determine
4637 // where in the file a line break occurs. A value of %NULL
4638 // indicates autodetection.
4640 // is owned by GLib and must not be freed.
4641 // RETURNS: The line termination string. This value
4642 // <length>: a location to return the length of the line terminator
4643 char* get_line_term()(int* length) nothrow {
4644 return g_io_channel_get_line_term(&this, length);
4647 // Initializes a #GIOChannel struct.
4649 // This is called by each of the above functions when creating a
4650 // #GIOChannel, and so is not often needed by the application
4651 // programmer (unless you are creating a new type of #GIOChannel).
4652 void init()() nothrow {
4653 g_io_channel_init(&this);
4656 // Reads data from a #GIOChannel.
4659 // Deprecated:2.2: Use g_io_channel_read_chars() instead.
4660 // RETURNS: %G_IO_ERROR_NONE if the operation was successful.
4661 // <buf>: a buffer to read the data into (which should be at least count bytes long)
4662 // <count>: the number of bytes to read from the #GIOChannel
4663 // <bytes_read>: returns the number of bytes actually read
4664 IOError read()(char* buf, size_t count, size_t* bytes_read) nothrow {
4665 return g_io_channel_read(&this, buf, count, bytes_read);
4668 // Replacement for g_io_channel_read() with the new API.
4669 // RETURNS: the status of the operation.
4670 // <buf>: a buffer to read data into
4671 // <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.
4672 // <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.
4673 IOStatus read_chars()(char* buf, size_t count, size_t* bytes_read, GLib2.Error** error=null) nothrow {
4674 return g_io_channel_read_chars(&this, buf, count, bytes_read, error);
4677 // Reads a line, including the terminating character(s),
4678 // from a #GIOChannel into a newly-allocated string.
4679 // @str_return will contain allocated memory if the return
4680 // is %G_IO_STATUS_NORMAL.
4681 // RETURNS: the status of the operation.
4682 // <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.
4683 // <length>: location to store length of the read data, or %NULL
4684 // <terminator_pos>: location to store position of line terminator, or %NULL
4685 IOStatus read_line()(char** str_return, size_t* length, size_t* terminator_pos, GLib2.Error** error=null) nothrow {
4686 return g_io_channel_read_line(&this, str_return, length, terminator_pos, error);
4689 // Reads a line from a #GIOChannel, using a #GString as a buffer.
4690 // RETURNS: the status of the operation.
4691 // <buffer>: a #GString into which the line will be written. If @buffer already contains data, the old data will be overwritten.
4692 // <terminator_pos>: location to store position of line terminator, or %NULL
4693 IOStatus read_line_string()(String* buffer, size_t* terminator_pos, GLib2.Error** error=null) nothrow {
4694 return g_io_channel_read_line_string(&this, buffer, terminator_pos, error);
4697 // Reads all the remaining data from the file.
4699 // This function never returns %G_IO_STATUS_EOF.
4700 // RETURNS: %G_IO_STATUS_NORMAL on success.
4701 // <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.
4702 // <length>: location to store length of the data
4703 IOStatus read_to_end()(char** str_return, size_t* length, GLib2.Error** error=null) nothrow {
4704 return g_io_channel_read_to_end(&this, str_return, length, error);
4707 // Reads a Unicode character from @channel.
4708 // This function cannot be called on a channel with %NULL encoding.
4709 // RETURNS: a #GIOStatus
4710 // <thechar>: a location to return a character
4711 IOStatus read_unichar()(dchar* thechar, GLib2.Error** error=null) nothrow {
4712 return g_io_channel_read_unichar(&this, thechar, error);
4715 // Increments the reference count of a #GIOChannel.
4716 // RETURNS: the @channel that was passed in (since 2.6)
4717 IOChannel* /*new*/ ref_()() nothrow {
4718 return g_io_channel_ref(&this);
4721 // Sets the current position in the #GIOChannel, similar to the standard
4722 // library function fseek().
4725 // Deprecated:2.2: Use g_io_channel_seek_position() instead.
4726 // RETURNS: %G_IO_ERROR_NONE if the operation was successful.
4727 // <offset>: an offset, in bytes, which is added to the position specified by @type
4728 // <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)
4729 IOError seek()(long offset, SeekType type) nothrow {
4730 return g_io_channel_seek(&this, offset, type);
4733 // Replacement for g_io_channel_seek() with the new API.
4734 // RETURNS: the status of the operation.
4735 // <offset>: The offset in bytes from the position specified by @type
4736 // <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.
4737 IOStatus seek_position()(long offset, SeekType type, GLib2.Error** error=null) nothrow {
4738 return g_io_channel_seek_position(&this, offset, type, error);
4741 // Sets the buffer size.
4742 // <size>: the size of the buffer, or 0 to let GLib pick a good size
4743 void set_buffer_size()(size_t size) nothrow {
4744 g_io_channel_set_buffer_size(&this, size);
4747 // The buffering state can only be set if the channel's encoding
4748 // is %NULL. For any other encoding, the channel must be buffered.
4750 // A buffered channel can only be set unbuffered if the channel's
4751 // internal buffers have been flushed. Newly created channels or
4752 // channels which have returned %G_IO_STATUS_EOF
4753 // not require such a flush. For write-only channels, a call to
4754 // g_io_channel_flush () is sufficient. For all other channels,
4755 // the buffers may be flushed by a call to g_io_channel_seek_position ().
4756 // This includes the possibility of seeking with seek type %G_SEEK_CUR
4757 // and an offset of zero. Note that this means that socket-based
4758 // channels cannot be set unbuffered once they have had data
4759 // read from them.
4761 // On unbuffered channels, it is safe to mix read and write
4762 // calls from the new and old APIs, if this is necessary for
4763 // maintaining old code.
4765 // The default state of the channel is buffered.
4766 // <buffered>: whether to set the channel buffered or unbuffered
4767 void set_buffered()(int buffered) nothrow {
4768 g_io_channel_set_buffered(&this, buffered);
4771 // Setting this flag to %TRUE for a channel you have already closed
4772 // can cause problems.
4773 // <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.
4774 void set_close_on_unref()(int do_close) nothrow {
4775 g_io_channel_set_close_on_unref(&this, do_close);
4778 // Sets the encoding for the input/output of the channel.
4779 // The internal encoding is always UTF-8. The default encoding
4780 // for the external file is UTF-8.
4782 // The encoding %NULL is safe to use with binary data.
4784 // The encoding can only be set if one of the following conditions
4785 // is true:
4786 // <itemizedlist>
4787 // <listitem><para>
4788 // The channel was just created, and has not been written to or read
4789 // from yet.
4790 // </para></listitem>
4791 // <listitem><para>
4792 // The channel is write-only.
4793 // </para></listitem>
4794 // <listitem><para>
4795 // The channel is a file, and the file pointer was just
4796 // repositioned by a call to g_io_channel_seek_position().
4797 // (This flushes all the internal buffers.)
4798 // </para></listitem>
4799 // <listitem><para>
4800 // The current encoding is %NULL or UTF-8.
4801 // </para></listitem>
4802 // <listitem><para>
4803 // One of the (new API) read functions has just returned %G_IO_STATUS_EOF
4804 // (or, in the case of g_io_channel_read_to_end(), %G_IO_STATUS_NORMAL).
4805 // </para></listitem>
4806 // <listitem><para>
4807 // One of the functions g_io_channel_read_chars() or
4808 // g_io_channel_read_unichar() has returned %G_IO_STATUS_AGAIN or
4809 // %G_IO_STATUS_ERROR. This may be useful in the case of
4810 // %G_CONVERT_ERROR_ILLEGAL_SEQUENCE.
4811 // Returning one of these statuses from g_io_channel_read_line(),
4812 // g_io_channel_read_line_string(), or g_io_channel_read_to_end()
4813 // does <emphasis>not</emphasis> guarantee that the encoding can
4814 // be changed.
4815 // </para></listitem>
4816 // </itemizedlist>
4817 // Channels which do not meet one of the above conditions cannot call
4818 // g_io_channel_seek_position() with an offset of %G_SEEK_CUR, and, if
4819 // they are "seekable", cannot call g_io_channel_write_chars() after
4820 // calling one of the API "read" functions.
4821 // RETURNS: %G_IO_STATUS_NORMAL if the encoding was successfully set.
4822 // <encoding>: the encoding type
4823 IOStatus set_encoding()(char* encoding, GLib2.Error** error=null) nothrow {
4824 return g_io_channel_set_encoding(&this, encoding, error);
4827 // Sets the (writeable) flags in @channel to (@flags & %G_IO_FLAG_SET_MASK).
4828 // RETURNS: the status of the operation.
4829 // <flags>: the flags to set on the IO channel
4830 IOStatus set_flags()(IOFlags flags, GLib2.Error** error=null) nothrow {
4831 return g_io_channel_set_flags(&this, flags, error);
4834 // This sets the string that #GIOChannel uses to determine
4835 // where in the file a line break occurs.
4836 // <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.
4837 // <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.
4838 void set_line_term()(char* line_term, int length) nothrow {
4839 g_io_channel_set_line_term(&this, line_term, length);
4842 // Close an IO channel. Any pending data to be written will be
4843 // flushed if @flush is %TRUE. The channel will not be freed until the
4844 // last reference is dropped using g_io_channel_unref().
4845 // RETURNS: the status of the operation.
4846 // <flush>: if %TRUE, flush pending
4847 IOStatus shutdown()(int flush, GLib2.Error** error=null) nothrow {
4848 return g_io_channel_shutdown(&this, flush, error);
4851 // Returns the file descriptor of the #GIOChannel.
4853 // On Windows this function returns the file descriptor or socket of
4854 // the #GIOChannel.
4855 int unix_get_fd()() nothrow {
4856 return g_io_channel_unix_get_fd(&this);
4858 // Decrements the reference count of a #GIOChannel.
4859 void unref()() nothrow {
4860 g_io_channel_unref(&this);
4863 // Writes data to a #GIOChannel.
4866 // Deprecated:2.2: Use g_io_channel_write_chars() instead.
4867 // RETURNS: %G_IO_ERROR_NONE if the operation was successful.
4868 // <buf>: the buffer containing the data to write
4869 // <count>: the number of bytes to write
4870 // <bytes_written>: the number of bytes actually written
4871 IOError write()(char* buf, size_t count, size_t* bytes_written) nothrow {
4872 return g_io_channel_write(&this, buf, count, bytes_written);
4875 // Replacement for g_io_channel_write() with the new API.
4877 // On seekable channels with encodings other than %NULL or UTF-8, generic
4878 // mixing of reading and writing is not allowed. A call to g_io_channel_write_chars ()
4879 // may only be made on a channel from which data has been read in the
4880 // cases described in the documentation for g_io_channel_set_encoding ().
4881 // RETURNS: the status of the operation.
4882 // <buf>: a buffer to write data from
4883 // <count>: the size of the buffer. If -1, the buffer is taken to be a nul-terminated string.
4884 // <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.
4885 IOStatus write_chars()(char* buf, ssize_t count, size_t* bytes_written, GLib2.Error** error=null) nothrow {
4886 return g_io_channel_write_chars(&this, buf, count, bytes_written, error);
4889 // Writes a Unicode character to @channel.
4890 // This function cannot be called on a channel with %NULL encoding.
4891 // RETURNS: a #GIOStatus
4892 // <thechar>: a character
4893 IOStatus write_unichar()(dchar thechar, GLib2.Error** error=null) nothrow {
4894 return g_io_channel_write_unichar(&this, thechar, error);
4897 // Converts an <literal>errno</literal> error number to a #GIOChannelError.
4899 // %G_IO_CHANNEL_ERROR_INVAL.
4900 // RETURNS: a #GIOChannelError error number, e.g.
4901 // <en>: an <literal>errno</literal> error number, e.g. <literal>EINVAL</literal>
4902 static IOChannelError error_from_errno()(int en) nothrow {
4903 return g_io_channel_error_from_errno(en);
4905 // RETURNS: the quark used as %G_IO_CHANNEL_ERROR
4906 static Quark error_quark()() nothrow {
4907 return g_io_channel_error_quark();
4911 // Error codes returned by #GIOChannel operations.
4912 enum IOChannelError {
4913 FBIG = 0,
4914 INVAL = 1,
4915 IO = 2,
4916 ISDIR = 3,
4917 NOSPC = 4,
4918 NXIO = 5,
4919 OVERFLOW = 6,
4920 PIPE = 7,
4921 FAILED = 8
4924 // A bitwise combination representing a condition to watch for on an
4925 // event source.
4926 enum IOCondition {
4927 IN = 1,
4928 OUT = 4,
4929 PRI = 2,
4930 ERR = 8,
4931 HUP = 16,
4932 NVAL = 32
4935 // #GIOError is only used by the deprecated functions
4936 // g_io_channel_read(), g_io_channel_write(), and g_io_channel_seek().
4937 enum IOError {
4938 NONE = 0,
4939 AGAIN = 1,
4940 INVAL = 2,
4941 UNKNOWN = 3
4944 // Specifies properties of a #GIOChannel. Some of the flags can only be
4945 // read with g_io_channel_get_flags(), but not changed with
4946 // g_io_channel_set_flags().
4947 enum IOFlags {
4948 APPEND = 1,
4949 NONBLOCK = 2,
4950 IS_READABLE = 4,
4951 IS_WRITABLE = 8,
4952 IS_SEEKABLE = 16,
4953 MASK = 31,
4954 GET_MASK = 31,
4955 SET_MASK = 3
4958 // Specifies the type of function passed to g_io_add_watch() or
4959 // g_io_add_watch_full(), which is called when the requested condition
4960 // on a #GIOChannel is satisfied.
4961 // <source>: the #GIOChannel event source
4962 // <condition>: the condition which has been satisfied
4963 // <data>: user data set in g_io_add_watch() or g_io_add_watch_full()
4964 extern (C) alias int function (IOChannel* source, IOCondition condition, void* data) nothrow IOFunc;
4967 // A table of functions used to handle different types of #GIOChannel
4968 // in a generic way.
4969 struct IOFuncs {
4970 extern (C) IOStatus function (IOChannel* channel, char* buf, size_t count, size_t* bytes_read, GLib2.Error** error=null) nothrow io_read;
4971 extern (C) IOStatus function (IOChannel* channel, char* buf, size_t count, size_t* bytes_written, GLib2.Error** error=null) nothrow io_write;
4972 extern (C) IOStatus function (IOChannel* channel, long offset, SeekType type, GLib2.Error** error=null) nothrow io_seek;
4973 extern (C) IOStatus function (IOChannel* channel, GLib2.Error** error=null) nothrow io_close;
4974 extern (C) Source* /*new*/ function (IOChannel* channel, IOCondition condition) nothrow io_create_watch;
4975 extern (C) void function (IOChannel* channel) nothrow io_free;
4976 extern (C) IOStatus function (IOChannel* channel, IOFlags flags, GLib2.Error** error=null) nothrow io_set_flags;
4977 extern (C) IOFlags function (IOChannel* channel) nothrow io_get_flags;
4980 // Stati returned by most of the #GIOFuncs functions.
4981 enum IOStatus {
4982 ERROR = 0,
4983 NORMAL = 1,
4984 EOF = 2,
4985 AGAIN = 3
4987 enum KEY_FILE_DESKTOP_GROUP = "Desktop Entry";
4988 enum KEY_FILE_DESKTOP_KEY_CATEGORIES = "Categories";
4989 enum KEY_FILE_DESKTOP_KEY_COMMENT = "Comment";
4990 enum KEY_FILE_DESKTOP_KEY_EXEC = "Exec";
4991 enum KEY_FILE_DESKTOP_KEY_GENERIC_NAME = "GenericName";
4992 enum KEY_FILE_DESKTOP_KEY_HIDDEN = "Hidden";
4993 enum KEY_FILE_DESKTOP_KEY_ICON = "Icon";
4994 enum KEY_FILE_DESKTOP_KEY_MIME_TYPE = "MimeType";
4995 enum KEY_FILE_DESKTOP_KEY_NAME = "Name";
4996 enum KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN = "NotShowIn";
4997 enum KEY_FILE_DESKTOP_KEY_NO_DISPLAY = "NoDisplay";
4998 enum KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN = "OnlyShowIn";
4999 enum KEY_FILE_DESKTOP_KEY_PATH = "Path";
5000 enum KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY = "StartupNotify";
5001 enum KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS = "StartupWMClass";
5002 enum KEY_FILE_DESKTOP_KEY_TERMINAL = "Terminal";
5003 enum KEY_FILE_DESKTOP_KEY_TRY_EXEC = "TryExec";
5004 enum KEY_FILE_DESKTOP_KEY_TYPE = "Type";
5005 enum KEY_FILE_DESKTOP_KEY_URL = "URL";
5006 enum KEY_FILE_DESKTOP_KEY_VERSION = "Version";
5007 enum KEY_FILE_DESKTOP_TYPE_APPLICATION = "Application";
5008 enum KEY_FILE_DESKTOP_TYPE_DIRECTORY = "Directory";
5009 enum KEY_FILE_DESKTOP_TYPE_LINK = "Link";
5011 // The GKeyFile struct contains only private data
5012 // and should not be accessed directly.
5013 struct KeyFile {
5015 // VERSION: 2.6
5016 // Creates a new empty #GKeyFile object. Use
5017 // g_key_file_load_from_file(), g_key_file_load_from_data(),
5018 // g_key_file_load_from_dirs() or g_key_file_load_from_data_dirs() to
5019 // read an existing key file.
5020 // RETURNS: an empty #GKeyFile.
5021 static KeyFile* /*new*/ new_()() nothrow {
5022 return g_key_file_new();
5024 alias new_!() opCall;
5026 // Unintrospectable method: free() / g_key_file_free()
5027 // VERSION: 2.6
5028 // Clears all keys and groups from @key_file, and decreases the
5029 // reference count by 1. If the reference count reaches zero,
5030 // frees the key file and all its allocated memory.
5031 void free()() nothrow {
5032 g_key_file_free(&this);
5035 // VERSION: 2.6
5036 // Returns the value associated with @key under @group_name as a
5037 // boolean.
5039 // If @key cannot be found then %FALSE is returned and @error is set
5040 // to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value
5041 // associated with @key cannot be interpreted as a boolean then %FALSE
5042 // is returned and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
5044 // or %FALSE if the key was not found or could not be parsed.
5045 // RETURNS: the value associated with the key as a boolean,
5046 // <group_name>: a group name
5047 // <key>: a key
5048 int get_boolean()(char* group_name, char* key, GLib2.Error** error=null) nothrow {
5049 return g_key_file_get_boolean(&this, group_name, key, error);
5052 // VERSION: 2.6
5053 // Returns the values associated with @key under @group_name as
5054 // booleans.
5056 // If @key cannot be found then %NULL is returned and @error is set to
5057 // #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
5058 // with @key cannot be interpreted as booleans then %NULL is returned
5059 // and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
5061 // the values associated with the key as a list of booleans, or %NULL if the
5062 // key was not found or could not be parsed. The returned list of booleans
5063 // should be freed with g_free() when no longer needed.
5064 // <group_name>: a group name
5065 // <key>: a key
5066 // <length>: the number of booleans returned
5067 int* /*new container*/ get_boolean_list()(char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error=null) nothrow {
5068 return g_key_file_get_boolean_list(&this, group_name, key, length, error);
5071 // VERSION: 2.6
5072 // Retrieves a comment above @key from @group_name.
5073 // If @key is %NULL then @comment will be read from above
5074 // @group_name. If both @key and @group_name are %NULL, then
5075 // @comment will be read from above the first group in the file.
5076 // RETURNS: a comment that should be freed with g_free()
5077 // <group_name>: a group name, or %NULL
5078 // <key>: a key
5079 char* /*new*/ get_comment()(char* group_name, char* key, GLib2.Error** error=null) nothrow {
5080 return g_key_file_get_comment(&this, group_name, key, error);
5083 // VERSION: 2.12
5084 // Returns the value associated with @key under @group_name as a
5085 // double. If @group_name is %NULL, the start_group is used.
5087 // If @key cannot be found then 0.0 is returned and @error is set to
5088 // #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated
5089 // with @key cannot be interpreted as a double then 0.0 is returned
5090 // and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
5092 // 0.0 if the key was not found or could not be parsed.
5093 // RETURNS: the value associated with the key as a double, or
5094 // <group_name>: a group name
5095 // <key>: a key
5096 double get_double()(char* group_name, char* key, GLib2.Error** error=null) nothrow {
5097 return g_key_file_get_double(&this, group_name, key, error);
5100 // VERSION: 2.12
5101 // Returns the values associated with @key under @group_name as
5102 // doubles.
5104 // If @key cannot be found then %NULL is returned and @error is set to
5105 // #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
5106 // with @key cannot be interpreted as doubles then %NULL is returned
5107 // and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
5109 // the values associated with the key as a list of doubles, or %NULL if the
5110 // key was not found or could not be parsed. The returned list of doubles
5111 // should be freed with g_free() when no longer needed.
5112 // <group_name>: a group name
5113 // <key>: a key
5114 // <length>: the number of doubles returned
5115 double* /*new container*/ get_double_list()(char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error=null) nothrow {
5116 return g_key_file_get_double_list(&this, group_name, key, length, error);
5119 // VERSION: 2.6
5120 // Returns all groups in the key file loaded with @key_file.
5121 // The array of returned groups will be %NULL-terminated, so
5122 // @length may optionally be %NULL.
5124 // Use g_strfreev() to free it.
5125 // RETURNS: a newly-allocated %NULL-terminated array of strings.
5126 // <length>: return location for the number of returned groups, or %NULL
5127 char** /*new*/ get_groups()(/*out*/ size_t* length=null) nothrow {
5128 return g_key_file_get_groups(&this, length);
5131 // VERSION: 2.26
5132 // Returns the value associated with @key under @group_name as a signed
5133 // 64-bit integer. This is similar to g_key_file_get_integer() but can return
5134 // 64-bit results without truncation.
5136 // 0 if the key was not found or could not be parsed.
5137 // RETURNS: the value associated with the key as a signed 64-bit integer, or
5138 // <group_name>: a non-%NULL group name
5139 // <key>: a non-%NULL key
5140 long get_int64()(char* group_name, char* key, GLib2.Error** error=null) nothrow {
5141 return g_key_file_get_int64(&this, group_name, key, error);
5144 // VERSION: 2.6
5145 // Returns the value associated with @key under @group_name as an
5146 // integer.
5148 // If @key cannot be found then 0 is returned and @error is set to
5149 // #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated
5150 // with @key cannot be interpreted as an integer then 0 is returned
5151 // and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
5153 // 0 if the key was not found or could not be parsed.
5154 // RETURNS: the value associated with the key as an integer, or
5155 // <group_name>: a group name
5156 // <key>: a key
5157 int get_integer()(char* group_name, char* key, GLib2.Error** error=null) nothrow {
5158 return g_key_file_get_integer(&this, group_name, key, error);
5161 // VERSION: 2.6
5162 // Returns the values associated with @key under @group_name as
5163 // integers.
5165 // If @key cannot be found then %NULL is returned and @error is set to
5166 // #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
5167 // with @key cannot be interpreted as integers then %NULL is returned
5168 // and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
5170 // the values associated with the key as a list of integers, or %NULL if
5171 // the key was not found or could not be parsed. The returned list of
5172 // integers should be freed with g_free() when no longer needed.
5173 // <group_name>: a group name
5174 // <key>: a key
5175 // <length>: the number of integers returned
5176 int* /*new container*/ get_integer_list()(char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error=null) nothrow {
5177 return g_key_file_get_integer_list(&this, group_name, key, length, error);
5180 // VERSION: 2.6
5181 // Returns all keys for the group name @group_name. The array of
5182 // returned keys will be %NULL-terminated, so @length may
5183 // optionally be %NULL. In the event that the @group_name cannot
5184 // be found, %NULL is returned and @error is set to
5185 // #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
5187 // Use g_strfreev() to free it.
5188 // RETURNS: a newly-allocated %NULL-terminated array of strings.
5189 // <group_name>: a group name
5190 // <length>: return location for the number of keys returned, or %NULL
5191 char** /*new*/ get_keys()(char* group_name, /*out*/ size_t* length, GLib2.Error** error=null) nothrow {
5192 return g_key_file_get_keys(&this, group_name, length, error);
5195 // VERSION: 2.6
5196 // Returns the value associated with @key under @group_name
5197 // translated in the given @locale if available. If @locale is
5198 // %NULL then the current locale is assumed.
5200 // If @key cannot be found then %NULL is returned and @error is set
5201 // to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the value associated
5202 // with @key cannot be interpreted or no suitable translation can
5203 // be found then the untranslated value is returned.
5205 // key cannot be found.
5206 // RETURNS: a newly allocated string or %NULL if the specified
5207 // <group_name>: a group name
5208 // <key>: a key
5209 // <locale>: a locale identifier or %NULL
5210 char* /*new*/ get_locale_string()(char* group_name, char* key, char* locale, GLib2.Error** error=null) nothrow {
5211 return g_key_file_get_locale_string(&this, group_name, key, locale, error);
5214 // VERSION: 2.6
5215 // Returns the values associated with @key under @group_name
5216 // translated in the given @locale if available. If @locale is
5217 // %NULL then the current locale is assumed.
5218 // If @key cannot be found then %NULL is returned and @error is set
5219 // to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the values associated
5220 // with @key cannot be interpreted or no suitable translations
5221 // can be found then the untranslated values are returned. The
5222 // returned array is %NULL-terminated, so @length may optionally
5223 // be %NULL.
5225 // or %NULL if the key isn't found. The string array should be freed
5226 // with g_strfreev().
5227 // RETURNS: a newly allocated %NULL-terminated string array
5228 // <group_name>: a group name
5229 // <key>: a key
5230 // <locale>: a locale identifier or %NULL
5231 // <length>: return location for the number of returned strings or %NULL
5232 char** /*new*/ get_locale_string_list()(char* group_name, char* key, char* locale, /*out*/ size_t* length, GLib2.Error** error=null) nothrow {
5233 return g_key_file_get_locale_string_list(&this, group_name, key, locale, length, error);
5236 // VERSION: 2.6
5237 // Returns the name of the start group of the file.
5238 // RETURNS: The start group of the key file.
5239 char* /*new*/ get_start_group()() nothrow {
5240 return g_key_file_get_start_group(&this);
5243 // VERSION: 2.6
5244 // Returns the string value associated with @key under @group_name.
5245 // Unlike g_key_file_get_value(), this function handles escape sequences
5246 // like \s.
5248 // In the event the key cannot be found, %NULL is returned and
5249 // @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the
5250 // event that the @group_name cannot be found, %NULL is returned
5251 // and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
5253 // key cannot be found.
5254 // RETURNS: a newly allocated string or %NULL if the specified
5255 // <group_name>: a group name
5256 // <key>: a key
5257 char* /*new*/ get_string()(char* group_name, char* key, GLib2.Error** error=null) nothrow {
5258 return g_key_file_get_string(&this, group_name, key, error);
5261 // VERSION: 2.6
5262 // Returns the values associated with @key under @group_name.
5264 // In the event the key cannot be found, %NULL is returned and
5265 // @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the
5266 // event that the @group_name cannot be found, %NULL is returned
5267 // and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
5269 // a %NULL-terminated string array or %NULL if the specified
5270 // key cannot be found. The array should be freed with g_strfreev().
5271 // <group_name>: a group name
5272 // <key>: a key
5273 // <length>: return location for the number of returned strings, or %NULL
5274 char** /*new*/ get_string_list()(char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error=null) nothrow {
5275 return g_key_file_get_string_list(&this, group_name, key, length, error);
5278 // VERSION: 2.26
5279 // Returns the value associated with @key under @group_name as an unsigned
5280 // 64-bit integer. This is similar to g_key_file_get_integer() but can return
5281 // large positive results without truncation.
5283 // or 0 if the key was not found or could not be parsed.
5284 // RETURNS: the value associated with the key as an unsigned 64-bit integer,
5285 // <group_name>: a non-%NULL group name
5286 // <key>: a non-%NULL key
5287 ulong get_uint64()(char* group_name, char* key, GLib2.Error** error=null) nothrow {
5288 return g_key_file_get_uint64(&this, group_name, key, error);
5291 // VERSION: 2.6
5292 // Returns the raw value associated with @key under @group_name.
5293 // Use g_key_file_get_string() to retrieve an unescaped UTF-8 string.
5295 // In the event the key cannot be found, %NULL is returned and
5296 // @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the
5297 // event that the @group_name cannot be found, %NULL is returned
5298 // and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
5301 // key cannot be found.
5302 // RETURNS: a newly allocated string or %NULL if the specified
5303 // <group_name>: a group name
5304 // <key>: a key
5305 char* /*new*/ get_value()(char* group_name, char* key, GLib2.Error** error=null) nothrow {
5306 return g_key_file_get_value(&this, group_name, key, error);
5309 // VERSION: 2.6
5310 // Looks whether the key file has the group @group_name.
5312 // otherwise.
5313 // RETURNS: %TRUE if @group_name is a part of @key_file, %FALSE
5314 // <group_name>: a group name
5315 int has_group()(char* group_name) nothrow {
5316 return g_key_file_has_group(&this, group_name);
5319 // Unintrospectable method: has_key() / g_key_file_has_key()
5320 // VERSION: 2.6
5321 // Looks whether the key file has the key @key in the group
5322 // @group_name.
5324 // <note>This function does not follow the rules for #GError strictly;
5325 // the return value both carries meaning and signals an error. To use
5326 // this function, you must pass a #GError pointer in @error, and check
5327 // whether it is not %NULL to see if an error occurred.</note>
5329 // Language bindings should use g_key_file_get_value() to test whether
5330 // or not a key exists.
5332 // otherwise.
5333 // RETURNS: %TRUE if @key is a part of @group_name, %FALSE
5334 // <group_name>: a group name
5335 // <key>: a key name
5336 int has_key()(char* group_name, char* key, GLib2.Error** error=null) nothrow {
5337 return g_key_file_has_key(&this, group_name, key, error);
5340 // VERSION: 2.6
5341 // Loads a key file from memory into an empty #GKeyFile structure.
5342 // If the object cannot be created then %error is set to a #GKeyFileError.
5343 // RETURNS: %TRUE if a key file could be loaded, %FALSE otherwise
5344 // <data>: key file loaded in memory
5345 // <length>: the length of @data in bytes
5346 // <flags>: flags from #GKeyFileFlags
5347 int load_from_data()(char* data, size_t length, KeyFileFlags flags, GLib2.Error** error=null) nothrow {
5348 return g_key_file_load_from_data(&this, data, length, flags, error);
5351 // VERSION: 2.6
5352 // This function looks for a key file named @file in the paths
5353 // returned from g_get_user_data_dir() and g_get_system_data_dirs(),
5354 // loads the file into @key_file and returns the file's full path in
5355 // @full_path. If the file could not be loaded then an %error is
5356 // set to either a #GFileError or #GKeyFileError.
5357 // RETURNS: %TRUE if a key file could be loaded, %FALSE othewise
5358 // <file>: a relative path to a filename to open and parse
5359 // <full_path>: return location for a string containing the full path of the file, or %NULL
5360 // <flags>: flags from #GKeyFileFlags
5361 int load_from_data_dirs()(char* file, /*out*/ char** full_path, KeyFileFlags flags, GLib2.Error** error=null) nothrow {
5362 return g_key_file_load_from_data_dirs(&this, file, full_path, flags, error);
5365 // VERSION: 2.14
5366 // This function looks for a key file named @file in the paths
5367 // specified in @search_dirs, loads the file into @key_file and
5368 // returns the file's full path in @full_path. If the file could not
5369 // be loaded then an %error is set to either a #GFileError or
5370 // #GKeyFileError.
5371 // RETURNS: %TRUE if a key file could be loaded, %FALSE otherwise
5372 // <file>: a relative path to a filename to open and parse
5373 // <search_dirs>: %NULL-terminated array of directories to search
5374 // <full_path>: return location for a string containing the full path of the file, or %NULL
5375 // <flags>: flags from #GKeyFileFlags
5376 int load_from_dirs()(char* file, char** search_dirs, /*out*/ char** full_path, KeyFileFlags flags, GLib2.Error** error=null) nothrow {
5377 return g_key_file_load_from_dirs(&this, file, search_dirs, full_path, flags, error);
5380 // VERSION: 2.6
5381 // Loads a key file into an empty #GKeyFile structure.
5382 // If the file could not be loaded then %error is set to
5383 // either a #GFileError or #GKeyFileError.
5384 // RETURNS: %TRUE if a key file could be loaded, %FALSE otherwise
5385 // <file>: the path of a filename to load, in the GLib filename encoding
5386 // <flags>: flags from #GKeyFileFlags
5387 int load_from_file()(char* file, KeyFileFlags flags, GLib2.Error** error=null) nothrow {
5388 return g_key_file_load_from_file(&this, file, flags, error);
5391 // Unintrospectable method: ref() / g_key_file_ref()
5392 // VERSION: 2.32
5393 // Increases the reference count of @key_file.
5394 // RETURNS: the same @key_file.
5395 KeyFile* /*new*/ ref_()() nothrow {
5396 return g_key_file_ref(&this);
5399 // VERSION: 2.6
5400 // Removes a comment above @key from @group_name.
5401 // If @key is %NULL then @comment will be removed above @group_name.
5402 // If both @key and @group_name are %NULL, then @comment will
5403 // be removed above the first group in the file.
5404 // RETURNS: %TRUE if the comment was removed, %FALSE otherwise
5405 // <group_name>: a group name, or %NULL
5406 // <key>: a key
5407 int remove_comment()(char* group_name, char* key, GLib2.Error** error=null) nothrow {
5408 return g_key_file_remove_comment(&this, group_name, key, error);
5411 // VERSION: 2.6
5412 // Removes the specified group, @group_name,
5413 // from the key file.
5414 // RETURNS: %TRUE if the group was removed, %FALSE otherwise
5415 // <group_name>: a group name
5416 int remove_group()(char* group_name, GLib2.Error** error=null) nothrow {
5417 return g_key_file_remove_group(&this, group_name, error);
5420 // VERSION: 2.6
5421 // Removes @key in @group_name from the key file.
5422 // RETURNS: %TRUE if the key was removed, %FALSE otherwise
5423 // <group_name>: a group name
5424 // <key>: a key name to remove
5425 int remove_key()(char* group_name, char* key, GLib2.Error** error=null) nothrow {
5426 return g_key_file_remove_key(&this, group_name, key, error);
5429 // VERSION: 2.6
5430 // Associates a new boolean value with @key under @group_name.
5431 // If @key cannot be found then it is created.
5432 // <group_name>: a group name
5433 // <key>: a key
5434 // <value>: %TRUE or %FALSE
5435 void set_boolean()(char* group_name, char* key, int value) nothrow {
5436 g_key_file_set_boolean(&this, group_name, key, value);
5439 // VERSION: 2.6
5440 // Associates a list of boolean values with @key under @group_name.
5441 // If @key cannot be found then it is created.
5442 // If @group_name is %NULL, the start_group is used.
5443 // <group_name>: a group name
5444 // <key>: a key
5445 // <list>: an array of boolean values
5446 // <length>: length of @list
5447 void set_boolean_list()(char* group_name, char* key, int list, size_t length) nothrow {
5448 g_key_file_set_boolean_list(&this, group_name, key, list, length);
5451 // VERSION: 2.6
5452 // Places a comment above @key from @group_name.
5453 // If @key is %NULL then @comment will be written above @group_name.
5454 // If both @key and @group_name are %NULL, then @comment will be
5455 // written above the first group in the file.
5456 // RETURNS: %TRUE if the comment was written, %FALSE otherwise
5457 // <group_name>: a group name, or %NULL
5458 // <key>: a key
5459 // <comment>: a comment
5460 int set_comment()(char* group_name, char* key, char* comment, GLib2.Error** error=null) nothrow {
5461 return g_key_file_set_comment(&this, group_name, key, comment, error);
5464 // VERSION: 2.12
5465 // Associates a new double value with @key under @group_name.
5466 // If @key cannot be found then it is created.
5467 // <group_name>: a group name
5468 // <key>: a key
5469 // <value>: an double value
5470 void set_double()(char* group_name, char* key, double value) nothrow {
5471 g_key_file_set_double(&this, group_name, key, value);
5474 // VERSION: 2.12
5475 // Associates a list of double values with @key under
5476 // @group_name. If @key cannot be found then it is created.
5477 // <group_name>: a group name
5478 // <key>: a key
5479 // <list>: an array of double values
5480 // <length>: number of double values in @list
5481 void set_double_list()(char* group_name, char* key, double list, size_t length) nothrow {
5482 g_key_file_set_double_list(&this, group_name, key, list, length);
5485 // VERSION: 2.26
5486 // Associates a new integer value with @key under @group_name.
5487 // If @key cannot be found then it is created.
5488 // <group_name>: a group name
5489 // <key>: a key
5490 // <value>: an integer value
5491 void set_int64()(char* group_name, char* key, long value) nothrow {
5492 g_key_file_set_int64(&this, group_name, key, value);
5495 // VERSION: 2.6
5496 // Associates a new integer value with @key under @group_name.
5497 // If @key cannot be found then it is created.
5498 // <group_name>: a group name
5499 // <key>: a key
5500 // <value>: an integer value
5501 void set_integer()(char* group_name, char* key, int value) nothrow {
5502 g_key_file_set_integer(&this, group_name, key, value);
5505 // VERSION: 2.6
5506 // Associates a list of integer values with @key under @group_name.
5507 // If @key cannot be found then it is created.
5508 // <group_name>: a group name
5509 // <key>: a key
5510 // <list>: an array of integer values
5511 // <length>: number of integer values in @list
5512 void set_integer_list()(char* group_name, char* key, int list, size_t length) nothrow {
5513 g_key_file_set_integer_list(&this, group_name, key, list, length);
5516 // VERSION: 2.6
5517 // Sets the character which is used to separate
5518 // values in lists. Typically ';' or ',' are used
5519 // as separators. The default list separator is ';'.
5520 // <separator>: the separator
5521 void set_list_separator()(char separator) nothrow {
5522 g_key_file_set_list_separator(&this, separator);
5525 // VERSION: 2.6
5526 // Associates a string value for @key and @locale under @group_name.
5527 // If the translation for @key cannot be found then it is created.
5528 // <group_name>: a group name
5529 // <key>: a key
5530 // <locale>: a locale identifier
5531 // <string>: a string
5532 void set_locale_string()(char* group_name, char* key, char* locale, char* string_) nothrow {
5533 g_key_file_set_locale_string(&this, group_name, key, locale, string_);
5536 // VERSION: 2.6
5537 // Associates a list of string values for @key and @locale under
5538 // @group_name. If the translation for @key cannot be found then
5539 // it is created.
5540 // <group_name>: a group name
5541 // <key>: a key
5542 // <locale>: a locale identifier
5543 // <list>: a %NULL-terminated array of locale string values
5544 // <length>: the length of @list
5545 void set_locale_string_list()(char* group_name, char* key, char* locale, char* list, size_t length) nothrow {
5546 g_key_file_set_locale_string_list(&this, group_name, key, locale, list, length);
5549 // VERSION: 2.6
5550 // Associates a new string value with @key under @group_name.
5551 // If @key cannot be found then it is created.
5552 // If @group_name cannot be found then it is created.
5553 // Unlike g_key_file_set_value(), this function handles characters
5554 // that need escaping, such as newlines.
5555 // <group_name>: a group name
5556 // <key>: a key
5557 // <string>: a string
5558 void set_string()(char* group_name, char* key, char* string_) nothrow {
5559 g_key_file_set_string(&this, group_name, key, string_);
5562 // VERSION: 2.6
5563 // Associates a list of string values for @key under @group_name.
5564 // If @key cannot be found then it is created.
5565 // If @group_name cannot be found then it is created.
5566 // <group_name>: a group name
5567 // <key>: a key
5568 // <list>: an array of string values
5569 // <length>: number of string values in @list
5570 void set_string_list()(char* group_name, char* key, char* list, size_t length) nothrow {
5571 g_key_file_set_string_list(&this, group_name, key, list, length);
5574 // VERSION: 2.26
5575 // Associates a new integer value with @key under @group_name.
5576 // If @key cannot be found then it is created.
5577 // <group_name>: a group name
5578 // <key>: a key
5579 // <value>: an integer value
5580 void set_uint64()(char* group_name, char* key, ulong value) nothrow {
5581 g_key_file_set_uint64(&this, group_name, key, value);
5584 // VERSION: 2.6
5585 // Associates a new value with @key under @group_name.
5587 // If @key cannot be found then it is created. If @group_name cannot
5588 // be found then it is created. To set an UTF-8 string which may contain
5589 // characters that need escaping (such as newlines or spaces), use
5590 // g_key_file_set_string().
5591 // <group_name>: a group name
5592 // <key>: a key
5593 // <value>: a string
5594 void set_value()(char* group_name, char* key, char* value) nothrow {
5595 g_key_file_set_value(&this, group_name, key, value);
5598 // VERSION: 2.6
5599 // This function outputs @key_file as a string.
5601 // Note that this function never reports an error,
5602 // so it is safe to pass %NULL as @error.
5604 // the contents of the #GKeyFile
5605 // RETURNS: a newly allocated string holding
5606 // <length>: return location for the length of the returned string, or %NULL
5607 char* /*new*/ to_data()(/*out*/ size_t* length, GLib2.Error** error=null) nothrow {
5608 return g_key_file_to_data(&this, length, error);
5611 // VERSION: 2.32
5612 // Decreases the reference count of @key_file by 1. If the reference count
5613 // reaches zero, frees the key file and all its allocated memory.
5614 void unref()() nothrow {
5615 g_key_file_unref(&this);
5617 static Quark error_quark()() nothrow {
5618 return g_key_file_error_quark();
5622 // Error codes returned by key file parsing.
5623 enum KeyFileError {
5624 UNKNOWN_ENCODING = 0,
5625 PARSE = 1,
5626 NOT_FOUND = 2,
5627 KEY_NOT_FOUND = 3,
5628 GROUP_NOT_FOUND = 4,
5629 INVALID_VALUE = 5
5631 // Flags which influence the parsing.
5632 enum KeyFileFlags {
5633 NONE = 0,
5634 KEEP_COMMENTS = 1,
5635 KEEP_TRANSLATIONS = 2
5637 enum int LITTLE_ENDIAN = 1234;
5638 enum double LN10 = 2.302585;
5639 enum double LN2 = 0.693147;
5640 enum double LOG_2_BASE_10 = 0.301030;
5641 enum int LOG_FATAL_MASK = 0;
5642 enum int LOG_LEVEL_USER_SHIFT = 8;
5643 // The #GList struct is used for each element in a doubly-linked list.
5644 struct List {
5645 void* data;
5646 GLib2.List* next, prev;
5649 // Unintrospectable function: alloc() / g_list_alloc()
5650 // Allocates space for one #GList element. It is called by
5651 // g_list_append(), g_list_prepend(), g_list_insert() and
5652 // g_list_insert_sorted() and so is rarely used on its own.
5653 static GLib2.List* alloc()() nothrow {
5654 return g_list_alloc();
5657 // Unintrospectable function: append() / g_list_append()
5658 // Adds a new element on to the end of the list.
5660 // <note><para>
5661 // The return value is the new start of the list, which
5662 // may have changed, so make sure you store the new value.
5663 // </para></note>
5665 // <note><para>
5666 // Note that g_list_append() has to traverse the entire list
5667 // to find the end, which is inefficient when adding multiple
5668 // elements. A common idiom to avoid the inefficiency is to prepend
5669 // the elements and reverse the list when all elements have been added.
5670 // </para></note>
5672 // |[
5673 // /&ast; Notice that these are initialized to the empty list. &ast;/
5674 // GList *list = NULL, *number_list = NULL;
5676 // /&ast; This is a list of strings. &ast;/
5677 // list = g_list_append (list, "first");
5678 // list = g_list_append (list, "second");
5680 // /&ast; This is a list of integers. &ast;/
5681 // number_list = g_list_append (number_list, GINT_TO_POINTER (27));
5682 // number_list = g_list_append (number_list, GINT_TO_POINTER (14));
5683 // ]|
5684 // RETURNS: the new start of the #GList
5685 // <list>: a pointer to a #GList
5686 // <data>: the data for the new element
5687 static GLib2.List* append()(GLib2.List* list, void* data) nothrow {
5688 return g_list_append(list, data);
5691 // Unintrospectable function: concat() / g_list_concat()
5692 // Adds the second #GList onto the end of the first #GList.
5693 // Note that the elements of the second #GList are not copied.
5694 // They are used directly.
5695 // RETURNS: the start of the new #GList
5696 // <list1>: a #GList
5697 // <list2>: the #GList to add to the end of the first #GList
5698 static GLib2.List* concat()(GLib2.List* list1, GLib2.List* list2) nothrow {
5699 return g_list_concat(list1, list2);
5702 // Unintrospectable function: copy() / g_list_copy()
5703 // Copies a #GList.
5705 // <note><para>
5706 // Note that this is a "shallow" copy. If the list elements
5707 // consist of pointers to data, the pointers are copied but
5708 // the actual data is not.
5709 // </para></note>
5710 // RETURNS: a copy of @list
5711 // <list>: a #GList
5712 static GLib2.List* copy()(GLib2.List* list) nothrow {
5713 return g_list_copy(list);
5716 // Unintrospectable function: delete_link() / g_list_delete_link()
5717 // Removes the node link_ from the list and frees it.
5718 // Compare this to g_list_remove_link() which removes the node
5719 // without freeing it.
5720 // RETURNS: the new head of @list
5721 // <list>: a #GList
5722 // <link_>: node to delete from @list
5723 static GLib2.List* delete_link()(GLib2.List* list, GLib2.List* link_) nothrow {
5724 return g_list_delete_link(list, link_);
5727 // Unintrospectable function: find() / g_list_find()
5728 // Finds the element in a #GList which
5729 // contains the given data.
5731 // or %NULL if it is not found
5732 // RETURNS: the found #GList element,
5733 // <list>: a #GList
5734 // <data>: the element data to find
5735 static GLib2.List* find()(GLib2.List* list, const(void)* data) nothrow {
5736 return g_list_find(list, data);
5739 // Unintrospectable function: find_custom() / g_list_find_custom()
5740 // Finds an element in a #GList, using a supplied function to
5741 // find the desired element. It iterates over the list, calling
5742 // the given function which should return 0 when the desired
5743 // element is found. The function takes two #gconstpointer arguments,
5744 // the #GList element's data as the first argument and the
5745 // given user data.
5746 // RETURNS: the found #GList element, or %NULL if it is not found
5747 // <list>: a #GList
5748 // <data>: user data passed to the function
5749 // <func>: the function to call for each element. It should return 0 when the desired element is found
5750 static GLib2.List* find_custom()(GLib2.List* list, const(void)* data, CompareFunc func) nothrow {
5751 return g_list_find_custom(list, data, func);
5754 // Unintrospectable function: first() / g_list_first()
5755 // Gets the first element in a #GList.
5757 // or %NULL if the #GList has no elements
5758 // RETURNS: the first element in the #GList,
5759 // <list>: a #GList
5760 static GLib2.List* first()(GLib2.List* list) nothrow {
5761 return g_list_first(list);
5764 // Unintrospectable function: foreach() / g_list_foreach()
5765 // Calls a function for each element of a #GList.
5766 // <list>: a #GList
5767 // <func>: the function to call with each element's data
5768 // <user_data>: user data to pass to the function
5769 static void foreach_()(GLib2.List* list, Func func, void* user_data) nothrow {
5770 g_list_foreach(list, func, user_data);
5773 // Unintrospectable function: free() / g_list_free()
5774 // Frees all of the memory used by a #GList.
5775 // The freed elements are returned to the slice allocator.
5777 // <note><para>
5778 // If list elements contain dynamically-allocated memory,
5779 // you should either use g_list_free_full() or free them manually
5780 // first.
5781 // </para></note>
5782 // <list>: a #GList
5783 static void free()(GLib2.List* list) nothrow {
5784 g_list_free(list);
5787 // Unintrospectable function: free_1() / g_list_free_1()
5788 // Frees one #GList element.
5789 // It is usually used after g_list_remove_link().
5790 // <list>: a #GList element
5791 static void free_1()(GLib2.List* list) nothrow {
5792 g_list_free_1(list);
5795 // Unintrospectable function: free_full() / g_list_free_full()
5796 // VERSION: 2.28
5797 // Convenience method, which frees all the memory used by a #GList, and
5798 // calls the specified destroy function on every element's data.
5799 // <list>: a pointer to a #GList
5800 // <free_func>: the function to be called to free each element's data
5801 static void free_full()(GLib2.List* list, DestroyNotify free_func) nothrow {
5802 g_list_free_full(list, free_func);
5805 // Unintrospectable function: index() / g_list_index()
5806 // Gets the position of the element containing
5807 // the given data (starting from 0).
5809 // or -1 if the data is not found
5810 // RETURNS: the index of the element containing the data,
5811 // <list>: a #GList
5812 // <data>: the data to find
5813 static int index()(GLib2.List* list, const(void)* data) nothrow {
5814 return g_list_index(list, data);
5817 // Unintrospectable function: insert() / g_list_insert()
5818 // Inserts a new element into the list at the given position.
5819 // RETURNS: the new start of the #GList
5820 // <list>: a pointer to a #GList
5821 // <data>: the data for the new element
5822 // <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.
5823 static GLib2.List* insert()(GLib2.List* list, void* data, int position) nothrow {
5824 return g_list_insert(list, data, position);
5827 // Unintrospectable function: insert_before() / g_list_insert_before()
5828 // Inserts a new element into the list before the given position.
5829 // RETURNS: the new start of the #GList
5830 // <list>: a pointer to a #GList
5831 // <sibling>: the list element before which the new element is inserted or %NULL to insert at the end of the list
5832 // <data>: the data for the new element
5833 static GLib2.List* insert_before()(GLib2.List* list, GLib2.List* sibling, void* data) nothrow {
5834 return g_list_insert_before(list, sibling, data);
5837 // Unintrospectable function: insert_sorted() / g_list_insert_sorted()
5838 // Inserts a new element into the list, using the given comparison
5839 // function to determine its position.
5840 // RETURNS: the new start of the #GList
5841 // <list>: a pointer to a #GList
5842 // <data>: the data for the new element
5843 // <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.
5844 static GLib2.List* insert_sorted()(GLib2.List* list, void* data, CompareFunc func) nothrow {
5845 return g_list_insert_sorted(list, data, func);
5848 // Unintrospectable function: insert_sorted_with_data() / g_list_insert_sorted_with_data()
5849 // VERSION: 2.10
5850 // Inserts a new element into the list, using the given comparison
5851 // function to determine its position.
5852 // RETURNS: the new start of the #GList
5853 // <list>: a pointer to a #GList
5854 // <data>: the data for the new element
5855 // <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.
5856 // <user_data>: user data to pass to comparison function.
5857 static GLib2.List* insert_sorted_with_data()(GLib2.List* list, void* data, CompareDataFunc func, void* user_data) nothrow {
5858 return g_list_insert_sorted_with_data(list, data, func, user_data);
5861 // Unintrospectable function: last() / g_list_last()
5862 // Gets the last element in a #GList.
5864 // or %NULL if the #GList has no elements
5865 // RETURNS: the last element in the #GList,
5866 // <list>: a #GList
5867 static GLib2.List* last()(GLib2.List* list) nothrow {
5868 return g_list_last(list);
5871 // Unintrospectable function: length() / g_list_length()
5872 // Gets the number of elements in a #GList.
5874 // <note><para>
5875 // This function iterates over the whole list to
5876 // count its elements.
5877 // </para></note>
5878 // RETURNS: the number of elements in the #GList
5879 // <list>: a #GList
5880 static uint length()(GLib2.List* list) nothrow {
5881 return g_list_length(list);
5884 // Unintrospectable function: nth() / g_list_nth()
5885 // Gets the element at the given position in a #GList.
5887 // the end of the #GList
5888 // RETURNS: the element, or %NULL if the position is off
5889 // <list>: a #GList
5890 // <n>: the position of the element, counting from 0
5891 static GLib2.List* nth()(GLib2.List* list, uint n) nothrow {
5892 return g_list_nth(list, n);
5895 // Unintrospectable function: nth_data() / g_list_nth_data()
5896 // Gets the data of the element at the given position.
5898 // is off the end of the #GList
5899 // RETURNS: the element's data, or %NULL if the position
5900 // <list>: a #GList
5901 // <n>: the position of the element
5902 static void* nth_data()(GLib2.List* list, uint n) nothrow {
5903 return g_list_nth_data(list, n);
5906 // Unintrospectable function: nth_prev() / g_list_nth_prev()
5907 // Gets the element @n places before @list.
5909 // off the end of the #GList
5910 // RETURNS: the element, or %NULL if the position is
5911 // <list>: a #GList
5912 // <n>: the position of the element, counting from 0
5913 static GLib2.List* nth_prev()(GLib2.List* list, uint n) nothrow {
5914 return g_list_nth_prev(list, n);
5917 // Unintrospectable function: position() / g_list_position()
5918 // Gets the position of the given element
5919 // in the #GList (starting from 0).
5921 // or -1 if the element is not found
5922 // RETURNS: the position of the element in the #GList,
5923 // <list>: a #GList
5924 // <llink>: an element in the #GList
5925 static int position()(GLib2.List* list, GLib2.List* llink) nothrow {
5926 return g_list_position(list, llink);
5929 // Unintrospectable function: prepend() / g_list_prepend()
5930 // Adds a new element on to the start of the list.
5932 // <note><para>
5933 // The return value is the new start of the list, which
5934 // may have changed, so make sure you store the new value.
5935 // </para></note>
5937 // |[
5938 // /&ast; Notice that it is initialized to the empty list. &ast;/
5939 // GList *list = NULL;
5940 // list = g_list_prepend (list, "last");
5941 // list = g_list_prepend (list, "first");
5942 // ]|
5943 // RETURNS: the new start of the #GList
5944 // <list>: a pointer to a #GList
5945 // <data>: the data for the new element
5946 static GLib2.List* prepend()(GLib2.List* list, void* data) nothrow {
5947 return g_list_prepend(list, data);
5950 // Unintrospectable function: remove() / g_list_remove()
5951 // Removes an element from a #GList.
5952 // If two elements contain the same data, only the first is removed.
5953 // If none of the elements contain the data, the #GList is unchanged.
5954 // RETURNS: the new start of the #GList
5955 // <list>: a #GList
5956 // <data>: the data of the element to remove
5957 static GLib2.List* remove()(GLib2.List* list, const(void)* data) nothrow {
5958 return g_list_remove(list, data);
5961 // Unintrospectable function: remove_all() / g_list_remove_all()
5962 // Removes all list nodes with data equal to @data.
5963 // Returns the new head of the list. Contrast with
5964 // g_list_remove() which removes only the first node
5965 // matching the given data.
5966 // RETURNS: new head of @list
5967 // <list>: a #GList
5968 // <data>: data to remove
5969 static GLib2.List* remove_all()(GLib2.List* list, const(void)* data) nothrow {
5970 return g_list_remove_all(list, data);
5973 // Unintrospectable function: remove_link() / g_list_remove_link()
5974 // Removes an element from a #GList, without freeing the element.
5975 // The removed element's prev and next links are set to %NULL, so
5976 // that it becomes a self-contained list with one element.
5977 // RETURNS: the new start of the #GList, without the element
5978 // <list>: a #GList
5979 // <llink>: an element in the #GList
5980 static GLib2.List* remove_link()(GLib2.List* list, GLib2.List* llink) nothrow {
5981 return g_list_remove_link(list, llink);
5984 // Unintrospectable function: reverse() / g_list_reverse()
5985 // Reverses a #GList.
5986 // It simply switches the next and prev pointers of each element.
5987 // RETURNS: the start of the reversed #GList
5988 // <list>: a #GList
5989 static GLib2.List* reverse()(GLib2.List* list) nothrow {
5990 return g_list_reverse(list);
5993 // Unintrospectable function: sort() / g_list_sort()
5994 // Sorts a #GList using the given comparison function. The algorithm
5995 // used is a stable sort.
5996 // RETURNS: the start of the sorted #GList
5997 // <list>: a #GList
5998 // <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.
5999 static GLib2.List* sort()(GLib2.List* list, CompareFunc compare_func) nothrow {
6000 return g_list_sort(list, compare_func);
6003 // Unintrospectable function: sort_with_data() / g_list_sort_with_data()
6004 // Like g_list_sort(), but the comparison function accepts
6005 // a user data argument.
6006 // RETURNS: the new head of @list
6007 // <list>: a #GList
6008 // <compare_func>: comparison function
6009 // <user_data>: user data to pass to comparison function
6010 static GLib2.List* sort_with_data()(GLib2.List* list, CompareDataFunc compare_func, void* user_data) nothrow {
6011 return g_list_sort_with_data(list, compare_func, user_data);
6016 // Specifies the prototype of log handler functions.
6017 // <log_domain>: the log domain of the message
6018 // <log_level>: the log level of the message (including the fatal and recursion flags)
6019 // <message>: the message to process
6020 // <user_data>: user data, set in g_log_set_handler()
6021 extern (C) alias void function (char* log_domain, LogLevelFlags log_level, char* message, void* user_data) nothrow LogFunc;
6024 // Flags specifying the level of log messages.
6026 // It is possible to change how GLib treats messages of the various
6027 // levels using g_log_set_handler() and g_log_set_fatal_mask().
6028 enum LogLevelFlags {
6029 FLAG_RECURSION = 1,
6030 FLAG_FATAL = 2,
6031 LEVEL_ERROR = 4,
6032 LEVEL_CRITICAL = 8,
6033 LEVEL_WARNING = 16,
6034 LEVEL_MESSAGE = 32,
6035 LEVEL_INFO = 64,
6036 LEVEL_DEBUG = 128,
6037 LEVEL_MASK = -4
6039 enum int MAJOR_VERSION = 2;
6040 enum int MICRO_VERSION = 16;
6041 enum int MINOR_VERSION = 31;
6042 enum MODULE_SUFFIX = "so";
6044 // The <structname>GMainContext</structname> struct is an opaque data
6045 // type representing a set of sources to be handled in a main loop.
6046 struct MainContext {
6048 // Creates a new #GMainContext structure.
6049 // RETURNS: the new #GMainContext
6050 static MainContext* /*new*/ new_()() nothrow {
6051 return g_main_context_new();
6053 alias new_!() opCall;
6055 // Tries to become the owner of the specified context.
6056 // If some other thread is the owner of the context,
6057 // returns %FALSE immediately. Ownership is properly
6058 // recursive: the owner can require ownership again
6059 // and will release ownership when g_main_context_release()
6060 // is called as many times as g_main_context_acquire().
6062 // You must be the owner of a context before you
6063 // can call g_main_context_prepare(), g_main_context_query(),
6064 // g_main_context_check(), g_main_context_dispatch().
6066 // this thread is now the owner of @context.
6067 // RETURNS: %TRUE if the operation succeeded, and
6068 int acquire()() nothrow {
6069 return g_main_context_acquire(&this);
6072 // Adds a file descriptor to the set of file descriptors polled for
6073 // this context. This will very seldom be used directly. Instead
6074 // a typical event source will use g_source_add_poll() instead.
6075 // <fd>: a #GPollFD structure holding information about a file descriptor to watch.
6076 // <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.
6077 void add_poll()(PollFD* fd, int priority) nothrow {
6078 g_main_context_add_poll(&this, fd, priority);
6081 // Passes the results of polling back to the main loop.
6082 // RETURNS: %TRUE if some sources are ready to be dispatched.
6083 // <max_priority>: the maximum numerical priority of sources to check
6084 // <fds>: array of #GPollFD's that was passed to the last call to g_main_context_query()
6085 // <n_fds>: return value of g_main_context_query()
6086 int check()(int max_priority, PollFD* fds, int n_fds) nothrow {
6087 return g_main_context_check(&this, max_priority, fds, n_fds);
6089 // Dispatches all pending sources.
6090 void dispatch()() nothrow {
6091 g_main_context_dispatch(&this);
6094 // Finds a source with the given source functions and user data. If
6095 // multiple sources exist with the same source function and user data,
6096 // the first one found will be returned.
6097 // RETURNS: the source, if one was found, otherwise %NULL
6098 // <funcs>: the @source_funcs passed to g_source_new().
6099 // <user_data>: the user data from the callback.
6100 Source* find_source_by_funcs_user_data()(SourceFuncs* funcs, void* user_data) nothrow {
6101 return g_main_context_find_source_by_funcs_user_data(&this, funcs, user_data);
6104 // Finds a #GSource given a pair of context and ID.
6105 // RETURNS: the #GSource if found, otherwise, %NULL
6106 // <source_id>: the source ID, as returned by g_source_get_id().
6107 Source* find_source_by_id()(uint source_id) nothrow {
6108 return g_main_context_find_source_by_id(&this, source_id);
6111 // Finds a source with the given user data for the callback. If
6112 // multiple sources exist with the same user data, the first
6113 // one found will be returned.
6114 // RETURNS: the source, if one was found, otherwise %NULL
6115 // <user_data>: the user_data for the callback.
6116 Source* find_source_by_user_data()(void* user_data) nothrow {
6117 return g_main_context_find_source_by_user_data(&this, user_data);
6120 // Unintrospectable method: get_poll_func() / g_main_context_get_poll_func()
6121 // Gets the poll function set by g_main_context_set_poll_func().
6122 // RETURNS: the poll function
6123 PollFunc get_poll_func()() nothrow {
6124 return g_main_context_get_poll_func(&this);
6127 // Unintrospectable method: invoke() / g_main_context_invoke()
6128 // VERSION: 2.28
6129 // Invokes a function in such a way that @context is owned during the
6130 // invocation of @function.
6132 // If @context is %NULL then the global default main context — as
6133 // returned by g_main_context_default() — is used.
6135 // If @context is owned by the current thread, @function is called
6136 // directly. Otherwise, if @context is the thread-default main context
6137 // of the current thread and g_main_context_acquire() succeeds, then
6138 // @function is called and g_main_context_release() is called
6139 // afterwards.
6141 // In any other case, an idle source is created to call @function and
6142 // that source is attached to @context (presumably to be run in another
6143 // thread). The idle source is attached with #G_PRIORITY_DEFAULT
6144 // priority. If you want a different priority, use
6145 // g_main_context_invoke_full().
6147 // Note that, as with normal idle functions, @function should probably
6148 // return %FALSE. If it returns %TRUE, it will be continuously run in a
6149 // loop (and may prevent this call from returning).
6150 // <function>: function to call
6151 // <data>: data to pass to @function
6152 void invoke()(SourceFunc function_, void* data) nothrow {
6153 g_main_context_invoke(&this, function_, data);
6156 // VERSION: 2.28
6157 // Invokes a function in such a way that @context is owned during the
6158 // invocation of @function.
6160 // This function is the same as g_main_context_invoke() except that it
6161 // lets you specify the priority incase @function ends up being
6162 // scheduled as an idle and also lets you give a #GDestroyNotify for @data.
6164 // @notify should not assume that it is called from any particular
6165 // thread or with any particular context acquired.
6166 // <priority>: the priority at which to run @function
6167 // <function>: function to call
6168 // <data>: data to pass to @function
6169 // <notify>: a function to call when @data is no longer in use, or %NULL.
6170 void invoke_full()(int priority, SourceFunc function_, void* data, DestroyNotify notify) nothrow {
6171 g_main_context_invoke_full(&this, priority, function_, data, notify);
6174 // VERSION: 2.10
6175 // Determines whether this thread holds the (recursive)
6176 // ownership of this #GMainContext. This is useful to
6177 // know before waiting on another thread that may be
6178 // blocking to get ownership of @context.
6179 // RETURNS: %TRUE if current thread is owner of @context.
6180 int is_owner()() nothrow {
6181 return g_main_context_is_owner(&this);
6184 // Runs a single iteration for the given main loop. This involves
6185 // checking to see if any event sources are ready to be processed,
6186 // then if no events sources are ready and @may_block is %TRUE, waiting
6187 // for a source to become ready, then dispatching the highest priority
6188 // events sources that are ready. Otherwise, if @may_block is %FALSE
6189 // sources are not waited to become ready, only those highest priority
6190 // events sources will be dispatched (if any), that are ready at this
6191 // given moment without further waiting.
6193 // Note that even when @may_block is %TRUE, it is still possible for
6194 // g_main_context_iteration() to return %FALSE, since the the wait may
6195 // be interrupted for other reasons than an event source becoming ready.
6196 // RETURNS: %TRUE if events were dispatched.
6197 // <may_block>: whether the call may block.
6198 int iteration()(int may_block) nothrow {
6199 return g_main_context_iteration(&this, may_block);
6202 // Checks if any sources have pending events for the given context.
6203 // RETURNS: %TRUE if events are pending.
6204 int pending()() nothrow {
6205 return g_main_context_pending(&this);
6208 // VERSION: 2.22
6209 // Pops @context off the thread-default context stack (verifying that
6210 // it was on the top of the stack).
6211 void pop_thread_default()() nothrow {
6212 g_main_context_pop_thread_default(&this);
6215 // Prepares to poll sources within a main loop. The resulting information
6216 // for polling is determined by calling g_main_context_query ().
6218 // prior to polling.
6219 // RETURNS: %TRUE if some source is ready to be dispatched
6220 // <priority>: location to store priority of highest priority source already ready.
6221 int prepare()(int* priority) nothrow {
6222 return g_main_context_prepare(&this, priority);
6225 // VERSION: 2.22
6226 // Acquires @context and sets it as the thread-default context for the
6227 // current thread. This will cause certain asynchronous operations
6228 // (such as most <link linkend="gio">gio</link>-based I/O) which are
6229 // started in this thread to run under @context and deliver their
6230 // results to its main loop, rather than running under the global
6231 // default context in the main thread. Note that calling this function
6232 // changes the context returned by
6233 // g_main_context_get_thread_default(), <emphasis>not</emphasis> the
6234 // one returned by g_main_context_default(), so it does not affect the
6235 // context used by functions like g_idle_add().
6237 // Normally you would call this function shortly after creating a new
6238 // thread, passing it a #GMainContext which will be run by a
6239 // #GMainLoop in that thread, to set a new default context for all
6240 // async operations in that thread. (In this case, you don't need to
6241 // ever call g_main_context_pop_thread_default().) In some cases
6242 // however, you may want to schedule a single operation in a
6243 // non-default context, or temporarily use a non-default context in
6244 // the main thread. In that case, you can wrap the call to the
6245 // asynchronous operation inside a
6246 // g_main_context_push_thread_default() /
6247 // g_main_context_pop_thread_default() pair, but it is up to you to
6248 // ensure that no other asynchronous operations accidentally get
6249 // started while the non-default context is active.
6251 // Beware that libraries that predate this function may not correctly
6252 // handle being used from a thread with a thread-default context. Eg,
6253 // see g_file_supports_thread_contexts().
6254 void push_thread_default()() nothrow {
6255 g_main_context_push_thread_default(&this);
6258 // Determines information necessary to poll this main loop.
6260 // or, if more than @n_fds records need to be stored, the number
6261 // of records that need to be stored.
6262 // RETURNS: the number of records actually stored in @fds,
6263 // <max_priority>: maximum priority source to check
6264 // <timeout_>: location to store timeout to be used in polling
6265 // <fds>: location to store #GPollFD records that need to be polled.
6266 // <n_fds>: length of @fds.
6267 int query()(int max_priority, /*out*/ int* timeout_, /*out*/ PollFD* fds, /*out*/ int n_fds) nothrow {
6268 return g_main_context_query(&this, max_priority, timeout_, fds, n_fds);
6271 // Increases the reference count on a #GMainContext object by one.
6272 // RETURNS: the @context that was passed in (since 2.6)
6273 MainContext* /*new*/ ref_()() nothrow {
6274 return g_main_context_ref(&this);
6277 // Releases ownership of a context previously acquired by this thread
6278 // with g_main_context_acquire(). If the context was acquired multiple
6279 // times, the ownership will be released only when g_main_context_release()
6280 // is called as many times as it was acquired.
6281 void release()() nothrow {
6282 g_main_context_release(&this);
6285 // Removes file descriptor from the set of file descriptors to be
6286 // polled for a particular context.
6287 // <fd>: a #GPollFD descriptor previously added with g_main_context_add_poll()
6288 void remove_poll()(PollFD* fd) nothrow {
6289 g_main_context_remove_poll(&this, fd);
6292 // Unintrospectable method: set_poll_func() / g_main_context_set_poll_func()
6293 // Sets the function to use to handle polling of file descriptors. It
6294 // will be used instead of the poll() system call
6295 // (or GLib's replacement function, which is used where
6296 // poll() isn't available).
6298 // This function could possibly be used to integrate the GLib event
6299 // loop with an external event loop.
6300 // <func>: the function to call to poll all file descriptors
6301 void set_poll_func()(PollFunc func) nothrow {
6302 g_main_context_set_poll_func(&this, func);
6305 // Decreases the reference count on a #GMainContext object by one. If
6306 // the result is zero, free the context and free all associated memory.
6307 void unref()() nothrow {
6308 g_main_context_unref(&this);
6311 // Tries to become the owner of the specified context,
6312 // as with g_main_context_acquire(). But if another thread
6313 // is the owner, atomically drop @mutex and wait on @cond until
6314 // that owner releases ownership or until @cond is signaled, then
6315 // try again (once) to become the owner.
6317 // this thread is now the owner of @context.
6318 // RETURNS: %TRUE if the operation succeeded, and
6319 // <cond>: a condition variable
6320 // <mutex>: a mutex, currently held
6321 int wait()(Cond* cond, Mutex* mutex) nothrow {
6322 return g_main_context_wait(&this, cond, mutex);
6325 // If @context is currently waiting in a poll(), interrupt
6326 // the poll(), and continue the iteration process.
6327 void wakeup()() nothrow {
6328 g_main_context_wakeup(&this);
6331 // Returns the global default main context. This is the main context
6332 // used for main loop functions when a main loop is not explicitly
6333 // specified, and corresponds to the "main" main loop. See also
6334 // g_main_context_get_thread_default().
6335 // RETURNS: the global default main context.
6336 static MainContext* default_()() nothrow {
6337 return g_main_context_default();
6340 // VERSION: 2.22
6341 // Gets the thread-default #GMainContext for this thread. Asynchronous
6342 // operations that want to be able to be run in contexts other than
6343 // the default one should call this method or
6344 // g_main_context_ref_thread_default() to get a #GMainContext to add
6345 // their #GSource<!-- -->s to. (Note that even in single-threaded
6346 // programs applications may sometimes want to temporarily push a
6347 // non-default context, so it is not safe to assume that this will
6348 // always return %NULL if you are running in the default thread.)
6350 // If you need to hold a reference on the context, use
6351 // g_main_context_ref_thread_default() instead.
6353 // %NULL if the thread-default context is the global default context.
6354 // RETURNS: the thread-default #GMainContext, or
6355 static MainContext* get_thread_default()() nothrow {
6356 return g_main_context_get_thread_default();
6359 // VERSION: 2.32
6360 // Gets the thread-default #GMainContext for this thread, as with
6361 // g_main_context_get_thread_default(), but also adds a reference to
6362 // it with g_main_context_ref(). In addition, unlike
6363 // g_main_context_get_thread_default(), if the thread-default context
6364 // is the global default context, this will return that #GMainContext
6365 // (with a ref added to it) rather than returning %NULL.
6367 // with g_main_context_unref() when you are done with it.
6368 // RETURNS: the thread-default #GMainContext. Unref
6369 static MainContext* /*new*/ ref_thread_default()() nothrow {
6370 return g_main_context_ref_thread_default();
6375 // The <structname>GMainLoop</structname> struct is an opaque data type
6376 // representing the main event loop of a GLib or GTK+ application.
6377 struct MainLoop {
6379 // Creates a new #GMainLoop structure.
6380 // RETURNS: a new #GMainLoop.
6381 // <context>: a #GMainContext (if %NULL, the default context will be used).
6382 // <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.
6383 static MainLoop* /*new*/ new_()(MainContext* context, int is_running) nothrow {
6384 return g_main_loop_new(context, is_running);
6386 alias new_!() opCall;
6388 // Returns the #GMainContext of @loop.
6389 // RETURNS: the #GMainContext of @loop
6390 MainContext* get_context()() nothrow {
6391 return g_main_loop_get_context(&this);
6394 // Checks to see if the main loop is currently being run via g_main_loop_run().
6395 // RETURNS: %TRUE if the mainloop is currently being run.
6396 int is_running()() nothrow {
6397 return g_main_loop_is_running(&this);
6400 // Stops a #GMainLoop from running. Any calls to g_main_loop_run()
6401 // for the loop will return.
6403 // Note that sources that have already been dispatched when
6404 // g_main_loop_quit() is called will still be executed.
6405 void quit()() nothrow {
6406 g_main_loop_quit(&this);
6409 // Increases the reference count on a #GMainLoop object by one.
6410 // RETURNS: @loop
6411 MainLoop* /*new*/ ref_()() nothrow {
6412 return g_main_loop_ref(&this);
6415 // Runs a main loop until g_main_loop_quit() is called on the loop.
6416 // If this is called for the thread of the loop's #GMainContext,
6417 // it will process events from the loop, otherwise it will
6418 // simply wait.
6419 void run()() nothrow {
6420 g_main_loop_run(&this);
6423 // Decreases the reference count on a #GMainLoop object by one. If
6424 // the result is zero, free the loop and free all associated memory.
6425 void unref()() nothrow {
6426 g_main_loop_unref(&this);
6431 // The #GMappedFile represents a file mapping created with
6432 // g_mapped_file_new(). It has only private members and should
6433 // not be accessed directly.
6434 struct MappedFile {
6436 // VERSION: 2.8
6437 // This call existed before #GMappedFile had refcounting and is currently
6438 // exactly the same as g_mapped_file_unref().
6440 // Deprecated:2.22: Use g_mapped_file_unref() instead.
6441 void free()() nothrow {
6442 g_mapped_file_free(&this);
6445 // VERSION: 2.8
6446 // Returns the contents of a #GMappedFile.
6448 // Note that the contents may not be zero-terminated,
6449 // even if the #GMappedFile is backed by a text file.
6451 // If the file is empty then %NULL is returned.
6452 // RETURNS: the contents of @file, or %NULL.
6453 char* /*new*/ get_contents()() nothrow {
6454 return g_mapped_file_get_contents(&this);
6457 // VERSION: 2.8
6458 // Returns the length of the contents of a #GMappedFile.
6459 // RETURNS: the length of the contents of @file.
6460 size_t get_length()() nothrow {
6461 return g_mapped_file_get_length(&this);
6464 // Unintrospectable method: ref() / g_mapped_file_ref()
6465 // VERSION: 2.22
6466 // Increments the reference count of @file by one. It is safe to call
6467 // this function from any thread.
6468 // RETURNS: the passed in #GMappedFile.
6469 MappedFile* ref_()() nothrow {
6470 return g_mapped_file_ref(&this);
6473 // Decrements the reference count of @file by one. If the reference count
6474 // drops to 0, unmaps the buffer of @file and frees it.
6476 // It is safe to call this function from any thread.
6478 // Since 2.22
6479 void unref()() nothrow {
6480 g_mapped_file_unref(&this);
6483 // Unintrospectable function: new() / g_mapped_file_new()
6484 // VERSION: 2.8
6485 // Maps a file into memory. On UNIX, this is using the mmap() function.
6487 // If @writable is %TRUE, the mapped buffer may be modified, otherwise
6488 // it is an error to modify the mapped buffer. Modifications to the buffer
6489 // are not visible to other processes mapping the same file, and are not
6490 // written back to the file.
6492 // Note that modifications of the underlying file might affect the contents
6493 // of the #GMappedFile. Therefore, mapping should only be used if the file
6494 // will not be modified, or if all modifications of the file are done
6495 // atomically (e.g. using g_file_set_contents()).
6497 // If @filename is the name of an empty, regular file, the function
6498 // will successfully return an empty #GMappedFile. In other cases of
6499 // size 0 (e.g. device files such as /dev/null), @error will be set
6500 // to the #GFileError value #G_FILE_ERROR_INVAL.
6502 // with g_mapped_file_unref(), or %NULL if the mapping failed.
6503 // RETURNS: a newly allocated #GMappedFile which must be unref'd
6504 // <filename>: The path of the file to load, in the GLib filename encoding
6505 // <writable>: whether the mapping should be writable
6506 static MappedFile* new_()(char* filename, int writable, GLib2.Error** error=null) nothrow {
6507 return g_mapped_file_new(filename, writable, error);
6510 // Unintrospectable function: new_from_fd() / g_mapped_file_new_from_fd()
6511 // VERSION: 2.30
6512 // Maps a file into memory. On UNIX, this is using the mmap() function.
6514 // If @writable is %TRUE, the mapped buffer may be modified, otherwise
6515 // it is an error to modify the mapped buffer. Modifications to the buffer
6516 // are not visible to other processes mapping the same file, and are not
6517 // written back to the file.
6519 // Note that modifications of the underlying file might affect the contents
6520 // of the #GMappedFile. Therefore, mapping should only be used if the file
6521 // will not be modified, or if all modifications of the file are done
6522 // atomically (e.g. using g_file_set_contents()).
6524 // with g_mapped_file_unref(), or %NULL if the mapping failed.
6525 // RETURNS: a newly allocated #GMappedFile which must be unref'd
6526 // <fd>: The file descriptor of the file to load
6527 // <writable>: whether the mapping should be writable
6528 static MappedFile* new_from_fd()(int fd, int writable, GLib2.Error** error=null) nothrow {
6529 return g_mapped_file_new_from_fd(fd, writable, error);
6534 // A mixed enumerated type and flags field. You must specify one type
6535 // (string, strdup, boolean, tristate). Additionally, you may optionally
6536 // bitwise OR the type with the flag %G_MARKUP_COLLECT_OPTIONAL.
6538 // It is likely that this enum will be extended in the future to
6539 // support other types.
6540 enum MarkupCollectType {
6541 INVALID = 0,
6542 STRING = 1,
6543 STRDUP = 2,
6544 BOOLEAN = 3,
6545 TRISTATE = 4,
6546 OPTIONAL = 65536
6548 // Error codes returned by markup parsing.
6549 enum MarkupError {
6550 BAD_UTF8 = 0,
6551 EMPTY = 1,
6552 PARSE = 2,
6553 UNKNOWN_ELEMENT = 3,
6554 UNKNOWN_ATTRIBUTE = 4,
6555 INVALID_CONTENT = 5,
6556 MISSING_ATTRIBUTE = 6
6559 // A parse context is used to parse a stream of bytes that
6560 // you expect to contain marked-up text.
6562 // See g_markup_parse_context_new(), #GMarkupParser, and so
6563 // on for more details.
6564 struct MarkupParseContext {
6566 // Signals to the #GMarkupParseContext that all data has been
6567 // fed into the parse context with g_markup_parse_context_parse().
6569 // This function reports an error if the document isn't complete,
6570 // for example if elements are still open.
6571 // RETURNS: %TRUE on success, %FALSE if an error was set
6572 int end_parse()(GLib2.Error** error=null) nothrow {
6573 return g_markup_parse_context_end_parse(&this, error);
6576 // Frees a #GMarkupParseContext.
6578 // This function can't be called from inside one of the
6579 // #GMarkupParser functions or while a subparser is pushed.
6580 void free()() nothrow {
6581 g_markup_parse_context_free(&this);
6584 // VERSION: 2.2
6585 // Retrieves the name of the currently open element.
6587 // If called from the start_element or end_element handlers this will
6588 // give the element_name as passed to those functions. For the parent
6589 // elements, see g_markup_parse_context_get_element_stack().
6590 // RETURNS: the name of the currently open element, or %NULL
6591 char* get_element()() nothrow {
6592 return g_markup_parse_context_get_element(&this);
6595 // Unintrospectable method: get_element_stack() / g_markup_parse_context_get_element_stack()
6596 // VERSION: 2.16
6597 // Retrieves the element stack from the internal state of the parser.
6599 // The returned #GSList is a list of strings where the first item is
6600 // the currently open tag (as would be returned by
6601 // g_markup_parse_context_get_element()) and the next item is its
6602 // immediate parent.
6604 // This function is intended to be used in the start_element and
6605 // end_element handlers where g_markup_parse_context_get_element()
6606 // would merely return the name of the element that is being
6607 // processed.
6608 // RETURNS: the element stack, which must not be modified
6609 GLib2.SList* get_element_stack()() nothrow {
6610 return g_markup_parse_context_get_element_stack(&this);
6613 // Retrieves the current line number and the number of the character on
6614 // that line. Intended for use in error messages; there are no strict
6615 // semantics for what constitutes the "current" line number other than
6616 // "the best number we could come up with for error messages."
6617 // <line_number>: return location for a line number, or %NULL
6618 // <char_number>: return location for a char-on-line number, or %NULL
6619 void get_position()(int* line_number=null, int* char_number=null) nothrow {
6620 g_markup_parse_context_get_position(&this, line_number, char_number);
6623 // Unintrospectable method: get_user_data() / g_markup_parse_context_get_user_data()
6624 // VERSION: 2.18
6625 // Returns the user_data associated with @context.
6627 // This will either be the user_data that was provided to
6628 // g_markup_parse_context_new() or to the most recent call
6629 // of g_markup_parse_context_push().
6631 // the markup context and will be freed when
6632 // g_markup_parse_context_free() is called.
6633 // RETURNS: the provided user_data. The returned data belongs to
6634 void* get_user_data()() nothrow {
6635 return g_markup_parse_context_get_user_data(&this);
6638 // Feed some data to the #GMarkupParseContext.
6640 // The data need not be valid UTF-8; an error will be signaled if
6641 // it's invalid. The data need not be an entire document; you can
6642 // feed a document into the parser incrementally, via multiple calls
6643 // to this function. Typically, as you receive data from a network
6644 // connection or file, you feed each received chunk of data into this
6645 // function, aborting the process if an error occurs. Once an error
6646 // is reported, no further data may be fed to the #GMarkupParseContext;
6647 // all errors are fatal.
6648 // RETURNS: %FALSE if an error occurred, %TRUE on success
6649 // <text>: chunk of text to parse
6650 // <text_len>: length of @text in bytes
6651 int parse()(char* text, ssize_t text_len, GLib2.Error** error=null) nothrow {
6652 return g_markup_parse_context_parse(&this, text, text_len, error);
6655 // Unintrospectable method: pop() / g_markup_parse_context_pop()
6656 // VERSION: 2.18
6657 // Completes the process of a temporary sub-parser redirection.
6659 // This function exists to collect the user_data allocated by a
6660 // matching call to g_markup_parse_context_push(). It must be called
6661 // in the end_element handler corresponding to the start_element
6662 // handler during which g_markup_parse_context_push() was called.
6663 // You must not call this function from the error callback -- the
6664 // @user_data is provided directly to the callback in that case.
6666 // This function is not intended to be directly called by users
6667 // interested in invoking subparsers. Instead, it is intended to
6668 // be used by the subparsers themselves to implement a higher-level
6669 // interface.
6670 // RETURNS: the user data passed to g_markup_parse_context_push()
6671 void* pop()() nothrow {
6672 return g_markup_parse_context_pop(&this);
6675 // VERSION: 2.18
6676 // Temporarily redirects markup data to a sub-parser.
6678 // This function may only be called from the start_element handler of
6679 // a #GMarkupParser. It must be matched with a corresponding call to
6680 // g_markup_parse_context_pop() in the matching end_element handler
6681 // (except in the case that the parser aborts due to an error).
6683 // All tags, text and other data between the matching tags is
6684 // redirected to the subparser given by @parser. @user_data is used
6685 // as the user_data for that parser. @user_data is also passed to the
6686 // error callback in the event that an error occurs. This includes
6687 // errors that occur in subparsers of the subparser.
6689 // The end tag matching the start tag for which this call was made is
6690 // handled by the previous parser (which is given its own user_data)
6691 // which is why g_markup_parse_context_pop() is provided to allow "one
6692 // last access" to the @user_data provided to this function. In the
6693 // case of error, the @user_data provided here is passed directly to
6694 // the error callback of the subparser and g_markup_parse_context_pop()
6695 // should not be called. In either case, if @user_data was allocated
6696 // then it ought to be freed from both of these locations.
6698 // This function is not intended to be directly called by users
6699 // interested in invoking subparsers. Instead, it is intended to be
6700 // used by the subparsers themselves to implement a higher-level
6701 // interface.
6703 // As an example, see the following implementation of a simple
6704 // parser that counts the number of tags encountered.
6706 // |[
6707 // typedef struct
6708 // {
6709 // gint tag_count;
6710 // } CounterData;
6712 // static void
6713 // counter_start_element (GMarkupParseContext *context,
6714 // const gchar *element_name,
6715 // const gchar **attribute_names,
6716 // const gchar **attribute_values,
6717 // gpointer user_data,
6718 // GError **error)
6719 // {
6720 // CounterData *data = user_data;
6722 // data->tag_count++;
6723 // }
6725 // static void
6726 // counter_error (GMarkupParseContext *context,
6727 // GError *error,
6728 // gpointer user_data)
6729 // {
6730 // CounterData *data = user_data;
6732 // g_slice_free (CounterData, data);
6733 // }
6735 // static GMarkupParser counter_subparser =
6736 // {
6737 // counter_start_element,
6738 // NULL,
6739 // NULL,
6740 // NULL,
6741 // counter_error
6742 // };
6743 // ]|
6745 // In order to allow this parser to be easily used as a subparser, the
6746 // following interface is provided:
6748 // |[
6749 // void
6750 // start_counting (GMarkupParseContext *context)
6751 // {
6752 // CounterData *data = g_slice_new (CounterData);
6754 // data->tag_count = 0;
6755 // g_markup_parse_context_push (context, &counter_subparser, data);
6756 // }
6758 // gint
6759 // end_counting (GMarkupParseContext *context)
6760 // {
6761 // CounterData *data = g_markup_parse_context_pop (context);
6762 // int result;
6764 // result = data->tag_count;
6765 // g_slice_free (CounterData, data);
6767 // return result;
6768 // }
6769 // ]|
6771 // The subparser would then be used as follows:
6773 // |[
6774 // static void start_element (context, element_name, ...)
6775 // {
6776 // if (strcmp (element_name, "count-these") == 0)
6777 // start_counting (context);
6779 // /&ast; else, handle other tags... &ast;/
6780 // }
6782 // static void end_element (context, element_name, ...)
6783 // {
6784 // if (strcmp (element_name, "count-these") == 0)
6785 // g_print ("Counted %d tags\n", end_counting (context));
6787 // /&ast; else, handle other tags... &ast;/
6788 // }
6789 // ]|
6790 // <parser>: a #GMarkupParser
6791 // <user_data>: user data to pass to #GMarkupParser functions
6792 void push()(MarkupParser* parser, void* user_data) nothrow {
6793 g_markup_parse_context_push(&this, parser, user_data);
6796 // Unintrospectable function: new() / g_markup_parse_context_new()
6797 // Creates a new parse context. A parse context is used to parse
6798 // marked-up documents. You can feed any number of documents into
6799 // a context, as long as no errors occur; once an error occurs,
6800 // the parse context can't continue to parse text (you have to
6801 // free it and create a new parse context).
6802 // RETURNS: a new #GMarkupParseContext
6803 // <parser>: a #GMarkupParser
6804 // <flags>: one or more #GMarkupParseFlags
6805 // <user_data>: user data to pass to #GMarkupParser functions
6806 // <user_data_dnotify>: user data destroy notifier called when the parse context is freed
6807 static MarkupParseContext* new_()(MarkupParser* parser, MarkupParseFlags flags, void* user_data, DestroyNotify user_data_dnotify) nothrow {
6808 return g_markup_parse_context_new(parser, flags, user_data, user_data_dnotify);
6812 // Flags that affect the behaviour of the parser.
6813 enum MarkupParseFlags {
6814 DO_NOT_USE_THIS_UNSUPPORTED_FLAG = 1,
6815 TREAT_CDATA_AS_TEXT = 2,
6816 PREFIX_ERROR_POSITION = 4
6819 // Any of the fields in #GMarkupParser can be %NULL, in which case they
6820 // will be ignored. Except for the @error function, any of these callbacks
6821 // can set an error; in particular the %G_MARKUP_ERROR_UNKNOWN_ELEMENT,
6822 // %G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, and %G_MARKUP_ERROR_INVALID_CONTENT
6823 // errors are intended to be set from these callbacks. If you set an error
6824 // from a callback, g_markup_parse_context_parse() will report that error
6825 // back to its caller.
6826 struct MarkupParser {
6827 extern (C) void function (MarkupParseContext* context, char* element_name, char** attribute_names, char** attribute_values, void* user_data, GLib2.Error** error=null) nothrow start_element;
6828 extern (C) void function (MarkupParseContext* context, char* element_name, void* user_data, GLib2.Error** error=null) nothrow end_element;
6829 extern (C) void function (MarkupParseContext* context, char* text, size_t text_len, void* user_data, GLib2.Error** error=null) nothrow text;
6830 extern (C) void function (MarkupParseContext* context, char* passthrough_text, size_t text_len, void* user_data, GLib2.Error** error=null) nothrow passthrough;
6831 extern (C) void function (MarkupParseContext* context, Error* error, void* user_data) nothrow error;
6834 struct MatchInfo {
6836 // VERSION: 2.14
6837 // Returns a new string containing the text in @string_to_expand with
6838 // references and escape sequences expanded. References refer to the last
6839 // match done with @string against @regex and have the same syntax used by
6840 // g_regex_replace().
6842 // The @string_to_expand must be UTF-8 encoded even if #G_REGEX_RAW was
6843 // passed to g_regex_new().
6845 // The backreferences are extracted from the string passed to the match
6846 // function, so you cannot call this function after freeing the string.
6848 // @match_info may be %NULL in which case @string_to_expand must not
6849 // contain references. For instance "foo\n" does not refer to an actual
6850 // pattern and '\n' merely will be replaced with \n character,
6851 // while to expand "\0" (whole match) one needs the result of a match.
6852 // Use g_regex_check_replacement() to find out whether @string_to_expand
6853 // contains references.
6854 // RETURNS: the expanded string, or %NULL if an error occurred
6855 // <string_to_expand>: the string to expand
6856 char* /*new*/ expand_references()(char* string_to_expand, GLib2.Error** error=null) nothrow {
6857 return g_match_info_expand_references(&this, string_to_expand, error);
6860 // VERSION: 2.14
6861 // Retrieves the text matching the @match_num<!-- -->'th capturing
6862 // parentheses. 0 is the full text of the match, 1 is the first paren
6863 // set, 2 the second, and so on.
6865 // If @match_num is a valid sub pattern but it didn't match anything
6866 // (e.g. sub pattern 1, matching "b" against "(a)?b") then an empty
6867 // string is returned.
6869 // If the match was obtained using the DFA algorithm, that is using
6870 // g_regex_match_all() or g_regex_match_all_full(), the retrieved
6871 // string is not that of a set of parentheses but that of a matched
6872 // substring. Substrings are matched in reverse order of length, so
6873 // 0 is the longest match.
6875 // The string is fetched from the string passed to the match function,
6876 // so you cannot call this function after freeing the string.
6878 // occurred. You have to free the string yourself
6879 // RETURNS: The matched substring, or %NULL if an error
6880 // <match_num>: number of the sub expression
6881 char* /*new*/ fetch()(int match_num) nothrow {
6882 return g_match_info_fetch(&this, match_num);
6885 // Unintrospectable method: fetch_all() / g_match_info_fetch_all()
6886 // VERSION: 2.14
6887 // Bundles up pointers to each of the matching substrings from a match
6888 // and stores them in an array of gchar pointers. The first element in
6889 // the returned array is the match number 0, i.e. the entire matched
6890 // text.
6892 // If a sub pattern didn't match anything (e.g. sub pattern 1, matching
6893 // "b" against "(a)?b") then an empty string is inserted.
6895 // If the last match was obtained using the DFA algorithm, that is using
6896 // g_regex_match_all() or g_regex_match_all_full(), the retrieved
6897 // strings are not that matched by sets of parentheses but that of the
6898 // matched substring. Substrings are matched in reverse order of length,
6899 // so the first one is the longest match.
6901 // The strings are fetched from the string passed to the match function,
6902 // so you cannot call this function after freeing the string.
6904 // It must be freed using g_strfreev(). If the previous match failed
6905 // %NULL is returned
6906 // RETURNS: a %NULL-terminated array of gchar * pointers.
6907 char** fetch_all()() nothrow {
6908 return g_match_info_fetch_all(&this);
6911 // VERSION: 2.14
6912 // Retrieves the text matching the capturing parentheses named @name.
6914 // If @name is a valid sub pattern name but it didn't match anything
6915 // (e.g. sub pattern "X", matching "b" against "(?P&lt;X&gt;a)?b")
6916 // then an empty string is returned.
6918 // The string is fetched from the string passed to the match function,
6919 // so you cannot call this function after freeing the string.
6921 // occurred. You have to free the string yourself
6922 // RETURNS: The matched substring, or %NULL if an error
6923 // <name>: name of the subexpression
6924 char* /*new*/ fetch_named()(char* name) nothrow {
6925 return g_match_info_fetch_named(&this, name);
6928 // VERSION: 2.14
6929 // Retrieves the position in bytes of the capturing parentheses named @name.
6931 // If @name is a valid sub pattern name but it didn't match anything
6932 // (e.g. sub pattern "X", matching "b" against "(?P&lt;X&gt;a)?b")
6933 // then @start_pos and @end_pos are set to -1 and %TRUE is returned.
6935 // If the position cannot be fetched, @start_pos and @end_pos
6936 // are left unchanged.
6937 // RETURNS: %TRUE if the position was fetched, %FALSE otherwise.
6938 // <name>: name of the subexpression
6939 // <start_pos>: pointer to location where to store the start position, or %NULL
6940 // <end_pos>: pointer to location where to store the end position, or %NULL
6941 int fetch_named_pos()(char* name, /*out*/ int* start_pos=null, /*out*/ int* end_pos=null) nothrow {
6942 return g_match_info_fetch_named_pos(&this, name, start_pos, end_pos);
6945 // VERSION: 2.14
6946 // Retrieves the position in bytes of the @match_num<!-- -->'th capturing
6947 // parentheses. 0 is the full text of the match, 1 is the first
6948 // paren set, 2 the second, and so on.
6950 // If @match_num is a valid sub pattern but it didn't match anything
6951 // (e.g. sub pattern 1, matching "b" against "(a)?b") then @start_pos
6952 // and @end_pos are set to -1 and %TRUE is returned.
6954 // If the match was obtained using the DFA algorithm, that is using
6955 // g_regex_match_all() or g_regex_match_all_full(), the retrieved
6956 // position is not that of a set of parentheses but that of a matched
6957 // substring. Substrings are matched in reverse order of length, so
6958 // 0 is the longest match.
6960 // the position cannot be fetched, @start_pos and @end_pos are left
6961 // unchanged
6962 // RETURNS: %TRUE if the position was fetched, %FALSE otherwise. If
6963 // <match_num>: number of the sub expression
6964 // <start_pos>: pointer to location where to store the start position, or %NULL
6965 // <end_pos>: pointer to location where to store the end position, or %NULL
6966 int fetch_pos()(int match_num, /*out*/ int* start_pos=null, /*out*/ int* end_pos=null) nothrow {
6967 return g_match_info_fetch_pos(&this, match_num, start_pos, end_pos);
6970 // VERSION: 2.14
6971 // If @match_info is not %NULL, calls g_match_info_unref(); otherwise does
6972 // nothing.
6973 void free()() nothrow {
6974 g_match_info_free(&this);
6977 // VERSION: 2.14
6978 // Retrieves the number of matched substrings (including substring 0,
6979 // that is the whole matched text), so 1 is returned if the pattern
6980 // has no substrings in it and 0 is returned if the match failed.
6982 // If the last match was obtained using the DFA algorithm, that is
6983 // using g_regex_match_all() or g_regex_match_all_full(), the retrieved
6984 // count is not that of the number of capturing parentheses but that of
6985 // the number of matched substrings.
6986 // RETURNS: Number of matched substrings, or -1 if an error occurred
6987 int get_match_count()() nothrow {
6988 return g_match_info_get_match_count(&this);
6991 // VERSION: 2.14
6992 // Returns #GRegex object used in @match_info. It belongs to Glib
6993 // and must not be freed. Use g_regex_ref() if you need to keep it
6994 // after you free @match_info object.
6995 // RETURNS: #GRegex object used in @match_info
6996 Regex* /*new*/ get_regex()() nothrow {
6997 return g_match_info_get_regex(&this);
7000 // VERSION: 2.14
7001 // Returns the string searched with @match_info. This is the
7002 // string passed to g_regex_match() or g_regex_replace() so
7003 // you may not free it before calling this function.
7004 // RETURNS: the string searched with @match_info
7005 char* get_string()() nothrow {
7006 return g_match_info_get_string(&this);
7009 // VERSION: 2.14
7010 // Usually if the string passed to g_regex_match*() matches as far as
7011 // it goes, but is too short to match the entire pattern, %FALSE is
7012 // returned. There are circumstances where it might be helpful to
7013 // distinguish this case from other cases in which there is no match.
7015 // Consider, for example, an application where a human is required to
7016 // type in data for a field with specific formatting requirements. An
7017 // example might be a date in the form ddmmmyy, defined by the pattern
7018 // "^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$".
7019 // If the application sees the user’s keystrokes one by one, and can
7020 // check that what has been typed so far is potentially valid, it is
7021 // able to raise an error as soon as a mistake is made.
7023 // GRegex supports the concept of partial matching by means of the
7024 // #G_REGEX_MATCH_PARTIAL flag. When this is set the return code for
7025 // g_regex_match() or g_regex_match_full() is, as usual, %TRUE
7026 // for a complete match, %FALSE otherwise. But, when these functions
7027 // return %FALSE, you can check if the match was partial calling
7028 // g_match_info_is_partial_match().
7030 // When using partial matching you cannot use g_match_info_fetch*().
7032 // Because of the way certain internal optimizations are implemented
7033 // the partial matching algorithm cannot be used with all patterns.
7034 // So repeated single characters such as "a{2,4}" and repeated single
7035 // meta-sequences such as "\d+" are not permitted if the maximum number
7036 // of occurrences is greater than one. Optional items such as "\d?"
7037 // (where the maximum is one) are permitted. Quantifiers with any values
7038 // are permitted after parentheses, so the invalid examples above can be
7039 // coded thus "(a){2,4}" and "(\d)+". If #G_REGEX_MATCH_PARTIAL is set
7040 // for a pattern that does not conform to the restrictions, matching
7041 // functions return an error.
7042 // RETURNS: %TRUE if the match was partial, %FALSE otherwise
7043 int is_partial_match()() nothrow {
7044 return g_match_info_is_partial_match(&this);
7047 // VERSION: 2.14
7048 // Returns whether the previous match operation succeeded.
7050 // %FALSE otherwise
7051 // RETURNS: %TRUE if the previous match operation succeeded,
7052 int matches()() nothrow {
7053 return g_match_info_matches(&this);
7056 // VERSION: 2.14
7057 // Scans for the next match using the same parameters of the previous
7058 // call to g_regex_match_full() or g_regex_match() that returned
7059 // @match_info.
7061 // The match is done on the string passed to the match function, so you
7062 // cannot free it before calling this function.
7063 // RETURNS: %TRUE is the string matched, %FALSE otherwise
7064 int next()(GLib2.Error** error=null) nothrow {
7065 return g_match_info_next(&this, error);
7068 // VERSION: 2.30
7069 // Increases reference count of @match_info by 1.
7070 // RETURNS: @match_info
7071 MatchInfo* /*new*/ ref_()() nothrow {
7072 return g_match_info_ref(&this);
7075 // VERSION: 2.30
7076 // Decreases reference count of @match_info by 1. When reference count drops
7077 // to zero, it frees all the memory associated with the match_info structure.
7078 void unref()() nothrow {
7079 g_match_info_unref(&this);
7084 // A set of functions used to perform memory allocation. The same #GMemVTable must
7085 // be used for all allocations in the same program; a call to g_mem_set_vtable(),
7086 // if it exists, should be prior to any use of GLib.
7087 struct MemVTable {
7088 // Unintrospectable functionp: malloc() / ()
7089 extern (C) void* function (size_t n_bytes) nothrow malloc;
7090 // Unintrospectable functionp: realloc() / ()
7091 extern (C) void* function (void* mem, size_t n_bytes) nothrow realloc;
7092 extern (C) void function (void* mem) nothrow free;
7093 // Unintrospectable functionp: calloc() / ()
7094 extern (C) void* function (size_t n_blocks, size_t n_block_bytes) nothrow calloc;
7095 // Unintrospectable functionp: try_malloc() / ()
7096 extern (C) void* function (size_t n_bytes) nothrow try_malloc;
7097 // Unintrospectable functionp: try_realloc() / ()
7098 extern (C) void* function (void* mem, size_t n_bytes) nothrow try_realloc;
7102 // The #GMutex struct is an opaque data structure to represent a mutex
7103 // (mutual exclusion). It can be used to protect data against shared
7104 // access. Take for example the following function:
7106 // <example>
7107 // <title>A function which will not work in a threaded environment</title>
7108 // <programlisting>
7109 // int
7110 // give_me_next_number (void)
7111 // {
7112 // static int current_number = 0;
7114 // /<!-- -->* now do a very complicated calculation to calculate the new
7115 // * number, this might for example be a random number generator
7116 // *<!-- -->/
7117 // current_number = calc_next_number (current_number);
7119 // return current_number;
7120 // }
7121 // </programlisting>
7122 // </example>
7124 // It is easy to see that this won't work in a multi-threaded
7125 // application. There current_number must be protected against shared
7126 // access. A #GMutex can be used as a solution to this problem:
7128 // <example>
7129 // <title>Using GMutex to protected a shared variable</title>
7130 // <programlisting>
7131 // int
7132 // give_me_next_number (void)
7133 // {
7134 // static GMutex mutex;
7135 // static int current_number = 0;
7136 // int ret_val;
7138 // g_mutex_lock (&amp;mutex);
7139 // ret_val = current_number = calc_next_number (current_number);
7140 // g_mutex_unlock (&amp;mutex);
7142 // return ret_val;
7143 // }
7144 // </programlisting>
7145 // </example>
7147 // Notice that the #GMutex is not initialised to any particular value.
7148 // Its placement in static storage ensures that it will be initialised
7149 // to all-zeros, which is appropriate.
7151 // If a #GMutex is placed in other contexts (eg: embedded in a struct)
7152 // then it must be explicitly initialised using g_mutex_init().
7154 // A #GMutex should only be accessed via <function>g_mutex_</function>
7155 // functions.
7156 union Mutex {
7157 private void* p;
7158 private uint[2] i;
7161 // Frees the resources allocated to a mutex with g_mutex_init().
7163 // This function should not be used with a #GMutex that has been
7164 // statically allocated.
7166 // Calling g_mutex_clear() on a locked mutex leads to undefined
7167 // behaviour.
7169 // Sine: 2.32
7170 void clear()() nothrow {
7171 g_mutex_clear(&this);
7174 // VERSION: 2.32
7175 // Initializes a #GMutex so that it can be used.
7177 // This function is useful to initialize a mutex that has been
7178 // allocated on the stack, or as part of a larger structure.
7179 // It is not necessary to initialize a mutex that has been
7180 // created that has been statically allocated.
7182 // |[
7183 // typedef struct {
7184 // GMutex m;
7185 // ...
7186 // } Blob;
7188 // Blob *b;
7190 // b = g_new (Blob, 1);
7191 // g_mutex_init (&b->m);
7192 // ]|
7194 // To undo the effect of g_mutex_init() when a mutex is no longer
7195 // needed, use g_mutex_clear().
7197 // Calling g_mutex_init() on an already initialized #GMutex leads
7198 // to undefined behaviour.
7199 void init()() nothrow {
7200 g_mutex_init(&this);
7203 // Locks @mutex. If @mutex is already locked by another thread, the
7204 // current thread will block until @mutex is unlocked by the other
7205 // thread.
7207 // <note>#GMutex is neither guaranteed to be recursive nor to be
7208 // non-recursive. As such, calling g_mutex_lock() on a #GMutex that has
7209 // already been locked by the same thread results in undefined behaviour
7210 // (including but not limited to deadlocks).</note>
7211 void lock()() nothrow {
7212 g_mutex_lock(&this);
7215 // Tries to lock @mutex. If @mutex is already locked by another thread,
7216 // it immediately returns %FALSE. Otherwise it locks @mutex and returns
7217 // %TRUE.
7219 // <note>#GMutex is neither guaranteed to be recursive nor to be
7220 // non-recursive. As such, calling g_mutex_lock() on a #GMutex that has
7221 // already been locked by the same thread results in undefined behaviour
7222 // (including but not limited to deadlocks or arbitrary return values).
7223 // </note>
7224 // RETURNS: %TRUE if @mutex could be locked
7225 int trylock()() nothrow {
7226 return g_mutex_trylock(&this);
7229 // Unlocks @mutex. If another thread is blocked in a g_mutex_lock()
7230 // call for @mutex, it will become unblocked and can lock @mutex itself.
7232 // Calling g_mutex_unlock() on a mutex that is not locked by the
7233 // current thread leads to undefined behaviour.
7234 void unlock()() nothrow {
7235 g_mutex_unlock(&this);
7240 // The #GNode struct represents one node in a
7241 // <link linkend="glib-N-ary-Trees">N-ary Tree</link>. fields
7242 struct Node {
7243 void* data;
7244 Node* next, prev, parent, children;
7247 // Gets the position of the first child of a #GNode
7248 // which contains the given data.
7250 // @data, or -1 if the data is not found
7251 // RETURNS: the index of the child of @node which contains
7252 // <data>: the data to find
7253 int child_index()(void* data) nothrow {
7254 return g_node_child_index(&this, data);
7257 // Gets the position of a #GNode with respect to its siblings.
7258 // @child must be a child of @node. The first child is numbered 0,
7259 // the second 1, and so on.
7260 // RETURNS: the position of @child with respect to its siblings
7261 // <child>: a child of @node
7262 int child_position()(Node* child) nothrow {
7263 return g_node_child_position(&this, child);
7266 // Unintrospectable method: children_foreach() / g_node_children_foreach()
7267 // Calls a function for each of the children of a #GNode.
7268 // Note that it doesn't descend beneath the child nodes.
7269 // <flags>: which types of children are to be visited, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
7270 // <func>: the function to call for each visited node
7271 // <data>: user data to pass to the function
7272 void children_foreach()(TraverseFlags flags, NodeForeachFunc func, void* data) nothrow {
7273 g_node_children_foreach(&this, flags, func, data);
7276 // Unintrospectable method: copy() / g_node_copy()
7277 // Recursively copies a #GNode (but does not deep-copy the data inside the
7278 // nodes, see g_node_copy_deep() if you need that).
7279 // RETURNS: a new #GNode containing the same data pointers
7280 Node* copy()() nothrow {
7281 return g_node_copy(&this);
7284 // Unintrospectable method: copy_deep() / g_node_copy_deep()
7285 // VERSION: 2.4
7286 // Recursively copies a #GNode and its data.
7287 // RETURNS: a new #GNode containing copies of the data in @node.
7288 // <copy_func>: the function which is called to copy the data inside each node, or %NULL to use the original data.
7289 // <data>: data to pass to @copy_func
7290 Node* copy_deep()(CopyFunc copy_func, void* data) nothrow {
7291 return g_node_copy_deep(&this, copy_func, data);
7294 // Gets the depth of a #GNode.
7296 // If @node is %NULL the depth is 0. The root node has a depth of 1.
7297 // For the children of the root node the depth is 2. And so on.
7298 // RETURNS: the depth of the #GNode
7299 uint depth()() nothrow {
7300 return g_node_depth(&this);
7303 // Removes @root and its children from the tree, freeing any memory
7304 // allocated.
7305 void destroy()() nothrow {
7306 g_node_destroy(&this);
7309 // Unintrospectable method: find() / g_node_find()
7310 // Finds a #GNode in a tree.
7311 // RETURNS: the found #GNode, or %NULL if the data is not found
7312 // <order>: the order in which nodes are visited - %G_IN_ORDER, %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER
7313 // <flags>: which types of children are to be searched, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
7314 // <data>: the data to find
7315 Node* find()(TraverseType order, TraverseFlags flags, void* data) nothrow {
7316 return g_node_find(&this, order, flags, data);
7319 // Unintrospectable method: find_child() / g_node_find_child()
7320 // Finds the first child of a #GNode with the given data.
7321 // RETURNS: the found child #GNode, or %NULL if the data is not found
7322 // <flags>: which types of children are to be searched, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
7323 // <data>: the data to find
7324 Node* find_child()(TraverseFlags flags, void* data) nothrow {
7325 return g_node_find_child(&this, flags, data);
7328 // Unintrospectable method: first_sibling() / g_node_first_sibling()
7329 // Gets the first sibling of a #GNode.
7330 // This could possibly be the node itself.
7331 // RETURNS: the first sibling of @node
7332 Node* first_sibling()() nothrow {
7333 return g_node_first_sibling(&this);
7336 // Unintrospectable method: get_root() / g_node_get_root()
7337 // Gets the root of a tree.
7338 // RETURNS: the root of the tree
7339 Node* get_root()() nothrow {
7340 return g_node_get_root(&this);
7343 // Unintrospectable method: insert() / g_node_insert()
7344 // Inserts a #GNode beneath the parent at the given position.
7345 // RETURNS: the inserted #GNode
7346 // <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
7347 // <node>: the #GNode to insert
7348 Node* insert()(int position, Node* node) nothrow {
7349 return g_node_insert(&this, position, node);
7352 // Unintrospectable method: insert_after() / g_node_insert_after()
7353 // Inserts a #GNode beneath the parent after the given sibling.
7354 // RETURNS: the inserted #GNode
7355 // <sibling>: the sibling #GNode to place @node after. If sibling is %NULL, the node is inserted as the first child of @parent.
7356 // <node>: the #GNode to insert
7357 Node* insert_after()(Node* sibling, Node* node) nothrow {
7358 return g_node_insert_after(&this, sibling, node);
7361 // Unintrospectable method: insert_before() / g_node_insert_before()
7362 // Inserts a #GNode beneath the parent before the given sibling.
7363 // RETURNS: the inserted #GNode
7364 // <sibling>: the sibling #GNode to place @node before. If sibling is %NULL, the node is inserted as the last child of @parent.
7365 // <node>: the #GNode to insert
7366 Node* insert_before()(Node* sibling, Node* node) nothrow {
7367 return g_node_insert_before(&this, sibling, node);
7370 // Returns %TRUE if @node is an ancestor of @descendant.
7371 // This is true if node is the parent of @descendant,
7372 // or if node is the grandparent of @descendant etc.
7373 // RETURNS: %TRUE if @node is an ancestor of @descendant
7374 // <descendant>: a #GNode
7375 int is_ancestor()(Node* descendant) nothrow {
7376 return g_node_is_ancestor(&this, descendant);
7379 // Unintrospectable method: last_child() / g_node_last_child()
7380 // Gets the last child of a #GNode.
7381 // RETURNS: the last child of @node, or %NULL if @node has no children
7382 Node* last_child()() nothrow {
7383 return g_node_last_child(&this);
7386 // Unintrospectable method: last_sibling() / g_node_last_sibling()
7387 // Gets the last sibling of a #GNode.
7388 // This could possibly be the node itself.
7389 // RETURNS: the last sibling of @node
7390 Node* last_sibling()() nothrow {
7391 return g_node_last_sibling(&this);
7394 // Gets the maximum height of all branches beneath a #GNode.
7395 // This is the maximum distance from the #GNode to all leaf nodes.
7397 // If @root is %NULL, 0 is returned. If @root has no children,
7398 // 1 is returned. If @root has children, 2 is returned. And so on.
7399 // RETURNS: the maximum height of the tree beneath @root
7400 uint max_height()() nothrow {
7401 return g_node_max_height(&this);
7404 // Gets the number of children of a #GNode.
7405 // RETURNS: the number of children of @node
7406 uint n_children()() nothrow {
7407 return g_node_n_children(&this);
7410 // Gets the number of nodes in a tree.
7411 // RETURNS: the number of nodes in the tree
7412 // <flags>: which types of children are to be counted, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
7413 uint n_nodes()(TraverseFlags flags) nothrow {
7414 return g_node_n_nodes(&this, flags);
7417 // Unintrospectable method: nth_child() / g_node_nth_child()
7418 // Gets a child of a #GNode, using the given index.
7419 // The first child is at index 0. If the index is
7420 // too big, %NULL is returned.
7421 // RETURNS: the child of @node at index @n
7422 // <n>: the index of the desired child
7423 Node* nth_child()(uint n) nothrow {
7424 return g_node_nth_child(&this, n);
7427 // Unintrospectable method: prepend() / g_node_prepend()
7428 // Inserts a #GNode as the first child of the given parent.
7429 // RETURNS: the inserted #GNode
7430 // <node>: the #GNode to insert
7431 Node* prepend()(Node* node) nothrow {
7432 return g_node_prepend(&this, node);
7435 // Reverses the order of the children of a #GNode.
7436 // (It doesn't change the order of the grandchildren.)
7437 void reverse_children()() nothrow {
7438 g_node_reverse_children(&this);
7441 // Unintrospectable method: traverse() / g_node_traverse()
7442 // Traverses a tree starting at the given root #GNode.
7443 // It calls the given function for each node visited.
7444 // The traversal can be halted at any point by returning %TRUE from @func.
7445 // <order>: the order in which nodes are visited - %G_IN_ORDER, %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER.
7446 // <flags>: which types of children are to be visited, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
7447 // <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.
7448 // <func>: the function to call for each visited #GNode
7449 // <data>: user data to pass to the function
7450 void traverse()(TraverseType order, TraverseFlags flags, int max_depth, NodeTraverseFunc func, void* data) nothrow {
7451 g_node_traverse(&this, order, flags, max_depth, func, data);
7453 // Unlinks a #GNode from a tree, resulting in two separate trees.
7454 void unlink()() nothrow {
7455 g_node_unlink(&this);
7458 // Unintrospectable function: new() / g_node_new()
7459 // Creates a new #GNode containing the given data.
7460 // Used to create the first node in a tree.
7461 // RETURNS: a new #GNode
7462 // <data>: the data of the new node
7463 static Node* new_()(void* data) nothrow {
7464 return g_node_new(data);
7469 // Specifies the type of function passed to g_node_children_foreach().
7470 // The function is called with each child node, together with the user
7471 // data passed to g_node_children_foreach().
7472 // <node>: a #GNode.
7473 // <data>: user data passed to g_node_children_foreach().
7474 extern (C) alias void function (Node* node, void* data) nothrow NodeForeachFunc;
7477 // Specifies the type of function passed to g_node_traverse(). The
7478 // function is called with each of the nodes visited, together with the
7479 // user data passed to g_node_traverse(). If the function returns
7480 // %TRUE, then the traversal is stopped.
7481 // <node>: a #GNode.
7482 // <data>: user data passed to g_node_traverse().
7483 extern (C) alias int function (Node* node, void* data) nothrow NodeTraverseFunc;
7486 // Defines how a Unicode string is transformed in a canonical
7487 // form, standardizing such issues as whether a character with
7488 // an accent is represented as a base character and combining
7489 // accent or as a single precomposed character. Unicode strings
7490 // should generally be normalized before comparing them.
7491 enum NormalizeMode {
7492 DEFAULT = 0,
7493 NFD = 0,
7494 DEFAULT_COMPOSE = 1,
7495 NFC = 1,
7496 ALL = 2,
7497 NFKD = 2,
7498 ALL_COMPOSE = 3,
7499 NFKC = 3
7501 enum OPTION_REMAINING = "";
7503 // A #GOnce struct controls a one-time initialization function. Any
7504 // one-time initialization function must have its own unique #GOnce
7505 // struct.
7506 struct Once /* Version 2.4 */ {
7507 OnceStatus status;
7508 void* retval;
7510 // Unintrospectable method: impl() / g_once_impl()
7511 void* impl()(ThreadFunc func, void* arg) nothrow {
7512 return g_once_impl(&this, func, arg);
7515 // VERSION: 2.14
7516 // Function to be called when starting a critical initialization
7517 // section. The argument @location must point to a static
7518 // 0-initialized variable that will be set to a value other than 0 at
7519 // the end of the initialization section. In combination with
7520 // g_once_init_leave() and the unique address @value_location, it can
7521 // be ensured that an initialization section will be executed only once
7522 // during a program's life time, and that concurrent threads are
7523 // blocked until initialization completed. To be used in constructs
7524 // like this:
7526 // |[
7527 // static gsize initialization_value = 0;
7529 // if (g_once_init_enter (&amp;initialization_value))
7530 // {
7531 // gsize setup_value = 42; /&ast;* initialization code here *&ast;/
7533 // g_once_init_leave (&amp;initialization_value, setup_value);
7534 // }
7536 // /&ast;* use initialization_value here *&ast;/
7537 // ]|
7539 // %FALSE and blocks otherwise
7540 // RETURNS: %TRUE if the initialization section should be entered,
7541 // <location>: location of a static initializable variable containing 0
7542 static int init_enter()(void* location) nothrow {
7543 return g_once_init_enter(location);
7546 // VERSION: 2.14
7547 // Counterpart to g_once_init_enter(). Expects a location of a static
7548 // 0-initialized initialization variable, and an initialization value
7549 // other than 0. Sets the variable to the initialization value, and
7550 // releases concurrent threads blocking in g_once_init_enter() on this
7551 // initialization variable.
7552 // <location>: location of a static initializable variable containing 0
7553 // <result>: new non-0 value for *@value_location
7554 static void init_leave()(void* location, size_t result) nothrow {
7555 g_once_init_leave(location, result);
7560 // The possible statuses of a one-time initialization function
7561 // controlled by a #GOnce struct.
7562 enum OnceStatus /* Version 2.4 */ {
7563 NOTCALLED = 0,
7564 PROGRESS = 1,
7565 READY = 2
7568 // The #GOptionArg enum values determine which type of extra argument the
7569 // options expect to find. If an option expects an extra argument, it
7570 // can be specified in several ways; with a short option:
7571 // <option>-x arg</option>, with a long option: <option>--name arg</option>
7572 // or combined in a single argument: <option>--name=arg</option>.
7573 enum OptionArg {
7574 NONE = 0,
7575 STRING = 1,
7576 INT = 2,
7577 CALLBACK = 3,
7578 FILENAME = 4,
7579 STRING_ARRAY = 5,
7580 FILENAME_ARRAY = 6,
7581 DOUBLE = 7,
7582 INT64 = 8
7585 // The type of function to be passed as callback for %G_OPTION_ARG_CALLBACK
7586 // options.
7588 // occurred, in which case @error should be set with g_set_error()
7589 // RETURNS: %TRUE if the option was successfully parsed, %FALSE if an error
7590 // <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.
7591 // <value>: The value to be parsed.
7592 // <data>: User data added to the #GOptionGroup containing the option when it was created with g_option_group_new()
7593 extern (C) alias int function (char* option_name, char* value, void* data, GLib2.Error** error=null) nothrow OptionArgFunc;
7596 // A <structname>GOptionContext</structname> struct defines which options
7597 // are accepted by the commandline option parser. The struct has only private
7598 // fields and should not be directly accessed.
7599 struct OptionContext {
7601 // VERSION: 2.6
7602 // Adds a #GOptionGroup to the @context, so that parsing with @context
7603 // will recognize the options in the group. Note that the group will
7604 // be freed together with the context when g_option_context_free() is
7605 // called, so you must not free the group yourself after adding it
7606 // to a context.
7607 // <group>: the group to add
7608 void add_group()(OptionGroup* group) nothrow {
7609 g_option_context_add_group(&this, group);
7612 // VERSION: 2.6
7613 // A convenience function which creates a main group if it doesn't
7614 // exist, adds the @entries to it and sets the translation domain.
7615 // <entries>: a %NULL-terminated array of #GOptionEntry<!-- -->s
7616 // <translation_domain>: a translation domain to use for translating the <option>--help</option> output for the options in @entries with gettext(), or %NULL
7617 void add_main_entries()(OptionEntry* entries, char* translation_domain) nothrow {
7618 g_option_context_add_main_entries(&this, entries, translation_domain);
7621 // VERSION: 2.6
7622 // Frees context and all the groups which have been
7623 // added to it.
7625 // Please note that parsed arguments need to be freed separately (see
7626 // #GOptionEntry).
7627 void free()() nothrow {
7628 g_option_context_free(&this);
7631 // VERSION: 2.12
7632 // Returns the description. See g_option_context_set_description().
7633 // RETURNS: the description
7634 char* get_description()() nothrow {
7635 return g_option_context_get_description(&this);
7638 // VERSION: 2.14
7639 // Returns a formatted, translated help text for the given context.
7640 // To obtain the text produced by <option>--help</option>, call
7641 // <literal>g_option_context_get_help (context, TRUE, NULL)</literal>.
7642 // To obtain the text produced by <option>--help-all</option>, call
7643 // <literal>g_option_context_get_help (context, FALSE, NULL)</literal>.
7644 // To obtain the help text for an option group, call
7645 // <literal>g_option_context_get_help (context, FALSE, group)</literal>.
7646 // RETURNS: A newly allocated string containing the help text
7647 // <main_help>: if %TRUE, only include the main group
7648 // <group>: the #GOptionGroup to create help for, or %NULL
7649 char* /*new*/ get_help()(int main_help, OptionGroup* group) nothrow {
7650 return g_option_context_get_help(&this, main_help, group);
7653 // VERSION: 2.6
7654 // Returns whether automatic <option>--help</option> generation
7655 // is turned on for @context. See g_option_context_set_help_enabled().
7656 // RETURNS: %TRUE if automatic help generation is turned on.
7657 int get_help_enabled()() nothrow {
7658 return g_option_context_get_help_enabled(&this);
7661 // VERSION: 2.6
7662 // Returns whether unknown options are ignored or not. See
7663 // g_option_context_set_ignore_unknown_options().
7664 // RETURNS: %TRUE if unknown options are ignored.
7665 int get_ignore_unknown_options()() nothrow {
7666 return g_option_context_get_ignore_unknown_options(&this);
7669 // Unintrospectable method: get_main_group() / g_option_context_get_main_group()
7670 // VERSION: 2.6
7671 // Returns a pointer to the main group of @context.
7673 // have a main group. Note that group belongs to @context and should
7674 // not be modified or freed.
7675 // RETURNS: the main group of @context, or %NULL if @context doesn't
7676 OptionGroup* get_main_group()() nothrow {
7677 return g_option_context_get_main_group(&this);
7680 // VERSION: 2.12
7681 // Returns the summary. See g_option_context_set_summary().
7682 // RETURNS: the summary
7683 char* get_summary()() nothrow {
7684 return g_option_context_get_summary(&this);
7687 // VERSION: 2.6
7688 // Parses the command line arguments, recognizing options
7689 // which have been added to @context. A side-effect of
7690 // calling this function is that g_set_prgname() will be
7691 // called.
7693 // If the parsing is successful, any parsed arguments are
7694 // removed from the array and @argc and @argv are updated
7695 // accordingly. A '--' option is stripped from @argv
7696 // unless there are unparsed options before and after it,
7697 // or some of the options after it start with '-'. In case
7698 // of an error, @argc and @argv are left unmodified.
7700 // If automatic <option>--help</option> support is enabled
7701 // (see g_option_context_set_help_enabled()), and the
7702 // @argv array contains one of the recognized help options,
7703 // this function will produce help output to stdout and
7704 // call <literal>exit (0)</literal>.
7706 // Note that function depends on the
7707 // <link linkend="setlocale">current locale</link> for
7708 // automatic character set conversion of string and filename
7709 // arguments.
7711 // %FALSE if an error occurred
7712 // RETURNS: %TRUE if the parsing was successful,
7713 // <argc>: a pointer to the number of command line arguments
7714 // <argv>: a pointer to the array of command line arguments
7715 int parse()(/*inout*/ int* argc, /*inout*/ char*** argv, GLib2.Error** error=null) nothrow {
7716 return g_option_context_parse(&this, argc, argv, error);
7719 // VERSION: 2.12
7720 // Adds a string to be displayed in <option>--help</option> output
7721 // after the list of options. This text often includes a bug reporting
7722 // address.
7724 // Note that the summary is translated (see
7725 // g_option_context_set_translate_func()).
7726 // <description>: a string to be shown in <option>--help</option> output after the list of options, or %NULL
7727 void set_description()(char* description) nothrow {
7728 g_option_context_set_description(&this, description);
7731 // VERSION: 2.6
7732 // Enables or disables automatic generation of <option>--help</option>
7733 // output. By default, g_option_context_parse() recognizes
7734 // <option>--help</option>, <option>-h</option>,
7735 // <option>-?</option>, <option>--help-all</option>
7736 // and <option>--help-</option><replaceable>groupname</replaceable> and creates
7737 // suitable output to stdout.
7738 // <help_enabled>: %TRUE to enable <option>--help</option>, %FALSE to disable it
7739 void set_help_enabled()(int help_enabled) nothrow {
7740 g_option_context_set_help_enabled(&this, help_enabled);
7743 // VERSION: 2.6
7744 // Sets whether to ignore unknown options or not. If an argument is
7745 // ignored, it is left in the @argv array after parsing. By default,
7746 // g_option_context_parse() treats unknown options as error.
7748 // This setting does not affect non-option arguments (i.e. arguments
7749 // which don't start with a dash). But note that GOption cannot reliably
7750 // determine whether a non-option belongs to a preceding unknown option.
7751 // <ignore_unknown>: %TRUE to ignore unknown options, %FALSE to produce an error when unknown options are met
7752 void set_ignore_unknown_options()(int ignore_unknown) nothrow {
7753 g_option_context_set_ignore_unknown_options(&this, ignore_unknown);
7756 // VERSION: 2.6
7757 // Sets a #GOptionGroup as main group of the @context.
7758 // This has the same effect as calling g_option_context_add_group(),
7759 // the only difference is that the options in the main group are
7760 // treated differently when generating <option>--help</option> output.
7761 // <group>: the group to set as main group
7762 void set_main_group()(OptionGroup* group) nothrow {
7763 g_option_context_set_main_group(&this, group);
7766 // VERSION: 2.12
7767 // Adds a string to be displayed in <option>--help</option> output
7768 // before the list of options. This is typically a summary of the
7769 // program functionality.
7771 // Note that the summary is translated (see
7772 // g_option_context_set_translate_func() and
7773 // g_option_context_set_translation_domain()).
7774 // <summary>: a string to be shown in <option>--help</option> output before the list of options, or %NULL
7775 void set_summary()(char* summary) nothrow {
7776 g_option_context_set_summary(&this, summary);
7779 // VERSION: 2.12
7780 // Sets the function which is used to translate the contexts
7781 // user-visible strings, for <option>--help</option> output.
7782 // If @func is %NULL, strings are not translated.
7784 // Note that option groups have their own translation functions,
7785 // this function only affects the @parameter_string (see g_option_context_new()),
7786 // the summary (see g_option_context_set_summary()) and the description
7787 // (see g_option_context_set_description()).
7789 // If you are using gettext(), you only need to set the translation
7790 // domain, see g_option_context_set_translation_domain().
7791 // <func>: the #GTranslateFunc, or %NULL
7792 // <data>: user data to pass to @func, or %NULL
7793 // <destroy_notify>: a function which gets called to free @data, or %NULL
7794 void set_translate_func()(TranslateFunc func, void* data, DestroyNotify destroy_notify) nothrow {
7795 g_option_context_set_translate_func(&this, func, data, destroy_notify);
7798 // VERSION: 2.12
7799 // A convenience function to use gettext() for translating
7800 // user-visible strings.
7801 // <domain>: the domain to use
7802 void set_translation_domain()(char* domain) nothrow {
7803 g_option_context_set_translation_domain(&this, domain);
7806 // Unintrospectable function: new() / g_option_context_new()
7807 // VERSION: 2.6
7808 // Creates a new option context.
7810 // The @parameter_string can serve multiple purposes. It can be used
7811 // to add descriptions for "rest" arguments, which are not parsed by
7812 // the #GOptionContext, typically something like "FILES" or
7813 // "FILE1 FILE2...". If you are using #G_OPTION_REMAINING for
7814 // collecting "rest" arguments, GLib handles this automatically by
7815 // using the @arg_description of the corresponding #GOptionEntry in
7816 // the usage summary.
7818 // Another usage is to give a short summary of the program
7819 // functionality, like " - frob the strings", which will be displayed
7820 // in the same line as the usage. For a longer description of the
7821 // program functionality that should be displayed as a paragraph
7822 // below the usage line, use g_option_context_set_summary().
7824 // Note that the @parameter_string is translated using the
7825 // function set with g_option_context_set_translate_func(), so
7826 // it should normally be passed untranslated.
7828 // freed with g_option_context_free() after use.
7829 // RETURNS: a newly created #GOptionContext, which must be
7830 // <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>
7831 static OptionContext* new_()(char* parameter_string) nothrow {
7832 return g_option_context_new(parameter_string);
7837 // A <structname>GOptionEntry</structname> defines a single option.
7838 // To have an effect, they must be added to a #GOptionGroup with
7839 // g_option_context_add_main_entries() or g_option_group_add_entries().
7840 struct OptionEntry {
7841 char* long_name;
7842 char short_name;
7843 int flags;
7844 OptionArg arg;
7845 void* arg_data;
7846 char* description, arg_description;
7849 // Error codes returned by option parsing.
7850 enum OptionError {
7851 UNKNOWN_OPTION = 0,
7852 BAD_VALUE = 1,
7853 FAILED = 2
7856 // The type of function to be used as callback when a parse error occurs.
7857 // <context>: The active #GOptionContext
7858 // <group>: The group to which the function belongs
7859 // <data>: User data added to the #GOptionGroup containing the option when it was created with g_option_group_new()
7860 extern (C) alias void function (OptionContext* context, OptionGroup* group, void* data, GLib2.Error** error=null) nothrow OptionErrorFunc;
7862 // Flags which modify individual options.
7863 enum OptionFlags {
7864 HIDDEN = 1,
7865 IN_MAIN = 2,
7866 REVERSE = 4,
7867 NO_ARG = 8,
7868 FILENAME = 16,
7869 OPTIONAL_ARG = 32,
7870 NOALIAS = 64
7873 // A <structname>GOptionGroup</structname> struct defines the options in a single
7874 // group. The struct has only private fields and should not be directly accessed.
7876 // All options in a group share the same translation function. Libraries which
7877 // need to parse commandline options are expected to provide a function for
7878 // getting a <structname>GOptionGroup</structname> holding their options, which
7879 // the application can then add to its #GOptionContext.
7880 struct OptionGroup {
7882 // VERSION: 2.6
7883 // Adds the options specified in @entries to @group.
7884 // <entries>: a %NULL-terminated array of #GOptionEntry<!-- -->s
7885 void add_entries()(OptionEntry* entries) nothrow {
7886 g_option_group_add_entries(&this, entries);
7889 // VERSION: 2.6
7890 // Frees a #GOptionGroup. Note that you must <emphasis>not</emphasis>
7891 // free groups which have been added to a #GOptionContext.
7892 void free()() nothrow {
7893 g_option_group_free(&this);
7896 // Unintrospectable method: set_error_hook() / g_option_group_set_error_hook()
7897 // VERSION: 2.6
7898 // Associates a function with @group which will be called
7899 // from g_option_context_parse() when an error occurs.
7901 // Note that the user data to be passed to @error_func can be
7902 // specified when constructing the group with g_option_group_new().
7903 // <error_func>: a function to call when an error occurs
7904 void set_error_hook()(OptionErrorFunc error_func) nothrow {
7905 g_option_group_set_error_hook(&this, error_func);
7908 // Unintrospectable method: set_parse_hooks() / g_option_group_set_parse_hooks()
7909 // VERSION: 2.6
7910 // Associates two functions with @group which will be called
7911 // from g_option_context_parse() before the first option is parsed
7912 // and after the last option has been parsed, respectively.
7914 // Note that the user data to be passed to @pre_parse_func and
7915 // @post_parse_func can be specified when constructing the group
7916 // with g_option_group_new().
7917 // <pre_parse_func>: a function to call before parsing, or %NULL
7918 // <post_parse_func>: a function to call after parsing, or %NULL
7919 void set_parse_hooks()(OptionParseFunc pre_parse_func, OptionParseFunc post_parse_func) nothrow {
7920 g_option_group_set_parse_hooks(&this, pre_parse_func, post_parse_func);
7923 // VERSION: 2.6
7924 // Sets the function which is used to translate user-visible
7925 // strings, for <option>--help</option> output. Different
7926 // groups can use different #GTranslateFunc<!-- -->s. If @func
7927 // is %NULL, strings are not translated.
7929 // If you are using gettext(), you only need to set the translation
7930 // domain, see g_option_group_set_translation_domain().
7931 // <func>: the #GTranslateFunc, or %NULL
7932 // <data>: user data to pass to @func, or %NULL
7933 // <destroy_notify>: a function which gets called to free @data, or %NULL
7934 void set_translate_func()(TranslateFunc func, void* data, DestroyNotify destroy_notify) nothrow {
7935 g_option_group_set_translate_func(&this, func, data, destroy_notify);
7938 // VERSION: 2.6
7939 // A convenience function to use gettext() for translating
7940 // user-visible strings.
7941 // <domain>: the domain to use
7942 void set_translation_domain()(char* domain) nothrow {
7943 g_option_group_set_translation_domain(&this, domain);
7946 // Unintrospectable function: new() / g_option_group_new()
7947 // VERSION: 2.6
7948 // Creates a new #GOptionGroup.
7950 // to a #GOptionContext or freed with g_option_group_free().
7951 // RETURNS: a newly created option group. It should be added
7952 // <name>: the name for the option group, this is used to provide help for the options in this group with <option>--help-</option>@name
7953 // <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
7954 // <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
7955 // <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
7956 // <destroy>: a function that will be called to free @user_data, or %NULL
7957 static OptionGroup* new_()(char* name, char* description, char* help_description, void* user_data, DestroyNotify destroy) nothrow {
7958 return g_option_group_new(name, description, help_description, user_data, destroy);
7963 // The type of function that can be called before and after parsing.
7965 // occurred, in which case @error should be set with g_set_error()
7966 // RETURNS: %TRUE if the function completed successfully, %FALSE if an error
7967 // <context>: The active #GOptionContext
7968 // <group>: The group to which the function belongs
7969 // <data>: User data added to the #GOptionGroup containing the option when it was created with g_option_group_new()
7970 extern (C) alias int function (OptionContext* context, OptionGroup* group, void* data, GLib2.Error** error=null) nothrow OptionParseFunc;
7972 enum int PDP_ENDIAN = 3412;
7973 enum double PI = 3.141593;
7974 enum double PI_2 = 1.570796;
7975 enum double PI_4 = 0.785398;
7976 enum POLLFD_FORMAT = "%#I64x";
7977 enum int PRIORITY_DEFAULT = 0;
7978 enum int PRIORITY_DEFAULT_IDLE = 200;
7979 enum int PRIORITY_HIGH = -100;
7980 enum int PRIORITY_HIGH_IDLE = 100;
7981 enum int PRIORITY_LOW = 300;
7983 // A <structname>GPatternSpec</structname> is the 'compiled' form of a
7984 // pattern. This structure is opaque and its fields cannot be accessed
7985 // directly.
7986 struct PatternSpec {
7988 // Compares two compiled pattern specs and returns whether they will
7989 // match the same set of strings.
7990 // <pspec2>: another #GPatternSpec
7991 int equal()(PatternSpec* pspec2) nothrow {
7992 return g_pattern_spec_equal(&this, pspec2);
7994 // Frees the memory allocated for the #GPatternSpec.
7995 void free()() nothrow {
7996 g_pattern_spec_free(&this);
7999 // Unintrospectable function: new() / g_pattern_spec_new()
8000 // Compiles a pattern to a #GPatternSpec.
8001 // <pattern>: a zero-terminated UTF-8 encoded string
8002 static PatternSpec* new_()(char* pattern) nothrow {
8003 return g_pattern_spec_new(pattern);
8008 // Represents a file descriptor, which events to poll for, and which events
8009 // occurred.
8010 struct PollFD {
8011 int fd;
8012 ushort events, revents;
8016 // Specifies the type of function passed to g_main_context_set_poll_func().
8017 // The semantics of the function should match those of the poll() system call.
8019 // reported, or -1 if an error occurred.
8020 // RETURNS: the number of #GPollFD elements which have events or errors
8021 // <ufds>: an array of #GPollFD elements
8022 // <nfsd>: the number of elements in @ufds
8023 // <timeout_>: the maximum time to wait for an event of the file descriptors. A negative value indicates an infinite timeout.
8024 extern (C) alias int function (PollFD* ufds, uint nfsd, int timeout_) nothrow PollFunc;
8027 // Specifies the type of the print handler functions.
8028 // These are called with the complete formatted string to output.
8029 // <string>: the message to output
8030 extern (C) alias void function (char* string_) nothrow PrintFunc;
8033 // The #GPrivate struct is an opaque data structure to represent a
8034 // thread-local data key. It is approximately equivalent to the
8035 // pthread_setspecific()/pthread_getspecific() APIs on POSIX and to
8036 // TlsSetValue()/TlsGetValue() on Windows.
8038 // If you don't already know why you might want this functionality,
8039 // then you probably don't need it.
8041 // #GPrivate is a very limited resource (as far as 128 per program,
8042 // shared between all libraries). It is also not possible to destroy a
8043 // #GPrivate after it has been used. As such, it is only ever acceptable
8044 // to use #GPrivate in static scope, and even then sparingly so.
8046 // See G_PRIVATE_INIT() for a couple of examples.
8048 // The #GPrivate structure should be considered opaque. It should only
8049 // be accessed via the <function>g_private_</function> functions.
8050 struct Private {
8051 private void* p;
8052 private DestroyNotify notify;
8053 private void*[2] future;
8056 // Unintrospectable method: get() / g_private_get()
8057 // Returns the current value of the thread local variable @key.
8059 // If the value has not yet been set in this thread, %NULL is returned.
8060 // Values are never copied between threads (when a new thread is
8061 // created, for example).
8062 // RETURNS: the thread-local value
8063 void* get()() nothrow {
8064 return g_private_get(&this);
8067 // VERSION: 2.32
8068 // Sets the thread local variable @key to have the value @value in the
8069 // current thread.
8071 // This function differs from g_private_set() in the following way: if
8072 // the previous value was non-%NULL then the #GDestroyNotify handler for
8073 // @key is run on it.
8074 // <value>: the new value
8075 void replace()(void* value) nothrow {
8076 g_private_replace(&this, value);
8079 // Sets the thread local variable @key to have the value @value in the
8080 // current thread.
8082 // This function differs from g_private_replace() in the following way:
8083 // the #GDestroyNotify for @key is not called on the old value.
8084 // <value>: the new value
8085 void set()(void* value) nothrow {
8086 g_private_set(&this, value);
8090 // Contains the public fields of a pointer array.
8091 struct PtrArray {
8092 void** pdata;
8093 uint len;
8096 // Adds a pointer to the end of the pointer array. The array will grow
8097 // in size automatically if necessary.
8098 // <array>: a #GPtrArray.
8099 // <data>: the pointer to add.
8100 static void add()(PtrArray* array, void* data) nothrow {
8101 g_ptr_array_add(array, data);
8104 // Unintrospectable function: foreach() / g_ptr_array_foreach()
8105 // VERSION: 2.4
8106 // Calls a function for each element of a #GPtrArray.
8107 // <array>: a #GPtrArray
8108 // <func>: the function to call for each array element
8109 // <user_data>: user data to pass to the function
8110 static void foreach_()(PtrArray* array, Func func, void* user_data) nothrow {
8111 g_ptr_array_foreach(array, func, user_data);
8114 // Unintrospectable function: free() / g_ptr_array_free()
8115 // Frees the memory allocated for the #GPtrArray. If @free_seg is %TRUE
8116 // it frees the memory block holding the elements as well. Pass %FALSE
8117 // if you want to free the #GPtrArray wrapper but preserve the
8118 // underlying array for use elsewhere. If the reference count of @array
8119 // is greater than one, the #GPtrArray wrapper is preserved but the
8120 // size of @array will be set to zero.
8122 // <note><para>If array contents point to dynamically-allocated
8123 // memory, they should be freed separately if @free_seg is %TRUE and no
8124 // #GDestroyNotify function has been set for @array.</para></note>
8125 // <array>: a #GPtrArray.
8126 // <free_seg>: if %TRUE the actual pointer array is freed as well.
8127 static void** free()(PtrArray* array, int free_seg) nothrow {
8128 return g_ptr_array_free(array, free_seg);
8131 // Unintrospectable function: new() / g_ptr_array_new()
8132 // Creates a new #GPtrArray with a reference count of 1.
8133 static PtrArray* new_()() nothrow {
8134 return g_ptr_array_new();
8137 // Unintrospectable function: new_full() / g_ptr_array_new_full()
8138 // VERSION: 2.30
8139 // Creates a new #GPtrArray with @reserved_size pointers preallocated
8140 // and a reference count of 1. This avoids frequent reallocation, if
8141 // you are going to add many pointers to the array. Note however that
8142 // the size of the array is still 0. It also set @element_free_func
8143 // for freeing each element when the array is destroyed either via
8144 // g_ptr_array_unref(), when g_ptr_array_free() is called with @free_segment
8145 // set to %TRUE or when removing elements.
8146 // RETURNS: A new #GPtrArray.
8147 // <reserved_size>: number of pointers preallocated.
8148 // <element_free_func>: A function to free elements with destroy @array or %NULL.
8149 static PtrArray* new_full()(uint reserved_size, DestroyNotify element_free_func) nothrow {
8150 return g_ptr_array_new_full(reserved_size, element_free_func);
8153 // Unintrospectable function: new_with_free_func() / g_ptr_array_new_with_free_func()
8154 // VERSION: 2.22
8155 // Creates a new #GPtrArray with a reference count of 1 and use @element_free_func
8156 // for freeing each element when the array is destroyed either via
8157 // g_ptr_array_unref(), when g_ptr_array_free() is called with @free_segment
8158 // set to %TRUE or when removing elements.
8159 // RETURNS: A new #GPtrArray.
8160 // <element_free_func>: A function to free elements with destroy @array or %NULL.
8161 static PtrArray* new_with_free_func()(DestroyNotify element_free_func) nothrow {
8162 return g_ptr_array_new_with_free_func(element_free_func);
8165 // Unintrospectable function: ref() / g_ptr_array_ref()
8166 // VERSION: 2.22
8167 // Atomically increments the reference count of @array by one. This
8168 // function is MT-safe and may be called from any thread.
8169 // RETURNS: The passed in #GPtrArray.
8170 // <array>: A #GArray.
8171 static PtrArray* ref_()(PtrArray* array) nothrow {
8172 return g_ptr_array_ref(array);
8175 // Removes the first occurrence of the given pointer from the pointer
8176 // array. The following elements are moved down one place. If @array
8177 // has a non-%NULL #GDestroyNotify function it is called for the
8178 // removed element.
8180 // It returns %TRUE if the pointer was removed, or %FALSE if the
8181 // pointer was not found.
8182 // <array>: a #GPtrArray.
8183 // <data>: the pointer to remove.
8184 static int remove()(PtrArray* array, void* data) nothrow {
8185 return g_ptr_array_remove(array, data);
8188 // Removes the first occurrence of the given pointer from the pointer
8189 // array. The last element in the array is used to fill in the space,
8190 // so this function does not preserve the order of the array. But it is
8191 // faster than g_ptr_array_remove(). If @array has a non-%NULL
8192 // #GDestroyNotify function it is called for the removed element.
8194 // It returns %TRUE if the pointer was removed, or %FALSE if the
8195 // pointer was not found.
8196 // <array>: a #GPtrArray.
8197 // <data>: the pointer to remove.
8198 static int remove_fast()(PtrArray* array, void* data) nothrow {
8199 return g_ptr_array_remove_fast(array, data);
8202 // Unintrospectable function: remove_index() / g_ptr_array_remove_index()
8203 // Removes the pointer at the given index from the pointer array. The
8204 // following elements are moved down one place. If @array has a
8205 // non-%NULL #GDestroyNotify function it is called for the removed
8206 // element.
8207 // <array>: a #GPtrArray.
8208 // <index_>: the index of the pointer to remove.
8209 static void* remove_index()(PtrArray* array, uint index_) nothrow {
8210 return g_ptr_array_remove_index(array, index_);
8213 // Unintrospectable function: remove_index_fast() / g_ptr_array_remove_index_fast()
8214 // Removes the pointer at the given index from the pointer array. The
8215 // last element in the array is used to fill in the space, so this
8216 // function does not preserve the order of the array. But it is faster
8217 // than g_ptr_array_remove_index(). If @array has a non-%NULL
8218 // #GDestroyNotify function it is called for the removed element.
8219 // <array>: a #GPtrArray.
8220 // <index_>: the index of the pointer to remove.
8221 static void* remove_index_fast()(PtrArray* array, uint index_) nothrow {
8222 return g_ptr_array_remove_index_fast(array, index_);
8225 // VERSION: 2.4
8226 // Removes the given number of pointers starting at the given index
8227 // from a #GPtrArray. The following elements are moved to close the
8228 // gap. If @array has a non-%NULL #GDestroyNotify function it is called
8229 // for the removed elements.
8230 // <array>: a @GPtrArray.
8231 // <index_>: the index of the first pointer to remove.
8232 // <length>: the number of pointers to remove.
8233 static void remove_range()(PtrArray* array, uint index_, uint length) nothrow {
8234 g_ptr_array_remove_range(array, index_, length);
8237 // VERSION: 2.22
8238 // Sets a function for freeing each element when @array is destroyed
8239 // either via g_ptr_array_unref(), when g_ptr_array_free() is called
8240 // with @free_segment set to %TRUE or when removing elements.
8241 // <array>: A #GPtrArray.
8242 // <element_free_func>: A function to free elements with destroy @array or %NULL.
8243 static void set_free_func()(PtrArray* array, DestroyNotify element_free_func) nothrow {
8244 g_ptr_array_set_free_func(array, element_free_func);
8247 // Sets the size of the array. When making the array larger,
8248 // newly-added elements will be set to %NULL. When making it smaller,
8249 // if @array has a non-%NULL #GDestroyNotify function then it will be
8250 // called for the removed elements.
8251 // <array>: a #GPtrArray.
8252 // <length>: the new length of the pointer array.
8253 static void set_size()(PtrArray* array, int length) nothrow {
8254 g_ptr_array_set_size(array, length);
8257 // Unintrospectable function: sized_new() / g_ptr_array_sized_new()
8258 // Creates a new #GPtrArray with @reserved_size pointers preallocated
8259 // and a reference count of 1. This avoids frequent reallocation, if
8260 // you are going to add many pointers to the array. Note however that
8261 // the size of the array is still 0.
8262 // <reserved_size>: number of pointers preallocated.
8263 static PtrArray* sized_new()(uint reserved_size) nothrow {
8264 return g_ptr_array_sized_new(reserved_size);
8267 // Unintrospectable function: sort() / g_ptr_array_sort()
8268 // Sorts the array, using @compare_func which should be a qsort()-style
8269 // comparison function (returns less than zero for first arg is less
8270 // than second arg, zero for equal, greater than zero if irst arg is
8271 // greater than second arg).
8273 // If two array elements compare equal, their order in the sorted array
8274 // is undefined. If you want equal elements to keep their order (i.e.
8275 // you want a stable sort) you can write a comparison function that,
8276 // if two elements would otherwise compare equal, compares them by
8277 // their addresses.
8279 // <note><para>The comparison function for g_ptr_array_sort() doesn't
8280 // take the pointers from the array as arguments, it takes pointers to
8281 // the pointers in the array.</para></note>
8282 // <array>: a #GPtrArray.
8283 // <compare_func>: comparison function.
8284 static void sort()(PtrArray* array, CompareFunc compare_func) nothrow {
8285 g_ptr_array_sort(array, compare_func);
8288 // Unintrospectable function: sort_with_data() / g_ptr_array_sort_with_data()
8289 // Like g_ptr_array_sort(), but the comparison function has an extra
8290 // user data argument.
8292 // <note><para>The comparison function for g_ptr_array_sort_with_data()
8293 // doesn't take the pointers from the array as arguments, it takes
8294 // pointers to the pointers in the array.</para></note>
8295 // <array>: a #GPtrArray.
8296 // <compare_func>: comparison function.
8297 // <user_data>: data to pass to @compare_func.
8298 static void sort_with_data()(PtrArray* array, CompareDataFunc compare_func, void* user_data) nothrow {
8299 g_ptr_array_sort_with_data(array, compare_func, user_data);
8302 // VERSION: 2.22
8303 // Atomically decrements the reference count of @array by one. If the
8304 // reference count drops to 0, the effect is the same as calling
8305 // g_ptr_array_free() with @free_segment set to %TRUE. This function
8306 // is MT-safe and may be called from any thread.
8307 // <array>: A #GPtrArray.
8308 static void unref()(PtrArray* array) nothrow {
8309 g_ptr_array_unref(array);
8314 // Contains the public fields of a
8315 // <link linkend="glib-Double-ended-Queues">Queue</link>.
8316 struct Queue {
8317 GLib2.List* head, tail;
8318 uint length;
8321 // VERSION: 2.14
8322 // Removes all the elements in @queue. If queue elements contain
8323 // dynamically-allocated memory, they should be freed first.
8324 void clear()() nothrow {
8325 g_queue_clear(&this);
8328 // Unintrospectable method: copy() / g_queue_copy()
8329 // VERSION: 2.4
8330 // Copies a @queue. Note that is a shallow copy. If the elements in the
8331 // queue consist of pointers to data, the pointers are copied, but the
8332 // actual data is not.
8333 // RETURNS: A copy of @queue
8334 Queue* copy()() nothrow {
8335 return g_queue_copy(&this);
8338 // Unintrospectable method: delete_link() / g_queue_delete_link()
8339 // VERSION: 2.4
8340 // Removes @link_ from @queue and frees it.
8342 // @link_ must be part of @queue.
8343 // <link_>: a #GList link that <emphasis>must</emphasis> be part of @queue
8344 void delete_link()(GLib2.List* link_) nothrow {
8345 g_queue_delete_link(&this, link_);
8348 // Unintrospectable method: find() / g_queue_find()
8349 // VERSION: 2.4
8350 // Finds the first link in @queue which contains @data.
8351 // RETURNS: The first link in @queue which contains @data.
8352 // <data>: data to find
8353 GLib2.List* find()(const(void)* data) nothrow {
8354 return g_queue_find(&this, data);
8357 // Unintrospectable method: find_custom() / g_queue_find_custom()
8358 // VERSION: 2.4
8359 // Finds an element in a #GQueue, using a supplied function to find the
8360 // desired element. It iterates over the queue, calling the given function
8361 // which should return 0 when the desired element is found. The function
8362 // takes two gconstpointer arguments, the #GQueue element's data as the
8363 // first argument and the given user data as the second argument.
8364 // RETURNS: The found link, or %NULL if it wasn't found
8365 // <data>: user data passed to @func
8366 // <func>: a #GCompareFunc to call for each element. It should return 0 when the desired element is found
8367 GLib2.List* find_custom()(const(void)* data, CompareFunc func) nothrow {
8368 return g_queue_find_custom(&this, data, func);
8371 // Unintrospectable method: foreach() / g_queue_foreach()
8372 // VERSION: 2.4
8373 // Calls @func for each element in the queue passing @user_data to the
8374 // function.
8375 // <func>: the function to call for each element's data
8376 // <user_data>: user data to pass to @func
8377 void foreach_()(Func func, void* user_data) nothrow {
8378 g_queue_foreach(&this, func, user_data);
8381 // Frees the memory allocated for the #GQueue. Only call this function if
8382 // @queue was created with g_queue_new(). If queue elements contain
8383 // dynamically-allocated memory, they should be freed first.
8385 // <note><para>
8386 // If queue elements contain dynamically-allocated memory,
8387 // you should either use g_queue_free_full() or free them manually
8388 // first.
8389 // </para></note>
8390 void free()() nothrow {
8391 g_queue_free(&this);
8394 // VERSION: 2.32
8395 // Convenience method, which frees all the memory used by a #GQueue, and
8396 // calls the specified destroy function on every element's data.
8397 // <free_func>: the function to be called to free each element's data
8398 void free_full()(DestroyNotify free_func) nothrow {
8399 g_queue_free_full(&this, free_func);
8402 // VERSION: 2.4
8403 // Returns the number of items in @queue.
8404 // RETURNS: The number of items in @queue.
8405 uint get_length()() nothrow {
8406 return g_queue_get_length(&this);
8409 // VERSION: 2.4
8410 // Returns the position of the first element in @queue which contains @data.
8411 // RETURNS: The position of the first element in @queue which contains @data, or -1 if no element in @queue contains @data.
8412 // <data>: the data to find.
8413 int index()(const(void)* data) nothrow {
8414 return g_queue_index(&this, data);
8417 // VERSION: 2.14
8418 // A statically-allocated #GQueue must be initialized with this function
8419 // before it can be used. Alternatively you can initialize it with
8420 // #G_QUEUE_INIT. It is not necessary to initialize queues created with
8421 // g_queue_new().
8422 void init()() nothrow {
8423 g_queue_init(&this);
8426 // Unintrospectable method: insert_after() / g_queue_insert_after()
8427 // VERSION: 2.4
8428 // Inserts @data into @queue after @sibling
8430 // @sibling must be part of @queue
8431 // <sibling>: a #GList link that <emphasis>must</emphasis> be part of @queue
8432 // <data>: the data to insert
8433 void insert_after()(GLib2.List* sibling, void* data) nothrow {
8434 g_queue_insert_after(&this, sibling, data);
8437 // Unintrospectable method: insert_before() / g_queue_insert_before()
8438 // VERSION: 2.4
8439 // Inserts @data into @queue before @sibling.
8441 // @sibling must be part of @queue.
8442 // <sibling>: a #GList link that <emphasis>must</emphasis> be part of @queue
8443 // <data>: the data to insert
8444 void insert_before()(GLib2.List* sibling, void* data) nothrow {
8445 g_queue_insert_before(&this, sibling, data);
8448 // Unintrospectable method: insert_sorted() / g_queue_insert_sorted()
8449 // VERSION: 2.4
8450 // Inserts @data into @queue using @func to determine the new position.
8451 // <data>: the data to insert
8452 // <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.
8453 // <user_data>: user data passed to @func.
8454 void insert_sorted()(void* data, CompareDataFunc func, void* user_data) nothrow {
8455 g_queue_insert_sorted(&this, data, func, user_data);
8458 // Returns %TRUE if the queue is empty.
8459 // RETURNS: %TRUE if the queue is empty.
8460 int is_empty()() nothrow {
8461 return g_queue_is_empty(&this);
8464 // Unintrospectable method: link_index() / g_queue_link_index()
8465 // VERSION: 2.4
8466 // Returns the position of @link_ in @queue.
8468 // not part of @queue
8469 // RETURNS: The position of @link_, or -1 if the link is
8470 // <link_>: A #GList link
8471 int link_index()(GLib2.List* link_) nothrow {
8472 return g_queue_link_index(&this, link_);
8475 // Unintrospectable method: peek_head() / g_queue_peek_head()
8476 // Returns the first element of the queue.
8478 // is empty.
8479 // RETURNS: the data of the first element in the queue, or %NULL if the queue
8480 void* peek_head()() nothrow {
8481 return g_queue_peek_head(&this);
8484 // Unintrospectable method: peek_head_link() / g_queue_peek_head_link()
8485 // VERSION: 2.4
8486 // Returns the first link in @queue
8487 // RETURNS: the first link in @queue, or %NULL if @queue is empty
8488 GLib2.List* peek_head_link()() nothrow {
8489 return g_queue_peek_head_link(&this);
8492 // Unintrospectable method: peek_nth() / g_queue_peek_nth()
8493 // VERSION: 2.4
8494 // Returns the @n'th element of @queue.
8496 // off the end of @queue.
8497 // RETURNS: The data for the @n'th element of @queue, or %NULL if @n is
8498 // <n>: the position of the element.
8499 void* peek_nth()(uint n) nothrow {
8500 return g_queue_peek_nth(&this, n);
8503 // Unintrospectable method: peek_nth_link() / g_queue_peek_nth_link()
8504 // VERSION: 2.4
8505 // Returns the link at the given position
8507 // end of the list
8508 // RETURNS: The link at the @n'th position, or %NULL if @n is off the
8509 // <n>: the position of the link
8510 GLib2.List* peek_nth_link()(uint n) nothrow {
8511 return g_queue_peek_nth_link(&this, n);
8514 // Unintrospectable method: peek_tail() / g_queue_peek_tail()
8515 // Returns the last element of the queue.
8517 // is empty.
8518 // RETURNS: the data of the last element in the queue, or %NULL if the queue
8519 void* peek_tail()() nothrow {
8520 return g_queue_peek_tail(&this);
8523 // Unintrospectable method: peek_tail_link() / g_queue_peek_tail_link()
8524 // VERSION: 2.4
8525 // Returns the last link @queue.
8526 // RETURNS: the last link in @queue, or %NULL if @queue is empty
8527 GLib2.List* peek_tail_link()() nothrow {
8528 return g_queue_peek_tail_link(&this);
8531 // Unintrospectable method: pop_head() / g_queue_pop_head()
8532 // Removes the first element of the queue.
8534 // is empty.
8535 // RETURNS: the data of the first element in the queue, or %NULL if the queue
8536 void* pop_head()() nothrow {
8537 return g_queue_pop_head(&this);
8540 // Unintrospectable method: pop_head_link() / g_queue_pop_head_link()
8541 // Removes the first element of the queue.
8543 // is empty.
8544 // RETURNS: the #GList element at the head of the queue, or %NULL if the queue
8545 GLib2.List* pop_head_link()() nothrow {
8546 return g_queue_pop_head_link(&this);
8549 // Unintrospectable method: pop_nth() / g_queue_pop_nth()
8550 // VERSION: 2.4
8551 // Removes the @n'th element of @queue.
8552 // RETURNS: the element's data, or %NULL if @n is off the end of @queue.
8553 // <n>: the position of the element.
8554 void* pop_nth()(uint n) nothrow {
8555 return g_queue_pop_nth(&this, n);
8558 // Unintrospectable method: pop_nth_link() / g_queue_pop_nth_link()
8559 // VERSION: 2.4
8560 // Removes and returns the link at the given position.
8561 // RETURNS: The @n'th link, or %NULL if @n is off the end of @queue.
8562 // <n>: the link's position
8563 GLib2.List* pop_nth_link()(uint n) nothrow {
8564 return g_queue_pop_nth_link(&this, n);
8567 // Unintrospectable method: pop_tail() / g_queue_pop_tail()
8568 // Removes the last element of the queue.
8570 // is empty.
8571 // RETURNS: the data of the last element in the queue, or %NULL if the queue
8572 void* pop_tail()() nothrow {
8573 return g_queue_pop_tail(&this);
8576 // Unintrospectable method: pop_tail_link() / g_queue_pop_tail_link()
8577 // Removes the last element of the queue.
8579 // is empty.
8580 // RETURNS: the #GList element at the tail of the queue, or %NULL if the queue
8581 GLib2.List* pop_tail_link()() nothrow {
8582 return g_queue_pop_tail_link(&this);
8585 // Adds a new element at the head of the queue.
8586 // <data>: the data for the new element.
8587 void push_head()(void* data) nothrow {
8588 g_queue_push_head(&this, data);
8591 // Unintrospectable method: push_head_link() / g_queue_push_head_link()
8592 // Adds a new element at the head of the queue.
8593 // <link_>: a single #GList element, <emphasis>not</emphasis> a list with more than one element.
8594 void push_head_link()(GLib2.List* link_) nothrow {
8595 g_queue_push_head_link(&this, link_);
8598 // VERSION: 2.4
8599 // Inserts a new element into @queue at the given position
8600 // <data>: the data for the new element
8601 // <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.
8602 void push_nth()(void* data, int n) nothrow {
8603 g_queue_push_nth(&this, data, n);
8606 // Unintrospectable method: push_nth_link() / g_queue_push_nth_link()
8607 // VERSION: 2.4
8608 // Inserts @link into @queue at the given position.
8609 // <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.
8610 // <link_>: the link to add to @queue
8611 void push_nth_link()(int n, GLib2.List* link_) nothrow {
8612 g_queue_push_nth_link(&this, n, link_);
8615 // Adds a new element at the tail of the queue.
8616 // <data>: the data for the new element.
8617 void push_tail()(void* data) nothrow {
8618 g_queue_push_tail(&this, data);
8621 // Unintrospectable method: push_tail_link() / g_queue_push_tail_link()
8622 // Adds a new element at the tail of the queue.
8623 // <link_>: a single #GList element, <emphasis>not</emphasis> a list with more than one element.
8624 void push_tail_link()(GLib2.List* link_) nothrow {
8625 g_queue_push_tail_link(&this, link_);
8628 // VERSION: 2.4
8629 // Removes the first element in @queue that contains @data.
8630 // RETURNS: %TRUE if @data was found and removed from @queue
8631 // <data>: data to remove.
8632 int remove()(const(void)* data) nothrow {
8633 return g_queue_remove(&this, data);
8636 // VERSION: 2.4
8637 // Remove all elements whose data equals @data from @queue.
8638 // RETURNS: the number of elements removed from @queue
8639 // <data>: data to remove
8640 uint remove_all()(const(void)* data) nothrow {
8641 return g_queue_remove_all(&this, data);
8644 // VERSION: 2.4
8645 // Reverses the order of the items in @queue.
8646 void reverse()() nothrow {
8647 g_queue_reverse(&this);
8650 // Unintrospectable method: sort() / g_queue_sort()
8651 // VERSION: 2.4
8652 // Sorts @queue using @compare_func.
8653 // <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.
8654 // <user_data>: user data passed to @compare_func
8655 void sort()(CompareDataFunc compare_func, void* user_data) nothrow {
8656 g_queue_sort(&this, compare_func, user_data);
8659 // Unintrospectable method: unlink() / g_queue_unlink()
8660 // VERSION: 2.4
8661 // Unlinks @link_ so that it will no longer be part of @queue. The link is
8662 // not freed.
8664 // @link_ must be part of @queue,
8665 // <link_>: a #GList link that <emphasis>must</emphasis> be part of @queue
8666 void unlink()(GLib2.List* link_) nothrow {
8667 g_queue_unlink(&this, link_);
8670 // Unintrospectable function: new() / g_queue_new()
8671 // Creates a new #GQueue.
8672 // RETURNS: a new #GQueue.
8673 static Queue* new_()() nothrow {
8674 return g_queue_new();
8679 // The GRWLock struct is an opaque data structure to represent a
8680 // reader-writer lock. It is similar to a #GMutex in that it allows
8681 // multiple threads to coordinate access to a shared resource.
8683 // The difference to a mutex is that a reader-writer lock discriminates
8684 // between read-only ('reader') and full ('writer') access. While only
8685 // one thread at a time is allowed write access (by holding the 'writer'
8686 // lock via g_rw_lock_writer_lock()), multiple threads can gain
8687 // simultaneous read-only access (by holding the 'reader' lock via
8688 // g_rw_lock_reader_lock()).
8690 // <example>
8691 // <title>An array with access functions</title>
8692 // <programlisting>
8693 // GRWLock lock;
8694 // GPtrArray *array;
8696 // gpointer
8697 // my_array_get (guint index)
8698 // {
8699 // gpointer retval = NULL;
8701 // if (!array)
8702 // return NULL;
8704 // g_rw_lock_reader_lock (&amp;lock);
8705 // if (index &lt; array->len)
8706 // retval = g_ptr_array_index (array, index);
8707 // g_rw_lock_reader_unlock (&amp;lock);
8709 // return retval;
8710 // }
8712 // void
8713 // my_array_set (guint index, gpointer data)
8714 // {
8715 // g_rw_lock_writer_lock (&amp;lock);
8717 // if (!array)
8718 // array = g_ptr_array_new (<!-- -->);
8720 // if (index >= array->len)
8721 // g_ptr_array_set_size (array, index+1);
8722 // g_ptr_array_index (array, index) = data;
8724 // g_rw_lock_writer_unlock (&amp;lock);
8725 // }
8726 // </programlisting>
8727 // <para>
8728 // This example shows an array which can be accessed by many readers
8729 // (the <function>my_array_get()</function> function) simultaneously,
8730 // whereas the writers (the <function>my_array_set()</function>
8731 // function) will only be allowed once at a time and only if no readers
8732 // currently access the array. This is because of the potentially
8733 // dangerous resizing of the array. Using these functions is fully
8734 // multi-thread safe now.
8735 // </para>
8736 // </example>
8738 // If a #GRWLock is allocated in static storage then it can be used
8739 // without initialisation. Otherwise, you should call
8740 // g_rw_lock_init() on it and g_rw_lock_clear() when done.
8742 // A GRWLock should only be accessed with the
8743 // <function>g_rw_lock_</function> functions.
8744 struct RWLock /* Version 2.32 */ {
8745 private void* p;
8746 private uint[2] i;
8749 // Frees the resources allocated to a lock with g_rw_lock_init().
8751 // This function should not be used with a #GRWLock that has been
8752 // statically allocated.
8754 // Calling g_rw_lock_clear() when any thread holds the lock
8755 // leads to undefined behaviour.
8757 // Sine: 2.32
8758 void clear()() nothrow {
8759 g_rw_lock_clear(&this);
8762 // VERSION: 2.32
8763 // Initializes a #GRWLock so that it can be used.
8765 // This function is useful to initialize a lock that has been
8766 // allocated on the stack, or as part of a larger structure. It is not
8767 // necessary to initialise a reader-writer lock that has been statically
8768 // allocated.
8770 // |[
8771 // typedef struct {
8772 // GRWLock l;
8773 // ...
8774 // } Blob;
8776 // Blob *b;
8778 // b = g_new (Blob, 1);
8779 // g_rw_lock_init (&b->l);
8780 // ]|
8782 // To undo the effect of g_rw_lock_init() when a lock is no longer
8783 // needed, use g_rw_lock_clear().
8785 // Calling g_rw_lock_init() on an already initialized #GRWLock leads
8786 // to undefined behaviour.
8787 void init()() nothrow {
8788 g_rw_lock_init(&this);
8791 // VERSION: 2.32
8792 // Obtain a read lock on @rw_lock. If another thread currently holds
8793 // the write lock on @rw_lock or blocks waiting for it, the current
8794 // thread will block. Read locks can be taken recursively.
8796 // It is implementation-defined how many threads are allowed to
8797 // hold read locks on the same lock simultaneously.
8798 void reader_lock()() nothrow {
8799 g_rw_lock_reader_lock(&this);
8802 // VERSION: 2.32
8803 // Tries to obtain a read lock on @rw_lock and returns %TRUE if
8804 // the read lock was successfully obtained. Otherwise it
8805 // returns %FALSE.
8806 // RETURNS: %TRUE if @rw_lock could be locked
8807 int reader_trylock()() nothrow {
8808 return g_rw_lock_reader_trylock(&this);
8811 // VERSION: 2.32
8812 // Release a read lock on @rw_lock.
8814 // Calling g_rw_lock_reader_unlock() on a lock that is not held
8815 // by the current thread leads to undefined behaviour.
8816 void reader_unlock()() nothrow {
8817 g_rw_lock_reader_unlock(&this);
8820 // VERSION: 2.32
8821 // Obtain a write lock on @rw_lock. If any thread already holds
8822 // a read or write lock on @rw_lock, the current thread will block
8823 // until all other threads have dropped their locks on @rw_lock.
8824 void writer_lock()() nothrow {
8825 g_rw_lock_writer_lock(&this);
8828 // VERSION: 2.32
8829 // Tries to obtain a write lock on @rw_lock. If any other thread holds
8830 // a read or write lock on @rw_lock, it immediately returns %FALSE.
8831 // Otherwise it locks @rw_lock and returns %TRUE.
8832 // RETURNS: %TRUE if @rw_lock could be locked
8833 int writer_trylock()() nothrow {
8834 return g_rw_lock_writer_trylock(&this);
8837 // VERSION: 2.32
8838 // Release a write lock on @rw_lock.
8840 // Calling g_rw_lock_writer_unlock() on a lock that is not held
8841 // by the current thread leads to undefined behaviour.
8842 void writer_unlock()() nothrow {
8843 g_rw_lock_writer_unlock(&this);
8848 // The #GRand struct is an opaque data structure. It should only be
8849 // accessed through the <function>g_rand_*</function> functions.
8850 struct Rand {
8852 // Unintrospectable method: copy() / g_rand_copy()
8853 // VERSION: 2.4
8854 // Copies a #GRand into a new one with the same exact state as before.
8855 // This way you can take a snapshot of the random number generator for
8856 // replaying later.
8857 // RETURNS: the new #GRand.
8858 Rand* copy()() nothrow {
8859 return g_rand_copy(&this);
8862 // Returns the next random #gdouble from @rand_ equally distributed over
8863 // the range [0..1).
8864 // RETURNS: A random number.
8865 double double_()() nothrow {
8866 return g_rand_double(&this);
8869 // Returns the next random #gdouble from @rand_ equally distributed over
8870 // the range [@begin..@end).
8871 // RETURNS: A random number.
8872 // <begin>: lower closed bound of the interval.
8873 // <end>: upper open bound of the interval.
8874 double double_range()(double begin, double end) nothrow {
8875 return g_rand_double_range(&this, begin, end);
8877 // Frees the memory allocated for the #GRand.
8878 void free()() nothrow {
8879 g_rand_free(&this);
8882 // Returns the next random #guint32 from @rand_ equally distributed over
8883 // the range [0..2^32-1].
8884 // RETURNS: A random number.
8885 uint int_()() nothrow {
8886 return g_rand_int(&this);
8889 // Returns the next random #gint32 from @rand_ equally distributed over
8890 // the range [@begin..@end-1].
8891 // RETURNS: A random number.
8892 // <begin>: lower closed bound of the interval.
8893 // <end>: upper open bound of the interval.
8894 int int_range()(int begin, int end) nothrow {
8895 return g_rand_int_range(&this, begin, end);
8898 // Sets the seed for the random number generator #GRand to @seed.
8899 // <seed>: a value to reinitialize the random number generator.
8900 void set_seed()(uint seed) nothrow {
8901 g_rand_set_seed(&this, seed);
8904 // VERSION: 2.4
8905 // Initializes the random number generator by an array of
8906 // longs. Array can be of arbitrary size, though only the
8907 // first 624 values are taken. This function is useful
8908 // if you have many low entropy seeds, or if you require more then
8909 // 32bits of actual entropy for your application.
8910 // <seed>: array to initialize with
8911 // <seed_length>: length of array
8912 void set_seed_array()(uint* seed, uint seed_length) nothrow {
8913 g_rand_set_seed_array(&this, seed, seed_length);
8916 // Unintrospectable function: new() / g_rand_new()
8917 // Creates a new random number generator initialized with a seed taken
8918 // either from <filename>/dev/urandom</filename> (if existing) or from
8919 // the current time (as a fallback).
8920 // RETURNS: the new #GRand.
8921 static Rand* new_()() nothrow {
8922 return g_rand_new();
8925 // Unintrospectable function: new_with_seed() / g_rand_new_with_seed()
8926 // Creates a new random number generator initialized with @seed.
8927 // RETURNS: the new #GRand.
8928 // <seed>: a value to initialize the random number generator.
8929 static Rand* new_with_seed()(uint seed) nothrow {
8930 return g_rand_new_with_seed(seed);
8933 // Unintrospectable function: new_with_seed_array() / g_rand_new_with_seed_array()
8934 // VERSION: 2.4
8935 // Creates a new random number generator initialized with @seed.
8936 // RETURNS: the new #GRand.
8937 // <seed>: an array of seeds to initialize the random number generator.
8938 // <seed_length>: an array of seeds to initialize the random number generator.
8939 static Rand* new_with_seed_array()(uint* seed, uint seed_length) nothrow {
8940 return g_rand_new_with_seed_array(seed, seed_length);
8945 // The GRecMutex struct is an opaque data structure to represent a
8946 // recursive mutex. It is similar to a #GMutex with the difference
8947 // that it is possible to lock a GRecMutex multiple times in the same
8948 // thread without deadlock. When doing so, care has to be taken to
8949 // unlock the recursive mutex as often as it has been locked.
8951 // If a #GRecMutex is allocated in static storage then it can be used
8952 // without initialisation. Otherwise, you should call
8953 // g_rec_mutex_init() on it and g_rec_mutex_clear() when done.
8955 // A GRecMutex should only be accessed with the
8956 // <function>g_rec_mutex_</function> functions.
8957 struct RecMutex /* Version 2.32 */ {
8958 private void* p;
8959 private uint[2] i;
8962 // Frees the resources allocated to a recursive mutex with
8963 // g_rec_mutex_init().
8965 // This function should not be used with a #GRecMutex that has been
8966 // statically allocated.
8968 // Calling g_rec_mutex_clear() on a locked recursive mutex leads
8969 // to undefined behaviour.
8971 // Sine: 2.32
8972 void clear()() nothrow {
8973 g_rec_mutex_clear(&this);
8976 // VERSION: 2.32
8977 // Initializes a #GRecMutex so that it can be used.
8979 // This function is useful to initialize a recursive mutex
8980 // that has been allocated on the stack, or as part of a larger
8981 // structure.
8983 // It is not necessary to initialise a recursive mutex that has been
8984 // statically allocated.
8986 // |[
8987 // typedef struct {
8988 // GRecMutex m;
8989 // ...
8990 // } Blob;
8992 // Blob *b;
8994 // b = g_new (Blob, 1);
8995 // g_rec_mutex_init (&b->m);
8996 // ]|
8998 // Calling g_rec_mutex_init() on an already initialized #GRecMutex
8999 // leads to undefined behaviour.
9001 // To undo the effect of g_rec_mutex_init() when a recursive mutex
9002 // is no longer needed, use g_rec_mutex_clear().
9003 void init()() nothrow {
9004 g_rec_mutex_init(&this);
9007 // VERSION: 2.32
9008 // Locks @rec_mutex. If @rec_mutex is already locked by another
9009 // thread, the current thread will block until @rec_mutex is
9010 // unlocked by the other thread. If @rec_mutex is already locked
9011 // by the current thread, the 'lock count' of @rec_mutex is increased.
9012 // The mutex will only become available again when it is unlocked
9013 // as many times as it has been locked.
9014 void lock()() nothrow {
9015 g_rec_mutex_lock(&this);
9018 // VERSION: 2.32
9019 // Tries to lock @rec_mutex. If @rec_mutex is already locked
9020 // by another thread, it immediately returns %FALSE. Otherwise
9021 // it locks @rec_mutex and returns %TRUE.
9022 // RETURNS: %TRUE if @rec_mutex could be locked
9023 int trylock()() nothrow {
9024 return g_rec_mutex_trylock(&this);
9027 // VERSION: 2.32
9028 // Unlocks @rec_mutex. If another thread is blocked in a
9029 // g_rec_mutex_lock() call for @rec_mutex, it will become unblocked
9030 // and can lock @rec_mutex itself.
9032 // Calling g_rec_mutex_unlock() on a recursive mutex that is not
9033 // locked by the current thread leads to undefined behaviour.
9034 void unlock()() nothrow {
9035 g_rec_mutex_unlock(&this);
9040 // The <function>g_regex_*()</function> functions implement regular
9041 // expression pattern matching using syntax and semantics similar to
9042 // Perl regular expression.
9044 // Some functions accept a @start_position argument, setting it differs
9045 // from just passing over a shortened string and setting #G_REGEX_MATCH_NOTBOL
9046 // in the case of a pattern that begins with any kind of lookbehind assertion.
9047 // For example, consider the pattern "\Biss\B" which finds occurrences of "iss"
9048 // in the middle of words. ("\B" matches only if the current position in the
9049 // subject is not a word boundary.) When applied to the string "Mississipi"
9050 // from the fourth byte, namely "issipi", it does not match, because "\B" is
9051 // always false at the start of the subject, which is deemed to be a word
9052 // boundary. However, if the entire string is passed , but with
9053 // @start_position set to 4, it finds the second occurrence of "iss" because
9054 // it is able to look behind the starting point to discover that it is
9055 // preceded by a letter.
9057 // Note that, unless you set the #G_REGEX_RAW flag, all the strings passed
9058 // to these functions must be encoded in UTF-8. The lengths and the positions
9059 // inside the strings are in bytes and not in characters, so, for instance,
9060 // "\xc3\xa0" (i.e. "&agrave;") is two bytes long but it is treated as a
9061 // single character. If you set #G_REGEX_RAW the strings can be non-valid
9062 // UTF-8 strings and a byte is treated as a character, so "\xc3\xa0" is two
9063 // bytes and two characters long.
9065 // When matching a pattern, "\n" matches only against a "\n" character in
9066 // the string, and "\r" matches only a "\r" character. To match any newline
9067 // sequence use "\R". This particular group matches either the two-character
9068 // sequence CR + LF ("\r\n"), or one of the single characters LF (linefeed,
9069 // U+000A, "\n"), VT vertical tab, U+000B, "\v"), FF (formfeed, U+000C, "\f"),
9070 // CR (carriage return, U+000D, "\r"), NEL (next line, U+0085), LS (line
9071 // separator, U+2028), or PS (paragraph separator, U+2029).
9073 // The behaviour of the dot, circumflex, and dollar metacharacters are
9074 // affected by newline characters, the default is to recognize any newline
9075 // character (the same characters recognized by "\R"). This can be changed
9076 // with #G_REGEX_NEWLINE_CR, #G_REGEX_NEWLINE_LF and #G_REGEX_NEWLINE_CRLF
9077 // compile options, and with #G_REGEX_MATCH_NEWLINE_ANY,
9078 // #G_REGEX_MATCH_NEWLINE_CR, #G_REGEX_MATCH_NEWLINE_LF and
9079 // #G_REGEX_MATCH_NEWLINE_CRLF match options. These settings are also
9080 // relevant when compiling a pattern if #G_REGEX_EXTENDED is set, and an
9081 // unescaped "#" outside a character class is encountered. This indicates
9082 // a comment that lasts until after the next newline.
9084 // Creating and manipulating the same #GRegex structure from different
9085 // threads is not a problem as #GRegex does not modify its internal
9086 // state between creation and destruction, on the other hand #GMatchInfo
9087 // is not threadsafe.
9089 // The regular expressions low-level functionalities are obtained through
9090 // the excellent <ulink url="http://www.pcre.org/">PCRE</ulink> library
9091 // written by Philip Hazel.
9092 struct Regex /* Version 2.14 */ {
9094 // VERSION: 2.14
9095 // Compiles the regular expression to an internal form, and does
9096 // the initial setup of the #GRegex structure.
9098 // are done with it
9099 // RETURNS: a #GRegex structure. Call g_regex_unref() when you
9100 // <pattern>: the regular expression
9101 // <compile_options>: compile options for the regular expression, or 0
9102 // <match_options>: match options for the regular expression, or 0
9103 static Regex* /*new*/ new_()(char* pattern, RegexCompileFlags compile_options, RegexMatchFlags match_options, GLib2.Error** error=null) nothrow {
9104 return g_regex_new(pattern, compile_options, match_options, error);
9106 alias new_!() opCall;
9108 // VERSION: 2.14
9109 // Returns the number of capturing subpatterns in the pattern.
9110 // RETURNS: the number of capturing subpatterns
9111 int get_capture_count()() nothrow {
9112 return g_regex_get_capture_count(&this);
9115 // VERSION: 2.26
9116 // Returns the compile options that @regex was created with.
9117 // RETURNS: flags from #GRegexCompileFlags
9118 RegexCompileFlags get_compile_flags()() nothrow {
9119 return g_regex_get_compile_flags(&this);
9122 // VERSION: 2.26
9123 // Returns the match options that @regex was created with.
9124 // RETURNS: flags from #GRegexMatchFlags
9125 RegexMatchFlags get_match_flags()() nothrow {
9126 return g_regex_get_match_flags(&this);
9129 // VERSION: 2.14
9130 // Returns the number of the highest back reference
9131 // in the pattern, or 0 if the pattern does not contain
9132 // back references.
9133 // RETURNS: the number of the highest back reference
9134 int get_max_backref()() nothrow {
9135 return g_regex_get_max_backref(&this);
9138 // VERSION: 2.14
9139 // Gets the pattern string associated with @regex, i.e. a copy of
9140 // the string passed to g_regex_new().
9141 // RETURNS: the pattern of @regex
9142 char* get_pattern()() nothrow {
9143 return g_regex_get_pattern(&this);
9146 // VERSION: 2.14
9147 // Retrieves the number of the subexpression named @name.
9149 // does not exists
9150 // RETURNS: The number of the subexpression or -1 if @name
9151 // <name>: name of the subexpression
9152 int get_string_number()(char* name) nothrow {
9153 return g_regex_get_string_number(&this, name);
9156 // VERSION: 2.14
9157 // Scans for a match in string for the pattern in @regex.
9158 // The @match_options are combined with the match options specified
9159 // when the @regex structure was created, letting you have more
9160 // flexibility in reusing #GRegex structures.
9162 // A #GMatchInfo structure, used to get information on the match,
9163 // is stored in @match_info if not %NULL. Note that if @match_info
9164 // is not %NULL then it is created even if the function returns %FALSE,
9165 // i.e. you must free it regardless if regular expression actually matched.
9167 // To retrieve all the non-overlapping matches of the pattern in
9168 // string you can use g_match_info_next().
9170 // |[
9171 // static void
9172 // print_uppercase_words (const gchar *string)
9173 // {
9174 // /&ast; Print all uppercase-only words. &ast;/
9175 // GRegex *regex;
9176 // GMatchInfo *match_info;
9177 // &nbsp;
9178 // regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
9179 // g_regex_match (regex, string, 0, &amp;match_info);
9180 // while (g_match_info_matches (match_info))
9181 // {
9182 // gchar *word = g_match_info_fetch (match_info, 0);
9183 // g_print ("Found: %s\n", word);
9184 // g_free (word);
9185 // g_match_info_next (match_info, NULL);
9186 // }
9187 // g_match_info_free (match_info);
9188 // g_regex_unref (regex);
9189 // }
9190 // ]|
9192 // @string is not copied and is used in #GMatchInfo internally. If
9193 // you use any #GMatchInfo method (except g_match_info_free()) after
9194 // freeing or modifying @string then the behaviour is undefined.
9195 // RETURNS: %TRUE is the string matched, %FALSE otherwise
9196 // <string>: the string to scan for matches
9197 // <match_options>: match options
9198 // <match_info>: pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
9199 int match()(char* string_, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info=null) nothrow {
9200 return g_regex_match(&this, string_, match_options, match_info);
9203 // VERSION: 2.14
9204 // Using the standard algorithm for regular expression matching only
9205 // the longest match in the string is retrieved. This function uses
9206 // a different algorithm so it can retrieve all the possible matches.
9207 // For more documentation see g_regex_match_all_full().
9209 // A #GMatchInfo structure, used to get information on the match, is
9210 // stored in @match_info if not %NULL. Note that if @match_info is
9211 // not %NULL then it is created even if the function returns %FALSE,
9212 // i.e. you must free it regardless if regular expression actually
9213 // matched.
9215 // @string is not copied and is used in #GMatchInfo internally. If
9216 // you use any #GMatchInfo method (except g_match_info_free()) after
9217 // freeing or modifying @string then the behaviour is undefined.
9218 // RETURNS: %TRUE is the string matched, %FALSE otherwise
9219 // <string>: the string to scan for matches
9220 // <match_options>: match options
9221 // <match_info>: pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
9222 int match_all()(char* string_, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info=null) nothrow {
9223 return g_regex_match_all(&this, string_, match_options, match_info);
9226 // VERSION: 2.14
9227 // Using the standard algorithm for regular expression matching only
9228 // the longest match in the string is retrieved, it is not possible
9229 // to obtain all the available matches. For instance matching
9230 // "&lt;a&gt; &lt;b&gt; &lt;c&gt;" against the pattern "&lt;.*&gt;"
9231 // you get "&lt;a&gt; &lt;b&gt; &lt;c&gt;".
9233 // This function uses a different algorithm (called DFA, i.e. deterministic
9234 // finite automaton), so it can retrieve all the possible matches, all
9235 // starting at the same point in the string. For instance matching
9236 // "&lt;a&gt; &lt;b&gt; &lt;c&gt;" against the pattern "&lt;.*&gt;"
9237 // you would obtain three matches: "&lt;a&gt; &lt;b&gt; &lt;c&gt;",
9238 // "&lt;a&gt; &lt;b&gt;" and "&lt;a&gt;".
9240 // The number of matched strings is retrieved using
9241 // g_match_info_get_match_count(). To obtain the matched strings and
9242 // their position you can use, respectively, g_match_info_fetch() and
9243 // g_match_info_fetch_pos(). Note that the strings are returned in
9244 // reverse order of length; that is, the longest matching string is
9245 // given first.
9247 // Note that the DFA algorithm is slower than the standard one and it
9248 // is not able to capture substrings, so backreferences do not work.
9250 // Setting @start_position differs from just passing over a shortened
9251 // string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
9252 // that begins with any kind of lookbehind assertion, such as "\b".
9254 // A #GMatchInfo structure, used to get information on the match, is
9255 // stored in @match_info if not %NULL. Note that if @match_info is
9256 // not %NULL then it is created even if the function returns %FALSE,
9257 // i.e. you must free it regardless if regular expression actually
9258 // matched.
9260 // @string is not copied and is used in #GMatchInfo internally. If
9261 // you use any #GMatchInfo method (except g_match_info_free()) after
9262 // freeing or modifying @string then the behaviour is undefined.
9263 // RETURNS: %TRUE is the string matched, %FALSE otherwise
9264 // <string>: the string to scan for matches
9265 // <string_len>: the length of @string, or -1 if @string is nul-terminated
9266 // <start_position>: starting index of the string to match
9267 // <match_options>: match options
9268 // <match_info>: pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
9269 int match_all_full()(char* string_, ssize_t string_len, int start_position, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info, GLib2.Error** error=null) nothrow {
9270 return g_regex_match_all_full(&this, string_, string_len, start_position, match_options, match_info, error);
9273 // VERSION: 2.14
9274 // Scans for a match in string for the pattern in @regex.
9275 // The @match_options are combined with the match options specified
9276 // when the @regex structure was created, letting you have more
9277 // flexibility in reusing #GRegex structures.
9279 // Setting @start_position differs from just passing over a shortened
9280 // string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
9281 // that begins with any kind of lookbehind assertion, such as "\b".
9283 // A #GMatchInfo structure, used to get information on the match, is
9284 // stored in @match_info if not %NULL. Note that if @match_info is
9285 // not %NULL then it is created even if the function returns %FALSE,
9286 // i.e. you must free it regardless if regular expression actually
9287 // matched.
9289 // @string is not copied and is used in #GMatchInfo internally. If
9290 // you use any #GMatchInfo method (except g_match_info_free()) after
9291 // freeing or modifying @string then the behaviour is undefined.
9293 // To retrieve all the non-overlapping matches of the pattern in
9294 // string you can use g_match_info_next().
9296 // |[
9297 // static void
9298 // print_uppercase_words (const gchar *string)
9299 // {
9300 // /&ast; Print all uppercase-only words. &ast;/
9301 // GRegex *regex;
9302 // GMatchInfo *match_info;
9303 // GError *error = NULL;
9304 // &nbsp;
9305 // regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
9306 // g_regex_match_full (regex, string, -1, 0, 0, &amp;match_info, &amp;error);
9307 // while (g_match_info_matches (match_info))
9308 // {
9309 // gchar *word = g_match_info_fetch (match_info, 0);
9310 // g_print ("Found: %s\n", word);
9311 // g_free (word);
9312 // g_match_info_next (match_info, &amp;error);
9313 // }
9314 // g_match_info_free (match_info);
9315 // g_regex_unref (regex);
9316 // if (error != NULL)
9317 // {
9318 // g_printerr ("Error while matching: %s\n", error->message);
9319 // g_error_free (error);
9320 // }
9321 // }
9322 // ]|
9323 // RETURNS: %TRUE is the string matched, %FALSE otherwise
9324 // <string>: the string to scan for matches
9325 // <string_len>: the length of @string, or -1 if @string is nul-terminated
9326 // <start_position>: starting index of the string to match
9327 // <match_options>: match options
9328 // <match_info>: pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
9329 int match_full()(char* string_, ssize_t string_len, int start_position, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info, GLib2.Error** error=null) nothrow {
9330 return g_regex_match_full(&this, string_, string_len, start_position, match_options, match_info, error);
9333 // VERSION: 2.14
9334 // Increases reference count of @regex by 1.
9335 // RETURNS: @regex
9336 Regex* /*new*/ ref_()() nothrow {
9337 return g_regex_ref(&this);
9340 // VERSION: 2.14
9341 // Replaces all occurrences of the pattern in @regex with the
9342 // replacement text. Backreferences of the form '\number' or
9343 // '\g&lt;number&gt;' in the replacement text are interpolated by the
9344 // number-th captured subexpression of the match, '\g&lt;name&gt;' refers
9345 // to the captured subexpression with the given name. '\0' refers to the
9346 // complete match, but '\0' followed by a number is the octal representation
9347 // of a character. To include a literal '\' in the replacement, write '\\'.
9348 // There are also escapes that changes the case of the following text:
9350 // <variablelist>
9351 // <varlistentry><term>\l</term>
9352 // <listitem>
9353 // <para>Convert to lower case the next character</para>
9354 // </listitem>
9355 // </varlistentry>
9356 // <varlistentry><term>\u</term>
9357 // <listitem>
9358 // <para>Convert to upper case the next character</para>
9359 // </listitem>
9360 // </varlistentry>
9361 // <varlistentry><term>\L</term>
9362 // <listitem>
9363 // <para>Convert to lower case till \E</para>
9364 // </listitem>
9365 // </varlistentry>
9366 // <varlistentry><term>\U</term>
9367 // <listitem>
9368 // <para>Convert to upper case till \E</para>
9369 // </listitem>
9370 // </varlistentry>
9371 // <varlistentry><term>\E</term>
9372 // <listitem>
9373 // <para>End case modification</para>
9374 // </listitem>
9375 // </varlistentry>
9376 // </variablelist>
9378 // If you do not need to use backreferences use g_regex_replace_literal().
9380 // The @replacement string must be UTF-8 encoded even if #G_REGEX_RAW was
9381 // passed to g_regex_new(). If you want to use not UTF-8 encoded stings
9382 // you can use g_regex_replace_literal().
9384 // Setting @start_position differs from just passing over a shortened
9385 // string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern that
9386 // begins with any kind of lookbehind assertion, such as "\b".
9387 // RETURNS: a newly allocated string containing the replacements
9388 // <string>: the string to perform matches against
9389 // <string_len>: the length of @string, or -1 if @string is nul-terminated
9390 // <start_position>: starting index of the string to match
9391 // <replacement>: text to replace each match with
9392 // <match_options>: options for the match
9393 char* /*new*/ replace()(char* string_, ssize_t string_len, int start_position, char* replacement, RegexMatchFlags match_options, GLib2.Error** error=null) nothrow {
9394 return g_regex_replace(&this, string_, string_len, start_position, replacement, match_options, error);
9397 // Unintrospectable method: replace_eval() / g_regex_replace_eval()
9398 // VERSION: 2.14
9399 // Replaces occurrences of the pattern in regex with the output of
9400 // @eval for that occurrence.
9402 // Setting @start_position differs from just passing over a shortened
9403 // string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
9404 // that begins with any kind of lookbehind assertion, such as "\b".
9406 // The following example uses g_regex_replace_eval() to replace multiple
9407 // strings at once:
9408 // |[
9409 // static gboolean
9410 // eval_cb (const GMatchInfo *info,
9411 // GString *res,
9412 // gpointer data)
9413 // {
9414 // gchar *match;
9415 // gchar *r;
9417 // match = g_match_info_fetch (info, 0);
9418 // r = g_hash_table_lookup ((GHashTable *)data, match);
9419 // g_string_append (res, r);
9420 // g_free (match);
9422 // return FALSE;
9423 // }
9425 // /&ast; ... &ast;/
9427 // GRegex *reg;
9428 // GHashTable *h;
9429 // gchar *res;
9431 // h = g_hash_table_new (g_str_hash, g_str_equal);
9433 // g_hash_table_insert (h, "1", "ONE");
9434 // g_hash_table_insert (h, "2", "TWO");
9435 // g_hash_table_insert (h, "3", "THREE");
9436 // g_hash_table_insert (h, "4", "FOUR");
9438 // reg = g_regex_new ("1|2|3|4", 0, 0, NULL);
9439 // res = g_regex_replace_eval (reg, text, -1, 0, 0, eval_cb, h, NULL);
9440 // g_hash_table_destroy (h);
9442 // /&ast; ... &ast;/
9443 // ]|
9444 // RETURNS: a newly allocated string containing the replacements
9445 // <string>: string to perform matches against
9446 // <string_len>: the length of @string, or -1 if @string is nul-terminated
9447 // <start_position>: starting index of the string to match
9448 // <match_options>: options for the match
9449 // <eval>: a function to call for each match
9450 // <user_data>: user data to pass to the function
9451 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) nothrow {
9452 return g_regex_replace_eval(&this, string_, string_len, start_position, match_options, eval, user_data, error);
9455 // VERSION: 2.14
9456 // Replaces all occurrences of the pattern in @regex with the
9457 // replacement text. @replacement is replaced literally, to
9458 // include backreferences use g_regex_replace().
9460 // Setting @start_position differs from just passing over a
9461 // shortened string and setting #G_REGEX_MATCH_NOTBOL in the
9462 // case of a pattern that begins with any kind of lookbehind
9463 // assertion, such as "\b".
9464 // RETURNS: a newly allocated string containing the replacements
9465 // <string>: the string to perform matches against
9466 // <string_len>: the length of @string, or -1 if @string is nul-terminated
9467 // <start_position>: starting index of the string to match
9468 // <replacement>: text to replace each match with
9469 // <match_options>: options for the match
9470 char* /*new*/ replace_literal()(char* string_, ssize_t string_len, int start_position, char* replacement, RegexMatchFlags match_options, GLib2.Error** error=null) nothrow {
9471 return g_regex_replace_literal(&this, string_, string_len, start_position, replacement, match_options, error);
9474 // Unintrospectable method: split() / g_regex_split()
9475 // VERSION: 2.14
9476 // Breaks the string on the pattern, and returns an array of the tokens.
9477 // If the pattern contains capturing parentheses, then the text for each
9478 // of the substrings will also be returned. If the pattern does not match
9479 // anywhere in the string, then the whole string is returned as the first
9480 // token.
9482 // As a special case, the result of splitting the empty string "" is an
9483 // empty vector, not a vector containing a single string. The reason for
9484 // this special case is that being able to represent a empty vector is
9485 // typically more useful than consistent handling of empty elements. If
9486 // you do need to represent empty elements, you'll need to check for the
9487 // empty string before calling this function.
9489 // A pattern that can match empty strings splits @string into separate
9490 // characters wherever it matches the empty string between characters.
9491 // For example splitting "ab c" using as a separator "\s*", you will get
9492 // "a", "b" and "c".
9493 // RETURNS: a %NULL-terminated gchar ** array. Free it using g_strfreev()
9494 // <string>: the string to split with the pattern
9495 // <match_options>: match time option flags
9496 char** split()(char* string_, RegexMatchFlags match_options) nothrow {
9497 return g_regex_split(&this, string_, match_options);
9500 // Unintrospectable method: split_full() / g_regex_split_full()
9501 // VERSION: 2.14
9502 // Breaks the string on the pattern, and returns an array of the tokens.
9503 // If the pattern contains capturing parentheses, then the text for each
9504 // of the substrings will also be returned. If the pattern does not match
9505 // anywhere in the string, then the whole string is returned as the first
9506 // token.
9508 // As a special case, the result of splitting the empty string "" is an
9509 // empty vector, not a vector containing a single string. The reason for
9510 // this special case is that being able to represent a empty vector is
9511 // typically more useful than consistent handling of empty elements. If
9512 // you do need to represent empty elements, you'll need to check for the
9513 // empty string before calling this function.
9515 // A pattern that can match empty strings splits @string into separate
9516 // characters wherever it matches the empty string between characters.
9517 // For example splitting "ab c" using as a separator "\s*", you will get
9518 // "a", "b" and "c".
9520 // Setting @start_position differs from just passing over a shortened
9521 // string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
9522 // that begins with any kind of lookbehind assertion, such as "\b".
9523 // RETURNS: a %NULL-terminated gchar ** array. Free it using g_strfreev()
9524 // <string>: the string to split with the pattern
9525 // <string_len>: the length of @string, or -1 if @string is nul-terminated
9526 // <start_position>: starting index of the string to match
9527 // <match_options>: match time option flags
9528 // <max_tokens>: the maximum number of tokens to split @string into. If this is less than 1, the string is split completely
9529 char** split_full()(char* string_, ssize_t string_len, int start_position, RegexMatchFlags match_options, int max_tokens, GLib2.Error** error=null) nothrow {
9530 return g_regex_split_full(&this, string_, string_len, start_position, match_options, max_tokens, error);
9533 // VERSION: 2.14
9534 // Decreases reference count of @regex by 1. When reference count drops
9535 // to zero, it frees all the memory associated with the regex structure.
9536 void unref()() nothrow {
9537 g_regex_unref(&this);
9540 // VERSION: 2.14
9541 // Checks whether @replacement is a valid replacement string
9542 // (see g_regex_replace()), i.e. that all escape sequences in
9543 // it are valid.
9545 // If @has_references is not %NULL then @replacement is checked
9546 // for pattern references. For instance, replacement text 'foo\n'
9547 // does not contain references and may be evaluated without information
9548 // about actual match, but '\0\1' (whole match followed by first
9549 // subpattern) requires valid #GMatchInfo object.
9550 // RETURNS: whether @replacement is a valid replacement string
9551 // <replacement>: the replacement string
9552 // <has_references>: location to store information about references in @replacement or %NULL
9553 static int check_replacement()(char* replacement, /*out*/ int* has_references, GLib2.Error** error=null) nothrow {
9554 return g_regex_check_replacement(replacement, has_references, error);
9556 static Quark error_quark()() nothrow {
9557 return g_regex_error_quark();
9560 // VERSION: 2.30
9561 // Escapes the nul characters in @string to "\x00". It can be used
9562 // to compile a regex with embedded nul characters.
9564 // For completeness, @length can be -1 for a nul-terminated string.
9565 // In this case the output string will be of course equal to @string.
9566 // RETURNS: a newly-allocated escaped string
9567 // <string>: the string to escape
9568 // <length>: the length of @string
9569 static char* /*new*/ escape_nul()(char* string_, int length) nothrow {
9570 return g_regex_escape_nul(string_, length);
9573 // VERSION: 2.14
9574 // Escapes the special characters used for regular expressions
9575 // in @string, for instance "a.b*c" becomes "a\.b\*c". This
9576 // function is useful to dynamically generate regular expressions.
9578 // @string can contain nul characters that are replaced with "\0",
9579 // in this case remember to specify the correct length of @string
9580 // in @length.
9581 // RETURNS: a newly-allocated escaped string
9582 // <string>: the string to escape
9583 // <length>: the length of @string, or -1 if @string is nul-terminated
9584 static char* /*new*/ escape_string()(char* string_, int length) nothrow {
9585 return g_regex_escape_string(string_, length);
9588 // VERSION: 2.14
9589 // Scans for a match in @string for @pattern.
9591 // This function is equivalent to g_regex_match() but it does not
9592 // require to compile the pattern with g_regex_new(), avoiding some
9593 // lines of code when you need just to do a match without extracting
9594 // substrings, capture counts, and so on.
9596 // If this function is to be called on the same @pattern more than
9597 // once, it's more efficient to compile the pattern once with
9598 // g_regex_new() and then use g_regex_match().
9599 // RETURNS: %TRUE if the string matched, %FALSE otherwise
9600 // <pattern>: the regular expression
9601 // <string>: the string to scan for matches
9602 // <compile_options>: compile options for the regular expression, or 0
9603 // <match_options>: match options, or 0
9604 static int match_simple()(char* pattern, char* string_, RegexCompileFlags compile_options, RegexMatchFlags match_options) nothrow {
9605 return g_regex_match_simple(pattern, string_, compile_options, match_options);
9608 // Unintrospectable function: split_simple() / g_regex_split_simple()
9609 // VERSION: 2.14
9610 // Breaks the string on the pattern, and returns an array of
9611 // the tokens. If the pattern contains capturing parentheses,
9612 // then the text for each of the substrings will also be returned.
9613 // If the pattern does not match anywhere in the string, then the
9614 // whole string is returned as the first token.
9616 // This function is equivalent to g_regex_split() but it does
9617 // not require to compile the pattern with g_regex_new(), avoiding
9618 // some lines of code when you need just to do a split without
9619 // extracting substrings, capture counts, and so on.
9621 // If this function is to be called on the same @pattern more than
9622 // once, it's more efficient to compile the pattern once with
9623 // g_regex_new() and then use g_regex_split().
9625 // As a special case, the result of splitting the empty string ""
9626 // is an empty vector, not a vector containing a single string.
9627 // The reason for this special case is that being able to represent
9628 // a empty vector is typically more useful than consistent handling
9629 // of empty elements. If you do need to represent empty elements,
9630 // you'll need to check for the empty string before calling this
9631 // function.
9633 // A pattern that can match empty strings splits @string into
9634 // separate characters wherever it matches the empty string between
9635 // characters. For example splitting "ab c" using as a separator
9636 // "\s*", you will get "a", "b" and "c".
9637 // RETURNS: a %NULL-terminated array of strings. Free it using g_strfreev()
9638 // <pattern>: the regular expression
9639 // <string>: the string to scan for matches
9640 // <compile_options>: compile options for the regular expression, or 0
9641 // <match_options>: match options, or 0
9642 static char** split_simple()(char* pattern, char* string_, RegexCompileFlags compile_options, RegexMatchFlags match_options) nothrow {
9643 return g_regex_split_simple(pattern, string_, compile_options, match_options);
9647 // Flags specifying compile-time options.
9648 enum RegexCompileFlags /* Version 2.14 */ {
9649 CASELESS = 1,
9650 MULTILINE = 2,
9651 DOTALL = 4,
9652 EXTENDED = 8,
9653 ANCHORED = 16,
9654 DOLLAR_ENDONLY = 32,
9655 UNGREEDY = 512,
9656 RAW = 2048,
9657 NO_AUTO_CAPTURE = 4096,
9658 OPTIMIZE = 8192,
9659 DUPNAMES = 524288,
9660 NEWLINE_CR = 1048576,
9661 NEWLINE_LF = 2097152,
9662 NEWLINE_CRLF = 3145728
9664 // Error codes returned by regular expressions functions.
9665 enum RegexError /* Version 2.14 */ {
9666 COMPILE = 0,
9667 OPTIMIZE = 1,
9668 REPLACE = 2,
9669 MATCH = 3,
9670 INTERNAL = 4,
9671 STRAY_BACKSLASH = 101,
9672 MISSING_CONTROL_CHAR = 102,
9673 UNRECOGNIZED_ESCAPE = 103,
9674 QUANTIFIERS_OUT_OF_ORDER = 104,
9675 QUANTIFIER_TOO_BIG = 105,
9676 UNTERMINATED_CHARACTER_CLASS = 106,
9677 INVALID_ESCAPE_IN_CHARACTER_CLASS = 107,
9678 RANGE_OUT_OF_ORDER = 108,
9679 NOTHING_TO_REPEAT = 109,
9680 UNRECOGNIZED_CHARACTER = 112,
9681 POSIX_NAMED_CLASS_OUTSIDE_CLASS = 113,
9682 UNMATCHED_PARENTHESIS = 114,
9683 INEXISTENT_SUBPATTERN_REFERENCE = 115,
9684 UNTERMINATED_COMMENT = 118,
9685 EXPRESSION_TOO_LARGE = 120,
9686 MEMORY_ERROR = 121,
9687 VARIABLE_LENGTH_LOOKBEHIND = 125,
9688 MALFORMED_CONDITION = 126,
9689 TOO_MANY_CONDITIONAL_BRANCHES = 127,
9690 ASSERTION_EXPECTED = 128,
9691 UNKNOWN_POSIX_CLASS_NAME = 130,
9692 POSIX_COLLATING_ELEMENTS_NOT_SUPPORTED = 131,
9693 HEX_CODE_TOO_LARGE = 134,
9694 INVALID_CONDITION = 135,
9695 SINGLE_BYTE_MATCH_IN_LOOKBEHIND = 136,
9696 INFINITE_LOOP = 140,
9697 MISSING_SUBPATTERN_NAME_TERMINATOR = 142,
9698 DUPLICATE_SUBPATTERN_NAME = 143,
9699 MALFORMED_PROPERTY = 146,
9700 UNKNOWN_PROPERTY = 147,
9701 SUBPATTERN_NAME_TOO_LONG = 148,
9702 TOO_MANY_SUBPATTERNS = 149,
9703 INVALID_OCTAL_VALUE = 151,
9704 TOO_MANY_BRANCHES_IN_DEFINE = 154,
9705 DEFINE_REPETION = 155,
9706 INCONSISTENT_NEWLINE_OPTIONS = 156,
9707 MISSING_BACK_REFERENCE = 157
9710 // VERSION: 2.14
9711 // Specifies the type of the function passed to g_regex_replace_eval().
9712 // It is called for each occurrence of the pattern in the string passed
9713 // to g_regex_replace_eval(), and it should append the replacement to
9714 // @result.
9715 // RETURNS: %FALSE to continue the replacement process, %TRUE to stop it
9716 // <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.
9717 // <result>: a #GString containing the new string
9718 // <user_data>: user data passed to g_regex_replace_eval()
9719 extern (C) alias int function (MatchInfo* match_info, String* result, void* user_data) nothrow RegexEvalCallback;
9721 // Flags specifying match-time options.
9722 enum RegexMatchFlags /* Version 2.14 */ {
9723 ANCHORED = 16,
9724 NOTBOL = 128,
9725 NOTEOL = 256,
9726 NOTEMPTY = 1024,
9727 PARTIAL = 32768,
9728 NEWLINE_CR = 1048576,
9729 NEWLINE_LF = 2097152,
9730 NEWLINE_CRLF = 3145728,
9731 NEWLINE_ANY = 4194304
9733 enum int SEARCHPATH_SEPARATOR = 59;
9734 enum SEARCHPATH_SEPARATOR_S = ";";
9735 enum int SIZEOF_LONG = 4;
9736 enum int SIZEOF_SIZE_T = 4;
9737 enum int SIZEOF_VOID_P = 4;
9739 // The #GSList struct is used for each element in the singly-linked
9740 // list.
9741 struct SList {
9742 void* data;
9743 GLib2.SList* next;
9746 // Unintrospectable function: alloc() / g_slist_alloc()
9747 // Allocates space for one #GSList element. It is called by the
9748 // g_slist_append(), g_slist_prepend(), g_slist_insert() and
9749 // g_slist_insert_sorted() functions and so is rarely used on its own.
9750 static GLib2.SList* alloc()() nothrow {
9751 return g_slist_alloc();
9754 // Unintrospectable function: append() / g_slist_append()
9755 // Adds a new element on to the end of the list.
9757 // <note><para>
9758 // The return value is the new start of the list, which may
9759 // have changed, so make sure you store the new value.
9760 // </para></note>
9762 // <note><para>
9763 // Note that g_slist_append() has to traverse the entire list
9764 // to find the end, which is inefficient when adding multiple
9765 // elements. A common idiom to avoid the inefficiency is to prepend
9766 // the elements and reverse the list when all elements have been added.
9767 // </para></note>
9769 // |[
9770 // /&ast; Notice that these are initialized to the empty list. &ast;/
9771 // GSList *list = NULL, *number_list = NULL;
9773 // /&ast; This is a list of strings. &ast;/
9774 // list = g_slist_append (list, "first");
9775 // list = g_slist_append (list, "second");
9777 // /&ast; This is a list of integers. &ast;/
9778 // number_list = g_slist_append (number_list, GINT_TO_POINTER (27));
9779 // number_list = g_slist_append (number_list, GINT_TO_POINTER (14));
9780 // ]|
9781 // RETURNS: the new start of the #GSList
9782 // <list>: a #GSList
9783 // <data>: the data for the new element
9784 static GLib2.SList* append()(GLib2.SList* list, void* data) nothrow {
9785 return g_slist_append(list, data);
9788 // Unintrospectable function: concat() / g_slist_concat()
9789 // Adds the second #GSList onto the end of the first #GSList.
9790 // Note that the elements of the second #GSList are not copied.
9791 // They are used directly.
9792 // RETURNS: the start of the new #GSList
9793 // <list1>: a #GSList
9794 // <list2>: the #GSList to add to the end of the first #GSList
9795 static GLib2.SList* concat()(GLib2.SList* list1, GLib2.SList* list2) nothrow {
9796 return g_slist_concat(list1, list2);
9799 // Unintrospectable function: copy() / g_slist_copy()
9800 // Copies a #GSList.
9802 // <note><para>
9803 // Note that this is a "shallow" copy. If the list elements
9804 // consist of pointers to data, the pointers are copied but
9805 // the actual data isn't.
9806 // </para></note>
9807 // RETURNS: a copy of @list
9808 // <list>: a #GSList
9809 static GLib2.SList* copy()(GLib2.SList* list) nothrow {
9810 return g_slist_copy(list);
9813 // Unintrospectable function: delete_link() / g_slist_delete_link()
9814 // Removes the node link_ from the list and frees it.
9815 // Compare this to g_slist_remove_link() which removes the node
9816 // without freeing it.
9817 // RETURNS: the new head of @list
9818 // <list>: a #GSList
9819 // <link_>: node to delete
9820 static GLib2.SList* delete_link()(GLib2.SList* list, GLib2.SList* link_) nothrow {
9821 return g_slist_delete_link(list, link_);
9824 // Unintrospectable function: find() / g_slist_find()
9825 // Finds the element in a #GSList which
9826 // contains the given data.
9828 // or %NULL if it is not found
9829 // RETURNS: the found #GSList element,
9830 // <list>: a #GSList
9831 // <data>: the element data to find
9832 static GLib2.SList* find()(GLib2.SList* list, const(void)* data) nothrow {
9833 return g_slist_find(list, data);
9836 // Unintrospectable function: find_custom() / g_slist_find_custom()
9837 // Finds an element in a #GSList, using a supplied function to
9838 // find the desired element. It iterates over the list, calling
9839 // the given function which should return 0 when the desired
9840 // element is found. The function takes two #gconstpointer arguments,
9841 // the #GSList element's data as the first argument and the
9842 // given user data.
9843 // RETURNS: the found #GSList element, or %NULL if it is not found
9844 // <list>: a #GSList
9845 // <data>: user data passed to the function
9846 // <func>: the function to call for each element. It should return 0 when the desired element is found
9847 static GLib2.SList* find_custom()(GLib2.SList* list, const(void)* data, CompareFunc func) nothrow {
9848 return g_slist_find_custom(list, data, func);
9851 // Unintrospectable function: foreach() / g_slist_foreach()
9852 // Calls a function for each element of a #GSList.
9853 // <list>: a #GSList
9854 // <func>: the function to call with each element's data
9855 // <user_data>: user data to pass to the function
9856 static void foreach_()(GLib2.SList* list, Func func, void* user_data) nothrow {
9857 g_slist_foreach(list, func, user_data);
9860 // Unintrospectable function: free() / g_slist_free()
9861 // Frees all of the memory used by a #GSList.
9862 // The freed elements are returned to the slice allocator.
9864 // <note><para>
9865 // If list elements contain dynamically-allocated memory,
9866 // you should either use g_slist_free_full() or free them manually
9867 // first.
9868 // </para></note>
9869 // <list>: a #GSList
9870 static void free()(GLib2.SList* list) nothrow {
9871 g_slist_free(list);
9874 // Unintrospectable function: free_1() / g_slist_free_1()
9875 // Frees one #GSList element.
9876 // It is usually used after g_slist_remove_link().
9877 // <list>: a #GSList element
9878 static void free_1()(GLib2.SList* list) nothrow {
9879 g_slist_free_1(list);
9882 // Unintrospectable function: free_full() / g_slist_free_full()
9883 // VERSION: 2.28
9884 // Convenience method, which frees all the memory used by a #GSList, and
9885 // calls the specified destroy function on every element's data.
9886 // <list>: a pointer to a #GSList
9887 // <free_func>: the function to be called to free each element's data
9888 static void free_full()(GLib2.SList* list, DestroyNotify free_func) nothrow {
9889 g_slist_free_full(list, free_func);
9892 // Unintrospectable function: index() / g_slist_index()
9893 // Gets the position of the element containing
9894 // the given data (starting from 0).
9896 // or -1 if the data is not found
9897 // RETURNS: the index of the element containing the data,
9898 // <list>: a #GSList
9899 // <data>: the data to find
9900 static int index()(GLib2.SList* list, const(void)* data) nothrow {
9901 return g_slist_index(list, data);
9904 // Unintrospectable function: insert() / g_slist_insert()
9905 // Inserts a new element into the list at the given position.
9906 // RETURNS: the new start of the #GSList
9907 // <list>: a #GSList
9908 // <data>: the data for the new element
9909 // <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.
9910 static GLib2.SList* insert()(GLib2.SList* list, void* data, int position) nothrow {
9911 return g_slist_insert(list, data, position);
9914 // Unintrospectable function: insert_before() / g_slist_insert_before()
9915 // Inserts a node before @sibling containing @data.
9916 // RETURNS: the new head of the list.
9917 // <slist>: a #GSList
9918 // <sibling>: node to insert @data before
9919 // <data>: data to put in the newly-inserted node
9920 static GLib2.SList* insert_before()(GLib2.SList* slist, GLib2.SList* sibling, void* data) nothrow {
9921 return g_slist_insert_before(slist, sibling, data);
9924 // Unintrospectable function: insert_sorted() / g_slist_insert_sorted()
9925 // Inserts a new element into the list, using the given
9926 // comparison function to determine its position.
9927 // RETURNS: the new start of the #GSList
9928 // <list>: a #GSList
9929 // <data>: the data for the new element
9930 // <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.
9931 static GLib2.SList* insert_sorted()(GLib2.SList* list, void* data, CompareFunc func) nothrow {
9932 return g_slist_insert_sorted(list, data, func);
9935 // Unintrospectable function: insert_sorted_with_data() / g_slist_insert_sorted_with_data()
9936 // VERSION: 2.10
9937 // Inserts a new element into the list, using the given
9938 // comparison function to determine its position.
9939 // RETURNS: the new start of the #GSList
9940 // <list>: a #GSList
9941 // <data>: the data for the new element
9942 // <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.
9943 // <user_data>: data to pass to comparison function
9944 static GLib2.SList* insert_sorted_with_data()(GLib2.SList* list, void* data, CompareDataFunc func, void* user_data) nothrow {
9945 return g_slist_insert_sorted_with_data(list, data, func, user_data);
9948 // Unintrospectable function: last() / g_slist_last()
9949 // Gets the last element in a #GSList.
9951 // <note><para>
9952 // This function iterates over the whole list.
9953 // </para></note>
9955 // or %NULL if the #GSList has no elements
9956 // RETURNS: the last element in the #GSList,
9957 // <list>: a #GSList
9958 static GLib2.SList* last()(GLib2.SList* list) nothrow {
9959 return g_slist_last(list);
9962 // Unintrospectable function: length() / g_slist_length()
9963 // Gets the number of elements in a #GSList.
9965 // <note><para>
9966 // This function iterates over the whole list to
9967 // count its elements.
9968 // </para></note>
9969 // RETURNS: the number of elements in the #GSList
9970 // <list>: a #GSList
9971 static uint length()(GLib2.SList* list) nothrow {
9972 return g_slist_length(list);
9975 // Unintrospectable function: nth() / g_slist_nth()
9976 // Gets the element at the given position in a #GSList.
9978 // the end of the #GSList
9979 // RETURNS: the element, or %NULL if the position is off
9980 // <list>: a #GSList
9981 // <n>: the position of the element, counting from 0
9982 static GLib2.SList* nth()(GLib2.SList* list, uint n) nothrow {
9983 return g_slist_nth(list, n);
9986 // Unintrospectable function: nth_data() / g_slist_nth_data()
9987 // Gets the data of the element at the given position.
9989 // is off the end of the #GSList
9990 // RETURNS: the element's data, or %NULL if the position
9991 // <list>: a #GSList
9992 // <n>: the position of the element
9993 static void* nth_data()(GLib2.SList* list, uint n) nothrow {
9994 return g_slist_nth_data(list, n);
9997 // Unintrospectable function: position() / g_slist_position()
9998 // Gets the position of the given element
9999 // in the #GSList (starting from 0).
10001 // or -1 if the element is not found
10002 // RETURNS: the position of the element in the #GSList,
10003 // <list>: a #GSList
10004 // <llink>: an element in the #GSList
10005 static int position()(GLib2.SList* list, GLib2.SList* llink) nothrow {
10006 return g_slist_position(list, llink);
10009 // Unintrospectable function: prepend() / g_slist_prepend()
10010 // Adds a new element on to the start of the list.
10012 // <note><para>
10013 // The return value is the new start of the list, which
10014 // may have changed, so make sure you store the new value.
10015 // </para></note>
10017 // |[
10018 // /&ast; Notice that it is initialized to the empty list. &ast;/
10019 // GSList *list = NULL;
10020 // list = g_slist_prepend (list, "last");
10021 // list = g_slist_prepend (list, "first");
10022 // ]|
10023 // RETURNS: the new start of the #GSList
10024 // <list>: a #GSList
10025 // <data>: the data for the new element
10026 static GLib2.SList* prepend()(GLib2.SList* list, void* data) nothrow {
10027 return g_slist_prepend(list, data);
10030 // Unintrospectable function: remove() / g_slist_remove()
10031 // Removes an element from a #GSList.
10032 // If two elements contain the same data, only the first is removed.
10033 // If none of the elements contain the data, the #GSList is unchanged.
10034 // RETURNS: the new start of the #GSList
10035 // <list>: a #GSList
10036 // <data>: the data of the element to remove
10037 static GLib2.SList* remove()(GLib2.SList* list, const(void)* data) nothrow {
10038 return g_slist_remove(list, data);
10041 // Unintrospectable function: remove_all() / g_slist_remove_all()
10042 // Removes all list nodes with data equal to @data.
10043 // Returns the new head of the list. Contrast with
10044 // g_slist_remove() which removes only the first node
10045 // matching the given data.
10046 // RETURNS: new head of @list
10047 // <list>: a #GSList
10048 // <data>: data to remove
10049 static GLib2.SList* remove_all()(GLib2.SList* list, const(void)* data) nothrow {
10050 return g_slist_remove_all(list, data);
10053 // Unintrospectable function: remove_link() / g_slist_remove_link()
10054 // Removes an element from a #GSList, without
10055 // freeing the element. The removed element's next
10056 // link is set to %NULL, so that it becomes a
10057 // self-contained list with one element.
10058 // RETURNS: the new start of the #GSList, without the element
10059 // <list>: a #GSList
10060 // <link_>: an element in the #GSList
10061 static GLib2.SList* remove_link()(GLib2.SList* list, GLib2.SList* link_) nothrow {
10062 return g_slist_remove_link(list, link_);
10065 // Unintrospectable function: reverse() / g_slist_reverse()
10066 // Reverses a #GSList.
10067 // RETURNS: the start of the reversed #GSList
10068 // <list>: a #GSList
10069 static GLib2.SList* reverse()(GLib2.SList* list) nothrow {
10070 return g_slist_reverse(list);
10073 // Unintrospectable function: sort() / g_slist_sort()
10074 // Sorts a #GSList using the given comparison function.
10075 // RETURNS: the start of the sorted #GSList
10076 // <list>: a #GSList
10077 // <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.
10078 static GLib2.SList* sort()(GLib2.SList* list, CompareFunc compare_func) nothrow {
10079 return g_slist_sort(list, compare_func);
10082 // Unintrospectable function: sort_with_data() / g_slist_sort_with_data()
10083 // Like g_slist_sort(), but the sort function accepts a user data argument.
10084 // RETURNS: new head of the list
10085 // <list>: a #GSList
10086 // <compare_func>: comparison function
10087 // <user_data>: data to pass to comparison function
10088 static GLib2.SList* sort_with_data()(GLib2.SList* list, CompareDataFunc compare_func, void* user_data) nothrow {
10089 return g_slist_sort_with_data(list, compare_func, user_data);
10093 enum double SQRT2 = 1.414214;
10094 enum STR_DELIMITERS = "_-|> <.";
10095 enum int SYSDEF_AF_INET = 2;
10096 enum int SYSDEF_AF_INET6 = 10;
10097 enum int SYSDEF_AF_UNIX = 1;
10098 enum int SYSDEF_MSG_DONTROUTE = 4;
10099 enum int SYSDEF_MSG_OOB = 1;
10100 enum int SYSDEF_MSG_PEEK = 2;
10102 // The data structure representing a lexical scanner.
10104 // You should set @input_name after creating the scanner, since
10105 // it is used by the default message handler when displaying
10106 // warnings and errors. If you are scanning a file, the filename
10107 // would be a good choice.
10109 // The @user_data and @max_parse_errors fields are not used.
10110 // If you need to associate extra data with the scanner you
10111 // can place them here.
10113 // If you want to use your own message handler you can set the
10114 // @msg_handler field. The type of the message handler function
10115 // is declared by #GScannerMsgFunc.
10116 struct Scanner {
10117 void* user_data;
10118 uint max_parse_errors, parse_errors;
10119 char* input_name;
10120 Data* qdata;
10121 ScannerConfig* config;
10122 TokenType token;
10123 TokenValue value;
10124 uint line, position;
10125 TokenType next_token;
10126 TokenValue next_value;
10127 uint next_line, next_position;
10128 private GLib2.HashTable* symbol_table;
10129 private int input_fd;
10130 private char* text, text_end, buffer;
10131 private uint scope_id;
10132 ScannerMsgFunc msg_handler;
10135 // Returns the current line in the input stream (counting
10136 // from 1). This is the line of the last token parsed via
10137 // g_scanner_get_next_token().
10138 // RETURNS: the current line
10139 uint cur_line()() nothrow {
10140 return g_scanner_cur_line(&this);
10143 // Returns the current position in the current line (counting
10144 // from 0). This is the position of the last token parsed via
10145 // g_scanner_get_next_token().
10146 // RETURNS: the current position on the line
10147 uint cur_position()() nothrow {
10148 return g_scanner_cur_position(&this);
10151 // Gets the current token type. This is simply the @token
10152 // field in the #GScanner structure.
10153 // RETURNS: the current token type
10154 TokenType cur_token()() nothrow {
10155 return g_scanner_cur_token(&this);
10158 // Unintrospectable method: cur_value() / g_scanner_cur_value()
10159 // Gets the current token value. This is simply the @value
10160 // field in the #GScanner structure.
10161 // RETURNS: the current token value
10162 TokenValue cur_value()() nothrow {
10163 return g_scanner_cur_value(&this);
10165 // Frees all memory used by the #GScanner.
10166 void destroy()() nothrow {
10167 g_scanner_destroy(&this);
10170 // Returns %TRUE if the scanner has reached the end of
10171 // the file or text buffer.
10173 // the file or text buffer
10174 // RETURNS: %TRUE if the scanner has reached the end of
10175 int eof()() nothrow {
10176 return g_scanner_eof(&this);
10179 // Unintrospectable method: error() / g_scanner_error()
10180 // Outputs an error message, via the #GScanner message handler.
10181 // <format>: the message format. See the printf() documentation
10182 /+ Not available -- variadic methods unsupported - use the C function directly.
10183 alias g_scanner_error error; // Variadic
10186 // Parses the next token just like g_scanner_peek_next_token()
10187 // and also removes it from the input stream. The token data is
10188 // placed in the @token, @value, @line, and @position fields of
10189 // the #GScanner structure.
10190 // RETURNS: the type of the token
10191 TokenType get_next_token()() nothrow {
10192 return g_scanner_get_next_token(&this);
10195 // Prepares to scan a file.
10196 // <input_fd>: a file descriptor
10197 void input_file()(int input_fd) nothrow {
10198 g_scanner_input_file(&this, input_fd);
10201 // Prepares to scan a text buffer.
10202 // <text>: the text buffer to scan
10203 // <text_len>: the length of the text buffer
10204 void input_text()(char* text, uint text_len) nothrow {
10205 g_scanner_input_text(&this, text, text_len);
10208 // Unintrospectable method: lookup_symbol() / g_scanner_lookup_symbol()
10209 // Looks up a symbol in the current scope and return its value.
10210 // If the symbol is not bound in the current scope, %NULL is
10211 // returned.
10213 // if @symbol is not bound in the current scope
10214 // RETURNS: the value of @symbol in the current scope, or %NULL
10215 // <symbol>: the symbol to look up
10216 void* lookup_symbol()(char* symbol) nothrow {
10217 return g_scanner_lookup_symbol(&this, symbol);
10220 // Parses the next token, without removing it from the input stream.
10221 // The token data is placed in the @next_token, @next_value, @next_line,
10222 // and @next_position fields of the #GScanner structure.
10224 // Note that, while the token is not removed from the input stream
10225 // (i.e. the next call to g_scanner_get_next_token() will return the
10226 // same token), it will not be reevaluated. This can lead to surprising
10227 // results when changing scope or the scanner configuration after peeking
10228 // the next token. Getting the next token after switching the scope or
10229 // configuration will return whatever was peeked before, regardless of
10230 // any symbols that may have been added or removed in the new scope.
10231 // RETURNS: the type of the token
10232 TokenType peek_next_token()() nothrow {
10233 return g_scanner_peek_next_token(&this);
10236 // Adds a symbol to the given scope.
10237 // <scope_id>: the scope id
10238 // <symbol>: the symbol to add
10239 // <value>: the value of the symbol
10240 void scope_add_symbol()(uint scope_id, char* symbol, void* value) nothrow {
10241 g_scanner_scope_add_symbol(&this, scope_id, symbol, value);
10244 // Unintrospectable method: scope_foreach_symbol() / g_scanner_scope_foreach_symbol()
10245 // Calls the given function for each of the symbol/value pairs
10246 // in the given scope of the #GScanner. The function is passed
10247 // the symbol and value of each pair, and the given @user_data
10248 // parameter.
10249 // <scope_id>: the scope id
10250 // <func>: the function to call for each symbol/value pair
10251 // <user_data>: user data to pass to the function
10252 void scope_foreach_symbol()(uint scope_id, HFunc func, void* user_data) nothrow {
10253 g_scanner_scope_foreach_symbol(&this, scope_id, func, user_data);
10256 // Unintrospectable method: scope_lookup_symbol() / g_scanner_scope_lookup_symbol()
10257 // Looks up a symbol in a scope and return its value. If the
10258 // symbol is not bound in the scope, %NULL is returned.
10260 // if @symbol is not bound in the given scope.
10261 // RETURNS: the value of @symbol in the given scope, or %NULL
10262 // <scope_id>: the scope id
10263 // <symbol>: the symbol to look up
10264 void* scope_lookup_symbol()(uint scope_id, char* symbol) nothrow {
10265 return g_scanner_scope_lookup_symbol(&this, scope_id, symbol);
10268 // Removes a symbol from a scope.
10269 // <scope_id>: the scope id
10270 // <symbol>: the symbol to remove
10271 void scope_remove_symbol()(uint scope_id, char* symbol) nothrow {
10272 g_scanner_scope_remove_symbol(&this, scope_id, symbol);
10275 // Sets the current scope.
10276 // RETURNS: the old scope id
10277 // <scope_id>: the new scope id
10278 uint set_scope()(uint scope_id) nothrow {
10279 return g_scanner_set_scope(&this, scope_id);
10282 // Rewinds the filedescriptor to the current buffer position
10283 // and blows the file read ahead buffer. This is useful for
10284 // third party uses of the scanners filedescriptor, which hooks
10285 // onto the current scanning position.
10286 void sync_file_offset()() nothrow {
10287 g_scanner_sync_file_offset(&this);
10290 // Outputs a message through the scanner's msg_handler,
10291 // resulting from an unexpected token in the input stream.
10292 // Note that you should not call g_scanner_peek_next_token()
10293 // followed by g_scanner_unexp_token() without an intermediate
10294 // call to g_scanner_get_next_token(), as g_scanner_unexp_token()
10295 // evaluates the scanner's current token (not the peeked token)
10296 // to construct part of the message.
10297 // <expected_token>: the expected token
10298 // <identifier_spec>: a string describing how the scanner's user refers to identifiers (%NULL defaults to "identifier"). This is used if @expected_token is %G_TOKEN_IDENTIFIER or %G_TOKEN_IDENTIFIER_NULL.
10299 // <symbol_spec>: a string describing how the scanner's user refers to symbols (%NULL defaults to "symbol"). This is used if @expected_token is %G_TOKEN_SYMBOL or any token value greater than %G_TOKEN_LAST.
10300 // <symbol_name>: the name of the symbol, if the scanner's current token is a symbol.
10301 // <message>: a message string to output at the end of the warning/error, or %NULL.
10302 // <is_error>: if %TRUE it is output as an error. If %FALSE it is output as a warning.
10303 void unexp_token()(TokenType expected_token, char* identifier_spec, char* symbol_spec, char* symbol_name, char* message, int is_error) nothrow {
10304 g_scanner_unexp_token(&this, expected_token, identifier_spec, symbol_spec, symbol_name, message, is_error);
10307 // Unintrospectable method: warn() / g_scanner_warn()
10308 // Outputs a warning message, via the #GScanner message handler.
10309 // <format>: the message format. See the printf() documentation
10310 /+ Not available -- variadic methods unsupported - use the C function directly.
10311 alias g_scanner_warn warn; // Variadic
10314 // Unintrospectable function: new() / g_scanner_new()
10315 // Creates a new #GScanner.
10317 // The @config_templ structure specifies the initial settings
10318 // of the scanner, which are copied into the #GScanner
10319 // @config field. If you pass %NULL then the default settings
10320 // are used.
10321 // RETURNS: the new #GScanner
10322 // <config_templ>: the initial scanner settings
10323 static Scanner* new_()(ScannerConfig* config_templ) nothrow {
10324 return g_scanner_new(config_templ);
10329 // Specifies the #GScanner parser configuration. Most settings can
10330 // be changed during the parsing phase and will affect the lexical
10331 // parsing of the next unpeeked token.
10332 struct ScannerConfig {
10333 char* cset_skip_characters, cset_identifier_first, cset_identifier_nth, cpair_comment_single;
10334 static import std.bitmanip; mixin(std.bitmanip.bitfields!(
10335 uint, "case_sensitive", 1,
10336 uint, "skip_comment_multi", 1,
10337 uint, "skip_comment_single", 1,
10338 uint, "scan_comment_multi", 1,
10339 uint, "scan_identifier", 1,
10340 uint, "scan_identifier_1char", 1,
10341 uint, "scan_identifier_NULL", 1,
10342 uint, "scan_symbols", 1,
10343 uint, "scan_binary", 1,
10344 uint, "scan_octal", 1,
10345 uint, "scan_float", 1,
10346 uint, "scan_hex", 1,
10347 uint, "scan_hex_dollar", 1,
10348 uint, "scan_string_sq", 1,
10349 uint, "scan_string_dq", 1,
10350 uint, "numbers_2_int", 1,
10351 uint, "int_2_float", 1,
10352 uint, "identifier_2_string", 1,
10353 uint, "char_2_token", 1,
10354 uint, "symbol_2_token", 1,
10355 uint, "scope_0_fallback", 1,
10356 uint, "store_int64", 1,
10357 uint, "__dummy32A", 10));
10358 private uint padding_dummy;
10362 // Specifies the type of the message handler function.
10363 // <scanner>: a #GScanner
10364 // <message>: the message
10365 // <error>: %TRUE if the message signals an error, %FALSE if it signals a warning.
10366 extern (C) alias void function (Scanner* scanner, char* message, int error) nothrow ScannerMsgFunc;
10369 // An enumeration specifying the base position for a
10370 // g_io_channel_seek_position() operation.
10371 enum SeekType {
10372 CUR = 0,
10373 SET = 1,
10374 END = 2
10377 // The #GSequence struct is an opaque data type representing a
10378 // <link linkend="glib-Sequences">Sequence</link> data type.
10379 struct Sequence {
10381 // Unintrospectable method: append() / g_sequence_append()
10382 // VERSION: 2.14
10383 // Adds a new item to the end of @seq.
10384 // RETURNS: an iterator pointing to the new item
10385 // <data>: the data for the new item
10386 SequenceIter* append()(void* data) nothrow {
10387 return g_sequence_append(&this, data);
10390 // Unintrospectable method: foreach() / g_sequence_foreach()
10391 // VERSION: 2.14
10392 // Calls @func for each item in the sequence passing @user_data
10393 // to the function.
10394 // <func>: the function to call for each item in @seq
10395 // <user_data>: user data passed to @func
10396 void foreach_()(Func func, void* user_data) nothrow {
10397 g_sequence_foreach(&this, func, user_data);
10400 // VERSION: 2.14
10401 // Frees the memory allocated for @seq. If @seq has a data destroy
10402 // function associated with it, that function is called on all items in
10403 // @seq.
10404 void free()() nothrow {
10405 g_sequence_free(&this);
10408 // Unintrospectable method: get_begin_iter() / g_sequence_get_begin_iter()
10409 // VERSION: 2.14
10410 // Returns the begin iterator for @seq.
10411 // RETURNS: the begin iterator for @seq.
10412 SequenceIter* get_begin_iter()() nothrow {
10413 return g_sequence_get_begin_iter(&this);
10416 // Unintrospectable method: get_end_iter() / g_sequence_get_end_iter()
10417 // VERSION: 2.14
10418 // Returns the end iterator for @seg
10419 // RETURNS: the end iterator for @seq
10420 SequenceIter* get_end_iter()() nothrow {
10421 return g_sequence_get_end_iter(&this);
10424 // Unintrospectable method: get_iter_at_pos() / g_sequence_get_iter_at_pos()
10425 // VERSION: 2.14
10426 // Returns the iterator at position @pos. If @pos is negative or larger
10427 // than the number of items in @seq, the end iterator is returned.
10428 // RETURNS: The #GSequenceIter at position @pos
10429 // <pos>: a position in @seq, or -1 for the end.
10430 SequenceIter* get_iter_at_pos()(int pos) nothrow {
10431 return g_sequence_get_iter_at_pos(&this, pos);
10434 // VERSION: 2.14
10435 // Returns the length of @seq
10436 // RETURNS: the length of @seq
10437 int get_length()() nothrow {
10438 return g_sequence_get_length(&this);
10441 // Unintrospectable method: insert_sorted() / g_sequence_insert_sorted()
10442 // VERSION: 2.14
10443 // Inserts @data into @sequence using @func to determine the new
10444 // position. The sequence must already be sorted according to @cmp_func;
10445 // otherwise the new position of @data is undefined.
10447 // @cmp_func is called with two items of the @seq and @user_data.
10448 // It should return 0 if the items are equal, a negative value
10449 // if the first item comes before the second, and a positive value
10450 // if the second item comes before the first.
10451 // RETURNS: a #GSequenceIter pointing to the new item.
10452 // <data>: the data to insert
10453 // <cmp_func>: the function used to compare items in the sequence
10454 // <cmp_data>: user data passed to @cmp_func.
10455 SequenceIter* insert_sorted()(void* data, CompareDataFunc cmp_func, void* cmp_data) nothrow {
10456 return g_sequence_insert_sorted(&this, data, cmp_func, cmp_data);
10459 // Unintrospectable method: insert_sorted_iter() / g_sequence_insert_sorted_iter()
10460 // VERSION: 2.14
10461 // Like g_sequence_insert_sorted(), but uses
10462 // a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as
10463 // the compare function.
10465 // @iter_cmp is called with two iterators pointing into @seq.
10466 // It should return 0 if the iterators are equal, a negative
10467 // value if the first iterator comes before the second, and a
10468 // positive value if the second iterator comes before the first.
10470 // It is called with two iterators pointing into @seq. It should
10471 // return 0 if the iterators are equal, a negative value if the
10472 // first iterator comes before the second, and a positive value
10473 // if the second iterator comes before the first.
10474 // RETURNS: a #GSequenceIter pointing to the new item
10475 // <data>: data for the new item
10476 // <iter_cmp>: the function used to compare iterators in the sequence
10477 // <cmp_data>: user data passed to @cmp_func
10478 SequenceIter* insert_sorted_iter()(void* data, SequenceIterCompareFunc iter_cmp, void* cmp_data) nothrow {
10479 return g_sequence_insert_sorted_iter(&this, data, iter_cmp, cmp_data);
10482 // Unintrospectable method: lookup() / g_sequence_lookup()
10483 // VERSION: 2.28
10484 // Returns an iterator pointing to the position of the first item found
10485 // equal to @data according to @cmp_func and @cmp_data. If more than one
10486 // item is equal, it is not guaranteed that it is the first which is
10487 // returned. In that case, you can use g_sequence_iter_next() and
10488 // g_sequence_iter_prev() to get others.
10490 // @cmp_func is called with two items of the @seq and @user_data.
10491 // It should return 0 if the items are equal, a negative value if
10492 // the first item comes before the second, and a positive value if
10493 // the second item comes before the first.
10495 // first item found equal to @data according to @cmp_func and @cmp_data.
10496 // RETURNS: an #GSequenceIter pointing to the position of the
10497 // <data>: data to lookup
10498 // <cmp_func>: the function used to compare items in the sequence
10499 // <cmp_data>: user data passed to @cmp_func.
10500 SequenceIter* lookup()(void* data, CompareDataFunc cmp_func, void* cmp_data) nothrow {
10501 return g_sequence_lookup(&this, data, cmp_func, cmp_data);
10504 // Unintrospectable method: lookup_iter() / g_sequence_lookup_iter()
10505 // VERSION: 2.28
10506 // Like g_sequence_lookup(), but uses a #GSequenceIterCompareFunc
10507 // instead of a #GCompareDataFunc as the compare function.
10509 // @iter_cmp is called with two iterators pointing into @seq.
10510 // It should return 0 if the iterators are equal, a negative value
10511 // if the first iterator comes before the second, and a positive
10512 // value if the second iterator comes before the first.
10514 // the first item found equal to @data according to @cmp_func
10515 // and @cmp_data.
10516 // RETURNS: an #GSequenceIter pointing to the position of
10517 // <data>: data to lookup
10518 // <iter_cmp>: the function used to compare iterators in the sequence
10519 // <cmp_data>: user data passed to @iter_cmp
10520 SequenceIter* lookup_iter()(void* data, SequenceIterCompareFunc iter_cmp, void* cmp_data) nothrow {
10521 return g_sequence_lookup_iter(&this, data, iter_cmp, cmp_data);
10524 // Unintrospectable method: prepend() / g_sequence_prepend()
10525 // VERSION: 2.14
10526 // Adds a new item to the front of @seq
10527 // RETURNS: an iterator pointing to the new item
10528 // <data>: the data for the new item
10529 SequenceIter* prepend()(void* data) nothrow {
10530 return g_sequence_prepend(&this, data);
10533 // Unintrospectable method: search() / g_sequence_search()
10534 // VERSION: 2.14
10535 // Returns an iterator pointing to the position where @data would
10536 // be inserted according to @cmp_func and @cmp_data.
10538 // @cmp_func is called with two items of the @seq and @user_data.
10539 // It should return 0 if the items are equal, a negative value if
10540 // the first item comes before the second, and a positive value if
10541 // the second item comes before the first.
10543 // If you are simply searching for an existing element of the sequence,
10544 // consider using g_sequence_lookup().
10546 // would have been inserted according to @cmp_func and @cmp_data.
10547 // RETURNS: an #GSequenceIter pointing to the position where @data
10548 // <data>: data for the new item
10549 // <cmp_func>: the function used to compare items in the sequence
10550 // <cmp_data>: user data passed to @cmp_func.
10551 SequenceIter* search()(void* data, CompareDataFunc cmp_func, void* cmp_data) nothrow {
10552 return g_sequence_search(&this, data, cmp_func, cmp_data);
10555 // Unintrospectable method: search_iter() / g_sequence_search_iter()
10556 // VERSION: 2.14
10557 // Like g_sequence_search(), but uses a #GSequenceIterCompareFunc
10558 // instead of a #GCompareDataFunc as the compare function.
10560 // @iter_cmp is called with two iterators pointing into @seq.
10561 // It should return 0 if the iterators are equal, a negative value
10562 // if the first iterator comes before the second, and a positive
10563 // value if the second iterator comes before the first.
10565 // If you are simply searching for an existing element of the sequence,
10566 // consider using g_sequence_lookup_iter().
10568 // where @data would have been inserted according to @iter_cmp
10569 // and @cmp_data.
10570 // RETURNS: a #GSequenceIter pointing to the position in @seq
10571 // <data>: data for the new item
10572 // <iter_cmp>: the function used to compare iterators in the sequence
10573 // <cmp_data>: user data passed to @iter_cmp
10574 SequenceIter* search_iter()(void* data, SequenceIterCompareFunc iter_cmp, void* cmp_data) nothrow {
10575 return g_sequence_search_iter(&this, data, iter_cmp, cmp_data);
10578 // Unintrospectable method: sort() / g_sequence_sort()
10579 // VERSION: 2.14
10580 // Sorts @seq using @cmp_func.
10582 // @cmp_func is passed two items of @seq and should
10583 // return 0 if they are equal, a negative value if the
10584 // first comes before the second, and a positive value
10585 // if the second comes before the first.
10586 // <cmp_func>: the function used to sort the sequence
10587 // <cmp_data>: user data passed to @cmp_func
10588 void sort()(CompareDataFunc cmp_func, void* cmp_data) nothrow {
10589 g_sequence_sort(&this, cmp_func, cmp_data);
10592 // Unintrospectable method: sort_iter() / g_sequence_sort_iter()
10593 // VERSION: 2.14
10594 // Like g_sequence_sort(), but uses a #GSequenceIterCompareFunc instead
10595 // of a GCompareDataFunc as the compare function
10597 // @cmp_func is called with two iterators pointing into @seq. It should
10598 // return 0 if the iterators are equal, a negative value if the first
10599 // iterator comes before the second, and a positive value if the second
10600 // iterator comes before the first.
10601 // <cmp_func>: the function used to compare iterators in the sequence
10602 // <cmp_data>: user data passed to @cmp_func
10603 void sort_iter()(SequenceIterCompareFunc cmp_func, void* cmp_data) nothrow {
10604 g_sequence_sort_iter(&this, cmp_func, cmp_data);
10607 // Unintrospectable function: foreach_range() / g_sequence_foreach_range()
10608 // VERSION: 2.14
10609 // Calls @func for each item in the range (@begin, @end) passing
10610 // @user_data to the function.
10611 // <begin>: a #GSequenceIter
10612 // <end>: a #GSequenceIter
10613 // <func>: a #GFunc
10614 // <user_data>: user data passed to @func
10615 static void foreach_range()(SequenceIter* begin, SequenceIter* end, Func func, void* user_data) nothrow {
10616 g_sequence_foreach_range(begin, end, func, user_data);
10619 // Unintrospectable function: get() / g_sequence_get()
10620 // VERSION: 2.14
10621 // Returns the data that @iter points to.
10622 // RETURNS: the data that @iter points to
10623 // <iter>: a #GSequenceIter
10624 static void* get()(SequenceIter* iter) nothrow {
10625 return g_sequence_get(iter);
10628 // Unintrospectable function: insert_before() / g_sequence_insert_before()
10629 // VERSION: 2.14
10630 // Inserts a new item just before the item pointed to by @iter.
10631 // RETURNS: an iterator pointing to the new item
10632 // <iter>: a #GSequenceIter
10633 // <data>: the data for the new item
10634 static SequenceIter* insert_before()(SequenceIter* iter, void* data) nothrow {
10635 return g_sequence_insert_before(iter, data);
10638 // VERSION: 2.14
10639 // Moves the item pointed to by @src to the position indicated by @dest.
10640 // After calling this function @dest will point to the position immediately
10641 // after @src. It is allowed for @src and @dest to point into different
10642 // sequences.
10643 // <src>: a #GSequenceIter pointing to the item to move
10644 // <dest>: a #GSequenceIter pointing to the position to which the item is moved.
10645 static void move()(SequenceIter* src, SequenceIter* dest) nothrow {
10646 g_sequence_move(src, dest);
10649 // VERSION: 2.14
10650 // Inserts the (@begin, @end) range at the destination pointed to by ptr.
10651 // The @begin and @end iters must point into the same sequence. It is
10652 // allowed for @dest to point to a different sequence than the one pointed
10653 // into by @begin and @end.
10655 // If @dest is NULL, the range indicated by @begin and @end is
10656 // removed from the sequence. If @dest iter points to a place within
10657 // the (@begin, @end) range, the range does not move.
10658 // <dest>: a #GSequenceIter
10659 // <begin>: a #GSequenceIter
10660 // <end>: a #GSequenceIter
10661 static void move_range()(SequenceIter* dest, SequenceIter* begin, SequenceIter* end) nothrow {
10662 g_sequence_move_range(dest, begin, end);
10665 // Unintrospectable function: new() / g_sequence_new()
10666 // VERSION: 2.14
10667 // Creates a new GSequence. The @data_destroy function, if non-%NULL will
10668 // be called on all items when the sequence is destroyed and on items that
10669 // are removed from the sequence.
10670 // RETURNS: a new #GSequence
10671 // <data_destroy>: a #GDestroyNotify function, or %NULL
10672 static Sequence* new_()(DestroyNotify data_destroy) nothrow {
10673 return g_sequence_new(data_destroy);
10676 // Unintrospectable function: range_get_midpoint() / g_sequence_range_get_midpoint()
10677 // VERSION: 2.14
10678 // Finds an iterator somewhere in the range (@begin, @end). This
10679 // iterator will be close to the middle of the range, but is not
10680 // guaranteed to be <emphasis>exactly</emphasis> in the middle.
10682 // The @begin and @end iterators must both point to the same sequence and
10683 // @begin must come before or be equal to @end in the sequence.
10685 // (@begin, @end) range.
10686 // RETURNS: A #GSequenceIter pointing somewhere in the
10687 // <begin>: a #GSequenceIter
10688 // <end>: a #GSequenceIter
10689 static SequenceIter* range_get_midpoint()(SequenceIter* begin, SequenceIter* end) nothrow {
10690 return g_sequence_range_get_midpoint(begin, end);
10693 // VERSION: 2.14
10694 // Removes the item pointed to by @iter. It is an error to pass the
10695 // end iterator to this function.
10697 // If the sequnce has a data destroy function associated with it, this
10698 // function is called on the data for the removed item.
10699 // <iter>: a #GSequenceIter
10700 static void remove()(SequenceIter* iter) nothrow {
10701 g_sequence_remove(iter);
10704 // VERSION: 2.14
10705 // Removes all items in the (@begin, @end) range.
10707 // If the sequence has a data destroy function associated with it, this
10708 // function is called on the data for the removed items.
10709 // <begin>: a #GSequenceIter
10710 // <end>: a #GSequenceIter
10711 static void remove_range()(SequenceIter* begin, SequenceIter* end) nothrow {
10712 g_sequence_remove_range(begin, end);
10715 // VERSION: 2.14
10716 // Changes the data for the item pointed to by @iter to be @data. If
10717 // the sequence has a data destroy function associated with it, that
10718 // function is called on the existing data that @iter pointed to.
10719 // <iter>: a #GSequenceIter
10720 // <data>: new data for the item
10721 static void set()(SequenceIter* iter, void* data) nothrow {
10722 g_sequence_set(iter, data);
10725 // Unintrospectable function: sort_changed() / g_sequence_sort_changed()
10726 // VERSION: 2.14
10727 // Moves the data pointed to a new position as indicated by @cmp_func. This
10728 // function should be called for items in a sequence already sorted according
10729 // to @cmp_func whenever some aspect of an item changes so that @cmp_func
10730 // may return different values for that item.
10732 // @cmp_func is called with two items of the @seq and @user_data.
10733 // It should return 0 if the items are equal, a negative value if
10734 // the first item comes before the second, and a positive value if
10735 // the second item comes before the first.
10736 // <iter>: A #GSequenceIter
10737 // <cmp_func>: the function used to compare items in the sequence
10738 // <cmp_data>: user data passed to @cmp_func.
10739 static void sort_changed()(SequenceIter* iter, CompareDataFunc cmp_func, void* cmp_data) nothrow {
10740 g_sequence_sort_changed(iter, cmp_func, cmp_data);
10743 // Unintrospectable function: sort_changed_iter() / g_sequence_sort_changed_iter()
10744 // VERSION: 2.14
10745 // Like g_sequence_sort_changed(), but uses
10746 // a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as
10747 // the compare function.
10749 // @iter_cmp is called with two iterators pointing into @seq. It should
10750 // return 0 if the iterators are equal, a negative value if the first
10751 // iterator comes before the second, and a positive value if the second
10752 // iterator comes before the first.
10753 // <iter>: a #GSequenceIter
10754 // <iter_cmp>: the function used to compare iterators in the sequence
10755 // <cmp_data>: user data passed to @cmp_func
10756 static void sort_changed_iter()(SequenceIter* iter, SequenceIterCompareFunc iter_cmp, void* cmp_data) nothrow {
10757 g_sequence_sort_changed_iter(iter, iter_cmp, cmp_data);
10760 // VERSION: 2.14
10761 // Swaps the items pointed to by @a and @b. It is allowed for @a and @b
10762 // to point into difference sequences.
10763 // <a>: a #GSequenceIter
10764 // <b>: a #GSequenceIter
10765 static void swap()(SequenceIter* a, SequenceIter* b) nothrow {
10766 g_sequence_swap(a, b);
10771 // The #GSequenceIter struct is an opaque data type representing an
10772 // iterator pointing into a #GSequence.
10773 struct SequenceIter {
10775 // VERSION: 2.14
10776 // Returns a negative number if @a comes before @b, 0 if they are equal,
10777 // and a positive number if @a comes after @b.
10779 // The @a and @b iterators must point into the same sequence.
10781 // equal, and a positive number if @a comes after @b.
10782 // RETURNS: A negative number if @a comes before @b, 0 if they are
10783 // <b>: a #GSequenceIter
10784 int compare()(SequenceIter* b) nothrow {
10785 return g_sequence_iter_compare(&this, b);
10788 // VERSION: 2.14
10789 // Returns the position of @iter
10790 // RETURNS: the position of @iter
10791 int get_position()() nothrow {
10792 return g_sequence_iter_get_position(&this);
10795 // Unintrospectable method: get_sequence() / g_sequence_iter_get_sequence()
10796 // VERSION: 2.14
10797 // Returns the #GSequence that @iter points into.
10798 // RETURNS: the #GSequence that @iter points into.
10799 Sequence* get_sequence()() nothrow {
10800 return g_sequence_iter_get_sequence(&this);
10803 // VERSION: 2.14
10804 // Returns whether @iter is the begin iterator
10805 // RETURNS: whether @iter is the begin iterator
10806 int is_begin()() nothrow {
10807 return g_sequence_iter_is_begin(&this);
10810 // VERSION: 2.14
10811 // Returns whether @iter is the end iterator
10812 // RETURNS: Whether @iter is the end iterator.
10813 int is_end()() nothrow {
10814 return g_sequence_iter_is_end(&this);
10817 // Unintrospectable method: move() / g_sequence_iter_move()
10818 // VERSION: 2.14
10819 // Returns the #GSequenceIter which is @delta positions away from @iter.
10820 // If @iter is closer than -@delta positions to the beginning of the sequence,
10821 // the begin iterator is returned. If @iter is closer than @delta positions
10822 // to the end of the sequence, the end iterator is returned.
10823 // RETURNS: a #GSequenceIter which is @delta positions away from @iter.
10824 // <delta>: A positive or negative number indicating how many positions away from @iter the returned #GSequenceIter will be.
10825 SequenceIter* move()(int delta) nothrow {
10826 return g_sequence_iter_move(&this, delta);
10829 // Unintrospectable method: next() / g_sequence_iter_next()
10830 // VERSION: 2.14
10831 // Returns an iterator pointing to the next position after @iter. If
10832 // @iter is the end iterator, the end iterator is returned.
10833 // RETURNS: a #GSequenceIter pointing to the next position after @iter.
10834 SequenceIter* next()() nothrow {
10835 return g_sequence_iter_next(&this);
10838 // Unintrospectable method: prev() / g_sequence_iter_prev()
10839 // VERSION: 2.14
10840 // Returns an iterator pointing to the previous position before @iter. If
10841 // @iter is the begin iterator, the begin iterator is returned.
10843 // @iter.
10844 // RETURNS: a #GSequenceIter pointing to the previous position before
10845 SequenceIter* prev()() nothrow {
10846 return g_sequence_iter_prev(&this);
10851 // A #GSequenceIterCompareFunc is a function used to compare iterators.
10852 // It must return zero if the iterators compare equal, a negative value
10853 // if @a comes before @b, and a positive value if @b comes before @a.
10854 // <a>: a #GSequenceIter
10855 // <b>: a #GSequenceIter
10856 // <data>: user data
10857 extern (C) alias int function (SequenceIter* a, SequenceIter* b, void* data) nothrow SequenceIterCompareFunc;
10859 // Error codes returned by shell functions.
10860 enum ShellError {
10861 BAD_QUOTING = 0,
10862 EMPTY_STRING = 1,
10863 FAILED = 2
10865 enum SliceConfig {
10866 ALWAYS_MALLOC = 1,
10867 BYPASS_MAGAZINES = 2,
10868 WORKING_SET_MSECS = 3,
10869 COLOR_INCREMENT = 4,
10870 CHUNK_SIZES = 5,
10871 CONTENTION_COUNTER = 6
10874 // The <structname>GSource</structname> struct is an opaque data type
10875 // representing an event source.
10876 struct Source {
10877 private void* callback_data;
10878 private SourceCallbackFuncs* callback_funcs;
10879 private SourceFuncs* source_funcs;
10880 private uint ref_count;
10881 private MainContext* context;
10882 private int priority;
10883 private uint flags, source_id;
10884 private GLib2.SList* poll_fds;
10885 private Source* prev, next;
10886 private char* name;
10887 private SourcePrivate* priv;
10890 // Creates a new #GSource structure. The size is specified to
10891 // allow creating structures derived from #GSource that contain
10892 // additional data. The size passed in must be at least
10893 // <literal>sizeof (GSource)</literal>.
10895 // The source will not initially be associated with any #GMainContext
10896 // and must be added to one with g_source_attach() before it will be
10897 // executed.
10898 // RETURNS: the newly-created #GSource.
10899 // <source_funcs>: structure containing functions that implement the sources behavior.
10900 // <struct_size>: size of the #GSource structure to create.
10901 static Source* /*new*/ new_()(SourceFuncs* source_funcs, uint struct_size) nothrow {
10902 return g_source_new(source_funcs, struct_size);
10904 alias new_!() opCall;
10906 // VERSION: 2.28
10907 // Adds @child_source to @source as a "polled" source; when @source is
10908 // added to a #GMainContext, @child_source will be automatically added
10909 // with the same priority, when @child_source is triggered, it will
10910 // cause @source to dispatch (in addition to calling its own
10911 // callback), and when @source is destroyed, it will destroy
10912 // @child_source as well. (@source will also still be dispatched if
10913 // its own prepare/check functions indicate that it is ready.)
10915 // If you don't need @child_source to do anything on its own when it
10916 // triggers, you can call g_source_set_dummy_callback() on it to set a
10917 // callback that does nothing (except return %TRUE if appropriate).
10919 // @source will hold a reference on @child_source while @child_source
10920 // is attached to it.
10921 // <child_source>: a second #GSource that @source should "poll"
10922 void add_child_source()(Source* child_source) nothrow {
10923 g_source_add_child_source(&this, child_source);
10926 // Adds a file descriptor to the set of file descriptors polled for
10927 // this source. This is usually combined with g_source_new() to add an
10928 // event source. The event source's check function will typically test
10929 // the @revents field in the #GPollFD struct and return %TRUE if events need
10930 // to be processed.
10931 // <fd>: a #GPollFD structure holding information about a file descriptor to watch.
10932 void add_poll()(PollFD* fd) nothrow {
10933 g_source_add_poll(&this, fd);
10936 // Adds a #GSource to a @context so that it will be executed within
10937 // that context. Remove it by calling g_source_destroy().
10939 // #GMainContext.
10940 // RETURNS: the ID (greater than 0) for the source within the
10941 // <context>: a #GMainContext (if %NULL, the default context will be used)
10942 uint attach()(MainContext* context=null) nothrow {
10943 return g_source_attach(&this, context);
10946 // Removes a source from its #GMainContext, if any, and mark it as
10947 // destroyed. The source cannot be subsequently added to another
10948 // context.
10949 void destroy()() nothrow {
10950 g_source_destroy(&this);
10953 // Checks whether a source is allowed to be called recursively.
10954 // see g_source_set_can_recurse().
10955 // RETURNS: whether recursion is allowed.
10956 int get_can_recurse()() nothrow {
10957 return g_source_get_can_recurse(&this);
10960 // Gets the #GMainContext with which the source is associated.
10961 // Calling this function on a destroyed source is an error.
10963 // source is associated, or %NULL if the context has not
10964 // yet been added to a source.
10965 // RETURNS: the #GMainContext with which the
10966 MainContext* get_context()() nothrow {
10967 return g_source_get_context(&this);
10970 // DEPRECATED (v2.28) method: get_current_time - use g_source_get_time() instead
10971 // This function ignores @source and is otherwise the same as
10972 // g_get_current_time().
10973 // <timeval>: #GTimeVal structure in which to store current time.
10974 void get_current_time()(TimeVal* timeval) nothrow {
10975 g_source_get_current_time(&this, timeval);
10978 // Returns the numeric ID for a particular source. The ID of a source
10979 // is a positive integer which is unique within a particular main loop
10980 // context. The reverse
10981 // mapping from ID to source is done by g_main_context_find_source_by_id().
10982 // RETURNS: the ID (greater than 0) for the source
10983 uint get_id()() nothrow {
10984 return g_source_get_id(&this);
10987 // VERSION: 2.26
10988 // Gets a name for the source, used in debugging and profiling.
10989 // The name may be #NULL if it has never been set with
10990 // g_source_set_name().
10991 // RETURNS: the name of the source
10992 char* get_name()() nothrow {
10993 return g_source_get_name(&this);
10996 // Gets the priority of a source.
10997 // RETURNS: the priority of the source
10998 int get_priority()() nothrow {
10999 return g_source_get_priority(&this);
11002 // VERSION: 2.28
11003 // Gets the time to be used when checking this source. The advantage of
11004 // calling this function over calling g_get_monotonic_time() directly is
11005 // that when checking multiple sources, GLib can cache a single value
11006 // instead of having to repeatedly get the system monotonic time.
11008 // The time here is the system monotonic time, if available, or some
11009 // other reasonable alternative otherwise. See g_get_monotonic_time().
11010 // RETURNS: the monotonic time in microseconds
11011 long get_time()() nothrow {
11012 return g_source_get_time(&this);
11015 // VERSION: 2.12
11016 // Returns whether @source has been destroyed.
11018 // This is important when you operate upon your objects
11019 // from within idle handlers, but may have freed the object
11020 // before the dispatch of your idle handler.
11022 // |[
11023 // static gboolean
11024 // idle_callback (gpointer data)
11025 // {
11026 // SomeWidget *self = data;
11028 // GDK_THREADS_ENTER (<!-- -->);
11029 // /<!-- -->* do stuff with self *<!-- -->/
11030 // self->idle_id = 0;
11031 // GDK_THREADS_LEAVE (<!-- -->);
11033 // return FALSE;
11034 // }
11036 // static void
11037 // some_widget_do_stuff_later (SomeWidget *self)
11038 // {
11039 // self->idle_id = g_idle_add (idle_callback, self);
11040 // }
11042 // static void
11043 // some_widget_finalize (GObject *object)
11044 // {
11045 // SomeWidget *self = SOME_WIDGET (object);
11047 // if (self->idle_id)
11048 // g_source_remove (self->idle_id);
11050 // G_OBJECT_CLASS (parent_class)->finalize (object);
11051 // }
11052 // ]|
11054 // This will fail in a multi-threaded application if the
11055 // widget is destroyed before the idle handler fires due
11056 // to the use after free in the callback. A solution, to
11057 // this particular problem, is to check to if the source
11058 // has already been destroy within the callback.
11060 // |[
11061 // static gboolean
11062 // idle_callback (gpointer data)
11063 // {
11064 // SomeWidget *self = data;
11066 // GDK_THREADS_ENTER ();
11067 // if (!g_source_is_destroyed (g_main_current_source ()))
11068 // {
11069 // /<!-- -->* do stuff with self *<!-- -->/
11070 // }
11071 // GDK_THREADS_LEAVE ();
11073 // return FALSE;
11074 // }
11075 // ]|
11076 // RETURNS: %TRUE if the source has been destroyed
11077 int is_destroyed()() nothrow {
11078 return g_source_is_destroyed(&this);
11081 // Increases the reference count on a source by one.
11082 // RETURNS: @source
11083 Source* /*new*/ ref_()() nothrow {
11084 return g_source_ref(&this);
11087 // VERSION: 2.28
11088 // Detaches @child_source from @source and destroys it.
11089 // <child_source>: a #GSource previously passed to g_source_add_child_source().
11090 void remove_child_source()(Source* child_source) nothrow {
11091 g_source_remove_child_source(&this, child_source);
11094 // Removes a file descriptor from the set of file descriptors polled for
11095 // this source.
11096 // <fd>: a #GPollFD structure previously passed to g_source_add_poll().
11097 void remove_poll()(PollFD* fd) nothrow {
11098 g_source_remove_poll(&this, fd);
11101 // Sets the callback function for a source. The callback for a source is
11102 // called from the source's dispatch function.
11104 // The exact type of @func depends on the type of source; ie. you
11105 // should not count on @func being called with @data as its first
11106 // parameter.
11108 // Typically, you won't use this function. Instead use functions specific
11109 // to the type of source you are using.
11110 // <func>: a callback function
11111 // <data>: the data to pass to callback function
11112 // <notify>: a function to call when @data is no longer in use, or %NULL.
11113 void set_callback()(SourceFunc func, void* data, DestroyNotify notify) nothrow {
11114 g_source_set_callback(&this, func, data, notify);
11117 // Sets the callback function storing the data as a refcounted callback
11118 // "object". This is used internally. Note that calling
11119 // g_source_set_callback_indirect() assumes
11120 // an initial reference count on @callback_data, and thus
11121 // @callback_funcs->unref will eventually be called once more
11122 // than @callback_funcs->ref.
11123 // <callback_data>: pointer to callback data "object"
11124 // <callback_funcs>: functions for reference counting @callback_data and getting the callback and data
11125 void set_callback_indirect()(void* callback_data, SourceCallbackFuncs* callback_funcs) nothrow {
11126 g_source_set_callback_indirect(&this, callback_data, callback_funcs);
11129 // Sets whether a source can be called recursively. If @can_recurse is
11130 // %TRUE, then while the source is being dispatched then this source
11131 // will be processed normally. Otherwise, all processing of this
11132 // source is blocked until the dispatch function returns.
11133 // <can_recurse>: whether recursion is allowed for this source
11134 void set_can_recurse()(int can_recurse) nothrow {
11135 g_source_set_can_recurse(&this, can_recurse);
11138 // VERSION: 2.12
11139 // Sets the source functions (can be used to override
11140 // default implementations) of an unattached source.
11141 // <funcs>: the new #GSourceFuncs
11142 void set_funcs()(SourceFuncs* funcs) nothrow {
11143 g_source_set_funcs(&this, funcs);
11146 // VERSION: 2.26
11147 // Sets a name for the source, used in debugging and profiling.
11148 // The name defaults to #NULL.
11150 // The source name should describe in a human-readable way
11151 // what the source does. For example, "X11 event queue"
11152 // or "GTK+ repaint idle handler" or whatever it is.
11154 // It is permitted to call this function multiple times, but is not
11155 // recommended due to the potential performance impact. For example,
11156 // one could change the name in the "check" function of a #GSourceFuncs
11157 // to include details like the event type in the source name.
11158 // <name>: debug name for the source
11159 void set_name()(char* name) nothrow {
11160 g_source_set_name(&this, name);
11163 // Sets the priority of a source. While the main loop is being run, a
11164 // source will be dispatched if it is ready to be dispatched and no
11165 // sources at a higher (numerically smaller) priority are ready to be
11166 // dispatched.
11167 // <priority>: the new priority.
11168 void set_priority()(int priority) nothrow {
11169 g_source_set_priority(&this, priority);
11172 // Decreases the reference count of a source by one. If the
11173 // resulting reference count is zero the source and associated
11174 // memory will be destroyed.
11175 void unref()() nothrow {
11176 g_source_unref(&this);
11179 // Removes the source with the given id from the default main context.
11180 // The id of
11181 // a #GSource is given by g_source_get_id(), or will be returned by the
11182 // functions g_source_attach(), g_idle_add(), g_idle_add_full(),
11183 // g_timeout_add(), g_timeout_add_full(), g_child_watch_add(),
11184 // g_child_watch_add_full(), g_io_add_watch(), and g_io_add_watch_full().
11186 // See also g_source_destroy(). You must use g_source_destroy() for sources
11187 // added to a non-default main context.
11188 // RETURNS: %TRUE if the source was found and removed.
11189 // <tag>: the ID of the source to remove.
11190 static int remove()(uint tag) nothrow {
11191 return g_source_remove(tag);
11194 // Removes a source from the default main loop context given the
11195 // source functions and user data. If multiple sources exist with the
11196 // same source functions and user data, only one will be destroyed.
11197 // RETURNS: %TRUE if a source was found and removed.
11198 // <funcs>: The @source_funcs passed to g_source_new()
11199 // <user_data>: the user data for the callback
11200 static int remove_by_funcs_user_data()(SourceFuncs* funcs, void* user_data) nothrow {
11201 return g_source_remove_by_funcs_user_data(funcs, user_data);
11204 // Removes a source from the default main loop context given the user
11205 // data for the callback. If multiple sources exist with the same user
11206 // data, only one will be destroyed.
11207 // RETURNS: %TRUE if a source was found and removed.
11208 // <user_data>: the user_data for the callback.
11209 static int remove_by_user_data()(void* user_data) nothrow {
11210 return g_source_remove_by_user_data(user_data);
11213 // VERSION: 2.26
11214 // Sets the name of a source using its ID.
11216 // This is a convenience utility to set source names from the return
11217 // value of g_idle_add(), g_timeout_add(), etc.
11218 // <tag>: a #GSource ID
11219 // <name>: debug name for the source
11220 static void set_name_by_id()(uint tag, char* name) nothrow {
11221 g_source_set_name_by_id(tag, name);
11225 struct SourceCallbackFuncs {
11226 extern (C) void function (void* cb_data) nothrow ref_;
11227 extern (C) void function (void* cb_data) nothrow unref;
11228 // Unintrospectable functionp: get() / ()
11229 extern (C) void function (void* cb_data, Source* source, SourceFunc* func, void** data) nothrow get;
11233 // This is just a placeholder for #GClosureMarshal,
11234 // which cannot be used here for dependency reasons.
11235 extern (C) alias void function () nothrow SourceDummyMarshal;
11238 // Specifies the type of function passed to g_timeout_add(),
11239 // g_timeout_add_full(), g_idle_add(), and g_idle_add_full().
11240 // RETURNS: %FALSE if the source should be removed
11241 // <user_data>: data passed to the function, set when the source was created with one of the above functions
11242 extern (C) alias int function (void* user_data) nothrow SourceFunc;
11245 // The <structname>GSourceFuncs</structname> struct contains a table of
11246 // functions used to handle event sources in a generic manner.
11248 // For idle sources, the prepare and check functions always return %TRUE
11249 // to indicate that the source is always ready to be processed. The prepare
11250 // function also returns a timeout value of 0 to ensure that the poll() call
11251 // doesn't block (since that would be time wasted which could have been spent
11252 // running the idle function).
11254 // For timeout sources, the prepare and check functions both return %TRUE
11255 // if the timeout interval has expired. The prepare function also returns
11256 // a timeout value to ensure that the poll() call doesn't block too long
11257 // and miss the next timeout.
11259 // For file descriptor sources, the prepare function typically returns %FALSE,
11260 // since it must wait until poll() has been called before it knows whether
11261 // any events need to be processed. It sets the returned timeout to -1 to
11262 // indicate that it doesn't mind how long the poll() call blocks. In the
11263 // check function, it tests the results of the poll() call to see if the
11264 // required condition has been met, and returns %TRUE if so.
11265 struct SourceFuncs {
11266 extern (C) int function (Source* source, int* timeout_) nothrow prepare;
11267 extern (C) int function (Source* source) nothrow check;
11268 // Unintrospectable functionp: dispatch() / ()
11269 extern (C) int function (Source* source, SourceFunc callback, void* user_data) nothrow dispatch;
11270 extern (C) void function (Source* source) nothrow finalize;
11271 private SourceFunc closure_callback;
11272 private SourceDummyMarshal closure_marshal;
11275 struct SourcePrivate {
11279 // Specifies the type of the setup function passed to g_spawn_async(),
11280 // g_spawn_sync() and g_spawn_async_with_pipes(), which can, in very
11281 // limited ways, be used to affect the child's execution.
11283 // On POSIX platforms, the function is called in the child after GLib
11284 // has performed all the setup it plans to perform, but before calling
11285 // exec(). Actions taken in this function will only affect the child,
11286 // not the parent.
11288 // On Windows, the function is called in the parent. Its usefulness on
11289 // Windows is thus questionable. In many cases executing the child setup
11290 // function in the parent can have ill effects, and you should be very
11291 // careful when porting software to Windows that uses child setup
11292 // functions.
11294 // However, even on POSIX, you are extremely limited in what you can
11295 // safely do from a #GSpawnChildSetupFunc, because any mutexes that
11296 // were held by other threads in the parent process at the time of the
11297 // fork() will still be locked in the child process, and they will
11298 // never be unlocked (since the threads that held them don't exist in
11299 // the child). POSIX allows only async-signal-safe functions (see
11300 // <citerefentry><refentrytitle>signal</refentrytitle><manvolnum>7</manvolnum></citerefentry>)
11301 // to be called in the child between fork() and exec(), which
11302 // drastically limits the usefulness of child setup functions.
11304 // In particular, it is not safe to call any function which may
11305 // call malloc(), which includes POSIX functions such as setenv().
11306 // If you need to set up the child environment differently from
11307 // the parent, you should use g_get_environ(), g_environ_setenv(),
11308 // and g_environ_unsetenv(), and then pass the complete environment
11309 // list to the <literal>g_spawn...</literal> function.
11310 // <user_data>: user data to pass to the function.
11311 extern (C) alias void function (void* user_data) nothrow SpawnChildSetupFunc;
11313 // Error codes returned by spawning processes.
11314 enum SpawnError {
11315 FORK = 0,
11316 READ = 1,
11317 CHDIR = 2,
11318 ACCES = 3,
11319 PERM = 4,
11320 _2BIG = 5,
11321 NOEXEC = 6,
11322 NAMETOOLONG = 7,
11323 NOENT = 8,
11324 NOMEM = 9,
11325 NOTDIR = 10,
11326 LOOP = 11,
11327 TXTBUSY = 12,
11328 IO = 13,
11329 NFILE = 14,
11330 MFILE = 15,
11331 INVAL = 16,
11332 ISDIR = 17,
11333 LIBBAD = 18,
11334 FAILED = 19
11336 // Flags passed to g_spawn_sync(), g_spawn_async() and g_spawn_async_with_pipes().
11337 enum SpawnFlags {
11338 LEAVE_DESCRIPTORS_OPEN = 1,
11339 DO_NOT_REAP_CHILD = 2,
11340 SEARCH_PATH = 4,
11341 STDOUT_TO_DEV_NULL = 8,
11342 STDERR_TO_DEV_NULL = 16,
11343 CHILD_INHERITS_STDIN = 32,
11344 FILE_AND_ARGV_ZERO = 64
11347 // A type corresponding to the appropriate struct type for the stat
11348 // system call, depending on the platform and/or compiler being used.
11350 // See g_stat() for more information.
11351 struct StatBuf {
11354 // The GString struct contains the public fields of a GString.
11355 struct String {
11356 char* str;
11357 size_t len, allocated_len;
11360 // Adds a string onto the end of a #GString, expanding
11361 // it if necessary.
11362 // RETURNS: @string
11363 // <val>: the string to append onto the end of @string
11364 String* /*new*/ append()(char* val) nothrow {
11365 return g_string_append(&this, val);
11368 // Adds a byte onto the end of a #GString, expanding
11369 // it if necessary.
11370 // RETURNS: @string
11371 // <c>: the byte to append onto the end of @string
11372 String* /*new*/ append_c()(char c) nothrow {
11373 return g_string_append_c(&this, c);
11376 // Appends @len bytes of @val to @string. Because @len is
11377 // provided, @val may contain embedded nuls and need not
11378 // be nul-terminated.
11380 // Since this function does not stop at nul bytes, it is
11381 // the caller's responsibility to ensure that @val has at
11382 // least @len addressable bytes.
11383 // RETURNS: @string
11384 // <val>: bytes to append
11385 // <len>: number of bytes of @val to use
11386 String* /*new*/ append_len()(char* val, ssize_t len) nothrow {
11387 return g_string_append_len(&this, val, len);
11390 // Unintrospectable method: append_printf() / g_string_append_printf()
11391 // Appends a formatted string onto the end of a #GString.
11392 // This function is similar to g_string_printf() except
11393 // that the text is appended to the #GString.
11394 // <format>: the string format. See the printf() documentation
11395 /+ Not available -- variadic methods unsupported - use the C function directly.
11396 alias g_string_append_printf append_printf; // Variadic
11399 // Converts a Unicode character into UTF-8, and appends it
11400 // to the string.
11401 // RETURNS: @string
11402 // <wc>: a Unicode character
11403 String* /*new*/ append_unichar()(dchar wc) nothrow {
11404 return g_string_append_unichar(&this, wc);
11407 // VERSION: 2.16
11408 // Appends @unescaped to @string, escaped any characters that
11409 // are reserved in URIs using URI-style escape sequences.
11410 // RETURNS: @string
11411 // <unescaped>: a string
11412 // <reserved_chars_allowed>: a string of reserved characters allowed to be used, or %NULL
11413 // <allow_utf8>: set %TRUE if the escaped string may include UTF8 characters
11414 String* /*new*/ append_uri_escaped()(char* unescaped, char* reserved_chars_allowed, int allow_utf8) nothrow {
11415 return g_string_append_uri_escaped(&this, unescaped, reserved_chars_allowed, allow_utf8);
11418 // Unintrospectable method: append_vprintf() / g_string_append_vprintf()
11419 // VERSION: 2.14
11420 // Appends a formatted string onto the end of a #GString.
11421 // This function is similar to g_string_append_printf()
11422 // except that the arguments to the format string are passed
11423 // as a va_list.
11424 // <format>: the string format. See the printf() documentation
11425 // <args>: the list of arguments to insert in the output
11426 void append_vprintf()(char* format, va_list args) nothrow {
11427 g_string_append_vprintf(&this, format, args);
11430 // Converts all uppercase ASCII letters to lowercase ASCII letters.
11432 // uppercase characters converted to lowercase in place,
11433 // with semantics that exactly match g_ascii_tolower().
11434 // RETURNS: passed-in @string pointer, with all the
11435 String* /*new*/ ascii_down()() nothrow {
11436 return g_string_ascii_down(&this);
11439 // Converts all lowercase ASCII letters to uppercase ASCII letters.
11441 // lowercase characters converted to uppercase in place,
11442 // with semantics that exactly match g_ascii_toupper().
11443 // RETURNS: passed-in @string pointer, with all the
11444 String* /*new*/ ascii_up()() nothrow {
11445 return g_string_ascii_up(&this);
11448 // Copies the bytes from a string into a #GString,
11449 // destroying any previous contents. It is rather like
11450 // the standard strcpy() function, except that you do not
11451 // have to worry about having enough space to copy the string.
11452 // RETURNS: @string
11453 // <rval>: the string to copy into @string
11454 String* /*new*/ assign()(char* rval) nothrow {
11455 return g_string_assign(&this, rval);
11458 // Converts a #GString to lowercase.
11461 // Deprecated:2.2: This function uses the locale-specific
11462 // tolower() function, which is almost never the right thing.
11463 // Use g_string_ascii_down() or g_utf8_strdown() instead.
11464 // RETURNS: the #GString
11465 String* /*new*/ down()() nothrow {
11466 return g_string_down(&this);
11469 // Compares two strings for equality, returning %TRUE if they are equal.
11470 // For use with #GHashTable.
11472 // same bytes
11473 // RETURNS: %TRUE if they strings are the same length and contain the
11474 // <v2>: another #GString
11475 int equal()(String* v2) nothrow {
11476 return g_string_equal(&this, v2);
11479 // Removes @len bytes from a #GString, starting at position @pos.
11480 // The rest of the #GString is shifted down to fill the gap.
11481 // RETURNS: @string
11482 // <pos>: the position of the content to remove
11483 // <len>: the number of bytes to remove, or -1 to remove all following bytes
11484 String* /*new*/ erase()(ssize_t pos, ssize_t len) nothrow {
11485 return g_string_erase(&this, pos, len);
11488 // Frees the memory allocated for the #GString.
11489 // If @free_segment is %TRUE it also frees the character data. If
11490 // it's %FALSE, the caller gains ownership of the buffer and must
11491 // free it after use with g_free().
11493 // (i.e. %NULL if @free_segment is %TRUE)
11494 // RETURNS: the character data of @string
11495 // <free_segment>: if %TRUE, the actual character data is freed as well
11496 char* /*new*/ free()(int free_segment) nothrow {
11497 return g_string_free(&this, free_segment);
11500 // Creates a hash code for @str; for use with #GHashTable.
11501 // RETURNS: hash code for @str
11502 uint hash()() nothrow {
11503 return g_string_hash(&this);
11506 // Inserts a copy of a string into a #GString,
11507 // expanding it if necessary.
11508 // RETURNS: @string
11509 // <pos>: the position to insert the copy of the string
11510 // <val>: the string to insert
11511 String* /*new*/ insert()(ssize_t pos, char* val) nothrow {
11512 return g_string_insert(&this, pos, val);
11515 // Inserts a byte into a #GString, expanding it if necessary.
11516 // RETURNS: @string
11517 // <pos>: the position to insert the byte
11518 // <c>: the byte to insert
11519 String* /*new*/ insert_c()(ssize_t pos, char c) nothrow {
11520 return g_string_insert_c(&this, pos, c);
11523 // Inserts @len bytes of @val into @string at @pos.
11524 // Because @len is provided, @val may contain embedded
11525 // nuls and need not be nul-terminated. If @pos is -1,
11526 // bytes are inserted at the end of the string.
11528 // Since this function does not stop at nul bytes, it is
11529 // the caller's responsibility to ensure that @val has at
11530 // least @len addressable bytes.
11531 // RETURNS: @string
11532 // <pos>: position in @string where insertion should happen, or -1 for at the end
11533 // <val>: bytes to insert
11534 // <len>: number of bytes of @val to insert
11535 String* /*new*/ insert_len()(ssize_t pos, char* val, ssize_t len) nothrow {
11536 return g_string_insert_len(&this, pos, val, len);
11539 // Converts a Unicode character into UTF-8, and insert it
11540 // into the string at the given position.
11541 // RETURNS: @string
11542 // <pos>: the position at which to insert character, or -1 to append at the end of the string
11543 // <wc>: a Unicode character
11544 String* /*new*/ insert_unichar()(ssize_t pos, dchar wc) nothrow {
11545 return g_string_insert_unichar(&this, pos, wc);
11548 // VERSION: 2.14
11549 // Overwrites part of a string, lengthening it if necessary.
11550 // RETURNS: @string
11551 // <pos>: the position at which to start overwriting
11552 // <val>: the string that will overwrite the @string starting at @pos
11553 String* /*new*/ overwrite()(size_t pos, char* val) nothrow {
11554 return g_string_overwrite(&this, pos, val);
11557 // VERSION: 2.14
11558 // Overwrites part of a string, lengthening it if necessary.
11559 // This function will work with embedded nuls.
11560 // RETURNS: @string
11561 // <pos>: the position at which to start overwriting
11562 // <val>: the string that will overwrite the @string starting at @pos
11563 // <len>: the number of bytes to write from @val
11564 String* /*new*/ overwrite_len()(size_t pos, char* val, ssize_t len) nothrow {
11565 return g_string_overwrite_len(&this, pos, val, len);
11568 // Adds a string on to the start of a #GString,
11569 // expanding it if necessary.
11570 // RETURNS: @string
11571 // <val>: the string to prepend on the start of @string
11572 String* /*new*/ prepend()(char* val) nothrow {
11573 return g_string_prepend(&this, val);
11576 // Adds a byte onto the start of a #GString,
11577 // expanding it if necessary.
11578 // RETURNS: @string
11579 // <c>: the byte to prepend on the start of the #GString
11580 String* /*new*/ prepend_c()(char c) nothrow {
11581 return g_string_prepend_c(&this, c);
11584 // Prepends @len bytes of @val to @string.
11585 // Because @len is provided, @val may contain
11586 // embedded nuls and need not be nul-terminated.
11588 // Since this function does not stop at nul bytes,
11589 // it is the caller's responsibility to ensure that
11590 // @val has at least @len addressable bytes.
11591 // RETURNS: @string
11592 // <val>: bytes to prepend
11593 // <len>: number of bytes in @val to prepend
11594 String* /*new*/ prepend_len()(char* val, ssize_t len) nothrow {
11595 return g_string_prepend_len(&this, val, len);
11598 // Converts a Unicode character into UTF-8, and prepends it
11599 // to the string.
11600 // RETURNS: @string
11601 // <wc>: a Unicode character
11602 String* /*new*/ prepend_unichar()(dchar wc) nothrow {
11603 return g_string_prepend_unichar(&this, wc);
11606 // Unintrospectable method: printf() / g_string_printf()
11607 // Writes a formatted string into a #GString.
11608 // This is similar to the standard sprintf() function,
11609 // except that the #GString buffer automatically expands
11610 // to contain the results. The previous contents of the
11611 // #GString are destroyed.
11612 // <format>: the string format. See the printf() documentation
11613 /+ Not available -- variadic methods unsupported - use the C function directly.
11614 alias g_string_printf printf; // Variadic
11617 // Sets the length of a #GString. If the length is less than
11618 // the current length, the string will be truncated. If the
11619 // length is greater than the current length, the contents
11620 // of the newly added area are undefined. (However, as
11621 // always, string->str[string->len] will be a nul byte.)
11622 // RETURNS: @string
11623 // <len>: the new length
11624 String* /*new*/ set_size()(size_t len) nothrow {
11625 return g_string_set_size(&this, len);
11628 // Cuts off the end of the GString, leaving the first @len bytes.
11629 // RETURNS: @string
11630 // <len>: the new size of @string
11631 String* /*new*/ truncate()(size_t len) nothrow {
11632 return g_string_truncate(&this, len);
11635 // Converts a #GString to uppercase.
11638 // Deprecated:2.2: This function uses the locale-specific
11639 // toupper() function, which is almost never the right thing.
11640 // Use g_string_ascii_up() or g_utf8_strup() instead.
11641 // RETURNS: @string
11642 String* /*new*/ up()() nothrow {
11643 return g_string_up(&this);
11646 // Unintrospectable method: vprintf() / g_string_vprintf()
11647 // VERSION: 2.14
11648 // Writes a formatted string into a #GString.
11649 // This function is similar to g_string_printf() except that
11650 // the arguments to the format string are passed as a va_list.
11651 // <format>: the string format. See the printf() documentation
11652 // <args>: the parameters to insert into the format string
11653 void vprintf()(char* format, va_list args) nothrow {
11654 g_string_vprintf(&this, format, args);
11659 // An opaque data structure representing String Chunks.
11660 // It should only be accessed by using the following functions.
11661 struct StringChunk {
11663 // VERSION: 2.14
11664 // Frees all strings contained within the #GStringChunk.
11665 // After calling g_string_chunk_clear() it is not safe to
11666 // access any of the strings which were contained within it.
11667 void clear()() nothrow {
11668 g_string_chunk_clear(&this);
11671 // Frees all memory allocated by the #GStringChunk.
11672 // After calling g_string_chunk_free() it is not safe to
11673 // access any of the strings which were contained within it.
11674 void free()() nothrow {
11675 g_string_chunk_free(&this);
11678 // Adds a copy of @string to the #GStringChunk.
11679 // It returns a pointer to the new copy of the string
11680 // in the #GStringChunk. The characters in the string
11681 // can be changed, if necessary, though you should not
11682 // change anything after the end of the string.
11684 // Unlike g_string_chunk_insert_const(), this function
11685 // does not check for duplicates. Also strings added
11686 // with g_string_chunk_insert() will not be searched
11687 // by g_string_chunk_insert_const() when looking for
11688 // duplicates.
11690 // the #GStringChunk
11691 // RETURNS: a pointer to the copy of @string within
11692 // <string>: the string to add
11693 char* /*new*/ insert()(char* string_) nothrow {
11694 return g_string_chunk_insert(&this, string_);
11697 // Adds a copy of @string to the #GStringChunk, unless the same
11698 // string has already been added to the #GStringChunk with
11699 // g_string_chunk_insert_const().
11701 // This function is useful if you need to copy a large number
11702 // of strings but do not want to waste space storing duplicates.
11703 // But you must remember that there may be several pointers to
11704 // the same string, and so any changes made to the strings
11705 // should be done very carefully.
11707 // Note that g_string_chunk_insert_const() will not return a
11708 // pointer to a string added with g_string_chunk_insert(), even
11709 // if they do match.
11711 // within the #GStringChunk
11712 // RETURNS: a pointer to the new or existing copy of @string
11713 // <string>: the string to add
11714 char* /*new*/ insert_const()(char* string_) nothrow {
11715 return g_string_chunk_insert_const(&this, string_);
11718 // VERSION: 2.4
11719 // Adds a copy of the first @len bytes of @string to the #GStringChunk.
11720 // The copy is nul-terminated.
11722 // Since this function does not stop at nul bytes, it is the caller's
11723 // responsibility to ensure that @string has at least @len addressable
11724 // bytes.
11726 // The characters in the returned string can be changed, if necessary,
11727 // though you should not change anything after the end of the string.
11728 // RETURNS: a pointer to the copy of @string within the #GStringChunk
11729 // <string>: bytes to insert
11730 // <len>: number of bytes of @string to insert, or -1 to insert a nul-terminated string
11731 char* /*new*/ insert_len()(char* string_, ssize_t len) nothrow {
11732 return g_string_chunk_insert_len(&this, string_, len);
11735 // Unintrospectable function: new() / g_string_chunk_new()
11736 // Creates a new #GStringChunk.
11737 // RETURNS: a new #GStringChunk
11738 // <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.
11739 static StringChunk* new_()(size_t size) nothrow {
11740 return g_string_chunk_new(size);
11744 // An opaque structure representing a test case.
11745 struct TestCase {
11748 struct TestConfig {
11749 int test_initialized, test_quick, test_perf, test_verbose, test_quiet, test_undefined;
11753 // VERSION: 2.28
11754 // The type used for test case functions that take an extra pointer
11755 // argument.
11756 // <user_data>: the data provided when registering the test
11757 extern (C) alias void function (const(void)* user_data) nothrow TestDataFunc;
11760 // VERSION: 2.28
11761 // The type used for functions that operate on test fixtures. This is
11762 // used for the fixture setup and teardown functions as well as for the
11763 // testcases themselves.
11765 // @user_data is a pointer to the data that was given when registering
11766 // the test case.
11768 // @fixture will be a pointer to the area of memory allocated by the
11769 // test framework, of the size requested. If the requested size was
11770 // zero then @fixture will be equal to @user_data.
11771 // <fixture>: the test fixture
11772 // <user_data>: the data provided when registering the test
11773 extern (C) alias void function (void* fixture, const(void)* user_data) nothrow TestFixtureFunc;
11776 // VERSION: 2.28
11777 // The type used for test case functions.
11778 extern (C) alias void function () nothrow TestFunc;
11780 struct TestLogBuffer {
11781 private String* data;
11782 private GLib2.SList* msgs;
11784 // Internal function for gtester to free test log messages, no ABI guarantees provided.
11785 void free()() nothrow {
11786 g_test_log_buffer_free(&this);
11789 // Unintrospectable method: pop() / g_test_log_buffer_pop()
11790 // Internal function for gtester to retrieve test log messages, no ABI guarantees provided.
11791 TestLogMsg* pop()() nothrow {
11792 return g_test_log_buffer_pop(&this);
11794 // Internal function for gtester to decode test log messages, no ABI guarantees provided.
11795 void push()(uint n_bytes, ubyte* bytes) nothrow {
11796 g_test_log_buffer_push(&this, n_bytes, bytes);
11799 // Unintrospectable function: new() / g_test_log_buffer_new()
11800 // Internal function for gtester to decode test log messages, no ABI guarantees provided.
11801 static TestLogBuffer* new_()() nothrow {
11802 return g_test_log_buffer_new();
11807 // VERSION: 2.22
11808 // Specifies the prototype of fatal log handler functions.
11809 // RETURNS: %TRUE if the program should abort, %FALSE otherwise
11810 // <log_domain>: the log domain of the message
11811 // <log_level>: the log level of the message (including the fatal and recursion flags)
11812 // <message>: the message to process
11813 // <user_data>: user data, set in g_test_log_set_fatal_handler()
11814 extern (C) alias int function (char* log_domain, LogLevelFlags log_level, char* message, void* user_data) nothrow TestLogFatalFunc;
11816 struct TestLogMsg {
11817 TestLogType log_type;
11818 uint n_strings;
11819 char** strings;
11820 uint n_nums;
11821 c_long* nums;
11823 // Internal function for gtester to free test log messages, no ABI guarantees provided.
11824 void free()() nothrow {
11825 g_test_log_msg_free(&this);
11829 enum TestLogType {
11830 NONE = 0,
11831 ERROR = 1,
11832 START_BINARY = 2,
11833 LIST_CASE = 3,
11834 SKIP_CASE = 4,
11835 START_CASE = 5,
11836 STOP_CASE = 6,
11837 MIN_RESULT = 7,
11838 MAX_RESULT = 8,
11839 MESSAGE = 9
11841 // An opaque structure representing a test suite.
11842 struct TestSuite {
11844 // VERSION: 2.16
11845 // Adds @test_case to @suite.
11846 // <test_case>: a #GTestCase
11847 void add()(TestCase* test_case) nothrow {
11848 g_test_suite_add(&this, test_case);
11851 // VERSION: 2.16
11852 // Adds @nestedsuite to @suite.
11853 // <nestedsuite>: another #GTestSuite
11854 void add_suite()(TestSuite* nestedsuite) nothrow {
11855 g_test_suite_add_suite(&this, nestedsuite);
11860 // Test traps are guards around forked tests.
11861 // These flags determine what traps to set.
11862 enum TestTrapFlags {
11863 SILENCE_STDOUT = 128,
11864 SILENCE_STDERR = 256,
11865 INHERIT_STDIN = 512
11868 // The #GThread struct represents a running thread. This struct
11869 // is returned by g_thread_new() or g_thread_try_new(). You can
11870 // obtain the #GThread struct representing the current thead by
11871 // calling g_thread_self().
11873 // GThread is refcounted, see g_thread_ref() and g_thread_unref().
11874 // The thread represented by it holds a reference while it is running,
11875 // and g_thread_join() consumes the reference that it is given, so
11876 // it is normally not necessary to manage GThread references
11877 // explicitly.
11879 // The structure is opaque -- none of its fields may be directly
11880 // accessed.
11881 struct Thread {
11883 // Unintrospectable method: join() / g_thread_join()
11884 // Waits until @thread finishes, i.e. the function @func, as
11885 // given to g_thread_new(), returns or g_thread_exit() is called.
11886 // If @thread has already terminated, then g_thread_join()
11887 // returns immediately.
11889 // Any thread can wait for any other thread by calling g_thread_join(),
11890 // not just its 'creator'. Calling g_thread_join() from multiple threads
11891 // for the same @thread leads to undefined behaviour.
11893 // The value returned by @func or given to g_thread_exit() is
11894 // returned by this function.
11896 // g_thread_join() consumes the reference to the passed-in @thread.
11897 // This will usually cause the #GThread struct and associated resources
11898 // to be freed. Use g_thread_ref() to obtain an extra reference if you
11899 // want to keep the GThread alive beyond the g_thread_join() call.
11900 // RETURNS: the return value of the thread
11901 void* join()() nothrow {
11902 return g_thread_join(&this);
11905 // Unintrospectable method: ref() / g_thread_ref()
11906 // VERSION: 2.32
11907 // Increase the reference count on @thread.
11908 // RETURNS: a new reference to @thread
11909 Thread* ref_()() nothrow {
11910 return g_thread_ref(&this);
11913 // VERSION: 2.32
11914 // Decrease the reference count on @thread, possibly freeing all
11915 // resources associated with it.
11917 // Note that each thread holds a reference to its #GThread while
11918 // it is running, so it is safe to drop your own reference to it
11919 // if you don't need it anymore.
11920 void unref()() nothrow {
11921 g_thread_unref(&this);
11923 static Quark error_quark()() nothrow {
11924 return g_thread_error_quark();
11927 // Terminates the current thread.
11929 // If another thread is waiting for us using g_thread_join() then the
11930 // waiting thread will be woken up and get @retval as the return value
11931 // of g_thread_join().
11933 // Calling <literal>g_thread_exit (retval)</literal> is equivalent to
11934 // returning @retval from the function @func, as given to g_thread_new().
11936 // <note><para>
11937 // You must only call g_thread_exit() from a thread that you created
11938 // yourself with g_thread_new() or related APIs. You must not call
11939 // this function from a thread created with another threading library
11940 // or or from within a #GThreadPool.
11941 // </para></note>
11942 // <retval>: the return value of this thread
11943 static void exit()(void* retval) nothrow {
11944 g_thread_exit(retval);
11947 // Unintrospectable function: new() / g_thread_new()
11948 // VERSION: 2.32
11949 // This function creates a new thread. The new thread starts by invoking
11950 // @func with the argument data. The thread will run until @func returns
11951 // or until g_thread_exit() is called from the new thread. The return value
11952 // of @func becomes the return value of the thread, which can be obtained
11953 // with g_thread_join().
11955 // The @name can be useful for discriminating threads in a debugger.
11956 // Some systems restrict the length of @name to 16 bytes.
11958 // If the thread can not be created the program aborts. See
11959 // g_thread_try_new() if you want to attempt to deal with failures.
11961 // To free the struct returned by this function, use g_thread_unref().
11962 // Note that g_thread_join() implicitly unrefs the #GThread as well.
11963 // RETURNS: the new #GThread
11964 // <name>: a name for the new thread
11965 // <func>: a function to execute in the new thread
11966 // <data>: an argument to supply to the new thread
11967 static Thread* new_()(char* name, ThreadFunc func, void* data) nothrow {
11968 return g_thread_new(name, func, data);
11971 // Unintrospectable function: self() / g_thread_self()
11972 // This functions returns the #GThread corresponding to the
11973 // current thread. Note that this function does not increase
11974 // the reference count of the returned struct.
11976 // This function will return a #GThread even for threads that
11977 // were not created by GLib (i.e. those created by other threading
11978 // APIs). This may be useful for thread identification purposes
11979 // (i.e. comparisons) but you must not use GLib functions (such
11980 // as g_thread_join()) on these threads.
11981 // RETURNS: the #GThread representing the current thread
11982 static Thread* self()() nothrow {
11983 return g_thread_self();
11986 // Unintrospectable function: try_new() / g_thread_try_new()
11987 // VERSION: 2.32
11988 // This function is the same as g_thread_new() except that
11989 // it allows for the possibility of failure.
11991 // If a thread can not be created (due to resource limits),
11992 // @error is set and %NULL is returned.
11993 // RETURNS: the new #GThread, or %NULL if an error occurred
11994 // <name>: a name for the new thread
11995 // <func>: a function to execute in the new thread
11996 // <data>: an argument to supply to the new thread
11997 static Thread* try_new()(char* name, ThreadFunc func, void* data, GLib2.Error** error=null) nothrow {
11998 return g_thread_try_new(name, func, data, error);
12001 // Causes the calling thread to voluntarily relinquish the CPU, so
12002 // that other threads can run.
12004 // This function is often used as a method to make busy wait less evil.
12005 static void yield()() nothrow {
12006 g_thread_yield();
12010 // Possible errors of thread related functions.
12011 enum ThreadError {
12012 THREAD_ERROR_AGAIN = 0
12015 // Unintrospectable callback: ThreadFunc() / ()
12016 // Specifies the type of the @func functions passed to g_thread_new()
12017 // or g_thread_try_new().
12018 // RETURNS: the return value of the thread
12019 // <data>: data passed to the thread
12020 extern (C) alias void* function (void* data) nothrow ThreadFunc;
12023 // The #GThreadPool struct represents a thread pool. It has three
12024 // public read-only members, but the underlying struct is bigger,
12025 // so you must not copy this struct.
12026 struct ThreadPool {
12027 Func func;
12028 void* user_data;
12029 int exclusive;
12032 // Frees all resources allocated for @pool.
12034 // If @immediate is %TRUE, no new task is processed for @pool.
12035 // Otherwise @pool is not freed before the last task is processed.
12036 // Note however, that no thread of this pool is interrupted while
12037 // processing a task. Instead at least all still running threads
12038 // can finish their tasks before the @pool is freed.
12040 // If @wait_ is %TRUE, the functions does not return before all
12041 // tasks to be processed (dependent on @immediate, whether all
12042 // or only the currently running) are ready.
12043 // Otherwise the function returns immediately.
12045 // After calling this function @pool must not be used anymore.
12046 // <immediate>: should @pool shut down immediately?
12047 // <wait_>: should the function wait for all tasks to be finished?
12048 void free()(int immediate, int wait_) nothrow {
12049 g_thread_pool_free(&this, immediate, wait_);
12052 // Returns the maximal number of threads for @pool.
12053 // RETURNS: the maximal number of threads
12054 int get_max_threads()() nothrow {
12055 return g_thread_pool_get_max_threads(&this);
12058 // Returns the number of threads currently running in @pool.
12059 // RETURNS: the number of threads currently running
12060 uint get_num_threads()() nothrow {
12061 return g_thread_pool_get_num_threads(&this);
12064 // Inserts @data into the list of tasks to be executed by @pool.
12066 // When the number of currently running threads is lower than the
12067 // maximal allowed number of threads, a new thread is started (or
12068 // reused) with the properties given to g_thread_pool_new().
12069 // Otherwise, @data stays in the queue until a thread in this pool
12070 // finishes its previous task and processes @data.
12072 // @error can be %NULL to ignore errors, or non-%NULL to report
12073 // errors. An error can only occur when a new thread couldn't be
12074 // created. In that case @data is simply appended to the queue of
12075 // work to do.
12077 // Before version 2.32, this function did not return a success status.
12078 // RETURNS: %TRUE on success, %FALSE if an error occurred
12079 // <data>: a new task for @pool
12080 int push()(void* data, GLib2.Error** error=null) nothrow {
12081 return g_thread_pool_push(&this, data, error);
12084 // Sets the maximal allowed number of threads for @pool.
12085 // A value of -1 means that the maximal number of threads
12086 // is unlimited. If @pool is an exclusive thread pool, setting
12087 // the maximal number of threads to -1 is not allowed.
12089 // Setting @max_threads to 0 means stopping all work for @pool.
12090 // It is effectively frozen until @max_threads is set to a non-zero
12091 // value again.
12093 // A thread is never terminated while calling @func, as supplied by
12094 // g_thread_pool_new(). Instead the maximal number of threads only
12095 // has effect for the allocation of new threads in g_thread_pool_push().
12096 // A new thread is allocated, whenever the number of currently
12097 // running threads in @pool is smaller than the maximal number.
12099 // @error can be %NULL to ignore errors, or non-%NULL to report
12100 // errors. An error can only occur when a new thread couldn't be
12101 // created.
12103 // Before version 2.32, this function did not return a success status.
12104 // RETURNS: %TRUE on success, %FALSE if an error occurred
12105 // <max_threads>: a new maximal number of threads for @pool, or -1 for unlimited
12106 int set_max_threads()(int max_threads, GLib2.Error** error=null) nothrow {
12107 return g_thread_pool_set_max_threads(&this, max_threads, error);
12110 // Unintrospectable method: set_sort_function() / g_thread_pool_set_sort_function()
12111 // VERSION: 2.10
12112 // Sets the function used to sort the list of tasks. This allows the
12113 // tasks to be processed by a priority determined by @func, and not
12114 // just in the order in which they were added to the pool.
12116 // Note, if the maximum number of threads is more than 1, the order
12117 // that threads are executed cannot be guaranteed 100%. Threads are
12118 // scheduled by the operating system and are executed at random. It
12119 // cannot be assumed that threads are executed in the order they are
12120 // created.
12121 // <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.
12122 // <user_data>: user data passed to @func
12123 void set_sort_function()(CompareDataFunc func, void* user_data) nothrow {
12124 g_thread_pool_set_sort_function(&this, func, user_data);
12127 // Returns the number of tasks still unprocessed in @pool.
12128 // RETURNS: the number of unprocessed tasks
12129 uint unprocessed()() nothrow {
12130 return g_thread_pool_unprocessed(&this);
12133 // VERSION: 2.10
12134 // This function will return the maximum @interval that a
12135 // thread will wait in the thread pool for new tasks before
12136 // being stopped.
12138 // If this function returns 0, threads waiting in the thread
12139 // pool for new work are not stopped.
12141 // for new tasks in the thread pool before stopping the
12142 // thread
12143 // RETURNS: the maximum @interval (milliseconds) to wait
12144 static uint get_max_idle_time()() nothrow {
12145 return g_thread_pool_get_max_idle_time();
12148 // Returns the maximal allowed number of unused threads.
12149 // RETURNS: the maximal number of unused threads
12150 static int get_max_unused_threads()() nothrow {
12151 return g_thread_pool_get_max_unused_threads();
12154 // Returns the number of currently unused threads.
12155 // RETURNS: the number of currently unused threads
12156 static uint get_num_unused_threads()() nothrow {
12157 return g_thread_pool_get_num_unused_threads();
12160 // Unintrospectable function: new() / g_thread_pool_new()
12161 // This function creates a new thread pool.
12163 // Whenever you call g_thread_pool_push(), either a new thread is
12164 // created or an unused one is reused. At most @max_threads threads
12165 // are running concurrently for this thread pool. @max_threads = -1
12166 // allows unlimited threads to be created for this thread pool. The
12167 // newly created or reused thread now executes the function @func
12168 // with the two arguments. The first one is the parameter to
12169 // g_thread_pool_push() and the second one is @user_data.
12171 // The parameter @exclusive determines whether the thread pool owns
12172 // all threads exclusive or shares them with other thread pools.
12173 // If @exclusive is %TRUE, @max_threads threads are started
12174 // immediately and they will run exclusively for this thread pool
12175 // until it is destroyed by g_thread_pool_free(). If @exclusive is
12176 // %FALSE, threads are created when needed and shared between all
12177 // non-exclusive thread pools. This implies that @max_threads may
12178 // not be -1 for exclusive thread pools.
12180 // @error can be %NULL to ignore errors, or non-%NULL to report
12181 // errors. An error can only occur when @exclusive is set to %TRUE
12182 // and not all @max_threads threads could be created.
12183 // RETURNS: the new #GThreadPool
12184 // <func>: a function to execute in the threads of the new thread pool
12185 // <user_data>: user data that is handed over to @func every time it is called
12186 // <max_threads>: the maximal number of threads to execute concurrently in the new thread pool, -1 means no limit
12187 // <exclusive>: should this thread pool be exclusive?
12188 static ThreadPool* new_()(Func func, void* user_data, int max_threads, int exclusive, GLib2.Error** error=null) nothrow {
12189 return g_thread_pool_new(func, user_data, max_threads, exclusive, error);
12192 // VERSION: 2.10
12193 // This function will set the maximum @interval that a thread
12194 // waiting in the pool for new tasks can be idle for before
12195 // being stopped. This function is similar to calling
12196 // g_thread_pool_stop_unused_threads() on a regular timeout,
12197 // except this is done on a per thread basis.
12199 // By setting @interval to 0, idle threads will not be stopped.
12201 // This function makes use of g_async_queue_timed_pop () using
12202 // @interval.
12203 // <interval>: the maximum @interval (in milliseconds) a thread can be idle
12204 static void set_max_idle_time()(uint interval) nothrow {
12205 g_thread_pool_set_max_idle_time(interval);
12208 // Sets the maximal number of unused threads to @max_threads.
12209 // If @max_threads is -1, no limit is imposed on the number
12210 // of unused threads.
12211 // <max_threads>: maximal number of unused threads
12212 static void set_max_unused_threads()(int max_threads) nothrow {
12213 g_thread_pool_set_max_unused_threads(max_threads);
12216 // Stops all currently unused threads. This does not change the
12217 // maximal number of unused threads. This function can be used to
12218 // regularly stop all unused threads e.g. from g_timeout_add().
12219 static void stop_unused_threads()() nothrow {
12220 g_thread_pool_stop_unused_threads();
12225 // Disambiguates a given time in two ways.
12227 // First, specifies if the given time is in universal or local time.
12229 // Second, if the time is in local time, specifies if it is local
12230 // standard time or local daylight time. This is important for the case
12231 // where the same local time occurs twice (during daylight savings time
12232 // transitions, for example).
12233 enum TimeType {
12234 STANDARD = 0,
12235 DAYLIGHT = 1,
12236 UNIVERSAL = 2
12239 // Represents a precise time, with seconds and microseconds.
12240 // Similar to the <structname>struct timeval</structname> returned by
12241 // the gettimeofday() UNIX system call.
12243 // GLib is attempting to unify around the use of 64bit integers to
12244 // represent microsecond-precision time. As such, this type will be
12245 // removed from a future version of GLib.
12246 struct TimeVal {
12247 c_long tv_sec, tv_usec;
12250 // Adds the given number of microseconds to @time_. @microseconds can
12251 // also be negative to decrease the value of @time_.
12252 // <microseconds>: number of microseconds to add to @time
12253 void add()(c_long microseconds) nothrow {
12254 g_time_val_add(&this, microseconds);
12257 // VERSION: 2.12
12258 // Converts @time_ into an RFC 3339 encoded string, relative to the
12259 // Coordinated Universal Time (UTC). This is one of the many formats
12260 // allowed by ISO 8601.
12262 // ISO 8601 allows a large number of date/time formats, with or without
12263 // punctuation and optional elements. The format returned by this function
12264 // is a complete date and time, with optional punctuation included, the
12265 // UTC time zone represented as "Z", and the @tv_usec part included if
12266 // and only if it is nonzero, i.e. either
12267 // "YYYY-MM-DDTHH:MM:SSZ" or "YYYY-MM-DDTHH:MM:SS.fffffZ".
12269 // This corresponds to the Internet date/time format defined by
12270 // <ulink url="https://www.ietf.org/rfc/rfc3339.txt">RFC 3339</ulink>, and
12271 // to either of the two most-precise formats defined by
12272 // <ulink url="http://www.w3.org/TR/NOTE-datetime-19980827">the W3C Note
12273 // "Date and Time Formats"</ulink>. Both of these documents are profiles of
12274 // ISO 8601.
12276 // Use g_date_time_format() or g_strdup_printf() if a different
12277 // variation of ISO 8601 format is required.
12278 // RETURNS: a newly allocated string containing an ISO 8601 date
12279 char* /*new*/ to_iso8601()() nothrow {
12280 return g_time_val_to_iso8601(&this);
12283 // VERSION: 2.12
12284 // Converts a string containing an ISO 8601 encoded date and time
12285 // to a #GTimeVal and puts it into @time_.
12287 // @iso_date must include year, month, day, hours, minutes, and
12288 // seconds. It can optionally include fractions of a second and a time
12289 // zone indicator. (In the absence of any time zone indication, the
12290 // timestamp is assumed to be in local time.)
12291 // RETURNS: %TRUE if the conversion was successful.
12292 // <iso_date>: an ISO 8601 encoded date string
12293 // <time_>: a #GTimeVal
12294 static int from_iso8601()(char* iso_date, /*out*/ TimeVal* time_) nothrow {
12295 return g_time_val_from_iso8601(iso_date, time_);
12300 // #GDateTime is an opaque structure whose members cannot be accessed
12301 // directly.
12302 struct TimeZone /* Version 2.26 */ {
12304 // VERSION: 2.26
12305 // Finds an interval within @tz that corresponds to the given @time_,
12306 // possibly adjusting @time_ if required to fit into an interval.
12307 // The meaning of @time_ depends on @type.
12309 // This function is similar to g_time_zone_find_interval(), with the
12310 // difference that it always succeeds (by making the adjustments
12311 // described below).
12313 // In any of the cases where g_time_zone_find_interval() succeeds then
12314 // this function returns the same value, without modifying @time_.
12316 // This function may, however, modify @time_ in order to deal with
12317 // non-existent times. If the non-existent local @time_ of 02:30 were
12318 // requested on March 13th 2010 in Toronto then this function would
12319 // adjust @time_ to be 03:00 and return the interval containing the
12320 // adjusted time.
12321 // RETURNS: the interval containing @time_, never -1
12322 // <type>: the #GTimeType of @time_
12323 // <time_>: a pointer to a number of seconds since January 1, 1970
12324 int adjust_time()(TimeType type, long* time_) nothrow {
12325 return g_time_zone_adjust_time(&this, type, time_);
12328 // VERSION: 2.26
12329 // Finds an the interval within @tz that corresponds to the given @time_.
12330 // The meaning of @time_ depends on @type.
12332 // If @type is %G_TIME_TYPE_UNIVERSAL then this function will always
12333 // succeed (since universal time is monotonic and continuous).
12335 // Otherwise @time_ is treated is local time. The distinction between
12336 // %G_TIME_TYPE_STANDARD and %G_TIME_TYPE_DAYLIGHT is ignored except in
12337 // the case that the given @time_ is ambiguous. In Toronto, for example,
12338 // 01:30 on November 7th 2010 occurred twice (once inside of daylight
12339 // savings time and the next, an hour later, outside of daylight savings
12340 // time). In this case, the different value of @type would result in a
12341 // different interval being returned.
12343 // It is still possible for this function to fail. In Toronto, for
12344 // example, 02:00 on March 14th 2010 does not exist (due to the leap
12345 // forward to begin daylight savings time). -1 is returned in that
12346 // case.
12347 // RETURNS: the interval containing @time_, or -1 in case of failure
12348 // <type>: the #GTimeType of @time_
12349 // <time_>: a number of seconds since January 1, 1970
12350 int find_interval()(TimeType type, long time_) nothrow {
12351 return g_time_zone_find_interval(&this, type, time_);
12354 // VERSION: 2.26
12355 // Determines the time zone abbreviation to be used during a particular
12356 // @interval of time in the time zone @tz.
12358 // For example, in Toronto this is currently "EST" during the winter
12359 // months and "EDT" during the summer months when daylight savings time
12360 // is in effect.
12361 // RETURNS: the time zone abbreviation, which belongs to @tz
12362 // <interval>: an interval within the timezone
12363 char* get_abbreviation()(int interval) nothrow {
12364 return g_time_zone_get_abbreviation(&this, interval);
12367 // VERSION: 2.26
12368 // Determines the offset to UTC in effect during a particular @interval
12369 // of time in the time zone @tz.
12371 // The offset is the number of seconds that you add to UTC time to
12372 // arrive at local time for @tz (ie: negative numbers for time zones
12373 // west of GMT, positive numbers for east).
12375 // local time in @tz
12376 // RETURNS: the number of seconds that should be added to UTC to get the
12377 // <interval>: an interval within the timezone
12378 int get_offset()(int interval) nothrow {
12379 return g_time_zone_get_offset(&this, interval);
12382 // VERSION: 2.26
12383 // Determines if daylight savings time is in effect during a particular
12384 // @interval of time in the time zone @tz.
12385 // RETURNS: %TRUE if daylight savings time is in effect
12386 // <interval>: an interval within the timezone
12387 int is_dst()(int interval) nothrow {
12388 return g_time_zone_is_dst(&this, interval);
12391 // Unintrospectable method: ref() / g_time_zone_ref()
12392 // VERSION: 2.26
12393 // Increases the reference count on @tz.
12394 // RETURNS: a new reference to @tz.
12395 TimeZone* ref_()() nothrow {
12396 return g_time_zone_ref(&this);
12399 // VERSION: 2.26
12400 // Decreases the reference count on @tz.
12401 void unref()() nothrow {
12402 g_time_zone_unref(&this);
12405 // Unintrospectable function: new() / g_time_zone_new()
12406 // VERSION: 2.26
12407 // Creates a #GTimeZone corresponding to @identifier.
12409 // @identifier can either be an RFC3339/ISO 8601 time offset or
12410 // something that would pass as a valid value for the
12411 // <varname>TZ</varname> environment variable (including %NULL).
12413 // Valid RFC3339 time offsets are <literal>"Z"</literal> (for UTC) or
12414 // <literal>"±hh:mm"</literal>. ISO 8601 additionally specifies
12415 // <literal>"±hhmm"</literal> and <literal>"±hh"</literal>.
12417 // The <varname>TZ</varname> environment variable typically corresponds
12418 // to the name of a file in the zoneinfo database, but there are many
12419 // other possibilities. Note that those other possibilities are not
12420 // currently implemented, but are planned.
12422 // g_time_zone_new_local() calls this function with the value of the
12423 // <varname>TZ</varname> environment variable. This function itself is
12424 // independent of the value of <varname>TZ</varname>, but if @identifier
12425 // is %NULL then <filename>/etc/localtime</filename> will be consulted
12426 // to discover the correct timezone.
12428 // See <ulink
12429 // url='http://tools.ietf.org/html/rfc3339#section-5.6'>RFC3339
12430 // §5.6</ulink> for a precise definition of valid RFC3339 time offsets
12431 // (the <varname>time-offset</varname> expansion) and ISO 8601 for the
12432 // full list of valid time offsets. See <ulink
12433 // url='http://www.gnu.org/s/libc/manual/html_node/TZ-Variable.html'>The
12434 // GNU C Library manual</ulink> for an explanation of the possible
12435 // values of the <varname>TZ</varname> environment variable.
12437 // You should release the return value by calling g_time_zone_unref()
12438 // when you are done with it.
12439 // RETURNS: the requested timezone
12440 // <identifier>: a timezone identifier
12441 static TimeZone* new_()(char* identifier=null) nothrow {
12442 return g_time_zone_new(identifier);
12445 // Unintrospectable function: new_local() / g_time_zone_new_local()
12446 // VERSION: 2.26
12447 // Creates a #GTimeZone corresponding to local time. The local time
12448 // zone may change between invocations to this function; for example,
12449 // if the system administrator changes it.
12451 // This is equivalent to calling g_time_zone_new() with the value of the
12452 // <varname>TZ</varname> environment variable (including the possibility
12453 // of %NULL).
12455 // You should release the return value by calling g_time_zone_unref()
12456 // when you are done with it.
12457 // RETURNS: the local timezone
12458 static TimeZone* new_local()() nothrow {
12459 return g_time_zone_new_local();
12462 // Unintrospectable function: new_utc() / g_time_zone_new_utc()
12463 // VERSION: 2.26
12464 // Creates a #GTimeZone corresponding to UTC.
12466 // This is equivalent to calling g_time_zone_new() with a value like
12467 // "Z", "UTC", "+00", etc.
12469 // You should release the return value by calling g_time_zone_unref()
12470 // when you are done with it.
12471 // RETURNS: the universal timezone
12472 static TimeZone* new_utc()() nothrow {
12473 return g_time_zone_new_utc();
12477 // Opaque datatype that records a start time.
12478 struct Timer {
12480 // VERSION: 2.4
12481 // Resumes a timer that has previously been stopped with
12482 // g_timer_stop(). g_timer_stop() must be called before using this
12483 // function.
12484 void continue_()() nothrow {
12485 g_timer_continue(&this);
12487 // Destroys a timer, freeing associated resources.
12488 void destroy()() nothrow {
12489 g_timer_destroy(&this);
12492 // If @timer has been started but not stopped, obtains the time since
12493 // the timer was started. If @timer has been stopped, obtains the
12494 // elapsed time between the time it was started and the time it was
12495 // stopped. The return value is the number of seconds elapsed,
12496 // including any fractional part. The @microseconds out parameter is
12497 // essentially useless.
12498 // <microseconds>: return location for the fractional part of seconds elapsed, in microseconds (that is, the total number of microseconds elapsed, modulo 1000000), or %NULL
12499 double elapsed()(c_ulong* microseconds) nothrow {
12500 return g_timer_elapsed(&this, microseconds);
12503 // This function is useless; it's fine to call g_timer_start() on an
12504 // already-started timer to reset the start time, so g_timer_reset()
12505 // serves no purpose.
12506 void reset()() nothrow {
12507 g_timer_reset(&this);
12510 // Marks a start time, so that future calls to g_timer_elapsed() will
12511 // report the time since g_timer_start() was called. g_timer_new()
12512 // automatically marks the start time, so no need to call
12513 // g_timer_start() immediately after creating the timer.
12514 void start()() nothrow {
12515 g_timer_start(&this);
12518 // Marks an end time, so calls to g_timer_elapsed() will return the
12519 // difference between this end time and the start time.
12520 void stop()() nothrow {
12521 g_timer_stop(&this);
12524 // Unintrospectable function: new() / g_timer_new()
12525 // Creates a new timer, and starts timing (i.e. g_timer_start() is
12526 // implicitly called for you).
12527 static Timer* new_()() nothrow {
12528 return g_timer_new();
12533 // The possible types of token returned from each
12534 // g_scanner_get_next_token() call.
12535 enum TokenType {
12536 EOF = 0,
12537 LEFT_PAREN = 40,
12538 RIGHT_PAREN = 41,
12539 LEFT_CURLY = 123,
12540 RIGHT_CURLY = 125,
12541 LEFT_BRACE = 91,
12542 RIGHT_BRACE = 93,
12543 EQUAL_SIGN = 61,
12544 COMMA = 44,
12545 NONE = 256,
12546 ERROR = 257,
12547 CHAR = 258,
12548 BINARY = 259,
12549 OCTAL = 260,
12550 INT = 261,
12551 HEX = 262,
12552 FLOAT = 263,
12553 STRING = 264,
12554 SYMBOL = 265,
12555 IDENTIFIER = 266,
12556 IDENTIFIER_NULL = 267,
12557 COMMENT_SINGLE = 268,
12558 COMMENT_MULTI = 269
12560 // A union holding the value of the token.
12561 union TokenValue {
12562 void* v_symbol;
12563 char* v_identifier;
12564 c_ulong v_binary, v_octal, v_int;
12565 ulong v_int64;
12566 double v_float;
12567 c_ulong v_hex;
12568 char* v_string, v_comment;
12569 ubyte v_char;
12570 uint v_error;
12574 // The type of functions which are used to translate user-visible
12575 // strings, for <option>--help</option> output.
12577 // The returned string is owned by GLib and must not be freed.
12578 // RETURNS: a translation of the string for the current locale.
12579 // <str>: the untranslated string
12580 // <data>: user data specified when installing the function, e.g. in g_option_group_set_translate_func()
12581 extern (C) alias char* function (char* str, void* data) nothrow TranslateFunc;
12584 // Each piece of memory that is pushed onto the stack
12585 // is cast to a <structname>GTrashStack*</structname>.
12586 struct TrashStack {
12587 TrashStack* next;
12590 // Returns the height of a #GTrashStack.
12592 // Note that execution of this function is of O(N) complexity
12593 // where N denotes the number of items on the stack.
12594 // RETURNS: the height of the stack
12595 // <stack_p>: a #GTrashStack
12596 static uint height()(TrashStack** stack_p) nothrow {
12597 return g_trash_stack_height(stack_p);
12600 // Unintrospectable function: peek() / g_trash_stack_peek()
12601 // Returns the element at the top of a #GTrashStack
12602 // which may be %NULL.
12603 // RETURNS: the element at the top of the stack
12604 // <stack_p>: a #GTrashStack
12605 static void* peek()(TrashStack** stack_p) nothrow {
12606 return g_trash_stack_peek(stack_p);
12609 // Unintrospectable function: pop() / g_trash_stack_pop()
12610 // Pops a piece of memory off a #GTrashStack.
12611 // RETURNS: the element at the top of the stack
12612 // <stack_p>: a #GTrashStack
12613 static void* pop()(TrashStack** stack_p) nothrow {
12614 return g_trash_stack_pop(stack_p);
12617 // Pushes a piece of memory onto a #GTrashStack.
12618 // <stack_p>: a #GTrashStack
12619 // <data_p>: the piece of memory to push on the stack
12620 static void push()(TrashStack** stack_p, void* data_p) nothrow {
12621 g_trash_stack_push(stack_p, data_p);
12626 // Specifies which nodes are visited during several of the tree
12627 // functions, including g_node_traverse() and g_node_find().
12628 enum TraverseFlags {
12629 LEAVES = 1,
12630 NON_LEAVES = 2,
12631 ALL = 3,
12632 MASK = 3,
12633 LEAFS = 1,
12634 NON_LEAFS = 2
12637 // Specifies the type of function passed to g_tree_traverse(). It is
12638 // passed the key and value of each node, together with the @user_data
12639 // parameter passed to g_tree_traverse(). If the function returns
12640 // %TRUE, the traversal is stopped.
12641 // <key>: a key of a #GTree node.
12642 // <value>: the value corresponding to the key.
12643 // <data>: user data passed to g_tree_traverse().
12644 extern (C) alias int function (void* key, void* value, void* data) nothrow TraverseFunc;
12647 // Specifies the type of traveral performed by g_tree_traverse(),
12648 // g_node_traverse() and g_node_find().
12649 enum TraverseType {
12650 IN_ORDER = 0,
12651 PRE_ORDER = 1,
12652 POST_ORDER = 2,
12653 LEVEL_ORDER = 3
12656 // The <structname>GTree</structname> struct is an opaque data
12657 // structure representing a <link
12658 // linkend="glib-Balanced-Binary-Trees">Balanced Binary Tree</link>. It
12659 // should be accessed only by using the following functions.
12660 struct Tree {
12662 // Removes all keys and values from the #GTree and decreases its
12663 // reference count by one. If keys and/or values are dynamically
12664 // allocated, you should either free them first or create the #GTree
12665 // using g_tree_new_full(). In the latter case the destroy functions
12666 // you supplied will be called on all keys and values before destroying
12667 // the #GTree.
12668 void destroy()() nothrow {
12669 g_tree_destroy(&this);
12672 // Unintrospectable method: foreach() / g_tree_foreach()
12673 // Calls the given function for each of the key/value pairs in the #GTree.
12674 // The function is passed the key and value of each pair, and the given
12675 // @data parameter. The tree is traversed in sorted order.
12677 // The tree may not be modified while iterating over it (you can't
12678 // add/remove items). To remove all items matching a predicate, you need
12679 // to add each item to a list in your #GTraverseFunc as you walk over
12680 // the tree, then walk the list and remove each item.
12681 // <func>: the function to call for each node visited. If this function returns %TRUE, the traversal is stopped.
12682 // <user_data>: user data to pass to the function.
12683 void foreach_()(TraverseFunc func, void* user_data) nothrow {
12684 g_tree_foreach(&this, func, user_data);
12687 // Gets the height of a #GTree.
12689 // If the #GTree contains no nodes, the height is 0.
12690 // If the #GTree contains only one root node the height is 1.
12691 // If the root node has children the height is 2, etc.
12692 // RETURNS: the height of the #GTree.
12693 int height()() nothrow {
12694 return g_tree_height(&this);
12697 // Inserts a key/value pair into a #GTree. If the given key already exists
12698 // in the #GTree its corresponding value is set to the new value. If you
12699 // supplied a value_destroy_func when creating the #GTree, the old value is
12700 // freed using that function. If you supplied a @key_destroy_func when
12701 // creating the #GTree, the passed key is freed using that function.
12703 // The tree is automatically 'balanced' as new key/value pairs are added,
12704 // so that the distance from the root to every leaf is as small as possible.
12705 // <key>: the key to insert.
12706 // <value>: the value corresponding to the key.
12707 void insert()(void* key, void* value) nothrow {
12708 g_tree_insert(&this, key, value);
12711 // Unintrospectable method: lookup() / g_tree_lookup()
12712 // Gets the value corresponding to the given key. Since a #GTree is
12713 // automatically balanced as key/value pairs are added, key lookup is very
12714 // fast.
12716 // not found.
12717 // RETURNS: the value corresponding to the key, or %NULL if the key was
12718 // <key>: the key to look up.
12719 void* lookup()(const(void)* key) nothrow {
12720 return g_tree_lookup(&this, key);
12723 // Looks up a key in the #GTree, returning the original key and the
12724 // associated value and a #gboolean which is %TRUE if the key was found. This
12725 // is useful if you need to free the memory allocated for the original key,
12726 // for example before calling g_tree_remove().
12727 // RETURNS: %TRUE if the key was found in the #GTree.
12728 // <lookup_key>: the key to look up.
12729 // <orig_key>: returns the original key.
12730 // <value>: returns the value associated with the key.
12731 int lookup_extended()(const(void)* lookup_key, void** orig_key, void** value) nothrow {
12732 return g_tree_lookup_extended(&this, lookup_key, orig_key, value);
12735 // Gets the number of nodes in a #GTree.
12736 // RETURNS: the number of nodes in the #GTree.
12737 int nnodes()() nothrow {
12738 return g_tree_nnodes(&this);
12741 // Unintrospectable method: ref() / g_tree_ref()
12742 // VERSION: 2.22
12743 // Increments the reference count of @tree by one. It is safe to call
12744 // this function from any thread.
12745 // RETURNS: the passed in #GTree.
12746 Tree* ref_()() nothrow {
12747 return g_tree_ref(&this);
12750 // Removes a key/value pair from a #GTree.
12752 // If the #GTree was created using g_tree_new_full(), the key and value
12753 // are freed using the supplied destroy functions, otherwise you have to
12754 // make sure that any dynamically allocated values are freed yourself.
12755 // If the key does not exist in the #GTree, the function does nothing.
12757 // nothing)
12758 // RETURNS: %TRUE if the key was found (prior to 2.8, this function returned
12759 // <key>: the key to remove.
12760 int remove()(const(void)* key) nothrow {
12761 return g_tree_remove(&this, key);
12764 // Inserts a new key and value into a #GTree similar to g_tree_insert().
12765 // The difference is that if the key already exists in the #GTree, it gets
12766 // replaced by the new key. If you supplied a @value_destroy_func when
12767 // creating the #GTree, the old value is freed using that function. If you
12768 // supplied a @key_destroy_func when creating the #GTree, the old key is
12769 // freed using that function.
12771 // The tree is automatically 'balanced' as new key/value pairs are added,
12772 // so that the distance from the root to every leaf is as small as possible.
12773 // <key>: the key to insert.
12774 // <value>: the value corresponding to the key.
12775 void replace()(void* key, void* value) nothrow {
12776 g_tree_replace(&this, key, value);
12779 // Unintrospectable method: search() / g_tree_search()
12780 // Searches a #GTree using @search_func.
12782 // The @search_func is called with a pointer to the key of a key/value
12783 // pair in the tree, and the passed in @user_data. If @search_func returns
12784 // 0 for a key/value pair, then the corresponding value is returned as
12785 // the result of g_tree_search(). If @search_func returns -1, searching
12786 // will proceed among the key/value pairs that have a smaller key; if
12787 // @search_func returns 1, searching will proceed among the key/value
12788 // pairs that have a larger key.
12790 // the key was not found.
12791 // RETURNS: the value corresponding to the found key, or %NULL if
12792 // <search_func>: a function used to search the #GTree
12793 // <user_data>: the data passed as the second argument to @search_func
12794 void* search()(CompareFunc search_func, const(void)* user_data) nothrow {
12795 return g_tree_search(&this, search_func, user_data);
12798 // Removes a key and its associated value from a #GTree without calling
12799 // the key and value destroy functions.
12801 // If the key does not exist in the #GTree, the function does nothing.
12803 // nothing)
12804 // RETURNS: %TRUE if the key was found (prior to 2.8, this function returned
12805 // <key>: the key to remove.
12806 int steal()(const(void)* key) nothrow {
12807 return g_tree_steal(&this, key);
12810 // Unintrospectable method: traverse() / g_tree_traverse()
12811 // Calls the given function for each node in the #GTree.
12813 // Deprecated:2.2: The order of a balanced tree is somewhat arbitrary. If you
12814 // just want to visit all nodes in sorted order, use g_tree_foreach()
12815 // instead. If you really need to visit nodes in a different order, consider
12816 // using an <link linkend="glib-N-ary-Trees">N-ary Tree</link>.
12817 // <traverse_func>: the function to call for each node visited. If this function returns %TRUE, the traversal is stopped.
12818 // <traverse_type>: the order in which nodes are visited, one of %G_IN_ORDER, %G_PRE_ORDER and %G_POST_ORDER.
12819 // <user_data>: user data to pass to the function.
12820 void traverse()(TraverseFunc traverse_func, TraverseType traverse_type, void* user_data) nothrow {
12821 g_tree_traverse(&this, traverse_func, traverse_type, user_data);
12824 // VERSION: 2.22
12825 // Decrements the reference count of @tree by one. If the reference count
12826 // drops to 0, all keys and values will be destroyed (if destroy
12827 // functions were specified) and all memory allocated by @tree will be
12828 // released.
12830 // It is safe to call this function from any thread.
12831 void unref()() nothrow {
12832 g_tree_unref(&this);
12835 // Unintrospectable function: new() / g_tree_new()
12836 // Creates a new #GTree.
12837 // RETURNS: a new #GTree.
12838 // <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.
12839 static Tree* new_()(CompareFunc key_compare_func) nothrow {
12840 return g_tree_new(key_compare_func);
12843 // Unintrospectable function: new_full() / g_tree_new_full()
12844 // Creates a new #GTree like g_tree_new() and allows to specify functions
12845 // to free the memory allocated for the key and value that get called when
12846 // removing the entry from the #GTree.
12847 // RETURNS: a new #GTree.
12848 // <key_compare_func>: qsort()-style comparison function.
12849 // <key_compare_data>: data to pass to comparison function.
12850 // <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.
12851 // <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.
12852 static Tree* new_full()(CompareDataFunc key_compare_func, void* key_compare_data, DestroyNotify key_destroy_func, DestroyNotify value_destroy_func) nothrow {
12853 return g_tree_new_full(key_compare_func, key_compare_data, key_destroy_func, value_destroy_func);
12856 // Unintrospectable function: new_with_data() / g_tree_new_with_data()
12857 // Creates a new #GTree with a comparison function that accepts user data.
12858 // See g_tree_new() for more details.
12859 // RETURNS: a new #GTree.
12860 // <key_compare_func>: qsort()-style comparison function.
12861 // <key_compare_data>: data to pass to comparison function.
12862 static Tree* new_with_data()(CompareDataFunc key_compare_func, void* key_compare_data) nothrow {
12863 return g_tree_new_with_data(key_compare_func, key_compare_data);
12867 enum int UNICHAR_MAX_DECOMPOSITION_LENGTH = 18;
12868 enum URI_RESERVED_CHARS_GENERIC_DELIMITERS = ":/?#[]@";
12869 enum URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS = "!$&'()*+,;=";
12870 enum int USEC_PER_SEC = 1000000;
12872 // These are the possible line break classifications.
12874 // The five Hangul types were added in Unicode 4.1, so, has been
12875 // introduced in GLib 2.10. Note that new types may be added in the future.
12876 // Applications should be ready to handle unknown values.
12877 // They may be regarded as %G_UNICODE_BREAK_UNKNOWN.
12879 // See <ulink url="http://www.unicode.org/unicode/reports/tr14/">http://www.unicode.org/unicode/reports/tr14/</ulink>.
12880 enum UnicodeBreakType {
12881 MANDATORY = 0,
12882 CARRIAGE_RETURN = 1,
12883 LINE_FEED = 2,
12884 COMBINING_MARK = 3,
12885 SURROGATE = 4,
12886 ZERO_WIDTH_SPACE = 5,
12887 INSEPARABLE = 6,
12888 NON_BREAKING_GLUE = 7,
12889 CONTINGENT = 8,
12890 SPACE = 9,
12891 AFTER = 10,
12892 BEFORE = 11,
12893 BEFORE_AND_AFTER = 12,
12894 HYPHEN = 13,
12895 NON_STARTER = 14,
12896 OPEN_PUNCTUATION = 15,
12897 CLOSE_PUNCTUATION = 16,
12898 QUOTATION = 17,
12899 EXCLAMATION = 18,
12900 IDEOGRAPHIC = 19,
12901 NUMERIC = 20,
12902 INFIX_SEPARATOR = 21,
12903 SYMBOL = 22,
12904 ALPHABETIC = 23,
12905 PREFIX = 24,
12906 POSTFIX = 25,
12907 COMPLEX_CONTEXT = 26,
12908 AMBIGUOUS = 27,
12909 UNKNOWN = 28,
12910 NEXT_LINE = 29,
12911 WORD_JOINER = 30,
12912 HANGUL_L_JAMO = 31,
12913 HANGUL_V_JAMO = 32,
12914 HANGUL_T_JAMO = 33,
12915 HANGUL_LV_SYLLABLE = 34,
12916 HANGUL_LVT_SYLLABLE = 35,
12917 CLOSE_PARANTHESIS = 36
12920 // The #GUnicodeScript enumeration identifies different writing
12921 // systems. The values correspond to the names as defined in the
12922 // Unicode standard. The enumeration has been added in GLib 2.14,
12923 // and is interchangeable with #PangoScript.
12925 // Note that new types may be added in the future. Applications
12926 // should be ready to handle unknown values.
12927 // See <ulink
12928 // url="http://www.unicode.org/reports/tr24/">Unicode Standard Annex
12929 // #24: Script names</ulink>.
12930 enum UnicodeScript {
12931 INVALID_CODE = -1,
12932 COMMON = 0,
12933 INHERITED = 1,
12934 ARABIC = 2,
12935 ARMENIAN = 3,
12936 BENGALI = 4,
12937 BOPOMOFO = 5,
12938 CHEROKEE = 6,
12939 COPTIC = 7,
12940 CYRILLIC = 8,
12941 DESERET = 9,
12942 DEVANAGARI = 10,
12943 ETHIOPIC = 11,
12944 GEORGIAN = 12,
12945 GOTHIC = 13,
12946 GREEK = 14,
12947 GUJARATI = 15,
12948 GURMUKHI = 16,
12949 HAN = 17,
12950 HANGUL = 18,
12951 HEBREW = 19,
12952 HIRAGANA = 20,
12953 KANNADA = 21,
12954 KATAKANA = 22,
12955 KHMER = 23,
12956 LAO = 24,
12957 LATIN = 25,
12958 MALAYALAM = 26,
12959 MONGOLIAN = 27,
12960 MYANMAR = 28,
12961 OGHAM = 29,
12962 OLD_ITALIC = 30,
12963 ORIYA = 31,
12964 RUNIC = 32,
12965 SINHALA = 33,
12966 SYRIAC = 34,
12967 TAMIL = 35,
12968 TELUGU = 36,
12969 THAANA = 37,
12970 THAI = 38,
12971 TIBETAN = 39,
12972 CANADIAN_ABORIGINAL = 40,
12973 YI = 41,
12974 TAGALOG = 42,
12975 HANUNOO = 43,
12976 BUHID = 44,
12977 TAGBANWA = 45,
12978 BRAILLE = 46,
12979 CYPRIOT = 47,
12980 LIMBU = 48,
12981 OSMANYA = 49,
12982 SHAVIAN = 50,
12983 LINEAR_B = 51,
12984 TAI_LE = 52,
12985 UGARITIC = 53,
12986 NEW_TAI_LUE = 54,
12987 BUGINESE = 55,
12988 GLAGOLITIC = 56,
12989 TIFINAGH = 57,
12990 SYLOTI_NAGRI = 58,
12991 OLD_PERSIAN = 59,
12992 KHAROSHTHI = 60,
12993 UNKNOWN = 61,
12994 BALINESE = 62,
12995 CUNEIFORM = 63,
12996 PHOENICIAN = 64,
12997 PHAGS_PA = 65,
12998 NKO = 66,
12999 KAYAH_LI = 67,
13000 LEPCHA = 68,
13001 REJANG = 69,
13002 SUNDANESE = 70,
13003 SAURASHTRA = 71,
13004 CHAM = 72,
13005 OL_CHIKI = 73,
13006 VAI = 74,
13007 CARIAN = 75,
13008 LYCIAN = 76,
13009 LYDIAN = 77,
13010 AVESTAN = 78,
13011 BAMUM = 79,
13012 EGYPTIAN_HIEROGLYPHS = 80,
13013 IMPERIAL_ARAMAIC = 81,
13014 INSCRIPTIONAL_PAHLAVI = 82,
13015 INSCRIPTIONAL_PARTHIAN = 83,
13016 JAVANESE = 84,
13017 KAITHI = 85,
13018 LISU = 86,
13019 MEETEI_MAYEK = 87,
13020 OLD_SOUTH_ARABIAN = 88,
13021 OLD_TURKIC = 89,
13022 SAMARITAN = 90,
13023 TAI_THAM = 91,
13024 TAI_VIET = 92,
13025 BATAK = 93,
13026 BRAHMI = 94,
13027 MANDAIC = 95
13030 // These are the possible character classifications from the
13031 // Unicode specification.
13032 // See <ulink url="http://www.unicode.org/Public/UNIDATA/UnicodeData.html">http://www.unicode.org/Public/UNIDATA/UnicodeData.html</ulink>.
13033 enum UnicodeType {
13034 CONTROL = 0,
13035 FORMAT = 1,
13036 UNASSIGNED = 2,
13037 PRIVATE_USE = 3,
13038 SURROGATE = 4,
13039 LOWERCASE_LETTER = 5,
13040 MODIFIER_LETTER = 6,
13041 OTHER_LETTER = 7,
13042 TITLECASE_LETTER = 8,
13043 UPPERCASE_LETTER = 9,
13044 SPACING_MARK = 10,
13045 ENCLOSING_MARK = 11,
13046 NON_SPACING_MARK = 12,
13047 DECIMAL_NUMBER = 13,
13048 LETTER_NUMBER = 14,
13049 OTHER_NUMBER = 15,
13050 CONNECT_PUNCTUATION = 16,
13051 DASH_PUNCTUATION = 17,
13052 CLOSE_PUNCTUATION = 18,
13053 FINAL_PUNCTUATION = 19,
13054 INITIAL_PUNCTUATION = 20,
13055 OTHER_PUNCTUATION = 21,
13056 OPEN_PUNCTUATION = 22,
13057 CURRENCY_SYMBOL = 23,
13058 MODIFIER_SYMBOL = 24,
13059 MATH_SYMBOL = 25,
13060 OTHER_SYMBOL = 26,
13061 LINE_SEPARATOR = 27,
13062 PARAGRAPH_SEPARATOR = 28,
13063 SPACE_SEPARATOR = 29
13066 // These are logical ids for special directories which are defined
13067 // depending on the platform used. You should use g_get_user_special_dir()
13068 // to retrieve the full path associated to the logical id.
13070 // The #GUserDirectory enumeration can be extended at later date. Not
13071 // every platform has a directory for every logical id in this
13072 // enumeration.
13073 enum UserDirectory /* Version 2.14 */ {
13074 DIRECTORY_DESKTOP = 0,
13075 DIRECTORY_DOCUMENTS = 1,
13076 DIRECTORY_DOWNLOAD = 2,
13077 DIRECTORY_MUSIC = 3,
13078 DIRECTORY_PICTURES = 4,
13079 DIRECTORY_PUBLIC_SHARE = 5,
13080 DIRECTORY_TEMPLATES = 6,
13081 DIRECTORY_VIDEOS = 7,
13082 N_DIRECTORIES = 8
13085 // #GVariant is a variant datatype; it stores a value along with
13086 // information about the type of that value. The range of possible
13087 // values is determined by the type. The type system used by #GVariant
13088 // is #GVariantType.
13090 // #GVariant instances always have a type and a value (which are given
13091 // at construction time). The type and value of a #GVariant instance
13092 // can never change other than by the #GVariant itself being
13093 // destroyed. A #GVariant cannot contain a pointer.
13095 // #GVariant is reference counted using g_variant_ref() and
13096 // g_variant_unref(). #GVariant also has floating reference counts --
13097 // see g_variant_ref_sink().
13099 // #GVariant is completely threadsafe. A #GVariant instance can be
13100 // concurrently accessed in any way from any number of threads without
13101 // problems.
13103 // #GVariant is heavily optimised for dealing with data in serialised
13104 // form. It works particularly well with data located in memory-mapped
13105 // files. It can perform nearly all deserialisation operations in a
13106 // small constant time, usually touching only a single memory page.
13107 // Serialised #GVariant data can also be sent over the network.
13109 // #GVariant is largely compatible with D-Bus. Almost all types of
13110 // #GVariant instances can be sent over D-Bus. See #GVariantType for
13111 // exceptions. (However, #GVariant's serialisation format is not the same
13112 // as the serialisation format of a D-Bus message body: use #GDBusMessage,
13113 // in the gio library, for those.)
13115 // For space-efficiency, the #GVariant serialisation format does not
13116 // automatically include the variant's type or endianness, which must
13117 // either be implied from context (such as knowledge that a particular
13118 // file format always contains a little-endian %G_VARIANT_TYPE_VARIANT)
13119 // or supplied out-of-band (for instance, a type and/or endianness
13120 // indicator could be placed at the beginning of a file, network message
13121 // or network stream).
13123 // A #GVariant's size is limited mainly by any lower level operating
13124 // system constraints, such as the number of bits in #gsize. For
13125 // example, it is reasonable to have a 2GB file mapped into memory
13126 // with #GMappedFile, and call g_variant_new_from_data() on it.
13128 // For convenience to C programmers, #GVariant features powerful
13129 // varargs-based value construction and destruction. This feature is
13130 // designed to be embedded in other libraries.
13132 // There is a Python-inspired text language for describing #GVariant
13133 // values. #GVariant includes a printer for this language and a parser
13134 // with type inferencing.
13136 // <refsect2>
13137 // <title>Memory Use</title>
13138 // <para>
13139 // #GVariant tries to be quite efficient with respect to memory use.
13140 // This section gives a rough idea of how much memory is used by the
13141 // current implementation. The information here is subject to change
13142 // in the future.
13143 // </para>
13144 // <para>
13145 // The memory allocated by #GVariant can be grouped into 4 broad
13146 // purposes: memory for serialised data, memory for the type
13147 // information cache, buffer management memory and memory for the
13148 // #GVariant structure itself.
13149 // </para>
13150 // <refsect3 id="gvariant-serialised-data-memory">
13151 // <title>Serialised Data Memory</title>
13152 // <para>
13153 // This is the memory that is used for storing GVariant data in
13154 // serialised form. This is what would be sent over the network or
13155 // what would end up on disk.
13156 // </para>
13157 // <para>
13158 // The amount of memory required to store a boolean is 1 byte. 16,
13159 // 32 and 64 bit integers and double precision floating point numbers
13160 // use their "natural" size. Strings (including object path and
13161 // signature strings) are stored with a nul terminator, and as such
13162 // use the length of the string plus 1 byte.
13163 // </para>
13164 // <para>
13165 // Maybe types use no space at all to represent the null value and
13166 // use the same amount of space (sometimes plus one byte) as the
13167 // equivalent non-maybe-typed value to represent the non-null case.
13168 // </para>
13169 // <para>
13170 // Arrays use the amount of space required to store each of their
13171 // members, concatenated. Additionally, if the items stored in an
13172 // array are not of a fixed-size (ie: strings, other arrays, etc)
13173 // then an additional framing offset is stored for each item. The
13174 // size of this offset is either 1, 2 or 4 bytes depending on the
13175 // overall size of the container. Additionally, extra padding bytes
13176 // are added as required for alignment of child values.
13177 // </para>
13178 // <para>
13179 // Tuples (including dictionary entries) use the amount of space
13180 // required to store each of their members, concatenated, plus one
13181 // framing offset (as per arrays) for each non-fixed-sized item in
13182 // the tuple, except for the last one. Additionally, extra padding
13183 // bytes are added as required for alignment of child values.
13184 // </para>
13185 // <para>
13186 // Variants use the same amount of space as the item inside of the
13187 // variant, plus 1 byte, plus the length of the type string for the
13188 // item inside the variant.
13189 // </para>
13190 // <para>
13191 // As an example, consider a dictionary mapping strings to variants.
13192 // In the case that the dictionary is empty, 0 bytes are required for
13193 // the serialisation.
13194 // </para>
13195 // <para>
13196 // If we add an item "width" that maps to the int32 value of 500 then
13197 // we will use 4 byte to store the int32 (so 6 for the variant
13198 // containing it) and 6 bytes for the string. The variant must be
13199 // aligned to 8 after the 6 bytes of the string, so that's 2 extra
13200 // bytes. 6 (string) + 2 (padding) + 6 (variant) is 14 bytes used
13201 // for the dictionary entry. An additional 1 byte is added to the
13202 // array as a framing offset making a total of 15 bytes.
13203 // </para>
13204 // <para>
13205 // If we add another entry, "title" that maps to a nullable string
13206 // that happens to have a value of null, then we use 0 bytes for the
13207 // null value (and 3 bytes for the variant to contain it along with
13208 // its type string) plus 6 bytes for the string. Again, we need 2
13209 // padding bytes. That makes a total of 6 + 2 + 3 = 11 bytes.
13210 // </para>
13211 // <para>
13212 // We now require extra padding between the two items in the array.
13213 // After the 14 bytes of the first item, that's 2 bytes required. We
13214 // now require 2 framing offsets for an extra two bytes. 14 + 2 + 11
13215 // + 2 = 29 bytes to encode the entire two-item dictionary.
13216 // </para>
13217 // </refsect3>
13218 // <refsect3>
13219 // <title>Type Information Cache</title>
13220 // <para>
13221 // For each GVariant type that currently exists in the program a type
13222 // information structure is kept in the type information cache. The
13223 // type information structure is required for rapid deserialisation.
13224 // </para>
13225 // <para>
13226 // Continuing with the above example, if a #GVariant exists with the
13227 // type "a{sv}" then a type information struct will exist for
13228 // "a{sv}", "{sv}", "s", and "v". Multiple uses of the same type
13229 // will share the same type information. Additionally, all
13230 // single-digit types are stored in read-only static memory and do
13231 // not contribute to the writable memory footprint of a program using
13232 // #GVariant.
13233 // </para>
13234 // <para>
13235 // Aside from the type information structures stored in read-only
13236 // memory, there are two forms of type information. One is used for
13237 // container types where there is a single element type: arrays and
13238 // maybe types. The other is used for container types where there
13239 // are multiple element types: tuples and dictionary entries.
13240 // </para>
13241 // <para>
13242 // Array type info structures are 6 * sizeof (void *), plus the
13243 // memory required to store the type string itself. This means that
13244 // on 32bit systems, the cache entry for "a{sv}" would require 30
13245 // bytes of memory (plus malloc overhead).
13246 // </para>
13247 // <para>
13248 // Tuple type info structures are 6 * sizeof (void *), plus 4 *
13249 // sizeof (void *) for each item in the tuple, plus the memory
13250 // required to store the type string itself. A 2-item tuple, for
13251 // example, would have a type information structure that consumed
13252 // writable memory in the size of 14 * sizeof (void *) (plus type
13253 // string) This means that on 32bit systems, the cache entry for
13254 // "{sv}" would require 61 bytes of memory (plus malloc overhead).
13255 // </para>
13256 // <para>
13257 // This means that in total, for our "a{sv}" example, 91 bytes of
13258 // type information would be allocated.
13259 // </para>
13260 // <para>
13261 // The type information cache, additionally, uses a #GHashTable to
13262 // store and lookup the cached items and stores a pointer to this
13263 // hash table in static storage. The hash table is freed when there
13264 // are zero items in the type cache.
13265 // </para>
13266 // <para>
13267 // Although these sizes may seem large it is important to remember
13268 // that a program will probably only have a very small number of
13269 // different types of values in it and that only one type information
13270 // structure is required for many different values of the same type.
13271 // </para>
13272 // </refsect3>
13273 // <refsect3>
13274 // <title>Buffer Management Memory</title>
13275 // <para>
13276 // #GVariant uses an internal buffer management structure to deal
13277 // with the various different possible sources of serialised data
13278 // that it uses. The buffer is responsible for ensuring that the
13279 // correct call is made when the data is no longer in use by
13280 // #GVariant. This may involve a g_free() or a g_slice_free() or
13281 // even g_mapped_file_unref().
13282 // </para>
13283 // <para>
13284 // One buffer management structure is used for each chunk of
13285 // serialised data. The size of the buffer management structure is 4
13286 // * (void *). On 32bit systems, that's 16 bytes.
13287 // </para>
13288 // </refsect3>
13289 // <refsect3>
13290 // <title>GVariant structure</title>
13291 // <para>
13292 // The size of a #GVariant structure is 6 * (void *). On 32 bit
13293 // systems, that's 24 bytes.
13294 // </para>
13295 // <para>
13296 // #GVariant structures only exist if they are explicitly created
13297 // with API calls. For example, if a #GVariant is constructed out of
13298 // serialised data for the example given above (with the dictionary)
13299 // then although there are 9 individual values that comprise the
13300 // entire dictionary (two keys, two values, two variants containing
13301 // the values, two dictionary entries, plus the dictionary itself),
13302 // only 1 #GVariant instance exists -- the one referring to the
13303 // dictionary.
13304 // </para>
13305 // <para>
13306 // If calls are made to start accessing the other values then
13307 // #GVariant instances will exist for those values only for as long
13308 // as they are in use (ie: until you call g_variant_unref()). The
13309 // type information is shared. The serialised data and the buffer
13310 // management structure for that serialised data is shared by the
13311 // child.
13312 // </para>
13313 // </refsect3>
13314 // <refsect3>
13315 // <title>Summary</title>
13316 // <para>
13317 // To put the entire example together, for our dictionary mapping
13318 // strings to variants (with two entries, as given above), we are
13319 // using 91 bytes of memory for type information, 29 byes of memory
13320 // for the serialised data, 16 bytes for buffer management and 24
13321 // bytes for the #GVariant instance, or a total of 160 bytes, plus
13322 // malloc overhead. If we were to use g_variant_get_child_value() to
13323 // access the two dictionary entries, we would use an additional 48
13324 // bytes. If we were to have other dictionaries of the same type, we
13325 // would use more memory for the serialised data and buffer
13326 // management for those dictionaries, but the type information would
13327 // be shared.
13328 // </para>
13329 // </refsect3>
13330 // </refsect2>
13331 struct Variant /* Version 2.24 */ {
13333 // Unintrospectable constructor: new() / g_variant_new()
13334 // VERSION: 2.24
13335 // Creates a new #GVariant instance.
13337 // Think of this function as an analogue to g_strdup_printf().
13339 // The type of the created instance and the arguments that are
13340 // expected by this function are determined by @format_string. See the
13341 // section on <link linkend='gvariant-format-strings'>GVariant Format
13342 // Strings</link>. Please note that the syntax of the format string is
13343 // very likely to be extended in the future.
13345 // The first character of the format string must not be '*' '?' '@' or
13346 // 'r'; in essence, a new #GVariant must always be constructed by this
13347 // function (and not merely passed through it unmodified).
13348 // RETURNS: a new floating #GVariant instance
13349 // <format_string>: a #GVariant format string
13350 alias g_variant_new new_; // Variadic
13352 // VERSION: 2.24
13353 // Creates a new #GVariant array from @children.
13355 // @child_type must be non-%NULL if @n_children is zero. Otherwise, the
13356 // child type is determined by inspecting the first element of the
13357 // @children array. If @child_type is non-%NULL then it must be a
13358 // definite type.
13360 // The items of the array are taken from the @children array. No entry
13361 // in the @children array may be %NULL.
13363 // All items in the array must have the same type, which must be the
13364 // same as @child_type, if given.
13366 // If the @children are floating references (see g_variant_ref_sink()), the
13367 // new instance takes ownership of them as if via g_variant_ref_sink().
13368 // RETURNS: a floating reference to a new #GVariant array
13369 // <child_type>: the element type of the new array
13370 // <children>: an array of #GVariant pointers, the children
13371 // <n_children>: the length of @children
13372 static Variant* new_array()(VariantType* child_type, Variant** children, size_t n_children) nothrow {
13373 return g_variant_new_array(child_type, children, n_children);
13375 alias new_array!() opCall;
13377 // VERSION: 2.24
13378 // Creates a new boolean #GVariant instance -- either %TRUE or %FALSE.
13379 // RETURNS: a floating reference to a new boolean #GVariant instance
13380 // <value>: a #gboolean value
13381 static Variant* new_boolean()(int value) nothrow {
13382 return g_variant_new_boolean(value);
13384 alias new_boolean!() opCall;
13386 // VERSION: 2.24
13387 // Creates a new byte #GVariant instance.
13388 // RETURNS: a floating reference to a new byte #GVariant instance
13389 // <value>: a #guint8 value
13390 static Variant* new_byte()(ubyte value) nothrow {
13391 return g_variant_new_byte(value);
13393 alias new_byte!() opCall;
13395 // VERSION: 2.26
13396 // Creates an array-of-bytes #GVariant with the contents of @string.
13397 // This function is just like g_variant_new_string() except that the
13398 // string need not be valid utf8.
13400 // The nul terminator character at the end of the string is stored in
13401 // the array.
13402 // RETURNS: a floating reference to a new bytestring #GVariant instance
13403 // <string>: a normal nul-terminated string in no particular encoding
13404 static Variant* new_bytestring()(ubyte* string_) nothrow {
13405 return g_variant_new_bytestring(string_);
13407 alias new_bytestring!() opCall;
13409 // VERSION: 2.26
13410 // Constructs an array of bytestring #GVariant from the given array of
13411 // strings.
13413 // If @length is -1 then @strv is %NULL-terminated.
13414 // RETURNS: a new floating #GVariant instance
13415 // <strv>: an array of strings
13416 // <length>: the length of @strv, or -1
13417 static Variant* new_bytestring_array()(char** strv, ssize_t length) nothrow {
13418 return g_variant_new_bytestring_array(strv, length);
13420 alias new_bytestring_array!() opCall;
13422 // VERSION: 2.24
13423 // Creates a new dictionary entry #GVariant. @key and @value must be
13424 // non-%NULL. @key must be a value of a basic type (ie: not a container).
13426 // If the @key or @value are floating references (see g_variant_ref_sink()),
13427 // the new instance takes ownership of them as if via g_variant_ref_sink().
13428 // RETURNS: a floating reference to a new dictionary entry #GVariant
13429 // <key>: a basic #GVariant, the key
13430 // <value>: a #GVariant, the value
13431 static Variant* new_dict_entry()(Variant* key, Variant* value) nothrow {
13432 return g_variant_new_dict_entry(key, value);
13434 alias new_dict_entry!() opCall;
13436 // VERSION: 2.24
13437 // Creates a new double #GVariant instance.
13438 // RETURNS: a floating reference to a new double #GVariant instance
13439 // <value>: a #gdouble floating point value
13440 static Variant* new_double()(double value) nothrow {
13441 return g_variant_new_double(value);
13443 alias new_double!() opCall;
13445 // VERSION: 2.32
13446 // Provides access to the serialised data for an array of fixed-sized
13447 // items.
13449 // @value must be an array with fixed-sized elements. Numeric types are
13450 // fixed-size as are tuples containing only other fixed-sized types.
13452 // @element_size must be the size of a single element in the array. For
13453 // example, if calling this function for an array of 32 bit integers,
13454 // you might say <code>sizeof (gint32)</code>. This value isn't used
13455 // except for the purpose of a double-check that the form of the
13456 // serialised data matches the caller's expectation.
13458 // @n_elements, which must be non-%NULL is set equal to the number of
13459 // items in the array.
13460 // RETURNS: a floating reference to a new array #GVariant instance
13461 // <element_type>: the #GVariantType of each element
13462 // <elements>: a pointer to the fixed array of contiguous elements
13463 // <n_elements>: the number of elements
13464 // <element_size>: the size of each element
13465 static Variant* new_fixed_array()(VariantType* element_type, const(void)* elements, size_t n_elements, size_t element_size) nothrow {
13466 return g_variant_new_fixed_array(element_type, elements, n_elements, element_size);
13468 alias new_fixed_array!() opCall;
13470 // VERSION: 2.24
13471 // Creates a new #GVariant instance from serialised data.
13473 // @type is the type of #GVariant instance that will be constructed.
13474 // The interpretation of @data depends on knowing the type.
13476 // @data is not modified by this function and must remain valid with an
13477 // unchanging value until such a time as @notify is called with
13478 // @user_data. If the contents of @data change before that time then
13479 // the result is undefined.
13481 // If @data is trusted to be serialised data in normal form then
13482 // @trusted should be %TRUE. This applies to serialised data created
13483 // within this process or read from a trusted location on the disk (such
13484 // as a file installed in /usr/lib alongside your application). You
13485 // should set trusted to %FALSE if @data is read from the network, a
13486 // file in the user's home directory, etc.
13488 // If @data was not stored in this machine's native endianness, any multi-byte
13489 // numeric values in the returned variant will also be in non-native
13490 // endianness. g_variant_byteswap() can be used to recover the original values.
13492 // @notify will be called with @user_data when @data is no longer
13493 // needed. The exact time of this call is unspecified and might even be
13494 // before this function returns.
13495 // RETURNS: a new floating #GVariant of type @type
13496 // <type>: a definite #GVariantType
13497 // <data>: the serialised data
13498 // <size>: the size of @data
13499 // <trusted>: %TRUE if @data is definitely in normal form
13500 // <notify>: function to call when @data is no longer needed
13501 // <user_data>: data for @notify
13502 static Variant* new_from_data()(VariantType* type, const(ubyte)* data, size_t size, int trusted, DestroyNotify notify, void* user_data) nothrow {
13503 return g_variant_new_from_data(type, data, size, trusted, notify, user_data);
13505 alias new_from_data!() opCall;
13507 // VERSION: 2.24
13508 // Creates a new handle #GVariant instance.
13510 // By convention, handles are indexes into an array of file descriptors
13511 // that are sent alongside a D-Bus message. If you're not interacting
13512 // with D-Bus, you probably don't need them.
13513 // RETURNS: a floating reference to a new handle #GVariant instance
13514 // <value>: a #gint32 value
13515 static Variant* new_handle()(int value) nothrow {
13516 return g_variant_new_handle(value);
13518 alias new_handle!() opCall;
13520 // VERSION: 2.24
13521 // Creates a new int16 #GVariant instance.
13522 // RETURNS: a floating reference to a new int16 #GVariant instance
13523 // <value>: a #gint16 value
13524 static Variant* new_int16()(short value) nothrow {
13525 return g_variant_new_int16(value);
13527 alias new_int16!() opCall;
13529 // VERSION: 2.24
13530 // Creates a new int32 #GVariant instance.
13531 // RETURNS: a floating reference to a new int32 #GVariant instance
13532 // <value>: a #gint32 value
13533 static Variant* new_int32()(int value) nothrow {
13534 return g_variant_new_int32(value);
13536 alias new_int32!() opCall;
13538 // VERSION: 2.24
13539 // Creates a new int64 #GVariant instance.
13540 // RETURNS: a floating reference to a new int64 #GVariant instance
13541 // <value>: a #gint64 value
13542 static Variant* new_int64()(long value) nothrow {
13543 return g_variant_new_int64(value);
13545 alias new_int64!() opCall;
13547 // VERSION: 2.24
13548 // Depending on if @child is %NULL, either wraps @child inside of a
13549 // maybe container or creates a Nothing instance for the given @type.
13551 // At least one of @child_type and @child must be non-%NULL.
13552 // If @child_type is non-%NULL then it must be a definite type.
13553 // If they are both non-%NULL then @child_type must be the type
13554 // of @child.
13556 // If @child is a floating reference (see g_variant_ref_sink()), the new
13557 // instance takes ownership of @child.
13558 // RETURNS: a floating reference to a new #GVariant maybe instance
13559 // <child_type>: the #GVariantType of the child, or %NULL
13560 // <child>: the child value, or %NULL
13561 static Variant* new_maybe()(VariantType* child_type=null, Variant* child=null) nothrow {
13562 return g_variant_new_maybe(child_type, child);
13564 alias new_maybe!() opCall;
13566 // VERSION: 2.24
13567 // Creates a D-Bus object path #GVariant with the contents of @string.
13568 // @string must be a valid D-Bus object path. Use
13569 // g_variant_is_object_path() if you're not sure.
13570 // RETURNS: a floating reference to a new object path #GVariant instance
13571 // <object_path>: a normal C nul-terminated string
13572 static Variant* new_object_path()(char* object_path) nothrow {
13573 return g_variant_new_object_path(object_path);
13575 alias new_object_path!() opCall;
13577 // VERSION: 2.30
13578 // Constructs an array of object paths #GVariant from the given array of
13579 // strings.
13581 // Each string must be a valid #GVariant object path; see
13582 // g_variant_is_object_path().
13584 // If @length is -1 then @strv is %NULL-terminated.
13585 // RETURNS: a new floating #GVariant instance
13586 // <strv>: an array of strings
13587 // <length>: the length of @strv, or -1
13588 static Variant* new_objv()(char** strv, ssize_t length) nothrow {
13589 return g_variant_new_objv(strv, length);
13591 alias new_objv!() opCall;
13593 // Unintrospectable constructor: new_parsed() / g_variant_new_parsed()
13594 // Parses @format and returns the result.
13596 // point that a value may appear in the text, a '%' character followed
13597 // by a GVariant format string (as per g_variant_new()) may appear. In
13598 // that case, the same arguments are collected from the argument list as
13599 // g_variant_new() would have collected.
13601 // Consider this simple example:
13603 // <informalexample><programlisting>
13604 // g_variant_new_parsed ("[('one', 1), ('two', %i), (%s, 3)]", 2, "three");
13605 // </programlisting></informalexample>
13607 // In the example, the variable argument parameters are collected and
13608 // filled in as if they were part of the original string to produce the
13609 // result of <code>[('one', 1), ('two', 2), ('three', 3)]</code>.
13611 // This function is intended only to be used with @format as a string
13612 // literal. Any parse error is fatal to the calling process. If you
13613 // want to parse data from untrusted sources, use g_variant_parse().
13615 // You may not use this function to return, unmodified, a single
13616 // #GVariant pointer from the argument list. ie: @format may not solely
13617 // be anything along the lines of "%*", "%?", "\%r", or anything starting
13618 // with "%@".
13619 // RETURNS: a new floating #GVariant instance
13620 // <format>: a text format #GVariant
13621 alias g_variant_new_parsed new_parsed; // Variadic
13623 // Unintrospectable constructor: new_parsed_va() / g_variant_new_parsed_va()
13624 // Parses @format and returns the result.
13626 // This is the version of g_variant_new_parsed() intended to be used
13627 // from libraries.
13629 // The return value will be floating if it was a newly created GVariant
13630 // instance. In the case that @format simply specified the collection
13631 // of a #GVariant pointer (eg: @format was "%*") then the collected
13632 // #GVariant pointer will be returned unmodified, without adding any
13633 // additional references.
13635 // In order to behave correctly in all cases it is necessary for the
13636 // calling function to g_variant_ref_sink() the return result before
13637 // returning control to the user that originally provided the pointer.
13638 // At this point, the caller will have their own full reference to the
13639 // result. This can also be done by adding the result to a container,
13640 // or by passing it to another g_variant_new() call.
13641 // RETURNS: a new, usually floating, #GVariant
13642 // <format>: a text format #GVariant
13643 // <app>: a pointer to a #va_list
13644 static Variant* /*new*/ new_parsed_va()(char* format, va_list* app) nothrow {
13645 return g_variant_new_parsed_va(format, app);
13647 alias new_parsed_va!() opCall;
13649 // VERSION: 2.24
13650 // Creates a D-Bus type signature #GVariant with the contents of
13651 // @string. @string must be a valid D-Bus type signature. Use
13652 // g_variant_is_signature() if you're not sure.
13653 // RETURNS: a floating reference to a new signature #GVariant instance
13654 // <signature>: a normal C nul-terminated string
13655 static Variant* new_signature()(char* signature) nothrow {
13656 return g_variant_new_signature(signature);
13658 alias new_signature!() opCall;
13660 // VERSION: 2.24
13661 // Creates a string #GVariant with the contents of @string.
13663 // @string must be valid utf8.
13664 // RETURNS: a floating reference to a new string #GVariant instance
13665 // <string>: a normal utf8 nul-terminated string
13666 static Variant* new_string()(char* string_) nothrow {
13667 return g_variant_new_string(string_);
13669 alias new_string!() opCall;
13671 // VERSION: 2.24
13672 // Constructs an array of strings #GVariant from the given array of
13673 // strings.
13675 // If @length is -1 then @strv is %NULL-terminated.
13676 // RETURNS: a new floating #GVariant instance
13677 // <strv>: an array of strings
13678 // <length>: the length of @strv, or -1
13679 static Variant* new_strv()(char** strv, ssize_t length) nothrow {
13680 return g_variant_new_strv(strv, length);
13682 alias new_strv!() opCall;
13684 // VERSION: 2.24
13685 // Creates a new tuple #GVariant out of the items in @children. The
13686 // type is determined from the types of @children. No entry in the
13687 // @children array may be %NULL.
13689 // If @n_children is 0 then the unit tuple is constructed.
13691 // If the @children are floating references (see g_variant_ref_sink()), the
13692 // new instance takes ownership of them as if via g_variant_ref_sink().
13693 // RETURNS: a floating reference to a new #GVariant tuple
13694 // <children>: the items to make the tuple out of
13695 // <n_children>: the length of @children
13696 static Variant* new_tuple()(Variant** children, size_t n_children) nothrow {
13697 return g_variant_new_tuple(children, n_children);
13699 alias new_tuple!() opCall;
13701 // VERSION: 2.24
13702 // Creates a new uint16 #GVariant instance.
13703 // RETURNS: a floating reference to a new uint16 #GVariant instance
13704 // <value>: a #guint16 value
13705 static Variant* new_uint16()(ushort value) nothrow {
13706 return g_variant_new_uint16(value);
13708 alias new_uint16!() opCall;
13710 // VERSION: 2.24
13711 // Creates a new uint32 #GVariant instance.
13712 // RETURNS: a floating reference to a new uint32 #GVariant instance
13713 // <value>: a #guint32 value
13714 static Variant* new_uint32()(uint value) nothrow {
13715 return g_variant_new_uint32(value);
13717 alias new_uint32!() opCall;
13719 // VERSION: 2.24
13720 // Creates a new uint64 #GVariant instance.
13721 // RETURNS: a floating reference to a new uint64 #GVariant instance
13722 // <value>: a #guint64 value
13723 static Variant* new_uint64()(ulong value) nothrow {
13724 return g_variant_new_uint64(value);
13726 alias new_uint64!() opCall;
13728 // Unintrospectable constructor: new_va() / g_variant_new_va()
13729 // VERSION: 2.24
13730 // This function is intended to be used by libraries based on
13731 // #GVariant that want to provide g_variant_new()-like functionality
13732 // to their users.
13734 // The API is more general than g_variant_new() to allow a wider range
13735 // of possible uses.
13737 // @format_string must still point to a valid format string, but it only
13738 // needs to be nul-terminated if @endptr is %NULL. If @endptr is
13739 // non-%NULL then it is updated to point to the first character past the
13740 // end of the format string.
13742 // @app is a pointer to a #va_list. The arguments, according to
13743 // @format_string, are collected from this #va_list and the list is left
13744 // pointing to the argument following the last.
13746 // These two generalisations allow mixing of multiple calls to
13747 // g_variant_new_va() and g_variant_get_va() within a single actual
13748 // varargs call by the user.
13750 // The return value will be floating if it was a newly created GVariant
13751 // instance (for example, if the format string was "(ii)"). In the case
13752 // that the format_string was '*', '?', 'r', or a format starting with
13753 // '@' then the collected #GVariant pointer will be returned unmodified,
13754 // without adding any additional references.
13756 // In order to behave correctly in all cases it is necessary for the
13757 // calling function to g_variant_ref_sink() the return result before
13758 // returning control to the user that originally provided the pointer.
13759 // At this point, the caller will have their own full reference to the
13760 // result. This can also be done by adding the result to a container,
13761 // or by passing it to another g_variant_new() call.
13762 // RETURNS: a new, usually floating, #GVariant
13763 // <format_string>: a string that is prefixed with a format string
13764 // <endptr>: location to store the end pointer, or %NULL
13765 // <app>: a pointer to a #va_list
13766 static Variant* /*new*/ new_va()(char* format_string, char** endptr, va_list* app) nothrow {
13767 return g_variant_new_va(format_string, endptr, app);
13769 alias new_va!() opCall;
13771 // VERSION: 2.24
13772 // Boxes @value. The result is a #GVariant instance representing a
13773 // variant containing the original value.
13775 // If @child is a floating reference (see g_variant_ref_sink()), the new
13776 // instance takes ownership of @child.
13777 // RETURNS: a floating reference to a new variant #GVariant instance
13778 // <value>: a #GVariant instance
13779 static Variant* new_variant()(Variant* value) nothrow {
13780 return g_variant_new_variant(value);
13782 alias new_variant!() opCall;
13784 // VERSION: 2.24
13785 // Performs a byteswapping operation on the contents of @value. The
13786 // result is that all multi-byte numeric data contained in @value is
13787 // byteswapped. That includes 16, 32, and 64bit signed and unsigned
13788 // integers as well as file handles and double precision floating point
13789 // values.
13791 // This function is an identity mapping on any value that does not
13792 // contain multi-byte numeric data. That include strings, booleans,
13793 // bytes and containers containing only these things (recursively).
13795 // The returned value is always in normal form and is marked as trusted.
13796 // RETURNS: the byteswapped form of @value
13797 Variant* /*new*/ byteswap()() nothrow {
13798 return g_variant_byteswap(&this);
13801 // VERSION: 2.24
13802 // Classifies @value according to its top-level type.
13803 // RETURNS: the #GVariantClass of @value
13804 VariantClass classify()() nothrow {
13805 return g_variant_classify(&this);
13808 // VERSION: 2.26
13809 // Compares @one and @two.
13811 // The types of @one and @two are #gconstpointer only to allow use of
13812 // this function with #GTree, #GPtrArray, etc. They must each be a
13813 // #GVariant.
13815 // Comparison is only defined for basic types (ie: booleans, numbers,
13816 // strings). For booleans, %FALSE is less than %TRUE. Numbers are
13817 // ordered in the usual way. Strings are in ASCII lexographical order.
13819 // It is a programmer error to attempt to compare container values or
13820 // two values that have types that are not exactly equal. For example,
13821 // you cannot compare a 32-bit signed integer with a 32-bit unsigned
13822 // integer. Also note that this function is not particularly
13823 // well-behaved when it comes to comparison of doubles; in particular,
13824 // the handling of incomparable values (ie: NaN) is undefined.
13826 // If you only require an equality comparison, g_variant_equal() is more
13827 // general.
13829 // zero if a = b;
13830 // positive value if a &gt; b.
13831 // RETURNS: negative value if a &lt; b;
13832 // <two>: a #GVariant instance of the same type
13833 int compare()(const(Variant)* two) nothrow {
13834 return g_variant_compare(&this, two);
13837 // VERSION: 2.26
13838 // Similar to g_variant_get_bytestring() except that instead of
13839 // returning a constant string, the string is duplicated.
13841 // The return value must be freed using g_free().
13843 // (element-type guint8): a newly allocated string
13844 // RETURNS: (transfer full) (array zero-terminated=1 length=length)
13845 // <length>: a pointer to a #gsize, to store the length (not including the nul terminator)
13846 char* /*new*/ dup_bytestring()(/*out*/ size_t* length=null) nothrow {
13847 return g_variant_dup_bytestring(&this, length);
13850 // VERSION: 2.26
13851 // Gets the contents of an array of array of bytes #GVariant. This call
13852 // makes a deep copy; the return result should be released with
13853 // g_strfreev().
13855 // If @length is non-%NULL then the number of elements in the result is
13856 // stored there. In any case, the resulting array will be
13857 // %NULL-terminated.
13859 // For an empty array, @length will be set to 0 and a pointer to a
13860 // %NULL pointer will be returned.
13861 // RETURNS: an array of strings
13862 // <length>: the length of the result, or %NULL
13863 char** /*new*/ dup_bytestring_array()(/*out*/ size_t* length=null) nothrow {
13864 return g_variant_dup_bytestring_array(&this, length);
13867 // VERSION: 2.30
13868 // Gets the contents of an array of object paths #GVariant. This call
13869 // makes a deep copy; the return result should be released with
13870 // g_strfreev().
13872 // If @length is non-%NULL then the number of elements in the result
13873 // is stored there. In any case, the resulting array will be
13874 // %NULL-terminated.
13876 // For an empty array, @length will be set to 0 and a pointer to a
13877 // %NULL pointer will be returned.
13878 // RETURNS: an array of strings
13879 // <length>: the length of the result, or %NULL
13880 char** /*new*/ dup_objv()(/*out*/ size_t* length=null) nothrow {
13881 return g_variant_dup_objv(&this, length);
13884 // VERSION: 2.24
13885 // Similar to g_variant_get_string() except that instead of returning
13886 // a constant string, the string is duplicated.
13888 // The string will always be utf8 encoded.
13890 // The return value must be freed using g_free().
13891 // RETURNS: a newly allocated string, utf8 encoded
13892 // <length>: a pointer to a #gsize, to store the length
13893 char* /*new*/ dup_string()(/*out*/ size_t* length) nothrow {
13894 return g_variant_dup_string(&this, length);
13897 // VERSION: 2.24
13898 // Gets the contents of an array of strings #GVariant. This call
13899 // makes a deep copy; the return result should be released with
13900 // g_strfreev().
13902 // If @length is non-%NULL then the number of elements in the result
13903 // is stored there. In any case, the resulting array will be
13904 // %NULL-terminated.
13906 // For an empty array, @length will be set to 0 and a pointer to a
13907 // %NULL pointer will be returned.
13908 // RETURNS: an array of strings
13909 // <length>: the length of the result, or %NULL
13910 char** /*new*/ dup_strv()(/*out*/ size_t* length=null) nothrow {
13911 return g_variant_dup_strv(&this, length);
13914 // VERSION: 2.24
13915 // Checks if @one and @two have the same type and value.
13917 // The types of @one and @two are #gconstpointer only to allow use of
13918 // this function with #GHashTable. They must each be a #GVariant.
13919 // RETURNS: %TRUE if @one and @two are equal
13920 // <two>: a #GVariant instance
13921 int equal()(const(Variant)* two) nothrow {
13922 return g_variant_equal(&this, two);
13925 // Unintrospectable method: get() / g_variant_get()
13926 // VERSION: 2.24
13927 // Deconstructs a #GVariant instance.
13929 // Think of this function as an analogue to scanf().
13931 // The arguments that are expected by this function are entirely
13932 // determined by @format_string. @format_string also restricts the
13933 // permissible types of @value. It is an error to give a value with
13934 // an incompatible type. See the section on <link
13935 // linkend='gvariant-format-strings'>GVariant Format Strings</link>.
13936 // Please note that the syntax of the format string is very likely to be
13937 // extended in the future.
13938 // <format_string>: a #GVariant format string
13939 /+ Not available -- variadic methods unsupported - use the C function directly.
13940 alias g_variant_get get; // Variadic
13943 // VERSION: 2.24
13944 // Returns the boolean value of @value.
13946 // It is an error to call this function with a @value of any type
13947 // other than %G_VARIANT_TYPE_BOOLEAN.
13948 // RETURNS: %TRUE or %FALSE
13949 int get_boolean()() nothrow {
13950 return g_variant_get_boolean(&this);
13953 // VERSION: 2.24
13954 // Returns the byte value of @value.
13956 // It is an error to call this function with a @value of any type
13957 // other than %G_VARIANT_TYPE_BYTE.
13958 // RETURNS: a #guchar
13959 ubyte get_byte()() nothrow {
13960 return g_variant_get_byte(&this);
13963 // VERSION: 2.26
13964 // Returns the string value of a #GVariant instance with an
13965 // array-of-bytes type. The string has no particular encoding.
13967 // If the array does not end with a nul terminator character, the empty
13968 // string is returned. For this reason, you can always trust that a
13969 // non-%NULL nul-terminated string will be returned by this function.
13971 // If the array contains a nul terminator character somewhere other than
13972 // the last byte then the returned string is the string, up to the first
13973 // such nul character.
13975 // It is an error to call this function with a @value that is not an
13976 // array of bytes.
13978 // The return value remains valid as long as @value exists.
13980 // the constant string
13981 ubyte* get_bytestring()() nothrow {
13982 return g_variant_get_bytestring(&this);
13985 // VERSION: 2.26
13986 // Gets the contents of an array of array of bytes #GVariant. This call
13987 // makes a shallow copy; the return result should be released with
13988 // g_free(), but the individual strings must not be modified.
13990 // If @length is non-%NULL then the number of elements in the result is
13991 // stored there. In any case, the resulting array will be
13992 // %NULL-terminated.
13994 // For an empty array, @length will be set to 0 and a pointer to a
13995 // %NULL pointer will be returned.
13996 // RETURNS: an array of constant strings
13997 // <length>: the length of the result, or %NULL
13998 char** /*new container*/ get_bytestring_array()(/*out*/ size_t* length=null) nothrow {
13999 return g_variant_get_bytestring_array(&this, length);
14002 // Unintrospectable method: get_child() / g_variant_get_child()
14003 // VERSION: 2.24
14004 // Reads a child item out of a container #GVariant instance and
14005 // deconstructs it according to @format_string. This call is
14006 // essentially a combination of g_variant_get_child_value() and
14007 // g_variant_get().
14008 // <index_>: the index of the child to deconstruct
14009 // <format_string>: a #GVariant format string
14010 /+ Not available -- variadic methods unsupported - use the C function directly.
14011 alias g_variant_get_child get_child; // Variadic
14014 // VERSION: 2.24
14015 // Reads a child item out of a container #GVariant instance. This
14016 // includes variants, maybes, arrays, tuples and dictionary
14017 // entries. It is an error to call this function on any other type of
14018 // #GVariant.
14020 // It is an error if @index_ is greater than the number of child items
14021 // in the container. See g_variant_n_children().
14023 // The returned value is never floating. You should free it with
14024 // g_variant_unref() when you're done with it.
14026 // This function is O(1).
14027 // RETURNS: the child at the specified index
14028 // <index_>: the index of the child to fetch
14029 Variant* /*new*/ get_child_value()(size_t index_) nothrow {
14030 return g_variant_get_child_value(&this, index_);
14033 // VERSION: 2.24
14034 // Returns a pointer to the serialised form of a #GVariant instance.
14035 // The returned data may not be in fully-normalised form if read from an
14036 // untrusted source. The returned data must not be freed; it remains
14037 // valid for as long as @value exists.
14039 // If @value is a fixed-sized value that was deserialised from a
14040 // corrupted serialised container then %NULL may be returned. In this
14041 // case, the proper thing to do is typically to use the appropriate
14042 // number of nul bytes in place of @value. If @value is not fixed-sized
14043 // then %NULL is never returned.
14045 // In the case that @value is already in serialised form, this function
14046 // is O(1). If the value is not already in serialised form,
14047 // serialisation occurs implicitly and is approximately O(n) in the size
14048 // of the result.
14050 // To deserialise the data returned by this function, in addition to the
14051 // serialised data, you must know the type of the #GVariant, and (if the
14052 // machine might be different) the endianness of the machine that stored
14053 // it. As a result, file formats or network messages that incorporate
14054 // serialised #GVariant<!---->s must include this information either
14055 // implicitly (for instance "the file always contains a
14056 // %G_VARIANT_TYPE_VARIANT and it is always in little-endian order") or
14057 // explicitly (by storing the type and/or endianness in addition to the
14058 // serialised data).
14059 // RETURNS: the serialised form of @value, or %NULL
14060 const(void)* get_data()() nothrow {
14061 return g_variant_get_data(&this);
14064 // VERSION: 2.24
14065 // Returns the double precision floating point value of @value.
14067 // It is an error to call this function with a @value of any type
14068 // other than %G_VARIANT_TYPE_DOUBLE.
14069 // RETURNS: a #gdouble
14070 double get_double()() nothrow {
14071 return g_variant_get_double(&this);
14074 // VERSION: 2.24
14075 // Provides access to the serialised data for an array of fixed-sized
14076 // items.
14078 // @value must be an array with fixed-sized elements. Numeric types are
14079 // fixed-size, as are tuples containing only other fixed-sized types.
14081 // @element_size must be the size of a single element in the array,
14082 // as given by the section on
14083 // <link linkend='gvariant-serialised-data-memory'>Serialised Data
14084 // Memory</link>.
14086 // In particular, arrays of these fixed-sized types can be interpreted
14087 // as an array of the given C type, with @element_size set to
14088 // <code>sizeof</code> the appropriate type:
14090 // <informaltable>
14091 // <tgroup cols='2'>
14092 // <thead><row><entry>element type</entry> <entry>C type</entry></row></thead>
14093 // <tbody>
14094 // <row><entry>%G_VARIANT_TYPE_INT16 (etc.)</entry>
14095 // <entry>#gint16 (etc.)</entry></row>
14096 // <row><entry>%G_VARIANT_TYPE_BOOLEAN</entry>
14097 // <entry>#guchar (not #gboolean!)</entry></row>
14098 // <row><entry>%G_VARIANT_TYPE_BYTE</entry> <entry>#guchar</entry></row>
14099 // <row><entry>%G_VARIANT_TYPE_HANDLE</entry> <entry>#guint32</entry></row>
14100 // <row><entry>%G_VARIANT_TYPE_DOUBLE</entry> <entry>#gdouble</entry></row>
14101 // </tbody>
14102 // </tgroup>
14103 // </informaltable>
14105 // For example, if calling this function for an array of 32 bit integers,
14106 // you might say <code>sizeof (gint32)</code>. This value isn't used
14107 // except for the purpose of a double-check that the form of the
14108 // serialised data matches the caller's expectation.
14110 // @n_elements, which must be non-%NULL is set equal to the number of
14111 // items in the array.
14113 // the fixed array
14114 // RETURNS: a pointer to
14115 // <n_elements>: a pointer to the location to store the number of items
14116 // <element_size>: the size of each element
14117 const(void)* get_fixed_array()(/*out*/ size_t* n_elements, size_t element_size) nothrow {
14118 return g_variant_get_fixed_array(&this, n_elements, element_size);
14121 // VERSION: 2.24
14122 // Returns the 32-bit signed integer value of @value.
14124 // It is an error to call this function with a @value of any type other
14125 // than %G_VARIANT_TYPE_HANDLE.
14127 // By convention, handles are indexes into an array of file descriptors
14128 // that are sent alongside a D-Bus message. If you're not interacting
14129 // with D-Bus, you probably don't need them.
14130 // RETURNS: a #gint32
14131 int get_handle()() nothrow {
14132 return g_variant_get_handle(&this);
14135 // VERSION: 2.24
14136 // Returns the 16-bit signed integer value of @value.
14138 // It is an error to call this function with a @value of any type
14139 // other than %G_VARIANT_TYPE_INT16.
14140 // RETURNS: a #gint16
14141 short get_int16()() nothrow {
14142 return g_variant_get_int16(&this);
14145 // VERSION: 2.24
14146 // Returns the 32-bit signed integer value of @value.
14148 // It is an error to call this function with a @value of any type
14149 // other than %G_VARIANT_TYPE_INT32.
14150 // RETURNS: a #gint32
14151 int get_int32()() nothrow {
14152 return g_variant_get_int32(&this);
14155 // VERSION: 2.24
14156 // Returns the 64-bit signed integer value of @value.
14158 // It is an error to call this function with a @value of any type
14159 // other than %G_VARIANT_TYPE_INT64.
14160 // RETURNS: a #gint64
14161 long get_int64()() nothrow {
14162 return g_variant_get_int64(&this);
14165 // VERSION: 2.24
14166 // Given a maybe-typed #GVariant instance, extract its value. If the
14167 // value is Nothing, then this function returns %NULL.
14168 // RETURNS: the contents of @value, or %NULL
14169 Variant* /*new*/ get_maybe()() nothrow {
14170 return g_variant_get_maybe(&this);
14173 // VERSION: 2.24
14174 // Gets a #GVariant instance that has the same value as @value and is
14175 // trusted to be in normal form.
14177 // If @value is already trusted to be in normal form then a new
14178 // reference to @value is returned.
14180 // If @value is not already trusted, then it is scanned to check if it
14181 // is in normal form. If it is found to be in normal form then it is
14182 // marked as trusted and a new reference to it is returned.
14184 // If @value is found not to be in normal form then a new trusted
14185 // #GVariant is created with the same value as @value.
14187 // It makes sense to call this function if you've received #GVariant
14188 // data from untrusted sources and you want to ensure your serialised
14189 // output is definitely in normal form.
14190 // RETURNS: a trusted #GVariant
14191 Variant* /*new*/ get_normal_form()() nothrow {
14192 return g_variant_get_normal_form(&this);
14195 // VERSION: 2.30
14196 // Gets the contents of an array of object paths #GVariant. This call
14197 // makes a shallow copy; the return result should be released with
14198 // g_free(), but the individual strings must not be modified.
14200 // If @length is non-%NULL then the number of elements in the result
14201 // is stored there. In any case, the resulting array will be
14202 // %NULL-terminated.
14204 // For an empty array, @length will be set to 0 and a pointer to a
14205 // %NULL pointer will be returned.
14206 // RETURNS: an array of constant strings
14207 // <length>: the length of the result, or %NULL
14208 char** /*new container*/ get_objv()(/*out*/ size_t* length=null) nothrow {
14209 return g_variant_get_objv(&this, length);
14212 // VERSION: 2.24
14213 // Determines the number of bytes that would be required to store @value
14214 // with g_variant_store().
14216 // If @value has a fixed-sized type then this function always returned
14217 // that fixed size.
14219 // In the case that @value is already in serialised form or the size has
14220 // already been calculated (ie: this function has been called before)
14221 // then this function is O(1). Otherwise, the size is calculated, an
14222 // operation which is approximately O(n) in the number of values
14223 // involved.
14224 // RETURNS: the serialised size of @value
14225 size_t get_size()() nothrow {
14226 return g_variant_get_size(&this);
14229 // VERSION: 2.24
14230 // Returns the string value of a #GVariant instance with a string
14231 // type. This includes the types %G_VARIANT_TYPE_STRING,
14232 // %G_VARIANT_TYPE_OBJECT_PATH and %G_VARIANT_TYPE_SIGNATURE.
14234 // The string will always be utf8 encoded.
14236 // If @length is non-%NULL then the length of the string (in bytes) is
14237 // returned there. For trusted values, this information is already
14238 // known. For untrusted values, a strlen() will be performed.
14240 // It is an error to call this function with a @value of any type
14241 // other than those three.
14243 // The return value remains valid as long as @value exists.
14244 // RETURNS: the constant string, utf8 encoded
14245 // <length>: a pointer to a #gsize, to store the length
14246 char* get_string()(/*out*/ size_t* length=null) nothrow {
14247 return g_variant_get_string(&this, length);
14250 // VERSION: 2.24
14251 // Gets the contents of an array of strings #GVariant. This call
14252 // makes a shallow copy; the return result should be released with
14253 // g_free(), but the individual strings must not be modified.
14255 // If @length is non-%NULL then the number of elements in the result
14256 // is stored there. In any case, the resulting array will be
14257 // %NULL-terminated.
14259 // For an empty array, @length will be set to 0 and a pointer to a
14260 // %NULL pointer will be returned.
14261 // RETURNS: an array of constant strings
14262 // <length>: the length of the result, or %NULL
14263 char** /*new container*/ get_strv()(/*out*/ size_t* length=null) nothrow {
14264 return g_variant_get_strv(&this, length);
14267 // VERSION: 2.24
14268 // Returns the type string of @value. Unlike the result of calling
14269 // g_variant_type_peek_string(), this string is nul-terminated. This
14270 // string belongs to #GVariant and must not be freed.
14271 // RETURNS: the type string for the type of @value
14272 char* get_type_string()() nothrow {
14273 return g_variant_get_type_string(&this);
14276 // VERSION: 2.24
14277 // Returns the 16-bit unsigned integer value of @value.
14279 // It is an error to call this function with a @value of any type
14280 // other than %G_VARIANT_TYPE_UINT16.
14281 // RETURNS: a #guint16
14282 ushort get_uint16()() nothrow {
14283 return g_variant_get_uint16(&this);
14286 // VERSION: 2.24
14287 // Returns the 32-bit unsigned integer value of @value.
14289 // It is an error to call this function with a @value of any type
14290 // other than %G_VARIANT_TYPE_UINT32.
14291 // RETURNS: a #guint32
14292 uint get_uint32()() nothrow {
14293 return g_variant_get_uint32(&this);
14296 // VERSION: 2.24
14297 // Returns the 64-bit unsigned integer value of @value.
14299 // It is an error to call this function with a @value of any type
14300 // other than %G_VARIANT_TYPE_UINT64.
14301 // RETURNS: a #guint64
14302 ulong get_uint64()() nothrow {
14303 return g_variant_get_uint64(&this);
14306 // Unintrospectable method: get_va() / g_variant_get_va()
14307 // VERSION: 2.24
14308 // This function is intended to be used by libraries based on #GVariant
14309 // that want to provide g_variant_get()-like functionality to their
14310 // users.
14312 // The API is more general than g_variant_get() to allow a wider range
14313 // of possible uses.
14315 // @format_string must still point to a valid format string, but it only
14316 // need to be nul-terminated if @endptr is %NULL. If @endptr is
14317 // non-%NULL then it is updated to point to the first character past the
14318 // end of the format string.
14320 // @app is a pointer to a #va_list. The arguments, according to
14321 // @format_string, are collected from this #va_list and the list is left
14322 // pointing to the argument following the last.
14324 // These two generalisations allow mixing of multiple calls to
14325 // g_variant_new_va() and g_variant_get_va() within a single actual
14326 // varargs call by the user.
14327 // <format_string>: a string that is prefixed with a format string
14328 // <endptr>: location to store the end pointer, or %NULL
14329 // <app>: a pointer to a #va_list
14330 void get_va()(char* format_string, char** endptr, va_list* app) nothrow {
14331 g_variant_get_va(&this, format_string, endptr, app);
14334 // VERSION: 2.24
14335 // Unboxes @value. The result is the #GVariant instance that was
14336 // contained in @value.
14337 // RETURNS: the item contained in the variant
14338 Variant* /*new*/ get_variant()() nothrow {
14339 return g_variant_get_variant(&this);
14342 // VERSION: 2.24
14343 // Generates a hash value for a #GVariant instance.
14345 // The output of this function is guaranteed to be the same for a given
14346 // value only per-process. It may change between different processor
14347 // architectures or even different versions of GLib. Do not use this
14348 // function as a basis for building protocols or file formats.
14350 // The type of @value is #gconstpointer only to allow use of this
14351 // function with #GHashTable. @value must be a #GVariant.
14352 // RETURNS: a hash value corresponding to @value
14353 uint hash()() nothrow {
14354 return g_variant_hash(&this);
14357 // VERSION: 2.24
14358 // Checks if @value is a container.
14359 // RETURNS: %TRUE if @value is a container
14360 int is_container()() nothrow {
14361 return g_variant_is_container(&this);
14364 // VERSION: 2.26
14365 // Checks whether @value has a floating reference count.
14367 // This function should only ever be used to assert that a given variant
14368 // is or is not floating, or for debug purposes. To acquire a reference
14369 // to a variant that might be floating, always use g_variant_ref_sink()
14370 // or g_variant_take_ref().
14372 // See g_variant_ref_sink() for more information about floating reference
14373 // counts.
14374 // RETURNS: whether @value is floating
14375 int is_floating()() nothrow {
14376 return g_variant_is_floating(&this);
14379 // VERSION: 2.24
14380 // Checks if @value is in normal form.
14382 // The main reason to do this is to detect if a given chunk of
14383 // serialised data is in normal form: load the data into a #GVariant
14384 // using g_variant_new_from_data() and then use this function to
14385 // check.
14387 // If @value is found to be in normal form then it will be marked as
14388 // being trusted. If the value was already marked as being trusted then
14389 // this function will immediately return %TRUE.
14390 // RETURNS: %TRUE if @value is in normal form
14391 int is_normal_form()() nothrow {
14392 return g_variant_is_normal_form(&this);
14395 // VERSION: 2.24
14396 // Checks if a value has a type matching the provided type.
14397 // RETURNS: %TRUE if the type of @value matches @type
14398 // <type>: a #GVariantType
14399 int is_of_type()(VariantType* type) nothrow {
14400 return g_variant_is_of_type(&this, type);
14403 // Unintrospectable method: iter_new() / g_variant_iter_new()
14404 // VERSION: 2.24
14405 // Creates a heap-allocated #GVariantIter for iterating over the items
14406 // in @value.
14408 // Use g_variant_iter_free() to free the return value when you no longer
14409 // need it.
14411 // A reference is taken to @value and will be released only when
14412 // g_variant_iter_free() is called.
14413 // RETURNS: a new heap-allocated #GVariantIter
14414 VariantIter* /*new*/ iter_new()() nothrow {
14415 return g_variant_iter_new(&this);
14418 // Unintrospectable method: lookup() / g_variant_lookup()
14419 // VERSION: 2.28
14420 // Looks up a value in a dictionary #GVariant.
14422 // This function is a wrapper around g_variant_lookup_value() and
14423 // g_variant_get(). In the case that %NULL would have been returned,
14424 // this function returns %FALSE. Otherwise, it unpacks the returned
14425 // value and returns %TRUE.
14427 // See g_variant_get() for information about @format_string.
14428 // RETURNS: %TRUE if a value was unpacked
14429 // <key>: the key to lookup in the dictionary
14430 // <format_string>: a GVariant format string
14431 /+ Not available -- variadic methods unsupported - use the C function directly.
14432 alias g_variant_lookup lookup; // Variadic
14435 // VERSION: 2.28
14436 // Looks up a value in a dictionary #GVariant.
14438 // This function works with dictionaries of the type
14439 // <literal>a{s*}</literal> (and equally well with type
14440 // <literal>a{o*}</literal>, but we only further discuss the string case
14441 // for sake of clarity).
14443 // In the event that @dictionary has the type <literal>a{sv}</literal>,
14444 // the @expected_type string specifies what type of value is expected to
14445 // be inside of the variant. If the value inside the variant has a
14446 // different type then %NULL is returned. In the event that @dictionary
14447 // has a value type other than <literal>v</literal> then @expected_type
14448 // must directly match the key type and it is used to unpack the value
14449 // directly or an error occurs.
14451 // In either case, if @key is not found in @dictionary, %NULL is
14452 // returned.
14454 // If the key is found and the value has the correct type, it is
14455 // returned. If @expected_type was specified then any non-%NULL return
14456 // value will have this type.
14457 // RETURNS: the value of the dictionary key, or %NULL
14458 // <key>: the key to lookup in the dictionary
14459 // <expected_type>: a #GVariantType, or %NULL
14460 Variant* /*new*/ lookup_value()(char* key, VariantType* expected_type=null) nothrow {
14461 return g_variant_lookup_value(&this, key, expected_type);
14464 // VERSION: 2.24
14465 // Determines the number of children in a container #GVariant instance.
14466 // This includes variants, maybes, arrays, tuples and dictionary
14467 // entries. It is an error to call this function on any other type of
14468 // #GVariant.
14470 // For variants, the return value is always 1. For values with maybe
14471 // types, it is always zero or one. For arrays, it is the length of the
14472 // array. For tuples it is the number of tuple items (which depends
14473 // only on the type). For dictionary entries, it is always 2
14475 // This function is O(1).
14476 // RETURNS: the number of children in the container
14477 size_t n_children()() nothrow {
14478 return g_variant_n_children(&this);
14481 // VERSION: 2.24
14482 // Pretty-prints @value in the format understood by g_variant_parse().
14484 // The format is described <link linkend='gvariant-text'>here</link>.
14486 // If @type_annotate is %TRUE, then type information is included in
14487 // the output.
14488 // RETURNS: a newly-allocated string holding the result.
14489 // <type_annotate>: %TRUE if type information should be included in the output
14490 char* /*new*/ print()(int type_annotate) nothrow {
14491 return g_variant_print(&this, type_annotate);
14494 // Unintrospectable method: print_string() / g_variant_print_string()
14495 // VERSION: 2.24
14496 // Behaves as g_variant_print(), but operates on a #GString.
14498 // If @string is non-%NULL then it is appended to and returned. Else,
14499 // a new empty #GString is allocated and it is returned.
14500 // RETURNS: a #GString containing the string
14501 // <string>: a #GString, or %NULL
14502 // <type_annotate>: %TRUE if type information should be included in the output
14503 String* /*new*/ print_string()(String* string_, int type_annotate) nothrow {
14504 return g_variant_print_string(&this, string_, type_annotate);
14507 // VERSION: 2.24
14508 // Increases the reference count of @value.
14509 // RETURNS: the same @value
14510 Variant* /*new*/ ref_()() nothrow {
14511 return g_variant_ref(&this);
14514 // VERSION: 2.24
14515 // #GVariant uses a floating reference count system. All functions with
14516 // names starting with <literal>g_variant_new_</literal> return floating
14517 // references.
14519 // Calling g_variant_ref_sink() on a #GVariant with a floating reference
14520 // will convert the floating reference into a full reference. Calling
14521 // g_variant_ref_sink() on a non-floating #GVariant results in an
14522 // additional normal reference being added.
14524 // In other words, if the @value is floating, then this call "assumes
14525 // ownership" of the floating reference, converting it to a normal
14526 // reference. If the @value is not floating, then this call adds a
14527 // new normal reference increasing the reference count by one.
14529 // All calls that result in a #GVariant instance being inserted into a
14530 // container will call g_variant_ref_sink() on the instance. This means
14531 // that if the value was just created (and has only its floating
14532 // reference) then the container will assume sole ownership of the value
14533 // at that point and the caller will not need to unreference it. This
14534 // makes certain common styles of programming much easier while still
14535 // maintaining normal refcounting semantics in situations where values
14536 // are not floating.
14537 // RETURNS: the same @value
14538 Variant* /*new*/ ref_sink()() nothrow {
14539 return g_variant_ref_sink(&this);
14542 // VERSION: 2.24
14543 // Stores the serialised form of @value at @data. @data should be
14544 // large enough. See g_variant_get_size().
14546 // The stored data is in machine native byte order but may not be in
14547 // fully-normalised form if read from an untrusted source. See
14548 // g_variant_get_normal_form() for a solution.
14550 // As with g_variant_get_data(), to be able to deserialise the
14551 // serialised variant successfully, its type and (if the destination
14552 // machine might be different) its endianness must also be available.
14554 // This function is approximately O(n) in the size of @data.
14555 // <data>: the location to store the serialised data at
14556 void store()(void* data) nothrow {
14557 g_variant_store(&this, data);
14560 // If @value is floating, sink it. Otherwise, do nothing.
14562 // Typically you want to use g_variant_ref_sink() in order to
14563 // automatically do the correct thing with respect to floating or
14564 // non-floating references, but there is one specific scenario where
14565 // this function is helpful.
14567 // The situation where this function is helpful is when creating an API
14568 // that allows the user to provide a callback function that returns a
14569 // #GVariant. We certainly want to allow the user the flexibility to
14570 // return a non-floating reference from this callback (for the case
14571 // where the value that is being returned already exists).
14573 // At the same time, the style of the #GVariant API makes it likely that
14574 // for newly-created #GVariant instances, the user can be saved some
14575 // typing if they are allowed to return a #GVariant with a floating
14576 // reference.
14578 // Using this function on the return value of the user's callback allows
14579 // the user to do whichever is more convenient for them. The caller
14580 // will alway receives exactly one full reference to the value: either
14581 // the one that was returned in the first place, or a floating reference
14582 // that has been converted to a full reference.
14584 // This function has an odd interaction when combined with
14585 // g_variant_ref_sink() running at the same time in another thread on
14586 // the same #GVariant instance. If g_variant_ref_sink() runs first then
14587 // the result will be that the floating reference is converted to a hard
14588 // reference. If g_variant_take_ref() runs first then the result will
14589 // be that the floating reference is converted to a hard reference and
14590 // an additional reference on top of that one is added. It is best to
14591 // avoid this situation.
14592 // RETURNS: the same @value
14593 Variant* /*new*/ take_ref()() nothrow {
14594 return g_variant_take_ref(&this);
14597 // VERSION: 2.24
14598 // Decreases the reference count of @value. When its reference count
14599 // drops to 0, the memory used by the variant is freed.
14600 void unref()() nothrow {
14601 g_variant_unref(&this);
14604 // VERSION: 2.24
14605 // Determines if a given string is a valid D-Bus object path. You
14606 // should ensure that a string is a valid D-Bus object path before
14607 // passing it to g_variant_new_object_path().
14609 // A valid object path starts with '/' followed by zero or more
14610 // sequences of characters separated by '/' characters. Each sequence
14611 // must contain only the characters "[A-Z][a-z][0-9]_". No sequence
14612 // (including the one following the final '/' character) may be empty.
14613 // RETURNS: %TRUE if @string is a D-Bus object path
14614 // <string>: a normal C nul-terminated string
14615 static int is_object_path()(char* string_) nothrow {
14616 return g_variant_is_object_path(string_);
14619 // VERSION: 2.24
14620 // Determines if a given string is a valid D-Bus type signature. You
14621 // should ensure that a string is a valid D-Bus type signature before
14622 // passing it to g_variant_new_signature().
14624 // D-Bus type signatures consist of zero or more definite #GVariantType
14625 // strings in sequence.
14626 // RETURNS: %TRUE if @string is a D-Bus type signature
14627 // <string>: a normal C nul-terminated string
14628 static int is_signature()(char* string_) nothrow {
14629 return g_variant_is_signature(string_);
14632 // Parses a #GVariant from a text representation.
14634 // A single #GVariant is parsed from the content of @text.
14636 // The format is described <link linkend='gvariant-text'>here</link>.
14638 // The memory at @limit will never be accessed and the parser behaves as
14639 // if the character at @limit is the nul terminator. This has the
14640 // effect of bounding @text.
14642 // If @endptr is non-%NULL then @text is permitted to contain data
14643 // following the value that this function parses and @endptr will be
14644 // updated to point to the first character past the end of the text
14645 // parsed by this function. If @endptr is %NULL and there is extra data
14646 // then an error is returned.
14648 // If @type is non-%NULL then the value will be parsed to have that
14649 // type. This may result in additional parse errors (in the case that
14650 // the parsed value doesn't fit the type) but may also result in fewer
14651 // errors (in the case that the type would have been ambiguous, such as
14652 // with empty arrays).
14654 // In the event that the parsing is successful, the resulting #GVariant
14655 // is returned.
14657 // In case of any error, %NULL will be returned. If @error is non-%NULL
14658 // then it will be set to reflect the error that occurred.
14660 // Officially, the language understood by the parser is "any string
14661 // produced by g_variant_print()".
14662 // <type>: a #GVariantType, or %NULL
14663 // <text>: a string containing a GVariant in text form
14664 // <limit>: a pointer to the end of @text, or %NULL
14665 // <endptr>: a location to store the end pointer, or %NULL
14666 static Variant* /*new*/ parse()(VariantType* type, char* text, char* limit, char** endptr, GLib2.Error** error=null) nothrow {
14667 return g_variant_parse(type, text, limit, endptr, error);
14669 static Quark parser_get_error_quark()() nothrow {
14670 return g_variant_parser_get_error_quark();
14675 // A utility type for constructing container-type #GVariant instances.
14677 // This is an opaque structure and may only be accessed using the
14678 // following functions.
14680 // #GVariantBuilder is not threadsafe in any way. Do not attempt to
14681 // access it from more than one thread.
14682 struct VariantBuilder {
14683 private size_t[16] x;
14686 // VERSION: 2.24
14687 // Allocates and initialises a new #GVariantBuilder.
14689 // You should call g_variant_builder_unref() on the return value when it
14690 // is no longer needed. The memory will not be automatically freed by
14691 // any other call.
14693 // In most cases it is easier to place a #GVariantBuilder directly on
14694 // the stack of the calling function and initialise it with
14695 // g_variant_builder_init().
14696 // RETURNS: a #GVariantBuilder
14697 // <type>: a container type
14698 static VariantBuilder* /*new*/ new_()(VariantType* type) nothrow {
14699 return g_variant_builder_new(type);
14701 alias new_!() opCall;
14703 // Unintrospectable method: add() / g_variant_builder_add()
14704 // VERSION: 2.24
14705 // Adds to a #GVariantBuilder.
14707 // This call is a convenience wrapper that is exactly equivalent to
14708 // calling g_variant_new() followed by g_variant_builder_add_value().
14710 // This function might be used as follows:
14712 // <programlisting>
14713 // GVariant *
14714 // make_pointless_dictionary (void)
14715 // {
14716 // GVariantBuilder *builder;
14717 // int i;
14719 // builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
14720 // for (i = 0; i < 16; i++)
14721 // {
14722 // gchar buf[3];
14724 // sprintf (buf, "%d", i);
14725 // g_variant_builder_add (builder, "{is}", i, buf);
14726 // }
14728 // return g_variant_builder_end (builder);
14729 // }
14730 // </programlisting>
14731 // <format_string>: a #GVariant varargs format string
14732 /+ Not available -- variadic methods unsupported - use the C function directly.
14733 alias g_variant_builder_add add; // Variadic
14736 // Unintrospectable method: add_parsed() / g_variant_builder_add_parsed()
14737 // VERSION: 2.26
14738 // Adds to a #GVariantBuilder.
14740 // This call is a convenience wrapper that is exactly equivalent to
14741 // calling g_variant_new_parsed() followed by
14742 // g_variant_builder_add_value().
14744 // This function might be used as follows:
14746 // <programlisting>
14747 // GVariant *
14748 // make_pointless_dictionary (void)
14749 // {
14750 // GVariantBuilder *builder;
14751 // int i;
14753 // builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
14754 // g_variant_builder_add_parsed (builder, "{'width', <%i>}", 600);
14755 // g_variant_builder_add_parsed (builder, "{'title', <%s>}", "foo");
14756 // g_variant_builder_add_parsed (builder, "{'transparency', <0.5>}");
14757 // return g_variant_builder_end (builder);
14758 // }
14759 // </programlisting>
14760 // <format>: a text format #GVariant
14761 /+ Not available -- variadic methods unsupported - use the C function directly.
14762 alias g_variant_builder_add_parsed add_parsed; // Variadic
14765 // VERSION: 2.24
14766 // Adds @value to @builder.
14768 // It is an error to call this function in any way that would create an
14769 // inconsistent value to be constructed. Some examples of this are
14770 // putting different types of items into an array, putting the wrong
14771 // types or number of items in a tuple, putting more than one value into
14772 // a variant, etc.
14774 // If @value is a floating reference (see g_variant_ref_sink()),
14775 // the @builder instance takes ownership of @value.
14776 // <value>: a #GVariant
14777 void add_value()(Variant* value) nothrow {
14778 g_variant_builder_add_value(&this, value);
14781 // Unintrospectable method: clear() / g_variant_builder_clear()
14782 // VERSION: 2.24
14783 // Releases all memory associated with a #GVariantBuilder without
14784 // freeing the #GVariantBuilder structure itself.
14786 // It typically only makes sense to do this on a stack-allocated
14787 // #GVariantBuilder if you want to abort building the value part-way
14788 // through. This function need not be called if you call
14789 // g_variant_builder_end() and it also doesn't need to be called on
14790 // builders allocated with g_variant_builder_new (see
14791 // g_variant_builder_unref() for that).
14793 // This function leaves the #GVariantBuilder structure set to all-zeros.
14794 // It is valid to call this function on either an initialised
14795 // #GVariantBuilder or one that is set to all-zeros but it is not valid
14796 // to call this function on uninitialised memory.
14797 void clear()() nothrow {
14798 g_variant_builder_clear(&this);
14801 // VERSION: 2.24
14802 // Closes the subcontainer inside the given @builder that was opened by
14803 // the most recent call to g_variant_builder_open().
14805 // It is an error to call this function in any way that would create an
14806 // inconsistent value to be constructed (ie: too few values added to the
14807 // subcontainer).
14808 void close()() nothrow {
14809 g_variant_builder_close(&this);
14812 // VERSION: 2.24
14813 // Ends the builder process and returns the constructed value.
14815 // It is not permissible to use @builder in any way after this call
14816 // except for reference counting operations (in the case of a
14817 // heap-allocated #GVariantBuilder) or by reinitialising it with
14818 // g_variant_builder_init() (in the case of stack-allocated).
14820 // It is an error to call this function in any way that would create an
14821 // inconsistent value to be constructed (ie: insufficient number of
14822 // items added to a container with a specific number of children
14823 // required). It is also an error to call this function if the builder
14824 // was created with an indefinite array or maybe type and no children
14825 // have been added; in this case it is impossible to infer the type of
14826 // the empty array.
14827 // RETURNS: a new, floating, #GVariant
14828 Variant* end()() nothrow {
14829 return g_variant_builder_end(&this);
14832 // Unintrospectable method: init() / g_variant_builder_init()
14833 // VERSION: 2.24
14834 // Initialises a #GVariantBuilder structure.
14836 // @type must be non-%NULL. It specifies the type of container to
14837 // construct. It can be an indefinite type such as
14838 // %G_VARIANT_TYPE_ARRAY or a definite type such as "as" or "(ii)".
14839 // Maybe, array, tuple, dictionary entry and variant-typed values may be
14840 // constructed.
14842 // After the builder is initialised, values are added using
14843 // g_variant_builder_add_value() or g_variant_builder_add().
14845 // After all the child values are added, g_variant_builder_end() frees
14846 // the memory associated with the builder and returns the #GVariant that
14847 // was created.
14849 // This function completely ignores the previous contents of @builder.
14850 // On one hand this means that it is valid to pass in completely
14851 // uninitialised memory. On the other hand, this means that if you are
14852 // initialising over top of an existing #GVariantBuilder you need to
14853 // first call g_variant_builder_clear() in order to avoid leaking
14854 // memory.
14856 // You must not call g_variant_builder_ref() or
14857 // g_variant_builder_unref() on a #GVariantBuilder that was initialised
14858 // with this function. If you ever pass a reference to a
14859 // #GVariantBuilder outside of the control of your own code then you
14860 // should assume that the person receiving that reference may try to use
14861 // reference counting; you should use g_variant_builder_new() instead of
14862 // this function.
14863 // <type>: a container type
14864 void init()(VariantType* type) nothrow {
14865 g_variant_builder_init(&this, type);
14868 // VERSION: 2.24
14869 // Opens a subcontainer inside the given @builder. When done adding
14870 // items to the subcontainer, g_variant_builder_close() must be called.
14872 // It is an error to call this function in any way that would cause an
14873 // inconsistent value to be constructed (ie: adding too many values or
14874 // a value of an incorrect type).
14875 // <type>: a #GVariantType
14876 void open()(VariantType* type) nothrow {
14877 g_variant_builder_open(&this, type);
14880 // VERSION: 2.24
14881 // Increases the reference count on @builder.
14883 // Don't call this on stack-allocated #GVariantBuilder instances or bad
14884 // things will happen.
14885 // RETURNS: a new reference to @builder
14886 VariantBuilder* /*new*/ ref_()() nothrow {
14887 return g_variant_builder_ref(&this);
14890 // VERSION: 2.24
14891 // Decreases the reference count on @builder.
14893 // In the event that there are no more references, releases all memory
14894 // associated with the #GVariantBuilder.
14896 // Don't call this on stack-allocated #GVariantBuilder instances or bad
14897 // things will happen.
14898 void unref()() nothrow {
14899 g_variant_builder_unref(&this);
14903 // The range of possible top-level types of #GVariant instances.
14904 enum VariantClass /* Version 2.24 */ {
14905 BOOLEAN = 98,
14906 BYTE = 121,
14907 INT16 = 110,
14908 UINT16 = 113,
14909 INT32 = 105,
14910 UINT32 = 117,
14911 INT64 = 120,
14912 UINT64 = 116,
14913 HANDLE = 104,
14914 DOUBLE = 100,
14915 STRING = 115,
14916 OBJECT_PATH = 111,
14917 SIGNATURE = 103,
14918 VARIANT = 118,
14919 MAYBE = 109,
14920 ARRAY = 97,
14921 TUPLE = 40,
14922 DICT_ENTRY = 123
14925 // #GVariantIter is an opaque data structure and can only be accessed
14926 // using the following functions.
14927 struct VariantIter {
14928 private size_t[16] x;
14931 // Unintrospectable method: copy() / g_variant_iter_copy()
14932 // VERSION: 2.24
14933 // Creates a new heap-allocated #GVariantIter to iterate over the
14934 // container that was being iterated over by @iter. Iteration begins on
14935 // the new iterator from the current position of the old iterator but
14936 // the two copies are independent past that point.
14938 // Use g_variant_iter_free() to free the return value when you no longer
14939 // need it.
14941 // A reference is taken to the container that @iter is iterating over
14942 // and will be releated only when g_variant_iter_free() is called.
14943 // RETURNS: a new heap-allocated #GVariantIter
14944 VariantIter* /*new*/ copy()() nothrow {
14945 return g_variant_iter_copy(&this);
14948 // VERSION: 2.24
14949 // Frees a heap-allocated #GVariantIter. Only call this function on
14950 // iterators that were returned by g_variant_iter_new() or
14951 // g_variant_iter_copy().
14952 void free()() nothrow {
14953 g_variant_iter_free(&this);
14956 // Unintrospectable method: init() / g_variant_iter_init()
14957 // VERSION: 2.24
14958 // Initialises (without allocating) a #GVariantIter. @iter may be
14959 // completely uninitialised prior to this call; its old value is
14960 // ignored.
14962 // The iterator remains valid for as long as @value exists, and need not
14963 // be freed in any way.
14964 // RETURNS: the number of items in @value
14965 // <value>: a container #GVariant
14966 size_t init()(Variant* value) nothrow {
14967 return g_variant_iter_init(&this, value);
14970 // Unintrospectable method: loop() / g_variant_iter_loop()
14971 // VERSION: 2.24
14972 // Gets the next item in the container and unpacks it into the variable
14973 // argument list according to @format_string, returning %TRUE.
14975 // If no more items remain then %FALSE is returned.
14977 // On the first call to this function, the pointers appearing on the
14978 // variable argument list are assumed to point at uninitialised memory.
14979 // On the second and later calls, it is assumed that the same pointers
14980 // will be given and that they will point to the memory as set by the
14981 // previous call to this function. This allows the previous values to
14982 // be freed, as appropriate.
14984 // This function is intended to be used with a while loop as
14985 // demonstrated in the following example. This function can only be
14986 // used when iterating over an array. It is only valid to call this
14987 // function with a string constant for the format string and the same
14988 // string constant must be used each time. Mixing calls to this
14989 // function and g_variant_iter_next() or g_variant_iter_next_value() on
14990 // the same iterator causes undefined behavior.
14992 // If you break out of a such a while loop using g_variant_iter_loop() then
14993 // you must free or unreference all the unpacked values as you would with
14994 // g_variant_get(). Failure to do so will cause a memory leak.
14996 // See the section on <link linkend='gvariant-format-strings'>GVariant
14997 // Format Strings</link>.
14999 // <example>
15000 // <title>Memory management with g_variant_iter_loop()</title>
15001 // <programlisting>
15002 // /<!-- -->* Iterates a dictionary of type 'a{sv}' *<!-- -->/
15003 // void
15004 // iterate_dictionary (GVariant *dictionary)
15005 // {
15006 // GVariantIter iter;
15007 // GVariant *value;
15008 // gchar *key;
15010 // g_variant_iter_init (&iter, dictionary);
15011 // while (g_variant_iter_loop (&iter, "{sv}", &key, &value))
15012 // {
15013 // g_print ("Item '%s' has type '%s'\n", key,
15014 // g_variant_get_type_string (value));
15016 // /<!-- -->* no need to free 'key' and 'value' here *<!-- -->/
15017 // /<!-- -->* unless breaking out of this loop *<!-- -->/
15018 // }
15019 // }
15020 // </programlisting>
15021 // </example>
15023 // For most cases you should use g_variant_iter_next().
15025 // This function is really only useful when unpacking into #GVariant or
15026 // #GVariantIter in order to allow you to skip the call to
15027 // g_variant_unref() or g_variant_iter_free().
15029 // For example, if you are only looping over simple integer and string
15030 // types, g_variant_iter_next() is definitely preferred. For string
15031 // types, use the '&' prefix to avoid allocating any memory at all (and
15032 // thereby avoiding the need to free anything as well).
15034 // value
15035 // RETURNS: %TRUE if a value was unpacked, or %FALSE if there was no
15036 // <format_string>: a GVariant format string
15037 /+ Not available -- variadic methods unsupported - use the C function directly.
15038 alias g_variant_iter_loop loop; // Variadic
15041 // VERSION: 2.24
15042 // Queries the number of child items in the container that we are
15043 // iterating over. This is the total number of items -- not the number
15044 // of items remaining.
15046 // This function might be useful for preallocation of arrays.
15047 // RETURNS: the number of children in the container
15048 size_t n_children()() nothrow {
15049 return g_variant_iter_n_children(&this);
15052 // Unintrospectable method: next() / g_variant_iter_next()
15053 // VERSION: 2.24
15054 // Gets the next item in the container and unpacks it into the variable
15055 // argument list according to @format_string, returning %TRUE.
15057 // If no more items remain then %FALSE is returned.
15059 // All of the pointers given on the variable arguments list of this
15060 // function are assumed to point at uninitialised memory. It is the
15061 // responsibility of the caller to free all of the values returned by
15062 // the unpacking process.
15064 // See the section on <link linkend='gvariant-format-strings'>GVariant
15065 // Format Strings</link>.
15067 // <example>
15068 // <title>Memory management with g_variant_iter_next()</title>
15069 // <programlisting>
15070 // /<!-- -->* Iterates a dictionary of type 'a{sv}' *<!-- -->/
15071 // void
15072 // iterate_dictionary (GVariant *dictionary)
15073 // {
15074 // GVariantIter iter;
15075 // GVariant *value;
15076 // gchar *key;
15078 // g_variant_iter_init (&iter, dictionary);
15079 // while (g_variant_iter_next (&iter, "{sv}", &key, &value))
15080 // {
15081 // g_print ("Item '%s' has type '%s'\n", key,
15082 // g_variant_get_type_string (value));
15084 // /<!-- -->* must free data for ourselves *<!-- -->/
15085 // g_variant_unref (value);
15086 // g_free (key);
15087 // }
15088 // }
15089 // </programlisting>
15090 // </example>
15092 // For a solution that is likely to be more convenient to C programmers
15093 // when dealing with loops, see g_variant_iter_loop().
15094 // RETURNS: %TRUE if a value was unpacked, or %FALSE if there as no value
15095 // <format_string>: a GVariant format string
15096 /+ Not available -- variadic methods unsupported - use the C function directly.
15097 alias g_variant_iter_next next; // Variadic
15100 // VERSION: 2.24
15101 // Gets the next item in the container. If no more items remain then
15102 // %NULL is returned.
15104 // Use g_variant_unref() to drop your reference on the return value when
15105 // you no longer need it.
15107 // <example>
15108 // <title>Iterating with g_variant_iter_next_value()</title>
15109 // <programlisting>
15110 // /<!-- -->* recursively iterate a container *<!-- -->/
15111 // void
15112 // iterate_container_recursive (GVariant *container)
15113 // {
15114 // GVariantIter iter;
15115 // GVariant *child;
15117 // g_variant_iter_init (&iter, container);
15118 // while ((child = g_variant_iter_next_value (&iter)))
15119 // {
15120 // g_print ("type '%s'\n", g_variant_get_type_string (child));
15122 // if (g_variant_is_container (child))
15123 // iterate_container_recursive (child);
15125 // g_variant_unref (child);
15126 // }
15127 // }
15128 // </programlisting>
15129 // </example>
15130 // RETURNS: a #GVariant, or %NULL
15131 Variant* /*new*/ next_value()() nothrow {
15132 return g_variant_iter_next_value(&this);
15136 // Error codes returned by parsing text-format GVariants.
15137 enum VariantParseError {
15138 FAILED = 0,
15139 BASIC_TYPE_EXPECTED = 1,
15140 CANNOT_INFER_TYPE = 2,
15141 DEFINITE_TYPE_EXPECTED = 3,
15142 INPUT_NOT_AT_END = 4,
15143 INVALID_CHARACTER = 5,
15144 INVALID_FORMAT_STRING = 6,
15145 INVALID_OBJECT_PATH = 7,
15146 INVALID_SIGNATURE = 8,
15147 INVALID_TYPE_STRING = 9,
15148 NO_COMMON_TYPE = 10,
15149 NUMBER_OUT_OF_RANGE = 11,
15150 NUMBER_TOO_BIG = 12,
15151 TYPE_ERROR = 13,
15152 UNEXPECTED_TOKEN = 14,
15153 UNKNOWN_KEYWORD = 15,
15154 UNTERMINATED_STRING_CONSTANT = 16,
15155 VALUE_EXPECTED = 17
15158 // This section introduces the GVariant type system. It is based, in
15159 // large part, on the D-Bus type system, with two major changes and some minor
15160 // lifting of restrictions. The <ulink
15161 // url='http://dbus.freedesktop.org/doc/dbus-specification.html'>DBus
15162 // specification</ulink>, therefore, provides a significant amount of
15163 // information that is useful when working with GVariant.
15165 // The first major change with respect to the D-Bus type system is the
15166 // introduction of maybe (or "nullable") types. Any type in GVariant can be
15167 // converted to a maybe type, in which case, "nothing" (or "null") becomes a
15168 // valid value. Maybe types have been added by introducing the
15169 // character "<literal>m</literal>" to type strings.
15171 // The second major change is that the GVariant type system supports the
15172 // concept of "indefinite types" -- types that are less specific than
15173 // the normal types found in D-Bus. For example, it is possible to speak
15174 // of "an array of any type" in GVariant, where the D-Bus type system
15175 // would require you to speak of "an array of integers" or "an array of
15176 // strings". Indefinite types have been added by introducing the
15177 // characters "<literal>*</literal>", "<literal>?</literal>" and
15178 // "<literal>r</literal>" to type strings.
15180 // Finally, all arbitrary restrictions relating to the complexity of
15181 // types are lifted along with the restriction that dictionary entries
15182 // may only appear nested inside of arrays.
15184 // Just as in D-Bus, GVariant types are described with strings ("type
15185 // strings"). Subject to the differences mentioned above, these strings
15186 // are of the same form as those found in DBus. Note, however: D-Bus
15187 // always works in terms of messages and therefore individual type
15188 // strings appear nowhere in its interface. Instead, "signatures"
15189 // are a concatenation of the strings of the type of each argument in a
15190 // message. GVariant deals with single values directly so GVariant type
15191 // strings always describe the type of exactly one value. This means
15192 // that a D-Bus signature string is generally not a valid GVariant type
15193 // string -- except in the case that it is the signature of a message
15194 // containing exactly one argument.
15196 // An indefinite type is similar in spirit to what may be called an
15197 // abstract type in other type systems. No value can exist that has an
15198 // indefinite type as its type, but values can exist that have types
15199 // that are subtypes of indefinite types. That is to say,
15200 // g_variant_get_type() will never return an indefinite type, but
15201 // calling g_variant_is_of_type() with an indefinite type may return
15202 // %TRUE. For example, you cannot have a value that represents "an
15203 // array of no particular type", but you can have an "array of integers"
15204 // which certainly matches the type of "an array of no particular type",
15205 // since "array of integers" is a subtype of "array of no particular
15206 // type".
15208 // This is similar to how instances of abstract classes may not
15209 // directly exist in other type systems, but instances of their
15210 // non-abstract subtypes may. For example, in GTK, no object that has
15211 // the type of #GtkBin can exist (since #GtkBin is an abstract class),
15212 // but a #GtkWindow can certainly be instantiated, and you would say
15213 // that the #GtkWindow is a #GtkBin (since #GtkWindow is a subclass of
15214 // #GtkBin).
15216 // A detailed description of GVariant type strings is given here:
15218 // <refsect2 id='gvariant-typestrings'>
15219 // <title>GVariant Type Strings</title>
15220 // <para>
15221 // A GVariant type string can be any of the following:
15222 // </para>
15223 // <itemizedlist>
15224 // <listitem>
15225 // <para>
15226 // any basic type string (listed below)
15227 // </para>
15228 // </listitem>
15229 // <listitem>
15230 // <para>
15231 // "<literal>v</literal>", "<literal>r</literal>" or
15232 // "<literal>*</literal>"
15233 // </para>
15234 // </listitem>
15235 // <listitem>
15236 // <para>
15237 // one of the characters '<literal>a</literal>' or
15238 // '<literal>m</literal>', followed by another type string
15239 // </para>
15240 // </listitem>
15241 // <listitem>
15242 // <para>
15243 // the character '<literal>(</literal>', followed by a concatenation
15244 // of zero or more other type strings, followed by the character
15245 // '<literal>)</literal>'
15246 // </para>
15247 // </listitem>
15248 // <listitem>
15249 // <para>
15250 // the character '<literal>{</literal>', followed by a basic type
15251 // string (see below), followed by another type string, followed by
15252 // the character '<literal>}</literal>'
15253 // </para>
15254 // </listitem>
15255 // </itemizedlist>
15256 // <para>
15257 // A basic type string describes a basic type (as per
15258 // g_variant_type_is_basic()) and is always a single
15259 // character in length. The valid basic type strings are
15260 // "<literal>b</literal>", "<literal>y</literal>",
15261 // "<literal>n</literal>", "<literal>q</literal>",
15262 // "<literal>i</literal>", "<literal>u</literal>",
15263 // "<literal>x</literal>", "<literal>t</literal>",
15264 // "<literal>h</literal>", "<literal>d</literal>",
15265 // "<literal>s</literal>", "<literal>o</literal>",
15266 // "<literal>g</literal>" and "<literal>?</literal>".
15267 // </para>
15268 // <para>
15269 // The above definition is recursive to arbitrary depth.
15270 // "<literal>aaaaai</literal>" and "<literal>(ui(nq((y)))s)</literal>"
15271 // are both valid type strings, as is
15272 // "<literal>a(aa(ui)(qna{ya(yd)}))</literal>".
15273 // </para>
15274 // <para>
15275 // The meaning of each of the characters is as follows:
15276 // </para>
15277 // <informaltable>
15278 // <tgroup cols='2'>
15279 // <tbody>
15280 // <row>
15281 // <entry>
15282 // <para>
15283 // <emphasis role='strong'>Character</emphasis>
15284 // </para>
15285 // </entry>
15286 // <entry>
15287 // <para>
15288 // <emphasis role='strong'>Meaning</emphasis>
15289 // </para>
15290 // </entry>
15291 // </row>
15292 // <row>
15293 // <entry>
15294 // <para>
15295 // <literal>b</literal>
15296 // </para>
15297 // </entry>
15298 // <entry>
15299 // <para>
15300 // the type string of %G_VARIANT_TYPE_BOOLEAN; a boolean value.
15301 // </para>
15302 // </entry>
15303 // </row>
15304 // <row>
15305 // <entry>
15306 // <para>
15307 // <literal>y</literal>
15308 // </para>
15309 // </entry>
15310 // <entry>
15311 // <para>
15312 // the type string of %G_VARIANT_TYPE_BYTE; a byte.
15313 // </para>
15314 // </entry>
15315 // </row>
15316 // <row>
15317 // <entry>
15318 // <para>
15319 // <literal>n</literal>
15320 // </para>
15321 // </entry>
15322 // <entry>
15323 // <para>
15324 // the type string of %G_VARIANT_TYPE_INT16; a signed 16 bit
15325 // integer.
15326 // </para>
15327 // </entry>
15328 // </row>
15329 // <row>
15330 // <entry>
15331 // <para>
15332 // <literal>q</literal>
15333 // </para>
15334 // </entry>
15335 // <entry>
15336 // <para>
15337 // the type string of %G_VARIANT_TYPE_UINT16; an unsigned 16 bit
15338 // integer.
15339 // </para>
15340 // </entry>
15341 // </row>
15342 // <row>
15343 // <entry>
15344 // <para>
15345 // <literal>i</literal>
15346 // </para>
15347 // </entry>
15348 // <entry>
15349 // <para>
15350 // the type string of %G_VARIANT_TYPE_INT32; a signed 32 bit
15351 // integer.
15352 // </para>
15353 // </entry>
15354 // </row>
15355 // <row>
15356 // <entry>
15357 // <para>
15358 // <literal>u</literal>
15359 // </para>
15360 // </entry>
15361 // <entry>
15362 // <para>
15363 // the type string of %G_VARIANT_TYPE_UINT32; an unsigned 32 bit
15364 // integer.
15365 // </para>
15366 // </entry>
15367 // </row>
15368 // <row>
15369 // <entry>
15370 // <para>
15371 // <literal>x</literal>
15372 // </para>
15373 // </entry>
15374 // <entry>
15375 // <para>
15376 // the type string of %G_VARIANT_TYPE_INT64; a signed 64 bit
15377 // integer.
15378 // </para>
15379 // </entry>
15380 // </row>
15381 // <row>
15382 // <entry>
15383 // <para>
15384 // <literal>t</literal>
15385 // </para>
15386 // </entry>
15387 // <entry>
15388 // <para>
15389 // the type string of %G_VARIANT_TYPE_UINT64; an unsigned 64 bit
15390 // integer.
15391 // </para>
15392 // </entry>
15393 // </row>
15394 // <row>
15395 // <entry>
15396 // <para>
15397 // <literal>h</literal>
15398 // </para>
15399 // </entry>
15400 // <entry>
15401 // <para>
15402 // the type string of %G_VARIANT_TYPE_HANDLE; a signed 32 bit
15403 // value that, by convention, is used as an index into an array
15404 // of file descriptors that are sent alongside a D-Bus message.
15405 // </para>
15406 // </entry>
15407 // </row>
15408 // <row>
15409 // <entry>
15410 // <para>
15411 // <literal>d</literal>
15412 // </para>
15413 // </entry>
15414 // <entry>
15415 // <para>
15416 // the type string of %G_VARIANT_TYPE_DOUBLE; a double precision
15417 // floating point value.
15418 // </para>
15419 // </entry>
15420 // </row>
15421 // <row>
15422 // <entry>
15423 // <para>
15424 // <literal>s</literal>
15425 // </para>
15426 // </entry>
15427 // <entry>
15428 // <para>
15429 // the type string of %G_VARIANT_TYPE_STRING; a string.
15430 // </para>
15431 // </entry>
15432 // </row>
15433 // <row>
15434 // <entry>
15435 // <para>
15436 // <literal>o</literal>
15437 // </para>
15438 // </entry>
15439 // <entry>
15440 // <para>
15441 // the type string of %G_VARIANT_TYPE_OBJECT_PATH; a string in
15442 // the form of a D-Bus object path.
15443 // </para>
15444 // </entry>
15445 // </row>
15446 // <row>
15447 // <entry>
15448 // <para>
15449 // <literal>g</literal>
15450 // </para>
15451 // </entry>
15452 // <entry>
15453 // <para>
15454 // the type string of %G_VARIANT_TYPE_STRING; a string in the
15455 // form of a D-Bus type signature.
15456 // </para>
15457 // </entry>
15458 // </row>
15459 // <row>
15460 // <entry>
15461 // <para>
15462 // <literal>?</literal>
15463 // </para>
15464 // </entry>
15465 // <entry>
15466 // <para>
15467 // the type string of %G_VARIANT_TYPE_BASIC; an indefinite type
15468 // that is a supertype of any of the basic types.
15469 // </para>
15470 // </entry>
15471 // </row>
15472 // <row>
15473 // <entry>
15474 // <para>
15475 // <literal>v</literal>
15476 // </para>
15477 // </entry>
15478 // <entry>
15479 // <para>
15480 // the type string of %G_VARIANT_TYPE_VARIANT; a container type
15481 // that contain any other type of value.
15482 // </para>
15483 // </entry>
15484 // </row>
15485 // <row>
15486 // <entry>
15487 // <para>
15488 // <literal>a</literal>
15489 // </para>
15490 // </entry>
15491 // <entry>
15492 // <para>
15493 // used as a prefix on another type string to mean an array of
15494 // that type; the type string "<literal>ai</literal>", for
15495 // example, is the type of an array of 32 bit signed integers.
15496 // </para>
15497 // </entry>
15498 // </row>
15499 // <row>
15500 // <entry>
15501 // <para>
15502 // <literal>m</literal>
15503 // </para>
15504 // </entry>
15505 // <entry>
15506 // <para>
15507 // used as a prefix on another type string to mean a "maybe", or
15508 // "nullable", version of that type; the type string
15509 // "<literal>ms</literal>", for example, is the type of a value
15510 // that maybe contains a string, or maybe contains nothing.
15511 // </para>
15512 // </entry>
15513 // </row>
15514 // <row>
15515 // <entry>
15516 // <para>
15517 // <literal>()</literal>
15518 // </para>
15519 // </entry>
15520 // <entry>
15521 // <para>
15522 // used to enclose zero or more other concatenated type strings
15523 // to create a tuple type; the type string
15524 // "<literal>(is)</literal>", for example, is the type of a pair
15525 // of an integer and a string.
15526 // </para>
15527 // </entry>
15528 // </row>
15529 // <row>
15530 // <entry>
15531 // <para>
15532 // <literal>r</literal>
15533 // </para>
15534 // </entry>
15535 // <entry>
15536 // <para>
15537 // the type string of %G_VARIANT_TYPE_TUPLE; an indefinite type
15538 // that is a supertype of any tuple type, regardless of the
15539 // number of items.
15540 // </para>
15541 // </entry>
15542 // </row>
15543 // <row>
15544 // <entry>
15545 // <para>
15546 // <literal>{}</literal>
15547 // </para>
15548 // </entry>
15549 // <entry>
15550 // <para>
15551 // used to enclose a basic type string concatenated with another
15552 // type string to create a dictionary entry type, which usually
15553 // appears inside of an array to form a dictionary; the type
15554 // string "<literal>a{sd}</literal>", for example, is the type of
15555 // a dictionary that maps strings to double precision floating
15556 // point values.
15557 // </para>
15558 // <para>
15559 // The first type (the basic type) is the key type and the second
15560 // type is the value type. The reason that the first type is
15561 // restricted to being a basic type is so that it can easily be
15562 // hashed.
15563 // </para>
15564 // </entry>
15565 // </row>
15566 // <row>
15567 // <entry>
15568 // <para>
15569 // <literal>*</literal>
15570 // </para>
15571 // </entry>
15572 // <entry>
15573 // <para>
15574 // the type string of %G_VARIANT_TYPE_ANY; the indefinite type
15575 // that is a supertype of all types. Note that, as with all type
15576 // strings, this character represents exactly one type. It
15577 // cannot be used inside of tuples to mean "any number of items".
15578 // </para>
15579 // </entry>
15580 // </row>
15581 // </tbody>
15582 // </tgroup>
15583 // </informaltable>
15584 // <para>
15585 // Any type string of a container that contains an indefinite type is,
15586 // itself, an indefinite type. For example, the type string
15587 // "<literal>a*</literal>" (corresponding to %G_VARIANT_TYPE_ARRAY) is
15588 // an indefinite type that is a supertype of every array type.
15589 // "<literal>(*s)</literal>" is a supertype of all tuples that
15590 // contain exactly two items where the second item is a string.
15591 // </para>
15592 // <para>
15593 // "<literal>a{?*}</literal>" is an indefinite type that is a
15594 // supertype of all arrays containing dictionary entries where the key
15595 // is any basic type and the value is any type at all. This is, by
15596 // definition, a dictionary, so this type string corresponds to
15597 // %G_VARIANT_TYPE_DICTIONARY. Note that, due to the restriction that
15598 // the key of a dictionary entry must be a basic type,
15599 // "<literal>{**}</literal>" is not a valid type string.
15600 // </para>
15601 // </refsect2>
15602 struct VariantType {
15604 // VERSION: 2.24
15605 // Creates a new #GVariantType corresponding to the type string given
15606 // by @type_string. It is appropriate to call g_variant_type_free() on
15607 // the return value.
15609 // It is a programmer error to call this function with an invalid type
15610 // string. Use g_variant_type_string_is_valid() if you are unsure.
15611 // RETURNS: a new #GVariantType
15612 // <type_string>: a valid GVariant type string
15613 static VariantType* /*new*/ new_()(char* type_string) nothrow {
15614 return g_variant_type_new(type_string);
15616 alias new_!() opCall;
15618 // Constructs a new tuple type, from @items.
15620 // @length is the number of items in @items, or -1 to indicate that
15621 // @items is %NULL-terminated.
15623 // It is appropriate to call g_variant_type_free() on the return value.
15626 // Since 2.24
15627 // RETURNS: a new tuple #GVariantType
15628 // <items>: an array of #GVariantTypes, one for each item
15629 // <length>: the length of @items, or -1
15630 static VariantType* /*new*/ new_tuple()(VariantType** items, int length) nothrow {
15631 return g_variant_type_new_tuple(items, length);
15633 alias new_tuple!() opCall;
15635 // Makes a copy of a #GVariantType. It is appropriate to call
15636 // g_variant_type_free() on the return value. @type may not be %NULL.
15639 // Since 2.24
15640 // RETURNS: a new #GVariantType
15641 VariantType* /*new*/ copy()() nothrow {
15642 return g_variant_type_copy(&this);
15645 // Returns a newly-allocated copy of the type string corresponding to
15646 // @type. The returned string is nul-terminated. It is appropriate to
15647 // call g_free() on the return value.
15650 // Since 2.24
15651 // RETURNS: the corresponding type string
15652 char* /*new*/ dup_string()() nothrow {
15653 return g_variant_type_dup_string(&this);
15656 // Determines the element type of an array or maybe type.
15658 // This function may only be used with array or maybe types.
15661 // Since 2.24
15662 // RETURNS: the element type of @type
15663 VariantType* element()() nothrow {
15664 return g_variant_type_element(&this);
15667 // Compares @type1 and @type2 for equality.
15669 // Only returns %TRUE if the types are exactly equal. Even if one type
15670 // is an indefinite type and the other is a subtype of it, %FALSE will
15671 // be returned if they are not exactly equal. If you want to check for
15672 // subtypes, use g_variant_type_is_subtype_of().
15674 // The argument types of @type1 and @type2 are only #gconstpointer to
15675 // allow use with #GHashTable without function pointer casting. For
15676 // both arguments, a valid #GVariantType must be provided.
15679 // Since 2.24
15680 // RETURNS: %TRUE if @type1 and @type2 are exactly equal
15681 // <type2>: a #GVariantType
15682 int equal()(const(VariantType)* type2) nothrow {
15683 return g_variant_type_equal(&this, type2);
15686 // Determines the first item type of a tuple or dictionary entry
15687 // type.
15689 // This function may only be used with tuple or dictionary entry types,
15690 // but must not be used with the generic tuple type
15691 // %G_VARIANT_TYPE_TUPLE.
15693 // In the case of a dictionary entry type, this returns the type of
15694 // the key.
15696 // %NULL is returned in case of @type being %G_VARIANT_TYPE_UNIT.
15698 // This call, together with g_variant_type_next() provides an iterator
15699 // interface over tuple and dictionary entry types.
15702 // Since 2.24
15703 // RETURNS: the first item type of @type, or %NULL
15704 VariantType* first()() nothrow {
15705 return g_variant_type_first(&this);
15708 // Frees a #GVariantType that was allocated with
15709 // g_variant_type_copy(), g_variant_type_new() or one of the container
15710 // type constructor functions.
15712 // In the case that @type is %NULL, this function does nothing.
15714 // Since 2.24
15715 void free()() nothrow {
15716 g_variant_type_free(&this);
15719 // Returns the length of the type string corresponding to the given
15720 // @type. This function must be used to determine the valid extent of
15721 // the memory region returned by g_variant_type_peek_string().
15724 // Since 2.24
15725 // RETURNS: the length of the corresponding type string
15726 size_t get_string_length()() nothrow {
15727 return g_variant_type_get_string_length(&this);
15730 // Hashes @type.
15732 // The argument type of @type is only #gconstpointer to allow use with
15733 // #GHashTable without function pointer casting. A valid
15734 // #GVariantType must be provided.
15737 // Since 2.24
15738 // RETURNS: the hash value
15739 uint hash()() nothrow {
15740 return g_variant_type_hash(&this);
15743 // Determines if the given @type is an array type. This is true if the
15744 // type string for @type starts with an 'a'.
15746 // This function returns %TRUE for any indefinite type for which every
15747 // definite subtype is an array type -- %G_VARIANT_TYPE_ARRAY, for
15748 // example.
15751 // Since 2.24
15752 // RETURNS: %TRUE if @type is an array type
15753 int is_array()() nothrow {
15754 return g_variant_type_is_array(&this);
15757 // Determines if the given @type is a basic type.
15759 // Basic types are booleans, bytes, integers, doubles, strings, object
15760 // paths and signatures.
15762 // Only a basic type may be used as the key of a dictionary entry.
15764 // This function returns %FALSE for all indefinite types except
15765 // %G_VARIANT_TYPE_BASIC.
15768 // Since 2.24
15769 // RETURNS: %TRUE if @type is a basic type
15770 int is_basic()() nothrow {
15771 return g_variant_type_is_basic(&this);
15774 // Determines if the given @type is a container type.
15776 // Container types are any array, maybe, tuple, or dictionary
15777 // entry types plus the variant type.
15779 // This function returns %TRUE for any indefinite type for which every
15780 // definite subtype is a container -- %G_VARIANT_TYPE_ARRAY, for
15781 // example.
15784 // Since 2.24
15785 // RETURNS: %TRUE if @type is a container type
15786 int is_container()() nothrow {
15787 return g_variant_type_is_container(&this);
15790 // Determines if the given @type is definite (ie: not indefinite).
15792 // A type is definite if its type string does not contain any indefinite
15793 // type characters ('*', '?', or 'r').
15795 // A #GVariant instance may not have an indefinite type, so calling
15796 // this function on the result of g_variant_get_type() will always
15797 // result in %TRUE being returned. Calling this function on an
15798 // indefinite type like %G_VARIANT_TYPE_ARRAY, however, will result in
15799 // %FALSE being returned.
15802 // Since 2.24
15803 // RETURNS: %TRUE if @type is definite
15804 int is_definite()() nothrow {
15805 return g_variant_type_is_definite(&this);
15808 // Determines if the given @type is a dictionary entry type. This is
15809 // true if the type string for @type starts with a '{'.
15811 // This function returns %TRUE for any indefinite type for which every
15812 // definite subtype is a dictionary entry type --
15813 // %G_VARIANT_TYPE_DICT_ENTRY, for example.
15816 // Since 2.24
15817 // RETURNS: %TRUE if @type is a dictionary entry type
15818 int is_dict_entry()() nothrow {
15819 return g_variant_type_is_dict_entry(&this);
15822 // Determines if the given @type is a maybe type. This is true if the
15823 // type string for @type starts with an 'm'.
15825 // This function returns %TRUE for any indefinite type for which every
15826 // definite subtype is a maybe type -- %G_VARIANT_TYPE_MAYBE, for
15827 // example.
15830 // Since 2.24
15831 // RETURNS: %TRUE if @type is a maybe type
15832 int is_maybe()() nothrow {
15833 return g_variant_type_is_maybe(&this);
15836 // Checks if @type is a subtype of @supertype.
15838 // This function returns %TRUE if @type is a subtype of @supertype. All
15839 // types are considered to be subtypes of themselves. Aside from that,
15840 // only indefinite types can have subtypes.
15843 // Since 2.24
15844 // RETURNS: %TRUE if @type is a subtype of @supertype
15845 // <supertype>: a #GVariantType
15846 int is_subtype_of()(VariantType* supertype) nothrow {
15847 return g_variant_type_is_subtype_of(&this, supertype);
15850 // Determines if the given @type is a tuple type. This is true if the
15851 // type string for @type starts with a '(' or if @type is
15852 // %G_VARIANT_TYPE_TUPLE.
15854 // This function returns %TRUE for any indefinite type for which every
15855 // definite subtype is a tuple type -- %G_VARIANT_TYPE_TUPLE, for
15856 // example.
15859 // Since 2.24
15860 // RETURNS: %TRUE if @type is a tuple type
15861 int is_tuple()() nothrow {
15862 return g_variant_type_is_tuple(&this);
15865 // Determines if the given @type is the variant type.
15868 // Since 2.24
15869 // RETURNS: %TRUE if @type is the variant type
15870 int is_variant()() nothrow {
15871 return g_variant_type_is_variant(&this);
15874 // Determines the key type of a dictionary entry type.
15876 // This function may only be used with a dictionary entry type. Other
15877 // than the additional restriction, this call is equivalent to
15878 // g_variant_type_first().
15881 // Since 2.24
15882 // RETURNS: the key type of the dictionary entry
15883 VariantType* key()() nothrow {
15884 return g_variant_type_key(&this);
15887 // Determines the number of items contained in a tuple or
15888 // dictionary entry type.
15890 // This function may only be used with tuple or dictionary entry types,
15891 // but must not be used with the generic tuple type
15892 // %G_VARIANT_TYPE_TUPLE.
15894 // In the case of a dictionary entry type, this function will always
15895 // return 2.
15898 // Since 2.24
15899 // RETURNS: the number of items in @type
15900 size_t n_items()() nothrow {
15901 return g_variant_type_n_items(&this);
15904 // Constructs the type corresponding to an array of elements of the
15905 // type @type.
15907 // It is appropriate to call g_variant_type_free() on the return value.
15910 // Since 2.24
15911 // RETURNS: a new array #GVariantType
15912 VariantType* /*new*/ new_array()() nothrow {
15913 return g_variant_type_new_array(&this);
15916 // Constructs the type corresponding to a dictionary entry with a key
15917 // of type @key and a value of type @value.
15919 // It is appropriate to call g_variant_type_free() on the return value.
15922 // Since 2.24
15923 // RETURNS: a new dictionary entry #GVariantType
15924 // <value>: a #GVariantType
15925 VariantType* /*new*/ new_dict_entry()(VariantType* value) nothrow {
15926 return g_variant_type_new_dict_entry(&this, value);
15929 // Constructs the type corresponding to a maybe instance containing
15930 // type @type or Nothing.
15932 // It is appropriate to call g_variant_type_free() on the return value.
15935 // Since 2.24
15936 // RETURNS: a new maybe #GVariantType
15937 VariantType* /*new*/ new_maybe()() nothrow {
15938 return g_variant_type_new_maybe(&this);
15941 // Determines the next item type of a tuple or dictionary entry
15942 // type.
15944 // @type must be the result of a previous call to
15945 // g_variant_type_first() or g_variant_type_next().
15947 // If called on the key type of a dictionary entry then this call
15948 // returns the value type. If called on the value type of a dictionary
15949 // entry then this call returns %NULL.
15951 // For tuples, %NULL is returned when @type is the last item in a tuple.
15954 // Since 2.24
15955 // RETURNS: the next #GVariantType after @type, or %NULL
15956 VariantType* next()() nothrow {
15957 return g_variant_type_next(&this);
15960 // Unintrospectable method: peek_string() / g_variant_type_peek_string()
15961 // Returns the type string corresponding to the given @type. The
15962 // result is not nul-terminated; in order to determine its length you
15963 // must call g_variant_type_get_string_length().
15965 // To get a nul-terminated string, see g_variant_type_dup_string().
15968 // Since 2.24
15969 // RETURNS: the corresponding type string (not nul-terminated)
15970 char* peek_string()() nothrow {
15971 return g_variant_type_peek_string(&this);
15974 // Determines the value type of a dictionary entry type.
15976 // This function may only be used with a dictionary entry type.
15979 // Since 2.24
15980 // RETURNS: the value type of the dictionary entry
15981 VariantType* value()() nothrow {
15982 return g_variant_type_value(&this);
15984 static VariantType* checked_()(char* arg_a) nothrow {
15985 return g_variant_type_checked_(arg_a);
15988 // Checks if @type_string is a valid GVariant type string. This call is
15989 // equivalent to calling g_variant_type_string_scan() and confirming
15990 // that the following character is a nul terminator.
15993 // Since 2.24
15994 // RETURNS: %TRUE if @type_string is exactly one valid type string
15995 // <type_string>: a pointer to any string
15996 static int string_is_valid()(char* type_string) nothrow {
15997 return g_variant_type_string_is_valid(type_string);
16000 // VERSION: 2.24
16001 // Scan for a single complete and valid GVariant type string in @string.
16002 // The memory pointed to by @limit (or bytes beyond it) is never
16003 // accessed.
16005 // If a valid type string is found, @endptr is updated to point to the
16006 // first character past the end of the string that was found and %TRUE
16007 // is returned.
16009 // If there is no valid type string starting at @string, or if the type
16010 // string does not end before @limit then %FALSE is returned.
16012 // For the simple case of checking if a string is a valid type string,
16013 // see g_variant_type_string_is_valid().
16014 // RETURNS: %TRUE if a valid type string was found
16015 // <string>: a pointer to any string
16016 // <limit>: the end of @string, or %NULL
16017 // <endptr>: location to store the end pointer, or %NULL
16018 static int string_scan()(char* string_, char* limit=null, /*out*/ char** endptr=null) nothrow {
16019 return g_variant_type_string_scan(string_, limit, endptr);
16024 // Declares a type of function which takes no arguments
16025 // and has no return value. It is used to specify the type
16026 // function passed to g_atexit().
16027 extern (C) alias void function () nothrow VoidFunc;
16029 enum int WIN32_MSG_HANDLE = 19981206;
16031 // VERSION: 2.8
16032 // A wrapper for the POSIX access() function. This function is used to
16033 // test a pathname for one or several of read, write or execute
16034 // permissions, or just existence.
16036 // On Windows, the file protection mechanism is not at all POSIX-like,
16037 // and the underlying function in the C library only checks the
16038 // FAT-style READONLY attribute, and does not look at the ACL of a
16039 // file at all. This function is this in practise almost useless on
16040 // Windows. Software that needs to handle file permissions on Windows
16041 // more exactly should use the Win32 API.
16043 // See your C library manual for more details about access().
16045 // object that has all the tested permissions, or -1 otherwise or on
16046 // error.
16047 // RETURNS: zero if the pathname refers to an existing file system
16048 // <filename>: a pathname in the GLib file name encoding (UTF-8 on Windows)
16049 // <mode>: as in access()
16050 static int access()(char* filename, int mode) nothrow {
16051 return g_access(filename, mode);
16055 // MOVED TO: Array.free
16056 // Frees the memory allocated for the #GArray. If @free_segment is
16057 // %TRUE it frees the memory block holding the elements as well and
16058 // also each element if @array has a @element_free_func set. Pass
16059 // %FALSE if you want to free the #GArray wrapper but preserve the
16060 // underlying array for use elsewhere. If the reference count of @array
16061 // is greater than one, the #GArray wrapper is preserved but the size
16062 // of @array will be set to zero.
16064 // <note><para>If array elements contain dynamically-allocated memory,
16065 // they should be freed separately.</para></note>
16066 // <array>: a #GArray.
16067 // <free_segment>: if %TRUE the actual element data is freed as well.
16068 static char* /*new*/ array_free()(Array* array, int free_segment) nothrow {
16069 return g_array_free(array, free_segment);
16073 // VERSION: 2.22
16074 // MOVED TO: Array.get_element_size
16075 // Gets the size of the elements in @array.
16076 // RETURNS: Size of each element, in bytes.
16077 // <array>: A #GArray.
16078 static uint array_get_element_size()(Array* array) nothrow {
16079 return g_array_get_element_size(array);
16082 // MOVED TO: Array.set_clear_func
16083 static void array_set_clear_func()(Array* array, DestroyNotify clear_func) nothrow {
16084 g_array_set_clear_func(array, clear_func);
16088 // VERSION: 2.22
16089 // MOVED TO: Array.unref
16090 // Atomically decrements the reference count of @array by one. If the
16091 // reference count drops to 0, all memory allocated by the array is
16092 // released. This function is MT-safe and may be called from any
16093 // thread.
16094 // <array>: A #GArray.
16095 static void array_unref()(Array* array) nothrow {
16096 g_array_unref(array);
16100 // Determines the numeric value of a character as a decimal
16101 // digit. Differs from g_unichar_digit_value() because it takes
16102 // a char, so there's no worry about sign extension if characters
16103 // are signed.
16105 // g_ascii_isdigit()), its numeric value. Otherwise, -1.
16106 // RETURNS: If @c is a decimal digit (according to
16107 // <c>: an ASCII character.
16108 static int ascii_digit_value()(char c) nothrow {
16109 return g_ascii_digit_value(c);
16113 // Converts a #gdouble to a string, using the '.' as
16114 // decimal point.
16116 // This functions generates enough precision that converting
16117 // the string back using g_ascii_strtod() gives the same machine-number
16118 // (on machines with IEEE compatible 64bit doubles). It is
16119 // guaranteed that the size of the resulting string will never
16120 // be larger than @G_ASCII_DTOSTR_BUF_SIZE bytes.
16121 // RETURNS: The pointer to the buffer with the converted string.
16122 // <buffer>: A buffer to place the resulting string in
16123 // <buf_len>: The length of the buffer.
16124 // <d>: The #gdouble to convert
16125 static char* /*new*/ ascii_dtostr()(char* buffer, int buf_len, double d) nothrow {
16126 return g_ascii_dtostr(buffer, buf_len, d);
16130 // Converts a #gdouble to a string, using the '.' as
16131 // decimal point. To format the number you pass in
16132 // a printf()-style format string. Allowed conversion
16133 // specifiers are 'e', 'E', 'f', 'F', 'g' and 'G'.
16135 // If you just want to want to serialize the value into a
16136 // string, use g_ascii_dtostr().
16137 // RETURNS: The pointer to the buffer with the converted string.
16138 // <buffer>: A buffer to place the resulting string in
16139 // <buf_len>: The length of the buffer.
16140 // <format>: The printf()-style format to use for the code to use for converting.
16141 // <d>: The #gdouble to convert
16142 static char* /*new*/ ascii_formatd()(char* buffer, int buf_len, char* format, double d) nothrow {
16143 return g_ascii_formatd(buffer, buf_len, format, d);
16147 // Compare two strings, ignoring the case of ASCII characters.
16149 // Unlike the BSD strcasecmp() function, this only recognizes standard
16150 // ASCII letters and ignores the locale, treating all non-ASCII
16151 // bytes as if they are not letters.
16153 // This function should be used only on strings that are known to be
16154 // in encodings where the bytes corresponding to ASCII letters always
16155 // represent themselves. This includes UTF-8 and the ISO-8859-*
16156 // charsets, but not for instance double-byte encodings like the
16157 // Windows Codepage 932, where the trailing bytes of double-byte
16158 // characters include all ASCII letters. If you compare two CP932
16159 // strings using this function, you will get false matches.
16161 // or a positive value if @s1 &gt; @s2.
16162 // RETURNS: 0 if the strings match, a negative value if @s1 &lt; @s2,
16163 // <s1>: string to compare with @s2.
16164 // <s2>: string to compare with @s1.
16165 static int ascii_strcasecmp()(char* s1, char* s2) nothrow {
16166 return g_ascii_strcasecmp(s1, s2);
16170 // Converts all upper case ASCII letters to lower case ASCII letters.
16172 // characters in @str converted to lower case, with
16173 // semantics that exactly match g_ascii_tolower(). (Note
16174 // that this is unlike the old g_strdown(), which modified
16175 // the string in place.)
16176 // RETURNS: a newly-allocated string, with all the upper case
16177 // <str>: a string.
16178 // <len>: length of @str in bytes, or -1 if @str is nul-terminated.
16179 static char* /*new*/ ascii_strdown()(char* str, ssize_t len) nothrow {
16180 return g_ascii_strdown(str, len);
16184 // Compare @s1 and @s2, ignoring the case of ASCII characters and any
16185 // characters after the first @n in each string.
16187 // Unlike the BSD strcasecmp() function, this only recognizes standard
16188 // ASCII letters and ignores the locale, treating all non-ASCII
16189 // characters as if they are not letters.
16191 // The same warning as in g_ascii_strcasecmp() applies: Use this
16192 // function only on strings known to be in encodings where bytes
16193 // corresponding to ASCII letters always represent themselves.
16195 // or a positive value if @s1 &gt; @s2.
16196 // RETURNS: 0 if the strings match, a negative value if @s1 &lt; @s2,
16197 // <s1>: string to compare with @s2.
16198 // <s2>: string to compare with @s1.
16199 // <n>: number of characters to compare.
16200 static int ascii_strncasecmp()(char* s1, char* s2, size_t n) nothrow {
16201 return g_ascii_strncasecmp(s1, s2, n);
16205 // Converts a string to a #gdouble value.
16207 // This function behaves like the standard strtod() function
16208 // does in the C locale. It does this without actually changing
16209 // the current locale, since that would not be thread-safe.
16210 // A limitation of the implementation is that this function
16211 // will still accept localized versions of infinities and NANs.
16213 // This function is typically used when reading configuration
16214 // files or other non-user input that should be locale independent.
16215 // To handle input from the user you should normally use the
16216 // locale-sensitive system strtod() function.
16218 // To convert from a #gdouble to a string in a locale-insensitive
16219 // way, use g_ascii_dtostr().
16221 // If the correct value would cause overflow, plus or minus <literal>HUGE_VAL</literal>
16222 // is returned (according to the sign of the value), and <literal>ERANGE</literal> is
16223 // stored in <literal>errno</literal>. If the correct value would cause underflow,
16224 // zero is returned and <literal>ERANGE</literal> is stored in <literal>errno</literal>.
16226 // This function resets <literal>errno</literal> before calling strtod() so that
16227 // you can reliably detect overflow and underflow.
16228 // RETURNS: the #gdouble value.
16229 // <nptr>: the string to convert to a numeric value.
16230 // <endptr>: if non-%NULL, it returns the character after the last character used in the conversion.
16231 static double ascii_strtod()(char* nptr, char** endptr) nothrow {
16232 return g_ascii_strtod(nptr, endptr);
16236 // VERSION: 2.12
16237 // Converts a string to a #gint64 value.
16238 // This function behaves like the standard strtoll() function
16239 // does in the C locale. It does this without actually
16240 // changing the current locale, since that would not be
16241 // thread-safe.
16243 // This function is typically used when reading configuration
16244 // files or other non-user input that should be locale independent.
16245 // To handle input from the user you should normally use the
16246 // locale-sensitive system strtoll() function.
16248 // If the correct value would cause overflow, %G_MAXINT64 or %G_MININT64
16249 // is returned, and <literal>ERANGE</literal> is stored in <literal>errno</literal>.
16250 // If the base is outside the valid range, zero is returned, and
16251 // <literal>EINVAL</literal> is stored in <literal>errno</literal>. If the
16252 // string conversion fails, zero is returned, and @endptr returns @nptr
16253 // (if @endptr is non-%NULL).
16254 // RETURNS: the #gint64 value or zero on error.
16255 // <nptr>: the string to convert to a numeric value.
16256 // <endptr>: if non-%NULL, it returns the character after the last character used in the conversion.
16257 // <base>: to be used for the conversion, 2..36 or 0
16258 static long ascii_strtoll()(char* nptr, char** endptr, uint base) nothrow {
16259 return g_ascii_strtoll(nptr, endptr, base);
16263 // VERSION: 2.2
16264 // Converts a string to a #guint64 value.
16265 // This function behaves like the standard strtoull() function
16266 // does in the C locale. It does this without actually
16267 // changing the current locale, since that would not be
16268 // thread-safe.
16270 // This function is typically used when reading configuration
16271 // files or other non-user input that should be locale independent.
16272 // To handle input from the user you should normally use the
16273 // locale-sensitive system strtoull() function.
16275 // If the correct value would cause overflow, %G_MAXUINT64
16276 // is returned, and <literal>ERANGE</literal> is stored in <literal>errno</literal>.
16277 // If the base is outside the valid range, zero is returned, and
16278 // <literal>EINVAL</literal> is stored in <literal>errno</literal>.
16279 // If the string conversion fails, zero is returned, and @endptr returns
16280 // @nptr (if @endptr is non-%NULL).
16281 // RETURNS: the #guint64 value or zero on error.
16282 // <nptr>: the string to convert to a numeric value.
16283 // <endptr>: if non-%NULL, it returns the character after the last character used in the conversion.
16284 // <base>: to be used for the conversion, 2..36 or 0
16285 static ulong ascii_strtoull()(char* nptr, char** endptr, uint base) nothrow {
16286 return g_ascii_strtoull(nptr, endptr, base);
16290 // Converts all lower case ASCII letters to upper case ASCII letters.
16292 // characters in @str converted to upper case, with
16293 // semantics that exactly match g_ascii_toupper(). (Note
16294 // that this is unlike the old g_strup(), which modified
16295 // the string in place.)
16296 // RETURNS: a newly allocated string, with all the lower case
16297 // <str>: a string.
16298 // <len>: length of @str in bytes, or -1 if @str is nul-terminated.
16299 static char* /*new*/ ascii_strup()(char* str, ssize_t len) nothrow {
16300 return g_ascii_strup(str, len);
16304 // Convert a character to ASCII lower case.
16306 // Unlike the standard C library tolower() function, this only
16307 // recognizes standard ASCII letters and ignores the locale, returning
16308 // all non-ASCII characters unchanged, even if they are lower case
16309 // letters in a particular character set. Also unlike the standard
16310 // library function, this takes and returns a char, not an int, so
16311 // don't call it on <literal>EOF</literal> but no need to worry about casting to #guchar
16312 // before passing a possibly non-ASCII character in.
16314 // If @c is not an ASCII upper case letter,
16315 // @c is returned unchanged.
16316 // RETURNS: the result of converting @c to lower case.
16317 // <c>: any character.
16318 static char ascii_tolower()(char c) nothrow {
16319 return g_ascii_tolower(c);
16323 // Convert a character to ASCII upper case.
16325 // Unlike the standard C library toupper() function, this only
16326 // recognizes standard ASCII letters and ignores the locale, returning
16327 // all non-ASCII characters unchanged, even if they are upper case
16328 // letters in a particular character set. Also unlike the standard
16329 // library function, this takes and returns a char, not an int, so
16330 // don't call it on <literal>EOF</literal> but no need to worry about casting to #guchar
16331 // before passing a possibly non-ASCII character in.
16333 // If @c is not an ASCII lower case letter,
16334 // @c is returned unchanged.
16335 // RETURNS: the result of converting @c to upper case.
16336 // <c>: any character.
16337 static char ascii_toupper()(char c) nothrow {
16338 return g_ascii_toupper(c);
16342 // Determines the numeric value of a character as a hexidecimal
16343 // digit. Differs from g_unichar_xdigit_value() because it takes
16344 // a char, so there's no worry about sign extension if characters
16345 // are signed.
16347 // g_ascii_isxdigit()), its numeric value. Otherwise, -1.
16348 // RETURNS: If @c is a hex digit (according to
16349 // <c>: an ASCII character.
16350 static int ascii_xdigit_value()(char c) nothrow {
16351 return g_ascii_xdigit_value(c);
16354 static void assert_warning()(char* log_domain, char* file, int line, char* pretty_function, char* expression) nothrow {
16355 g_assert_warning(log_domain, file, line, pretty_function, expression);
16358 static void assertion_message()(char* domain, char* file, int line, char* func, char* message) nothrow {
16359 g_assertion_message(domain, file, line, func, message);
16362 // Unintrospectable function: assertion_message_cmpnum() / g_assertion_message_cmpnum()
16363 static void assertion_message_cmpnum()(char* domain, char* file, int line, char* func, char* expr, real arg1, char* cmp, real arg2, char numtype) nothrow {
16364 g_assertion_message_cmpnum(domain, file, line, func, expr, arg1, cmp, arg2, numtype);
16367 static void assertion_message_cmpstr()(char* domain, char* file, int line, char* func, char* expr, char* arg1, char* cmp, char* arg2) nothrow {
16368 g_assertion_message_cmpstr(domain, file, line, func, expr, arg1, cmp, arg2);
16371 static void assertion_message_error()(char* domain, char* file, int line, char* func, char* expr, Error* error, Quark error_domain, int error_code) nothrow {
16372 g_assertion_message_error(domain, file, line, func, expr, error, error_domain, error_code);
16375 static void assertion_message_expr()(char* domain, char* file, int line, char* func, char* expr) nothrow {
16376 g_assertion_message_expr(domain, file, line, func, expr);
16380 // Specifies a function to be called at normal program termination.
16382 // Since GLib 2.8.2, on Windows g_atexit() actually is a preprocessor
16383 // macro that maps to a call to the atexit() function in the C
16384 // library. This means that in case the code that calls g_atexit(),
16385 // i.e. atexit(), is in a DLL, the function will be called when the
16386 // DLL is detached from the program. This typically makes more sense
16387 // than that the function is called when the GLib DLL is detached,
16388 // which happened earlier when g_atexit() was a function in the GLib
16389 // DLL.
16391 // The behaviour of atexit() in the context of dynamically loaded
16392 // modules is not formally specified and varies wildly.
16394 // On POSIX systems, calling g_atexit() (or atexit()) in a dynamically
16395 // loaded module which is unloaded before the program terminates might
16396 // well cause a crash at program exit.
16398 // Some POSIX systems implement atexit() like Windows, and have each
16399 // dynamically loaded module maintain an own atexit chain that is
16400 // called when the module is unloaded.
16402 // On other POSIX systems, before a dynamically loaded module is
16403 // unloaded, the registered atexit functions (if any) residing in that
16404 // module are called, regardless where the code that registered them
16405 // resided. This is presumably the most robust approach.
16407 // As can be seen from the above, for portability it's best to avoid
16408 // calling g_atexit() (or atexit()) except in the main executable of a
16409 // program.
16411 // Deprecated:2.32: It is best to avoid g_atexit().
16412 // <func>: the function to call on normal program termination.
16413 static void atexit()(VoidFunc func) nothrow {
16414 g_atexit(func);
16418 // VERSION: 2.4
16419 // Atomically adds @val to the value of @atomic.
16421 // Think of this operation as an atomic version of
16422 // <literal>{ tmp = *atomic; *@atomic += @val; return tmp; }</literal>
16424 // This call acts as a full compiler and hardware memory barrier.
16426 // Before version 2.30, this function did not return a value
16427 // (but g_atomic_int_exchange_and_add() did, and had the same meaning).
16428 // RETURNS: the value of @atomic before the add, signed
16429 // <atomic>: a pointer to a #gint or #guint
16430 // <val>: the value to add
16431 static int atomic_int_add()(int* atomic, int val) nothrow {
16432 return g_atomic_int_add(atomic, val);
16436 // VERSION: 2.30
16437 // Performs an atomic bitwise 'and' of the value of @atomic and @val,
16438 // storing the result back in @atomic.
16440 // This call acts as a full compiler and hardware memory barrier.
16442 // Think of this operation as an atomic version of
16443 // <literal>{ tmp = *atomic; *@atomic &= @val; return tmp; }</literal>
16444 // RETURNS: the value of @atomic before the operation, unsigned
16445 // <atomic>: a pointer to a #gint or #guint
16446 // <val>: the value to 'and'
16447 static uint atomic_int_and()(uint* atomic, uint val) nothrow {
16448 return g_atomic_int_and(atomic, val);
16452 // VERSION: 2.4
16453 // Compares @atomic to @oldval and, if equal, sets it to @newval.
16454 // If @atomic was not equal to @oldval then no change occurs.
16456 // This compare and exchange is done atomically.
16458 // Think of this operation as an atomic version of
16459 // <literal>{ if (*@atomic == @oldval) { *@atomic = @newval; return TRUE; } else return FALSE; }</literal>
16461 // This call acts as a full compiler and hardware memory barrier.
16462 // RETURNS: %TRUE if the exchange took place
16463 // <atomic>: a pointer to a #gint or #guint
16464 // <oldval>: the value to compare with
16465 // <newval>: the value to conditionally replace with
16466 static int atomic_int_compare_and_exchange()(int* atomic, int oldval, int newval) nothrow {
16467 return g_atomic_int_compare_and_exchange(atomic, oldval, newval);
16471 // VERSION: 2.4
16472 // Decrements the value of @atomic by 1.
16474 // Think of this operation as an atomic version of
16475 // <literal>{ *@atomic -= 1; return (*@atomic == 0); }</literal>
16477 // This call acts as a full compiler and hardware memory barrier.
16478 // RETURNS: %TRUE if the resultant value is zero
16479 // <atomic>: a pointer to a #gint or #guint
16480 static int atomic_int_dec_and_test()(int* atomic) nothrow {
16481 return g_atomic_int_dec_and_test(atomic);
16485 // VERSION: 2.4
16486 // DEPRECATED (v2.30) function: atomic_int_exchange_and_add - Use g_atomic_int_add() instead.
16487 // This function existed before g_atomic_int_add() returned the prior
16488 // value of the integer (which it now does). It is retained only for
16489 // compatibility reasons. Don't use this function in new code.
16490 // RETURNS: the value of @atomic before the add, signed
16491 // <atomic>: a pointer to a #gint
16492 // <val>: the value to add
16493 static int atomic_int_exchange_and_add()(int* atomic, int val) nothrow {
16494 return g_atomic_int_exchange_and_add(atomic, val);
16498 // VERSION: 2.4
16499 // Gets the current value of @atomic.
16501 // This call acts as a full compiler and hardware
16502 // memory barrier (before the get).
16503 // RETURNS: the value of the integer
16504 // <atomic>: a pointer to a #gint or #guint
16505 static int atomic_int_get()(int* atomic) nothrow {
16506 return g_atomic_int_get(atomic);
16510 // VERSION: 2.4
16511 // Increments the value of @atomic by 1.
16513 // Think of this operation as an atomic version of
16514 // <literal>{ *@atomic += 1; }</literal>
16516 // This call acts as a full compiler and hardware memory barrier.
16517 // <atomic>: a pointer to a #gint or #guint
16518 static void atomic_int_inc()(int* atomic) nothrow {
16519 g_atomic_int_inc(atomic);
16523 // VERSION: 2.30
16524 // Performs an atomic bitwise 'or' of the value of @atomic and @val,
16525 // storing the result back in @atomic.
16527 // Think of this operation as an atomic version of
16528 // <literal>{ tmp = *atomic; *@atomic |= @val; return tmp; }</literal>
16530 // This call acts as a full compiler and hardware memory barrier.
16531 // RETURNS: the value of @atomic before the operation, unsigned
16532 // <atomic>: a pointer to a #gint or #guint
16533 // <val>: the value to 'or'
16534 static uint atomic_int_or()(uint* atomic, uint val) nothrow {
16535 return g_atomic_int_or(atomic, val);
16539 // VERSION: 2.4
16540 // Sets the value of @atomic to @newval.
16542 // This call acts as a full compiler and hardware
16543 // memory barrier (after the set).
16544 // <atomic>: a pointer to a #gint or #guint
16545 // <newval>: a new value to store
16546 static void atomic_int_set()(int* atomic, int newval) nothrow {
16547 g_atomic_int_set(atomic, newval);
16551 // VERSION: 2.30
16552 // Performs an atomic bitwise 'xor' of the value of @atomic and @val,
16553 // storing the result back in @atomic.
16555 // Think of this operation as an atomic version of
16556 // <literal>{ tmp = *atomic; *@atomic ^= @val; return tmp; }</literal>
16558 // This call acts as a full compiler and hardware memory barrier.
16559 // RETURNS: the value of @atomic before the operation, unsigned
16560 // <atomic>: a pointer to a #gint or #guint
16561 // <val>: the value to 'xor'
16562 static uint atomic_int_xor()(uint* atomic, uint val) nothrow {
16563 return g_atomic_int_xor(atomic, val);
16567 // VERSION: 2.30
16568 // Atomically adds @val to the value of @atomic.
16570 // Think of this operation as an atomic version of
16571 // <literal>{ tmp = *atomic; *@atomic += @val; return tmp; }</literal>
16573 // This call acts as a full compiler and hardware memory barrier.
16574 // RETURNS: the value of @atomic before the add, signed
16575 // <atomic>: a pointer to a #gpointer-sized value
16576 // <val>: the value to add
16577 static ssize_t atomic_pointer_add()(void* atomic, ssize_t val) nothrow {
16578 return g_atomic_pointer_add(atomic, val);
16582 // VERSION: 2.30
16583 // Performs an atomic bitwise 'and' of the value of @atomic and @val,
16584 // storing the result back in @atomic.
16586 // Think of this operation as an atomic version of
16587 // <literal>{ tmp = *atomic; *@atomic &= @val; return tmp; }</literal>
16589 // This call acts as a full compiler and hardware memory barrier.
16590 // RETURNS: the value of @atomic before the operation, unsigned
16591 // <atomic>: a pointer to a #gpointer-sized value
16592 // <val>: the value to 'and'
16593 static size_t atomic_pointer_and()(void* atomic, size_t val) nothrow {
16594 return g_atomic_pointer_and(atomic, val);
16598 // VERSION: 2.4
16599 // Compares @atomic to @oldval and, if equal, sets it to @newval.
16600 // If @atomic was not equal to @oldval then no change occurs.
16602 // This compare and exchange is done atomically.
16604 // Think of this operation as an atomic version of
16605 // <literal>{ if (*@atomic == @oldval) { *@atomic = @newval; return TRUE; } else return FALSE; }</literal>
16607 // This call acts as a full compiler and hardware memory barrier.
16608 // RETURNS: %TRUE if the exchange took place
16609 // <atomic>: a pointer to a #gpointer-sized value
16610 // <oldval>: the value to compare with
16611 // <newval>: the value to conditionally replace with
16612 static int atomic_pointer_compare_and_exchange()(void* atomic, void* oldval, void* newval) nothrow {
16613 return g_atomic_pointer_compare_and_exchange(atomic, oldval, newval);
16617 // Unintrospectable function: atomic_pointer_get() / g_atomic_pointer_get()
16618 // VERSION: 2.4
16619 // Gets the current value of @atomic.
16621 // This call acts as a full compiler and hardware
16622 // memory barrier (before the get).
16623 // RETURNS: the value of the pointer
16624 // <atomic>: a pointer to a #gpointer-sized value
16625 static void* atomic_pointer_get()(void* atomic) nothrow {
16626 return g_atomic_pointer_get(atomic);
16630 // VERSION: 2.30
16631 // Performs an atomic bitwise 'or' of the value of @atomic and @val,
16632 // storing the result back in @atomic.
16634 // Think of this operation as an atomic version of
16635 // <literal>{ tmp = *atomic; *@atomic |= @val; return tmp; }</literal>
16637 // This call acts as a full compiler and hardware memory barrier.
16638 // RETURNS: the value of @atomic before the operation, unsigned
16639 // <atomic>: a pointer to a #gpointer-sized value
16640 // <val>: the value to 'or'
16641 static size_t atomic_pointer_or()(void* atomic, size_t val) nothrow {
16642 return g_atomic_pointer_or(atomic, val);
16646 // VERSION: 2.4
16647 // Sets the value of @atomic to @newval.
16649 // This call acts as a full compiler and hardware
16650 // memory barrier (after the set).
16651 // <atomic>: a pointer to a #gpointer-sized value
16652 // <newval>: a new value to store
16653 static void atomic_pointer_set()(void* atomic, void* newval) nothrow {
16654 g_atomic_pointer_set(atomic, newval);
16658 // VERSION: 2.30
16659 // Performs an atomic bitwise 'xor' of the value of @atomic and @val,
16660 // storing the result back in @atomic.
16662 // Think of this operation as an atomic version of
16663 // <literal>{ tmp = *atomic; *@atomic ^= @val; return tmp; }</literal>
16665 // This call acts as a full compiler and hardware memory barrier.
16666 // RETURNS: the value of @atomic before the operation, unsigned
16667 // <atomic>: a pointer to a #gpointer-sized value
16668 // <val>: the value to 'xor'
16669 static size_t atomic_pointer_xor()(void* atomic, size_t val) nothrow {
16670 return g_atomic_pointer_xor(atomic, val);
16674 // VERSION: 2.12
16675 // Decode a sequence of Base-64 encoded text into binary data
16677 // newly allocated buffer containing the binary data
16678 // that @text represents. The returned buffer must
16679 // be freed with g_free().
16680 // <text>: zero-terminated string with base64 text to decode
16681 // <out_len>: The length of the decoded data is written here
16682 static ubyte* /*new*/ base64_decode()(char* text, /*out*/ size_t* out_len) nothrow {
16683 return g_base64_decode(text, out_len);
16687 // VERSION: 2.20
16688 // Decode a sequence of Base-64 encoded text into binary data
16689 // by overwriting the input data.
16691 // is the same as the input @text.
16692 // RETURNS: The binary data that @text responds. This pointer
16693 // <text>: zero-terminated string with base64 text to decode
16694 // <out_len>: The length of the decoded data is written here
16695 static ubyte* base64_decode_inplace()(/*inout*/ ubyte* text, /*inout*/ size_t* out_len) nothrow {
16696 return g_base64_decode_inplace(text, out_len);
16700 // VERSION: 2.12
16701 // Incrementally decode a sequence of binary data from its Base-64 stringified
16702 // representation. By calling this function multiple times you can convert
16703 // data in chunks to avoid having to have the full encoded data in memory.
16705 // The output buffer must be large enough to fit all the data that will
16706 // be written to it. Since base64 encodes 3 bytes in 4 chars you need
16707 // at least: (@len / 4) * 3 + 3 bytes (+ 3 may be needed in case of non-zero
16708 // state).
16709 // RETURNS: The number of bytes of output that was written
16710 // <in>: binary input data
16711 // <len>: max length of @in data to decode
16712 // <out>: output buffer
16713 // <state>: Saved state between steps, initialize to 0
16714 // <save>: Saved state between steps, initialize to 0
16715 static size_t base64_decode_step()(ubyte* in_, size_t len, /*out*/ ubyte* out_, /*inout*/ int* state, /*inout*/ uint* save) nothrow {
16716 return g_base64_decode_step(in_, len, out_, state, save);
16720 // VERSION: 2.12
16721 // Encode a sequence of binary data into its Base-64 stringified
16722 // representation.
16724 // encoded string representing @data. The returned string must
16725 // be freed with g_free().
16726 // RETURNS: a newly allocated, zero-terminated Base-64
16727 // <data>: the binary data to encode
16728 // <len>: the length of @data
16729 static char* /*new*/ base64_encode()(ubyte* data, size_t len) nothrow {
16730 return g_base64_encode(data, len);
16734 // VERSION: 2.12
16735 // Flush the status from a sequence of calls to g_base64_encode_step().
16737 // The output buffer must be large enough to fit all the data that will
16738 // be written to it. It will need up to 4 bytes, or up to 5 bytes if
16739 // line-breaking is enabled.
16740 // RETURNS: The number of bytes of output that was written
16741 // <break_lines>: whether to break long lines
16742 // <out>: pointer to destination buffer
16743 // <state>: Saved state from g_base64_encode_step()
16744 // <save>: Saved state from g_base64_encode_step()
16745 static size_t base64_encode_close()(int break_lines, /*out*/ ubyte* out_, /*inout*/ int* state, /*inout*/ int* save) nothrow {
16746 return g_base64_encode_close(break_lines, out_, state, save);
16750 // VERSION: 2.12
16751 // Incrementally encode a sequence of binary data into its Base-64 stringified
16752 // representation. By calling this function multiple times you can convert
16753 // data in chunks to avoid having to have the full encoded data in memory.
16755 // When all of the data has been converted you must call
16756 // g_base64_encode_close() to flush the saved state.
16758 // The output buffer must be large enough to fit all the data that will
16759 // be written to it. Due to the way base64 encodes you will need
16760 // at least: (@len / 3 + 1) * 4 + 4 bytes (+ 4 may be needed in case of
16761 // non-zero state). If you enable line-breaking you will need at least:
16762 // ((@len / 3 + 1) * 4 + 4) / 72 + 1 bytes of extra space.
16764 // @break_lines is typically used when putting base64-encoded data in emails.
16765 // It breaks the lines at 72 columns instead of putting all of the text on
16766 // the same line. This avoids problems with long lines in the email system.
16767 // Note however that it breaks the lines with <literal>LF</literal>
16768 // characters, not <literal>CR LF</literal> sequences, so the result cannot
16769 // be passed directly to SMTP or certain other protocols.
16770 // RETURNS: The number of bytes of output that was written
16771 // <in>: the binary data to encode
16772 // <len>: the length of @in
16773 // <break_lines>: whether to break long lines
16774 // <out>: pointer to destination buffer
16775 // <state>: Saved state between steps, initialize to 0
16776 // <save>: Saved state between steps, initialize to 0
16777 static size_t base64_encode_step()(ubyte* in_, size_t len, int break_lines, /*out*/ ubyte* out_, /*inout*/ int* state, /*inout*/ int* save) nothrow {
16778 return g_base64_encode_step(in_, len, break_lines, out_, state, save);
16782 // Gets the name of the file without any leading directory
16783 // components. It returns a pointer into the given file name
16784 // string.
16786 // directory components
16788 // Deprecated:2.2: Use g_path_get_basename() instead, but notice
16789 // that g_path_get_basename() allocates new memory for the
16790 // returned string, unlike this function which returns a pointer
16791 // into the argument.
16792 // RETURNS: the name of the file without any leading
16793 // <file_name>: the name of the file
16794 static char* basename()(char* file_name) nothrow {
16795 return g_basename(file_name);
16799 // VERSION: 2.24
16800 // Sets the indicated @lock_bit in @address. If the bit is already
16801 // set, this call will block until g_bit_unlock() unsets the
16802 // corresponding bit.
16804 // Attempting to lock on two different bits within the same integer is
16805 // not supported and will very probably cause deadlocks.
16807 // The value of the bit that is set is (1u << @bit). If @bit is not
16808 // between 0 and 31 then the result is undefined.
16810 // This function accesses @address atomically. All other accesses to
16811 // @address must be atomic in order for this function to work
16812 // reliably.
16813 // <address>: a pointer to an integer
16814 // <lock_bit>: a bit value between 0 and 31
16815 static void bit_lock()(int* address, int lock_bit) nothrow {
16816 g_bit_lock(address, lock_bit);
16820 // Find the position of the first bit set in @mask, searching
16821 // from (but not including) @nth_bit upwards. Bits are numbered
16822 // from 0 (least significant) to sizeof(#gulong) * 8 - 1 (31 or 63,
16823 // usually). To start searching from the 0th bit, set @nth_bit to -1.
16824 // RETURNS: the index of the first bit set which is higher than @nth_bit
16825 // <mask>: a #gulong containing flags
16826 // <nth_bit>: the index of the bit to start the search from
16827 static int bit_nth_lsf()(c_ulong mask, int nth_bit) nothrow {
16828 return g_bit_nth_lsf(mask, nth_bit);
16832 // Find the position of the first bit set in @mask, searching
16833 // from (but not including) @nth_bit downwards. Bits are numbered
16834 // from 0 (least significant) to sizeof(#gulong) * 8 - 1 (31 or 63,
16835 // usually). To start searching from the last bit, set @nth_bit to
16836 // -1 or GLIB_SIZEOF_LONG * 8.
16837 // RETURNS: the index of the first bit set which is lower than @nth_bit
16838 // <mask>: a #gulong containing flags
16839 // <nth_bit>: the index of the bit to start the search from
16840 static int bit_nth_msf()(c_ulong mask, int nth_bit) nothrow {
16841 return g_bit_nth_msf(mask, nth_bit);
16845 // Gets the number of bits used to hold @number,
16846 // e.g. if @number is 4, 3 bits are needed.
16847 // RETURNS: the number of bits used to hold @number
16848 // <number>: a #guint
16849 static uint bit_storage()(c_ulong number) nothrow {
16850 return g_bit_storage(number);
16854 // VERSION: 2.24
16855 // Sets the indicated @lock_bit in @address, returning %TRUE if
16856 // successful. If the bit is already set, returns %FALSE immediately.
16858 // Attempting to lock on two different bits within the same integer is
16859 // not supported.
16861 // The value of the bit that is set is (1u << @bit). If @bit is not
16862 // between 0 and 31 then the result is undefined.
16864 // This function accesses @address atomically. All other accesses to
16865 // @address must be atomic in order for this function to work
16866 // reliably.
16867 // RETURNS: %TRUE if the lock was acquired
16868 // <address>: a pointer to an integer
16869 // <lock_bit>: a bit value between 0 and 31
16870 static int bit_trylock()(int* address, int lock_bit) nothrow {
16871 return g_bit_trylock(address, lock_bit);
16875 // VERSION: 2.24
16876 // Clears the indicated @lock_bit in @address. If another thread is
16877 // currently blocked in g_bit_lock() on this same bit then it will be
16878 // woken up.
16880 // This function accesses @address atomically. All other accesses to
16881 // @address must be atomic in order for this function to work
16882 // reliably.
16883 // <address>: a pointer to an integer
16884 // <lock_bit>: a bit value between 0 and 31
16885 static void bit_unlock()(int* address, int lock_bit) nothrow {
16886 g_bit_unlock(address, lock_bit);
16889 // MOVED TO: BookmarkFile.error_quark
16890 static Quark bookmark_file_error_quark()() nothrow {
16891 return g_bookmark_file_error_quark();
16895 // Unintrospectable function: build_filename() / g_build_filename()
16896 // Creates a filename from a series of elements using the correct
16897 // separator for filenames.
16899 // On Unix, this function behaves identically to <literal>g_build_path
16900 // (G_DIR_SEPARATOR_S, first_element, ....)</literal>.
16902 // On Windows, it takes into account that either the backslash
16903 // (<literal>\</literal> or slash (<literal>/</literal>) can be used
16904 // as separator in filenames, but otherwise behaves as on Unix. When
16905 // file pathname separators need to be inserted, the one that last
16906 // previously occurred in the parameters (reading from left to right)
16907 // is used.
16909 // No attempt is made to force the resulting filename to be an absolute
16910 // path. If the first element is a relative path, the result will
16911 // be a relative path.
16912 // RETURNS: a newly-allocated string that must be freed with g_free().
16913 // <first_element>: the first element in the path
16914 alias g_build_filename build_filename; // Variadic
16917 // VERSION: 2.8
16918 // Behaves exactly like g_build_filename(), but takes the path elements
16919 // as a string array, instead of varargs. This function is mainly
16920 // meant for language bindings.
16921 // RETURNS: a newly-allocated string that must be freed with g_free().
16922 // <args>: %NULL-terminated array of strings containing the path elements.
16923 static char* /*new*/ build_filenamev()(char** args) nothrow {
16924 return g_build_filenamev(args);
16928 // Unintrospectable function: build_path() / g_build_path()
16929 // Creates a path from a series of elements using @separator as the
16930 // separator between elements. At the boundary between two elements,
16931 // any trailing occurrences of separator in the first element, or
16932 // leading occurrences of separator in the second element are removed
16933 // and exactly one copy of the separator is inserted.
16935 // Empty elements are ignored.
16937 // The number of leading copies of the separator on the result is
16938 // the same as the number of leading copies of the separator on
16939 // the first non-empty element.
16941 // The number of trailing copies of the separator on the result is
16942 // the same as the number of trailing copies of the separator on
16943 // the last non-empty element. (Determination of the number of
16944 // trailing copies is done without stripping leading copies, so
16945 // if the separator is <literal>ABA</literal>, <literal>ABABA</literal>
16946 // has 1 trailing copy.)
16948 // However, if there is only a single non-empty element, and there
16949 // are no characters in that element not part of the leading or
16950 // trailing separators, then the result is exactly the original value
16951 // of that element.
16953 // Other than for determination of the number of leading and trailing
16954 // copies of the separator, elements consisting only of copies
16955 // of the separator are ignored.
16956 // RETURNS: a newly-allocated string that must be freed with g_free().
16957 // <separator>: a string used to separator the elements of the path.
16958 // <first_element>: the first element in the path
16959 alias g_build_path build_path; // Variadic
16962 // VERSION: 2.8
16963 // Behaves exactly like g_build_path(), but takes the path elements
16964 // as a string array, instead of varargs. This function is mainly
16965 // meant for language bindings.
16966 // RETURNS: a newly-allocated string that must be freed with g_free().
16967 // <separator>: a string used to separator the elements of the path.
16968 // <args>: %NULL-terminated array of strings containing the path elements.
16969 static char* /*new*/ build_pathv()(char* separator, char** args) nothrow {
16970 return g_build_pathv(separator, args);
16974 // MOVED TO: ByteArray.free
16975 // Frees the memory allocated by the #GByteArray. If @free_segment is
16976 // %TRUE it frees the actual byte data. If the reference count of
16977 // @array is greater than one, the #GByteArray wrapper is preserved but
16978 // the size of @array will be set to zero.
16979 // <array>: a #GByteArray.
16980 // <free_segment>: if %TRUE the actual byte data is freed as well.
16981 static ubyte* byte_array_free()(ByteArray* array, int free_segment) nothrow {
16982 return g_byte_array_free(array, free_segment);
16986 // VERSION: 2.32
16987 // MOVED TO: ByteArray.free_to_bytes
16988 // Transfers the data from the #GByteArray into a new immutable #GBytes.
16990 // The #GByteArray is freed unless the reference count of @array is greater
16991 // than one, the #GByteArray wrapper is preserved but the size of @array
16992 // will be set to zero.
16994 // This is identical to using g_bytes_new_take() and g_byte_array_free()
16995 // together.
16998 // data that was in the array
16999 // RETURNS: a new immutable #GBytes representing same byte
17000 // <array>: a #GByteArray
17001 static Bytes* /*new*/ byte_array_free_to_bytes()(ByteArray* array) nothrow {
17002 return g_byte_array_free_to_bytes(array);
17006 // VERSION: 2.32
17007 // MOVED TO: ByteArray.new_take
17008 // Create byte array containing the data. The data will be owned by the array
17009 // and will be freed with g_free(), i.e. it could be allocated using g_strdup().
17010 // RETURNS: a new #GByteArray
17011 // <data>: byte data for the array
17012 // <len>: length of @data
17013 static ByteArray* /*new*/ byte_array_new_take()(ubyte* data, size_t len) nothrow {
17014 return g_byte_array_new_take(data, len);
17018 // VERSION: 2.22
17019 // MOVED TO: ByteArray.unref
17020 // Atomically decrements the reference count of @array by one. If the
17021 // reference count drops to 0, all memory allocated by the array is
17022 // released. This function is MT-safe and may be called from any
17023 // thread.
17024 // <array>: A #GByteArray.
17025 static void byte_array_unref()(ByteArray* array) nothrow {
17026 g_byte_array_unref(array);
17030 // VERSION: 2.8
17031 // A wrapper for the POSIX chdir() function. The function changes the
17032 // current directory of the process to @path.
17034 // See your C library manual for more details about chdir().
17035 // RETURNS: 0 on success, -1 if an error occurred.
17036 // <path>: a pathname in the GLib file name encoding (UTF-8 on Windows)
17037 static int chdir()(char* path) nothrow {
17038 return g_chdir(path);
17042 // VERSION: 2.6
17043 // Checks that the GLib library in use is compatible with the
17044 // given version. Generally you would pass in the constants
17045 // #GLIB_MAJOR_VERSION, #GLIB_MINOR_VERSION, #GLIB_MICRO_VERSION
17046 // as the three arguments to this function; that produces
17047 // a check that the library in use is compatible with
17048 // the version of GLib the application or module was compiled
17049 // against.
17051 // Compatibility is defined by two things: first the version
17052 // of the running library is newer than the version
17053 // @required_major.required_minor.@required_micro. Second
17054 // the running library must be binary compatible with the
17055 // version @required_major.required_minor.@required_micro
17056 // (same major version.)
17058 // given version, or a string describing the version mismatch.
17059 // The returned string is owned by GLib and must not be modified
17060 // or freed.
17061 // RETURNS: %NULL if the GLib library is compatible with the
17062 // <required_major>: the required major version.
17063 // <required_minor>: the required minor version.
17064 // <required_micro>: the required micro version.
17065 static char* check_version()(uint required_major, uint required_minor, uint required_micro) nothrow {
17066 return glib_check_version(required_major, required_minor, required_micro);
17070 // VERSION: 2.16
17071 // MOVED TO: Checksum.type_get_length
17072 // Gets the length in bytes of digests of type @checksum_type
17074 // not supported.
17075 // RETURNS: the checksum length, or -1 if @checksum_type is
17076 // <checksum_type>: a #GChecksumType
17077 static ssize_t checksum_type_get_length()(ChecksumType checksum_type) nothrow {
17078 return g_checksum_type_get_length(checksum_type);
17082 // Unintrospectable function: child_watch_add() / g_child_watch_add()
17083 // VERSION: 2.4
17084 // Sets a function to be called when the child indicated by @pid
17085 // exits, at a default priority, #G_PRIORITY_DEFAULT.
17087 // If you obtain @pid from g_spawn_async() or g_spawn_async_with_pipes()
17088 // you will need to pass #G_SPAWN_DO_NOT_REAP_CHILD as flag to
17089 // the spawn function for the child watching to work.
17091 // Note that on platforms where #GPid must be explicitly closed
17092 // (see g_spawn_close_pid()) @pid must not be closed while the
17093 // source is still active. Typically, you will want to call
17094 // g_spawn_close_pid() in the callback function for the source.
17096 // GLib supports only a single callback per process id.
17098 // This internally creates a main loop source using
17099 // g_child_watch_source_new() and attaches it to the main loop context
17100 // using g_source_attach(). You can do these steps manually if you
17101 // need greater control.
17102 // RETURNS: the ID (greater than 0) of the event source.
17103 // <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).
17104 // <function>: function to call
17105 // <data>: data to pass to @function
17106 static uint child_watch_add()(Pid pid, ChildWatchFunc function_, void* data) nothrow {
17107 return g_child_watch_add(pid, function_, data);
17111 // VERSION: 2.4
17112 // Sets a function to be called when the child indicated by @pid
17113 // exits, at the priority @priority.
17115 // If you obtain @pid from g_spawn_async() or g_spawn_async_with_pipes()
17116 // you will need to pass #G_SPAWN_DO_NOT_REAP_CHILD as flag to
17117 // the spawn function for the child watching to work.
17119 // Note that on platforms where #GPid must be explicitly closed
17120 // (see g_spawn_close_pid()) @pid must not be closed while the
17121 // source is still active. Typically, you will want to call
17122 // g_spawn_close_pid() in the callback function for the source.
17124 // GLib supports only a single callback per process id.
17126 // This internally creates a main loop source using
17127 // g_child_watch_source_new() and attaches it to the main loop context
17128 // using g_source_attach(). You can do these steps manually if you
17129 // need greater control.
17130 // RETURNS: the ID (greater than 0) of the event source.
17131 // <priority>: the priority of the idle source. Typically this will be in the range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.
17132 // <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).
17133 // <function>: function to call
17134 // <data>: data to pass to @function
17135 // <notify>: function to call when the idle is removed, or %NULL
17136 static uint child_watch_add_full()(int priority, Pid pid, ChildWatchFunc function_, void* data, DestroyNotify notify) nothrow {
17137 return g_child_watch_add_full(priority, pid, function_, data, notify);
17141 // VERSION: 2.4
17142 // Creates a new child_watch source.
17144 // The source will not initially be associated with any #GMainContext
17145 // and must be added to one with g_source_attach() before it will be
17146 // executed.
17148 // Note that child watch sources can only be used in conjunction with
17149 // <literal>g_spawn...</literal> when the %G_SPAWN_DO_NOT_REAP_CHILD
17150 // flag is used.
17152 // Note that on platforms where #GPid must be explicitly closed
17153 // (see g_spawn_close_pid()) @pid must not be closed while the
17154 // source is still active. Typically, you will want to call
17155 // g_spawn_close_pid() in the callback function for the source.
17157 // Note further that using g_child_watch_source_new() is not
17158 // compatible with calling <literal>waitpid(-1)</literal> in
17159 // the application. Calling waitpid() for individual pids will
17160 // still work fine.
17161 // RETURNS: the newly-created child watch source
17162 // <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).
17163 static Source* /*new*/ child_watch_source_new()(Pid pid) nothrow {
17164 return g_child_watch_source_new(pid);
17168 // If @err is %NULL, does nothing. If @err is non-%NULL,
17169 // calls g_error_free() on *@err and sets *@err to %NULL.
17170 static void clear_error()(GLib2.Error** error=null) nothrow {
17171 g_clear_error(error);
17175 // VERSION: 2.16
17176 // Computes the checksum for a binary @data of @length. This is a
17177 // convenience wrapper for g_checksum_new(), g_checksum_get_string()
17178 // and g_checksum_free().
17180 // The hexadecimal string returned will be in lower case.
17182 // The returned string should be freed with g_free() when done using it.
17183 // RETURNS: the digest of the binary data as a string in hexadecimal.
17184 // <checksum_type>: a #GChecksumType
17185 // <data>: binary blob to compute the digest of
17186 // <length>: length of @data
17187 static char* /*new*/ compute_checksum_for_data()(ChecksumType checksum_type, ubyte* data, size_t length) nothrow {
17188 return g_compute_checksum_for_data(checksum_type, data, length);
17192 // VERSION: 2.16
17193 // Computes the checksum of a string.
17195 // The hexadecimal string returned will be in lower case.
17197 // should be freed with g_free() when done using it.
17198 // RETURNS: the checksum as a hexadecimal string. The returned string
17199 // <checksum_type>: a #GChecksumType
17200 // <str>: the string to compute the checksum of
17201 // <length>: the length of the string, or -1 if the string is null-terminated.
17202 static char* /*new*/ compute_checksum_for_string()(ChecksumType checksum_type, char* str, ssize_t length) nothrow {
17203 return g_compute_checksum_for_string(checksum_type, str, length);
17207 // VERSION: 2.30
17208 // Computes the HMAC for a binary @data of @length. This is a
17209 // convenience wrapper for g_hmac_new(), g_hmac_get_string()
17210 // and g_hmac_unref().
17212 // The hexadecimal string returned will be in lower case.
17214 // The returned string should be freed with g_free() when done using it.
17215 // RETURNS: the HMAC of the binary data as a string in hexadecimal.
17216 // <digest_type>: a #GChecksumType to use for the HMAC
17217 // <key>: the key to use in the HMAC
17218 // <key_len>: the length of the key
17219 // <data>: binary blob to compute the HMAC of
17220 // <length>: length of @data
17221 static char* /*new*/ compute_hmac_for_data()(ChecksumType digest_type, ubyte* key, size_t key_len, ubyte* data, size_t length) nothrow {
17222 return g_compute_hmac_for_data(digest_type, key, key_len, data, length);
17226 // VERSION: 2.30
17227 // Computes the HMAC for a string.
17229 // The hexadecimal string returned will be in lower case.
17231 // The returned string should be freed with g_free()
17232 // when done using it.
17233 // RETURNS: the HMAC as a hexadecimal string.
17234 // <digest_type>: a #GChecksumType to use for the HMAC
17235 // <key>: the key to use in the HMAC
17236 // <key_len>: the length of the key
17237 // <str>: the string to compute the HMAC for
17238 // <length>: the length of the string, or -1 if the string is nul-terminated
17239 static char* /*new*/ compute_hmac_for_string()(ChecksumType digest_type, ubyte* key, size_t key_len, char* str, ssize_t length) nothrow {
17240 return g_compute_hmac_for_string(digest_type, key, key_len, str, length);
17244 // Converts a string from one character set to another.
17246 // Note that you should use g_iconv() for streaming
17247 // conversions<footnoteref linkend="streaming-state"/>.
17249 // nul-terminated string, which must be freed with
17250 // g_free(). Otherwise %NULL and @error will be set.
17251 // RETURNS: If the conversion was successful, a newly allocated
17252 // <str>: the string to convert
17253 // <len>: the length of the string, or -1 if the string is nul-terminated<footnote id="nul-unsafe">
17254 // <to_codeset>: name of character set into which to convert @str
17255 // <from_codeset>: character set of @str.
17256 // <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.
17257 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
17258 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) nothrow {
17259 return g_convert(str, len, to_codeset, from_codeset, bytes_read, bytes_written, error);
17262 static Quark convert_error_quark()() nothrow {
17263 return g_convert_error_quark();
17267 // Converts a string from one character set to another, possibly
17268 // including fallback sequences for characters not representable
17269 // in the output. Note that it is not guaranteed that the specification
17270 // for the fallback sequences in @fallback will be honored. Some
17271 // systems may do an approximate conversion from @from_codeset
17272 // to @to_codeset in their iconv() functions,
17273 // in which case GLib will simply return that approximate conversion.
17275 // Note that you should use g_iconv() for streaming
17276 // conversions<footnoteref linkend="streaming-state"/>.
17278 // nul-terminated string, which must be freed with
17279 // g_free(). Otherwise %NULL and @error will be set.
17280 // RETURNS: If the conversion was successful, a newly allocated
17281 // <str>: the string to convert
17282 // <len>: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
17283 // <to_codeset>: name of character set into which to convert @str
17284 // <from_codeset>: character set of @str.
17285 // <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).
17286 // <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.
17287 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
17288 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) nothrow {
17289 return g_convert_with_fallback(str, len, to_codeset, from_codeset, fallback, bytes_read, bytes_written, error);
17293 // Converts a string from one character set to another.
17295 // Note that you should use g_iconv() for streaming
17296 // conversions<footnote id="streaming-state">
17297 // <para>
17298 // Despite the fact that @byes_read can return information about partial
17299 // characters, the <literal>g_convert_...</literal> functions
17300 // are not generally suitable for streaming. If the underlying converter
17301 // being used maintains internal state, then this won't be preserved
17302 // across successive calls to g_convert(), g_convert_with_iconv() or
17303 // g_convert_with_fallback(). (An example of this is the GNU C converter
17304 // for CP1255 which does not emit a base character until it knows that
17305 // the next character is not a mark that could combine with the base
17306 // character.)
17307 // </para>
17308 // </footnote>.
17310 // nul-terminated string, which must be freed with
17311 // g_free(). Otherwise %NULL and @error will be set.
17312 // RETURNS: If the conversion was successful, a newly allocated
17313 // <str>: the string to convert
17314 // <len>: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
17315 // <converter>: conversion descriptor from g_iconv_open()
17316 // <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.
17317 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
17318 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) nothrow {
17319 return g_convert_with_iconv(str, len, converter, bytes_read, bytes_written, error);
17323 // Frees all the data elements of the datalist.
17324 // The data elements' destroy functions are called
17325 // if they have been set.
17326 // <datalist>: a datalist.
17327 static void datalist_clear()(Data** datalist) nothrow {
17328 g_datalist_clear(datalist);
17332 // Unintrospectable function: datalist_foreach() / g_datalist_foreach()
17333 // Calls the given function for each data element of the datalist. The
17334 // function is called with each data element's #GQuark id and data,
17335 // together with the given @user_data parameter. Note that this
17336 // function is NOT thread-safe. So unless @datalist can be protected
17337 // from any modifications during invocation of this function, it should
17338 // not be called.
17339 // <datalist>: a datalist.
17340 // <func>: the function to call for each data element.
17341 // <user_data>: user data to pass to the function.
17342 static void datalist_foreach()(Data** datalist, DataForeachFunc func, void* user_data) nothrow {
17343 g_datalist_foreach(datalist, func, user_data);
17347 // Unintrospectable function: datalist_get_data() / g_datalist_get_data()
17348 // Gets a data element, using its string identifer. This is slower than
17349 // g_datalist_id_get_data() because it compares strings.
17350 // <datalist>: a datalist.
17351 // <key>: the string identifying a data element.
17352 static void* datalist_get_data()(Data** datalist, char* key) nothrow {
17353 return g_datalist_get_data(datalist, key);
17357 // VERSION: 2.8
17358 // Gets flags values packed in together with the datalist.
17359 // See g_datalist_set_flags().
17360 // RETURNS: the flags of the datalist
17361 // <datalist>: pointer to the location that holds a list
17362 static uint datalist_get_flags()(Data** datalist) nothrow {
17363 return g_datalist_get_flags(datalist);
17367 // Unintrospectable function: datalist_id_get_data() / g_datalist_id_get_data()
17368 // Retrieves the data element corresponding to @key_id.
17369 // <datalist>: a datalist.
17370 // <key_id>: the #GQuark identifying a data element.
17371 static void* datalist_id_get_data()(Data** datalist, Quark key_id) nothrow {
17372 return g_datalist_id_get_data(datalist, key_id);
17376 // Unintrospectable function: datalist_id_remove_no_notify() / g_datalist_id_remove_no_notify()
17377 // Removes an element, without calling its destroy notification
17378 // function.
17379 // <datalist>: a datalist.
17380 // <key_id>: the #GQuark identifying a data element.
17381 static void* datalist_id_remove_no_notify()(Data** datalist, Quark key_id) nothrow {
17382 return g_datalist_id_remove_no_notify(datalist, key_id);
17386 // Sets the data corresponding to the given #GQuark id, and the
17387 // function to be called when the element is removed from the datalist.
17388 // Any previous data with the same key is removed, and its destroy
17389 // function is called.
17390 // <datalist>: a datalist.
17391 // <key_id>: the #GQuark to identify the data element.
17392 // <data>: the data element or %NULL to remove any previous element corresponding to @key_id.
17393 // <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.
17394 static void datalist_id_set_data_full()(Data** datalist, Quark key_id, void* data, DestroyNotify destroy_func) nothrow {
17395 g_datalist_id_set_data_full(datalist, key_id, data, destroy_func);
17399 // Resets the datalist to %NULL. It does not free any memory or call
17400 // any destroy functions.
17401 // <datalist>: a pointer to a pointer to a datalist.
17402 static void datalist_init()(Data** datalist) nothrow {
17403 g_datalist_init(datalist);
17407 // VERSION: 2.8
17408 // Turns on flag values for a data list. This function is used
17409 // to keep a small number of boolean flags in an object with
17410 // a data list without using any additional space. It is
17411 // not generally useful except in circumstances where space
17412 // is very tight. (It is used in the base #GObject type, for
17413 // example.)
17414 // <datalist>: pointer to the location that holds a list
17415 // <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.
17416 static void datalist_set_flags()(Data** datalist, uint flags) nothrow {
17417 g_datalist_set_flags(datalist, flags);
17421 // VERSION: 2.8
17422 // Turns off flag values for a data list. See g_datalist_unset_flags()
17423 // <datalist>: pointer to the location that holds a list
17424 // <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.
17425 static void datalist_unset_flags()(Data** datalist, uint flags) nothrow {
17426 g_datalist_unset_flags(datalist, flags);
17430 // Destroys the dataset, freeing all memory allocated, and calling any
17431 // destroy functions set for data elements.
17432 // <dataset_location>: the location identifying the dataset.
17433 static void dataset_destroy()(const(void)* dataset_location) nothrow {
17434 g_dataset_destroy(dataset_location);
17438 // Unintrospectable function: dataset_foreach() / g_dataset_foreach()
17439 // Calls the given function for each data element which is associated
17440 // with the given location. Note that this function is NOT thread-safe.
17441 // So unless @datalist can be protected from any modifications during
17442 // invocation of this function, it should not be called.
17443 // <dataset_location>: the location identifying the dataset.
17444 // <func>: the function to call for each data element.
17445 // <user_data>: user data to pass to the function.
17446 static void dataset_foreach()(const(void)* dataset_location, DataForeachFunc func, void* user_data) nothrow {
17447 g_dataset_foreach(dataset_location, func, user_data);
17451 // Unintrospectable function: dataset_id_get_data() / g_dataset_id_get_data()
17452 // Gets the data element corresponding to a #GQuark.
17453 // <dataset_location>: the location identifying the dataset.
17454 // <key_id>: the #GQuark id to identify the data element.
17455 static void* dataset_id_get_data()(const(void)* dataset_location, Quark key_id) nothrow {
17456 return g_dataset_id_get_data(dataset_location, key_id);
17460 // Unintrospectable function: dataset_id_remove_no_notify() / g_dataset_id_remove_no_notify()
17461 // Removes an element, without calling its destroy notification
17462 // function.
17463 // <dataset_location>: the location identifying the dataset.
17464 // <key_id>: the #GQuark ID identifying the data element.
17465 static void* dataset_id_remove_no_notify()(const(void)* dataset_location, Quark key_id) nothrow {
17466 return g_dataset_id_remove_no_notify(dataset_location, key_id);
17470 // Sets the data element associated with the given #GQuark id, and also
17471 // the function to call when the data element is destroyed. Any
17472 // previous data with the same key is removed, and its destroy function
17473 // is called.
17474 // <dataset_location>: the location identifying the dataset.
17475 // <key_id>: the #GQuark id to identify the data element.
17476 // <data>: the data element.
17477 // <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.
17478 static void dataset_id_set_data_full()(const(void)* dataset_location, Quark key_id, void* data, DestroyNotify destroy_func) nothrow {
17479 g_dataset_id_set_data_full(dataset_location, key_id, data, destroy_func);
17483 // MOVED TO: Date.get_days_in_month
17484 // Returns the number of days in a month, taking leap
17485 // years into account.
17486 // RETURNS: number of days in @month during the @year
17487 // <month>: month
17488 // <year>: year
17489 static ubyte date_get_days_in_month()(DateMonth month, DateYear year) nothrow {
17490 return g_date_get_days_in_month(month, year);
17494 // MOVED TO: Date.get_monday_weeks_in_year
17495 // Returns the number of weeks in the year, where weeks
17496 // are taken to start on Monday. Will be 52 or 53. The
17497 // date must be valid. (Years always have 52 7-day periods,
17498 // plus 1 or 2 extra days depending on whether it's a leap
17499 // year. This function is basically telling you how many
17500 // Mondays are in the year, i.e. there are 53 Mondays if
17501 // one of the extra days happens to be a Monday.)
17502 // RETURNS: number of Mondays in the year
17503 // <year>: a year
17504 static ubyte date_get_monday_weeks_in_year()(DateYear year) nothrow {
17505 return g_date_get_monday_weeks_in_year(year);
17509 // MOVED TO: Date.get_sunday_weeks_in_year
17510 // Returns the number of weeks in the year, where weeks
17511 // are taken to start on Sunday. Will be 52 or 53. The
17512 // date must be valid. (Years always have 52 7-day periods,
17513 // plus 1 or 2 extra days depending on whether it's a leap
17514 // year. This function is basically telling you how many
17515 // Sundays are in the year, i.e. there are 53 Sundays if
17516 // one of the extra days happens to be a Sunday.)
17517 // RETURNS: the number of weeks in @year
17518 // <year>: year to count weeks in
17519 static ubyte date_get_sunday_weeks_in_year()(DateYear year) nothrow {
17520 return g_date_get_sunday_weeks_in_year(year);
17524 // MOVED TO: Date.is_leap_year
17525 // Returns %TRUE if the year is a leap year.
17526 // <footnote><para>For the purposes of this function,
17527 // leap year is every year divisible by 4 unless that year
17528 // is divisible by 100. If it is divisible by 100 it would
17529 // be a leap year only if that year is also divisible
17530 // by 400.</para></footnote>
17531 // RETURNS: %TRUE if the year is a leap year
17532 // <year>: year to check
17533 static int date_is_leap_year()(DateYear year) nothrow {
17534 return g_date_is_leap_year(year);
17538 // MOVED TO: Date.strftime
17539 // Generates a printed representation of the date, in a
17540 // <link linkend="setlocale">locale</link>-specific way.
17541 // Works just like the platform's C library strftime() function,
17542 // but only accepts date-related formats; time-related formats
17543 // give undefined results. Date must be valid. Unlike strftime()
17544 // (which uses the locale encoding), works on a UTF-8 format
17545 // string and stores a UTF-8 result.
17547 // This function does not provide any conversion specifiers in
17548 // addition to those implemented by the platform's C library.
17549 // For example, don't expect that using g_date_strftime() would
17550 // make the \%F provided by the C99 strftime() work on Windows
17551 // where the C library only complies to C89.
17552 // RETURNS: number of characters written to the buffer, or 0 the buffer was too small
17553 // <s>: destination buffer
17554 // <slen>: buffer size
17555 // <format>: format string
17556 // <date>: valid #GDate
17557 static size_t date_strftime()(char* s, size_t slen, char* format, Date* date) nothrow {
17558 return g_date_strftime(s, slen, format, date);
17562 // VERSION: 2.26
17563 // MOVED TO: DateTime.compare
17564 // A comparison function for #GDateTimes that is suitable
17565 // as a #GCompareFunc. Both #GDateTimes must be non-%NULL.
17567 // than @dt2.
17568 // RETURNS: -1, 0 or 1 if @dt1 is less than, equal to or greater
17569 // <dt1>: first #GDateTime to compare
17570 // <dt2>: second #GDateTime to compare
17571 static int date_time_compare()(const(void)* dt1, const(void)* dt2) nothrow {
17572 return g_date_time_compare(dt1, dt2);
17576 // VERSION: 2.26
17577 // MOVED TO: DateTime.equal
17578 // Checks to see if @dt1 and @dt2 are equal.
17580 // Equal here means that they represent the same moment after converting
17581 // them to the same time zone.
17582 // RETURNS: %TRUE if @dt1 and @dt2 are equal
17583 // <dt1>: a #GDateTime
17584 // <dt2>: a #GDateTime
17585 static int date_time_equal()(const(void)* dt1, const(void)* dt2) nothrow {
17586 return g_date_time_equal(dt1, dt2);
17590 // VERSION: 2.26
17591 // MOVED TO: DateTime.hash
17592 // Hashes @datetime into a #guint, suitable for use within #GHashTable.
17593 // RETURNS: a #guint containing the hash
17594 // <datetime>: a #GDateTime
17595 static uint date_time_hash()(const(void)* datetime) nothrow {
17596 return g_date_time_hash(datetime);
17600 // MOVED TO: Date.valid_day
17601 // Returns %TRUE if the day of the month is valid (a day is valid if it's
17602 // between 1 and 31 inclusive).
17603 // RETURNS: %TRUE if the day is valid
17604 // <day>: day to check
17605 static int date_valid_day()(DateDay day) nothrow {
17606 return g_date_valid_day(day);
17610 // MOVED TO: Date.valid_dmy
17611 // Returns %TRUE if the day-month-year triplet forms a valid, existing day
17612 // in the range of days #GDate understands (Year 1 or later, no more than
17613 // a few thousand years in the future).
17614 // RETURNS: %TRUE if the date is a valid one
17615 // <day>: day
17616 // <month>: month
17617 // <year>: year
17618 static int date_valid_dmy()(DateDay day, DateMonth month, DateYear year) nothrow {
17619 return g_date_valid_dmy(day, month, year);
17623 // MOVED TO: Date.valid_julian
17624 // Returns %TRUE if the Julian day is valid. Anything greater than zero
17625 // is basically a valid Julian, though there is a 32-bit limit.
17626 // RETURNS: %TRUE if the Julian day is valid
17627 // <julian_date>: Julian day to check
17628 static int date_valid_julian()(uint julian_date) nothrow {
17629 return g_date_valid_julian(julian_date);
17633 // MOVED TO: Date.valid_month
17634 // Returns %TRUE if the month value is valid. The 12 #GDateMonth
17635 // enumeration values are the only valid months.
17636 // RETURNS: %TRUE if the month is valid
17637 // <month>: month
17638 static int date_valid_month()(DateMonth month) nothrow {
17639 return g_date_valid_month(month);
17643 // MOVED TO: Date.valid_weekday
17644 // Returns %TRUE if the weekday is valid. The seven #GDateWeekday enumeration
17645 // values are the only valid weekdays.
17646 // RETURNS: %TRUE if the weekday is valid
17647 // <weekday>: weekday
17648 static int date_valid_weekday()(DateWeekday weekday) nothrow {
17649 return g_date_valid_weekday(weekday);
17653 // MOVED TO: Date.valid_year
17654 // Returns %TRUE if the year is valid. Any year greater than 0 is valid,
17655 // though there is a 16-bit limit to what #GDate will understand.
17656 // RETURNS: %TRUE if the year is valid
17657 // <year>: year
17658 static int date_valid_year()(DateYear year) nothrow {
17659 return g_date_valid_year(year);
17663 // VERSION: 2.26
17664 // This is a variant of g_dgettext() that allows specifying a locale
17665 // category instead of always using <envar>LC_MESSAGES</envar>. See g_dgettext() for
17666 // more information about how this functions differs from calling
17667 // dcgettext() directly.
17668 // RETURNS: the translated string for the given locale category
17669 // <domain>: the translation domain to use, or %NULL to use the domain set with textdomain()
17670 // <msgid>: message to translate
17671 // <category>: a locale category
17672 static char* dcgettext()(char* domain, char* msgid, int category) nothrow {
17673 return g_dcgettext(domain, msgid, category);
17677 // VERSION: 2.18
17678 // This function is a wrapper of dgettext() which does not translate
17679 // the message if the default domain as set with textdomain() has no
17680 // translations for the current locale.
17682 // The advantage of using this function over dgettext() proper is that
17683 // libraries using this function (like GTK+) will not use translations
17684 // if the application using the library does not have translations for
17685 // the current locale. This results in a consistent English-only
17686 // interface instead of one having partial translations. For this
17687 // feature to work, the call to textdomain() and setlocale() should
17688 // precede any g_dgettext() invocations. For GTK+, it means calling
17689 // textdomain() before gtk_init or its variants.
17691 // This function disables translations if and only if upon its first
17692 // call all the following conditions hold:
17693 // <itemizedlist>
17694 // <listitem>@domain is not %NULL</listitem>
17695 // <listitem>textdomain() has been called to set a default text domain</listitem>
17696 // <listitem>there is no translations available for the default text domain
17697 // and the current locale</listitem>
17698 // <listitem>current locale is not "C" or any English locales (those
17699 // starting with "en_")</listitem>
17700 // </itemizedlist>
17702 // Note that this behavior may not be desired for example if an application
17703 // has its untranslated messages in a language other than English. In those
17704 // cases the application should call textdomain() after initializing GTK+.
17706 // Applications should normally not use this function directly,
17707 // but use the _() macro for translations.
17708 // RETURNS: The translated string
17709 // <domain>: the translation domain to use, or %NULL to use the domain set with textdomain()
17710 // <msgid>: message to translate
17711 static char* dgettext()(char* domain, char* msgid) nothrow {
17712 return g_dgettext(domain, msgid);
17716 // VERSION: 2.30
17717 // MOVED TO: Dir.make_tmp
17718 // Creates a subdirectory in the preferred directory for temporary
17719 // files (as returned by g_get_tmp_dir()).
17721 // @tmpl should be a string in the GLib file name encoding containing
17722 // a sequence of six 'X' characters, as the parameter to g_mkstemp().
17723 // However, unlike these functions, the template should only be a
17724 // basename, no directory components are allowed. If template is
17725 // %NULL, a default template is used.
17727 // Note that in contrast to g_mkdtemp() (and mkdtemp()) @tmpl is not
17728 // modified, and might thus be a read-only literal string.
17730 // should be freed with g_free() when not needed any longer and is
17731 // is in the GLib file name encoding. In case of errors, %NULL is
17732 // returned and @error will be set.
17733 // RETURNS: The actual name used. This string
17734 // <tmpl>: Template for directory name, as in g_mkdtemp(), basename only, or %NULL for a default template
17735 static char* /*new*/ dir_make_tmp()(char* tmpl, GLib2.Error** error=null) nothrow {
17736 return g_dir_make_tmp(tmpl, error);
17740 // Compares two #gpointer arguments and returns %TRUE if they are equal.
17741 // It can be passed to g_hash_table_new() as the @key_equal_func
17742 // parameter, when using opaque pointers compared by pointer value as keys
17743 // in a #GHashTable.
17745 // This equality function is also appropriate for keys that are integers stored
17746 // in pointers, such as <literal>GINT_TO_POINTER (n)</literal>.
17747 // RETURNS: %TRUE if the two keys match.
17748 // <v1>: a key
17749 // <v2>: a key to compare with @v1
17750 static int direct_equal()(const(void)* v1=null, const(void)* v2=null) nothrow {
17751 return g_direct_equal(v1, v2);
17755 // Converts a gpointer to a hash value.
17756 // It can be passed to g_hash_table_new() as the @hash_func parameter,
17757 // when using opaque pointers compared by pointer value as keys in a
17758 // #GHashTable.
17760 // This hash function is also appropriate for keys that are integers stored
17761 // in pointers, such as <literal>GINT_TO_POINTER (n)</literal>.
17762 // RETURNS: a hash value corresponding to the key.
17763 // <v>: a #gpointer key
17764 static uint direct_hash()(const(void)* v=null) nothrow {
17765 return g_direct_hash(v);
17769 // VERSION: 2.18
17770 // This function is a wrapper of dngettext() which does not translate
17771 // the message if the default domain as set with textdomain() has no
17772 // translations for the current locale.
17774 // See g_dgettext() for details of how this differs from dngettext()
17775 // proper.
17776 // RETURNS: The translated string
17777 // <domain>: the translation domain to use, or %NULL to use the domain set with textdomain()
17778 // <msgid>: message to translate
17779 // <msgid_plural>: plural form of the message
17780 // <n>: the quantity for which translation is needed
17781 static char* dngettext()(char* domain, char* msgid, char* msgid_plural, c_ulong n) nothrow {
17782 return g_dngettext(domain, msgid, msgid_plural, n);
17786 // VERSION: 2.22
17787 // Compares the two #gdouble values being pointed to and returns
17788 // %TRUE if they are equal.
17789 // It can be passed to g_hash_table_new() as the @key_equal_func
17790 // parameter, when using non-%NULL pointers to doubles as keys in a
17791 // #GHashTable.
17792 // RETURNS: %TRUE if the two keys match.
17793 // <v1>: a pointer to a #gdouble key
17794 // <v2>: a pointer to a #gdouble key to compare with @v1
17795 static int double_equal()(const(void)* v1, const(void)* v2) nothrow {
17796 return g_double_equal(v1, v2);
17800 // VERSION: 2.22
17801 // Converts a pointer to a #gdouble to a hash value.
17802 // It can be passed to g_hash_table_new() as the @hash_func parameter,
17803 // It can be passed to g_hash_table_new() as the @hash_func parameter,
17804 // when using non-%NULL pointers to doubles as keys in a #GHashTable.
17805 // RETURNS: a hash value corresponding to the key.
17806 // <v>: a pointer to a #gdouble key
17807 static uint double_hash()(const(void)* v) nothrow {
17808 return g_double_hash(v);
17812 // VERSION: 2.16
17813 // This function is a variant of g_dgettext() which supports
17814 // a disambiguating message context. GNU gettext uses the
17815 // '\004' character to separate the message context and
17816 // message id in @msgctxtid.
17817 // If 0 is passed as @msgidoffset, this function will fall back to
17818 // trying to use the deprecated convention of using "|" as a separation
17819 // character.
17821 // This uses g_dgettext() internally. See that functions for differences
17822 // with dgettext() proper.
17824 // Applications should normally not use this function directly,
17825 // but use the C_() macro for translations with context.
17826 // RETURNS: The translated string
17827 // <domain>: the translation domain to use, or %NULL to use the domain set with textdomain()
17828 // <msgctxtid>: a combined message context and message id, separated by a \004 character
17829 // <msgidoffset>: the offset of the message id in @msgctxid
17830 static char* dpgettext()(char* domain, char* msgctxtid, size_t msgidoffset) nothrow {
17831 return g_dpgettext(domain, msgctxtid, msgidoffset);
17835 // VERSION: 2.18
17836 // This function is a variant of g_dgettext() which supports
17837 // a disambiguating message context. GNU gettext uses the
17838 // '\004' character to separate the message context and
17839 // message id in @msgctxtid.
17841 // This uses g_dgettext() internally. See that functions for differences
17842 // with dgettext() proper.
17844 // This function differs from C_() in that it is not a macro and
17845 // thus you may use non-string-literals as context and msgid arguments.
17846 // RETURNS: The translated string
17847 // <domain>: the translation domain to use, or %NULL to use the domain set with textdomain()
17848 // <context>: the message context
17849 // <msgid>: the message
17850 static char* dpgettext2()(char* domain, char* context, char* msgid) nothrow {
17851 return g_dpgettext2(domain, context, msgid);
17855 // VERSION: 2.32
17856 // Returns the value of the environment variable @variable in the
17857 // provided list @envp.
17859 // The name and value are in the GLib file name encoding.
17860 // On UNIX, this means the actual bytes which might or might not
17861 // be in some consistent character set and encoding. On Windows,
17862 // it is in UTF-8. On Windows, in case the environment variable's
17863 // value contains references to other environment variables, they
17864 // are expanded.
17866 // the environment variable is not set in @envp. The returned
17867 // string is owned by @envp, and will be freed if @variable is
17868 // set or unset again.
17869 // RETURNS: the value of the environment variable, or %NULL if
17870 // <envp>: an environment list (eg, as returned from g_get_environ())
17871 // <variable>: the environment variable to get, in the GLib file name encoding
17872 static char* environ_getenv()(char** envp, char* variable) nothrow {
17873 return g_environ_getenv(envp, variable);
17877 // VERSION: 2.32
17878 // Sets the environment variable @variable in the provided list
17879 // @envp to @value.
17881 // Both the variable's name and value should be in the GLib
17882 // file name encoding. On UNIX, this means that they can be
17883 // arbitrary byte strings. On Windows, they should be in UTF-8.
17885 // updated environment
17886 // RETURNS: the
17887 // <envp>: an environment list (eg, as returned from g_get_environ())
17888 // <variable>: the environment variable to set, must not contain '='
17889 // <value>: the value for to set the variable to
17890 // <overwrite>: whether to change the variable if it already exists
17891 static char** /*new*/ environ_setenv()(char** envp, char* variable, char* value, int overwrite) nothrow {
17892 return g_environ_setenv(envp, variable, value, overwrite);
17896 // VERSION: 2.32
17897 // Removes the environment variable @variable from the provided
17898 // environment @envp.
17900 // updated environment
17901 // RETURNS: the
17902 // <envp>: an environment list (eg, as returned from g_get_environ())
17903 // <variable>: the environment variable to remove, must not contain '='
17904 static char** /*new*/ environ_unsetenv()(char** envp, char* variable) nothrow {
17905 return g_environ_unsetenv(envp, variable);
17909 // Gets a #GFileError constant based on the passed-in @err_no.
17910 // For example, if you pass in <literal>EEXIST</literal> this function returns
17911 // #G_FILE_ERROR_EXIST. Unlike <literal>errno</literal> values, you can portably
17912 // assume that all #GFileError values will exist.
17914 // Normally a #GFileError value goes into a #GError returned
17915 // from a function that manipulates files. So you would use
17916 // g_file_error_from_errno() when constructing a #GError.
17917 // RETURNS: #GFileError corresponding to the given @errno
17918 // <err_no>: an "errno" value
17919 static FileError file_error_from_errno()(int err_no) nothrow {
17920 return g_file_error_from_errno(err_no);
17923 static Quark file_error_quark()() nothrow {
17924 return g_file_error_quark();
17928 // Reads an entire file into allocated memory, with good error
17929 // checking.
17931 // If the call was successful, it returns %TRUE and sets @contents to the file
17932 // contents and @length to the length of the file contents in bytes. The string
17933 // stored in @contents will be nul-terminated, so for text files you can pass
17934 // %NULL for the @length argument. If the call was not successful, it returns
17935 // %FALSE and sets @error. The error domain is #G_FILE_ERROR. Possible error
17936 // codes are those in the #GFileError enumeration. In the error case,
17937 // @contents is set to %NULL and @length is set to zero.
17938 // RETURNS: %TRUE on success, %FALSE if an error occurred
17939 // <filename>: name of a file to read contents from, in the GLib file name encoding
17940 // <contents>: location to store an allocated string, use g_free() to free the returned string
17941 // <length>: location to store length in bytes of the contents, or %NULL
17942 static int file_get_contents()(char* filename, /*out*/ ubyte** contents, /*out*/ size_t* length, GLib2.Error** error=null) nothrow {
17943 return g_file_get_contents(filename, contents, length, error);
17947 // Opens a file for writing in the preferred directory for temporary
17948 // files (as returned by g_get_tmp_dir()).
17950 // @tmpl should be a string in the GLib file name encoding containing
17951 // a sequence of six 'X' characters, as the parameter to g_mkstemp().
17952 // However, unlike these functions, the template should only be a
17953 // basename, no directory components are allowed. If template is
17954 // %NULL, a default template is used.
17956 // Note that in contrast to g_mkstemp() (and mkstemp()) @tmpl is not
17957 // modified, and might thus be a read-only literal string.
17959 // Upon success, and if @name_used is non-%NULL, the actual name used
17960 // is returned in @name_used. This string should be freed with g_free()
17961 // when not needed any longer. The returned name is in the GLib file
17962 // name encoding.
17964 // reading and writing. The file is opened in binary mode on platforms
17965 // where there is a difference. The file handle should be closed with
17966 // close(). In case of errors, -1 is returned and @error will be set.
17967 // RETURNS: A file handle (as from open()) to the file opened for
17968 // <tmpl>: Template for file name, as in g_mkstemp(), basename only, or %NULL for a default template
17969 // <name_used>: location to store actual name used, or %NULL
17970 static int file_open_tmp()(char* tmpl, /*out*/ char** name_used, GLib2.Error** error=null) nothrow {
17971 return g_file_open_tmp(tmpl, name_used, error);
17975 // VERSION: 2.4
17976 // Reads the contents of the symbolic link @filename like the POSIX
17977 // readlink() function. The returned string is in the encoding used
17978 // for filenames. Use g_filename_to_utf8() to convert it to UTF-8.
17980 // or %NULL if an error occurred.
17981 // RETURNS: A newly-allocated string with the contents of the symbolic link,
17982 // <filename>: the symbolic link
17983 static char* /*new*/ file_read_link()(char* filename, GLib2.Error** error=null) nothrow {
17984 return g_file_read_link(filename, error);
17988 // VERSION: 2.8
17989 // Writes all of @contents to a file named @filename, with good error checking.
17990 // If a file called @filename already exists it will be overwritten.
17992 // This write is atomic in the sense that it is first written to a temporary
17993 // file which is then renamed to the final name. Notes:
17994 // <itemizedlist>
17995 // <listitem>
17996 // On Unix, if @filename already exists hard links to @filename will break.
17997 // Also since the file is recreated, existing permissions, access control
17998 // lists, metadata etc. may be lost. If @filename is a symbolic link,
17999 // the link itself will be replaced, not the linked file.
18000 // </listitem>
18001 // <listitem>
18002 // On Windows renaming a file will not remove an existing file with the
18003 // new name, so on Windows there is a race condition between the existing
18004 // file being removed and the temporary file being renamed.
18005 // </listitem>
18006 // <listitem>
18007 // On Windows there is no way to remove a file that is open to some
18008 // process, or mapped into memory. Thus, this function will fail if
18009 // @filename already exists and is open.
18010 // </listitem>
18011 // </itemizedlist>
18013 // If the call was successful, it returns %TRUE. If the call was not successful,
18014 // it returns %FALSE and sets @error. The error domain is #G_FILE_ERROR.
18015 // Possible error codes are those in the #GFileError enumeration.
18017 // Note that the name for the temporary file is constructed by appending up
18018 // to 7 characters to @filename.
18019 // RETURNS: %TRUE on success, %FALSE if an error occurred
18020 // <filename>: name of a file to write @contents to, in the GLib file name encoding
18021 // <contents>: string to write to the file
18022 // <length>: length of @contents, or -1 if @contents is a nul-terminated string
18023 static int file_set_contents()(char* filename, ubyte* contents, ssize_t length, GLib2.Error** error=null) nothrow {
18024 return g_file_set_contents(filename, contents, length, error);
18028 // Returns %TRUE if any of the tests in the bitfield @test are
18029 // %TRUE. For example, <literal>(G_FILE_TEST_EXISTS |
18030 // G_FILE_TEST_IS_DIR)</literal> will return %TRUE if the file exists;
18031 // the check whether it's a directory doesn't matter since the existence
18032 // test is %TRUE. With the current set of available tests, there's no point
18033 // passing in more than one test at a time.
18035 // Apart from %G_FILE_TEST_IS_SYMLINK all tests follow symbolic links,
18036 // so for a symbolic link to a regular file g_file_test() will return
18037 // %TRUE for both %G_FILE_TEST_IS_SYMLINK and %G_FILE_TEST_IS_REGULAR.
18039 // Note, that for a dangling symbolic link g_file_test() will return
18040 // %TRUE for %G_FILE_TEST_IS_SYMLINK and %FALSE for all other flags.
18042 // You should never use g_file_test() to test whether it is safe
18043 // to perform an operation, because there is always the possibility
18044 // of the condition changing before you actually perform the operation.
18045 // For example, you might think you could use %G_FILE_TEST_IS_SYMLINK
18046 // to know whether it is safe to write to a file without being
18047 // tricked into writing into a different location. It doesn't work!
18048 // |[
18049 // /&ast; DON'T DO THIS &ast;/
18050 // if (!g_file_test (filename, G_FILE_TEST_IS_SYMLINK))
18051 // {
18052 // fd = g_open (filename, O_WRONLY);
18053 // /&ast; write to fd &ast;/
18054 // }
18055 // ]|
18057 // Another thing to note is that %G_FILE_TEST_EXISTS and
18058 // %G_FILE_TEST_IS_EXECUTABLE are implemented using the access()
18059 // system call. This usually doesn't matter, but if your program
18060 // is setuid or setgid it means that these tests will give you
18061 // the answer for the real user ID and group ID, rather than the
18062 // effective user ID and group ID.
18064 // On Windows, there are no symlinks, so testing for
18065 // %G_FILE_TEST_IS_SYMLINK will always return %FALSE. Testing for
18066 // %G_FILE_TEST_IS_EXECUTABLE will just check that the file exists and
18067 // its name indicates that it is executable, checking for well-known
18068 // extensions and those listed in the <envar>PATHEXT</envar> environment variable.
18069 // RETURNS: whether a test was %TRUE
18070 // <filename>: a filename to test in the GLib file name encoding
18071 // <test>: bitfield of #GFileTest flags
18072 static int file_test()(char* filename, FileTest test) nothrow {
18073 return g_file_test(filename, test);
18077 // VERSION: 2.6
18078 // Returns the display basename for the particular filename, guaranteed
18079 // to be valid UTF-8. The display name might not be identical to the filename,
18080 // for instance there might be problems converting it to UTF-8, and some files
18081 // can be translated in the display.
18083 // If GLib cannot make sense of the encoding of @filename, as a last resort it
18084 // replaces unknown characters with U+FFFD, the Unicode replacement character.
18085 // You can search the result for the UTF-8 encoding of this character (which is
18086 // "\357\277\275" in octal notation) to find out if @filename was in an invalid
18087 // encoding.
18089 // You must pass the whole absolute pathname to this functions so that
18090 // translation of well known locations can be done.
18092 // This function is preferred over g_filename_display_name() if you know the
18093 // whole path, as it allows translation.
18095 // a rendition of the basename of the filename in valid UTF-8
18096 // RETURNS: a newly allocated string containing
18097 // <filename>: an absolute pathname in the GLib file name encoding
18098 static char* /*new*/ filename_display_basename()(char* filename) nothrow {
18099 return g_filename_display_basename(filename);
18103 // VERSION: 2.6
18104 // Converts a filename into a valid UTF-8 string. The conversion is
18105 // not necessarily reversible, so you should keep the original around
18106 // and use the return value of this function only for display purposes.
18107 // Unlike g_filename_to_utf8(), the result is guaranteed to be non-%NULL
18108 // even if the filename actually isn't in the GLib file name encoding.
18110 // If GLib cannot make sense of the encoding of @filename, as a last resort it
18111 // replaces unknown characters with U+FFFD, the Unicode replacement character.
18112 // You can search the result for the UTF-8 encoding of this character (which is
18113 // "\357\277\275" in octal notation) to find out if @filename was in an invalid
18114 // encoding.
18116 // If you know the whole pathname of the file you should use
18117 // g_filename_display_basename(), since that allows location-based
18118 // translation of filenames.
18120 // a rendition of the filename in valid UTF-8
18121 // RETURNS: a newly allocated string containing
18122 // <filename>: a pathname hopefully in the GLib file name encoding
18123 static char* /*new*/ filename_display_name()(char* filename) nothrow {
18124 return g_filename_display_name(filename);
18128 // Converts an escaped ASCII-encoded URI to a local filename in the
18129 // encoding used for filenames.
18131 // filename, or %NULL on an error.
18132 // RETURNS: a newly-allocated string holding the resulting
18133 // <uri>: a uri describing a filename (escaped, encoded in ASCII).
18134 // <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.
18135 static char* /*new*/ filename_from_uri()(char* uri, char** hostname, GLib2.Error** error=null) nothrow {
18136 return g_filename_from_uri(uri, hostname, error);
18140 // Converts a string from UTF-8 to the encoding GLib uses for
18141 // filenames. Note that on Windows GLib uses UTF-8 for filenames;
18142 // on other platforms, this function indirectly depends on the
18143 // <link linkend="setlocale">current locale</link>.
18144 // RETURNS: The converted string, or %NULL on an error.
18145 // <utf8string>: a UTF-8 encoded string.
18146 // <len>: the length of the string, or -1 if the string is nul-terminated.
18147 // <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.
18148 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
18149 static char* /*new*/ filename_from_utf8()(char* utf8string, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error=null) nothrow {
18150 return g_filename_from_utf8(utf8string, len, bytes_read, bytes_written, error);
18154 // Converts an absolute filename to an escaped ASCII-encoded URI, with the path
18155 // component following Section 3.3. of RFC 2396.
18157 // URI, or %NULL on an error.
18158 // RETURNS: a newly-allocated string holding the resulting
18159 // <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
18160 // <hostname>: A UTF-8 encoded hostname, or %NULL for none.
18161 static char* /*new*/ filename_to_uri()(char* filename, char* hostname, GLib2.Error** error=null) nothrow {
18162 return g_filename_to_uri(filename, hostname, error);
18166 // Converts a string which is in the encoding used by GLib for
18167 // filenames into a UTF-8 string. Note that on Windows GLib uses UTF-8
18168 // for filenames; on other platforms, this function indirectly depends on
18169 // the <link linkend="setlocale">current locale</link>.
18170 // RETURNS: The converted string, or %NULL on an error.
18171 // <opsysstring>: a string in the encoding for filenames
18172 // <len>: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
18173 // <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.
18174 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
18175 static char* /*new*/ filename_to_utf8()(char* opsysstring, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error=null) nothrow {
18176 return g_filename_to_utf8(opsysstring, len, bytes_read, bytes_written, error);
18180 // Locates the first executable named @program in the user's path, in the
18181 // same way that execvp() would locate it. Returns an allocated string
18182 // with the absolute path name, or %NULL if the program is not found in
18183 // the path. If @program is already an absolute path, returns a copy of
18184 // @program if @program exists and is executable, and %NULL otherwise.
18186 // On Windows, if @program does not have a file type suffix, tries
18187 // with the suffixes .exe, .cmd, .bat and .com, and the suffixes in
18188 // the <envar>PATHEXT</envar> environment variable.
18190 // On Windows, it looks for the file in the same way as CreateProcess()
18191 // would. This means first in the directory where the executing
18192 // program was loaded from, then in the current directory, then in the
18193 // Windows 32-bit system directory, then in the Windows directory, and
18194 // finally in the directories in the <envar>PATH</envar> environment
18195 // variable. If the program is found, the return value contains the
18196 // full name including the type suffix.
18197 // RETURNS: absolute path, or %NULL
18198 // <program>: a program name in the GLib file name encoding
18199 static char* /*new*/ find_program_in_path()(char* program) nothrow {
18200 return g_find_program_in_path(program);
18204 // VERSION: 2.30
18205 // Formats a size (for example the size of a file) into a human readable
18206 // string. Sizes are rounded to the nearest size prefix (kB, MB, GB)
18207 // and are displayed rounded to the nearest tenth. E.g. the file size
18208 // 3292528 bytes will be converted into the string "3.2 MB".
18210 // The prefix units base is 1000 (i.e. 1 kB is 1000 bytes).
18212 // This string should be freed with g_free() when not needed any longer.
18214 // See g_format_size_full() for more options about how the size might be
18215 // formatted.
18217 // file size
18218 // RETURNS: a newly-allocated formatted string containing a human readable
18219 // <size>: a size in bytes
18220 static char* /*new*/ format_size()(ulong size) nothrow {
18221 return g_format_size(size);
18225 // VERSION: 2.16
18226 // Formats a size (for example the size of a file) into a human
18227 // readable string. Sizes are rounded to the nearest size prefix
18228 // (KB, MB, GB) and are displayed rounded to the nearest tenth.
18229 // E.g. the file size 3292528 bytes will be converted into the
18230 // string "3.1 MB".
18232 // The prefix units base is 1024 (i.e. 1 KB is 1024 bytes).
18234 // This string should be freed with g_free() when not needed any longer.
18236 // readable file size
18239 // Deprecated:2.30: This function is broken due to its use of SI
18240 // suffixes to denote IEC units. Use g_format_size() instead.
18241 // RETURNS: a newly-allocated formatted string containing a human
18242 // <size>: a size in bytes
18243 static char* /*new*/ format_size_for_display()(long size) nothrow {
18244 return g_format_size_for_display(size);
18248 // VERSION: 2.30
18249 // Formats a size.
18251 // This function is similar to g_format_size() but allows for flags
18252 // that modify the output. See #GFormatSizeFlags.
18254 // readable file size
18255 // RETURNS: a newly-allocated formatted string containing a human
18256 // <size>: a size in bytes
18257 // <flags>: #GFormatSizeFlags to modify the output
18258 static char* /*new*/ format_size_full()(ulong size, FormatSizeFlags flags) nothrow {
18259 return g_format_size_full(size, flags);
18263 // Unintrospectable function: fprintf() / g_fprintf()
18264 // VERSION: 2.2
18265 // An implementation of the standard fprintf() function which supports
18266 // positional parameters, as specified in the Single Unix Specification.
18267 // RETURNS: the number of bytes printed.
18268 // <file>: the stream to write to.
18269 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
18270 alias g_fprintf fprintf; // Variadic
18273 // Frees the memory pointed to by @mem.
18274 // If @mem is %NULL it simply returns.
18275 // <mem>: the memory to free
18276 static void free()(void* mem) nothrow {
18277 g_free(mem);
18281 // VERSION: 2.2
18282 // Gets a human-readable name for the application, as set by
18283 // g_set_application_name(). This name should be localized if
18284 // possible, and is intended for display to the user. Contrast with
18285 // g_get_prgname(), which gets a non-localized name. If
18286 // g_set_application_name() has not been called, returns the result of
18287 // g_get_prgname() (which may be %NULL if g_set_prgname() has also not
18288 // been called).
18289 // RETURNS: human-readable application name. may return %NULL
18290 static char* get_application_name()() nothrow {
18291 return g_get_application_name();
18295 // Obtains the character set for the <link linkend="setlocale">current
18296 // locale</link>; you might use this character set as an argument to
18297 // g_convert(), to convert from the current locale's encoding to some
18298 // other encoding. (Frequently g_locale_to_utf8() and g_locale_from_utf8()
18299 // are nice shortcuts, though.)
18301 // On Windows the character set returned by this function is the
18302 // so-called system default ANSI code-page. That is the character set
18303 // used by the "narrow" versions of C library and Win32 functions that
18304 // handle file names. It might be different from the character set
18305 // used by the C library's current locale.
18307 // The return value is %TRUE if the locale's encoding is UTF-8, in that
18308 // case you can perhaps avoid calling g_convert().
18310 // The string returned in @charset is not allocated, and should not be
18311 // freed.
18312 // RETURNS: %TRUE if the returned charset is UTF-8
18313 // <charset>: return location for character set name
18314 static int get_charset()(char** charset) nothrow {
18315 return g_get_charset(charset);
18319 // Gets the character set for the current locale.
18321 // of the character set. This string must be freed with g_free().
18322 // RETURNS: a newly allocated string containing the name
18323 static char* /*new*/ get_codeset()() nothrow {
18324 return g_get_codeset();
18328 // Gets the current directory.
18330 // The returned string should be freed when no longer needed.
18331 // The encoding of the returned string is system defined.
18332 // On Windows, it is always UTF-8.
18333 // RETURNS: the current directory
18334 static char* /*new*/ get_current_dir()() nothrow {
18335 return g_get_current_dir();
18339 // Equivalent to the UNIX gettimeofday() function, but portable.
18341 // You may find g_get_real_time() to be more convenient.
18342 // <result>: #GTimeVal structure in which to store current time.
18343 static void get_current_time()(TimeVal* result) nothrow {
18344 g_get_current_time(result);
18348 // VERSION: 2.28
18349 // Gets the list of environment variables for the current process.
18351 // The list is %NULL terminated and each item in the list is of the
18352 // form 'NAME=VALUE'.
18354 // This is equivalent to direct access to the 'environ' global variable,
18355 // except portable.
18357 // The return value is freshly allocated and it should be freed with
18358 // g_strfreev() when it is no longer needed.
18360 // environment variables
18361 // RETURNS: the list of
18362 static char** /*new*/ get_environ()() nothrow {
18363 return g_get_environ();
18367 // VERSION: 2.6
18368 // Determines the preferred character sets used for filenames.
18369 // The first character set from the @charsets is the filename encoding, the
18370 // subsequent character sets are used when trying to generate a displayable
18371 // representation of a filename, see g_filename_display_name().
18373 // On Unix, the character sets are determined by consulting the
18374 // environment variables <envar>G_FILENAME_ENCODING</envar> and
18375 // <envar>G_BROKEN_FILENAMES</envar>. On Windows, the character set
18376 // used in the GLib API is always UTF-8 and said environment variables
18377 // have no effect.
18379 // <envar>G_FILENAME_ENCODING</envar> may be set to a comma-separated list
18380 // of character set names. The special token "&commat;locale" is taken to
18381 // mean the character set for the <link linkend="setlocale">current
18382 // locale</link>. If <envar>G_FILENAME_ENCODING</envar> is not set, but
18383 // <envar>G_BROKEN_FILENAMES</envar> is, the character set of the current
18384 // locale is taken as the filename encoding. If neither environment variable
18385 // is set, UTF-8 is taken as the filename encoding, but the character
18386 // set of the current locale is also put in the list of encodings.
18388 // The returned @charsets belong to GLib and must not be freed.
18390 // Note that on Unix, regardless of the locale character set or
18391 // <envar>G_FILENAME_ENCODING</envar> value, the actual file names present
18392 // on a system might be in any random encoding or just gibberish.
18393 // RETURNS: %TRUE if the filename encoding is UTF-8.
18394 // <charsets>: return location for the %NULL-terminated list of encoding names
18395 static int get_filename_charsets()(char*** charsets) nothrow {
18396 return g_get_filename_charsets(charsets);
18400 // Gets the current user's home directory as defined in the
18401 // password database.
18403 // Note that in contrast to traditional UNIX tools, this function
18404 // prefers <filename>passwd</filename> entries over the <envar>HOME</envar>
18405 // environment variable.
18407 // One of the reasons for this decision is that applications in many
18408 // cases need special handling to deal with the case where
18409 // <envar>HOME</envar> is
18410 // <simplelist>
18411 // <member>Not owned by the user</member>
18412 // <member>Not writeable</member>
18413 // <member>Not even readable</member>
18414 // </simplelist>
18415 // Since applications are in general <emphasis>not</emphasis> written
18416 // to deal with these situations it was considered better to make
18417 // g_get_home_dir() not pay attention to <envar>HOME</envar> and to
18418 // return the real home directory for the user. If applications
18419 // want to pay attention to <envar>HOME</envar>, they can do:
18420 // |[
18421 // const char *homedir = g_getenv ("HOME");
18422 // if (!homedir)
18423 // homedir = g_get_home_dir (<!-- -->);
18424 // ]|
18425 // RETURNS: the current user's home directory
18426 static char* get_home_dir()() nothrow {
18427 return g_get_home_dir();
18431 // VERSION: 2.8
18432 // Return a name for the machine.
18434 // The returned name is not necessarily a fully-qualified domain name,
18435 // or even present in DNS or some other name service at all. It need
18436 // not even be unique on your local network or site, but usually it
18437 // is. Callers should not rely on the return value having any specific
18438 // properties like uniqueness for security purposes. Even if the name
18439 // of the machine is changed while an application is running, the
18440 // return value from this function does not change. The returned
18441 // string is owned by GLib and should not be modified or freed. If no
18442 // name can be determined, a default fixed string "localhost" is
18443 // returned.
18444 // RETURNS: the host name of the machine.
18445 static char* get_host_name()() nothrow {
18446 return g_get_host_name();
18450 // VERSION: 2.6
18451 // Computes a list of applicable locale names, which can be used to
18452 // e.g. construct locale-dependent filenames or search paths. The returned
18453 // list is sorted from most desirable to least desirable and always contains
18454 // the default locale "C".
18456 // For example, if LANGUAGE=de:en_US, then the returned list is
18457 // "de", "en_US", "en", "C".
18459 // This function consults the environment variables <envar>LANGUAGE</envar>,
18460 // <envar>LC_ALL</envar>, <envar>LC_MESSAGES</envar> and <envar>LANG</envar>
18461 // to find the list of locales specified by the user.
18463 // that must not be modified or freed.
18464 // RETURNS: a %NULL-terminated array of strings owned by GLib
18465 static char** get_language_names()() nothrow {
18466 return g_get_language_names();
18470 // VERSION: 2.28
18471 // Returns a list of derived variants of @locale, which can be used to
18472 // e.g. construct locale-dependent filenames or search paths. The returned
18473 // list is sorted from most desirable to least desirable.
18474 // This function handles territory, charset and extra locale modifiers.
18476 // For example, if @locale is "fr_BE", then the returned list
18477 // is "fr_BE", "fr".
18479 // If you need the list of variants for the <emphasis>current locale</emphasis>,
18480 // use g_get_language_names().
18482 // allocated array of newly allocated strings with the locale variants. Free with
18483 // g_strfreev().
18484 // RETURNS: a newly
18485 // <locale>: a locale identifier
18486 static char** /*new*/ get_locale_variants()(char* locale) nothrow {
18487 return g_get_locale_variants(locale);
18491 // VERSION: 2.28
18492 // Queries the system monotonic time, if available.
18494 // On POSIX systems with clock_gettime() and <literal>CLOCK_MONOTONIC</literal> this call
18495 // is a very shallow wrapper for that. Otherwise, we make a best effort
18496 // that probably involves returning the wall clock time (with at least
18497 // microsecond accuracy, subject to the limitations of the OS kernel).
18499 // It's important to note that POSIX <literal>CLOCK_MONOTONIC</literal> does
18500 // not count time spent while the machine is suspended.
18502 // On Windows, "limitations of the OS kernel" is a rather substantial
18503 // statement. Depending on the configuration of the system, the wall
18504 // clock time is updated as infrequently as 64 times a second (which
18505 // is approximately every 16ms). Also, the on XP (not on Vista or later)
18506 // the monitonic clock is locally monotonic, but may differ in exact
18507 // value between processes due to timer wrap handling.
18508 // RETURNS: the monotonic time, in microseconds
18509 static long get_monotonic_time()() nothrow {
18510 return g_get_monotonic_time();
18514 // Gets the name of the program. This name should <emphasis>not</emphasis>
18515 // be localized, contrast with g_get_application_name().
18516 // (If you are using GDK or GTK+ the program name is set in gdk_init(),
18517 // which is called by gtk_init(). The program name is found by taking
18518 // the last component of <literal>argv[0]</literal>.)
18520 // to GLib and must not be modified or freed.
18521 // RETURNS: the name of the program. The returned string belongs
18522 static char* /*new*/ get_prgname()() nothrow {
18523 return g_get_prgname();
18527 // Gets the real name of the user. This usually comes from the user's entry
18528 // in the <filename>passwd</filename> file. The encoding of the returned
18529 // string is system-defined. (On Windows, it is, however, always UTF-8.)
18530 // If the real user name cannot be determined, the string "Unknown" is
18531 // returned.
18532 // RETURNS: the user's real name.
18533 static char* get_real_name()() nothrow {
18534 return g_get_real_name();
18538 // VERSION: 2.28
18539 // Queries the system wall-clock time.
18541 // This call is functionally equivalent to g_get_current_time() except
18542 // that the return value is often more convenient than dealing with a
18543 // #GTimeVal.
18545 // You should only use this call if you are actually interested in the real
18546 // wall-clock time. g_get_monotonic_time() is probably more useful for
18547 // measuring intervals.
18548 // RETURNS: the number of microseconds since January 1, 1970 UTC.
18549 static long get_real_time()() nothrow {
18550 return g_get_real_time();
18554 // VERSION: 2.6
18555 // Returns an ordered list of base directories in which to access
18556 // system-wide configuration information.
18558 // On UNIX platforms this is determined using the mechanisms described in
18559 // the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
18560 // XDG Base Directory Specification</ulink>.
18561 // In this case the list of directories retrieved will be XDG_CONFIG_DIRS.
18563 // On Windows is the directory that contains application data for all users.
18564 // A typical path is C:\Documents and Settings\All Users\Application Data.
18565 // This folder is used for application data that is not user specific.
18566 // For example, an application can store a spell-check dictionary, a database
18567 // of clip art, or a log file in the CSIDL_COMMON_APPDATA folder.
18568 // This information will not roam and is available to anyone using the computer.
18570 // not be modified or freed.
18571 // RETURNS: a %NULL-terminated array of strings owned by GLib that must
18572 static char** get_system_config_dirs()() nothrow {
18573 return g_get_system_config_dirs();
18577 // VERSION: 2.6
18578 // Returns an ordered list of base directories in which to access
18579 // system-wide application data.
18581 // On UNIX platforms this is determined using the mechanisms described in
18582 // the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
18583 // XDG Base Directory Specification</ulink>
18584 // In this case the list of directories retrieved will be XDG_DATA_DIRS.
18586 // On Windows the first elements in the list are the Application Data
18587 // and Documents folders for All Users. (These can be determined only
18588 // on Windows 2000 or later and are not present in the list on other
18589 // Windows versions.) See documentation for CSIDL_COMMON_APPDATA and
18590 // CSIDL_COMMON_DOCUMENTS.
18592 // Then follows the "share" subfolder in the installation folder for
18593 // the package containing the DLL that calls this function, if it can
18594 // be determined.
18596 // Finally the list contains the "share" subfolder in the installation
18597 // folder for GLib, and in the installation folder for the package the
18598 // application's .exe file belongs to.
18600 // The installation folders above are determined by looking up the
18601 // folder where the module (DLL or EXE) in question is located. If the
18602 // folder's name is "bin", its parent is used, otherwise the folder
18603 // itself.
18605 // Note that on Windows the returned list can vary depending on where
18606 // this function is called.
18608 // not be modified or freed.
18609 // RETURNS: a %NULL-terminated array of strings owned by GLib that must
18610 static char** get_system_data_dirs()() nothrow {
18611 return g_get_system_data_dirs();
18615 // Gets the directory to use for temporary files. This is found from
18616 // inspecting the environment variables <envar>TMPDIR</envar>,
18617 // <envar>TMP</envar>, and <envar>TEMP</envar> in that order. If none
18618 // of those are defined "/tmp" is returned on UNIX and "C:\" on Windows.
18619 // The encoding of the returned string is system-defined. On Windows,
18620 // it is always UTF-8. The return value is never %NULL or the empty string.
18621 // RETURNS: the directory to use for temporary files.
18622 static char* get_tmp_dir()() nothrow {
18623 return g_get_tmp_dir();
18627 // VERSION: 2.6
18628 // Returns a base directory in which to store non-essential, cached
18629 // data specific to particular user.
18631 // On UNIX platforms this is determined using the mechanisms described in
18632 // the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
18633 // XDG Base Directory Specification</ulink>.
18634 // In this case the directory retrieved will be XDG_CACHE_HOME.
18636 // On Windows is the directory that serves as a common repository for
18637 // temporary Internet files. A typical path is
18638 // C:\Documents and Settings\username\Local Settings\Temporary Internet Files.
18639 // See documentation for CSIDL_INTERNET_CACHE.
18641 // or freed.
18642 // RETURNS: a string owned by GLib that must not be modified
18643 static char* get_user_cache_dir()() nothrow {
18644 return g_get_user_cache_dir();
18648 // VERSION: 2.6
18649 // Returns a base directory in which to store user-specific application
18650 // configuration information such as user preferences and settings.
18652 // On UNIX platforms this is determined using the mechanisms described in
18653 // the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
18654 // XDG Base Directory Specification</ulink>.
18655 // In this case the directory retrieved will be XDG_CONFIG_HOME.
18657 // On Windows this is the folder to use for local (as opposed to
18658 // roaming) application data. See documentation for
18659 // CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
18660 // what g_get_user_data_dir() returns.
18662 // or freed.
18663 // RETURNS: a string owned by GLib that must not be modified
18664 static char* get_user_config_dir()() nothrow {
18665 return g_get_user_config_dir();
18669 // VERSION: 2.6
18670 // Returns a base directory in which to access application data such
18671 // as icons that is customized for a particular user.
18673 // On UNIX platforms this is determined using the mechanisms described in
18674 // the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
18675 // XDG Base Directory Specification</ulink>.
18676 // In this case the directory retrieved will be XDG_DATA_HOME.
18678 // On Windows this is the folder to use for local (as opposed to
18679 // roaming) application data. See documentation for
18680 // CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
18681 // what g_get_user_config_dir() returns.
18683 // or freed.
18684 // RETURNS: a string owned by GLib that must not be modified
18685 static char* get_user_data_dir()() nothrow {
18686 return g_get_user_data_dir();
18690 // Gets the user name of the current user. The encoding of the returned
18691 // string is system-defined. On UNIX, it might be the preferred file name
18692 // encoding, or something else, and there is no guarantee that it is even
18693 // consistent on a machine. On Windows, it is always UTF-8.
18694 // RETURNS: the user name of the current user.
18695 static char* get_user_name()() nothrow {
18696 return g_get_user_name();
18700 // VERSION: 2.28
18701 // Returns a directory that is unique to the current user on the local
18702 // system.
18704 // On UNIX platforms this is determined using the mechanisms described in
18705 // the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
18706 // XDG Base Directory Specification</ulink>. This is the directory
18707 // specified in the <envar>XDG_RUNTIME_DIR</envar> environment variable.
18708 // In the case that this variable is not set, GLib will issue a warning
18709 // message to stderr and return the value of g_get_user_cache_dir().
18711 // On Windows this is the folder to use for local (as opposed to
18712 // roaming) application data. See documentation for
18713 // CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
18714 // what g_get_user_config_dir() returns.
18715 // RETURNS: a string owned by GLib that must not be modified or freed.
18716 static char* get_user_runtime_dir()() nothrow {
18717 return g_get_user_runtime_dir();
18721 // VERSION: 2.14
18722 // Returns the full path of a special directory using its logical id.
18724 // On Unix this is done using the XDG special user directories.
18725 // For compatibility with existing practise, %G_USER_DIRECTORY_DESKTOP
18726 // falls back to <filename>$HOME/Desktop</filename> when XDG special
18727 // user directories have not been set up.
18729 // Depending on the platform, the user might be able to change the path
18730 // of the special directory without requiring the session to restart; GLib
18731 // will not reflect any change once the special directories are loaded.
18733 // if the logical id was not found. The returned string is owned by
18734 // GLib and should not be modified or freed.
18735 // RETURNS: the path to the specified special directory, or %NULL
18736 // <directory>: the logical id of special directory
18737 static char* get_user_special_dir()(UserDirectory directory) nothrow {
18738 return g_get_user_special_dir(directory);
18742 // Returns the value of an environment variable.
18744 // The name and value are in the GLib file name encoding. On UNIX,
18745 // this means the actual bytes which might or might not be in some
18746 // consistent character set and encoding. On Windows, it is in UTF-8.
18747 // On Windows, in case the environment variable's value contains
18748 // references to other environment variables, they are expanded.
18750 // the environment variable is not found. The returned string
18751 // may be overwritten by the next call to g_getenv(), g_setenv()
18752 // or g_unsetenv().
18753 // RETURNS: the value of the environment variable, or %NULL if
18754 // <variable>: the environment variable to get, in the GLib file name encoding
18755 static char* getenv()(char* variable) nothrow {
18756 return g_getenv(variable);
18760 // VERSION: 2.32
18761 // MOVED TO: HashTable.add
18762 // This is a convenience function for using a #GHashTable as a set. It
18763 // is equivalent to calling g_hash_table_replace() with @key as both the
18764 // key and the value.
18766 // When a hash table only ever contains keys that have themselves as the
18767 // corresponding value it is able to be stored more efficiently. See
18768 // the discussion in the section description.
18769 // <hash_table>: a #GHashTable
18770 // <key>: a key to insert
18771 static void hash_table_add()(GLib2.HashTable* hash_table, void* key) nothrow {
18772 g_hash_table_add(hash_table, key);
18776 // VERSION: 2.32
18777 // MOVED TO: HashTable.contains
18778 // Checks if @key is in @hash_table.
18779 // <hash_table>: a #GHashTable
18780 static int hash_table_contains()(GLib2.HashTable* hash_table, const(void)* lookup_key) nothrow {
18781 return g_hash_table_contains(hash_table, lookup_key);
18785 // MOVED TO: HashTable.destroy
18786 // Destroys all keys and values in the #GHashTable and decrements its
18787 // reference count by 1. If keys and/or values are dynamically allocated,
18788 // you should either free them first or create the #GHashTable with destroy
18789 // notifiers using g_hash_table_new_full(). In the latter case the destroy
18790 // functions you supplied will be called on all keys and values during the
18791 // destruction phase.
18792 // <hash_table>: a #GHashTable
18793 static void hash_table_destroy()(GLib2.HashTable* hash_table) nothrow {
18794 g_hash_table_destroy(hash_table);
18798 // MOVED TO: HashTable.insert
18799 // Inserts a new key and value into a #GHashTable.
18801 // If the key already exists in the #GHashTable its current
18802 // value is replaced with the new value. If you supplied a
18803 // @value_destroy_func when creating the #GHashTable, the old
18804 // value is freed using that function. If you supplied a
18805 // @key_destroy_func when creating the #GHashTable, the passed
18806 // key is freed using that function.
18807 // <hash_table>: a #GHashTable
18808 // <key>: a key to insert
18809 // <value>: the value to associate with the key
18810 static void hash_table_insert()(GLib2.HashTable* hash_table, void* key, void* value) nothrow {
18811 g_hash_table_insert(hash_table, key, value);
18815 // MOVED TO: HashTable.lookup_extended
18816 // Looks up a key in the #GHashTable, returning the original key and the
18817 // associated value and a #gboolean which is %TRUE if the key was found. This
18818 // is useful if you need to free the memory allocated for the original key,
18819 // for example before calling g_hash_table_remove().
18821 // You can actually pass %NULL for @lookup_key to test
18822 // whether the %NULL key exists, provided the hash and equal functions
18823 // of @hash_table are %NULL-safe.
18824 // RETURNS: %TRUE if the key was found in the #GHashTable
18825 // <hash_table>: a #GHashTable
18826 // <lookup_key>: the key to look up
18827 // <orig_key>: return location for the original key, or %NULL
18828 // <value>: return location for the value associated with the key, or %NULL
18829 static int hash_table_lookup_extended()(GLib2.HashTable* hash_table, const(void)* lookup_key, void** orig_key=null, void** value=null) nothrow {
18830 return g_hash_table_lookup_extended(hash_table, lookup_key, orig_key, value);
18834 // MOVED TO: HashTable.remove
18835 // Removes a key and its associated value from a #GHashTable.
18837 // If the #GHashTable was created using g_hash_table_new_full(), the
18838 // key and value are freed using the supplied destroy functions, otherwise
18839 // you have to make sure that any dynamically allocated values are freed
18840 // yourself.
18841 // RETURNS: %TRUE if the key was found and removed from the #GHashTable
18842 // <hash_table>: a #GHashTable
18843 // <key>: the key to remove
18844 static int hash_table_remove()(GLib2.HashTable* hash_table, const(void)* key) nothrow {
18845 return g_hash_table_remove(hash_table, key);
18849 // VERSION: 2.12
18850 // MOVED TO: HashTable.remove_all
18851 // Removes all keys and their associated values from a #GHashTable.
18853 // If the #GHashTable was created using g_hash_table_new_full(),
18854 // the keys and values are freed using the supplied destroy functions,
18855 // otherwise you have to make sure that any dynamically allocated
18856 // values are freed yourself.
18857 // <hash_table>: a #GHashTable
18858 static void hash_table_remove_all()(GLib2.HashTable* hash_table) nothrow {
18859 g_hash_table_remove_all(hash_table);
18863 // MOVED TO: HashTable.replace
18864 // Inserts a new key and value into a #GHashTable similar to
18865 // g_hash_table_insert(). The difference is that if the key
18866 // already exists in the #GHashTable, it gets replaced by the
18867 // new key. If you supplied a @value_destroy_func when creating
18868 // the #GHashTable, the old value is freed using that function.
18869 // If you supplied a @key_destroy_func when creating the
18870 // #GHashTable, the old key is freed using that function.
18871 // <hash_table>: a #GHashTable
18872 // <key>: a key to insert
18873 // <value>: the value to associate with the key
18874 static void hash_table_replace()(GLib2.HashTable* hash_table, void* key, void* value) nothrow {
18875 g_hash_table_replace(hash_table, key, value);
18879 // MOVED TO: HashTable.size
18880 // Returns the number of elements contained in the #GHashTable.
18881 // RETURNS: the number of key/value pairs in the #GHashTable.
18882 // <hash_table>: a #GHashTable
18883 static uint hash_table_size()(GLib2.HashTable* hash_table) nothrow {
18884 return g_hash_table_size(hash_table);
18888 // MOVED TO: HashTable.steal
18889 // Removes a key and its associated value from a #GHashTable without
18890 // calling the key and value destroy functions.
18891 // RETURNS: %TRUE if the key was found and removed from the #GHashTable
18892 // <hash_table>: a #GHashTable
18893 // <key>: the key to remove
18894 static int hash_table_steal()(GLib2.HashTable* hash_table, const(void)* key) nothrow {
18895 return g_hash_table_steal(hash_table, key);
18899 // VERSION: 2.12
18900 // MOVED TO: HashTable.steal_all
18901 // Removes all keys and their associated values from a #GHashTable
18902 // without calling the key and value destroy functions.
18903 // <hash_table>: a #GHashTable
18904 static void hash_table_steal_all()(GLib2.HashTable* hash_table) nothrow {
18905 g_hash_table_steal_all(hash_table);
18909 // VERSION: 2.10
18910 // MOVED TO: HashTable.unref
18911 // Atomically decrements the reference count of @hash_table by one.
18912 // If the reference count drops to 0, all keys and values will be
18913 // destroyed, and all memory allocated by the hash table is released.
18914 // This function is MT-safe and may be called from any thread.
18915 // <hash_table>: a valid #GHashTable
18916 static void hash_table_unref()(GLib2.HashTable* hash_table) nothrow {
18917 g_hash_table_unref(hash_table);
18921 // MOVED TO: Hook.destroy
18922 // Destroys a #GHook, given its ID.
18923 // RETURNS: %TRUE if the #GHook was found in the #GHookList and destroyed
18924 // <hook_list>: a #GHookList
18925 // <hook_id>: a hook ID
18926 static int hook_destroy()(HookList* hook_list, c_ulong hook_id) nothrow {
18927 return g_hook_destroy(hook_list, hook_id);
18931 // MOVED TO: Hook.destroy_link
18932 // Removes one #GHook from a #GHookList, marking it
18933 // inactive and calling g_hook_unref() on it.
18934 // <hook_list>: a #GHookList
18935 // <hook>: the #GHook to remove
18936 static void hook_destroy_link()(HookList* hook_list, Hook* hook) nothrow {
18937 g_hook_destroy_link(hook_list, hook);
18941 // MOVED TO: Hook.free
18942 // Calls the #GHookList @finalize_hook function if it exists,
18943 // and frees the memory allocated for the #GHook.
18944 // <hook_list>: a #GHookList
18945 // <hook>: the #GHook to free
18946 static void hook_free()(HookList* hook_list, Hook* hook) nothrow {
18947 g_hook_free(hook_list, hook);
18951 // MOVED TO: Hook.insert_before
18952 // Inserts a #GHook into a #GHookList, before a given #GHook.
18953 // <hook_list>: a #GHookList
18954 // <sibling>: the #GHook to insert the new #GHook before
18955 // <hook>: the #GHook to insert
18956 static void hook_insert_before()(HookList* hook_list, Hook* sibling, Hook* hook) nothrow {
18957 g_hook_insert_before(hook_list, sibling, hook);
18961 // MOVED TO: Hook.prepend
18962 // Prepends a #GHook on the start of a #GHookList.
18963 // <hook_list>: a #GHookList
18964 // <hook>: the #GHook to add to the start of @hook_list
18965 static void hook_prepend()(HookList* hook_list, Hook* hook) nothrow {
18966 g_hook_prepend(hook_list, hook);
18970 // MOVED TO: Hook.unref
18971 // Decrements the reference count of a #GHook.
18972 // If the reference count falls to 0, the #GHook is removed
18973 // from the #GHookList and g_hook_free() is called to free it.
18974 // <hook_list>: a #GHookList
18975 // <hook>: the #GHook to unref
18976 static void hook_unref()(HookList* hook_list, Hook* hook) nothrow {
18977 g_hook_unref(hook_list, hook);
18981 // VERSION: 2.22
18982 // Tests if @hostname contains segments with an ASCII-compatible
18983 // encoding of an Internationalized Domain Name. If this returns
18984 // %TRUE, you should decode the hostname with g_hostname_to_unicode()
18985 // before displaying it to the user.
18987 // Note that a hostname might contain a mix of encoded and unencoded
18988 // segments, and so it is possible for g_hostname_is_non_ascii() and
18989 // g_hostname_is_ascii_encoded() to both return %TRUE for a name.
18991 // segments.
18992 // RETURNS: %TRUE if @hostname contains any ASCII-encoded
18993 // <hostname>: a hostname
18994 static int hostname_is_ascii_encoded()(char* hostname) nothrow {
18995 return g_hostname_is_ascii_encoded(hostname);
18999 // VERSION: 2.22
19000 // Tests if @hostname is the string form of an IPv4 or IPv6 address.
19001 // (Eg, "192.168.0.1".)
19002 // RETURNS: %TRUE if @hostname is an IP address
19003 // <hostname>: a hostname (or IP address in string form)
19004 static int hostname_is_ip_address()(char* hostname) nothrow {
19005 return g_hostname_is_ip_address(hostname);
19009 // VERSION: 2.22
19010 // Tests if @hostname contains Unicode characters. If this returns
19011 // %TRUE, you need to encode the hostname with g_hostname_to_ascii()
19012 // before using it in non-IDN-aware contexts.
19014 // Note that a hostname might contain a mix of encoded and unencoded
19015 // segments, and so it is possible for g_hostname_is_non_ascii() and
19016 // g_hostname_is_ascii_encoded() to both return %TRUE for a name.
19017 // RETURNS: %TRUE if @hostname contains any non-ASCII characters
19018 // <hostname>: a hostname
19019 static int hostname_is_non_ascii()(char* hostname) nothrow {
19020 return g_hostname_is_non_ascii(hostname);
19024 // VERSION: 2.22
19025 // Converts @hostname to its canonical ASCII form; an ASCII-only
19026 // string containing no uppercase letters and not ending with a
19027 // trailing dot.
19029 // @hostname is in some way invalid.
19030 // RETURNS: an ASCII hostname, which must be freed, or %NULL if
19031 // <hostname>: a valid UTF-8 or ASCII hostname
19032 static char* /*new*/ hostname_to_ascii()(char* hostname) nothrow {
19033 return g_hostname_to_ascii(hostname);
19037 // VERSION: 2.22
19038 // Converts @hostname to its canonical presentation form; a UTF-8
19039 // string in Unicode normalization form C, containing no uppercase
19040 // letters, no forbidden characters, and no ASCII-encoded segments,
19041 // and not ending with a trailing dot.
19043 // Of course if @hostname is not an internationalized hostname, then
19044 // the canonical presentation form will be entirely ASCII.
19046 // @hostname is in some way invalid.
19047 // RETURNS: a UTF-8 hostname, which must be freed, or %NULL if
19048 // <hostname>: a valid UTF-8 or ASCII hostname
19049 static char* /*new*/ hostname_to_unicode()(char* hostname) nothrow {
19050 return g_hostname_to_unicode(hostname);
19054 // Unintrospectable function: idle_add() / g_idle_add()
19055 // Adds a function to be called whenever there are no higher priority
19056 // events pending to the default main loop. The function is given the
19057 // default idle priority, #G_PRIORITY_DEFAULT_IDLE. If the function
19058 // returns %FALSE it is automatically removed from the list of event
19059 // sources and will not be called again.
19061 // This internally creates a main loop source using g_idle_source_new()
19062 // and attaches it to the main loop context using g_source_attach().
19063 // You can do these steps manually if you need greater control.
19064 // RETURNS: the ID (greater than 0) of the event source.
19065 // <function>: function to call
19066 // <data>: data to pass to @function.
19067 static uint idle_add()(SourceFunc function_, void* data) nothrow {
19068 return g_idle_add(function_, data);
19072 // Adds a function to be called whenever there are no higher priority
19073 // events pending. If the function returns %FALSE it is automatically
19074 // removed from the list of event sources and will not be called again.
19076 // This internally creates a main loop source using g_idle_source_new()
19077 // and attaches it to the main loop context using g_source_attach().
19078 // You can do these steps manually if you need greater control.
19079 // RETURNS: the ID (greater than 0) of the event source.
19080 // <priority>: the priority of the idle source. Typically this will be in the range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.
19081 // <function>: function to call
19082 // <data>: data to pass to @function
19083 // <notify>: function to call when the idle is removed, or %NULL
19084 static uint idle_add_full()(int priority, SourceFunc function_, void* data, DestroyNotify notify) nothrow {
19085 return g_idle_add_full(priority, function_, data, notify);
19089 // Removes the idle function with the given data.
19090 // RETURNS: %TRUE if an idle source was found and removed.
19091 // <data>: the data for the idle source's callback.
19092 static int idle_remove_by_data()(void* data) nothrow {
19093 return g_idle_remove_by_data(data);
19097 // Creates a new idle source.
19099 // The source will not initially be associated with any #GMainContext
19100 // and must be added to one with g_source_attach() before it will be
19101 // executed. Note that the default priority for idle sources is
19102 // %G_PRIORITY_DEFAULT_IDLE, as compared to other sources which
19103 // have a default priority of %G_PRIORITY_DEFAULT.
19104 // RETURNS: the newly-created idle source
19105 static Source* /*new*/ idle_source_new()() nothrow {
19106 return g_idle_source_new();
19110 // VERSION: 2.22
19111 // Compares the two #gint64 values being pointed to and returns
19112 // %TRUE if they are equal.
19113 // It can be passed to g_hash_table_new() as the @key_equal_func
19114 // parameter, when using non-%NULL pointers to 64-bit integers as keys in a
19115 // #GHashTable.
19116 // RETURNS: %TRUE if the two keys match.
19117 // <v1>: a pointer to a #gint64 key
19118 // <v2>: a pointer to a #gint64 key to compare with @v1
19119 static int int64_equal()(const(void)* v1, const(void)* v2) nothrow {
19120 return g_int64_equal(v1, v2);
19124 // VERSION: 2.22
19125 // Converts a pointer to a #gint64 to a hash value.
19127 // It can be passed to g_hash_table_new() as the @hash_func parameter,
19128 // when using non-%NULL pointers to 64-bit integer values as keys in a
19129 // #GHashTable.
19130 // RETURNS: a hash value corresponding to the key.
19131 // <v>: a pointer to a #gint64 key
19132 static uint int64_hash()(const(void)* v) nothrow {
19133 return g_int64_hash(v);
19137 // Compares the two #gint values being pointed to and returns
19138 // %TRUE if they are equal.
19139 // It can be passed to g_hash_table_new() as the @key_equal_func
19140 // parameter, when using non-%NULL pointers to integers as keys in a
19141 // #GHashTable.
19143 // Note that this function acts on pointers to #gint, not on #gint directly:
19144 // if your hash table's keys are of the form
19145 // <literal>GINT_TO_POINTER (n)</literal>, use g_direct_equal() instead.
19146 // RETURNS: %TRUE if the two keys match.
19147 // <v1>: a pointer to a #gint key
19148 // <v2>: a pointer to a #gint key to compare with @v1
19149 static int int_equal()(const(void)* v1, const(void)* v2) nothrow {
19150 return g_int_equal(v1, v2);
19154 // Converts a pointer to a #gint to a hash value.
19155 // It can be passed to g_hash_table_new() as the @hash_func parameter,
19156 // when using non-%NULL pointers to integer values as keys in a #GHashTable.
19158 // Note that this function acts on pointers to #gint, not on #gint directly:
19159 // if your hash table's keys are of the form
19160 // <literal>GINT_TO_POINTER (n)</literal>, use g_direct_hash() instead.
19161 // RETURNS: a hash value corresponding to the key.
19162 // <v>: a pointer to a #gint key
19163 static uint int_hash()(const(void)* v) nothrow {
19164 return g_int_hash(v);
19168 // VERSION: 2.10
19169 // Returns a canonical representation for @string. Interned strings can
19170 // be compared for equality by comparing the pointers, instead of using strcmp().
19171 // g_intern_static_string() does not copy the string, therefore @string must
19172 // not be freed or modified.
19173 // RETURNS: a canonical representation for the string
19174 // <string>: a static string
19175 static char* intern_static_string()(char* string_=null) nothrow {
19176 return g_intern_static_string(string_);
19180 // VERSION: 2.10
19181 // Returns a canonical representation for @string. Interned strings can
19182 // be compared for equality by comparing the pointers, instead of using strcmp().
19183 // RETURNS: a canonical representation for the string
19184 // <string>: a string
19185 static char* intern_string()(char* string_=null) nothrow {
19186 return g_intern_string(string_);
19190 // Unintrospectable function: io_add_watch() / g_io_add_watch()
19191 // Adds the #GIOChannel into the default main loop context
19192 // with the default priority.
19193 // RETURNS: the event source id
19194 // <channel>: a #GIOChannel
19195 // <condition>: the condition to watch for
19196 // <func>: the function to call when the condition is satisfied
19197 // <user_data>: user data to pass to @func
19198 static uint io_add_watch()(IOChannel* channel, IOCondition condition, IOFunc func, void* user_data) nothrow {
19199 return g_io_add_watch(channel, condition, func, user_data);
19203 // Adds the #GIOChannel into the default main loop context
19204 // with the given priority.
19206 // This internally creates a main loop source using g_io_create_watch()
19207 // and attaches it to the main loop context with g_source_attach().
19208 // You can do these steps manually if you need greater control.
19209 // RETURNS: the event source id
19210 // <channel>: a #GIOChannel
19211 // <priority>: the priority of the #GIOChannel source
19212 // <condition>: the condition to watch for
19213 // <func>: the function to call when the condition is satisfied
19214 // <user_data>: user data to pass to @func
19215 // <notify>: the function to call when the source is removed
19216 static uint io_add_watch_full()(IOChannel* channel, int priority, IOCondition condition, IOFunc func, void* user_data, DestroyNotify notify) nothrow {
19217 return g_io_add_watch_full(channel, priority, condition, func, user_data, notify);
19221 // MOVED TO: IOChannel.error_from_errno
19222 // Converts an <literal>errno</literal> error number to a #GIOChannelError.
19224 // %G_IO_CHANNEL_ERROR_INVAL.
19225 // RETURNS: a #GIOChannelError error number, e.g.
19226 // <en>: an <literal>errno</literal> error number, e.g. <literal>EINVAL</literal>
19227 static IOChannelError io_channel_error_from_errno()(int en) nothrow {
19228 return g_io_channel_error_from_errno(en);
19232 // MOVED TO: IOChannel.error_quark
19234 // RETURNS: the quark used as %G_IO_CHANNEL_ERROR
19235 static Quark io_channel_error_quark()() nothrow {
19236 return g_io_channel_error_quark();
19240 // Creates a #GSource that's dispatched when @condition is met for the
19241 // given @channel. For example, if condition is #G_IO_IN, the source will
19242 // be dispatched when there's data available for reading.
19244 // g_io_add_watch() is a simpler interface to this same functionality, for
19245 // the case where you want to add the source to the default main loop context
19246 // at the default priority.
19248 // On Windows, polling a #GSource created to watch a channel for a socket
19249 // puts the socket in non-blocking mode. This is a side-effect of the
19250 // implementation and unavoidable.
19251 // RETURNS: a new #GSource
19252 // <channel>: a #GIOChannel to watch
19253 // <condition>: conditions to watch for
19254 static Source* /*new*/ io_create_watch()(IOChannel* channel, IOCondition condition) nothrow {
19255 return g_io_create_watch(channel, condition);
19258 // MOVED TO: KeyFile.error_quark
19259 static Quark key_file_error_quark()() nothrow {
19260 return g_key_file_error_quark();
19264 // VERSION: 2.8
19265 // Gets the names of all variables set in the environment.
19267 // Programs that want to be portable to Windows should typically use
19268 // this function and g_getenv() instead of using the environ array
19269 // from the C library directly. On Windows, the strings in the environ
19270 // array are in system codepage encoding, while in most of the typical
19271 // use cases for environment variables in GLib-using programs you want
19272 // the UTF-8 encoding that this function and g_getenv() provide.
19274 // list of strings which must be freed with g_strfreev().
19275 // RETURNS: a %NULL-terminated
19276 static char** /*new*/ listenv()() nothrow {
19277 return g_listenv();
19281 // Converts a string from UTF-8 to the encoding used for strings by
19282 // the C runtime (usually the same as that used by the operating
19283 // system) in the <link linkend="setlocale">current locale</link>. On
19284 // Windows this means the system codepage.
19285 // RETURNS: The converted string, or %NULL on an error.
19286 // <utf8string>: a UTF-8 encoded string
19287 // <len>: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
19288 // <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.
19289 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
19290 static char* /*new*/ locale_from_utf8()(char* utf8string, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error=null) nothrow {
19291 return g_locale_from_utf8(utf8string, len, bytes_read, bytes_written, error);
19295 // Converts a string which is in the encoding used for strings by
19296 // the C runtime (usually the same as that used by the operating
19297 // system) in the <link linkend="setlocale">current locale</link> into a
19298 // UTF-8 string.
19299 // RETURNS: The converted string, or %NULL on an error.
19300 // <opsysstring>: a string in the encoding of the current locale. On Windows this means the system codepage.
19301 // <len>: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
19302 // <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.
19303 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
19304 static char* /*new*/ locale_to_utf8()(char* opsysstring, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error=null) nothrow {
19305 return g_locale_to_utf8(opsysstring, len, bytes_read, bytes_written, error);
19309 // Unintrospectable function: log() / g_log()
19310 // Logs an error or debugging message.
19312 // If the log level has been set as fatal, the abort()
19313 // function is called to terminate the program.
19314 // <log_domain>: the log domain, usually #G_LOG_DOMAIN
19315 // <log_level>: the log level, either from #GLogLevelFlags or a user-defined level
19316 // <format>: the message format. See the printf() documentation
19317 alias g_log log; // Variadic
19320 // The default log handler set up by GLib; g_log_set_default_handler()
19321 // allows to install an alternate default log handler.
19322 // This is used if no log handler has been set for the particular log
19323 // domain and log level combination. It outputs the message to stderr
19324 // or stdout and if the log level is fatal it calls abort().
19326 // The behavior of this log handler can be influenced by a number of
19327 // environment variables:
19328 // <variablelist>
19329 // <varlistentry>
19330 // <term><envar>G_MESSAGES_PREFIXED</envar></term>
19331 // <listitem>
19332 // A :-separated list of log levels for which messages should
19333 // be prefixed by the program name and PID of the aplication.
19334 // </listitem>
19335 // </varlistentry>
19336 // <varlistentry>
19337 // <term><envar>G_MESSAGES_DEBUG</envar></term>
19338 // <listitem>
19339 // A space-separated list of log domains for which debug and
19340 // informational messages are printed. By default these
19341 // messages are not printed.
19342 // </listitem>
19343 // </varlistentry>
19344 // </variablelist>
19346 // stderr is used for levels %G_LOG_LEVEL_ERROR, %G_LOG_LEVEL_CRITICAL,
19347 // %G_LOG_LEVEL_WARNING and %G_LOG_LEVEL_MESSAGE. stdout is used for
19348 // the rest.
19349 // <log_domain>: the log domain of the message
19350 // <log_level>: the level of the message
19351 // <message>: the message
19352 // <unused_data>: data passed from g_log() which is unused
19353 static void log_default_handler()(char* log_domain, LogLevelFlags log_level, char* message, void* unused_data) nothrow {
19354 g_log_default_handler(log_domain, log_level, message, unused_data);
19358 // Removes the log handler.
19359 // <log_domain>: the log domain
19360 // <handler_id>: the id of the handler, which was returned in g_log_set_handler()
19361 static void log_remove_handler()(char* log_domain, uint handler_id) nothrow {
19362 g_log_remove_handler(log_domain, handler_id);
19366 // Sets the message levels which are always fatal, in any log domain.
19367 // When a message with any of these levels is logged the program terminates.
19368 // You can only set the levels defined by GLib to be fatal.
19369 // %G_LOG_LEVEL_ERROR is always fatal.
19371 // You can also make some message levels fatal at runtime by setting
19372 // the <envar>G_DEBUG</envar> environment variable (see
19373 // <ulink url="glib-running.html">Running GLib Applications</ulink>).
19374 // RETURNS: the old fatal mask
19375 // <fatal_mask>: the mask containing bits set for each level of error which is to be fatal
19376 static LogLevelFlags log_set_always_fatal()(LogLevelFlags fatal_mask) nothrow {
19377 return g_log_set_always_fatal(fatal_mask);
19381 // Unintrospectable function: log_set_default_handler() / g_log_set_default_handler()
19382 // VERSION: 2.6
19383 // Installs a default log handler which is used if no
19384 // log handler has been set for the particular log domain
19385 // and log level combination. By default, GLib uses
19386 // g_log_default_handler() as default log handler.
19387 // RETURNS: the previous default log handler
19388 // <log_func>: the log handler function
19389 // <user_data>: data passed to the log handler
19390 static LogFunc log_set_default_handler()(LogFunc log_func, void* user_data) nothrow {
19391 return g_log_set_default_handler(log_func, user_data);
19395 // Sets the log levels which are fatal in the given domain.
19396 // %G_LOG_LEVEL_ERROR is always fatal.
19397 // RETURNS: the old fatal mask for the log domain
19398 // <log_domain>: the log domain
19399 // <fatal_mask>: the new fatal mask
19400 static LogLevelFlags log_set_fatal_mask()(char* log_domain, LogLevelFlags fatal_mask) nothrow {
19401 return g_log_set_fatal_mask(log_domain, fatal_mask);
19405 // Unintrospectable function: log_set_handler() / g_log_set_handler()
19406 // Sets the log handler for a domain and a set of log levels.
19407 // To handle fatal and recursive messages the @log_levels parameter
19408 // must be combined with the #G_LOG_FLAG_FATAL and #G_LOG_FLAG_RECURSION
19409 // bit flags.
19411 // Note that since the #G_LOG_LEVEL_ERROR log level is always fatal, if
19412 // you want to set a handler for this log level you must combine it with
19413 // #G_LOG_FLAG_FATAL.
19415 // <example>
19416 // <title>Adding a log handler for all warning messages in the default
19417 // (application) domain</title>
19418 // <programlisting>
19419 // g_log_set_handler (NULL, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
19420 // | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
19421 // </programlisting>
19422 // </example>
19424 // <example>
19425 // <title>Adding a log handler for all critical messages from GTK+</title>
19426 // <programlisting>
19427 // g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL
19428 // | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
19429 // </programlisting>
19430 // </example>
19432 // <example>
19433 // <title>Adding a log handler for <emphasis>all</emphasis> messages from
19434 // GLib</title>
19435 // <programlisting>
19436 // g_log_set_handler ("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
19437 // | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
19438 // </programlisting>
19439 // </example>
19440 // RETURNS: the id of the new handler
19441 // <log_domain>: the log domain, or %NULL for the default "" application domain
19442 // <log_levels>: the log levels to apply the log handler for. To handle fatal and recursive messages as well, combine the log levels with the #G_LOG_FLAG_FATAL and #G_LOG_FLAG_RECURSION bit flags.
19443 // <log_func>: the log handler function
19444 // <user_data>: data passed to the log handler
19445 static uint log_set_handler()(char* log_domain, LogLevelFlags log_levels, LogFunc log_func, void* user_data) nothrow {
19446 return g_log_set_handler(log_domain, log_levels, log_func, user_data);
19450 // Unintrospectable function: logv() / g_logv()
19451 // Logs an error or debugging message.
19453 // If the log level has been set as fatal, the abort()
19454 // function is called to terminate the program.
19455 // <log_domain>: the log domain
19456 // <log_level>: the log level
19457 // <format>: the message format. See the printf() documentation
19458 // <args>: the parameters to insert into the format string
19459 static void logv()(char* log_domain, LogLevelFlags log_level, char* format, va_list args) nothrow {
19460 g_logv(log_domain, log_level, format, args);
19464 // MOVED TO: MainContext.default
19465 // Returns the global default main context. This is the main context
19466 // used for main loop functions when a main loop is not explicitly
19467 // specified, and corresponds to the "main" main loop. See also
19468 // g_main_context_get_thread_default().
19469 // RETURNS: the global default main context.
19470 static MainContext* main_context_default()() nothrow {
19471 return g_main_context_default();
19475 // VERSION: 2.22
19476 // MOVED TO: MainContext.get_thread_default
19477 // Gets the thread-default #GMainContext for this thread. Asynchronous
19478 // operations that want to be able to be run in contexts other than
19479 // the default one should call this method or
19480 // g_main_context_ref_thread_default() to get a #GMainContext to add
19481 // their #GSource<!-- -->s to. (Note that even in single-threaded
19482 // programs applications may sometimes want to temporarily push a
19483 // non-default context, so it is not safe to assume that this will
19484 // always return %NULL if you are running in the default thread.)
19486 // If you need to hold a reference on the context, use
19487 // g_main_context_ref_thread_default() instead.
19489 // %NULL if the thread-default context is the global default context.
19490 // RETURNS: the thread-default #GMainContext, or
19491 static MainContext* main_context_get_thread_default()() nothrow {
19492 return g_main_context_get_thread_default();
19496 // VERSION: 2.32
19497 // MOVED TO: MainContext.ref_thread_default
19498 // Gets the thread-default #GMainContext for this thread, as with
19499 // g_main_context_get_thread_default(), but also adds a reference to
19500 // it with g_main_context_ref(). In addition, unlike
19501 // g_main_context_get_thread_default(), if the thread-default context
19502 // is the global default context, this will return that #GMainContext
19503 // (with a ref added to it) rather than returning %NULL.
19505 // with g_main_context_unref() when you are done with it.
19506 // RETURNS: the thread-default #GMainContext. Unref
19507 static MainContext* /*new*/ main_context_ref_thread_default()() nothrow {
19508 return g_main_context_ref_thread_default();
19512 // VERSION: 2.12
19513 // Returns the currently firing source for this thread.
19514 // RETURNS: The currently firing source or %NULL.
19515 static Source* main_current_source()() nothrow {
19516 return g_main_current_source();
19520 // Returns the depth of the stack of calls to
19521 // g_main_context_dispatch() on any #GMainContext in the current thread.
19522 // That is, when called from the toplevel, it gives 0. When
19523 // called from within a callback from g_main_context_iteration()
19524 // (or g_main_loop_run(), etc.) it returns 1. When called from within
19525 // a callback to a recursive call to g_main_context_iteration(),
19526 // it returns 2. And so forth.
19528 // This function is useful in a situation like the following:
19529 // Imagine an extremely simple "garbage collected" system.
19531 // |[
19532 // static GList *free_list;
19534 // gpointer
19535 // allocate_memory (gsize size)
19536 // {
19537 // gpointer result = g_malloc (size);
19538 // free_list = g_list_prepend (free_list, result);
19539 // return result;
19540 // }
19542 // void
19543 // free_allocated_memory (void)
19544 // {
19545 // GList *l;
19546 // for (l = free_list; l; l = l->next);
19547 // g_free (l->data);
19548 // g_list_free (free_list);
19549 // free_list = NULL;
19550 // }
19552 // [...]
19554 // while (TRUE);
19555 // {
19556 // g_main_context_iteration (NULL, TRUE);
19557 // free_allocated_memory();
19558 // }
19559 // ]|
19561 // This works from an application, however, if you want to do the same
19562 // thing from a library, it gets more difficult, since you no longer
19563 // control the main loop. You might think you can simply use an idle
19564 // function to make the call to free_allocated_memory(), but that
19565 // doesn't work, since the idle function could be called from a
19566 // recursive callback. This can be fixed by using g_main_depth()
19568 // |[
19569 // gpointer
19570 // allocate_memory (gsize size)
19571 // {
19572 // FreeListBlock *block = g_new (FreeListBlock, 1);
19573 // block->mem = g_malloc (size);
19574 // block->depth = g_main_depth ();
19575 // free_list = g_list_prepend (free_list, block);
19576 // return block->mem;
19577 // }
19579 // void
19580 // free_allocated_memory (void)
19581 // {
19582 // GList *l;
19584 // int depth = g_main_depth ();
19585 // for (l = free_list; l; );
19586 // {
19587 // GList *next = l->next;
19588 // FreeListBlock *block = l->data;
19589 // if (block->depth > depth)
19590 // {
19591 // g_free (block->mem);
19592 // g_free (block);
19593 // free_list = g_list_delete_link (free_list, l);
19594 // }
19596 // l = next;
19597 // }
19598 // }
19599 // ]|
19601 // There is a temptation to use g_main_depth() to solve
19602 // problems with reentrancy. For instance, while waiting for data
19603 // to be received from the network in response to a menu item,
19604 // the menu item might be selected again. It might seem that
19605 // one could make the menu item's callback return immediately
19606 // and do nothing if g_main_depth() returns a value greater than 1.
19607 // However, this should be avoided since the user then sees selecting
19608 // the menu item do nothing. Furthermore, you'll find yourself adding
19609 // these checks all over your code, since there are doubtless many,
19610 // many things that the user could do. Instead, you can use the
19611 // following techniques:
19613 // <orderedlist>
19614 // <listitem>
19615 // <para>
19616 // Use gtk_widget_set_sensitive() or modal dialogs to prevent
19617 // the user from interacting with elements while the main
19618 // loop is recursing.
19619 // </para>
19620 // </listitem>
19621 // <listitem>
19622 // <para>
19623 // Avoid main loop recursion in situations where you can't handle
19624 // arbitrary callbacks. Instead, structure your code so that you
19625 // simply return to the main loop and then get called again when
19626 // there is more work to do.
19627 // </para>
19628 // </listitem>
19629 // </orderedlist>
19630 // RETURNS: The main loop recursion level in the current thread
19631 static int main_depth()() nothrow {
19632 return g_main_depth();
19636 // Unintrospectable function: malloc() / g_malloc()
19637 // Allocates @n_bytes bytes of memory.
19638 // If @n_bytes is 0 it returns %NULL.
19639 // RETURNS: a pointer to the allocated memory
19640 // <n_bytes>: the number of bytes to allocate
19641 static void* malloc()(size_t n_bytes) nothrow {
19642 return g_malloc(n_bytes);
19646 // Unintrospectable function: malloc0() / g_malloc0()
19647 // Allocates @n_bytes bytes of memory, initialized to 0's.
19648 // If @n_bytes is 0 it returns %NULL.
19649 // RETURNS: a pointer to the allocated memory
19650 // <n_bytes>: the number of bytes to allocate
19651 static void* malloc0()(size_t n_bytes) nothrow {
19652 return g_malloc0(n_bytes);
19656 // Unintrospectable function: malloc0_n() / g_malloc0_n()
19657 // VERSION: 2.24
19658 // This function is similar to g_malloc0(), allocating (@n_blocks * @n_block_bytes) bytes,
19659 // but care is taken to detect possible overflow during multiplication.
19660 // RETURNS: a pointer to the allocated memory
19661 // <n_blocks>: the number of blocks to allocate
19662 // <n_block_bytes>: the size of each block in bytes
19663 static void* malloc0_n()(size_t n_blocks, size_t n_block_bytes) nothrow {
19664 return g_malloc0_n(n_blocks, n_block_bytes);
19668 // Unintrospectable function: malloc_n() / g_malloc_n()
19669 // VERSION: 2.24
19670 // This function is similar to g_malloc(), allocating (@n_blocks * @n_block_bytes) bytes,
19671 // but care is taken to detect possible overflow during multiplication.
19672 // RETURNS: a pointer to the allocated memory
19673 // <n_blocks>: the number of blocks to allocate
19674 // <n_block_bytes>: the size of each block in bytes
19675 static void* malloc_n()(size_t n_blocks, size_t n_block_bytes) nothrow {
19676 return g_malloc_n(n_blocks, n_block_bytes);
19680 // Unintrospectable function: markup_collect_attributes() / g_markup_collect_attributes()
19681 // VERSION: 2.16
19682 // Collects the attributes of the element from the data passed to the
19683 // #GMarkupParser start_element function, dealing with common error
19684 // conditions and supporting boolean values.
19686 // This utility function is not required to write a parser but can save
19687 // a lot of typing.
19689 // The @element_name, @attribute_names, @attribute_values and @error
19690 // parameters passed to the start_element callback should be passed
19691 // unmodified to this function.
19693 // Following these arguments is a list of "supported" attributes to collect.
19694 // It is an error to specify multiple attributes with the same name. If any
19695 // attribute not in the list appears in the @attribute_names array then an
19696 // unknown attribute error will result.
19698 // The #GMarkupCollectType field allows specifying the type of collection
19699 // to perform and if a given attribute must appear or is optional.
19701 // The attribute name is simply the name of the attribute to collect.
19703 // The pointer should be of the appropriate type (see the descriptions
19704 // under #GMarkupCollectType) and may be %NULL in case a particular
19705 // attribute is to be allowed but ignored.
19707 // This function deals with issuing errors for missing attributes
19708 // (of type %G_MARKUP_ERROR_MISSING_ATTRIBUTE), unknown attributes
19709 // (of type %G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE) and duplicate
19710 // attributes (of type %G_MARKUP_ERROR_INVALID_CONTENT) as well
19711 // as parse errors for boolean-valued attributes (again of type
19712 // %G_MARKUP_ERROR_INVALID_CONTENT). In all of these cases %FALSE
19713 // will be returned and @error will be set as appropriate.
19714 // RETURNS: %TRUE if successful
19715 // <element_name>: the current tag name
19716 // <attribute_names>: the attribute names
19717 // <attribute_values>: the attribute values
19718 // <error>: a pointer to a #GError or %NULL
19719 // <first_type>: the #GMarkupCollectType of the first attribute
19720 // <first_attr>: the name of the first attribute
19721 alias g_markup_collect_attributes markup_collect_attributes; // Variadic
19723 static Quark markup_error_quark()() nothrow {
19724 return g_markup_error_quark();
19728 // Escapes text so that the markup parser will parse it verbatim.
19729 // Less than, greater than, ampersand, etc. are replaced with the
19730 // corresponding entities. This function would typically be used
19731 // when writing out a file to be parsed with the markup parser.
19733 // Note that this function doesn't protect whitespace and line endings
19734 // from being processed according to the XML rules for normalization
19735 // of line endings and attribute values.
19737 // Note also that this function will produce character references in
19738 // the range of &amp;#x1; ... &amp;#x1f; for all control sequences
19739 // except for tabstop, newline and carriage return. The character
19740 // references in this range are not valid XML 1.0, but they are
19741 // valid XML 1.1 and will be accepted by the GMarkup parser.
19742 // RETURNS: a newly allocated string with the escaped text
19743 // <text>: some valid UTF-8 text
19744 // <length>: length of @text in bytes, or -1 if the text is nul-terminated
19745 static char* /*new*/ markup_escape_text()(char* text, ssize_t length) nothrow {
19746 return g_markup_escape_text(text, length);
19750 // Unintrospectable function: markup_printf_escaped() / g_markup_printf_escaped()
19751 // VERSION: 2.4
19752 // Formats arguments according to @format, escaping
19753 // all string and character arguments in the fashion
19754 // of g_markup_escape_text(). This is useful when you
19755 // want to insert literal strings into XML-style markup
19756 // output, without having to worry that the strings
19757 // might themselves contain markup.
19759 // |[
19760 // const char *store = "Fortnum &amp; Mason";
19761 // const char *item = "Tea";
19762 // char *output;
19763 // &nbsp;
19764 // output = g_markup_printf_escaped ("&lt;purchase&gt;"
19765 // "&lt;store&gt;&percnt;s&lt;/store&gt;"
19766 // "&lt;item&gt;&percnt;s&lt;/item&gt;"
19767 // "&lt;/purchase&gt;",
19768 // store, item);
19769 // ]|
19771 // operation. Free with g_free().
19772 // RETURNS: newly allocated result from formatting
19773 // <format>: printf() style format string
19774 alias g_markup_printf_escaped markup_printf_escaped; // Variadic
19777 // Unintrospectable function: markup_vprintf_escaped() / g_markup_vprintf_escaped()
19778 // VERSION: 2.4
19779 // Formats the data in @args according to @format, escaping
19780 // all string and character arguments in the fashion
19781 // of g_markup_escape_text(). See g_markup_printf_escaped().
19783 // operation. Free with g_free().
19784 // RETURNS: newly allocated result from formatting
19785 // <format>: printf() style format string
19786 // <args>: variable argument list, similar to vprintf()
19787 static char* /*new*/ markup_vprintf_escaped()(char* format, va_list args) nothrow {
19788 return g_markup_vprintf_escaped(format, args);
19792 // Checks whether the allocator used by g_malloc() is the system's
19793 // malloc implementation. If it returns %TRUE memory allocated with
19794 // malloc() can be used interchangeable with memory allocated using g_malloc().
19795 // This function is useful for avoiding an extra copy of allocated memory returned
19796 // by a non-GLib-based API.
19798 // A different allocator can be set using g_mem_set_vtable().
19799 // RETURNS: if %TRUE, malloc() and g_malloc() can be mixed.
19800 static int mem_is_system_malloc()() nothrow {
19801 return g_mem_is_system_malloc();
19805 // Outputs a summary of memory usage.
19807 // It outputs the frequency of allocations of different sizes,
19808 // the total number of bytes which have been allocated,
19809 // the total number of bytes which have been freed,
19810 // and the difference between the previous two values, i.e. the number of bytes
19811 // still in use.
19813 // Note that this function will not output anything unless you have
19814 // previously installed the #glib_mem_profiler_table with g_mem_set_vtable().
19815 static void mem_profile()() nothrow {
19816 g_mem_profile();
19820 // Sets the #GMemVTable to use for memory allocation. You can use this to provide
19821 // custom memory allocation routines. <emphasis>This function must be called
19822 // before using any other GLib functions.</emphasis> The @vtable only needs to
19823 // provide malloc(), realloc(), and free() functions; GLib can provide default
19824 // implementations of the others. The malloc() and realloc() implementations
19825 // should return %NULL on failure, GLib will handle error-checking for you.
19826 // @vtable is copied, so need not persist after this function has been called.
19827 // <vtable>: table of memory allocation routines.
19828 static void mem_set_vtable()(MemVTable* vtable) nothrow {
19829 g_mem_set_vtable(vtable);
19833 // Unintrospectable function: memdup() / g_memdup()
19834 // Allocates @byte_size bytes of memory, and copies @byte_size bytes into it
19835 // from @mem. If @mem is %NULL it returns %NULL.
19837 // is %NULL.
19838 // RETURNS: a pointer to the newly-allocated copy of the memory, or %NULL if @mem
19839 // <mem>: the memory to copy.
19840 // <byte_size>: the number of bytes to copy.
19841 static void* memdup()(const(void)* mem, uint byte_size) nothrow {
19842 return g_memdup(mem, byte_size);
19846 // VERSION: 2.8
19847 // Create a directory if it doesn't already exist. Create intermediate
19848 // parent directories as needed, too.
19850 // created. Returns -1 if an error occurred, with errno set.
19851 // RETURNS: 0 if the directory already exists, or was successfully
19852 // <pathname>: a pathname in the GLib file name encoding
19853 // <mode>: permissions to use for newly created directories
19854 static int mkdir_with_parents()(char* pathname, int mode) nothrow {
19855 return g_mkdir_with_parents(pathname, mode);
19859 // VERSION: 2.30
19860 // Creates a temporary directory. See the mkdtemp() documentation
19861 // on most UNIX-like systems.
19863 // The parameter is a string that should follow the rules for
19864 // mkdtemp() templates, i.e. contain the string "XXXXXX".
19865 // g_mkdtemp() is slightly more flexible than mkdtemp() in that the
19866 // sequence does not have to occur at the very end of the template
19867 // and you can pass a @mode and additional @flags. The X string will
19868 // be modified to form the name of a directory that didn't exist.
19869 // The string should be in the GLib file name encoding. Most importantly,
19870 // on Windows it should be in UTF-8.
19872 // to hold the directory name. In case of errors, %NULL is
19873 // returned and %errno will be set.
19874 // RETURNS: A pointer to @tmpl, which has been modified
19875 // <tmpl>: template directory name
19876 static char* /*new*/ mkdtemp()(char* tmpl) nothrow {
19877 return g_mkdtemp(tmpl);
19881 // VERSION: 2.30
19882 // Creates a temporary directory. See the mkdtemp() documentation
19883 // on most UNIX-like systems.
19885 // The parameter is a string that should follow the rules for
19886 // mkdtemp() templates, i.e. contain the string "XXXXXX".
19887 // g_mkdtemp() is slightly more flexible than mkdtemp() in that the
19888 // sequence does not have to occur at the very end of the template
19889 // and you can pass a @mode. The X string will be modified to form
19890 // the name of a directory that didn't exist. The string should be
19891 // in the GLib file name encoding. Most importantly, on Windows it
19892 // should be in UTF-8.
19894 // to hold the directory name. In case of errors, %NULL is
19895 // returned, and %errno will be set.
19896 // RETURNS: A pointer to @tmpl, which has been modified
19897 // <tmpl>: template directory name
19898 // <mode>: permissions to create the temporary directory with
19899 static char* /*new*/ mkdtemp_full()(char* tmpl, int mode) nothrow {
19900 return g_mkdtemp_full(tmpl, mode);
19904 // Opens a temporary file. See the mkstemp() documentation
19905 // on most UNIX-like systems.
19907 // The parameter is a string that should follow the rules for
19908 // mkstemp() templates, i.e. contain the string "XXXXXX".
19909 // g_mkstemp() is slightly more flexible than mkstemp() in that the
19910 // sequence does not have to occur at the very end of the template.
19911 // The X string will be modified to form the name of a file that
19912 // didn't exist. The string should be in the GLib file name encoding.
19913 // Most importantly, on Windows it should be in UTF-8.
19915 // opened for reading and writing. The file is opened in binary
19916 // mode on platforms where there is a difference. The file handle
19917 // should be closed with close(). In case of errors, -1 is
19918 // returned and %errno will be set.
19919 // RETURNS: A file handle (as from open()) to the file
19920 // <tmpl>: template filename
19921 static int mkstemp()(char* tmpl) nothrow {
19922 return g_mkstemp(tmpl);
19926 // VERSION: 2.22
19927 // Opens a temporary file. See the mkstemp() documentation
19928 // on most UNIX-like systems.
19930 // The parameter is a string that should follow the rules for
19931 // mkstemp() templates, i.e. contain the string "XXXXXX".
19932 // g_mkstemp_full() is slightly more flexible than mkstemp()
19933 // in that the sequence does not have to occur at the very end of the
19934 // template and you can pass a @mode and additional @flags. The X
19935 // string will be modified to form the name of a file that didn't exist.
19936 // The string should be in the GLib file name encoding. Most importantly,
19937 // on Windows it should be in UTF-8.
19939 // opened for reading and writing. The file handle should be
19940 // closed with close(). In case of errors, -1 is returned
19941 // and %errno will be set.
19942 // RETURNS: A file handle (as from open()) to the file
19943 // <tmpl>: template filename
19944 // <flags>: flags to pass to an open() call in addition to O_EXCL and O_CREAT, which are passed automatically
19945 // <mode>: permissions to create the temporary file with
19946 static int mkstemp_full()(char* tmpl, int flags, int mode) nothrow {
19947 return g_mkstemp_full(tmpl, flags, mode);
19951 // Set the pointer at the specified location to %NULL.
19952 // <nullify_location>: the memory address of the pointer.
19953 static void nullify_pointer()(void** nullify_location) nothrow {
19954 g_nullify_pointer(nullify_location);
19958 // Prompts the user with
19959 // <computeroutput>[E]xit, [H]alt, show [S]tack trace or [P]roceed</computeroutput>.
19960 // This function is intended to be used for debugging use only.
19961 // The following example shows how it can be used together with
19962 // the g_log() functions.
19964 // |[
19965 // &num;include &lt;glib.h&gt;
19967 // static void
19968 // log_handler (const gchar *log_domain,
19969 // GLogLevelFlags log_level,
19970 // const gchar *message,
19971 // gpointer user_data)
19972 // {
19973 // g_log_default_handler (log_domain, log_level, message, user_data);
19975 // g_on_error_query (MY_PROGRAM_NAME);
19976 // }
19978 // int
19979 // main (int argc, char *argv[])
19980 // {
19981 // g_log_set_handler (MY_LOG_DOMAIN,
19982 // G_LOG_LEVEL_WARNING |
19983 // G_LOG_LEVEL_ERROR |
19984 // G_LOG_LEVEL_CRITICAL,
19985 // log_handler,
19986 // NULL);
19987 // /&ast; ... &ast;/
19988 // ]|
19990 // If [E]xit is selected, the application terminates with a call
19991 // to <literal>_exit(0)</literal>.
19993 // If [S]tack trace is selected, g_on_error_stack_trace() is called.
19994 // This invokes <command>gdb</command>, which attaches to the current
19995 // process and shows a stack trace. The prompt is then shown again.
19997 // If [P]roceed is selected, the function returns.
19999 // This function may cause different actions on non-UNIX platforms.
20000 // <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)
20001 static void on_error_query()(char* prg_name) nothrow {
20002 g_on_error_query(prg_name);
20006 // Invokes <command>gdb</command>, which attaches to the current
20007 // process and shows a stack trace. Called by g_on_error_query()
20008 // when the [S]tack trace option is selected. You can get the current
20009 // process's "program name" with g_get_prgname(), assuming that you
20010 // have called gtk_init() or gdk_init().
20012 // This function may cause different actions on non-UNIX platforms.
20013 // <prg_name>: the program name, needed by <command>gdb</command> for the [S]tack trace option.
20014 static void on_error_stack_trace()(char* prg_name) nothrow {
20015 g_on_error_stack_trace(prg_name);
20019 // VERSION: 2.14
20020 // MOVED TO: Once.init_enter
20021 // Function to be called when starting a critical initialization
20022 // section. The argument @location must point to a static
20023 // 0-initialized variable that will be set to a value other than 0 at
20024 // the end of the initialization section. In combination with
20025 // g_once_init_leave() and the unique address @value_location, it can
20026 // be ensured that an initialization section will be executed only once
20027 // during a program's life time, and that concurrent threads are
20028 // blocked until initialization completed. To be used in constructs
20029 // like this:
20031 // |[
20032 // static gsize initialization_value = 0;
20034 // if (g_once_init_enter (&amp;initialization_value))
20035 // {
20036 // gsize setup_value = 42; /&ast;* initialization code here *&ast;/
20038 // g_once_init_leave (&amp;initialization_value, setup_value);
20039 // }
20041 // /&ast;* use initialization_value here *&ast;/
20042 // ]|
20044 // %FALSE and blocks otherwise
20045 // RETURNS: %TRUE if the initialization section should be entered,
20046 // <location>: location of a static initializable variable containing 0
20047 static int once_init_enter()(void* location) nothrow {
20048 return g_once_init_enter(location);
20052 // VERSION: 2.14
20053 // MOVED TO: Once.init_leave
20054 // Counterpart to g_once_init_enter(). Expects a location of a static
20055 // 0-initialized initialization variable, and an initialization value
20056 // other than 0. Sets the variable to the initialization value, and
20057 // releases concurrent threads blocking in g_once_init_enter() on this
20058 // initialization variable.
20059 // <location>: location of a static initializable variable containing 0
20060 // <result>: new non-0 value for *@value_location
20061 static void once_init_leave()(void* location, size_t result) nothrow {
20062 g_once_init_leave(location, result);
20065 static Quark option_error_quark()() nothrow {
20066 return g_option_error_quark();
20070 // Parses a string containing debugging options
20071 // into a %guint containing bit flags. This is used
20072 // within GDK and GTK+ to parse the debug options passed on the
20073 // command line or through environment variables.
20075 // If @string is equal to <code>"all"</code>, all flags are set. Any flags
20076 // specified along with <code>"all"</code> in @string are inverted; thus,
20077 // <code>"all,foo,bar"</code> or <code>"foo,bar,all"</code> sets all flags
20078 // except those corresponding to <code>"foo"</code> and <code>"bar"</code>.
20080 // If @string is equal to <code>"help"</code>, all the available keys in @keys
20081 // are printed out to standard error.
20082 // RETURNS: the combined set of bit flags.
20083 // <string>: a list of debug options separated by colons, spaces, or commas, or %NULL.
20084 // <keys>: pointer to an array of #GDebugKey which associate strings with bit flags.
20085 // <nkeys>: the number of #GDebugKey<!-- -->s in the array.
20086 static uint parse_debug_string()(char* string_, DebugKey* keys, uint nkeys) nothrow {
20087 return g_parse_debug_string(string_, keys, nkeys);
20091 // Gets the last component of the filename.
20093 // If @file_name ends with a directory separator it gets the component
20094 // before the last slash. If @file_name consists only of directory
20095 // separators (and on Windows, possibly a drive letter), a single
20096 // separator is returned. If @file_name is empty, it gets ".".
20098 // component of the filename
20099 // RETURNS: a newly allocated string containing the last
20100 // <file_name>: the name of the file
20101 static char* /*new*/ path_get_basename()(char* file_name) nothrow {
20102 return g_path_get_basename(file_name);
20106 // Gets the directory components of a file name.
20108 // If the file name has no directory components "." is returned.
20109 // The returned string should be freed when no longer needed.
20110 // RETURNS: the directory components of the file
20111 // <file_name>: the name of the file
20112 static char* /*new*/ path_get_dirname()(char* file_name) nothrow {
20113 return g_path_get_dirname(file_name);
20117 // Returns %TRUE if the given @file_name is an absolute file name.
20118 // Note that this is a somewhat vague concept on Windows.
20120 // On POSIX systems, an absolute file name is well-defined. It always
20121 // starts from the single root directory. For example "/usr/local".
20123 // On Windows, the concepts of current drive and drive-specific
20124 // current directory introduce vagueness. This function interprets as
20125 // an absolute file name one that either begins with a directory
20126 // separator such as "\Users\tml" or begins with the root on a drive,
20127 // for example "C:\Windows". The first case also includes UNC paths
20128 // such as "\\myserver\docs\foo". In all cases, either slashes or
20129 // backslashes are accepted.
20131 // Note that a file name relative to the current drive root does not
20132 // truly specify a file uniquely over time and across processes, as
20133 // the current drive is a per-process value and can be changed.
20135 // File names relative the current directory on some specific drive,
20136 // such as "D:foo/bar", are not interpreted as absolute by this
20137 // function, but they obviously are not relative to the normal current
20138 // directory as returned by getcwd() or g_get_current_dir()
20139 // either. Such paths should be avoided, or need to be handled using
20140 // Windows-specific code.
20141 // RETURNS: %TRUE if @file_name is absolute
20142 // <file_name>: a file name
20143 static int path_is_absolute()(char* file_name) nothrow {
20144 return g_path_is_absolute(file_name);
20148 // Returns a pointer into @file_name after the root component,
20149 // i.e. after the "/" in UNIX or "C:\" under Windows. If @file_name
20150 // is not an absolute path it returns %NULL.
20151 // RETURNS: a pointer into @file_name after the root component
20152 // <file_name>: a file name
20153 static char* path_skip_root()(char* file_name) nothrow {
20154 return g_path_skip_root(file_name);
20158 // Matches a string against a compiled pattern. Passing the correct
20159 // length of the string given is mandatory. The reversed string can be
20160 // omitted by passing %NULL, this is more efficient if the reversed
20161 // version of the string to be matched is not at hand, as
20162 // g_pattern_match() will only construct it if the compiled pattern
20163 // requires reverse matches.
20165 // Note that, if the user code will (possibly) match a string against a
20166 // multitude of patterns containing wildcards, chances are high that
20167 // some patterns will require a reversed string. In this case, it's
20168 // more efficient to provide the reversed string to avoid multiple
20169 // constructions thereof in the various calls to g_pattern_match().
20171 // Note also that the reverse of a UTF-8 encoded string can in general
20172 // <emphasis>not</emphasis> be obtained by g_strreverse(). This works
20173 // only if the string doesn't contain any multibyte characters. GLib
20174 // offers the g_utf8_strreverse() function to reverse UTF-8 encoded
20175 // strings.
20176 // <pspec>: a #GPatternSpec
20177 // <string_length>: the length of @string (in bytes, i.e. strlen(), <emphasis>not</emphasis> g_utf8_strlen())
20178 // <string>: the UTF-8 encoded string to match
20179 // <string_reversed>: the reverse of @string or %NULL
20180 static int pattern_match()(PatternSpec* pspec, uint string_length, char* string_, char* string_reversed) nothrow {
20181 return g_pattern_match(pspec, string_length, string_, string_reversed);
20185 // Matches a string against a pattern given as a string. If this
20186 // function is to be called in a loop, it's more efficient to compile
20187 // the pattern once with g_pattern_spec_new() and call
20188 // g_pattern_match_string() repeatedly.
20189 // <pattern>: the UTF-8 encoded pattern
20190 // <string>: the UTF-8 encoded string to match
20191 static int pattern_match_simple()(char* pattern, char* string_) nothrow {
20192 return g_pattern_match_simple(pattern, string_);
20196 // Matches a string against a compiled pattern. If the string is to be
20197 // matched against more than one pattern, consider using
20198 // g_pattern_match() instead while supplying the reversed string.
20199 // <pspec>: a #GPatternSpec
20200 // <string>: the UTF-8 encoded string to match
20201 static int pattern_match_string()(PatternSpec* pspec, char* string_) nothrow {
20202 return g_pattern_match_string(pspec, string_);
20206 // VERSION: 2.30
20207 // This is equivalent to g_bit_lock, but working on pointers (or other
20208 // pointer-sized values).
20210 // For portability reasons, you may only lock on the bottom 32 bits of
20211 // the pointer.
20212 // <address>: a pointer to a #gpointer-sized value
20213 // <lock_bit>: a bit value between 0 and 31
20214 static void pointer_bit_lock()(void* address, int lock_bit) nothrow {
20215 g_pointer_bit_lock(address, lock_bit);
20219 // VERSION: 2.30
20220 // This is equivalent to g_bit_trylock, but working on pointers (or
20221 // other pointer-sized values).
20223 // For portability reasons, you may only lock on the bottom 32 bits of
20224 // the pointer.
20225 // RETURNS: %TRUE if the lock was acquired
20226 // <address>: a pointer to a #gpointer-sized value
20227 // <lock_bit>: a bit value between 0 and 31
20228 static int pointer_bit_trylock()(void* address, int lock_bit) nothrow {
20229 return g_pointer_bit_trylock(address, lock_bit);
20233 // VERSION: 2.30
20234 // This is equivalent to g_bit_unlock, but working on pointers (or other
20235 // pointer-sized values).
20237 // For portability reasons, you may only lock on the bottom 32 bits of
20238 // the pointer.
20239 // <address>: a pointer to a #gpointer-sized value
20240 // <lock_bit>: a bit value between 0 and 31
20241 static void pointer_bit_unlock()(void* address, int lock_bit) nothrow {
20242 g_pointer_bit_unlock(address, lock_bit);
20246 // VERSION: 2.20
20247 // Polls @fds, as with the poll() system call, but portably. (On
20248 // systems that don't have poll(), it is emulated using select().)
20249 // This is used internally by #GMainContext, but it can be called
20250 // directly if you need to block until a file descriptor is ready, but
20251 // don't want to run the full main loop.
20253 // Each element of @fds is a #GPollFD describing a single file
20254 // descriptor to poll. The %fd field indicates the file descriptor,
20255 // and the %events field indicates the events to poll for. On return,
20256 // the %revents fields will be filled with the events that actually
20257 // occurred.
20259 // On POSIX systems, the file descriptors in @fds can be any sort of
20260 // file descriptor, but the situation is much more complicated on
20261 // Windows. If you need to use g_poll() in code that has to run on
20262 // Windows, the easiest solution is to construct all of your
20263 // #GPollFD<!-- -->s with g_io_channel_win32_make_pollfd().
20265 // were filled in, or 0 if the operation timed out, or -1 on error or
20266 // if the call was interrupted.
20267 // RETURNS: the number of entries in @fds whose %revents fields
20268 // <fds>: file descriptors to poll
20269 // <nfds>: the number of file descriptors in @fds
20270 // <timeout>: amount of time to wait, in milliseconds, or -1 to wait forever
20271 static int poll()(PollFD* fds, uint nfds, int timeout) nothrow {
20272 return g_poll(fds, nfds, timeout);
20276 // Unintrospectable function: prefix_error() / g_prefix_error()
20277 // VERSION: 2.16
20278 // Formats a string according to @format and
20279 // prefix it to an existing error message. If
20280 // nothing.
20282 // If *@err is %NULL (ie: an error variable is
20283 // present but there is no error condition) then
20284 // also do nothing. Whether or not it makes
20285 // sense to take advantage of this feature is up
20286 // to you.
20287 // <err>: a return location for a #GError, or %NULL
20288 // <format>: printf()-style format string
20289 alias g_prefix_error prefix_error; // Variadic
20292 // Unintrospectable function: print() / g_print()
20293 // Outputs a formatted message via the print handler.
20294 // The default print handler simply outputs the message to stdout.
20296 // g_print() should not be used from within libraries for debugging
20297 // messages, since it may be redirected by applications to special
20298 // purpose message windows or even files. Instead, libraries should
20299 // use g_log(), or the convenience functions g_message(), g_warning()
20300 // and g_error().
20301 // <format>: the message format. See the printf() documentation
20302 alias g_print print; // Variadic
20305 // Unintrospectable function: printerr() / g_printerr()
20306 // Outputs a formatted message via the error message handler.
20307 // The default handler simply outputs the message to stderr.
20309 // g_printerr() should not be used from within libraries.
20310 // Instead g_log() should be used, or the convenience functions
20311 // g_message(), g_warning() and g_error().
20312 // <format>: the message format. See the printf() documentation
20313 alias g_printerr printerr; // Variadic
20316 // Unintrospectable function: printf() / g_printf()
20317 // VERSION: 2.2
20318 // An implementation of the standard printf() function which supports
20319 // positional parameters, as specified in the Single Unix Specification.
20320 // RETURNS: the number of bytes printed.
20321 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
20322 alias g_printf printf; // Variadic
20325 // Unintrospectable function: printf_string_upper_bound() / g_printf_string_upper_bound()
20326 // Calculates the maximum space needed to store the output
20327 // of the sprintf() function.
20328 // RETURNS: the maximum space needed to store the formatted string
20329 // <format>: the format string. See the printf() documentation
20330 // <args>: the parameters to be inserted into the format string
20331 static size_t printf_string_upper_bound()(char* format, va_list args) nothrow {
20332 return g_printf_string_upper_bound(format, args);
20336 // If @dest is %NULL, free @src; otherwise, moves @src into *@dest.
20337 // The error variable @dest points to must be %NULL.
20338 // <dest>: error return location
20339 // <src>: error to move into the return location
20340 static void propagate_error()(Error** dest, Error* src) nothrow {
20341 g_propagate_error(dest, src);
20345 // Unintrospectable function: propagate_prefixed_error() / g_propagate_prefixed_error()
20346 // VERSION: 2.16
20347 // If @dest is %NULL, free @src; otherwise,
20348 // moves @src into *@dest. *@dest must be %NULL.
20349 // After the move, add a prefix as with
20350 // g_prefix_error().
20351 // <dest>: error return location
20352 // <src>: error to move into the return location
20353 // <format>: printf()-style format string
20354 alias g_propagate_prefixed_error propagate_prefixed_error; // Variadic
20357 // MOVED TO: PtrArray.add
20358 // Adds a pointer to the end of the pointer array. The array will grow
20359 // in size automatically if necessary.
20360 // <array>: a #GPtrArray.
20361 // <data>: the pointer to add.
20362 static void ptr_array_add()(PtrArray* array, void* data) nothrow {
20363 g_ptr_array_add(array, data);
20367 // MOVED TO: PtrArray.remove
20368 // Removes the first occurrence of the given pointer from the pointer
20369 // array. The following elements are moved down one place. If @array
20370 // has a non-%NULL #GDestroyNotify function it is called for the
20371 // removed element.
20373 // It returns %TRUE if the pointer was removed, or %FALSE if the
20374 // pointer was not found.
20375 // <array>: a #GPtrArray.
20376 // <data>: the pointer to remove.
20377 static int ptr_array_remove()(PtrArray* array, void* data) nothrow {
20378 return g_ptr_array_remove(array, data);
20382 // MOVED TO: PtrArray.remove_fast
20383 // Removes the first occurrence of the given pointer from the pointer
20384 // array. The last element in the array is used to fill in the space,
20385 // so this function does not preserve the order of the array. But it is
20386 // faster than g_ptr_array_remove(). If @array has a non-%NULL
20387 // #GDestroyNotify function it is called for the removed element.
20389 // It returns %TRUE if the pointer was removed, or %FALSE if the
20390 // pointer was not found.
20391 // <array>: a #GPtrArray.
20392 // <data>: the pointer to remove.
20393 static int ptr_array_remove_fast()(PtrArray* array, void* data) nothrow {
20394 return g_ptr_array_remove_fast(array, data);
20398 // VERSION: 2.4
20399 // MOVED TO: PtrArray.remove_range
20400 // Removes the given number of pointers starting at the given index
20401 // from a #GPtrArray. The following elements are moved to close the
20402 // gap. If @array has a non-%NULL #GDestroyNotify function it is called
20403 // for the removed elements.
20404 // <array>: a @GPtrArray.
20405 // <index_>: the index of the first pointer to remove.
20406 // <length>: the number of pointers to remove.
20407 static void ptr_array_remove_range()(PtrArray* array, uint index_, uint length) nothrow {
20408 g_ptr_array_remove_range(array, index_, length);
20412 // VERSION: 2.22
20413 // MOVED TO: PtrArray.set_free_func
20414 // Sets a function for freeing each element when @array is destroyed
20415 // either via g_ptr_array_unref(), when g_ptr_array_free() is called
20416 // with @free_segment set to %TRUE or when removing elements.
20417 // <array>: A #GPtrArray.
20418 // <element_free_func>: A function to free elements with destroy @array or %NULL.
20419 static void ptr_array_set_free_func()(PtrArray* array, DestroyNotify element_free_func) nothrow {
20420 g_ptr_array_set_free_func(array, element_free_func);
20424 // MOVED TO: PtrArray.set_size
20425 // Sets the size of the array. When making the array larger,
20426 // newly-added elements will be set to %NULL. When making it smaller,
20427 // if @array has a non-%NULL #GDestroyNotify function then it will be
20428 // called for the removed elements.
20429 // <array>: a #GPtrArray.
20430 // <length>: the new length of the pointer array.
20431 static void ptr_array_set_size()(PtrArray* array, int length) nothrow {
20432 g_ptr_array_set_size(array, length);
20436 // VERSION: 2.22
20437 // MOVED TO: PtrArray.unref
20438 // Atomically decrements the reference count of @array by one. If the
20439 // reference count drops to 0, the effect is the same as calling
20440 // g_ptr_array_free() with @free_segment set to %TRUE. This function
20441 // is MT-safe and may be called from any thread.
20442 // <array>: A #GPtrArray.
20443 static void ptr_array_unref()(PtrArray* array) nothrow {
20444 g_ptr_array_unref(array);
20448 // Unintrospectable function: qsort_with_data() / g_qsort_with_data()
20449 // This is just like the standard C qsort() function, but
20450 // the comparison routine accepts a user data argument.
20451 // <pbase>: start of array to sort
20452 // <total_elems>: elements in the array
20453 // <size>: size of each element
20454 // <compare_func>: function to compare elements
20455 // <user_data>: data to pass to @compare_func
20456 static void qsort_with_data()(const(void)* pbase, int total_elems, size_t size, CompareDataFunc compare_func, void* user_data) nothrow {
20457 g_qsort_with_data(pbase, total_elems, size, compare_func, user_data);
20461 // Gets the #GQuark identifying the given (static) string. If the
20462 // string does not currently have an associated #GQuark, a new #GQuark
20463 // is created, linked to the given string.
20465 // Note that this function is identical to g_quark_from_string() except
20466 // that if a new #GQuark is created the string itself is used rather
20467 // than a copy. This saves memory, but can only be used if the string
20468 // will <emphasis>always</emphasis> exist. It can be used with
20469 // statically allocated strings in the main program, but not with
20470 // statically allocated memory in dynamically loaded modules, if you
20471 // expect to ever unload the module again (e.g. do not use this
20472 // function in GTK+ theme engines).
20473 // <string>: a string.
20474 static Quark quark_from_static_string()(char* string_=null) nothrow {
20475 return g_quark_from_static_string(string_);
20479 // Gets the #GQuark identifying the given string. If the string does
20480 // not currently have an associated #GQuark, a new #GQuark is created,
20481 // using a copy of the string.
20482 // <string>: a string.
20483 static Quark quark_from_string()(char* string_=null) nothrow {
20484 return g_quark_from_string(string_);
20488 // Gets the string associated with the given #GQuark.
20489 // <quark>: a #GQuark.
20490 static char* quark_to_string()(Quark quark) nothrow {
20491 return g_quark_to_string(quark);
20495 // Gets the #GQuark associated with the given string, or 0 if string is
20496 // %NULL or it has no associated #GQuark.
20498 // If you want the GQuark to be created if it doesn't already exist,
20499 // use g_quark_from_string() or g_quark_from_static_string().
20500 // <string>: a string.
20501 static Quark quark_try_string()(char* string_=null) nothrow {
20502 return g_quark_try_string(string_);
20506 // Returns a random #gdouble equally distributed over the range [0..1).
20507 // RETURNS: A random number.
20508 static double random_double()() nothrow {
20509 return g_random_double();
20513 // Returns a random #gdouble equally distributed over the range [@begin..@end).
20514 // RETURNS: A random number.
20515 // <begin>: lower closed bound of the interval.
20516 // <end>: upper open bound of the interval.
20517 static double random_double_range()(double begin, double end) nothrow {
20518 return g_random_double_range(begin, end);
20522 // Return a random #guint32 equally distributed over the range
20523 // [0..2^32-1].
20524 // RETURNS: A random number.
20525 static uint random_int()() nothrow {
20526 return g_random_int();
20530 // Returns a random #gint32 equally distributed over the range
20531 // [@begin..@end-1].
20532 // RETURNS: A random number.
20533 // <begin>: lower closed bound of the interval.
20534 // <end>: upper open bound of the interval.
20535 static int random_int_range()(int begin, int end) nothrow {
20536 return g_random_int_range(begin, end);
20540 // Sets the seed for the global random number generator, which is used
20541 // by the <function>g_random_*</function> functions, to @seed.
20542 // <seed>: a value to reinitialize the global random number generator.
20543 static void random_set_seed()(uint seed) nothrow {
20544 g_random_set_seed(seed);
20548 // Unintrospectable function: realloc() / g_realloc()
20549 // Reallocates the memory pointed to by @mem, so that it now has space for
20550 // @n_bytes bytes of memory. It returns the new address of the memory, which may
20551 // have been moved. @mem may be %NULL, in which case it's considered to
20552 // have zero-length. @n_bytes may be 0, in which case %NULL will be returned
20553 // and @mem will be freed unless it is %NULL.
20554 // RETURNS: the new address of the allocated memory
20555 // <mem>: the memory to reallocate
20556 // <n_bytes>: new size of the memory in bytes
20557 static void* realloc()(void* mem, size_t n_bytes) nothrow {
20558 return g_realloc(mem, n_bytes);
20562 // Unintrospectable function: realloc_n() / g_realloc_n()
20563 // VERSION: 2.24
20564 // This function is similar to g_realloc(), allocating (@n_blocks * @n_block_bytes) bytes,
20565 // but care is taken to detect possible overflow during multiplication.
20566 // RETURNS: the new address of the allocated memory
20567 // <mem>: the memory to reallocate
20568 // <n_blocks>: the number of blocks to allocate
20569 // <n_block_bytes>: the size of each block in bytes
20570 static void* realloc_n()(void* mem, size_t n_blocks, size_t n_block_bytes) nothrow {
20571 return g_realloc_n(mem, n_blocks, n_block_bytes);
20575 // VERSION: 2.14
20576 // MOVED TO: Regex.check_replacement
20577 // Checks whether @replacement is a valid replacement string
20578 // (see g_regex_replace()), i.e. that all escape sequences in
20579 // it are valid.
20581 // If @has_references is not %NULL then @replacement is checked
20582 // for pattern references. For instance, replacement text 'foo\n'
20583 // does not contain references and may be evaluated without information
20584 // about actual match, but '\0\1' (whole match followed by first
20585 // subpattern) requires valid #GMatchInfo object.
20586 // RETURNS: whether @replacement is a valid replacement string
20587 // <replacement>: the replacement string
20588 // <has_references>: location to store information about references in @replacement or %NULL
20589 static int regex_check_replacement()(char* replacement, /*out*/ int* has_references, GLib2.Error** error=null) nothrow {
20590 return g_regex_check_replacement(replacement, has_references, error);
20593 // MOVED TO: Regex.error_quark
20594 static Quark regex_error_quark()() nothrow {
20595 return g_regex_error_quark();
20599 // VERSION: 2.30
20600 // MOVED TO: Regex.escape_nul
20601 // Escapes the nul characters in @string to "\x00". It can be used
20602 // to compile a regex with embedded nul characters.
20604 // For completeness, @length can be -1 for a nul-terminated string.
20605 // In this case the output string will be of course equal to @string.
20606 // RETURNS: a newly-allocated escaped string
20607 // <string>: the string to escape
20608 // <length>: the length of @string
20609 static char* /*new*/ regex_escape_nul()(char* string_, int length) nothrow {
20610 return g_regex_escape_nul(string_, length);
20614 // VERSION: 2.14
20615 // MOVED TO: Regex.escape_string
20616 // Escapes the special characters used for regular expressions
20617 // in @string, for instance "a.b*c" becomes "a\.b\*c". This
20618 // function is useful to dynamically generate regular expressions.
20620 // @string can contain nul characters that are replaced with "\0",
20621 // in this case remember to specify the correct length of @string
20622 // in @length.
20623 // RETURNS: a newly-allocated escaped string
20624 // <string>: the string to escape
20625 // <length>: the length of @string, or -1 if @string is nul-terminated
20626 static char* /*new*/ regex_escape_string()(char* string_, int length) nothrow {
20627 return g_regex_escape_string(string_, length);
20631 // VERSION: 2.14
20632 // MOVED TO: Regex.match_simple
20633 // Scans for a match in @string for @pattern.
20635 // This function is equivalent to g_regex_match() but it does not
20636 // require to compile the pattern with g_regex_new(), avoiding some
20637 // lines of code when you need just to do a match without extracting
20638 // substrings, capture counts, and so on.
20640 // If this function is to be called on the same @pattern more than
20641 // once, it's more efficient to compile the pattern once with
20642 // g_regex_new() and then use g_regex_match().
20643 // RETURNS: %TRUE if the string matched, %FALSE otherwise
20644 // <pattern>: the regular expression
20645 // <string>: the string to scan for matches
20646 // <compile_options>: compile options for the regular expression, or 0
20647 // <match_options>: match options, or 0
20648 static int regex_match_simple()(char* pattern, char* string_, RegexCompileFlags compile_options, RegexMatchFlags match_options) nothrow {
20649 return g_regex_match_simple(pattern, string_, compile_options, match_options);
20653 // VERSION: 2.22
20654 // Resets the cache used for g_get_user_special_dir(), so
20655 // that the latest on-disk version is used. Call this only
20656 // if you just changed the data on disk yourself.
20658 // Due to threadsafety issues this may cause leaking of strings
20659 // that were previously returned from g_get_user_special_dir()
20660 // that can't be freed. We ensure to only leak the data for
20661 // the directories that actually changed value though.
20662 static void reload_user_special_dirs_cache()() nothrow {
20663 g_reload_user_special_dirs_cache();
20666 static void return_if_fail_warning()(char* log_domain, char* pretty_function, char* expression) nothrow {
20667 g_return_if_fail_warning(log_domain, pretty_function, expression);
20671 // VERSION: 2.6
20672 // A wrapper for the POSIX rmdir() function. The rmdir() function
20673 // deletes a directory from the filesystem.
20675 // See your C library manual for more details about how rmdir() works
20676 // on your system.
20678 // occurred
20679 // RETURNS: 0 if the directory was successfully removed, -1 if an error
20680 // <filename>: a pathname in the GLib file name encoding (UTF-8 on Windows)
20681 static int rmdir()(char* filename) nothrow {
20682 return g_rmdir(filename);
20686 // VERSION: 2.14
20687 // MOVED TO: Sequence.move
20688 // Moves the item pointed to by @src to the position indicated by @dest.
20689 // After calling this function @dest will point to the position immediately
20690 // after @src. It is allowed for @src and @dest to point into different
20691 // sequences.
20692 // <src>: a #GSequenceIter pointing to the item to move
20693 // <dest>: a #GSequenceIter pointing to the position to which the item is moved.
20694 static void sequence_move()(SequenceIter* src, SequenceIter* dest) nothrow {
20695 g_sequence_move(src, dest);
20699 // VERSION: 2.14
20700 // MOVED TO: Sequence.move_range
20701 // Inserts the (@begin, @end) range at the destination pointed to by ptr.
20702 // The @begin and @end iters must point into the same sequence. It is
20703 // allowed for @dest to point to a different sequence than the one pointed
20704 // into by @begin and @end.
20706 // If @dest is NULL, the range indicated by @begin and @end is
20707 // removed from the sequence. If @dest iter points to a place within
20708 // the (@begin, @end) range, the range does not move.
20709 // <dest>: a #GSequenceIter
20710 // <begin>: a #GSequenceIter
20711 // <end>: a #GSequenceIter
20712 static void sequence_move_range()(SequenceIter* dest, SequenceIter* begin, SequenceIter* end) nothrow {
20713 g_sequence_move_range(dest, begin, end);
20717 // VERSION: 2.14
20718 // MOVED TO: Sequence.remove
20719 // Removes the item pointed to by @iter. It is an error to pass the
20720 // end iterator to this function.
20722 // If the sequnce has a data destroy function associated with it, this
20723 // function is called on the data for the removed item.
20724 // <iter>: a #GSequenceIter
20725 static void sequence_remove()(SequenceIter* iter) nothrow {
20726 g_sequence_remove(iter);
20730 // VERSION: 2.14
20731 // MOVED TO: Sequence.remove_range
20732 // Removes all items in the (@begin, @end) range.
20734 // If the sequence has a data destroy function associated with it, this
20735 // function is called on the data for the removed items.
20736 // <begin>: a #GSequenceIter
20737 // <end>: a #GSequenceIter
20738 static void sequence_remove_range()(SequenceIter* begin, SequenceIter* end) nothrow {
20739 g_sequence_remove_range(begin, end);
20743 // VERSION: 2.14
20744 // MOVED TO: Sequence.set
20745 // Changes the data for the item pointed to by @iter to be @data. If
20746 // the sequence has a data destroy function associated with it, that
20747 // function is called on the existing data that @iter pointed to.
20748 // <iter>: a #GSequenceIter
20749 // <data>: new data for the item
20750 static void sequence_set()(SequenceIter* iter, void* data) nothrow {
20751 g_sequence_set(iter, data);
20755 // VERSION: 2.14
20756 // MOVED TO: Sequence.swap
20757 // Swaps the items pointed to by @a and @b. It is allowed for @a and @b
20758 // to point into difference sequences.
20759 // <a>: a #GSequenceIter
20760 // <b>: a #GSequenceIter
20761 static void sequence_swap()(SequenceIter* a, SequenceIter* b) nothrow {
20762 g_sequence_swap(a, b);
20766 // VERSION: 2.2
20767 // Sets a human-readable name for the application. This name should be
20768 // localized if possible, and is intended for display to the user.
20769 // Contrast with g_set_prgname(), which sets a non-localized name.
20770 // g_set_prgname() will be called automatically by gtk_init(),
20771 // but g_set_application_name() will not.
20773 // Note that for thread safety reasons, this function can only
20774 // be called once.
20776 // The application name will be used in contexts such as error messages,
20777 // or when displaying an application's name in the task list.
20778 // <application_name>: localized name of the application
20779 static void set_application_name()(char* application_name) nothrow {
20780 g_set_application_name(application_name);
20784 // Unintrospectable function: set_error() / g_set_error()
20785 // Does nothing if @err is %NULL; if @err is non-%NULL, then *@err
20786 // must be %NULL. A new #GError is created and assigned to *@err.
20787 // <err>: a return location for a #GError, or %NULL
20788 // <domain>: error domain
20789 // <code>: error code
20790 // <format>: printf()-style format
20791 alias g_set_error set_error; // Variadic
20794 // VERSION: 2.18
20795 // Does nothing if @err is %NULL; if @err is non-%NULL, then *@err
20796 // must be %NULL. A new #GError is created and assigned to *@err.
20797 // Unlike g_set_error(), @message is not a printf()-style format string.
20798 // Use this function if @message contains text you don't have control over,
20799 // that could include printf() escape sequences.
20800 // <err>: a return location for a #GError, or %NULL
20801 // <domain>: error domain
20802 // <code>: error code
20803 // <message>: error message
20804 static void set_error_literal()(Error** err, Quark domain, int code, char* message) nothrow {
20805 g_set_error_literal(err, domain, code, message);
20809 // Sets the name of the program. This name should <emphasis>not</emphasis>
20810 // be localized, contrast with g_set_application_name(). Note that for
20811 // thread-safety reasons this function can only be called once.
20812 // <prgname>: the name of the program.
20813 static void set_prgname()(char* prgname) nothrow {
20814 g_set_prgname(prgname);
20818 // Unintrospectable function: set_print_handler() / g_set_print_handler()
20819 // Sets the print handler.
20821 // Any messages passed to g_print() will be output via
20822 // the new handler. The default handler simply outputs
20823 // the message to stdout. By providing your own handler
20824 // you can redirect the output, to a GTK+ widget or a
20825 // log file for example.
20826 // RETURNS: the old print handler
20827 // <func>: the new print handler
20828 static PrintFunc set_print_handler()(PrintFunc func) nothrow {
20829 return g_set_print_handler(func);
20833 // Unintrospectable function: set_printerr_handler() / g_set_printerr_handler()
20834 // Sets the handler for printing error messages.
20836 // Any messages passed to g_printerr() will be output via
20837 // the new handler. The default handler simply outputs the
20838 // message to stderr. By providing your own handler you can
20839 // redirect the output, to a GTK+ widget or a log file for
20840 // example.
20841 // RETURNS: the old error message handler
20842 // <func>: the new error message handler
20843 static PrintFunc set_printerr_handler()(PrintFunc func) nothrow {
20844 return g_set_printerr_handler(func);
20848 // VERSION: 2.4
20849 // Sets an environment variable. Both the variable's name and value
20850 // should be in the GLib file name encoding. On UNIX, this means that
20851 // they can be arbitrary byte strings. On Windows, they should be in
20852 // UTF-8.
20854 // Note that on some systems, when variables are overwritten, the memory
20855 // used for the previous variables and its value isn't reclaimed.
20857 // <warning><para>
20858 // Environment variable handling in UNIX is not thread-safe, and your
20859 // program may crash if one thread calls g_setenv() while another
20860 // thread is calling getenv(). (And note that many functions, such as
20861 // gettext(), call getenv() internally.) This function is only safe to
20862 // use at the very start of your program, before creating any other
20863 // threads (or creating objects that create worker threads of their
20864 // own).
20865 // </para><para>
20866 // If you need to set up the environment for a child process, you can
20867 // use g_get_environ() to get an environment array, modify that with
20868 // g_environ_setenv() and g_environ_unsetenv(), and then pass that
20869 // array directly to execvpe(), g_spawn_async(), or the like.
20870 // </para></warning>
20871 // RETURNS: %FALSE if the environment variable couldn't be set.
20872 // <variable>: the environment variable to set, must not contain '='.
20873 // <value>: the value for to set the variable to.
20874 // <overwrite>: whether to change the variable if it already exists.
20875 static int setenv()(char* variable, char* value, int overwrite) nothrow {
20876 return g_setenv(variable, value, overwrite);
20879 static Quark shell_error_quark()() nothrow {
20880 return g_shell_error_quark();
20884 // Parses a command line into an argument vector, in much the same way
20885 // the shell would, but without many of the expansions the shell would
20886 // perform (variable expansion, globs, operators, filename expansion,
20887 // etc. are not supported). The results are defined to be the same as
20888 // those you would get from a UNIX98 /bin/sh, as long as the input
20889 // contains none of the unsupported shell expansions. If the input
20890 // does contain such expansions, they are passed through
20891 // literally. Possible errors are those from the #G_SHELL_ERROR
20892 // domain. Free the returned vector with g_strfreev().
20893 // RETURNS: %TRUE on success, %FALSE if error set
20894 // <command_line>: command line to parse
20895 // <argcp>: return location for number of args
20896 // <argvp>: return location for array of args
20897 static int shell_parse_argv()(char* command_line, /*out*/ int* argcp, /*out*/ char*** argvp, GLib2.Error** error=null) nothrow {
20898 return g_shell_parse_argv(command_line, argcp, argvp, error);
20902 // Quotes a string so that the shell (/bin/sh) will interpret the
20903 // quoted string to mean @unquoted_string. If you pass a filename to
20904 // the shell, for example, you should first quote it with this
20905 // function. The return value must be freed with g_free(). The
20906 // quoting style used is undefined (single or double quotes may be
20907 // used).
20908 // RETURNS: quoted string
20909 // <unquoted_string>: a literal string
20910 static char* /*new*/ shell_quote()(char* unquoted_string) nothrow {
20911 return g_shell_quote(unquoted_string);
20915 // Unquotes a string as the shell (/bin/sh) would. Only handles
20916 // quotes; if a string contains file globs, arithmetic operators,
20917 // variables, backticks, redirections, or other special-to-the-shell
20918 // features, the result will be different from the result a real shell
20919 // would produce (the variables, backticks, etc. will be passed
20920 // through literally instead of being expanded). This function is
20921 // guaranteed to succeed if applied to the result of
20922 // g_shell_quote(). If it fails, it returns %NULL and sets the
20923 // error. The @quoted_string need not actually contain quoted or
20924 // escaped text; g_shell_unquote() simply goes through the string and
20925 // unquotes/unescapes anything that the shell would. Both single and
20926 // double quotes are handled, as are escapes including escaped
20927 // newlines. The return value must be freed with g_free(). Possible
20928 // errors are in the #G_SHELL_ERROR domain.
20930 // Shell quoting rules are a bit strange. Single quotes preserve the
20931 // literal string exactly. escape sequences are not allowed; not even
20932 // \' - if you want a ' in the quoted text, you have to do something
20933 // like 'foo'\''bar'. Double quotes allow $, `, ", \, and newline to
20934 // be escaped with backslash. Otherwise double quotes preserve things
20935 // literally.
20936 // RETURNS: an unquoted string
20937 // <quoted_string>: shell-quoted string
20938 static char* /*new*/ shell_unquote()(char* quoted_string, GLib2.Error** error=null) nothrow {
20939 return g_shell_unquote(quoted_string, error);
20943 // Unintrospectable function: slice_alloc() / g_slice_alloc()
20944 // VERSION: 2.10
20945 // Allocates a block of memory from the slice allocator.
20946 // The block adress handed out can be expected to be aligned
20947 // to at least <literal>1 * sizeof (void*)</literal>,
20948 // though in general slices are 2 * sizeof (void*) bytes aligned,
20949 // if a malloc() fallback implementation is used instead,
20950 // the alignment may be reduced in a libc dependent fashion.
20951 // Note that the underlying slice allocation mechanism can
20952 // be changed with the <link linkend="G_SLICE">G_SLICE=always-malloc</link>
20953 // environment variable.
20954 // RETURNS: a pointer to the allocated memory block
20955 // <block_size>: the number of bytes to allocate
20956 static void* slice_alloc()(size_t block_size) nothrow {
20957 return g_slice_alloc(block_size);
20961 // Unintrospectable function: slice_alloc0() / g_slice_alloc0()
20962 // VERSION: 2.10
20963 // Allocates a block of memory via g_slice_alloc() and initializes
20964 // the returned memory to 0. Note that the underlying slice allocation
20965 // mechanism can be changed with the
20966 // <link linkend="G_SLICE">G_SLICE=always-malloc</link>
20967 // environment variable.
20968 // RETURNS: a pointer to the allocated block
20969 // <block_size>: the number of bytes to allocate
20970 static void* slice_alloc0()(size_t block_size) nothrow {
20971 return g_slice_alloc0(block_size);
20975 // Unintrospectable function: slice_copy() / g_slice_copy()
20976 // VERSION: 2.14
20977 // Allocates a block of memory from the slice allocator
20978 // and copies @block_size bytes into it from @mem_block.
20979 // RETURNS: a pointer to the allocated memory block
20980 // <block_size>: the number of bytes to allocate
20981 // <mem_block>: the memory to copy
20982 static void* slice_copy()(size_t block_size, const(void)* mem_block) nothrow {
20983 return g_slice_copy(block_size, mem_block);
20987 // VERSION: 2.10
20988 // Frees a block of memory.
20990 // The memory must have been allocated via g_slice_alloc() or
20991 // g_slice_alloc0() and the @block_size has to match the size
20992 // specified upon allocation. Note that the exact release behaviour
20993 // can be changed with the
20994 // <link linkend="G_DEBUG">G_DEBUG=gc-friendly</link> environment
20995 // variable, also see <link linkend="G_SLICE">G_SLICE</link> for
20996 // related debugging options.
20997 // <block_size>: the size of the block
20998 // <mem_block>: a pointer to the block to free
20999 static void slice_free1()(size_t block_size, void* mem_block) nothrow {
21000 g_slice_free1(block_size, mem_block);
21004 // VERSION: 2.10
21005 // Frees a linked list of memory blocks of structure type @type.
21007 // The memory blocks must be equal-sized, allocated via
21008 // g_slice_alloc() or g_slice_alloc0() and linked together by a
21009 // @next pointer (similar to #GSList). The offset of the @next
21010 // field in each block is passed as third argument.
21011 // Note that the exact release behaviour can be changed with the
21012 // <link linkend="G_DEBUG">G_DEBUG=gc-friendly</link> environment
21013 // variable, also see <link linkend="G_SLICE">G_SLICE</link> for
21014 // related debugging options.
21015 // <block_size>: the size of the blocks
21016 // <mem_chain>: a pointer to the first block of the chain
21017 // <next_offset>: the offset of the @next field in the blocks
21018 static void slice_free_chain_with_offset()(size_t block_size, void* mem_chain, size_t next_offset) nothrow {
21019 g_slice_free_chain_with_offset(block_size, mem_chain, next_offset);
21022 static long slice_get_config()(SliceConfig ckey) nothrow {
21023 return g_slice_get_config(ckey);
21026 static long* slice_get_config_state()(SliceConfig ckey, long address, uint* n_values) nothrow {
21027 return g_slice_get_config_state(ckey, address, n_values);
21030 static void slice_set_config()(SliceConfig ckey, long value) nothrow {
21031 g_slice_set_config(ckey, value);
21035 // Unintrospectable function: snprintf() / g_snprintf()
21036 // A safer form of the standard sprintf() function. The output is guaranteed
21037 // to not exceed @n characters (including the terminating nul character), so
21038 // it is easy to ensure that a buffer overflow cannot occur.
21040 // See also g_strdup_printf().
21042 // In versions of GLib prior to 1.2.3, this function may return -1 if the
21043 // output was truncated, and the truncated string may not be nul-terminated.
21044 // In versions prior to 1.3.12, this function returns the length of the output
21045 // string.
21047 // The return value of g_snprintf() conforms to the snprintf()
21048 // function as standardized in ISO C99. Note that this is different from
21049 // traditional snprintf(), which returns the length of the output string.
21051 // The format string may contain positional parameters, as specified in
21052 // the Single Unix Specification.
21054 // was large enough.
21055 // RETURNS: the number of bytes which would be produced if the buffer
21056 // <string>: the buffer to hold the output.
21057 // <n>: the maximum number of bytes to produce (including the terminating nul character).
21058 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
21059 alias g_snprintf snprintf; // Variadic
21062 // MOVED TO: Source.remove
21063 // Removes the source with the given id from the default main context.
21064 // The id of
21065 // a #GSource is given by g_source_get_id(), or will be returned by the
21066 // functions g_source_attach(), g_idle_add(), g_idle_add_full(),
21067 // g_timeout_add(), g_timeout_add_full(), g_child_watch_add(),
21068 // g_child_watch_add_full(), g_io_add_watch(), and g_io_add_watch_full().
21070 // See also g_source_destroy(). You must use g_source_destroy() for sources
21071 // added to a non-default main context.
21072 // RETURNS: %TRUE if the source was found and removed.
21073 // <tag>: the ID of the source to remove.
21074 static int source_remove()(uint tag) nothrow {
21075 return g_source_remove(tag);
21079 // MOVED TO: Source.remove_by_funcs_user_data
21080 // Removes a source from the default main loop context given the
21081 // source functions and user data. If multiple sources exist with the
21082 // same source functions and user data, only one will be destroyed.
21083 // RETURNS: %TRUE if a source was found and removed.
21084 // <funcs>: The @source_funcs passed to g_source_new()
21085 // <user_data>: the user data for the callback
21086 static int source_remove_by_funcs_user_data()(SourceFuncs* funcs, void* user_data) nothrow {
21087 return g_source_remove_by_funcs_user_data(funcs, user_data);
21091 // MOVED TO: Source.remove_by_user_data
21092 // Removes a source from the default main loop context given the user
21093 // data for the callback. If multiple sources exist with the same user
21094 // data, only one will be destroyed.
21095 // RETURNS: %TRUE if a source was found and removed.
21096 // <user_data>: the user_data for the callback.
21097 static int source_remove_by_user_data()(void* user_data) nothrow {
21098 return g_source_remove_by_user_data(user_data);
21102 // VERSION: 2.26
21103 // MOVED TO: Source.set_name_by_id
21104 // Sets the name of a source using its ID.
21106 // This is a convenience utility to set source names from the return
21107 // value of g_idle_add(), g_timeout_add(), etc.
21108 // <tag>: a #GSource ID
21109 // <name>: debug name for the source
21110 static void source_set_name_by_id()(uint tag, char* name) nothrow {
21111 g_source_set_name_by_id(tag, name);
21115 // Gets the smallest prime number from a built-in array of primes which
21116 // is larger than @num. This is used within GLib to calculate the optimum
21117 // size of a #GHashTable.
21119 // The built-in array of primes ranges from 11 to 13845163 such that
21120 // each prime is approximately 1.5-2 times the previous prime.
21122 // which is larger than @num
21123 // RETURNS: the smallest prime number from a built-in array of primes
21124 // <num>: a #guint
21125 static uint spaced_primes_closest()(uint num) nothrow {
21126 return g_spaced_primes_closest(num);
21130 // See g_spawn_async_with_pipes() for a full description; this function
21131 // simply calls the g_spawn_async_with_pipes() without any pipes.
21133 // You should call g_spawn_close_pid() on the returned child process
21134 // reference when you don't need it any more.
21136 // <note><para>
21137 // If you are writing a GTK+ application, and the program you
21138 // are spawning is a graphical application, too, then you may
21139 // want to use gdk_spawn_on_screen() instead to ensure that
21140 // the spawned program opens its windows on the right screen.
21141 // </para></note>
21143 // <note><para> Note that the returned @child_pid on Windows is a
21144 // handle to the child process and not its identifier. Process handles
21145 // and process identifiers are different concepts on Windows.
21146 // </para></note>
21147 // RETURNS: %TRUE on success, %FALSE if error is set
21148 // <working_directory>: child's current working directory, or %NULL to inherit parent's
21149 // <argv>: child's argument vector
21150 // <envp>: child's environment, or %NULL to inherit parent's
21151 // <flags>: flags from #GSpawnFlags
21152 // <child_setup>: function to run in the child just before exec()
21153 // <user_data>: user data for @child_setup
21154 // <child_pid>: return location for child process reference, or %NULL
21155 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) nothrow {
21156 return g_spawn_async(working_directory, argv, envp, flags, child_setup, user_data, child_pid, error);
21160 // Executes a child program asynchronously (your program will not
21161 // block waiting for the child to exit). The child program is
21162 // specified by the only argument that must be provided, @argv. @argv
21163 // should be a %NULL-terminated array of strings, to be passed as the
21164 // argument vector for the child. The first string in @argv is of
21165 // course the name of the program to execute. By default, the name of
21166 // the program must be a full path; the <envar>PATH</envar> shell variable
21167 // will only be searched if you pass the %G_SPAWN_SEARCH_PATH flag.
21168 // If the program name is not a full path and %G_SPAWN_SEARCH_PATH flag is not
21169 // used, then the program will be run from the current directory (or
21170 // @working_directory, if specified); this might be unexpected or even
21171 // dangerous in some cases when the current directory is world-writable.
21173 // On Windows, note that all the string or string vector arguments to
21174 // this function and the other g_spawn*() functions are in UTF-8, the
21175 // GLib file name encoding. Unicode characters that are not part of
21176 // the system codepage passed in these arguments will be correctly
21177 // available in the spawned program only if it uses wide character API
21178 // to retrieve its command line. For C programs built with Microsoft's
21179 // tools it is enough to make the program have a wmain() instead of
21180 // main(). wmain() has a wide character argument vector as parameter.
21182 // At least currently, mingw doesn't support wmain(), so if you use
21183 // mingw to develop the spawned program, it will have to call the
21184 // undocumented function __wgetmainargs() to get the wide character
21185 // argument vector and environment. See gspawn-win32-helper.c in the
21186 // GLib sources or init.c in the mingw runtime sources for a prototype
21187 // for that function. Alternatively, you can retrieve the Win32 system
21188 // level wide character command line passed to the spawned program
21189 // using the GetCommandLineW() function.
21191 // On Windows the low-level child process creation API
21192 // <function>CreateProcess()</function> doesn't use argument vectors,
21193 // but a command line. The C runtime library's
21194 // <function>spawn*()</function> family of functions (which
21195 // g_spawn_async_with_pipes() eventually calls) paste the argument
21196 // vector elements together into a command line, and the C runtime startup code
21197 // does a corresponding reconstruction of an argument vector from the
21198 // command line, to be passed to main(). Complications arise when you have
21199 // argument vector elements that contain spaces of double quotes. The
21200 // <function>spawn*()</function> functions don't do any quoting or
21201 // escaping, but on the other hand the startup code does do unquoting
21202 // and unescaping in order to enable receiving arguments with embedded
21203 // spaces or double quotes. To work around this asymmetry,
21204 // g_spawn_async_with_pipes() will do quoting and escaping on argument
21205 // vector elements that need it before calling the C runtime
21206 // spawn() function.
21208 // The returned @child_pid on Windows is a handle to the child
21209 // process, not its identifier. Process handles and process
21210 // identifiers are different concepts on Windows.
21212 // @envp is a %NULL-terminated array of strings, where each string
21213 // has the form <literal>KEY=VALUE</literal>. This will become
21214 // the child's environment. If @envp is %NULL, the child inherits its
21215 // parent's environment.
21217 // @flags should be the bitwise OR of any flags you want to affect the
21218 // function's behaviour. The %G_SPAWN_DO_NOT_REAP_CHILD means that the
21219 // child will not automatically be reaped; you must use a child watch to
21220 // be notified about the death of the child process. Eventually you must
21221 // call g_spawn_close_pid() on the @child_pid, in order to free
21222 // resources which may be associated with the child process. (On Unix,
21223 // using a child watch is equivalent to calling waitpid() or handling
21224 // the <literal>SIGCHLD</literal> signal manually. On Windows, calling g_spawn_close_pid()
21225 // is equivalent to calling CloseHandle() on the process handle returned
21226 // in @child_pid). See g_child_watch_add().
21228 // %G_SPAWN_LEAVE_DESCRIPTORS_OPEN means that the parent's open file
21229 // descriptors will be inherited by the child; otherwise all
21230 // descriptors except stdin/stdout/stderr will be closed before
21231 // calling exec() in the child. %G_SPAWN_SEARCH_PATH
21232 // means that <literal>argv[0]</literal> need not be an absolute path, it
21233 // will be looked for in the user's <envar>PATH</envar>.
21234 // %G_SPAWN_STDOUT_TO_DEV_NULL means that the child's standard output will
21235 // be discarded, instead of going to the same location as the parent's
21236 // standard output. If you use this flag, @standard_output must be %NULL.
21237 // %G_SPAWN_STDERR_TO_DEV_NULL means that the child's standard error
21238 // will be discarded, instead of going to the same location as the parent's
21239 // standard error. If you use this flag, @standard_error must be %NULL.
21240 // %G_SPAWN_CHILD_INHERITS_STDIN means that the child will inherit the parent's
21241 // standard input (by default, the child's standard input is attached to
21242 // /dev/null). If you use this flag, @standard_input must be %NULL.
21243 // %G_SPAWN_FILE_AND_ARGV_ZERO means that the first element of @argv is
21244 // the file to execute, while the remaining elements are the
21245 // actual argument vector to pass to the file. Normally
21246 // g_spawn_async_with_pipes() uses @argv[0] as the file to execute, and
21247 // passes all of @argv to the child.
21249 // @child_setup and @user_data are a function and user data. On POSIX
21250 // platforms, the function is called in the child after GLib has
21251 // performed all the setup it plans to perform (including creating
21252 // pipes, closing file descriptors, etc.) but before calling
21253 // exec(). That is, @child_setup is called just
21254 // before calling exec() in the child. Obviously
21255 // actions taken in this function will only affect the child, not the
21256 // parent.
21258 // On Windows, there is no separate fork() and exec()
21259 // functionality. Child processes are created and run with a single
21260 // API call, CreateProcess(). There is no sensible thing @child_setup
21261 // could be used for on Windows so it is ignored and not called.
21263 // If non-%NULL, @child_pid will on Unix be filled with the child's
21264 // process ID. You can use the process ID to send signals to the
21265 // child, or to use g_child_watch_add() (or waitpid()) if you specified the
21266 // %G_SPAWN_DO_NOT_REAP_CHILD flag. On Windows, @child_pid will be
21267 // filled with a handle to the child process only if you specified the
21268 // %G_SPAWN_DO_NOT_REAP_CHILD flag. You can then access the child
21269 // process using the Win32 API, for example wait for its termination
21270 // with the <function>WaitFor*()</function> functions, or examine its
21271 // exit code with GetExitCodeProcess(). You should close the handle
21272 // with CloseHandle() or g_spawn_close_pid() when you no longer need it.
21274 // If non-%NULL, the @standard_input, @standard_output, @standard_error
21275 // locations will be filled with file descriptors for writing to the child's
21276 // standard input or reading from its standard output or standard error.
21277 // The caller of g_spawn_async_with_pipes() must close these file descriptors
21278 // when they are no longer in use. If these parameters are %NULL, the corresponding
21279 // pipe won't be created.
21281 // If @standard_input is NULL, the child's standard input is attached to
21282 // /dev/null unless %G_SPAWN_CHILD_INHERITS_STDIN is set.
21284 // If @standard_error is NULL, the child's standard error goes to the same
21285 // location as the parent's standard error unless %G_SPAWN_STDERR_TO_DEV_NULL
21286 // is set.
21288 // If @standard_output is NULL, the child's standard output goes to the same
21289 // location as the parent's standard output unless %G_SPAWN_STDOUT_TO_DEV_NULL
21290 // is set.
21292 // @error can be %NULL to ignore errors, or non-%NULL to report errors.
21293 // If an error is set, the function returns %FALSE. Errors
21294 // are reported even if they occur in the child (for example if the
21295 // executable in <literal>argv[0]</literal> is not found). Typically
21296 // the <literal>message</literal> field of returned errors should be displayed
21297 // to users. Possible errors are those from the #G_SPAWN_ERROR domain.
21299 // If an error occurs, @child_pid, @standard_input, @standard_output,
21300 // and @standard_error will not be filled with valid values.
21302 // If @child_pid is not %NULL and an error does not occur then the returned
21303 // process reference must be closed using g_spawn_close_pid().
21305 // <note><para>
21306 // If you are writing a GTK+ application, and the program you
21307 // are spawning is a graphical application, too, then you may
21308 // want to use gdk_spawn_on_screen_with_pipes() instead to ensure that
21309 // the spawned program opens its windows on the right screen.
21310 // </para></note>
21311 // RETURNS: %TRUE on success, %FALSE if an error was set
21312 // <working_directory>: child's current working directory, or %NULL to inherit parent's, in the GLib file name encoding
21313 // <argv>: child's argument vector, in the GLib file name encoding
21314 // <envp>: child's environment, or %NULL to inherit parent's, in the GLib file name encoding
21315 // <flags>: flags from #GSpawnFlags
21316 // <child_setup>: function to run in the child just before exec()
21317 // <user_data>: user data for @child_setup
21318 // <child_pid>: return location for child process ID, or %NULL
21319 // <standard_input>: return location for file descriptor to write to child's stdin, or %NULL
21320 // <standard_output>: return location for file descriptor to read child's stdout, or %NULL
21321 // <standard_error>: return location for file descriptor to read child's stderr, or %NULL
21322 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) nothrow {
21323 return g_spawn_async_with_pipes(working_directory, argv, envp, flags, child_setup, user_data, child_pid, standard_input, standard_output, standard_error, error);
21327 // On some platforms, notably Windows, the #GPid type represents a resource
21328 // which must be closed to prevent resource leaking. g_spawn_close_pid()
21329 // is provided for this purpose. It should be used on all platforms, even
21330 // though it doesn't do anything under UNIX.
21331 // <pid>: The process reference to close
21332 static void spawn_close_pid()(Pid pid) nothrow {
21333 g_spawn_close_pid(pid);
21337 // A simple version of g_spawn_async() that parses a command line with
21338 // g_shell_parse_argv() and passes it to g_spawn_async(). Runs a
21339 // command line in the background. Unlike g_spawn_async(), the
21340 // %G_SPAWN_SEARCH_PATH flag is enabled, other flags are not. Note
21341 // that %G_SPAWN_SEARCH_PATH can have security implications, so
21342 // consider using g_spawn_async() directly if appropriate. Possible
21343 // errors are those from g_shell_parse_argv() and g_spawn_async().
21345 // The same concerns on Windows apply as for g_spawn_command_line_sync().
21346 // RETURNS: %TRUE on success, %FALSE if error is set.
21347 // <command_line>: a command line
21348 static int spawn_command_line_async()(char* command_line, GLib2.Error** error=null) nothrow {
21349 return g_spawn_command_line_async(command_line, error);
21353 // A simple version of g_spawn_sync() with little-used parameters
21354 // removed, taking a command line instead of an argument vector. See
21355 // g_spawn_sync() for full details. @command_line will be parsed by
21356 // g_shell_parse_argv(). Unlike g_spawn_sync(), the %G_SPAWN_SEARCH_PATH flag
21357 // is enabled. Note that %G_SPAWN_SEARCH_PATH can have security
21358 // implications, so consider using g_spawn_sync() directly if
21359 // appropriate. Possible errors are those from g_spawn_sync() and those
21360 // from g_shell_parse_argv().
21362 // If @exit_status is non-%NULL, the exit status of the child is stored there as
21363 // it would be returned by waitpid(); standard UNIX macros such as WIFEXITED()
21364 // and WEXITSTATUS() must be used to evaluate the exit status.
21366 // On Windows, please note the implications of g_shell_parse_argv()
21367 // parsing @command_line. Parsing is done according to Unix shell rules, not
21368 // Windows command interpreter rules.
21369 // Space is a separator, and backslashes are
21370 // special. Thus you cannot simply pass a @command_line containing
21371 // canonical Windows paths, like "c:\\program files\\app\\app.exe", as
21372 // the backslashes will be eaten, and the space will act as a
21373 // separator. You need to enclose such paths with single quotes, like
21374 // "'c:\\program files\\app\\app.exe' 'e:\\folder\\argument.txt'".
21375 // RETURNS: %TRUE on success, %FALSE if an error was set
21376 // <command_line>: a command line
21377 // <standard_output>: return location for child output
21378 // <standard_error>: return location for child errors
21379 // <exit_status>: return location for child exit status, as returned by waitpid()
21380 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) nothrow {
21381 return g_spawn_command_line_sync(command_line, standard_output, standard_error, exit_status, error);
21384 static Quark spawn_error_quark()() nothrow {
21385 return g_spawn_error_quark();
21389 // Executes a child synchronously (waits for the child to exit before returning).
21390 // All output from the child is stored in @standard_output and @standard_error,
21391 // if those parameters are non-%NULL. Note that you must set the
21392 // %G_SPAWN_STDOUT_TO_DEV_NULL and %G_SPAWN_STDERR_TO_DEV_NULL flags when
21393 // passing %NULL for @standard_output and @standard_error.
21394 // If @exit_status is non-%NULL, the exit status of the child is stored
21395 // there as it would be returned by waitpid(); standard UNIX macros such
21396 // as WIFEXITED() and WEXITSTATUS() must be used to evaluate the exit status.
21397 // Note that this function call waitpid() even if @exit_status is %NULL, and
21398 // does not accept the %G_SPAWN_DO_NOT_REAP_CHILD flag.
21399 // If an error occurs, no data is returned in @standard_output,
21400 // @standard_error, or @exit_status.
21402 // This function calls g_spawn_async_with_pipes() internally; see that
21403 // function for full details on the other parameters and details on
21404 // how these functions work on Windows.
21405 // RETURNS: %TRUE on success, %FALSE if an error was set.
21406 // <working_directory>: child's current working directory, or %NULL to inherit parent's
21407 // <argv>: child's argument vector
21408 // <envp>: child's environment, or %NULL to inherit parent's
21409 // <flags>: flags from #GSpawnFlags
21410 // <child_setup>: function to run in the child just before exec()
21411 // <user_data>: user data for @child_setup
21412 // <standard_output>: return location for child output, or %NULL
21413 // <standard_error>: return location for child error messages, or %NULL
21414 // <exit_status>: return location for child exit status, as returned by waitpid(), or %NULL
21415 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) nothrow {
21416 return g_spawn_sync(working_directory, argv, envp, flags, child_setup, user_data, standard_output, standard_error, exit_status, error);
21420 // Unintrospectable function: sprintf() / g_sprintf()
21421 // VERSION: 2.2
21422 // An implementation of the standard sprintf() function which supports
21423 // positional parameters, as specified in the Single Unix Specification.
21425 // Note that it is usually better to use g_snprintf(), to avoid the
21426 // risk of buffer overflow.
21428 // See also g_strdup_printf().
21429 // RETURNS: the number of bytes printed.
21430 // <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
21431 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
21432 alias g_sprintf sprintf; // Variadic
21435 // Copies a nul-terminated string into the dest buffer, include the
21436 // trailing nul, and return a pointer to the trailing nul byte.
21437 // This is useful for concatenating multiple strings together
21438 // without having to repeatedly scan for the end.
21439 // RETURNS: a pointer to trailing nul byte.
21440 // <dest>: destination buffer.
21441 // <src>: source string.
21442 static char* /*new*/ stpcpy()(char* dest, char* src) nothrow {
21443 return g_stpcpy(dest, src);
21447 // Compares two strings for byte-by-byte equality and returns %TRUE
21448 // if they are equal. It can be passed to g_hash_table_new() as the
21449 // @key_equal_func parameter, when using non-%NULL strings as keys in a
21450 // #GHashTable.
21452 // Note that this function is primarily meant as a hash table comparison
21453 // function. For a general-purpose, %NULL-safe string comparison function,
21454 // see g_strcmp0().
21455 // RETURNS: %TRUE if the two keys match
21456 // <v1>: a key
21457 // <v2>: a key to compare with @v1
21458 static int str_equal()(const(void)* v1, const(void)* v2) nothrow {
21459 return g_str_equal(v1, v2);
21463 // VERSION: 2.2
21464 // Looks whether the string @str begins with @prefix.
21465 // RETURNS: %TRUE if @str begins with @prefix, %FALSE otherwise.
21466 // <str>: a nul-terminated string
21467 // <prefix>: the nul-terminated prefix to look for
21468 static int str_has_prefix()(char* str, char* prefix) nothrow {
21469 return g_str_has_prefix(str, prefix);
21473 // VERSION: 2.2
21474 // Looks whether the string @str ends with @suffix.
21475 // RETURNS: %TRUE if @str end with @suffix, %FALSE otherwise.
21476 // <str>: a nul-terminated string
21477 // <suffix>: the nul-terminated suffix to look for
21478 static int str_has_suffix()(char* str, char* suffix) nothrow {
21479 return g_str_has_suffix(str, suffix);
21483 // Converts a string to a hash value.
21485 // This function implements the widely used "djb" hash apparently posted
21486 // by Daniel Bernstein to comp.lang.c some time ago. The 32 bit
21487 // unsigned hash value starts at 5381 and for each byte 'c' in the
21488 // string, is updated: <literal>hash = hash * 33 + c</literal>. This
21489 // function uses the signed value of each byte.
21491 // It can be passed to g_hash_table_new() as the @hash_func parameter,
21492 // when using non-%NULL strings as keys in a #GHashTable.
21493 // RETURNS: a hash value corresponding to the key
21494 // <v>: a string key
21495 static uint str_hash()(const(void)* v) nothrow {
21496 return g_str_hash(v);
21500 // For each character in @string, if the character is not in
21501 // @valid_chars, replaces the character with @substitutor.
21502 // Modifies @string in place, and return @string itself, not
21503 // a copy. The return value is to allow nesting such as
21504 // |[
21505 // g_ascii_strup (g_strcanon (str, "abc", '?'))
21506 // ]|
21507 // RETURNS: @string
21508 // <string>: a nul-terminated array of bytes
21509 // <valid_chars>: bytes permitted in @string
21510 // <substitutor>: replacement character for disallowed bytes
21511 static char* /*new*/ strcanon()(char* string_, char* valid_chars, char substitutor) nothrow {
21512 return g_strcanon(string_, valid_chars, substitutor);
21516 // A case-insensitive string comparison, corresponding to the standard
21517 // strcasecmp() function on platforms which support it.
21519 // or a positive value if @s1 &gt; @s2.
21521 // Deprecated:2.2: See g_strncasecmp() for a discussion of why this function
21522 // is deprecated and how to replace it.
21523 // RETURNS: 0 if the strings match, a negative value if @s1 &lt; @s2,
21524 // <s1>: a string.
21525 // <s2>: a string to compare with @s1.
21526 static int strcasecmp()(char* s1, char* s2) nothrow {
21527 return g_strcasecmp(s1, s2);
21531 // Removes trailing whitespace from a string.
21533 // This function doesn't allocate or reallocate any memory;
21534 // it modifies @string in place. The pointer to @string is
21535 // returned to allow the nesting of functions.
21537 // Also see g_strchug() and g_strstrip().
21538 // RETURNS: @string.
21539 // <string>: a string to remove the trailing whitespace from
21540 static char* /*new*/ strchomp()(char* string_) nothrow {
21541 return g_strchomp(string_);
21545 // Removes leading whitespace from a string, by moving the rest
21546 // of the characters forward.
21548 // This function doesn't allocate or reallocate any memory;
21549 // it modifies @string in place. The pointer to @string is
21550 // returned to allow the nesting of functions.
21552 // Also see g_strchomp() and g_strstrip().
21553 // RETURNS: @string
21554 // <string>: a string to remove the leading whitespace from
21555 static char* /*new*/ strchug()(char* string_) nothrow {
21556 return g_strchug(string_);
21560 // VERSION: 2.16
21561 // Compares @str1 and @str2 like strcmp(). Handles %NULL
21562 // gracefully by sorting it before non-%NULL strings.
21563 // Comparing two %NULL pointers returns 0.
21564 // RETURNS: -1, 0 or 1, if @str1 is <, == or > than @str2.
21565 // <str1>: a C string or %NULL
21566 // <str2>: another C string or %NULL
21567 static int strcmp0()(char* str1, char* str2) nothrow {
21568 return g_strcmp0(str1, str2);
21572 // Replaces all escaped characters with their one byte equivalent.
21574 // This function does the reverse conversion of g_strescape().
21576 // character compressed
21577 // RETURNS: a newly-allocated copy of @source with all escaped
21578 // <source>: a string to compress
21579 static char* /*new*/ strcompress()(char* source) nothrow {
21580 return g_strcompress(source);
21584 // Unintrospectable function: strconcat() / g_strconcat()
21585 // Concatenates all of the given strings into one long string.
21586 // The returned string should be freed with g_free() when no longer needed.
21588 // Note that this function is usually not the right function to use to
21589 // assemble a translated message from pieces, since proper translation
21590 // often requires the pieces to be reordered.
21592 // <warning><para>The variable argument list <emphasis>must</emphasis> end
21593 // with %NULL. If you forget the %NULL, g_strconcat() will start appending
21594 // random memory junk to your string.</para></warning>
21595 // RETURNS: a newly-allocated string containing all the string arguments
21596 // <string1>: the first string to add, which must not be %NULL
21597 alias g_strconcat strconcat; // Variadic
21600 // Converts any delimiter characters in @string to @new_delimiter.
21601 // Any characters in @string which are found in @delimiters are
21602 // changed to the @new_delimiter character. Modifies @string in place,
21603 // and returns @string itself, not a copy. The return value is to
21604 // allow nesting such as
21605 // |[
21606 // g_ascii_strup (g_strdelimit (str, "abc", '?'))
21607 // ]|
21608 // RETURNS: @string
21609 // <string>: the string to convert
21610 // <delimiters>: a string containing the current delimiters, or %NULL to use the standard delimiters defined in #G_STR_DELIMITERS
21611 // <new_delimiter>: the new delimiter character
21612 static char* /*new*/ strdelimit()(char* string_, char* delimiters, char new_delimiter) nothrow {
21613 return g_strdelimit(string_, delimiters, new_delimiter);
21617 // Converts a string to lower case.
21620 // Deprecated:2.2: This function is totally broken for the reasons discussed
21621 // in the g_strncasecmp() docs - use g_ascii_strdown() or g_utf8_strdown()
21622 // instead.
21623 // RETURNS: the string
21624 // <string>: the string to convert.
21625 static char* /*new*/ strdown()(char* string_) nothrow {
21626 return g_strdown(string_);
21630 // Duplicates a string. If @str is %NULL it returns %NULL.
21631 // The returned string should be freed with g_free()
21632 // when no longer needed.
21633 // RETURNS: a newly-allocated copy of @str
21634 // <str>: the string to duplicate
21635 static char* /*new*/ strdup()(char* str) nothrow {
21636 return g_strdup(str);
21640 // Unintrospectable function: strdup_printf() / g_strdup_printf()
21641 // Similar to the standard C sprintf() function but safer, since it
21642 // calculates the maximum space required and allocates memory to hold
21643 // the result. The returned string should be freed with g_free() when no
21644 // longer needed.
21645 // RETURNS: a newly-allocated string holding the result
21646 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>
21647 alias g_strdup_printf strdup_printf; // Variadic
21650 // Unintrospectable function: strdup_vprintf() / g_strdup_vprintf()
21651 // Similar to the standard C vsprintf() function but safer, since it
21652 // calculates the maximum space required and allocates memory to hold
21653 // the result. The returned string should be freed with g_free() when
21654 // no longer needed.
21656 // See also g_vasprintf(), which offers the same functionality, but
21657 // additionally returns the length of the allocated string.
21658 // RETURNS: a newly-allocated string holding the result
21659 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>
21660 // <args>: the list of parameters to insert into the format string
21661 static char* /*new*/ strdup_vprintf()(char* format, va_list args) nothrow {
21662 return g_strdup_vprintf(format, args);
21666 // Unintrospectable function: strdupv() / g_strdupv()
21667 // Copies %NULL-terminated array of strings. The copy is a deep copy;
21668 // the new array should be freed by first freeing each string, then
21669 // the array itself. g_strfreev() does this for you. If called
21670 // on a %NULL value, g_strdupv() simply returns %NULL.
21671 // RETURNS: a new %NULL-terminated array of strings.
21672 // <str_array>: a %NULL-terminated array of strings
21673 static char** strdupv()(char** str_array) nothrow {
21674 return g_strdupv(str_array);
21678 // Returns a string corresponding to the given error code, e.g.
21679 // "no such process". You should use this function in preference to
21680 // strerror(), because it returns a string in UTF-8 encoding, and since
21681 // not all platforms support the strerror() function.
21683 // is unknown, it returns "unknown error (&lt;code&gt;)".
21684 // RETURNS: a UTF-8 string describing the error code. If the error code
21685 // <errnum>: the system error number. See the standard C %errno documentation
21686 static char* strerror()(int errnum) nothrow {
21687 return g_strerror(errnum);
21691 // Escapes the special characters '\b', '\f', '\n', '\r', '\t', '\v', '\'
21692 // and '&quot;' in the string @source by inserting a '\' before
21693 // them. Additionally all characters in the range 0x01-0x1F (everything
21694 // below SPACE) and in the range 0x7F-0xFF (all non-ASCII chars) are
21695 // replaced with a '\' followed by their octal representation.
21696 // Characters supplied in @exceptions are not escaped.
21698 // g_strcompress() does the reverse conversion.
21700 // characters escaped. See above.
21701 // RETURNS: a newly-allocated copy of @source with certain
21702 // <source>: a string to escape
21703 // <exceptions>: a string of characters not to escape in @source
21704 static char* /*new*/ strescape()(char* source, char* exceptions) nothrow {
21705 return g_strescape(source, exceptions);
21708 // <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.
21709 static void strfreev()(char** str_array) nothrow {
21710 g_strfreev(str_array);
21714 // Creates a new #GString, initialized with the given string.
21715 // RETURNS: the new #GString
21716 // <init>: the initial text to copy into the string
21717 static String* /*new*/ string_new()(char* init) nothrow {
21718 return g_string_new(init);
21722 // Creates a new #GString with @len bytes of the @init buffer.
21723 // Because a length is provided, @init need not be nul-terminated,
21724 // and can contain embedded nul bytes.
21726 // Since this function does not stop at nul bytes, it is the caller's
21727 // responsibility to ensure that @init has at least @len addressable
21728 // bytes.
21729 // RETURNS: a new #GString
21730 // <init>: initial contents of the string
21731 // <len>: length of @init to use
21732 static String* /*new*/ string_new_len()(char* init, ssize_t len) nothrow {
21733 return g_string_new_len(init, len);
21737 // Creates a new #GString, with enough space for @dfl_size
21738 // bytes. This is useful if you are going to add a lot of
21739 // text to the string and don't want it to be reallocated
21740 // too often.
21741 // RETURNS: the new #GString
21742 // <dfl_size>: the default size of the space allocated to hold the string
21743 static String* /*new*/ string_sized_new()(size_t dfl_size) nothrow {
21744 return g_string_sized_new(dfl_size);
21748 // VERSION: 2.4
21749 // An auxiliary function for gettext() support (see Q_()).
21751 // and contains a '|' character, in which case a pointer to
21752 // the substring of msgid after the first '|' character is returned.
21753 // RETURNS: @msgval, unless @msgval is identical to @msgid
21754 // <msgid>: a string
21755 // <msgval>: another string
21756 static char* strip_context()(char* msgid, char* msgval) nothrow {
21757 return g_strip_context(msgid, msgval);
21761 // Unintrospectable function: strjoin() / g_strjoin()
21762 // Joins a number of strings together to form one long string, with the
21763 // optional @separator inserted between each of them. The returned string
21764 // should be freed with g_free().
21766 // together, with @separator between them
21767 // RETURNS: a newly-allocated string containing all of the strings joined
21768 // <separator>: a string to insert between each of the strings, or %NULL
21769 alias g_strjoin strjoin; // Variadic
21772 // Joins a number of strings together to form one long string, with the
21773 // optional @separator inserted between each of them. The returned string
21774 // should be freed with g_free().
21776 // together, with @separator between them
21777 // RETURNS: a newly-allocated string containing all of the strings joined
21778 // <separator>: a string to insert between each of the strings, or %NULL
21779 // <str_array>: a %NULL-terminated array of strings to join
21780 static char* /*new*/ strjoinv()(char* separator, char** str_array) nothrow {
21781 return g_strjoinv(separator, str_array);
21785 // Portability wrapper that calls strlcat() on systems which have it,
21786 // and emulates it otherwise. Appends nul-terminated @src string to @dest,
21787 // guaranteeing nul-termination for @dest. The total size of @dest won't
21788 // exceed @dest_size.
21790 // At most dest_size - 1 characters will be copied.
21791 // Unlike strncat, dest_size is the full size of dest, not the space left over.
21792 // This function does NOT allocate memory.
21793 // This always NUL terminates (unless siz == 0 or there were no NUL characters
21794 // in the dest_size characters of dest to start with).
21796 // <note><para>Caveat: this is supposedly a more secure alternative to
21797 // strcat() or strncat(), but for real security g_strconcat() is harder
21798 // to mess up.</para></note>
21800 // (original dest)) + strlen (src), so if retval >= dest_size,
21801 // truncation occurred.
21802 // RETURNS: size of attempted result, which is MIN (dest_size, strlen
21803 // <dest>: destination buffer, already containing one nul-terminated string
21804 // <src>: source buffer
21805 // <dest_size>: length of @dest buffer in bytes (not length of existing string inside @dest)
21806 static size_t strlcat()(char* dest, char* src, size_t dest_size) nothrow {
21807 return g_strlcat(dest, src, dest_size);
21811 // Portability wrapper that calls strlcpy() on systems which have it,
21812 // and emulates strlcpy() otherwise. Copies @src to @dest; @dest is
21813 // guaranteed to be nul-terminated; @src must be nul-terminated;
21814 // @dest_size is the buffer size, not the number of chars to copy.
21816 // At most dest_size - 1 characters will be copied. Always nul-terminates
21817 // (unless dest_size == 0). This function does <emphasis>not</emphasis>
21818 // allocate memory. Unlike strncpy(), this function doesn't pad dest (so
21819 // it's often faster). It returns the size of the attempted result,
21820 // strlen (src), so if @retval >= @dest_size, truncation occurred.
21822 // <note><para>Caveat: strlcpy() is supposedly more secure than
21823 // strcpy() or strncpy(), but if you really want to avoid screwups,
21824 // g_strdup() is an even better idea.</para></note>
21825 // RETURNS: length of @src
21826 // <dest>: destination buffer
21827 // <src>: source buffer
21828 // <dest_size>: length of @dest in bytes
21829 static size_t strlcpy()(char* dest, char* src, size_t dest_size) nothrow {
21830 return g_strlcpy(dest, src, dest_size);
21834 // A case-insensitive string comparison, corresponding to the standard
21835 // strncasecmp() function on platforms which support it.
21836 // It is similar to g_strcasecmp() except it only compares the first @n
21837 // characters of the strings.
21839 // or a positive value if @s1 &gt; @s2.
21841 // Deprecated:2.2: The problem with g_strncasecmp() is that it does the
21842 // comparison by calling toupper()/tolower(). These functions are
21843 // locale-specific and operate on single bytes. However, it is impossible
21844 // to handle things correctly from an I18N standpoint by operating on
21845 // bytes, since characters may be multibyte. Thus g_strncasecmp() is
21846 // broken if your string is guaranteed to be ASCII, since it's
21847 // locale-sensitive, and it's broken if your string is localized, since
21848 // it doesn't work on many encodings at all, including UTF-8, EUC-JP,
21849 // etc.
21851 // There are therefore two replacement functions: g_ascii_strncasecmp(),
21852 // which only works on ASCII and is not locale-sensitive, and
21853 // g_utf8_casefold(), which is good for case-insensitive sorting of UTF-8.
21854 // RETURNS: 0 if the strings match, a negative value if @s1 &lt; @s2,
21855 // <s1>: a string.
21856 // <s2>: a string to compare with @s1.
21857 // <n>: the maximum number of characters to compare.
21858 static int strncasecmp()(char* s1, char* s2, uint n) nothrow {
21859 return g_strncasecmp(s1, s2, n);
21863 // Duplicates the first @n bytes of a string, returning a newly-allocated
21864 // buffer @n + 1 bytes long which will always be nul-terminated.
21865 // If @str is less than @n bytes long the buffer is padded with nuls.
21866 // If @str is %NULL it returns %NULL.
21867 // The returned value should be freed when no longer needed.
21869 // <note><para>
21870 // To copy a number of characters from a UTF-8 encoded string, use
21871 // g_utf8_strncpy() instead.
21872 // </para></note>
21874 // of @str, nul-terminated
21875 // RETURNS: a newly-allocated buffer containing the first @n bytes
21876 // <str>: the string to duplicate
21877 // <n>: the maximum number of bytes to copy from @str
21878 static char* /*new*/ strndup()(char* str, size_t n) nothrow {
21879 return g_strndup(str, n);
21883 // Creates a new string @length bytes long filled with @fill_char.
21884 // The returned string should be freed when no longer needed.
21885 // RETURNS: a newly-allocated string filled the @fill_char
21886 // <length>: the length of the new string
21887 // <fill_char>: the byte to fill the string with
21888 static char* /*new*/ strnfill()(size_t length, char fill_char) nothrow {
21889 return g_strnfill(length, fill_char);
21893 // Reverses all of the bytes in a string. For example,
21894 // <literal>g_strreverse ("abcdef")</literal> will result
21895 // in "fedcba".
21897 // Note that g_strreverse() doesn't work on UTF-8 strings
21898 // containing multibyte characters. For that purpose, use
21899 // g_utf8_strreverse().
21900 // RETURNS: the same pointer passed in as @string
21901 // <string>: the string to reverse
21902 static char* /*new*/ strreverse()(char* string_) nothrow {
21903 return g_strreverse(string_);
21907 // Searches the string @haystack for the last occurrence
21908 // of the string @needle.
21910 // %NULL if not found.
21911 // RETURNS: a pointer to the found occurrence, or
21912 // <haystack>: a nul-terminated string
21913 // <needle>: the nul-terminated string to search for
21914 static char* /*new*/ strrstr()(char* haystack, char* needle) nothrow {
21915 return g_strrstr(haystack, needle);
21919 // Searches the string @haystack for the last occurrence
21920 // of the string @needle, limiting the length of the search
21921 // to @haystack_len.
21923 // %NULL if not found.
21924 // RETURNS: a pointer to the found occurrence, or
21925 // <haystack>: a nul-terminated string
21926 // <haystack_len>: the maximum length of @haystack
21927 // <needle>: the nul-terminated string to search for
21928 static char* /*new*/ strrstr_len()(char* haystack, ssize_t haystack_len, char* needle) nothrow {
21929 return g_strrstr_len(haystack, haystack_len, needle);
21933 // Returns a string describing the given signal, e.g. "Segmentation fault".
21934 // You should use this function in preference to strsignal(), because it
21935 // returns a string in UTF-8 encoding, and since not all platforms support
21936 // the strsignal() function.
21938 // it returns "unknown signal (&lt;signum&gt;)".
21939 // RETURNS: a UTF-8 string describing the signal. If the signal is unknown,
21940 // <signum>: the signal number. See the <literal>signal</literal> documentation
21941 static char* strsignal()(int signum) nothrow {
21942 return g_strsignal(signum);
21946 // Unintrospectable function: strsplit() / g_strsplit()
21947 // Splits a string into a maximum of @max_tokens pieces, using the given
21948 // @delimiter. If @max_tokens is reached, the remainder of @string is
21949 // appended to the last token.
21951 // As a special case, the result of splitting the empty string "" is an empty
21952 // vector, not a vector containing a single string. The reason for this
21953 // special case is that being able to represent a empty vector is typically
21954 // more useful than consistent handling of empty elements. If you do need
21955 // to represent empty elements, you'll need to check for the empty string
21956 // before calling g_strsplit().
21958 // g_strfreev() to free it.
21959 // RETURNS: a newly-allocated %NULL-terminated array of strings. Use
21960 // <string>: a string to split
21961 // <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.
21962 // <max_tokens>: the maximum number of pieces to split @string into. If this is less than 1, the string is split completely.
21963 static char** strsplit()(char* string_, char* delimiter, int max_tokens) nothrow {
21964 return g_strsplit(string_, delimiter, max_tokens);
21968 // Unintrospectable function: strsplit_set() / g_strsplit_set()
21969 // VERSION: 2.4
21970 // Splits @string into a number of tokens not containing any of the characters
21971 // in @delimiter. A token is the (possibly empty) longest string that does not
21972 // contain any of the characters in @delimiters. If @max_tokens is reached, the
21973 // remainder is appended to the last token.
21975 // For example the result of g_strsplit_set ("abc:def/ghi", ":/", -1) is a
21976 // %NULL-terminated vector containing the three strings "abc", "def",
21977 // and "ghi".
21979 // The result if g_strsplit_set (":def/ghi:", ":/", -1) is a %NULL-terminated
21980 // vector containing the four strings "", "def", "ghi", and "".
21982 // As a special case, the result of splitting the empty string "" is an empty
21983 // vector, not a vector containing a single string. The reason for this
21984 // special case is that being able to represent a empty vector is typically
21985 // more useful than consistent handling of empty elements. If you do need
21986 // to represent empty elements, you'll need to check for the empty string
21987 // before calling g_strsplit_set().
21989 // Note that this function works on bytes not characters, so it can't be used
21990 // to delimit UTF-8 strings for anything but ASCII characters.
21992 // g_strfreev() to free it.
21993 // RETURNS: a newly-allocated %NULL-terminated array of strings. Use
21994 // <string>: The string to be tokenized
21995 // <delimiters>: A nul-terminated string containing bytes that are used to split the string.
21996 // <max_tokens>: The maximum number of tokens to split @string into. If this is less than 1, the string is split completely
21997 static char** strsplit_set()(char* string_, char* delimiters, int max_tokens) nothrow {
21998 return g_strsplit_set(string_, delimiters, max_tokens);
22002 // Searches the string @haystack for the first occurrence
22003 // of the string @needle, limiting the length of the search
22004 // to @haystack_len.
22006 // %NULL if not found.
22007 // RETURNS: a pointer to the found occurrence, or
22008 // <haystack>: a string
22009 // <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.
22010 // <needle>: the string to search for
22011 static char* /*new*/ strstr_len()(char* haystack, ssize_t haystack_len, char* needle) nothrow {
22012 return g_strstr_len(haystack, haystack_len, needle);
22016 // Converts a string to a #gdouble value.
22017 // It calls the standard strtod() function to handle the conversion, but
22018 // if the string is not completely converted it attempts the conversion
22019 // again with g_ascii_strtod(), and returns the best match.
22021 // This function should seldom be used. The normal situation when reading
22022 // numbers not for human consumption is to use g_ascii_strtod(). Only when
22023 // you know that you must expect both locale formatted and C formatted numbers
22024 // should you use this. Make sure that you don't pass strings such as comma
22025 // separated lists of values, since the commas may be interpreted as a decimal
22026 // point in some locales, causing unexpected results.
22027 // RETURNS: the #gdouble value.
22028 // <nptr>: the string to convert to a numeric value.
22029 // <endptr>: if non-%NULL, it returns the character after the last character used in the conversion.
22030 static double strtod()(char* nptr, char** endptr) nothrow {
22031 return g_strtod(nptr, endptr);
22035 // Converts a string to upper case.
22038 // Deprecated:2.2: This function is totally broken for the reasons discussed
22039 // in the g_strncasecmp() docs - use g_ascii_strup() or g_utf8_strup() instead.
22040 // RETURNS: the string
22041 // <string>: the string to convert.
22042 static char* /*new*/ strup()(char* string_) nothrow {
22043 return g_strup(string_);
22046 static Type strv_get_type()() nothrow {
22047 return g_strv_get_type();
22051 // VERSION: 2.6
22052 // Returns the length of the given %NULL-terminated
22053 // string array @str_array.
22054 // RETURNS: length of @str_array.
22055 // <str_array>: a %NULL-terminated array of strings
22056 static uint strv_length()(char** str_array) nothrow {
22057 return g_strv_length(str_array);
22061 // Unintrospectable function: test_add_data_func() / g_test_add_data_func()
22062 // VERSION: 2.16
22063 // Create a new test case, similar to g_test_create_case(). However
22064 // the test is assumed to use no fixture, and test suites are automatically
22065 // created on the fly and added to the root fixture, based on the
22066 // slash-separated portions of @testpath. The @test_data argument
22067 // will be passed as first argument to @test_func.
22068 // <testpath>: Slash-separated test case path name for the test.
22069 // <test_data>: Test data argument for the test function.
22070 // <test_func>: The test function to invoke for this test.
22071 static void test_add_data_func()(char* testpath, const(void)* test_data, TestDataFunc test_func) nothrow {
22072 g_test_add_data_func(testpath, test_data, test_func);
22076 // Unintrospectable function: test_add_func() / g_test_add_func()
22077 // VERSION: 2.16
22078 // Create a new test case, similar to g_test_create_case(). However
22079 // the test is assumed to use no fixture, and test suites are automatically
22080 // created on the fly and added to the root fixture, based on the
22081 // slash-separated portions of @testpath.
22082 // <testpath>: Slash-separated test case path name for the test.
22083 // <test_func>: The test function to invoke for this test.
22084 static void test_add_func()(char* testpath, TestFunc test_func) nothrow {
22085 g_test_add_func(testpath, test_func);
22088 // Unintrospectable function: test_add_vtable() / g_test_add_vtable()
22089 static void test_add_vtable()(char* testpath, size_t data_size, const(void)* test_data, TestFixtureFunc data_setup, TestFixtureFunc data_test, TestFixtureFunc data_teardown) nothrow {
22090 g_test_add_vtable(testpath, data_size, test_data, data_setup, data_test, data_teardown);
22094 // VERSION: 2.16
22095 // This function adds a message to test reports that
22096 // associates a bug URI with a test case.
22097 // Bug URIs are constructed from a base URI set with g_test_bug_base()
22098 // and @bug_uri_snippet.
22099 // <bug_uri_snippet>: Bug specific bug tracker URI portion.
22100 static void test_bug()(char* bug_uri_snippet) nothrow {
22101 g_test_bug(bug_uri_snippet);
22105 // VERSION: 2.16
22106 // Specify the base URI for bug reports.
22108 // The base URI is used to construct bug report messages for
22109 // g_test_message() when g_test_bug() is called.
22110 // Calling this function outside of a test case sets the
22111 // default base URI for all test cases. Calling it from within
22112 // a test case changes the base URI for the scope of the test
22113 // case only.
22114 // Bug URIs are constructed by appending a bug specific URI
22115 // portion to @uri_pattern, or by replacing the special string
22116 // '\%s' within @uri_pattern if that is present.
22117 // <uri_pattern>: the base pattern for bug URIs
22118 static void test_bug_base()(char* uri_pattern) nothrow {
22119 g_test_bug_base(uri_pattern);
22123 // Unintrospectable function: test_create_case() / g_test_create_case()
22124 // VERSION: 2.16
22125 // Create a new #GTestCase, named @test_name, this API is fairly
22126 // low level, calling g_test_add() or g_test_add_func() is preferable.
22127 // When this test is executed, a fixture structure of size @data_size
22128 // will be allocated and filled with 0s. Then @data_setup is called
22129 // to initialize the fixture. After fixture setup, the actual test
22130 // function @data_test is called. Once the test run completed, the
22131 // fixture structure is torn down by calling @data_teardown and
22132 // after that the memory is released.
22134 // Splitting up a test run into fixture setup, test function and
22135 // fixture teardown is most usful if the same fixture is used for
22136 // multiple tests. In this cases, g_test_create_case() will be
22137 // called with the same fixture, but varying @test_name and
22138 // @data_test arguments.
22139 // RETURNS: a newly allocated #GTestCase.
22140 // <test_name>: the name for the test case
22141 // <data_size>: the size of the fixture data structure
22142 // <test_data>: test data argument for the test functions
22143 // <data_setup>: the function to set up the fixture data
22144 // <data_test>: the actual test function
22145 // <data_teardown>: the function to teardown the fixture data
22146 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) nothrow {
22147 return g_test_create_case(test_name, data_size, test_data, data_setup, data_test, data_teardown);
22151 // Unintrospectable function: test_create_suite() / g_test_create_suite()
22152 // VERSION: 2.16
22153 // Create a new test suite with the name @suite_name.
22154 // RETURNS: A newly allocated #GTestSuite instance.
22155 // <suite_name>: a name for the suite
22156 static TestSuite* test_create_suite()(char* suite_name) nothrow {
22157 return g_test_create_suite(suite_name);
22161 // VERSION: 2.30
22162 // Indicates that a test failed. This function can be called
22163 // multiple times from the same test. You can use this function
22164 // if your test failed in a recoverable way.
22166 // Do not use this function if the failure of a test could cause
22167 // other tests to malfunction.
22169 // Calling this function will not stop the test from running, you
22170 // need to return from the test function yourself. So you can
22171 // produce additional diagnostic messages or even continue running
22172 // the test.
22174 // If not called from inside a test, this function does nothing.
22175 static void test_fail()() nothrow {
22176 g_test_fail();
22180 // Unintrospectable function: test_get_root() / g_test_get_root()
22181 // VERSION: 2.16
22182 // Get the toplevel test suite for the test path API.
22183 // RETURNS: the toplevel #GTestSuite
22184 static TestSuite* test_get_root()() nothrow {
22185 return g_test_get_root();
22189 // Unintrospectable function: test_init() / g_test_init()
22190 // VERSION: 2.16
22191 // Initialize the GLib testing framework, e.g. by seeding the
22192 // test random number generator, the name for g_get_prgname()
22193 // and parsing test related command line args.
22194 // So far, the following arguments are understood:
22195 // <variablelist>
22196 // <varlistentry>
22197 // <term><option>-l</option></term>
22198 // <listitem><para>
22199 // list test cases available in a test executable.
22200 // </para></listitem>
22201 // </varlistentry>
22202 // <varlistentry>
22203 // <term><option>--seed=<replaceable>RANDOMSEED</replaceable></option></term>
22204 // <listitem><para>
22205 // provide a random seed to reproduce test runs using random numbers.
22206 // </para></listitem>
22207 // </varlistentry>
22208 // <varlistentry>
22209 // <term><option>--verbose</option></term>
22210 // <listitem><para>run tests verbosely.</para></listitem>
22211 // </varlistentry>
22212 // <varlistentry>
22213 // <term><option>-q</option>, <option>--quiet</option></term>
22214 // <listitem><para>run tests quietly.</para></listitem>
22215 // </varlistentry>
22216 // <varlistentry>
22217 // <term><option>-p <replaceable>TESTPATH</replaceable></option></term>
22218 // <listitem><para>
22219 // execute all tests matching <replaceable>TESTPATH</replaceable>.
22220 // </para></listitem>
22221 // </varlistentry>
22222 // <varlistentry>
22223 // <term><option>-m {perf|slow|thorough|quick|undefined|no-undefined}</option></term>
22224 // <listitem><para>
22225 // execute tests according to these test modes:
22226 // <variablelist>
22227 // <varlistentry>
22228 // <term>perf</term>
22229 // <listitem><para>
22230 // performance tests, may take long and report results.
22231 // </para></listitem>
22232 // </varlistentry>
22233 // <varlistentry>
22234 // <term>slow, thorough</term>
22235 // <listitem><para>
22236 // slow and thorough tests, may take quite long and
22237 // maximize coverage.
22238 // </para></listitem>
22239 // </varlistentry>
22240 // <varlistentry>
22241 // <term>quick</term>
22242 // <listitem><para>
22243 // quick tests, should run really quickly and give good coverage.
22244 // </para></listitem>
22245 // </varlistentry>
22246 // <varlistentry>
22247 // <term>undefined</term>
22248 // <listitem><para>
22249 // tests for undefined behaviour, may provoke programming errors
22250 // under g_test_trap_fork() to check that appropriate assertions
22251 // or warnings are given
22252 // </para></listitem>
22253 // </varlistentry>
22254 // <varlistentry>
22255 // <term>no-undefined</term>
22256 // <listitem><para>
22257 // avoid tests for undefined behaviour
22258 // </para></listitem>
22259 // </varlistentry>
22260 // </variablelist>
22261 // </para></listitem>
22262 // </varlistentry>
22263 // <varlistentry>
22264 // <term><option>--debug-log</option></term>
22265 // <listitem><para>debug test logging output.</para></listitem>
22266 // </varlistentry>
22267 // <varlistentry>
22268 // <term><option>-k</option>, <option>--keep-going</option></term>
22269 // <listitem><para>gtester-specific argument.</para></listitem>
22270 // </varlistentry>
22271 // <varlistentry>
22272 // <term><option>--GTestLogFD <replaceable>N</replaceable></option></term>
22273 // <listitem><para>gtester-specific argument.</para></listitem>
22274 // </varlistentry>
22275 // <varlistentry>
22276 // <term><option>--GTestSkipCount <replaceable>N</replaceable></option></term>
22277 // <listitem><para>gtester-specific argument.</para></listitem>
22278 // </varlistentry>
22279 // </variablelist>
22280 // <argc>: Address of the @argc parameter of the main() function. Changed if any arguments were handled.
22281 // <argv>: Address of the @argv parameter of main(). Any parameters understood by g_test_init() stripped before return.
22282 alias g_test_init test_init; // Variadic
22285 // Unintrospectable function: test_log_set_fatal_handler() / g_test_log_set_fatal_handler()
22286 // VERSION: 2.22
22287 // Installs a non-error fatal log handler which can be
22288 // used to decide whether log messages which are counted
22289 // as fatal abort the program.
22291 // The use case here is that you are running a test case
22292 // that depends on particular libraries or circumstances
22293 // and cannot prevent certain known critical or warning
22294 // messages. So you install a handler that compares the
22295 // domain and message to precisely not abort in such a case.
22297 // Note that the handler is reset at the beginning of
22298 // any test case, so you have to set it inside each test
22299 // function which needs the special behavior.
22301 // This handler has no effect on g_error messages.
22302 // <log_func>: the log handler function.
22303 // <user_data>: data passed to the log handler.
22304 static void test_log_set_fatal_handler()(TestLogFatalFunc log_func, void* user_data) nothrow {
22305 g_test_log_set_fatal_handler(log_func, user_data);
22308 static char* test_log_type_name()(TestLogType log_type) nothrow {
22309 return g_test_log_type_name(log_type);
22313 // Unintrospectable function: test_maximized_result() / g_test_maximized_result()
22314 // VERSION: 2.16
22315 // Report the result of a performance or measurement test.
22316 // The test should generally strive to maximize the reported
22317 // quantities (larger values are better than smaller ones),
22318 // this and @maximized_quantity can determine sorting
22319 // order for test result reports.
22320 // <maximized_quantity>: the reported value
22321 // <format>: the format string of the report message
22322 alias g_test_maximized_result test_maximized_result; // Variadic
22325 // Unintrospectable function: test_message() / g_test_message()
22326 // VERSION: 2.16
22327 // Add a message to the test report.
22328 // <format>: the format string
22329 alias g_test_message test_message; // Variadic
22332 // Unintrospectable function: test_minimized_result() / g_test_minimized_result()
22333 // VERSION: 2.16
22334 // Report the result of a performance or measurement test.
22335 // The test should generally strive to minimize the reported
22336 // quantities (smaller values are better than larger ones),
22337 // this and @minimized_quantity can determine sorting
22338 // order for test result reports.
22339 // <minimized_quantity>: the reported value
22340 // <format>: the format string of the report message
22341 alias g_test_minimized_result test_minimized_result; // Variadic
22344 // VERSION: 2.16
22345 // This function enqueus a callback @destroy_func to be executed
22346 // during the next test case teardown phase. This is most useful
22347 // to auto destruct allocted test resources at the end of a test run.
22348 // Resources are released in reverse queue order, that means enqueueing
22349 // callback A before callback B will cause B() to be called before
22350 // A() during teardown.
22351 // <destroy_func>: Destroy callback for teardown phase.
22352 // <destroy_data>: Destroy callback data.
22353 static void test_queue_destroy()(DestroyNotify destroy_func, void* destroy_data) nothrow {
22354 g_test_queue_destroy(destroy_func, destroy_data);
22358 // VERSION: 2.16
22359 // Enqueue a pointer to be released with g_free() during the next
22360 // teardown phase. This is equivalent to calling g_test_queue_destroy()
22361 // with a destroy callback of g_free().
22362 // <gfree_pointer>: the pointer to be stored.
22363 static void test_queue_free()(void* gfree_pointer) nothrow {
22364 g_test_queue_free(gfree_pointer);
22368 // VERSION: 2.16
22369 // Get a reproducible random floating point number,
22370 // see g_test_rand_int() for details on test case random numbers.
22371 // RETURNS: a random number from the seeded random number generator.
22372 static double test_rand_double()() nothrow {
22373 return g_test_rand_double();
22377 // VERSION: 2.16
22378 // Get a reproducible random floating pointer number out of a specified range,
22379 // see g_test_rand_int() for details on test case random numbers.
22380 // RETURNS: a number with @range_start <= number < @range_end.
22381 // <range_start>: the minimum value returned by this function
22382 // <range_end>: the minimum value not returned by this function
22383 static double test_rand_double_range()(double range_start, double range_end) nothrow {
22384 return g_test_rand_double_range(range_start, range_end);
22388 // VERSION: 2.16
22389 // Get a reproducible random integer number.
22391 // The random numbers generated by the g_test_rand_*() family of functions
22392 // change with every new test program start, unless the --seed option is
22393 // given when starting test programs.
22395 // For individual test cases however, the random number generator is
22396 // reseeded, to avoid dependencies between tests and to make --seed
22397 // effective for all test cases.
22398 // RETURNS: a random number from the seeded random number generator.
22399 static int test_rand_int()() nothrow {
22400 return g_test_rand_int();
22404 // VERSION: 2.16
22405 // Get a reproducible random integer number out of a specified range,
22406 // see g_test_rand_int() for details on test case random numbers.
22407 // RETURNS: a number with @begin <= number < @end.
22408 // <begin>: the minimum value returned by this function
22409 // <end>: the smallest value not to be returned by this function
22410 static int test_rand_int_range()(int begin, int end) nothrow {
22411 return g_test_rand_int_range(begin, end);
22415 // VERSION: 2.16
22416 // Runs all tests under the toplevel suite which can be retrieved
22417 // with g_test_get_root(). Similar to g_test_run_suite(), the test
22418 // cases to be run are filtered according to
22419 // test path arguments (-p <replaceable>testpath</replaceable>) as
22420 // parsed by g_test_init().
22421 // g_test_run_suite() or g_test_run() may only be called once
22422 // in a program.
22423 // RETURNS: 0 on success
22424 static int test_run()() nothrow {
22425 return g_test_run();
22429 // VERSION: 2.16
22430 // Execute the tests within @suite and all nested #GTestSuites.
22431 // The test suites to be executed are filtered according to
22432 // test path arguments (-p <replaceable>testpath</replaceable>)
22433 // as parsed by g_test_init().
22434 // g_test_run_suite() or g_test_run() may only be called once
22435 // in a program.
22436 // RETURNS: 0 on success
22437 // <suite>: a #GTestSuite
22438 static int test_run_suite()(TestSuite* suite) nothrow {
22439 return g_test_run_suite(suite);
22443 // VERSION: 2.16
22444 // Get the time since the last start of the timer with g_test_timer_start().
22445 // RETURNS: the time since the last start of the timer, as a double
22446 static double test_timer_elapsed()() nothrow {
22447 return g_test_timer_elapsed();
22451 // VERSION: 2.16
22452 // Report the last result of g_test_timer_elapsed().
22453 // RETURNS: the last result of g_test_timer_elapsed(), as a double
22454 static double test_timer_last()() nothrow {
22455 return g_test_timer_last();
22459 // VERSION: 2.16
22460 // Start a timing test. Call g_test_timer_elapsed() when the task is supposed
22461 // to be done. Call this function again to restart the timer.
22462 static void test_timer_start()() nothrow {
22463 g_test_timer_start();
22466 static void test_trap_assertions()(char* domain, char* file, int line, char* func, ulong assertion_flags, char* pattern) nothrow {
22467 g_test_trap_assertions(domain, file, line, func, assertion_flags, pattern);
22471 // VERSION: 2.16
22472 // Fork the current test program to execute a test case that might
22473 // not return or that might abort. The forked test case is aborted
22474 // and considered failing if its run time exceeds @usec_timeout.
22476 // The forking behavior can be configured with the #GTestTrapFlags flags.
22478 // In the following example, the test code forks, the forked child
22479 // process produces some sample output and exits successfully.
22480 // The forking parent process then asserts successful child program
22481 // termination and validates child program outputs.
22483 // |[
22484 // static void
22485 // test_fork_patterns (void)
22486 // {
22487 // if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
22488 // {
22489 // g_print ("some stdout text: somagic17\n");
22490 // g_printerr ("some stderr text: semagic43\n");
22491 // exit (0); /&ast; successful test run &ast;/
22492 // }
22493 // g_test_trap_assert_passed();
22494 // g_test_trap_assert_stdout ("*somagic17*");
22495 // g_test_trap_assert_stderr ("*semagic43*");
22496 // }
22497 // ]|
22499 // This function is implemented only on Unix platforms.
22500 // RETURNS: %TRUE for the forked child and %FALSE for the executing parent process.
22501 // <usec_timeout>: Timeout for the forked test in micro seconds.
22502 // <test_trap_flags>: Flags to modify forking behaviour.
22503 static int test_trap_fork()(ulong usec_timeout, TestTrapFlags test_trap_flags) nothrow {
22504 return g_test_trap_fork(usec_timeout, test_trap_flags);
22508 // VERSION: 2.16
22509 // Check the result of the last g_test_trap_fork() call.
22510 // RETURNS: %TRUE if the last forked child terminated successfully.
22511 static int test_trap_has_passed()() nothrow {
22512 return g_test_trap_has_passed();
22516 // VERSION: 2.16
22517 // Check the result of the last g_test_trap_fork() call.
22518 // RETURNS: %TRUE if the last forked child got killed due to a fork timeout.
22519 static int test_trap_reached_timeout()() nothrow {
22520 return g_test_trap_reached_timeout();
22523 // MOVED TO: Thread.error_quark
22524 static Quark thread_error_quark()() nothrow {
22525 return g_thread_error_quark();
22529 // MOVED TO: Thread.exit
22530 // Terminates the current thread.
22532 // If another thread is waiting for us using g_thread_join() then the
22533 // waiting thread will be woken up and get @retval as the return value
22534 // of g_thread_join().
22536 // Calling <literal>g_thread_exit (retval)</literal> is equivalent to
22537 // returning @retval from the function @func, as given to g_thread_new().
22539 // <note><para>
22540 // You must only call g_thread_exit() from a thread that you created
22541 // yourself with g_thread_new() or related APIs. You must not call
22542 // this function from a thread created with another threading library
22543 // or or from within a #GThreadPool.
22544 // </para></note>
22545 // <retval>: the return value of this thread
22546 static void thread_exit()(void* retval) nothrow {
22547 g_thread_exit(retval);
22551 // VERSION: 2.10
22552 // MOVED TO: ThreadPool.get_max_idle_time
22553 // This function will return the maximum @interval that a
22554 // thread will wait in the thread pool for new tasks before
22555 // being stopped.
22557 // If this function returns 0, threads waiting in the thread
22558 // pool for new work are not stopped.
22560 // for new tasks in the thread pool before stopping the
22561 // thread
22562 // RETURNS: the maximum @interval (milliseconds) to wait
22563 static uint thread_pool_get_max_idle_time()() nothrow {
22564 return g_thread_pool_get_max_idle_time();
22568 // MOVED TO: ThreadPool.get_max_unused_threads
22569 // Returns the maximal allowed number of unused threads.
22570 // RETURNS: the maximal number of unused threads
22571 static int thread_pool_get_max_unused_threads()() nothrow {
22572 return g_thread_pool_get_max_unused_threads();
22576 // MOVED TO: ThreadPool.get_num_unused_threads
22577 // Returns the number of currently unused threads.
22578 // RETURNS: the number of currently unused threads
22579 static uint thread_pool_get_num_unused_threads()() nothrow {
22580 return g_thread_pool_get_num_unused_threads();
22584 // VERSION: 2.10
22585 // MOVED TO: ThreadPool.set_max_idle_time
22586 // This function will set the maximum @interval that a thread
22587 // waiting in the pool for new tasks can be idle for before
22588 // being stopped. This function is similar to calling
22589 // g_thread_pool_stop_unused_threads() on a regular timeout,
22590 // except this is done on a per thread basis.
22592 // By setting @interval to 0, idle threads will not be stopped.
22594 // This function makes use of g_async_queue_timed_pop () using
22595 // @interval.
22596 // <interval>: the maximum @interval (in milliseconds) a thread can be idle
22597 static void thread_pool_set_max_idle_time()(uint interval) nothrow {
22598 g_thread_pool_set_max_idle_time(interval);
22602 // MOVED TO: ThreadPool.set_max_unused_threads
22603 // Sets the maximal number of unused threads to @max_threads.
22604 // If @max_threads is -1, no limit is imposed on the number
22605 // of unused threads.
22606 // <max_threads>: maximal number of unused threads
22607 static void thread_pool_set_max_unused_threads()(int max_threads) nothrow {
22608 g_thread_pool_set_max_unused_threads(max_threads);
22612 // MOVED TO: ThreadPool.stop_unused_threads
22613 // Stops all currently unused threads. This does not change the
22614 // maximal number of unused threads. This function can be used to
22615 // regularly stop all unused threads e.g. from g_timeout_add().
22616 static void thread_pool_stop_unused_threads()() nothrow {
22617 g_thread_pool_stop_unused_threads();
22621 // MOVED TO: Thread.yield
22622 // Causes the calling thread to voluntarily relinquish the CPU, so
22623 // that other threads can run.
22625 // This function is often used as a method to make busy wait less evil.
22626 static void thread_yield()() nothrow {
22627 g_thread_yield();
22631 // VERSION: 2.12
22632 // MOVED TO: TimeVal.from_iso8601
22633 // Converts a string containing an ISO 8601 encoded date and time
22634 // to a #GTimeVal and puts it into @time_.
22636 // @iso_date must include year, month, day, hours, minutes, and
22637 // seconds. It can optionally include fractions of a second and a time
22638 // zone indicator. (In the absence of any time zone indication, the
22639 // timestamp is assumed to be in local time.)
22640 // RETURNS: %TRUE if the conversion was successful.
22641 // <iso_date>: an ISO 8601 encoded date string
22642 // <time_>: a #GTimeVal
22643 static int time_val_from_iso8601()(char* iso_date, /*out*/ TimeVal* time_) nothrow {
22644 return g_time_val_from_iso8601(iso_date, time_);
22648 // Unintrospectable function: timeout_add() / g_timeout_add()
22649 // Sets a function to be called at regular intervals, with the default
22650 // priority, #G_PRIORITY_DEFAULT. The function is called repeatedly
22651 // until it returns %FALSE, at which point the timeout is automatically
22652 // destroyed and the function will not be called again. The first call
22653 // to the function will be at the end of the first @interval.
22655 // Note that timeout functions may be delayed, due to the processing of other
22656 // event sources. Thus they should not be relied on for precise timing.
22657 // After each call to the timeout function, the time of the next
22658 // timeout is recalculated based on the current time and the given interval
22659 // (it does not try to 'catch up' time lost in delays).
22661 // If you want to have a timer in the "seconds" range and do not care
22662 // about the exact time of the first call of the timer, use the
22663 // g_timeout_add_seconds() function; this function allows for more
22664 // optimizations and more efficient system power usage.
22666 // This internally creates a main loop source using g_timeout_source_new()
22667 // and attaches it to the main loop context using g_source_attach(). You can
22668 // do these steps manually if you need greater control.
22670 // The interval given is in terms of monotonic time, not wall clock
22671 // time. See g_get_monotonic_time().
22672 // RETURNS: the ID (greater than 0) of the event source.
22673 // <interval>: the time between calls to the function, in milliseconds (1/1000ths of a second)
22674 // <function>: function to call
22675 // <data>: data to pass to @function
22676 static uint timeout_add()(uint interval, SourceFunc function_, void* data) nothrow {
22677 return g_timeout_add(interval, function_, data);
22681 // Sets a function to be called at regular intervals, with the given
22682 // priority. The function is called repeatedly until it returns
22683 // %FALSE, at which point the timeout is automatically destroyed and
22684 // the function will not be called again. The @notify function is
22685 // called when the timeout is destroyed. The first call to the
22686 // function will be at the end of the first @interval.
22688 // Note that timeout functions may be delayed, due to the processing of other
22689 // event sources. Thus they should not be relied on for precise timing.
22690 // After each call to the timeout function, the time of the next
22691 // timeout is recalculated based on the current time and the given interval
22692 // (it does not try to 'catch up' time lost in delays).
22694 // This internally creates a main loop source using g_timeout_source_new()
22695 // and attaches it to the main loop context using g_source_attach(). You can
22696 // do these steps manually if you need greater control.
22698 // The interval given in terms of monotonic time, not wall clock time.
22699 // See g_get_monotonic_time().
22700 // RETURNS: the ID (greater than 0) of the event source.
22701 // <priority>: the priority of the timeout source. Typically this will be in the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
22702 // <interval>: the time between calls to the function, in milliseconds (1/1000ths of a second)
22703 // <function>: function to call
22704 // <data>: data to pass to @function
22705 // <notify>: function to call when the timeout is removed, or %NULL
22706 static uint timeout_add_full()(int priority, uint interval, SourceFunc function_, void* data, DestroyNotify notify) nothrow {
22707 return g_timeout_add_full(priority, interval, function_, data, notify);
22711 // Unintrospectable function: timeout_add_seconds() / g_timeout_add_seconds()
22712 // VERSION: 2.14
22713 // Sets a function to be called at regular intervals with the default
22714 // priority, #G_PRIORITY_DEFAULT. The function is called repeatedly until
22715 // it returns %FALSE, at which point the timeout is automatically destroyed
22716 // and the function will not be called again.
22718 // This internally creates a main loop source using
22719 // g_timeout_source_new_seconds() and attaches it to the main loop context
22720 // using g_source_attach(). You can do these steps manually if you need
22721 // greater control. Also see g_timeout_add_seconds_full().
22723 // Note that the first call of the timer may not be precise for timeouts
22724 // of one second. If you need finer precision and have such a timeout,
22725 // you may want to use g_timeout_add() instead.
22727 // The interval given is in terms of monotonic time, not wall clock
22728 // time. See g_get_monotonic_time().
22729 // RETURNS: the ID (greater than 0) of the event source.
22730 // <interval>: the time between calls to the function, in seconds
22731 // <function>: function to call
22732 // <data>: data to pass to @function
22733 static uint timeout_add_seconds()(uint interval, SourceFunc function_, void* data) nothrow {
22734 return g_timeout_add_seconds(interval, function_, data);
22738 // VERSION: 2.14
22739 // Sets a function to be called at regular intervals, with @priority.
22740 // The function is called repeatedly until it returns %FALSE, at which
22741 // point the timeout is automatically destroyed and the function will
22742 // not be called again.
22744 // Unlike g_timeout_add(), this function operates at whole second granularity.
22745 // The initial starting point of the timer is determined by the implementation
22746 // and the implementation is expected to group multiple timers together so that
22747 // they fire all at the same time.
22748 // To allow this grouping, the @interval to the first timer is rounded
22749 // and can deviate up to one second from the specified interval.
22750 // Subsequent timer iterations will generally run at the specified interval.
22752 // Note that timeout functions may be delayed, due to the processing of other
22753 // event sources. Thus they should not be relied on for precise timing.
22754 // After each call to the timeout function, the time of the next
22755 // timeout is recalculated based on the current time and the given @interval
22757 // If you want timing more precise than whole seconds, use g_timeout_add()
22758 // instead.
22760 // The grouping of timers to fire at the same time results in a more power
22761 // and CPU efficient behavior so if your timer is in multiples of seconds
22762 // and you don't require the first timer exactly one second from now, the
22763 // use of g_timeout_add_seconds() is preferred over g_timeout_add().
22765 // This internally creates a main loop source using
22766 // g_timeout_source_new_seconds() and attaches it to the main loop context
22767 // using g_source_attach(). You can do these steps manually if you need
22768 // greater control.
22770 // The interval given is in terms of monotonic time, not wall clock
22771 // time. See g_get_monotonic_time().
22772 // RETURNS: the ID (greater than 0) of the event source.
22773 // <priority>: the priority of the timeout source. Typically this will be in the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
22774 // <interval>: the time between calls to the function, in seconds
22775 // <function>: function to call
22776 // <data>: data to pass to @function
22777 // <notify>: function to call when the timeout is removed, or %NULL
22778 static uint timeout_add_seconds_full()(int priority, uint interval, SourceFunc function_, void* data, DestroyNotify notify) nothrow {
22779 return g_timeout_add_seconds_full(priority, interval, function_, data, notify);
22783 // Creates a new timeout source.
22785 // The source will not initially be associated with any #GMainContext
22786 // and must be added to one with g_source_attach() before it will be
22787 // executed.
22789 // The interval given is in terms of monotonic time, not wall clock
22790 // time. See g_get_monotonic_time().
22791 // RETURNS: the newly-created timeout source
22792 // <interval>: the timeout interval in milliseconds.
22793 static Source* /*new*/ timeout_source_new()(uint interval) nothrow {
22794 return g_timeout_source_new(interval);
22798 // VERSION: 2.14
22799 // Creates a new timeout source.
22801 // The source will not initially be associated with any #GMainContext
22802 // and must be added to one with g_source_attach() before it will be
22803 // executed.
22805 // The scheduling granularity/accuracy of this timeout source will be
22806 // in seconds.
22808 // The interval given in terms of monotonic time, not wall clock time.
22809 // See g_get_monotonic_time().
22810 // RETURNS: the newly-created timeout source
22811 // <interval>: the timeout interval in seconds
22812 static Source* /*new*/ timeout_source_new_seconds()(uint interval) nothrow {
22813 return g_timeout_source_new_seconds(interval);
22817 // MOVED TO: TrashStack.height
22818 // Returns the height of a #GTrashStack.
22820 // Note that execution of this function is of O(N) complexity
22821 // where N denotes the number of items on the stack.
22822 // RETURNS: the height of the stack
22823 // <stack_p>: a #GTrashStack
22824 static uint trash_stack_height()(TrashStack** stack_p) nothrow {
22825 return g_trash_stack_height(stack_p);
22829 // MOVED TO: TrashStack.push
22830 // Pushes a piece of memory onto a #GTrashStack.
22831 // <stack_p>: a #GTrashStack
22832 // <data_p>: the piece of memory to push on the stack
22833 static void trash_stack_push()(TrashStack** stack_p, void* data_p) nothrow {
22834 g_trash_stack_push(stack_p, data_p);
22838 // Unintrospectable function: try_malloc() / g_try_malloc()
22839 // Attempts to allocate @n_bytes, and returns %NULL on failure.
22840 // Contrast with g_malloc(), which aborts the program on failure.
22841 // RETURNS: the allocated memory, or %NULL.
22842 // <n_bytes>: number of bytes to allocate.
22843 static void* try_malloc()(size_t n_bytes) nothrow {
22844 return g_try_malloc(n_bytes);
22848 // Unintrospectable function: try_malloc0() / g_try_malloc0()
22849 // VERSION: 2.8
22850 // Attempts to allocate @n_bytes, initialized to 0's, and returns %NULL on
22851 // failure. Contrast with g_malloc0(), which aborts the program on failure.
22852 // RETURNS: the allocated memory, or %NULL
22853 // <n_bytes>: number of bytes to allocate
22854 static void* try_malloc0()(size_t n_bytes) nothrow {
22855 return g_try_malloc0(n_bytes);
22859 // Unintrospectable function: try_malloc0_n() / g_try_malloc0_n()
22860 // VERSION: 2.24
22861 // This function is similar to g_try_malloc0(), allocating (@n_blocks * @n_block_bytes) bytes,
22862 // but care is taken to detect possible overflow during multiplication.
22863 // RETURNS: the allocated memory, or %NULL
22864 // <n_blocks>: the number of blocks to allocate
22865 // <n_block_bytes>: the size of each block in bytes
22866 static void* try_malloc0_n()(size_t n_blocks, size_t n_block_bytes) nothrow {
22867 return g_try_malloc0_n(n_blocks, n_block_bytes);
22871 // Unintrospectable function: try_malloc_n() / g_try_malloc_n()
22872 // VERSION: 2.24
22873 // This function is similar to g_try_malloc(), allocating (@n_blocks * @n_block_bytes) bytes,
22874 // but care is taken to detect possible overflow during multiplication.
22875 // RETURNS: the allocated memory, or %NULL.
22876 // <n_blocks>: the number of blocks to allocate
22877 // <n_block_bytes>: the size of each block in bytes
22878 static void* try_malloc_n()(size_t n_blocks, size_t n_block_bytes) nothrow {
22879 return g_try_malloc_n(n_blocks, n_block_bytes);
22883 // Unintrospectable function: try_realloc() / g_try_realloc()
22884 // Attempts to realloc @mem to a new size, @n_bytes, and returns %NULL
22885 // on failure. Contrast with g_realloc(), which aborts the program
22886 // on failure. If @mem is %NULL, behaves the same as g_try_malloc().
22887 // RETURNS: the allocated memory, or %NULL.
22888 // <mem>: previously-allocated memory, or %NULL.
22889 // <n_bytes>: number of bytes to allocate.
22890 static void* try_realloc()(void* mem, size_t n_bytes) nothrow {
22891 return g_try_realloc(mem, n_bytes);
22895 // Unintrospectable function: try_realloc_n() / g_try_realloc_n()
22896 // VERSION: 2.24
22897 // This function is similar to g_try_realloc(), allocating (@n_blocks * @n_block_bytes) bytes,
22898 // but care is taken to detect possible overflow during multiplication.
22899 // RETURNS: the allocated memory, or %NULL.
22900 // <mem>: previously-allocated memory, or %NULL.
22901 // <n_blocks>: the number of blocks to allocate
22902 // <n_block_bytes>: the size of each block in bytes
22903 static void* try_realloc_n()(void* mem, size_t n_blocks, size_t n_block_bytes) nothrow {
22904 return g_try_realloc_n(mem, n_blocks, n_block_bytes);
22908 // Convert a string from UCS-4 to UTF-16. A 0 character will be
22909 // added to the result after the converted text.
22911 // This value must be freed with g_free(). If an
22912 // error occurs, %NULL will be returned and
22913 // @error set.
22914 // RETURNS: a pointer to a newly allocated UTF-16 string.
22915 // <str>: a UCS-4 encoded string
22916 // <len>: the maximum length (number of characters) of @str to use. If @len < 0, then the string is nul-terminated.
22917 // <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.
22918 // <items_written>: location to store number of <type>gunichar2</type> written, or %NULL. The value stored here does not include the trailing 0.
22919 static wchar* ucs4_to_utf16()(dchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error=null) nothrow {
22920 return g_ucs4_to_utf16(str, len, items_read, items_written, error);
22924 // Convert a string from a 32-bit fixed width representation as UCS-4.
22925 // to UTF-8. The result will be terminated with a 0 byte.
22927 // This value must be freed with g_free(). If an
22928 // error occurs, %NULL will be returned and
22929 // @error set. In that case, @items_read will be
22930 // set to the position of the first invalid input
22931 // character.
22932 // RETURNS: a pointer to a newly allocated UTF-8 string.
22933 // <str>: a UCS-4 encoded string
22934 // <len>: the maximum length (number of characters) of @str to use. If @len < 0, then the string is nul-terminated.
22935 // <items_read>: location to store number of characters read, or %NULL.
22936 // <items_written>: location to store number of bytes written or %NULL. The value here stored does not include the trailing 0 byte.
22937 static char* /*new*/ ucs4_to_utf8()(dchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error=null) nothrow {
22938 return g_ucs4_to_utf8(str, len, items_read, items_written, error);
22942 // Determines the break type of @c. @c should be a Unicode character
22943 // (to derive a character from UTF-8 encoded text, use
22944 // g_utf8_get_char()). The break type is used to find word and line
22945 // breaks ("text boundaries"), Pango implements the Unicode boundary
22946 // resolution algorithms and normally you would use a function such
22947 // as pango_break() instead of caring about break types yourself.
22948 // RETURNS: the break type of @c
22949 // <c>: a Unicode character
22950 static UnicodeBreakType unichar_break_type()(dchar c) nothrow {
22951 return g_unichar_break_type(c);
22955 // VERSION: 2.14
22956 // Determines the canonical combining class of a Unicode character.
22957 // RETURNS: the combining class of the character
22958 // <uc>: a Unicode character
22959 static int unichar_combining_class()(dchar uc) nothrow {
22960 return g_unichar_combining_class(uc);
22964 // VERSION: 2.30
22965 // Performs a single composition step of the
22966 // Unicode canonical composition algorithm.
22968 // This function includes algorithmic Hangul Jamo composition,
22969 // but it is not exactly the inverse of g_unichar_decompose().
22970 // No composition can have either of @a or @b equal to zero.
22971 // To be precise, this function composes if and only if
22972 // there exists a Primary Composite P which is canonically
22973 // equivalent to the sequence <@a,@b>. See the Unicode
22974 // Standard for the definition of Primary Composite.
22976 // If @a and @b do not compose a new character, @ch is set to zero.
22978 // See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
22979 // for details.
22980 // RETURNS: %TRUE if the characters could be composed
22981 // <a>: a Unicode character
22982 // <b>: a Unicode character
22983 // <ch>: return location for the composed character
22984 static int unichar_compose()(dchar a, dchar b, dchar* ch) nothrow {
22985 return g_unichar_compose(a, b, ch);
22989 // VERSION: 2.30
22990 // Performs a single decomposition step of the
22991 // Unicode canonical decomposition algorithm.
22993 // This function does not include compatibility
22994 // decompositions. It does, however, include algorithmic
22995 // Hangul Jamo decomposition, as well as 'singleton'
22996 // decompositions which replace a character by a single
22997 // other character. In the case of singletons *@b will
22998 // be set to zero.
23000 // If @ch is not decomposable, *@a is set to @ch and *@b
23001 // is set to zero.
23003 // Note that the way Unicode decomposition pairs are
23004 // defined, it is guaranteed that @b would not decompose
23005 // further, but @a may itself decompose. To get the full
23006 // canonical decomposition for @ch, one would need to
23007 // recursively call this function on @a. Or use
23008 // g_unichar_fully_decompose().
23010 // See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
23011 // for details.
23012 // RETURNS: %TRUE if the character could be decomposed
23013 // <ch>: a Unicode character
23014 // <a>: return location for the first component of @ch
23015 // <b>: return location for the second component of @ch
23016 static int unichar_decompose()(dchar ch, dchar* a, dchar* b) nothrow {
23017 return g_unichar_decompose(ch, a, b);
23021 // Determines the numeric value of a character as a decimal
23022 // digit.
23024 // g_unichar_isdigit()), its numeric value. Otherwise, -1.
23025 // RETURNS: If @c is a decimal digit (according to
23026 // <c>: a Unicode character
23027 static int unichar_digit_value()(dchar c) nothrow {
23028 return g_unichar_digit_value(c);
23032 // VERSION: 2.30
23033 // Computes the canonical or compatibility decomposition of a
23034 // Unicode character. For compatibility decomposition,
23035 // pass %TRUE for @compat; for canonical decomposition
23036 // pass %FALSE for @compat.
23038 // The decomposed sequence is placed in @result. Only up to
23039 // @result_len characters are written into @result. The length
23040 // of the full decomposition (irrespective of @result_len) is
23041 // returned by the function. For canonical decomposition,
23042 // currently all decompositions are of length at most 4, but
23043 // this may change in the future (very unlikely though).
23044 // At any rate, Unicode does guarantee that a buffer of length
23045 // 18 is always enough for both compatibility and canonical
23046 // decompositions, so that is the size recommended. This is provided
23047 // as %G_UNICHAR_MAX_DECOMPOSITION_LENGTH.
23049 // See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
23050 // for details.
23051 // RETURNS: the length of the full decomposition.
23052 // <ch>: a Unicode character.
23053 // <compat>: whether perform canonical or compatibility decomposition
23054 // <result>: location to store decomposed result, or %NULL
23055 // <result_len>: length of @result
23056 static size_t unichar_fully_decompose()(dchar ch, int compat, dchar* result, size_t result_len) nothrow {
23057 return g_unichar_fully_decompose(ch, compat, result, result_len);
23061 // VERSION: 2.4
23062 // In Unicode, some characters are <firstterm>mirrored</firstterm>. This
23063 // means that their images are mirrored horizontally in text that is laid
23064 // out from right to left. For instance, "(" would become its mirror image,
23065 // ")", in right-to-left text.
23067 // If @ch has the Unicode mirrored property and there is another unicode
23068 // character that typically has a glyph that is the mirror image of @ch's
23069 // glyph and @mirrored_ch is set, it puts that character in the address
23070 // pointed to by @mirrored_ch. Otherwise the original character is put.
23071 // RETURNS: %TRUE if @ch has a mirrored character, %FALSE otherwise
23072 // <ch>: a Unicode character
23073 // <mirrored_ch>: location to store the mirrored character
23074 static int unichar_get_mirror_char()(dchar ch, dchar* mirrored_ch) nothrow {
23075 return g_unichar_get_mirror_char(ch, mirrored_ch);
23079 // VERSION: 2.14
23080 // Looks up the #GUnicodeScript for a particular character (as defined
23081 // by Unicode Standard Annex \#24). No check is made for @ch being a
23082 // valid Unicode character; if you pass in invalid character, the
23083 // result is undefined.
23085 // This function is equivalent to pango_script_for_unichar() and the
23086 // two are interchangeable.
23087 // RETURNS: the #GUnicodeScript for the character.
23088 // <ch>: a Unicode character
23089 static UnicodeScript unichar_get_script()(dchar ch) nothrow {
23090 return g_unichar_get_script(ch);
23094 // Determines whether a character is alphanumeric.
23095 // Given some UTF-8 text, obtain a character value
23096 // with g_utf8_get_char().
23097 // RETURNS: %TRUE if @c is an alphanumeric character
23098 // <c>: a Unicode character
23099 static int unichar_isalnum()(dchar c) nothrow {
23100 return g_unichar_isalnum(c);
23104 // Determines whether a character is alphabetic (i.e. a letter).
23105 // Given some UTF-8 text, obtain a character value with
23106 // g_utf8_get_char().
23107 // RETURNS: %TRUE if @c is an alphabetic character
23108 // <c>: a Unicode character
23109 static int unichar_isalpha()(dchar c) nothrow {
23110 return g_unichar_isalpha(c);
23114 // Determines whether a character is a control character.
23115 // Given some UTF-8 text, obtain a character value with
23116 // g_utf8_get_char().
23117 // RETURNS: %TRUE if @c is a control character
23118 // <c>: a Unicode character
23119 static int unichar_iscntrl()(dchar c) nothrow {
23120 return g_unichar_iscntrl(c);
23124 // Determines if a given character is assigned in the Unicode
23125 // standard.
23126 // RETURNS: %TRUE if the character has an assigned value
23127 // <c>: a Unicode character
23128 static int unichar_isdefined()(dchar c) nothrow {
23129 return g_unichar_isdefined(c);
23133 // Determines whether a character is numeric (i.e. a digit). This
23134 // covers ASCII 0-9 and also digits in other languages/scripts. Given
23135 // some UTF-8 text, obtain a character value with g_utf8_get_char().
23136 // RETURNS: %TRUE if @c is a digit
23137 // <c>: a Unicode character
23138 static int unichar_isdigit()(dchar c) nothrow {
23139 return g_unichar_isdigit(c);
23143 // Determines whether a character is printable and not a space
23144 // (returns %FALSE for control characters, format characters, and
23145 // spaces). g_unichar_isprint() is similar, but returns %TRUE for
23146 // spaces. Given some UTF-8 text, obtain a character value with
23147 // g_utf8_get_char().
23148 // RETURNS: %TRUE if @c is printable unless it's a space
23149 // <c>: a Unicode character
23150 static int unichar_isgraph()(dchar c) nothrow {
23151 return g_unichar_isgraph(c);
23155 // Determines whether a character is a lowercase letter.
23156 // Given some UTF-8 text, obtain a character value with
23157 // g_utf8_get_char().
23158 // RETURNS: %TRUE if @c is a lowercase letter
23159 // <c>: a Unicode character
23160 static int unichar_islower()(dchar c) nothrow {
23161 return g_unichar_islower(c);
23165 // VERSION: 2.14
23166 // Determines whether a character is a mark (non-spacing mark,
23167 // combining mark, or enclosing mark in Unicode speak).
23168 // Given some UTF-8 text, obtain a character value
23169 // with g_utf8_get_char().
23171 // Note: in most cases where isalpha characters are allowed,
23172 // ismark characters should be allowed to as they are essential
23173 // for writing most European languages as well as many non-Latin
23174 // scripts.
23175 // RETURNS: %TRUE if @c is a mark character
23176 // <c>: a Unicode character
23177 static int unichar_ismark()(dchar c) nothrow {
23178 return g_unichar_ismark(c);
23182 // Determines whether a character is printable.
23183 // Unlike g_unichar_isgraph(), returns %TRUE for spaces.
23184 // Given some UTF-8 text, obtain a character value with
23185 // g_utf8_get_char().
23186 // RETURNS: %TRUE if @c is printable
23187 // <c>: a Unicode character
23188 static int unichar_isprint()(dchar c) nothrow {
23189 return g_unichar_isprint(c);
23193 // Determines whether a character is punctuation or a symbol.
23194 // Given some UTF-8 text, obtain a character value with
23195 // g_utf8_get_char().
23196 // RETURNS: %TRUE if @c is a punctuation or symbol character
23197 // <c>: a Unicode character
23198 static int unichar_ispunct()(dchar c) nothrow {
23199 return g_unichar_ispunct(c);
23203 // Determines whether a character is a space, tab, or line separator
23204 // (newline, carriage return, etc.). Given some UTF-8 text, obtain a
23205 // character value with g_utf8_get_char().
23207 // (Note: don't use this to do word breaking; you have to use
23208 // Pango or equivalent to get word breaking right, the algorithm
23209 // is fairly complex.)
23210 // RETURNS: %TRUE if @c is a space character
23211 // <c>: a Unicode character
23212 static int unichar_isspace()(dchar c) nothrow {
23213 return g_unichar_isspace(c);
23217 // Determines if a character is titlecase. Some characters in
23218 // Unicode which are composites, such as the DZ digraph
23219 // have three case variants instead of just two. The titlecase
23220 // form is used at the beginning of a word where only the
23221 // first letter is capitalized. The titlecase form of the DZ
23222 // digraph is U+01F2 LATIN CAPITAL LETTTER D WITH SMALL LETTER Z.
23223 // RETURNS: %TRUE if the character is titlecase
23224 // <c>: a Unicode character
23225 static int unichar_istitle()(dchar c) nothrow {
23226 return g_unichar_istitle(c);
23230 // Determines if a character is uppercase.
23231 // RETURNS: %TRUE if @c is an uppercase character
23232 // <c>: a Unicode character
23233 static int unichar_isupper()(dchar c) nothrow {
23234 return g_unichar_isupper(c);
23238 // Determines if a character is typically rendered in a double-width
23239 // cell.
23240 // RETURNS: %TRUE if the character is wide
23241 // <c>: a Unicode character
23242 static int unichar_iswide()(dchar c) nothrow {
23243 return g_unichar_iswide(c);
23247 // VERSION: 2.12
23248 // Determines if a character is typically rendered in a double-width
23249 // cell under legacy East Asian locales. If a character is wide according to
23250 // g_unichar_iswide(), then it is also reported wide with this function, but
23251 // the converse is not necessarily true. See the
23252 // <ulink url="http://www.unicode.org/reports/tr11/">Unicode Standard
23253 // Annex #11</ulink> for details.
23255 // If a character passes the g_unichar_iswide() test then it will also pass
23256 // this test, but not the other way around. Note that some characters may
23257 // pas both this test and g_unichar_iszerowidth().
23258 // RETURNS: %TRUE if the character is wide in legacy East Asian locales
23259 // <c>: a Unicode character
23260 static int unichar_iswide_cjk()(dchar c) nothrow {
23261 return g_unichar_iswide_cjk(c);
23265 // Determines if a character is a hexidecimal digit.
23266 // RETURNS: %TRUE if the character is a hexadecimal digit
23267 // <c>: a Unicode character.
23268 static int unichar_isxdigit()(dchar c) nothrow {
23269 return g_unichar_isxdigit(c);
23273 // VERSION: 2.14
23274 // Determines if a given character typically takes zero width when rendered.
23275 // The return value is %TRUE for all non-spacing and enclosing marks
23276 // (e.g., combining accents), format characters, zero-width
23277 // space, but not U+00AD SOFT HYPHEN.
23279 // A typical use of this function is with one of g_unichar_iswide() or
23280 // g_unichar_iswide_cjk() to determine the number of cells a string occupies
23281 // when displayed on a grid display (terminals). However, note that not all
23282 // terminals support zero-width rendering of zero-width marks.
23283 // RETURNS: %TRUE if the character has zero width
23284 // <c>: a Unicode character
23285 static int unichar_iszerowidth()(dchar c) nothrow {
23286 return g_unichar_iszerowidth(c);
23290 // Converts a single character to UTF-8.
23291 // RETURNS: number of bytes written
23292 // <c>: a Unicode character code
23293 // <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.
23294 static int unichar_to_utf8()(dchar c, char* outbuf) nothrow {
23295 return g_unichar_to_utf8(c, outbuf);
23299 // Converts a character to lower case.
23301 // If @c is not an upperlower or titlecase character,
23302 // or has no lowercase equivalent @c is returned unchanged.
23303 // RETURNS: the result of converting @c to lower case.
23304 // <c>: a Unicode character.
23305 static dchar unichar_tolower()(dchar c) nothrow {
23306 return g_unichar_tolower(c);
23310 // Converts a character to the titlecase.
23312 // If @c is not an uppercase or lowercase character,
23313 // @c is returned unchanged.
23314 // RETURNS: the result of converting @c to titlecase.
23315 // <c>: a Unicode character
23316 static dchar unichar_totitle()(dchar c) nothrow {
23317 return g_unichar_totitle(c);
23321 // Converts a character to uppercase.
23323 // If @c is not an lowercase or titlecase character,
23324 // or has no upper case equivalent @c is returned unchanged.
23325 // RETURNS: the result of converting @c to uppercase.
23326 // <c>: a Unicode character
23327 static dchar unichar_toupper()(dchar c) nothrow {
23328 return g_unichar_toupper(c);
23332 // Classifies a Unicode character by type.
23333 // RETURNS: the type of the character.
23334 // <c>: a Unicode character
23335 static UnicodeType unichar_type()(dchar c) nothrow {
23336 return g_unichar_type(c);
23340 // Checks whether @ch is a valid Unicode character. Some possible
23341 // integer values of @ch will not be valid. 0 is considered a valid
23342 // character, though it's normally a string terminator.
23343 // RETURNS: %TRUE if @ch is a valid Unicode character
23344 // <ch>: a Unicode character
23345 static int unichar_validate()(dchar ch) nothrow {
23346 return g_unichar_validate(ch);
23350 // Determines the numeric value of a character as a hexidecimal
23351 // digit.
23353 // g_unichar_isxdigit()), its numeric value. Otherwise, -1.
23354 // RETURNS: If @c is a hex digit (according to
23355 // <c>: a Unicode character
23356 static int unichar_xdigit_value()(dchar c) nothrow {
23357 return g_unichar_xdigit_value(c);
23361 // DEPRECATED (v2.30) function: unicode_canonical_decomposition - Use the more flexible g_unichar_fully_decompose()
23362 // Computes the canonical decomposition of a Unicode character.
23364 // @result_len is set to the resulting length of the string.
23366 // instead.
23367 // RETURNS: a newly allocated string of Unicode characters.
23368 // <ch>: a Unicode character.
23369 // <result_len>: location to store the length of the return value.
23370 static dchar* unicode_canonical_decomposition()(dchar ch, size_t* result_len) nothrow {
23371 return g_unicode_canonical_decomposition(ch, result_len);
23375 // Computes the canonical ordering of a string in-place.
23376 // This rearranges decomposed characters in the string
23377 // according to their combining classes. See the Unicode
23378 // manual for more information.
23379 // <string>: a UCS-4 encoded string.
23380 // <len>: the maximum length of @string to use.
23381 static void unicode_canonical_ordering()(dchar* string_, size_t len) nothrow {
23382 g_unicode_canonical_ordering(string_, len);
23386 // VERSION: 2.30
23387 // Looks up the Unicode script for @iso15924. ISO 15924 assigns four-letter
23388 // codes to scripts. For example, the code for Arabic is 'Arab'.
23389 // This function accepts four letter codes encoded as a @guint32 in a
23390 // big-endian fashion. That is, the code expected for Arabic is
23391 // 0x41726162 (0x41 is ASCII code for 'A', 0x72 is ASCII code for 'r', etc).
23393 // See <ulink url="http://unicode.org/iso15924/codelists.html">Codes for the
23394 // representation of names of scripts</ulink> for details.
23396 // of %G_UNICODE_SCRIPT_INVALID_CODE if @iso15924 is zero and
23397 // %G_UNICODE_SCRIPT_UNKNOWN if @iso15924 is unknown.
23398 // RETURNS: the Unicode script for @iso15924, or
23399 // <iso15924>: a Unicode script
23400 static UnicodeScript unicode_script_from_iso15924()(uint iso15924) nothrow {
23401 return g_unicode_script_from_iso15924(iso15924);
23405 // VERSION: 2.30
23406 // Looks up the ISO 15924 code for @script. ISO 15924 assigns four-letter
23407 // codes to scripts. For example, the code for Arabic is 'Arab'. The
23408 // four letter codes are encoded as a @guint32 by this function in a
23409 // big-endian fashion. That is, the code returned for Arabic is
23410 // 0x41726162 (0x41 is ASCII code for 'A', 0x72 is ASCII code for 'r', etc).
23412 // See <ulink url="http://unicode.org/iso15924/codelists.html">Codes for the
23413 // representation of names of scripts</ulink> for details.
23415 // of zero if @script is %G_UNICODE_SCRIPT_INVALID_CODE or
23416 // ISO 15924 code 'Zzzz' (script code for UNKNOWN) if @script is not understood.
23417 // RETURNS: the ISO 15924 code for @script, encoded as an integer,
23418 // <script>: a Unicode script
23419 static uint unicode_script_to_iso15924()(UnicodeScript script) nothrow {
23420 return g_unicode_script_to_iso15924(script);
23424 // VERSION: 2.6
23425 // A wrapper for the POSIX unlink() function. The unlink() function
23426 // deletes a name from the filesystem. If this was the last link to the
23427 // file and no processes have it opened, the diskspace occupied by the
23428 // file is freed.
23430 // See your C library manual for more details about unlink(). Note
23431 // that on Windows, it is in general not possible to delete files that
23432 // are open to some process, or mapped into memory.
23434 // occurred
23435 // RETURNS: 0 if the name was successfully deleted, -1 if an error
23436 // <filename>: a pathname in the GLib file name encoding (UTF-8 on Windows)
23437 static int unlink()(char* filename) nothrow {
23438 return g_unlink(filename);
23442 // VERSION: 2.4
23443 // Removes an environment variable from the environment.
23445 // Note that on some systems, when variables are overwritten, the
23446 // memory used for the previous variables and its value isn't reclaimed.
23448 // <warning><para>
23449 // Environment variable handling in UNIX is not thread-safe, and your
23450 // program may crash if one thread calls g_unsetenv() while another
23451 // thread is calling getenv(). (And note that many functions, such as
23452 // gettext(), call getenv() internally.) This function is only safe
23453 // to use at the very start of your program, before creating any other
23454 // threads (or creating objects that create worker threads of their
23455 // own).
23456 // </para><para>
23457 // If you need to set up the environment for a child process, you can
23458 // use g_get_environ() to get an environment array, modify that with
23459 // g_environ_setenv() and g_environ_unsetenv(), and then pass that
23460 // array directly to execvpe(), g_spawn_async(), or the like.
23461 // </para></warning>
23462 // <variable>: the environment variable to remove, must not contain '='
23463 static void unsetenv()(char* variable) nothrow {
23464 g_unsetenv(variable);
23468 // VERSION: 2.16
23469 // Escapes a string for use in a URI.
23471 // Normally all characters that are not "unreserved" (i.e. ASCII alphanumerical
23472 // characters plus dash, dot, underscore and tilde) are escaped.
23473 // But if you specify characters in @reserved_chars_allowed they are not
23474 // escaped. This is useful for the "reserved" characters in the URI
23475 // specification, since those are allowed unescaped in some portions of
23476 // a URI.
23478 // freed when no longer needed.
23479 // RETURNS: an escaped version of @unescaped. The returned string should be
23480 // <unescaped>: the unescaped input string.
23481 // <reserved_chars_allowed>: a string of reserved characters that are allowed to be used, or %NULL.
23482 // <allow_utf8>: %TRUE if the result can include UTF-8 characters.
23483 static char* /*new*/ uri_escape_string()(char* unescaped, char* reserved_chars_allowed, int allow_utf8) nothrow {
23484 return g_uri_escape_string(unescaped, reserved_chars_allowed, allow_utf8);
23488 // Unintrospectable function: uri_list_extract_uris() / g_uri_list_extract_uris()
23489 // VERSION: 2.6
23490 // Splits an URI list conforming to the text/uri-list
23491 // mime type defined in RFC 2483 into individual URIs,
23492 // discarding any comments. The URIs are not validated.
23494 // strings holding the individual URIs. The array should
23495 // be freed with g_strfreev().
23496 // RETURNS: a newly allocated %NULL-terminated list of
23497 // <uri_list>: an URI list
23498 static char** uri_list_extract_uris()(char* uri_list) nothrow {
23499 return g_uri_list_extract_uris(uri_list);
23503 // VERSION: 2.16
23504 // Gets the scheme portion of a URI string. RFC 3986 decodes the scheme as:
23505 // <programlisting>
23506 // URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
23507 // </programlisting>
23508 // Common schemes include "file", "http", "svn+ssh", etc.
23510 // The returned string should be freed when no longer needed.
23511 // RETURNS: The "Scheme" component of the URI, or %NULL on error.
23512 // <uri>: a valid URI.
23513 static char* /*new*/ uri_parse_scheme()(char* uri) nothrow {
23514 return g_uri_parse_scheme(uri);
23518 // VERSION: 2.16
23519 // Unescapes a segment of an escaped string.
23521 // If any of the characters in @illegal_characters or the character zero appears
23522 // as an escaped character in @escaped_string then that is an error and %NULL
23523 // will be returned. This is useful it you want to avoid for instance having a
23524 // slash being expanded in an escaped path element, which might confuse pathname
23525 // handling.
23527 // The returned string should be freed when no longer needed.
23528 // RETURNS: an unescaped version of @escaped_string or %NULL on error.
23529 // <escaped_string>: a string.
23530 // <escaped_string_end>: a string.
23531 // <illegal_characters>: an optional string of illegal characters not to be allowed.
23532 static char* /*new*/ uri_unescape_segment()(char* escaped_string, char* escaped_string_end, char* illegal_characters) nothrow {
23533 return g_uri_unescape_segment(escaped_string, escaped_string_end, illegal_characters);
23537 // VERSION: 2.16
23538 // Unescapes a whole escaped string.
23540 // If any of the characters in @illegal_characters or the character zero appears
23541 // as an escaped character in @escaped_string then that is an error and %NULL
23542 // will be returned. This is useful it you want to avoid for instance having a
23543 // slash being expanded in an escaped path element, which might confuse pathname
23544 // handling.
23546 // should be freed when no longer needed.
23547 // RETURNS: an unescaped version of @escaped_string. The returned string
23548 // <escaped_string>: an escaped string to be unescaped.
23549 // <illegal_characters>: an optional string of illegal characters not to be allowed.
23550 static char* /*new*/ uri_unescape_string()(char* escaped_string, char* illegal_characters) nothrow {
23551 return g_uri_unescape_string(escaped_string, illegal_characters);
23555 // Pauses the current thread for the given number of microseconds.
23557 // There are 1 million microseconds per second (represented by the
23558 // #G_USEC_PER_SEC macro). g_usleep() may have limited precision,
23559 // depending on hardware and operating system; don't rely on the exact
23560 // length of the sleep.
23561 // <microseconds>: number of microseconds to pause
23562 static void usleep()(c_ulong microseconds) nothrow {
23563 g_usleep(microseconds);
23567 // Convert a string from UTF-16 to UCS-4. The result will be
23568 // nul-terminated.
23570 // This value must be freed with g_free(). If an
23571 // error occurs, %NULL will be returned and
23572 // @error set.
23573 // RETURNS: a pointer to a newly allocated UCS-4 string.
23574 // <str>: a UTF-16 encoded string
23575 // <len>: the maximum length (number of <type>gunichar2</type>) of @str to use. If @len < 0, then the string is nul-terminated.
23576 // <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.
23577 // <items_written>: location to store number of characters written, or %NULL. The value stored here does not include the trailing 0 character.
23578 static dchar* utf16_to_ucs4()(wchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error=null) nothrow {
23579 return g_utf16_to_ucs4(str, len, items_read, items_written, error);
23583 // Convert a string from UTF-16 to UTF-8. The result will be
23584 // terminated with a 0 byte.
23586 // Note that the input is expected to be already in native endianness,
23587 // an initial byte-order-mark character is not handled specially.
23588 // g_convert() can be used to convert a byte buffer of UTF-16 data of
23589 // ambiguous endianess.
23591 // Further note that this function does not validate the result
23592 // string; it may e.g. include embedded NUL characters. The only
23593 // validation done by this function is to ensure that the input can
23594 // be correctly interpreted as UTF-16, i.e. it doesn't contain
23595 // things unpaired surrogates.
23597 // This value must be freed with g_free(). If an
23598 // error occurs, %NULL will be returned and
23599 // @error set.
23600 // RETURNS: a pointer to a newly allocated UTF-8 string.
23601 // <str>: a UTF-16 encoded string
23602 // <len>: the maximum length (number of <type>gunichar2</type>) of @str to use. If @len < 0, then the string is nul-terminated.
23603 // <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.
23604 // <items_written>: location to store number of bytes written, or %NULL. The value stored here does not include the trailing 0 byte.
23605 static char* /*new*/ utf16_to_utf8()(wchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error=null) nothrow {
23606 return g_utf16_to_utf8(str, len, items_read, items_written, error);
23610 // Converts a string into a form that is independent of case. The
23611 // result will not correspond to any particular case, but can be
23612 // compared for equality or ordered with the results of calling
23613 // g_utf8_casefold() on other strings.
23615 // Note that calling g_utf8_casefold() followed by g_utf8_collate() is
23616 // only an approximation to the correct linguistic case insensitive
23617 // ordering, though it is a fairly good one. Getting this exactly
23618 // right would require a more sophisticated collation function that
23619 // takes case sensitivity into account. GLib does not currently
23620 // provide such a function.
23622 // case independent form of @str.
23623 // RETURNS: a newly allocated string, that is a
23624 // <str>: a UTF-8 encoded string
23625 // <len>: length of @str, in bytes, or -1 if @str is nul-terminated.
23626 static char* /*new*/ utf8_casefold()(char* str, ssize_t len) nothrow {
23627 return g_utf8_casefold(str, len);
23631 // Compares two strings for ordering using the linguistically
23632 // correct rules for the <link linkend="setlocale">current locale</link>.
23633 // When sorting a large number of strings, it will be significantly
23634 // faster to obtain collation keys with g_utf8_collate_key() and
23635 // compare the keys with strcmp() when sorting instead of sorting
23636 // the original strings.
23638 // 0 if they compare equal, &gt; 0 if @str1 compares after @str2.
23639 // RETURNS: &lt; 0 if @str1 compares before @str2,
23640 // <str1>: a UTF-8 encoded string
23641 // <str2>: a UTF-8 encoded string
23642 static int utf8_collate()(char* str1, char* str2) nothrow {
23643 return g_utf8_collate(str1, str2);
23647 // Converts a string into a collation key that can be compared
23648 // with other collation keys produced by the same function using
23649 // strcmp().
23651 // The results of comparing the collation keys of two strings
23652 // with strcmp() will always be the same as comparing the two
23653 // original keys with g_utf8_collate().
23655 // Note that this function depends on the
23656 // <link linkend="setlocale">current locale</link>.
23658 // be freed with g_free() when you are done with it.
23659 // RETURNS: a newly allocated string. This string should
23660 // <str>: a UTF-8 encoded string.
23661 // <len>: length of @str, in bytes, or -1 if @str is nul-terminated.
23662 static char* /*new*/ utf8_collate_key()(char* str, ssize_t len) nothrow {
23663 return g_utf8_collate_key(str, len);
23667 // VERSION: 2.8
23668 // Converts a string into a collation key that can be compared
23669 // with other collation keys produced by the same function using strcmp().
23671 // In order to sort filenames correctly, this function treats the dot '.'
23672 // as a special case. Most dictionary orderings seem to consider it
23673 // insignificant, thus producing the ordering "event.c" "eventgenerator.c"
23674 // "event.h" instead of "event.c" "event.h" "eventgenerator.c". Also, we
23675 // would like to treat numbers intelligently so that "file1" "file10" "file5"
23676 // is sorted as "file1" "file5" "file10".
23678 // Note that this function depends on the
23679 // <link linkend="setlocale">current locale</link>.
23681 // be freed with g_free() when you are done with it.
23682 // RETURNS: a newly allocated string. This string should
23683 // <str>: a UTF-8 encoded string.
23684 // <len>: length of @str, in bytes, or -1 if @str is nul-terminated.
23685 static char* /*new*/ utf8_collate_key_for_filename()(char* str, ssize_t len) nothrow {
23686 return g_utf8_collate_key_for_filename(str, len);
23690 // Finds the start of the next UTF-8 character in the string after @p.
23692 // @p does not have to be at the beginning of a UTF-8 character. No check
23693 // is made to see if the character found is actually valid other than
23694 // it starts with an appropriate byte.
23695 // RETURNS: a pointer to the found character or %NULL
23696 // <p>: a pointer to a position within a UTF-8 encoded string
23697 // <end>: a pointer to the byte following the end of the string, or %NULL to indicate that the string is nul-terminated.
23698 static char* /*new*/ utf8_find_next_char()(char* p, char* end) nothrow {
23699 return g_utf8_find_next_char(p, end);
23703 // Given a position @p with a UTF-8 encoded string @str, find the start
23704 // of the previous UTF-8 character starting before @p. Returns %NULL if no
23705 // UTF-8 characters are present in @str before @p.
23707 // @p does not have to be at the beginning of a UTF-8 character. No check
23708 // is made to see if the character found is actually valid other than
23709 // it starts with an appropriate byte.
23710 // RETURNS: a pointer to the found character or %NULL.
23711 // <str>: pointer to the beginning of a UTF-8 encoded string
23712 // <p>: pointer to some position within @str
23713 static char* /*new*/ utf8_find_prev_char()(char* str, char* p) nothrow {
23714 return g_utf8_find_prev_char(str, p);
23718 // Converts a sequence of bytes encoded as UTF-8 to a Unicode character.
23719 // If @p does not point to a valid UTF-8 encoded character, results are
23720 // undefined. If you are not sure that the bytes are complete
23721 // valid Unicode characters, you should use g_utf8_get_char_validated()
23722 // instead.
23723 // RETURNS: the resulting character
23724 // <p>: a pointer to Unicode character encoded as UTF-8
23725 static dchar utf8_get_char()(char* p) nothrow {
23726 return g_utf8_get_char(p);
23730 // Convert a sequence of bytes encoded as UTF-8 to a Unicode character.
23731 // This function checks for incomplete characters, for invalid characters
23732 // such as characters that are out of the range of Unicode, and for
23733 // overlong encodings of valid characters.
23735 // sequence at the end of a string that could begin a valid
23736 // character (or if @max_len is zero), returns (gunichar)-2;
23737 // otherwise, if @p does not point to a valid UTF-8 encoded
23738 // Unicode character, returns (gunichar)-1.
23739 // RETURNS: the resulting character. If @p points to a partial
23740 // <p>: a pointer to Unicode character encoded as UTF-8
23741 // <max_len>: the maximum number of bytes to read, or -1, for no maximum or if @p is nul-terminated
23742 static dchar utf8_get_char_validated()(char* p, ssize_t max_len) nothrow {
23743 return g_utf8_get_char_validated(p, max_len);
23747 // Converts a string into canonical form, standardizing
23748 // such issues as whether a character with an accent
23749 // is represented as a base character and combining
23750 // accent or as a single precomposed character. The
23751 // string has to be valid UTF-8, otherwise %NULL is
23752 // returned. You should generally call g_utf8_normalize()
23753 // before comparing two Unicode strings.
23755 // The normalization mode %G_NORMALIZE_DEFAULT only
23756 // standardizes differences that do not affect the
23757 // text content, such as the above-mentioned accent
23758 // representation. %G_NORMALIZE_ALL also standardizes
23759 // the "compatibility" characters in Unicode, such
23760 // as SUPERSCRIPT THREE to the standard forms
23761 // (in this case DIGIT THREE). Formatting information
23762 // may be lost but for most text operations such
23763 // characters should be considered the same.
23765 // %G_NORMALIZE_DEFAULT_COMPOSE and %G_NORMALIZE_ALL_COMPOSE
23766 // are like %G_NORMALIZE_DEFAULT and %G_NORMALIZE_ALL,
23767 // but returned a result with composed forms rather
23768 // than a maximally decomposed form. This is often
23769 // useful if you intend to convert the string to
23770 // a legacy encoding or pass it to a system with
23771 // less capable Unicode handling.
23773 // normalized form of @str, or %NULL if @str is not
23774 // valid UTF-8.
23775 // RETURNS: a newly allocated string, that is the
23776 // <str>: a UTF-8 encoded string.
23777 // <len>: length of @str, in bytes, or -1 if @str is nul-terminated.
23778 // <mode>: the type of normalization to perform.
23779 static char* /*new*/ utf8_normalize()(char* str, ssize_t len, NormalizeMode mode) nothrow {
23780 return g_utf8_normalize(str, len, mode);
23784 // Converts from an integer character offset to a pointer to a position
23785 // within the string.
23787 // Since 2.10, this function allows to pass a negative @offset to
23788 // step backwards. It is usually worth stepping backwards from the end
23789 // instead of forwards if @offset is in the last fourth of the string,
23790 // since moving forward is about 3 times faster than moving backward.
23792 // <note><para>
23793 // This function doesn't abort when reaching the end of @str. Therefore
23794 // you should be sure that @offset is within string boundaries before
23795 // calling that function. Call g_utf8_strlen() when unsure.
23797 // This limitation exists as this function is called frequently during
23798 // text rendering and therefore has to be as fast as possible.
23799 // </para></note>
23800 // RETURNS: the resulting pointer
23801 // <str>: a UTF-8 encoded string
23802 // <offset>: a character offset within @str
23803 static char* /*new*/ utf8_offset_to_pointer()(char* str, c_long offset) nothrow {
23804 return g_utf8_offset_to_pointer(str, offset);
23808 // Converts from a pointer to position within a string to a integer
23809 // character offset.
23811 // Since 2.10, this function allows @pos to be before @str, and returns
23812 // a negative offset in this case.
23813 // RETURNS: the resulting character offset
23814 // <str>: a UTF-8 encoded string
23815 // <pos>: a pointer to a position within @str
23816 static c_long utf8_pointer_to_offset()(char* str, char* pos) nothrow {
23817 return g_utf8_pointer_to_offset(str, pos);
23821 // Finds the previous UTF-8 character in the string before @p.
23823 // @p does not have to be at the beginning of a UTF-8 character. No check
23824 // is made to see if the character found is actually valid other than
23825 // it starts with an appropriate byte. If @p might be the first
23826 // character of the string, you must use g_utf8_find_prev_char() instead.
23827 // RETURNS: a pointer to the found character.
23828 // <p>: a pointer to a position within a UTF-8 encoded string
23829 static char* /*new*/ utf8_prev_char()(char* p) nothrow {
23830 return g_utf8_prev_char(p);
23834 // Finds the leftmost occurrence of the given Unicode character
23835 // in a UTF-8 encoded string, while limiting the search to @len bytes.
23836 // If @len is -1, allow unbounded search.
23838 // otherwise, a pointer to the start of the leftmost occurrence of
23839 // the character in the string.
23840 // RETURNS: %NULL if the string does not contain the character,
23841 // <p>: a nul-terminated UTF-8 encoded string
23842 // <len>: the maximum length of @p
23843 // <c>: a Unicode character
23844 static char* /*new*/ utf8_strchr()(char* p, ssize_t len, dchar c) nothrow {
23845 return g_utf8_strchr(p, len, c);
23849 // Converts all Unicode characters in the string that have a case
23850 // to lowercase. The exact manner that this is done depends
23851 // on the current locale, and may result in the number of
23852 // characters in the string changing.
23854 // converted to lowercase.
23855 // RETURNS: a newly allocated string, with all characters
23856 // <str>: a UTF-8 encoded string
23857 // <len>: length of @str, in bytes, or -1 if @str is nul-terminated.
23858 static char* /*new*/ utf8_strdown()(char* str, ssize_t len) nothrow {
23859 return g_utf8_strdown(str, len);
23863 // Computes the length of the string in characters, not including
23864 // the terminating nul character. If the @max'th byte falls in the
23865 // middle of a character, the last (partial) character is not counted.
23866 // RETURNS: the length of the string in characters
23867 // <p>: pointer to the start of a UTF-8 encoded string
23868 // <max>: the maximum number of bytes to examine. If @max is less than 0, then the string is assumed to be nul-terminated. If @max is 0, @p will not be examined and may be %NULL. If @max is greater than 0, up to @max bytes are examined
23869 static c_long utf8_strlen()(char* p, ssize_t max) nothrow {
23870 return g_utf8_strlen(p, max);
23874 // Like the standard C strncpy() function, but
23875 // copies a given number of characters instead of a given number of
23876 // bytes. The @src string must be valid UTF-8 encoded text.
23877 // (Use g_utf8_validate() on all text before trying to use UTF-8
23878 // utility functions with it.)
23879 // RETURNS: @dest
23880 // <dest>: buffer to fill with characters from @src
23881 // <src>: UTF-8 encoded string
23882 // <n>: character count
23883 static char* /*new*/ utf8_strncpy()(char* dest, char* src, size_t n) nothrow {
23884 return g_utf8_strncpy(dest, src, n);
23888 // Find the rightmost occurrence of the given Unicode character
23889 // in a UTF-8 encoded string, while limiting the search to @len bytes.
23890 // If @len is -1, allow unbounded search.
23892 // otherwise, a pointer to the start of the rightmost occurrence of the
23893 // character in the string.
23894 // RETURNS: %NULL if the string does not contain the character,
23895 // <p>: a nul-terminated UTF-8 encoded string
23896 // <len>: the maximum length of @p
23897 // <c>: a Unicode character
23898 static char* /*new*/ utf8_strrchr()(char* p, ssize_t len, dchar c) nothrow {
23899 return g_utf8_strrchr(p, len, c);
23903 // VERSION: 2.2
23904 // Reverses a UTF-8 string. @str must be valid UTF-8 encoded text.
23905 // (Use g_utf8_validate() on all text before trying to use UTF-8
23906 // utility functions with it.)
23908 // This function is intended for programmatic uses of reversed strings.
23909 // It pays no attention to decomposed characters, combining marks, byte
23910 // order marks, directional indicators (LRM, LRO, etc) and similar
23911 // characters which might need special handling when reversing a string
23912 // for display purposes.
23914 // Note that unlike g_strreverse(), this function returns
23915 // newly-allocated memory, which should be freed with g_free() when
23916 // no longer needed.
23917 // RETURNS: a newly-allocated string which is the reverse of @str.
23918 // <str>: a UTF-8 encoded string
23919 // <len>: the maximum length of @str to use, in bytes. If @len < 0, then the string is nul-terminated.
23920 static char* /*new*/ utf8_strreverse()(char* str, ssize_t len) nothrow {
23921 return g_utf8_strreverse(str, len);
23925 // Converts all Unicode characters in the string that have a case
23926 // to uppercase. The exact manner that this is done depends
23927 // on the current locale, and may result in the number of
23928 // characters in the string increasing. (For instance, the
23929 // German ess-zet will be changed to SS.)
23931 // converted to uppercase.
23932 // RETURNS: a newly allocated string, with all characters
23933 // <str>: a UTF-8 encoded string
23934 // <len>: length of @str, in bytes, or -1 if @str is nul-terminated.
23935 static char* /*new*/ utf8_strup()(char* str, ssize_t len) nothrow {
23936 return g_utf8_strup(str, len);
23940 // VERSION: 2.30
23941 // Copies a substring out of a UTF-8 encoded string.
23942 // The substring will contain @end_pos - @start_pos
23943 // characters.
23945 // substring. Free with g_free() when no longer needed.
23946 // RETURNS: a newly allocated copy of the requested
23947 // <str>: a UTF-8 encoded string
23948 // <start_pos>: a character offset within @str
23949 // <end_pos>: another character offset within @str
23950 static char* /*new*/ utf8_substring()(char* str, c_long start_pos, c_long end_pos) nothrow {
23951 return g_utf8_substring(str, start_pos, end_pos);
23955 // Convert a string from UTF-8 to a 32-bit fixed width
23956 // representation as UCS-4. A trailing 0 character will be added to the
23957 // string after the converted text.
23959 // This value must be freed with g_free(). If an
23960 // error occurs, %NULL will be returned and
23961 // @error set.
23962 // RETURNS: a pointer to a newly allocated UCS-4 string.
23963 // <str>: a UTF-8 encoded string
23964 // <len>: the maximum length of @str to use, in bytes. If @len < 0, then the string is nul-terminated.
23965 // <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.
23966 // <items_written>: location to store number of characters written or %NULL. The value here stored does not include the trailing 0 character.
23967 static dchar* utf8_to_ucs4()(char* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error=null) nothrow {
23968 return g_utf8_to_ucs4(str, len, items_read, items_written, error);
23972 // Convert a string from UTF-8 to a 32-bit fixed width
23973 // representation as UCS-4, assuming valid UTF-8 input.
23974 // This function is roughly twice as fast as g_utf8_to_ucs4()
23975 // but does no error checking on the input. A trailing 0 character
23976 // will be added to the string after the converted text.
23978 // This value must be freed with g_free().
23979 // RETURNS: a pointer to a newly allocated UCS-4 string.
23980 // <str>: a UTF-8 encoded string
23981 // <len>: the maximum length of @str to use, in bytes. If @len < 0, then the string is nul-terminated.
23982 // <items_written>: location to store the number of characters in the result, or %NULL.
23983 static dchar* utf8_to_ucs4_fast()(char* str, c_long len, c_long* items_written) nothrow {
23984 return g_utf8_to_ucs4_fast(str, len, items_written);
23988 // Convert a string from UTF-8 to UTF-16. A 0 character will be
23989 // added to the result after the converted text.
23991 // This value must be freed with g_free(). If an
23992 // error occurs, %NULL will be returned and
23993 // @error set.
23994 // RETURNS: a pointer to a newly allocated UTF-16 string.
23995 // <str>: a UTF-8 encoded string
23996 // <len>: the maximum length (number of bytes) of @str to use. If @len < 0, then the string is nul-terminated.
23997 // <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.
23998 // <items_written>: location to store number of <type>gunichar2</type> written, or %NULL. The value stored here does not include the trailing 0.
23999 static wchar* utf8_to_utf16()(char* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error=null) nothrow {
24000 return g_utf8_to_utf16(str, len, items_read, items_written, error);
24004 // Validates UTF-8 encoded text. @str is the text to validate;
24005 // if @str is nul-terminated, then @max_len can be -1, otherwise
24006 // @max_len should be the number of bytes to validate.
24007 // If @end is non-%NULL, then the end of the valid range
24008 // will be stored there (i.e. the start of the first invalid
24009 // character if some bytes were invalid, or the end of the text
24010 // being validated otherwise).
24012 // Note that g_utf8_validate() returns %FALSE if @max_len is
24013 // positive and any of the @max_len bytes are NUL.
24015 // Returns %TRUE if all of @str was valid. Many GLib and GTK+
24016 // routines <emphasis>require</emphasis> valid UTF-8 as input;
24017 // so data read from a file or the network should be checked
24018 // with g_utf8_validate() before doing anything else with it.
24019 // RETURNS: %TRUE if the text was valid UTF-8
24020 // <str>: a pointer to character data
24021 // <max_len>: max bytes to validate, or -1 to go until NUL
24022 // <end>: return location for end of valid data
24023 static int utf8_validate()(char* str, ssize_t max_len, /*out*/ char** end=null) nothrow {
24024 return g_utf8_validate(str, max_len, end);
24027 static Type variant_get_gtype()() nothrow {
24028 return g_variant_get_gtype();
24032 // VERSION: 2.24
24033 // Determines the type of @value.
24035 // The return value is valid for the lifetime of @value and must not
24036 // be freed.
24037 // RETURNS: a #GVariantType
24038 // <value>: a #GVariant
24039 static VariantType* variant_get_type()(Variant* value) nothrow {
24040 return g_variant_get_type(value);
24044 // VERSION: 2.24
24045 // MOVED TO: Variant.is_object_path
24046 // Determines if a given string is a valid D-Bus object path. You
24047 // should ensure that a string is a valid D-Bus object path before
24048 // passing it to g_variant_new_object_path().
24050 // A valid object path starts with '/' followed by zero or more
24051 // sequences of characters separated by '/' characters. Each sequence
24052 // must contain only the characters "[A-Z][a-z][0-9]_". No sequence
24053 // (including the one following the final '/' character) may be empty.
24054 // RETURNS: %TRUE if @string is a D-Bus object path
24055 // <string>: a normal C nul-terminated string
24056 static int variant_is_object_path()(char* string_) nothrow {
24057 return g_variant_is_object_path(string_);
24061 // VERSION: 2.24
24062 // MOVED TO: Variant.is_signature
24063 // Determines if a given string is a valid D-Bus type signature. You
24064 // should ensure that a string is a valid D-Bus type signature before
24065 // passing it to g_variant_new_signature().
24067 // D-Bus type signatures consist of zero or more definite #GVariantType
24068 // strings in sequence.
24069 // RETURNS: %TRUE if @string is a D-Bus type signature
24070 // <string>: a normal C nul-terminated string
24071 static int variant_is_signature()(char* string_) nothrow {
24072 return g_variant_is_signature(string_);
24076 // MOVED TO: Variant.parse
24077 // Parses a #GVariant from a text representation.
24079 // A single #GVariant is parsed from the content of @text.
24081 // The format is described <link linkend='gvariant-text'>here</link>.
24083 // The memory at @limit will never be accessed and the parser behaves as
24084 // if the character at @limit is the nul terminator. This has the
24085 // effect of bounding @text.
24087 // If @endptr is non-%NULL then @text is permitted to contain data
24088 // following the value that this function parses and @endptr will be
24089 // updated to point to the first character past the end of the text
24090 // parsed by this function. If @endptr is %NULL and there is extra data
24091 // then an error is returned.
24093 // If @type is non-%NULL then the value will be parsed to have that
24094 // type. This may result in additional parse errors (in the case that
24095 // the parsed value doesn't fit the type) but may also result in fewer
24096 // errors (in the case that the type would have been ambiguous, such as
24097 // with empty arrays).
24099 // In the event that the parsing is successful, the resulting #GVariant
24100 // is returned.
24102 // In case of any error, %NULL will be returned. If @error is non-%NULL
24103 // then it will be set to reflect the error that occurred.
24105 // Officially, the language understood by the parser is "any string
24106 // produced by g_variant_print()".
24107 // <type>: a #GVariantType, or %NULL
24108 // <text>: a string containing a GVariant in text form
24109 // <limit>: a pointer to the end of @text, or %NULL
24110 // <endptr>: a location to store the end pointer, or %NULL
24111 static Variant* /*new*/ variant_parse()(VariantType* type, char* text, char* limit, char** endptr, GLib2.Error** error=null) nothrow {
24112 return g_variant_parse(type, text, limit, endptr, error);
24115 // MOVED TO: Variant.parser_get_error_quark
24116 static Quark variant_parser_get_error_quark()() nothrow {
24117 return g_variant_parser_get_error_quark();
24120 // MOVED TO: VariantType.checked_
24121 static VariantType* variant_type_checked_()(char* arg_a) nothrow {
24122 return g_variant_type_checked_(arg_a);
24126 // MOVED TO: VariantType.string_is_valid
24127 // Checks if @type_string is a valid GVariant type string. This call is
24128 // equivalent to calling g_variant_type_string_scan() and confirming
24129 // that the following character is a nul terminator.
24132 // Since 2.24
24133 // RETURNS: %TRUE if @type_string is exactly one valid type string
24134 // <type_string>: a pointer to any string
24135 static int variant_type_string_is_valid()(char* type_string) nothrow {
24136 return g_variant_type_string_is_valid(type_string);
24140 // VERSION: 2.24
24141 // MOVED TO: VariantType.string_scan
24142 // Scan for a single complete and valid GVariant type string in @string.
24143 // The memory pointed to by @limit (or bytes beyond it) is never
24144 // accessed.
24146 // If a valid type string is found, @endptr is updated to point to the
24147 // first character past the end of the string that was found and %TRUE
24148 // is returned.
24150 // If there is no valid type string starting at @string, or if the type
24151 // string does not end before @limit then %FALSE is returned.
24153 // For the simple case of checking if a string is a valid type string,
24154 // see g_variant_type_string_is_valid().
24155 // RETURNS: %TRUE if a valid type string was found
24156 // <string>: a pointer to any string
24157 // <limit>: the end of @string, or %NULL
24158 // <endptr>: location to store the end pointer, or %NULL
24159 static int variant_type_string_scan()(char* string_, char* limit=null, /*out*/ char** endptr=null) nothrow {
24160 return g_variant_type_string_scan(string_, limit, endptr);
24164 // Unintrospectable function: vasprintf() / g_vasprintf()
24165 // VERSION: 2.4
24166 // An implementation of the GNU vasprintf() function which supports
24167 // positional parameters, as specified in the Single Unix Specification.
24168 // This function is similar to g_vsprintf(), except that it allocates a
24169 // string to hold the output, instead of putting the output in a buffer
24170 // you allocate in advance.
24171 // RETURNS: the number of bytes printed.
24172 // <string>: the return location for the newly-allocated string.
24173 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
24174 // <args>: the list of arguments to insert in the output.
24175 static int vasprintf()(char** string_, char* format, va_list args) nothrow {
24176 return g_vasprintf(string_, format, args);
24180 // Unintrospectable function: vfprintf() / g_vfprintf()
24181 // VERSION: 2.2
24182 // An implementation of the standard fprintf() function which supports
24183 // positional parameters, as specified in the Single Unix Specification.
24184 // RETURNS: the number of bytes printed.
24185 // <file>: the stream to write to.
24186 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
24187 // <args>: the list of arguments to insert in the output.
24188 static int vfprintf()(FILE* file, char* format, va_list args) nothrow {
24189 return g_vfprintf(file, format, args);
24193 // Unintrospectable function: vprintf() / g_vprintf()
24194 // VERSION: 2.2
24195 // An implementation of the standard vprintf() function which supports
24196 // positional parameters, as specified in the Single Unix Specification.
24197 // RETURNS: the number of bytes printed.
24198 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
24199 // <args>: the list of arguments to insert in the output.
24200 static int vprintf()(char* format, va_list args) nothrow {
24201 return g_vprintf(format, args);
24205 // Unintrospectable function: vsnprintf() / g_vsnprintf()
24206 // A safer form of the standard vsprintf() function. The output is guaranteed
24207 // to not exceed @n characters (including the terminating nul character), so
24208 // it is easy to ensure that a buffer overflow cannot occur.
24210 // See also g_strdup_vprintf().
24212 // In versions of GLib prior to 1.2.3, this function may return -1 if the
24213 // output was truncated, and the truncated string may not be nul-terminated.
24214 // In versions prior to 1.3.12, this function returns the length of the output
24215 // string.
24217 // The return value of g_vsnprintf() conforms to the vsnprintf() function
24218 // as standardized in ISO C99. Note that this is different from traditional
24219 // vsnprintf(), which returns the length of the output string.
24221 // The format string may contain positional parameters, as specified in
24222 // the Single Unix Specification.
24224 // was large enough.
24225 // RETURNS: the number of bytes which would be produced if the buffer
24226 // <string>: the buffer to hold the output.
24227 // <n>: the maximum number of bytes to produce (including the terminating nul character).
24228 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
24229 // <args>: the list of arguments to insert in the output.
24230 static int vsnprintf()(char* string_, c_ulong n, char* format, va_list args) nothrow {
24231 return g_vsnprintf(string_, n, format, args);
24235 // Unintrospectable function: vsprintf() / g_vsprintf()
24236 // VERSION: 2.2
24237 // An implementation of the standard vsprintf() function which supports
24238 // positional parameters, as specified in the Single Unix Specification.
24239 // RETURNS: the number of bytes printed.
24240 // <string>: the buffer to hold the output.
24241 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
24242 // <args>: the list of arguments to insert in the output.
24243 static int vsprintf()(char* string_, char* format, va_list args) nothrow {
24244 return g_vsprintf(string_, format, args);
24247 static void warn_message()(char* domain, char* file, int line, char* func, char* warnexpr) nothrow {
24248 g_warn_message(domain, file, line, func, warnexpr);
24252 // C prototypes:
24254 extern (C) {
24255 Array* g_array_append_vals(Array* array, const(void)* data, uint len) nothrow;
24256 char* /*new*/ g_array_free(Array* array, int free_segment) nothrow;
24257 uint g_array_get_element_size(Array* array) nothrow;
24258 Array* g_array_insert_vals(Array* array, uint index_, const(void)* data, uint len) nothrow;
24259 Array* g_array_new(int zero_terminated, int clear_, uint element_size) nothrow;
24260 Array* g_array_prepend_vals(Array* array, const(void)* data, uint len) nothrow;
24261 Array* g_array_ref(Array* array) nothrow;
24262 Array* g_array_remove_index(Array* array, uint index_) nothrow;
24263 Array* g_array_remove_index_fast(Array* array, uint index_) nothrow;
24264 Array* g_array_remove_range(Array* array, uint index_, uint length) nothrow;
24265 void g_array_set_clear_func(Array* array, DestroyNotify clear_func) nothrow;
24266 Array* g_array_set_size(Array* array, uint length) nothrow;
24267 Array* g_array_sized_new(int zero_terminated, int clear_, uint element_size, uint reserved_size) nothrow;
24268 void g_array_sort(Array* array, CompareFunc compare_func) nothrow;
24269 void g_array_sort_with_data(Array* array, CompareDataFunc compare_func, void* user_data) nothrow;
24270 void g_array_unref(Array* array) nothrow;
24271 int g_async_queue_length(AsyncQueue* this_) nothrow;
24272 int g_async_queue_length_unlocked(AsyncQueue* this_) nothrow;
24273 void g_async_queue_lock(AsyncQueue* this_) nothrow;
24274 void* g_async_queue_pop(AsyncQueue* this_) nothrow;
24275 void* g_async_queue_pop_unlocked(AsyncQueue* this_) nothrow;
24276 void g_async_queue_push(AsyncQueue* this_, void* data) nothrow;
24277 void g_async_queue_push_sorted(AsyncQueue* this_, void* data, CompareDataFunc func, void* user_data) nothrow;
24278 void g_async_queue_push_sorted_unlocked(AsyncQueue* this_, void* data, CompareDataFunc func, void* user_data) nothrow;
24279 void g_async_queue_push_unlocked(AsyncQueue* this_, void* data) nothrow;
24280 AsyncQueue* g_async_queue_ref(AsyncQueue* this_) nothrow;
24281 void g_async_queue_ref_unlocked(AsyncQueue* this_) nothrow;
24282 void g_async_queue_sort(AsyncQueue* this_, CompareDataFunc func, void* user_data) nothrow;
24283 void g_async_queue_sort_unlocked(AsyncQueue* this_, CompareDataFunc func, void* user_data) nothrow;
24284 void* g_async_queue_timed_pop(AsyncQueue* this_, TimeVal* end_time) nothrow;
24285 void* g_async_queue_timed_pop_unlocked(AsyncQueue* this_, TimeVal* end_time) nothrow;
24286 void* g_async_queue_try_pop(AsyncQueue* this_) nothrow;
24287 void* g_async_queue_try_pop_unlocked(AsyncQueue* this_) nothrow;
24288 void g_async_queue_unlock(AsyncQueue* this_) nothrow;
24289 void g_async_queue_unref(AsyncQueue* this_) nothrow;
24290 void g_async_queue_unref_and_unlock(AsyncQueue* this_) nothrow;
24291 AsyncQueue* g_async_queue_new() nothrow;
24292 AsyncQueue* g_async_queue_new_full(DestroyNotify item_free_func) nothrow;
24293 void g_bookmark_file_add_application(BookmarkFile* this_, char* uri, char* name, char* exec) nothrow;
24294 void g_bookmark_file_add_group(BookmarkFile* this_, char* uri, char* group) nothrow;
24295 void g_bookmark_file_free(BookmarkFile* this_) nothrow;
24296 time_t g_bookmark_file_get_added(BookmarkFile* this_, char* uri, GLib2.Error** error) nothrow;
24297 int g_bookmark_file_get_app_info(BookmarkFile* this_, char* uri, char* name, char** exec, uint* count, time_t* stamp, GLib2.Error** error) nothrow;
24298 char** g_bookmark_file_get_applications(BookmarkFile* this_, char* uri, size_t* length, GLib2.Error** error) nothrow;
24299 char* /*new*/ g_bookmark_file_get_description(BookmarkFile* this_, char* uri, GLib2.Error** error) nothrow;
24300 char** g_bookmark_file_get_groups(BookmarkFile* this_, char* uri, size_t* length, GLib2.Error** error) nothrow;
24301 int g_bookmark_file_get_icon(BookmarkFile* this_, char* uri, char** href, char** mime_type, GLib2.Error** error) nothrow;
24302 int g_bookmark_file_get_is_private(BookmarkFile* this_, char* uri, GLib2.Error** error) nothrow;
24303 char* /*new*/ g_bookmark_file_get_mime_type(BookmarkFile* this_, char* uri, GLib2.Error** error) nothrow;
24304 time_t g_bookmark_file_get_modified(BookmarkFile* this_, char* uri, GLib2.Error** error) nothrow;
24305 int g_bookmark_file_get_size(BookmarkFile* this_) nothrow;
24306 char* /*new*/ g_bookmark_file_get_title(BookmarkFile* this_, char* uri, GLib2.Error** error) nothrow;
24307 char** g_bookmark_file_get_uris(BookmarkFile* this_, size_t* length) nothrow;
24308 time_t g_bookmark_file_get_visited(BookmarkFile* this_, char* uri, GLib2.Error** error) nothrow;
24309 int g_bookmark_file_has_application(BookmarkFile* this_, char* uri, char* name, GLib2.Error** error) nothrow;
24310 int g_bookmark_file_has_group(BookmarkFile* this_, char* uri, char* group, GLib2.Error** error) nothrow;
24311 int g_bookmark_file_has_item(BookmarkFile* this_, char* uri) nothrow;
24312 int g_bookmark_file_load_from_data(BookmarkFile* this_, char* data, size_t length, GLib2.Error** error) nothrow;
24313 int g_bookmark_file_load_from_data_dirs(BookmarkFile* this_, char* file, char** full_path, GLib2.Error** error) nothrow;
24314 int g_bookmark_file_load_from_file(BookmarkFile* this_, char* filename, GLib2.Error** error) nothrow;
24315 int g_bookmark_file_move_item(BookmarkFile* this_, char* old_uri, char* new_uri, GLib2.Error** error) nothrow;
24316 int g_bookmark_file_remove_application(BookmarkFile* this_, char* uri, char* name, GLib2.Error** error) nothrow;
24317 int g_bookmark_file_remove_group(BookmarkFile* this_, char* uri, char* group, GLib2.Error** error) nothrow;
24318 int g_bookmark_file_remove_item(BookmarkFile* this_, char* uri, GLib2.Error** error) nothrow;
24319 void g_bookmark_file_set_added(BookmarkFile* this_, char* uri, time_t added) nothrow;
24320 int g_bookmark_file_set_app_info(BookmarkFile* this_, char* uri, char* name, char* exec, int count, time_t stamp, GLib2.Error** error) nothrow;
24321 void g_bookmark_file_set_description(BookmarkFile* this_, char* uri, char* description) nothrow;
24322 void g_bookmark_file_set_groups(BookmarkFile* this_, char* uri, char** groups, size_t length) nothrow;
24323 void g_bookmark_file_set_icon(BookmarkFile* this_, char* uri, char* href, char* mime_type) nothrow;
24324 void g_bookmark_file_set_is_private(BookmarkFile* this_, char* uri, int is_private) nothrow;
24325 void g_bookmark_file_set_mime_type(BookmarkFile* this_, char* uri, char* mime_type) nothrow;
24326 void g_bookmark_file_set_modified(BookmarkFile* this_, char* uri, time_t modified) nothrow;
24327 void g_bookmark_file_set_title(BookmarkFile* this_, char* uri, char* title) nothrow;
24328 void g_bookmark_file_set_visited(BookmarkFile* this_, char* uri, time_t visited) nothrow;
24329 char* /*new*/ g_bookmark_file_to_data(BookmarkFile* this_, size_t* length, GLib2.Error** error) nothrow;
24330 int g_bookmark_file_to_file(BookmarkFile* this_, char* filename, GLib2.Error** error) nothrow;
24331 Quark g_bookmark_file_error_quark() nothrow;
24332 BookmarkFile* g_bookmark_file_new() nothrow;
24333 ByteArray* g_byte_array_append(ByteArray* array, ubyte* data, uint len) nothrow;
24334 ubyte* g_byte_array_free(ByteArray* array, int free_segment) nothrow;
24335 Bytes* /*new*/ g_byte_array_free_to_bytes(ByteArray* array) nothrow;
24336 ByteArray* g_byte_array_new() nothrow;
24337 ByteArray* /*new*/ g_byte_array_new_take(ubyte* data, size_t len) nothrow;
24338 ByteArray* g_byte_array_prepend(ByteArray* array, ubyte* data, uint len) nothrow;
24339 ByteArray* g_byte_array_ref(ByteArray* array) nothrow;
24340 ByteArray* g_byte_array_remove_index(ByteArray* array, uint index_) nothrow;
24341 ByteArray* g_byte_array_remove_index_fast(ByteArray* array, uint index_) nothrow;
24342 ByteArray* g_byte_array_remove_range(ByteArray* array, uint index_, uint length) nothrow;
24343 ByteArray* g_byte_array_set_size(ByteArray* array, uint length) nothrow;
24344 ByteArray* g_byte_array_sized_new(uint reserved_size) nothrow;
24345 void g_byte_array_sort(ByteArray* array, CompareFunc compare_func) nothrow;
24346 void g_byte_array_sort_with_data(ByteArray* array, CompareDataFunc compare_func, void* user_data) nothrow;
24347 void g_byte_array_unref(ByteArray* array) nothrow;
24348 Bytes* /*new*/ g_bytes_new(const(void)* data, size_t size) nothrow;
24349 Bytes* /*new*/ g_bytes_new_static(const(void)* data, size_t size) nothrow;
24350 Bytes* /*new*/ g_bytes_new_take(void* data, size_t size) nothrow;
24351 Bytes* /*new*/ g_bytes_new_with_free_func(const(void)* data, size_t size, DestroyNotify free_func, void* user_data) nothrow;
24352 int g_bytes_compare(Bytes* this_, const(Bytes)* bytes2) nothrow;
24353 int g_bytes_equal(Bytes* this_, const(Bytes)* bytes2) nothrow;
24354 const(ubyte)* g_bytes_get_data(Bytes* this_, /*out*/ size_t* size=null) nothrow;
24355 size_t g_bytes_get_size(Bytes* this_) nothrow;
24356 uint g_bytes_hash(Bytes* this_) nothrow;
24357 Bytes* /*new*/ g_bytes_new_from_bytes(Bytes* this_, size_t offset, size_t length) nothrow;
24358 Bytes* /*new*/ g_bytes_ref(Bytes* this_) nothrow;
24359 void g_bytes_unref(Bytes* this_) nothrow;
24360 ByteArray* /*new*/ g_bytes_unref_to_array(Bytes* this_) nothrow;
24361 void* /*new*/ g_bytes_unref_to_data(Bytes* this_, size_t* size) nothrow;
24362 Checksum* g_checksum_copy(Checksum* this_) nothrow;
24363 void g_checksum_free(Checksum* this_) nothrow;
24364 void g_checksum_get_digest(Checksum* this_, ubyte* buffer, size_t* digest_len) nothrow;
24365 char* g_checksum_get_string(Checksum* this_) nothrow;
24366 void g_checksum_reset(Checksum* this_) nothrow;
24367 void g_checksum_update(Checksum* this_, ubyte* data, ssize_t length) nothrow;
24368 Checksum* g_checksum_new(ChecksumType checksum_type) nothrow;
24369 ssize_t g_checksum_type_get_length(ChecksumType checksum_type) nothrow;
24370 void g_cond_broadcast(Cond* this_) nothrow;
24371 void g_cond_clear(Cond* this_) nothrow;
24372 void g_cond_init(Cond* this_) nothrow;
24373 void g_cond_signal(Cond* this_) nothrow;
24374 void g_cond_wait(Cond* this_, Mutex* mutex) nothrow;
24375 int g_cond_wait_until(Cond* this_, Mutex* mutex, long end_time) nothrow;
24376 Date* /*new*/ g_date_new() nothrow;
24377 Date* /*new*/ g_date_new_dmy(DateDay day, DateMonth month, DateYear year) nothrow;
24378 Date* /*new*/ g_date_new_julian(uint julian_day) nothrow;
24379 void g_date_add_days(Date* this_, uint n_days) nothrow;
24380 void g_date_add_months(Date* this_, uint n_months) nothrow;
24381 void g_date_add_years(Date* this_, uint n_years) nothrow;
24382 void g_date_clamp(Date* this_, Date* min_date, Date* max_date) nothrow;
24383 void g_date_clear(Date* this_, uint n_dates) nothrow;
24384 int g_date_compare(Date* this_, Date* rhs) nothrow;
24385 int g_date_days_between(Date* this_, Date* date2) nothrow;
24386 void g_date_free(Date* this_) nothrow;
24387 DateDay g_date_get_day(Date* this_) nothrow;
24388 uint g_date_get_day_of_year(Date* this_) nothrow;
24389 uint g_date_get_iso8601_week_of_year(Date* this_) nothrow;
24390 uint g_date_get_julian(Date* this_) nothrow;
24391 uint g_date_get_monday_week_of_year(Date* this_) nothrow;
24392 DateMonth g_date_get_month(Date* this_) nothrow;
24393 uint g_date_get_sunday_week_of_year(Date* this_) nothrow;
24394 DateWeekday g_date_get_weekday(Date* this_) nothrow;
24395 DateYear g_date_get_year(Date* this_) nothrow;
24396 int g_date_is_first_of_month(Date* this_) nothrow;
24397 int g_date_is_last_of_month(Date* this_) nothrow;
24398 void g_date_order(Date* this_, Date* date2) nothrow;
24399 void g_date_set_day(Date* this_, DateDay day) nothrow;
24400 void g_date_set_dmy(Date* this_, DateDay day, DateMonth month, DateYear y) nothrow;
24401 void g_date_set_julian(Date* this_, uint julian_date) nothrow;
24402 void g_date_set_month(Date* this_, DateMonth month) nothrow;
24403 void g_date_set_parse(Date* this_, char* str) nothrow;
24404 void g_date_set_time(Date* this_, Time time_) nothrow;
24405 void g_date_set_time_t(Date* this_, time_t timet) nothrow;
24406 void g_date_set_time_val(Date* this_, TimeVal* timeval) nothrow;
24407 void g_date_set_year(Date* this_, DateYear year) nothrow;
24408 void g_date_subtract_days(Date* this_, uint n_days) nothrow;
24409 void g_date_subtract_months(Date* this_, uint n_months) nothrow;
24410 void g_date_subtract_years(Date* this_, uint n_years) nothrow;
24411 void g_date_to_struct_tm(Date* this_, void** tm) nothrow;
24412 int g_date_valid(Date* this_) nothrow;
24413 ubyte g_date_get_days_in_month(DateMonth month, DateYear year) nothrow;
24414 ubyte g_date_get_monday_weeks_in_year(DateYear year) nothrow;
24415 ubyte g_date_get_sunday_weeks_in_year(DateYear year) nothrow;
24416 int g_date_is_leap_year(DateYear year) nothrow;
24417 size_t g_date_strftime(char* s, size_t slen, char* format, Date* date) nothrow;
24418 int g_date_valid_day(DateDay day) nothrow;
24419 int g_date_valid_dmy(DateDay day, DateMonth month, DateYear year) nothrow;
24420 int g_date_valid_julian(uint julian_date) nothrow;
24421 int g_date_valid_month(DateMonth month) nothrow;
24422 int g_date_valid_weekday(DateWeekday weekday) nothrow;
24423 int g_date_valid_year(DateYear year) nothrow;
24424 DateTime* /*new*/ g_date_time_new(TimeZone* tz, int year, int month, int day, int hour, int minute, double seconds) nothrow;
24425 DateTime* /*new*/ g_date_time_new_from_timeval_local(TimeVal* tv) nothrow;
24426 DateTime* /*new*/ g_date_time_new_from_timeval_utc(TimeVal* tv) nothrow;
24427 DateTime* /*new*/ g_date_time_new_from_unix_local(long t) nothrow;
24428 DateTime* /*new*/ g_date_time_new_from_unix_utc(long t) nothrow;
24429 DateTime* /*new*/ g_date_time_new_local(int year, int month, int day, int hour, int minute, double seconds) nothrow;
24430 DateTime* /*new*/ g_date_time_new_now(TimeZone* tz) nothrow;
24431 DateTime* /*new*/ g_date_time_new_now_local() nothrow;
24432 DateTime* /*new*/ g_date_time_new_now_utc() nothrow;
24433 DateTime* /*new*/ g_date_time_new_utc(int year, int month, int day, int hour, int minute, double seconds) nothrow;
24434 DateTime* /*new*/ g_date_time_add(DateTime* this_, TimeSpan timespan) nothrow;
24435 DateTime* /*new*/ g_date_time_add_days(DateTime* this_, int days) nothrow;
24436 DateTime* /*new*/ g_date_time_add_full(DateTime* this_, int years, int months, int days, int hours, int minutes, double seconds) nothrow;
24437 DateTime* /*new*/ g_date_time_add_hours(DateTime* this_, int hours) nothrow;
24438 DateTime* /*new*/ g_date_time_add_minutes(DateTime* this_, int minutes) nothrow;
24439 DateTime* /*new*/ g_date_time_add_months(DateTime* this_, int months) nothrow;
24440 DateTime* /*new*/ g_date_time_add_seconds(DateTime* this_, double seconds) nothrow;
24441 DateTime* /*new*/ g_date_time_add_weeks(DateTime* this_, int weeks) nothrow;
24442 DateTime* /*new*/ g_date_time_add_years(DateTime* this_, int years) nothrow;
24443 TimeSpan g_date_time_difference(DateTime* this_, DateTime* begin) nothrow;
24444 char* /*new*/ g_date_time_format(DateTime* this_, char* format) nothrow;
24445 int g_date_time_get_day_of_month(DateTime* this_) nothrow;
24446 int g_date_time_get_day_of_week(DateTime* this_) nothrow;
24447 int g_date_time_get_day_of_year(DateTime* this_) nothrow;
24448 int g_date_time_get_hour(DateTime* this_) nothrow;
24449 int g_date_time_get_microsecond(DateTime* this_) nothrow;
24450 int g_date_time_get_minute(DateTime* this_) nothrow;
24451 int g_date_time_get_month(DateTime* this_) nothrow;
24452 int g_date_time_get_second(DateTime* this_) nothrow;
24453 double g_date_time_get_seconds(DateTime* this_) nothrow;
24454 char* g_date_time_get_timezone_abbreviation(DateTime* this_) nothrow;
24455 TimeSpan g_date_time_get_utc_offset(DateTime* this_) nothrow;
24456 int g_date_time_get_week_numbering_year(DateTime* this_) nothrow;
24457 int g_date_time_get_week_of_year(DateTime* this_) nothrow;
24458 int g_date_time_get_year(DateTime* this_) nothrow;
24459 void g_date_time_get_ymd(DateTime* this_, /*out*/ int* year, /*out*/ int* month, /*out*/ int* day) nothrow;
24460 int g_date_time_is_daylight_savings(DateTime* this_) nothrow;
24461 DateTime* /*new*/ g_date_time_ref(DateTime* this_) nothrow;
24462 DateTime* /*new*/ g_date_time_to_local(DateTime* this_) nothrow;
24463 int g_date_time_to_timeval(DateTime* this_, TimeVal* tv) nothrow;
24464 DateTime* /*new*/ g_date_time_to_timezone(DateTime* this_, TimeZone* tz) nothrow;
24465 long g_date_time_to_unix(DateTime* this_) nothrow;
24466 DateTime* /*new*/ g_date_time_to_utc(DateTime* this_) nothrow;
24467 void g_date_time_unref(DateTime* this_) nothrow;
24468 int g_date_time_compare(const(void)* dt1, const(void)* dt2) nothrow;
24469 int g_date_time_equal(const(void)* dt1, const(void)* dt2) nothrow;
24470 uint g_date_time_hash(const(void)* datetime) nothrow;
24471 void g_dir_close(Dir* this_) nothrow;
24472 char* g_dir_read_name(Dir* this_) nothrow;
24473 void g_dir_rewind(Dir* this_) nothrow;
24474 char* /*new*/ g_dir_make_tmp(char* tmpl, GLib2.Error** error) nothrow;
24475 Dir* g_dir_open(char* path, uint flags, GLib2.Error** error) nothrow;
24476 Error* /*new*/ g_error_new(Quark domain, int code, char* format, ...) nothrow;
24477 Error* /*new*/ g_error_new_literal(Quark domain, int code, char* message) nothrow;
24478 Error* /*new*/ g_error_new_valist(Quark domain, int code, char* format, va_list args) nothrow;
24479 Error* /*new*/ g_error_copy(Error* this_) nothrow;
24480 void g_error_free(Error* this_) nothrow;
24481 int g_error_matches(Error* this_, Quark domain, int code) nothrow;
24482 void g_hash_table_add(GLib2.HashTable* hash_table, void* key) nothrow;
24483 int g_hash_table_contains(GLib2.HashTable* hash_table, const(void)* lookup_key) nothrow;
24484 void g_hash_table_destroy(GLib2.HashTable* hash_table) nothrow;
24485 void* g_hash_table_find(GLib2.HashTable* hash_table, HRFunc predicate, void* user_data) nothrow;
24486 void g_hash_table_foreach(GLib2.HashTable* hash_table, HFunc func, void* user_data) nothrow;
24487 uint g_hash_table_foreach_remove(GLib2.HashTable* hash_table, HRFunc func, void* user_data) nothrow;
24488 uint g_hash_table_foreach_steal(GLib2.HashTable* hash_table, HRFunc func, void* user_data) nothrow;
24489 GLib2.List* g_hash_table_get_keys(GLib2.HashTable* hash_table) nothrow;
24490 GLib2.List* g_hash_table_get_values(GLib2.HashTable* hash_table) nothrow;
24491 void g_hash_table_insert(GLib2.HashTable* hash_table, void* key, void* value) nothrow;
24492 void* g_hash_table_lookup(GLib2.HashTable* hash_table, const(void)* key) nothrow;
24493 int g_hash_table_lookup_extended(GLib2.HashTable* hash_table, const(void)* lookup_key, void** orig_key=null, void** value=null) nothrow;
24494 GLib2.HashTable* g_hash_table_new(HashFunc hash_func, EqualFunc key_equal_func) nothrow;
24495 GLib2.HashTable* g_hash_table_new_full(HashFunc hash_func, EqualFunc key_equal_func, DestroyNotify key_destroy_func, DestroyNotify value_destroy_func) nothrow;
24496 GLib2.HashTable* g_hash_table_ref(GLib2.HashTable* hash_table) nothrow;
24497 int g_hash_table_remove(GLib2.HashTable* hash_table, const(void)* key) nothrow;
24498 void g_hash_table_remove_all(GLib2.HashTable* hash_table) nothrow;
24499 void g_hash_table_replace(GLib2.HashTable* hash_table, void* key, void* value) nothrow;
24500 uint g_hash_table_size(GLib2.HashTable* hash_table) nothrow;
24501 int g_hash_table_steal(GLib2.HashTable* hash_table, const(void)* key) nothrow;
24502 void g_hash_table_steal_all(GLib2.HashTable* hash_table) nothrow;
24503 void g_hash_table_unref(GLib2.HashTable* hash_table) nothrow;
24504 GLib2.HashTable* g_hash_table_iter_get_hash_table(HashTableIter* this_) nothrow;
24505 void g_hash_table_iter_init(HashTableIter* this_, GLib2.HashTable* hash_table) nothrow;
24506 int g_hash_table_iter_next(HashTableIter* this_, void** key, void** value) nothrow;
24507 void g_hash_table_iter_remove(HashTableIter* this_) nothrow;
24508 void g_hash_table_iter_replace(HashTableIter* this_, void* value) nothrow;
24509 void g_hash_table_iter_steal(HashTableIter* this_) nothrow;
24510 Hmac* g_hmac_copy(Hmac* this_) nothrow;
24511 void g_hmac_get_digest(Hmac* this_, ubyte* buffer, size_t* digest_len) nothrow;
24512 char* g_hmac_get_string(Hmac* this_) nothrow;
24513 Hmac* g_hmac_ref(Hmac* this_) nothrow;
24514 void g_hmac_unref(Hmac* this_) nothrow;
24515 void g_hmac_update(Hmac* this_, ubyte* data, ssize_t length) nothrow;
24516 Hmac* g_hmac_new(ChecksumType digest_type, ubyte* key, size_t key_len) nothrow;
24517 int g_hook_compare_ids(Hook* this_, Hook* sibling) nothrow;
24518 Hook* g_hook_alloc(HookList* hook_list) nothrow;
24519 int g_hook_destroy(HookList* hook_list, c_ulong hook_id) nothrow;
24520 void g_hook_destroy_link(HookList* hook_list, Hook* hook) nothrow;
24521 Hook* g_hook_find(HookList* hook_list, int need_valids, HookFindFunc func, void* data) nothrow;
24522 Hook* g_hook_find_data(HookList* hook_list, int need_valids, void* data) nothrow;
24523 Hook* g_hook_find_func(HookList* hook_list, int need_valids, void* func) nothrow;
24524 Hook* g_hook_find_func_data(HookList* hook_list, int need_valids, void* func, void* data) nothrow;
24525 Hook* g_hook_first_valid(HookList* hook_list, int may_be_in_call) nothrow;
24526 void g_hook_free(HookList* hook_list, Hook* hook) nothrow;
24527 Hook* g_hook_get(HookList* hook_list, c_ulong hook_id) nothrow;
24528 void g_hook_insert_before(HookList* hook_list, Hook* sibling, Hook* hook) nothrow;
24529 void g_hook_insert_sorted(HookList* hook_list, Hook* hook, HookCompareFunc func) nothrow;
24530 Hook* g_hook_next_valid(HookList* hook_list, Hook* hook, int may_be_in_call) nothrow;
24531 void g_hook_prepend(HookList* hook_list, Hook* hook) nothrow;
24532 Hook* g_hook_ref(HookList* hook_list, Hook* hook) nothrow;
24533 void g_hook_unref(HookList* hook_list, Hook* hook) nothrow;
24534 void g_hook_list_clear(HookList* this_) nothrow;
24535 void g_hook_list_init(HookList* this_, uint hook_size) nothrow;
24536 void g_hook_list_invoke(HookList* this_, int may_recurse) nothrow;
24537 void g_hook_list_invoke_check(HookList* this_, int may_recurse) nothrow;
24538 void g_hook_list_marshal(HookList* this_, int may_recurse, HookMarshaller marshaller, void* marshal_data) nothrow;
24539 void g_hook_list_marshal_check(HookList* this_, int may_recurse, HookCheckMarshaller marshaller, void* marshal_data) nothrow;
24540 size_t g_iconv(IConv* this_, char** inbuf, size_t* inbytes_left, char** outbuf, size_t* outbytes_left) nothrow;
24541 int g_iconv_close(IConv* this_) nothrow;
24542 IConv g_iconv_open(char* to_codeset, char* from_codeset) nothrow;
24543 IOChannel* /*new*/ g_io_channel_new_file(char* filename, char* mode, GLib2.Error** error) nothrow;
24544 IOChannel* /*new*/ g_io_channel_unix_new(int fd) nothrow;
24545 void g_io_channel_close(IOChannel* this_) nothrow;
24546 IOStatus g_io_channel_flush(IOChannel* this_, GLib2.Error** error) nothrow;
24547 IOCondition g_io_channel_get_buffer_condition(IOChannel* this_) nothrow;
24548 size_t g_io_channel_get_buffer_size(IOChannel* this_) nothrow;
24549 int g_io_channel_get_buffered(IOChannel* this_) nothrow;
24550 int g_io_channel_get_close_on_unref(IOChannel* this_) nothrow;
24551 char* g_io_channel_get_encoding(IOChannel* this_) nothrow;
24552 IOFlags g_io_channel_get_flags(IOChannel* this_) nothrow;
24553 char* g_io_channel_get_line_term(IOChannel* this_, int* length) nothrow;
24554 void g_io_channel_init(IOChannel* this_) nothrow;
24555 IOError g_io_channel_read(IOChannel* this_, char* buf, size_t count, size_t* bytes_read) nothrow;
24556 IOStatus g_io_channel_read_chars(IOChannel* this_, char* buf, size_t count, size_t* bytes_read, GLib2.Error** error) nothrow;
24557 IOStatus g_io_channel_read_line(IOChannel* this_, char** str_return, size_t* length, size_t* terminator_pos, GLib2.Error** error) nothrow;
24558 IOStatus g_io_channel_read_line_string(IOChannel* this_, String* buffer, size_t* terminator_pos, GLib2.Error** error) nothrow;
24559 IOStatus g_io_channel_read_to_end(IOChannel* this_, char** str_return, size_t* length, GLib2.Error** error) nothrow;
24560 IOStatus g_io_channel_read_unichar(IOChannel* this_, dchar* thechar, GLib2.Error** error) nothrow;
24561 IOChannel* /*new*/ g_io_channel_ref(IOChannel* this_) nothrow;
24562 IOError g_io_channel_seek(IOChannel* this_, long offset, SeekType type) nothrow;
24563 IOStatus g_io_channel_seek_position(IOChannel* this_, long offset, SeekType type, GLib2.Error** error) nothrow;
24564 void g_io_channel_set_buffer_size(IOChannel* this_, size_t size) nothrow;
24565 void g_io_channel_set_buffered(IOChannel* this_, int buffered) nothrow;
24566 void g_io_channel_set_close_on_unref(IOChannel* this_, int do_close) nothrow;
24567 IOStatus g_io_channel_set_encoding(IOChannel* this_, char* encoding, GLib2.Error** error) nothrow;
24568 IOStatus g_io_channel_set_flags(IOChannel* this_, IOFlags flags, GLib2.Error** error) nothrow;
24569 void g_io_channel_set_line_term(IOChannel* this_, char* line_term, int length) nothrow;
24570 IOStatus g_io_channel_shutdown(IOChannel* this_, int flush, GLib2.Error** error) nothrow;
24571 int g_io_channel_unix_get_fd(IOChannel* this_) nothrow;
24572 void g_io_channel_unref(IOChannel* this_) nothrow;
24573 IOError g_io_channel_write(IOChannel* this_, char* buf, size_t count, size_t* bytes_written) nothrow;
24574 IOStatus g_io_channel_write_chars(IOChannel* this_, char* buf, ssize_t count, size_t* bytes_written, GLib2.Error** error) nothrow;
24575 IOStatus g_io_channel_write_unichar(IOChannel* this_, dchar thechar, GLib2.Error** error) nothrow;
24576 IOChannelError g_io_channel_error_from_errno(int en) nothrow;
24577 Quark g_io_channel_error_quark() nothrow;
24578 KeyFile* /*new*/ g_key_file_new() nothrow;
24579 void g_key_file_free(KeyFile* this_) nothrow;
24580 int g_key_file_get_boolean(KeyFile* this_, char* group_name, char* key, GLib2.Error** error) nothrow;
24581 int* /*new container*/ g_key_file_get_boolean_list(KeyFile* this_, char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error) nothrow;
24582 char* /*new*/ g_key_file_get_comment(KeyFile* this_, char* group_name, char* key, GLib2.Error** error) nothrow;
24583 double g_key_file_get_double(KeyFile* this_, char* group_name, char* key, GLib2.Error** error) nothrow;
24584 double* /*new container*/ g_key_file_get_double_list(KeyFile* this_, char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error) nothrow;
24585 char** /*new*/ g_key_file_get_groups(KeyFile* this_, /*out*/ size_t* length=null) nothrow;
24586 long g_key_file_get_int64(KeyFile* this_, char* group_name, char* key, GLib2.Error** error) nothrow;
24587 int g_key_file_get_integer(KeyFile* this_, char* group_name, char* key, GLib2.Error** error) nothrow;
24588 int* /*new container*/ g_key_file_get_integer_list(KeyFile* this_, char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error) nothrow;
24589 char** /*new*/ g_key_file_get_keys(KeyFile* this_, char* group_name, /*out*/ size_t* length, GLib2.Error** error) nothrow;
24590 char* /*new*/ g_key_file_get_locale_string(KeyFile* this_, char* group_name, char* key, char* locale, GLib2.Error** error) nothrow;
24591 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) nothrow;
24592 char* /*new*/ g_key_file_get_start_group(KeyFile* this_) nothrow;
24593 char* /*new*/ g_key_file_get_string(KeyFile* this_, char* group_name, char* key, GLib2.Error** error) nothrow;
24594 char** /*new*/ g_key_file_get_string_list(KeyFile* this_, char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error) nothrow;
24595 ulong g_key_file_get_uint64(KeyFile* this_, char* group_name, char* key, GLib2.Error** error) nothrow;
24596 char* /*new*/ g_key_file_get_value(KeyFile* this_, char* group_name, char* key, GLib2.Error** error) nothrow;
24597 int g_key_file_has_group(KeyFile* this_, char* group_name) nothrow;
24598 int g_key_file_has_key(KeyFile* this_, char* group_name, char* key, GLib2.Error** error) nothrow;
24599 int g_key_file_load_from_data(KeyFile* this_, char* data, size_t length, KeyFileFlags flags, GLib2.Error** error) nothrow;
24600 int g_key_file_load_from_data_dirs(KeyFile* this_, char* file, /*out*/ char** full_path, KeyFileFlags flags, GLib2.Error** error) nothrow;
24601 int g_key_file_load_from_dirs(KeyFile* this_, char* file, char** search_dirs, /*out*/ char** full_path, KeyFileFlags flags, GLib2.Error** error) nothrow;
24602 int g_key_file_load_from_file(KeyFile* this_, char* file, KeyFileFlags flags, GLib2.Error** error) nothrow;
24603 KeyFile* /*new*/ g_key_file_ref(KeyFile* this_) nothrow;
24604 int g_key_file_remove_comment(KeyFile* this_, char* group_name, char* key, GLib2.Error** error) nothrow;
24605 int g_key_file_remove_group(KeyFile* this_, char* group_name, GLib2.Error** error) nothrow;
24606 int g_key_file_remove_key(KeyFile* this_, char* group_name, char* key, GLib2.Error** error) nothrow;
24607 void g_key_file_set_boolean(KeyFile* this_, char* group_name, char* key, int value) nothrow;
24608 void g_key_file_set_boolean_list(KeyFile* this_, char* group_name, char* key, int list, size_t length) nothrow;
24609 int g_key_file_set_comment(KeyFile* this_, char* group_name, char* key, char* comment, GLib2.Error** error) nothrow;
24610 void g_key_file_set_double(KeyFile* this_, char* group_name, char* key, double value) nothrow;
24611 void g_key_file_set_double_list(KeyFile* this_, char* group_name, char* key, double list, size_t length) nothrow;
24612 void g_key_file_set_int64(KeyFile* this_, char* group_name, char* key, long value) nothrow;
24613 void g_key_file_set_integer(KeyFile* this_, char* group_name, char* key, int value) nothrow;
24614 void g_key_file_set_integer_list(KeyFile* this_, char* group_name, char* key, int list, size_t length) nothrow;
24615 void g_key_file_set_list_separator(KeyFile* this_, char separator) nothrow;
24616 void g_key_file_set_locale_string(KeyFile* this_, char* group_name, char* key, char* locale, char* string_) nothrow;
24617 void g_key_file_set_locale_string_list(KeyFile* this_, char* group_name, char* key, char* locale, char* list, size_t length) nothrow;
24618 void g_key_file_set_string(KeyFile* this_, char* group_name, char* key, char* string_) nothrow;
24619 void g_key_file_set_string_list(KeyFile* this_, char* group_name, char* key, char* list, size_t length) nothrow;
24620 void g_key_file_set_uint64(KeyFile* this_, char* group_name, char* key, ulong value) nothrow;
24621 void g_key_file_set_value(KeyFile* this_, char* group_name, char* key, char* value) nothrow;
24622 char* /*new*/ g_key_file_to_data(KeyFile* this_, /*out*/ size_t* length, GLib2.Error** error) nothrow;
24623 void g_key_file_unref(KeyFile* this_) nothrow;
24624 Quark g_key_file_error_quark() nothrow;
24625 GLib2.List* g_list_alloc() nothrow;
24626 GLib2.List* g_list_append(GLib2.List* list, void* data) nothrow;
24627 GLib2.List* g_list_concat(GLib2.List* list1, GLib2.List* list2) nothrow;
24628 GLib2.List* g_list_copy(GLib2.List* list) nothrow;
24629 GLib2.List* g_list_delete_link(GLib2.List* list, GLib2.List* link_) nothrow;
24630 GLib2.List* g_list_find(GLib2.List* list, const(void)* data) nothrow;
24631 GLib2.List* g_list_find_custom(GLib2.List* list, const(void)* data, CompareFunc func) nothrow;
24632 GLib2.List* g_list_first(GLib2.List* list) nothrow;
24633 void g_list_foreach(GLib2.List* list, Func func, void* user_data) nothrow;
24634 void g_list_free(GLib2.List* list) nothrow;
24635 void g_list_free_1(GLib2.List* list) nothrow;
24636 void g_list_free_full(GLib2.List* list, DestroyNotify free_func) nothrow;
24637 int g_list_index(GLib2.List* list, const(void)* data) nothrow;
24638 GLib2.List* g_list_insert(GLib2.List* list, void* data, int position) nothrow;
24639 GLib2.List* g_list_insert_before(GLib2.List* list, GLib2.List* sibling, void* data) nothrow;
24640 GLib2.List* g_list_insert_sorted(GLib2.List* list, void* data, CompareFunc func) nothrow;
24641 GLib2.List* g_list_insert_sorted_with_data(GLib2.List* list, void* data, CompareDataFunc func, void* user_data) nothrow;
24642 GLib2.List* g_list_last(GLib2.List* list) nothrow;
24643 uint g_list_length(GLib2.List* list) nothrow;
24644 GLib2.List* g_list_nth(GLib2.List* list, uint n) nothrow;
24645 void* g_list_nth_data(GLib2.List* list, uint n) nothrow;
24646 GLib2.List* g_list_nth_prev(GLib2.List* list, uint n) nothrow;
24647 int g_list_position(GLib2.List* list, GLib2.List* llink) nothrow;
24648 GLib2.List* g_list_prepend(GLib2.List* list, void* data) nothrow;
24649 GLib2.List* g_list_remove(GLib2.List* list, const(void)* data) nothrow;
24650 GLib2.List* g_list_remove_all(GLib2.List* list, const(void)* data) nothrow;
24651 GLib2.List* g_list_remove_link(GLib2.List* list, GLib2.List* llink) nothrow;
24652 GLib2.List* g_list_reverse(GLib2.List* list) nothrow;
24653 GLib2.List* g_list_sort(GLib2.List* list, CompareFunc compare_func) nothrow;
24654 GLib2.List* g_list_sort_with_data(GLib2.List* list, CompareDataFunc compare_func, void* user_data) nothrow;
24655 MainContext* /*new*/ g_main_context_new() nothrow;
24656 int g_main_context_acquire(MainContext* this_) nothrow;
24657 void g_main_context_add_poll(MainContext* this_, PollFD* fd, int priority) nothrow;
24658 int g_main_context_check(MainContext* this_, int max_priority, PollFD* fds, int n_fds) nothrow;
24659 void g_main_context_dispatch(MainContext* this_) nothrow;
24660 Source* g_main_context_find_source_by_funcs_user_data(MainContext* this_, SourceFuncs* funcs, void* user_data) nothrow;
24661 Source* g_main_context_find_source_by_id(MainContext* this_, uint source_id) nothrow;
24662 Source* g_main_context_find_source_by_user_data(MainContext* this_, void* user_data) nothrow;
24663 PollFunc g_main_context_get_poll_func(MainContext* this_) nothrow;
24664 void g_main_context_invoke(MainContext* this_, SourceFunc function_, void* data) nothrow;
24665 void g_main_context_invoke_full(MainContext* this_, int priority, SourceFunc function_, void* data, DestroyNotify notify) nothrow;
24666 int g_main_context_is_owner(MainContext* this_) nothrow;
24667 int g_main_context_iteration(MainContext* this_, int may_block) nothrow;
24668 int g_main_context_pending(MainContext* this_) nothrow;
24669 void g_main_context_pop_thread_default(MainContext* this_) nothrow;
24670 int g_main_context_prepare(MainContext* this_, int* priority) nothrow;
24671 void g_main_context_push_thread_default(MainContext* this_) nothrow;
24672 int g_main_context_query(MainContext* this_, int max_priority, /*out*/ int* timeout_, /*out*/ PollFD* fds, /*out*/ int n_fds) nothrow;
24673 MainContext* /*new*/ g_main_context_ref(MainContext* this_) nothrow;
24674 void g_main_context_release(MainContext* this_) nothrow;
24675 void g_main_context_remove_poll(MainContext* this_, PollFD* fd) nothrow;
24676 void g_main_context_set_poll_func(MainContext* this_, PollFunc func) nothrow;
24677 void g_main_context_unref(MainContext* this_) nothrow;
24678 int g_main_context_wait(MainContext* this_, Cond* cond, Mutex* mutex) nothrow;
24679 void g_main_context_wakeup(MainContext* this_) nothrow;
24680 MainContext* g_main_context_default() nothrow;
24681 MainContext* g_main_context_get_thread_default() nothrow;
24682 MainContext* /*new*/ g_main_context_ref_thread_default() nothrow;
24683 MainLoop* /*new*/ g_main_loop_new(MainContext* context, int is_running) nothrow;
24684 MainContext* g_main_loop_get_context(MainLoop* this_) nothrow;
24685 int g_main_loop_is_running(MainLoop* this_) nothrow;
24686 void g_main_loop_quit(MainLoop* this_) nothrow;
24687 MainLoop* /*new*/ g_main_loop_ref(MainLoop* this_) nothrow;
24688 void g_main_loop_run(MainLoop* this_) nothrow;
24689 void g_main_loop_unref(MainLoop* this_) nothrow;
24690 void g_mapped_file_free(MappedFile* this_) nothrow;
24691 char* /*new*/ g_mapped_file_get_contents(MappedFile* this_) nothrow;
24692 size_t g_mapped_file_get_length(MappedFile* this_) nothrow;
24693 MappedFile* g_mapped_file_ref(MappedFile* this_) nothrow;
24694 void g_mapped_file_unref(MappedFile* this_) nothrow;
24695 MappedFile* g_mapped_file_new(char* filename, int writable, GLib2.Error** error) nothrow;
24696 MappedFile* g_mapped_file_new_from_fd(int fd, int writable, GLib2.Error** error) nothrow;
24697 int g_markup_parse_context_end_parse(MarkupParseContext* this_, GLib2.Error** error) nothrow;
24698 void g_markup_parse_context_free(MarkupParseContext* this_) nothrow;
24699 char* g_markup_parse_context_get_element(MarkupParseContext* this_) nothrow;
24700 GLib2.SList* g_markup_parse_context_get_element_stack(MarkupParseContext* this_) nothrow;
24701 void g_markup_parse_context_get_position(MarkupParseContext* this_, int* line_number=null, int* char_number=null) nothrow;
24702 void* g_markup_parse_context_get_user_data(MarkupParseContext* this_) nothrow;
24703 int g_markup_parse_context_parse(MarkupParseContext* this_, char* text, ssize_t text_len, GLib2.Error** error) nothrow;
24704 void* g_markup_parse_context_pop(MarkupParseContext* this_) nothrow;
24705 void g_markup_parse_context_push(MarkupParseContext* this_, MarkupParser* parser, void* user_data) nothrow;
24706 MarkupParseContext* g_markup_parse_context_new(MarkupParser* parser, MarkupParseFlags flags, void* user_data, DestroyNotify user_data_dnotify) nothrow;
24707 char* /*new*/ g_match_info_expand_references(MatchInfo* this_, char* string_to_expand, GLib2.Error** error) nothrow;
24708 char* /*new*/ g_match_info_fetch(MatchInfo* this_, int match_num) nothrow;
24709 char** g_match_info_fetch_all(MatchInfo* this_) nothrow;
24710 char* /*new*/ g_match_info_fetch_named(MatchInfo* this_, char* name) nothrow;
24711 int g_match_info_fetch_named_pos(MatchInfo* this_, char* name, /*out*/ int* start_pos=null, /*out*/ int* end_pos=null) nothrow;
24712 int g_match_info_fetch_pos(MatchInfo* this_, int match_num, /*out*/ int* start_pos=null, /*out*/ int* end_pos=null) nothrow;
24713 void g_match_info_free(MatchInfo* this_) nothrow;
24714 int g_match_info_get_match_count(MatchInfo* this_) nothrow;
24715 Regex* /*new*/ g_match_info_get_regex(MatchInfo* this_) nothrow;
24716 char* g_match_info_get_string(MatchInfo* this_) nothrow;
24717 int g_match_info_is_partial_match(MatchInfo* this_) nothrow;
24718 int g_match_info_matches(MatchInfo* this_) nothrow;
24719 int g_match_info_next(MatchInfo* this_, GLib2.Error** error) nothrow;
24720 MatchInfo* /*new*/ g_match_info_ref(MatchInfo* this_) nothrow;
24721 void g_match_info_unref(MatchInfo* this_) nothrow;
24722 void g_mutex_clear(Mutex* this_) nothrow;
24723 void g_mutex_init(Mutex* this_) nothrow;
24724 void g_mutex_lock(Mutex* this_) nothrow;
24725 int g_mutex_trylock(Mutex* this_) nothrow;
24726 void g_mutex_unlock(Mutex* this_) nothrow;
24727 int g_node_child_index(Node* this_, void* data) nothrow;
24728 int g_node_child_position(Node* this_, Node* child) nothrow;
24729 void g_node_children_foreach(Node* this_, TraverseFlags flags, NodeForeachFunc func, void* data) nothrow;
24730 Node* g_node_copy(Node* this_) nothrow;
24731 Node* g_node_copy_deep(Node* this_, CopyFunc copy_func, void* data) nothrow;
24732 uint g_node_depth(Node* this_) nothrow;
24733 void g_node_destroy(Node* this_) nothrow;
24734 Node* g_node_find(Node* this_, TraverseType order, TraverseFlags flags, void* data) nothrow;
24735 Node* g_node_find_child(Node* this_, TraverseFlags flags, void* data) nothrow;
24736 Node* g_node_first_sibling(Node* this_) nothrow;
24737 Node* g_node_get_root(Node* this_) nothrow;
24738 Node* g_node_insert(Node* this_, int position, Node* node) nothrow;
24739 Node* g_node_insert_after(Node* this_, Node* sibling, Node* node) nothrow;
24740 Node* g_node_insert_before(Node* this_, Node* sibling, Node* node) nothrow;
24741 int g_node_is_ancestor(Node* this_, Node* descendant) nothrow;
24742 Node* g_node_last_child(Node* this_) nothrow;
24743 Node* g_node_last_sibling(Node* this_) nothrow;
24744 uint g_node_max_height(Node* this_) nothrow;
24745 uint g_node_n_children(Node* this_) nothrow;
24746 uint g_node_n_nodes(Node* this_, TraverseFlags flags) nothrow;
24747 Node* g_node_nth_child(Node* this_, uint n) nothrow;
24748 Node* g_node_prepend(Node* this_, Node* node) nothrow;
24749 void g_node_reverse_children(Node* this_) nothrow;
24750 void g_node_traverse(Node* this_, TraverseType order, TraverseFlags flags, int max_depth, NodeTraverseFunc func, void* data) nothrow;
24751 void g_node_unlink(Node* this_) nothrow;
24752 Node* g_node_new(void* data) nothrow;
24753 void* g_once_impl(Once* this_, ThreadFunc func, void* arg) nothrow;
24754 int g_once_init_enter(void* location) nothrow;
24755 void g_once_init_leave(void* location, size_t result) nothrow;
24756 void g_option_context_add_group(OptionContext* this_, OptionGroup* group) nothrow;
24757 void g_option_context_add_main_entries(OptionContext* this_, OptionEntry* entries, char* translation_domain) nothrow;
24758 void g_option_context_free(OptionContext* this_) nothrow;
24759 char* g_option_context_get_description(OptionContext* this_) nothrow;
24760 char* /*new*/ g_option_context_get_help(OptionContext* this_, int main_help, OptionGroup* group) nothrow;
24761 int g_option_context_get_help_enabled(OptionContext* this_) nothrow;
24762 int g_option_context_get_ignore_unknown_options(OptionContext* this_) nothrow;
24763 OptionGroup* g_option_context_get_main_group(OptionContext* this_) nothrow;
24764 char* g_option_context_get_summary(OptionContext* this_) nothrow;
24765 int g_option_context_parse(OptionContext* this_, /*inout*/ int* argc, /*inout*/ char*** argv, GLib2.Error** error) nothrow;
24766 void g_option_context_set_description(OptionContext* this_, char* description) nothrow;
24767 void g_option_context_set_help_enabled(OptionContext* this_, int help_enabled) nothrow;
24768 void g_option_context_set_ignore_unknown_options(OptionContext* this_, int ignore_unknown) nothrow;
24769 void g_option_context_set_main_group(OptionContext* this_, OptionGroup* group) nothrow;
24770 void g_option_context_set_summary(OptionContext* this_, char* summary) nothrow;
24771 void g_option_context_set_translate_func(OptionContext* this_, TranslateFunc func, void* data, DestroyNotify destroy_notify) nothrow;
24772 void g_option_context_set_translation_domain(OptionContext* this_, char* domain) nothrow;
24773 OptionContext* g_option_context_new(char* parameter_string) nothrow;
24774 void g_option_group_add_entries(OptionGroup* this_, OptionEntry* entries) nothrow;
24775 void g_option_group_free(OptionGroup* this_) nothrow;
24776 void g_option_group_set_error_hook(OptionGroup* this_, OptionErrorFunc error_func) nothrow;
24777 void g_option_group_set_parse_hooks(OptionGroup* this_, OptionParseFunc pre_parse_func, OptionParseFunc post_parse_func) nothrow;
24778 void g_option_group_set_translate_func(OptionGroup* this_, TranslateFunc func, void* data, DestroyNotify destroy_notify) nothrow;
24779 void g_option_group_set_translation_domain(OptionGroup* this_, char* domain) nothrow;
24780 OptionGroup* g_option_group_new(char* name, char* description, char* help_description, void* user_data, DestroyNotify destroy) nothrow;
24781 int g_pattern_spec_equal(PatternSpec* this_, PatternSpec* pspec2) nothrow;
24782 void g_pattern_spec_free(PatternSpec* this_) nothrow;
24783 PatternSpec* g_pattern_spec_new(char* pattern) nothrow;
24784 void* g_private_get(Private* this_) nothrow;
24785 void g_private_replace(Private* this_, void* value) nothrow;
24786 void g_private_set(Private* this_, void* value) nothrow;
24787 void g_ptr_array_add(PtrArray* array, void* data) nothrow;
24788 void g_ptr_array_foreach(PtrArray* array, Func func, void* user_data) nothrow;
24789 void** g_ptr_array_free(PtrArray* array, int free_seg) nothrow;
24790 PtrArray* g_ptr_array_new() nothrow;
24791 PtrArray* g_ptr_array_new_full(uint reserved_size, DestroyNotify element_free_func) nothrow;
24792 PtrArray* g_ptr_array_new_with_free_func(DestroyNotify element_free_func) nothrow;
24793 PtrArray* g_ptr_array_ref(PtrArray* array) nothrow;
24794 int g_ptr_array_remove(PtrArray* array, void* data) nothrow;
24795 int g_ptr_array_remove_fast(PtrArray* array, void* data) nothrow;
24796 void* g_ptr_array_remove_index(PtrArray* array, uint index_) nothrow;
24797 void* g_ptr_array_remove_index_fast(PtrArray* array, uint index_) nothrow;
24798 void g_ptr_array_remove_range(PtrArray* array, uint index_, uint length) nothrow;
24799 void g_ptr_array_set_free_func(PtrArray* array, DestroyNotify element_free_func) nothrow;
24800 void g_ptr_array_set_size(PtrArray* array, int length) nothrow;
24801 PtrArray* g_ptr_array_sized_new(uint reserved_size) nothrow;
24802 void g_ptr_array_sort(PtrArray* array, CompareFunc compare_func) nothrow;
24803 void g_ptr_array_sort_with_data(PtrArray* array, CompareDataFunc compare_func, void* user_data) nothrow;
24804 void g_ptr_array_unref(PtrArray* array) nothrow;
24805 void g_queue_clear(Queue* this_) nothrow;
24806 Queue* g_queue_copy(Queue* this_) nothrow;
24807 void g_queue_delete_link(Queue* this_, GLib2.List* link_) nothrow;
24808 GLib2.List* g_queue_find(Queue* this_, const(void)* data) nothrow;
24809 GLib2.List* g_queue_find_custom(Queue* this_, const(void)* data, CompareFunc func) nothrow;
24810 void g_queue_foreach(Queue* this_, Func func, void* user_data) nothrow;
24811 void g_queue_free(Queue* this_) nothrow;
24812 void g_queue_free_full(Queue* this_, DestroyNotify free_func) nothrow;
24813 uint g_queue_get_length(Queue* this_) nothrow;
24814 int g_queue_index(Queue* this_, const(void)* data) nothrow;
24815 void g_queue_init(Queue* this_) nothrow;
24816 void g_queue_insert_after(Queue* this_, GLib2.List* sibling, void* data) nothrow;
24817 void g_queue_insert_before(Queue* this_, GLib2.List* sibling, void* data) nothrow;
24818 void g_queue_insert_sorted(Queue* this_, void* data, CompareDataFunc func, void* user_data) nothrow;
24819 int g_queue_is_empty(Queue* this_) nothrow;
24820 int g_queue_link_index(Queue* this_, GLib2.List* link_) nothrow;
24821 void* g_queue_peek_head(Queue* this_) nothrow;
24822 GLib2.List* g_queue_peek_head_link(Queue* this_) nothrow;
24823 void* g_queue_peek_nth(Queue* this_, uint n) nothrow;
24824 GLib2.List* g_queue_peek_nth_link(Queue* this_, uint n) nothrow;
24825 void* g_queue_peek_tail(Queue* this_) nothrow;
24826 GLib2.List* g_queue_peek_tail_link(Queue* this_) nothrow;
24827 void* g_queue_pop_head(Queue* this_) nothrow;
24828 GLib2.List* g_queue_pop_head_link(Queue* this_) nothrow;
24829 void* g_queue_pop_nth(Queue* this_, uint n) nothrow;
24830 GLib2.List* g_queue_pop_nth_link(Queue* this_, uint n) nothrow;
24831 void* g_queue_pop_tail(Queue* this_) nothrow;
24832 GLib2.List* g_queue_pop_tail_link(Queue* this_) nothrow;
24833 void g_queue_push_head(Queue* this_, void* data) nothrow;
24834 void g_queue_push_head_link(Queue* this_, GLib2.List* link_) nothrow;
24835 void g_queue_push_nth(Queue* this_, void* data, int n) nothrow;
24836 void g_queue_push_nth_link(Queue* this_, int n, GLib2.List* link_) nothrow;
24837 void g_queue_push_tail(Queue* this_, void* data) nothrow;
24838 void g_queue_push_tail_link(Queue* this_, GLib2.List* link_) nothrow;
24839 int g_queue_remove(Queue* this_, const(void)* data) nothrow;
24840 uint g_queue_remove_all(Queue* this_, const(void)* data) nothrow;
24841 void g_queue_reverse(Queue* this_) nothrow;
24842 void g_queue_sort(Queue* this_, CompareDataFunc compare_func, void* user_data) nothrow;
24843 void g_queue_unlink(Queue* this_, GLib2.List* link_) nothrow;
24844 Queue* g_queue_new() nothrow;
24845 void g_rw_lock_clear(RWLock* this_) nothrow;
24846 void g_rw_lock_init(RWLock* this_) nothrow;
24847 void g_rw_lock_reader_lock(RWLock* this_) nothrow;
24848 int g_rw_lock_reader_trylock(RWLock* this_) nothrow;
24849 void g_rw_lock_reader_unlock(RWLock* this_) nothrow;
24850 void g_rw_lock_writer_lock(RWLock* this_) nothrow;
24851 int g_rw_lock_writer_trylock(RWLock* this_) nothrow;
24852 void g_rw_lock_writer_unlock(RWLock* this_) nothrow;
24853 Rand* g_rand_copy(Rand* this_) nothrow;
24854 double g_rand_double(Rand* this_) nothrow;
24855 double g_rand_double_range(Rand* this_, double begin, double end) nothrow;
24856 void g_rand_free(Rand* this_) nothrow;
24857 uint g_rand_int(Rand* this_) nothrow;
24858 int g_rand_int_range(Rand* this_, int begin, int end) nothrow;
24859 void g_rand_set_seed(Rand* this_, uint seed) nothrow;
24860 void g_rand_set_seed_array(Rand* this_, uint* seed, uint seed_length) nothrow;
24861 Rand* g_rand_new() nothrow;
24862 Rand* g_rand_new_with_seed(uint seed) nothrow;
24863 Rand* g_rand_new_with_seed_array(uint* seed, uint seed_length) nothrow;
24864 void g_rec_mutex_clear(RecMutex* this_) nothrow;
24865 void g_rec_mutex_init(RecMutex* this_) nothrow;
24866 void g_rec_mutex_lock(RecMutex* this_) nothrow;
24867 int g_rec_mutex_trylock(RecMutex* this_) nothrow;
24868 void g_rec_mutex_unlock(RecMutex* this_) nothrow;
24869 Regex* /*new*/ g_regex_new(char* pattern, RegexCompileFlags compile_options, RegexMatchFlags match_options, GLib2.Error** error) nothrow;
24870 int g_regex_get_capture_count(Regex* this_) nothrow;
24871 RegexCompileFlags g_regex_get_compile_flags(Regex* this_) nothrow;
24872 RegexMatchFlags g_regex_get_match_flags(Regex* this_) nothrow;
24873 int g_regex_get_max_backref(Regex* this_) nothrow;
24874 char* g_regex_get_pattern(Regex* this_) nothrow;
24875 int g_regex_get_string_number(Regex* this_, char* name) nothrow;
24876 int g_regex_match(Regex* this_, char* string_, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info=null) nothrow;
24877 int g_regex_match_all(Regex* this_, char* string_, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info=null) nothrow;
24878 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) nothrow;
24879 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) nothrow;
24880 Regex* /*new*/ g_regex_ref(Regex* this_) nothrow;
24881 char* /*new*/ g_regex_replace(Regex* this_, char* string_, ssize_t string_len, int start_position, char* replacement, RegexMatchFlags match_options, GLib2.Error** error) nothrow;
24882 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) nothrow;
24883 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) nothrow;
24884 char** g_regex_split(Regex* this_, char* string_, RegexMatchFlags match_options) nothrow;
24885 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) nothrow;
24886 void g_regex_unref(Regex* this_) nothrow;
24887 int g_regex_check_replacement(char* replacement, /*out*/ int* has_references, GLib2.Error** error) nothrow;
24888 Quark g_regex_error_quark() nothrow;
24889 char* /*new*/ g_regex_escape_nul(char* string_, int length) nothrow;
24890 char* /*new*/ g_regex_escape_string(char* string_, int length) nothrow;
24891 int g_regex_match_simple(char* pattern, char* string_, RegexCompileFlags compile_options, RegexMatchFlags match_options) nothrow;
24892 char** g_regex_split_simple(char* pattern, char* string_, RegexCompileFlags compile_options, RegexMatchFlags match_options) nothrow;
24893 GLib2.SList* g_slist_alloc() nothrow;
24894 GLib2.SList* g_slist_append(GLib2.SList* list, void* data) nothrow;
24895 GLib2.SList* g_slist_concat(GLib2.SList* list1, GLib2.SList* list2) nothrow;
24896 GLib2.SList* g_slist_copy(GLib2.SList* list) nothrow;
24897 GLib2.SList* g_slist_delete_link(GLib2.SList* list, GLib2.SList* link_) nothrow;
24898 GLib2.SList* g_slist_find(GLib2.SList* list, const(void)* data) nothrow;
24899 GLib2.SList* g_slist_find_custom(GLib2.SList* list, const(void)* data, CompareFunc func) nothrow;
24900 void g_slist_foreach(GLib2.SList* list, Func func, void* user_data) nothrow;
24901 void g_slist_free(GLib2.SList* list) nothrow;
24902 void g_slist_free_1(GLib2.SList* list) nothrow;
24903 void g_slist_free_full(GLib2.SList* list, DestroyNotify free_func) nothrow;
24904 int g_slist_index(GLib2.SList* list, const(void)* data) nothrow;
24905 GLib2.SList* g_slist_insert(GLib2.SList* list, void* data, int position) nothrow;
24906 GLib2.SList* g_slist_insert_before(GLib2.SList* slist, GLib2.SList* sibling, void* data) nothrow;
24907 GLib2.SList* g_slist_insert_sorted(GLib2.SList* list, void* data, CompareFunc func) nothrow;
24908 GLib2.SList* g_slist_insert_sorted_with_data(GLib2.SList* list, void* data, CompareDataFunc func, void* user_data) nothrow;
24909 GLib2.SList* g_slist_last(GLib2.SList* list) nothrow;
24910 uint g_slist_length(GLib2.SList* list) nothrow;
24911 GLib2.SList* g_slist_nth(GLib2.SList* list, uint n) nothrow;
24912 void* g_slist_nth_data(GLib2.SList* list, uint n) nothrow;
24913 int g_slist_position(GLib2.SList* list, GLib2.SList* llink) nothrow;
24914 GLib2.SList* g_slist_prepend(GLib2.SList* list, void* data) nothrow;
24915 GLib2.SList* g_slist_remove(GLib2.SList* list, const(void)* data) nothrow;
24916 GLib2.SList* g_slist_remove_all(GLib2.SList* list, const(void)* data) nothrow;
24917 GLib2.SList* g_slist_remove_link(GLib2.SList* list, GLib2.SList* link_) nothrow;
24918 GLib2.SList* g_slist_reverse(GLib2.SList* list) nothrow;
24919 GLib2.SList* g_slist_sort(GLib2.SList* list, CompareFunc compare_func) nothrow;
24920 GLib2.SList* g_slist_sort_with_data(GLib2.SList* list, CompareDataFunc compare_func, void* user_data) nothrow;
24921 uint g_scanner_cur_line(Scanner* this_) nothrow;
24922 uint g_scanner_cur_position(Scanner* this_) nothrow;
24923 TokenType g_scanner_cur_token(Scanner* this_) nothrow;
24924 TokenValue g_scanner_cur_value(Scanner* this_) nothrow;
24925 void g_scanner_destroy(Scanner* this_) nothrow;
24926 int g_scanner_eof(Scanner* this_) nothrow;
24927 void g_scanner_error(Scanner* this_, char* format, ...) nothrow;
24928 TokenType g_scanner_get_next_token(Scanner* this_) nothrow;
24929 void g_scanner_input_file(Scanner* this_, int input_fd) nothrow;
24930 void g_scanner_input_text(Scanner* this_, char* text, uint text_len) nothrow;
24931 void* g_scanner_lookup_symbol(Scanner* this_, char* symbol) nothrow;
24932 TokenType g_scanner_peek_next_token(Scanner* this_) nothrow;
24933 void g_scanner_scope_add_symbol(Scanner* this_, uint scope_id, char* symbol, void* value) nothrow;
24934 void g_scanner_scope_foreach_symbol(Scanner* this_, uint scope_id, HFunc func, void* user_data) nothrow;
24935 void* g_scanner_scope_lookup_symbol(Scanner* this_, uint scope_id, char* symbol) nothrow;
24936 void g_scanner_scope_remove_symbol(Scanner* this_, uint scope_id, char* symbol) nothrow;
24937 uint g_scanner_set_scope(Scanner* this_, uint scope_id) nothrow;
24938 void g_scanner_sync_file_offset(Scanner* this_) nothrow;
24939 void g_scanner_unexp_token(Scanner* this_, TokenType expected_token, char* identifier_spec, char* symbol_spec, char* symbol_name, char* message, int is_error) nothrow;
24940 void g_scanner_warn(Scanner* this_, char* format, ...) nothrow;
24941 Scanner* g_scanner_new(ScannerConfig* config_templ) nothrow;
24942 SequenceIter* g_sequence_append(Sequence* this_, void* data) nothrow;
24943 void g_sequence_foreach(Sequence* this_, Func func, void* user_data) nothrow;
24944 void g_sequence_free(Sequence* this_) nothrow;
24945 SequenceIter* g_sequence_get_begin_iter(Sequence* this_) nothrow;
24946 SequenceIter* g_sequence_get_end_iter(Sequence* this_) nothrow;
24947 SequenceIter* g_sequence_get_iter_at_pos(Sequence* this_, int pos) nothrow;
24948 int g_sequence_get_length(Sequence* this_) nothrow;
24949 SequenceIter* g_sequence_insert_sorted(Sequence* this_, void* data, CompareDataFunc cmp_func, void* cmp_data) nothrow;
24950 SequenceIter* g_sequence_insert_sorted_iter(Sequence* this_, void* data, SequenceIterCompareFunc iter_cmp, void* cmp_data) nothrow;
24951 SequenceIter* g_sequence_lookup(Sequence* this_, void* data, CompareDataFunc cmp_func, void* cmp_data) nothrow;
24952 SequenceIter* g_sequence_lookup_iter(Sequence* this_, void* data, SequenceIterCompareFunc iter_cmp, void* cmp_data) nothrow;
24953 SequenceIter* g_sequence_prepend(Sequence* this_, void* data) nothrow;
24954 SequenceIter* g_sequence_search(Sequence* this_, void* data, CompareDataFunc cmp_func, void* cmp_data) nothrow;
24955 SequenceIter* g_sequence_search_iter(Sequence* this_, void* data, SequenceIterCompareFunc iter_cmp, void* cmp_data) nothrow;
24956 void g_sequence_sort(Sequence* this_, CompareDataFunc cmp_func, void* cmp_data) nothrow;
24957 void g_sequence_sort_iter(Sequence* this_, SequenceIterCompareFunc cmp_func, void* cmp_data) nothrow;
24958 void g_sequence_foreach_range(SequenceIter* begin, SequenceIter* end, Func func, void* user_data) nothrow;
24959 void* g_sequence_get(SequenceIter* iter) nothrow;
24960 SequenceIter* g_sequence_insert_before(SequenceIter* iter, void* data) nothrow;
24961 void g_sequence_move(SequenceIter* src, SequenceIter* dest) nothrow;
24962 void g_sequence_move_range(SequenceIter* dest, SequenceIter* begin, SequenceIter* end) nothrow;
24963 Sequence* g_sequence_new(DestroyNotify data_destroy) nothrow;
24964 SequenceIter* g_sequence_range_get_midpoint(SequenceIter* begin, SequenceIter* end) nothrow;
24965 void g_sequence_remove(SequenceIter* iter) nothrow;
24966 void g_sequence_remove_range(SequenceIter* begin, SequenceIter* end) nothrow;
24967 void g_sequence_set(SequenceIter* iter, void* data) nothrow;
24968 void g_sequence_sort_changed(SequenceIter* iter, CompareDataFunc cmp_func, void* cmp_data) nothrow;
24969 void g_sequence_sort_changed_iter(SequenceIter* iter, SequenceIterCompareFunc iter_cmp, void* cmp_data) nothrow;
24970 void g_sequence_swap(SequenceIter* a, SequenceIter* b) nothrow;
24971 int g_sequence_iter_compare(SequenceIter* this_, SequenceIter* b) nothrow;
24972 int g_sequence_iter_get_position(SequenceIter* this_) nothrow;
24973 Sequence* g_sequence_iter_get_sequence(SequenceIter* this_) nothrow;
24974 int g_sequence_iter_is_begin(SequenceIter* this_) nothrow;
24975 int g_sequence_iter_is_end(SequenceIter* this_) nothrow;
24976 SequenceIter* g_sequence_iter_move(SequenceIter* this_, int delta) nothrow;
24977 SequenceIter* g_sequence_iter_next(SequenceIter* this_) nothrow;
24978 SequenceIter* g_sequence_iter_prev(SequenceIter* this_) nothrow;
24979 Source* /*new*/ g_source_new(SourceFuncs* source_funcs, uint struct_size) nothrow;
24980 void g_source_add_child_source(Source* this_, Source* child_source) nothrow;
24981 void g_source_add_poll(Source* this_, PollFD* fd) nothrow;
24982 uint g_source_attach(Source* this_, MainContext* context=null) nothrow;
24983 void g_source_destroy(Source* this_) nothrow;
24984 int g_source_get_can_recurse(Source* this_) nothrow;
24985 MainContext* g_source_get_context(Source* this_) nothrow;
24986 void g_source_get_current_time(Source* this_, TimeVal* timeval) nothrow;
24987 uint g_source_get_id(Source* this_) nothrow;
24988 char* g_source_get_name(Source* this_) nothrow;
24989 int g_source_get_priority(Source* this_) nothrow;
24990 long g_source_get_time(Source* this_) nothrow;
24991 int g_source_is_destroyed(Source* this_) nothrow;
24992 Source* /*new*/ g_source_ref(Source* this_) nothrow;
24993 void g_source_remove_child_source(Source* this_, Source* child_source) nothrow;
24994 void g_source_remove_poll(Source* this_, PollFD* fd) nothrow;
24995 void g_source_set_callback(Source* this_, SourceFunc func, void* data, DestroyNotify notify) nothrow;
24996 void g_source_set_callback_indirect(Source* this_, void* callback_data, SourceCallbackFuncs* callback_funcs) nothrow;
24997 void g_source_set_can_recurse(Source* this_, int can_recurse) nothrow;
24998 void g_source_set_funcs(Source* this_, SourceFuncs* funcs) nothrow;
24999 void g_source_set_name(Source* this_, char* name) nothrow;
25000 void g_source_set_priority(Source* this_, int priority) nothrow;
25001 void g_source_unref(Source* this_) nothrow;
25002 int g_source_remove(uint tag) nothrow;
25003 int g_source_remove_by_funcs_user_data(SourceFuncs* funcs, void* user_data) nothrow;
25004 int g_source_remove_by_user_data(void* user_data) nothrow;
25005 void g_source_set_name_by_id(uint tag, char* name) nothrow;
25006 String* /*new*/ g_string_append(String* this_, char* val) nothrow;
25007 String* /*new*/ g_string_append_c(String* this_, char c) nothrow;
25008 String* /*new*/ g_string_append_len(String* this_, char* val, ssize_t len) nothrow;
25009 void g_string_append_printf(String* this_, char* format, ...) nothrow;
25010 String* /*new*/ g_string_append_unichar(String* this_, dchar wc) nothrow;
25011 String* /*new*/ g_string_append_uri_escaped(String* this_, char* unescaped, char* reserved_chars_allowed, int allow_utf8) nothrow;
25012 void g_string_append_vprintf(String* this_, char* format, va_list args) nothrow;
25013 String* /*new*/ g_string_ascii_down(String* this_) nothrow;
25014 String* /*new*/ g_string_ascii_up(String* this_) nothrow;
25015 String* /*new*/ g_string_assign(String* this_, char* rval) nothrow;
25016 String* /*new*/ g_string_down(String* this_) nothrow;
25017 int g_string_equal(String* this_, String* v2) nothrow;
25018 String* /*new*/ g_string_erase(String* this_, ssize_t pos, ssize_t len) nothrow;
25019 char* /*new*/ g_string_free(String* this_, int free_segment) nothrow;
25020 uint g_string_hash(String* this_) nothrow;
25021 String* /*new*/ g_string_insert(String* this_, ssize_t pos, char* val) nothrow;
25022 String* /*new*/ g_string_insert_c(String* this_, ssize_t pos, char c) nothrow;
25023 String* /*new*/ g_string_insert_len(String* this_, ssize_t pos, char* val, ssize_t len) nothrow;
25024 String* /*new*/ g_string_insert_unichar(String* this_, ssize_t pos, dchar wc) nothrow;
25025 String* /*new*/ g_string_overwrite(String* this_, size_t pos, char* val) nothrow;
25026 String* /*new*/ g_string_overwrite_len(String* this_, size_t pos, char* val, ssize_t len) nothrow;
25027 String* /*new*/ g_string_prepend(String* this_, char* val) nothrow;
25028 String* /*new*/ g_string_prepend_c(String* this_, char c) nothrow;
25029 String* /*new*/ g_string_prepend_len(String* this_, char* val, ssize_t len) nothrow;
25030 String* /*new*/ g_string_prepend_unichar(String* this_, dchar wc) nothrow;
25031 void g_string_printf(String* this_, char* format, ...) nothrow;
25032 String* /*new*/ g_string_set_size(String* this_, size_t len) nothrow;
25033 String* /*new*/ g_string_truncate(String* this_, size_t len) nothrow;
25034 String* /*new*/ g_string_up(String* this_) nothrow;
25035 void g_string_vprintf(String* this_, char* format, va_list args) nothrow;
25036 void g_string_chunk_clear(StringChunk* this_) nothrow;
25037 void g_string_chunk_free(StringChunk* this_) nothrow;
25038 char* /*new*/ g_string_chunk_insert(StringChunk* this_, char* string_) nothrow;
25039 char* /*new*/ g_string_chunk_insert_const(StringChunk* this_, char* string_) nothrow;
25040 char* /*new*/ g_string_chunk_insert_len(StringChunk* this_, char* string_, ssize_t len) nothrow;
25041 StringChunk* g_string_chunk_new(size_t size) nothrow;
25042 void g_test_log_buffer_free(TestLogBuffer* this_) nothrow;
25043 TestLogMsg* g_test_log_buffer_pop(TestLogBuffer* this_) nothrow;
25044 void g_test_log_buffer_push(TestLogBuffer* this_, uint n_bytes, ubyte* bytes) nothrow;
25045 TestLogBuffer* g_test_log_buffer_new() nothrow;
25046 void g_test_log_msg_free(TestLogMsg* this_) nothrow;
25047 void g_test_suite_add(TestSuite* this_, TestCase* test_case) nothrow;
25048 void g_test_suite_add_suite(TestSuite* this_, TestSuite* nestedsuite) nothrow;
25049 void* g_thread_join(Thread* this_) nothrow;
25050 Thread* g_thread_ref(Thread* this_) nothrow;
25051 void g_thread_unref(Thread* this_) nothrow;
25052 Quark g_thread_error_quark() nothrow;
25053 void g_thread_exit(void* retval) nothrow;
25054 Thread* g_thread_new(char* name, ThreadFunc func, void* data) nothrow;
25055 Thread* g_thread_self() nothrow;
25056 Thread* g_thread_try_new(char* name, ThreadFunc func, void* data, GLib2.Error** error) nothrow;
25057 void g_thread_yield() nothrow;
25058 void g_thread_pool_free(ThreadPool* this_, int immediate, int wait_) nothrow;
25059 int g_thread_pool_get_max_threads(ThreadPool* this_) nothrow;
25060 uint g_thread_pool_get_num_threads(ThreadPool* this_) nothrow;
25061 int g_thread_pool_push(ThreadPool* this_, void* data, GLib2.Error** error) nothrow;
25062 int g_thread_pool_set_max_threads(ThreadPool* this_, int max_threads, GLib2.Error** error) nothrow;
25063 void g_thread_pool_set_sort_function(ThreadPool* this_, CompareDataFunc func, void* user_data) nothrow;
25064 uint g_thread_pool_unprocessed(ThreadPool* this_) nothrow;
25065 uint g_thread_pool_get_max_idle_time() nothrow;
25066 int g_thread_pool_get_max_unused_threads() nothrow;
25067 uint g_thread_pool_get_num_unused_threads() nothrow;
25068 ThreadPool* g_thread_pool_new(Func func, void* user_data, int max_threads, int exclusive, GLib2.Error** error) nothrow;
25069 void g_thread_pool_set_max_idle_time(uint interval) nothrow;
25070 void g_thread_pool_set_max_unused_threads(int max_threads) nothrow;
25071 void g_thread_pool_stop_unused_threads() nothrow;
25072 void g_time_val_add(TimeVal* this_, c_long microseconds) nothrow;
25073 char* /*new*/ g_time_val_to_iso8601(TimeVal* this_) nothrow;
25074 int g_time_val_from_iso8601(char* iso_date, /*out*/ TimeVal* time_) nothrow;
25075 int g_time_zone_adjust_time(TimeZone* this_, TimeType type, long* time_) nothrow;
25076 int g_time_zone_find_interval(TimeZone* this_, TimeType type, long time_) nothrow;
25077 char* g_time_zone_get_abbreviation(TimeZone* this_, int interval) nothrow;
25078 int g_time_zone_get_offset(TimeZone* this_, int interval) nothrow;
25079 int g_time_zone_is_dst(TimeZone* this_, int interval) nothrow;
25080 TimeZone* g_time_zone_ref(TimeZone* this_) nothrow;
25081 void g_time_zone_unref(TimeZone* this_) nothrow;
25082 TimeZone* g_time_zone_new(char* identifier=null) nothrow;
25083 TimeZone* g_time_zone_new_local() nothrow;
25084 TimeZone* g_time_zone_new_utc() nothrow;
25085 void g_timer_continue(Timer* this_) nothrow;
25086 void g_timer_destroy(Timer* this_) nothrow;
25087 double g_timer_elapsed(Timer* this_, c_ulong* microseconds) nothrow;
25088 void g_timer_reset(Timer* this_) nothrow;
25089 void g_timer_start(Timer* this_) nothrow;
25090 void g_timer_stop(Timer* this_) nothrow;
25091 Timer* g_timer_new() nothrow;
25092 uint g_trash_stack_height(TrashStack** stack_p) nothrow;
25093 void* g_trash_stack_peek(TrashStack** stack_p) nothrow;
25094 void* g_trash_stack_pop(TrashStack** stack_p) nothrow;
25095 void g_trash_stack_push(TrashStack** stack_p, void* data_p) nothrow;
25096 void g_tree_destroy(Tree* this_) nothrow;
25097 void g_tree_foreach(Tree* this_, TraverseFunc func, void* user_data) nothrow;
25098 int g_tree_height(Tree* this_) nothrow;
25099 void g_tree_insert(Tree* this_, void* key, void* value) nothrow;
25100 void* g_tree_lookup(Tree* this_, const(void)* key) nothrow;
25101 int g_tree_lookup_extended(Tree* this_, const(void)* lookup_key, void** orig_key, void** value) nothrow;
25102 int g_tree_nnodes(Tree* this_) nothrow;
25103 Tree* g_tree_ref(Tree* this_) nothrow;
25104 int g_tree_remove(Tree* this_, const(void)* key) nothrow;
25105 void g_tree_replace(Tree* this_, void* key, void* value) nothrow;
25106 void* g_tree_search(Tree* this_, CompareFunc search_func, const(void)* user_data) nothrow;
25107 int g_tree_steal(Tree* this_, const(void)* key) nothrow;
25108 void g_tree_traverse(Tree* this_, TraverseFunc traverse_func, TraverseType traverse_type, void* user_data) nothrow;
25109 void g_tree_unref(Tree* this_) nothrow;
25110 Tree* g_tree_new(CompareFunc key_compare_func) nothrow;
25111 Tree* g_tree_new_full(CompareDataFunc key_compare_func, void* key_compare_data, DestroyNotify key_destroy_func, DestroyNotify value_destroy_func) nothrow;
25112 Tree* g_tree_new_with_data(CompareDataFunc key_compare_func, void* key_compare_data) nothrow;
25113 Variant* /*new*/ g_variant_new(char* format_string, ...) nothrow;
25114 Variant* g_variant_new_array(VariantType* child_type, Variant** children, size_t n_children) nothrow;
25115 Variant* g_variant_new_boolean(int value) nothrow;
25116 Variant* g_variant_new_byte(ubyte value) nothrow;
25117 Variant* g_variant_new_bytestring(ubyte* string_) nothrow;
25118 Variant* g_variant_new_bytestring_array(char** strv, ssize_t length) nothrow;
25119 Variant* g_variant_new_dict_entry(Variant* key, Variant* value) nothrow;
25120 Variant* g_variant_new_double(double value) nothrow;
25121 Variant* g_variant_new_fixed_array(VariantType* element_type, const(void)* elements, size_t n_elements, size_t element_size) nothrow;
25122 Variant* g_variant_new_from_data(VariantType* type, const(ubyte)* data, size_t size, int trusted, DestroyNotify notify, void* user_data) nothrow;
25123 Variant* g_variant_new_handle(int value) nothrow;
25124 Variant* g_variant_new_int16(short value) nothrow;
25125 Variant* g_variant_new_int32(int value) nothrow;
25126 Variant* g_variant_new_int64(long value) nothrow;
25127 Variant* g_variant_new_maybe(VariantType* child_type=null, Variant* child=null) nothrow;
25128 Variant* g_variant_new_object_path(char* object_path) nothrow;
25129 Variant* g_variant_new_objv(char** strv, ssize_t length) nothrow;
25130 Variant* /*new*/ g_variant_new_parsed(char* format, ...) nothrow;
25131 Variant* /*new*/ g_variant_new_parsed_va(char* format, va_list* app) nothrow;
25132 Variant* g_variant_new_signature(char* signature) nothrow;
25133 Variant* g_variant_new_string(char* string_) nothrow;
25134 Variant* g_variant_new_strv(char** strv, ssize_t length) nothrow;
25135 Variant* g_variant_new_tuple(Variant** children, size_t n_children) nothrow;
25136 Variant* g_variant_new_uint16(ushort value) nothrow;
25137 Variant* g_variant_new_uint32(uint value) nothrow;
25138 Variant* g_variant_new_uint64(ulong value) nothrow;
25139 Variant* /*new*/ g_variant_new_va(char* format_string, char** endptr, va_list* app) nothrow;
25140 Variant* g_variant_new_variant(Variant* value) nothrow;
25141 Variant* /*new*/ g_variant_byteswap(Variant* this_) nothrow;
25142 VariantClass g_variant_classify(Variant* this_) nothrow;
25143 int g_variant_compare(Variant* this_, const(Variant)* two) nothrow;
25144 char* /*new*/ g_variant_dup_bytestring(Variant* this_, /*out*/ size_t* length=null) nothrow;
25145 char** /*new*/ g_variant_dup_bytestring_array(Variant* this_, /*out*/ size_t* length=null) nothrow;
25146 char** /*new*/ g_variant_dup_objv(Variant* this_, /*out*/ size_t* length=null) nothrow;
25147 char* /*new*/ g_variant_dup_string(Variant* this_, /*out*/ size_t* length) nothrow;
25148 char** /*new*/ g_variant_dup_strv(Variant* this_, /*out*/ size_t* length=null) nothrow;
25149 int g_variant_equal(Variant* this_, const(Variant)* two) nothrow;
25150 void g_variant_get(Variant* this_, char* format_string, ...) nothrow;
25151 int g_variant_get_boolean(Variant* this_) nothrow;
25152 ubyte g_variant_get_byte(Variant* this_) nothrow;
25153 ubyte* g_variant_get_bytestring(Variant* this_) nothrow;
25154 char** /*new container*/ g_variant_get_bytestring_array(Variant* this_, /*out*/ size_t* length=null) nothrow;
25155 void g_variant_get_child(Variant* this_, size_t index_, char* format_string, ...) nothrow;
25156 Variant* /*new*/ g_variant_get_child_value(Variant* this_, size_t index_) nothrow;
25157 const(void)* g_variant_get_data(Variant* this_) nothrow;
25158 double g_variant_get_double(Variant* this_) nothrow;
25159 const(void)* g_variant_get_fixed_array(Variant* this_, /*out*/ size_t* n_elements, size_t element_size) nothrow;
25160 int g_variant_get_handle(Variant* this_) nothrow;
25161 short g_variant_get_int16(Variant* this_) nothrow;
25162 int g_variant_get_int32(Variant* this_) nothrow;
25163 long g_variant_get_int64(Variant* this_) nothrow;
25164 Variant* /*new*/ g_variant_get_maybe(Variant* this_) nothrow;
25165 Variant* /*new*/ g_variant_get_normal_form(Variant* this_) nothrow;
25166 char** /*new container*/ g_variant_get_objv(Variant* this_, /*out*/ size_t* length=null) nothrow;
25167 size_t g_variant_get_size(Variant* this_) nothrow;
25168 char* g_variant_get_string(Variant* this_, /*out*/ size_t* length=null) nothrow;
25169 char** /*new container*/ g_variant_get_strv(Variant* this_, /*out*/ size_t* length=null) nothrow;
25170 char* g_variant_get_type_string(Variant* this_) nothrow;
25171 ushort g_variant_get_uint16(Variant* this_) nothrow;
25172 uint g_variant_get_uint32(Variant* this_) nothrow;
25173 ulong g_variant_get_uint64(Variant* this_) nothrow;
25174 void g_variant_get_va(Variant* this_, char* format_string, char** endptr, va_list* app) nothrow;
25175 Variant* /*new*/ g_variant_get_variant(Variant* this_) nothrow;
25176 uint g_variant_hash(Variant* this_) nothrow;
25177 int g_variant_is_container(Variant* this_) nothrow;
25178 int g_variant_is_floating(Variant* this_) nothrow;
25179 int g_variant_is_normal_form(Variant* this_) nothrow;
25180 int g_variant_is_of_type(Variant* this_, VariantType* type) nothrow;
25181 VariantIter* /*new*/ g_variant_iter_new(Variant* this_) nothrow;
25182 int g_variant_lookup(Variant* this_, char* key, char* format_string, ...) nothrow;
25183 Variant* /*new*/ g_variant_lookup_value(Variant* this_, char* key, VariantType* expected_type=null) nothrow;
25184 size_t g_variant_n_children(Variant* this_) nothrow;
25185 char* /*new*/ g_variant_print(Variant* this_, int type_annotate) nothrow;
25186 String* /*new*/ g_variant_print_string(Variant* this_, String* string_, int type_annotate) nothrow;
25187 Variant* /*new*/ g_variant_ref(Variant* this_) nothrow;
25188 Variant* /*new*/ g_variant_ref_sink(Variant* this_) nothrow;
25189 void g_variant_store(Variant* this_, void* data) nothrow;
25190 Variant* /*new*/ g_variant_take_ref(Variant* this_) nothrow;
25191 void g_variant_unref(Variant* this_) nothrow;
25192 int g_variant_is_object_path(char* string_) nothrow;
25193 int g_variant_is_signature(char* string_) nothrow;
25194 Variant* /*new*/ g_variant_parse(VariantType* type, char* text, char* limit, char** endptr, GLib2.Error** error) nothrow;
25195 Quark g_variant_parser_get_error_quark() nothrow;
25196 VariantBuilder* /*new*/ g_variant_builder_new(VariantType* type) nothrow;
25197 void g_variant_builder_add(VariantBuilder* this_, char* format_string, ...) nothrow;
25198 void g_variant_builder_add_parsed(VariantBuilder* this_, char* format, ...) nothrow;
25199 void g_variant_builder_add_value(VariantBuilder* this_, Variant* value) nothrow;
25200 void g_variant_builder_clear(VariantBuilder* this_) nothrow;
25201 void g_variant_builder_close(VariantBuilder* this_) nothrow;
25202 Variant* g_variant_builder_end(VariantBuilder* this_) nothrow;
25203 void g_variant_builder_init(VariantBuilder* this_, VariantType* type) nothrow;
25204 void g_variant_builder_open(VariantBuilder* this_, VariantType* type) nothrow;
25205 VariantBuilder* /*new*/ g_variant_builder_ref(VariantBuilder* this_) nothrow;
25206 void g_variant_builder_unref(VariantBuilder* this_) nothrow;
25207 VariantIter* /*new*/ g_variant_iter_copy(VariantIter* this_) nothrow;
25208 void g_variant_iter_free(VariantIter* this_) nothrow;
25209 size_t g_variant_iter_init(VariantIter* this_, Variant* value) nothrow;
25210 int g_variant_iter_loop(VariantIter* this_, char* format_string, ...) nothrow;
25211 size_t g_variant_iter_n_children(VariantIter* this_) nothrow;
25212 int g_variant_iter_next(VariantIter* this_, char* format_string, ...) nothrow;
25213 Variant* /*new*/ g_variant_iter_next_value(VariantIter* this_) nothrow;
25214 VariantType* /*new*/ g_variant_type_new(char* type_string) nothrow;
25215 VariantType* /*new*/ g_variant_type_new_tuple(VariantType** items, int length) nothrow;
25216 VariantType* /*new*/ g_variant_type_copy(VariantType* this_) nothrow;
25217 char* /*new*/ g_variant_type_dup_string(VariantType* this_) nothrow;
25218 VariantType* g_variant_type_element(VariantType* this_) nothrow;
25219 int g_variant_type_equal(VariantType* this_, const(VariantType)* type2) nothrow;
25220 VariantType* g_variant_type_first(VariantType* this_) nothrow;
25221 void g_variant_type_free(VariantType* this_) nothrow;
25222 size_t g_variant_type_get_string_length(VariantType* this_) nothrow;
25223 uint g_variant_type_hash(VariantType* this_) nothrow;
25224 int g_variant_type_is_array(VariantType* this_) nothrow;
25225 int g_variant_type_is_basic(VariantType* this_) nothrow;
25226 int g_variant_type_is_container(VariantType* this_) nothrow;
25227 int g_variant_type_is_definite(VariantType* this_) nothrow;
25228 int g_variant_type_is_dict_entry(VariantType* this_) nothrow;
25229 int g_variant_type_is_maybe(VariantType* this_) nothrow;
25230 int g_variant_type_is_subtype_of(VariantType* this_, VariantType* supertype) nothrow;
25231 int g_variant_type_is_tuple(VariantType* this_) nothrow;
25232 int g_variant_type_is_variant(VariantType* this_) nothrow;
25233 VariantType* g_variant_type_key(VariantType* this_) nothrow;
25234 size_t g_variant_type_n_items(VariantType* this_) nothrow;
25235 VariantType* /*new*/ g_variant_type_new_array(VariantType* this_) nothrow;
25236 VariantType* /*new*/ g_variant_type_new_dict_entry(VariantType* this_, VariantType* value) nothrow;
25237 VariantType* /*new*/ g_variant_type_new_maybe(VariantType* this_) nothrow;
25238 VariantType* g_variant_type_next(VariantType* this_) nothrow;
25239 char* g_variant_type_peek_string(VariantType* this_) nothrow;
25240 VariantType* g_variant_type_value(VariantType* this_) nothrow;
25241 VariantType* g_variant_type_checked_(char* arg_a) nothrow;
25242 int g_variant_type_string_is_valid(char* type_string) nothrow;
25243 int g_variant_type_string_scan(char* string_, char* limit=null, /*out*/ char** endptr=null) nothrow;
25244 int g_access(char* filename, int mode) nothrow;
25245 int g_ascii_digit_value(char c) nothrow;
25246 char* /*new*/ g_ascii_dtostr(char* buffer, int buf_len, double d) nothrow;
25247 char* /*new*/ g_ascii_formatd(char* buffer, int buf_len, char* format, double d) nothrow;
25248 int g_ascii_strcasecmp(char* s1, char* s2) nothrow;
25249 char* /*new*/ g_ascii_strdown(char* str, ssize_t len) nothrow;
25250 int g_ascii_strncasecmp(char* s1, char* s2, size_t n) nothrow;
25251 double g_ascii_strtod(char* nptr, char** endptr) nothrow;
25252 long g_ascii_strtoll(char* nptr, char** endptr, uint base) nothrow;
25253 ulong g_ascii_strtoull(char* nptr, char** endptr, uint base) nothrow;
25254 char* /*new*/ g_ascii_strup(char* str, ssize_t len) nothrow;
25255 char g_ascii_tolower(char c) nothrow;
25256 char g_ascii_toupper(char c) nothrow;
25257 int g_ascii_xdigit_value(char c) nothrow;
25258 void g_assert_warning(char* log_domain, char* file, int line, char* pretty_function, char* expression) nothrow;
25259 void g_assertion_message(char* domain, char* file, int line, char* func, char* message) nothrow;
25260 void g_assertion_message_cmpnum(char* domain, char* file, int line, char* func, char* expr, real arg1, char* cmp, real arg2, char numtype) nothrow;
25261 void g_assertion_message_cmpstr(char* domain, char* file, int line, char* func, char* expr, char* arg1, char* cmp, char* arg2) nothrow;
25262 void g_assertion_message_error(char* domain, char* file, int line, char* func, char* expr, Error* error, Quark error_domain, int error_code) nothrow;
25263 void g_assertion_message_expr(char* domain, char* file, int line, char* func, char* expr) nothrow;
25264 void g_atexit(VoidFunc func) nothrow;
25265 int g_atomic_int_add(int* atomic, int val) nothrow;
25266 uint g_atomic_int_and(uint* atomic, uint val) nothrow;
25267 int g_atomic_int_compare_and_exchange(int* atomic, int oldval, int newval) nothrow;
25268 int g_atomic_int_dec_and_test(int* atomic) nothrow;
25269 int g_atomic_int_exchange_and_add(int* atomic, int val) nothrow;
25270 int g_atomic_int_get(int* atomic) nothrow;
25271 void g_atomic_int_inc(int* atomic) nothrow;
25272 uint g_atomic_int_or(uint* atomic, uint val) nothrow;
25273 void g_atomic_int_set(int* atomic, int newval) nothrow;
25274 uint g_atomic_int_xor(uint* atomic, uint val) nothrow;
25275 ssize_t g_atomic_pointer_add(void* atomic, ssize_t val) nothrow;
25276 size_t g_atomic_pointer_and(void* atomic, size_t val) nothrow;
25277 int g_atomic_pointer_compare_and_exchange(void* atomic, void* oldval, void* newval) nothrow;
25278 void* g_atomic_pointer_get(void* atomic) nothrow;
25279 size_t g_atomic_pointer_or(void* atomic, size_t val) nothrow;
25280 void g_atomic_pointer_set(void* atomic, void* newval) nothrow;
25281 size_t g_atomic_pointer_xor(void* atomic, size_t val) nothrow;
25282 ubyte* /*new*/ g_base64_decode(char* text, /*out*/ size_t* out_len) nothrow;
25283 ubyte* g_base64_decode_inplace(/*inout*/ ubyte* text, /*inout*/ size_t* out_len) nothrow;
25284 size_t g_base64_decode_step(ubyte* in_, size_t len, /*out*/ ubyte* out_, /*inout*/ int* state, /*inout*/ uint* save) nothrow;
25285 char* /*new*/ g_base64_encode(ubyte* data, size_t len) nothrow;
25286 size_t g_base64_encode_close(int break_lines, /*out*/ ubyte* out_, /*inout*/ int* state, /*inout*/ int* save) nothrow;
25287 size_t g_base64_encode_step(ubyte* in_, size_t len, int break_lines, /*out*/ ubyte* out_, /*inout*/ int* state, /*inout*/ int* save) nothrow;
25288 char* g_basename(char* file_name) nothrow;
25289 void g_bit_lock(int* address, int lock_bit) nothrow;
25290 int g_bit_nth_lsf(c_ulong mask, int nth_bit) nothrow;
25291 int g_bit_nth_msf(c_ulong mask, int nth_bit) nothrow;
25292 uint g_bit_storage(c_ulong number) nothrow;
25293 int g_bit_trylock(int* address, int lock_bit) nothrow;
25294 void g_bit_unlock(int* address, int lock_bit) nothrow;
25295 char* /*new*/ g_build_filename(char* first_element, ...) nothrow;
25296 char* /*new*/ g_build_filenamev(char** args) nothrow;
25297 char* /*new*/ g_build_path(char* separator, char* first_element, ...) nothrow;
25298 char* /*new*/ g_build_pathv(char* separator, char** args) nothrow;
25299 int g_chdir(char* path) nothrow;
25300 char* glib_check_version(uint required_major, uint required_minor, uint required_micro) nothrow;
25301 uint g_child_watch_add(Pid pid, ChildWatchFunc function_, void* data) nothrow;
25302 uint g_child_watch_add_full(int priority, Pid pid, ChildWatchFunc function_, void* data, DestroyNotify notify) nothrow;
25303 Source* /*new*/ g_child_watch_source_new(Pid pid) nothrow;
25304 void g_clear_error(GLib2.Error** error) nothrow;
25305 char* /*new*/ g_compute_checksum_for_data(ChecksumType checksum_type, ubyte* data, size_t length) nothrow;
25306 char* /*new*/ g_compute_checksum_for_string(ChecksumType checksum_type, char* str, ssize_t length) nothrow;
25307 char* /*new*/ g_compute_hmac_for_data(ChecksumType digest_type, ubyte* key, size_t key_len, ubyte* data, size_t length) nothrow;
25308 char* /*new*/ g_compute_hmac_for_string(ChecksumType digest_type, ubyte* key, size_t key_len, char* str, ssize_t length) nothrow;
25309 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) nothrow;
25310 Quark g_convert_error_quark() nothrow;
25311 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) nothrow;
25312 char* /*new*/ g_convert_with_iconv(char* str, ssize_t len, IConv converter, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error) nothrow;
25313 void g_datalist_clear(Data** datalist) nothrow;
25314 void g_datalist_foreach(Data** datalist, DataForeachFunc func, void* user_data) nothrow;
25315 void* g_datalist_get_data(Data** datalist, char* key) nothrow;
25316 uint g_datalist_get_flags(Data** datalist) nothrow;
25317 void* g_datalist_id_get_data(Data** datalist, Quark key_id) nothrow;
25318 void* g_datalist_id_remove_no_notify(Data** datalist, Quark key_id) nothrow;
25319 void g_datalist_id_set_data_full(Data** datalist, Quark key_id, void* data, DestroyNotify destroy_func) nothrow;
25320 void g_datalist_init(Data** datalist) nothrow;
25321 void g_datalist_set_flags(Data** datalist, uint flags) nothrow;
25322 void g_datalist_unset_flags(Data** datalist, uint flags) nothrow;
25323 void g_dataset_destroy(const(void)* dataset_location) nothrow;
25324 void g_dataset_foreach(const(void)* dataset_location, DataForeachFunc func, void* user_data) nothrow;
25325 void* g_dataset_id_get_data(const(void)* dataset_location, Quark key_id) nothrow;
25326 void* g_dataset_id_remove_no_notify(const(void)* dataset_location, Quark key_id) nothrow;
25327 void g_dataset_id_set_data_full(const(void)* dataset_location, Quark key_id, void* data, DestroyNotify destroy_func) nothrow;
25328 char* g_dcgettext(char* domain, char* msgid, int category) nothrow;
25329 char* g_dgettext(char* domain, char* msgid) nothrow;
25330 int g_direct_equal(const(void)* v1=null, const(void)* v2=null) nothrow;
25331 uint g_direct_hash(const(void)* v=null) nothrow;
25332 char* g_dngettext(char* domain, char* msgid, char* msgid_plural, c_ulong n) nothrow;
25333 int g_double_equal(const(void)* v1, const(void)* v2) nothrow;
25334 uint g_double_hash(const(void)* v) nothrow;
25335 char* g_dpgettext(char* domain, char* msgctxtid, size_t msgidoffset) nothrow;
25336 char* g_dpgettext2(char* domain, char* context, char* msgid) nothrow;
25337 char* g_environ_getenv(char** envp, char* variable) nothrow;
25338 char** /*new*/ g_environ_setenv(char** envp, char* variable, char* value, int overwrite) nothrow;
25339 char** /*new*/ g_environ_unsetenv(char** envp, char* variable) nothrow;
25340 FileError g_file_error_from_errno(int err_no) nothrow;
25341 Quark g_file_error_quark() nothrow;
25342 int g_file_get_contents(char* filename, /*out*/ ubyte** contents, /*out*/ size_t* length, GLib2.Error** error) nothrow;
25343 int g_file_open_tmp(char* tmpl, /*out*/ char** name_used, GLib2.Error** error) nothrow;
25344 char* /*new*/ g_file_read_link(char* filename, GLib2.Error** error) nothrow;
25345 int g_file_set_contents(char* filename, ubyte* contents, ssize_t length, GLib2.Error** error) nothrow;
25346 int g_file_test(char* filename, FileTest test) nothrow;
25347 char* /*new*/ g_filename_display_basename(char* filename) nothrow;
25348 char* /*new*/ g_filename_display_name(char* filename) nothrow;
25349 char* /*new*/ g_filename_from_uri(char* uri, char** hostname, GLib2.Error** error) nothrow;
25350 char* /*new*/ g_filename_from_utf8(char* utf8string, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error) nothrow;
25351 char* /*new*/ g_filename_to_uri(char* filename, char* hostname, GLib2.Error** error) nothrow;
25352 char* /*new*/ g_filename_to_utf8(char* opsysstring, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error) nothrow;
25353 char* /*new*/ g_find_program_in_path(char* program) nothrow;
25354 char* /*new*/ g_format_size(ulong size) nothrow;
25355 char* /*new*/ g_format_size_for_display(long size) nothrow;
25356 char* /*new*/ g_format_size_full(ulong size, FormatSizeFlags flags) nothrow;
25357 int g_fprintf(FILE* file, char* format, ...) nothrow;
25358 void g_free(void* mem) nothrow;
25359 char* g_get_application_name() nothrow;
25360 int g_get_charset(char** charset) nothrow;
25361 char* /*new*/ g_get_codeset() nothrow;
25362 char* /*new*/ g_get_current_dir() nothrow;
25363 void g_get_current_time(TimeVal* result) nothrow;
25364 char** /*new*/ g_get_environ() nothrow;
25365 int g_get_filename_charsets(char*** charsets) nothrow;
25366 char* g_get_home_dir() nothrow;
25367 char* g_get_host_name() nothrow;
25368 char** g_get_language_names() nothrow;
25369 char** /*new*/ g_get_locale_variants(char* locale) nothrow;
25370 long g_get_monotonic_time() nothrow;
25371 char* /*new*/ g_get_prgname() nothrow;
25372 char* g_get_real_name() nothrow;
25373 long g_get_real_time() nothrow;
25374 char** g_get_system_config_dirs() nothrow;
25375 char** g_get_system_data_dirs() nothrow;
25376 char* g_get_tmp_dir() nothrow;
25377 char* g_get_user_cache_dir() nothrow;
25378 char* g_get_user_config_dir() nothrow;
25379 char* g_get_user_data_dir() nothrow;
25380 char* g_get_user_name() nothrow;
25381 char* g_get_user_runtime_dir() nothrow;
25382 char* g_get_user_special_dir(UserDirectory directory) nothrow;
25383 char* g_getenv(char* variable) nothrow;
25384 int g_hostname_is_ascii_encoded(char* hostname) nothrow;
25385 int g_hostname_is_ip_address(char* hostname) nothrow;
25386 int g_hostname_is_non_ascii(char* hostname) nothrow;
25387 char* /*new*/ g_hostname_to_ascii(char* hostname) nothrow;
25388 char* /*new*/ g_hostname_to_unicode(char* hostname) nothrow;
25389 uint g_idle_add(SourceFunc function_, void* data) nothrow;
25390 uint g_idle_add_full(int priority, SourceFunc function_, void* data, DestroyNotify notify) nothrow;
25391 int g_idle_remove_by_data(void* data) nothrow;
25392 Source* /*new*/ g_idle_source_new() nothrow;
25393 int g_int64_equal(const(void)* v1, const(void)* v2) nothrow;
25394 uint g_int64_hash(const(void)* v) nothrow;
25395 int g_int_equal(const(void)* v1, const(void)* v2) nothrow;
25396 uint g_int_hash(const(void)* v) nothrow;
25397 char* g_intern_static_string(char* string_=null) nothrow;
25398 char* g_intern_string(char* string_=null) nothrow;
25399 uint g_io_add_watch(IOChannel* channel, IOCondition condition, IOFunc func, void* user_data) nothrow;
25400 uint g_io_add_watch_full(IOChannel* channel, int priority, IOCondition condition, IOFunc func, void* user_data, DestroyNotify notify) nothrow;
25401 Source* /*new*/ g_io_create_watch(IOChannel* channel, IOCondition condition) nothrow;
25402 char** /*new*/ g_listenv() nothrow;
25403 char* /*new*/ g_locale_from_utf8(char* utf8string, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error) nothrow;
25404 char* /*new*/ g_locale_to_utf8(char* opsysstring, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error) nothrow;
25405 void g_log(char* log_domain, LogLevelFlags log_level, char* format, ...) nothrow;
25406 void g_log_default_handler(char* log_domain, LogLevelFlags log_level, char* message, void* unused_data) nothrow;
25407 void g_log_remove_handler(char* log_domain, uint handler_id) nothrow;
25408 LogLevelFlags g_log_set_always_fatal(LogLevelFlags fatal_mask) nothrow;
25409 LogFunc g_log_set_default_handler(LogFunc log_func, void* user_data) nothrow;
25410 LogLevelFlags g_log_set_fatal_mask(char* log_domain, LogLevelFlags fatal_mask) nothrow;
25411 uint g_log_set_handler(char* log_domain, LogLevelFlags log_levels, LogFunc log_func, void* user_data) nothrow;
25412 void g_logv(char* log_domain, LogLevelFlags log_level, char* format, va_list args) nothrow;
25413 Source* g_main_current_source() nothrow;
25414 int g_main_depth() nothrow;
25415 void* g_malloc(size_t n_bytes) nothrow;
25416 void* g_malloc0(size_t n_bytes) nothrow;
25417 void* g_malloc0_n(size_t n_blocks, size_t n_block_bytes) nothrow;
25418 void* g_malloc_n(size_t n_blocks, size_t n_block_bytes) nothrow;
25419 int g_markup_collect_attributes(char* element_name, char** attribute_names, char** attribute_values, Error** error, MarkupCollectType first_type, char* first_attr, ...) nothrow;
25420 Quark g_markup_error_quark() nothrow;
25421 char* /*new*/ g_markup_escape_text(char* text, ssize_t length) nothrow;
25422 char* /*new*/ g_markup_printf_escaped(char* format, ...) nothrow;
25423 char* /*new*/ g_markup_vprintf_escaped(char* format, va_list args) nothrow;
25424 int g_mem_is_system_malloc() nothrow;
25425 void g_mem_profile() nothrow;
25426 void g_mem_set_vtable(MemVTable* vtable) nothrow;
25427 void* g_memdup(const(void)* mem, uint byte_size) nothrow;
25428 int g_mkdir_with_parents(char* pathname, int mode) nothrow;
25429 char* /*new*/ g_mkdtemp(char* tmpl) nothrow;
25430 char* /*new*/ g_mkdtemp_full(char* tmpl, int mode) nothrow;
25431 int g_mkstemp(char* tmpl) nothrow;
25432 int g_mkstemp_full(char* tmpl, int flags, int mode) nothrow;
25433 void g_nullify_pointer(void** nullify_location) nothrow;
25434 void g_on_error_query(char* prg_name) nothrow;
25435 void g_on_error_stack_trace(char* prg_name) nothrow;
25436 Quark g_option_error_quark() nothrow;
25437 uint g_parse_debug_string(char* string_, DebugKey* keys, uint nkeys) nothrow;
25438 char* /*new*/ g_path_get_basename(char* file_name) nothrow;
25439 char* /*new*/ g_path_get_dirname(char* file_name) nothrow;
25440 int g_path_is_absolute(char* file_name) nothrow;
25441 char* g_path_skip_root(char* file_name) nothrow;
25442 int g_pattern_match(PatternSpec* pspec, uint string_length, char* string_, char* string_reversed) nothrow;
25443 int g_pattern_match_simple(char* pattern, char* string_) nothrow;
25444 int g_pattern_match_string(PatternSpec* pspec, char* string_) nothrow;
25445 void g_pointer_bit_lock(void* address, int lock_bit) nothrow;
25446 int g_pointer_bit_trylock(void* address, int lock_bit) nothrow;
25447 void g_pointer_bit_unlock(void* address, int lock_bit) nothrow;
25448 int g_poll(PollFD* fds, uint nfds, int timeout) nothrow;
25449 void g_prefix_error(Error** err, char* format, ...) nothrow;
25450 void g_print(char* format, ...) nothrow;
25451 void g_printerr(char* format, ...) nothrow;
25452 int g_printf(char* format, ...) nothrow;
25453 size_t g_printf_string_upper_bound(char* format, va_list args) nothrow;
25454 void g_propagate_error(Error** dest, Error* src) nothrow;
25455 void g_propagate_prefixed_error(Error** dest, Error* src, char* format, ...) nothrow;
25456 void g_qsort_with_data(const(void)* pbase, int total_elems, size_t size, CompareDataFunc compare_func, void* user_data) nothrow;
25457 Quark g_quark_from_static_string(char* string_=null) nothrow;
25458 Quark g_quark_from_string(char* string_=null) nothrow;
25459 char* g_quark_to_string(Quark quark) nothrow;
25460 Quark g_quark_try_string(char* string_=null) nothrow;
25461 double g_random_double() nothrow;
25462 double g_random_double_range(double begin, double end) nothrow;
25463 uint g_random_int() nothrow;
25464 int g_random_int_range(int begin, int end) nothrow;
25465 void g_random_set_seed(uint seed) nothrow;
25466 void* g_realloc(void* mem, size_t n_bytes) nothrow;
25467 void* g_realloc_n(void* mem, size_t n_blocks, size_t n_block_bytes) nothrow;
25468 void g_reload_user_special_dirs_cache() nothrow;
25469 void g_return_if_fail_warning(char* log_domain, char* pretty_function, char* expression) nothrow;
25470 int g_rmdir(char* filename) nothrow;
25471 void g_set_application_name(char* application_name) nothrow;
25472 void g_set_error(Error** err, Quark domain, int code, char* format, ...) nothrow;
25473 void g_set_error_literal(Error** err, Quark domain, int code, char* message) nothrow;
25474 void g_set_prgname(char* prgname) nothrow;
25475 PrintFunc g_set_print_handler(PrintFunc func) nothrow;
25476 PrintFunc g_set_printerr_handler(PrintFunc func) nothrow;
25477 int g_setenv(char* variable, char* value, int overwrite) nothrow;
25478 Quark g_shell_error_quark() nothrow;
25479 int g_shell_parse_argv(char* command_line, /*out*/ int* argcp, /*out*/ char*** argvp, GLib2.Error** error) nothrow;
25480 char* /*new*/ g_shell_quote(char* unquoted_string) nothrow;
25481 char* /*new*/ g_shell_unquote(char* quoted_string, GLib2.Error** error) nothrow;
25482 void* g_slice_alloc(size_t block_size) nothrow;
25483 void* g_slice_alloc0(size_t block_size) nothrow;
25484 void* g_slice_copy(size_t block_size, const(void)* mem_block) nothrow;
25485 void g_slice_free1(size_t block_size, void* mem_block) nothrow;
25486 void g_slice_free_chain_with_offset(size_t block_size, void* mem_chain, size_t next_offset) nothrow;
25487 long g_slice_get_config(SliceConfig ckey) nothrow;
25488 long* g_slice_get_config_state(SliceConfig ckey, long address, uint* n_values) nothrow;
25489 void g_slice_set_config(SliceConfig ckey, long value) nothrow;
25490 int g_snprintf(char* string_, c_ulong n, char* format, ...) nothrow;
25491 uint g_spaced_primes_closest(uint num) nothrow;
25492 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) nothrow;
25493 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) nothrow;
25494 void g_spawn_close_pid(Pid pid) nothrow;
25495 int g_spawn_command_line_async(char* command_line, GLib2.Error** error) nothrow;
25496 int g_spawn_command_line_sync(char* command_line, /*out*/ ubyte** standard_output, /*out*/ ubyte** standard_error, /*out*/ int* exit_status, GLib2.Error** error) nothrow;
25497 Quark g_spawn_error_quark() nothrow;
25498 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) nothrow;
25499 int g_sprintf(char* string_, char* format, ...) nothrow;
25500 char* /*new*/ g_stpcpy(char* dest, char* src) nothrow;
25501 int g_str_equal(const(void)* v1, const(void)* v2) nothrow;
25502 int g_str_has_prefix(char* str, char* prefix) nothrow;
25503 int g_str_has_suffix(char* str, char* suffix) nothrow;
25504 uint g_str_hash(const(void)* v) nothrow;
25505 char* /*new*/ g_strcanon(char* string_, char* valid_chars, char substitutor) nothrow;
25506 int g_strcasecmp(char* s1, char* s2) nothrow;
25507 char* /*new*/ g_strchomp(char* string_) nothrow;
25508 char* /*new*/ g_strchug(char* string_) nothrow;
25509 int g_strcmp0(char* str1, char* str2) nothrow;
25510 char* /*new*/ g_strcompress(char* source) nothrow;
25511 char* /*new*/ g_strconcat(char* string1, ...) nothrow;
25512 char* /*new*/ g_strdelimit(char* string_, char* delimiters, char new_delimiter) nothrow;
25513 char* /*new*/ g_strdown(char* string_) nothrow;
25514 char* /*new*/ g_strdup(char* str) nothrow;
25515 char* /*new*/ g_strdup_printf(char* format, ...) nothrow;
25516 char* /*new*/ g_strdup_vprintf(char* format, va_list args) nothrow;
25517 char** g_strdupv(char** str_array) nothrow;
25518 char* g_strerror(int errnum) nothrow;
25519 char* /*new*/ g_strescape(char* source, char* exceptions) nothrow;
25520 void g_strfreev(char** str_array) nothrow;
25521 String* /*new*/ g_string_new(char* init) nothrow;
25522 String* /*new*/ g_string_new_len(char* init, ssize_t len) nothrow;
25523 String* /*new*/ g_string_sized_new(size_t dfl_size) nothrow;
25524 char* g_strip_context(char* msgid, char* msgval) nothrow;
25525 char* /*new*/ g_strjoin(char* separator, ...) nothrow;
25526 char* /*new*/ g_strjoinv(char* separator, char** str_array) nothrow;
25527 size_t g_strlcat(char* dest, char* src, size_t dest_size) nothrow;
25528 size_t g_strlcpy(char* dest, char* src, size_t dest_size) nothrow;
25529 int g_strncasecmp(char* s1, char* s2, uint n) nothrow;
25530 char* /*new*/ g_strndup(char* str, size_t n) nothrow;
25531 char* /*new*/ g_strnfill(size_t length, char fill_char) nothrow;
25532 char* /*new*/ g_strreverse(char* string_) nothrow;
25533 char* /*new*/ g_strrstr(char* haystack, char* needle) nothrow;
25534 char* /*new*/ g_strrstr_len(char* haystack, ssize_t haystack_len, char* needle) nothrow;
25535 char* g_strsignal(int signum) nothrow;
25536 char** g_strsplit(char* string_, char* delimiter, int max_tokens) nothrow;
25537 char** g_strsplit_set(char* string_, char* delimiters, int max_tokens) nothrow;
25538 char* /*new*/ g_strstr_len(char* haystack, ssize_t haystack_len, char* needle) nothrow;
25539 double g_strtod(char* nptr, char** endptr) nothrow;
25540 char* /*new*/ g_strup(char* string_) nothrow;
25541 Type g_strv_get_type() nothrow;
25542 uint g_strv_length(char** str_array) nothrow;
25543 void g_test_add_data_func(char* testpath, const(void)* test_data, TestDataFunc test_func) nothrow;
25544 void g_test_add_func(char* testpath, TestFunc test_func) nothrow;
25545 void g_test_add_vtable(char* testpath, size_t data_size, const(void)* test_data, TestFixtureFunc data_setup, TestFixtureFunc data_test, TestFixtureFunc data_teardown) nothrow;
25546 void g_test_bug(char* bug_uri_snippet) nothrow;
25547 void g_test_bug_base(char* uri_pattern) nothrow;
25548 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) nothrow;
25549 TestSuite* g_test_create_suite(char* suite_name) nothrow;
25550 void g_test_fail() nothrow;
25551 TestSuite* g_test_get_root() nothrow;
25552 void g_test_init(int* argc, char*** argv, ...) nothrow;
25553 void g_test_log_set_fatal_handler(TestLogFatalFunc log_func, void* user_data) nothrow;
25554 char* g_test_log_type_name(TestLogType log_type) nothrow;
25555 void g_test_maximized_result(double maximized_quantity, char* format, ...) nothrow;
25556 void g_test_message(char* format, ...) nothrow;
25557 void g_test_minimized_result(double minimized_quantity, char* format, ...) nothrow;
25558 void g_test_queue_destroy(DestroyNotify destroy_func, void* destroy_data) nothrow;
25559 void g_test_queue_free(void* gfree_pointer) nothrow;
25560 double g_test_rand_double() nothrow;
25561 double g_test_rand_double_range(double range_start, double range_end) nothrow;
25562 int g_test_rand_int() nothrow;
25563 int g_test_rand_int_range(int begin, int end) nothrow;
25564 int g_test_run() nothrow;
25565 int g_test_run_suite(TestSuite* suite) nothrow;
25566 double g_test_timer_elapsed() nothrow;
25567 double g_test_timer_last() nothrow;
25568 void g_test_timer_start() nothrow;
25569 void g_test_trap_assertions(char* domain, char* file, int line, char* func, ulong assertion_flags, char* pattern) nothrow;
25570 int g_test_trap_fork(ulong usec_timeout, TestTrapFlags test_trap_flags) nothrow;
25571 int g_test_trap_has_passed() nothrow;
25572 int g_test_trap_reached_timeout() nothrow;
25573 uint g_timeout_add(uint interval, SourceFunc function_, void* data) nothrow;
25574 uint g_timeout_add_full(int priority, uint interval, SourceFunc function_, void* data, DestroyNotify notify) nothrow;
25575 uint g_timeout_add_seconds(uint interval, SourceFunc function_, void* data) nothrow;
25576 uint g_timeout_add_seconds_full(int priority, uint interval, SourceFunc function_, void* data, DestroyNotify notify) nothrow;
25577 Source* /*new*/ g_timeout_source_new(uint interval) nothrow;
25578 Source* /*new*/ g_timeout_source_new_seconds(uint interval) nothrow;
25579 void* g_try_malloc(size_t n_bytes) nothrow;
25580 void* g_try_malloc0(size_t n_bytes) nothrow;
25581 void* g_try_malloc0_n(size_t n_blocks, size_t n_block_bytes) nothrow;
25582 void* g_try_malloc_n(size_t n_blocks, size_t n_block_bytes) nothrow;
25583 void* g_try_realloc(void* mem, size_t n_bytes) nothrow;
25584 void* g_try_realloc_n(void* mem, size_t n_blocks, size_t n_block_bytes) nothrow;
25585 wchar* g_ucs4_to_utf16(dchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error) nothrow;
25586 char* /*new*/ g_ucs4_to_utf8(dchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error) nothrow;
25587 UnicodeBreakType g_unichar_break_type(dchar c) nothrow;
25588 int g_unichar_combining_class(dchar uc) nothrow;
25589 int g_unichar_compose(dchar a, dchar b, dchar* ch) nothrow;
25590 int g_unichar_decompose(dchar ch, dchar* a, dchar* b) nothrow;
25591 int g_unichar_digit_value(dchar c) nothrow;
25592 size_t g_unichar_fully_decompose(dchar ch, int compat, dchar* result, size_t result_len) nothrow;
25593 int g_unichar_get_mirror_char(dchar ch, dchar* mirrored_ch) nothrow;
25594 UnicodeScript g_unichar_get_script(dchar ch) nothrow;
25595 int g_unichar_isalnum(dchar c) nothrow;
25596 int g_unichar_isalpha(dchar c) nothrow;
25597 int g_unichar_iscntrl(dchar c) nothrow;
25598 int g_unichar_isdefined(dchar c) nothrow;
25599 int g_unichar_isdigit(dchar c) nothrow;
25600 int g_unichar_isgraph(dchar c) nothrow;
25601 int g_unichar_islower(dchar c) nothrow;
25602 int g_unichar_ismark(dchar c) nothrow;
25603 int g_unichar_isprint(dchar c) nothrow;
25604 int g_unichar_ispunct(dchar c) nothrow;
25605 int g_unichar_isspace(dchar c) nothrow;
25606 int g_unichar_istitle(dchar c) nothrow;
25607 int g_unichar_isupper(dchar c) nothrow;
25608 int g_unichar_iswide(dchar c) nothrow;
25609 int g_unichar_iswide_cjk(dchar c) nothrow;
25610 int g_unichar_isxdigit(dchar c) nothrow;
25611 int g_unichar_iszerowidth(dchar c) nothrow;
25612 int g_unichar_to_utf8(dchar c, char* outbuf) nothrow;
25613 dchar g_unichar_tolower(dchar c) nothrow;
25614 dchar g_unichar_totitle(dchar c) nothrow;
25615 dchar g_unichar_toupper(dchar c) nothrow;
25616 UnicodeType g_unichar_type(dchar c) nothrow;
25617 int g_unichar_validate(dchar ch) nothrow;
25618 int g_unichar_xdigit_value(dchar c) nothrow;
25619 dchar* g_unicode_canonical_decomposition(dchar ch, size_t* result_len) nothrow;
25620 void g_unicode_canonical_ordering(dchar* string_, size_t len) nothrow;
25621 UnicodeScript g_unicode_script_from_iso15924(uint iso15924) nothrow;
25622 uint g_unicode_script_to_iso15924(UnicodeScript script) nothrow;
25623 int g_unlink(char* filename) nothrow;
25624 void g_unsetenv(char* variable) nothrow;
25625 char* /*new*/ g_uri_escape_string(char* unescaped, char* reserved_chars_allowed, int allow_utf8) nothrow;
25626 char** g_uri_list_extract_uris(char* uri_list) nothrow;
25627 char* /*new*/ g_uri_parse_scheme(char* uri) nothrow;
25628 char* /*new*/ g_uri_unescape_segment(char* escaped_string, char* escaped_string_end, char* illegal_characters) nothrow;
25629 char* /*new*/ g_uri_unescape_string(char* escaped_string, char* illegal_characters) nothrow;
25630 void g_usleep(c_ulong microseconds) nothrow;
25631 dchar* g_utf16_to_ucs4(wchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error) nothrow;
25632 char* /*new*/ g_utf16_to_utf8(wchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error) nothrow;
25633 char* /*new*/ g_utf8_casefold(char* str, ssize_t len) nothrow;
25634 int g_utf8_collate(char* str1, char* str2) nothrow;
25635 char* /*new*/ g_utf8_collate_key(char* str, ssize_t len) nothrow;
25636 char* /*new*/ g_utf8_collate_key_for_filename(char* str, ssize_t len) nothrow;
25637 char* /*new*/ g_utf8_find_next_char(char* p, char* end) nothrow;
25638 char* /*new*/ g_utf8_find_prev_char(char* str, char* p) nothrow;
25639 dchar g_utf8_get_char(char* p) nothrow;
25640 dchar g_utf8_get_char_validated(char* p, ssize_t max_len) nothrow;
25641 char* /*new*/ g_utf8_normalize(char* str, ssize_t len, NormalizeMode mode) nothrow;
25642 char* /*new*/ g_utf8_offset_to_pointer(char* str, c_long offset) nothrow;
25643 c_long g_utf8_pointer_to_offset(char* str, char* pos) nothrow;
25644 char* /*new*/ g_utf8_prev_char(char* p) nothrow;
25645 char* /*new*/ g_utf8_strchr(char* p, ssize_t len, dchar c) nothrow;
25646 char* /*new*/ g_utf8_strdown(char* str, ssize_t len) nothrow;
25647 c_long g_utf8_strlen(char* p, ssize_t max) nothrow;
25648 char* /*new*/ g_utf8_strncpy(char* dest, char* src, size_t n) nothrow;
25649 char* /*new*/ g_utf8_strrchr(char* p, ssize_t len, dchar c) nothrow;
25650 char* /*new*/ g_utf8_strreverse(char* str, ssize_t len) nothrow;
25651 char* /*new*/ g_utf8_strup(char* str, ssize_t len) nothrow;
25652 char* /*new*/ g_utf8_substring(char* str, c_long start_pos, c_long end_pos) nothrow;
25653 dchar* g_utf8_to_ucs4(char* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error) nothrow;
25654 dchar* g_utf8_to_ucs4_fast(char* str, c_long len, c_long* items_written) nothrow;
25655 wchar* g_utf8_to_utf16(char* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error) nothrow;
25656 int g_utf8_validate(char* str, ssize_t max_len, /*out*/ char** end=null) nothrow;
25657 Type g_variant_get_gtype() nothrow;
25658 VariantType* g_variant_get_type(Variant* value) nothrow;
25659 int g_vasprintf(char** string_, char* format, va_list args) nothrow;
25660 int g_vfprintf(FILE* file, char* format, va_list args) nothrow;
25661 int g_vprintf(char* format, va_list args) nothrow;
25662 int g_vsnprintf(char* string_, c_ulong n, char* format, va_list args) nothrow;
25663 int g_vsprintf(char* string_, char* format, va_list args) nothrow;
25664 void g_warn_message(char* domain, char* file, int line, char* func, char* warnexpr) nothrow;