From d8b0f9f88bba7a3fe577d089fd39a78ba92e2170 Mon Sep 17 00:00:00 2001 From: rachytski Date: Tue, 24 Jul 2012 14:50:51 -0700 Subject: [PATCH] added saving and reading int and unsigned int from settings. --- platform/settings.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/platform/settings.cpp b/platform/settings.cpp index d3542fe283..38334e36e5 100644 --- a/platform/settings.cpp +++ b/platform/settings.cpp @@ -199,6 +199,44 @@ namespace Settings else return false; } + template <> string ToString(int const & v) + { + ostringstream stream; + stream << v; + return stream.str(); + } + + template <> bool FromString(string const & str, int & v) + { + istringstream stream(str); + if (stream.good()) + { + stream >> v; + return !stream.fail(); + } + else + return false; + } + + template <> string ToString(unsigned const & v) + { + ostringstream stream; + stream << v; + return stream.str(); + } + + template <> bool FromString(string const & str, unsigned & v) + { + istringstream stream(str); + if (stream.good()) + { + stream >> v; + return !stream.fail(); + } + else + return false; + } + namespace impl { template string ToStringPair(TPair const & value)