summaryrefslogtreecommitdiff
path: root/libkms++util/strhelpers.cpp
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2016-06-03 21:41:41 +0300
committerTomi Valkeinen <tomi.valkeinen@ti.com>2016-06-05 22:09:39 +0300
commitdce7c0afa22ca6568bbf6cca6a9cd669ef8b4b28 (patch)
tree91b35552bd0718d29c72ba8da944bb4e3d82f323 /libkms++util/strhelpers.cpp
parent4864a696159a510053daf30e3bf96a3b255bb3ed (diff)
util: add helpers
Diffstat (limited to 'libkms++util/strhelpers.cpp')
-rw-r--r--libkms++util/strhelpers.cpp27
1 files changed, 27 insertions, 0 deletions
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 <algorithm>
+#include <stdarg.h>
+
+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);
+}