summaryrefslogtreecommitdiff
path: root/comphelper/source/misc
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-11-22 23:40:24 +0000
committerCaolán McNamara <caolanm@redhat.com>2011-11-23 10:10:09 +0000
commitb7ea36101497c275cb08b0e37facbde656197d9b (patch)
treea05e25d4f01c94c69712d17a1ab4cdbc925ef355 /comphelper/source/misc
parent62d880f3228c7f5c3f8a1d30f5a5c9ed390a1eb5 (diff)
add stripStart, can replace EraseTrailingChars
Diffstat (limited to 'comphelper/source/misc')
-rw-r--r--comphelper/source/misc/string.cxx31
1 files changed, 31 insertions, 0 deletions
diff --git a/comphelper/source/misc/string.cxx b/comphelper/source/misc/string.cxx
index 09fb2684e7ce..02d1cd4d104c 100644
--- a/comphelper/source/misc/string.cxx
+++ b/comphelper/source/misc/string.cxx
@@ -200,6 +200,37 @@ rtl::OUString stripStart(const rtl::OUString &rIn, sal_Unicode c)
return tmpl_stripStart<rtl::OUString, sal_Unicode>(rIn, c);
}
+namespace
+{
+ template <typename T, typename C> T tmpl_stripEnd(const T &rIn,
+ const C cRemove)
+ {
+ if (rIn.isEmpty())
+ return rIn;
+
+ sal_Int32 i = rIn.getLength();
+
+ while (i > 0)
+ {
+ if (rIn[i-1] != cRemove)
+ break;
+ --i;
+ }
+
+ return rIn.copy(0, i);
+ }
+}
+
+rtl::OString stripEnd(const rtl::OString &rIn, sal_Char c)
+{
+ return tmpl_stripEnd<rtl::OString, sal_Char>(rIn, c);
+}
+
+rtl::OUString stripEnd(const rtl::OUString &rIn, sal_Unicode c)
+{
+ return tmpl_stripEnd<rtl::OUString, sal_Unicode>(rIn, c);
+}
+
sal_uInt32 decimalStringToNumber(
::rtl::OUString const & str )
{