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