summaryrefslogtreecommitdiff
path: root/src/utils/stringutils.h
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-05-03 12:53:40 +0200
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-05-03 12:55:22 +0200
commit19bf50bbff325024c2ed9ad724aeb6acb39bae39 (patch)
tree811b25f52c49c501e58604757e5c72d442210377 /src/utils/stringutils.h
parenta8ebdf2555ac6b89afa2e0e575ba01c349ef3fe2 (diff)
downloadmana-client-19bf50bbff325024c2ed9ad724aeb6acb39bae39.tar.gz
mana-client-19bf50bbff325024c2ed9ad724aeb6acb39bae39.tar.bz2
mana-client-19bf50bbff325024c2ed9ad724aeb6acb39bae39.tar.xz
mana-client-19bf50bbff325024c2ed9ad724aeb6acb39bae39.zip
Moved strprintf into stringutils.{h,cpp}
Diffstat (limited to 'src/utils/stringutils.h')
-rw-r--r--src/utils/stringutils.h11
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