summaryrefslogtreecommitdiffstats
path: root/src/utils/string.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/string.hpp')
-rw-r--r--src/utils/string.hpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/utils/string.hpp b/src/utils/string.hpp
index 9f2b4ac..6127bfe 100644
--- a/src/utils/string.hpp
+++ b/src/utils/string.hpp
@@ -22,6 +22,7 @@
#define UTILS_STRING_H
#include <string>
+#include <sstream>
namespace utils
{
@@ -67,6 +68,19 @@ namespace utils
* @param str the string to trim spaces off
*/
void trim(std::string &str);
+
+ /**
+ * Converts the given value to a string using std::stringstream.
+ *
+ * @param arg the value to convert to a string
+ * @return the string representation of arg
+ */
+ template<typename T> std::string toString(const T &arg)
+ {
+ std::stringstream ss;
+ ss << arg;
+ return ss.str();
+ }
}
#endif // UTILS_STRING_H