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 value associated with @key under @group_name
451 	 * translated in the given @locale if available.  If @locale is
452 	 * %NULL then the current locale is assumed.
453 	 *
454 	 * If @key cannot be found then %NULL is returned and @error is set
455 	 * to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the value associated
456 	 * with @key cannot be interpreted or no suitable translation can
457 	 * be found then the untranslated value is returned.
458 	 *
459 	 * Params:
460 	 *     groupName = a group name
461 	 *     key = a key
462 	 *     locale = a locale identifier or %NULL
463 	 *
464 	 * Returns: a newly allocated string or %NULL if the specified
465 	 *     key cannot be found.
466 	 *
467 	 * Since: 2.6
468 	 *
469 	 * Throws: GException on failure.
470 	 */
471 	public string getLocaleString(string groupName, string key, string locale)
472 	{
473 		GError* err = null;
474 
475 		auto retStr = g_key_file_get_locale_string(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), Str.toStringz(locale), &err);
476 
477 		if (err !is null)
478 		{
479 			throw new GException( new ErrorG(err) );
480 		}
481 
482 		scope(exit) Str.freeString(retStr);
483 		return Str.toString(retStr);
484 	}
485 
486 	/**
487 	 * Returns the values associated with @key under @group_name
488 	 * translated in the given @locale if available.  If @locale is
489 	 * %NULL then the current locale is assumed.
490 	 *
491 	 * If @key cannot be found then %NULL is returned and @error is set
492 	 * to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the values associated
493 	 * with @key cannot be interpreted or no suitable translations
494 	 * can be found then the untranslated values are returned. The
495 	 * returned array is %NULL-terminated, so @length may optionally
496 	 * be %NULL.
497 	 *
498 	 * Params:
499 	 *     groupName = a group name
500 	 *     key = a key
501 	 *     locale = a locale identifier or %NULL
502 	 *
503 	 * Returns: a newly allocated %NULL-terminated string array
504 	 *     or %NULL if the key isn't found. The string array should be freed
505 	 *     with g_strfreev().
506 	 *
507 	 * Since: 2.6
508 	 *
509 	 * Throws: GException on failure.
510 	 */
511 	public string[] getLocaleStringList(string groupName, string key, string locale)
512 	{
513 		size_t length;
514 		GError* err = null;
515 
516 		auto retStr = g_key_file_get_locale_string_list(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), Str.toStringz(locale), &length, &err);
517 
518 		if (err !is null)
519 		{
520 			throw new GException( new ErrorG(err) );
521 		}
522 
523 		scope(exit) Str.freeStringArray(retStr);
524 		return Str.toStringArray(retStr, length);
525 	}
526 
527 	/**
528 	 * Returns the name of the start group of the file.
529 	 *
530 	 * Returns: The start group of the key file.
531 	 *
532 	 * Since: 2.6
533 	 */
534 	public string getStartGroup()
535 	{
536 		auto retStr = g_key_file_get_start_group(gKeyFile);
537 
538 		scope(exit) Str.freeString(retStr);
539 		return Str.toString(retStr);
540 	}
541 
542 	/**
543 	 * Returns the string value associated with @key under @group_name.
544 	 * Unlike g_key_file_get_value(), this function handles escape sequences
545 	 * like \s.
546 	 *
547 	 * In the event the key cannot be found, %NULL is returned and
548 	 * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND.  In the
549 	 * event that the @group_name cannot be found, %NULL is returned
550 	 * and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
551 	 *
552 	 * Params:
553 	 *     groupName = a group name
554 	 *     key = a key
555 	 *
556 	 * Returns: a newly allocated string or %NULL if the specified
557 	 *     key cannot be found.
558 	 *
559 	 * Since: 2.6
560 	 *
561 	 * Throws: GException on failure.
562 	 */
563 	public string getString(string groupName, string key)
564 	{
565 		GError* err = null;
566 
567 		auto retStr = g_key_file_get_string(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), &err);
568 
569 		if (err !is null)
570 		{
571 			throw new GException( new ErrorG(err) );
572 		}
573 
574 		scope(exit) Str.freeString(retStr);
575 		return Str.toString(retStr);
576 	}
577 
578 	/**
579 	 * Returns the values associated with @key under @group_name.
580 	 *
581 	 * In the event the key cannot be found, %NULL is returned and
582 	 * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND.  In the
583 	 * event that the @group_name cannot be found, %NULL is returned
584 	 * and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
585 	 *
586 	 * Params:
587 	 *     groupName = a group name
588 	 *     key = a key
589 	 *
590 	 * Returns: a %NULL-terminated string array or %NULL if the specified
591 	 *     key cannot be found. The array should be freed with g_strfreev().
592 	 *
593 	 * Since: 2.6
594 	 *
595 	 * Throws: GException on failure.
596 	 */
597 	public string[] getStringList(string groupName, string key)
598 	{
599 		size_t length;
600 		GError* err = null;
601 
602 		auto retStr = g_key_file_get_string_list(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), &length, &err);
603 
604 		if (err !is null)
605 		{
606 			throw new GException( new ErrorG(err) );
607 		}
608 
609 		scope(exit) Str.freeStringArray(retStr);
610 		return Str.toStringArray(retStr, length);
611 	}
612 
613 	/**
614 	 * Returns the value associated with @key under @group_name as an unsigned
615 	 * 64-bit integer. This is similar to g_key_file_get_integer() but can return
616 	 * large positive results without truncation.
617 	 *
618 	 * Params:
619 	 *     groupName = a non-%NULL group name
620 	 *     key = a non-%NULL key
621 	 *
622 	 * Returns: the value associated with the key as an unsigned 64-bit integer,
623 	 *     or 0 if the key was not found or could not be parsed.
624 	 *
625 	 * Since: 2.26
626 	 *
627 	 * Throws: GException on failure.
628 	 */
629 	public ulong getUint64(string groupName, string key)
630 	{
631 		GError* err = null;
632 
633 		auto p = g_key_file_get_uint64(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), &err);
634 
635 		if (err !is null)
636 		{
637 			throw new GException( new ErrorG(err) );
638 		}
639 
640 		return p;
641 	}
642 
643 	/**
644 	 * Returns the raw value associated with @key under @group_name.
645 	 * Use g_key_file_get_string() to retrieve an unescaped UTF-8 string.
646 	 *
647 	 * In the event the key cannot be found, %NULL is returned and
648 	 * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND.  In the
649 	 * event that the @group_name cannot be found, %NULL is returned
650 	 * and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND.
651 	 *
652 	 * Params:
653 	 *     groupName = a group name
654 	 *     key = a key
655 	 *
656 	 * Returns: a newly allocated string or %NULL if the specified
657 	 *     key cannot be found.
658 	 *
659 	 * Since: 2.6
660 	 *
661 	 * Throws: GException on failure.
662 	 */
663 	public string getValue(string groupName, string key)
664 	{
665 		GError* err = null;
666 
667 		auto retStr = g_key_file_get_value(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), &err);
668 
669 		if (err !is null)
670 		{
671 			throw new GException( new ErrorG(err) );
672 		}
673 
674 		scope(exit) Str.freeString(retStr);
675 		return Str.toString(retStr);
676 	}
677 
678 	/**
679 	 * Looks whether the key file has the group @group_name.
680 	 *
681 	 * Params:
682 	 *     groupName = a group name
683 	 *
684 	 * Returns: %TRUE if @group_name is a part of @key_file, %FALSE
685 	 *     otherwise.
686 	 *
687 	 * Since: 2.6
688 	 */
689 	public bool hasGroup(string groupName)
690 	{
691 		return g_key_file_has_group(gKeyFile, Str.toStringz(groupName)) != 0;
692 	}
693 
694 	/**
695 	 * Looks whether the key file has the key @key in the group
696 	 * @group_name.
697 	 *
698 	 * Note that this function does not follow the rules for #GError strictly;
699 	 * the return value both carries meaning and signals an error.  To use
700 	 * this function, you must pass a #GError pointer in @error, and check
701 	 * whether it is not %NULL to see if an error occurred.
702 	 *
703 	 * Language bindings should use g_key_file_get_value() to test whether
704 	 * or not a key exists.
705 	 *
706 	 * Params:
707 	 *     groupName = a group name
708 	 *     key = a key name
709 	 *
710 	 * Returns: %TRUE if @key is a part of @group_name, %FALSE otherwise
711 	 *
712 	 * Since: 2.6
713 	 *
714 	 * Throws: GException on failure.
715 	 */
716 	public bool hasKey(string groupName, string key)
717 	{
718 		GError* err = null;
719 
720 		auto p = g_key_file_has_key(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), &err) != 0;
721 
722 		if (err !is null)
723 		{
724 			throw new GException( new ErrorG(err) );
725 		}
726 
727 		return p;
728 	}
729 
730 	/**
731 	 * Loads a key file from the data in @bytes into an empty #GKeyFile structure.
732 	 * If the object cannot be created then %error is set to a #GKeyFileError.
733 	 *
734 	 * Params:
735 	 *     bytes = a #GBytes
736 	 *     flags = flags from #GKeyFileFlags
737 	 *
738 	 * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
739 	 *
740 	 * Since: 2.50
741 	 *
742 	 * Throws: GException on failure.
743 	 */
744 	public bool loadFromBytes(Bytes bytes, GKeyFileFlags flags)
745 	{
746 		GError* err = null;
747 
748 		auto p = g_key_file_load_from_bytes(gKeyFile, (bytes is null) ? null : bytes.getBytesStruct(), flags, &err) != 0;
749 
750 		if (err !is null)
751 		{
752 			throw new GException( new ErrorG(err) );
753 		}
754 
755 		return p;
756 	}
757 
758 	/**
759 	 * Loads a key file from memory into an empty #GKeyFile structure.
760 	 * If the object cannot be created then %error is set to a #GKeyFileError.
761 	 *
762 	 * Params:
763 	 *     data = key file loaded in memory
764 	 *     length = the length of @data in bytes (or (gsize)-1 if data is nul-terminated)
765 	 *     flags = flags from #GKeyFileFlags
766 	 *
767 	 * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
768 	 *
769 	 * Since: 2.6
770 	 *
771 	 * Throws: GException on failure.
772 	 */
773 	public bool loadFromData(string data, size_t length, GKeyFileFlags flags)
774 	{
775 		GError* err = null;
776 
777 		auto p = g_key_file_load_from_data(gKeyFile, Str.toStringz(data), length, flags, &err) != 0;
778 
779 		if (err !is null)
780 		{
781 			throw new GException( new ErrorG(err) );
782 		}
783 
784 		return p;
785 	}
786 
787 	/**
788 	 * This function looks for a key file named @file in the paths
789 	 * returned from g_get_user_data_dir() and g_get_system_data_dirs(),
790 	 * loads the file into @key_file and returns the file's full path in
791 	 * @full_path.  If the file could not be loaded then an %error is
792 	 * set to either a #GFileError or #GKeyFileError.
793 	 *
794 	 * Params:
795 	 *     file = a relative path to a filename to open and parse
796 	 *     fullPath = return location for a string containing the full path
797 	 *         of the file, or %NULL
798 	 *     flags = flags from #GKeyFileFlags
799 	 *
800 	 * Returns: %TRUE if a key file could be loaded, %FALSE othewise
801 	 *
802 	 * Since: 2.6
803 	 *
804 	 * Throws: GException on failure.
805 	 */
806 	public bool loadFromDataDirs(string file, out string fullPath, GKeyFileFlags flags)
807 	{
808 		char* outfullPath = null;
809 		GError* err = null;
810 
811 		auto p = g_key_file_load_from_data_dirs(gKeyFile, Str.toStringz(file), &outfullPath, flags, &err) != 0;
812 
813 		if (err !is null)
814 		{
815 			throw new GException( new ErrorG(err) );
816 		}
817 
818 		fullPath = Str.toString(outfullPath);
819 
820 		return p;
821 	}
822 
823 	/**
824 	 * This function looks for a key file named @file in the paths
825 	 * specified in @search_dirs, loads the file into @key_file and
826 	 * returns the file's full path in @full_path.
827 	 *
828 	 * If the file could not be found in any of the @search_dirs,
829 	 * %G_KEY_FILE_ERROR_NOT_FOUND is returned. If
830 	 * the file is found but the OS returns an error when opening or reading the
831 	 * file, a %G_FILE_ERROR is returned. If there is a problem parsing the file, a
832 	 * %G_KEY_FILE_ERROR is returned.
833 	 *
834 	 * Params:
835 	 *     file = a relative path to a filename to open and parse
836 	 *     searchDirs = %NULL-terminated array of directories to search
837 	 *     fullPath = return location for a string containing the full path
838 	 *         of the file, or %NULL
839 	 *     flags = flags from #GKeyFileFlags
840 	 *
841 	 * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
842 	 *
843 	 * Since: 2.14
844 	 *
845 	 * Throws: GException on failure.
846 	 */
847 	public bool loadFromDirs(string file, string[] searchDirs, out string fullPath, GKeyFileFlags flags)
848 	{
849 		char* outfullPath = null;
850 		GError* err = null;
851 
852 		auto p = g_key_file_load_from_dirs(gKeyFile, Str.toStringz(file), Str.toStringzArray(searchDirs), &outfullPath, flags, &err) != 0;
853 
854 		if (err !is null)
855 		{
856 			throw new GException( new ErrorG(err) );
857 		}
858 
859 		fullPath = Str.toString(outfullPath);
860 
861 		return p;
862 	}
863 
864 	/**
865 	 * Loads a key file into an empty #GKeyFile structure.
866 	 *
867 	 * If the OS returns an error when opening or reading the file, a
868 	 * %G_FILE_ERROR is returned. If there is a problem parsing the file, a
869 	 * %G_KEY_FILE_ERROR is returned.
870 	 *
871 	 * This function will never return a %G_KEY_FILE_ERROR_NOT_FOUND error. If the
872 	 * @file is not found, %G_FILE_ERROR_NOENT is returned.
873 	 *
874 	 * Params:
875 	 *     file = the path of a filename to load, in the GLib filename encoding
876 	 *     flags = flags from #GKeyFileFlags
877 	 *
878 	 * Returns: %TRUE if a key file could be loaded, %FALSE otherwise
879 	 *
880 	 * Since: 2.6
881 	 *
882 	 * Throws: GException on failure.
883 	 */
884 	public bool loadFromFile(string file, GKeyFileFlags flags)
885 	{
886 		GError* err = null;
887 
888 		auto p = g_key_file_load_from_file(gKeyFile, Str.toStringz(file), flags, &err) != 0;
889 
890 		if (err !is null)
891 		{
892 			throw new GException( new ErrorG(err) );
893 		}
894 
895 		return p;
896 	}
897 
898 	/**
899 	 * Increases the reference count of @key_file.
900 	 *
901 	 * Returns: the same @key_file.
902 	 *
903 	 * Since: 2.32
904 	 */
905 	public KeyFile doref()
906 	{
907 		auto p = g_key_file_ref(gKeyFile);
908 
909 		if(p is null)
910 		{
911 			return null;
912 		}
913 
914 		return new KeyFile(cast(GKeyFile*) p, true);
915 	}
916 
917 	/**
918 	 * Removes a comment above @key from @group_name.
919 	 * If @key is %NULL then @comment will be removed above @group_name.
920 	 * If both @key and @group_name are %NULL, then @comment will
921 	 * be removed above the first group in the file.
922 	 *
923 	 * Params:
924 	 *     groupName = a group name, or %NULL
925 	 *     key = a key
926 	 *
927 	 * Returns: %TRUE if the comment was removed, %FALSE otherwise
928 	 *
929 	 * Since: 2.6
930 	 *
931 	 * Throws: GException on failure.
932 	 */
933 	public bool removeComment(string groupName, string key)
934 	{
935 		GError* err = null;
936 
937 		auto p = g_key_file_remove_comment(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), &err) != 0;
938 
939 		if (err !is null)
940 		{
941 			throw new GException( new ErrorG(err) );
942 		}
943 
944 		return p;
945 	}
946 
947 	/**
948 	 * Removes the specified group, @group_name,
949 	 * from the key file.
950 	 *
951 	 * Params:
952 	 *     groupName = a group name
953 	 *
954 	 * Returns: %TRUE if the group was removed, %FALSE otherwise
955 	 *
956 	 * Since: 2.6
957 	 *
958 	 * Throws: GException on failure.
959 	 */
960 	public bool removeGroup(string groupName)
961 	{
962 		GError* err = null;
963 
964 		auto p = g_key_file_remove_group(gKeyFile, Str.toStringz(groupName), &err) != 0;
965 
966 		if (err !is null)
967 		{
968 			throw new GException( new ErrorG(err) );
969 		}
970 
971 		return p;
972 	}
973 
974 	/**
975 	 * Removes @key in @group_name from the key file.
976 	 *
977 	 * Params:
978 	 *     groupName = a group name
979 	 *     key = a key name to remove
980 	 *
981 	 * Returns: %TRUE if the key was removed, %FALSE otherwise
982 	 *
983 	 * Since: 2.6
984 	 *
985 	 * Throws: GException on failure.
986 	 */
987 	public bool removeKey(string groupName, string key)
988 	{
989 		GError* err = null;
990 
991 		auto p = g_key_file_remove_key(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), &err) != 0;
992 
993 		if (err !is null)
994 		{
995 			throw new GException( new ErrorG(err) );
996 		}
997 
998 		return p;
999 	}
1000 
1001 	/**
1002 	 * Writes the contents of @key_file to @filename using
1003 	 * g_file_set_contents().
1004 	 *
1005 	 * This function can fail for any of the reasons that
1006 	 * g_file_set_contents() may fail.
1007 	 *
1008 	 * Params:
1009 	 *     filename = the name of the file to write to
1010 	 *
1011 	 * Returns: %TRUE if successful, else %FALSE with @error set
1012 	 *
1013 	 * Since: 2.40
1014 	 *
1015 	 * Throws: GException on failure.
1016 	 */
1017 	public bool saveToFile(string filename)
1018 	{
1019 		GError* err = null;
1020 
1021 		auto p = g_key_file_save_to_file(gKeyFile, Str.toStringz(filename), &err) != 0;
1022 
1023 		if (err !is null)
1024 		{
1025 			throw new GException( new ErrorG(err) );
1026 		}
1027 
1028 		return p;
1029 	}
1030 
1031 	/**
1032 	 * Associates a new boolean value with @key under @group_name.
1033 	 * If @key cannot be found then it is created.
1034 	 *
1035 	 * Params:
1036 	 *     groupName = a group name
1037 	 *     key = a key
1038 	 *     value = %TRUE or %FALSE
1039 	 *
1040 	 * Since: 2.6
1041 	 */
1042 	public void setBoolean(string groupName, string key, bool value)
1043 	{
1044 		g_key_file_set_boolean(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), value);
1045 	}
1046 
1047 	/**
1048 	 * Associates a list of boolean values with @key under @group_name.
1049 	 * If @key cannot be found then it is created.
1050 	 * If @group_name is %NULL, the start_group is used.
1051 	 *
1052 	 * Params:
1053 	 *     groupName = a group name
1054 	 *     key = a key
1055 	 *     list = an array of boolean values
1056 	 *
1057 	 * Since: 2.6
1058 	 */
1059 	public void setBooleanList(string groupName, string key, bool[] list)
1060 	{
1061 		int[] listArray = new int[list.length];
1062 		for ( int i = 0; i < list.length; i++ )
1063 		{
1064 			listArray[i] = list[i] ? 1 : 0;
1065 		}
1066 
1067 		g_key_file_set_boolean_list(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), listArray.ptr, cast(size_t)list.length);
1068 	}
1069 
1070 	/**
1071 	 * Places a comment above @key from @group_name.
1072 	 *
1073 	 * If @key is %NULL then @comment will be written above @group_name.
1074 	 * If both @key and @group_name  are %NULL, then @comment will be
1075 	 * written above the first group in the file.
1076 	 *
1077 	 * Note that this function prepends a '#' comment marker to
1078 	 * each line of @comment.
1079 	 *
1080 	 * Params:
1081 	 *     groupName = a group name, or %NULL
1082 	 *     key = a key
1083 	 *     comment = a comment
1084 	 *
1085 	 * Returns: %TRUE if the comment was written, %FALSE otherwise
1086 	 *
1087 	 * Since: 2.6
1088 	 *
1089 	 * Throws: GException on failure.
1090 	 */
1091 	public bool setComment(string groupName, string key, string comment)
1092 	{
1093 		GError* err = null;
1094 
1095 		auto p = g_key_file_set_comment(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), Str.toStringz(comment), &err) != 0;
1096 
1097 		if (err !is null)
1098 		{
1099 			throw new GException( new ErrorG(err) );
1100 		}
1101 
1102 		return p;
1103 	}
1104 
1105 	/**
1106 	 * Associates a new double value with @key under @group_name.
1107 	 * If @key cannot be found then it is created.
1108 	 *
1109 	 * Params:
1110 	 *     groupName = a group name
1111 	 *     key = a key
1112 	 *     value = an double value
1113 	 *
1114 	 * Since: 2.12
1115 	 */
1116 	public void setDouble(string groupName, string key, double value)
1117 	{
1118 		g_key_file_set_double(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), value);
1119 	}
1120 
1121 	/**
1122 	 * Associates a list of double values with @key under
1123 	 * @group_name.  If @key cannot be found then it is created.
1124 	 *
1125 	 * Params:
1126 	 *     groupName = a group name
1127 	 *     key = a key
1128 	 *     list = an array of double values
1129 	 *
1130 	 * Since: 2.12
1131 	 */
1132 	public void setDoubleList(string groupName, string key, double[] list)
1133 	{
1134 		g_key_file_set_double_list(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), list.ptr, cast(size_t)list.length);
1135 	}
1136 
1137 	/**
1138 	 * Associates a new integer value with @key under @group_name.
1139 	 * If @key cannot be found then it is created.
1140 	 *
1141 	 * Params:
1142 	 *     groupName = a group name
1143 	 *     key = a key
1144 	 *     value = an integer value
1145 	 *
1146 	 * Since: 2.26
1147 	 */
1148 	public void setInt64(string groupName, string key, long value)
1149 	{
1150 		g_key_file_set_int64(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), value);
1151 	}
1152 
1153 	/**
1154 	 * Associates a new integer value with @key under @group_name.
1155 	 * If @key cannot be found then it is created.
1156 	 *
1157 	 * Params:
1158 	 *     groupName = a group name
1159 	 *     key = a key
1160 	 *     value = an integer value
1161 	 *
1162 	 * Since: 2.6
1163 	 */
1164 	public void setInteger(string groupName, string key, int value)
1165 	{
1166 		g_key_file_set_integer(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), value);
1167 	}
1168 
1169 	/**
1170 	 * Associates a list of integer values with @key under @group_name.
1171 	 * If @key cannot be found then it is created.
1172 	 *
1173 	 * Params:
1174 	 *     groupName = a group name
1175 	 *     key = a key
1176 	 *     list = an array of integer values
1177 	 *
1178 	 * Since: 2.6
1179 	 */
1180 	public void setIntegerList(string groupName, string key, int[] list)
1181 	{
1182 		g_key_file_set_integer_list(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), list.ptr, cast(size_t)list.length);
1183 	}
1184 
1185 	/**
1186 	 * Sets the character which is used to separate
1187 	 * values in lists. Typically ';' or ',' are used
1188 	 * as separators. The default list separator is ';'.
1189 	 *
1190 	 * Params:
1191 	 *     separator = the separator
1192 	 *
1193 	 * Since: 2.6
1194 	 */
1195 	public void setListSeparator(char separator)
1196 	{
1197 		g_key_file_set_list_separator(gKeyFile, separator);
1198 	}
1199 
1200 	/**
1201 	 * Associates a string value for @key and @locale under @group_name.
1202 	 * If the translation for @key cannot be found then it is created.
1203 	 *
1204 	 * Params:
1205 	 *     groupName = a group name
1206 	 *     key = a key
1207 	 *     locale = a locale identifier
1208 	 *     str = a string
1209 	 *
1210 	 * Since: 2.6
1211 	 */
1212 	public void setLocaleString(string groupName, string key, string locale, string str)
1213 	{
1214 		g_key_file_set_locale_string(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), Str.toStringz(locale), Str.toStringz(str));
1215 	}
1216 
1217 	/**
1218 	 * Associates a list of string values for @key and @locale under
1219 	 * @group_name.  If the translation for @key cannot be found then
1220 	 * it is created.
1221 	 *
1222 	 * Params:
1223 	 *     groupName = a group name
1224 	 *     key = a key
1225 	 *     locale = a locale identifier
1226 	 *     list = a %NULL-terminated array of locale string values
1227 	 *
1228 	 * Since: 2.6
1229 	 */
1230 	public void setLocaleStringList(string groupName, string key, string locale, string[] list)
1231 	{
1232 		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);
1233 	}
1234 
1235 	/**
1236 	 * Associates a new string value with @key under @group_name.
1237 	 * If @key cannot be found then it is created.
1238 	 * If @group_name cannot be found then it is created.
1239 	 * Unlike g_key_file_set_value(), this function handles characters
1240 	 * that need escaping, such as newlines.
1241 	 *
1242 	 * Params:
1243 	 *     groupName = a group name
1244 	 *     key = a key
1245 	 *     str = a string
1246 	 *
1247 	 * Since: 2.6
1248 	 */
1249 	public void setString(string groupName, string key, string str)
1250 	{
1251 		g_key_file_set_string(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), Str.toStringz(str));
1252 	}
1253 
1254 	/**
1255 	 * Associates a list of string values for @key under @group_name.
1256 	 * If @key cannot be found then it is created.
1257 	 * If @group_name cannot be found then it is created.
1258 	 *
1259 	 * Params:
1260 	 *     groupName = a group name
1261 	 *     key = a key
1262 	 *     list = an array of string values
1263 	 *
1264 	 * Since: 2.6
1265 	 */
1266 	public void setStringList(string groupName, string key, string[] list)
1267 	{
1268 		g_key_file_set_string_list(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), Str.toStringzArray(list), cast(size_t)list.length);
1269 	}
1270 
1271 	/**
1272 	 * Associates a new integer value with @key under @group_name.
1273 	 * If @key cannot be found then it is created.
1274 	 *
1275 	 * Params:
1276 	 *     groupName = a group name
1277 	 *     key = a key
1278 	 *     value = an integer value
1279 	 *
1280 	 * Since: 2.26
1281 	 */
1282 	public void setUint64(string groupName, string key, ulong value)
1283 	{
1284 		g_key_file_set_uint64(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), value);
1285 	}
1286 
1287 	/**
1288 	 * Associates a new value with @key under @group_name.
1289 	 *
1290 	 * If @key cannot be found then it is created. If @group_name cannot
1291 	 * be found then it is created. To set an UTF-8 string which may contain
1292 	 * characters that need escaping (such as newlines or spaces), use
1293 	 * g_key_file_set_string().
1294 	 *
1295 	 * Params:
1296 	 *     groupName = a group name
1297 	 *     key = a key
1298 	 *     value = a string
1299 	 *
1300 	 * Since: 2.6
1301 	 */
1302 	public void setValue(string groupName, string key, string value)
1303 	{
1304 		g_key_file_set_value(gKeyFile, Str.toStringz(groupName), Str.toStringz(key), Str.toStringz(value));
1305 	}
1306 
1307 	/**
1308 	 * This function outputs @key_file as a string.
1309 	 *
1310 	 * Note that this function never reports an error,
1311 	 * so it is safe to pass %NULL as @error.
1312 	 *
1313 	 * Params:
1314 	 *     length = return location for the length of the
1315 	 *         returned string, or %NULL
1316 	 *
1317 	 * Returns: a newly allocated string holding
1318 	 *     the contents of the #GKeyFile
1319 	 *
1320 	 * Since: 2.6
1321 	 *
1322 	 * Throws: GException on failure.
1323 	 */
1324 	public string toData(out size_t length)
1325 	{
1326 		GError* err = null;
1327 
1328 		auto retStr = g_key_file_to_data(gKeyFile, &length, &err);
1329 
1330 		if (err !is null)
1331 		{
1332 			throw new GException( new ErrorG(err) );
1333 		}
1334 
1335 		scope(exit) Str.freeString(retStr);
1336 		return Str.toString(retStr);
1337 	}
1338 
1339 	/**
1340 	 * Decreases the reference count of @key_file by 1. If the reference count
1341 	 * reaches zero, frees the key file and all its allocated memory.
1342 	 *
1343 	 * Since: 2.32
1344 	 */
1345 	public void unref()
1346 	{
1347 		g_key_file_unref(gKeyFile);
1348 	}
1349 
1350 	/** */
1351 	public static GQuark errorQuark()
1352 	{
1353 		return g_key_file_error_quark();
1354 	}
1355 }