summaryrefslogtreecommitdiffstats
path: root/src/common/stringutils.h
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2013-12-03 00:11:26 +0100
committerPiotr Dziwinski <piotrdz@gmail.com>2013-12-04 00:15:39 +0100
commit8deb1305726966b3b583865dec1ba7ba1327d8cb (patch)
tree291627fbe0123dc35c015b1f398585f204afe8ea /src/common/stringutils.h
parentdae8d8738908a65a4ee4ef14d88681e196825126 (diff)
downloadcolobot-8deb1305726966b3b583865dec1ba7ba1327d8cb.tar.gz
colobot-8deb1305726966b3b583865dec1ba7ba1327d8cb.tar.bz2
colobot-8deb1305726966b3b583865dec1ba7ba1327d8cb.zip
Changed char[] to std::string in restext
Experimental changes
Diffstat (limited to 'src/common/stringutils.h')
-rw-r--r--src/common/stringutils.h11
1 files changed, 7 insertions, 4 deletions
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\<int\> */
template<class T>
-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\<int\> */
template<class T>
-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);