diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2016-06-11 20:17:35 +0300 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2016-06-11 20:17:35 +0300 |
commit | 17d180891f1e237ea5d25835999a8b23a6e7946d (patch) | |
tree | 5963fe4d338f6272daf55c76ed355effb47afc71 /kms++util/strhelpers.h | |
parent | 38a71ee72c47f3287c327113ce411f236cac05ef (diff) |
rename dirs
Diffstat (limited to 'kms++util/strhelpers.h')
-rw-r--r-- | kms++util/strhelpers.h | 33 |
1 files changed, 33 insertions, 0 deletions
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 <sstream> +#include <string> +#include <vector> +#include <functional> + +std::string to_lower(const std::string& str); + +template <typename T> +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 <typename T> +std::string join(const std::vector<T>& values, const std::string& delim, std::function<std::string(T)> 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))); |