aboutsummaryrefslogtreecommitdiff
path: root/include/base/string.h
diff options
context:
space:
mode:
authorNicholas <nbnoll@eml.cc>2021-11-20 10:53:19 -0800
committerNicholas <nbnoll@eml.cc>2021-11-20 10:53:19 -0800
commita9bfe650038afea8b751175cac16f6027345e45f (patch)
tree9a7f9feb76a64bb3efe573036d80b7bdbf8a59a5 /include/base/string.h
parent1c8d4e69205fd875f6bec3fa3bd929c2e7f52f62 (diff)
Chore: reorganize libutf and libfmt into base
I found the split to be arbitrary. Better to include the functionality in the standard library. I also split the headers to allow for more granular inclusion (but the library is still monolithic). The only ugliness is the circular dependency introduced with libutf's generated functions. We put explicit prereqs with the necessary object files instead.
Diffstat (limited to 'include/base/string.h')
-rw-r--r--include/base/string.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/include/base/string.h b/include/base/string.h
new file mode 100644
index 0000000..08466fa
--- /dev/null
+++ b/include/base/string.h
@@ -0,0 +1,30 @@
+#pragma once
+
+typedef byte* string;
+
+/* augmented string functions */
+string str·makecap(const char *s, vlong len, vlong cap);
+string str·makelen(const char *s, vlong len);
+string str·make(const char *s);
+string str·makef(const char *fmt, ...);
+void str·free(string s);
+int str·len(const string s);
+int str·cap(const string s);
+void str·clear(string *s);
+void str·grow(string *s, vlong delta);
+void str·fit(string *s);
+int str·appendlen(string *s, vlong len, const char *b);
+int str·append(string *s, const char *b);
+int str·appendf(string *s, const char *fmt, ...);
+int str·appendbyte(string *s, const char b);
+bool str·equals(const string s, const string t);
+int str·find(string s, const char* substr);
+void str·lower(string s);
+void str·upper(string s);
+int str·read(string s, int size, int n, void *buf);
+void str·replace(string s, const byte* from, const byte* to);
+string* str·split(string s, const byte* tok);
+string str·join(vlong len, byte** fields, const byte* sep);
+
+/* raw C string functions */
+char *str·copyn(char *dst, char *src, int n);