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