aboutsummaryrefslogtreecommitdiff
path: root/src/string.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-02-02 15:28:49 +0000
committergingerBill <bill@gingerbill.org>2022-02-02 15:28:49 +0000
commit78815778ee399b4df1c5f7c44522c792b9dc3e23 (patch)
tree884c8a2a459ff9068daac89a63ced2e160564ea9 /src/string.cpp
parenta04d849e30da1252e56d29ee18e2a51a5b6cb0d5 (diff)
Add `//+private file` to complement `//+private` (`//+private package`)
Diffstat (limited to 'src/string.cpp')
-rw-r--r--src/string.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/string.cpp b/src/string.cpp
index 800378689..eb6058f78 100644
--- a/src/string.cpp
+++ b/src/string.cpp
@@ -195,8 +195,6 @@ template <isize N> bool operator > (String const &a, char const (&b)[N]) { retu
template <isize N> bool operator <= (String const &a, char const (&b)[N]) { return str_le(a, make_string(cast(u8 *)b, N-1)); }
template <isize N> bool operator >= (String const &a, char const (&b)[N]) { return str_ge(a, make_string(cast(u8 *)b, N-1)); }
-
-
gb_inline bool string_starts_with(String const &s, String const &prefix) {
if (prefix.len > s.len) {
return false;
@@ -230,6 +228,16 @@ gb_inline bool string_ends_with(String const &s, u8 suffix) {
return s[s.len-1] == suffix;
}
+
+
+gb_inline String string_trim_starts_with(String const &s, String const &prefix) {
+ if (string_starts_with(s, prefix)) {
+ return substring(s, prefix.len, s.len);
+ }
+ return s;
+}
+
+
gb_inline isize string_extension_position(String const &str) {
isize dot_pos = -1;
isize i = str.len;