xref: /aoo42x/main/sal/inc/rtl/ustring.h (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _RTL_USTRING_H_
29 #define _RTL_USTRING_H_
30 
31 #include <sal/types.h>
32 #include <osl/interlck.h>
33 #include <rtl/string.h>
34 #include <rtl/textenc.h>
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /* ======================================================================= */
41 
42 /** Return the length of a string.
43 
44     The length is equal to the number of 16-bit Unicode characters in the
45     string, without the terminating NUL character.
46 
47     @param str
48     a null-terminated string.
49 
50     @return
51     the length of the sequence of characters represented by this string,
52     excluding the terminating NUL character.
53  */
54 sal_Int32 SAL_CALL rtl_ustr_getLength( const sal_Unicode * str ) SAL_THROW_EXTERN_C();
55 
56 /** Compare two strings.
57 
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.
62 
63     @param first
64     the first null-terminated string to be compared.
65 
66     @param second
67     the second null-terminated string which is compared with the first one.
68 
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.
73  */
74 sal_Int32 SAL_CALL rtl_ustr_compare( const sal_Unicode * first, const sal_Unicode * second ) SAL_THROW_EXTERN_C();
75 
76 /** Compare two strings.
77 
78     The comparison is based on the numeric value of each character in the
79     strings and returns a value indicating their relationship.  This function
80     cannot be used for language-specific sorting.
81 
82     @param first
83     the first string to be compared.  Need not be null-terminated, but must be
84     at least as long as the specified firstLen.
85 
86     @param firstLen
87     the length of the first string.
88 
89     @param second
90     the second string which is compared with the first one.  Need not be
91     null-terminated, but must be at least as long as the specified secondLen.
92 
93     @param secondLen
94     the length of the second string.
95 
96     @return
97     0 if both strings are equal, a value less than 0 if the first string is
98     less than the second string, and a value greater than 0 if the first
99     string is greater than the second string.
100  */
101 sal_Int32 SAL_CALL rtl_ustr_compare_WithLength( const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
102 
103 /** Compare two strings with a maximum count of characters.
104 
105     The comparison is based on the numeric value of each character in the
106     strings and returns a value indicating their relationship.  This function
107     cannot be used for language-specific sorting.
108 
109     @param first
110     the first string to be compared.  Need not be null-terminated, but must be
111     at least as long as the specified firstLen.
112 
113     @param firstLen
114     the length of the first string.
115 
116     @param second
117     the second string which is compared with the first one.  Need not be
118     null-terminated, but must be at least as long as the specified secondLen.
119 
120     @param secondLen
121     the length of the second string.
122 
123     @param shortenedLen
124     the maximum number of characters to compare.  This length can be greater
125     or smaller than the lengths of the two strings.
126 
127     @return
128     0 if both substrings are equal, a value less than 0 if the first substring
129     is less than the second substring, and a value greater than 0 if the first
130     substring is greater than the second substring.
131  */
132 sal_Int32 SAL_CALL rtl_ustr_shortenedCompare_WithLength( const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
133 
134 /** Compare two strings from back to front.
135 
136     The comparison is based on the numeric value of each character in the
137     strings and returns a value indicating their relationship.  This function
138     cannot be used for language-specific sorting.
139 
140     @param first
141     the first string to be compared.  Need not be null-terminated, but must be
142     at least as long as the specified firstLen.
143 
144     @param firstLen
145     the length of the first string.
146 
147     @param second
148     the second string which is compared with the first one.  Need not be
149     null-terminated, but must be at least as long as the specified secondLen.
150 
151     @param secondLen
152     the length of the second string.
153 
154     @return
155     0 if both strings are equal, a value less than 0 if the first string
156     compares less than the second string, and a value greater than 0 if the
157     first string compares greater than the second string.
158  */
159 sal_Int32 SAL_CALL rtl_ustr_reverseCompare_WithLength( const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
160 
161 /** Compare two strings from back to front for equality.
162 
163     The comparison is based on the numeric value of each character in the
164     strings and returns 'true' if, ans only if, both strings are equal.
165 	This function cannot be used for language-specific sorting.
166 
167     @param first
168     the first string to be compared.  Need not be null-terminated, but must be
169     at least as long as the specified len.
170 
171     @param second
172     the second string which is compared with the first one.  Need not be
173     null-terminated, but must be at least as long as the specified len.
174 
175     @param len
176     the length of both strings.
177 
178     @return
179     true if both strings are equal, false if they are not equal.
180  */
181 
182 sal_Bool SAL_CALL rtl_ustr_asciil_reverseEquals_WithLength( const sal_Unicode * first, const sal_Char * second, sal_Int32 len ) SAL_THROW_EXTERN_C();
183 
184 /** Compare two strings, ignoring the case of ASCII characters.
185 
186     The comparison is based on the numeric value of each character in the
187     strings and returns a value indicating their relationship.  Character
188     values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
189     and 122 (ASCII a--z).  This function cannot be used for language-specific
190     sorting.  Both strings must be null-terminated.
191 
192     @param first
193     the first null-terminated string to be compared.
194 
195     @param second
196     the second null-terminated string which is compared with the first one.
197 
198     @return
199     0 if both strings are equal, a value less than 0 if the first string is
200     less than the second string, and a value greater than 0 if the first
201     string is greater than the second string.
202  */
203 sal_Int32 SAL_CALL rtl_ustr_compareIgnoreAsciiCase( const sal_Unicode * first, const sal_Unicode * second ) SAL_THROW_EXTERN_C();
204 
205 /** Compare two strings, ignoring the case of ASCII characters.
206 
207     The comparison is based on the numeric value of each character in the
208     strings and returns a value indicating their relationship.  Character
209     values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
210     and 122 (ASCII a--z).  This function cannot be used for language-specific
211     sorting.
212 
213     @param first
214     the first string to be compared.  Need not be null-terminated, but must be
215     at least as long as the specified firstLen.
216 
217     @param firstLen
218     the length of the first string.
219 
220     @param second
221     the second string which is compared with the first one.  Need not be
222     null-terminated, but must be at least as long as the specified secondLen.
223 
224     @param secondLen
225     the length of the second string.
226 
227     @return
228     0 if both strings are equal, a value less than 0 if the first string is
229     less than the second string, and a value greater than 0 if the first
230     string is greater than the second string.
231  */
232 sal_Int32 SAL_CALL rtl_ustr_compareIgnoreAsciiCase_WithLength( const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
233 
234 /** Compare two strings with a maximum count of characters, ignoring the case
235     of ASCII characters.
236 
237     The comparison is based on the numeric value of each character in the
238     strings and returns a value indicating their relationship.  Character
239     values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
240     and 122 (ASCII a--z).  This function cannot be used for language-specific
241     sorting.
242 
243     @param first
244     the first string to be compared.  Need not be null-terminated, but must be
245     at least as long as the specified firstLen.
246 
247     @param firstLen
248     the length of the first string.
249 
250     @param second
251     the second string which is compared with the first one.  Need not be
252     null-terminated, but must be at least as long as the specified secondLen.
253 
254     @param secondLen
255     the length of the second string.
256 
257     @param shortenedLen
258     the maximum number of characters to compare.  This length can be greater
259     or smaller than the lengths of the two strings.
260 
261     @return
262     0 if both substrings are equal, a value less than 0 if the first substring
263     is less than the second substring, and a value greater than 0 if the first
264     substring is greater than the second substring.
265  */
266 sal_Int32 SAL_CALL rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
267 
268 /** Compare two strings.
269 
270     The comparison is based on the numeric value of each character in the
271     strings and returns a value indicating their relationship.  This function
272     cannot be used for language-specific sorting.  Both strings must be
273     null-terminated.
274 
275     Since this function is optimized for performance, the ASCII character
276     values are not converted in any way.  The caller has to make sure that
277     all ASCII characters are in the allowed range of 0 and 127, inclusive.
278 
279     @param first
280     the first null-terminated string to be compared.
281 
282     @param second
283     the second null-terminated ASCII string which is compared with the first
284     one.
285 
286     @return
287     0 if both substrings are equal, a value less than 0 if the first substring
288     is less than the second substring, and a value greater than 0 if the first
289     substring is greater than the second substring.
290  */
291 sal_Int32 SAL_CALL rtl_ustr_ascii_compare( const sal_Unicode * first, const sal_Char * second ) SAL_THROW_EXTERN_C();
292 
293 /** Compare two strings.
294 
295     The comparison is based on the numeric value of each character in the
296     strings and returns a value indicating their relationship.  This function
297     cannot be used for language-specific sorting.
298 
299     Since this function is optimized for performance, the ASCII character
300     values are not converted in any way.  The caller has to make sure that
301     all ASCII characters are in the allowed range of 0 and 127, inclusive.
302 
303     @param first
304     the first string to be compared.  Need not be null-terminated, but must be
305     at least as long as the specified firstLen.
306 
307     @param firstLen
308     the length of the first string.
309 
310     @param second
311     the second null-terminated ASCII string which is compared with the first
312     one.
313 
314     @return
315     0 if both substrings are equal, a value less than 0 if the first substring
316     is less than the second substring, and a value greater than 0 if the first
317     substring is greater than the second substring.
318  */
319 sal_Int32 SAL_CALL rtl_ustr_ascii_compare_WithLength( const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second ) SAL_THROW_EXTERN_C();
320 
321 /** Compare two strings with a maximum count of characters.
322 
323     The comparison is based on the numeric value of each character in the
324     strings and returns a value indicating their relationship.  This function
325     cannot be used for language-specific sorting.
326 
327     Since this function is optimized for performance, the ASCII character
328     values are not converted in any way.  The caller has to make sure that
329     all ASCII characters are in the allowed range of 0 and 127, inclusive.
330 
331     @param first
332     the first string to be compared.  Need not be null-terminated, but must be
333     at least as long as the specified firstLen.
334 
335     @param firstLen
336     the length of the first string.
337 
338     @param second
339     the second null-terminated ASCII string which is compared with the first
340     one.
341 
342     @param shortenedLen
343     the maximum number of characters to compare.  This length can be greater
344     or smaller than the lengths of the two strings.
345 
346     @return
347     0 if both substrings are equal, a value less than 0 if the first substring
348     is less than the second substring, and a value greater than 0 if the first
349     substring is greater than the second substring.
350  */
351 sal_Int32 SAL_CALL rtl_ustr_ascii_shortenedCompare_WithLength( const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
352 
353 /** Compare two strings from back to front.
354 
355     The comparison is based on the numeric value of each character in the
356     strings and returns a value indicating their relationship.  This function
357     cannot be used for language-specific sorting.
358 
359     Since this function is optimized for performance, the ASCII character
360     values are not converted in any way.  The caller has to make sure that
361     all ASCII characters are in the allowed range of 0 and 127, inclusive.
362 
363     @param first
364     the first string to be compared.  Need not be null-terminated, but must be
365     at least as long as the specified firstLen.
366 
367     @param firstLen
368     the length of the first string.
369 
370     @param second
371     the second ASCII string which is compared with the first one.  Need not be
372     null-terminated, but must be at least as long as the specified secondLen.
373 
374     @param secondLen
375     the length of the second string.
376 
377     @return
378     0 if both strings are equal, a value less than 0 if the first string
379     compares less than the second string, and a value greater than 0 if the
380     first string compares greater than the second string.
381  */
382 sal_Int32 SAL_CALL rtl_ustr_asciil_reverseCompare_WithLength( const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
383 
384 /** Compare two strings, ignoring the case of ASCII characters.
385 
386     The comparison is based on the numeric value of each character in the
387     strings and returns a value indicating their relationship.  Character
388     values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
389     and 122 (ASCII a--z).  This function cannot be used for language-specific
390     sorting.  Both strings must be null-terminated.
391 
392     Since this function is optimized for performance, the ASCII character
393     values are not converted in any way.  The caller has to make sure that
394     all ASCII characters are in the allowed range of 0 and 127, inclusive.
395 
396     @param first
397     the first null-terminated string to be compared.
398 
399     @param second
400     the second null-terminated ASCII string which is compared with the first
401     one.
402 
403     @return
404     0 if both strings are equal, a value less than 0 if the first string is
405     less than the second string, and a value greater than 0 if the first
406     string is greater than the second string.
407  */
408 sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase( const sal_Unicode * first, const sal_Char * second ) SAL_THROW_EXTERN_C();
409 
410 /** Compare two strings, ignoring the case of ASCII characters.
411 
412     The comparison is based on the numeric value of each character in the
413     strings and returns a value indicating their relationship.  Character
414     values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
415     and 122 (ASCII a--z).  This function cannot be used for language-specific
416     sorting.
417 
418     Since this function is optimized for performance, the ASCII character
419     values are not converted in any way.  The caller has to make sure that
420     all ASCII characters are in the allowed range of 0 and 127, inclusive.
421 
422     @param first
423     the first string to be compared.  Need not be null-terminated, but must be
424     at least as long as the specified firstLen.
425 
426     @param firstLen
427     the length of the first string.
428 
429     @param second
430     the second null-terminated ASCII string which is compared with the first
431     one.
432 
433     @return
434     0 if both strings are equal, a value less than 0 if the first string is
435     less than the second string, and a value greater than 0 if the first
436     string is greater than the second string.
437  */
438 sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second ) SAL_THROW_EXTERN_C();
439 
440 /** Compare two strings, ignoring the case of ASCII characters.
441 
442     The comparison is based on the numeric value of each character in the
443     strings and returns a value indicating their relationship.  Character
444     values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
445     and 122 (ASCII a--z).  This function cannot be used for language-specific
446     sorting.
447 
448     Since this function is optimized for performance, the ASCII character
449     values are not converted in any way.  The caller has to make sure that
450     all ASCII characters are in the allowed range of 0 and 127, inclusive.
451 
452     @param first
453     the first string to be compared.  Need not be null-terminated, but must be
454     at least as long as the specified firstLen.
455 
456     @param firstLen
457     the length of the first string.
458 
459     @param second
460     the second string which is compared with the first one.  Need not be
461     null-terminated, but must be at least as long as the specified secondLen.
462 
463     @param secondLen
464     the length of the second string.
465 
466     @return
467     0 if both strings are equal, a value less than 0 if the first string is
468     less than the second string, and a value greater than 0 if the first
469     string is greater than the second string.
470  */
471 sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
472     sal_Unicode const * first, sal_Int32 firstLen,
473     char const * second, sal_Int32 secondLen) SAL_THROW_EXTERN_C();
474 
475 /** Compare two strings with a maximum count of characters, ignoring the case
476     of ASCII characters.
477 
478     The comparison is based on the numeric value of each character in the
479     strings and returns a value indicating their relationship.  Character
480     values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
481     and 122 (ASCII a--z).  This function cannot be used for language-specific
482     sorting.
483 
484     Since this function is optimized for performance, the ASCII character
485     values are not converted in any way.  The caller has to make sure that
486     all ASCII characters are in the allowed range of 0 and 127, inclusive.
487 
488     @param first
489     the first string to be compared.  Need not be null-terminated, but must be
490     at least as long as the specified firstLen.
491 
492     @param firstLen
493     the length of the first string.
494 
495     @param second
496     the second null-terminated ASCII string which is compared with the first
497     one.
498 
499     @param shortenedLen
500     the maximum number of characters to compare.  This length can be greater
501     or smaller than the lengths of the two strings.
502 
503     @return
504     0 if both substrings are equal, a value less than 0 if the first substring
505     is less than the second substring, and a value greater than 0 if the first
506     substring is greater than the second substring.
507  */
508 sal_Int32 SAL_CALL rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
509 
510 /** Return a hash code for a string.
511 
512     It is not allowed to store the hash code persistently, because later
513     versions could return other hash codes.  The string must be
514     null-terminated.
515 
516     @param str
517     a null-terminated string.
518 
519     @return
520     a hash code for the given string.
521  */
522 sal_Int32 SAL_CALL rtl_ustr_hashCode( const sal_Unicode * str ) SAL_THROW_EXTERN_C();
523 
524 /** Return a hash code for a string.
525 
526     It is not allowed to store the hash code persistently, because later
527     versions could return other hash codes.
528 
529     @param str
530     a string.  Need not be null-terminated, but must be at least as long as
531     the specified len.
532 
533     @param len
534     the length of the string.
535 
536     @return
537     a hash code for the given string.
538  */
539 sal_Int32 SAL_CALL rtl_ustr_hashCode_WithLength( const sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
540 
541 /** Search for the first occurrence of a character within a string.
542 
543     The string must be null-terminated.
544 
545     @param str
546     a null-terminated string.
547 
548     @param ch
549     the character to be searched for.
550 
551     @return
552     the index (starting at 0) of the first occurrence of the character in the
553     string, or -1 if the character does not occur.
554  */
555 sal_Int32 SAL_CALL rtl_ustr_indexOfChar( const sal_Unicode * str, sal_Unicode ch ) SAL_THROW_EXTERN_C();
556 
557 /** Search for the first occurrence of a character within a string.
558 
559     @param str
560     a string.  Need not be null-terminated, but must be at least as long as
561     the specified len.
562 
563     @param len
564     the length of the string.
565 
566     @param ch
567     the character to be searched for.
568 
569     @return
570     the index (starting at 0) of the first occurrence of the character in the
571     string, or -1 if the character does not occur.
572  */
573 sal_Int32 SAL_CALL rtl_ustr_indexOfChar_WithLength( const sal_Unicode * str, sal_Int32 len, sal_Unicode ch ) SAL_THROW_EXTERN_C();
574 
575 /** Search for the last occurrence of a character within a string.
576 
577     The string must be null-terminated.
578 
579     @param str
580     a null-terminated string.
581 
582     @param ch
583     the character to be searched for.
584 
585     @return
586     the index (starting at 0) of the last occurrence of the character in the
587     string, or -1 if the character does not occur.  The returned value is
588     always smaller than the string length.
589  */
590 sal_Int32 SAL_CALL rtl_ustr_lastIndexOfChar( const sal_Unicode * str, sal_Unicode ch ) SAL_THROW_EXTERN_C();
591 
592 /** Search for the last occurrence of a character within a string.
593 
594     @param str
595     a string.  Need not be null-terminated, but must be at least as long as
596     the specified len.
597 
598     @param len
599     the length of the string.
600 
601     @param ch
602     the character to be searched for.
603 
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.
608  */
609 sal_Int32 SAL_CALL rtl_ustr_lastIndexOfChar_WithLength( const sal_Unicode * str, sal_Int32 len, sal_Unicode ch ) SAL_THROW_EXTERN_C();
610 
611 /** Search for the first occurrence of a substring within a string.
612 
613     If subStr is empty, or both str and subStr are empty, -1 is returned.
614     Both strings must be null-terminated.
615 
616     @param str
617     a null-terminated string.
618 
619     @param subStr
620     the null-terminated substring to be searched for.
621 
622     @return
623     the index (starting at 0) of the first character of the first occurrence
624     of the substring within the string, or -1 if the substring does not occur.
625  */
626 sal_Int32 SAL_CALL rtl_ustr_indexOfStr( const sal_Unicode * str, const sal_Unicode * subStr ) SAL_THROW_EXTERN_C();
627 
628 /** Search for the first occurrence of a substring within a string.
629 
630     If subStr is empty, or both str and subStr are empty, -1 is returned.
631 
632     @param str
633     a string.  Need not be null-terminated, but must be at least as long as
634     the specified len.
635 
636     @param len
637     the length of the string.
638 
639     @param subStr
640     the substring to be searched for.  Need not be null-terminated, but must
641     be at least as long as the specified subLen.
642 
643     @param subLen
644     the length of the substring.
645 
646     @return
647     the index (starting at 0) of the first character of the first occurrence
648     of the substring within the string, or -1 if the substring does not occur.
649  */
650 sal_Int32 SAL_CALL rtl_ustr_indexOfStr_WithLength( const sal_Unicode * str, sal_Int32 len, const sal_Unicode * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
651 
652 /** Search for the first occurrence of an ASCII substring within a string.
653 
654     @param str
655     a string.  Need not be null-terminated, but must be at least as long as
656     the specified len.
657 
658     @param len
659     the length of the string; must be non-negative.
660 
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.  Must only contain characters
664     in the ASCII range 0x00--7F.
665 
666     @param subLen
667     the length of the substring; must be non-negative.
668 
669     @return
670     the index (starting at 0) of the first character of the first occurrence
671     of the substring within the string, or -1 if the substring does not occur.
672     If subLen is zero, -1 is returned.
673 
674     @since UDK 3.2.7
675 */
676 sal_Int32 SAL_CALL rtl_ustr_indexOfAscii_WithLength(
677     sal_Unicode const * str, sal_Int32 len,
678     char const * subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C();
679 
680 /** Search for the last occurrence of a substring within a string.
681 
682     If subStr is empty, or both str and subStr are empty, -1 is returned.
683     Both strings must be null-terminated.
684 
685     @param str
686     a null-terminated string.
687 
688     @param subStr
689     the null-terminated substring to be searched for.
690 
691     @return
692     the index (starting at 0) of the first character of the last occurrence
693     of the substring within the string, or -1 if the substring does not occur.
694  */
695 sal_Int32 SAL_CALL rtl_ustr_lastIndexOfStr( const sal_Unicode * str, const sal_Unicode * subStr ) SAL_THROW_EXTERN_C();
696 
697 /** Search for the last occurrence of a substring within a string.
698 
699     If subStr is empty, or both str and subStr are empty, -1 is returned.
700 
701     @param str
702     a string.  Need not be null-terminated, but must be at least as long as
703     the specified len.
704 
705     @param len
706     the length of the string.
707 
708     @param subStr
709     the substring to be searched for.  Need not be null-terminated, but must
710     be at least as long as the specified subLen.
711 
712     @param subLen
713     the length of the substring.
714 
715     @return
716     the index (starting at 0) of the first character of the first occurrence
717     of the substring within the string, or -1 if the substring does not occur.
718  */
719 sal_Int32 SAL_CALL rtl_ustr_lastIndexOfStr_WithLength( const sal_Unicode * str, sal_Int32 len, const sal_Unicode * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
720 
721 /** Search for the last occurrence of an ASCII substring within a string.
722 
723     @param str
724     a string.  Need not be null-terminated, but must be at least as long as
725     the specified len.
726 
727     @param len
728     the length of the string; must be non-negative.
729 
730     @param subStr
731     the substring to be searched for.  Need not be null-terminated, but must
732     be at least as long as the specified subLen.  Must only contain characters
733     in the ASCII range 0x00--7F.
734 
735     @param subLen
736     the length of the substring; must be non-negative.
737 
738     @return
739     the index (starting at 0) of the first character of the last occurrence
740     of the substring within the string, or -1 if the substring does not occur.
741     If subLen is zero, -1 is returned.
742 
743     @since UDK 3.2.7
744 */
745 sal_Int32 SAL_CALL rtl_ustr_lastIndexOfAscii_WithLength(
746     sal_Unicode const * str, sal_Int32 len,
747     char const * subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C();
748 
749 /** Replace all occurrences of a single character within a string.
750 
751     If oldChar does not occur within str, then the string is not modified.
752     The string must be null-terminated.
753 
754     @param str
755     a null-terminated string.
756 
757     @param oldChar
758     the old character.
759 
760     @param newChar
761     the new character.
762  */
763 void SAL_CALL rtl_ustr_replaceChar( sal_Unicode * str, sal_Unicode oldChar, sal_Unicode newChar ) SAL_THROW_EXTERN_C();
764 
765 /** Replace all occurrences of a single character within a string.
766 
767     If oldChar does not occur within str, then the string is not modified.
768 
769     @param str
770     a string.  Need not be null-terminated, but must be at least as long as
771     the specified len.
772 
773     @param len
774     the length of the string.
775 
776     @param oldChar
777     the old character.
778 
779     @param newChar
780     the new character.
781  */
782 void SAL_CALL rtl_ustr_replaceChar_WithLength( sal_Unicode * str, sal_Int32 len, sal_Unicode oldChar, sal_Unicode newChar ) SAL_THROW_EXTERN_C();
783 
784 /** Convert all ASCII uppercase letters to lowercase within a string.
785 
786     The characters with values between 65 and 90 (ASCII A--Z) are replaced
787     with values between 97 and 122 (ASCII a--z).  The string must be
788     null-terminated.
789 
790     @param str
791     a null-terminated string.
792  */
793 void SAL_CALL rtl_ustr_toAsciiLowerCase( sal_Unicode * str ) SAL_THROW_EXTERN_C();
794 
795 /** Convert all ASCII uppercase letters to lowercase within a string.
796 
797     The characters with values between 65 and 90 (ASCII A--Z) are replaced
798     with values between 97 and 122 (ASCII a--z).
799 
800     @param str
801     a string.  Need not be null-terminated, but must be at least as long as
802     the specified len.
803 
804     @param len
805     the length of the string.
806  */
807 void SAL_CALL rtl_ustr_toAsciiLowerCase_WithLength( sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
808 
809 /** Convert all ASCII lowercase letters to uppercase within a string.
810 
811     The characters with values between 97 and 122 (ASCII a--z) are replaced
812     with values between 65 and 90 (ASCII A--Z).  The string must be
813     null-terminated.
814 
815     @param str
816     a null-terminated string.
817  */
818 void SAL_CALL rtl_ustr_toAsciiUpperCase( sal_Unicode * str ) SAL_THROW_EXTERN_C();
819 
820 /** Convert all ASCII lowercase letters to uppercase within a string.
821 
822     The characters with values between 97 and 122 (ASCII a--z) are replaced
823     with values between 65 and 90 (ASCII A--Z).
824 
825     @param str
826     a string.  Need not be null-terminated, but must be at least as long as
827     the specified len.
828 
829     @param len
830     the length of the string.
831  */
832 void SAL_CALL rtl_ustr_toAsciiUpperCase_WithLength( sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
833 
834 /** Remove white space from both ends of a string.
835 
836     All characters with values less than or equal to 32 (the space character)
837     are considered to be white space.  This function cannot be used for
838     language-specific operations.  The string must be null-terminated.
839 
840     @param str
841     a null-terminated string.
842 
843     @return
844     the new length of the string.
845  */
846 sal_Int32 SAL_CALL rtl_ustr_trim( sal_Unicode * str ) SAL_THROW_EXTERN_C();
847 
848 /** Remove white space from both ends of the string.
849 
850     All characters with values less than or equal to 32 (the space character)
851     are considered to be white space.  This function cannot be used for
852     language-specific operations.  The string must be null-terminated.
853 
854     @param str
855     a string.  Need not be null-terminated, but must be at least as long as
856     the specified len.
857 
858     @param len
859     the original length of the string.
860 
861     @return
862     the new length of the string.
863  */
864 sal_Int32 SAL_CALL rtl_ustr_trim_WithLength( sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
865 
866 /** Create the string representation of a boolean.
867 
868     If b is true, the buffer is filled with the string "true" and 5 is
869     returned.  If b is false, the buffer is filled with the string "false" and
870     6 is returned.  This function cannot be used for language-specific
871     operations.
872 
873     @param str
874     a buffer that is big enough to hold the result and the terminating NUL
875     character.  You should use the RTL_USTR_MAX_VALUEOFBOOLEAN define to
876     create a buffer that is big enough.
877 
878     @param b
879     a boolean value.
880 
881     @return
882     the length of the string.
883  */
884 sal_Int32 SAL_CALL rtl_ustr_valueOfBoolean( sal_Unicode * str, sal_Bool b ) SAL_THROW_EXTERN_C();
885 #define RTL_USTR_MAX_VALUEOFBOOLEAN RTL_STR_MAX_VALUEOFBOOLEAN
886 
887 /** Create the string representation of a character.
888 
889     @param str
890     a buffer that is big enough to hold the result and the terminating NUL
891     character.  You should use the RTL_USTR_MAX_VALUEOFCHAR define to create a
892     buffer that is big enough.
893 
894     @param ch
895     a character value.
896 
897     @return
898     the length of the string.
899  */
900 sal_Int32 SAL_CALL rtl_ustr_valueOfChar( sal_Unicode * str, sal_Unicode ch ) SAL_THROW_EXTERN_C();
901 #define RTL_USTR_MAX_VALUEOFCHAR RTL_STR_MAX_VALUEOFCHAR
902 
903 /** Create the string representation of an integer.
904 
905     This function cannot be used for language-specific operations.
906 
907     @param str
908     a buffer that is big enough to hold the result and the terminating NUL
909     character.  You should use the RTL_USTR_MAX_VALUEOFINT32 define to create
910     a buffer that is big enough.
911 
912     @param i
913     an integer value.
914 
915     @param radix
916     the radix.  Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
917     (36), inclusive.
918 
919     @return
920     the length of the string.
921  */
922 sal_Int32 SAL_CALL rtl_ustr_valueOfInt32( sal_Unicode * str, sal_Int32 i, sal_Int16 radix ) SAL_THROW_EXTERN_C();
923 #define RTL_USTR_MIN_RADIX          RTL_STR_MIN_RADIX
924 #define RTL_USTR_MAX_RADIX          RTL_STR_MAX_RADIX
925 #define RTL_USTR_MAX_VALUEOFINT32   RTL_STR_MAX_VALUEOFINT32
926 
927 /** Create the string representation of a long integer.
928 
929     This function cannot be used for language-specific operations.
930 
931     @param str
932     a buffer that is big enough to hold the result and the terminating NUL
933     character.  You should use the RTL_USTR_MAX_VALUEOFINT64 define to create
934     a buffer that is big enough.
935 
936     @param l
937     a long integer value.
938 
939     @param radix
940     the radix.  Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
941     (36), inclusive.
942 
943     @return
944     the length of the string.
945  */
946 sal_Int32 SAL_CALL rtl_ustr_valueOfInt64( sal_Unicode * str, sal_Int64 l, sal_Int16 radix ) SAL_THROW_EXTERN_C();
947 #define RTL_USTR_MAX_VALUEOFINT64 RTL_STR_MAX_VALUEOFINT64
948 
949 /** Create the string representation of a float.
950 
951     This function cannot be used for language-specific conversion.
952 
953     @param str
954     a buffer that is big enough to hold the result and the terminating NUL
955     character.  You should use the RTL_USTR_MAX_VALUEOFFLOAT define to create
956     a buffer that is big enough.
957 
958     @param f
959     a float value.
960 
961     @return
962     the length of the string.
963  */
964 sal_Int32 SAL_CALL rtl_ustr_valueOfFloat( sal_Unicode * str, float f ) SAL_THROW_EXTERN_C();
965 #define RTL_USTR_MAX_VALUEOFFLOAT RTL_STR_MAX_VALUEOFFLOAT
966 
967 /** Create the string representation of a double.
968 
969     This function cannot be used for language-specific conversion.
970 
971     @param str
972     a buffer that is big enough to hold the result and the terminating NUL
973     character.  You should use the RTL_USTR_MAX_VALUEOFDOUBLE define to create
974     a buffer that is big enough.
975 
976     @param d
977     a double value.
978 
979     @return
980     the length of the string.
981  */
982 sal_Int32 SAL_CALL rtl_ustr_valueOfDouble( sal_Unicode * str, double d ) SAL_THROW_EXTERN_C();
983 #define RTL_USTR_MAX_VALUEOFDOUBLE RTL_STR_MAX_VALUEOFDOUBLE
984 
985 /** Interpret a string as a boolean.
986 
987     This function cannot be used for language-specific conversion.  The string
988     must be null-terminated.
989 
990     @param str
991     a null-terminated string.
992 
993     @return
994     true if the string is "1" or "true" in any ASCII case, false otherwise.
995  */
996 sal_Bool SAL_CALL rtl_ustr_toBoolean( const sal_Unicode * str ) SAL_THROW_EXTERN_C();
997 
998 /** Interpret a string as an integer.
999 
1000     This function cannot be used for language-specific conversion.  The string
1001     must be null-terminated.
1002 
1003     @param str
1004     a null-terminated string.
1005 
1006     @param radix
1007     the radix.  Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
1008     (36), inclusive.
1009 
1010     @return
1011     the integer value represented by the string, or 0 if the string does not
1012     represent an integer.
1013  */
1014 sal_Int32 SAL_CALL rtl_ustr_toInt32( const sal_Unicode * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
1015 
1016 /** Interpret a string as a long integer.
1017 
1018     This function cannot be used for language-specific conversion.  The string
1019     must be null-terminated.
1020 
1021     @param str
1022     a null-terminated string.
1023 
1024     @param radix
1025     the radix.  Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
1026     (36), inclusive.
1027 
1028     @return
1029     the long integer value represented by the string, or 0 if the string does
1030     not represent a long integer.
1031  */
1032 sal_Int64 SAL_CALL rtl_ustr_toInt64( const sal_Unicode * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
1033 
1034 /** Interpret a string as a float.
1035 
1036     This function cannot be used for language-specific conversion.  The string
1037     must be null-terminated.
1038 
1039     @param str
1040     a null-terminated string.
1041 
1042     @return
1043     the float value represented by the string, or 0.0 if the string does not
1044     represent a float.
1045  */
1046 float SAL_CALL rtl_ustr_toFloat( const sal_Unicode * str ) SAL_THROW_EXTERN_C();
1047 
1048 /** Interpret a string as a double.
1049 
1050     This function cannot be used for language-specific conversion.  The string
1051     must be null-terminated.
1052 
1053     @param str
1054     a null-terminated string.
1055 
1056     @return
1057     the float value represented by the string, or 0.0 if the string does not
1058     represent a double.
1059  */
1060 double SAL_CALL rtl_ustr_toDouble( const sal_Unicode * str ) SAL_THROW_EXTERN_C();
1061 
1062 /* ======================================================================= */
1063 
1064 #if defined( SAL_W32) ||  defined(SAL_OS2)
1065 #pragma pack(push, 4)
1066 #endif
1067 
1068 /** The implementation of a Unicode string.
1069 
1070     @internal
1071 */
1072 typedef struct _rtl_uString
1073 {
1074     oslInterlockedCount refCount; /* opaque */
1075     sal_Int32           length;
1076     sal_Unicode         buffer[1];
1077 } rtl_uString;
1078 
1079 #if defined( SAL_W32) ||  defined(SAL_OS2)
1080 #pragma pack(pop)
1081 #endif
1082 
1083 /* ----------------------------------------------------------------------- */
1084 
1085 /** Increment the reference count of a string.
1086 
1087     @param str
1088     a string.
1089  */
1090 void SAL_CALL rtl_uString_acquire( rtl_uString * str ) SAL_THROW_EXTERN_C();
1091 
1092 /** Decrement the reference count of a string.
1093 
1094     If the count goes to zero than the string data is deleted.
1095 
1096     @param str
1097     a string.
1098  */
1099 void SAL_CALL rtl_uString_release( rtl_uString * str ) SAL_THROW_EXTERN_C();
1100 
1101 /** Allocate a new string containing no characters.
1102 
1103     @param newStr
1104     pointer to the new string.  The pointed-to data must be null or a valid
1105     string.
1106  */
1107 void SAL_CALL rtl_uString_new( rtl_uString ** newStr ) SAL_THROW_EXTERN_C();
1108 
1109 /** Allocate a new string containing space for a given number of characters.
1110 
1111     If len is greater than zero, the reference count of the new string will be
1112     1.  The values of all characters are set to 0 and the length of the string
1113     is 0.  This function does not handle out-of-memory conditions.
1114 
1115     @param newStr
1116     pointer to the new string.  The pointed-to data must be null or a valid
1117     string.
1118 
1119     @param len
1120     the number of characters.
1121  */
1122 void SAL_CALL rtl_uString_new_WithLength( rtl_uString ** newStr, sal_Int32 nLen ) SAL_THROW_EXTERN_C();
1123 
1124 /** Allocate a new string that contains a copy of another string.
1125 
1126     If the length of value is greater than zero, the reference count of the
1127     new string will be 1.  This function does not handle out-of-memory
1128     conditions.
1129 
1130     @param newStr
1131     pointer to the new string.  The pointed-to data must be null or a valid
1132     string.
1133 
1134     @param value
1135     a valid string.
1136  */
1137 void SAL_CALL rtl_uString_newFromString( rtl_uString ** newStr, const rtl_uString * value ) SAL_THROW_EXTERN_C();
1138 
1139 /** Allocate a new string that contains a copy of a character array.
1140 
1141     If the length of value is greater than zero, the reference count of the
1142     new string will be 1.  This function does not handle out-of-memory
1143     conditions.
1144 
1145     @param newStr
1146     pointer to the new string.  The pointed-to data must be null or a valid
1147     string.
1148 
1149     @param value
1150     a null-terminated character array.
1151  */
1152 void SAL_CALL rtl_uString_newFromStr( rtl_uString ** newStr, const sal_Unicode * value ) SAL_THROW_EXTERN_C();
1153 
1154 /** Allocate a new string that contains a copy of a character array.
1155 
1156     If the length of value is greater than zero, the reference count of the
1157     new string will be 1.  This function does not handle out-of-memory
1158     conditions.
1159 
1160     @param newStr
1161     pointer to the new string.  The pointed-to data must be null or a valid
1162     string.
1163 
1164     @param value
1165     a character array.  Need not be null-terminated, but must be at least as
1166     long as the specified len.
1167 
1168     @param len
1169     the length of the character array.
1170  */
1171 void SAL_CALL rtl_uString_newFromStr_WithLength( rtl_uString ** newStr, const sal_Unicode * value, sal_Int32 len ) SAL_THROW_EXTERN_C();
1172 
1173 /** Allocate a new string that contains a copy of a character array.
1174 
1175     If the length of value is greater than zero, the reference count of the
1176     new string will be 1.  This function does not handle out-of-memory
1177     conditions.
1178 
1179     Since this function is optimized for performance, the ASCII character
1180     values are not converted in any way.  The caller has to make sure that
1181     all ASCII characters are in the allowed range of 0 and 127, inclusive.
1182 
1183     @param newStr
1184     pointer to the new string.  The pointed-to data must be null or a valid
1185     string.
1186 
1187     @param value
1188     a null-terminated ASCII character array.
1189  */
1190 void SAL_CALL rtl_uString_newFromAscii( rtl_uString ** newStr, const sal_Char * value ) SAL_THROW_EXTERN_C();
1191 
1192 /** Allocate a new string from an array of Unicode code points.
1193 
1194     @param newString
1195     a non-null pointer to a (possibly null) rtl_uString pointer, which (if
1196     non-null) will have been passed to rtl_uString_release before the function
1197     returns.  Upon return, points to the newly allocated string or to null if
1198     there was either an out-of-memory condition or the resulting number of
1199     UTF-16 code units would have been larger than SAL_MAX_INT32.  The newly
1200     allocated string (if any) must ultimately be passed to rtl_uString_release.
1201 
1202     @param codePoints
1203     an array of at least codePointCount code points, which each must be in the
1204     range from 0 to 0x10FFFF, inclusive.  May be null if codePointCount is zero.
1205 
1206     @param codePointCount
1207     the non-negative number of code points.
1208 
1209     @since UDK 3.2.7
1210 */
1211 void SAL_CALL rtl_uString_newFromCodePoints(
1212     rtl_uString ** newString, sal_uInt32 const * codePoints,
1213     sal_Int32 codePointCount) SAL_THROW_EXTERN_C();
1214 
1215 /** Assign a new value to a string.
1216 
1217     First releases any value str might currently hold, then acquires
1218     rightValue.
1219 
1220     @param str
1221     pointer to the string.  The pointed-to data must be null or a valid
1222     string.
1223 
1224     @param rightValue
1225     a valid string.
1226  */
1227 void SAL_CALL rtl_uString_assign( rtl_uString ** str, rtl_uString * rightValue ) SAL_THROW_EXTERN_C();
1228 
1229 /** Return the length of a string.
1230 
1231     The length is equal to the number of characters in the string.
1232 
1233     @param str
1234     a valid string.
1235 
1236     @return
1237     the length of the string.
1238  */
1239 sal_Int32 SAL_CALL rtl_uString_getLength( const rtl_uString * str ) SAL_THROW_EXTERN_C();
1240 
1241 /** Return a pointer to the underlying character array of a string.
1242 
1243     @param str
1244     a valid string.
1245 
1246     @return
1247     a pointer to the null-terminated character array.
1248  */
1249 sal_Unicode * SAL_CALL rtl_uString_getStr( rtl_uString * str ) SAL_THROW_EXTERN_C();
1250 
1251 /** Create a new string that is the concatenation of two other strings.
1252 
1253     The new string does not necessarily have a reference count of 1 (in cases
1254     where one of the two other strings is empty), so it must not be modified
1255     without checking the reference count.  This function does not handle
1256     out-of-memory conditions.
1257 
1258     @param newStr
1259     pointer to the new string.  The pointed-to data must be null or a valid
1260     string.
1261 
1262     @param left
1263     a valid string.
1264 
1265     @param right
1266     a valid string.
1267  */
1268 void SAL_CALL rtl_uString_newConcat( rtl_uString ** newStr, rtl_uString * left, rtl_uString * right ) SAL_THROW_EXTERN_C();
1269 
1270 /** Create a new string by replacing a substring of another string.
1271 
1272     The new string results from replacing a number of characters (count),
1273     starting at the specified position (index) in the original string (str),
1274     with some new substring (subStr).  If subStr is null, than only a number
1275     of characters is deleted.
1276 
1277     The new string does not necessarily have a reference count of 1, so it
1278     must not be modified without checking the reference count.  This function
1279     does not handle out-of-memory conditions.
1280 
1281     @param newStr
1282     pointer to the new string.  The pointed-to data must be null or a valid
1283     string.
1284 
1285     @param str
1286     a valid string.
1287 
1288     @param index
1289     the index into str at which to start replacement.  Must be between 0 and
1290     the length of str, inclusive.
1291 
1292     @param count
1293     the number of charcters to remove.  Must not be negative, and the sum of
1294     index and count must not exceed the length of str.
1295 
1296     @param subStr
1297     either null or a valid string to be inserted.
1298  */
1299 void SAL_CALL rtl_uString_newReplaceStrAt( rtl_uString ** newStr, rtl_uString * str, sal_Int32 idx, sal_Int32 count, rtl_uString * subStr ) SAL_THROW_EXTERN_C();
1300 
1301 /** Create a new string by replacing all occurrences of a single character
1302     within another string.
1303 
1304     The new string results from replacing all occurrences of oldChar in str
1305     with newChar.
1306 
1307     The new string does not necessarily have a reference count of 1 (in cases
1308     where oldChar does not occur in str), so it must not be modified without
1309     checking the reference count.  This function does not handle out-of-memory
1310     conditions.
1311 
1312     @param newStr
1313     pointer to the new string.  The pointed-to data must be null or a valid
1314     string.
1315 
1316     @param str
1317     a valid string.
1318 
1319     @param oldChar
1320     the old character.
1321 
1322     @param newChar
1323     the new character.
1324  */
1325 void SAL_CALL rtl_uString_newReplace( rtl_uString ** newStr, rtl_uString * str, sal_Unicode oldChar, sal_Unicode newChar ) SAL_THROW_EXTERN_C();
1326 
1327 /** Create a new string by converting all ASCII uppercase letters to lowercase
1328     within another string.
1329 
1330     The new string results from replacing all characters with values between
1331     65 and 90 (ASCII A--Z) by values between 97 and 122 (ASCII a--z).
1332 
1333     This function cannot be used for language-specific conversion.  The new
1334     string does not necessarily have a reference count of 1 (in cases where
1335     no characters need to be converted), so it must not be modified without
1336     checking the reference count.  This function does not handle out-of-memory
1337     conditions.
1338 
1339     @param newStr
1340     pointer to the new string.  The pointed-to data must be null or a valid
1341     string.
1342 
1343     @param str
1344     a valid string.
1345  */
1346 void SAL_CALL rtl_uString_newToAsciiLowerCase( rtl_uString ** newStr, rtl_uString * str ) SAL_THROW_EXTERN_C();
1347 
1348 /** Create a new string by converting all ASCII lowercase letters to uppercase
1349     within another string.
1350 
1351     The new string results from replacing all characters with values between
1352     97 and 122 (ASCII a--z) by values between 65 and 90 (ASCII A--Z).
1353 
1354     This function cannot be used for language-specific conversion.  The new
1355     string does not necessarily have a reference count of 1 (in cases where
1356     no characters need to be converted), so it must not be modified without
1357     checking the reference count.  This function does not handle out-of-memory
1358     conditions.
1359 
1360     @param newStr
1361     pointer to the new string.  The pointed-to data must be null or a valid
1362     string.
1363 
1364     @param str
1365     a valid string.
1366  */
1367 void SAL_CALL rtl_uString_newToAsciiUpperCase( rtl_uString ** newStr, rtl_uString * str ) SAL_THROW_EXTERN_C();
1368 
1369 /** Create a new string by removing white space from both ends of another
1370     string.
1371 
1372     The new string results from removing all characters with values less than
1373     or equal to 32 (the space character) form both ends of str.
1374 
1375     This function cannot be used for language-specific conversion.  The new
1376     string does not necessarily have a reference count of 1 (in cases where
1377     no characters need to be removed), so it must not be modified without
1378     checking the reference count.  This function does not handle out-of-memory
1379     conditions.
1380 
1381     @param newStr
1382     pointer to the new string.  The pointed-to data must be null or a valid
1383     string.
1384 
1385     @param str
1386     a valid string.
1387  */
1388 void SAL_CALL rtl_uString_newTrim( rtl_uString ** newStr, rtl_uString * str ) SAL_THROW_EXTERN_C();
1389 
1390 /** Create a new string by extracting a single token from another string.
1391 
1392     Starting at index, the token's next token is searched for.  If there is no
1393     such token, the result is an empty string.  Otherwise, all characters from
1394     the start of that token and up to, but not including the next occurrence
1395     of cTok make up the resulting token.  The return value is the position of
1396     the next token, or -1 if no more tokens follow.
1397 
1398     Example code could look like
1399       rtl_uString * pToken = NULL;
1400       sal_Int32 nIndex = 0;
1401       do
1402       {
1403           ...
1404           nIndex = rtl_uString_getToken(&pToken, pStr, 0, ';', nIndex);
1405           ...
1406       }
1407       while (nIndex >= 0);
1408 
1409     The new string does not necessarily have a reference count of 1, so it
1410     must not be modified without checking the reference count.  This function
1411     does not handle out-of-memory conditions.
1412 
1413     @param newStr
1414     pointer to the new string.  The pointed-to data must be null or a valid
1415     string.  If either token or index is negative, an empty token is stored in
1416     newStr (and -1 is returned).
1417 
1418     @param str
1419     a valid string.
1420 
1421     @param token
1422     the number of the token to return, starting at index.
1423 
1424     @param cTok
1425     the character that seperates the tokens.
1426 
1427     @param index
1428     the position at which searching for the token starts.  Must not be greater
1429     than the length of str.
1430 
1431     @return
1432     the index of the next token, or -1 if no more tokens follow.
1433  */
1434 sal_Int32 SAL_CALL rtl_uString_getToken( rtl_uString ** newStr , rtl_uString * str, sal_Int32 token, sal_Unicode cTok, sal_Int32 idx ) SAL_THROW_EXTERN_C();
1435 
1436 /* ======================================================================= */
1437 
1438 /** Supply an ASCII string literal together with its length and text encoding.
1439 
1440     This macro can be used to compute (some of) the arguments in function calls
1441     like rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foo")).
1442 
1443     @param constAsciiStr
1444     must be an expression of type "(possibly cv-qualified reference to) array of
1445     (possibly cv-qualified) char."  Each element of the referenced array must
1446     represent an ASCII value in the range 0x00--0x7F.  The last element of the
1447     referenced array is not considered part of the represented ASCII string, and
1448     its value should be 0x00.  Depending on where this macro is used, the nature
1449     of the supplied expression might be further restricted.
1450 */
1451 #define RTL_CONSTASCII_USTRINGPARAM( constAsciiStr ) constAsciiStr, ((sal_Int32)(sizeof(constAsciiStr)-1)), RTL_TEXTENCODING_ASCII_US
1452 
1453 /* ======================================================================= */
1454 
1455 /* predefined constants for String-Conversion */
1456 #define OSTRING_TO_OUSTRING_CVTFLAGS    (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MAPTOPRIVATE |\
1457                                          RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT |\
1458                                          RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT)
1459 
1460 /* ----------------------------------------------------------------------- */
1461 
1462 /** Create a new Unicode string by converting a byte string, using a specific
1463     text encoding.
1464 
1465     The lengths of the byte string and the Unicode string may differ (e.g.,
1466     for double-byte encodings, UTF-7, UTF-8).
1467 
1468     If the length of the byte string is greater than zero, the reference count
1469     of the new string will be 1.
1470 
1471     If an out-of-memory condition occurs, newStr will point to a null pointer
1472     upon return.
1473 
1474     @param newStr
1475     pointer to the new string.  The pointed-to data must be null or a valid
1476     string.
1477 
1478     @param str
1479     a byte character array.  Need not be null-terminated, but must be at
1480     least as long as the specified len.
1481 
1482     @param len
1483     the length of the byte character array.
1484 
1485     @param encoding
1486     the text encoding to use for conversion.
1487 
1488     @param convertFlags
1489     flags which control the conversion.  Either use
1490     OSTRING_TO_OUSTRING_CVTFLAGS, or see
1491     <http://udk.openoffice.org/cpp/man/spec/textconversion.html> for more
1492     details.
1493  */
1494 void SAL_CALL rtl_string2UString( rtl_uString ** newStr, const sal_Char * str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags ) SAL_THROW_EXTERN_C();
1495 
1496 /* ======================================================================= */
1497 /* Interning methods */
1498 
1499 /** Return a canonical representation for a string.
1500 
1501     A pool of strings, initially empty is maintained privately
1502     by the string class. On invocation, if present in the pool
1503     the original string will be returned. Otherwise this string,
1504     or a copy thereof will be added to the pool and returned.
1505 
1506     @param newStr
1507     pointer to the new string.  The pointed-to data must be null or a valid
1508     string.
1509 
1510     If an out-of-memory condition occurs, newStr will point to a null pointer
1511     upon return.
1512 
1513     @param str
1514     pointer to the string to be interned.
1515 
1516     @since UDK 3.2.7
1517  */
1518 void SAL_CALL rtl_uString_intern( rtl_uString ** newStr,
1519                                   rtl_uString  * str) SAL_THROW_EXTERN_C();
1520 
1521 /** Return a canonical representation for a string.
1522 
1523     A pool of strings, initially empty is maintained privately
1524     by the string class. On invocation, if present in the pool
1525     the original string will be returned. Otherwise this string,
1526     or a copy thereof will be added to the pool and returned.
1527 
1528     @param newStr
1529     pointer to the new string.  The pointed-to data must be null or a valid
1530     string.
1531 
1532     If an out-of-memory condition occurs, newStr will point to a null pointer
1533     upon return.
1534 
1535     @param str
1536     a byte character array.  Need not be null-terminated, but must be at
1537     least as long as the specified len.
1538 
1539     @param len
1540     the length of the byte character array.
1541 
1542     @param encoding
1543     the text encoding to use for conversion.
1544 
1545     @param convertFlags
1546     flags which control the conversion.  Either use
1547     OSTRING_TO_OUSTRING_CVTFLAGS, or see
1548     <http://udk.openoffice.org/cpp/man/spec/textconversion.html> for more
1549     details.
1550 
1551     @param pInfo
1552     pointer to return conversion status in, or NULL.
1553 
1554     @since UDK 3.2.7
1555  */
1556 void SAL_CALL rtl_uString_internConvert( rtl_uString   ** newStr,
1557                                          const sal_Char * str,
1558                                          sal_Int32        len,
1559                                          rtl_TextEncoding encoding,
1560                                          sal_uInt32       convertFlags,
1561                                          sal_uInt32      *pInfo) SAL_THROW_EXTERN_C();
1562 
1563 /** Iterate through a string based on code points instead of UTF-16 code units.
1564 
1565     See Chapter 3 of The Unicode Standard 5.0 (Addison--Wesley, 2006) for
1566     definitions of the various terms used in this description.
1567 
1568     The given string is interpreted as a sequence of zero or more UTF-16 code
1569     units.  For each index into this sequence (from zero to one less than the
1570     length of the sequence, inclusive), a code point represented starting at the
1571     given index is computed as follows:
1572 
1573     - If the UTF-16 code unit addressed by the index constitutes a well-formed
1574     UTF-16 code unit sequence, the computed code point is the scalar value
1575     encoded by that UTF-16 code unit sequence.
1576 
1577     - Otherwise, if the index is at least two UTF-16 code units away from the
1578     end of the sequence, and the sequence of two UTF-16 code units addressed by
1579     the index constitutes a well-formed UTF-16 code unit sequence, the computed
1580     code point is the scalar value encoded by that UTF-16 code unit sequence.
1581 
1582     - Otherwise, the computed code point is the UTF-16 code unit addressed by
1583     the index.  (This last case catches unmatched surrogates as well as indices
1584     pointing into the middle of surrogate pairs.)
1585 
1586     @param string
1587     pointer to a valid string; must not be null.
1588 
1589     @param indexUtf16
1590     pointer to a UTF-16 based index into the given string; must not be null.  On
1591     entry, the index must be in the range from zero to the length of the string
1592     (in UTF-16 code units), inclusive.  Upon successful return, the index will
1593     be updated to address the UTF-16 code unit that is the given
1594     incrementCodePoints away from the initial index.
1595 
1596     @param incrementCodePoints
1597     the number of code points to move the given *indexUtf16.  If non-negative,
1598     moving is done after determining the code point at the index.  If negative,
1599     moving is done before determining the code point at the (then updated)
1600     index.  The value must be such that the resulting UTF-16 based index is in
1601     the range from zero to the length of the string (in UTF-16 code units),
1602     inclusive.
1603 
1604     @return
1605     the code point (an integer in the range from 0 to 0x10FFFF, inclusive) that
1606     is represented within the string starting at the index computed as follows:
1607     If incrementCodePoints is non-negative, the index is the initial value of
1608     *indexUtf16; if incrementCodePoints is negative, the index is the updated
1609     value of *indexUtf16.  In either case, the computed index must be in the
1610     range from zero to one less than the length of the string (in UTF-16 code
1611     units), inclusive.
1612 
1613     @since UDK 3.2.7
1614 */
1615 sal_uInt32 SAL_CALL rtl_uString_iterateCodePoints(
1616     rtl_uString const * string, sal_Int32 * indexUtf16,
1617     sal_Int32 incrementCodePoints);
1618 
1619 /** Converts a byte string to a Unicode string, signalling failure.
1620 
1621     @param target
1622     An out parameter receiving the converted string.  Must not be null itself,
1623     and must contain either null or a pointer to a valid rtl_uString; the
1624     contents are unspecified if conversion fails (rtl_convertStringToUString
1625     returns false).
1626 
1627     @param source
1628     The byte string.  May only be null if length is zero.
1629 
1630     @param length
1631     The length of the byte string.  Must be non-negative.
1632 
1633     @param encoding
1634     The text encoding to convert from.  Must be an octet encoding (i.e.,
1635     rtl_isOctetTextEncoding(encoding) must return true).
1636 
1637     @param flags
1638     A combination of RTL_TEXTTOUNICODE_FLAGS that detail how to do the
1639     conversion (see rtl_convertTextToUnicode).  RTL_TEXTTOUNICODE_FLAGS_FLUSH
1640     need not be included, it is implicitly assumed.  Typical uses are either
1641     RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
1642     RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
1643     RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR (fail if a byte or multi-byte sequence
1644     cannot be converted from the source encoding) or
1645     OSTRING_TO_OUSTRING_CVTFLAGS (make a best efforts conversion).
1646 
1647     @return
1648     True if the conversion succeeded, false otherwise.
1649 
1650     @since UDK 3.2.9
1651 */
1652 sal_Bool SAL_CALL rtl_convertStringToUString(
1653     rtl_uString ** target, char const * source, sal_Int32 length,
1654     rtl_TextEncoding encoding, sal_uInt32 flags) SAL_THROW_EXTERN_C();
1655 
1656 #ifdef __cplusplus
1657 }
1658 #endif
1659 
1660 #endif /* _RTL_USTRING_H_ */
1661