diff options
author | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2014-11-04 03:03:19 -0200 |
---|---|---|
committer | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2014-12-13 01:59:52 -0200 |
commit | 6390c66e950b0536c438bf3be1ea78fd0540d6c9 (patch) | |
tree | cd186e179228890375625265ae67fa3508256353 /src/common/string_util.h | |
parent | 6b0fb62c47875bf19edcb8e964d7595662caf5b3 (diff) |
Implement text path trimming for shorter paths.
Diffstat (limited to 'src/common/string_util.h')
-rw-r--r-- | src/common/string_util.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/common/string_util.h b/src/common/string_util.h index ae5bbadad9..7d75691b11 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'); +} + } |