From 17d180891f1e237ea5d25835999a8b23a6e7946d Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Sat, 11 Jun 2016 20:17:35 +0300 Subject: rename dirs --- kms++util/strhelpers.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 kms++util/strhelpers.h (limited to 'kms++util/strhelpers.h') diff --git a/kms++util/strhelpers.h b/kms++util/strhelpers.h new file mode 100644 index 0000000..2c540f3 --- /dev/null +++ b/kms++util/strhelpers.h @@ -0,0 +1,33 @@ +#include +#include +#include +#include + +std::string to_lower(const std::string& str); + +template +std::string join(const T& values, const std::string& delim) +{ + std::ostringstream ss; + for (const auto& v : values) { + if (&v != &values[0]) + ss << delim; + ss << v; + } + return ss.str(); +} + +template +std::string join(const std::vector& values, const std::string& delim, std::function func) +{ + std::ostringstream ss; + for (const auto& v : values) { + if (&v != &values[0]) + ss << delim; + ss << func(v); + } + return ss.str(); +} + +std::string sformat(const char *fmt, ...) + __attribute__ ((format (printf, 1, 2))); -- cgit v1.2.3