VirtualBox

Ignore:
Timestamp:
Jan 27, 2012 3:25:44 PM (13 years ago)
Author:
vboxsync
Message:

RTCString: Adding count() from QString, implementing one of the three variants.

File:
1 edited

Legend:

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

    r39873 r39897  
    216216}
    217217
    218 void RTCString::findReplace(char cFind, char cReplace)
    219 {
     218void RTCString::findReplace(char chFind, char chReplace)
     219{
     220    Assert((unsigned int)chFind    < 128U);
     221    Assert((unsigned int)chReplace < 128U);
     222
    220223    for (size_t i = 0; i < length(); ++i)
    221224    {
    222225        char *p = &m_psz[i];
    223         if (*p == cFind)
    224             *p = cReplace;
    225     }
    226 }
     226        if (*p == chFind)
     227            *p = chReplace;
     228    }
     229}
     230
     231size_t RTCString::count(char ch) const
     232{
     233    Assert((unsigned int)ch < 128U);
     234
     235    size_t      c   = 0;
     236    const char *psz = m_psz;
     237    char        chCur;
     238    while ((chCur = *psz++) != '\0')
     239        if (chCur == ch)
     240            c++;
     241    return c;
     242}
     243
     244#if 0  /** @todo implement these when needed. */
     245size_t RTCString::count(const char *psz, CaseSensitivity cs = CaseSensitive) const
     246{
     247}
     248
     249size_t RTCString::count(const RTCString *pStr, CaseSensitivity cs = CaseSensitive) const
     250{
     251
     252}
     253#endif
    227254
    228255RTCString RTCString::substrCP(size_t pos /*= 0*/, size_t n /*= npos*/) const
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