1*9eab2a37SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9eab2a37SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9eab2a37SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9eab2a37SAndrew Rist * distributed with this work for additional information 6*9eab2a37SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9eab2a37SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9eab2a37SAndrew Rist * "License"); you may not use this file except in compliance 9*9eab2a37SAndrew Rist * with the License. You may obtain a copy of the License at 10*9eab2a37SAndrew Rist * 11*9eab2a37SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*9eab2a37SAndrew Rist * 13*9eab2a37SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9eab2a37SAndrew Rist * software distributed under the License is distributed on an 15*9eab2a37SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9eab2a37SAndrew Rist * KIND, either express or implied. See the License for the 17*9eab2a37SAndrew Rist * specific language governing permissions and limitations 18*9eab2a37SAndrew Rist * under the License. 19*9eab2a37SAndrew Rist * 20*9eab2a37SAndrew Rist *************************************************************/ 21*9eab2a37SAndrew Rist 22*9eab2a37SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _RTL_STRBUF_H_ 25cdf0e10cSrcweir #define _RTL_STRBUF_H_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <rtl/string.h> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #ifdef __cplusplus 30cdf0e10cSrcweir extern "C" { 31cdf0e10cSrcweir #endif 32cdf0e10cSrcweir 33cdf0e10cSrcweir /** @HTML 34cdf0e10cSrcweir Allocates a new <code>String</code> that contains characters from 35cdf0e10cSrcweir the character array argument. 36cdf0e10cSrcweir 37cdf0e10cSrcweir The <code>count</code> argument specifies 38cdf0e10cSrcweir the length of the array. The initial capacity of the string buffer is 39cdf0e10cSrcweir <code>16</code> plus the length of the string argument. 40cdf0e10cSrcweir 41cdf0e10cSrcweir @param newStr out parameter, contains the new string. The reference count is 1. 42cdf0e10cSrcweir @param value the initial value of the string. 43cdf0e10cSrcweir @param count the length of value. 44cdf0e10cSrcweir */ 45cdf0e10cSrcweir void SAL_CALL rtl_stringbuffer_newFromStr_WithLength( rtl_String ** newStr, 46cdf0e10cSrcweir const sal_Char * value, 47cdf0e10cSrcweir sal_Int32 count); 48cdf0e10cSrcweir 49cdf0e10cSrcweir /** 50cdf0e10cSrcweir Allocates a new <code>String</code> that contains the same sequence of 51cdf0e10cSrcweir characters as the string argument. 52cdf0e10cSrcweir 53cdf0e10cSrcweir The initial capacity is the larger of: 54cdf0e10cSrcweir <ul> 55cdf0e10cSrcweir <li> The <code>bufferLen</code> argument. 56cdf0e10cSrcweir <li> The <code>length</code> of the string argument. 57cdf0e10cSrcweir </ul> 58cdf0e10cSrcweir 59cdf0e10cSrcweir @param newStr out parameter, contains the new string. The reference count is 1. 60cdf0e10cSrcweir @param capacity the initial len of the string buffer. 61cdf0e10cSrcweir @param oldStr the initial value of the string. 62cdf0e10cSrcweir @return the new capacity of the string buffer 63cdf0e10cSrcweir */ 64cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_stringbuffer_newFromStringBuffer( rtl_String ** newStr, 65cdf0e10cSrcweir sal_Int32 capacity, 66cdf0e10cSrcweir rtl_String * olsStr ); 67cdf0e10cSrcweir 68cdf0e10cSrcweir /** 69cdf0e10cSrcweir Ensures that the capacity of the buffer is at least equal to the 70cdf0e10cSrcweir specified minimum. 71cdf0e10cSrcweir 72cdf0e10cSrcweir If the current capacity of this string buffer is less than the 73cdf0e10cSrcweir argument, then a new internal buffer is allocated with greater 74cdf0e10cSrcweir capacity. The new capacity is the larger of: 75cdf0e10cSrcweir <ul> 76cdf0e10cSrcweir <li>The <code>minimumCapacity</code> argument. 77cdf0e10cSrcweir <li>Twice the old capacity, plus <code>2</code>. 78cdf0e10cSrcweir </ul> 79cdf0e10cSrcweir If the <code>minimumCapacity</code> argument is nonpositive, this 80cdf0e10cSrcweir method takes no action and simply returns. 81cdf0e10cSrcweir 82cdf0e10cSrcweir @param capacity in: old capicity, out: new capacity. 83cdf0e10cSrcweir @param minimumCapacity the minimum desired capacity. 84cdf0e10cSrcweir */ 85cdf0e10cSrcweir void SAL_CALL rtl_stringbuffer_ensureCapacity( /*inout*/rtl_String ** This, 86cdf0e10cSrcweir /*inout*/sal_Int32* capacity, 87cdf0e10cSrcweir sal_Int32 minimumCapacity); 88cdf0e10cSrcweir 89cdf0e10cSrcweir 90cdf0e10cSrcweir /** 91cdf0e10cSrcweir Inserts the string representation of the <code>char</code> array 92cdf0e10cSrcweir argument into this string buffer. 93cdf0e10cSrcweir 94cdf0e10cSrcweir The characters of the array argument are inserted into the 95cdf0e10cSrcweir contents of this string buffer at the position indicated by 96cdf0e10cSrcweir <code>offset</code>. The length of this string buffer increases by 97cdf0e10cSrcweir the length of the argument. 98cdf0e10cSrcweir 99cdf0e10cSrcweir @param capacity the capacity of the string buffer 100cdf0e10cSrcweir @param offset the offset. 101cdf0e10cSrcweir @param ch a character array. 102cdf0e10cSrcweir @param len the number of characters to append. 103cdf0e10cSrcweir @return this string buffer. 104cdf0e10cSrcweir */ 105cdf0e10cSrcweir void SAL_CALL rtl_stringbuffer_insert( /*inout*/rtl_String ** This, 106cdf0e10cSrcweir /*inout*/sal_Int32 * capacity, 107cdf0e10cSrcweir sal_Int32 offset, 108cdf0e10cSrcweir const sal_Char * str, 109cdf0e10cSrcweir sal_Int32 len); 110cdf0e10cSrcweir 111cdf0e10cSrcweir #ifdef __cplusplus 112cdf0e10cSrcweir } 113cdf0e10cSrcweir #endif 114cdf0e10cSrcweir 115cdf0e10cSrcweir #endif /* _RTL_STRBUF_H_ */ 116