xref: /aoo42x/main/sal/inc/rtl/ustrbuf.h (revision 9eab2a37)
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_USTRBUF_H_
25cdf0e10cSrcweir #define _RTL_USTRBUF_H_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <rtl/ustring.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_uStringbuffer_newFromStr_WithLength( rtl_uString ** newStr,
46cdf0e10cSrcweir                                                       const sal_Unicode * 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_uStringbuffer_newFromStringBuffer( rtl_uString ** newStr,
65cdf0e10cSrcweir                                                           sal_Int32 capacity,
66cdf0e10cSrcweir                                                           rtl_uString * 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_uStringbuffer_ensureCapacity( /*inout*/rtl_uString ** This,
86cdf0e10cSrcweir                                                 /*inout*/sal_Int32* capacity,
87cdf0e10cSrcweir                                                 sal_Int32 minimumCapacity);
88cdf0e10cSrcweir 
89cdf0e10cSrcweir /**
90cdf0e10cSrcweir 	Inserts the string representation of the <code>str</code> array
91cdf0e10cSrcweir 	argument into this string buffer.
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 	The characters of the array argument are inserted into the
94cdf0e10cSrcweir 	contents of this string buffer at the position indicated by
95cdf0e10cSrcweir 	<code>offset</code>. The length of this string buffer increases by
96cdf0e10cSrcweir 	the length of the argument.
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 	@param   This        The string, on that the operation should take place
99cdf0e10cSrcweir 	@param   capacity    the capacity of the string buffer
100cdf0e10cSrcweir 	@param   offset      the offset.
101cdf0e10cSrcweir 	@param   str         a character array.
102cdf0e10cSrcweir 	@param   len         the number of characters to append.
103cdf0e10cSrcweir  */
104cdf0e10cSrcweir void SAL_CALL rtl_uStringbuffer_insert( /*inout*/rtl_uString ** This,
105cdf0e10cSrcweir                                         /*inout*/sal_Int32 * capacity,
106cdf0e10cSrcweir                                         sal_Int32 offset,
107cdf0e10cSrcweir                                         const sal_Unicode * str,
108cdf0e10cSrcweir                                         sal_Int32 len);
109cdf0e10cSrcweir 
110cdf0e10cSrcweir /**
111cdf0e10cSrcweir    Inserts a single UTF-32 character into this string buffer.
112cdf0e10cSrcweir 
113cdf0e10cSrcweir    <p>The single UTF-32 character will be represented within the string buffer
114cdf0e10cSrcweir    as either one or two UTF-16 code units.</p>
115cdf0e10cSrcweir 
116cdf0e10cSrcweir    @param pThis the string buffer on which the operation is performed
117cdf0e10cSrcweir 
118cdf0e10cSrcweir    @param capacity the capacity of the string buffer
119cdf0e10cSrcweir 
120cdf0e10cSrcweir    @param offset the offset into this string buffer (from zero to the length
121cdf0e10cSrcweir    of this string buffer, inclusive)
122cdf0e10cSrcweir 
123cdf0e10cSrcweir    @param c a well-formed UTF-32 code unit (that is, a value in the range
124cdf0e10cSrcweir    <code>0</code>&ndash;<code>0x10FFFF</code>, but excluding
125cdf0e10cSrcweir    <code>0xD800</code>&ndash;<code>0xDFFF</code>)
126cdf0e10cSrcweir  */
127cdf0e10cSrcweir void SAL_CALL rtl_uStringbuffer_insertUtf32(
128cdf0e10cSrcweir     rtl_uString ** pThis, sal_Int32 * capacity, sal_Int32 offset, sal_uInt32 c)
129cdf0e10cSrcweir     SAL_THROW_EXTERN_C();
130cdf0e10cSrcweir 
131cdf0e10cSrcweir /**
132cdf0e10cSrcweir 	Inserts the 8-Bit ASCII string representation of the <code>str</code>
133cdf0e10cSrcweir 	array argument into this string buffer.
134cdf0e10cSrcweir 
135cdf0e10cSrcweir     Since this function is optimized
136cdf0e10cSrcweir 	for performance, the ASCII character values are not converted in any way.
137cdf0e10cSrcweir 	The caller has to make sure that all ASCII characters are in the allowed
138cdf0e10cSrcweir 	range between 0 and 127.
139cdf0e10cSrcweir 	<p>
140cdf0e10cSrcweir 	The characters of the array argument are inserted into the
141cdf0e10cSrcweir 	contents of this string buffer at the position indicated by
142cdf0e10cSrcweir 	<code>offset</code>. The length of this string buffer increases by
143cdf0e10cSrcweir 	the length of the argument.
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 	@param   This        The string, on that the operation should take place
146cdf0e10cSrcweir 	@param   capacity    the capacity of the string buffer
147cdf0e10cSrcweir 	@param   offset      the offset.
148cdf0e10cSrcweir 	@param   str         a character array.
149cdf0e10cSrcweir 	@param   len         the number of characters to append.
150cdf0e10cSrcweir  */
151cdf0e10cSrcweir void SAL_CALL rtl_uStringbuffer_insert_ascii(   /*inout*/rtl_uString ** This,
152cdf0e10cSrcweir                                                 /*inout*/sal_Int32 * capacity,
153cdf0e10cSrcweir                                                 sal_Int32 offset,
154cdf0e10cSrcweir                                                 const sal_Char * str,
155cdf0e10cSrcweir                                                 sal_Int32 len);
156cdf0e10cSrcweir 
157cdf0e10cSrcweir #ifdef __cplusplus
158cdf0e10cSrcweir }
159cdf0e10cSrcweir #endif
160cdf0e10cSrcweir 
161cdf0e10cSrcweir #endif  /* _RTL_USTRBUF_H_ */
162