|
TaPAS
0.2
|
Implementation of some kind of "preferences" table. More...
Go to the source code of this file.
Macros | |
| #define | ccl_config_table_create() ccl_config_table_inherits (NULL) |
| Builds an empty table. | |
Typedefs | |
| typedef struct ccl_config_table_st | ccl_config_table |
| Abstract type for "preferences" table. | |
Functions | |
| ccl_config_table * | ccl_config_table_add_reference (ccl_config_table *conf) |
| Adds one reference to conf. More... | |
| void | ccl_config_table_del_reference (ccl_config_table *conf) |
| Removes one reference to conf. More... | |
| ccl_config_table * | ccl_config_table_inherits (ccl_config_table *parent) |
| Builds a locally empty table but inherits content from parent. More... | |
| int | ccl_config_table_is_changed (ccl_config_table *conf) |
| Checks if the content of the table has changed. More... | |
| void | ccl_config_table_set (ccl_config_table *conf, const char *name, const char *value) |
| Adds the couple (name, value) into conf. More... | |
| int | ccl_config_table_has (ccl_config_table *conf, const char *name) |
| Checks if the table conf contains an entry for the option name. More... | |
| const char * | ccl_config_table_set_if_null (ccl_config_table *conf, const char *name, const char *value) |
| Add the couple (name, value) if the entry does not exist. More... | |
| void | ccl_config_table_add (ccl_config_table *conf, ccl_config_table *others) |
| Adds all (local) preferences of others to conf. More... | |
| const char * | ccl_config_table_get (ccl_config_table *conf, const char *name) |
| Returns the value for the configuration option name. More... | |
| int | ccl_config_table_get_integer (ccl_config_table *conf, const char *name) |
| Returns the value for the configuration option name but the value is interpreted as an integer. More... | |
| int | ccl_config_table_get_boolean (ccl_config_table *conf, const char *name) |
| Returns the value for the configuration option name but the value is interpreted as a Boolean value. More... | |
| ccl_list * | ccl_config_table_get_names (ccl_config_table *conf) |
| Returns the list of valued options. More... | |
| void | ccl_config_table_save (ccl_config_table *conf, FILE *output) |
| Writes the content of conf onto the output stream. More... | |
| void | ccl_config_table_load (ccl_config_table *conf, FILE *input) |
| Reads configuration options from the input stream and adds them into the conf table. More... | |
| void | ccl_config_table_display (ccl_config_table *conf) |
| Display on the CCL_LOG_DISPLAY stream the entries of conf. More... | |
Implementation of some kind of "preferences" table.
This module implements hierarchical associative tables. Each ccl_config_table stores couple of strings (identifier, value). A table may inherits content from another which means that is an identifier is not found locally in a table, the search is transfered to the parent table (until the identifier is found or no more ancestor exists).
Definition in file ccl-config-table.h.
| void ccl_config_table_add | ( | ccl_config_table * | conf, |
| ccl_config_table * | others | ||
| ) |
Adds all (local) preferences of others to conf.
| conf | the configuration table |
| others | another configuration table |
| ccl_config_table* ccl_config_table_add_reference | ( | ccl_config_table * | conf | ) |
Adds one reference to conf.
The function increments the counter of references of conf.
| conf | the configuration table |
| void ccl_config_table_del_reference | ( | ccl_config_table * | conf | ) |
Removes one reference to conf.
If the counter of references of conf falls to zero then the resources allocated to conf are released.
| conf | the configuration table |
| void ccl_config_table_display | ( | ccl_config_table * | conf | ) |
Display on the CCL_LOG_DISPLAY stream the entries of conf.
| conf | the configuration table |
| const char* ccl_config_table_get | ( | ccl_config_table * | conf, |
| const char * | name | ||
| ) |
Returns the value for the configuration option name.
If the option is not found then a message is sent on CCL_LOG_WARNING.
| conf | the configuration table |
| name | the name of the option |
| int ccl_config_table_get_boolean | ( | ccl_config_table * | conf, |
| const char * | name | ||
| ) |
Returns the value for the configuration option name but the value is interpreted as a Boolean value.
| conf | the configuration table |
| name | the name of the option |
| int ccl_config_table_get_integer | ( | ccl_config_table * | conf, |
| const char * | name | ||
| ) |
Returns the value for the configuration option name but the value is interpreted as an integer.
| conf | the configuration table |
| name | the name of the option |
| ccl_list* ccl_config_table_get_names | ( | ccl_config_table * | conf | ) |
Returns the list of valued options.
The function collects in conf and its parents the name of options that have been set.
| conf | the configuration table |
| int ccl_config_table_has | ( | ccl_config_table * | conf, |
| const char * | name | ||
| ) |
Checks if the table conf contains an entry for the option name.
| conf | the configuration table |
| name | the name of the configuration option |
| ccl_config_table* ccl_config_table_inherits | ( | ccl_config_table * | parent | ) |
Builds a locally empty table but inherits content from parent.
| parent | the configuration table used as parent |
| int ccl_config_table_is_changed | ( | ccl_config_table * | conf | ) |
Checks if the content of the table has changed.
The table maintains a flag indicating if the value of one entry has been changed since the creation of the table or its loading. New entries are no considered here.
| conf | the configuration table |
| void ccl_config_table_load | ( | ccl_config_table * | conf, |
| FILE * | input | ||
| ) |
Reads configuration options from the input stream and adds them into the conf table.
input must be a stream containing data previously saved with the ccl_config_table_save function.
| conf | the configuration table |
| input | the input stream |
| void ccl_config_table_save | ( | ccl_config_table * | conf, |
| FILE * | output | ||
| ) |
Writes the content of conf onto the output stream.
| conf | the configuration table |
| output | the output stream |
| void ccl_config_table_set | ( | ccl_config_table * | conf, |
| const char * | name, | ||
| const char * | value | ||
| ) |
Adds the couple (name, value) into conf.
If the entry name exists in the table then the old value is replaced.
| conf | the configuration table |
| name | the option name |
| value | the value of the option |
| const char* ccl_config_table_set_if_null | ( | ccl_config_table * | conf, |
| const char * | name, | ||
| const char * | value | ||
| ) |
Add the couple (name, value) if the entry does not exist.
If the entry name does not exist in conf, then the entry is created with the couple (name, value); else, the existing value is not modified.
| conf | the configuration table |
| name | the name of the option to assign |
| value | the value assigned to the option |
1.8.5