LibreOffice: rtl/ustring.hxx Source File

LibreOffice LibreOffice 5.3 SDK C/C++ API Reference

ustring.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20 #ifndef INCLUDED_RTL_USTRING_HXX
21 #define INCLUDED_RTL_USTRING_HXX
22
23 #include <sal/config.h>
24
25 #include <cassert>
26 #include <cstddef>
27 #include <new>
28 #include <ostream>
29 #include <string.h>
30
31 #include <rtl/ustring.h>
32 #include <rtl/string.hxx>
33 #include <rtl/stringutils.hxx>
34 #include <rtl/textenc.h>
35 #include <sal/log.hxx>
36
37 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
38 #include <config_global.h>
39 #include <rtl/stringconcat.hxx>
40 #endif
41
42 // The unittest uses slightly different code to help check that the proper
43 // calls are made. The class is put into a different namespace to make
44 // sure the compiler generates a different (if generating also non-inline)
45 // copy of the function and does not merge them together. The class
46 // is "brought" into the proper rtl namespace by a typedef below.
47 #ifdef RTL_STRING_UNITTEST
48 #define rtl rtlunittest
49 #endif
50
51 namespace rtl
52 {
53
54 #ifdef RTL_STRING_UNITTEST
55 #undef rtl
56 #endif
57
58 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
59
69 struct SAL_WARN_UNUSED OUStringLiteral
70 {
71 template< int N >
72 explicit SAL_CONSTEXPR OUStringLiteral( const char (&str)[ N ] ) : size( N - 1 ), data( str )
73 { /* only C++14 constexpr: assert( strlen( str ) == N - 1 ); */ }
74 int size;
75 const char* data;
76 };
77
79 #endif
80
81 /* ======================================================================= */
82
106 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OUString
107 {
108 public:
110 rtl_uString * pData;
112
116 OUString()
117 {
118 pData = NULL;
119 rtl_uString_new( &pData );
120 }
121
127 OUString( const OUString & str )
128 {
129 pData = str.pData;
130 rtl_uString_acquire( pData );
131 }
132
133 #ifndef _MSC_VER // TODO?
134 #if defined LIBO_INTERNAL_ONLY
135
141 OUString( OUString && str )
142 {
143 pData = str.pData;
144 str.pData = nullptr;
145 rtl_uString_new( &str.pData );
146 }
147 #endif
148 #endif
149
155 OUString( rtl_uString * str )
156 {
157 pData = str;
158 rtl_uString_acquire( pData );
159 }
160
169 inline OUString( rtl_uString * str, __sal_NoAcquire )
170 { pData = str; }
171
177 explicit OUString( sal_Unicode value )
178 : pData (NULL)
179 {
180 rtl_uString_newFromStr_WithLength( &pData, &value, 1 );
181 }
182
183 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
184 // Catch inadvertent conversions to the above ctor (but still allow
186 // construction from char literals):
187 OUString(int) = delete;
188 explicit OUString(char c):
189 OUString(sal_Unicode(static_cast<unsigned char>(c)))
190 {}
192 #endif
193
199 OUString( const sal_Unicode * value )
200 {
201 pData = NULL;
202 rtl_uString_newFromStr( &pData, value );
203 }
204
213 OUString( const sal_Unicode * value, sal_Int32 length )
214 {
215 pData = NULL;
216 rtl_uString_newFromStr_WithLength( &pData, value, length );
217 }
218
234 template< typename T >
235 OUString( T& literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type = libreoffice_internal::Dummy() )
236 {
237 assert(
238 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
239 pData = NULL;
240 if (libreoffice_internal::ConstCharArrayDetector<T>::length == 0) {
241 rtl_uString_new(&pData);
242 } else {
243 rtl_uString_newFromLiteral(
244 &pData,
245 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
246 literal),
247 libreoffice_internal::ConstCharArrayDetector<T>::length, 0);
248 }
249 #ifdef RTL_STRING_UNITTEST
250 rtl_string_unittest_const_literal = true;
251 #endif
252 }
253
254 #if defined LIBO_INTERNAL_ONLY
255
256 template<typename T> OUString(
257 T & literal,
258 typename libreoffice_internal::ConstCharArrayDetector<
259 T, libreoffice_internal::Dummy>::TypeUtf16
260 = libreoffice_internal::Dummy()):
261 pData(nullptr)
262 {
263 if (libreoffice_internal::ConstCharArrayDetector<T>::length == 0) {
264 rtl_uString_new(&pData);
265 } else {
266 rtl_uString_newFromStr_WithLength(
267 &pData,
268 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
269 literal),
270 libreoffice_internal::ConstCharArrayDetector<T>::length);
271 }
272 }
273 #endif
274
275 #ifdef RTL_STRING_UNITTEST
276
280 template< typename T >
281 OUString( T&, typename libreoffice_internal::ExceptConstCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
282 {
283 pData = NULL;
284 rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
285 rtl_string_unittest_invalid_conversion = true;
286 }
291 template< typename T >
292 OUString( const T&, typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
293 {
294 pData = NULL;
295 rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
296 rtl_string_unittest_invalid_conversion = true;
297 }
298 #endif
299
300 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
301
317 OUString(OUStringLiteral literal): pData(NULL) {
318 rtl_uString_newFromLiteral(&pData, literal.data, literal.size, 0);
319 }
321 #endif
322
337 OUString( const sal_Char * value, sal_Int32 length,
338 rtl_TextEncoding encoding,
339 sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
340 {
341 pData = NULL;
342 rtl_string2UString( &pData, value, length, encoding, convertFlags );
343 if (pData == NULL) {
344 throw std::bad_alloc();
345 }
346 }
347
364 inline explicit OUString(
365 sal_uInt32 const * codePoints, sal_Int32 codePointCount):
366 pData(NULL)
367 {
368 rtl_uString_newFromCodePoints(&pData, codePoints, codePointCount);
369 if (pData == NULL) {
370 throw std::bad_alloc();
371 }
372 }
373
374 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
375
379 template< typename T1, typename T2 >
380 OUString( const OUStringConcat< T1, T2 >& c )
381 {
382 const sal_Int32 l = c.length();
383 pData = rtl_uString_alloc( l );
384 if (l != 0)
385 {
386 sal_Unicode* end = c.addData( pData->buffer );
387 pData->length = l;
388 *end = '\0';
389 // TODO realloc in case pData->length is noticeably smaller than l?
390 }
391 }
392 #endif
393
397 ~OUString()
398 {
399 rtl_uString_release( pData );
400 }
401
413 static inline OUString const & unacquired( rtl_uString * const * ppHandle )
414 { return * reinterpret_cast< OUString const * >( ppHandle ); }
415
421 OUString & operator=( const OUString & str )
422 {
423 rtl_uString_assign( &pData, str.pData );
424 return *this;
425 }
426
427 #ifndef _MSC_VER // TODO?
428 #if defined LIBO_INTERNAL_ONLY
429
435 OUString & operator=( OUString && str )
436 {
437 rtl_uString_release( pData );
438 pData = str.pData;
439 str.pData = nullptr;
440 rtl_uString_new( &str.pData );
441 return *this;
442 }
443 #endif
444 #endif
445
458 template< typename T >
459 typename libreoffice_internal::ConstCharArrayDetector< T, OUString& >::Type operator=( T& literal )
460 {
461 assert(
462 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
463 if (libreoffice_internal::ConstCharArrayDetector<T>::length == 0) {
464 rtl_uString_new(&pData);
465 } else {
466 rtl_uString_newFromLiteral(
467 &pData,
468 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
469 literal),
470 libreoffice_internal::ConstCharArrayDetector<T>::length, 0);
471 }
472 return *this;
473 }
474
475 #if defined LIBO_INTERNAL_ONLY
476
477 template<typename T>
478 typename
479 libreoffice_internal::ConstCharArrayDetector<T, OUString &>::TypeUtf16
480 operator =(T & literal) {
481 if (libreoffice_internal::ConstCharArrayDetector<T>::length == 0) {
482 rtl_uString_new(&pData);
483 } else {
484 rtl_uString_newFromStr_WithLength(
485 &pData,
486 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
487 literal),
488 libreoffice_internal::ConstCharArrayDetector<T>::length);
489 }
490 return *this;
491 }
492 #endif
493
499 OUString & operator+=( const OUString & str )
500 #if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
501 &
502 #endif
503 {
504 rtl_uString_newConcat( &pData, pData, str.pData );
505 return *this;
506 }
507 #if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
508 void operator+=(OUString const &) && = delete;
509 #endif
510
517 template<typename T>
518 typename libreoffice_internal::ConstCharArrayDetector<T, OUString &>::Type
519 operator +=(T & literal)
520 #if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
521 &
522 #endif
523 {
524 assert(
525 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
526 rtl_uString_newConcatAsciiL(
527 &pData, pData,
528 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
529 libreoffice_internal::ConstCharArrayDetector<T>::length);
530 return *this;
531 }
532 #if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
533 template<typename T>
534 typename libreoffice_internal::ConstCharArrayDetector<T, OUString &>::Type
535 operator +=(T &) && = delete;
536 #endif
537
538 #if defined LIBO_INTERNAL_ONLY
539
540 template<typename T>
541 typename
542 libreoffice_internal::ConstCharArrayDetector<T, OUString &>::TypeUtf16
543 operator +=(T & literal)
544 #if HAVE_CXX11_REF_QUALIFIER
545 &
546 #endif
547 {
548 rtl_uString_newConcatUtf16L(
549 &pData, pData,
550 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
551 libreoffice_internal::ConstCharArrayDetector<T>::length);
552 return *this;
553 }
554 #if HAVE_CXX11_REF_QUALIFIER
555 template<typename T>
556 typename
557 libreoffice_internal::ConstCharArrayDetector<T, OUString &>::TypeUtf16
558 operator +=(T &) && = delete;
559 #endif
560 #endif
561
562 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
563
567 template< typename T1, typename T2 >
568 OUString& operator+=( const OUStringConcat< T1, T2 >& c )
569 #if HAVE_CXX11_REF_QUALIFIER
570 &
571 #endif
572 {
573 sal_Int32 l = c.length();
574 if( l == 0 )
575 return *this;
576 l += pData->length;
577 rtl_uString_ensureCapacity( &pData, l );
578 sal_Unicode* end = c.addData( pData->buffer + pData->length );
579 *end = '\0';
580 pData->length = l;
581 return *this;
582 }
583 #if HAVE_CXX11_REF_QUALIFIER
584 template<typename T1, typename T2> void operator +=(
585 OUStringConcat<T1, T2> const &) && = delete;
586 #endif
587 #endif
588
593 void clear()
594 {
595 rtl_uString_new( &pData );
596 }
597
606 sal_Int32 getLength() const { return pData->length; }
607
616 bool isEmpty() const
617 {
618 return pData->length == 0;
619 }
620
628 const sal_Unicode * getStr() const { return pData->buffer; }
629
639 sal_Unicode operator [](sal_Int32 index) const {
640 // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
641 assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
642 return getStr()[index];
643 }
644
657 sal_Int32 compareTo( const OUString & str ) const
658 {
659 return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
660 str.pData->buffer, str.pData->length );
661 }
662
678 sal_Int32 compareTo( const OUString & str, sal_Int32 maxLength ) const
679 {
680 return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
681 str.pData->buffer, str.pData->length, maxLength );
682 }
683
696 sal_Int32 reverseCompareTo( const OUString & str ) const
697 {
698 return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
699 str.pData->buffer, str.pData->length );
700 }
701
707 template< typename T >
708 typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type reverseCompareTo( T& literal ) const
709 {
710 assert(
711 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
712 return rtl_ustr_asciil_reverseCompare_WithLength(
713 pData->buffer, pData->length,
714 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
715 libreoffice_internal::ConstCharArrayDetector<T>::length);
716 }
717
718 #if defined LIBO_INTERNAL_ONLY
719
720 template<typename T>
721 typename
722 libreoffice_internal::ConstCharArrayDetector<T, sal_Int32>::TypeUtf16
723 reverseCompareTo(T & literal) const {
724 return rtl_ustr_reverseCompare_WithLength(
725 pData->buffer, pData->length,
726 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
727 libreoffice_internal::ConstCharArrayDetector<T>::length);
728 }
729 #endif
730
742 bool equals( const OUString & str ) const
743 {
744 if ( pData->length != str.pData->length )
745 return false;
746 if ( pData == str.pData )
747 return true;
748 return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
749 str.pData->buffer, str.pData->length ) == 0;
750 }
751
766 bool equalsIgnoreAsciiCase( const OUString & str ) const
767 {
768 if ( pData->length != str.pData->length )
769 return false;
770 if ( pData == str.pData )
771 return true;
772 return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
773 str.pData->buffer, str.pData->length ) == 0;
774 }
775
791 sal_Int32 compareToIgnoreAsciiCase( const OUString & str ) const
792 {
793 return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
794 str.pData->buffer, str.pData->length );
795 }
796
797
803 template< typename T >
804 typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase( T& literal ) const
805 {
806 assert(
807 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
808 return
809 (pData->length
810 == libreoffice_internal::ConstCharArrayDetector<T>::length)
811 && (rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength(
812 pData->buffer, pData->length,
813 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
814 literal))
815 == 0);
816 }
817
818 #if defined LIBO_INTERNAL_ONLY
819
820 template<typename T>
821 typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
822 equalsIgnoreAsciiCase(T & literal) const {
823 return
824 rtl_ustr_compareIgnoreAsciiCase_WithLength(
825 pData->buffer, pData->length,
826 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
827 literal),
828 libreoffice_internal::ConstCharArrayDetector<T>::length)
829 == 0;
830 }
831 #endif
832
848 bool match( const OUString & str, sal_Int32 fromIndex = 0 ) const
849 {
850 return rtl_ustr_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
851 str.pData->buffer, str.pData->length, str.pData->length ) == 0;
852 }
853
859 template< typename T >
860 typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
861 {
862 assert(
863 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
864 return
865 rtl_ustr_ascii_shortenedCompare_WithLength(
866 pData->buffer+fromIndex, pData->length-fromIndex,
867 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
868 literal),
869 libreoffice_internal::ConstCharArrayDetector<T>::length)
870 == 0;
871 }
872
873 #if defined LIBO_INTERNAL_ONLY
874
875 template<typename T>
876 typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
877 match(T & literal, sal_Int32 fromIndex = 0) const {
878 assert(fromIndex >= 0);
879 return
880 rtl_ustr_shortenedCompare_WithLength(
881 pData->buffer + fromIndex, pData->length - fromIndex,
882 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
883 literal),
884 libreoffice_internal::ConstCharArrayDetector<T>::length,
885 libreoffice_internal::ConstCharArrayDetector<T>::length)
886 == 0;
887 }
888 #endif
889
908 bool matchIgnoreAsciiCase( const OUString & str, sal_Int32 fromIndex = 0 ) const
909 {
910 return rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
911 str.pData->buffer, str.pData->length,
912 str.pData->length ) == 0;
913 }
914
920 template< typename T >
921 typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
922 {
923 assert(
924 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
925 return
926 rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(
927 pData->buffer+fromIndex, pData->length-fromIndex,
928 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
929 literal),
930 libreoffice_internal::ConstCharArrayDetector<T>::length)
931 == 0;
932 }
933
934 #if defined LIBO_INTERNAL_ONLY
935
936 template<typename T>
937 typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
938 matchIgnoreAsciiCase(T & literal, sal_Int32 fromIndex = 0) const {
939 assert(fromIndex >= 0);
940 return
941 rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength(
942 pData->buffer + fromIndex, pData->length - fromIndex,
943 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
944 literal),
945 libreoffice_internal::ConstCharArrayDetector<T>::length,
946 libreoffice_internal::ConstCharArrayDetector<T>::length)
947 == 0;
948 }
949 #endif
950
967 sal_Int32 compareToAscii( const sal_Char* asciiStr ) const
968 {
969 return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length, asciiStr );
970 }
971
994 SAL_DEPRECATED(
995 "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
996 sal_Int32 compareToAscii( const sal_Char * asciiStr, sal_Int32 maxLength ) const
997 {
998 return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer, pData->length,
999 asciiStr, maxLength );
1000 }
1001
1021 sal_Int32 reverseCompareToAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
1022 {
1023 return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
1024 asciiStr, asciiStrLength );
1025 }
1026
1042 bool equalsAscii( const sal_Char* asciiStr ) const
1043 {
1044 return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length,
1045 asciiStr ) == 0;
1046 }
1047
1065 bool equalsAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength ) const
1066 {
1067 if ( pData->length != asciiStrLength )
1068 return false;
1069
1070 return rtl_ustr_asciil_reverseEquals_WithLength(
1071 pData->buffer, asciiStr, asciiStrLength );
1072 }
1073
1092 bool equalsIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const
1093 {
1094 return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1095 }
1096
1115 sal_Int32 compareToIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const
1116 {
1117 return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr );
1118 }
1119
1140 bool equalsIgnoreAsciiCaseAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
1141 {
1142 if ( pData->length != asciiStrLength )
1143 return false;
1144
1145 return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1146 }
1147
1169 bool matchAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1170 {
1171 return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1172 asciiStr, asciiStrLength ) == 0;
1173 }
1174
1175 // This overload is left undefined, to detect calls of matchAsciiL that
1176 // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1177 // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1178 // platforms):
1179 #if SAL_TYPES_SIZEOFLONG == 8
1180 void matchAsciiL(char const *, sal_Int32, rtl_TextEncoding) const;
1181 #endif
1182
1207 bool matchIgnoreAsciiCaseAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1208 {
1209 return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1210 asciiStr, asciiStrLength ) == 0;
1211 }
1212
1213 // This overload is left undefined, to detect calls of
1214 // matchIgnoreAsciiCaseAsciiL that erroneously use
1215 // RTL_CONSTASCII_USTRINGPARAM instead of RTL_CONSTASCII_STRINGPARAM (but
1216 // would lead to ambiguities on 32 bit platforms):
1217 #if SAL_TYPES_SIZEOFLONG == 8
1218 void matchIgnoreAsciiCaseAsciiL(char const *, sal_Int32, rtl_TextEncoding)
1219 const;
1220 #endif
1221
1236 bool startsWith(OUString const & str, OUString * rest = NULL) const {
1237 bool b = match(str);
1238 if (b && rest != NULL) {
1239 *rest = copy(str.getLength());
1240 }
1241 return b;
1242 }
1243
1249 template< typename T >
1250 typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWith(
1251 T & literal, OUString * rest = NULL) const
1252 {
1253 assert(
1254 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
1255 bool b
1256 = (libreoffice_internal::ConstCharArrayDetector<T>::length
1257 <= sal_uInt32(pData->length))
1258 && rtl_ustr_asciil_reverseEquals_WithLength(
1259 pData->buffer,
1260 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1261 literal),
1262 libreoffice_internal::ConstCharArrayDetector<T>::length);
1263 if (b && rest != NULL) {
1264 *rest = copy(
1265 libreoffice_internal::ConstCharArrayDetector<T>::length);
1266 }
1267 return b;
1268 }
1269
1270 #if defined LIBO_INTERNAL_ONLY
1271
1272 template<typename T>
1273 typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1274 startsWith(T & literal, OUString * rest = nullptr) const {
1275 bool b
1276 = (libreoffice_internal::ConstCharArrayDetector<T>::length
1277 <= sal_uInt32(pData->length))
1278 && (rtl_ustr_reverseCompare_WithLength(
1279 pData->buffer,
1280 libreoffice_internal::ConstCharArrayDetector<T>::length,
1281 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1282 literal),
1283 libreoffice_internal::ConstCharArrayDetector<T>::length)
1284 == 0);
1285 if (b && rest != nullptr) {
1286 *rest = copy(
1287 libreoffice_internal::ConstCharArrayDetector<T>::length);
1288 }
1289 return b;
1290 }
1291 #endif
1292
1313 bool startsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL)
1314 const
1315 {
1316 bool b = matchIgnoreAsciiCase(str);
1317 if (b && rest != NULL) {
1318 *rest = copy(str.getLength());
1319 }
1320 return b;
1321 }
1322
1328 template< typename T >
1329 typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type
1330 startsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1331 {
1332 assert(
1333 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
1334 bool b
1335 = (rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
1336 pData->buffer,
1337 libreoffice_internal::ConstCharArrayDetector<T>::length,
1338 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1339 literal),
1340 libreoffice_internal::ConstCharArrayDetector<T>::length)
1341 == 0);
1342 if (b && rest != NULL) {
1343 *rest = copy(
1344 libreoffice_internal::ConstCharArrayDetector<T>::length);
1345 }
1346 return b;
1347 }
1348
1349 #if defined LIBO_INTERNAL_ONLY
1350
1351 template<typename T>
1352 typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1353 startsWithIgnoreAsciiCase(T & literal, OUString * rest = nullptr) const {
1354 bool b
1355 = (libreoffice_internal::ConstCharArrayDetector<T>::length
1356 <= sal_uInt32(pData->length))
1357 && (rtl_ustr_compareIgnoreAsciiCase_WithLength(
1358 pData->buffer,
1359 libreoffice_internal::ConstCharArrayDetector<T>::length,
1360 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1361 literal),
1362 libreoffice_internal::ConstCharArrayDetector<T>::length)
1363 == 0);
1364 if (b && rest != nullptr) {
1365 *rest = copy(
1366 libreoffice_internal::ConstCharArrayDetector<T>::length);
1367 }
1368 return b;
1369 }
1370 #endif
1371
1386 bool endsWith(OUString const & str, OUString * rest = NULL) const {
1387 bool b = str.getLength() <= getLength()
1388 && match(str, getLength() - str.getLength());
1389 if (b && rest != NULL) {
1390 *rest = copy(0, getLength() - str.getLength());
1391 }
1392 return b;
1393 }
1394
1400 template< typename T >
1401 typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type
1402 endsWith(T & literal, OUString * rest = NULL) const
1403 {
1404 assert(
1405 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
1406 bool b
1407 = (libreoffice_internal::ConstCharArrayDetector<T>::length
1408 <= sal_uInt32(pData->length))
1409 && rtl_ustr_asciil_reverseEquals_WithLength(
1410 (pData->buffer + pData->length
1411 - libreoffice_internal::ConstCharArrayDetector<T>::length),
1412 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1413 literal),
1414 libreoffice_internal::ConstCharArrayDetector<T>::length);
1415 if (b && rest != NULL) {
1416 *rest = copy(
1417 0,
1418 (getLength()
1419 - libreoffice_internal::ConstCharArrayDetector<T>::length));
1420 }
1421 return b;
1422 }
1423
1424 #if defined LIBO_INTERNAL_ONLY
1425
1426 template<typename T>
1427 typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1428 endsWith(T & literal, OUString * rest = nullptr) const {
1429 bool b
1430 = (libreoffice_internal::ConstCharArrayDetector<T>::length
1431 <= sal_uInt32(pData->length))
1432 && (rtl_ustr_reverseCompare_WithLength(
1433 (pData->buffer + pData->length
1434 - libreoffice_internal::ConstCharArrayDetector<T>::length),
1435 libreoffice_internal::ConstCharArrayDetector<T>::length,
1436 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1437 literal),
1438 libreoffice_internal::ConstCharArrayDetector<T>::length)
1439 == 0);
1440 if (b && rest != nullptr) {
1441 *rest = copy(
1442 0,
1443 (getLength()
1444 - libreoffice_internal::ConstCharArrayDetector<T>::length));
1445 }
1446 return b;
1447 }
1448 #endif
1449
1461 inline bool endsWithAsciiL(char const * asciiStr, sal_Int32 asciiStrLength)
1462 const
1463 {
1464 return asciiStrLength <= pData->length
1465 && rtl_ustr_asciil_reverseEquals_WithLength(
1466 pData->buffer + pData->length - asciiStrLength, asciiStr,
1467 asciiStrLength);
1468 }
1469
1490 bool endsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL) const
1491 {
1492 bool b = str.getLength() <= getLength()
1493 && matchIgnoreAsciiCase(str, getLength() - str.getLength());
1494 if (b && rest != NULL) {
1495 *rest = copy(0, getLength() - str.getLength());
1496 }
1497 return b;
1498 }
1499
1505 template< typename T >
1506 typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type
1507 endsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1508 {
1509 assert(
1510 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
1511 bool b
1512 = (libreoffice_internal::ConstCharArrayDetector<T>::length
1513 <= sal_uInt32(pData->length))
1514 && (rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
1515 (pData->buffer + pData->length
1516 - libreoffice_internal::ConstCharArrayDetector<T>::length),
1517 libreoffice_internal::ConstCharArrayDetector<T>::length,
1518 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1519 literal),
1520 libreoffice_internal::ConstCharArrayDetector<T>::length)
1521 == 0);
1522 if (b && rest != NULL) {
1523 *rest = copy(
1524 0,
1525 (getLength()
1526 - libreoffice_internal::ConstCharArrayDetector<T>::length));
1527 }
1528 return b;
1529 }
1530
1531 #if defined LIBO_INTERNAL_ONLY
1532
1533 template<typename T>
1534 typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1535 endsWithIgnoreAsciiCase(T & literal, OUString * rest = nullptr) const {
1536 bool b
1537 = (libreoffice_internal::ConstCharArrayDetector<T>::length
1538 <= sal_uInt32(pData->length))
1539 && (rtl_ustr_compareIgnoreAsciiCase_WithLength(
1540 (pData->buffer + pData->length
1541 - libreoffice_internal::ConstCharArrayDetector<T>::length),
1542 libreoffice_internal::ConstCharArrayDetector<T>::length,
1543 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1544 literal),
1545 libreoffice_internal::ConstCharArrayDetector<T>::length)
1546 == 0);
1547 if (b && rest != nullptr) {
1548 *rest = copy(
1549 0,
1550 (getLength()
1551 - libreoffice_internal::ConstCharArrayDetector<T>::length));
1552 }
1553 return b;
1554 }
1555 #endif
1556
1567 inline bool endsWithIgnoreAsciiCaseAsciiL(
1568 char const * asciiStr, sal_Int32 asciiStrLength) const
1569 {
1570 return asciiStrLength <= pData->length
1571 && (rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
1572 pData->buffer + pData->length - asciiStrLength,
1573 asciiStrLength, asciiStr, asciiStrLength)
1574 == 0);
1575 }
1576
1577 friend bool operator == ( const OUString& rStr1, const OUString& rStr2 )
1578 { return rStr1.equals(rStr2); }
1579 friend bool operator == ( const OUString& rStr1, const sal_Unicode * pStr2 )
1580 { return rStr1.compareTo( pStr2 ) == 0; }
1581 friend bool operator == ( const sal_Unicode * pStr1, const OUString& rStr2 )
1582 { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
1583
1584 friend bool operator != ( const OUString& rStr1, const OUString& rStr2 )
1585 { return !(operator == ( rStr1, rStr2 )); }
1586 friend bool operator != ( const OUString& rStr1, const sal_Unicode * pStr2 )
1587 { return !(operator == ( rStr1, pStr2 )); }
1588 friend bool operator != ( const sal_Unicode * pStr1, const OUString& rStr2 )
1589 { return !(operator == ( pStr1, rStr2 )); }
1590
1591 friend bool operator < ( const OUString& rStr1, const OUString& rStr2 )
1592 { return rStr1.compareTo( rStr2 ) < 0; }
1593 friend bool operator > ( const OUString& rStr1, const OUString& rStr2 )
1594 { return rStr1.compareTo( rStr2 ) > 0; }
1595 friend bool operator <= ( const OUString& rStr1, const OUString& rStr2 )
1596 { return rStr1.compareTo( rStr2 ) <= 0; }
1597 friend bool operator >= ( const OUString& rStr1, const OUString& rStr2 )
1598 { return rStr1.compareTo( rStr2 ) >= 0; }
1599
1607 template< typename T >
1608 friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==( const OUString& rString, T& literal )
1609 {
1610 assert(
1611 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
1612 return rString.equalsAsciiL(
1613 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
1614 libreoffice_internal::ConstCharArrayDetector<T>::length);
1615 }
1623 template< typename T >
1624 friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==( T& literal, const OUString& rString )
1625 {
1626 assert(
1627 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
1628 return rString.equalsAsciiL(
1629 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
1630 libreoffice_internal::ConstCharArrayDetector<T>::length);
1631 }
1639 template< typename T >
1640 friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=( const OUString& rString, T& literal )
1641 {
1642 assert(
1643 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
1644 return !rString.equalsAsciiL(
1645 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
1646 libreoffice_internal::ConstCharArrayDetector<T>::length);
1647 }
1655 template< typename T >
1656 friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=( T& literal, const OUString& rString )
1657 {
1658 assert(
1659 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
1660 return !rString.equalsAsciiL(
1661 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
1662 libreoffice_internal::ConstCharArrayDetector<T>::length);
1663 }
1664
1665 #if defined LIBO_INTERNAL_ONLY
1666
1667 template<typename T> friend inline
1668 typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1669 operator ==(OUString & string, T & literal) {
1670 return
1671 rtl_ustr_reverseCompare_WithLength(
1672 string.pData->buffer, string.pData->length,
1673 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1674 literal),
1675 libreoffice_internal::ConstCharArrayDetector<T>::length)
1676 == 0;
1677 }
1679 template<typename T> friend inline
1680 typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1681 operator ==(T & literal, OUString & string) {
1682 return
1683 rtl_ustr_reverseCompare_WithLength(
1684 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1685 literal),
1686 libreoffice_internal::ConstCharArrayDetector<T>::length,
1687 string.pData->buffer, string.pData->length)
1688 == 0;
1689 }
1691 template<typename T> friend inline
1692 typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1693 operator !=(OUString & string, T & literal) {
1694 return
1695 rtl_ustr_reverseCompare_WithLength(
1696 string.pData->buffer, string.pData->length,
1697 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1698 literal),
1699 libreoffice_internal::ConstCharArrayDetector<T>::length)
1700 != 0;
1701 }
1703 template<typename T> friend inline
1704 typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1705 operator !=(T & literal, OUString & string) {
1706 return
1707 rtl_ustr_reverseCompare_WithLength(
1708 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1709 literal),
1710 libreoffice_internal::ConstCharArrayDetector<T>::length,
1711 string.pData->buffer, string.pData->length)
1712 != 0;
1713 }
1714 #endif
1715
1716 #if defined LIBO_INTERNAL_ONLY
1717
1719 /* Comparison between OUString and OUStringLiteral.
1720
1721 @since LibreOffice 5.0
1722 */
1723
1724 friend bool operator ==(OUString const & lhs, OUStringLiteral const & rhs) {
1725 return lhs.equalsAsciiL(rhs.data, rhs.size);
1726 }
1727
1728 friend bool operator !=(OUString const & lhs, OUStringLiteral const & rhs) {
1729 return !lhs.equalsAsciiL(rhs.data, rhs.size);
1730 }
1731
1732 friend bool operator <(OUString const & lhs, OUStringLiteral const & rhs) {
1733 return
1734 (rtl_ustr_ascii_compare_WithLength(
1735 lhs.pData->buffer, lhs.pData->length, rhs.data))
1736 < 0;
1737 }
1738
1739 friend bool operator <=(OUString const & lhs, OUStringLiteral const & rhs) {
1740 return
1741 (rtl_ustr_ascii_compare_WithLength(
1742 lhs.pData->buffer, lhs.pData->length, rhs.data))
1743 <= 0;
1744 }
1745
1746 friend bool operator >(OUString const & lhs, OUStringLiteral const & rhs) {
1747 return
1748 (rtl_ustr_ascii_compare_WithLength(
1749 lhs.pData->buffer, lhs.pData->length, rhs.data))
1750 > 0;
1751 }
1752
1753 friend bool operator >=(OUString const & lhs, OUStringLiteral const & rhs) {
1754 return
1755 (rtl_ustr_ascii_compare_WithLength(
1756 lhs.pData->buffer, lhs.pData->length, rhs.data))
1757 >= 0;
1758 }
1759
1760 friend bool operator ==(OUStringLiteral const & lhs, OUString const & rhs) {
1761 return rhs.equalsAsciiL(lhs.data, lhs.size);
1762 }
1763
1764 friend bool operator !=(OUStringLiteral const & lhs, OUString const & rhs) {
1765 return !rhs.equalsAsciiL(lhs.data, lhs.size);
1766 }
1767
1768 friend bool operator <(OUStringLiteral const & lhs, OUString const & rhs) {
1769 return
1770 (rtl_ustr_ascii_compare_WithLength(
1771 rhs.pData->buffer, rhs.pData->length, lhs.data))
1772 >= 0;
1773 }
1774
1775 friend bool operator <=(OUStringLiteral const & lhs, OUString const & rhs) {
1776 return
1777 (rtl_ustr_ascii_compare_WithLength(
1778 rhs.pData->buffer, rhs.pData->length, lhs.data))
1779 > 0;
1780 }
1781
1782 friend bool operator >(OUStringLiteral const & lhs, OUString const & rhs) {
1783 return
1784 (rtl_ustr_ascii_compare_WithLength(
1785 rhs.pData->buffer, rhs.pData->length, lhs.data))
1786 <= 0;
1787 }
1788
1789 friend bool operator >=(OUStringLiteral const & lhs, OUString const & rhs) {
1790 return
1791 (rtl_ustr_ascii_compare_WithLength(
1792 rhs.pData->buffer, rhs.pData->length, lhs.data))
1793 < 0;
1794 }
1795
1797 #endif
1798
1806 sal_Int32 hashCode() const
1807 {
1808 return rtl_ustr_hashCode_WithLength( pData->buffer, pData->length );
1809 }
1810
1824 sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
1825 {
1826 sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1827 return (ret < 0 ? ret : ret+fromIndex);
1828 }
1829
1839 sal_Int32 lastIndexOf( sal_Unicode ch ) const
1840 {
1841 return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1842 }
1843
1856 sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
1857 {
1858 return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1859 }
1860
1876 sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
1877 {
1878 sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1879 str.pData->buffer, str.pData->length );
1880 return (ret < 0 ? ret : ret+fromIndex);
1881 }
1882
1888 template< typename T >
1889 typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1890 {
1891 assert(
1892 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
1893 sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
1894 pData->buffer + fromIndex, pData->length - fromIndex,
1895 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
1896 libreoffice_internal::ConstCharArrayDetector<T>::length);
1897 return n < 0 ? n : n + fromIndex;
1898 }
1899
1900 #if defined LIBO_INTERNAL_ONLY
1901
1902 template<typename T>
1903 typename
1904 libreoffice_internal::ConstCharArrayDetector<T, sal_Int32>::TypeUtf16
1905 indexOf(T & literal, sal_Int32 fromIndex = 0) const {
1906 assert(fromIndex >= 0);
1907 auto n = rtl_ustr_indexOfStr_WithLength(
1908 pData->buffer + fromIndex, pData->length - fromIndex,
1909 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
1910 libreoffice_internal::ConstCharArrayDetector<T>::length);
1911 return n < 0 ? n : n + fromIndex;
1912 }
1913 #endif
1914
1938 sal_Int32 indexOfAsciiL(
1939 char const * str, sal_Int32 len, sal_Int32 fromIndex = 0) const
1940 {
1941 sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
1942 pData->buffer + fromIndex, pData->length - fromIndex, str, len);
1943 return ret < 0 ? ret : ret + fromIndex;
1944 }
1945
1946 // This overload is left undefined, to detect calls of indexOfAsciiL that
1947 // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1948 // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1949 // platforms):
1950 #if SAL_TYPES_SIZEOFLONG == 8
1951 void indexOfAsciiL(char const *, sal_Int32 len, rtl_TextEncoding) const;
1952 #endif
1953
1969 sal_Int32 lastIndexOf( const OUString & str ) const
1970 {
1971 return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1972 str.pData->buffer, str.pData->length );
1973 }
1974
1992 sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
1993 {
1994 return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1995 str.pData->buffer, str.pData->length );
1996 }
1997
2003 template< typename T >
2004 typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type lastIndexOf( T& literal ) const
2005 {
2006 assert(
2007 libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
2008 return rtl_ustr_lastIndexOfAscii_WithLength(
2009 pData->buffer, pData->length,
2010 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
2011 libreoffice_internal::ConstCharArrayDetector<T>::length);
2012 }
2013
2014 #if defined LIBO_INTERNAL_ONLY
2015
2016 template<typename T>
2017 typename
2018 libreoffice_internal::ConstCharArrayDetector<T, sal_Int32>::TypeUtf16
2019 lastIndexOf(T & literal) const {
2020 return rtl_ustr_lastIndexOfStr_WithLength(
2021 pData->buffer, pData->length,
2022 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
2023 libreoffice_internal::ConstCharArrayDetector<T>::length);
2024 }
2025 #endif
2026
2046 sal_Int32 lastIndexOfAsciiL(char const * str, sal_Int32 len) const
2047 {
2048 return rtl_ustr_lastIndexOfAscii_WithLength(
2049 pData->buffer, pData->length, str, len);
2050 }
2051
2062 SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex ) const
2063 {
2064 rtl_uString *pNew = NULL;
2065 rtl_uString_newFromSubString( &pNew, pData, beginIndex, getLength() - beginIndex );
2066 return OUString( pNew, SAL_NO_ACQUIRE );
2067 }
2068
2081 SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const
2082 {
2083 rtl_uString *pNew = NULL;
2084 rtl_uString_newFromSubString( &pNew, pData, beginIndex, count );
2085 return OUString( pNew, SAL_NO_ACQUIRE );
2086 }
2087
2096 SAL_WARN_UNUSED_RESULT OUString concat( const OUString & str ) const
2097 {
2098 rtl_uString* pNew = NULL;
2099 rtl_uString_newConcat( &pNew, pData, str.pData );
2100 return OUString( pNew, SAL_NO_ACQUIRE );
2101 }
2102
2103 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2104 friend OUString operator+( const OUString& rStr1, const OUString& rStr2 )
2105 {
2106 return rStr1.concat( rStr2 );
2107 }
2108 #endif
2109
2123 SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const
2124 {
2125 rtl_uString* pNew = NULL;
2126 rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
2127 return OUString( pNew, SAL_NO_ACQUIRE );
2128 }
2129
2143 SAL_WARN_UNUSED_RESULT OUString replace( sal_Unicode oldChar, sal_Unicode newChar ) const
2144 {
2145 rtl_uString* pNew = NULL;
2146 rtl_uString_newReplace( &pNew, pData, oldChar, newChar );
2147 return OUString( pNew, SAL_NO_ACQUIRE );
2148 }
2149
2168 SAL_WARN_UNUSED_RESULT OUString replaceFirst(
2169 OUString const & from, OUString const & to, sal_Int32 * index = NULL) const
2170 {
2171 rtl_uString * s = NULL;
2172 sal_Int32 i = 0;
2173 rtl_uString_newReplaceFirst(
2174 &s, pData, from.pData, to.pData, index == NULL ? &i : index);
2175 return OUString(s, SAL_NO_ACQUIRE);
2176 }
2177
2196 template< typename T >
2197 SAL_WARN_UNUSED_RESULT typename libreoffice_internal::ConstCharArrayDetector< T, OUString >::Type replaceFirst( T& from, OUString const & to,
2198 sal_Int32 * index = NULL) const
2199 {
2200 assert(libreoffice_internal::ConstCharArrayDetector<T>::isValid(from));
2201 rtl_uString * s = NULL;
2202 sal_Int32 i = 0;
2203 rtl_uString_newReplaceFirstAsciiL(
2204 &s, pData,
2205 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(from),
2206 libreoffice_internal::ConstCharArrayDetector<T>::length, to.pData,
2207 index == NULL ? &i : index);
2208 return OUString(s, SAL_NO_ACQUIRE);
2209 }
2210
2229 template< typename T >
2230 SAL_WARN_UNUSED_RESULT typename libreoffice_internal::ConstCharArrayDetector< T, OUString >::Type replaceFirst( OUString const & from, T& to,
2231 sal_Int32 * index = NULL) const
2232 {
2233 assert(libreoffice_internal::ConstCharArrayDetector<T>::isValid(to));
2234 rtl_uString * s = NULL;
2235 sal_Int32 i = 0;
2236 rtl_uString_newReplaceFirstToAsciiL(
2237 &s, pData, from.pData,
2238 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(to),
2239 libreoffice_internal::ConstCharArrayDetector<T>::length,
2240 index == NULL ? &i : index);
2241 return OUString(s, SAL_NO_ACQUIRE);
2242 }
2243
2262 template< typename T1, typename T2 >
2263 SAL_WARN_UNUSED_RESULT typename libreoffice_internal::ConstCharArrayDetector< T1, typename libreoffice_internal::ConstCharArrayDetector< T2, OUString >::Type >::Type
2264 replaceFirst( T1& from, T2& to, sal_Int32 * index = NULL) const
2265 {
2266 assert(libreoffice_internal::ConstCharArrayDetector<T1>::isValid(from));
2267 assert(libreoffice_internal::ConstCharArrayDetector<T2>::isValid(to));
2268 rtl_uString * s = NULL;
2269 sal_Int32 i = 0;
2270 rtl_uString_newReplaceFirstAsciiLAsciiL(
2271 &s, pData,
2272 libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2273 libreoffice_internal::ConstCharArrayDetector<T1>::length,
2274 libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2275 libreoffice_internal::ConstCharArrayDetector<T2>::length,
2276 index == NULL ? &i : index);
2277 return OUString(s, SAL_NO_ACQUIRE);
2278 }
2279
2280 #if defined LIBO_INTERNAL_ONLY
2281
2282 template<typename T> SAL_WARN_UNUSED_RESULT
2283 typename
2284 libreoffice_internal::ConstCharArrayDetector<T, OUString>::TypeUtf16
2285 replaceFirst(T & from, OUString const & to, sal_Int32 * index = nullptr)
2286 const
2287 {
2288 rtl_uString * s = nullptr;
2289 sal_Int32 i = 0;
2290 rtl_uString_newReplaceFirstUtf16LUtf16L(
2291 &s, pData,
2292 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(from),
2293 libreoffice_internal::ConstCharArrayDetector<T>::length,
2294 to.pData->buffer, to.pData->length, index == nullptr ? &i : index);
2295 if (s == nullptr) {
2296 throw std::bad_alloc();
2297 // should be std::length_error if resulting would be too large
2298 }
2299 return OUString(s, SAL_NO_ACQUIRE);
2300 }
2302 template<typename T> SAL_WARN_UNUSED_RESULT
2303 typename
2304 libreoffice_internal::ConstCharArrayDetector<T, OUString>::TypeUtf16
2305 replaceFirst(OUString const & from, T & to, sal_Int32 * index = nullptr)
2306 const
2307 {
2308 rtl_uString * s = nullptr;
2309 sal_Int32 i = 0;
2310 rtl_uString_newReplaceFirstUtf16LUtf16L(
2311 &s, pData, from.pData->buffer, from.pData->length,
2312 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(to),
2313 libreoffice_internal::ConstCharArrayDetector<T>::length,
2314 index == nullptr ? &i : index);
2315 if (s == nullptr) {
2316 throw std::bad_alloc();
2317 // should be std::length_error if resulting would be too large
2318 }
2319 return OUString(s, SAL_NO_ACQUIRE);
2320 }
2322 template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2323 typename
2324 libreoffice_internal::ConstCharArrayDetector<
2325 T1,
2326 typename libreoffice_internal::ConstCharArrayDetector<
2327 T2, OUString>::TypeUtf16
2328 >::TypeUtf16
2329 replaceFirst(T1 & from, T2 & to, sal_Int32 * index = nullptr) const {
2330 rtl_uString * s = nullptr;
2331 sal_Int32 i = 0;
2332 rtl_uString_newReplaceFirstUtf16LUtf16L(
2333 &s, pData,
2334 libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2335 libreoffice_internal::ConstCharArrayDetector<T1>::length,
2336 libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2337 libreoffice_internal::ConstCharArrayDetector<T2>::length,
2338 index == nullptr ? &i : index);
2339 if (s == nullptr) {
2340 throw std::bad_alloc();
2341 // should be std::length_error if resulting would be too large
2342 }
2343 return OUString(s, SAL_NO_ACQUIRE);
2344 }
2346 template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2347 typename
2348 libreoffice_internal::ConstCharArrayDetector<
2349 T1,
2350 typename libreoffice_internal::ConstCharArrayDetector<
2351 T2, OUString>::Type
2352 >::TypeUtf16
2353 replaceFirst(T1 & from, T2 & to, sal_Int32 * index = nullptr) const {
2354 rtl_uString * s = nullptr;
2355 sal_Int32 i = 0;
2356 rtl_uString_newReplaceFirstUtf16LAsciiL(
2357 &s, pData,
2358 libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2359 libreoffice_internal::ConstCharArrayDetector<T1>::length,
2360 libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2361 libreoffice_internal::ConstCharArrayDetector<T2>::length,
2362 index == nullptr ? &i : index);
2363 if (s == nullptr) {
2364 throw std::bad_alloc();
2365 // should be std::length_error if resulting would be too large
2366 }
2367 return OUString(s, SAL_NO_ACQUIRE);
2368 }
2370 template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2371 typename
2372 libreoffice_internal::ConstCharArrayDetector<
2373 T1,
2374 typename libreoffice_internal::ConstCharArrayDetector<
2375 T2, OUString>::TypeUtf16
2376 >::Type
2377 replaceFirst(T1 & from, T2 & to, sal_Int32 * index = nullptr) const {
2378 rtl_uString * s = nullptr;
2379 sal_Int32 i = 0;
2380 rtl_uString_newReplaceFirstAsciiLUtf16L(
2381 &s, pData,
2382 libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2383 libreoffice_internal::ConstCharArrayDetector<T1>::length,
2384 libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2385 libreoffice_internal::ConstCharArrayDetector<T2>::length,
2386 index == nullptr ? &i : index);
2387 if (s == nullptr) {
2388 throw std::bad_alloc();
2389 // should be std::length_error if resulting would be too large
2390 }
2391 return OUString(s, SAL_NO_ACQUIRE);
2392 }
2393 #endif
2394
2410 SAL_WARN_UNUSED_RESULT OUString replaceAll(
2411 OUString const & from, OUString const & to, sal_Int32 fromIndex = 0) const
2412 {
2413 rtl_uString * s = NULL;
2414 rtl_uString_newReplaceAllFromIndex(&s, pData, from.pData, to.pData, fromIndex);
2415 return OUString(s, SAL_NO_ACQUIRE);
2416 }
2417
2431 template< typename T >
2432 SAL_WARN_UNUSED_RESULT typename libreoffice_internal::ConstCharArrayDetector< T, OUString >::Type replaceAll( T& from, OUString const & to) const
2433 {
2434 assert(libreoffice_internal::ConstCharArrayDetector<T>::isValid(from));
2435 rtl_uString * s = NULL;
2436 rtl_uString_newReplaceAllAsciiL(
2437 &s, pData,
2438 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(from),
2439 libreoffice_internal::ConstCharArrayDetector<T>::length, to.pData);
2440 return OUString(s, SAL_NO_ACQUIRE);
2441 }
2442
2456 template< typename T >
2457 SAL_WARN_UNUSED_RESULT typename libreoffice_internal::ConstCharArrayDetector< T, OUString >::Type replaceAll( OUString const & from, T& to) const
2458 {
2459 assert(libreoffice_internal::ConstCharArrayDetector<T>::isValid(to));
2460 rtl_uString * s = NULL;
2461 rtl_uString_newReplaceAllToAsciiL(
2462 &s, pData, from.pData,
2463 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(to),
2464 libreoffice_internal::ConstCharArrayDetector<T>::length);
2465 return OUString(s, SAL_NO_ACQUIRE);
2466 }
2467
2481 template< typename T1, typename T2 >
2482 SAL_WARN_UNUSED_RESULT typename libreoffice_internal::ConstCharArrayDetector< T1, typename libreoffice_internal::ConstCharArrayDetector< T2, OUString >::Type >::Type
2483 replaceAll( T1& from, T2& to ) const
2484 {
2485 assert(libreoffice_internal::ConstCharArrayDetector<T1>::isValid(from));
2486 assert(libreoffice_internal::ConstCharArrayDetector<T2>::isValid(to));
2487 rtl_uString * s = NULL;
2488 rtl_uString_newReplaceAllAsciiLAsciiL(
2489 &s, pData,
2490 libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2491 libreoffice_internal::ConstCharArrayDetector<T1>::length,
2492 libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2493 libreoffice_internal::ConstCharArrayDetector<T2>::length);
2494 return OUString(s, SAL_NO_ACQUIRE);
2495 }
2496
2497 #if defined LIBO_INTERNAL_ONLY
2498
2499 template<typename T> SAL_WARN_UNUSED_RESULT
2500 typename
2501 libreoffice_internal::ConstCharArrayDetector<T, OUString>::TypeUtf16
2502 replaceAll(T & from, OUString const & to) const {
2503 rtl_uString * s = nullptr;
2504 rtl_uString_newReplaceAllUtf16LUtf16L(
2505 &s, pData,
2506 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(from),
2507 libreoffice_internal::ConstCharArrayDetector<T>::length,
2508 to.pData->buffer, to.pData->length);
2509 if (s == nullptr) {
2510 throw std::bad_alloc();
2511 // should be std::length_error if resulting would be too large
2512 }
2513 return OUString(s, SAL_NO_ACQUIRE);
2514 }
2516 template<typename T> SAL_WARN_UNUSED_RESULT
2517 typename
2518 libreoffice_internal::ConstCharArrayDetector<T, OUString>::TypeUtf16
2519 replaceAll(OUString const & from, T & to) const {
2520 rtl_uString * s = nullptr;
2521 rtl_uString_newReplaceAllUtf16LUtf16L(
2522 &s, pData, from.pData->buffer, from.pData->length,
2523 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(to),
2524 libreoffice_internal::ConstCharArrayDetector<T>::length);
2525 if (s == nullptr) {
2526 throw std::bad_alloc();
2527 // should be std::length_error if resulting would be too large
2528 }
2529 return OUString(s, SAL_NO_ACQUIRE);
2530 }
2532 template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2533 typename
2534 libreoffice_internal::ConstCharArrayDetector<
2535 T1,
2536 typename libreoffice_internal::ConstCharArrayDetector<
2537 T2, OUString>::TypeUtf16
2538 >::TypeUtf16
2539 replaceAll(T1 & from, T2 & to) const {
2540 rtl_uString * s = nullptr;
2541 rtl_uString_newReplaceAllUtf16LUtf16L(
2542 &s, pData,
2543 libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2544 libreoffice_internal::ConstCharArrayDetector<T1>::length,
2545 libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2546 libreoffice_internal::ConstCharArrayDetector<T2>::length);
2547 if (s == nullptr) {
2548 throw std::bad_alloc();
2549 // should be std::length_error if resulting would be too large
2550 }
2551 return OUString(s, SAL_NO_ACQUIRE);
2552 }
2554 template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2555 typename
2556 libreoffice_internal::ConstCharArrayDetector<
2557 T1,
2558 typename libreoffice_internal::ConstCharArrayDetector<
2559 T2, OUString>::Type
2560 >::TypeUtf16
2561 replaceAll(T1 & from, T2 & to) const {
2562 rtl_uString * s = nullptr;
2563 rtl_uString_newReplaceAllUtf16LAsciiL(
2564 &s, pData,
2565 libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2566 libreoffice_internal::ConstCharArrayDetector<T1>::length,
2567 libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2568 libreoffice_internal::ConstCharArrayDetector<T2>::length);
2569 if (s == nullptr) {
2570 throw std::bad_alloc();
2571 // should be std::length_error if resulting would be too large
2572 }
2573 return OUString(s, SAL_NO_ACQUIRE);
2574 }
2576 template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2577 typename
2578 libreoffice_internal::ConstCharArrayDetector<
2579 T1,
2580 typename libreoffice_internal::ConstCharArrayDetector<
2581 T2, OUString>::TypeUtf16
2582 >::Type
2583 replaceAll(T1 & from, T2 & to) const {
2584 rtl_uString * s = nullptr;
2585 rtl_uString_newReplaceAllAsciiLUtf16L(
2586 &s, pData,
2587 libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2588 libreoffice_internal::ConstCharArrayDetector<T1>::length,
2589 libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2590 libreoffice_internal::ConstCharArrayDetector<T2>::length);
2591 if (s == nullptr) {
2592 throw std::bad_alloc();
2593 // should be std::length_error if resulting would be too large
2594 }
2595 return OUString(s, SAL_NO_ACQUIRE);
2596 }
2597 #endif
2598
2609 SAL_WARN_UNUSED_RESULT OUString toAsciiLowerCase() const
2610 {
2611 rtl_uString* pNew = NULL;
2612 rtl_uString_newToAsciiLowerCase( &pNew, pData );
2613 return OUString( pNew, SAL_NO_ACQUIRE );
2614 }
2615
2626 SAL_WARN_UNUSED_RESULT OUString toAsciiUpperCase() const
2627 {
2628 rtl_uString* pNew = NULL;
2629 rtl_uString_newToAsciiUpperCase( &pNew, pData );
2630 return OUString( pNew, SAL_NO_ACQUIRE );
2631 }
2632
2644 SAL_WARN_UNUSED_RESULT OUString trim() const
2645 {
2646 rtl_uString* pNew = NULL;
2647 rtl_uString_newTrim( &pNew, pData );
2648 return OUString( pNew, SAL_NO_ACQUIRE );
2649 }
2650
2675 OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const
2676 {
2677 rtl_uString * pNew = NULL;
2678 index = rtl_uString_getToken( &pNew, pData, token, cTok, index );
2679 return OUString( pNew, SAL_NO_ACQUIRE );
2680 }
2681
2695 OUString getToken(sal_Int32 count, sal_Unicode separator) const {
2696 sal_Int32 n = 0;
2697 return getToken(count, separator, n);
2698 }
2699
2708 bool toBoolean() const
2709 {
2710 return rtl_ustr_toBoolean( pData->buffer );
2711 }
2712
2719 sal_Unicode toChar() const
2720 {
2721 return pData->buffer[0];
2722 }
2723
2734 sal_Int32 toInt32( sal_Int16 radix = 10 ) const
2735 {
2736 return rtl_ustr_toInt32( pData->buffer, radix );
2737 }
2738
2751 sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
2752 {
2753 return rtl_ustr_toUInt32( pData->buffer, radix );
2754 }
2755
2766 sal_Int64 toInt64( sal_Int16 radix = 10 ) const
2767 {
2768 return rtl_ustr_toInt64( pData->buffer, radix );
2769 }
2770
2783 sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
2784 {
2785 return rtl_ustr_toUInt64( pData->buffer, radix );
2786 }
2787
2796 float toFloat() const
2797 {
2798 return rtl_ustr_toFloat( pData->buffer );
2799 }
2800
2809 double toDouble() const
2810 {
2811 return rtl_ustr_toDouble( pData->buffer );
2812 }
2813
2814
2830 OUString intern() const
2831 {
2832 rtl_uString * pNew = NULL;
2833 rtl_uString_intern( &pNew, pData );
2834 if (pNew == NULL) {
2835 throw std::bad_alloc();
2836 }
2837 return OUString( pNew, SAL_NO_ACQUIRE );
2838 }
2839
2865 static OUString intern( const sal_Char * value, sal_Int32 length,
2866 rtl_TextEncoding encoding,
2867 sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS,
2868 sal_uInt32 *pInfo = NULL )
2869 {
2870 rtl_uString * pNew = NULL;
2871 rtl_uString_internConvert( &pNew, value, length, encoding,
2872 convertFlags, pInfo );
2873 if (pNew == NULL) {
2874 throw std::bad_alloc();
2875 }
2876 return OUString( pNew, SAL_NO_ACQUIRE );
2877 }
2878
2903 inline bool convertToString(OString * pTarget, rtl_TextEncoding nEncoding,
2904 sal_uInt32 nFlags) const
2905 {
2906 return rtl_convertUStringToString(&pTarget->pData, pData->buffer,
2907 pData->length, nEncoding, nFlags);
2908 }
2909
2961 inline sal_uInt32 iterateCodePoints(
2962 sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1) const
2963 {
2964 return rtl_uString_iterateCodePoints(
2965 pData, indexUtf16, incrementCodePoints);
2966 }
2967
2977 static inline OUString fromUtf8(const OString& rSource)
2978 {
2979 OUString aTarget;
2980 bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
2981 rSource.getStr(),
2982 rSource.getLength(),
2983 RTL_TEXTENCODING_UTF8,
2984 RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR|RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR|RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR);
2985 (void) bSuccess;
2986 assert(bSuccess);
2987 return aTarget;
2988 }
2989
3000 inline OString toUtf8() const
3001 {
3002 OString aTarget;
3003 bool bSuccess = rtl_convertUStringToString(&aTarget.pData,
3004 getStr(),
3005 getLength(),
3006 RTL_TEXTENCODING_UTF8,
3007 RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR|RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR);
3008 (void) bSuccess;
3009 assert(bSuccess);
3010 return aTarget;
3011 }
3012
3023 static OUString number( int i, sal_Int16 radix = 10 )
3024 {
3025 sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFINT32];
3026 rtl_uString* pNewData = NULL;
3027 rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt32( aBuf, i, radix ) );
3028 return OUString( pNewData, SAL_NO_ACQUIRE );
3029 }
3032 static OUString number( unsigned int i, sal_Int16 radix = 10 )
3033 {
3034 return number( static_cast< unsigned long long >( i ), radix );
3035 }
3038 static OUString number( long i, sal_Int16 radix = 10)
3039 {
3040 return number( static_cast< long long >( i ), radix );
3041 }
3044 static OUString number( unsigned long i, sal_Int16 radix = 10 )
3045 {
3046 return number( static_cast< unsigned long long >( i ), radix );
3047 }
3050 static OUString number( long long ll, sal_Int16 radix = 10 )
3051 {
3052 sal_Unicode aBuf[RTL_STR_MAX_VALUEOFINT64];
3053 rtl_uString* pNewData = NULL;
3054 rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt64( aBuf, ll, radix ) );
3055 return OUString( pNewData, SAL_NO_ACQUIRE );
3056 }
3059 static OUString number( unsigned long long ll, sal_Int16 radix = 10 )
3060 {
3061 sal_Unicode aBuf[RTL_STR_MAX_VALUEOFUINT64];
3062 rtl_uString* pNewData = NULL;
3063 rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfUInt64( aBuf, ll, radix ) );
3064 return OUString( pNewData, SAL_NO_ACQUIRE );
3065 }
3066
3076 static OUString number( float f )
3077 {
3078 sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFFLOAT];
3079 rtl_uString* pNewData = NULL;
3080 rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfFloat( aBuf, f ) );
3081 return OUString( pNewData, SAL_NO_ACQUIRE );
3082 }
3083
3093 static OUString number( double d )
3094 {
3095 sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFDOUBLE];
3096 rtl_uString* pNewData = NULL;
3097 rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfDouble( aBuf, d ) );
3098 return OUString( pNewData, SAL_NO_ACQUIRE );
3099 }
3100
3112 SAL_DEPRECATED("use boolean()") static OUString valueOf( sal_Bool b )
3113 {
3114 return boolean(b);
3115 }
3116
3128 static OUString boolean( bool b )
3129 {
3130 sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFBOOLEAN];
3131 rtl_uString* pNewData = NULL;
3132 rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfBoolean( aBuf, b ) );
3133 return OUString( pNewData, SAL_NO_ACQUIRE );
3134 }
3135
3143 SAL_DEPRECATED("convert to OUString or use directly") static OUString valueOf( sal_Unicode c )
3144 {
3145 return OUString( &c, 1 );
3146 }
3147
3158 SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
3159 {
3160 return number( i, radix );
3161 }
3162
3173 SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
3174 {
3175 return number( ll, radix );
3176 }
3177
3187 SAL_DEPRECATED("use number()") static OUString valueOf( float f )
3188 {
3189 return number(f);
3190 }
3191
3201 SAL_DEPRECATED("use number()") static OUString valueOf( double d )
3202 {
3203 return number(d);
3204 }
3205
3221 static OUString createFromAscii( const sal_Char * value )
3222 {
3223 rtl_uString* pNew = NULL;
3224 rtl_uString_newFromAscii( &pNew, value );
3225 return OUString( pNew, SAL_NO_ACQUIRE );
3226 }
3227 };
3228
3229 #if defined LIBO_INTERNAL_ONLY
3230 // Prevent the operator ==/!= overloads with 'sal_Unicode const *' paramter from
3231 // being selected for nonsensical code like
3232 //
3233 // if (ouIdAttr == nullptr)
3234 //
3235 void operator ==(OUString const &, std::nullptr_t) = delete;
3236 void operator ==(std::nullptr_t, OUString const &) = delete;
3237 void operator !=(OUString const &, std::nullptr_t) = delete;
3238 void operator !=(std::nullptr_t, OUString const &) = delete;
3239 #endif
3240
3241 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3242
3247 template<>
3248 struct ToStringHelper< OUString >
3249 {
3250 static int length( const OUString& s ) { return s.getLength(); }
3251 static sal_Unicode* addData( sal_Unicode* buffer, const OUString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
3252 static const bool allowOStringConcat = false;
3253 static const bool allowOUStringConcat = true;
3254 };
3255
3259 template<>
3260 struct ToStringHelper< OUStringLiteral >
3261 {
3262 static int length( const OUStringLiteral& str ) { return str.size; }
3263 static sal_Unicode* addData( sal_Unicode* buffer, const OUStringLiteral& str ) { return addDataLiteral( buffer, str.data, str.size ); }
3264 static const bool allowOStringConcat = false;
3265 static const bool allowOUStringConcat = true;
3266 };
3267
3271 template< typename charT, typename traits, typename T1, typename T2 >
3272 inline std::basic_ostream<charT, traits> & operator <<(
3273 std::basic_ostream<charT, traits> & stream, const OUStringConcat< T1, T2 >& concat)
3274 {
3275 return stream << OUString( concat );
3276 }
3277
3279 #endif
3280
3286 struct OUStringHash
3287 {
3297 size_t operator()(const OUString& rString) const
3298 { return (size_t)rString.hashCode(); }
3299 };
3300
3301 /* ======================================================================= */
3302
3320 inline OUString OStringToOUString( const OString & rStr,
3321 rtl_TextEncoding encoding,
3322 sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
3323 {
3324 return OUString( rStr.getStr(), rStr.getLength(), encoding, convertFlags );
3325 }
3326
3344 inline OString OUStringToOString( const OUString & rUnicode,
3345 rtl_TextEncoding encoding,
3346 sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
3347 {
3348 return OString( rUnicode.getStr(), rUnicode.getLength(), encoding, convertFlags );
3349 }
3350
3351 /* ======================================================================= */
3352
3361 template< typename charT, typename traits >
3362 inline std::basic_ostream<charT, traits> & operator <<(
3363 std::basic_ostream<charT, traits> & stream, OUString const & rString)
3364 {
3365 return stream <<
3366 OUStringToOString(rString, RTL_TEXTENCODING_UTF8).getStr();
3367 // best effort; potentially loses data due to conversion failures
3368 // (stray surrogate halves) and embedded null characters
3369 }
3370
3371 } // namespace
3372
3373 #ifdef RTL_STRING_UNITTEST
3374 namespace rtl
3375 {
3376 typedef rtlunittest::OUString OUString;
3377 }
3378 #endif
3379
3380 // In internal code, allow to use classes like OUString without having to
3381 // explicitly refer to the rtl namespace, which is kind of superfluous given
3382 // that OUString itself is namespaced by its OU prefix:
3383 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3384 using ::rtl::OUString;
3385 using ::rtl::OUStringHash;
3386 using ::rtl::OStringToOUString;
3387 using ::rtl::OUStringToOString;
3388 using ::rtl::OUStringLiteral;
3389 using ::rtl::OUStringLiteral1;
3390 #endif
3391
3392 #endif /* _RTL_USTRING_HXX */
3393
3394 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::OUString::lastIndexOf
sal_Int32 lastIndexOf(const OUString &str) const
Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the end.
Definition: ustring.hxx:1969
rtl_ustr_asciil_reverseEquals_WithLength
SAL_DLLPUBLIC sal_Bool rtl_ustr_asciil_reverseEquals_WithLength(const sal_Unicode *first, const sal_Char *second, sal_Int32 len) SAL_THROW_EXTERN_C()
Compare two strings from back to front for equality.
rtl_uString_newReplace
SAL_DLLPUBLIC void rtl_uString_newReplace(rtl_uString **newStr, rtl_uString *str, sal_Unicode oldChar, sal_Unicode newChar) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a single character within another string...
OUSTRING_TO_OSTRING_CVTFLAGS
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1324
rtl_uString_iterateCodePoints
SAL_DLLPUBLIC sal_uInt32 rtl_uString_iterateCodePoints(rtl_uString const *string, sal_Int32 *indexUtf16, sal_Int32 incrementCodePoints)
Iterate through a string based on code points instead of UTF-16 code units.
string.h
rtl::OUString::matchIgnoreAsciiCase
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:921
rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Char *second, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters, ignoring the case of ASCII characters...
rtl::OUString::createFromAscii
static OUString createFromAscii(const sal_Char *value)
Returns a OUString copied without conversion from an ASCII character string.
Definition: ustring.hxx:3221
rtl_ustr_indexOfStr_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfStr_WithLength(const sal_Unicode *str, sal_Int32 len, const sal_Unicode *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of a substring within a string.
rtl::OUString::lastIndexOfAsciiL
sal_Int32 lastIndexOfAsciiL(char const *str, sal_Int32 len) const
Returns the index within this string of the last occurrence of the specified ASCII substring...
Definition: ustring.hxx:2046
rtl_TextEncoding
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:39
rtl::OUString::isEmpty
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:616
rtl::OUString::number
static OUString number(unsigned long i, sal_Int16 radix=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:3044
rtl::OUString::equalsAscii
bool equalsAscii(const sal_Char *asciiStr) const
Perform a comparison of two strings.
Definition: ustring.hxx:1042
RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:64
rtl_ustr_lastIndexOfAscii_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfAscii_WithLength(sal_Unicode const *str, sal_Int32 len, char const *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of an ASCII substring within a string.
rtl_uString_newReplaceAllUtf16LAsciiL
SAL_DLLPUBLIC void rtl_uString_newReplaceAllUtf16LAsciiL(rtl_uString **newStr, rtl_uString *str, sal_Unicode const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
rtl_uString_newReplaceAllAsciiLAsciiL
SAL_DLLPUBLIC void rtl_uString_newReplaceAllAsciiLAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
rtl_uString_new
SAL_DLLPUBLIC void rtl_uString_new(rtl_uString **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
rtl::OUString::toInt32
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: ustring.hxx:2734
rtl_ustr_toBoolean
SAL_DLLPUBLIC sal_Bool rtl_ustr_toBoolean(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
rtl_uString_newReplaceFirst
SAL_DLLPUBLIC void rtl_uString_newReplaceFirst(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, rtl_uString const *to, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
rtl_uString_newReplaceFirstUtf16LAsciiL
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstUtf16LAsciiL(rtl_uString **newStr, rtl_uString *str, sal_Unicode const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
RTL_STR_MAX_VALUEOFUINT64
#define RTL_STR_MAX_VALUEOFUINT64
Definition: string.h:673
rtl_uString_newReplaceAllUtf16LUtf16L
SAL_DLLPUBLIC void rtl_uString_newReplaceAllUtf16LUtf16L(rtl_uString **newStr, rtl_uString *str, sal_Unicode const *from, sal_Int32 fromLength, sal_Unicode const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
rtl::OUString::copy
SAL_WARN_UNUSED_RESULT OUString copy(sal_Int32 beginIndex, sal_Int32 count) const
Returns a new string that is a substring of this string.
Definition: ustring.hxx:2081
rtl_ustr_hashCode_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_hashCode_WithLength(const sal_Unicode *str, sal_Int32 len) SAL_THROW_EXTERN_C()
Return a hash code for a string.
rtl::OUString::startsWithIgnoreAsciiCase
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWithIgnoreAsciiCase(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1330
rtl::libreoffice_internal::ConstCharArrayDetector
Definition: stringutils.hxx:158
RTL_STR_MAX_VALUEOFINT64
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:650
rtl_string2UString
SAL_DLLPUBLIC void rtl_string2UString(rtl_uString **newStr, const sal_Char *str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags) SAL_THROW_EXTERN_C()
Create a new Unicode string by converting a byte string, using a specific text encoding.
rtl::OUString::matchIgnoreAsciiCaseAsciiL
bool matchIgnoreAsciiCaseAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string, ignoring the case of ASCII letters.
Definition: ustring.hxx:1207
rtl_uString_newReplaceFirstAsciiLUtf16L
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstAsciiLUtf16L(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, sal_Unicode const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
rtl::OUString::clear
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: ustring.hxx:593
rtl_ustr_valueOfFloat
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfFloat(sal_Unicode *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
rtl::OUString::intern
OUString intern() const
Return a canonical representation for a string.
Definition: ustring.hxx:2830
rtl_uString_newFromSubString
SAL_DLLPUBLIC void rtl_uString_newFromSubString(rtl_uString **newStr, const rtl_uString *from, sal_Int32 beginIndex, sal_Int32 count) SAL_THROW_EXTERN_C()
Allocate a new string that is a substring of this string.
rtl::OUString::compareToIgnoreAsciiCaseAscii
sal_Int32 compareToIgnoreAsciiCaseAscii(const sal_Char *asciiStr) const
Compares two ASCII strings ignoring case.
Definition: ustring.hxx:1115
rtl_uString_newConcatAsciiL
SAL_DLLPUBLIC void rtl_uString_newConcatAsciiL(rtl_uString **newString, rtl_uString *left, char const *right, sal_Int32 rightLength)
Create a new string that is the concatenation of two other strings.
rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(sal_Unicode const *first, sal_Int32 firstLen, char const *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
rtl::OUString::number
static OUString number(double d)
Returns the string representation of the double argument.
Definition: ustring.hxx:3093
rtl_ustr_indexOfAscii_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfAscii_WithLength(sal_Unicode const *str, sal_Int32 len, char const *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of an ASCII substring within a string.
rtl_ustr_ascii_compare_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_compare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Char *second) SAL_THROW_EXTERN_C()
Compare two strings.
rtl::OUString::number
static OUString number(unsigned long long ll, sal_Int16 radix=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:3059
rtl::OUString::operator!=
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1656
rtl::OUString::OUString
OUString(rtl_uString *str)
New string from OUString data.
Definition: ustring.hxx:155
RTL_USTR_MAX_VALUEOFINT32
#define RTL_USTR_MAX_VALUEOFINT32
Definition: ustring.h:957
rtl_ustr_toDouble
SAL_DLLPUBLIC double rtl_ustr_toDouble(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a double.
rtl::OUString::indexOf
sal_Int32 indexOf(const OUString &str, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
Definition: ustring.hxx:1876
rtl::OString::getStr
const sal_Char * getStr() const
Returns a pointer to the characters of this string.
Definition: string.hxx:430
rtl::OUString::convertToString
bool convertToString(OString *pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) const
Converts to an OString, signalling failure.
Definition: ustring.hxx:2903
rtl_ustr_valueOfInt32
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfInt32(sal_Unicode *str, sal_Int32 i, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an integer.
rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength
SAL_DLLPUBLIC sal_Int32 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()
Compare two strings with a maximum count of characters, ignoring the case of ASCII characters...
rtl::OUString::toDouble
double toDouble() const
Returns the double value from this string.
Definition: ustring.hxx:2809
rtl::OUString::toBoolean
bool toBoolean() const
Returns the Boolean value from this string.
Definition: ustring.hxx:2708
rtl_ustr_indexOfChar_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfChar_WithLength(const sal_Unicode *str, sal_Int32 len, sal_Unicode ch) SAL_THROW_EXTERN_C()
Search for the first occurrence of a character within a string.
rtl::OUString::operator!=
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1640
rtl::OUString::hashCode
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: ustring.hxx:1806
rtl::OUString::equals
bool equals(const OUString &str) const
Perform a comparison of two strings.
Definition: ustring.hxx:742
rtl::OUString::startsWith
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWith(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1250
rtl::OUString::replaceAll
SAL_WARN_UNUSED_RESULT OUString replaceAll(OUString const &from, OUString const &to, sal_Int32 fromIndex=0) const
Returns a new string resulting from replacing all occurrences of a given substring with another subst...
Definition: ustring.hxx:2410
RTL_TEXTENCODING_UTF8
#define RTL_TEXTENCODING_UTF8
Definition: textenc.h:121
rtl::OUString::match
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:860
RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR
#define RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR
Definition: textcvt.h:71
rtl_uString_newFromStr
SAL_DLLPUBLIC void rtl_uString_newFromStr(rtl_uString **newStr, const sal_Unicode *value) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
SAL_DEPRECATED
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don&#39;t use, it&#39;s evil.") void doit(int nPara);.
Definition: types.h:509
SAL_WARN_UNUSED
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:624
rtl::OUString::matchAsciiL
bool matchAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:1169
rtl_ustr_valueOfInt64
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfInt64(sal_Unicode *str, sal_Int64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of a long integer.
rtl::OUString::equalsIgnoreAsciiCase
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:804
rtl_ustr_reverseCompare_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_reverseCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings from back to front.
RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR
#define RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR
Definition: textcvt.h:134
rtl::OUString::reverseCompareTo
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type reverseCompareTo(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:708
rtl::OUString::compareTo
sal_Int32 compareTo(const OUString &str, sal_Int32 maxLength) const
Compares two strings with a maximum count of characters.
Definition: ustring.hxx:678
rtl::OUString::fromUtf8
static OUString fromUtf8(const OString &rSource)
Convert an OString to an OUString, assuming that the OString is UTF-8-encoded.
Definition: ustring.hxx:2977
rtl_uString_newFromCodePoints
SAL_DLLPUBLIC void rtl_uString_newFromCodePoints(rtl_uString **newString, sal_uInt32 const *codePoints, sal_Int32 codePointCount) SAL_THROW_EXTERN_C()
Allocate a new string from an array of Unicode code points.
RTL_USTR_MAX_VALUEOFBOOLEAN
#define RTL_USTR_MAX_VALUEOFBOOLEAN
Definition: ustring.h:915
rtl::OUString::indexOfAsciiL
sal_Int32 indexOfAsciiL(char const *str, sal_Int32 len, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified ASCII substring...
Definition: ustring.hxx:1938
rtl::OUString::OUString
OUString(rtl_uString *str, __sal_NoAcquire)
New OUString from OUString data without acquiring it.
Definition: ustring.hxx:169
rtl_ustr_valueOfDouble
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfDouble(sal_Unicode *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
rtl::OUString::number
static OUString number(float f)
Returns the string representation of the float argument.
Definition: ustring.hxx:3076
rtl_uString_newReplaceAllAsciiLUtf16L
SAL_DLLPUBLIC void rtl_uString_newReplaceAllAsciiLUtf16L(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, sal_Unicode const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
rtl::OUString::replaceAll
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T, OUString >::Type replaceAll(T &from, OUString const &to) const
Returns a new string resulting from replacing all occurrences of a given substring with another subst...
Definition: ustring.hxx:2432
rtl::OUString::operator==
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1608
rtl_uString_newReplaceFirstUtf16LUtf16L
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstUtf16LUtf16L(rtl_uString **newStr, rtl_uString *str, sal_Unicode const *from, sal_Int32 fromLength, sal_Unicode const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
rtl::OUString::equalsIgnoreAsciiCaseAscii
bool equalsIgnoreAsciiCaseAscii(const sal_Char *asciiStr) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1092
rtl_ustr_ascii_shortenedCompare_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_shortenedCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Char *second, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters.
rtl::OUString::OUString
OUString(const OUString &str)
New string from OUString.
Definition: ustring.hxx:127
rtl_uString_newReplaceAllToAsciiL
SAL_DLLPUBLIC void rtl_uString_newReplaceAllToAsciiL(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, char const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
rtl::OString
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:90
rtl::OUString::trim
SAL_WARN_UNUSED_RESULT OUString trim() const
Returns a new string resulting from removing white space from both ends of the string.
Definition: ustring.hxx:2644
rtl::OUString::toInt64
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: ustring.hxx:2766
rtl_ustr_valueOfUInt64
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfUInt64(sal_Unicode *str, sal_uInt64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an unsigned long integer.
salhelper::operator<
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:96
sal_Unicode
sal_uInt16 sal_Unicode
Definition: types.h:155
rtl::OUString::compareTo
sal_Int32 compareTo(const OUString &str) const
Compares two strings.
Definition: ustring.hxx:657
rtl::OUString::matchIgnoreAsciiCase
bool matchIgnoreAsciiCase(const OUString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string, ignoring the case of ASCII letters.
Definition: ustring.hxx:908
rtl::OUString::equalsIgnoreAsciiCase
bool equalsIgnoreAsciiCase(const OUString &str) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:766
rtl::OUString::match
bool match(const OUString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:848
rtl::OUString::replaceFirst
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T, OUString >::Type replaceFirst(OUString const &from, T &to, sal_Int32 *index=NULL) const
Returns a new string resulting from replacing the first occurrence of a given substring with another ...
Definition: ustring.hxx:2230
rtl_uString_intern
SAL_DLLPUBLIC void rtl_uString_intern(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Return a canonical representation for a string.
RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:128
sal_Bool
unsigned char sal_Bool
Definition: types.h:48
rtl::OUString::lastIndexOf
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type lastIndexOf(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:2004
__sal_NoAcquire
__sal_NoAcquire
Definition: types.h:384
rtl::OUString::compareToIgnoreAsciiCase
sal_Int32 compareToIgnoreAsciiCase(const OUString &str) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:791
rtl::OUString::number
static OUString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: ustring.hxx:3023
rtl::OUString::startsWith
bool startsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: ustring.hxx:1236
rtl::OUString::operator==
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1624
ustring.h
rtl::OUString::getToken
OUString getToken(sal_Int32 token, sal_Unicode cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: ustring.hxx:2675
rtl::OUString::operator=
libreoffice_internal::ConstCharArrayDetector< T, OUString &>::Type operator=(T &literal)
Assign a new string from an 8-Bit string literal that is expected to contain only characters in the A...
Definition: ustring.hxx:459
log.hxx
RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
Definition: textcvt.h:68
rtl_uString_newToAsciiUpperCase
SAL_DLLPUBLIC void rtl_uString_newToAsciiUpperCase(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Create a new string by converting all ASCII lowercase letters to uppercase within another string...
rtl::OUString::endsWithAsciiL
bool endsWithAsciiL(char const *asciiStr, sal_Int32 asciiStrLength) const
Check whether this string ends with a given ASCII string.
Definition: ustring.hxx:1461
rtl::OUString::equalsIgnoreAsciiCaseAsciiL
bool equalsIgnoreAsciiCaseAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1140
rtl::OUString::toAsciiLowerCase
SAL_WARN_UNUSED_RESULT OUString toAsciiLowerCase() const
Converts from this string all ASCII uppercase characters (65-90) to ASCII lowercase characters (97-12...
Definition: ustring.hxx:2609
rtl::OUString::compareToAscii
sal_Int32 compareToAscii(const sal_Char *asciiStr) const
Compares two strings.
Definition: ustring.hxx:967
rtl::OUString::boolean
static OUString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: ustring.hxx:3128
rtl_ustr_lastIndexOfChar_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfChar_WithLength(const sal_Unicode *str, sal_Int32 len, sal_Unicode ch) SAL_THROW_EXTERN_C()
Search for the last occurrence of a character within a string.
rtl_ustr_compare_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_compare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings.
rtl::OUString::number
static OUString number(long i, sal_Int16 radix=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:3038
rtl::OUString::replaceAll
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T, OUString >::Type replaceAll(OUString const &from, T &to) const
Returns a new string resulting from replacing all occurrences of a given substring with another subst...
Definition: ustring.hxx:2457
rtl::OUString::OUString
OUString(sal_uInt32 const *codePoints, sal_Int32 codePointCount)
Create a new string from an array of Unicode code points.
Definition: ustring.hxx:364
rtl::OUString::replaceAt
SAL_WARN_UNUSED_RESULT OUString replaceAt(sal_Int32 index, sal_Int32 count, const OUString &newStr) const
Returns a new string resulting from replacing n = count characters from position index in this string...
Definition: ustring.hxx:2123
rtl::OUString::OUString
OUString(const sal_Unicode *value, sal_Int32 length)
New string from a Unicode character buffer array.
Definition: ustring.hxx:213
rtl::OUString::reverseCompareTo
sal_Int32 reverseCompareTo(const OUString &str) const
Compares two strings in reverse order.
Definition: ustring.hxx:696
salhelper::operator==
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:116
rtl::OUString::operator=
OUString & operator=(const OUString &str)
Assign a new string.
Definition: ustring.hxx:421
rtl::OUStringToOString
OString OUStringToOString(const OUString &rUnicode, rtl_TextEncoding encoding, sal_uInt32 convertFlags=OUSTRING_TO_OSTRING_CVTFLAGS)
Convert an OUString to an OString, using a specific text encoding.
Definition: ustring.hxx:3344
rtl_ustr_compareIgnoreAsciiCase_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_compareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
rtl_uString_newReplaceAllFromIndex
SAL_DLLPUBLIC void rtl_uString_newReplaceAllFromIndex(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, rtl_uString const *to, sal_Int32 fromIndex) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
rtl::OUString::OUString
OUString(T &literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
New string from an 8-Bit string literal that is expected to contain only characters in the ASCII set ...
Definition: ustring.hxx:235
rtl::OUString::lastIndexOf
sal_Int32 lastIndexOf(sal_Unicode ch, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified character, searching backward starting before the specified index.
Definition: ustring.hxx:1856
rtl::OUString::endsWithIgnoreAsciiCaseAsciiL
bool endsWithIgnoreAsciiCaseAsciiL(char const *asciiStr, sal_Int32 asciiStrLength) const
Check whether this string ends with a given ASCII string, ignoring the case of ASCII letters...
Definition: ustring.hxx:1567
rtl::OUString::lastIndexOf
sal_Int32 lastIndexOf(const OUString &str, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified substring, searching backward starting before the specified index.
Definition: ustring.hxx:1992
string.hxx
rtl::OUString::replaceFirst
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T1, typename libreoffice_internal::ConstCharArrayDetector< T2, OUString >::Type >::Type replaceFirst(T1 &from, T2 &to, sal_Int32 *index=NULL) const
Returns a new string resulting from replacing the first occurrence of a given substring with another ...
Definition: ustring.hxx:2264
com::sun::star::uno::operator!=
bool operator!=(const Any &rAny, const C &value)
Template unequality operator: compares set value of left side any to right side value.
Definition: Any.hxx:633
SAL_NO_ACQUIRE
definition of a no acquire enum for ctors
Definition: types.h:388
rtl_ustr_asciil_reverseCompare_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_asciil_reverseCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings from back to front.
rtl::OUStringHash::operator()
size_t operator()(const OUString &rString) const
Compute a hash code for a string.
Definition: ustring.hxx:3297
rtl_uString_newTrim
SAL_DLLPUBLIC void rtl_uString_newTrim(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Create a new string by removing white space from both ends of another string.
rtl_uString_newToAsciiLowerCase
SAL_DLLPUBLIC void rtl_uString_newToAsciiLowerCase(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Create a new string by converting all ASCII uppercase letters to lowercase within another string...
rtl::OUString::replaceAll
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T1, typename libreoffice_internal::ConstCharArrayDetector< T2, OUString >::Type >::Type replaceAll(T1 &from, T2 &to) const
Returns a new string resulting from replacing all occurrences of a given substring with another subst...
Definition: ustring.hxx:2483
rtl::OUString::endsWithIgnoreAsciiCase
bool endsWithIgnoreAsciiCase(OUString const &str, OUString *rest=NULL) const
Check whether this string ends with a given string, ignoring the case of ASCII letters.
Definition: ustring.hxx:1490
config.h
rtl::OUString::endsWith
bool endsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string ends with a given substring.
Definition: ustring.hxx:1386
rtl_ustr_valueOfBoolean
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfBoolean(sal_Unicode *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
rtl::OUString::endsWith
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type endsWith(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1402
textenc.h
rtl_uString_newReplaceFirstToAsciiL
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstToAsciiL(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, char const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
rtl_ustr_shortenedCompare_WithLength
SAL_DLLPUBLIC sal_Int32 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()
Compare two strings with a maximum count of characters.
rtl::OUString::toUInt64
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: ustring.hxx:2783
rtl::OUString::toFloat
float toFloat() const
Returns the float value from this string.
Definition: ustring.hxx:2796
rtl::OUString
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:106
rtl::OUString::copy
SAL_WARN_UNUSED_RESULT OUString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: ustring.hxx:2062
rtl::OUString::OUString
OUString(const sal_Char *value, sal_Int32 length, rtl_TextEncoding encoding, sal_uInt32 convertFlags=OSTRING_TO_OUSTRING_CVTFLAGS)
New string from an 8-Bit character buffer array.
Definition: ustring.hxx:337
rtl_ustr_lastIndexOfStr_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfStr_WithLength(const sal_Unicode *str, sal_Int32 len, const sal_Unicode *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of a substring within a string.
rtl_convertStringToUString
SAL_DLLPUBLIC sal_Bool rtl_convertStringToUString(rtl_uString **target, char const *source, sal_Int32 length, rtl_TextEncoding encoding, sal_uInt32 flags) SAL_THROW_EXTERN_C()
Converts a byte string to a Unicode string, signalling failure.
rtl::OUString::replace
SAL_WARN_UNUSED_RESULT OUString replace(sal_Unicode oldChar, sal_Unicode newChar) const
Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar...
Definition: ustring.hxx:2143
rtl::OUString::intern
static OUString intern(const sal_Char *value, sal_Int32 length, rtl_TextEncoding encoding, sal_uInt32 convertFlags=OSTRING_TO_OUSTRING_CVTFLAGS, sal_uInt32 *pInfo=NULL)
Return a canonical representation for a converted string.
Definition: ustring.hxx:2865
rtl::OUString::reverseCompareToAsciiL
sal_Int32 reverseCompareToAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Compares two strings in reverse order.
Definition: ustring.hxx:1021
rtl::operator<<
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &stream, OString const &rString)
Support for rtl::OString in std::ostream (and thus in CPPUNIT_ASSERT or SAL_INFO macros, for example).
Definition: string.hxx:1894
SAL_CONSTEXPR
#define SAL_CONSTEXPR
C++11 "constexpr" feature.
Definition: types.h:445
SAL_WARN_UNUSED_RESULT
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:325
sal_Char
char sal_Char
A legacy synonym for char.
Definition: types.h:130
rtl::OUString::operator+=
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition: ustring.hxx:499
rtl::OStringToOUString
OUString OStringToOUString(const OString &rStr, rtl_TextEncoding encoding, sal_uInt32 convertFlags=OSTRING_TO_OUSTRING_CVTFLAGS)
Convert an OString to an OUString, using a specific text encoding.
Definition: ustring.hxx:3320
RTL_USTR_MAX_VALUEOFFLOAT
#define RTL_USTR_MAX_VALUEOFFLOAT
Definition: ustring.h:1022
rtl_uString_newFromLiteral
SAL_DLLPUBLIC void rtl_uString_newFromLiteral(rtl_uString **newStr, const sal_Char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
stringutils.hxx
rtl::OUString::indexOf
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1889
salhelper::operator>
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:106
rtl_uString_newReplaceFirstAsciiLAsciiL
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstAsciiLAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
rtl::OUString::replaceFirst
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T, OUString >::Type replaceFirst(T &from, OUString const &to, sal_Int32 *index=NULL) const
Returns a new string resulting from replacing the first occurrence of a given substring with another ...
Definition: ustring.hxx:2197
rtl::OUString::replaceFirst
SAL_WARN_UNUSED_RESULT OUString replaceFirst(OUString const &from, OUString const &to, sal_Int32 *index=NULL) const
Returns a new string resulting from replacing the first occurrence of a given substring with another ...
Definition: ustring.hxx:2168
rtl::OUString::toAsciiUpperCase
SAL_WARN_UNUSED_RESULT OUString toAsciiUpperCase() const
Converts from this string all ASCII lowercase characters (97-122) to ASCII uppercase characters (65-9...
Definition: ustring.hxx:2626
rtl::OUString::getToken
OUString getToken(sal_Int32 count, sal_Unicode separator) const
Returns a token from the string.
Definition: ustring.hxx:2695
rtl::OUString::OUString
OUString(sal_Unicode value)
New string from a single Unicode character.
Definition: ustring.hxx:177
RTL_USTR_MAX_VALUEOFDOUBLE
#define RTL_USTR_MAX_VALUEOFDOUBLE
Definition: ustring.h:1041
rtl_uString_newReplaceStrAt
SAL_DLLPUBLIC void rtl_uString_newReplaceStrAt(rtl_uString **newStr, rtl_uString *str, sal_Int32 idx, sal_Int32 count, rtl_uString *subStr) SAL_THROW_EXTERN_C()
Create a new string by replacing a substring of another string.
rtl::OUString::toChar
sal_Unicode toChar() const
Returns the first character from this string.
Definition: ustring.hxx:2719
rtl_ustr_toUInt32
SAL_DLLPUBLIC sal_uInt32 rtl_ustr_toUInt32(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned integer.
rtl::libreoffice_internal::Dummy
Definition: stringutils.hxx:115
rtl::OUString::OUString
OUString(const sal_Unicode *value)
New string from a Unicode character buffer array.
Definition: ustring.hxx:199
rtl_uString_newFromAscii
SAL_DLLPUBLIC void rtl_uString_newFromAscii(rtl_uString **newStr, const sal_Char *value) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
rtl::OUString::getStr
const sal_Unicode * getStr() const
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:628
rtl::OUString::equalsAsciiL
bool equalsAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform a comparison of two strings.
Definition: ustring.hxx:1065
rtl_uString_internConvert
SAL_DLLPUBLIC void rtl_uString_internConvert(rtl_uString **newStr, const sal_Char *str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags, sal_uInt32 *pInfo) SAL_THROW_EXTERN_C()
Return a canonical representation for a string.
rtl::OUString::indexOf
sal_Int32 indexOf(sal_Unicode ch, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.
Definition: ustring.hxx:1824
rtl_uString_newReplaceAllAsciiL
SAL_DLLPUBLIC void rtl_uString_newReplaceAllAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, rtl_uString const *to) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
rtl_uString_newFromStr_WithLength
SAL_DLLPUBLIC void rtl_uString_newFromStr_WithLength(rtl_uString **newStr, const sal_Unicode *value, sal_Int32 len) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
rtl::OUString::lastIndexOf
sal_Int32 lastIndexOf(sal_Unicode ch) const
Returns the index within this string of the last occurrence of the specified character, searching backward starting at the end.
Definition: ustring.hxx:1839
rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Char *second) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
rtl_uString_newConcat
SAL_DLLPUBLIC void rtl_uString_newConcat(rtl_uString **newStr, rtl_uString *left, rtl_uString *right) SAL_THROW_EXTERN_C()
Create a new string that is the concatenation of two other strings.
stringconcat.hxx
rtl::OString::getLength
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:404
rtl::OUString::unacquired
static OUString const & unacquired(rtl_uString *const *ppHandle)
Provides an OUString const & passing a storage pointer of an rtl_uString * handle.
Definition: ustring.hxx:413
rtl
Definition: bootstrap.hxx:29
rtl::OUString::concat
SAL_WARN_UNUSED_RESULT OUString concat(const OUString &str) const
Concatenates the specified string to the end of this string.
Definition: ustring.hxx:2096
rtl::OUString::startsWithIgnoreAsciiCase
bool startsWithIgnoreAsciiCase(OUString const &str, OUString *rest=NULL) const
Check whether this string starts with a given string, ignoring the case of ASCII letters.
Definition: ustring.hxx:1313
rtl::OUString::operator+
friend OUString operator+(const OUString &rStr1, const OUString &rStr2)
Definition: ustring.hxx:2104
rtl_ustr_toUInt64
SAL_DLLPUBLIC sal_uInt64 rtl_ustr_toUInt64(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned long integer.
rtl_uString_release
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Decrement the reference count of a string.
rtl::OUString::OUString
OUString()
New string containing no characters.
Definition: ustring.hxx:116
rtl::OUString::iterateCodePoints
sal_uInt32 iterateCodePoints(sal_Int32 *indexUtf16, sal_Int32 incrementCodePoints=1) const
Iterate through this string based on code points instead of UTF-16 code units.
Definition: ustring.hxx:2961
rtl::OUString::getLength
sal_Int32 getLength() const
Returns the length of this string.
Definition: ustring.hxx:606
rtl_ustr_toInt32
SAL_DLLPUBLIC sal_Int32 rtl_ustr_toInt32(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an integer.
rtl::OUString::number
static OUString number(unsigned int i, sal_Int16 radix=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:3032
rtl_uString_newConcatUtf16L
SAL_DLLPUBLIC void rtl_uString_newConcatUtf16L(rtl_uString **newString, rtl_uString *left, sal_Unicode const *right, sal_Int32 rightLength)
Create a new string that is the concatenation of two other strings.
OSTRING_TO_OUSTRING_CVTFLAGS
#define OSTRING_TO_OUSTRING_CVTFLAGS
Definition: ustring.h:2117
rtl::OUString::toUInt32
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: ustring.hxx:2751
rtl_uString_ensureCapacity
SAL_DLLPUBLIC void rtl_uString_ensureCapacity(rtl_uString **str, sal_Int32 size) SAL_THROW_EXTERN_C()
Ensure a string has enough space for a given number of characters.
rtl::OUString::number
static OUString number(long long ll, sal_Int16 radix=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:3050
rtl_uString_alloc
SAL_DLLPUBLIC rtl_uString * rtl_uString_alloc(sal_Int32 nLen) SAL_THROW_EXTERN_C()
Allocate a new string containing space for a given number of characters.
rtl_uString_assign
SAL_DLLPUBLIC void rtl_uString_assign(rtl_uString **str, rtl_uString *rightValue) SAL_THROW_EXTERN_C()
Assign a new value to a string.
rtl_ustr_toFloat
SAL_DLLPUBLIC float rtl_ustr_toFloat(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a float.
rtl::OUStringHash
A helper to use OUStrings with hash maps.
Definition: ustring.hxx:3286
rtl_uString_newReplaceFirstAsciiL
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, rtl_uString const *to, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
rtl_uString_acquire
SAL_DLLPUBLIC void rtl_uString_acquire(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Increment the reference count of a string.
rtl::OUString::endsWithIgnoreAsciiCase
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type endsWithIgnoreAsciiCase(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1507
rtl::OUString::~OUString
~OUString()
Release the string data.
Definition: ustring.hxx:397
rtl::OUString::toUtf8
OString toUtf8() const
Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully.
Definition: ustring.hxx:3000
rtl_uString_getToken
SAL_DLLPUBLIC sal_Int32 rtl_uString_getToken(rtl_uString **newStr, rtl_uString *str, sal_Int32 token, sal_Unicode cTok, sal_Int32 idx) SAL_THROW_EXTERN_C()
Create a new string by extracting a single token from another string.
rtl_convertUStringToString
SAL_DLLPUBLIC sal_Bool rtl_convertUStringToString(rtl_String **pTarget, sal_Unicode const *pSource, sal_Int32 nLength, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) SAL_THROW_EXTERN_C()
Converts a Unicode string to a byte string, signalling failure.
rtl_ustr_toInt64
SAL_DLLPUBLIC sal_Int64 rtl_ustr_toInt64(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as a long integer.