aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMax Horn2009-06-07 13:04:03 +0000
committerMax Horn2009-06-07 13:04:03 +0000
commita39048877a0db397e8412e722af296e7c49643de (patch)
treeaaab76676aac9f9449bca183547eeb5b146cdd98 /common
parent985bc454b20f20f2eccb62a2f3000022ac0d2c99 (diff)
downloadscummvm-rg350-a39048877a0db397e8412e722af296e7c49643de.tar.gz
scummvm-rg350-a39048877a0db397e8412e722af296e7c49643de.tar.bz2
scummvm-rg350-a39048877a0db397e8412e722af296e7c49643de.zip
Added some new method variants to Common::String
svn-id: r41333
Diffstat (limited to 'common')
-rw-r--r--common/str.cpp12
-rw-r--r--common/str.h4
2 files changed, 16 insertions, 0 deletions
diff --git a/common/str.cpp b/common/str.cpp
index 3a3b1e610c..75394fcf89 100644
--- a/common/str.cpp
+++ b/common/str.cpp
@@ -294,6 +294,10 @@ String &String::operator +=(char c) {
return *this;
}
+bool String::hasPrefix(const String &x) const {
+ return hasPrefix(x.c_str());
+}
+
bool String::hasPrefix(const char *x) const {
assert(x != 0);
// Compare x with the start of _str.
@@ -307,6 +311,10 @@ bool String::hasPrefix(const char *x) const {
return *x == 0;
}
+bool String::hasSuffix(const String &x) const {
+ return hasSuffix(x.c_str());
+}
+
bool String::hasSuffix(const char *x) const {
assert(x != 0);
// Compare x with the end of _str.
@@ -323,6 +331,10 @@ bool String::hasSuffix(const char *x) const {
return *x == 0;
}
+bool String::contains(const String &x) const {
+ return strstr(c_str(), x.c_str()) != NULL;
+}
+
bool String::contains(const char *x) const {
assert(x != 0);
return strstr(c_str(), x) != NULL;
diff --git a/common/str.h b/common/str.h
index 4dc0f1be92..b7dbd6535a 100644
--- a/common/str.h
+++ b/common/str.h
@@ -143,9 +143,13 @@ public:
int compareTo(const char *x) const; // strcmp clone
int compareToIgnoreCase(const char *x) const; // stricmp clone
+ bool hasSuffix(const String &x) const;
bool hasSuffix(const char *x) const;
+
+ bool hasPrefix(const String &x) const;
bool hasPrefix(const char *x) const;
+ bool contains(const String &x) const;
bool contains(const char *x) const;
bool contains(char x) const;