summaryrefslogtreecommitdiff
path: root/comphelper/inc/comphelper/string.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'comphelper/inc/comphelper/string.hxx')
-rw-r--r--comphelper/inc/comphelper/string.hxx192
1 files changed, 20 insertions, 172 deletions
diff --git a/comphelper/inc/comphelper/string.hxx b/comphelper/inc/comphelper/string.hxx
index 2c63954a3535..f52021d9b68f 100644
--- a/comphelper/inc/comphelper/string.hxx
+++ b/comphelper/inc/comphelper/string.hxx
@@ -112,113 +112,33 @@ COMPHELPER_DLLPUBLIC inline rtl_String * SAL_CALL rtl_string_alloc(sal_Int32 nLe
return detail::string_alloc<rtl_String, sal_Char>(nLen);
}
-/**
- Replace the first occurrence of a substring with another string.
-
- @param source
- The source string, in which the search will take place.
-
- @param from
- The ASCII substring to search for. Must point to at least fromLength ASCII
- characters.
-
- @param fromLength
- The length of the from substring. Must not be negative.
-
- @param to
- The string to use as replacement.
-
- @param beginAt
- The index at which to begin the search. Must be between zero and the length
- of source, inclusive.
-
- @param replacedAt
- If non-null, receives the starting index at which the replacement took place
- or -1 if from was not found.
-
- @return
- The resulting string, in which the replacement has taken place.
-*/
-COMPHELPER_DLLPUBLIC rtl::OUString searchAndReplaceAsciiL(
- rtl::OUString const & source, char const * from, sal_Int32 fromLength,
- rtl::OUString const & to, sal_Int32 beginAt = 0,
- sal_Int32 * replacedAt = NULL);
-
-/** replaces, in the given source string, all occurrences of a given ASCII pattern
- with another ASCII pattern
-*/
-COMPHELPER_DLLPUBLIC ::rtl::OUString searchAndReplaceAllAsciiWithAscii(
- const ::rtl::OUString& source, const sal_Char* from, const sal_Char* to,
- const sal_Int32 beginAt = 0 );
-
-/** does an in-place replacement of the first occurrence of a sub string with
- another string
-
- @param source
- the string to search and replace in.
- @param asciiPattern
- the ASCII sub string to search for. Must point to a 0-terminated string.
- @param replace
- The string to use as replacement.
- @param beginAt
- The index at which to begin the search. Must be between zero and the length
- of source, inclusive.
-
- @param replacedAt
- If non-null, receives the starting index at which the replacement took place
- or -1 if from was not found.
-
- @return
- a reference to <code>source</code>
-*/
-COMPHELPER_DLLPUBLIC ::rtl::OUString&
- searchAndReplaceAsciiI( ::rtl::OUString & source, sal_Char const * asciiPattern,
- ::rtl::OUString const & replace, sal_Int32 beginAt = 0,
- sal_Int32 * replacedAt = NULL );
-
-/** Replaces each substring of this OString that matches the search OString
- with the specified replacement OString
-
- @param rIn The input OString
- @param rSearch The substring to be replaced
- @param rReplace The replacement substring
-
- @return The resulting OString
- */
-COMPHELPER_DLLPUBLIC rtl::OString replace(const rtl::OString &rIn,
- const rtl::OString &rSearch, const rtl::OString &rReplace);
-
-/** Replaces each substring of this OUString that matches the search OUString
- with the specified replacement OUString
-
- @param rIn The input OUString
- @param rSearch The substring to be replaced
- @param rReplace The replacement substring
-
- @return The resulting OUString
- */
-COMPHELPER_DLLPUBLIC rtl::OUString replace(const rtl::OUString &rIn,
- const rtl::OUString &rSearch, const rtl::OUString &rReplace);
-
/** Removes all occurrences of a character from within the source string
+ @deprecated Use rtl::OString::replaceAll(rtl::OString(c), rtl::OString())
+ instead.
+
@param rIn The input OString
@param c The character to be removed
@return The resulting OString
*/
-COMPHELPER_DLLPUBLIC rtl::OString remove(const rtl::OString &rIn,
- sal_Char c);
+inline rtl::OString remove(const rtl::OString &rIn,
+ sal_Char c)
+{ return rIn.replaceAll(rtl::OString(c), rtl::OString()); }
/** Removes all occurrences of a character from within the source string
+ @deprecated Use
+ rtl::OUString::replaceAll(rtl::OUString(c), rtl::OUString()) instead.
+
@param rIn The input OUString
@param c The character to be removed
@return The resulting OUString
*/
-COMPHELPER_DLLPUBLIC rtl::OUString remove(const rtl::OUString &rIn,
- sal_Unicode c);
+inline rtl::OUString remove(const rtl::OUString &rIn,
+ sal_Unicode c)
+{ return rIn.replaceAll(rtl::OUString(c), rtl::OUString()); }
/** Strips occurrences of a character from the start of the source string
@@ -282,32 +202,34 @@ COMPHELPER_DLLPUBLIC rtl::OUString strip(const rtl::OUString &rIn,
/** Returns a token in an OString
+ @deprecated Use rtl::OString::getToken(nToken, cTok) instead.
+
@param rIn the input OString
@param nToken the number of the token to return
@param cTok the character which seperate the tokens.
@return the token if token is negative or doesn't exist an empty token
is returned
*/
-COMPHELPER_DLLPUBLIC inline rtl::OString getToken(const rtl::OString &rIn,
+inline rtl::OString getToken(const rtl::OString &rIn,
sal_Int32 nToken, sal_Char cTok) SAL_THROW(())
{
- sal_Int32 nIndex = 0;
- return rIn.getToken(nToken, cTok, nIndex);
+ return rIn.getToken(nToken, cTok);
}
/** Returns a token in an OUString
+ @deprecated Use rtl::OUString::getToken(nToken, cTok) instead.
+
@param rIn the input OUString
@param nToken the number of the token to return
@param cTok the character which seperate the tokens.
@return the token if token is negative or doesn't exist an empty token
is returned
*/
-COMPHELPER_DLLPUBLIC inline rtl::OUString getToken(const rtl::OUString &rIn,
+inline rtl::OUString getToken(const rtl::OUString &rIn,
sal_Int32 nToken, sal_Unicode cTok) SAL_THROW(())
{
- sal_Int32 nIndex = 0;
- return rIn.getToken(nToken, cTok, nIndex);
+ return rIn.getToken(nToken, cTok);
}
/** Returns number of tokens in an OUString
@@ -326,80 +248,6 @@ COMPHELPER_DLLPUBLIC sal_Int32 getTokenCount(const rtl::OString &rIn, sal_Char c
*/
COMPHELPER_DLLPUBLIC sal_Int32 getTokenCount(const rtl::OUString &rIn, sal_Unicode cTok);
-/**
- 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;
-}
-
-/**
- Match against a substring appearing in this string, ignoring the case of
- ASCII letters.
-
- The result is true if and only if the second string appears as a substring
- of this string, at the given position.
- Character values between 65 and 90 (ASCII A-Z) are interpreted as
- values between 97 and 122 (ASCII a-z).
- 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 str match with the characters in the string
- at the given position;
- sal_False, otherwise.
-*/
-COMPHELPER_DLLPUBLIC inline sal_Bool matchIgnoreAsciiCaseL(const rtl::OString& rStr, const char *pMatch, sal_Int32 nMatchLen, sal_Int32 fromIndex = 0) SAL_THROW(())
-{
- return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( rStr.pData->buffer+fromIndex, rStr.pData->length-fromIndex,
- pMatch, nMatchLen,
- nMatchLen ) == 0;
-}
-
-/**
- Returns the index within this string of the first occurrence of the
- specified substring, starting at the specified index.
-
- If str doesn't include any character, always -1 is
- returned. This is also the case, if both strings are empty.
-
- @param rStr The string that pSearch will be searched within.
- @param pSearch the substring to search for.
- @param nSearchLen the length of pSearch
- @param fromIndex the index to start the search from.
- @return If the string argument occurs one or more times as a substring
- within this string at the starting index, then the index
- of the first character of the first such substring is
- returned. If it does not occur as a substring starting
- at fromIndex or beyond, -1 is returned.
-*/
-COMPHELPER_DLLPUBLIC inline sal_Int32 indexOfL(const rtl::OString& rStr, const char *pSearch, sal_Int32 nSearchLen, sal_Int32 fromIndex = 0) SAL_THROW(())
-{
- sal_Int32 ret = rtl_str_indexOfStr_WithLength(rStr.pData->buffer+fromIndex,
- rStr.pData->length-fromIndex, pSearch, nSearchLen);
- return (ret < 0 ? ret : ret+fromIndex);
-}
-
namespace detail
{
template<typename B> B& truncateToLength(B& rBuffer, sal_Int32 nLen)