VirtualBox

Ignore:
Timestamp:
Aug 27, 2018 10:15:30 AM (6 years ago)
Author:
vboxsync
Message:

iprt/cpp/ministring.h: Added appendPrintf with all variants. Marked a lot of methods with noexcept.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/string/ministring.cpp

    r73907 r73908  
    283283}
    284284
     285RTCString &RTCString::appendPrintfV(const char *pszFormat, va_list va)
     286{
     287    RTStrFormatV(printfOutputCallback, this, NULL, NULL, pszFormat, va);
     288    return *this;
     289}
     290
    285291struct RTCSTRINGOTHROW
    286292{
     
    338344}
    339345
     346int RTCString::appendPrintfVNoThrow(const char *pszFormat, va_list va) RT_NOEXCEPT
     347{
     348    RTCSTRINGOTHROW Args = { this, VINF_SUCCESS };
     349    RTStrFormatV(printfOutputCallback, &Args, NULL, NULL, pszFormat, va);
     350    return Args.rc;
     351}
     352
     353RTCString &RTCString::appendPrintf(const char *pszFormat, ...)
     354{
     355    va_list va;
     356    va_start(va, pszFormat);
     357    appendPrintfV(pszFormat, va);
     358    va_end(va);
     359    return *this;
     360}
     361
     362int RTCString::appendPrintfNoThrow(const char *pszFormat, ...) RT_NOEXCEPT
     363{
     364    va_list va;
     365    va_start(va, pszFormat);
     366    int rc = appendPrintfVNoThrow(pszFormat, va);
     367    va_end(va);
     368    return rc;
     369}
     370
    340371RTCString &RTCString::append(const RTCString &that)
    341372{
     
    538569}
    539570
    540 
    541 RTCString &RTCString::erase(size_t offStart /*= 0*/, size_t cchLength /*= npos*/)
     571RTCString &RTCString::erase(size_t offStart /*= 0*/, size_t cchLength /*= npos*/) RT_NOEXCEPT
    542572{
    543573    size_t cch = length();
     
    592622
    593623int RTCString::replaceNoThrow(size_t offStart, size_t cchLength, const RTCString &rStrReplacement,
    594                               size_t offReplacement, size_t cchReplacement)
     624                              size_t offReplacement, size_t cchReplacement) RT_NOEXCEPT
    595625{
    596626    Assert(this != &rStrReplacement);
     
    713743
    714744
    715 size_t RTCString::find(const char *pszNeedle, size_t offStart /*= 0*/) const
     745size_t RTCString::find(const char *pszNeedle, size_t offStart /*= 0*/) const RT_NOEXCEPT
    716746{
    717747    if (offStart < length())
     
    732762}
    733763
    734 size_t RTCString::find(const RTCString *pStrNeedle, size_t offStart /*= 0*/) const
     764size_t RTCString::find(const RTCString *pStrNeedle, size_t offStart /*= 0*/) const RT_NOEXCEPT
    735765{
    736766    if (offStart < length())
     
    755785}
    756786
    757 void RTCString::findReplace(char chFind, char chReplace)
     787void RTCString::findReplace(char chFind, char chReplace) RT_NOEXCEPT
    758788{
    759789    Assert((unsigned int)chFind    < 128U);
     
    768798}
    769799
    770 size_t RTCString::count(char ch) const
     800size_t RTCString::count(char ch) const RT_NOEXCEPT
    771801{
    772802    Assert((unsigned int)ch < 128U);
     
    785815
    786816#if 0  /** @todo implement these when needed. */
    787 size_t RTCString::count(const char *psz, CaseSensitivity cs = CaseSensitive) const
    788 {
    789 }
    790 
    791 size_t RTCString::count(const RTCString *pStr, CaseSensitivity cs = CaseSensitive) const
     817size_t RTCString::count(const char *psz, CaseSensitivity cs = CaseSensitive) const RT_NOEXCEPT
     818{
     819}
     820
     821size_t RTCString::count(const RTCString *pStr, CaseSensitivity cs = CaseSensitive) const RT_NOEXCEPT
    792822{
    793823
     
    796826
    797827
    798 RTCString &RTCString::strip()
     828RTCString &RTCString::strip() RT_NOEXCEPT
    799829{
    800830    stripRight();
     
    803833
    804834
    805 RTCString &RTCString::stripLeft()
     835RTCString &RTCString::stripLeft() RT_NOEXCEPT
    806836{
    807837    char        *psz = m_psz;
     
    824854
    825855
    826 RTCString &RTCString::stripRight()
     856RTCString &RTCString::stripRight() RT_NOEXCEPT
    827857{
    828858    char  *psz = m_psz;
     
    888918}
    889919
    890 bool RTCString::endsWith(const RTCString &that, CaseSensitivity cs /*= CaseSensitive*/) const
     920bool RTCString::endsWith(const RTCString &that, CaseSensitivity cs /*= CaseSensitive*/) const RT_NOEXCEPT
    891921{
    892922    size_t l1 = length();
     
    906936}
    907937
    908 bool RTCString::startsWith(const RTCString &that, CaseSensitivity cs /*= CaseSensitive*/) const
     938bool RTCString::startsWith(const RTCString &that, CaseSensitivity cs /*= CaseSensitive*/) const RT_NOEXCEPT
    909939{
    910940    size_t l1 = length();
     
    921951}
    922952
    923 bool RTCString::startsWithWord(const char *pszWord, CaseSensitivity enmCase /*= CaseSensitive*/) const
     953bool RTCString::startsWithWord(const char *pszWord, CaseSensitivity enmCase /*= CaseSensitive*/) const RT_NOEXCEPT
    924954{
    925955    const char *pszSrc  = RTStrStripL(c_str()); /** @todo RTStrStripL doesn't use RTUniCpIsSpace (nbsp) */
     
    940970}
    941971
    942 bool RTCString::startsWithWord(const RTCString &rThat, CaseSensitivity enmCase /*= CaseSensitive*/) const
     972bool RTCString::startsWithWord(const RTCString &rThat, CaseSensitivity enmCase /*= CaseSensitive*/) const RT_NOEXCEPT
    943973{
    944974    return startsWithWord(rThat.c_str(), enmCase);
    945975}
    946976
    947 bool RTCString::contains(const RTCString &that, CaseSensitivity cs /*= CaseSensitive*/) const
     977bool RTCString::contains(const RTCString &that, CaseSensitivity cs /*= CaseSensitive*/) const RT_NOEXCEPT
    948978{
    949979    /** @todo r-bird: Not checking for NULL strings like startsWith does (and
     
    954984}
    955985
    956 bool RTCString::contains(const char *pszNeedle, CaseSensitivity cs /*= CaseSensitive*/) const
     986bool RTCString::contains(const char *pszNeedle, CaseSensitivity cs /*= CaseSensitive*/) const RT_NOEXCEPT
    957987{
    958988    /** @todo r-bird: Not checking for NULL strings like startsWith does (and
     
    963993}
    964994
    965 int RTCString::toInt(uint64_t &i) const
     995int RTCString::toInt(uint64_t &i) const RT_NOEXCEPT
    966996{
    967997    if (!m_psz)
     
    9701000}
    9711001
    972 int RTCString::toInt(uint32_t &i) const
     1002int RTCString::toInt(uint32_t &i) const RT_NOEXCEPT
    9731003{
    9741004    if (!m_psz)
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