[Scummvm-git-logs] scummvm master -> eb72d6b479e8b5b29b1662f9c4711ad2dd7a5c20
sev-
sev at scummvm.org
Fri Oct 18 00:28:54 CEST 2019
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
eb72d6b479 COMMON: Added String::find()
Commit: eb72d6b479e8b5b29b1662f9c4711ad2dd7a5c20
https://github.com/scummvm/scummvm/commit/eb72d6b479e8b5b29b1662f9c4711ad2dd7a5c20
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-10-18T00:28:36+02:00
Commit Message:
COMMON: Added String::find()
Changed paths:
common/str.cpp
common/str.h
diff --git a/common/str.cpp b/common/str.cpp
index aecbbf2..383a61a 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;
diff --git a/common/str.h b/common/str.h
index 54044cf..92cbc89 100644
--- a/common/str.h
+++ b/common/str.h
@@ -168,6 +168,8 @@ public:
bool contains(const char *x) const;
bool contains(char x) const;
+ uint32 find(const String &str, uint32 pos = 0) const;
+
/** Return uint64 corrensponding to String's contents. */
uint64 asUint64() const;
More information about the Scummvm-git-logs
mailing list