From 0c571e233f8824ab0ccd907e72dd8a81527f0998 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 17 Aug 2011 09:53:41 +0100 Subject: add and use a matchL --- comphelper/inc/comphelper/string.hxx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'comphelper') 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. -- cgit