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_H_ 25*b1cdbd2cSJim Jagielski #define _RTL_USTRBUF_H_ 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski #include <rtl/ustring.h> 28*b1cdbd2cSJim Jagielski 29*b1cdbd2cSJim Jagielski #ifdef __cplusplus 30*b1cdbd2cSJim Jagielski extern "C" { 31*b1cdbd2cSJim Jagielski #endif 32*b1cdbd2cSJim Jagielski 33*b1cdbd2cSJim Jagielski /** @HTML 34*b1cdbd2cSJim Jagielski Allocates a new <code>String</code> that contains characters from 35*b1cdbd2cSJim Jagielski the character array argument. 36*b1cdbd2cSJim Jagielski 37*b1cdbd2cSJim Jagielski The <code>count</code> argument specifies 38*b1cdbd2cSJim Jagielski the length of the array. The initial capacity of the string buffer is 39*b1cdbd2cSJim Jagielski <code>16</code> plus the length of the string argument. 40*b1cdbd2cSJim Jagielski 41*b1cdbd2cSJim Jagielski @param newStr out parameter, contains the new string. The reference count is 1. 42*b1cdbd2cSJim Jagielski @param value the initial value of the string. 43*b1cdbd2cSJim Jagielski @param count the length of value. 44*b1cdbd2cSJim Jagielski */ 45*b1cdbd2cSJim Jagielski void SAL_CALL rtl_uStringbuffer_newFromStr_WithLength( rtl_uString ** newStr, 46*b1cdbd2cSJim Jagielski const sal_Unicode * value, 47*b1cdbd2cSJim Jagielski sal_Int32 count ); 48*b1cdbd2cSJim Jagielski 49*b1cdbd2cSJim Jagielski /** 50*b1cdbd2cSJim Jagielski Allocates a new <code>String</code> that contains the same sequence of 51*b1cdbd2cSJim Jagielski characters as the string argument. 52*b1cdbd2cSJim Jagielski 53*b1cdbd2cSJim Jagielski The initial capacity is the larger of: 54*b1cdbd2cSJim Jagielski <ul> 55*b1cdbd2cSJim Jagielski <li> The <code>bufferLen</code> argument. 56*b1cdbd2cSJim Jagielski <li> The <code>length</code> of the string argument. 57*b1cdbd2cSJim Jagielski </ul> 58*b1cdbd2cSJim Jagielski 59*b1cdbd2cSJim Jagielski @param newStr out parameter, contains the new string. The reference count is 1. 60*b1cdbd2cSJim Jagielski @param capacity the initial len of the string buffer. 61*b1cdbd2cSJim Jagielski @param oldStr the initial value of the string. 62*b1cdbd2cSJim Jagielski @return the new capacity of the string buffer 63*b1cdbd2cSJim Jagielski */ 64*b1cdbd2cSJim Jagielski sal_Int32 SAL_CALL rtl_uStringbuffer_newFromStringBuffer( rtl_uString ** newStr, 65*b1cdbd2cSJim Jagielski sal_Int32 capacity, 66*b1cdbd2cSJim Jagielski rtl_uString * olsStr ); 67*b1cdbd2cSJim Jagielski 68*b1cdbd2cSJim Jagielski /** 69*b1cdbd2cSJim Jagielski Ensures that the capacity of the buffer is at least equal to the 70*b1cdbd2cSJim Jagielski specified minimum. 71*b1cdbd2cSJim Jagielski 72*b1cdbd2cSJim Jagielski If the current capacity of this string buffer is less than the 73*b1cdbd2cSJim Jagielski argument, then a new internal buffer is allocated with greater 74*b1cdbd2cSJim Jagielski capacity. The new capacity is the larger of: 75*b1cdbd2cSJim Jagielski <ul> 76*b1cdbd2cSJim Jagielski <li>The <code>minimumCapacity</code> argument. 77*b1cdbd2cSJim Jagielski <li>Twice the old capacity, plus <code>2</code>. 78*b1cdbd2cSJim Jagielski </ul> 79*b1cdbd2cSJim Jagielski If the <code>minimumCapacity</code> argument is nonpositive, this 80*b1cdbd2cSJim Jagielski method takes no action and simply returns. 81*b1cdbd2cSJim Jagielski 82*b1cdbd2cSJim Jagielski @param capacity in: old capicity, out: new capacity. 83*b1cdbd2cSJim Jagielski @param minimumCapacity the minimum desired capacity. 84*b1cdbd2cSJim Jagielski */ 85*b1cdbd2cSJim Jagielski void SAL_CALL rtl_uStringbuffer_ensureCapacity( /*inout*/rtl_uString ** This, 86*b1cdbd2cSJim Jagielski /*inout*/sal_Int32* capacity, 87*b1cdbd2cSJim Jagielski sal_Int32 minimumCapacity); 88*b1cdbd2cSJim Jagielski 89*b1cdbd2cSJim Jagielski /** 90*b1cdbd2cSJim Jagielski Inserts the string representation of the <code>str</code> array 91*b1cdbd2cSJim Jagielski argument into this string buffer. 92*b1cdbd2cSJim Jagielski 93*b1cdbd2cSJim Jagielski The characters of the array argument are inserted into the 94*b1cdbd2cSJim Jagielski contents of this string buffer at the position indicated by 95*b1cdbd2cSJim Jagielski <code>offset</code>. The length of this string buffer increases by 96*b1cdbd2cSJim Jagielski the length of the argument. 97*b1cdbd2cSJim Jagielski 98*b1cdbd2cSJim Jagielski @param This The string, on that the operation should take place 99*b1cdbd2cSJim Jagielski @param capacity the capacity of the string buffer 100*b1cdbd2cSJim Jagielski @param offset the offset. 101*b1cdbd2cSJim Jagielski @param str a character array. 102*b1cdbd2cSJim Jagielski @param len the number of characters to append. 103*b1cdbd2cSJim Jagielski */ 104*b1cdbd2cSJim Jagielski void SAL_CALL rtl_uStringbuffer_insert( /*inout*/rtl_uString ** This, 105*b1cdbd2cSJim Jagielski /*inout*/sal_Int32 * capacity, 106*b1cdbd2cSJim Jagielski sal_Int32 offset, 107*b1cdbd2cSJim Jagielski const sal_Unicode * str, 108*b1cdbd2cSJim Jagielski sal_Int32 len); 109*b1cdbd2cSJim Jagielski 110*b1cdbd2cSJim Jagielski /** 111*b1cdbd2cSJim Jagielski Inserts a single UTF-32 character into this string buffer. 112*b1cdbd2cSJim Jagielski 113*b1cdbd2cSJim Jagielski <p>The single UTF-32 character will be represented within the string buffer 114*b1cdbd2cSJim Jagielski as either one or two UTF-16 code units.</p> 115*b1cdbd2cSJim Jagielski 116*b1cdbd2cSJim Jagielski @param pThis the string buffer on which the operation is performed 117*b1cdbd2cSJim Jagielski 118*b1cdbd2cSJim Jagielski @param capacity the capacity of the string buffer 119*b1cdbd2cSJim Jagielski 120*b1cdbd2cSJim Jagielski @param offset the offset into this string buffer (from zero to the length 121*b1cdbd2cSJim Jagielski of this string buffer, inclusive) 122*b1cdbd2cSJim Jagielski 123*b1cdbd2cSJim Jagielski @param c a well-formed UTF-32 code unit (that is, a value in the range 124*b1cdbd2cSJim Jagielski <code>0</code>–<code>0x10FFFF</code>, but excluding 125*b1cdbd2cSJim Jagielski <code>0xD800</code>–<code>0xDFFF</code>) 126*b1cdbd2cSJim Jagielski */ 127*b1cdbd2cSJim Jagielski void SAL_CALL rtl_uStringbuffer_insertUtf32( 128*b1cdbd2cSJim Jagielski rtl_uString ** pThis, sal_Int32 * capacity, sal_Int32 offset, sal_uInt32 c) 129*b1cdbd2cSJim Jagielski SAL_THROW_EXTERN_C(); 130*b1cdbd2cSJim Jagielski 131*b1cdbd2cSJim Jagielski /** 132*b1cdbd2cSJim Jagielski Inserts the 8-Bit ASCII string representation of the <code>str</code> 133*b1cdbd2cSJim Jagielski array argument into this string buffer. 134*b1cdbd2cSJim Jagielski 135*b1cdbd2cSJim Jagielski Since this function is optimized 136*b1cdbd2cSJim Jagielski for performance, the ASCII character values are not converted in any way. 137*b1cdbd2cSJim Jagielski The caller has to make sure that all ASCII characters are in the allowed 138*b1cdbd2cSJim Jagielski range between 0 and 127. 139*b1cdbd2cSJim Jagielski <p> 140*b1cdbd2cSJim Jagielski The characters of the array argument are inserted into the 141*b1cdbd2cSJim Jagielski contents of this string buffer at the position indicated by 142*b1cdbd2cSJim Jagielski <code>offset</code>. The length of this string buffer increases by 143*b1cdbd2cSJim Jagielski the length of the argument. 144*b1cdbd2cSJim Jagielski 145*b1cdbd2cSJim Jagielski @param This The string, on that the operation should take place 146*b1cdbd2cSJim Jagielski @param capacity the capacity of the string buffer 147*b1cdbd2cSJim Jagielski @param offset the offset. 148*b1cdbd2cSJim Jagielski @param str a character array. 149*b1cdbd2cSJim Jagielski @param len the number of characters to append. 150*b1cdbd2cSJim Jagielski */ 151*b1cdbd2cSJim Jagielski void SAL_CALL rtl_uStringbuffer_insert_ascii( /*inout*/rtl_uString ** This, 152*b1cdbd2cSJim Jagielski /*inout*/sal_Int32 * capacity, 153*b1cdbd2cSJim Jagielski sal_Int32 offset, 154*b1cdbd2cSJim Jagielski const sal_Char * str, 155*b1cdbd2cSJim Jagielski sal_Int32 len); 156*b1cdbd2cSJim Jagielski 157*b1cdbd2cSJim Jagielski #ifdef __cplusplus 158*b1cdbd2cSJim Jagielski } 159*b1cdbd2cSJim Jagielski #endif 160*b1cdbd2cSJim Jagielski 161*b1cdbd2cSJim Jagielski #endif /* _RTL_USTRBUF_H_ */ 162