summaryrefslogtreecommitdiff
path: root/src/std/str.h
diff options
context:
space:
mode:
authorOmniscient <17525998+omnisci3nce@users.noreply.github.com>2024-02-24 22:47:46 +1100
committerOmniscient <17525998+omnisci3nce@users.noreply.github.com>2024-02-24 22:47:46 +1100
commit7b3afcaf77f96e7d62f6cd1623ead7f17512d79f (patch)
treeb5f82c64e9c06a84e4d095ab4ac48712e860b673 /src/std/str.h
parentb047be5252aeb981faea077409c1768fda0301d9 (diff)
repo init. partial port of existing code
Diffstat (limited to 'src/std/str.h')
-rw-r--r--src/std/str.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/std/str.h b/src/std/str.h
new file mode 100644
index 0000000..3d3cb41
--- /dev/null
+++ b/src/std/str.h
@@ -0,0 +1,30 @@
+/**
+ * @brief
+ *
+ */
+#pragma once
+
+#include "defines.h"
+
+/**
+ * @brief Fat pointer representing a UTF8 (TODO) encoded string
+ * @note when using `printf` you must use %s.*s length, string
+ */
+typedef struct {
+ u8 *buf;
+ size_t len;
+} str8;
+
+/** @brief Compare two strings for exact equality */
+bool str8_equals(str8 a, str8 b);
+
+/**
+ * @brief Compare the first `first_nchars` of each string for equality
+ If either of the strings are shorter than the number only the characters up until the end
+ of the shorter string will be compared.
+ * @returns 0 if they are fully equal up until `first_nchars`, i.e they never differed, else it
+ returns the index at which the first string differed from the second string.
+*/
+size_t str8_nequals(str8 a, str8 b, size_t first_nchars);
+
+bool str8_ends_with(str8 input_str, str8 suffix); \ No newline at end of file