summaryrefslogtreecommitdiffstats
path: root/src/common/stringutils.h
diff options
context:
space:
mode:
authorkrzys-h <krzys_h@interia.pl>2014-07-01 12:15:38 +0200
committerkrzys-h <krzys_h@interia.pl>2014-07-01 12:16:32 +0200
commitd9fee8b2adad613cf8c10d153cd5cd7b261b7863 (patch)
treef6b71cc2daa719c10c1ce31cf738e1c6ec934a73 /src/common/stringutils.h
parent0f2adf05fd2b2b38c2b84aa8d72b3fd756dcfcd4 (diff)
parent1835d2ae580525603308206f7b8e6b4552b3ca0f (diff)
downloadcolobot-d9fee8b2adad613cf8c10d153cd5cd7b261b7863.tar.gz
colobot-d9fee8b2adad613cf8c10d153cd5cd7b261b7863.tar.bz2
colobot-d9fee8b2adad613cf8c10d153cd5cd7b261b7863.zip
Release 0.1.3-alpha
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);