diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-08-17 09:53:41 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-08-17 09:54:14 +0100 |
commit | 0c571e233f8824ab0ccd907e72dd8a81527f0998 (patch) | |
tree | a94236182b3f24c47000078751730370f69f28ca /comphelper | |
parent | bb70a1256200a593489005ce175d57fd246164ad (diff) |
add and use a matchL
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/inc/comphelper/string.hxx | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/comphelper/inc/comphelper/string.hxx b/comphelper/inc/comphelper/string.hxx index c576a24ae6f5..3e74ca452aaa 100644 --- a/comphelper/inc/comphelper/string.hxx +++ b/comphelper/inc/comphelper/string.hxx @@ -162,6 +162,29 @@ COMPHELPER_DLLPUBLIC inline rtl::OUString getToken(const rtl::OUString &rIn, return rIn.getToken(nToken, cTok, nIndex); } +/** + Match against a substring appearing in another string. + + The result is true if and only if the second string appears as a substring + of the first string, at the given position. + This function can't be used for language specific comparison. + + @param rStr The string that pMatch will be compared to. + @param pMatch The substring rStr is to be compared against + @param nMatchLen The length of pMatch + @param fromIndex The index to start the comparion from. + The index must be greater or equal than 0 + and less or equal as the string length. + @return sal_True if pMatch match with the characters in the string + at the given position; + sal_False, otherwise. +*/ +COMPHELPER_DLLPUBLIC inline sal_Bool matchL(const rtl::OString& rStr, const char *pMatch, sal_Int32 nMatchLen, sal_Int32 fromIndex = 0) SAL_THROW(()) +{ + return rtl_str_shortenedCompare_WithLength( rStr.pData->buffer+fromIndex, + rStr.pData->length-fromIndex, pMatch, nMatchLen, nMatchLen ) == 0; +} + /** Convert a sequence of strings to a single comma separated string. Note that no escaping of commas or anything fancy is done. |