summaryrefslogtreecommitdiff
path: root/src/configuration.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-02 12:55:32 +0000
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-02 12:55:32 +0000
commit5efaa5125fe92a5438b3cc2949f4d720bced5a7a (patch)
tree87f4da1382fb6179610182ca3e502e5365e66276 /src/configuration.cpp
parent2e60491ceb0548b0bea93207c13b974d6a6cf5cc (diff)
downloadmana-5efaa5125fe92a5438b3cc2949f4d720bced5a7a.tar.gz
mana-5efaa5125fe92a5438b3cc2949f4d720bced5a7a.tar.bz2
mana-5efaa5125fe92a5438b3cc2949f4d720bced5a7a.tar.xz
mana-5efaa5125fe92a5438b3cc2949f4d720bced5a7a.zip
General code cleanups
* Don't needlessly store or return raw pointers in BeingInfo * Less copying, more moving * Less else after return * Make AddDEF a template instead of a macro * Removed some unused includes * Use range-based for loops
Diffstat (limited to 'src/configuration.cpp')
-rw-r--r--src/configuration.cpp30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/configuration.cpp b/src/configuration.cpp
index f7718bdc..ca1f4438 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -128,19 +128,19 @@ VariableData* Configuration::getDefault(const std::string &key,
{
if (mDefaultsData)
{
- DefaultsData::const_iterator itdef = mDefaultsData->find(key);
+ auto itdef = mDefaultsData->find(key);
if (itdef != mDefaultsData->end() && itdef->second
&& itdef->second->getType() == type)
{
return itdef->second;
}
- else
- {
- logger->log("%s: No value in registry for key %s",
- mConfigPath.c_str(), key.c_str());
- }
+
+ logger->log("%s: No value in registry for key %s",
+ mConfigPath.c_str(),
+ key.c_str());
}
+
return nullptr;
}
@@ -158,6 +158,7 @@ int Configuration::getIntValue(const std::string &key) const
{
defaultValue = atoi(iter->second.c_str());
}
+
return defaultValue;
}
@@ -167,16 +168,14 @@ std::string Configuration::getStringValue(const std::string &key) const
auto iter = mOptions.find(key);
if (iter == mOptions.end())
{
- VariableData* vd = getDefault(key,
- VariableData::DATA_STRING);
-
- if (vd)
+ if (VariableData *vd = getDefault(key, VariableData::DATA_STRING))
defaultValue = ((StringData*)vd)->getData();
}
else
{
defaultValue = iter->second;
}
+
return defaultValue;
}
@@ -187,16 +186,14 @@ float Configuration::getFloatValue(const std::string &key) const
auto iter = mOptions.find(key);
if (iter == mOptions.end())
{
- VariableData* vd = getDefault(key,
- VariableData::DATA_FLOAT);
-
- if (vd)
+ if (VariableData *vd = getDefault(key, VariableData::DATA_FLOAT))
defaultValue = ((FloatData*)vd)->getData();
}
else
{
defaultValue = atof(iter->second.c_str());
}
+
return defaultValue;
}
@@ -206,10 +203,7 @@ bool Configuration::getBoolValue(const std::string &key) const
auto iter = mOptions.find(key);
if (iter == mOptions.end())
{
- VariableData* vd = getDefault(key,
- VariableData::DATA_BOOL);
-
- if (vd)
+ if (VariableData *vd = getDefault(key, VariableData::DATA_BOOL))
defaultValue = ((BoolData*)vd)->getData();
}
else