summaryrefslogtreecommitdiffstats
path: root/src/Utilities.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Utilities.cpp')
-rw-r--r--src/Utilities.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Utilities.cpp b/src/Utilities.cpp
index 6346a49..dc654ea 100644
--- a/src/Utilities.cpp
+++ b/src/Utilities.cpp
@@ -44,7 +44,17 @@ int stringToInt(const std::string& s)
if (iss.fail() || !iss.eof())
throw bad_cast();
return i;
+}
+int stringToInt(const std::string& s, int fallback)
+{
+ int i;
+ std::istringstream iss(s);
+ iss.imbue(std::locale::classic());
+ iss >> i;
+ if (iss.fail() || !iss.eof())
+ return fallback;
+ return i;
}
float stringToFloat(const std::string& s)