[PATCH] add copy() and toInt32() to OUStringBuffer

Christina Roßmanith (via_Code_Review) gerrit at gerrit.libreoffice.org
Tue Feb 12 13:38:20 PST 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/2125

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/25/2125/1

add copy() and toInt32() to OUStringBuffer

Change-Id: Ibac7f624f1a1dcce653dff4bec573be457d70075
---
M sal/inc/rtl/ustrbuf.hxx
1 file changed, 57 insertions(+), 0 deletions(-)



diff --git a/sal/inc/rtl/ustrbuf.hxx b/sal/inc/rtl/ustrbuf.hxx
index a7d5748..c222e4d 100644
--- a/sal/inc/rtl/ustrbuf.hxx
+++ b/sal/inc/rtl/ustrbuf.hxx
@@ -1309,6 +1309,56 @@
     {
         return stripStart(c) + stripEnd(c);
     }
+    /**
+      Returns the int32 value from this string buffer.
+
+      This function can't be used for language specific conversion.
+
+      @param    radix       the radix (between 2 and 36)
+      @return   the int32 represented from this string.
+                0 if this string represents no number.
+      @since LibreOffice 4.1
+    */
+    sal_Int32 toInt32( sal_Int16 radix = 10 ) const SAL_THROW(())
+    {
+        return rtl_ustr_toInt32( pData->buffer, radix );
+    }
+    /**
+      Returns a new string buffer that is a substring of this string.
+
+      The substring begins at the specified beginIndex. If
+      beginIndex is negative or be greater than the length of
+      this string, behaviour is undefined.
+
+      @param     beginIndex   the beginning index, inclusive.
+      @return    the specified substring.
+      @since LibreOffice 4.1
+    */
+    OUStringBuffer copy( sal_Int32 beginIndex ) const SAL_THROW(())
+    {
+        rtl_uString *pNew = 0;
+        rtl_uString_newFromSubString( &pNew, pData, beginIndex, getLength() - beginIndex );
+        return OUStringBuffer( pNew, (DO_NOT_ACQUIRE*)0 );
+    }
+    /**
+      Returns a new string buffer that is a substring of this string.
+
+      The substring begins at the specified beginIndex and contains count
+      characters.  If either beginIndex or count are negative,
+      or beginIndex + count are greater than the length of this string
+      then behaviour is undefined.
+
+      @param     beginIndex   the beginning index, inclusive.
+      @param     count        the number of characters.
+      @return    the specified substring.
+      @since LibreOffice 4.1
+    */
+    OUStringBuffer copy( sal_Int32 beginIndex, sal_Int32 count ) const SAL_THROW(())
+    {
+        rtl_uString *pNew = 0;
+        rtl_uString_newFromSubString( &pNew, pData, beginIndex, count );
+        return OUStringBuffer( pNew, (DO_NOT_ACQUIRE*)0 );
+    }
 
 #ifdef LIBO_INTERNAL_ONLY
     // This is to complement the RTL_FAST_STRING operator+, which allows any combination of valid operands,
@@ -1326,6 +1376,13 @@
 #endif
 
 private:
+    class DO_NOT_ACQUIRE{};
+
+    OUStringBuffer( rtl_uString * value, SAL_UNUSED_PARAMETER DO_NOT_ACQUIRE * )
+    {
+        pData = value;
+    }
+
     /**
         A pointer to the data structur which contains the data.
      */

-- 
To view, visit https://gerrit.libreoffice.org/2125
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibac7f624f1a1dcce653dff4bec573be457d70075
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Christina Roßmanith <ChrRossmanith at web.de>


More information about the LibreOffice mailing list