initial code repo
[stor4nfv.git] / src / ceph / src / include / stringify.h
diff --git a/src/ceph/src/include/stringify.h b/src/ceph/src/include/stringify.h
new file mode 100644 (file)
index 0000000..1b2a130
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef __CEPH_STRINGIFY_H
+#define __CEPH_STRINGIFY_H
+
+#include <string>
+#include <sstream>
+
+#include "include/types.h"
+
+template<typename T>
+inline std::string stringify(const T& a) {
+#if defined(__GNUC__) && !(defined(__clang__) || defined(__INTEL_COMPILER))
+  static __thread std::ostringstream ss;
+  ss.str("");
+#else
+  std::ostringstream ss;
+#endif
+  ss << a;
+  return ss.str();
+}
+
+template <class T, class A>
+T joinify(const A &begin, const A &end, const T &t)
+{
+  T result;
+  for (A it = begin; it != end; it++) {
+    if (!result.empty())
+      result.append(t);
+    result.append(*it);
+  }
+  return result;
+}
+
+#endif