141 |
141 |
142 METHOD join (const String& delim) -> String; |
142 METHOD join (const String& delim) -> String; |
143 }; |
143 }; |
144 |
144 |
145 // ------------------------------------------------------------------------------------------------- |
145 // ------------------------------------------------------------------------------------------------- |
146 |
146 // |
147 inline FUNCTION operator== (const char* a, const String& b) -> bool; |
147 inline FUNCTION operator== (const char* a, const String& b) -> bool; |
148 inline FUNCTION operator+ (const char* a, const String& b) -> String; |
148 inline FUNCTION operator+ (const char* a, const String& b) -> String; |
149 |
149 |
150 // ------------------------------------------------------------------------------------------------- |
150 // ------------------------------------------------------------------------------------------------- |
151 |
151 // |
152 inline METHOD |
152 inline METHOD |
153 String::is_empty() const -> bool |
153 String::is_empty() const -> bool |
154 { |
154 { |
155 return m_string[0] == '\0'; |
155 return m_string[0] == '\0'; |
156 } |
156 } |
157 |
157 |
158 // ------------------------------------------------------------------------------------------------- |
158 // ------------------------------------------------------------------------------------------------- |
159 |
159 // |
160 inline METHOD |
160 inline METHOD |
161 String::append (const char* data) -> void |
161 String::append (const char* data) -> void |
162 { |
162 { |
163 m_string.append (data); |
163 m_string.append (data); |
164 } |
164 } |
165 |
165 |
166 // ------------------------------------------------------------------------------------------------- |
166 // ------------------------------------------------------------------------------------------------- |
167 |
167 // |
168 inline METHOD |
168 inline METHOD |
169 String::append (char data) -> void |
169 String::append (char data) -> void |
170 { |
170 { |
171 m_string.push_back (data); |
171 m_string.push_back (data); |
172 } |
172 } |
173 |
173 |
174 // ------------------------------------------------------------------------------------------------- |
174 // ------------------------------------------------------------------------------------------------- |
175 |
175 // |
176 inline METHOD |
176 inline METHOD |
177 String::append (const String& data) -> void |
177 String::append (const String& data) -> void |
178 { |
178 { |
179 m_string.append (data.chars()); |
179 m_string.append (data.chars()); |
180 } |
180 } |
181 |
181 |
182 // ------------------------------------------------------------------------------------------------- |
182 // ------------------------------------------------------------------------------------------------- |
183 |
183 // |
184 inline METHOD |
184 inline METHOD |
185 String::begin() -> std::string::iterator |
185 String::begin() -> std::string::iterator |
186 { |
186 { |
187 return m_string.begin(); |
187 return m_string.begin(); |
188 } |
188 } |
189 |
189 |
190 // ------------------------------------------------------------------------------------------------- |
190 // ------------------------------------------------------------------------------------------------- |
191 |
191 // |
192 inline METHOD |
192 inline METHOD |
193 String::begin() const -> std::string::const_iterator |
193 String::begin() const -> std::string::const_iterator |
194 { |
194 { |
195 return m_string.cbegin(); |
195 return m_string.cbegin(); |
196 } |
196 } |
197 |
197 |
198 // ------------------------------------------------------------------------------------------------- |
198 // ------------------------------------------------------------------------------------------------- |
199 |
199 // |
200 inline const char* String::chars() const |
200 inline const char* String::chars() const |
201 { |
201 { |
202 return m_string.c_str(); |
202 return m_string.c_str(); |
203 } |
203 } |
204 |
204 |
205 // ------------------------------------------------------------------------------------------------- |
205 // ------------------------------------------------------------------------------------------------- |
206 |
206 // |
207 inline METHOD |
207 inline METHOD |
208 String::end() -> std::string::iterator |
208 String::end() -> std::string::iterator |
209 { |
209 { |
210 return m_string.end(); |
210 return m_string.end(); |
211 } |
211 } |
212 |
212 |
213 // ------------------------------------------------------------------------------------------------- |
213 // ------------------------------------------------------------------------------------------------- |
214 |
214 // |
215 inline METHOD |
215 inline METHOD |
216 String::end() const -> std::string::const_iterator |
216 String::end() const -> std::string::const_iterator |
217 { |
217 { |
218 return m_string.end(); |
218 return m_string.end(); |
219 } |
219 } |
220 |
220 |
221 // ------------------------------------------------------------------------------------------------- |
221 // ------------------------------------------------------------------------------------------------- |
222 |
222 // |
223 inline METHOD |
223 inline METHOD |
224 String::clear() -> void |
224 String::clear() -> void |
225 { |
225 { |
226 m_string.clear(); |
226 m_string.clear(); |
227 } |
227 } |
228 |
228 |
229 // ------------------------------------------------------------------------------------------------- |
229 // ------------------------------------------------------------------------------------------------- |
230 |
230 // |
231 inline METHOD |
231 inline METHOD |
232 String::remove_at (int pos) -> void |
232 String::remove_at (int pos) -> void |
233 { |
233 { |
234 m_string.erase (m_string.begin() + pos); |
234 m_string.erase (m_string.begin() + pos); |
235 } |
235 } |
236 |
236 |
237 // ------------------------------------------------------------------------------------------------- |
237 // ------------------------------------------------------------------------------------------------- |
238 |
238 // |
239 inline METHOD |
239 inline METHOD |
240 String::insert (int pos, char c) -> void |
240 String::insert (int pos, char c) -> void |
241 { |
241 { |
242 m_string.insert (m_string.begin() + pos, c); |
242 m_string.insert (m_string.begin() + pos, c); |
243 } |
243 } |
249 { |
249 { |
250 m_string.insert (pos, c); |
250 m_string.insert (pos, c); |
251 } |
251 } |
252 |
252 |
253 // ------------------------------------------------------------------------------------------------- |
253 // ------------------------------------------------------------------------------------------------- |
254 |
254 // |
255 inline METHOD |
255 inline METHOD |
256 String::length() const -> int |
256 String::length() const -> int |
257 { |
257 { |
258 return m_string.length(); |
258 return m_string.length(); |
259 } |
259 } |
260 |
260 |
261 // ------------------------------------------------------------------------------------------------- |
261 // ------------------------------------------------------------------------------------------------- |
262 |
262 // |
263 inline METHOD |
263 inline METHOD |
264 String::remove (int pos, int len) -> void |
264 String::remove (int pos, int len) -> void |
265 { |
265 { |
266 m_string.replace (pos, len, ""); |
266 m_string.replace (pos, len, ""); |
267 } |
267 } |
268 |
268 |
269 // ------------------------------------------------------------------------------------------------- |
269 // ------------------------------------------------------------------------------------------------- |
270 |
270 // |
271 inline METHOD |
271 inline METHOD |
272 String::remove_from_start (int len) -> void |
272 String::remove_from_start (int len) -> void |
273 { |
273 { |
274 remove (0, len); |
274 remove (0, len); |
275 } |
275 } |
276 |
276 |
277 // ------------------------------------------------------------------------------------------------- |
277 // ------------------------------------------------------------------------------------------------- |
278 |
278 // |
279 inline METHOD |
279 inline METHOD |
280 String::remove_from_end (int len) -> void |
280 String::remove_from_end (int len) -> void |
281 { |
281 { |
282 remove (length() - len, len); |
282 remove (length() - len, len); |
283 } |
283 } |
284 |
284 |
285 // ------------------------------------------------------------------------------------------------- |
285 // ------------------------------------------------------------------------------------------------- |
286 |
286 // |
287 inline METHOD |
287 inline METHOD |
288 String::replace (int pos, int n, const String& a) -> void |
288 String::replace (int pos, int n, const String& a) -> void |
289 { |
289 { |
290 m_string.replace (pos, n, a.chars()); |
290 m_string.replace (pos, n, a.chars()); |
291 } |
291 } |
292 |
292 |
293 // ------------------------------------------------------------------------------------------------- |
293 // ------------------------------------------------------------------------------------------------- |
294 |
294 // |
295 inline METHOD |
295 inline METHOD |
296 String::shrink_to_fit() -> void |
296 String::shrink_to_fit() -> void |
297 { |
297 { |
298 m_string.shrink_to_fit(); |
298 m_string.shrink_to_fit(); |
299 } |
299 } |
300 |
300 |
301 // ------------------------------------------------------------------------------------------------- |
301 // ------------------------------------------------------------------------------------------------- |
302 |
302 // |
303 inline const std::string& String::std_string() const |
303 inline const std::string& String::std_string() const |
304 { |
304 { |
305 return m_string; |
305 return m_string; |
306 } |
306 } |
307 |
307 |
308 // ------------------------------------------------------------------------------------------------- |
308 // ------------------------------------------------------------------------------------------------- |
309 |
309 // |
310 inline METHOD |
310 inline METHOD |
311 String::strip (char unwanted) -> String |
311 String::strip (char unwanted) -> String |
312 { |
312 { |
313 return strip ({unwanted}); |
313 return strip ({unwanted}); |
314 } |
314 } |
315 |
315 |
316 // ------------------------------------------------------------------------------------------------- |
316 // ------------------------------------------------------------------------------------------------- |
317 |
317 // |
318 inline METHOD |
318 inline METHOD |
319 String::operator+ (int num) const -> String |
319 String::operator+ (int num) const -> String |
320 { |
320 { |
321 return *this + String::from_number (num); |
321 return *this + String::from_number (num); |
322 } |
322 } |
323 |
323 |
324 // ------------------------------------------------------------------------------------------------- |
324 // ------------------------------------------------------------------------------------------------- |
325 |
325 // |
326 inline METHOD |
326 inline METHOD |
327 String::operator+= (const String& data) -> String& |
327 String::operator+= (const String& data) -> String& |
328 { |
328 { |
329 append (data); |
329 append (data); |
330 return *this; |
330 return *this; |
331 } |
331 } |
332 |
332 |
333 // ------------------------------------------------------------------------------------------------- |
333 // ------------------------------------------------------------------------------------------------- |
334 |
334 // |
335 inline METHOD |
335 inline METHOD |
336 String::operator+= (const char* data) -> String& |
336 String::operator+= (const char* data) -> String& |
337 { |
337 { |
338 append (data); |
338 append (data); |
339 return *this; |
339 return *this; |
340 } |
340 } |
341 |
341 |
342 // ------------------------------------------------------------------------------------------------- |
342 // ------------------------------------------------------------------------------------------------- |
343 |
343 // |
344 inline METHOD |
344 inline METHOD |
345 String::operator+= (int num) -> String& |
345 String::operator+= (int num) -> String& |
346 { |
346 { |
347 return operator+= (String::from_number (num)); |
347 return operator+= (String::from_number (num)); |
348 } |
348 } |
349 |
349 |
350 // ------------------------------------------------------------------------------------------------- |
350 // ------------------------------------------------------------------------------------------------- |
351 |
351 // |
352 inline METHOD |
352 inline METHOD |
353 String::prepend (String a) -> void |
353 String::prepend (String a) -> void |
354 { |
354 { |
355 m_string = (a + m_string).std_string(); |
355 m_string = (a + m_string).std_string(); |
356 } |
356 } |
363 append (data); |
363 append (data); |
364 return *this; |
364 return *this; |
365 } |
365 } |
366 |
366 |
367 // ------------------------------------------------------------------------------------------------- |
367 // ------------------------------------------------------------------------------------------------- |
368 |
368 // |
369 inline METHOD |
369 inline METHOD |
370 String::operator== (const String& other) const -> bool |
370 String::operator== (const String& other) const -> bool |
371 { |
371 { |
372 return std_string() == other.std_string(); |
372 return std_string() == other.std_string(); |
373 } |
373 } |
374 |
374 |
375 // ------------------------------------------------------------------------------------------------- |
375 // ------------------------------------------------------------------------------------------------- |
376 |
376 // |
377 inline METHOD |
377 inline METHOD |
378 String::operator== (const char* other) const -> bool |
378 String::operator== (const char* other) const -> bool |
379 { |
379 { |
380 return operator== (String (other)); |
380 return operator== (String (other)); |
381 } |
381 } |
382 |
382 |
383 // ------------------------------------------------------------------------------------------------- |
383 // ------------------------------------------------------------------------------------------------- |
384 |
384 // |
385 inline METHOD |
385 inline METHOD |
386 String::operator!= (const String& other) const -> bool |
386 String::operator!= (const String& other) const -> bool |
387 { |
387 { |
388 return std_string() != other.std_string(); |
388 return std_string() != other.std_string(); |
389 } |
389 } |
390 |
390 |
391 // ------------------------------------------------------------------------------------------------- |
391 // ------------------------------------------------------------------------------------------------- |
392 |
392 // |
393 inline METHOD |
393 inline METHOD |
394 String::operator!= (const char* other) const -> bool |
394 String::operator!= (const char* other) const -> bool |
395 { |
395 { |
396 return operator!= (String (other)); |
396 return operator!= (String (other)); |
397 } |
397 } |
398 |
398 |
399 // ------------------------------------------------------------------------------------------------- |
399 // ------------------------------------------------------------------------------------------------- |
400 |
400 // |
401 inline METHOD |
401 inline METHOD |
402 String::operator> (const String& other) const -> bool |
402 String::operator> (const String& other) const -> bool |
403 { |
403 { |
404 return std_string() > other.std_string(); |
404 return std_string() > other.std_string(); |
405 } |
405 } |
406 |
406 |
407 // ------------------------------------------------------------------------------------------------- |
407 // ------------------------------------------------------------------------------------------------- |
408 |
408 // |
409 inline METHOD |
409 inline METHOD |
410 String::operator< (const String& other) const -> bool |
410 String::operator< (const String& other) const -> bool |
411 { |
411 { |
412 return std_string() < other.std_string(); |
412 return std_string() < other.std_string(); |
413 } |
413 } |
414 |
414 |
415 // ------------------------------------------------------------------------------------------------- |
415 // ------------------------------------------------------------------------------------------------- |
416 |
416 // |
417 inline String::operator const char*() const |
417 inline String::operator const char*() const |
418 { |
418 { |
419 return chars(); |
419 return chars(); |
420 } |
420 } |
421 |
421 |
422 // ------------------------------------------------------------------------------------------------- |
422 // ------------------------------------------------------------------------------------------------- |
423 |
423 // |
424 inline String::operator const std::string&() const |
424 inline String::operator const std::string&() const |
425 { |
425 { |
426 return std_string(); |
426 return std_string(); |
427 } |
427 } |
428 |
428 |
429 // ------------------------------------------------------------------------------------------------- |
429 // ------------------------------------------------------------------------------------------------- |
430 |
430 // |
431 inline METHOD |
431 inline METHOD |
432 String::modify_index (int& a) -> void |
432 String::modify_index (int& a) -> void |
433 { |
433 { |
434 if (a < 0) |
434 if (a < 0) |
435 a = length() - a; |
435 a = length() - a; |
436 } |
436 } |
437 |
437 |
438 // ------------------------------------------------------------------------------------------------- |
438 // ------------------------------------------------------------------------------------------------- |
439 |
439 // |
440 inline METHOD |
440 inline METHOD |
441 String::index_difference (int a, int b) -> int |
441 String::index_difference (int a, int b) -> int |
442 { |
442 { |
443 modify_index (a); |
443 modify_index (a); |
444 modify_index (b); |
444 modify_index (b); |
445 return b - a; |
445 return b - a; |
446 } |
446 } |
447 |
447 |
448 // ------------------------------------------------------------------------------------------------- |
448 // ------------------------------------------------------------------------------------------------- |
449 |
449 // |
450 inline FUNCTION |
450 inline FUNCTION |
451 operator== (const char* a, const String& b) -> bool |
451 operator== (const char* a, const String& b) -> bool |
452 { |
452 { |
453 return b == a; |
453 return b == a; |
454 } |
454 } |
455 |
455 |
456 // ------------------------------------------------------------------------------------------------- |
456 // ------------------------------------------------------------------------------------------------- |
457 |
457 // |
458 inline FUNCTION |
458 inline FUNCTION |
459 operator+ (const char* a, const String& b) -> String |
459 operator+ (const char* a, const String& b) -> String |
460 { |
460 { |
461 return String (a) + b; |
461 return String (a) + b; |
462 } |
462 } |