From c111483f1dd3d8fb02a39ea6ae16c25d8bc28df8 Mon Sep 17 00:00:00 2001 From: q66 Date: Wed, 27 May 2015 22:15:24 +0100 Subject: [PATCH] some initial funcs --- octa/string.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/octa/string.h b/octa/string.h index 05e254e..a897ddb 100644 --- a/octa/string.h +++ b/octa/string.h @@ -6,6 +6,7 @@ #ifndef OCTA_STRING_H #define OCTA_STRING_H +#include #include #include "octa/utility.h" @@ -92,6 +93,11 @@ namespace octa { bool empty() const { return (length() == 0); } + void push(T v) { + p_buf.last() = v; + p_buf.push('\0'); + } + StringBase &operator+=(const StringBase &s) { p_buf.pop(); p_buf.insert_range(p_buf.length(), s.p_buf.each()); @@ -136,6 +142,23 @@ namespace octa { } return move(ret); } + + template + String to_string(const T &) { + return ""; + } + + String to_string(char c) { + String ret; + ret.push(c); + return move(ret); + } + + String to_string(int v) { + char buf[128]; + sprintf(buf, "%d", v); + return String((const char *)buf); + } } #endif \ No newline at end of file