Added remove methods to WString
This commit is contained in:
parent
ef4e8c6537
commit
6bef2ada06
|
@ -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)
|
void String::toLowerCase(void)
|
||||||
{
|
{
|
||||||
if (!buffer) return;
|
if (!buffer) return;
|
||||||
|
|
|
@ -164,6 +164,8 @@ public:
|
||||||
// modification
|
// modification
|
||||||
void replace(char find, char replace);
|
void replace(char find, char replace);
|
||||||
void replace(const String& find, const String& 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 toLowerCase(void);
|
||||||
void toUpperCase(void);
|
void toUpperCase(void);
|
||||||
void trim(void);
|
void trim(void);
|
||||||
|
|
Loading…
Reference in New Issue