儲存庫 vbox 的更動 42570
- 時間撮記:
- 2012-8-3 上午09:56:09 (12 年 以前)
- 位置:
- trunk
- 檔案:
-
- 修改 2 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/include/VBox/com/string.h
r42177 r42570 559 559 bool operator<(const RTCString &that) const { return RTCString::operator<(that); } 560 560 561 /** 562 * Extended assignment method that returns a COM status code instead of an 563 * exception on failure. 564 * 565 * @returns S_OK or E_OUTOFMEMORY. 566 * @param a_rSrcStr The source string 567 */ 568 HRESULT assignEx(Utf8Str const &a_rSrcStr) 569 { 570 return copyFromExNComRC(a_rSrcStr.m_psz, a_rSrcStr.m_cch); 571 } 572 573 /** 574 * Extended assignment method that returns a COM status code instead of an 575 * exception on failure. 576 * 577 * @returns S_OK, E_OUTOFMEMORY or E_INVALIDARG. 578 * @param a_pcszSrc The source string 579 * @param a_offSrc The character (byte) offset of the substring. 580 * @param a_cchSrc The number of characters (bytes) to copy from the source 581 * string. 582 */ 583 HRESULT assignEx(Utf8Str const &a_rSrcStr, size_t a_offSrc, size_t a_cchSrc) 584 { 585 if ( a_offSrc + a_cchSrc > a_rSrcStr.m_cch 586 || a_offSrc > a_rSrcStr.m_cch) 587 return E_INVALIDARG; 588 return copyFromExNComRC(a_rSrcStr.m_psz, a_rSrcStr.m_cch); 589 } 590 591 /** 592 * Extended assignment method that returns a COM status code instead of an 593 * exception on failure. 594 * 595 * @returns S_OK or E_OUTOFMEMORY. 596 * @param a_pcszSrc The source string 597 */ 598 HRESULT assignEx(const char *a_pcszSrc) 599 { 600 return copyFromExNComRC(a_pcszSrc, a_pcszSrc ? strlen(a_pcszSrc) : 0); 601 } 602 603 /** 604 * Extended assignment method that returns a COM status code instead of an 605 * exception on failure. 606 * 607 * @returns S_OK or E_OUTOFMEMORY. 608 * @param a_pcszSrc The source string 609 * @param a_cchSrc The number of characters (bytes) to copy from the source 610 * string. 611 */ 612 HRESULT assignEx(const char *a_pcszSrc, size_t a_cchSrc) 613 { 614 return copyFromExNComRC(a_pcszSrc, a_cchSrc); 615 } 616 561 617 RTMEMEF_NEW_AND_DELETE_OPERATORS(); 562 618 … … 655 711 void copyFrom(CBSTR a_pbstr); 656 712 HRESULT copyFromEx(CBSTR a_pbstr); 713 HRESULT copyFromExNComRC(const char *a_pcszSrc, size_t a_cchSrc); 657 714 658 715 friend class Bstr; /* to access our raw_copy() */ -
trunk/src/VBox/Main/glue/string.cpp
r40418 r42570 241 241 } 242 242 243 244 /** 245 * A variant of Utf8Str::copyFromN that does not throw any exceptions but 246 * returns E_OUTOFMEMORY instead. 247 * 248 * @param a_pcszSrc The source string. 249 * @param a_cchSrc The source string. 250 * @returns S_OK or E_OUTOFMEMORY. 251 * 252 * @remarks This calls cleanup() first, so the caller doesn't have to. (Saves 253 * code space.) 254 */ 255 HRESULT Utf8Str::copyFromExNComRC(const char *a_pcszSrc, size_t a_cchSrc) 256 { 257 cleanup(); 258 if (a_cchSrc) 259 { 260 m_psz = RTStrAlloc(a_cchSrc + 1); 261 if (RT_LIKELY(m_psz)) 262 { 263 m_cch = a_cchSrc; 264 m_cbAllocated = a_cchSrc + 1; 265 memcpy(m_psz, a_pcszSrc, a_cchSrc); 266 m_psz[a_cchSrc] = '\0'; 267 } 268 else 269 { 270 m_cch = 0; 271 m_cbAllocated = 0; 272 return E_OUTOFMEMORY; 273 } 274 } 275 else 276 { 277 m_cch = 0; 278 m_cbAllocated = 0; 279 m_psz = NULL; 280 } 281 return S_OK; 282 } 283 243 284 } /* namespace com */
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器