Package ch.bailu.gtk.glib
Class KeyFile
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.type.Record
ch.bailu.gtk.glib.KeyFile
- All Implemented Interfaces:
PointerInterface
The GKeyFile struct contains only private data
and should not be accessed directly.
and should not be accessed directly.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionKeyFile()
Creates a new empty #GKeyFile object.KeyFile
(PointerContainer pointer) -
Method Summary
Modifier and TypeMethodDescriptionstatic int
void
free()
Clears all keys and groups from @key_file, and decreases the
reference count by 1.boolean
getBoolean
(Str group_name, Str key) Returns the value associated with @key under @group_name as a
boolean.boolean
getBoolean
(String group_name, String key) Returns the value associated with @key under @group_name as a
boolean.getBooleanList
(Str group_name, Str key, Int64 length) Returns the values associated with @key under @group_name as
booleans.getBooleanList
(String group_name, String key, Int64 length) Returns the values associated with @key under @group_name as
booleans.static ClassHandler
getComment
(Str group_name, Str key) Retrieves a comment above @key from @group_name.getComment
(String group_name, String key) Retrieves a comment above @key from @group_name.double
Returns the value associated with @key under @group_name as a
double.double
Returns the value associated with @key under @group_name as a
double.getDoubleList
(Str group_name, Str key, Int64 length) Returns the values associated with @key under @group_name as
doubles.getDoubleList
(String group_name, String key, Int64 length) Returns the values associated with @key under @group_name as
doubles.static int
long
Returns the value associated with @key under @group_name as a signed
64-bit integer.long
Returns the value associated with @key under @group_name as a signed
64-bit integer.int
getInteger
(Str group_name, Str key) Returns the value associated with @key under @group_name as an
integer.int
getInteger
(String group_name, String key) Returns the value associated with @key under @group_name as an
integer.getIntegerList
(Str group_name, Str key, Int64 length) Returns the values associated with @key under @group_name as
integers.getIntegerList
(String group_name, String key, Int64 length) Returns the values associated with @key under @group_name as
integers.getLocaleForKey
(Str group_name, Str key, Str locale) Returns the actual locale which the result of
g_key_file_get_locale_string() or g_key_file_get_locale_string_list()
came from.getLocaleForKey
(String group_name, String key, String locale) Returns the actual locale which the result of
g_key_file_get_locale_string() or g_key_file_get_locale_string_list()
came from.getLocaleString
(Str group_name, Str key, Str locale) Returns the value associated with @key under @group_name
translated in the given @locale if available.getLocaleString
(String group_name, String key, String locale) Returns the value associated with @key under @group_name
translated in the given @locale if available.static long
static TypeSystem.TypeSize
Returns the name of the start group of the file.Returns the string value associated with @key under @group_name.Returns the string value associated with @key under @group_name.static long
static TypeSystem.TypeSize
long
Returns the value associated with @key under @group_name as an unsigned
64-bit integer.long
Returns the value associated with @key under @group_name as an unsigned
64-bit integer.Returns the raw value associated with @key under @group_name.Returns the raw value associated with @key under @group_name.boolean
Looks whether the key file has the group @group_name.boolean
Looks whether the key file has the group @group_name.boolean
Looks whether the key file has the key @key in the group
@group_name.boolean
Looks whether the key file has the key @key in the group
@group_name.boolean
loadFromBytes
(Bytes bytes, int flags) Loads a key file from the data in @bytes into an empty #GKeyFile structure.boolean
loadFromData
(Str data, long length, int flags) Loads a key file from memory into an empty #GKeyFile structure.boolean
loadFromData
(String data, long length, int flags) Loads a key file from memory into an empty #GKeyFile structure.boolean
loadFromFile
(Str file, int flags) Loads a key file into an empty #GKeyFile structure.boolean
loadFromFile
(String file, int flags) Loads a key file into an empty #GKeyFile structure.ref()
Increases the reference count of @key_file.boolean
removeComment
(Str group_name, Str key) Removes a comment above @key from @group_name.boolean
removeComment
(String group_name, String key) Removes a comment above @key from @group_name.boolean
removeGroup
(Str group_name) Removes the specified group, @group_name,
from the key file.boolean
removeGroup
(String group_name) Removes the specified group, @group_name,
from the key file.boolean
Removes @key in @group_name from the key file.boolean
Removes @key in @group_name from the key file.boolean
saveToFile
(Str filename) Writes the contents of @key_file to @filename using
g_file_set_contents().boolean
saveToFile
(String filename) Writes the contents of @key_file to @filename using
g_file_set_contents().void
setBoolean
(Str group_name, Str key, boolean value) Associates a new boolean value with @key under @group_name.void
setBoolean
(String group_name, String key, boolean value) Associates a new boolean value with @key under @group_name.void
setBooleanList
(Str group_name, Str key, Int list, long length) Associates a list of boolean values with @key under @group_name.void
setBooleanList
(String group_name, String key, Int list, long length) Associates a list of boolean values with @key under @group_name.boolean
setComment
(Str group_name, Str key, Str comment) Places a comment above @key from @group_name.boolean
setComment
(String group_name, String key, String comment) Places a comment above @key from @group_name.void
Associates a new double value with @key under @group_name.void
Associates a new double value with @key under @group_name.void
setDoubleList
(Str group_name, Str key, Dbl list, long length) Associates a list of double values with @key under
@group_name.void
setDoubleList
(String group_name, String key, Dbl list, long length) Associates a list of double values with @key under
@group_name.void
Associates a new integer value with @key under @group_name.void
Associates a new integer value with @key under @group_name.void
setInteger
(Str group_name, Str key, int value) Associates a new integer value with @key under @group_name.void
setInteger
(String group_name, String key, int value) Associates a new integer value with @key under @group_name.void
setIntegerList
(Str group_name, Str key, Int list, long length) Associates a list of integer values with @key under @group_name.void
setIntegerList
(String group_name, String key, Int list, long length) Associates a list of integer values with @key under @group_name.void
setListSeparator
(byte separator) Sets the character which is used to separate
values in lists.void
setLocaleString
(Str group_name, Str key, Str locale, Str string) Associates a string value for @key and @locale under @group_name.void
setLocaleString
(String group_name, String key, String locale, String string) Associates a string value for @key and @locale under @group_name.void
Associates a new string value with @key under @group_name.void
Associates a new string value with @key under @group_name.void
Associates a new integer value with @key under @group_name.void
Associates a new integer value with @key under @group_name.void
Associates a new value with @key under @group_name.void
Associates a new value with @key under @group_name.This function outputs @key_file as a string.void
unref()
Decreases the reference count of @key_file by 1.Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Constructor Details
-
KeyFile
-
KeyFile
public KeyFile()Creates a new empty #GKeyFile object. Use
g_key_file_load_from_file(), g_key_file_load_from_data(),
g_key_file_load_from_dirs() or g_key_file_load_from_data_dirs() to
read an existing key file.
-
-
Method Details
-
getClassHandler
-
free
public void free()Clears all keys and groups from @key_file, and decreases the
reference count by 1. If the reference count reaches zero,
frees the key file and all its allocated memory. -
getBoolean
Returns the value associated with @key under @group_name as a
boolean.
If @key cannot be found then %FALSE is returned and @error is set
to %G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value
associated with @key cannot be interpreted as a boolean then %FALSE
is returned and @error is set to %G_KEY_FILE_ERROR_INVALID_VALUE.- Parameters:
group_name
- a group namekey
- a key- Returns:
- the value associated with the key as a boolean, or %FALSE if the key was not found or could not be parsed.
- Throws:
AllocationError
-
getBoolean
Returns the value associated with @key under @group_name as a
boolean.
If @key cannot be found then %FALSE is returned and @error is set
to %G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value
associated with @key cannot be interpreted as a boolean then %FALSE
is returned and @error is set to %G_KEY_FILE_ERROR_INVALID_VALUE.- Parameters:
group_name
- a group namekey
- a key- Returns:
- the value associated with the key as a boolean, or %FALSE if the key was not found or could not be parsed.
- Throws:
AllocationError
-
getBooleanList
public Int getBooleanList(@Nonnull Str group_name, @Nonnull Str key, @Nonnull Int64 length) throws AllocationError Returns the values associated with @key under @group_name as
booleans.
If @key cannot be found then %NULL is returned and @error is set to
%G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
with @key cannot be interpreted as booleans then %NULL is returned
and @error is set to %G_KEY_FILE_ERROR_INVALID_VALUE.- Parameters:
group_name
- a group namekey
- a keylength
- the number of booleans returned- Returns:
- the values associated with the key as a list of booleans, or %NULL if the key was not found or could not be parsed. The returned list of booleans should be freed with g_free() when no longer needed.
- Throws:
AllocationError
-
getBooleanList
public Int getBooleanList(String group_name, String key, @Nonnull Int64 length) throws AllocationError Returns the values associated with @key under @group_name as
booleans.
If @key cannot be found then %NULL is returned and @error is set to
%G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
with @key cannot be interpreted as booleans then %NULL is returned
and @error is set to %G_KEY_FILE_ERROR_INVALID_VALUE.- Parameters:
group_name
- a group namekey
- a keylength
- the number of booleans returned- Returns:
- the values associated with the key as a list of booleans, or %NULL if the key was not found or could not be parsed. The returned list of booleans should be freed with g_free() when no longer needed.
- Throws:
AllocationError
-
getComment
Retrieves a comment above @key from @group_name.
If @key is %NULL then @comment will be read from above
@group_name. If both @key and @group_name are %NULL, then
@comment will be read from above the first group in the file.
Note that the returned string does not include the '#' comment markers,
but does include any whitespace after them (on each line). It includes
the line breaks between lines, but does not include the final line break.- Parameters:
group_name
- a group name, or %NULLkey
- a key- Returns:
- a comment that should be freed with g_free()
- Throws:
AllocationError
-
getComment
Retrieves a comment above @key from @group_name.
If @key is %NULL then @comment will be read from above
@group_name. If both @key and @group_name are %NULL, then
@comment will be read from above the first group in the file.
Note that the returned string does not include the '#' comment markers,
but does include any whitespace after them (on each line). It includes
the line breaks between lines, but does not include the final line break.- Parameters:
group_name
- a group name, or %NULLkey
- a key- Returns:
- a comment that should be freed with g_free()
- Throws:
AllocationError
-
getDouble
Returns the value associated with @key under @group_name as a
double. If @group_name is %NULL, the start_group is used.
If @key cannot be found then 0.0 is returned and @error is set to
%G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated
with @key cannot be interpreted as a double then 0.0 is returned
and @error is set to %G_KEY_FILE_ERROR_INVALID_VALUE.- Parameters:
group_name
- a group namekey
- a key- Returns:
- the value associated with the key as a double, or 0.0 if the key was not found or could not be parsed.
- Throws:
AllocationError
-
getDouble
Returns the value associated with @key under @group_name as a
double. If @group_name is %NULL, the start_group is used.
If @key cannot be found then 0.0 is returned and @error is set to
%G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated
with @key cannot be interpreted as a double then 0.0 is returned
and @error is set to %G_KEY_FILE_ERROR_INVALID_VALUE.- Parameters:
group_name
- a group namekey
- a key- Returns:
- the value associated with the key as a double, or 0.0 if the key was not found or could not be parsed.
- Throws:
AllocationError
-
getDoubleList
public Dbl getDoubleList(@Nonnull Str group_name, @Nonnull Str key, @Nonnull Int64 length) throws AllocationError Returns the values associated with @key under @group_name as
doubles.
If @key cannot be found then %NULL is returned and @error is set to
%G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
with @key cannot be interpreted as doubles then %NULL is returned
and @error is set to %G_KEY_FILE_ERROR_INVALID_VALUE.- Parameters:
group_name
- a group namekey
- a keylength
- the number of doubles returned- Returns:
- the values associated with the key as a list of doubles, or %NULL if the key was not found or could not be parsed. The returned list of doubles should be freed with g_free() when no longer needed.
- Throws:
AllocationError
-
getDoubleList
public Dbl getDoubleList(String group_name, String key, @Nonnull Int64 length) throws AllocationError Returns the values associated with @key under @group_name as
doubles.
If @key cannot be found then %NULL is returned and @error is set to
%G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
with @key cannot be interpreted as doubles then %NULL is returned
and @error is set to %G_KEY_FILE_ERROR_INVALID_VALUE.- Parameters:
group_name
- a group namekey
- a keylength
- the number of doubles returned- Returns:
- the values associated with the key as a list of doubles, or %NULL if the key was not found or could not be parsed. The returned list of doubles should be freed with g_free() when no longer needed.
- Throws:
AllocationError
-
getInt64
Returns the value associated with @key under @group_name as a signed
64-bit integer. This is similar to g_key_file_get_integer() but can return
64-bit results without truncation.- Parameters:
group_name
- a non-%NULL group namekey
- a non-%NULL key- Returns:
- the value associated with the key as a signed 64-bit integer, or 0 if the key was not found or could not be parsed.
- Throws:
AllocationError
-
getInt64
Returns the value associated with @key under @group_name as a signed
64-bit integer. This is similar to g_key_file_get_integer() but can return
64-bit results without truncation.- Parameters:
group_name
- a non-%NULL group namekey
- a non-%NULL key- Returns:
- the value associated with the key as a signed 64-bit integer, or 0 if the key was not found or could not be parsed.
- Throws:
AllocationError
-
getInteger
Returns the value associated with @key under @group_name as an
integer.
If @key cannot be found then 0 is returned and @error is set to
%G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated
with @key cannot be interpreted as an integer, or is out of range
for a #gint, then 0 is returned
and @error is set to %G_KEY_FILE_ERROR_INVALID_VALUE.- Parameters:
group_name
- a group namekey
- a key- Returns:
- the value associated with the key as an integer, or 0 if the key was not found or could not be parsed.
- Throws:
AllocationError
-
getInteger
Returns the value associated with @key under @group_name as an
integer.
If @key cannot be found then 0 is returned and @error is set to
%G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated
with @key cannot be interpreted as an integer, or is out of range
for a #gint, then 0 is returned
and @error is set to %G_KEY_FILE_ERROR_INVALID_VALUE.- Parameters:
group_name
- a group namekey
- a key- Returns:
- the value associated with the key as an integer, or 0 if the key was not found or could not be parsed.
- Throws:
AllocationError
-
getIntegerList
public Int getIntegerList(@Nonnull Str group_name, @Nonnull Str key, @Nonnull Int64 length) throws AllocationError Returns the values associated with @key under @group_name as
integers.
If @key cannot be found then %NULL is returned and @error is set to
%G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
with @key cannot be interpreted as integers, or are out of range for
#gint, then %NULL is returned
and @error is set to %G_KEY_FILE_ERROR_INVALID_VALUE.- Parameters:
group_name
- a group namekey
- a keylength
- the number of integers returned- Returns:
- the values associated with the key as a list of integers, or %NULL if the key was not found or could not be parsed. The returned list of integers should be freed with g_free() when no longer needed.
- Throws:
AllocationError
-
getIntegerList
public Int getIntegerList(String group_name, String key, @Nonnull Int64 length) throws AllocationError Returns the values associated with @key under @group_name as
integers.
If @key cannot be found then %NULL is returned and @error is set to
%G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the values associated
with @key cannot be interpreted as integers, or are out of range for
#gint, then %NULL is returned
and @error is set to %G_KEY_FILE_ERROR_INVALID_VALUE.- Parameters:
group_name
- a group namekey
- a keylength
- the number of integers returned- Returns:
- the values associated with the key as a list of integers, or %NULL if the key was not found or could not be parsed. The returned list of integers should be freed with g_free() when no longer needed.
- Throws:
AllocationError
-
getLocaleForKey
Returns the actual locale which the result of
g_key_file_get_locale_string() or g_key_file_get_locale_string_list()
came from.
If calling g_key_file_get_locale_string() or
g_key_file_get_locale_string_list() with exactly the same @key_file,
@group_name, @key and @locale, the result of those functions will
have originally been tagged with the locale that is the result of
this function.- Parameters:
group_name
- a group namekey
- a keylocale
- a locale identifier or %NULL- Returns:
- the locale from the file, or %NULL if the key was not found or the entry in the file was was untranslated
-
getLocaleForKey
Returns the actual locale which the result of
g_key_file_get_locale_string() or g_key_file_get_locale_string_list()
came from.
If calling g_key_file_get_locale_string() or
g_key_file_get_locale_string_list() with exactly the same @key_file,
@group_name, @key and @locale, the result of those functions will
have originally been tagged with the locale that is the result of
this function.- Parameters:
group_name
- a group namekey
- a keylocale
- a locale identifier or %NULL- Returns:
- the locale from the file, or %NULL if the key was not found or the entry in the file was was untranslated
-
getLocaleString
public Str getLocaleString(@Nonnull Str group_name, @Nonnull Str key, @Nullable Str locale) throws AllocationError Returns the value associated with @key under @group_name
translated in the given @locale if available. If @locale is
%NULL then the current locale is assumed.
If @locale is to be non-%NULL, or if the current locale will change over
the lifetime of the #GKeyFile, it must be loaded with
%G_KEY_FILE_KEEP_TRANSLATIONS in order to load strings for all locales.
If @key cannot be found then %NULL is returned and @error is set
to %G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the value associated
with @key cannot be interpreted or no suitable translation can
be found then the untranslated value is returned.- Parameters:
group_name
- a group namekey
- a keylocale
- a locale identifier or %NULL- Returns:
- a newly allocated string or %NULL if the specified key cannot be found.
- Throws:
AllocationError
-
getLocaleString
Returns the value associated with @key under @group_name
translated in the given @locale if available. If @locale is
%NULL then the current locale is assumed.
If @locale is to be non-%NULL, or if the current locale will change over
the lifetime of the #GKeyFile, it must be loaded with
%G_KEY_FILE_KEEP_TRANSLATIONS in order to load strings for all locales.
If @key cannot be found then %NULL is returned and @error is set
to %G_KEY_FILE_ERROR_KEY_NOT_FOUND. If the value associated
with @key cannot be interpreted or no suitable translation can
be found then the untranslated value is returned.- Parameters:
group_name
- a group namekey
- a keylocale
- a locale identifier or %NULL- Returns:
- a newly allocated string or %NULL if the specified key cannot be found.
- Throws:
AllocationError
-
getStartGroup
Returns the name of the start group of the file.- Returns:
- The start group of the key file.
-
getString
Returns the string value associated with @key under @group_name.
Unlike g_key_file_get_value(), this function handles escape sequences
like \s.
In the event the key cannot be found, %NULL is returned and
@error is set to %G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the
event that the @group_name cannot be found, %NULL is returned
and @error is set to %G_KEY_FILE_ERROR_GROUP_NOT_FOUND.- Parameters:
group_name
- a group namekey
- a key- Returns:
- a newly allocated string or %NULL if the specified key cannot be found.
- Throws:
AllocationError
-
getString
Returns the string value associated with @key under @group_name.
Unlike g_key_file_get_value(), this function handles escape sequences
like \s.
In the event the key cannot be found, %NULL is returned and
@error is set to %G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the
event that the @group_name cannot be found, %NULL is returned
and @error is set to %G_KEY_FILE_ERROR_GROUP_NOT_FOUND.- Parameters:
group_name
- a group namekey
- a key- Returns:
- a newly allocated string or %NULL if the specified key cannot be found.
- Throws:
AllocationError
-
getUint64
Returns the value associated with @key under @group_name as an unsigned
64-bit integer. This is similar to g_key_file_get_integer() but can return
large positive results without truncation.- Parameters:
group_name
- a non-%NULL group namekey
- a non-%NULL key- Returns:
- the value associated with the key as an unsigned 64-bit integer, or 0 if the key was not found or could not be parsed.
- Throws:
AllocationError
-
getUint64
Returns the value associated with @key under @group_name as an unsigned
64-bit integer. This is similar to g_key_file_get_integer() but can return
large positive results without truncation.- Parameters:
group_name
- a non-%NULL group namekey
- a non-%NULL key- Returns:
- the value associated with the key as an unsigned 64-bit integer, or 0 if the key was not found or could not be parsed.
- Throws:
AllocationError
-
getValue
Returns the raw value associated with @key under @group_name.
Use g_key_file_get_string() to retrieve an unescaped UTF-8 string.
In the event the key cannot be found, %NULL is returned and
@error is set to %G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the
event that the @group_name cannot be found, %NULL is returned
and @error is set to %G_KEY_FILE_ERROR_GROUP_NOT_FOUND.- Parameters:
group_name
- a group namekey
- a key- Returns:
- a newly allocated string or %NULL if the specified key cannot be found.
- Throws:
AllocationError
-
getValue
Returns the raw value associated with @key under @group_name.
Use g_key_file_get_string() to retrieve an unescaped UTF-8 string.
In the event the key cannot be found, %NULL is returned and
@error is set to %G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the
event that the @group_name cannot be found, %NULL is returned
and @error is set to %G_KEY_FILE_ERROR_GROUP_NOT_FOUND.- Parameters:
group_name
- a group namekey
- a key- Returns:
- a newly allocated string or %NULL if the specified key cannot be found.
- Throws:
AllocationError
-
hasGroup
Looks whether the key file has the group @group_name.- Parameters:
group_name
- a group name- Returns:
- %TRUE if @group_name is a part of @key_file, %FALSE otherwise.
-
hasGroup
Looks whether the key file has the group @group_name.- Parameters:
group_name
- a group name- Returns:
- %TRUE if @group_name is a part of @key_file, %FALSE otherwise.
-
hasKey
Looks whether the key file has the key @key in the group
@group_name.
Note that this function does not follow the rules for #GError strictly;
the return value both carries meaning and signals an error. To use
this function, you must pass a #GError pointer in @error, and check
whether it is not %NULL to see if an error occurred.
Language bindings should use g_key_file_get_value() to test whether
or not a key exists.- Parameters:
group_name
- a group namekey
- a key name- Returns:
- %TRUE if @key is a part of @group_name, %FALSE otherwise
- Throws:
AllocationError
-
hasKey
Looks whether the key file has the key @key in the group
@group_name.
Note that this function does not follow the rules for #GError strictly;
the return value both carries meaning and signals an error. To use
this function, you must pass a #GError pointer in @error, and check
whether it is not %NULL to see if an error occurred.
Language bindings should use g_key_file_get_value() to test whether
or not a key exists.- Parameters:
group_name
- a group namekey
- a key name- Returns:
- %TRUE if @key is a part of @group_name, %FALSE otherwise
- Throws:
AllocationError
-
loadFromBytes
Loads a key file from the data in @bytes into an empty #GKeyFile structure.
If the object cannot be created then %error is set to a #GKeyFileError.- Parameters:
bytes
- a #GBytesflags
- flags from #GKeyFileFlags- Returns:
- %TRUE if a key file could be loaded, %FALSE otherwise
- Throws:
AllocationError
-
loadFromData
Loads a key file from memory into an empty #GKeyFile structure.
If the object cannot be created then %error is set to a #GKeyFileError.- Parameters:
data
- key file loaded in memorylength
- the length of @data in bytes (or (gsize)-1 if data is nul-terminated)flags
- flags from #GKeyFileFlags- Returns:
- %TRUE if a key file could be loaded, %FALSE otherwise
- Throws:
AllocationError
-
loadFromData
Loads a key file from memory into an empty #GKeyFile structure.
If the object cannot be created then %error is set to a #GKeyFileError.- Parameters:
data
- key file loaded in memorylength
- the length of @data in bytes (or (gsize)-1 if data is nul-terminated)flags
- flags from #GKeyFileFlags- Returns:
- %TRUE if a key file could be loaded, %FALSE otherwise
- Throws:
AllocationError
-
loadFromFile
Loads a key file into an empty #GKeyFile structure.
If the OS returns an error when opening or reading the file, a
%G_FILE_ERROR is returned. If there is a problem parsing the file, a
%G_KEY_FILE_ERROR is returned.
This function will never return a %G_KEY_FILE_ERROR_NOT_FOUND error. If the
@file is not found, %G_FILE_ERROR_NOENT is returned.- Parameters:
file
- the path of a filename to load, in the GLib filename encodingflags
- flags from #GKeyFileFlags- Returns:
- %TRUE if a key file could be loaded, %FALSE otherwise
- Throws:
AllocationError
-
loadFromFile
Loads a key file into an empty #GKeyFile structure.
If the OS returns an error when opening or reading the file, a
%G_FILE_ERROR is returned. If there is a problem parsing the file, a
%G_KEY_FILE_ERROR is returned.
This function will never return a %G_KEY_FILE_ERROR_NOT_FOUND error. If the
@file is not found, %G_FILE_ERROR_NOENT is returned.- Parameters:
file
- the path of a filename to load, in the GLib filename encodingflags
- flags from #GKeyFileFlags- Returns:
- %TRUE if a key file could be loaded, %FALSE otherwise
- Throws:
AllocationError
-
ref
Increases the reference count of @key_file.- Returns:
- the same @key_file.
-
removeComment
Removes a comment above @key from @group_name.
If @key is %NULL then @comment will be removed above @group_name.
If both @key and @group_name are %NULL, then @comment will
be removed above the first group in the file.- Parameters:
group_name
- a group name, or %NULLkey
- a key- Returns:
- %TRUE if the comment was removed, %FALSE otherwise
- Throws:
AllocationError
-
removeComment
Removes a comment above @key from @group_name.
If @key is %NULL then @comment will be removed above @group_name.
If both @key and @group_name are %NULL, then @comment will
be removed above the first group in the file.- Parameters:
group_name
- a group name, or %NULLkey
- a key- Returns:
- %TRUE if the comment was removed, %FALSE otherwise
- Throws:
AllocationError
-
removeGroup
Removes the specified group, @group_name,
from the key file.- Parameters:
group_name
- a group name- Returns:
- %TRUE if the group was removed, %FALSE otherwise
- Throws:
AllocationError
-
removeGroup
Removes the specified group, @group_name,
from the key file.- Parameters:
group_name
- a group name- Returns:
- %TRUE if the group was removed, %FALSE otherwise
- Throws:
AllocationError
-
removeKey
Removes @key in @group_name from the key file.- Parameters:
group_name
- a group namekey
- a key name to remove- Returns:
- %TRUE if the key was removed, %FALSE otherwise
- Throws:
AllocationError
-
removeKey
Removes @key in @group_name from the key file.- Parameters:
group_name
- a group namekey
- a key name to remove- Returns:
- %TRUE if the key was removed, %FALSE otherwise
- Throws:
AllocationError
-
saveToFile
Writes the contents of @key_file to @filename using
g_file_set_contents(). If you need stricter guarantees about durability of
the written file than are provided by g_file_set_contents(), use
g_file_set_contents_full() with the return value of g_key_file_to_data().
This function can fail for any of the reasons that
g_file_set_contents() may fail.- Parameters:
filename
- the name of the file to write to- Returns:
- %TRUE if successful, else %FALSE with @error set
- Throws:
AllocationError
-
saveToFile
Writes the contents of @key_file to @filename using
g_file_set_contents(). If you need stricter guarantees about durability of
the written file than are provided by g_file_set_contents(), use
g_file_set_contents_full() with the return value of g_key_file_to_data().
This function can fail for any of the reasons that
g_file_set_contents() may fail.- Parameters:
filename
- the name of the file to write to- Returns:
- %TRUE if successful, else %FALSE with @error set
- Throws:
AllocationError
-
setBoolean
Associates a new boolean value with @key under @group_name.
If @key cannot be found then it is created.- Parameters:
group_name
- a group namekey
- a keyvalue
- %TRUE or %FALSE
-
setBoolean
Associates a new boolean value with @key under @group_name.
If @key cannot be found then it is created.- Parameters:
group_name
- a group namekey
- a keyvalue
- %TRUE or %FALSE
-
setBooleanList
public void setBooleanList(@Nonnull Str group_name, @Nonnull Str key, @Nonnull Int list, long length) Associates a list of boolean values with @key under @group_name.
If @key cannot be found then it is created.
If @group_name is %NULL, the start_group is used.- Parameters:
group_name
- a group namekey
- a keylist
- an array of boolean valueslength
- length of @list
-
setBooleanList
Associates a list of boolean values with @key under @group_name.
If @key cannot be found then it is created.
If @group_name is %NULL, the start_group is used.- Parameters:
group_name
- a group namekey
- a keylist
- an array of boolean valueslength
- length of @list
-
setComment
public boolean setComment(@Nullable Str group_name, @Nullable Str key, @Nonnull Str comment) throws AllocationError Places a comment above @key from @group_name.
If @key is %NULL then @comment will be written above @group_name.
If both @key and @group_name are %NULL, then @comment will be
written above the first group in the file.
Note that this function prepends a '#' comment marker to
each line of @comment.- Parameters:
group_name
- a group name, or %NULLkey
- a keycomment
- a comment- Returns:
- %TRUE if the comment was written, %FALSE otherwise
- Throws:
AllocationError
-
setComment
Places a comment above @key from @group_name.
If @key is %NULL then @comment will be written above @group_name.
If both @key and @group_name are %NULL, then @comment will be
written above the first group in the file.
Note that this function prepends a '#' comment marker to
each line of @comment.- Parameters:
group_name
- a group name, or %NULLkey
- a keycomment
- a comment- Returns:
- %TRUE if the comment was written, %FALSE otherwise
- Throws:
AllocationError
-
setDouble
Associates a new double value with @key under @group_name.
If @key cannot be found then it is created.- Parameters:
group_name
- a group namekey
- a keyvalue
- a double value
-
setDouble
Associates a new double value with @key under @group_name.
If @key cannot be found then it is created.- Parameters:
group_name
- a group namekey
- a keyvalue
- a double value
-
setDoubleList
public void setDoubleList(@Nonnull Str group_name, @Nonnull Str key, @Nonnull Dbl list, long length) Associates a list of double values with @key under
@group_name. If @key cannot be found then it is created.- Parameters:
group_name
- a group namekey
- a keylist
- an array of double valueslength
- number of double values in @list
-
setDoubleList
Associates a list of double values with @key under
@group_name. If @key cannot be found then it is created.- Parameters:
group_name
- a group namekey
- a keylist
- an array of double valueslength
- number of double values in @list
-
setInt64
Associates a new integer value with @key under @group_name.
If @key cannot be found then it is created.- Parameters:
group_name
- a group namekey
- a keyvalue
- an integer value
-
setInt64
Associates a new integer value with @key under @group_name.
If @key cannot be found then it is created.- Parameters:
group_name
- a group namekey
- a keyvalue
- an integer value
-
setInteger
Associates a new integer value with @key under @group_name.
If @key cannot be found then it is created.- Parameters:
group_name
- a group namekey
- a keyvalue
- an integer value
-
setInteger
Associates a new integer value with @key under @group_name.
If @key cannot be found then it is created.- Parameters:
group_name
- a group namekey
- a keyvalue
- an integer value
-
setIntegerList
public void setIntegerList(@Nonnull Str group_name, @Nonnull Str key, @Nonnull Int list, long length) Associates a list of integer values with @key under @group_name.
If @key cannot be found then it is created.- Parameters:
group_name
- a group namekey
- a keylist
- an array of integer valueslength
- number of integer values in @list
-
setIntegerList
Associates a list of integer values with @key under @group_name.
If @key cannot be found then it is created.- Parameters:
group_name
- a group namekey
- a keylist
- an array of integer valueslength
- number of integer values in @list
-
setListSeparator
public void setListSeparator(byte separator) Sets the character which is used to separate
values in lists. Typically ';' or ',' are used
as separators. The default list separator is ';'.- Parameters:
separator
- the separator
-
setLocaleString
public void setLocaleString(@Nonnull Str group_name, @Nonnull Str key, @Nonnull Str locale, @Nonnull Str string) Associates a string value for @key and @locale under @group_name.
If the translation for @key cannot be found then it is created.- Parameters:
group_name
- a group namekey
- a keylocale
- a locale identifierstring
- a string
-
setLocaleString
Associates a string value for @key and @locale under @group_name.
If the translation for @key cannot be found then it is created.- Parameters:
group_name
- a group namekey
- a keylocale
- a locale identifierstring
- a string
-
setString
Associates a new string value with @key under @group_name.
If @key cannot be found then it is created.
If @group_name cannot be found then it is created.
Unlike g_key_file_set_value(), this function handles characters
that need escaping, such as newlines.- Parameters:
group_name
- a group namekey
- a keystring
- a string
-
setString
Associates a new string value with @key under @group_name.
If @key cannot be found then it is created.
If @group_name cannot be found then it is created.
Unlike g_key_file_set_value(), this function handles characters
that need escaping, such as newlines.- Parameters:
group_name
- a group namekey
- a keystring
- a string
-
setUint64
Associates a new integer value with @key under @group_name.
If @key cannot be found then it is created.- Parameters:
group_name
- a group namekey
- a keyvalue
- an integer value
-
setUint64
Associates a new integer value with @key under @group_name.
If @key cannot be found then it is created.- Parameters:
group_name
- a group namekey
- a keyvalue
- an integer value
-
setValue
Associates a new value with @key under @group_name.
If @key cannot be found then it is created. If @group_name cannot
be found then it is created. To set an UTF-8 string which may contain
characters that need escaping (such as newlines or spaces), use
g_key_file_set_string().- Parameters:
group_name
- a group namekey
- a keyvalue
- a string
-
setValue
Associates a new value with @key under @group_name.
If @key cannot be found then it is created. If @group_name cannot
be found then it is created. To set an UTF-8 string which may contain
characters that need escaping (such as newlines or spaces), use
g_key_file_set_string().- Parameters:
group_name
- a group namekey
- a keyvalue
- a string
-
toData
This function outputs @key_file as a string.
Note that this function never reports an error,
so it is safe to pass %NULL as @error.- Parameters:
length
- return location for the length of the returned string, or %NULL- Returns:
- a newly allocated string holding the contents of the #GKeyFile
- Throws:
AllocationError
-
unref
public void unref()Decreases the reference count of @key_file by 1. If the reference count
reaches zero, frees the key file and all its allocated memory. -
errorQuark
public static int errorQuark()- Returns:
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-