mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-17 23:39:18 +02:00
Replace starts_with and ends_with with string class methods
This commit is contained in:
@@ -404,30 +404,16 @@ std::ptrdiff_t len_common_prefix(std::string_view a, std::string_view b)
|
||||
return std::distance(a.begin(), it1);
|
||||
}
|
||||
|
||||
// returns true if provided string ends with another provided string
|
||||
bool ends_with(std::string_view String, std::string_view Suffix)
|
||||
{
|
||||
|
||||
return (String.size() >= Suffix.size()) && (0 == String.compare(String.size() - Suffix.size(), Suffix.size(), Suffix));
|
||||
}
|
||||
|
||||
// returns true if provided string begins with another provided string
|
||||
bool starts_with(std::string_view const String, std::string_view Prefix)
|
||||
{
|
||||
|
||||
return (String.size() >= Prefix.size()) && (0 == String.compare(0, Prefix.size(), Prefix));
|
||||
}
|
||||
|
||||
// returns true if provided string contains another provided string
|
||||
bool contains(std::string_view const String, std::string_view Substring)
|
||||
{
|
||||
|
||||
// To be replaced with string::contains in C++ 23
|
||||
return (String.find(Substring) != std::string::npos);
|
||||
}
|
||||
|
||||
bool contains(std::string_view const String, char Character)
|
||||
{
|
||||
|
||||
// To be replaced with string::contains in C++ 23
|
||||
return (String.find(Character) != std::string::npos);
|
||||
}
|
||||
|
||||
|
||||
@@ -226,10 +226,6 @@ std::string_view substr_path(std::string const &Filename);
|
||||
// returns common prefix of two provided strings
|
||||
std::ptrdiff_t len_common_prefix(std::string_view a, std::string_view b);
|
||||
|
||||
// returns true if provided string ends with another provided string
|
||||
bool ends_with(std::string_view String, std::string_view Suffix);
|
||||
// returns true if provided string begins with another provided string
|
||||
bool starts_with(std::string_view String, std::string_view Prefix);
|
||||
// returns true if provided string contains another provided string
|
||||
bool contains(std::string_view const String, std::string_view Substring);
|
||||
bool contains(std::string_view const String, char Character);
|
||||
|
||||
Reference in New Issue
Block a user