aboutsummaryrefslogtreecommitdiff
path: root/src/shared/Config/Config.cpp
diff options
context:
space:
mode:
authorXTZGZoReX <none@none>2009-03-18 20:46:39 +0100
committerXTZGZoReX <none@none>2009-03-18 20:46:39 +0100
commit5184783bd165bec038273fa5cfbc593716856fc2 (patch)
treeb9d15444d71ffddeb3f8e5341a05fcec06fca2c2 /src/shared/Config/Config.cpp
parent5f2e9f1ed190b3108a55efe809463c0b1ed401bd (diff)
* Fixed/improved the config library: Removed useless methods and fixed the existing.
* Few related changes to make the rest of the core reflect the changes. --HG-- branch : trunk
Diffstat (limited to 'src/shared/Config/Config.cpp')
-rw-r--r--src/shared/Config/Config.cpp114
1 files changed, 22 insertions, 92 deletions
diff --git a/src/shared/Config/Config.cpp b/src/shared/Config/Config.cpp
index 52fca953f64..b56b804b50a 100644
--- a/src/shared/Config/Config.cpp
+++ b/src/shared/Config/Config.cpp
@@ -60,118 +60,48 @@ bool Config::Reload()
return true;
}
-bool Config::GetString(const char* name, std::string *value)
-{
- if(!mConf)
- return false;
-
- DOTCONFDocumentNode const *node = mConf->findNode(name);
- if(!node || !node->getValue())
- return false;
-
- *value = node->getValue();
-
- return true;
-}
-
-bool Config::GetString(const char* name, char const **value)
-{
- if(!mConf)
- return false;
-
- DOTCONFDocumentNode const *node = mConf->findNode(name);
- if(!node || !node->getValue())
- return false;
-
- *value = node->getValue();
-
- return true;
-}
-
-
-std::string Config::GetStringDefault(const char* name, const char* def)
+std::string Config::GetStringDefault(const char * name, std::string def)
{
if(!mConf)
return std::string(def);
-
- DOTCONFDocumentNode const *node = mConf->findNode(name);
+ const DOTCONFDocumentNode * node = mConf->findNode(name);
if(!node || !node->getValue())
return std::string(def);
-
return std::string(node->getValue());
-}
-
+};
-bool Config::GetBool(const char* name, bool *value)
+bool Config::GetBoolDefault(const char * name, const bool def)
{
if(!mConf)
return false;
-
- DOTCONFDocumentNode const *node = mConf->findNode(name);
+ const DOTCONFDocumentNode * node = mConf->findNode(name);
if(!node || !node->getValue())
- return false;
-
- const char* str = node->getValue();
+ return def;
+ const char * str = node->getValue();
if(strcmp(str, "true") == 0 || strcmp(str, "TRUE") == 0 ||
strcmp(str, "yes") == 0 || strcmp(str, "YES") == 0 ||
strcmp(str, "1") == 0)
- {
- *value = true;
- }
+ return true;
else
- *value = false;
-
- return true;
-}
-
-
-bool Config::GetBoolDefault(const char* name, const bool def)
-{
- bool val;
- return GetBool(name, &val) ? val : def;
-}
-
+ return false;
+};
-bool Config::GetInt(const char* name, int *value)
+int32 Config::GetIntDefault(const char * name, const int32 def)
{
if(!mConf)
- return false;
-
- DOTCONFDocumentNode const *node = mConf->findNode(name);
+ return def;
+ const DOTCONFDocumentNode * node = mConf->findNode(name);
if(!node || !node->getValue())
- return false;
-
- *value = atoi(node->getValue());
-
- return true;
-}
-
+ return def;
+ return atoi(node->getValue());
+};
-bool Config::GetFloat(const char* name, float *value)
+float Config::GetFloatDefault(const char * name, const float def)
{
if(!mConf)
- return false;
-
- DOTCONFDocumentNode const *node = mConf->findNode(name);
+ return def;
+ const DOTCONFDocumentNode * node = mConf->findNode(name);
if(!node || !node->getValue())
- return false;
-
- *value = atof(node->getValue());
-
- return true;
-}
-
-
-int Config::GetIntDefault(const char* name, const int def)
-{
- int val;
- return GetInt(name, &val) ? val : def;
-}
-
-
-float Config::GetFloatDefault(const char* name, const float def)
-{
- float val;
- return (GetFloat(name, &val) ? val : def);
-}
-
+ return def;
+ return atof(node->getValue());
+};