xref: /AOO41X/main/sal/inc/rtl/strbuf.h (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _RTL_STRBUF_H_
29*cdf0e10cSrcweir #define _RTL_STRBUF_H_
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <rtl/string.h>
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #ifdef __cplusplus
34*cdf0e10cSrcweir extern "C" {
35*cdf0e10cSrcweir #endif
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir /** @HTML
38*cdf0e10cSrcweir 	Allocates a new <code>String</code> that contains characters from
39*cdf0e10cSrcweir 	the character array argument.
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir     The <code>count</code> argument specifies
42*cdf0e10cSrcweir 	the length of the array. The initial capacity of the string buffer is
43*cdf0e10cSrcweir 	<code>16</code> plus the length of the string argument.
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir 	@param  newStr   out parameter, contains the new string. The reference count is 1.
46*cdf0e10cSrcweir 	@param  value    the initial value of the string.
47*cdf0e10cSrcweir 	@param  count    the length of value.
48*cdf0e10cSrcweir  */
49*cdf0e10cSrcweir void SAL_CALL rtl_stringbuffer_newFromStr_WithLength( rtl_String ** newStr,
50*cdf0e10cSrcweir 													  const sal_Char * value,
51*cdf0e10cSrcweir 													  sal_Int32 count);
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir /**
54*cdf0e10cSrcweir 	Allocates a new <code>String</code> that contains the same sequence of
55*cdf0e10cSrcweir 	characters as the string argument.
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir     The initial capacity is the larger of:
58*cdf0e10cSrcweir 	<ul>
59*cdf0e10cSrcweir 	<li> The <code>bufferLen</code> argument.
60*cdf0e10cSrcweir 	<li> The <code>length</code> of the string argument.
61*cdf0e10cSrcweir 	</ul>
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir 	@param  newStr   	out parameter, contains the new string. The reference count is 1.
64*cdf0e10cSrcweir 	@param  capacity   	the initial len of the string buffer.
65*cdf0e10cSrcweir 	@param  oldStr	    the initial value of the string.
66*cdf0e10cSrcweir 	@return the new capacity of the string buffer
67*cdf0e10cSrcweir  */
68*cdf0e10cSrcweir sal_Int32 SAL_CALL rtl_stringbuffer_newFromStringBuffer( rtl_String ** newStr,
69*cdf0e10cSrcweir 													     sal_Int32 capacity,
70*cdf0e10cSrcweir 													     rtl_String * olsStr );
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir /**
73*cdf0e10cSrcweir 	Ensures that the capacity of the buffer is at least equal to the
74*cdf0e10cSrcweir 	specified minimum.
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 	If the current capacity of this string buffer is less than the
77*cdf0e10cSrcweir 	argument, then a new internal buffer is allocated with greater
78*cdf0e10cSrcweir 	capacity. The new capacity is the larger of:
79*cdf0e10cSrcweir 	<ul>
80*cdf0e10cSrcweir 	<li>The <code>minimumCapacity</code> argument.
81*cdf0e10cSrcweir 	<li>Twice the old capacity, plus <code>2</code>.
82*cdf0e10cSrcweir 	</ul>
83*cdf0e10cSrcweir 	If the <code>minimumCapacity</code> argument is nonpositive, this
84*cdf0e10cSrcweir 	method takes no action and simply returns.
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir 	@param   capacity		  in: old capicity, out: new capacity.
87*cdf0e10cSrcweir 	@param   minimumCapacity   the minimum desired capacity.
88*cdf0e10cSrcweir  */
89*cdf0e10cSrcweir void SAL_CALL rtl_stringbuffer_ensureCapacity(	/*inout*/rtl_String ** This,
90*cdf0e10cSrcweir 												/*inout*/sal_Int32* capacity,
91*cdf0e10cSrcweir 												sal_Int32 minimumCapacity);
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir /**
95*cdf0e10cSrcweir 	Inserts the string representation of the <code>char</code> array
96*cdf0e10cSrcweir 	argument into this string buffer.
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir 	The characters of the array argument are inserted into the
99*cdf0e10cSrcweir 	contents of this string buffer at the position indicated by
100*cdf0e10cSrcweir 	<code>offset</code>. The length of this string buffer increases by
101*cdf0e10cSrcweir 	the length of the argument.
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir 	@param	capacity 	the capacity of the string buffer
104*cdf0e10cSrcweir 	@param 	offset  	the offset.
105*cdf0e10cSrcweir 	@param 	ch      	a character array.
106*cdf0e10cSrcweir 	@param	len    		the number of characters to append.
107*cdf0e10cSrcweir 	@return	this string buffer.
108*cdf0e10cSrcweir  */
109*cdf0e10cSrcweir void SAL_CALL rtl_stringbuffer_insert( /*inout*/rtl_String ** This,
110*cdf0e10cSrcweir 									   /*inout*/sal_Int32 * capacity,
111*cdf0e10cSrcweir 									   sal_Int32 offset,
112*cdf0e10cSrcweir 									   const sal_Char * str,
113*cdf0e10cSrcweir 									   sal_Int32 len);
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir #ifdef __cplusplus
116*cdf0e10cSrcweir }
117*cdf0e10cSrcweir #endif
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir #endif	/* _RTL_STRBUF_H_ */
120