Implement text path trimming for shorter paths.

This commit is contained in:
Yuri Kunde Schlesner 2014-11-04 03:03:19 -02:00
parent 6b0fb62c47
commit 6390c66e95
3 changed files with 53 additions and 1 deletions

View file

@ -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');
}
}