openFrameworks
openFrameworks copied to clipboard
feature: string starts and ends with functions
I find myself always adding little string helper functions. I think startsWith and endsWith will be added for cpp20.
does it make sense to add something like this to the core?
//ofEndsWith
static bool ofDoesStringEndWith(const std::string &str, const std::string &suffix)
{
return str.size() >= suffix.size() && 0 == str.compare(str.size() - suffix.size(), suffix.size(), suffix);
}
//ofStartsWith
static bool ofDoesStringStartWith(const std::string &str, const std::string &prefix)
{
return str.size() >= prefix.size() && 0 == str.compare(0, prefix.size(), prefix);
}
t