Changeset 33621 in vbox
- Timestamp:
- Oct 29, 2010 4:15:40 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/string.h
r33073 r33621 431 431 } 432 432 433 /** 434 * Constructs a new string given the format string and the list of the 435 * arguments for the format string. 436 * 437 * @param a_pszFormat Pointer to the format string (UTF-8), 438 * @see pg_rt_str_format. 439 * @param a_va Argument vector containing the arguments 440 * specified by the format string. 441 * @sa iprt::MiniString::printfV 442 */ 443 Utf8Str(const char *a_pszFormat, va_list a_va) 444 : MiniString(a_pszFormat, a_va) 445 { 446 } 447 433 448 Utf8Str& operator=(const MiniString &that) 434 449 { … … 544 559 545 560 /** 546 * This class is a printf-like formatter for Utf8Str strings. Its purpose is 547 * to construct Utf8Str objects from a format string and a list of arguments 548 * for the format string. 549 * 550 * The usage of this class is like the following: 551 * <code> 552 * Utf8StrFmt string("program name = %s", argv[0]); 553 * </code> 561 * Class with iprt::MiniString::printf as constructor for your convenience. 562 * 563 * Constructing a Utf8Str string object from a format string and a variable 564 * number of arguments can easily be confused with the other Utf8Str 565 * constructures, thus this child class. 566 * 567 * The usage of this class is like the following: 568 * @code 569 Utf8StrFmt strName("program name = %s", argv[0]); 570 @endcode 554 571 */ 555 572 class Utf8StrFmt : public Utf8Str … … 558 575 559 576 /** 560 * Constructs a new string given the format string and the list 561 * of the arguments for the format string. 562 * 563 * @param format printf-like format string (in UTF-8 encoding) 564 * @param ... list of the arguments for the format string 565 */ 566 explicit Utf8StrFmt(const char *format, ...) 567 { 568 va_list args; 569 va_start(args, format); 570 init(format, args); 571 va_end(args); 577 * Constructs a new string given the format string and the list of the 578 * arguments for the format string. 579 * 580 * @param a_pszFormat Pointer to the format string (UTF-8), 581 * @see pg_rt_str_format. 582 * @param ... Ellipsis containing the arguments specified by 583 * the format string. 584 */ 585 explicit Utf8StrFmt(const char *a_pszFormat, ...) 586 { 587 va_list va; 588 va_start(va, a_pszFormat); 589 printfV(a_pszFormat, va); 590 va_end(va); 572 591 } 573 592 … … 576 595 { } 577 596 578 void init(const char *format, va_list args);579 580 597 private: 581 };582 583 /**584 * This class is a vprintf-like formatter for Utf8Str strings. It is585 * identical to Utf8StrFmt except that its constructor takes a va_list586 * argument instead of ellipsis.587 *588 * Note that a separate class is necessary because va_list is defined as589 * |char *| on most platforms. For this reason, if we had two overloaded590 * constructors in Utf8StrFmt (one taking ellipsis and another one taking591 * va_list) then composing a constructor call using exactly two |char *|592 * arguments would cause the compiler to use the va_list overload instead of593 * the ellipsis one which is obviously wrong. The compiler would choose594 * va_list because ellipsis has the lowest rank when it comes to resolving595 * overloads, as opposed to va_list which is an exact match for |char *|.596 */597 class Utf8StrFmtVA : public Utf8StrFmt598 {599 public:600 601 /**602 * Constructs a new string given the format string and the list603 * of the arguments for the format string.604 *605 * @param format printf-like format string (in UTF-8 encoding)606 * @param args list of arguments for the format string607 */608 Utf8StrFmtVA(const char *format, va_list args) { init(format, args); }609 598 }; 610 599 … … 627 616 va_list args; 628 617 va_start(args, aFormat); 629 copyFrom(Utf8Str FmtVA(aFormat, args).c_str());618 copyFrom(Utf8Str(aFormat, args).c_str()); 630 619 va_end(args); 631 620 } … … 633 622 634 623 /** 635 * The BstrFmtVA class is a shortcut to <tt>Bstr(Utf8Str FmtVA(...))</tt>.624 * The BstrFmtVA class is a shortcut to <tt>Bstr(Utf8Str(format,va))</tt>. 636 625 */ 637 626 class BstrFmtVA : public Bstr … … 648 637 BstrFmtVA(const char *aFormat, va_list aArgs) 649 638 { 650 copyFrom(Utf8Str FmtVA(aFormat, aArgs).c_str());639 copyFrom(Utf8Str(aFormat, aArgs).c_str()); 651 640 } 652 641 }; -
trunk/src/VBox/Main/ApplianceImpl.cpp
r33540 r33621 819 819 va_list args; 820 820 va_start(args, aWarning); 821 Utf8Str FmtVAstr(aWarning, args);821 Utf8Str str(aWarning, args); 822 822 va_end(args); 823 823 m->llWarnings.push_back(str); -
trunk/src/VBox/Main/ConsoleImpl.cpp
r33590 r33621 3013 3013 getStaticClassIID(), 3014 3014 getStaticComponentName(), 3015 Utf8Str FmtVA(pcsz, args),3015 Utf8Str(pcsz, args), 3016 3016 false /* aWarning */, 3017 3017 true /* aLogIt */); … … 7039 7039 AssertReturnVoid(that); 7040 7040 7041 Utf8Str message = Utf8StrFmtVA(pszFormat, va);7041 Utf8Str message(pszFormat, va); 7042 7042 7043 7043 LogRel(("Console: VM runtime error: fatal=%RTbool, errorID=%s message=\"%s\"\n", -
trunk/src/VBox/Main/ProgressImpl.cpp
r33540 r33621 1161 1161 va_list va) 1162 1162 { 1163 Utf8Str text = Utf8StrFmtVA(aText, va);1163 Utf8Str text(aText, va); 1164 1164 1165 1165 AutoCaller autoCaller(this); -
trunk/src/VBox/Main/VirtualBoxBase.cpp
r33540 r33621 462 462 this->getClassIID(), 463 463 this->getComponentName(), 464 Utf8Str FmtVA(pcsz, args),464 Utf8Str(pcsz, args), 465 465 false /* aWarning */, 466 466 true /* aLogIt */); … … 482 482 this->getClassIID(), 483 483 this->getComponentName(), 484 Utf8Str FmtVA(pcsz, args),484 Utf8Str(pcsz, args), 485 485 true /* aWarning */, 486 486 true /* aLogIt */); … … 502 502 this->getClassIID(), 503 503 this->getComponentName(), 504 Utf8Str FmtVA(pcsz, args),504 Utf8Str(pcsz, args), 505 505 false /* aWarning */, 506 506 false /* aLogIt */); -
trunk/src/VBox/Main/glue/string.cpp
r33563 r33621 139 139 } 140 140 141 void Utf8StrFmt::init(const char *format, va_list args)142 {143 if (!format || !*format)144 {145 m_cch = 0;146 m_cbAllocated = 0;147 m_psz = NULL;148 }149 else150 {151 m_cch = RTStrAPrintfV(&m_psz, format, args);152 m_cbAllocated = m_cch + 1;153 }154 }155 156 141 } /* namespace com */ -
trunk/src/VBox/Main/xml/Settings.cpp
r33612 r33621 189 189 va_list args; 190 190 va_start(args, pcszFormat); 191 Utf8Str FmtVAstrWhat(pcszFormat, args);191 Utf8Str strWhat(pcszFormat, args); 192 192 va_end(args); 193 193
Note:
See TracChangeset
for help on using the changeset viewer.