diff options
author | Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl> | 2018-12-07 16:41:40 +0100 |
---|---|---|
committer | Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl> | 2018-12-23 16:57:45 +0100 |
commit | 8220a50be6bcbddf179bb855b2f7d36436fcca6b (patch) | |
tree | 81986f22c74784ff02c88f1d071fae32186e5f89 /src/Utilities.cpp | |
parent | cbc2e1079cf40c6f0c08d2f9c54f7b41b678e567 (diff) | |
download | astra-8220a50be6bcbddf179bb855b2f7d36436fcca6b.tar.gz astra-8220a50be6bcbddf179bb855b2f7d36436fcca6b.tar.bz2 astra-8220a50be6bcbddf179bb855b2f7d36436fcca6b.tar.xz astra-8220a50be6bcbddf179bb855b2f7d36436fcca6b.zip |
More gracefully handle config errors in geometries
Diffstat (limited to 'src/Utilities.cpp')
-rw-r--r-- | src/Utilities.cpp | 10 |
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) |