VirtualBox

Changeset 85288 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Jul 13, 2020 12:19:47 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
139265
Message:

Main: Adding two Bstr::assignEx variants that returns HRESULT instead of throwing exceptions. bugref:9790

File:
1 edited

Legend:

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

    r84341 r85288  
    173173    }
    174174
     175    /**
     176     * Extended assignment method that returns a COM status code instead of an
     177     * exception on failure.
     178     *
     179     * @returns S_OK or E_OUTOFMEMORY.
     180     * @param   a_rSrcStr   The source string
     181     */
     182    HRESULT assignEx(const Bstr &a_rSrcStr) RT_NOEXCEPT
     183    {
     184        return cleanupAndCopyFromEx((const OLECHAR *)a_rSrcStr.m_bstr);
     185    }
     186
     187    /**
     188     * Extended assignment method that returns a COM status code instead of an
     189     * exception on failure.
     190     *
     191     * @returns S_OK or E_OUTOFMEMORY.
     192     * @param   a_pSrcStr   The source string
     193     */
     194    HRESULT assignEx(CBSTR a_pSrcStr) RT_NOEXCEPT
     195    {
     196        return cleanupAndCopyFromEx((const OLECHAR *)a_pSrcStr);
     197    }
     198
    175199#ifdef _MSC_VER
    176200# if _MSC_VER >= 1400
     
    950974    /** cleanup() + copyFrom() - for assignment operators.  */
    951975    void cleanupAndCopyFrom(const OLECHAR *a_bstrSrc);
     976
     977    /**
     978     * Protected internal helper to copy a string, implying cleanup().
     979     *
     980     * This variant copies from a zero-terminated UTF-16 string (which need not be a
     981     * BSTR, i.e. need not have a length prefix).
     982     *
     983     * If the source is empty, this sets the member string to NULL.
     984     *
     985     * @param   a_bstrSrc           The source string.  The caller guarantees
     986     *                              that this is valid UTF-16.
     987     * @returns S_OK or E_OUTOFMEMORY
     988     */
     989    HRESULT cleanupAndCopyFromEx(const OLECHAR *a_bstrSrc) RT_NOEXCEPT;
    952990
    953991    /**
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