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