mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-18 04:08:27 +00:00
[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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user