summaryrefslogtreecommitdiff
path: root/comphelper/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-11-22 17:17:53 +0000
committerCaolán McNamara <caolanm@redhat.com>2011-11-23 10:10:08 +0000
commit20153742d2dee2df022275a07cc958b1759b9b72 (patch)
treea91d3d42faa559783d407bb1fe08f4070d945762 /comphelper/source
parenta22ce3e4483f6fe462eaba8826a91355957e3676 (diff)
add a stripStart, can replace EraseLeadingChars
Diffstat (limited to 'comphelper/source')
-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 8525e79bd4fc..09fb2684e7ce 100644
--- a/comphelper/source/misc/string.cxx
+++ b/comphelper/source/misc/string.cxx
@@ -169,6 +169,37 @@ rtl::OUString remove(const rtl::OUString &rIn, sal_Unicode c)
return tmpl_remove<rtl::OUString, sal_Unicode, rtl::OUStringBuffer>(rIn, c);
}
+namespace
+{
+ template <typename T, typename C> T tmpl_stripStart(const T &rIn,
+ const C cRemove)
+ {
+ if (rIn.isEmpty())
+ return rIn;
+
+ sal_Int32 i = 0;
+
+ while (i < rIn.getLength())
+ {
+ if (rIn[i] != cRemove)
+ break;
+ ++i;
+ }
+
+ return rIn.copy(i);
+ }
+}
+
+rtl::OString stripStart(const rtl::OString &rIn, sal_Char c)
+{
+ return tmpl_stripStart<rtl::OString, sal_Char>(rIn, c);
+}
+
+rtl::OUString stripStart(const rtl::OUString &rIn, sal_Unicode c)
+{
+ return tmpl_stripStart<rtl::OUString, sal_Unicode>(rIn, c);
+}
+
sal_uInt32 decimalStringToNumber(
::rtl::OUString const & str )
{