Added some new method variants to Common::String
svn-id: r41333
This commit is contained in:
parent
985bc454b2
commit
a39048877a
3 changed files with 19 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue