139 int icompare (const char* c); |
141 int icompare (const char* c); |
140 |
142 |
141 // Counts the amount of substrings in the string |
143 // Counts the amount of substrings in the string |
142 unsigned int count (char* s); |
144 unsigned int count (char* s); |
143 |
145 |
144 #if 0 |
146 array<str> split (str del); |
145 str** split (char* del); |
|
146 #endif |
|
147 |
147 |
148 // ====================================================================== |
148 // ====================================================================== |
149 // OPERATORS |
149 // OPERATORS |
150 str operator + (str& c); |
150 str operator+ (str& c) { |
151 str& operator += (char c); |
151 append (c); |
152 str& operator += (const char* c); |
152 return *this; |
153 str& operator += (const str c); |
153 } |
154 char operator [] (unsigned int pos); |
154 |
155 operator char* () const; |
155 str& operator+= (char c) { |
156 operator int () const; |
156 append (c); |
157 operator unsigned int () const; |
157 return *this; |
|
158 } |
|
159 |
|
160 str& operator+= (const char* c) { |
|
161 append (c); |
|
162 return *this; |
|
163 } |
|
164 |
|
165 str& operator+= (const str c) { |
|
166 append (c); |
|
167 return *this; |
|
168 } |
|
169 |
|
170 str operator* (const int repcount) { |
|
171 repeat (repcount); |
|
172 return *this; |
|
173 } |
|
174 |
|
175 str& operator*= (const int repcount) { |
|
176 repeat (repcount); |
|
177 return *this; |
|
178 } |
|
179 |
|
180 str operator- (const int trimcount) { |
|
181 trim (trimcount); |
|
182 return *this; |
|
183 } |
|
184 |
|
185 str& operator-= (const int trimcount) { |
|
186 trim (trimcount); |
|
187 return *this; |
|
188 } |
|
189 |
|
190 array<str> operator/ (str splitstring); |
|
191 array<str> operator/ (char* splitstring); |
|
192 array<str> operator/ (const char* splitstring); |
|
193 |
|
194 str operator+ () { |
|
195 return toupper (); |
|
196 } |
|
197 |
|
198 str operator- () { |
|
199 return tolower (); |
|
200 } |
|
201 |
|
202 str operator! () { |
|
203 reverse (); |
|
204 return *this; |
|
205 } |
|
206 |
|
207 #define DEFINE_OPERATOR_TYPE(OPER, TYPE) \ |
|
208 bool operator OPER (TYPE other) {return compare(other) OPER 0;} |
|
209 #define DEFINE_OPERATOR(OPER) \ |
|
210 DEFINE_OPERATOR_TYPE (OPER, str) \ |
|
211 DEFINE_OPERATOR_TYPE (OPER, char*) \ |
|
212 DEFINE_OPERATOR_TYPE (OPER, const char*) |
|
213 |
|
214 DEFINE_OPERATOR (==) |
|
215 DEFINE_OPERATOR (!=) |
|
216 DEFINE_OPERATOR (>) |
|
217 DEFINE_OPERATOR (<) |
|
218 DEFINE_OPERATOR (>=) |
|
219 DEFINE_OPERATOR (<=) |
|
220 |
|
221 char operator [] (unsigned int pos) { |
|
222 return text[pos]; |
|
223 } |
|
224 |
|
225 operator char* () const { |
|
226 return text; |
|
227 } |
|
228 |
|
229 operator int () const {return atoi(text);} |
|
230 operator unsigned int () const {return atoi(text);} |
158 }; |
231 }; |
159 |
232 |
160 #endif // __STR_H__ |
233 #endif // __STR_H__ |