Add endswith helper to string_utils

This commit is contained in:
Cody Northrop
2017-06-22 14:23:34 -06:00
committed by Baldur Karlsson
parent 95225d12b4
commit cced0e695b
2 changed files with 10 additions and 0 deletions
+8
View File
@@ -99,3 +99,11 @@ std::string trim(const std::string &str)
// searching from the start found something, so searching from the end must have too.
return str.substr(start, end - start + 1);
}
bool endswith(const std::string &value, const std::string &ending)
{
if(ending.length() > value.length())
return false;
return (0 == value.compare(value.length() - ending.length(), ending.length(), ending));
}
+2
View File
@@ -41,6 +41,8 @@ std::string trim(const std::string &str);
uint32_t strhash(const char *str, uint32_t existingHash = 5381);
bool endswith(const std::string &value, const std::string &ending);
template <class strType>
strType basename(const strType &path)
{