VirtualBox

Changeset 80793 in vbox for trunk/include/VBox/com


Ignore:
Timestamp:
Sep 15, 2019 11:27:47 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
133360
Message:

Bstr: Added printf, printfNoThrow, printfV and printfVNoThrow methods (untested).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/com/string.h

    r76585 r80793  
    147147    }
    148148
    149     Bstr& operator=(const Bstr &that)
     149    Bstr &operator=(const Bstr &that)
    150150    {
    151151        cleanup();
     
    154154    }
    155155
    156     Bstr& operator=(CBSTR that)
     156    Bstr &operator=(CBSTR that)
    157157    {
    158158        cleanup();
     
    162162
    163163#if defined(VBOX_WITH_XPCOM)
    164     Bstr& operator=(const wchar_t *that)
     164    Bstr &operator=(const wchar_t *that)
    165165    {
    166166        cleanup();
     
    170170#endif
    171171
    172     Bstr& setNull()
     172    Bstr &setNull()
    173173    {
    174174        cleanup();
     
    301301    size_t length() const { return isEmpty() ? 0 : ::RTUtf16Len((PRTUTF16)m_bstr); }
    302302
     303    /**
     304     * Assigns the output of the string format operation (RTStrPrintf).
     305     *
     306     * @param   pszFormat       Pointer to the format string,
     307     *                          @see pg_rt_str_format.
     308     * @param   ...             Ellipsis containing the arguments specified by
     309     *                          the format string.
     310     *
     311     * @throws  std::bad_alloc  On allocation error.  Object state is undefined.
     312     *
     313     * @returns Reference to the object.
     314     */
     315    Bstr &printf(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
     316
     317    /**
     318     * Assigns the output of the string format operation (RTStrPrintf).
     319     *
     320     * @param   pszFormat       Pointer to the format string,
     321     *                          @see pg_rt_str_format.
     322     * @param   ...             Ellipsis containing the arguments specified by
     323     *                          the format string.
     324     *
     325     * @returns S_OK or E_OUTOFMEMORY
     326     */
     327    HRESULT printfNoThrow(const char *pszFormat, ...) RT_NOEXCEPT RT_IPRT_FORMAT_ATTR(1, 2);
     328
     329    /**
     330     * Assigns the output of the string format operation (RTStrPrintfV).
     331     *
     332     * @param   pszFormat       Pointer to the format string,
     333     *                          @see pg_rt_str_format.
     334     * @param   va              Argument vector containing the arguments
     335     *                          specified by the format string.
     336     *
     337     * @throws  std::bad_alloc  On allocation error.  Object state is undefined.
     338     *
     339     * @returns Reference to the object.
     340     */
     341    Bstr &printfV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
     342
     343    /**
     344     * Assigns the output of the string format operation (RTStrPrintfV).
     345     *
     346     * @param   pszFormat       Pointer to the format string,
     347     *                          @see pg_rt_str_format.
     348     * @param   va              Argument vector containing the arguments
     349     *                          specified by the format string.
     350     *
     351     * @returns S_OK or E_OUTOFMEMORY
     352     */
     353    HRESULT printfVNoThrow(const char *pszFormat, va_list va) RT_NOEXCEPT RT_IPRT_FORMAT_ATTR(1, 0);
     354
    303355#if defined(VBOX_WITH_XPCOM)
    304356    /**
     
    522574     */
    523575    void copyFromN(const char *a_pszSrc, size_t a_cchSrc);
     576
     577    static DECLCALLBACK(size_t) printfOutputCallbackNoThrow(void *pvArg, const char *pachChars, size_t cbChars) RT_NOEXCEPT;
    524578
    525579    BSTR m_bstr;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette