398 |
399 |
399 return tmp; |
400 return tmp; |
400 } |
401 } |
401 |
402 |
402 // ============================================================================ |
403 // ============================================================================ |
403 #if 0 |
404 array<str> str::split (str del) { |
404 str** str::split (char* del) { |
405 array<str> res; |
405 unsigned int arrcount = count (del) + 1; |
|
406 str** arr = new str* [arrcount]; |
|
407 |
|
408 unsigned int a = 0; |
406 unsigned int a = 0; |
409 unsigned int index = 0; |
407 |
|
408 // Find all separators and store the text left to them. |
410 while (1) { |
409 while (1) { |
411 unsigned int b = first (del, a+1); |
410 unsigned int b = first (del, a); |
412 printf ("next: %u (<-> %u)\n", b, len()); |
|
413 |
411 |
414 if (b == len()) |
412 if (b == len()) |
415 break; |
413 break; |
416 |
414 |
417 str* x = new str; |
415 res.push (substr (a, b)); |
418 x->append (substr (a, b)); |
416 a = b + strlen (del); |
419 arr[index] = x; |
417 } |
420 index++; |
418 |
421 a = b; |
419 // Add the string at the right of the last separator |
422 } |
420 res.push (substr (a, len())); |
423 |
421 return res; |
424 return arr; |
422 } |
425 } |
423 |
426 #endif |
424 array<str> str::operator/ (str splitstring) {return split(splitstring);} |
427 |
425 array<str> str::operator/ (char* splitstring) {return split(splitstring);} |
428 // ============================================================================ |
426 array<str> str::operator/ (const char* splitstring) {return split(splitstring);} |
429 // OPERATORS |
|
430 str str::operator + (str& c) { |
|
431 append (c); |
|
432 return *this; |
|
433 } |
|
434 |
|
435 str& str::operator += (char c) { |
|
436 append (c); |
|
437 return *this; |
|
438 } |
|
439 |
|
440 str& str::operator += (const char* c) { |
|
441 append (c); |
|
442 return *this; |
|
443 } |
|
444 |
|
445 str& str::operator += (const str c) { |
|
446 append (c); |
|
447 return *this; |
|
448 } |
|
449 |
|
450 char str::operator [] (unsigned int pos) { |
|
451 return text[pos]; |
|
452 } |
|
453 |
|
454 str::operator char* () const { |
|
455 return text; |
|
456 } |
|
457 |
|
458 str::operator int () const {return atoi(text);} |
|
459 str::operator unsigned int () const {return atoi(text);} |
|