diff options
author | nyamatongwe <devnull@localhost> | 2004-03-04 11:50:12 +0000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2004-03-04 11:50:12 +0000 |
commit | 8478222abdc5012ddc51713d2720cf571a3bc251 (patch) | |
tree | 43ab2370417e15544a8f99a72afc135d9bd46c7f /src | |
parent | a11744bf524da19d5627aca61b129569e8131d76 (diff) | |
download | scintilla-mirror-8478222abdc5012ddc51713d2720cf571a3bc251.tar.gz |
Added startswith and endswith methods to SString.
Diffstat (limited to 'src')
-rw-r--r-- | src/PropSet.cxx | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/PropSet.cxx b/src/PropSet.cxx index a1ed39da6..32ec59626 100644 --- a/src/PropSet.cxx +++ b/src/PropSet.cxx @@ -247,6 +247,22 @@ void SString::remove(lenpos_t pos, lenpos_t len) { } } +bool SString::startswith(const char *prefix) { + lenpos_t lenPrefix = strlen(prefix); + if (lenPrefix > sLen) { + return false; + } + return strncmp(s, prefix, lenPrefix) == 0; +} + +bool SString::endswith(const char *suffix) { + lenpos_t lenSuffix = strlen(suffix); + if (lenSuffix > sLen) { + return false; + } + return strncmp(s + sLen - lenSuffix, suffix, lenSuffix) == 0; +} + int SString::search(const char *sFind, lenpos_t start) const { if (start < sLen) { const char *sFound = strstr(s + start, sFind); |