From 0a07fd5fc38f5b3beac187de88dcd26cb60d9f76 Mon Sep 17 00:00:00 2001 From: Subv Date: Thu, 3 Jul 2014 15:08:10 -0500 Subject: Some changes here and there in shared --- src/server/shared/Configuration/Config.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src/server/shared/Configuration/Config.cpp') diff --git a/src/server/shared/Configuration/Config.cpp b/src/server/shared/Configuration/Config.cpp index b6690d02155..aea9d4c1366 100644 --- a/src/server/shared/Configuration/Config.cpp +++ b/src/server/shared/Configuration/Config.cpp @@ -38,12 +38,11 @@ bool ConfigMgr::LoadInitial(char const* file) ptree fullTree; boost::property_tree::ini_parser::read_ini(file, fullTree); + if (fullTree.empty()) + return false; + // Since we're using only one section per config file, we skip the section and have direct property access - for (auto section : fullTree) - { - _config = section.second; - break; - } + _config = fullTree.begin().second; } catch (std::exception const& /*ex*/) { @@ -58,9 +57,9 @@ bool ConfigMgr::Reload() return LoadInitial(_filename.c_str()); } -std::string ConfigMgr::GetStringDefault(const char* name, const std::string &def) +std::string ConfigMgr::GetStringDefault(const char* name, const std::string& def) { - std::string value = _config.get(ptree::path_type(name,'/'), def); + std::string value = _config.get(ptree::path_type(name, '/'), def); value.erase(std::remove(value.begin(), value.end(), '"'), value.end()); @@ -104,12 +103,8 @@ std::list ConfigMgr::GetKeysByString(std::string const& name) std::list keys; for (const ptree::value_type& child : _config) - { if (child.first.compare(0, name.length(), name) == 0) - { keys.push_back(child.first); - } - } return keys; } -- cgit v1.2.3