summaryrefslogtreecommitdiff
path: root/core/string
diff options
context:
space:
mode:
authorBastiaan Olij <mux213@gmail.com>2022-11-19 00:17:37 +1100
committerBastiaan Olij <mux213@gmail.com>2022-11-24 21:48:16 +1100
commita479f5af2208882767ae5d11dca35cc9bfecef31 (patch)
treeeb093fca304199f06ec27fe6ac8ef9e7eef9a193 /core/string
parentfa270c2456df5ad12f51584c4ff891e2cf728cec (diff)
Improve logic for detecting and tracking extensions
Diffstat (limited to 'core/string')
-rw-r--r--core/string/ustring.cpp12
-rw-r--r--core/string/ustring.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp
index 175c42542b..4e26b61334 100644
--- a/core/string/ustring.cpp
+++ b/core/string/ustring.cpp
@@ -161,6 +161,18 @@ bool CharString::operator<(const CharString &p_right) const {
return is_str_less(get_data(), p_right.get_data());
}
+bool CharString::operator==(const CharString &p_right) const {
+ if (length() == 0) {
+ // True if both have length 0, false if only p_right has a length
+ return p_right.length() == 0;
+ } else if (p_right.length() == 0) {
+ // False due to unequal length
+ return false;
+ }
+
+ return strcmp(ptr(), p_right.ptr()) == 0;
+}
+
CharString &CharString::operator+=(char p_char) {
const int lhs_len = length();
resize(lhs_len + 2);
diff --git a/core/string/ustring.h b/core/string/ustring.h
index 0c171024f7..ed3848fb8a 100644
--- a/core/string/ustring.h
+++ b/core/string/ustring.h
@@ -156,6 +156,7 @@ public:
void operator=(const char *p_cstr);
bool operator<(const CharString &p_right) const;
+ bool operator==(const CharString &p_right) const;
CharString &operator+=(char p_char);
int length() const { return size() ? size() - 1 : 0; }
const char *get_data() const;