WString explicit converters to reduce Flash size (#3497)

* WString explicit converters to reduce Flash size

This is a port from the same patch for ESP8266: https://github.com/esp8266/Arduino/pull/6759/files
This commit is contained in:
Clemens Kirchgatterer 2020-01-20 14:29:16 +01:00 committed by Me No Dev
parent 7de1717640
commit 36075257c2

View File

@ -203,8 +203,20 @@ class String {
unsigned char equalsIgnoreCase(const String &s) const; unsigned char equalsIgnoreCase(const String &s) const;
unsigned char equalsConstantTime(const String &s) const; unsigned char equalsConstantTime(const String &s) const;
unsigned char startsWith(const String &prefix) const; unsigned char startsWith(const String &prefix) const;
unsigned char startsWith(const char *prefix) const {
return this->startsWith(String(prefix));
}
unsigned char startsWith(const __FlashStringHelper *prefix) const {
return this->startsWith(String(prefix));
}
unsigned char startsWith(const String &prefix, unsigned int offset) const; unsigned char startsWith(const String &prefix, unsigned int offset) const;
unsigned char endsWith(const String &suffix) const; unsigned char endsWith(const String &suffix) const;
unsigned char endsWith(const char *suffix) const {
return this->endsWith(String(suffix));
}
unsigned char endsWith(const __FlashStringHelper * suffix) const {
return this->endsWith(String(suffix));
}
// character access // character access
char charAt(unsigned int index) const; char charAt(unsigned int index) const;
@ -238,7 +250,22 @@ class String {
// 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 replace(const char *find, const String &replace) {
this->replace(String(find), replace);
}
void replace(const __FlashStringHelper *find, const String &replace) {
this->replace(String(find), replace);
}
void replace(const char *find, const char *replace) {
this->replace(String(find), String(replace));
}
void replace(const __FlashStringHelper *find, const char *replace) {
this->replace(String(find), String(replace));
}
void replace(const __FlashStringHelper *find, const __FlashStringHelper *replace) {
this->replace(String(find), String(replace));
}
void remove(unsigned int index); void remove(unsigned int index);
void remove(unsigned int index, unsigned int count); void remove(unsigned int index, unsigned int count);
void toLowerCase(void); void toLowerCase(void);