[config] Added default values when the logger settings are not found
This commit is contained in:
@@ -49,26 +49,50 @@ ConfigReader::setFile(boost::filesystem::path p)
|
||||
}
|
||||
|
||||
std::string
|
||||
ConfigReader::getString(std::string setting)
|
||||
ConfigReader::getString(std::string setting, std::string def)
|
||||
{
|
||||
return _config->lookup(setting);
|
||||
try {
|
||||
return _config->lookup(setting);
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long
|
||||
ConfigReader::getULong(std::string setting)
|
||||
ConfigReader::getULong(std::string setting, unsigned long def)
|
||||
{
|
||||
return static_cast<unsigned int>(_config->lookup(setting));
|
||||
try {
|
||||
return static_cast<unsigned int>(_config->lookup(setting));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
long
|
||||
ConfigReader::getLong(std::string setting)
|
||||
ConfigReader::getLong(std::string setting, long def)
|
||||
{
|
||||
return _config->lookup(setting);
|
||||
try {
|
||||
return _config->lookup(setting);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
ConfigReader::getBool(std::string setting)
|
||||
ConfigReader::getBool(std::string setting, bool def)
|
||||
{
|
||||
return _config->lookup(setting);
|
||||
try {
|
||||
return _config->lookup(setting);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,10 +34,11 @@ class ConfigReader
|
||||
|
||||
void setFile(boost::filesystem::path p);
|
||||
|
||||
std::string getString(std::string setting);
|
||||
unsigned long getULong(std::string setting);
|
||||
long getLong(std::string setting);
|
||||
bool getBool(std::string setting);
|
||||
/* Default values are returned in case of setting not found */
|
||||
std::string getString(std::string setting, std::string def = "");
|
||||
unsigned long getULong(std::string setting, unsigned long def = 0);
|
||||
long getLong(std::string setting, long def = 0);
|
||||
bool getBool(std::string setting, bool def = false);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user