From 8d6fdc09e7427f0f024c76d73d9915014e97cce9 Mon Sep 17 00:00:00 2001 From: David Athay Date: Wed, 5 Nov 2008 16:51:44 +0000 Subject: Use a string util for converting strings to integers, as per Bjorns suggestion. --- src/utils/string.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/utils/string.cpp') diff --git a/src/utils/string.cpp b/src/utils/string.cpp index abd6eb88..79ca4dc6 100644 --- a/src/utils/string.cpp +++ b/src/utils/string.cpp @@ -23,6 +23,7 @@ #include #include +#include std::string utils::toupper(std::string s) { @@ -42,3 +43,14 @@ bool utils::isNumeric(const std::string &s) return true; } + +int utils::stringToInt(const std::string &s) +{ + int value; + std::stringstream str(s); + + // put the string into the int + str >> value; + + return value; +} -- cgit v1.2.3-70-g09d2