aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkString.h
diff options
context:
space:
mode:
authorGravatar epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-04-27 17:11:31 +0000
committerGravatar epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-04-27 17:11:31 +0000
commitc4ae974db67977e766b66fb42e58e088c6381e29 (patch)
treefdded56573d2214abed88d8f0a83bcf22e54504e /include/core/SkString.h
parent8d033a1b125886c62906d975b5cc28a382064526 (diff)
Add SkString.contains()
Review URL: https://codereview.appspot.com/6130046 git-svn-id: http://skia.googlecode.com/svn/trunk@3781 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkString.h')
-rw-r--r--include/core/SkString.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/include/core/SkString.h b/include/core/SkString.h
index 3fa367b859..3dd89a5c9a 100644
--- a/include/core/SkString.h
+++ b/include/core/SkString.h
@@ -15,9 +15,18 @@
/* Some helper functions for C strings
*/
-bool SkStrStartsWith(const char string[], const char prefix[]);
+static bool SkStrStartsWith(const char string[], const char prefix[]) {
+ SkASSERT(string);
+ SkASSERT(prefix);
+ return !strncmp(string, prefix, strlen(prefix));
+}
bool SkStrEndsWith(const char string[], const char suffix[]);
int SkStrStartsWithOneOf(const char string[], const char prefixes[]);
+static bool SkStrContains(const char string[], const char substring[]) {
+ SkASSERT(string);
+ SkASSERT(substring);
+ return (NULL != strstr(string, substring));
+}
#define SkStrAppendS32_MaxSize 11
char* SkStrAppendS32(char buffer[], int32_t);
@@ -81,6 +90,9 @@ public:
bool endsWith(const char suffix[]) const {
return SkStrEndsWith(fRec->data(), suffix);
}
+ bool contains(const char substring[]) const {
+ return SkStrContains(fRec->data(), substring);
+ }
friend bool operator==(const SkString& a, const SkString& b) {
return a.equals(b);