diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-05-03 12:53:40 +0200 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-05-03 12:55:22 +0200 |
commit | 19bf50bbff325024c2ed9ad724aeb6acb39bae39 (patch) | |
tree | 811b25f52c49c501e58604757e5c72d442210377 /src/utils/stringutils.h | |
parent | a8ebdf2555ac6b89afa2e0e575ba01c349ef3fe2 (diff) | |
download | mana-19bf50bbff325024c2ed9ad724aeb6acb39bae39.tar.gz mana-19bf50bbff325024c2ed9ad724aeb6acb39bae39.tar.bz2 mana-19bf50bbff325024c2ed9ad724aeb6acb39bae39.tar.xz mana-19bf50bbff325024c2ed9ad724aeb6acb39bae39.zip |
Moved strprintf into stringutils.{h,cpp}
Diffstat (limited to 'src/utils/stringutils.h')
-rw-r--r-- | src/utils/stringutils.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h index 3af0bfa5..89d3d7e9 100644 --- a/src/utils/stringutils.h +++ b/src/utils/stringutils.h @@ -74,6 +74,17 @@ template<typename T> std::string toString(const T &arg) const char *ipToString(int address); /** + * A safe version of sprintf that returns a std::string of the result. + */ +std::string strprintf(char const *, ...) +#ifdef __GNUC__ + /* This attribute is nice: it even works through gettext invokation. For + example, gcc will complain that strprintf(_("%s"), 42) is ill-formed. */ + __attribute__((format(printf, 1, 2))) +#endif +; + +/** * Removes bad characters from a string * * @param str the string to remove the bad chars from |