29#include <avr/pgmspace.h>
37class __FlashStringHelper;
38#define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))
49 typedef void (String::*StringIfHelperType)()
const;
50 void StringIfHelper()
const {}
58 String(
const char *cstr =
"");
59 String(
const String &str);
60 String(
const __FlashStringHelper *str);
61#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
62 String(String &&rval);
63 String(StringSumHelper &&rval);
65 explicit String(
char c);
66 explicit String(
unsigned char,
unsigned char base = 10);
67 explicit String(
int,
unsigned char base = 10);
68 explicit String(
unsigned int,
unsigned char base = 10);
69 explicit String(
long,
unsigned char base = 10);
70 explicit String(
unsigned long,
unsigned char base = 10);
71 explicit String(
float,
unsigned char decimalPlaces = 2);
72 explicit String(
double,
unsigned char decimalPlaces = 2);
79 unsigned char reserve(
unsigned int size);
80 inline unsigned int length(
void)
const
88 String &operator = (
const String &rhs);
89 String &operator = (
const char *cstr);
90 String &operator = (
const __FlashStringHelper *str);
91#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
92 String &operator = (String &&rval);
93 String &operator = (StringSumHelper &&rval);
101 unsigned char concat(
const String &str);
102 unsigned char concat(
const char *cstr);
103 unsigned char concat(
char c);
104 unsigned char concat(
unsigned char c);
105 unsigned char concat(
int num);
106 unsigned char concat(
unsigned int num);
107 unsigned char concat(
long num);
108 unsigned char concat(
unsigned long num);
109 unsigned char concat(
float num);
110 unsigned char concat(
double num);
111 unsigned char concat(
const __FlashStringHelper *str);
115 String &operator += (
const String &rhs)
120 String &operator += (
const char *cstr)
125 String &operator += (
char c)
130 String &operator += (
unsigned char num)
135 String &operator += (
int num)
140 String &operator += (
unsigned int num)
145 String &operator += (
long num)
150 String &operator += (
unsigned long num)
155 String &operator += (
float num)
160 String &operator += (
double num)
165 String &operator += (
const __FlashStringHelper *str)
171 friend StringSumHelper &operator + (
const StringSumHelper &lhs,
const String &rhs);
172 friend StringSumHelper &operator + (
const StringSumHelper &lhs,
const char *cstr);
173 friend StringSumHelper &operator + (
const StringSumHelper &lhs,
char c);
174 friend StringSumHelper &operator + (
const StringSumHelper &lhs,
unsigned char num);
175 friend StringSumHelper &operator + (
const StringSumHelper &lhs,
int num);
176 friend StringSumHelper &operator + (
const StringSumHelper &lhs,
unsigned int num);
177 friend StringSumHelper &operator + (
const StringSumHelper &lhs,
long num);
178 friend StringSumHelper &operator + (
const StringSumHelper &lhs,
unsigned long num);
179 friend StringSumHelper &operator + (
const StringSumHelper &lhs,
float num);
180 friend StringSumHelper &operator + (
const StringSumHelper &lhs,
double num);
181 friend StringSumHelper &operator + (
const StringSumHelper &lhs,
const __FlashStringHelper *rhs);
184 operator StringIfHelperType()
const
186 return buffer ? &String::StringIfHelper : 0;
188 int compareTo(
const String &s)
const;
189 unsigned char equals(
const String &s)
const;
190 unsigned char equals(
const char *cstr)
const;
191 unsigned char operator == (
const String &rhs)
const
195 unsigned char operator == (
const char *cstr)
const
199 unsigned char operator != (
const String &rhs)
const
203 unsigned char operator != (
const char *cstr)
const
205 return !equals(cstr);
207 unsigned char operator < (
const String &rhs)
const;
208 unsigned char operator > (
const String &rhs)
const;
209 unsigned char operator <= (
const String &rhs)
const;
210 unsigned char operator >= (
const String &rhs)
const;
211 unsigned char equalsIgnoreCase(
const String &s)
const;
212 unsigned char startsWith(
const String &prefix)
const;
213 unsigned char startsWith(
const String &prefix,
unsigned int offset)
const;
214 unsigned char endsWith(
const String &suffix)
const;
217 char charAt(
unsigned int index)
const;
218 void setCharAt(
unsigned int index,
char c);
219 char operator [](
unsigned int index)
const;
220 char &operator [](
unsigned int index);
221 void getBytes(
unsigned char *buf,
unsigned int bufsize,
unsigned int index = 0)
const;
222 void toCharArray(
char *buf,
unsigned int bufsize,
unsigned int index = 0)
const
224 getBytes((
unsigned char *)buf, bufsize, index);
226 const char *c_str()
const
236 return buffer + length();
238 const char *begin()
const
242 const char *end()
const
244 return c_str() + length();
248 int indexOf(
char ch)
const;
249 int indexOf(
char ch,
unsigned int fromIndex)
const;
250 int indexOf(
const String &str)
const;
251 int indexOf(
const String &str,
unsigned int fromIndex)
const;
252 int lastIndexOf(
char ch)
const;
253 int lastIndexOf(
char ch,
unsigned int fromIndex)
const;
254 int lastIndexOf(
const String &str)
const;
255 int lastIndexOf(
const String &str,
unsigned int fromIndex)
const;
256 String substring(
unsigned int beginIndex)
const
258 return substring(beginIndex, len);
260 String substring(
unsigned int beginIndex,
unsigned int endIndex)
const;
263 void replace(
char find,
char replace);
264 void replace(
const String &find,
const String &replace);
265 void remove(
unsigned int index);
266 void remove(
unsigned int index,
unsigned int count);
267 void toLowerCase(
void);
268 void toUpperCase(
void);
272 long toInt(
void)
const;
273 float toFloat(
void)
const;
274 double toDouble(
void)
const;
278 unsigned int capacity;
282 void invalidate(
void);
283 unsigned char changeBuffer(
unsigned int maxStrLen);
284 unsigned char concat(
const char *cstr,
unsigned int length);
287 String ©(
const char *cstr,
unsigned int length);
288 String ©(
const __FlashStringHelper *pstr,
unsigned int length);
289#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
290 void move(String &rhs);
294class StringSumHelper :
public String {
296 StringSumHelper(
const String &s) : String(s) {}
297 StringSumHelper(
const char *p) : String(p) {}
298 StringSumHelper(
char c) : String(c) {}
299 StringSumHelper(
unsigned char num) : String(num) {}
300 StringSumHelper(
int num) : String(num) {}
301 StringSumHelper(
unsigned int num) : String(num) {}
302 StringSumHelper(
long num) : String(num) {}
303 StringSumHelper(
unsigned long num) : String(num) {}
304 StringSumHelper(
float num) : String(num) {}
305 StringSumHelper(
double num) : String(num) {}