allow tilde expansion for section names in config file

This commit is contained in:
dockes
2005-11-17 12:47:03 +00:00
parent 22e229fdca
commit 511e513543
7 changed files with 74 additions and 39 deletions
+25 -1
View File
@@ -1,7 +1,8 @@
#ifndef lint
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.10 2005-11-05 14:40:50 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.11 2005-11-17 12:47:03 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
#include <unistd.h>
#include <errno.h>
#include <iostream>
@@ -80,6 +81,29 @@ RclConfig::RclConfig()
return;
}
bool RclConfig::getConfParam(const std::string &name, int *ivp)
{
string value;
if (!getConfParam(name, value))
return false;
errno = 0;
long lval = strtol(value.c_str(), 0, 0);
if (lval == 0 && errno)
return 0;
if (ivp)
*ivp = int(lval);
return true;
}
bool RclConfig::getConfParam(const std::string &name, bool *value)
{
int ival;
if (!getConfParam(name, &ival))
return false;
if (*value)
*value = ival ? true : false;
return true;
}
static ConfSimple::WalkerCode mtypesWalker(void *l,
const char *nm, const char *value)
{
+8 -1
View File
@@ -1,6 +1,6 @@
#ifndef _RCLCONFIG_H_INCLUDED_
#define _RCLCONFIG_H_INCLUDED_
/* @(#$Id: rclconfig.h,v 1.6 2005-11-05 14:40:50 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: rclconfig.h,v 1.7 2005-11-17 12:47:03 dockes Exp $ (C) 2004 J.F.Dockes */
#include <list>
@@ -38,6 +38,13 @@ class RclConfig {
return false;
return conf->get(name, value, keydir);
}
/*
* Variants with autoconversion
*/
bool getConfParam(const std::string &name, int *value);
bool getConfParam(const std::string &name, bool *value);
/// Set current directory reference, and fetch automatic parameters.
void setKeyDir(const string &dir)
{