android: Update app-specific/MIME type icons
[LibreOffice.git] / include / rtl / ustring.h
blobda4278e5a683f94a03f1a7316e90a7872fa71ace
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_USTRING_H
25 #define INCLUDED_RTL_USTRING_H
27 #include "sal/config.h"
29 #include "osl/interlck.h"
30 #include "rtl/string.h"
31 #include "rtl/textenc.h"
32 #include "sal/saldllapi.h"
33 #include "sal/types.h"
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
39 /* ======================================================================= */
41 /** Return the length of a string.
43 The length is equal to the number of 16-bit Unicode characters in the
44 string, without the terminating NUL character.
46 @param str
47 a null-terminated string.
49 @return
50 the length of the sequence of characters represented by this string,
51 excluding the terminating NUL character.
53 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_getLength(
54 const sal_Unicode * str ) SAL_THROW_EXTERN_C();
56 /** Compare two strings.
58 The comparison is based on the numeric value of each character in the
59 strings and returns a value indicating their relationship. This function
60 cannot be used for language-specific sorting. Both strings must be
61 null-terminated.
63 @param first
64 the first null-terminated string to be compared.
66 @param second
67 the second null-terminated string which is compared with the first one.
69 @return
70 0 if both strings are equal, a value less than 0 if the first string is
71 less than the second string, and a value greater than 0 if the first
72 string is greater than the second string.
74 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_compare(
75 const sal_Unicode * first, const sal_Unicode * second ) SAL_THROW_EXTERN_C();
77 /** Compare two strings.
79 The comparison is based on the numeric value of each character in the
80 strings and returns a value indicating their relationship. This function
81 cannot be used for language-specific sorting.
83 @param first
84 the first string to be compared. Need not be null-terminated, but must be
85 at least as long as the specified firstLen.
87 @param firstLen
88 the length of the first string.
90 @param second
91 the second string which is compared with the first one. Need not be
92 null-terminated, but must be at least as long as the specified secondLen.
94 @param secondLen
95 the length of the second string.
97 @return
98 0 if both strings are equal, a value less than 0 if the first string is
99 less than the second string, and a value greater than 0 if the first
100 string is greater than the second string.
102 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_compare_WithLength(
103 const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
105 /** Compare two strings with a maximum count of characters.
107 The comparison is based on the numeric value of each character in the
108 strings and returns a value indicating their relationship. This function
109 cannot be used for language-specific sorting.
111 @param first
112 the first string to be compared. Need not be null-terminated, but must be
113 at least as long as the specified firstLen.
115 @param firstLen
116 the length of the first string.
118 @param second
119 the second string which is compared with the first one. Need not be
120 null-terminated, but must be at least as long as the specified secondLen.
122 @param secondLen
123 the length of the second string.
125 @param shortenedLen
126 the maximum number of characters to compare. This length can be greater
127 or smaller than the lengths of the two strings.
129 @return
130 0 if both substrings are equal, a value less than 0 if the first substring
131 is less than the second substring, and a value greater than 0 if the first
132 substring is greater than the second substring.
134 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_shortenedCompare_WithLength(
135 const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
137 /** Compare two strings from back to front.
139 The comparison is based on the numeric value of each character in the
140 strings and returns a value indicating their relationship. This function
141 cannot be used for language-specific sorting.
143 @param first
144 the first string to be compared. Need not be null-terminated, but must be
145 at least as long as the specified firstLen.
147 @param firstLen
148 the length of the first string.
150 @param second
151 the second string which is compared with the first one. Need not be
152 null-terminated, but must be at least as long as the specified secondLen.
154 @param secondLen
155 the length of the second string.
157 @return
158 0 if both strings are equal, a value less than 0 if the first string
159 compares less than the second string, and a value greater than 0 if the
160 first string compares greater than the second string.
162 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_reverseCompare_WithLength(
163 const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
165 /** Compare two strings from back to front for equality.
167 The comparison is based on the numeric value of each character in the
168 strings and returns 'true' if, and only if, both strings are equal.
169 This function cannot be used for language-specific sorting.
171 @param first
172 the first string to be compared. Need not be null-terminated, but must be
173 at least as long as the specified len.
175 @param second
176 the second string which is compared with the first one. Need not be
177 null-terminated, but must be at least as long as the specified len.
179 @param len
180 the length of both strings.
182 @return
183 true if both strings are equal, false if they are not equal.
186 SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_ustr_asciil_reverseEquals_WithLength(
187 const sal_Unicode * first, const char * second, sal_Int32 len ) SAL_THROW_EXTERN_C();
189 /** Compare two strings, ignoring the case of ASCII characters.
191 The comparison is based on the numeric value of each character in the
192 strings and returns a value indicating their relationship. Character
193 values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
194 and 122 (ASCII a--z). This function cannot be used for language-specific
195 sorting. Both strings must be null-terminated.
197 @param first
198 the first null-terminated string to be compared.
200 @param second
201 the second null-terminated string which is compared with the first one.
203 @return
204 0 if both strings are equal, a value less than 0 if the first string is
205 less than the second string, and a value greater than 0 if the first
206 string is greater than the second string.
208 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_compareIgnoreAsciiCase(
209 const sal_Unicode * first, const sal_Unicode * second ) SAL_THROW_EXTERN_C();
211 /** Compare two strings, ignoring the case of ASCII characters.
213 The comparison is based on the numeric value of each character in the
214 strings and returns a value indicating their relationship. Character
215 values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
216 and 122 (ASCII a--z). This function cannot be used for language-specific
217 sorting.
219 @param first
220 the first string to be compared. Need not be null-terminated, but must be
221 at least as long as the specified firstLen.
223 @param firstLen
224 the length of the first string.
226 @param second
227 the second string which is compared with the first one. Need not be
228 null-terminated, but must be at least as long as the specified secondLen.
230 @param secondLen
231 the length of the second string.
233 @return
234 0 if both strings are equal, a value less than 0 if the first string is
235 less than the second string, and a value greater than 0 if the first
236 string is greater than the second string.
238 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_compareIgnoreAsciiCase_WithLength(
239 const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
241 /** Compare two strings with a maximum count of characters, ignoring the case
242 of ASCII characters.
244 The comparison is based on the numeric value of each character in the
245 strings and returns a value indicating their relationship. Character
246 values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
247 and 122 (ASCII a--z). This function cannot be used for language-specific
248 sorting.
250 @param first
251 the first string to be compared. Need not be null-terminated, but must be
252 at least as long as the specified firstLen.
254 @param firstLen
255 the length of the first string.
257 @param second
258 the second string which is compared with the first one. Need not be
259 null-terminated, but must be at least as long as the specified secondLen.
261 @param secondLen
262 the length of the second string.
264 @param shortenedLen
265 the maximum number of characters to compare. This length can be greater
266 or smaller than the lengths of the two strings.
268 @return
269 0 if both substrings are equal, a value less than 0 if the first substring
270 is less than the second substring, and a value greater than 0 if the first
271 substring is greater than the second substring.
273 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength(
274 const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
276 /** Compare two strings.
278 The comparison is based on the numeric value of each character in the
279 strings and returns a value indicating their relationship. This function
280 cannot be used for language-specific sorting. Both strings must be
281 null-terminated.
283 Since this function is optimized for performance, the ASCII character
284 values are not converted in any way. The caller has to make sure that
285 all ASCII characters are in the allowed range of 0 and 127, inclusive.
287 @param first
288 the first null-terminated string to be compared.
290 @param second
291 the second null-terminated ASCII string which is compared with the first
292 one.
294 @return
295 0 if both substrings are equal, a value less than 0 if the first substring
296 is less than the second substring, and a value greater than 0 if the first
297 substring is greater than the second substring.
299 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_compare(
300 const sal_Unicode * first, const char * second ) SAL_THROW_EXTERN_C();
302 /** Compare two strings.
304 The comparison is based on the numeric value of each character in the
305 strings and returns a value indicating their relationship. This function
306 cannot be used for language-specific sorting.
308 Since this function is optimized for performance, the ASCII character
309 values are not converted in any way. The caller has to make sure that
310 all ASCII characters are in the allowed range of 0 and 127, inclusive.
312 @param first
313 the first string to be compared. Need not be null-terminated, but must be
314 at least as long as the specified firstLen.
316 @param firstLen
317 the length of the first string.
319 @param second
320 the second null-terminated ASCII string which is compared with the first
321 one.
323 @return
324 0 if both substrings are equal, a value less than 0 if the first substring
325 is less than the second substring, and a value greater than 0 if the first
326 substring is greater than the second substring.
328 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_compare_WithLength(
329 const sal_Unicode * first, sal_Int32 firstLen, const char * second ) SAL_THROW_EXTERN_C();
331 /** Compare two strings with a maximum count of characters.
333 The comparison is based on the numeric value of each character in the
334 strings and returns a value indicating their relationship. This function
335 cannot be used for language-specific sorting.
337 Since this function is optimized for performance, the ASCII character
338 values are not converted in any way. The caller has to make sure that
339 all ASCII characters are in the allowed range of 0 and 127, inclusive.
341 @param first
342 the first string to be compared. Need not be null-terminated, but must be
343 at least as long as the specified firstLen.
345 @param firstLen
346 the length of the first string.
348 @param second
349 the second null-terminated ASCII string which is compared with the first
350 one.
352 @param shortenedLen
353 the maximum number of characters to compare. This length can be greater
354 or smaller than the lengths of the two strings.
356 @return
357 0 if both substrings are equal, a value less than 0 if the first substring
358 is less than the second substring, and a value greater than 0 if the first
359 substring is greater than the second substring.
361 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_shortenedCompare_WithLength(
362 const sal_Unicode * first, sal_Int32 firstLen, const char * second, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
364 /** Compare two strings from back to front.
366 The comparison is based on the numeric value of each character in the
367 strings and returns a value indicating their relationship. This function
368 cannot be used for language-specific sorting.
370 Since this function is optimized for performance, the ASCII character
371 values are not converted in any way. The caller has to make sure that
372 all ASCII characters are in the allowed range of 0 and 127, inclusive.
374 @param first
375 the first string to be compared. Need not be null-terminated, but must be
376 at least as long as the specified firstLen.
378 @param firstLen
379 the length of the first string.
381 @param second
382 the second ASCII string which is compared with the first one. Need not be
383 null-terminated, but must be at least as long as the specified secondLen.
385 @param secondLen
386 the length of the second string.
388 @return
389 0 if both strings are equal, a value less than 0 if the first string
390 compares less than the second string, and a value greater than 0 if the
391 first string compares greater than the second string.
393 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_asciil_reverseCompare_WithLength(
394 const sal_Unicode * first, sal_Int32 firstLen, const char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
396 /** Compare two strings, ignoring the case of ASCII characters.
398 The comparison is based on the numeric value of each character in the
399 strings and returns a value indicating their relationship. Character
400 values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
401 and 122 (ASCII a--z). This function cannot be used for language-specific
402 sorting. Both strings must be null-terminated.
404 Since this function is optimized for performance, the ASCII character
405 values are not converted in any way. The caller has to make sure that
406 all ASCII characters are in the allowed range of 0 and 127, inclusive.
408 @param first
409 the first null-terminated string to be compared.
411 @param second
412 the second null-terminated ASCII string which is compared with the first
413 one.
415 @return
416 0 if both strings are equal, a value less than 0 if the first string is
417 less than the second string, and a value greater than 0 if the first
418 string is greater than the second string.
420 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase(
421 const sal_Unicode * first, const char * second ) SAL_THROW_EXTERN_C();
423 /** Compare two strings, ignoring the case of ASCII characters.
425 The comparison is based on the numeric value of each character in the
426 strings and returns a value indicating their relationship. Character
427 values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
428 and 122 (ASCII a--z). This function cannot be used for language-specific
429 sorting.
431 Since this function is optimized for performance, the ASCII character
432 values are not converted in any way. The caller has to make sure that
433 all ASCII characters are in the allowed range of 0 and 127, inclusive.
435 @param first
436 the first string to be compared. Need not be null-terminated, but must be
437 at least as long as the specified firstLen.
439 @param firstLen
440 the length of the first string.
442 @param second
443 the second null-terminated ASCII string which is compared with the first
444 one.
446 @return
447 0 if both strings are equal, a value less than 0 if the first string is
448 less than the second string, and a value greater than 0 if the first
449 string is greater than the second string.
451 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength(
452 const sal_Unicode * first, sal_Int32 firstLen, const char * second ) SAL_THROW_EXTERN_C();
454 /** Compare two strings, ignoring the case of ASCII characters.
456 The comparison is based on the numeric value of each character in the
457 strings and returns a value indicating their relationship. Character
458 values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
459 and 122 (ASCII a--z). This function cannot be used for language-specific
460 sorting.
462 Since this function is optimized for performance, the ASCII character
463 values are not converted in any way. The caller has to make sure that
464 all ASCII characters are in the allowed range of 0 and 127, inclusive.
466 @param first
467 the first string to be compared. Need not be null-terminated, but must be
468 at least as long as the specified firstLen.
470 @param firstLen
471 the length of the first string.
473 @param second
474 the second string which is compared with the first one. Need not be
475 null-terminated, but must be at least as long as the specified secondLen.
477 @param secondLen
478 the length of the second string.
480 @return
481 0 if both strings are equal, a value less than 0 if the first string is
482 less than the second string, and a value greater than 0 if the first
483 string is greater than the second string.
485 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
486 sal_Unicode const * first, sal_Int32 firstLen,
487 char const * second, sal_Int32 secondLen) SAL_THROW_EXTERN_C();
489 /** Compare two strings with a maximum count of characters, ignoring the case
490 of ASCII characters.
492 The comparison is based on the numeric value of each character in the
493 strings and returns a value indicating their relationship. Character
494 values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
495 and 122 (ASCII a--z). This function cannot be used for language-specific
496 sorting.
498 Since this function is optimized for performance, the ASCII character
499 values are not converted in any way. The caller has to make sure that
500 all ASCII characters are in the allowed range of 0 and 127, inclusive.
502 @param first
503 the first string to be compared. Need not be null-terminated, but must be
504 at least as long as the specified firstLen.
506 @param firstLen
507 the length of the first string.
509 @param second
510 the second null-terminated ASCII string which is compared with the first
511 one.
513 @param shortenedLen
514 the maximum number of characters to compare. This length can be greater
515 or smaller than the lengths of the two strings.
517 @return
518 0 if both substrings are equal, a value less than 0 if the first substring
519 is less than the second substring, and a value greater than 0 if the first
520 substring is greater than the second substring.
522 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(
523 const sal_Unicode * first, sal_Int32 firstLen, const char * second, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
525 /** Return a hash code for a string.
527 It is not allowed to store the hash code persistently, because later
528 versions could return other hash codes. The string must be
529 null-terminated.
531 @param str
532 a null-terminated string.
534 @return
535 a hash code for the given string.
537 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_hashCode(
538 const sal_Unicode * str ) SAL_THROW_EXTERN_C();
540 /** Return a hash code for a string.
542 It is not allowed to store the hash code persistently, because later
543 versions could return other hash codes.
545 @param str
546 a string. Need not be null-terminated, but must be at least as long as
547 the specified len.
549 @param len
550 the length of the string.
552 @return
553 a hash code for the given string.
555 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_hashCode_WithLength(
556 const sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
558 /** Search for the first occurrence of a character within a string.
560 The string must be null-terminated.
562 @param str
563 a null-terminated string.
565 @param ch
566 the character to be searched for.
568 @return
569 the index (starting at 0) of the first occurrence of the character in the
570 string, or -1 if the character does not occur.
572 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_indexOfChar(
573 const sal_Unicode * str, sal_Unicode ch ) SAL_THROW_EXTERN_C();
575 /** Search for the first occurrence of a character within a string.
577 @param str
578 a string. Need not be null-terminated, but must be at least as long as
579 the specified len.
581 @param len
582 the length of the string.
584 @param ch
585 the character to be searched for.
587 @return
588 the index (starting at 0) of the first occurrence of the character in the
589 string, or -1 if the character does not occur.
591 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_indexOfChar_WithLength(
592 const sal_Unicode * str, sal_Int32 len, sal_Unicode ch ) SAL_THROW_EXTERN_C();
594 /** Search for the last occurrence of a character within a string.
596 The string must be null-terminated.
598 @param str
599 a null-terminated string.
601 @param ch
602 the character to be searched for.
604 @return
605 the index (starting at 0) of the last occurrence of the character in the
606 string, or -1 if the character does not occur. The returned value is
607 always smaller than the string length.
609 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_lastIndexOfChar(
610 const sal_Unicode * str, sal_Unicode ch ) SAL_THROW_EXTERN_C();
612 /** Search for the last occurrence of a character within a string.
614 @param str
615 a string. Need not be null-terminated, but must be at least as long as
616 the specified len.
618 @param len
619 the length of the string.
621 @param ch
622 the character to be searched for.
624 @return
625 the index (starting at 0) of the last occurrence of the character in the
626 string, or -1 if the character does not occur. The returned value is
627 always smaller than the string length.
629 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_lastIndexOfChar_WithLength(
630 const sal_Unicode * str, sal_Int32 len, sal_Unicode ch ) SAL_THROW_EXTERN_C();
632 /** Search for the first occurrence of a substring within a string.
634 If subStr is empty, or both str and subStr are empty, -1 is returned.
635 Both strings must be null-terminated.
637 @param str
638 a null-terminated string.
640 @param subStr
641 the null-terminated substring to be searched for.
643 @return
644 the index (starting at 0) of the first character of the first occurrence
645 of the substring within the string, or -1 if the substring does not occur.
647 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_indexOfStr(
648 const sal_Unicode * str, const sal_Unicode * subStr ) SAL_THROW_EXTERN_C();
650 /** Search for the first occurrence of a substring within a string.
652 If subStr is empty, or both str and subStr are empty, -1 is returned.
654 @param str
655 a string. Need not be null-terminated, but must be at least as long as
656 the specified len.
658 @param len
659 the length of the string.
661 @param subStr
662 the substring to be searched for. Need not be null-terminated, but must
663 be at least as long as the specified subLen.
665 @param subLen
666 the length of the substring.
668 @return
669 the index (starting at 0) of the first character of the first occurrence
670 of the substring within the string, or -1 if the substring does not occur.
672 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_indexOfStr_WithLength(
673 const sal_Unicode * str, sal_Int32 len, const sal_Unicode * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
675 /** Search for the first occurrence of an ASCII substring within a string.
677 @param str
678 a string. Need not be null-terminated, but must be at least as long as
679 the specified len.
681 @param len
682 the length of the string; must be non-negative.
684 @param subStr
685 the substring to be searched for. Need not be null-terminated, but must
686 be at least as long as the specified subLen. Must only contain characters
687 in the ASCII range 0x00--7F.
689 @param subLen
690 the length of the substring; must be non-negative.
692 @return
693 the index (starting at 0) of the first character of the first occurrence
694 of the substring within the string, or -1 if the substring does not occur.
695 If subLen is zero, -1 is returned.
697 @since UDK 3.2.7
699 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_indexOfAscii_WithLength(
700 sal_Unicode const * str, sal_Int32 len,
701 char const * subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C();
703 /** Search for the last occurrence of a substring within a string.
705 If subStr is empty, or both str and subStr are empty, -1 is returned.
706 Both strings must be null-terminated.
708 @param str
709 a null-terminated string.
711 @param subStr
712 the null-terminated substring to be searched for.
714 @return
715 the index (starting at 0) of the first character of the last occurrence
716 of the substring within the string, or -1 if the substring does not occur.
718 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_lastIndexOfStr(
719 const sal_Unicode * str, const sal_Unicode * subStr ) SAL_THROW_EXTERN_C();
721 /** Search for the last occurrence of a substring within a string.
723 If subStr is empty, or both str and subStr are empty, -1 is returned.
725 @param str
726 a string. Need not be null-terminated, but must be at least as long as
727 the specified len.
729 @param len
730 the length of the string.
732 @param subStr
733 the substring to be searched for. Need not be null-terminated, but must
734 be at least as long as the specified subLen.
736 @param subLen
737 the length of the substring.
739 @return
740 the index (starting at 0) of the first character of the first occurrence
741 of the substring within the string, or -1 if the substring does not occur.
743 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_lastIndexOfStr_WithLength(
744 const sal_Unicode * str, sal_Int32 len, const sal_Unicode * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
746 /** Search for the last occurrence of an ASCII substring within a string.
748 @param str
749 a string. Need not be null-terminated, but must be at least as long as
750 the specified len.
752 @param len
753 the length of the string; must be non-negative.
755 @param subStr
756 the substring to be searched for. Need not be null-terminated, but must
757 be at least as long as the specified subLen. Must only contain characters
758 in the ASCII range 0x00--7F.
760 @param subLen
761 the length of the substring; must be non-negative.
763 @return
764 the index (starting at 0) of the first character of the last occurrence
765 of the substring within the string, or -1 if the substring does not occur.
766 If subLen is zero, -1 is returned.
768 @since UDK 3.2.7
770 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_lastIndexOfAscii_WithLength(
771 sal_Unicode const * str, sal_Int32 len,
772 char const * subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C();
774 /** Replace all occurrences of a single character within a string.
776 If oldChar does not occur within str, then the string is not modified.
777 The string must be null-terminated.
779 @param str
780 a null-terminated string.
782 @param oldChar
783 the old character.
785 @param newChar
786 the new character.
788 SAL_DLLPUBLIC void SAL_CALL rtl_ustr_replaceChar(
789 sal_Unicode * str, sal_Unicode oldChar, sal_Unicode newChar ) SAL_THROW_EXTERN_C();
791 /** Replace all occurrences of a single character within a string.
793 If oldChar does not occur within str, then the string is not modified.
795 @param str
796 a string. Need not be null-terminated, but must be at least as long as
797 the specified len.
799 @param len
800 the length of the string.
802 @param oldChar
803 the old character.
805 @param newChar
806 the new character.
808 SAL_DLLPUBLIC void SAL_CALL rtl_ustr_replaceChar_WithLength(
809 sal_Unicode * str, sal_Int32 len, sal_Unicode oldChar, sal_Unicode newChar ) SAL_THROW_EXTERN_C();
811 /** Convert all ASCII uppercase letters to lowercase within a string.
813 The characters with values between 65 and 90 (ASCII A--Z) are replaced
814 with values between 97 and 122 (ASCII a--z). The string must be
815 null-terminated.
817 @param str
818 a null-terminated string.
820 SAL_DLLPUBLIC void SAL_CALL rtl_ustr_toAsciiLowerCase(
821 sal_Unicode * str ) SAL_THROW_EXTERN_C();
823 /** Convert all ASCII uppercase letters to lowercase within a string.
825 The characters with values between 65 and 90 (ASCII A--Z) are replaced
826 with values between 97 and 122 (ASCII a--z).
828 @param str
829 a string. Need not be null-terminated, but must be at least as long as
830 the specified len.
832 @param len
833 the length of the string.
835 SAL_DLLPUBLIC void SAL_CALL rtl_ustr_toAsciiLowerCase_WithLength(
836 sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
838 /** Convert all ASCII lowercase letters to uppercase within a string.
840 The characters with values between 97 and 122 (ASCII a--z) are replaced
841 with values between 65 and 90 (ASCII A--Z). The string must be
842 null-terminated.
844 @param str
845 a null-terminated string.
847 SAL_DLLPUBLIC void SAL_CALL rtl_ustr_toAsciiUpperCase(
848 sal_Unicode * str ) SAL_THROW_EXTERN_C();
850 /** Convert all ASCII lowercase letters to uppercase within a string.
852 The characters with values between 97 and 122 (ASCII a--z) are replaced
853 with values between 65 and 90 (ASCII A--Z).
855 @param str
856 a string. Need not be null-terminated, but must be at least as long as
857 the specified len.
859 @param len
860 the length of the string.
862 SAL_DLLPUBLIC void SAL_CALL rtl_ustr_toAsciiUpperCase_WithLength(
863 sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
865 /** Remove white space from both ends of a string.
867 All characters with values less than or equal to 32 (the space character)
868 are considered to be white space. This function cannot be used for
869 language-specific operations. The string must be null-terminated.
871 @param str
872 a null-terminated string.
874 @return
875 the new length of the string.
877 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_trim(
878 sal_Unicode * str ) SAL_THROW_EXTERN_C();
880 /** Remove white space from both ends of the string.
882 All characters with values less than or equal to 32 (the space character)
883 are considered to be white space. This function cannot be used for
884 language-specific operations. The string must be null-terminated.
886 @param str
887 a string. Need not be null-terminated, but must be at least as long as
888 the specified len.
890 @param len
891 the original length of the string.
893 @return
894 the new length of the string.
896 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_trim_WithLength(
897 sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
899 /** Create the string representation of a boolean.
901 If b is true, the buffer is filled with the string "true" and 4 is
902 returned. If b is false, the buffer is filled with the string "false" and
903 5 is returned. This function cannot be used for language-specific
904 operations.
906 @param str
907 a buffer that is big enough to hold the result and the terminating NUL
908 character. You should use the RTL_USTR_MAX_VALUEOFBOOLEAN define to
909 create a buffer that is big enough.
911 @param b
912 a boolean value.
914 @return
915 the length of the string.
917 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfBoolean(
918 sal_Unicode * str, sal_Bool b ) SAL_THROW_EXTERN_C();
919 #define RTL_USTR_MAX_VALUEOFBOOLEAN RTL_STR_MAX_VALUEOFBOOLEAN
921 /** Create the string representation of a character.
923 @param str
924 a buffer that is big enough to hold the result and the terminating NUL
925 character. You should use the RTL_USTR_MAX_VALUEOFCHAR define to create a
926 buffer that is big enough.
928 @param ch
929 a character value.
931 @return
932 the length of the string.
934 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfChar(
935 sal_Unicode * str, sal_Unicode ch ) SAL_THROW_EXTERN_C();
936 #define RTL_USTR_MAX_VALUEOFCHAR RTL_STR_MAX_VALUEOFCHAR
938 /** Create the string representation of an integer.
940 This function cannot be used for language-specific operations.
942 @param str
943 a buffer that is big enough to hold the result and the terminating NUL
944 character. You should use the RTL_USTR_MAX_VALUEOFINT32 define to create
945 a buffer that is big enough.
947 @param i
948 an integer value.
950 @param radix
951 the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
952 (36), inclusive.
954 @return
955 the length of the string.
957 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfInt32(
958 sal_Unicode * str, sal_Int32 i, sal_Int16 radix ) SAL_THROW_EXTERN_C();
959 #define RTL_USTR_MIN_RADIX RTL_STR_MIN_RADIX
960 #define RTL_USTR_MAX_RADIX RTL_STR_MAX_RADIX
961 #define RTL_USTR_MAX_VALUEOFINT32 RTL_STR_MAX_VALUEOFINT32
963 /** Create the string representation of a long integer.
965 This function cannot be used for language-specific operations.
967 @param str
968 a buffer that is big enough to hold the result and the terminating NUL
969 character. You should use the RTL_USTR_MAX_VALUEOFINT64 define to create
970 a buffer that is big enough.
972 @param l
973 a long integer value.
975 @param radix
976 the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
977 (36), inclusive.
979 @return
980 the length of the string.
982 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfInt64(
983 sal_Unicode * str, sal_Int64 l, sal_Int16 radix ) SAL_THROW_EXTERN_C();
984 #define RTL_USTR_MAX_VALUEOFINT64 RTL_STR_MAX_VALUEOFINT64
986 /** Create the string representation of an unsigned long integer.
988 This function cannot be used for language-specific operations.
990 @param str
991 a buffer that is big enough to hold the result and the terminating NUL
992 character. You should use the RTL_USTR_MAX_VALUEOFUINT64 define to create
993 a buffer that is big enough.
995 @param l
996 a long integer value.
998 @param radix
999 the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
1000 (36), inclusive.
1002 @return
1003 the length of the string.
1005 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfUInt64(
1006 sal_Unicode * str, sal_uInt64 l, sal_Int16 radix ) SAL_THROW_EXTERN_C();
1007 #define RTL_USTR_MAX_VALUEOFUINT64 RTL_STR_MAX_VALUEOFUINT64
1009 /** Create the string representation of a float.
1011 This function cannot be used for language-specific conversion.
1013 @param str
1014 a buffer that is big enough to hold the result and the terminating NUL
1015 character. You should use the RTL_USTR_MAX_VALUEOFFLOAT define to create
1016 a buffer that is big enough.
1018 @param f
1019 a float value.
1021 @return
1022 the length of the string.
1024 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfFloat(
1025 sal_Unicode * str, float f ) SAL_THROW_EXTERN_C();
1026 #define RTL_USTR_MAX_VALUEOFFLOAT RTL_STR_MAX_VALUEOFFLOAT
1028 /** Create the string representation of a double.
1030 This function cannot be used for language-specific conversion.
1032 @param str
1033 a buffer that is big enough to hold the result and the terminating NUL
1034 character. You should use the RTL_USTR_MAX_VALUEOFDOUBLE define to create
1035 a buffer that is big enough.
1037 @param d
1038 a double value.
1040 @return
1041 the length of the string.
1043 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_valueOfDouble(
1044 sal_Unicode * str, double d ) SAL_THROW_EXTERN_C();
1045 #define RTL_USTR_MAX_VALUEOFDOUBLE RTL_STR_MAX_VALUEOFDOUBLE
1047 /** Interpret a string as a boolean.
1049 This function cannot be used for language-specific conversion. The string
1050 must be null-terminated.
1052 @param str
1053 a null-terminated string.
1055 @return
1056 true if the string is "1" or "true" in any ASCII case, false otherwise.
1058 SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_ustr_toBoolean(
1059 const sal_Unicode * str ) SAL_THROW_EXTERN_C();
1061 /** Interpret a string as an integer.
1063 This function cannot be used for language-specific conversion. The string
1064 must be null-terminated.
1066 @param str
1067 a null-terminated string.
1069 @param radix
1070 the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
1071 (36), inclusive.
1073 @return
1074 the integer value represented by the string, or 0 if the string does not
1075 represent an integer.
1077 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_toInt32(
1078 const sal_Unicode * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
1080 /** Interpret a string as an unsigned integer.
1082 This function cannot be used for language-specific conversion. The string
1083 must be null-terminated.
1085 @param str
1086 a null-terminated string.
1088 @param radix
1089 the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
1090 (36), inclusive.
1092 @return
1093 the unsigned integer value represented by the string, or 0 if the string
1094 does not represent an unsigned integer.
1096 @since LibreOffice 4.2
1098 SAL_DLLPUBLIC sal_uInt32 SAL_CALL rtl_ustr_toUInt32(
1099 const sal_Unicode * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
1101 /** Interpret a string as a long integer.
1103 This function cannot be used for language-specific conversion. The string
1104 must be null-terminated.
1106 @param str
1107 a null-terminated string.
1109 @param radix
1110 the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
1111 (36), inclusive.
1113 @return
1114 the long integer value represented by the string, or 0 if the string does
1115 not represent a long integer.
1117 SAL_DLLPUBLIC sal_Int64 SAL_CALL rtl_ustr_toInt64(
1118 const sal_Unicode * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
1120 /** Interpret a string as a long integer.
1122 This function cannot be used for language-specific conversion.
1124 @param str
1125 a string.
1127 @param radix
1128 the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
1129 (36), inclusive.
1131 @param nStrLength
1132 number of chars to process
1134 @return
1135 the long integer value represented by the string, or 0 if the string does
1136 not represent a long integer.
1138 @internal
1139 @since LibreOffice 6.4
1141 SAL_DLLPUBLIC sal_Int64 SAL_CALL rtl_ustr_toInt64_WithLength(
1142 const sal_Unicode * str, sal_Int16 radix, sal_Int32 nStrLength ) SAL_THROW_EXTERN_C();
1144 /** Interpret a string as an unsigned long integer.
1146 This function cannot be used for language-specific conversion. The string
1147 must be null-terminated.
1149 @param str
1150 a null-terminated string.
1152 @param radix
1153 the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
1154 (36), inclusive.
1156 @return
1157 the unsigned long integer value represented by the string, or 0 if the
1158 string does not represent an unsigned long integer.
1160 @since LibreOffice 4.1
1162 SAL_DLLPUBLIC sal_uInt64 SAL_CALL rtl_ustr_toUInt64(
1163 const sal_Unicode * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
1165 /** Interpret a string as a float.
1167 This function cannot be used for language-specific conversion. The string
1168 must be null-terminated.
1170 @param str
1171 a null-terminated string.
1173 @return
1174 the float value represented by the string, or 0.0 if the string does not
1175 represent a float.
1177 SAL_DLLPUBLIC float SAL_CALL rtl_ustr_toFloat(
1178 const sal_Unicode * str ) SAL_THROW_EXTERN_C();
1180 /** Interpret a string as a double.
1182 This function cannot be used for language-specific conversion. The string
1183 must be null-terminated.
1185 @param str
1186 a null-terminated string.
1188 @return
1189 the float value represented by the string, or 0.0 if the string does not
1190 represent a double.
1192 SAL_DLLPUBLIC double SAL_CALL rtl_ustr_toDouble(
1193 const sal_Unicode * str ) SAL_THROW_EXTERN_C();
1195 /* ======================================================================= */
1197 #if defined(_WIN32)
1198 #pragma pack(push, 4)
1199 #endif
1201 /** @cond INTERNAL */
1202 /** The implementation of a Unicode string.
1204 typedef struct SAL_DLLPUBLIC_RTTI _rtl_uString
1206 oslInterlockedCount refCount; /* opaque */
1207 sal_Int32 length;
1208 sal_Unicode buffer[1];
1209 } rtl_uString;
1210 /** @endcond */
1212 #if defined(_WIN32)
1213 #pragma pack(pop)
1214 #endif
1216 /* ----------------------------------------------------------------------- */
1218 /** Increment the reference count of a string.
1220 @param str
1221 a string.
1223 SAL_DLLPUBLIC void SAL_CALL rtl_uString_acquire(
1224 rtl_uString * str ) SAL_THROW_EXTERN_C() SAL_HOT;
1226 /** Decrement the reference count of a string.
1228 If the count goes to zero than the string data is deleted.
1230 @param str
1231 a string.
1233 SAL_DLLPUBLIC void SAL_CALL rtl_uString_release(
1234 rtl_uString * str ) SAL_THROW_EXTERN_C() SAL_HOT;
1236 /** Allocate a new string containing no characters.
1238 @param newStr
1239 pointer to the new string. The pointed-to data must be null or a valid
1240 string.
1242 SAL_DLLPUBLIC void SAL_CALL rtl_uString_new(
1243 rtl_uString ** newStr ) SAL_THROW_EXTERN_C();
1245 /** Allocate a new string containing space for a given number of characters.
1247 The reference count of the new string will be 1. The length of the string
1248 will be nLen. This function does not handle out-of-memory conditions.
1250 For failed allocation this method returns NULL.
1252 The characters of the capacity are not cleared, and the length is set to
1253 nLen, unlike the similar method of rtl_uString_new_WithLength which
1254 zeros out the buffer, and sets the length to 0. So should be somewhat
1255 more efficient for allocating a new string.
1257 call rtl_uString_release to release the string
1258 alternatively pass ownership to an OUString with
1259 rtl::OUString(newStr, SAL_NO_ACQUIRE);
1261 @param[in] nLen the number of characters. Must be >= 0.
1263 @return pointer to the new string.
1265 @since LibreOffice 4.1
1267 SAL_DLLPUBLIC rtl_uString * SAL_CALL rtl_uString_alloc(sal_Int32 nLen) SAL_THROW_EXTERN_C();
1269 /** Allocate a new string containing space for a given number of characters.
1271 If len is greater than zero, the reference count of the new string will be
1272 1. The values of all characters are set to 0 and the length of the string
1273 is 0. This function does not handle out-of-memory conditions.
1275 @param newStr
1276 pointer to the new string. The pointed-to data must be null or a valid
1277 string.
1279 @param nLen
1280 the number of characters.
1282 SAL_DLLPUBLIC void SAL_CALL rtl_uString_new_WithLength(
1283 rtl_uString ** newStr, sal_Int32 nLen ) SAL_THROW_EXTERN_C();
1285 /** Allocate a new string that contains a copy of another string.
1287 If the length of value is greater than zero, the reference count of the
1288 new string will be 1. This function does not handle out-of-memory
1289 conditions.
1291 @param newStr
1292 pointer to the new string. The pointed-to data must be null or a valid
1293 string.
1295 @param value
1296 a valid string.
1298 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromString(
1299 rtl_uString ** newStr, const rtl_uString * value ) SAL_THROW_EXTERN_C();
1301 /** Allocate a new string that contains a copy of a character array.
1303 If the length of value is greater than zero, the reference count of the
1304 new string will be 1. This function does not handle out-of-memory
1305 conditions.
1307 @param newStr
1308 pointer to the new string. The pointed-to data must be null or a valid
1309 string.
1311 @param value
1312 a null-terminated character array.
1314 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromStr(
1315 rtl_uString ** newStr, const sal_Unicode * value ) SAL_THROW_EXTERN_C();
1317 /** Allocate a new string that contains a copy of a character array.
1319 If the length of value is greater than zero, the reference count of the
1320 new string will be 1. This function does not handle out-of-memory
1321 conditions.
1323 @param newStr
1324 pointer to the new string. The pointed-to data must be null or a valid
1325 string.
1327 @param value
1328 a character array. Need not be null-terminated, but must be at least as
1329 long as the specified len.
1331 @param len
1332 the length of the character array.
1334 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromStr_WithLength(
1335 rtl_uString ** newStr, const sal_Unicode * value, sal_Int32 len ) SAL_THROW_EXTERN_C();
1337 /** Allocate a new string that is a substring of this string.
1339 The substring begins at the specified beginIndex and contains count
1340 characters. Meaningless combinations such as negative beginIndex,
1341 or beginIndex + count greater than the length of the string have
1342 undefined behaviour.
1344 @param[out] newStr the specified substring.
1345 @param[in] from the String to take the substring from.
1346 @param[in] beginIndex the beginning index, inclusive.
1347 @param[in] count the number of characters.
1349 @since LibreOffice 4.0
1351 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromSubString(
1352 rtl_uString ** newStr, const rtl_uString * from,
1353 sal_Int32 beginIndex, sal_Int32 count ) SAL_THROW_EXTERN_C();
1355 /** Allocate a new string that contains a copy of a character array.
1357 If the length of value is greater than zero, the reference count of the
1358 new string will be 1. This function does not handle out-of-memory
1359 conditions.
1361 Since this function is optimized for performance, the ASCII character
1362 values are not converted in any way. The caller has to make sure that
1363 all ASCII characters are in the allowed range of 0 and 127, inclusive.
1365 @param newStr
1366 pointer to the new string. The pointed-to data must be null or a valid
1367 string.
1369 @param value
1370 a null-terminated ASCII character array.
1372 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromAscii(
1373 rtl_uString ** newStr, const char * value ) SAL_THROW_EXTERN_C();
1376 @internal
1377 @since LibreOffice 3.6
1379 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromLiteral(
1380 rtl_uString ** newStr, const char * value, sal_Int32 len,
1381 sal_Int32 allocExtra ) SAL_THROW_EXTERN_C();
1383 /** Allocate a new string from an array of Unicode code points.
1385 @param newString
1386 a non-null pointer to a (possibly null) rtl_uString pointer, which (if
1387 non-null) will have been passed to rtl_uString_release before the function
1388 returns. Upon return, points to the newly allocated string or to null if
1389 there was either an out-of-memory condition or the resulting number of
1390 UTF-16 code units would have been larger than SAL_MAX_INT32. The newly
1391 allocated string (if any) must ultimately be passed to rtl_uString_release.
1393 @param codePoints
1394 an array of at least codePointCount code points, which each must be in the
1395 range from 0 to 0x10FFFF, inclusive. May be null if codePointCount is zero.
1397 @param codePointCount
1398 the non-negative number of code points.
1400 @since UDK 3.2.7
1402 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newFromCodePoints(
1403 rtl_uString ** newString, sal_uInt32 const * codePoints,
1404 sal_Int32 codePointCount) SAL_THROW_EXTERN_C();
1406 /** Assign a new value to a string.
1408 First releases any value str might currently hold, then acquires
1409 rightValue.
1411 @param str
1412 pointer to the string. The pointed-to data must be null or a valid
1413 string.
1415 @param rightValue
1416 a valid string.
1418 SAL_DLLPUBLIC void SAL_CALL rtl_uString_assign(
1419 rtl_uString ** str, rtl_uString * rightValue ) SAL_THROW_EXTERN_C();
1421 /** Return the length of a string.
1423 The length is equal to the number of characters in the string.
1425 @param str
1426 a valid string.
1428 @return
1429 the length of the string.
1431 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_uString_getLength(
1432 const rtl_uString * str ) SAL_THROW_EXTERN_C();
1434 /** Return a pointer to the underlying character array of a string.
1436 @param str
1437 a valid string.
1439 @return
1440 a pointer to the null-terminated character array.
1442 SAL_DLLPUBLIC sal_Unicode * SAL_CALL rtl_uString_getStr(
1443 rtl_uString * str ) SAL_THROW_EXTERN_C();
1445 /** Create a new string that is the concatenation of two other strings.
1447 The new string does not necessarily have a reference count of 1 (in cases
1448 where one of the two other strings is empty), so it must not be modified
1449 without checking the reference count. This function does not handle
1450 out-of-memory conditions.
1452 @param newStr
1453 pointer to the new string. The pointed-to data must be null or a valid
1454 string.
1456 @param left
1457 a valid string.
1459 @param right
1460 a valid string.
1462 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newConcat(
1463 rtl_uString ** newStr, rtl_uString * left, rtl_uString * right ) SAL_THROW_EXTERN_C();
1465 /** Create a new string that is the concatenation of two other strings.
1467 The new string does not necessarily have a reference count of 1 (in cases
1468 where the ASCII string is empty), so it must not be modified without
1469 checking the reference count.
1471 @param newString
1472 pointer to the new string. The pointed-to data must be null or a valid
1473 string.
1475 @param left
1476 a valid string.
1478 @param right must not be null and must point to memory of at least
1479 \p rightLength ASCII bytes
1481 @param rightLength the length of the \p right string; must be non-negative
1483 @since LibreOffice 5.1
1485 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newConcatAsciiL(
1486 rtl_uString ** newString, rtl_uString * left, char const * right,
1487 sal_Int32 rightLength);
1489 /** Create a new string that is the concatenation of two other strings.
1491 The new string does not necessarily have a reference count of 1 (in cases
1492 where the UTF-16 string is empty), so it must not be modified without
1493 checking the reference count.
1495 @param newString pointer to the new string. The pointed-to data must be null
1496 or a valid string.
1498 @param left a valid string.
1500 @param right must point to memory of at least \p rightLength UTF-16 code units; may be null if
1501 \p rigthLength is zero
1503 @param rightLength the length of the \p right string; must be non-negative
1505 @since LibreOffice 5.3
1507 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newConcatUtf16L(
1508 rtl_uString ** newString, rtl_uString * left, sal_Unicode const * right,
1509 sal_Int32 rightLength);
1511 /** Create a new string by replacing a substring of another string.
1513 The new string results from replacing a number of characters (count),
1514 starting at the specified position (index) in the original string (str),
1515 with some new substring (subStr). If subStr is null, then only a number
1516 of characters is deleted.
1518 The new string does not necessarily have a reference count of 1, so it
1519 must not be modified without checking the reference count. This function
1520 does not handle out-of-memory conditions.
1522 @param newStr
1523 pointer to the new string. The pointed-to data must be null or a valid
1524 string.
1526 @param str
1527 a valid string.
1529 @param idx
1530 the index into str at which to start replacement. Must be between 0 and
1531 the length of str, inclusive.
1533 @param count
1534 the number of characters to remove. Must not be negative, and the sum of
1535 index and count must not exceed the length of str.
1537 @param subStr
1538 either null or a valid string to be inserted.
1540 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceStrAt(
1541 rtl_uString ** newStr, rtl_uString * str, sal_Int32 idx, sal_Int32 count, rtl_uString * subStr ) SAL_THROW_EXTERN_C();
1543 #ifdef LIBO_INTERNAL_ONLY
1544 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceStrAtUtf16L(
1545 rtl_uString ** newStr, rtl_uString * str, sal_Int32 idx, sal_Int32 count, sal_Unicode const * subStr, sal_Int32 substrLen ) SAL_THROW_EXTERN_C();
1546 #endif
1548 /** Create a new string by replacing all occurrences of a single character
1549 within another string.
1551 The new string results from replacing all occurrences of oldChar in str
1552 with newChar.
1554 The new string does not necessarily have a reference count of 1 (in cases
1555 where oldChar does not occur in str), so it must not be modified without
1556 checking the reference count. This function does not handle out-of-memory
1557 conditions.
1559 @param newStr
1560 pointer to the new string. The pointed-to data must be null or a valid
1561 string.
1563 @param str
1564 a valid string.
1566 @param oldChar
1567 the old character.
1569 @param newChar
1570 the new character.
1572 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplace(
1573 rtl_uString ** newStr, rtl_uString * str, sal_Unicode oldChar, sal_Unicode newChar ) SAL_THROW_EXTERN_C();
1575 /** Create a new string by replacing the first occurrence of a given substring
1576 with another substring.
1578 @param[in, out] newStr pointer to the new string; must not be null; must
1579 point to null or a valid rtl_uString
1581 @param str pointer to the original string; must not be null
1583 @param from pointer to the substring to be replaced; must not be null
1585 @param to pointer to the replacing substring; must not be null
1587 @param[in,out] index pointer to a start index, must not be null; upon entry
1588 to the function its value is the index into the original string at which to
1589 start searching for the \p from substring, the value must be non-negative
1590 and not greater than the original string's length; upon exit from the
1591 function its value is the index into the original string at which the
1592 replacement took place or -1 if no replacement took place
1594 @since LibreOffice 3.6
1596 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceFirst(
1597 rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from,
1598 rtl_uString const * to, sal_Int32 * index) SAL_THROW_EXTERN_C();
1600 /** Create a new string by replacing the first occurrence of a given substring
1601 with another substring.
1603 @param[in, out] newStr pointer to the new string; must not be null; must
1604 point to null or a valid rtl_uString
1606 @param str pointer to the original string; must not be null
1608 @param from pointer to the substring to be replaced; must not be null and
1609 must point to memory of at least \p fromLength ASCII bytes
1611 @param fromLength the length of the \p from substring; must be non-negative
1613 @param to pointer to the replacing substring; must not be null
1615 @param[in,out] index pointer to a start index, must not be null; upon entry
1616 to the function its value is the index into the original string at which to
1617 start searching for the \p from substring, the value must be non-negative
1618 and not greater than the original string's length; upon exit from the
1619 function its value is the index into the original string at which the
1620 replacement took place or -1 if no replacement took place
1622 @since LibreOffice 3.6
1624 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceFirstAsciiL(
1625 rtl_uString ** newStr, rtl_uString * str, char const * from,
1626 sal_Int32 fromLength, rtl_uString const * to, sal_Int32 * index)
1627 SAL_THROW_EXTERN_C();
1629 /** Create a new string by replacing the first occurrence of a given substring
1630 with another substring.
1632 @param[in, out] newStr pointer to the new string; must not be null; must
1633 point to null or a valid rtl_uString
1635 @param str pointer to the original string; must not be null
1637 @param from pointer to the substring to be replaced; must not be null
1639 @param to pointer to the replacing substring; must not be null and must
1640 point to memory of at least \p toLength ASCII bytes
1642 @param toLength the length of the \p to substring; must be non-negative
1644 @param[in,out] index pointer to a start index, must not be null; upon entry
1645 to the function its value is the index into the original string at which to
1646 start searching for the \p from substring, the value must be non-negative
1647 and not greater than the original string's length; upon exit from the
1648 function its value is the index into the original string at which the
1649 replacement took place or -1 if no replacement took place
1651 @since LibreOffice 5.1
1653 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceFirstToAsciiL(
1654 rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from,
1655 char const * to, sal_Int32 toLength, sal_Int32 * index)
1656 SAL_THROW_EXTERN_C();
1658 /** Create a new string by replacing the first occurrence of a given substring
1659 with another substring.
1661 @param[in, out] newStr pointer to the new string; must not be null; must
1662 point to null or a valid rtl_uString
1664 @param str pointer to the original string; must not be null
1666 @param from pointer to the substring to be replaced; must not be null and
1667 must point to memory of at least \p fromLength ASCII bytes
1669 @param fromLength the length of the \p from substring; must be non-negative
1671 @param to pointer to the substring to be replaced; must not be null and
1672 must point to memory of at least \p toLength ASCII bytes
1674 @param toLength the length of the \p to substring; must be non-negative
1676 @param[in,out] index pointer to a start index, must not be null; upon entry
1677 to the function its value is the index into the original string at which to
1678 start searching for the \p from substring, the value must be non-negative
1679 and not greater than the original string's length; upon exit from the
1680 function its value is the index into the original string at which the
1681 replacement took place or -1 if no replacement took place
1683 @since LibreOffice 3.6
1685 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceFirstAsciiLAsciiL(
1686 rtl_uString ** newStr, rtl_uString * str, char const * from,
1687 sal_Int32 fromLength, char const * to, sal_Int32 toLength,
1688 sal_Int32 * index) SAL_THROW_EXTERN_C();
1690 /** Create a new string by replacing the first occurrence of a given substring
1691 with another substring.
1693 @param[in, out] newStr pointer to the new string; must not be null; must
1694 point to null or a valid rtl_uString; upon return, points to the newly
1695 allocated string or to null if there was either an out-of-memory condition
1696 or the resulting number of UTF-16 code units would have been larger than
1697 SAL_MAX_INT32
1699 @param str pointer to the original string; must not be null
1701 @param from pointer to the substring to be replaced; must not be null and
1702 must point to memory of at least \p fromLength ASCII bytes
1704 @param fromLength the length of the \p from substring; must be non-negative
1706 @param to pointer to the substring to be replaced; must not be null and
1707 must point to memory of at least \p toLength UTF-16 code units
1709 @param toLength the length of the \p to substring; must be non-negative
1711 @param[in,out] index pointer to a start index, must not be null; upon entry
1712 to the function its value is the index into the original string at which to
1713 start searching for the \p from substring, the value must be non-negative
1714 and not greater than the original string's length; upon exit from the
1715 function its value is the index into the original string at which the
1716 replacement took place (or would have taken place if \p newStr points to
1717 null upon return) or -1 if no replacement took place
1719 @since LibreOffice 5.3
1721 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceFirstAsciiLUtf16L(
1722 rtl_uString ** newStr, rtl_uString * str, char const * from,
1723 sal_Int32 fromLength, sal_Unicode const * to, sal_Int32 toLength,
1724 sal_Int32 * index) SAL_THROW_EXTERN_C();
1726 /** Create a new string by replacing the first occurrence of a given substring
1727 with another substring.
1729 @param[in, out] newStr pointer to the new string; must not be null; must
1730 point to null or a valid rtl_uString; upon return, points to the newly
1731 allocated string or to null if there was either an out-of-memory condition
1732 or the resulting number of UTF-16 code units would have been larger than
1733 SAL_MAX_INT32
1735 @param str pointer to the original string; must not be null
1737 @param from pointer to the substring to be replaced; must not be null and
1738 must point to memory of at least \p fromLength UTF-16 code units
1740 @param fromLength the length of the \p from substring; must be non-negative
1742 @param to pointer to the substring to be replaced; must not be null and
1743 must point to memory of at least \p toLength ASCII bytes
1745 @param toLength the length of the \p to substring; must be non-negative
1747 @param[in,out] index pointer to a start index, must not be null; upon entry
1748 to the function its value is the index into the original string at which to
1749 start searching for the \p from substring, the value must be non-negative
1750 and not greater than the original string's length; upon exit from the
1751 function its value is the index into the original string at which the
1752 replacement took place (or would have taken place if \p newStr points to
1753 null upon return) or -1 if no replacement took place
1755 @since LibreOffice 5.3
1757 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceFirstUtf16LAsciiL(
1758 rtl_uString ** newStr, rtl_uString * str, sal_Unicode const * from,
1759 sal_Int32 fromLength, char const * to, sal_Int32 toLength,
1760 sal_Int32 * index) SAL_THROW_EXTERN_C();
1762 /** Create a new string by replacing the first occurrence of a given substring
1763 with another substring.
1765 @param[in, out] newStr pointer to the new string; must not be null; must
1766 point to null or a valid rtl_uString; upon return, points to the newly
1767 allocated string or to null if there was either an out-of-memory condition
1768 or the resulting number of UTF-16 code units would have been larger than
1769 SAL_MAX_INT32
1771 @param str pointer to the original string; must not be null
1773 @param from pointer to the substring to be replaced; must point to memory of at least
1774 \p fromLength UTF-16 code units; may be null if \p toLength is zero
1776 @param fromLength the length of the \p from substring; must be non-negative
1778 @param to pointer to the substring to be replaced; must point to memory of at least \p toLength
1779 UTF-16 code units; may be null if \p toLength is zero
1781 @param toLength the length of the \p to substring; must be non-negative
1783 @param[in,out] index pointer to a start index, must not be null; upon entry
1784 to the function its value is the index into the original string at which to
1785 start searching for the \p from substring, the value must be non-negative
1786 and not greater than the original string's length; upon exit from the
1787 function its value is the index into the original string at which the
1788 replacement took place (or would have taken place if \p newStr points to
1789 null upon return) or -1 if no replacement took place
1791 @since LibreOffice 5.3
1793 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceFirstUtf16LUtf16L(
1794 rtl_uString ** newStr, rtl_uString * str, sal_Unicode const * from,
1795 sal_Int32 fromLength, sal_Unicode const * to, sal_Int32 toLength,
1796 sal_Int32 * index) SAL_THROW_EXTERN_C();
1798 /** Create a new string by replacing all occurrences of a given substring with
1799 another substring.
1801 Replacing subsequent occurrences picks up only after a given replacement.
1802 That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
1804 @param[in, out] newStr pointer to the new string; must not be null; must
1805 point to null or a valid rtl_uString
1807 @param str pointer to the original string; must not be null
1809 @param from pointer to the substring to be replaced; must not be null
1811 @param to pointer to the replacing substring; must not be null
1813 @since LibreOffice 3.6
1815 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceAll(
1816 rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from,
1817 rtl_uString const * to) SAL_THROW_EXTERN_C();
1819 /** Create a new string by replacing all occurrences of a given substring with
1820 another substring.
1822 Replacing subsequent occurrences picks up only after a given replacement.
1823 That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
1825 @param[in, out] newStr pointer to the new string; must not be null; must
1826 point to null or a valid rtl_uString
1828 @param str pointer to the original string; must not be null
1830 @param from pointer to the substring to be replaced; must not be null
1832 @param to pointer to the replacing substring; must not be null
1834 @param fromIndex the position in the string where we will begin searching
1836 @since LibreOffice 4.0
1838 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceAllFromIndex(
1839 rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from,
1840 rtl_uString const * to, sal_Int32 fromIndex) SAL_THROW_EXTERN_C();
1842 /** Create a new string by replacing all occurrences of a given substring with
1843 another substring.
1845 Replacing subsequent occurrences picks up only after a given replacement.
1846 That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
1848 @param[in, out] newStr pointer to the new string; must not be null; must
1849 point to null or a valid rtl_uString
1851 @param str pointer to the original string; must not be null
1853 @param from pointer to the substring to be replaced; must not be null and
1854 must point to memory of at least \p fromLength ASCII bytes
1856 @param fromLength the length of the \p from substring; must be non-negative
1858 @param to pointer to the replacing substring; must not be null
1860 @since LibreOffice 3.6
1862 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceAllAsciiL(
1863 rtl_uString ** newStr, rtl_uString * str, char const * from,
1864 sal_Int32 fromLength, rtl_uString const * to) SAL_THROW_EXTERN_C();
1866 /** Create a new string by replacing all occurrences of a given substring with
1867 another substring.
1869 Replacing subsequent occurrences picks up only after a given replacement.
1870 That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
1872 @param[in, out] newStr pointer to the new string; must not be null; must
1873 point to null or a valid rtl_uString
1875 @param str pointer to the original string; must not be null
1877 @param from pointer to the substring to be replaced; must not be null
1879 @param to pointer to the replacing substring; must not be null and must
1880 point to memory of at least \p toLength ASCII bytes
1882 @param toLength the length of the \p to substring; must be non-negative
1884 @since LibreOffice 5.1
1886 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceAllToAsciiL(
1887 rtl_uString ** newStr, rtl_uString * str, rtl_uString const * from,
1888 char const * to, sal_Int32 toLength) SAL_THROW_EXTERN_C();
1890 /** Create a new string by replacing all occurrences of a given substring with
1891 another substring.
1893 Replacing subsequent occurrences picks up only after a given replacement.
1894 That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
1896 @param[in, out] newStr pointer to the new string; must not be null; must
1897 point to null or a valid rtl_uString
1899 @param str pointer to the original string; must not be null
1901 @param from pointer to the substring to be replaced; must not be null and
1902 must point to memory of at least \p fromLength ASCII bytes
1904 @param fromLength the length of the \p from substring; must be non-negative
1906 @param to pointer to the substring to be replaced; must not be null and
1907 must point to memory of at least \p toLength ASCII bytes
1909 @param toLength the length of the \p to substring; must be non-negative
1911 @since LibreOffice 3.6
1913 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceAllAsciiLAsciiL(
1914 rtl_uString ** newStr, rtl_uString * str, char const * from,
1915 sal_Int32 fromLength, char const * to, sal_Int32 toLength)
1916 SAL_THROW_EXTERN_C();
1918 /** Create a new string by replacing all occurrences of a given substring with
1919 another substring.
1921 Replacing subsequent occurrences picks up only after a given replacement.
1922 That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
1924 @param[in, out] newStr pointer to the new string; must not be null; must
1925 point to null or a valid rtl_uString; upon return, points to the newly
1926 allocated string or to null if there was either an out-of-memory condition
1927 or the resulting number of UTF-16 code units would have been larger than
1928 SAL_MAX_INT32
1930 @param str pointer to the original string; must not be null
1932 @param from pointer to the substring to be replaced; must not be null and
1933 must point to memory of at least \p fromLength ASCII bytes
1935 @param fromLength the length of the \p from substring; must be non-negative
1937 @param to pointer to the substring to be replaced; must point to memory of at least \p toLength
1938 UTF-16 code units; may be null if \p toLength is zero
1940 @param toLength the length of the \p to substring; must be non-negative
1942 @since LibreOffice 3.6
1944 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceAllAsciiLUtf16L(
1945 rtl_uString ** newStr, rtl_uString * str, char const * from,
1946 sal_Int32 fromLength, sal_Unicode const * to, sal_Int32 toLength)
1947 SAL_THROW_EXTERN_C();
1949 /** Create a new string by replacing all occurrences of a given substring with
1950 another substring.
1952 Replacing subsequent occurrences picks up only after a given replacement.
1953 That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
1955 @param[in, out] newStr pointer to the new string; must not be null; must
1956 point to null or a valid rtl_uString; upon return, points to the newly
1957 allocated string or to null if there was either an out-of-memory condition
1958 or the resulting number of UTF-16 code units would have been larger than
1959 SAL_MAX_INT32
1961 @param str pointer to the original string; must not be null
1963 @param from pointer to the substring to be replaced; must not be null and
1964 must point to memory of at least \p fromLength UTF-16 code units
1966 @param fromLength the length of the \p from substring; must be non-negative
1968 @param to pointer to the substring to be replaced; must not be null and
1969 must point to memory of at least \p toLength ASCII bytes
1971 @param toLength the length of the \p to substring; must be non-negative
1973 @since LibreOffice 3.6
1975 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceAllUtf16LAsciiL(
1976 rtl_uString ** newStr, rtl_uString * str, sal_Unicode const * from,
1977 sal_Int32 fromLength, char const * to, sal_Int32 toLength)
1978 SAL_THROW_EXTERN_C();
1980 /** Create a new string by replacing all occurrences of a given substring with
1981 another substring.
1983 Replacing subsequent occurrences picks up only after a given replacement.
1984 That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
1986 @param[in, out] newStr pointer to the new string; must not be null; must
1987 point to null or a valid rtl_uString; upon return, points to the newly
1988 allocated string or to null if there was either an out-of-memory condition
1989 or the resulting number of UTF-16 code units would have been larger than
1990 SAL_MAX_INT32
1992 @param str pointer to the original string; must not be null
1994 @param from pointer to the substring to be replaced; must not be null and
1995 must point to memory of at least \p fromLength UTF-16 code units
1997 @param fromLength the length of the \p from substring; must be non-negative
1999 @param to pointer to the substring to be replaced; must not be null and
2000 must point to memory of at least \p toLength UTF-16 code units
2002 @param toLength the length of the \p to substring; must be non-negative
2004 @since LibreOffice 3.6
2006 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceAllUtf16LUtf16L(
2007 rtl_uString ** newStr, rtl_uString * str, sal_Unicode const * from,
2008 sal_Int32 fromLength, sal_Unicode const * to, sal_Int32 toLength)
2009 SAL_THROW_EXTERN_C();
2011 #if defined LIBO_INTERNAL_ONLY
2012 /** Create a new string by replacing all occurrences of a given substring with
2013 another substring.
2015 Replacing subsequent occurrences picks up only after a given replacement.
2016 That is, replacing from "xa" to "xx" in "xaa" results in "xxa", not "xxx".
2018 @param[in, out] newStr pointer to the new string; must not be null; must
2019 point to null or a valid rtl_uString; upon return, points to the newly
2020 allocated string or to null if there was either an out-of-memory condition
2021 or the resulting number of UTF-16 code units would have been larger than
2022 SAL_MAX_INT32
2024 @param str pointer to the original string; must not be null
2026 @param from pointer to the substring to be replaced; must not be null and
2027 must point to memory of at least \p fromLength UTF-16 code units
2029 @param fromLength the length of the \p from substring; must be non-negative
2031 @param to pointer to the substring to be replaced; must not be null and
2032 must point to memory of at least \p toLength UTF-16 code units
2034 @param toLength the length of the \p to substring; must be non-negative
2036 @param fromIndex the position in the string where we will begin searching
2038 @since LibreOffice 7.1
2040 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newReplaceAllFromIndexUtf16LUtf16L(
2041 rtl_uString ** newStr, rtl_uString * str, sal_Unicode const * from,
2042 sal_Int32 fromLength, sal_Unicode const * to, sal_Int32 toLength, sal_Int32 fromIndex)
2043 SAL_THROW_EXTERN_C();
2044 #endif
2046 /** Create a new string by converting all ASCII uppercase letters to lowercase
2047 within another string.
2049 The new string results from replacing all characters with values between
2050 65 and 90 (ASCII A--Z) by values between 97 and 122 (ASCII a--z).
2052 This function cannot be used for language-specific conversion. The new
2053 string does not necessarily have a reference count of 1 (in cases where
2054 no characters need to be converted), so it must not be modified without
2055 checking the reference count. This function does not handle out-of-memory
2056 conditions.
2058 @param newStr
2059 pointer to the new string. The pointed-to data must be null or a valid
2060 string.
2062 @param str
2063 a valid string.
2065 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newToAsciiLowerCase(
2066 rtl_uString ** newStr, rtl_uString * str ) SAL_THROW_EXTERN_C();
2068 /** Create a new string by converting all ASCII lowercase letters to uppercase
2069 within another string.
2071 The new string results from replacing all characters with values between
2072 97 and 122 (ASCII a--z) by values between 65 and 90 (ASCII A--Z).
2074 This function cannot be used for language-specific conversion. The new
2075 string does not necessarily have a reference count of 1 (in cases where
2076 no characters need to be converted), so it must not be modified without
2077 checking the reference count. This function does not handle out-of-memory
2078 conditions.
2080 @param newStr
2081 pointer to the new string. The pointed-to data must be null or a valid
2082 string.
2084 @param str
2085 a valid string.
2087 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newToAsciiUpperCase(
2088 rtl_uString ** newStr, rtl_uString * str ) SAL_THROW_EXTERN_C();
2090 /** Create a new string by removing white space from both ends of another
2091 string.
2093 The new string results from removing all characters with values less than
2094 or equal to 32 (the space character), and also Unicode General Punctuation
2095 area Space and some Control characters, form both ends of str (see
2096 implIsWhitespace).
2098 This function cannot be used for language-specific conversion. The new
2099 string does not necessarily have a reference count of 1 (in cases where
2100 no characters need to be removed), so it must not be modified without
2101 checking the reference count. This function does not handle out-of-memory
2102 conditions.
2104 @param newStr
2105 pointer to the new string. The pointed-to data must be null or a valid
2106 string.
2108 @param str
2109 a valid string.
2111 SAL_DLLPUBLIC void SAL_CALL rtl_uString_newTrim(
2112 rtl_uString ** newStr, rtl_uString * str ) SAL_THROW_EXTERN_C();
2114 /** Create a new string by extracting a single token from another string.
2116 Starting at index, the token's next token is searched for. If there is no
2117 such token, the result is an empty string. Otherwise, all characters from
2118 the start of that token and up to, but not including the next occurrence
2119 of cTok make up the resulting token. The return value is the position of
2120 the next token, or -1 if no more tokens follow.
2122 Example code could look like
2123 rtl_uString * pToken = NULL;
2124 sal_Int32 nIndex = 0;
2128 nIndex = rtl_uString_getToken(&pToken, pStr, 0, ';', nIndex);
2131 while (nIndex >= 0);
2133 The new string does not necessarily have a reference count of 1, so it
2134 must not be modified without checking the reference count. This function
2135 does not handle out-of-memory conditions.
2137 @param newStr
2138 pointer to the new string. The pointed-to data must be null or a valid
2139 string. If either token or index is negative, an empty token is stored in
2140 newStr (and -1 is returned).
2142 @param str
2143 a valid string.
2145 @param token
2146 the number of the token to return, starting at index.
2148 @param cTok
2149 the character that separates the tokens.
2151 @param idx
2152 the position at which searching for the token starts. Must not be greater
2153 than the length of str.
2155 @return
2156 the index of the next token, or -1 if no more tokens follow.
2158 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_uString_getToken(
2159 rtl_uString ** newStr , rtl_uString * str, sal_Int32 token, sal_Unicode cTok, sal_Int32 idx ) SAL_THROW_EXTERN_C();
2161 /* ======================================================================= */
2163 /** Supply an ASCII string literal together with its length and text encoding.
2165 This macro can be used to compute (some of) the arguments in function calls
2166 like rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foo")).
2168 @param constAsciiStr
2169 must be an expression of type "(possibly cv-qualified reference to) array of
2170 (possibly cv-qualified) char." Each element of the referenced array must
2171 represent an ASCII value in the range 0x00--0x7F. The last element of the
2172 referenced array is not considered part of the represented ASCII string, and
2173 its value should be 0x00. Depending on where this macro is used, the nature
2174 of the supplied expression might be further restricted.
2176 // The &foo[0] trick is intentional, it makes sure the type is char* or const char*
2177 // (plain cast to const char* would not work with non-const char foo[]="a", which seems to be allowed).
2178 // This is to avoid mistaken use with functions that accept string literals
2179 // (i.e. const char (&)[N]) where usage of this macro otherwise could match
2180 // the argument and a following int argument with a default value (e.g. OUString::match()).
2181 #define RTL_CONSTASCII_USTRINGPARAM( constAsciiStr ) (&(constAsciiStr)[0]), \
2182 ((sal_Int32)(SAL_N_ELEMENTS(constAsciiStr)-1)), RTL_TEXTENCODING_ASCII_US
2184 /* ======================================================================= */
2186 /* predefined constants for String-Conversion */
2187 #define OSTRING_TO_OUSTRING_CVTFLAGS (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MAPTOPRIVATE |\
2188 RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT |\
2189 RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT)
2191 /* ----------------------------------------------------------------------- */
2193 /** Create a new Unicode string by converting a byte string, using a specific
2194 text encoding.
2196 The lengths of the byte string and the Unicode string may differ (e.g.,
2197 for double-byte encodings, UTF-7, UTF-8).
2199 If the length of the byte string is greater than zero, the reference count
2200 of the new string will be 1.
2202 If an out-of-memory condition occurs, newStr will point to a null pointer
2203 upon return.
2205 @param newStr
2206 pointer to the new string. The pointed-to data must be null or a valid
2207 string.
2209 @param str
2210 a byte character array. Need not be null-terminated, but must be at
2211 least as long as the specified len.
2213 @param len
2214 the length of the byte character array.
2216 @param encoding
2217 the text encoding to use for conversion.
2219 @param convertFlags
2220 flags which control the conversion. Either use
2221 OSTRING_TO_OUSTRING_CVTFLAGS, or see
2222 <http://udk.openoffice.org/cpp/man/spec/textconversion.html> for more
2223 details.
2225 SAL_DLLPUBLIC void SAL_CALL rtl_string2UString(
2226 rtl_uString ** newStr, const char * str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags ) SAL_THROW_EXTERN_C();
2228 /* ======================================================================= */
2229 /* Interning methods */
2231 /** Return a canonical representation for a string.
2233 A pool of strings, initially empty is maintained privately
2234 by the string class. On invocation, if present in the pool
2235 the original string will be returned. Otherwise this string,
2236 or a copy thereof will be added to the pool and returned.
2238 @param newStr
2239 pointer to the new string. The pointed-to data must be null or a valid
2240 string.
2242 If an out-of-memory condition occurs, newStr will point to a null pointer
2243 upon return.
2245 @param str
2246 pointer to the string to be interned.
2248 @since UDK 3.2.7
2250 SAL_DLLPUBLIC void SAL_CALL rtl_uString_intern(
2251 rtl_uString ** newStr, rtl_uString * str) SAL_THROW_EXTERN_C();
2253 /** Return a canonical representation for a string.
2255 A pool of strings, initially empty is maintained privately
2256 by the string class. On invocation, if present in the pool
2257 the original string will be returned. Otherwise this string,
2258 or a copy thereof will be added to the pool and returned.
2260 @param newStr
2261 pointer to the new string. The pointed-to data must be null or a valid
2262 string.
2264 If an out-of-memory condition occurs, newStr will point to a null pointer
2265 upon return.
2267 @param str
2268 a byte character array. Need not be null-terminated, but must be at
2269 least as long as the specified len.
2271 @param len
2272 the length of the byte character array.
2274 @param encoding
2275 the text encoding to use for conversion.
2277 @param convertFlags
2278 flags which control the conversion. Either use
2279 OSTRING_TO_OUSTRING_CVTFLAGS, or see
2280 <http://udk.openoffice.org/cpp/man/spec/textconversion.html> for more
2281 details.
2283 @param pInfo
2284 pointer to return conversion status in, or NULL.
2286 @since UDK 3.2.7
2288 SAL_DLLPUBLIC void SAL_CALL rtl_uString_internConvert(
2289 rtl_uString ** newStr,
2290 const char * str,
2291 sal_Int32 len,
2292 rtl_TextEncoding encoding,
2293 sal_uInt32 convertFlags,
2294 sal_uInt32 *pInfo) SAL_THROW_EXTERN_C();
2296 /** Iterate through a string based on code points instead of UTF-16 code units.
2298 See Chapter 3 of The Unicode Standard 5.0 (Addison--Wesley, 2006) for
2299 definitions of the various terms used in this description.
2301 The given string is interpreted as a sequence of zero or more UTF-16 code
2302 units. For each index into this sequence (from zero to one less than the
2303 length of the sequence, inclusive), a code point represented starting at the
2304 given index is computed as follows:
2306 - If the UTF-16 code unit addressed by the index constitutes a well-formed
2307 UTF-16 code unit sequence, the computed code point is the scalar value
2308 encoded by that UTF-16 code unit sequence.
2310 - Otherwise, if the index is at least two UTF-16 code units away from the
2311 end of the sequence, and the sequence of two UTF-16 code units addressed by
2312 the index constitutes a well-formed UTF-16 code unit sequence, the computed
2313 code point is the scalar value encoded by that UTF-16 code unit sequence.
2315 - Otherwise, the computed code point is the UTF-16 code unit addressed by
2316 the index. (This last case catches unmatched surrogates as well as indices
2317 pointing into the middle of surrogate pairs.)
2319 @param string
2320 pointer to a valid string; must not be null.
2322 @param indexUtf16
2323 pointer to a UTF-16 based index into the given string; must not be null. On
2324 entry, the index must be in the range from zero to the length of the string
2325 (in UTF-16 code units), inclusive. Upon successful return, the index will
2326 be updated to address the UTF-16 code unit that is the given
2327 incrementCodePoints away from the initial index.
2329 @param incrementCodePoints
2330 the number of code points to move the given *indexUtf16. If non-negative,
2331 moving is done after determining the code point at the index. If negative,
2332 moving is done before determining the code point at the (then updated)
2333 index. The value must be such that the resulting UTF-16 based index is in
2334 the range from zero to the length of the string (in UTF-16 code units),
2335 inclusive.
2337 @return
2338 the code point (an integer in the range from 0 to 0x10FFFF, inclusive) that
2339 is represented within the string starting at the index computed as follows:
2340 If incrementCodePoints is non-negative, the index is the initial value of
2341 *indexUtf16; if incrementCodePoints is negative, the index is the updated
2342 value of *indexUtf16. In either case, the computed index must be in the
2343 range from zero to one less than the length of the string (in UTF-16 code
2344 units), inclusive.
2346 @since UDK 3.2.7
2348 SAL_DLLPUBLIC sal_uInt32 SAL_CALL rtl_uString_iterateCodePoints(
2349 rtl_uString const * string, sal_Int32 * indexUtf16,
2350 sal_Int32 incrementCodePoints);
2352 /** Converts a byte string to a Unicode string, signalling failure.
2354 @param target
2355 An out parameter receiving the converted string. Must not be null itself,
2356 and must contain either null or a pointer to a valid rtl_uString; the
2357 contents are unspecified if conversion fails (rtl_convertStringToUString
2358 returns false).
2360 @param source
2361 The byte string. May only be null if length is zero.
2363 @param length
2364 The length of the byte string. Must be non-negative.
2366 @param encoding
2367 The text encoding to convert from. Must be an octet encoding (i.e.,
2368 rtl_isOctetTextEncoding(encoding) must return true).
2370 @param flags
2371 A combination of RTL_TEXTTOUNICODE_FLAGS that detail how to do the
2372 conversion (see rtl_convertTextToUnicode). RTL_TEXTTOUNICODE_FLAGS_FLUSH
2373 need not be included, it is implicitly assumed. Typical uses are either
2374 RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
2375 RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
2376 RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR (fail if a byte or multi-byte sequence
2377 cannot be converted from the source encoding) or
2378 OSTRING_TO_OUSTRING_CVTFLAGS (make a best efforts conversion).
2380 @return
2381 True if the conversion succeeded, false otherwise.
2383 @since UDK 3.2.9
2385 SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_convertStringToUString(
2386 rtl_uString ** target, char const * source, sal_Int32 length,
2387 rtl_TextEncoding encoding, sal_uInt32 flags) SAL_THROW_EXTERN_C();
2389 /** Ensure a string has enough space for a given number of characters.
2391 If the given string is large enough and has refcount of 1, it is not altered in any way.
2392 Otherwise it is replaced by a copy that has enough space for the given number of characters,
2393 data from the source string is copied to the beginning of it, the content of the remaining
2394 capacity undefined, the string has refcount of 1, and refcount of the original string is decreased.
2396 @param str
2397 pointer to the string. The pointed-to data must be a valid string.
2399 @param size
2400 the number of characters
2402 @since LibreOffice 4.1
2403 @internal
2405 SAL_DLLPUBLIC void SAL_CALL rtl_uString_ensureCapacity( rtl_uString ** str, sal_Int32 size ) SAL_THROW_EXTERN_C();
2407 #ifdef __cplusplus
2409 #endif
2411 #endif // INCLUDED_RTL_USTRING_H
2413 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */