mirror of https://github.com/stella-emu/stella.git
Added a few more 'string_view' in bspf.
This commit is contained in:
parent
c59bf70656
commit
2a07daccb4
|
@ -242,7 +242,7 @@ namespace BSPF
|
||||||
|
|
||||||
// Find location (if any) of the second string within the first,
|
// Find location (if any) of the second string within the first,
|
||||||
// starting from 'startpos' in the first string
|
// starting from 'startpos' in the first string
|
||||||
static size_t findIgnoreCase(const string& s1, const string& s2, size_t startpos = 0)
|
static size_t findIgnoreCase(string_view s1, string_view s2, size_t startpos = 0)
|
||||||
{
|
{
|
||||||
auto pos = std::search(s1.cbegin()+startpos, s1.cend(),
|
auto pos = std::search(s1.cbegin()+startpos, s1.cend(),
|
||||||
s2.cbegin(), s2.cend(), [](char ch1, char ch2) {
|
s2.cbegin(), s2.cend(), [](char ch1, char ch2) {
|
||||||
|
@ -252,7 +252,7 @@ namespace BSPF
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test whether the first string contains the second one (case insensitive)
|
// Test whether the first string contains the second one (case insensitive)
|
||||||
inline bool containsIgnoreCase(const string& s1, const string& s2)
|
inline bool containsIgnoreCase(string_view s1, string_view s2)
|
||||||
{
|
{
|
||||||
return findIgnoreCase(s1, s2) != string::npos;
|
return findIgnoreCase(s1, s2) != string::npos;
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ namespace BSPF
|
||||||
// Test whether the first string matches the second one (case insensitive)
|
// Test whether the first string matches the second one (case insensitive)
|
||||||
// - the first character must match
|
// - the first character must match
|
||||||
// - the following characters must appear in the order of the first string
|
// - the following characters must appear in the order of the first string
|
||||||
inline bool matches(const string& s1, const string& s2)
|
inline bool matches(string_view s1, string_view s2)
|
||||||
{
|
{
|
||||||
if(startsWithIgnoreCase(s1, s2.substr(0, 1)))
|
if(startsWithIgnoreCase(s1, s2.substr(0, 1)))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue