cfg_registry.h

00001 /*****************************************************************
00002  * gmerlin - a general purpose multimedia framework and applications
00003  *
00004  * Copyright (c) 2001 - 2008 Members of the Gmerlin project
00005  * gmerlin-general@lists.sourceforge.net
00006  * http://gmerlin.sourceforge.net
00007  *
00008  * This program is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation, either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00020  * *****************************************************************/
00021 
00022 #ifndef __BG_CFG_REGISTRY_H_
00023 #define __BG_CFG_REGISTRY_H_
00024 
00025 #include <gmerlin/parameter.h>
00026 
00059 typedef struct bg_cfg_section_s  bg_cfg_section_t;
00060 
00067 typedef struct bg_cfg_registry_s bg_cfg_registry_t;
00068 
00076 bg_cfg_registry_t * bg_cfg_registry_create();
00077 
00083 void bg_cfg_registry_destroy(bg_cfg_registry_t * reg);
00084 
00085 /* cfg_xml.c */
00086 
00093 void bg_cfg_registry_load(bg_cfg_registry_t * reg, const char * filename);
00094 
00101 void bg_cfg_registry_save(bg_cfg_registry_t * reg, const char * filename);
00102 
00103 /* The name and xml tag of the section must be set before */
00104 
00113 void bg_cfg_section_2_xml(bg_cfg_section_t * section, xmlNodePtr xml_section);
00114 
00124 void bg_cfg_xml_2_section(xmlDocPtr xml_doc, xmlNodePtr xml_section,
00125                           bg_cfg_section_t * section);
00126 
00127 /*
00128  *  Path looks like "section:subsection:subsubsection"
00129  */
00130 
00142 bg_cfg_section_t * bg_cfg_registry_find_section(bg_cfg_registry_t * reg,
00143                                                 const char * path);
00144 
00154 bg_cfg_section_t * bg_cfg_section_find_subsection(bg_cfg_section_t * section,
00155                                                   const char * name);
00156 
00164 bg_cfg_section_t * bg_cfg_section_create_subsection_at_pos(bg_cfg_section_t * section,
00165                                                            int pos);
00166 
00174 void bg_cfg_section_move_child(bg_cfg_section_t * section, bg_cfg_section_t * child,
00175                                int pos);
00176 
00177 
00187 bg_cfg_section_t * bg_cfg_section_find_subsection_by_index(bg_cfg_section_t * section,
00188                                                            int index);
00189 
00190 
00191 /* 
00192  *  Create/destroy config sections
00193  */
00194 
00201 bg_cfg_section_t * bg_cfg_section_create(const char * name);
00202 
00214 bg_cfg_section_t *
00215 bg_cfg_section_create_from_parameters(const char * name,
00216                                       const bg_parameter_info_t * parameters);
00217 
00228 void bg_cfg_section_create_items(bg_cfg_section_t * section,
00229                                  const bg_parameter_info_t * parameters);
00230 
00236 void bg_cfg_section_destroy(bg_cfg_section_t * section);
00237 
00244 bg_cfg_section_t * bg_cfg_section_copy(const bg_cfg_section_t * src);
00245 
00253 void bg_cfg_section_restore(bg_cfg_section_t * section, bg_cfg_section_t * section_saved);
00254 
00265 void bg_cfg_section_transfer(bg_cfg_section_t * src, bg_cfg_section_t * dst);
00266 
00267 /*
00268  *  Get/Set section names
00269  */
00270 
00277 const char * bg_cfg_section_get_name(bg_cfg_section_t * section);
00278 
00287 char * bg_cfg_section_get_name_translated(bg_cfg_section_t * section);
00288 
00297 void bg_cfg_section_set_name(bg_cfg_section_t * section, const char * name,
00298                              const char * gettext_domain,
00299                              const char * gettext_directory);
00300 
00301 /*
00302  *  Get/Set values
00303  */
00304 
00315 void bg_cfg_section_set_parameter(bg_cfg_section_t * section,
00316                                   const bg_parameter_info_t * info,
00317                                   const bg_parameter_value_t * value);
00318 
00331 int bg_cfg_section_set_parameters_from_string(bg_cfg_section_t * section,
00332                                               const bg_parameter_info_t * info,
00333                                               const char * str);
00334 
00345 void bg_cfg_section_get_parameter(bg_cfg_section_t * section,
00346                                   const bg_parameter_info_t * info,
00347                                   bg_parameter_value_t * value);
00348 
00357 void bg_cfg_section_delete_subsection(bg_cfg_section_t * section,
00358                                       bg_cfg_section_t * subsection);
00359 
00360 
00361 /*
00362  *  Type specific get/set functions, which don't require
00363  *  an info structure
00364  */
00365 
00373 void bg_cfg_section_set_parameter_int(bg_cfg_section_t * section,
00374                                       const char * name, int value);
00375 
00383 void bg_cfg_section_set_parameter_float(bg_cfg_section_t * section,
00384                                         const char * name, float value);
00385 
00393 void bg_cfg_section_set_parameter_string(bg_cfg_section_t * section,
00394                                          const char * name, const char * value);
00395 
00403 void bg_cfg_section_set_parameter_time(bg_cfg_section_t * section,
00404                                        const char * name, gavl_time_t value);
00405 
00406 /* Get parameter values, return 0 if no such entry */
00407 
00416 int bg_cfg_section_get_parameter_int(bg_cfg_section_t * section,
00417                                       const char * name, int * value);
00418 
00427 int bg_cfg_section_get_parameter_float(bg_cfg_section_t * section,
00428                                        const char * name, float * value);
00429 
00438 int bg_cfg_section_get_parameter_string(bg_cfg_section_t * section,
00439                                         const char * name, const char ** value);
00440 
00449 int bg_cfg_section_get_parameter_time(bg_cfg_section_t * section,
00450                                       const char * name, gavl_time_t * value);
00451 
00452 
00453 /* Apply all values found in the parameter info */
00454 
00467 void bg_cfg_section_apply(bg_cfg_section_t * section,
00468                           const bg_parameter_info_t * parameters,
00469                           bg_set_parameter_func_t func,
00470                           void * callback_data);
00471 
00483 void bg_cfg_section_apply_noterminate(bg_cfg_section_t * section,
00484                                       const bg_parameter_info_t * infos,
00485                                       bg_set_parameter_func_t func,
00486                                       void * callback_data);
00487 
00501 void bg_cfg_section_get(bg_cfg_section_t * section,
00502                         const bg_parameter_info_t * parameters,
00503                         bg_get_parameter_func_t func,
00504                         void * callback_data);
00505 
00513 int bg_cfg_section_has_subsection(bg_cfg_section_t * section,
00514                                   const char * name);
00515 
00516 #endif /* __BG_CFG_REGISTRY_H_ */
Generated on Sat Apr 24 15:29:52 2010 for gmerlin by  doxygen 1.6.3