54 #include "WiringFrameworkDependencies.h" 58 #define STRING_IRAM_ATTR // IRAM_ATTR 60 #ifndef __GXX_EXPERIMENTAL_CXX0X__ 61 #define __GXX_EXPERIMENTAL_CXX0X__ 79 class __FlashStringHelper;
80 typedef const __FlashStringHelper* flash_string_t;
83 #define FPSTR(pstr_pointer) reinterpret_cast<flash_string_t>(pstr_pointer) 90 #define F(string_literal) String(FPSTR(PSTR(string_literal)), sizeof(string_literal) - 1) 109 typedef void (
String::*StringIfHelperType)()
const;
110 void STRING_IRAM_ATTR StringIfHelper()
const {}
123 STRING_IRAM_ATTR
String(
const char *cstr =
nullptr);
124 STRING_IRAM_ATTR
String(
const char *cstr,
unsigned int length);
126 explicit String(flash_string_t pstr,
int length = -1);
129 #ifdef __GXX_EXPERIMENTAL_CXX0X__ 134 explicit String(
unsigned char,
unsigned char base = 10);
135 explicit String(
int,
unsigned char base = 10);
136 explicit String(
unsigned int,
unsigned char base = 10);
137 explicit String(
long,
unsigned char base = 10);
138 explicit String(
unsigned long,
unsigned char base = 10);
139 explicit String(
float,
unsigned char decimalPlaces=2);
140 explicit String(
double,
unsigned char decimalPlaces=2);
143 void setString(
const char *cstr,
int length = -1);
144 void setString(flash_string_t pstr,
int length = -1);
150 bool reserve(
unsigned int size);
159 inline unsigned int length(
void)
const 167 String & STRING_IRAM_ATTR operator = (
const String &rhs);
168 String & STRING_IRAM_ATTR operator = (
const char *cstr);
169 #ifdef __GXX_EXPERIMENTAL_CXX0X__ 179 bool concat(
const String &str);
180 bool concat(
const char *cstr);
181 bool STRING_IRAM_ATTR concat(
const char *cstr,
unsigned int length);
183 bool concat(
unsigned char c);
184 bool concat(
int num);
185 bool concat(
unsigned int num);
186 bool concat(
long num);
187 bool concat(
unsigned long num);
188 bool concat(
float num);
189 bool concat(
double num);
198 String & operator += (
const char *cstr)
203 String & operator += (
char c)
208 String & operator += (
unsigned char num)
213 String & operator += (
int num)
218 String & operator += (
unsigned int num)
223 String & operator += (
long num)
228 String & operator += (
unsigned long num)
233 String & operator += (
float num)
238 String & operator += (
double num)
256 operator StringIfHelperType()
const 258 return buffer ? &String::StringIfHelper : 0;
260 int STRING_IRAM_ATTR compareTo(
const String &s)
const;
261 bool STRING_IRAM_ATTR equals(
const String &s)
const;
262 bool STRING_IRAM_ATTR equals(
const char *cstr)
const;
265 bool STRING_IRAM_ATTR operator == (
const String &rhs)
const 269 bool STRING_IRAM_ATTR operator == (
const char *cstr)
const 273 bool STRING_IRAM_ATTR operator==(
const FlashString& fstr)
const 277 bool STRING_IRAM_ATTR operator != (
const String &rhs)
const 281 bool STRING_IRAM_ATTR operator != (
const char *cstr)
const 283 return !equals(cstr);
285 bool operator < (
const String &rhs)
const;
286 bool operator > (
const String &rhs)
const;
287 bool operator <= (
const String &rhs)
const;
288 bool operator >= (
const String &rhs)
const;
289 bool equalsIgnoreCase(
const char* cstr)
const;
290 bool equalsIgnoreCase(
const String &s2)
const;
291 bool equalsIgnoreCase(
const FlashString& fstr)
const;
292 bool startsWith(
const String &prefix)
const;
293 bool startsWith(
const String &prefix,
unsigned int offset)
const;
294 bool endsWith(
const String &suffix)
const;
297 char STRING_IRAM_ATTR charAt(
unsigned int index)
const;
298 void STRING_IRAM_ATTR setCharAt(
unsigned int index,
char c);
299 char STRING_IRAM_ATTR operator [](
unsigned int index)
const;
300 char& STRING_IRAM_ATTR operator [](
unsigned int index);
310 unsigned int getBytes(
unsigned char *buf,
unsigned int bufsize,
unsigned int index = 0)
const;
312 void toCharArray(
char *buf,
unsigned int bufsize,
unsigned int index = 0)
const 314 getBytes((
unsigned char *)buf, bufsize, index);
316 const char* c_str()
const {
return buffer ?: empty.buffer; }
317 char* begin() {
return buffer; }
318 char* end() {
return buffer + length(); }
319 const char* begin()
const {
return c_str(); }
320 const char* end()
const {
return c_str() + length(); }
323 int STRING_IRAM_ATTR indexOf(
char ch)
const;
324 int indexOf(
char ch,
unsigned int fromIndex)
const;
325 int STRING_IRAM_ATTR indexOf(
const String &str)
const;
326 int indexOf(
const String &s2,
unsigned int fromIndex)
const;
327 int lastIndexOf(
char ch)
const;
328 int lastIndexOf(
char ch,
unsigned int fromIndex)
const;
329 int lastIndexOf(
const String &s2)
const;
330 int lastIndexOf(
const String &s2,
unsigned int fromIndex)
const;
331 String substring(
unsigned int beginIndex)
const {
return substring(beginIndex, len); }
332 String substring(
unsigned int beginIndex,
unsigned int endIndex)
const;
335 void replace(
char find,
char replace);
336 void replace(
const String& find,
const String& replace);
337 void remove(
unsigned int index);
338 void remove(
unsigned int index,
unsigned int count);
339 void toLowerCase(
void);
340 void toUpperCase(
void);
344 long toInt(
void)
const;
345 float toFloat(
void)
const;
352 char *buffer =
nullptr;
353 uint16_t capacity = 0;
358 void STRING_IRAM_ATTR invalidate(
void);
359 bool STRING_IRAM_ATTR changeBuffer(
unsigned int maxStrLen);
362 String & copy(
const char *cstr,
unsigned int length);
363 String& copy(flash_string_t pstr,
unsigned int length);
364 #ifdef __GXX_EXPERIMENTAL_CXX0X__ 384 #include "FlashString.h" 385 #include "SplitString.h" 387 #endif // __cplusplus bool setLength(unsigned int length)
set the string length accordingly, expanding if necessary
static const String empty
An empty string evaluates to true.
Definition: WString.h:115
describes a counted string stored in flash memory
Definition: FlashString.h:171
The string class.
Definition: WString.h:104
static const String nullstr
A null string evaluates to false.
Definition: WString.h:114
unsigned int getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index=0) const
read contents of string into a buffer
Definition: WString.h:369