LibreOffice
LibreOffice 7.3 SDK C/C++ API Reference
ustring.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20/*
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 friend class OUStringConstExpr;
88
89public:
90#if HAVE_CPP_CONSTEVAL
91 consteval
92#else
93 constexpr
94#endif
95 OUStringLiteral(char16_t const (&literal)[N]) {
96 assertLayout();
97 assert(literal[N - 1] == '\0');
98 //TODO: Use C++20 constexpr std::copy_n (P0202R3):
99 for (std::size_t i = 0; i != N; ++i) {
100 more.buffer[i] = literal[i];
101 }
102 }
103
104 constexpr sal_Int32 getLength() const { return more.length; }
105
106 constexpr sal_Unicode const * getStr() const SAL_RETURNS_NONNULL { return more.buffer; }
107
108 constexpr operator std::u16string_view() const { return {more.buffer, sal_uInt32(more.length)}; }
109
110private:
111 static constexpr void assertLayout() {
112 // These static_asserts verifying the layout compatibility with rtl_uString cannot be class
113 // member declarations, as offsetof requires a complete type, so defer them to here:
114 static_assert(std::is_standard_layout_v<OUStringLiteral>);
115 static_assert(offsetof(OUStringLiteral, str.refCount) == offsetof(OUStringLiteral, more.refCount));
116 static_assert(offsetof(OUStringLiteral, str.length) == offsetof(OUStringLiteral, more.length));
117 static_assert(offsetof(OUStringLiteral, str.buffer) == offsetof(OUStringLiteral, more.buffer));
118 }
119
120 union {
121 rtl_uString str;
122 struct {
123 oslInterlockedCount refCount;
124 sal_Int32 length;
125 sal_Unicode buffer[N];
126 } more =
127 {
128 0x40000000, // SAL_STRING_STATIC_FLAG (sal/rtl/strimp.hxx)
129 N - 1,
130 {} //TODO: drop initialization for C++20 (P1331R2)
131 };
132 };
133};
134
135#if defined RTL_STRING_UNITTEST
136namespace libreoffice_internal {
137template<std::size_t N> struct ExceptConstCharArrayDetector<OUStringLiteral<N>> {};
138template<std::size_t N> struct ExceptCharArrayDetector<OUStringLiteral<N>> {};
139}
140#endif
141
150class OUString;
151class OUStringConstExpr
152{
153public:
154 template<std::size_t N> constexpr OUStringConstExpr(OUStringLiteral<N> const & literal):
155 pData(const_cast<rtl_uString *>(&literal.str)) {}
156
157 // prevent mis-use
158 template<std::size_t N> constexpr OUStringConstExpr(OUStringLiteral<N> && literal)
159 = delete;
160
161 // no destructor necessary because we know we are pointing at a compile-time
162 // constant OUStringLiteral, which bypasses ref-counting.
163
167 constexpr std::u16string_view asView() const { return {pData->buffer, static_cast<sal_uInt32>(pData->length)}; }
168
169 inline operator const OUString&() const;
170
171private:
172 rtl_uString* pData;
173};
174
176#endif
177
178/* ======================================================================= */
179
203class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OUString
204{
205public:
207 rtl_uString * pData;
209
214 {
215 pData = NULL;
216 rtl_uString_new( &pData );
217 }
218
224 OUString( const OUString & str )
225 {
226 pData = str.pData;
227 rtl_uString_acquire( pData );
228 }
229
230#if defined LIBO_INTERNAL_ONLY
237 OUString( OUString && str ) noexcept
238 {
239 pData = str.pData;
240 str.pData = nullptr;
241 rtl_uString_new( &str.pData );
242 }
243#endif
244
250 OUString( rtl_uString * str )
251 {
252 pData = str;
253 rtl_uString_acquire( pData );
254 }
255
264 OUString( rtl_uString * str, __sal_NoAcquire )
265 { pData = str; }
266
272 explicit OUString( sal_Unicode value )
273 : pData (NULL)
274 {
275 rtl_uString_newFromStr_WithLength( &pData, &value, 1 );
276 }
277
278#if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
280 // Catch inadvertent conversions to the above ctor (but still allow
281 // construction from char literals):
282 OUString(int) = delete;
283 explicit OUString(char c):
284 OUString(sal_Unicode(static_cast<unsigned char>(c)))
285 {}
287#endif
288
289#if defined LIBO_INTERNAL_ONLY
290
291 template<typename T> explicit OUString(
292 T const & value,
293 typename libreoffice_internal::CharPtrDetector<T, libreoffice_internal::Dummy>::TypeUtf16
294 = libreoffice_internal::Dummy()):
295 pData(nullptr)
296 { rtl_uString_newFromStr(&pData, value); }
297
298 template<typename T> explicit OUString(
299 T & value,
300 typename
301 libreoffice_internal::NonConstCharArrayDetector<T, libreoffice_internal::Dummy>::TypeUtf16
302 = libreoffice_internal::Dummy()):
303 pData(nullptr)
304 { rtl_uString_newFromStr(&pData, value); }
305
306#else
307
313 OUString( const sal_Unicode * value )
314 {
315 pData = NULL;
316 rtl_uString_newFromStr( &pData, value );
317 }
318
319#endif
320
329 OUString( const sal_Unicode * value, sal_Int32 length )
330 {
331 pData = NULL;
332 rtl_uString_newFromStr_WithLength( &pData, value, length );
333 }
334
350 template< typename T >
352 {
353 assert(
355 pData = NULL;
357 rtl_uString_new(&pData);
358 } else {
360 &pData,
362 literal),
364 }
365#ifdef RTL_STRING_UNITTEST
366 rtl_string_unittest_const_literal = true;
367#endif
368 }
369
370#if defined LIBO_INTERNAL_ONLY
372 template<typename T> OUString(
373 T & literal,
375 T, libreoffice_internal::Dummy>::TypeUtf16
377 pData(nullptr)
378 {
379 assert(
382 rtl_uString_new(&pData);
383 } else {
385 &pData,
386 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
387 literal),
388 libreoffice_internal::ConstCharArrayDetector<T>::length);
389 }
390 }
391#endif
392
393#if defined LIBO_INTERNAL_ONLY && defined RTL_STRING_UNITTEST
395
399 template< typename T >
400 OUString( T&, typename libreoffice_internal::ExceptConstCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
401 {
402 pData = NULL;
403 rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
404 rtl_string_unittest_invalid_conversion = true;
405 }
410 template< typename T >
411 OUString( const T&, typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
412 {
413 pData = NULL;
414 rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
415 rtl_string_unittest_invalid_conversion = true;
416 }
418#endif
419
420#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
422
427 template<std::size_t N> constexpr OUString(OUStringLiteral<N> const & literal):
428 pData(const_cast<rtl_uString *>(&literal.str)) {}
429 template<std::size_t N> OUString(OUStringLiteral<N> &&) = delete;
431#endif
432
447 OUString( const char * value, sal_Int32 length,
448 rtl_TextEncoding encoding,
449 sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
450 {
451 pData = NULL;
452 rtl_string2UString( &pData, value, length, encoding, convertFlags );
453 if (pData == NULL) {
454 throw std::bad_alloc();
455 }
456 }
457
474 explicit OUString(
475 sal_uInt32 const * codePoints, sal_Int32 codePointCount):
476 pData(NULL)
477 {
478 rtl_uString_newFromCodePoints(&pData, codePoints, codePointCount);
479 if (pData == NULL) {
480 throw std::bad_alloc();
481 }
482 }
483
484#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
489 template< typename T1, typename T2 >
490 OUString( OUStringConcat< T1, T2 >&& c )
491 {
492 const sal_Int32 l = c.length();
493 pData = rtl_uString_alloc( l );
494 if (l != 0)
495 {
496 sal_Unicode* end = c.addData( pData->buffer );
497 pData->length = l;
498 *end = '\0';
499 }
500 }
501
506 template< typename T >
507 OUString( OUStringNumber< T >&& n )
508 : OUString( n.buf, n.length )
509 {}
510#endif
511
512#if defined LIBO_INTERNAL_ONLY
513 explicit OUString(std::u16string_view sv) {
514 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
515 throw std::bad_alloc();
516 }
517 pData = nullptr;
518 rtl_uString_newFromStr_WithLength(&pData, sv.data(), sv.size());
519 }
520#endif
521
526 {
527 rtl_uString_release( pData );
528 }
529
541 static OUString const & unacquired( rtl_uString * const * ppHandle )
542 { return * reinterpret_cast< OUString const * >( ppHandle ); }
543
549 OUString & operator=( const OUString & str )
550 {
551 rtl_uString_assign( &pData, str.pData );
552 return *this;
553 }
554
555#if defined LIBO_INTERNAL_ONLY
562 OUString & operator=( OUString && str ) noexcept
563 {
564 rtl_uString_release( pData );
565 pData = str.pData;
566 str.pData = nullptr;
567 rtl_uString_new( &str.pData );
568 return *this;
569 }
570#endif
571
584 template< typename T >
586 {
587 assert(
590 rtl_uString_new(&pData);
591 } else {
593 &pData,
595 literal),
597 }
598 return *this;
599 }
600
601#if defined LIBO_INTERNAL_ONLY
603 template<typename T>
604 typename
606 operator =(T & literal) {
608 rtl_uString_new(&pData);
609 } else {
611 &pData,
612 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
613 literal),
614 libreoffice_internal::ConstCharArrayDetector<T>::length);
615 }
616 return *this;
617 }
618
620 template<std::size_t N> OUString & operator =(OUStringLiteral<N> const & literal) {
621 rtl_uString_release(pData);
622 pData = const_cast<rtl_uString *>(&literal.str);
623 return *this;
624 }
625 template<std::size_t N> OUString & operator =(OUStringLiteral<N> &&) = delete;
626
627 template<typename T>
628 OUString & operator =(OUStringNumber<T> && n) {
629 // n.length should never be zero, so no need to add an optimization for that case
630 rtl_uString_newFromStr_WithLength(&pData, n.buf, n.length);
631 return *this;
632 }
633
634 OUString & operator =(std::u16string_view sv) {
635 if (sv.empty()) {
636 rtl_uString_new(&pData);
637 } else {
638 rtl_uString_newFromStr_WithLength(&pData, sv.data(), sv.size());
639 }
640 return *this;
641 }
642#endif
643
644#if defined LIBO_INTERNAL_ONLY
653 inline OUString & operator+=( const OUStringBuffer & str ) &;
654#endif
655
663 OUString & operator+=( const OUString & str )
664#if defined LIBO_INTERNAL_ONLY
665 &
666#endif
667 {
668 return internalAppend(str.pData);
669 }
670#if defined LIBO_INTERNAL_ONLY
671 void operator+=(OUString const &) && = delete;
672#endif
673
680 template<typename T>
682 operator +=(T & literal)
683#if defined LIBO_INTERNAL_ONLY
684 &
685#endif
686 {
687 assert(
690 &pData, pData,
693 return *this;
694 }
695#if defined LIBO_INTERNAL_ONLY
696 template<typename T>
698 operator +=(T &) && = delete;
699#endif
700
701#if defined LIBO_INTERNAL_ONLY
703 template<typename T>
704 typename
706 operator +=(T & literal) & {
708 &pData, pData,
711 return *this;
712 }
713 template<typename T>
714 typename
715 libreoffice_internal::ConstCharArrayDetector<T, OUString &>::TypeUtf16
716 operator +=(T &) && = delete;
717
719 template<std::size_t N> OUString & operator +=(OUStringLiteral<N> const & literal) & {
720 rtl_uString_newConcatUtf16L(&pData, pData, literal.getStr(), literal.getLength());
721 return *this;
722 }
723 template<std::size_t N> void operator +=(OUStringLiteral<N> const &) && = delete;
724
725 OUString & operator +=(std::u16string_view sv) & {
726 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
727 throw std::bad_alloc();
728 }
729 rtl_uString_newConcatUtf16L(&pData, pData, sv.data(), sv.size());
730 return *this;
731 }
732 void operator +=(std::u16string_view) && = delete;
733#endif
734
735#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
740 template< typename T1, typename T2 >
741 OUString& operator+=( OUStringConcat< T1, T2 >&& c ) & {
742 sal_Int32 l = c.length();
743 if( l == 0 )
744 return *this;
745 l += pData->length;
746 rtl_uString_ensureCapacity( &pData, l );
747 sal_Unicode* end = c.addData( pData->buffer + pData->length );
748 *end = '\0';
749 pData->length = l;
750 return *this;
751 }
752 template<typename T1, typename T2> void operator +=(
753 OUStringConcat<T1, T2> &&) && = delete;
754
759 template< typename T >
760 OUString& operator+=( OUStringNumber< T >&& n ) & {
761 sal_Int32 l = n.length;
762 if( l == 0 )
763 return *this;
764 l += pData->length;
765 rtl_uString_ensureCapacity( &pData, l );
766 sal_Unicode* end = addDataHelper( pData->buffer + pData->length, n.buf, n.length );
767 *end = '\0';
768 pData->length = l;
769 return *this;
770 }
771 template<typename T> void operator +=(
772 OUStringNumber<T> &&) && = delete;
773#endif
774
779 void clear()
780 {
781 rtl_uString_new( &pData );
782 }
783
792 sal_Int32 getLength() const { return pData->length; }
793
802 bool isEmpty() const
803 {
804 return pData->length == 0;
805 }
806
814 const sal_Unicode * getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
815
825 sal_Unicode operator [](sal_Int32 index) const {
826 // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
827 assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
828 return getStr()[index];
829 }
830
843#if defined LIBO_INTERNAL_ONLY
844 sal_Int32 compareTo( std::u16string_view str ) const
845 {
846 return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
847 str.data(), str.length() );
848 }
849#else
850 sal_Int32 compareTo( const OUString & str ) const
851 {
852 return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
853 str.pData->buffer, str.pData->length );
854 }
855#endif
856
872#if defined LIBO_INTERNAL_ONLY
873 sal_Int32 compareTo( std::u16string_view str, sal_Int32 maxLength ) const
874 {
875 return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
876 str.data(), str.length(), maxLength );
877 }
878#else
879 sal_Int32 compareTo( const OUString & str, sal_Int32 maxLength ) const
880 {
881 return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
882 str.pData->buffer, str.pData->length, maxLength );
883 }
884#endif
885
898#if defined LIBO_INTERNAL_ONLY
899 sal_Int32 reverseCompareTo(std::u16string_view sv) const {
901 pData->buffer, pData->length, sv.data(), sv.size());
902 }
903#else
904 sal_Int32 reverseCompareTo( const OUString & str ) const
905 {
906 return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
907 str.pData->buffer, str.pData->length );
908 }
909#endif
910
916 template< typename T >
918 {
919 assert(
922 pData->buffer, pData->length,
925 }
926
938 bool equals( const OUString & str ) const
939 {
940 if ( pData->length != str.pData->length )
941 return false;
942 if ( pData == str.pData )
943 return true;
944 return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
945 str.pData->buffer, str.pData->length ) == 0;
946 }
947
962#if defined LIBO_INTERNAL_ONLY
963 bool equalsIgnoreAsciiCase(std::u16string_view sv) const {
964 return
966 pData->buffer, pData->length, sv.data(), sv.size())
967 == 0;
968 }
969#else
970 bool equalsIgnoreAsciiCase( const OUString & str ) const
971 {
972 if ( pData->length != str.pData->length )
973 return false;
974 if ( pData == str.pData )
975 return true;
976 return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
977 str.pData->buffer, str.pData->length ) == 0;
978 }
979#endif
980
996#if defined LIBO_INTERNAL_ONLY
997 sal_Int32 compareToIgnoreAsciiCase(std::u16string_view sv) const {
999 pData->buffer, pData->length, sv.data(), sv.size());
1000 }
1001#else
1002 sal_Int32 compareToIgnoreAsciiCase( const OUString & str ) const
1003 {
1004 return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
1005 str.pData->buffer, str.pData->length );
1006 }
1007#endif
1008
1014 template< typename T >
1016 {
1017 assert(
1019 return
1020 (pData->length
1023 pData->buffer, pData->length,
1025 literal))
1026 == 0);
1027 }
1028
1044#if defined LIBO_INTERNAL_ONLY
1045 bool match(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
1046 return
1048 pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1049 sv.size())
1050 == 0;
1051 }
1052#else
1053 bool match( const OUString & str, sal_Int32 fromIndex = 0 ) const
1054 {
1055 return rtl_ustr_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1056 str.pData->buffer, str.pData->length, str.pData->length ) == 0;
1057 }
1058#endif
1059
1065 template< typename T >
1066 typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
1067 {
1068 assert(
1070 return
1072 pData->buffer+fromIndex, pData->length-fromIndex,
1074 literal),
1076 == 0;
1077 }
1078
1097#if defined LIBO_INTERNAL_ONLY
1098 bool matchIgnoreAsciiCase(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
1099 return
1101 pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1102 sv.size())
1103 == 0;
1104 }
1105#else
1106 bool matchIgnoreAsciiCase( const OUString & str, sal_Int32 fromIndex = 0 ) const
1107 {
1108 return rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1109 str.pData->buffer, str.pData->length,
1110 str.pData->length ) == 0;
1111 }
1112#endif
1113
1119 template< typename T >
1121 {
1122 assert(
1124 return matchIgnoreAsciiCaseAsciiL(
1127 }
1128
1145 sal_Int32 compareToAscii( const char* asciiStr ) const
1146 {
1147 return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length, asciiStr );
1148 }
1149
1173 "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
1174 sal_Int32 compareToAscii( const char * asciiStr, sal_Int32 maxLength ) const
1175 {
1176 return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer, pData->length,
1177 asciiStr, maxLength );
1178 }
1179
1199 sal_Int32 reverseCompareToAsciiL( const char * asciiStr, sal_Int32 asciiStrLength ) const
1200 {
1201 return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
1202 asciiStr, asciiStrLength );
1203 }
1204
1220 bool equalsAscii( const char* asciiStr ) const
1221 {
1222 return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length,
1223 asciiStr ) == 0;
1224 }
1225
1243 bool equalsAsciiL( const char* asciiStr, sal_Int32 asciiStrLength ) const
1244 {
1245 if ( pData->length != asciiStrLength )
1246 return false;
1247
1249 pData->buffer, asciiStr, asciiStrLength );
1250 }
1251
1270 bool equalsIgnoreAsciiCaseAscii( const char * asciiStr ) const
1271 {
1272 return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1273 }
1274
1293 sal_Int32 compareToIgnoreAsciiCaseAscii( const char * asciiStr ) const
1294 {
1295 return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr );
1296 }
1297
1318 bool equalsIgnoreAsciiCaseAsciiL( const char * asciiStr, sal_Int32 asciiStrLength ) const
1319 {
1320 if ( pData->length != asciiStrLength )
1321 return false;
1322
1323 return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1324 }
1325
1347 bool matchAsciiL( const char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1348 {
1349 return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1350 asciiStr, asciiStrLength ) == 0;
1351 }
1352
1353 // This overload is left undefined, to detect calls of matchAsciiL that
1354 // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1355 // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1356 // platforms):
1357#if SAL_TYPES_SIZEOFLONG == 8
1358 void matchAsciiL(char const *, sal_Int32, rtl_TextEncoding) const;
1359#endif
1360
1385 bool matchIgnoreAsciiCaseAsciiL( const char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1386 {
1387 return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1388 asciiStr, asciiStrLength ) == 0;
1389 }
1390
1391 // This overload is left undefined, to detect calls of
1392 // matchIgnoreAsciiCaseAsciiL that erroneously use
1393 // RTL_CONSTASCII_USTRINGPARAM instead of RTL_CONSTASCII_STRINGPARAM (but
1394 // would lead to ambiguities on 32 bit platforms):
1395#if SAL_TYPES_SIZEOFLONG == 8
1396 void matchIgnoreAsciiCaseAsciiL(char const *, sal_Int32, rtl_TextEncoding)
1397 const;
1398#endif
1399
1414#if defined LIBO_INTERNAL_ONLY
1415 bool startsWith(std::u16string_view sv, OUString * rest = nullptr) const {
1416 auto const b = match(sv);
1417 if (b && rest != nullptr) {
1418 *rest = copy(sv.size());
1419 }
1420 return b;
1421 }
1422#else
1423 bool startsWith(OUString const & str, OUString * rest = NULL) const {
1424 bool b = match(str);
1425 if (b && rest != NULL) {
1426 *rest = copy(str.getLength());
1427 }
1428 return b;
1429 }
1430#endif
1431
1437 template< typename T >
1439 T & literal, OUString * rest = NULL) const
1440 {
1441 assert(
1443 bool b
1445 <= sal_uInt32(pData->length))
1447 pData->buffer,
1449 literal),
1451 if (b && rest != NULL) {
1452 *rest = copy(
1454 }
1455 return b;
1456 }
1457
1478#if defined LIBO_INTERNAL_ONLY
1479 bool startsWithIgnoreAsciiCase(std::u16string_view sv, OUString * rest = nullptr) const {
1480 auto const b = matchIgnoreAsciiCase(sv);
1481 if (b && rest != nullptr) {
1482 *rest = copy(sv.size());
1483 }
1484 return b;
1485 }
1486#else
1487 bool startsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL)
1488 const
1489 {
1490 bool b = matchIgnoreAsciiCase(str);
1491 if (b && rest != NULL) {
1492 *rest = copy(str.getLength());
1493 }
1494 return b;
1495 }
1496#endif
1497
1503 template< typename T >
1505 startsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1506 {
1507 assert(
1509 bool b
1511 <= sal_uInt32(pData->length))
1513 pData->buffer,
1516 literal),
1518 == 0);
1519 if (b && rest != NULL) {
1520 *rest = copy(
1522 }
1523 return b;
1524 }
1525
1540#if defined LIBO_INTERNAL_ONLY
1541 bool endsWith(std::u16string_view sv, OUString * rest = nullptr) const {
1542 auto const b = sv.size() <= sal_uInt32(pData->length)
1543 && match(sv, pData->length - sv.size());
1544 if (b && rest != nullptr) {
1545 *rest = copy(0, (pData->length - sv.size()));
1546 }
1547 return b;
1548 }
1549#else
1550 bool endsWith(OUString const & str, OUString * rest = NULL) const {
1551 bool b = str.getLength() <= getLength()
1552 && match(str, getLength() - str.getLength());
1553 if (b && rest != NULL) {
1554 *rest = copy(0, getLength() - str.getLength());
1555 }
1556 return b;
1557 }
1558#endif
1559
1565 template< typename T >
1567 endsWith(T & literal, OUString * rest = NULL) const
1568 {
1569 assert(
1571 bool b
1573 <= sal_uInt32(pData->length))
1575 (pData->buffer + pData->length
1578 literal),
1580 if (b && rest != NULL) {
1581 *rest = copy(
1582 0,
1583 (getLength()
1585 }
1586 return b;
1587 }
1588
1600 bool endsWithAsciiL(char const * asciiStr, sal_Int32 asciiStrLength)
1601 const
1602 {
1603 return asciiStrLength <= pData->length
1605 pData->buffer + pData->length - asciiStrLength, asciiStr,
1606 asciiStrLength);
1607 }
1608
1629#if defined LIBO_INTERNAL_ONLY
1630 bool endsWithIgnoreAsciiCase(std::u16string_view sv, OUString * rest = nullptr) const {
1631 auto const b = sv.size() <= sal_uInt32(pData->length)
1632 && matchIgnoreAsciiCase(sv, pData->length - sv.size());
1633 if (b && rest != nullptr) {
1634 *rest = copy(0, pData->length - sv.size());
1635 }
1636 return b;
1637 }
1638#else
1639 bool endsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL) const
1640 {
1641 bool b = str.getLength() <= getLength()
1642 && matchIgnoreAsciiCase(str, getLength() - str.getLength());
1643 if (b && rest != NULL) {
1644 *rest = copy(0, getLength() - str.getLength());
1645 }
1646 return b;
1647 }
1648#endif
1649
1655 template< typename T >
1657 endsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1658 {
1659 assert(
1661 bool b
1663 <= sal_uInt32(pData->length))
1665 (pData->buffer + pData->length
1669 literal),
1671 == 0);
1672 if (b && rest != NULL) {
1673 *rest = copy(
1674 0,
1675 (getLength()
1677 }
1678 return b;
1679 }
1680
1692 char const * asciiStr, sal_Int32 asciiStrLength) const
1693 {
1694 return asciiStrLength <= pData->length
1696 pData->buffer + pData->length - asciiStrLength,
1697 asciiStrLength, asciiStr, asciiStrLength)
1698 == 0);
1699 }
1700
1701 friend bool operator == ( const OUString& rStr1, const OUString& rStr2 )
1702 { return rStr1.equals(rStr2); }
1703
1704 friend bool operator != ( const OUString& rStr1, const OUString& rStr2 )
1705 { return !(operator == ( rStr1, rStr2 )); }
1706
1707 friend bool operator < ( const OUString& rStr1, const OUString& rStr2 )
1708 { return rStr1.compareTo( rStr2 ) < 0; }
1709 friend bool operator > ( const OUString& rStr1, const OUString& rStr2 )
1710 { return rStr1.compareTo( rStr2 ) > 0; }
1711 friend bool operator <= ( const OUString& rStr1, const OUString& rStr2 )
1712 { return rStr1.compareTo( rStr2 ) <= 0; }
1713 friend bool operator >= ( const OUString& rStr1, const OUString& rStr2 )
1714 { return rStr1.compareTo( rStr2 ) >= 0; }
1715
1716#if defined LIBO_INTERNAL_ONLY
1717
1718 template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1719 operator ==(OUString const & s1, T const & s2) {
1721 == 0;
1722 }
1723
1724 template<typename T>
1725 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1726 operator ==(OUString const & s1, T & s2) {
1727 return rtl_ustr_compare_WithLength(s1.getStr(), s1.getLength(), s2, rtl_ustr_getLength(s2))
1728 == 0;
1729 }
1730
1731 template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1732 operator ==(T const & s1, OUString const & s2) {
1733 return rtl_ustr_compare_WithLength(s1, rtl_ustr_getLength(s1), s2.getStr(), s2.getLength())
1734 == 0;
1735 }
1736
1737 template<typename T>
1738 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1739 operator ==(T & s1, OUString const & s2) {
1740 return rtl_ustr_compare_WithLength(s1, rtl_ustr_getLength(s1), s2.getStr(), s2.getLength())
1741 == 0;
1742 }
1743
1744 template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1745 operator !=(OUString const & s1, T const & s2) { return !(s1 == s2); }
1746
1747 template<typename T>
1748 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1749 operator !=(OUString const & s1, T & s2) { return !(s1 == s2); }
1750
1751 template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1752 operator !=(T const & s1, OUString const & s2) { return !(s1 == s2); }
1753
1754 template<typename T>
1755 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1756 operator !=(T & s1, OUString const & s2) { return !(s1 == s2); }
1757
1758#else
1759
1760 friend bool operator == ( const OUString& rStr1, const sal_Unicode * pStr2 )
1761 { return rStr1.compareTo( pStr2 ) == 0; }
1762 friend bool operator == ( const sal_Unicode * pStr1, const OUString& rStr2 )
1763 { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
1764
1765 friend bool operator != ( const OUString& rStr1, const sal_Unicode * pStr2 )
1766 { return !(operator == ( rStr1, pStr2 )); }
1767 friend bool operator != ( const sal_Unicode * pStr1, const OUString& rStr2 )
1768 { return !(operator == ( pStr1, rStr2 )); }
1769
1770#endif
1771
1779 template< typename T >
1781 {
1782 assert(
1784 return rString.equalsAsciiL(
1787 }
1795 template< typename T >
1797 {
1798 assert(
1800 return rString.equalsAsciiL(
1803 }
1811 template< typename T >
1813 {
1814 assert(
1816 return !rString.equalsAsciiL(
1819 }
1827 template< typename T >
1829 {
1830 assert(
1832 return !rString.equalsAsciiL(
1835 }
1836
1837#if defined LIBO_INTERNAL_ONLY
1839 template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1840 operator ==(OUString const & string, T & literal) {
1841 return
1843 string.pData->buffer, string.pData->length,
1845 literal),
1847 == 0;
1848 }
1850 template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1851 operator ==(T & literal, OUString const & string) {
1852 return
1854 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1855 literal),
1856 libreoffice_internal::ConstCharArrayDetector<T>::length,
1857 string.pData->buffer, string.pData->length)
1858 == 0;
1859 }
1861 template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1862 operator !=(OUString const & string, T & literal) {
1863 return
1865 string.pData->buffer, string.pData->length,
1866 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1867 literal),
1868 libreoffice_internal::ConstCharArrayDetector<T>::length)
1869 != 0;
1870 }
1872 template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1873 operator !=(T & literal, OUString const & string) {
1874 return
1876 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1877 literal),
1878 libreoffice_internal::ConstCharArrayDetector<T>::length,
1879 string.pData->buffer, string.pData->length)
1880 != 0;
1881 }
1882#endif
1883
1891 sal_Int32 hashCode() const
1892 {
1893 return rtl_ustr_hashCode_WithLength( pData->buffer, pData->length );
1894 }
1895
1909 sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
1910 {
1911 sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1912 return (ret < 0 ? ret : ret+fromIndex);
1913 }
1914
1924 sal_Int32 lastIndexOf( sal_Unicode ch ) const
1925 {
1926 return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1927 }
1928
1941 sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
1942 {
1943 return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1944 }
1945
1961#if defined LIBO_INTERNAL_ONLY
1962 sal_Int32 indexOf(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
1963 auto const n = rtl_ustr_indexOfStr_WithLength(
1964 pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size());
1965 return n < 0 ? n : n + fromIndex;
1966 }
1967#else
1968 sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
1969 {
1970 sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1971 str.pData->buffer, str.pData->length );
1972 return (ret < 0 ? ret : ret+fromIndex);
1973 }
1974#endif
1975
1981 template< typename T >
1982 typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1983 {
1984 assert(
1987 pData->buffer + fromIndex, pData->length - fromIndex,
1990 return n < 0 ? n : n + fromIndex;
1991 }
1992
2016 sal_Int32 indexOfAsciiL(
2017 char const * str, sal_Int32 len, sal_Int32 fromIndex = 0) const
2018 {
2019 sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
2020 pData->buffer + fromIndex, pData->length - fromIndex, str, len);
2021 return ret < 0 ? ret : ret + fromIndex;
2022 }
2023
2024 // This overload is left undefined, to detect calls of indexOfAsciiL that
2025 // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
2026 // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
2027 // platforms):
2028#if SAL_TYPES_SIZEOFLONG == 8
2029 void indexOfAsciiL(char const *, sal_Int32 len, rtl_TextEncoding) const;
2030#endif
2031
2047#if defined LIBO_INTERNAL_ONLY
2048 sal_Int32 lastIndexOf(std::u16string_view sv) const {
2050 pData->buffer, pData->length, sv.data(), sv.size());
2051 }
2052#else
2053 sal_Int32 lastIndexOf( const OUString & str ) const
2054 {
2055 return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
2056 str.pData->buffer, str.pData->length );
2057 }
2058#endif
2059
2077#if defined LIBO_INTERNAL_ONLY
2078 sal_Int32 lastIndexOf(std::u16string_view sv, sal_Int32 fromIndex) const {
2079 return rtl_ustr_lastIndexOfStr_WithLength(pData->buffer, fromIndex, sv.data(), sv.size());
2080 }
2081#else
2082 sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
2083 {
2084 return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
2085 str.pData->buffer, str.pData->length );
2086 }
2087#endif
2088
2094 template< typename T >
2096 {
2097 assert(
2100 pData->buffer, pData->length,
2103 }
2104
2124 sal_Int32 lastIndexOfAsciiL(char const * str, sal_Int32 len) const
2125 {
2127 pData->buffer, pData->length, str, len);
2128 }
2129
2140 SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex ) const
2141 {
2142 return copy(beginIndex, getLength() - beginIndex);
2143 }
2144
2157 SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const
2158 {
2159 rtl_uString *pNew = NULL;
2160 rtl_uString_newFromSubString( &pNew, pData, beginIndex, count );
2161 return OUString( pNew, SAL_NO_ACQUIRE );
2162 }
2163
2164#if defined LIBO_INTERNAL_ONLY
2175 SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex ) const
2176 {
2177 assert(beginIndex >= 0);
2178 assert(beginIndex <= getLength());
2179 return subView(beginIndex, getLength() - beginIndex);
2180 }
2181
2194 SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex, sal_Int32 count ) const
2195 {
2196 assert(beginIndex >= 0);
2197 assert(count >= 0);
2198 assert(beginIndex <= getLength());
2199 assert(count <= getLength() - beginIndex);
2200 return std::u16string_view(*this).substr(beginIndex, count);
2201 }
2202#endif
2203
2204#ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2213 SAL_WARN_UNUSED_RESULT OUString concat( const OUString & str ) const
2214 {
2215 rtl_uString* pNew = NULL;
2216 rtl_uString_newConcat( &pNew, pData, str.pData );
2217 return OUString( pNew, SAL_NO_ACQUIRE );
2218 }
2219#endif
2220
2221#ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2222 friend OUString operator+( const OUString& rStr1, const OUString& rStr2 )
2223 {
2224 return rStr1.concat( rStr2 );
2225 }
2226#endif
2227
2228// hide this from internal code to avoid ambiguous lookup error
2229#ifndef LIBO_INTERNAL_ONLY
2243 SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const
2244 {
2245 rtl_uString* pNew = NULL;
2246 rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
2247 return OUString( pNew, SAL_NO_ACQUIRE );
2248 }
2249#endif
2250
2251#ifdef LIBO_INTERNAL_ONLY
2252 SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, std::u16string_view newStr ) const
2253 {
2254 rtl_uString* pNew = NULL;
2255 rtl_uString_newReplaceStrAtUtf16L( &pNew, pData, index, count, newStr.data(), newStr.size() );
2256 return OUString( pNew, SAL_NO_ACQUIRE );
2257 }
2258#endif
2259
2274 {
2275 rtl_uString* pNew = NULL;
2276 rtl_uString_newReplace( &pNew, pData, oldChar, newChar );
2277 return OUString( pNew, SAL_NO_ACQUIRE );
2278 }
2279
2298#if defined LIBO_INTERNAL_ONLY
2299 [[nodiscard]] OUString replaceFirst(
2300 std::u16string_view from, std::u16string_view to, sal_Int32 * index = nullptr) const
2301 {
2302 rtl_uString * s = nullptr;
2303 sal_Int32 i = 0;
2305 &s, pData, from.data(), from.size(), to.data(), to.size(),
2306 index == nullptr ? &i : index);
2307 return OUString(s, SAL_NO_ACQUIRE);
2308 }
2309#else
2311 OUString const & from, OUString const & to, sal_Int32 * index = NULL) const
2312 {
2313 rtl_uString * s = NULL;
2314 sal_Int32 i = 0;
2316 &s, pData, from.pData, to.pData, index == NULL ? &i : index);
2317 return OUString(s, SAL_NO_ACQUIRE);
2318 }
2319#endif
2320
2339#if defined LIBO_INTERNAL_ONLY
2340 template<typename T> [[nodiscard]]
2342 T & from, std::u16string_view to, sal_Int32 * index = nullptr) const
2343 {
2345 rtl_uString * s = nullptr;
2346 sal_Int32 i = 0;
2350 index == nullptr ? &i : index);
2351 return OUString(s, SAL_NO_ACQUIRE);
2352 }
2353#else
2354 template< typename T >
2356 sal_Int32 * index = NULL) const
2357 {
2359 rtl_uString * s = NULL;
2360 sal_Int32 i = 0;
2362 &s, pData,
2365 index == NULL ? &i : index);
2366 return OUString(s, SAL_NO_ACQUIRE);
2367 }
2368#endif
2369
2388#if defined LIBO_INTERNAL_ONLY
2389 template<typename T> [[nodiscard]]
2391 std::u16string_view from, T & to, sal_Int32 * index = nullptr) const
2392 {
2394 rtl_uString * s = nullptr;
2395 sal_Int32 i = 0;
2397 &s, pData, from.data(), from.size(),
2399 libreoffice_internal::ConstCharArrayDetector<T>::length, index == nullptr ? &i : index);
2400 return OUString(s, SAL_NO_ACQUIRE);
2401 }
2402#else
2403 template< typename T >
2405 sal_Int32 * index = NULL) const
2406 {
2408 rtl_uString * s = NULL;
2409 sal_Int32 i = 0;
2411 &s, pData, from.pData,
2414 index == NULL ? &i : index);
2415 return OUString(s, SAL_NO_ACQUIRE);
2416 }
2417#endif
2418
2437 template< typename T1, typename T2 >
2439 replaceFirst( T1& from, T2& to, sal_Int32 * index = NULL) const
2440 {
2443 rtl_uString * s = NULL;
2444 sal_Int32 i = 0;
2446 &s, pData,
2451 index == NULL ? &i : index);
2452 return OUString(s, SAL_NO_ACQUIRE);
2453 }
2454
2470#if defined LIBO_INTERNAL_ONLY
2471 [[nodiscard]] OUString replaceAll(
2472 std::u16string_view from, std::u16string_view to, sal_Int32 fromIndex = 0) const
2473 {
2474 rtl_uString * s = nullptr;
2475 rtl_uString_newReplaceAllFromIndexUtf16LUtf16L(
2476 &s, pData, from.data(), from.size(), to.data(), to.size(), fromIndex);
2477 return OUString(s, SAL_NO_ACQUIRE);
2478 }
2479#else
2481 OUString const & from, OUString const & to, sal_Int32 fromIndex = 0) const
2482 {
2483 rtl_uString * s = NULL;
2484 rtl_uString_newReplaceAllFromIndex(&s, pData, from.pData, to.pData, fromIndex);
2485 return OUString(s, SAL_NO_ACQUIRE);
2486 }
2487#endif
2488
2502#if defined LIBO_INTERNAL_ONLY
2503 template<typename T> [[nodiscard]]
2505 T & from, std::u16string_view to) const
2506 {
2508 rtl_uString * s = nullptr;
2512 return OUString(s, SAL_NO_ACQUIRE);
2513 }
2514#else
2515 template< typename T >
2517 {
2519 rtl_uString * s = NULL;
2521 &s, pData,
2524 return OUString(s, SAL_NO_ACQUIRE);
2525 }
2526#endif
2527
2541#if defined LIBO_INTERNAL_ONLY
2542 template<typename T> [[nodiscard]]
2544 std::u16string_view from, T & to) const
2545 {
2547 rtl_uString * s = nullptr;
2549 &s, pData, from.data(), from.size(),
2552 return OUString(s, SAL_NO_ACQUIRE);
2553 }
2554#else
2555 template< typename T >
2557 {
2559 rtl_uString * s = NULL;
2561 &s, pData, from.pData,
2564 return OUString(s, SAL_NO_ACQUIRE);
2565 }
2566#endif
2567
2581 template< typename T1, typename T2 >
2583 replaceAll( T1& from, T2& to ) const
2584 {
2587 rtl_uString * s = NULL;
2589 &s, pData,
2594 return OUString(s, SAL_NO_ACQUIRE);
2595 }
2596
2608 {
2609 rtl_uString* pNew = NULL;
2610 rtl_uString_newToAsciiLowerCase( &pNew, pData );
2611 return OUString( pNew, SAL_NO_ACQUIRE );
2612 }
2613
2625 {
2626 rtl_uString* pNew = NULL;
2627 rtl_uString_newToAsciiUpperCase( &pNew, pData );
2628 return OUString( pNew, SAL_NO_ACQUIRE );
2629 }
2630
2645 {
2646 rtl_uString* pNew = NULL;
2647 rtl_uString_newTrim( &pNew, pData );
2648 return OUString( pNew, SAL_NO_ACQUIRE );
2649 }
2650
2675 OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const
2676 {
2677 rtl_uString * pNew = NULL;
2678 index = rtl_uString_getToken( &pNew, pData, token, cTok, index );
2679 return OUString( pNew, SAL_NO_ACQUIRE );
2680 }
2681
2695 OUString getToken(sal_Int32 count, sal_Unicode separator) const {
2696 sal_Int32 n = 0;
2697 return getToken(count, separator, n);
2698 }
2699
2708 bool toBoolean() const
2709 {
2710 return rtl_ustr_toBoolean( pData->buffer );
2711 }
2712
2720 {
2721 return pData->buffer[0];
2722 }
2723
2734 sal_Int32 toInt32( sal_Int16 radix = 10 ) const
2735 {
2736 return rtl_ustr_toInt32( pData->buffer, radix );
2737 }
2738
2751 sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
2752 {
2753 return rtl_ustr_toUInt32( pData->buffer, radix );
2754 }
2755
2766 sal_Int64 toInt64( sal_Int16 radix = 10 ) const
2767 {
2768 return rtl_ustr_toInt64( pData->buffer, radix );
2769 }
2770
2783 sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
2784 {
2785 return rtl_ustr_toUInt64( pData->buffer, radix );
2786 }
2787
2796 float toFloat() const
2797 {
2798 return rtl_ustr_toFloat( pData->buffer );
2799 }
2800
2809 double toDouble() const
2810 {
2811 return rtl_ustr_toDouble( pData->buffer );
2812 }
2813
2814
2831 {
2832 rtl_uString * pNew = NULL;
2833 rtl_uString_intern( &pNew, pData );
2834 if (pNew == NULL) {
2835 throw std::bad_alloc();
2836 }
2837 return OUString( pNew, SAL_NO_ACQUIRE );
2838 }
2839
2865 static OUString intern( const char * value, sal_Int32 length,
2866 rtl_TextEncoding encoding,
2867 sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS,
2868 sal_uInt32 *pInfo = NULL )
2869 {
2870 rtl_uString * pNew = NULL;
2871 rtl_uString_internConvert( &pNew, value, length, encoding,
2872 convertFlags, pInfo );
2873 if (pNew == NULL) {
2874 throw std::bad_alloc();
2875 }
2876 return OUString( pNew, SAL_NO_ACQUIRE );
2877 }
2878
2903 bool convertToString(OString * pTarget, rtl_TextEncoding nEncoding,
2904 sal_uInt32 nFlags) const
2905 {
2906 return rtl_convertUStringToString(&pTarget->pData, pData->buffer,
2907 pData->length, nEncoding, nFlags);
2908 }
2909
2962 sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1) const
2963 {
2965 pData, indexUtf16, incrementCodePoints);
2966 }
2967
2977#if defined LIBO_INTERNAL_ONLY
2978 static OUString fromUtf8(std::string_view rSource)
2979 {
2980 OUString aTarget;
2981 bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
2982 rSource.data(),
2983 rSource.length(),
2986 (void) bSuccess;
2987 assert(bSuccess);
2988 return aTarget;
2989 }
2990#else
2991 static OUString fromUtf8(const OString& rSource)
2992 {
2993 OUString aTarget;
2994 bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
2995 rSource.getStr(),
2996 rSource.getLength(),
2999 (void) bSuccess;
3000 assert(bSuccess);
3001 return aTarget;
3002 }
3003#endif
3004
3016 {
3017 OString aTarget;
3018 bool bSuccess = rtl_convertUStringToString(&aTarget.pData,
3019 getStr(),
3020 getLength(),
3023 (void) bSuccess;
3024 assert(bSuccess);
3025 return aTarget;
3026 }
3027
3028#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3029
3030 static OUStringNumber< int > number( int i, sal_Int16 radix = 10 )
3031 {
3032 return OUStringNumber< int >( i, radix );
3033 }
3034 static OUStringNumber< long long > number( long long ll, sal_Int16 radix = 10 )
3035 {
3036 return OUStringNumber< long long >( ll, radix );
3037 }
3038 static OUStringNumber< unsigned long long > number( unsigned long long ll, sal_Int16 radix = 10 )
3039 {
3040 return OUStringNumber< unsigned long long >( ll, radix );
3041 }
3042 static OUStringNumber< unsigned long long > number( unsigned int i, sal_Int16 radix = 10 )
3043 {
3044 return number( static_cast< unsigned long long >( i ), radix );
3045 }
3046 static OUStringNumber< long long > number( long i, sal_Int16 radix = 10)
3047 {
3048 return number( static_cast< long long >( i ), radix );
3049 }
3050 static OUStringNumber< unsigned long long > number( unsigned long i, sal_Int16 radix = 10 )
3051 {
3052 return number( static_cast< unsigned long long >( i ), radix );
3053 }
3054 static OUStringNumber< float > number( float f )
3055 {
3056 return OUStringNumber< float >( f );
3057 }
3058 static OUStringNumber< double > number( double d )
3059 {
3060 return OUStringNumber< double >( d );
3061 }
3062#else
3073 static OUString number( int i, sal_Int16 radix = 10 )
3074 {
3076 return OUString(aBuf, rtl_ustr_valueOfInt32(aBuf, i, radix));
3077 }
3080 static OUString number( unsigned int i, sal_Int16 radix = 10 )
3081 {
3082 return number( static_cast< unsigned long long >( i ), radix );
3083 }
3086 static OUString number( long i, sal_Int16 radix = 10)
3087 {
3088 return number( static_cast< long long >( i ), radix );
3089 }
3092 static OUString number( unsigned long i, sal_Int16 radix = 10 )
3093 {
3094 return number( static_cast< unsigned long long >( i ), radix );
3095 }
3098 static OUString number( long long ll, sal_Int16 radix = 10 )
3099 {
3101 return OUString(aBuf, rtl_ustr_valueOfInt64(aBuf, ll, radix));
3102 }
3105 static OUString number( unsigned long long ll, sal_Int16 radix = 10 )
3106 {
3108 return OUString(aBuf, rtl_ustr_valueOfUInt64(aBuf, ll, radix));
3109 }
3110
3120 static OUString number( float f )
3121 {
3123 return OUString(aBuf, rtl_ustr_valueOfFloat(aBuf, f));
3124 }
3125
3135 static OUString number( double d )
3136 {
3138 return OUString(aBuf, rtl_ustr_valueOfDouble(aBuf, d));
3139 }
3140#endif
3141
3153 SAL_DEPRECATED("use boolean()") static OUString valueOf( sal_Bool b )
3154 {
3155 return boolean(b);
3156 }
3157
3169 static OUString boolean( bool b )
3170 {
3172 return OUString(aBuf, rtl_ustr_valueOfBoolean(aBuf, b));
3173 }
3174
3182 SAL_DEPRECATED("convert to OUString or use directly") static OUString valueOf( sal_Unicode c )
3183 {
3184 return OUString( &c, 1 );
3185 }
3186
3197 SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
3198 {
3199 return number( i, radix );
3200 }
3201
3212 SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
3213 {
3214 return number( ll, radix );
3215 }
3216
3226 SAL_DEPRECATED("use number()") static OUString valueOf( float f )
3227 {
3228 return number(f);
3229 }
3230
3240 SAL_DEPRECATED("use number()") static OUString valueOf( double d )
3241 {
3242 return number(d);
3243 }
3244
3260 static OUString createFromAscii( const char * value )
3261 {
3262 rtl_uString* pNew = NULL;
3263 rtl_uString_newFromAscii( &pNew, value );
3264 return OUString( pNew, SAL_NO_ACQUIRE );
3265 }
3266
3267#if defined LIBO_INTERNAL_ONLY
3268 static OUString createFromAscii(std::string_view value) {
3269 rtl_uString * p = nullptr;
3270 rtl_uString_newFromLiteral(&p, value.data(), value.size(), 0); //TODO: check for overflow
3271 return OUString(p, SAL_NO_ACQUIRE);
3272 }
3273 #endif
3274
3275#if defined LIBO_INTERNAL_ONLY
3276 operator std::u16string_view() const { return {getStr(), sal_uInt32(getLength())}; }
3277#endif
3278
3279#if defined LIBO_INTERNAL_ONLY
3280 // A wrapper for the first expression in an
3281 //
3282 // OUString::Concat(e1) + e2 + ...
3283 //
3284 // concatenation chain, when neither of the first two e1, e2 is one of our rtl string-related
3285 // classes (so something like
3286 //
3287 // OUString s = "a" + (b ? std::u16string_view(u"c") : std::u16string_view(u"dd"));
3288 //
3289 // would not compile):
3290 template<typename T> [[nodiscard]] static
3291 typename std::enable_if_t<
3292 ToStringHelper<T>::allowOUStringConcat, OUStringConcat<OUStringConcatMarker, T>>
3293 Concat(T const & value) { return OUStringConcat<OUStringConcatMarker, T>({}, value); }
3294
3295 // This overload is needed so that an argument of type 'char const[N]' ends up as
3296 // 'OUStringConcat<rtl::OUStringConcatMarker, char const[N]>' rather than as
3297 // 'OUStringConcat<rtl::OUStringConcatMarker, char[N]>':
3298 template<typename T, std::size_t N> [[nodiscard]] static
3299 typename std::enable_if_t<
3300 ToStringHelper<T[N]>::allowOUStringConcat, OUStringConcat<OUStringConcatMarker, T[N]>>
3301 Concat(T (& value)[N]) { return OUStringConcat<OUStringConcatMarker, T[N]>({}, value); }
3302#endif
3303
3304private:
3305 OUString & internalAppend( rtl_uString* pOtherData )
3306 {
3307 rtl_uString* pNewData = NULL;
3308 rtl_uString_newConcat( &pNewData, pData, pOtherData );
3309 if (pNewData == NULL) {
3310 throw std::bad_alloc();
3311 }
3312 rtl_uString_assign(&pData, pNewData);
3313 rtl_uString_release(pNewData);
3314 return *this;
3315 }
3316
3317};
3318
3319#if defined LIBO_INTERNAL_ONLY
3320// Can only define this after we define OUString
3321inline OUStringConstExpr::operator const OUString &() const { return OUString::unacquired(&pData); }
3322#endif
3323
3324#if defined LIBO_INTERNAL_ONLY
3325// Prevent the operator ==/!= overloads with 'sal_Unicode const *' parameter from
3326// being selected for nonsensical code like
3327//
3328// if (ouIdAttr == nullptr)
3329//
3330void operator ==(OUString const &, std::nullptr_t) = delete;
3331void operator ==(std::nullptr_t, OUString const &) = delete;
3332void operator !=(OUString const &, std::nullptr_t) = delete;
3333void operator !=(std::nullptr_t, OUString const &) = delete;
3334#endif
3335
3336#if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3337inline bool operator ==(OUString const & lhs, OUStringConcatenation const & rhs)
3338{ return lhs == std::u16string_view(rhs); }
3339inline bool operator !=(OUString const & lhs, OUStringConcatenation const & rhs)
3340{ return lhs != std::u16string_view(rhs); }
3341inline bool operator ==(OUStringConcatenation const & lhs, OUString const & rhs)
3342{ return std::u16string_view(lhs) == rhs; }
3343inline bool operator !=(OUStringConcatenation const & lhs, OUString const & rhs)
3344{ return std::u16string_view(lhs) != rhs; }
3345#endif
3346
3347#if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3349
3353template<>
3354struct ToStringHelper< OUString >
3355 {
3356 static std::size_t length( const OUString& s ) { return s.getLength(); }
3357 static sal_Unicode* addData( sal_Unicode* buffer, const OUString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
3358 static const bool allowOStringConcat = false;
3359 static const bool allowOUStringConcat = true;
3360 };
3361
3365template<std::size_t N>
3366struct ToStringHelper< OUStringLiteral<N> >
3367 {
3368 static std::size_t length( const OUStringLiteral<N>& str ) { return str.getLength(); }
3369 static sal_Unicode* addData( sal_Unicode* buffer, const OUStringLiteral<N>& str ) { return addDataHelper( buffer, str.getStr(), str.getLength() ); }
3370 static const bool allowOStringConcat = false;
3371 static const bool allowOUStringConcat = true;
3372 };
3373
3377template< typename charT, typename traits, typename T1, typename T2 >
3378inline std::basic_ostream<charT, traits> & operator <<(
3379 std::basic_ostream<charT, traits> & stream, OUStringConcat< T1, T2 >&& concat)
3380{
3381 return stream << OUString( std::move(concat) );
3382}
3383
3384
3386#endif
3387
3394{
3404 size_t operator()(const OUString& rString) const
3405 { return static_cast<size_t>(rString.hashCode()); }
3406};
3407
3408/* ======================================================================= */
3409
3427#if defined LIBO_INTERNAL_ONLY
3428inline OUString OStringToOUString( std::string_view rStr,
3429 rtl_TextEncoding encoding,
3430 sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
3431{
3432 return OUString( rStr.data(), rStr.length(), encoding, convertFlags );
3433}
3434#else
3436 rtl_TextEncoding encoding,
3437 sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
3438{
3439 return OUString( rStr.getStr(), rStr.getLength(), encoding, convertFlags );
3440}
3441#endif
3442
3460#if defined LIBO_INTERNAL_ONLY
3461inline OString OUStringToOString( std::u16string_view rUnicode,
3462 rtl_TextEncoding encoding,
3463 sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
3464{
3465 return OString( rUnicode.data(), rUnicode.length(), encoding, convertFlags );
3466}
3467#else
3468inline OString OUStringToOString( const OUString & rUnicode,
3469 rtl_TextEncoding encoding,
3470 sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
3471{
3472 return OString( rUnicode.getStr(), rUnicode.getLength(), encoding, convertFlags );
3473}
3474#endif
3475
3476/* ======================================================================= */
3477
3486template< typename charT, typename traits >
3487inline std::basic_ostream<charT, traits> & operator <<(
3488 std::basic_ostream<charT, traits> & stream, OUString const & rString)
3489{
3490 return stream <<
3492 // best effort; potentially loses data due to conversion failures
3493 // (stray surrogate halves) and embedded null characters
3494}
3495
3496} // namespace
3497
3498#ifdef RTL_STRING_UNITTEST
3499namespace rtl
3500{
3501typedef rtlunittest::OUString OUString;
3502}
3503#endif
3504
3505// In internal code, allow to use classes like OUString without having to
3506// explicitly refer to the rtl namespace, which is kind of superfluous given
3507// that OUString itself is namespaced by its OU prefix:
3508#if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3509using ::rtl::OUString;
3510using ::rtl::OUStringHash;
3513using ::rtl::OUStringLiteral;
3514using ::rtl::OUStringChar;
3515using ::rtl::OUStringConcatenation;
3516#endif
3517
3519
3524#if defined LIBO_INTERNAL_ONLY
3525namespace std {
3526
3527template<>
3528struct hash<::rtl::OUString>
3529{
3530 std::size_t operator()(::rtl::OUString const & s) const
3531 { return std::size_t(s.hashCode()); }
3532};
3533
3534}
3535
3536#endif
3538
3539#endif /* _RTL_USTRING_HXX */
3540
3541/* 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_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:1358
#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_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:2188
#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_Int32 oslInterlockedCount
Definition: interlck.h:44
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
Definition: bootstrap.hxx:34
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:2255
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:3435
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:3468
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
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:181
const char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:603
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:577
Definition: stringutils.hxx:136
Definition: stringutils.hxx:139
This String class provides base functionality for C++ like Unicode character array handling.
Definition: ustring.hxx:204
static OUString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: ustring.hxx:3073
OUString intern() const
Return a canonical representation for a string.
Definition: ustring.hxx:2830
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:1982
bool endsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string ends with a given substring.
Definition: ustring.hxx:1550
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:1691
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:2607
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:2516
const sal_Unicode * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:814
bool equalsIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:970
bool endsWithAsciiL(char const *asciiStr, sal_Int32 asciiStrLength) const
Check whether this string ends with a given ASCII string.
Definition: ustring.hxx:1600
OUString(const OUString &str)
New string from OUString.
Definition: ustring.hxx:224
sal_uInt32 iterateCodePoints(sal_Int32 *indexUtf16, sal_Int32 incrementCodePoints=1) const
Iterate through this string based on code points instead of UTF-16 code units.
Definition: ustring.hxx:2961
static OUString fromUtf8(const OString &rSource)
Convert an OString to an OUString, assuming that the OString is UTF-8-encoded.
Definition: ustring.hxx:2991
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:1066
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: ustring.hxx:2734
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: ustring.hxx:779
bool equalsIgnoreAsciiCaseAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1318
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:3105
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:2016
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:2583
~OUString()
Release the string data.
Definition: ustring.hxx:525
sal_Int32 compareTo(const OUString &str, sal_Int32 maxLength) const
Compares two strings with a maximum count of characters.
Definition: ustring.hxx:879
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:2124
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:1909
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:2556
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:3098
bool matchAsciiL(const char *asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:1347
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:2480
float toFloat() const
Returns the float value from this string.
Definition: ustring.hxx:2796
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:3092
static OUString createFromAscii(const char *value)
Returns an OUString copied without conversion from an ASCII character string.
Definition: ustring.hxx:3260
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:2355
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:2439
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:2273
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: ustring.hxx:1891
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:917
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1796
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1780
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:3086
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:1015
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: ustring.hxx:2783
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:1385
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:1505
OString toUtf8() const
Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully.
Definition: ustring.hxx:3015
sal_Int32 reverseCompareToAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Compares two strings in reverse order.
Definition: ustring.hxx:1199
bool equalsAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform a comparison of two strings.
Definition: ustring.hxx:1243
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:3080
bool convertToString(OString *pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) const
Converts to an OString, signalling failure.
Definition: ustring.hxx:2903
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:1438
OUString(rtl_uString *str)
New string from OUString data.
Definition: ustring.hxx:250
OUString(const sal_Unicode *value, sal_Int32 length)
New string from a Unicode character buffer array.
Definition: ustring.hxx:329
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:1639
sal_Int32 compareTo(const OUString &str) const
Compares two strings.
Definition: ustring.hxx:850
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1812
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:585
bool startsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: ustring.hxx:1423
sal_Int32 lastIndexOf(sal_Unicode ch) const
Returns the index within this string of the last occurrence of the specified character,...
Definition: ustring.hxx:1924
sal_Int32 compareToIgnoreAsciiCaseAscii(const char *asciiStr) const
Compares two ASCII strings ignoring case.
Definition: ustring.hxx:1293
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:2404
OUString(sal_Unicode value)
New string from a single Unicode character.
Definition: ustring.hxx:272
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:2310
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: ustring.hxx:2766
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: ustring.hxx:2751
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:1487
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:2082
static OUString const & unacquired(rtl_uString *const *ppHandle)
Provides an OUString const & passing a storage pointer of an rtl_uString * handle.
Definition: ustring.hxx:541
double toDouble() const
Returns the double value from this string.
Definition: ustring.hxx:2809
bool equalsAscii(const char *asciiStr) const
Perform a comparison of two strings.
Definition: ustring.hxx:1220
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:1120
OUString getToken(sal_Int32 token, sal_Unicode cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: ustring.hxx:2675
sal_Int32 getLength() const
Returns the length of this string.
Definition: ustring.hxx:792
bool equalsIgnoreAsciiCaseAscii(const char *asciiStr) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1270
OUString()
New string containing no characters.
Definition: ustring.hxx:213
OUString(const sal_Unicode *value)
New string from a Unicode character buffer array.
Definition: ustring.hxx:313
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:447
OUString & operator=(const OUString &str)
Assign a new string.
Definition: ustring.hxx:549
static OUString number(float f)
Returns the string representation of the float argument.
Definition: ustring.hxx:3120
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:802
sal_Int32 compareToIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1002
OUString(sal_uInt32 const *codePoints, sal_Int32 codePointCount)
Create a new string from an array of Unicode code points.
Definition: ustring.hxx:474
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:1567
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition: ustring.hxx:663
sal_Unicode toChar() const
Returns the first character from this string.
Definition: ustring.hxx:2719
OUString getToken(sal_Int32 count, sal_Unicode separator) const
Returns a token from the string.
Definition: ustring.hxx:2695
static OUString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: ustring.hxx:3169
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:2095
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:2157
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:1657
OUString(rtl_uString *str, __sal_NoAcquire)
New OUString from OUString data without acquiring it.
Definition: ustring.hxx:264
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:1941
SAL_WARN_UNUSED_RESULT OUString trim() const
Returns a new string resulting from removing white space from both ends of the string.
Definition: ustring.hxx:2644
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:2624
SAL_WARN_UNUSED_RESULT OUString concat(const OUString &str) const
Concatenates the specified string to the end of this string.
Definition: ustring.hxx:2213
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:2243
bool match(const OUString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:1053
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:1106
sal_Int32 compareToAscii(const char *asciiStr) const
Compares two strings.
Definition: ustring.hxx:1145
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:351
sal_Int32 reverseCompareTo(const OUString &str) const
Compares two strings in reverse order.
Definition: ustring.hxx:904
static OUString number(double d)
Returns the string representation of the double argument.
Definition: ustring.hxx:3135
friend OUString operator+(const OUString &rStr1, const OUString &rStr2)
Definition: ustring.hxx:2222
SAL_WARN_UNUSED_RESULT OUString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: ustring.hxx:2140
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1828
bool equals(const OUString &str) const
Perform a comparison of two strings.
Definition: ustring.hxx:938
sal_Int32 lastIndexOf(const OUString &str) const
Returns the index within this string of the last occurrence of the specified substring,...
Definition: ustring.hxx:2053
bool toBoolean() const
Returns the Boolean value from this string.
Definition: ustring.hxx:2708
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:1968
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:2865
A helper to use OUStrings with hash maps.
Definition: ustring.hxx:3394
size_t operator()(const OUString &rString) const
Compute a hash code for a string.
Definition: ustring.hxx:3404