1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski #ifndef _RTL_USTRBUF_HXX_ 25*b1cdbd2cSJim Jagielski #define _RTL_USTRBUF_HXX_ 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski #include <osl/diagnose.h> 28*b1cdbd2cSJim Jagielski #include <rtl/ustrbuf.h> 29*b1cdbd2cSJim Jagielski #ifndef _RTL_USTRING_HXX 30*b1cdbd2cSJim Jagielski #include <rtl/ustring.hxx> 31*b1cdbd2cSJim Jagielski #endif 32*b1cdbd2cSJim Jagielski 33*b1cdbd2cSJim Jagielski #ifdef __cplusplus 34*b1cdbd2cSJim Jagielski 35*b1cdbd2cSJim Jagielski namespace rtl 36*b1cdbd2cSJim Jagielski { 37*b1cdbd2cSJim Jagielski 38*b1cdbd2cSJim Jagielski /** @HTML 39*b1cdbd2cSJim Jagielski A string buffer implements a mutable sequence of characters. 40*b1cdbd2cSJim Jagielski <p> 41*b1cdbd2cSJim Jagielski String buffers are safe for use by multiple threads. The methods 42*b1cdbd2cSJim Jagielski are synchronized where necessary so that all the operations on any 43*b1cdbd2cSJim Jagielski particular instance behave as if they occur in some serial order. 44*b1cdbd2cSJim Jagielski <p> 45*b1cdbd2cSJim Jagielski String buffers are used by the compiler to implement the binary 46*b1cdbd2cSJim Jagielski string concatenation operator <code>+</code>. For example, the code: 47*b1cdbd2cSJim Jagielski <p><blockquote><pre> 48*b1cdbd2cSJim Jagielski x = "a" + 4 + "c" 49*b1cdbd2cSJim Jagielski </pre></blockquote><p> 50*b1cdbd2cSJim Jagielski is compiled to the equivalent of: 51*b1cdbd2cSJim Jagielski <p><blockquote><pre> 52*b1cdbd2cSJim Jagielski x = new OUStringBuffer().append("a").append(4).append("c") 53*b1cdbd2cSJim Jagielski .toString() 54*b1cdbd2cSJim Jagielski </pre></blockquote><p> 55*b1cdbd2cSJim Jagielski The principal operations on a <code>OUStringBuffer</code> are the 56*b1cdbd2cSJim Jagielski <code>append</code> and <code>insert</code> methods, which are 57*b1cdbd2cSJim Jagielski overloaded so as to accept data of any type. Each effectively 58*b1cdbd2cSJim Jagielski converts a given datum to a string and then appends or inserts the 59*b1cdbd2cSJim Jagielski characters of that string to the string buffer. The 60*b1cdbd2cSJim Jagielski <code>append</code> method always adds these characters at the end 61*b1cdbd2cSJim Jagielski of the buffer; the <code>insert</code> method adds the characters at 62*b1cdbd2cSJim Jagielski a specified point. 63*b1cdbd2cSJim Jagielski <p> 64*b1cdbd2cSJim Jagielski For example, if <code>z</code> refers to a string buffer object 65*b1cdbd2cSJim Jagielski whose current contents are "<code>start</code>", then 66*b1cdbd2cSJim Jagielski the method call <code>z.append("le")</code> would cause the string 67*b1cdbd2cSJim Jagielski buffer to contain "<code>startle</code>", whereas 68*b1cdbd2cSJim Jagielski <code>z.insert(4, "le")</code> would alter the string buffer to 69*b1cdbd2cSJim Jagielski contain "<code>starlet</code>". 70*b1cdbd2cSJim Jagielski <p> 71*b1cdbd2cSJim Jagielski Every string buffer has a capacity. As long as the length of the 72*b1cdbd2cSJim Jagielski character sequence contained in the string buffer does not exceed 73*b1cdbd2cSJim Jagielski the capacity, it is not necessary to allocate a new internal 74*b1cdbd2cSJim Jagielski buffer array. If the internal buffer overflows, it is 75*b1cdbd2cSJim Jagielski automatically made larger. 76*b1cdbd2cSJim Jagielski */ 77*b1cdbd2cSJim Jagielski class OUStringBuffer 78*b1cdbd2cSJim Jagielski { 79*b1cdbd2cSJim Jagielski public: 80*b1cdbd2cSJim Jagielski /** 81*b1cdbd2cSJim Jagielski Constructs a string buffer with no characters in it and an 82*b1cdbd2cSJim Jagielski initial capacity of 16 characters. 83*b1cdbd2cSJim Jagielski */ OUStringBuffer()84*b1cdbd2cSJim Jagielski OUStringBuffer() 85*b1cdbd2cSJim Jagielski : pData(NULL) 86*b1cdbd2cSJim Jagielski , nCapacity( 16 ) 87*b1cdbd2cSJim Jagielski { 88*b1cdbd2cSJim Jagielski rtl_uString_new_WithLength( &pData, nCapacity ); 89*b1cdbd2cSJim Jagielski } 90*b1cdbd2cSJim Jagielski 91*b1cdbd2cSJim Jagielski /** 92*b1cdbd2cSJim Jagielski Allocates a new string buffer that contains the same sequence of 93*b1cdbd2cSJim Jagielski characters as the string buffer argument. 94*b1cdbd2cSJim Jagielski 95*b1cdbd2cSJim Jagielski @param value a <code>OStringBuffer</code>. 96*b1cdbd2cSJim Jagielski */ OUStringBuffer(const OUStringBuffer & value)97*b1cdbd2cSJim Jagielski OUStringBuffer( const OUStringBuffer & value ) 98*b1cdbd2cSJim Jagielski : pData(NULL) 99*b1cdbd2cSJim Jagielski , nCapacity( value.nCapacity ) 100*b1cdbd2cSJim Jagielski { 101*b1cdbd2cSJim Jagielski rtl_uStringbuffer_newFromStringBuffer( &pData, value.nCapacity, value.pData ); 102*b1cdbd2cSJim Jagielski } 103*b1cdbd2cSJim Jagielski 104*b1cdbd2cSJim Jagielski /** 105*b1cdbd2cSJim Jagielski Constructs a string buffer with no characters in it and an 106*b1cdbd2cSJim Jagielski initial capacity specified by the <code>length</code> argument. 107*b1cdbd2cSJim Jagielski 108*b1cdbd2cSJim Jagielski @param length the initial capacity. 109*b1cdbd2cSJim Jagielski */ OUStringBuffer(sal_Int32 length)110*b1cdbd2cSJim Jagielski OUStringBuffer(sal_Int32 length) 111*b1cdbd2cSJim Jagielski : pData(NULL) 112*b1cdbd2cSJim Jagielski , nCapacity( length ) 113*b1cdbd2cSJim Jagielski { 114*b1cdbd2cSJim Jagielski rtl_uString_new_WithLength( &pData, length ); 115*b1cdbd2cSJim Jagielski } 116*b1cdbd2cSJim Jagielski 117*b1cdbd2cSJim Jagielski /** 118*b1cdbd2cSJim Jagielski Constructs a string buffer so that it represents the same 119*b1cdbd2cSJim Jagielski sequence of characters as the string argument. 120*b1cdbd2cSJim Jagielski 121*b1cdbd2cSJim Jagielski The initial 122*b1cdbd2cSJim Jagielski capacity of the string buffer is <code>16</code> plus the length 123*b1cdbd2cSJim Jagielski of the string argument. 124*b1cdbd2cSJim Jagielski 125*b1cdbd2cSJim Jagielski @param str the initial contents of the buffer. 126*b1cdbd2cSJim Jagielski */ OUStringBuffer(OUString value)127*b1cdbd2cSJim Jagielski OUStringBuffer(OUString value) 128*b1cdbd2cSJim Jagielski : pData(NULL) 129*b1cdbd2cSJim Jagielski , nCapacity( value.getLength() + 16 ) 130*b1cdbd2cSJim Jagielski { 131*b1cdbd2cSJim Jagielski rtl_uStringbuffer_newFromStr_WithLength( &pData, value.getStr(), value.getLength() ); 132*b1cdbd2cSJim Jagielski } 133*b1cdbd2cSJim Jagielski 134*b1cdbd2cSJim Jagielski /** Assign to this a copy of value. 135*b1cdbd2cSJim Jagielski */ operator =(const OUStringBuffer & value)136*b1cdbd2cSJim Jagielski OUStringBuffer& operator = ( const OUStringBuffer& value ) 137*b1cdbd2cSJim Jagielski { 138*b1cdbd2cSJim Jagielski if (this != &value) 139*b1cdbd2cSJim Jagielski { 140*b1cdbd2cSJim Jagielski rtl_uStringbuffer_newFromStringBuffer(&pData, 141*b1cdbd2cSJim Jagielski value.nCapacity, 142*b1cdbd2cSJim Jagielski value.pData); 143*b1cdbd2cSJim Jagielski nCapacity = value.nCapacity; 144*b1cdbd2cSJim Jagielski } 145*b1cdbd2cSJim Jagielski return *this; 146*b1cdbd2cSJim Jagielski } 147*b1cdbd2cSJim Jagielski 148*b1cdbd2cSJim Jagielski /** 149*b1cdbd2cSJim Jagielski Release the string data. 150*b1cdbd2cSJim Jagielski */ ~OUStringBuffer()151*b1cdbd2cSJim Jagielski ~OUStringBuffer() 152*b1cdbd2cSJim Jagielski { 153*b1cdbd2cSJim Jagielski rtl_uString_release( pData ); 154*b1cdbd2cSJim Jagielski } 155*b1cdbd2cSJim Jagielski 156*b1cdbd2cSJim Jagielski /** 157*b1cdbd2cSJim Jagielski Fill the string data in the new string and clear the buffer. 158*b1cdbd2cSJim Jagielski 159*b1cdbd2cSJim Jagielski This method is more efficient than the contructor of the string. It does 160*b1cdbd2cSJim Jagielski not copy the buffer. 161*b1cdbd2cSJim Jagielski 162*b1cdbd2cSJim Jagielski @return the string previously contained in the buffer. 163*b1cdbd2cSJim Jagielski */ makeStringAndClear()164*b1cdbd2cSJim Jagielski OUString makeStringAndClear() 165*b1cdbd2cSJim Jagielski { 166*b1cdbd2cSJim Jagielski OUString aRet( pData ); 167*b1cdbd2cSJim Jagielski rtl_uString_new(&pData); 168*b1cdbd2cSJim Jagielski nCapacity = 0; 169*b1cdbd2cSJim Jagielski return aRet; 170*b1cdbd2cSJim Jagielski } 171*b1cdbd2cSJim Jagielski 172*b1cdbd2cSJim Jagielski /** 173*b1cdbd2cSJim Jagielski Returns the length (character count) of this string buffer. 174*b1cdbd2cSJim Jagielski 175*b1cdbd2cSJim Jagielski @return the number of characters in this string buffer. 176*b1cdbd2cSJim Jagielski */ getLength() const177*b1cdbd2cSJim Jagielski sal_Int32 getLength() const 178*b1cdbd2cSJim Jagielski { 179*b1cdbd2cSJim Jagielski return pData->length; 180*b1cdbd2cSJim Jagielski } 181*b1cdbd2cSJim Jagielski 182*b1cdbd2cSJim Jagielski /** 183*b1cdbd2cSJim Jagielski Returns the current capacity of the String buffer. 184*b1cdbd2cSJim Jagielski 185*b1cdbd2cSJim Jagielski The capacity 186*b1cdbd2cSJim Jagielski is the amount of storage available for newly inserted 187*b1cdbd2cSJim Jagielski characters. The real buffer size is 2 bytes longer, because 188*b1cdbd2cSJim Jagielski all strings are 0 terminated. 189*b1cdbd2cSJim Jagielski 190*b1cdbd2cSJim Jagielski @return the current capacity of this string buffer. 191*b1cdbd2cSJim Jagielski */ getCapacity() const192*b1cdbd2cSJim Jagielski sal_Int32 getCapacity() const 193*b1cdbd2cSJim Jagielski { 194*b1cdbd2cSJim Jagielski return nCapacity; 195*b1cdbd2cSJim Jagielski } 196*b1cdbd2cSJim Jagielski 197*b1cdbd2cSJim Jagielski /** 198*b1cdbd2cSJim Jagielski Ensures that the capacity of the buffer is at least equal to the 199*b1cdbd2cSJim Jagielski specified minimum. 200*b1cdbd2cSJim Jagielski 201*b1cdbd2cSJim Jagielski The new capacity will be at least as large as the maximum of the current 202*b1cdbd2cSJim Jagielski length (so that no contents of the buffer is destroyed) and the given 203*b1cdbd2cSJim Jagielski minimumCapacity. If the given minimumCapacity is negative, nothing is 204*b1cdbd2cSJim Jagielski changed. 205*b1cdbd2cSJim Jagielski 206*b1cdbd2cSJim Jagielski @param minimumCapacity the minimum desired capacity. 207*b1cdbd2cSJim Jagielski */ ensureCapacity(sal_Int32 minimumCapacity)208*b1cdbd2cSJim Jagielski void ensureCapacity(sal_Int32 minimumCapacity) 209*b1cdbd2cSJim Jagielski { 210*b1cdbd2cSJim Jagielski rtl_uStringbuffer_ensureCapacity( &pData, &nCapacity, minimumCapacity ); 211*b1cdbd2cSJim Jagielski } 212*b1cdbd2cSJim Jagielski 213*b1cdbd2cSJim Jagielski /** 214*b1cdbd2cSJim Jagielski Sets the length of this String buffer. 215*b1cdbd2cSJim Jagielski 216*b1cdbd2cSJim Jagielski If the <code>newLength</code> argument is less than the current 217*b1cdbd2cSJim Jagielski length of the string buffer, the string buffer is truncated to 218*b1cdbd2cSJim Jagielski contain exactly the number of characters given by the 219*b1cdbd2cSJim Jagielski <code>newLength</code> argument. 220*b1cdbd2cSJim Jagielski <p> 221*b1cdbd2cSJim Jagielski If the <code>newLength</code> argument is greater than or equal 222*b1cdbd2cSJim Jagielski to the current length, sufficient null characters 223*b1cdbd2cSJim Jagielski (<code>'\u0000'</code>) are appended to the string buffer so that 224*b1cdbd2cSJim Jagielski length becomes the <code>newLength</code> argument. 225*b1cdbd2cSJim Jagielski <p> 226*b1cdbd2cSJim Jagielski The <code>newLength</code> argument must be greater than or equal 227*b1cdbd2cSJim Jagielski to <code>0</code>. 228*b1cdbd2cSJim Jagielski 229*b1cdbd2cSJim Jagielski @param newLength the new length of the buffer. 230*b1cdbd2cSJim Jagielski */ setLength(sal_Int32 newLength)231*b1cdbd2cSJim Jagielski void setLength(sal_Int32 newLength) 232*b1cdbd2cSJim Jagielski { 233*b1cdbd2cSJim Jagielski OSL_ASSERT(newLength >= 0); 234*b1cdbd2cSJim Jagielski // Avoid modifications if pData points to const empty string: 235*b1cdbd2cSJim Jagielski if( newLength != pData->length ) 236*b1cdbd2cSJim Jagielski { 237*b1cdbd2cSJim Jagielski if( newLength > nCapacity ) 238*b1cdbd2cSJim Jagielski rtl_uStringbuffer_ensureCapacity(&pData, &nCapacity, newLength); 239*b1cdbd2cSJim Jagielski else 240*b1cdbd2cSJim Jagielski pData->buffer[newLength] = 0; 241*b1cdbd2cSJim Jagielski pData->length = newLength; 242*b1cdbd2cSJim Jagielski } 243*b1cdbd2cSJim Jagielski } 244*b1cdbd2cSJim Jagielski 245*b1cdbd2cSJim Jagielski /** 246*b1cdbd2cSJim Jagielski Returns the character at a specific index in this string buffer. 247*b1cdbd2cSJim Jagielski 248*b1cdbd2cSJim Jagielski The first character of a string buffer is at index 249*b1cdbd2cSJim Jagielski <code>0</code>, the next at index <code>1</code>, and so on, for 250*b1cdbd2cSJim Jagielski array indexing. 251*b1cdbd2cSJim Jagielski <p> 252*b1cdbd2cSJim Jagielski The index argument must be greater than or equal to 253*b1cdbd2cSJim Jagielski <code>0</code>, and less than the length of this string buffer. 254*b1cdbd2cSJim Jagielski 255*b1cdbd2cSJim Jagielski @param index the index of the desired character. 256*b1cdbd2cSJim Jagielski @return the character at the specified index of this string buffer. 257*b1cdbd2cSJim Jagielski */ charAt(sal_Int32 index) const258*b1cdbd2cSJim Jagielski sal_Unicode charAt( sal_Int32 index ) const 259*b1cdbd2cSJim Jagielski { 260*b1cdbd2cSJim Jagielski OSL_ASSERT(index >= 0 && index < pData->length); 261*b1cdbd2cSJim Jagielski return pData->buffer[ index ]; 262*b1cdbd2cSJim Jagielski } 263*b1cdbd2cSJim Jagielski 264*b1cdbd2cSJim Jagielski /** 265*b1cdbd2cSJim Jagielski Return a null terminated unicode character array. 266*b1cdbd2cSJim Jagielski */ 267*b1cdbd2cSJim Jagielski operator const sal_Unicode *() const { return pData->buffer; } 268*b1cdbd2cSJim Jagielski 269*b1cdbd2cSJim Jagielski /** 270*b1cdbd2cSJim Jagielski Return a null terminated unicode character array. 271*b1cdbd2cSJim Jagielski */ getStr() const272*b1cdbd2cSJim Jagielski const sal_Unicode* getStr() const { return pData->buffer; } 273*b1cdbd2cSJim Jagielski 274*b1cdbd2cSJim Jagielski 275*b1cdbd2cSJim Jagielski /** 276*b1cdbd2cSJim Jagielski The character at the specified index of this string buffer is set 277*b1cdbd2cSJim Jagielski to <code>ch</code>. 278*b1cdbd2cSJim Jagielski 279*b1cdbd2cSJim Jagielski The index argument must be greater than or equal to 280*b1cdbd2cSJim Jagielski <code>0</code>, and less than the length of this string buffer. 281*b1cdbd2cSJim Jagielski 282*b1cdbd2cSJim Jagielski @param index the index of the character to modify. 283*b1cdbd2cSJim Jagielski @param ch the new character. 284*b1cdbd2cSJim Jagielski */ setCharAt(sal_Int32 index,sal_Unicode ch)285*b1cdbd2cSJim Jagielski OUStringBuffer & setCharAt(sal_Int32 index, sal_Unicode ch) 286*b1cdbd2cSJim Jagielski { 287*b1cdbd2cSJim Jagielski OSL_ASSERT(index >= 0 && index < pData->length); 288*b1cdbd2cSJim Jagielski pData->buffer[ index ] = ch; 289*b1cdbd2cSJim Jagielski return *this; 290*b1cdbd2cSJim Jagielski } 291*b1cdbd2cSJim Jagielski 292*b1cdbd2cSJim Jagielski /** 293*b1cdbd2cSJim Jagielski Appends the string to this string buffer. 294*b1cdbd2cSJim Jagielski 295*b1cdbd2cSJim Jagielski The characters of the <code>String</code> argument are appended, in 296*b1cdbd2cSJim Jagielski order, to the contents of this string buffer, increasing the 297*b1cdbd2cSJim Jagielski length of this string buffer by the length of the argument. 298*b1cdbd2cSJim Jagielski 299*b1cdbd2cSJim Jagielski @param str a string. 300*b1cdbd2cSJim Jagielski @return this string buffer. 301*b1cdbd2cSJim Jagielski */ append(const OUString & str)302*b1cdbd2cSJim Jagielski OUStringBuffer & append(const OUString &str) 303*b1cdbd2cSJim Jagielski { 304*b1cdbd2cSJim Jagielski return append( str.getStr(), str.getLength() ); 305*b1cdbd2cSJim Jagielski } 306*b1cdbd2cSJim Jagielski 307*b1cdbd2cSJim Jagielski /** 308*b1cdbd2cSJim Jagielski Appends the string representation of the <code>char</code> array 309*b1cdbd2cSJim Jagielski argument to this string buffer. 310*b1cdbd2cSJim Jagielski 311*b1cdbd2cSJim Jagielski The characters of the array argument are appended, in order, to 312*b1cdbd2cSJim Jagielski the contents of this string buffer. The length of this string 313*b1cdbd2cSJim Jagielski buffer increases by the length of the argument. 314*b1cdbd2cSJim Jagielski 315*b1cdbd2cSJim Jagielski @param str the characters to be appended. 316*b1cdbd2cSJim Jagielski @return this string buffer. 317*b1cdbd2cSJim Jagielski */ append(const sal_Unicode * str)318*b1cdbd2cSJim Jagielski OUStringBuffer & append( const sal_Unicode * str ) 319*b1cdbd2cSJim Jagielski { 320*b1cdbd2cSJim Jagielski return append( str, rtl_ustr_getLength( str ) ); 321*b1cdbd2cSJim Jagielski } 322*b1cdbd2cSJim Jagielski 323*b1cdbd2cSJim Jagielski /** 324*b1cdbd2cSJim Jagielski Appends the string representation of the <code>char</code> array 325*b1cdbd2cSJim Jagielski argument to this string buffer. 326*b1cdbd2cSJim Jagielski 327*b1cdbd2cSJim Jagielski Characters of the character array <code>str</code> are appended, 328*b1cdbd2cSJim Jagielski in order, to the contents of this string buffer. The length of this 329*b1cdbd2cSJim Jagielski string buffer increases by the value of <code>len</code>. 330*b1cdbd2cSJim Jagielski 331*b1cdbd2cSJim Jagielski @param str the characters to be appended; must be non-null, and must 332*b1cdbd2cSJim Jagielski point to at least len characters 333*b1cdbd2cSJim Jagielski @param len the number of characters to append; must be non-negative 334*b1cdbd2cSJim Jagielski @return this string buffer. 335*b1cdbd2cSJim Jagielski */ append(const sal_Unicode * str,sal_Int32 len)336*b1cdbd2cSJim Jagielski OUStringBuffer & append( const sal_Unicode * str, sal_Int32 len) 337*b1cdbd2cSJim Jagielski { 338*b1cdbd2cSJim Jagielski // insert behind the last character 339*b1cdbd2cSJim Jagielski rtl_uStringbuffer_insert( &pData, &nCapacity, getLength(), str, len ); 340*b1cdbd2cSJim Jagielski return *this; 341*b1cdbd2cSJim Jagielski } 342*b1cdbd2cSJim Jagielski 343*b1cdbd2cSJim Jagielski /** 344*b1cdbd2cSJim Jagielski Appends a 8-Bit ASCII character string to this string buffer. 345*b1cdbd2cSJim Jagielski 346*b1cdbd2cSJim Jagielski Since this method is optimized for performance. the ASCII 347*b1cdbd2cSJim Jagielski character values are not converted in any way. The caller 348*b1cdbd2cSJim Jagielski has to make sure that all ASCII characters are in the 349*b1cdbd2cSJim Jagielski allowed range between 0 and 127. The ASCII string must be 350*b1cdbd2cSJim Jagielski NULL-terminated. 351*b1cdbd2cSJim Jagielski <p> 352*b1cdbd2cSJim Jagielski The characters of the array argument are appended, in order, to 353*b1cdbd2cSJim Jagielski the contents of this string buffer. The length of this string 354*b1cdbd2cSJim Jagielski buffer increases by the length of the argument. 355*b1cdbd2cSJim Jagielski 356*b1cdbd2cSJim Jagielski @param str the 8-Bit ASCII characters to be appended. 357*b1cdbd2cSJim Jagielski @return this string buffer. 358*b1cdbd2cSJim Jagielski */ appendAscii(const sal_Char * str)359*b1cdbd2cSJim Jagielski OUStringBuffer & appendAscii( const sal_Char * str ) 360*b1cdbd2cSJim Jagielski { 361*b1cdbd2cSJim Jagielski return appendAscii( str, rtl_str_getLength( str ) ); 362*b1cdbd2cSJim Jagielski } 363*b1cdbd2cSJim Jagielski 364*b1cdbd2cSJim Jagielski /** 365*b1cdbd2cSJim Jagielski Appends a 8-Bit ASCII character string to this string buffer. 366*b1cdbd2cSJim Jagielski 367*b1cdbd2cSJim Jagielski Since this method is optimized for performance. the ASCII 368*b1cdbd2cSJim Jagielski character values are not converted in any way. The caller 369*b1cdbd2cSJim Jagielski has to make sure that all ASCII characters are in the 370*b1cdbd2cSJim Jagielski allowed range between 0 and 127. The ASCII string must be 371*b1cdbd2cSJim Jagielski NULL-terminated. 372*b1cdbd2cSJim Jagielski <p> 373*b1cdbd2cSJim Jagielski Characters of the character array <code>str</code> are appended, 374*b1cdbd2cSJim Jagielski in order, to the contents of this string buffer. The length of this 375*b1cdbd2cSJim Jagielski string buffer increases by the value of <code>len</code>. 376*b1cdbd2cSJim Jagielski 377*b1cdbd2cSJim Jagielski @param str the 8-Bit ASCII characters to be appended; must be non-null, 378*b1cdbd2cSJim Jagielski and must point to at least len characters 379*b1cdbd2cSJim Jagielski @param len the number of characters to append; must be non-negative 380*b1cdbd2cSJim Jagielski @return this string buffer. 381*b1cdbd2cSJim Jagielski */ appendAscii(const sal_Char * str,sal_Int32 len)382*b1cdbd2cSJim Jagielski OUStringBuffer & appendAscii( const sal_Char * str, sal_Int32 len) 383*b1cdbd2cSJim Jagielski { 384*b1cdbd2cSJim Jagielski rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, getLength(), str, len ); 385*b1cdbd2cSJim Jagielski return *this; 386*b1cdbd2cSJim Jagielski } 387*b1cdbd2cSJim Jagielski 388*b1cdbd2cSJim Jagielski 389*b1cdbd2cSJim Jagielski /** 390*b1cdbd2cSJim Jagielski Appends the string representation of the <code>sal_Bool</code> 391*b1cdbd2cSJim Jagielski argument to the string buffer. 392*b1cdbd2cSJim Jagielski 393*b1cdbd2cSJim Jagielski The argument is converted to a string as if by the method 394*b1cdbd2cSJim Jagielski <code>String.valueOf</code>, and the characters of that 395*b1cdbd2cSJim Jagielski string are then appended to this string buffer. 396*b1cdbd2cSJim Jagielski 397*b1cdbd2cSJim Jagielski @param b a <code>sal_Bool</code>. 398*b1cdbd2cSJim Jagielski @return this string buffer. 399*b1cdbd2cSJim Jagielski */ append(sal_Bool b)400*b1cdbd2cSJim Jagielski OUStringBuffer & append(sal_Bool b) 401*b1cdbd2cSJim Jagielski { 402*b1cdbd2cSJim Jagielski sal_Unicode sz[RTL_USTR_MAX_VALUEOFBOOLEAN]; 403*b1cdbd2cSJim Jagielski return append( sz, rtl_ustr_valueOfBoolean( sz, b ) ); 404*b1cdbd2cSJim Jagielski } 405*b1cdbd2cSJim Jagielski 406*b1cdbd2cSJim Jagielski /** 407*b1cdbd2cSJim Jagielski Appends the string representation of the <code>char</code> 408*b1cdbd2cSJim Jagielski argument to this string buffer. 409*b1cdbd2cSJim Jagielski 410*b1cdbd2cSJim Jagielski The argument is appended to the contents of this string buffer. 411*b1cdbd2cSJim Jagielski The length of this string buffer increases by <code>1</code>. 412*b1cdbd2cSJim Jagielski 413*b1cdbd2cSJim Jagielski @param ch a <code>char</code>. 414*b1cdbd2cSJim Jagielski @return this string buffer. 415*b1cdbd2cSJim Jagielski */ append(sal_Unicode c)416*b1cdbd2cSJim Jagielski OUStringBuffer & append(sal_Unicode c) 417*b1cdbd2cSJim Jagielski { 418*b1cdbd2cSJim Jagielski return append( &c, 1 ); 419*b1cdbd2cSJim Jagielski } 420*b1cdbd2cSJim Jagielski 421*b1cdbd2cSJim Jagielski /** 422*b1cdbd2cSJim Jagielski Appends the string representation of the <code>sal_Int32</code> 423*b1cdbd2cSJim Jagielski argument to this string buffer. 424*b1cdbd2cSJim Jagielski 425*b1cdbd2cSJim Jagielski The argument is converted to a string as if by the method 426*b1cdbd2cSJim Jagielski <code>String.valueOf</code>, and the characters of that 427*b1cdbd2cSJim Jagielski string are then appended to this string buffer. 428*b1cdbd2cSJim Jagielski 429*b1cdbd2cSJim Jagielski @param i an <code>sal_Int32</code>. 430*b1cdbd2cSJim Jagielski @return this string buffer. 431*b1cdbd2cSJim Jagielski */ append(sal_Int32 i,sal_Int16 radix=10)432*b1cdbd2cSJim Jagielski OUStringBuffer & append(sal_Int32 i, sal_Int16 radix = 10 ) 433*b1cdbd2cSJim Jagielski { 434*b1cdbd2cSJim Jagielski sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT32]; 435*b1cdbd2cSJim Jagielski return append( sz, rtl_ustr_valueOfInt32( sz, i, radix ) ); 436*b1cdbd2cSJim Jagielski } 437*b1cdbd2cSJim Jagielski 438*b1cdbd2cSJim Jagielski /** 439*b1cdbd2cSJim Jagielski Appends the string representation of the <code>long</code> 440*b1cdbd2cSJim Jagielski argument to this string buffer. 441*b1cdbd2cSJim Jagielski 442*b1cdbd2cSJim Jagielski The argument is converted to a string as if by the method 443*b1cdbd2cSJim Jagielski <code>String.valueOf</code>, and the characters of that 444*b1cdbd2cSJim Jagielski string are then appended to this string buffer. 445*b1cdbd2cSJim Jagielski 446*b1cdbd2cSJim Jagielski @param l a <code>long</code>. 447*b1cdbd2cSJim Jagielski @return this string buffer. 448*b1cdbd2cSJim Jagielski */ append(sal_Int64 l,sal_Int16 radix=10)449*b1cdbd2cSJim Jagielski OUStringBuffer & append(sal_Int64 l, sal_Int16 radix = 10 ) 450*b1cdbd2cSJim Jagielski { 451*b1cdbd2cSJim Jagielski sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT64]; 452*b1cdbd2cSJim Jagielski return append( sz, rtl_ustr_valueOfInt64( sz, l, radix ) ); 453*b1cdbd2cSJim Jagielski } 454*b1cdbd2cSJim Jagielski 455*b1cdbd2cSJim Jagielski /** 456*b1cdbd2cSJim Jagielski Appends the string representation of the <code>float</code> 457*b1cdbd2cSJim Jagielski argument to this string buffer. 458*b1cdbd2cSJim Jagielski 459*b1cdbd2cSJim Jagielski The argument is converted to a string as if by the method 460*b1cdbd2cSJim Jagielski <code>String.valueOf</code>, and the characters of that 461*b1cdbd2cSJim Jagielski string are then appended to this string buffer. 462*b1cdbd2cSJim Jagielski 463*b1cdbd2cSJim Jagielski @param f a <code>float</code>. 464*b1cdbd2cSJim Jagielski @return this string buffer. 465*b1cdbd2cSJim Jagielski */ append(float f)466*b1cdbd2cSJim Jagielski OUStringBuffer & append(float f) 467*b1cdbd2cSJim Jagielski { 468*b1cdbd2cSJim Jagielski sal_Unicode sz[RTL_USTR_MAX_VALUEOFFLOAT]; 469*b1cdbd2cSJim Jagielski return append( sz, rtl_ustr_valueOfFloat( sz, f ) ); 470*b1cdbd2cSJim Jagielski } 471*b1cdbd2cSJim Jagielski 472*b1cdbd2cSJim Jagielski /** 473*b1cdbd2cSJim Jagielski Appends the string representation of the <code>double</code> 474*b1cdbd2cSJim Jagielski argument to this string buffer. 475*b1cdbd2cSJim Jagielski 476*b1cdbd2cSJim Jagielski The argument is converted to a string as if by the method 477*b1cdbd2cSJim Jagielski <code>String.valueOf</code>, and the characters of that 478*b1cdbd2cSJim Jagielski string are then appended to this string buffer. 479*b1cdbd2cSJim Jagielski 480*b1cdbd2cSJim Jagielski @param d a <code>double</code>. 481*b1cdbd2cSJim Jagielski @return this string buffer. 482*b1cdbd2cSJim Jagielski */ append(double d)483*b1cdbd2cSJim Jagielski OUStringBuffer & append(double d) 484*b1cdbd2cSJim Jagielski { 485*b1cdbd2cSJim Jagielski sal_Unicode sz[RTL_USTR_MAX_VALUEOFDOUBLE]; 486*b1cdbd2cSJim Jagielski return append( sz, rtl_ustr_valueOfDouble( sz, d ) ); 487*b1cdbd2cSJim Jagielski } 488*b1cdbd2cSJim Jagielski 489*b1cdbd2cSJim Jagielski /** 490*b1cdbd2cSJim Jagielski Appends a single UTF-32 character to this string buffer. 491*b1cdbd2cSJim Jagielski 492*b1cdbd2cSJim Jagielski <p>The single UTF-32 character will be represented within the string 493*b1cdbd2cSJim Jagielski buffer as either one or two UTF-16 code units.</p> 494*b1cdbd2cSJim Jagielski 495*b1cdbd2cSJim Jagielski @param c a well-formed UTF-32 code unit (that is, a value in the range 496*b1cdbd2cSJim Jagielski <code>0</code>–<code>0x10FFFF</code>, but excluding 497*b1cdbd2cSJim Jagielski <code>0xD800</code>–<code>0xDFFF</code>) 498*b1cdbd2cSJim Jagielski 499*b1cdbd2cSJim Jagielski @return 500*b1cdbd2cSJim Jagielski this string buffer 501*b1cdbd2cSJim Jagielski */ appendUtf32(sal_uInt32 c)502*b1cdbd2cSJim Jagielski OUStringBuffer & appendUtf32(sal_uInt32 c) { 503*b1cdbd2cSJim Jagielski return insertUtf32(getLength(), c); 504*b1cdbd2cSJim Jagielski } 505*b1cdbd2cSJim Jagielski 506*b1cdbd2cSJim Jagielski /** 507*b1cdbd2cSJim Jagielski Inserts the string into this string buffer. 508*b1cdbd2cSJim Jagielski 509*b1cdbd2cSJim Jagielski The characters of the <code>String</code> argument are inserted, in 510*b1cdbd2cSJim Jagielski order, into this string buffer at the indicated offset. The length 511*b1cdbd2cSJim Jagielski of this string buffer is increased by the length of the argument. 512*b1cdbd2cSJim Jagielski <p> 513*b1cdbd2cSJim Jagielski The offset argument must be greater than or equal to 514*b1cdbd2cSJim Jagielski <code>0</code>, and less than or equal to the length of this 515*b1cdbd2cSJim Jagielski string buffer. 516*b1cdbd2cSJim Jagielski 517*b1cdbd2cSJim Jagielski @param offset the offset. 518*b1cdbd2cSJim Jagielski @param str a string. 519*b1cdbd2cSJim Jagielski @return this string buffer. 520*b1cdbd2cSJim Jagielski */ insert(sal_Int32 offset,const OUString & str)521*b1cdbd2cSJim Jagielski OUStringBuffer & insert(sal_Int32 offset, const OUString & str) 522*b1cdbd2cSJim Jagielski { 523*b1cdbd2cSJim Jagielski return insert( offset, str.getStr(), str.getLength() ); 524*b1cdbd2cSJim Jagielski } 525*b1cdbd2cSJim Jagielski 526*b1cdbd2cSJim Jagielski /** 527*b1cdbd2cSJim Jagielski Inserts the string representation of the <code>char</code> array 528*b1cdbd2cSJim Jagielski argument into this string buffer. 529*b1cdbd2cSJim Jagielski 530*b1cdbd2cSJim Jagielski The characters of the array argument are inserted into the 531*b1cdbd2cSJim Jagielski contents of this string buffer at the position indicated by 532*b1cdbd2cSJim Jagielski <code>offset</code>. The length of this string buffer increases by 533*b1cdbd2cSJim Jagielski the length of the argument. 534*b1cdbd2cSJim Jagielski <p> 535*b1cdbd2cSJim Jagielski The offset argument must be greater than or equal to 536*b1cdbd2cSJim Jagielski <code>0</code>, and less than or equal to the length of this 537*b1cdbd2cSJim Jagielski string buffer. 538*b1cdbd2cSJim Jagielski 539*b1cdbd2cSJim Jagielski @param offset the offset. 540*b1cdbd2cSJim Jagielski @param ch a character array. 541*b1cdbd2cSJim Jagielski @return this string buffer. 542*b1cdbd2cSJim Jagielski */ insert(sal_Int32 offset,const sal_Unicode * str)543*b1cdbd2cSJim Jagielski OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str ) 544*b1cdbd2cSJim Jagielski { 545*b1cdbd2cSJim Jagielski return insert( offset, str, rtl_ustr_getLength( str ) ); 546*b1cdbd2cSJim Jagielski } 547*b1cdbd2cSJim Jagielski 548*b1cdbd2cSJim Jagielski /** 549*b1cdbd2cSJim Jagielski Inserts the string representation of the <code>char</code> array 550*b1cdbd2cSJim Jagielski argument into this string buffer. 551*b1cdbd2cSJim Jagielski 552*b1cdbd2cSJim Jagielski The characters of the array argument are inserted into the 553*b1cdbd2cSJim Jagielski contents of this string buffer at the position indicated by 554*b1cdbd2cSJim Jagielski <code>offset</code>. The length of this string buffer increases by 555*b1cdbd2cSJim Jagielski the length of the argument. 556*b1cdbd2cSJim Jagielski <p> 557*b1cdbd2cSJim Jagielski The offset argument must be greater than or equal to 558*b1cdbd2cSJim Jagielski <code>0</code>, and less than or equal to the length of this 559*b1cdbd2cSJim Jagielski string buffer. 560*b1cdbd2cSJim Jagielski 561*b1cdbd2cSJim Jagielski @param offset the offset. 562*b1cdbd2cSJim Jagielski @param ch a character array. 563*b1cdbd2cSJim Jagielski @param len the number of characters to append. 564*b1cdbd2cSJim Jagielski @return this string buffer. 565*b1cdbd2cSJim Jagielski */ insert(sal_Int32 offset,const sal_Unicode * str,sal_Int32 len)566*b1cdbd2cSJim Jagielski OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str, sal_Int32 len) 567*b1cdbd2cSJim Jagielski { 568*b1cdbd2cSJim Jagielski // insert behind the last character 569*b1cdbd2cSJim Jagielski rtl_uStringbuffer_insert( &pData, &nCapacity, offset, str, len ); 570*b1cdbd2cSJim Jagielski return *this; 571*b1cdbd2cSJim Jagielski } 572*b1cdbd2cSJim Jagielski 573*b1cdbd2cSJim Jagielski /** 574*b1cdbd2cSJim Jagielski Inserts the string representation of the <code>sal_Bool</code> 575*b1cdbd2cSJim Jagielski argument into this string buffer. 576*b1cdbd2cSJim Jagielski 577*b1cdbd2cSJim Jagielski The second argument is converted to a string as if by the method 578*b1cdbd2cSJim Jagielski <code>String.valueOf</code>, and the characters of that 579*b1cdbd2cSJim Jagielski string are then inserted into this string buffer at the indicated 580*b1cdbd2cSJim Jagielski offset. 581*b1cdbd2cSJim Jagielski <p> 582*b1cdbd2cSJim Jagielski The offset argument must be greater than or equal to 583*b1cdbd2cSJim Jagielski <code>0</code>, and less than or equal to the length of this 584*b1cdbd2cSJim Jagielski string buffer. 585*b1cdbd2cSJim Jagielski 586*b1cdbd2cSJim Jagielski @param offset the offset. 587*b1cdbd2cSJim Jagielski @param b a <code>sal_Bool</code>. 588*b1cdbd2cSJim Jagielski @return this string buffer. 589*b1cdbd2cSJim Jagielski */ insert(sal_Int32 offset,sal_Bool b)590*b1cdbd2cSJim Jagielski OUStringBuffer & insert(sal_Int32 offset, sal_Bool b) 591*b1cdbd2cSJim Jagielski { 592*b1cdbd2cSJim Jagielski sal_Unicode sz[RTL_USTR_MAX_VALUEOFBOOLEAN]; 593*b1cdbd2cSJim Jagielski return insert( offset, sz, rtl_ustr_valueOfBoolean( sz, b ) ); 594*b1cdbd2cSJim Jagielski } 595*b1cdbd2cSJim Jagielski 596*b1cdbd2cSJim Jagielski /** 597*b1cdbd2cSJim Jagielski Inserts the string representation of the <code>char</code> 598*b1cdbd2cSJim Jagielski argument into this string buffer. 599*b1cdbd2cSJim Jagielski 600*b1cdbd2cSJim Jagielski The second argument is inserted into the contents of this string 601*b1cdbd2cSJim Jagielski buffer at the position indicated by <code>offset</code>. The length 602*b1cdbd2cSJim Jagielski of this string buffer increases by one. 603*b1cdbd2cSJim Jagielski <p> 604*b1cdbd2cSJim Jagielski The offset argument must be greater than or equal to 605*b1cdbd2cSJim Jagielski <code>0</code>, and less than or equal to the length of this 606*b1cdbd2cSJim Jagielski string buffer. 607*b1cdbd2cSJim Jagielski 608*b1cdbd2cSJim Jagielski @param offset the offset. 609*b1cdbd2cSJim Jagielski @param ch a <code>char</code>. 610*b1cdbd2cSJim Jagielski @return this string buffer. 611*b1cdbd2cSJim Jagielski */ insert(sal_Int32 offset,sal_Unicode c)612*b1cdbd2cSJim Jagielski OUStringBuffer & insert(sal_Int32 offset, sal_Unicode c) 613*b1cdbd2cSJim Jagielski { 614*b1cdbd2cSJim Jagielski return insert( offset, &c, 1 ); 615*b1cdbd2cSJim Jagielski } 616*b1cdbd2cSJim Jagielski 617*b1cdbd2cSJim Jagielski /** 618*b1cdbd2cSJim Jagielski Inserts the string representation of the second <code>sal_Int32</code> 619*b1cdbd2cSJim Jagielski argument into this string buffer. 620*b1cdbd2cSJim Jagielski 621*b1cdbd2cSJim Jagielski The second argument is converted to a string as if by the method 622*b1cdbd2cSJim Jagielski <code>String.valueOf</code>, and the characters of that 623*b1cdbd2cSJim Jagielski string are then inserted into this string buffer at the indicated 624*b1cdbd2cSJim Jagielski offset. 625*b1cdbd2cSJim Jagielski <p> 626*b1cdbd2cSJim Jagielski The offset argument must be greater than or equal to 627*b1cdbd2cSJim Jagielski <code>0</code>, and less than or equal to the length of this 628*b1cdbd2cSJim Jagielski string buffer. 629*b1cdbd2cSJim Jagielski 630*b1cdbd2cSJim Jagielski @param offset the offset. 631*b1cdbd2cSJim Jagielski @param b an <code>sal_Int32</code>. 632*b1cdbd2cSJim Jagielski @return this string buffer. 633*b1cdbd2cSJim Jagielski @exception StringIndexOutOfBoundsException if the offset is invalid. 634*b1cdbd2cSJim Jagielski */ insert(sal_Int32 offset,sal_Int32 i,sal_Int16 radix=10)635*b1cdbd2cSJim Jagielski OUStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 ) 636*b1cdbd2cSJim Jagielski { 637*b1cdbd2cSJim Jagielski sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT32]; 638*b1cdbd2cSJim Jagielski return insert( offset, sz, rtl_ustr_valueOfInt32( sz, i, radix ) ); 639*b1cdbd2cSJim Jagielski } 640*b1cdbd2cSJim Jagielski 641*b1cdbd2cSJim Jagielski /** 642*b1cdbd2cSJim Jagielski Inserts the string representation of the <code>long</code> 643*b1cdbd2cSJim Jagielski argument into this string buffer. 644*b1cdbd2cSJim Jagielski 645*b1cdbd2cSJim Jagielski The second argument is converted to a string as if by the method 646*b1cdbd2cSJim Jagielski <code>String.valueOf</code>, and the characters of that 647*b1cdbd2cSJim Jagielski string are then inserted into this string buffer at the indicated 648*b1cdbd2cSJim Jagielski offset. 649*b1cdbd2cSJim Jagielski <p> 650*b1cdbd2cSJim Jagielski The offset argument must be greater than or equal to 651*b1cdbd2cSJim Jagielski <code>0</code>, and less than or equal to the length of this 652*b1cdbd2cSJim Jagielski string buffer. 653*b1cdbd2cSJim Jagielski 654*b1cdbd2cSJim Jagielski @param offset the offset. 655*b1cdbd2cSJim Jagielski @param b a <code>long</code>. 656*b1cdbd2cSJim Jagielski @return this string buffer. 657*b1cdbd2cSJim Jagielski @exception StringIndexOutOfBoundsException if the offset is invalid. 658*b1cdbd2cSJim Jagielski */ insert(sal_Int32 offset,sal_Int64 l,sal_Int16 radix=10)659*b1cdbd2cSJim Jagielski OUStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 ) 660*b1cdbd2cSJim Jagielski { 661*b1cdbd2cSJim Jagielski sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT64]; 662*b1cdbd2cSJim Jagielski return insert( offset, sz, rtl_ustr_valueOfInt64( sz, l, radix ) ); 663*b1cdbd2cSJim Jagielski } 664*b1cdbd2cSJim Jagielski 665*b1cdbd2cSJim Jagielski /** 666*b1cdbd2cSJim Jagielski Inserts the string representation of the <code>float</code> 667*b1cdbd2cSJim Jagielski argument into this string buffer. 668*b1cdbd2cSJim Jagielski 669*b1cdbd2cSJim Jagielski The second argument is converted to a string as if by the method 670*b1cdbd2cSJim Jagielski <code>String.valueOf</code>, and the characters of that 671*b1cdbd2cSJim Jagielski string are then inserted into this string buffer at the indicated 672*b1cdbd2cSJim Jagielski offset. 673*b1cdbd2cSJim Jagielski <p> 674*b1cdbd2cSJim Jagielski The offset argument must be greater than or equal to 675*b1cdbd2cSJim Jagielski <code>0</code>, and less than or equal to the length of this 676*b1cdbd2cSJim Jagielski string buffer. 677*b1cdbd2cSJim Jagielski 678*b1cdbd2cSJim Jagielski @param offset the offset. 679*b1cdbd2cSJim Jagielski @param b a <code>float</code>. 680*b1cdbd2cSJim Jagielski @return this string buffer. 681*b1cdbd2cSJim Jagielski @exception StringIndexOutOfBoundsException if the offset is invalid. 682*b1cdbd2cSJim Jagielski */ insert(sal_Int32 offset,float f)683*b1cdbd2cSJim Jagielski OUStringBuffer insert(sal_Int32 offset, float f) 684*b1cdbd2cSJim Jagielski { 685*b1cdbd2cSJim Jagielski sal_Unicode sz[RTL_USTR_MAX_VALUEOFFLOAT]; 686*b1cdbd2cSJim Jagielski return insert( offset, sz, rtl_ustr_valueOfFloat( sz, f ) ); 687*b1cdbd2cSJim Jagielski } 688*b1cdbd2cSJim Jagielski 689*b1cdbd2cSJim Jagielski /** 690*b1cdbd2cSJim Jagielski Inserts the string representation of the <code>double</code> 691*b1cdbd2cSJim Jagielski argument into this string buffer. 692*b1cdbd2cSJim Jagielski 693*b1cdbd2cSJim Jagielski The second argument is converted to a string as if by the method 694*b1cdbd2cSJim Jagielski <code>String.valueOf</code>, and the characters of that 695*b1cdbd2cSJim Jagielski string are then inserted into this string buffer at the indicated 696*b1cdbd2cSJim Jagielski offset. 697*b1cdbd2cSJim Jagielski <p> 698*b1cdbd2cSJim Jagielski The offset argument must be greater than or equal to 699*b1cdbd2cSJim Jagielski <code>0</code>, and less than or equal to the length of this 700*b1cdbd2cSJim Jagielski string buffer. 701*b1cdbd2cSJim Jagielski 702*b1cdbd2cSJim Jagielski @param offset the offset. 703*b1cdbd2cSJim Jagielski @param b a <code>double</code>. 704*b1cdbd2cSJim Jagielski @return this string buffer. 705*b1cdbd2cSJim Jagielski @exception StringIndexOutOfBoundsException if the offset is invalid. 706*b1cdbd2cSJim Jagielski */ insert(sal_Int32 offset,double d)707*b1cdbd2cSJim Jagielski OUStringBuffer & insert(sal_Int32 offset, double d) 708*b1cdbd2cSJim Jagielski { 709*b1cdbd2cSJim Jagielski sal_Unicode sz[RTL_USTR_MAX_VALUEOFDOUBLE]; 710*b1cdbd2cSJim Jagielski return insert( offset, sz, rtl_ustr_valueOfDouble( sz, d ) ); 711*b1cdbd2cSJim Jagielski } 712*b1cdbd2cSJim Jagielski 713*b1cdbd2cSJim Jagielski /** 714*b1cdbd2cSJim Jagielski Inserts a single UTF-32 character into this string buffer. 715*b1cdbd2cSJim Jagielski 716*b1cdbd2cSJim Jagielski <p>The single UTF-32 character will be represented within the string 717*b1cdbd2cSJim Jagielski buffer as either one or two UTF-16 code units.</p> 718*b1cdbd2cSJim Jagielski 719*b1cdbd2cSJim Jagielski @param offset the offset into this string buffer (from zero to the length 720*b1cdbd2cSJim Jagielski of this string buffer, inclusive) 721*b1cdbd2cSJim Jagielski 722*b1cdbd2cSJim Jagielski @param c a well-formed UTF-32 code unit (that is, a value in the range 723*b1cdbd2cSJim Jagielski <code>0</code>–<code>0x10FFFF</code>, but excluding 724*b1cdbd2cSJim Jagielski <code>0xD800</code>–<code>0xDFFF</code>) 725*b1cdbd2cSJim Jagielski 726*b1cdbd2cSJim Jagielski @return this string buffer 727*b1cdbd2cSJim Jagielski */ insertUtf32(sal_Int32 offset,sal_uInt32 c)728*b1cdbd2cSJim Jagielski OUStringBuffer & insertUtf32(sal_Int32 offset, sal_uInt32 c) { 729*b1cdbd2cSJim Jagielski rtl_uStringbuffer_insertUtf32(&pData, &nCapacity, offset, c); 730*b1cdbd2cSJim Jagielski return *this; 731*b1cdbd2cSJim Jagielski } 732*b1cdbd2cSJim Jagielski 733*b1cdbd2cSJim Jagielski /** Allows access to the internal data of this OUStringBuffer, for effective 734*b1cdbd2cSJim Jagielski manipulation. 735*b1cdbd2cSJim Jagielski 736*b1cdbd2cSJim Jagielski This method should be used with care. After you have called this 737*b1cdbd2cSJim Jagielski method, you may use the returned pInternalData or pInternalCapacity only 738*b1cdbd2cSJim Jagielski as long as you make no other method call on this OUStringBuffer. 739*b1cdbd2cSJim Jagielski 740*b1cdbd2cSJim Jagielski @param pInternalData 741*b1cdbd2cSJim Jagielski This output parameter receives a pointer to the internal data 742*b1cdbd2cSJim Jagielski (rtl_uString pointer). pInternalData itself must not be null. 743*b1cdbd2cSJim Jagielski 744*b1cdbd2cSJim Jagielski @param pInternalCapacity 745*b1cdbd2cSJim Jagielski This output parameter receives a pointer to the internal capacity. 746*b1cdbd2cSJim Jagielski pInternalCapacity itself must not be null. 747*b1cdbd2cSJim Jagielski */ accessInternals(rtl_uString *** pInternalData,sal_Int32 ** pInternalCapacity)748*b1cdbd2cSJim Jagielski inline void accessInternals(rtl_uString *** pInternalData, 749*b1cdbd2cSJim Jagielski sal_Int32 ** pInternalCapacity) 750*b1cdbd2cSJim Jagielski { 751*b1cdbd2cSJim Jagielski *pInternalData = &pData; 752*b1cdbd2cSJim Jagielski *pInternalCapacity = &nCapacity; 753*b1cdbd2cSJim Jagielski } 754*b1cdbd2cSJim Jagielski 755*b1cdbd2cSJim Jagielski private: 756*b1cdbd2cSJim Jagielski /** 757*b1cdbd2cSJim Jagielski A pointer to the data structur which contains the data. 758*b1cdbd2cSJim Jagielski */ 759*b1cdbd2cSJim Jagielski rtl_uString * pData; 760*b1cdbd2cSJim Jagielski 761*b1cdbd2cSJim Jagielski /** 762*b1cdbd2cSJim Jagielski The len of the pData->buffer. 763*b1cdbd2cSJim Jagielski */ 764*b1cdbd2cSJim Jagielski sal_Int32 nCapacity; 765*b1cdbd2cSJim Jagielski }; 766*b1cdbd2cSJim Jagielski 767*b1cdbd2cSJim Jagielski } 768*b1cdbd2cSJim Jagielski 769*b1cdbd2cSJim Jagielski #endif /* __cplusplus */ 770*b1cdbd2cSJim Jagielski #endif /* _RTL_USTRBUF_HXX_ */ 771