diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/configuration.cpp | 33 | ||||
-rw-r--r-- | src/configuration.h | 36 |
2 files changed, 45 insertions, 24 deletions
diff --git a/src/configuration.cpp b/src/configuration.cpp index bf9244bd5..73b590a6f 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -223,7 +223,8 @@ void ConfigurationObject::deleteKey(const std::string &key) mOptions.erase(key); } -void Configuration::setValue(const std::string &key, const std::string &value) +void Configuration::setValue(const std::string &key, + const std::string &value) { ConfigurationObject::setValue(key, value); mUpdated = true; @@ -246,7 +247,8 @@ void Configuration::incValue(const std::string &key) ? atoi(iter->second.c_str()) + 1 : 1); } -void Configuration::setSilent(const std::string &key, const std::string &value) +void Configuration::setSilent(const std::string &key, + const std::string &value) { ConfigurationObject::setValue(key, value); } @@ -365,7 +367,8 @@ void Configuration::cleanDefaults() if (mDefaultsData) { for (DefaultsData::const_iterator iter = mDefaultsData->begin(); - iter != mDefaultsData->end(); ++iter) + iter != mDefaultsData->end(); + ++iter) { delete (iter->second); } @@ -485,7 +488,8 @@ std::string Configuration::getStringValue(const std::string &key) const const DefaultsData::const_iterator itdef = mDefaultsData->find(key); - if (itdef != mDefaultsData->end() && itdef->second) + if (itdef != mDefaultsData->end() && + itdef->second) { const VariableData *const data = itdef->second; const VariableData::DataType type = static_cast<const @@ -535,7 +539,8 @@ float Configuration::getFloatValue(const std::string &key) const const DefaultsData::const_iterator itdef = mDefaultsData->find(key); - if (itdef != mDefaultsData->end() && itdef->second) + if (itdef != mDefaultsData->end() && + itdef->second) { const VariableData *const data = itdef->second; const VariableData::DataType type = static_cast< @@ -591,7 +596,8 @@ bool Configuration::getBoolValue(const std::string &key) const const DefaultsData::const_iterator itdef = mDefaultsData->find(key); - if (itdef != mDefaultsData->end() && itdef->second) + if (itdef != mDefaultsData->end() && + itdef->second) { const VariableData *const data = itdef->second; const VariableData::DataType type = static_cast< @@ -657,8 +663,9 @@ bool Configuration::resetBoolValue(const std::string &key) const DefaultsData::const_iterator itdef = mDefaultsData->find(key); const VariableData *const data = itdef->second; - if (itdef != mDefaultsData->end() && data - && data->getType() == VariableData::DATA_BOOL) + if (itdef != mDefaultsData->end() && + data && + data->getType() == VariableData::DATA_BOOL) { defaultValue = (static_cast<const BoolData*>(data))->getData(); } @@ -691,8 +698,8 @@ void ConfigurationObject::initFromXML(const XmlNodePtrConst parentNode) for_each_xml_child_node(subnode, node) { - if (xmlNameEqual(subnode, name.c_str()) - && subnode->type == XML_ELEMENT_NODE) + if (xmlNameEqual(subnode, name.c_str()) && + subnode->type == XML_ELEMENT_NODE) { ConfigurationObject *const cobj = new ConfigurationObject; cobj->initFromXML(subnode); // recurse @@ -906,9 +913,9 @@ void Configuration::removeListeners(ConfigListener *const listener) void Configuration::removeOldKeys() { - if (mOptions.find(unusedKeys[0]) != mOptions.end() - || mOptions.find(unusedKeys[1]) != mOptions.end() - || mOptions.find(unusedKeys[2]) != mOptions.end()) + if (mOptions.find(unusedKeys[0]) != mOptions.end() || + mOptions.find(unusedKeys[1]) != mOptions.end() || + mOptions.find(unusedKeys[2]) != mOptions.end()) { int f = 0; while (unusedKeys[f] != "") diff --git a/src/configuration.h b/src/configuration.h index 53b836795..d2e88d86b 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -185,7 +185,8 @@ class ConfigurationObject notfinal return container; for (ConfigurationList::const_iterator it = list->begin(); - it != list->end(); ++ it) + it != list->end(); + ++ it) { container = manager->readConfigItem(*it, container); } @@ -291,33 +292,43 @@ class Configuration final : public ConfigurationObject void incValue(const std::string &key); - void setSilent(const std::string &key, const std::string &value); + void setSilent(const std::string &key, + const std::string &value); - inline void setValue(const std::string &key, const char *const value) + inline void setValue(const std::string &key, + const char *const value) { if (value) setValue(key, std::string(value)); } - inline void setSilent(const std::string &key, const char *const value) + inline void setSilent(const std::string &key, + const char *const value) { if (value) setSilent(key, std::string(value)); } - inline void setValue(const std::string &key, const float value) + inline void setValue(const std::string &key, + const float value) { setValue(key, toString(value)); } - inline void setValue(const std::string &key, const double value) + inline void setValue(const std::string &key, + const double value) { setValue(key, toString(value)); } - inline void setValue(const std::string &key, const int value) + inline void setValue(const std::string &key, + const int value) { setValue(key, toString(value)); } - inline void setValueInt(const std::string &key, const int value) + inline void setValueInt(const std::string &key, + const int value) { setValue(key, toString(value)); } - inline void setValue(const std::string &key, const unsigned value) + inline void setValue(const std::string &key, + const unsigned value) { setValue(key, toString(value)); } - inline void setValue(const std::string &key, const bool value) + inline void setValue(const std::string &key, + const bool value) { setValue(key, value ? "1" : "0"); } - inline void setSilent(const std::string &key, const bool value) + inline void setSilent(const std::string &key, + const bool value) { setSilent(key, value ? "1" : "0"); } int resetIntValue(const std::string &key); @@ -333,8 +344,11 @@ class Configuration final : public ConfigurationObject * @see defaults.h */ int getIntValue(const std::string &key) const A_WARN_UNUSED; + float getFloatValue(const std::string &key) const A_WARN_UNUSED; + std::string getStringValue(const std::string &key) const A_WARN_UNUSED; + bool getBoolValue(const std::string &key) const A_WARN_UNUSED; std::string getDirectory() const A_WARN_UNUSED |