diff options
Diffstat (limited to 'src/string.cc')
| -rw-r--r-- | src/string.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/string.cc b/src/string.cc index e7dd167f..2c180e50 100644 --- a/src/string.cc +++ b/src/string.cc @@ -23,6 +23,18 @@ std::vector<String> split(const String& str, char separator) return res; } +int str_to_int(const String& str) +{ + try + { + return stoi(str); + } + catch (std::logic_error&) + { + throw runtime_error(str + "is not a number"); + } +} + String option_to_string(const Regex& re) { return String{re.str()}; |
