mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-02-20 13:54:14 +01:00
Added find_last_of() to SourceHook::String for searching the string backwards
--HG-- extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%40383
This commit is contained in:
parent
5a343e7f29
commit
bbb371c8d7
@ -153,6 +153,30 @@ public:
|
||||
return npos;
|
||||
}
|
||||
|
||||
int find_last_of(const char c, int index = npos) const
|
||||
{
|
||||
int len = static_cast<int>(size());
|
||||
if (len < 1)
|
||||
return npos;
|
||||
if (index >= len || index < npos)
|
||||
return npos;
|
||||
int i;
|
||||
if (index == npos)
|
||||
i = len - 1;
|
||||
else
|
||||
i = index;
|
||||
|
||||
for (; i>=0; i--)
|
||||
{
|
||||
if (v[i] == c)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return npos;
|
||||
}
|
||||
|
||||
bool is_space(int c) const
|
||||
{
|
||||
if (c == '\f' || c == '\n' ||
|
||||
|
Loading…
x
Reference in New Issue
Block a user