VirtualBox

Changeset 39897 in vbox


Ignore:
Timestamp:
Jan 27, 2012 3:25:44 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
75956
Message:

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

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/cpp/ministring.h

    r39277 r39897  
    688688     * values less than 128; this is not verified.
    689689     *
    690      * @param cFind Character to replace. Must be ASCII < 128.
    691      * @param cReplace Character to replace cFind with. Must be ASCII < 128.
    692      */
    693     void findReplace(char cFind, char cReplace);
     690     * @param   chFind      Character to replace. Must be ASCII < 128.
     691     * @param   chReplace   Character to replace cFind with. Must be ASCII < 128.
     692     */
     693    void findReplace(char chFind, char chReplace);
     694
     695    /**
     696     * Count the occurences of the specified character in the string.
     697     *
     698     * @param   ch          What to search for. Must be ASCII < 128.
     699     * @remarks QString::count
     700     */
     701    size_t count(char ch) const;
     702
     703    /**
     704     * Count the occurences of the specified sub-string in the string.
     705     *
     706     * @param   psz         What to search for.
     707     * @param   cs          Case sensitivity selector.
     708     * @remarks QString::count
     709     */
     710    size_t count(const char *psz, CaseSensitivity cs = CaseSensitive) const;
     711
     712    /**
     713     * Count the occurences of the specified sub-string in the string.
     714     *
     715     * @param   pStr        What to search for.
     716     * @param   cs          Case sensitivity selector.
     717     * @remarks QString::count
     718     */
     719    size_t count(const RTCString *pStr, CaseSensitivity cs = CaseSensitive) const;
    694720
    695721    /**
  • 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.

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