VirtualBox

Changeset 18529 in vbox


Ignore:
Timestamp:
Mar 30, 2009 11:54:06 AM (15 years ago)
Author:
vboxsync
Message:

Main: added toLower, toUpper & contains

File:
1 edited

Legend:

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

    r18148 r18529  
    504504    }
    505505
     506    bool contains (const Utf8Str &that, CaseSensitivity cs = CaseSensitive) const
     507    {
     508        if (isNull() || that.isNull())
     509            return false;
     510
     511        char *pszString = ::RTStrDup(str);
     512        char *pszTmp;
     513
     514        /* Create the generic pattern */
     515        ::RTStrAPrintf(&pszTmp, "*%s*", that.str);
     516        /* We have to duplicate the strings as long as there is no case
     517         * insensitive version of RTStrSimplePatternMatch. */
     518        if (cs == CaseInsensitive)
     519        {
     520            pszTmp = ::RTStrToLower(pszTmp);
     521            pszString = ::RTStrToLower(pszString);
     522        }
     523        bool fResult = ::RTStrSimplePatternMatch(pszTmp, pszString);
     524        RTStrFree(pszTmp);
     525        RTStrFree(pszString);
     526
     527        return fResult;
     528    }
     529
     530    Utf8Str& toLower()
     531    {
     532        if (isEmpty())
     533            return *this;
     534
     535        ::RTStrToLower(str);
     536
     537        return *this;
     538    }
     539
     540    Utf8Str& toUpper()
     541    {
     542        if (isEmpty())
     543            return *this;
     544
     545        ::RTStrToUpper(str);
     546
     547        return *this;
     548    }
     549
    506550    bool isNull() const { return str == NULL; }
    507551    operator bool() const { return !isNull(); }
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