diff options
author | Didier Raboud <odyx@debian.org> | 2014-07-02 11:33:47 +0200 |
---|---|---|
committer | Didier Raboud <odyx@debian.org> | 2014-07-02 11:33:47 +0200 |
commit | 2e136acd34c45e5e6d105cabf91c67e5865c38fe (patch) | |
tree | 8561603160cce0b41ba31250539a22d37a2951de /src/common/stringutils.h | |
parent | 562be6fe765d7742f7c38fbd82f8cc26369e238b (diff) | |
parent | d9fee8b2adad613cf8c10d153cd5cd7b261b7863 (diff) | |
download | colobot-2e136acd34c45e5e6d105cabf91c67e5865c38fe.tar.gz colobot-2e136acd34c45e5e6d105cabf91c67e5865c38fe.tar.bz2 colobot-2e136acd34c45e5e6d105cabf91c67e5865c38fe.zip |
Merge tag 'colobot-gold-0.1.3-alpha' into debian
Diffstat (limited to 'src/common/stringutils.h')
-rw-r--r-- | src/common/stringutils.h | 11 |
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); |