aboutsummaryrefslogtreecommitdiff
path: root/src/server/shared/Configuration/Config.cpp
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2014-07-03 15:08:10 -0500
committerSubv <subv2112@gmail.com>2014-07-03 15:08:35 -0500
commit0a07fd5fc38f5b3beac187de88dcd26cb60d9f76 (patch)
treeca4513aa0c002e8cc135d93ec322c85c1c69868c /src/server/shared/Configuration/Config.cpp
parent25debd75777fef2cd3e3903eba814ee882e19a68 (diff)
Some changes here and there in shared
Diffstat (limited to 'src/server/shared/Configuration/Config.cpp')
-rw-r--r--src/server/shared/Configuration/Config.cpp17
1 files changed, 6 insertions, 11 deletions
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<std::string>(ptree::path_type(name,'/'), def);
+ std::string value = _config.get<std::string>(ptree::path_type(name, '/'), def);
value.erase(std::remove(value.begin(), value.end(), '"'), value.end());
@@ -104,12 +103,8 @@ std::list<std::string> ConfigMgr::GetKeysByString(std::string const& name)
std::list<std::string> keys;
for (const ptree::value_type& child : _config)
- {
if (child.first.compare(0, name.length(), name) == 0)
- {
keys.push_back(child.first);
- }
- }
return keys;
}