diff options
author | Jeff Brown <jeffbrown@google.com> | 2014-06-06 19:30:15 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2014-06-09 14:02:52 -0700 |
commit | 5ee915afe17b7190f992addc48cb53ed6371a68d (patch) | |
tree | b9d17977eac672201411fbb01c17bc4f16464aa5 /include/utils | |
parent | 45e2756409bee6b766fd965bd945f9d42789fb33 (diff) | |
download | system_core-5ee915afe17b7190f992addc48cb53ed6371a68d.zip system_core-5ee915afe17b7190f992addc48cb53ed6371a68d.tar.gz system_core-5ee915afe17b7190f992addc48cb53ed6371a68d.tar.bz2 |
Add a couple of useful string functions.
Change-Id: I158f69917bab5f15482dd8f2b66b36a4cc0f11ad
Diffstat (limited to 'include/utils')
-rw-r--r-- | include/utils/String8.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/utils/String8.h b/include/utils/String8.h index ef59470..ecfcf10 100644 --- a/include/utils/String8.h +++ b/include/utils/String8.h @@ -130,11 +130,19 @@ public: // start, or -1 if not found ssize_t find(const char* other, size_t start = 0) const; + // return true if this string contains the specified substring + inline bool contains(const char* other) const; + + // removes all occurrence of the specified substring + // returns true if any were found and removed + bool removeAll(const char* other); + void toLower(); void toLower(size_t start, size_t numChars); void toUpper(); void toUpper(size_t start, size_t numChars); + /* * These methods operate on the string as if it were a path name. */ @@ -280,6 +288,11 @@ inline const SharedBuffer* String8::sharedBuffer() const return SharedBuffer::bufferFromData(mString); } +inline bool String8::contains(const char* other) const +{ + return find(other) >= 0; +} + inline String8& String8::operator=(const String8& other) { setTo(other); |