LibreOffice
LibreOffice 7.2 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/*
21 * This file is part of LibreOffice published API.
22 */
23
24#ifndef INCLUDED_RTL_USTRING_HXX
25#define INCLUDED_RTL_USTRING_HXX
26
27#include "sal/config.h"
28
29#include <cassert>
30#include <cstddef>
31#include <cstdlib>
32#include <limits>
33#include <new>
34#include <ostream>
35#include <utility>
36
37#if defined LIBO_INTERNAL_ONLY
38#include <string_view>
39#include <type_traits>
40#endif
41
42#include "rtl/ustring.h"
43#include "rtl/string.hxx"
44#include "rtl/stringutils.hxx"
45#include "rtl/textenc.h"
46
47#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
48#include "config_global.h"
49#include "rtl/stringconcat.hxx"
50#endif
51
52#ifdef RTL_STRING_UNITTEST
53extern bool rtl_string_unittest_invalid_conversion;
54#endif
55
56// The unittest uses slightly different code to help check that the proper
57// calls are made. The class is put into a different namespace to make
58// sure the compiler generates a different (if generating also non-inline)
59// copy of the function and does not merge them together. The class
60// is "brought" into the proper rtl namespace by a typedef below.
61#ifdef RTL_STRING_UNITTEST
62#define rtl rtlunittest
63#endif
64
65namespace rtl
66{
67
68class OUStringBuffer;
69
70#ifdef RTL_STRING_UNITTEST
71#undef rtl
72#endif
73
74#if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
76
83template<std::size_t N> class SAL_WARN_UNUSED OUStringLiteral {
84 static_assert(N != 0);
85 static_assert(N - 1 <= std::numeric_limits<sal_Int32>::max(), "literal too long");
86 friend class OUString;
87
88public:
89#if HAVE_CPP_CONSTEVAL
90 consteval
91#else
92 constexpr
93#endif
94 OUStringLiteral(char16_t const (&literal)[N]) {
95 assertLayout();
96 assert(literal[N - 1] == '\0');
97 //TODO: Use C++20 constexpr std::copy_n (P0202R3):
98 for (std::size_t i = 0; i != N; ++i) {
99 more.buffer[i] = literal[i];
100 }
101 }
102
103 constexpr sal_Int32 getLength() const { return more.length; }
104
105 constexpr sal_Unicode const * getStr() const SAL_RETURNS_NONNULL { return more.buffer; }
106
107 constexpr operator std::u16string_view() const { return {more.buffer, sal_uInt32(more.length)}; }
108
109private:
110 static constexpr void assertLayout() {
111 // These static_asserts verifying the layout compatibility with rtl_uString cannot be class
112 // member declarations, as offsetof requires a complete type, so defer them to here:
113 static_assert(offsetof(OUStringLiteral, str.refCount) == offsetof(OUStringLiteral, more.refCount));
114 static_assert(offsetof(OUStringLiteral, str.length) == offsetof(OUStringLiteral, more.length));
115 static_assert(offsetof(OUStringLiteral, str.buffer) == offsetof(OUStringLiteral, more.buffer));
116 }
117
118 union {
119 rtl_uString str;
120 struct {
121 oslInterlockedCount refCount;
122 sal_Int32 length;
123 sal_Unicode buffer[N];
124 } more =
125 {
126 0x40000000, // SAL_STRING_STATIC_FLAG (sal/rtl/strimp.hxx)
127 N - 1,
128 {} //TODO: drop initialization for C++20 (P1331R2)
129 };
130 };
131};
132
133#if defined RTL_STRING_UNITTEST
134namespace libreoffice_internal {
135template<std::size_t N> struct ExceptConstCharArrayDetector<OUStringLiteral<N>> {};
136template<std::size_t N> struct ExceptCharArrayDetector<OUStringLiteral<N>> {};
137}
138#endif
139
141#endif
142
143/* ======================================================================= */
144
168class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OUString
169{
170public:
172 rtl_uString * pData;
174
179 {
180 pData = NULL;
181 rtl_uString_new( &pData );
182 }
183
189 OUString( const OUString & str )
190 {
191 pData = str.pData;
192 rtl_uString_acquire( pData );
193 }
194
195#if defined LIBO_INTERNAL_ONLY
202 OUString( OUString && str ) noexcept
203 {
204 pData = str.pData;
205 str.pData = nullptr;
206 rtl_uString_new( &str.pData );
207 }
208#endif
209
215 OUString( rtl_uString * str )
216 {
217 pData = str;
218 rtl_uString_acquire( pData );
219 }
220
229 OUString( rtl_uString * str, __sal_NoAcquire )
230 { pData = str; }
231
237 explicit OUString( sal_Unicode value )
238 : pData (NULL)
239 {
240 rtl_uString_newFromStr_WithLength( &pData, &value, 1 );
241 }
242
243#if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
245 // Catch inadvertent conversions to the above ctor (but still allow
246 // construction from char literals):
247 OUString(int) = delete;
248 explicit OUString(char c):
249 OUString(sal_Unicode(static_cast<unsigned char>(c)))
250 {}
252#endif
253
254#if defined LIBO_INTERNAL_ONLY
255
256 template<typename T> explicit OUString(
257 T const & value,
258 typename libreoffice_internal::CharPtrDetector<T, libreoffice_internal::Dummy>::TypeUtf16
259 = libreoffice_internal::Dummy()):
260 pData(nullptr)
261 { rtl_uString_newFromStr(&pData, value); }
262
263 template<typename T> explicit OUString(
264 T & value,
265 typename
266 libreoffice_internal::NonConstCharArrayDetector<T, libreoffice_internal::Dummy>::TypeUtf16
267 = libreoffice_internal::Dummy()):
268 pData(nullptr)
269 { rtl_uString_newFromStr(&pData, value); }
270
271#else
272
278 OUString( const sal_Unicode * value )
279 {
280 pData = NULL;
281 rtl_uString_newFromStr( &pData, value );
282 }
283
284#endif
285
294 OUString( const sal_Unicode * value, sal_Int32 length )
295 {
296 pData = NULL;
297 rtl_uString_newFromStr_WithLength( &pData, value, length );
298 }
299
315 template< typename T >
317 {
318 assert(
320 pData = NULL;
322 rtl_uString_new(&pData);
323 } else {
325 &pData,
327 literal),
329 }
330#ifdef RTL_STRING_UNITTEST
331 rtl_string_unittest_const_literal = true;
332#endif
333 }
334
335#if defined LIBO_INTERNAL_ONLY
337 template<typename T> OUString(
338 T & literal,
340 T, libreoffice_internal::Dummy>::TypeUtf16
342 pData(nullptr)
343 {
344 assert(
347 rtl_uString_new(&pData);
348 } else {
350 &pData,
351 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
352 literal),
353 libreoffice_internal::ConstCharArrayDetector<T>::length);
354 }
355 }
356#endif
357
358#if defined LIBO_INTERNAL_ONLY && defined RTL_STRING_UNITTEST
360
364 template< typename T >
365 OUString( T&, typename libreoffice_internal::ExceptConstCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
366 {
367 pData = NULL;
368 rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
369 rtl_string_unittest_invalid_conversion = true;
370 }
375 template< typename T >
376 OUString( const T&, typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
377 {
378 pData = NULL;
379 rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
380 rtl_string_unittest_invalid_conversion = true;
381 }
383#endif
384
385#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
387
392 template<std::size_t N> constexpr OUString(OUStringLiteral<N> const & literal):
393 pData(const_cast<rtl_uString *>(&literal.str)) {}
394 template<std::size_t N> OUString(OUStringLiteral<N> &&) = delete;
396#endif
397
412 OUString( const char * value, sal_Int32 length,
413 rtl_TextEncoding encoding,
414 sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
415 {
416 pData = NULL;
417 rtl_string2UString( &pData, value, length, encoding, convertFlags );
418 if (pData == NULL) {
419 throw std::bad_alloc();
420 }
421 }
422
439 explicit OUString(
440 sal_uInt32 const * codePoints, sal_Int32 codePointCount):
441 pData(NULL)
442 {
443 rtl_uString_newFromCodePoints(&pData, codePoints, codePointCount);
444 if (pData == NULL) {
445 throw std::bad_alloc();
446 }
447 }
448
449#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
454 template< typename T1, typename T2 >
455 OUString( OUStringConcat< T1, T2 >&& c )
456 {
457 const sal_Int32 l = c.length();
458 pData = rtl_uString_alloc( l );
459 if (l != 0)
460 {
461 sal_Unicode* end = c.addData( pData->buffer );
462 pData->length = l;
463 *end = '\0';
464 }
465 }
466
471 template< typename T >
472 OUString( OUStringNumber< T >&& n )
473 : OUString( n.buf, n.length )
474 {}
475#endif
476
477#if defined LIBO_INTERNAL_ONLY
478 explicit OUString(std::u16string_view sv) {
479 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
480 throw std::bad_alloc();
481 }
482 pData = nullptr;
483 rtl_uString_newFromStr_WithLength(&pData, sv.data(), sv.size());
484 }
485#endif
486
491 {
492 rtl_uString_release( pData );
493 }
494
506 static OUString const & unacquired( rtl_uString * const * ppHandle )
507 { return * reinterpret_cast< OUString const * >( ppHandle ); }
508
514 OUString & operator=( const OUString & str )
515 {
516 rtl_uString_assign( &pData, str.pData );
517 return *this;
518 }
519
520#if defined LIBO_INTERNAL_ONLY
527 OUString & operator=( OUString && str ) noexcept
528 {
529 rtl_uString_release( pData );
530 pData = str.pData;
531 str.pData = nullptr;
532 rtl_uString_new( &str.pData );
533 return *this;
534 }
535#endif
536
549 template< typename T >
551 {
552 assert(
555 rtl_uString_new(&pData);
556 } else {
558 &pData,
560 literal),
562 }
563 return *this;
564 }
565
566#if defined LIBO_INTERNAL_ONLY
568 template<typename T>
569 typename
571 operator =(T & literal) {
573 rtl_uString_new(&pData);
574 } else {
576 &pData,
577 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
578 literal),
579 libreoffice_internal::ConstCharArrayDetector<T>::length);
580 }
581 return *this;
582 }
583
585 template<std::size_t N> OUString & operator =(OUStringLiteral<N> const & literal) {
586 if (literal.getLength() == 0) {
587 rtl_uString_new(&pData);
588 } else {
589 rtl_uString_newFromStr_WithLength(&pData, literal.getStr(), literal.getLength());
590 }
591 return *this;
592 }
593
594 template<typename T>
595 OUString & operator =(OUStringNumber<T> && n) {
596 // n.length should never be zero, so no need to add an optimization for that case
597 rtl_uString_newFromStr_WithLength(&pData, n.buf, n.length);
598 return *this;
599 }
600
601 OUString & operator =(std::u16string_view sv) {
602 if (sv.empty()) {
603 rtl_uString_new(&pData);
604 } else {
605 rtl_uString_newFromStr_WithLength(&pData, sv.data(), sv.size());
606 }
607 return *this;
608 }
609#endif
610
611#if defined LIBO_INTERNAL_ONLY
620 inline OUString & operator+=( const OUStringBuffer & str ) &;
621#endif
622
630 OUString & operator+=( const OUString & str )
631#if defined LIBO_INTERNAL_ONLY
632 &
633#endif
634 {
635 return internalAppend(str.pData);
636 }
637#if defined LIBO_INTERNAL_ONLY
638 void operator+=(OUString const &) && = delete;
639#endif
640
647 template<typename T>
649 operator +=(T & literal)
650#if defined LIBO_INTERNAL_ONLY
651 &
652#endif
653 {
654 assert(
657 &pData, pData,
660 return *this;
661 }
662#if defined LIBO_INTERNAL_ONLY
663 template<typename T>
665 operator +=(T &) && = delete;
666#endif
667
668#if defined LIBO_INTERNAL_ONLY
670 template<typename T>
671 typename
673 operator +=(T & literal) & {
675 &pData, pData,
678 return *this;
679 }
680 template<typename T>
681 typename
682 libreoffice_internal::ConstCharArrayDetector<T, OUString &>::TypeUtf16
683 operator +=(T &) && = delete;
684
686 template<std::size_t N> OUString & operator +=(OUStringLiteral<N> const & literal) & {
687 rtl_uString_newConcatUtf16L(&pData, pData, literal.getStr(), literal.getLength());
688 return *this;
689 }
690 template<std::size_t N> void operator +=(OUStringLiteral<N> const &) && = delete;
691
692 OUString & operator +=(std::u16string_view sv) & {
693 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
694 throw std::bad_alloc();
695 }
696 rtl_uString_newConcatUtf16L(&pData, pData, sv.data(), sv.size());
697 return *this;
698 }
699 void operator +=(std::u16string_view) && = delete;
700#endif
701
702#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
707 template< typename T1, typename T2 >
708 OUString& operator+=( OUStringConcat< T1, T2 >&& c ) & {
709 sal_Int32 l = c.length();
710 if( l == 0 )
711 return *this;
712 l += pData->length;
713 rtl_uString_ensureCapacity( &pData, l );
714 sal_Unicode* end = c.addData( pData->buffer + pData->length );
715 *end = '\0';
716 pData->length = l;
717 return *this;
718 }
719 template<typename T1, typename T2> void operator +=(
720 OUStringConcat<T1, T2> &&) && = delete;
721
726 template< typename T >
727 OUString& operator+=( OUStringNumber< T >&& n ) & {
728 sal_Int32 l = n.length;
729 if( l == 0 )
730 return *this;
731 l += pData->length;
732 rtl_uString_ensureCapacity( &pData, l );
733 sal_Unicode* end = addDataHelper( pData->buffer + pData->length, n.buf, n.length );
734 *end = '\0';
735 pData->length = l;
736 return *this;
737 }
738 template<typename T> void operator +=(
739 OUStringNumber<T> &&) && = delete;
740#endif
741
746 void clear()
747 {
748 rtl_uString_new( &pData );
749 }
750
759 sal_Int32 getLength() const { return pData->length; }
760
769 bool isEmpty() const
770 {
771 return pData->length == 0;
772 }
773
781 const sal_Unicode * getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
782
792 sal_Unicode operator [](sal_Int32 index) const {
793 // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
794 assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
795 return getStr()[index];
796 }
797
810#if defined LIBO_INTERNAL_ONLY
811 sal_Int32 compareTo( std::u16string_view str ) const
812 {
813 return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
814 str.data(), str.length() );
815 }
816#else
817 sal_Int32 compareTo( const OUString & str ) const
818 {
819 return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
820 str.pData->buffer, str.pData->length );
821 }
822#endif
823
839#if defined LIBO_INTERNAL_ONLY
840 sal_Int32 compareTo( std::u16string_view str, sal_Int32 maxLength ) const
841 {
842 return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
843 str.data(), str.length(), maxLength );
844 }
845#else
846 sal_Int32 compareTo( const OUString & str, sal_Int32 maxLength ) const
847 {
848 return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
849 str.pData->buffer, str.pData->length, maxLength );
850 }
851#endif
852
865#if defined LIBO_INTERNAL_ONLY
866 sal_Int32 reverseCompareTo(std::u16string_view sv) const {
868 pData->buffer, pData->length, sv.data(), sv.size());
869 }
870#else
871 sal_Int32 reverseCompareTo( const OUString & str ) const
872 {
873 return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
874 str.pData->buffer, str.pData->length );
875 }
876#endif
877
883 template< typename T >
885 {
886 assert(
889 pData->buffer, pData->length,
892 }
893
905 bool equals( const OUString & str ) const
906 {
907 if ( pData->length != str.pData->length )
908 return false;
909 if ( pData == str.pData )
910 return true;
911 return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
912 str.pData->buffer, str.pData->length ) == 0;
913 }
914
929#if defined LIBO_INTERNAL_ONLY
930 bool equalsIgnoreAsciiCase(std::u16string_view sv) const {
931 return
933 pData->buffer, pData->length, sv.data(), sv.size())
934 == 0;
935 }
936#else
937 bool equalsIgnoreAsciiCase( const OUString & str ) const
938 {
939 if ( pData->length != str.pData->length )
940 return false;
941 if ( pData == str.pData )
942 return true;
943 return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
944 str.pData->buffer, str.pData->length ) == 0;
945 }
946#endif
947
963#if defined LIBO_INTERNAL_ONLY
964 sal_Int32 compareToIgnoreAsciiCase(std::u16string_view sv) const {
966 pData->buffer, pData->length, sv.data(), sv.size());
967 }
968#else
969 sal_Int32 compareToIgnoreAsciiCase( const OUString & str ) const
970 {
971 return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
972 str.pData->buffer, str.pData->length );
973 }
974#endif
975
981 template< typename T >
983 {
984 assert(
986 return
987 (pData->length
990 pData->buffer, pData->length,
992 literal))
993 == 0);
994 }
995
1011#if defined LIBO_INTERNAL_ONLY
1012 bool match(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
1013 return
1015 pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1016 sv.size())
1017 == 0;
1018 }
1019#else
1020 bool match( const OUString & str, sal_Int32 fromIndex = 0 ) const
1021 {
1022 return rtl_ustr_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1023 str.pData->buffer, str.pData->length, str.pData->length ) == 0;
1024 }
1025#endif
1026
1032 template< typename T >
1033 typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
1034 {
1035 assert(
1037 return
1039 pData->buffer+fromIndex, pData->length-fromIndex,
1041 literal),
1043 == 0;
1044 }
1045
1064#if defined LIBO_INTERNAL_ONLY
1065 bool matchIgnoreAsciiCase(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
1066 return
1068 pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1069 sv.size())
1070 == 0;
1071 }
1072#else
1073 bool matchIgnoreAsciiCase( const OUString & str, sal_Int32 fromIndex = 0 ) const
1074 {
1075 return rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1076 str.pData->buffer, str.pData->length,
1077 str.pData->length ) == 0;
1078 }
1079#endif
1080
1086 template< typename T >
1088 {
1089 assert(
1091 return
1093 pData->buffer+fromIndex, pData->length-fromIndex,
1095 literal),
1097 == 0;
1098 }
1099
1116 sal_Int32 compareToAscii( const char* asciiStr ) const
1117 {
1118 return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length, asciiStr );
1119 }
1120
1144 "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
1145 sal_Int32 compareToAscii( const char * asciiStr, sal_Int32 maxLength ) const
1146 {
1147 return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer, pData->length,
1148 asciiStr, maxLength );
1149 }
1150
1170 sal_Int32 reverseCompareToAsciiL( const char * asciiStr, sal_Int32 asciiStrLength ) const
1171 {
1172 return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
1173 asciiStr, asciiStrLength );
1174 }
1175
1191 bool equalsAscii( const char* asciiStr ) const
1192 {
1193 return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length,
1194 asciiStr ) == 0;
1195 }
1196
1214 bool equalsAsciiL( const char* asciiStr, sal_Int32 asciiStrLength ) const
1215 {
1216 if ( pData->length != asciiStrLength )
1217 return false;
1218
1220 pData->buffer, asciiStr, asciiStrLength );
1221 }
1222
1241 bool equalsIgnoreAsciiCaseAscii( const char * asciiStr ) const
1242 {
1243 return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1244 }
1245
1264 sal_Int32 compareToIgnoreAsciiCaseAscii( const char * asciiStr ) const
1265 {
1266 return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr );
1267 }
1268
1289 bool equalsIgnoreAsciiCaseAsciiL( const char * asciiStr, sal_Int32 asciiStrLength ) const
1290 {
1291 if ( pData->length != asciiStrLength )
1292 return false;
1293
1294 return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1295 }
1296
1318 bool matchAsciiL( const char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1319 {
1320 return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1321 asciiStr, asciiStrLength ) == 0;
1322 }
1323
1324 // This overload is left undefined, to detect calls of matchAsciiL that
1325 // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1326 // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1327 // platforms):
1328#if SAL_TYPES_SIZEOFLONG == 8
1329 void matchAsciiL(char const *, sal_Int32, rtl_TextEncoding) const;
1330#endif
1331
1356 bool matchIgnoreAsciiCaseAsciiL( const char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1357 {
1358 return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1359 asciiStr, asciiStrLength ) == 0;
1360 }
1361
1362 // This overload is left undefined, to detect calls of
1363 // matchIgnoreAsciiCaseAsciiL that erroneously use
1364 // RTL_CONSTASCII_USTRINGPARAM instead of RTL_CONSTASCII_STRINGPARAM (but
1365 // would lead to ambiguities on 32 bit platforms):
1366#if SAL_TYPES_SIZEOFLONG == 8
1367 void matchIgnoreAsciiCaseAsciiL(char const *, sal_Int32, rtl_TextEncoding)
1368 const;
1369#endif
1370
1385#if defined LIBO_INTERNAL_ONLY
1386 bool startsWith(std::u16string_view sv, OUString * rest = nullptr) const {
1387 auto const b = match(sv);
1388 if (b && rest != nullptr) {
1389 *rest = copy(sv.size());
1390 }
1391 return b;
1392 }
1393#else
1394 bool startsWith(OUString const & str, OUString * rest = NULL) const {
1395 bool b = match(str);
1396 if (b && rest != NULL) {
1397 *rest = copy(str.getLength());
1398 }
1399 return b;
1400 }
1401#endif
1402
1408 template< typename T >
1410 T & literal, OUString * rest = NULL) const
1411 {
1412 assert(
1414 bool b
1416 <= sal_uInt32(pData->length))
1418 pData->buffer,
1420 literal),
1422 if (b && rest != NULL) {
1423 *rest = copy(
1425 }
1426 return b;
1427 }
1428
1449#if defined LIBO_INTERNAL_ONLY
1450 bool startsWithIgnoreAsciiCase(std::u16string_view sv, OUString * rest = nullptr) const {
1451 auto const b = matchIgnoreAsciiCase(sv);
1452 if (b && rest != nullptr) {
1453 *rest = copy(sv.size());
1454 }
1455 return b;
1456 }
1457#else
1458 bool startsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL)
1459 const
1460 {
1461 bool b = matchIgnoreAsciiCase(str);
1462 if (b && rest != NULL) {
1463 *rest = copy(str.getLength());
1464 }
1465 return b;
1466 }
1467#endif
1468
1474 template< typename T >
1476 startsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1477 {
1478 assert(
1480 bool b
1482 pData->buffer,
1485 literal),
1487 == 0);
1488 if (b && rest != NULL) {
1489 *rest = copy(
1491 }
1492 return b;
1493 }
1494
1509#if defined LIBO_INTERNAL_ONLY
1510 bool endsWith(std::u16string_view sv, OUString * rest = nullptr) const {
1511 auto const b = sv.size() <= sal_uInt32(pData->length)
1512 && match(sv, pData->length - sv.size());
1513 if (b && rest != nullptr) {
1514 *rest = copy(0, (pData->length - sv.size()));
1515 }
1516 return b;
1517 }
1518#else
1519 bool endsWith(OUString const & str, OUString * rest = NULL) const {
1520 bool b = str.getLength() <= getLength()
1521 && match(str, getLength() - str.getLength());
1522 if (b && rest != NULL) {
1523 *rest = copy(0, getLength() - str.getLength());
1524 }
1525 return b;
1526 }
1527#endif
1528
1534 template< typename T >
1536 endsWith(T & literal, OUString * rest = NULL) const
1537 {
1538 assert(
1540 bool b
1542 <= sal_uInt32(pData->length))
1544 (pData->buffer + pData->length
1547 literal),
1549 if (b && rest != NULL) {
1550 *rest = copy(
1551 0,
1552 (getLength()
1554 }
1555 return b;
1556 }
1557
1569 bool endsWithAsciiL(char const * asciiStr, sal_Int32 asciiStrLength)
1570 const
1571 {
1572 return asciiStrLength <= pData->length
1574 pData->buffer + pData->length - asciiStrLength, asciiStr,
1575 asciiStrLength);
1576 }
1577
1598#if defined LIBO_INTERNAL_ONLY
1599 bool endsWithIgnoreAsciiCase(std::u16string_view sv, OUString * rest = nullptr) const {
1600 auto const b = sv.size() <= sal_uInt32(pData->length)
1601 && matchIgnoreAsciiCase(sv, pData->length - sv.size());
1602 if (b && rest != nullptr) {
1603 *rest = copy(0, pData->length - sv.size());
1604 }
1605 return b;
1606 }
1607#else
1608 bool endsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL) const
1609 {
1610 bool b = str.getLength() <= getLength()
1611 && matchIgnoreAsciiCase(str, getLength() - str.getLength());
1612 if (b && rest != NULL) {
1613 *rest = copy(0, getLength() - str.getLength());
1614 }
1615 return b;
1616 }
1617#endif
1618
1624 template< typename T >
1626 endsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1627 {
1628 assert(
1630 bool b
1632 <= sal_uInt32(pData->length))
1634 (pData->buffer + pData->length
1638 literal),
1640 == 0);
1641 if (b && rest != NULL) {
1642 *rest = copy(
1643 0,
1644 (getLength()
1646 }
1647 return b;
1648 }
1649
1661 char const * asciiStr, sal_Int32 asciiStrLength) const
1662 {
1663 return asciiStrLength <= pData->length
1665 pData->buffer + pData->length - asciiStrLength,
1666 asciiStrLength, asciiStr, asciiStrLength)
1667 == 0);
1668 }
1669
1670 friend bool operator == ( const OUString& rStr1, const OUString& rStr2 )
1671 { return rStr1.equals(rStr2); }
1672
1673 friend bool operator != ( const OUString& rStr1, const OUString& rStr2 )
1674 { return !(operator == ( rStr1, rStr2 )); }
1675
1676 friend bool operator < ( const OUString& rStr1, const OUString& rStr2 )
1677 { return rStr1.compareTo( rStr2 ) < 0; }
1678 friend bool operator > ( const OUString& rStr1, const OUString& rStr2 )
1679 { return rStr1.compareTo( rStr2 ) > 0; }
1680 friend bool operator <= ( const OUString& rStr1, const OUString& rStr2 )
1681 { return rStr1.compareTo( rStr2 ) <= 0; }
1682 friend bool operator >= ( const OUString& rStr1, const OUString& rStr2 )
1683 { return rStr1.compareTo( rStr2 ) >= 0; }
1684
1685#if defined LIBO_INTERNAL_ONLY
1686
1687 template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1688 operator ==(OUString const & s1, T const & s2) {
1689 return rtl_ustr_compare_WithLength(s1.getStr(), s1.getLength(), s2, rtl_ustr_getLength(s2))
1690 == 0;
1691 }
1692
1693 template<typename T>
1694 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1695 operator ==(OUString const & s1, T & s2) {
1696 return rtl_ustr_compare_WithLength(s1.getStr(), s1.getLength(), s2, rtl_ustr_getLength(s2))
1697 == 0;
1698 }
1699
1700 template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1701 operator ==(T const & s1, OUString const & s2) {
1702 return rtl_ustr_compare_WithLength(s1, rtl_ustr_getLength(s1), s2.getStr(), s2.getLength())
1703 == 0;
1704 }
1705
1706 template<typename T>
1707 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1708 operator ==(T & s1, OUString const & s2) {
1709 return rtl_ustr_compare_WithLength(s1, rtl_ustr_getLength(s1), s2.getStr(), s2.getLength())
1710 == 0;
1711 }
1712
1713 template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1714 operator !=(OUString const & s1, T const & s2) { return !(s1 == s2); }
1715
1716 template<typename T>
1717 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1718 operator !=(OUString const & s1, T & s2) { return !(s1 == s2); }
1719
1720 template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1721 operator !=(T const & s1, OUString const & s2) { return !(s1 == s2); }
1722
1723 template<typename T>
1724 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1725 operator !=(T & s1, OUString const & s2) { return !(s1 == s2); }
1726
1727#else
1728
1729 friend bool operator == ( const OUString& rStr1, const sal_Unicode * pStr2 )
1730 { return rStr1.compareTo( pStr2 ) == 0; }
1731 friend bool operator == ( const sal_Unicode * pStr1, const OUString& rStr2 )
1732 { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
1733
1734 friend bool operator != ( const OUString& rStr1, const sal_Unicode * pStr2 )
1735 { return !(operator == ( rStr1, pStr2 )); }
1736 friend bool operator != ( const sal_Unicode * pStr1, const OUString& rStr2 )
1737 { return !(operator == ( pStr1, rStr2 )); }
1738
1739#endif
1740
1748 template< typename T >
1750 {
1751 assert(
1753 return rString.equalsAsciiL(
1756 }
1764 template< typename T >
1766 {
1767 assert(
1769 return rString.equalsAsciiL(
1772 }
1780 template< typename T >
1782 {
1783 assert(
1785 return !rString.equalsAsciiL(
1788 }
1796 template< typename T >
1798 {
1799 assert(
1801 return !rString.equalsAsciiL(
1804 }
1805
1806#if defined LIBO_INTERNAL_ONLY
1808 template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1809 operator ==(OUString const & string, T & literal) {
1810 return
1812 string.pData->buffer, string.pData->length,
1814 literal),
1816 == 0;
1817 }
1819 template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1820 operator ==(T & literal, OUString const & string) {
1821 return
1823 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1824 literal),
1825 libreoffice_internal::ConstCharArrayDetector<T>::length,
1826 string.pData->buffer, string.pData->length)
1827 == 0;
1828 }
1830 template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1831 operator !=(OUString const & string, T & literal) {
1832 return
1834 string.pData->buffer, string.pData->length,
1835 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1836 literal),
1837 libreoffice_internal::ConstCharArrayDetector<T>::length)
1838 != 0;
1839 }
1841 template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1842 operator !=(T & literal, OUString const & string) {
1843 return
1845 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1846 literal),
1847 libreoffice_internal::ConstCharArrayDetector<T>::length,
1848 string.pData->buffer, string.pData->length)
1849 != 0;
1850 }
1851#endif
1852
1853#if defined LIBO_INTERNAL_ONLY
1855
1856 /* Comparison between OUString and OUStringLiteral.
1857
1858 @since LibreOffice 5.0
1859 */
1860
1861 template<std::size_t N>
1862 friend bool operator ==(OUString const & lhs, OUStringLiteral<N> const & rhs) {
1863 return
1865 lhs.pData->buffer, lhs.pData->length, rhs.getStr(), rhs.getLength())
1866 == 0;
1867 }
1868
1869 template<std::size_t N>
1870 friend bool operator !=(OUString const & lhs, OUStringLiteral<N> const & rhs) {
1871 return
1873 lhs.pData->buffer, lhs.pData->length, rhs.getStr(), rhs.getLength())
1874 != 0;
1875 }
1876
1877 template<std::size_t N>
1878 friend bool operator <(OUString const & lhs, OUStringLiteral<N> const & rhs) {
1879 return
1881 lhs.pData->buffer, lhs.pData->length, rhs.getStr(), rhs.getLength()))
1882 < 0;
1883 }
1884
1885 template<std::size_t N>
1886 friend bool operator <=(OUString const & lhs, OUStringLiteral<N> const & rhs) {
1887 return
1889 lhs.pData->buffer, lhs.pData->length, rhs.getStr(), rhs.getLength()))
1890 <= 0;
1891 }
1892
1893 template<std::size_t N>
1894 friend bool operator >(OUString const & lhs, OUStringLiteral<N> const & rhs) {
1895 return
1897 lhs.pData->buffer, lhs.pData->length, rhs.getStr(), rhs.getLength()))
1898 > 0;
1899 }
1900
1901 template<std::size_t N>
1902 friend bool operator >=(OUString const & lhs, OUStringLiteral<N> const & rhs) {
1903 return
1905 lhs.pData->buffer, lhs.pData->length, rhs.getStr(), rhs.getLength()))
1906 >= 0;
1907 }
1908
1909 template<std::size_t N>
1910 friend bool operator ==(OUStringLiteral<N> const & lhs, OUString const & rhs) {
1911 return
1913 lhs.getStr(), lhs.getLength(), rhs.pData->buffer, rhs.pData->length)
1914 == 0;
1915 }
1916
1917 template<std::size_t N>
1918 friend bool operator !=(OUStringLiteral<N> const & lhs, OUString const & rhs) {
1919 return
1921 lhs.getStr(), lhs.getLength(), rhs.pData->buffer, rhs.pData->length)
1922 != 0;
1923 }
1924
1925 template<std::size_t N>
1926 friend bool operator <(OUStringLiteral<N> const & lhs, OUString const & rhs) {
1927 return
1929 lhs.getStr(), lhs.getLength(), rhs.pData->buffer, rhs.pData->length))
1930 < 0;
1931 }
1932
1933 template<std::size_t N>
1934 friend bool operator <=(OUStringLiteral<N> const & lhs, OUString const & rhs) {
1935 return
1937 lhs.getStr(), lhs.getLength(), rhs.pData->buffer, rhs.pData->length))
1938 <= 0;
1939 }
1940
1941 template<std::size_t N>
1942 friend bool operator >(OUStringLiteral<N> const & lhs, OUString const & rhs) {
1943 return
1945 lhs.getStr(), lhs.getLength(), rhs.pData->buffer, rhs.pData->length))
1946 > 0;
1947 }
1948
1949 template<std::size_t N>
1950 friend bool operator >=(OUStringLiteral<N> const & lhs, OUString const & rhs) {
1951 return
1953 lhs.getStr(), lhs.getLength(), rhs.pData->buffer, rhs.pData->length))
1954 >= 0;
1955 }
1956
1958#endif
1959
1967 sal_Int32 hashCode() const
1968 {
1969 return rtl_ustr_hashCode_WithLength( pData->buffer, pData->length );
1970 }
1971
1985 sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
1986 {
1987 sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1988 return (ret < 0 ? ret : ret+fromIndex);
1989 }
1990
2000 sal_Int32 lastIndexOf( sal_Unicode ch ) const
2001 {
2002 return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
2003 }
2004
2017 sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
2018 {
2019 return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
2020 }
2021
2037#if defined LIBO_INTERNAL_ONLY
2038 sal_Int32 indexOf(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
2039 auto const n = rtl_ustr_indexOfStr_WithLength(
2040 pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size());
2041 return n < 0 ? n : n + fromIndex;
2042 }
2043#else
2044 sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
2045 {
2046 sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
2047 str.pData->buffer, str.pData->length );
2048 return (ret < 0 ? ret : ret+fromIndex);
2049 }
2050#endif
2051
2057 template< typename T >
2058 typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
2059 {
2060 assert(
2063 pData->buffer + fromIndex, pData->length - fromIndex,
2066 return n < 0 ? n : n + fromIndex;
2067 }
2068
2092 sal_Int32 indexOfAsciiL(
2093 char const * str, sal_Int32 len, sal_Int32 fromIndex = 0) const
2094 {
2095 sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
2096 pData->buffer + fromIndex, pData->length - fromIndex, str, len);
2097 return ret < 0 ? ret : ret + fromIndex;
2098 }
2099
2100 // This overload is left undefined, to detect calls of indexOfAsciiL that
2101 // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
2102 // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
2103 // platforms):
2104#if SAL_TYPES_SIZEOFLONG == 8
2105 void indexOfAsciiL(char const *, sal_Int32 len, rtl_TextEncoding) const;
2106#endif
2107
2123#if defined LIBO_INTERNAL_ONLY
2124 sal_Int32 lastIndexOf(std::u16string_view sv) const {
2126 pData->buffer, pData->length, sv.data(), sv.size());
2127 }
2128#else
2129 sal_Int32 lastIndexOf( const OUString & str ) const
2130 {
2131 return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
2132 str.pData->buffer, str.pData->length );
2133 }
2134#endif
2135
2153#if defined LIBO_INTERNAL_ONLY
2154 sal_Int32 lastIndexOf(std::u16string_view sv, sal_Int32 fromIndex) const {
2155 return rtl_ustr_lastIndexOfStr_WithLength(pData->buffer, fromIndex, sv.data(), sv.size());
2156 }
2157#else
2158 sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
2159 {
2160 return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
2161 str.pData->buffer, str.pData->length );
2162 }
2163#endif
2164
2170 template< typename T >
2172 {
2173 assert(
2176 pData->buffer, pData->length,
2179 }
2180
2200 sal_Int32 lastIndexOfAsciiL(char const * str, sal_Int32 len) const
2201 {
2203 pData->buffer, pData->length, str, len);
2204 }
2205
2216 SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex ) const
2217 {
2218 return copy(beginIndex, getLength() - beginIndex);
2219 }
2220
2233 SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const
2234 {
2235 rtl_uString *pNew = NULL;
2236 rtl_uString_newFromSubString( &pNew, pData, beginIndex, count );
2237 return OUString( pNew, SAL_NO_ACQUIRE );
2238 }
2239
2240#if defined LIBO_INTERNAL_ONLY
2251 SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex ) const
2252 {
2253 assert(beginIndex >= 0);
2254 assert(beginIndex <= getLength());
2255 return subView(beginIndex, getLength() - beginIndex);
2256 }
2257
2270 SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex, sal_Int32 count ) const
2271 {
2272 assert(beginIndex >= 0);
2273 assert(count >= 0);
2274 assert(beginIndex <= getLength());
2275 assert(count <= getLength() - beginIndex);
2276 return std::u16string_view(*this).substr(beginIndex, count);
2277 }
2278#endif
2279
2280#ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2289 SAL_WARN_UNUSED_RESULT OUString concat( const OUString & str ) const
2290 {
2291 rtl_uString* pNew = NULL;
2292 rtl_uString_newConcat( &pNew, pData, str.pData );
2293 return OUString( pNew, SAL_NO_ACQUIRE );
2294 }
2295#endif
2296
2297#ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2298 friend OUString operator+( const OUString& rStr1, const OUString& rStr2 )
2299 {
2300 return rStr1.concat( rStr2 );
2301 }
2302#endif
2303
2317 SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const
2318 {
2319 rtl_uString* pNew = NULL;
2320 rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
2321 return OUString( pNew, SAL_NO_ACQUIRE );
2322 }
2323
2338 {
2339 rtl_uString* pNew = NULL;
2340 rtl_uString_newReplace( &pNew, pData, oldChar, newChar );
2341 return OUString( pNew, SAL_NO_ACQUIRE );
2342 }
2343
2362#if defined LIBO_INTERNAL_ONLY
2363 [[nodiscard]] OUString replaceFirst(
2364 std::u16string_view from, std::u16string_view to, sal_Int32 * index = nullptr) const
2365 {
2366 rtl_uString * s = nullptr;
2367 sal_Int32 i = 0;
2369 &s, pData, from.data(), from.size(), to.data(), to.size(),
2370 index == nullptr ? &i : index);
2371 return OUString(s, SAL_NO_ACQUIRE);
2372 }
2373#else
2375 OUString const & from, OUString const & to, sal_Int32 * index = NULL) const
2376 {
2377 rtl_uString * s = NULL;
2378 sal_Int32 i = 0;
2380 &s, pData, from.pData, to.pData, index == NULL ? &i : index);
2381 return OUString(s, SAL_NO_ACQUIRE);
2382 }
2383#endif
2384
2403#if defined LIBO_INTERNAL_ONLY
2404 template<typename T> [[nodiscard]]
2406 T & from, std::u16string_view to, sal_Int32 * index = nullptr) const
2407 {
2409 rtl_uString * s = nullptr;
2410 sal_Int32 i = 0;
2414 index == nullptr ? &i : index);
2415 return OUString(s, SAL_NO_ACQUIRE);
2416 }
2417#else
2418 template< typename T >
2420 sal_Int32 * index = NULL) const
2421 {
2423 rtl_uString * s = NULL;
2424 sal_Int32 i = 0;
2426 &s, pData,
2429 index == NULL ? &i : index);
2430 return OUString(s, SAL_NO_ACQUIRE);
2431 }
2432#endif
2433
2452#if defined LIBO_INTERNAL_ONLY
2453 template<typename T> [[nodiscard]]
2455 std::u16string_view from, T & to, sal_Int32 * index = nullptr) const
2456 {
2458 rtl_uString * s = nullptr;
2459 sal_Int32 i = 0;
2461 &s, pData, from.data(), from.size(),
2463 libreoffice_internal::ConstCharArrayDetector<T>::length, index == nullptr ? &i : index);
2464 return OUString(s, SAL_NO_ACQUIRE);
2465 }
2466#else
2467 template< typename T >
2469 sal_Int32 * index = NULL) const
2470 {
2472 rtl_uString * s = NULL;
2473 sal_Int32 i = 0;
2475 &s, pData, from.pData,
2478 index == NULL ? &i : index);
2479 return OUString(s, SAL_NO_ACQUIRE);
2480 }
2481#endif
2482
2501 template< typename T1, typename T2 >
2503 replaceFirst( T1& from, T2& to, sal_Int32 * index = NULL) const
2504 {
2507 rtl_uString * s = NULL;
2508 sal_Int32 i = 0;
2510 &s, pData,
2515 index == NULL ? &i : index);
2516 return OUString(s, SAL_NO_ACQUIRE);
2517 }
2518
2534#if defined LIBO_INTERNAL_ONLY
2535 [[nodiscard]] OUString replaceAll(
2536 std::u16string_view from, std::u16string_view to, sal_Int32 fromIndex = 0) const
2537 {
2538 rtl_uString * s = nullptr;
2539 rtl_uString_newReplaceAllFromIndexUtf16LUtf16L(
2540 &s, pData, from.data(), from.size(), to.data(), to.size(), fromIndex);
2541 return OUString(s, SAL_NO_ACQUIRE);
2542 }
2543#else
2545 OUString const & from, OUString const & to, sal_Int32 fromIndex = 0) const
2546 {
2547 rtl_uString * s = NULL;
2548 rtl_uString_newReplaceAllFromIndex(&s, pData, from.pData, to.pData, fromIndex);
2549 return OUString(s, SAL_NO_ACQUIRE);
2550 }
2551#endif
2552
2566#if defined LIBO_INTERNAL_ONLY
2567 template<typename T> [[nodiscard]]
2569 T & from, std::u16string_view to) const
2570 {
2572 rtl_uString * s = nullptr;
2576 return OUString(s, SAL_NO_ACQUIRE);
2577 }
2578#else
2579 template< typename T >
2581 {
2583 rtl_uString * s = NULL;
2585 &s, pData,
2588 return OUString(s, SAL_NO_ACQUIRE);
2589 }
2590#endif
2591
2605#if defined LIBO_INTERNAL_ONLY
2606 template<typename T> [[nodiscard]]
2608 std::u16string_view from, T & to) const
2609 {
2611 rtl_uString * s = nullptr;
2613 &s, pData, from.data(), from.size(),
2616 return OUString(s, SAL_NO_ACQUIRE);
2617 }
2618#else
2619 template< typename T >
2621 {
2623 rtl_uString * s = NULL;
2625 &s, pData, from.pData,
2628 return OUString(s, SAL_NO_ACQUIRE);
2629 }
2630#endif
2631
2645 template< typename T1, typename T2 >
2647 replaceAll( T1& from, T2& to ) const
2648 {
2651 rtl_uString * s = NULL;
2653 &s, pData,
2658 return OUString(s, SAL_NO_ACQUIRE);
2659 }
2660
2672 {
2673 rtl_uString* pNew = NULL;
2674 rtl_uString_newToAsciiLowerCase( &pNew, pData );
2675 return OUString( pNew, SAL_NO_ACQUIRE );
2676 }
2677
2689 {
2690 rtl_uString* pNew = NULL;
2691 rtl_uString_newToAsciiUpperCase( &pNew, pData );
2692 return OUString( pNew, SAL_NO_ACQUIRE );
2693 }
2694
2709 {
2710 rtl_uString* pNew = NULL;
2711 rtl_uString_newTrim( &pNew, pData );
2712 return OUString( pNew, SAL_NO_ACQUIRE );
2713 }
2714
2739 OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const
2740 {
2741 rtl_uString * pNew = NULL;
2742 index = rtl_uString_getToken( &pNew, pData, token, cTok, index );
2743 return OUString( pNew, SAL_NO_ACQUIRE );
2744 }
2745
2759 OUString getToken(sal_Int32 count, sal_Unicode separator) const {
2760 sal_Int32 n = 0;
2761 return getToken(count, separator, n);
2762 }
2763
2772 bool toBoolean() const
2773 {
2774 return rtl_ustr_toBoolean( pData->buffer );
2775 }
2776
2784 {
2785 return pData->buffer[0];
2786 }
2787
2798 sal_Int32 toInt32( sal_Int16 radix = 10 ) const
2799 {
2800 return rtl_ustr_toInt32( pData->buffer, radix );
2801 }
2802
2815 sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
2816 {
2817 return rtl_ustr_toUInt32( pData->buffer, radix );
2818 }
2819
2830 sal_Int64 toInt64( sal_Int16 radix = 10 ) const
2831 {
2832 return rtl_ustr_toInt64( pData->buffer, radix );
2833 }
2834
2847 sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
2848 {
2849 return rtl_ustr_toUInt64( pData->buffer, radix );
2850 }
2851
2860 float toFloat() const
2861 {
2862 return rtl_ustr_toFloat( pData->buffer );
2863 }
2864
2873 double toDouble() const
2874 {
2875 return rtl_ustr_toDouble( pData->buffer );
2876 }
2877
2878
2895 {
2896 rtl_uString * pNew = NULL;
2897 rtl_uString_intern( &pNew, pData );
2898 if (pNew == NULL) {
2899 throw std::bad_alloc();
2900 }
2901 return OUString( pNew, SAL_NO_ACQUIRE );
2902 }
2903
2929 static OUString intern( const char * value, sal_Int32 length,
2930 rtl_TextEncoding encoding,
2931 sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS,
2932 sal_uInt32 *pInfo = NULL )
2933 {
2934 rtl_uString * pNew = NULL;
2935 rtl_uString_internConvert( &pNew, value, length, encoding,
2936 convertFlags, pInfo );
2937 if (pNew == NULL) {
2938 throw std::bad_alloc();
2939 }
2940 return OUString( pNew, SAL_NO_ACQUIRE );
2941 }
2942
2967 bool convertToString(OString * pTarget, rtl_TextEncoding nEncoding,
2968 sal_uInt32 nFlags) const
2969 {
2970 return rtl_convertUStringToString(&pTarget->pData, pData->buffer,
2971 pData->length, nEncoding, nFlags);
2972 }
2973
3026 sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1) const
3027 {
3029 pData, indexUtf16, incrementCodePoints);
3030 }
3031
3041#if defined LIBO_INTERNAL_ONLY
3042 static OUString fromUtf8(std::string_view rSource)
3043 {
3044 OUString aTarget;
3045 bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
3046 rSource.data(),
3047 rSource.length(),
3050 (void) bSuccess;
3051 assert(bSuccess);
3052 return aTarget;
3053 }
3054#else
3055 static OUString fromUtf8(const OString& rSource)
3056 {
3057 OUString aTarget;
3058 bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
3059 rSource.getStr(),
3060 rSource.getLength(),
3063 (void) bSuccess;
3064 assert(bSuccess);
3065 return aTarget;
3066 }
3067#endif
3068
3080 {
3081 OString aTarget;
3082 bool bSuccess = rtl_convertUStringToString(&aTarget.pData,
3083 getStr(),
3084 getLength(),
3087 (void) bSuccess;
3088 assert(bSuccess);
3089 return aTarget;
3090 }
3091
3092#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3093
3094 static OUStringNumber< int > number( int i, sal_Int16 radix = 10 )
3095 {
3096 return OUStringNumber< int >( i, radix );
3097 }
3098 static OUStringNumber< long long > number( long long ll, sal_Int16 radix = 10 )
3099 {
3100 return OUStringNumber< long long >( ll, radix );
3101 }
3102 static OUStringNumber< unsigned long long > number( unsigned long long ll, sal_Int16 radix = 10 )
3103 {
3104 return OUStringNumber< unsigned long long >( ll, radix );
3105 }
3106 static OUStringNumber< unsigned long long > number( unsigned int i, sal_Int16 radix = 10 )
3107 {
3108 return number( static_cast< unsigned long long >( i ), radix );
3109 }
3110 static OUStringNumber< long long > number( long i, sal_Int16 radix = 10)
3111 {
3112 return number( static_cast< long long >( i ), radix );
3113 }
3114 static OUStringNumber< unsigned long long > number( unsigned long i, sal_Int16 radix = 10 )
3115 {
3116 return number( static_cast< unsigned long long >( i ), radix );
3117 }
3118 static OUStringNumber< float > number( float f )
3119 {
3120 return OUStringNumber< float >( f );
3121 }
3122 static OUStringNumber< double > number( double d )
3123 {
3124 return OUStringNumber< double >( d );
3125 }
3126#else
3137 static OUString number( int i, sal_Int16 radix = 10 )
3138 {
3140 return OUString(aBuf, rtl_ustr_valueOfInt32(aBuf, i, radix));
3141 }
3144 static OUString number( unsigned int i, sal_Int16 radix = 10 )
3145 {
3146 return number( static_cast< unsigned long long >( i ), radix );
3147 }
3150 static OUString number( long i, sal_Int16 radix = 10)
3151 {
3152 return number( static_cast< long long >( i ), radix );
3153 }
3156 static OUString number( unsigned long i, sal_Int16 radix = 10 )
3157 {
3158 return number( static_cast< unsigned long long >( i ), radix );
3159 }
3162 static OUString number( long long ll, sal_Int16 radix = 10 )
3163 {
3165 return OUString(aBuf, rtl_ustr_valueOfInt64(aBuf, ll, radix));
3166 }
3169 static OUString number( unsigned long long ll, sal_Int16 radix = 10 )
3170 {
3172 return OUString(aBuf, rtl_ustr_valueOfUInt64(aBuf, ll, radix));
3173 }
3174
3184 static OUString number( float f )
3185 {
3187 return OUString(aBuf, rtl_ustr_valueOfFloat(aBuf, f));
3188 }
3189
3199 static OUString number( double d )
3200 {
3202 return OUString(aBuf, rtl_ustr_valueOfDouble(aBuf, d));
3203 }
3204#endif
3205
3217 SAL_DEPRECATED("use boolean()") static OUString valueOf( sal_Bool b )
3218 {
3219 return boolean(b);
3220 }
3221
3233 static OUString boolean( bool b )
3234 {
3236 return OUString(aBuf, rtl_ustr_valueOfBoolean(aBuf, b));
3237 }
3238
3246 SAL_DEPRECATED("convert to OUString or use directly") static OUString valueOf( sal_Unicode c )
3247 {
3248 return OUString( &c, 1 );
3249 }
3250
3261 SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
3262 {
3263 return number( i, radix );
3264 }
3265
3276 SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
3277 {
3278 return number( ll, radix );
3279 }
3280
3290 SAL_DEPRECATED("use number()") static OUString valueOf( float f )
3291 {
3292 return number(f);
3293 }
3294
3304 SAL_DEPRECATED("use number()") static OUString valueOf( double d )
3305 {
3306 return number(d);
3307 }
3308
3324 static OUString createFromAscii( const char * value )
3325 {
3326 rtl_uString* pNew = NULL;
3327 rtl_uString_newFromAscii( &pNew, value );
3328 return OUString( pNew, SAL_NO_ACQUIRE );
3329 }
3330
3331#if defined LIBO_INTERNAL_ONLY
3332 static OUString createFromAscii(std::string_view value) {
3333 rtl_uString * p = nullptr;
3334 rtl_uString_newFromLiteral(&p, value.data(), value.size(), 0); //TODO: check for overflow
3335 return OUString(p, SAL_NO_ACQUIRE);
3336 }
3337 #endif
3338
3339#if defined LIBO_INTERNAL_ONLY
3340 operator std::u16string_view() const { return {getStr(), sal_uInt32(getLength())}; }
3341#endif
3342
3343#if defined LIBO_INTERNAL_ONLY
3344 // A wrapper for the first expression in an
3345 //
3346 // OUString::Concat(e1) + e2 + ...
3347 //
3348 // concatenation chain, when neither of the first two e1, e2 is one of our rtl string-related
3349 // classes (so something like
3350 //
3351 // OUString s = "a" + (b ? std::u16string_view(u"c") : std::u16string_view(u"dd"));
3352 //
3353 // would not compile):
3354 template<typename T> [[nodiscard]] static
3355 typename std::enable_if_t<
3356 ToStringHelper<T>::allowOUStringConcat, OUStringConcat<OUStringConcatMarker, T>>
3357 Concat(T const & value) { return OUStringConcat<OUStringConcatMarker, T>({}, value); }
3358
3359 // This overload is needed so that an argument of type 'char const[N]' ends up as
3360 // 'OUStringConcat<rtl::OUStringConcatMarker, char const[N]>' rather than as
3361 // 'OUStringConcat<rtl::OUStringConcatMarker, char[N]>':
3362 template<typename T, std::size_t N> [[nodiscard]] static
3363 typename std::enable_if_t<
3364 ToStringHelper<T[N]>::allowOUStringConcat, OUStringConcat<OUStringConcatMarker, T[N]>>
3365 Concat(T (& value)[N]) { return OUStringConcat<OUStringConcatMarker, T[N]>({}, value); }
3366#endif
3367
3368private:
3369 OUString & internalAppend( rtl_uString* pOtherData )
3370 {
3371 rtl_uString* pNewData = NULL;
3372 rtl_uString_newConcat( &pNewData, pData, pOtherData );
3373 if (pNewData == NULL) {
3374 throw std::bad_alloc();
3375 }
3376 rtl_uString_assign(&pData, pNewData);
3377 rtl_uString_release(pNewData);
3378 return *this;
3379 }
3380
3381};
3382
3383#if defined LIBO_INTERNAL_ONLY
3384// Prevent the operator ==/!= overloads with 'sal_Unicode const *' parameter from
3385// being selected for nonsensical code like
3386//
3387// if (ouIdAttr == nullptr)
3388//
3389void operator ==(OUString const &, std::nullptr_t) = delete;
3390void operator ==(std::nullptr_t, OUString const &) = delete;
3391void operator !=(OUString const &, std::nullptr_t) = delete;
3392void operator !=(std::nullptr_t, OUString const &) = delete;
3393#endif
3394
3395#if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3397
3401template<>
3402struct ToStringHelper< OUString >
3403 {
3404 static std::size_t length( const OUString& s ) { return s.getLength(); }
3405 static sal_Unicode* addData( sal_Unicode* buffer, const OUString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
3406 static const bool allowOStringConcat = false;
3407 static const bool allowOUStringConcat = true;
3408 };
3409
3413template<std::size_t N>
3414struct ToStringHelper< OUStringLiteral<N> >
3415 {
3416 static std::size_t length( const OUStringLiteral<N>& str ) { return str.getLength(); }
3417 static sal_Unicode* addData( sal_Unicode* buffer, const OUStringLiteral<N>& str ) { return addDataHelper( buffer, str.getStr(), str.getLength() ); }
3418 static const bool allowOStringConcat = false;
3419 static const bool allowOUStringConcat = true;
3420 };
3421
3425template< typename charT, typename traits, typename T1, typename T2 >
3426inline std::basic_ostream<charT, traits> & operator <<(
3427 std::basic_ostream<charT, traits> & stream, OUStringConcat< T1, T2 >&& concat)
3428{
3429 return stream << OUString( std::move(concat) );
3430}
3431
3433#endif
3434
3441{
3451 size_t operator()(const OUString& rString) const
3452 { return static_cast<size_t>(rString.hashCode()); }
3453};
3454
3455/* ======================================================================= */
3456
3474#if defined LIBO_INTERNAL_ONLY
3475inline OUString OStringToOUString( std::string_view rStr,
3476 rtl_TextEncoding encoding,
3477 sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
3478{
3479 return OUString( rStr.data(), rStr.length(), encoding, convertFlags );
3480}
3481#else
3483 rtl_TextEncoding encoding,
3484 sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
3485{
3486 return OUString( rStr.getStr(), rStr.getLength(), encoding, convertFlags );
3487}
3488#endif
3489
3507#if defined LIBO_INTERNAL_ONLY
3508inline OString OUStringToOString( std::u16string_view rUnicode,
3509 rtl_TextEncoding encoding,
3510 sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
3511{
3512 return OString( rUnicode.data(), rUnicode.length(), encoding, convertFlags );
3513}
3514#else
3515inline OString OUStringToOString( const OUString & rUnicode,
3516 rtl_TextEncoding encoding,
3517 sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
3518{
3519 return OString( rUnicode.getStr(), rUnicode.getLength(), encoding, convertFlags );
3520}
3521#endif
3522
3523/* ======================================================================= */
3524
3533template< typename charT, typename traits >
3534inline std::basic_ostream<charT, traits> & operator <<(
3535 std::basic_ostream<charT, traits> & stream, OUString const & rString)
3536{
3537 return stream <<
3539 // best effort; potentially loses data due to conversion failures
3540 // (stray surrogate halves) and embedded null characters
3541}
3542
3543} // namespace
3544
3545#ifdef RTL_STRING_UNITTEST
3546namespace rtl
3547{
3548typedef rtlunittest::OUString OUString;
3549}
3550#endif
3551
3552// In internal code, allow to use classes like OUString without having to
3553// explicitly refer to the rtl namespace, which is kind of superfluous given
3554// that OUString itself is namespaced by its OU prefix:
3555#if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3556using ::rtl::OUString;
3557using ::rtl::OUStringHash;
3560using ::rtl::OUStringLiteral;
3561using ::rtl::OUStringChar;
3562#endif
3563
3565
3570#if defined LIBO_INTERNAL_ONLY
3571namespace std {
3572
3573template<>
3574struct hash<::rtl::OUString>
3575{
3576 std::size_t operator()(::rtl::OUString const & s) const
3577 { return std::size_t(s.hashCode()); }
3578};
3579
3580}
3581
3582#endif
3584
3585#endif /* _RTL_USTRING_HXX */
3586
3587/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don't use, it's evil.") void doit(int nPara);.
Definition: types.h:474
__sal_NoAcquire
Definition: types.h:353
@ SAL_NO_ACQUIRE
definition of a no acquire enum for ctors
Definition: types.h:356
unsigned char sal_Bool
Definition: types.h:38
sal_uInt16 sal_Unicode
Definition: types.h:123
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:284
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:587
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.
SAL_DLLPUBLIC void rtl_uString_assign(rtl_uString **str, rtl_uString *rightValue) SAL_THROW_EXTERN_C()
Assign a new value to a string.
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.
SAL_DLLPUBLIC float rtl_ustr_toFloat(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a float.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_shortenedCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters.
SAL_DLLPUBLIC void rtl_uString_new(rtl_uString **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
#define OSTRING_TO_OUSTRING_CVTFLAGS
Definition: ustring.h:2184
#define RTL_USTR_MAX_VALUEOFFLOAT
Definition: ustring.h:1026
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.
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.
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.
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.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters, ignoring the case of ASCII characters.
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.
#define RTL_USTR_MAX_VALUEOFDOUBLE
Definition: ustring.h:1045
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.
SAL_DLLPUBLIC sal_Bool rtl_ustr_asciil_reverseEquals_WithLength(const sal_Unicode *first, const char *second, sal_Int32 len) SAL_THROW_EXTERN_C()
Compare two strings from back to front for equality.
SAL_DLLPUBLIC void rtl_uString_newFromLiteral(rtl_uString **newStr, const char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
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.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfBoolean(sal_Unicode *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
SAL_DLLPUBLIC double rtl_ustr_toDouble(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a double.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfFloat(sal_Unicode *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
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.
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.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfDouble(sal_Unicode *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
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.
#define RTL_USTR_MAX_VALUEOFINT64
Definition: ustring.h:984
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
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.
SAL_DLLPUBLIC void rtl_uString_internConvert(rtl_uString **newStr, const 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.
SAL_DLLPUBLIC void rtl_uString_acquire(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Increment the reference count of a string.
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.
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.
#define RTL_USTR_MAX_VALUEOFUINT64
Definition: ustring.h:1007
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.
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.
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.
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.
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.
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Decrement the reference count of a string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_getLength(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Return the length of a string.
SAL_DLLPUBLIC void rtl_uString_newFromAscii(rtl_uString **newStr, const char *value) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
SAL_DLLPUBLIC void rtl_uString_intern(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Return a canonical representation for a string.
SAL_DLLPUBLIC void rtl_string2UString(rtl_uString **newStr, const 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.
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_DLLPUBLIC sal_Int32 rtl_ustr_asciil_reverseCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings from back to front.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_compare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second) SAL_THROW_EXTERN_C()
Compare two strings.
#define RTL_USTR_MAX_VALUEOFBOOLEAN
Definition: ustring.h:919
SAL_DLLPUBLIC sal_Int32 rtl_ustr_toInt32(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an integer.
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.
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.
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.
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.
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.
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.
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.
SAL_DLLPUBLIC sal_Bool rtl_ustr_toBoolean(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
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.
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.
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.
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.
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.
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.
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.
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.
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.
#define RTL_USTR_MAX_VALUEOFINT32
Definition: ustring.h:961
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.
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1354
#define RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR
Definition: textcvt.h:151
#define RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR
Definition: textcvt.h:75
#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
Definition: textcvt.h:72
#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:68
#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:145
#define RTL_TEXTENCODING_UTF8
Definition: textenc.h:117
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:37
sal_Int32 oslInterlockedCount
Definition: interlck.h:44
bool operator!=(const Any &rAny, const C &value)
Template inequality operator: compares set value of left side any to right side value.
Definition: Any.hxx:668
Definition: unotype.hxx:47
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,...
Definition: string.hxx:2231
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:3482
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:3515
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:93
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:103
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:113
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:180
const char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:602
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:576
Definition: stringutils.hxx:136
Definition: stringutils.hxx:139
This String class provides base functionality for C++ like Unicode character array handling.
Definition: ustring.hxx:169
static OUString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: ustring.hxx:3137
OUString intern() const
Return a canonical representation for a string.
Definition: ustring.hxx:2894
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:2058
bool endsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string ends with a given substring.
Definition: ustring.hxx:1519
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:1660
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:2671
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:2580
const sal_Unicode * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:781
bool equalsIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:937
bool endsWithAsciiL(char const *asciiStr, sal_Int32 asciiStrLength) const
Check whether this string ends with a given ASCII string.
Definition: ustring.hxx:1569
OUString(const OUString &str)
New string from OUString.
Definition: ustring.hxx:189
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:3025
static OUString fromUtf8(const OString &rSource)
Convert an OString to an OUString, assuming that the OString is UTF-8-encoded.
Definition: ustring.hxx:3055
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:1033
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: ustring.hxx:2798
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: ustring.hxx:746
bool equalsIgnoreAsciiCaseAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1289
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:3169
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:2092
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T1, typenamelibreoffice_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:2647
~OUString()
Release the string data.
Definition: ustring.hxx:490
sal_Int32 compareTo(const OUString &str, sal_Int32 maxLength) const
Compares two strings with a maximum count of characters.
Definition: ustring.hxx:846
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:2200
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,...
Definition: ustring.hxx:1985
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:2620
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:3162
bool matchAsciiL(const char *asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:1318
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:2544
float toFloat() const
Returns the float value from this string.
Definition: ustring.hxx:2860
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:3156
static OUString createFromAscii(const char *value)
Returns an OUString copied without conversion from an ASCII character string.
Definition: ustring.hxx:3324
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:2419
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T1, typenamelibreoffice_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:2503
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:2337
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: ustring.hxx:1967
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:884
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1765
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1749
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:3150
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:982
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: ustring.hxx:2847
bool matchIgnoreAsciiCaseAsciiL(const 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:1356
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:1476
OString toUtf8() const
Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully.
Definition: ustring.hxx:3079
sal_Int32 reverseCompareToAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Compares two strings in reverse order.
Definition: ustring.hxx:1170
bool equalsAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform a comparison of two strings.
Definition: ustring.hxx:1214
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:3144
bool convertToString(OString *pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) const
Converts to an OString, signalling failure.
Definition: ustring.hxx:2967
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:1409
OUString(rtl_uString *str)
New string from OUString data.
Definition: ustring.hxx:215
OUString(const sal_Unicode *value, sal_Int32 length)
New string from a Unicode character buffer array.
Definition: ustring.hxx:294
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:1608
sal_Int32 compareTo(const OUString &str) const
Compares two strings.
Definition: ustring.hxx:817
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1781
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:550
bool startsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: ustring.hxx:1394
sal_Int32 lastIndexOf(sal_Unicode ch) const
Returns the index within this string of the last occurrence of the specified character,...
Definition: ustring.hxx:2000
sal_Int32 compareToIgnoreAsciiCaseAscii(const char *asciiStr) const
Compares two ASCII strings ignoring case.
Definition: ustring.hxx:1264
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:2468
OUString(sal_Unicode value)
New string from a single Unicode character.
Definition: ustring.hxx:237
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:2374
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: ustring.hxx:2830
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: ustring.hxx:2815
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:1458
sal_Int32 lastIndexOf(const OUString &str, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified substring,...
Definition: ustring.hxx:2158
static OUString const & unacquired(rtl_uString *const *ppHandle)
Provides an OUString const & passing a storage pointer of an rtl_uString * handle.
Definition: ustring.hxx:506
double toDouble() const
Returns the double value from this string.
Definition: ustring.hxx:2873
bool equalsAscii(const char *asciiStr) const
Perform a comparison of two strings.
Definition: ustring.hxx:1191
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:1087
OUString getToken(sal_Int32 token, sal_Unicode cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: ustring.hxx:2739
sal_Int32 getLength() const
Returns the length of this string.
Definition: ustring.hxx:759
bool equalsIgnoreAsciiCaseAscii(const char *asciiStr) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1241
OUString()
New string containing no characters.
Definition: ustring.hxx:178
OUString(const sal_Unicode *value)
New string from a Unicode character buffer array.
Definition: ustring.hxx:278
OUString(const 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:412
OUString & operator=(const OUString &str)
Assign a new string.
Definition: ustring.hxx:514
static OUString number(float f)
Returns the string representation of the float argument.
Definition: ustring.hxx:3184
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:769
sal_Int32 compareToIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:969
OUString(sal_uInt32 const *codePoints, sal_Int32 codePointCount)
Create a new string from an array of Unicode code points.
Definition: ustring.hxx:439
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:1536
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition: ustring.hxx:630
sal_Unicode toChar() const
Returns the first character from this string.
Definition: ustring.hxx:2783
OUString getToken(sal_Int32 count, sal_Unicode separator) const
Returns a token from the string.
Definition: ustring.hxx:2759
static OUString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: ustring.hxx:3233
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:2171
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:2233
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:1626
OUString(rtl_uString *str, __sal_NoAcquire)
New OUString from OUString data without acquiring it.
Definition: ustring.hxx:229
sal_Int32 lastIndexOf(sal_Unicode ch, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified character,...
Definition: ustring.hxx:2017
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:2708
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:2688
SAL_WARN_UNUSED_RESULT OUString concat(const OUString &str) const
Concatenates the specified string to the end of this string.
Definition: ustring.hxx:2289
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:2317
bool match(const OUString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:1020
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:1073
sal_Int32 compareToAscii(const char *asciiStr) const
Compares two strings.
Definition: ustring.hxx:1116
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:316
sal_Int32 reverseCompareTo(const OUString &str) const
Compares two strings in reverse order.
Definition: ustring.hxx:871
static OUString number(double d)
Returns the string representation of the double argument.
Definition: ustring.hxx:3199
friend OUString operator+(const OUString &rStr1, const OUString &rStr2)
Definition: ustring.hxx:2298
SAL_WARN_UNUSED_RESULT OUString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: ustring.hxx:2216
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1797
bool equals(const OUString &str) const
Perform a comparison of two strings.
Definition: ustring.hxx:905
sal_Int32 lastIndexOf(const OUString &str) const
Returns the index within this string of the last occurrence of the specified substring,...
Definition: ustring.hxx:2129
bool toBoolean() const
Returns the Boolean value from this string.
Definition: ustring.hxx:2772
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,...
Definition: ustring.hxx:2044
static OUString intern(const 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:2929
A helper to use OUStrings with hash maps.
Definition: ustring.hxx:3441
size_t operator()(const OUString &rString) const
Compute a hash code for a string.
Definition: ustring.hxx:3451