1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_RTL_USTRBUF_H
21 #define INCLUDED_RTL_USTRBUF_H
23 #include "sal/config.h"
25 #include "rtl/ustring.h"
26 #include "sal/saldllapi.h"
32 /** Allocates a new <code>String</code> that contains characters from
33 the character array argument.
35 The <code>count</code> argument specifies
36 the length of the array. The initial capacity of the string buffer is
37 <code>16</code> plus the length of the string argument.
39 @param newStr out parameter, contains the new string. The reference count is 1.
40 @param value the initial value of the string.
41 @param count the length of value.
43 SAL_DLLPUBLIC
void SAL_CALL
rtl_uStringbuffer_newFromStr_WithLength(
44 rtl_uString
** newStr
,
45 const sal_Unicode
* value
,
49 Allocates a new <code>String</code> that contains the same sequence of
50 characters as the string argument.
52 The initial capacity is the larger of:
54 <li> The <code>bufferLen</code> argument.
55 <li> The <code>length</code> of the string argument.
58 @param newStr out parameter, contains the new string. The reference count is 1.
59 @param capacity the initial len of the string buffer.
60 @param oldStr the initial value of the string.
61 @return the new capacity of the string buffer
63 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_uStringbuffer_newFromStringBuffer(
64 rtl_uString
** newStr
,
66 rtl_uString
* oldStr
);
69 Ensures that the capacity of the buffer is at least equal to the
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:
76 <li>The <code>minimumCapacity</code> argument.
77 <li>Twice the old capacity, plus <code>2</code>.
79 If the <code>minimumCapacity</code> argument is nonpositive, this
80 method takes no action and simply returns.
82 @param[in,out] This the String to operate on.
83 @param[in,out] capacity in: old capacity, out: new capacity.
84 @param[in] minimumCapacity the minimum desired capacity.
86 SAL_DLLPUBLIC
void SAL_CALL
rtl_uStringbuffer_ensureCapacity(
89 sal_Int32 minimumCapacity
);
92 Inserts the string representation of the <code>str</code> array
93 argument into this string buffer.
95 The characters of the array argument are inserted into the
96 contents of this string buffer at the position indicated by
97 <code>offset</code>. The length of this string buffer increases by
98 the length of the argument.
100 @param This The string, on that the operation should take place
101 @param capacity the capacity of the string buffer
102 @param offset the offset.
103 @param str a character array. Since LibreOffice 4.4, as a special
104 case, if str is null then the len added characters are
106 @param len the number of characters to append.
108 SAL_DLLPUBLIC
void SAL_CALL
rtl_uStringbuffer_insert(
109 /*inout*/rtl_uString
** This
,
110 /*inout*/sal_Int32
* capacity
,
112 const sal_Unicode
* str
,
116 Inserts a single UTF-32 character into this string buffer.
118 <p>The single UTF-32 character will be represented within the string buffer
119 as either one or two UTF-16 code units.</p>
121 @param pThis the string buffer on which the operation is performed
123 @param capacity the capacity of the string buffer
125 @param offset the offset into this string buffer (from zero to the length
126 of this string buffer, inclusive)
128 @param c a well-formed UTF-32 code unit (that is, a value in the range
129 <code>0</code>–<code>0x10FFFF</code>, but excluding
130 <code>0xD800</code>–<code>0xDFFF</code>)
132 SAL_DLLPUBLIC
void SAL_CALL
rtl_uStringbuffer_insertUtf32(
133 rtl_uString
** pThis
, sal_Int32
* capacity
, sal_Int32 offset
, sal_uInt32 c
)
134 SAL_THROW_EXTERN_C();
137 Inserts the 8-Bit ASCII string representation of the <code>str</code>
138 array argument into this string buffer.
140 Since this function is optimized
141 for performance, the ASCII character values are not converted in any way.
142 The caller has to make sure that all ASCII characters are in the allowed
143 range between 0 and 127.
145 The characters of the array argument are inserted into the
146 contents of this string buffer at the position indicated by
147 <code>offset</code>. The length of this string buffer increases by
148 the length of the argument.
150 @param This The string, on that the operation should take place
151 @param capacity the capacity of the string buffer
152 @param offset the offset.
153 @param str a character array.
154 @param len the number of characters to append.
156 SAL_DLLPUBLIC
void SAL_CALL
rtl_uStringbuffer_insert_ascii(
157 /*inout*/rtl_uString
** This
,
158 /*inout*/sal_Int32
* capacity
,
160 const sal_Char
* str
,
164 Removes the characters in a substring of this sequence.
166 The substring begins at the specified <code>start</code> and
167 is <code>len</code> characters long.
169 start must be >= 0 && <= This->length
171 @param[in,out] This The String to operate on.
172 @param[in] start The beginning index, inclusive
173 @param[in] len The substring length
175 SAL_DLLPUBLIC
void SAL_CALL
rtl_uStringbuffer_remove(
181 Returns an immutable rtl_uString object, while clearing the string buffer.
183 This method is primarily used to allow these completed
184 string allocation events to be traced.
186 @param ppThis The string, on that the operation should take place
187 @param nCapacity pointer to the capacity of the string buffer
189 @since LibreOffice 3.6
191 SAL_DLLPUBLIC rtl_uString
* SAL_CALL
rtl_uStringBuffer_makeStringAndClear(
192 /*inout*/ rtl_uString
** ppThis
,
193 sal_Int32
*nCapacity
) SAL_RETURNS_NONNULL
;
196 References and returns an immutable rtl_uString object, from a mutable
197 string-buffer object.
199 This method is primarily used to allow legacy 'String' class
200 conversions to OUString to be accurately traced.
202 @param pThis The string, on that the operation should take place
204 @since LibreOffice 3.6
206 SAL_DLLPUBLIC rtl_uString
* SAL_CALL
rtl_uStringBuffer_refReturn( rtl_uString
*pThis
);
212 #endif // INCLUDED_RTL_USTRBUF_H
214 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */