diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2023-11-10 19:37:08 +0100 |
|---|---|---|
| committer | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2023-11-10 19:37:08 +0100 |
| commit | e19460cbd7c847bd5452b2c7bf96b38d06b2a182 (patch) | |
| tree | 33163490d2d1468aa452b71134af22eb12d2a3e0 /src/string.cpp | |
| parent | 70c1f9d0e19a4b97c03308de8f2b9c0c28ba4cf1 (diff) | |
Add -microarch:?
Diffstat (limited to 'src/string.cpp')
| -rw-r--r-- | src/string.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/string.cpp b/src/string.cpp index 6eac4f53b..e85787c59 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -10,6 +10,10 @@ struct String { return text[i]; } }; +struct String_Iterator { + String const &str; + isize pos; +}; // NOTE(bill): used for printf style arguments #define LIT(x) ((int)(x).len), (x).text #if defined(GB_COMPILER_MSVC) && _MSC_VER < 1700 @@ -201,6 +205,26 @@ gb_internal gb_inline String string_trim_starts_with(String const &s, String con } +gb_internal String string_split_iterator(String_Iterator *it, const char sep) { + isize start = it->pos; + isize end = it->str.len; + + if (start == end) { + return str_lit(""); + } + + isize i = start; + for (; i < it->str.len; i++) { + if (it->str[i] == sep) { + String res = substring(it->str, start, i); + it->pos += res.len + 1; + return res; + } + } + it->pos = end; + return substring(it->str, start, end); +} + gb_internal gb_inline isize string_extension_position(String const &str) { isize dot_pos = -1; isize i = str.len; |