ZIF Reference Manual | ||||
---|---|---|---|---|
Top | Description | Object Hierarchy |
#define ZIF_CONFIG_ERROR struct ZifConfig; struct ZifConfigClass; enum ZifConfigError; guint (*ZifConfigEnumMappingFunc) (const gchar *str
); GQuark zif_config_error_quark (void
); ZifConfig * zif_config_new (void
); gboolean zif_config_is_instance_valid (void
); gboolean zif_config_set_filename (ZifConfig *config
,const gchar *filename
,GError **error
); gboolean zif_config_unset (ZifConfig *config
,const gchar *key
,GError **error
); gchar * zif_config_get_string (ZifConfig *config
,const gchar *key
,GError **error
); gchar ** zif_config_get_strv (ZifConfig *config
,const gchar *key
,GError **error
); gboolean zif_config_get_boolean (ZifConfig *config
,const gchar *key
,GError **error
); guint zif_config_get_uint (ZifConfig *config
,const gchar *key
,GError **error
); guint zif_config_get_time (ZifConfig *config
,const gchar *key
,GError **error
); guint zif_config_get_enum (ZifConfig *config
,const gchar *key
,ZifConfigEnumMappingFunc func
,GError **error
); gboolean zif_config_set_local (ZifConfig *config
,const gchar *key
,const gchar *value
,GError **error
); gboolean zif_config_set_string (ZifConfig *config
,const gchar *key
,const gchar *value
,GError **error
); gboolean zif_config_set_boolean (ZifConfig *config
,const gchar *key
,gboolean value
,GError **error
); gboolean zif_config_set_uint (ZifConfig *config
,const gchar *key
,guint value
,GError **error
); gboolean zif_config_reset_default (ZifConfig *config
,GError **error
); gchar * zif_config_expand_substitutions (ZifConfig *config
,const gchar *text
,GError **error
); gchar ** zif_config_get_basearch_array (ZifConfig *config
);
ZifConfig allows settings to be read from a central config file. Some values can be overridden in a running instance.
The values that are overridden can be reset back to the defaults without re-reading the config file.
Different types of data can be read (string, bool, uint, time).
Before reading any data, the backing config file has to be set with
zif_config_set_filename()
and any reads prior to that will fail.
struct ZifConfigClass { GObjectClass parent_class; /* Padding for future expansion */ void (*_zif_reserved1) (void); void (*_zif_reserved2) (void); void (*_zif_reserved3) (void); void (*_zif_reserved4) (void); };
GQuark zif_config_error_quark (void
);
Returns : |
An error quark. |
Since 0.1.0
ZifConfig * zif_config_new (void
);
Returns : |
A new ZifConfig instance. |
Since 0.1.0
gboolean zif_config_is_instance_valid (void
);
Returns : |
TRUE if a singleton instance already exists |
Since 0.1.6
gboolean zif_config_set_filename (ZifConfig *config
,const gchar *filename
,GError **error
);
Sets the filename to use as the system wide config file.
Using filename
set to NULL
to use the default value
has been supported since 0.1.3. Earlier versions will assert.
|
A ZifConfig |
|
A system wide config file, e.g. "/etc/zif/zif.conf", or NULL to use the default. |
|
A GError, or NULL
|
Returns : |
TRUE for success, FALSE otherwise |
Since 0.1.0
gboolean zif_config_unset (ZifConfig *config
,const gchar *key
,GError **error
);
Unsets an overriden value back to the default. Note: if the value was never set then this method also returns with success. The idea is that we unset any value.
|
A ZifConfig |
|
A key name to unset, e.g. "cachedir" |
|
A GError, or NULL
|
Returns : |
TRUE for success |
Since 0.1.3
gchar * zif_config_get_string (ZifConfig *config
,const gchar *key
,GError **error
);
Gets a string value from a local setting, falling back to the config file.
|
A ZifConfig |
|
A key name to retrieve, e.g. "cachedir" |
|
A GError, or NULL
|
Returns : |
An allocated value, or NULL
|
Since 0.1.0
gchar ** zif_config_get_strv (ZifConfig *config
,const gchar *key
,GError **error
);
Gets a string array value from a local setting, falling back to the config file.
|
A ZifConfig |
|
A key name to retrieve, e.g. "keepcache" |
|
A GError, or NULL
|
Returns : |
NULL , or a string array. [element-type utf8][transfer full]
|
Since 0.1.3
gboolean zif_config_get_boolean (ZifConfig *config
,const gchar *key
,GError **error
);
Gets a boolean value from a local setting, falling back to the config file.
|
A ZifConfig |
|
A key name to retrieve, e.g. "keepcache" |
|
A GError, or NULL
|
Returns : |
TRUE or FALSE
|
Since 0.1.0
guint zif_config_get_uint (ZifConfig *config
,const gchar *key
,GError **error
);
Gets a unsigned integer value from a local setting, falling back to the config file.
|
A ZifConfig |
|
A key name to retrieve, e.g. "keepcache" |
|
A GError, or NULL
|
Returns : |
Data value, or G_MAXUINT for error |
Since 0.1.0
guint zif_config_get_time (ZifConfig *config
,const gchar *key
,GError **error
);
Gets a time value from a local setting, falling back to the config file.
|
A ZifConfig |
|
A key name to retrieve, e.g. "metadata_expire" |
|
A GError, or NULL
|
Returns : |
Data value, or 0 for an error |
Since 0.1.0
guint zif_config_get_enum (ZifConfig *config
,const gchar *key
,ZifConfigEnumMappingFunc func
,GError **error
);
Gets an enumerated value from a local setting, falling back to the config file.
|
A ZifConfig |
|
A key name to retrieve, e.g. "pkg_compare_mode" |
|
A ZifConfigEnumMappingFunc to convert the string to an enum. [scope call] |
|
A GError, or NULL
|
Returns : |
Enumerated value, or G_MAXUINT for an error |
Since 0.2.3
gboolean zif_config_set_local (ZifConfig *config
,const gchar *key
,const gchar *value
,GError **error
);
Sets a local value which is used in preference to the config value.
This is deprecated. Use zif_config_set_string()
, zif_config_set_uint()
and zif_config_set_boolean()
instead.
|
A ZifConfig |
|
Key name to save, e.g. "keepcache" |
|
Key data to save, e.g. "always" |
|
A GError, or NULL
|
Returns : |
TRUE for success, FALSE otherwise |
Since 0.1.0
gboolean zif_config_set_string (ZifConfig *config
,const gchar *key
,const gchar *value
,GError **error
);
Sets a local value which is used in preference to the config value.
|
A ZifConfig |
|
Key name to save, e.g. "keepcache" |
|
Key data to save, e.g. "always" |
|
A GError, or NULL
|
Returns : |
TRUE for success, FALSE otherwise |
Since 0.1.2
gboolean zif_config_set_boolean (ZifConfig *config
,const gchar *key
,gboolean value
,GError **error
);
Sets a local value which is used in preference to the config value.
TRUE
is saved as "true" and FALSE
is saved as "false"
|
A ZifConfig |
|
Key name to save, e.g. "keepcache" |
|
Key data, e.g. TRUE
|
|
A GError, or NULL
|
Returns : |
TRUE for success, FALSE otherwise |
Since 0.1.2
gboolean zif_config_set_uint (ZifConfig *config
,const gchar *key
,guint value
,GError **error
);
Sets a local value which is used in preference to the config value.
|
A ZifConfig |
|
Key name to save, e.g. "keepcache" |
|
Key data, e.g. TRUE
|
|
A GError, or NULL
|
Returns : |
TRUE for success, FALSE otherwise |
Since 0.1.2
gboolean zif_config_reset_default (ZifConfig *config
,GError **error
);
Removes any local settings previously set.
Since 0.1.0
gchar * zif_config_expand_substitutions (ZifConfig *config
,const gchar *text
,GError **error
);
Replaces substitutions in text with the actual values of the running system.
|
A ZifConfig |
|
The string to scan, e.g. "http://fedora/$releasever/$basearch/moo.rpm" |
|
A GError, or NULL
|
Returns : |
A new allocated string or NULL for error |
Since 0.1.0