summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-10-09 09:50:37 +0100
committerCaolán McNamara <caolanm@redhat.com>2013-10-09 13:17:27 +0100
commit5089bdb234a93bcb62b597c18b8ab66048246b13 (patch)
tree0983967d89d9662b8484c88d2590cfdd7362fa43 /comphelper
parent0ba03a38f022ca8d3705ae1370bb1d739e1e973f (diff)
Related: fdo#38838 remove UniString::EqualsAscii
Change-Id: I55c85c1c44452c7fb6ac40591aea7177d054affe
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/misc/string.cxx32
1 files changed, 32 insertions, 0 deletions
diff --git a/comphelper/source/misc/string.cxx b/comphelper/source/misc/string.cxx
index fc15b09f17a1..f59653130e06 100644
--- a/comphelper/source/misc/string.cxx
+++ b/comphelper/source/misc/string.cxx
@@ -417,6 +417,38 @@ sal_Int32 indexOfAny(OUString const& rIn,
return -1;
}
+OUString setToken(const OUString& rIn, sal_Int32 nToken, sal_Unicode cTok,
+ const OUString& rNewToken)
+{
+ const sal_Unicode* pStr = rIn.getStr();
+ sal_Int32 nLen = rIn.getLength();
+ sal_Int32 nTok = 0;
+ sal_Int32 nFirstChar = 0;
+ sal_Int32 i = 0;
+
+ // Determine token position and length
+ while ( i < nLen )
+ {
+ // Increase token count if match
+ if (*pStr == cTok)
+ {
+ ++nTok;
+
+ if (nTok == nToken)
+ nFirstChar = i+1;
+ else if (nTok > nToken)
+ break;
+ }
+
+ ++pStr,
+ ++i;
+ }
+
+ if (nTok >= nToken)
+ return rIn.replaceAt(nFirstChar, i-nFirstChar, rNewToken);
+ return rIn;
+}
+
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */