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