diff options
author | nyamatongwe <devnull@localhost> | 2002-04-23 11:26:21 +0000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2002-04-23 11:26:21 +0000 |
commit | 3a99b5276b0037f1ed5e6e65870a12be02a5f991 (patch) | |
tree | 7253bf0970262c9b6eb7190d0eeb86dfe6b4c894 /include/SString.h | |
parent | 2b30ea35f7117bce7bd3936d5e8c7fadac87d072 (diff) | |
download | scintilla-mirror-3a99b5276b0037f1ed5e6e65870a12be02a5f991.tar.gz |
Don Paul Beletsky added substr and lowercase methods.
Diffstat (limited to 'include/SString.h')
-rw-r--r-- | include/SString.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/include/SString.h b/include/SString.h index d33d4c4fa..58f178b5b 100644 --- a/include/SString.h +++ b/include/SString.h @@ -92,6 +92,7 @@ public: sSize = sLen = (s) ? strlen(s) : 0; } SString(const char *s_, lenpos_t first, lenpos_t last) : sizeGrowth(sizeGrowthDefault) { + // note: expects the "last" argument to point one beyond the range end (a la STL iterators) s = StringAllocate(s_ + first, last - first); sSize = sLen = (s) ? strlen(s) : 0; } @@ -188,6 +189,27 @@ public: else return '\0'; } + SString substr(lenpos_t subPos, lenpos_t subLen=measure_length) const { + if (subPos >= sLen) { + return SString(); // return a null string if start index is out of bounds + } + if ((subLen == measure_length) || (subPos + subLen > sLen)) { + subLen = sLen - subPos; // can't substr past end of source string + } + return SString(s, subPos, subPos + subLen); + } + SString &lowercase(lenpos_t subPos = 0, lenpos_t subLen=measure_length) { + if ((subLen == measure_length) || (subPos + subLen > sLen)) { + subLen = sLen - subPos; // don't apply past end of string + } + for (unsigned int i = subPos; i < subPos + subLen; i++) { + if (s[i] < 'A' || s[i] > 'Z') + continue; + else + s[i] = static_cast<char>(s[i] - 'A' + 'a'); + } + return *this; + } SString &append(const char *sOther, lenpos_t sLenOther=measure_length, char sep = '\0') { if (!sOther) { return *this; |