Kaydet (Commit) 3563ee58 authored tarafından Luboš Luňák's avatar Luboš Luňák

change O[U]StringBuffer::remove() to take start+len

In order to be consistent with other usage in LO and C++ libs,
instead of being consistent with Java.
üst d8636d2f
...@@ -116,19 +116,16 @@ void SAL_CALL rtl_stringbuffer_insert( /*inout*/rtl_String ** This, ...@@ -116,19 +116,16 @@ void SAL_CALL rtl_stringbuffer_insert( /*inout*/rtl_String ** This,
Removes the characters in a substring of this sequence. Removes the characters in a substring of this sequence.
The substring begins at the specified <code>start</code> and The substring begins at the specified <code>start</code> and
extends to the character at index <code>end - 1</code> or to is <code>len</code> characters long.
the end of the sequence if no such character exists. If
<code>start</code> is equal to <code>end</code>, no changes
are made.
start must be >= 0 && <= This->length && <= end start must be >= 0 && <= This->length
@param start The beginning index, inclusive @param start The beginning index, inclusive
@param end The ending index, exclusive @param len The substring length
*/ */
void SAL_CALL rtl_stringbuffer_remove( /*inout*/rtl_String ** This, void SAL_CALL rtl_stringbuffer_remove( /*inout*/rtl_String ** This,
sal_Int32 start, sal_Int32 start,
sal_Int32 end ); sal_Int32 len );
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -675,25 +675,17 @@ public: ...@@ -675,25 +675,17 @@ public:
Removes the characters in a substring of this sequence. Removes the characters in a substring of this sequence.
The substring begins at the specified <code>start</code> and The substring begins at the specified <code>start</code> and
extends to the character at index <code>end - 1</code> or to is <code>len</code> characters long.
the end of the sequence if no such character exists. If
<code>start</code> is equal to <code>end</code>, no changes
are made.
start must be >= 0 && <= getLength() && <= end start must be >= 0 && <= getLength() && <= end
As is usual for the rtl string classes, this is based
on an analogous Java StringBuffer member. In this
case <code>delete</code>, but because that's a reserved
keyword in C++, this is named <code>remove</code>.
@param start The beginning index, inclusive @param start The beginning index, inclusive
@param end The ending index, exclusive @param len The substring length
@return this string buffer. @return this string buffer.
*/ */
OStringBuffer & remove( sal_Int32 start, sal_Int32 end ) OStringBuffer & remove( sal_Int32 start, sal_Int32 len )
{ {
rtl_stringbuffer_remove( &pData, start, end ); rtl_stringbuffer_remove( &pData, start, len );
return *this; return *this;
} }
......
...@@ -163,19 +163,16 @@ void SAL_CALL rtl_uStringbuffer_insert_ascii( /*inout*/rtl_uString ** This, ...@@ -163,19 +163,16 @@ void SAL_CALL rtl_uStringbuffer_insert_ascii( /*inout*/rtl_uString ** This,
Removes the characters in a substring of this sequence. Removes the characters in a substring of this sequence.
The substring begins at the specified <code>start</code> and The substring begins at the specified <code>start</code> and
extends to the character at index <code>end - 1</code> or to is <code>len</code> characters long.
the end of the sequence if no such character exists. If
<code>start</code> is equal to <code>end</code>, no changes
are made.
start must be >= 0 && <= This->length && <= end start must be >= 0 && <= This->length
@param start The beginning index, inclusive @param start The beginning index, inclusive
@param end The ending index, exclusive @param len The substring length
*/ */
void SAL_CALL rtl_uStringbuffer_remove( /*inout*/rtl_uString ** This, void SAL_CALL rtl_uStringbuffer_remove( /*inout*/rtl_uString ** This,
sal_Int32 start, sal_Int32 start,
sal_Int32 end ); sal_Int32 len );
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -742,25 +742,17 @@ public: ...@@ -742,25 +742,17 @@ public:
Removes the characters in a substring of this sequence. Removes the characters in a substring of this sequence.
The substring begins at the specified <code>start</code> and The substring begins at the specified <code>start</code> and
extends to the character at index <code>end - 1</code> or to is <code>len</code> characters long.
the end of the sequence if no such character exists. If
<code>start</code> is equal to <code>end</code>, no changes
are made.
start must be >= 0 && <= getLength() && <= end start must be >= 0 && <= This->length
As is usual for the rtl string classes, this is based
on an analogous Java StringBuffer member. In this
case <code>delete</code>, but because that's a reserved
keyword in C++, this is named <code>remove</code>.
@param start The beginning index, inclusive @param start The beginning index, inclusive
@param end The ending index, exclusive @param len The substring length
@return this string buffer. @return this string buffer.
*/ */
OUStringBuffer & remove( sal_Int32 start, sal_Int32 end ) OUStringBuffer & remove( sal_Int32 start, sal_Int32 len )
{ {
rtl_uStringbuffer_remove( &pData, start, end ); rtl_uStringbuffer_remove( &pData, start, len );
return *this; return *this;
} }
......
...@@ -340,7 +340,7 @@ namespace rtl_OStringBuffer ...@@ -340,7 +340,7 @@ namespace rtl_OStringBuffer
CPPUNIT_ASSERT(sb.toString().equalsL( CPPUNIT_ASSERT(sb.toString().equalsL(
RTL_CONSTASCII_STRINGPARAM("Hat, Inc."))); RTL_CONSTASCII_STRINGPARAM("Hat, Inc.")));
sb.remove(3, 9); sb.remove(3, 6);
CPPUNIT_ASSERT(sb.toString().equalsL( CPPUNIT_ASSERT(sb.toString().equalsL(
RTL_CONSTASCII_STRINGPARAM("Hat"))); RTL_CONSTASCII_STRINGPARAM("Hat")));
......
...@@ -151,31 +151,28 @@ void SAL_CALL rtl_stringbuffer_insert( rtl_String ** This, ...@@ -151,31 +151,28 @@ void SAL_CALL rtl_stringbuffer_insert( rtl_String ** This,
*/ */
void SAL_CALL rtl_stringbuffer_remove( rtl_String ** This, void SAL_CALL rtl_stringbuffer_remove( rtl_String ** This,
sal_Int32 start, sal_Int32 start,
sal_Int32 end ) sal_Int32 len )
{ {
sal_Int32 nTailLen; sal_Int32 nTailLen;
sal_Char * pBuf; sal_Char * pBuf;
sal_Int32 n;
if (end > (*This)->length)
end = (*This)->length;
n = end - start; if (len > (*This)->length - start)
len = (*This)->length - start;
//remove nothing //remove nothing
if (!n) if (!len)
return; return;
pBuf = (*This)->buffer; pBuf = (*This)->buffer;
nTailLen = (*This)->length - end; nTailLen = (*This)->length - ( start + len );
if (nTailLen) if (nTailLen)
{ {
/* move the tail */ /* move the tail */
rtl_moveMemory(pBuf + start, pBuf + end, nTailLen * sizeof(sal_Char)); rtl_moveMemory(pBuf + start, pBuf + start + len, nTailLen * sizeof(sal_Char));
} }
(*This)->length-=n; (*This)->length-=len;
pBuf[ (*This)->length ] = 0; pBuf[ (*This)->length ] = 0;
} }
......
...@@ -211,31 +211,28 @@ void SAL_CALL rtl_uStringbuffer_insert_ascii( /*inout*/rtl_uString ** This, ...@@ -211,31 +211,28 @@ void SAL_CALL rtl_uStringbuffer_insert_ascii( /*inout*/rtl_uString ** This,
*/ */
void SAL_CALL rtl_uStringbuffer_remove( rtl_uString ** This, void SAL_CALL rtl_uStringbuffer_remove( rtl_uString ** This,
sal_Int32 start, sal_Int32 start,
sal_Int32 end ) sal_Int32 len )
{ {
sal_Int32 nTailLen; sal_Int32 nTailLen;
sal_Unicode * pBuf; sal_Unicode * pBuf;
sal_Int32 n;
if (end > (*This)->length)
end = (*This)->length;
n = end - start; if (len > (*This)->length - start)
len = (*This)->length - start;
//remove nothing //remove nothing
if (!n) if (!len)
return; return;
pBuf = (*This)->buffer; pBuf = (*This)->buffer;
nTailLen = (*This)->length - end; nTailLen = (*This)->length - ( start + len );
if (nTailLen) if (nTailLen)
{ {
/* move the tail */ /* move the tail */
rtl_moveMemory(pBuf + start, pBuf + end, nTailLen * sizeof(sal_Unicode)); rtl_moveMemory(pBuf + start, pBuf + start + len, nTailLen * sizeof(sal_Unicode));
} }
(*This)->length-=n; (*This)->length-=len;
pBuf[ (*This)->length ] = 0; pBuf[ (*This)->length ] = 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment