diff options
author | David Athay <ko2fan@gmail.com> | 2008-11-05 16:51:44 +0000 |
---|---|---|
committer | David Athay <ko2fan@gmail.com> | 2008-11-05 16:51:44 +0000 |
commit | 8d6fdc09e7427f0f024c76d73d9915014e97cce9 (patch) | |
tree | 54482ccb10a1ee002919c9c5de67bf8108607516 /src/utils/string.cpp | |
parent | 8de368c1456d997d61c4730f2fe12624dfcf1974 (diff) | |
download | manaserv-8d6fdc09e7427f0f024c76d73d9915014e97cce9.tar.gz manaserv-8d6fdc09e7427f0f024c76d73d9915014e97cce9.tar.bz2 manaserv-8d6fdc09e7427f0f024c76d73d9915014e97cce9.tar.xz manaserv-8d6fdc09e7427f0f024c76d73d9915014e97cce9.zip |
Use a string util for converting strings to
integers, as per Bjorns suggestion.
Diffstat (limited to 'src/utils/string.cpp')
-rw-r--r-- | src/utils/string.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
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 <cctype> #include <algorithm> +#include <sstream> 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; +} |