VirtualBox

Changeset 80836 in vbox for trunk/include/VBox/com/string.h


Ignore:
Timestamp:
Sep 17, 2019 12:26:52 AM (5 years ago)
Author:
vboxsync
Message:

Main/glue: Added all the append methods that RTCString have and then some.

File:
1 edited

Legend:

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

    r80835 r80836  
    323323     *                          the format string.
    324324     *
    325      * @returns S_OK or E_OUTOFMEMORY
     325     * @returns S_OK, E_OUTOFMEMORY or E_INVAL (bad encoding).
    326326     */
    327327    HRESULT printfNoThrow(const char *pszFormat, ...) RT_NOEXCEPT RT_IPRT_FORMAT_ATTR(1, 2);
     
    349349     *                          specified by the format string.
    350350     *
    351      * @returns S_OK or E_OUTOFMEMORY
     351     * @returns S_OK, E_OUTOFMEMORY or E_INVAL (bad encoding).
    352352     */
    353353    HRESULT printfVNoThrow(const char *pszFormat, va_list va) RT_NOEXCEPT RT_IPRT_FORMAT_ATTR(1, 0);
     354
     355    /** @name Append methods and operators
     356     *  @{ */
     357
     358    /**
     359     * Appends the string @a that to @a rThat.
     360     *
     361     * @param   rThat            The string to append.
     362     * @throws  std::bad_alloc  On allocation error.  The object is left unchanged.
     363     * @returns Reference to the object.
     364     */
     365    Bstr &append(const Bstr &rThat);
     366
     367    /**
     368     * Appends the string @a that to @a rThat.
     369     *
     370     * @param   rThat            The string to append.
     371     * @returns S_OK, E_OUTOFMEMORY or E_INVAL (bad encoding).
     372     */
     373    HRESULT appendNoThrow(const Bstr &rThat) RT_NOEXCEPT;
     374
     375    /**
     376     * Appends the UTF-8 string @a that to @a rThat.
     377     *
     378     * @param   rThat            The string to append.
     379     * @throws  std::bad_alloc  On allocation error.  The object is left unchanged.
     380     * @returns Reference to the object.
     381     */
     382    Bstr &append(const RTCString &rThat);
     383
     384    /**
     385     * Appends the UTF-8 string @a that to @a rThat.
     386     *
     387     * @param   rThat            The string to append.
     388     * @returns S_OK, E_OUTOFMEMORY or E_INVAL (bad encoding).
     389     */
     390    HRESULT appendNoThrow(const RTCString &rThat) RT_NOEXCEPT;
     391
     392    /**
     393     * Appends the UTF-16 string @a pszSrc to @a this.
     394     *
     395     * @param   pwszSrc         The C-style UTF-16 string to append.
     396     * @throws  std::bad_alloc  On allocation error.  The object is left unchanged.
     397     * @returns Reference to the object.
     398     */
     399    Bstr &append(CBSTR pwszSrc);
     400
     401    /**
     402     * Appends the UTF-16 string @a pszSrc to @a this.
     403     *
     404     * @param   pwszSrc         The C-style UTF-16 string to append.
     405     * @returns S_OK, E_OUTOFMEMORY or E_INVAL (bad encoding).
     406     */
     407    HRESULT appendNoThrow(CBSTR pwszSrc) RT_NOEXCEPT;
     408
     409    /**
     410     * Appends the UTF-8 string @a pszSrc to @a this.
     411     *
     412     * @param   pszSrc          The C-style string to append.
     413     * @throws  std::bad_alloc  On allocation error.  The object is left unchanged.
     414     * @returns Reference to the object.
     415     */
     416    Bstr &append(const char *pszSrc);
     417
     418    /**
     419     * Appends the UTF-8 string @a pszSrc to @a this.
     420     *
     421     * @param   pszSrc          The C-style string to append.
     422     * @returns S_OK, E_OUTOFMEMORY or E_INVAL (bad encoding).
     423     */
     424    HRESULT appendNoThrow(const char *pszSrc) RT_NOEXCEPT;
     425
     426    /**
     427     * Appends the a substring from @a rThat to @a this.
     428     *
     429     * @param   rThat           The string to append a substring from.
     430     * @param   offStart        The start of the substring to append (UTF-16
     431     *                          offset, not codepoint).
     432     * @param   cwcMax          The maximum number of UTF-16 units to append.
     433     * @throws  std::bad_alloc  On allocation error.  The object is left unchanged.
     434     * @returns Reference to the object.
     435     */
     436    Bstr &append(const Bstr &rThat, size_t offStart, size_t cwcMax = RTSTR_MAX);
     437
     438    /**
     439     * Appends the a substring from @a rThat to @a this.
     440     *
     441     * @param   rThat           The string to append a substring from.
     442     * @param   offStart        The start of the substring to append (UTF-16
     443     *                          offset, not codepoint).
     444     * @param   cwcMax          The maximum number of UTF-16 units to append.
     445     * @returns S_OK, E_OUTOFMEMORY or E_INVAL (bad encoding).
     446     */
     447    HRESULT appendNoThrow(const Bstr &rThat, size_t offStart, size_t cwcMax = RTSTR_MAX) RT_NOEXCEPT;
     448
     449    /**
     450     * Appends the a substring from UTF-8 @a rThat to @a this.
     451     *
     452     * @param   rThat           The string to append a substring from.
     453     * @param   offStart        The start of the substring to append (byte offset,
     454     *                          not codepoint).
     455     * @param   cchMax          The maximum number of bytes to append.
     456     * @throws  std::bad_alloc  On allocation error.  The object is left unchanged.
     457     * @returns Reference to the object.
     458     */
     459    Bstr &append(const RTCString &rThat, size_t offStart, size_t cchMax = RTSTR_MAX);
     460
     461    /**
     462     * Appends the a substring from UTF-8 @a rThat to @a this.
     463     *
     464     * @param   rThat           The string to append a substring from.
     465     * @param   offStart        The start of the substring to append (byte offset,
     466     *                          not codepoint).
     467     * @param   cchMax          The maximum number of bytes to append.
     468     * @returns S_OK, E_OUTOFMEMORY or E_INVAL (bad encoding).
     469     */
     470    HRESULT appendNoThrow(const RTCString &rThat, size_t offStart, size_t cchMax = RTSTR_MAX) RT_NOEXCEPT;
     471
     472    /**
     473     * Appends the first @a cchMax chars from UTF-16 string @a pszThat to @a this.
     474     *
     475     * @param   pwszThat        The C-style UTF-16 string to append.
     476     * @param   cchMax          The maximum number of bytes to append.
     477     * @throws  std::bad_alloc  On allocation error.  The object is left unchanged.
     478     * @returns Reference to the object.
     479     */
     480    Bstr &append(CBSTR pwszThat, size_t cchMax);
     481
     482    /**
     483     * Appends the first @a cchMax chars from UTF-16 string @a pszThat to @a this.
     484     *
     485     * @param   pwszThat        The C-style UTF-16 string to append.
     486     * @param   cchMax          The maximum number of bytes to append.
     487     * @returns S_OK, E_OUTOFMEMORY or E_INVAL (bad encoding).
     488     */
     489    HRESULT appendNoThrow(CBSTR pwszThat, size_t cchMax) RT_NOEXCEPT;
     490
     491    /**
     492     * Appends the first @a cchMax chars from string @a pszThat to @a this.
     493     *
     494     * @param   pszThat         The C-style string to append.
     495     * @param   cchMax          The maximum number of bytes to append.
     496     * @throws  std::bad_alloc  On allocation error.  The object is left unchanged.
     497     * @returns Reference to the object.
     498     */
     499    Bstr &append(const char *pszThat, size_t cchMax);
     500
     501    /**
     502     * Appends the first @a cchMax chars from string @a pszThat to @a this.
     503     *
     504     * @param   pszThat         The C-style string to append.
     505     * @param   cchMax          The maximum number of bytes to append.
     506     * @returns S_OK, E_OUTOFMEMORY or E_INVAL (bad encoding).
     507     */
     508    HRESULT appendNoThrow(const char *pszThat, size_t cchMax) RT_NOEXCEPT;
     509
     510    /**
     511     * Appends the given character to @a this.
     512     *
     513     * @param   ch              The character to append.
     514     * @throws  std::bad_alloc  On allocation error.  The object is left unchanged.
     515     * @returns Reference to the object.
     516     */
     517    Bstr &append(char ch);
     518
     519    /**
     520     * Appends the given character to @a this.
     521     *
     522     * @param   ch              The character to append.
     523     * @returns S_OK, E_OUTOFMEMORY or E_INVAL (bad encoding).
     524     */
     525    HRESULT appendNoThrow(char ch) RT_NOEXCEPT;
     526
     527    /**
     528     * Appends the given unicode code point to @a this.
     529     *
     530     * @param   uc              The unicode code point to append.
     531     * @throws  std::bad_alloc  On allocation error.  The object is left unchanged.
     532     * @returns Reference to the object.
     533     */
     534    Bstr &appendCodePoint(RTUNICP uc);
     535
     536    /**
     537     * Appends the given unicode code point to @a this.
     538     *
     539     * @param   uc              The unicode code point to append.
     540     * @returns S_OK, E_OUTOFMEMORY or E_INVAL (bad encoding).
     541     */
     542    HRESULT appendCodePointNoThrow(RTUNICP uc) RT_NOEXCEPT;
     543
     544    /**
     545     * Appends the output of the string format operation (RTStrPrintf).
     546     *
     547     * @param   pszFormat       Pointer to the format string,
     548     *                          @see pg_rt_str_format.
     549     * @param   ...             Ellipsis containing the arguments specified by
     550     *                          the format string.
     551     *
     552     * @throws  std::bad_alloc  On allocation error.  Object state is undefined.
     553     *
     554     * @returns Reference to the object.
     555     */
     556    Bstr &appendPrintf(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
     557
     558    /**
     559     * Appends the output of the string format operation (RTStrPrintf).
     560     *
     561     * @param   pszFormat       Pointer to the format string,
     562     *                          @see pg_rt_str_format.
     563     * @param   ...             Ellipsis containing the arguments specified by
     564     *                          the format string.
     565     *
     566     * @returns S_OK, E_OUTOFMEMORY or E_INVAL (bad encoding).
     567     */
     568    HRESULT appendPrintfNoThrow(const char *pszFormat, ...) RT_NOEXCEPT RT_IPRT_FORMAT_ATTR(1, 2);
     569
     570    /**
     571     * Appends the output of the string format operation (RTStrPrintfV).
     572     *
     573     * @param   pszFormat       Pointer to the format string,
     574     *                          @see pg_rt_str_format.
     575     * @param   va              Argument vector containing the arguments
     576     *                          specified by the format string.
     577     *
     578     * @throws  std::bad_alloc  On allocation error.  Object state is undefined.
     579     *
     580     * @returns Reference to the object.
     581     */
     582    Bstr &appendPrintfV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
     583
     584    /**
     585     * Appends the output of the string format operation (RTStrPrintfV).
     586     *
     587     * @param   pszFormat       Pointer to the format string,
     588     *                          @see pg_rt_str_format.
     589     * @param   va              Argument vector containing the arguments
     590     *                          specified by the format string.
     591     *
     592     * @returns S_OK, E_OUTOFMEMORY or E_INVAL (bad encoding).
     593     */
     594    HRESULT appendPrintfVNoThrow(const char *pszFormat, va_list va) RT_NOEXCEPT RT_IPRT_FORMAT_ATTR(1, 0);
     595
     596    /**
     597     * Shortcut to append(), Bstr variant.
     598     *
     599     * @param   rThat           The string to append.
     600     * @returns Reference to the object.
     601     */
     602    Bstr &operator+=(const Bstr &rThat)
     603    {
     604        return append(rThat);
     605    }
     606
     607    /**
     608     * Shortcut to append(), RTCString variant.
     609     *
     610     * @param   rThat           The string to append.
     611     * @returns Reference to the object.
     612     */
     613    Bstr &operator+=(const RTCString &rThat)
     614    {
     615        return append(rThat);
     616    }
     617
     618    /**
     619     * Shortcut to append(), CBSTR variant.
     620     *
     621     * @param   pwszThat        The C-style string to append.
     622     * @returns                 Reference to the object.
     623     */
     624    Bstr &operator+=(CBSTR pwszThat)
     625    {
     626        return append(pwszThat);
     627    }
     628
     629    /**
     630     * Shortcut to append(), const char * variant.
     631     *
     632     * @param   pszThat         The C-style string to append.
     633     * @returns                 Reference to the object.
     634     */
     635    Bstr &operator+=(const char *pszThat)
     636    {
     637        return append(pszThat);
     638    }
     639
     640#if 0
     641    /**
     642     * Shortcut to append(), char variant.
     643     *
     644     * @param ch                The character to append.
     645     *
     646     * @returns                 Reference to the object.
     647     */
     648    Bstr &operator+=(char ch)
     649    {
     650        return append(ch);
     651    }
     652#endif
     653
     654    /** @} */
    354655
    355656#if defined(VBOX_WITH_XPCOM)
     
    643944     */
    644945    void copyFromN(const char *a_pszSrc, size_t a_cchSrc);
     946
     947    Bstr   &appendWorkerUtf16(PCRTUTF16 pwszSrc, size_t cwcSrc);
     948    Bstr   &appendWorkerUtf8(const char *pszSrc, size_t cchSrc);
     949    HRESULT appendWorkerUtf16NoThrow(PCRTUTF16 pwszSrc, size_t cwcSrc) RT_NOEXCEPT;
     950    HRESULT appendWorkerUtf8NoThrow(const char *pszSrc, size_t cchSrc) RT_NOEXCEPT;
    645951
    646952    static DECLCALLBACK(size_t) printfOutputCallbackNoThrow(void *pvArg, const char *pachChars, size_t cbChars) RT_NOEXCEPT;
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