summaryrefslogtreecommitdiff
path: root/src/settings.h
diff options
context:
space:
mode:
authorsapier <Sapier at GMX dot net>2014-02-05 01:35:40 +0100
committerkwolekr <kwolekr@minetest.net>2014-02-04 22:14:13 -0500
commit3f376a092e1c16429fb52f24736e9da98aff4cd5 (patch)
tree7055808f86884593ef2f63316d61533968112956 /src/settings.h
parent2927a327cabe4feddc0aeea0f4111d888560612f (diff)
downloadminetest-3f376a092e1c16429fb52f24736e9da98aff4cd5.tar.gz
minetest-3f376a092e1c16429fb52f24736e9da98aff4cd5.tar.bz2
minetest-3f376a092e1c16429fb52f24736e9da98aff4cd5.zip
Fix settings to honor numeric conversion errors
Rename try* non exceptioning functions to *NoEx
Diffstat (limited to 'src/settings.h')
-rw-r--r--src/settings.h42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/settings.h b/src/settings.h
index f019ce50c..11b11e635 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -745,17 +745,19 @@ fail:
}
//////////// Try to get value, no exception thrown
- bool tryGet(std::string name, std::string &val)
+ bool getNoEx(std::string name, std::string &val)
{
try {
val = get(name);
return true;
} catch (SettingNotFoundException &e) {
return false;
+ } catch (NumericException &e) {
+ return false;
}
}
- bool tryGetFlagStr(std::string name, u32 &val, FlagDesc *flagdesc)
+ bool getFlagStrNoEx(std::string name, u32 &val, FlagDesc *flagdesc)
{
try {
val = getFlagStr(name, flagdesc);
@@ -765,93 +767,111 @@ fail:
}
}
- bool tryGetFloat(std::string name, float &val)
+ bool getFloatNoEx(std::string name, float &val)
{
try {
val = getFloat(name);
return true;
} catch (SettingNotFoundException &e) {
return false;
+ } catch (NumericException &e) {
+ return false;
}
}
- bool tryGetU16(std::string name, int &val)
+ bool getU16NoEx(std::string name, int &val)
{
try {
val = getU16(name);
return true;
} catch (SettingNotFoundException &e) {
return false;
+ } catch (NumericException &e) {
+ return false;
}
}
- bool tryGetU16(std::string name, u16 &val)
+ bool getU16NoEx(std::string name, u16 &val)
{
try {
val = getU16(name);
return true;
} catch (SettingNotFoundException &e) {
return false;
+ } catch (NumericException &e) {
+ return false;
}
}
- bool tryGetS16(std::string name, int &val)
+ bool getS16NoEx(std::string name, int &val)
{
try {
val = getU16(name);
return true;
} catch (SettingNotFoundException &e) {
return false;
+ } catch (NumericException &e) {
+ return false;
}
}
- bool tryGetS16(std::string name, s16 &val)
+ bool getS16NoEx(std::string name, s16 &val)
{
try {
val = getS16(name);
return true;
} catch (SettingNotFoundException &e) {
return false;
+ } catch (NumericException &e) {
+ return false;
}
}
- bool tryGetS32(std::string name, s32 &val)
+ bool getS32NoEx(std::string name, s32 &val)
{
try {
val = getS32(name);
return true;
} catch (SettingNotFoundException &e) {
return false;
+ } catch (NumericException &e) {
+ return false;
}
}
- bool tryGetV3F(std::string name, v3f &val)
+ bool getV3FNoEx(std::string name, v3f &val)
{
try {
val = getV3F(name);
return true;
} catch (SettingNotFoundException &e) {
return false;
+ } catch (NumericException &e) {
+ return false;
}
}
- bool tryGetV2F(std::string name, v2f &val)
+ bool getV2FNoEx(std::string name, v2f &val)
{
try {
val = getV2F(name);
return true;
} catch (SettingNotFoundException &e) {
return false;
+ } catch (NumericException &e) {
+ return false;
}
}
- bool tryGetU64(std::string name, u64 &val)
+ bool getU64NoEx(std::string name, u64 &val)
{
try {
val = getU64(name);
return true;
} catch (SettingNotFoundException &e) {
return false;
+ } catch (NumericException &e) {
+ return false;
}
}