VirtualBox

Changeset 85308 in vbox


Ignore:
Timestamp:
Jul 13, 2020 12:38:55 PM (4 years ago)
Author:
vboxsync
Message:

VBox/com/string.h: Some more Bstr assignEx methods. (forgot the header) bugref:9790

File:
1 edited

Legend:

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

    r85288 r85308  
    197197    }
    198198
     199    /**
     200     * Assign the value of a RTCString/Utf8Str string, no exceptions.
     201     *
     202     * @returns S_OK or E_OUTOFMEMORY.
     203     * @param   a_rSrcStr   The source string
     204     */
     205    HRESULT assignEx(RTCString const &a_rSrcStr) RT_NOEXCEPT
     206    {
     207        return cleanupAndCopyFromNoThrow(a_rSrcStr.c_str(), a_rSrcStr.length());
     208    }
     209
     210    /**
     211     * Assign the value of a RTCString/Utf8Str substring, no exceptions.
     212     *
     213     * @returns S_OK, E_OUTOFMEMORY or E_INVALIDARG.
     214     * @param   a_rSrcStr   The source string
     215     * @param   a_offSrc    The character (byte) offset of the substring.
     216     * @param   a_cchSrc    The number of characters (bytes) to copy from the source
     217     *                      string.
     218     */
     219    HRESULT assignEx(RTCString const &a_rSrcStr, size_t a_offSrc, size_t a_cchSrc) RT_NOEXCEPT
     220    {
     221        size_t const cchTmp = a_rSrcStr.length();
     222        if (   a_offSrc + a_cchSrc < cchTmp
     223            && a_offSrc < cchTmp)
     224            return cleanupAndCopyFromNoThrow(a_rSrcStr.c_str() + a_offSrc, a_cchSrc);
     225        return E_INVALIDARG;
     226    }
     227
     228    /**
     229     * Assign the value of a zero terminated UTF-8 string, no exceptions.
     230     *
     231     * @returns S_OK or E_OUTOFMEMORY.
     232     * @param   a_pszSrcStr The source string.
     233     */
     234    HRESULT assignEx(const char *a_pszSrcStr) RT_NOEXCEPT
     235    {
     236        return cleanupAndCopyFromNoThrow(a_pszSrcStr, RTSTR_MAX);
     237    }
     238
     239    /**
     240     * Assign the value of a UTF-8 substring, no exceptions.
     241     *
     242     * @returns S_OK or E_OUTOFMEMORY.
     243     * @param   a_pszSrcStr The source string.
     244     * @param   a_cchSrc    The number of characters (bytes) to copy from the source
     245     *                      string.
     246     */
     247    HRESULT assignEx(const char *a_pszSrcStr, size_t a_cchSrc) RT_NOEXCEPT
     248    {
     249        return cleanupAndCopyFromNoThrow(a_pszSrcStr, a_cchSrc);
     250    }
     251
    199252#ifdef _MSC_VER
    200253# if _MSC_VER >= 1400
     
    10191072     */
    10201073    void copyFromN(const char *a_pszSrc, size_t a_cchSrc);
     1074
     1075    /** cleanup() + non-throwing copyFromN(). */
     1076    HRESULT cleanupAndCopyFromNoThrow(const char *a_pszSrc, size_t a_cchMax) RT_NOEXCEPT;
    10211077
    10221078    Bstr   &appendWorkerUtf16(PCRTUTF16 pwszSrc, size_t cwcSrc);
Note: See TracChangeset for help on using the changeset viewer.

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