00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 template<typename T> inline
00024 T ParameterMap::GetValue(const std::string &name) const {
00025 return sheep::StringUtils::FromString<T>(Find(name));
00026 }
00027
00028 template<> inline
00029 std::string ParameterMap::GetValue<std::string>(const std::string &name) const
00030 throw(InvalidKeyException, sheep::StringUtils::ConversionErrorException)
00031 {
00032 return Find(name);
00033 }
00034
00035 template<> inline
00036 bool ParameterMap::GetValue<bool>(const std::string &name) const
00037 throw(InvalidKeyException, sheep::StringUtils::ConversionErrorException)
00038 {
00039 const std::string value = Find(name);
00040
00041 if(!sheep::StringUtils::CompareNoCase(value, "true"))
00042 return true;
00043 else if(!sheep::StringUtils::CompareNoCase(value, "false"))
00044 return false;
00045 else throw sheep::StringUtils::ConversionErrorException();
00046 }
00047
00048 template<typename T> inline
00049 T ParameterMap::GetOptionalValue(const std::string &name, const T &default_value) const {
00050 try {
00051 return GetValue<T>(name);
00052 }
00053 catch(InvalidKeyException) {
00054 return default_value;
00055 }
00056 }