[Libreoffice-commits] .: sal/inc

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Nov 21 06:58:22 PST 2012


 sal/inc/rtl/ustrbuf.hxx |   66 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)

New commits:
commit 95841e1393868f0fa7d015b31accea960d35a7b6
Author: Norbert Thiebaud <nthiebaud at gmail.com>
Date:   Mon Nov 19 22:34:58 2012 -0600

    add strip* Family of function to OUStringBuffer
    
    Change-Id: I225f95601009704c93484b6a68a0efd2446d4b48
    Reviewed-on: https://gerrit.libreoffice.org/1140
    Reviewed-by: Luboš Luňák <l.lunak at suse.cz>
    Tested-by: Norbert Thiebaud <nthiebaud at gmail.com>
    Reviewed-by: Norbert Thiebaud <nthiebaud at gmail.com>

diff --git a/sal/inc/rtl/ustrbuf.hxx b/sal/inc/rtl/ustrbuf.hxx
index 201e790..a82a30b 100644
--- a/sal/inc/rtl/ustrbuf.hxx
+++ b/sal/inc/rtl/ustrbuf.hxx
@@ -1102,6 +1102,72 @@ public:
             pData->buffer, pData->length, literal, internal::ConstCharArrayDetector< T, void >::size - 1);
     }
 
+    /**
+       Strip the given character from the start of the buffer.
+
+       @since LibreOffice 4.0
+
+       @param    c         the character to strip
+       @return   The number of characters stripped
+
+    */
+    sal_Int32 stripStart(sal_Unicode c = (sal_Unicode)' ')
+    {
+        sal_Int32 index;
+        for(index = 0; index < getLength() ; index++)
+        {
+            if(pData->buffer[ index ] != c)
+            {
+                break;
+            }
+        }
+        if(index)
+        {
+            remove(0, index);
+        }
+        return index;
+    }
+
+    /**
+       Strip the given character from the end of the buffer.
+
+       @since LibreOffice 4.0
+
+       @param    c         the character to strip
+       @return   The number of characters stripped
+
+    */
+    sal_Int32 stripEnd(sal_Unicode c = (sal_Unicode)' ')
+    {
+        sal_Int32 result = getLength();
+        sal_Int32 index;
+        for(index = getLength(); index > 0 ; index--)
+        {
+            if(pData->buffer[ index - 1 ] != c)
+            {
+                break;
+            }
+        }
+        if(index < getLength())
+        {
+            remove(index);
+        }
+        return result - getLength();
+    }
+    /**
+       Strip the given character from the both end of the buffer.
+
+       @since LibreOffice 4.0
+
+       @param    c         the character to strip
+       @return   The number of characters stripped
+
+    */
+    sal_Int32 strip(sal_Unicode c = (sal_Unicode)' ')
+    {
+        return stripStart(c) + stripEnd(c);
+    }
+
 private:
     /**
         A pointer to the data structur which contains the data.


More information about the Libreoffice-commits mailing list