From 5842d13294148fdab018c6d64beda4283979e244 Mon Sep 17 00:00:00 2001 From: PS Date: Wed, 27 Mar 2024 13:49:29 -0700 Subject: [PATCH] string_find_first_of_set impl --- code/custom/4coder_base_types.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/code/custom/4coder_base_types.cpp b/code/custom/4coder_base_types.cpp index 8ca2e84d..fe2173b2 100644 --- a/code/custom/4coder_base_types.cpp +++ b/code/custom/4coder_base_types.cpp @@ -4990,6 +4990,27 @@ string_find_first_insensitive(String_Const_u32 str, String_Const_u32 needle){ return(string_find_first(str, needle, StringMatch_CaseInsensitive)); } +function u64 +string_find_first_of_set(String_Const_u8 str, String_Const_u8 needle) +{ + u64 i = 0; + if (needle.size > 0){ + i = 0; + for (;i < str.size; i += 1){ + bool found = false; + for (u64 j = 0; j < needle.size; j++) + { + if (str.str[i] == needle.str[j]) { + found = true; + break; + } + } + if (found) break; + } + } + return(i); +} + function b32 string_has_substr(String_Const_u8 str, String_Const_u8 needle, String_Match_Rule rule){ return(string_find_first(str, needle, rule) < str.size);