From: arjen Date: Fri, 4 May 2007 14:01:22 +0000 (+0000) Subject: Added new arguments to configuration::find_parameter() to allow for a list of X-Git-Tag: AXE_0_4~1 X-Git-Url: http://www.andromeda.nl/gitweb/?p=AXE.git;a=commitdiff_plain;h=bc014628c407db99abf7e0461aa0e961493726aa Added new arguments to configuration::find_parameter() to allow for a list of sections and a list of parameters in sections. The new arguments are section index and parameter index (default = 0). --- diff --git a/src/configuration.cpp b/src/configuration.cpp index 9f2eda8..18046b4 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -6,7 +6,7 @@ *********************** ** FILE NAME : configuration.cpp ** SYSTEM NAME : AXE - Andromeda X-windows Encapsulation -** VERSION NUMBER : $Revision: 1.5 $ +** VERSION NUMBER : $Revision: 1.6 $ ** ** DESCRIPTION : Implementation of configuration class ** @@ -18,13 +18,18 @@ ******************************** ** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl ** CREATION DATE : Jul 23, 2002 -** LAST UPDATE : Nov 22, 2002 +** LAST UPDATE : Apr 13, 2007 ** MODIFICATIONS : **************************************************************************/ /***************************** $Log: configuration.cpp,v $ - Revision 1.5 2003-03-29 07:19:37 arjen + Revision 1.6 2007-05-04 14:01:22 arjen + Added new arguments to configuration::find_parameter() to allow for a list of + sections and a list of parameters in sections. + The new arguments are section index and parameter index (default = 0). + + Revision 1.5 2003/03/29 07:19:37 arjen Bugfix: Do not read the config file in the home directory if the HOME environment variable doesn't exist @@ -45,7 +50,7 @@ *****************************/ -static const char *RCSID = "$Id: configuration.cpp,v 1.5 2003-03-29 07:19:37 arjen Exp $"; +static const char *RCSID = "$Id: configuration.cpp,v 1.6 2007-05-04 14:01:22 arjen Exp $"; #include #include @@ -146,11 +151,11 @@ bool configuration::read(const String name) ** VARS CHANGED : ** FUNCTIONS USED : ** SEE ALSO : -** LAST MODIFIED : Jul 24, 2002 +** LAST MODIFIED : Apr 13, 2007 **========================================================================= */ -xmlNodePtr configuration::xmlFindTag(xmlNodePtr node, const String tag) +xmlNodePtr configuration::xmlFindTag(xmlNodePtr node, const String tag, int n) { xmlNodePtr element = NULL; @@ -158,7 +163,11 @@ xmlNodePtr configuration::xmlFindTag(xmlNodePtr node, const String tag) { if (node->type == XML_ELEMENT_NODE && tag == (char *)node->name) { - element = node; + if (n == 0) + { + element = node; + } + n--; } node = node->next; } @@ -178,11 +187,11 @@ xmlNodePtr configuration::xmlFindTag(xmlNodePtr node, const String tag) ** VARS CHANGED : ** FUNCTIONS USED : ** SEE ALSO : -** LAST MODIFIED : Nov 02, 2002 +** LAST MODIFIED : Apr 13, 2007 **========================================================================= */ -String configuration::find_parameter(const String section, const String parameter) +String configuration::find_parameter(const String section, const String parameter, int sec_n, int param_n) { xmlNodePtr root_node; xmlNodePtr section_node; @@ -195,10 +204,10 @@ String configuration::find_parameter(const String section, const String paramete if (system) { root_node = xmlDocGetRootElement(system); - section_node = xmlFindTag(root_node->children, section); + section_node = xmlFindTag(root_node->children, section, sec_n); if (section_node != NULL) { - param_node = xmlFindTag(section_node->children, parameter); + param_node = xmlFindTag(section_node->children, parameter, param_n); if (param_node != NULL) { param_node = param_node->children; @@ -216,10 +225,10 @@ String configuration::find_parameter(const String section, const String paramete if (user) { root_node = xmlDocGetRootElement(user); - section_node = xmlFindTag(root_node->children, section); + section_node = xmlFindTag(root_node->children, section, sec_n); if (section_node != NULL) { - param_node = xmlFindTag(section_node->children, parameter); + param_node = xmlFindTag(section_node->children, parameter, param_n); if (param_node != NULL) { param_node = param_node->children; diff --git a/src/configuration.h b/src/configuration.h index 9c59c87..fd584ec 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -5,7 +5,7 @@ *********************** ** FILE NAME : configuration.h ** SYSTEM NAME : AXE - Andromeda X-windows Encapsulation -** VERSION NUMBER : $Revision: 1.3 $ +** VERSION NUMBER : $Revision: 1.4 $ ** ** DESCRIPTION : Definition of configuration class ** @@ -23,7 +23,12 @@ /***************************** $Log: configuration.h,v $ - Revision 1.3 2002-11-02 14:35:15 arjen + Revision 1.4 2007-05-04 14:01:22 arjen + Added new arguments to configuration::find_parameter() to allow for a list of + sections and a list of parameters in sections. + The new arguments are section index and parameter index (default = 0). + + Revision 1.3 2002/11/02 14:35:15 arjen Uses the XML2 library BugFix: segfault when finding a parameters that is not in the user-sepcific config tree. @@ -36,7 +41,7 @@ *****************************/ -/* static const char *RCSID = "$Id: configuration.h,v 1.3 2002-11-02 14:35:15 arjen Exp $"; */ +/* static const char *RCSID = "$Id: configuration.h,v 1.4 2007-05-04 14:01:22 arjen Exp $"; */ #ifndef CONFIGURATION_H #define CONFIGURATION_H @@ -67,7 +72,7 @@ // // RELATIONS : // SEE ALSO : -// LAST MODIFIED : Jul 24, 2002 +// LAST MODIFIED : Apr 13, 2007 /////////////////////////////////////////////////////////////////////////// */ @@ -78,7 +83,7 @@ class configuration xmlDocPtr user; // User-specific config tree String app_name; // Name of the application and XML root element - xmlNodePtr xmlFindTag(xmlNodePtr, const String); + xmlNodePtr xmlFindTag(xmlNodePtr, const String, int n = 0); public: @@ -95,7 +100,7 @@ public: // Return the value of a config parameter - String find_parameter(const String section, const String parameter); + String find_parameter(const String section, const String parameter, int sec_n = 0, int param_n = 0); }; diff --git a/src/xappl.h b/src/xappl.h index 189b71e..5bb95ae 100644 --- a/src/xappl.h +++ b/src/xappl.h @@ -5,7 +5,7 @@ *********************** ** FILE NAME : xappl.h ** SYSTEM NAME : AXE - Andromeda X-windows Encapsulation -** VERSION NUMBER : $Revision: 1.1 $ +** VERSION NUMBER : $Revision: 1.2 $ ** ** DESCRIPTION : Definition of xapplication class ** @@ -23,12 +23,17 @@ /***************************** $Log: xappl.h,v $ - Revision 1.1 2002-07-25 08:01:27 arjen + Revision 1.2 2007-05-04 14:01:22 arjen + Added new arguments to configuration::find_parameter() to allow for a list of + sections and a list of parameters in sections. + The new arguments are section index and parameter index (default = 0). + + Revision 1.1 2002/07/25 08:01:27 arjen First checkin, AXE release 0.2 *****************************/ -/* static const char *RCSID = "$Id: xappl.h,v 1.1 2002-07-25 08:01:27 arjen Exp $"; */ +/* static const char *RCSID = "$Id: xappl.h,v 1.2 2007-05-04 14:01:22 arjen Exp $"; */ #ifndef XAPPL_H #define XAPPL_H @@ -118,7 +123,7 @@ public: { tabsize = 100; - table = new (xw_list *)[tabsize]; + table = new xw_list * [tabsize]; for (unsigned i=0; i < tabsize; i++) { table[i] = 0; @@ -129,7 +134,7 @@ public: { tabsize = size; - table = new (xw_list *)[size]; + table = new xw_list * [size]; for (unsigned i=0; i < tabsize; i++) { table[i] = 0;