Added remove methods to WString

This commit is contained in:
Ryan Esteves 2013-06-05 14:08:59 -04:00
parent ef4e8c6537
commit 6bef2ada06
2 changed files with 18 additions and 0 deletions

View File

@ -604,6 +604,22 @@ void String::replace(const String& find, const String& replace)
}
}
void String::remove(unsigned int index){
if (index >= len) { return; }
int count = len - index;
remove(index, count);
}
void String::remove(unsigned int index, unsigned int count){
if (index >= len) { return; }
if (count <= 0) { return; }
if (index + count > len) { count = len - index; }
char *writeTo = buffer + index;
len = len - count;
strncpy(writeTo, buffer + index + count,len - index);
buffer[len] = 0;
}
void String::toLowerCase(void)
{
if (!buffer) return;

View File

@ -164,6 +164,8 @@ public:
// modification
void replace(char find, char replace);
void replace(const String& find, const String& replace);
void remove(unsigned int index);
void remove(unsigned int index, unsigned int count);
void toLowerCase(void);
void toUpperCase(void);
void trim(void);