aboutsummaryrefslogtreecommitdiff
path: root/common/ustr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/ustr.cpp')
-rw-r--r--common/ustr.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/common/ustr.cpp b/common/ustr.cpp
index c53c4286f7..3a78239cb6 100644
--- a/common/ustr.cpp
+++ b/common/ustr.cpp
@@ -232,6 +232,30 @@ void U32String::deleteChar(uint32 p) {
_size--;
}
+void U32String::deleteLastChar() {
+ if (_size > 0)
+ deleteChar(_size - 1);
+}
+
+void U32String::erase(uint32 p, uint32 len) {
+ assert(p < _size);
+
+ makeUnique();
+ // If len == npos or p + len is over the end, remove all the way to the end
+ if (len == npos || p + len >= _size) {
+ // Delete char at p as well. So _size = (p - 1) + 1
+ _size = p;
+ // Null terminate
+ _str[_size] = 0;
+ return;
+ }
+
+ for ( ; p + len <= _size; p++) {
+ _str[p] = _str[p + len];
+ }
+ _size -= len;
+}
+
void U32String::clear() {
decRefCount(_extern._refCount);