54 friend class StringSumHelper;
58 typedef void (String::*StringIfHelperType)()
const;
59 void StringIfHelper()
const {}
61 static size_t const FLT_MAX_DECIMAL_PLACES = 10;
62 static size_t const DBL_MAX_DECIMAL_PLACES = FLT_MAX_DECIMAL_PLACES;
70 String(
const char *cstr =
"");
71 String(
const char *cstr,
unsigned int length);
72 String(
const uint8_t *cstr,
unsigned int length) : String((
const char*)cstr, length) {}
73 String(
const String &str);
74 String(
const __FlashStringHelper *str);
75 String(String &&rval);
76 explicit String(
char c);
77 explicit String(
unsigned char,
unsigned char base=10);
78 explicit String(
int,
unsigned char base=10);
79 explicit String(
unsigned int,
unsigned char base=10);
80 explicit String(
long,
unsigned char base=10);
81 explicit String(
unsigned long,
unsigned char base=10);
82 explicit String(
float,
unsigned char decimalPlaces=2);
83 explicit String(
double,
unsigned char decimalPlaces=2);
90 bool reserve(
unsigned int size);
91 inline unsigned int length(
void)
const {
return len;}
92 inline bool isEmpty(
void)
const {
return length() == 0; }
97 String & operator = (
const String &rhs);
98 String & operator = (
const char *cstr);
99 String & operator = (
const __FlashStringHelper *str);
100 String & operator = (String &&rval);
107 bool concat(
const String &str);
108 bool concat(
const char *cstr);
109 bool concat(
const char *cstr,
unsigned int length);
110 bool concat(
const uint8_t *cstr,
unsigned int length) {
return concat((
const char*)cstr, length);}
112 bool concat(
unsigned char num);
113 bool concat(
int num);
114 bool concat(
unsigned int num);
115 bool concat(
long num);
116 bool concat(
unsigned long num);
117 bool concat(
float num);
118 bool concat(
double num);
119 bool concat(
const __FlashStringHelper * str);
123 String & operator += (
const String &rhs) {concat(rhs);
return (*
this);}
124 String & operator += (
const char *cstr) {concat(cstr);
return (*
this);}
125 String & operator += (
char c) {concat(c);
return (*
this);}
126 String & operator += (
unsigned char num) {concat(num);
return (*
this);}
127 String & operator += (
int num) {concat(num);
return (*
this);}
128 String & operator += (
unsigned int num) {concat(num);
return (*
this);}
129 String & operator += (
long num) {concat(num);
return (*
this);}
130 String & operator += (
unsigned long num) {concat(num);
return (*
this);}
131 String & operator += (
float num) {concat(num);
return (*
this);}
132 String & operator += (
double num) {concat(num);
return (*
this);}
133 String & operator += (
const __FlashStringHelper *str){concat(str);
return (*
this);}
135 friend StringSumHelper & operator + (
const StringSumHelper &lhs,
const String &rhs);
136 friend StringSumHelper & operator + (
const StringSumHelper &lhs,
const char *cstr);
137 friend StringSumHelper & operator + (
const StringSumHelper &lhs,
char c);
138 friend StringSumHelper & operator + (
const StringSumHelper &lhs,
unsigned char num);
139 friend StringSumHelper & operator + (
const StringSumHelper &lhs,
int num);
140 friend StringSumHelper & operator + (
const StringSumHelper &lhs,
unsigned int num);
141 friend StringSumHelper & operator + (
const StringSumHelper &lhs,
long num);
142 friend StringSumHelper & operator + (
const StringSumHelper &lhs,
unsigned long num);
143 friend StringSumHelper & operator + (
const StringSumHelper &lhs,
float num);
144 friend StringSumHelper & operator + (
const StringSumHelper &lhs,
double num);
145 friend StringSumHelper & operator + (
const StringSumHelper &lhs,
const __FlashStringHelper *rhs);
148 operator StringIfHelperType()
const {
return buffer ? &String::StringIfHelper : 0; }
149 int compareTo(
const String &s)
const;
150 int compareTo(
const char *cstr)
const;
151 bool equals(
const String &s)
const;
152 bool equals(
const char *cstr)
const;
154 friend bool operator == (
const String &a,
const String &b) {
return a.equals(b); }
155 friend bool operator == (
const String &a,
const char *b) {
return a.equals(b); }
156 friend bool operator == (
const char *a,
const String &b) {
return b == a; }
157 friend bool operator < (
const String &a,
const String &b) {
return a.compareTo(b) < 0; }
158 friend bool operator < (
const String &a,
const char *b) {
return a.compareTo(b) < 0; }
159 friend bool operator < (
const char *a,
const String &b) {
return b.compareTo(a) > 0; }
161 friend bool operator != (
const String &a,
const String &b) {
return !(a == b); }
162 friend bool operator != (
const String &a,
const char *b) {
return !(a == b); }
163 friend bool operator != (
const char *a,
const String &b) {
return !(a == b); }
164 friend bool operator > (
const String &a,
const String &b) {
return b < a; }
165 friend bool operator > (
const String &a,
const char *b) {
return b < a; }
166 friend bool operator > (
const char *a,
const String &b) {
return b < a; }
167 friend bool operator <= (
const String &a,
const String &b) {
return !(b < a); }
168 friend bool operator <= (
const String &a,
const char *b) {
return !(b < a); }
169 friend bool operator <= (
const char *a,
const String &b) {
return !(b < a); }
170 friend bool operator >= (
const String &a,
const String &b) {
return !(a < b); }
171 friend bool operator >= (
const String &a,
const char *b) {
return !(a < b); }
172 friend bool operator >= (
const char *a,
const String &b) {
return !(a < b); }
174 bool equalsIgnoreCase(
const String &s)
const;
175 bool startsWith(
const String &prefix)
const;
176 bool startsWith(
const String &prefix,
unsigned int offset)
const;
177 bool endsWith(
const String &suffix)
const;
180 char charAt(
unsigned int index)
const;
181 void setCharAt(
unsigned int index,
char c);
182 char operator [] (
unsigned int index)
const;
183 char& operator [] (
unsigned int index);
184 void getBytes(
unsigned char *buf,
unsigned int bufsize,
unsigned int index=0)
const;
185 void toCharArray(
char *buf,
unsigned int bufsize,
unsigned int index=0)
const
186 { getBytes((
unsigned char *)buf, bufsize, index); }
187 const char* c_str()
const {
return buffer; }
188 char* begin() {
return buffer; }
189 char* end() {
return buffer + length(); }
190 const char* begin()
const {
return c_str(); }
191 const char* end()
const {
return c_str() + length(); }
194 int indexOf(
char ch )
const;
195 int indexOf(
char ch,
unsigned int fromIndex )
const;
196 int indexOf(
const String &str )
const;
197 int indexOf(
const String &str,
unsigned int fromIndex )
const;
198 int lastIndexOf(
char ch )
const;
199 int lastIndexOf(
char ch,
unsigned int fromIndex )
const;
200 int lastIndexOf(
const String &str )
const;
201 int lastIndexOf(
const String &str,
unsigned int fromIndex )
const;
202 String substring(
unsigned int beginIndex )
const {
return substring(beginIndex, len); };
203 String substring(
unsigned int beginIndex,
unsigned int endIndex )
const;
206 void replace(
char find,
char replace);
207 void replace(
const String& find,
const String& replace);
208 void remove(
unsigned int index);
209 void remove(
unsigned int index,
unsigned int count);
210 void toLowerCase(
void);
211 void toUpperCase(
void);
215 long toInt(
void)
const;
216 float toFloat(
void)
const;
217 double toDouble(
void)
const;
221 unsigned int capacity;
225 void invalidate(
void);
226 bool changeBuffer(
unsigned int maxStrLen);
229 String & copy(
const char *cstr,
unsigned int length);
230 String & copy(
const __FlashStringHelper *pstr,
unsigned int length);
231 void move(String &rhs);