22 #ifndef String_class_h 23 #define String_class_h 29 #include <avr/pgmspace.h> 37 class __FlashStringHelper;
38 #define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal))) 42 class StringSumHelper;
50 typedef void (String::*StringIfHelperType)()
const;
51 void StringIfHelper()
const {}
59 String(
const char *cstr =
"");
60 String(
const String &str);
61 String(
const __FlashStringHelper *str);
62 #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) 63 String(String &&rval);
64 String(StringSumHelper &&rval);
66 explicit String(
char c);
67 explicit String(
unsigned char,
unsigned char base=10);
68 explicit String(
int,
unsigned char base=10);
69 explicit String(
unsigned int,
unsigned char base=10);
70 explicit String(
long,
unsigned char base=10);
71 explicit String(
unsigned long,
unsigned char base=10);
72 explicit String(
float,
unsigned char decimalPlaces=2);
73 explicit String(
double,
unsigned char decimalPlaces=2);
80 unsigned char reserve(
unsigned int size);
81 inline unsigned int length(
void)
const {
return len;}
86 String & operator = (
const String &rhs);
87 String & operator = (
const char *cstr);
88 String & operator = (
const __FlashStringHelper *str);
89 #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) 90 String & operator = (String &&rval);
91 String & operator = (StringSumHelper &&rval);
99 unsigned char concat(
const String &str);
100 unsigned char concat(
const char *cstr);
101 unsigned char concat(
char c);
102 unsigned char concat(
unsigned char c);
103 unsigned char concat(
int num);
104 unsigned char concat(
unsigned int num);
105 unsigned char concat(
long num);
106 unsigned char concat(
unsigned long num);
107 unsigned char concat(
float num);
108 unsigned char concat(
double num);
109 unsigned char concat(
const __FlashStringHelper * str);
113 String &
operator += (
const String &rhs) {concat(rhs);
return (*
this);}
114 String &
operator += (
const char *cstr) {concat(cstr);
return (*
this);}
115 String &
operator += (
char c) {concat(c);
return (*
this);}
116 String &
operator += (
unsigned char num) {concat(num);
return (*
this);}
117 String &
operator += (
int num) {concat(num);
return (*
this);}
118 String &
operator += (
unsigned int num) {concat(num);
return (*
this);}
119 String &
operator += (
long num) {concat(num);
return (*
this);}
120 String &
operator += (
unsigned long num) {concat(num);
return (*
this);}
121 String &
operator += (
float num) {concat(num);
return (*
this);}
122 String &
operator += (
double num) {concat(num);
return (*
this);}
123 String &
operator += (
const __FlashStringHelper *str){concat(str);
return (*
this);}
125 friend StringSumHelper &
operator + (
const StringSumHelper &lhs,
const String &rhs);
126 friend StringSumHelper &
operator + (
const StringSumHelper &lhs,
const char *cstr);
127 friend StringSumHelper &
operator + (
const StringSumHelper &lhs,
char c);
128 friend StringSumHelper &
operator + (
const StringSumHelper &lhs,
unsigned char num);
129 friend StringSumHelper &
operator + (
const StringSumHelper &lhs,
int num);
130 friend StringSumHelper &
operator + (
const StringSumHelper &lhs,
unsigned int num);
131 friend StringSumHelper &
operator + (
const StringSumHelper &lhs,
long num);
132 friend StringSumHelper &
operator + (
const StringSumHelper &lhs,
unsigned long num);
133 friend StringSumHelper &
operator + (
const StringSumHelper &lhs,
float num);
134 friend StringSumHelper &
operator + (
const StringSumHelper &lhs,
double num);
135 friend StringSumHelper &
operator + (
const StringSumHelper &lhs,
const __FlashStringHelper *rhs);
138 operator StringIfHelperType()
const {
return buffer ? &String::StringIfHelper : 0; }
139 int compareTo(
const String &
s)
const;
140 unsigned char equals(
const String &
s)
const;
141 unsigned char equals(
const char *cstr)
const;
142 unsigned char operator == (
const String &rhs)
const {
return equals(rhs);}
143 unsigned char operator == (
const char *cstr)
const {
return equals(cstr);}
144 unsigned char operator != (
const String &rhs)
const {
return !equals(rhs);}
145 unsigned char operator != (
const char *cstr)
const {
return !equals(cstr);}
146 unsigned char operator < (
const String &rhs)
const;
147 unsigned char operator > (
const String &rhs)
const;
148 unsigned char operator <= (
const String &rhs)
const;
149 unsigned char operator >= (
const String &rhs)
const;
150 unsigned char equalsIgnoreCase(
const String &
s)
const;
151 unsigned char startsWith(
const String &prefix)
const;
152 unsigned char startsWith(
const String &prefix,
unsigned int offset)
const;
153 unsigned char endsWith(
const String &suffix)
const;
156 char charAt(
unsigned int index)
const;
157 void setCharAt(
unsigned int index,
char c);
158 char operator [] (
unsigned int index)
const;
159 char& operator [] (
unsigned int index);
160 void getBytes(
unsigned char *buf,
unsigned int bufsize,
unsigned int index=0)
const;
161 void toCharArray(
char *buf,
unsigned int bufsize,
unsigned int index=0)
const 162 { getBytes((
unsigned char *)buf, bufsize,
index); }
163 const char* c_str()
const {
return buffer; }
166 const char*
begin()
const {
return c_str(); }
167 const char*
end()
const {
return c_str() +
length(); }
170 int indexOf(
char ch )
const;
171 int indexOf(
char ch,
unsigned int fromIndex )
const;
172 int indexOf(
const String &str )
const;
173 int indexOf(
const String &str,
unsigned int fromIndex )
const;
174 int lastIndexOf(
char ch )
const;
175 int lastIndexOf(
char ch,
unsigned int fromIndex )
const;
176 int lastIndexOf(
const String &str )
const;
177 int lastIndexOf(
const String &str,
unsigned int fromIndex )
const;
178 String substring(
unsigned int beginIndex )
const {
return substring(beginIndex,
len); };
179 String substring(
unsigned int beginIndex,
unsigned int endIndex )
const;
182 void replace(
char find,
char replace);
183 void replace(
const String& find,
const String& replace);
184 void remove(
unsigned int index);
185 void remove(
unsigned int index,
unsigned int count);
191 long toInt(
void)
const;
192 float toFloat(
void)
const;
193 double toDouble(
void)
const;
197 unsigned int capacity;
201 void invalidate(
void);
202 unsigned char changeBuffer(
unsigned int maxStrLen);
203 unsigned char concat(
const char *cstr,
unsigned int length);
206 String & copy(
const char *cstr,
unsigned int length);
207 String & copy(
const __FlashStringHelper *pstr,
unsigned int length);
208 #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) 209 void move(String &rhs);
213 class StringSumHelper :
public String
216 StringSumHelper(
const String &
s) : String(s) {}
217 StringSumHelper(
const char *
p) : String(p) {}
218 StringSumHelper(
char c) : String(c) {}
219 StringSumHelper(
unsigned char num) : String(num) {}
220 StringSumHelper(
int num) : String(num) {}
221 StringSumHelper(
unsigned int num) : String(num) {}
222 StringSumHelper(
long num) : String(num) {}
223 StringSumHelper(
unsigned long num) : String(num) {}
224 StringSumHelper(
float num) : String(num) {}
225 StringSumHelper(
double num) : String(num) {}
228 #endif // __cplusplus 229 #endif // String_class_h GLuint GLsizei GLsizei * length
GLvoid *typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
int toLowerCase(int c) __attribute__((always_inline))
bool TOPO_IMPEXP operator!=(const TCoords &a, const TCoords &o)
EIGEN_STRONG_INLINE iterator begin()
bool TOPO_IMPEXP operator==(const TCoords &a, const TCoords &o)
std::vector< T1 > operator+(const std::vector< T1 > &a, const std::vector< T2 > &b)
int toUpperCase(int c) __attribute__((always_inline))
std::vector< T1 > & operator+=(std::vector< T1 > &a, const std::vector< T2 > &b)
std::string BASE_IMPEXP trim(const std::string &str)
GLuint GLuint GLsizei count
const T & move(const T &t)