gmerlin
cfg_registry.h
1/*****************************************************************
2 * gmerlin - a general purpose multimedia framework and applications
3 *
4 * Copyright (c) 2001 - 2012 Members of the Gmerlin project
5 * gmerlin-general@lists.sourceforge.net
6 * http://gmerlin.sourceforge.net
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * *****************************************************************/
21
22#ifndef __BG_CFG_REGISTRY_H_
23#define __BG_CFG_REGISTRY_H_
24
25#include <gmerlin/parameter.h>
26
59typedef struct bg_cfg_section_s bg_cfg_section_t;
60
67typedef struct bg_cfg_registry_s bg_cfg_registry_t;
68
77
84
85/* cfg_xml.c */
86
93void bg_cfg_registry_load(bg_cfg_registry_t * reg, const char * filename);
94
101void bg_cfg_registry_save(bg_cfg_registry_t * reg, const char * filename);
102
111int bg_cfg_registry_has_section(bg_cfg_registry_t * reg, const char * name);
112
113
114/* The name and xml tag of the section must be set before */
115
124void bg_cfg_section_2_xml(const bg_cfg_section_t * section, xmlNodePtr xml_section);
125
135void bg_cfg_xml_2_section(xmlDocPtr xml_doc, xmlNodePtr xml_section,
136 bg_cfg_section_t * section);
137
146void bg_cfg_section_dump(bg_cfg_section_t * section, const char * filename);
147
148/*
149 * Path looks like "section:subsection:subsubsection"
150 */
151
164 const char * path);
165
176 const char * name);
177
186 int pos);
187
196 int pos);
197
198
209 int index);
210
211
212/*
213 * Create/destroy config sections
214 */
215
223
237 const bg_parameter_info_t * parameters);
238
250 const bg_parameter_info_t * parameters);
251
258
266
278
286
294
295/*
296 * Get/Set section names
297 */
298
306
316
325void bg_cfg_section_set_name(bg_cfg_section_t * section, const char * name,
326 const char * gettext_domain,
327 const char * gettext_directory);
328
329/*
330 * Get/Set values
331 */
332
344 const bg_parameter_info_t * info,
345 const bg_parameter_value_t * value);
346
360 const bg_parameter_info_t * info,
361 const char * str);
362
374 const bg_parameter_info_t * info,
375 bg_parameter_value_t * value);
376
386 bg_cfg_section_t * subsection);
387
394
395
396/*
397 * Type specific get/set functions, which don't require
398 * an info structure
399 */
400
409 const char * name, int value);
410
419 const char * name, float value);
420
429 const char * name, const char * value);
430
439 const char * name, gavl_time_t value);
440
441/* Get parameter values, return 0 if no such entry */
442
452 const char * name, int * value);
453
463 const char * name, float * value);
464
474 const char * name, const char ** value);
475
485 const char * name, gavl_time_t * value);
486
487
488/* Apply all values found in the parameter info */
489
503 const bg_parameter_info_t * parameters,
505 void * callback_data);
506
519 const bg_parameter_info_t * infos,
521 void * callback_data);
522
537 const bg_parameter_info_t * parameters,
539 void * callback_data);
540
549 const char * name);
550
558 const bg_parameter_info_t * info);
559
560
561#endif /* __BG_CFG_REGISTRY_H_ */
bg_cfg_registry_t * bg_cfg_registry_create()
Create an empty configuration registry.
void bg_cfg_registry_destroy(bg_cfg_registry_t *reg)
Destroy configuration registry and free all associated memory.
struct bg_cfg_registry_s bg_cfg_registry_t
Configuration registry.
Definition cfg_registry.h:67
void bg_cfg_registry_load(bg_cfg_registry_t *reg, const char *filename)
Load a configuration registry from an xml- file.
bg_cfg_section_t * bg_cfg_registry_find_section(bg_cfg_registry_t *reg, const char *path)
Find a section in the registry.
void bg_cfg_registry_save(bg_cfg_registry_t *reg, const char *filename)
Save a configuration registry to an xml-file.
int bg_cfg_registry_has_section(bg_cfg_registry_t *reg, const char *name)
Check if a registry has a section.
void bg_cfg_section_2_xml(const bg_cfg_section_t *section, xmlNodePtr xml_section)
Convert a configuration section into a libxml2 node.
bg_cfg_section_t * bg_cfg_section_create_subsection_at_pos(bg_cfg_section_t *section, int pos)
Create a subsection at the specified position.
void bg_cfg_section_set_parameter(bg_cfg_section_t *section, const bg_parameter_info_t *info, const bg_parameter_value_t *value)
Store a value in the section.
bg_cfg_section_t * bg_cfg_section_create_from_parameters(const char *name, const bg_parameter_info_t *parameters)
Create a config section from a parameter array.
bg_cfg_section_t * bg_cfg_section_find_subsection_by_index(bg_cfg_section_t *section, int index)
Find a child of a section by index.
bg_cfg_section_t * bg_cfg_section_find_subsection(bg_cfg_section_t *section, const char *name)
Find a child of a section.
void bg_cfg_section_transfer(bg_cfg_section_t *src, bg_cfg_section_t *dst)
Set values in a configuration section from another section.
const char * bg_cfg_section_get_name(bg_cfg_section_t *section)
Get the name of a configuration section.
void bg_cfg_section_transfer_children(bg_cfg_section_t *src, bg_cfg_section_t *dst)
Like bg_cfg_section_transfer but acts only on the subsections.
int bg_cfg_section_get_parameter_float(bg_cfg_section_t *section, const char *name, float *value)
Get an float value from a section.
void bg_cfg_section_set_parameter_int(bg_cfg_section_t *section, const char *name, int value)
Store an integer value in a section.
int bg_cfg_section_get_parameter_time(bg_cfg_section_t *section, const char *name, gavl_time_t *value)
Get an time value from a section.
int bg_cfg_section_set_parameters_from_string(bg_cfg_section_t *section, const bg_parameter_info_t *info, const char *str)
Set values from an option string.
int bg_cfg_section_get_parameter_string(bg_cfg_section_t *section, const char *name, const char **value)
Get an string value from a section.
void bg_cfg_section_delete_subsection(bg_cfg_section_t *section, bg_cfg_section_t *subsection)
Delete a subsection.
void bg_cfg_section_get(bg_cfg_section_t *section, const bg_parameter_info_t *parameters, bg_get_parameter_func_t func, void *callback_data)
Get parameters from a module.
char * bg_cfg_section_get_name_translated(bg_cfg_section_t *section)
Get the translated name of a configuration section.
void bg_cfg_section_set_parameter_string(bg_cfg_section_t *section, const char *name, const char *value)
Store a string value in a section.
void bg_cfg_section_apply(bg_cfg_section_t *section, const bg_parameter_info_t *parameters, bg_set_parameter_func_t func, void *callback_data)
Send all parameters to a module.
void bg_cfg_section_set_parameter_float(bg_cfg_section_t *section, const char *name, float value)
Store a float value in a section.
void bg_cfg_section_dump(bg_cfg_section_t *section, const char *filename)
Dump a config section to a file.
void bg_cfg_section_create_items(bg_cfg_section_t *section, const bg_parameter_info_t *parameters)
Create items from a parameter info.
int bg_cfg_section_has_subsection(bg_cfg_section_t *section, const char *name)
Qurey if a child section is available.
void bg_cfg_section_restore_defaults(bg_cfg_section_t *section, const bg_parameter_info_t *info)
Restore default values of a section.
void bg_cfg_section_set_parameter_time(bg_cfg_section_t *section, const char *name, gavl_time_t value)
Store a time value in a section.
bg_cfg_section_t * bg_cfg_section_create(const char *name)
Create an empty config section.
void bg_cfg_xml_2_section(xmlDocPtr xml_doc, xmlNodePtr xml_section, bg_cfg_section_t *section)
Convert libxml2 node into a configuration section.
void bg_cfg_section_destroy(bg_cfg_section_t *section)
Destroy a config section.
void bg_cfg_section_move_child(bg_cfg_section_t *section, bg_cfg_section_t *child, int pos)
Move a subsection to the specified position.
bg_cfg_section_t * bg_cfg_section_copy(const bg_cfg_section_t *src)
Duplicate a configuration section.
int bg_cfg_section_get_parameter_int(bg_cfg_section_t *section, const char *name, int *value)
Get an integer value from a section.
void bg_cfg_section_set_name(bg_cfg_section_t *section, const char *name, const char *gettext_domain, const char *gettext_directory)
Set the name of a configuration section.
void bg_cfg_section_delete_subsections(bg_cfg_section_t *section)
Delete all subsections.
void bg_cfg_section_apply_noterminate(bg_cfg_section_t *section, const bg_parameter_info_t *infos, bg_set_parameter_func_t func, void *callback_data)
Send all parameters to a module without terminating.
void bg_cfg_section_get_parameter(bg_cfg_section_t *section, const bg_parameter_info_t *info, bg_parameter_value_t *value)
Read a value from the section.
struct bg_cfg_section_s bg_cfg_section_t
Configuration section.
Definition cfg_registry.h:59
void bg_cfg_section_add_ref(bg_cfg_section_t *section, bg_cfg_section_t *ref)
Insert a reference to a section as child.
void(* bg_set_parameter_func_t)(void *data, const char *name, const bg_parameter_value_t *v)
Generic prototype for setting parameters in a module.
Definition parameter.h:205
int(* bg_get_parameter_func_t)(void *data, const char *name, bg_parameter_value_t *v)
Generic prototype for getting parameters from a module.
Definition parameter.h:221
int64_t gavl_time_t
Parmeter description.
Definition parameter.h:135
Container for a parameter value.
Definition parameter.h:83