1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = glib-Miscellaneous-Utility-Functions.html
27  * outPack = glib
28  * outFile = Util
29  * strct   = 
30  * realStrct=
31  * ctorStrct=
32  * clss    = Util
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.ListG
47  * 	- glib.Str
48  * structWrap:
49  * 	- GList* -> ListG
50  * module aliases:
51  * local aliases:
52  * overrides:
53  */
54 
55 module glib.Util;
56 
57 public  import gtkc.glibtypes;
58 
59 private import gtkc.glib;
60 private import glib.ConstructionException;
61 
62 
63 private import glib.ListG;
64 private import glib.Str;
65 
66 
67 
68 
69 /**
70  * Description
71  * These are portable utility functions.
72  */
73 public class Util
74 {
75 	
76 	/**
77 	 * Creates a filename from a series of elements using the correct
78 	 * separator for filenames.
79 	 * On Unix, this function behaves identically to g_build_path
80 	 * (G_DIR_SEPARATOR_S, first_element, ....).
81 	 * On Windows, it takes into account that either the backslash
82 	 * (\ or slash (/) can be used
83 	 * as separator in filenames, but otherwise behaves as on Unix. When
84 	 * file pathname separators need to be inserted, the one that last
85 	 * previously occurred in the parameters (reading from left to right)
86 	 * is used.
87 	 * No attempt is made to force the resulting filename to be an absolute
88 	 * path. If the first element is a relative path, the result will
89 	 * be a relative path.
90 	 * Params:
91 	 * firstElement =  the first element in the path
92 	 * ... =  remaining elements in path, terminated by NULL
93 	 * Returns: a newly-allocated string that must be freed with g_free().
94 	 */
95 	public static string buildFilename(string[] firstElement ... )
96 	{
97 		// gchar* g_build_filename (const gchar *first_element,  ...);
98 		return buildFilenamev(Str.toStringzArray(firstElement));
99 	}
100 	
101 	/**
102 	 * Creates a path from a series of elements using separator as the
103 	 * separator between elements. At the boundary between two elements,
104 	 * any trailing occurrences of separator in the first element, or
105 	 * leading occurrences of separator in the second element are removed
106 	 * and exactly one copy of the separator is inserted.
107 	 * Empty elements are ignored.
108 	 * The number of leading copies of the separator on the result is
109 	 * the same as the number of leading copies of the separator on
110 	 * the first non-empty element.
111 	 * The number of trailing copies of the separator on the result is
112 	 * the same as the number of trailing copies of the separator on
113 	 * the last non-empty element. (Determination of the number of
114 	 * trailing copies is done without stripping leading copies, so
115 	 * if the separator is ABA, ABABA
116 	 * has 1 trailing copy.)
117 	 * However, if there is only a single non-empty element, and there
118 	 * are no characters in that element not part of the leading or
119 	 * trailing separators, then the result is exactly the original value
120 	 * of that element.
121 	 * Other than for determination of the number of leading and trailing
122 	 * copies of the separator, elements consisting only of copies
123 	 * of the separator are ignored.
124 	 * Params:
125 	 * separator =  a string used to separator the elements of the path.
126 	 * firstElement =  the first element in the path
127 	 * ... =  remaining elements in path, terminated by NULL
128 	 * Returns: a newly-allocated string that must be freed with g_free().
129 	 */
130 	public static string buildPath(string separator, string[] firstElement ... )
131 	{
132 		// gchar* g_build_path (const gchar *separator,  const gchar *first_element,  ...);
133 		return buildPathv(separator, Str.toStringzArray(firstElement));
134 	}
135 	
136 	/**
137 	 */
138 	
139 	/**
140 	 * Gets a human-readable name for the application, as set by
141 	 * g_set_application_name(). This name should be localized if
142 	 * possible, and is intended for display to the user. Contrast with
143 	 * g_get_prgname(), which gets a non-localized name. If
144 	 * g_set_application_name() has not been called, returns the result of
145 	 * g_get_prgname() (which may be NULL if g_set_prgname() has also not
146 	 * been called).
147 	 * Since 2.2
148 	 * Returns: human-readable application name. may return NULL
149 	 */
150 	public static string getApplicationName()
151 	{
152 		// const gchar * g_get_application_name (void);
153 		return Str.toString(g_get_application_name());
154 	}
155 	
156 	/**
157 	 * Sets a human-readable name for the application. This name should be
158 	 * localized if possible, and is intended for display to the user.
159 	 * Contrast with g_set_prgname(), which sets a non-localized name.
160 	 * g_set_prgname() will be called automatically by gtk_init(),
161 	 * but g_set_application_name() will not.
162 	 * Note that for thread safety reasons, this function can only
163 	 * be called once.
164 	 * The application name will be used in contexts such as error messages,
165 	 * or when displaying an application's name in the task list.
166 	 * Since 2.2
167 	 * Params:
168 	 * applicationName = localized name of the application
169 	 */
170 	public static void setApplicationName(string applicationName)
171 	{
172 		// void g_set_application_name (const gchar *application_name);
173 		g_set_application_name(Str.toStringz(applicationName));
174 	}
175 	
176 	/**
177 	 * Gets the name of the program. This name should not
178 	 * be localized, contrast with g_get_application_name().
179 	 * (If you are using GDK or GTK+ the program name is set in gdk_init(),
180 	 * which is called by gtk_init(). The program name is found by taking
181 	 * the last component of argv[0].)
182 	 * Returns: the name of the program. The returned string belongs to GLib and must not be modified or freed.
183 	 */
184 	public static string getPrgname()
185 	{
186 		// gchar * g_get_prgname (void);
187 		return Str.toString(g_get_prgname());
188 	}
189 	
190 	/**
191 	 * Sets the name of the program. This name should not
192 	 * be localized, contrast with g_set_application_name(). Note that for
193 	 * thread-safety reasons this function can only be called once.
194 	 * Params:
195 	 * prgname = the name of the program.
196 	 */
197 	public static void setPrgname(string prgname)
198 	{
199 		// void g_set_prgname (const gchar *prgname);
200 		g_set_prgname(Str.toStringz(prgname));
201 	}
202 	
203 	/**
204 	 * Gets the list of environment variables for the current process. The
205 	 * list is NULL terminated and each item in the list is of the form
206 	 * 'NAME=VALUE'.
207 	 * This is equivalent to direct access to the 'environ' global variable,
208 	 * except portable.
209 	 * The return value is freshly allocated and it should be freed with
210 	 * g_strfreev() when it is no longer needed.
211 	 * Since 2.28
212 	 * Returns: the list of environment variables
213 	 */
214 	public static string[] getEnviron()
215 	{
216 		// gchar ** g_get_environ (void);
217 		return Str.toStringArray(g_get_environ());
218 	}
219 	
220 	/**
221 	 * Gets the names of all variables set in the environment.
222 	 * Since 2.8
223 	 * Returns: a NULL-terminated list of strings which must be freed with g_strfreev(). Programs that want to be portable to Windows should typically use this function and g_getenv() instead of using the environ array from the C library directly. On Windows, the strings in the environ array are in system codepage encoding, while in most of the typical use cases for environment variables in GLib-using programs you want the UTF-8 encoding that this function and g_getenv() provide.
224 	 */
225 	public static string[] listenv()
226 	{
227 		// gchar ** g_listenv (void);
228 		return Str.toStringArray(g_listenv());
229 	}
230 	
231 	/**
232 	 * Returns a base directory in which to store non-essential, cached
233 	 * data specific to particular user.
234 	 * On UNIX platforms this is determined using the mechanisms described in
235 	 * the
236 	 * XDG Base Directory Specification.
237 	 * In this case the directory retrieved will be XDG_CACHE_HOME.
238 	 * On Windows is the directory that serves as a common repository for
239 	 * temporary Internet files. A typical path is
240 	 * C:\Documents and Settings\username\Local Settings\Temporary Internet Files.
241 	 * See documentation for CSIDL_INTERNET_CACHE.
242 	 * Since 2.6
243 	 * Returns: a string owned by GLib that must not be modified or freed.
244 	 */
245 	public static string getUserCacheDir()
246 	{
247 		// const gchar * g_get_user_cache_dir (void);
248 		return Str.toString(g_get_user_cache_dir());
249 	}
250 	
251 	/**
252 	 * Returns a base directory in which to access application data such
253 	 * as icons that is customized for a particular user.
254 	 * On UNIX platforms this is determined using the mechanisms described in
255 	 * the
256 	 * XDG Base Directory Specification.
257 	 * In this case the directory retrieved will be XDG_DATA_HOME.
258 	 * On Windows this is the folder to use for local (as opposed to
259 	 * roaming) application data. See documentation for
260 	 * CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
261 	 * what g_get_user_config_dir() returns.
262 	 * Since 2.6
263 	 * Returns: a string owned by GLib that must not be modified or freed.
264 	 */
265 	public static string getUserDataDir()
266 	{
267 		// const gchar * g_get_user_data_dir (void);
268 		return Str.toString(g_get_user_data_dir());
269 	}
270 	
271 	/**
272 	 * Returns a base directory in which to store user-specific application
273 	 * configuration information such as user preferences and settings.
274 	 * On UNIX platforms this is determined using the mechanisms described in
275 	 * the
276 	 * XDG Base Directory Specification.
277 	 * In this case the directory retrieved will be XDG_CONFIG_HOME.
278 	 * On Windows this is the folder to use for local (as opposed to
279 	 * roaming) application data. See documentation for
280 	 * CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
281 	 * what g_get_user_data_dir() returns.
282 	 * Since 2.6
283 	 * Returns: a string owned by GLib that must not be modified or freed.
284 	 */
285 	public static string getUserConfigDir()
286 	{
287 		// const gchar * g_get_user_config_dir (void);
288 		return Str.toString(g_get_user_config_dir());
289 	}
290 	
291 	/**
292 	 * Returns a directory that is unique to the current user on the local
293 	 * system.
294 	 * On UNIX platforms this is determined using the mechanisms described in
295 	 * the
296 	 * XDG Base Directory Specification. This is the directory
297 	 * specified in the XDG_RUNTIME_DIR environment variable.
298 	 * In the case that this variable is not set, GLib will issue a warning
299 	 * message to stderr and return the value of g_get_user_cache_dir().
300 	 * On Windows this is the folder to use for local (as opposed to
301 	 * roaming) application data. See documentation for
302 	 * CSIDL_LOCAL_APPDATA. Note that on Windows it thus is the same as
303 	 * what g_get_user_config_dir() returns.
304 	 * Since 2.28
305 	 * Returns: a string owned by GLib that must not be modified or freed.
306 	 */
307 	public static string getUserRuntimeDir()
308 	{
309 		// const gchar * g_get_user_runtime_dir (void);
310 		return Str.toString(g_get_user_runtime_dir());
311 	}
312 	
313 	/**
314 	 * Returns the full path of a special directory using its logical id.
315 	 * On Unix this is done using the XDG special user directories.
316 	 * For compatibility with existing practise, G_USER_DIRECTORY_DESKTOP
317 	 * falls back to $HOME/Desktop when XDG special
318 	 * user directories have not been set up.
319 	 * Depending on the platform, the user might be able to change the path
320 	 * of the special directory without requiring the session to restart; GLib
321 	 * will not reflect any change once the special directories are loaded.
322 	 * Since 2.14
323 	 * Params:
324 	 * directory = the logical id of special directory
325 	 * Returns: the path to the specified special directory, or NULL if the logical id was not found. The returned string is owned by GLib and should not be modified or freed.
326 	 */
327 	public static string getUserSpecialDir(GUserDirectory directory)
328 	{
329 		// const gchar * g_get_user_special_dir (GUserDirectory directory);
330 		return Str.toString(g_get_user_special_dir(directory));
331 	}
332 	
333 	/**
334 	 * Returns an ordered list of base directories in which to access
335 	 * system-wide application data.
336 	 * On UNIX platforms this is determined using the mechanisms described in
337 	 * the
338 	 * XDG Base Directory Specification
339 	 * In this case the list of directories retrieved will be XDG_DATA_DIRS.
340 	 * On Windows the first elements in the list are the Application Data
341 	 * and Documents folders for All Users. (These can be determined only
342 	 * on Windows 2000 or later and are not present in the list on other
343 	 * Windows versions.) See documentation for CSIDL_COMMON_APPDATA and
344 	 * CSIDL_COMMON_DOCUMENTS.
345 	 * Then follows the "share" subfolder in the installation folder for
346 	 * the package containing the DLL that calls this function, if it can
347 	 * be determined.
348 	 * Finally the list contains the "share" subfolder in the installation
349 	 * folder for GLib, and in the installation folder for the package the
350 	 * application's .exe file belongs to.
351 	 * The installation folders above are determined by looking up the
352 	 * folder where the module (DLL or EXE) in question is located. If the
353 	 * folder's name is "bin", its parent is used, otherwise the folder
354 	 * itself.
355 	 * Note that on Windows the returned list can vary depending on where
356 	 * this function is called.
357 	 * Since 2.6
358 	 * Returns: a NULL-terminated array of strings owned by GLib that must not be modified or freed.
359 	 */
360 	public static string[] getSystemDataDirs()
361 	{
362 		// const gchar * const * g_get_system_data_dirs (void);
363 		return Str.toStringArray(g_get_system_data_dirs());
364 	}
365 	
366 	/**
367 	 * Returns an ordered list of base directories in which to access
368 	 * system-wide configuration information.
369 	 * On UNIX platforms this is determined using the mechanisms described in
370 	 * the
371 	 * XDG Base Directory Specification.
372 	 * In this case the list of directories retrieved will be XDG_CONFIG_DIRS.
373 	 * On Windows is the directory that contains application data for all users.
374 	 * A typical path is C:\Documents and Settings\All Users\Application Data.
375 	 * This folder is used for application data that is not user specific.
376 	 * For example, an application can store a spell-check dictionary, a database
377 	 * of clip art, or a log file in the CSIDL_COMMON_APPDATA folder.
378 	 * This information will not roam and is available to anyone using the computer.
379 	 * Since 2.6
380 	 * Returns: a NULL-terminated array of strings owned by GLib that must not be modified or freed.
381 	 */
382 	public static string[] getSystemConfigDirs()
383 	{
384 		// const gchar * const * g_get_system_config_dirs (void);
385 		return Str.toStringArray(g_get_system_config_dirs());
386 	}
387 	
388 	/**
389 	 * Resets the cache used for g_get_user_special_dir(), so
390 	 * that the latest on-disk version is used. Call this only
391 	 * if you just changed the data on disk yourself.
392 	 * Due to threadsafety issues this may cause leaking of strings
393 	 * that were previously returned from g_get_user_special_dir()
394 	 * that can't be freed. We ensure to only leak the data for
395 	 * the directories that actually changed value though.
396 	 * Since 2.22
397 	 */
398 	public static void reloadUserSpecialDirsCache()
399 	{
400 		// void g_reload_user_special_dirs_cache (void);
401 		g_reload_user_special_dirs_cache();
402 	}
403 	
404 	/**
405 	 * Return a name for the machine.
406 	 * The returned name is not necessarily a fully-qualified domain name,
407 	 * or even present in DNS or some other name service at all. It need
408 	 * not even be unique on your local network or site, but usually it
409 	 * is. Callers should not rely on the return value having any specific
410 	 * properties like uniqueness for security purposes. Even if the name
411 	 * of the machine is changed while an application is running, the
412 	 * return value from this function does not change. The returned
413 	 * string is owned by GLib and should not be modified or freed. If no
414 	 * name can be determined, a default fixed string "localhost" is
415 	 * returned.
416 	 * Since 2.8
417 	 * Returns: the host name of the machine.
418 	 */
419 	public static string getHostName()
420 	{
421 		// const gchar * g_get_host_name (void);
422 		return Str.toString(g_get_host_name());
423 	}
424 	
425 	/**
426 	 * Warning
427 	 * g_basename has been deprecated since version 2.2 and should not be used in newly-written code. Use g_path_get_basename() instead, but notice that
428 	 * g_path_get_basename() allocates new memory for the returned string, unlike
429 	 * this function which returns a pointer into the argument.
430 	 * Gets the name of the file without any leading directory components.
431 	 * It returns a pointer into the given file name string.
432 	 * Params:
433 	 * fileName = the name of the file.
434 	 * Returns: the name of the file without any leading directory components.
435 	 */
436 	public static string basename(string fileName)
437 	{
438 		// const gchar * g_basename (const gchar *file_name);
439 		return Str.toString(g_basename(Str.toStringz(fileName)));
440 	}
441 	
442 	/**
443 	 * Returns TRUE if the given file_name is an absolute file name.
444 	 * Note that this is a somewhat vague concept on Windows.
445 	 * On POSIX systems, an absolute file name is well-defined. It always
446 	 * starts from the single root directory. For example "/usr/local".
447 	 * On Windows, the concepts of current drive and drive-specific
448 	 * current directory introduce vagueness. This function interprets as
449 	 * an absolute file name one that either begins with a directory
450 	 * separator such as "\Users\tml" or begins with the root on a drive,
451 	 * for example "C:\Windows". The first case also includes UNC paths
452 	 * such as "\\myserver\docs\foo". In all cases, either slashes or
453 	 * backslashes are accepted.
454 	 * Note that a file name relative to the current drive root does not
455 	 * truly specify a file uniquely over time and across processes, as
456 	 * the current drive is a per-process value and can be changed.
457 	 * File names relative the current directory on some specific drive,
458 	 * such as "D:foo/bar", are not interpreted as absolute by this
459 	 * function, but they obviously are not relative to the normal current
460 	 * directory as returned by getcwd() or g_get_current_dir()
461 	 * either. Such paths should be avoided, or need to be handled using
462 	 * Windows-specific code.
463 	 * Params:
464 	 * fileName = a file name.
465 	 * Returns: TRUE if file_name is absolute.
466 	 */
467 	public static int pathIsAbsolute(string fileName)
468 	{
469 		// gboolean g_path_is_absolute (const gchar *file_name);
470 		return g_path_is_absolute(Str.toStringz(fileName));
471 	}
472 	
473 	/**
474 	 * Returns a pointer into file_name after the root component, i.e. after
475 	 * the "/" in UNIX or "C:\" under Windows. If file_name is not an absolute
476 	 * path it returns NULL.
477 	 * Params:
478 	 * fileName = a file name.
479 	 * Returns: a pointer into file_name after the root component.
480 	 */
481 	public static string pathSkipRoot(string fileName)
482 	{
483 		// const gchar * g_path_skip_root (const gchar *file_name);
484 		return Str.toString(g_path_skip_root(Str.toStringz(fileName)));
485 	}
486 	
487 	/**
488 	 * Gets the last component of the filename. If file_name ends with a
489 	 * directory separator it gets the component before the last slash. If
490 	 * file_name consists only of directory separators (and on Windows,
491 	 * possibly a drive letter), a single separator is returned. If
492 	 * file_name is empty, it gets ".".
493 	 * Params:
494 	 * fileName = the name of the file.
495 	 * Returns: a newly allocated string containing the last component of the filename.
496 	 */
497 	public static string pathGetBasename(string fileName)
498 	{
499 		// gchar * g_path_get_basename (const gchar *file_name);
500 		return Str.toString(g_path_get_basename(Str.toStringz(fileName)));
501 	}
502 	
503 	/**
504 	 * Gets the directory components of a file name. If the file name has no
505 	 * directory components "." is returned. The returned string should be
506 	 * freed when no longer needed.
507 	 * Params:
508 	 * fileName = the name of the file.
509 	 * Returns: the directory components of the file.
510 	 */
511 	public static string pathGetDirname(string fileName)
512 	{
513 		// gchar * g_path_get_dirname (const gchar *file_name);
514 		return Str.toString(g_path_get_dirname(Str.toStringz(fileName)));
515 	}
516 	
517 	/**
518 	 * Behaves exactly like g_build_filename(), but takes the path elements
519 	 * as a string array, instead of varargs. This function is mainly
520 	 * meant for language bindings.
521 	 * Since 2.8
522 	 * Params:
523 	 * args = NULL-terminated array of strings containing the path elements.
524 	 * Returns: a newly-allocated string that must be freed with g_free().
525 	 */
526 	public static string buildFilenamev(char** args)
527 	{
528 		// gchar * g_build_filenamev (gchar **args);
529 		return Str.toString(g_build_filenamev(args));
530 	}
531 	
532 	/**
533 	 * Behaves exactly like g_build_path(), but takes the path elements
534 	 * as a string array, instead of varargs. This function is mainly
535 	 * meant for language bindings.
536 	 * Since 2.8
537 	 * Params:
538 	 * separator = a string used to separator the elements of the path.
539 	 * args = NULL-terminated array of strings containing the path elements.
540 	 * Returns: a newly-allocated string that must be freed with g_free().
541 	 */
542 	public static string buildPathv(string separator, char** args)
543 	{
544 		// gchar * g_build_pathv (const gchar *separator,  gchar **args);
545 		return Str.toString(g_build_pathv(Str.toStringz(separator), args));
546 	}
547 	
548 	/**
549 	 * Formats a size (for example the size of a file) into a human readable string.
550 	 * Sizes are rounded to the nearest size prefix (KB, MB, GB) and are displayed
551 	 * rounded to the nearest tenth. E.g. the file size 3292528 bytes will be
552 	 * converted into the string "3.1 MB".
553 	 * The prefix units base is 1024 (i.e. 1 KB is 1024 bytes).
554 	 * This string should be freed with g_free() when not needed any longer.
555 	 * Since 2.16
556 	 * Params:
557 	 * size = a size in bytes.
558 	 * Returns: a newly-allocated formatted string containing a human readable file size.
559 	 */
560 	public static string formatSizeForDisplay(long size)
561 	{
562 		// char * g_format_size_for_display (goffset size);
563 		return Str.toString(g_format_size_for_display(size));
564 	}
565 	
566 	/**
567 	 * Find the position of the first bit set in mask, searching from (but not
568 	 * including) nth_bit upwards. Bits are numbered from 0 (least significant)
569 	 * to sizeof(gulong) * 8 - 1 (31 or 63, usually). To start searching from the
570 	 * 0th bit, set nth_bit to -1.
571 	 * Params:
572 	 * mask = a gulong containing flags.
573 	 * nthBit = the index of the bit to start the search from.
574 	 * Returns: the index of the first bit set which is higher than nth_bit.
575 	 */
576 	public static int bitNthLsf(gulong mask, int nthBit)
577 	{
578 		// gint g_bit_nth_lsf (gulong mask,  gint nth_bit);
579 		return g_bit_nth_lsf(mask, nthBit);
580 	}
581 	
582 	/**
583 	 * Find the position of the first bit set in mask, searching from (but not
584 	 * including) nth_bit downwards. Bits are numbered from 0 (least significant)
585 	 * to sizeof(gulong) * 8 - 1 (31 or 63, usually). To start searching from the
586 	 * last bit, set nth_bit to -1 or GLIB_SIZEOF_LONG * 8.
587 	 * Params:
588 	 * mask = a gulong containing flags.
589 	 * nthBit = the index of the bit to start the search from.
590 	 * Returns: the index of the first bit set which is lower than nth_bit.
591 	 */
592 	public static int bitNthMsf(gulong mask, int nthBit)
593 	{
594 		// gint g_bit_nth_msf (gulong mask,  gint nth_bit);
595 		return g_bit_nth_msf(mask, nthBit);
596 	}
597 	
598 	/**
599 	 * Gets the number of bits used to hold number,
600 	 * e.g. if number is 4, 3 bits are needed.
601 	 * Params:
602 	 * number = a guint.
603 	 * Returns: the number of bits used to hold number.
604 	 */
605 	public static uint bitStorage(gulong number)
606 	{
607 		// guint g_bit_storage (gulong number);
608 		return g_bit_storage(number);
609 	}
610 	
611 	/**
612 	 * Gets the smallest prime number from a built-in array of primes which
613 	 * is larger than num. This is used within GLib to calculate the optimum
614 	 * size of a GHashTable.
615 	 * The built-in array of primes ranges from 11 to 13845163 such that
616 	 * each prime is approximately 1.5-2 times the previous prime.
617 	 * Params:
618 	 * num = a guint.
619 	 * Returns: the smallest prime number from a built-in array of primes which is larger than num.
620 	 */
621 	public static uint spacedPrimesClosest(uint num)
622 	{
623 		// guint g_spaced_primes_closest (guint num);
624 		return g_spaced_primes_closest(num);
625 	}
626 	
627 	/**
628 	 * Specifies a function to be called at normal program termination.
629 	 * Since GLib 2.8.2, on Windows g_atexit() actually is a preprocessor
630 	 * macro that maps to a call to the atexit() function in the C
631 	 * library. This means that in case the code that calls g_atexit(),
632 	 * i.e. atexit(), is in a DLL, the function will be called when the
633 	 * DLL is detached from the program. This typically makes more sense
634 	 * than that the function is called when the GLib DLL is detached,
635 	 * which happened earlier when g_atexit() was a function in the GLib
636 	 * DLL.
637 	 * The behaviour of atexit() in the context of dynamically loaded
638 	 * modules is not formally specified and varies wildly.
639 	 * On POSIX systems, calling g_atexit() (or atexit()) in a dynamically
640 	 * loaded module which is unloaded before the program terminates might
641 	 * well cause a crash at program exit.
642 	 * Some POSIX systems implement atexit() like Windows, and have each
643 	 * dynamically loaded module maintain an own atexit chain that is
644 	 * called when the module is unloaded.
645 	 * On other POSIX systems, before a dynamically loaded module is
646 	 * unloaded, the registered atexit functions (if any) residing in that
647 	 * module are called, regardless where the code that registered them
648 	 * resided. This is presumably the most robust approach.
649 	 * As can be seen from the above, for portability it's best to avoid
650 	 * calling g_atexit() (or atexit()) except in the main executable of a
651 	 * program.
652 	 * Params:
653 	 * func = the function to call on normal program termination.
654 	 */
655 	public static void atexit(GVoidFunc func)
656 	{
657 		// void g_atexit (GVoidFunc func);
658 		g_atexit(func);
659 	}
660 	
661 	/**
662 	 * Parses a string containing debugging options
663 	 * into a guint containing bit flags. This is used
664 	 * within GDK and GTK+ to parse the debug options passed on the
665 	 * command line or through environment variables.
666 	 * If string is equal to "all", all flags are set. If string
667 	 * is equal to "help", all the available keys in keys are printed
668 	 * out to standard error.
669 	 * Params:
670 	 * string = a list of debug options separated by colons, spaces, or
671 	 * commas, or NULL.
672 	 * keys = pointer to an array of GDebugKey which associate
673 	 * strings with bit flags.
674 	 * nkeys = the number of GDebugKeys in the array.
675 	 * Returns: the combined set of bit flags.
676 	 */
677 	public static uint parseDebugString(string string, GDebugKey* keys, uint nkeys)
678 	{
679 		// guint g_parse_debug_string (const gchar *string,  const GDebugKey *keys,  guint nkeys);
680 		return g_parse_debug_string(Str.toStringz(string), keys, nkeys);
681 	}
682 	
683 	/**
684 	 * This is just like the standard C qsort() function, but
685 	 * the comparison routine accepts a user data argument.
686 	 * Params:
687 	 * pbase = start of array to sort
688 	 * totalElems = elements in the array
689 	 * size = size of each element
690 	 * compareFunc = function to compare elements
691 	 * userData = data to pass to compare_func
692 	 */
693 	public static void qsortWithData(void* pbase, int totalElems, gsize size, GCompareDataFunc compareFunc, void* userData)
694 	{
695 		// void g_qsort_with_data (gconstpointer pbase,  gint total_elems,  gsize size,  GCompareDataFunc compare_func,  gpointer user_data);
696 		g_qsort_with_data(pbase, totalElems, size, compareFunc, userData);
697 	}
698 	
699 	/**
700 	 * Set the pointer at the specified location to NULL.
701 	 * Params:
702 	 * nullifyLocation = the memory address of the pointer.
703 	 */
704 	public static void nullifyPointer(void** nullifyLocation)
705 	{
706 		// void g_nullify_pointer (gpointer *nullify_location);
707 		g_nullify_pointer(nullifyLocation);
708 	}
709 }