mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-18 07:52:14 +01:00
Added remove methods to WString
This commit is contained in:
parent
22320dbc07
commit
0778f8a3f3
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user