Re: [PATCH] config: rework code to use GKeyFile instead of GHashTable+GValue
- From: Lionel Landwerlin <lionel g landwerlin linux intel com>
- To: grilo-list gnome org
- Subject: Re: [PATCH] config: rework code to use GKeyFile instead of GHashTable+GValue
- Date: Tue, 18 Jan 2011 15:05:32 +0000
On Tue, 2011-01-18 at 14:58 +0000, Iago Toral wrote:
> Hi,
>
> there is still one minor problem, which was partially present in the
> previous implementation:
>
> if the client requests the value for a configuration parameter that is
> not present in the configuration, it gets a default value and no hint
> that the parameter did not exist. This was already the case in the
> previous code, however, when in need to know if the parameter actually
> existed, the client could use grl_config_get, which would return a
> GValue (if the parameter existed) or NULL (otherwise). This was used in
> the filesystem plugin to check the maximum depth allowed for search
> operations. In this plugin, if this limit is not set through a config
> parameter, a sane default is used by the plugin, but with this patch
> this situation can no longer be detected, since grl_config_get does not
> exist any more.
>
> My proposal to fix this situation is to add one more parameter to the
> 'get' APIs. The new parameter would be a pointer to a location where the
> result should be stored, and the function result would be a boolean to
> let clients know if the parameter did exist in the configuration.
>
> So, for example, we would have this:
> gboolean grl_config_get_string (GrlConfig *config, const gchar *param,
> gchar **value);
>
> Instead of this:
> gchar *grl_config_get_string (GrlConfig *config, const gchar *param);
>
> Sounds good?
>
GKeyFile has g_key_file_has_key() function, which we could wrap in a
grl_config_has_key/value/config function.
We could also use the GError framework as GKeyFile does.
Regards,
--
Lionel Landwerlin
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]