diff options
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/util.cc | 8 | ||||
-rw-r--r-- | src/libutil/util.hh | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc index 1873ccfe536c..4f6c367da8b1 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -1020,6 +1020,14 @@ bool string2Int(const string & s, int & n) } +bool string2Int(const string & s, long long & n) +{ + std::istringstream str(s); + str >> n; + return str && str.get() == EOF; +} + + void ignoreException() { try { diff --git a/src/libutil/util.hh b/src/libutil/util.hh index d1e30fa6b9e3..5d28a8308cb8 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -287,6 +287,7 @@ bool statusOk(int status); /* Parse a string into an integer. */ string int2String(int n); bool string2Int(const string & s, int & n); +bool string2Int(const string & s, long long & n); /* Exception handling in destructors: print an error message, then |