diff options
author | Eugene Sandulenko | 2019-10-18 00:28:36 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2019-10-18 00:28:36 +0200 |
commit | eb72d6b479e8b5b29b1662f9c4711ad2dd7a5c20 (patch) | |
tree | 77a43bcbfd0a3aae58af978d97e2eb950227db12 /common/str.cpp | |
parent | 3ae526dfed510c33a55a9f19b8ccba8e97d13f79 (diff) | |
download | scummvm-rg350-eb72d6b479e8b5b29b1662f9c4711ad2dd7a5c20.tar.gz scummvm-rg350-eb72d6b479e8b5b29b1662f9c4711ad2dd7a5c20.tar.bz2 scummvm-rg350-eb72d6b479e8b5b29b1662f9c4711ad2dd7a5c20.zip |
COMMON: Added String::find()
Diffstat (limited to 'common/str.cpp')
-rw-r--r-- | common/str.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/common/str.cpp b/common/str.cpp index aecbbf2574..383a61a687 100644 --- a/common/str.cpp +++ b/common/str.cpp @@ -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; |