xref: /aoo4110/main/sal/inc/rtl/strbuf.h (revision b1cdbd2c)
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_STRBUF_H_
25*b1cdbd2cSJim Jagielski #define _RTL_STRBUF_H_
26*b1cdbd2cSJim Jagielski 
27*b1cdbd2cSJim Jagielski #include <rtl/string.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_stringbuffer_newFromStr_WithLength( rtl_String ** newStr,
46*b1cdbd2cSJim Jagielski 													  const sal_Char * 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_stringbuffer_newFromStringBuffer( rtl_String ** newStr,
65*b1cdbd2cSJim Jagielski 													     sal_Int32 capacity,
66*b1cdbd2cSJim Jagielski 													     rtl_String * 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_stringbuffer_ensureCapacity(	/*inout*/rtl_String ** This,
86*b1cdbd2cSJim Jagielski 												/*inout*/sal_Int32* capacity,
87*b1cdbd2cSJim Jagielski 												sal_Int32 minimumCapacity);
88*b1cdbd2cSJim Jagielski 
89*b1cdbd2cSJim Jagielski 
90*b1cdbd2cSJim Jagielski /**
91*b1cdbd2cSJim Jagielski 	Inserts the string representation of the <code>char</code> array
92*b1cdbd2cSJim Jagielski 	argument into this string buffer.
93*b1cdbd2cSJim Jagielski 
94*b1cdbd2cSJim Jagielski 	The characters of the array argument are inserted into the
95*b1cdbd2cSJim Jagielski 	contents of this string buffer at the position indicated by
96*b1cdbd2cSJim Jagielski 	<code>offset</code>. The length of this string buffer increases by
97*b1cdbd2cSJim Jagielski 	the length of the argument.
98*b1cdbd2cSJim Jagielski 
99*b1cdbd2cSJim Jagielski 	@param	capacity 	the capacity of the string buffer
100*b1cdbd2cSJim Jagielski 	@param 	offset  	the offset.
101*b1cdbd2cSJim Jagielski 	@param 	ch      	a character array.
102*b1cdbd2cSJim Jagielski 	@param	len    		the number of characters to append.
103*b1cdbd2cSJim Jagielski 	@return	this string buffer.
104*b1cdbd2cSJim Jagielski  */
105*b1cdbd2cSJim Jagielski void SAL_CALL rtl_stringbuffer_insert( /*inout*/rtl_String ** This,
106*b1cdbd2cSJim Jagielski 									   /*inout*/sal_Int32 * capacity,
107*b1cdbd2cSJim Jagielski 									   sal_Int32 offset,
108*b1cdbd2cSJim Jagielski 									   const sal_Char * str,
109*b1cdbd2cSJim Jagielski 									   sal_Int32 len);
110*b1cdbd2cSJim Jagielski 
111*b1cdbd2cSJim Jagielski #ifdef __cplusplus
112*b1cdbd2cSJim Jagielski }
113*b1cdbd2cSJim Jagielski #endif
114*b1cdbd2cSJim Jagielski 
115*b1cdbd2cSJim Jagielski #endif	/* _RTL_STRBUF_H_ */
116