From dce7c0afa22ca6568bbf6cca6a9cd669ef8b4b28 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Fri, 3 Jun 2016 21:41:41 +0300 Subject: util: add helpers --- libkms++util/strhelpers.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 libkms++util/strhelpers.cpp (limited to 'libkms++util/strhelpers.cpp') diff --git a/libkms++util/strhelpers.cpp b/libkms++util/strhelpers.cpp new file mode 100644 index 0000000..f18c749 --- /dev/null +++ b/libkms++util/strhelpers.cpp @@ -0,0 +1,27 @@ +#include "strhelpers.h" + +#include +#include + +using namespace std; + +string to_lower(const string& str) +{ + string data = str; + transform(data.begin(), data.end(), data.begin(), ::tolower); + return data; +} + +string sformat(const char *fmt, ...) +{ + static char s_format_buf[1024]; + + va_list args; + va_start(args, fmt); + + vsnprintf(s_format_buf, sizeof(s_format_buf), fmt, args); + + va_end(args); + + return string(s_format_buf); +} -- cgit v1.2.3