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 module glib.KeyFile;
26 
27 private import glib.Bytes;
28 private import glib.ConstructionException;
29 private import glib.ErrorG;
30 private import glib.GException;
31 private import glib.Str;
32 private import glib.c.functions;
33 public  import glib.c.types;
34 public  import gtkc.glibtypes;
35 private import gtkd.Loader;
36 
37 
38 /**
39  * The GKeyFile struct contains only private data
40  * and should not be accessed directly.
41  */
42 public class KeyFile
43 {
44 	/** the main Gtk struct */
45 	protected GKeyFile* gKeyFile;
46 	protected bool ownedRef;
47 
48 	/** Get the main Gtk struct */
49 	public GKeyFile* getKeyFileStruct(bool transferOwnership = false)
50 	{
51 		if (transferOwnership)
52 			ownedRef = false;
53 		return gKeyFile;
54 	}
55 
56 	/** the main Gtk struct as a void* */
57 	protected void* getStruct()
58 	{
59 		return cast(void*)gKeyFile;
60 	}
61 
62 	/**
63 	 * Sets our main struct and passes it to the parent class.
64 	 */
65 	public this (GKeyFile* gKeyFile, bool ownedRef = false)
66 	{
67 		this.gKeyFile = gKeyFile;
68 		this.ownedRef = ownedRef;
69 	}
70 
71 	~this ()
72 	{
73 		if ( Linker.isLoaded(LIBRARY_GLIB) && ownedRef )
74 			g_key_file_unref(gKeyFile);
75 	}
76 
77 
78 	/**
79 	 * Creates a new empty #GKeyFile object. Use
80 	 * g_key_file_load_from_file(), g_key_file_load_from_data(),
81 	 * g_key_file_load_from_dirs() or g_key_file_load_from_data_dirs() to
82 	 * read an existing key file.
83 	 *
84 	 * Returns: an empty #GKeyFile.
85 	 *
86 	 * Since: 2.6
87 	 *
88 	 * Throws: ConstructionException GTK+ fails to create the object.
89 	 */
90 	public this()
91 	{
92 		auto p = g_key_file_new();
93 
94 		if(p is null)
95 		{
96 			throw new ConstructionException("null returned by new");
97 		}
98 
99 		this(cast(GKeyFile*) p);
100 	}
101 
102 	/**
103 	 * Clears all keys and groups from @key_file, and decreases the
104 	 * reference count by 1. If the reference count reaches zero,
105 	 * frees the key file and all its allocated memory.
106 	 *
107 	 * Since: 2.6
108 	 */
109 	public void free()
110 	{
111 		g_key_file_free(gKeyFile);
112 		ownedRef = false;
113 	}
114 
115 	/**
116 	 * Returns the value associated with @key under @group_name as a
117 	 * boolean.
118 	 *
119 	 * If @key cannot be found then %FALSE is returned and @error is set
120 	 * to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value
121 	 * associated with @key cannot be interpreted as a boolean then %FALSE
122 	 * is returned and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
123 	 *
124 	 * Params:
125 	 *     groupName = a group name
126 	 *     key = a key
127 	 *
128 	 * Returns: the value associated with the key as a boolean,
129 	 *     or %FALSE if the key was not found or could not be parsed.
130 	 *
131 	 * Since: 2.6
132 	 *
133 	 * Throws: GException on failure.
134 	 */
135 	public bool getBoolean(string groupName, string key)
136 	{
137 		GError* err = null;
138 
139 		auto p = g_key_file_get_boolean(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), &err) != 0;
140 
141 		if (err !is null)
142 		{
143 			throw new GException( new ErrorG(err) );
144 		}
145 
146 		return p;
147 	}
148 
149 	/**
150 	 * Returns the values associated with @key under @group_name as
151 	 * booleans.
152 	 *
153 	 * If @key cannot be found then %NULL is returned and @error is set to
154 	 * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
155 	 * with @key cannot be interpreted as booleans then %NULL is returned
156 	 * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
157 	 *
158 	 * Params:
159 	 *     groupName = a group name
160 	 *     key = a key
161 	 *
162 	 * Returns: the values associated with the key as a list of booleans, or %NULL if the
163 	 *     key was not found or could not be parsed. The returned list of booleans
164 	 *     should be freed with g_free() when no longer needed.
165 	 *
166 	 * Since: 2.6
167 	 *
168 	 * Throws: GException on failure.
169 	 */
170 	public bool[] getBooleanList(string groupName, string key)
171 	{
172 		size_t length;
173 		GError* err = null;
174 
175 		auto p = g_key_file_get_boolean_list(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), &length, &err);
176 
177 		if (err !is null)
178 		{
179 			throw new GException( new ErrorG(err) );
180 		}
181 
182 		bool[] r = new bool[length];
183 		for(size_t i = 0; i < length; i++)
184 		{
185 			r[i] = p[i] != 0;
186 		}
187 		return r;
188 	}
189 
190 	/**
191 	 * Retrieves a comment above @key from @group_name.
192 	 * If @key is %NULL then @comment will be read from above
193 	 * @group_name. If both @key and @group_name are %NULL, then
194 	 * @comment will be read from above the first group in the file.
195 	 *
196 	 * Note that the returned string includes the '#' comment markers.
197 	 *
198 	 * Params:
199 	 *     groupName = a group name, or %NULL
200 	 *     key = a key
201 	 *
202 	 * Returns: a comment that should be freed with g_free()
203 	 *
204 	 * Since: 2.6
205 	 *
206 	 * Throws: GException on failure.
207 	 */
208 	public string getComment(string groupName, string key)
209 	{
210 		GError* err = null;
211 
212 		auto retStr = g_key_file_get_comment(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), &err);
213 
214 		if (err !is null)
215 		{
216 			throw new GException( new ErrorG(err) );
217 		}
218 
219 		scope(exit) Str.freeString(retStr);
220 		return Str.toString(retStr);
221 	}
222 
223 	/**
224 	 * Returns the value associated with @key under @group_name as a
225 	 * double. If @group_name is %NULL, the start_group is used.
226 	 *
227 	 * If @key cannot be found then 0.0 is returned and @error is set to
228 	 * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated
229 	 * with @key cannot be interpreted as a double then 0.0 is returned
230 	 * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
231 	 *
232 	 * Params:
233 	 *     groupName = a group name
234 	 *     key = a key
235 	 *
236 	 * Returns: the value associated with the key as a double, or
237 	 *     0.0 if the key was not found or could not be parsed.
238 	 *
239 	 * Since: 2.12
240 	 *
241 	 * Throws: GException on failure.
242 	 */
243 	public double getDouble(string groupName, string key)
244 	{
245 		GError* err = null;
246 
247 		auto p = g_key_file_get_double(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), &err);
248 
249 		if (err !is null)
250 		{
251 			throw new GException( new ErrorG(err) );
252 		}
253 
254 		return p;
255 	}
256 
257 	/**
258 	 * Returns the values associated with @key under @group_name as
259 	 * doubles.
260 	 *
261 	 * If @key cannot be found then %NULL is returned and @error is set to
262 	 * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
263 	 * with @key cannot be interpreted as doubles then %NULL is returned
264 	 * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
265 	 *
266 	 * Params:
267 	 *     groupName = a group name
268 	 *     key = a key
269 	 *
270 	 * Returns: the values associated with the key as a list of doubles, or %NULL if the
271 	 *     key was not found or could not be parsed. The returned list of doubles
272 	 *     should be freed with g_free() when no longer needed.
273 	 *
274 	 * Since: 2.12
275 	 *
276 	 * Throws: GException on failure.
277 	 */
278 	public double[] getDoubleList(string groupName, string key)
279 	{
280 		size_t length;
281 		GError* err = null;
282 
283 		auto p = g_key_file_get_double_list(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), &length, &err);
284 
285 		if (err !is null)
286 		{
287 			throw new GException( new ErrorG(err) );
288 		}
289 
290 		return p[0 .. length];
291 	}
292 
293 	/**
294 	 * Returns all groups in the key file loaded with @key_file.
295 	 * The array of returned groups will be %NULL-terminated, so
296 	 * @length may optionally be %NULL.
297 	 *
298 	 * Params:
299 	 *     length = return location for the number of returned groups, or %NULL
300 	 *
301 	 * Returns: a newly-allocated %NULL-terminated array of strings.
302 	 *     Use g_strfreev() to free it.
303 	 *
304 	 * Since: 2.6
305 	 */
306 	public string[] getGroups(out size_t length)
307 	{
308 		auto retStr = g_key_file_get_groups(gKeyFile, &length);
309 
310 		scope(exit) Str.freeStringArray(retStr);
311 		return Str.toStringArray(retStr);
312 	}
313 
314 	/**
315 	 * Returns the value associated with @key under @group_name as a signed
316 	 * 64-bit integer. This is similar to g_key_file_get_integer() but can return
317 	 * 64-bit results without truncation.
318 	 *
319 	 * Params:
320 	 *     groupName = a non-%NULL group name
321 	 *     key = a non-%NULL key
322 	 *
323 	 * Returns: the value associated with the key as a signed 64-bit integer, or
324 	 *     0 if the key was not found or could not be parsed.
325 	 *
326 	 * Since: 2.26
327 	 *
328 	 * Throws: GException on failure.
329 	 */
330 	public long getInt64(string groupName, string key)
331 	{
332 		GError* err = null;
333 
334 		auto p = g_key_file_get_int64(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), &err);
335 
336 		if (err !is null)
337 		{
338 			throw new GException( new ErrorG(err) );
339 		}
340 
341 		return p;
342 	}
343 
344 	/**
345 	 * Returns the value associated with @key under @group_name as an
346 	 * integer.
347 	 *
348 	 * If @key cannot be found then 0 is returned and @error is set to
349 	 * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated
350 	 * with @key cannot be interpreted as an integer, or is out of range
351 	 * for a #gint, then 0 is returned
352 	 * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
353 	 *
354 	 * Params:
355 	 *     groupName = a group name
356 	 *     key = a key
357 	 *
358 	 * Returns: the value associated with the key as an integer, or
359 	 *     0 if the key was not found or could not be parsed.
360 	 *
361 	 * Since: 2.6
362 	 *
363 	 * Throws: GException on failure.
364 	 */
365 	public int getInteger(string groupName, string key)
366 	{
367 		GError* err = null;
368 
369 		auto p = g_key_file_get_integer(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), &err);
370 
371 		if (err !is null)
372 		{
373 			throw new GException( new ErrorG(err) );
374 		}
375 
376 		return p;
377 	}
378 
379 	/**
380 	 * Returns the values associated with @key under @group_name as
381 	 * integers.
382 	 *
383 	 * If @key cannot be found then %NULL is returned and @error is set to
384 	 * #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
385 	 * with @key cannot be interpreted as integers, or are out of range for
386 	 * #gint, then %NULL is returned
387 	 * and @error is set to #G_KEY_FILE_ERROR_INVALID_VALUE.
388 	 *
389 	 * Params:
390 	 *     groupName = a group name
391 	 *     key = a key
392 	 *
393 	 * Returns: the values associated with the key as a list of integers, or %NULL if
394 	 *     the key was not found or could not be parsed. The returned list of
395 	 *     integers should be freed with g_free() when no longer needed.
396 	 *
397 	 * Since: 2.6
398 	 *
399 	 * Throws: GException on failure.
400 	 */
401 	public int[] getIntegerList(string groupName, string key)
402 	{
403 		size_t length;
404 		GError* err = null;
405 
406 		auto p = g_key_file_get_integer_list(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), &length, &err);
407 
408 		if (err !is null)
409 		{
410 			throw new GException( new ErrorG(err) );
411 		}
412 
413 		return p[0 .. length];
414 	}
415 
416 	/**
417 	 * Returns all keys for the group name @group_name.  The array of
418 	 * returned keys will be %NULL-terminated, so @length may
419 	 * optionally be %NULL. In the event that the @group_name cannot
420 	 * be found, %NULL is returned and @error is set to
421 	 * #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
422 	 *
423 	 * Params:
424 	 *     groupName = a group name
425 	 *     length = return location for the number of keys returned, or %NULL
426 	 *
427 	 * Returns: a newly-allocated %NULL-terminated array of strings.
428 	 *     Use g_strfreev() to free it.
429 	 *
430 	 * Since: 2.6
431 	 *
432 	 * Throws: GException on failure.
433 	 */
434 	public string[] getKeys(string groupName, out size_t length)
435 	{
436 		GError* err = null;
437 
438 		auto retStr = g_key_file_get_keys(gKeyFile, Str.toStringz(groupName), &length, &err);
439 
440 		if (err !is null)
441 		{
442 			throw new GException( new ErrorG(err) );
443 		}
444 
445 		scope(exit) Str.freeStringArray(retStr);
446 		return Str.toStringArray(retStr);
447 	}
448 
449 	/**
450 	 * Returns the actual locale which the result of
451 	 * g_key_file_get_locale_string() or g_key_file_get_locale_string_list()
452 	 * came from.
453 	 *
454 	 * If calling g_key_file_get_locale_string() or
455 	 * g_key_file_get_locale_string_list() with exactly the same @key_file,
456 	 * @group_name, @key and @locale, the result of those functions will
457 	 * have originally been tagged with the locale that is the result of
458 	 * this function.
459 	 *
460 	 * Params:
461 	 *     groupName = a group name
462 	 *     key = a key
463 	 *     locale = a locale identifier or %NULL
464 	 *
465 	 * Returns: the locale from the file, or %NULL if the key was not
466 	 *     found or the entry in the file was was untranslated
467 	 *
468 	 * Since: 2.56
469 	 */
470 	public string getLocaleForKey(string groupName, string key, string locale)
471 	{
472 		auto retStr = g_key_file_get_locale_for_key(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), Str.toStringz(locale));
473 
474 		scope(exit) Str.freeString(retStr);
475 		return Str.toString(retStr);
476 	}
477 
478 	/**
479 	 * Returns the value associated with @key under @group_name
480 	 * translated in the given @locale if available.  If @locale is
481 	 * %NULL then the current locale is assumed.
482 	 *
483 	 * If @locale is to be non-%NULL, or if the current locale will change over
484 	 * the lifetime of the #GKeyFile, it must be loaded with
485 	 * %G_KEY_FILE_KEEP_TRANSLATIONS in order to load strings for all locales.
486 	 *
487 	 * If @key cannot be found then %NULL is returned and @error is set
488 	 * to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the value associated
489 	 * with @key cannot be interpreted or no suitable translation can
490 	 * be found then the untranslated value is returned.
491 	 *
492 	 * Params:
493 	 *     groupName = a group name
494 	 *     key = a key
495 	 *     locale = a locale identifier or %NULL
496 	 *
497 	 * Returns: a newly allocated string or %NULL if the specified
498 	 *     key cannot be found.
499 	 *
500 	 * Since: 2.6
501 	 *
502 	 * Throws: GException on failure.
503 	 */
504 	public string getLocaleString(string groupName, string key, string locale)
505 	{
506 		GError* err = null;
507 
508 		auto retStr = g_key_file_get_locale_string(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), Str.toStringz(locale), &err);
509 
510 		if (err !is null)
511 		{
512 			throw new GException( new ErrorG(err) );
513 		}
514 
515 		scope(exit) Str.freeString(retStr);
516 		return Str.toString(retStr);
517 	}
518 
519 	/**
520 	 * Returns the values associated with @key under @group_name
521 	 * translated in the given @locale if available.  If @locale is
522 	 * %NULL then the current locale is assumed.
523 	 *
524 	 * If @locale is to be non-%NULL, or if the current locale will change over
525 	 * the lifetime of the #GKeyFile, it must be loaded with
526 	 * %G_KEY_FILE_KEEP_TRANSLATIONS in order to load strings for all locales.
527 	 *
528 	 * If @key cannot be found then %NULL is returned and @error is set
529 	 * to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the values associated
530 	 * with @key cannot be interpreted or no suitable translations
531 	 * can be found then the untranslated values are returned. The
532 	 * returned array is %NULL-terminated, so @length may optionally
533 	 * be %NULL.
534 	 *
535 	 * Params:
536 	 *     groupName = a group name
537 	 *     key = a key
538 	 *     locale = a locale identifier or %NULL
539 	 *
540 	 * Returns: a newly allocated %NULL-terminated string array
541 	 *     or %NULL if the key isn't found. The string array should be freed
542 	 *     with g_strfreev().
543 	 *
544 	 * Since: 2.6
545 	 *
546 	 * Throws: GException on failure.
547 	 */
548 	public string[] getLocaleStringList(string groupName, string key, string locale)
549 	{
550 		size_t length;
551 		GError* err = null;
552 
553 		auto retStr = g_key_file_get_locale_string_list(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), Str.toStringz(locale), &length, &err);
554 
555 		if (err !is null)
556 		{
557 			throw new GException( new ErrorG(err) );
558 		}
559 
560 		scope(exit) Str.freeStringArray(retStr);
561 		return Str.toStringArray(retStr, length);
562 	}
563 
564 	/**
565 	 * Returns the name of the start group of the file.
566 	 *
567 	 * Returns: The start group of the key file.
568 	 *
569 	 * Since: 2.6
570 	 */
571 	public string getStartGroup()
572 	{
573 		auto retStr = g_key_file_get_start_group(gKeyFile);
574 
575 		scope(exit) Str.freeString(retStr);
576 		return Str.toString(retStr);
577 	}
578 
579 	/**
580 	 * Returns the string value associated with @key under @group_name.
581 	 * Unlike g_key_file_get_value(), this function handles escape sequences
582 	 * like \s.
583 	 *
584 	 * In the event the key cannot be found, %NULL is returned and
585 	 * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND.  In the
586 	 * event that the @group_name cannot be found, %NULL is returned
587 	 * and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
588 	 *
589 	 * Params:
590 	 *     groupName = a group name
591 	 *     key = a key
592 	 *
593 	 * Returns: a newly allocated string or %NULL if the specified
594 	 *     key cannot be found.
595 	 *
596 	 * Since: 2.6
597 	 *
598 	 * Throws: GException on failure.
599 	 */
600 	public string getString(string groupName, string key)
601 	{
602 		GError* err = null;
603 
604 		auto retStr = g_key_file_get_string(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), &err);
605 
606 		if (err !is null)
607 		{
608 			throw new GException( new ErrorG(err) );
609 		}
610 
611 		scope(exit) Str.freeString(retStr);
612 		return Str.toString(retStr);
613 	}
614 
615 	/**
616 	 * Returns the values associated with @key under @group_name.
617 	 *
618 	 * In the event the key cannot be found, %NULL is returned and
619 	 * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND.  In the
620 	 * event that the @group_name cannot be found, %NULL is returned
621 	 * and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
622 	 *
623 	 * Params:
624 	 *     groupName = a group name
625 	 *     key = a key
626 	 *
627 	 * Returns: a %NULL-terminated string array or %NULL if the specified
628 	 *     key cannot be found. The array should be freed with g_strfreev().
629 	 *
630 	 * Since: 2.6
631 	 *
632 	 * Throws: GException on failure.
633 	 */
634 	public string[] getStringList(string groupName, string key)
635 	{
636 		size_t length;
637 		GError* err = null;
638 
639 		auto retStr = g_key_file_get_string_list(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), &length, &err);
640 
641 		if (err !is null)
642 		{
643 			throw new GException( new ErrorG(err) );
644 		}
645 
646 		scope(exit) Str.freeStringArray(retStr);
647 		return Str.toStringArray(retStr, length);
648 	}
649 
650 	/**
651 	 * Returns the value associated with @key under @group_name as an unsigned
652 	 * 64-bit integer. This is similar to g_key_file_get_integer() but can return
653 	 * large positive results without truncation.
654 	 *
655 	 * Params:
656 	 *     groupName = a non-%NULL group name
657 	 *     key = a non-%NULL key
658 	 *
659 	 * Returns: the value associated with the key as an unsigned 64-bit integer,
660 	 *     or 0 if the key was not found or could not be parsed.
661 	 *
662 	 * Since: 2.26
663 	 *
664 	 * Throws: GException on failure.
665 	 */
666 	public ulong getUint64(string groupName, string key)
667 	{
668 		GError* err = null;
669 
670 		auto p = g_key_file_get_uint64(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), &err);
671 
672 		if (err !is null)
673 		{
674 			throw new GException( new ErrorG(err) );
675 		}
676 
677 		return p;
678 	}
679 
680 	/**
681 	 * Returns the raw value associated with @key under @group_name.
682 	 * Use g_key_file_get_string() to retrieve an unescaped UTF-8 string.
683 	 *
684 	 * In the event the key cannot be found, %NULL is returned and
685 	 * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND.  In the
686 	 * event that the @group_name cannot be found, %NULL is returned
687 	 * and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
688 	 *
689 	 * Params:
690 	 *     groupName = a group name
691 	 *     key = a key
692 	 *
693 	 * Returns: a newly allocated string or %NULL if the specified
694 	 *     key cannot be found.
695 	 *
696 	 * Since: 2.6
697 	 *
698 	 * Throws: GException on failure.
699 	 */
700 	public string getValue(string groupName, string key)
701 	{
702 		GError* err = null;
703 
704 		auto retStr = g_key_file_get_value(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), &err);
705 
706 		if (err !is null)
707 		{
708 			throw new GException( new ErrorG(err) );
709 		}
710 
711 		scope(exit) Str.freeString(retStr);
712 		return Str.toString(retStr);
713 	}
714 
715 	/**
716 	 * Looks whether the key file has the group @group_name.
717 	 *
718 	 * Params:
719 	 *     groupName = a group name
720 	 *
721 	 * Returns: %TRUE if @group_name is a part of @key_file, %FALSE
722 	 *     otherwise.
723 	 *
724 	 * Since: 2.6
725 	 */
726 	public bool hasGroup(string groupName)
727 	{
728 		return g_key_file_has_group(gKeyFile, Str.toStringz(groupName)) != 0;
729 	}
730 
731 	/**
732 	 * Looks whether the key file has the key @key in the group
733 	 * @group_name.
734 	 *
735 	 * Note that this function does not follow the rules for #GError strictly;
736 	 * the return value both carries meaning and signals an error.  To use
737 	 * this function, you must pass a #GError pointer in @error, and check
738 	 * whether it is not %NULL to see if an error occurred.
739 	 *
740 	 * Language bindings should use g_key_file_get_value() to test whether
741 	 * or not a key exists.
742 	 *
743 	 * Params:
744 	 *     groupName = a group name
745 	 *     key = a key name
746 	 *
747 	 * Returns: %TRUE if @key is a part of @group_name, %FALSE otherwise
748 	 *
749 	 * Since: 2.6
750 	 *
751 	 * Throws: GException on failure.
752 	 */
753 	public bool hasKey(string groupName, string key)
754 	{
755 		GError* err = null;
756 
757 		auto p = g_key_file_has_key(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), &err) != 0;
758 
759 		if (err !is null)
760 		{
761 			throw new GException( new ErrorG(err) );
762 		}
763 
764 		return p;
765 	}
766 
767 	/**
768 	 * Loads a key file from the data in @bytes into an empty #GKeyFile structure.
769 	 * If the object cannot be created then %error is set to a #GKeyFileError.
770 	 *
771 	 * Params:
772 	 *     bytes = a #GBytes
773 	 *     flags = flags from #GKeyFileFlags
774 	 *
775 	 * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
776 	 *
777 	 * Since: 2.50
778 	 *
779 	 * Throws: GException on failure.
780 	 */
781 	public bool loadFromBytes(Bytes bytes, GKeyFileFlags flags)
782 	{
783 		GError* err = null;
784 
785 		auto p = g_key_file_load_from_bytes(gKeyFile, (bytes is null) ? null : bytes.getBytesStruct(), flags, &err) != 0;
786 
787 		if (err !is null)
788 		{
789 			throw new GException( new ErrorG(err) );
790 		}
791 
792 		return p;
793 	}
794 
795 	/**
796 	 * Loads a key file from memory into an empty #GKeyFile structure.
797 	 * If the object cannot be created then %error is set to a #GKeyFileError.
798 	 *
799 	 * Params:
800 	 *     data = key file loaded in memory
801 	 *     length = the length of @data in bytes (or (gsize)-1 if data is nul-terminated)
802 	 *     flags = flags from #GKeyFileFlags
803 	 *
804 	 * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
805 	 *
806 	 * Since: 2.6
807 	 *
808 	 * Throws: GException on failure.
809 	 */
810 	public bool loadFromData(string data, size_t length, GKeyFileFlags flags)
811 	{
812 		GError* err = null;
813 
814 		auto p = g_key_file_load_from_data(gKeyFile, Str.toStringz(data), length, flags, &err) != 0;
815 
816 		if (err !is null)
817 		{
818 			throw new GException( new ErrorG(err) );
819 		}
820 
821 		return p;
822 	}
823 
824 	/**
825 	 * This function looks for a key file named @file in the paths
826 	 * returned from g_get_user_data_dir() and g_get_system_data_dirs(),
827 	 * loads the file into @key_file and returns the file's full path in
828 	 * @full_path.  If the file could not be loaded then an %error is
829 	 * set to either a #GFileError or #GKeyFileError.
830 	 *
831 	 * Params:
832 	 *     file = a relative path to a filename to open and parse
833 	 *     fullPath = return location for a string containing the full path
834 	 *         of the file, or %NULL
835 	 *     flags = flags from #GKeyFileFlags
836 	 *
837 	 * Returns: %TRUE if a key file could be loaded, %FALSE othewise
838 	 *
839 	 * Since: 2.6
840 	 *
841 	 * Throws: GException on failure.
842 	 */
843 	public bool loadFromDataDirs(string file, out string fullPath, GKeyFileFlags flags)
844 	{
845 		char* outfullPath = null;
846 		GError* err = null;
847 
848 		auto p = g_key_file_load_from_data_dirs(gKeyFile, Str.toStringz(file), &outfullPath, flags, &err) != 0;
849 
850 		if (err !is null)
851 		{
852 			throw new GException( new ErrorG(err) );
853 		}
854 
855 		fullPath = Str.toString(outfullPath);
856 
857 		return p;
858 	}
859 
860 	/**
861 	 * This function looks for a key file named @file in the paths
862 	 * specified in @search_dirs, loads the file into @key_file and
863 	 * returns the file's full path in @full_path.
864 	 *
865 	 * If the file could not be found in any of the @search_dirs,
866 	 * %G_KEY_FILE_ERROR_NOT_FOUND is returned. If
867 	 * the file is found but the OS returns an error when opening or reading the
868 	 * file, a %G_FILE_ERROR is returned. If there is a problem parsing the file, a
869 	 * %G_KEY_FILE_ERROR is returned.
870 	 *
871 	 * Params:
872 	 *     file = a relative path to a filename to open and parse
873 	 *     searchDirs = %NULL-terminated array of directories to search
874 	 *     fullPath = return location for a string containing the full path
875 	 *         of the file, or %NULL
876 	 *     flags = flags from #GKeyFileFlags
877 	 *
878 	 * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
879 	 *
880 	 * Since: 2.14
881 	 *
882 	 * Throws: GException on failure.
883 	 */
884 	public bool loadFromDirs(string file, string[] searchDirs, out string fullPath, GKeyFileFlags flags)
885 	{
886 		char* outfullPath = null;
887 		GError* err = null;
888 
889 		auto p = g_key_file_load_from_dirs(gKeyFile, Str.toStringz(file), Str.toStringzArray(searchDirs), &outfullPath, flags, &err) != 0;
890 
891 		if (err !is null)
892 		{
893 			throw new GException( new ErrorG(err) );
894 		}
895 
896 		fullPath = Str.toString(outfullPath);
897 
898 		return p;
899 	}
900 
901 	/**
902 	 * Loads a key file into an empty #GKeyFile structure.
903 	 *
904 	 * If the OS returns an error when opening or reading the file, a
905 	 * %G_FILE_ERROR is returned. If there is a problem parsing the file, a
906 	 * %G_KEY_FILE_ERROR is returned.
907 	 *
908 	 * This function will never return a %G_KEY_FILE_ERROR_NOT_FOUND error. If the
909 	 * @file is not found, %G_FILE_ERROR_NOENT is returned.
910 	 *
911 	 * Params:
912 	 *     file = the path of a filename to load, in the GLib filename encoding
913 	 *     flags = flags from #GKeyFileFlags
914 	 *
915 	 * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
916 	 *
917 	 * Since: 2.6
918 	 *
919 	 * Throws: GException on failure.
920 	 */
921 	public bool loadFromFile(string file, GKeyFileFlags flags)
922 	{
923 		GError* err = null;
924 
925 		auto p = g_key_file_load_from_file(gKeyFile, Str.toStringz(file), flags, &err) != 0;
926 
927 		if (err !is null)
928 		{
929 			throw new GException( new ErrorG(err) );
930 		}
931 
932 		return p;
933 	}
934 
935 	/**
936 	 * Increases the reference count of @key_file.
937 	 *
938 	 * Returns: the same @key_file.
939 	 *
940 	 * Since: 2.32
941 	 */
942 	public KeyFile doref()
943 	{
944 		auto p = g_key_file_ref(gKeyFile);
945 
946 		if(p is null)
947 		{
948 			return null;
949 		}
950 
951 		return new KeyFile(cast(GKeyFile*) p, true);
952 	}
953 
954 	/**
955 	 * Removes a comment above @key from @group_name.
956 	 * If @key is %NULL then @comment will be removed above @group_name.
957 	 * If both @key and @group_name are %NULL, then @comment will
958 	 * be removed above the first group in the file.
959 	 *
960 	 * Params:
961 	 *     groupName = a group name, or %NULL
962 	 *     key = a key
963 	 *
964 	 * Returns: %TRUE if the comment was removed, %FALSE otherwise
965 	 *
966 	 * Since: 2.6
967 	 *
968 	 * Throws: GException on failure.
969 	 */
970 	public bool removeComment(string groupName, string key)
971 	{
972 		GError* err = null;
973 
974 		auto p = g_key_file_remove_comment(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), &err) != 0;
975 
976 		if (err !is null)
977 		{
978 			throw new GException( new ErrorG(err) );
979 		}
980 
981 		return p;
982 	}
983 
984 	/**
985 	 * Removes the specified group, @group_name,
986 	 * from the key file.
987 	 *
988 	 * Params:
989 	 *     groupName = a group name
990 	 *
991 	 * Returns: %TRUE if the group was removed, %FALSE otherwise
992 	 *
993 	 * Since: 2.6
994 	 *
995 	 * Throws: GException on failure.
996 	 */
997 	public bool removeGroup(string groupName)
998 	{
999 		GError* err = null;
1000 
1001 		auto p = g_key_file_remove_group(gKeyFile, Str.toStringz(groupName), &err) != 0;
1002 
1003 		if (err !is null)
1004 		{
1005 			throw new GException( new ErrorG(err) );
1006 		}
1007 
1008 		return p;
1009 	}
1010 
1011 	/**
1012 	 * Removes @key in @group_name from the key file.
1013 	 *
1014 	 * Params:
1015 	 *     groupName = a group name
1016 	 *     key = a key name to remove
1017 	 *
1018 	 * Returns: %TRUE if the key was removed, %FALSE otherwise
1019 	 *
1020 	 * Since: 2.6
1021 	 *
1022 	 * Throws: GException on failure.
1023 	 */
1024 	public bool removeKey(string groupName, string key)
1025 	{
1026 		GError* err = null;
1027 
1028 		auto p = g_key_file_remove_key(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), &err) != 0;
1029 
1030 		if (err !is null)
1031 		{
1032 			throw new GException( new ErrorG(err) );
1033 		}
1034 
1035 		return p;
1036 	}
1037 
1038 	/**
1039 	 * Writes the contents of @key_file to @filename using
1040 	 * g_file_set_contents().
1041 	 *
1042 	 * This function can fail for any of the reasons that
1043 	 * g_file_set_contents() may fail.
1044 	 *
1045 	 * Params:
1046 	 *     filename = the name of the file to write to
1047 	 *
1048 	 * Returns: %TRUE if successful, else %FALSE with @error set
1049 	 *
1050 	 * Since: 2.40
1051 	 *
1052 	 * Throws: GException on failure.
1053 	 */
1054 	public bool saveToFile(string filename)
1055 	{
1056 		GError* err = null;
1057 
1058 		auto p = g_key_file_save_to_file(gKeyFile, Str.toStringz(filename), &err) != 0;
1059 
1060 		if (err !is null)
1061 		{
1062 			throw new GException( new ErrorG(err) );
1063 		}
1064 
1065 		return p;
1066 	}
1067 
1068 	/**
1069 	 * Associates a new boolean value with @key under @group_name.
1070 	 * If @key cannot be found then it is created.
1071 	 *
1072 	 * Params:
1073 	 *     groupName = a group name
1074 	 *     key = a key
1075 	 *     value = %TRUE or %FALSE
1076 	 *
1077 	 * Since: 2.6
1078 	 */
1079 	public void setBoolean(string groupName, string key, bool value)
1080 	{
1081 		g_key_file_set_boolean(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), value);
1082 	}
1083 
1084 	/**
1085 	 * Associates a list of boolean values with @key under @group_name.
1086 	 * If @key cannot be found then it is created.
1087 	 * If @group_name is %NULL, the start_group is used.
1088 	 *
1089 	 * Params:
1090 	 *     groupName = a group name
1091 	 *     key = a key
1092 	 *     list = an array of boolean values
1093 	 *
1094 	 * Since: 2.6
1095 	 */
1096 	public void setBooleanList(string groupName, string key, bool[] list)
1097 	{
1098 		int[] listArray = new int[list.length];
1099 		for ( int i = 0; i < list.length; i++ )
1100 		{
1101 			listArray[i] = list[i] ? 1 : 0;
1102 		}
1103 
1104 		g_key_file_set_boolean_list(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), listArray.ptr, cast(size_t)list.length);
1105 	}
1106 
1107 	/**
1108 	 * Places a comment above @key from @group_name.
1109 	 *
1110 	 * If @key is %NULL then @comment will be written above @group_name.
1111 	 * If both @key and @group_name  are %NULL, then @comment will be
1112 	 * written above the first group in the file.
1113 	 *
1114 	 * Note that this function prepends a '#' comment marker to
1115 	 * each line of @comment.
1116 	 *
1117 	 * Params:
1118 	 *     groupName = a group name, or %NULL
1119 	 *     key = a key
1120 	 *     comment = a comment
1121 	 *
1122 	 * Returns: %TRUE if the comment was written, %FALSE otherwise
1123 	 *
1124 	 * Since: 2.6
1125 	 *
1126 	 * Throws: GException on failure.
1127 	 */
1128 	public bool setComment(string groupName, string key, string comment)
1129 	{
1130 		GError* err = null;
1131 
1132 		auto p = g_key_file_set_comment(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), Str.toStringz(comment), &err) != 0;
1133 
1134 		if (err !is null)
1135 		{
1136 			throw new GException( new ErrorG(err) );
1137 		}
1138 
1139 		return p;
1140 	}
1141 
1142 	/**
1143 	 * Associates a new double value with @key under @group_name.
1144 	 * If @key cannot be found then it is created.
1145 	 *
1146 	 * Params:
1147 	 *     groupName = a group name
1148 	 *     key = a key
1149 	 *     value = an double value
1150 	 *
1151 	 * Since: 2.12
1152 	 */
1153 	public void setDouble(string groupName, string key, double value)
1154 	{
1155 		g_key_file_set_double(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), value);
1156 	}
1157 
1158 	/**
1159 	 * Associates a list of double values with @key under
1160 	 * @group_name.  If @key cannot be found then it is created.
1161 	 *
1162 	 * Params:
1163 	 *     groupName = a group name
1164 	 *     key = a key
1165 	 *     list = an array of double values
1166 	 *
1167 	 * Since: 2.12
1168 	 */
1169 	public void setDoubleList(string groupName, string key, double[] list)
1170 	{
1171 		g_key_file_set_double_list(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), list.ptr, cast(size_t)list.length);
1172 	}
1173 
1174 	/**
1175 	 * Associates a new integer value with @key under @group_name.
1176 	 * If @key cannot be found then it is created.
1177 	 *
1178 	 * Params:
1179 	 *     groupName = a group name
1180 	 *     key = a key
1181 	 *     value = an integer value
1182 	 *
1183 	 * Since: 2.26
1184 	 */
1185 	public void setInt64(string groupName, string key, long value)
1186 	{
1187 		g_key_file_set_int64(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), value);
1188 	}
1189 
1190 	/**
1191 	 * Associates a new integer value with @key under @group_name.
1192 	 * If @key cannot be found then it is created.
1193 	 *
1194 	 * Params:
1195 	 *     groupName = a group name
1196 	 *     key = a key
1197 	 *     value = an integer value
1198 	 *
1199 	 * Since: 2.6
1200 	 */
1201 	public void setInteger(string groupName, string key, int value)
1202 	{
1203 		g_key_file_set_integer(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), value);
1204 	}
1205 
1206 	/**
1207 	 * Associates a list of integer values with @key under @group_name.
1208 	 * If @key cannot be found then it is created.
1209 	 *
1210 	 * Params:
1211 	 *     groupName = a group name
1212 	 *     key = a key
1213 	 *     list = an array of integer values
1214 	 *
1215 	 * Since: 2.6
1216 	 */
1217 	public void setIntegerList(string groupName, string key, int[] list)
1218 	{
1219 		g_key_file_set_integer_list(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), list.ptr, cast(size_t)list.length);
1220 	}
1221 
1222 	/**
1223 	 * Sets the character which is used to separate
1224 	 * values in lists. Typically ';' or ',' are used
1225 	 * as separators. The default list separator is ';'.
1226 	 *
1227 	 * Params:
1228 	 *     separator = the separator
1229 	 *
1230 	 * Since: 2.6
1231 	 */
1232 	public void setListSeparator(char separator)
1233 	{
1234 		g_key_file_set_list_separator(gKeyFile, separator);
1235 	}
1236 
1237 	/**
1238 	 * Associates a string value for @key and @locale under @group_name.
1239 	 * If the translation for @key cannot be found then it is created.
1240 	 *
1241 	 * Params:
1242 	 *     groupName = a group name
1243 	 *     key = a key
1244 	 *     locale = a locale identifier
1245 	 *     str = a string
1246 	 *
1247 	 * Since: 2.6
1248 	 */
1249 	public void setLocaleString(string groupName, string key, string locale, string str)
1250 	{
1251 		g_key_file_set_locale_string(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), Str.toStringz(locale), Str.toStringz(str));
1252 	}
1253 
1254 	/**
1255 	 * Associates a list of string values for @key and @locale under
1256 	 * @group_name.  If the translation for @key cannot be found then
1257 	 * it is created.
1258 	 *
1259 	 * Params:
1260 	 *     groupName = a group name
1261 	 *     key = a key
1262 	 *     locale = a locale identifier
1263 	 *     list = a %NULL-terminated array of locale string values
1264 	 *
1265 	 * Since: 2.6
1266 	 */
1267 	public void setLocaleStringList(string groupName, string key, string locale, string[] list)
1268 	{
1269 		g_key_file_set_locale_string_list(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), Str.toStringz(locale), Str.toStringzArray(list), cast(size_t)list.length);
1270 	}
1271 
1272 	/**
1273 	 * Associates a new string value with @key under @group_name.
1274 	 * If @key cannot be found then it is created.
1275 	 * If @group_name cannot be found then it is created.
1276 	 * Unlike g_key_file_set_value(), this function handles characters
1277 	 * that need escaping, such as newlines.
1278 	 *
1279 	 * Params:
1280 	 *     groupName = a group name
1281 	 *     key = a key
1282 	 *     str = a string
1283 	 *
1284 	 * Since: 2.6
1285 	 */
1286 	public void setString(string groupName, string key, string str)
1287 	{
1288 		g_key_file_set_string(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), Str.toStringz(str));
1289 	}
1290 
1291 	/**
1292 	 * Associates a list of string values for @key under @group_name.
1293 	 * If @key cannot be found then it is created.
1294 	 * If @group_name cannot be found then it is created.
1295 	 *
1296 	 * Params:
1297 	 *     groupName = a group name
1298 	 *     key = a key
1299 	 *     list = an array of string values
1300 	 *
1301 	 * Since: 2.6
1302 	 */
1303 	public void setStringList(string groupName, string key, string[] list)
1304 	{
1305 		g_key_file_set_string_list(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), Str.toStringzArray(list), cast(size_t)list.length);
1306 	}
1307 
1308 	/**
1309 	 * Associates a new integer value with @key under @group_name.
1310 	 * If @key cannot be found then it is created.
1311 	 *
1312 	 * Params:
1313 	 *     groupName = a group name
1314 	 *     key = a key
1315 	 *     value = an integer value
1316 	 *
1317 	 * Since: 2.26
1318 	 */
1319 	public void setUint64(string groupName, string key, ulong value)
1320 	{
1321 		g_key_file_set_uint64(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), value);
1322 	}
1323 
1324 	/**
1325 	 * Associates a new value with @key under @group_name.
1326 	 *
1327 	 * If @key cannot be found then it is created. If @group_name cannot
1328 	 * be found then it is created. To set an UTF-8 string which may contain
1329 	 * characters that need escaping (such as newlines or spaces), use
1330 	 * g_key_file_set_string().
1331 	 *
1332 	 * Params:
1333 	 *     groupName = a group name
1334 	 *     key = a key
1335 	 *     value = a string
1336 	 *
1337 	 * Since: 2.6
1338 	 */
1339 	public void setValue(string groupName, string key, string value)
1340 	{
1341 		g_key_file_set_value(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), Str.toStringz(value));
1342 	}
1343 
1344 	/**
1345 	 * This function outputs @key_file as a string.
1346 	 *
1347 	 * Note that this function never reports an error,
1348 	 * so it is safe to pass %NULL as @error.
1349 	 *
1350 	 * Params:
1351 	 *     length = return location for the length of the
1352 	 *         returned string, or %NULL
1353 	 *
1354 	 * Returns: a newly allocated string holding
1355 	 *     the contents of the #GKeyFile
1356 	 *
1357 	 * Since: 2.6
1358 	 *
1359 	 * Throws: GException on failure.
1360 	 */
1361 	public string toData(out size_t length)
1362 	{
1363 		GError* err = null;
1364 
1365 		auto retStr = g_key_file_to_data(gKeyFile, &length, &err);
1366 
1367 		if (err !is null)
1368 		{
1369 			throw new GException( new ErrorG(err) );
1370 		}
1371 
1372 		scope(exit) Str.freeString(retStr);
1373 		return Str.toString(retStr);
1374 	}
1375 
1376 	/**
1377 	 * Decreases the reference count of @key_file by 1. If the reference count
1378 	 * reaches zero, frees the key file and all its allocated memory.
1379 	 *
1380 	 * Since: 2.32
1381 	 */
1382 	public void unref()
1383 	{
1384 		g_key_file_unref(gKeyFile);
1385 	}
1386 
1387 	/** */
1388 	public static GQuark errorQuark()
1389 	{
1390 		return g_key_file_error_quark();
1391 	}
1392 }