summaryrefslogtreecommitdiffstats
path: root/src/common/string_util.h
diff options
context:
space:
mode:
authorYuri Kunde Schlesner <yuriks@yuriks.net>2014-11-04 06:03:19 +0100
committerYuri Kunde Schlesner <yuriks@yuriks.net>2014-12-13 04:59:52 +0100
commit6390c66e950b0536c438bf3be1ea78fd0540d6c9 (patch)
treecd186e179228890375625265ae67fa3508256353 /src/common/string_util.h
parentRe-add coloring to the console logging output. (diff)
downloadyuzu-6390c66e950b0536c438bf3be1ea78fd0540d6c9.tar
yuzu-6390c66e950b0536c438bf3be1ea78fd0540d6c9.tar.gz
yuzu-6390c66e950b0536c438bf3be1ea78fd0540d6c9.tar.bz2
yuzu-6390c66e950b0536c438bf3be1ea78fd0540d6c9.tar.lz
yuzu-6390c66e950b0536c438bf3be1ea78fd0540d6c9.tar.xz
yuzu-6390c66e950b0536c438bf3be1ea78fd0540d6c9.tar.zst
yuzu-6390c66e950b0536c438bf3be1ea78fd0540d6c9.zip
Diffstat (limited to 'src/common/string_util.h')
-rw-r--r--src/common/string_util.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/common/string_util.h b/src/common/string_util.h
index ae5bbadad..7d75691b1 100644
--- a/src/common/string_util.h
+++ b/src/common/string_util.h
@@ -115,4 +115,19 @@ inline std::string UTF8ToTStr(const std::string& str)
#endif
+/**
+ * Compares the string defined by the range [`begin`, `end`) to the null-terminated C-string
+ * `other` for equality.
+ */
+template <typename InIt>
+bool ComparePartialString(InIt begin, InIt end, const char* other) {
+ for (; begin != end && *other != '\0'; ++begin, ++other) {
+ if (*begin != *other) {
+ return false;
+ }
+ }
+ // Only return true if both strings finished at the same point
+ return (begin == end) == (*other == '\0');
+}
+
}