summaryrefslogtreecommitdiff
path: root/comphelper/inc/comphelper
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-08-15 00:22:23 +0100
committerCaolán McNamara <caolanm@redhat.com>2011-08-15 09:21:49 +0100
commit061ebc34468c37d27524352de56faaf9df742556 (patch)
tree96d924d1f23690029ba13598290858881bdb2495 /comphelper/inc/comphelper
parent90fe8dadaaad07aee2ec513eab1ad75bbf306cb3 (diff)
add a getToken wrapper for extracting a single token painlessly
Diffstat (limited to 'comphelper/inc/comphelper')
-rw-r--r--comphelper/inc/comphelper/string.hxx28
1 files changed, 28 insertions, 0 deletions
diff --git a/comphelper/inc/comphelper/string.hxx b/comphelper/inc/comphelper/string.hxx
index 886074dc5682..c576a24ae6f5 100644
--- a/comphelper/inc/comphelper/string.hxx
+++ b/comphelper/inc/comphelper/string.hxx
@@ -134,6 +134,34 @@ COMPHELPER_DLLPUBLIC rtl::OString replace(const rtl::OString &rIn,
COMPHELPER_DLLPUBLIC rtl::OUString replace(const rtl::OUString &rIn,
const rtl::OUString &rSearch, const rtl::OUString &rReplace);
+/** Returns a token in the OString
+
+ @param token 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,
+ sal_Int32 nToken, sal_Char cTok) SAL_THROW(())
+{
+ sal_Int32 nIndex = 0;
+ return rIn.getToken(nToken, cTok, nIndex);
+}
+
+/** Returns a token in the OUString
+
+ @param token 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,
+ sal_Int32 nToken, sal_Unicode cTok) SAL_THROW(())
+{
+ sal_Int32 nIndex = 0;
+ return rIn.getToken(nToken, cTok, nIndex);
+}
+
/** Convert a sequence of strings to a single comma separated string.
Note that no escaping of commas or anything fancy is done.