Support for PangoFT2, PangoCairo, fontconfig2, freetype22, GL, Clutter, ClutterX11...
[girtod.git] / gtk2 / glib2.d
blobde9f3bcc6d7967aed818fb63543ef6ee16e31c10
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 // <--- mixin/GLib2__MODULE_HEAD.d ---
46 alias ubyte DateDay;
47 alias ushort DateYear;
49 // A type which is used to hold a process identification.
50 //
51 // On UNIX, processes are identified by a process id (an integer),
52 // while Windows uses process handles (which are pointers).
53 alias int Pid;
55 // A GQuark is a non-zero integer which uniquely identifies a
56 // particular string. A GQuark value of zero is associated to %NULL.
57 alias uint Quark;
58 // A C representable type name for #G_TYPE_STRV.
59 alias void* Strv;
60 alias int Time;
61 // A value representing an interval of time, in microseconds.
62 alias long TimeSpan;
64 // A numerical value which represents the unique identifier of a registered
65 // type.
66 alias size_t Type;
67 enum int ALLOCATOR_LIST = 1;
68 enum int ALLOCATOR_NODE = 3;
69 enum int ALLOCATOR_SLIST = 2;
70 enum int ALLOC_AND_FREE = 2;
71 enum int ALLOC_ONLY = 1;
72 enum int ASCII_DTOSTR_BUF_SIZE = 39;
73 enum int ATOMIC_OP_USE_GCC_BUILTINS = 1;
75 // The #GAllocator struct contains private data. and should only be
76 // accessed using the following functions.
77 struct Allocator {
79 // Frees all of the memory allocated by the #GAllocator.
80 //
81 // Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
82 // allocator</link> instead
83 void free() {
84 g_allocator_free(&this);
87 // Unintrospectable function: new() / g_allocator_new()
88 // Creates a new #GAllocator.
89 //
90 // Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
91 // allocator</link> instead
92 // <name>: the name of the #GAllocator. This name is used to set the name of the #GMemChunk used by the #GAllocator, and is only used for debugging.
93 // <n_preallocs>: the number of elements in each block of memory allocated. Larger blocks mean less calls to g_malloc(), but some memory may be wasted. (GLib uses 128 elements per block by default.) The value must be between 1 and 65535.
94 static Allocator* new_(char* name, uint n_preallocs) {
95 return g_allocator_new(name, n_preallocs);
99 // Contains the public fields of an <link linkend="glib-Arrays">Array</link>.
100 struct Array {
101 char* data;
102 uint len;
105 // Unintrospectable function: append_vals() / g_array_append_vals()
106 // Adds @len elements onto the end of the array.
107 // <array>: a #GArray.
108 // <data>: a pointer to the elements to append to the end of the array.
109 // <len>: the number of elements to append.
110 static Array* append_vals(Array* array, const(void)* data, uint len) {
111 return g_array_append_vals(array, data, len);
114 // Frees the memory allocated for the #GArray. If @free_segment is
115 // %TRUE it frees the memory block holding the elements as well and
116 // also each element if @array has a @element_free_func set. Pass
117 // %FALSE if you want to free the #GArray wrapper but preserve the
118 // underlying array for use elsewhere. If the reference count of @array
119 // is greater than one, the #GArray wrapper is preserved but the size
120 // of @array will be set to zero.
122 // <note><para>If array elements contain dynamically-allocated memory,
123 // they should be freed separately.</para></note>
124 // <array>: a #GArray.
125 // <free_segment>: if %TRUE the actual element data is freed as well.
126 static char* /*new*/ free(Array* array, int free_segment) {
127 return g_array_free(array, free_segment);
130 // Gets the size of the elements in @array.
131 // RETURNS: Size of each element, in bytes.
132 // <array>: A #GArray.
133 static uint get_element_size(Array* array) {
134 return g_array_get_element_size(array);
137 // Unintrospectable function: insert_vals() / g_array_insert_vals()
138 // Inserts @len elements into a #GArray at the given index.
139 // <array>: a #GArray.
140 // <index_>: the index to place the elements at.
141 // <data>: a pointer to the elements to insert.
142 // <len>: the number of elements to insert.
143 static Array* insert_vals(Array* array, uint index_, const(void)* data, uint len) {
144 return g_array_insert_vals(array, index_, data, len);
147 // Unintrospectable function: new() / g_array_new()
148 // Creates a new #GArray with a reference count of 1.
149 // <zero_terminated>: %TRUE if the array should have an extra element at the end which is set to 0.
150 // <clear_>: %TRUE if #GArray elements should be automatically cleared to 0 when they are allocated.
151 // <element_size>: the size of each element in bytes.
152 static Array* new_(int zero_terminated, int clear_, uint element_size) {
153 return g_array_new(zero_terminated, clear_, element_size);
156 // Unintrospectable function: prepend_vals() / g_array_prepend_vals()
157 // Adds @len elements onto the start of the array.
159 // This operation is slower than g_array_append_vals() since the
160 // existing elements in the array have to be moved to make space for
161 // the new elements.
162 // <array>: a #GArray.
163 // <data>: a pointer to the elements to prepend to the start of the array.
164 // <len>: the number of elements to prepend.
165 static Array* prepend_vals(Array* array, const(void)* data, uint len) {
166 return g_array_prepend_vals(array, data, len);
169 // Unintrospectable function: ref() / g_array_ref()
170 // Atomically increments the reference count of @array by one. This
171 // function is MT-safe and may be called from any thread.
172 // RETURNS: The passed in #GArray.
173 // <array>: A #GArray.
174 static Array* ref_(Array* array) {
175 return g_array_ref(array);
178 // Unintrospectable function: remove_index() / g_array_remove_index()
179 // Removes the element at the given index from a #GArray. The following
180 // elements are moved down one place.
181 // <array>: a #GArray.
182 // <index_>: the index of the element to remove.
183 static Array* remove_index(Array* array, uint index_) {
184 return g_array_remove_index(array, index_);
187 // Unintrospectable function: remove_index_fast() / g_array_remove_index_fast()
188 // Removes the element at the given index from a #GArray. The last
189 // element in the array is used to fill in the space, so this function
190 // does not preserve the order of the #GArray. But it is faster than
191 // g_array_remove_index().
192 // <array>: a @GArray.
193 // <index_>: the index of the element to remove.
194 static Array* remove_index_fast(Array* array, uint index_) {
195 return g_array_remove_index_fast(array, index_);
198 // Unintrospectable function: remove_range() / g_array_remove_range()
199 // Removes the given number of elements starting at the given index
200 // from a #GArray. The following elements are moved to close the gap.
201 // <array>: a @GArray.
202 // <index_>: the index of the first element to remove.
203 // <length>: the number of elements to remove.
204 static Array* remove_range(Array* array, uint index_, uint length) {
205 return g_array_remove_range(array, index_, length);
208 // Unintrospectable function: set_size() / g_array_set_size()
209 // Sets the size of the array, expanding it if necessary. If the array
210 // was created with @clear_ set to %TRUE, the new elements are set to 0.
211 // <array>: a #GArray.
212 // <length>: the new size of the #GArray.
213 static Array* set_size(Array* array, uint length) {
214 return g_array_set_size(array, length);
217 // Unintrospectable function: sized_new() / g_array_sized_new()
218 // Creates a new #GArray with @reserved_size elements preallocated and
219 // a reference count of 1. This avoids frequent reallocation, if you
220 // are going to add many elements to the array. Note however that the
221 // size of the array is still 0.
222 // <zero_terminated>: %TRUE if the array should have an extra element at the end with all bits cleared.
223 // <clear_>: %TRUE if all bits in the array should be cleared to 0 on allocation.
224 // <element_size>: size of each element in the array.
225 // <reserved_size>: number of elements preallocated.
226 static Array* sized_new(int zero_terminated, int clear_, uint element_size, uint reserved_size) {
227 return g_array_sized_new(zero_terminated, clear_, element_size, reserved_size);
230 // Unintrospectable function: sort() / g_array_sort()
231 // Sorts a #GArray using @compare_func which should be a qsort()-style
232 // comparison function (returns less than zero for first arg is less
233 // than second arg, zero for equal, greater zero if first arg is
234 // greater than second arg).
236 // If two array elements compare equal, their order in the sorted array
237 // is undefined. If you want equal elements to keep their order &#8211; i.e.
238 // you want a stable sort &#8211; you can write a comparison function that,
239 // if two elements would otherwise compare equal, compares them by
240 // their addresses.
241 // <array>: a #GArray.
242 // <compare_func>: comparison function.
243 static void sort(Array* array, CompareFunc compare_func) {
244 g_array_sort(array, compare_func);
247 // Unintrospectable function: sort_with_data() / g_array_sort_with_data()
248 // Like g_array_sort(), but the comparison function receives an extra
249 // user data argument.
250 // <array>: a #GArray.
251 // <compare_func>: comparison function.
252 // <user_data>: data to pass to @compare_func.
253 static void sort_with_data(Array* array, CompareDataFunc compare_func, void* user_data) {
254 g_array_sort_with_data(array, compare_func, user_data);
257 // Atomically decrements the reference count of @array by one. If the
258 // reference count drops to 0, all memory allocated by the array is
259 // released. This function is MT-safe and may be called from any
260 // thread.
261 // <array>: A #GArray.
262 static void unref(Array* array) {
263 g_array_unref(array);
267 enum AsciiType {
268 ALNUM = 1,
269 ALPHA = 2,
270 CNTRL = 4,
271 DIGIT = 8,
272 GRAPH = 16,
273 LOWER = 32,
274 PRINT = 64,
275 PUNCT = 128,
276 SPACE = 256,
277 UPPER = 512,
278 XDIGIT = 1024
281 // The GAsyncQueue struct is an opaque data structure, which represents
282 // an asynchronous queue. It should only be accessed through the
283 // <function>g_async_queue_*</function> functions.
284 struct AsyncQueue {
286 // Returns the length of the queue, negative values mean waiting
287 // threads, positive values mean available entries in the
288 // @queue. Actually this function returns the number of data items in
289 // the queue minus the number of waiting threads. Thus a return value
290 // of 0 could mean 'n' entries in the queue and 'n' thread waiting.
291 // That can happen due to locking of the queue or due to
292 // scheduling.
293 // RETURNS: the length of the @queue.
294 int length() {
295 return g_async_queue_length(&this);
298 // Returns the length of the queue, negative values mean waiting
299 // threads, positive values mean available entries in the
300 // @queue. Actually this function returns the number of data items in
301 // the queue minus the number of waiting threads. Thus a return value
302 // of 0 could mean 'n' entries in the queue and 'n' thread waiting.
303 // That can happen due to locking of the queue or due to
304 // scheduling. This function must be called while holding the @queue's
305 // lock.
306 // RETURNS: the length of the @queue.
307 int length_unlocked() {
308 return g_async_queue_length_unlocked(&this);
311 // Acquires the @queue's lock. After that you can only call the
312 // <function>g_async_queue_*_unlocked()</function> function variants on that
313 // @queue. Otherwise it will deadlock.
314 void lock() {
315 g_async_queue_lock(&this);
318 // Unintrospectable method: pop() / g_async_queue_pop()
319 // Pops data from the @queue. This function blocks until data become
320 // available.
321 // RETURNS: data from the queue.
322 void* pop() {
323 return g_async_queue_pop(&this);
326 // Unintrospectable method: pop_unlocked() / g_async_queue_pop_unlocked()
327 // Pops data from the @queue. This function blocks until data become
328 // available. This function must be called while holding the @queue's
329 // lock.
330 // RETURNS: data from the queue.
331 void* pop_unlocked() {
332 return g_async_queue_pop_unlocked(&this);
335 // Pushes the @data into the @queue. @data must not be %NULL.
336 // <data>: @data to push into the @queue.
337 void push(void* data) {
338 g_async_queue_push(&this, data);
341 // Unintrospectable method: push_sorted() / g_async_queue_push_sorted()
342 // Inserts @data into @queue using @func to determine the new
343 // position.
345 // This function requires that the @queue is sorted before pushing on
346 // new elements.
348 // This function will lock @queue before it sorts the queue and unlock
349 // it when it is finished.
351 // For an example of @func see g_async_queue_sort().
352 // <data>: the @data to push into the @queue
353 // <func>: the #GCompareDataFunc is used to sort @queue. This function is passed two elements of the @queue. The function should return 0 if they are equal, a negative value if the first element should be higher in the @queue or a positive value if the first element should be lower in the @queue than the second element.
354 // <user_data>: user data passed to @func.
355 void push_sorted(void* data, CompareDataFunc func, void* user_data) {
356 g_async_queue_push_sorted(&this, data, func, user_data);
359 // Unintrospectable method: push_sorted_unlocked() / g_async_queue_push_sorted_unlocked()
360 // Inserts @data into @queue using @func to determine the new
361 // position.
363 // This function requires that the @queue is sorted before pushing on
364 // new elements.
366 // This function is called while holding the @queue's lock.
368 // For an example of @func see g_async_queue_sort().
369 // <data>: the @data to push into the @queue
370 // <func>: the #GCompareDataFunc is used to sort @queue. This function is passed two elements of the @queue. The function should return 0 if they are equal, a negative value if the first element should be higher in the @queue or a positive value if the first element should be lower in the @queue than the second element.
371 // <user_data>: user data passed to @func.
372 void push_sorted_unlocked(void* data, CompareDataFunc func, void* user_data) {
373 g_async_queue_push_sorted_unlocked(&this, data, func, user_data);
376 // Pushes the @data into the @queue. @data must not be %NULL. This
377 // function must be called while holding the @queue's lock.
378 // <data>: @data to push into the @queue.
379 void push_unlocked(void* data) {
380 g_async_queue_push_unlocked(&this, data);
383 // Unintrospectable method: ref() / g_async_queue_ref()
384 // Increases the reference count of the asynchronous @queue by 1. You
385 // do not need to hold the lock to call this function.
386 // RETURNS: the @queue that was passed in (since 2.6)
387 AsyncQueue* ref_() {
388 return g_async_queue_ref(&this);
391 // Increases the reference count of the asynchronous @queue by 1.
393 // so g_async_queue_ref() can be used regardless of the @queue's
394 // lock.
395 void ref_unlocked() {
396 g_async_queue_ref_unlocked(&this);
399 // Unintrospectable method: sort() / g_async_queue_sort()
400 // Sorts @queue using @func.
402 // This function will lock @queue before it sorts the queue and unlock
403 // it when it is finished.
405 // If you were sorting a list of priority numbers to make sure the
406 // lowest priority would be at the top of the queue, you could use:
407 // |[
408 // gint32 id1;
409 // gint32 id2;
411 // id1 = GPOINTER_TO_INT (element1);
412 // id2 = GPOINTER_TO_INT (element2);
414 // return (id1 > id2 ? +1 : id1 == id2 ? 0 : -1);
415 // ]|
416 // <func>: the #GCompareDataFunc is used to sort @queue. This function is passed two elements of the @queue. The function should return 0 if they are equal, a negative value if the first element should be higher in the @queue or a positive value if the first element should be lower in the @queue than the second element.
417 // <user_data>: user data passed to @func
418 void sort(CompareDataFunc func, void* user_data) {
419 g_async_queue_sort(&this, func, user_data);
422 // Unintrospectable method: sort_unlocked() / g_async_queue_sort_unlocked()
423 // Sorts @queue using @func.
425 // This function is called while holding the @queue's lock.
426 // <func>: the #GCompareDataFunc is used to sort @queue. This function is passed two elements of the @queue. The function should return 0 if they are equal, a negative value if the first element should be higher in the @queue or a positive value if the first element should be lower in the @queue than the second element.
427 // <user_data>: user data passed to @func
428 void sort_unlocked(CompareDataFunc func, void* user_data) {
429 g_async_queue_sort_unlocked(&this, func, user_data);
432 // Unintrospectable method: timed_pop() / g_async_queue_timed_pop()
433 // Pops data from the @queue. If no data is received before @end_time,
434 // %NULL is returned.
436 // To easily calculate @end_time a combination of g_get_current_time()
437 // and g_time_val_add() can be used.
439 // received before @end_time.
440 // RETURNS: data from the queue or %NULL, when no data is
441 // <end_time>: a #GTimeVal, determining the final time.
442 void* timed_pop(TimeVal* end_time) {
443 return g_async_queue_timed_pop(&this, end_time);
446 // Unintrospectable method: timed_pop_unlocked() / g_async_queue_timed_pop_unlocked()
447 // Pops data from the @queue. If no data is received before @end_time,
448 // %NULL is returned. This function must be called while holding the
449 // @queue's lock.
451 // To easily calculate @end_time a combination of g_get_current_time()
452 // and g_time_val_add() can be used.
454 // received before @end_time.
455 // RETURNS: data from the queue or %NULL, when no data is
456 // <end_time>: a #GTimeVal, determining the final time.
457 void* timed_pop_unlocked(TimeVal* end_time) {
458 return g_async_queue_timed_pop_unlocked(&this, end_time);
461 // Unintrospectable method: try_pop() / g_async_queue_try_pop()
462 // Tries to pop data from the @queue. If no data is available, %NULL is
463 // returned.
465 // available immediately.
466 // RETURNS: data from the queue or %NULL, when no data is
467 void* try_pop() {
468 return g_async_queue_try_pop(&this);
471 // Unintrospectable method: try_pop_unlocked() / g_async_queue_try_pop_unlocked()
472 // Tries to pop data from the @queue. If no data is available, %NULL is
473 // returned. This function must be called while holding the @queue's
474 // lock.
476 // available immediately.
477 // RETURNS: data from the queue or %NULL, when no data is
478 void* try_pop_unlocked() {
479 return g_async_queue_try_pop_unlocked(&this);
481 // Releases the queue's lock.
482 void unlock() {
483 g_async_queue_unlock(&this);
486 // Decreases the reference count of the asynchronous @queue by 1. If
487 // the reference count went to 0, the @queue will be destroyed and the
488 // memory allocated will be freed. So you are not allowed to use the
489 // @queue afterwards, as it might have disappeared. You do not need to
490 // hold the lock to call this function.
491 void unref() {
492 g_async_queue_unref(&this);
495 // Decreases the reference count of the asynchronous @queue by 1 and
496 // releases the lock. This function must be called while holding the
497 // @queue's lock. If the reference count went to 0, the @queue will be
498 // destroyed and the memory allocated will be freed.
500 // so g_async_queue_unref() can be used regardless of the @queue's
501 // lock.
502 void unref_and_unlock() {
503 g_async_queue_unref_and_unlock(&this);
506 // Unintrospectable function: new() / g_async_queue_new()
507 // Creates a new asynchronous queue with the initial reference count of 1.
508 // RETURNS: the new #GAsyncQueue.
509 static AsyncQueue* new_() {
510 return g_async_queue_new();
513 // Unintrospectable function: new_full() / g_async_queue_new_full()
514 // Creates a new asynchronous queue with an initial reference count of 1 and
515 // sets up a destroy notify function that is used to free any remaining
516 // queue items when the queue is destroyed after the final unref.
517 // RETURNS: the new #GAsyncQueue.
518 // <item_free_func>: function to free queue elements
519 static AsyncQueue* new_full(DestroyNotify item_free_func) {
520 return g_async_queue_new_full(item_free_func);
524 enum int BIG_ENDIAN = 4321;
526 // The <structname>GBookmarkFile</structname> struct contains only
527 // private data and should not be directly accessed.
528 struct BookmarkFile {
530 // Adds the application with @name and @exec to the list of
531 // applications that have registered a bookmark for @uri into
532 // @bookmark.
534 // Every bookmark inside a #GBookmarkFile must have at least an
535 // application registered. Each application must provide a name, a
536 // command line useful for launching the bookmark, the number of times
537 // the bookmark has been registered by the application and the last
538 // time the application registered this bookmark.
540 // If @name is %NULL, the name of the application will be the
541 // same returned by g_get_application_name(); if @exec is %NULL, the
542 // command line will be a composition of the program name as
543 // returned by g_get_prgname() and the "%u" modifier, which will be
544 // expanded to the bookmark's URI.
546 // This function will automatically take care of updating the
547 // registrations count and timestamping in case an application
548 // with the same @name had already registered a bookmark for
549 // @uri inside @bookmark.
551 // If no bookmark for @uri is found, one is created.
552 // <uri>: a valid URI
553 // <name>: the name of the application registering the bookmark or %NULL
554 // <exec>: command line to be used to launch the bookmark or %NULL
555 void add_application(char* uri, char* name, char* exec) {
556 g_bookmark_file_add_application(&this, uri, name, exec);
559 // Adds @group to the list of groups to which the bookmark for @uri
560 // belongs to.
562 // If no bookmark for @uri is found then it is created.
563 // <uri>: a valid URI
564 // <group>: the group name to be added
565 void add_group(char* uri, char* group) {
566 g_bookmark_file_add_group(&this, uri, group);
568 // Frees a #GBookmarkFile.
569 void free() {
570 g_bookmark_file_free(&this);
573 // Gets the time the bookmark for @uri was added to @bookmark
575 // In the event the URI cannot be found, -1 is returned and
576 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
577 // RETURNS: a timestamp
578 // <uri>: a valid URI
579 time_t get_added(char* uri, GLib2.Error** error=null) {
580 return g_bookmark_file_get_added(&this, uri, error);
583 // Gets the registration informations of @app_name for the bookmark for
584 // @uri. See g_bookmark_file_set_app_info() for more informations about
585 // the returned data.
587 // The string returned in @app_exec must be freed.
589 // In the event the URI cannot be found, %FALSE is returned and
590 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the
591 // event that no application with name @app_name has registered a bookmark
592 // for @uri, %FALSE is returned and error is set to
593 // #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. In the event that unquoting
594 // the command line fails, an error of the #G_SHELL_ERROR domain is
595 // set and %FALSE is returned.
596 // RETURNS: %TRUE on success.
597 // <uri>: a valid URI
598 // <name>: an application's name
599 // <exec>: location for the command line of the application, or %NULL
600 // <count>: return location for the registration count, or %NULL
601 // <stamp>: return location for the last registration time, or %NULL
602 int get_app_info(char* uri, char* name, char** exec, uint* count, time_t* stamp, GLib2.Error** error=null) {
603 return g_bookmark_file_get_app_info(&this, uri, name, exec, count, stamp, error);
606 // Unintrospectable method: get_applications() / g_bookmark_file_get_applications()
607 // Retrieves the names of the applications that have registered the
608 // bookmark for @uri.
610 // In the event the URI cannot be found, %NULL is returned and
611 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
613 // Use g_strfreev() to free it.
614 // RETURNS: a newly allocated %NULL-terminated array of strings.
615 // <uri>: a valid URI
616 // <length>: return location of the length of the returned list, or %NULL
617 char** get_applications(char* uri, size_t* length, GLib2.Error** error=null) {
618 return g_bookmark_file_get_applications(&this, uri, length, error);
621 // Retrieves the description of the bookmark for @uri.
623 // In the event the URI cannot be found, %NULL is returned and
624 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
626 // URI cannot be found.
627 // RETURNS: a newly allocated string or %NULL if the specified
628 // <uri>: a valid URI
629 char* /*new*/ get_description(char* uri, GLib2.Error** error=null) {
630 return g_bookmark_file_get_description(&this, uri, error);
633 // Unintrospectable method: get_groups() / g_bookmark_file_get_groups()
634 // Retrieves the list of group names of the bookmark for @uri.
636 // In the event the URI cannot be found, %NULL is returned and
637 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
639 // The returned array is %NULL terminated, so @length may optionally
640 // be %NULL.
642 // Use g_strfreev() to free it.
643 // RETURNS: a newly allocated %NULL-terminated array of group names.
644 // <uri>: a valid URI
645 // <length>: return location for the length of the returned string, or %NULL
646 char** get_groups(char* uri, size_t* length, GLib2.Error** error=null) {
647 return g_bookmark_file_get_groups(&this, uri, length, error);
650 // Gets the icon of the bookmark for @uri.
652 // In the event the URI cannot be found, %FALSE is returned and
653 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
655 // You should free the returned strings.
656 // RETURNS: %TRUE if the icon for the bookmark for the URI was found.
657 // <uri>: a valid URI
658 // <href>: return location for the icon's location or %NULL
659 // <mime_type>: return location for the icon's MIME type or %NULL
660 int get_icon(char* uri, char** href, char** mime_type, GLib2.Error** error=null) {
661 return g_bookmark_file_get_icon(&this, uri, href, mime_type, error);
664 // Gets whether the private flag of the bookmark for @uri is set.
666 // In the event the URI cannot be found, %FALSE is returned and
667 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the
668 // event that the private flag cannot be found, %FALSE is returned and
669 // @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
670 // RETURNS: %TRUE if the private flag is set, %FALSE otherwise.
671 // <uri>: a valid URI
672 int get_is_private(char* uri, GLib2.Error** error=null) {
673 return g_bookmark_file_get_is_private(&this, uri, error);
676 // Retrieves the MIME type of the resource pointed by @uri.
678 // In the event the URI cannot be found, %NULL is returned and
679 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the
680 // event that the MIME type cannot be found, %NULL is returned and
681 // @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
683 // URI cannot be found.
684 // RETURNS: a newly allocated string or %NULL if the specified
685 // <uri>: a valid URI
686 char* /*new*/ get_mime_type(char* uri, GLib2.Error** error=null) {
687 return g_bookmark_file_get_mime_type(&this, uri, error);
690 // Gets the time when the bookmark for @uri was last modified.
692 // In the event the URI cannot be found, -1 is returned and
693 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
694 // RETURNS: a timestamp
695 // <uri>: a valid URI
696 time_t get_modified(char* uri, GLib2.Error** error=null) {
697 return g_bookmark_file_get_modified(&this, uri, error);
700 // Gets the number of bookmarks inside @bookmark.
701 // RETURNS: the number of bookmarks
702 int get_size() {
703 return g_bookmark_file_get_size(&this);
706 // Returns the title of the bookmark for @uri.
708 // If @uri is %NULL, the title of @bookmark is returned.
710 // In the event the URI cannot be found, %NULL is returned and
711 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
713 // URI cannot be found.
714 // RETURNS: a newly allocated string or %NULL if the specified
715 // <uri>: a valid URI or %NULL
716 char* /*new*/ get_title(char* uri, GLib2.Error** error=null) {
717 return g_bookmark_file_get_title(&this, uri, error);
720 // Unintrospectable method: get_uris() / g_bookmark_file_get_uris()
721 // Returns all URIs of the bookmarks in the bookmark file @bookmark.
722 // The array of returned URIs will be %NULL-terminated, so @length may
723 // optionally be %NULL.
725 // Use g_strfreev() to free it.
726 // RETURNS: a newly allocated %NULL-terminated array of strings.
727 // <length>: return location for the number of returned URIs, or %NULL
728 char** get_uris(size_t* length) {
729 return g_bookmark_file_get_uris(&this, length);
732 // Gets the time the bookmark for @uri was last visited.
734 // In the event the URI cannot be found, -1 is returned and
735 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
736 // RETURNS: a timestamp.
737 // <uri>: a valid URI
738 time_t get_visited(char* uri, GLib2.Error** error=null) {
739 return g_bookmark_file_get_visited(&this, uri, error);
742 // Checks whether the bookmark for @uri inside @bookmark has been
743 // registered by application @name.
745 // In the event the URI cannot be found, %FALSE is returned and
746 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
747 // RETURNS: %TRUE if the application @name was found
748 // <uri>: a valid URI
749 // <name>: the name of the application
750 int has_application(char* uri, char* name, GLib2.Error** error=null) {
751 return g_bookmark_file_has_application(&this, uri, name, error);
754 // Checks whether @group appears in the list of groups to which
755 // the bookmark for @uri belongs to.
757 // In the event the URI cannot be found, %FALSE is returned and
758 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
759 // RETURNS: %TRUE if @group was found.
760 // <uri>: a valid URI
761 // <group>: the group name to be searched
762 int has_group(char* uri, char* group, GLib2.Error** error=null) {
763 return g_bookmark_file_has_group(&this, uri, group, error);
766 // Looks whether the desktop bookmark has an item with its URI set to @uri.
767 // RETURNS: %TRUE if @uri is inside @bookmark, %FALSE otherwise
768 // <uri>: a valid URI
769 int has_item(char* uri) {
770 return g_bookmark_file_has_item(&this, uri);
773 // Loads a bookmark file from memory into an empty #GBookmarkFile
774 // structure. If the object cannot be created then @error is set to a
775 // #GBookmarkFileError.
776 // RETURNS: %TRUE if a desktop bookmark could be loaded.
777 // <data>: desktop bookmarks loaded in memory
778 // <length>: the length of @data in bytes
779 int load_from_data(char* data, size_t length, GLib2.Error** error=null) {
780 return g_bookmark_file_load_from_data(&this, data, length, error);
783 // This function looks for a desktop bookmark file named @file in the
784 // paths returned from g_get_user_data_dir() and g_get_system_data_dirs(),
785 // loads the file into @bookmark and returns the file's full path in
786 // @full_path. If the file could not be loaded then an %error is
787 // set to either a #GFileError or #GBookmarkFileError.
788 // RETURNS: %TRUE if a key file could be loaded, %FALSE othewise
789 // <file>: a relative path to a filename to open and parse
790 // <full_path>: return location for a string containing the full path of the file, or %NULL
791 int load_from_data_dirs(char* file, char** full_path, GLib2.Error** error=null) {
792 return g_bookmark_file_load_from_data_dirs(&this, file, full_path, error);
795 // Loads a desktop bookmark file into an empty #GBookmarkFile structure.
796 // If the file could not be loaded then @error is set to either a #GFileError
797 // or #GBookmarkFileError.
798 // RETURNS: %TRUE if a desktop bookmark file could be loaded
799 // <filename>: the path of a filename to load, in the GLib file name encoding
800 int load_from_file(char* filename, GLib2.Error** error=null) {
801 return g_bookmark_file_load_from_file(&this, filename, error);
804 // Changes the URI of a bookmark item from @old_uri to @new_uri. Any
805 // existing bookmark for @new_uri will be overwritten. If @new_uri is
806 // %NULL, then the bookmark is removed.
808 // In the event the URI cannot be found, %FALSE is returned and
809 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
810 // RETURNS: %TRUE if the URI was successfully changed
811 // <old_uri>: a valid URI
812 // <new_uri>: a valid URI, or %NULL
813 int move_item(char* old_uri, char* new_uri, GLib2.Error** error=null) {
814 return g_bookmark_file_move_item(&this, old_uri, new_uri, error);
817 // Removes application registered with @name from the list of applications
818 // that have registered a bookmark for @uri inside @bookmark.
820 // In the event the URI cannot be found, %FALSE is returned and
821 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
822 // In the event that no application with name @app_name has registered
823 // a bookmark for @uri, %FALSE is returned and error is set to
824 // #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED.
825 // RETURNS: %TRUE if the application was successfully removed.
826 // <uri>: a valid URI
827 // <name>: the name of the application
828 int remove_application(char* uri, char* name, GLib2.Error** error=null) {
829 return g_bookmark_file_remove_application(&this, uri, name, error);
832 // Removes @group from the list of groups to which the bookmark
833 // for @uri belongs to.
835 // In the event the URI cannot be found, %FALSE is returned and
836 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
837 // In the event no group was defined, %FALSE is returned and
838 // @error is set to #G_BOOKMARK_FILE_ERROR_INVALID_VALUE.
839 // RETURNS: %TRUE if @group was successfully removed.
840 // <uri>: a valid URI
841 // <group>: the group name to be removed
842 int remove_group(char* uri, char* group, GLib2.Error** error=null) {
843 return g_bookmark_file_remove_group(&this, uri, group, error);
846 // Removes the bookmark for @uri from the bookmark file @bookmark.
847 // RETURNS: %TRUE if the bookmark was removed successfully.
848 // <uri>: a valid URI
849 int remove_item(char* uri, GLib2.Error** error=null) {
850 return g_bookmark_file_remove_item(&this, uri, error);
853 // Sets the time the bookmark for @uri was added into @bookmark.
855 // If no bookmark for @uri is found then it is created.
856 // <uri>: a valid URI
857 // <added>: a timestamp or -1 to use the current time
858 void set_added(char* uri, time_t added) {
859 g_bookmark_file_set_added(&this, uri, added);
862 // Sets the meta-data of application @name inside the list of
863 // applications that have registered a bookmark for @uri inside
864 // @bookmark.
866 // You should rarely use this function; use g_bookmark_file_add_application()
867 // and g_bookmark_file_remove_application() instead.
869 // @name can be any UTF-8 encoded string used to identify an
870 // application.
871 // be expanded as the local file name retrieved from the bookmark's
872 // URI; "%u", which will be expanded as the bookmark's URI.
873 // The expansion is done automatically when retrieving the stored
874 // command line using the g_bookmark_file_get_app_info() function.
875 // @count is the number of times the application has registered the
876 // bookmark; if is < 0, the current registration count will be increased
877 // by one, if is 0, the application with @name will be removed from
878 // the list of registered applications.
879 // @stamp is the Unix time of the last registration; if it is -1, the
880 // current time will be used.
882 // If you try to remove an application by setting its registration count to
883 // zero, and no bookmark for @uri is found, %FALSE is returned and
884 // @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND; similarly,
885 // in the event that no application @name has registered a bookmark
886 // for @uri, %FALSE is returned and error is set to
887 // #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. Otherwise, if no bookmark
888 // for @uri is found, one is created.
890 // changed.
891 // RETURNS: %TRUE if the application's meta-data was successfully
892 // <uri>: a valid URI
893 // <name>: an application's name
894 // <exec>: an application's command line
895 // <count>: the number of registrations done for this application
896 // <stamp>: the time of the last registration for this application
897 int set_app_info(char* uri, char* name, char* exec, int count, time_t stamp, GLib2.Error** error=null) {
898 return g_bookmark_file_set_app_info(&this, uri, name, exec, count, stamp, error);
901 // Sets @description as the description of the bookmark for @uri.
903 // If @uri is %NULL, the description of @bookmark is set.
905 // If a bookmark for @uri cannot be found then it is created.
906 // <uri>: a valid URI or %NULL
907 // <description>: a string
908 void set_description(char* uri, char* description) {
909 g_bookmark_file_set_description(&this, uri, description);
912 // Sets a list of group names for the item with URI @uri. Each previously
913 // set group name list is removed.
915 // If @uri cannot be found then an item for it is created.
916 // <uri>: an item's URI
917 // <groups>: an array of group names, or %NULL to remove all groups
918 // <length>: number of group name values in @groups
919 void set_groups(char* uri, char** groups, size_t length) {
920 g_bookmark_file_set_groups(&this, uri, groups, length);
923 // Sets the icon for the bookmark for @uri. If @href is %NULL, unsets
924 // the currently set icon. @href can either be a full URL for the icon
925 // file or the icon name following the Icon Naming specification.
927 // If no bookmark for @uri is found one is created.
928 // <uri>: a valid URI
929 // <href>: the URI of the icon for the bookmark, or %NULL
930 // <mime_type>: the MIME type of the icon for the bookmark
931 void set_icon(char* uri, char* href, char* mime_type) {
932 g_bookmark_file_set_icon(&this, uri, href, mime_type);
935 // Sets the private flag of the bookmark for @uri.
937 // If a bookmark for @uri cannot be found then it is created.
938 // <uri>: a valid URI
939 // <is_private>: %TRUE if the bookmark should be marked as private
940 void set_is_private(char* uri, int is_private) {
941 g_bookmark_file_set_is_private(&this, uri, is_private);
944 // Sets @mime_type as the MIME type of the bookmark for @uri.
946 // If a bookmark for @uri cannot be found then it is created.
947 // <uri>: a valid URI
948 // <mime_type>: a MIME type
949 void set_mime_type(char* uri, char* mime_type) {
950 g_bookmark_file_set_mime_type(&this, uri, mime_type);
953 // Sets the last time the bookmark for @uri was last modified.
955 // If no bookmark for @uri is found then it is created.
957 // The "modified" time should only be set when the bookmark's meta-data
958 // was actually changed. Every function of #GBookmarkFile that
959 // modifies a bookmark also changes the modification time, except for
960 // g_bookmark_file_set_visited().
961 // <uri>: a valid URI
962 // <modified>: a timestamp or -1 to use the current time
963 void set_modified(char* uri, time_t modified) {
964 g_bookmark_file_set_modified(&this, uri, modified);
967 // Sets @title as the title of the bookmark for @uri inside the
968 // bookmark file @bookmark.
970 // If @uri is %NULL, the title of @bookmark is set.
972 // If a bookmark for @uri cannot be found then it is created.
973 // <uri>: a valid URI or %NULL
974 // <title>: a UTF-8 encoded string
975 void set_title(char* uri, char* title) {
976 g_bookmark_file_set_title(&this, uri, title);
979 // Sets the time the bookmark for @uri was last visited.
981 // If no bookmark for @uri is found then it is created.
983 // The "visited" time should only be set if the bookmark was launched,
984 // either using the command line retrieved by g_bookmark_file_get_app_info()
985 // or by the default application for the bookmark's MIME type, retrieved
986 // using g_bookmark_file_get_mime_type(). Changing the "visited" time
987 // does not affect the "modified" time.
988 // <uri>: a valid URI
989 // <visited>: a timestamp or -1 to use the current time
990 void set_visited(char* uri, time_t visited) {
991 g_bookmark_file_set_visited(&this, uri, visited);
994 // This function outputs @bookmark as a string.
996 // the contents of the #GBookmarkFile
997 // RETURNS: a newly allocated string holding
998 // <length>: return location for the length of the returned string, or %NULL
999 char* /*new*/ to_data(size_t* length, GLib2.Error** error=null) {
1000 return g_bookmark_file_to_data(&this, length, error);
1003 // This function outputs @bookmark into a file. The write process is
1004 // guaranteed to be atomic by using g_file_set_contents() internally.
1005 // RETURNS: %TRUE if the file was successfully written.
1006 // <filename>: path of the output file
1007 int to_file(char* filename, GLib2.Error** error=null) {
1008 return g_bookmark_file_to_file(&this, filename, error);
1010 static Quark error_quark() {
1011 return g_bookmark_file_error_quark();
1014 // Unintrospectable function: new() / g_bookmark_file_new()
1015 // Creates a new empty #GBookmarkFile object.
1017 // Use g_bookmark_file_load_from_file(), g_bookmark_file_load_from_data()
1018 // or g_bookmark_file_load_from_data_dirs() to read an existing bookmark
1019 // file.
1020 // RETURNS: an empty #GBookmarkFile
1021 static BookmarkFile* new_() {
1022 return g_bookmark_file_new();
1026 // Error codes returned by bookmark file parsing.
1027 enum BookmarkFileError {
1028 INVALID_URI = 0,
1029 INVALID_VALUE = 1,
1030 APP_NOT_REGISTERED = 2,
1031 URI_NOT_FOUND = 3,
1032 READ = 4,
1033 UNKNOWN_ENCODING = 5,
1034 WRITE = 6,
1035 FILE_NOT_FOUND = 7
1038 // The <structname>GByteArray</structname> struct allows access to the
1039 // public fields of a <structname>GByteArray</structname>.
1040 struct ByteArray {
1041 ubyte* data;
1042 uint len;
1045 // Unintrospectable function: append() / g_byte_array_append()
1046 // Adds the given bytes to the end of the #GByteArray. The array will
1047 // grow in size automatically if necessary.
1048 // <array>: a #GByteArray.
1049 // <data>: the byte data to be added.
1050 // <len>: the number of bytes to add.
1051 static ByteArray* append(ByteArray* array, ubyte* data, uint len) {
1052 return g_byte_array_append(array, data, len);
1055 // Frees the memory allocated by the #GByteArray. If @free_segment is
1056 // %TRUE it frees the actual byte data. If the reference count of
1057 // @array is greater than one, the #GByteArray wrapper is preserved but
1058 // the size of @array will be set to zero.
1059 // <array>: a #GByteArray.
1060 // <free_segment>: if %TRUE the actual byte data is freed as well.
1061 static ubyte* free(ByteArray* array, int free_segment) {
1062 return g_byte_array_free(array, free_segment);
1065 // Unintrospectable function: new() / g_byte_array_new()
1066 // Creates a new #GByteArray with a reference count of 1.
1067 static ByteArray* new_() {
1068 return g_byte_array_new();
1071 // Unintrospectable function: prepend() / g_byte_array_prepend()
1072 // Adds the given data to the start of the #GByteArray. The array will
1073 // grow in size automatically if necessary.
1074 // <array>: a #GByteArray.
1075 // <data>: the byte data to be added.
1076 // <len>: the number of bytes to add.
1077 static ByteArray* prepend(ByteArray* array, ubyte* data, uint len) {
1078 return g_byte_array_prepend(array, data, len);
1081 // Unintrospectable function: ref() / g_byte_array_ref()
1082 // Atomically increments the reference count of @array by one. This
1083 // function is MT-safe and may be called from any thread.
1084 // RETURNS: The passed in #GByteArray.
1085 // <array>: A #GByteArray.
1086 static ByteArray* ref_(ByteArray* array) {
1087 return g_byte_array_ref(array);
1090 // Unintrospectable function: remove_index() / g_byte_array_remove_index()
1091 // Removes the byte at the given index from a #GByteArray. The
1092 // following bytes are moved down one place.
1093 // <array>: a #GByteArray.
1094 // <index_>: the index of the byte to remove.
1095 static ByteArray* remove_index(ByteArray* array, uint index_) {
1096 return g_byte_array_remove_index(array, index_);
1099 // Unintrospectable function: remove_index_fast() / g_byte_array_remove_index_fast()
1100 // Removes the byte at the given index from a #GByteArray. The last
1101 // element in the array is used to fill in the space, so this function
1102 // does not preserve the order of the #GByteArray. But it is faster
1103 // than g_byte_array_remove_index().
1104 // <array>: a #GByteArray.
1105 // <index_>: the index of the byte to remove.
1106 static ByteArray* remove_index_fast(ByteArray* array, uint index_) {
1107 return g_byte_array_remove_index_fast(array, index_);
1110 // Unintrospectable function: remove_range() / g_byte_array_remove_range()
1111 // Removes the given number of bytes starting at the given index from a
1112 // #GByteArray. The following elements are moved to close the gap.
1113 // <array>: a @GByteArray.
1114 // <index_>: the index of the first byte to remove.
1115 // <length>: the number of bytes to remove.
1116 static ByteArray* remove_range(ByteArray* array, uint index_, uint length) {
1117 return g_byte_array_remove_range(array, index_, length);
1120 // Unintrospectable function: set_size() / g_byte_array_set_size()
1121 // Sets the size of the #GByteArray, expanding it if necessary.
1122 // <array>: a #GByteArray.
1123 // <length>: the new size of the #GByteArray.
1124 static ByteArray* set_size(ByteArray* array, uint length) {
1125 return g_byte_array_set_size(array, length);
1128 // Unintrospectable function: sized_new() / g_byte_array_sized_new()
1129 // Creates a new #GByteArray with @reserved_size bytes preallocated.
1130 // This avoids frequent reallocation, if you are going to add many
1131 // bytes to the array. Note however that the size of the array is still
1132 // 0.
1133 // <reserved_size>: number of bytes preallocated.
1134 static ByteArray* sized_new(uint reserved_size) {
1135 return g_byte_array_sized_new(reserved_size);
1138 // Unintrospectable function: sort() / g_byte_array_sort()
1139 // Sorts a byte array, using @compare_func which should be a
1140 // qsort()-style comparison function (returns less than zero for first
1141 // arg is less than second arg, zero for equal, greater than zero if
1142 // first arg is greater than second arg).
1144 // If two array elements compare equal, their order in the sorted array
1145 // is undefined. If you want equal elements to keep their order &#8211; i.e.
1146 // you want a stable sort &#8211; you can write a comparison function that,
1147 // if two elements would otherwise compare equal, compares them by
1148 // their addresses.
1149 // <array>: a #GByteArray.
1150 // <compare_func>: comparison function.
1151 static void sort(ByteArray* array, CompareFunc compare_func) {
1152 g_byte_array_sort(array, compare_func);
1155 // Unintrospectable function: sort_with_data() / g_byte_array_sort_with_data()
1156 // Like g_byte_array_sort(), but the comparison function takes an extra
1157 // user data argument.
1158 // <array>: a #GByteArray.
1159 // <compare_func>: comparison function.
1160 // <user_data>: data to pass to @compare_func.
1161 static void sort_with_data(ByteArray* array, CompareDataFunc compare_func, void* user_data) {
1162 g_byte_array_sort_with_data(array, compare_func, user_data);
1165 // Atomically decrements the reference count of @array by one. If the
1166 // reference count drops to 0, all memory allocated by the array is
1167 // released. This function is MT-safe and may be called from any
1168 // thread.
1169 // <array>: A #GByteArray.
1170 static void unref(ByteArray* array) {
1171 g_byte_array_unref(array);
1175 enum int CAN_INLINE = 1;
1176 enum CSET_A_2_Z = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
1177 enum CSET_DIGITS = "0123456789";
1178 enum CSET_a_2_z = "abcdefghijklmnopqrstuvwxyz";
1180 // The #GCache struct is an opaque data structure containing
1181 // information about a #GCache. It should only be accessed via the
1182 // following functions.
1183 struct Cache {
1185 // Frees the memory allocated for the #GCache.
1187 // Note that it does not destroy the keys and values which were
1188 // contained in the #GCache.
1189 void destroy() {
1190 g_cache_destroy(&this);
1193 // Unintrospectable method: insert() / g_cache_insert()
1194 // Gets the value corresponding to the given key, creating it if
1195 // necessary. It first checks if the value already exists in the
1196 // #GCache, by using the @key_equal_func function passed to
1197 // g_cache_new(). If it does already exist it is returned, and its
1198 // reference count is increased by one. If the value does not currently
1199 // exist, if is created by calling the @value_new_func. The key is
1200 // duplicated by calling @key_dup_func and the duplicated key and value
1201 // are inserted into the #GCache.
1202 // <key>: a key describing a #GCache object.
1203 void* insert(void* key) {
1204 return g_cache_insert(&this, key);
1207 // Unintrospectable method: key_foreach() / g_cache_key_foreach()
1208 // Calls the given function for each of the keys in the #GCache.
1210 // NOTE @func is passed three parameters, the value and key of a cache
1211 // entry and the @user_data. The order of value and key is different
1212 // from the order in which g_hash_table_foreach() passes key-value
1213 // pairs to its callback function !
1214 // <func>: the function to call with each #GCache key.
1215 // <user_data>: user data to pass to the function.
1216 void key_foreach(HFunc func, void* user_data) {
1217 g_cache_key_foreach(&this, func, user_data);
1220 // Decreases the reference count of the given value. If it drops to 0
1221 // then the value and its corresponding key are destroyed, using the
1222 // @value_destroy_func and @key_destroy_func passed to g_cache_new().
1223 // <value>: the value to remove.
1224 void remove(const(void)* value) {
1225 g_cache_remove(&this, value);
1228 // Unintrospectable method: value_foreach() / g_cache_value_foreach()
1229 // Calls the given function for each of the values in the #GCache.
1231 // Deprecated:2.10: The reason is that it passes pointers to internal
1232 // data structures to @func; use g_cache_key_foreach()
1233 // instead
1234 // <func>: the function to call with each #GCache value.
1235 // <user_data>: user data to pass to the function.
1236 void value_foreach(HFunc func, void* user_data) {
1237 g_cache_value_foreach(&this, func, user_data);
1240 // Unintrospectable function: new() / g_cache_new()
1241 // Creates a new #GCache.
1242 // <value_new_func>: a function to create a new object given a key. This is called by g_cache_insert() if an object with the given key does not already exist.
1243 // <value_destroy_func>: a function to destroy an object. It is called by g_cache_remove() when the object is no longer needed (i.e. its reference count drops to 0).
1244 // <key_dup_func>: a function to copy a key. It is called by g_cache_insert() if the key does not already exist in the #GCache.
1245 // <key_destroy_func>: a function to destroy a key. It is called by g_cache_remove() when the object is no longer needed (i.e. its reference count drops to 0).
1246 // <hash_key_func>: a function to create a hash value from a key.
1247 // <hash_value_func>: a function to create a hash value from a value.
1248 // <key_equal_func>: a function to compare two keys. It should return %TRUE if the two keys are equivalent.
1249 static Cache* new_(CacheNewFunc value_new_func, CacheDestroyFunc value_destroy_func, CacheDupFunc key_dup_func, CacheDestroyFunc key_destroy_func, HashFunc hash_key_func, HashFunc hash_value_func, EqualFunc key_equal_func) {
1250 return g_cache_new(value_new_func, value_destroy_func, key_dup_func, key_destroy_func, hash_key_func, hash_value_func, key_equal_func);
1255 // Specifies the type of the @value_destroy_func and @key_destroy_func
1256 // functions passed to g_cache_new(). The functions are passed a
1257 // pointer to the #GCache key or #GCache value and should free any
1258 // memory and other resources associated with it.
1259 // <value>: the #GCache value to destroy.
1260 extern (C) alias void function (void* value) CacheDestroyFunc;
1263 // Unintrospectable callback: CacheDupFunc() / ()
1264 // Specifies the type of the @key_dup_func function passed to
1265 // g_cache_new(). The function is passed a key
1266 // (<emphasis>not</emphasis> a value as the prototype implies) and
1267 // should return a duplicate of the key.
1268 // <value>: the #GCache key to destroy (<emphasis>not</emphasis> a #GCache value as it seems).
1269 extern (C) alias void* function (void* value) CacheDupFunc;
1272 // Unintrospectable callback: CacheNewFunc() / ()
1273 // Specifies the type of the @value_new_func function passed to
1274 // g_cache_new(). It is passed a #GCache key and should create the
1275 // value corresponding to the key.
1276 // <key>: a #GCache key.
1277 extern (C) alias void* function (void* key) CacheNewFunc;
1280 // An opaque structure representing a checksumming operation.
1281 // To create a new GChecksum, use g_checksum_new(). To free
1282 // a GChecksum, use g_checksum_free().
1283 struct Checksum /* Version 2.16 */ {
1285 // Unintrospectable method: copy() / g_checksum_copy()
1286 // Copies a #GChecksum. If @checksum has been closed, by calling
1287 // g_checksum_get_string() or g_checksum_get_digest(), the copied
1288 // checksum will be closed as well.
1290 // when finished using it.
1291 // RETURNS: the copy of the passed #GChecksum. Use g_checksum_free()
1292 Checksum* copy() {
1293 return g_checksum_copy(&this);
1295 // Frees the memory allocated for @checksum.
1296 void free() {
1297 g_checksum_free(&this);
1300 // Gets the digest from @checksum as a raw binary vector and places it
1301 // into @buffer. The size of the digest depends on the type of checksum.
1303 // Once this function has been called, the #GChecksum is closed and can
1304 // no longer be updated with g_checksum_update().
1305 // <buffer>: output buffer
1306 // <digest_len>: an inout parameter. The caller initializes it to the size of @buffer. After the call it contains the length of the digest.
1307 void get_digest(ubyte* buffer, size_t* digest_len) {
1308 g_checksum_get_digest(&this, buffer, digest_len);
1311 // Gets the digest as an hexadecimal string.
1313 // Once this function has been called the #GChecksum can no longer be
1314 // updated with g_checksum_update().
1316 // The hexadecimal characters will be lower case.
1318 // returned string is owned by the checksum and should not be modified
1319 // or freed.
1320 // RETURNS: the hexadecimal representation of the checksum. The
1321 char* get_string() {
1322 return g_checksum_get_string(&this);
1324 // Resets the state of the @checksum back to its initial state.
1325 void reset() {
1326 g_checksum_reset(&this);
1329 // Feeds @data into an existing #GChecksum. The checksum must still be
1330 // open, that is g_checksum_get_string() or g_checksum_get_digest() must
1331 // not have been called on @checksum.
1332 // <data>: buffer used to compute the checksum
1333 // <length>: size of the buffer, or -1 if it is a null-terminated string.
1334 void update(ubyte* data, ssize_t length) {
1335 g_checksum_update(&this, data, length);
1338 // Unintrospectable function: new() / g_checksum_new()
1339 // Creates a new #GChecksum, using the checksum algorithm @checksum_type.
1340 // If the @checksum_type is not known, %NULL is returned.
1341 // A #GChecksum can be used to compute the checksum, or digest, of an
1342 // arbitrary binary blob, using different hashing algorithms.
1344 // A #GChecksum works by feeding a binary blob through g_checksum_update()
1345 // until there is data to be checked; the digest can then be extracted
1346 // using g_checksum_get_string(), which will return the checksum as a
1347 // hexadecimal string; or g_checksum_get_digest(), which will return a
1348 // vector of raw bytes. Once either g_checksum_get_string() or
1349 // g_checksum_get_digest() have been called on a #GChecksum, the checksum
1350 // will be closed and it won't be possible to call g_checksum_update()
1351 // on it anymore.
1353 // Use g_checksum_free() to free the memory allocated by it.
1354 // RETURNS: the newly created #GChecksum, or %NULL.
1355 // <checksum_type>: the desired type of checksum
1356 static Checksum* new_(ChecksumType checksum_type) {
1357 return g_checksum_new(checksum_type);
1360 // Gets the length in bytes of digests of type @checksum_type
1362 // not supported.
1363 // RETURNS: the checksum length, or -1 if @checksum_type is
1364 // <checksum_type>: a #GChecksumType
1365 static ssize_t type_get_length(ChecksumType checksum_type) {
1366 return g_checksum_type_get_length(checksum_type);
1371 // The hashing algorithm to be used by #GChecksum when performing the
1372 // digest of some data.
1374 // Note that the #GChecksumType enumeration may be extended at a later
1375 // date to include new hashing algorithm types.
1376 enum ChecksumType /* Version 2.16 */ {
1377 MD5 = 0,
1378 SHA1 = 1,
1379 SHA256 = 2
1382 // The type of functions to be called when a child exists.
1383 // <pid>: the process id of the child process
1384 // <status>: Status information about the child process, see waitpid(2) for more information about this field
1385 // <user_data>: user data passed to g_child_watch_add()
1386 extern (C) alias void function (Pid pid, int status, void* user_data) ChildWatchFunc;
1389 // Specifies the type of a comparison function used to compare two
1390 // values. The function should return a negative integer if the first
1391 // value comes before the second, 0 if they are equal, or a positive
1392 // integer if the first value comes after the second.
1393 // <a>: a value.
1394 // <b>: a value to compare with.
1395 // <user_data>: user data to pass to comparison function.
1396 extern (C) alias int function (const(void)* a, const(void)* b, void* user_data) CompareDataFunc;
1399 // Specifies the type of a comparison function used to compare two
1400 // values. The function should return a negative integer if the first
1401 // value comes before the second, 0 if they are equal, or a positive
1402 // integer if the first value comes after the second.
1403 // <a>: a value.
1404 // <b>: a value to compare with.
1405 extern (C) alias int function (const(void)* a, const(void)* b) CompareFunc;
1407 // The data structure used for automatic completion.
1408 struct Completion {
1409 GLib2.List* items;
1410 CompletionFunc func;
1411 char* prefix;
1412 GLib2.List* cache;
1413 CompletionStrncmpFunc strncmp_func;
1416 // Unintrospectable method: add_items() / g_completion_add_items()
1417 // Adds items to the #GCompletion.
1418 // <items>: the list of items to add.
1419 void add_items(GLib2.List* items) {
1420 g_completion_add_items(&this, items);
1422 // Removes all items from the #GCompletion.
1423 void clear_items() {
1424 g_completion_clear_items(&this);
1427 // Unintrospectable method: complete() / g_completion_complete()
1428 // Attempts to complete the string @prefix using the #GCompletion
1429 // target items.
1430 // <prefix>: the prefix string, typically typed by the user, which is compared with each of the items.
1431 // <new_prefix>: if non-%NULL, returns the longest prefix which is common to all items that matched @prefix, or %NULL if no items matched @prefix. This string should be freed when no longer needed.
1432 GLib2.List* complete(char* prefix, char** new_prefix) {
1433 return g_completion_complete(&this, prefix, new_prefix);
1436 // Attempts to complete the string @prefix using the #GCompletion target items.
1437 // In contrast to g_completion_complete(), this function returns the largest common
1438 // prefix that is a valid UTF-8 string, omitting a possible common partial
1439 // character.
1441 // You should use this function instead of g_completion_complete() if your
1442 // items are UTF-8 strings.
1444 // not be changed.
1445 // RETURNS: the list of items whose strings begin with @prefix. This should
1446 // <prefix>: the prefix string, typically used by the user, which is compared with each of the items
1447 // <new_prefix>: if non-%NULL, returns the longest prefix which is common to all items that matched @prefix, or %NULL if no items matched @prefix. This string should be freed when no longer needed.
1448 GLib2.List* complete_utf8(char* prefix, char** new_prefix) {
1449 return g_completion_complete_utf8(&this, prefix, new_prefix);
1451 // Frees all memory used by the #GCompletion.
1452 void free() {
1453 g_completion_free(&this);
1456 // Unintrospectable method: remove_items() / g_completion_remove_items()
1457 // Removes items from a #GCompletion.
1458 // <items>: the items to remove.
1459 void remove_items(GLib2.List* items) {
1460 g_completion_remove_items(&this, items);
1463 // Unintrospectable method: set_compare() / g_completion_set_compare()
1464 // Sets the function to use for string comparisons. The default string
1465 // comparison function is strncmp().
1466 // <strncmp_func>: the string comparison function.
1467 void set_compare(CompletionStrncmpFunc strncmp_func) {
1468 g_completion_set_compare(&this, strncmp_func);
1471 // Unintrospectable function: new() / g_completion_new()
1472 // Creates a new #GCompletion.
1473 // <func>: the function to be called to return the string representing an item in the #GCompletion, or %NULL if strings are going to be used as the #GCompletion items.
1474 static Completion* new_(CompletionFunc func) {
1475 return g_completion_new(func);
1480 // Specifies the type of the function passed to g_completion_new(). It
1481 // should return the string corresponding to the given target item.
1482 // This is used when you use data structures as #GCompletion items.
1483 extern (C) alias char* /*new*/ function (void* arg_a) CompletionFunc;
1486 // Specifies the type of the function passed to
1487 // g_completion_set_compare(). This is used when you use strings as
1488 // #GCompletion items.
1489 // <s1>: string to compare with @s2.
1490 // <s2>: string to compare with @s1.
1491 // <n>: maximal number of bytes to compare.
1492 extern (C) alias int function (char* s1, char* s2, size_t n) CompletionStrncmpFunc;
1495 // The #GCond struct is an opaque data structure that represents a
1496 // condition. Threads can block on a #GCond if they find a certain
1497 // condition to be false. If other threads change the state of this
1498 // condition they signal the #GCond, and that causes the waiting
1499 // threads to be woken up.
1501 // <example>
1502 // <title>
1503 // Using GCond to block a thread until a condition is satisfied
1504 // </title>
1505 // <programlisting>
1506 // GCond* data_cond = NULL; /<!-- -->* Must be initialized somewhere *<!-- -->/
1507 // GMutex* data_mutex = NULL; /<!-- -->* Must be initialized somewhere *<!-- -->/
1508 // gpointer current_data = NULL;
1510 // void
1511 // push_data (gpointer data)
1512 // {
1513 // g_mutex_lock (data_mutex);
1514 // current_data = data;
1515 // g_cond_signal (data_cond);
1516 // g_mutex_unlock (data_mutex);
1517 // }
1519 // gpointer
1520 // pop_data (void)
1521 // {
1522 // gpointer data;
1524 // g_mutex_lock (data_mutex);
1525 // while (!current_data)
1526 // g_cond_wait (data_cond, data_mutex);
1527 // data = current_data;
1528 // current_data = NULL;
1529 // g_mutex_unlock (data_mutex);
1531 // return data;
1532 // }
1533 // </programlisting>
1534 // </example>
1536 // Whenever a thread calls <function>pop_data()</function> now, it will
1537 // wait until current_data is non-%NULL, i.e. until some other thread
1538 // has called <function>push_data()</function>.
1540 // <note><para>It is important to use the g_cond_wait() and
1541 // g_cond_timed_wait() functions only inside a loop which checks for the
1542 // condition to be true. It is not guaranteed that the waiting thread
1543 // will find the condition fulfilled after it wakes up, even if the
1544 // signaling thread left the condition in that state: another thread may
1545 // have altered the condition before the waiting thread got the chance
1546 // to be woken up, even if the condition itself is protected by a
1547 // #GMutex, like above.</para></note>
1549 // A #GCond should only be accessed via the following functions.
1551 // <note><para>All of the <function>g_cond_*</function> functions are
1552 // actually macros. Apart from taking their addresses, you can however
1553 // use them as if they were functions.</para></note>
1554 struct Cond {
1557 // Error codes returned by character set conversion routines.
1558 enum ConvertError {
1559 NO_CONVERSION = 0,
1560 ILLEGAL_SEQUENCE = 1,
1561 FAILED = 2,
1562 PARTIAL_INPUT = 3,
1563 BAD_URI = 4,
1564 NOT_ABSOLUTE_PATH = 5
1567 // Unintrospectable callback: CopyFunc() / ()
1568 // A function of this signature is used to copy the node data
1569 // when doing a deep-copy of a tree.
1570 // RETURNS: A pointer to the copy
1571 // <src>: A pointer to the data which should be copied
1572 // <data>: Additional data
1573 extern (C) alias void* function (const(void)* src, void* data) CopyFunc;
1575 enum int DATALIST_FLAGS_MASK = 3;
1576 enum int DATE_BAD_DAY = 0;
1577 enum int DATE_BAD_JULIAN = 0;
1578 enum int DATE_BAD_YEAR = 0;
1579 enum int DIR_SEPARATOR = 92;
1580 enum DIR_SEPARATOR_S = "\\";
1582 // The #GData struct is an opaque data structure to represent a <link
1583 // linkend="glib-Keyed-Data-Lists">Keyed Data List</link>. It should
1584 // only be accessed via the following functions.
1585 struct Data {
1589 // Specifies the type of function passed to g_dataset_foreach(). It is
1590 // called with each #GQuark id and associated data element, together
1591 // with the @user_data parameter supplied to g_dataset_foreach().
1592 // <key_id>: the #GQuark id to identifying the data element.
1593 // <data>: the data element.
1594 // <user_data>: user data passed to g_dataset_foreach().
1595 extern (C) alias void function (Quark key_id, void* data, void* user_data) DataForeachFunc;
1597 struct Date {
1598 static import std.bitmanip; mixin(std.bitmanip.bitfields!(
1599 uint, "julian_days", 32,
1600 uint, "julian", 1,
1601 uint, "dmy", 1,
1602 uint, "day", 6,
1603 uint, "month", 4,
1604 uint, "year", 16,
1605 uint, "__dummy64A", 4));
1607 static Date* /*new*/ new_() {
1608 return g_date_new();
1610 static Date* /*new*/ new_dmy(DateDay day, DateMonth month, DateYear year) {
1611 return g_date_new_dmy(day, month, year);
1613 static Date* /*new*/ new_julian(uint julian_day) {
1614 return g_date_new_julian(julian_day);
1616 void add_days(uint n_days) {
1617 g_date_add_days(&this, n_days);
1619 void add_months(uint n_months) {
1620 g_date_add_months(&this, n_months);
1622 void add_years(uint n_years) {
1623 g_date_add_years(&this, n_years);
1625 void clamp(Date* min_date, Date* max_date) {
1626 g_date_clamp(&this, min_date, max_date);
1628 void clear(uint n_dates) {
1629 g_date_clear(&this, n_dates);
1631 int compare(Date* rhs) {
1632 return g_date_compare(&this, rhs);
1634 int days_between(Date* date2) {
1635 return g_date_days_between(&this, date2);
1637 void free() {
1638 g_date_free(&this);
1640 DateDay get_day() {
1641 return g_date_get_day(&this);
1643 uint get_day_of_year() {
1644 return g_date_get_day_of_year(&this);
1647 // Returns the week of the year, where weeks are interpreted according
1648 // to ISO 8601.
1649 // RETURNS: ISO 8601 week number of the year.
1650 uint get_iso8601_week_of_year() {
1651 return g_date_get_iso8601_week_of_year(&this);
1653 uint get_julian() {
1654 return g_date_get_julian(&this);
1656 uint get_monday_week_of_year() {
1657 return g_date_get_monday_week_of_year(&this);
1659 DateMonth get_month() {
1660 return g_date_get_month(&this);
1662 uint get_sunday_week_of_year() {
1663 return g_date_get_sunday_week_of_year(&this);
1665 DateWeekday get_weekday() {
1666 return g_date_get_weekday(&this);
1668 DateYear get_year() {
1669 return g_date_get_year(&this);
1671 int is_first_of_month() {
1672 return g_date_is_first_of_month(&this);
1674 int is_last_of_month() {
1675 return g_date_is_last_of_month(&this);
1677 void order(Date* date2) {
1678 g_date_order(&this, date2);
1680 void set_day(DateDay day) {
1681 g_date_set_day(&this, day);
1683 void set_dmy(DateDay day, DateMonth month, DateYear y) {
1684 g_date_set_dmy(&this, day, month, y);
1686 void set_julian(uint julian_date) {
1687 g_date_set_julian(&this, julian_date);
1689 void set_month(DateMonth month) {
1690 g_date_set_month(&this, month);
1692 void set_parse(char* str) {
1693 g_date_set_parse(&this, str);
1696 // Sets the value of a date from a #GTime value.
1697 // The time to date conversion is done using the user's current timezone.
1698 // <time_>: #GTime value to set.
1699 void set_time(Time time_) {
1700 g_date_set_time(&this, time_);
1703 // Sets the value of a date to the date corresponding to a time
1704 // specified as a time_t. The time to date conversion is done using
1705 // the user's current timezone.
1707 // To set the value of a date to the current day, you could write:
1708 // |[
1709 // g_date_set_time_t (date, time (NULL));
1710 // ]|
1711 // <timet>: <type>time_t</type> value to set
1712 void set_time_t(time_t timet) {
1713 g_date_set_time_t(&this, timet);
1716 // Sets the value of a date from a #GTimeVal value. Note that the
1717 // @tv_usec member is ignored, because #GDate can't make use of the
1718 // additional precision.
1720 // The time to date conversion is done using the user's current timezone.
1721 // <timeval>: #GTimeVal value to set
1722 void set_time_val(TimeVal* timeval) {
1723 g_date_set_time_val(&this, timeval);
1725 void set_year(DateYear year) {
1726 g_date_set_year(&this, year);
1728 void subtract_days(uint n_days) {
1729 g_date_subtract_days(&this, n_days);
1731 void subtract_months(uint n_months) {
1732 g_date_subtract_months(&this, n_months);
1734 void subtract_years(uint n_years) {
1735 g_date_subtract_years(&this, n_years);
1737 void to_struct_tm(void** tm) {
1738 g_date_to_struct_tm(&this, tm);
1740 int valid() {
1741 return g_date_valid(&this);
1743 static ubyte get_days_in_month(DateMonth month, DateYear year) {
1744 return g_date_get_days_in_month(month, year);
1746 static ubyte get_monday_weeks_in_year(DateYear year) {
1747 return g_date_get_monday_weeks_in_year(year);
1749 static ubyte get_sunday_weeks_in_year(DateYear year) {
1750 return g_date_get_sunday_weeks_in_year(year);
1752 static int is_leap_year(DateYear year) {
1753 return g_date_is_leap_year(year);
1755 static size_t strftime(char* s, size_t slen, char* format, Date* date) {
1756 return g_date_strftime(s, slen, format, date);
1758 static int valid_day(DateDay day) {
1759 return g_date_valid_day(day);
1761 static int valid_dmy(DateDay day, DateMonth month, DateYear year) {
1762 return g_date_valid_dmy(day, month, year);
1764 static int valid_julian(uint julian_date) {
1765 return g_date_valid_julian(julian_date);
1767 static int valid_month(DateMonth month) {
1768 return g_date_valid_month(month);
1770 static int valid_weekday(DateWeekday weekday) {
1771 return g_date_valid_weekday(weekday);
1773 static int valid_year(DateYear year) {
1774 return g_date_valid_year(year);
1778 enum DateDMY {
1779 DAY = 0,
1780 MONTH = 1,
1781 YEAR = 2
1783 enum DateMonth {
1784 BAD_MONTH = 0,
1785 JANUARY = 1,
1786 FEBRUARY = 2,
1787 MARCH = 3,
1788 APRIL = 4,
1789 MAY = 5,
1790 JUNE = 6,
1791 JULY = 7,
1792 AUGUST = 8,
1793 SEPTEMBER = 9,
1794 OCTOBER = 10,
1795 NOVEMBER = 11,
1796 DECEMBER = 12
1799 // <structname>GDateTime</structname> is an opaque structure whose members
1800 // cannot be accessed directly.
1801 struct DateTime /* Version 2.26 */ {
1803 // Creates a new #GDateTime corresponding to the given date and time in
1804 // the time zone @tz.
1806 // The @year must be between 1 and 9999, @month between 1 and 12 and @day
1807 // between 1 and 28, 29, 30 or 31 depending on the month and the year.
1809 // @hour must be between 0 and 23 and @minute must be between 0 and 59.
1811 // @seconds must be at least 0.0 and must be strictly less than 60.0.
1812 // It will be rounded down to the nearest microsecond.
1814 // If the given time is not representable in the given time zone (for
1815 // example, 02:30 on March 14th 2010 in Toronto, due to daylight savings
1816 // time) then the time will be rounded up to the nearest existing time
1817 // (in this case, 03:00). If this matters to you then you should verify
1818 // the return value for containing the same as the numbers you gave.
1820 // In the case that the given time is ambiguous in the given time zone
1821 // (for example, 01:30 on November 7th 2010 in Toronto, due to daylight
1822 // savings time) then the time falling within standard (ie:
1823 // non-daylight) time is taken.
1825 // It not considered a programmer error for the values to this function
1826 // to be out of range, but in the case that they are, the function will
1827 // return %NULL.
1829 // You should release the return value by calling g_date_time_unref()
1830 // when you are done with it.
1831 // RETURNS: a new #GDateTime, or %NULL
1832 // <tz>: a #GTimeZone
1833 // <year>: the year component of the date
1834 // <month>: the month component of the date
1835 // <day>: the day component of the date
1836 // <hour>: the hour component of the date
1837 // <minute>: the minute component of the date
1838 // <seconds>: the number of seconds past the minute
1839 static DateTime* /*new*/ new_(TimeZone* tz, int year, int month, int day, int hour, int minute, double seconds) {
1840 return g_date_time_new(tz, year, month, day, hour, minute, seconds);
1843 // Creates a #GDateTime corresponding to the given #GTimeVal @tv in the
1844 // local time zone.
1846 // The time contained in a #GTimeVal is always stored in the form of
1847 // seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the
1848 // local time offset.
1850 // This call can fail (returning %NULL) if @tv represents a time outside
1851 // of the supported range of #GDateTime.
1853 // You should release the return value by calling g_date_time_unref()
1854 // when you are done with it.
1855 // RETURNS: a new #GDateTime, or %NULL
1856 // <tv>: a #GTimeVal
1857 static DateTime* /*new*/ new_from_timeval_local(TimeVal* tv) {
1858 return g_date_time_new_from_timeval_local(tv);
1861 // Creates a #GDateTime corresponding to the given #GTimeVal @tv in UTC.
1863 // The time contained in a #GTimeVal is always stored in the form of
1864 // seconds elapsed since 1970-01-01 00:00:00 UTC.
1866 // This call can fail (returning %NULL) if @tv represents a time outside
1867 // of the supported range of #GDateTime.
1869 // You should release the return value by calling g_date_time_unref()
1870 // when you are done with it.
1871 // RETURNS: a new #GDateTime, or %NULL
1872 // <tv>: a #GTimeVal
1873 static DateTime* /*new*/ new_from_timeval_utc(TimeVal* tv) {
1874 return g_date_time_new_from_timeval_utc(tv);
1877 // Creates a #GDateTime corresponding to the given Unix time @t in the
1878 // local time zone.
1880 // Unix time is the number of seconds that have elapsed since 1970-01-01
1881 // 00:00:00 UTC, regardless of the local time offset.
1883 // This call can fail (returning %NULL) if @t represents a time outside
1884 // of the supported range of #GDateTime.
1886 // You should release the return value by calling g_date_time_unref()
1887 // when you are done with it.
1888 // RETURNS: a new #GDateTime, or %NULL
1889 // <t>: the Unix time
1890 static DateTime* /*new*/ new_from_unix_local(long t) {
1891 return g_date_time_new_from_unix_local(t);
1894 // Creates a #GDateTime corresponding to the given Unix time @t in UTC.
1896 // Unix time is the number of seconds that have elapsed since 1970-01-01
1897 // 00:00:00 UTC.
1899 // This call can fail (returning %NULL) if @t represents a time outside
1900 // of the supported range of #GDateTime.
1902 // You should release the return value by calling g_date_time_unref()
1903 // when you are done with it.
1904 // RETURNS: a new #GDateTime, or %NULL
1905 // <t>: the Unix time
1906 static DateTime* /*new*/ new_from_unix_utc(long t) {
1907 return g_date_time_new_from_unix_utc(t);
1910 // Creates a new #GDateTime corresponding to the given date and time in
1911 // the local time zone.
1913 // This call is equivalent to calling g_date_time_new() with the time
1914 // zone returned by g_time_zone_new_local().
1915 // RETURNS: a #GDateTime, or %NULL
1916 // <year>: the year component of the date
1917 // <month>: the month component of the date
1918 // <day>: the day component of the date
1919 // <hour>: the hour component of the date
1920 // <minute>: the minute component of the date
1921 // <seconds>: the number of seconds past the minute
1922 static DateTime* /*new*/ new_local(int year, int month, int day, int hour, int minute, double seconds) {
1923 return g_date_time_new_local(year, month, day, hour, minute, seconds);
1926 // Creates a #GDateTime corresponding to this exact instant in the given
1927 // time zone @tz. The time is as accurate as the system allows, to a
1928 // maximum accuracy of 1 microsecond.
1930 // This function will always succeed unless the system clock is set to
1931 // truly insane values (or unless GLib is still being used after the
1932 // year 9999).
1934 // You should release the return value by calling g_date_time_unref()
1935 // when you are done with it.
1936 // RETURNS: a new #GDateTime, or %NULL
1937 // <tz>: a #GTimeZone
1938 static DateTime* /*new*/ new_now(TimeZone* tz) {
1939 return g_date_time_new_now(tz);
1942 // Creates a #GDateTime corresponding to this exact instant in the local
1943 // time zone.
1945 // This is equivalent to calling g_date_time_new_now() with the time
1946 // zone returned by g_time_zone_new_local().
1947 // RETURNS: a new #GDateTime, or %NULL
1948 static DateTime* /*new*/ new_now_local() {
1949 return g_date_time_new_now_local();
1952 // Creates a #GDateTime corresponding to this exact instant in UTC.
1954 // This is equivalent to calling g_date_time_new_now() with the time
1955 // zone returned by g_time_zone_new_utc().
1956 // RETURNS: a new #GDateTime, or %NULL
1957 static DateTime* /*new*/ new_now_utc() {
1958 return g_date_time_new_now_utc();
1961 // Creates a new #GDateTime corresponding to the given date and time in
1962 // UTC.
1964 // This call is equivalent to calling g_date_time_new() with the time
1965 // zone returned by g_time_zone_new_utc().
1966 // RETURNS: a #GDateTime, or %NULL
1967 // <year>: the year component of the date
1968 // <month>: the month component of the date
1969 // <day>: the day component of the date
1970 // <hour>: the hour component of the date
1971 // <minute>: the minute component of the date
1972 // <seconds>: the number of seconds past the minute
1973 static DateTime* /*new*/ new_utc(int year, int month, int day, int hour, int minute, double seconds) {
1974 return g_date_time_new_utc(year, month, day, hour, minute, seconds);
1977 // Creates a copy of @datetime and adds the specified timespan to the copy.
1979 // g_date_time_unref().
1980 // RETURNS: the newly created #GDateTime which should be freed with
1981 // <timespan>: a #GTimeSpan
1982 DateTime* /*new*/ add(TimeSpan timespan) {
1983 return g_date_time_add(&this, timespan);
1986 // Creates a copy of @datetime and adds the specified number of days to the
1987 // copy.
1989 // g_date_time_unref().
1990 // RETURNS: the newly created #GDateTime which should be freed with
1991 // <days>: the number of days
1992 DateTime* /*new*/ add_days(int days) {
1993 return g_date_time_add_days(&this, days);
1996 // Creates a new #GDateTime adding the specified values to the current date and
1997 // time in @datetime.
1999 // g_date_time_unref().
2000 // RETURNS: the newly created #GDateTime that should be freed with
2001 // <years>: the number of years to add
2002 // <months>: the number of months to add
2003 // <days>: the number of days to add
2004 // <hours>: the number of hours to add
2005 // <minutes>: the number of minutes to add
2006 // <seconds>: the number of seconds to add
2007 DateTime* /*new*/ add_full(int years, int months, int days, int hours, int minutes, double seconds) {
2008 return g_date_time_add_full(&this, years, months, days, hours, minutes, seconds);
2011 // Creates a copy of @datetime and adds the specified number of hours
2013 // g_date_time_unref().
2014 // RETURNS: the newly created #GDateTime which should be freed with
2015 // <hours>: the number of hours to add
2016 DateTime* /*new*/ add_hours(int hours) {
2017 return g_date_time_add_hours(&this, hours);
2020 // Creates a copy of @datetime adding the specified number of minutes.
2022 // g_date_time_unref().
2023 // RETURNS: the newly created #GDateTime which should be freed with
2024 // <minutes>: the number of minutes to add
2025 DateTime* /*new*/ add_minutes(int minutes) {
2026 return g_date_time_add_minutes(&this, minutes);
2029 // Creates a copy of @datetime and adds the specified number of months to the
2030 // copy.
2032 // g_date_time_unref().
2033 // RETURNS: the newly created #GDateTime which should be freed with
2034 // <months>: the number of months
2035 DateTime* /*new*/ add_months(int months) {
2036 return g_date_time_add_months(&this, months);
2039 // Creates a copy of @datetime and adds the specified number of seconds.
2041 // g_date_time_unref().
2042 // RETURNS: the newly created #GDateTime which should be freed with
2043 // <seconds>: the number of seconds to add
2044 DateTime* /*new*/ add_seconds(double seconds) {
2045 return g_date_time_add_seconds(&this, seconds);
2048 // Creates a copy of @datetime and adds the specified number of weeks to the
2049 // copy.
2051 // g_date_time_unref().
2052 // RETURNS: the newly created #GDateTime which should be freed with
2053 // <weeks>: the number of weeks
2054 DateTime* /*new*/ add_weeks(int weeks) {
2055 return g_date_time_add_weeks(&this, weeks);
2058 // Creates a copy of @datetime and adds the specified number of years to the
2059 // copy.
2061 // g_date_time_unref().
2062 // RETURNS: the newly created #GDateTime which should be freed with
2063 // <years>: the number of years
2064 DateTime* /*new*/ add_years(int years) {
2065 return g_date_time_add_years(&this, years);
2068 // Calculates the difference in time between @end and @begin. The
2069 // #GTimeSpan that is returned is effectively @end - @begin (ie:
2070 // positive if the first simparameter is larger).
2072 // span expressed in microseconds.
2073 // RETURNS: the difference between the two #GDateTime, as a time
2074 // <begin>: a #GDateTime
2075 TimeSpan difference(DateTime* begin) {
2076 return g_date_time_difference(&this, begin);
2079 // Creates a newly allocated string representing the requested @format.
2081 // The format strings understood by this function are a subset of the
2082 // strftime() format language. In contrast to strftime(), this function
2083 // always produces a UTF-8 string, regardless of the current locale.
2084 // Note that the rendering of many formats is locale-dependent and may
2085 // not match the strftime() output exactly.
2087 // The following format specifiers are supported:
2089 // <variablelist>
2090 // <varlistentry><term>
2091 // <literal>%%a</literal>:
2092 // </term><listitem><simpara>
2093 // the abbreviated weekday name according to the current locale
2094 // </simpara></listitem></varlistentry>
2095 // <varlistentry><term>
2096 // <literal>%%A</literal>:
2097 // </term><listitem><simpara>
2098 // the full weekday name according to the current locale
2099 // </simpara></listitem></varlistentry>
2100 // <varlistentry><term>
2101 // <literal>%%b</literal>:
2102 // </term><listitem><simpara>
2103 // the abbreviated month name according to the current locale
2104 // </simpara></listitem></varlistentry>
2105 // <varlistentry><term>
2106 // <literal>%%B</literal>:
2107 // </term><listitem><simpara>
2108 // the full month name according to the current locale
2109 // </simpara></listitem></varlistentry>
2110 // <varlistentry><term>
2111 // <literal>%%d</literal>:
2112 // </term><listitem><simpara>
2113 // the day of the month as a decimal number (range 01 to 31)
2114 // </simpara></listitem></varlistentry>
2115 // <varlistentry><term>
2116 // <literal>%%e</literal>:
2117 // </term><listitem><simpara>
2118 // the day of the month as a decimal number (range 1 to 31)
2119 // </simpara></listitem></varlistentry>
2120 // <varlistentry><term>
2121 // <literal>%%F</literal>:
2122 // </term><listitem><simpara>
2123 // equivalent to <literal>%%Y-%%m-%%d</literal> (the ISO 8601 date
2124 // format)
2125 // </simpara></listitem></varlistentry>
2126 // <varlistentry><term>
2127 // <literal>%%h</literal>:
2128 // </term><listitem><simpara>
2129 // equivalent to <literal>%%b</literal>
2130 // </simpara></listitem></varlistentry>
2131 // <varlistentry><term>
2132 // <literal>%%H</literal>:
2133 // </term><listitem><simpara>
2134 // the hour as a decimal number using a 24-hour clock (range 00 to
2135 // 23)
2136 // </simpara></listitem></varlistentry>
2137 // <varlistentry><term>
2138 // <literal>%%I</literal>:
2139 // </term><listitem><simpara>
2140 // the hour as a decimal number using a 12-hour clock (range 01 to
2141 // 12)
2142 // </simpara></listitem></varlistentry>
2143 // <varlistentry><term>
2144 // <literal>%%j</literal>:
2145 // </term><listitem><simpara>
2146 // the day of the year as a decimal number (range 001 to 366)
2147 // </simpara></listitem></varlistentry>
2148 // <varlistentry><term>
2149 // <literal>%%k</literal>:
2150 // </term><listitem><simpara>
2151 // the hour (24-hour clock) as a decimal number (range 0 to 23);
2152 // single digits are preceded by a blank
2153 // </simpara></listitem></varlistentry>
2154 // <varlistentry><term>
2155 // <literal>%%l</literal>:
2156 // </term><listitem><simpara>
2157 // the hour (12-hour clock) as a decimal number (range 1 to 12);
2158 // single digits are preceded by a blank
2159 // </simpara></listitem></varlistentry>
2160 // <varlistentry><term>
2161 // <literal>%%m</literal>:
2162 // </term><listitem><simpara>
2163 // the month as a decimal number (range 01 to 12)
2164 // </simpara></listitem></varlistentry>
2165 // <varlistentry><term>
2166 // <literal>%%M</literal>:
2167 // </term><listitem><simpara>
2168 // the minute as a decimal number (range 00 to 59)
2169 // </simpara></listitem></varlistentry>
2170 // <varlistentry><term>
2171 // <literal>%%N</literal>:
2172 // </term><listitem><simpara>
2173 // the micro-seconds as a decimal number
2174 // </simpara></listitem></varlistentry>
2175 // <varlistentry><term>
2176 // <literal>%%p</literal>:
2177 // </term><listitem><simpara>
2178 // either "AM" or "PM" according to the given time value, or the
2179 // corresponding strings for the current locale. Noon is treated as
2180 // "PM" and midnight as "AM".
2181 // </simpara></listitem></varlistentry>
2182 // <varlistentry><term>
2183 // <literal>%%P</literal>:
2184 // </term><listitem><simpara>
2185 // like %%p but lowercase: "am" or "pm" or a corresponding string for
2186 // the current locale
2187 // </simpara></listitem></varlistentry>
2188 // <varlistentry><term>
2189 // <literal>%%r</literal>:
2190 // </term><listitem><simpara>
2191 // the time in a.m. or p.m. notation
2192 // </simpara></listitem></varlistentry>
2193 // <varlistentry><term>
2194 // <literal>%%R</literal>:
2195 // </term><listitem><simpara>
2196 // the time in 24-hour notation (<literal>%%H:%%M</literal>)
2197 // </simpara></listitem></varlistentry>
2198 // <varlistentry><term>
2199 // <literal>%%s</literal>:
2200 // </term><listitem><simpara>
2201 // the number of seconds since the Epoch, that is, since 1970-01-01
2202 // 00:00:00 UTC
2203 // </simpara></listitem></varlistentry>
2204 // <varlistentry><term>
2205 // <literal>%%S</literal>:
2206 // </term><listitem><simpara>
2207 // the second as a decimal number (range 00 to 60)
2208 // </simpara></listitem></varlistentry>
2209 // <varlistentry><term>
2210 // <literal>%%t</literal>:
2211 // </term><listitem><simpara>
2212 // a tab character
2213 // </simpara></listitem></varlistentry>
2214 // <varlistentry><term>
2215 // <literal>%%T</literal>:
2216 // </term><listitem><simpara>
2217 // the time in 24-hour notation with seconds (<literal>%%H:%%M:%%S</literal>)
2218 // </simpara></listitem></varlistentry>
2219 // <varlistentry><term>
2220 // <literal>%%u</literal>:
2221 // </term><listitem><simpara>
2222 // the day of the week as a decimal, range 1 to 7, Monday being 1
2223 // </simpara></listitem></varlistentry>
2224 // <varlistentry><term>
2225 // <literal>%%W</literal>:
2226 // </term><listitem><simpara>
2227 // the week number of the current year as a decimal number
2228 // </simpara></listitem></varlistentry>
2229 // <varlistentry><term>
2230 // <literal>%%x</literal>:
2231 // </term><listitem><simpara>
2232 // the preferred date representation for the current locale without
2233 // the time
2234 // </simpara></listitem></varlistentry>
2235 // <varlistentry><term>
2236 // <literal>%%X</literal>:
2237 // </term><listitem><simpara>
2238 // the preferred time representation for the current locale without
2239 // the date
2240 // </simpara></listitem></varlistentry>
2241 // <varlistentry><term>
2242 // <literal>%%y</literal>:
2243 // </term><listitem><simpara>
2244 // the year as a decimal number without the century
2245 // </simpara></listitem></varlistentry>
2246 // <varlistentry><term>
2247 // <literal>%%Y</literal>:
2248 // </term><listitem><simpara>
2249 // the year as a decimal number including the century
2250 // </simpara></listitem></varlistentry>
2251 // <varlistentry><term>
2252 // <literal>%%z</literal>:
2253 // </term><listitem><simpara>
2254 // the time-zone as hour offset from UTC
2255 // </simpara></listitem></varlistentry>
2256 // <varlistentry><term>
2257 // <literal>%%Z</literal>:
2258 // </term><listitem><simpara>
2259 // the time zone or name or abbreviation
2260 // </simpara></listitem></varlistentry>
2261 // <varlistentry><term>
2262 // <literal>%%%</literal>:
2263 // </term><listitem><simpara>
2264 // a literal <literal>%%</literal> character
2265 // </simpara></listitem></varlistentry>
2266 // </variablelist>
2268 // Some conversion specifications can be modified by preceding the
2269 // conversion specifier by one or more modifier characters. The
2270 // following modifiers are supported for many of the numeric
2271 // conversions:
2272 // <variablelist>
2273 // <varlistentry>
2274 // <term>O</term>
2275 // <listitem>
2276 // Use alternative numeric symbols, if the current locale
2277 // supports those.
2278 // </listitem>
2279 // </varlistentry>
2280 // <varlistentry>
2281 // <term>_</term>
2282 // <listitem>
2283 // Pad a numeric result with spaces.
2284 // This overrides the default padding for the specifier.
2285 // </listitem>
2286 // </varlistentry>
2287 // <varlistentry>
2288 // <term>-</term>
2289 // <listitem>
2290 // Do not pad a numeric result.
2291 // This overrides the default padding for the specifier.
2292 // </listitem>
2293 // </varlistentry>
2294 // <varlistentry>
2295 // <term>0</term>
2296 // <listitem>
2297 // Pad a numeric result with zeros.
2298 // This overrides the default padding for the specifier.
2299 // </listitem>
2300 // </varlistentry>
2301 // </variablelist>
2303 // or %NULL in the case that there was an error. The string
2304 // should be freed with g_free().
2305 // RETURNS: a newly allocated string formatted to the requested format
2306 // <format>: a valid UTF-8 string, containing the format for the #GDateTime
2307 char* /*new*/ format(char* format) {
2308 return g_date_time_format(&this, format);
2311 // Retrieves the day of the month represented by @datetime in the gregorian
2312 // calendar.
2313 // RETURNS: the day of the month
2314 int get_day_of_month() {
2315 return g_date_time_get_day_of_month(&this);
2318 // Retrieves the ISO 8601 day of the week on which @datetime falls (1 is
2319 // Monday, 2 is Tuesday... 7 is Sunday).
2320 // RETURNS: the day of the week
2321 int get_day_of_week() {
2322 return g_date_time_get_day_of_week(&this);
2325 // Retrieves the day of the year represented by @datetime in the Gregorian
2326 // calendar.
2327 // RETURNS: the day of the year
2328 int get_day_of_year() {
2329 return g_date_time_get_day_of_year(&this);
2332 // Retrieves the hour of the day represented by @datetime
2333 // RETURNS: the hour of the day
2334 int get_hour() {
2335 return g_date_time_get_hour(&this);
2338 // Retrieves the microsecond of the date represented by @datetime
2339 // RETURNS: the microsecond of the second
2340 int get_microsecond() {
2341 return g_date_time_get_microsecond(&this);
2344 // Retrieves the minute of the hour represented by @datetime
2345 // RETURNS: the minute of the hour
2346 int get_minute() {
2347 return g_date_time_get_minute(&this);
2350 // Retrieves the month of the year represented by @datetime in the Gregorian
2351 // calendar.
2352 // RETURNS: the month represented by @datetime
2353 int get_month() {
2354 return g_date_time_get_month(&this);
2357 // Retrieves the second of the minute represented by @datetime
2358 // RETURNS: the second represented by @datetime
2359 int get_second() {
2360 return g_date_time_get_second(&this);
2363 // Retrieves the number of seconds since the start of the last minute,
2364 // including the fractional part.
2365 // RETURNS: the number of seconds
2366 double get_seconds() {
2367 return g_date_time_get_seconds(&this);
2370 // Determines the time zone abbreviation to be used at the time and in
2371 // the time zone of @datetime.
2373 // For example, in Toronto this is currently "EST" during the winter
2374 // months and "EDT" during the summer months when daylight savings
2375 // time is in effect.
2377 // string is owned by the #GDateTime and it should not be
2378 // modified or freed
2379 // RETURNS: the time zone abbreviation. The returned
2380 char* get_timezone_abbreviation() {
2381 return g_date_time_get_timezone_abbreviation(&this);
2384 // Determines the offset to UTC in effect at the time and in the time
2385 // zone of @datetime.
2387 // The offset is the number of microseconds that you add to UTC time to
2388 // arrive at local time for the time zone (ie: negative numbers for time
2389 // zones west of GMT, positive numbers for east).
2391 // If @datetime represents UTC time, then the offset is always zero.
2393 // get the local time
2394 // RETURNS: the number of microseconds that should be added to UTC to
2395 TimeSpan get_utc_offset() {
2396 return g_date_time_get_utc_offset(&this);
2399 // Returns the ISO 8601 week-numbering year in which the week containing
2400 // @datetime falls.
2402 // This function, taken together with g_date_time_get_week_of_year() and
2403 // g_date_time_get_day_of_week() can be used to determine the full ISO
2404 // week date on which @datetime falls.
2406 // This is usually equal to the normal Gregorian year (as returned by
2407 // g_date_time_get_year()), except as detailed below:
2409 // For Thursday, the week-numbering year is always equal to the usual
2410 // calendar year. For other days, the number is such that every day
2411 // within a complete week (Monday to Sunday) is contained within the
2412 // same week-numbering year.
2414 // For Monday, Tuesday and Wednesday occurring near the end of the year,
2415 // this may mean that the week-numbering year is one greater than the
2416 // calendar year (so that these days have the same week-numbering year
2417 // as the Thursday occurring early in the next year).
2419 // For Friday, Saturaday and Sunday occurring near the start of the year,
2420 // this may mean that the week-numbering year is one less than the
2421 // calendar year (so that these days have the same week-numbering year
2422 // as the Thursday occurring late in the previous year).
2424 // An equivalent description is that the week-numbering year is equal to
2425 // the calendar year containing the majority of the days in the current
2426 // week (Monday to Sunday).
2428 // Note that January 1 0001 in the proleptic Gregorian calendar is a
2429 // Monday, so this function never returns 0.
2430 // RETURNS: the ISO 8601 week-numbering year for @datetime
2431 int get_week_numbering_year() {
2432 return g_date_time_get_week_numbering_year(&this);
2435 // Returns the ISO 8601 week number for the week containing @datetime.
2436 // The ISO 8601 week number is the same for every day of the week (from
2437 // Moday through Sunday). That can produce some unusual results
2438 // (described below).
2440 // The first week of the year is week 1. This is the week that contains
2441 // the first Thursday of the year. Equivalently, this is the first week
2442 // that has more than 4 of its days falling within the calendar year.
2444 // The value 0 is never returned by this function. Days contained
2445 // within a year but occurring before the first ISO 8601 week of that
2446 // year are considered as being contained in the last week of the
2447 // previous year. Similarly, the final days of a calendar year may be
2448 // considered as being part of the first ISO 8601 week of the next year
2449 // if 4 or more days of that week are contained within the new year.
2450 // RETURNS: the ISO 8601 week number for @datetime.
2451 int get_week_of_year() {
2452 return g_date_time_get_week_of_year(&this);
2455 // Retrieves the year represented by @datetime in the Gregorian calendar.
2456 // RETURNS: the year represented by @datetime
2457 int get_year() {
2458 return g_date_time_get_year(&this);
2461 // Retrieves the Gregorian day, month, and year of a given #GDateTime.
2462 // <year>: the return location for the gregorian year, or %NULL.
2463 // <month>: the return location for the month of the year, or %NULL.
2464 // <day>: the return location for the day of the month, or %NULL.
2465 void get_ymd(/*out*/ int* year, /*out*/ int* month, /*out*/ int* day) {
2466 g_date_time_get_ymd(&this, year, month, day);
2469 // Determines if daylight savings time is in effect at the time and in
2470 // the time zone of @datetime.
2471 // RETURNS: %TRUE if daylight savings time is in effect
2472 int is_daylight_savings() {
2473 return g_date_time_is_daylight_savings(&this);
2476 // Atomically increments the reference count of @datetime by one.
2477 // RETURNS: the #GDateTime with the reference count increased
2478 DateTime* /*new*/ ref_() {
2479 return g_date_time_ref(&this);
2482 // Creates a new #GDateTime corresponding to the same instant in time as
2483 // @datetime, but in the local time zone.
2485 // This call is equivalent to calling g_date_time_to_timezone() with the
2486 // time zone returned by g_time_zone_new_local().
2487 // RETURNS: the newly created #GDateTime
2488 DateTime* /*new*/ to_local() {
2489 return g_date_time_to_local(&this);
2492 // Stores the instant in time that @datetime represents into @tv.
2494 // The time contained in a #GTimeVal is always stored in the form of
2495 // seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the time
2496 // zone associated with @datetime.
2498 // On systems where 'long' is 32bit (ie: all 32bit systems and all
2499 // Windows systems), a #GTimeVal is incapable of storing the entire
2500 // range of values that #GDateTime is capable of expressing. On those
2501 // systems, this function returns %FALSE to indicate that the time is
2502 // out of range.
2504 // On systems where 'long' is 64bit, this function never fails.
2505 // RETURNS: %TRUE if successful, else %FALSE
2506 // <tv>: a #GTimeVal to modify
2507 int to_timeval(TimeVal* tv) {
2508 return g_date_time_to_timeval(&this, tv);
2511 // Create a new #GDateTime corresponding to the same instant in time as
2512 // @datetime, but in the time zone @tz.
2514 // This call can fail in the case that the time goes out of bounds. For
2515 // example, converting 0001-01-01 00:00:00 UTC to a time zone west of
2516 // Greenwich will fail (due to the year 0 being out of range).
2518 // You should release the return value by calling g_date_time_unref()
2519 // when you are done with it.
2520 // RETURNS: a new #GDateTime, or %NULL
2521 // <tz>: the new #GTimeZone
2522 DateTime* /*new*/ to_timezone(TimeZone* tz) {
2523 return g_date_time_to_timezone(&this, tz);
2526 // Gives the Unix time corresponding to @datetime, rounding down to the
2527 // nearest second.
2529 // Unix time is the number of seconds that have elapsed since 1970-01-01
2530 // 00:00:00 UTC, regardless of the time zone associated with @datetime.
2531 // RETURNS: the Unix time corresponding to @datetime
2532 long to_unix() {
2533 return g_date_time_to_unix(&this);
2536 // Creates a new #GDateTime corresponding to the same instant in time as
2537 // @datetime, but in UTC.
2539 // This call is equivalent to calling g_date_time_to_timezone() with the
2540 // time zone returned by g_time_zone_new_utc().
2541 // RETURNS: the newly created #GDateTime
2542 DateTime* /*new*/ to_utc() {
2543 return g_date_time_to_utc(&this);
2546 // Atomically decrements the reference count of @datetime by one.
2548 // When the reference count reaches zero, the resources allocated by
2549 // @datetime are freed
2550 void unref() {
2551 g_date_time_unref(&this);
2554 // A comparison function for #GDateTimes that is suitable
2555 // as a #GCompareFunc. Both #GDateTimes must be non-%NULL.
2557 // than @dt2.
2558 // RETURNS: -1, 0 or 1 if @dt1 is less than, equal to or greater
2559 // <dt1>: first #GDateTime to compare
2560 // <dt2>: second #GDateTime to compare
2561 static int compare(const(void)* dt1, const(void)* dt2) {
2562 return g_date_time_compare(dt1, dt2);
2565 // Checks to see if @dt1 and @dt2 are equal.
2567 // Equal here means that they represent the same moment after converting
2568 // them to the same time zone.
2569 // RETURNS: %TRUE if @dt1 and @dt2 are equal
2570 // <dt1>: a #GDateTime
2571 // <dt2>: a #GDateTime
2572 static int equal(const(void)* dt1, const(void)* dt2) {
2573 return g_date_time_equal(dt1, dt2);
2576 // Hashes @datetime into a #guint, suitable for use within #GHashTable.
2577 // RETURNS: a #guint containing the hash
2578 // <datetime>: a #GDateTime
2579 static uint hash(const(void)* datetime) {
2580 return g_date_time_hash(datetime);
2584 enum DateWeekday {
2585 BAD_WEEKDAY = 0,
2586 MONDAY = 1,
2587 TUESDAY = 2,
2588 WEDNESDAY = 3,
2589 THURSDAY = 4,
2590 FRIDAY = 5,
2591 SATURDAY = 6,
2592 SUNDAY = 7
2595 // Associates a string with a bit flag.
2596 // Used in g_parse_debug_string().
2597 struct DebugKey {
2598 char* key;
2599 uint value;
2603 // Specifies the type of function which is called when a data element
2604 // is destroyed. It is passed the pointer to the data element and
2605 // should free any memory and resources allocated for it.
2606 // <data>: the data element.
2607 extern (C) alias void function (void* data) DestroyNotify;
2609 struct Dir {
2610 // Closes the directory and deallocates all related resources.
2611 void close() {
2612 g_dir_close(&this);
2615 // Retrieves the name of another entry in the directory, or %NULL.
2616 // The order of entries returned from this function is not defined,
2617 // and may vary by file system or other operating-system dependent
2618 // factors.
2620 // On Unix, the '.' and '..' entries are omitted, and the returned
2621 // name is in the on-disk encoding.
2623 // On Windows, as is true of all GLib functions which operate on
2624 // filenames, the returned name is in UTF-8.
2626 // more entries. The return value is owned by GLib and
2627 // must not be modified or freed.
2628 // RETURNS: The entry's name or %NULL if there are no
2629 char* read_name() {
2630 return g_dir_read_name(&this);
2633 // Resets the given directory. The next call to g_dir_read_name()
2634 // will return the first entry again.
2635 void rewind() {
2636 g_dir_rewind(&this);
2639 // Creates a subdirectory in the preferred directory for temporary
2640 // files (as returned by g_get_tmp_dir()).
2642 // @tmpl should be a string in the GLib file name encoding containing
2643 // a sequence of six 'X' characters, as the parameter to g_mkstemp().
2644 // However, unlike these functions, the template should only be a
2645 // basename, no directory components are allowed. If template is
2646 // %NULL, a default template is used.
2648 // Note that in contrast to g_mkdtemp() (and mkdtemp()) @tmpl is not
2649 // modified, and might thus be a read-only literal string.
2651 // should be freed with g_free() when not needed any longer and is
2652 // is in the GLib file name encoding. In case of errors, %NULL is
2653 // returned and @error will be set.
2654 // RETURNS: The actual name used. This string
2655 // <tmpl>: Template for directory name, as in g_mkdtemp(), basename only, or %NULL for a default template
2656 static char* /*new*/ make_tmp(char* tmpl, GLib2.Error** error=null) {
2657 return g_dir_make_tmp(tmpl, error);
2660 // Unintrospectable function: open() / g_dir_open()
2661 // Opens a directory for reading. The names of the files in the
2662 // directory can then be retrieved using g_dir_read_name(). Note
2663 // that the ordering is not defined.
2665 // If non-%NULL, you must free the result with g_dir_close()
2666 // when you are finished with it.
2667 // RETURNS: a newly allocated #GDir on success, %NULL on failure.
2668 // <path>: the path to the directory you are interested in. On Unix in the on-disk encoding. On Windows in UTF-8
2669 // <flags>: Currently must be set to 0. Reserved for future use.
2670 static Dir* open(char* path, uint flags, GLib2.Error** error=null) {
2671 return g_dir_open(path, flags, error);
2675 union DoubleIEEE754 {
2676 double v_double;
2678 struct mpn {
2679 static import std.bitmanip; mixin(std.bitmanip.bitfields!(
2680 uint, "mantissa_low", 32,
2681 uint, "mantissa_high", 20,
2682 uint, "biased_exponent", 11,
2683 uint, "sign", 1));
2687 enum double E = 2.718282;
2689 // Specifies the type of a function used to test two values for
2690 // equality. The function should return %TRUE if both values are equal
2691 // and %FALSE otherwise.
2692 // <a>: a value.
2693 // <b>: a value to compare with.
2694 extern (C) alias int function (const(void)* a, const(void)* b) EqualFunc;
2697 // The <structname>GError</structname> structure contains
2698 // information about an error that has occurred.
2699 struct Error {
2700 Quark domain;
2701 int code;
2702 char* message;
2705 // Unintrospectable constructor: new() / g_error_new()
2706 // Creates a new #GError with the given @domain and @code,
2707 // and a message formatted with @format.
2708 // RETURNS: a new #GError
2709 // <domain>: error domain
2710 // <code>: error code
2711 // <format>: printf()-style format for error message
2712 alias g_error_new new_; // Variadic
2714 // Creates a new #GError; unlike g_error_new(), @message is
2715 // not a printf()-style format string. Use this function if
2716 // @message contains text you don't have control over,
2717 // that could include printf() escape sequences.
2718 // RETURNS: a new #GError
2719 // <domain>: error domain
2720 // <code>: error code
2721 // <message>: error message
2722 static Error* /*new*/ new_literal(Quark domain, int code, char* message) {
2723 return g_error_new_literal(domain, code, message);
2726 // Unintrospectable constructor: new_valist() / g_error_new_valist()
2727 // Creates a new #GError with the given @domain and @code,
2728 // and a message formatted with @format.
2729 // RETURNS: a new #GError
2730 // <domain>: error domain
2731 // <code>: error code
2732 // <format>: printf()-style format for error message
2733 // <args>: #va_list of parameters for the message format
2734 static Error* /*new*/ new_valist(Quark domain, int code, char* format, va_list args) {
2735 return g_error_new_valist(domain, code, format, args);
2738 // Makes a copy of @error.
2739 // RETURNS: a new #GError
2740 Error* /*new*/ copy() {
2741 return g_error_copy(&this);
2743 // Frees a #GError and associated resources.
2744 void free() {
2745 g_error_free(&this);
2748 // Returns %TRUE if @error matches @domain and @code, %FALSE
2749 // otherwise. In particular, when @error is %NULL, %FALSE will
2750 // be returned.
2751 // RETURNS: whether @error has @domain and @code
2752 // <domain>: an error domain
2753 // <code>: an error code
2754 int matches(Quark domain, int code) {
2755 return g_error_matches(&this, domain, code);
2759 enum ErrorType {
2760 UNKNOWN = 0,
2761 UNEXP_EOF = 1,
2762 UNEXP_EOF_IN_STRING = 2,
2763 UNEXP_EOF_IN_COMMENT = 3,
2764 NON_DIGIT_IN_CONST = 4,
2765 DIGIT_RADIX = 5,
2766 FLOAT_RADIX = 6,
2767 FLOAT_MALFORMED = 7
2769 enum FileError {
2770 EXIST = 0,
2771 ISDIR = 1,
2772 ACCES = 2,
2773 NAMETOOLONG = 3,
2774 NOENT = 4,
2775 NOTDIR = 5,
2776 NXIO = 6,
2777 NODEV = 7,
2778 ROFS = 8,
2779 TXTBSY = 9,
2780 FAULT = 10,
2781 LOOP = 11,
2782 NOSPC = 12,
2783 NOMEM = 13,
2784 MFILE = 14,
2785 NFILE = 15,
2786 BADF = 16,
2787 INVAL = 17,
2788 PIPE = 18,
2789 AGAIN = 19,
2790 INTR = 20,
2791 IO = 21,
2792 PERM = 22,
2793 NOSYS = 23,
2794 FAILED = 24
2796 enum FileTest {
2797 IS_REGULAR = 1,
2798 IS_SYMLINK = 2,
2799 IS_DIR = 4,
2800 IS_EXECUTABLE = 8,
2801 EXISTS = 16
2803 union FloatIEEE754 {
2804 float v_float;
2806 struct mpn {
2807 static import std.bitmanip; mixin(std.bitmanip.bitfields!(
2808 uint, "mantissa", 23,
2809 uint, "biased_exponent", 8,
2810 uint, "sign", 1));
2815 // Flags to modify the format of the string returned by
2816 // g_format_size_full().
2817 enum FormatSizeFlags {
2818 DEFAULT = 0,
2819 LONG_FORMAT = 1,
2820 IEC_UNITS = 2
2823 // Declares a type of function which takes an arbitrary
2824 // data pointer argument and has no return value. It is
2825 // not currently used in GLib or GTK+.
2826 // <data>: a data pointer
2827 extern (C) alias void function (void* data) FreeFunc;
2830 // Specifies the type of functions passed to g_list_foreach() and
2831 // g_slist_foreach().
2832 // <data>: the element's data.
2833 // <user_data>: user data passed to g_list_foreach() or g_slist_foreach().
2834 extern (C) alias void function (void* data, void* user_data) Func;
2836 enum GINT16_FORMAT = "hi";
2837 enum GINT16_MODIFIER = "h";
2838 enum GINT32_FORMAT = "i";
2839 enum GINT32_MODIFIER = "";
2840 enum GINT64_FORMAT = "lli";
2841 enum GINT64_MODIFIER = "ll";
2842 enum GINTPTR_FORMAT = "i";
2843 enum GINTPTR_MODIFIER = "";
2844 enum GNUC_FUNCTION = "";
2845 enum GNUC_PRETTY_FUNCTION = "";
2846 enum GSIZE_FORMAT = "u";
2847 enum GSIZE_MODIFIER = "";
2848 enum GSSIZE_FORMAT = "i";
2849 enum GUINT16_FORMAT = "hu";
2850 enum GUINT32_FORMAT = "u";
2851 enum GUINT64_FORMAT = "llu";
2852 enum GUINTPTR_FORMAT = "u";
2853 enum int HAVE_GINT64 = 1;
2854 enum int HAVE_GNUC_VARARGS = 1;
2855 enum int HAVE_GNUC_VISIBILITY = 1;
2856 enum int HAVE_GROWING_STACK = 1;
2857 enum int HAVE_INLINE = 1;
2858 enum int HAVE_ISO_VARARGS = 1;
2859 enum int HAVE___INLINE = 1;
2860 enum int HAVE___INLINE__ = 1;
2862 // Specifies the type of the function passed to g_hash_table_foreach().
2863 // It is called with each key/value pair, together with the @user_data
2864 // parameter which is passed to g_hash_table_foreach().
2865 // <key>: a key.
2866 // <value>: the value corresponding to the key.
2867 // <user_data>: user data passed to g_hash_table_foreach().
2868 extern (C) alias void function (void* key, void* value, void* user_data) HFunc;
2870 enum int HOOK_FLAG_USER_SHIFT = 4;
2872 // Specifies the type of the function passed to
2873 // g_hash_table_foreach_remove(). It is called with each key/value
2874 // pair, together with the @user_data parameter passed to
2875 // g_hash_table_foreach_remove(). It should return %TRUE if the
2876 // key/value pair should be removed from the #GHashTable.
2877 // <key>: a key.
2878 // <value>: the value associated with the key.
2879 // <user_data>: user data passed to g_hash_table_remove().
2880 extern (C) alias int function (void* key, void* value, void* user_data) HRFunc;
2883 // Specifies the type of the hash function which is passed to
2884 // g_hash_table_new() when a #GHashTable is created.
2886 // The function is passed a key and should return a #guint hash value.
2887 // The functions g_direct_hash(), g_int_hash() and g_str_hash() provide
2888 // hash functions which can be used when the key is a #gpointer, #gint,
2889 // and #gchar* respectively.
2891 // <!-- FIXME: Need more here. --> The hash values should be evenly
2892 // distributed over a fairly large range? The modulus is taken with the
2893 // hash table size (a prime number) to find the 'bucket' to place each
2894 // key into. The function should also be very fast, since it is called
2895 // for each key lookup.
2896 // <key>: a key.
2897 extern (C) alias uint function (const(void)* key) HashFunc;
2900 // The #GHashTable struct is an opaque data structure to represent a
2901 // <link linkend="glib-Hash-Tables">Hash Table</link>. It should only be
2902 // accessed via the following functions.
2903 struct HashTable {
2905 // Destroys all keys and values in the #GHashTable and decrements its
2906 // reference count by 1. If keys and/or values are dynamically allocated,
2907 // you should either free them first or create the #GHashTable with destroy
2908 // notifiers using g_hash_table_new_full(). In the latter case the destroy
2909 // functions you supplied will be called on all keys and values during the
2910 // destruction phase.
2911 // <hash_table>: a #GHashTable.
2912 static void destroy(GLib2.HashTable* hash_table) {
2913 g_hash_table_destroy(hash_table);
2916 // Unintrospectable function: find() / g_hash_table_find()
2917 // Calls the given function for key/value pairs in the #GHashTable until
2918 // @predicate returns %TRUE. The function is passed the key and value of
2919 // each pair, and the given @user_data parameter. The hash table may not
2920 // be modified while iterating over it (you can't add/remove items).
2922 // Note, that hash tables are really only optimized for forward lookups,
2923 // i.e. g_hash_table_lookup().
2924 // So code that frequently issues g_hash_table_find() or
2925 // g_hash_table_foreach() (e.g. in the order of once per every entry in a
2926 // hash table) should probably be reworked to use additional or different
2927 // data structures for reverse lookups (keep in mind that an O(n) find/foreach
2928 // operation issued for all n values in a hash table ends up needing O(n*n)
2929 // operations).
2931 // for which @predicate evaluates to %TRUE. If no pair with the
2932 // requested property is found, %NULL is returned.
2933 // RETURNS: The value of the first key/value pair is returned,
2934 // <hash_table>: a #GHashTable.
2935 // <predicate>: function to test the key/value pairs for a certain property.
2936 // <user_data>: user data to pass to the function.
2937 static void* find(GLib2.HashTable* hash_table, HRFunc predicate, void* user_data) {
2938 return g_hash_table_find(hash_table, predicate, user_data);
2941 // Unintrospectable function: foreach() / g_hash_table_foreach()
2942 // Calls the given function for each of the key/value pairs in the
2943 // #GHashTable. The function is passed the key and value of each
2944 // pair, and the given @user_data parameter. The hash table may not
2945 // be modified while iterating over it (you can't add/remove
2946 // items). To remove all items matching a predicate, use
2947 // g_hash_table_foreach_remove().
2949 // See g_hash_table_find() for performance caveats for linear
2950 // order searches in contrast to g_hash_table_lookup().
2951 // <hash_table>: a #GHashTable.
2952 // <func>: the function to call for each key/value pair.
2953 // <user_data>: user data to pass to the function.
2954 static void foreach_(GLib2.HashTable* hash_table, HFunc func, void* user_data) {
2955 g_hash_table_foreach(hash_table, func, user_data);
2958 // Unintrospectable function: foreach_remove() / g_hash_table_foreach_remove()
2959 // Calls the given function for each key/value pair in the #GHashTable.
2960 // If the function returns %TRUE, then the key/value pair is removed from the
2961 // #GHashTable. If you supplied key or value destroy functions when creating
2962 // the #GHashTable, they are used to free the memory allocated for the removed
2963 // keys and values.
2965 // See #GHashTableIter for an alternative way to loop over the
2966 // key/value pairs in the hash table.
2967 // RETURNS: the number of key/value pairs removed.
2968 // <hash_table>: a #GHashTable.
2969 // <func>: the function to call for each key/value pair.
2970 // <user_data>: user data to pass to the function.
2971 static uint foreach_remove(GLib2.HashTable* hash_table, HRFunc func, void* user_data) {
2972 return g_hash_table_foreach_remove(hash_table, func, user_data);
2975 // Unintrospectable function: foreach_steal() / g_hash_table_foreach_steal()
2976 // Calls the given function for each key/value pair in the #GHashTable.
2977 // If the function returns %TRUE, then the key/value pair is removed from the
2978 // #GHashTable, but no key or value destroy functions are called.
2980 // See #GHashTableIter for an alternative way to loop over the
2981 // key/value pairs in the hash table.
2982 // RETURNS: the number of key/value pairs removed.
2983 // <hash_table>: a #GHashTable.
2984 // <func>: the function to call for each key/value pair.
2985 // <user_data>: user data to pass to the function.
2986 static uint foreach_steal(GLib2.HashTable* hash_table, HRFunc func, void* user_data) {
2987 return g_hash_table_foreach_steal(hash_table, func, user_data);
2990 // Unintrospectable function: get_keys() / g_hash_table_get_keys()
2991 // Retrieves every key inside @hash_table. The returned data is valid
2992 // until @hash_table is modified.
2994 // table. The content of the list is owned by the hash table and
2995 // should not be modified or freed. Use g_list_free() when done
2996 // using the list.
2997 // RETURNS: a #GList containing all the keys inside the hash
2998 // <hash_table>: a #GHashTable
2999 static GLib2.List* get_keys(GLib2.HashTable* hash_table) {
3000 return g_hash_table_get_keys(hash_table);
3003 // Unintrospectable function: get_values() / g_hash_table_get_values()
3004 // Retrieves every value inside @hash_table. The returned data is
3005 // valid until @hash_table is modified.
3007 // table. The content of the list is owned by the hash table and
3008 // should not be modified or freed. Use g_list_free() when done
3009 // using the list.
3010 // RETURNS: a #GList containing all the values inside the hash
3011 // <hash_table>: a #GHashTable
3012 static GLib2.List* get_values(GLib2.HashTable* hash_table) {
3013 return g_hash_table_get_values(hash_table);
3016 // Inserts a new key and value into a #GHashTable.
3018 // If the key already exists in the #GHashTable its current value is replaced
3019 // with the new value. If you supplied a @value_destroy_func when creating the
3020 // #GHashTable, the old value is freed using that function. If you supplied
3021 // a @key_destroy_func when creating the #GHashTable, the passed key is freed
3022 // using that function.
3023 // <hash_table>: a #GHashTable.
3024 // <key>: a key to insert.
3025 // <value>: the value to associate with the key.
3026 static void insert(GLib2.HashTable* hash_table, void* key, void* value) {
3027 g_hash_table_insert(hash_table, key, value);
3030 // Unintrospectable function: lookup() / g_hash_table_lookup()
3031 // Looks up a key in a #GHashTable. Note that this function cannot
3032 // distinguish between a key that is not present and one which is present
3033 // and has the value %NULL. If you need this distinction, use
3034 // g_hash_table_lookup_extended().
3035 // RETURNS: the associated value, or %NULL if the key is not found.
3036 // <hash_table>: a #GHashTable.
3037 // <key>: the key to look up.
3038 static void* lookup(GLib2.HashTable* hash_table, const(void)* key) {
3039 return g_hash_table_lookup(hash_table, key);
3042 // Looks up a key in the #GHashTable, returning the original key and the
3043 // associated value and a #gboolean which is %TRUE if the key was found. This
3044 // is useful if you need to free the memory allocated for the original key,
3045 // for example before calling g_hash_table_remove().
3047 // You can actually pass %NULL for @lookup_key to test
3048 // whether the %NULL key exists, provided the hash and equal functions
3049 // of @hash_table are %NULL-safe.
3050 // RETURNS: %TRUE if the key was found in the #GHashTable.
3051 // <hash_table>: a #GHashTable
3052 // <lookup_key>: the key to look up
3053 // <orig_key>: return location for the original key, or %NULL
3054 // <value>: return location for the value associated with the key, or %NULL
3055 static int lookup_extended(GLib2.HashTable* hash_table, const(void)* lookup_key, void** orig_key, void** value) {
3056 return g_hash_table_lookup_extended(hash_table, lookup_key, orig_key, value);
3059 // Unintrospectable function: new() / g_hash_table_new()
3060 // Creates a new #GHashTable with a reference count of 1.
3061 // RETURNS: a new #GHashTable.
3062 // <hash_func>: a function to create a hash value from a key. Hash values are used to determine where keys are stored within the #GHashTable data structure. The g_direct_hash(), g_int_hash(), g_int64_hash(), g_double_hash() and g_str_hash() functions are provided for some common types of keys. If hash_func is %NULL, g_direct_hash() is used.
3063 // <key_equal_func>: a function to check two keys for equality. This is used when looking up keys in the #GHashTable. The g_direct_equal(), g_int_equal(), g_int64_equal(), g_double_equal() and g_str_equal() functions are provided for the most common types of keys. If @key_equal_func is %NULL, keys are compared directly in a similar fashion to g_direct_equal(), but without the overhead of a function call.
3064 static GLib2.HashTable* new_(HashFunc hash_func, EqualFunc key_equal_func) {
3065 return g_hash_table_new(hash_func, key_equal_func);
3068 // Unintrospectable function: new_full() / g_hash_table_new_full()
3069 // Creates a new #GHashTable like g_hash_table_new() with a reference count
3070 // of 1 and allows to specify functions to free the memory allocated for the
3071 // key and value that get called when removing the entry from the #GHashTable.
3072 // RETURNS: a new #GHashTable.
3073 // <hash_func>: a function to create a hash value from a key.
3074 // <key_equal_func>: a function to check two keys for equality.
3075 // <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.
3076 // <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.
3077 static GLib2.HashTable* new_full(HashFunc hash_func, EqualFunc key_equal_func, DestroyNotify key_destroy_func, DestroyNotify value_destroy_func) {
3078 return g_hash_table_new_full(hash_func, key_equal_func, key_destroy_func, value_destroy_func);
3081 // Unintrospectable function: ref() / g_hash_table_ref()
3082 // Atomically increments the reference count of @hash_table by one.
3083 // This function is MT-safe and may be called from any thread.
3084 // RETURNS: the passed in #GHashTable.
3085 // <hash_table>: a valid #GHashTable.
3086 static GLib2.HashTable* ref_(GLib2.HashTable* hash_table) {
3087 return g_hash_table_ref(hash_table);
3090 // Removes a key and its associated value from a #GHashTable.
3092 // If the #GHashTable was created using g_hash_table_new_full(), the
3093 // key and value are freed using the supplied destroy functions, otherwise
3094 // you have to make sure that any dynamically allocated values are freed
3095 // yourself.
3096 // RETURNS: %TRUE if the key was found and removed from the #GHashTable.
3097 // <hash_table>: a #GHashTable.
3098 // <key>: the key to remove.
3099 static int remove(GLib2.HashTable* hash_table, const(void)* key) {
3100 return g_hash_table_remove(hash_table, key);
3103 // Removes all keys and their associated values from a #GHashTable.
3105 // If the #GHashTable was created using g_hash_table_new_full(), the keys
3106 // and values are freed using the supplied destroy functions, otherwise you
3107 // have to make sure that any dynamically allocated values are freed
3108 // yourself.
3109 // <hash_table>: a #GHashTable
3110 static void remove_all(GLib2.HashTable* hash_table) {
3111 g_hash_table_remove_all(hash_table);
3114 // Inserts a new key and value into a #GHashTable similar to
3115 // g_hash_table_insert(). The difference is that if the key already exists
3116 // in the #GHashTable, it gets replaced by the new key. If you supplied a
3117 // @value_destroy_func when creating the #GHashTable, the old value is freed
3118 // using that function. If you supplied a @key_destroy_func when creating the
3119 // #GHashTable, the old key is freed using that function.
3120 // <hash_table>: a #GHashTable.
3121 // <key>: a key to insert.
3122 // <value>: the value to associate with the key.
3123 static void replace(GLib2.HashTable* hash_table, void* key, void* value) {
3124 g_hash_table_replace(hash_table, key, value);
3127 // Returns the number of elements contained in the #GHashTable.
3128 // RETURNS: the number of key/value pairs in the #GHashTable.
3129 // <hash_table>: a #GHashTable.
3130 static uint size(GLib2.HashTable* hash_table) {
3131 return g_hash_table_size(hash_table);
3134 // Removes a key and its associated value from a #GHashTable without
3135 // calling the key and value destroy functions.
3136 // RETURNS: %TRUE if the key was found and removed from the #GHashTable.
3137 // <hash_table>: a #GHashTable.
3138 // <key>: the key to remove.
3139 static int steal(GLib2.HashTable* hash_table, const(void)* key) {
3140 return g_hash_table_steal(hash_table, key);
3143 // Removes all keys and their associated values from a #GHashTable
3144 // without calling the key and value destroy functions.
3145 // <hash_table>: a #GHashTable.
3146 static void steal_all(GLib2.HashTable* hash_table) {
3147 g_hash_table_steal_all(hash_table);
3150 // Atomically decrements the reference count of @hash_table by one.
3151 // If the reference count drops to 0, all keys and values will be
3152 // destroyed, and all memory allocated by the hash table is released.
3153 // This function is MT-safe and may be called from any thread.
3154 // <hash_table>: a valid #GHashTable.
3155 static void unref(GLib2.HashTable* hash_table) {
3156 g_hash_table_unref(hash_table);
3161 // A GHashTableIter structure represents an iterator that can be used
3162 // to iterate over the elements of a #GHashTable. GHashTableIter
3163 // structures are typically allocated on the stack and then initialized
3164 // with g_hash_table_iter_init().
3165 struct HashTableIter {
3166 private void* dummy1, dummy2, dummy3;
3167 private int dummy4;
3168 private int dummy5;
3169 private void* dummy6;
3172 // Unintrospectable method: get_hash_table() / g_hash_table_iter_get_hash_table()
3173 // Returns the #GHashTable associated with @iter.
3174 // RETURNS: the #GHashTable associated with @iter.
3175 GLib2.HashTable* get_hash_table() {
3176 return g_hash_table_iter_get_hash_table(&this);
3179 // Initializes a key/value pair iterator and associates it with
3180 // @hash_table. Modifying the hash table after calling this function
3181 // invalidates the returned iterator.
3182 // |[
3183 // GHashTableIter iter;
3184 // gpointer key, value;
3186 // g_hash_table_iter_init (&iter, hash_table);
3187 // while (g_hash_table_iter_next (&iter, &key, &value))
3188 // {
3189 // /&ast; do something with key and value &ast;/
3190 // }
3191 // ]|
3192 // <hash_table>: a #GHashTable.
3193 void init(GLib2.HashTable* hash_table) {
3194 g_hash_table_iter_init(&this, hash_table);
3197 // Advances @iter and retrieves the key and/or value that are now
3198 // pointed to as a result of this advancement. If %FALSE is returned,
3199 // @key and @value are not set, and the iterator becomes invalid.
3200 // RETURNS: %FALSE if the end of the #GHashTable has been reached.
3201 // <key>: a location to store the key, or %NULL.
3202 // <value>: a location to store the value, or %NULL.
3203 int next(void** key, void** value) {
3204 return g_hash_table_iter_next(&this, key, value);
3207 // Removes the key/value pair currently pointed to by the iterator
3208 // from its associated #GHashTable. Can only be called after
3209 // g_hash_table_iter_next() returned %TRUE, and cannot be called more
3210 // than once for the same key/value pair.
3212 // If the #GHashTable was created using g_hash_table_new_full(), the
3213 // key and value are freed using the supplied destroy functions, otherwise
3214 // you have to make sure that any dynamically allocated values are freed
3215 // yourself.
3216 void remove() {
3217 g_hash_table_iter_remove(&this);
3220 // Replaces the value currently pointed to by the iterator
3221 // from its associated #GHashTable. Can only be called after
3222 // g_hash_table_iter_next() returned %TRUE.
3224 // If you supplied a @value_destroy_func when creating the #GHashTable,
3225 // the old value is freed using that function.
3226 // <value>: the value to replace with
3227 void replace(void* value) {
3228 g_hash_table_iter_replace(&this, value);
3231 // Removes the key/value pair currently pointed to by the iterator
3232 // from its associated #GHashTable, without calling the key and value
3233 // destroy functions. Can only be called after
3234 // g_hash_table_iter_next() returned %TRUE, and cannot be called more
3235 // than once for the same key/value pair.
3236 void steal() {
3237 g_hash_table_iter_steal(&this);
3242 // An opaque structure representing a HMAC operation.
3243 // To create a new GHmac, use g_hmac_new(). To free
3244 // a GHmac, use g_hmac_unref().
3245 struct Hmac /* Version 2.30 */ {
3247 // Unintrospectable method: copy() / g_hmac_copy()
3248 // Copies a #GHmac. If @hmac has been closed, by calling
3249 // g_hmac_get_string() or g_hmac_get_digest(), the copied
3250 // HMAC will be closed as well.
3252 // when finished using it.
3253 // RETURNS: the copy of the passed #GHmac. Use g_hmac_unref()
3254 Hmac* copy() {
3255 return g_hmac_copy(&this);
3258 // Gets the digest from @checksum as a raw binary array and places it
3259 // into @buffer. The size of the digest depends on the type of checksum.
3261 // Once this function has been called, the #GHmac is closed and can
3262 // no longer be updated with g_checksum_update().
3263 // <buffer>: output buffer
3264 // <digest_len>: an inout parameter. The caller initializes it to the size of @buffer. After the call it contains the length of the digest
3265 void get_digest(ubyte* buffer, size_t* digest_len) {
3266 g_hmac_get_digest(&this, buffer, digest_len);
3269 // Gets the HMAC as an hexadecimal string.
3271 // Once this function has been called the #GHmac can no longer be
3272 // updated with g_hmac_update().
3274 // The hexadecimal characters will be lower case.
3276 // returned string is owned by the HMAC and should not be modified
3277 // or freed.
3278 // RETURNS: the hexadecimal representation of the HMAC. The
3279 char* get_string() {
3280 return g_hmac_get_string(&this);
3283 // Unintrospectable method: ref() / g_hmac_ref()
3284 // Atomically increments the reference count of @hmac by one.
3286 // This function is MT-safe and may be called from any thread.
3287 // RETURNS: the passed in #GHmac.
3288 Hmac* ref_() {
3289 return g_hmac_ref(&this);
3292 // Atomically decrements the reference count of @hmac by one.
3294 // If the reference count drops to 0, all keys and values will be
3295 // destroyed, and all memory allocated by the hash table is released.
3296 // This function is MT-safe and may be called from any thread.
3297 // Frees the memory allocated for @hmac.
3298 void unref() {
3299 g_hmac_unref(&this);
3302 // Feeds @data into an existing #GHmac.
3304 // The HMAC must still be open, that is g_hmac_get_string() or
3305 // g_hmac_get_digest() must not have been called on @hmac.
3306 // <data>: buffer used to compute the checksum
3307 // <length>: size of the buffer, or -1 if it is a nul-terminated string
3308 void update(ubyte* data, ssize_t length) {
3309 g_hmac_update(&this, data, length);
3312 // Unintrospectable function: new() / g_hmac_new()
3313 // Creates a new #GHmac, using the digest algorithm @digest_type.
3314 // If the @digest_type is not known, %NULL is returned.
3315 // A #GHmac can be used to compute the HMAC of a key and an
3316 // arbitrary binary blob, using different hashing algorithms.
3318 // A #GHmac works by feeding a binary blob through g_hmac_update()
3319 // until the data is complete; the digest can then be extracted
3320 // using g_hmac_get_string(), which will return the checksum as a
3321 // hexadecimal string; or g_hmac_get_digest(), which will return a
3322 // array of raw bytes. Once either g_hmac_get_string() or
3323 // g_hmac_get_digest() have been called on a #GHmac, the HMAC
3324 // will be closed and it won't be possible to call g_hmac_update()
3325 // on it anymore.
3327 // Use g_hmac_unref() to free the memory allocated by it.
3328 // RETURNS: the newly created #GHmac, or %NULL.
3329 // <digest_type>: the desired type of digest
3330 // <key>: the key for the HMAC
3331 // <key_len>: the length of the keys
3332 static Hmac* new_(ChecksumType digest_type, ubyte* key, size_t key_len) {
3333 return g_hmac_new(digest_type, key, key_len);
3337 struct Hook {
3338 void* data;
3339 Hook* next, prev;
3340 uint ref_count;
3341 c_ulong hook_id;
3342 uint flags;
3343 void* func;
3344 DestroyNotify destroy_;
3346 int compare_ids(Hook* sibling) {
3347 return g_hook_compare_ids(&this, sibling);
3349 // Unintrospectable function: alloc() / g_hook_alloc()
3350 static Hook* alloc(HookList* hook_list) {
3351 return g_hook_alloc(hook_list);
3353 static int destroy(HookList* hook_list, c_ulong hook_id) {
3354 return g_hook_destroy(hook_list, hook_id);
3356 static void destroy_link(HookList* hook_list, Hook* hook) {
3357 g_hook_destroy_link(hook_list, hook);
3359 // Unintrospectable function: find() / g_hook_find()
3360 static Hook* find(HookList* hook_list, int need_valids, HookFindFunc func, void* data) {
3361 return g_hook_find(hook_list, need_valids, func, data);
3363 // Unintrospectable function: find_data() / g_hook_find_data()
3364 static Hook* find_data(HookList* hook_list, int need_valids, void* data) {
3365 return g_hook_find_data(hook_list, need_valids, data);
3367 // Unintrospectable function: find_func() / g_hook_find_func()
3368 static Hook* find_func(HookList* hook_list, int need_valids, void* func) {
3369 return g_hook_find_func(hook_list, need_valids, func);
3371 // Unintrospectable function: find_func_data() / g_hook_find_func_data()
3372 static Hook* find_func_data(HookList* hook_list, int need_valids, void* func, void* data) {
3373 return g_hook_find_func_data(hook_list, need_valids, func, data);
3375 // Unintrospectable function: first_valid() / g_hook_first_valid()
3376 static Hook* first_valid(HookList* hook_list, int may_be_in_call) {
3377 return g_hook_first_valid(hook_list, may_be_in_call);
3379 static void free(HookList* hook_list, Hook* hook) {
3380 g_hook_free(hook_list, hook);
3382 // Unintrospectable function: get() / g_hook_get()
3383 static Hook* get(HookList* hook_list, c_ulong hook_id) {
3384 return g_hook_get(hook_list, hook_id);
3386 static void insert_before(HookList* hook_list, Hook* sibling, Hook* hook) {
3387 g_hook_insert_before(hook_list, sibling, hook);
3389 // Unintrospectable function: insert_sorted() / g_hook_insert_sorted()
3390 static void insert_sorted(HookList* hook_list, Hook* hook, HookCompareFunc func) {
3391 g_hook_insert_sorted(hook_list, hook, func);
3393 // Unintrospectable function: next_valid() / g_hook_next_valid()
3394 static Hook* next_valid(HookList* hook_list, Hook* hook, int may_be_in_call) {
3395 return g_hook_next_valid(hook_list, hook, may_be_in_call);
3397 static void prepend(HookList* hook_list, Hook* hook) {
3398 g_hook_prepend(hook_list, hook);
3400 // Unintrospectable function: ref() / g_hook_ref()
3401 static Hook* ref_(HookList* hook_list, Hook* hook) {
3402 return g_hook_ref(hook_list, hook);
3404 static void unref(HookList* hook_list, Hook* hook) {
3405 g_hook_unref(hook_list, hook);
3409 extern (C) alias int function (void* data) HookCheckFunc;
3411 extern (C) alias int function (Hook* hook, void* marshal_data) HookCheckMarshaller;
3413 extern (C) alias int function (Hook* new_hook, Hook* sibling) HookCompareFunc;
3415 extern (C) alias void function (HookList* hook_list, Hook* hook) HookFinalizeFunc;
3417 extern (C) alias int function (Hook* hook, void* data) HookFindFunc;
3419 enum HookFlagMask {
3420 ACTIVE = 1,
3421 IN_CALL = 2,
3422 MASK = 15
3424 extern (C) alias void function (void* data) HookFunc;
3426 struct HookList {
3427 c_ulong seq_id;
3428 static import std.bitmanip; mixin(std.bitmanip.bitfields!(
3429 uint, "hook_size", 16,
3430 uint, "is_setup", 1,
3431 uint, "__dummy32A", 15));
3432 Hook* hooks;
3433 void* dummy3;
3434 HookFinalizeFunc finalize_hook;
3435 void*[2] dummy;
3437 void clear() {
3438 g_hook_list_clear(&this);
3440 void init(uint hook_size) {
3441 g_hook_list_init(&this, hook_size);
3443 void invoke(int may_recurse) {
3444 g_hook_list_invoke(&this, may_recurse);
3446 void invoke_check(int may_recurse) {
3447 g_hook_list_invoke_check(&this, may_recurse);
3449 // Unintrospectable method: marshal() / g_hook_list_marshal()
3450 void marshal(int may_recurse, HookMarshaller marshaller, void* marshal_data) {
3451 g_hook_list_marshal(&this, may_recurse, marshaller, marshal_data);
3453 // Unintrospectable method: marshal_check() / g_hook_list_marshal_check()
3454 void marshal_check(int may_recurse, HookCheckMarshaller marshaller, void* marshal_data) {
3455 g_hook_list_marshal_check(&this, may_recurse, marshaller, marshal_data);
3459 extern (C) alias void function (Hook* hook, void* marshal_data) HookMarshaller;
3461 struct IConv {
3463 // Same as the standard UNIX routine iconv(), but
3464 // may be implemented via libiconv on UNIX flavors that lack
3465 // a native implementation.
3467 // GLib provides g_convert() and g_locale_to_utf8() which are likely
3468 // more convenient than the raw iconv wrappers.
3469 // RETURNS: count of non-reversible conversions, or -1 on error
3470 // <inbuf>: bytes to convert
3471 // <inbytes_left>: inout parameter, bytes remaining to convert in @inbuf
3472 // <outbuf>: converted output bytes
3473 // <outbytes_left>: inout parameter, bytes available to fill in @outbuf
3474 size_t /*NAME MISSING IN GIR*/ iconv(char** inbuf, size_t* inbytes_left, char** outbuf, size_t* outbytes_left) {
3475 return g_iconv(&this, inbuf, inbytes_left, outbuf, outbytes_left);
3478 // Same as the standard UNIX routine iconv_close(), but
3479 // may be implemented via libiconv on UNIX flavors that lack
3480 // a native implementation. Should be called to clean up
3481 // the conversion descriptor from g_iconv_open() when
3482 // you are done converting things.
3484 // GLib provides g_convert() and g_locale_to_utf8() which are likely
3485 // more convenient than the raw iconv wrappers.
3486 // RETURNS: -1 on error, 0 on success
3487 int close() {
3488 return g_iconv_close(&this);
3491 // Unintrospectable function: open() / g_iconv_open()
3492 // Same as the standard UNIX routine iconv_open(), but
3493 // may be implemented via libiconv on UNIX flavors that lack
3494 // a native implementation.
3496 // GLib provides g_convert() and g_locale_to_utf8() which are likely
3497 // more convenient than the raw iconv wrappers.
3499 // opening the converter failed.
3500 // RETURNS: a "conversion descriptor", or (GIConv)-1 if
3501 // <to_codeset>: destination codeset
3502 // <from_codeset>: source codeset
3503 static IConv open(char* to_codeset, char* from_codeset) {
3504 return g_iconv_open(to_codeset, from_codeset);
3508 enum int IEEE754_DOUBLE_BIAS = 1023;
3509 enum int IEEE754_FLOAT_BIAS = 127;
3511 // A data structure representing an IO Channel. The fields should be
3512 // considered private and should only be accessed with the following
3513 // functions.
3514 struct IOChannel {
3515 private int ref_count;
3516 private IOFuncs* funcs;
3517 private char* encoding;
3518 private IConv read_cd, write_cd;
3519 private char* line_term;
3520 private uint line_term_len;
3521 private size_t buf_size;
3522 private String* read_buf, encoded_read_buf, write_buf;
3523 private char[6] partial_write_buf;
3524 static import std.bitmanip; mixin(std.bitmanip.bitfields!(
3525 uint, "use_buffer", 1,
3526 uint, "do_encode", 1,
3527 uint, "close_on_unref", 1,
3528 uint, "is_readable", 1,
3529 uint, "is_writeable", 1,
3530 uint, "is_seekable", 1,
3531 uint, "__dummy32A", 26));
3532 private void* reserved1, reserved2;
3535 // Open a file @filename as a #GIOChannel using mode @mode. This
3536 // channel will be closed when the last reference to it is dropped,
3537 // so there is no need to call g_io_channel_close() (though doing
3538 // so will not cause problems, as long as no attempt is made to
3539 // access the channel after it is closed).
3540 // RETURNS: A #GIOChannel on success, %NULL on failure.
3541 // <filename>: A string containing the name of a file
3542 // <mode>: One of "r", "w", "a", "r+", "w+", "a+". These have the same meaning as in fopen()
3543 static IOChannel* /*new*/ new_file(char* filename, char* mode, GLib2.Error** error=null) {
3544 return g_io_channel_new_file(filename, mode, error);
3547 // Creates a new #GIOChannel given a file descriptor. On UNIX systems
3548 // this works for plain files, pipes, and sockets.
3550 // The returned #GIOChannel has a reference count of 1.
3552 // The default encoding for #GIOChannel is UTF-8. If your application
3553 // is reading output from a command using via pipe, you may need to set
3554 // the encoding to the encoding of the current locale (see
3555 // g_get_charset()) with the g_io_channel_set_encoding() function.
3557 // If you want to read raw binary data without interpretation, then
3558 // call the g_io_channel_set_encoding() function with %NULL for the
3559 // encoding argument.
3561 // This function is available in GLib on Windows, too, but you should
3562 // avoid using it on Windows. The domain of file descriptors and
3563 // sockets overlap. There is no way for GLib to know which one you mean
3564 // in case the argument you pass to this function happens to be both a
3565 // valid file descriptor and socket. If that happens a warning is
3566 // issued, and GLib assumes that it is the file descriptor you mean.
3567 // <fd>: a file descriptor.
3568 static IOChannel* /*new*/ unix_new(int fd) {
3569 return g_io_channel_unix_new(fd);
3572 // Close an IO channel. Any pending data to be written will be
3573 // flushed, ignoring errors. The channel will not be freed until the
3574 // last reference is dropped using g_io_channel_unref().
3576 // Deprecated:2.2: Use g_io_channel_shutdown() instead.
3577 void close() {
3578 g_io_channel_close(&this);
3581 // Flushes the write buffer for the GIOChannel.
3583 // #G_IO_STATUS_NORMAL, #G_IO_STATUS_AGAIN, or
3584 // #G_IO_STATUS_ERROR.
3585 // RETURNS: the status of the operation: One of
3586 IOStatus flush(GLib2.Error** error=null) {
3587 return g_io_channel_flush(&this, error);
3590 // This function returns a #GIOCondition depending on whether there
3591 // is data to be read/space to write data in the internal buffers in
3592 // the #GIOChannel. Only the flags %G_IO_IN and %G_IO_OUT may be set.
3593 // RETURNS: A #GIOCondition
3594 IOCondition get_buffer_condition() {
3595 return g_io_channel_get_buffer_condition(&this);
3598 // Gets the buffer size.
3599 // RETURNS: the size of the buffer.
3600 size_t get_buffer_size() {
3601 return g_io_channel_get_buffer_size(&this);
3604 // Returns whether @channel is buffered.
3605 // RETURNS: %TRUE if the @channel is buffered.
3606 int get_buffered() {
3607 return g_io_channel_get_buffered(&this);
3610 // Returns whether the file/socket/whatever associated with @channel
3611 // will be closed when @channel receives its final unref and is
3612 // destroyed. The default value of this is %TRUE for channels created
3613 // by g_io_channel_new_file (), and %FALSE for all other channels.
3615 // the GIOChannel data structure.
3616 // RETURNS: Whether the channel will be closed on the final unref of
3617 int get_close_on_unref() {
3618 return g_io_channel_get_close_on_unref(&this);
3621 // Gets the encoding for the input/output of the channel.
3622 // The internal encoding is always UTF-8. The encoding %NULL
3623 // makes the channel safe for binary data.
3625 // owned by GLib and must not be freed.
3626 // RETURNS: A string containing the encoding, this string is
3627 char* get_encoding() {
3628 return g_io_channel_get_encoding(&this);
3631 // Gets the current flags for a #GIOChannel, including read-only
3632 // flags such as %G_IO_FLAG_IS_READABLE.
3634 // The values of the flags %G_IO_FLAG_IS_READABLE and %G_IO_FLAG_IS_WRITEABLE
3635 // are cached for internal use by the channel when it is created.
3636 // If they should change at some later point (e.g. partial shutdown
3637 // of a socket with the UNIX shutdown() function), the user
3638 // should immediately call g_io_channel_get_flags() to update
3639 // the internal values of these flags.
3640 // RETURNS: the flags which are set on the channel
3641 IOFlags get_flags() {
3642 return g_io_channel_get_flags(&this);
3645 // This returns the string that #GIOChannel uses to determine
3646 // where in the file a line break occurs. A value of %NULL
3647 // indicates autodetection.
3649 // is owned by GLib and must not be freed.
3650 // RETURNS: The line termination string. This value
3651 // <length>: a location to return the length of the line terminator
3652 char* get_line_term(int* length) {
3653 return g_io_channel_get_line_term(&this, length);
3656 // Initializes a #GIOChannel struct.
3658 // This is called by each of the above functions when creating a
3659 // #GIOChannel, and so is not often needed by the application
3660 // programmer (unless you are creating a new type of #GIOChannel).
3661 void init() {
3662 g_io_channel_init(&this);
3665 // Reads data from a #GIOChannel.
3668 // Deprecated:2.2: Use g_io_channel_read_chars() instead.
3669 // RETURNS: %G_IO_ERROR_NONE if the operation was successful.
3670 // <buf>: a buffer to read the data into (which should be at least count bytes long)
3671 // <count>: the number of bytes to read from the #GIOChannel
3672 // <bytes_read>: returns the number of bytes actually read
3673 IOError read(char* buf, size_t count, size_t* bytes_read) {
3674 return g_io_channel_read(&this, buf, count, bytes_read);
3677 // Replacement for g_io_channel_read() with the new API.
3678 // RETURNS: the status of the operation.
3679 // <buf>: a buffer to read data into
3680 // <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.
3681 // <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.
3682 IOStatus read_chars(char* buf, size_t count, size_t* bytes_read, GLib2.Error** error=null) {
3683 return g_io_channel_read_chars(&this, buf, count, bytes_read, error);
3686 // Reads a line, including the terminating character(s),
3687 // from a #GIOChannel into a newly-allocated string.
3688 // @str_return will contain allocated memory if the return
3689 // is %G_IO_STATUS_NORMAL.
3690 // RETURNS: the status of the operation.
3691 // <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.
3692 // <length>: location to store length of the read data, or %NULL
3693 // <terminator_pos>: location to store position of line terminator, or %NULL
3694 IOStatus read_line(char** str_return, size_t* length, size_t* terminator_pos, GLib2.Error** error=null) {
3695 return g_io_channel_read_line(&this, str_return, length, terminator_pos, error);
3698 // Reads a line from a #GIOChannel, using a #GString as a buffer.
3699 // RETURNS: the status of the operation.
3700 // <buffer>: a #GString into which the line will be written. If @buffer already contains data, the old data will be overwritten.
3701 // <terminator_pos>: location to store position of line terminator, or %NULL
3702 IOStatus read_line_string(String* buffer, size_t* terminator_pos, GLib2.Error** error=null) {
3703 return g_io_channel_read_line_string(&this, buffer, terminator_pos, error);
3706 // Reads all the remaining data from the file.
3708 // This function never returns %G_IO_STATUS_EOF.
3709 // RETURNS: %G_IO_STATUS_NORMAL on success.
3710 // <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.
3711 // <length>: location to store length of the data
3712 IOStatus read_to_end(char** str_return, size_t* length, GLib2.Error** error=null) {
3713 return g_io_channel_read_to_end(&this, str_return, length, error);
3716 // Reads a Unicode character from @channel.
3717 // This function cannot be called on a channel with %NULL encoding.
3718 // RETURNS: a #GIOStatus
3719 // <thechar>: a location to return a character
3720 IOStatus read_unichar(dchar* thechar, GLib2.Error** error=null) {
3721 return g_io_channel_read_unichar(&this, thechar, error);
3724 // Increments the reference count of a #GIOChannel.
3725 // RETURNS: the @channel that was passed in (since 2.6)
3726 IOChannel* /*new*/ ref_() {
3727 return g_io_channel_ref(&this);
3730 // Sets the current position in the #GIOChannel, similar to the standard
3731 // library function fseek().
3734 // Deprecated:2.2: Use g_io_channel_seek_position() instead.
3735 // RETURNS: %G_IO_ERROR_NONE if the operation was successful.
3736 // <offset>: an offset, in bytes, which is added to the position specified by @type
3737 // <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)
3738 IOError seek(long offset, SeekType type) {
3739 return g_io_channel_seek(&this, offset, type);
3742 // Replacement for g_io_channel_seek() with the new API.
3743 // RETURNS: the status of the operation.
3744 // <offset>: The offset in bytes from the position specified by @type
3745 // <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.
3746 IOStatus seek_position(long offset, SeekType type, GLib2.Error** error=null) {
3747 return g_io_channel_seek_position(&this, offset, type, error);
3750 // Sets the buffer size.
3751 // <size>: the size of the buffer, or 0 to let GLib pick a good size
3752 void set_buffer_size(size_t size) {
3753 g_io_channel_set_buffer_size(&this, size);
3756 // The buffering state can only be set if the channel's encoding
3757 // is %NULL. For any other encoding, the channel must be buffered.
3759 // A buffered channel can only be set unbuffered if the channel's
3760 // internal buffers have been flushed. Newly created channels or
3761 // channels which have returned %G_IO_STATUS_EOF
3762 // not require such a flush. For write-only channels, a call to
3763 // g_io_channel_flush () is sufficient. For all other channels,
3764 // the buffers may be flushed by a call to g_io_channel_seek_position ().
3765 // This includes the possibility of seeking with seek type %G_SEEK_CUR
3766 // and an offset of zero. Note that this means that socket-based
3767 // channels cannot be set unbuffered once they have had data
3768 // read from them.
3770 // On unbuffered channels, it is safe to mix read and write
3771 // calls from the new and old APIs, if this is necessary for
3772 // maintaining old code.
3774 // The default state of the channel is buffered.
3775 // <buffered>: whether to set the channel buffered or unbuffered
3776 void set_buffered(int buffered) {
3777 g_io_channel_set_buffered(&this, buffered);
3780 // Setting this flag to %TRUE for a channel you have already closed
3781 // can cause problems.
3782 // <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.
3783 void set_close_on_unref(int do_close) {
3784 g_io_channel_set_close_on_unref(&this, do_close);
3787 // Sets the encoding for the input/output of the channel.
3788 // The internal encoding is always UTF-8. The default encoding
3789 // for the external file is UTF-8.
3791 // The encoding %NULL is safe to use with binary data.
3793 // The encoding can only be set if one of the following conditions
3794 // is true:
3795 // <itemizedlist>
3796 // <listitem><para>
3797 // The channel was just created, and has not been written to or read
3798 // from yet.
3799 // </para></listitem>
3800 // <listitem><para>
3801 // The channel is write-only.
3802 // </para></listitem>
3803 // <listitem><para>
3804 // The channel is a file, and the file pointer was just
3805 // repositioned by a call to g_io_channel_seek_position().
3806 // (This flushes all the internal buffers.)
3807 // </para></listitem>
3808 // <listitem><para>
3809 // The current encoding is %NULL or UTF-8.
3810 // </para></listitem>
3811 // <listitem><para>
3812 // One of the (new API) read functions has just returned %G_IO_STATUS_EOF
3813 // (or, in the case of g_io_channel_read_to_end(), %G_IO_STATUS_NORMAL).
3814 // </para></listitem>
3815 // <listitem><para>
3816 // One of the functions g_io_channel_read_chars() or
3817 // g_io_channel_read_unichar() has returned %G_IO_STATUS_AGAIN or
3818 // %G_IO_STATUS_ERROR. This may be useful in the case of
3819 // %G_CONVERT_ERROR_ILLEGAL_SEQUENCE.
3820 // Returning one of these statuses from g_io_channel_read_line(),
3821 // g_io_channel_read_line_string(), or g_io_channel_read_to_end()
3822 // does <emphasis>not</emphasis> guarantee that the encoding can
3823 // be changed.
3824 // </para></listitem>
3825 // </itemizedlist>
3826 // Channels which do not meet one of the above conditions cannot call
3827 // g_io_channel_seek_position() with an offset of %G_SEEK_CUR, and, if
3828 // they are "seekable", cannot call g_io_channel_write_chars() after
3829 // calling one of the API "read" functions.
3830 // RETURNS: %G_IO_STATUS_NORMAL if the encoding was successfully set.
3831 // <encoding>: the encoding type
3832 IOStatus set_encoding(char* encoding, GLib2.Error** error=null) {
3833 return g_io_channel_set_encoding(&this, encoding, error);
3836 // Sets the (writeable) flags in @channel to (@flags & %G_IO_CHANNEL_SET_MASK).
3837 // RETURNS: the status of the operation.
3838 // <flags>: the flags to set on the IO channel
3839 IOStatus set_flags(IOFlags flags, GLib2.Error** error=null) {
3840 return g_io_channel_set_flags(&this, flags, error);
3843 // This sets the string that #GIOChannel uses to determine
3844 // where in the file a line break occurs.
3845 // <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.
3846 // <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.
3847 void set_line_term(char* line_term, int length) {
3848 g_io_channel_set_line_term(&this, line_term, length);
3851 // Close an IO channel. Any pending data to be written will be
3852 // flushed if @flush is %TRUE. The channel will not be freed until the
3853 // last reference is dropped using g_io_channel_unref().
3854 // RETURNS: the status of the operation.
3855 // <flush>: if %TRUE, flush pending
3856 IOStatus shutdown(int flush, GLib2.Error** error=null) {
3857 return g_io_channel_shutdown(&this, flush, error);
3860 // Returns the file descriptor of the #GIOChannel.
3862 // On Windows this function returns the file descriptor or socket of
3863 // the #GIOChannel.
3864 int unix_get_fd() {
3865 return g_io_channel_unix_get_fd(&this);
3867 // Decrements the reference count of a #GIOChannel.
3868 void unref() {
3869 g_io_channel_unref(&this);
3872 // Writes data to a #GIOChannel.
3875 // Deprecated:2.2: Use g_io_channel_write_chars() instead.
3876 // RETURNS: %G_IO_ERROR_NONE if the operation was successful.
3877 // <buf>: the buffer containing the data to write
3878 // <count>: the number of bytes to write
3879 // <bytes_written>: the number of bytes actually written
3880 IOError write(char* buf, size_t count, size_t* bytes_written) {
3881 return g_io_channel_write(&this, buf, count, bytes_written);
3884 // Replacement for g_io_channel_write() with the new API.
3886 // On seekable channels with encodings other than %NULL or UTF-8, generic
3887 // mixing of reading and writing is not allowed. A call to g_io_channel_write_chars ()
3888 // may only be made on a channel from which data has been read in the
3889 // cases described in the documentation for g_io_channel_set_encoding ().
3890 // RETURNS: the status of the operation.
3891 // <buf>: a buffer to write data from
3892 // <count>: the size of the buffer. If -1, the buffer is taken to be a nul-terminated string.
3893 // <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.
3894 IOStatus write_chars(char* buf, ssize_t count, size_t* bytes_written, GLib2.Error** error=null) {
3895 return g_io_channel_write_chars(&this, buf, count, bytes_written, error);
3898 // Writes a Unicode character to @channel.
3899 // This function cannot be called on a channel with %NULL encoding.
3900 // RETURNS: a #GIOStatus
3901 // <thechar>: a character
3902 IOStatus write_unichar(dchar thechar, GLib2.Error** error=null) {
3903 return g_io_channel_write_unichar(&this, thechar, error);
3906 // Converts an <literal>errno</literal> error number to a #GIOChannelError.
3908 // %G_IO_CHANNEL_ERROR_INVAL.
3909 // RETURNS: a #GIOChannelError error number, e.g.
3910 // <en>: an <literal>errno</literal> error number, e.g. %EINVAL
3911 static IOChannelError error_from_errno(int en) {
3912 return g_io_channel_error_from_errno(en);
3914 // RETURNS: the quark used as %G_IO_CHANNEL_ERROR
3915 static Quark error_quark() {
3916 return g_io_channel_error_quark();
3920 // Error codes returned by #GIOChannel operations.
3921 enum IOChannelError {
3922 FBIG = 0,
3923 INVAL = 1,
3924 IO = 2,
3925 ISDIR = 3,
3926 NOSPC = 4,
3927 NXIO = 5,
3928 OVERFLOW = 6,
3929 PIPE = 7,
3930 FAILED = 8
3933 // A bitwise combination representing a condition to watch for on an
3934 // event source.
3935 enum IOCondition {
3936 IN = 1,
3937 OUT = 4,
3938 PRI = 2,
3939 ERR = 8,
3940 HUP = 16,
3941 NVAL = 32
3944 // #GIOError is only used by the deprecated functions
3945 // g_io_channel_read(), g_io_channel_write(), and g_io_channel_seek().
3946 enum IOError {
3947 NONE = 0,
3948 AGAIN = 1,
3949 INVAL = 2,
3950 UNKNOWN = 3
3953 // Specifies properties of a #GIOChannel. Some of the flags can only be
3954 // read with g_io_channel_get_flags(), but not changed with
3955 // g_io_channel_set_flags().
3956 enum IOFlags {
3957 APPEND = 1,
3958 NONBLOCK = 2,
3959 IS_READABLE = 4,
3960 IS_WRITEABLE = 8,
3961 IS_SEEKABLE = 16,
3962 MASK = 31,
3963 GET_MASK = 31,
3964 SET_MASK = 3
3967 // Specifies the type of function passed to g_io_add_watch() or
3968 // g_io_add_watch_full(), which is called when the requested condition
3969 // on a #GIOChannel is satisfied.
3970 // <source>: the #GIOChannel event source
3971 // <condition>: the condition which has been satisfied
3972 // <data>: user data set in g_io_add_watch() or g_io_add_watch_full()
3973 extern (C) alias int function (IOChannel* source, IOCondition condition, void* data) IOFunc;
3976 // A table of functions used to handle different types of #GIOChannel
3977 // in a generic way.
3978 struct IOFuncs {
3979 extern (C) IOStatus function (IOChannel* channel, char* buf, size_t count, size_t* bytes_read, GLib2.Error** error=null) io_read;
3980 extern (C) IOStatus function (IOChannel* channel, char* buf, size_t count, size_t* bytes_written, GLib2.Error** error=null) io_write;
3981 extern (C) IOStatus function (IOChannel* channel, long offset, SeekType type, GLib2.Error** error=null) io_seek;
3982 extern (C) IOStatus function (IOChannel* channel, GLib2.Error** error=null) io_close;
3983 extern (C) Source* /*new*/ function (IOChannel* channel, IOCondition condition) io_create_watch;
3984 extern (C) void function (IOChannel* channel) io_free;
3985 extern (C) IOStatus function (IOChannel* channel, IOFlags flags, GLib2.Error** error=null) io_set_flags;
3986 extern (C) IOFlags function (IOChannel* channel) io_get_flags;
3989 // Stati returned by most of the #GIOFuncs functions.
3990 enum IOStatus {
3991 ERROR = 0,
3992 NORMAL = 1,
3993 EOF = 2,
3994 AGAIN = 3
3996 enum KEY_FILE_DESKTOP_GROUP = "Desktop Entry";
3997 enum KEY_FILE_DESKTOP_KEY_CATEGORIES = "Categories";
3998 enum KEY_FILE_DESKTOP_KEY_COMMENT = "Comment";
3999 enum KEY_FILE_DESKTOP_KEY_EXEC = "Exec";
4000 enum KEY_FILE_DESKTOP_KEY_GENERIC_NAME = "GenericName";
4001 enum KEY_FILE_DESKTOP_KEY_HIDDEN = "Hidden";
4002 enum KEY_FILE_DESKTOP_KEY_ICON = "Icon";
4003 enum KEY_FILE_DESKTOP_KEY_MIME_TYPE = "MimeType";
4004 enum KEY_FILE_DESKTOP_KEY_NAME = "Name";
4005 enum KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN = "NotShowIn";
4006 enum KEY_FILE_DESKTOP_KEY_NO_DISPLAY = "NoDisplay";
4007 enum KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN = "OnlyShowIn";
4008 enum KEY_FILE_DESKTOP_KEY_PATH = "Path";
4009 enum KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY = "StartupNotify";
4010 enum KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS = "StartupWMClass";
4011 enum KEY_FILE_DESKTOP_KEY_TERMINAL = "Terminal";
4012 enum KEY_FILE_DESKTOP_KEY_TRY_EXEC = "TryExec";
4013 enum KEY_FILE_DESKTOP_KEY_TYPE = "Type";
4014 enum KEY_FILE_DESKTOP_KEY_URL = "URL";
4015 enum KEY_FILE_DESKTOP_KEY_VERSION = "Version";
4016 enum KEY_FILE_DESKTOP_TYPE_APPLICATION = "Application";
4017 enum KEY_FILE_DESKTOP_TYPE_DIRECTORY = "Directory";
4018 enum KEY_FILE_DESKTOP_TYPE_LINK = "Link";
4019 struct KeyFile {
4020 // Frees a #GKeyFile.
4021 void free() {
4022 g_key_file_free(&this);
4025 // Returns the value associated with @key under @group_name as a
4026 // boolean.
4028 // If @key cannot be found then %FALSE is returned and @error is set
4029 // to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value
4030 // associated with @key cannot be interpreted as a boolean then %FALSE
4031 // is returned and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
4033 // or %FALSE if the key was not found or could not be parsed.
4034 // RETURNS: the value associated with the key as a boolean,
4035 // <group_name>: a group name
4036 // <key>: a key
4037 int get_boolean(char* group_name, char* key, GLib2.Error** error=null) {
4038 return g_key_file_get_boolean(&this, group_name, key, error);
4041 // Returns the values associated with @key under @group_name as
4042 // booleans.
4044 // If @key cannot be found then %NULL is returned and @error is set to
4045 // #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
4046 // with @key cannot be interpreted as booleans then %NULL is returned
4047 // and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
4049 // the values associated with the key as a list of booleans, or %NULL if the
4050 // key was not found or could not be parsed. The returned list of booleans
4051 // should be freed with g_free() when no longer needed.
4052 // <group_name>: a group name
4053 // <key>: a key
4054 // <length>: the number of booleans returned
4055 int* /*new container*/ get_boolean_list(char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error=null) {
4056 return g_key_file_get_boolean_list(&this, group_name, key, length, error);
4059 // Retrieves a comment above @key from @group_name.
4060 // If @key is %NULL then @comment will be read from above
4061 // @group_name. If both @key and @group_name are %NULL, then
4062 // @comment will be read from above the first group in the file.
4063 // RETURNS: a comment that should be freed with g_free()
4064 // <group_name>: a group name, or %NULL
4065 // <key>: a key
4066 char* /*new*/ get_comment(char* group_name, char* key, GLib2.Error** error=null) {
4067 return g_key_file_get_comment(&this, group_name, key, error);
4070 // Returns the value associated with @key under @group_name as a
4071 // double. If @group_name is %NULL, the start_group is used.
4073 // If @key cannot be found then 0.0 is returned and @error is set to
4074 // #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated
4075 // with @key cannot be interpreted as a double then 0.0 is returned
4076 // and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
4078 // 0.0 if the key was not found or could not be parsed.
4079 // RETURNS: the value associated with the key as a double, or
4080 // <group_name>: a group name
4081 // <key>: a key
4082 double get_double(char* group_name, char* key, GLib2.Error** error=null) {
4083 return g_key_file_get_double(&this, group_name, key, error);
4086 // Returns the values associated with @key under @group_name as
4087 // doubles.
4089 // If @key cannot be found then %NULL is returned and @error is set to
4090 // #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
4091 // with @key cannot be interpreted as doubles then %NULL is returned
4092 // and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
4094 // the values associated with the key as a list of doubles, or %NULL if the
4095 // key was not found or could not be parsed. The returned list of doubles
4096 // should be freed with g_free() when no longer needed.
4097 // <group_name>: a group name
4098 // <key>: a key
4099 // <length>: the number of doubles returned
4100 double* /*new container*/ get_double_list(char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error=null) {
4101 return g_key_file_get_double_list(&this, group_name, key, length, error);
4104 // Unintrospectable method: get_groups() / g_key_file_get_groups()
4105 // Returns all groups in the key file loaded with @key_file.
4106 // The array of returned groups will be %NULL-terminated, so
4107 // @length may optionally be %NULL.
4109 // Use g_strfreev() to free it.
4110 // RETURNS: a newly-allocated %NULL-terminated array of strings.
4111 // <length>: return location for the number of returned groups, or %NULL
4112 char** get_groups(size_t* length) {
4113 return g_key_file_get_groups(&this, length);
4116 // Returns the value associated with @key under @group_name as a signed
4117 // 64-bit integer. This is similar to g_key_file_get_integer() but can return
4118 // 64-bit results without truncation.
4120 // 0 if the key was not found or could not be parsed.
4121 // RETURNS: the value associated with the key as a signed 64-bit integer, or
4122 // <group_name>: a non-%NULL group name
4123 // <key>: a non-%NULL key
4124 long get_int64(char* group_name, char* key, GLib2.Error** error=null) {
4125 return g_key_file_get_int64(&this, group_name, key, error);
4128 // Returns the value associated with @key under @group_name as an
4129 // integer.
4131 // If @key cannot be found then 0 is returned and @error is set to
4132 // #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated
4133 // with @key cannot be interpreted as an integer then 0 is returned
4134 // and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
4136 // 0 if the key was not found or could not be parsed.
4137 // RETURNS: the value associated with the key as an integer, or
4138 // <group_name>: a group name
4139 // <key>: a key
4140 int get_integer(char* group_name, char* key, GLib2.Error** error=null) {
4141 return g_key_file_get_integer(&this, group_name, key, error);
4144 // Returns the values associated with @key under @group_name as
4145 // integers.
4147 // If @key cannot be found then %NULL is returned and @error is set to
4148 // #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
4149 // with @key cannot be interpreted as integers then %NULL is returned
4150 // and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
4152 // the values associated with the key as a list of integers, or %NULL if
4153 // the key was not found or could not be parsed. The returned list of
4154 // integers should be freed with g_free() when no longer needed.
4155 // <group_name>: a group name
4156 // <key>: a key
4157 // <length>: the number of integers returned
4158 int* /*new container*/ get_integer_list(char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error=null) {
4159 return g_key_file_get_integer_list(&this, group_name, key, length, error);
4162 // Unintrospectable method: get_keys() / g_key_file_get_keys()
4163 // Returns all keys for the group name @group_name. The array of
4164 // returned keys will be %NULL-terminated, so @length may
4165 // optionally be %NULL. In the event that the @group_name cannot
4166 // be found, %NULL is returned and @error is set to
4167 // #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
4169 // Use g_strfreev() to free it.
4170 // RETURNS: a newly-allocated %NULL-terminated array of strings.
4171 // <group_name>: a group name
4172 // <length>: return location for the number of keys returned, or %NULL
4173 char** get_keys(char* group_name, size_t* length, GLib2.Error** error=null) {
4174 return g_key_file_get_keys(&this, group_name, length, error);
4177 // Returns the value associated with @key under @group_name
4178 // translated in the given @locale if available. If @locale is
4179 // %NULL then the current locale is assumed.
4181 // If @key cannot be found then %NULL is returned and @error is set
4182 // to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the value associated
4183 // with @key cannot be interpreted or no suitable translation can
4184 // be found then the untranslated value is returned.
4186 // key cannot be found.
4187 // RETURNS: a newly allocated string or %NULL if the specified
4188 // <group_name>: a group name
4189 // <key>: a key
4190 // <locale>: a locale identifier or %NULL
4191 char* /*new*/ get_locale_string(char* group_name, char* key, char* locale, GLib2.Error** error=null) {
4192 return g_key_file_get_locale_string(&this, group_name, key, locale, error);
4195 // Returns the values associated with @key under @group_name
4196 // translated in the given @locale if available. If @locale is
4197 // %NULL then the current locale is assumed.
4198 // If @key cannot be found then %NULL is returned and @error is set
4199 // to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the values associated
4200 // with @key cannot be interpreted or no suitable translations
4201 // can be found then the untranslated values are returned. The
4202 // returned array is %NULL-terminated, so @length may optionally
4203 // be %NULL.
4205 // or %NULL if the key isn't found. The string array should be freed
4206 // with g_strfreev().
4207 // RETURNS: a newly allocated %NULL-terminated string array
4208 // <group_name>: a group name
4209 // <key>: a key
4210 // <locale>: a locale identifier or %NULL
4211 // <length>: return location for the number of returned strings or %NULL
4212 char** /*new*/ get_locale_string_list(char* group_name, char* key, char* locale, /*out*/ size_t* length, GLib2.Error** error=null) {
4213 return g_key_file_get_locale_string_list(&this, group_name, key, locale, length, error);
4216 // Returns the name of the start group of the file.
4217 // RETURNS: The start group of the key file.
4218 char* /*new*/ get_start_group() {
4219 return g_key_file_get_start_group(&this);
4222 // Returns the string value associated with @key under @group_name.
4223 // Unlike g_key_file_get_value(), this function handles escape sequences
4224 // like \s.
4226 // In the event the key cannot be found, %NULL is returned and
4227 // @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the
4228 // event that the @group_name cannot be found, %NULL is returned
4229 // and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
4231 // key cannot be found.
4232 // RETURNS: a newly allocated string or %NULL if the specified
4233 // <group_name>: a group name
4234 // <key>: a key
4235 char* /*new*/ get_string(char* group_name, char* key, GLib2.Error** error=null) {
4236 return g_key_file_get_string(&this, group_name, key, error);
4239 // Returns the values associated with @key under @group_name.
4241 // In the event the key cannot be found, %NULL is returned and
4242 // @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the
4243 // event that the @group_name cannot be found, %NULL is returned
4244 // and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
4246 // a %NULL-terminated string array or %NULL if the specified
4247 // key cannot be found. The array should be freed with g_strfreev().
4248 // <group_name>: a group name
4249 // <key>: a key
4250 // <length>: return location for the number of returned strings, or %NULL
4251 char** /*new*/ get_string_list(char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error=null) {
4252 return g_key_file_get_string_list(&this, group_name, key, length, error);
4255 // Returns the value associated with @key under @group_name as an unsigned
4256 // 64-bit integer. This is similar to g_key_file_get_integer() but can return
4257 // large positive results without truncation.
4259 // or 0 if the key was not found or could not be parsed.
4260 // RETURNS: the value associated with the key as an unsigned 64-bit integer,
4261 // <group_name>: a non-%NULL group name
4262 // <key>: a non-%NULL key
4263 ulong get_uint64(char* group_name, char* key, GLib2.Error** error=null) {
4264 return g_key_file_get_uint64(&this, group_name, key, error);
4267 // Returns the raw value associated with @key under @group_name.
4268 // Use g_key_file_get_string() to retrieve an unescaped UTF-8 string.
4270 // In the event the key cannot be found, %NULL is returned and
4271 // @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the
4272 // event that the @group_name cannot be found, %NULL is returned
4273 // and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
4276 // key cannot be found.
4277 // RETURNS: a newly allocated string or %NULL if the specified
4278 // <group_name>: a group name
4279 // <key>: a key
4280 char* /*new*/ get_value(char* group_name, char* key, GLib2.Error** error=null) {
4281 return g_key_file_get_value(&this, group_name, key, error);
4284 // Looks whether the key file has the group @group_name.
4286 // otherwise.
4287 // RETURNS: %TRUE if @group_name is a part of @key_file, %FALSE
4288 // <group_name>: a group name
4289 int has_group(char* group_name) {
4290 return g_key_file_has_group(&this, group_name);
4293 // Unintrospectable method: has_key() / g_key_file_has_key()
4294 // Looks whether the key file has the key @key in the group
4295 // @group_name.
4297 // <note>This function does not follow the rules for #GError strictly;
4298 // the return value both carries meaning and signals an error. To use
4299 // this function, you must pass a #GError pointer in @error, and check
4300 // whether it is not %NULL to see if an error occurred.</note>
4302 // Language bindings should use g_key_file_get_value() to test whether
4303 // or not a key exists.
4305 // otherwise.
4306 // RETURNS: %TRUE if @key is a part of @group_name, %FALSE
4307 // <group_name>: a group name
4308 // <key>: a key name
4309 int has_key(char* group_name, char* key, GLib2.Error** error=null) {
4310 return g_key_file_has_key(&this, group_name, key, error);
4313 // Loads a key file from memory into an empty #GKeyFile structure.
4314 // If the object cannot be created then %error is set to a #GKeyFileError.
4315 // RETURNS: %TRUE if a key file could be loaded, %FALSE otherwise
4316 // <data>: key file loaded in memory
4317 // <length>: the length of @data in bytes
4318 // <flags>: flags from #GKeyFileFlags
4319 int load_from_data(char* data, size_t length, KeyFileFlags flags, GLib2.Error** error=null) {
4320 return g_key_file_load_from_data(&this, data, length, flags, error);
4323 // This function looks for a key file named @file in the paths
4324 // returned from g_get_user_data_dir() and g_get_system_data_dirs(),
4325 // loads the file into @key_file and returns the file's full path in
4326 // @full_path. If the file could not be loaded then an %error is
4327 // set to either a #GFileError or #GKeyFileError.
4328 // RETURNS: %TRUE if a key file could be loaded, %FALSE othewise
4329 // <file>: a relative path to a filename to open and parse
4330 // <full_path>: return location for a string containing the full path of the file, or %NULL
4331 // <flags>: flags from #GKeyFileFlags
4332 int load_from_data_dirs(char* file, char** full_path, KeyFileFlags flags, GLib2.Error** error=null) {
4333 return g_key_file_load_from_data_dirs(&this, file, full_path, flags, error);
4336 // This function looks for a key file named @file in the paths
4337 // specified in @search_dirs, loads the file into @key_file and
4338 // returns the file's full path in @full_path. If the file could not
4339 // be loaded then an %error is set to either a #GFileError or
4340 // #GKeyFileError.
4341 // RETURNS: %TRUE if a key file could be loaded, %FALSE otherwise
4342 // <file>: a relative path to a filename to open and parse
4343 // <search_dirs>: %NULL-terminated array of directories to search
4344 // <full_path>: return location for a string containing the full path of the file, or %NULL
4345 // <flags>: flags from #GKeyFileFlags
4346 int load_from_dirs(char* file, char** search_dirs, char** full_path, KeyFileFlags flags, GLib2.Error** error=null) {
4347 return g_key_file_load_from_dirs(&this, file, search_dirs, full_path, flags, error);
4350 // Loads a key file into an empty #GKeyFile structure.
4351 // If the file could not be loaded then %error is set to
4352 // either a #GFileError or #GKeyFileError.
4353 // RETURNS: %TRUE if a key file could be loaded, %FALSE otherwise
4354 // <file>: the path of a filename to load, in the GLib filename encoding
4355 // <flags>: flags from #GKeyFileFlags
4356 int load_from_file(char* file, KeyFileFlags flags, GLib2.Error** error=null) {
4357 return g_key_file_load_from_file(&this, file, flags, error);
4360 // Removes a comment above @key from @group_name.
4361 // If @key is %NULL then @comment will be removed above @group_name.
4362 // If both @key and @group_name are %NULL, then @comment will
4363 // be removed above the first group in the file.
4364 // RETURNS: %TRUE if the comment was removed, %FALSE otherwise
4365 // <group_name>: a group name, or %NULL
4366 // <key>: a key
4367 int remove_comment(char* group_name, char* key, GLib2.Error** error=null) {
4368 return g_key_file_remove_comment(&this, group_name, key, error);
4371 // Removes the specified group, @group_name,
4372 // from the key file.
4373 // RETURNS: %TRUE if the group was removed, %FALSE otherwise
4374 // <group_name>: a group name
4375 int remove_group(char* group_name, GLib2.Error** error=null) {
4376 return g_key_file_remove_group(&this, group_name, error);
4379 // Removes @key in @group_name from the key file.
4380 // RETURNS: %TRUE if the key was removed, %FALSE otherwise
4381 // <group_name>: a group name
4382 // <key>: a key name to remove
4383 int remove_key(char* group_name, char* key, GLib2.Error** error=null) {
4384 return g_key_file_remove_key(&this, group_name, key, error);
4387 // Associates a new boolean value with @key under @group_name.
4388 // If @key cannot be found then it is created.
4389 // <group_name>: a group name
4390 // <key>: a key
4391 // <value>: %TRUE or %FALSE
4392 void set_boolean(char* group_name, char* key, int value) {
4393 g_key_file_set_boolean(&this, group_name, key, value);
4396 // Associates a list of boolean values with @key under @group_name.
4397 // If @key cannot be found then it is created.
4398 // If @group_name is %NULL, the start_group is used.
4399 // <group_name>: a group name
4400 // <key>: a key
4401 // <list>: an array of boolean values
4402 // <length>: length of @list
4403 void set_boolean_list(char* group_name, char* key, int list, size_t length) {
4404 g_key_file_set_boolean_list(&this, group_name, key, list, length);
4407 // Places a comment above @key from @group_name.
4408 // If @key is %NULL then @comment will be written above @group_name.
4409 // If both @key and @group_name are %NULL, then @comment will be
4410 // written above the first group in the file.
4411 // RETURNS: %TRUE if the comment was written, %FALSE otherwise
4412 // <group_name>: a group name, or %NULL
4413 // <key>: a key
4414 // <comment>: a comment
4415 int set_comment(char* group_name, char* key, char* comment, GLib2.Error** error=null) {
4416 return g_key_file_set_comment(&this, group_name, key, comment, error);
4419 // Associates a new double value with @key under @group_name.
4420 // If @key cannot be found then it is created.
4421 // <group_name>: a group name
4422 // <key>: a key
4423 // <value>: an double value
4424 void set_double(char* group_name, char* key, double value) {
4425 g_key_file_set_double(&this, group_name, key, value);
4428 // Associates a list of double values with @key under
4429 // @group_name. If @key cannot be found then it is created.
4430 // <group_name>: a group name
4431 // <key>: a key
4432 // <list>: an array of double values
4433 // <length>: number of double values in @list
4434 void set_double_list(char* group_name, char* key, double list, size_t length) {
4435 g_key_file_set_double_list(&this, group_name, key, list, length);
4438 // Associates a new integer value with @key under @group_name.
4439 // If @key cannot be found then it is created.
4440 // <group_name>: a group name
4441 // <key>: a key
4442 // <value>: an integer value
4443 void set_int64(char* group_name, char* key, long value) {
4444 g_key_file_set_int64(&this, group_name, key, value);
4447 // Associates a new integer value with @key under @group_name.
4448 // If @key cannot be found then it is created.
4449 // <group_name>: a group name
4450 // <key>: a key
4451 // <value>: an integer value
4452 void set_integer(char* group_name, char* key, int value) {
4453 g_key_file_set_integer(&this, group_name, key, value);
4456 // Associates a list of integer values with @key under @group_name.
4457 // If @key cannot be found then it is created.
4458 // <group_name>: a group name
4459 // <key>: a key
4460 // <list>: an array of integer values
4461 // <length>: number of integer values in @list
4462 void set_integer_list(char* group_name, char* key, int list, size_t length) {
4463 g_key_file_set_integer_list(&this, group_name, key, list, length);
4466 // Sets the character which is used to separate
4467 // values in lists. Typically ';' or ',' are used
4468 // as separators. The default list separator is ';'.
4469 // <separator>: the separator
4470 void set_list_separator(char separator) {
4471 g_key_file_set_list_separator(&this, separator);
4474 // Associates a string value for @key and @locale under @group_name.
4475 // If the translation for @key cannot be found then it is created.
4476 // <group_name>: a group name
4477 // <key>: a key
4478 // <locale>: a locale identifier
4479 // <string>: a string
4480 void set_locale_string(char* group_name, char* key, char* locale, char* string_) {
4481 g_key_file_set_locale_string(&this, group_name, key, locale, string_);
4484 // Associates a list of string values for @key and @locale under
4485 // @group_name. If the translation for @key cannot be found then
4486 // it is created.
4487 // <group_name>: a group name
4488 // <key>: a key
4489 // <locale>: a locale identifier
4490 // <list>: a %NULL-terminated array of locale string values
4491 // <length>: the length of @list
4492 void set_locale_string_list(char* group_name, char* key, char* locale, char* list, size_t length) {
4493 g_key_file_set_locale_string_list(&this, group_name, key, locale, list, length);
4496 // Associates a new string value with @key under @group_name.
4497 // If @key cannot be found then it is created.
4498 // If @group_name cannot be found then it is created.
4499 // Unlike g_key_file_set_value(), this function handles characters
4500 // that need escaping, such as newlines.
4501 // <group_name>: a group name
4502 // <key>: a key
4503 // <string>: a string
4504 void set_string(char* group_name, char* key, char* string_) {
4505 g_key_file_set_string(&this, group_name, key, string_);
4508 // Associates a list of string values for @key under @group_name.
4509 // If @key cannot be found then it is created.
4510 // If @group_name cannot be found then it is created.
4511 // <group_name>: a group name
4512 // <key>: a key
4513 // <list>: an array of string values
4514 // <length>: number of string values in @list
4515 void set_string_list(char* group_name, char* key, char* list, size_t length) {
4516 g_key_file_set_string_list(&this, group_name, key, list, length);
4519 // Associates a new integer value with @key under @group_name.
4520 // If @key cannot be found then it is created.
4521 // <group_name>: a group name
4522 // <key>: a key
4523 // <value>: an integer value
4524 void set_uint64(char* group_name, char* key, ulong value) {
4525 g_key_file_set_uint64(&this, group_name, key, value);
4528 // Associates a new value with @key under @group_name.
4530 // If @key cannot be found then it is created. If @group_name cannot
4531 // be found then it is created. To set an UTF-8 string which may contain
4532 // characters that need escaping (such as newlines or spaces), use
4533 // g_key_file_set_string().
4534 // <group_name>: a group name
4535 // <key>: a key
4536 // <value>: a string
4537 void set_value(char* group_name, char* key, char* value) {
4538 g_key_file_set_value(&this, group_name, key, value);
4541 // This function outputs @key_file as a string.
4543 // Note that this function never reports an error,
4544 // so it is safe to pass %NULL as @error.
4546 // the contents of the #GKeyFile
4547 // RETURNS: a newly allocated string holding
4548 // <length>: return location for the length of the returned string, or %NULL
4549 char* /*new*/ to_data(size_t* length, GLib2.Error** error=null) {
4550 return g_key_file_to_data(&this, length, error);
4552 static Quark error_quark() {
4553 return g_key_file_error_quark();
4556 // Unintrospectable function: new() / g_key_file_new()
4557 // Creates a new empty #GKeyFile object. Use
4558 // g_key_file_load_from_file(), g_key_file_load_from_data(),
4559 // g_key_file_load_from_dirs() or g_key_file_load_from_data_dirs() to
4560 // read an existing key file.
4561 // RETURNS: an empty #GKeyFile.
4562 static KeyFile* new_() {
4563 return g_key_file_new();
4567 enum KeyFileError {
4568 UNKNOWN_ENCODING = 0,
4569 PARSE = 1,
4570 NOT_FOUND = 2,
4571 KEY_NOT_FOUND = 3,
4572 GROUP_NOT_FOUND = 4,
4573 INVALID_VALUE = 5
4575 enum KeyFileFlags {
4576 NONE = 0,
4577 KEEP_COMMENTS = 1,
4578 KEEP_TRANSLATIONS = 2
4580 enum int LITTLE_ENDIAN = 1234;
4581 enum double LN10 = 2.302585;
4582 enum double LN2 = 0.693147;
4583 enum double LOG_2_BASE_10 = 0.301030;
4584 enum int LOG_FATAL_MASK = 0;
4585 enum int LOG_LEVEL_USER_SHIFT = 8;
4586 // The #GList struct is used for each element in a doubly-linked list.
4587 struct List {
4588 void* data;
4589 GLib2.List* next, prev;
4592 // Unintrospectable function: alloc() / g_list_alloc()
4593 // Allocates space for one #GList element. It is called by
4594 // g_list_append(), g_list_prepend(), g_list_insert() and
4595 // g_list_insert_sorted() and so is rarely used on its own.
4596 static GLib2.List* alloc() {
4597 return g_list_alloc();
4600 // Unintrospectable function: append() / g_list_append()
4601 // Adds a new element on to the end of the list.
4603 // <note><para>
4604 // The return value is the new start of the list, which
4605 // may have changed, so make sure you store the new value.
4606 // </para></note>
4608 // <note><para>
4609 // Note that g_list_append() has to traverse the entire list
4610 // to find the end, which is inefficient when adding multiple
4611 // elements. A common idiom to avoid the inefficiency is to prepend
4612 // the elements and reverse the list when all elements have been added.
4613 // </para></note>
4615 // |[
4616 // /&ast; Notice that these are initialized to the empty list. &ast;/
4617 // GList *list = NULL, *number_list = NULL;
4619 // /&ast; This is a list of strings. &ast;/
4620 // list = g_list_append (list, "first");
4621 // list = g_list_append (list, "second");
4623 // /&ast; This is a list of integers. &ast;/
4624 // number_list = g_list_append (number_list, GINT_TO_POINTER (27));
4625 // number_list = g_list_append (number_list, GINT_TO_POINTER (14));
4626 // ]|
4627 // RETURNS: the new start of the #GList
4628 // <list>: a pointer to a #GList
4629 // <data>: the data for the new element
4630 static GLib2.List* append(GLib2.List* list, void* data) {
4631 return g_list_append(list, data);
4634 // Unintrospectable function: concat() / g_list_concat()
4635 // Adds the second #GList onto the end of the first #GList.
4636 // Note that the elements of the second #GList are not copied.
4637 // They are used directly.
4638 // RETURNS: the start of the new #GList
4639 // <list1>: a #GList
4640 // <list2>: the #GList to add to the end of the first #GList
4641 static GLib2.List* concat(GLib2.List* list1, GLib2.List* list2) {
4642 return g_list_concat(list1, list2);
4645 // Unintrospectable function: copy() / g_list_copy()
4646 // Copies a #GList.
4648 // <note><para>
4649 // Note that this is a "shallow" copy. If the list elements
4650 // consist of pointers to data, the pointers are copied but
4651 // the actual data is not.
4652 // </para></note>
4653 // RETURNS: a copy of @list
4654 // <list>: a #GList
4655 static GLib2.List* copy(GLib2.List* list) {
4656 return g_list_copy(list);
4659 // Unintrospectable function: delete_link() / g_list_delete_link()
4660 // Removes the node link_ from the list and frees it.
4661 // Compare this to g_list_remove_link() which removes the node
4662 // without freeing it.
4663 // RETURNS: the new head of @list
4664 // <list>: a #GList
4665 // <link_>: node to delete from @list
4666 static GLib2.List* delete_link(GLib2.List* list, GLib2.List* link_) {
4667 return g_list_delete_link(list, link_);
4670 // Unintrospectable function: find() / g_list_find()
4671 // Finds the element in a #GList which
4672 // contains the given data.
4674 // or %NULL if it is not found
4675 // RETURNS: the found #GList element,
4676 // <list>: a #GList
4677 // <data>: the element data to find
4678 static GLib2.List* find(GLib2.List* list, const(void)* data) {
4679 return g_list_find(list, data);
4682 // Unintrospectable function: find_custom() / g_list_find_custom()
4683 // Finds an element in a #GList, using a supplied function to
4684 // find the desired element. It iterates over the list, calling
4685 // the given function which should return 0 when the desired
4686 // element is found. The function takes two #gconstpointer arguments,
4687 // the #GList element's data as the first argument and the
4688 // given user data.
4689 // RETURNS: the found #GList element, or %NULL if it is not found
4690 // <list>: a #GList
4691 // <data>: user data passed to the function
4692 // <func>: the function to call for each element. It should return 0 when the desired element is found
4693 static GLib2.List* find_custom(GLib2.List* list, const(void)* data, CompareFunc func) {
4694 return g_list_find_custom(list, data, func);
4697 // Unintrospectable function: first() / g_list_first()
4698 // Gets the first element in a #GList.
4700 // or %NULL if the #GList has no elements
4701 // RETURNS: the first element in the #GList,
4702 // <list>: a #GList
4703 static GLib2.List* first(GLib2.List* list) {
4704 return g_list_first(list);
4707 // Unintrospectable function: foreach() / g_list_foreach()
4708 // Calls a function for each element of a #GList.
4709 // <list>: a #GList
4710 // <func>: the function to call with each element's data
4711 // <user_data>: user data to pass to the function
4712 static void foreach_(GLib2.List* list, Func func, void* user_data) {
4713 g_list_foreach(list, func, user_data);
4716 // Unintrospectable function: free() / g_list_free()
4717 // Frees all of the memory used by a #GList.
4718 // The freed elements are returned to the slice allocator.
4720 // <note><para>
4721 // If list elements contain dynamically-allocated memory,
4722 // you should either use g_list_free_full() or free them manually
4723 // first.
4724 // </para></note>
4725 // <list>: a #GList
4726 static void free(GLib2.List* list) {
4727 g_list_free(list);
4730 // Unintrospectable function: free_1() / g_list_free_1()
4731 // Frees one #GList element.
4732 // It is usually used after g_list_remove_link().
4733 // <list>: a #GList element
4734 static void free_1(GLib2.List* list) {
4735 g_list_free_1(list);
4738 // Unintrospectable function: free_full() / g_list_free_full()
4739 // Convenience method, which frees all the memory used by a #GList, and
4740 // calls the specified destroy function on every element's data.
4741 // <list>: a pointer to a #GList
4742 // <free_func>: the function to be called to free each element's data
4743 static void free_full(GLib2.List* list, DestroyNotify free_func) {
4744 g_list_free_full(list, free_func);
4747 // Unintrospectable function: index() / g_list_index()
4748 // Gets the position of the element containing
4749 // the given data (starting from 0).
4751 // or -1 if the data is not found
4752 // RETURNS: the index of the element containing the data,
4753 // <list>: a #GList
4754 // <data>: the data to find
4755 static int index(GLib2.List* list, const(void)* data) {
4756 return g_list_index(list, data);
4759 // Unintrospectable function: insert() / g_list_insert()
4760 // Inserts a new element into the list at the given position.
4761 // RETURNS: the new start of the #GList
4762 // <list>: a pointer to a #GList
4763 // <data>: the data for the new element
4764 // <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.
4765 static GLib2.List* insert(GLib2.List* list, void* data, int position) {
4766 return g_list_insert(list, data, position);
4769 // Unintrospectable function: insert_before() / g_list_insert_before()
4770 // Inserts a new element into the list before the given position.
4771 // RETURNS: the new start of the #GList
4772 // <list>: a pointer to a #GList
4773 // <sibling>: the list element before which the new element is inserted or %NULL to insert at the end of the list
4774 // <data>: the data for the new element
4775 static GLib2.List* insert_before(GLib2.List* list, GLib2.List* sibling, void* data) {
4776 return g_list_insert_before(list, sibling, data);
4779 // Unintrospectable function: insert_sorted() / g_list_insert_sorted()
4780 // Inserts a new element into the list, using the given comparison
4781 // function to determine its position.
4782 // RETURNS: the new start of the #GList
4783 // <list>: a pointer to a #GList
4784 // <data>: the data for the new element
4785 // <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.
4786 static GLib2.List* insert_sorted(GLib2.List* list, void* data, CompareFunc func) {
4787 return g_list_insert_sorted(list, data, func);
4790 // Unintrospectable function: insert_sorted_with_data() / g_list_insert_sorted_with_data()
4791 // Inserts a new element into the list, using the given comparison
4792 // function to determine its position.
4793 // RETURNS: the new start of the #GList
4794 // <list>: a pointer to a #GList
4795 // <data>: the data for the new element
4796 // <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.
4797 // <user_data>: user data to pass to comparison function.
4798 static GLib2.List* insert_sorted_with_data(GLib2.List* list, void* data, CompareDataFunc func, void* user_data) {
4799 return g_list_insert_sorted_with_data(list, data, func, user_data);
4802 // Unintrospectable function: last() / g_list_last()
4803 // Gets the last element in a #GList.
4805 // or %NULL if the #GList has no elements
4806 // RETURNS: the last element in the #GList,
4807 // <list>: a #GList
4808 static GLib2.List* last(GLib2.List* list) {
4809 return g_list_last(list);
4812 // Unintrospectable function: length() / g_list_length()
4813 // Gets the number of elements in a #GList.
4815 // <note><para>
4816 // This function iterates over the whole list to
4817 // count its elements.
4818 // </para></note>
4819 // RETURNS: the number of elements in the #GList
4820 // <list>: a #GList
4821 static uint length(GLib2.List* list) {
4822 return g_list_length(list);
4825 // Unintrospectable function: nth() / g_list_nth()
4826 // Gets the element at the given position in a #GList.
4828 // the end of the #GList
4829 // RETURNS: the element, or %NULL if the position is off
4830 // <list>: a #GList
4831 // <n>: the position of the element, counting from 0
4832 static GLib2.List* nth(GLib2.List* list, uint n) {
4833 return g_list_nth(list, n);
4836 // Unintrospectable function: nth_data() / g_list_nth_data()
4837 // Gets the data of the element at the given position.
4839 // is off the end of the #GList
4840 // RETURNS: the element's data, or %NULL if the position
4841 // <list>: a #GList
4842 // <n>: the position of the element
4843 static void* nth_data(GLib2.List* list, uint n) {
4844 return g_list_nth_data(list, n);
4847 // Unintrospectable function: nth_prev() / g_list_nth_prev()
4848 // Gets the element @n places before @list.
4850 // off the end of the #GList
4851 // RETURNS: the element, or %NULL if the position is
4852 // <list>: a #GList
4853 // <n>: the position of the element, counting from 0
4854 static GLib2.List* nth_prev(GLib2.List* list, uint n) {
4855 return g_list_nth_prev(list, n);
4858 // Restores the previous #GAllocator, used when allocating #GList
4859 // elements.
4861 // Note that this function is not available if GLib has been compiled
4862 // with <option>--disable-mem-pools</option>
4864 // Deprecated:2.10: It does nothing, since #GList has been converted
4865 // to the <link linkend="glib-Memory-Slices">slice
4866 // allocator</link>
4867 static void pop_allocator() {
4868 g_list_pop_allocator();
4871 // Unintrospectable function: position() / g_list_position()
4872 // Gets the position of the given element
4873 // in the #GList (starting from 0).
4875 // or -1 if the element is not found
4876 // RETURNS: the position of the element in the #GList,
4877 // <list>: a #GList
4878 // <llink>: an element in the #GList
4879 static int position(GLib2.List* list, GLib2.List* llink) {
4880 return g_list_position(list, llink);
4883 // Unintrospectable function: prepend() / g_list_prepend()
4884 // Adds a new element on to the start of the list.
4886 // <note><para>
4887 // The return value is the new start of the list, which
4888 // may have changed, so make sure you store the new value.
4889 // </para></note>
4891 // |[
4892 // /&ast; Notice that it is initialized to the empty list. &ast;/
4893 // GList *list = NULL;
4894 // list = g_list_prepend (list, "last");
4895 // list = g_list_prepend (list, "first");
4896 // ]|
4897 // RETURNS: the new start of the #GList
4898 // <list>: a pointer to a #GList
4899 // <data>: the data for the new element
4900 static GLib2.List* prepend(GLib2.List* list, void* data) {
4901 return g_list_prepend(list, data);
4904 // Sets the allocator to use to allocate #GList elements. Use
4905 // g_list_pop_allocator() to restore the previous allocator.
4907 // Note that this function is not available if GLib has been compiled
4908 // with <option>--disable-mem-pools</option>
4910 // Deprecated:2.10: It does nothing, since #GList has been converted
4911 // to the <link linkend="glib-Memory-Slices">slice
4912 // allocator</link>
4913 // <allocator>: the #GAllocator to use when allocating #GList elements.
4914 static void push_allocator(void* allocator) {
4915 g_list_push_allocator(allocator);
4918 // Unintrospectable function: remove() / g_list_remove()
4919 // Removes an element from a #GList.
4920 // If two elements contain the same data, only the first is removed.
4921 // If none of the elements contain the data, the #GList is unchanged.
4922 // RETURNS: the new start of the #GList
4923 // <list>: a #GList
4924 // <data>: the data of the element to remove
4925 static GLib2.List* remove(GLib2.List* list, const(void)* data) {
4926 return g_list_remove(list, data);
4929 // Unintrospectable function: remove_all() / g_list_remove_all()
4930 // Removes all list nodes with data equal to @data.
4931 // Returns the new head of the list. Contrast with
4932 // g_list_remove() which removes only the first node
4933 // matching the given data.
4934 // RETURNS: new head of @list
4935 // <list>: a #GList
4936 // <data>: data to remove
4937 static GLib2.List* remove_all(GLib2.List* list, const(void)* data) {
4938 return g_list_remove_all(list, data);
4941 // Unintrospectable function: remove_link() / g_list_remove_link()
4942 // Removes an element from a #GList, without freeing the element.
4943 // The removed element's prev and next links are set to %NULL, so
4944 // that it becomes a self-contained list with one element.
4945 // RETURNS: the new start of the #GList, without the element
4946 // <list>: a #GList
4947 // <llink>: an element in the #GList
4948 static GLib2.List* remove_link(GLib2.List* list, GLib2.List* llink) {
4949 return g_list_remove_link(list, llink);
4952 // Unintrospectable function: reverse() / g_list_reverse()
4953 // Reverses a #GList.
4954 // It simply switches the next and prev pointers of each element.
4955 // RETURNS: the start of the reversed #GList
4956 // <list>: a #GList
4957 static GLib2.List* reverse(GLib2.List* list) {
4958 return g_list_reverse(list);
4961 // Unintrospectable function: sort() / g_list_sort()
4962 // Sorts a #GList using the given comparison function.
4963 // RETURNS: the start of the sorted #GList
4964 // <list>: a #GList
4965 // <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.
4966 static GLib2.List* sort(GLib2.List* list, CompareFunc compare_func) {
4967 return g_list_sort(list, compare_func);
4970 // Unintrospectable function: sort_with_data() / g_list_sort_with_data()
4971 // Like g_list_sort(), but the comparison function accepts
4972 // a user data argument.
4973 // RETURNS: the new head of @list
4974 // <list>: a #GList
4975 // <compare_func>: comparison function
4976 // <user_data>: user data to pass to comparison function
4977 static GLib2.List* sort_with_data(GLib2.List* list, CompareDataFunc compare_func, void* user_data) {
4978 return g_list_sort_with_data(list, compare_func, user_data);
4982 extern (C) alias void function (char* log_domain, LogLevelFlags log_level, char* message, void* user_data) LogFunc;
4984 enum LogLevelFlags {
4985 FLAG_RECURSION = 1,
4986 FLAG_FATAL = 2,
4987 LEVEL_ERROR = 4,
4988 LEVEL_CRITICAL = 8,
4989 LEVEL_WARNING = 16,
4990 LEVEL_MESSAGE = 32,
4991 LEVEL_INFO = 64,
4992 LEVEL_DEBUG = 128,
4993 LEVEL_MASK = -4
4995 enum int MAJOR_VERSION = 2;
4996 enum int MICRO_VERSION = 2;
4997 enum int MINOR_VERSION = 30;
4998 enum MODULE_SUFFIX = "so";
4999 enum int MUTEX_DEBUG_MAGIC = cast(int)4175530711;
5001 // The <structname>GMainContext</structname> struct is an opaque data
5002 // type representing a set of sources to be handled in a main loop.
5003 struct MainContext {
5005 // Creates a new #GMainContext structure.
5006 // RETURNS: the new #GMainContext
5007 static MainContext* /*new*/ new_() {
5008 return g_main_context_new();
5011 // Tries to become the owner of the specified context.
5012 // If some other thread is the owner of the context,
5013 // returns %FALSE immediately. Ownership is properly
5014 // recursive: the owner can require ownership again
5015 // and will release ownership when g_main_context_release()
5016 // is called as many times as g_main_context_acquire().
5018 // You must be the owner of a context before you
5019 // can call g_main_context_prepare(), g_main_context_query(),
5020 // g_main_context_check(), g_main_context_dispatch().
5022 // this thread is now the owner of @context.
5023 // RETURNS: %TRUE if the operation succeeded, and
5024 int acquire() {
5025 return g_main_context_acquire(&this);
5028 // Adds a file descriptor to the set of file descriptors polled for
5029 // this context. This will very seldom be used directly. Instead
5030 // a typical event source will use g_source_add_poll() instead.
5031 // <fd>: a #GPollFD structure holding information about a file descriptor to watch.
5032 // <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.
5033 void add_poll(PollFD* fd, int priority) {
5034 g_main_context_add_poll(&this, fd, priority);
5037 // Passes the results of polling back to the main loop.
5038 // RETURNS: %TRUE if some sources are ready to be dispatched.
5039 // <max_priority>: the maximum numerical priority of sources to check
5040 // <fds>: array of #GPollFD's that was passed to the last call to g_main_context_query()
5041 // <n_fds>: return value of g_main_context_query()
5042 int check(int max_priority, PollFD* fds, int n_fds) {
5043 return g_main_context_check(&this, max_priority, fds, n_fds);
5045 // Dispatches all pending sources.
5046 void dispatch() {
5047 g_main_context_dispatch(&this);
5050 // Finds a source with the given source functions and user data. If
5051 // multiple sources exist with the same source function and user data,
5052 // the first one found will be returned.
5053 // RETURNS: the source, if one was found, otherwise %NULL
5054 // <funcs>: the @source_funcs passed to g_source_new().
5055 // <user_data>: the user data from the callback.
5056 Source* find_source_by_funcs_user_data(SourceFuncs* funcs, void* user_data) {
5057 return g_main_context_find_source_by_funcs_user_data(&this, funcs, user_data);
5060 // Finds a #GSource given a pair of context and ID.
5061 // RETURNS: the #GSource if found, otherwise, %NULL
5062 // <source_id>: the source ID, as returned by g_source_get_id().
5063 Source* find_source_by_id(uint source_id) {
5064 return g_main_context_find_source_by_id(&this, source_id);
5067 // Finds a source with the given user data for the callback. If
5068 // multiple sources exist with the same user data, the first
5069 // one found will be returned.
5070 // RETURNS: the source, if one was found, otherwise %NULL
5071 // <user_data>: the user_data for the callback.
5072 Source* find_source_by_user_data(void* user_data) {
5073 return g_main_context_find_source_by_user_data(&this, user_data);
5076 // Unintrospectable method: get_poll_func() / g_main_context_get_poll_func()
5077 // Gets the poll function set by g_main_context_set_poll_func().
5078 // RETURNS: the poll function
5079 PollFunc get_poll_func() {
5080 return g_main_context_get_poll_func(&this);
5083 // Unintrospectable method: invoke() / g_main_context_invoke()
5084 // Invokes a function in such a way that @context is owned during the
5085 // invocation of @function.
5087 // If @context is %NULL then the global default main context — as
5088 // returned by g_main_context_default() — is used.
5090 // If @context is owned by the current thread, @function is called
5091 // directly. Otherwise, if @context is the thread-default main context
5092 // of the current thread and g_main_context_acquire() succeeds, then
5093 // @function is called and g_main_context_release() is called
5094 // afterwards.
5096 // In any other case, an idle source is created to call @function and
5097 // that source is attached to @context (presumably to be run in another
5098 // thread). The idle source is attached with #G_PRIORITY_DEFAULT
5099 // priority. If you want a different priority, use
5100 // g_main_context_invoke_full().
5102 // Note that, as with normal idle functions, @function should probably
5103 // return %FALSE. If it returns %TRUE, it will be continuously run in a
5104 // loop (and may prevent this call from returning).
5105 // <function>: function to call
5106 // <data>: data to pass to @function
5107 void invoke(SourceFunc function_, void* data) {
5108 g_main_context_invoke(&this, function_, data);
5111 // Invokes a function in such a way that @context is owned during the
5112 // invocation of @function.
5114 // This function is the same as g_main_context_invoke() except that it
5115 // lets you specify the priority incase @function ends up being
5116 // scheduled as an idle and also lets you give a #GDestroyNotify for @data.
5118 // @notify should not assume that it is called from any particular
5119 // thread or with any particular context acquired.
5120 // <priority>: the priority at which to run @function
5121 // <function>: function to call
5122 // <data>: data to pass to @function
5123 // <notify>: a function to call when @data is no longer in use, or %NULL.
5124 void invoke_full(int priority, SourceFunc function_, void* data, DestroyNotify notify) {
5125 g_main_context_invoke_full(&this, priority, function_, data, notify);
5128 // Determines whether this thread holds the (recursive)
5129 // ownership of this #GMaincontext. This is useful to
5130 // know before waiting on another thread that may be
5131 // blocking to get ownership of @context.
5132 // RETURNS: %TRUE if current thread is owner of @context.
5133 int is_owner() {
5134 return g_main_context_is_owner(&this);
5137 // Runs a single iteration for the given main loop. This involves
5138 // checking to see if any event sources are ready to be processed,
5139 // then if no events sources are ready and @may_block is %TRUE, waiting
5140 // for a source to become ready, then dispatching the highest priority
5141 // events sources that are ready. Otherwise, if @may_block is %FALSE
5142 // sources are not waited to become ready, only those highest priority
5143 // events sources will be dispatched (if any), that are ready at this
5144 // given moment without further waiting.
5146 // Note that even when @may_block is %TRUE, it is still possible for
5147 // g_main_context_iteration() to return %FALSE, since the the wait may
5148 // be interrupted for other reasons than an event source becoming ready.
5149 // RETURNS: %TRUE if events were dispatched.
5150 // <may_block>: whether the call may block.
5151 int iteration(int may_block) {
5152 return g_main_context_iteration(&this, may_block);
5155 // Checks if any sources have pending events for the given context.
5156 // RETURNS: %TRUE if events are pending.
5157 int pending() {
5158 return g_main_context_pending(&this);
5161 // Pops @context off the thread-default context stack (verifying that
5162 // it was on the top of the stack).
5163 void pop_thread_default() {
5164 g_main_context_pop_thread_default(&this);
5167 // Prepares to poll sources within a main loop. The resulting information
5168 // for polling is determined by calling g_main_context_query ().
5170 // prior to polling.
5171 // RETURNS: %TRUE if some source is ready to be dispatched
5172 // <priority>: location to store priority of highest priority source already ready.
5173 int prepare(int* priority) {
5174 return g_main_context_prepare(&this, priority);
5177 // Acquires @context and sets it as the thread-default context for the
5178 // current thread. This will cause certain asynchronous operations
5179 // (such as most <link linkend="gio">gio</link>-based I/O) which are
5180 // started in this thread to run under @context and deliver their
5181 // results to its main loop, rather than running under the global
5182 // default context in the main thread. Note that calling this function
5183 // changes the context returned by
5184 // g_main_context_get_thread_default(), <emphasis>not</emphasis> the
5185 // one returned by g_main_context_default(), so it does not affect the
5186 // context used by functions like g_idle_add().
5188 // Normally you would call this function shortly after creating a new
5189 // thread, passing it a #GMainContext which will be run by a
5190 // #GMainLoop in that thread, to set a new default context for all
5191 // async operations in that thread. (In this case, you don't need to
5192 // ever call g_main_context_pop_thread_default().) In some cases
5193 // however, you may want to schedule a single operation in a
5194 // non-default context, or temporarily use a non-default context in
5195 // the main thread. In that case, you can wrap the call to the
5196 // asynchronous operation inside a
5197 // g_main_context_push_thread_default() /
5198 // g_main_context_pop_thread_default() pair, but it is up to you to
5199 // ensure that no other asynchronous operations accidentally get
5200 // started while the non-default context is active.
5202 // Beware that libraries that predate this function may not correctly
5203 // handle being used from a thread with a thread-default context. Eg,
5204 // see g_file_supports_thread_contexts().
5205 void push_thread_default() {
5206 g_main_context_push_thread_default(&this);
5209 // Determines information necessary to poll this main loop.
5211 // or, if more than @n_fds records need to be stored, the number
5212 // of records that need to be stored.
5213 // RETURNS: the number of records actually stored in @fds,
5214 // <max_priority>: maximum priority source to check
5215 // <timeout_>: location to store timeout to be used in polling
5216 // <fds>: location to store #GPollFD records that need to be polled.
5217 // <n_fds>: length of @fds.
5218 int query(int max_priority, /*out*/ int* timeout_, /*out*/ PollFD* fds, /*out*/ int n_fds) {
5219 return g_main_context_query(&this, max_priority, timeout_, fds, n_fds);
5222 // Increases the reference count on a #GMainContext object by one.
5223 // RETURNS: the @context that was passed in (since 2.6)
5224 MainContext* /*new*/ ref_() {
5225 return g_main_context_ref(&this);
5228 // Releases ownership of a context previously acquired by this thread
5229 // with g_main_context_acquire(). If the context was acquired multiple
5230 // times, the ownership will be released only when g_main_context_release()
5231 // is called as many times as it was acquired.
5232 void release() {
5233 g_main_context_release(&this);
5236 // Removes file descriptor from the set of file descriptors to be
5237 // polled for a particular context.
5238 // <fd>: a #GPollFD descriptor previously added with g_main_context_add_poll()
5239 void remove_poll(PollFD* fd) {
5240 g_main_context_remove_poll(&this, fd);
5243 // Unintrospectable method: set_poll_func() / g_main_context_set_poll_func()
5244 // Sets the function to use to handle polling of file descriptors. It
5245 // will be used instead of the poll() system call
5246 // (or GLib's replacement function, which is used where
5247 // poll() isn't available).
5249 // This function could possibly be used to integrate the GLib event
5250 // loop with an external event loop.
5251 // <func>: the function to call to poll all file descriptors
5252 void set_poll_func(PollFunc func) {
5253 g_main_context_set_poll_func(&this, func);
5256 // Decreases the reference count on a #GMainContext object by one. If
5257 // the result is zero, free the context and free all associated memory.
5258 void unref() {
5259 g_main_context_unref(&this);
5262 // Tries to become the owner of the specified context,
5263 // as with g_main_context_acquire(). But if another thread
5264 // is the owner, atomically drop @mutex and wait on @cond until
5265 // that owner releases ownership or until @cond is signaled, then
5266 // try again (once) to become the owner.
5268 // this thread is now the owner of @context.
5269 // RETURNS: %TRUE if the operation succeeded, and
5270 // <cond>: a condition variable
5271 // <mutex>: a mutex, currently held
5272 int wait(Cond* cond, Mutex* mutex) {
5273 return g_main_context_wait(&this, cond, mutex);
5276 // If @context is currently waiting in a poll(), interrupt
5277 // the poll(), and continue the iteration process.
5278 void wakeup() {
5279 g_main_context_wakeup(&this);
5282 // Returns the global default main context. This is the main context
5283 // used for main loop functions when a main loop is not explicitly
5284 // specified, and corresponds to the "main" main loop. See also
5285 // g_main_context_get_thread_default().
5286 // RETURNS: the global default main context.
5287 static MainContext* default_() {
5288 return g_main_context_default();
5291 // Gets the thread-default #GMainContext for this thread. Asynchronous
5292 // operations that want to be able to be run in contexts other than
5293 // the default one should call this method to get a #GMainContext to
5294 // add their #GSource<!-- -->s to. (Note that even in single-threaded
5295 // programs applications may sometimes want to temporarily push a
5296 // non-default context, so it is not safe to assume that this will
5297 // always return %NULL if threads are not initialized.)
5299 // %NULL if the thread-default context is the global default context.
5300 // RETURNS: the thread-default #GMainContext, or
5301 static MainContext* get_thread_default() {
5302 return g_main_context_get_thread_default();
5307 // The <structname>GMainLoop</structname> struct is an opaque data type
5308 // representing the main event loop of a GLib or GTK+ application.
5309 struct MainLoop {
5311 // Creates a new #GMainLoop structure.
5312 // RETURNS: a new #GMainLoop.
5313 // <context>: a #GMainContext (if %NULL, the default context will be used).
5314 // <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.
5315 static MainLoop* /*new*/ new_(MainContext* context, int is_running) {
5316 return g_main_loop_new(context, is_running);
5319 // Returns the #GMainContext of @loop.
5320 // RETURNS: the #GMainContext of @loop
5321 MainContext* get_context() {
5322 return g_main_loop_get_context(&this);
5325 // Checks to see if the main loop is currently being run via g_main_loop_run().
5326 // RETURNS: %TRUE if the mainloop is currently being run.
5327 int is_running() {
5328 return g_main_loop_is_running(&this);
5331 // Stops a #GMainLoop from running. Any calls to g_main_loop_run()
5332 // for the loop will return.
5334 // Note that sources that have already been dispatched when
5335 // g_main_loop_quit() is called will still be executed.
5336 void quit() {
5337 g_main_loop_quit(&this);
5340 // Increases the reference count on a #GMainLoop object by one.
5341 // RETURNS: @loop
5342 MainLoop* /*new*/ ref_() {
5343 return g_main_loop_ref(&this);
5346 // Runs a main loop until g_main_loop_quit() is called on the loop.
5347 // If this is called for the thread of the loop's #GMainContext,
5348 // it will process events from the loop, otherwise it will
5349 // simply wait.
5350 void run() {
5351 g_main_loop_run(&this);
5354 // Decreases the reference count on a #GMainLoop object by one. If
5355 // the result is zero, free the loop and free all associated memory.
5356 void unref() {
5357 g_main_loop_unref(&this);
5361 struct MappedFile {
5363 // This call existed before #GMappedFile had refcounting and is currently
5364 // exactly the same as g_mapped_file_unref().
5366 // Deprecated:2.22: Use g_mapped_file_unref() instead.
5367 void free() {
5368 g_mapped_file_free(&this);
5371 // Returns the contents of a #GMappedFile.
5373 // Note that the contents may not be zero-terminated,
5374 // even if the #GMappedFile is backed by a text file.
5376 // If the file is empty then %NULL is returned.
5377 // RETURNS: the contents of @file, or %NULL.
5378 char* /*new*/ get_contents() {
5379 return g_mapped_file_get_contents(&this);
5382 // Returns the length of the contents of a #GMappedFile.
5383 // RETURNS: the length of the contents of @file.
5384 size_t get_length() {
5385 return g_mapped_file_get_length(&this);
5388 // Unintrospectable method: ref() / g_mapped_file_ref()
5389 // Increments the reference count of @file by one. It is safe to call
5390 // this function from any thread.
5391 // RETURNS: the passed in #GMappedFile.
5392 MappedFile* ref_() {
5393 return g_mapped_file_ref(&this);
5396 // Decrements the reference count of @file by one. If the reference count
5397 // drops to 0, unmaps the buffer of @file and frees it.
5399 // It is safe to call this function from any thread.
5401 // Since 2.22
5402 void unref() {
5403 g_mapped_file_unref(&this);
5406 // Unintrospectable function: new() / g_mapped_file_new()
5407 // Maps a file into memory. On UNIX, this is using the mmap() function.
5409 // If @writable is %TRUE, the mapped buffer may be modified, otherwise
5410 // it is an error to modify the mapped buffer. Modifications to the buffer
5411 // are not visible to other processes mapping the same file, and are not
5412 // written back to the file.
5414 // Note that modifications of the underlying file might affect the contents
5415 // of the #GMappedFile. Therefore, mapping should only be used if the file
5416 // will not be modified, or if all modifications of the file are done
5417 // atomically (e.g. using g_file_set_contents()).
5419 // with g_mapped_file_unref(), or %NULL if the mapping failed.
5420 // RETURNS: a newly allocated #GMappedFile which must be unref'd
5421 // <filename>: The path of the file to load, in the GLib filename encoding
5422 // <writable>: whether the mapping should be writable
5423 static MappedFile* new_(char* filename, int writable, GLib2.Error** error=null) {
5424 return g_mapped_file_new(filename, writable, error);
5429 // A mixed enumerated type and flags field. You must specify one type
5430 // (string, strdup, boolean, tristate). Additionally, you may optionally
5431 // bitwise OR the type with the flag %G_MARKUP_COLLECT_OPTIONAL.
5433 // It is likely that this enum will be extended in the future to
5434 // support other types.
5435 enum MarkupCollectType {
5436 INVALID = 0,
5437 STRING = 1,
5438 STRDUP = 2,
5439 BOOLEAN = 3,
5440 TRISTATE = 4,
5441 OPTIONAL = 65536
5443 // Error codes returned by markup parsing.
5444 enum MarkupError {
5445 BAD_UTF8 = 0,
5446 EMPTY = 1,
5447 PARSE = 2,
5448 UNKNOWN_ELEMENT = 3,
5449 UNKNOWN_ATTRIBUTE = 4,
5450 INVALID_CONTENT = 5,
5451 MISSING_ATTRIBUTE = 6
5454 // A parse context is used to parse a stream of bytes that
5455 // you expect to contain marked-up text.
5457 // See g_markup_parse_context_new(), #GMarkupParser, and so
5458 // on for more details.
5459 struct MarkupParseContext {
5461 // Signals to the #GMarkupParseContext that all data has been
5462 // fed into the parse context with g_markup_parse_context_parse().
5464 // This function reports an error if the document isn't complete,
5465 // for example if elements are still open.
5466 // RETURNS: %TRUE on success, %FALSE if an error was set
5467 int end_parse(GLib2.Error** error=null) {
5468 return g_markup_parse_context_end_parse(&this, error);
5471 // Frees a #GMarkupParseContext.
5473 // This function can't be called from inside one of the
5474 // #GMarkupParser functions or while a subparser is pushed.
5475 void free() {
5476 g_markup_parse_context_free(&this);
5479 // Retrieves the name of the currently open element.
5481 // If called from the start_element or end_element handlers this will
5482 // give the element_name as passed to those functions. For the parent
5483 // elements, see g_markup_parse_context_get_element_stack().
5484 // RETURNS: the name of the currently open element, or %NULL
5485 char* get_element() {
5486 return g_markup_parse_context_get_element(&this);
5489 // Unintrospectable method: get_element_stack() / g_markup_parse_context_get_element_stack()
5490 // Retrieves the element stack from the internal state of the parser.
5492 // The returned #GSList is a list of strings where the first item is
5493 // the currently open tag (as would be returned by
5494 // g_markup_parse_context_get_element()) and the next item is its
5495 // immediate parent.
5497 // This function is intended to be used in the start_element and
5498 // end_element handlers where g_markup_parse_context_get_element()
5499 // would merely return the name of the element that is being
5500 // processed.
5501 // RETURNS: the element stack, which must not be modified
5502 GLib2.SList* get_element_stack() {
5503 return g_markup_parse_context_get_element_stack(&this);
5506 // Retrieves the current line number and the number of the character on
5507 // that line. Intended for use in error messages; there are no strict
5508 // semantics for what constitutes the "current" line number other than
5509 // "the best number we could come up with for error messages."
5510 // <line_number>: return location for a line number, or %NULL
5511 // <char_number>: return location for a char-on-line number, or %NULL
5512 void get_position(int* line_number=null, int* char_number=null) {
5513 g_markup_parse_context_get_position(&this, line_number, char_number);
5516 // Unintrospectable method: get_user_data() / g_markup_parse_context_get_user_data()
5517 // Returns the user_data associated with @context.
5519 // This will either be the user_data that was provided to
5520 // g_markup_parse_context_new() or to the most recent call
5521 // of g_markup_parse_context_push().
5523 // the markup context and will be freed when
5524 // g_markup_parse_context_free() is called.
5525 // RETURNS: the provided user_data. The returned data belongs to
5526 void* get_user_data() {
5527 return g_markup_parse_context_get_user_data(&this);
5530 // Feed some data to the #GMarkupParseContext.
5532 // The data need not be valid UTF-8; an error will be signaled if
5533 // it's invalid. The data need not be an entire document; you can
5534 // feed a document into the parser incrementally, via multiple calls
5535 // to this function. Typically, as you receive data from a network
5536 // connection or file, you feed each received chunk of data into this
5537 // function, aborting the process if an error occurs. Once an error
5538 // is reported, no further data may be fed to the #GMarkupParseContext;
5539 // all errors are fatal.
5540 // RETURNS: %FALSE if an error occurred, %TRUE on success
5541 // <text>: chunk of text to parse
5542 // <text_len>: length of @text in bytes
5543 int parse(char* text, ssize_t text_len, GLib2.Error** error=null) {
5544 return g_markup_parse_context_parse(&this, text, text_len, error);
5547 // Unintrospectable method: pop() / g_markup_parse_context_pop()
5548 // Completes the process of a temporary sub-parser redirection.
5550 // This function exists to collect the user_data allocated by a
5551 // matching call to g_markup_parse_context_push(). It must be called
5552 // in the end_element handler corresponding to the start_element
5553 // handler during which g_markup_parse_context_push() was called.
5554 // You must not call this function from the error callback -- the
5555 // @user_data is provided directly to the callback in that case.
5557 // This function is not intended to be directly called by users
5558 // interested in invoking subparsers. Instead, it is intended to
5559 // be used by the subparsers themselves to implement a higher-level
5560 // interface.
5561 // RETURNS: the user data passed to g_markup_parse_context_push()
5562 void* pop() {
5563 return g_markup_parse_context_pop(&this);
5566 // Temporarily redirects markup data to a sub-parser.
5568 // This function may only be called from the start_element handler of
5569 // a #GMarkupParser. It must be matched with a corresponding call to
5570 // g_markup_parse_context_pop() in the matching end_element handler
5571 // (except in the case that the parser aborts due to an error).
5573 // All tags, text and other data between the matching tags is
5574 // redirected to the subparser given by @parser. @user_data is used
5575 // as the user_data for that parser. @user_data is also passed to the
5576 // error callback in the event that an error occurs. This includes
5577 // errors that occur in subparsers of the subparser.
5579 // The end tag matching the start tag for which this call was made is
5580 // handled by the previous parser (which is given its own user_data)
5581 // which is why g_markup_parse_context_pop() is provided to allow "one
5582 // last access" to the @user_data provided to this function. In the
5583 // case of error, the @user_data provided here is passed directly to
5584 // the error callback of the subparser and g_markup_parse_context_pop()
5585 // should not be called. In either case, if @user_data was allocated
5586 // then it ought to be freed from both of these locations.
5588 // This function is not intended to be directly called by users
5589 // interested in invoking subparsers. Instead, it is intended to be
5590 // used by the subparsers themselves to implement a higher-level
5591 // interface.
5593 // As an example, see the following implementation of a simple
5594 // parser that counts the number of tags encountered.
5596 // |[
5597 // typedef struct
5598 // {
5599 // gint tag_count;
5600 // } CounterData;
5602 // static void
5603 // counter_start_element (GMarkupParseContext *context,
5604 // const gchar *element_name,
5605 // const gchar **attribute_names,
5606 // const gchar **attribute_values,
5607 // gpointer user_data,
5608 // GError **error)
5609 // {
5610 // CounterData *data = user_data;
5612 // data->tag_count++;
5613 // }
5615 // static void
5616 // counter_error (GMarkupParseContext *context,
5617 // GError *error,
5618 // gpointer user_data)
5619 // {
5620 // CounterData *data = user_data;
5622 // g_slice_free (CounterData, data);
5623 // }
5625 // static GMarkupParser counter_subparser =
5626 // {
5627 // counter_start_element,
5628 // NULL,
5629 // NULL,
5630 // NULL,
5631 // counter_error
5632 // };
5633 // ]|
5635 // In order to allow this parser to be easily used as a subparser, the
5636 // following interface is provided:
5638 // |[
5639 // void
5640 // start_counting (GMarkupParseContext *context)
5641 // {
5642 // CounterData *data = g_slice_new (CounterData);
5644 // data->tag_count = 0;
5645 // g_markup_parse_context_push (context, &counter_subparser, data);
5646 // }
5648 // gint
5649 // end_counting (GMarkupParseContext *context)
5650 // {
5651 // CounterData *data = g_markup_parse_context_pop (context);
5652 // int result;
5654 // result = data->tag_count;
5655 // g_slice_free (CounterData, data);
5657 // return result;
5658 // }
5659 // ]|
5661 // The subparser would then be used as follows:
5663 // |[
5664 // static void start_element (context, element_name, ...)
5665 // {
5666 // if (strcmp (element_name, "count-these") == 0)
5667 // start_counting (context);
5669 // /&ast; else, handle other tags... &ast;/
5670 // }
5672 // static void end_element (context, element_name, ...)
5673 // {
5674 // if (strcmp (element_name, "count-these") == 0)
5675 // g_print ("Counted %d tags\n", end_counting (context));
5677 // /&ast; else, handle other tags... &ast;/
5678 // }
5679 // ]|
5680 // <parser>: a #GMarkupParser
5681 // <user_data>: user data to pass to #GMarkupParser functions
5682 void push(MarkupParser* parser, void* user_data) {
5683 g_markup_parse_context_push(&this, parser, user_data);
5686 // Unintrospectable function: new() / g_markup_parse_context_new()
5687 // Creates a new parse context. A parse context is used to parse
5688 // marked-up documents. You can feed any number of documents into
5689 // a context, as long as no errors occur; once an error occurs,
5690 // the parse context can't continue to parse text (you have to
5691 // free it and create a new parse context).
5692 // RETURNS: a new #GMarkupParseContext
5693 // <parser>: a #GMarkupParser
5694 // <flags>: one or more #GMarkupParseFlags
5695 // <user_data>: user data to pass to #GMarkupParser functions
5696 // <user_data_dnotify>: user data destroy notifier called when the parse context is freed
5697 static MarkupParseContext* new_(MarkupParser* parser, MarkupParseFlags flags, void* user_data, DestroyNotify user_data_dnotify) {
5698 return g_markup_parse_context_new(parser, flags, user_data, user_data_dnotify);
5702 // Flags that affect the behaviour of the parser.
5703 enum MarkupParseFlags {
5704 DO_NOT_USE_THIS_UNSUPPORTED_FLAG = 1,
5705 TREAT_CDATA_AS_TEXT = 2,
5706 PREFIX_ERROR_POSITION = 4
5709 // Any of the fields in #GMarkupParser can be %NULL, in which case they
5710 // will be ignored. Except for the @error function, any of these callbacks
5711 // can set an error; in particular the %G_MARKUP_ERROR_UNKNOWN_ELEMENT,
5712 // %G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, and %G_MARKUP_ERROR_INVALID_CONTENT
5713 // errors are intended to be set from these callbacks. If you set an error
5714 // from a callback, g_markup_parse_context_parse() will report that error
5715 // back to its caller.
5716 struct MarkupParser {
5717 extern (C) void function (MarkupParseContext* context, char* element_name, char** attribute_names, char** attribute_values, void* user_data, GLib2.Error** error=null) start_element;
5718 extern (C) void function (MarkupParseContext* context, char* element_name, void* user_data, GLib2.Error** error=null) end_element;
5719 extern (C) void function (MarkupParseContext* context, char* text, size_t text_len, void* user_data, GLib2.Error** error=null) text;
5720 extern (C) void function (MarkupParseContext* context, char* passthrough_text, size_t text_len, void* user_data, GLib2.Error** error=null) passthrough;
5721 extern (C) void function (MarkupParseContext* context, Error* error, void* user_data) error;
5724 struct MatchInfo {
5726 // Returns a new string containing the text in @string_to_expand with
5727 // references and escape sequences expanded. References refer to the last
5728 // match done with @string against @regex and have the same syntax used by
5729 // g_regex_replace().
5731 // The @string_to_expand must be UTF-8 encoded even if #G_REGEX_RAW was
5732 // passed to g_regex_new().
5734 // The backreferences are extracted from the string passed to the match
5735 // function, so you cannot call this function after freeing the string.
5737 // @match_info may be %NULL in which case @string_to_expand must not
5738 // contain references. For instance "foo\n" does not refer to an actual
5739 // pattern and '\n' merely will be replaced with \n character,
5740 // while to expand "\0" (whole match) one needs the result of a match.
5741 // Use g_regex_check_replacement() to find out whether @string_to_expand
5742 // contains references.
5743 // RETURNS: the expanded string, or %NULL if an error occurred
5744 // <string_to_expand>: the string to expand
5745 char* /*new*/ expand_references(char* string_to_expand, GLib2.Error** error=null) {
5746 return g_match_info_expand_references(&this, string_to_expand, error);
5749 // Retrieves the text matching the @match_num<!-- -->'th capturing
5750 // parentheses. 0 is the full text of the match, 1 is the first paren
5751 // set, 2 the second, and so on.
5753 // If @match_num is a valid sub pattern but it didn't match anything
5754 // (e.g. sub pattern 1, matching "b" against "(a)?b") then an empty
5755 // string is returned.
5757 // If the match was obtained using the DFA algorithm, that is using
5758 // g_regex_match_all() or g_regex_match_all_full(), the retrieved
5759 // string is not that of a set of parentheses but that of a matched
5760 // substring. Substrings are matched in reverse order of length, so
5761 // 0 is the longest match.
5763 // The string is fetched from the string passed to the match function,
5764 // so you cannot call this function after freeing the string.
5766 // occurred. You have to free the string yourself
5767 // RETURNS: The matched substring, or %NULL if an error
5768 // <match_num>: number of the sub expression
5769 char* /*new*/ fetch(int match_num) {
5770 return g_match_info_fetch(&this, match_num);
5773 // Unintrospectable method: fetch_all() / g_match_info_fetch_all()
5774 // Bundles up pointers to each of the matching substrings from a match
5775 // and stores them in an array of gchar pointers. The first element in
5776 // the returned array is the match number 0, i.e. the entire matched
5777 // text.
5779 // If a sub pattern didn't match anything (e.g. sub pattern 1, matching
5780 // "b" against "(a)?b") then an empty string is inserted.
5782 // If the last match was obtained using the DFA algorithm, that is using
5783 // g_regex_match_all() or g_regex_match_all_full(), the retrieved
5784 // strings are not that matched by sets of parentheses but that of the
5785 // matched substring. Substrings are matched in reverse order of length,
5786 // so the first one is the longest match.
5788 // The strings are fetched from the string passed to the match function,
5789 // so you cannot call this function after freeing the string.
5791 // It must be freed using g_strfreev(). If the previous match failed
5792 // %NULL is returned
5793 // RETURNS: a %NULL-terminated array of gchar * pointers.
5794 char** fetch_all() {
5795 return g_match_info_fetch_all(&this);
5798 // Retrieves the text matching the capturing parentheses named @name.
5800 // If @name is a valid sub pattern name but it didn't match anything
5801 // (e.g. sub pattern "X", matching "b" against "(?P&lt;X&gt;a)?b")
5802 // then an empty string is returned.
5804 // The string is fetched from the string passed to the match function,
5805 // so you cannot call this function after freeing the string.
5807 // occurred. You have to free the string yourself
5808 // RETURNS: The matched substring, or %NULL if an error
5809 // <name>: name of the subexpression
5810 char* /*new*/ fetch_named(char* name) {
5811 return g_match_info_fetch_named(&this, name);
5814 // Retrieves the position in bytes of the capturing parentheses named @name.
5816 // If @name is a valid sub pattern name but it didn't match anything
5817 // (e.g. sub pattern "X", matching "b" against "(?P&lt;X&gt;a)?b")
5818 // then @start_pos and @end_pos are set to -1 and %TRUE is returned.
5820 // If the position cannot be fetched, @start_pos and @end_pos
5821 // are left unchanged.
5822 // RETURNS: %TRUE if the position was fetched, %FALSE otherwise.
5823 // <name>: name of the subexpression
5824 // <start_pos>: pointer to location where to store the start position, or %NULL
5825 // <end_pos>: pointer to location where to store the end position, or %NULL
5826 int fetch_named_pos(char* name, /*out*/ int* start_pos=null, /*out*/ int* end_pos=null) {
5827 return g_match_info_fetch_named_pos(&this, name, start_pos, end_pos);
5830 // Retrieves the position in bytes of the @match_num<!-- -->'th capturing
5831 // parentheses. 0 is the full text of the match, 1 is the first
5832 // paren set, 2 the second, and so on.
5834 // If @match_num is a valid sub pattern but it didn't match anything
5835 // (e.g. sub pattern 1, matching "b" against "(a)?b") then @start_pos
5836 // and @end_pos are set to -1 and %TRUE is returned.
5838 // If the match was obtained using the DFA algorithm, that is using
5839 // g_regex_match_all() or g_regex_match_all_full(), the retrieved
5840 // position is not that of a set of parentheses but that of a matched
5841 // substring. Substrings are matched in reverse order of length, so
5842 // 0 is the longest match.
5844 // the position cannot be fetched, @start_pos and @end_pos are left
5845 // unchanged
5846 // RETURNS: %TRUE if the position was fetched, %FALSE otherwise. If
5847 // <match_num>: number of the sub expression
5848 // <start_pos>: pointer to location where to store the start position, or %NULL
5849 // <end_pos>: pointer to location where to store the end position, or %NULL
5850 int fetch_pos(int match_num, /*out*/ int* start_pos=null, /*out*/ int* end_pos=null) {
5851 return g_match_info_fetch_pos(&this, match_num, start_pos, end_pos);
5854 // If @match_info is not %NULL, calls g_match_info_unref(); otherwise does
5855 // nothing.
5856 void free() {
5857 g_match_info_free(&this);
5860 // Retrieves the number of matched substrings (including substring 0,
5861 // that is the whole matched text), so 1 is returned if the pattern
5862 // has no substrings in it and 0 is returned if the match failed.
5864 // If the last match was obtained using the DFA algorithm, that is
5865 // using g_regex_match_all() or g_regex_match_all_full(), the retrieved
5866 // count is not that of the number of capturing parentheses but that of
5867 // the number of matched substrings.
5868 // RETURNS: Number of matched substrings, or -1 if an error occurred
5869 int get_match_count() {
5870 return g_match_info_get_match_count(&this);
5873 // Returns #GRegex object used in @match_info. It belongs to Glib
5874 // and must not be freed. Use g_regex_ref() if you need to keep it
5875 // after you free @match_info object.
5876 // RETURNS: #GRegex object used in @match_info
5877 Regex* /*new*/ get_regex() {
5878 return g_match_info_get_regex(&this);
5881 // Returns the string searched with @match_info. This is the
5882 // string passed to g_regex_match() or g_regex_replace() so
5883 // you may not free it before calling this function.
5884 // RETURNS: the string searched with @match_info
5885 char* get_string() {
5886 return g_match_info_get_string(&this);
5889 // Usually if the string passed to g_regex_match*() matches as far as
5890 // it goes, but is too short to match the entire pattern, %FALSE is
5891 // returned. There are circumstances where it might be helpful to
5892 // distinguish this case from other cases in which there is no match.
5894 // Consider, for example, an application where a human is required to
5895 // type in data for a field with specific formatting requirements. An
5896 // example might be a date in the form ddmmmyy, defined by the pattern
5897 // "^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$".
5898 // If the application sees the user’s keystrokes one by one, and can
5899 // check that what has been typed so far is potentially valid, it is
5900 // able to raise an error as soon as a mistake is made.
5902 // GRegex supports the concept of partial matching by means of the
5903 // #G_REGEX_MATCH_PARTIAL flag. When this is set the return code for
5904 // g_regex_match() or g_regex_match_full() is, as usual, %TRUE
5905 // for a complete match, %FALSE otherwise. But, when these functions
5906 // return %FALSE, you can check if the match was partial calling
5907 // g_match_info_is_partial_match().
5909 // When using partial matching you cannot use g_match_info_fetch*().
5911 // Because of the way certain internal optimizations are implemented
5912 // the partial matching algorithm cannot be used with all patterns.
5913 // So repeated single characters such as "a{2,4}" and repeated single
5914 // meta-sequences such as "\d+" are not permitted if the maximum number
5915 // of occurrences is greater than one. Optional items such as "\d?"
5916 // (where the maximum is one) are permitted. Quantifiers with any values
5917 // are permitted after parentheses, so the invalid examples above can be
5918 // coded thus "(a){2,4}" and "(\d)+". If #G_REGEX_MATCH_PARTIAL is set
5919 // for a pattern that does not conform to the restrictions, matching
5920 // functions return an error.
5921 // RETURNS: %TRUE if the match was partial, %FALSE otherwise
5922 int is_partial_match() {
5923 return g_match_info_is_partial_match(&this);
5926 // Returns whether the previous match operation succeeded.
5928 // %FALSE otherwise
5929 // RETURNS: %TRUE if the previous match operation succeeded,
5930 int matches() {
5931 return g_match_info_matches(&this);
5934 // Scans for the next match using the same parameters of the previous
5935 // call to g_regex_match_full() or g_regex_match() that returned
5936 // @match_info.
5938 // The match is done on the string passed to the match function, so you
5939 // cannot free it before calling this function.
5940 // RETURNS: %TRUE is the string matched, %FALSE otherwise
5941 int next(GLib2.Error** error=null) {
5942 return g_match_info_next(&this, error);
5945 // Increases reference count of @match_info by 1.
5946 // RETURNS: @match_info
5947 MatchInfo* /*new*/ ref_() {
5948 return g_match_info_ref(&this);
5951 // Decreases reference count of @match_info by 1. When reference count drops
5952 // to zero, it frees all the memory associated with the match_info structure.
5953 void unref() {
5954 g_match_info_unref(&this);
5959 // The #GMemChunk struct is an opaque data structure representing a
5960 // memory chunk. It should be accessed only through the use of the
5961 // following functions.
5962 struct MemChunk {
5964 // Unintrospectable method: alloc() / g_mem_chunk_alloc()
5965 // Allocates an atom of memory from a #GMemChunk.
5967 // Deprecated:2.10: Use g_slice_alloc() instead
5968 void* alloc() {
5969 return g_mem_chunk_alloc(&this);
5972 // Unintrospectable method: alloc0() / g_mem_chunk_alloc0()
5973 // Allocates an atom of memory from a #GMemChunk, setting the memory to
5974 // 0.
5976 // Deprecated:2.10: Use g_slice_alloc0() instead
5977 void* alloc0() {
5978 return g_mem_chunk_alloc0(&this);
5981 // Frees any blocks in a #GMemChunk which are no longer being used.
5983 // Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
5984 // allocator</link> instead
5985 void clean() {
5986 g_mem_chunk_clean(&this);
5989 // Frees all of the memory allocated for a #GMemChunk.
5991 // Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
5992 // allocator</link> instead
5993 void destroy() {
5994 g_mem_chunk_destroy(&this);
5997 // Frees an atom in a #GMemChunk. This should only be called if the
5998 // #GMemChunk was created with #G_ALLOC_AND_FREE. Otherwise it will
5999 // simply return.
6001 // Deprecated:2.10: Use g_slice_free1() instead
6002 // <mem>: a pointer to the atom to free.
6003 void free(void* mem) {
6004 g_mem_chunk_free(&this, mem);
6007 // Outputs debugging information for a #GMemChunk. It outputs the name
6008 // of the #GMemChunk (set with g_mem_chunk_new()), the number of bytes
6009 // used, and the number of blocks of memory allocated.
6011 // Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
6012 // allocator</link> instead
6013 void print() {
6014 g_mem_chunk_print(&this);
6017 // Resets a GMemChunk to its initial state. It frees all of the
6018 // currently allocated blocks of memory.
6020 // Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
6021 // allocator</link> instead
6022 void reset() {
6023 g_mem_chunk_reset(&this);
6026 // Outputs debugging information for all #GMemChunk objects currently
6027 // in use. It outputs the number of #GMemChunk objects currently
6028 // allocated, and calls g_mem_chunk_print() to output information on
6029 // each one.
6031 // Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
6032 // allocator</link> instead
6033 static void info() {
6034 g_mem_chunk_info();
6037 // Unintrospectable function: new() / g_mem_chunk_new()
6038 // Creates a new #GMemChunk.
6040 // Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
6041 // allocator</link> instead
6042 // <name>: a string to identify the #GMemChunk. It is not copied so it should be valid for the lifetime of the #GMemChunk. It is only used in g_mem_chunk_print(), which is used for debugging.
6043 // <atom_size>: the size, in bytes, of each element in the #GMemChunk.
6044 // <area_size>: the size, in bytes, of each block of memory allocated to contain the atoms.
6045 // <type>: the type of the #GMemChunk. #G_ALLOC_AND_FREE is used if the atoms will be freed individually. #G_ALLOC_ONLY should be used if atoms will never be freed individually. #G_ALLOC_ONLY is quicker, since it does not need to track free atoms, but it obviously wastes memory if you no longer need many of the atoms.
6046 static MemChunk* new_(char* name, int atom_size, size_t area_size, int type) {
6047 return g_mem_chunk_new(name, atom_size, area_size, type);
6052 // A set of functions used to perform memory allocation. The same #GMemVTable must
6053 // be used for all allocations in the same program; a call to g_mem_set_vtable(),
6054 // if it exists, should be prior to any use of GLib.
6055 struct MemVTable {
6056 // Unintrospectable functionp: malloc() / ()
6057 extern (C) void* function (size_t n_bytes) malloc;
6058 // Unintrospectable functionp: realloc() / ()
6059 extern (C) void* function (void* mem, size_t n_bytes) realloc;
6060 extern (C) void function (void* mem) free;
6061 // Unintrospectable functionp: calloc() / ()
6062 extern (C) void* function (size_t n_blocks, size_t n_block_bytes) calloc;
6063 // Unintrospectable functionp: try_malloc() / ()
6064 extern (C) void* function (size_t n_bytes) try_malloc;
6065 // Unintrospectable functionp: try_realloc() / ()
6066 extern (C) void* function (void* mem, size_t n_bytes) try_realloc;
6070 // The #GMutex struct is an opaque data structure to represent a mutex
6071 // (mutual exclusion). It can be used to protect data against shared
6072 // access. Take for example the following function:
6074 // <example>
6075 // <title>A function which will not work in a threaded environment</title>
6076 // <programlisting>
6077 // int
6078 // give_me_next_number (void)
6079 // {
6080 // static int current_number = 0;
6082 // /<!-- -->* now do a very complicated calculation to calculate the new
6083 // * number, this might for example be a random number generator
6084 // *<!-- -->/
6085 // current_number = calc_next_number (current_number);
6087 // return current_number;
6088 // }
6089 // </programlisting>
6090 // </example>
6092 // It is easy to see that this won't work in a multi-threaded
6093 // application. There current_number must be protected against shared
6094 // access. A first naive implementation would be:
6096 // <example>
6097 // <title>The wrong way to write a thread-safe function</title>
6098 // <programlisting>
6099 // int
6100 // give_me_next_number (void)
6101 // {
6102 // static int current_number = 0;
6103 // int ret_val;
6104 // static GMutex * mutex = NULL;
6106 // if (!mutex) mutex = g_mutex_new (<!-- -->);
6108 // g_mutex_lock (mutex);
6109 // ret_val = current_number = calc_next_number (current_number);
6110 // g_mutex_unlock (mutex);
6112 // return ret_val;
6113 // }
6114 // </programlisting>
6115 // </example>
6117 // This looks like it would work, but there is a race condition while
6118 // constructing the mutex and this code cannot work reliable. Please do
6119 // not use such constructs in your own programs! One working solution
6120 // is:
6122 // <example>
6123 // <title>A correct thread-safe function</title>
6124 // <programlisting>
6125 // static GMutex *give_me_next_number_mutex = NULL;
6127 // /<!-- -->* this function must be called before any call to
6128 // * give_me_next_number(<!-- -->)
6129 // *
6130 // * it must be called exactly once.
6131 // *<!-- -->/
6132 // void
6133 // init_give_me_next_number (void)
6134 // {
6135 // g_assert (give_me_next_number_mutex == NULL);
6136 // give_me_next_number_mutex = g_mutex_new (<!-- -->);
6137 // }
6139 // int
6140 // give_me_next_number (void)
6141 // {
6142 // static int current_number = 0;
6143 // int ret_val;
6145 // g_mutex_lock (give_me_next_number_mutex);
6146 // ret_val = current_number = calc_next_number (current_number);
6147 // g_mutex_unlock (give_me_next_number_mutex);
6149 // return ret_val;
6150 // }
6151 // </programlisting>
6152 // </example>
6154 // #GStaticMutex provides a simpler and safer way of doing this.
6156 // If you want to use a mutex, and your code should also work without
6157 // calling g_thread_init() first, then you cannot use a #GMutex, as
6158 // g_mutex_new() requires that the thread system be initialized. Use a
6159 // #GStaticMutex instead.
6161 // A #GMutex should only be accessed via the following functions.
6163 // <note><para>All of the <function>g_mutex_*</function> functions are
6164 // actually macros. Apart from taking their addresses, you can however
6165 // use them as if they were functions.</para></note>
6166 struct Mutex {
6170 // The #GNode struct represents one node in a
6171 // <link linkend="glib-N-ary-Trees">N-ary Tree</link>. fields
6172 struct Node {
6173 void* data;
6174 Node* next, prev, parent, children;
6177 // Gets the position of the first child of a #GNode
6178 // which contains the given data.
6180 // @data, or -1 if the data is not found
6181 // RETURNS: the index of the child of @node which contains
6182 // <data>: the data to find
6183 int child_index(void* data) {
6184 return g_node_child_index(&this, data);
6187 // Gets the position of a #GNode with respect to its siblings.
6188 // @child must be a child of @node. The first child is numbered 0,
6189 // the second 1, and so on.
6190 // RETURNS: the position of @child with respect to its siblings
6191 // <child>: a child of @node
6192 int child_position(Node* child) {
6193 return g_node_child_position(&this, child);
6196 // Unintrospectable method: children_foreach() / g_node_children_foreach()
6197 // Calls a function for each of the children of a #GNode.
6198 // Note that it doesn't descend beneath the child nodes.
6199 // <flags>: which types of children are to be visited, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
6200 // <func>: the function to call for each visited node
6201 // <data>: user data to pass to the function
6202 void children_foreach(TraverseFlags flags, NodeForeachFunc func, void* data) {
6203 g_node_children_foreach(&this, flags, func, data);
6206 // Unintrospectable method: copy() / g_node_copy()
6207 // Recursively copies a #GNode (but does not deep-copy the data inside the
6208 // nodes, see g_node_copy_deep() if you need that).
6209 // RETURNS: a new #GNode containing the same data pointers
6210 Node* copy() {
6211 return g_node_copy(&this);
6214 // Unintrospectable method: copy_deep() / g_node_copy_deep()
6215 // Recursively copies a #GNode and its data.
6216 // RETURNS: a new #GNode containing copies of the data in @node.
6217 // <copy_func>: the function which is called to copy the data inside each node, or %NULL to use the original data.
6218 // <data>: data to pass to @copy_func
6219 Node* copy_deep(CopyFunc copy_func, void* data) {
6220 return g_node_copy_deep(&this, copy_func, data);
6223 // Gets the depth of a #GNode.
6225 // If @node is %NULL the depth is 0. The root node has a depth of 1.
6226 // For the children of the root node the depth is 2. And so on.
6227 // RETURNS: the depth of the #GNode
6228 uint depth() {
6229 return g_node_depth(&this);
6232 // Removes @root and its children from the tree, freeing any memory
6233 // allocated.
6234 void destroy() {
6235 g_node_destroy(&this);
6238 // Unintrospectable method: find() / g_node_find()
6239 // Finds a #GNode in a tree.
6240 // RETURNS: the found #GNode, or %NULL if the data is not found
6241 // <order>: the order in which nodes are visited - %G_IN_ORDER, %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER
6242 // <flags>: which types of children are to be searched, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
6243 // <data>: the data to find
6244 Node* find(TraverseType order, TraverseFlags flags, void* data) {
6245 return g_node_find(&this, order, flags, data);
6248 // Unintrospectable method: find_child() / g_node_find_child()
6249 // Finds the first child of a #GNode with the given data.
6250 // RETURNS: the found child #GNode, or %NULL if the data is not found
6251 // <flags>: which types of children are to be searched, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
6252 // <data>: the data to find
6253 Node* find_child(TraverseFlags flags, void* data) {
6254 return g_node_find_child(&this, flags, data);
6257 // Unintrospectable method: first_sibling() / g_node_first_sibling()
6258 // Gets the first sibling of a #GNode.
6259 // This could possibly be the node itself.
6260 // RETURNS: the first sibling of @node
6261 Node* first_sibling() {
6262 return g_node_first_sibling(&this);
6265 // Unintrospectable method: get_root() / g_node_get_root()
6266 // Gets the root of a tree.
6267 // RETURNS: the root of the tree
6268 Node* get_root() {
6269 return g_node_get_root(&this);
6272 // Unintrospectable method: insert() / g_node_insert()
6273 // Inserts a #GNode beneath the parent at the given position.
6274 // RETURNS: the inserted #GNode
6275 // <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
6276 // <node>: the #GNode to insert
6277 Node* insert(int position, Node* node) {
6278 return g_node_insert(&this, position, node);
6281 // Unintrospectable method: insert_after() / g_node_insert_after()
6282 // Inserts a #GNode beneath the parent after the given sibling.
6283 // RETURNS: the inserted #GNode
6284 // <sibling>: the sibling #GNode to place @node after. If sibling is %NULL, the node is inserted as the first child of @parent.
6285 // <node>: the #GNode to insert
6286 Node* insert_after(Node* sibling, Node* node) {
6287 return g_node_insert_after(&this, sibling, node);
6290 // Unintrospectable method: insert_before() / g_node_insert_before()
6291 // Inserts a #GNode beneath the parent before the given sibling.
6292 // RETURNS: the inserted #GNode
6293 // <sibling>: the sibling #GNode to place @node before. If sibling is %NULL, the node is inserted as the last child of @parent.
6294 // <node>: the #GNode to insert
6295 Node* insert_before(Node* sibling, Node* node) {
6296 return g_node_insert_before(&this, sibling, node);
6299 // Returns %TRUE if @node is an ancestor of @descendant.
6300 // This is true if node is the parent of @descendant,
6301 // or if node is the grandparent of @descendant etc.
6302 // RETURNS: %TRUE if @node is an ancestor of @descendant
6303 // <descendant>: a #GNode
6304 int is_ancestor(Node* descendant) {
6305 return g_node_is_ancestor(&this, descendant);
6308 // Unintrospectable method: last_child() / g_node_last_child()
6309 // Gets the last child of a #GNode.
6310 // RETURNS: the last child of @node, or %NULL if @node has no children
6311 Node* last_child() {
6312 return g_node_last_child(&this);
6315 // Unintrospectable method: last_sibling() / g_node_last_sibling()
6316 // Gets the last sibling of a #GNode.
6317 // This could possibly be the node itself.
6318 // RETURNS: the last sibling of @node
6319 Node* last_sibling() {
6320 return g_node_last_sibling(&this);
6323 // Gets the maximum height of all branches beneath a #GNode.
6324 // This is the maximum distance from the #GNode to all leaf nodes.
6326 // If @root is %NULL, 0 is returned. If @root has no children,
6327 // 1 is returned. If @root has children, 2 is returned. And so on.
6328 // RETURNS: the maximum height of the tree beneath @root
6329 uint max_height() {
6330 return g_node_max_height(&this);
6333 // Gets the number of children of a #GNode.
6334 // RETURNS: the number of children of @node
6335 uint n_children() {
6336 return g_node_n_children(&this);
6339 // Gets the number of nodes in a tree.
6340 // RETURNS: the number of nodes in the tree
6341 // <flags>: which types of children are to be counted, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
6342 uint n_nodes(TraverseFlags flags) {
6343 return g_node_n_nodes(&this, flags);
6346 // Unintrospectable method: nth_child() / g_node_nth_child()
6347 // Gets a child of a #GNode, using the given index.
6348 // The first child is at index 0. If the index is
6349 // too big, %NULL is returned.
6350 // RETURNS: the child of @node at index @n
6351 // <n>: the index of the desired child
6352 Node* nth_child(uint n) {
6353 return g_node_nth_child(&this, n);
6356 // Unintrospectable method: prepend() / g_node_prepend()
6357 // Inserts a #GNode as the first child of the given parent.
6358 // RETURNS: the inserted #GNode
6359 // <node>: the #GNode to insert
6360 Node* prepend(Node* node) {
6361 return g_node_prepend(&this, node);
6364 // Reverses the order of the children of a #GNode.
6365 // (It doesn't change the order of the grandchildren.)
6366 void reverse_children() {
6367 g_node_reverse_children(&this);
6370 // Unintrospectable method: traverse() / g_node_traverse()
6371 // Traverses a tree starting at the given root #GNode.
6372 // It calls the given function for each node visited.
6373 // The traversal can be halted at any point by returning %TRUE from @func.
6374 // <order>: the order in which nodes are visited - %G_IN_ORDER, %G_PRE_ORDER, %G_POST_ORDER, or %G_LEVEL_ORDER.
6375 // <flags>: which types of children are to be visited, one of %G_TRAVERSE_ALL, %G_TRAVERSE_LEAVES and %G_TRAVERSE_NON_LEAVES
6376 // <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.
6377 // <func>: the function to call for each visited #GNode
6378 // <data>: user data to pass to the function
6379 void traverse(TraverseType order, TraverseFlags flags, int max_depth, NodeTraverseFunc func, void* data) {
6380 g_node_traverse(&this, order, flags, max_depth, func, data);
6382 // Unlinks a #GNode from a tree, resulting in two separate trees.
6383 void unlink() {
6384 g_node_unlink(&this);
6387 // Unintrospectable function: new() / g_node_new()
6388 // Creates a new #GNode containing the given data.
6389 // Used to create the first node in a tree.
6390 // RETURNS: a new #GNode
6391 // <data>: the data of the new node
6392 static Node* new_(void* data) {
6393 return g_node_new(data);
6396 // Restores the previous #GAllocator, used when allocating #GNode
6397 // elements.
6399 // Note that this function is not available if GLib has been compiled
6400 // with <option>--disable-mem-pools</option>
6402 // Deprecated:2.10: It does nothing, since #GNode has been converted to
6403 // the <link linkend="glib-Memory-Slices">slice
6404 // allocator</link>
6405 static void pop_allocator() {
6406 g_node_pop_allocator();
6409 // Sets the allocator to use to allocate #GNode elements. Use
6410 // g_node_pop_allocator() to restore the previous allocator.
6412 // Note that this function is not available if GLib has been compiled
6413 // with <option>--disable-mem-pools</option>
6415 // Deprecated:2.10: It does nothing, since #GNode has been converted to
6416 // the <link linkend="glib-Memory-Slices">slice
6417 // allocator</link>
6418 // <dummy>: the #GAllocator to use when allocating #GNode elements.
6419 static void push_allocator(void* dummy) {
6420 g_node_push_allocator(dummy);
6425 // Specifies the type of function passed to g_node_children_foreach().
6426 // The function is called with each child node, together with the user
6427 // data passed to g_node_children_foreach().
6428 // <node>: a #GNode.
6429 // <data>: user data passed to g_node_children_foreach().
6430 extern (C) alias void function (Node* node, void* data) NodeForeachFunc;
6433 // Specifies the type of function passed to g_node_traverse(). The
6434 // function is called with each of the nodes visited, together with the
6435 // user data passed to g_node_traverse(). If the function returns
6436 // %TRUE, then the traversal is stopped.
6437 // <node>: a #GNode.
6438 // <data>: user data passed to g_node_traverse().
6439 extern (C) alias int function (Node* node, void* data) NodeTraverseFunc;
6442 // Defines how a Unicode string is transformed in a canonical
6443 // form, standardizing such issues as whether a character with
6444 // an accent is represented as a base character and combining
6445 // accent or as a single precomposed character. Unicode strings
6446 // should generally be normalized before comparing them.
6447 enum NormalizeMode {
6448 DEFAULT = 0,
6449 NFD = 0,
6450 DEFAULT_COMPOSE = 1,
6451 NFC = 1,
6452 ALL = 2,
6453 NFKD = 2,
6454 ALL_COMPOSE = 3,
6455 NFKC = 3
6457 enum OPTION_REMAINING = "";
6459 // A #GOnce struct controls a one-time initialization function. Any
6460 // one-time initialization function must have its own unique #GOnce
6461 // struct.
6462 struct Once /* Version 2.4 */ {
6463 OnceStatus status;
6464 void* retval;
6466 // Unintrospectable method: impl() / g_once_impl()
6467 void* impl(ThreadFunc func, void* arg) {
6468 return g_once_impl(&this, func, arg);
6471 // Function to be called when starting a critical initialization
6472 // section. The argument @value_location must point to a static
6473 // 0-initialized variable that will be set to a value other than 0 at
6474 // the end of the initialization section. In combination with
6475 // g_once_init_leave() and the unique address @value_location, it can
6476 // be ensured that an initialization section will be executed only once
6477 // during a program's life time, and that concurrent threads are
6478 // blocked until initialization completed. To be used in constructs
6479 // like this:
6481 // <informalexample>
6482 // <programlisting>
6483 // static gsize initialization_value = 0;
6485 // if (g_once_init_enter (&amp;initialization_value))
6486 // {
6487 // gsize setup_value = 42; /<!-- -->* initialization code here *<!-- -->/
6489 // g_once_init_leave (&amp;initialization_value, setup_value);
6490 // }
6492 // /<!-- -->* use initialization_value here *<!-- -->/
6493 // </programlisting>
6494 // </informalexample>
6495 // <value_location>: location of a static initializable variable containing 0.
6496 static int init_enter(size_t* value_location) {
6497 return g_once_init_enter(value_location);
6499 static int init_enter_impl(size_t* value_location) {
6500 return g_once_init_enter_impl(value_location);
6503 // Counterpart to g_once_init_enter(). Expects a location of a static
6504 // 0-initialized initialization variable, and an initialization value
6505 // other than 0. Sets the variable to the initialization value, and
6506 // releases concurrent threads blocking in g_once_init_enter() on this
6507 // initialization variable.
6508 // <value_location>: location of a static initializable variable containing 0.
6509 // <initialization_value>: new non-0 value for *@value_location.
6510 static void init_leave(size_t* value_location, size_t initialization_value) {
6511 g_once_init_leave(value_location, initialization_value);
6516 // The possible statuses of a one-time initialization function
6517 // controlled by a #GOnce struct.
6518 enum OnceStatus /* Version 2.4 */ {
6519 NOTCALLED = 0,
6520 PROGRESS = 1,
6521 READY = 2
6524 // The #GOptionArg enum values determine which type of extra argument the
6525 // options expect to find. If an option expects an extra argument, it
6526 // can be specified in several ways; with a short option:
6527 // <option>-x arg</option>, with a long option: <option>--name arg</option>
6528 // or combined in a single argument: <option>--name=arg</option>.
6529 enum OptionArg {
6530 NONE = 0,
6531 STRING = 1,
6532 INT = 2,
6533 CALLBACK = 3,
6534 FILENAME = 4,
6535 STRING_ARRAY = 5,
6536 FILENAME_ARRAY = 6,
6537 DOUBLE = 7,
6538 INT64 = 8
6541 // The type of function to be passed as callback for %G_OPTION_ARG_CALLBACK
6542 // options.
6544 // occurred, in which case @error should be set with g_set_error()
6545 // RETURNS: %TRUE if the option was successfully parsed, %FALSE if an error
6546 // <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.
6547 // <value>: The value to be parsed.
6548 // <data>: User data added to the #GOptionGroup containing the option when it was created with g_option_group_new()
6549 extern (C) alias int function (char* option_name, char* value, void* data, GLib2.Error** error=null) OptionArgFunc;
6552 // A <structname>GOptionContext</structname> struct defines which options
6553 // are accepted by the commandline option parser. The struct has only private
6554 // fields and should not be directly accessed.
6555 struct OptionContext {
6557 // Adds a #GOptionGroup to the @context, so that parsing with @context
6558 // will recognize the options in the group. Note that the group will
6559 // be freed together with the context when g_option_context_free() is
6560 // called, so you must not free the group yourself after adding it
6561 // to a context.
6562 // <group>: the group to add
6563 void add_group(OptionGroup* group) {
6564 g_option_context_add_group(&this, group);
6567 // A convenience function which creates a main group if it doesn't
6568 // exist, adds the @entries to it and sets the translation domain.
6569 // <entries>: a %NULL-terminated array of #GOptionEntry<!-- -->s
6570 // <translation_domain>: a translation domain to use for translating the <option>--help</option> output for the options in @entries with gettext(), or %NULL
6571 void add_main_entries(OptionEntry* entries, char* translation_domain) {
6572 g_option_context_add_main_entries(&this, entries, translation_domain);
6575 // Frees context and all the groups which have been
6576 // added to it.
6578 // Please note that parsed arguments need to be freed separately (see
6579 // #GOptionEntry).
6580 void free() {
6581 g_option_context_free(&this);
6584 // Returns the description. See g_option_context_set_description().
6585 // RETURNS: the description
6586 char* get_description() {
6587 return g_option_context_get_description(&this);
6590 // Returns a formatted, translated help text for the given context.
6591 // To obtain the text produced by <option>--help</option>, call
6592 // <literal>g_option_context_get_help (context, TRUE, NULL)</literal>.
6593 // To obtain the text produced by <option>--help-all</option>, call
6594 // <literal>g_option_context_get_help (context, FALSE, NULL)</literal>.
6595 // To obtain the help text for an option group, call
6596 // <literal>g_option_context_get_help (context, FALSE, group)</literal>.
6597 // RETURNS: A newly allocated string containing the help text
6598 // <main_help>: if %TRUE, only include the main group
6599 // <group>: the #GOptionGroup to create help for, or %NULL
6600 char* /*new*/ get_help(int main_help, OptionGroup* group) {
6601 return g_option_context_get_help(&this, main_help, group);
6604 // Returns whether automatic <option>--help</option> generation
6605 // is turned on for @context. See g_option_context_set_help_enabled().
6606 // RETURNS: %TRUE if automatic help generation is turned on.
6607 int get_help_enabled() {
6608 return g_option_context_get_help_enabled(&this);
6611 // Returns whether unknown options are ignored or not. See
6612 // g_option_context_set_ignore_unknown_options().
6613 // RETURNS: %TRUE if unknown options are ignored.
6614 int get_ignore_unknown_options() {
6615 return g_option_context_get_ignore_unknown_options(&this);
6618 // Unintrospectable method: get_main_group() / g_option_context_get_main_group()
6619 // Returns a pointer to the main group of @context.
6621 // have a main group. Note that group belongs to @context and should
6622 // not be modified or freed.
6623 // RETURNS: the main group of @context, or %NULL if @context doesn't
6624 OptionGroup* get_main_group() {
6625 return g_option_context_get_main_group(&this);
6628 // Returns the summary. See g_option_context_set_summary().
6629 // RETURNS: the summary
6630 char* get_summary() {
6631 return g_option_context_get_summary(&this);
6634 // Parses the command line arguments, recognizing options
6635 // which have been added to @context. A side-effect of
6636 // calling this function is that g_set_prgname() will be
6637 // called.
6639 // If the parsing is successful, any parsed arguments are
6640 // removed from the array and @argc and @argv are updated
6641 // accordingly. A '--' option is stripped from @argv
6642 // unless there are unparsed options before and after it,
6643 // or some of the options after it start with '-'. In case
6644 // of an error, @argc and @argv are left unmodified.
6646 // If automatic <option>--help</option> support is enabled
6647 // (see g_option_context_set_help_enabled()), and the
6648 // @argv array contains one of the recognized help options,
6649 // this function will produce help output to stdout and
6650 // call <literal>exit (0)</literal>.
6652 // Note that function depends on the
6653 // <link linkend="setlocale">current locale</link> for
6654 // automatic character set conversion of string and filename
6655 // arguments.
6657 // %FALSE if an error occurred
6658 // RETURNS: %TRUE if the parsing was successful,
6659 // <argc>: a pointer to the number of command line arguments
6660 // <argv>: a pointer to the array of command line arguments
6661 int parse(/*inout*/ int* argc, /*inout*/ char*** argv, GLib2.Error** error=null) {
6662 return g_option_context_parse(&this, argc, argv, error);
6665 // Adds a string to be displayed in <option>--help</option> output
6666 // after the list of options. This text often includes a bug reporting
6667 // address.
6669 // Note that the summary is translated (see
6670 // g_option_context_set_translate_func()).
6671 // <description>: a string to be shown in <option>--help</option> output after the list of options, or %NULL
6672 void set_description(char* description) {
6673 g_option_context_set_description(&this, description);
6676 // Enables or disables automatic generation of <option>--help</option>
6677 // output. By default, g_option_context_parse() recognizes
6678 // <option>--help</option>, <option>-h</option>,
6679 // <option>-?</option>, <option>--help-all</option>
6680 // and <option>--help-</option><replaceable>groupname</replaceable> and creates
6681 // suitable output to stdout.
6682 // <help_enabled>: %TRUE to enable <option>--help</option>, %FALSE to disable it
6683 void set_help_enabled(int help_enabled) {
6684 g_option_context_set_help_enabled(&this, help_enabled);
6687 // Sets whether to ignore unknown options or not. If an argument is
6688 // ignored, it is left in the @argv array after parsing. By default,
6689 // g_option_context_parse() treats unknown options as error.
6691 // This setting does not affect non-option arguments (i.e. arguments
6692 // which don't start with a dash). But note that GOption cannot reliably
6693 // determine whether a non-option belongs to a preceding unknown option.
6694 // <ignore_unknown>: %TRUE to ignore unknown options, %FALSE to produce an error when unknown options are met
6695 void set_ignore_unknown_options(int ignore_unknown) {
6696 g_option_context_set_ignore_unknown_options(&this, ignore_unknown);
6699 // Sets a #GOptionGroup as main group of the @context.
6700 // This has the same effect as calling g_option_context_add_group(),
6701 // the only difference is that the options in the main group are
6702 // treated differently when generating <option>--help</option> output.
6703 // <group>: the group to set as main group
6704 void set_main_group(OptionGroup* group) {
6705 g_option_context_set_main_group(&this, group);
6708 // Adds a string to be displayed in <option>--help</option> output
6709 // before the list of options. This is typically a summary of the
6710 // program functionality.
6712 // Note that the summary is translated (see
6713 // g_option_context_set_translate_func() and
6714 // g_option_context_set_translation_domain()).
6715 // <summary>: a string to be shown in <option>--help</option> output before the list of options, or %NULL
6716 void set_summary(char* summary) {
6717 g_option_context_set_summary(&this, summary);
6720 // Sets the function which is used to translate the contexts
6721 // user-visible strings, for <option>--help</option> output.
6722 // If @func is %NULL, strings are not translated.
6724 // Note that option groups have their own translation functions,
6725 // this function only affects the @parameter_string (see g_option_context_new()),
6726 // the summary (see g_option_context_set_summary()) and the description
6727 // (see g_option_context_set_description()).
6729 // If you are using gettext(), you only need to set the translation
6730 // domain, see g_option_context_set_translation_domain().
6731 // <func>: the #GTranslateFunc, or %NULL
6732 // <data>: user data to pass to @func, or %NULL
6733 // <destroy_notify>: a function which gets called to free @data, or %NULL
6734 void set_translate_func(TranslateFunc func, void* data, DestroyNotify destroy_notify) {
6735 g_option_context_set_translate_func(&this, func, data, destroy_notify);
6738 // A convenience function to use gettext() for translating
6739 // user-visible strings.
6740 // <domain>: the domain to use
6741 void set_translation_domain(char* domain) {
6742 g_option_context_set_translation_domain(&this, domain);
6745 // Unintrospectable function: new() / g_option_context_new()
6746 // Creates a new option context.
6748 // The @parameter_string can serve multiple purposes. It can be used
6749 // to add descriptions for "rest" arguments, which are not parsed by
6750 // the #GOptionContext, typically something like "FILES" or
6751 // "FILE1 FILE2...". If you are using #G_OPTION_REMAINING for
6752 // collecting "rest" arguments, GLib handles this automatically by
6753 // using the @arg_description of the corresponding #GOptionEntry in
6754 // the usage summary.
6756 // Another usage is to give a short summary of the program
6757 // functionality, like " - frob the strings", which will be displayed
6758 // in the same line as the usage. For a longer description of the
6759 // program functionality that should be displayed as a paragraph
6760 // below the usage line, use g_option_context_set_summary().
6762 // Note that the @parameter_string is translated using the
6763 // function set with g_option_context_set_translate_func(), so
6764 // it should normally be passed untranslated.
6766 // freed with g_option_context_free() after use.
6767 // RETURNS: a newly created #GOptionContext, which must be
6768 // <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>
6769 static OptionContext* new_(char* parameter_string) {
6770 return g_option_context_new(parameter_string);
6775 // A <structname>GOptionEntry</structname> defines a single option.
6776 // To have an effect, they must be added to a #GOptionGroup with
6777 // g_option_context_add_main_entries() or g_option_group_add_entries().
6778 struct OptionEntry {
6779 char* long_name;
6780 char short_name;
6781 int flags;
6782 OptionArg arg;
6783 void* arg_data;
6784 char* description, arg_description;
6787 // Error codes returned by option parsing.
6788 enum OptionError {
6789 UNKNOWN_OPTION = 0,
6790 BAD_VALUE = 1,
6791 FAILED = 2
6794 // The type of function to be used as callback when a parse error occurs.
6795 // <context>: The active #GOptionContext
6796 // <group>: The group to which the function belongs
6797 // <data>: User data added to the #GOptionGroup containing the option when it was created with g_option_group_new()
6798 extern (C) alias void function (OptionContext* context, OptionGroup* group, void* data, GLib2.Error** error=null) OptionErrorFunc;
6800 // Flags which modify individual options.
6801 enum OptionFlags {
6802 HIDDEN = 1,
6803 IN_MAIN = 2,
6804 REVERSE = 4,
6805 NO_ARG = 8,
6806 FILENAME = 16,
6807 OPTIONAL_ARG = 32,
6808 NOALIAS = 64
6811 // A <structname>GOptionGroup</structname> struct defines the options in a single
6812 // group. The struct has only private fields and should not be directly accessed.
6814 // All options in a group share the same translation function. Libraries which
6815 // need to parse commandline options are expected to provide a function for
6816 // getting a <structname>GOptionGroup</structname> holding their options, which
6817 // the application can then add to its #GOptionContext.
6818 struct OptionGroup {
6820 // Adds the options specified in @entries to @group.
6821 // <entries>: a %NULL-terminated array of #GOptionEntry<!-- -->s
6822 void add_entries(OptionEntry* entries) {
6823 g_option_group_add_entries(&this, entries);
6826 // Frees a #GOptionGroup. Note that you must <emphasis>not</emphasis>
6827 // free groups which have been added to a #GOptionContext.
6828 void free() {
6829 g_option_group_free(&this);
6832 // Unintrospectable method: set_error_hook() / g_option_group_set_error_hook()
6833 // Associates a function with @group which will be called
6834 // from g_option_context_parse() when an error occurs.
6836 // Note that the user data to be passed to @error_func can be
6837 // specified when constructing the group with g_option_group_new().
6838 // <error_func>: a function to call when an error occurs
6839 void set_error_hook(OptionErrorFunc error_func) {
6840 g_option_group_set_error_hook(&this, error_func);
6843 // Unintrospectable method: set_parse_hooks() / g_option_group_set_parse_hooks()
6844 // Associates two functions with @group which will be called
6845 // from g_option_context_parse() before the first option is parsed
6846 // and after the last option has been parsed, respectively.
6848 // Note that the user data to be passed to @pre_parse_func and
6849 // @post_parse_func can be specified when constructing the group
6850 // with g_option_group_new().
6851 // <pre_parse_func>: a function to call before parsing, or %NULL
6852 // <post_parse_func>: a function to call after parsing, or %NULL
6853 void set_parse_hooks(OptionParseFunc pre_parse_func, OptionParseFunc post_parse_func) {
6854 g_option_group_set_parse_hooks(&this, pre_parse_func, post_parse_func);
6857 // Sets the function which is used to translate user-visible
6858 // strings, for <option>--help</option> output. Different
6859 // groups can use different #GTranslateFunc<!-- -->s. If @func
6860 // is %NULL, strings are not translated.
6862 // If you are using gettext(), you only need to set the translation
6863 // domain, see g_option_group_set_translation_domain().
6864 // <func>: the #GTranslateFunc, or %NULL
6865 // <data>: user data to pass to @func, or %NULL
6866 // <destroy_notify>: a function which gets called to free @data, or %NULL
6867 void set_translate_func(TranslateFunc func, void* data, DestroyNotify destroy_notify) {
6868 g_option_group_set_translate_func(&this, func, data, destroy_notify);
6871 // A convenience function to use gettext() for translating
6872 // user-visible strings.
6873 // <domain>: the domain to use
6874 void set_translation_domain(char* domain) {
6875 g_option_group_set_translation_domain(&this, domain);
6878 // Unintrospectable function: new() / g_option_group_new()
6879 // Creates a new #GOptionGroup.
6881 // to a #GOptionContext or freed with g_option_group_free().
6882 // RETURNS: a newly created option group. It should be added
6883 // <name>: the name for the option group, this is used to provide help for the options in this group with <option>--help-</option>@name
6884 // <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
6885 // <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
6886 // <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
6887 // <destroy>: a function that will be called to free @user_data, or %NULL
6888 static OptionGroup* new_(char* name, char* description, char* help_description, void* user_data, DestroyNotify destroy) {
6889 return g_option_group_new(name, description, help_description, user_data, destroy);
6894 // The type of function that can be called before and after parsing.
6896 // occurred, in which case @error should be set with g_set_error()
6897 // RETURNS: %TRUE if the function completed successfully, %FALSE if an error
6898 // <context>: The active #GOptionContext
6899 // <group>: The group to which the function belongs
6900 // <data>: User data added to the #GOptionGroup containing the option when it was created with g_option_group_new()
6901 extern (C) alias int function (OptionContext* context, OptionGroup* group, void* data, GLib2.Error** error=null) OptionParseFunc;
6903 enum int PDP_ENDIAN = 3412;
6904 enum double PI = 3.141593;
6905 enum double PI_2 = 1.570796;
6906 enum double PI_4 = 0.785398;
6907 enum POLLFD_FORMAT = "%#I64x";
6908 enum int PRIORITY_DEFAULT = 0;
6909 enum int PRIORITY_DEFAULT_IDLE = 200;
6910 enum int PRIORITY_HIGH = -100;
6911 enum int PRIORITY_HIGH_IDLE = 100;
6912 enum int PRIORITY_LOW = 300;
6914 // A <structname>GPatternSpec</structname> is the 'compiled' form of a
6915 // pattern. This structure is opaque and its fields cannot be accessed
6916 // directly.
6917 struct PatternSpec {
6919 // Compares two compiled pattern specs and returns whether they will
6920 // match the same set of strings.
6921 // <pspec2>: another #GPatternSpec
6922 int equal(PatternSpec* pspec2) {
6923 return g_pattern_spec_equal(&this, pspec2);
6925 // Frees the memory allocated for the #GPatternSpec.
6926 void free() {
6927 g_pattern_spec_free(&this);
6930 // Unintrospectable function: new() / g_pattern_spec_new()
6931 // Compiles a pattern to a #GPatternSpec.
6932 // <pattern>: a zero-terminated UTF-8 encoded string
6933 static PatternSpec* new_(char* pattern) {
6934 return g_pattern_spec_new(pattern);
6938 struct PollFD {
6939 int fd;
6940 ushort events, revents;
6944 // Specifies the type of function passed to g_main_context_set_poll_func().
6945 // The semantics of the function should match those of the poll() system call.
6947 // reported, or -1 if an error occurred.
6948 // RETURNS: the number of #GPollFD elements which have events or errors
6949 // <ufds>: an array of #GPollFD elements
6950 // <nfsd>: the number of elements in @ufds
6951 // <timeout_>: the maximum time to wait for an event of the file descriptors. A negative value indicates an infinite timeout.
6952 extern (C) alias int function (PollFD* ufds, uint nfsd, int timeout_) PollFunc;
6955 // Specifies the type of the print handler functions.
6956 // These are called with the complete formatted string to output.
6957 // <string>: the message to output
6958 extern (C) alias void function (char* string_) PrintFunc;
6961 // <note><para>
6962 // #GStaticPrivate is a better choice for most uses.
6963 // </para></note>
6965 // The #GPrivate struct is an opaque data structure to represent a
6966 // thread private data key. Threads can thereby obtain and set a
6967 // pointer which is private to the current thread. Take our
6968 // <function>give_me_next_number(<!-- -->)</function> example from
6969 // above. Suppose we don't want <literal>current_number</literal> to be
6970 // shared between the threads, but instead to be private to each thread.
6971 // This can be done as follows:
6973 // <example>
6974 // <title>Using GPrivate for per-thread data</title>
6975 // <programlisting>
6976 // GPrivate* current_number_key = NULL; /<!-- -->* Must be initialized somewhere
6977 // with g_private_new (g_free); *<!-- -->/
6979 // int
6980 // give_me_next_number (void)
6981 // {
6982 // int *current_number = g_private_get (current_number_key);
6984 // if (!current_number)
6985 // {
6986 // current_number = g_new (int, 1);
6987 // *current_number = 0;
6988 // g_private_set (current_number_key, current_number);
6989 // }
6991 // *current_number = calc_next_number (*current_number);
6993 // return *current_number;
6994 // }
6995 // </programlisting>
6996 // </example>
6998 // Here the pointer belonging to the key
6999 // <literal>current_number_key</literal> is read. If it is %NULL, it has
7000 // not been set yet. Then get memory for an integer value, assign this
7001 // memory to the pointer and write the pointer back. Now we have an
7002 // integer value that is private to the current thread.
7004 // The #GPrivate struct should only be accessed via the following
7005 // functions.
7007 // <note><para>All of the <function>g_private_*</function> functions are
7008 // actually macros. Apart from taking their addresses, you can however
7009 // use them as if they were functions.</para></note>
7010 struct Private {
7013 // Contains the public fields of a pointer array.
7014 struct PtrArray {
7015 void** pdata;
7016 uint len;
7019 // Adds a pointer to the end of the pointer array. The array will grow
7020 // in size automatically if necessary.
7021 // <array>: a #GPtrArray.
7022 // <data>: the pointer to add.
7023 static void add(PtrArray* array, void* data) {
7024 g_ptr_array_add(array, data);
7027 // Unintrospectable function: foreach() / g_ptr_array_foreach()
7028 // Calls a function for each element of a #GPtrArray.
7029 // <array>: a #GPtrArray
7030 // <func>: the function to call for each array element
7031 // <user_data>: user data to pass to the function
7032 static void foreach_(PtrArray* array, Func func, void* user_data) {
7033 g_ptr_array_foreach(array, func, user_data);
7036 // Unintrospectable function: free() / g_ptr_array_free()
7037 // Frees the memory allocated for the #GPtrArray. If @free_seg is %TRUE
7038 // it frees the memory block holding the elements as well. Pass %FALSE
7039 // if you want to free the #GPtrArray wrapper but preserve the
7040 // underlying array for use elsewhere. If the reference count of @array
7041 // is greater than one, the #GPtrArray wrapper is preserved but the
7042 // size of @array will be set to zero.
7044 // <note><para>If array contents point to dynamically-allocated
7045 // memory, they should be freed separately if @free_seg is %TRUE and no
7046 // #GDestroyNotify function has been set for @array.</para></note>
7047 // <array>: a #GPtrArray.
7048 // <free_seg>: if %TRUE the actual pointer array is freed as well.
7049 static void** free(PtrArray* array, int free_seg) {
7050 return g_ptr_array_free(array, free_seg);
7053 // Unintrospectable function: new() / g_ptr_array_new()
7054 // Creates a new #GPtrArray with a reference count of 1.
7055 static PtrArray* new_() {
7056 return g_ptr_array_new();
7059 // Unintrospectable function: new_full() / g_ptr_array_new_full()
7060 // Creates a new #GPtrArray with @reserved_size pointers preallocated
7061 // and a reference count of 1. This avoids frequent reallocation, if
7062 // you are going to add many pointers to the array. Note however that
7063 // the size of the array is still 0. It also set @element_free_func
7064 // for freeing each element when the array is destroyed either via
7065 // g_ptr_array_unref(), when g_ptr_array_free() is called with @free_segment
7066 // set to %TRUE or when removing elements.
7067 // RETURNS: A new #GPtrArray.
7068 // <reserved_size>: number of pointers preallocated.
7069 // <element_free_func>: A function to free elements with destroy @array or %NULL.
7070 static PtrArray* new_full(uint reserved_size, DestroyNotify element_free_func) {
7071 return g_ptr_array_new_full(reserved_size, element_free_func);
7074 // Unintrospectable function: new_with_free_func() / g_ptr_array_new_with_free_func()
7075 // Creates a new #GPtrArray with a reference count of 1 and use @element_free_func
7076 // for freeing each element when the array is destroyed either via
7077 // g_ptr_array_unref(), when g_ptr_array_free() is called with @free_segment
7078 // set to %TRUE or when removing elements.
7079 // RETURNS: A new #GPtrArray.
7080 // <element_free_func>: A function to free elements with destroy @array or %NULL.
7081 static PtrArray* new_with_free_func(DestroyNotify element_free_func) {
7082 return g_ptr_array_new_with_free_func(element_free_func);
7085 // Unintrospectable function: ref() / g_ptr_array_ref()
7086 // Atomically increments the reference count of @array by one. This
7087 // function is MT-safe and may be called from any thread.
7088 // RETURNS: The passed in #GPtrArray.
7089 // <array>: A #GArray.
7090 static PtrArray* ref_(PtrArray* array) {
7091 return g_ptr_array_ref(array);
7094 // Removes the first occurrence of the given pointer from the pointer
7095 // array. The following elements are moved down one place. If @array
7096 // has a non-%NULL #GDestroyNotify function it is called for the
7097 // removed element.
7099 // It returns %TRUE if the pointer was removed, or %FALSE if the
7100 // pointer was not found.
7101 // <array>: a #GPtrArray.
7102 // <data>: the pointer to remove.
7103 static int remove(PtrArray* array, void* data) {
7104 return g_ptr_array_remove(array, data);
7107 // Removes the first occurrence of the given pointer from the pointer
7108 // array. The last element in the array is used to fill in the space,
7109 // so this function does not preserve the order of the array. But it is
7110 // faster than g_ptr_array_remove(). If @array has a non-%NULL
7111 // #GDestroyNotify function it is called for the removed element.
7113 // It returns %TRUE if the pointer was removed, or %FALSE if the
7114 // pointer was not found.
7115 // <array>: a #GPtrArray.
7116 // <data>: the pointer to remove.
7117 static int remove_fast(PtrArray* array, void* data) {
7118 return g_ptr_array_remove_fast(array, data);
7121 // Unintrospectable function: remove_index() / g_ptr_array_remove_index()
7122 // Removes the pointer at the given index from the pointer array. The
7123 // following elements are moved down one place. If @array has a
7124 // non-%NULL #GDestroyNotify function it is called for the removed
7125 // element.
7126 // <array>: a #GPtrArray.
7127 // <index_>: the index of the pointer to remove.
7128 static void* remove_index(PtrArray* array, uint index_) {
7129 return g_ptr_array_remove_index(array, index_);
7132 // Unintrospectable function: remove_index_fast() / g_ptr_array_remove_index_fast()
7133 // Removes the pointer at the given index from the pointer array. The
7134 // last element in the array is used to fill in the space, so this
7135 // function does not preserve the order of the array. But it is faster
7136 // than g_ptr_array_remove_index(). If @array has a non-%NULL
7137 // #GDestroyNotify function it is called for the removed element.
7138 // <array>: a #GPtrArray.
7139 // <index_>: the index of the pointer to remove.
7140 static void* remove_index_fast(PtrArray* array, uint index_) {
7141 return g_ptr_array_remove_index_fast(array, index_);
7144 // Removes the given number of pointers starting at the given index
7145 // from a #GPtrArray. The following elements are moved to close the
7146 // gap. If @array has a non-%NULL #GDestroyNotify function it is called
7147 // for the removed elements.
7148 // <array>: a @GPtrArray.
7149 // <index_>: the index of the first pointer to remove.
7150 // <length>: the number of pointers to remove.
7151 static void remove_range(PtrArray* array, uint index_, uint length) {
7152 g_ptr_array_remove_range(array, index_, length);
7155 // Sets a function for freeing each element when @array is destroyed
7156 // either via g_ptr_array_unref(), when g_ptr_array_free() is called
7157 // with @free_segment set to %TRUE or when removing elements.
7158 // <array>: A #GPtrArray.
7159 // <element_free_func>: A function to free elements with destroy @array or %NULL.
7160 static void set_free_func(PtrArray* array, DestroyNotify element_free_func) {
7161 g_ptr_array_set_free_func(array, element_free_func);
7164 // Sets the size of the array. When making the array larger,
7165 // newly-added elements will be set to %NULL. When making it smaller,
7166 // if @array has a non-%NULL #GDestroyNotify function then it will be
7167 // called for the removed elements.
7168 // <array>: a #GPtrArray.
7169 // <length>: the new length of the pointer array.
7170 static void set_size(PtrArray* array, int length) {
7171 g_ptr_array_set_size(array, length);
7174 // Unintrospectable function: sized_new() / g_ptr_array_sized_new()
7175 // Creates a new #GPtrArray with @reserved_size pointers preallocated
7176 // and a reference count of 1. This avoids frequent reallocation, if
7177 // you are going to add many pointers to the array. Note however that
7178 // the size of the array is still 0.
7179 // <reserved_size>: number of pointers preallocated.
7180 static PtrArray* sized_new(uint reserved_size) {
7181 return g_ptr_array_sized_new(reserved_size);
7184 // Unintrospectable function: sort() / g_ptr_array_sort()
7185 // Sorts the array, using @compare_func which should be a qsort()-style
7186 // comparison function (returns less than zero for first arg is less
7187 // than second arg, zero for equal, greater than zero if irst arg is
7188 // greater than second arg).
7190 // If two array elements compare equal, their order in the sorted array
7191 // is undefined. If you want equal elements to keep their order &#8211; i.e.
7192 // you want a stable sort &#8211; you can write a comparison function that,
7193 // if two elements would otherwise compare equal, compares them by
7194 // their addresses.
7196 // <note><para>The comparison function for g_ptr_array_sort() doesn't
7197 // take the pointers from the array as arguments, it takes pointers to
7198 // the pointers in the array.</para></note>
7199 // <array>: a #GPtrArray.
7200 // <compare_func>: comparison function.
7201 static void sort(PtrArray* array, CompareFunc compare_func) {
7202 g_ptr_array_sort(array, compare_func);
7205 // Unintrospectable function: sort_with_data() / g_ptr_array_sort_with_data()
7206 // Like g_ptr_array_sort(), but the comparison function has an extra
7207 // user data argument.
7209 // <note><para>The comparison function for g_ptr_array_sort_with_data()
7210 // doesn't take the pointers from the array as arguments, it takes
7211 // pointers to the pointers in the array.</para></note>
7212 // <array>: a #GPtrArray.
7213 // <compare_func>: comparison function.
7214 // <user_data>: data to pass to @compare_func.
7215 static void sort_with_data(PtrArray* array, CompareDataFunc compare_func, void* user_data) {
7216 g_ptr_array_sort_with_data(array, compare_func, user_data);
7219 // Atomically decrements the reference count of @array by one. If the
7220 // reference count drops to 0, the effect is the same as calling
7221 // g_ptr_array_free() with @free_segment set to %TRUE. This function
7222 // is MT-safe and may be called from any thread.
7223 // <array>: A #GPtrArray.
7224 static void unref(PtrArray* array) {
7225 g_ptr_array_unref(array);
7230 // Contains the public fields of a
7231 // <link linkend="glib-Double-ended-Queues">Queue</link>.
7232 struct Queue {
7233 GLib2.List* head, tail;
7234 uint length;
7237 // Removes all the elements in @queue. If queue elements contain
7238 // dynamically-allocated memory, they should be freed first.
7239 void clear() {
7240 g_queue_clear(&this);
7243 // Unintrospectable method: copy() / g_queue_copy()
7244 // Copies a @queue. Note that is a shallow copy. If the elements in the
7245 // queue consist of pointers to data, the pointers are copied, but the
7246 // actual data is not.
7247 // RETURNS: A copy of @queue
7248 Queue* copy() {
7249 return g_queue_copy(&this);
7252 // Unintrospectable method: delete_link() / g_queue_delete_link()
7253 // Removes @link_ from @queue and frees it.
7255 // @link_ must be part of @queue.
7256 // <link_>: a #GList link that <emphasis>must</emphasis> be part of @queue
7257 void delete_link(GLib2.List* link_) {
7258 g_queue_delete_link(&this, link_);
7261 // Unintrospectable method: find() / g_queue_find()
7262 // Finds the first link in @queue which contains @data.
7263 // RETURNS: The first link in @queue which contains @data.
7264 // <data>: data to find
7265 GLib2.List* find(const(void)* data) {
7266 return g_queue_find(&this, data);
7269 // Unintrospectable method: find_custom() / g_queue_find_custom()
7270 // Finds an element in a #GQueue, using a supplied function to find the
7271 // desired element. It iterates over the queue, calling the given function
7272 // which should return 0 when the desired element is found. The function
7273 // takes two gconstpointer arguments, the #GQueue element's data as the
7274 // first argument and the given user data as the second argument.
7275 // RETURNS: The found link, or %NULL if it wasn't found
7276 // <data>: user data passed to @func
7277 // <func>: a #GCompareFunc to call for each element. It should return 0 when the desired element is found
7278 GLib2.List* find_custom(const(void)* data, CompareFunc func) {
7279 return g_queue_find_custom(&this, data, func);
7282 // Unintrospectable method: foreach() / g_queue_foreach()
7283 // Calls @func for each element in the queue passing @user_data to the
7284 // function.
7285 // <func>: the function to call for each element's data
7286 // <user_data>: user data to pass to @func
7287 void foreach_(Func func, void* user_data) {
7288 g_queue_foreach(&this, func, user_data);
7291 // Frees the memory allocated for the #GQueue. Only call this function if
7292 // @queue was created with g_queue_new(). If queue elements contain
7293 // dynamically-allocated memory, they should be freed first.
7294 void free() {
7295 g_queue_free(&this);
7298 // Returns the number of items in @queue.
7299 // RETURNS: The number of items in @queue.
7300 uint get_length() {
7301 return g_queue_get_length(&this);
7304 // Returns the position of the first element in @queue which contains @data.
7305 // RETURNS: The position of the first element in @queue which contains @data, or -1 if no element in @queue contains @data.
7306 // <data>: the data to find.
7307 int index(const(void)* data) {
7308 return g_queue_index(&this, data);
7311 // A statically-allocated #GQueue must be initialized with this function
7312 // before it can be used. Alternatively you can initialize it with
7313 // #G_QUEUE_INIT. It is not necessary to initialize queues created with
7314 // g_queue_new().
7315 void init() {
7316 g_queue_init(&this);
7319 // Unintrospectable method: insert_after() / g_queue_insert_after()
7320 // Inserts @data into @queue after @sibling
7322 // @sibling must be part of @queue
7323 // <sibling>: a #GList link that <emphasis>must</emphasis> be part of @queue
7324 // <data>: the data to insert
7325 void insert_after(GLib2.List* sibling, void* data) {
7326 g_queue_insert_after(&this, sibling, data);
7329 // Unintrospectable method: insert_before() / g_queue_insert_before()
7330 // Inserts @data into @queue before @sibling.
7332 // @sibling must be part of @queue.
7333 // <sibling>: a #GList link that <emphasis>must</emphasis> be part of @queue
7334 // <data>: the data to insert
7335 void insert_before(GLib2.List* sibling, void* data) {
7336 g_queue_insert_before(&this, sibling, data);
7339 // Unintrospectable method: insert_sorted() / g_queue_insert_sorted()
7340 // Inserts @data into @queue using @func to determine the new position.
7341 // <data>: the data to insert
7342 // <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.
7343 // <user_data>: user data passed to @func.
7344 void insert_sorted(void* data, CompareDataFunc func, void* user_data) {
7345 g_queue_insert_sorted(&this, data, func, user_data);
7348 // Returns %TRUE if the queue is empty.
7349 // RETURNS: %TRUE if the queue is empty.
7350 int is_empty() {
7351 return g_queue_is_empty(&this);
7354 // Unintrospectable method: link_index() / g_queue_link_index()
7355 // Returns the position of @link_ in @queue.
7357 // not part of @queue
7358 // RETURNS: The position of @link_, or -1 if the link is
7359 // <link_>: A #GList link
7360 int link_index(GLib2.List* link_) {
7361 return g_queue_link_index(&this, link_);
7364 // Unintrospectable method: peek_head() / g_queue_peek_head()
7365 // Returns the first element of the queue.
7367 // is empty.
7368 // RETURNS: the data of the first element in the queue, or %NULL if the queue
7369 void* peek_head() {
7370 return g_queue_peek_head(&this);
7373 // Unintrospectable method: peek_head_link() / g_queue_peek_head_link()
7374 // Returns the first link in @queue
7375 // RETURNS: the first link in @queue, or %NULL if @queue is empty
7376 GLib2.List* peek_head_link() {
7377 return g_queue_peek_head_link(&this);
7380 // Unintrospectable method: peek_nth() / g_queue_peek_nth()
7381 // Returns the @n'th element of @queue.
7383 // off the end of @queue.
7384 // RETURNS: The data for the @n'th element of @queue, or %NULL if @n is
7385 // <n>: the position of the element.
7386 void* peek_nth(uint n) {
7387 return g_queue_peek_nth(&this, n);
7390 // Unintrospectable method: peek_nth_link() / g_queue_peek_nth_link()
7391 // Returns the link at the given position
7393 // end of the list
7394 // RETURNS: The link at the @n'th position, or %NULL if @n is off the
7395 // <n>: the position of the link
7396 GLib2.List* peek_nth_link(uint n) {
7397 return g_queue_peek_nth_link(&this, n);
7400 // Unintrospectable method: peek_tail() / g_queue_peek_tail()
7401 // Returns the last element of the queue.
7403 // is empty.
7404 // RETURNS: the data of the last element in the queue, or %NULL if the queue
7405 void* peek_tail() {
7406 return g_queue_peek_tail(&this);
7409 // Unintrospectable method: peek_tail_link() / g_queue_peek_tail_link()
7410 // Returns the last link @queue.
7411 // RETURNS: the last link in @queue, or %NULL if @queue is empty
7412 GLib2.List* peek_tail_link() {
7413 return g_queue_peek_tail_link(&this);
7416 // Unintrospectable method: pop_head() / g_queue_pop_head()
7417 // Removes the first element of the queue.
7419 // is empty.
7420 // RETURNS: the data of the first element in the queue, or %NULL if the queue
7421 void* pop_head() {
7422 return g_queue_pop_head(&this);
7425 // Unintrospectable method: pop_head_link() / g_queue_pop_head_link()
7426 // Removes the first element of the queue.
7428 // is empty.
7429 // RETURNS: the #GList element at the head of the queue, or %NULL if the queue
7430 GLib2.List* pop_head_link() {
7431 return g_queue_pop_head_link(&this);
7434 // Unintrospectable method: pop_nth() / g_queue_pop_nth()
7435 // Removes the @n'th element of @queue.
7436 // RETURNS: the element's data, or %NULL if @n is off the end of @queue.
7437 // <n>: the position of the element.
7438 void* pop_nth(uint n) {
7439 return g_queue_pop_nth(&this, n);
7442 // Unintrospectable method: pop_nth_link() / g_queue_pop_nth_link()
7443 // Removes and returns the link at the given position.
7444 // RETURNS: The @n'th link, or %NULL if @n is off the end of @queue.
7445 // <n>: the link's position
7446 GLib2.List* pop_nth_link(uint n) {
7447 return g_queue_pop_nth_link(&this, n);
7450 // Unintrospectable method: pop_tail() / g_queue_pop_tail()
7451 // Removes the last element of the queue.
7453 // is empty.
7454 // RETURNS: the data of the last element in the queue, or %NULL if the queue
7455 void* pop_tail() {
7456 return g_queue_pop_tail(&this);
7459 // Unintrospectable method: pop_tail_link() / g_queue_pop_tail_link()
7460 // Removes the last element of the queue.
7462 // is empty.
7463 // RETURNS: the #GList element at the tail of the queue, or %NULL if the queue
7464 GLib2.List* pop_tail_link() {
7465 return g_queue_pop_tail_link(&this);
7468 // Adds a new element at the head of the queue.
7469 // <data>: the data for the new element.
7470 void push_head(void* data) {
7471 g_queue_push_head(&this, data);
7474 // Unintrospectable method: push_head_link() / g_queue_push_head_link()
7475 // Adds a new element at the head of the queue.
7476 // <link_>: a single #GList element, <emphasis>not</emphasis> a list with more than one element.
7477 void push_head_link(GLib2.List* link_) {
7478 g_queue_push_head_link(&this, link_);
7481 // Inserts a new element into @queue at the given position
7482 // <data>: the data for the new element
7483 // <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.
7484 void push_nth(void* data, int n) {
7485 g_queue_push_nth(&this, data, n);
7488 // Unintrospectable method: push_nth_link() / g_queue_push_nth_link()
7489 // Inserts @link into @queue at the given position.
7490 // <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.
7491 // <link_>: the link to add to @queue
7492 void push_nth_link(int n, GLib2.List* link_) {
7493 g_queue_push_nth_link(&this, n, link_);
7496 // Adds a new element at the tail of the queue.
7497 // <data>: the data for the new element.
7498 void push_tail(void* data) {
7499 g_queue_push_tail(&this, data);
7502 // Unintrospectable method: push_tail_link() / g_queue_push_tail_link()
7503 // Adds a new element at the tail of the queue.
7504 // <link_>: a single #GList element, <emphasis>not</emphasis> a list with more than one element.
7505 void push_tail_link(GLib2.List* link_) {
7506 g_queue_push_tail_link(&this, link_);
7509 // Removes the first element in @queue that contains @data.
7510 // RETURNS: %TRUE if @data was found and removed from @queue
7511 // <data>: data to remove.
7512 int remove(const(void)* data) {
7513 return g_queue_remove(&this, data);
7516 // Remove all elements whose data equals @data from @queue.
7517 // RETURNS: the number of elements removed from @queue
7518 // <data>: data to remove
7519 uint remove_all(const(void)* data) {
7520 return g_queue_remove_all(&this, data);
7522 // Reverses the order of the items in @queue.
7523 void reverse() {
7524 g_queue_reverse(&this);
7527 // Unintrospectable method: sort() / g_queue_sort()
7528 // Sorts @queue using @compare_func.
7529 // <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.
7530 // <user_data>: user data passed to @compare_func
7531 void sort(CompareDataFunc compare_func, void* user_data) {
7532 g_queue_sort(&this, compare_func, user_data);
7535 // Unintrospectable method: unlink() / g_queue_unlink()
7536 // Unlinks @link_ so that it will no longer be part of @queue. The link is
7537 // not freed.
7539 // @link_ must be part of @queue,
7540 // <link_>: a #GList link that <emphasis>must</emphasis> be part of @queue
7541 void unlink(GLib2.List* link_) {
7542 g_queue_unlink(&this, link_);
7545 // Unintrospectable function: new() / g_queue_new()
7546 // Creates a new #GQueue.
7547 // RETURNS: a new #GQueue.
7548 static Queue* new_() {
7549 return g_queue_new();
7554 // The #GRand struct is an opaque data structure. It should only be
7555 // accessed through the <function>g_rand_*</function> functions.
7556 struct Rand {
7558 // Unintrospectable method: copy() / g_rand_copy()
7559 // Copies a #GRand into a new one with the same exact state as before.
7560 // This way you can take a snapshot of the random number generator for
7561 // replaying later.
7562 // RETURNS: the new #GRand.
7563 Rand* copy() {
7564 return g_rand_copy(&this);
7567 // Returns the next random #gdouble from @rand_ equally distributed over
7568 // the range [0..1).
7569 // RETURNS: A random number.
7570 double double_() {
7571 return g_rand_double(&this);
7574 // Returns the next random #gdouble from @rand_ equally distributed over
7575 // the range [@begin..@end).
7576 // RETURNS: A random number.
7577 // <begin>: lower closed bound of the interval.
7578 // <end>: upper open bound of the interval.
7579 double double_range(double begin, double end) {
7580 return g_rand_double_range(&this, begin, end);
7582 // Frees the memory allocated for the #GRand.
7583 void free() {
7584 g_rand_free(&this);
7587 // Returns the next random #guint32 from @rand_ equally distributed over
7588 // the range [0..2^32-1].
7589 // RETURNS: A random number.
7590 uint int_() {
7591 return g_rand_int(&this);
7594 // Returns the next random #gint32 from @rand_ equally distributed over
7595 // the range [@begin..@end-1].
7596 // RETURNS: A random number.
7597 // <begin>: lower closed bound of the interval.
7598 // <end>: upper open bound of the interval.
7599 int int_range(int begin, int end) {
7600 return g_rand_int_range(&this, begin, end);
7603 // Sets the seed for the random number generator #GRand to @seed.
7604 // <seed>: a value to reinitialize the random number generator.
7605 void set_seed(uint seed) {
7606 g_rand_set_seed(&this, seed);
7609 // Initializes the random number generator by an array of
7610 // longs. Array can be of arbitrary size, though only the
7611 // first 624 values are taken. This function is useful
7612 // if you have many low entropy seeds, or if you require more then
7613 // 32bits of actual entropy for your application.
7614 // <seed>: array to initialize with
7615 // <seed_length>: length of array
7616 void set_seed_array(uint* seed, uint seed_length) {
7617 g_rand_set_seed_array(&this, seed, seed_length);
7620 // Unintrospectable function: new() / g_rand_new()
7621 // Creates a new random number generator initialized with a seed taken
7622 // either from <filename>/dev/urandom</filename> (if existing) or from
7623 // the current time (as a fallback).
7624 // RETURNS: the new #GRand.
7625 static Rand* new_() {
7626 return g_rand_new();
7629 // Unintrospectable function: new_with_seed() / g_rand_new_with_seed()
7630 // Creates a new random number generator initialized with @seed.
7631 // RETURNS: the new #GRand.
7632 // <seed>: a value to initialize the random number generator.
7633 static Rand* new_with_seed(uint seed) {
7634 return g_rand_new_with_seed(seed);
7637 // Unintrospectable function: new_with_seed_array() / g_rand_new_with_seed_array()
7638 // Creates a new random number generator initialized with @seed.
7639 // RETURNS: the new #GRand.
7640 // <seed>: an array of seeds to initialize the random number generator.
7641 // <seed_length>: an array of seeds to initialize the random number generator.
7642 static Rand* new_with_seed_array(uint* seed, uint seed_length) {
7643 return g_rand_new_with_seed_array(seed, seed_length);
7648 // The <function>g_regex_*()</function> functions implement regular
7649 // expression pattern matching using syntax and semantics similar to
7650 // Perl regular expression.
7652 // Some functions accept a @start_position argument, setting it differs
7653 // from just passing over a shortened string and setting #G_REGEX_MATCH_NOTBOL
7654 // in the case of a pattern that begins with any kind of lookbehind assertion.
7655 // For example, consider the pattern "\Biss\B" which finds occurrences of "iss"
7656 // in the middle of words. ("\B" matches only if the current position in the
7657 // subject is not a word boundary.) When applied to the string "Mississipi"
7658 // from the fourth byte, namely "issipi", it does not match, because "\B" is
7659 // always false at the start of the subject, which is deemed to be a word
7660 // boundary. However, if the entire string is passed , but with
7661 // @start_position set to 4, it finds the second occurrence of "iss" because
7662 // it is able to look behind the starting point to discover that it is
7663 // preceded by a letter.
7665 // Note that, unless you set the #G_REGEX_RAW flag, all the strings passed
7666 // to these functions must be encoded in UTF-8. The lengths and the positions
7667 // inside the strings are in bytes and not in characters, so, for instance,
7668 // "\xc3\xa0" (i.e. "&agrave;") is two bytes long but it is treated as a
7669 // single character. If you set #G_REGEX_RAW the strings can be non-valid
7670 // UTF-8 strings and a byte is treated as a character, so "\xc3\xa0" is two
7671 // bytes and two characters long.
7673 // When matching a pattern, "\n" matches only against a "\n" character in
7674 // the string, and "\r" matches only a "\r" character. To match any newline
7675 // sequence use "\R". This particular group matches either the two-character
7676 // sequence CR + LF ("\r\n"), or one of the single characters LF (linefeed,
7677 // U+000A, "\n"), VT vertical tab, U+000B, "\v"), FF (formfeed, U+000C, "\f"),
7678 // CR (carriage return, U+000D, "\r"), NEL (next line, U+0085), LS (line
7679 // separator, U+2028), or PS (paragraph separator, U+2029).
7681 // The behaviour of the dot, circumflex, and dollar metacharacters are
7682 // affected by newline characters, the default is to recognize any newline
7683 // character (the same characters recognized by "\R"). This can be changed
7684 // with #G_REGEX_NEWLINE_CR, #G_REGEX_NEWLINE_LF and #G_REGEX_NEWLINE_CRLF
7685 // compile options, and with #G_REGEX_MATCH_NEWLINE_ANY,
7686 // #G_REGEX_MATCH_NEWLINE_CR, #G_REGEX_MATCH_NEWLINE_LF and
7687 // #G_REGEX_MATCH_NEWLINE_CRLF match options. These settings are also
7688 // relevant when compiling a pattern if #G_REGEX_EXTENDED is set, and an
7689 // unescaped "#" outside a character class is encountered. This indicates
7690 // a comment that lasts until after the next newline.
7692 // Creating and manipulating the same #GRegex structure from different
7693 // threads is not a problem as #GRegex does not modify its internal
7694 // state between creation and destruction, on the other hand #GMatchInfo
7695 // is not threadsafe.
7697 // The regular expressions low-level functionalities are obtained through
7698 // the excellent <ulink url="http://www.pcre.org/">PCRE</ulink> library
7699 // written by Philip Hazel.
7700 struct Regex /* Version 2.14 */ {
7702 // Compiles the regular expression to an internal form, and does
7703 // the initial setup of the #GRegex structure.
7705 // are done with it
7706 // RETURNS: a #GRegex structure. Call g_regex_unref() when you
7707 // <pattern>: the regular expression
7708 // <compile_options>: compile options for the regular expression, or 0
7709 // <match_options>: match options for the regular expression, or 0
7710 static Regex* /*new*/ new_(char* pattern, RegexCompileFlags compile_options, RegexMatchFlags match_options, GLib2.Error** error=null) {
7711 return g_regex_new(pattern, compile_options, match_options, error);
7714 // Returns the number of capturing subpatterns in the pattern.
7715 // RETURNS: the number of capturing subpatterns
7716 int get_capture_count() {
7717 return g_regex_get_capture_count(&this);
7720 // Returns the compile options that @regex was created with.
7721 // RETURNS: flags from #GRegexCompileFlags
7722 RegexCompileFlags get_compile_flags() {
7723 return g_regex_get_compile_flags(&this);
7726 // Returns the match options that @regex was created with.
7727 // RETURNS: flags from #GRegexMatchFlags
7728 RegexMatchFlags get_match_flags() {
7729 return g_regex_get_match_flags(&this);
7732 // Returns the number of the highest back reference
7733 // in the pattern, or 0 if the pattern does not contain
7734 // back references.
7735 // RETURNS: the number of the highest back reference
7736 int get_max_backref() {
7737 return g_regex_get_max_backref(&this);
7740 // Gets the pattern string associated with @regex, i.e. a copy of
7741 // the string passed to g_regex_new().
7742 // RETURNS: the pattern of @regex
7743 char* get_pattern() {
7744 return g_regex_get_pattern(&this);
7747 // Retrieves the number of the subexpression named @name.
7749 // does not exists
7750 // RETURNS: The number of the subexpression or -1 if @name
7751 // <name>: name of the subexpression
7752 int get_string_number(char* name) {
7753 return g_regex_get_string_number(&this, name);
7756 // Scans for a match in string for the pattern in @regex.
7757 // The @match_options are combined with the match options specified
7758 // when the @regex structure was created, letting you have more
7759 // flexibility in reusing #GRegex structures.
7761 // A #GMatchInfo structure, used to get information on the match,
7762 // is stored in @match_info if not %NULL. Note that if @match_info
7763 // is not %NULL then it is created even if the function returns %FALSE,
7764 // i.e. you must free it regardless if regular expression actually matched.
7766 // To retrieve all the non-overlapping matches of the pattern in
7767 // string you can use g_match_info_next().
7769 // |[
7770 // static void
7771 // print_uppercase_words (const gchar *string)
7772 // {
7773 // /&ast; Print all uppercase-only words. &ast;/
7774 // GRegex *regex;
7775 // GMatchInfo *match_info;
7776 // &nbsp;
7777 // regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
7778 // g_regex_match (regex, string, 0, &amp;match_info);
7779 // while (g_match_info_matches (match_info))
7780 // {
7781 // gchar *word = g_match_info_fetch (match_info, 0);
7782 // g_print ("Found: %s\n", word);
7783 // g_free (word);
7784 // g_match_info_next (match_info, NULL);
7785 // }
7786 // g_match_info_free (match_info);
7787 // g_regex_unref (regex);
7788 // }
7789 // ]|
7791 // @string is not copied and is used in #GMatchInfo internally. If
7792 // you use any #GMatchInfo method (except g_match_info_free()) after
7793 // freeing or modifying @string then the behaviour is undefined.
7794 // RETURNS: %TRUE is the string matched, %FALSE otherwise
7795 // <string>: the string to scan for matches
7796 // <match_options>: match options
7797 // <match_info>: pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
7798 int match(char* string_, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info=null) {
7799 return g_regex_match(&this, string_, match_options, match_info);
7802 // Using the standard algorithm for regular expression matching only
7803 // the longest match in the string is retrieved. This function uses
7804 // a different algorithm so it can retrieve all the possible matches.
7805 // For more documentation see g_regex_match_all_full().
7807 // A #GMatchInfo structure, used to get information on the match, is
7808 // stored in @match_info if not %NULL. Note that if @match_info is
7809 // not %NULL then it is created even if the function returns %FALSE,
7810 // i.e. you must free it regardless if regular expression actually
7811 // matched.
7813 // @string is not copied and is used in #GMatchInfo internally. If
7814 // you use any #GMatchInfo method (except g_match_info_free()) after
7815 // freeing or modifying @string then the behaviour is undefined.
7816 // RETURNS: %TRUE is the string matched, %FALSE otherwise
7817 // <string>: the string to scan for matches
7818 // <match_options>: match options
7819 // <match_info>: pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
7820 int match_all(char* string_, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info=null) {
7821 return g_regex_match_all(&this, string_, match_options, match_info);
7824 // Using the standard algorithm for regular expression matching only
7825 // the longest match in the string is retrieved, it is not possible
7826 // to obtain all the available matches. For instance matching
7827 // "&lt;a&gt; &lt;b&gt; &lt;c&gt;" against the pattern "&lt;.*&gt;"
7828 // you get "&lt;a&gt; &lt;b&gt; &lt;c&gt;".
7830 // This function uses a different algorithm (called DFA, i.e. deterministic
7831 // finite automaton), so it can retrieve all the possible matches, all
7832 // starting at the same point in the string. For instance matching
7833 // "&lt;a&gt; &lt;b&gt; &lt;c&gt;" against the pattern "&lt;.*&gt;"
7834 // you would obtain three matches: "&lt;a&gt; &lt;b&gt; &lt;c&gt;",
7835 // "&lt;a&gt; &lt;b&gt;" and "&lt;a&gt;".
7837 // The number of matched strings is retrieved using
7838 // g_match_info_get_match_count(). To obtain the matched strings and
7839 // their position you can use, respectively, g_match_info_fetch() and
7840 // g_match_info_fetch_pos(). Note that the strings are returned in
7841 // reverse order of length; that is, the longest matching string is
7842 // given first.
7844 // Note that the DFA algorithm is slower than the standard one and it
7845 // is not able to capture substrings, so backreferences do not work.
7847 // Setting @start_position differs from just passing over a shortened
7848 // string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
7849 // that begins with any kind of lookbehind assertion, such as "\b".
7851 // A #GMatchInfo structure, used to get information on the match, is
7852 // stored in @match_info if not %NULL. Note that if @match_info is
7853 // not %NULL then it is created even if the function returns %FALSE,
7854 // i.e. you must free it regardless if regular expression actually
7855 // matched.
7857 // @string is not copied and is used in #GMatchInfo internally. If
7858 // you use any #GMatchInfo method (except g_match_info_free()) after
7859 // freeing or modifying @string then the behaviour is undefined.
7860 // RETURNS: %TRUE is the string matched, %FALSE otherwise
7861 // <string>: the string to scan for matches
7862 // <string_len>: the length of @string, or -1 if @string is nul-terminated
7863 // <start_position>: starting index of the string to match
7864 // <match_options>: match options
7865 // <match_info>: pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
7866 int match_all_full(char* string_, ssize_t string_len, int start_position, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info, GLib2.Error** error=null) {
7867 return g_regex_match_all_full(&this, string_, string_len, start_position, match_options, match_info, error);
7870 // Scans for a match in string for the pattern in @regex.
7871 // The @match_options are combined with the match options specified
7872 // when the @regex structure was created, letting you have more
7873 // flexibility in reusing #GRegex structures.
7875 // Setting @start_position differs from just passing over a shortened
7876 // string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
7877 // that begins with any kind of lookbehind assertion, such as "\b".
7879 // A #GMatchInfo structure, used to get information on the match, is
7880 // stored in @match_info if not %NULL. Note that if @match_info is
7881 // not %NULL then it is created even if the function returns %FALSE,
7882 // i.e. you must free it regardless if regular expression actually
7883 // matched.
7885 // @string is not copied and is used in #GMatchInfo internally. If
7886 // you use any #GMatchInfo method (except g_match_info_free()) after
7887 // freeing or modifying @string then the behaviour is undefined.
7889 // To retrieve all the non-overlapping matches of the pattern in
7890 // string you can use g_match_info_next().
7892 // |[
7893 // static void
7894 // print_uppercase_words (const gchar *string)
7895 // {
7896 // /&ast; Print all uppercase-only words. &ast;/
7897 // GRegex *regex;
7898 // GMatchInfo *match_info;
7899 // GError *error = NULL;
7900 // &nbsp;
7901 // regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
7902 // g_regex_match_full (regex, string, -1, 0, 0, &amp;match_info, &amp;error);
7903 // while (g_match_info_matches (match_info))
7904 // {
7905 // gchar *word = g_match_info_fetch (match_info, 0);
7906 // g_print ("Found: %s\n", word);
7907 // g_free (word);
7908 // g_match_info_next (match_info, &amp;error);
7909 // }
7910 // g_match_info_free (match_info);
7911 // g_regex_unref (regex);
7912 // if (error != NULL)
7913 // {
7914 // g_printerr ("Error while matching: %s\n", error->message);
7915 // g_error_free (error);
7916 // }
7917 // }
7918 // ]|
7919 // RETURNS: %TRUE is the string matched, %FALSE otherwise
7920 // <string>: the string to scan for matches
7921 // <string_len>: the length of @string, or -1 if @string is nul-terminated
7922 // <start_position>: starting index of the string to match
7923 // <match_options>: match options
7924 // <match_info>: pointer to location where to store the #GMatchInfo, or %NULL if you do not need it
7925 int match_full(char* string_, ssize_t string_len, int start_position, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info, GLib2.Error** error=null) {
7926 return g_regex_match_full(&this, string_, string_len, start_position, match_options, match_info, error);
7929 // Increases reference count of @regex by 1.
7930 // RETURNS: @regex
7931 Regex* /*new*/ ref_() {
7932 return g_regex_ref(&this);
7935 // Replaces all occurrences of the pattern in @regex with the
7936 // replacement text. Backreferences of the form '\number' or
7937 // '\g&lt;number&gt;' in the replacement text are interpolated by the
7938 // number-th captured subexpression of the match, '\g&lt;name&gt;' refers
7939 // to the captured subexpression with the given name. '\0' refers to the
7940 // complete match, but '\0' followed by a number is the octal representation
7941 // of a character. To include a literal '\' in the replacement, write '\\'.
7942 // There are also escapes that changes the case of the following text:
7944 // <variablelist>
7945 // <varlistentry><term>\l</term>
7946 // <listitem>
7947 // <para>Convert to lower case the next character</para>
7948 // </listitem>
7949 // </varlistentry>
7950 // <varlistentry><term>\u</term>
7951 // <listitem>
7952 // <para>Convert to upper case the next character</para>
7953 // </listitem>
7954 // </varlistentry>
7955 // <varlistentry><term>\L</term>
7956 // <listitem>
7957 // <para>Convert to lower case till \E</para>
7958 // </listitem>
7959 // </varlistentry>
7960 // <varlistentry><term>\U</term>
7961 // <listitem>
7962 // <para>Convert to upper case till \E</para>
7963 // </listitem>
7964 // </varlistentry>
7965 // <varlistentry><term>\E</term>
7966 // <listitem>
7967 // <para>End case modification</para>
7968 // </listitem>
7969 // </varlistentry>
7970 // </variablelist>
7972 // If you do not need to use backreferences use g_regex_replace_literal().
7974 // The @replacement string must be UTF-8 encoded even if #G_REGEX_RAW was
7975 // passed to g_regex_new(). If you want to use not UTF-8 encoded stings
7976 // you can use g_regex_replace_literal().
7978 // Setting @start_position differs from just passing over a shortened
7979 // string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern that
7980 // begins with any kind of lookbehind assertion, such as "\b".
7981 // RETURNS: a newly allocated string containing the replacements
7982 // <string>: the string to perform matches against
7983 // <string_len>: the length of @string, or -1 if @string is nul-terminated
7984 // <start_position>: starting index of the string to match
7985 // <replacement>: text to replace each match with
7986 // <match_options>: options for the match
7987 char* /*new*/ replace(char* string_, ssize_t string_len, int start_position, char* replacement, RegexMatchFlags match_options, GLib2.Error** error=null) {
7988 return g_regex_replace(&this, string_, string_len, start_position, replacement, match_options, error);
7991 // Unintrospectable method: replace_eval() / g_regex_replace_eval()
7992 // Replaces occurrences of the pattern in regex with the output of
7993 // @eval for that occurrence.
7995 // Setting @start_position differs from just passing over a shortened
7996 // string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
7997 // that begins with any kind of lookbehind assertion, such as "\b".
7999 // The following example uses g_regex_replace_eval() to replace multiple
8000 // strings at once:
8001 // |[
8002 // static gboolean
8003 // eval_cb (const GMatchInfo *info,
8004 // GString *res,
8005 // gpointer data)
8006 // {
8007 // gchar *match;
8008 // gchar *r;
8010 // match = g_match_info_fetch (info, 0);
8011 // r = g_hash_table_lookup ((GHashTable *)data, match);
8012 // g_string_append (res, r);
8013 // g_free (match);
8015 // return FALSE;
8016 // }
8018 // /&ast; ... &ast;/
8020 // GRegex *reg;
8021 // GHashTable *h;
8022 // gchar *res;
8024 // h = g_hash_table_new (g_str_hash, g_str_equal);
8026 // g_hash_table_insert (h, "1", "ONE");
8027 // g_hash_table_insert (h, "2", "TWO");
8028 // g_hash_table_insert (h, "3", "THREE");
8029 // g_hash_table_insert (h, "4", "FOUR");
8031 // reg = g_regex_new ("1|2|3|4", 0, 0, NULL);
8032 // res = g_regex_replace_eval (reg, text, -1, 0, 0, eval_cb, h, NULL);
8033 // g_hash_table_destroy (h);
8035 // /&ast; ... &ast;/
8036 // ]|
8037 // RETURNS: a newly allocated string containing the replacements
8038 // <string>: string to perform matches against
8039 // <string_len>: the length of @string, or -1 if @string is nul-terminated
8040 // <start_position>: starting index of the string to match
8041 // <match_options>: options for the match
8042 // <eval>: a function to call for each match
8043 // <user_data>: user data to pass to the function
8044 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) {
8045 return g_regex_replace_eval(&this, string_, string_len, start_position, match_options, eval, user_data, error);
8048 // Replaces all occurrences of the pattern in @regex with the
8049 // replacement text. @replacement is replaced literally, to
8050 // include backreferences use g_regex_replace().
8052 // Setting @start_position differs from just passing over a
8053 // shortened string and setting #G_REGEX_MATCH_NOTBOL in the
8054 // case of a pattern that begins with any kind of lookbehind
8055 // assertion, such as "\b".
8056 // RETURNS: a newly allocated string containing the replacements
8057 // <string>: the string to perform matches against
8058 // <string_len>: the length of @string, or -1 if @string is nul-terminated
8059 // <start_position>: starting index of the string to match
8060 // <replacement>: text to replace each match with
8061 // <match_options>: options for the match
8062 char* /*new*/ replace_literal(char* string_, ssize_t string_len, int start_position, char* replacement, RegexMatchFlags match_options, GLib2.Error** error=null) {
8063 return g_regex_replace_literal(&this, string_, string_len, start_position, replacement, match_options, error);
8066 // Unintrospectable method: split() / g_regex_split()
8067 // Breaks the string on the pattern, and returns an array of the tokens.
8068 // If the pattern contains capturing parentheses, then the text for each
8069 // of the substrings will also be returned. If the pattern does not match
8070 // anywhere in the string, then the whole string is returned as the first
8071 // token.
8073 // As a special case, the result of splitting the empty string "" is an
8074 // empty vector, not a vector containing a single string. The reason for
8075 // this special case is that being able to represent a empty vector is
8076 // typically more useful than consistent handling of empty elements. If
8077 // you do need to represent empty elements, you'll need to check for the
8078 // empty string before calling this function.
8080 // A pattern that can match empty strings splits @string into separate
8081 // characters wherever it matches the empty string between characters.
8082 // For example splitting "ab c" using as a separator "\s*", you will get
8083 // "a", "b" and "c".
8084 // RETURNS: a %NULL-terminated gchar ** array. Free it using g_strfreev()
8085 // <string>: the string to split with the pattern
8086 // <match_options>: match time option flags
8087 char** split(char* string_, RegexMatchFlags match_options) {
8088 return g_regex_split(&this, string_, match_options);
8091 // Unintrospectable method: split_full() / g_regex_split_full()
8092 // Breaks the string on the pattern, and returns an array of the tokens.
8093 // If the pattern contains capturing parentheses, then the text for each
8094 // of the substrings will also be returned. If the pattern does not match
8095 // anywhere in the string, then the whole string is returned as the first
8096 // token.
8098 // As a special case, the result of splitting the empty string "" is an
8099 // empty vector, not a vector containing a single string. The reason for
8100 // this special case is that being able to represent a empty vector is
8101 // typically more useful than consistent handling of empty elements. If
8102 // you do need to represent empty elements, you'll need to check for the
8103 // empty string before calling this function.
8105 // A pattern that can match empty strings splits @string into separate
8106 // characters wherever it matches the empty string between characters.
8107 // For example splitting "ab c" using as a separator "\s*", you will get
8108 // "a", "b" and "c".
8110 // Setting @start_position differs from just passing over a shortened
8111 // string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern
8112 // that begins with any kind of lookbehind assertion, such as "\b".
8113 // RETURNS: a %NULL-terminated gchar ** array. Free it using g_strfreev()
8114 // <string>: the string to split with the pattern
8115 // <string_len>: the length of @string, or -1 if @string is nul-terminated
8116 // <start_position>: starting index of the string to match
8117 // <match_options>: match time option flags
8118 // <max_tokens>: the maximum number of tokens to split @string into. If this is less than 1, the string is split completely
8119 char** split_full(char* string_, ssize_t string_len, int start_position, RegexMatchFlags match_options, int max_tokens, GLib2.Error** error=null) {
8120 return g_regex_split_full(&this, string_, string_len, start_position, match_options, max_tokens, error);
8123 // Decreases reference count of @regex by 1. When reference count drops
8124 // to zero, it frees all the memory associated with the regex structure.
8125 void unref() {
8126 g_regex_unref(&this);
8129 // Checks whether @replacement is a valid replacement string
8130 // (see g_regex_replace()), i.e. that all escape sequences in
8131 // it are valid.
8133 // If @has_references is not %NULL then @replacement is checked
8134 // for pattern references. For instance, replacement text 'foo\n'
8135 // does not contain references and may be evaluated without information
8136 // about actual match, but '\0\1' (whole match followed by first
8137 // subpattern) requires valid #GMatchInfo object.
8138 // RETURNS: whether @replacement is a valid replacement string
8139 // <replacement>: the replacement string
8140 // <has_references>: location to store information about references in @replacement or %NULL
8141 static int check_replacement(char* replacement, /*out*/ int* has_references, GLib2.Error** error=null) {
8142 return g_regex_check_replacement(replacement, has_references, error);
8144 static Quark error_quark() {
8145 return g_regex_error_quark();
8148 // Escapes the nul characters in @string to "\x00". It can be used
8149 // to compile a regex with embedded nul characters.
8151 // For completeness, @length can be -1 for a nul-terminated string.
8152 // In this case the output string will be of course equal to @string.
8153 // RETURNS: a newly-allocated escaped string
8154 // <string>: the string to escape
8155 // <length>: the length of @string
8156 static char* /*new*/ escape_nul(char* string_, int length) {
8157 return g_regex_escape_nul(string_, length);
8160 // Escapes the special characters used for regular expressions
8161 // in @string, for instance "a.b*c" becomes "a\.b\*c". This
8162 // function is useful to dynamically generate regular expressions.
8164 // @string can contain nul characters that are replaced with "\0",
8165 // in this case remember to specify the correct length of @string
8166 // in @length.
8167 // RETURNS: a newly-allocated escaped string
8168 // <string>: the string to escape
8169 // <length>: the length of @string, or -1 if @string is nul-terminated
8170 static char* /*new*/ escape_string(char* string_, int length) {
8171 return g_regex_escape_string(string_, length);
8174 // Scans for a match in @string for @pattern.
8176 // This function is equivalent to g_regex_match() but it does not
8177 // require to compile the pattern with g_regex_new(), avoiding some
8178 // lines of code when you need just to do a match without extracting
8179 // substrings, capture counts, and so on.
8181 // If this function is to be called on the same @pattern more than
8182 // once, it's more efficient to compile the pattern once with
8183 // g_regex_new() and then use g_regex_match().
8184 // RETURNS: %TRUE if the string matched, %FALSE otherwise
8185 // <pattern>: the regular expression
8186 // <string>: the string to scan for matches
8187 // <compile_options>: compile options for the regular expression, or 0
8188 // <match_options>: match options, or 0
8189 static int match_simple(char* pattern, char* string_, RegexCompileFlags compile_options, RegexMatchFlags match_options) {
8190 return g_regex_match_simple(pattern, string_, compile_options, match_options);
8193 // Unintrospectable function: split_simple() / g_regex_split_simple()
8194 // Breaks the string on the pattern, and returns an array of
8195 // the tokens. If the pattern contains capturing parentheses,
8196 // then the text for each of the substrings will also be returned.
8197 // If the pattern does not match anywhere in the string, then the
8198 // whole string is returned as the first token.
8200 // This function is equivalent to g_regex_split() but it does
8201 // not require to compile the pattern with g_regex_new(), avoiding
8202 // some lines of code when you need just to do a split without
8203 // extracting substrings, capture counts, and so on.
8205 // If this function is to be called on the same @pattern more than
8206 // once, it's more efficient to compile the pattern once with
8207 // g_regex_new() and then use g_regex_split().
8209 // As a special case, the result of splitting the empty string ""
8210 // is an empty vector, not a vector containing a single string.
8211 // The reason for this special case is that being able to represent
8212 // a empty vector is typically more useful than consistent handling
8213 // of empty elements. If you do need to represent empty elements,
8214 // you'll need to check for the empty string before calling this
8215 // function.
8217 // A pattern that can match empty strings splits @string into
8218 // separate characters wherever it matches the empty string between
8219 // characters. For example splitting "ab c" using as a separator
8220 // "\s*", you will get "a", "b" and "c".
8221 // RETURNS: a %NULL-terminated array of strings. Free it using g_strfreev()
8222 // <pattern>: the regular expression
8223 // <string>: the string to scan for matches
8224 // <compile_options>: compile options for the regular expression, or 0
8225 // <match_options>: match options, or 0
8226 static char** split_simple(char* pattern, char* string_, RegexCompileFlags compile_options, RegexMatchFlags match_options) {
8227 return g_regex_split_simple(pattern, string_, compile_options, match_options);
8231 // Flags specifying compile-time options.
8232 enum RegexCompileFlags /* Version 2.14 */ {
8233 CASELESS = 1,
8234 MULTILINE = 2,
8235 DOTALL = 4,
8236 EXTENDED = 8,
8237 ANCHORED = 16,
8238 DOLLAR_ENDONLY = 32,
8239 UNGREEDY = 512,
8240 RAW = 2048,
8241 NO_AUTO_CAPTURE = 4096,
8242 OPTIMIZE = 8192,
8243 DUPNAMES = 524288,
8244 NEWLINE_CR = 1048576,
8245 NEWLINE_LF = 2097152,
8246 NEWLINE_CRLF = 3145728
8248 // Error codes returned by regular expressions functions.
8249 enum RegexError /* Version 2.14 */ {
8250 COMPILE = 0,
8251 OPTIMIZE = 1,
8252 REPLACE = 2,
8253 MATCH = 3,
8254 INTERNAL = 4,
8255 STRAY_BACKSLASH = 101,
8256 MISSING_CONTROL_CHAR = 102,
8257 UNRECOGNIZED_ESCAPE = 103,
8258 QUANTIFIERS_OUT_OF_ORDER = 104,
8259 QUANTIFIER_TOO_BIG = 105,
8260 UNTERMINATED_CHARACTER_CLASS = 106,
8261 INVALID_ESCAPE_IN_CHARACTER_CLASS = 107,
8262 RANGE_OUT_OF_ORDER = 108,
8263 NOTHING_TO_REPEAT = 109,
8264 UNRECOGNIZED_CHARACTER = 112,
8265 POSIX_NAMED_CLASS_OUTSIDE_CLASS = 113,
8266 UNMATCHED_PARENTHESIS = 114,
8267 INEXISTENT_SUBPATTERN_REFERENCE = 115,
8268 UNTERMINATED_COMMENT = 118,
8269 EXPRESSION_TOO_LARGE = 120,
8270 MEMORY_ERROR = 121,
8271 VARIABLE_LENGTH_LOOKBEHIND = 125,
8272 MALFORMED_CONDITION = 126,
8273 TOO_MANY_CONDITIONAL_BRANCHES = 127,
8274 ASSERTION_EXPECTED = 128,
8275 UNKNOWN_POSIX_CLASS_NAME = 130,
8276 POSIX_COLLATING_ELEMENTS_NOT_SUPPORTED = 131,
8277 HEX_CODE_TOO_LARGE = 134,
8278 INVALID_CONDITION = 135,
8279 SINGLE_BYTE_MATCH_IN_LOOKBEHIND = 136,
8280 INFINITE_LOOP = 140,
8281 MISSING_SUBPATTERN_NAME_TERMINATOR = 142,
8282 DUPLICATE_SUBPATTERN_NAME = 143,
8283 MALFORMED_PROPERTY = 146,
8284 UNKNOWN_PROPERTY = 147,
8285 SUBPATTERN_NAME_TOO_LONG = 148,
8286 TOO_MANY_SUBPATTERNS = 149,
8287 INVALID_OCTAL_VALUE = 151,
8288 TOO_MANY_BRANCHES_IN_DEFINE = 154,
8289 DEFINE_REPETION = 155,
8290 INCONSISTENT_NEWLINE_OPTIONS = 156,
8291 MISSING_BACK_REFERENCE = 157
8294 // Specifies the type of the function passed to g_regex_replace_eval().
8295 // It is called for each occurrence of the pattern in the string passed
8296 // to g_regex_replace_eval(), and it should append the replacement to
8297 // @result.
8298 // RETURNS: %FALSE to continue the replacement process, %TRUE to stop it
8299 // <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.
8300 // <result>: a #GString containing the new string
8301 // <user_data>: user data passed to g_regex_replace_eval()
8302 extern (C) alias int function (MatchInfo* match_info, String* result, void* user_data) RegexEvalCallback;
8304 // Flags specifying match-time options.
8305 enum RegexMatchFlags /* Version 2.14 */ {
8306 ANCHORED = 16,
8307 NOTBOL = 128,
8308 NOTEOL = 256,
8309 NOTEMPTY = 1024,
8310 PARTIAL = 32768,
8311 NEWLINE_CR = 1048576,
8312 NEWLINE_LF = 2097152,
8313 NEWLINE_CRLF = 3145728,
8314 NEWLINE_ANY = 4194304
8317 // The #GRelation struct is an opaque data structure to represent a
8318 // <link linkend="glib-Relations-and-Tuples">Relation</link>. It should
8319 // only be accessed via the following functions.
8320 struct Relation {
8322 // Returns the number of tuples in a #GRelation that have the given
8323 // value in the given field.
8324 // <key>: the value to compare with.
8325 // <field>: the field of each record to match.
8326 int count(const(void)* key, int field) {
8327 return g_relation_count(&this, key, field);
8330 // Deletes any records from a #GRelation that have the given key value
8331 // in the given field.
8332 // <key>: the value to compare with.
8333 // <field>: the field of each record to match.
8334 int delete_(const(void)* key, int field) {
8335 return g_relation_delete(&this, key, field);
8338 // Destroys the #GRelation, freeing all memory allocated. However, it
8339 // does not free memory allocated for the tuple data, so you should
8340 // free that first if appropriate.
8341 void destroy() {
8342 g_relation_destroy(&this);
8345 // Unintrospectable method: exists() / g_relation_exists()
8346 // Returns %TRUE if a record with the given values exists in a
8347 // #GRelation. Note that the values are compared directly, so that, for
8348 // example, two copies of the same string will not match.
8349 /+ Not available -- variadic methods unsupported - use the C function directly.
8350 alias g_relation_exists exists; // Variadic
8353 // Unintrospectable method: index() / g_relation_index()
8354 // Creates an index on the given field. Note that this must be called
8355 // before any records are added to the #GRelation.
8356 // <field>: the field to index, counting from 0.
8357 // <hash_func>: a function to produce a hash value from the field data.
8358 // <key_equal_func>: a function to compare two values of the given field.
8359 void index(int field, HashFunc hash_func, EqualFunc key_equal_func) {
8360 g_relation_index(&this, field, hash_func, key_equal_func);
8363 // Unintrospectable method: insert() / g_relation_insert()
8364 // Inserts a record into a #GRelation.
8365 /+ Not available -- variadic methods unsupported - use the C function directly.
8366 alias g_relation_insert insert; // Variadic
8369 // Outputs information about all records in a #GRelation, as well as
8370 // the indexes. It is for debugging.
8371 void print() {
8372 g_relation_print(&this);
8375 // Unintrospectable method: select() / g_relation_select()
8376 // Returns all of the tuples which have the given key in the given
8377 // field. Use g_tuples_index() to access the returned records. The
8378 // returned records should be freed with g_tuples_destroy().
8379 // <key>: the value to compare with.
8380 // <field>: the field of each record to match.
8381 Tuples* select(const(void)* key, int field) {
8382 return g_relation_select(&this, key, field);
8385 // Unintrospectable function: new() / g_relation_new()
8386 // Creates a new #GRelation with the given number of fields. Note that
8387 // currently the number of fields must be 2.
8388 // <fields>: the number of fields.
8389 static Relation* new_(int fields) {
8390 return g_relation_new(fields);
8394 enum int SEARCHPATH_SEPARATOR = 59;
8395 enum SEARCHPATH_SEPARATOR_S = ";";
8396 enum int SIZEOF_LONG = 4;
8397 enum int SIZEOF_SIZE_T = 4;
8398 enum int SIZEOF_VOID_P = 4;
8400 // The #GSList struct is used for each element in the singly-linked
8401 // list.
8402 struct SList {
8403 void* data;
8404 GLib2.SList* next;
8407 // Unintrospectable function: alloc() / g_slist_alloc()
8408 // Allocates space for one #GSList element. It is called by the
8409 // g_slist_append(), g_slist_prepend(), g_slist_insert() and
8410 // g_slist_insert_sorted() functions and so is rarely used on its own.
8411 static GLib2.SList* alloc() {
8412 return g_slist_alloc();
8415 // Unintrospectable function: append() / g_slist_append()
8416 // Adds a new element on to the end of the list.
8418 // <note><para>
8419 // The return value is the new start of the list, which may
8420 // have changed, so make sure you store the new value.
8421 // </para></note>
8423 // <note><para>
8424 // Note that g_slist_append() has to traverse the entire list
8425 // to find the end, which is inefficient when adding multiple
8426 // elements. A common idiom to avoid the inefficiency is to prepend
8427 // the elements and reverse the list when all elements have been added.
8428 // </para></note>
8430 // |[
8431 // /&ast; Notice that these are initialized to the empty list. &ast;/
8432 // GSList *list = NULL, *number_list = NULL;
8434 // /&ast; This is a list of strings. &ast;/
8435 // list = g_slist_append (list, "first");
8436 // list = g_slist_append (list, "second");
8438 // /&ast; This is a list of integers. &ast;/
8439 // number_list = g_slist_append (number_list, GINT_TO_POINTER (27));
8440 // number_list = g_slist_append (number_list, GINT_TO_POINTER (14));
8441 // ]|
8442 // RETURNS: the new start of the #GSList
8443 // <list>: a #GSList
8444 // <data>: the data for the new element
8445 static GLib2.SList* append(GLib2.SList* list, void* data) {
8446 return g_slist_append(list, data);
8449 // Unintrospectable function: concat() / g_slist_concat()
8450 // Adds the second #GSList onto the end of the first #GSList.
8451 // Note that the elements of the second #GSList are not copied.
8452 // They are used directly.
8453 // RETURNS: the start of the new #GSList
8454 // <list1>: a #GSList
8455 // <list2>: the #GSList to add to the end of the first #GSList
8456 static GLib2.SList* concat(GLib2.SList* list1, GLib2.SList* list2) {
8457 return g_slist_concat(list1, list2);
8460 // Unintrospectable function: copy() / g_slist_copy()
8461 // Copies a #GSList.
8463 // <note><para>
8464 // Note that this is a "shallow" copy. If the list elements
8465 // consist of pointers to data, the pointers are copied but
8466 // the actual data isn't.
8467 // </para></note>
8468 // RETURNS: a copy of @list
8469 // <list>: a #GSList
8470 static GLib2.SList* copy(GLib2.SList* list) {
8471 return g_slist_copy(list);
8474 // Unintrospectable function: delete_link() / g_slist_delete_link()
8475 // Removes the node link_ from the list and frees it.
8476 // Compare this to g_slist_remove_link() which removes the node
8477 // without freeing it.
8478 // RETURNS: the new head of @list
8479 // <list>: a #GSList
8480 // <link_>: node to delete
8481 static GLib2.SList* delete_link(GLib2.SList* list, GLib2.SList* link_) {
8482 return g_slist_delete_link(list, link_);
8485 // Unintrospectable function: find() / g_slist_find()
8486 // Finds the element in a #GSList which
8487 // contains the given data.
8489 // or %NULL if it is not found
8490 // RETURNS: the found #GSList element,
8491 // <list>: a #GSList
8492 // <data>: the element data to find
8493 static GLib2.SList* find(GLib2.SList* list, const(void)* data) {
8494 return g_slist_find(list, data);
8497 // Unintrospectable function: find_custom() / g_slist_find_custom()
8498 // Finds an element in a #GSList, using a supplied function to
8499 // find the desired element. It iterates over the list, calling
8500 // the given function which should return 0 when the desired
8501 // element is found. The function takes two #gconstpointer arguments,
8502 // the #GSList element's data as the first argument and the
8503 // given user data.
8504 // RETURNS: the found #GSList element, or %NULL if it is not found
8505 // <list>: a #GSList
8506 // <data>: user data passed to the function
8507 // <func>: the function to call for each element. It should return 0 when the desired element is found
8508 static GLib2.SList* find_custom(GLib2.SList* list, const(void)* data, CompareFunc func) {
8509 return g_slist_find_custom(list, data, func);
8512 // Unintrospectable function: foreach() / g_slist_foreach()
8513 // Calls a function for each element of a #GSList.
8514 // <list>: a #GSList
8515 // <func>: the function to call with each element's data
8516 // <user_data>: user data to pass to the function
8517 static void foreach_(GLib2.SList* list, Func func, void* user_data) {
8518 g_slist_foreach(list, func, user_data);
8521 // Unintrospectable function: free() / g_slist_free()
8522 // Frees all of the memory used by a #GSList.
8523 // The freed elements are returned to the slice allocator.
8525 // <note><para>
8526 // If list elements contain dynamically-allocated memory,
8527 // you should either use g_slist_free_full() or free them manually
8528 // first.
8529 // </para></note>
8530 // <list>: a #GSList
8531 static void free(GLib2.SList* list) {
8532 g_slist_free(list);
8535 // Unintrospectable function: free_1() / g_slist_free_1()
8536 // Frees one #GSList element.
8537 // It is usually used after g_slist_remove_link().
8538 // <list>: a #GSList element
8539 static void free_1(GLib2.SList* list) {
8540 g_slist_free_1(list);
8543 // Unintrospectable function: free_full() / g_slist_free_full()
8544 // Convenience method, which frees all the memory used by a #GSList, and
8545 // calls the specified destroy function on every element's data.
8546 // <list>: a pointer to a #GSList
8547 // <free_func>: the function to be called to free each element's data
8548 static void free_full(GLib2.SList* list, DestroyNotify free_func) {
8549 g_slist_free_full(list, free_func);
8552 // Unintrospectable function: index() / g_slist_index()
8553 // Gets the position of the element containing
8554 // the given data (starting from 0).
8556 // or -1 if the data is not found
8557 // RETURNS: the index of the element containing the data,
8558 // <list>: a #GSList
8559 // <data>: the data to find
8560 static int index(GLib2.SList* list, const(void)* data) {
8561 return g_slist_index(list, data);
8564 // Unintrospectable function: insert() / g_slist_insert()
8565 // Inserts a new element into the list at the given position.
8566 // RETURNS: the new start of the #GSList
8567 // <list>: a #GSList
8568 // <data>: the data for the new element
8569 // <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.
8570 static GLib2.SList* insert(GLib2.SList* list, void* data, int position) {
8571 return g_slist_insert(list, data, position);
8574 // Unintrospectable function: insert_before() / g_slist_insert_before()
8575 // Inserts a node before @sibling containing @data.
8576 // RETURNS: the new head of the list.
8577 // <slist>: a #GSList
8578 // <sibling>: node to insert @data before
8579 // <data>: data to put in the newly-inserted node
8580 static GLib2.SList* insert_before(GLib2.SList* slist, GLib2.SList* sibling, void* data) {
8581 return g_slist_insert_before(slist, sibling, data);
8584 // Unintrospectable function: insert_sorted() / g_slist_insert_sorted()
8585 // Inserts a new element into the list, using the given
8586 // comparison function to determine its position.
8587 // RETURNS: the new start of the #GSList
8588 // <list>: a #GSList
8589 // <data>: the data for the new element
8590 // <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.
8591 static GLib2.SList* insert_sorted(GLib2.SList* list, void* data, CompareFunc func) {
8592 return g_slist_insert_sorted(list, data, func);
8595 // Unintrospectable function: insert_sorted_with_data() / g_slist_insert_sorted_with_data()
8596 // Inserts a new element into the list, using the given
8597 // comparison function to determine its position.
8598 // RETURNS: the new start of the #GSList
8599 // <list>: a #GSList
8600 // <data>: the data for the new element
8601 // <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.
8602 // <user_data>: data to pass to comparison function
8603 static GLib2.SList* insert_sorted_with_data(GLib2.SList* list, void* data, CompareDataFunc func, void* user_data) {
8604 return g_slist_insert_sorted_with_data(list, data, func, user_data);
8607 // Unintrospectable function: last() / g_slist_last()
8608 // Gets the last element in a #GSList.
8610 // <note><para>
8611 // This function iterates over the whole list.
8612 // </para></note>
8614 // or %NULL if the #GSList has no elements
8615 // RETURNS: the last element in the #GSList,
8616 // <list>: a #GSList
8617 static GLib2.SList* last(GLib2.SList* list) {
8618 return g_slist_last(list);
8621 // Unintrospectable function: length() / g_slist_length()
8622 // Gets the number of elements in a #GSList.
8624 // <note><para>
8625 // This function iterates over the whole list to
8626 // count its elements.
8627 // </para></note>
8628 // RETURNS: the number of elements in the #GSList
8629 // <list>: a #GSList
8630 static uint length(GLib2.SList* list) {
8631 return g_slist_length(list);
8634 // Unintrospectable function: nth() / g_slist_nth()
8635 // Gets the element at the given position in a #GSList.
8637 // the end of the #GSList
8638 // RETURNS: the element, or %NULL if the position is off
8639 // <list>: a #GSList
8640 // <n>: the position of the element, counting from 0
8641 static GLib2.SList* nth(GLib2.SList* list, uint n) {
8642 return g_slist_nth(list, n);
8645 // Unintrospectable function: nth_data() / g_slist_nth_data()
8646 // Gets the data of the element at the given position.
8648 // is off the end of the #GSList
8649 // RETURNS: the element's data, or %NULL if the position
8650 // <list>: a #GSList
8651 // <n>: the position of the element
8652 static void* nth_data(GLib2.SList* list, uint n) {
8653 return g_slist_nth_data(list, n);
8656 // Restores the previous #GAllocator, used when allocating #GSList
8657 // elements.
8659 // Note that this function is not available if GLib has been compiled
8660 // with <option>--disable-mem-pools</option>
8662 // to the <link linkend="glib-Memory-Slices">slice
8663 // allocator</link>
8664 static void pop_allocator() {
8665 g_slist_pop_allocator();
8668 // Unintrospectable function: position() / g_slist_position()
8669 // Gets the position of the given element
8670 // in the #GSList (starting from 0).
8672 // or -1 if the element is not found
8673 // RETURNS: the position of the element in the #GSList,
8674 // <list>: a #GSList
8675 // <llink>: an element in the #GSList
8676 static int position(GLib2.SList* list, GLib2.SList* llink) {
8677 return g_slist_position(list, llink);
8680 // Unintrospectable function: prepend() / g_slist_prepend()
8681 // Adds a new element on to the start of the list.
8683 // <note><para>
8684 // The return value is the new start of the list, which
8685 // may have changed, so make sure you store the new value.
8686 // </para></note>
8688 // |[
8689 // /&ast; Notice that it is initialized to the empty list. &ast;/
8690 // GSList *list = NULL;
8691 // list = g_slist_prepend (list, "last");
8692 // list = g_slist_prepend (list, "first");
8693 // ]|
8694 // RETURNS: the new start of the #GSList
8695 // <list>: a #GSList
8696 // <data>: the data for the new element
8697 static GLib2.SList* prepend(GLib2.SList* list, void* data) {
8698 return g_slist_prepend(list, data);
8701 // Sets the allocator to use to allocate #GSList elements. Use
8702 // g_slist_pop_allocator() to restore the previous allocator.
8704 // Note that this function is not available if GLib has been compiled
8705 // with <option>--disable-mem-pools</option>
8707 // to the <link linkend="glib-Memory-Slices">slice
8708 // allocator</link>
8709 // <dummy>: the #GAllocator to use when allocating #GSList elements.
8710 static void push_allocator(void* dummy) {
8711 g_slist_push_allocator(dummy);
8714 // Unintrospectable function: remove() / g_slist_remove()
8715 // Removes an element from a #GSList.
8716 // If two elements contain the same data, only the first is removed.
8717 // If none of the elements contain the data, the #GSList is unchanged.
8718 // RETURNS: the new start of the #GSList
8719 // <list>: a #GSList
8720 // <data>: the data of the element to remove
8721 static GLib2.SList* remove(GLib2.SList* list, const(void)* data) {
8722 return g_slist_remove(list, data);
8725 // Unintrospectable function: remove_all() / g_slist_remove_all()
8726 // Removes all list nodes with data equal to @data.
8727 // Returns the new head of the list. Contrast with
8728 // g_slist_remove() which removes only the first node
8729 // matching the given data.
8730 // RETURNS: new head of @list
8731 // <list>: a #GSList
8732 // <data>: data to remove
8733 static GLib2.SList* remove_all(GLib2.SList* list, const(void)* data) {
8734 return g_slist_remove_all(list, data);
8737 // Unintrospectable function: remove_link() / g_slist_remove_link()
8738 // Removes an element from a #GSList, without
8739 // freeing the element. The removed element's next
8740 // link is set to %NULL, so that it becomes a
8741 // self-contained list with one element.
8742 // RETURNS: the new start of the #GSList, without the element
8743 // <list>: a #GSList
8744 // <link_>: an element in the #GSList
8745 static GLib2.SList* remove_link(GLib2.SList* list, GLib2.SList* link_) {
8746 return g_slist_remove_link(list, link_);
8749 // Unintrospectable function: reverse() / g_slist_reverse()
8750 // Reverses a #GSList.
8751 // RETURNS: the start of the reversed #GSList
8752 // <list>: a #GSList
8753 static GLib2.SList* reverse(GLib2.SList* list) {
8754 return g_slist_reverse(list);
8757 // Unintrospectable function: sort() / g_slist_sort()
8758 // Sorts a #GSList using the given comparison function.
8759 // RETURNS: the start of the sorted #GSList
8760 // <list>: a #GSList
8761 // <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.
8762 static GLib2.SList* sort(GLib2.SList* list, CompareFunc compare_func) {
8763 return g_slist_sort(list, compare_func);
8766 // Unintrospectable function: sort_with_data() / g_slist_sort_with_data()
8767 // Like g_slist_sort(), but the sort function accepts a user data argument.
8768 // RETURNS: new head of the list
8769 // <list>: a #GSList
8770 // <compare_func>: comparison function
8771 // <user_data>: data to pass to comparison function
8772 static GLib2.SList* sort_with_data(GLib2.SList* list, CompareDataFunc compare_func, void* user_data) {
8773 return g_slist_sort_with_data(list, compare_func, user_data);
8777 enum double SQRT2 = 1.414214;
8778 enum STR_DELIMITERS = "_-|> <.";
8779 enum int SYSDEF_AF_INET = 2;
8780 enum int SYSDEF_AF_INET6 = 10;
8781 enum int SYSDEF_AF_UNIX = 1;
8782 enum int SYSDEF_MSG_DONTROUTE = 4;
8783 enum int SYSDEF_MSG_OOB = 1;
8784 enum int SYSDEF_MSG_PEEK = 2;
8785 struct Scanner {
8786 void* user_data;
8787 uint max_parse_errors, parse_errors;
8788 char* input_name;
8789 Data* qdata;
8790 ScannerConfig* config;
8791 TokenType token;
8792 TokenValue value;
8793 uint line, position;
8794 TokenType next_token;
8795 TokenValue next_value;
8796 uint next_line, next_position;
8797 GLib2.HashTable* symbol_table;
8798 int input_fd;
8799 char* text, text_end, buffer;
8800 uint scope_id;
8801 ScannerMsgFunc msg_handler;
8803 uint cur_line() {
8804 return g_scanner_cur_line(&this);
8806 uint cur_position() {
8807 return g_scanner_cur_position(&this);
8809 TokenType cur_token() {
8810 return g_scanner_cur_token(&this);
8812 // Unintrospectable method: cur_value() / g_scanner_cur_value()
8813 TokenValue cur_value() {
8814 return g_scanner_cur_value(&this);
8816 void destroy() {
8817 g_scanner_destroy(&this);
8819 int eof() {
8820 return g_scanner_eof(&this);
8822 // Unintrospectable method: error() / g_scanner_error()
8823 /+ Not available -- variadic methods unsupported - use the C function directly.
8824 alias g_scanner_error error; // Variadic
8826 TokenType get_next_token() {
8827 return g_scanner_get_next_token(&this);
8829 void input_file(int input_fd) {
8830 g_scanner_input_file(&this, input_fd);
8832 void input_text(char* text, uint text_len) {
8833 g_scanner_input_text(&this, text, text_len);
8835 // Unintrospectable method: lookup_symbol() / g_scanner_lookup_symbol()
8836 void* lookup_symbol(char* symbol) {
8837 return g_scanner_lookup_symbol(&this, symbol);
8839 TokenType peek_next_token() {
8840 return g_scanner_peek_next_token(&this);
8842 void scope_add_symbol(uint scope_id, char* symbol, void* value) {
8843 g_scanner_scope_add_symbol(&this, scope_id, symbol, value);
8845 // Unintrospectable method: scope_foreach_symbol() / g_scanner_scope_foreach_symbol()
8846 void scope_foreach_symbol(uint scope_id, HFunc func, void* user_data) {
8847 g_scanner_scope_foreach_symbol(&this, scope_id, func, user_data);
8849 // Unintrospectable method: scope_lookup_symbol() / g_scanner_scope_lookup_symbol()
8850 void* scope_lookup_symbol(uint scope_id, char* symbol) {
8851 return g_scanner_scope_lookup_symbol(&this, scope_id, symbol);
8853 void scope_remove_symbol(uint scope_id, char* symbol) {
8854 g_scanner_scope_remove_symbol(&this, scope_id, symbol);
8856 uint set_scope(uint scope_id) {
8857 return g_scanner_set_scope(&this, scope_id);
8859 void sync_file_offset() {
8860 g_scanner_sync_file_offset(&this);
8862 void unexp_token(TokenType expected_token, char* identifier_spec, char* symbol_spec, char* symbol_name, char* message, int is_error) {
8863 g_scanner_unexp_token(&this, expected_token, identifier_spec, symbol_spec, symbol_name, message, is_error);
8865 // Unintrospectable method: warn() / g_scanner_warn()
8866 /+ Not available -- variadic methods unsupported - use the C function directly.
8867 alias g_scanner_warn warn; // Variadic
8869 // Unintrospectable function: new() / g_scanner_new()
8870 static Scanner* new_(ScannerConfig* config_templ) {
8871 return g_scanner_new(config_templ);
8875 struct ScannerConfig {
8876 char* cset_skip_characters, cset_identifier_first, cset_identifier_nth, cpair_comment_single;
8877 static import std.bitmanip; mixin(std.bitmanip.bitfields!(
8878 uint, "case_sensitive", 1,
8879 uint, "skip_comment_multi", 1,
8880 uint, "skip_comment_single", 1,
8881 uint, "scan_comment_multi", 1,
8882 uint, "scan_identifier", 1,
8883 uint, "scan_identifier_1char", 1,
8884 uint, "scan_identifier_NULL", 1,
8885 uint, "scan_symbols", 1,
8886 uint, "scan_binary", 1,
8887 uint, "scan_octal", 1,
8888 uint, "scan_float", 1,
8889 uint, "scan_hex", 1,
8890 uint, "scan_hex_dollar", 1,
8891 uint, "scan_string_sq", 1,
8892 uint, "scan_string_dq", 1,
8893 uint, "numbers_2_int", 1,
8894 uint, "int_2_float", 1,
8895 uint, "identifier_2_string", 1,
8896 uint, "char_2_token", 1,
8897 uint, "symbol_2_token", 1,
8898 uint, "scope_0_fallback", 1,
8899 uint, "store_int64", 1,
8900 uint, "__dummy32A", 10));
8901 uint padding_dummy;
8904 extern (C) alias void function (Scanner* scanner, char* message, int error) ScannerMsgFunc;
8907 // An enumeration specifying the base position for a
8908 // g_io_channel_seek_position() operation.
8909 enum SeekType {
8910 CUR = 0,
8911 SET = 1,
8912 END = 2
8915 // The #GSequence struct is an opaque data type representing a
8916 // <link linkend="glib-Sequences">Sequence</link> data type.
8917 struct Sequence {
8919 // Unintrospectable method: append() / g_sequence_append()
8920 // Adds a new item to the end of @seq.
8921 // RETURNS: an iterator pointing to the new item
8922 // <data>: the data for the new item
8923 SequenceIter* append(void* data) {
8924 return g_sequence_append(&this, data);
8927 // Unintrospectable method: foreach() / g_sequence_foreach()
8928 // Calls @func for each item in the sequence passing @user_data
8929 // to the function.
8930 // <func>: the function to call for each item in @seq
8931 // <user_data>: user data passed to @func
8932 void foreach_(Func func, void* user_data) {
8933 g_sequence_foreach(&this, func, user_data);
8936 // Frees the memory allocated for @seq. If @seq has a data destroy
8937 // function associated with it, that function is called on all items in
8938 // @seq.
8939 void free() {
8940 g_sequence_free(&this);
8943 // Unintrospectable method: get_begin_iter() / g_sequence_get_begin_iter()
8944 // Returns the begin iterator for @seq.
8945 // RETURNS: the begin iterator for @seq.
8946 SequenceIter* get_begin_iter() {
8947 return g_sequence_get_begin_iter(&this);
8950 // Unintrospectable method: get_end_iter() / g_sequence_get_end_iter()
8951 // Returns the end iterator for @seg
8952 // RETURNS: the end iterator for @seq
8953 SequenceIter* get_end_iter() {
8954 return g_sequence_get_end_iter(&this);
8957 // Unintrospectable method: get_iter_at_pos() / g_sequence_get_iter_at_pos()
8958 // Returns the iterator at position @pos. If @pos is negative or larger
8959 // than the number of items in @seq, the end iterator is returned.
8960 // RETURNS: The #GSequenceIter at position @pos
8961 // <pos>: a position in @seq, or -1 for the end.
8962 SequenceIter* get_iter_at_pos(int pos) {
8963 return g_sequence_get_iter_at_pos(&this, pos);
8966 // Returns the length of @seq
8967 // RETURNS: the length of @seq
8968 int get_length() {
8969 return g_sequence_get_length(&this);
8972 // Unintrospectable method: insert_sorted() / g_sequence_insert_sorted()
8973 // Inserts @data into @sequence using @func to determine the new
8974 // position. The sequence must already be sorted according to @cmp_func;
8975 // otherwise the new position of @data is undefined.
8977 // @cmp_func is called with two items of the @seq and @user_data.
8978 // It should return 0 if the items are equal, a negative value
8979 // if the first item comes before the second, and a positive value
8980 // if the second item comes before the first.
8981 // RETURNS: a #GSequenceIter pointing to the new item.
8982 // <data>: the data to insert
8983 // <cmp_func>: the function used to compare items in the sequence
8984 // <cmp_data>: user data passed to @cmp_func.
8985 SequenceIter* insert_sorted(void* data, CompareDataFunc cmp_func, void* cmp_data) {
8986 return g_sequence_insert_sorted(&this, data, cmp_func, cmp_data);
8989 // Unintrospectable method: insert_sorted_iter() / g_sequence_insert_sorted_iter()
8990 // Like g_sequence_insert_sorted(), but uses
8991 // a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as
8992 // the compare function.
8994 // @iter_cmp is called with two iterators pointing into @seq.
8995 // It should return 0 if the iterators are equal, a negative
8996 // value if the first iterator comes before the second, and a
8997 // positive value if the second iterator comes before the first.
8999 // It is called with two iterators pointing into @seq. It should
9000 // return 0 if the iterators are equal, a negative value if the
9001 // first iterator comes before the second, and a positive value
9002 // if the second iterator comes before the first.
9003 // RETURNS: a #GSequenceIter pointing to the new item
9004 // <data>: data for the new item
9005 // <iter_cmp>: the function used to compare iterators in the sequence
9006 // <cmp_data>: user data passed to @cmp_func
9007 SequenceIter* insert_sorted_iter(void* data, SequenceIterCompareFunc iter_cmp, void* cmp_data) {
9008 return g_sequence_insert_sorted_iter(&this, data, iter_cmp, cmp_data);
9011 // Unintrospectable method: lookup() / g_sequence_lookup()
9012 // Returns an iterator pointing to the position of the first item found
9013 // equal to @data according to @cmp_func and @cmp_data. If more than one
9014 // item is equal, it is not guaranteed that it is the first which is
9015 // returned. In that case, you can use g_sequence_iter_next() and
9016 // g_sequence_iter_prev() to get others.
9018 // @cmp_func is called with two items of the @seq and @user_data.
9019 // It should return 0 if the items are equal, a negative value if
9020 // the first item comes before the second, and a positive value if
9021 // the second item comes before the first.
9023 // first item found equal to @data according to @cmp_func and @cmp_data.
9024 // RETURNS: an #GSequenceIter pointing to the position of the
9025 // <data>: data to lookup
9026 // <cmp_func>: the function used to compare items in the sequence
9027 // <cmp_data>: user data passed to @cmp_func.
9028 SequenceIter* lookup(void* data, CompareDataFunc cmp_func, void* cmp_data) {
9029 return g_sequence_lookup(&this, data, cmp_func, cmp_data);
9032 // Unintrospectable method: lookup_iter() / g_sequence_lookup_iter()
9033 // Like g_sequence_lookup(), but uses a #GSequenceIterCompareFunc
9034 // instead of a #GCompareDataFunc as the compare function.
9036 // @iter_cmp is called with two iterators pointing into @seq.
9037 // It should return 0 if the iterators are equal, a negative value
9038 // if the first iterator comes before the second, and a positive
9039 // value if the second iterator comes before the first.
9041 // the first item found equal to @data according to @cmp_func
9042 // and @cmp_data.
9043 // RETURNS: an #GSequenceIter pointing to the position of
9044 // <data>: data to lookup
9045 // <iter_cmp>: the function used to compare iterators in the sequence
9046 // <cmp_data>: user data passed to @iter_cmp
9047 SequenceIter* lookup_iter(void* data, SequenceIterCompareFunc iter_cmp, void* cmp_data) {
9048 return g_sequence_lookup_iter(&this, data, iter_cmp, cmp_data);
9051 // Unintrospectable method: prepend() / g_sequence_prepend()
9052 // Adds a new item to the front of @seq
9053 // RETURNS: an iterator pointing to the new item
9054 // <data>: the data for the new item
9055 SequenceIter* prepend(void* data) {
9056 return g_sequence_prepend(&this, data);
9059 // Unintrospectable method: search() / g_sequence_search()
9060 // Returns an iterator pointing to the position where @data would
9061 // be inserted according to @cmp_func and @cmp_data.
9063 // @cmp_func is called with two items of the @seq and @user_data.
9064 // It should return 0 if the items are equal, a negative value if
9065 // the first item comes before the second, and a positive value if
9066 // the second item comes before the first.
9068 // If you are simply searching for an existing element of the sequence,
9069 // consider using g_sequence_lookup().
9071 // would have been inserted according to @cmp_func and @cmp_data.
9072 // RETURNS: an #GSequenceIter pointing to the position where @data
9073 // <data>: data for the new item
9074 // <cmp_func>: the function used to compare items in the sequence
9075 // <cmp_data>: user data passed to @cmp_func.
9076 SequenceIter* search(void* data, CompareDataFunc cmp_func, void* cmp_data) {
9077 return g_sequence_search(&this, data, cmp_func, cmp_data);
9080 // Unintrospectable method: search_iter() / g_sequence_search_iter()
9081 // Like g_sequence_search(), but uses a #GSequenceIterCompareFunc
9082 // instead of a #GCompareDataFunc as the compare function.
9084 // @iter_cmp is called with two iterators pointing into @seq.
9085 // It should return 0 if the iterators are equal, a negative value
9086 // if the first iterator comes before the second, and a positive
9087 // value if the second iterator comes before the first.
9089 // If you are simply searching for an existing element of the sequence,
9090 // consider using g_sequence_lookup_iter().
9092 // where @data would have been inserted according to @iter_cmp
9093 // and @cmp_data.
9094 // RETURNS: a #GSequenceIter pointing to the position in @seq
9095 // <data>: data for the new item
9096 // <iter_cmp>: the function used to compare iterators in the sequence
9097 // <cmp_data>: user data passed to @iter_cmp
9098 SequenceIter* search_iter(void* data, SequenceIterCompareFunc iter_cmp, void* cmp_data) {
9099 return g_sequence_search_iter(&this, data, iter_cmp, cmp_data);
9102 // Unintrospectable method: sort() / g_sequence_sort()
9103 // Sorts @seq using @cmp_func.
9105 // @cmp_func is passed two items of @seq and should
9106 // return 0 if they are equal, a negative value if the
9107 // first comes before the second, and a positive value
9108 // if the second comes before the first.
9109 // <cmp_func>: the function used to sort the sequence
9110 // <cmp_data>: user data passed to @cmp_func
9111 void sort(CompareDataFunc cmp_func, void* cmp_data) {
9112 g_sequence_sort(&this, cmp_func, cmp_data);
9115 // Unintrospectable method: sort_iter() / g_sequence_sort_iter()
9116 // Like g_sequence_sort(), but uses a #GSequenceIterCompareFunc instead
9117 // of a GCompareDataFunc as the compare function
9119 // @cmp_func is called with two iterators pointing into @seq. It should
9120 // return 0 if the iterators are equal, a negative value if the first
9121 // iterator comes before the second, and a positive value if the second
9122 // iterator comes before the first.
9123 // <cmp_func>: the function used to compare iterators in the sequence
9124 // <cmp_data>: user data passed to @cmp_func
9125 void sort_iter(SequenceIterCompareFunc cmp_func, void* cmp_data) {
9126 g_sequence_sort_iter(&this, cmp_func, cmp_data);
9129 // Unintrospectable function: foreach_range() / g_sequence_foreach_range()
9130 // Calls @func for each item in the range (@begin, @end) passing
9131 // @user_data to the function.
9132 // <begin>: a #GSequenceIter
9133 // <end>: a #GSequenceIter
9134 // <func>: a #GFunc
9135 // <user_data>: user data passed to @func
9136 static void foreach_range(SequenceIter* begin, SequenceIter* end, Func func, void* user_data) {
9137 g_sequence_foreach_range(begin, end, func, user_data);
9140 // Unintrospectable function: get() / g_sequence_get()
9141 // Returns the data that @iter points to.
9142 // RETURNS: the data that @iter points to
9143 // <iter>: a #GSequenceIter
9144 static void* get(SequenceIter* iter) {
9145 return g_sequence_get(iter);
9148 // Unintrospectable function: insert_before() / g_sequence_insert_before()
9149 // Inserts a new item just before the item pointed to by @iter.
9150 // RETURNS: an iterator pointing to the new item
9151 // <iter>: a #GSequenceIter
9152 // <data>: the data for the new item
9153 static SequenceIter* insert_before(SequenceIter* iter, void* data) {
9154 return g_sequence_insert_before(iter, data);
9157 // Moves the item pointed to by @src to the position indicated by @dest.
9158 // After calling this function @dest will point to the position immediately
9159 // after @src. It is allowed for @src and @dest to point into different
9160 // sequences.
9161 // <src>: a #GSequenceIter pointing to the item to move
9162 // <dest>: a #GSequenceIter pointing to the position to which the item is moved.
9163 static void move(SequenceIter* src, SequenceIter* dest) {
9164 g_sequence_move(src, dest);
9167 // Inserts the (@begin, @end) range at the destination pointed to by ptr.
9168 // The @begin and @end iters must point into the same sequence. It is
9169 // allowed for @dest to point to a different sequence than the one pointed
9170 // into by @begin and @end.
9172 // If @dest is NULL, the range indicated by @begin and @end is
9173 // removed from the sequence. If @dest iter points to a place within
9174 // the (@begin, @end) range, the range does not move.
9175 // <dest>: a #GSequenceIter
9176 // <begin>: a #GSequenceIter
9177 // <end>: a #GSequenceIter
9178 static void move_range(SequenceIter* dest, SequenceIter* begin, SequenceIter* end) {
9179 g_sequence_move_range(dest, begin, end);
9182 // Unintrospectable function: new() / g_sequence_new()
9183 // Creates a new GSequence. The @data_destroy function, if non-%NULL will
9184 // be called on all items when the sequence is destroyed and on items that
9185 // are removed from the sequence.
9186 // RETURNS: a new #GSequence
9187 // <data_destroy>: a #GDestroyNotify function, or %NULL
9188 static Sequence* new_(DestroyNotify data_destroy) {
9189 return g_sequence_new(data_destroy);
9192 // Unintrospectable function: range_get_midpoint() / g_sequence_range_get_midpoint()
9193 // Finds an iterator somewhere in the range (@begin, @end). This
9194 // iterator will be close to the middle of the range, but is not
9195 // guaranteed to be <emphasis>exactly</emphasis> in the middle.
9197 // The @begin and @end iterators must both point to the same sequence and
9198 // @begin must come before or be equal to @end in the sequence.
9200 // (@begin, @end) range.
9201 // RETURNS: A #GSequenceIter pointing somewhere in the
9202 // <begin>: a #GSequenceIter
9203 // <end>: a #GSequenceIter
9204 static SequenceIter* range_get_midpoint(SequenceIter* begin, SequenceIter* end) {
9205 return g_sequence_range_get_midpoint(begin, end);
9208 // Removes the item pointed to by @iter. It is an error to pass the
9209 // end iterator to this function.
9211 // If the sequnce has a data destroy function associated with it, this
9212 // function is called on the data for the removed item.
9213 // <iter>: a #GSequenceIter
9214 static void remove(SequenceIter* iter) {
9215 g_sequence_remove(iter);
9218 // Removes all items in the (@begin, @end) range.
9220 // If the sequence has a data destroy function associated with it, this
9221 // function is called on the data for the removed items.
9222 // <begin>: a #GSequenceIter
9223 // <end>: a #GSequenceIter
9224 static void remove_range(SequenceIter* begin, SequenceIter* end) {
9225 g_sequence_remove_range(begin, end);
9228 // Changes the data for the item pointed to by @iter to be @data. If
9229 // the sequence has a data destroy function associated with it, that
9230 // function is called on the existing data that @iter pointed to.
9231 // <iter>: a #GSequenceIter
9232 // <data>: new data for the item
9233 static void set(SequenceIter* iter, void* data) {
9234 g_sequence_set(iter, data);
9237 // Unintrospectable function: sort_changed() / g_sequence_sort_changed()
9238 // Moves the data pointed to a new position as indicated by @cmp_func. This
9239 // function should be called for items in a sequence already sorted according
9240 // to @cmp_func whenever some aspect of an item changes so that @cmp_func
9241 // may return different values for that item.
9243 // @cmp_func is called with two items of the @seq and @user_data.
9244 // It should return 0 if the items are equal, a negative value if
9245 // the first item comes before the second, and a positive value if
9246 // the second item comes before the first.
9247 // <iter>: A #GSequenceIter
9248 // <cmp_func>: the function used to compare items in the sequence
9249 // <cmp_data>: user data passed to @cmp_func.
9250 static void sort_changed(SequenceIter* iter, CompareDataFunc cmp_func, void* cmp_data) {
9251 g_sequence_sort_changed(iter, cmp_func, cmp_data);
9254 // Unintrospectable function: sort_changed_iter() / g_sequence_sort_changed_iter()
9255 // Like g_sequence_sort_changed(), but uses
9256 // a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as
9257 // the compare function.
9259 // @iter_cmp is called with two iterators pointing into @seq. It should
9260 // return 0 if the iterators are equal, a negative value if the first
9261 // iterator comes before the second, and a positive value if the second
9262 // iterator comes before the first.
9263 // <iter>: a #GSequenceIter
9264 // <iter_cmp>: the function used to compare iterators in the sequence
9265 // <cmp_data>: user data passed to @cmp_func
9266 static void sort_changed_iter(SequenceIter* iter, SequenceIterCompareFunc iter_cmp, void* cmp_data) {
9267 g_sequence_sort_changed_iter(iter, iter_cmp, cmp_data);
9270 // Swaps the items pointed to by @a and @b. It is allowed for @a and @b
9271 // to point into difference sequences.
9272 // <a>: a #GSequenceIter
9273 // <b>: a #GSequenceIter
9274 static void swap(SequenceIter* a, SequenceIter* b) {
9275 g_sequence_swap(a, b);
9280 // The #GSequenceIter struct is an opaque data type representing an
9281 // iterator pointing into a #GSequence.
9282 struct SequenceIter {
9284 // Returns a negative number if @a comes before @b, 0 if they are equal,
9285 // and a positive number if @a comes after @b.
9287 // The @a and @b iterators must point into the same sequence.
9289 // equal, and a positive number if @a comes after @b.
9290 // RETURNS: A negative number if @a comes before @b, 0 if they are
9291 // <b>: a #GSequenceIter
9292 int compare(SequenceIter* b) {
9293 return g_sequence_iter_compare(&this, b);
9296 // Returns the position of @iter
9297 // RETURNS: the position of @iter
9298 int get_position() {
9299 return g_sequence_iter_get_position(&this);
9302 // Unintrospectable method: get_sequence() / g_sequence_iter_get_sequence()
9303 // Returns the #GSequence that @iter points into.
9304 // RETURNS: the #GSequence that @iter points into.
9305 Sequence* get_sequence() {
9306 return g_sequence_iter_get_sequence(&this);
9309 // Returns whether @iter is the begin iterator
9310 // RETURNS: whether @iter is the begin iterator
9311 int is_begin() {
9312 return g_sequence_iter_is_begin(&this);
9315 // Returns whether @iter is the end iterator
9316 // RETURNS: Whether @iter is the end iterator.
9317 int is_end() {
9318 return g_sequence_iter_is_end(&this);
9321 // Unintrospectable method: move() / g_sequence_iter_move()
9322 // Returns the #GSequenceIter which is @delta positions away from @iter.
9323 // If @iter is closer than -@delta positions to the beginning of the sequence,
9324 // the begin iterator is returned. If @iter is closer than @delta positions
9325 // to the end of the sequence, the end iterator is returned.
9326 // RETURNS: a #GSequenceIter which is @delta positions away from @iter.
9327 // <delta>: A positive or negative number indicating how many positions away from @iter the returned #GSequenceIter will be.
9328 SequenceIter* move(int delta) {
9329 return g_sequence_iter_move(&this, delta);
9332 // Unintrospectable method: next() / g_sequence_iter_next()
9333 // Returns an iterator pointing to the next position after @iter. If
9334 // @iter is the end iterator, the end iterator is returned.
9335 // RETURNS: a #GSequenceIter pointing to the next position after @iter.
9336 SequenceIter* next() {
9337 return g_sequence_iter_next(&this);
9340 // Unintrospectable method: prev() / g_sequence_iter_prev()
9341 // Returns an iterator pointing to the previous position before @iter. If
9342 // @iter is the begin iterator, the begin iterator is returned.
9344 // @iter.
9345 // RETURNS: a #GSequenceIter pointing to the previous position before
9346 SequenceIter* prev() {
9347 return g_sequence_iter_prev(&this);
9352 // A #GSequenceIterCompareFunc is a function used to compare iterators.
9353 // It must return zero if the iterators compare equal, a negative value
9354 // if @a comes before @b, and a positive value if @b comes before @a.
9355 // <a>: a #GSequenceIter
9356 // <b>: a #GSequenceIter
9357 // <data>: user data
9358 extern (C) alias int function (SequenceIter* a, SequenceIter* b, void* data) SequenceIterCompareFunc;
9360 // Error codes returned by shell functions.
9361 enum ShellError {
9362 BAD_QUOTING = 0,
9363 EMPTY_STRING = 1,
9364 FAILED = 2
9366 enum SliceConfig {
9367 ALWAYS_MALLOC = 1,
9368 BYPASS_MAGAZINES = 2,
9369 WORKING_SET_MSECS = 3,
9370 COLOR_INCREMENT = 4,
9371 CHUNK_SIZES = 5,
9372 CONTENTION_COUNTER = 6
9375 // The <structname>GSource</structname> struct is an opaque data type
9376 // representing an event source.
9377 struct Source {
9378 private void* callback_data;
9379 private SourceCallbackFuncs* callback_funcs;
9380 private SourceFuncs* source_funcs;
9381 private uint ref_count;
9382 private MainContext* context;
9383 private int priority;
9384 private uint flags, source_id;
9385 private GLib2.SList* poll_fds;
9386 private Source* prev, next;
9387 private char* name;
9388 private SourcePrivate* priv;
9391 // Creates a new #GSource structure. The size is specified to
9392 // allow creating structures derived from #GSource that contain
9393 // additional data. The size passed in must be at least
9394 // <literal>sizeof (GSource)</literal>.
9396 // The source will not initially be associated with any #GMainContext
9397 // and must be added to one with g_source_attach() before it will be
9398 // executed.
9399 // RETURNS: the newly-created #GSource.
9400 // <source_funcs>: structure containing functions that implement the sources behavior.
9401 // <struct_size>: size of the #GSource structure to create.
9402 static Source* /*new*/ new_(SourceFuncs* source_funcs, uint struct_size) {
9403 return g_source_new(source_funcs, struct_size);
9406 // Adds @child_source to @source as a "polled" source; when @source is
9407 // added to a #GMainContext, @child_source will be automatically added
9408 // with the same priority, when @child_source is triggered, it will
9409 // cause @source to dispatch (in addition to calling its own
9410 // callback), and when @source is destroyed, it will destroy
9411 // @child_source as well. (@source will also still be dispatched if
9412 // its own prepare/check functions indicate that it is ready.)
9414 // If you don't need @child_source to do anything on its own when it
9415 // triggers, you can call g_source_set_dummy_callback() on it to set a
9416 // callback that does nothing (except return %TRUE if appropriate).
9418 // @source will hold a reference on @child_source while @child_source
9419 // is attached to it.
9420 // <child_source>: a second #GSource that @source should "poll"
9421 void add_child_source(Source* child_source) {
9422 g_source_add_child_source(&this, child_source);
9425 // Adds a file descriptor to the set of file descriptors polled for
9426 // this source. This is usually combined with g_source_new() to add an
9427 // event source. The event source's check function will typically test
9428 // the @revents field in the #GPollFD struct and return %TRUE if events need
9429 // to be processed.
9430 // <fd>: a #GPollFD structure holding information about a file descriptor to watch.
9431 void add_poll(PollFD* fd) {
9432 g_source_add_poll(&this, fd);
9435 // Adds a #GSource to a @context so that it will be executed within
9436 // that context. Remove it by calling g_source_destroy().
9438 // #GMainContext.
9439 // RETURNS: the ID (greater than 0) for the source within the
9440 // <context>: a #GMainContext (if %NULL, the default context will be used)
9441 uint attach(MainContext* context) {
9442 return g_source_attach(&this, context);
9445 // Removes a source from its #GMainContext, if any, and mark it as
9446 // destroyed. The source cannot be subsequently added to another
9447 // context.
9448 void destroy() {
9449 g_source_destroy(&this);
9452 // Checks whether a source is allowed to be called recursively.
9453 // see g_source_set_can_recurse().
9454 // RETURNS: whether recursion is allowed.
9455 int get_can_recurse() {
9456 return g_source_get_can_recurse(&this);
9459 // Gets the #GMainContext with which the source is associated.
9460 // Calling this function on a destroyed source is an error.
9462 // source is associated, or %NULL if the context has not
9463 // yet been added to a source.
9464 // RETURNS: the #GMainContext with which the
9465 MainContext* get_context() {
9466 return g_source_get_context(&this);
9469 // Gets the "current time" to be used when checking
9470 // this source. The advantage of calling this function over
9471 // calling g_get_current_time() directly is that when
9472 // checking multiple sources, GLib can cache a single value
9473 // instead of having to repeatedly get the system time.
9474 // <timeval>: #GTimeVal structure in which to store current time.
9475 void get_current_time(TimeVal* timeval) {
9476 g_source_get_current_time(&this, timeval);
9479 // Returns the numeric ID for a particular source. The ID of a source
9480 // is a positive integer which is unique within a particular main loop
9481 // context. The reverse
9482 // mapping from ID to source is done by g_main_context_find_source_by_id().
9483 // RETURNS: the ID (greater than 0) for the source
9484 uint get_id() {
9485 return g_source_get_id(&this);
9488 // Gets a name for the source, used in debugging and profiling.
9489 // The name may be #NULL if it has never been set with
9490 // g_source_set_name().
9491 // RETURNS: the name of the source
9492 char* get_name() {
9493 return g_source_get_name(&this);
9496 // Gets the priority of a source.
9497 // RETURNS: the priority of the source
9498 int get_priority() {
9499 return g_source_get_priority(&this);
9502 // Gets the time to be used when checking this source. The advantage of
9503 // calling this function over calling g_get_monotonic_time() directly is
9504 // that when checking multiple sources, GLib can cache a single value
9505 // instead of having to repeatedly get the system monotonic time.
9507 // The time here is the system monotonic time, if available, or some
9508 // other reasonable alternative otherwise. See g_get_monotonic_time().
9509 // RETURNS: the monotonic time in microseconds
9510 long get_time() {
9511 return g_source_get_time(&this);
9514 // Returns whether @source has been destroyed.
9516 // This is important when you operate upon your objects
9517 // from within idle handlers, but may have freed the object
9518 // before the dispatch of your idle handler.
9520 // |[
9521 // static gboolean
9522 // idle_callback (gpointer data)
9523 // {
9524 // SomeWidget *self = data;
9526 // GDK_THREADS_ENTER (<!-- -->);
9527 // /<!-- -->* do stuff with self *<!-- -->/
9528 // self->idle_id = 0;
9529 // GDK_THREADS_LEAVE (<!-- -->);
9531 // return FALSE;
9532 // }
9534 // static void
9535 // some_widget_do_stuff_later (SomeWidget *self)
9536 // {
9537 // self->idle_id = g_idle_add (idle_callback, self);
9538 // }
9540 // static void
9541 // some_widget_finalize (GObject *object)
9542 // {
9543 // SomeWidget *self = SOME_WIDGET (object);
9545 // if (self->idle_id)
9546 // g_source_remove (self->idle_id);
9548 // G_OBJECT_CLASS (parent_class)->finalize (object);
9549 // }
9550 // ]|
9552 // This will fail in a multi-threaded application if the
9553 // widget is destroyed before the idle handler fires due
9554 // to the use after free in the callback. A solution, to
9555 // this particular problem, is to check to if the source
9556 // has already been destroy within the callback.
9558 // |[
9559 // static gboolean
9560 // idle_callback (gpointer data)
9561 // {
9562 // SomeWidget *self = data;
9564 // GDK_THREADS_ENTER ();
9565 // if (!g_source_is_destroyed (g_main_current_source ()))
9566 // {
9567 // /<!-- -->* do stuff with self *<!-- -->/
9568 // }
9569 // GDK_THREADS_LEAVE ();
9571 // return FALSE;
9572 // }
9573 // ]|
9574 // RETURNS: %TRUE if the source has been destroyed
9575 int is_destroyed() {
9576 return g_source_is_destroyed(&this);
9579 // Increases the reference count on a source by one.
9580 // RETURNS: @source
9581 Source* /*new*/ ref_() {
9582 return g_source_ref(&this);
9585 // Detaches @child_source from @source and destroys it.
9586 // <child_source>: a #GSource previously passed to g_source_add_child_source().
9587 void remove_child_source(Source* child_source) {
9588 g_source_remove_child_source(&this, child_source);
9591 // Removes a file descriptor from the set of file descriptors polled for
9592 // this source.
9593 // <fd>: a #GPollFD structure previously passed to g_source_add_poll().
9594 void remove_poll(PollFD* fd) {
9595 g_source_remove_poll(&this, fd);
9598 // Sets the callback function for a source. The callback for a source is
9599 // called from the source's dispatch function.
9601 // The exact type of @func depends on the type of source; ie. you
9602 // should not count on @func being called with @data as its first
9603 // parameter.
9605 // Typically, you won't use this function. Instead use functions specific
9606 // to the type of source you are using.
9607 // <func>: a callback function
9608 // <data>: the data to pass to callback function
9609 // <notify>: a function to call when @data is no longer in use, or %NULL.
9610 void set_callback(SourceFunc func, void* data, DestroyNotify notify) {
9611 g_source_set_callback(&this, func, data, notify);
9614 // Sets the callback function storing the data as a refcounted callback
9615 // "object". This is used internally. Note that calling
9616 // g_source_set_callback_indirect() assumes
9617 // an initial reference count on @callback_data, and thus
9618 // @callback_funcs->unref will eventually be called once more
9619 // than @callback_funcs->ref.
9620 // <callback_data>: pointer to callback data "object"
9621 // <callback_funcs>: functions for reference counting @callback_data and getting the callback and data
9622 void set_callback_indirect(void* callback_data, SourceCallbackFuncs* callback_funcs) {
9623 g_source_set_callback_indirect(&this, callback_data, callback_funcs);
9626 // Sets whether a source can be called recursively. If @can_recurse is
9627 // %TRUE, then while the source is being dispatched then this source
9628 // will be processed normally. Otherwise, all processing of this
9629 // source is blocked until the dispatch function returns.
9630 // <can_recurse>: whether recursion is allowed for this source
9631 void set_can_recurse(int can_recurse) {
9632 g_source_set_can_recurse(&this, can_recurse);
9635 // Sets the source functions (can be used to override
9636 // default implementations) of an unattached source.
9637 // <funcs>: the new #GSourceFuncs
9638 void set_funcs(SourceFuncs* funcs) {
9639 g_source_set_funcs(&this, funcs);
9642 // Sets a name for the source, used in debugging and profiling.
9643 // The name defaults to #NULL.
9645 // The source name should describe in a human-readable way
9646 // what the source does. For example, "X11 event queue"
9647 // or "GTK+ repaint idle handler" or whatever it is.
9649 // It is permitted to call this function multiple times, but is not
9650 // recommended due to the potential performance impact. For example,
9651 // one could change the name in the "check" function of a #GSourceFuncs
9652 // to include details like the event type in the source name.
9653 // <name>: debug name for the source
9654 void set_name(char* name) {
9655 g_source_set_name(&this, name);
9658 // Sets the priority of a source. While the main loop is being run, a
9659 // source will be dispatched if it is ready to be dispatched and no
9660 // sources at a higher (numerically smaller) priority are ready to be
9661 // dispatched.
9662 // <priority>: the new priority.
9663 void set_priority(int priority) {
9664 g_source_set_priority(&this, priority);
9667 // Decreases the reference count of a source by one. If the
9668 // resulting reference count is zero the source and associated
9669 // memory will be destroyed.
9670 void unref() {
9671 g_source_unref(&this);
9674 // Removes the source with the given id from the default main context.
9675 // The id of
9676 // a #GSource is given by g_source_get_id(), or will be returned by the
9677 // functions g_source_attach(), g_idle_add(), g_idle_add_full(),
9678 // g_timeout_add(), g_timeout_add_full(), g_child_watch_add(),
9679 // g_child_watch_add_full(), g_io_add_watch(), and g_io_add_watch_full().
9681 // See also g_source_destroy(). You must use g_source_destroy() for sources
9682 // added to a non-default main context.
9683 // RETURNS: %TRUE if the source was found and removed.
9684 // <tag>: the ID of the source to remove.
9685 static int remove(uint tag) {
9686 return g_source_remove(tag);
9689 // Removes a source from the default main loop context given the
9690 // source functions and user data. If multiple sources exist with the
9691 // same source functions and user data, only one will be destroyed.
9692 // RETURNS: %TRUE if a source was found and removed.
9693 // <funcs>: The @source_funcs passed to g_source_new()
9694 // <user_data>: the user data for the callback
9695 static int remove_by_funcs_user_data(SourceFuncs* funcs, void* user_data) {
9696 return g_source_remove_by_funcs_user_data(funcs, user_data);
9699 // Removes a source from the default main loop context given the user
9700 // data for the callback. If multiple sources exist with the same user
9701 // data, only one will be destroyed.
9702 // RETURNS: %TRUE if a source was found and removed.
9703 // <user_data>: the user_data for the callback.
9704 static int remove_by_user_data(void* user_data) {
9705 return g_source_remove_by_user_data(user_data);
9708 // Sets the name of a source using its ID.
9710 // This is a convenience utility to set source names from the return
9711 // value of g_idle_add(), g_timeout_add(), etc.
9712 // <tag>: a #GSource ID
9713 // <name>: debug name for the source
9714 static void set_name_by_id(uint tag, char* name) {
9715 g_source_set_name_by_id(tag, name);
9719 struct SourceCallbackFuncs {
9720 extern (C) void function (void* cb_data) ref_;
9721 extern (C) void function (void* cb_data) unref;
9722 // Unintrospectable functionp: get() / ()
9723 extern (C) void function (void* cb_data, Source* source, SourceFunc* func, void** data) get;
9727 // This is just a placeholder for #GClosureMarshal,
9728 // which cannot be used here for dependency reasons.
9729 extern (C) alias void function () SourceDummyMarshal;
9732 // Specifies the type of function passed to g_timeout_add(),
9733 // g_timeout_add_full(), g_idle_add(), and g_idle_add_full().
9734 // RETURNS: %FALSE if the source should be removed
9735 // <user_data>: data passed to the function, set when the source was created with one of the above functions
9736 extern (C) alias int function (void* user_data) SourceFunc;
9739 // The <structname>GSourceFuncs</structname> struct contains a table of
9740 // functions used to handle event sources in a generic manner.
9742 // For idle sources, the prepare and check functions always return %TRUE
9743 // to indicate that the source is always ready to be processed. The prepare
9744 // function also returns a timeout value of 0 to ensure that the poll() call
9745 // doesn't block (since that would be time wasted which could have been spent
9746 // running the idle function).
9748 // For timeout sources, the prepare and check functions both return %TRUE
9749 // if the timeout interval has expired. The prepare function also returns
9750 // a timeout value to ensure that the poll() call doesn't block too long
9751 // and miss the next timeout.
9753 // For file descriptor sources, the prepare function typically returns %FALSE,
9754 // since it must wait until poll() has been called before it knows whether
9755 // any events need to be processed. It sets the returned timeout to -1 to
9756 // indicate that it doesn't mind how long the poll() call blocks. In the
9757 // check function, it tests the results of the poll() call to see if the
9758 // required condition has been met, and returns %TRUE if so.
9759 struct SourceFuncs {
9760 extern (C) int function (Source* source, int* timeout_) prepare;
9761 extern (C) int function (Source* source) check;
9762 // Unintrospectable functionp: dispatch() / ()
9763 extern (C) int function (Source* source, SourceFunc callback, void* user_data) dispatch;
9764 extern (C) void function (Source* source) finalize;
9765 SourceFunc closure_callback;
9766 SourceDummyMarshal closure_marshal;
9769 struct SourcePrivate {
9773 // Specifies the type of the setup function passed to g_spawn_async(),
9774 // g_spawn_sync() and g_spawn_async_with_pipes(). On POSIX platforms it
9775 // is called in the child after GLib has performed all the setup it plans
9776 // to perform but before calling exec(). On POSIX actions taken in this
9777 // function will thus only affect the child, not the parent.
9779 // Note that POSIX allows only async-signal-safe functions (see signal(7))
9780 // to be called in the child between fork() and exec(), which drastically
9781 // limits the usefulness of child setup functions.
9783 // Also note that modifying the environment from the child setup function
9784 // may not have the intended effect, since it will get overridden by
9785 // a non-%NULL @env argument to the <literal>g_spawn...</literal> functions.
9787 // On Windows the function is called in the parent. Its usefulness on
9788 // Windows is thus questionable. In many cases executing the child setup
9789 // function in the parent can have ill effects, and you should be very
9790 // careful when porting software to Windows that uses child setup
9791 // functions.
9792 // <user_data>: user data to pass to the function.
9793 extern (C) alias void function (void* user_data) SpawnChildSetupFunc;
9795 // Error codes returned by spawning processes.
9796 enum SpawnError {
9797 FORK = 0,
9798 READ = 1,
9799 CHDIR = 2,
9800 ACCES = 3,
9801 PERM = 4,
9802 _2BIG = 5,
9803 NOEXEC = 6,
9804 NAMETOOLONG = 7,
9805 NOENT = 8,
9806 NOMEM = 9,
9807 NOTDIR = 10,
9808 LOOP = 11,
9809 TXTBUSY = 12,
9810 IO = 13,
9811 NFILE = 14,
9812 MFILE = 15,
9813 INVAL = 16,
9814 ISDIR = 17,
9815 LIBBAD = 18,
9816 FAILED = 19
9818 // Flags passed to g_spawn_sync(), g_spawn_async() and g_spawn_async_with_pipes().
9819 enum SpawnFlags {
9820 LEAVE_DESCRIPTORS_OPEN = 1,
9821 DO_NOT_REAP_CHILD = 2,
9822 SEARCH_PATH = 4,
9823 STDOUT_TO_DEV_NULL = 8,
9824 STDERR_TO_DEV_NULL = 16,
9825 CHILD_INHERITS_STDIN = 32,
9826 FILE_AND_ARGV_ZERO = 64
9829 // A type corresponding to the appropriate struct type for the stat
9830 // system call, depending on the platform and/or compiler being used.
9832 // See g_stat() for more information.
9833 struct StatBuf {
9837 // A #GStaticMutex works like a #GMutex, but it has one significant
9838 // advantage. It doesn't need to be created at run-time like a #GMutex,
9839 // but can be defined at compile-time. Here is a shorter, easier and
9840 // safer version of our <function>give_me_next_number()</function>
9841 // example:
9843 // <example>
9844 // <title>
9845 // Using <structname>GStaticMutex</structname>
9846 // to simplify thread-safe programming
9847 // </title>
9848 // <programlisting>
9849 // int
9850 // give_me_next_number (void)
9851 // {
9852 // static int current_number = 0;
9853 // int ret_val;
9854 // static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
9856 // g_static_mutex_lock (&amp;mutex);
9857 // ret_val = current_number = calc_next_number (current_number);
9858 // g_static_mutex_unlock (&amp;mutex);
9860 // return ret_val;
9861 // }
9862 // </programlisting>
9863 // </example>
9865 // Sometimes you would like to dynamically create a mutex. If you don't
9866 // want to require prior calling to g_thread_init(), because your code
9867 // should also be usable in non-threaded programs, you are not able to
9868 // use g_mutex_new() and thus #GMutex, as that requires a prior call to
9869 // g_thread_init(). In theses cases you can also use a #GStaticMutex.
9870 // It must be initialized with g_static_mutex_init() before using it
9871 // and freed with with g_static_mutex_free() when not needed anymore to
9872 // free up any allocated resources.
9874 // Even though #GStaticMutex is not opaque, it should only be used with
9875 // the following functions, as it is defined differently on different
9876 // platforms.
9878 // All of the <function>g_static_mutex_*</function> functions apart
9879 // from <function>g_static_mutex_get_mutex</function> can also be used
9880 // even if g_thread_init() has not yet been called. Then they do
9881 // nothing, apart from <function>g_static_mutex_trylock</function>,
9882 // which does nothing but returning %TRUE.
9884 // <note><para>All of the <function>g_static_mutex_*</function>
9885 // functions are actually macros. Apart from taking their addresses, you
9886 // can however use them as if they were functions.</para></note>
9887 struct StaticMutex {
9888 void** runtime_mutex;
9890 union static_mutex {
9891 char[24] pad;
9892 double dummy_double;
9893 void* dummy_pointer;
9894 c_long dummy_long;
9898 // Releases all resources allocated to @mutex.
9900 // You don't have to call this functions for a #GStaticMutex with an
9901 // unbounded lifetime, i.e. objects declared 'static', but if you have
9902 // a #GStaticMutex as a member of a structure and the structure is
9903 // freed, you should also free the #GStaticMutex.
9905 // <note><para>Calling g_static_mutex_free() on a locked mutex may
9906 // result in undefined behaviour.</para></note>
9907 void free() {
9908 g_static_mutex_free(&this);
9911 // Initializes @mutex. Alternatively you can initialize it with
9912 // #G_STATIC_MUTEX_INIT.
9913 void init() {
9914 g_static_mutex_init(&this);
9916 // Unintrospectable function: get_mutex_impl() / g_static_mutex_get_mutex_impl()
9917 static Mutex* get_mutex_impl(Mutex** mutex) {
9918 return g_static_mutex_get_mutex_impl(mutex);
9923 // A #GStaticPrivate works almost like a #GPrivate, but it has one
9924 // significant advantage. It doesn't need to be created at run-time
9925 // like a #GPrivate, but can be defined at compile-time. This is
9926 // similar to the difference between #GMutex and #GStaticMutex. Now
9927 // look at our <function>give_me_next_number()</function> example with
9928 // #GStaticPrivate:
9930 // <example>
9931 // <title>Using GStaticPrivate for per-thread data</title>
9932 // <programlisting>
9933 // int
9934 // give_me_next_number (<!-- -->)
9935 // {
9936 // static GStaticPrivate current_number_key = G_STATIC_PRIVATE_INIT;
9937 // int *current_number = g_static_private_get (&amp;current_number_key);
9939 // if (!current_number)
9940 // {
9941 // current_number = g_new (int,1);
9942 // *current_number = 0;
9943 // g_static_private_set (&amp;current_number_key, current_number, g_free);
9944 // }
9946 // *current_number = calc_next_number (*current_number);
9948 // return *current_number;
9949 // }
9950 // </programlisting>
9951 // </example>
9952 struct StaticPrivate {
9953 private uint index;
9956 // Releases all resources allocated to @private_key.
9958 // You don't have to call this functions for a #GStaticPrivate with an
9959 // unbounded lifetime, i.e. objects declared 'static', but if you have
9960 // a #GStaticPrivate as a member of a structure and the structure is
9961 // freed, you should also free the #GStaticPrivate.
9962 void free() {
9963 g_static_private_free(&this);
9966 // Unintrospectable method: get() / g_static_private_get()
9967 // Works like g_private_get() only for a #GStaticPrivate.
9969 // This function works even if g_thread_init() has not yet been called.
9970 void* get() {
9971 return g_static_private_get(&this);
9974 // Initializes @private_key. Alternatively you can initialize it with
9975 // #G_STATIC_PRIVATE_INIT.
9976 void init() {
9977 g_static_private_init(&this);
9980 // Sets the pointer keyed to @private_key for the current thread and
9981 // the function @notify to be called with that pointer (%NULL or
9982 // non-%NULL), whenever the pointer is set again or whenever the
9983 // current thread ends.
9985 // This function works even if g_thread_init() has not yet been called.
9986 // If g_thread_init() is called later, the @data keyed to @private_key
9987 // will be inherited only by the main thread, i.e. the one that called
9988 // g_thread_init().
9990 // <note><para>@notify is used quite differently from @destructor in
9991 // g_private_new().</para></note>
9992 // <data>: the new pointer.
9993 // <notify>: a function to be called with the pointer whenever the current thread ends or sets this pointer again.
9994 void set(void* data, DestroyNotify notify) {
9995 g_static_private_set(&this, data, notify);
10000 // The #GStaticRWLock struct represents a read-write lock. A read-write
10001 // lock can be used for protecting data that some portions of code only
10002 // read from, while others also write. In such situations it is
10003 // desirable that several readers can read at once, whereas of course
10004 // only one writer may write at a time. Take a look at the following
10005 // example:
10007 // <example>
10008 // <title>An array with access functions</title>
10009 // <programlisting>
10010 // GStaticRWLock rwlock = G_STATIC_RW_LOCK_INIT;
10011 // GPtrArray *array;
10013 // gpointer
10014 // my_array_get (guint index)
10015 // {
10016 // gpointer retval = NULL;
10018 // if (!array)
10019 // return NULL;
10021 // g_static_rw_lock_reader_lock (&amp;rwlock);
10022 // if (index &lt; array->len)
10023 // retval = g_ptr_array_index (array, index);
10024 // g_static_rw_lock_reader_unlock (&amp;rwlock);
10026 // return retval;
10027 // }
10029 // void
10030 // my_array_set (guint index, gpointer data)
10031 // {
10032 // g_static_rw_lock_writer_lock (&amp;rwlock);
10034 // if (!array)
10035 // array = g_ptr_array_new (<!-- -->);
10037 // if (index >= array->len)
10038 // g_ptr_array_set_size (array, index+1);
10039 // g_ptr_array_index (array, index) = data;
10041 // g_static_rw_lock_writer_unlock (&amp;rwlock);
10042 // }
10043 // </programlisting>
10044 // </example>
10046 // This example shows an array which can be accessed by many readers
10047 // (the <function>my_array_get()</function> function) simultaneously,
10048 // whereas the writers (the <function>my_array_set()</function>
10049 // function) will only be allowed once at a time and only if no readers
10050 // currently access the array. This is because of the potentially
10051 // dangerous resizing of the array. Using these functions is fully
10052 // multi-thread safe now.
10054 // Most of the time, writers should have precedence over readers. That
10055 // means, for this implementation, that as soon as a writer wants to
10056 // lock the data, no other reader is allowed to lock the data, whereas,
10057 // of course, the readers that already have locked the data are allowed
10058 // to finish their operation. As soon as the last reader unlocks the
10059 // data, the writer will lock it.
10061 // Even though #GStaticRWLock is not opaque, it should only be used
10062 // with the following functions.
10064 // All of the <function>g_static_rw_lock_*</function> functions can be
10065 // used even if g_thread_init() has not been called. Then they do
10066 // nothing, apart from <function>g_static_rw_lock_*_trylock</function>,
10067 // which does nothing but returning %TRUE.
10069 // <note><para>A read-write lock has a higher overhead than a mutex. For
10070 // example, both g_static_rw_lock_reader_lock() and
10071 // g_static_rw_lock_reader_unlock() have to lock and unlock a
10072 // #GStaticMutex, so it takes at least twice the time to lock and unlock
10073 // a #GStaticRWLock that it does to lock and unlock a #GStaticMutex. So
10074 // only data structures that are accessed by multiple readers, and which
10075 // keep the lock for a considerable time justify a #GStaticRWLock. The
10076 // above example most probably would fare better with a
10077 // #GStaticMutex.</para></note>
10078 struct StaticRWLock {
10079 private StaticMutex mutex;
10080 private Cond* read_cond, write_cond;
10081 private uint read_counter;
10082 private int have_writer;
10083 private uint want_to_read, want_to_write;
10086 // Releases all resources allocated to @lock.
10088 // You don't have to call this functions for a #GStaticRWLock with an
10089 // unbounded lifetime, i.e. objects declared 'static', but if you have
10090 // a #GStaticRWLock as a member of a structure, and the structure is
10091 // freed, you should also free the #GStaticRWLock.
10092 void free() {
10093 g_static_rw_lock_free(&this);
10096 // A #GStaticRWLock must be initialized with this function before it
10097 // can be used. Alternatively you can initialize it with
10098 // #G_STATIC_RW_LOCK_INIT.
10099 void init() {
10100 g_static_rw_lock_init(&this);
10103 // Locks @lock for reading. There may be unlimited concurrent locks for
10104 // reading of a #GStaticRWLock at the same time. If @lock is already
10105 // locked for writing by another thread or if another thread is already
10106 // waiting to lock @lock for writing, this function will block until
10107 // @lock is unlocked by the other writing thread and no other writing
10108 // threads want to lock @lock. This lock has to be unlocked by
10109 // g_static_rw_lock_reader_unlock().
10111 // #GStaticRWLock is not recursive. It might seem to be possible to
10112 // recursively lock for reading, but that can result in a deadlock, due
10113 // to writer preference.
10114 void reader_lock() {
10115 g_static_rw_lock_reader_lock(&this);
10118 // Tries to lock @lock for reading. If @lock is already locked for
10119 // writing by another thread or if another thread is already waiting to
10120 // lock @lock for writing, immediately returns %FALSE. Otherwise locks
10121 // @lock for reading and returns %TRUE. This lock has to be unlocked by
10122 // g_static_rw_lock_reader_unlock().
10123 int reader_trylock() {
10124 return g_static_rw_lock_reader_trylock(&this);
10127 // Unlocks @lock. If a thread waits to lock @lock for writing and all
10128 // locks for reading have been unlocked, the waiting thread is woken up
10129 // and can lock @lock for writing.
10130 void reader_unlock() {
10131 g_static_rw_lock_reader_unlock(&this);
10134 // Locks @lock for writing. If @lock is already locked for writing or
10135 // reading by other threads, this function will block until @lock is
10136 // completely unlocked and then lock @lock for writing. While this
10137 // functions waits to lock @lock, no other thread can lock @lock for
10138 // reading. When @lock is locked for writing, no other thread can lock
10139 // @lock (neither for reading nor writing). This lock has to be
10140 // unlocked by g_static_rw_lock_writer_unlock().
10141 void writer_lock() {
10142 g_static_rw_lock_writer_lock(&this);
10145 // Tries to lock @lock for writing. If @lock is already locked (for
10146 // either reading or writing) by another thread, it immediately returns
10147 // %FALSE. Otherwise it locks @lock for writing and returns %TRUE. This
10148 // lock has to be unlocked by g_static_rw_lock_writer_unlock().
10149 int writer_trylock() {
10150 return g_static_rw_lock_writer_trylock(&this);
10153 // Unlocks @lock. If a thread is waiting to lock @lock for writing and
10154 // all locks for reading have been unlocked, the waiting thread is
10155 // woken up and can lock @lock for writing. If no thread is waiting to
10156 // lock @lock for writing, and some thread or threads are waiting to
10157 // lock @lock for reading, the waiting threads are woken up and can
10158 // lock @lock for reading.
10159 void writer_unlock() {
10160 g_static_rw_lock_writer_unlock(&this);
10165 // A #GStaticRecMutex works like a #GStaticMutex, but it can be locked
10166 // multiple times by one thread. If you enter it n times, you have to
10167 // unlock it n times again to let other threads lock it. An exception
10168 // is the function g_static_rec_mutex_unlock_full(): that allows you to
10169 // unlock a #GStaticRecMutex completely returning the depth, (i.e. the
10170 // number of times this mutex was locked). The depth can later be used
10171 // to restore the state of the #GStaticRecMutex by calling
10172 // g_static_rec_mutex_lock_full().
10174 // Even though #GStaticRecMutex is not opaque, it should only be used
10175 // with the following functions.
10177 // All of the <function>g_static_rec_mutex_*</function> functions can
10178 // be used even if g_thread_init() has not been called. Then they do
10179 // nothing, apart from <function>g_static_rec_mutex_trylock</function>,
10180 // which does nothing but returning %TRUE.
10181 struct StaticRecMutex {
10182 private StaticMutex mutex;
10183 private uint depth;
10184 private SystemThread owner;
10187 // Releases all resources allocated to a #GStaticRecMutex.
10189 // You don't have to call this functions for a #GStaticRecMutex with an
10190 // unbounded lifetime, i.e. objects declared 'static', but if you have
10191 // a #GStaticRecMutex as a member of a structure and the structure is
10192 // freed, you should also free the #GStaticRecMutex.
10193 void free() {
10194 g_static_rec_mutex_free(&this);
10197 // A #GStaticRecMutex must be initialized with this function before it
10198 // can be used. Alternatively you can initialize it with
10199 // #G_STATIC_REC_MUTEX_INIT.
10200 void init() {
10201 g_static_rec_mutex_init(&this);
10204 // Locks @mutex. If @mutex is already locked by another thread, the
10205 // current thread will block until @mutex is unlocked by the other
10206 // thread. If @mutex is already locked by the calling thread, this
10207 // functions increases the depth of @mutex and returns immediately.
10208 void lock() {
10209 g_static_rec_mutex_lock(&this);
10212 // Works like calling g_static_rec_mutex_lock() for @mutex @depth times.
10213 // <depth>: number of times this mutex has to be unlocked to be completely unlocked.
10214 void lock_full(uint depth) {
10215 g_static_rec_mutex_lock_full(&this, depth);
10218 // Tries to lock @mutex. If @mutex is already locked by another thread,
10219 // it immediately returns %FALSE. Otherwise it locks @mutex and returns
10220 // %TRUE. If @mutex is already locked by the calling thread, this
10221 // functions increases the depth of @mutex and immediately returns
10222 // %TRUE.
10223 int trylock() {
10224 return g_static_rec_mutex_trylock(&this);
10227 // Unlocks @mutex. Another thread will be allowed to lock @mutex only
10228 // when it has been unlocked as many times as it had been locked
10229 // before. If @mutex is completely unlocked and another thread is
10230 // blocked in a g_static_rec_mutex_lock() call for @mutex, it will be
10231 // woken and can lock @mutex itself.
10232 void unlock() {
10233 g_static_rec_mutex_unlock(&this);
10236 // Completely unlocks @mutex. If another thread is blocked in a
10237 // g_static_rec_mutex_lock() call for @mutex, it will be woken and can
10238 // lock @mutex itself. This function returns the number of times that
10239 // @mutex has been locked by the current thread. To restore the state
10240 // before the call to g_static_rec_mutex_unlock_full() you can call
10241 // g_static_rec_mutex_lock_full() with the depth returned by this
10242 // function.
10243 uint unlock_full() {
10244 return g_static_rec_mutex_unlock_full(&this);
10248 // The #GString struct contains the public fields of a #GString.
10249 struct String {
10250 char* str;
10251 size_t len, allocated_len;
10254 // Adds a string onto the end of a #GString, expanding
10255 // it if necessary.
10256 // RETURNS: @string
10257 // <val>: the string to append onto the end of @string
10258 String* /*new*/ append(char* val) {
10259 return g_string_append(&this, val);
10262 // Adds a byte onto the end of a #GString, expanding
10263 // it if necessary.
10264 // RETURNS: @string
10265 // <c>: the byte to append onto the end of @string
10266 String* /*new*/ append_c(char c) {
10267 return g_string_append_c(&this, c);
10270 // Appends @len bytes of @val to @string. Because @len is
10271 // provided, @val may contain embedded nuls and need not
10272 // be nul-terminated.
10274 // Since this function does not stop at nul bytes, it is
10275 // the caller's responsibility to ensure that @val has at
10276 // least @len addressable bytes.
10277 // RETURNS: @string
10278 // <val>: bytes to append
10279 // <len>: number of bytes of @val to use
10280 String* /*new*/ append_len(char* val, ssize_t len) {
10281 return g_string_append_len(&this, val, len);
10284 // Unintrospectable method: append_printf() / g_string_append_printf()
10285 // Appends a formatted string onto the end of a #GString.
10286 // This function is similar to g_string_printf() except
10287 // that the text is appended to the #GString.
10288 // <format>: the string format. See the printf() documentation
10289 /+ Not available -- variadic methods unsupported - use the C function directly.
10290 alias g_string_append_printf append_printf; // Variadic
10293 // Converts a Unicode character into UTF-8, and appends it
10294 // to the string.
10295 // RETURNS: @string
10296 // <wc>: a Unicode character
10297 String* /*new*/ append_unichar(dchar wc) {
10298 return g_string_append_unichar(&this, wc);
10301 // Appends @unescaped to @string, escaped any characters that
10302 // are reserved in URIs using URI-style escape sequences.
10303 // RETURNS: @string
10304 // <unescaped>: a string
10305 // <reserved_chars_allowed>: a string of reserved characters allowed to be used, or %NULL
10306 // <allow_utf8>: set %TRUE if the escaped string may include UTF8 characters
10307 String* /*new*/ append_uri_escaped(char* unescaped, char* reserved_chars_allowed, int allow_utf8) {
10308 return g_string_append_uri_escaped(&this, unescaped, reserved_chars_allowed, allow_utf8);
10311 // Unintrospectable method: append_vprintf() / g_string_append_vprintf()
10312 // Appends a formatted string onto the end of a #GString.
10313 // This function is similar to g_string_append_printf()
10314 // except that the arguments to the format string are passed
10315 // as a va_list.
10316 // <format>: the string format. See the printf() documentation
10317 // <args>: the list of arguments to insert in the output
10318 void append_vprintf(char* format, va_list args) {
10319 g_string_append_vprintf(&this, format, args);
10322 // Converts all upper case ASCII letters to lower case ASCII letters.
10324 // characters converted to lower case in place, with
10325 // semantics that exactly match g_ascii_tolower().
10326 // RETURNS: passed-in @string pointer, with all the upper case
10327 String* /*new*/ ascii_down() {
10328 return g_string_ascii_down(&this);
10331 // Converts all lower case ASCII letters to upper case ASCII letters.
10333 // characters converted to upper case in place, with
10334 // semantics that exactly match g_ascii_toupper().
10335 // RETURNS: passed-in @string pointer, with all the lower case
10336 String* /*new*/ ascii_up() {
10337 return g_string_ascii_up(&this);
10340 // Copies the bytes from a string into a #GString,
10341 // destroying any previous contents. It is rather like
10342 // the standard strcpy() function, except that you do not
10343 // have to worry about having enough space to copy the string.
10344 // RETURNS: @string
10345 // <rval>: the string to copy into @string
10346 String* /*new*/ assign(char* rval) {
10347 return g_string_assign(&this, rval);
10350 // Converts a #GString to lowercase.
10353 // Deprecated:2.2: This function uses the locale-specific
10354 // tolower() function, which is almost never the right thing.
10355 // Use g_string_ascii_down() or g_utf8_strdown() instead.
10356 // RETURNS: the #GString.
10357 String* /*new*/ down() {
10358 return g_string_down(&this);
10361 // Compares two strings for equality, returning %TRUE if they are equal.
10362 // For use with #GHashTable.
10364 // same bytes
10365 // RETURNS: %TRUE if they strings are the same length and contain the
10366 // <v2>: another #GString
10367 int equal(String* v2) {
10368 return g_string_equal(&this, v2);
10371 // Removes @len bytes from a #GString, starting at position @pos.
10372 // The rest of the #GString is shifted down to fill the gap.
10373 // RETURNS: @string
10374 // <pos>: the position of the content to remove
10375 // <len>: the number of bytes to remove, or -1 to remove all following bytes
10376 String* /*new*/ erase(ssize_t pos, ssize_t len) {
10377 return g_string_erase(&this, pos, len);
10380 // Frees the memory allocated for the #GString.
10381 // If @free_segment is %TRUE it also frees the character data. If
10382 // it's %FALSE, the caller gains ownership of the buffer and must
10383 // free it after use with g_free().
10385 // (i.e. %NULL if @free_segment is %TRUE)
10386 // RETURNS: the character data of @string
10387 // <free_segment>: if %TRUE the actual character data is freed as well
10388 char* /*new*/ free(int free_segment) {
10389 return g_string_free(&this, free_segment);
10392 // Creates a hash code for @str; for use with #GHashTable.
10393 // RETURNS: hash code for @str
10394 uint hash() {
10395 return g_string_hash(&this);
10398 // Inserts a copy of a string into a #GString,
10399 // expanding it if necessary.
10400 // RETURNS: @string
10401 // <pos>: the position to insert the copy of the string
10402 // <val>: the string to insert
10403 String* /*new*/ insert(ssize_t pos, char* val) {
10404 return g_string_insert(&this, pos, val);
10407 // Inserts a byte into a #GString, expanding it if necessary.
10408 // RETURNS: @string
10409 // <pos>: the position to insert the byte
10410 // <c>: the byte to insert
10411 String* /*new*/ insert_c(ssize_t pos, char c) {
10412 return g_string_insert_c(&this, pos, c);
10415 // Inserts @len bytes of @val into @string at @pos.
10416 // Because @len is provided, @val may contain embedded
10417 // nuls and need not be nul-terminated. If @pos is -1,
10418 // bytes are inserted at the end of the string.
10420 // Since this function does not stop at nul bytes, it is
10421 // the caller's responsibility to ensure that @val has at
10422 // least @len addressable bytes.
10423 // RETURNS: @string
10424 // <pos>: position in @string where insertion should happen, or -1 for at the end
10425 // <val>: bytes to insert
10426 // <len>: number of bytes of @val to insert
10427 String* /*new*/ insert_len(ssize_t pos, char* val, ssize_t len) {
10428 return g_string_insert_len(&this, pos, val, len);
10431 // Converts a Unicode character into UTF-8, and insert it
10432 // into the string at the given position.
10433 // RETURNS: @string
10434 // <pos>: the position at which to insert character, or -1 to append at the end of the string
10435 // <wc>: a Unicode character
10436 String* /*new*/ insert_unichar(ssize_t pos, dchar wc) {
10437 return g_string_insert_unichar(&this, pos, wc);
10440 // Overwrites part of a string, lengthening it if necessary.
10441 // RETURNS: @string
10442 // <pos>: the position at which to start overwriting
10443 // <val>: the string that will overwrite the @string starting at @pos
10444 String* /*new*/ overwrite(size_t pos, char* val) {
10445 return g_string_overwrite(&this, pos, val);
10448 // Overwrites part of a string, lengthening it if necessary.
10449 // This function will work with embedded nuls.
10450 // RETURNS: @string
10451 // <pos>: the position at which to start overwriting
10452 // <val>: the string that will overwrite the @string starting at @pos
10453 // <len>: the number of bytes to write from @val
10454 String* /*new*/ overwrite_len(size_t pos, char* val, ssize_t len) {
10455 return g_string_overwrite_len(&this, pos, val, len);
10458 // Adds a string on to the start of a #GString,
10459 // expanding it if necessary.
10460 // RETURNS: @string
10461 // <val>: the string to prepend on the start of @string
10462 String* /*new*/ prepend(char* val) {
10463 return g_string_prepend(&this, val);
10466 // Adds a byte onto the start of a #GString,
10467 // expanding it if necessary.
10468 // RETURNS: @string
10469 // <c>: the byte to prepend on the start of the #GString
10470 String* /*new*/ prepend_c(char c) {
10471 return g_string_prepend_c(&this, c);
10474 // Prepends @len bytes of @val to @string.
10475 // Because @len is provided, @val may contain
10476 // embedded nuls and need not be nul-terminated.
10478 // Since this function does not stop at nul bytes,
10479 // it is the caller's responsibility to ensure that
10480 // @val has at least @len addressable bytes.
10481 // RETURNS: @string
10482 // <val>: bytes to prepend
10483 // <len>: number of bytes in @val to prepend
10484 String* /*new*/ prepend_len(char* val, ssize_t len) {
10485 return g_string_prepend_len(&this, val, len);
10488 // Converts a Unicode character into UTF-8, and prepends it
10489 // to the string.
10490 // RETURNS: @string
10491 // <wc>: a Unicode character
10492 String* /*new*/ prepend_unichar(dchar wc) {
10493 return g_string_prepend_unichar(&this, wc);
10496 // Unintrospectable method: printf() / g_string_printf()
10497 // Writes a formatted string into a #GString.
10498 // This is similar to the standard sprintf() function,
10499 // except that the #GString buffer automatically expands
10500 // to contain the results. The previous contents of the
10501 // #GString are destroyed.
10502 // <format>: the string format. See the printf() documentation
10503 /+ Not available -- variadic methods unsupported - use the C function directly.
10504 alias g_string_printf printf; // Variadic
10507 // Sets the length of a #GString. If the length is less than
10508 // the current length, the string will be truncated. If the
10509 // length is greater than the current length, the contents
10510 // of the newly added area are undefined. (However, as
10511 // always, string->str[string->len] will be a nul byte.)
10512 // RETURNS: @string
10513 // <len>: the new length
10514 String* /*new*/ set_size(size_t len) {
10515 return g_string_set_size(&this, len);
10518 // Cuts off the end of the GString, leaving the first @len bytes.
10519 // RETURNS: @string
10520 // <len>: the new size of @string
10521 String* /*new*/ truncate(size_t len) {
10522 return g_string_truncate(&this, len);
10525 // Converts a #GString to uppercase.
10528 // Deprecated:2.2: This function uses the locale-specific
10529 // toupper() function, which is almost never the right thing.
10530 // Use g_string_ascii_up() or g_utf8_strup() instead.
10531 // RETURNS: @string
10532 String* /*new*/ up() {
10533 return g_string_up(&this);
10536 // Unintrospectable method: vprintf() / g_string_vprintf()
10537 // Writes a formatted string into a #GString.
10538 // This function is similar to g_string_printf() except that
10539 // the arguments to the format string are passed as a va_list.
10540 // <format>: the string format. See the printf() documentation
10541 // <args>: the parameters to insert into the format string
10542 void vprintf(char* format, va_list args) {
10543 g_string_vprintf(&this, format, args);
10548 // An opaque data structure representing String Chunks. It should only
10549 // be accessed by using the following functions.
10550 struct StringChunk {
10552 // Frees all strings contained within the #GStringChunk.
10553 // After calling g_string_chunk_clear() it is not safe to
10554 // access any of the strings which were contained within it.
10555 void clear() {
10556 g_string_chunk_clear(&this);
10559 // Frees all memory allocated by the #GStringChunk.
10560 // After calling g_string_chunk_free() it is not safe to
10561 // access any of the strings which were contained within it.
10562 void free() {
10563 g_string_chunk_free(&this);
10566 // Adds a copy of @string to the #GStringChunk.
10567 // It returns a pointer to the new copy of the string
10568 // in the #GStringChunk. The characters in the string
10569 // can be changed, if necessary, though you should not
10570 // change anything after the end of the string.
10572 // Unlike g_string_chunk_insert_const(), this function
10573 // does not check for duplicates. Also strings added
10574 // with g_string_chunk_insert() will not be searched
10575 // by g_string_chunk_insert_const() when looking for
10576 // duplicates.
10578 // the #GStringChunk
10579 // RETURNS: a pointer to the copy of @string within
10580 // <string>: the string to add
10581 char* /*new*/ insert(char* string_) {
10582 return g_string_chunk_insert(&this, string_);
10585 // Adds a copy of @string to the #GStringChunk, unless the same
10586 // string has already been added to the #GStringChunk with
10587 // g_string_chunk_insert_const().
10589 // This function is useful if you need to copy a large number
10590 // of strings but do not want to waste space storing duplicates.
10591 // But you must remember that there may be several pointers to
10592 // the same string, and so any changes made to the strings
10593 // should be done very carefully.
10595 // Note that g_string_chunk_insert_const() will not return a
10596 // pointer to a string added with g_string_chunk_insert(), even
10597 // if they do match.
10599 // within the #GStringChunk
10600 // RETURNS: a pointer to the new or existing copy of @string
10601 // <string>: the string to add
10602 char* /*new*/ insert_const(char* string_) {
10603 return g_string_chunk_insert_const(&this, string_);
10606 // Adds a copy of the first @len bytes of @string to the #GStringChunk.
10607 // The copy is nul-terminated.
10609 // Since this function does not stop at nul bytes, it is the caller's
10610 // responsibility to ensure that @string has at least @len addressable
10611 // bytes.
10613 // The characters in the returned string can be changed, if necessary,
10614 // though you should not change anything after the end of the string.
10615 // RETURNS: a pointer to the copy of @string within the #GStringChunk
10616 // <string>: bytes to insert
10617 // <len>: number of bytes of @string to insert, or -1 to insert a nul-terminated string
10618 char* /*new*/ insert_len(char* string_, ssize_t len) {
10619 return g_string_chunk_insert_len(&this, string_, len);
10622 // Unintrospectable function: new() / g_string_chunk_new()
10623 // Creates a new #GStringChunk.
10624 // RETURNS: a new #GStringChunk
10625 // <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.
10626 static StringChunk* new_(size_t size) {
10627 return g_string_chunk_new(size);
10631 union SystemThread {
10632 char[4] data;
10633 double dummy_double;
10634 void* dummy_pointer;
10635 c_long dummy_long;
10638 struct TestCase {
10641 struct TestConfig {
10642 int test_initialized, test_quick, test_perf, test_verbose, test_quiet;
10646 // The type used for test case functions that take an extra pointer
10647 // argument.
10648 // <user_data>: the data provided when registering the test
10649 extern (C) alias void function (const(void)* user_data) TestDataFunc;
10652 // The type used for functions that operate on test fixtures. This is
10653 // used for the fixture setup and teardown functions as well as for the
10654 // testcases themselves.
10656 // @user_data is a pointer to the data that was given when registering
10657 // the test case.
10659 // @fixture will be a pointer to the area of memory allocated by the
10660 // test framework, of the size requested. If the requested size was
10661 // zero then @fixture will be equal to @user_data.
10662 // <fixture>: the test fixture
10663 // <user_data>: the data provided when registering the test
10664 extern (C) alias void function (void* fixture, const(void)* user_data) TestFixtureFunc;
10666 // The type used for test case functions.
10667 extern (C) alias void function () TestFunc;
10669 struct TestLogBuffer {
10670 private String* data;
10671 private GLib2.SList* msgs;
10673 // Internal function for gtester to free test log messages, no ABI guarantees provided.
10674 void free() {
10675 g_test_log_buffer_free(&this);
10678 // Unintrospectable method: pop() / g_test_log_buffer_pop()
10679 // Internal function for gtester to retrieve test log messages, no ABI guarantees provided.
10680 TestLogMsg* pop() {
10681 return g_test_log_buffer_pop(&this);
10683 // Internal function for gtester to decode test log messages, no ABI guarantees provided.
10684 void push(uint n_bytes, ubyte* bytes) {
10685 g_test_log_buffer_push(&this, n_bytes, bytes);
10688 // Unintrospectable function: new() / g_test_log_buffer_new()
10689 // Internal function for gtester to decode test log messages, no ABI guarantees provided.
10690 static TestLogBuffer* new_() {
10691 return g_test_log_buffer_new();
10696 // Specifies the prototype of fatal log handler functions.
10697 // RETURNS: %TRUE if the program should abort, %FALSE otherwise
10698 // <log_domain>: the log domain of the message
10699 // <log_level>: the log level of the message (including the fatal and recursion flags)
10700 // <message>: the message to process
10701 // <user_data>: user data, set in g_test_log_set_fatal_handler()
10702 extern (C) alias int function (char* log_domain, LogLevelFlags log_level, char* message, void* user_data) TestLogFatalFunc;
10704 struct TestLogMsg {
10705 TestLogType log_type;
10706 uint n_strings;
10707 char** strings;
10708 uint n_nums;
10709 c_long* nums;
10711 // Internal function for gtester to free test log messages, no ABI guarantees provided.
10712 void free() {
10713 g_test_log_msg_free(&this);
10717 enum TestLogType {
10718 NONE = 0,
10719 ERROR = 1,
10720 START_BINARY = 2,
10721 LIST_CASE = 3,
10722 SKIP_CASE = 4,
10723 START_CASE = 5,
10724 STOP_CASE = 6,
10725 MIN_RESULT = 7,
10726 MAX_RESULT = 8,
10727 MESSAGE = 9
10729 struct TestSuite {
10731 // Adds @test_case to @suite.
10732 // <test_case>: a #GTestCase
10733 void add(TestCase* test_case) {
10734 g_test_suite_add(&this, test_case);
10737 // Adds @nestedsuite to @suite.
10738 // <nestedsuite>: another #GTestSuite
10739 void add_suite(TestSuite* nestedsuite) {
10740 g_test_suite_add_suite(&this, nestedsuite);
10744 enum TestTrapFlags {
10745 SILENCE_STDOUT = 128,
10746 SILENCE_STDERR = 256,
10747 INHERIT_STDIN = 512
10750 // The #GThread struct represents a running thread. It has three public
10751 // read-only members, but the underlying struct is bigger, so you must
10752 // not copy this struct.
10754 // <note><para>Resources for a joinable thread are not fully released
10755 // until g_thread_join() is called for that thread.</para></note>
10756 struct Thread {
10757 private ThreadFunc func;
10758 private void* data;
10759 private int joinable;
10760 private ThreadPriority priority;
10763 // Unintrospectable method: join() / g_thread_join()
10764 // Waits until @thread finishes, i.e. the function @func, as given to
10765 // g_thread_create(), returns or g_thread_exit() is called by @thread.
10766 // All resources of @thread including the #GThread struct are released.
10767 // @thread must have been created with @joinable=%TRUE in
10768 // g_thread_create(). The value returned by @func or given to
10769 // g_thread_exit() by @thread is returned by this function.
10770 void* join() {
10771 return g_thread_join(&this);
10774 // Changes the priority of @thread to @priority.
10776 // <note><para>It is not guaranteed that threads with different
10777 // priorities really behave accordingly. On some systems (e.g. Linux)
10778 // there are no thread priorities. On other systems (e.g. Solaris) there
10779 // doesn't seem to be different scheduling for different priorities. All
10780 // in all try to avoid being dependent on priorities.</para></note>
10781 // <priority>: a new priority for @thread.
10782 void set_priority(ThreadPriority priority) {
10783 g_thread_set_priority(&this, priority);
10786 // Unintrospectable function: create_full() / g_thread_create_full()
10787 // This function creates a new thread with the priority @priority. If
10788 // the underlying thread implementation supports it, the thread gets a
10789 // stack size of @stack_size or the default value for the current
10790 // platform, if @stack_size is 0.
10792 // If @joinable is %TRUE, you can wait for this threads termination
10793 // calling g_thread_join(). Otherwise the thread will just disappear
10794 // when it terminates. If @bound is %TRUE, this thread will be
10795 // scheduled in the system scope, otherwise the implementation is free
10796 // to do scheduling in the process scope. The first variant is more
10797 // expensive resource-wise, but generally faster. On some systems (e.g.
10798 // Linux) all threads are bound.
10800 // The new thread executes the function @func with the argument @data.
10801 // If the thread was created successfully, it is returned.
10803 // @error can be %NULL to ignore errors, or non-%NULL to report errors.
10804 // The error is set, if and only if the function returns %NULL.
10806 // <note><para>It is not guaranteed that threads with different priorities
10807 // really behave accordingly. On some systems (e.g. Linux) there are no
10808 // thread priorities. On other systems (e.g. Solaris) there doesn't
10809 // seem to be different scheduling for different priorities. All in all
10810 // try to avoid being dependent on priorities. Use
10811 // %G_THREAD_PRIORITY_NORMAL here as a default.</para></note>
10813 // <note><para>Only use g_thread_create_full() if you really can't use
10814 // g_thread_create() instead. g_thread_create() does not take
10815 // @stack_size, @bound, and @priority as arguments, as they should only
10816 // be used in cases in which it is unavoidable.</para></note>
10817 // <func>: a function to execute in the new thread.
10818 // <data>: an argument to supply to the new thread.
10819 // <stack_size>: a stack size for the new thread.
10820 // <joinable>: should this thread be joinable?
10821 // <bound>: should this thread be bound to a system thread?
10822 // <priority>: a priority for the thread.
10823 static Thread* create_full(ThreadFunc func, void* data, c_ulong stack_size, int joinable, int bound, ThreadPriority priority, GLib2.Error** error=null) {
10824 return g_thread_create_full(func, data, stack_size, joinable, bound, priority, error);
10826 static Quark error_quark() {
10827 return g_thread_error_quark();
10830 // Exits the current thread. If another thread is waiting for that
10831 // thread using g_thread_join() and the current thread is joinable, the
10832 // waiting thread will be woken up and get @retval as the return value
10833 // of g_thread_join(). If the current thread is not joinable, @retval
10834 // is ignored. Calling
10836 // <informalexample>
10837 // <programlisting>
10838 // g_thread_exit (retval);
10839 // </programlisting>
10840 // </informalexample>
10842 // is equivalent to returning @retval from the function @func, as given
10843 // to g_thread_create().
10845 // <note><para>Never call g_thread_exit() from within a thread of a
10846 // #GThreadPool, as that will mess up the bookkeeping and lead to funny
10847 // and unwanted results.</para></note>
10848 // <retval>: the return value of this thread.
10849 static void exit(void* retval) {
10850 g_thread_exit(retval);
10853 // Unintrospectable function: foreach() / g_thread_foreach()
10854 // Call @thread_func on all existing #GThread structures. Note that
10855 // threads may decide to exit while @thread_func is running, so
10856 // without intimate knowledge about the lifetime of foreign threads,
10857 // @thread_func shouldn't access the GThread* pointer passed in as
10858 // first argument. However, @thread_func will not be called for threads
10859 // which are known to have exited already.
10861 // Due to thread lifetime checks, this function has an execution complexity
10862 // which is quadratic in the number of existing threads.
10863 // <thread_func>: function to call for all GThread structures
10864 // <user_data>: second argument to @thread_func
10865 static void foreach_(Func thread_func, void* user_data) {
10866 g_thread_foreach(thread_func, user_data);
10869 // Indicates if g_thread_init() has been called.
10870 // RETURNS: %TRUE if threads have been initialized.
10871 static int get_initialized() {
10872 return g_thread_get_initialized();
10875 // If you use GLib from more than one thread, you must initialize the
10876 // thread system by calling g_thread_init(). Most of the time you will
10877 // only have to call <literal>g_thread_init (NULL)</literal>.
10879 // <note><para>Do not call g_thread_init() with a non-%NULL parameter unless
10880 // you really know what you are doing.</para></note>
10882 // <note><para>g_thread_init() must not be called directly or indirectly as a
10883 // callback from GLib. Also no mutexes may be currently locked while
10884 // calling g_thread_init().</para></note>
10886 // <note><para>g_thread_init() changes the way in which #GTimer measures
10887 // elapsed time. As a consequence, timers that are running while
10888 // g_thread_init() is called may report unreliable times.</para></note>
10890 // Calling g_thread_init() multiple times is allowed (since version
10891 // 2.24), but nothing happens except for the first call. If the
10892 // argument is non-%NULL on such a call a warning will be printed, but
10893 // otherwise the argument is ignored.
10895 // If no thread system is available and @vtable is %NULL or if not all
10896 // elements of @vtable are non-%NULL, then g_thread_init() will abort.
10898 // <note><para>To use g_thread_init() in your program, you have to link with
10899 // the libraries that the command <command>pkg-config --libs
10900 // gthread-2.0</command> outputs. This is not the case for all the
10901 // other thread related functions of GLib. Those can be used without
10902 // having to link with the thread libraries.</para></note>
10903 // <vtable>: a function table of type #GThreadFunctions, that provides the entry points to the thread system to be used.
10904 static void init(ThreadFunctions* vtable) {
10905 g_thread_init(vtable);
10907 static void init_with_errorcheck_mutexes(ThreadFunctions* vtable) {
10908 g_thread_init_with_errorcheck_mutexes(vtable);
10911 // Unintrospectable function: self() / g_thread_self()
10912 // This functions returns the #GThread corresponding to the calling
10913 // thread.
10914 static Thread* self() {
10915 return g_thread_self();
10919 // Possible errors of thread related functions.
10920 enum ThreadError {
10921 THREAD_ERROR_AGAIN = 0
10924 // Unintrospectable callback: ThreadFunc() / ()
10925 // Specifies the type of the @func functions passed to
10926 // g_thread_create() or g_thread_create_full().
10927 // <data>: data passed to the thread.
10928 extern (C) alias void* function (void* data) ThreadFunc;
10931 // This function table is used by g_thread_init() to initialize the
10932 // thread system. The functions in the table are directly used by their
10933 // g_* prepended counterparts (described in this document). For
10934 // example, if you call g_mutex_new() then mutex_new() from the table
10935 // provided to g_thread_init() will be called.
10937 // <note><para>Do not use this struct unless you know what you are
10938 // doing.</para></note>
10939 struct ThreadFunctions {
10940 // Unintrospectable functionp: mutex_new() / ()
10941 extern (C) Mutex* function () mutex_new;
10942 extern (C) void function (Mutex* mutex) mutex_lock;
10943 extern (C) int function (Mutex* mutex) mutex_trylock;
10944 extern (C) void function (Mutex* mutex) mutex_unlock;
10945 extern (C) void function (Mutex* mutex) mutex_free;
10946 // Unintrospectable functionp: cond_new() / ()
10947 extern (C) Cond* function () cond_new;
10948 extern (C) void function (Cond* cond) cond_signal;
10949 extern (C) void function (Cond* cond) cond_broadcast;
10950 extern (C) void function (Cond* cond, Mutex* mutex) cond_wait;
10951 extern (C) int function (Cond* cond, Mutex* mutex, TimeVal* end_time) cond_timed_wait;
10952 extern (C) void function (Cond* cond) cond_free;
10953 // Unintrospectable functionp: private_new() / ()
10954 extern (C) Private* function (DestroyNotify destructor) private_new;
10955 // Unintrospectable functionp: private_get() / ()
10956 extern (C) void* function (Private* private_key) private_get;
10957 extern (C) void function (Private* private_key, void* data) private_set;
10958 // Unintrospectable functionp: thread_create() / ()
10959 extern (C) void function (ThreadFunc func, void* data, c_ulong stack_size, int joinable, int bound, ThreadPriority priority, void* thread, GLib2.Error** error=null) thread_create;
10960 extern (C) void function () thread_yield;
10961 extern (C) void function (void* thread) thread_join;
10962 extern (C) void function () thread_exit;
10963 extern (C) void function (void* thread, ThreadPriority priority) thread_set_priority;
10964 extern (C) void function (void* thread) thread_self;
10965 extern (C) int function (void* thread1, void* thread2) thread_equal;
10969 // The #GThreadPool struct represents a thread pool. It has three
10970 // public read-only members, but the underlying struct is bigger, so
10971 // you must not copy this struct.
10972 struct ThreadPool {
10973 Func func;
10974 void* user_data;
10975 int exclusive;
10978 // Frees all resources allocated for @pool.
10980 // If @immediate is %TRUE, no new task is processed for
10981 // @pool. Otherwise @pool is not freed before the last task is
10982 // processed. Note however, that no thread of this pool is
10983 // interrupted, while processing a task. Instead at least all still
10984 // running threads can finish their tasks before the @pool is freed.
10986 // If @wait_ is %TRUE, the functions does not return before all tasks
10987 // to be processed (dependent on @immediate, whether all or only the
10988 // currently running) are ready. Otherwise the function returns immediately.
10990 // After calling this function @pool must not be used anymore.
10991 // <immediate>: should @pool shut down immediately?
10992 // <wait_>: should the function wait for all tasks to be finished?
10993 void free(int immediate, int wait_) {
10994 g_thread_pool_free(&this, immediate, wait_);
10997 // Returns the maximal number of threads for @pool.
10998 // RETURNS: the maximal number of threads
10999 int get_max_threads() {
11000 return g_thread_pool_get_max_threads(&this);
11003 // Returns the number of threads currently running in @pool.
11004 // RETURNS: the number of threads currently running
11005 uint get_num_threads() {
11006 return g_thread_pool_get_num_threads(&this);
11009 // Inserts @data into the list of tasks to be executed by @pool. When
11010 // the number of currently running threads is lower than the maximal
11011 // allowed number of threads, a new thread is started (or reused) with
11012 // the properties given to g_thread_pool_new (). Otherwise @data stays
11013 // in the queue until a thread in this pool finishes its previous task
11014 // and processes @data.
11016 // @error can be %NULL to ignore errors, or non-%NULL to report
11017 // errors. An error can only occur when a new thread couldn't be
11018 // created. In that case @data is simply appended to the queue of work
11019 // to do.
11020 // <data>: a new task for @pool
11021 void push(void* data, GLib2.Error** error=null) {
11022 g_thread_pool_push(&this, data, error);
11025 // Sets the maximal allowed number of threads for @pool. A value of -1
11026 // means, that the maximal number of threads is unlimited.
11028 // Setting @max_threads to 0 means stopping all work for @pool. It is
11029 // effectively frozen until @max_threads is set to a non-zero value
11030 // again.
11032 // A thread is never terminated while calling @func, as supplied by
11033 // g_thread_pool_new (). Instead the maximal number of threads only
11034 // has effect for the allocation of new threads in g_thread_pool_push().
11035 // A new thread is allocated, whenever the number of currently
11036 // running threads in @pool is smaller than the maximal number.
11038 // @error can be %NULL to ignore errors, or non-%NULL to report
11039 // errors. An error can only occur when a new thread couldn't be
11040 // created.
11041 // <max_threads>: a new maximal number of threads for @pool
11042 void set_max_threads(int max_threads, GLib2.Error** error=null) {
11043 g_thread_pool_set_max_threads(&this, max_threads, error);
11046 // Unintrospectable method: set_sort_function() / g_thread_pool_set_sort_function()
11047 // Sets the function used to sort the list of tasks. This allows the
11048 // tasks to be processed by a priority determined by @func, and not
11049 // just in the order in which they were added to the pool.
11051 // Note, if the maximum number of threads is more than 1, the order
11052 // that threads are executed cannot be guaranteed 100%. Threads are
11053 // scheduled by the operating system and are executed at random. It
11054 // cannot be assumed that threads are executed in the order they are
11055 // created.
11056 // <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.
11057 // <user_data>: user data passed to @func.
11058 void set_sort_function(CompareDataFunc func, void* user_data) {
11059 g_thread_pool_set_sort_function(&this, func, user_data);
11062 // Returns the number of tasks still unprocessed in @pool.
11063 // RETURNS: the number of unprocessed tasks
11064 uint unprocessed() {
11065 return g_thread_pool_unprocessed(&this);
11068 // This function will return the maximum @interval that a thread will
11069 // wait in the thread pool for new tasks before being stopped.
11071 // If this function returns 0, threads waiting in the thread pool for
11072 // new work are not stopped.
11074 // thread pool before stopping the thread (1/1000ths of a second).
11075 // RETURNS: the maximum @interval to wait for new tasks in the
11076 static uint get_max_idle_time() {
11077 return g_thread_pool_get_max_idle_time();
11080 // Returns the maximal allowed number of unused threads.
11081 // RETURNS: the maximal number of unused threads
11082 static int get_max_unused_threads() {
11083 return g_thread_pool_get_max_unused_threads();
11086 // Returns the number of currently unused threads.
11087 // RETURNS: the number of currently unused threads
11088 static uint get_num_unused_threads() {
11089 return g_thread_pool_get_num_unused_threads();
11092 // Unintrospectable function: new() / g_thread_pool_new()
11093 // This function creates a new thread pool.
11095 // Whenever you call g_thread_pool_push(), either a new thread is
11096 // created or an unused one is reused. At most @max_threads threads
11097 // are running concurrently for this thread pool. @max_threads = -1
11098 // allows unlimited threads to be created for this thread pool. The
11099 // newly created or reused thread now executes the function @func with
11100 // the two arguments. The first one is the parameter to
11101 // g_thread_pool_push() and the second one is @user_data.
11103 // The parameter @exclusive determines, whether the thread pool owns
11104 // all threads exclusive or whether the threads are shared
11105 // globally. If @exclusive is %TRUE, @max_threads threads are started
11106 // immediately and they will run exclusively for this thread pool until
11107 // it is destroyed by g_thread_pool_free(). If @exclusive is %FALSE,
11108 // threads are created, when needed and shared between all
11109 // non-exclusive thread pools. This implies that @max_threads may not
11110 // be -1 for exclusive thread pools.
11112 // @error can be %NULL to ignore errors, or non-%NULL to report
11113 // errors. An error can only occur when @exclusive is set to %TRUE and
11114 // not all @max_threads threads could be created.
11115 // RETURNS: the new #GThreadPool
11116 // <func>: a function to execute in the threads of the new thread pool
11117 // <user_data>: user data that is handed over to @func every time it is called
11118 // <max_threads>: the maximal number of threads to execute concurrently in the new thread pool, -1 means no limit
11119 // <exclusive>: should this thread pool be exclusive?
11120 static ThreadPool* new_(Func func, void* user_data, int max_threads, int exclusive, GLib2.Error** error=null) {
11121 return g_thread_pool_new(func, user_data, max_threads, exclusive, error);
11124 // This function will set the maximum @interval that a thread waiting
11125 // in the pool for new tasks can be idle for before being
11126 // stopped. This function is similar to calling
11127 // g_thread_pool_stop_unused_threads() on a regular timeout, except,
11128 // this is done on a per thread basis.
11130 // By setting @interval to 0, idle threads will not be stopped.
11132 // This function makes use of g_async_queue_timed_pop () using
11133 // @interval.
11134 // <interval>: the maximum @interval (1/1000ths of a second) a thread can be idle.
11135 static void set_max_idle_time(uint interval) {
11136 g_thread_pool_set_max_idle_time(interval);
11139 // Sets the maximal number of unused threads to @max_threads. If
11140 // @max_threads is -1, no limit is imposed on the number of unused
11141 // threads.
11142 // <max_threads>: maximal number of unused threads
11143 static void set_max_unused_threads(int max_threads) {
11144 g_thread_pool_set_max_unused_threads(max_threads);
11147 // Stops all currently unused threads. This does not change the
11148 // maximal number of unused threads. This function can be used to
11149 // regularly stop all unused threads e.g. from g_timeout_add().
11150 static void stop_unused_threads() {
11151 g_thread_pool_stop_unused_threads();
11156 // Specifies the priority of a thread.
11158 // <note><para>It is not guaranteed that threads with different priorities
11159 // really behave accordingly. On some systems (e.g. Linux) there are no
11160 // thread priorities. On other systems (e.g. Solaris) there doesn't
11161 // seem to be different scheduling for different priorities. All in all
11162 // try to avoid being dependent on priorities.</para></note>
11163 enum ThreadPriority {
11164 LOW = 0,
11165 NORMAL = 1,
11166 HIGH = 2,
11167 URGENT = 3
11170 // Disambiguates a given time in two ways.
11172 // First, specifies if the given time is in universal or local time.
11174 // Second, if the time is in local time, specifies if it is local
11175 // standard time or local daylight time. This is important for the case
11176 // where the same local time occurs twice (during daylight savings time
11177 // transitions, for example).
11178 enum TimeType {
11179 STANDARD = 0,
11180 DAYLIGHT = 1,
11181 UNIVERSAL = 2
11183 struct TimeVal {
11184 c_long tv_sec, tv_usec;
11187 // Adds the given number of microseconds to @time_. @microseconds can
11188 // also be negative to decrease the value of @time_.
11189 // <microseconds>: number of microseconds to add to @time
11190 void add(c_long microseconds) {
11191 g_time_val_add(&this, microseconds);
11194 // Converts @time_ into an ISO 8601 encoded string, relative to the
11195 // Coordinated Universal Time (UTC).
11196 // RETURNS: a newly allocated string containing an ISO 8601 date
11197 char* /*new*/ to_iso8601() {
11198 return g_time_val_to_iso8601(&this);
11201 // Converts a string containing an ISO 8601 encoded date and time
11202 // to a #GTimeVal and puts it into @time_.
11203 // RETURNS: %TRUE if the conversion was successful.
11204 // <iso_date>: an ISO 8601 encoded date string
11205 // <time_>: a #GTimeVal
11206 static int from_iso8601(char* iso_date, TimeVal* time_) {
11207 return g_time_val_from_iso8601(iso_date, time_);
11212 // #GDateTime is an opaque structure whose members cannot be accessed
11213 // directly.
11214 struct TimeZone /* Version 2.26 */ {
11216 // Finds an interval within @tz that corresponds to the given @time_,
11217 // possibly adjusting @time_ if required to fit into an interval.
11218 // The meaning of @time_ depends on @type.
11220 // This function is similar to g_time_zone_find_interval(), with the
11221 // difference that it always succeeds (by making the adjustments
11222 // described below).
11224 // In any of the cases where g_time_zone_find_interval() succeeds then
11225 // this function returns the same value, without modifying @time_.
11227 // This function may, however, modify @time_ in order to deal with
11228 // non-existent times. If the non-existent local @time_ of 02:30 were
11229 // requested on March 13th 2010 in Toronto then this function would
11230 // adjust @time_ to be 03:00 and return the interval containing the
11231 // adjusted time.
11232 // RETURNS: the interval containing @time_, never -1
11233 // <type>: the #GTimeType of @time_
11234 // <time_>: a pointer to a number of seconds since January 1, 1970
11235 int adjust_time(TimeType type, long* time_) {
11236 return g_time_zone_adjust_time(&this, type, time_);
11239 // Finds an the interval within @tz that corresponds to the given @time_.
11240 // The meaning of @time_ depends on @type.
11242 // If @type is %G_TIME_TYPE_UNIVERSAL then this function will always
11243 // succeed (since universal time is monotonic and continuous).
11245 // Otherwise @time_ is treated is local time. The distinction between
11246 // %G_TIME_TYPE_STANDARD and %G_TIME_TYPE_DAYLIGHT is ignored except in
11247 // the case that the given @time_ is ambiguous. In Toronto, for example,
11248 // 01:30 on November 7th 2010 occurred twice (once inside of daylight
11249 // savings time and the next, an hour later, outside of daylight savings
11250 // time). In this case, the different value of @type would result in a
11251 // different interval being returned.
11253 // It is still possible for this function to fail. In Toronto, for
11254 // example, 02:00 on March 14th 2010 does not exist (due to the leap
11255 // forward to begin daylight savings time). -1 is returned in that
11256 // case.
11257 // RETURNS: the interval containing @time_, or -1 in case of failure
11258 // <type>: the #GTimeType of @time_
11259 // <time_>: a number of seconds since January 1, 1970
11260 int find_interval(TimeType type, long time_) {
11261 return g_time_zone_find_interval(&this, type, time_);
11264 // Determines the time zone abbreviation to be used during a particular
11265 // @interval of time in the time zone @tz.
11267 // For example, in Toronto this is currently "EST" during the winter
11268 // months and "EDT" during the summer months when daylight savings time
11269 // is in effect.
11270 // RETURNS: the time zone abbreviation, which belongs to @tz
11271 // <interval>: an interval within the timezone
11272 char* get_abbreviation(int interval) {
11273 return g_time_zone_get_abbreviation(&this, interval);
11276 // Determines the offset to UTC in effect during a particular @interval
11277 // of time in the time zone @tz.
11279 // The offset is the number of seconds that you add to UTC time to
11280 // arrive at local time for @tz (ie: negative numbers for time zones
11281 // west of GMT, positive numbers for east).
11283 // local time in @tz
11284 // RETURNS: the number of seconds that should be added to UTC to get the
11285 // <interval>: an interval within the timezone
11286 int get_offset(int interval) {
11287 return g_time_zone_get_offset(&this, interval);
11290 // Determines if daylight savings time is in effect during a particular
11291 // @interval of time in the time zone @tz.
11292 // RETURNS: %TRUE if daylight savings time is in effect
11293 // <interval>: an interval within the timezone
11294 int is_dst(int interval) {
11295 return g_time_zone_is_dst(&this, interval);
11298 // Unintrospectable method: ref() / g_time_zone_ref()
11299 // Increases the reference count on @tz.
11300 // RETURNS: a new reference to @tz.
11301 TimeZone* ref_() {
11302 return g_time_zone_ref(&this);
11304 // Decreases the reference count on @tz.
11305 void unref() {
11306 g_time_zone_unref(&this);
11309 // Unintrospectable function: new() / g_time_zone_new()
11310 // Creates a #GTimeZone corresponding to @identifier.
11312 // @identifier can either be an RFC3339/ISO 8601 time offset or
11313 // something that would pass as a valid value for the
11314 // <varname>TZ</varname> environment variable (including %NULL).
11316 // Valid RFC3339 time offsets are <literal>"Z"</literal> (for UTC) or
11317 // <literal>"±hh:mm"</literal>. ISO 8601 additionally specifies
11318 // <literal>"±hhmm"</literal> and <literal>"±hh"</literal>.
11320 // The <varname>TZ</varname> environment variable typically corresponds
11321 // to the name of a file in the zoneinfo database, but there are many
11322 // other possibilities. Note that those other possibilities are not
11323 // currently implemented, but are planned.
11325 // g_time_zone_new_local() calls this function with the value of the
11326 // <varname>TZ</varname> environment variable. This function itself is
11327 // independent of the value of <varname>TZ</varname>, but if @identifier
11328 // is %NULL then <filename>/etc/localtime</filename> will be consulted
11329 // to discover the correct timezone.
11331 // See <ulink
11332 // url='http://tools.ietf.org/html/rfc3339#section-5.6'>RFC3339
11333 // §5.6</ulink> for a precise definition of valid RFC3339 time offsets
11334 // (the <varname>time-offset</varname> expansion) and ISO 8601 for the
11335 // full list of valid time offsets. See <ulink
11336 // url='http://www.gnu.org/s/libc/manual/html_node/TZ-Variable.html'>The
11337 // GNU C Library manual</ulink> for an explanation of the possible
11338 // values of the <varname>TZ</varname> environment variable.
11340 // You should release the return value by calling g_time_zone_unref()
11341 // when you are done with it.
11342 // RETURNS: the requested timezone
11343 // <identifier>: a timezone identifier
11344 static TimeZone* new_(char* identifier=null) {
11345 return g_time_zone_new(identifier);
11348 // Unintrospectable function: new_local() / g_time_zone_new_local()
11349 // Creates a #GTimeZone corresponding to local time. The local time
11350 // zone may change between invocations to this function; for example,
11351 // if the system administrator changes it.
11353 // This is equivalent to calling g_time_zone_new() with the value of the
11354 // <varname>TZ</varname> environment variable (including the possibility
11355 // of %NULL).
11357 // You should release the return value by calling g_time_zone_unref()
11358 // when you are done with it.
11359 // RETURNS: the local timezone
11360 static TimeZone* new_local() {
11361 return g_time_zone_new_local();
11364 // Unintrospectable function: new_utc() / g_time_zone_new_utc()
11365 // Creates a #GTimeZone corresponding to UTC.
11367 // This is equivalent to calling g_time_zone_new() with a value like
11368 // "Z", "UTC", "+00", etc.
11370 // You should release the return value by calling g_time_zone_unref()
11371 // when you are done with it.
11372 // RETURNS: the universal timezone
11373 static TimeZone* new_utc() {
11374 return g_time_zone_new_utc();
11378 // Opaque datatype that records a start time.
11379 struct Timer {
11381 // Resumes a timer that has previously been stopped with
11382 // g_timer_stop(). g_timer_stop() must be called before using this
11383 // function.
11384 void continue_() {
11385 g_timer_continue(&this);
11387 // Destroys a timer, freeing associated resources.
11388 void destroy() {
11389 g_timer_destroy(&this);
11392 // If @timer has been started but not stopped, obtains the time since
11393 // the timer was started. If @timer has been stopped, obtains the
11394 // elapsed time between the time it was started and the time it was
11395 // stopped. The return value is the number of seconds elapsed,
11396 // including any fractional part. The @microseconds out parameter is
11397 // essentially useless.
11399 // <warning><para>
11400 // Calling initialization functions, in particular g_thread_init(), while a
11401 // timer is running will cause invalid return values from this function.
11402 // </para></warning>
11403 // <microseconds>: return location for the fractional part of seconds elapsed, in microseconds (that is, the total number of microseconds elapsed, modulo 1000000), or %NULL
11404 double elapsed(c_ulong* microseconds) {
11405 return g_timer_elapsed(&this, microseconds);
11408 // This function is useless; it's fine to call g_timer_start() on an
11409 // already-started timer to reset the start time, so g_timer_reset()
11410 // serves no purpose.
11411 void reset() {
11412 g_timer_reset(&this);
11415 // Marks a start time, so that future calls to g_timer_elapsed() will
11416 // report the time since g_timer_start() was called. g_timer_new()
11417 // automatically marks the start time, so no need to call
11418 // g_timer_start() immediately after creating the timer.
11419 void start() {
11420 g_timer_start(&this);
11423 // Marks an end time, so calls to g_timer_elapsed() will return the
11424 // difference between this end time and the start time.
11425 void stop() {
11426 g_timer_stop(&this);
11429 // Unintrospectable function: new() / g_timer_new()
11430 // Creates a new timer, and starts timing (i.e. g_timer_start() is
11431 // implicitly called for you).
11432 static Timer* new_() {
11433 return g_timer_new();
11437 enum TokenType {
11438 EOF = 0,
11439 LEFT_PAREN = 40,
11440 RIGHT_PAREN = 41,
11441 LEFT_CURLY = 123,
11442 RIGHT_CURLY = 125,
11443 LEFT_BRACE = 91,
11444 RIGHT_BRACE = 93,
11445 EQUAL_SIGN = 61,
11446 COMMA = 44,
11447 NONE = 256,
11448 ERROR = 257,
11449 CHAR = 258,
11450 BINARY = 259,
11451 OCTAL = 260,
11452 INT = 261,
11453 HEX = 262,
11454 FLOAT = 263,
11455 STRING = 264,
11456 SYMBOL = 265,
11457 IDENTIFIER = 266,
11458 IDENTIFIER_NULL = 267,
11459 COMMENT_SINGLE = 268,
11460 COMMENT_MULTI = 269,
11461 LAST = 270
11463 union TokenValue {
11464 void* v_symbol;
11465 char* v_identifier;
11466 c_ulong v_binary, v_octal, v_int;
11467 ulong v_int64;
11468 double v_float;
11469 c_ulong v_hex;
11470 char* v_string, v_comment;
11471 ubyte v_char;
11472 uint v_error;
11476 // The type of functions which are used to translate user-visible
11477 // strings, for <option>--help</option> output.
11479 // The returned string is owned by GLib and must not be freed.
11480 // RETURNS: a translation of the string for the current locale.
11481 // <str>: the untranslated string
11482 // <data>: user data specified when installing the function, e.g. in g_option_group_set_translate_func()
11483 extern (C) alias char* function (char* str, void* data) TranslateFunc;
11485 struct TrashStack {
11486 TrashStack* next;
11488 static uint height(TrashStack** stack_p) {
11489 return g_trash_stack_height(stack_p);
11491 // Unintrospectable function: peek() / g_trash_stack_peek()
11492 static void* peek(TrashStack** stack_p) {
11493 return g_trash_stack_peek(stack_p);
11495 // Unintrospectable function: pop() / g_trash_stack_pop()
11496 static void* pop(TrashStack** stack_p) {
11497 return g_trash_stack_pop(stack_p);
11499 static void push(TrashStack** stack_p, void* data_p) {
11500 g_trash_stack_push(stack_p, data_p);
11505 // Specifies which nodes are visited during several of the tree
11506 // functions, including g_node_traverse() and g_node_find().
11507 enum TraverseFlags {
11508 LEAVES = 1,
11509 NON_LEAVES = 2,
11510 ALL = 3,
11511 MASK = 3,
11512 LEAFS = 1,
11513 NON_LEAFS = 2
11516 // Specifies the type of function passed to g_tree_traverse(). It is
11517 // passed the key and value of each node, together with the @user_data
11518 // parameter passed to g_tree_traverse(). If the function returns
11519 // %TRUE, the traversal is stopped.
11520 // <key>: a key of a #GTree node.
11521 // <value>: the value corresponding to the key.
11522 // <data>: user data passed to g_tree_traverse().
11523 extern (C) alias int function (void* key, void* value, void* data) TraverseFunc;
11526 // Specifies the type of traveral performed by g_tree_traverse(),
11527 // g_node_traverse() and g_node_find().
11528 enum TraverseType {
11529 IN_ORDER = 0,
11530 PRE_ORDER = 1,
11531 POST_ORDER = 2,
11532 LEVEL_ORDER = 3
11535 // The <structname>GTree</structname> struct is an opaque data
11536 // structure representing a <link
11537 // linkend="glib-Balanced-Binary-Trees">Balanced Binary Tree</link>. It
11538 // should be accessed only by using the following functions.
11539 struct Tree {
11541 // Removes all keys and values from the #GTree and decreases its
11542 // reference count by one. If keys and/or values are dynamically
11543 // allocated, you should either free them first or create the #GTree
11544 // using g_tree_new_full(). In the latter case the destroy functions
11545 // you supplied will be called on all keys and values before destroying
11546 // the #GTree.
11547 void destroy() {
11548 g_tree_destroy(&this);
11551 // Unintrospectable method: foreach() / g_tree_foreach()
11552 // Calls the given function for each of the key/value pairs in the #GTree.
11553 // The function is passed the key and value of each pair, and the given
11554 // @data parameter. The tree is traversed in sorted order.
11556 // The tree may not be modified while iterating over it (you can't
11557 // add/remove items). To remove all items matching a predicate, you need
11558 // to add each item to a list in your #GTraverseFunc as you walk over
11559 // the tree, then walk the list and remove each item.
11560 // <func>: the function to call for each node visited. If this function returns %TRUE, the traversal is stopped.
11561 // <user_data>: user data to pass to the function.
11562 void foreach_(TraverseFunc func, void* user_data) {
11563 g_tree_foreach(&this, func, user_data);
11566 // Gets the height of a #GTree.
11568 // If the #GTree contains no nodes, the height is 0.
11569 // If the #GTree contains only one root node the height is 1.
11570 // If the root node has children the height is 2, etc.
11571 // RETURNS: the height of the #GTree.
11572 int height() {
11573 return g_tree_height(&this);
11576 // Inserts a key/value pair into a #GTree. If the given key already exists
11577 // in the #GTree its corresponding value is set to the new value. If you
11578 // supplied a value_destroy_func when creating the #GTree, the old value is
11579 // freed using that function. If you supplied a @key_destroy_func when
11580 // creating the #GTree, the passed key is freed using that function.
11582 // The tree is automatically 'balanced' as new key/value pairs are added,
11583 // so that the distance from the root to every leaf is as small as possible.
11584 // <key>: the key to insert.
11585 // <value>: the value corresponding to the key.
11586 void insert(void* key, void* value) {
11587 g_tree_insert(&this, key, value);
11590 // Unintrospectable method: lookup() / g_tree_lookup()
11591 // Gets the value corresponding to the given key. Since a #GTree is
11592 // automatically balanced as key/value pairs are added, key lookup is very
11593 // fast.
11595 // not found.
11596 // RETURNS: the value corresponding to the key, or %NULL if the key was
11597 // <key>: the key to look up.
11598 void* lookup(const(void)* key) {
11599 return g_tree_lookup(&this, key);
11602 // Looks up a key in the #GTree, returning the original key and the
11603 // associated value and a #gboolean which is %TRUE if the key was found. This
11604 // is useful if you need to free the memory allocated for the original key,
11605 // for example before calling g_tree_remove().
11606 // RETURNS: %TRUE if the key was found in the #GTree.
11607 // <lookup_key>: the key to look up.
11608 // <orig_key>: returns the original key.
11609 // <value>: returns the value associated with the key.
11610 int lookup_extended(const(void)* lookup_key, void** orig_key, void** value) {
11611 return g_tree_lookup_extended(&this, lookup_key, orig_key, value);
11614 // Gets the number of nodes in a #GTree.
11615 // RETURNS: the number of nodes in the #GTree.
11616 int nnodes() {
11617 return g_tree_nnodes(&this);
11620 // Unintrospectable method: ref() / g_tree_ref()
11621 // Increments the reference count of @tree by one. It is safe to call
11622 // this function from any thread.
11623 // RETURNS: the passed in #GTree.
11624 Tree* ref_() {
11625 return g_tree_ref(&this);
11628 // Removes a key/value pair from a #GTree.
11630 // If the #GTree was created using g_tree_new_full(), the key and value
11631 // are freed using the supplied destroy functions, otherwise you have to
11632 // make sure that any dynamically allocated values are freed yourself.
11633 // If the key does not exist in the #GTree, the function does nothing.
11635 // nothing)
11636 // RETURNS: %TRUE if the key was found (prior to 2.8, this function returned
11637 // <key>: the key to remove.
11638 int remove(const(void)* key) {
11639 return g_tree_remove(&this, key);
11642 // Inserts a new key and value into a #GTree similar to g_tree_insert().
11643 // The difference is that if the key already exists in the #GTree, it gets
11644 // replaced by the new key. If you supplied a @value_destroy_func when
11645 // creating the #GTree, the old value is freed using that function. If you
11646 // supplied a @key_destroy_func when creating the #GTree, the old key is
11647 // freed using that function.
11649 // The tree is automatically 'balanced' as new key/value pairs are added,
11650 // so that the distance from the root to every leaf is as small as possible.
11651 // <key>: the key to insert.
11652 // <value>: the value corresponding to the key.
11653 void replace(void* key, void* value) {
11654 g_tree_replace(&this, key, value);
11657 // Unintrospectable method: search() / g_tree_search()
11658 // Searches a #GTree using @search_func.
11660 // The @search_func is called with a pointer to the key of a key/value
11661 // pair in the tree, and the passed in @user_data. If @search_func returns
11662 // 0 for a key/value pair, then the corresponding value is returned as
11663 // the result of g_tree_search(). If @search_func returns -1, searching
11664 // will proceed among the key/value pairs that have a smaller key; if
11665 // @search_func returns 1, searching will proceed among the key/value
11666 // pairs that have a larger key.
11668 // the key was not found.
11669 // RETURNS: the value corresponding to the found key, or %NULL if
11670 // <search_func>: a function used to search the #GTree
11671 // <user_data>: the data passed as the second argument to @search_func
11672 void* search(CompareFunc search_func, const(void)* user_data) {
11673 return g_tree_search(&this, search_func, user_data);
11676 // Removes a key and its associated value from a #GTree without calling
11677 // the key and value destroy functions.
11679 // If the key does not exist in the #GTree, the function does nothing.
11681 // nothing)
11682 // RETURNS: %TRUE if the key was found (prior to 2.8, this function returned
11683 // <key>: the key to remove.
11684 int steal(const(void)* key) {
11685 return g_tree_steal(&this, key);
11688 // Unintrospectable method: traverse() / g_tree_traverse()
11689 // Calls the given function for each node in the #GTree.
11691 // Deprecated:2.2: The order of a balanced tree is somewhat arbitrary. If you
11692 // just want to visit all nodes in sorted order, use g_tree_foreach()
11693 // instead. If you really need to visit nodes in a different order, consider
11694 // using an <link linkend="glib-N-ary-Trees">N-ary Tree</link>.
11695 // <traverse_func>: the function to call for each node visited. If this function returns %TRUE, the traversal is stopped.
11696 // <traverse_type>: the order in which nodes are visited, one of %G_IN_ORDER, %G_PRE_ORDER and %G_POST_ORDER.
11697 // <user_data>: user data to pass to the function.
11698 void traverse(TraverseFunc traverse_func, TraverseType traverse_type, void* user_data) {
11699 g_tree_traverse(&this, traverse_func, traverse_type, user_data);
11702 // Decrements the reference count of @tree by one. If the reference count
11703 // drops to 0, all keys and values will be destroyed (if destroy
11704 // functions were specified) and all memory allocated by @tree will be
11705 // released.
11707 // It is safe to call this function from any thread.
11708 void unref() {
11709 g_tree_unref(&this);
11712 // Unintrospectable function: new() / g_tree_new()
11713 // Creates a new #GTree.
11714 // RETURNS: a new #GTree.
11715 // <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.
11716 static Tree* new_(CompareFunc key_compare_func) {
11717 return g_tree_new(key_compare_func);
11720 // Unintrospectable function: new_full() / g_tree_new_full()
11721 // Creates a new #GTree like g_tree_new() and allows to specify functions
11722 // to free the memory allocated for the key and value that get called when
11723 // removing the entry from the #GTree.
11724 // RETURNS: a new #GTree.
11725 // <key_compare_func>: qsort()-style comparison function.
11726 // <key_compare_data>: data to pass to comparison function.
11727 // <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.
11728 // <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.
11729 static Tree* new_full(CompareDataFunc key_compare_func, void* key_compare_data, DestroyNotify key_destroy_func, DestroyNotify value_destroy_func) {
11730 return g_tree_new_full(key_compare_func, key_compare_data, key_destroy_func, value_destroy_func);
11733 // Unintrospectable function: new_with_data() / g_tree_new_with_data()
11734 // Creates a new #GTree with a comparison function that accepts user data.
11735 // See g_tree_new() for more details.
11736 // RETURNS: a new #GTree.
11737 // <key_compare_func>: qsort()-style comparison function.
11738 // <key_compare_data>: data to pass to comparison function.
11739 static Tree* new_with_data(CompareDataFunc key_compare_func, void* key_compare_data) {
11740 return g_tree_new_with_data(key_compare_func, key_compare_data);
11745 // The #GTuples struct is used to return records (or tuples) from the
11746 // #GRelation by g_relation_select(). It only contains one public
11747 // member - the number of records that matched. To access the matched
11748 // records, you must use g_tuples_index().
11749 struct Tuples {
11750 uint len;
11753 // Frees the records which were returned by g_relation_select(). This
11754 // should always be called after g_relation_select() when you are
11755 // finished with the records. The records are not removed from the
11756 // #GRelation.
11757 void destroy() {
11758 g_tuples_destroy(&this);
11761 // Unintrospectable method: index() / g_tuples_index()
11762 // Gets a field from the records returned by g_relation_select(). It
11763 // returns the given field of the record at the given index. The
11764 // returned value should not be changed.
11765 // <index_>: the index of the record.
11766 // <field>: the field to return.
11767 void* index(int index_, int field) {
11768 return g_tuples_index(&this, index_, field);
11772 enum URI_RESERVED_CHARS_GENERIC_DELIMITERS = ":/?#[]@";
11773 enum URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS = "!$&'()*+,;=";
11774 enum int USEC_PER_SEC = 1000000;
11776 // These are the possible line break classifications.
11778 // The five Hangul types were added in Unicode 4.1, so, has been
11779 // introduced in GLib 2.10. Note that new types may be added in the future.
11780 // Applications should be ready to handle unknown values.
11781 // They may be regarded as %G_UNICODE_BREAK_UNKNOWN.
11783 // See <ulink url="http://www.unicode.org/unicode/reports/tr14/">http://www.unicode.org/unicode/reports/tr14/</ulink>.
11784 enum UnicodeBreakType {
11785 MANDATORY = 0,
11786 CARRIAGE_RETURN = 1,
11787 LINE_FEED = 2,
11788 COMBINING_MARK = 3,
11789 SURROGATE = 4,
11790 ZERO_WIDTH_SPACE = 5,
11791 INSEPARABLE = 6,
11792 NON_BREAKING_GLUE = 7,
11793 CONTINGENT = 8,
11794 SPACE = 9,
11795 AFTER = 10,
11796 BEFORE = 11,
11797 BEFORE_AND_AFTER = 12,
11798 HYPHEN = 13,
11799 NON_STARTER = 14,
11800 OPEN_PUNCTUATION = 15,
11801 CLOSE_PUNCTUATION = 16,
11802 QUOTATION = 17,
11803 EXCLAMATION = 18,
11804 IDEOGRAPHIC = 19,
11805 NUMERIC = 20,
11806 INFIX_SEPARATOR = 21,
11807 SYMBOL = 22,
11808 ALPHABETIC = 23,
11809 PREFIX = 24,
11810 POSTFIX = 25,
11811 COMPLEX_CONTEXT = 26,
11812 AMBIGUOUS = 27,
11813 UNKNOWN = 28,
11814 NEXT_LINE = 29,
11815 WORD_JOINER = 30,
11816 HANGUL_L_JAMO = 31,
11817 HANGUL_V_JAMO = 32,
11818 HANGUL_T_JAMO = 33,
11819 HANGUL_LV_SYLLABLE = 34,
11820 HANGUL_LVT_SYLLABLE = 35,
11821 CLOSE_PARANTHESIS = 36
11824 // The #GUnicodeScript enumeration identifies different writing
11825 // systems. The values correspond to the names as defined in the
11826 // Unicode standard. The enumeration has been added in GLib 2.14,
11827 // and is interchangeable with #PangoScript.
11829 // Note that new types may be added in the future. Applications
11830 // should be ready to handle unknown values.
11831 // See <ulink
11832 // url="http://www.unicode.org/reports/tr24/">Unicode Standard Annex
11833 // #24: Script names</ulink>.
11834 enum UnicodeScript {
11835 INVALID_CODE = -1,
11836 COMMON = 0,
11837 INHERITED = 1,
11838 ARABIC = 2,
11839 ARMENIAN = 3,
11840 BENGALI = 4,
11841 BOPOMOFO = 5,
11842 CHEROKEE = 6,
11843 COPTIC = 7,
11844 CYRILLIC = 8,
11845 DESERET = 9,
11846 DEVANAGARI = 10,
11847 ETHIOPIC = 11,
11848 GEORGIAN = 12,
11849 GOTHIC = 13,
11850 GREEK = 14,
11851 GUJARATI = 15,
11852 GURMUKHI = 16,
11853 HAN = 17,
11854 HANGUL = 18,
11855 HEBREW = 19,
11856 HIRAGANA = 20,
11857 KANNADA = 21,
11858 KATAKANA = 22,
11859 KHMER = 23,
11860 LAO = 24,
11861 LATIN = 25,
11862 MALAYALAM = 26,
11863 MONGOLIAN = 27,
11864 MYANMAR = 28,
11865 OGHAM = 29,
11866 OLD_ITALIC = 30,
11867 ORIYA = 31,
11868 RUNIC = 32,
11869 SINHALA = 33,
11870 SYRIAC = 34,
11871 TAMIL = 35,
11872 TELUGU = 36,
11873 THAANA = 37,
11874 THAI = 38,
11875 TIBETAN = 39,
11876 CANADIAN_ABORIGINAL = 40,
11877 YI = 41,
11878 TAGALOG = 42,
11879 HANUNOO = 43,
11880 BUHID = 44,
11881 TAGBANWA = 45,
11882 BRAILLE = 46,
11883 CYPRIOT = 47,
11884 LIMBU = 48,
11885 OSMANYA = 49,
11886 SHAVIAN = 50,
11887 LINEAR_B = 51,
11888 TAI_LE = 52,
11889 UGARITIC = 53,
11890 NEW_TAI_LUE = 54,
11891 BUGINESE = 55,
11892 GLAGOLITIC = 56,
11893 TIFINAGH = 57,
11894 SYLOTI_NAGRI = 58,
11895 OLD_PERSIAN = 59,
11896 KHAROSHTHI = 60,
11897 UNKNOWN = 61,
11898 BALINESE = 62,
11899 CUNEIFORM = 63,
11900 PHOENICIAN = 64,
11901 PHAGS_PA = 65,
11902 NKO = 66,
11903 KAYAH_LI = 67,
11904 LEPCHA = 68,
11905 REJANG = 69,
11906 SUNDANESE = 70,
11907 SAURASHTRA = 71,
11908 CHAM = 72,
11909 OL_CHIKI = 73,
11910 VAI = 74,
11911 CARIAN = 75,
11912 LYCIAN = 76,
11913 LYDIAN = 77,
11914 AVESTAN = 78,
11915 BAMUM = 79,
11916 EGYPTIAN_HIEROGLYPHS = 80,
11917 IMPERIAL_ARAMAIC = 81,
11918 INSCRIPTIONAL_PAHLAVI = 82,
11919 INSCRIPTIONAL_PARTHIAN = 83,
11920 JAVANESE = 84,
11921 KAITHI = 85,
11922 LISU = 86,
11923 MEETEI_MAYEK = 87,
11924 OLD_SOUTH_ARABIAN = 88,
11925 OLD_TURKIC = 89,
11926 SAMARITAN = 90,
11927 TAI_THAM = 91,
11928 TAI_VIET = 92,
11929 BATAK = 93,
11930 BRAHMI = 94,
11931 MANDAIC = 95
11934 // These are the possible character classifications from the
11935 // Unicode specification.
11936 // See <ulink url="http://www.unicode.org/Public/UNIDATA/UnicodeData.html">http://www.unicode.org/Public/UNIDATA/UnicodeData.html</ulink>.
11937 enum UnicodeType {
11938 CONTROL = 0,
11939 FORMAT = 1,
11940 UNASSIGNED = 2,
11941 PRIVATE_USE = 3,
11942 SURROGATE = 4,
11943 LOWERCASE_LETTER = 5,
11944 MODIFIER_LETTER = 6,
11945 OTHER_LETTER = 7,
11946 TITLECASE_LETTER = 8,
11947 UPPERCASE_LETTER = 9,
11948 SPACING_MARK = 10,
11949 ENCLOSING_MARK = 11,
11950 NON_SPACING_MARK = 12,
11951 DECIMAL_NUMBER = 13,
11952 LETTER_NUMBER = 14,
11953 OTHER_NUMBER = 15,
11954 CONNECT_PUNCTUATION = 16,
11955 DASH_PUNCTUATION = 17,
11956 CLOSE_PUNCTUATION = 18,
11957 FINAL_PUNCTUATION = 19,
11958 INITIAL_PUNCTUATION = 20,
11959 OTHER_PUNCTUATION = 21,
11960 OPEN_PUNCTUATION = 22,
11961 CURRENCY_SYMBOL = 23,
11962 MODIFIER_SYMBOL = 24,
11963 MATH_SYMBOL = 25,
11964 OTHER_SYMBOL = 26,
11965 LINE_SEPARATOR = 27,
11966 PARAGRAPH_SEPARATOR = 28,
11967 SPACE_SEPARATOR = 29
11970 // These are logical ids for special directories which are defined
11971 // depending on the platform used. You should use g_get_user_special_dir()
11972 // to retrieve the full path associated to the logical id.
11974 // The #GUserDirectory enumeration can be extended at later date. Not
11975 // every platform has a directory for every logical id in this
11976 // enumeration.
11977 enum UserDirectory /* Version 2.14 */ {
11978 DIRECTORY_DESKTOP = 0,
11979 DIRECTORY_DOCUMENTS = 1,
11980 DIRECTORY_DOWNLOAD = 2,
11981 DIRECTORY_MUSIC = 3,
11982 DIRECTORY_PICTURES = 4,
11983 DIRECTORY_PUBLIC_SHARE = 5,
11984 DIRECTORY_TEMPLATES = 6,
11985 DIRECTORY_VIDEOS = 7,
11986 N_DIRECTORIES = 8
11989 // #GVariant is a variant datatype; it stores a value along with
11990 // information about the type of that value. The range of possible
11991 // values is determined by the type. The type system used by #GVariant
11992 // is #GVariantType.
11994 // #GVariant instances always have a type and a value (which are given
11995 // at construction time). The type and value of a #GVariant instance
11996 // can never change other than by the #GVariant itself being
11997 // destroyed. A #GVariant cannot contain a pointer.
11999 // #GVariant is reference counted using g_variant_ref() and
12000 // g_variant_unref(). #GVariant also has floating reference counts --
12001 // see g_variant_ref_sink().
12003 // #GVariant is completely threadsafe. A #GVariant instance can be
12004 // concurrently accessed in any way from any number of threads without
12005 // problems.
12007 // #GVariant is heavily optimised for dealing with data in serialised
12008 // form. It works particularly well with data located in memory-mapped
12009 // files. It can perform nearly all deserialisation operations in a
12010 // small constant time, usually touching only a single memory page.
12011 // Serialised #GVariant data can also be sent over the network.
12013 // #GVariant is largely compatible with D-Bus. Almost all types of
12014 // #GVariant instances can be sent over D-Bus. See #GVariantType for
12015 // exceptions.
12017 // For convenience to C programmers, #GVariant features powerful
12018 // varargs-based value construction and destruction. This feature is
12019 // designed to be embedded in other libraries.
12021 // There is a Python-inspired text language for describing #GVariant
12022 // values. #GVariant includes a printer for this language and a parser
12023 // with type inferencing.
12025 // <refsect2>
12026 // <title>Memory Use</title>
12027 // <para>
12028 // #GVariant tries to be quite efficient with respect to memory use.
12029 // This section gives a rough idea of how much memory is used by the
12030 // current implementation. The information here is subject to change
12031 // in the future.
12032 // </para>
12033 // <para>
12034 // The memory allocated by #GVariant can be grouped into 4 broad
12035 // purposes: memory for serialised data, memory for the type
12036 // information cache, buffer management memory and memory for the
12037 // #GVariant structure itself.
12038 // </para>
12039 // <refsect3>
12040 // <title>Serialised Data Memory</title>
12041 // <para>
12042 // This is the memory that is used for storing GVariant data in
12043 // serialised form. This is what would be sent over the network or
12044 // what would end up on disk.
12045 // </para>
12046 // <para>
12047 // The amount of memory required to store a boolean is 1 byte. 16,
12048 // 32 and 64 bit integers and double precision floating point numbers
12049 // use their "natural" size. Strings (including object path and
12050 // signature strings) are stored with a nul terminator, and as such
12051 // use the length of the string plus 1 byte.
12052 // </para>
12053 // <para>
12054 // Maybe types use no space at all to represent the null value and
12055 // use the same amount of space (sometimes plus one byte) as the
12056 // equivalent non-maybe-typed value to represent the non-null case.
12057 // </para>
12058 // <para>
12059 // Arrays use the amount of space required to store each of their
12060 // members, concatenated. Additionally, if the items stored in an
12061 // array are not of a fixed-size (ie: strings, other arrays, etc)
12062 // then an additional framing offset is stored for each item. The
12063 // size of this offset is either 1, 2 or 4 bytes depending on the
12064 // overall size of the container. Additionally, extra padding bytes
12065 // are added as required for alignment of child values.
12066 // </para>
12067 // <para>
12068 // Tuples (including dictionary entries) use the amount of space
12069 // required to store each of their members, concatenated, plus one
12070 // framing offset (as per arrays) for each non-fixed-sized item in
12071 // the tuple, except for the last one. Additionally, extra padding
12072 // bytes are added as required for alignment of child values.
12073 // </para>
12074 // <para>
12075 // Variants use the same amount of space as the item inside of the
12076 // variant, plus 1 byte, plus the length of the type string for the
12077 // item inside the variant.
12078 // </para>
12079 // <para>
12080 // As an example, consider a dictionary mapping strings to variants.
12081 // In the case that the dictionary is empty, 0 bytes are required for
12082 // the serialisation.
12083 // </para>
12084 // <para>
12085 // If we add an item "width" that maps to the int32 value of 500 then
12086 // we will use 4 byte to store the int32 (so 6 for the variant
12087 // containing it) and 6 bytes for the string. The variant must be
12088 // aligned to 8 after the 6 bytes of the string, so that's 2 extra
12089 // bytes. 6 (string) + 2 (padding) + 6 (variant) is 14 bytes used
12090 // for the dictionary entry. An additional 1 byte is added to the
12091 // array as a framing offset making a total of 15 bytes.
12092 // </para>
12093 // <para>
12094 // If we add another entry, "title" that maps to a nullable string
12095 // that happens to have a value of null, then we use 0 bytes for the
12096 // null value (and 3 bytes for the variant to contain it along with
12097 // its type string) plus 6 bytes for the string. Again, we need 2
12098 // padding bytes. That makes a total of 6 + 2 + 3 = 11 bytes.
12099 // </para>
12100 // <para>
12101 // We now require extra padding between the two items in the array.
12102 // After the 14 bytes of the first item, that's 2 bytes required. We
12103 // now require 2 framing offsets for an extra two bytes. 14 + 2 + 11
12104 // + 2 = 29 bytes to encode the entire two-item dictionary.
12105 // </para>
12106 // </refsect3>
12107 // <refsect3>
12108 // <title>Type Information Cache</title>
12109 // <para>
12110 // For each GVariant type that currently exists in the program a type
12111 // information structure is kept in the type information cache. The
12112 // type information structure is required for rapid deserialisation.
12113 // </para>
12114 // <para>
12115 // Continuing with the above example, if a #GVariant exists with the
12116 // type "a{sv}" then a type information struct will exist for
12117 // "a{sv}", "{sv}", "s", and "v". Multiple uses of the same type
12118 // will share the same type information. Additionally, all
12119 // single-digit types are stored in read-only static memory and do
12120 // not contribute to the writable memory footprint of a program using
12121 // #GVariant.
12122 // </para>
12123 // <para>
12124 // Aside from the type information structures stored in read-only
12125 // memory, there are two forms of type information. One is used for
12126 // container types where there is a single element type: arrays and
12127 // maybe types. The other is used for container types where there
12128 // are multiple element types: tuples and dictionary entries.
12129 // </para>
12130 // <para>
12131 // Array type info structures are 6 * sizeof (void *), plus the
12132 // memory required to store the type string itself. This means that
12133 // on 32bit systems, the cache entry for "a{sv}" would require 30
12134 // bytes of memory (plus malloc overhead).
12135 // </para>
12136 // <para>
12137 // Tuple type info structures are 6 * sizeof (void *), plus 4 *
12138 // sizeof (void *) for each item in the tuple, plus the memory
12139 // required to store the type string itself. A 2-item tuple, for
12140 // example, would have a type information structure that consumed
12141 // writable memory in the size of 14 * sizeof (void *) (plus type
12142 // string) This means that on 32bit systems, the cache entry for
12143 // "{sv}" would require 61 bytes of memory (plus malloc overhead).
12144 // </para>
12145 // <para>
12146 // This means that in total, for our "a{sv}" example, 91 bytes of
12147 // type information would be allocated.
12148 // </para>
12149 // <para>
12150 // The type information cache, additionally, uses a #GHashTable to
12151 // store and lookup the cached items and stores a pointer to this
12152 // hash table in static storage. The hash table is freed when there
12153 // are zero items in the type cache.
12154 // </para>
12155 // <para>
12156 // Although these sizes may seem large it is important to remember
12157 // that a program will probably only have a very small number of
12158 // different types of values in it and that only one type information
12159 // structure is required for many different values of the same type.
12160 // </para>
12161 // </refsect3>
12162 // <refsect3>
12163 // <title>Buffer Management Memory</title>
12164 // <para>
12165 // #GVariant uses an internal buffer management structure to deal
12166 // with the various different possible sources of serialised data
12167 // that it uses. The buffer is responsible for ensuring that the
12168 // correct call is made when the data is no longer in use by
12169 // #GVariant. This may involve a g_free() or a g_slice_free() or
12170 // even g_mapped_file_unref().
12171 // </para>
12172 // <para>
12173 // One buffer management structure is used for each chunk of
12174 // serialised data. The size of the buffer management structure is 4
12175 // * (void *). On 32bit systems, that's 16 bytes.
12176 // </para>
12177 // </refsect3>
12178 // <refsect3>
12179 // <title>GVariant structure</title>
12180 // <para>
12181 // The size of a #GVariant structure is 6 * (void *). On 32 bit
12182 // systems, that's 24 bytes.
12183 // </para>
12184 // <para>
12185 // #GVariant structures only exist if they are explicitly created
12186 // with API calls. For example, if a #GVariant is constructed out of
12187 // serialised data for the example given above (with the dictionary)
12188 // then although there are 9 individual values that comprise the
12189 // entire dictionary (two keys, two values, two variants containing
12190 // the values, two dictionary entries, plus the dictionary itself),
12191 // only 1 #GVariant instance exists -- the one referring to the
12192 // dictionary.
12193 // </para>
12194 // <para>
12195 // If calls are made to start accessing the other values then
12196 // #GVariant instances will exist for those values only for as long
12197 // as they are in use (ie: until you call g_variant_unref()). The
12198 // type information is shared. The serialised data and the buffer
12199 // management structure for that serialised data is shared by the
12200 // child.
12201 // </para>
12202 // </refsect3>
12203 // <refsect3>
12204 // <title>Summary</title>
12205 // <para>
12206 // To put the entire example together, for our dictionary mapping
12207 // strings to variants (with two entries, as given above), we are
12208 // using 91 bytes of memory for type information, 29 byes of memory
12209 // for the serialised data, 16 bytes for buffer management and 24
12210 // bytes for the #GVariant instance, or a total of 160 bytes, plus
12211 // malloc overhead. If we were to use g_variant_get_child_value() to
12212 // access the two dictionary entries, we would use an additional 48
12213 // bytes. If we were to have other dictionaries of the same type, we
12214 // would use more memory for the serialised data and buffer
12215 // management for those dictionaries, but the type information would
12216 // be shared.
12217 // </para>
12218 // </refsect3>
12219 // </refsect2>
12220 struct Variant /* Version 2.24 */ {
12222 // Unintrospectable constructor: new() / g_variant_new()
12223 // Creates a new #GVariant instance.
12225 // Think of this function as an analogue to g_strdup_printf().
12227 // The type of the created instance and the arguments that are
12228 // expected by this function are determined by @format_string. See the
12229 // section on <link linkend='gvariant-format-strings'>GVariant Format
12230 // Strings</link>. Please note that the syntax of the format string is
12231 // very likely to be extended in the future.
12233 // The first character of the format string must not be '*' '?' '@' or
12234 // 'r'; in essence, a new #GVariant must always be constructed by this
12235 // function (and not merely passed through it unmodified).
12236 // RETURNS: a new floating #GVariant instance
12237 // <format_string>: a #GVariant format string
12238 alias g_variant_new new_; // Variadic
12240 // Creates a new #GVariant array from @children.
12242 // @child_type must be non-%NULL if @n_children is zero. Otherwise, the
12243 // child type is determined by inspecting the first element of the
12244 // @children array. If @child_type is non-%NULL then it must be a
12245 // definite type.
12247 // The items of the array are taken from the @children array. No entry
12248 // in the @children array may be %NULL.
12250 // All items in the array must have the same type, which must be the
12251 // same as @child_type, if given.
12253 // If the @children are floating references (see g_variant_ref_sink()), the
12254 // new instance takes ownership of them as if via g_variant_ref_sink().
12255 // RETURNS: a floating reference to a new #GVariant array
12256 // <child_type>: the element type of the new array
12257 // <children>: an array of #GVariant pointers, the children
12258 // <n_children>: the length of @children
12259 static Variant* new_array(VariantType* child_type, Variant** children, size_t n_children) {
12260 return g_variant_new_array(child_type, children, n_children);
12263 // Creates a new boolean #GVariant instance -- either %TRUE or %FALSE.
12264 // RETURNS: a floating reference to a new boolean #GVariant instance
12265 // <value>: a #gboolean value
12266 static Variant* new_boolean(int value) {
12267 return g_variant_new_boolean(value);
12270 // Creates a new byte #GVariant instance.
12271 // RETURNS: a floating reference to a new byte #GVariant instance
12272 // <value>: a #guint8 value
12273 static Variant* new_byte(ubyte value) {
12274 return g_variant_new_byte(value);
12277 // Creates an array-of-bytes #GVariant with the contents of @string.
12278 // This function is just like g_variant_new_string() except that the
12279 // string need not be valid utf8.
12281 // The nul terminator character at the end of the string is stored in
12282 // the array.
12283 // RETURNS: a floating reference to a new bytestring #GVariant instance
12284 // <string>: a normal nul-terminated string in no particular encoding
12285 static Variant* new_bytestring(ubyte* string_) {
12286 return g_variant_new_bytestring(string_);
12289 // Constructs an array of bytestring #GVariant from the given array of
12290 // strings.
12292 // If @length is -1 then @strv is %NULL-terminated.
12293 // RETURNS: a new floating #GVariant instance
12294 // <strv>: an array of strings
12295 // <length>: the length of @strv, or -1
12296 static Variant* new_bytestring_array(char** strv, ssize_t length) {
12297 return g_variant_new_bytestring_array(strv, length);
12300 // Creates a new dictionary entry #GVariant. @key and @value must be
12301 // non-%NULL. @key must be a value of a basic type (ie: not a container).
12303 // If the @key or @value are floating references (see g_variant_ref_sink()),
12304 // the new instance takes ownership of them as if via g_variant_ref_sink().
12305 // RETURNS: a floating reference to a new dictionary entry #GVariant
12306 // <key>: a basic #GVariant, the key
12307 // <value>: a #GVariant, the value
12308 static Variant* new_dict_entry(Variant* key, Variant* value) {
12309 return g_variant_new_dict_entry(key, value);
12312 // Creates a new double #GVariant instance.
12313 // RETURNS: a floating reference to a new double #GVariant instance
12314 // <value>: a #gdouble floating point value
12315 static Variant* new_double(double value) {
12316 return g_variant_new_double(value);
12319 // Creates a new #GVariant instance from serialised data.
12321 // @type is the type of #GVariant instance that will be constructed.
12322 // The interpretation of @data depends on knowing the type.
12324 // @data is not modified by this function and must remain valid with an
12325 // unchanging value until such a time as @notify is called with
12326 // @user_data. If the contents of @data change before that time then
12327 // the result is undefined.
12329 // If @data is trusted to be serialised data in normal form then
12330 // @trusted should be %TRUE. This applies to serialised data created
12331 // within this process or read from a trusted location on the disk (such
12332 // as a file installed in /usr/lib alongside your application). You
12333 // should set trusted to %FALSE if @data is read from the network, a
12334 // file in the user's home directory, etc.
12336 // @notify will be called with @user_data when @data is no longer
12337 // needed. The exact time of this call is unspecified and might even be
12338 // before this function returns.
12339 // RETURNS: a new floating #GVariant of type @type
12340 // <type>: a definite #GVariantType
12341 // <data>: the serialised data
12342 // <size>: the size of @data
12343 // <trusted>: %TRUE if @data is definitely in normal form
12344 // <notify>: function to call when @data is no longer needed
12345 // <user_data>: data for @notify
12346 static Variant* new_from_data(VariantType* type, const(ubyte)* data, size_t size, int trusted, DestroyNotify notify, void* user_data) {
12347 return g_variant_new_from_data(type, data, size, trusted, notify, user_data);
12350 // Creates a new handle #GVariant instance.
12352 // By convention, handles are indexes into an array of file descriptors
12353 // that are sent alongside a D-Bus message. If you're not interacting
12354 // with D-Bus, you probably don't need them.
12355 // RETURNS: a floating reference to a new handle #GVariant instance
12356 // <value>: a #gint32 value
12357 static Variant* new_handle(int value) {
12358 return g_variant_new_handle(value);
12361 // Creates a new int16 #GVariant instance.
12362 // RETURNS: a floating reference to a new int16 #GVariant instance
12363 // <value>: a #gint16 value
12364 static Variant* new_int16(short value) {
12365 return g_variant_new_int16(value);
12368 // Creates a new int32 #GVariant instance.
12369 // RETURNS: a floating reference to a new int32 #GVariant instance
12370 // <value>: a #gint32 value
12371 static Variant* new_int32(int value) {
12372 return g_variant_new_int32(value);
12375 // Creates a new int64 #GVariant instance.
12376 // RETURNS: a floating reference to a new int64 #GVariant instance
12377 // <value>: a #gint64 value
12378 static Variant* new_int64(long value) {
12379 return g_variant_new_int64(value);
12382 // Depending on if @child is %NULL, either wraps @child inside of a
12383 // maybe container or creates a Nothing instance for the given @type.
12385 // At least one of @child_type and @child must be non-%NULL.
12386 // If @child_type is non-%NULL then it must be a definite type.
12387 // If they are both non-%NULL then @child_type must be the type
12388 // of @child.
12390 // If @child is a floating reference (see g_variant_ref_sink()), the new
12391 // instance takes ownership of @child.
12392 // RETURNS: a floating reference to a new #GVariant maybe instance
12393 // <child_type>: the #GVariantType of the child, or %NULL
12394 // <child>: the child value, or %NULL
12395 static Variant* new_maybe(VariantType* child_type=null, Variant* child=null) {
12396 return g_variant_new_maybe(child_type, child);
12399 // Creates a D-Bus object path #GVariant with the contents of @string.
12400 // @string must be a valid D-Bus object path. Use
12401 // g_variant_is_object_path() if you're not sure.
12402 // RETURNS: a floating reference to a new object path #GVariant instance
12403 // <object_path>: a normal C nul-terminated string
12404 static Variant* new_object_path(char* object_path) {
12405 return g_variant_new_object_path(object_path);
12408 // Constructs an array of object paths #GVariant from the given array of
12409 // strings.
12411 // Each string must be a valid #GVariant object path; see
12412 // g_variant_is_object_path().
12414 // If @length is -1 then @strv is %NULL-terminated.
12415 // RETURNS: a new floating #GVariant instance
12416 // <strv>: an array of strings
12417 // <length>: the length of @strv, or -1
12418 static Variant* new_objv(char** strv, ssize_t length) {
12419 return g_variant_new_objv(strv, length);
12422 // Unintrospectable constructor: new_parsed() / g_variant_new_parsed()
12423 // Parses @format and returns the result.
12425 // point that a value may appear in the text, a '%' character followed
12426 // by a GVariant format string (as per g_variant_new()) may appear. In
12427 // that case, the same arguments are collected from the argument list as
12428 // g_variant_new() would have collected.
12430 // Consider this simple example:
12432 // <informalexample><programlisting>
12433 // g_variant_new_parsed ("[('one', 1), ('two', %i), (%s, 3)]", 2, "three");
12434 // </programlisting></informalexample>
12436 // In the example, the variable argument parameters are collected and
12437 // filled in as if they were part of the original string to produce the
12438 // result of <code>[('one', 1), ('two', 2), ('three', 3)]</code>.
12440 // This function is intended only to be used with @format as a string
12441 // literal. Any parse error is fatal to the calling process. If you
12442 // want to parse data from untrusted sources, use g_variant_parse().
12444 // You may not use this function to return, unmodified, a single
12445 // #GVariant pointer from the argument list. ie: @format may not solely
12446 // be anything along the lines of "%*", "%?", "%r", or anything starting
12447 // with "%@".
12448 // RETURNS: a new floating #GVariant instance
12449 // <format>: a text format #GVariant
12450 alias g_variant_new_parsed new_parsed; // Variadic
12452 // Unintrospectable constructor: new_parsed_va() / g_variant_new_parsed_va()
12453 // Parses @format and returns the result.
12455 // This is the version of g_variant_new_parsed() intended to be used
12456 // from libraries.
12458 // The return value will be floating if it was a newly created GVariant
12459 // instance. In the case that @format simply specified the collection
12460 // of a #GVariant pointer (eg: @format was "%*") then the collected
12461 // #GVariant pointer will be returned unmodified, without adding any
12462 // additional references.
12464 // In order to behave correctly in all cases it is necessary for the
12465 // calling function to g_variant_ref_sink() the return result before
12466 // returning control to the user that originally provided the pointer.
12467 // At this point, the caller will have their own full reference to the
12468 // result. This can also be done by adding the result to a container,
12469 // or by passing it to another g_variant_new() call.
12470 // RETURNS: a new, usually floating, #GVariant
12471 // <format>: a text format #GVariant
12472 // <app>: a pointer to a #va_list
12473 static Variant* /*new*/ new_parsed_va(char* format, va_list* app) {
12474 return g_variant_new_parsed_va(format, app);
12477 // Creates a D-Bus type signature #GVariant with the contents of
12478 // @string. @string must be a valid D-Bus type signature. Use
12479 // g_variant_is_signature() if you're not sure.
12480 // RETURNS: a floating reference to a new signature #GVariant instance
12481 // <signature>: a normal C nul-terminated string
12482 static Variant* new_signature(char* signature) {
12483 return g_variant_new_signature(signature);
12486 // Creates a string #GVariant with the contents of @string.
12488 // @string must be valid utf8.
12489 // RETURNS: a floating reference to a new string #GVariant instance
12490 // <string>: a normal utf8 nul-terminated string
12491 static Variant* new_string(char* string_) {
12492 return g_variant_new_string(string_);
12495 // Constructs an array of strings #GVariant from the given array of
12496 // strings.
12498 // If @length is -1 then @strv is %NULL-terminated.
12499 // RETURNS: a new floating #GVariant instance
12500 // <strv>: an array of strings
12501 // <length>: the length of @strv, or -1
12502 static Variant* new_strv(char** strv, ssize_t length) {
12503 return g_variant_new_strv(strv, length);
12506 // Creates a new tuple #GVariant out of the items in @children. The
12507 // type is determined from the types of @children. No entry in the
12508 // @children array may be %NULL.
12510 // If @n_children is 0 then the unit tuple is constructed.
12512 // If the @children are floating references (see g_variant_ref_sink()), the
12513 // new instance takes ownership of them as if via g_variant_ref_sink().
12514 // RETURNS: a floating reference to a new #GVariant tuple
12515 // <children>: the items to make the tuple out of
12516 // <n_children>: the length of @children
12517 static Variant* new_tuple(Variant** children, size_t n_children) {
12518 return g_variant_new_tuple(children, n_children);
12521 // Creates a new uint16 #GVariant instance.
12522 // RETURNS: a floating reference to a new uint16 #GVariant instance
12523 // <value>: a #guint16 value
12524 static Variant* new_uint16(ushort value) {
12525 return g_variant_new_uint16(value);
12528 // Creates a new uint32 #GVariant instance.
12529 // RETURNS: a floating reference to a new uint32 #GVariant instance
12530 // <value>: a #guint32 value
12531 static Variant* new_uint32(uint value) {
12532 return g_variant_new_uint32(value);
12535 // Creates a new uint64 #GVariant instance.
12536 // RETURNS: a floating reference to a new uint64 #GVariant instance
12537 // <value>: a #guint64 value
12538 static Variant* new_uint64(ulong value) {
12539 return g_variant_new_uint64(value);
12542 // Unintrospectable constructor: new_va() / g_variant_new_va()
12543 // This function is intended to be used by libraries based on
12544 // #GVariant that want to provide g_variant_new()-like functionality
12545 // to their users.
12547 // The API is more general than g_variant_new() to allow a wider range
12548 // of possible uses.
12550 // @format_string must still point to a valid format string, but it only
12551 // needs to be nul-terminated if @endptr is %NULL. If @endptr is
12552 // non-%NULL then it is updated to point to the first character past the
12553 // end of the format string.
12555 // @app is a pointer to a #va_list. The arguments, according to
12556 // @format_string, are collected from this #va_list and the list is left
12557 // pointing to the argument following the last.
12559 // These two generalisations allow mixing of multiple calls to
12560 // g_variant_new_va() and g_variant_get_va() within a single actual
12561 // varargs call by the user.
12563 // The return value will be floating if it was a newly created GVariant
12564 // instance (for example, if the format string was "(ii)"). In the case
12565 // that the format_string was '*', '?', 'r', or a format starting with
12566 // '@' then the collected #GVariant pointer will be returned unmodified,
12567 // without adding any additional references.
12569 // In order to behave correctly in all cases it is necessary for the
12570 // calling function to g_variant_ref_sink() the return result before
12571 // returning control to the user that originally provided the pointer.
12572 // At this point, the caller will have their own full reference to the
12573 // result. This can also be done by adding the result to a container,
12574 // or by passing it to another g_variant_new() call.
12575 // RETURNS: a new, usually floating, #GVariant
12576 // <format_string>: a string that is prefixed with a format string
12577 // <endptr>: location to store the end pointer, or %NULL
12578 // <app>: a pointer to a #va_list
12579 static Variant* /*new*/ new_va(char* format_string, char** endptr, va_list* app) {
12580 return g_variant_new_va(format_string, endptr, app);
12583 // Boxes @value. The result is a #GVariant instance representing a
12584 // variant containing the original value.
12586 // If @child is a floating reference (see g_variant_ref_sink()), the new
12587 // instance takes ownership of @child.
12588 // RETURNS: a floating reference to a new variant #GVariant instance
12589 // <value>: a #GVariant instance
12590 static Variant* new_variant(Variant* value) {
12591 return g_variant_new_variant(value);
12594 // Performs a byteswapping operation on the contents of @value. The
12595 // result is that all multi-byte numeric data contained in @value is
12596 // byteswapped. That includes 16, 32, and 64bit signed and unsigned
12597 // integers as well as file handles and double precision floating point
12598 // values.
12600 // This function is an identity mapping on any value that does not
12601 // contain multi-byte numeric data. That include strings, booleans,
12602 // bytes and containers containing only these things (recursively).
12604 // The returned value is always in normal form and is marked as trusted.
12605 // RETURNS: the byteswapped form of @value
12606 Variant* /*new*/ byteswap() {
12607 return g_variant_byteswap(&this);
12610 // Classifies @value according to its top-level type.
12611 // RETURNS: the #GVariantClass of @value
12612 VariantClass classify() {
12613 return g_variant_classify(&this);
12616 // Compares @one and @two.
12618 // The types of @one and @two are #gconstpointer only to allow use of
12619 // this function with #GTree, #GPtrArray, etc. They must each be a
12620 // #GVariant.
12622 // Comparison is only defined for basic types (ie: booleans, numbers,
12623 // strings). For booleans, %FALSE is less than %TRUE. Numbers are
12624 // ordered in the usual way. Strings are in ASCII lexographical order.
12626 // It is a programmer error to attempt to compare container values or
12627 // two values that have types that are not exactly equal. For example,
12628 // you cannot compare a 32-bit signed integer with a 32-bit unsigned
12629 // integer. Also note that this function is not particularly
12630 // well-behaved when it comes to comparison of doubles; in particular,
12631 // the handling of incomparable values (ie: NaN) is undefined.
12633 // If you only require an equality comparison, g_variant_equal() is more
12634 // general.
12635 // RETURNS: negative value if a &lt; b; zero if a = b; positive value if a &gt; b.
12636 // <two>: a #GVariant instance of the same type
12637 int compare(const(Variant)* two) {
12638 return g_variant_compare(&this, two);
12641 // Similar to g_variant_get_bytestring() except that instead of
12642 // returning a constant string, the string is duplicated.
12644 // The return value must be freed using g_free().
12645 // RETURNS: a newly allocated string
12646 // <length>: a pointer to a #gsize, to store the length (not including the nul terminator)
12647 ubyte* /*new*/ dup_bytestring(/*out*/ size_t* length=null) {
12648 return g_variant_dup_bytestring(&this, length);
12651 // Gets the contents of an array of array of bytes #GVariant. This call
12652 // makes a deep copy; the return result should be released with
12653 // g_strfreev().
12655 // If @length is non-%NULL then the number of elements in the result is
12656 // stored there. In any case, the resulting array will be
12657 // %NULL-terminated.
12659 // For an empty array, @length will be set to 0 and a pointer to a
12660 // %NULL pointer will be returned.
12661 // RETURNS: an array of strings
12662 // <length>: the length of the result, or %NULL
12663 char** /*new*/ dup_bytestring_array(/*out*/ size_t* length=null) {
12664 return g_variant_dup_bytestring_array(&this, length);
12667 // Gets the contents of an array of object paths #GVariant. This call
12668 // makes a deep copy; the return result should be released with
12669 // g_strfreev().
12671 // If @length is non-%NULL then the number of elements in the result
12672 // is stored there. In any case, the resulting array will be
12673 // %NULL-terminated.
12675 // For an empty array, @length will be set to 0 and a pointer to a
12676 // %NULL pointer will be returned.
12677 // RETURNS: an array of strings
12678 // <length>: the length of the result, or %NULL
12679 char** /*new*/ dup_objv(/*out*/ size_t* length=null) {
12680 return g_variant_dup_objv(&this, length);
12683 // Similar to g_variant_get_string() except that instead of returning
12684 // a constant string, the string is duplicated.
12686 // The string will always be utf8 encoded.
12688 // The return value must be freed using g_free().
12689 // RETURNS: a newly allocated string, utf8 encoded
12690 // <length>: a pointer to a #gsize, to store the length
12691 char* /*new*/ dup_string(/*out*/ size_t* length) {
12692 return g_variant_dup_string(&this, length);
12695 // Gets the contents of an array of strings #GVariant. This call
12696 // makes a deep copy; the return result should be released with
12697 // g_strfreev().
12699 // If @length is non-%NULL then the number of elements in the result
12700 // is stored there. In any case, the resulting array will be
12701 // %NULL-terminated.
12703 // For an empty array, @length will be set to 0 and a pointer to a
12704 // %NULL pointer will be returned.
12705 // RETURNS: an array of strings
12706 // <length>: the length of the result, or %NULL
12707 char** /*new*/ dup_strv(/*out*/ size_t* length=null) {
12708 return g_variant_dup_strv(&this, length);
12711 // Checks if @one and @two have the same type and value.
12713 // The types of @one and @two are #gconstpointer only to allow use of
12714 // this function with #GHashTable. They must each be a #GVariant.
12715 // RETURNS: %TRUE if @one and @two are equal
12716 // <two>: a #GVariant instance
12717 int equal(const(Variant)* two) {
12718 return g_variant_equal(&this, two);
12721 // Unintrospectable method: get() / g_variant_get()
12722 // Deconstructs a #GVariant instance.
12724 // Think of this function as an analogue to scanf().
12726 // The arguments that are expected by this function are entirely
12727 // determined by @format_string. @format_string also restricts the
12728 // permissible types of @value. It is an error to give a value with
12729 // an incompatible type. See the section on <link
12730 // linkend='gvariant-format-strings'>GVariant Format Strings</link>.
12731 // Please note that the syntax of the format string is very likely to be
12732 // extended in the future.
12733 // <format_string>: a #GVariant format string
12734 /+ Not available -- variadic methods unsupported - use the C function directly.
12735 alias g_variant_get get; // Variadic
12738 // Returns the boolean value of @value.
12740 // It is an error to call this function with a @value of any type
12741 // other than %G_VARIANT_TYPE_BOOLEAN.
12742 // RETURNS: %TRUE or %FALSE
12743 int get_boolean() {
12744 return g_variant_get_boolean(&this);
12747 // Returns the byte value of @value.
12749 // It is an error to call this function with a @value of any type
12750 // other than %G_VARIANT_TYPE_BYTE.
12751 // RETURNS: a #guchar
12752 ubyte get_byte() {
12753 return g_variant_get_byte(&this);
12756 // Returns the string value of a #GVariant instance with an
12757 // array-of-bytes type. The string has no particular encoding.
12759 // If the array does not end with a nul terminator character, the empty
12760 // string is returned. For this reason, you can always trust that a
12761 // non-%NULL nul-terminated string will be returned by this function.
12763 // If the array contains a nul terminator character somewhere other than
12764 // the last byte then the returned string is the string, up to the first
12765 // such nul character.
12767 // It is an error to call this function with a @value that is not an
12768 // array of bytes.
12770 // The return value remains valid as long as @value exists.
12771 // RETURNS: the constant string
12772 ubyte* get_bytestring() {
12773 return g_variant_get_bytestring(&this);
12776 // Gets the contents of an array of array of bytes #GVariant. This call
12777 // makes a shallow copy; the return result should be released with
12778 // g_free(), but the individual strings must not be modified.
12780 // If @length is non-%NULL then the number of elements in the result is
12781 // stored there. In any case, the resulting array will be
12782 // %NULL-terminated.
12784 // For an empty array, @length will be set to 0 and a pointer to a
12785 // %NULL pointer will be returned.
12786 // RETURNS: an array of constant strings
12787 // <length>: the length of the result, or %NULL
12788 char** /*new container*/ get_bytestring_array(/*out*/ size_t* length=null) {
12789 return g_variant_get_bytestring_array(&this, length);
12792 // Unintrospectable method: get_child() / g_variant_get_child()
12793 // Reads a child item out of a container #GVariant instance and
12794 // deconstructs it according to @format_string. This call is
12795 // essentially a combination of g_variant_get_child_value() and
12796 // g_variant_get().
12797 // <index_>: the index of the child to deconstruct
12798 // <format_string>: a #GVariant format string
12799 /+ Not available -- variadic methods unsupported - use the C function directly.
12800 alias g_variant_get_child get_child; // Variadic
12803 // Reads a child item out of a container #GVariant instance. This
12804 // includes variants, maybes, arrays, tuples and dictionary
12805 // entries. It is an error to call this function on any other type of
12806 // #GVariant.
12808 // It is an error if @index_ is greater than the number of child items
12809 // in the container. See g_variant_n_children().
12811 // This function is O(1).
12812 // RETURNS: the child at the specified index
12813 // <index_>: the index of the child to fetch
12814 Variant* /*new*/ get_child_value(size_t index_) {
12815 return g_variant_get_child_value(&this, index_);
12818 // Returns a pointer to the serialised form of a #GVariant instance.
12819 // The returned data may not be in fully-normalised form if read from an
12820 // untrusted source. The returned data must not be freed; it remains
12821 // valid for as long as @value exists.
12823 // If @value is a fixed-sized value that was deserialised from a
12824 // corrupted serialised container then %NULL may be returned. In this
12825 // case, the proper thing to do is typically to use the appropriate
12826 // number of nul bytes in place of @value. If @value is not fixed-sized
12827 // then %NULL is never returned.
12829 // In the case that @value is already in serialised form, this function
12830 // is O(1). If the value is not already in serialised form,
12831 // serialisation occurs implicitly and is approximately O(n) in the size
12832 // of the result.
12833 // RETURNS: the serialised form of @value, or %NULL
12834 const(void)* get_data() {
12835 return g_variant_get_data(&this);
12838 // Returns the double precision floating point value of @value.
12840 // It is an error to call this function with a @value of any type
12841 // other than %G_VARIANT_TYPE_DOUBLE.
12842 // RETURNS: a #gdouble
12843 double get_double() {
12844 return g_variant_get_double(&this);
12847 // Provides access to the serialised data for an array of fixed-sized
12848 // items.
12850 // @value must be an array with fixed-sized elements. Numeric types are
12851 // fixed-size as are tuples containing only other fixed-sized types.
12853 // @element_size must be the size of a single element in the array. For
12854 // example, if calling this function for an array of 32 bit integers,
12855 // you might say <code>sizeof (gint32)</code>. This value isn't used
12856 // except for the purpose of a double-check that the form of the
12857 // seralised data matches the caller's expectation.
12859 // @n_elements, which must be non-%NULL is set equal to the number of
12860 // items in the array.
12861 // RETURNS: a pointer to the fixed array
12862 // <n_elements>: a pointer to the location to store the number of items
12863 // <element_size>: the size of each element
12864 const(void)* get_fixed_array(/*out*/ size_t* n_elements, size_t element_size) {
12865 return g_variant_get_fixed_array(&this, n_elements, element_size);
12868 // Returns the 32-bit signed integer value of @value.
12870 // It is an error to call this function with a @value of any type other
12871 // than %G_VARIANT_TYPE_HANDLE.
12873 // By convention, handles are indexes into an array of file descriptors
12874 // that are sent alongside a D-Bus message. If you're not interacting
12875 // with D-Bus, you probably don't need them.
12876 // RETURNS: a #gint32
12877 int get_handle() {
12878 return g_variant_get_handle(&this);
12881 // Returns the 16-bit signed integer value of @value.
12883 // It is an error to call this function with a @value of any type
12884 // other than %G_VARIANT_TYPE_INT16.
12885 // RETURNS: a #gint16
12886 short get_int16() {
12887 return g_variant_get_int16(&this);
12890 // Returns the 32-bit signed integer value of @value.
12892 // It is an error to call this function with a @value of any type
12893 // other than %G_VARIANT_TYPE_INT32.
12894 // RETURNS: a #gint32
12895 int get_int32() {
12896 return g_variant_get_int32(&this);
12899 // Returns the 64-bit signed integer value of @value.
12901 // It is an error to call this function with a @value of any type
12902 // other than %G_VARIANT_TYPE_INT64.
12903 // RETURNS: a #gint64
12904 long get_int64() {
12905 return g_variant_get_int64(&this);
12908 // Given a maybe-typed #GVariant instance, extract its value. If the
12909 // value is Nothing, then this function returns %NULL.
12910 // RETURNS: the contents of @value, or %NULL
12911 Variant* /*new*/ get_maybe() {
12912 return g_variant_get_maybe(&this);
12915 // Gets a #GVariant instance that has the same value as @value and is
12916 // trusted to be in normal form.
12918 // If @value is already trusted to be in normal form then a new
12919 // reference to @value is returned.
12921 // If @value is not already trusted, then it is scanned to check if it
12922 // is in normal form. If it is found to be in normal form then it is
12923 // marked as trusted and a new reference to it is returned.
12925 // If @value is found not to be in normal form then a new trusted
12926 // #GVariant is created with the same value as @value.
12928 // It makes sense to call this function if you've received #GVariant
12929 // data from untrusted sources and you want to ensure your serialised
12930 // output is definitely in normal form.
12931 // RETURNS: a trusted #GVariant
12932 Variant* /*new*/ get_normal_form() {
12933 return g_variant_get_normal_form(&this);
12936 // Gets the contents of an array of object paths #GVariant. This call
12937 // makes a shallow copy; the return result should be released with
12938 // g_free(), but the individual strings must not be modified.
12940 // If @length is non-%NULL then the number of elements in the result
12941 // is stored there. In any case, the resulting array will be
12942 // %NULL-terminated.
12944 // For an empty array, @length will be set to 0 and a pointer to a
12945 // %NULL pointer will be returned.
12946 // RETURNS: an array of constant strings
12947 // <length>: the length of the result, or %NULL
12948 char** /*new container*/ get_objv(/*out*/ size_t* length=null) {
12949 return g_variant_get_objv(&this, length);
12952 // Determines the number of bytes that would be required to store @value
12953 // with g_variant_store().
12955 // If @value has a fixed-sized type then this function always returned
12956 // that fixed size.
12958 // In the case that @value is already in serialised form or the size has
12959 // already been calculated (ie: this function has been called before)
12960 // then this function is O(1). Otherwise, the size is calculated, an
12961 // operation which is approximately O(n) in the number of values
12962 // involved.
12963 // RETURNS: the serialised size of @value
12964 size_t get_size() {
12965 return g_variant_get_size(&this);
12968 // Returns the string value of a #GVariant instance with a string
12969 // type. This includes the types %G_VARIANT_TYPE_STRING,
12970 // %G_VARIANT_TYPE_OBJECT_PATH and %G_VARIANT_TYPE_SIGNATURE.
12972 // The string will always be utf8 encoded.
12974 // If @length is non-%NULL then the length of the string (in bytes) is
12975 // returned there. For trusted values, this information is already
12976 // known. For untrusted values, a strlen() will be performed.
12978 // It is an error to call this function with a @value of any type
12979 // other than those three.
12981 // The return value remains valid as long as @value exists.
12982 // RETURNS: the constant string, utf8 encoded
12983 // <length>: a pointer to a #gsize, to store the length
12984 char* get_string(/*out*/ size_t* length=null) {
12985 return g_variant_get_string(&this, length);
12988 // Gets the contents of an array of strings #GVariant. This call
12989 // makes a shallow copy; the return result should be released with
12990 // g_free(), but the individual strings must not be modified.
12992 // If @length is non-%NULL then the number of elements in the result
12993 // is stored there. In any case, the resulting array will be
12994 // %NULL-terminated.
12996 // For an empty array, @length will be set to 0 and a pointer to a
12997 // %NULL pointer will be returned.
12998 // RETURNS: an array of constant strings
12999 // <length>: the length of the result, or %NULL
13000 char** /*new container*/ get_strv(/*out*/ size_t* length=null) {
13001 return g_variant_get_strv(&this, length);
13004 // Returns the type string of @value. Unlike the result of calling
13005 // g_variant_type_peek_string(), this string is nul-terminated. This
13006 // string belongs to #GVariant and must not be freed.
13007 // RETURNS: the type string for the type of @value
13008 char* get_type_string() {
13009 return g_variant_get_type_string(&this);
13012 // Returns the 16-bit unsigned integer value of @value.
13014 // It is an error to call this function with a @value of any type
13015 // other than %G_VARIANT_TYPE_UINT16.
13016 // RETURNS: a #guint16
13017 ushort get_uint16() {
13018 return g_variant_get_uint16(&this);
13021 // Returns the 32-bit unsigned integer value of @value.
13023 // It is an error to call this function with a @value of any type
13024 // other than %G_VARIANT_TYPE_UINT32.
13025 // RETURNS: a #guint32
13026 uint get_uint32() {
13027 return g_variant_get_uint32(&this);
13030 // Returns the 64-bit unsigned integer value of @value.
13032 // It is an error to call this function with a @value of any type
13033 // other than %G_VARIANT_TYPE_UINT64.
13034 // RETURNS: a #guint64
13035 ulong get_uint64() {
13036 return g_variant_get_uint64(&this);
13039 // Unintrospectable method: get_va() / g_variant_get_va()
13040 // This function is intended to be used by libraries based on #GVariant
13041 // that want to provide g_variant_get()-like functionality to their
13042 // users.
13044 // The API is more general than g_variant_get() to allow a wider range
13045 // of possible uses.
13047 // @format_string must still point to a valid format string, but it only
13048 // need to be nul-terminated if @endptr is %NULL. If @endptr is
13049 // non-%NULL then it is updated to point to the first character past the
13050 // end of the format string.
13052 // @app is a pointer to a #va_list. The arguments, according to
13053 // @format_string, are collected from this #va_list and the list is left
13054 // pointing to the argument following the last.
13056 // These two generalisations allow mixing of multiple calls to
13057 // g_variant_new_va() and g_variant_get_va() within a single actual
13058 // varargs call by the user.
13059 // <format_string>: a string that is prefixed with a format string
13060 // <endptr>: location to store the end pointer, or %NULL
13061 // <app>: a pointer to a #va_list
13062 void get_va(char* format_string, char** endptr, va_list* app) {
13063 g_variant_get_va(&this, format_string, endptr, app);
13066 // Unboxes @value. The result is the #GVariant instance that was
13067 // contained in @value.
13068 // RETURNS: the item contained in the variant
13069 Variant* /*new*/ get_variant() {
13070 return g_variant_get_variant(&this);
13073 // Generates a hash value for a #GVariant instance.
13075 // The output of this function is guaranteed to be the same for a given
13076 // value only per-process. It may change between different processor
13077 // architectures or even different versions of GLib. Do not use this
13078 // function as a basis for building protocols or file formats.
13080 // The type of @value is #gconstpointer only to allow use of this
13081 // function with #GHashTable. @value must be a #GVariant.
13082 // RETURNS: a hash value corresponding to @value
13083 uint hash() {
13084 return g_variant_hash(&this);
13087 // Checks if @value is a container.
13088 // RETURNS: %TRUE if @value is a container
13089 int is_container() {
13090 return g_variant_is_container(&this);
13093 // Checks whether @value has a floating reference count.
13095 // This function should only ever be used to assert that a given variant
13096 // is or is not floating, or for debug purposes. To acquire a reference
13097 // to a variant that might be floating, always use g_variant_ref_sink()
13098 // or g_variant_take_ref().
13100 // See g_variant_ref_sink() for more information about floating reference
13101 // counts.
13102 // RETURNS: whether @value is floating
13103 int is_floating() {
13104 return g_variant_is_floating(&this);
13107 // Checks if @value is in normal form.
13109 // The main reason to do this is to detect if a given chunk of
13110 // serialised data is in normal form: load the data into a #GVariant
13111 // using g_variant_new_from_data() and then use this function to
13112 // check.
13114 // If @value is found to be in normal form then it will be marked as
13115 // being trusted. If the value was already marked as being trusted then
13116 // this function will immediately return %TRUE.
13117 // RETURNS: %TRUE if @value is in normal form
13118 int is_normal_form() {
13119 return g_variant_is_normal_form(&this);
13122 // Checks if a value has a type matching the provided type.
13123 // RETURNS: %TRUE if the type of @value matches @type
13124 // <type>: a #GVariantType
13125 int is_of_type(VariantType* type) {
13126 return g_variant_is_of_type(&this, type);
13129 // Unintrospectable method: iter_new() / g_variant_iter_new()
13130 // Creates a heap-allocated #GVariantIter for iterating over the items
13131 // in @value.
13133 // Use g_variant_iter_free() to free the return value when you no longer
13134 // need it.
13136 // A reference is taken to @value and will be released only when
13137 // g_variant_iter_free() is called.
13138 // RETURNS: a new heap-allocated #GVariantIter
13139 VariantIter* /*new*/ iter_new() {
13140 return g_variant_iter_new(&this);
13143 // Unintrospectable method: lookup() / g_variant_lookup()
13144 // Looks up a value in a dictionary #GVariant.
13146 // This function is a wrapper around g_variant_lookup_value() and
13147 // g_variant_get(). In the case that %NULL would have been returned,
13148 // this function returns %FALSE. Otherwise, it unpacks the returned
13149 // value and returns %TRUE.
13151 // See g_variant_get() for information about @format_string.
13152 // RETURNS: %TRUE if a value was unpacked
13153 // <key>: the key to lookup in the dictionary
13154 // <format_string>: a GVariant format string
13155 /+ Not available -- variadic methods unsupported - use the C function directly.
13156 alias g_variant_lookup lookup; // Variadic
13159 // Looks up a value in a dictionary #GVariant.
13161 // This function works with dictionaries of the type
13162 // <literal>a{s*}</literal> (and equally well with type
13163 // <literal>a{o*}</literal>, but we only further discuss the string case
13164 // for sake of clarity).
13166 // In the event that @dictionary has the type <literal>a{sv}</literal>,
13167 // the @expected_type string specifies what type of value is expected to
13168 // be inside of the variant. If the value inside the variant has a
13169 // different type then %NULL is returned. In the event that @dictionary
13170 // has a value type other than <literal>v</literal> then @expected_type
13171 // must directly match the key type and it is used to unpack the value
13172 // directly or an error occurs.
13174 // In either case, if @key is not found in @dictionary, %NULL is
13175 // returned.
13177 // If the key is found and the value has the correct type, it is
13178 // returned. If @expected_type was specified then any non-%NULL return
13179 // value will have this type.
13180 // RETURNS: the value of the dictionary key, or %NULL
13181 // <key>: the key to lookup in the dictionary
13182 // <expected_type>: a #GVariantType, or %NULL
13183 Variant* /*new*/ lookup_value(char* key, VariantType* expected_type=null) {
13184 return g_variant_lookup_value(&this, key, expected_type);
13187 // Determines the number of children in a container #GVariant instance.
13188 // This includes variants, maybes, arrays, tuples and dictionary
13189 // entries. It is an error to call this function on any other type of
13190 // #GVariant.
13192 // For variants, the return value is always 1. For values with maybe
13193 // types, it is always zero or one. For arrays, it is the length of the
13194 // array. For tuples it is the number of tuple items (which depends
13195 // only on the type). For dictionary entries, it is always 2
13197 // This function is O(1).
13198 // RETURNS: the number of children in the container
13199 size_t n_children() {
13200 return g_variant_n_children(&this);
13203 // Pretty-prints @value in the format understood by g_variant_parse().
13205 // The format is described <link linkend='gvariant-text'>here</link>.
13207 // If @type_annotate is %TRUE, then type information is included in
13208 // the output.
13209 // RETURNS: a newly-allocated string holding the result.
13210 // <type_annotate>: %TRUE if type information should be included in the output
13211 char* /*new*/ print(int type_annotate) {
13212 return g_variant_print(&this, type_annotate);
13215 // Unintrospectable method: print_string() / g_variant_print_string()
13216 // Behaves as g_variant_print(), but operates on a #GString.
13218 // If @string is non-%NULL then it is appended to and returned. Else,
13219 // a new empty #GString is allocated and it is returned.
13220 // RETURNS: a #GString containing the string
13221 // <string>: a #GString, or %NULL
13222 // <type_annotate>: %TRUE if type information should be included in the output
13223 String* /*new*/ print_string(String* string_, int type_annotate) {
13224 return g_variant_print_string(&this, string_, type_annotate);
13227 // Increases the reference count of @value.
13228 // RETURNS: the same @value
13229 Variant* /*new*/ ref_() {
13230 return g_variant_ref(&this);
13233 // #GVariant uses a floating reference count system. All functions with
13234 // names starting with <literal>g_variant_new_</literal> return floating
13235 // references.
13237 // Calling g_variant_ref_sink() on a #GVariant with a floating reference
13238 // will convert the floating reference into a full reference. Calling
13239 // g_variant_ref_sink() on a non-floating #GVariant results in an
13240 // additional normal reference being added.
13242 // In other words, if the @value is floating, then this call "assumes
13243 // ownership" of the floating reference, converting it to a normal
13244 // reference. If the @value is not floating, then this call adds a
13245 // new normal reference increasing the reference count by one.
13247 // All calls that result in a #GVariant instance being inserted into a
13248 // container will call g_variant_ref_sink() on the instance. This means
13249 // that if the value was just created (and has only its floating
13250 // reference) then the container will assume sole ownership of the value
13251 // at that point and the caller will not need to unreference it. This
13252 // makes certain common styles of programming much easier while still
13253 // maintaining normal refcounting semantics in situations where values
13254 // are not floating.
13255 // RETURNS: the same @value
13256 Variant* /*new*/ ref_sink() {
13257 return g_variant_ref_sink(&this);
13260 // Stores the serialised form of @value at @data. @data should be
13261 // large enough. See g_variant_get_size().
13263 // The stored data is in machine native byte order but may not be in
13264 // fully-normalised form if read from an untrusted source. See
13265 // g_variant_get_normal_form() for a solution.
13267 // This function is approximately O(n) in the size of @data.
13268 // <data>: the location to store the serialised data at
13269 void store(void* data) {
13270 g_variant_store(&this, data);
13273 // If @value is floating, sink it. Otherwise, do nothing.
13275 // Typically you want to use g_variant_ref_sink() in order to
13276 // automatically do the correct thing with respect to floating or
13277 // non-floating references, but there is one specific scenario where
13278 // this function is helpful.
13280 // The situation where this function is helpful is when creating an API
13281 // that allows the user to provide a callback function that returns a
13282 // #GVariant. We certainly want to allow the user the flexibility to
13283 // return a non-floating reference from this callback (for the case
13284 // where the value that is being returned already exists).
13286 // At the same time, the style of the #GVariant API makes it likely that
13287 // for newly-created #GVariant instances, the user can be saved some
13288 // typing if they are allowed to return a #GVariant with a floating
13289 // reference.
13291 // Using this function on the return value of the user's callback allows
13292 // the user to do whichever is more convenient for them. The caller
13293 // will alway receives exactly one full reference to the value: either
13294 // the one that was returned in the first place, or a floating reference
13295 // that has been converted to a full reference.
13297 // This function has an odd interaction when combined with
13298 // g_variant_ref_sink() running at the same time in another thread on
13299 // the same #GVariant instance. If g_variant_ref_sink() runs first then
13300 // the result will be that the floating reference is converted to a hard
13301 // reference. If g_variant_take_ref() runs first then the result will
13302 // be that the floating reference is converted to a hard reference and
13303 // an additional reference on top of that one is added. It is best to
13304 // avoid this situation.
13305 // RETURNS: the same @value
13306 Variant* /*new*/ take_ref() {
13307 return g_variant_take_ref(&this);
13310 // Decreases the reference count of @value. When its reference count
13311 // drops to 0, the memory used by the variant is freed.
13312 void unref() {
13313 g_variant_unref(&this);
13316 // Determines if a given string is a valid D-Bus object path. You
13317 // should ensure that a string is a valid D-Bus object path before
13318 // passing it to g_variant_new_object_path().
13320 // A valid object path starts with '/' followed by zero or more
13321 // sequences of characters separated by '/' characters. Each sequence
13322 // must contain only the characters "[A-Z][a-z][0-9]_". No sequence
13323 // (including the one following the final '/' character) may be empty.
13324 // RETURNS: %TRUE if @string is a D-Bus object path
13325 // <string>: a normal C nul-terminated string
13326 static int is_object_path(char* string_) {
13327 return g_variant_is_object_path(string_);
13330 // Determines if a given string is a valid D-Bus type signature. You
13331 // should ensure that a string is a valid D-Bus type signature before
13332 // passing it to g_variant_new_signature().
13334 // D-Bus type signatures consist of zero or more definite #GVariantType
13335 // strings in sequence.
13336 // RETURNS: %TRUE if @string is a D-Bus type signature
13337 // <string>: a normal C nul-terminated string
13338 static int is_signature(char* string_) {
13339 return g_variant_is_signature(string_);
13342 // Parses a #GVariant from a text representation.
13344 // A single #GVariant is parsed from the content of @text.
13346 // The format is described <link linkend='gvariant-text'>here</link>.
13348 // The memory at @limit will never be accessed and the parser behaves as
13349 // if the character at @limit is the nul terminator. This has the
13350 // effect of bounding @text.
13352 // If @endptr is non-%NULL then @text is permitted to contain data
13353 // following the value that this function parses and @endptr will be
13354 // updated to point to the first character past the end of the text
13355 // parsed by this function. If @endptr is %NULL and there is extra data
13356 // then an error is returned.
13358 // If @type is non-%NULL then the value will be parsed to have that
13359 // type. This may result in additional parse errors (in the case that
13360 // the parsed value doesn't fit the type) but may also result in fewer
13361 // errors (in the case that the type would have been ambiguous, such as
13362 // with empty arrays).
13364 // In the event that the parsing is successful, the resulting #GVariant
13365 // is returned.
13367 // In case of any error, %NULL will be returned. If @error is non-%NULL
13368 // then it will be set to reflect the error that occurred.
13370 // Officially, the language understood by the parser is "any string
13371 // produced by g_variant_print()".
13372 // <type>: a #GVariantType, or %NULL
13373 // <text>: a string containing a GVariant in text form
13374 // <limit>: a pointer to the end of @text, or %NULL
13375 // <endptr>: a location to store the end pointer, or %NULL
13376 static Variant* /*new*/ parse(VariantType* type, char* text, char* limit, char** endptr, GLib2.Error** error=null) {
13377 return g_variant_parse(type, text, limit, endptr, error);
13379 static Quark parser_get_error_quark() {
13380 return g_variant_parser_get_error_quark();
13385 // A utility type for constructing container-type #GVariant instances.
13387 // This is an opaque structure and may only be accessed using the
13388 // following functions.
13390 // #GVariantBuilder is not threadsafe in any way. Do not attempt to
13391 // access it from more than one thread.
13392 struct VariantBuilder {
13393 private size_t[16] x;
13396 // Allocates and initialises a new #GVariantBuilder.
13398 // You should call g_variant_builder_unref() on the return value when it
13399 // is no longer needed. The memory will not be automatically freed by
13400 // any other call.
13402 // In most cases it is easier to place a #GVariantBuilder directly on
13403 // the stack of the calling function and initialise it with
13404 // g_variant_builder_init().
13405 // RETURNS: a #GVariantBuilder
13406 // <type>: a container type
13407 static VariantBuilder* /*new*/ new_(VariantType* type) {
13408 return g_variant_builder_new(type);
13411 // Unintrospectable method: add() / g_variant_builder_add()
13412 // Adds to a #GVariantBuilder.
13414 // This call is a convenience wrapper that is exactly equivalent to
13415 // calling g_variant_new() followed by g_variant_builder_add_value().
13417 // This function might be used as follows:
13419 // <programlisting>
13420 // GVariant *
13421 // make_pointless_dictionary (void)
13422 // {
13423 // GVariantBuilder *builder;
13424 // int i;
13426 // builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
13427 // for (i = 0; i < 16; i++)
13428 // {
13429 // gchar buf[3];
13431 // sprintf (buf, "%d", i);
13432 // g_variant_builder_add (builder, "{is}", i, buf);
13433 // }
13435 // return g_variant_builder_end (builder);
13436 // }
13437 // </programlisting>
13438 // <format_string>: a #GVariant varargs format string
13439 /+ Not available -- variadic methods unsupported - use the C function directly.
13440 alias g_variant_builder_add add; // Variadic
13443 // Unintrospectable method: add_parsed() / g_variant_builder_add_parsed()
13444 // Adds to a #GVariantBuilder.
13446 // This call is a convenience wrapper that is exactly equivalent to
13447 // calling g_variant_new_parsed() followed by
13448 // g_variant_builder_add_value().
13450 // This function might be used as follows:
13452 // <programlisting>
13453 // GVariant *
13454 // make_pointless_dictionary (void)
13455 // {
13456 // GVariantBuilder *builder;
13457 // int i;
13459 // builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
13460 // g_variant_builder_add_parsed (builder, "{'width', <%i>}", 600);
13461 // g_variant_builder_add_parsed (builder, "{'title', <%s>}", "foo");
13462 // g_variant_builder_add_parsed (builder, "{'transparency', <0.5>}");
13463 // return g_variant_builder_end (builder);
13464 // }
13465 // </programlisting>
13466 // <format>: a text format #GVariant
13467 /+ Not available -- variadic methods unsupported - use the C function directly.
13468 alias g_variant_builder_add_parsed add_parsed; // Variadic
13471 // Adds @value to @builder.
13473 // It is an error to call this function in any way that would create an
13474 // inconsistent value to be constructed. Some examples of this are
13475 // putting different types of items into an array, putting the wrong
13476 // types or number of items in a tuple, putting more than one value into
13477 // a variant, etc.
13479 // If @value is a floating reference (see g_variant_ref_sink()),
13480 // the @builder instance takes ownership of @value.
13481 // <value>: a #GVariant
13482 void add_value(Variant* value) {
13483 g_variant_builder_add_value(&this, value);
13486 // Unintrospectable method: clear() / g_variant_builder_clear()
13487 // Releases all memory associated with a #GVariantBuilder without
13488 // freeing the #GVariantBuilder structure itself.
13490 // It typically only makes sense to do this on a stack-allocated
13491 // #GVariantBuilder if you want to abort building the value part-way
13492 // through. This function need not be called if you call
13493 // g_variant_builder_end() and it also doesn't need to be called on
13494 // builders allocated with g_variant_builder_new (see
13495 // g_variant_builder_unref() for that).
13497 // This function leaves the #GVariantBuilder structure set to all-zeros.
13498 // It is valid to call this function on either an initialised
13499 // #GVariantBuilder or one that is set to all-zeros but it is not valid
13500 // to call this function on uninitialised memory.
13501 void clear() {
13502 g_variant_builder_clear(&this);
13505 // Closes the subcontainer inside the given @builder that was opened by
13506 // the most recent call to g_variant_builder_open().
13508 // It is an error to call this function in any way that would create an
13509 // inconsistent value to be constructed (ie: too few values added to the
13510 // subcontainer).
13511 void close() {
13512 g_variant_builder_close(&this);
13515 // Ends the builder process and returns the constructed value.
13517 // It is not permissible to use @builder in any way after this call
13518 // except for reference counting operations (in the case of a
13519 // heap-allocated #GVariantBuilder) or by reinitialising it with
13520 // g_variant_builder_init() (in the case of stack-allocated).
13522 // It is an error to call this function in any way that would create an
13523 // inconsistent value to be constructed (ie: insufficient number of
13524 // items added to a container with a specific number of children
13525 // required). It is also an error to call this function if the builder
13526 // was created with an indefinite array or maybe type and no children
13527 // have been added; in this case it is impossible to infer the type of
13528 // the empty array.
13529 // RETURNS: a new, floating, #GVariant
13530 Variant* end() {
13531 return g_variant_builder_end(&this);
13534 // Unintrospectable method: init() / g_variant_builder_init()
13535 // Initialises a #GVariantBuilder structure.
13537 // @type must be non-%NULL. It specifies the type of container to
13538 // construct. It can be an indefinite type such as
13539 // %G_VARIANT_TYPE_ARRAY or a definite type such as "as" or "(ii)".
13540 // Maybe, array, tuple, dictionary entry and variant-typed values may be
13541 // constructed.
13543 // After the builder is initialised, values are added using
13544 // g_variant_builder_add_value() or g_variant_builder_add().
13546 // After all the child values are added, g_variant_builder_end() frees
13547 // the memory associated with the builder and returns the #GVariant that
13548 // was created.
13550 // This function completely ignores the previous contents of @builder.
13551 // On one hand this means that it is valid to pass in completely
13552 // uninitialised memory. On the other hand, this means that if you are
13553 // initialising over top of an existing #GVariantBuilder you need to
13554 // first call g_variant_builder_clear() in order to avoid leaking
13555 // memory.
13557 // You must not call g_variant_builder_ref() or
13558 // g_variant_builder_unref() on a #GVariantBuilder that was initialised
13559 // with this function. If you ever pass a reference to a
13560 // #GVariantBuilder outside of the control of your own code then you
13561 // should assume that the person receiving that reference may try to use
13562 // reference counting; you should use g_variant_builder_new() instead of
13563 // this function.
13564 // <type>: a container type
13565 void init(VariantType* type) {
13566 g_variant_builder_init(&this, type);
13569 // Opens a subcontainer inside the given @builder. When done adding
13570 // items to the subcontainer, g_variant_builder_close() must be called.
13572 // It is an error to call this function in any way that would cause an
13573 // inconsistent value to be constructed (ie: adding too many values or
13574 // a value of an incorrect type).
13575 // <type>: a #GVariantType
13576 void open(VariantType* type) {
13577 g_variant_builder_open(&this, type);
13580 // Increases the reference count on @builder.
13582 // Don't call this on stack-allocated #GVariantBuilder instances or bad
13583 // things will happen.
13584 // RETURNS: a new reference to @builder
13585 VariantBuilder* /*new*/ ref_() {
13586 return g_variant_builder_ref(&this);
13589 // Decreases the reference count on @builder.
13591 // In the event that there are no more references, releases all memory
13592 // associated with the #GVariantBuilder.
13594 // Don't call this on stack-allocated #GVariantBuilder instances or bad
13595 // things will happen.
13596 void unref() {
13597 g_variant_builder_unref(&this);
13601 // The range of possible top-level types of #GVariant instances.
13602 enum VariantClass /* Version 2.24 */ {
13603 BOOLEAN = 98,
13604 BYTE = 121,
13605 INT16 = 110,
13606 UINT16 = 113,
13607 INT32 = 105,
13608 UINT32 = 117,
13609 INT64 = 120,
13610 UINT64 = 116,
13611 HANDLE = 104,
13612 DOUBLE = 100,
13613 STRING = 115,
13614 OBJECT_PATH = 111,
13615 SIGNATURE = 103,
13616 VARIANT = 118,
13617 MAYBE = 109,
13618 ARRAY = 97,
13619 TUPLE = 40,
13620 DICT_ENTRY = 123
13623 // #GVariantIter is an opaque data structure and can only be accessed
13624 // using the following functions.
13625 struct VariantIter {
13626 private size_t[16] x;
13629 // Unintrospectable method: copy() / g_variant_iter_copy()
13630 // Creates a new heap-allocated #GVariantIter to iterate over the
13631 // container that was being iterated over by @iter. Iteration begins on
13632 // the new iterator from the current position of the old iterator but
13633 // the two copies are independent past that point.
13635 // Use g_variant_iter_free() to free the return value when you no longer
13636 // need it.
13638 // A reference is taken to the container that @iter is iterating over
13639 // and will be releated only when g_variant_iter_free() is called.
13640 // RETURNS: a new heap-allocated #GVariantIter
13641 VariantIter* /*new*/ copy() {
13642 return g_variant_iter_copy(&this);
13645 // Frees a heap-allocated #GVariantIter. Only call this function on
13646 // iterators that were returned by g_variant_iter_new() or
13647 // g_variant_iter_copy().
13648 void free() {
13649 g_variant_iter_free(&this);
13652 // Unintrospectable method: init() / g_variant_iter_init()
13653 // Initialises (without allocating) a #GVariantIter. @iter may be
13654 // completely uninitialised prior to this call; its old value is
13655 // ignored.
13657 // The iterator remains valid for as long as @value exists, and need not
13658 // be freed in any way.
13659 // RETURNS: the number of items in @value
13660 // <value>: a container #GVariant
13661 size_t init(Variant* value) {
13662 return g_variant_iter_init(&this, value);
13665 // Unintrospectable method: loop() / g_variant_iter_loop()
13666 // Gets the next item in the container and unpacks it into the variable
13667 // argument list according to @format_string, returning %TRUE.
13669 // If no more items remain then %FALSE is returned.
13671 // On the first call to this function, the pointers appearing on the
13672 // variable argument list are assumed to point at uninitialised memory.
13673 // On the second and later calls, it is assumed that the same pointers
13674 // will be given and that they will point to the memory as set by the
13675 // previous call to this function. This allows the previous values to
13676 // be freed, as appropriate.
13678 // This function is intended to be used with a while loop as
13679 // demonstrated in the following example. This function can only be
13680 // used when iterating over an array. It is only valid to call this
13681 // function with a string constant for the format string and the same
13682 // string constant must be used each time. Mixing calls to this
13683 // function and g_variant_iter_next() or g_variant_iter_next_value() on
13684 // the same iterator is not recommended.
13686 // See the section on <link linkend='gvariant-format-strings'>GVariant
13687 // Format Strings</link>.
13689 // <example>
13690 // <title>Memory management with g_variant_iter_loop()</title>
13691 // <programlisting>
13692 // /<!-- -->* Iterates a dictionary of type 'a{sv}' *<!-- -->/
13693 // void
13694 // iterate_dictionary (GVariant *dictionary)
13695 // {
13696 // GVariantIter iter;
13697 // GVariant *value;
13698 // gchar *key;
13700 // g_variant_iter_init (&iter, dictionary);
13701 // while (g_variant_iter_loop (&iter, "{sv}", &key, &value))
13702 // {
13703 // g_print ("Item '%s' has type '%s'\n", key,
13704 // g_variant_get_type_string (value));
13706 // /<!-- -->* no need to free 'key' and 'value' here *<!-- -->/
13707 // }
13708 // }
13709 // </programlisting>
13710 // </example>
13712 // For most cases you should use g_variant_iter_next().
13714 // This function is really only useful when unpacking into #GVariant or
13715 // #GVariantIter in order to allow you to skip the call to
13716 // g_variant_unref() or g_variant_iter_free().
13718 // For example, if you are only looping over simple integer and string
13719 // types, g_variant_iter_next() is definitely preferred. For string
13720 // types, use the '&' prefix to avoid allocating any memory at all (and
13721 // thereby avoiding the need to free anything as well).
13722 // RETURNS: %TRUE if a value was unpacked, or %FALSE if there as no value
13723 // <format_string>: a GVariant format string
13724 /+ Not available -- variadic methods unsupported - use the C function directly.
13725 alias g_variant_iter_loop loop; // Variadic
13728 // Queries the number of child items in the container that we are
13729 // iterating over. This is the total number of items -- not the number
13730 // of items remaining.
13732 // This function might be useful for preallocation of arrays.
13733 // RETURNS: the number of children in the container
13734 size_t n_children() {
13735 return g_variant_iter_n_children(&this);
13738 // Unintrospectable method: next() / g_variant_iter_next()
13739 // Gets the next item in the container and unpacks it into the variable
13740 // argument list according to @format_string, returning %TRUE.
13742 // If no more items remain then %FALSE is returned.
13744 // All of the pointers given on the variable arguments list of this
13745 // function are assumed to point at uninitialised memory. It is the
13746 // responsibility of the caller to free all of the values returned by
13747 // the unpacking process.
13749 // See the section on <link linkend='gvariant-format-strings'>GVariant
13750 // Format Strings</link>.
13752 // <example>
13753 // <title>Memory management with g_variant_iter_next()</title>
13754 // <programlisting>
13755 // /<!-- -->* Iterates a dictionary of type 'a{sv}' *<!-- -->/
13756 // void
13757 // iterate_dictionary (GVariant *dictionary)
13758 // {
13759 // GVariantIter iter;
13760 // GVariant *value;
13761 // gchar *key;
13763 // g_variant_iter_init (&iter, dictionary);
13764 // while (g_variant_iter_next (&iter, "{sv}", &key, &value))
13765 // {
13766 // g_print ("Item '%s' has type '%s'\n", key,
13767 // g_variant_get_type_string (value));
13769 // /<!-- -->* must free data for ourselves *<!-- -->/
13770 // g_variant_unref (value);
13771 // g_free (key);
13772 // }
13773 // }
13774 // </programlisting>
13775 // </example>
13777 // For a solution that is likely to be more convenient to C programmers
13778 // when dealing with loops, see g_variant_iter_loop().
13779 // RETURNS: %TRUE if a value was unpacked, or %FALSE if there as no value
13780 // <format_string>: a GVariant format string
13781 /+ Not available -- variadic methods unsupported - use the C function directly.
13782 alias g_variant_iter_next next; // Variadic
13785 // Gets the next item in the container. If no more items remain then
13786 // %NULL is returned.
13788 // Use g_variant_unref() to drop your reference on the return value when
13789 // you no longer need it.
13791 // <example>
13792 // <title>Iterating with g_variant_iter_next_value()</title>
13793 // <programlisting>
13794 // /<!-- -->* recursively iterate a container *<!-- -->/
13795 // void
13796 // iterate_container_recursive (GVariant *container)
13797 // {
13798 // GVariantIter iter;
13799 // GVariant *child;
13801 // g_variant_iter_init (&iter, container);
13802 // while ((child = g_variant_iter_next_value (&iter)))
13803 // {
13804 // g_print ("type '%s'\n", g_variant_get_type_string (child));
13806 // if (g_variant_is_container (child))
13807 // iterate_container_recursive (child);
13809 // g_variant_unref (child);
13810 // }
13811 // }
13812 // </programlisting>
13813 // </example>
13814 // RETURNS: a #GVariant, or %NULL
13815 Variant* /*new*/ next_value() {
13816 return g_variant_iter_next_value(&this);
13820 // Error codes returned by parsing text-format GVariants.
13821 enum VariantParseError {
13822 FAILED = 0,
13823 BASIC_TYPE_EXPECTED = 1,
13824 CANNOT_INFER_TYPE = 2,
13825 DEFINITE_TYPE_EXPECTED = 3,
13826 INPUT_NOT_AT_END = 4,
13827 INVALID_CHARACTER = 5,
13828 INVALID_FORMAT_STRING = 6,
13829 INVALID_OBJECT_PATH = 7,
13830 INVALID_SIGNATURE = 8,
13831 INVALID_TYPE_STRING = 9,
13832 NO_COMMON_TYPE = 10,
13833 NUMBER_OUT_OF_RANGE = 11,
13834 NUMBER_TOO_BIG = 12,
13835 TYPE_ERROR = 13,
13836 UNEXPECTED_TOKEN = 14,
13837 UNKNOWN_KEYWORD = 15,
13838 UNTERMINATED_STRING_CONSTANT = 16,
13839 VALUE_EXPECTED = 17
13842 // This section introduces the GVariant type system. It is based, in
13843 // large part, on the D-Bus type system, with two major changes and some minor
13844 // lifting of restrictions. The <ulink
13845 // url='http://dbus.freedesktop.org/doc/dbus-specification.html'>DBus
13846 // specification</ulink>, therefore, provides a significant amount of
13847 // information that is useful when working with GVariant.
13849 // The first major change with respect to the D-Bus type system is the
13850 // introduction of maybe (or "nullable") types. Any type in GVariant can be
13851 // converted to a maybe type, in which case, "nothing" (or "null") becomes a
13852 // valid value. Maybe types have been added by introducing the
13853 // character "<literal>m</literal>" to type strings.
13855 // The second major change is that the GVariant type system supports the
13856 // concept of "indefinite types" -- types that are less specific than
13857 // the normal types found in D-Bus. For example, it is possible to speak
13858 // of "an array of any type" in GVariant, where the D-Bus type system
13859 // would require you to speak of "an array of integers" or "an array of
13860 // strings". Indefinite types have been added by introducing the
13861 // characters "<literal>*</literal>", "<literal>?</literal>" and
13862 // "<literal>r</literal>" to type strings.
13864 // Finally, all arbitrary restrictions relating to the complexity of
13865 // types are lifted along with the restriction that dictionary entries
13866 // may only appear nested inside of arrays.
13868 // Just as in D-Bus, GVariant types are described with strings ("type
13869 // strings"). Subject to the differences mentioned above, these strings
13870 // are of the same form as those found in DBus. Note, however: D-Bus
13871 // always works in terms of messages and therefore individual type
13872 // strings appear nowhere in its interface. Instead, "signatures"
13873 // are a concatenation of the strings of the type of each argument in a
13874 // message. GVariant deals with single values directly so GVariant type
13875 // strings always describe the type of exactly one value. This means
13876 // that a D-Bus signature string is generally not a valid GVariant type
13877 // string -- except in the case that it is the signature of a message
13878 // containing exactly one argument.
13880 // An indefinite type is similar in spirit to what may be called an
13881 // abstract type in other type systems. No value can exist that has an
13882 // indefinite type as its type, but values can exist that have types
13883 // that are subtypes of indefinite types. That is to say,
13884 // g_variant_get_type() will never return an indefinite type, but
13885 // calling g_variant_is_of_type() with an indefinite type may return
13886 // %TRUE. For example, you cannot have a value that represents "an
13887 // array of no particular type", but you can have an "array of integers"
13888 // which certainly matches the type of "an array of no particular type",
13889 // since "array of integers" is a subtype of "array of no particular
13890 // type".
13892 // This is similar to how instances of abstract classes may not
13893 // directly exist in other type systems, but instances of their
13894 // non-abstract subtypes may. For example, in GTK, no object that has
13895 // the type of #GtkBin can exist (since #GtkBin is an abstract class),
13896 // but a #GtkWindow can certainly be instantiated, and you would say
13897 // that the #GtkWindow is a #GtkBin (since #GtkWindow is a subclass of
13898 // #GtkBin).
13900 // A detailed description of GVariant type strings is given here:
13902 // <refsect2 id='gvariant-typestrings'>
13903 // <title>GVariant Type Strings</title>
13904 // <para>
13905 // A GVariant type string can be any of the following:
13906 // </para>
13907 // <itemizedlist>
13908 // <listitem>
13909 // <para>
13910 // any basic type string (listed below)
13911 // </para>
13912 // </listitem>
13913 // <listitem>
13914 // <para>
13915 // "<literal>v</literal>", "<literal>r</literal>" or
13916 // "<literal>*</literal>"
13917 // </para>
13918 // </listitem>
13919 // <listitem>
13920 // <para>
13921 // one of the characters '<literal>a</literal>' or
13922 // '<literal>m</literal>', followed by another type string
13923 // </para>
13924 // </listitem>
13925 // <listitem>
13926 // <para>
13927 // the character '<literal>(</literal>', followed by a concatenation
13928 // of zero or more other type strings, followed by the character
13929 // '<literal>)</literal>'
13930 // </para>
13931 // </listitem>
13932 // <listitem>
13933 // <para>
13934 // the character '<literal>{</literal>', followed by a basic type
13935 // string (see below), followed by another type string, followed by
13936 // the character '<literal>}</literal>'
13937 // </para>
13938 // </listitem>
13939 // </itemizedlist>
13940 // <para>
13941 // A basic type string describes a basic type (as per
13942 // g_variant_type_is_basic()) and is always a single
13943 // character in length. The valid basic type strings are
13944 // "<literal>b</literal>", "<literal>y</literal>",
13945 // "<literal>n</literal>", "<literal>q</literal>",
13946 // "<literal>i</literal>", "<literal>u</literal>",
13947 // "<literal>x</literal>", "<literal>t</literal>",
13948 // "<literal>h</literal>", "<literal>d</literal>",
13949 // "<literal>s</literal>", "<literal>o</literal>",
13950 // "<literal>g</literal>" and "<literal>?</literal>".
13951 // </para>
13952 // <para>
13953 // The above definition is recursive to arbitrary depth.
13954 // "<literal>aaaaai</literal>" and "<literal>(ui(nq((y)))s)</literal>"
13955 // are both valid type strings, as is
13956 // "<literal>a(aa(ui)(qna{ya(yd)}))</literal>".
13957 // </para>
13958 // <para>
13959 // The meaning of each of the characters is as follows:
13960 // </para>
13961 // <informaltable>
13962 // <tgroup cols='2'>
13963 // <tbody>
13964 // <row>
13965 // <entry>
13966 // <para>
13967 // <emphasis role='strong'>Character</emphasis>
13968 // </para>
13969 // </entry>
13970 // <entry>
13971 // <para>
13972 // <emphasis role='strong'>Meaning</emphasis>
13973 // </para>
13974 // </entry>
13975 // </row>
13976 // <row>
13977 // <entry>
13978 // <para>
13979 // <literal>b</literal>
13980 // </para>
13981 // </entry>
13982 // <entry>
13983 // <para>
13984 // the type string of %G_VARIANT_TYPE_BOOLEAN; a boolean value.
13985 // </para>
13986 // </entry>
13987 // </row>
13988 // <row>
13989 // <entry>
13990 // <para>
13991 // <literal>y</literal>
13992 // </para>
13993 // </entry>
13994 // <entry>
13995 // <para>
13996 // the type string of %G_VARIANT_TYPE_BYTE; a byte.
13997 // </para>
13998 // </entry>
13999 // </row>
14000 // <row>
14001 // <entry>
14002 // <para>
14003 // <literal>n</literal>
14004 // </para>
14005 // </entry>
14006 // <entry>
14007 // <para>
14008 // the type string of %G_VARIANT_TYPE_INT16; a signed 16 bit
14009 // integer.
14010 // </para>
14011 // </entry>
14012 // </row>
14013 // <row>
14014 // <entry>
14015 // <para>
14016 // <literal>q</literal>
14017 // </para>
14018 // </entry>
14019 // <entry>
14020 // <para>
14021 // the type string of %G_VARIANT_TYPE_UINT16; an unsigned 16 bit
14022 // integer.
14023 // </para>
14024 // </entry>
14025 // </row>
14026 // <row>
14027 // <entry>
14028 // <para>
14029 // <literal>i</literal>
14030 // </para>
14031 // </entry>
14032 // <entry>
14033 // <para>
14034 // the type string of %G_VARIANT_TYPE_INT32; a signed 32 bit
14035 // integer.
14036 // </para>
14037 // </entry>
14038 // </row>
14039 // <row>
14040 // <entry>
14041 // <para>
14042 // <literal>u</literal>
14043 // </para>
14044 // </entry>
14045 // <entry>
14046 // <para>
14047 // the type string of %G_VARIANT_TYPE_UINT32; an unsigned 32 bit
14048 // integer.
14049 // </para>
14050 // </entry>
14051 // </row>
14052 // <row>
14053 // <entry>
14054 // <para>
14055 // <literal>x</literal>
14056 // </para>
14057 // </entry>
14058 // <entry>
14059 // <para>
14060 // the type string of %G_VARIANT_TYPE_INT64; a signed 64 bit
14061 // integer.
14062 // </para>
14063 // </entry>
14064 // </row>
14065 // <row>
14066 // <entry>
14067 // <para>
14068 // <literal>t</literal>
14069 // </para>
14070 // </entry>
14071 // <entry>
14072 // <para>
14073 // the type string of %G_VARIANT_TYPE_UINT64; an unsigned 64 bit
14074 // integer.
14075 // </para>
14076 // </entry>
14077 // </row>
14078 // <row>
14079 // <entry>
14080 // <para>
14081 // <literal>h</literal>
14082 // </para>
14083 // </entry>
14084 // <entry>
14085 // <para>
14086 // the type string of %G_VARIANT_TYPE_HANDLE; a signed 32 bit
14087 // value that, by convention, is used as an index into an array
14088 // of file descriptors that are sent alongside a D-Bus message.
14089 // </para>
14090 // </entry>
14091 // </row>
14092 // <row>
14093 // <entry>
14094 // <para>
14095 // <literal>d</literal>
14096 // </para>
14097 // </entry>
14098 // <entry>
14099 // <para>
14100 // the type string of %G_VARIANT_TYPE_DOUBLE; a double precision
14101 // floating point value.
14102 // </para>
14103 // </entry>
14104 // </row>
14105 // <row>
14106 // <entry>
14107 // <para>
14108 // <literal>s</literal>
14109 // </para>
14110 // </entry>
14111 // <entry>
14112 // <para>
14113 // the type string of %G_VARIANT_TYPE_STRING; a string.
14114 // </para>
14115 // </entry>
14116 // </row>
14117 // <row>
14118 // <entry>
14119 // <para>
14120 // <literal>o</literal>
14121 // </para>
14122 // </entry>
14123 // <entry>
14124 // <para>
14125 // the type string of %G_VARIANT_TYPE_OBJECT_PATH; a string in
14126 // the form of a D-Bus object path.
14127 // </para>
14128 // </entry>
14129 // </row>
14130 // <row>
14131 // <entry>
14132 // <para>
14133 // <literal>g</literal>
14134 // </para>
14135 // </entry>
14136 // <entry>
14137 // <para>
14138 // the type string of %G_VARIANT_TYPE_STRING; a string in the
14139 // form of a D-Bus type signature.
14140 // </para>
14141 // </entry>
14142 // </row>
14143 // <row>
14144 // <entry>
14145 // <para>
14146 // <literal>?</literal>
14147 // </para>
14148 // </entry>
14149 // <entry>
14150 // <para>
14151 // the type string of %G_VARIANT_TYPE_BASIC; an indefinite type
14152 // that is a supertype of any of the basic types.
14153 // </para>
14154 // </entry>
14155 // </row>
14156 // <row>
14157 // <entry>
14158 // <para>
14159 // <literal>v</literal>
14160 // </para>
14161 // </entry>
14162 // <entry>
14163 // <para>
14164 // the type string of %G_VARIANT_TYPE_VARIANT; a container type
14165 // that contain any other type of value.
14166 // </para>
14167 // </entry>
14168 // </row>
14169 // <row>
14170 // <entry>
14171 // <para>
14172 // <literal>a</literal>
14173 // </para>
14174 // </entry>
14175 // <entry>
14176 // <para>
14177 // used as a prefix on another type string to mean an array of
14178 // that type; the type string "<literal>ai</literal>", for
14179 // example, is the type of an array of 32 bit signed integers.
14180 // </para>
14181 // </entry>
14182 // </row>
14183 // <row>
14184 // <entry>
14185 // <para>
14186 // <literal>m</literal>
14187 // </para>
14188 // </entry>
14189 // <entry>
14190 // <para>
14191 // used as a prefix on another type string to mean a "maybe", or
14192 // "nullable", version of that type; the type string
14193 // "<literal>ms</literal>", for example, is the type of a value
14194 // that maybe contains a string, or maybe contains nothing.
14195 // </para>
14196 // </entry>
14197 // </row>
14198 // <row>
14199 // <entry>
14200 // <para>
14201 // <literal>()</literal>
14202 // </para>
14203 // </entry>
14204 // <entry>
14205 // <para>
14206 // used to enclose zero or more other concatenated type strings
14207 // to create a tuple type; the type string
14208 // "<literal>(is)</literal>", for example, is the type of a pair
14209 // of an integer and a string.
14210 // </para>
14211 // </entry>
14212 // </row>
14213 // <row>
14214 // <entry>
14215 // <para>
14216 // <literal>r</literal>
14217 // </para>
14218 // </entry>
14219 // <entry>
14220 // <para>
14221 // the type string of %G_VARIANT_TYPE_TUPLE; an indefinite type
14222 // that is a supertype of any tuple type, regardless of the
14223 // number of items.
14224 // </para>
14225 // </entry>
14226 // </row>
14227 // <row>
14228 // <entry>
14229 // <para>
14230 // <literal>{}</literal>
14231 // </para>
14232 // </entry>
14233 // <entry>
14234 // <para>
14235 // used to enclose a basic type string concatenated with another
14236 // type string to create a dictionary entry type, which usually
14237 // appears inside of an array to form a dictionary; the type
14238 // string "<literal>a{sd}</literal>", for example, is the type of
14239 // a dictionary that maps strings to double precision floating
14240 // point values.
14241 // </para>
14242 // <para>
14243 // The first type (the basic type) is the key type and the second
14244 // type is the value type. The reason that the first type is
14245 // restricted to being a basic type is so that it can easily be
14246 // hashed.
14247 // </para>
14248 // </entry>
14249 // </row>
14250 // <row>
14251 // <entry>
14252 // <para>
14253 // <literal>*</literal>
14254 // </para>
14255 // </entry>
14256 // <entry>
14257 // <para>
14258 // the type string of %G_VARIANT_TYPE_ANY; the indefinite type
14259 // that is a supertype of all types. Note that, as with all type
14260 // strings, this character represents exactly one type. It
14261 // cannot be used inside of tuples to mean "any number of items".
14262 // </para>
14263 // </entry>
14264 // </row>
14265 // </tbody>
14266 // </tgroup>
14267 // </informaltable>
14268 // <para>
14269 // Any type string of a container that contains an indefinite type is,
14270 // itself, an indefinite type. For example, the type string
14271 // "<literal>a*</literal>" (corresponding to %G_VARIANT_TYPE_ARRAY) is
14272 // an indefinite type that is a supertype of every array type.
14273 // "<literal>(*s)</literal>" is a supertype of all tuples that
14274 // contain exactly two items where the second item is a string.
14275 // </para>
14276 // <para>
14277 // "<literal>a{?*}</literal>" is an indefinite type that is a
14278 // supertype of all arrays containing dictionary entries where the key
14279 // is any basic type and the value is any type at all. This is, by
14280 // definition, a dictionary, so this type string corresponds to
14281 // %G_VARIANT_TYPE_DICTIONARY. Note that, due to the restriction that
14282 // the key of a dictionary entry must be a basic type,
14283 // "<literal>{**}</literal>" is not a valid type string.
14284 // </para>
14285 // </refsect2>
14286 struct VariantType {
14288 // Creates a new #GVariantType corresponding to the type string given
14289 // by @type_string. It is appropriate to call g_variant_type_free() on
14290 // the return value.
14292 // It is a programmer error to call this function with an invalid type
14293 // string. Use g_variant_type_string_is_valid() if you are unsure.
14294 // RETURNS: a new #GVariantType
14295 // <type_string>: a valid GVariant type string
14296 static VariantType* /*new*/ new_(char* type_string) {
14297 return g_variant_type_new(type_string);
14300 // Constructs a new tuple type, from @items.
14302 // @length is the number of items in @items, or -1 to indicate that
14303 // @items is %NULL-terminated.
14305 // It is appropriate to call g_variant_type_free() on the return value.
14307 // Since 2.24
14308 // RETURNS: a new tuple #GVariantType
14309 // <items>: an array of #GVariantTypes, one for each item
14310 // <length>: the length of @items, or -1
14311 static VariantType* /*new*/ new_tuple(VariantType** items, int length) {
14312 return g_variant_type_new_tuple(items, length);
14315 // Makes a copy of a #GVariantType. It is appropriate to call
14316 // g_variant_type_free() on the return value. @type may not be %NULL.
14318 // Since 2.24
14319 // RETURNS: a new #GVariantType
14320 VariantType* /*new*/ copy() {
14321 return g_variant_type_copy(&this);
14324 // Returns a newly-allocated copy of the type string corresponding to
14325 // @type. The returned string is nul-terminated. It is appropriate to
14326 // call g_free() on the return value.
14328 // Since 2.24
14329 // RETURNS: the corresponding type string
14330 char* /*new*/ dup_string() {
14331 return g_variant_type_dup_string(&this);
14334 // Determines the element type of an array or maybe type.
14336 // This function may only be used with array or maybe types.
14338 // Since 2.24
14339 // RETURNS: the element type of @type
14340 VariantType* element() {
14341 return g_variant_type_element(&this);
14344 // Compares @type1 and @type2 for equality.
14346 // Only returns %TRUE if the types are exactly equal. Even if one type
14347 // is an indefinite type and the other is a subtype of it, %FALSE will
14348 // be returned if they are not exactly equal. If you want to check for
14349 // subtypes, use g_variant_type_is_subtype_of().
14351 // The argument types of @type1 and @type2 are only #gconstpointer to
14352 // allow use with #GHashTable without function pointer casting. For
14353 // both arguments, a valid #GVariantType must be provided.
14355 // Since 2.24
14356 // RETURNS: %TRUE if @type1 and @type2 are exactly equal
14357 // <type2>: a #GVariantType
14358 int equal(const(VariantType)* type2) {
14359 return g_variant_type_equal(&this, type2);
14362 // Determines the first item type of a tuple or dictionary entry
14363 // type.
14365 // This function may only be used with tuple or dictionary entry types,
14366 // but must not be used with the generic tuple type
14367 // %G_VARIANT_TYPE_TUPLE.
14369 // In the case of a dictionary entry type, this returns the type of
14370 // the key.
14372 // %NULL is returned in case of @type being %G_VARIANT_TYPE_UNIT.
14374 // This call, together with g_variant_type_next() provides an iterator
14375 // interface over tuple and dictionary entry types.
14377 // Since 2.24
14378 // RETURNS: the first item type of @type, or %NULL
14379 VariantType* first() {
14380 return g_variant_type_first(&this);
14383 // Frees a #GVariantType that was allocated with
14384 // g_variant_type_copy(), g_variant_type_new() or one of the container
14385 // type constructor functions.
14387 // In the case that @type is %NULL, this function does nothing.
14389 // Since 2.24
14390 void free() {
14391 g_variant_type_free(&this);
14394 // Returns the length of the type string corresponding to the given
14395 // @type. This function must be used to determine the valid extent of
14396 // the memory region returned by g_variant_type_peek_string().
14398 // Since 2.24
14399 // RETURNS: the length of the corresponding type string
14400 size_t get_string_length() {
14401 return g_variant_type_get_string_length(&this);
14404 // Hashes @type.
14406 // The argument type of @type is only #gconstpointer to allow use with
14407 // #GHashTable without function pointer casting. A valid
14408 // #GVariantType must be provided.
14410 // Since 2.24
14411 // RETURNS: the hash value
14412 uint hash() {
14413 return g_variant_type_hash(&this);
14416 // Determines if the given @type is an array type. This is true if the
14417 // type string for @type starts with an 'a'.
14419 // This function returns %TRUE for any indefinite type for which every
14420 // definite subtype is an array type -- %G_VARIANT_TYPE_ARRAY, for
14421 // example.
14423 // Since 2.24
14424 // RETURNS: %TRUE if @type is an array type
14425 int is_array() {
14426 return g_variant_type_is_array(&this);
14429 // Determines if the given @type is a basic type.
14431 // Basic types are booleans, bytes, integers, doubles, strings, object
14432 // paths and signatures.
14434 // Only a basic type may be used as the key of a dictionary entry.
14436 // This function returns %FALSE for all indefinite types except
14437 // %G_VARIANT_TYPE_BASIC.
14439 // Since 2.24
14440 // RETURNS: %TRUE if @type is a basic type
14441 int is_basic() {
14442 return g_variant_type_is_basic(&this);
14445 // Determines if the given @type is a container type.
14447 // Container types are any array, maybe, tuple, or dictionary
14448 // entry types plus the variant type.
14450 // This function returns %TRUE for any indefinite type for which every
14451 // definite subtype is a container -- %G_VARIANT_TYPE_ARRAY, for
14452 // example.
14454 // Since 2.24
14455 // RETURNS: %TRUE if @type is a container type
14456 int is_container() {
14457 return g_variant_type_is_container(&this);
14460 // Determines if the given @type is definite (ie: not indefinite).
14462 // A type is definite if its type string does not contain any indefinite
14463 // type characters ('*', '?', or 'r').
14465 // A #GVariant instance may not have an indefinite type, so calling
14466 // this function on the result of g_variant_get_type() will always
14467 // result in %TRUE being returned. Calling this function on an
14468 // indefinite type like %G_VARIANT_TYPE_ARRAY, however, will result in
14469 // %FALSE being returned.
14471 // Since 2.24
14472 // RETURNS: %TRUE if @type is definite
14473 int is_definite() {
14474 return g_variant_type_is_definite(&this);
14477 // Determines if the given @type is a dictionary entry type. This is
14478 // true if the type string for @type starts with a '{'.
14480 // This function returns %TRUE for any indefinite type for which every
14481 // definite subtype is a dictionary entry type --
14482 // %G_VARIANT_TYPE_DICT_ENTRY, for example.
14484 // Since 2.24
14485 // RETURNS: %TRUE if @type is a dictionary entry type
14486 int is_dict_entry() {
14487 return g_variant_type_is_dict_entry(&this);
14490 // Determines if the given @type is a maybe type. This is true if the
14491 // type string for @type starts with an 'm'.
14493 // This function returns %TRUE for any indefinite type for which every
14494 // definite subtype is a maybe type -- %G_VARIANT_TYPE_MAYBE, for
14495 // example.
14497 // Since 2.24
14498 // RETURNS: %TRUE if @type is a maybe type
14499 int is_maybe() {
14500 return g_variant_type_is_maybe(&this);
14503 // Checks if @type is a subtype of @supertype.
14505 // This function returns %TRUE if @type is a subtype of @supertype. All
14506 // types are considered to be subtypes of themselves. Aside from that,
14507 // only indefinite types can have subtypes.
14509 // Since 2.24
14510 // RETURNS: %TRUE if @type is a subtype of @supertype
14511 // <supertype>: a #GVariantType
14512 int is_subtype_of(VariantType* supertype) {
14513 return g_variant_type_is_subtype_of(&this, supertype);
14516 // Determines if the given @type is a tuple type. This is true if the
14517 // type string for @type starts with a '(' or if @type is
14518 // %G_VARIANT_TYPE_TUPLE.
14520 // This function returns %TRUE for any indefinite type for which every
14521 // definite subtype is a tuple type -- %G_VARIANT_TYPE_TUPLE, for
14522 // example.
14524 // Since 2.24
14525 // RETURNS: %TRUE if @type is a tuple type
14526 int is_tuple() {
14527 return g_variant_type_is_tuple(&this);
14530 // Determines if the given @type is the variant type.
14532 // Since 2.24
14533 // RETURNS: %TRUE if @type is the variant type
14534 int is_variant() {
14535 return g_variant_type_is_variant(&this);
14538 // Determines the key type of a dictionary entry type.
14540 // This function may only be used with a dictionary entry type. Other
14541 // than the additional restriction, this call is equivalent to
14542 // g_variant_type_first().
14544 // Since 2.24
14545 // RETURNS: the key type of the dictionary entry
14546 VariantType* key() {
14547 return g_variant_type_key(&this);
14550 // Determines the number of items contained in a tuple or
14551 // dictionary entry type.
14553 // This function may only be used with tuple or dictionary entry types,
14554 // but must not be used with the generic tuple type
14555 // %G_VARIANT_TYPE_TUPLE.
14557 // In the case of a dictionary entry type, this function will always
14558 // return 2.
14560 // Since 2.24
14561 // RETURNS: the number of items in @type
14562 size_t n_items() {
14563 return g_variant_type_n_items(&this);
14566 // Constructs the type corresponding to an array of elements of the
14567 // type @type.
14569 // It is appropriate to call g_variant_type_free() on the return value.
14571 // Since 2.24
14572 // RETURNS: a new array #GVariantType
14573 VariantType* /*new*/ new_array() {
14574 return g_variant_type_new_array(&this);
14577 // Constructs the type corresponding to a dictionary entry with a key
14578 // of type @key and a value of type @value.
14580 // It is appropriate to call g_variant_type_free() on the return value.
14582 // Since 2.24
14583 // RETURNS: a new dictionary entry #GVariantType
14584 // <value>: a #GVariantType
14585 VariantType* /*new*/ new_dict_entry(VariantType* value) {
14586 return g_variant_type_new_dict_entry(&this, value);
14589 // Constructs the type corresponding to a maybe instance containing
14590 // type @type or Nothing.
14592 // It is appropriate to call g_variant_type_free() on the return value.
14594 // Since 2.24
14595 // RETURNS: a new maybe #GVariantType
14596 VariantType* /*new*/ new_maybe() {
14597 return g_variant_type_new_maybe(&this);
14600 // Determines the next item type of a tuple or dictionary entry
14601 // type.
14603 // @type must be the result of a previous call to
14604 // g_variant_type_first() or g_variant_type_next().
14606 // If called on the key type of a dictionary entry then this call
14607 // returns the value type. If called on the value type of a dictionary
14608 // entry then this call returns %NULL.
14610 // For tuples, %NULL is returned when @type is the last item in a tuple.
14612 // Since 2.24
14613 // RETURNS: the next #GVariantType after @type, or %NULL
14614 VariantType* next() {
14615 return g_variant_type_next(&this);
14618 // Unintrospectable method: peek_string() / g_variant_type_peek_string()
14619 // Returns the type string corresponding to the given @type. The
14620 // result is not nul-terminated; in order to determine its length you
14621 // must call g_variant_type_get_string_length().
14623 // To get a nul-terminated string, see g_variant_type_dup_string().
14625 // Since 2.24
14626 // RETURNS: the corresponding type string (not nul-terminated)
14627 char* peek_string() {
14628 return g_variant_type_peek_string(&this);
14631 // Determines the value type of a dictionary entry type.
14633 // This function may only be used with a dictionary entry type.
14635 // Since 2.24
14636 // RETURNS: the value type of the dictionary entry
14637 VariantType* value() {
14638 return g_variant_type_value(&this);
14640 static VariantType* checked_(char* arg_a) {
14641 return g_variant_type_checked_(arg_a);
14644 // Checks if @type_string is a valid GVariant type string. This call is
14645 // equivalent to calling g_variant_type_string_scan() and confirming
14646 // that the following character is a nul terminator.
14648 // Since 2.24
14649 // RETURNS: %TRUE if @type_string is exactly one valid type string
14650 // <type_string>: a pointer to any string
14651 static int string_is_valid(char* type_string) {
14652 return g_variant_type_string_is_valid(type_string);
14655 // Scan for a single complete and valid GVariant type string in @string.
14656 // The memory pointed to by @limit (or bytes beyond it) is never
14657 // accessed.
14659 // If a valid type string is found, @endptr is updated to point to the
14660 // first character past the end of the string that was found and %TRUE
14661 // is returned.
14663 // If there is no valid type string starting at @string, or if the type
14664 // string does not end before @limit then %FALSE is returned.
14666 // For the simple case of checking if a string is a valid type string,
14667 // see g_variant_type_string_is_valid().
14668 // RETURNS: %TRUE if a valid type string was found
14669 // <string>: a pointer to any string
14670 // <limit>: the end of @string, or %NULL
14671 // <endptr>: location to store the end pointer, or %NULL
14672 static int string_scan(char* string_, char* limit=null, /*out*/ char** endptr=null) {
14673 return g_variant_type_string_scan(string_, limit, endptr);
14678 // Declares a type of function which takes no arguments
14679 // and has no return value. It is used to specify the type
14680 // function passed to g_atexit().
14681 extern (C) alias void function () VoidFunc;
14683 enum int WIN32_MSG_HANDLE = 19981206;
14685 // A wrapper for the POSIX access() function. This function is used to
14686 // test a pathname for one or several of read, write or execute
14687 // permissions, or just existence.
14689 // On Windows, the file protection mechanism is not at all POSIX-like,
14690 // and the underlying function in the C library only checks the
14691 // FAT-style READONLY attribute, and does not look at the ACL of a
14692 // file at all. This function is this in practise almost useless on
14693 // Windows. Software that needs to handle file permissions on Windows
14694 // more exactly should use the Win32 API.
14696 // See your C library manual for more details about access().
14698 // object that has all the tested permissions, or -1 otherwise or on
14699 // error.
14700 // RETURNS: zero if the pathname refers to an existing file system
14701 // <filename>: a pathname in the GLib file name encoding (UTF-8 on Windows)
14702 // <mode>: as in access()
14703 static int access(char* filename, int mode) {
14704 return g_access(filename, mode);
14708 // Frees the memory allocated for the #GArray. If @free_segment is
14709 // %TRUE it frees the memory block holding the elements as well and
14710 // also each element if @array has a @element_free_func set. Pass
14711 // %FALSE if you want to free the #GArray wrapper but preserve the
14712 // underlying array for use elsewhere. If the reference count of @array
14713 // is greater than one, the #GArray wrapper is preserved but the size
14714 // of @array will be set to zero.
14716 // <note><para>If array elements contain dynamically-allocated memory,
14717 // they should be freed separately.</para></note>
14718 // <array>: a #GArray.
14719 // <free_segment>: if %TRUE the actual element data is freed as well.
14720 static char* /*new*/ array_free(Array* array, int free_segment) {
14721 return g_array_free(array, free_segment);
14725 // Gets the size of the elements in @array.
14726 // RETURNS: Size of each element, in bytes.
14727 // <array>: A #GArray.
14728 static uint array_get_element_size(Array* array) {
14729 return g_array_get_element_size(array);
14733 // Atomically decrements the reference count of @array by one. If the
14734 // reference count drops to 0, all memory allocated by the array is
14735 // released. This function is MT-safe and may be called from any
14736 // thread.
14737 // <array>: A #GArray.
14738 static void array_unref(Array* array) {
14739 g_array_unref(array);
14743 // Determines the numeric value of a character as a decimal
14744 // digit. Differs from g_unichar_digit_value() because it takes
14745 // a char, so there's no worry about sign extension if characters
14746 // are signed.
14748 // g_ascii_isdigit()), its numeric value. Otherwise, -1.
14749 // RETURNS: If @c is a decimal digit (according to
14750 // <c>: an ASCII character.
14751 static int ascii_digit_value(char c) {
14752 return g_ascii_digit_value(c);
14756 // Converts a #gdouble to a string, using the '.' as
14757 // decimal point.
14759 // This functions generates enough precision that converting
14760 // the string back using g_ascii_strtod() gives the same machine-number
14761 // (on machines with IEEE compatible 64bit doubles). It is
14762 // guaranteed that the size of the resulting string will never
14763 // be larger than @G_ASCII_DTOSTR_BUF_SIZE bytes.
14764 // RETURNS: The pointer to the buffer with the converted string.
14765 // <buffer>: A buffer to place the resulting string in
14766 // <buf_len>: The length of the buffer.
14767 // <d>: The #gdouble to convert
14768 static char* /*new*/ ascii_dtostr(char* buffer, int buf_len, double d) {
14769 return g_ascii_dtostr(buffer, buf_len, d);
14773 // Converts a #gdouble to a string, using the '.' as
14774 // decimal point. To format the number you pass in
14775 // a printf()-style format string. Allowed conversion
14776 // specifiers are 'e', 'E', 'f', 'F', 'g' and 'G'.
14778 // If you just want to want to serialize the value into a
14779 // string, use g_ascii_dtostr().
14780 // RETURNS: The pointer to the buffer with the converted string.
14781 // <buffer>: A buffer to place the resulting string in
14782 // <buf_len>: The length of the buffer.
14783 // <format>: The printf()-style format to use for the code to use for converting.
14784 // <d>: The #gdouble to convert
14785 static char* /*new*/ ascii_formatd(char* buffer, int buf_len, char* format, double d) {
14786 return g_ascii_formatd(buffer, buf_len, format, d);
14790 // Compare two strings, ignoring the case of ASCII characters.
14792 // Unlike the BSD strcasecmp() function, this only recognizes standard
14793 // ASCII letters and ignores the locale, treating all non-ASCII
14794 // bytes as if they are not letters.
14796 // This function should be used only on strings that are known to be
14797 // in encodings where the bytes corresponding to ASCII letters always
14798 // represent themselves. This includes UTF-8 and the ISO-8859-*
14799 // charsets, but not for instance double-byte encodings like the
14800 // Windows Codepage 932, where the trailing bytes of double-byte
14801 // characters include all ASCII letters. If you compare two CP932
14802 // strings using this function, you will get false matches.
14804 // or a positive value if @s1 &gt; @s2.
14805 // RETURNS: 0 if the strings match, a negative value if @s1 &lt; @s2,
14806 // <s1>: string to compare with @s2.
14807 // <s2>: string to compare with @s1.
14808 static int ascii_strcasecmp(char* s1, char* s2) {
14809 return g_ascii_strcasecmp(s1, s2);
14813 // Converts all upper case ASCII letters to lower case ASCII letters.
14815 // characters in @str converted to lower case, with
14816 // semantics that exactly match g_ascii_tolower(). (Note
14817 // that this is unlike the old g_strdown(), which modified
14818 // the string in place.)
14819 // RETURNS: a newly-allocated string, with all the upper case
14820 // <str>: a string.
14821 // <len>: length of @str in bytes, or -1 if @str is nul-terminated.
14822 static char* /*new*/ ascii_strdown(char* str, ssize_t len) {
14823 return g_ascii_strdown(str, len);
14827 // Compare @s1 and @s2, ignoring the case of ASCII characters and any
14828 // characters after the first @n in each string.
14830 // Unlike the BSD strcasecmp() function, this only recognizes standard
14831 // ASCII letters and ignores the locale, treating all non-ASCII
14832 // characters as if they are not letters.
14834 // The same warning as in g_ascii_strcasecmp() applies: Use this
14835 // function only on strings known to be in encodings where bytes
14836 // corresponding to ASCII letters always represent themselves.
14838 // or a positive value if @s1 &gt; @s2.
14839 // RETURNS: 0 if the strings match, a negative value if @s1 &lt; @s2,
14840 // <s1>: string to compare with @s2.
14841 // <s2>: string to compare with @s1.
14842 // <n>: number of characters to compare.
14843 static int ascii_strncasecmp(char* s1, char* s2, size_t n) {
14844 return g_ascii_strncasecmp(s1, s2, n);
14848 // Converts a string to a #gdouble value.
14850 // This function behaves like the standard strtod() function
14851 // does in the C locale. It does this without actually changing
14852 // the current locale, since that would not be thread-safe.
14853 // A limitation of the implementation is that this function
14854 // will still accept localized versions of infinities and NANs.
14856 // This function is typically used when reading configuration
14857 // files or other non-user input that should be locale independent.
14858 // To handle input from the user you should normally use the
14859 // locale-sensitive system strtod() function.
14861 // To convert from a #gdouble to a string in a locale-insensitive
14862 // way, use g_ascii_dtostr().
14864 // If the correct value would cause overflow, plus or minus %HUGE_VAL
14865 // is returned (according to the sign of the value), and %ERANGE is
14866 // stored in %errno. If the correct value would cause underflow,
14867 // zero is returned and %ERANGE is stored in %errno.
14869 // This function resets %errno before calling strtod() so that
14870 // you can reliably detect overflow and underflow.
14871 // RETURNS: the #gdouble value.
14872 // <nptr>: the string to convert to a numeric value.
14873 // <endptr>: if non-%NULL, it returns the character after the last character used in the conversion.
14874 static double ascii_strtod(char* nptr, char** endptr) {
14875 return g_ascii_strtod(nptr, endptr);
14879 // Converts a string to a #gint64 value.
14880 // This function behaves like the standard strtoll() function
14881 // does in the C locale. It does this without actually
14882 // changing the current locale, since that would not be
14883 // thread-safe.
14885 // This function is typically used when reading configuration
14886 // files or other non-user input that should be locale independent.
14887 // To handle input from the user you should normally use the
14888 // locale-sensitive system strtoll() function.
14890 // If the correct value would cause overflow, %G_MAXINT64 or %G_MININT64
14891 // is returned, and %ERANGE is stored in %errno. If the base is
14892 // outside the valid range, zero is returned, and %EINVAL is stored
14893 // in %errno. If the string conversion fails, zero is returned, and
14894 // @endptr returns @nptr (if @endptr is non-%NULL).
14895 // RETURNS: the #gint64 value or zero on error.
14896 // <nptr>: the string to convert to a numeric value.
14897 // <endptr>: if non-%NULL, it returns the character after the last character used in the conversion.
14898 // <base>: to be used for the conversion, 2..36 or 0
14899 static long ascii_strtoll(char* nptr, char** endptr, uint base) {
14900 return g_ascii_strtoll(nptr, endptr, base);
14904 // Converts a string to a #guint64 value.
14905 // This function behaves like the standard strtoull() function
14906 // does in the C locale. It does this without actually
14907 // changing the current locale, since that would not be
14908 // thread-safe.
14910 // This function is typically used when reading configuration
14911 // files or other non-user input that should be locale independent.
14912 // To handle input from the user you should normally use the
14913 // locale-sensitive system strtoull() function.
14915 // If the correct value would cause overflow, %G_MAXUINT64
14916 // is returned, and %ERANGE is stored in %errno. If the base is
14917 // outside the valid range, zero is returned, and %EINVAL is stored
14918 // in %errno. If the string conversion fails, zero is returned, and
14919 // @endptr returns @nptr (if @endptr is non-%NULL).
14920 // RETURNS: the #guint64 value or zero on error.
14921 // <nptr>: the string to convert to a numeric value.
14922 // <endptr>: if non-%NULL, it returns the character after the last character used in the conversion.
14923 // <base>: to be used for the conversion, 2..36 or 0
14924 static ulong ascii_strtoull(char* nptr, char** endptr, uint base) {
14925 return g_ascii_strtoull(nptr, endptr, base);
14929 // Converts all lower case ASCII letters to upper case ASCII letters.
14931 // characters in @str converted to upper case, with
14932 // semantics that exactly match g_ascii_toupper(). (Note
14933 // that this is unlike the old g_strup(), which modified
14934 // the string in place.)
14935 // RETURNS: a newly allocated string, with all the lower case
14936 // <str>: a string.
14937 // <len>: length of @str in bytes, or -1 if @str is nul-terminated.
14938 static char* /*new*/ ascii_strup(char* str, ssize_t len) {
14939 return g_ascii_strup(str, len);
14943 // Convert a character to ASCII lower case.
14945 // Unlike the standard C library tolower() function, this only
14946 // recognizes standard ASCII letters and ignores the locale, returning
14947 // all non-ASCII characters unchanged, even if they are lower case
14948 // letters in a particular character set. Also unlike the standard
14949 // library function, this takes and returns a char, not an int, so
14950 // don't call it on %EOF but no need to worry about casting to #guchar
14951 // before passing a possibly non-ASCII character in.
14953 // If @c is not an ASCII upper case letter,
14954 // @c is returned unchanged.
14955 // RETURNS: the result of converting @c to lower case.
14956 // <c>: any character.
14957 static char ascii_tolower(char c) {
14958 return g_ascii_tolower(c);
14962 // Convert a character to ASCII upper case.
14964 // Unlike the standard C library toupper() function, this only
14965 // recognizes standard ASCII letters and ignores the locale, returning
14966 // all non-ASCII characters unchanged, even if they are upper case
14967 // letters in a particular character set. Also unlike the standard
14968 // library function, this takes and returns a char, not an int, so
14969 // don't call it on %EOF but no need to worry about casting to #guchar
14970 // before passing a possibly non-ASCII character in.
14972 // If @c is not an ASCII lower case letter,
14973 // @c is returned unchanged.
14974 // RETURNS: the result of converting @c to upper case.
14975 // <c>: any character.
14976 static char ascii_toupper(char c) {
14977 return g_ascii_toupper(c);
14981 // Determines the numeric value of a character as a hexidecimal
14982 // digit. Differs from g_unichar_xdigit_value() because it takes
14983 // a char, so there's no worry about sign extension if characters
14984 // are signed.
14986 // g_ascii_isxdigit()), its numeric value. Otherwise, -1.
14987 // RETURNS: If @c is a hex digit (according to
14988 // <c>: an ASCII character.
14989 static int ascii_xdigit_value(char c) {
14990 return g_ascii_xdigit_value(c);
14993 static void assert_warning(char* log_domain, char* file, int line, char* pretty_function, char* expression) {
14994 g_assert_warning(log_domain, file, line, pretty_function, expression);
14997 static void assertion_message(char* domain, char* file, int line, char* func, char* message) {
14998 g_assertion_message(domain, file, line, func, message);
15001 // Unintrospectable function: assertion_message_cmpnum() / g_assertion_message_cmpnum()
15002 static void assertion_message_cmpnum(char* domain, char* file, int line, char* func, char* expr, real arg1, char* cmp, real arg2, char numtype) {
15003 g_assertion_message_cmpnum(domain, file, line, func, expr, arg1, cmp, arg2, numtype);
15006 static void assertion_message_cmpstr(char* domain, char* file, int line, char* func, char* expr, char* arg1, char* cmp, char* arg2) {
15007 g_assertion_message_cmpstr(domain, file, line, func, expr, arg1, cmp, arg2);
15010 static void assertion_message_error(char* domain, char* file, int line, char* func, char* expr, Error* error, Quark error_domain, int error_code) {
15011 g_assertion_message_error(domain, file, line, func, expr, error, error_domain, error_code);
15014 static void assertion_message_expr(char* domain, char* file, int line, char* func, char* expr) {
15015 g_assertion_message_expr(domain, file, line, func, expr);
15019 // Specifies a function to be called at normal program termination.
15021 // Since GLib 2.8.2, on Windows g_atexit() actually is a preprocessor
15022 // macro that maps to a call to the atexit() function in the C
15023 // library. This means that in case the code that calls g_atexit(),
15024 // i.e. atexit(), is in a DLL, the function will be called when the
15025 // DLL is detached from the program. This typically makes more sense
15026 // than that the function is called when the GLib DLL is detached,
15027 // which happened earlier when g_atexit() was a function in the GLib
15028 // DLL.
15030 // The behaviour of atexit() in the context of dynamically loaded
15031 // modules is not formally specified and varies wildly.
15033 // On POSIX systems, calling g_atexit() (or atexit()) in a dynamically
15034 // loaded module which is unloaded before the program terminates might
15035 // well cause a crash at program exit.
15037 // Some POSIX systems implement atexit() like Windows, and have each
15038 // dynamically loaded module maintain an own atexit chain that is
15039 // called when the module is unloaded.
15041 // On other POSIX systems, before a dynamically loaded module is
15042 // unloaded, the registered atexit functions (if any) residing in that
15043 // module are called, regardless where the code that registered them
15044 // resided. This is presumably the most robust approach.
15046 // As can be seen from the above, for portability it's best to avoid
15047 // calling g_atexit() (or atexit()) except in the main executable of a
15048 // program.
15049 // <func>: the function to call on normal program termination.
15050 static void atexit(VoidFunc func) {
15051 g_atexit(func);
15055 // Atomically adds @val to the value of @atomic.
15057 // Think of this operation as an atomic version of
15058 // <literal>{ tmp = *atomic; *@atomic += @val; return tmp; }</literal>
15060 // This call acts as a full compiler and hardware memory barrier.
15062 // Before version 2.30, this function did not return a value
15063 // (but g_atomic_int_exchange_and_add() did, and had the same meaning).
15064 // RETURNS: the value of @atomic before the add, signed
15065 // <atomic>: a pointer to a #gint or #guint
15066 // <val>: the value to add
15067 static int atomic_int_add(int* atomic, int val) {
15068 return g_atomic_int_add(atomic, val);
15072 // Performs an atomic bitwise 'and' of the value of @atomic and @val,
15073 // storing the result back in @atomic.
15075 // This call acts as a full compiler and hardware memory barrier.
15077 // Think of this operation as an atomic version of
15078 // <literal>{ tmp = *atomic; *@atomic &= @val; return tmp; }</literal>
15079 // RETURNS: the value of @atomic before the operation, unsigned
15080 // <atomic>: a pointer to a #gint or #guint
15081 // <val>: the value to 'and'
15082 static uint atomic_int_and(uint* atomic, uint val) {
15083 return g_atomic_int_and(atomic, val);
15087 // Compares @atomic to @oldval and, if equal, sets it to @newval.
15088 // If @atomic was not equal to @oldval then no change occurs.
15090 // This compare and exchange is done atomically.
15092 // Think of this operation as an atomic version of
15093 // <literal>{ if (*@atomic == @oldval) { *@atomic = @newval; return TRUE; } else return FALSE; }</literal>
15095 // This call acts as a full compiler and hardware memory barrier.
15096 // RETURNS: %TRUE if the exchange took place
15097 // <atomic>: a pointer to a #gint or #guint
15098 // <oldval>: the value to compare with
15099 // <newval>: the value to conditionally replace with
15100 static int atomic_int_compare_and_exchange(int* atomic, int oldval, int newval) {
15101 return g_atomic_int_compare_and_exchange(atomic, oldval, newval);
15105 // Decrements the value of @atomic by 1.
15107 // Think of this operation as an atomic version of
15108 // <literal>{ *@atomic -= 1; return (*@atomic == 0); }</literal>
15110 // This call acts as a full compiler and hardware memory barrier.
15111 // RETURNS: %TRUE if the resultant value is zero
15112 // <atomic>: a pointer to a #gint or #guint
15113 static int atomic_int_dec_and_test(int* atomic) {
15114 return g_atomic_int_dec_and_test(atomic);
15118 // This function existed before g_atomic_int_add() returned the prior
15119 // value of the integer (which it now does). It is retained only for
15120 // compatibility reasons. Don't use this function in new code.
15121 // RETURNS: the value of @atomic before the add, signed
15122 // <atomic>: a pointer to a #gint
15123 // <val>: the value to add
15124 static int atomic_int_exchange_and_add(int* atomic, int val) {
15125 return g_atomic_int_exchange_and_add(atomic, val);
15129 // Gets the current value of @atomic.
15131 // This call acts as a full compiler and hardware
15132 // memory barrier (before the get).
15133 // RETURNS: the value of the integer
15134 // <atomic>: a pointer to a #gint or #guint
15135 static int atomic_int_get(int* atomic) {
15136 return g_atomic_int_get(atomic);
15140 // Increments the value of @atomic by 1.
15142 // Think of this operation as an atomic version of
15143 // <literal>{ *@atomic += 1; }</literal>
15145 // This call acts as a full compiler and hardware memory barrier.
15146 // <atomic>: a pointer to a #gint or #guint
15147 static void atomic_int_inc(int* atomic) {
15148 g_atomic_int_inc(atomic);
15152 // Performs an atomic bitwise 'or' of the value of @atomic and @val,
15153 // storing the result back in @atomic.
15155 // Think of this operation as an atomic version of
15156 // <literal>{ tmp = *atomic; *@atomic |= @val; return tmp; }</literal>
15158 // This call acts as a full compiler and hardware memory barrier.
15159 // RETURNS: the value of @atomic before the operation, unsigned
15160 // <atomic>: a pointer to a #gint or #guint
15161 // <val>: the value to 'or'
15162 static uint atomic_int_or(uint* atomic, uint val) {
15163 return g_atomic_int_or(atomic, val);
15167 // Sets the value of @atomic to @newval.
15169 // This call acts as a full compiler and hardware
15170 // memory barrier (after the set).
15171 // <atomic>: a pointer to a #gint or #guint
15172 // <newval>: a new value to store
15173 static void atomic_int_set(int* atomic, int newval) {
15174 g_atomic_int_set(atomic, newval);
15178 // Performs an atomic bitwise 'xor' of the value of @atomic and @val,
15179 // storing the result back in @atomic.
15181 // Think of this operation as an atomic version of
15182 // <literal>{ tmp = *atomic; *@atomic ^= @val; return tmp; }</literal>
15184 // This call acts as a full compiler and hardware memory barrier.
15185 // RETURNS: the value of @atomic before the operation, unsigned
15186 // <atomic>: a pointer to a #gint or #guint
15187 // <val>: the value to 'xor'
15188 static uint atomic_int_xor(uint* atomic, uint val) {
15189 return g_atomic_int_xor(atomic, val);
15193 // Atomically adds @val to the value of @atomic.
15195 // Think of this operation as an atomic version of
15196 // <literal>{ tmp = *atomic; *@atomic += @val; return tmp; }</literal>
15198 // This call acts as a full compiler and hardware memory barrier.
15199 // RETURNS: the value of @atomic before the add, signed
15200 // <atomic>: a pointer to a #gpointer-sized value
15201 // <val>: the value to add
15202 static ssize_t atomic_pointer_add(void* atomic, ssize_t val) {
15203 return g_atomic_pointer_add(atomic, val);
15207 // Performs an atomic bitwise 'and' of the value of @atomic and @val,
15208 // storing the result back in @atomic.
15210 // Think of this operation as an atomic version of
15211 // <literal>{ tmp = *atomic; *@atomic &= @val; return tmp; }</literal>
15213 // This call acts as a full compiler and hardware memory barrier.
15214 // RETURNS: the value of @atomic before the operation, unsigned
15215 // <atomic>: a pointer to a #gpointer-sized value
15216 // <val>: the value to 'and'
15217 static size_t atomic_pointer_and(void* atomic, size_t val) {
15218 return g_atomic_pointer_and(atomic, val);
15222 // Compares @atomic to @oldval and, if equal, sets it to @newval.
15223 // If @atomic was not equal to @oldval then no change occurs.
15225 // This compare and exchange is done atomically.
15227 // Think of this operation as an atomic version of
15228 // <literal>{ if (*@atomic == @oldval) { *@atomic = @newval; return TRUE; } else return FALSE; }</literal>
15230 // This call acts as a full compiler and hardware memory barrier.
15231 // RETURNS: %TRUE if the exchange took place
15232 // <atomic>: a pointer to a #gpointer-sized value
15233 // <oldval>: the value to compare with
15234 // <newval>: the value to conditionally replace with
15235 static int atomic_pointer_compare_and_exchange(void* atomic, void* oldval, void* newval) {
15236 return g_atomic_pointer_compare_and_exchange(atomic, oldval, newval);
15240 // Unintrospectable function: atomic_pointer_get() / g_atomic_pointer_get()
15241 // Gets the current value of @atomic.
15243 // This call acts as a full compiler and hardware
15244 // memory barrier (before the get).
15245 // RETURNS: the value of the pointer
15246 // <atomic>: a pointer to a #gpointer-sized value
15247 static void* atomic_pointer_get(void* atomic) {
15248 return g_atomic_pointer_get(atomic);
15252 // Performs an atomic bitwise 'or' of the value of @atomic and @val,
15253 // storing the result back in @atomic.
15255 // Think of this operation as an atomic version of
15256 // <literal>{ tmp = *atomic; *@atomic |= @val; return tmp; }</literal>
15258 // This call acts as a full compiler and hardware memory barrier.
15259 // RETURNS: the value of @atomic before the operation, unsigned
15260 // <atomic>: a pointer to a #gpointer-sized value
15261 // <val>: the value to 'or'
15262 static size_t atomic_pointer_or(void* atomic, size_t val) {
15263 return g_atomic_pointer_or(atomic, val);
15267 // Sets the value of @atomic to @newval.
15269 // This call acts as a full compiler and hardware
15270 // memory barrier (after the set).
15271 // <atomic>: a pointer to a #gpointer-sized value
15272 // <newval>: a new value to store
15273 static void atomic_pointer_set(void* atomic, void* newval) {
15274 g_atomic_pointer_set(atomic, newval);
15278 // Performs an atomic bitwise 'xor' of the value of @atomic and @val,
15279 // storing the result back in @atomic.
15281 // Think of this operation as an atomic version of
15282 // <literal>{ tmp = *atomic; *@atomic ^= @val; return tmp; }</literal>
15284 // This call acts as a full compiler and hardware memory barrier.
15285 // RETURNS: the value of @atomic before the operation, unsigned
15286 // <atomic>: a pointer to a #gpointer-sized value
15287 // <val>: the value to 'xor'
15288 static size_t atomic_pointer_xor(void* atomic, size_t val) {
15289 return g_atomic_pointer_xor(atomic, val);
15293 // Decode a sequence of Base-64 encoded text into binary data
15295 // newly allocated buffer containing the binary data
15296 // that @text represents. The returned buffer must
15297 // be freed with g_free().
15298 // <text>: zero-terminated string with base64 text to decode
15299 // <out_len>: The length of the decoded data is written here
15300 static ubyte* /*new*/ base64_decode(char* text, /*out*/ size_t* out_len) {
15301 return g_base64_decode(text, out_len);
15305 // Decode a sequence of Base-64 encoded text into binary data
15306 // by overwriting the input data.
15308 // is the same as the input @text.
15309 // RETURNS: The binary data that @text responds. This pointer
15310 // <text>: zero-terminated string with base64 text to decode
15311 // <out_len>: The length of the decoded data is written here
15312 static ubyte* base64_decode_inplace(/*inout*/ ubyte* text, /*inout*/ size_t* out_len) {
15313 return g_base64_decode_inplace(text, out_len);
15317 // Incrementally decode a sequence of binary data from its Base-64 stringified
15318 // representation. By calling this function multiple times you can convert
15319 // data in chunks to avoid having to have the full encoded data in memory.
15321 // The output buffer must be large enough to fit all the data that will
15322 // be written to it. Since base64 encodes 3 bytes in 4 chars you need
15323 // at least: (@len / 4) * 3 + 3 bytes (+ 3 may be needed in case of non-zero
15324 // state).
15325 // RETURNS: The number of bytes of output that was written
15326 // <in>: binary input data
15327 // <len>: max length of @in data to decode
15328 // <out>: output buffer
15329 // <state>: Saved state between steps, initialize to 0
15330 // <save>: Saved state between steps, initialize to 0
15331 static size_t base64_decode_step(ubyte* in_, size_t len, /*out*/ ubyte* out_, /*inout*/ int* state, /*inout*/ uint* save) {
15332 return g_base64_decode_step(in_, len, out_, state, save);
15336 // Encode a sequence of binary data into its Base-64 stringified
15337 // representation.
15339 // encoded string representing @data. The returned string must
15340 // be freed with g_free().
15341 // RETURNS: a newly allocated, zero-terminated Base-64
15342 // <data>: the binary data to encode
15343 // <len>: the length of @data
15344 static char* /*new*/ base64_encode(ubyte* data, size_t len) {
15345 return g_base64_encode(data, len);
15349 // Flush the status from a sequence of calls to g_base64_encode_step().
15351 // The output buffer must be large enough to fit all the data that will
15352 // be written to it. It will need up to 4 bytes, or up to 5 bytes if
15353 // line-breaking is enabled.
15354 // RETURNS: The number of bytes of output that was written
15355 // <break_lines>: whether to break long lines
15356 // <out>: pointer to destination buffer
15357 // <state>: Saved state from g_base64_encode_step()
15358 // <save>: Saved state from g_base64_encode_step()
15359 static size_t base64_encode_close(int break_lines, /*out*/ ubyte* out_, /*inout*/ int* state, /*inout*/ int* save) {
15360 return g_base64_encode_close(break_lines, out_, state, save);
15364 // Incrementally encode a sequence of binary data into its Base-64 stringified
15365 // representation. By calling this function multiple times you can convert
15366 // data in chunks to avoid having to have the full encoded data in memory.
15368 // When all of the data has been converted you must call
15369 // g_base64_encode_close() to flush the saved state.
15371 // The output buffer must be large enough to fit all the data that will
15372 // be written to it. Due to the way base64 encodes you will need
15373 // at least: (@len / 3 + 1) * 4 + 4 bytes (+ 4 may be needed in case of
15374 // non-zero state). If you enable line-breaking you will need at least:
15375 // ((@len / 3 + 1) * 4 + 4) / 72 + 1 bytes of extra space.
15377 // @break_lines is typically used when putting base64-encoded data in emails.
15378 // It breaks the lines at 72 columns instead of putting all of the text on
15379 // the same line. This avoids problems with long lines in the email system.
15380 // RETURNS: The number of bytes of output that was written
15381 // <in>: the binary data to encode
15382 // <len>: the length of @in
15383 // <break_lines>: whether to break long lines
15384 // <out>: pointer to destination buffer
15385 // <state>: Saved state between steps, initialize to 0
15386 // <save>: Saved state between steps, initialize to 0
15387 static size_t base64_encode_step(ubyte* in_, size_t len, int break_lines, /*out*/ ubyte* out_, /*inout*/ int* state, /*inout*/ int* save) {
15388 return g_base64_encode_step(in_, len, break_lines, out_, state, save);
15392 // Gets the name of the file without any leading directory components.
15393 // It returns a pointer into the given file name string.
15396 // Deprecated:2.2: Use g_path_get_basename() instead, but notice that
15397 // g_path_get_basename() allocates new memory for the returned string, unlike
15398 // this function which returns a pointer into the argument.
15399 // RETURNS: the name of the file without any leading directory components.
15400 // <file_name>: the name of the file.
15401 static char* basename(char* file_name) {
15402 return g_basename(file_name);
15406 // Sets the indicated @lock_bit in @address. If the bit is already
15407 // set, this call will block until g_bit_unlock() unsets the
15408 // corresponding bit.
15410 // Attempting to lock on two different bits within the same integer is
15411 // not supported and will very probably cause deadlocks.
15413 // The value of the bit that is set is (1u << @bit). If @bit is not
15414 // between 0 and 31 then the result is undefined.
15416 // This function accesses @address atomically. All other accesses to
15417 // @address must be atomic in order for this function to work
15418 // reliably.
15419 // <address>: a pointer to an integer
15420 // <lock_bit>: a bit value between 0 and 31
15421 static void bit_lock(int* address, int lock_bit) {
15422 g_bit_lock(address, lock_bit);
15426 // Find the position of the first bit set in @mask, searching
15427 // from (but not including) @nth_bit upwards. Bits are numbered
15428 // from 0 (least significant) to sizeof(#gulong) * 8 - 1 (31 or 63,
15429 // usually). To start searching from the 0th bit, set @nth_bit to -1.
15430 // RETURNS: the index of the first bit set which is higher than @nth_bit
15431 // <mask>: a #gulong containing flags
15432 // <nth_bit>: the index of the bit to start the search from
15433 static int bit_nth_lsf(c_ulong mask, int nth_bit) {
15434 return g_bit_nth_lsf(mask, nth_bit);
15438 // Find the position of the first bit set in @mask, searching
15439 // from (but not including) @nth_bit downwards. Bits are numbered
15440 // from 0 (least significant) to sizeof(#gulong) * 8 - 1 (31 or 63,
15441 // usually). To start searching from the last bit, set @nth_bit to
15442 // -1 or GLIB_SIZEOF_LONG * 8.
15443 // RETURNS: the index of the first bit set which is lower than @nth_bit
15444 // <mask>: a #gulong containing flags
15445 // <nth_bit>: the index of the bit to start the search from
15446 static int bit_nth_msf(c_ulong mask, int nth_bit) {
15447 return g_bit_nth_msf(mask, nth_bit);
15451 // Gets the number of bits used to hold @number,
15452 // e.g. if @number is 4, 3 bits are needed.
15453 // RETURNS: the number of bits used to hold @number
15454 // <number>: a #guint
15455 static uint bit_storage(c_ulong number) {
15456 return g_bit_storage(number);
15460 // Sets the indicated @lock_bit in @address, returning %TRUE if
15461 // successful. If the bit is already set, returns %FALSE immediately.
15463 // Attempting to lock on two different bits within the same integer is
15464 // not supported.
15466 // The value of the bit that is set is (1u << @bit). If @bit is not
15467 // between 0 and 31 then the result is undefined.
15469 // This function accesses @address atomically. All other accesses to
15470 // @address must be atomic in order for this function to work
15471 // reliably.
15472 // RETURNS: %TRUE if the lock was acquired
15473 // <address>: a pointer to an integer
15474 // <lock_bit>: a bit value between 0 and 31
15475 static int bit_trylock(int* address, int lock_bit) {
15476 return g_bit_trylock(address, lock_bit);
15480 // Clears the indicated @lock_bit in @address. If another thread is
15481 // currently blocked in g_bit_lock() on this same bit then it will be
15482 // woken up.
15484 // This function accesses @address atomically. All other accesses to
15485 // @address must be atomic in order for this function to work
15486 // reliably.
15487 // <address>: a pointer to an integer
15488 // <lock_bit>: a bit value between 0 and 31
15489 static void bit_unlock(int* address, int lock_bit) {
15490 g_bit_unlock(address, lock_bit);
15494 // Calls g_mem_chunk_clean() on all #GMemChunk objects.
15496 // Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
15497 // allocator</link> instead
15498 static void blow_chunks() {
15499 g_blow_chunks();
15502 static Quark bookmark_file_error_quark() {
15503 return g_bookmark_file_error_quark();
15507 // Unintrospectable function: build_filename() / g_build_filename()
15508 // Creates a filename from a series of elements using the correct
15509 // separator for filenames.
15511 // On Unix, this function behaves identically to <literal>g_build_path
15512 // (G_DIR_SEPARATOR_S, first_element, ....)</literal>.
15514 // On Windows, it takes into account that either the backslash
15515 // (<literal>\</literal> or slash (<literal>/</literal>) can be used
15516 // as separator in filenames, but otherwise behaves as on Unix. When
15517 // file pathname separators need to be inserted, the one that last
15518 // previously occurred in the parameters (reading from left to right)
15519 // is used.
15521 // No attempt is made to force the resulting filename to be an absolute
15522 // path. If the first element is a relative path, the result will
15523 // be a relative path.
15524 // RETURNS: a newly-allocated string that must be freed with g_free().
15525 // <first_element>: the first element in the path
15526 alias g_build_filename build_filename; // Variadic
15529 // Behaves exactly like g_build_filename(), but takes the path elements
15530 // as a string array, instead of varargs. This function is mainly
15531 // meant for language bindings.
15532 // RETURNS: a newly-allocated string that must be freed with g_free().
15533 // <args>: %NULL-terminated array of strings containing the path elements.
15534 static char* /*new*/ build_filenamev(char** args) {
15535 return g_build_filenamev(args);
15539 // Unintrospectable function: build_path() / g_build_path()
15540 // Creates a path from a series of elements using @separator as the
15541 // separator between elements. At the boundary between two elements,
15542 // any trailing occurrences of separator in the first element, or
15543 // leading occurrences of separator in the second element are removed
15544 // and exactly one copy of the separator is inserted.
15546 // Empty elements are ignored.
15548 // The number of leading copies of the separator on the result is
15549 // the same as the number of leading copies of the separator on
15550 // the first non-empty element.
15552 // The number of trailing copies of the separator on the result is
15553 // the same as the number of trailing copies of the separator on
15554 // the last non-empty element. (Determination of the number of
15555 // trailing copies is done without stripping leading copies, so
15556 // if the separator is <literal>ABA</literal>, <literal>ABABA</literal>
15557 // has 1 trailing copy.)
15559 // However, if there is only a single non-empty element, and there
15560 // are no characters in that element not part of the leading or
15561 // trailing separators, then the result is exactly the original value
15562 // of that element.
15564 // Other than for determination of the number of leading and trailing
15565 // copies of the separator, elements consisting only of copies
15566 // of the separator are ignored.
15567 // RETURNS: a newly-allocated string that must be freed with g_free().
15568 // <separator>: a string used to separator the elements of the path.
15569 // <first_element>: the first element in the path
15570 alias g_build_path build_path; // Variadic
15573 // Behaves exactly like g_build_path(), but takes the path elements
15574 // as a string array, instead of varargs. This function is mainly
15575 // meant for language bindings.
15576 // RETURNS: a newly-allocated string that must be freed with g_free().
15577 // <separator>: a string used to separator the elements of the path.
15578 // <args>: %NULL-terminated array of strings containing the path elements.
15579 static char* /*new*/ build_pathv(char* separator, char** args) {
15580 return g_build_pathv(separator, args);
15584 // Frees the memory allocated by the #GByteArray. If @free_segment is
15585 // %TRUE it frees the actual byte data. If the reference count of
15586 // @array is greater than one, the #GByteArray wrapper is preserved but
15587 // the size of @array will be set to zero.
15588 // <array>: a #GByteArray.
15589 // <free_segment>: if %TRUE the actual byte data is freed as well.
15590 static ubyte* byte_array_free(ByteArray* array, int free_segment) {
15591 return g_byte_array_free(array, free_segment);
15595 // Atomically decrements the reference count of @array by one. If the
15596 // reference count drops to 0, all memory allocated by the array is
15597 // released. This function is MT-safe and may be called from any
15598 // thread.
15599 // <array>: A #GByteArray.
15600 static void byte_array_unref(ByteArray* array) {
15601 g_byte_array_unref(array);
15605 // A wrapper for the POSIX chdir() function. The function changes the
15606 // current directory of the process to @path.
15608 // See your C library manual for more details about chdir().
15609 // RETURNS: 0 on success, -1 if an error occurred.
15610 // <path>: a pathname in the GLib file name encoding (UTF-8 on Windows)
15611 static int chdir(char* path) {
15612 return g_chdir(path);
15616 // Checks that the GLib library in use is compatible with the
15617 // given version. Generally you would pass in the constants
15618 // #GLIB_MAJOR_VERSION, #GLIB_MINOR_VERSION, #GLIB_MICRO_VERSION
15619 // as the three arguments to this function; that produces
15620 // a check that the library in use is compatible with
15621 // the version of GLib the application or module was compiled
15622 // against.
15624 // Compatibility is defined by two things: first the version
15625 // of the running library is newer than the version
15626 // @required_major.required_minor.@required_micro. Second
15627 // the running library must be binary compatible with the
15628 // version @required_major.required_minor.@required_micro
15629 // (same major version.)
15631 // given version, or a string describing the version mismatch.
15632 // The returned string is owned by GLib and must not be modified
15633 // or freed.
15634 // RETURNS: %NULL if the GLib library is compatible with the
15635 // <required_major>: the required major version.
15636 // <required_minor>: the required minor version.
15637 // <required_micro>: the required micro version.
15638 static char* check_version(uint required_major, uint required_minor, uint required_micro) {
15639 return glib_check_version(required_major, required_minor, required_micro);
15643 // Gets the length in bytes of digests of type @checksum_type
15645 // not supported.
15646 // RETURNS: the checksum length, or -1 if @checksum_type is
15647 // <checksum_type>: a #GChecksumType
15648 static ssize_t checksum_type_get_length(ChecksumType checksum_type) {
15649 return g_checksum_type_get_length(checksum_type);
15653 // Unintrospectable function: child_watch_add() / g_child_watch_add()
15654 // Sets a function to be called when the child indicated by @pid
15655 // exits, at a default priority, #G_PRIORITY_DEFAULT.
15657 // If you obtain @pid from g_spawn_async() or g_spawn_async_with_pipes()
15658 // you will need to pass #G_SPAWN_DO_NOT_REAP_CHILD as flag to
15659 // the spawn function for the child watching to work.
15661 // Note that on platforms where #GPid must be explicitly closed
15662 // (see g_spawn_close_pid()) @pid must not be closed while the
15663 // source is still active. Typically, you will want to call
15664 // g_spawn_close_pid() in the callback function for the source.
15666 // GLib supports only a single callback per process id.
15668 // This internally creates a main loop source using
15669 // g_child_watch_source_new() and attaches it to the main loop context
15670 // using g_source_attach(). You can do these steps manually if you
15671 // need greater control.
15672 // RETURNS: the ID (greater than 0) of the event source.
15673 // <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).
15674 // <function>: function to call
15675 // <data>: data to pass to @function
15676 static uint child_watch_add(Pid pid, ChildWatchFunc function_, void* data) {
15677 return g_child_watch_add(pid, function_, data);
15681 // Sets a function to be called when the child indicated by @pid
15682 // exits, at the priority @priority.
15684 // If you obtain @pid from g_spawn_async() or g_spawn_async_with_pipes()
15685 // you will need to pass #G_SPAWN_DO_NOT_REAP_CHILD as flag to
15686 // the spawn function for the child watching to work.
15688 // Note that on platforms where #GPid must be explicitly closed
15689 // (see g_spawn_close_pid()) @pid must not be closed while the
15690 // source is still active. Typically, you will want to call
15691 // g_spawn_close_pid() in the callback function for the source.
15693 // GLib supports only a single callback per process id.
15695 // This internally creates a main loop source using
15696 // g_child_watch_source_new() and attaches it to the main loop context
15697 // using g_source_attach(). You can do these steps manually if you
15698 // need greater control.
15699 // RETURNS: the ID (greater than 0) of the event source.
15700 // <priority>: the priority of the idle source. Typically this will be in the range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.
15701 // <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).
15702 // <function>: function to call
15703 // <data>: data to pass to @function
15704 // <notify>: function to call when the idle is removed, or %NULL
15705 static uint child_watch_add_full(int priority, Pid pid, ChildWatchFunc function_, void* data, DestroyNotify notify) {
15706 return g_child_watch_add_full(priority, pid, function_, data, notify);
15710 // Creates a new child_watch source.
15712 // The source will not initially be associated with any #GMainContext
15713 // and must be added to one with g_source_attach() before it will be
15714 // executed.
15716 // Note that child watch sources can only be used in conjunction with
15717 // <literal>g_spawn...</literal> when the %G_SPAWN_DO_NOT_REAP_CHILD
15718 // flag is used.
15720 // Note that on platforms where #GPid must be explicitly closed
15721 // (see g_spawn_close_pid()) @pid must not be closed while the
15722 // source is still active. Typically, you will want to call
15723 // g_spawn_close_pid() in the callback function for the source.
15725 // Note further that using g_child_watch_source_new() is not
15726 // compatible with calling <literal>waitpid(-1)</literal> in
15727 // the application. Calling waitpid() for individual pids will
15728 // still work fine.
15729 // RETURNS: the newly-created child watch source
15730 // <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).
15731 static Source* /*new*/ child_watch_source_new(Pid pid) {
15732 return g_child_watch_source_new(pid);
15736 // If @err is %NULL, does nothing. If @err is non-%NULL,
15737 // calls g_error_free() on *@err and sets *@err to %NULL.
15738 static void clear_error(GLib2.Error** error=null) {
15739 g_clear_error(error);
15743 // Computes the checksum for a binary @data of @length. This is a
15744 // convenience wrapper for g_checksum_new(), g_checksum_get_string()
15745 // and g_checksum_free().
15747 // The hexadecimal string returned will be in lower case.
15749 // The returned string should be freed with g_free() when done using it.
15750 // RETURNS: the digest of the binary data as a string in hexadecimal.
15751 // <checksum_type>: a #GChecksumType
15752 // <data>: binary blob to compute the digest of
15753 // <length>: length of @data
15754 static char* /*new*/ compute_checksum_for_data(ChecksumType checksum_type, ubyte* data, size_t length) {
15755 return g_compute_checksum_for_data(checksum_type, data, length);
15759 // Computes the checksum of a string.
15761 // The hexadecimal string returned will be in lower case.
15763 // should be freed with g_free() when done using it.
15764 // RETURNS: the checksum as a hexadecimal string. The returned string
15765 // <checksum_type>: a #GChecksumType
15766 // <str>: the string to compute the checksum of
15767 // <length>: the length of the string, or -1 if the string is null-terminated.
15768 static char* /*new*/ compute_checksum_for_string(ChecksumType checksum_type, char* str, ssize_t length) {
15769 return g_compute_checksum_for_string(checksum_type, str, length);
15773 // Computes the HMAC for a binary @data of @length. This is a
15774 // convenience wrapper for g_hmac_new(), g_hmac_get_string()
15775 // and g_hmac_unref().
15777 // The hexadecimal string returned will be in lower case.
15779 // The returned string should be freed with g_free() when done using it.
15780 // RETURNS: the HMAC of the binary data as a string in hexadecimal.
15781 // <digest_type>: a #GChecksumType to use for the HMAC
15782 // <key>: the key to use in the HMAC
15783 // <key_len>: the length of the key
15784 // <data>: binary blob to compute the HMAC of
15785 // <length>: length of @data
15786 static char* /*new*/ compute_hmac_for_data(ChecksumType digest_type, ubyte* key, size_t key_len, ubyte* data, size_t length) {
15787 return g_compute_hmac_for_data(digest_type, key, key_len, data, length);
15791 // Computes the HMAC for a string.
15793 // The hexadecimal string returned will be in lower case.
15795 // The returned string should be freed with g_free()
15796 // when done using it.
15797 // RETURNS: the HMAC as a hexadecimal string.
15798 // <digest_type>: a #GChecksumType to use for the HMAC
15799 // <key>: the key to use in the HMAC
15800 // <key_len>: the length of the key
15801 // <str>: the string to compute the HMAC for
15802 // <length>: the length of the string, or -1 if the string is nul-terminated
15803 static char* /*new*/ compute_hmac_for_string(ChecksumType digest_type, ubyte* key, size_t key_len, char* str, ssize_t length) {
15804 return g_compute_hmac_for_string(digest_type, key, key_len, str, length);
15808 // Converts a string from one character set to another.
15810 // Note that you should use g_iconv() for streaming
15811 // conversions<footnoteref linkend="streaming-state"/>.
15813 // nul-terminated string, which must be freed with
15814 // g_free(). Otherwise %NULL and @error will be set.
15815 // RETURNS: If the conversion was successful, a newly allocated
15816 // <str>: the string to convert
15817 // <len>: the length of the string, or -1 if the string is nul-terminated<footnote id="nul-unsafe">
15818 // <to_codeset>: name of character set into which to convert @str
15819 // <from_codeset>: character set of @str.
15820 // <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.
15821 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
15822 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) {
15823 return g_convert(str, len, to_codeset, from_codeset, bytes_read, bytes_written, error);
15826 static Quark convert_error_quark() {
15827 return g_convert_error_quark();
15831 // Converts a string from one character set to another, possibly
15832 // including fallback sequences for characters not representable
15833 // in the output. Note that it is not guaranteed that the specification
15834 // for the fallback sequences in @fallback will be honored. Some
15835 // systems may do an approximate conversion from @from_codeset
15836 // to @to_codeset in their iconv() functions,
15837 // in which case GLib will simply return that approximate conversion.
15839 // Note that you should use g_iconv() for streaming
15840 // conversions<footnoteref linkend="streaming-state"/>.
15842 // nul-terminated string, which must be freed with
15843 // g_free(). Otherwise %NULL and @error will be set.
15844 // RETURNS: If the conversion was successful, a newly allocated
15845 // <str>: the string to convert
15846 // <len>: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
15847 // <to_codeset>: name of character set into which to convert @str
15848 // <from_codeset>: character set of @str.
15849 // <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).
15850 // <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.
15851 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
15852 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) {
15853 return g_convert_with_fallback(str, len, to_codeset, from_codeset, fallback, bytes_read, bytes_written, error);
15857 // Converts a string from one character set to another.
15859 // Note that you should use g_iconv() for streaming
15860 // conversions<footnote id="streaming-state">
15861 // <para>
15862 // Despite the fact that @byes_read can return information about partial
15863 // characters, the <literal>g_convert_...</literal> functions
15864 // are not generally suitable for streaming. If the underlying converter
15865 // being used maintains internal state, then this won't be preserved
15866 // across successive calls to g_convert(), g_convert_with_iconv() or
15867 // g_convert_with_fallback(). (An example of this is the GNU C converter
15868 // for CP1255 which does not emit a base character until it knows that
15869 // the next character is not a mark that could combine with the base
15870 // character.)
15871 // </para>
15872 // </footnote>.
15874 // nul-terminated string, which must be freed with
15875 // g_free(). Otherwise %NULL and @error will be set.
15876 // RETURNS: If the conversion was successful, a newly allocated
15877 // <str>: the string to convert
15878 // <len>: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
15879 // <converter>: conversion descriptor from g_iconv_open()
15880 // <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.
15881 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
15882 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) {
15883 return g_convert_with_iconv(str, len, converter, bytes_read, bytes_written, error);
15887 // Frees all the data elements of the datalist.
15888 // The data elements' destroy functions are called
15889 // if they have been set.
15890 // <datalist>: a datalist.
15891 static void datalist_clear(Data** datalist) {
15892 g_datalist_clear(datalist);
15896 // Unintrospectable function: datalist_foreach() / g_datalist_foreach()
15897 // Calls the given function for each data element of the datalist. The
15898 // function is called with each data element's #GQuark id and data,
15899 // together with the given @user_data parameter. Note that this
15900 // function is NOT thread-safe. So unless @datalist can be protected
15901 // from any modifications during invocation of this function, it should
15902 // not be called.
15903 // <datalist>: a datalist.
15904 // <func>: the function to call for each data element.
15905 // <user_data>: user data to pass to the function.
15906 static void datalist_foreach(Data** datalist, DataForeachFunc func, void* user_data) {
15907 g_datalist_foreach(datalist, func, user_data);
15911 // Unintrospectable function: datalist_get_data() / g_datalist_get_data()
15912 // Gets a data element, using its string identifer. This is slower than
15913 // g_datalist_id_get_data() because it compares strings.
15914 // <datalist>: a datalist.
15915 // <key>: the string identifying a data element.
15916 static void* datalist_get_data(Data** datalist, char* key) {
15917 return g_datalist_get_data(datalist, key);
15921 // Gets flags values packed in together with the datalist.
15922 // See g_datalist_set_flags().
15923 // RETURNS: the flags of the datalist
15924 // <datalist>: pointer to the location that holds a list
15925 static uint datalist_get_flags(Data** datalist) {
15926 return g_datalist_get_flags(datalist);
15930 // Unintrospectable function: datalist_id_get_data() / g_datalist_id_get_data()
15931 // Retrieves the data element corresponding to @key_id.
15932 // <datalist>: a datalist.
15933 // <key_id>: the #GQuark identifying a data element.
15934 static void* datalist_id_get_data(Data** datalist, Quark key_id) {
15935 return g_datalist_id_get_data(datalist, key_id);
15939 // Unintrospectable function: datalist_id_remove_no_notify() / g_datalist_id_remove_no_notify()
15940 // Removes an element, without calling its destroy notification
15941 // function.
15942 // <datalist>: a datalist.
15943 // <key_id>: the #GQuark identifying a data element.
15944 static void* datalist_id_remove_no_notify(Data** datalist, Quark key_id) {
15945 return g_datalist_id_remove_no_notify(datalist, key_id);
15949 // Sets the data corresponding to the given #GQuark id, and the
15950 // function to be called when the element is removed from the datalist.
15951 // Any previous data with the same key is removed, and its destroy
15952 // function is called.
15953 // <datalist>: a datalist.
15954 // <key_id>: the #GQuark to identify the data element.
15955 // <data>: the data element or %NULL to remove any previous element corresponding to @key_id.
15956 // <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.
15957 static void datalist_id_set_data_full(Data** datalist, Quark key_id, void* data, DestroyNotify destroy_func) {
15958 g_datalist_id_set_data_full(datalist, key_id, data, destroy_func);
15962 // Resets the datalist to %NULL. It does not free any memory or call
15963 // any destroy functions.
15964 // <datalist>: a pointer to a pointer to a datalist.
15965 static void datalist_init(Data** datalist) {
15966 g_datalist_init(datalist);
15970 // Turns on flag values for a data list. This function is used
15971 // to keep a small number of boolean flags in an object with
15972 // a data list without using any additional space. It is
15973 // not generally useful except in circumstances where space
15974 // is very tight. (It is used in the base #GObject type, for
15975 // example.)
15976 // <datalist>: pointer to the location that holds a list
15977 // <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.
15978 static void datalist_set_flags(Data** datalist, uint flags) {
15979 g_datalist_set_flags(datalist, flags);
15983 // Turns off flag values for a data list. See g_datalist_unset_flags()
15984 // <datalist>: pointer to the location that holds a list
15985 // <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.
15986 static void datalist_unset_flags(Data** datalist, uint flags) {
15987 g_datalist_unset_flags(datalist, flags);
15991 // Destroys the dataset, freeing all memory allocated, and calling any
15992 // destroy functions set for data elements.
15993 // <dataset_location>: the location identifying the dataset.
15994 static void dataset_destroy(const(void)* dataset_location) {
15995 g_dataset_destroy(dataset_location);
15999 // Unintrospectable function: dataset_foreach() / g_dataset_foreach()
16000 // Calls the given function for each data element which is associated
16001 // with the given location. Note that this function is NOT thread-safe.
16002 // So unless @datalist can be protected from any modifications during
16003 // invocation of this function, it should not be called.
16004 // <dataset_location>: the location identifying the dataset.
16005 // <func>: the function to call for each data element.
16006 // <user_data>: user data to pass to the function.
16007 static void dataset_foreach(const(void)* dataset_location, DataForeachFunc func, void* user_data) {
16008 g_dataset_foreach(dataset_location, func, user_data);
16012 // Unintrospectable function: dataset_id_get_data() / g_dataset_id_get_data()
16013 // Gets the data element corresponding to a #GQuark.
16014 // <dataset_location>: the location identifying the dataset.
16015 // <key_id>: the #GQuark id to identify the data element.
16016 static void* dataset_id_get_data(const(void)* dataset_location, Quark key_id) {
16017 return g_dataset_id_get_data(dataset_location, key_id);
16021 // Unintrospectable function: dataset_id_remove_no_notify() / g_dataset_id_remove_no_notify()
16022 // Removes an element, without calling its destroy notification
16023 // function.
16024 // <dataset_location>: the location identifying the dataset.
16025 // <key_id>: the #GQuark ID identifying the data element.
16026 static void* dataset_id_remove_no_notify(const(void)* dataset_location, Quark key_id) {
16027 return g_dataset_id_remove_no_notify(dataset_location, key_id);
16031 // Sets the data element associated with the given #GQuark id, and also
16032 // the function to call when the data element is destroyed. Any
16033 // previous data with the same key is removed, and its destroy function
16034 // is called.
16035 // <dataset_location>: the location identifying the dataset.
16036 // <key_id>: the #GQuark id to identify the data element.
16037 // <data>: the data element.
16038 // <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.
16039 static void dataset_id_set_data_full(const(void)* dataset_location, Quark key_id, void* data, DestroyNotify destroy_func) {
16040 g_dataset_id_set_data_full(dataset_location, key_id, data, destroy_func);
16043 static ubyte date_get_days_in_month(DateMonth month, DateYear year) {
16044 return g_date_get_days_in_month(month, year);
16047 static ubyte date_get_monday_weeks_in_year(DateYear year) {
16048 return g_date_get_monday_weeks_in_year(year);
16051 static ubyte date_get_sunday_weeks_in_year(DateYear year) {
16052 return g_date_get_sunday_weeks_in_year(year);
16055 static int date_is_leap_year(DateYear year) {
16056 return g_date_is_leap_year(year);
16059 static size_t date_strftime(char* s, size_t slen, char* format, Date* date) {
16060 return g_date_strftime(s, slen, format, date);
16064 // A comparison function for #GDateTimes that is suitable
16065 // as a #GCompareFunc. Both #GDateTimes must be non-%NULL.
16067 // than @dt2.
16068 // RETURNS: -1, 0 or 1 if @dt1 is less than, equal to or greater
16069 // <dt1>: first #GDateTime to compare
16070 // <dt2>: second #GDateTime to compare
16071 static int date_time_compare(const(void)* dt1, const(void)* dt2) {
16072 return g_date_time_compare(dt1, dt2);
16076 // Checks to see if @dt1 and @dt2 are equal.
16078 // Equal here means that they represent the same moment after converting
16079 // them to the same time zone.
16080 // RETURNS: %TRUE if @dt1 and @dt2 are equal
16081 // <dt1>: a #GDateTime
16082 // <dt2>: a #GDateTime
16083 static int date_time_equal(const(void)* dt1, const(void)* dt2) {
16084 return g_date_time_equal(dt1, dt2);
16088 // Hashes @datetime into a #guint, suitable for use within #GHashTable.
16089 // RETURNS: a #guint containing the hash
16090 // <datetime>: a #GDateTime
16091 static uint date_time_hash(const(void)* datetime) {
16092 return g_date_time_hash(datetime);
16095 static int date_valid_day(DateDay day) {
16096 return g_date_valid_day(day);
16099 static int date_valid_dmy(DateDay day, DateMonth month, DateYear year) {
16100 return g_date_valid_dmy(day, month, year);
16103 static int date_valid_julian(uint julian_date) {
16104 return g_date_valid_julian(julian_date);
16107 static int date_valid_month(DateMonth month) {
16108 return g_date_valid_month(month);
16111 static int date_valid_weekday(DateWeekday weekday) {
16112 return g_date_valid_weekday(weekday);
16115 static int date_valid_year(DateYear year) {
16116 return g_date_valid_year(year);
16120 // This is a variant of g_dgettext() that allows specifying a locale
16121 // category instead of always using %LC_MESSAGES. See g_dgettext() for
16122 // more information about how this functions differs from calling
16123 // dcgettext() directly.
16124 // RETURNS: the translated string for the given locale category
16125 // <domain>: the translation domain to use, or %NULL to use the domain set with textdomain()
16126 // <msgid>: message to translate
16127 // <category>: a locale category
16128 static char* dcgettext(char* domain, char* msgid, int category) {
16129 return g_dcgettext(domain, msgid, category);
16133 // This function is a wrapper of dgettext() which does not translate
16134 // the message if the default domain as set with textdomain() has no
16135 // translations for the current locale.
16137 // The advantage of using this function over dgettext() proper is that
16138 // libraries using this function (like GTK+) will not use translations
16139 // if the application using the library does not have translations for
16140 // the current locale. This results in a consistent English-only
16141 // interface instead of one having partial translations. For this
16142 // feature to work, the call to textdomain() and setlocale() should
16143 // precede any g_dgettext() invocations. For GTK+, it means calling
16144 // textdomain() before gtk_init or its variants.
16146 // This function disables translations if and only if upon its first
16147 // call all the following conditions hold:
16148 // <itemizedlist>
16149 // <listitem>@domain is not %NULL</listitem>
16150 // <listitem>textdomain() has been called to set a default text domain</listitem>
16151 // <listitem>there is no translations available for the default text domain
16152 // and the current locale</listitem>
16153 // <listitem>current locale is not "C" or any English locales (those
16154 // starting with "en_")</listitem>
16155 // </itemizedlist>
16157 // Note that this behavior may not be desired for example if an application
16158 // has its untranslated messages in a language other than English. In those
16159 // cases the application should call textdomain() after initializing GTK+.
16161 // Applications should normally not use this function directly,
16162 // but use the _() macro for translations.
16163 // RETURNS: The translated string
16164 // <domain>: the translation domain to use, or %NULL to use the domain set with textdomain()
16165 // <msgid>: message to translate
16166 static char* dgettext(char* domain, char* msgid) {
16167 return g_dgettext(domain, msgid);
16171 // Creates a subdirectory in the preferred directory for temporary
16172 // files (as returned by g_get_tmp_dir()).
16174 // @tmpl should be a string in the GLib file name encoding containing
16175 // a sequence of six 'X' characters, as the parameter to g_mkstemp().
16176 // However, unlike these functions, the template should only be a
16177 // basename, no directory components are allowed. If template is
16178 // %NULL, a default template is used.
16180 // Note that in contrast to g_mkdtemp() (and mkdtemp()) @tmpl is not
16181 // modified, and might thus be a read-only literal string.
16183 // should be freed with g_free() when not needed any longer and is
16184 // is in the GLib file name encoding. In case of errors, %NULL is
16185 // returned and @error will be set.
16186 // RETURNS: The actual name used. This string
16187 // <tmpl>: Template for directory name, as in g_mkdtemp(), basename only, or %NULL for a default template
16188 static char* /*new*/ dir_make_tmp(char* tmpl, GLib2.Error** error=null) {
16189 return g_dir_make_tmp(tmpl, error);
16193 // Compares two #gpointer arguments and returns %TRUE if they are equal.
16194 // It can be passed to g_hash_table_new() as the @key_equal_func
16195 // parameter, when using pointers as keys in a #GHashTable.
16196 // RETURNS: %TRUE if the two keys match.
16197 // <v1>: a key.
16198 // <v2>: a key to compare with @v1.
16199 static int direct_equal(const(void)* v1, const(void)* v2) {
16200 return g_direct_equal(v1, v2);
16204 // Converts a gpointer to a hash value.
16205 // It can be passed to g_hash_table_new() as the @hash_func parameter,
16206 // when using pointers as keys in a #GHashTable.
16207 // RETURNS: a hash value corresponding to the key.
16208 // <v>: a #gpointer key
16209 static uint direct_hash(const(void)* v) {
16210 return g_direct_hash(v);
16214 // This function is a wrapper of dngettext() which does not translate
16215 // the message if the default domain as set with textdomain() has no
16216 // translations for the current locale.
16218 // See g_dgettext() for details of how this differs from dngettext()
16219 // proper.
16220 // RETURNS: The translated string
16221 // <domain>: the translation domain to use, or %NULL to use the domain set with textdomain()
16222 // <msgid>: message to translate
16223 // <msgid_plural>: plural form of the message
16224 // <n>: the quantity for which translation is needed
16225 static char* dngettext(char* domain, char* msgid, char* msgid_plural, c_ulong n) {
16226 return g_dngettext(domain, msgid, msgid_plural, n);
16230 // Compares the two #gdouble values being pointed to and returns
16231 // %TRUE if they are equal.
16232 // It can be passed to g_hash_table_new() as the @key_equal_func
16233 // parameter, when using pointers to doubles as keys in a #GHashTable.
16234 // RETURNS: %TRUE if the two keys match.
16235 // <v1>: a pointer to a #gdouble key.
16236 // <v2>: a pointer to a #gdouble key to compare with @v1.
16237 static int double_equal(const(void)* v1, const(void)* v2) {
16238 return g_double_equal(v1, v2);
16242 // Converts a pointer to a #gdouble to a hash value.
16243 // It can be passed to g_hash_table_new() as the @hash_func parameter,
16244 // when using pointers to doubles as keys in a #GHashTable.
16245 // RETURNS: a hash value corresponding to the key.
16246 // <v>: a pointer to a #gdouble key
16247 static uint double_hash(const(void)* v) {
16248 return g_double_hash(v);
16252 // This function is a variant of g_dgettext() which supports
16253 // a disambiguating message context. GNU gettext uses the
16254 // '\004' character to separate the message context and
16255 // message id in @msgctxtid.
16256 // If 0 is passed as @msgidoffset, this function will fall back to
16257 // trying to use the deprecated convention of using "|" as a separation
16258 // character.
16260 // This uses g_dgettext() internally. See that functions for differences
16261 // with dgettext() proper.
16263 // Applications should normally not use this function directly,
16264 // but use the C_() macro for translations with context.
16265 // RETURNS: The translated string
16266 // <domain>: the translation domain to use, or %NULL to use the domain set with textdomain()
16267 // <msgctxtid>: a combined message context and message id, separated by a \004 character
16268 // <msgidoffset>: the offset of the message id in @msgctxid
16269 static char* dpgettext(char* domain, char* msgctxtid, size_t msgidoffset) {
16270 return g_dpgettext(domain, msgctxtid, msgidoffset);
16274 // This function is a variant of g_dgettext() which supports
16275 // a disambiguating message context. GNU gettext uses the
16276 // '\004' character to separate the message context and
16277 // message id in @msgctxtid.
16279 // This uses g_dgettext() internally. See that functions for differences
16280 // with dgettext() proper.
16282 // This function differs from C_() in that it is not a macro and
16283 // thus you may use non-string-literals as context and msgid arguments.
16284 // RETURNS: The translated string
16285 // <domain>: the translation domain to use, or %NULL to use the domain set with textdomain()
16286 // <context>: the message context
16287 // <msgid>: the message
16288 static char* dpgettext2(char* domain, char* context, char* msgid) {
16289 return g_dpgettext2(domain, context, msgid);
16294 // Gets a #GFileError constant based on the passed-in @errno.
16295 // For example, if you pass in %EEXIST this function returns
16296 // #G_FILE_ERROR_EXIST. Unlike @errno values, you can portably
16297 // assume that all #GFileError values will exist.
16299 // Normally a #GFileError value goes into a #GError returned
16300 // from a function that manipulates files. So you would use
16301 // g_file_error_from_errno() when constructing a #GError.
16302 // RETURNS: #GFileError corresponding to the given @errno
16303 // <err_no>: an "errno" value
16304 static FileError file_error_from_errno(int err_no) {
16305 return g_file_error_from_errno(err_no);
16308 static Quark file_error_quark() {
16309 return g_file_error_quark();
16313 // Reads an entire file into allocated memory, with good error
16314 // checking.
16316 // If the call was successful, it returns %TRUE and sets @contents to the file
16317 // contents and @length to the length of the file contents in bytes. The string
16318 // stored in @contents will be nul-terminated, so for text files you can pass
16319 // %NULL for the @length argument. If the call was not successful, it returns
16320 // %FALSE and sets @error. The error domain is #G_FILE_ERROR. Possible error
16321 // codes are those in the #GFileError enumeration. In the error case,
16322 // @contents is set to %NULL and @length is set to zero.
16323 // RETURNS: %TRUE on success, %FALSE if an error occurred
16324 // <filename>: name of a file to read contents from, in the GLib file name encoding
16325 // <contents>: location to store an allocated string, use g_free() to free the returned string
16326 // <length>: location to store length in bytes of the contents, or %NULL
16327 static int file_get_contents(char* filename, /*out*/ ubyte** contents, /*out*/ size_t* length, GLib2.Error** error=null) {
16328 return g_file_get_contents(filename, contents, length, error);
16332 // Opens a file for writing in the preferred directory for temporary
16333 // files (as returned by g_get_tmp_dir()).
16335 // @tmpl should be a string in the GLib file name encoding containing
16336 // a sequence of six 'X' characters, as the parameter to g_mkstemp().
16337 // However, unlike these functions, the template should only be a
16338 // basename, no directory components are allowed. If template is
16339 // %NULL, a default template is used.
16341 // Note that in contrast to g_mkstemp() (and mkstemp()) @tmpl is not
16342 // modified, and might thus be a read-only literal string.
16344 // Upon success, and if @name_used is non-%NULL, the actual name used
16345 // is returned in @name_used. This string should be freed with g_free()
16346 // when not needed any longer. The returned name is in the GLib file
16347 // name encoding.
16349 // reading and writing. The file is opened in binary mode on platforms
16350 // where there is a difference. The file handle should be closed with
16351 // close(). In case of errors, -1 is returned and @error will be set.
16352 // RETURNS: A file handle (as from open()) to the file opened for
16353 // <tmpl>: Template for file name, as in g_mkstemp(), basename only, or %NULL for a default template
16354 // <name_used>: location to store actual name used, or %NULL
16355 static int file_open_tmp(char* tmpl, /*out*/ char** name_used, GLib2.Error** error=null) {
16356 return g_file_open_tmp(tmpl, name_used, error);
16360 // Reads the contents of the symbolic link @filename like the POSIX
16361 // readlink() function. The returned string is in the encoding used
16362 // for filenames. Use g_filename_to_utf8() to convert it to UTF-8.
16364 // or %NULL if an error occurred.
16365 // RETURNS: A newly-allocated string with the contents of the symbolic link,
16366 // <filename>: the symbolic link
16367 static char* /*new*/ file_read_link(char* filename, GLib2.Error** error=null) {
16368 return g_file_read_link(filename, error);
16372 // Writes all of @contents to a file named @filename, with good error checking.
16373 // If a file called @filename already exists it will be overwritten.
16375 // This write is atomic in the sense that it is first written to a temporary
16376 // file which is then renamed to the final name. Notes:
16377 // <itemizedlist>
16378 // <listitem>
16379 // On Unix, if @filename already exists hard links to @filename will break.
16380 // Also since the file is recreated, existing permissions, access control
16381 // lists, metadata etc. may be lost. If @filename is a symbolic link,
16382 // the link itself will be replaced, not the linked file.
16383 // </listitem>
16384 // <listitem>
16385 // On Windows renaming a file will not remove an existing file with the
16386 // new name, so on Windows there is a race condition between the existing
16387 // file being removed and the temporary file being renamed.
16388 // </listitem>
16389 // <listitem>
16390 // On Windows there is no way to remove a file that is open to some
16391 // process, or mapped into memory. Thus, this function will fail if
16392 // @filename already exists and is open.
16393 // </listitem>
16394 // </itemizedlist>
16396 // If the call was successful, it returns %TRUE. If the call was not successful,
16397 // it returns %FALSE and sets @error. The error domain is #G_FILE_ERROR.
16398 // Possible error codes are those in the #GFileError enumeration.
16400 // Note that the name for the temporary file is constructed by appending up
16401 // to 7 characters to @filename.
16402 // RETURNS: %TRUE on success, %FALSE if an error occurred
16403 // <filename>: name of a file to write @contents to, in the GLib file name encoding
16404 // <contents>: string to write to the file
16405 // <length>: length of @contents, or -1 if @contents is a nul-terminated string
16406 static int file_set_contents(char* filename, ubyte* contents, ssize_t length, GLib2.Error** error=null) {
16407 return g_file_set_contents(filename, contents, length, error);
16411 // Returns %TRUE if any of the tests in the bitfield @test are
16412 // %TRUE. For example, <literal>(G_FILE_TEST_EXISTS |
16413 // G_FILE_TEST_IS_DIR)</literal> will return %TRUE if the file exists;
16414 // the check whether it's a directory doesn't matter since the existence
16415 // test is %TRUE. With the current set of available tests, there's no point
16416 // passing in more than one test at a time.
16418 // Apart from %G_FILE_TEST_IS_SYMLINK all tests follow symbolic links,
16419 // so for a symbolic link to a regular file g_file_test() will return
16420 // %TRUE for both %G_FILE_TEST_IS_SYMLINK and %G_FILE_TEST_IS_REGULAR.
16422 // Note, that for a dangling symbolic link g_file_test() will return
16423 // %TRUE for %G_FILE_TEST_IS_SYMLINK and %FALSE for all other flags.
16425 // You should never use g_file_test() to test whether it is safe
16426 // to perform an operation, because there is always the possibility
16427 // of the condition changing before you actually perform the operation.
16428 // For example, you might think you could use %G_FILE_TEST_IS_SYMLINK
16429 // to know whether it is safe to write to a file without being
16430 // tricked into writing into a different location. It doesn't work!
16431 // |[
16432 // /&ast; DON'T DO THIS &ast;/
16433 // if (!g_file_test (filename, G_FILE_TEST_IS_SYMLINK))
16434 // {
16435 // fd = g_open (filename, O_WRONLY);
16436 // /&ast; write to fd &ast;/
16437 // }
16438 // ]|
16440 // Another thing to note is that %G_FILE_TEST_EXISTS and
16441 // %G_FILE_TEST_IS_EXECUTABLE are implemented using the access()
16442 // system call. This usually doesn't matter, but if your program
16443 // is setuid or setgid it means that these tests will give you
16444 // the answer for the real user ID and group ID, rather than the
16445 // effective user ID and group ID.
16447 // On Windows, there are no symlinks, so testing for
16448 // %G_FILE_TEST_IS_SYMLINK will always return %FALSE. Testing for
16449 // %G_FILE_TEST_IS_EXECUTABLE will just check that the file exists and
16450 // its name indicates that it is executable, checking for well-known
16451 // extensions and those listed in the %PATHEXT environment variable.
16452 // RETURNS: whether a test was %TRUE
16453 // <filename>: a filename to test in the GLib file name encoding
16454 // <test>: bitfield of #GFileTest flags
16455 static int file_test(char* filename, FileTest test) {
16456 return g_file_test(filename, test);
16460 // Returns the display basename for the particular filename, guaranteed
16461 // to be valid UTF-8. The display name might not be identical to the filename,
16462 // for instance there might be problems converting it to UTF-8, and some files
16463 // can be translated in the display.
16465 // If GLib cannot make sense of the encoding of @filename, as a last resort it
16466 // replaces unknown characters with U+FFFD, the Unicode replacement character.
16467 // You can search the result for the UTF-8 encoding of this character (which is
16468 // "\357\277\275" in octal notation) to find out if @filename was in an invalid
16469 // encoding.
16471 // You must pass the whole absolute pathname to this functions so that
16472 // translation of well known locations can be done.
16474 // This function is preferred over g_filename_display_name() if you know the
16475 // whole path, as it allows translation.
16477 // a rendition of the basename of the filename in valid UTF-8
16478 // RETURNS: a newly allocated string containing
16479 // <filename>: an absolute pathname in the GLib file name encoding
16480 static char* /*new*/ filename_display_basename(char* filename) {
16481 return g_filename_display_basename(filename);
16485 // Converts a filename into a valid UTF-8 string. The conversion is
16486 // not necessarily reversible, so you should keep the original around
16487 // and use the return value of this function only for display purposes.
16488 // Unlike g_filename_to_utf8(), the result is guaranteed to be non-%NULL
16489 // even if the filename actually isn't in the GLib file name encoding.
16491 // If GLib cannot make sense of the encoding of @filename, as a last resort it
16492 // replaces unknown characters with U+FFFD, the Unicode replacement character.
16493 // You can search the result for the UTF-8 encoding of this character (which is
16494 // "\357\277\275" in octal notation) to find out if @filename was in an invalid
16495 // encoding.
16497 // If you know the whole pathname of the file you should use
16498 // g_filename_display_basename(), since that allows location-based
16499 // translation of filenames.
16501 // a rendition of the filename in valid UTF-8
16502 // RETURNS: a newly allocated string containing
16503 // <filename>: a pathname hopefully in the GLib file name encoding
16504 static char* /*new*/ filename_display_name(char* filename) {
16505 return g_filename_display_name(filename);
16509 // Converts an escaped ASCII-encoded URI to a local filename in the
16510 // encoding used for filenames.
16512 // filename, or %NULL on an error.
16513 // RETURNS: a newly-allocated string holding the resulting
16514 // <uri>: a uri describing a filename (escaped, encoded in ASCII).
16515 // <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.
16516 static char* /*new*/ filename_from_uri(char* uri, char** hostname, GLib2.Error** error=null) {
16517 return g_filename_from_uri(uri, hostname, error);
16521 // Converts a string from UTF-8 to the encoding GLib uses for
16522 // filenames. Note that on Windows GLib uses UTF-8 for filenames;
16523 // on other platforms, this function indirectly depends on the
16524 // <link linkend="setlocale">current locale</link>.
16525 // RETURNS: The converted string, or %NULL on an error.
16526 // <utf8string>: a UTF-8 encoded string.
16527 // <len>: the length of the string, or -1 if the string is nul-terminated.
16528 // <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.
16529 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
16530 static char* /*new*/ filename_from_utf8(char* utf8string, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error=null) {
16531 return g_filename_from_utf8(utf8string, len, bytes_read, bytes_written, error);
16535 // Converts an absolute filename to an escaped ASCII-encoded URI, with the path
16536 // component following Section 3.3. of RFC 2396.
16538 // URI, or %NULL on an error.
16539 // RETURNS: a newly-allocated string holding the resulting
16540 // <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
16541 // <hostname>: A UTF-8 encoded hostname, or %NULL for none.
16542 static char* /*new*/ filename_to_uri(char* filename, char* hostname, GLib2.Error** error=null) {
16543 return g_filename_to_uri(filename, hostname, error);
16547 // Converts a string which is in the encoding used by GLib for
16548 // filenames into a UTF-8 string. Note that on Windows GLib uses UTF-8
16549 // for filenames; on other platforms, this function indirectly depends on
16550 // the <link linkend="setlocale">current locale</link>.
16551 // RETURNS: The converted string, or %NULL on an error.
16552 // <opsysstring>: a string in the encoding for filenames
16553 // <len>: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
16554 // <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.
16555 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
16556 static char* /*new*/ filename_to_utf8(char* opsysstring, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error=null) {
16557 return g_filename_to_utf8(opsysstring, len, bytes_read, bytes_written, error);
16561 // Locates the first executable named @program in the user's path, in the
16562 // same way that execvp() would locate it. Returns an allocated string
16563 // with the absolute path name, or %NULL if the program is not found in
16564 // the path. If @program is already an absolute path, returns a copy of
16565 // @program if @program exists and is executable, and %NULL otherwise.
16567 // On Windows, if @program does not have a file type suffix, tries
16568 // with the suffixes .exe, .cmd, .bat and .com, and the suffixes in
16569 // the <envar>PATHEXT</envar> environment variable.
16571 // On Windows, it looks for the file in the same way as CreateProcess()
16572 // would. This means first in the directory where the executing
16573 // program was loaded from, then in the current directory, then in the
16574 // Windows 32-bit system directory, then in the Windows directory, and
16575 // finally in the directories in the <envar>PATH</envar> environment
16576 // variable. If the program is found, the return value contains the
16577 // full name including the type suffix.
16578 // RETURNS: absolute path, or %NULL
16579 // <program>: a program name in the GLib file name encoding
16580 static char* /*new*/ find_program_in_path(char* program) {
16581 return g_find_program_in_path(program);
16585 // Formats a size (for example the size of a file) into a human readable
16586 // string. Sizes are rounded to the nearest size prefix (kB, MB, GB)
16587 // and are displayed rounded to the nearest tenth. E.g. the file size
16588 // 3292528 bytes will be converted into the string "3.2 MB".
16590 // The prefix units base is 1000 (i.e. 1 kB is 1000 bytes).
16592 // This string should be freed with g_free() when not needed any longer.
16594 // See g_format_size_full() for more options about how the size might be
16595 // formatted.
16597 // file size.
16598 // RETURNS: a newly-allocated formatted string containing a human readable
16599 // <size>: a size in bytes
16600 static char* /*new*/ format_size(ulong size) {
16601 return g_format_size(size);
16605 // Formats a size (for example the size of a file) into a human readable string.
16606 // Sizes are rounded to the nearest size prefix (KB, MB, GB) and are displayed
16607 // rounded to the nearest tenth. E.g. the file size 3292528 bytes will be
16608 // converted into the string "3.1 MB".
16610 // The prefix units base is 1024 (i.e. 1 KB is 1024 bytes).
16612 // This string should be freed with g_free() when not needed any longer.
16614 // file size.
16616 // Deprecated:2.30: This function is broken due to its use of SI
16617 // suffixes to denote IEC units. Use g_format_size()
16618 // instead.
16619 // RETURNS: a newly-allocated formatted string containing a human readable
16620 // <size>: a size in bytes.
16621 static char* /*new*/ format_size_for_display(long size) {
16622 return g_format_size_for_display(size);
16626 // Formats a size.
16628 // This function is similar to g_format_size() but allows for flags that
16629 // modify the output. See #GFormatSizeFlags.
16631 // readable file size.
16632 // RETURNS: a newly-allocated formatted string containing a human
16633 // <size>: a size in bytes
16634 // <flags>: #GFormatSizeFlags to modify the output
16635 static char* /*new*/ format_size_full(ulong size, FormatSizeFlags flags) {
16636 return g_format_size_full(size, flags);
16640 // Unintrospectable function: fprintf() / g_fprintf()
16641 // An implementation of the standard fprintf() function which supports
16642 // positional parameters, as specified in the Single Unix Specification.
16643 // RETURNS: the number of bytes printed.
16644 // <file>: the stream to write to.
16645 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
16646 alias g_fprintf fprintf; // Variadic
16649 // Frees the memory pointed to by @mem.
16650 // If @mem is %NULL it simply returns.
16651 // <mem>: the memory to free
16652 static void free(void* mem) {
16653 g_free(mem);
16657 // Gets a human-readable name for the application, as set by
16658 // g_set_application_name(). This name should be localized if
16659 // possible, and is intended for display to the user. Contrast with
16660 // g_get_prgname(), which gets a non-localized name. If
16661 // g_set_application_name() has not been called, returns the result of
16662 // g_get_prgname() (which may be %NULL if g_set_prgname() has also not
16663 // been called).
16664 // RETURNS: human-readable application name. may return %NULL
16665 static char* get_application_name() {
16666 return g_get_application_name();
16670 // Obtains the character set for the <link linkend="setlocale">current
16671 // locale</link>; you might use this character set as an argument to
16672 // g_convert(), to convert from the current locale's encoding to some
16673 // other encoding. (Frequently g_locale_to_utf8() and g_locale_from_utf8()
16674 // are nice shortcuts, though.)
16676 // On Windows the character set returned by this function is the
16677 // so-called system default ANSI code-page. That is the character set
16678 // used by the "narrow" versions of C library and Win32 functions that
16679 // handle file names. It might be different from the character set
16680 // used by the C library's current locale.
16682 // The return value is %TRUE if the locale's encoding is UTF-8, in that
16683 // case you can perhaps avoid calling g_convert().
16685 // The string returned in @charset is not allocated, and should not be
16686 // freed.
16687 // RETURNS: %TRUE if the returned charset is UTF-8
16688 // <charset>: return location for character set name
16689 static int get_charset(char** charset) {
16690 return g_get_charset(charset);
16694 // Gets the current directory.
16695 // The returned string should be freed when no longer needed. The encoding
16696 // of the returned string is system defined. On Windows, it is always UTF-8.
16697 // RETURNS: the current directory.
16698 static char* /*new*/ get_current_dir() {
16699 return g_get_current_dir();
16703 // Equivalent to the UNIX gettimeofday() function, but portable.
16705 // You may find g_get_real_time() to be more convenient.
16706 // <result>: #GTimeVal structure in which to store current time.
16707 static void get_current_time(TimeVal* result) {
16708 g_get_current_time(result);
16712 // Gets the list of environment variables for the current process. The
16713 // list is %NULL terminated and each item in the list is of the form
16714 // 'NAME=VALUE'.
16716 // This is equivalent to direct access to the 'environ' global variable,
16717 // except portable.
16719 // The return value is freshly allocated and it should be freed with
16720 // g_strfreev() when it is no longer needed.
16721 // RETURNS: the list of environment variables
16722 static char** /*new*/ get_environ() {
16723 return g_get_environ();
16727 // Determines the preferred character sets used for filenames.
16728 // The first character set from the @charsets is the filename encoding, the
16729 // subsequent character sets are used when trying to generate a displayable
16730 // representation of a filename, see g_filename_display_name().
16732 // On Unix, the character sets are determined by consulting the
16733 // environment variables <envar>G_FILENAME_ENCODING</envar> and
16734 // <envar>G_BROKEN_FILENAMES</envar>. On Windows, the character set
16735 // used in the GLib API is always UTF-8 and said environment variables
16736 // have no effect.
16738 // <envar>G_FILENAME_ENCODING</envar> may be set to a comma-separated list
16739 // of character set names. The special token "&commat;locale" is taken to
16740 // mean the character set for the <link linkend="setlocale">current
16741 // locale</link>. If <envar>G_FILENAME_ENCODING</envar> is not set, but
16742 // <envar>G_BROKEN_FILENAMES</envar> is, the character set of the current
16743 // locale is taken as the filename encoding. If neither environment variable
16744 // is set, UTF-8 is taken as the filename encoding, but the character
16745 // set of the current locale is also put in the list of encodings.
16747 // The returned @charsets belong to GLib and must not be freed.
16749 // Note that on Unix, regardless of the locale character set or
16750 // <envar>G_FILENAME_ENCODING</envar> value, the actual file names present
16751 // on a system might be in any random encoding or just gibberish.
16752 // RETURNS: %TRUE if the filename encoding is UTF-8.
16753 // <charsets>: return location for the %NULL-terminated list of encoding names
16754 static int get_filename_charsets(char*** charsets) {
16755 return g_get_filename_charsets(charsets);
16759 // Gets the current user's home directory as defined in the
16760 // password database.
16762 // Note that in contrast to traditional UNIX tools, this function
16763 // prefers <filename>passwd</filename> entries over the <envar>HOME</envar>
16764 // environment variable.
16766 // One of the reasons for this decision is that applications in many
16767 // cases need special handling to deal with the case where
16768 // <envar>HOME</envar> is
16769 // <simplelist>
16770 // <member>Not owned by the user</member>
16771 // <member>Not writeable</member>
16772 // <member>Not even readable</member>
16773 // </simplelist>
16774 // Since applications are in general <emphasis>not</emphasis> written
16775 // to deal with these situations it was considered better to make
16776 // g_get_home_dir() not pay attention to <envar>HOME</envar> and to
16777 // return the real home directory for the user. If applications
16778 // want to pay attention to <envar>HOME</envar>, they can do:
16779 // |[
16780 // const char *homedir = g_getenv ("HOME");
16781 // if (!homedir)
16782 // homedir = g_get_home_dir (<!-- -->);
16783 // ]|
16784 // RETURNS: the current user's home directory
16785 static char* get_home_dir() {
16786 return g_get_home_dir();
16790 // Return a name for the machine.
16792 // The returned name is not necessarily a fully-qualified domain name,
16793 // or even present in DNS or some other name service at all. It need
16794 // not even be unique on your local network or site, but usually it
16795 // is. Callers should not rely on the return value having any specific
16796 // properties like uniqueness for security purposes. Even if the name
16797 // of the machine is changed while an application is running, the
16798 // return value from this function does not change. The returned
16799 // string is owned by GLib and should not be modified or freed. If no
16800 // name can be determined, a default fixed string "localhost" is
16801 // returned.
16802 // RETURNS: the host name of the machine.
16803 static char* get_host_name() {
16804 return g_get_host_name();
16808 // Computes a list of applicable locale names, which can be used to
16809 // e.g. construct locale-dependent filenames or search paths. The returned
16810 // list is sorted from most desirable to least desirable and always contains
16811 // the default locale "C".
16813 // For example, if LANGUAGE=de:en_US, then the returned list is
16814 // "de", "en_US", "en", "C".
16816 // This function consults the environment variables <envar>LANGUAGE</envar>,
16817 // <envar>LC_ALL</envar>, <envar>LC_MESSAGES</envar> and <envar>LANG</envar>
16818 // to find the list of locales specified by the user.
16820 // that must not be modified or freed.
16821 // RETURNS: a %NULL-terminated array of strings owned by GLib
16822 static char** get_language_names() {
16823 return g_get_language_names();
16827 // Returns a list of derived variants of @locale, which can be used to
16828 // e.g. construct locale-dependent filenames or search paths. The returned
16829 // list is sorted from most desirable to least desirable.
16830 // This function handles territory, charset and extra locale modifiers.
16832 // For example, if @locale is "fr_BE", then the returned list
16833 // is "fr_BE", "fr".
16835 // If you need the list of variants for the <emphasis>current locale</emphasis>,
16836 // use g_get_language_names().
16838 // allocated array of newly allocated strings with the locale variants. Free with
16839 // g_strfreev().
16840 // RETURNS: a newly
16841 // <locale>: a locale identifier
16842 static char** /*new*/ get_locale_variants(char* locale) {
16843 return g_get_locale_variants(locale);
16847 // Queries the system monotonic time, if available.
16849 // On POSIX systems with clock_gettime() and %CLOCK_MONOTONIC this call
16850 // is a very shallow wrapper for that. Otherwise, we make a best effort
16851 // that probably involves returning the wall clock time (with at least
16852 // microsecond accuracy, subject to the limitations of the OS kernel).
16854 // It's important to note that POSIX %CLOCK_MONOTONIC does not count
16855 // time spent while the machine is suspended.
16857 // On Windows, "limitations of the OS kernel" is a rather substantial
16858 // statement. Depending on the configuration of the system, the wall
16859 // clock time is updated as infrequently as 64 times a second (which
16860 // is approximately every 16ms).
16861 // RETURNS: the monotonic time, in microseconds
16862 static long get_monotonic_time() {
16863 return g_get_monotonic_time();
16867 // Gets the name of the program. This name should <emphasis>not</emphasis>
16868 // be localized, contrast with g_get_application_name().
16869 // (If you are using GDK or GTK+ the program name is set in gdk_init(),
16870 // which is called by gtk_init(). The program name is found by taking
16871 // the last component of <literal>argv[0]</literal>.)
16873 // to GLib and must not be modified or freed.
16874 // RETURNS: the name of the program. The returned string belongs
16875 static char* /*new*/ get_prgname() {
16876 return g_get_prgname();
16880 // Gets the real name of the user. This usually comes from the user's entry
16881 // in the <filename>passwd</filename> file. The encoding of the returned
16882 // string is system-defined. (On Windows, it is, however, always UTF-8.)
16883 // If the real user name cannot be determined, the string "Unknown" is
16884 // returned.
16885 // RETURNS: the user's real name.
16886 static char* get_real_name() {
16887 return g_get_real_name();
16891 // Queries the system wall-clock time.
16893 // This call is functionally equivalent to g_get_current_time() except
16894 // that the return value is often more convenient than dealing with a
16895 // #GTimeVal.
16897 // You should only use this call if you are actually interested in the real
16898 // wall-clock time. g_get_monotonic_time() is probably more useful for
16899 // measuring intervals.
16900 // RETURNS: the number of microseconds since January 1, 1970 UTC.
16901 static long get_real_time() {
16902 return g_get_real_time();
16906 // Returns an ordered list of base directories in which to access
16907 // system-wide configuration information.
16909 // On UNIX platforms this is determined using the mechanisms described in
16910 // the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
16911 // XDG Base Directory Specification</ulink>.
16912 // In this case the list of directories retrieved will be XDG_CONFIG_DIRS.
16914 // On Windows is the directory that contains application data for all users.
16915 // A typical path is C:\Documents and Settings\All Users\Application Data.
16916 // This folder is used for application data that is not user specific.
16917 // For example, an application can store a spell-check dictionary, a database
16918 // of clip art, or a log file in the CSIDL_COMMON_APPDATA folder.
16919 // This information will not roam and is available to anyone using the computer.
16921 // not be modified or freed.
16922 // RETURNS: a %NULL-terminated array of strings owned by GLib that must
16923 static char** get_system_config_dirs() {
16924 return g_get_system_config_dirs();
16928 // Returns an ordered list of base directories in which to access
16929 // system-wide application data.
16931 // On UNIX platforms this is determined using the mechanisms described in
16932 // the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
16933 // XDG Base Directory Specification</ulink>
16934 // In this case the list of directories retrieved will be XDG_DATA_DIRS.
16936 // On Windows the first elements in the list are the Application Data
16937 // and Documents folders for All Users. (These can be determined only
16938 // on Windows 2000 or later and are not present in the list on other
16939 // Windows versions.) See documentation for CSIDL_COMMON_APPDATA and
16940 // CSIDL_COMMON_DOCUMENTS.
16942 // Then follows the "share" subfolder in the installation folder for
16943 // the package containing the DLL that calls this function, if it can
16944 // be determined.
16946 // Finally the list contains the "share" subfolder in the installation
16947 // folder for GLib, and in the installation folder for the package the
16948 // application's .exe file belongs to.
16950 // The installation folders above are determined by looking up the
16951 // folder where the module (DLL or EXE) in question is located. If the
16952 // folder's name is "bin", its parent is used, otherwise the folder
16953 // itself.
16955 // Note that on Windows the returned list can vary depending on where
16956 // this function is called.
16958 // not be modified or freed.
16959 // RETURNS: a %NULL-terminated array of strings owned by GLib that must
16960 static char** get_system_data_dirs() {
16961 return g_get_system_data_dirs();
16965 // Gets the directory to use for temporary files. This is found from
16966 // inspecting the environment variables <envar>TMPDIR</envar>,
16967 // <envar>TMP</envar>, and <envar>TEMP</envar> in that order. If none
16968 // of those are defined "/tmp" is returned on UNIX and "C:\" on Windows.
16969 // The encoding of the returned string is system-defined. On Windows,
16970 // it is always UTF-8. The return value is never %NULL or the empty string.
16971 // RETURNS: the directory to use for temporary files.
16972 static char* get_tmp_dir() {
16973 return g_get_tmp_dir();
16977 // Returns a base directory in which to store non-essential, cached
16978 // data specific to particular user.
16980 // On UNIX platforms this is determined using the mechanisms described in
16981 // the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
16982 // XDG Base Directory Specification</ulink>.
16983 // In this case the directory retrieved will be XDG_CACHE_HOME.
16985 // On Windows is the directory that serves as a common repository for
16986 // temporary Internet files. A typical path is
16987 // C:\Documents and Settings\username\Local Settings\Temporary Internet Files.
16988 // See documentation for CSIDL_INTERNET_CACHE.
16990 // or freed.
16991 // RETURNS: a string owned by GLib that must not be modified
16992 static char* get_user_cache_dir() {
16993 return g_get_user_cache_dir();
16997 // Returns a base directory in which to store user-specific application
16998 // configuration information such as user preferences and settings.
17000 // On UNIX platforms this is determined using the mechanisms described in
17001 // the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
17002 // XDG Base Directory Specification</ulink>.
17003 // In this case the directory retrieved will be XDG_CONFIG_HOME.
17005 // On Windows this is the folder to use for local (as opposed to
17006 // roaming) application data. See documentation for
17007 // CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
17008 // what g_get_user_data_dir() returns.
17010 // or freed.
17011 // RETURNS: a string owned by GLib that must not be modified
17012 static char* get_user_config_dir() {
17013 return g_get_user_config_dir();
17017 // Returns a base directory in which to access application data such
17018 // as icons that is customized for a particular user.
17020 // On UNIX platforms this is determined using the mechanisms described in
17021 // the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
17022 // XDG Base Directory Specification</ulink>.
17023 // In this case the directory retrieved will be XDG_DATA_HOME.
17025 // On Windows this is the folder to use for local (as opposed to
17026 // roaming) application data. See documentation for
17027 // CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
17028 // what g_get_user_config_dir() returns.
17030 // or freed.
17031 // RETURNS: a string owned by GLib that must not be modified
17032 static char* get_user_data_dir() {
17033 return g_get_user_data_dir();
17037 // Gets the user name of the current user. The encoding of the returned
17038 // string is system-defined. On UNIX, it might be the preferred file name
17039 // encoding, or something else, and there is no guarantee that it is even
17040 // consistent on a machine. On Windows, it is always UTF-8.
17041 // RETURNS: the user name of the current user.
17042 static char* get_user_name() {
17043 return g_get_user_name();
17047 // Returns a directory that is unique to the current user on the local
17048 // system.
17050 // On UNIX platforms this is determined using the mechanisms described in
17051 // the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
17052 // XDG Base Directory Specification</ulink>. This is the directory
17053 // specified in the <envar>XDG_RUNTIME_DIR</envar> environment variable.
17054 // In the case that this variable is not set, GLib will issue a warning
17055 // message to stderr and return the value of g_get_user_cache_dir().
17057 // On Windows this is the folder to use for local (as opposed to
17058 // roaming) application data. See documentation for
17059 // CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
17060 // what g_get_user_config_dir() returns.
17061 // RETURNS: a string owned by GLib that must not be modified or freed.
17062 static char* get_user_runtime_dir() {
17063 return g_get_user_runtime_dir();
17067 // Returns the full path of a special directory using its logical id.
17069 // On Unix this is done using the XDG special user directories.
17070 // For compatibility with existing practise, %G_USER_DIRECTORY_DESKTOP
17071 // falls back to <filename>$HOME/Desktop</filename> when XDG special
17072 // user directories have not been set up.
17074 // Depending on the platform, the user might be able to change the path
17075 // of the special directory without requiring the session to restart; GLib
17076 // will not reflect any change once the special directories are loaded.
17078 // if the logical id was not found. The returned string is owned by
17079 // GLib and should not be modified or freed.
17080 // RETURNS: the path to the specified special directory, or %NULL
17081 // <directory>: the logical id of special directory
17082 static char* get_user_special_dir(UserDirectory directory) {
17083 return g_get_user_special_dir(directory);
17087 // Returns the value of an environment variable. The name and value
17088 // are in the GLib file name encoding. On UNIX, this means the actual
17089 // bytes which might or might not be in some consistent character set
17090 // and encoding. On Windows, it is in UTF-8. On Windows, in case the
17091 // environment variable's value contains references to other
17092 // environment variables, they are expanded.
17094 // the environment variable is not found. The returned string may be
17095 // overwritten by the next call to g_getenv(), g_setenv() or
17096 // g_unsetenv().
17097 // RETURNS: the value of the environment variable, or %NULL if
17098 // <variable>: the environment variable to get, in the GLib file name encoding.
17099 static char* getenv(char* variable) {
17100 return g_getenv(variable);
17104 // Destroys all keys and values in the #GHashTable and decrements its
17105 // reference count by 1. If keys and/or values are dynamically allocated,
17106 // you should either free them first or create the #GHashTable with destroy
17107 // notifiers using g_hash_table_new_full(). In the latter case the destroy
17108 // functions you supplied will be called on all keys and values during the
17109 // destruction phase.
17110 // <hash_table>: a #GHashTable.
17111 static void hash_table_destroy(GLib2.HashTable* hash_table) {
17112 g_hash_table_destroy(hash_table);
17116 // Inserts a new key and value into a #GHashTable.
17118 // If the key already exists in the #GHashTable its current value is replaced
17119 // with the new value. If you supplied a @value_destroy_func when creating the
17120 // #GHashTable, the old value is freed using that function. If you supplied
17121 // a @key_destroy_func when creating the #GHashTable, the passed key is freed
17122 // using that function.
17123 // <hash_table>: a #GHashTable.
17124 // <key>: a key to insert.
17125 // <value>: the value to associate with the key.
17126 static void hash_table_insert(GLib2.HashTable* hash_table, void* key, void* value) {
17127 g_hash_table_insert(hash_table, key, value);
17131 // Looks up a key in the #GHashTable, returning the original key and the
17132 // associated value and a #gboolean which is %TRUE if the key was found. This
17133 // is useful if you need to free the memory allocated for the original key,
17134 // for example before calling g_hash_table_remove().
17136 // You can actually pass %NULL for @lookup_key to test
17137 // whether the %NULL key exists, provided the hash and equal functions
17138 // of @hash_table are %NULL-safe.
17139 // RETURNS: %TRUE if the key was found in the #GHashTable.
17140 // <hash_table>: a #GHashTable
17141 // <lookup_key>: the key to look up
17142 // <orig_key>: return location for the original key, or %NULL
17143 // <value>: return location for the value associated with the key, or %NULL
17144 static int hash_table_lookup_extended(GLib2.HashTable* hash_table, const(void)* lookup_key, void** orig_key, void** value) {
17145 return g_hash_table_lookup_extended(hash_table, lookup_key, orig_key, value);
17149 // Removes a key and its associated value from a #GHashTable.
17151 // If the #GHashTable was created using g_hash_table_new_full(), the
17152 // key and value are freed using the supplied destroy functions, otherwise
17153 // you have to make sure that any dynamically allocated values are freed
17154 // yourself.
17155 // RETURNS: %TRUE if the key was found and removed from the #GHashTable.
17156 // <hash_table>: a #GHashTable.
17157 // <key>: the key to remove.
17158 static int hash_table_remove(GLib2.HashTable* hash_table, const(void)* key) {
17159 return g_hash_table_remove(hash_table, key);
17163 // Removes all keys and their associated values from a #GHashTable.
17165 // If the #GHashTable was created using g_hash_table_new_full(), the keys
17166 // and values are freed using the supplied destroy functions, otherwise you
17167 // have to make sure that any dynamically allocated values are freed
17168 // yourself.
17169 // <hash_table>: a #GHashTable
17170 static void hash_table_remove_all(GLib2.HashTable* hash_table) {
17171 g_hash_table_remove_all(hash_table);
17175 // Inserts a new key and value into a #GHashTable similar to
17176 // g_hash_table_insert(). The difference is that if the key already exists
17177 // in the #GHashTable, it gets replaced by the new key. If you supplied a
17178 // @value_destroy_func when creating the #GHashTable, the old value is freed
17179 // using that function. If you supplied a @key_destroy_func when creating the
17180 // #GHashTable, the old key is freed using that function.
17181 // <hash_table>: a #GHashTable.
17182 // <key>: a key to insert.
17183 // <value>: the value to associate with the key.
17184 static void hash_table_replace(GLib2.HashTable* hash_table, void* key, void* value) {
17185 g_hash_table_replace(hash_table, key, value);
17189 // Returns the number of elements contained in the #GHashTable.
17190 // RETURNS: the number of key/value pairs in the #GHashTable.
17191 // <hash_table>: a #GHashTable.
17192 static uint hash_table_size(GLib2.HashTable* hash_table) {
17193 return g_hash_table_size(hash_table);
17197 // Removes a key and its associated value from a #GHashTable without
17198 // calling the key and value destroy functions.
17199 // RETURNS: %TRUE if the key was found and removed from the #GHashTable.
17200 // <hash_table>: a #GHashTable.
17201 // <key>: the key to remove.
17202 static int hash_table_steal(GLib2.HashTable* hash_table, const(void)* key) {
17203 return g_hash_table_steal(hash_table, key);
17207 // Removes all keys and their associated values from a #GHashTable
17208 // without calling the key and value destroy functions.
17209 // <hash_table>: a #GHashTable.
17210 static void hash_table_steal_all(GLib2.HashTable* hash_table) {
17211 g_hash_table_steal_all(hash_table);
17215 // Atomically decrements the reference count of @hash_table by one.
17216 // If the reference count drops to 0, all keys and values will be
17217 // destroyed, and all memory allocated by the hash table is released.
17218 // This function is MT-safe and may be called from any thread.
17219 // <hash_table>: a valid #GHashTable.
17220 static void hash_table_unref(GLib2.HashTable* hash_table) {
17221 g_hash_table_unref(hash_table);
17224 static int hook_destroy(HookList* hook_list, c_ulong hook_id) {
17225 return g_hook_destroy(hook_list, hook_id);
17228 static void hook_destroy_link(HookList* hook_list, Hook* hook) {
17229 g_hook_destroy_link(hook_list, hook);
17232 static void hook_free(HookList* hook_list, Hook* hook) {
17233 g_hook_free(hook_list, hook);
17236 static void hook_insert_before(HookList* hook_list, Hook* sibling, Hook* hook) {
17237 g_hook_insert_before(hook_list, sibling, hook);
17240 static void hook_prepend(HookList* hook_list, Hook* hook) {
17241 g_hook_prepend(hook_list, hook);
17244 static void hook_unref(HookList* hook_list, Hook* hook) {
17245 g_hook_unref(hook_list, hook);
17249 // Tests if @hostname contains segments with an ASCII-compatible
17250 // encoding of an Internationalized Domain Name. If this returns
17251 // %TRUE, you should decode the hostname with g_hostname_to_unicode()
17252 // before displaying it to the user.
17254 // Note that a hostname might contain a mix of encoded and unencoded
17255 // segments, and so it is possible for g_hostname_is_non_ascii() and
17256 // g_hostname_is_ascii_encoded() to both return %TRUE for a name.
17258 // segments.
17259 // RETURNS: %TRUE if @hostname contains any ASCII-encoded
17260 // <hostname>: a hostname
17261 static int hostname_is_ascii_encoded(char* hostname) {
17262 return g_hostname_is_ascii_encoded(hostname);
17266 // Tests if @hostname is the string form of an IPv4 or IPv6 address.
17267 // (Eg, "192.168.0.1".)
17268 // RETURNS: %TRUE if @hostname is an IP address
17269 // <hostname>: a hostname (or IP address in string form)
17270 static int hostname_is_ip_address(char* hostname) {
17271 return g_hostname_is_ip_address(hostname);
17275 // Tests if @hostname contains Unicode characters. If this returns
17276 // %TRUE, you need to encode the hostname with g_hostname_to_ascii()
17277 // before using it in non-IDN-aware contexts.
17279 // Note that a hostname might contain a mix of encoded and unencoded
17280 // segments, and so it is possible for g_hostname_is_non_ascii() and
17281 // g_hostname_is_ascii_encoded() to both return %TRUE for a name.
17282 // RETURNS: %TRUE if @hostname contains any non-ASCII characters
17283 // <hostname>: a hostname
17284 static int hostname_is_non_ascii(char* hostname) {
17285 return g_hostname_is_non_ascii(hostname);
17289 // Converts @hostname to its canonical ASCII form; an ASCII-only
17290 // string containing no uppercase letters and not ending with a
17291 // trailing dot.
17293 // @hostname is in some way invalid.
17294 // RETURNS: an ASCII hostname, which must be freed, or %NULL if
17295 // <hostname>: a valid UTF-8 or ASCII hostname
17296 static char* /*new*/ hostname_to_ascii(char* hostname) {
17297 return g_hostname_to_ascii(hostname);
17301 // Converts @hostname to its canonical presentation form; a UTF-8
17302 // string in Unicode normalization form C, containing no uppercase
17303 // letters, no forbidden characters, and no ASCII-encoded segments,
17304 // and not ending with a trailing dot.
17306 // Of course if @hostname is not an internationalized hostname, then
17307 // the canonical presentation form will be entirely ASCII.
17309 // @hostname is in some way invalid.
17310 // RETURNS: a UTF-8 hostname, which must be freed, or %NULL if
17311 // <hostname>: a valid UTF-8 or ASCII hostname
17312 static char* /*new*/ hostname_to_unicode(char* hostname) {
17313 return g_hostname_to_unicode(hostname);
17317 // Unintrospectable function: idle_add() / g_idle_add()
17318 // Adds a function to be called whenever there are no higher priority
17319 // events pending to the default main loop. The function is given the
17320 // default idle priority, #G_PRIORITY_DEFAULT_IDLE. If the function
17321 // returns %FALSE it is automatically removed from the list of event
17322 // sources and will not be called again.
17324 // This internally creates a main loop source using g_idle_source_new()
17325 // and attaches it to the main loop context using g_source_attach().
17326 // You can do these steps manually if you need greater control.
17327 // RETURNS: the ID (greater than 0) of the event source.
17328 // <function>: function to call
17329 // <data>: data to pass to @function.
17330 static uint idle_add(SourceFunc function_, void* data) {
17331 return g_idle_add(function_, data);
17335 // Adds a function to be called whenever there are no higher priority
17336 // events pending. If the function returns %FALSE it is automatically
17337 // removed from the list of event sources and will not be called again.
17339 // This internally creates a main loop source using g_idle_source_new()
17340 // and attaches it to the main loop context using g_source_attach().
17341 // You can do these steps manually if you need greater control.
17342 // RETURNS: the ID (greater than 0) of the event source.
17343 // <priority>: the priority of the idle source. Typically this will be in the range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.
17344 // <function>: function to call
17345 // <data>: data to pass to @function
17346 // <notify>: function to call when the idle is removed, or %NULL
17347 static uint idle_add_full(int priority, SourceFunc function_, void* data, DestroyNotify notify) {
17348 return g_idle_add_full(priority, function_, data, notify);
17352 // Removes the idle function with the given data.
17353 // RETURNS: %TRUE if an idle source was found and removed.
17354 // <data>: the data for the idle source's callback.
17355 static int idle_remove_by_data(void* data) {
17356 return g_idle_remove_by_data(data);
17360 // Creates a new idle source.
17362 // The source will not initially be associated with any #GMainContext
17363 // and must be added to one with g_source_attach() before it will be
17364 // executed. Note that the default priority for idle sources is
17365 // %G_PRIORITY_DEFAULT_IDLE, as compared to other sources which
17366 // have a default priority of %G_PRIORITY_DEFAULT.
17367 // RETURNS: the newly-created idle source
17368 static Source* /*new*/ idle_source_new() {
17369 return g_idle_source_new();
17373 // Compares the two #gint64 values being pointed to and returns
17374 // %TRUE if they are equal.
17375 // It can be passed to g_hash_table_new() as the @key_equal_func
17376 // parameter, when using pointers to 64-bit integers as keys in a #GHashTable.
17377 // RETURNS: %TRUE if the two keys match.
17378 // <v1>: a pointer to a #gint64 key.
17379 // <v2>: a pointer to a #gint64 key to compare with @v1.
17380 static int int64_equal(const(void)* v1, const(void)* v2) {
17381 return g_int64_equal(v1, v2);
17385 // Converts a pointer to a #gint64 to a hash value.
17386 // It can be passed to g_hash_table_new() as the @hash_func parameter,
17387 // when using pointers to 64-bit integers values as keys in a #GHashTable.
17388 // RETURNS: a hash value corresponding to the key.
17389 // <v>: a pointer to a #gint64 key
17390 static uint int64_hash(const(void)* v) {
17391 return g_int64_hash(v);
17395 // Compares the two #gint values being pointed to and returns
17396 // %TRUE if they are equal.
17397 // It can be passed to g_hash_table_new() as the @key_equal_func
17398 // parameter, when using pointers to integers as keys in a #GHashTable.
17399 // RETURNS: %TRUE if the two keys match.
17400 // <v1>: a pointer to a #gint key.
17401 // <v2>: a pointer to a #gint key to compare with @v1.
17402 static int int_equal(const(void)* v1, const(void)* v2) {
17403 return g_int_equal(v1, v2);
17407 // Converts a pointer to a #gint to a hash value.
17408 // It can be passed to g_hash_table_new() as the @hash_func parameter,
17409 // when using pointers to integers values as keys in a #GHashTable.
17410 // RETURNS: a hash value corresponding to the key.
17411 // <v>: a pointer to a #gint key
17412 static uint int_hash(const(void)* v) {
17413 return g_int_hash(v);
17417 // Returns a canonical representation for @string. Interned strings can
17418 // be compared for equality by comparing the pointers, instead of using strcmp().
17419 // g_intern_static_string() does not copy the string, therefore @string must
17420 // not be freed or modified.
17421 // RETURNS: a canonical representation for the string
17422 // <string>: a static string
17423 static char* intern_static_string(char* string_=null) {
17424 return g_intern_static_string(string_);
17428 // Returns a canonical representation for @string. Interned strings can
17429 // be compared for equality by comparing the pointers, instead of using strcmp().
17430 // RETURNS: a canonical representation for the string
17431 // <string>: a string
17432 static char* intern_string(char* string_=null) {
17433 return g_intern_string(string_);
17437 // Unintrospectable function: io_add_watch() / g_io_add_watch()
17438 // Adds the #GIOChannel into the default main loop context
17439 // with the default priority.
17440 // RETURNS: the event source id
17441 // <channel>: a #GIOChannel
17442 // <condition>: the condition to watch for
17443 // <func>: the function to call when the condition is satisfied
17444 // <user_data>: user data to pass to @func
17445 static uint io_add_watch(IOChannel* channel, IOCondition condition, IOFunc func, void* user_data) {
17446 return g_io_add_watch(channel, condition, func, user_data);
17450 // Adds the #GIOChannel into the default main loop context
17451 // with the given priority.
17453 // This internally creates a main loop source using g_io_create_watch()
17454 // and attaches it to the main loop context with g_source_attach().
17455 // You can do these steps manually if you need greater control.
17456 // RETURNS: the event source id
17457 // <channel>: a #GIOChannel
17458 // <priority>: the priority of the #GIOChannel source
17459 // <condition>: the condition to watch for
17460 // <func>: the function to call when the condition is satisfied
17461 // <user_data>: user data to pass to @func
17462 // <notify>: the function to call when the source is removed
17463 static uint io_add_watch_full(IOChannel* channel, int priority, IOCondition condition, IOFunc func, void* user_data, DestroyNotify notify) {
17464 return g_io_add_watch_full(channel, priority, condition, func, user_data, notify);
17468 // Converts an <literal>errno</literal> error number to a #GIOChannelError.
17470 // %G_IO_CHANNEL_ERROR_INVAL.
17471 // RETURNS: a #GIOChannelError error number, e.g.
17472 // <en>: an <literal>errno</literal> error number, e.g. %EINVAL
17473 static IOChannelError io_channel_error_from_errno(int en) {
17474 return g_io_channel_error_from_errno(en);
17477 // RETURNS: the quark used as %G_IO_CHANNEL_ERROR
17478 static Quark io_channel_error_quark() {
17479 return g_io_channel_error_quark();
17483 // Creates a #GSource that's dispatched when @condition is met for the
17484 // given @channel. For example, if condition is #G_IO_IN, the source will
17485 // be dispatched when there's data available for reading.
17487 // g_io_add_watch() is a simpler interface to this same functionality, for
17488 // the case where you want to add the source to the default main loop context
17489 // at the default priority.
17491 // On Windows, polling a #GSource created to watch a channel for a socket
17492 // puts the socket in non-blocking mode. This is a side-effect of the
17493 // implementation and unavoidable.
17494 // RETURNS: a new #GSource
17495 // <channel>: a #GIOChannel to watch
17496 // <condition>: conditions to watch for
17497 static Source* /*new*/ io_create_watch(IOChannel* channel, IOCondition condition) {
17498 return g_io_create_watch(channel, condition);
17501 static Quark key_file_error_quark() {
17502 return g_key_file_error_quark();
17506 // Restores the previous #GAllocator, used when allocating #GList
17507 // elements.
17509 // Note that this function is not available if GLib has been compiled
17510 // with <option>--disable-mem-pools</option>
17512 // Deprecated:2.10: It does nothing, since #GList has been converted
17513 // to the <link linkend="glib-Memory-Slices">slice
17514 // allocator</link>
17515 static void list_pop_allocator() {
17516 g_list_pop_allocator();
17520 // Sets the allocator to use to allocate #GList elements. Use
17521 // g_list_pop_allocator() to restore the previous allocator.
17523 // Note that this function is not available if GLib has been compiled
17524 // with <option>--disable-mem-pools</option>
17526 // Deprecated:2.10: It does nothing, since #GList has been converted
17527 // to the <link linkend="glib-Memory-Slices">slice
17528 // allocator</link>
17529 // <allocator>: the #GAllocator to use when allocating #GList elements.
17530 static void list_push_allocator(void* allocator) {
17531 g_list_push_allocator(allocator);
17535 // Gets the names of all variables set in the environment.
17537 // with g_strfreev().
17539 // Programs that want to be portable to Windows should typically use
17540 // this function and g_getenv() instead of using the environ array
17541 // from the C library directly. On Windows, the strings in the environ
17542 // array are in system codepage encoding, while in most of the typical
17543 // use cases for environment variables in GLib-using programs you want
17544 // the UTF-8 encoding that this function and g_getenv() provide.
17545 // RETURNS: a %NULL-terminated list of strings which must be freed
17546 static char** /*new*/ listenv() {
17547 return g_listenv();
17551 // Converts a string from UTF-8 to the encoding used for strings by
17552 // the C runtime (usually the same as that used by the operating
17553 // system) in the <link linkend="setlocale">current locale</link>. On
17554 // Windows this means the system codepage.
17555 // RETURNS: The converted string, or %NULL on an error.
17556 // <utf8string>: a UTF-8 encoded string
17557 // <len>: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
17558 // <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.
17559 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
17560 static char* /*new*/ locale_from_utf8(char* utf8string, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error=null) {
17561 return g_locale_from_utf8(utf8string, len, bytes_read, bytes_written, error);
17565 // Converts a string which is in the encoding used for strings by
17566 // the C runtime (usually the same as that used by the operating
17567 // system) in the <link linkend="setlocale">current locale</link> into a
17568 // UTF-8 string.
17569 // RETURNS: The converted string, or %NULL on an error.
17570 // <opsysstring>: a string in the encoding of the current locale. On Windows this means the system codepage.
17571 // <len>: the length of the string, or -1 if the string is nul-terminated<footnoteref linkend="nul-unsafe"/>.
17572 // <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.
17573 // <bytes_written>: the number of bytes stored in the output buffer (not including the terminating nul).
17574 static char* /*new*/ locale_to_utf8(char* opsysstring, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error=null) {
17575 return g_locale_to_utf8(opsysstring, len, bytes_read, bytes_written, error);
17578 // Unintrospectable function: log() / g_log()
17579 alias g_log log; // Variadic
17581 static void log_default_handler(char* log_domain, LogLevelFlags log_level, char* message, void* unused_data) {
17582 g_log_default_handler(log_domain, log_level, message, unused_data);
17585 static void log_remove_handler(char* log_domain, uint handler_id) {
17586 g_log_remove_handler(log_domain, handler_id);
17589 static LogLevelFlags log_set_always_fatal(LogLevelFlags fatal_mask) {
17590 return g_log_set_always_fatal(fatal_mask);
17593 // Unintrospectable function: log_set_default_handler() / g_log_set_default_handler()
17594 static LogFunc log_set_default_handler(LogFunc log_func, void* user_data) {
17595 return g_log_set_default_handler(log_func, user_data);
17598 static LogLevelFlags log_set_fatal_mask(char* log_domain, LogLevelFlags fatal_mask) {
17599 return g_log_set_fatal_mask(log_domain, fatal_mask);
17602 // Unintrospectable function: log_set_handler() / g_log_set_handler()
17603 static uint log_set_handler(char* log_domain, LogLevelFlags log_levels, LogFunc log_func, void* user_data) {
17604 return g_log_set_handler(log_domain, log_levels, log_func, user_data);
17607 // Unintrospectable function: logv() / g_logv()
17608 static void logv(char* log_domain, LogLevelFlags log_level, char* format, va_list args) {
17609 g_logv(log_domain, log_level, format, args);
17613 // Returns the global default main context. This is the main context
17614 // used for main loop functions when a main loop is not explicitly
17615 // specified, and corresponds to the "main" main loop. See also
17616 // g_main_context_get_thread_default().
17617 // RETURNS: the global default main context.
17618 static MainContext* main_context_default() {
17619 return g_main_context_default();
17623 // Gets the thread-default #GMainContext for this thread. Asynchronous
17624 // operations that want to be able to be run in contexts other than
17625 // the default one should call this method to get a #GMainContext to
17626 // add their #GSource<!-- -->s to. (Note that even in single-threaded
17627 // programs applications may sometimes want to temporarily push a
17628 // non-default context, so it is not safe to assume that this will
17629 // always return %NULL if threads are not initialized.)
17631 // %NULL if the thread-default context is the global default context.
17632 // RETURNS: the thread-default #GMainContext, or
17633 static MainContext* main_context_get_thread_default() {
17634 return g_main_context_get_thread_default();
17638 // Returns the currently firing source for this thread.
17639 // RETURNS: The currently firing source or %NULL.
17640 static Source* main_current_source() {
17641 return g_main_current_source();
17645 // Returns the depth of the stack of calls to
17646 // g_main_context_dispatch() on any #GMainContext in the current thread.
17647 // That is, when called from the toplevel, it gives 0. When
17648 // called from within a callback from g_main_context_iteration()
17649 // (or g_main_loop_run(), etc.) it returns 1. When called from within
17650 // a callback to a recursive call to g_main_context_iteration(),
17651 // it returns 2. And so forth.
17653 // This function is useful in a situation like the following:
17654 // Imagine an extremely simple "garbage collected" system.
17656 // |[
17657 // static GList *free_list;
17659 // gpointer
17660 // allocate_memory (gsize size)
17661 // {
17662 // gpointer result = g_malloc (size);
17663 // free_list = g_list_prepend (free_list, result);
17664 // return result;
17665 // }
17667 // void
17668 // free_allocated_memory (void)
17669 // {
17670 // GList *l;
17671 // for (l = free_list; l; l = l->next);
17672 // g_free (l->data);
17673 // g_list_free (free_list);
17674 // free_list = NULL;
17675 // }
17677 // [...]
17679 // while (TRUE);
17680 // {
17681 // g_main_context_iteration (NULL, TRUE);
17682 // free_allocated_memory();
17683 // }
17684 // ]|
17686 // This works from an application, however, if you want to do the same
17687 // thing from a library, it gets more difficult, since you no longer
17688 // control the main loop. You might think you can simply use an idle
17689 // function to make the call to free_allocated_memory(), but that
17690 // doesn't work, since the idle function could be called from a
17691 // recursive callback. This can be fixed by using g_main_depth()
17693 // |[
17694 // gpointer
17695 // allocate_memory (gsize size)
17696 // {
17697 // FreeListBlock *block = g_new (FreeListBlock, 1);
17698 // block->mem = g_malloc (size);
17699 // block->depth = g_main_depth ();
17700 // free_list = g_list_prepend (free_list, block);
17701 // return block->mem;
17702 // }
17704 // void
17705 // free_allocated_memory (void)
17706 // {
17707 // GList *l;
17709 // int depth = g_main_depth ();
17710 // for (l = free_list; l; );
17711 // {
17712 // GList *next = l->next;
17713 // FreeListBlock *block = l->data;
17714 // if (block->depth > depth)
17715 // {
17716 // g_free (block->mem);
17717 // g_free (block);
17718 // free_list = g_list_delete_link (free_list, l);
17719 // }
17721 // l = next;
17722 // }
17723 // }
17724 // ]|
17726 // There is a temptation to use g_main_depth() to solve
17727 // problems with reentrancy. For instance, while waiting for data
17728 // to be received from the network in response to a menu item,
17729 // the menu item might be selected again. It might seem that
17730 // one could make the menu item's callback return immediately
17731 // and do nothing if g_main_depth() returns a value greater than 1.
17732 // However, this should be avoided since the user then sees selecting
17733 // the menu item do nothing. Furthermore, you'll find yourself adding
17734 // these checks all over your code, since there are doubtless many,
17735 // many things that the user could do. Instead, you can use the
17736 // following techniques:
17738 // <orderedlist>
17739 // <listitem>
17740 // <para>
17741 // Use gtk_widget_set_sensitive() or modal dialogs to prevent
17742 // the user from interacting with elements while the main
17743 // loop is recursing.
17744 // </para>
17745 // </listitem>
17746 // <listitem>
17747 // <para>
17748 // Avoid main loop recursion in situations where you can't handle
17749 // arbitrary callbacks. Instead, structure your code so that you
17750 // simply return to the main loop and then get called again when
17751 // there is more work to do.
17752 // </para>
17753 // </listitem>
17754 // </orderedlist>
17755 // RETURNS: The main loop recursion level in the current thread
17756 static int main_depth() {
17757 return g_main_depth();
17761 // Unintrospectable function: malloc() / g_malloc()
17762 // Allocates @n_bytes bytes of memory.
17763 // If @n_bytes is 0 it returns %NULL.
17764 // RETURNS: a pointer to the allocated memory
17765 // <n_bytes>: the number of bytes to allocate
17766 static void* malloc(size_t n_bytes) {
17767 return g_malloc(n_bytes);
17771 // Unintrospectable function: malloc0() / g_malloc0()
17772 // Allocates @n_bytes bytes of memory, initialized to 0's.
17773 // If @n_bytes is 0 it returns %NULL.
17774 // RETURNS: a pointer to the allocated memory
17775 // <n_bytes>: the number of bytes to allocate
17776 static void* malloc0(size_t n_bytes) {
17777 return g_malloc0(n_bytes);
17781 // Unintrospectable function: malloc0_n() / g_malloc0_n()
17782 // This function is similar to g_malloc0(), allocating (@n_blocks * @n_block_bytes) bytes,
17783 // but care is taken to detect possible overflow during multiplication.
17784 // RETURNS: a pointer to the allocated memory
17785 // <n_blocks>: the number of blocks to allocate
17786 // <n_block_bytes>: the size of each block in bytes
17787 static void* malloc0_n(size_t n_blocks, size_t n_block_bytes) {
17788 return g_malloc0_n(n_blocks, n_block_bytes);
17792 // Unintrospectable function: malloc_n() / g_malloc_n()
17793 // This function is similar to g_malloc(), allocating (@n_blocks * @n_block_bytes) bytes,
17794 // but care is taken to detect possible overflow during multiplication.
17795 // RETURNS: a pointer to the allocated memory
17796 // <n_blocks>: the number of blocks to allocate
17797 // <n_block_bytes>: the size of each block in bytes
17798 static void* malloc_n(size_t n_blocks, size_t n_block_bytes) {
17799 return g_malloc_n(n_blocks, n_block_bytes);
17803 // Unintrospectable function: markup_collect_attributes() / g_markup_collect_attributes()
17804 // Collects the attributes of the element from the data passed to the
17805 // #GMarkupParser start_element function, dealing with common error
17806 // conditions and supporting boolean values.
17808 // This utility function is not required to write a parser but can save
17809 // a lot of typing.
17811 // The @element_name, @attribute_names, @attribute_values and @error
17812 // parameters passed to the start_element callback should be passed
17813 // unmodified to this function.
17815 // Following these arguments is a list of "supported" attributes to collect.
17816 // It is an error to specify multiple attributes with the same name. If any
17817 // attribute not in the list appears in the @attribute_names array then an
17818 // unknown attribute error will result.
17820 // The #GMarkupCollectType field allows specifying the type of collection
17821 // to perform and if a given attribute must appear or is optional.
17823 // The attribute name is simply the name of the attribute to collect.
17825 // The pointer should be of the appropriate type (see the descriptions
17826 // under #GMarkupCollectType) and may be %NULL in case a particular
17827 // attribute is to be allowed but ignored.
17829 // This function deals with issuing errors for missing attributes
17830 // (of type %G_MARKUP_ERROR_MISSING_ATTRIBUTE), unknown attributes
17831 // (of type %G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE) and duplicate
17832 // attributes (of type %G_MARKUP_ERROR_INVALID_CONTENT) as well
17833 // as parse errors for boolean-valued attributes (again of type
17834 // %G_MARKUP_ERROR_INVALID_CONTENT). In all of these cases %FALSE
17835 // will be returned and @error will be set as appropriate.
17836 // RETURNS: %TRUE if successful
17837 // <element_name>: the current tag name
17838 // <attribute_names>: the attribute names
17839 // <attribute_values>: the attribute values
17840 // <error>: a pointer to a #GError or %NULL
17841 // <first_type>: the #GMarkupCollectType of the first attribute
17842 // <first_attr>: the name of the first attribute
17843 alias g_markup_collect_attributes markup_collect_attributes; // Variadic
17845 static Quark markup_error_quark() {
17846 return g_markup_error_quark();
17850 // Escapes text so that the markup parser will parse it verbatim.
17851 // Less than, greater than, ampersand, etc. are replaced with the
17852 // corresponding entities. This function would typically be used
17853 // when writing out a file to be parsed with the markup parser.
17855 // Note that this function doesn't protect whitespace and line endings
17856 // from being processed according to the XML rules for normalization
17857 // of line endings and attribute values.
17859 // Note also that this function will produce character references in
17860 // the range of &amp;#x1; ... &amp;#x1f; for all control sequences
17861 // except for tabstop, newline and carriage return. The character
17862 // references in this range are not valid XML 1.0, but they are
17863 // valid XML 1.1 and will be accepted by the GMarkup parser.
17864 // RETURNS: a newly allocated string with the escaped text
17865 // <text>: some valid UTF-8 text
17866 // <length>: length of @text in bytes, or -1 if the text is nul-terminated
17867 static char* /*new*/ markup_escape_text(char* text, ssize_t length) {
17868 return g_markup_escape_text(text, length);
17872 // Unintrospectable function: markup_printf_escaped() / g_markup_printf_escaped()
17873 // Formats arguments according to @format, escaping
17874 // all string and character arguments in the fashion
17875 // of g_markup_escape_text(). This is useful when you
17876 // want to insert literal strings into XML-style markup
17877 // output, without having to worry that the strings
17878 // might themselves contain markup.
17880 // |[
17881 // const char *store = "Fortnum &amp; Mason";
17882 // const char *item = "Tea";
17883 // char *output;
17884 // &nbsp;
17885 // output = g_markup_printf_escaped ("&lt;purchase&gt;"
17886 // "&lt;store&gt;&percnt;s&lt;/store&gt;"
17887 // "&lt;item&gt;&percnt;s&lt;/item&gt;"
17888 // "&lt;/purchase&gt;",
17889 // store, item);
17890 // ]|
17892 // operation. Free with g_free().
17893 // RETURNS: newly allocated result from formatting
17894 // <format>: printf() style format string
17895 alias g_markup_printf_escaped markup_printf_escaped; // Variadic
17898 // Unintrospectable function: markup_vprintf_escaped() / g_markup_vprintf_escaped()
17899 // Formats the data in @args according to @format, escaping
17900 // all string and character arguments in the fashion
17901 // of g_markup_escape_text(). See g_markup_printf_escaped().
17903 // operation. Free with g_free().
17904 // RETURNS: newly allocated result from formatting
17905 // <format>: printf() style format string
17906 // <args>: variable argument list, similar to vprintf()
17907 static char* /*new*/ markup_vprintf_escaped(char* format, va_list args) {
17908 return g_markup_vprintf_escaped(format, args);
17912 // Outputs debugging information for all #GMemChunk objects currently
17913 // in use. It outputs the number of #GMemChunk objects currently
17914 // allocated, and calls g_mem_chunk_print() to output information on
17915 // each one.
17917 // Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
17918 // allocator</link> instead
17919 static void mem_chunk_info() {
17920 g_mem_chunk_info();
17924 // Checks whether the allocator used by g_malloc() is the system's
17925 // malloc implementation. If it returns %TRUE memory allocated with
17926 // malloc() can be used interchangeable with memory allocated using g_malloc().
17927 // This function is useful for avoiding an extra copy of allocated memory returned
17928 // by a non-GLib-based API.
17930 // A different allocator can be set using g_mem_set_vtable().
17931 // RETURNS: if %TRUE, malloc() and g_malloc() can be mixed.
17932 static int mem_is_system_malloc() {
17933 return g_mem_is_system_malloc();
17937 // Outputs a summary of memory usage.
17939 // It outputs the frequency of allocations of different sizes,
17940 // the total number of bytes which have been allocated,
17941 // the total number of bytes which have been freed,
17942 // and the difference between the previous two values, i.e. the number of bytes
17943 // still in use.
17945 // Note that this function will not output anything unless you have
17946 // previously installed the #glib_mem_profiler_table with g_mem_set_vtable().
17947 static void mem_profile() {
17948 g_mem_profile();
17952 // Sets the #GMemVTable to use for memory allocation. You can use this to provide
17953 // custom memory allocation routines. <emphasis>This function must be called
17954 // before using any other GLib functions.</emphasis> The @vtable only needs to
17955 // provide malloc(), realloc(), and free() functions; GLib can provide default
17956 // implementations of the others. The malloc() and realloc() implementations
17957 // should return %NULL on failure, GLib will handle error-checking for you.
17958 // @vtable is copied, so need not persist after this function has been called.
17959 // <vtable>: table of memory allocation routines.
17960 static void mem_set_vtable(MemVTable* vtable) {
17961 g_mem_set_vtable(vtable);
17965 // Unintrospectable function: memdup() / g_memdup()
17966 // Allocates @byte_size bytes of memory, and copies @byte_size bytes into it
17967 // from @mem. If @mem is %NULL it returns %NULL.
17969 // is %NULL.
17970 // RETURNS: a pointer to the newly-allocated copy of the memory, or %NULL if @mem
17971 // <mem>: the memory to copy.
17972 // <byte_size>: the number of bytes to copy.
17973 static void* memdup(const(void)* mem, uint byte_size) {
17974 return g_memdup(mem, byte_size);
17978 // Create a directory if it doesn't already exist. Create intermediate
17979 // parent directories as needed, too.
17981 // created. Returns -1 if an error occurred, with errno set.
17982 // RETURNS: 0 if the directory already exists, or was successfully
17983 // <pathname>: a pathname in the GLib file name encoding
17984 // <mode>: permissions to use for newly created directories
17985 static int mkdir_with_parents(char* pathname, int mode) {
17986 return g_mkdir_with_parents(pathname, mode);
17990 // Creates a temporary directory. See the mkdtemp() documentation
17991 // on most UNIX-like systems.
17993 // The parameter is a string that should follow the rules for
17994 // mkdtemp() templates, i.e. contain the string "XXXXXX".
17995 // g_mkdtemp() is slightly more flexible than mkdtemp() in that the
17996 // sequence does not have to occur at the very end of the template
17997 // and you can pass a @mode and additional @flags. The X string will
17998 // be modified to form the name of a directory that didn't exist.
17999 // The string should be in the GLib file name encoding. Most importantly,
18000 // on Windows it should be in UTF-8.
18002 // to hold the directory name. In case of errors, %NULL is
18003 // returned and %errno will be set.
18004 // RETURNS: A pointer to @tmpl, which has been modified
18005 // <tmpl>: template directory name
18006 static char* /*new*/ mkdtemp(char* tmpl) {
18007 return g_mkdtemp(tmpl);
18011 // Creates a temporary directory. See the mkdtemp() documentation
18012 // on most UNIX-like systems.
18014 // The parameter is a string that should follow the rules for
18015 // mkdtemp() templates, i.e. contain the string "XXXXXX".
18016 // g_mkdtemp() is slightly more flexible than mkdtemp() in that the
18017 // sequence does not have to occur at the very end of the template
18018 // and you can pass a @mode. The X string will be modified to form
18019 // the name of a directory that didn't exist. The string should be
18020 // in the GLib file name encoding. Most importantly, on Windows it
18021 // should be in UTF-8.
18023 // to hold the directory name. In case of errors, %NULL is
18024 // returned, and %errno will be set.
18025 // RETURNS: A pointer to @tmpl, which has been modified
18026 // <tmpl>: template directory name
18027 // <mode>: permissions to create the temporary directory with
18028 static char* /*new*/ mkdtemp_full(char* tmpl, int mode) {
18029 return g_mkdtemp_full(tmpl, mode);
18033 // Opens a temporary file. See the mkstemp() documentation
18034 // on most UNIX-like systems.
18036 // The parameter is a string that should follow the rules for
18037 // mkstemp() templates, i.e. contain the string "XXXXXX".
18038 // g_mkstemp() is slightly more flexible than mkstemp() in that the
18039 // sequence does not have to occur at the very end of the template.
18040 // The X string will be modified to form the name of a file that
18041 // didn't exist. The string should be in the GLib file name encoding.
18042 // Most importantly, on Windows it should be in UTF-8.
18044 // opened for reading and writing. The file is opened in binary
18045 // mode on platforms where there is a difference. The file handle
18046 // should be closed with close(). In case of errors, -1 is
18047 // returned and %errno will be set.
18048 // RETURNS: A file handle (as from open()) to the file
18049 // <tmpl>: template filename
18050 static int mkstemp(char* tmpl) {
18051 return g_mkstemp(tmpl);
18055 // Opens a temporary file. See the mkstemp() documentation
18056 // on most UNIX-like systems.
18058 // The parameter is a string that should follow the rules for
18059 // mkstemp() templates, i.e. contain the string "XXXXXX".
18060 // g_mkstemp_full() is slightly more flexible than mkstemp()
18061 // in that the sequence does not have to occur at the very end of the
18062 // template and you can pass a @mode and additional @flags. The X
18063 // string will be modified to form the name of a file that didn't exist.
18064 // The string should be in the GLib file name encoding. Most importantly,
18065 // on Windows it should be in UTF-8.
18067 // opened for reading and writing. The file handle should be
18068 // closed with close(). In case of errors, -1 is returned
18069 // and %errno will be set.
18070 // RETURNS: A file handle (as from open()) to the file
18071 // <tmpl>: template filename
18072 // <flags>: flags to pass to an open() call in addition to O_EXCL and O_CREAT, which are passed automatically
18073 // <mode>: permissions to create the temporary file with
18074 static int mkstemp_full(char* tmpl, int flags, int mode) {
18075 return g_mkstemp_full(tmpl, flags, mode);
18079 // Restores the previous #GAllocator, used when allocating #GNode
18080 // elements.
18082 // Note that this function is not available if GLib has been compiled
18083 // with <option>--disable-mem-pools</option>
18085 // Deprecated:2.10: It does nothing, since #GNode has been converted to
18086 // the <link linkend="glib-Memory-Slices">slice
18087 // allocator</link>
18088 static void node_pop_allocator() {
18089 g_node_pop_allocator();
18093 // Sets the allocator to use to allocate #GNode elements. Use
18094 // g_node_pop_allocator() to restore the previous allocator.
18096 // Note that this function is not available if GLib has been compiled
18097 // with <option>--disable-mem-pools</option>
18099 // Deprecated:2.10: It does nothing, since #GNode has been converted to
18100 // the <link linkend="glib-Memory-Slices">slice
18101 // allocator</link>
18102 // <dummy>: the #GAllocator to use when allocating #GNode elements.
18103 static void node_push_allocator(void* dummy) {
18104 g_node_push_allocator(dummy);
18108 // Set the pointer at the specified location to %NULL.
18109 // <nullify_location>: the memory address of the pointer.
18110 static void nullify_pointer(void** nullify_location) {
18111 g_nullify_pointer(nullify_location);
18115 // Prompts the user with
18116 // <computeroutput>[E]xit, [H]alt, show [S]tack trace or [P]roceed</computeroutput>.
18117 // This function is intended to be used for debugging use only.
18118 // The following example shows how it can be used together with
18119 // the g_log() functions.
18121 // |[
18122 // &num;include &lt;glib.h&gt;
18124 // static void
18125 // log_handler (const gchar *log_domain,
18126 // GLogLevelFlags log_level,
18127 // const gchar *message,
18128 // gpointer user_data)
18129 // {
18130 // g_log_default_handler (log_domain, log_level, message, user_data);
18132 // g_on_error_query (MY_PROGRAM_NAME);
18133 // }
18135 // int
18136 // main (int argc, char *argv[])
18137 // {
18138 // g_log_set_handler (MY_LOG_DOMAIN,
18139 // G_LOG_LEVEL_WARNING |
18140 // G_LOG_LEVEL_ERROR |
18141 // G_LOG_LEVEL_CRITICAL,
18142 // log_handler,
18143 // NULL);
18144 // /&ast; ... &ast;/
18145 // ]|
18147 // If [E]xit is selected, the application terminates with a call
18148 // to <literal>_exit(0)</literal>.
18150 // If [S]tack trace is selected, g_on_error_stack_trace() is called.
18151 // This invokes <command>gdb</command>, which attaches to the current
18152 // process and shows a stack trace. The prompt is then shown again.
18154 // If [P]roceed is selected, the function returns.
18156 // This function may cause different actions on non-UNIX platforms.
18157 // <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)
18158 static void on_error_query(char* prg_name) {
18159 g_on_error_query(prg_name);
18163 // Invokes <command>gdb</command>, which attaches to the current
18164 // process and shows a stack trace. Called by g_on_error_query()
18165 // when the [S]tack trace option is selected.
18167 // This function may cause different actions on non-UNIX platforms.
18168 // <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)
18169 static void on_error_stack_trace(char* prg_name) {
18170 g_on_error_stack_trace(prg_name);
18174 // Function to be called when starting a critical initialization
18175 // section. The argument @value_location must point to a static
18176 // 0-initialized variable that will be set to a value other than 0 at
18177 // the end of the initialization section. In combination with
18178 // g_once_init_leave() and the unique address @value_location, it can
18179 // be ensured that an initialization section will be executed only once
18180 // during a program's life time, and that concurrent threads are
18181 // blocked until initialization completed. To be used in constructs
18182 // like this:
18184 // <informalexample>
18185 // <programlisting>
18186 // static gsize initialization_value = 0;
18188 // if (g_once_init_enter (&amp;initialization_value))
18189 // {
18190 // gsize setup_value = 42; /<!-- -->* initialization code here *<!-- -->/
18192 // g_once_init_leave (&amp;initialization_value, setup_value);
18193 // }
18195 // /<!-- -->* use initialization_value here *<!-- -->/
18196 // </programlisting>
18197 // </informalexample>
18198 // <value_location>: location of a static initializable variable containing 0.
18199 static int once_init_enter(size_t* value_location) {
18200 return g_once_init_enter(value_location);
18203 static int once_init_enter_impl(size_t* value_location) {
18204 return g_once_init_enter_impl(value_location);
18208 // Counterpart to g_once_init_enter(). Expects a location of a static
18209 // 0-initialized initialization variable, and an initialization value
18210 // other than 0. Sets the variable to the initialization value, and
18211 // releases concurrent threads blocking in g_once_init_enter() on this
18212 // initialization variable.
18213 // <value_location>: location of a static initializable variable containing 0.
18214 // <initialization_value>: new non-0 value for *@value_location.
18215 static void once_init_leave(size_t* value_location, size_t initialization_value) {
18216 g_once_init_leave(value_location, initialization_value);
18219 static Quark option_error_quark() {
18220 return g_option_error_quark();
18224 // Parses a string containing debugging options
18225 // into a %guint containing bit flags. This is used
18226 // within GDK and GTK+ to parse the debug options passed on the
18227 // command line or through environment variables.
18229 // If @string is equal to "all", all flags are set. If @string
18230 // is equal to "help", all the available keys in @keys are printed
18231 // out to standard error.
18232 // RETURNS: the combined set of bit flags.
18233 // <string>: a list of debug options separated by colons, spaces, or commas, or %NULL.
18234 // <keys>: pointer to an array of #GDebugKey which associate strings with bit flags.
18235 // <nkeys>: the number of #GDebugKey<!-- -->s in the array.
18236 static uint parse_debug_string(char* string_, DebugKey* keys, uint nkeys) {
18237 return g_parse_debug_string(string_, keys, nkeys);
18241 // Gets the last component of the filename. If @file_name ends with a
18242 // directory separator it gets the component before the last slash. If
18243 // @file_name consists only of directory separators (and on Windows,
18244 // possibly a drive letter), a single separator is returned. If
18245 // @file_name is empty, it gets ".".
18247 // the filename.
18248 // RETURNS: a newly allocated string containing the last component of
18249 // <file_name>: the name of the file.
18250 static char* /*new*/ path_get_basename(char* file_name) {
18251 return g_path_get_basename(file_name);
18255 // Gets the directory components of a file name. If the file name has no
18256 // directory components "." is returned. The returned string should be
18257 // freed when no longer needed.
18258 // RETURNS: the directory components of the file.
18259 // <file_name>: the name of the file.
18260 static char* /*new*/ path_get_dirname(char* file_name) {
18261 return g_path_get_dirname(file_name);
18265 // Returns %TRUE if the given @file_name is an absolute file name.
18266 // Note that this is a somewhat vague concept on Windows.
18268 // On POSIX systems, an absolute file name is well-defined. It always
18269 // starts from the single root directory. For example "/usr/local".
18271 // On Windows, the concepts of current drive and drive-specific
18272 // current directory introduce vagueness. This function interprets as
18273 // an absolute file name one that either begins with a directory
18274 // separator such as "\Users\tml" or begins with the root on a drive,
18275 // for example "C:\Windows". The first case also includes UNC paths
18276 // such as "\\myserver\docs\foo". In all cases, either slashes or
18277 // backslashes are accepted.
18279 // Note that a file name relative to the current drive root does not
18280 // truly specify a file uniquely over time and across processes, as
18281 // the current drive is a per-process value and can be changed.
18283 // File names relative the current directory on some specific drive,
18284 // such as "D:foo/bar", are not interpreted as absolute by this
18285 // function, but they obviously are not relative to the normal current
18286 // directory as returned by getcwd() or g_get_current_dir()
18287 // either. Such paths should be avoided, or need to be handled using
18288 // Windows-specific code.
18289 // RETURNS: %TRUE if @file_name is absolute.
18290 // <file_name>: a file name.
18291 static int path_is_absolute(char* file_name) {
18292 return g_path_is_absolute(file_name);
18296 // Returns a pointer into @file_name after the root component, i.e. after
18297 // the "/" in UNIX or "C:\" under Windows. If @file_name is not an absolute
18298 // path it returns %NULL.
18299 // RETURNS: a pointer into @file_name after the root component.
18300 // <file_name>: a file name.
18301 static char* path_skip_root(char* file_name) {
18302 return g_path_skip_root(file_name);
18306 // Matches a string against a compiled pattern. Passing the correct
18307 // length of the string given is mandatory. The reversed string can be
18308 // omitted by passing %NULL, this is more efficient if the reversed
18309 // version of the string to be matched is not at hand, as
18310 // g_pattern_match() will only construct it if the compiled pattern
18311 // requires reverse matches.
18313 // Note that, if the user code will (possibly) match a string against a
18314 // multitude of patterns containing wildcards, chances are high that
18315 // some patterns will require a reversed string. In this case, it's
18316 // more efficient to provide the reversed string to avoid multiple
18317 // constructions thereof in the various calls to g_pattern_match().
18319 // Note also that the reverse of a UTF-8 encoded string can in general
18320 // <emphasis>not</emphasis> be obtained by g_strreverse(). This works
18321 // only if the string doesn't contain any multibyte characters. GLib
18322 // offers the g_utf8_strreverse() function to reverse UTF-8 encoded
18323 // strings.
18324 // <pspec>: a #GPatternSpec
18325 // <string_length>: the length of @string (in bytes, i.e. strlen(), <emphasis>not</emphasis> g_utf8_strlen())
18326 // <string>: the UTF-8 encoded string to match
18327 // <string_reversed>: the reverse of @string or %NULL
18328 static int pattern_match(PatternSpec* pspec, uint string_length, char* string_, char* string_reversed) {
18329 return g_pattern_match(pspec, string_length, string_, string_reversed);
18333 // Matches a string against a pattern given as a string. If this
18334 // function is to be called in a loop, it's more efficient to compile
18335 // the pattern once with g_pattern_spec_new() and call
18336 // g_pattern_match_string() repeatedly.
18337 // <pattern>: the UTF-8 encoded pattern
18338 // <string>: the UTF-8 encoded string to match
18339 static int pattern_match_simple(char* pattern, char* string_) {
18340 return g_pattern_match_simple(pattern, string_);
18344 // Matches a string against a compiled pattern. If the string is to be
18345 // matched against more than one pattern, consider using
18346 // g_pattern_match() instead while supplying the reversed string.
18347 // <pspec>: a #GPatternSpec
18348 // <string>: the UTF-8 encoded string to match
18349 static int pattern_match_string(PatternSpec* pspec, char* string_) {
18350 return g_pattern_match_string(pspec, string_);
18354 // This is equivalent to g_bit_lock, but working on pointers (or other
18355 // pointer-sized values).
18357 // For portability reasons, you may only lock on the bottom 32 bits of
18358 // the pointer.
18359 // <address>: a pointer to a #gpointer-sized value
18360 // <lock_bit>: a bit value between 0 and 31
18361 static void pointer_bit_lock(void* address, int lock_bit) {
18362 g_pointer_bit_lock(address, lock_bit);
18366 // This is equivalent to g_bit_trylock, but working on pointers (or
18367 // other pointer-sized values).
18369 // For portability reasons, you may only lock on the bottom 32 bits of
18370 // the pointer.
18371 // RETURNS: %TRUE if the lock was acquired
18372 // <address>: a pointer to a #gpointer-sized value
18373 // <lock_bit>: a bit value between 0 and 31
18374 static int pointer_bit_trylock(void* address, int lock_bit) {
18375 return g_pointer_bit_trylock(address, lock_bit);
18379 // This is equivalent to g_bit_unlock, but working on pointers (or other
18380 // pointer-sized values).
18382 // For portability reasons, you may only lock on the bottom 32 bits of
18383 // the pointer.
18384 // <address>: a pointer to a #gpointer-sized value
18385 // <lock_bit>: a bit value between 0 and 31
18386 static void pointer_bit_unlock(void* address, int lock_bit) {
18387 g_pointer_bit_unlock(address, lock_bit);
18391 // Polls @fds, as with the poll() system call, but portably. (On
18392 // systems that don't have poll(), it is emulated using select().)
18393 // This is used internally by #GMainContext, but it can be called
18394 // directly if you need to block until a file descriptor is ready, but
18395 // don't want to run the full main loop.
18397 // Each element of @fds is a #GPollFD describing a single file
18398 // descriptor to poll. The %fd field indicates the file descriptor,
18399 // and the %events field indicates the events to poll for. On return,
18400 // the %revents fields will be filled with the events that actually
18401 // occurred.
18403 // On POSIX systems, the file descriptors in @fds can be any sort of
18404 // file descriptor, but the situation is much more complicated on
18405 // Windows. If you need to use g_poll() in code that has to run on
18406 // Windows, the easiest solution is to construct all of your
18407 // #GPollFD<!-- -->s with g_io_channel_win32_make_pollfd().
18409 // were filled in, or 0 if the operation timed out, or -1 on error or
18410 // if the call was interrupted.
18411 // RETURNS: the number of entries in @fds whose %revents fields
18412 // <fds>: file descriptors to poll
18413 // <nfds>: the number of file descriptors in @fds
18414 // <timeout>: amount of time to wait, in milliseconds, or -1 to wait forever
18415 static int poll(PollFD* fds, uint nfds, int timeout) {
18416 return g_poll(fds, nfds, timeout);
18420 // Unintrospectable function: prefix_error() / g_prefix_error()
18421 // Formats a string according to @format and
18422 // prefix it to an existing error message. If
18423 // nothing.
18425 // If *@err is %NULL (ie: an error variable is
18426 // present but there is no error condition) then
18427 // also do nothing. Whether or not it makes
18428 // sense to take advantage of this feature is up
18429 // to you.
18430 // <err>: a return location for a #GError, or %NULL
18431 // <format>: printf()-style format string
18432 alias g_prefix_error prefix_error; // Variadic
18435 // Unintrospectable function: print() / g_print()
18436 // Outputs a formatted message via the print handler.
18437 // The default print handler simply outputs the message to stdout.
18439 // g_print() should not be used from within libraries for debugging
18440 // messages, since it may be redirected by applications to special
18441 // purpose message windows or even files. Instead, libraries should
18442 // use g_log(), or the convenience functions g_message(), g_warning()
18443 // and g_error().
18444 // <format>: the message format. See the printf() documentation
18445 alias g_print print; // Variadic
18448 // Unintrospectable function: printerr() / g_printerr()
18449 // Outputs a formatted message via the error message handler.
18450 // The default handler simply outputs the message to stderr.
18452 // g_printerr() should not be used from within libraries.
18453 // Instead g_log() should be used, or the convenience functions
18454 // g_message(), g_warning() and g_error().
18455 // <format>: the message format. See the printf() documentation
18456 alias g_printerr printerr; // Variadic
18459 // Unintrospectable function: printf() / g_printf()
18460 // An implementation of the standard printf() function which supports
18461 // positional parameters, as specified in the Single Unix Specification.
18462 // RETURNS: the number of bytes printed.
18463 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
18464 alias g_printf printf; // Variadic
18466 // Unintrospectable function: printf_string_upper_bound() / g_printf_string_upper_bound()
18467 static size_t printf_string_upper_bound(char* format, va_list args) {
18468 return g_printf_string_upper_bound(format, args);
18472 // If @dest is %NULL, free @src; otherwise, moves @src into *@dest.
18473 // The error variable @dest points to must be %NULL.
18474 // <dest>: error return location
18475 // <src>: error to move into the return location
18476 static void propagate_error(Error** dest, Error* src) {
18477 g_propagate_error(dest, src);
18481 // Unintrospectable function: propagate_prefixed_error() / g_propagate_prefixed_error()
18482 // If @dest is %NULL, free @src; otherwise,
18483 // moves @src into *@dest. *@dest must be %NULL.
18484 // After the move, add a prefix as with
18485 // g_prefix_error().
18486 // <dest>: error return location
18487 // <src>: error to move into the return location
18488 // <format>: printf()-style format string
18489 alias g_propagate_prefixed_error propagate_prefixed_error; // Variadic
18492 // Adds a pointer to the end of the pointer array. The array will grow
18493 // in size automatically if necessary.
18494 // <array>: a #GPtrArray.
18495 // <data>: the pointer to add.
18496 static void ptr_array_add(PtrArray* array, void* data) {
18497 g_ptr_array_add(array, data);
18501 // Removes the first occurrence of the given pointer from the pointer
18502 // array. The following elements are moved down one place. If @array
18503 // has a non-%NULL #GDestroyNotify function it is called for the
18504 // removed element.
18506 // It returns %TRUE if the pointer was removed, or %FALSE if the
18507 // pointer was not found.
18508 // <array>: a #GPtrArray.
18509 // <data>: the pointer to remove.
18510 static int ptr_array_remove(PtrArray* array, void* data) {
18511 return g_ptr_array_remove(array, data);
18515 // Removes the first occurrence of the given pointer from the pointer
18516 // array. The last element in the array is used to fill in the space,
18517 // so this function does not preserve the order of the array. But it is
18518 // faster than g_ptr_array_remove(). If @array has a non-%NULL
18519 // #GDestroyNotify function it is called for the removed element.
18521 // It returns %TRUE if the pointer was removed, or %FALSE if the
18522 // pointer was not found.
18523 // <array>: a #GPtrArray.
18524 // <data>: the pointer to remove.
18525 static int ptr_array_remove_fast(PtrArray* array, void* data) {
18526 return g_ptr_array_remove_fast(array, data);
18530 // Removes the given number of pointers starting at the given index
18531 // from a #GPtrArray. The following elements are moved to close the
18532 // gap. If @array has a non-%NULL #GDestroyNotify function it is called
18533 // for the removed elements.
18534 // <array>: a @GPtrArray.
18535 // <index_>: the index of the first pointer to remove.
18536 // <length>: the number of pointers to remove.
18537 static void ptr_array_remove_range(PtrArray* array, uint index_, uint length) {
18538 g_ptr_array_remove_range(array, index_, length);
18542 // Sets a function for freeing each element when @array is destroyed
18543 // either via g_ptr_array_unref(), when g_ptr_array_free() is called
18544 // with @free_segment set to %TRUE or when removing elements.
18545 // <array>: A #GPtrArray.
18546 // <element_free_func>: A function to free elements with destroy @array or %NULL.
18547 static void ptr_array_set_free_func(PtrArray* array, DestroyNotify element_free_func) {
18548 g_ptr_array_set_free_func(array, element_free_func);
18552 // Sets the size of the array. When making the array larger,
18553 // newly-added elements will be set to %NULL. When making it smaller,
18554 // if @array has a non-%NULL #GDestroyNotify function then it will be
18555 // called for the removed elements.
18556 // <array>: a #GPtrArray.
18557 // <length>: the new length of the pointer array.
18558 static void ptr_array_set_size(PtrArray* array, int length) {
18559 g_ptr_array_set_size(array, length);
18563 // Atomically decrements the reference count of @array by one. If the
18564 // reference count drops to 0, the effect is the same as calling
18565 // g_ptr_array_free() with @free_segment set to %TRUE. This function
18566 // is MT-safe and may be called from any thread.
18567 // <array>: A #GPtrArray.
18568 static void ptr_array_unref(PtrArray* array) {
18569 g_ptr_array_unref(array);
18573 // Unintrospectable function: qsort_with_data() / g_qsort_with_data()
18574 // This is just like the standard C qsort() function, but
18575 // the comparison routine accepts a user data argument.
18576 // <pbase>: start of array to sort
18577 // <total_elems>: elements in the array
18578 // <size>: size of each element
18579 // <compare_func>: function to compare elements
18580 // <user_data>: data to pass to @compare_func
18581 static void qsort_with_data(const(void)* pbase, int total_elems, size_t size, CompareDataFunc compare_func, void* user_data) {
18582 g_qsort_with_data(pbase, total_elems, size, compare_func, user_data);
18586 // Gets the #GQuark identifying the given (static) string. If the
18587 // string does not currently have an associated #GQuark, a new #GQuark
18588 // is created, linked to the given string.
18590 // Note that this function is identical to g_quark_from_string() except
18591 // that if a new #GQuark is created the string itself is used rather
18592 // than a copy. This saves memory, but can only be used if the string
18593 // will <emphasis>always</emphasis> exist. It can be used with
18594 // statically allocated strings in the main program, but not with
18595 // statically allocated memory in dynamically loaded modules, if you
18596 // expect to ever unload the module again (e.g. do not use this
18597 // function in GTK+ theme engines).
18598 // <string>: a string.
18599 static Quark quark_from_static_string(char* string_=null) {
18600 return g_quark_from_static_string(string_);
18604 // Gets the #GQuark identifying the given string. If the string does
18605 // not currently have an associated #GQuark, a new #GQuark is created,
18606 // using a copy of the string.
18607 // <string>: a string.
18608 static Quark quark_from_string(char* string_=null) {
18609 return g_quark_from_string(string_);
18613 // Gets the string associated with the given #GQuark.
18614 // <quark>: a #GQuark.
18615 static char* quark_to_string(Quark quark) {
18616 return g_quark_to_string(quark);
18620 // Gets the #GQuark associated with the given string, or 0 if string is
18621 // %NULL or it has no associated #GQuark.
18623 // If you want the GQuark to be created if it doesn't already exist,
18624 // use g_quark_from_string() or g_quark_from_static_string().
18625 // <string>: a string.
18626 static Quark quark_try_string(char* string_=null) {
18627 return g_quark_try_string(string_);
18631 // Returns a random #gdouble equally distributed over the range [0..1).
18632 // RETURNS: A random number.
18633 static double random_double() {
18634 return g_random_double();
18638 // Returns a random #gdouble equally distributed over the range [@begin..@end).
18639 // RETURNS: A random number.
18640 // <begin>: lower closed bound of the interval.
18641 // <end>: upper open bound of the interval.
18642 static double random_double_range(double begin, double end) {
18643 return g_random_double_range(begin, end);
18647 // Return a random #guint32 equally distributed over the range
18648 // [0..2^32-1].
18649 // RETURNS: A random number.
18650 static uint random_int() {
18651 return g_random_int();
18655 // Returns a random #gint32 equally distributed over the range
18656 // [@begin..@end-1].
18657 // RETURNS: A random number.
18658 // <begin>: lower closed bound of the interval.
18659 // <end>: upper open bound of the interval.
18660 static int random_int_range(int begin, int end) {
18661 return g_random_int_range(begin, end);
18665 // Sets the seed for the global random number generator, which is used
18666 // by the <function>g_random_*</function> functions, to @seed.
18667 // <seed>: a value to reinitialize the global random number generator.
18668 static void random_set_seed(uint seed) {
18669 g_random_set_seed(seed);
18673 // Unintrospectable function: realloc() / g_realloc()
18674 // Reallocates the memory pointed to by @mem, so that it now has space for
18675 // @n_bytes bytes of memory. It returns the new address of the memory, which may
18676 // have been moved. @mem may be %NULL, in which case it's considered to
18677 // have zero-length. @n_bytes may be 0, in which case %NULL will be returned
18678 // and @mem will be freed unless it is %NULL.
18679 // RETURNS: the new address of the allocated memory
18680 // <mem>: the memory to reallocate
18681 // <n_bytes>: new size of the memory in bytes
18682 static void* realloc(void* mem, size_t n_bytes) {
18683 return g_realloc(mem, n_bytes);
18687 // Unintrospectable function: realloc_n() / g_realloc_n()
18688 // This function is similar to g_realloc(), allocating (@n_blocks * @n_block_bytes) bytes,
18689 // but care is taken to detect possible overflow during multiplication.
18690 // RETURNS: the new address of the allocated memory
18691 // <mem>: the memory to reallocate
18692 // <n_blocks>: the number of blocks to allocate
18693 // <n_block_bytes>: the size of each block in bytes
18694 static void* realloc_n(void* mem, size_t n_blocks, size_t n_block_bytes) {
18695 return g_realloc_n(mem, n_blocks, n_block_bytes);
18699 // Checks whether @replacement is a valid replacement string
18700 // (see g_regex_replace()), i.e. that all escape sequences in
18701 // it are valid.
18703 // If @has_references is not %NULL then @replacement is checked
18704 // for pattern references. For instance, replacement text 'foo\n'
18705 // does not contain references and may be evaluated without information
18706 // about actual match, but '\0\1' (whole match followed by first
18707 // subpattern) requires valid #GMatchInfo object.
18708 // RETURNS: whether @replacement is a valid replacement string
18709 // <replacement>: the replacement string
18710 // <has_references>: location to store information about references in @replacement or %NULL
18711 static int regex_check_replacement(char* replacement, /*out*/ int* has_references, GLib2.Error** error=null) {
18712 return g_regex_check_replacement(replacement, has_references, error);
18715 static Quark regex_error_quark() {
18716 return g_regex_error_quark();
18720 // Escapes the nul characters in @string to "\x00". It can be used
18721 // to compile a regex with embedded nul characters.
18723 // For completeness, @length can be -1 for a nul-terminated string.
18724 // In this case the output string will be of course equal to @string.
18725 // RETURNS: a newly-allocated escaped string
18726 // <string>: the string to escape
18727 // <length>: the length of @string
18728 static char* /*new*/ regex_escape_nul(char* string_, int length) {
18729 return g_regex_escape_nul(string_, length);
18733 // Escapes the special characters used for regular expressions
18734 // in @string, for instance "a.b*c" becomes "a\.b\*c". This
18735 // function is useful to dynamically generate regular expressions.
18737 // @string can contain nul characters that are replaced with "\0",
18738 // in this case remember to specify the correct length of @string
18739 // in @length.
18740 // RETURNS: a newly-allocated escaped string
18741 // <string>: the string to escape
18742 // <length>: the length of @string, or -1 if @string is nul-terminated
18743 static char* /*new*/ regex_escape_string(char* string_, int length) {
18744 return g_regex_escape_string(string_, length);
18748 // Scans for a match in @string for @pattern.
18750 // This function is equivalent to g_regex_match() but it does not
18751 // require to compile the pattern with g_regex_new(), avoiding some
18752 // lines of code when you need just to do a match without extracting
18753 // substrings, capture counts, and so on.
18755 // If this function is to be called on the same @pattern more than
18756 // once, it's more efficient to compile the pattern once with
18757 // g_regex_new() and then use g_regex_match().
18758 // RETURNS: %TRUE if the string matched, %FALSE otherwise
18759 // <pattern>: the regular expression
18760 // <string>: the string to scan for matches
18761 // <compile_options>: compile options for the regular expression, or 0
18762 // <match_options>: match options, or 0
18763 static int regex_match_simple(char* pattern, char* string_, RegexCompileFlags compile_options, RegexMatchFlags match_options) {
18764 return g_regex_match_simple(pattern, string_, compile_options, match_options);
18768 // Resets the cache used for g_get_user_special_dir(), so
18769 // that the latest on-disk version is used. Call this only
18770 // if you just changed the data on disk yourself.
18772 // Due to threadsafety issues this may cause leaking of strings
18773 // that were previously returned from g_get_user_special_dir()
18774 // that can't be freed. We ensure to only leak the data for
18775 // the directories that actually changed value though.
18776 static void reload_user_special_dirs_cache() {
18777 g_reload_user_special_dirs_cache();
18780 static void return_if_fail_warning(char* log_domain, char* pretty_function, char* expression) {
18781 g_return_if_fail_warning(log_domain, pretty_function, expression);
18785 // A wrapper for the POSIX rmdir() function. The rmdir() function
18786 // deletes a directory from the filesystem.
18788 // See your C library manual for more details about how rmdir() works
18789 // on your system.
18791 // occurred
18792 // RETURNS: 0 if the directory was successfully removed, -1 if an error
18793 // <filename>: a pathname in the GLib file name encoding (UTF-8 on Windows)
18794 static int rmdir(char* filename) {
18795 return g_rmdir(filename);
18799 // Moves the item pointed to by @src to the position indicated by @dest.
18800 // After calling this function @dest will point to the position immediately
18801 // after @src. It is allowed for @src and @dest to point into different
18802 // sequences.
18803 // <src>: a #GSequenceIter pointing to the item to move
18804 // <dest>: a #GSequenceIter pointing to the position to which the item is moved.
18805 static void sequence_move(SequenceIter* src, SequenceIter* dest) {
18806 g_sequence_move(src, dest);
18810 // Inserts the (@begin, @end) range at the destination pointed to by ptr.
18811 // The @begin and @end iters must point into the same sequence. It is
18812 // allowed for @dest to point to a different sequence than the one pointed
18813 // into by @begin and @end.
18815 // If @dest is NULL, the range indicated by @begin and @end is
18816 // removed from the sequence. If @dest iter points to a place within
18817 // the (@begin, @end) range, the range does not move.
18818 // <dest>: a #GSequenceIter
18819 // <begin>: a #GSequenceIter
18820 // <end>: a #GSequenceIter
18821 static void sequence_move_range(SequenceIter* dest, SequenceIter* begin, SequenceIter* end) {
18822 g_sequence_move_range(dest, begin, end);
18826 // Removes the item pointed to by @iter. It is an error to pass the
18827 // end iterator to this function.
18829 // If the sequnce has a data destroy function associated with it, this
18830 // function is called on the data for the removed item.
18831 // <iter>: a #GSequenceIter
18832 static void sequence_remove(SequenceIter* iter) {
18833 g_sequence_remove(iter);
18837 // Removes all items in the (@begin, @end) range.
18839 // If the sequence has a data destroy function associated with it, this
18840 // function is called on the data for the removed items.
18841 // <begin>: a #GSequenceIter
18842 // <end>: a #GSequenceIter
18843 static void sequence_remove_range(SequenceIter* begin, SequenceIter* end) {
18844 g_sequence_remove_range(begin, end);
18848 // Changes the data for the item pointed to by @iter to be @data. If
18849 // the sequence has a data destroy function associated with it, that
18850 // function is called on the existing data that @iter pointed to.
18851 // <iter>: a #GSequenceIter
18852 // <data>: new data for the item
18853 static void sequence_set(SequenceIter* iter, void* data) {
18854 g_sequence_set(iter, data);
18858 // Swaps the items pointed to by @a and @b. It is allowed for @a and @b
18859 // to point into difference sequences.
18860 // <a>: a #GSequenceIter
18861 // <b>: a #GSequenceIter
18862 static void sequence_swap(SequenceIter* a, SequenceIter* b) {
18863 g_sequence_swap(a, b);
18867 // Sets a human-readable name for the application. This name should be
18868 // localized if possible, and is intended for display to the user.
18869 // Contrast with g_set_prgname(), which sets a non-localized name.
18870 // g_set_prgname() will be called automatically by gtk_init(),
18871 // but g_set_application_name() will not.
18873 // Note that for thread safety reasons, this function can only
18874 // be called once.
18876 // The application name will be used in contexts such as error messages,
18877 // or when displaying an application's name in the task list.
18878 // <application_name>: localized name of the application
18879 static void set_application_name(char* application_name) {
18880 g_set_application_name(application_name);
18884 // Unintrospectable function: set_error() / g_set_error()
18885 // Does nothing if @err is %NULL; if @err is non-%NULL, then *@err
18886 // must be %NULL. A new #GError is created and assigned to *@err.
18887 // <err>: a return location for a #GError, or %NULL
18888 // <domain>: error domain
18889 // <code>: error code
18890 // <format>: printf()-style format
18891 alias g_set_error set_error; // Variadic
18894 // Does nothing if @err is %NULL; if @err is non-%NULL, then *@err
18895 // must be %NULL. A new #GError is created and assigned to *@err.
18896 // Unlike g_set_error(), @message is not a printf()-style format string.
18897 // Use this function if @message contains text you don't have control over,
18898 // that could include printf() escape sequences.
18899 // <err>: a return location for a #GError, or %NULL
18900 // <domain>: error domain
18901 // <code>: error code
18902 // <message>: error message
18903 static void set_error_literal(Error** err, Quark domain, int code, char* message) {
18904 g_set_error_literal(err, domain, code, message);
18908 // Sets the name of the program. This name should <emphasis>not</emphasis>
18909 // be localized, contrast with g_set_application_name(). Note that for
18910 // thread-safety reasons this function can only be called once.
18911 // <prgname>: the name of the program.
18912 static void set_prgname(char* prgname) {
18913 g_set_prgname(prgname);
18917 // Unintrospectable function: set_print_handler() / g_set_print_handler()
18918 // Sets the print handler.
18920 // Any messages passed to g_print() will be output via
18921 // the new handler. The default handler simply outputs
18922 // the message to stdout. By providing your own handler
18923 // you can redirect the output, to a GTK+ widget or a
18924 // log file for example.
18925 // RETURNS: the old print handler
18926 // <func>: the new print handler
18927 static PrintFunc set_print_handler(PrintFunc func) {
18928 return g_set_print_handler(func);
18932 // Unintrospectable function: set_printerr_handler() / g_set_printerr_handler()
18933 // Sets the handler for printing error messages.
18935 // Any messages passed to g_printerr() will be output via
18936 // the new handler. The default handler simply outputs the
18937 // message to stderr. By providing your own handler you can
18938 // redirect the output, to a GTK+ widget or a log file for
18939 // example.
18940 // RETURNS: the old error message handler
18941 // <func>: the new error message handler
18942 static PrintFunc set_printerr_handler(PrintFunc func) {
18943 return g_set_printerr_handler(func);
18947 // Sets an environment variable. Both the variable's name and value
18948 // should be in the GLib file name encoding. On UNIX, this means that
18949 // they can be any sequence of bytes. On Windows, they should be in
18950 // UTF-8.
18952 // Note that on some systems, when variables are overwritten, the memory
18953 // used for the previous variables and its value isn't reclaimed.
18954 // RETURNS: %FALSE if the environment variable couldn't be set.
18955 // <variable>: the environment variable to set, must not contain '='.
18956 // <value>: the value for to set the variable to.
18957 // <overwrite>: whether to change the variable if it already exists.
18958 static int setenv(char* variable, char* value, int overwrite) {
18959 return g_setenv(variable, value, overwrite);
18962 static Quark shell_error_quark() {
18963 return g_shell_error_quark();
18967 // Parses a command line into an argument vector, in much the same way
18968 // the shell would, but without many of the expansions the shell would
18969 // perform (variable expansion, globs, operators, filename expansion,
18970 // etc. are not supported). The results are defined to be the same as
18971 // those you would get from a UNIX98 /bin/sh, as long as the input
18972 // contains none of the unsupported shell expansions. If the input
18973 // does contain such expansions, they are passed through
18974 // literally. Possible errors are those from the #G_SHELL_ERROR
18975 // domain. Free the returned vector with g_strfreev().
18976 // RETURNS: %TRUE on success, %FALSE if error set
18977 // <command_line>: command line to parse
18978 // <argcp>: return location for number of args
18979 // <argvp>: return location for array of args
18980 static int shell_parse_argv(char* command_line, /*out*/ int* argcp, /*out*/ char*** argvp, GLib2.Error** error=null) {
18981 return g_shell_parse_argv(command_line, argcp, argvp, error);
18985 // Quotes a string so that the shell (/bin/sh) will interpret the
18986 // quoted string to mean @unquoted_string. If you pass a filename to
18987 // the shell, for example, you should first quote it with this
18988 // function. The return value must be freed with g_free(). The
18989 // quoting style used is undefined (single or double quotes may be
18990 // used).
18991 // RETURNS: quoted string
18992 // <unquoted_string>: a literal string
18993 static char* /*new*/ shell_quote(char* unquoted_string) {
18994 return g_shell_quote(unquoted_string);
18998 // Unquotes a string as the shell (/bin/sh) would. Only handles
18999 // quotes; if a string contains file globs, arithmetic operators,
19000 // variables, backticks, redirections, or other special-to-the-shell
19001 // features, the result will be different from the result a real shell
19002 // would produce (the variables, backticks, etc. will be passed
19003 // through literally instead of being expanded). This function is
19004 // guaranteed to succeed if applied to the result of
19005 // g_shell_quote(). If it fails, it returns %NULL and sets the
19006 // error. The @quoted_string need not actually contain quoted or
19007 // escaped text; g_shell_unquote() simply goes through the string and
19008 // unquotes/unescapes anything that the shell would. Both single and
19009 // double quotes are handled, as are escapes including escaped
19010 // newlines. The return value must be freed with g_free(). Possible
19011 // errors are in the #G_SHELL_ERROR domain.
19013 // Shell quoting rules are a bit strange. Single quotes preserve the
19014 // literal string exactly. escape sequences are not allowed; not even
19015 // \' - if you want a ' in the quoted text, you have to do something
19016 // like 'foo'\''bar'. Double quotes allow $, `, ", \, and newline to
19017 // be escaped with backslash. Otherwise double quotes preserve things
19018 // literally.
19019 // RETURNS: an unquoted string
19020 // <quoted_string>: shell-quoted string
19021 static char* /*new*/ shell_unquote(char* quoted_string, GLib2.Error** error=null) {
19022 return g_shell_unquote(quoted_string, error);
19025 // Unintrospectable function: slice_alloc() / g_slice_alloc()
19026 static void* slice_alloc(size_t block_size) {
19027 return g_slice_alloc(block_size);
19030 // Unintrospectable function: slice_alloc0() / g_slice_alloc0()
19031 static void* slice_alloc0(size_t block_size) {
19032 return g_slice_alloc0(block_size);
19035 // Unintrospectable function: slice_copy() / g_slice_copy()
19036 static void* slice_copy(size_t block_size, const(void)* mem_block) {
19037 return g_slice_copy(block_size, mem_block);
19040 static void slice_free1(size_t block_size, void* mem_block) {
19041 g_slice_free1(block_size, mem_block);
19044 static void slice_free_chain_with_offset(size_t block_size, void* mem_chain, size_t next_offset) {
19045 g_slice_free_chain_with_offset(block_size, mem_chain, next_offset);
19048 static long slice_get_config(SliceConfig ckey) {
19049 return g_slice_get_config(ckey);
19052 static long* slice_get_config_state(SliceConfig ckey, long address, uint* n_values) {
19053 return g_slice_get_config_state(ckey, address, n_values);
19056 static void slice_set_config(SliceConfig ckey, long value) {
19057 g_slice_set_config(ckey, value);
19061 // Restores the previous #GAllocator, used when allocating #GSList
19062 // elements.
19064 // Note that this function is not available if GLib has been compiled
19065 // with <option>--disable-mem-pools</option>
19067 // to the <link linkend="glib-Memory-Slices">slice
19068 // allocator</link>
19069 static void slist_pop_allocator() {
19070 g_slist_pop_allocator();
19074 // Sets the allocator to use to allocate #GSList elements. Use
19075 // g_slist_pop_allocator() to restore the previous allocator.
19077 // Note that this function is not available if GLib has been compiled
19078 // with <option>--disable-mem-pools</option>
19080 // to the <link linkend="glib-Memory-Slices">slice
19081 // allocator</link>
19082 // <dummy>: the #GAllocator to use when allocating #GSList elements.
19083 static void slist_push_allocator(void* dummy) {
19084 g_slist_push_allocator(dummy);
19088 // Unintrospectable function: snprintf() / g_snprintf()
19089 // A safer form of the standard sprintf() function. The output is guaranteed
19090 // to not exceed @n characters (including the terminating nul character), so
19091 // it is easy to ensure that a buffer overflow cannot occur.
19093 // See also g_strdup_printf().
19095 // In versions of GLib prior to 1.2.3, this function may return -1 if the
19096 // output was truncated, and the truncated string may not be nul-terminated.
19097 // In versions prior to 1.3.12, this function returns the length of the output
19098 // string.
19100 // The return value of g_snprintf() conforms to the snprintf()
19101 // function as standardized in ISO C99. Note that this is different from
19102 // traditional snprintf(), which returns the length of the output string.
19104 // The format string may contain positional parameters, as specified in
19105 // the Single Unix Specification.
19107 // was large enough.
19108 // RETURNS: the number of bytes which would be produced if the buffer
19109 // <string>: the buffer to hold the output.
19110 // <n>: the maximum number of bytes to produce (including the terminating nul character).
19111 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
19112 alias g_snprintf snprintf; // Variadic
19115 // Removes the source with the given id from the default main context.
19116 // The id of
19117 // a #GSource is given by g_source_get_id(), or will be returned by the
19118 // functions g_source_attach(), g_idle_add(), g_idle_add_full(),
19119 // g_timeout_add(), g_timeout_add_full(), g_child_watch_add(),
19120 // g_child_watch_add_full(), g_io_add_watch(), and g_io_add_watch_full().
19122 // See also g_source_destroy(). You must use g_source_destroy() for sources
19123 // added to a non-default main context.
19124 // RETURNS: %TRUE if the source was found and removed.
19125 // <tag>: the ID of the source to remove.
19126 static int source_remove(uint tag) {
19127 return g_source_remove(tag);
19131 // Removes a source from the default main loop context given the
19132 // source functions and user data. If multiple sources exist with the
19133 // same source functions and user data, only one will be destroyed.
19134 // RETURNS: %TRUE if a source was found and removed.
19135 // <funcs>: The @source_funcs passed to g_source_new()
19136 // <user_data>: the user data for the callback
19137 static int source_remove_by_funcs_user_data(SourceFuncs* funcs, void* user_data) {
19138 return g_source_remove_by_funcs_user_data(funcs, user_data);
19142 // Removes a source from the default main loop context given the user
19143 // data for the callback. If multiple sources exist with the same user
19144 // data, only one will be destroyed.
19145 // RETURNS: %TRUE if a source was found and removed.
19146 // <user_data>: the user_data for the callback.
19147 static int source_remove_by_user_data(void* user_data) {
19148 return g_source_remove_by_user_data(user_data);
19152 // Sets the name of a source using its ID.
19154 // This is a convenience utility to set source names from the return
19155 // value of g_idle_add(), g_timeout_add(), etc.
19156 // <tag>: a #GSource ID
19157 // <name>: debug name for the source
19158 static void source_set_name_by_id(uint tag, char* name) {
19159 g_source_set_name_by_id(tag, name);
19163 // Gets the smallest prime number from a built-in array of primes which
19164 // is larger than @num. This is used within GLib to calculate the optimum
19165 // size of a #GHashTable.
19167 // The built-in array of primes ranges from 11 to 13845163 such that
19168 // each prime is approximately 1.5-2 times the previous prime.
19170 // which is larger than @num
19171 // RETURNS: the smallest prime number from a built-in array of primes
19172 // <num>: a #guint
19173 static uint spaced_primes_closest(uint num) {
19174 return g_spaced_primes_closest(num);
19178 // See g_spawn_async_with_pipes() for a full description; this function
19179 // simply calls the g_spawn_async_with_pipes() without any pipes.
19181 // You should call g_spawn_close_pid() on the returned child process
19182 // reference when you don't need it any more.
19184 // <note><para>
19185 // If you are writing a GTK+ application, and the program you
19186 // are spawning is a graphical application, too, then you may
19187 // want to use gdk_spawn_on_screen() instead to ensure that
19188 // the spawned program opens its windows on the right screen.
19189 // </para></note>
19191 // <note><para> Note that the returned @child_pid on Windows is a
19192 // handle to the child process and not its identifier. Process handles
19193 // and process identifiers are different concepts on Windows.
19194 // </para></note>
19195 // RETURNS: %TRUE on success, %FALSE if error is set
19196 // <working_directory>: child's current working directory, or %NULL to inherit parent's
19197 // <argv>: child's argument vector
19198 // <envp>: child's environment, or %NULL to inherit parent's
19199 // <flags>: flags from #GSpawnFlags
19200 // <child_setup>: function to run in the child just before exec()
19201 // <user_data>: user data for @child_setup
19202 // <child_pid>: return location for child process reference, or %NULL
19203 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) {
19204 return g_spawn_async(working_directory, argv, envp, flags, child_setup, user_data, child_pid, error);
19208 // Executes a child program asynchronously (your program will not
19209 // block waiting for the child to exit). The child program is
19210 // specified by the only argument that must be provided, @argv. @argv
19211 // should be a %NULL-terminated array of strings, to be passed as the
19212 // argument vector for the child. The first string in @argv is of
19213 // course the name of the program to execute. By default, the name of
19214 // the program must be a full path; the <envar>PATH</envar> shell variable
19215 // will only be searched if you pass the %G_SPAWN_SEARCH_PATH flag.
19217 // On Windows, note that all the string or string vector arguments to
19218 // this function and the other g_spawn*() functions are in UTF-8, the
19219 // GLib file name encoding. Unicode characters that are not part of
19220 // the system codepage passed in these arguments will be correctly
19221 // available in the spawned program only if it uses wide character API
19222 // to retrieve its command line. For C programs built with Microsoft's
19223 // tools it is enough to make the program have a wmain() instead of
19224 // main(). wmain() has a wide character argument vector as parameter.
19226 // At least currently, mingw doesn't support wmain(), so if you use
19227 // mingw to develop the spawned program, it will have to call the
19228 // undocumented function __wgetmainargs() to get the wide character
19229 // argument vector and environment. See gspawn-win32-helper.c in the
19230 // GLib sources or init.c in the mingw runtime sources for a prototype
19231 // for that function. Alternatively, you can retrieve the Win32 system
19232 // level wide character command line passed to the spawned program
19233 // using the GetCommandLineW() function.
19235 // On Windows the low-level child process creation API
19236 // <function>CreateProcess()</function> doesn't use argument vectors,
19237 // but a command line. The C runtime library's
19238 // <function>spawn*()</function> family of functions (which
19239 // g_spawn_async_with_pipes() eventually calls) paste the argument
19240 // vector elements together into a command line, and the C runtime startup code
19241 // does a corresponding reconstruction of an argument vector from the
19242 // command line, to be passed to main(). Complications arise when you have
19243 // argument vector elements that contain spaces of double quotes. The
19244 // <function>spawn*()</function> functions don't do any quoting or
19245 // escaping, but on the other hand the startup code does do unquoting
19246 // and unescaping in order to enable receiving arguments with embedded
19247 // spaces or double quotes. To work around this asymmetry,
19248 // g_spawn_async_with_pipes() will do quoting and escaping on argument
19249 // vector elements that need it before calling the C runtime
19250 // spawn() function.
19252 // The returned @child_pid on Windows is a handle to the child
19253 // process, not its identifier. Process handles and process
19254 // identifiers are different concepts on Windows.
19256 // @envp is a %NULL-terminated array of strings, where each string
19257 // has the form <literal>KEY=VALUE</literal>. This will become
19258 // the child's environment. If @envp is %NULL, the child inherits its
19259 // parent's environment.
19261 // @flags should be the bitwise OR of any flags you want to affect the
19262 // function's behaviour. The %G_SPAWN_DO_NOT_REAP_CHILD means that
19263 // the child will not automatically be reaped; you must use a
19264 // #GChildWatch source to be notified about the death of the child
19265 // process. Eventually you must call g_spawn_close_pid() on the
19266 // @child_pid, in order to free resources which may be associated
19267 // with the child process. (On Unix, using a #GChildWatch source is
19268 // equivalent to calling waitpid() or handling the %SIGCHLD signal
19269 // manually. On Windows, calling g_spawn_close_pid() is equivalent
19270 // to calling CloseHandle() on the process handle returned in
19271 // @child_pid).
19273 // %G_SPAWN_LEAVE_DESCRIPTORS_OPEN means that the parent's open file
19274 // descriptors will be inherited by the child; otherwise all
19275 // descriptors except stdin/stdout/stderr will be closed before
19276 // calling exec() in the child. %G_SPAWN_SEARCH_PATH
19277 // means that <literal>argv[0]</literal> need not be an absolute path, it
19278 // will be looked for in the user's <envar>PATH</envar>.
19279 // %G_SPAWN_STDOUT_TO_DEV_NULL means that the child's standard output will
19280 // be discarded, instead of going to the same location as the parent's
19281 // standard output. If you use this flag, @standard_output must be %NULL.
19282 // %G_SPAWN_STDERR_TO_DEV_NULL means that the child's standard error
19283 // will be discarded, instead of going to the same location as the parent's
19284 // standard error. If you use this flag, @standard_error must be %NULL.
19285 // %G_SPAWN_CHILD_INHERITS_STDIN means that the child will inherit the parent's
19286 // standard input (by default, the child's standard input is attached to
19287 // /dev/null). If you use this flag, @standard_input must be %NULL.
19288 // %G_SPAWN_FILE_AND_ARGV_ZERO means that the first element of @argv is
19289 // the file to execute, while the remaining elements are the
19290 // actual argument vector to pass to the file. Normally
19291 // g_spawn_async_with_pipes() uses @argv[0] as the file to execute, and
19292 // passes all of @argv to the child.
19294 // @child_setup and @user_data are a function and user data. On POSIX
19295 // platforms, the function is called in the child after GLib has
19296 // performed all the setup it plans to perform (including creating
19297 // pipes, closing file descriptors, etc.) but before calling
19298 // exec(). That is, @child_setup is called just
19299 // before calling exec() in the child. Obviously
19300 // actions taken in this function will only affect the child, not the
19301 // parent.
19303 // On Windows, there is no separate fork() and exec()
19304 // functionality. Child processes are created and run with a single
19305 // API call, CreateProcess(). There is no sensible thing @child_setup
19306 // could be used for on Windows so it is ignored and not called.
19308 // If non-%NULL, @child_pid will on Unix be filled with the child's
19309 // process ID. You can use the process ID to send signals to the
19310 // child, or to use g_child_watch_add() (or waitpid()) if you specified the
19311 // %G_SPAWN_DO_NOT_REAP_CHILD flag. On Windows, @child_pid will be
19312 // filled with a handle to the child process only if you specified the
19313 // %G_SPAWN_DO_NOT_REAP_CHILD flag. You can then access the child
19314 // process using the Win32 API, for example wait for its termination
19315 // with the <function>WaitFor*()</function> functions, or examine its
19316 // exit code with GetExitCodeProcess(). You should close the handle
19317 // with CloseHandle() or g_spawn_close_pid() when you no longer need it.
19319 // If non-%NULL, the @standard_input, @standard_output, @standard_error
19320 // locations will be filled with file descriptors for writing to the child's
19321 // standard input or reading from its standard output or standard error.
19322 // The caller of g_spawn_async_with_pipes() must close these file descriptors
19323 // when they are no longer in use. If these parameters are %NULL, the corresponding
19324 // pipe won't be created.
19326 // If @standard_input is NULL, the child's standard input is attached to
19327 // /dev/null unless %G_SPAWN_CHILD_INHERITS_STDIN is set.
19329 // If @standard_error is NULL, the child's standard error goes to the same
19330 // location as the parent's standard error unless %G_SPAWN_STDERR_TO_DEV_NULL
19331 // is set.
19333 // If @standard_output is NULL, the child's standard output goes to the same
19334 // location as the parent's standard output unless %G_SPAWN_STDOUT_TO_DEV_NULL
19335 // is set.
19337 // @error can be %NULL to ignore errors, or non-%NULL to report errors.
19338 // If an error is set, the function returns %FALSE. Errors
19339 // are reported even if they occur in the child (for example if the
19340 // executable in <literal>argv[0]</literal> is not found). Typically
19341 // the <literal>message</literal> field of returned errors should be displayed
19342 // to users. Possible errors are those from the #G_SPAWN_ERROR domain.
19344 // If an error occurs, @child_pid, @standard_input, @standard_output,
19345 // and @standard_error will not be filled with valid values.
19347 // If @child_pid is not %NULL and an error does not occur then the returned
19348 // process reference must be closed using g_spawn_close_pid().
19350 // <note><para>
19351 // If you are writing a GTK+ application, and the program you
19352 // are spawning is a graphical application, too, then you may
19353 // want to use gdk_spawn_on_screen_with_pipes() instead to ensure that
19354 // the spawned program opens its windows on the right screen.
19355 // </para></note>
19356 // RETURNS: %TRUE on success, %FALSE if an error was set
19357 // <working_directory>: child's current working directory, or %NULL to inherit parent's, in the GLib file name encoding
19358 // <argv>: child's argument vector, in the GLib file name encoding
19359 // <envp>: child's environment, or %NULL to inherit parent's, in the GLib file name encoding
19360 // <flags>: flags from #GSpawnFlags
19361 // <child_setup>: function to run in the child just before exec()
19362 // <user_data>: user data for @child_setup
19363 // <child_pid>: return location for child process ID, or %NULL
19364 // <standard_input>: return location for file descriptor to write to child's stdin, or %NULL
19365 // <standard_output>: return location for file descriptor to read child's stdout, or %NULL
19366 // <standard_error>: return location for file descriptor to read child's stderr, or %NULL
19367 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) {
19368 return g_spawn_async_with_pipes(working_directory, argv, envp, flags, child_setup, user_data, child_pid, standard_input, standard_output, standard_error, error);
19372 // On some platforms, notably Windows, the #GPid type represents a resource
19373 // which must be closed to prevent resource leaking. g_spawn_close_pid()
19374 // is provided for this purpose. It should be used on all platforms, even
19375 // though it doesn't do anything under UNIX.
19376 // <pid>: The process reference to close
19377 static void spawn_close_pid(Pid pid) {
19378 g_spawn_close_pid(pid);
19382 // A simple version of g_spawn_async() that parses a command line with
19383 // g_shell_parse_argv() and passes it to g_spawn_async(). Runs a
19384 // command line in the background. Unlike g_spawn_async(), the
19385 // %G_SPAWN_SEARCH_PATH flag is enabled, other flags are not. Note
19386 // that %G_SPAWN_SEARCH_PATH can have security implications, so
19387 // consider using g_spawn_async() directly if appropriate. Possible
19388 // errors are those from g_shell_parse_argv() and g_spawn_async().
19390 // The same concerns on Windows apply as for g_spawn_command_line_sync().
19391 // RETURNS: %TRUE on success, %FALSE if error is set.
19392 // <command_line>: a command line
19393 static int spawn_command_line_async(char* command_line, GLib2.Error** error=null) {
19394 return g_spawn_command_line_async(command_line, error);
19398 // A simple version of g_spawn_sync() with little-used parameters
19399 // removed, taking a command line instead of an argument vector. See
19400 // g_spawn_sync() for full details. @command_line will be parsed by
19401 // g_shell_parse_argv(). Unlike g_spawn_sync(), the %G_SPAWN_SEARCH_PATH flag
19402 // is enabled. Note that %G_SPAWN_SEARCH_PATH can have security
19403 // implications, so consider using g_spawn_sync() directly if
19404 // appropriate. Possible errors are those from g_spawn_sync() and those
19405 // from g_shell_parse_argv().
19407 // If @exit_status is non-%NULL, the exit status of the child is stored there as
19408 // it would be returned by waitpid(); standard UNIX macros such as WIFEXITED()
19409 // and WEXITSTATUS() must be used to evaluate the exit status.
19411 // On Windows, please note the implications of g_shell_parse_argv()
19412 // parsing @command_line. Parsing is done according to Unix shell rules, not
19413 // Windows command interpreter rules.
19414 // Space is a separator, and backslashes are
19415 // special. Thus you cannot simply pass a @command_line containing
19416 // canonical Windows paths, like "c:\\program files\\app\\app.exe", as
19417 // the backslashes will be eaten, and the space will act as a
19418 // separator. You need to enclose such paths with single quotes, like
19419 // "'c:\\program files\\app\\app.exe' 'e:\\folder\\argument.txt'".
19420 // RETURNS: %TRUE on success, %FALSE if an error was set
19421 // <command_line>: a command line
19422 // <standard_output>: return location for child output
19423 // <standard_error>: return location for child errors
19424 // <exit_status>: return location for child exit status, as returned by waitpid()
19425 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) {
19426 return g_spawn_command_line_sync(command_line, standard_output, standard_error, exit_status, error);
19429 static Quark spawn_error_quark() {
19430 return g_spawn_error_quark();
19434 // Executes a child synchronously (waits for the child to exit before returning).
19435 // All output from the child is stored in @standard_output and @standard_error,
19436 // if those parameters are non-%NULL. Note that you must set the
19437 // %G_SPAWN_STDOUT_TO_DEV_NULL and %G_SPAWN_STDERR_TO_DEV_NULL flags when
19438 // passing %NULL for @standard_output and @standard_error.
19439 // If @exit_status is non-%NULL, the exit status of the child is stored
19440 // there as it would be returned by waitpid(); standard UNIX macros such
19441 // as WIFEXITED() and WEXITSTATUS() must be used to evaluate the exit status.
19442 // Note that this function call waitpid() even if @exit_status is %NULL, and
19443 // does not accept the %G_SPAWN_DO_NOT_REAP_CHILD flag.
19444 // If an error occurs, no data is returned in @standard_output,
19445 // @standard_error, or @exit_status.
19447 // This function calls g_spawn_async_with_pipes() internally; see that
19448 // function for full details on the other parameters and details on
19449 // how these functions work on Windows.
19450 // RETURNS: %TRUE on success, %FALSE if an error was set.
19451 // <working_directory>: child's current working directory, or %NULL to inherit parent's
19452 // <argv>: child's argument vector
19453 // <envp>: child's environment, or %NULL to inherit parent's
19454 // <flags>: flags from #GSpawnFlags
19455 // <child_setup>: function to run in the child just before exec()
19456 // <user_data>: user data for @child_setup
19457 // <standard_output>: return location for child output, or %NULL
19458 // <standard_error>: return location for child error messages, or %NULL
19459 // <exit_status>: return location for child exit status, as returned by waitpid(), or %NULL
19460 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) {
19461 return g_spawn_sync(working_directory, argv, envp, flags, child_setup, user_data, standard_output, standard_error, exit_status, error);
19465 // Unintrospectable function: sprintf() / g_sprintf()
19466 // An implementation of the standard sprintf() function which supports
19467 // positional parameters, as specified in the Single Unix Specification.
19469 // Note that it is usually better to use g_snprintf(), to avoid the
19470 // risk of buffer overflow.
19472 // See also g_strdup_printf().
19473 // RETURNS: the number of bytes printed.
19474 // <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
19475 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
19476 alias g_sprintf sprintf; // Variadic
19479 // Copies a nul-terminated string into the dest buffer, include the
19480 // trailing nul, and return a pointer to the trailing nul byte.
19481 // This is useful for concatenating multiple strings together
19482 // without having to repeatedly scan for the end.
19483 // RETURNS: a pointer to trailing nul byte.
19484 // <dest>: destination buffer.
19485 // <src>: source string.
19486 static char* /*new*/ stpcpy(char* dest, char* src) {
19487 return g_stpcpy(dest, src);
19491 // Compares two strings for byte-by-byte equality and returns %TRUE
19492 // if they are equal. It can be passed to g_hash_table_new() as the
19493 // @key_equal_func parameter, when using strings as keys in a #GHashTable.
19495 // Note that this function is primarily meant as a hash table comparison
19496 // function. For a general-purpose, %NULL-safe string comparison function,
19497 // see g_strcmp0().
19498 // RETURNS: %TRUE if the two keys match
19499 // <v1>: a key
19500 // <v2>: a key to compare with @v1
19501 static int str_equal(const(void)* v1, const(void)* v2) {
19502 return g_str_equal(v1, v2);
19506 // Looks whether the string @str begins with @prefix.
19507 // RETURNS: %TRUE if @str begins with @prefix, %FALSE otherwise.
19508 // <str>: a nul-terminated string.
19509 // <prefix>: the nul-terminated prefix to look for.
19510 static int str_has_prefix(char* str, char* prefix) {
19511 return g_str_has_prefix(str, prefix);
19515 // Looks whether the string @str ends with @suffix.
19516 // RETURNS: %TRUE if @str end with @suffix, %FALSE otherwise.
19517 // <str>: a nul-terminated string.
19518 // <suffix>: the nul-terminated suffix to look for.
19519 static int str_has_suffix(char* str, char* suffix) {
19520 return g_str_has_suffix(str, suffix);
19524 // Converts a string to a hash value.
19526 // This function implements the widely used "djb" hash apparently posted
19527 // by Daniel Bernstein to comp.lang.c some time ago. The 32 bit
19528 // unsigned hash value starts at 5381 and for each byte 'c' in the
19529 // string, is updated: <literal>hash = hash * 33 + c</literal>. This
19530 // function uses the signed value of each byte.
19532 // It can be passed to g_hash_table_new() as the @hash_func parameter,
19533 // when using strings as keys in a #GHashTable.
19534 // RETURNS: a hash value corresponding to the key
19535 // <v>: a string key
19536 static uint str_hash(const(void)* v) {
19537 return g_str_hash(v);
19540 static char* /*new*/ strcanon(char* string_, char* valid_chars, char substitutor) {
19541 return g_strcanon(string_, valid_chars, substitutor);
19545 // A case-insensitive string comparison, corresponding to the standard
19546 // strcasecmp() function on platforms which support it.
19548 // or a positive value if @s1 &gt; @s2.
19550 // Deprecated:2.2: See g_strncasecmp() for a discussion of why this function
19551 // is deprecated and how to replace it.
19552 // RETURNS: 0 if the strings match, a negative value if @s1 &lt; @s2,
19553 // <s1>: a string.
19554 // <s2>: a string to compare with @s1.
19555 static int strcasecmp(char* s1, char* s2) {
19556 return g_strcasecmp(s1, s2);
19559 static char* /*new*/ strchomp(char* string_) {
19560 return g_strchomp(string_);
19563 static char* /*new*/ strchug(char* string_) {
19564 return g_strchug(string_);
19568 // Compares @str1 and @str2 like strcmp(). Handles %NULL
19569 // gracefully by sorting it before non-%NULL strings.
19570 // Comparing two %NULL pointers returns 0.
19571 // RETURNS: -1, 0 or 1, if @str1 is <, == or > than @str2.
19572 // <str1>: a C string or %NULL
19573 // <str2>: another C string or %NULL
19574 static int strcmp0(char* str1, char* str2) {
19575 return g_strcmp0(str1, str2);
19578 static char* /*new*/ strcompress(char* source) {
19579 return g_strcompress(source);
19583 // Unintrospectable function: strconcat() / g_strconcat()
19584 // Concatenates all of the given strings into one long string.
19585 // The returned string should be freed with g_free() when no longer needed.
19587 // Note that this function is usually not the right function to use to
19588 // assemble a translated message from pieces, since proper translation
19589 // often requires the pieces to be reordered.
19591 // <warning><para>The variable argument list <emphasis>must</emphasis> end
19592 // with %NULL. If you forget the %NULL, g_strconcat() will start appending
19593 // random memory junk to your string.</para></warning>
19594 // RETURNS: a newly-allocated string containing all the string arguments
19595 // <string1>: the first string to add, which must not be %NULL
19596 alias g_strconcat strconcat; // Variadic
19598 static char* /*new*/ strdelimit(char* string_, char* delimiters, char new_delimiter) {
19599 return g_strdelimit(string_, delimiters, new_delimiter);
19603 // Converts a string to lower case.
19606 // Deprecated:2.2: This function is totally broken for the reasons discussed
19607 // in the g_strncasecmp() docs - use g_ascii_strdown() or g_utf8_strdown()
19608 // instead.
19609 // RETURNS: the string
19610 // <string>: the string to convert.
19611 static char* /*new*/ strdown(char* string_) {
19612 return g_strdown(string_);
19616 // Duplicates a string. If @str is %NULL it returns %NULL.
19617 // The returned string should be freed with g_free()
19618 // when no longer needed.
19619 // RETURNS: a newly-allocated copy of @str
19620 // <str>: the string to duplicate
19621 static char* /*new*/ strdup(char* str) {
19622 return g_strdup(str);
19626 // Unintrospectable function: strdup_printf() / g_strdup_printf()
19627 // Similar to the standard C sprintf() function but safer, since it
19628 // calculates the maximum space required and allocates memory to hold
19629 // the result. The returned string should be freed with g_free() when no
19630 // longer needed.
19631 // RETURNS: a newly-allocated string holding the result
19632 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>
19633 alias g_strdup_printf strdup_printf; // Variadic
19636 // Unintrospectable function: strdup_vprintf() / g_strdup_vprintf()
19637 // Similar to the standard C vsprintf() function but safer, since it
19638 // calculates the maximum space required and allocates memory to hold
19639 // the result. The returned string should be freed with g_free() when
19640 // no longer needed.
19642 // See also g_vasprintf(), which offers the same functionality, but
19643 // additionally returns the length of the allocated string.
19644 // RETURNS: a newly-allocated string holding the result
19645 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>
19646 // <args>: the list of parameters to insert into the format string
19647 static char* /*new*/ strdup_vprintf(char* format, va_list args) {
19648 return g_strdup_vprintf(format, args);
19652 // Unintrospectable function: strdupv() / g_strdupv()
19653 // Copies %NULL-terminated array of strings. The copy is a deep copy;
19654 // the new array should be freed by first freeing each string, then
19655 // the array itself. g_strfreev() does this for you. If called
19656 // on a %NULL value, g_strdupv() simply returns %NULL.
19657 // RETURNS: a new %NULL-terminated array of strings.
19658 // <str_array>: %NULL-terminated array of strings.
19659 static char** strdupv(char** str_array) {
19660 return g_strdupv(str_array);
19664 // Returns a string corresponding to the given error code, e.g.
19665 // "no such process". You should use this function in preference to
19666 // strerror(), because it returns a string in UTF-8 encoding, and since
19667 // not all platforms support the strerror() function.
19669 // is unknown, it returns "unknown error (&lt;code&gt;)". The string
19670 // can only be used until the next call to g_strerror()
19671 // RETURNS: a UTF-8 string describing the error code. If the error code
19672 // <errnum>: the system error number. See the standard C %errno documentation
19673 static char* strerror(int errnum) {
19674 return g_strerror(errnum);
19677 static char* /*new*/ strescape(char* source, char* exceptions) {
19678 return g_strescape(source, exceptions);
19681 // <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.
19682 static void strfreev(char** str_array) {
19683 g_strfreev(str_array);
19687 // Creates a new #GString, initialized with the given string.
19688 // RETURNS: the new #GString
19689 // <init>: the initial text to copy into the string
19690 static String* /*new*/ string_new(char* init) {
19691 return g_string_new(init);
19695 // Creates a new #GString with @len bytes of the @init buffer.
19696 // Because a length is provided, @init need not be nul-terminated,
19697 // and can contain embedded nul bytes.
19699 // Since this function does not stop at nul bytes, it is the caller's
19700 // responsibility to ensure that @init has at least @len addressable
19701 // bytes.
19702 // RETURNS: a new #GString
19703 // <init>: initial contents of the string
19704 // <len>: length of @init to use
19705 static String* /*new*/ string_new_len(char* init, ssize_t len) {
19706 return g_string_new_len(init, len);
19710 // Creates a new #GString, with enough space for @dfl_size
19711 // bytes. This is useful if you are going to add a lot of
19712 // text to the string and don't want it to be reallocated
19713 // too often.
19714 // RETURNS: the new #GString
19715 // <dfl_size>: the default size of the space allocated to hold the string
19716 static String* /*new*/ string_sized_new(size_t dfl_size) {
19717 return g_string_sized_new(dfl_size);
19721 // An auxiliary function for gettext() support (see Q_()).
19723 // a '|' character, in which case a pointer to the substring of msgid after
19724 // the first '|' character is returned.
19725 // RETURNS: @msgval, unless @msgval is identical to @msgid and contains
19726 // <msgid>: a string
19727 // <msgval>: another string
19728 static char* strip_context(char* msgid, char* msgval) {
19729 return g_strip_context(msgid, msgval);
19733 // Unintrospectable function: strjoin() / g_strjoin()
19734 // Joins a number of strings together to form one long string, with the
19735 // optional @separator inserted between each of them. The returned string
19736 // should be freed with g_free().
19738 // together, with @separator between them
19739 // RETURNS: a newly-allocated string containing all of the strings joined
19740 // <separator>: a string to insert between each of the strings, or %NULL
19741 alias g_strjoin strjoin; // Variadic
19744 // Joins a number of strings together to form one long string, with the
19745 // optional @separator inserted between each of them. The returned string
19746 // should be freed with g_free().
19748 // together, with @separator between them
19749 // RETURNS: a newly-allocated string containing all of the strings joined
19750 // <separator>: a string to insert between each of the strings, or %NULL
19751 // <str_array>: a %NULL-terminated array of strings to join
19752 static char* /*new*/ strjoinv(char* separator, char** str_array) {
19753 return g_strjoinv(separator, str_array);
19757 // Portability wrapper that calls strlcat() on systems which have it,
19758 // and emulates it otherwise. Appends nul-terminated @src string to @dest,
19759 // guaranteeing nul-termination for @dest. The total size of @dest won't
19760 // exceed @dest_size.
19762 // At most dest_size - 1 characters will be copied.
19763 // Unlike strncat, dest_size is the full size of dest, not the space left over.
19764 // This function does NOT allocate memory.
19765 // This always NUL terminates (unless siz == 0 or there were no NUL characters
19766 // in the dest_size characters of dest to start with).
19768 // <note><para>Caveat: this is supposedly a more secure alternative to
19769 // strcat() or strncat(), but for real security g_strconcat() is harder
19770 // to mess up.</para></note>
19772 // (original dest)) + strlen (src), so if retval >= dest_size,
19773 // truncation occurred.
19774 // RETURNS: size of attempted result, which is MIN (dest_size, strlen
19775 // <dest>: destination buffer, already containing one nul-terminated string
19776 // <src>: source buffer
19777 // <dest_size>: length of @dest buffer in bytes (not length of existing string inside @dest)
19778 static size_t strlcat(char* dest, char* src, size_t dest_size) {
19779 return g_strlcat(dest, src, dest_size);
19783 // Portability wrapper that calls strlcpy() on systems which have it,
19784 // and emulates strlcpy() otherwise. Copies @src to @dest; @dest is
19785 // guaranteed to be nul-terminated; @src must be nul-terminated;
19786 // @dest_size is the buffer size, not the number of chars to copy.
19788 // At most dest_size - 1 characters will be copied. Always nul-terminates
19789 // (unless dest_size == 0). This function does <emphasis>not</emphasis>
19790 // allocate memory. Unlike strncpy(), this function doesn't pad dest (so
19791 // it's often faster). It returns the size of the attempted result,
19792 // strlen (src), so if @retval >= @dest_size, truncation occurred.
19794 // <note><para>Caveat: strlcpy() is supposedly more secure than
19795 // strcpy() or strncpy(), but if you really want to avoid screwups,
19796 // g_strdup() is an even better idea.</para></note>
19797 // RETURNS: length of @src
19798 // <dest>: destination buffer
19799 // <src>: source buffer
19800 // <dest_size>: length of @dest in bytes
19801 static size_t strlcpy(char* dest, char* src, size_t dest_size) {
19802 return g_strlcpy(dest, src, dest_size);
19806 // A case-insensitive string comparison, corresponding to the standard
19807 // strncasecmp() function on platforms which support it.
19808 // It is similar to g_strcasecmp() except it only compares the first @n
19809 // characters of the strings.
19811 // or a positive value if @s1 &gt; @s2.
19813 // Deprecated:2.2: The problem with g_strncasecmp() is that it does the
19814 // comparison by calling toupper()/tolower(). These functions are
19815 // locale-specific and operate on single bytes. However, it is impossible
19816 // to handle things correctly from an I18N standpoint by operating on
19817 // bytes, since characters may be multibyte. Thus g_strncasecmp() is
19818 // broken if your string is guaranteed to be ASCII, since it's
19819 // locale-sensitive, and it's broken if your string is localized, since
19820 // it doesn't work on many encodings at all, including UTF-8, EUC-JP,
19821 // etc.
19823 // There are therefore two replacement functions: g_ascii_strncasecmp(),
19824 // which only works on ASCII and is not locale-sensitive, and
19825 // g_utf8_casefold(), which is good for case-insensitive sorting of UTF-8.
19826 // RETURNS: 0 if the strings match, a negative value if @s1 &lt; @s2,
19827 // <s1>: a string.
19828 // <s2>: a string to compare with @s1.
19829 // <n>: the maximum number of characters to compare.
19830 static int strncasecmp(char* s1, char* s2, uint n) {
19831 return g_strncasecmp(s1, s2, n);
19835 // Duplicates the first @n bytes of a string, returning a newly-allocated
19836 // buffer @n + 1 bytes long which will always be nul-terminated.
19837 // If @str is less than @n bytes long the buffer is padded with nuls.
19838 // If @str is %NULL it returns %NULL.
19839 // The returned value should be freed when no longer needed.
19841 // <note><para>
19842 // To copy a number of characters from a UTF-8 encoded string, use
19843 // g_utf8_strncpy() instead.
19844 // </para></note>
19846 // of @str, nul-terminated
19847 // RETURNS: a newly-allocated buffer containing the first @n bytes
19848 // <str>: the string to duplicate
19849 // <n>: the maximum number of bytes to copy from @str
19850 static char* /*new*/ strndup(char* str, size_t n) {
19851 return g_strndup(str, n);
19855 // Creates a new string @length bytes long filled with @fill_char.
19856 // The returned string should be freed when no longer needed.
19857 // RETURNS: a newly-allocated string filled the @fill_char
19858 // <length>: the length of the new string
19859 // <fill_char>: the byte to fill the string with
19860 static char* /*new*/ strnfill(size_t length, char fill_char) {
19861 return g_strnfill(length, fill_char);
19865 // Reverses all of the bytes in a string. For example,
19866 // <literal>g_strreverse ("abcdef")</literal> will result
19867 // in "fedcba".
19869 // Note that g_strreverse() doesn't work on UTF-8 strings
19870 // containing multibyte characters. For that purpose, use
19871 // g_utf8_strreverse().
19872 // RETURNS: the same pointer passed in as @string
19873 // <string>: the string to reverse
19874 static char* /*new*/ strreverse(char* string_) {
19875 return g_strreverse(string_);
19879 // Searches the string @haystack for the last occurrence
19880 // of the string @needle.
19882 // %NULL if not found.
19883 // RETURNS: a pointer to the found occurrence, or
19884 // <haystack>: a nul-terminated string.
19885 // <needle>: the nul-terminated string to search for.
19886 static char* /*new*/ strrstr(char* haystack, char* needle) {
19887 return g_strrstr(haystack, needle);
19891 // Searches the string @haystack for the last occurrence
19892 // of the string @needle, limiting the length of the search
19893 // to @haystack_len.
19895 // %NULL if not found.
19896 // RETURNS: a pointer to the found occurrence, or
19897 // <haystack>: a nul-terminated string.
19898 // <haystack_len>: the maximum length of @haystack.
19899 // <needle>: the nul-terminated string to search for.
19900 static char* /*new*/ strrstr_len(char* haystack, ssize_t haystack_len, char* needle) {
19901 return g_strrstr_len(haystack, haystack_len, needle);
19905 // Returns a string describing the given signal, e.g. "Segmentation fault".
19906 // You should use this function in preference to strsignal(), because it
19907 // returns a string in UTF-8 encoding, and since not all platforms support
19908 // the strsignal() function.
19910 // it returns "unknown signal (&lt;signum&gt;)". The string can only be
19911 // used until the next call to g_strsignal()
19912 // RETURNS: a UTF-8 string describing the signal. If the signal is unknown,
19913 // <signum>: the signal number. See the <literal>signal</literal> documentation
19914 static char* strsignal(int signum) {
19915 return g_strsignal(signum);
19919 // Unintrospectable function: strsplit() / g_strsplit()
19920 // Splits a string into a maximum of @max_tokens pieces, using the given
19921 // @delimiter. If @max_tokens is reached, the remainder of @string is appended
19922 // to the last token.
19924 // As a special case, the result of splitting the empty string "" is an empty
19925 // vector, not a vector containing a single string. The reason for this
19926 // special case is that being able to represent a empty vector is typically
19927 // more useful than consistent handling of empty elements. If you do need
19928 // to represent empty elements, you'll need to check for the empty string
19929 // before calling g_strsplit().
19931 // g_strfreev() to free it.
19932 // RETURNS: a newly-allocated %NULL-terminated array of strings. Use
19933 // <string>: a string to split.
19934 // <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.
19935 // <max_tokens>: the maximum number of pieces to split @string into. If this is less than 1, the string is split completely.
19936 static char** strsplit(char* string_, char* delimiter, int max_tokens) {
19937 return g_strsplit(string_, delimiter, max_tokens);
19941 // Unintrospectable function: strsplit_set() / g_strsplit_set()
19942 // Splits @string into a number of tokens not containing any of the characters
19943 // in @delimiter. A token is the (possibly empty) longest string that does not
19944 // contain any of the characters in @delimiters. If @max_tokens is reached, the
19945 // remainder is appended to the last token.
19947 // For example the result of g_strsplit_set ("abc:def/ghi", ":/", -1) is a
19948 // %NULL-terminated vector containing the three strings "abc", "def",
19949 // and "ghi".
19951 // The result if g_strsplit_set (":def/ghi:", ":/", -1) is a %NULL-terminated
19952 // vector containing the four strings "", "def", "ghi", and "".
19954 // As a special case, the result of splitting the empty string "" is an empty
19955 // vector, not a vector containing a single string. The reason for this
19956 // special case is that being able to represent a empty vector is typically
19957 // more useful than consistent handling of empty elements. If you do need
19958 // to represent empty elements, you'll need to check for the empty string
19959 // before calling g_strsplit_set().
19961 // Note that this function works on bytes not characters, so it can't be used
19962 // to delimit UTF-8 strings for anything but ASCII characters.
19964 // g_strfreev() to free it.
19965 // RETURNS: a newly-allocated %NULL-terminated array of strings. Use
19966 // <string>: The string to be tokenized
19967 // <delimiters>: A nul-terminated string containing bytes that are used to split the string.
19968 // <max_tokens>: The maximum number of tokens to split @string into. If this is less than 1, the string is split completely
19969 static char** strsplit_set(char* string_, char* delimiters, int max_tokens) {
19970 return g_strsplit_set(string_, delimiters, max_tokens);
19974 // Searches the string @haystack for the first occurrence
19975 // of the string @needle, limiting the length of the search
19976 // to @haystack_len.
19978 // %NULL if not found.
19979 // RETURNS: a pointer to the found occurrence, or
19980 // <haystack>: a string.
19981 // <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.
19982 // <needle>: the string to search for.
19983 static char* /*new*/ strstr_len(char* haystack, ssize_t haystack_len, char* needle) {
19984 return g_strstr_len(haystack, haystack_len, needle);
19988 // Converts a string to a #gdouble value.
19989 // It calls the standard strtod() function to handle the conversion, but
19990 // if the string is not completely converted it attempts the conversion
19991 // again with g_ascii_strtod(), and returns the best match.
19993 // This function should seldom be used. The normal situation when reading
19994 // numbers not for human consumption is to use g_ascii_strtod(). Only when
19995 // you know that you must expect both locale formatted and C formatted numbers
19996 // should you use this. Make sure that you don't pass strings such as comma
19997 // separated lists of values, since the commas may be interpreted as a decimal
19998 // point in some locales, causing unexpected results.
19999 // RETURNS: the #gdouble value.
20000 // <nptr>: the string to convert to a numeric value.
20001 // <endptr>: if non-%NULL, it returns the character after the last character used in the conversion.
20002 static double strtod(char* nptr, char** endptr) {
20003 return g_strtod(nptr, endptr);
20007 // Converts a string to upper case.
20010 // Deprecated:2.2: This function is totally broken for the reasons discussed
20011 // in the g_strncasecmp() docs - use g_ascii_strup() or g_utf8_strup() instead.
20012 // RETURNS: the string
20013 // <string>: the string to convert.
20014 static char* /*new*/ strup(char* string_) {
20015 return g_strup(string_);
20018 static Type strv_get_type() {
20019 return g_strv_get_type();
20023 // Returns the length of the given %NULL-terminated
20024 // string array @str_array.
20025 // RETURNS: length of @str_array.
20026 // <str_array>: a %NULL-terminated array of strings.
20027 static uint strv_length(char** str_array) {
20028 return g_strv_length(str_array);
20032 // Unintrospectable function: test_add_data_func() / g_test_add_data_func()
20033 // Create a new test case, similar to g_test_create_case(). However
20034 // the test is assumed to use no fixture, and test suites are automatically
20035 // created on the fly and added to the root fixture, based on the
20036 // slash-separated portions of @testpath. The @test_data argument
20037 // will be passed as first argument to @test_func.
20038 // <testpath>: Slash-separated test case path name for the test.
20039 // <test_data>: Test data argument for the test function.
20040 // <test_func>: The test function to invoke for this test.
20041 static void test_add_data_func(char* testpath, const(void)* test_data, TestDataFunc test_func) {
20042 g_test_add_data_func(testpath, test_data, test_func);
20046 // Unintrospectable function: test_add_func() / g_test_add_func()
20047 // Create a new test case, similar to g_test_create_case(). However
20048 // the test is assumed to use no fixture, and test suites are automatically
20049 // created on the fly and added to the root fixture, based on the
20050 // slash-separated portions of @testpath.
20051 // <testpath>: Slash-separated test case path name for the test.
20052 // <test_func>: The test function to invoke for this test.
20053 static void test_add_func(char* testpath, TestFunc test_func) {
20054 g_test_add_func(testpath, test_func);
20057 // Unintrospectable function: test_add_vtable() / g_test_add_vtable()
20058 static void test_add_vtable(char* testpath, size_t data_size, const(void)* test_data, TestFixtureFunc data_setup, TestFixtureFunc data_test, TestFixtureFunc data_teardown) {
20059 g_test_add_vtable(testpath, data_size, test_data, data_setup, data_test, data_teardown);
20063 // This function adds a message to test reports that
20064 // associates a bug URI with a test case.
20065 // Bug URIs are constructed from a base URI set with g_test_bug_base()
20066 // and @bug_uri_snippet.
20067 // <bug_uri_snippet>: Bug specific bug tracker URI portion.
20068 static void test_bug(char* bug_uri_snippet) {
20069 g_test_bug(bug_uri_snippet);
20073 // Specify the base URI for bug reports.
20075 // The base URI is used to construct bug report messages for
20076 // g_test_message() when g_test_bug() is called.
20077 // Calling this function outside of a test case sets the
20078 // default base URI for all test cases. Calling it from within
20079 // a test case changes the base URI for the scope of the test
20080 // case only.
20081 // Bug URIs are constructed by appending a bug specific URI
20082 // portion to @uri_pattern, or by replacing the special string
20083 // '%s' within @uri_pattern if that is present.
20084 // <uri_pattern>: the base pattern for bug URIs
20085 static void test_bug_base(char* uri_pattern) {
20086 g_test_bug_base(uri_pattern);
20090 // Unintrospectable function: test_create_case() / g_test_create_case()
20091 // Create a new #GTestCase, named @test_name, this API is fairly
20092 // low level, calling g_test_add() or g_test_add_func() is preferable.
20093 // When this test is executed, a fixture structure of size @data_size
20094 // will be allocated and filled with 0s. Then data_setup() is called
20095 // to initialize the fixture. After fixture setup, the actual test
20096 // function data_test() is called. Once the test run completed, the
20097 // fixture structure is torn down by calling data_teardown() and
20098 // after that the memory is released.
20100 // Splitting up a test run into fixture setup, test function and
20101 // fixture teardown is most usful if the same fixture is used for
20102 // multiple tests. In this cases, g_test_create_case() will be
20103 // called with the same fixture, but varying @test_name and
20104 // @data_test arguments.
20105 // RETURNS: a newly allocated #GTestCase.
20106 // <test_name>: the name for the test case
20107 // <data_size>: the size of the fixture data structure
20108 // <test_data>: test data argument for the test functions
20109 // <data_setup>: the function to set up the fixture data
20110 // <data_test>: the actual test function
20111 // <data_teardown>: the function to teardown the fixture data
20112 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) {
20113 return g_test_create_case(test_name, data_size, test_data, data_setup, data_test, data_teardown);
20117 // Unintrospectable function: test_create_suite() / g_test_create_suite()
20118 // Create a new test suite with the name @suite_name.
20119 // RETURNS: A newly allocated #GTestSuite instance.
20120 // <suite_name>: a name for the suite
20121 static TestSuite* test_create_suite(char* suite_name) {
20122 return g_test_create_suite(suite_name);
20126 // Indicates that a test failed. This function can be called
20127 // multiple times from the same test. You can use this function
20128 // if your test failed in a recoverable way.
20130 // Do not use this function if the failure of a test could cause
20131 // other tests to malfunction.
20133 // Calling this function will not stop the test from running, you
20134 // need to return from the test function yourself. So you can
20135 // produce additional diagnostic messages or even continue running
20136 // the test.
20138 // If not called from inside a test, this function does nothing.
20139 static void test_fail() {
20140 g_test_fail();
20144 // Unintrospectable function: test_get_root() / g_test_get_root()
20145 // Get the toplevel test suite for the test path API.
20146 // RETURNS: the toplevel #GTestSuite
20147 static TestSuite* test_get_root() {
20148 return g_test_get_root();
20152 // Unintrospectable function: test_init() / g_test_init()
20153 // Initialize the GLib testing framework, e.g. by seeding the
20154 // test random number generator, the name for g_get_prgname()
20155 // and parsing test related command line args.
20156 // So far, the following arguments are understood:
20157 // <variablelist>
20158 // <varlistentry>
20159 // <term><option>-l</option></term>
20160 // <listitem><para>
20161 // list test cases available in a test executable.
20162 // </para></listitem>
20163 // </varlistentry>
20164 // <varlistentry>
20165 // <term><option>--seed=<replaceable>RANDOMSEED</replaceable></option></term>
20166 // <listitem><para>
20167 // provide a random seed to reproduce test runs using random numbers.
20168 // </para></listitem>
20169 // </varlistentry>
20170 // <varlistentry>
20171 // <term><option>--verbose</option></term>
20172 // <listitem><para>run tests verbosely.</para></listitem>
20173 // </varlistentry>
20174 // <varlistentry>
20175 // <term><option>-q</option>, <option>--quiet</option></term>
20176 // <listitem><para>run tests quietly.</para></listitem>
20177 // </varlistentry>
20178 // <varlistentry>
20179 // <term><option>-p <replaceable>TESTPATH</replaceable></option></term>
20180 // <listitem><para>
20181 // execute all tests matching <replaceable>TESTPATH</replaceable>.
20182 // </para></listitem>
20183 // </varlistentry>
20184 // <varlistentry>
20185 // <term><option>-m {perf|slow|thorough|quick}</option></term>
20186 // <listitem><para>
20187 // execute tests according to these test modes:
20188 // <variablelist>
20189 // <varlistentry>
20190 // <term>perf</term>
20191 // <listitem><para>
20192 // performance tests, may take long and report results.
20193 // </para></listitem>
20194 // </varlistentry>
20195 // <varlistentry>
20196 // <term>slow, thorough</term>
20197 // <listitem><para>
20198 // slow and thorough tests, may take quite long and
20199 // maximize coverage.
20200 // </para></listitem>
20201 // </varlistentry>
20202 // <varlistentry>
20203 // <term>quick</term>
20204 // <listitem><para>
20205 // quick tests, should run really quickly and give good coverage.
20206 // </para></listitem>
20207 // </varlistentry>
20208 // </variablelist>
20209 // </para></listitem>
20210 // </varlistentry>
20211 // <varlistentry>
20212 // <term><option>--debug-log</option></term>
20213 // <listitem><para>debug test logging output.</para></listitem>
20214 // </varlistentry>
20215 // <varlistentry>
20216 // <term><option>-k</option>, <option>--keep-going</option></term>
20217 // <listitem><para>gtester-specific argument.</para></listitem>
20218 // </varlistentry>
20219 // <varlistentry>
20220 // <term><option>--GTestLogFD <replaceable>N</replaceable></option></term>
20221 // <listitem><para>gtester-specific argument.</para></listitem>
20222 // </varlistentry>
20223 // <varlistentry>
20224 // <term><option>--GTestSkipCount <replaceable>N</replaceable></option></term>
20225 // <listitem><para>gtester-specific argument.</para></listitem>
20226 // </varlistentry>
20227 // </variablelist>
20228 // <argc>: Address of the @argc parameter of the main() function. Changed if any arguments were handled.
20229 // <argv>: Address of the @argv parameter of main(). Any parameters understood by g_test_init() stripped before return.
20230 alias g_test_init test_init; // Variadic
20233 // Unintrospectable function: test_log_set_fatal_handler() / g_test_log_set_fatal_handler()
20234 // Installs a non-error fatal log handler which can be
20235 // used to decide whether log messages which are counted
20236 // as fatal abort the program.
20238 // The use case here is that you are running a test case
20239 // that depends on particular libraries or circumstances
20240 // and cannot prevent certain known critical or warning
20241 // messages. So you install a handler that compares the
20242 // domain and message to precisely not abort in such a case.
20244 // Note that the handler is reset at the beginning of
20245 // any test case, so you have to set it inside each test
20246 // function which needs the special behavior.
20248 // This handler has no effect on g_error messages.
20249 // <log_func>: the log handler function.
20250 // <user_data>: data passed to the log handler.
20251 static void test_log_set_fatal_handler(TestLogFatalFunc log_func, void* user_data) {
20252 g_test_log_set_fatal_handler(log_func, user_data);
20255 static char* test_log_type_name(TestLogType log_type) {
20256 return g_test_log_type_name(log_type);
20260 // Unintrospectable function: test_maximized_result() / g_test_maximized_result()
20261 // Report the result of a performance or measurement test.
20262 // The test should generally strive to maximize the reported
20263 // quantities (larger values are better than smaller ones),
20264 // this and @maximized_quantity can determine sorting
20265 // order for test result reports.
20266 // <maximized_quantity>: the reported value
20267 // <format>: the format string of the report message
20268 alias g_test_maximized_result test_maximized_result; // Variadic
20271 // Unintrospectable function: test_message() / g_test_message()
20272 // Add a message to the test report.
20273 // <format>: the format string
20274 alias g_test_message test_message; // Variadic
20277 // Unintrospectable function: test_minimized_result() / g_test_minimized_result()
20278 // Report the result of a performance or measurement test.
20279 // The test should generally strive to minimize the reported
20280 // quantities (smaller values are better than larger ones),
20281 // this and @minimized_quantity can determine sorting
20282 // order for test result reports.
20283 // <minimized_quantity>: the reported value
20284 // <format>: the format string of the report message
20285 alias g_test_minimized_result test_minimized_result; // Variadic
20288 // This function enqueus a callback @destroy_func() to be executed
20289 // during the next test case teardown phase. This is most useful
20290 // to auto destruct allocted test resources at the end of a test run.
20291 // Resources are released in reverse queue order, that means enqueueing
20292 // callback A before callback B will cause B() to be called before
20293 // A() during teardown.
20294 // <destroy_func>: Destroy callback for teardown phase.
20295 // <destroy_data>: Destroy callback data.
20296 static void test_queue_destroy(DestroyNotify destroy_func, void* destroy_data) {
20297 g_test_queue_destroy(destroy_func, destroy_data);
20301 // Enqueue a pointer to be released with g_free() during the next
20302 // teardown phase. This is equivalent to calling g_test_queue_destroy()
20303 // with a destroy callback of g_free().
20304 // <gfree_pointer>: the pointer to be stored.
20305 static void test_queue_free(void* gfree_pointer) {
20306 g_test_queue_free(gfree_pointer);
20310 // Get a reproducible random floating point number,
20311 // see g_test_rand_int() for details on test case random numbers.
20312 // RETURNS: a random number from the seeded random number generator.
20313 static double test_rand_double() {
20314 return g_test_rand_double();
20318 // Get a reproducible random floating pointer number out of a specified range,
20319 // see g_test_rand_int() for details on test case random numbers.
20320 // RETURNS: a number with @range_start <= number < @range_end.
20321 // <range_start>: the minimum value returned by this function
20322 // <range_end>: the minimum value not returned by this function
20323 static double test_rand_double_range(double range_start, double range_end) {
20324 return g_test_rand_double_range(range_start, range_end);
20328 // Get a reproducible random integer number.
20330 // The random numbers generated by the g_test_rand_*() family of functions
20331 // change with every new test program start, unless the --seed option is
20332 // given when starting test programs.
20334 // For individual test cases however, the random number generator is
20335 // reseeded, to avoid dependencies between tests and to make --seed
20336 // effective for all test cases.
20337 // RETURNS: a random number from the seeded random number generator.
20338 static int test_rand_int() {
20339 return g_test_rand_int();
20343 // Get a reproducible random integer number out of a specified range,
20344 // see g_test_rand_int() for details on test case random numbers.
20345 // RETURNS: a number with @begin <= number < @end.
20346 // <begin>: the minimum value returned by this function
20347 // <end>: the smallest value not to be returned by this function
20348 static int test_rand_int_range(int begin, int end) {
20349 return g_test_rand_int_range(begin, end);
20353 // Runs all tests under the toplevel suite which can be retrieved
20354 // with g_test_get_root(). Similar to g_test_run_suite(), the test
20355 // cases to be run are filtered according to
20356 // test path arguments (-p <replaceable>testpath</replaceable>) as
20357 // parsed by g_test_init().
20358 // g_test_run_suite() or g_test_run() may only be called once
20359 // in a program.
20360 // RETURNS: 0 on success
20361 static int test_run() {
20362 return g_test_run();
20366 // Execute the tests within @suite and all nested #GTestSuites.
20367 // The test suites to be executed are filtered according to
20368 // test path arguments (-p <replaceable>testpath</replaceable>)
20369 // as parsed by g_test_init().
20370 // g_test_run_suite() or g_test_run() may only be called once
20371 // in a program.
20372 // RETURNS: 0 on success
20373 // <suite>: a #GTestSuite
20374 static int test_run_suite(TestSuite* suite) {
20375 return g_test_run_suite(suite);
20379 // Get the time since the last start of the timer with g_test_timer_start().
20380 // RETURNS: the time since the last start of the timer, as a double
20381 static double test_timer_elapsed() {
20382 return g_test_timer_elapsed();
20386 // Report the last result of g_test_timer_elapsed().
20387 // RETURNS: the last result of g_test_timer_elapsed(), as a double
20388 static double test_timer_last() {
20389 return g_test_timer_last();
20393 // Start a timing test. Call g_test_timer_elapsed() when the task is supposed
20394 // to be done. Call this function again to restart the timer.
20395 static void test_timer_start() {
20396 g_test_timer_start();
20399 static void test_trap_assertions(char* domain, char* file, int line, char* func, ulong assertion_flags, char* pattern) {
20400 g_test_trap_assertions(domain, file, line, func, assertion_flags, pattern);
20404 // Fork the current test program to execute a test case that might
20405 // not return or that might abort. The forked test case is aborted
20406 // and considered failing if its run time exceeds @usec_timeout.
20408 // The forking behavior can be configured with the #GTestTrapFlags flags.
20410 // In the following example, the test code forks, the forked child
20411 // process produces some sample output and exits successfully.
20412 // The forking parent process then asserts successful child program
20413 // termination and validates child program outputs.
20415 // |[
20416 // static void
20417 // test_fork_patterns (void)
20418 // {
20419 // if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
20420 // {
20421 // g_print ("some stdout text: somagic17\n");
20422 // g_printerr ("some stderr text: semagic43\n");
20423 // exit (0); /&ast; successful test run &ast;/
20424 // }
20425 // g_test_trap_assert_passed();
20426 // g_test_trap_assert_stdout ("*somagic17*");
20427 // g_test_trap_assert_stderr ("*semagic43*");
20428 // }
20429 // ]|
20431 // This function is implemented only on Unix platforms.
20432 // RETURNS: %TRUE for the forked child and %FALSE for the executing parent process.
20433 // <usec_timeout>: Timeout for the forked test in micro seconds.
20434 // <test_trap_flags>: Flags to modify forking behaviour.
20435 static int test_trap_fork(ulong usec_timeout, TestTrapFlags test_trap_flags) {
20436 return g_test_trap_fork(usec_timeout, test_trap_flags);
20440 // Check the result of the last g_test_trap_fork() call.
20441 // RETURNS: %TRUE if the last forked child terminated successfully.
20442 static int test_trap_has_passed() {
20443 return g_test_trap_has_passed();
20447 // Check the result of the last g_test_trap_fork() call.
20448 // RETURNS: %TRUE if the last forked child got killed due to a fork timeout.
20449 static int test_trap_reached_timeout() {
20450 return g_test_trap_reached_timeout();
20453 static Quark thread_error_quark() {
20454 return g_thread_error_quark();
20458 // Exits the current thread. If another thread is waiting for that
20459 // thread using g_thread_join() and the current thread is joinable, the
20460 // waiting thread will be woken up and get @retval as the return value
20461 // of g_thread_join(). If the current thread is not joinable, @retval
20462 // is ignored. Calling
20464 // <informalexample>
20465 // <programlisting>
20466 // g_thread_exit (retval);
20467 // </programlisting>
20468 // </informalexample>
20470 // is equivalent to returning @retval from the function @func, as given
20471 // to g_thread_create().
20473 // <note><para>Never call g_thread_exit() from within a thread of a
20474 // #GThreadPool, as that will mess up the bookkeeping and lead to funny
20475 // and unwanted results.</para></note>
20476 // <retval>: the return value of this thread.
20477 static void thread_exit(void* retval) {
20478 g_thread_exit(retval);
20482 // Indicates if g_thread_init() has been called.
20483 // RETURNS: %TRUE if threads have been initialized.
20484 static int thread_get_initialized() {
20485 return g_thread_get_initialized();
20489 // If you use GLib from more than one thread, you must initialize the
20490 // thread system by calling g_thread_init(). Most of the time you will
20491 // only have to call <literal>g_thread_init (NULL)</literal>.
20493 // <note><para>Do not call g_thread_init() with a non-%NULL parameter unless
20494 // you really know what you are doing.</para></note>
20496 // <note><para>g_thread_init() must not be called directly or indirectly as a
20497 // callback from GLib. Also no mutexes may be currently locked while
20498 // calling g_thread_init().</para></note>
20500 // <note><para>g_thread_init() changes the way in which #GTimer measures
20501 // elapsed time. As a consequence, timers that are running while
20502 // g_thread_init() is called may report unreliable times.</para></note>
20504 // Calling g_thread_init() multiple times is allowed (since version
20505 // 2.24), but nothing happens except for the first call. If the
20506 // argument is non-%NULL on such a call a warning will be printed, but
20507 // otherwise the argument is ignored.
20509 // If no thread system is available and @vtable is %NULL or if not all
20510 // elements of @vtable are non-%NULL, then g_thread_init() will abort.
20512 // <note><para>To use g_thread_init() in your program, you have to link with
20513 // the libraries that the command <command>pkg-config --libs
20514 // gthread-2.0</command> outputs. This is not the case for all the
20515 // other thread related functions of GLib. Those can be used without
20516 // having to link with the thread libraries.</para></note>
20517 // <vtable>: a function table of type #GThreadFunctions, that provides the entry points to the thread system to be used.
20518 static void thread_init(ThreadFunctions* vtable) {
20519 g_thread_init(vtable);
20522 static void thread_init_with_errorcheck_mutexes(ThreadFunctions* vtable) {
20523 g_thread_init_with_errorcheck_mutexes(vtable);
20527 // This function will return the maximum @interval that a thread will
20528 // wait in the thread pool for new tasks before being stopped.
20530 // If this function returns 0, threads waiting in the thread pool for
20531 // new work are not stopped.
20533 // thread pool before stopping the thread (1/1000ths of a second).
20534 // RETURNS: the maximum @interval to wait for new tasks in the
20535 static uint thread_pool_get_max_idle_time() {
20536 return g_thread_pool_get_max_idle_time();
20540 // Returns the maximal allowed number of unused threads.
20541 // RETURNS: the maximal number of unused threads
20542 static int thread_pool_get_max_unused_threads() {
20543 return g_thread_pool_get_max_unused_threads();
20547 // Returns the number of currently unused threads.
20548 // RETURNS: the number of currently unused threads
20549 static uint thread_pool_get_num_unused_threads() {
20550 return g_thread_pool_get_num_unused_threads();
20554 // This function will set the maximum @interval that a thread waiting
20555 // in the pool for new tasks can be idle for before being
20556 // stopped. This function is similar to calling
20557 // g_thread_pool_stop_unused_threads() on a regular timeout, except,
20558 // this is done on a per thread basis.
20560 // By setting @interval to 0, idle threads will not be stopped.
20562 // This function makes use of g_async_queue_timed_pop () using
20563 // @interval.
20564 // <interval>: the maximum @interval (1/1000ths of a second) a thread can be idle.
20565 static void thread_pool_set_max_idle_time(uint interval) {
20566 g_thread_pool_set_max_idle_time(interval);
20570 // Sets the maximal number of unused threads to @max_threads. If
20571 // @max_threads is -1, no limit is imposed on the number of unused
20572 // threads.
20573 // <max_threads>: maximal number of unused threads
20574 static void thread_pool_set_max_unused_threads(int max_threads) {
20575 g_thread_pool_set_max_unused_threads(max_threads);
20579 // Stops all currently unused threads. This does not change the
20580 // maximal number of unused threads. This function can be used to
20581 // regularly stop all unused threads e.g. from g_timeout_add().
20582 static void thread_pool_stop_unused_threads() {
20583 g_thread_pool_stop_unused_threads();
20587 // Converts a string containing an ISO 8601 encoded date and time
20588 // to a #GTimeVal and puts it into @time_.
20589 // RETURNS: %TRUE if the conversion was successful.
20590 // <iso_date>: an ISO 8601 encoded date string
20591 // <time_>: a #GTimeVal
20592 static int time_val_from_iso8601(char* iso_date, TimeVal* time_) {
20593 return g_time_val_from_iso8601(iso_date, time_);
20597 // Unintrospectable function: timeout_add() / g_timeout_add()
20598 // Sets a function to be called at regular intervals, with the default
20599 // priority, #G_PRIORITY_DEFAULT. The function is called repeatedly
20600 // until it returns %FALSE, at which point the timeout is automatically
20601 // destroyed and the function will not be called again. The first call
20602 // to the function will be at the end of the first @interval.
20604 // Note that timeout functions may be delayed, due to the processing of other
20605 // event sources. Thus they should not be relied on for precise timing.
20606 // After each call to the timeout function, the time of the next
20607 // timeout is recalculated based on the current time and the given interval
20608 // (it does not try to 'catch up' time lost in delays).
20610 // If you want to have a timer in the "seconds" range and do not care
20611 // about the exact time of the first call of the timer, use the
20612 // g_timeout_add_seconds() function; this function allows for more
20613 // optimizations and more efficient system power usage.
20615 // This internally creates a main loop source using g_timeout_source_new()
20616 // and attaches it to the main loop context using g_source_attach(). You can
20617 // do these steps manually if you need greater control.
20619 // The interval given is in terms of monotonic time, not wall clock
20620 // time. See g_get_monotonic_time().
20621 // RETURNS: the ID (greater than 0) of the event source.
20622 // <interval>: the time between calls to the function, in milliseconds (1/1000ths of a second)
20623 // <function>: function to call
20624 // <data>: data to pass to @function
20625 static uint timeout_add(uint interval, SourceFunc function_, void* data) {
20626 return g_timeout_add(interval, function_, data);
20630 // Sets a function to be called at regular intervals, with the given
20631 // priority. The function is called repeatedly until it returns
20632 // %FALSE, at which point the timeout is automatically destroyed and
20633 // the function will not be called again. The @notify function is
20634 // called when the timeout is destroyed. The first call to the
20635 // function will be at the end of the first @interval.
20637 // Note that timeout functions may be delayed, due to the processing of other
20638 // event sources. Thus they should not be relied on for precise timing.
20639 // After each call to the timeout function, the time of the next
20640 // timeout is recalculated based on the current time and the given interval
20641 // (it does not try to 'catch up' time lost in delays).
20643 // This internally creates a main loop source using g_timeout_source_new()
20644 // and attaches it to the main loop context using g_source_attach(). You can
20645 // do these steps manually if you need greater control.
20647 // The interval given in terms of monotonic time, not wall clock time.
20648 // See g_get_monotonic_time().
20649 // RETURNS: the ID (greater than 0) of the event source.
20650 // <priority>: the priority of the timeout source. Typically this will be in the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
20651 // <interval>: the time between calls to the function, in milliseconds (1/1000ths of a second)
20652 // <function>: function to call
20653 // <data>: data to pass to @function
20654 // <notify>: function to call when the timeout is removed, or %NULL
20655 static uint timeout_add_full(int priority, uint interval, SourceFunc function_, void* data, DestroyNotify notify) {
20656 return g_timeout_add_full(priority, interval, function_, data, notify);
20660 // Unintrospectable function: timeout_add_seconds() / g_timeout_add_seconds()
20661 // Sets a function to be called at regular intervals with the default
20662 // priority, #G_PRIORITY_DEFAULT. The function is called repeatedly until
20663 // it returns %FALSE, at which point the timeout is automatically destroyed
20664 // and the function will not be called again.
20666 // This internally creates a main loop source using
20667 // g_timeout_source_new_seconds() and attaches it to the main loop context
20668 // using g_source_attach(). You can do these steps manually if you need
20669 // greater control. Also see g_timeout_add_seconds_full().
20671 // Note that the first call of the timer may not be precise for timeouts
20672 // of one second. If you need finer precision and have such a timeout,
20673 // you may want to use g_timeout_add() instead.
20675 // The interval given is in terms of monotonic time, not wall clock
20676 // time. See g_get_monotonic_time().
20677 // RETURNS: the ID (greater than 0) of the event source.
20678 // <interval>: the time between calls to the function, in seconds
20679 // <function>: function to call
20680 // <data>: data to pass to @function
20681 static uint timeout_add_seconds(uint interval, SourceFunc function_, void* data) {
20682 return g_timeout_add_seconds(interval, function_, data);
20686 // Sets a function to be called at regular intervals, with @priority.
20687 // The function is called repeatedly until it returns %FALSE, at which
20688 // point the timeout is automatically destroyed and the function will
20689 // not be called again.
20691 // Unlike g_timeout_add(), this function operates at whole second granularity.
20692 // The initial starting point of the timer is determined by the implementation
20693 // and the implementation is expected to group multiple timers together so that
20694 // they fire all at the same time.
20695 // To allow this grouping, the @interval to the first timer is rounded
20696 // and can deviate up to one second from the specified interval.
20697 // Subsequent timer iterations will generally run at the specified interval.
20699 // Note that timeout functions may be delayed, due to the processing of other
20700 // event sources. Thus they should not be relied on for precise timing.
20701 // After each call to the timeout function, the time of the next
20702 // timeout is recalculated based on the current time and the given @interval
20704 // If you want timing more precise than whole seconds, use g_timeout_add()
20705 // instead.
20707 // The grouping of timers to fire at the same time results in a more power
20708 // and CPU efficient behavior so if your timer is in multiples of seconds
20709 // and you don't require the first timer exactly one second from now, the
20710 // use of g_timeout_add_seconds() is preferred over g_timeout_add().
20712 // This internally creates a main loop source using
20713 // g_timeout_source_new_seconds() and attaches it to the main loop context
20714 // using g_source_attach(). You can do these steps manually if you need
20715 // greater control.
20717 // The interval given is in terms of monotonic time, not wall clock
20718 // time. See g_get_monotonic_time().
20719 // RETURNS: the ID (greater than 0) of the event source.
20720 // <priority>: the priority of the timeout source. Typically this will be in the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
20721 // <interval>: the time between calls to the function, in seconds
20722 // <function>: function to call
20723 // <data>: data to pass to @function
20724 // <notify>: function to call when the timeout is removed, or %NULL
20725 static uint timeout_add_seconds_full(int priority, uint interval, SourceFunc function_, void* data, DestroyNotify notify) {
20726 return g_timeout_add_seconds_full(priority, interval, function_, data, notify);
20730 // Creates a new timeout source.
20732 // The source will not initially be associated with any #GMainContext
20733 // and must be added to one with g_source_attach() before it will be
20734 // executed.
20736 // The interval given is in terms of monotonic time, not wall clock
20737 // time. See g_get_monotonic_time().
20738 // RETURNS: the newly-created timeout source
20739 // <interval>: the timeout interval in milliseconds.
20740 static Source* /*new*/ timeout_source_new(uint interval) {
20741 return g_timeout_source_new(interval);
20745 // Creates a new timeout source.
20747 // The source will not initially be associated with any #GMainContext
20748 // and must be added to one with g_source_attach() before it will be
20749 // executed.
20751 // The scheduling granularity/accuracy of this timeout source will be
20752 // in seconds.
20754 // The interval given in terms of monotonic time, not wall clock time.
20755 // See g_get_monotonic_time().
20756 // RETURNS: the newly-created timeout source
20757 // <interval>: the timeout interval in seconds
20758 static Source* /*new*/ timeout_source_new_seconds(uint interval) {
20759 return g_timeout_source_new_seconds(interval);
20762 static uint trash_stack_height(TrashStack** stack_p) {
20763 return g_trash_stack_height(stack_p);
20766 static void trash_stack_push(TrashStack** stack_p, void* data_p) {
20767 g_trash_stack_push(stack_p, data_p);
20771 // Unintrospectable function: try_malloc() / g_try_malloc()
20772 // Attempts to allocate @n_bytes, and returns %NULL on failure.
20773 // Contrast with g_malloc(), which aborts the program on failure.
20774 // RETURNS: the allocated memory, or %NULL.
20775 // <n_bytes>: number of bytes to allocate.
20776 static void* try_malloc(size_t n_bytes) {
20777 return g_try_malloc(n_bytes);
20781 // Unintrospectable function: try_malloc0() / g_try_malloc0()
20782 // Attempts to allocate @n_bytes, initialized to 0's, and returns %NULL on
20783 // failure. Contrast with g_malloc0(), which aborts the program on failure.
20784 // RETURNS: the allocated memory, or %NULL
20785 // <n_bytes>: number of bytes to allocate
20786 static void* try_malloc0(size_t n_bytes) {
20787 return g_try_malloc0(n_bytes);
20791 // Unintrospectable function: try_malloc0_n() / g_try_malloc0_n()
20792 // This function is similar to g_try_malloc0(), allocating (@n_blocks * @n_block_bytes) bytes,
20793 // but care is taken to detect possible overflow during multiplication.
20794 // RETURNS: the allocated memory, or %NULL
20795 // <n_blocks>: the number of blocks to allocate
20796 // <n_block_bytes>: the size of each block in bytes
20797 static void* try_malloc0_n(size_t n_blocks, size_t n_block_bytes) {
20798 return g_try_malloc0_n(n_blocks, n_block_bytes);
20802 // Unintrospectable function: try_malloc_n() / g_try_malloc_n()
20803 // This function is similar to g_try_malloc(), allocating (@n_blocks * @n_block_bytes) bytes,
20804 // but care is taken to detect possible overflow during multiplication.
20805 // RETURNS: the allocated memory, or %NULL.
20806 // <n_blocks>: the number of blocks to allocate
20807 // <n_block_bytes>: the size of each block in bytes
20808 static void* try_malloc_n(size_t n_blocks, size_t n_block_bytes) {
20809 return g_try_malloc_n(n_blocks, n_block_bytes);
20813 // Unintrospectable function: try_realloc() / g_try_realloc()
20814 // Attempts to realloc @mem to a new size, @n_bytes, and returns %NULL
20815 // on failure. Contrast with g_realloc(), which aborts the program
20816 // on failure. If @mem is %NULL, behaves the same as g_try_malloc().
20817 // RETURNS: the allocated memory, or %NULL.
20818 // <mem>: previously-allocated memory, or %NULL.
20819 // <n_bytes>: number of bytes to allocate.
20820 static void* try_realloc(void* mem, size_t n_bytes) {
20821 return g_try_realloc(mem, n_bytes);
20825 // Unintrospectable function: try_realloc_n() / g_try_realloc_n()
20826 // This function is similar to g_try_realloc(), allocating (@n_blocks * @n_block_bytes) bytes,
20827 // but care is taken to detect possible overflow during multiplication.
20828 // RETURNS: the allocated memory, or %NULL.
20829 // <mem>: previously-allocated memory, or %NULL.
20830 // <n_blocks>: the number of blocks to allocate
20831 // <n_block_bytes>: the size of each block in bytes
20832 static void* try_realloc_n(void* mem, size_t n_blocks, size_t n_block_bytes) {
20833 return g_try_realloc_n(mem, n_blocks, n_block_bytes);
20837 // Convert a string from UCS-4 to UTF-16. A 0 character will be
20838 // added to the result after the converted text.
20840 // This value must be freed with g_free(). If an
20841 // error occurs, %NULL will be returned and
20842 // @error set.
20843 // RETURNS: a pointer to a newly allocated UTF-16 string.
20844 // <str>: a UCS-4 encoded string
20845 // <len>: the maximum length (number of characters) of @str to use. If @len < 0, then the string is nul-terminated.
20846 // <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.
20847 // <items_written>: location to store number of <type>gunichar2</type> written, or %NULL. The value stored here does not include the trailing 0.
20848 static wchar* ucs4_to_utf16(dchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error=null) {
20849 return g_ucs4_to_utf16(str, len, items_read, items_written, error);
20853 // Convert a string from a 32-bit fixed width representation as UCS-4.
20854 // to UTF-8. The result will be terminated with a 0 byte.
20856 // This value must be freed with g_free(). If an
20857 // error occurs, %NULL will be returned and
20858 // @error set. In that case, @items_read will be
20859 // set to the position of the first invalid input
20860 // character.
20861 // RETURNS: a pointer to a newly allocated UTF-8 string.
20862 // <str>: a UCS-4 encoded string
20863 // <len>: the maximum length (number of characters) of @str to use. If @len < 0, then the string is nul-terminated.
20864 // <items_read>: location to store number of characters read, or %NULL.
20865 // <items_written>: location to store number of bytes written or %NULL. The value here stored does not include the trailing 0 byte.
20866 static char* /*new*/ ucs4_to_utf8(dchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error=null) {
20867 return g_ucs4_to_utf8(str, len, items_read, items_written, error);
20871 // Determines the break type of @c. @c should be a Unicode character
20872 // (to derive a character from UTF-8 encoded text, use
20873 // g_utf8_get_char()). The break type is used to find word and line
20874 // breaks ("text boundaries"), Pango implements the Unicode boundary
20875 // resolution algorithms and normally you would use a function such
20876 // as pango_break() instead of caring about break types yourself.
20877 // RETURNS: the break type of @c
20878 // <c>: a Unicode character
20879 static UnicodeBreakType unichar_break_type(dchar c) {
20880 return g_unichar_break_type(c);
20884 // Determines the canonical combining class of a Unicode character.
20885 // RETURNS: the combining class of the character
20886 // <uc>: a Unicode character
20887 static int unichar_combining_class(dchar uc) {
20888 return g_unichar_combining_class(uc);
20892 // Performs a single composition step of the
20893 // Unicode canonical composition algorithm.
20895 // This function does not perform algorithmic composition
20896 // for Hangul characters, and does not include compatibility
20897 // compositions. It does, however, include 'singleton'
20898 // compositions which replace a character by a single
20899 // other character. To obtain these, pass zero for @b.
20901 // This function includes algorithmic Hangul Jamo composition.
20903 // If @a and @b do not compose a new character, @ch is set to zero.
20905 // See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
20906 // for details.
20907 // RETURNS: %TRUE if the characters could be composed
20908 // <a>: a Unicode character
20909 // <b>: a Unicode character
20910 // <ch>: return location for the composed character
20911 static int unichar_compose(dchar a, dchar b, dchar* ch) {
20912 return g_unichar_compose(a, b, ch);
20916 // Performs a single decomposition step of the
20917 // Unicode canonical decomposition algorithm.
20919 // This function does not include compatibility
20920 // decompositions. It does, however, include algorithmic
20921 // Hangul Jamo decomposition, as well as 'singleton'
20922 // decompositions which replace a character by a single
20923 // other character. In the case of singletons *@b will
20924 // be set to zero.
20926 // If @ch is not decomposable, *@a is set to @ch and *@b
20927 // is set to zero.
20929 // Note that the way Unicode decomposition pairs are
20930 // defined, it is guaranteed that @b would not decompose
20931 // further, but @a may itself decompose. To get the full
20932 // canonical decomposition for @ch, one would need to
20933 // recursively call this function on @a. Or use
20934 // g_unichar_fully_decompose().
20936 // See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
20937 // for details.
20938 // RETURNS: %TRUE if the character could be decomposed
20939 // <ch>: a Unicode character
20940 // <a>: return location for the first component of @ch
20941 // <b>: return location for the second component of @ch
20942 static int unichar_decompose(dchar ch, dchar* a, dchar* b) {
20943 return g_unichar_decompose(ch, a, b);
20947 // Determines the numeric value of a character as a decimal
20948 // digit.
20950 // g_unichar_isdigit()), its numeric value. Otherwise, -1.
20951 // RETURNS: If @c is a decimal digit (according to
20952 // <c>: a Unicode character
20953 static int unichar_digit_value(dchar c) {
20954 return g_unichar_digit_value(c);
20958 // Computes the canonical or compatibility decomposition of a
20959 // Unicode character. For compatibility decomposition,
20960 // pass %TRUE for @compat; for canonical decomposition
20961 // pass %FALSE for @compat.
20963 // The decomposed sequence is placed in @result. Only up to
20964 // @result_len characters are written into @result. The length
20965 // of the full decomposition (irrespective of @result_len) is
20966 // returned by the function. For canonical decomposition,
20967 // currently all decompositions are of length at most 4, but
20968 // this may change in the future (very unlikely though).
20969 // At any rate, Unicode does guarantee that a buffer of length
20970 // 18 is always enough for both compatibility and canonical
20971 // decompositions.
20973 // See <ulink url="http://unicode.org/reports/tr15/">UAX#15</ulink>
20974 // for details.
20975 // RETURNS: the length of the full decomposition.
20976 // <ch>: a Unicode character.
20977 // <compat>: whether perform canonical or compatibility decomposition
20978 // <result>: location to store decomposed result, or %NULL
20979 // <result_len>: length of @result
20980 static size_t unichar_fully_decompose(dchar ch, int compat, dchar* result, size_t result_len) {
20981 return g_unichar_fully_decompose(ch, compat, result, result_len);
20985 // In Unicode, some characters are <firstterm>mirrored</firstterm>. This
20986 // means that their images are mirrored horizontally in text that is laid
20987 // out from right to left. For instance, "(" would become its mirror image,
20988 // ")", in right-to-left text.
20990 // If @ch has the Unicode mirrored property and there is another unicode
20991 // character that typically has a glyph that is the mirror image of @ch's
20992 // glyph and @mirrored_ch is set, it puts that character in the address
20993 // pointed to by @mirrored_ch. Otherwise the original character is put.
20994 // RETURNS: %TRUE if @ch has a mirrored character, %FALSE otherwise
20995 // <ch>: a Unicode character
20996 // <mirrored_ch>: location to store the mirrored character
20997 static int unichar_get_mirror_char(dchar ch, dchar* mirrored_ch) {
20998 return g_unichar_get_mirror_char(ch, mirrored_ch);
21002 // Looks up the #GUnicodeScript for a particular character (as defined
21003 // by Unicode Standard Annex #24). No check is made for @ch being a
21004 // valid Unicode character; if you pass in invalid character, the
21005 // result is undefined.
21007 // This function is equivalent to pango_script_for_unichar() and the
21008 // two are interchangeable.
21009 // RETURNS: the #GUnicodeScript for the character.
21010 // <ch>: a Unicode character
21011 static UnicodeScript unichar_get_script(dchar ch) {
21012 return g_unichar_get_script(ch);
21016 // Determines whether a character is alphanumeric.
21017 // Given some UTF-8 text, obtain a character value
21018 // with g_utf8_get_char().
21019 // RETURNS: %TRUE if @c is an alphanumeric character
21020 // <c>: a Unicode character
21021 static int unichar_isalnum(dchar c) {
21022 return g_unichar_isalnum(c);
21026 // Determines whether a character is alphabetic (i.e. a letter).
21027 // Given some UTF-8 text, obtain a character value with
21028 // g_utf8_get_char().
21029 // RETURNS: %TRUE if @c is an alphabetic character
21030 // <c>: a Unicode character
21031 static int unichar_isalpha(dchar c) {
21032 return g_unichar_isalpha(c);
21036 // Determines whether a character is a control character.
21037 // Given some UTF-8 text, obtain a character value with
21038 // g_utf8_get_char().
21039 // RETURNS: %TRUE if @c is a control character
21040 // <c>: a Unicode character
21041 static int unichar_iscntrl(dchar c) {
21042 return g_unichar_iscntrl(c);
21046 // Determines if a given character is assigned in the Unicode
21047 // standard.
21048 // RETURNS: %TRUE if the character has an assigned value
21049 // <c>: a Unicode character
21050 static int unichar_isdefined(dchar c) {
21051 return g_unichar_isdefined(c);
21055 // Determines whether a character is numeric (i.e. a digit). This
21056 // covers ASCII 0-9 and also digits in other languages/scripts. Given
21057 // some UTF-8 text, obtain a character value with g_utf8_get_char().
21058 // RETURNS: %TRUE if @c is a digit
21059 // <c>: a Unicode character
21060 static int unichar_isdigit(dchar c) {
21061 return g_unichar_isdigit(c);
21065 // Determines whether a character is printable and not a space
21066 // (returns %FALSE for control characters, format characters, and
21067 // spaces). g_unichar_isprint() is similar, but returns %TRUE for
21068 // spaces. Given some UTF-8 text, obtain a character value with
21069 // g_utf8_get_char().
21070 // RETURNS: %TRUE if @c is printable unless it's a space
21071 // <c>: a Unicode character
21072 static int unichar_isgraph(dchar c) {
21073 return g_unichar_isgraph(c);
21077 // Determines whether a character is a lowercase letter.
21078 // Given some UTF-8 text, obtain a character value with
21079 // g_utf8_get_char().
21080 // RETURNS: %TRUE if @c is a lowercase letter
21081 // <c>: a Unicode character
21082 static int unichar_islower(dchar c) {
21083 return g_unichar_islower(c);
21087 // Determines whether a character is a mark (non-spacing mark,
21088 // combining mark, or enclosing mark in Unicode speak).
21089 // Given some UTF-8 text, obtain a character value
21090 // with g_utf8_get_char().
21092 // Note: in most cases where isalpha characters are allowed,
21093 // ismark characters should be allowed to as they are essential
21094 // for writing most European languages as well as many non-Latin
21095 // scripts.
21096 // RETURNS: %TRUE if @c is a mark character
21097 // <c>: a Unicode character
21098 static int unichar_ismark(dchar c) {
21099 return g_unichar_ismark(c);
21103 // Determines whether a character is printable.
21104 // Unlike g_unichar_isgraph(), returns %TRUE for spaces.
21105 // Given some UTF-8 text, obtain a character value with
21106 // g_utf8_get_char().
21107 // RETURNS: %TRUE if @c is printable
21108 // <c>: a Unicode character
21109 static int unichar_isprint(dchar c) {
21110 return g_unichar_isprint(c);
21114 // Determines whether a character is punctuation or a symbol.
21115 // Given some UTF-8 text, obtain a character value with
21116 // g_utf8_get_char().
21117 // RETURNS: %TRUE if @c is a punctuation or symbol character
21118 // <c>: a Unicode character
21119 static int unichar_ispunct(dchar c) {
21120 return g_unichar_ispunct(c);
21124 // Determines whether a character is a space, tab, or line separator
21125 // (newline, carriage return, etc.). Given some UTF-8 text, obtain a
21126 // character value with g_utf8_get_char().
21128 // (Note: don't use this to do word breaking; you have to use
21129 // Pango or equivalent to get word breaking right, the algorithm
21130 // is fairly complex.)
21131 // RETURNS: %TRUE if @c is a space character
21132 // <c>: a Unicode character
21133 static int unichar_isspace(dchar c) {
21134 return g_unichar_isspace(c);
21138 // Determines if a character is titlecase. Some characters in
21139 // Unicode which are composites, such as the DZ digraph
21140 // have three case variants instead of just two. The titlecase
21141 // form is used at the beginning of a word where only the
21142 // first letter is capitalized. The titlecase form of the DZ
21143 // digraph is U+01F2 LATIN CAPITAL LETTTER D WITH SMALL LETTER Z.
21144 // RETURNS: %TRUE if the character is titlecase
21145 // <c>: a Unicode character
21146 static int unichar_istitle(dchar c) {
21147 return g_unichar_istitle(c);
21151 // Determines if a character is uppercase.
21152 // RETURNS: %TRUE if @c is an uppercase character
21153 // <c>: a Unicode character
21154 static int unichar_isupper(dchar c) {
21155 return g_unichar_isupper(c);
21159 // Determines if a character is typically rendered in a double-width
21160 // cell.
21161 // RETURNS: %TRUE if the character is wide
21162 // <c>: a Unicode character
21163 static int unichar_iswide(dchar c) {
21164 return g_unichar_iswide(c);
21168 // Determines if a character is typically rendered in a double-width
21169 // cell under legacy East Asian locales. If a character is wide according to
21170 // g_unichar_iswide(), then it is also reported wide with this function, but
21171 // the converse is not necessarily true. See the
21172 // <ulink url="http://www.unicode.org/reports/tr11/">Unicode Standard
21173 // Annex #11</ulink> for details.
21175 // If a character passes the g_unichar_iswide() test then it will also pass
21176 // this test, but not the other way around. Note that some characters may
21177 // pas both this test and g_unichar_iszerowidth().
21178 // RETURNS: %TRUE if the character is wide in legacy East Asian locales
21179 // <c>: a Unicode character
21180 static int unichar_iswide_cjk(dchar c) {
21181 return g_unichar_iswide_cjk(c);
21185 // Determines if a character is a hexidecimal digit.
21186 // RETURNS: %TRUE if the character is a hexadecimal digit
21187 // <c>: a Unicode character.
21188 static int unichar_isxdigit(dchar c) {
21189 return g_unichar_isxdigit(c);
21193 // Determines if a given character typically takes zero width when rendered.
21194 // The return value is %TRUE for all non-spacing and enclosing marks
21195 // (e.g., combining accents), format characters, zero-width
21196 // space, but not U+00AD SOFT HYPHEN.
21198 // A typical use of this function is with one of g_unichar_iswide() or
21199 // g_unichar_iswide_cjk() to determine the number of cells a string occupies
21200 // when displayed on a grid display (terminals). However, note that not all
21201 // terminals support zero-width rendering of zero-width marks.
21202 // RETURNS: %TRUE if the character has zero width
21203 // <c>: a Unicode character
21204 static int unichar_iszerowidth(dchar c) {
21205 return g_unichar_iszerowidth(c);
21209 // Converts a single character to UTF-8.
21210 // RETURNS: number of bytes written
21211 // <c>: a Unicode character code
21212 // <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.
21213 static int unichar_to_utf8(dchar c, char* outbuf) {
21214 return g_unichar_to_utf8(c, outbuf);
21218 // Converts a character to lower case.
21220 // If @c is not an upperlower or titlecase character,
21221 // or has no lowercase equivalent @c is returned unchanged.
21222 // RETURNS: the result of converting @c to lower case.
21223 // <c>: a Unicode character.
21224 static dchar unichar_tolower(dchar c) {
21225 return g_unichar_tolower(c);
21229 // Converts a character to the titlecase.
21231 // If @c is not an uppercase or lowercase character,
21232 // @c is returned unchanged.
21233 // RETURNS: the result of converting @c to titlecase.
21234 // <c>: a Unicode character
21235 static dchar unichar_totitle(dchar c) {
21236 return g_unichar_totitle(c);
21240 // Converts a character to uppercase.
21242 // If @c is not an lowercase or titlecase character,
21243 // or has no upper case equivalent @c is returned unchanged.
21244 // RETURNS: the result of converting @c to uppercase.
21245 // <c>: a Unicode character
21246 static dchar unichar_toupper(dchar c) {
21247 return g_unichar_toupper(c);
21251 // Classifies a Unicode character by type.
21252 // RETURNS: the type of the character.
21253 // <c>: a Unicode character
21254 static UnicodeType unichar_type(dchar c) {
21255 return g_unichar_type(c);
21259 // Checks whether @ch is a valid Unicode character. Some possible
21260 // integer values of @ch will not be valid. 0 is considered a valid
21261 // character, though it's normally a string terminator.
21262 // RETURNS: %TRUE if @ch is a valid Unicode character
21263 // <ch>: a Unicode character
21264 static int unichar_validate(dchar ch) {
21265 return g_unichar_validate(ch);
21269 // Determines the numeric value of a character as a hexidecimal
21270 // digit.
21272 // g_unichar_isxdigit()), its numeric value. Otherwise, -1.
21273 // RETURNS: If @c is a hex digit (according to
21274 // <c>: a Unicode character
21275 static int unichar_xdigit_value(dchar c) {
21276 return g_unichar_xdigit_value(c);
21280 // Computes the canonical decomposition of a Unicode character.
21282 // @result_len is set to the resulting length of the string.
21284 // instead.
21285 // RETURNS: a newly allocated string of Unicode characters.
21286 // <ch>: a Unicode character.
21287 // <result_len>: location to store the length of the return value.
21288 static dchar* unicode_canonical_decomposition(dchar ch, size_t* result_len) {
21289 return g_unicode_canonical_decomposition(ch, result_len);
21293 // Computes the canonical ordering of a string in-place.
21294 // This rearranges decomposed characters in the string
21295 // according to their combining classes. See the Unicode
21296 // manual for more information.
21297 // <string>: a UCS-4 encoded string.
21298 // <len>: the maximum length of @string to use.
21299 static void unicode_canonical_ordering(dchar* string_, size_t len) {
21300 g_unicode_canonical_ordering(string_, len);
21304 // Looks up the Unicode script for @iso15924. ISO 15924 assigns four-letter
21305 // codes to scripts. For example, the code for Arabic is 'Arab'.
21306 // This function accepts four letter codes encoded as a @guint32 in a
21307 // big-endian fashion. That is, the code expected for Arabic is
21308 // 0x41726162 (0x41 is ASCII code for 'A', 0x72 is ASCII code for 'r', etc).
21310 // See <ulink url="http://unicode.org/iso15924/codelists.html">Codes for the
21311 // representation of names of scripts</ulink> for details.
21313 // of %G_UNICODE_SCRIPT_INVALID_CODE if @iso15924 is zero and
21314 // %G_UNICODE_SCRIPT_UNKNOWN if @iso15924 is unknown.
21315 // RETURNS: the Unicode script for @iso15924, or
21316 // <iso15924>: a Unicode script
21317 static UnicodeScript unicode_script_from_iso15924(uint iso15924) {
21318 return g_unicode_script_from_iso15924(iso15924);
21322 // Looks up the ISO 15924 code for @script. ISO 15924 assigns four-letter
21323 // codes to scripts. For example, the code for Arabic is 'Arab'. The
21324 // four letter codes are encoded as a @guint32 by this function in a
21325 // big-endian fashion. That is, the code returned for Arabic is
21326 // 0x41726162 (0x41 is ASCII code for 'A', 0x72 is ASCII code for 'r', etc).
21328 // See <ulink url="http://unicode.org/iso15924/codelists.html">Codes for the
21329 // representation of names of scripts</ulink> for details.
21331 // of zero if @script is %G_UNICODE_SCRIPT_INVALID_CODE or
21332 // ISO 15924 code 'Zzzz' (script code for UNKNOWN) if @script is not understood.
21333 // RETURNS: the ISO 15924 code for @script, encoded as an integer,
21334 // <script>: a Unicode script
21335 static uint unicode_script_to_iso15924(UnicodeScript script) {
21336 return g_unicode_script_to_iso15924(script);
21340 // A wrapper for the POSIX unlink() function. The unlink() function
21341 // deletes a name from the filesystem. If this was the last link to the
21342 // file and no processes have it opened, the diskspace occupied by the
21343 // file is freed.
21345 // See your C library manual for more details about unlink(). Note
21346 // that on Windows, it is in general not possible to delete files that
21347 // are open to some process, or mapped into memory.
21349 // occurred
21350 // RETURNS: 0 if the name was successfully deleted, -1 if an error
21351 // <filename>: a pathname in the GLib file name encoding (UTF-8 on Windows)
21352 static int unlink(char* filename) {
21353 return g_unlink(filename);
21357 // Removes an environment variable from the environment.
21359 // Note that on some systems, when variables are overwritten, the memory
21360 // used for the previous variables and its value isn't reclaimed.
21361 // Furthermore, this function can't be guaranteed to operate in a
21362 // threadsafe way.
21363 // <variable>: the environment variable to remove, must not contain '='.
21364 static void unsetenv(char* variable) {
21365 g_unsetenv(variable);
21369 // Escapes a string for use in a URI.
21371 // Normally all characters that are not "unreserved" (i.e. ASCII alphanumerical
21372 // characters plus dash, dot, underscore and tilde) are escaped.
21373 // But if you specify characters in @reserved_chars_allowed they are not
21374 // escaped. This is useful for the "reserved" characters in the URI
21375 // specification, since those are allowed unescaped in some portions of
21376 // a URI.
21378 // freed when no longer needed.
21379 // RETURNS: an escaped version of @unescaped. The returned string should be
21380 // <unescaped>: the unescaped input string.
21381 // <reserved_chars_allowed>: a string of reserved characters that are allowed to be used, or %NULL.
21382 // <allow_utf8>: %TRUE if the result can include UTF-8 characters.
21383 static char* /*new*/ uri_escape_string(char* unescaped, char* reserved_chars_allowed, int allow_utf8) {
21384 return g_uri_escape_string(unescaped, reserved_chars_allowed, allow_utf8);
21388 // Unintrospectable function: uri_list_extract_uris() / g_uri_list_extract_uris()
21389 // Splits an URI list conforming to the text/uri-list
21390 // mime type defined in RFC 2483 into individual URIs,
21391 // discarding any comments. The URIs are not validated.
21393 // strings holding the individual URIs. The array should
21394 // be freed with g_strfreev().
21395 // RETURNS: a newly allocated %NULL-terminated list of
21396 // <uri_list>: an URI list
21397 static char** uri_list_extract_uris(char* uri_list) {
21398 return g_uri_list_extract_uris(uri_list);
21402 // Gets the scheme portion of a URI string. RFC 3986 decodes the scheme as:
21403 // <programlisting>
21404 // URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
21405 // </programlisting>
21406 // Common schemes include "file", "http", "svn+ssh", etc.
21408 // The returned string should be freed when no longer needed.
21409 // RETURNS: The "Scheme" component of the URI, or %NULL on error.
21410 // <uri>: a valid URI.
21411 static char* /*new*/ uri_parse_scheme(char* uri) {
21412 return g_uri_parse_scheme(uri);
21416 // Unescapes a segment of an escaped string.
21418 // If any of the characters in @illegal_characters or the character zero appears
21419 // as an escaped character in @escaped_string then that is an error and %NULL
21420 // will be returned. This is useful it you want to avoid for instance having a
21421 // slash being expanded in an escaped path element, which might confuse pathname
21422 // handling.
21424 // The returned string should be freed when no longer needed.
21425 // RETURNS: an unescaped version of @escaped_string or %NULL on error.
21426 // <escaped_string>: a string.
21427 // <escaped_string_end>: a string.
21428 // <illegal_characters>: an optional string of illegal characters not to be allowed.
21429 static char* /*new*/ uri_unescape_segment(char* escaped_string, char* escaped_string_end, char* illegal_characters) {
21430 return g_uri_unescape_segment(escaped_string, escaped_string_end, illegal_characters);
21434 // Unescapes a whole escaped string.
21436 // If any of the characters in @illegal_characters or the character zero appears
21437 // as an escaped character in @escaped_string then that is an error and %NULL
21438 // will be returned. This is useful it you want to avoid for instance having a
21439 // slash being expanded in an escaped path element, which might confuse pathname
21440 // handling.
21442 // should be freed when no longer needed.
21443 // RETURNS: an unescaped version of @escaped_string. The returned string
21444 // <escaped_string>: an escaped string to be unescaped.
21445 // <illegal_characters>: an optional string of illegal characters not to be allowed.
21446 static char* /*new*/ uri_unescape_string(char* escaped_string, char* illegal_characters) {
21447 return g_uri_unescape_string(escaped_string, illegal_characters);
21450 static void usleep(c_ulong microseconds) {
21451 g_usleep(microseconds);
21455 // Convert a string from UTF-16 to UCS-4. The result will be
21456 // nul-terminated.
21458 // This value must be freed with g_free(). If an
21459 // error occurs, %NULL will be returned and
21460 // @error set.
21461 // RETURNS: a pointer to a newly allocated UCS-4 string.
21462 // <str>: a UTF-16 encoded string
21463 // <len>: the maximum length (number of <type>gunichar2</type>) of @str to use. If @len < 0, then the string is nul-terminated.
21464 // <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.
21465 // <items_written>: location to store number of characters written, or %NULL. The value stored here does not include the trailing 0 character.
21466 static dchar* utf16_to_ucs4(wchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error=null) {
21467 return g_utf16_to_ucs4(str, len, items_read, items_written, error);
21471 // Convert a string from UTF-16 to UTF-8. The result will be
21472 // terminated with a 0 byte.
21474 // Note that the input is expected to be already in native endianness,
21475 // an initial byte-order-mark character is not handled specially.
21476 // g_convert() can be used to convert a byte buffer of UTF-16 data of
21477 // ambiguous endianess.
21479 // Further note that this function does not validate the result
21480 // string; it may e.g. include embedded NUL characters. The only
21481 // validation done by this function is to ensure that the input can
21482 // be correctly interpreted as UTF-16, i.e. it doesn't contain
21483 // things unpaired surrogates.
21485 // This value must be freed with g_free(). If an
21486 // error occurs, %NULL will be returned and
21487 // @error set.
21488 // RETURNS: a pointer to a newly allocated UTF-8 string.
21489 // <str>: a UTF-16 encoded string
21490 // <len>: the maximum length (number of <type>gunichar2</type>) of @str to use. If @len < 0, then the string is nul-terminated.
21491 // <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.
21492 // <items_written>: location to store number of bytes written, or %NULL. The value stored here does not include the trailing 0 byte.
21493 static char* /*new*/ utf16_to_utf8(wchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error=null) {
21494 return g_utf16_to_utf8(str, len, items_read, items_written, error);
21498 // Converts a string into a form that is independent of case. The
21499 // result will not correspond to any particular case, but can be
21500 // compared for equality or ordered with the results of calling
21501 // g_utf8_casefold() on other strings.
21503 // Note that calling g_utf8_casefold() followed by g_utf8_collate() is
21504 // only an approximation to the correct linguistic case insensitive
21505 // ordering, though it is a fairly good one. Getting this exactly
21506 // right would require a more sophisticated collation function that
21507 // takes case sensitivity into account. GLib does not currently
21508 // provide such a function.
21510 // case independent form of @str.
21511 // RETURNS: a newly allocated string, that is a
21512 // <str>: a UTF-8 encoded string
21513 // <len>: length of @str, in bytes, or -1 if @str is nul-terminated.
21514 static char* /*new*/ utf8_casefold(char* str, ssize_t len) {
21515 return g_utf8_casefold(str, len);
21519 // Compares two strings for ordering using the linguistically
21520 // correct rules for the <link linkend="setlocale">current locale</link>.
21521 // When sorting a large number of strings, it will be significantly
21522 // faster to obtain collation keys with g_utf8_collate_key() and
21523 // compare the keys with strcmp() when sorting instead of sorting
21524 // the original strings.
21526 // 0 if they compare equal, &gt; 0 if @str1 compares after @str2.
21527 // RETURNS: &lt; 0 if @str1 compares before @str2,
21528 // <str1>: a UTF-8 encoded string
21529 // <str2>: a UTF-8 encoded string
21530 static int utf8_collate(char* str1, char* str2) {
21531 return g_utf8_collate(str1, str2);
21535 // Converts a string into a collation key that can be compared
21536 // with other collation keys produced by the same function using
21537 // strcmp().
21539 // The results of comparing the collation keys of two strings
21540 // with strcmp() will always be the same as comparing the two
21541 // original keys with g_utf8_collate().
21543 // Note that this function depends on the
21544 // <link linkend="setlocale">current locale</link>.
21546 // be freed with g_free() when you are done with it.
21547 // RETURNS: a newly allocated string. This string should
21548 // <str>: a UTF-8 encoded string.
21549 // <len>: length of @str, in bytes, or -1 if @str is nul-terminated.
21550 static char* /*new*/ utf8_collate_key(char* str, ssize_t len) {
21551 return g_utf8_collate_key(str, len);
21555 // Converts a string into a collation key that can be compared
21556 // with other collation keys produced by the same function using strcmp().
21558 // In order to sort filenames correctly, this function treats the dot '.'
21559 // as a special case. Most dictionary orderings seem to consider it
21560 // insignificant, thus producing the ordering "event.c" "eventgenerator.c"
21561 // "event.h" instead of "event.c" "event.h" "eventgenerator.c". Also, we
21562 // would like to treat numbers intelligently so that "file1" "file10" "file5"
21563 // is sorted as "file1" "file5" "file10".
21565 // Note that this function depends on the
21566 // <link linkend="setlocale">current locale</link>.
21568 // be freed with g_free() when you are done with it.
21569 // RETURNS: a newly allocated string. This string should
21570 // <str>: a UTF-8 encoded string.
21571 // <len>: length of @str, in bytes, or -1 if @str is nul-terminated.
21572 static char* /*new*/ utf8_collate_key_for_filename(char* str, ssize_t len) {
21573 return g_utf8_collate_key_for_filename(str, len);
21577 // Finds the start of the next UTF-8 character in the string after @p.
21579 // @p does not have to be at the beginning of a UTF-8 character. No check
21580 // is made to see if the character found is actually valid other than
21581 // it starts with an appropriate byte.
21582 // RETURNS: a pointer to the found character or %NULL
21583 // <p>: a pointer to a position within a UTF-8 encoded string
21584 // <end>: a pointer to the byte following the end of the string, or %NULL to indicate that the string is nul-terminated.
21585 static char* /*new*/ utf8_find_next_char(char* p, char* end) {
21586 return g_utf8_find_next_char(p, end);
21590 // Given a position @p with a UTF-8 encoded string @str, find the start
21591 // of the previous UTF-8 character starting before @p. Returns %NULL if no
21592 // UTF-8 characters are present in @str before @p.
21594 // @p does not have to be at the beginning of a UTF-8 character. No check
21595 // is made to see if the character found is actually valid other than
21596 // it starts with an appropriate byte.
21597 // RETURNS: a pointer to the found character or %NULL.
21598 // <str>: pointer to the beginning of a UTF-8 encoded string
21599 // <p>: pointer to some position within @str
21600 static char* /*new*/ utf8_find_prev_char(char* str, char* p) {
21601 return g_utf8_find_prev_char(str, p);
21605 // Converts a sequence of bytes encoded as UTF-8 to a Unicode character.
21606 // If @p does not point to a valid UTF-8 encoded character, results are
21607 // undefined. If you are not sure that the bytes are complete
21608 // valid Unicode characters, you should use g_utf8_get_char_validated()
21609 // instead.
21610 // RETURNS: the resulting character
21611 // <p>: a pointer to Unicode character encoded as UTF-8
21612 static dchar utf8_get_char(char* p) {
21613 return g_utf8_get_char(p);
21617 // Convert a sequence of bytes encoded as UTF-8 to a Unicode character.
21618 // This function checks for incomplete characters, for invalid characters
21619 // such as characters that are out of the range of Unicode, and for
21620 // overlong encodings of valid characters.
21622 // sequence at the end of a string that could begin a valid
21623 // character (or if @max_len is zero), returns (gunichar)-2;
21624 // otherwise, if @p does not point to a valid UTF-8 encoded
21625 // Unicode character, returns (gunichar)-1.
21626 // RETURNS: the resulting character. If @p points to a partial
21627 // <p>: a pointer to Unicode character encoded as UTF-8
21628 // <max_len>: the maximum number of bytes to read, or -1, for no maximum or if @p is nul-terminated
21629 static dchar utf8_get_char_validated(char* p, ssize_t max_len) {
21630 return g_utf8_get_char_validated(p, max_len);
21634 // Converts a string into canonical form, standardizing
21635 // such issues as whether a character with an accent
21636 // is represented as a base character and combining
21637 // accent or as a single precomposed character. The
21638 // string has to be valid UTF-8, otherwise %NULL is
21639 // returned. You should generally call g_utf8_normalize()
21640 // before comparing two Unicode strings.
21642 // The normalization mode %G_NORMALIZE_DEFAULT only
21643 // standardizes differences that do not affect the
21644 // text content, such as the above-mentioned accent
21645 // representation. %G_NORMALIZE_ALL also standardizes
21646 // the "compatibility" characters in Unicode, such
21647 // as SUPERSCRIPT THREE to the standard forms
21648 // (in this case DIGIT THREE). Formatting information
21649 // may be lost but for most text operations such
21650 // characters should be considered the same.
21652 // %G_NORMALIZE_DEFAULT_COMPOSE and %G_NORMALIZE_ALL_COMPOSE
21653 // are like %G_NORMALIZE_DEFAULT and %G_NORMALIZE_ALL,
21654 // but returned a result with composed forms rather
21655 // than a maximally decomposed form. This is often
21656 // useful if you intend to convert the string to
21657 // a legacy encoding or pass it to a system with
21658 // less capable Unicode handling.
21660 // normalized form of @str, or %NULL if @str is not
21661 // valid UTF-8.
21662 // RETURNS: a newly allocated string, that is the
21663 // <str>: a UTF-8 encoded string.
21664 // <len>: length of @str, in bytes, or -1 if @str is nul-terminated.
21665 // <mode>: the type of normalization to perform.
21666 static char* /*new*/ utf8_normalize(char* str, ssize_t len, NormalizeMode mode) {
21667 return g_utf8_normalize(str, len, mode);
21671 // Converts from an integer character offset to a pointer to a position
21672 // within the string.
21674 // Since 2.10, this function allows to pass a negative @offset to
21675 // step backwards. It is usually worth stepping backwards from the end
21676 // instead of forwards if @offset is in the last fourth of the string,
21677 // since moving forward is about 3 times faster than moving backward.
21679 // <note><para>
21680 // This function doesn't abort when reaching the end of @str. Therefore
21681 // you should be sure that @offset is within string boundaries before
21682 // calling that function. Call g_utf8_strlen() when unsure.
21684 // This limitation exists as this function is called frequently during
21685 // text rendering and therefore has to be as fast as possible.
21686 // </para></note>
21687 // RETURNS: the resulting pointer
21688 // <str>: a UTF-8 encoded string
21689 // <offset>: a character offset within @str
21690 static char* /*new*/ utf8_offset_to_pointer(char* str, c_long offset) {
21691 return g_utf8_offset_to_pointer(str, offset);
21695 // Converts from a pointer to position within a string to a integer
21696 // character offset.
21698 // Since 2.10, this function allows @pos to be before @str, and returns
21699 // a negative offset in this case.
21700 // RETURNS: the resulting character offset
21701 // <str>: a UTF-8 encoded string
21702 // <pos>: a pointer to a position within @str
21703 static c_long utf8_pointer_to_offset(char* str, char* pos) {
21704 return g_utf8_pointer_to_offset(str, pos);
21708 // Finds the previous UTF-8 character in the string before @p.
21710 // @p does not have to be at the beginning of a UTF-8 character. No check
21711 // is made to see if the character found is actually valid other than
21712 // it starts with an appropriate byte. If @p might be the first
21713 // character of the string, you must use g_utf8_find_prev_char() instead.
21714 // RETURNS: a pointer to the found character.
21715 // <p>: a pointer to a position within a UTF-8 encoded string
21716 static char* /*new*/ utf8_prev_char(char* p) {
21717 return g_utf8_prev_char(p);
21721 // Finds the leftmost occurrence of the given Unicode character
21722 // in a UTF-8 encoded string, while limiting the search to @len bytes.
21723 // If @len is -1, allow unbounded search.
21725 // otherwise, a pointer to the start of the leftmost occurrence of
21726 // the character in the string.
21727 // RETURNS: %NULL if the string does not contain the character,
21728 // <p>: a nul-terminated UTF-8 encoded string
21729 // <len>: the maximum length of @p
21730 // <c>: a Unicode character
21731 static char* /*new*/ utf8_strchr(char* p, ssize_t len, dchar c) {
21732 return g_utf8_strchr(p, len, c);
21736 // Converts all Unicode characters in the string that have a case
21737 // to lowercase. The exact manner that this is done depends
21738 // on the current locale, and may result in the number of
21739 // characters in the string changing.
21741 // converted to lowercase.
21742 // RETURNS: a newly allocated string, with all characters
21743 // <str>: a UTF-8 encoded string
21744 // <len>: length of @str, in bytes, or -1 if @str is nul-terminated.
21745 static char* /*new*/ utf8_strdown(char* str, ssize_t len) {
21746 return g_utf8_strdown(str, len);
21750 // Computes the length of the string in characters, not including
21751 // the terminating nul character.
21752 // RETURNS: the length of the string in characters
21753 // <p>: pointer to the start of a UTF-8 encoded string
21754 // <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.
21755 static c_long utf8_strlen(char* p, ssize_t max) {
21756 return g_utf8_strlen(p, max);
21760 // Like the standard C strncpy() function, but
21761 // copies a given number of characters instead of a given number of
21762 // bytes. The @src string must be valid UTF-8 encoded text.
21763 // (Use g_utf8_validate() on all text before trying to use UTF-8
21764 // utility functions with it.)
21765 // RETURNS: @dest
21766 // <dest>: buffer to fill with characters from @src
21767 // <src>: UTF-8 encoded string
21768 // <n>: character count
21769 static char* /*new*/ utf8_strncpy(char* dest, char* src, size_t n) {
21770 return g_utf8_strncpy(dest, src, n);
21774 // Find the rightmost occurrence of the given Unicode character
21775 // in a UTF-8 encoded string, while limiting the search to @len bytes.
21776 // If @len is -1, allow unbounded search.
21778 // otherwise, a pointer to the start of the rightmost occurrence of the
21779 // character in the string.
21780 // RETURNS: %NULL if the string does not contain the character,
21781 // <p>: a nul-terminated UTF-8 encoded string
21782 // <len>: the maximum length of @p
21783 // <c>: a Unicode character
21784 static char* /*new*/ utf8_strrchr(char* p, ssize_t len, dchar c) {
21785 return g_utf8_strrchr(p, len, c);
21789 // Reverses a UTF-8 string. @str must be valid UTF-8 encoded text.
21790 // (Use g_utf8_validate() on all text before trying to use UTF-8
21791 // utility functions with it.)
21793 // This function is intended for programmatic uses of reversed strings.
21794 // It pays no attention to decomposed characters, combining marks, byte
21795 // order marks, directional indicators (LRM, LRO, etc) and similar
21796 // characters which might need special handling when reversing a string
21797 // for display purposes.
21799 // Note that unlike g_strreverse(), this function returns
21800 // newly-allocated memory, which should be freed with g_free() when
21801 // no longer needed.
21802 // RETURNS: a newly-allocated string which is the reverse of @str.
21803 // <str>: a UTF-8 encoded string
21804 // <len>: the maximum length of @str to use, in bytes. If @len < 0, then the string is nul-terminated.
21805 static char* /*new*/ utf8_strreverse(char* str, ssize_t len) {
21806 return g_utf8_strreverse(str, len);
21810 // Converts all Unicode characters in the string that have a case
21811 // to uppercase. The exact manner that this is done depends
21812 // on the current locale, and may result in the number of
21813 // characters in the string increasing. (For instance, the
21814 // German ess-zet will be changed to SS.)
21816 // converted to uppercase.
21817 // RETURNS: a newly allocated string, with all characters
21818 // <str>: a UTF-8 encoded string
21819 // <len>: length of @str, in bytes, or -1 if @str is nul-terminated.
21820 static char* /*new*/ utf8_strup(char* str, ssize_t len) {
21821 return g_utf8_strup(str, len);
21825 // Copies a substring out of a UTF-8 encoded string.
21826 // The substring will contain @end_pos - @start_pos
21827 // characters.
21829 // substring. Free with g_free() when no longer needed.
21830 // RETURNS: a newly allocated copy of the requested
21831 // <str>: a UTF-8 encoded string
21832 // <start_pos>: a character offset within @str
21833 // <end_pos>: another character offset within @str
21834 static char* /*new*/ utf8_substring(char* str, c_long start_pos, c_long end_pos) {
21835 return g_utf8_substring(str, start_pos, end_pos);
21839 // Convert a string from UTF-8 to a 32-bit fixed width
21840 // representation as UCS-4. A trailing 0 character will be added to the
21841 // string after the converted text.
21843 // This value must be freed with g_free(). If an
21844 // error occurs, %NULL will be returned and
21845 // @error set.
21846 // RETURNS: a pointer to a newly allocated UCS-4 string.
21847 // <str>: a UTF-8 encoded string
21848 // <len>: the maximum length of @str to use, in bytes. If @len < 0, then the string is nul-terminated.
21849 // <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.
21850 // <items_written>: location to store number of characters written or %NULL. The value here stored does not include the trailing 0 character.
21851 static dchar* utf8_to_ucs4(char* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error=null) {
21852 return g_utf8_to_ucs4(str, len, items_read, items_written, error);
21856 // Convert a string from UTF-8 to a 32-bit fixed width
21857 // representation as UCS-4, assuming valid UTF-8 input.
21858 // This function is roughly twice as fast as g_utf8_to_ucs4()
21859 // but does no error checking on the input. A trailing 0 character
21860 // will be added to the string after the converted text.
21862 // This value must be freed with g_free().
21863 // RETURNS: a pointer to a newly allocated UCS-4 string.
21864 // <str>: a UTF-8 encoded string
21865 // <len>: the maximum length of @str to use, in bytes. If @len < 0, then the string is nul-terminated.
21866 // <items_written>: location to store the number of characters in the result, or %NULL.
21867 static dchar* utf8_to_ucs4_fast(char* str, c_long len, c_long* items_written) {
21868 return g_utf8_to_ucs4_fast(str, len, items_written);
21872 // Convert a string from UTF-8 to UTF-16. A 0 character will be
21873 // added to the result after the converted text.
21875 // This value must be freed with g_free(). If an
21876 // error occurs, %NULL will be returned and
21877 // @error set.
21878 // RETURNS: a pointer to a newly allocated UTF-16 string.
21879 // <str>: a UTF-8 encoded string
21880 // <len>: the maximum length (number of bytes) of @str to use. If @len < 0, then the string is nul-terminated.
21881 // <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.
21882 // <items_written>: location to store number of <type>gunichar2</type> written, or %NULL. The value stored here does not include the trailing 0.
21883 static wchar* utf8_to_utf16(char* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error=null) {
21884 return g_utf8_to_utf16(str, len, items_read, items_written, error);
21888 // Validates UTF-8 encoded text. @str is the text to validate;
21889 // if @str is nul-terminated, then @max_len can be -1, otherwise
21890 // @max_len should be the number of bytes to validate.
21891 // If @end is non-%NULL, then the end of the valid range
21892 // will be stored there (i.e. the start of the first invalid
21893 // character if some bytes were invalid, or the end of the text
21894 // being validated otherwise).
21896 // Note that g_utf8_validate() returns %FALSE if @max_len is
21897 // positive and NUL is met before @max_len bytes have been read.
21899 // Returns %TRUE if all of @str was valid. Many GLib and GTK+
21900 // routines <emphasis>require</emphasis> valid UTF-8 as input;
21901 // so data read from a file or the network should be checked
21902 // with g_utf8_validate() before doing anything else with it.
21903 // RETURNS: %TRUE if the text was valid UTF-8
21904 // <str>: a pointer to character data
21905 // <max_len>: max bytes to validate, or -1 to go until NUL
21906 // <end>: return location for end of valid data
21907 static int utf8_validate(char* str, ssize_t max_len, /*out*/ char** end=null) {
21908 return g_utf8_validate(str, max_len, end);
21911 static Type variant_get_gtype() {
21912 return g_variant_get_gtype();
21916 // Determines the type of @value.
21918 // The return value is valid for the lifetime of @value and must not
21919 // be freed.
21920 // RETURNS: a #GVariantType
21921 // <value>: a #GVariant
21922 static VariantType* variant_get_type(Variant* value) {
21923 return g_variant_get_type(value);
21927 // Determines if a given string is a valid D-Bus object path. You
21928 // should ensure that a string is a valid D-Bus object path before
21929 // passing it to g_variant_new_object_path().
21931 // A valid object path starts with '/' followed by zero or more
21932 // sequences of characters separated by '/' characters. Each sequence
21933 // must contain only the characters "[A-Z][a-z][0-9]_". No sequence
21934 // (including the one following the final '/' character) may be empty.
21935 // RETURNS: %TRUE if @string is a D-Bus object path
21936 // <string>: a normal C nul-terminated string
21937 static int variant_is_object_path(char* string_) {
21938 return g_variant_is_object_path(string_);
21942 // Determines if a given string is a valid D-Bus type signature. You
21943 // should ensure that a string is a valid D-Bus type signature before
21944 // passing it to g_variant_new_signature().
21946 // D-Bus type signatures consist of zero or more definite #GVariantType
21947 // strings in sequence.
21948 // RETURNS: %TRUE if @string is a D-Bus type signature
21949 // <string>: a normal C nul-terminated string
21950 static int variant_is_signature(char* string_) {
21951 return g_variant_is_signature(string_);
21955 // Parses a #GVariant from a text representation.
21957 // A single #GVariant is parsed from the content of @text.
21959 // The format is described <link linkend='gvariant-text'>here</link>.
21961 // The memory at @limit will never be accessed and the parser behaves as
21962 // if the character at @limit is the nul terminator. This has the
21963 // effect of bounding @text.
21965 // If @endptr is non-%NULL then @text is permitted to contain data
21966 // following the value that this function parses and @endptr will be
21967 // updated to point to the first character past the end of the text
21968 // parsed by this function. If @endptr is %NULL and there is extra data
21969 // then an error is returned.
21971 // If @type is non-%NULL then the value will be parsed to have that
21972 // type. This may result in additional parse errors (in the case that
21973 // the parsed value doesn't fit the type) but may also result in fewer
21974 // errors (in the case that the type would have been ambiguous, such as
21975 // with empty arrays).
21977 // In the event that the parsing is successful, the resulting #GVariant
21978 // is returned.
21980 // In case of any error, %NULL will be returned. If @error is non-%NULL
21981 // then it will be set to reflect the error that occurred.
21983 // Officially, the language understood by the parser is "any string
21984 // produced by g_variant_print()".
21985 // <type>: a #GVariantType, or %NULL
21986 // <text>: a string containing a GVariant in text form
21987 // <limit>: a pointer to the end of @text, or %NULL
21988 // <endptr>: a location to store the end pointer, or %NULL
21989 static Variant* /*new*/ variant_parse(VariantType* type, char* text, char* limit, char** endptr, GLib2.Error** error=null) {
21990 return g_variant_parse(type, text, limit, endptr, error);
21993 static Quark variant_parser_get_error_quark() {
21994 return g_variant_parser_get_error_quark();
21997 static VariantType* variant_type_checked_(char* arg_a) {
21998 return g_variant_type_checked_(arg_a);
22002 // Checks if @type_string is a valid GVariant type string. This call is
22003 // equivalent to calling g_variant_type_string_scan() and confirming
22004 // that the following character is a nul terminator.
22006 // Since 2.24
22007 // RETURNS: %TRUE if @type_string is exactly one valid type string
22008 // <type_string>: a pointer to any string
22009 static int variant_type_string_is_valid(char* type_string) {
22010 return g_variant_type_string_is_valid(type_string);
22014 // Scan for a single complete and valid GVariant type string in @string.
22015 // The memory pointed to by @limit (or bytes beyond it) is never
22016 // accessed.
22018 // If a valid type string is found, @endptr is updated to point to the
22019 // first character past the end of the string that was found and %TRUE
22020 // is returned.
22022 // If there is no valid type string starting at @string, or if the type
22023 // string does not end before @limit then %FALSE is returned.
22025 // For the simple case of checking if a string is a valid type string,
22026 // see g_variant_type_string_is_valid().
22027 // RETURNS: %TRUE if a valid type string was found
22028 // <string>: a pointer to any string
22029 // <limit>: the end of @string, or %NULL
22030 // <endptr>: location to store the end pointer, or %NULL
22031 static int variant_type_string_scan(char* string_, char* limit=null, /*out*/ char** endptr=null) {
22032 return g_variant_type_string_scan(string_, limit, endptr);
22036 // Unintrospectable function: vasprintf() / g_vasprintf()
22037 // An implementation of the GNU vasprintf() function which supports
22038 // positional parameters, as specified in the Single Unix Specification.
22039 // This function is similar to g_vsprintf(), except that it allocates a
22040 // string to hold the output, instead of putting the output in a buffer
22041 // you allocate in advance.
22042 // RETURNS: the number of bytes printed.
22043 // <string>: the return location for the newly-allocated string.
22044 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
22045 // <args>: the list of arguments to insert in the output.
22046 static int vasprintf(char** string_, char* format, va_list args) {
22047 return g_vasprintf(string_, format, args);
22051 // Unintrospectable function: vfprintf() / g_vfprintf()
22052 // An implementation of the standard fprintf() function which supports
22053 // positional parameters, as specified in the Single Unix Specification.
22054 // RETURNS: the number of bytes printed.
22055 // <file>: the stream to write to.
22056 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
22057 // <args>: the list of arguments to insert in the output.
22058 static int vfprintf(FILE* file, char* format, va_list args) {
22059 return g_vfprintf(file, format, args);
22063 // Unintrospectable function: vprintf() / g_vprintf()
22064 // An implementation of the standard vprintf() function which supports
22065 // positional parameters, as specified in the Single Unix Specification.
22066 // RETURNS: the number of bytes printed.
22067 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
22068 // <args>: the list of arguments to insert in the output.
22069 static int vprintf(char* format, va_list args) {
22070 return g_vprintf(format, args);
22074 // Unintrospectable function: vsnprintf() / g_vsnprintf()
22075 // A safer form of the standard vsprintf() function. The output is guaranteed
22076 // to not exceed @n characters (including the terminating nul character), so
22077 // it is easy to ensure that a buffer overflow cannot occur.
22079 // See also g_strdup_vprintf().
22081 // In versions of GLib prior to 1.2.3, this function may return -1 if the
22082 // output was truncated, and the truncated string may not be nul-terminated.
22083 // In versions prior to 1.3.12, this function returns the length of the output
22084 // string.
22086 // The return value of g_vsnprintf() conforms to the vsnprintf() function
22087 // as standardized in ISO C99. Note that this is different from traditional
22088 // vsnprintf(), which returns the length of the output string.
22090 // The format string may contain positional parameters, as specified in
22091 // the Single Unix Specification.
22093 // was large enough.
22094 // RETURNS: the number of bytes which would be produced if the buffer
22095 // <string>: the buffer to hold the output.
22096 // <n>: the maximum number of bytes to produce (including the terminating nul character).
22097 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
22098 // <args>: the list of arguments to insert in the output.
22099 static int vsnprintf(char* string_, c_ulong n, char* format, va_list args) {
22100 return g_vsnprintf(string_, n, format, args);
22104 // Unintrospectable function: vsprintf() / g_vsprintf()
22105 // An implementation of the standard vsprintf() function which supports
22106 // positional parameters, as specified in the Single Unix Specification.
22107 // RETURNS: the number of bytes printed.
22108 // <string>: the buffer to hold the output.
22109 // <format>: a standard printf() format string, but notice <link linkend="string-precision">string precision pitfalls</link>.
22110 // <args>: the list of arguments to insert in the output.
22111 static int vsprintf(char* string_, char* format, va_list args) {
22112 return g_vsprintf(string_, format, args);
22115 static void warn_message(char* domain, char* file, int line, char* func, char* warnexpr) {
22116 g_warn_message(domain, file, line, func, warnexpr);
22120 // C prototypes:
22122 extern (C) {
22123 void g_allocator_free(Allocator* this_);
22124 Allocator* g_allocator_new(char* name, uint n_preallocs);
22125 Array* g_array_append_vals(Array* array, const(void)* data, uint len);
22126 char* /*new*/ g_array_free(Array* array, int free_segment);
22127 uint g_array_get_element_size(Array* array);
22128 Array* g_array_insert_vals(Array* array, uint index_, const(void)* data, uint len);
22129 Array* g_array_new(int zero_terminated, int clear_, uint element_size);
22130 Array* g_array_prepend_vals(Array* array, const(void)* data, uint len);
22131 Array* g_array_ref(Array* array);
22132 Array* g_array_remove_index(Array* array, uint index_);
22133 Array* g_array_remove_index_fast(Array* array, uint index_);
22134 Array* g_array_remove_range(Array* array, uint index_, uint length);
22135 Array* g_array_set_size(Array* array, uint length);
22136 Array* g_array_sized_new(int zero_terminated, int clear_, uint element_size, uint reserved_size);
22137 void g_array_sort(Array* array, CompareFunc compare_func);
22138 void g_array_sort_with_data(Array* array, CompareDataFunc compare_func, void* user_data);
22139 void g_array_unref(Array* array);
22140 int g_async_queue_length(AsyncQueue* this_);
22141 int g_async_queue_length_unlocked(AsyncQueue* this_);
22142 void g_async_queue_lock(AsyncQueue* this_);
22143 void* g_async_queue_pop(AsyncQueue* this_);
22144 void* g_async_queue_pop_unlocked(AsyncQueue* this_);
22145 void g_async_queue_push(AsyncQueue* this_, void* data);
22146 void g_async_queue_push_sorted(AsyncQueue* this_, void* data, CompareDataFunc func, void* user_data);
22147 void g_async_queue_push_sorted_unlocked(AsyncQueue* this_, void* data, CompareDataFunc func, void* user_data);
22148 void g_async_queue_push_unlocked(AsyncQueue* this_, void* data);
22149 AsyncQueue* g_async_queue_ref(AsyncQueue* this_);
22150 void g_async_queue_ref_unlocked(AsyncQueue* this_);
22151 void g_async_queue_sort(AsyncQueue* this_, CompareDataFunc func, void* user_data);
22152 void g_async_queue_sort_unlocked(AsyncQueue* this_, CompareDataFunc func, void* user_data);
22153 void* g_async_queue_timed_pop(AsyncQueue* this_, TimeVal* end_time);
22154 void* g_async_queue_timed_pop_unlocked(AsyncQueue* this_, TimeVal* end_time);
22155 void* g_async_queue_try_pop(AsyncQueue* this_);
22156 void* g_async_queue_try_pop_unlocked(AsyncQueue* this_);
22157 void g_async_queue_unlock(AsyncQueue* this_);
22158 void g_async_queue_unref(AsyncQueue* this_);
22159 void g_async_queue_unref_and_unlock(AsyncQueue* this_);
22160 AsyncQueue* g_async_queue_new();
22161 AsyncQueue* g_async_queue_new_full(DestroyNotify item_free_func);
22162 void g_bookmark_file_add_application(BookmarkFile* this_, char* uri, char* name, char* exec);
22163 void g_bookmark_file_add_group(BookmarkFile* this_, char* uri, char* group);
22164 void g_bookmark_file_free(BookmarkFile* this_);
22165 time_t g_bookmark_file_get_added(BookmarkFile* this_, char* uri, GLib2.Error** error);
22166 int g_bookmark_file_get_app_info(BookmarkFile* this_, char* uri, char* name, char** exec, uint* count, time_t* stamp, GLib2.Error** error);
22167 char** g_bookmark_file_get_applications(BookmarkFile* this_, char* uri, size_t* length, GLib2.Error** error);
22168 char* /*new*/ g_bookmark_file_get_description(BookmarkFile* this_, char* uri, GLib2.Error** error);
22169 char** g_bookmark_file_get_groups(BookmarkFile* this_, char* uri, size_t* length, GLib2.Error** error);
22170 int g_bookmark_file_get_icon(BookmarkFile* this_, char* uri, char** href, char** mime_type, GLib2.Error** error);
22171 int g_bookmark_file_get_is_private(BookmarkFile* this_, char* uri, GLib2.Error** error);
22172 char* /*new*/ g_bookmark_file_get_mime_type(BookmarkFile* this_, char* uri, GLib2.Error** error);
22173 time_t g_bookmark_file_get_modified(BookmarkFile* this_, char* uri, GLib2.Error** error);
22174 int g_bookmark_file_get_size(BookmarkFile* this_);
22175 char* /*new*/ g_bookmark_file_get_title(BookmarkFile* this_, char* uri, GLib2.Error** error);
22176 char** g_bookmark_file_get_uris(BookmarkFile* this_, size_t* length);
22177 time_t g_bookmark_file_get_visited(BookmarkFile* this_, char* uri, GLib2.Error** error);
22178 int g_bookmark_file_has_application(BookmarkFile* this_, char* uri, char* name, GLib2.Error** error);
22179 int g_bookmark_file_has_group(BookmarkFile* this_, char* uri, char* group, GLib2.Error** error);
22180 int g_bookmark_file_has_item(BookmarkFile* this_, char* uri);
22181 int g_bookmark_file_load_from_data(BookmarkFile* this_, char* data, size_t length, GLib2.Error** error);
22182 int g_bookmark_file_load_from_data_dirs(BookmarkFile* this_, char* file, char** full_path, GLib2.Error** error);
22183 int g_bookmark_file_load_from_file(BookmarkFile* this_, char* filename, GLib2.Error** error);
22184 int g_bookmark_file_move_item(BookmarkFile* this_, char* old_uri, char* new_uri, GLib2.Error** error);
22185 int g_bookmark_file_remove_application(BookmarkFile* this_, char* uri, char* name, GLib2.Error** error);
22186 int g_bookmark_file_remove_group(BookmarkFile* this_, char* uri, char* group, GLib2.Error** error);
22187 int g_bookmark_file_remove_item(BookmarkFile* this_, char* uri, GLib2.Error** error);
22188 void g_bookmark_file_set_added(BookmarkFile* this_, char* uri, time_t added);
22189 int g_bookmark_file_set_app_info(BookmarkFile* this_, char* uri, char* name, char* exec, int count, time_t stamp, GLib2.Error** error);
22190 void g_bookmark_file_set_description(BookmarkFile* this_, char* uri, char* description);
22191 void g_bookmark_file_set_groups(BookmarkFile* this_, char* uri, char** groups, size_t length);
22192 void g_bookmark_file_set_icon(BookmarkFile* this_, char* uri, char* href, char* mime_type);
22193 void g_bookmark_file_set_is_private(BookmarkFile* this_, char* uri, int is_private);
22194 void g_bookmark_file_set_mime_type(BookmarkFile* this_, char* uri, char* mime_type);
22195 void g_bookmark_file_set_modified(BookmarkFile* this_, char* uri, time_t modified);
22196 void g_bookmark_file_set_title(BookmarkFile* this_, char* uri, char* title);
22197 void g_bookmark_file_set_visited(BookmarkFile* this_, char* uri, time_t visited);
22198 char* /*new*/ g_bookmark_file_to_data(BookmarkFile* this_, size_t* length, GLib2.Error** error);
22199 int g_bookmark_file_to_file(BookmarkFile* this_, char* filename, GLib2.Error** error);
22200 Quark g_bookmark_file_error_quark();
22201 BookmarkFile* g_bookmark_file_new();
22202 ByteArray* g_byte_array_append(ByteArray* array, ubyte* data, uint len);
22203 ubyte* g_byte_array_free(ByteArray* array, int free_segment);
22204 ByteArray* g_byte_array_new();
22205 ByteArray* g_byte_array_prepend(ByteArray* array, ubyte* data, uint len);
22206 ByteArray* g_byte_array_ref(ByteArray* array);
22207 ByteArray* g_byte_array_remove_index(ByteArray* array, uint index_);
22208 ByteArray* g_byte_array_remove_index_fast(ByteArray* array, uint index_);
22209 ByteArray* g_byte_array_remove_range(ByteArray* array, uint index_, uint length);
22210 ByteArray* g_byte_array_set_size(ByteArray* array, uint length);
22211 ByteArray* g_byte_array_sized_new(uint reserved_size);
22212 void g_byte_array_sort(ByteArray* array, CompareFunc compare_func);
22213 void g_byte_array_sort_with_data(ByteArray* array, CompareDataFunc compare_func, void* user_data);
22214 void g_byte_array_unref(ByteArray* array);
22215 void g_cache_destroy(Cache* this_);
22216 void* g_cache_insert(Cache* this_, void* key);
22217 void g_cache_key_foreach(Cache* this_, HFunc func, void* user_data);
22218 void g_cache_remove(Cache* this_, const(void)* value);
22219 void g_cache_value_foreach(Cache* this_, HFunc func, void* user_data);
22220 Cache* g_cache_new(CacheNewFunc value_new_func, CacheDestroyFunc value_destroy_func, CacheDupFunc key_dup_func, CacheDestroyFunc key_destroy_func, HashFunc hash_key_func, HashFunc hash_value_func, EqualFunc key_equal_func);
22221 Checksum* g_checksum_copy(Checksum* this_);
22222 void g_checksum_free(Checksum* this_);
22223 void g_checksum_get_digest(Checksum* this_, ubyte* buffer, size_t* digest_len);
22224 char* g_checksum_get_string(Checksum* this_);
22225 void g_checksum_reset(Checksum* this_);
22226 void g_checksum_update(Checksum* this_, ubyte* data, ssize_t length);
22227 Checksum* g_checksum_new(ChecksumType checksum_type);
22228 ssize_t g_checksum_type_get_length(ChecksumType checksum_type);
22229 void g_completion_add_items(Completion* this_, GLib2.List* items);
22230 void g_completion_clear_items(Completion* this_);
22231 GLib2.List* g_completion_complete(Completion* this_, char* prefix, char** new_prefix);
22232 GLib2.List* g_completion_complete_utf8(Completion* this_, char* prefix, char** new_prefix);
22233 void g_completion_free(Completion* this_);
22234 void g_completion_remove_items(Completion* this_, GLib2.List* items);
22235 void g_completion_set_compare(Completion* this_, CompletionStrncmpFunc strncmp_func);
22236 Completion* g_completion_new(CompletionFunc func);
22237 Date* /*new*/ g_date_new();
22238 Date* /*new*/ g_date_new_dmy(DateDay day, DateMonth month, DateYear year);
22239 Date* /*new*/ g_date_new_julian(uint julian_day);
22240 void g_date_add_days(Date* this_, uint n_days);
22241 void g_date_add_months(Date* this_, uint n_months);
22242 void g_date_add_years(Date* this_, uint n_years);
22243 void g_date_clamp(Date* this_, Date* min_date, Date* max_date);
22244 void g_date_clear(Date* this_, uint n_dates);
22245 int g_date_compare(Date* this_, Date* rhs);
22246 int g_date_days_between(Date* this_, Date* date2);
22247 void g_date_free(Date* this_);
22248 DateDay g_date_get_day(Date* this_);
22249 uint g_date_get_day_of_year(Date* this_);
22250 uint g_date_get_iso8601_week_of_year(Date* this_);
22251 uint g_date_get_julian(Date* this_);
22252 uint g_date_get_monday_week_of_year(Date* this_);
22253 DateMonth g_date_get_month(Date* this_);
22254 uint g_date_get_sunday_week_of_year(Date* this_);
22255 DateWeekday g_date_get_weekday(Date* this_);
22256 DateYear g_date_get_year(Date* this_);
22257 int g_date_is_first_of_month(Date* this_);
22258 int g_date_is_last_of_month(Date* this_);
22259 void g_date_order(Date* this_, Date* date2);
22260 void g_date_set_day(Date* this_, DateDay day);
22261 void g_date_set_dmy(Date* this_, DateDay day, DateMonth month, DateYear y);
22262 void g_date_set_julian(Date* this_, uint julian_date);
22263 void g_date_set_month(Date* this_, DateMonth month);
22264 void g_date_set_parse(Date* this_, char* str);
22265 void g_date_set_time(Date* this_, Time time_);
22266 void g_date_set_time_t(Date* this_, time_t timet);
22267 void g_date_set_time_val(Date* this_, TimeVal* timeval);
22268 void g_date_set_year(Date* this_, DateYear year);
22269 void g_date_subtract_days(Date* this_, uint n_days);
22270 void g_date_subtract_months(Date* this_, uint n_months);
22271 void g_date_subtract_years(Date* this_, uint n_years);
22272 void g_date_to_struct_tm(Date* this_, void** tm);
22273 int g_date_valid(Date* this_);
22274 ubyte g_date_get_days_in_month(DateMonth month, DateYear year);
22275 ubyte g_date_get_monday_weeks_in_year(DateYear year);
22276 ubyte g_date_get_sunday_weeks_in_year(DateYear year);
22277 int g_date_is_leap_year(DateYear year);
22278 size_t g_date_strftime(char* s, size_t slen, char* format, Date* date);
22279 int g_date_valid_day(DateDay day);
22280 int g_date_valid_dmy(DateDay day, DateMonth month, DateYear year);
22281 int g_date_valid_julian(uint julian_date);
22282 int g_date_valid_month(DateMonth month);
22283 int g_date_valid_weekday(DateWeekday weekday);
22284 int g_date_valid_year(DateYear year);
22285 DateTime* /*new*/ g_date_time_new(TimeZone* tz, int year, int month, int day, int hour, int minute, double seconds);
22286 DateTime* /*new*/ g_date_time_new_from_timeval_local(TimeVal* tv);
22287 DateTime* /*new*/ g_date_time_new_from_timeval_utc(TimeVal* tv);
22288 DateTime* /*new*/ g_date_time_new_from_unix_local(long t);
22289 DateTime* /*new*/ g_date_time_new_from_unix_utc(long t);
22290 DateTime* /*new*/ g_date_time_new_local(int year, int month, int day, int hour, int minute, double seconds);
22291 DateTime* /*new*/ g_date_time_new_now(TimeZone* tz);
22292 DateTime* /*new*/ g_date_time_new_now_local();
22293 DateTime* /*new*/ g_date_time_new_now_utc();
22294 DateTime* /*new*/ g_date_time_new_utc(int year, int month, int day, int hour, int minute, double seconds);
22295 DateTime* /*new*/ g_date_time_add(DateTime* this_, TimeSpan timespan);
22296 DateTime* /*new*/ g_date_time_add_days(DateTime* this_, int days);
22297 DateTime* /*new*/ g_date_time_add_full(DateTime* this_, int years, int months, int days, int hours, int minutes, double seconds);
22298 DateTime* /*new*/ g_date_time_add_hours(DateTime* this_, int hours);
22299 DateTime* /*new*/ g_date_time_add_minutes(DateTime* this_, int minutes);
22300 DateTime* /*new*/ g_date_time_add_months(DateTime* this_, int months);
22301 DateTime* /*new*/ g_date_time_add_seconds(DateTime* this_, double seconds);
22302 DateTime* /*new*/ g_date_time_add_weeks(DateTime* this_, int weeks);
22303 DateTime* /*new*/ g_date_time_add_years(DateTime* this_, int years);
22304 TimeSpan g_date_time_difference(DateTime* this_, DateTime* begin);
22305 char* /*new*/ g_date_time_format(DateTime* this_, char* format);
22306 int g_date_time_get_day_of_month(DateTime* this_);
22307 int g_date_time_get_day_of_week(DateTime* this_);
22308 int g_date_time_get_day_of_year(DateTime* this_);
22309 int g_date_time_get_hour(DateTime* this_);
22310 int g_date_time_get_microsecond(DateTime* this_);
22311 int g_date_time_get_minute(DateTime* this_);
22312 int g_date_time_get_month(DateTime* this_);
22313 int g_date_time_get_second(DateTime* this_);
22314 double g_date_time_get_seconds(DateTime* this_);
22315 char* g_date_time_get_timezone_abbreviation(DateTime* this_);
22316 TimeSpan g_date_time_get_utc_offset(DateTime* this_);
22317 int g_date_time_get_week_numbering_year(DateTime* this_);
22318 int g_date_time_get_week_of_year(DateTime* this_);
22319 int g_date_time_get_year(DateTime* this_);
22320 void g_date_time_get_ymd(DateTime* this_, /*out*/ int* year, /*out*/ int* month, /*out*/ int* day);
22321 int g_date_time_is_daylight_savings(DateTime* this_);
22322 DateTime* /*new*/ g_date_time_ref(DateTime* this_);
22323 DateTime* /*new*/ g_date_time_to_local(DateTime* this_);
22324 int g_date_time_to_timeval(DateTime* this_, TimeVal* tv);
22325 DateTime* /*new*/ g_date_time_to_timezone(DateTime* this_, TimeZone* tz);
22326 long g_date_time_to_unix(DateTime* this_);
22327 DateTime* /*new*/ g_date_time_to_utc(DateTime* this_);
22328 void g_date_time_unref(DateTime* this_);
22329 int g_date_time_compare(const(void)* dt1, const(void)* dt2);
22330 int g_date_time_equal(const(void)* dt1, const(void)* dt2);
22331 uint g_date_time_hash(const(void)* datetime);
22332 void g_dir_close(Dir* this_);
22333 char* g_dir_read_name(Dir* this_);
22334 void g_dir_rewind(Dir* this_);
22335 char* /*new*/ g_dir_make_tmp(char* tmpl, GLib2.Error** error);
22336 Dir* g_dir_open(char* path, uint flags, GLib2.Error** error);
22337 Error* /*new*/ g_error_new(Quark domain, int code, char* format, ...);
22338 Error* /*new*/ g_error_new_literal(Quark domain, int code, char* message);
22339 Error* /*new*/ g_error_new_valist(Quark domain, int code, char* format, va_list args);
22340 Error* /*new*/ g_error_copy(Error* this_);
22341 void g_error_free(Error* this_);
22342 int g_error_matches(Error* this_, Quark domain, int code);
22343 void g_hash_table_destroy(GLib2.HashTable* hash_table);
22344 void* g_hash_table_find(GLib2.HashTable* hash_table, HRFunc predicate, void* user_data);
22345 void g_hash_table_foreach(GLib2.HashTable* hash_table, HFunc func, void* user_data);
22346 uint g_hash_table_foreach_remove(GLib2.HashTable* hash_table, HRFunc func, void* user_data);
22347 uint g_hash_table_foreach_steal(GLib2.HashTable* hash_table, HRFunc func, void* user_data);
22348 GLib2.List* g_hash_table_get_keys(GLib2.HashTable* hash_table);
22349 GLib2.List* g_hash_table_get_values(GLib2.HashTable* hash_table);
22350 void g_hash_table_insert(GLib2.HashTable* hash_table, void* key, void* value);
22351 void* g_hash_table_lookup(GLib2.HashTable* hash_table, const(void)* key);
22352 int g_hash_table_lookup_extended(GLib2.HashTable* hash_table, const(void)* lookup_key, void** orig_key, void** value);
22353 GLib2.HashTable* g_hash_table_new(HashFunc hash_func, EqualFunc key_equal_func);
22354 GLib2.HashTable* g_hash_table_new_full(HashFunc hash_func, EqualFunc key_equal_func, DestroyNotify key_destroy_func, DestroyNotify value_destroy_func);
22355 GLib2.HashTable* g_hash_table_ref(GLib2.HashTable* hash_table);
22356 int g_hash_table_remove(GLib2.HashTable* hash_table, const(void)* key);
22357 void g_hash_table_remove_all(GLib2.HashTable* hash_table);
22358 void g_hash_table_replace(GLib2.HashTable* hash_table, void* key, void* value);
22359 uint g_hash_table_size(GLib2.HashTable* hash_table);
22360 int g_hash_table_steal(GLib2.HashTable* hash_table, const(void)* key);
22361 void g_hash_table_steal_all(GLib2.HashTable* hash_table);
22362 void g_hash_table_unref(GLib2.HashTable* hash_table);
22363 GLib2.HashTable* g_hash_table_iter_get_hash_table(HashTableIter* this_);
22364 void g_hash_table_iter_init(HashTableIter* this_, GLib2.HashTable* hash_table);
22365 int g_hash_table_iter_next(HashTableIter* this_, void** key, void** value);
22366 void g_hash_table_iter_remove(HashTableIter* this_);
22367 void g_hash_table_iter_replace(HashTableIter* this_, void* value);
22368 void g_hash_table_iter_steal(HashTableIter* this_);
22369 Hmac* g_hmac_copy(Hmac* this_);
22370 void g_hmac_get_digest(Hmac* this_, ubyte* buffer, size_t* digest_len);
22371 char* g_hmac_get_string(Hmac* this_);
22372 Hmac* g_hmac_ref(Hmac* this_);
22373 void g_hmac_unref(Hmac* this_);
22374 void g_hmac_update(Hmac* this_, ubyte* data, ssize_t length);
22375 Hmac* g_hmac_new(ChecksumType digest_type, ubyte* key, size_t key_len);
22376 int g_hook_compare_ids(Hook* this_, Hook* sibling);
22377 Hook* g_hook_alloc(HookList* hook_list);
22378 int g_hook_destroy(HookList* hook_list, c_ulong hook_id);
22379 void g_hook_destroy_link(HookList* hook_list, Hook* hook);
22380 Hook* g_hook_find(HookList* hook_list, int need_valids, HookFindFunc func, void* data);
22381 Hook* g_hook_find_data(HookList* hook_list, int need_valids, void* data);
22382 Hook* g_hook_find_func(HookList* hook_list, int need_valids, void* func);
22383 Hook* g_hook_find_func_data(HookList* hook_list, int need_valids, void* func, void* data);
22384 Hook* g_hook_first_valid(HookList* hook_list, int may_be_in_call);
22385 void g_hook_free(HookList* hook_list, Hook* hook);
22386 Hook* g_hook_get(HookList* hook_list, c_ulong hook_id);
22387 void g_hook_insert_before(HookList* hook_list, Hook* sibling, Hook* hook);
22388 void g_hook_insert_sorted(HookList* hook_list, Hook* hook, HookCompareFunc func);
22389 Hook* g_hook_next_valid(HookList* hook_list, Hook* hook, int may_be_in_call);
22390 void g_hook_prepend(HookList* hook_list, Hook* hook);
22391 Hook* g_hook_ref(HookList* hook_list, Hook* hook);
22392 void g_hook_unref(HookList* hook_list, Hook* hook);
22393 void g_hook_list_clear(HookList* this_);
22394 void g_hook_list_init(HookList* this_, uint hook_size);
22395 void g_hook_list_invoke(HookList* this_, int may_recurse);
22396 void g_hook_list_invoke_check(HookList* this_, int may_recurse);
22397 void g_hook_list_marshal(HookList* this_, int may_recurse, HookMarshaller marshaller, void* marshal_data);
22398 void g_hook_list_marshal_check(HookList* this_, int may_recurse, HookCheckMarshaller marshaller, void* marshal_data);
22399 size_t g_iconv(IConv* this_, char** inbuf, size_t* inbytes_left, char** outbuf, size_t* outbytes_left);
22400 int g_iconv_close(IConv* this_);
22401 IConv g_iconv_open(char* to_codeset, char* from_codeset);
22402 IOChannel* /*new*/ g_io_channel_new_file(char* filename, char* mode, GLib2.Error** error);
22403 IOChannel* /*new*/ g_io_channel_unix_new(int fd);
22404 void g_io_channel_close(IOChannel* this_);
22405 IOStatus g_io_channel_flush(IOChannel* this_, GLib2.Error** error);
22406 IOCondition g_io_channel_get_buffer_condition(IOChannel* this_);
22407 size_t g_io_channel_get_buffer_size(IOChannel* this_);
22408 int g_io_channel_get_buffered(IOChannel* this_);
22409 int g_io_channel_get_close_on_unref(IOChannel* this_);
22410 char* g_io_channel_get_encoding(IOChannel* this_);
22411 IOFlags g_io_channel_get_flags(IOChannel* this_);
22412 char* g_io_channel_get_line_term(IOChannel* this_, int* length);
22413 void g_io_channel_init(IOChannel* this_);
22414 IOError g_io_channel_read(IOChannel* this_, char* buf, size_t count, size_t* bytes_read);
22415 IOStatus g_io_channel_read_chars(IOChannel* this_, char* buf, size_t count, size_t* bytes_read, GLib2.Error** error);
22416 IOStatus g_io_channel_read_line(IOChannel* this_, char** str_return, size_t* length, size_t* terminator_pos, GLib2.Error** error);
22417 IOStatus g_io_channel_read_line_string(IOChannel* this_, String* buffer, size_t* terminator_pos, GLib2.Error** error);
22418 IOStatus g_io_channel_read_to_end(IOChannel* this_, char** str_return, size_t* length, GLib2.Error** error);
22419 IOStatus g_io_channel_read_unichar(IOChannel* this_, dchar* thechar, GLib2.Error** error);
22420 IOChannel* /*new*/ g_io_channel_ref(IOChannel* this_);
22421 IOError g_io_channel_seek(IOChannel* this_, long offset, SeekType type);
22422 IOStatus g_io_channel_seek_position(IOChannel* this_, long offset, SeekType type, GLib2.Error** error);
22423 void g_io_channel_set_buffer_size(IOChannel* this_, size_t size);
22424 void g_io_channel_set_buffered(IOChannel* this_, int buffered);
22425 void g_io_channel_set_close_on_unref(IOChannel* this_, int do_close);
22426 IOStatus g_io_channel_set_encoding(IOChannel* this_, char* encoding, GLib2.Error** error);
22427 IOStatus g_io_channel_set_flags(IOChannel* this_, IOFlags flags, GLib2.Error** error);
22428 void g_io_channel_set_line_term(IOChannel* this_, char* line_term, int length);
22429 IOStatus g_io_channel_shutdown(IOChannel* this_, int flush, GLib2.Error** error);
22430 int g_io_channel_unix_get_fd(IOChannel* this_);
22431 void g_io_channel_unref(IOChannel* this_);
22432 IOError g_io_channel_write(IOChannel* this_, char* buf, size_t count, size_t* bytes_written);
22433 IOStatus g_io_channel_write_chars(IOChannel* this_, char* buf, ssize_t count, size_t* bytes_written, GLib2.Error** error);
22434 IOStatus g_io_channel_write_unichar(IOChannel* this_, dchar thechar, GLib2.Error** error);
22435 IOChannelError g_io_channel_error_from_errno(int en);
22436 Quark g_io_channel_error_quark();
22437 void g_key_file_free(KeyFile* this_);
22438 int g_key_file_get_boolean(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
22439 int* /*new container*/ g_key_file_get_boolean_list(KeyFile* this_, char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error);
22440 char* /*new*/ g_key_file_get_comment(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
22441 double g_key_file_get_double(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
22442 double* /*new container*/ g_key_file_get_double_list(KeyFile* this_, char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error);
22443 char** g_key_file_get_groups(KeyFile* this_, size_t* length);
22444 long g_key_file_get_int64(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
22445 int g_key_file_get_integer(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
22446 int* /*new container*/ g_key_file_get_integer_list(KeyFile* this_, char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error);
22447 char** g_key_file_get_keys(KeyFile* this_, char* group_name, size_t* length, GLib2.Error** error);
22448 char* /*new*/ g_key_file_get_locale_string(KeyFile* this_, char* group_name, char* key, char* locale, GLib2.Error** error);
22449 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);
22450 char* /*new*/ g_key_file_get_start_group(KeyFile* this_);
22451 char* /*new*/ g_key_file_get_string(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
22452 char** /*new*/ g_key_file_get_string_list(KeyFile* this_, char* group_name, char* key, /*out*/ size_t* length, GLib2.Error** error);
22453 ulong g_key_file_get_uint64(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
22454 char* /*new*/ g_key_file_get_value(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
22455 int g_key_file_has_group(KeyFile* this_, char* group_name);
22456 int g_key_file_has_key(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
22457 int g_key_file_load_from_data(KeyFile* this_, char* data, size_t length, KeyFileFlags flags, GLib2.Error** error);
22458 int g_key_file_load_from_data_dirs(KeyFile* this_, char* file, char** full_path, KeyFileFlags flags, GLib2.Error** error);
22459 int g_key_file_load_from_dirs(KeyFile* this_, char* file, char** search_dirs, char** full_path, KeyFileFlags flags, GLib2.Error** error);
22460 int g_key_file_load_from_file(KeyFile* this_, char* file, KeyFileFlags flags, GLib2.Error** error);
22461 int g_key_file_remove_comment(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
22462 int g_key_file_remove_group(KeyFile* this_, char* group_name, GLib2.Error** error);
22463 int g_key_file_remove_key(KeyFile* this_, char* group_name, char* key, GLib2.Error** error);
22464 void g_key_file_set_boolean(KeyFile* this_, char* group_name, char* key, int value);
22465 void g_key_file_set_boolean_list(KeyFile* this_, char* group_name, char* key, int list, size_t length);
22466 int g_key_file_set_comment(KeyFile* this_, char* group_name, char* key, char* comment, GLib2.Error** error);
22467 void g_key_file_set_double(KeyFile* this_, char* group_name, char* key, double value);
22468 void g_key_file_set_double_list(KeyFile* this_, char* group_name, char* key, double list, size_t length);
22469 void g_key_file_set_int64(KeyFile* this_, char* group_name, char* key, long value);
22470 void g_key_file_set_integer(KeyFile* this_, char* group_name, char* key, int value);
22471 void g_key_file_set_integer_list(KeyFile* this_, char* group_name, char* key, int list, size_t length);
22472 void g_key_file_set_list_separator(KeyFile* this_, char separator);
22473 void g_key_file_set_locale_string(KeyFile* this_, char* group_name, char* key, char* locale, char* string_);
22474 void g_key_file_set_locale_string_list(KeyFile* this_, char* group_name, char* key, char* locale, char* list, size_t length);
22475 void g_key_file_set_string(KeyFile* this_, char* group_name, char* key, char* string_);
22476 void g_key_file_set_string_list(KeyFile* this_, char* group_name, char* key, char* list, size_t length);
22477 void g_key_file_set_uint64(KeyFile* this_, char* group_name, char* key, ulong value);
22478 void g_key_file_set_value(KeyFile* this_, char* group_name, char* key, char* value);
22479 char* /*new*/ g_key_file_to_data(KeyFile* this_, size_t* length, GLib2.Error** error);
22480 Quark g_key_file_error_quark();
22481 KeyFile* g_key_file_new();
22482 GLib2.List* g_list_alloc();
22483 GLib2.List* g_list_append(GLib2.List* list, void* data);
22484 GLib2.List* g_list_concat(GLib2.List* list1, GLib2.List* list2);
22485 GLib2.List* g_list_copy(GLib2.List* list);
22486 GLib2.List* g_list_delete_link(GLib2.List* list, GLib2.List* link_);
22487 GLib2.List* g_list_find(GLib2.List* list, const(void)* data);
22488 GLib2.List* g_list_find_custom(GLib2.List* list, const(void)* data, CompareFunc func);
22489 GLib2.List* g_list_first(GLib2.List* list);
22490 void g_list_foreach(GLib2.List* list, Func func, void* user_data);
22491 void g_list_free(GLib2.List* list);
22492 void g_list_free_1(GLib2.List* list);
22493 void g_list_free_full(GLib2.List* list, DestroyNotify free_func);
22494 int g_list_index(GLib2.List* list, const(void)* data);
22495 GLib2.List* g_list_insert(GLib2.List* list, void* data, int position);
22496 GLib2.List* g_list_insert_before(GLib2.List* list, GLib2.List* sibling, void* data);
22497 GLib2.List* g_list_insert_sorted(GLib2.List* list, void* data, CompareFunc func);
22498 GLib2.List* g_list_insert_sorted_with_data(GLib2.List* list, void* data, CompareDataFunc func, void* user_data);
22499 GLib2.List* g_list_last(GLib2.List* list);
22500 uint g_list_length(GLib2.List* list);
22501 GLib2.List* g_list_nth(GLib2.List* list, uint n);
22502 void* g_list_nth_data(GLib2.List* list, uint n);
22503 GLib2.List* g_list_nth_prev(GLib2.List* list, uint n);
22504 void g_list_pop_allocator();
22505 int g_list_position(GLib2.List* list, GLib2.List* llink);
22506 GLib2.List* g_list_prepend(GLib2.List* list, void* data);
22507 void g_list_push_allocator(void* allocator);
22508 GLib2.List* g_list_remove(GLib2.List* list, const(void)* data);
22509 GLib2.List* g_list_remove_all(GLib2.List* list, const(void)* data);
22510 GLib2.List* g_list_remove_link(GLib2.List* list, GLib2.List* llink);
22511 GLib2.List* g_list_reverse(GLib2.List* list);
22512 GLib2.List* g_list_sort(GLib2.List* list, CompareFunc compare_func);
22513 GLib2.List* g_list_sort_with_data(GLib2.List* list, CompareDataFunc compare_func, void* user_data);
22514 MainContext* /*new*/ g_main_context_new();
22515 int g_main_context_acquire(MainContext* this_);
22516 void g_main_context_add_poll(MainContext* this_, PollFD* fd, int priority);
22517 int g_main_context_check(MainContext* this_, int max_priority, PollFD* fds, int n_fds);
22518 void g_main_context_dispatch(MainContext* this_);
22519 Source* g_main_context_find_source_by_funcs_user_data(MainContext* this_, SourceFuncs* funcs, void* user_data);
22520 Source* g_main_context_find_source_by_id(MainContext* this_, uint source_id);
22521 Source* g_main_context_find_source_by_user_data(MainContext* this_, void* user_data);
22522 PollFunc g_main_context_get_poll_func(MainContext* this_);
22523 void g_main_context_invoke(MainContext* this_, SourceFunc function_, void* data);
22524 void g_main_context_invoke_full(MainContext* this_, int priority, SourceFunc function_, void* data, DestroyNotify notify);
22525 int g_main_context_is_owner(MainContext* this_);
22526 int g_main_context_iteration(MainContext* this_, int may_block);
22527 int g_main_context_pending(MainContext* this_);
22528 void g_main_context_pop_thread_default(MainContext* this_);
22529 int g_main_context_prepare(MainContext* this_, int* priority);
22530 void g_main_context_push_thread_default(MainContext* this_);
22531 int g_main_context_query(MainContext* this_, int max_priority, /*out*/ int* timeout_, /*out*/ PollFD* fds, /*out*/ int n_fds);
22532 MainContext* /*new*/ g_main_context_ref(MainContext* this_);
22533 void g_main_context_release(MainContext* this_);
22534 void g_main_context_remove_poll(MainContext* this_, PollFD* fd);
22535 void g_main_context_set_poll_func(MainContext* this_, PollFunc func);
22536 void g_main_context_unref(MainContext* this_);
22537 int g_main_context_wait(MainContext* this_, Cond* cond, Mutex* mutex);
22538 void g_main_context_wakeup(MainContext* this_);
22539 MainContext* g_main_context_default();
22540 MainContext* g_main_context_get_thread_default();
22541 MainLoop* /*new*/ g_main_loop_new(MainContext* context, int is_running);
22542 MainContext* g_main_loop_get_context(MainLoop* this_);
22543 int g_main_loop_is_running(MainLoop* this_);
22544 void g_main_loop_quit(MainLoop* this_);
22545 MainLoop* /*new*/ g_main_loop_ref(MainLoop* this_);
22546 void g_main_loop_run(MainLoop* this_);
22547 void g_main_loop_unref(MainLoop* this_);
22548 void g_mapped_file_free(MappedFile* this_);
22549 char* /*new*/ g_mapped_file_get_contents(MappedFile* this_);
22550 size_t g_mapped_file_get_length(MappedFile* this_);
22551 MappedFile* g_mapped_file_ref(MappedFile* this_);
22552 void g_mapped_file_unref(MappedFile* this_);
22553 MappedFile* g_mapped_file_new(char* filename, int writable, GLib2.Error** error);
22554 int g_markup_parse_context_end_parse(MarkupParseContext* this_, GLib2.Error** error);
22555 void g_markup_parse_context_free(MarkupParseContext* this_);
22556 char* g_markup_parse_context_get_element(MarkupParseContext* this_);
22557 GLib2.SList* g_markup_parse_context_get_element_stack(MarkupParseContext* this_);
22558 void g_markup_parse_context_get_position(MarkupParseContext* this_, int* line_number=null, int* char_number=null);
22559 void* g_markup_parse_context_get_user_data(MarkupParseContext* this_);
22560 int g_markup_parse_context_parse(MarkupParseContext* this_, char* text, ssize_t text_len, GLib2.Error** error);
22561 void* g_markup_parse_context_pop(MarkupParseContext* this_);
22562 void g_markup_parse_context_push(MarkupParseContext* this_, MarkupParser* parser, void* user_data);
22563 MarkupParseContext* g_markup_parse_context_new(MarkupParser* parser, MarkupParseFlags flags, void* user_data, DestroyNotify user_data_dnotify);
22564 char* /*new*/ g_match_info_expand_references(MatchInfo* this_, char* string_to_expand, GLib2.Error** error);
22565 char* /*new*/ g_match_info_fetch(MatchInfo* this_, int match_num);
22566 char** g_match_info_fetch_all(MatchInfo* this_);
22567 char* /*new*/ g_match_info_fetch_named(MatchInfo* this_, char* name);
22568 int g_match_info_fetch_named_pos(MatchInfo* this_, char* name, /*out*/ int* start_pos=null, /*out*/ int* end_pos=null);
22569 int g_match_info_fetch_pos(MatchInfo* this_, int match_num, /*out*/ int* start_pos=null, /*out*/ int* end_pos=null);
22570 void g_match_info_free(MatchInfo* this_);
22571 int g_match_info_get_match_count(MatchInfo* this_);
22572 Regex* /*new*/ g_match_info_get_regex(MatchInfo* this_);
22573 char* g_match_info_get_string(MatchInfo* this_);
22574 int g_match_info_is_partial_match(MatchInfo* this_);
22575 int g_match_info_matches(MatchInfo* this_);
22576 int g_match_info_next(MatchInfo* this_, GLib2.Error** error);
22577 MatchInfo* /*new*/ g_match_info_ref(MatchInfo* this_);
22578 void g_match_info_unref(MatchInfo* this_);
22579 void* g_mem_chunk_alloc(MemChunk* this_);
22580 void* g_mem_chunk_alloc0(MemChunk* this_);
22581 void g_mem_chunk_clean(MemChunk* this_);
22582 void g_mem_chunk_destroy(MemChunk* this_);
22583 void g_mem_chunk_free(MemChunk* this_, void* mem);
22584 void g_mem_chunk_print(MemChunk* this_);
22585 void g_mem_chunk_reset(MemChunk* this_);
22586 void g_mem_chunk_info();
22587 MemChunk* g_mem_chunk_new(char* name, int atom_size, size_t area_size, int type);
22588 int g_node_child_index(Node* this_, void* data);
22589 int g_node_child_position(Node* this_, Node* child);
22590 void g_node_children_foreach(Node* this_, TraverseFlags flags, NodeForeachFunc func, void* data);
22591 Node* g_node_copy(Node* this_);
22592 Node* g_node_copy_deep(Node* this_, CopyFunc copy_func, void* data);
22593 uint g_node_depth(Node* this_);
22594 void g_node_destroy(Node* this_);
22595 Node* g_node_find(Node* this_, TraverseType order, TraverseFlags flags, void* data);
22596 Node* g_node_find_child(Node* this_, TraverseFlags flags, void* data);
22597 Node* g_node_first_sibling(Node* this_);
22598 Node* g_node_get_root(Node* this_);
22599 Node* g_node_insert(Node* this_, int position, Node* node);
22600 Node* g_node_insert_after(Node* this_, Node* sibling, Node* node);
22601 Node* g_node_insert_before(Node* this_, Node* sibling, Node* node);
22602 int g_node_is_ancestor(Node* this_, Node* descendant);
22603 Node* g_node_last_child(Node* this_);
22604 Node* g_node_last_sibling(Node* this_);
22605 uint g_node_max_height(Node* this_);
22606 uint g_node_n_children(Node* this_);
22607 uint g_node_n_nodes(Node* this_, TraverseFlags flags);
22608 Node* g_node_nth_child(Node* this_, uint n);
22609 Node* g_node_prepend(Node* this_, Node* node);
22610 void g_node_reverse_children(Node* this_);
22611 void g_node_traverse(Node* this_, TraverseType order, TraverseFlags flags, int max_depth, NodeTraverseFunc func, void* data);
22612 void g_node_unlink(Node* this_);
22613 Node* g_node_new(void* data);
22614 void g_node_pop_allocator();
22615 void g_node_push_allocator(void* dummy);
22616 void* g_once_impl(Once* this_, ThreadFunc func, void* arg);
22617 int g_once_init_enter(size_t* value_location);
22618 int g_once_init_enter_impl(size_t* value_location);
22619 void g_once_init_leave(size_t* value_location, size_t initialization_value);
22620 void g_option_context_add_group(OptionContext* this_, OptionGroup* group);
22621 void g_option_context_add_main_entries(OptionContext* this_, OptionEntry* entries, char* translation_domain);
22622 void g_option_context_free(OptionContext* this_);
22623 char* g_option_context_get_description(OptionContext* this_);
22624 char* /*new*/ g_option_context_get_help(OptionContext* this_, int main_help, OptionGroup* group);
22625 int g_option_context_get_help_enabled(OptionContext* this_);
22626 int g_option_context_get_ignore_unknown_options(OptionContext* this_);
22627 OptionGroup* g_option_context_get_main_group(OptionContext* this_);
22628 char* g_option_context_get_summary(OptionContext* this_);
22629 int g_option_context_parse(OptionContext* this_, /*inout*/ int* argc, /*inout*/ char*** argv, GLib2.Error** error);
22630 void g_option_context_set_description(OptionContext* this_, char* description);
22631 void g_option_context_set_help_enabled(OptionContext* this_, int help_enabled);
22632 void g_option_context_set_ignore_unknown_options(OptionContext* this_, int ignore_unknown);
22633 void g_option_context_set_main_group(OptionContext* this_, OptionGroup* group);
22634 void g_option_context_set_summary(OptionContext* this_, char* summary);
22635 void g_option_context_set_translate_func(OptionContext* this_, TranslateFunc func, void* data, DestroyNotify destroy_notify);
22636 void g_option_context_set_translation_domain(OptionContext* this_, char* domain);
22637 OptionContext* g_option_context_new(char* parameter_string);
22638 void g_option_group_add_entries(OptionGroup* this_, OptionEntry* entries);
22639 void g_option_group_free(OptionGroup* this_);
22640 void g_option_group_set_error_hook(OptionGroup* this_, OptionErrorFunc error_func);
22641 void g_option_group_set_parse_hooks(OptionGroup* this_, OptionParseFunc pre_parse_func, OptionParseFunc post_parse_func);
22642 void g_option_group_set_translate_func(OptionGroup* this_, TranslateFunc func, void* data, DestroyNotify destroy_notify);
22643 void g_option_group_set_translation_domain(OptionGroup* this_, char* domain);
22644 OptionGroup* g_option_group_new(char* name, char* description, char* help_description, void* user_data, DestroyNotify destroy);
22645 int g_pattern_spec_equal(PatternSpec* this_, PatternSpec* pspec2);
22646 void g_pattern_spec_free(PatternSpec* this_);
22647 PatternSpec* g_pattern_spec_new(char* pattern);
22648 void g_ptr_array_add(PtrArray* array, void* data);
22649 void g_ptr_array_foreach(PtrArray* array, Func func, void* user_data);
22650 void** g_ptr_array_free(PtrArray* array, int free_seg);
22651 PtrArray* g_ptr_array_new();
22652 PtrArray* g_ptr_array_new_full(uint reserved_size, DestroyNotify element_free_func);
22653 PtrArray* g_ptr_array_new_with_free_func(DestroyNotify element_free_func);
22654 PtrArray* g_ptr_array_ref(PtrArray* array);
22655 int g_ptr_array_remove(PtrArray* array, void* data);
22656 int g_ptr_array_remove_fast(PtrArray* array, void* data);
22657 void* g_ptr_array_remove_index(PtrArray* array, uint index_);
22658 void* g_ptr_array_remove_index_fast(PtrArray* array, uint index_);
22659 void g_ptr_array_remove_range(PtrArray* array, uint index_, uint length);
22660 void g_ptr_array_set_free_func(PtrArray* array, DestroyNotify element_free_func);
22661 void g_ptr_array_set_size(PtrArray* array, int length);
22662 PtrArray* g_ptr_array_sized_new(uint reserved_size);
22663 void g_ptr_array_sort(PtrArray* array, CompareFunc compare_func);
22664 void g_ptr_array_sort_with_data(PtrArray* array, CompareDataFunc compare_func, void* user_data);
22665 void g_ptr_array_unref(PtrArray* array);
22666 void g_queue_clear(Queue* this_);
22667 Queue* g_queue_copy(Queue* this_);
22668 void g_queue_delete_link(Queue* this_, GLib2.List* link_);
22669 GLib2.List* g_queue_find(Queue* this_, const(void)* data);
22670 GLib2.List* g_queue_find_custom(Queue* this_, const(void)* data, CompareFunc func);
22671 void g_queue_foreach(Queue* this_, Func func, void* user_data);
22672 void g_queue_free(Queue* this_);
22673 uint g_queue_get_length(Queue* this_);
22674 int g_queue_index(Queue* this_, const(void)* data);
22675 void g_queue_init(Queue* this_);
22676 void g_queue_insert_after(Queue* this_, GLib2.List* sibling, void* data);
22677 void g_queue_insert_before(Queue* this_, GLib2.List* sibling, void* data);
22678 void g_queue_insert_sorted(Queue* this_, void* data, CompareDataFunc func, void* user_data);
22679 int g_queue_is_empty(Queue* this_);
22680 int g_queue_link_index(Queue* this_, GLib2.List* link_);
22681 void* g_queue_peek_head(Queue* this_);
22682 GLib2.List* g_queue_peek_head_link(Queue* this_);
22683 void* g_queue_peek_nth(Queue* this_, uint n);
22684 GLib2.List* g_queue_peek_nth_link(Queue* this_, uint n);
22685 void* g_queue_peek_tail(Queue* this_);
22686 GLib2.List* g_queue_peek_tail_link(Queue* this_);
22687 void* g_queue_pop_head(Queue* this_);
22688 GLib2.List* g_queue_pop_head_link(Queue* this_);
22689 void* g_queue_pop_nth(Queue* this_, uint n);
22690 GLib2.List* g_queue_pop_nth_link(Queue* this_, uint n);
22691 void* g_queue_pop_tail(Queue* this_);
22692 GLib2.List* g_queue_pop_tail_link(Queue* this_);
22693 void g_queue_push_head(Queue* this_, void* data);
22694 void g_queue_push_head_link(Queue* this_, GLib2.List* link_);
22695 void g_queue_push_nth(Queue* this_, void* data, int n);
22696 void g_queue_push_nth_link(Queue* this_, int n, GLib2.List* link_);
22697 void g_queue_push_tail(Queue* this_, void* data);
22698 void g_queue_push_tail_link(Queue* this_, GLib2.List* link_);
22699 int g_queue_remove(Queue* this_, const(void)* data);
22700 uint g_queue_remove_all(Queue* this_, const(void)* data);
22701 void g_queue_reverse(Queue* this_);
22702 void g_queue_sort(Queue* this_, CompareDataFunc compare_func, void* user_data);
22703 void g_queue_unlink(Queue* this_, GLib2.List* link_);
22704 Queue* g_queue_new();
22705 Rand* g_rand_copy(Rand* this_);
22706 double g_rand_double(Rand* this_);
22707 double g_rand_double_range(Rand* this_, double begin, double end);
22708 void g_rand_free(Rand* this_);
22709 uint g_rand_int(Rand* this_);
22710 int g_rand_int_range(Rand* this_, int begin, int end);
22711 void g_rand_set_seed(Rand* this_, uint seed);
22712 void g_rand_set_seed_array(Rand* this_, uint* seed, uint seed_length);
22713 Rand* g_rand_new();
22714 Rand* g_rand_new_with_seed(uint seed);
22715 Rand* g_rand_new_with_seed_array(uint* seed, uint seed_length);
22716 Regex* /*new*/ g_regex_new(char* pattern, RegexCompileFlags compile_options, RegexMatchFlags match_options, GLib2.Error** error);
22717 int g_regex_get_capture_count(Regex* this_);
22718 RegexCompileFlags g_regex_get_compile_flags(Regex* this_);
22719 RegexMatchFlags g_regex_get_match_flags(Regex* this_);
22720 int g_regex_get_max_backref(Regex* this_);
22721 char* g_regex_get_pattern(Regex* this_);
22722 int g_regex_get_string_number(Regex* this_, char* name);
22723 int g_regex_match(Regex* this_, char* string_, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info=null);
22724 int g_regex_match_all(Regex* this_, char* string_, RegexMatchFlags match_options, /*out*/ MatchInfo** match_info=null);
22725 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);
22726 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);
22727 Regex* /*new*/ g_regex_ref(Regex* this_);
22728 char* /*new*/ g_regex_replace(Regex* this_, char* string_, ssize_t string_len, int start_position, char* replacement, RegexMatchFlags match_options, GLib2.Error** error);
22729 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);
22730 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);
22731 char** g_regex_split(Regex* this_, char* string_, RegexMatchFlags match_options);
22732 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);
22733 void g_regex_unref(Regex* this_);
22734 int g_regex_check_replacement(char* replacement, /*out*/ int* has_references, GLib2.Error** error);
22735 Quark g_regex_error_quark();
22736 char* /*new*/ g_regex_escape_nul(char* string_, int length);
22737 char* /*new*/ g_regex_escape_string(char* string_, int length);
22738 int g_regex_match_simple(char* pattern, char* string_, RegexCompileFlags compile_options, RegexMatchFlags match_options);
22739 char** g_regex_split_simple(char* pattern, char* string_, RegexCompileFlags compile_options, RegexMatchFlags match_options);
22740 int g_relation_count(Relation* this_, const(void)* key, int field);
22741 int g_relation_delete(Relation* this_, const(void)* key, int field);
22742 void g_relation_destroy(Relation* this_);
22743 int g_relation_exists(Relation* this_, ...);
22744 void g_relation_index(Relation* this_, int field, HashFunc hash_func, EqualFunc key_equal_func);
22745 void g_relation_insert(Relation* this_, ...);
22746 void g_relation_print(Relation* this_);
22747 Tuples* g_relation_select(Relation* this_, const(void)* key, int field);
22748 Relation* g_relation_new(int fields);
22749 GLib2.SList* g_slist_alloc();
22750 GLib2.SList* g_slist_append(GLib2.SList* list, void* data);
22751 GLib2.SList* g_slist_concat(GLib2.SList* list1, GLib2.SList* list2);
22752 GLib2.SList* g_slist_copy(GLib2.SList* list);
22753 GLib2.SList* g_slist_delete_link(GLib2.SList* list, GLib2.SList* link_);
22754 GLib2.SList* g_slist_find(GLib2.SList* list, const(void)* data);
22755 GLib2.SList* g_slist_find_custom(GLib2.SList* list, const(void)* data, CompareFunc func);
22756 void g_slist_foreach(GLib2.SList* list, Func func, void* user_data);
22757 void g_slist_free(GLib2.SList* list);
22758 void g_slist_free_1(GLib2.SList* list);
22759 void g_slist_free_full(GLib2.SList* list, DestroyNotify free_func);
22760 int g_slist_index(GLib2.SList* list, const(void)* data);
22761 GLib2.SList* g_slist_insert(GLib2.SList* list, void* data, int position);
22762 GLib2.SList* g_slist_insert_before(GLib2.SList* slist, GLib2.SList* sibling, void* data);
22763 GLib2.SList* g_slist_insert_sorted(GLib2.SList* list, void* data, CompareFunc func);
22764 GLib2.SList* g_slist_insert_sorted_with_data(GLib2.SList* list, void* data, CompareDataFunc func, void* user_data);
22765 GLib2.SList* g_slist_last(GLib2.SList* list);
22766 uint g_slist_length(GLib2.SList* list);
22767 GLib2.SList* g_slist_nth(GLib2.SList* list, uint n);
22768 void* g_slist_nth_data(GLib2.SList* list, uint n);
22769 void g_slist_pop_allocator();
22770 int g_slist_position(GLib2.SList* list, GLib2.SList* llink);
22771 GLib2.SList* g_slist_prepend(GLib2.SList* list, void* data);
22772 void g_slist_push_allocator(void* dummy);
22773 GLib2.SList* g_slist_remove(GLib2.SList* list, const(void)* data);
22774 GLib2.SList* g_slist_remove_all(GLib2.SList* list, const(void)* data);
22775 GLib2.SList* g_slist_remove_link(GLib2.SList* list, GLib2.SList* link_);
22776 GLib2.SList* g_slist_reverse(GLib2.SList* list);
22777 GLib2.SList* g_slist_sort(GLib2.SList* list, CompareFunc compare_func);
22778 GLib2.SList* g_slist_sort_with_data(GLib2.SList* list, CompareDataFunc compare_func, void* user_data);
22779 uint g_scanner_cur_line(Scanner* this_);
22780 uint g_scanner_cur_position(Scanner* this_);
22781 TokenType g_scanner_cur_token(Scanner* this_);
22782 TokenValue g_scanner_cur_value(Scanner* this_);
22783 void g_scanner_destroy(Scanner* this_);
22784 int g_scanner_eof(Scanner* this_);
22785 void g_scanner_error(Scanner* this_, char* format, ...);
22786 TokenType g_scanner_get_next_token(Scanner* this_);
22787 void g_scanner_input_file(Scanner* this_, int input_fd);
22788 void g_scanner_input_text(Scanner* this_, char* text, uint text_len);
22789 void* g_scanner_lookup_symbol(Scanner* this_, char* symbol);
22790 TokenType g_scanner_peek_next_token(Scanner* this_);
22791 void g_scanner_scope_add_symbol(Scanner* this_, uint scope_id, char* symbol, void* value);
22792 void g_scanner_scope_foreach_symbol(Scanner* this_, uint scope_id, HFunc func, void* user_data);
22793 void* g_scanner_scope_lookup_symbol(Scanner* this_, uint scope_id, char* symbol);
22794 void g_scanner_scope_remove_symbol(Scanner* this_, uint scope_id, char* symbol);
22795 uint g_scanner_set_scope(Scanner* this_, uint scope_id);
22796 void g_scanner_sync_file_offset(Scanner* this_);
22797 void g_scanner_unexp_token(Scanner* this_, TokenType expected_token, char* identifier_spec, char* symbol_spec, char* symbol_name, char* message, int is_error);
22798 void g_scanner_warn(Scanner* this_, char* format, ...);
22799 Scanner* g_scanner_new(ScannerConfig* config_templ);
22800 SequenceIter* g_sequence_append(Sequence* this_, void* data);
22801 void g_sequence_foreach(Sequence* this_, Func func, void* user_data);
22802 void g_sequence_free(Sequence* this_);
22803 SequenceIter* g_sequence_get_begin_iter(Sequence* this_);
22804 SequenceIter* g_sequence_get_end_iter(Sequence* this_);
22805 SequenceIter* g_sequence_get_iter_at_pos(Sequence* this_, int pos);
22806 int g_sequence_get_length(Sequence* this_);
22807 SequenceIter* g_sequence_insert_sorted(Sequence* this_, void* data, CompareDataFunc cmp_func, void* cmp_data);
22808 SequenceIter* g_sequence_insert_sorted_iter(Sequence* this_, void* data, SequenceIterCompareFunc iter_cmp, void* cmp_data);
22809 SequenceIter* g_sequence_lookup(Sequence* this_, void* data, CompareDataFunc cmp_func, void* cmp_data);
22810 SequenceIter* g_sequence_lookup_iter(Sequence* this_, void* data, SequenceIterCompareFunc iter_cmp, void* cmp_data);
22811 SequenceIter* g_sequence_prepend(Sequence* this_, void* data);
22812 SequenceIter* g_sequence_search(Sequence* this_, void* data, CompareDataFunc cmp_func, void* cmp_data);
22813 SequenceIter* g_sequence_search_iter(Sequence* this_, void* data, SequenceIterCompareFunc iter_cmp, void* cmp_data);
22814 void g_sequence_sort(Sequence* this_, CompareDataFunc cmp_func, void* cmp_data);
22815 void g_sequence_sort_iter(Sequence* this_, SequenceIterCompareFunc cmp_func, void* cmp_data);
22816 void g_sequence_foreach_range(SequenceIter* begin, SequenceIter* end, Func func, void* user_data);
22817 void* g_sequence_get(SequenceIter* iter);
22818 SequenceIter* g_sequence_insert_before(SequenceIter* iter, void* data);
22819 void g_sequence_move(SequenceIter* src, SequenceIter* dest);
22820 void g_sequence_move_range(SequenceIter* dest, SequenceIter* begin, SequenceIter* end);
22821 Sequence* g_sequence_new(DestroyNotify data_destroy);
22822 SequenceIter* g_sequence_range_get_midpoint(SequenceIter* begin, SequenceIter* end);
22823 void g_sequence_remove(SequenceIter* iter);
22824 void g_sequence_remove_range(SequenceIter* begin, SequenceIter* end);
22825 void g_sequence_set(SequenceIter* iter, void* data);
22826 void g_sequence_sort_changed(SequenceIter* iter, CompareDataFunc cmp_func, void* cmp_data);
22827 void g_sequence_sort_changed_iter(SequenceIter* iter, SequenceIterCompareFunc iter_cmp, void* cmp_data);
22828 void g_sequence_swap(SequenceIter* a, SequenceIter* b);
22829 int g_sequence_iter_compare(SequenceIter* this_, SequenceIter* b);
22830 int g_sequence_iter_get_position(SequenceIter* this_);
22831 Sequence* g_sequence_iter_get_sequence(SequenceIter* this_);
22832 int g_sequence_iter_is_begin(SequenceIter* this_);
22833 int g_sequence_iter_is_end(SequenceIter* this_);
22834 SequenceIter* g_sequence_iter_move(SequenceIter* this_, int delta);
22835 SequenceIter* g_sequence_iter_next(SequenceIter* this_);
22836 SequenceIter* g_sequence_iter_prev(SequenceIter* this_);
22837 Source* /*new*/ g_source_new(SourceFuncs* source_funcs, uint struct_size);
22838 void g_source_add_child_source(Source* this_, Source* child_source);
22839 void g_source_add_poll(Source* this_, PollFD* fd);
22840 uint g_source_attach(Source* this_, MainContext* context);
22841 void g_source_destroy(Source* this_);
22842 int g_source_get_can_recurse(Source* this_);
22843 MainContext* g_source_get_context(Source* this_);
22844 void g_source_get_current_time(Source* this_, TimeVal* timeval);
22845 uint g_source_get_id(Source* this_);
22846 char* g_source_get_name(Source* this_);
22847 int g_source_get_priority(Source* this_);
22848 long g_source_get_time(Source* this_);
22849 int g_source_is_destroyed(Source* this_);
22850 Source* /*new*/ g_source_ref(Source* this_);
22851 void g_source_remove_child_source(Source* this_, Source* child_source);
22852 void g_source_remove_poll(Source* this_, PollFD* fd);
22853 void g_source_set_callback(Source* this_, SourceFunc func, void* data, DestroyNotify notify);
22854 void g_source_set_callback_indirect(Source* this_, void* callback_data, SourceCallbackFuncs* callback_funcs);
22855 void g_source_set_can_recurse(Source* this_, int can_recurse);
22856 void g_source_set_funcs(Source* this_, SourceFuncs* funcs);
22857 void g_source_set_name(Source* this_, char* name);
22858 void g_source_set_priority(Source* this_, int priority);
22859 void g_source_unref(Source* this_);
22860 int g_source_remove(uint tag);
22861 int g_source_remove_by_funcs_user_data(SourceFuncs* funcs, void* user_data);
22862 int g_source_remove_by_user_data(void* user_data);
22863 void g_source_set_name_by_id(uint tag, char* name);
22864 void g_static_mutex_free(StaticMutex* this_);
22865 void g_static_mutex_init(StaticMutex* this_);
22866 Mutex* g_static_mutex_get_mutex_impl(Mutex** mutex);
22867 void g_static_private_free(StaticPrivate* this_);
22868 void* g_static_private_get(StaticPrivate* this_);
22869 void g_static_private_init(StaticPrivate* this_);
22870 void g_static_private_set(StaticPrivate* this_, void* data, DestroyNotify notify);
22871 void g_static_rw_lock_free(StaticRWLock* this_);
22872 void g_static_rw_lock_init(StaticRWLock* this_);
22873 void g_static_rw_lock_reader_lock(StaticRWLock* this_);
22874 int g_static_rw_lock_reader_trylock(StaticRWLock* this_);
22875 void g_static_rw_lock_reader_unlock(StaticRWLock* this_);
22876 void g_static_rw_lock_writer_lock(StaticRWLock* this_);
22877 int g_static_rw_lock_writer_trylock(StaticRWLock* this_);
22878 void g_static_rw_lock_writer_unlock(StaticRWLock* this_);
22879 void g_static_rec_mutex_free(StaticRecMutex* this_);
22880 void g_static_rec_mutex_init(StaticRecMutex* this_);
22881 void g_static_rec_mutex_lock(StaticRecMutex* this_);
22882 void g_static_rec_mutex_lock_full(StaticRecMutex* this_, uint depth);
22883 int g_static_rec_mutex_trylock(StaticRecMutex* this_);
22884 void g_static_rec_mutex_unlock(StaticRecMutex* this_);
22885 uint g_static_rec_mutex_unlock_full(StaticRecMutex* this_);
22886 String* /*new*/ g_string_append(String* this_, char* val);
22887 String* /*new*/ g_string_append_c(String* this_, char c);
22888 String* /*new*/ g_string_append_len(String* this_, char* val, ssize_t len);
22889 void g_string_append_printf(String* this_, char* format, ...);
22890 String* /*new*/ g_string_append_unichar(String* this_, dchar wc);
22891 String* /*new*/ g_string_append_uri_escaped(String* this_, char* unescaped, char* reserved_chars_allowed, int allow_utf8);
22892 void g_string_append_vprintf(String* this_, char* format, va_list args);
22893 String* /*new*/ g_string_ascii_down(String* this_);
22894 String* /*new*/ g_string_ascii_up(String* this_);
22895 String* /*new*/ g_string_assign(String* this_, char* rval);
22896 String* /*new*/ g_string_down(String* this_);
22897 int g_string_equal(String* this_, String* v2);
22898 String* /*new*/ g_string_erase(String* this_, ssize_t pos, ssize_t len);
22899 char* /*new*/ g_string_free(String* this_, int free_segment);
22900 uint g_string_hash(String* this_);
22901 String* /*new*/ g_string_insert(String* this_, ssize_t pos, char* val);
22902 String* /*new*/ g_string_insert_c(String* this_, ssize_t pos, char c);
22903 String* /*new*/ g_string_insert_len(String* this_, ssize_t pos, char* val, ssize_t len);
22904 String* /*new*/ g_string_insert_unichar(String* this_, ssize_t pos, dchar wc);
22905 String* /*new*/ g_string_overwrite(String* this_, size_t pos, char* val);
22906 String* /*new*/ g_string_overwrite_len(String* this_, size_t pos, char* val, ssize_t len);
22907 String* /*new*/ g_string_prepend(String* this_, char* val);
22908 String* /*new*/ g_string_prepend_c(String* this_, char c);
22909 String* /*new*/ g_string_prepend_len(String* this_, char* val, ssize_t len);
22910 String* /*new*/ g_string_prepend_unichar(String* this_, dchar wc);
22911 void g_string_printf(String* this_, char* format, ...);
22912 String* /*new*/ g_string_set_size(String* this_, size_t len);
22913 String* /*new*/ g_string_truncate(String* this_, size_t len);
22914 String* /*new*/ g_string_up(String* this_);
22915 void g_string_vprintf(String* this_, char* format, va_list args);
22916 void g_string_chunk_clear(StringChunk* this_);
22917 void g_string_chunk_free(StringChunk* this_);
22918 char* /*new*/ g_string_chunk_insert(StringChunk* this_, char* string_);
22919 char* /*new*/ g_string_chunk_insert_const(StringChunk* this_, char* string_);
22920 char* /*new*/ g_string_chunk_insert_len(StringChunk* this_, char* string_, ssize_t len);
22921 StringChunk* g_string_chunk_new(size_t size);
22922 void g_test_log_buffer_free(TestLogBuffer* this_);
22923 TestLogMsg* g_test_log_buffer_pop(TestLogBuffer* this_);
22924 void g_test_log_buffer_push(TestLogBuffer* this_, uint n_bytes, ubyte* bytes);
22925 TestLogBuffer* g_test_log_buffer_new();
22926 void g_test_log_msg_free(TestLogMsg* this_);
22927 void g_test_suite_add(TestSuite* this_, TestCase* test_case);
22928 void g_test_suite_add_suite(TestSuite* this_, TestSuite* nestedsuite);
22929 void* g_thread_join(Thread* this_);
22930 void g_thread_set_priority(Thread* this_, ThreadPriority priority);
22931 Thread* g_thread_create_full(ThreadFunc func, void* data, c_ulong stack_size, int joinable, int bound, ThreadPriority priority, GLib2.Error** error);
22932 Quark g_thread_error_quark();
22933 void g_thread_exit(void* retval);
22934 void g_thread_foreach(Func thread_func, void* user_data);
22935 int g_thread_get_initialized();
22936 void g_thread_init(ThreadFunctions* vtable);
22937 void g_thread_init_with_errorcheck_mutexes(ThreadFunctions* vtable);
22938 Thread* g_thread_self();
22939 void g_thread_pool_free(ThreadPool* this_, int immediate, int wait_);
22940 int g_thread_pool_get_max_threads(ThreadPool* this_);
22941 uint g_thread_pool_get_num_threads(ThreadPool* this_);
22942 void g_thread_pool_push(ThreadPool* this_, void* data, GLib2.Error** error);
22943 void g_thread_pool_set_max_threads(ThreadPool* this_, int max_threads, GLib2.Error** error);
22944 void g_thread_pool_set_sort_function(ThreadPool* this_, CompareDataFunc func, void* user_data);
22945 uint g_thread_pool_unprocessed(ThreadPool* this_);
22946 uint g_thread_pool_get_max_idle_time();
22947 int g_thread_pool_get_max_unused_threads();
22948 uint g_thread_pool_get_num_unused_threads();
22949 ThreadPool* g_thread_pool_new(Func func, void* user_data, int max_threads, int exclusive, GLib2.Error** error);
22950 void g_thread_pool_set_max_idle_time(uint interval);
22951 void g_thread_pool_set_max_unused_threads(int max_threads);
22952 void g_thread_pool_stop_unused_threads();
22953 void g_time_val_add(TimeVal* this_, c_long microseconds);
22954 char* /*new*/ g_time_val_to_iso8601(TimeVal* this_);
22955 int g_time_val_from_iso8601(char* iso_date, TimeVal* time_);
22956 int g_time_zone_adjust_time(TimeZone* this_, TimeType type, long* time_);
22957 int g_time_zone_find_interval(TimeZone* this_, TimeType type, long time_);
22958 char* g_time_zone_get_abbreviation(TimeZone* this_, int interval);
22959 int g_time_zone_get_offset(TimeZone* this_, int interval);
22960 int g_time_zone_is_dst(TimeZone* this_, int interval);
22961 TimeZone* g_time_zone_ref(TimeZone* this_);
22962 void g_time_zone_unref(TimeZone* this_);
22963 TimeZone* g_time_zone_new(char* identifier=null);
22964 TimeZone* g_time_zone_new_local();
22965 TimeZone* g_time_zone_new_utc();
22966 void g_timer_continue(Timer* this_);
22967 void g_timer_destroy(Timer* this_);
22968 double g_timer_elapsed(Timer* this_, c_ulong* microseconds);
22969 void g_timer_reset(Timer* this_);
22970 void g_timer_start(Timer* this_);
22971 void g_timer_stop(Timer* this_);
22972 Timer* g_timer_new();
22973 uint g_trash_stack_height(TrashStack** stack_p);
22974 void* g_trash_stack_peek(TrashStack** stack_p);
22975 void* g_trash_stack_pop(TrashStack** stack_p);
22976 void g_trash_stack_push(TrashStack** stack_p, void* data_p);
22977 void g_tree_destroy(Tree* this_);
22978 void g_tree_foreach(Tree* this_, TraverseFunc func, void* user_data);
22979 int g_tree_height(Tree* this_);
22980 void g_tree_insert(Tree* this_, void* key, void* value);
22981 void* g_tree_lookup(Tree* this_, const(void)* key);
22982 int g_tree_lookup_extended(Tree* this_, const(void)* lookup_key, void** orig_key, void** value);
22983 int g_tree_nnodes(Tree* this_);
22984 Tree* g_tree_ref(Tree* this_);
22985 int g_tree_remove(Tree* this_, const(void)* key);
22986 void g_tree_replace(Tree* this_, void* key, void* value);
22987 void* g_tree_search(Tree* this_, CompareFunc search_func, const(void)* user_data);
22988 int g_tree_steal(Tree* this_, const(void)* key);
22989 void g_tree_traverse(Tree* this_, TraverseFunc traverse_func, TraverseType traverse_type, void* user_data);
22990 void g_tree_unref(Tree* this_);
22991 Tree* g_tree_new(CompareFunc key_compare_func);
22992 Tree* g_tree_new_full(CompareDataFunc key_compare_func, void* key_compare_data, DestroyNotify key_destroy_func, DestroyNotify value_destroy_func);
22993 Tree* g_tree_new_with_data(CompareDataFunc key_compare_func, void* key_compare_data);
22994 void g_tuples_destroy(Tuples* this_);
22995 void* g_tuples_index(Tuples* this_, int index_, int field);
22996 Variant* /*new*/ g_variant_new(char* format_string, ...);
22997 Variant* g_variant_new_array(VariantType* child_type, Variant** children, size_t n_children);
22998 Variant* g_variant_new_boolean(int value);
22999 Variant* g_variant_new_byte(ubyte value);
23000 Variant* g_variant_new_bytestring(ubyte* string_);
23001 Variant* g_variant_new_bytestring_array(char** strv, ssize_t length);
23002 Variant* g_variant_new_dict_entry(Variant* key, Variant* value);
23003 Variant* g_variant_new_double(double value);
23004 Variant* g_variant_new_from_data(VariantType* type, const(ubyte)* data, size_t size, int trusted, DestroyNotify notify, void* user_data);
23005 Variant* g_variant_new_handle(int value);
23006 Variant* g_variant_new_int16(short value);
23007 Variant* g_variant_new_int32(int value);
23008 Variant* g_variant_new_int64(long value);
23009 Variant* g_variant_new_maybe(VariantType* child_type=null, Variant* child=null);
23010 Variant* g_variant_new_object_path(char* object_path);
23011 Variant* g_variant_new_objv(char** strv, ssize_t length);
23012 Variant* /*new*/ g_variant_new_parsed(char* format, ...);
23013 Variant* /*new*/ g_variant_new_parsed_va(char* format, va_list* app);
23014 Variant* g_variant_new_signature(char* signature);
23015 Variant* g_variant_new_string(char* string_);
23016 Variant* g_variant_new_strv(char** strv, ssize_t length);
23017 Variant* g_variant_new_tuple(Variant** children, size_t n_children);
23018 Variant* g_variant_new_uint16(ushort value);
23019 Variant* g_variant_new_uint32(uint value);
23020 Variant* g_variant_new_uint64(ulong value);
23021 Variant* /*new*/ g_variant_new_va(char* format_string, char** endptr, va_list* app);
23022 Variant* g_variant_new_variant(Variant* value);
23023 Variant* /*new*/ g_variant_byteswap(Variant* this_);
23024 VariantClass g_variant_classify(Variant* this_);
23025 int g_variant_compare(Variant* this_, const(Variant)* two);
23026 ubyte* /*new*/ g_variant_dup_bytestring(Variant* this_, /*out*/ size_t* length=null);
23027 char** /*new*/ g_variant_dup_bytestring_array(Variant* this_, /*out*/ size_t* length=null);
23028 char** /*new*/ g_variant_dup_objv(Variant* this_, /*out*/ size_t* length=null);
23029 char* /*new*/ g_variant_dup_string(Variant* this_, /*out*/ size_t* length);
23030 char** /*new*/ g_variant_dup_strv(Variant* this_, /*out*/ size_t* length=null);
23031 int g_variant_equal(Variant* this_, const(Variant)* two);
23032 void g_variant_get(Variant* this_, char* format_string, ...);
23033 int g_variant_get_boolean(Variant* this_);
23034 ubyte g_variant_get_byte(Variant* this_);
23035 ubyte* g_variant_get_bytestring(Variant* this_);
23036 char** /*new container*/ g_variant_get_bytestring_array(Variant* this_, /*out*/ size_t* length=null);
23037 void g_variant_get_child(Variant* this_, size_t index_, char* format_string, ...);
23038 Variant* /*new*/ g_variant_get_child_value(Variant* this_, size_t index_);
23039 const(void)* g_variant_get_data(Variant* this_);
23040 double g_variant_get_double(Variant* this_);
23041 const(void)* g_variant_get_fixed_array(Variant* this_, /*out*/ size_t* n_elements, size_t element_size);
23042 int g_variant_get_handle(Variant* this_);
23043 short g_variant_get_int16(Variant* this_);
23044 int g_variant_get_int32(Variant* this_);
23045 long g_variant_get_int64(Variant* this_);
23046 Variant* /*new*/ g_variant_get_maybe(Variant* this_);
23047 Variant* /*new*/ g_variant_get_normal_form(Variant* this_);
23048 char** /*new container*/ g_variant_get_objv(Variant* this_, /*out*/ size_t* length=null);
23049 size_t g_variant_get_size(Variant* this_);
23050 char* g_variant_get_string(Variant* this_, /*out*/ size_t* length=null);
23051 char** /*new container*/ g_variant_get_strv(Variant* this_, /*out*/ size_t* length=null);
23052 char* g_variant_get_type_string(Variant* this_);
23053 ushort g_variant_get_uint16(Variant* this_);
23054 uint g_variant_get_uint32(Variant* this_);
23055 ulong g_variant_get_uint64(Variant* this_);
23056 void g_variant_get_va(Variant* this_, char* format_string, char** endptr, va_list* app);
23057 Variant* /*new*/ g_variant_get_variant(Variant* this_);
23058 uint g_variant_hash(Variant* this_);
23059 int g_variant_is_container(Variant* this_);
23060 int g_variant_is_floating(Variant* this_);
23061 int g_variant_is_normal_form(Variant* this_);
23062 int g_variant_is_of_type(Variant* this_, VariantType* type);
23063 VariantIter* /*new*/ g_variant_iter_new(Variant* this_);
23064 int g_variant_lookup(Variant* this_, char* key, char* format_string, ...);
23065 Variant* /*new*/ g_variant_lookup_value(Variant* this_, char* key, VariantType* expected_type=null);
23066 size_t g_variant_n_children(Variant* this_);
23067 char* /*new*/ g_variant_print(Variant* this_, int type_annotate);
23068 String* /*new*/ g_variant_print_string(Variant* this_, String* string_, int type_annotate);
23069 Variant* /*new*/ g_variant_ref(Variant* this_);
23070 Variant* /*new*/ g_variant_ref_sink(Variant* this_);
23071 void g_variant_store(Variant* this_, void* data);
23072 Variant* /*new*/ g_variant_take_ref(Variant* this_);
23073 void g_variant_unref(Variant* this_);
23074 int g_variant_is_object_path(char* string_);
23075 int g_variant_is_signature(char* string_);
23076 Variant* /*new*/ g_variant_parse(VariantType* type, char* text, char* limit, char** endptr, GLib2.Error** error);
23077 Quark g_variant_parser_get_error_quark();
23078 VariantBuilder* /*new*/ g_variant_builder_new(VariantType* type);
23079 void g_variant_builder_add(VariantBuilder* this_, char* format_string, ...);
23080 void g_variant_builder_add_parsed(VariantBuilder* this_, char* format, ...);
23081 void g_variant_builder_add_value(VariantBuilder* this_, Variant* value);
23082 void g_variant_builder_clear(VariantBuilder* this_);
23083 void g_variant_builder_close(VariantBuilder* this_);
23084 Variant* g_variant_builder_end(VariantBuilder* this_);
23085 void g_variant_builder_init(VariantBuilder* this_, VariantType* type);
23086 void g_variant_builder_open(VariantBuilder* this_, VariantType* type);
23087 VariantBuilder* /*new*/ g_variant_builder_ref(VariantBuilder* this_);
23088 void g_variant_builder_unref(VariantBuilder* this_);
23089 VariantIter* /*new*/ g_variant_iter_copy(VariantIter* this_);
23090 void g_variant_iter_free(VariantIter* this_);
23091 size_t g_variant_iter_init(VariantIter* this_, Variant* value);
23092 int g_variant_iter_loop(VariantIter* this_, char* format_string, ...);
23093 size_t g_variant_iter_n_children(VariantIter* this_);
23094 int g_variant_iter_next(VariantIter* this_, char* format_string, ...);
23095 Variant* /*new*/ g_variant_iter_next_value(VariantIter* this_);
23096 VariantType* /*new*/ g_variant_type_new(char* type_string);
23097 VariantType* /*new*/ g_variant_type_new_tuple(VariantType** items, int length);
23098 VariantType* /*new*/ g_variant_type_copy(VariantType* this_);
23099 char* /*new*/ g_variant_type_dup_string(VariantType* this_);
23100 VariantType* g_variant_type_element(VariantType* this_);
23101 int g_variant_type_equal(VariantType* this_, const(VariantType)* type2);
23102 VariantType* g_variant_type_first(VariantType* this_);
23103 void g_variant_type_free(VariantType* this_);
23104 size_t g_variant_type_get_string_length(VariantType* this_);
23105 uint g_variant_type_hash(VariantType* this_);
23106 int g_variant_type_is_array(VariantType* this_);
23107 int g_variant_type_is_basic(VariantType* this_);
23108 int g_variant_type_is_container(VariantType* this_);
23109 int g_variant_type_is_definite(VariantType* this_);
23110 int g_variant_type_is_dict_entry(VariantType* this_);
23111 int g_variant_type_is_maybe(VariantType* this_);
23112 int g_variant_type_is_subtype_of(VariantType* this_, VariantType* supertype);
23113 int g_variant_type_is_tuple(VariantType* this_);
23114 int g_variant_type_is_variant(VariantType* this_);
23115 VariantType* g_variant_type_key(VariantType* this_);
23116 size_t g_variant_type_n_items(VariantType* this_);
23117 VariantType* /*new*/ g_variant_type_new_array(VariantType* this_);
23118 VariantType* /*new*/ g_variant_type_new_dict_entry(VariantType* this_, VariantType* value);
23119 VariantType* /*new*/ g_variant_type_new_maybe(VariantType* this_);
23120 VariantType* g_variant_type_next(VariantType* this_);
23121 char* g_variant_type_peek_string(VariantType* this_);
23122 VariantType* g_variant_type_value(VariantType* this_);
23123 VariantType* g_variant_type_checked_(char* arg_a);
23124 int g_variant_type_string_is_valid(char* type_string);
23125 int g_variant_type_string_scan(char* string_, char* limit=null, /*out*/ char** endptr=null);
23126 int g_access(char* filename, int mode);
23127 int g_ascii_digit_value(char c);
23128 char* /*new*/ g_ascii_dtostr(char* buffer, int buf_len, double d);
23129 char* /*new*/ g_ascii_formatd(char* buffer, int buf_len, char* format, double d);
23130 int g_ascii_strcasecmp(char* s1, char* s2);
23131 char* /*new*/ g_ascii_strdown(char* str, ssize_t len);
23132 int g_ascii_strncasecmp(char* s1, char* s2, size_t n);
23133 double g_ascii_strtod(char* nptr, char** endptr);
23134 long g_ascii_strtoll(char* nptr, char** endptr, uint base);
23135 ulong g_ascii_strtoull(char* nptr, char** endptr, uint base);
23136 char* /*new*/ g_ascii_strup(char* str, ssize_t len);
23137 char g_ascii_tolower(char c);
23138 char g_ascii_toupper(char c);
23139 int g_ascii_xdigit_value(char c);
23140 void g_assert_warning(char* log_domain, char* file, int line, char* pretty_function, char* expression);
23141 void g_assertion_message(char* domain, char* file, int line, char* func, char* message);
23142 void g_assertion_message_cmpnum(char* domain, char* file, int line, char* func, char* expr, real arg1, char* cmp, real arg2, char numtype);
23143 void g_assertion_message_cmpstr(char* domain, char* file, int line, char* func, char* expr, char* arg1, char* cmp, char* arg2);
23144 void g_assertion_message_error(char* domain, char* file, int line, char* func, char* expr, Error* error, Quark error_domain, int error_code);
23145 void g_assertion_message_expr(char* domain, char* file, int line, char* func, char* expr);
23146 void g_atexit(VoidFunc func);
23147 int g_atomic_int_add(int* atomic, int val);
23148 uint g_atomic_int_and(uint* atomic, uint val);
23149 int g_atomic_int_compare_and_exchange(int* atomic, int oldval, int newval);
23150 int g_atomic_int_dec_and_test(int* atomic);
23151 int g_atomic_int_exchange_and_add(int* atomic, int val);
23152 int g_atomic_int_get(int* atomic);
23153 void g_atomic_int_inc(int* atomic);
23154 uint g_atomic_int_or(uint* atomic, uint val);
23155 void g_atomic_int_set(int* atomic, int newval);
23156 uint g_atomic_int_xor(uint* atomic, uint val);
23157 ssize_t g_atomic_pointer_add(void* atomic, ssize_t val);
23158 size_t g_atomic_pointer_and(void* atomic, size_t val);
23159 int g_atomic_pointer_compare_and_exchange(void* atomic, void* oldval, void* newval);
23160 void* g_atomic_pointer_get(void* atomic);
23161 size_t g_atomic_pointer_or(void* atomic, size_t val);
23162 void g_atomic_pointer_set(void* atomic, void* newval);
23163 size_t g_atomic_pointer_xor(void* atomic, size_t val);
23164 ubyte* /*new*/ g_base64_decode(char* text, /*out*/ size_t* out_len);
23165 ubyte* g_base64_decode_inplace(/*inout*/ ubyte* text, /*inout*/ size_t* out_len);
23166 size_t g_base64_decode_step(ubyte* in_, size_t len, /*out*/ ubyte* out_, /*inout*/ int* state, /*inout*/ uint* save);
23167 char* /*new*/ g_base64_encode(ubyte* data, size_t len);
23168 size_t g_base64_encode_close(int break_lines, /*out*/ ubyte* out_, /*inout*/ int* state, /*inout*/ int* save);
23169 size_t g_base64_encode_step(ubyte* in_, size_t len, int break_lines, /*out*/ ubyte* out_, /*inout*/ int* state, /*inout*/ int* save);
23170 char* g_basename(char* file_name);
23171 void g_bit_lock(int* address, int lock_bit);
23172 int g_bit_nth_lsf(c_ulong mask, int nth_bit);
23173 int g_bit_nth_msf(c_ulong mask, int nth_bit);
23174 uint g_bit_storage(c_ulong number);
23175 int g_bit_trylock(int* address, int lock_bit);
23176 void g_bit_unlock(int* address, int lock_bit);
23177 void g_blow_chunks();
23178 char* /*new*/ g_build_filename(char* first_element, ...);
23179 char* /*new*/ g_build_filenamev(char** args);
23180 char* /*new*/ g_build_path(char* separator, char* first_element, ...);
23181 char* /*new*/ g_build_pathv(char* separator, char** args);
23182 int g_chdir(char* path);
23183 char* glib_check_version(uint required_major, uint required_minor, uint required_micro);
23184 uint g_child_watch_add(Pid pid, ChildWatchFunc function_, void* data);
23185 uint g_child_watch_add_full(int priority, Pid pid, ChildWatchFunc function_, void* data, DestroyNotify notify);
23186 Source* /*new*/ g_child_watch_source_new(Pid pid);
23187 void g_clear_error(GLib2.Error** error);
23188 char* /*new*/ g_compute_checksum_for_data(ChecksumType checksum_type, ubyte* data, size_t length);
23189 char* /*new*/ g_compute_checksum_for_string(ChecksumType checksum_type, char* str, ssize_t length);
23190 char* /*new*/ g_compute_hmac_for_data(ChecksumType digest_type, ubyte* key, size_t key_len, ubyte* data, size_t length);
23191 char* /*new*/ g_compute_hmac_for_string(ChecksumType digest_type, ubyte* key, size_t key_len, char* str, ssize_t length);
23192 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);
23193 Quark g_convert_error_quark();
23194 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);
23195 char* /*new*/ g_convert_with_iconv(char* str, ssize_t len, IConv converter, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error);
23196 void g_datalist_clear(Data** datalist);
23197 void g_datalist_foreach(Data** datalist, DataForeachFunc func, void* user_data);
23198 void* g_datalist_get_data(Data** datalist, char* key);
23199 uint g_datalist_get_flags(Data** datalist);
23200 void* g_datalist_id_get_data(Data** datalist, Quark key_id);
23201 void* g_datalist_id_remove_no_notify(Data** datalist, Quark key_id);
23202 void g_datalist_id_set_data_full(Data** datalist, Quark key_id, void* data, DestroyNotify destroy_func);
23203 void g_datalist_init(Data** datalist);
23204 void g_datalist_set_flags(Data** datalist, uint flags);
23205 void g_datalist_unset_flags(Data** datalist, uint flags);
23206 void g_dataset_destroy(const(void)* dataset_location);
23207 void g_dataset_foreach(const(void)* dataset_location, DataForeachFunc func, void* user_data);
23208 void* g_dataset_id_get_data(const(void)* dataset_location, Quark key_id);
23209 void* g_dataset_id_remove_no_notify(const(void)* dataset_location, Quark key_id);
23210 void g_dataset_id_set_data_full(const(void)* dataset_location, Quark key_id, void* data, DestroyNotify destroy_func);
23211 char* g_dcgettext(char* domain, char* msgid, int category);
23212 char* g_dgettext(char* domain, char* msgid);
23213 int g_direct_equal(const(void)* v1, const(void)* v2);
23214 uint g_direct_hash(const(void)* v);
23215 char* g_dngettext(char* domain, char* msgid, char* msgid_plural, c_ulong n);
23216 int g_double_equal(const(void)* v1, const(void)* v2);
23217 uint g_double_hash(const(void)* v);
23218 char* g_dpgettext(char* domain, char* msgctxtid, size_t msgidoffset);
23219 char* g_dpgettext2(char* domain, char* context, char* msgid);
23220 FileError g_file_error_from_errno(int err_no);
23221 Quark g_file_error_quark();
23222 int g_file_get_contents(char* filename, /*out*/ ubyte** contents, /*out*/ size_t* length, GLib2.Error** error);
23223 int g_file_open_tmp(char* tmpl, /*out*/ char** name_used, GLib2.Error** error);
23224 char* /*new*/ g_file_read_link(char* filename, GLib2.Error** error);
23225 int g_file_set_contents(char* filename, ubyte* contents, ssize_t length, GLib2.Error** error);
23226 int g_file_test(char* filename, FileTest test);
23227 char* /*new*/ g_filename_display_basename(char* filename);
23228 char* /*new*/ g_filename_display_name(char* filename);
23229 char* /*new*/ g_filename_from_uri(char* uri, char** hostname, GLib2.Error** error);
23230 char* /*new*/ g_filename_from_utf8(char* utf8string, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error);
23231 char* /*new*/ g_filename_to_uri(char* filename, char* hostname, GLib2.Error** error);
23232 char* /*new*/ g_filename_to_utf8(char* opsysstring, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error);
23233 char* /*new*/ g_find_program_in_path(char* program);
23234 char* /*new*/ g_format_size(ulong size);
23235 char* /*new*/ g_format_size_for_display(long size);
23236 char* /*new*/ g_format_size_full(ulong size, FormatSizeFlags flags);
23237 int g_fprintf(FILE* file, char* format, ...);
23238 void g_free(void* mem);
23239 char* g_get_application_name();
23240 int g_get_charset(char** charset);
23241 char* /*new*/ g_get_current_dir();
23242 void g_get_current_time(TimeVal* result);
23243 char** /*new*/ g_get_environ();
23244 int g_get_filename_charsets(char*** charsets);
23245 char* g_get_home_dir();
23246 char* g_get_host_name();
23247 char** g_get_language_names();
23248 char** /*new*/ g_get_locale_variants(char* locale);
23249 long g_get_monotonic_time();
23250 char* /*new*/ g_get_prgname();
23251 char* g_get_real_name();
23252 long g_get_real_time();
23253 char** g_get_system_config_dirs();
23254 char** g_get_system_data_dirs();
23255 char* g_get_tmp_dir();
23256 char* g_get_user_cache_dir();
23257 char* g_get_user_config_dir();
23258 char* g_get_user_data_dir();
23259 char* g_get_user_name();
23260 char* g_get_user_runtime_dir();
23261 char* g_get_user_special_dir(UserDirectory directory);
23262 char* g_getenv(char* variable);
23263 int g_hostname_is_ascii_encoded(char* hostname);
23264 int g_hostname_is_ip_address(char* hostname);
23265 int g_hostname_is_non_ascii(char* hostname);
23266 char* /*new*/ g_hostname_to_ascii(char* hostname);
23267 char* /*new*/ g_hostname_to_unicode(char* hostname);
23268 uint g_idle_add(SourceFunc function_, void* data);
23269 uint g_idle_add_full(int priority, SourceFunc function_, void* data, DestroyNotify notify);
23270 int g_idle_remove_by_data(void* data);
23271 Source* /*new*/ g_idle_source_new();
23272 int g_int64_equal(const(void)* v1, const(void)* v2);
23273 uint g_int64_hash(const(void)* v);
23274 int g_int_equal(const(void)* v1, const(void)* v2);
23275 uint g_int_hash(const(void)* v);
23276 char* g_intern_static_string(char* string_=null);
23277 char* g_intern_string(char* string_=null);
23278 uint g_io_add_watch(IOChannel* channel, IOCondition condition, IOFunc func, void* user_data);
23279 uint g_io_add_watch_full(IOChannel* channel, int priority, IOCondition condition, IOFunc func, void* user_data, DestroyNotify notify);
23280 Source* /*new*/ g_io_create_watch(IOChannel* channel, IOCondition condition);
23281 char** /*new*/ g_listenv();
23282 char* /*new*/ g_locale_from_utf8(char* utf8string, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error);
23283 char* /*new*/ g_locale_to_utf8(char* opsysstring, ssize_t len, size_t* bytes_read, size_t* bytes_written, GLib2.Error** error);
23284 void g_log(char* log_domain, LogLevelFlags log_level, char* format, ...);
23285 void g_log_default_handler(char* log_domain, LogLevelFlags log_level, char* message, void* unused_data);
23286 void g_log_remove_handler(char* log_domain, uint handler_id);
23287 LogLevelFlags g_log_set_always_fatal(LogLevelFlags fatal_mask);
23288 LogFunc g_log_set_default_handler(LogFunc log_func, void* user_data);
23289 LogLevelFlags g_log_set_fatal_mask(char* log_domain, LogLevelFlags fatal_mask);
23290 uint g_log_set_handler(char* log_domain, LogLevelFlags log_levels, LogFunc log_func, void* user_data);
23291 void g_logv(char* log_domain, LogLevelFlags log_level, char* format, va_list args);
23292 Source* g_main_current_source();
23293 int g_main_depth();
23294 void* g_malloc(size_t n_bytes);
23295 void* g_malloc0(size_t n_bytes);
23296 void* g_malloc0_n(size_t n_blocks, size_t n_block_bytes);
23297 void* g_malloc_n(size_t n_blocks, size_t n_block_bytes);
23298 int g_markup_collect_attributes(char* element_name, char** attribute_names, char** attribute_values, Error** error, MarkupCollectType first_type, char* first_attr, ...);
23299 Quark g_markup_error_quark();
23300 char* /*new*/ g_markup_escape_text(char* text, ssize_t length);
23301 char* /*new*/ g_markup_printf_escaped(char* format, ...);
23302 char* /*new*/ g_markup_vprintf_escaped(char* format, va_list args);
23303 int g_mem_is_system_malloc();
23304 void g_mem_profile();
23305 void g_mem_set_vtable(MemVTable* vtable);
23306 void* g_memdup(const(void)* mem, uint byte_size);
23307 int g_mkdir_with_parents(char* pathname, int mode);
23308 char* /*new*/ g_mkdtemp(char* tmpl);
23309 char* /*new*/ g_mkdtemp_full(char* tmpl, int mode);
23310 int g_mkstemp(char* tmpl);
23311 int g_mkstemp_full(char* tmpl, int flags, int mode);
23312 void g_nullify_pointer(void** nullify_location);
23313 void g_on_error_query(char* prg_name);
23314 void g_on_error_stack_trace(char* prg_name);
23315 Quark g_option_error_quark();
23316 uint g_parse_debug_string(char* string_, DebugKey* keys, uint nkeys);
23317 char* /*new*/ g_path_get_basename(char* file_name);
23318 char* /*new*/ g_path_get_dirname(char* file_name);
23319 int g_path_is_absolute(char* file_name);
23320 char* g_path_skip_root(char* file_name);
23321 int g_pattern_match(PatternSpec* pspec, uint string_length, char* string_, char* string_reversed);
23322 int g_pattern_match_simple(char* pattern, char* string_);
23323 int g_pattern_match_string(PatternSpec* pspec, char* string_);
23324 void g_pointer_bit_lock(void* address, int lock_bit);
23325 int g_pointer_bit_trylock(void* address, int lock_bit);
23326 void g_pointer_bit_unlock(void* address, int lock_bit);
23327 int g_poll(PollFD* fds, uint nfds, int timeout);
23328 void g_prefix_error(Error** err, char* format, ...);
23329 void g_print(char* format, ...);
23330 void g_printerr(char* format, ...);
23331 int g_printf(char* format, ...);
23332 size_t g_printf_string_upper_bound(char* format, va_list args);
23333 void g_propagate_error(Error** dest, Error* src);
23334 void g_propagate_prefixed_error(Error** dest, Error* src, char* format, ...);
23335 void g_qsort_with_data(const(void)* pbase, int total_elems, size_t size, CompareDataFunc compare_func, void* user_data);
23336 Quark g_quark_from_static_string(char* string_=null);
23337 Quark g_quark_from_string(char* string_=null);
23338 char* g_quark_to_string(Quark quark);
23339 Quark g_quark_try_string(char* string_=null);
23340 double g_random_double();
23341 double g_random_double_range(double begin, double end);
23342 uint g_random_int();
23343 int g_random_int_range(int begin, int end);
23344 void g_random_set_seed(uint seed);
23345 void* g_realloc(void* mem, size_t n_bytes);
23346 void* g_realloc_n(void* mem, size_t n_blocks, size_t n_block_bytes);
23347 void g_reload_user_special_dirs_cache();
23348 void g_return_if_fail_warning(char* log_domain, char* pretty_function, char* expression);
23349 int g_rmdir(char* filename);
23350 void g_set_application_name(char* application_name);
23351 void g_set_error(Error** err, Quark domain, int code, char* format, ...);
23352 void g_set_error_literal(Error** err, Quark domain, int code, char* message);
23353 void g_set_prgname(char* prgname);
23354 PrintFunc g_set_print_handler(PrintFunc func);
23355 PrintFunc g_set_printerr_handler(PrintFunc func);
23356 int g_setenv(char* variable, char* value, int overwrite);
23357 Quark g_shell_error_quark();
23358 int g_shell_parse_argv(char* command_line, /*out*/ int* argcp, /*out*/ char*** argvp, GLib2.Error** error);
23359 char* /*new*/ g_shell_quote(char* unquoted_string);
23360 char* /*new*/ g_shell_unquote(char* quoted_string, GLib2.Error** error);
23361 void* g_slice_alloc(size_t block_size);
23362 void* g_slice_alloc0(size_t block_size);
23363 void* g_slice_copy(size_t block_size, const(void)* mem_block);
23364 void g_slice_free1(size_t block_size, void* mem_block);
23365 void g_slice_free_chain_with_offset(size_t block_size, void* mem_chain, size_t next_offset);
23366 long g_slice_get_config(SliceConfig ckey);
23367 long* g_slice_get_config_state(SliceConfig ckey, long address, uint* n_values);
23368 void g_slice_set_config(SliceConfig ckey, long value);
23369 int g_snprintf(char* string_, c_ulong n, char* format, ...);
23370 uint g_spaced_primes_closest(uint num);
23371 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);
23372 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);
23373 void g_spawn_close_pid(Pid pid);
23374 int g_spawn_command_line_async(char* command_line, GLib2.Error** error);
23375 int g_spawn_command_line_sync(char* command_line, /*out*/ ubyte** standard_output, /*out*/ ubyte** standard_error, /*out*/ int* exit_status, GLib2.Error** error);
23376 Quark g_spawn_error_quark();
23377 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);
23378 int g_sprintf(char* string_, char* format, ...);
23379 char* /*new*/ g_stpcpy(char* dest, char* src);
23380 int g_str_equal(const(void)* v1, const(void)* v2);
23381 int g_str_has_prefix(char* str, char* prefix);
23382 int g_str_has_suffix(char* str, char* suffix);
23383 uint g_str_hash(const(void)* v);
23384 char* /*new*/ g_strcanon(char* string_, char* valid_chars, char substitutor);
23385 int g_strcasecmp(char* s1, char* s2);
23386 char* /*new*/ g_strchomp(char* string_);
23387 char* /*new*/ g_strchug(char* string_);
23388 int g_strcmp0(char* str1, char* str2);
23389 char* /*new*/ g_strcompress(char* source);
23390 char* /*new*/ g_strconcat(char* string1, ...);
23391 char* /*new*/ g_strdelimit(char* string_, char* delimiters, char new_delimiter);
23392 char* /*new*/ g_strdown(char* string_);
23393 char* /*new*/ g_strdup(char* str);
23394 char* /*new*/ g_strdup_printf(char* format, ...);
23395 char* /*new*/ g_strdup_vprintf(char* format, va_list args);
23396 char** g_strdupv(char** str_array);
23397 char* g_strerror(int errnum);
23398 char* /*new*/ g_strescape(char* source, char* exceptions);
23399 void g_strfreev(char** str_array);
23400 String* /*new*/ g_string_new(char* init);
23401 String* /*new*/ g_string_new_len(char* init, ssize_t len);
23402 String* /*new*/ g_string_sized_new(size_t dfl_size);
23403 char* g_strip_context(char* msgid, char* msgval);
23404 char* /*new*/ g_strjoin(char* separator, ...);
23405 char* /*new*/ g_strjoinv(char* separator, char** str_array);
23406 size_t g_strlcat(char* dest, char* src, size_t dest_size);
23407 size_t g_strlcpy(char* dest, char* src, size_t dest_size);
23408 int g_strncasecmp(char* s1, char* s2, uint n);
23409 char* /*new*/ g_strndup(char* str, size_t n);
23410 char* /*new*/ g_strnfill(size_t length, char fill_char);
23411 char* /*new*/ g_strreverse(char* string_);
23412 char* /*new*/ g_strrstr(char* haystack, char* needle);
23413 char* /*new*/ g_strrstr_len(char* haystack, ssize_t haystack_len, char* needle);
23414 char* g_strsignal(int signum);
23415 char** g_strsplit(char* string_, char* delimiter, int max_tokens);
23416 char** g_strsplit_set(char* string_, char* delimiters, int max_tokens);
23417 char* /*new*/ g_strstr_len(char* haystack, ssize_t haystack_len, char* needle);
23418 double g_strtod(char* nptr, char** endptr);
23419 char* /*new*/ g_strup(char* string_);
23420 Type g_strv_get_type();
23421 uint g_strv_length(char** str_array);
23422 void g_test_add_data_func(char* testpath, const(void)* test_data, TestDataFunc test_func);
23423 void g_test_add_func(char* testpath, TestFunc test_func);
23424 void g_test_add_vtable(char* testpath, size_t data_size, const(void)* test_data, TestFixtureFunc data_setup, TestFixtureFunc data_test, TestFixtureFunc data_teardown);
23425 void g_test_bug(char* bug_uri_snippet);
23426 void g_test_bug_base(char* uri_pattern);
23427 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);
23428 TestSuite* g_test_create_suite(char* suite_name);
23429 void g_test_fail();
23430 TestSuite* g_test_get_root();
23431 void g_test_init(int* argc, char*** argv, ...);
23432 void g_test_log_set_fatal_handler(TestLogFatalFunc log_func, void* user_data);
23433 char* g_test_log_type_name(TestLogType log_type);
23434 void g_test_maximized_result(double maximized_quantity, char* format, ...);
23435 void g_test_message(char* format, ...);
23436 void g_test_minimized_result(double minimized_quantity, char* format, ...);
23437 void g_test_queue_destroy(DestroyNotify destroy_func, void* destroy_data);
23438 void g_test_queue_free(void* gfree_pointer);
23439 double g_test_rand_double();
23440 double g_test_rand_double_range(double range_start, double range_end);
23441 int g_test_rand_int();
23442 int g_test_rand_int_range(int begin, int end);
23443 int g_test_run();
23444 int g_test_run_suite(TestSuite* suite);
23445 double g_test_timer_elapsed();
23446 double g_test_timer_last();
23447 void g_test_timer_start();
23448 void g_test_trap_assertions(char* domain, char* file, int line, char* func, ulong assertion_flags, char* pattern);
23449 int g_test_trap_fork(ulong usec_timeout, TestTrapFlags test_trap_flags);
23450 int g_test_trap_has_passed();
23451 int g_test_trap_reached_timeout();
23452 uint g_timeout_add(uint interval, SourceFunc function_, void* data);
23453 uint g_timeout_add_full(int priority, uint interval, SourceFunc function_, void* data, DestroyNotify notify);
23454 uint g_timeout_add_seconds(uint interval, SourceFunc function_, void* data);
23455 uint g_timeout_add_seconds_full(int priority, uint interval, SourceFunc function_, void* data, DestroyNotify notify);
23456 Source* /*new*/ g_timeout_source_new(uint interval);
23457 Source* /*new*/ g_timeout_source_new_seconds(uint interval);
23458 void* g_try_malloc(size_t n_bytes);
23459 void* g_try_malloc0(size_t n_bytes);
23460 void* g_try_malloc0_n(size_t n_blocks, size_t n_block_bytes);
23461 void* g_try_malloc_n(size_t n_blocks, size_t n_block_bytes);
23462 void* g_try_realloc(void* mem, size_t n_bytes);
23463 void* g_try_realloc_n(void* mem, size_t n_blocks, size_t n_block_bytes);
23464 wchar* g_ucs4_to_utf16(dchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error);
23465 char* /*new*/ g_ucs4_to_utf8(dchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error);
23466 UnicodeBreakType g_unichar_break_type(dchar c);
23467 int g_unichar_combining_class(dchar uc);
23468 int g_unichar_compose(dchar a, dchar b, dchar* ch);
23469 int g_unichar_decompose(dchar ch, dchar* a, dchar* b);
23470 int g_unichar_digit_value(dchar c);
23471 size_t g_unichar_fully_decompose(dchar ch, int compat, dchar* result, size_t result_len);
23472 int g_unichar_get_mirror_char(dchar ch, dchar* mirrored_ch);
23473 UnicodeScript g_unichar_get_script(dchar ch);
23474 int g_unichar_isalnum(dchar c);
23475 int g_unichar_isalpha(dchar c);
23476 int g_unichar_iscntrl(dchar c);
23477 int g_unichar_isdefined(dchar c);
23478 int g_unichar_isdigit(dchar c);
23479 int g_unichar_isgraph(dchar c);
23480 int g_unichar_islower(dchar c);
23481 int g_unichar_ismark(dchar c);
23482 int g_unichar_isprint(dchar c);
23483 int g_unichar_ispunct(dchar c);
23484 int g_unichar_isspace(dchar c);
23485 int g_unichar_istitle(dchar c);
23486 int g_unichar_isupper(dchar c);
23487 int g_unichar_iswide(dchar c);
23488 int g_unichar_iswide_cjk(dchar c);
23489 int g_unichar_isxdigit(dchar c);
23490 int g_unichar_iszerowidth(dchar c);
23491 int g_unichar_to_utf8(dchar c, char* outbuf);
23492 dchar g_unichar_tolower(dchar c);
23493 dchar g_unichar_totitle(dchar c);
23494 dchar g_unichar_toupper(dchar c);
23495 UnicodeType g_unichar_type(dchar c);
23496 int g_unichar_validate(dchar ch);
23497 int g_unichar_xdigit_value(dchar c);
23498 dchar* g_unicode_canonical_decomposition(dchar ch, size_t* result_len);
23499 void g_unicode_canonical_ordering(dchar* string_, size_t len);
23500 UnicodeScript g_unicode_script_from_iso15924(uint iso15924);
23501 uint g_unicode_script_to_iso15924(UnicodeScript script);
23502 int g_unlink(char* filename);
23503 void g_unsetenv(char* variable);
23504 char* /*new*/ g_uri_escape_string(char* unescaped, char* reserved_chars_allowed, int allow_utf8);
23505 char** g_uri_list_extract_uris(char* uri_list);
23506 char* /*new*/ g_uri_parse_scheme(char* uri);
23507 char* /*new*/ g_uri_unescape_segment(char* escaped_string, char* escaped_string_end, char* illegal_characters);
23508 char* /*new*/ g_uri_unescape_string(char* escaped_string, char* illegal_characters);
23509 void g_usleep(c_ulong microseconds);
23510 dchar* g_utf16_to_ucs4(wchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error);
23511 char* /*new*/ g_utf16_to_utf8(wchar* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error);
23512 char* /*new*/ g_utf8_casefold(char* str, ssize_t len);
23513 int g_utf8_collate(char* str1, char* str2);
23514 char* /*new*/ g_utf8_collate_key(char* str, ssize_t len);
23515 char* /*new*/ g_utf8_collate_key_for_filename(char* str, ssize_t len);
23516 char* /*new*/ g_utf8_find_next_char(char* p, char* end);
23517 char* /*new*/ g_utf8_find_prev_char(char* str, char* p);
23518 dchar g_utf8_get_char(char* p);
23519 dchar g_utf8_get_char_validated(char* p, ssize_t max_len);
23520 char* /*new*/ g_utf8_normalize(char* str, ssize_t len, NormalizeMode mode);
23521 char* /*new*/ g_utf8_offset_to_pointer(char* str, c_long offset);
23522 c_long g_utf8_pointer_to_offset(char* str, char* pos);
23523 char* /*new*/ g_utf8_prev_char(char* p);
23524 char* /*new*/ g_utf8_strchr(char* p, ssize_t len, dchar c);
23525 char* /*new*/ g_utf8_strdown(char* str, ssize_t len);
23526 c_long g_utf8_strlen(char* p, ssize_t max);
23527 char* /*new*/ g_utf8_strncpy(char* dest, char* src, size_t n);
23528 char* /*new*/ g_utf8_strrchr(char* p, ssize_t len, dchar c);
23529 char* /*new*/ g_utf8_strreverse(char* str, ssize_t len);
23530 char* /*new*/ g_utf8_strup(char* str, ssize_t len);
23531 char* /*new*/ g_utf8_substring(char* str, c_long start_pos, c_long end_pos);
23532 dchar* g_utf8_to_ucs4(char* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error);
23533 dchar* g_utf8_to_ucs4_fast(char* str, c_long len, c_long* items_written);
23534 wchar* g_utf8_to_utf16(char* str, c_long len, c_long* items_read, c_long* items_written, GLib2.Error** error);
23535 int g_utf8_validate(char* str, ssize_t max_len, /*out*/ char** end=null);
23536 Type g_variant_get_gtype();
23537 VariantType* g_variant_get_type(Variant* value);
23538 int g_vasprintf(char** string_, char* format, va_list args);
23539 int g_vfprintf(FILE* file, char* format, va_list args);
23540 int g_vprintf(char* format, va_list args);
23541 int g_vsnprintf(char* string_, c_ulong n, char* format, va_list args);
23542 int g_vsprintf(char* string_, char* format, va_list args);
23543 void g_warn_message(char* domain, char* file, int line, char* func, char* warnexpr);