configuration parsing fixed

This commit is contained in:
Matej Sekoranja
2011-03-08 10:54:47 +01:00
parent 92364a9756
commit 357d48a5e7

View File

@@ -195,8 +195,9 @@ SystemConfigurationImpl::SystemConfigurationImpl()
{
_envParam.name = new char[MAX_NAME_LENGHT];
_envParam.pdflt = NULL;
_ibuffer.exceptions ( ifstream::failbit | ifstream::badbit );
_obuffer.exceptions ( ifstream::failbit | ifstream::badbit );
// no exception, default value is taken
//_ibuffer.exceptions ( ifstream::failbit | ifstream::badbit );
//_obuffer.exceptions ( ifstream::failbit | ifstream::badbit );
_properties = new Properties();
}
@@ -215,7 +216,10 @@ bool SystemConfigurationImpl::getPropertyAsBoolean(const string name, const bool
_obuffer << defaultValue;
_ibuffer.str(getPropertyAsString(name,_obuffer.str()));
_ibuffer >> retval;
return retval;
if (_ibuffer.fail() || _ibuffer.bad())
return defaultValue;
else
return retval;
}
int32 SystemConfigurationImpl::getPropertyAsInteger(const string name, const int32 defaultValue)
@@ -227,7 +231,10 @@ int32 SystemConfigurationImpl::getPropertyAsInteger(const string name, const int
_obuffer << defaultValue;
_ibuffer.str(getPropertyAsString(name, _obuffer.str()));
_ibuffer >> retval;
return retval;
if (_ibuffer.fail() || _ibuffer.bad())
return defaultValue;
else
return retval;
}
float SystemConfigurationImpl::getPropertyAsFloat(const string name, const float defaultValue)
@@ -239,7 +246,10 @@ float SystemConfigurationImpl::getPropertyAsFloat(const string name, const float
_obuffer << defaultValue;
_ibuffer.str(getPropertyAsString(name, _obuffer.str()));
_ibuffer >> retval;
return retval;
if (_ibuffer.fail() || _ibuffer.bad())
return defaultValue;
else
return retval;
}
float SystemConfigurationImpl::getPropertyAsDouble(const string name, const double defaultValue)
@@ -251,7 +261,10 @@ float SystemConfigurationImpl::getPropertyAsDouble(const string name, const doub
_obuffer << defaultValue;
_ibuffer.str(getPropertyAsString(name, _obuffer.str()));
_ibuffer >> retval;
return retval;
if (_ibuffer.fail() || _ibuffer.bad())
return defaultValue;
else
return retval;
}
string SystemConfigurationImpl::getPropertyAsString(const string name, const string defaultValue)