From 8deb1305726966b3b583865dec1ba7ba1327d8cb Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Tue, 3 Dec 2013 00:11:26 +0100 Subject: Changed char[] to std::string in restext Experimental changes --- src/common/stringutils.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/common/stringutils.h') diff --git a/src/common/stringutils.h b/src/common/stringutils.h index c60bfb0..e80163a 100644 --- a/src/common/stringutils.h +++ b/src/common/stringutils.h @@ -31,11 +31,11 @@ namespace StrUtils { /** If given, \a ok is set to true/false on success/failure. Warning: To avoid unnecessary problems, *always* give full template qualifier e.g. ToString\ */ template -std::string ToString(T value, bool *ok = NULL) +std::string ToString(T value, bool *ok = nullptr) { std::ostringstream s; s << value; - if (ok != NULL) + if (ok != nullptr) *ok = !s.fail(); return s.str(); } @@ -44,17 +44,20 @@ std::string ToString(T value, bool *ok = NULL) /** If given, \a ok is set to true/false on success/failure. Warning: To avoid unnecessary problems, *always* give full template qualifier e.g. FromString\ */ template -T FromString(const std::string &str, bool *ok = NULL) +T FromString(const std::string &str, bool *ok = nullptr) { std::istringstream s; s.str(str); T value; s >> value; - if (ok != NULL) + if (ok != nullptr) *ok = !s.fail(); return value; } +//! Replacement for sprintf() +std::string Format(const char *fmt, ...); + //! Returns a string with every occurence of \a oldStr in \a str replaced to \a newStr std::string Replace(const std::string &str, const std::string &oldStr, const std::string &newStr); -- cgit v1.2.3-1-g7c22