COMMON: Added String::find()

This commit is contained in:
Eugene Sandulenko 2019-10-18 00:28:36 +02:00
parent 3ae526dfed
commit eb72d6b479
2 changed files with 27 additions and 0 deletions

View file

@ -605,6 +605,31 @@ void String::replace(uint32 posOri, uint32 countOri, const char *str,
}
uint32 String::find(const String &str, uint32 pos) const {
if (pos >= _size) {
return npos;
}
const char *strP = str.c_str();
for (const_iterator cur = begin() + pos; *cur; ++cur) {
uint i = 0;
while (true) {
if (!strP[i]) {
return cur - begin();
}
if (cur[i] != strP[i]) {
break;
}
++i;
}
}
return npos;
}
// static
String String::format(const char *fmt, ...) {
String output;