forked from OctaForge/libostd
some initial funcs
parent
434816840b
commit
c111483f1d
|
@ -6,6 +6,7 @@
|
||||||
#ifndef OCTA_STRING_H
|
#ifndef OCTA_STRING_H
|
||||||
#define OCTA_STRING_H
|
#define OCTA_STRING_H
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "octa/utility.h"
|
#include "octa/utility.h"
|
||||||
|
@ -92,6 +93,11 @@ namespace octa {
|
||||||
|
|
||||||
bool empty() const { return (length() == 0); }
|
bool empty() const { return (length() == 0); }
|
||||||
|
|
||||||
|
void push(T v) {
|
||||||
|
p_buf.last() = v;
|
||||||
|
p_buf.push('\0');
|
||||||
|
}
|
||||||
|
|
||||||
StringBase<T> &operator+=(const StringBase &s) {
|
StringBase<T> &operator+=(const StringBase &s) {
|
||||||
p_buf.pop();
|
p_buf.pop();
|
||||||
p_buf.insert_range(p_buf.length(), s.p_buf.each());
|
p_buf.insert_range(p_buf.length(), s.p_buf.each());
|
||||||
|
@ -136,6 +142,23 @@ namespace octa {
|
||||||
}
|
}
|
||||||
return move(ret);
|
return move(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
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
|
#endif
|
Loading…
Reference in New Issue