mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 10:00:40 +00:00
strings: Helper to remove pattern from the end
This commit is contained in:
committed by
Baldur Karlsson
parent
cde58e7326
commit
296854da73
@@ -107,3 +107,16 @@ bool endswith(const std::string &value, const std::string &ending)
|
||||
|
||||
return (0 == value.compare(value.length() - ending.length(), ending.length(), ending));
|
||||
}
|
||||
|
||||
std::string removeFromEnd(const std::string &value, const std::string &ending)
|
||||
{
|
||||
string::size_type pos;
|
||||
pos = value.rfind(ending);
|
||||
|
||||
// Create new string from beginning to pattern
|
||||
if(string::npos != pos)
|
||||
return value.substr(0, pos);
|
||||
|
||||
// If pattern not found, just return original string
|
||||
return value;
|
||||
}
|
||||
@@ -38,6 +38,7 @@ std::string strupper(const std::string &str);
|
||||
std::wstring strupper(const std::wstring &str);
|
||||
|
||||
std::string trim(const std::string &str);
|
||||
std::string removeFromEnd(const std::string &value, const std::string &ending);
|
||||
|
||||
uint32_t strhash(const char *str, uint32_t existingHash = 5381);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user