| 358 | } |
| 359 | |
| 360 | void AbstractString::baseTrim(const TrimType whereTrim, const_pointer toTrim) |
| 361 | { |
| 362 | const strBitMask sm(toTrim, static_cast<size_type>(strlen(toTrim))); |
| 363 | const_pointer b = c_str(); |
| 364 | const_pointer e = c_str() + length() - 1; |
| 365 | if (whereTrim != TrimRight) |
| 366 | { |
| 367 | while (b <= e) |
| 368 | { |
| 369 | if (! sm.Contains(*b)) { |
| 370 | break; |
| 371 | } |
| 372 | ++b; |
| 373 | } |
| 374 | } |
| 375 | if (whereTrim != TrimLeft) |
| 376 | { |
| 377 | while (b <= e) |
| 378 | { |
| 379 | if (! sm.Contains(*e)) { |
| 380 | break; |
| 381 | } |
| 382 | --e; |
| 383 | } |
| 384 | } |
| 385 | const size_type NewLength = e - b + 1; |
| 386 | |
| 387 | if (NewLength == length()) |
| 388 | return; |
| 389 | |
| 390 | if (b != c_str()) |
| 391 | { |
| 392 | memmove(stringBuffer, b, NewLength); |
| 393 | } |
| 394 | stringLength = NewLength; |
| 395 | stringBuffer[NewLength] = 0; |
| 396 | shrinkBuffer(); |
| 397 | } |
| 398 | |
| 399 | void AbstractString::printf(const char* format,...) |
| 400 | { |