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 .
21 * This file is part of LibreOffice published API.
24 #ifndef INCLUDED_RTL_USTRBUF_H
25 #define INCLUDED_RTL_USTRBUF_H
27 #include "sal/config.h"
29 #include "rtl/ustring.h"
30 #include "sal/saldllapi.h"
36 /** Allocates a new <code>String</code> that contains characters from
37 the character array argument.
39 The <code>count</code> argument specifies
40 the length of the array. The initial capacity of the string buffer is
41 <code>16</code> plus the length of the string argument.
43 @param newStr out parameter, contains the new string. The reference count is 1.
44 @param value the initial value of the string.
45 @param count the length of value.
47 SAL_DLLPUBLIC
void SAL_CALL
rtl_uStringbuffer_newFromStr_WithLength(
48 rtl_uString
** newStr
,
49 const sal_Unicode
* value
,
53 Allocates a new <code>String</code> that contains the same sequence of
54 characters as the string argument.
56 The initial capacity is the larger of:
58 <li> The <code>bufferLen</code> argument.
59 <li> The <code>length</code> of the string argument.
62 @param newStr out parameter, contains the new string. The reference count is 1.
63 @param capacity the initial len of the string buffer.
64 @param oldStr the initial value of the string.
65 @return the new capacity of the string buffer
67 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_uStringbuffer_newFromStringBuffer(
68 rtl_uString
** newStr
,
70 rtl_uString
* oldStr
);
73 Ensures that the capacity of the buffer is at least equal to the
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:
80 <li>The <code>minimumCapacity</code> argument.
81 <li>Twice the old capacity, plus <code>2</code>.
83 If the <code>minimumCapacity</code> argument is nonpositive, this
84 method takes no action and simply returns.
86 @param[in,out] This the String to operate on.
87 @param[in,out] capacity in: old capacity, out: new capacity.
88 @param[in] minimumCapacity the minimum desired capacity.
90 SAL_DLLPUBLIC
void SAL_CALL
rtl_uStringbuffer_ensureCapacity(
93 sal_Int32 minimumCapacity
);
96 Inserts the string representation of the <code>str</code> array
97 argument into this string buffer.
99 The characters of the array argument are inserted into the
100 contents of this string buffer at the position indicated by
101 <code>offset</code>. The length of this string buffer increases by
102 the length of the argument.
104 @param This The string, on that the operation should take place
105 @param capacity the capacity of the string buffer
106 @param offset the offset.
107 @param str a character array. Since LibreOffice 4.4, as a special
108 case, if str is null then the len added characters are
110 @param len the number of characters to append.
112 SAL_DLLPUBLIC
void SAL_CALL
rtl_uStringbuffer_insert(
113 /*inout*/rtl_uString
** This
,
114 /*inout*/sal_Int32
* capacity
,
116 const sal_Unicode
* str
,
120 Inserts a single UTF-32 character into this string buffer.
122 <p>The single UTF-32 character will be represented within the string buffer
123 as either one or two UTF-16 code units.</p>
125 @param pThis the string buffer on which the operation is performed
127 @param capacity the capacity of the string buffer
129 @param offset the offset into this string buffer (from zero to the length
130 of this string buffer, inclusive)
132 @param c a well-formed UTF-32 code unit (that is, a value in the range
133 <code>0</code>–<code>0x10FFFF</code>, but excluding
134 <code>0xD800</code>–<code>0xDFFF</code>)
136 SAL_DLLPUBLIC
void SAL_CALL
rtl_uStringbuffer_insertUtf32(
137 rtl_uString
** pThis
, sal_Int32
* capacity
, sal_Int32 offset
, sal_uInt32 c
)
138 SAL_THROW_EXTERN_C();
141 Inserts the 8-Bit ASCII string representation of the <code>str</code>
142 array argument into this string buffer.
144 Since this function is optimized
145 for performance, the ASCII character values are not converted in any way.
146 The caller has to make sure that all ASCII characters are in the allowed
147 range between 0 and 127.
149 The characters of the array argument are inserted into the
150 contents of this string buffer at the position indicated by
151 <code>offset</code>. The length of this string buffer increases by
152 the length of the argument.
154 @param This The string, on that the operation should take place
155 @param capacity the capacity of the string buffer
156 @param offset the offset.
157 @param str a character array.
158 @param len the number of characters to append.
160 SAL_DLLPUBLIC
void SAL_CALL
rtl_uStringbuffer_insert_ascii(
161 /*inout*/rtl_uString
** This
,
162 /*inout*/sal_Int32
* capacity
,
168 Removes the characters in a substring of this sequence.
170 The substring begins at the specified <code>start</code> and
171 is <code>len</code> characters long.
173 start must be >= 0 && <= This->length
175 @param[in,out] This The String to operate on.
176 @param[in] start The beginning index, inclusive
177 @param[in] len The substring length
179 SAL_DLLPUBLIC
void SAL_CALL
rtl_uStringbuffer_remove(
185 Returns an immutable rtl_uString object, while clearing the string buffer.
187 This method is primarily used to allow these completed
188 string allocation events to be traced.
190 @param ppThis The string, on that the operation should take place
191 @param nCapacity pointer to the capacity of the string buffer
193 @since LibreOffice 3.6
195 SAL_DLLPUBLIC rtl_uString
* SAL_CALL
rtl_uStringBuffer_makeStringAndClear(
196 /*inout*/ rtl_uString
** ppThis
,
197 sal_Int32
*nCapacity
) SAL_RETURNS_NONNULL
;
200 References and returns an immutable rtl_uString object, from a mutable
201 string-buffer object.
203 This method is primarily used to allow legacy 'String' class
204 conversions to OUString to be accurately traced.
206 @param pThis The string, on that the operation should take place
208 @since LibreOffice 3.6
210 SAL_DLLPUBLIC rtl_uString
* SAL_CALL
rtl_uStringBuffer_refReturn( rtl_uString
*pThis
);
216 #endif // INCLUDED_RTL_USTRBUF_H
218 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */