From 19bf50bbff325024c2ed9ad724aeb6acb39bae39 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 3 May 2009 12:53:40 +0200 Subject: Moved strprintf into stringutils.{h,cpp} --- src/utils/stringutils.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/utils/stringutils.h') 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 @@ -73,6 +73,17 @@ template 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 * -- cgit v1.2.3-70-g09d2