VirtualBox

Changeset 80838 in vbox for trunk/src/VBox/Main/glue


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

Main/glue: Added an erase method identical to the one in RTCString.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/glue/string.cpp

    r80836 r80838  
    575575
    576576
     577Bstr &Bstr::erase(size_t offStart /*= 0*/, size_t cwcLength /*= RTSTR_MAX*/) RT_NOEXCEPT
     578{
     579    size_t cwc = length();
     580    if (offStart < cwc)
     581    {
     582        if (cwcLength >= cwc - offStart)
     583        {
     584            if (!offStart)
     585                cleanup();
     586            else
     587            {
     588                /* Trail removal, nothing to move.  */
     589                m_bstr[offStart] = '\0';
     590                joltNoThrow(offStart); /* not entirely optimal... */
     591            }
     592        }
     593        else if (cwcLength > 0)
     594        {
     595            /* Pull up the tail to offStart. */
     596            size_t cwcAfter = cwc - offStart - cwcLength;
     597            memmove(&m_bstr[offStart], &m_bstr[offStart + cwcLength], cwcAfter * sizeof(*m_bstr));
     598            cwc -= cwcLength;
     599            m_bstr[cwc] = '\0';
     600            joltNoThrow(cwc); /* not entirely optimal... */
     601        }
     602    }
     603    return *this;
     604}
     605
    577606
    578607/*********************************************************************************************************************************
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