Changeset 17742 in vbox for trunk/include/VBox
- Timestamp:
- Mar 12, 2009 1:12:10 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/string.h
r17740 r17742 328 328 public: 329 329 330 enum CaseSensitivity 331 { 332 CaseSensitive, 333 CaseInsensitive 334 }; 335 330 336 typedef char *String; 331 337 typedef const char *ConstString; … … 438 444 } 439 445 440 int compare (const char * s) const441 { 442 if (str == s)446 int compare (const char *pcsz, CaseSensitivity cs = CaseSensitive) const 447 { 448 if (str == pcsz) 443 449 return 0; 444 450 if (str == NULL) 445 451 return -1; 446 if ( s== NULL)452 if (pcsz == NULL) 447 453 return 1; 448 454 449 return ::strcmp (str, s); 450 } 451 452 bool operator == (const Utf8Str &that) const { return !compare (that.str); } 453 bool operator != (const Utf8Str &that) const { return !!compare (that.str); } 455 if (cs == CaseSensitive) 456 return ::RTStrCmp(str, pcsz); 457 else 458 return ::RTStrICmp(str, pcsz); 459 } 460 461 int compare (const Utf8Str &that, CaseSensitivity cs = CaseSensitive) const 462 { 463 return compare (that.str, cs); 464 } 465 466 bool operator == (const Utf8Str &that) const { return !compare (that); } 467 bool operator != (const Utf8Str &that) const { return !!compare (that); } 454 468 bool operator == (const char *that) const { return !compare (that); } 455 469 bool operator != (const char *that) const { return !!compare (that); } 456 bool operator < (const Utf8Str &that) const { return compare (that .str) < 0; }470 bool operator < (const Utf8Str &that) const { return compare (that) < 0; } 457 471 bool operator < (const char *that) const { return compare (that) < 0; } 458 472 459 int compareIgnoreCase(const char *pcsz) const 460 { 461 return ::RTStrICmp(str, pcsz); 462 } 463 464 bool endsWith (const Utf8Str &that) const 473 bool endsWith (const Utf8Str &that, CaseSensitivity cs = CaseSensitive) const 465 474 { 466 475 if (length() < that.length()) … … 468 477 469 478 int l = length() - that.length(); 470 return ::strcmp (&str[l], that.str) == 0; 479 if (cs == CaseSensitive) 480 return ::RTStrCmp(&str[l], that.str) == 0; 481 else 482 return ::RTStrICmp(&str[l], that.str) == 0; 483 } 484 485 bool startsWith (const Utf8Str &that, CaseSensitivity cs = CaseSensitive) const 486 { 487 if (length() < that.length()) 488 return false; 489 490 if (cs == CaseSensitive) 491 return ::RTStrNCmp(str, that.str, that.length()) == 0; 492 else 493 return ::RTStrNICmp(str, that.str, that.length()) == 0; 471 494 } 472 495
Note:
See TracChangeset
for help on using the changeset viewer.