Changeset 33610 in vbox for trunk/include
- Timestamp:
- Oct 29, 2010 2:42:36 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/cpp/ministring.h
r33605 r33610 100 100 101 101 /** 102 * Create a new string given the format string and its arguments. 103 * 104 * @param a_pszFormat Pointer to the format string (UTF-8), 105 * @see pg_rt_str_format. 106 * @param a_va Argument vector containing the arguments 107 * specified by the format string. 108 * @sa printfV 109 */ 110 MiniString(const char *a_pszFormat, va_list a_va) 111 : m_psz(NULL), 112 m_cch(0), 113 m_cbAllocated(0) 114 115 { 116 printfV(a_pszFormat, a_va); 117 } 118 119 /** 102 120 * Destructor. 103 121 */ … … 214 232 * Assigns the output of the string format operation (RTStrPrintf). 215 233 * 216 * @param pszFormat The format string. 234 * @param pszFormat Pointer to the format string, 235 * @see pg_rt_str_format. 217 236 * @param ... Ellipsis containing the arguments specified by 218 237 * the format string. … … 227 246 * Assigns the output of the string format operation (RTStrPrintfV). 228 247 * 229 * @param pszFormat The format string. 248 * @param pszFormat Pointer to the format string, 249 * @see pg_rt_str_format. 230 250 * @param va Argument vector containing the arguments 231 251 * specified by the format string. … … 461 481 462 482 /** 463 * Compares the member string to pcsz.464 * @param pcsz465 * @param cs Whether comparison should be case-sensitive.466 * @ return467 * /468 int compare(const char *pcsz, CaseSensitivity cs = CaseSensitive) const469 {470 if (m_psz == pcsz)471 return 0;472 if (m_psz == NULL)473 return -1;474 if ( pcsz == NULL)475 return 1;483 * Compares the member string to a C-string. 484 * 485 * @param pcszThat The string to compare with. 486 * @param cs Whether comparison should be case-sensitive. 487 * @returns 0 if equal, negative if this is smaller than @a pcsz, positive 488 * if larger. 489 */ 490 int compare(const char *pcszThat, CaseSensitivity cs = CaseSensitive) const 491 { 492 /* This klugde is for m_cch=0 and m_psz=NULL. pcsz=NULL and psz="" 493 are treated the same way so that str.compare(str2.c_str()) works. */ 494 if (length() == 0) 495 return pcszThat == NULL || *pcszThat != '\0'; 476 496 477 497 if (cs == CaseSensitive) 478 return ::RTStrCmp(m_psz, pcsz); 479 else 480 return ::RTStrICmp(m_psz, pcsz); 481 } 482 498 return ::RTStrCmp(m_psz, pcszThat); 499 return ::RTStrICmp(m_psz, pcszThat); 500 } 501 502 /** 503 * Compares the member string to another MiniString. 504 * 505 * @param pcszThat The string to compare with. 506 * @param cs Whether comparison should be case-sensitive. 507 * @returns 0 if equal, negative if this is smaller than @a pcsz, positive 508 * if larger. 509 */ 483 510 int compare(const MiniString &that, CaseSensitivity cs = CaseSensitive) const 484 511 { 485 return compare(that.m_psz, cs); 512 if (cs == CaseSensitive) 513 return ::RTStrCmp(m_psz, that.m_psz); 514 return ::RTStrICmp(m_psz, that.m_psz); 486 515 } 487 516 … … 506 535 bool equals(const char *pszThat) const 507 536 { 537 /* This klugde is for m_cch=0 and m_psz=NULL. pcsz=NULL and psz="" 538 are treated the same way so that str.equals(str2.c_str()) works. */ 539 if (length() == 0) 540 return pszThat == NULL || *pszThat == '\0'; 508 541 return RTStrCmp(pszThat, m_psz) == 0; 509 542 } … … 530 563 bool equalsIgnoreCase(const char *pszThat) const 531 564 { 565 /* This klugde is for m_cch=0 and m_psz=NULL. pcsz=NULL and psz="" 566 are treated the same way so that str.equalsIgnoreCase(str2.c_str()) works. */ 567 if (length() == 0) 568 return pszThat == NULL || *pszThat == '\0'; 532 569 return RTStrICmp(pszThat, m_psz) == 0; 533 570 }
Note:
See TracChangeset
for help on using the changeset viewer.