VirtualBox

Ignore:
Timestamp:
Jul 24, 2017 12:44:02 PM (7 years ago)
Author:
vboxsync
Message:

RTCString: Added startsWithWord method.

File:
1 edited

Legend:

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

    r67688 r68094  
    3434#include <iprt/cpp/ministring.h>
    3535#include <iprt/ctype.h>
     36#include <iprt/uni.h>
    3637
    3738
     
    488489}
    489490
     491bool RTCString::startsWithWord(const char *pszWord, CaseSensitivity enmCase /*= CaseSensitive*/) const
     492{
     493    const char *pszSrc  = RTStrStripL(c_str()); /** @todo RTStrStripL doesn't use RTUniCpIsSpace (nbsp) */
     494    size_t      cchWord = strlen(pszWord);
     495    if (  enmCase == CaseSensitive
     496        ? RTStrNCmp(pszSrc, pszWord, cchWord) == 0
     497        : RTStrNICmp(pszSrc, pszWord, cchWord) == 0)
     498    {
     499        if (   pszSrc[cchWord] == '\0'
     500            || RT_C_IS_SPACE(pszSrc[cchWord])
     501            || RT_C_IS_PUNCT(pszSrc[cchWord]) )
     502            return true;
     503        RTUNICP uc = RTStrGetCp(&pszSrc[cchWord]);
     504        if (RTUniCpIsSpace(uc))
     505            return true;
     506    }
     507    return false;
     508}
     509
     510bool RTCString::startsWithWord(const RTCString &rThat, CaseSensitivity enmCase /*= CaseSensitive*/) const
     511{
     512    return startsWithWord(rThat.c_str(), enmCase);
     513}
     514
    490515bool RTCString::contains(const RTCString &that, CaseSensitivity cs /*= CaseSensitive*/) const
    491516{
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