From 6bef2ada0627be776e463661ccbcdeba5a373f3a Mon Sep 17 00:00:00 2001 From: Ryan Esteves Date: Wed, 5 Jun 2013 14:08:59 -0400 Subject: Added remove methods to WString --- cores/arduino/WString.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'cores/arduino/WString.cpp') diff --git a/cores/arduino/WString.cpp b/cores/arduino/WString.cpp index c6839fc..aab2a54 100644 --- a/cores/arduino/WString.cpp +++ b/cores/arduino/WString.cpp @@ -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; -- cgit v1.2.3-18-g5258