371 |
371 |
372 return n; |
372 return n; |
373 } |
373 } |
374 |
374 |
375 // ============================================================================ |
375 // ============================================================================ |
|
376 unsigned int str::count (char* c) { |
|
377 unsigned int r = 0; |
|
378 unsigned int tmp = 0; |
|
379 ITERATE_STRING (u) { |
|
380 if (text[u] == c[r]) { |
|
381 r++; |
|
382 if (r == strlen (c)) { |
|
383 r = 0; |
|
384 tmp++; |
|
385 } |
|
386 } else { |
|
387 if (r != 0) |
|
388 u--; |
|
389 r = 0; |
|
390 } |
|
391 } |
|
392 |
|
393 return tmp; |
|
394 } |
|
395 |
|
396 // ============================================================================ |
|
397 #if 0 |
|
398 str** str::split (char* del) { |
|
399 unsigned int arrcount = count (del) + 1; |
|
400 str** arr = new str* [arrcount]; |
|
401 |
|
402 unsigned int a = 0; |
|
403 unsigned int index = 0; |
|
404 while (1) { |
|
405 unsigned int b = first (del, a+1); |
|
406 printf ("next: %u (<-> %u)\n", b, len()); |
|
407 |
|
408 if (b == len()) |
|
409 break; |
|
410 |
|
411 str* x = new str; |
|
412 x->append (substr (a, b)); |
|
413 arr[index] = x; |
|
414 index++; |
|
415 a = b; |
|
416 } |
|
417 |
|
418 return arr; |
|
419 } |
|
420 #endif |
|
421 |
|
422 // ============================================================================ |
376 // OPERATORS |
423 // OPERATORS |
377 str str::operator + (str& c) { |
424 str str::operator + (str& c) { |
378 append (c); |
425 append (c); |
379 return *this; |
426 return *this; |
380 } |
427 } |