[Feature] Add Strings::BeginsWith() and Strings::EndsWith() (#3471)

* [Strings] Add Strings::BeginsWith() and Strings::EndsWith()

# Notes
- These are useful so that we don't have to manually calculate size or perform a substring.

* Update questmgr.cpp

* Update client.cpp
This commit is contained in:
Alex King
2023-07-03 09:40:44 -04:00
committed by GitHub
parent 2717fcc339
commit ee14aed8de
7 changed files with 73 additions and 68 deletions
+23
View File
@@ -695,8 +695,31 @@ std::string Strings::ConvertToDigit(int n, const std::string& suffix)
return NUM_TO_ENGLISH_X[n] + suffix;
}
}
bool Strings::BeginsWith(const std::string& subject, const std::string& search)
{
if (subject.length() < search.length()) {
return false;
}
return subject.starts_with(search);
}
bool Strings::EndsWith(const std::string& subject, const std::string& search)
{
if (subject.length() < search.length()) {
return false;
}
return subject.ends_with(search);
}
bool Strings::Contains(const std::string& subject, const std::string& search)
{
if (subject.length() < search.length()) {
return false;
}
return subject.find(search) != std::string::npos;
}