summaryrefslogtreecommitdiff
path: root/src/common/configuration.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-09-08 22:43:00 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-09-08 22:43:00 +0200
commitd6d215e2ab53322c769792b4aa53396ecce96422 (patch)
treeca1f73f1156f7a3eeccf2430a00d7bcdbd39d149 /src/common/configuration.cpp
parentde803e103f5317856d4eadf15661ef7516cfc72a (diff)
downloadmanaserv-d6d215e2ab53322c769792b4aa53396ecce96422.tar.gz
manaserv-d6d215e2ab53322c769792b4aa53396ecce96422.tar.bz2
manaserv-d6d215e2ab53322c769792b4aa53396ecce96422.tar.xz
manaserv-d6d215e2ab53322c769792b4aa53396ecce96422.zip
Centralized stringToBool conversion.
Also moved the trim() function into the utils namespace where it belongs more, and made some random code cleanups. Reviewed-by: Thorbjorn.
Diffstat (limited to 'src/common/configuration.cpp')
-rw-r--r--src/common/configuration.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/common/configuration.cpp b/src/common/configuration.cpp
index 0f0a5844..a0e2ab2e 100644
--- a/src/common/configuration.cpp
+++ b/src/common/configuration.cpp
@@ -27,6 +27,7 @@
#include "utils/logger.h"
#include "utils/xml.hpp"
+#include "utils/string.hpp"
/**< Persistent configuration. */
static std::map< std::string, std::string > options;
@@ -78,13 +79,23 @@ std::string Configuration::getValue(const std::string &key,
const std::string &deflt)
{
std::map<std::string, std::string>::iterator iter = options.find(key);
- if (iter == options.end()) return deflt;
+ if (iter == options.end())
+ return deflt;
return iter->second;
}
int Configuration::getValue(const std::string &key, int deflt)
{
std::map<std::string, std::string>::iterator iter = options.find(key);
- if (iter == options.end()) return deflt;
+ if (iter == options.end())
+ return deflt;
return atoi(iter->second.c_str());
}
+
+bool Configuration::getBoolValue(const std::string &key, bool deflt)
+{
+ std::map<std::string, std::string>::iterator iter = options.find(key);
+ if (iter == options.end())
+ return deflt;
+ return utils::stringToBool(iter->second.c_str(), deflt);
+}