LibreOfficeDev
LibreOfficeDev 7.5 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 struct Data {
121 Data() = default;
122
123 oslInterlockedCount refCount = 0x40000000; // SAL_STRING_STATIC_FLAG (sal/rtl/strimp.hxx)
124 sal_Int32 length = N - 1;
125 sal_Unicode buffer[N] = {}; //TODO: drop initialization for C++20 (P1331R2)
126 };
127
128 union {
129 rtl_uString str;
130 Data more = {};
131 };
132};
133
134#if defined RTL_STRING_UNITTEST
135namespace libreoffice_internal {
136template<std::size_t N> struct ExceptConstCharArrayDetector<OUStringLiteral<N>> {};
137template<std::size_t N> struct ExceptCharArrayDetector<OUStringLiteral<N>> {};
138}
139#endif
140
149class OUString;
150class OUStringConstExpr
151{
152public:
153 template<std::size_t N> constexpr OUStringConstExpr(OUStringLiteral<N> const & literal):
154 pData(const_cast<rtl_uString *>(&literal.str)) {}
155
156 // prevent mis-use
157 template<std::size_t N> constexpr OUStringConstExpr(OUStringLiteral<N> && literal)
158 = delete;
159
160 // no destructor necessary because we know we are pointing at a compile-time
161 // constant OUStringLiteral, which bypasses ref-counting.
162
166 constexpr std::u16string_view asView() const { return std::u16string_view(pData->buffer, pData->length); }
167
168 inline operator const OUString&() const;
169
170private:
171 rtl_uString* pData;
172};
173
175#endif
176
177/* ======================================================================= */
178
202class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OUString
203{
204public:
206 rtl_uString * pData;
208
213 {
214 pData = NULL;
215 rtl_uString_new( &pData );
216 }
217
223 OUString( const OUString & str )
224 {
225 pData = str.pData;
226 rtl_uString_acquire( pData );
227 }
228
229#if defined LIBO_INTERNAL_ONLY
236 OUString( OUString && str ) noexcept
237 {
238 pData = str.pData;
239 str.pData = nullptr;
240 rtl_uString_new( &str.pData );
241 }
242#endif
243
249 OUString( rtl_uString * str )
250 {
251 pData = str;
252 rtl_uString_acquire( pData );
253 }
254
263 OUString( rtl_uString * str, __sal_NoAcquire )
264 { pData = str; }
265
271 explicit OUString( sal_Unicode value )
272 : pData (NULL)
273 {
274 rtl_uString_newFromStr_WithLength( &pData, &value, 1 );
275 }
276
277#if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
279 // Catch inadvertent conversions to the above ctor (but still allow
280 // construction from char literals):
281 OUString(int) = delete;
282 explicit OUString(char c):
283 OUString(sal_Unicode(static_cast<unsigned char>(c)))
284 {}
286#endif
287
288#if defined LIBO_INTERNAL_ONLY
289
290 template<typename T> explicit OUString(
291 T const & value,
292 typename libreoffice_internal::CharPtrDetector<T, libreoffice_internal::Dummy>::TypeUtf16
293 = libreoffice_internal::Dummy()):
294 pData(nullptr)
295 { rtl_uString_newFromStr(&pData, value); }
296
297 template<typename T> explicit OUString(
298 T & value,
299 typename
300 libreoffice_internal::NonConstCharArrayDetector<T, libreoffice_internal::Dummy>::TypeUtf16
301 = libreoffice_internal::Dummy()):
302 pData(nullptr)
303 { rtl_uString_newFromStr(&pData, value); }
304
305#else
306
312 OUString( const sal_Unicode * value )
313 {
314 pData = NULL;
315 rtl_uString_newFromStr( &pData, value );
316 }
317
318#endif
319
328 OUString( const sal_Unicode * value, sal_Int32 length )
329 {
330 pData = NULL;
331 rtl_uString_newFromStr_WithLength( &pData, value, length );
332 }
333
349 template< typename T >
351 {
352 assert(
354 pData = NULL;
356 rtl_uString_new(&pData);
357 } else {
359 &pData,
361 literal),
363 }
364#ifdef RTL_STRING_UNITTEST
365 rtl_string_unittest_const_literal = true;
366#endif
367 }
368
369#if defined LIBO_INTERNAL_ONLY
371 template<typename T> OUString(
372 T & literal,
374 T, libreoffice_internal::Dummy>::TypeUtf16
376 pData(nullptr)
377 {
378 assert(
381 rtl_uString_new(&pData);
382 } else {
384 &pData,
385 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
386 literal),
387 libreoffice_internal::ConstCharArrayDetector<T>::length);
388 }
389 }
390#endif
391
392#if defined LIBO_INTERNAL_ONLY && defined RTL_STRING_UNITTEST
394
398 template< typename T >
399 OUString( T&, typename libreoffice_internal::ExceptConstCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
400 {
401 pData = NULL;
402 rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
403 rtl_string_unittest_invalid_conversion = true;
404 }
409 template< typename T >
410 OUString( const T&, typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
411 {
412 pData = NULL;
413 rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
414 rtl_string_unittest_invalid_conversion = true;
415 }
417#endif
418
419#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
421
426 template<std::size_t N> constexpr OUString(OUStringLiteral<N> const & literal):
427 pData(const_cast<rtl_uString *>(&literal.str)) {}
428 template<std::size_t N> OUString(OUStringLiteral<N> &&) = delete;
430#endif
431
446 OUString( const char * value, sal_Int32 length,
447 rtl_TextEncoding encoding,
448 sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
449 {
450 pData = NULL;
451 rtl_string2UString( &pData, value, length, encoding, convertFlags );
452 if (pData == NULL) {
453 throw std::bad_alloc();
454 }
455 }
456
473 explicit OUString(
474 sal_uInt32 const * codePoints, sal_Int32 codePointCount):
475 pData(NULL)
476 {
477 rtl_uString_newFromCodePoints(&pData, codePoints, codePointCount);
478 if (pData == NULL) {
479 throw std::bad_alloc();
480 }
481 }
482
483#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
488 template< typename T1, typename T2 >
489 OUString( OUStringConcat< T1, T2 >&& c )
490 {
491 const sal_Int32 l = c.length();
492 pData = rtl_uString_alloc( l );
493 if (l != 0)
494 {
495 sal_Unicode* end = c.addData( pData->buffer );
496 pData->length = l;
497 *end = '\0';
498 }
499 }
500
505 template< typename T, std::size_t N >
506 OUString( StringNumberBase< sal_Unicode, T, N >&& n )
507 : OUString( n.buf, n.length )
508 {}
509#endif
510
511#if defined LIBO_INTERNAL_ONLY
512 explicit OUString(std::u16string_view sv) {
513 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
514 throw std::bad_alloc();
515 }
516 pData = nullptr;
517 rtl_uString_newFromStr_WithLength(&pData, sv.data(), sv.size());
518 }
519#endif
520
525 {
526 rtl_uString_release( pData );
527 }
528
540 static OUString const & unacquired( rtl_uString * const * ppHandle )
541 { return * reinterpret_cast< OUString const * >( ppHandle ); }
542
543#if defined LIBO_INTERNAL_ONLY
556 static OUString const& unacquired(const OUStringBuffer& str);
557#endif
558
564 OUString & operator=( const OUString & str )
565 {
566 rtl_uString_assign( &pData, str.pData );
567 return *this;
568 }
569
570#if defined LIBO_INTERNAL_ONLY
577 OUString & operator=( OUString && str ) noexcept
578 {
579 std::swap(pData, str.pData);
580 // rtl_uString_new will release any existing data before assigning empty
581 rtl_uString_new( &str.pData );
582 return *this;
583 }
584#endif
585
598 template< typename T >
600 {
601 assert(
604 rtl_uString_new(&pData);
605 } else {
607 &pData,
609 literal),
611 }
612 return *this;
613 }
614
615#if defined LIBO_INTERNAL_ONLY
617 template<typename T>
618 typename
620 operator =(T & literal) {
622 rtl_uString_new(&pData);
623 } else {
625 &pData,
626 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
627 literal),
628 libreoffice_internal::ConstCharArrayDetector<T>::length);
629 }
630 return *this;
631 }
632
634 template<std::size_t N> OUString & operator =(OUStringLiteral<N> const & literal) {
635 rtl_uString_release(pData);
636 pData = const_cast<rtl_uString *>(&literal.str);
637 return *this;
638 }
639 template<std::size_t N> OUString & operator =(OUStringLiteral<N> &&) = delete;
640
641 template <typename T, std::size_t N>
642 OUString & operator =(StringNumberBase<sal_Unicode, T, N> && n) {
643 // n.length should never be zero, so no need to add an optimization for that case
644 rtl_uString_newFromStr_WithLength(&pData, n.buf, n.length);
645 return *this;
646 }
647
648 OUString & operator =(std::u16string_view sv) {
649 if (sv.empty()) {
650 rtl_uString_new(&pData);
651 } else {
652 rtl_uString_newFromStr_WithLength(&pData, sv.data(), sv.size());
653 }
654 return *this;
655 }
656#endif
657
658#if defined LIBO_INTERNAL_ONLY
667 inline OUString & operator+=( const OUStringBuffer & str ) &;
668#endif
669
677 OUString & operator+=( const OUString & str )
678#if defined LIBO_INTERNAL_ONLY
679 &
680#endif
681 {
682 return internalAppend(str.pData);
683 }
684#if defined LIBO_INTERNAL_ONLY
685 void operator+=(OUString const &) && = delete;
686#endif
687
694 template<typename T>
696 operator +=(T & literal)
697#if defined LIBO_INTERNAL_ONLY
698 &
699#endif
700 {
701 assert(
704 &pData, pData,
707 return *this;
708 }
709#if defined LIBO_INTERNAL_ONLY
710 template<typename T>
712 operator +=(T &) && = delete;
713#endif
714
715#if defined LIBO_INTERNAL_ONLY
717 template<typename T>
718 typename
720 operator +=(T & literal) & {
722 &pData, pData,
725 return *this;
726 }
727 template<typename T>
728 typename
729 libreoffice_internal::ConstCharArrayDetector<T, OUString &>::TypeUtf16
730 operator +=(T &) && = delete;
731
733 template<std::size_t N> OUString & operator +=(OUStringLiteral<N> const & literal) & {
734 rtl_uString_newConcatUtf16L(&pData, pData, literal.getStr(), literal.getLength());
735 return *this;
736 }
737 template<std::size_t N> void operator +=(OUStringLiteral<N> const &) && = delete;
738
739 OUString & operator +=(std::u16string_view sv) & {
740 if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
741 throw std::bad_alloc();
742 }
743 rtl_uString_newConcatUtf16L(&pData, pData, sv.data(), sv.size());
744 return *this;
745 }
746 void operator +=(std::u16string_view) && = delete;
747#endif
748
749#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
754 template< typename T1, typename T2 >
755 OUString& operator+=( OUStringConcat< T1, T2 >&& c ) & {
756 sal_Int32 l = c.length();
757 if( l == 0 )
758 return *this;
759 l += pData->length;
760 rtl_uString_ensureCapacity( &pData, l );
761 sal_Unicode* end = c.addData( pData->buffer + pData->length );
762 *end = '\0';
763 pData->length = l;
764 return *this;
765 }
766 template<typename T1, typename T2> void operator +=(
767 OUStringConcat<T1, T2> &&) && = delete;
768
773 template< typename T, std::size_t N >
774 OUString& operator+=( StringNumberBase< sal_Unicode, T, N >&& n ) & {
775 sal_Int32 l = n.length;
776 if( l == 0 )
777 return *this;
778 l += pData->length;
779 rtl_uString_ensureCapacity( &pData, l );
780 sal_Unicode* end = addDataHelper( pData->buffer + pData->length, n.buf, n.length );
781 *end = '\0';
782 pData->length = l;
783 return *this;
784 }
785 template<typename T, std::size_t N> void operator +=(
786 StringNumberBase<sal_Unicode, T, N> &&) && = delete;
787#endif
788
793 void clear()
794 {
795 rtl_uString_new( &pData );
796 }
797
806 sal_Int32 getLength() const { return pData->length; }
807
816 bool isEmpty() const
817 {
818 return pData->length == 0;
819 }
820
828 const sal_Unicode * getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
829
839 sal_Unicode operator [](sal_Int32 index) const {
840 // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
841 assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
842 return getStr()[index];
843 }
844
857#if defined LIBO_INTERNAL_ONLY
858 sal_Int32 compareTo( std::u16string_view str ) const
859 {
860 return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
861 str.data(), str.length() );
862 }
863#else
864 sal_Int32 compareTo( const OUString & str ) const
865 {
866 return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
867 str.pData->buffer, str.pData->length );
868 }
869#endif
870
886#if defined LIBO_INTERNAL_ONLY
887 sal_Int32 compareTo( std::u16string_view str, sal_Int32 maxLength ) const
888 {
889 return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
890 str.data(), str.length(), maxLength );
891 }
892#else
893 sal_Int32 compareTo( const OUString & str, sal_Int32 maxLength ) const
894 {
895 return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
896 str.pData->buffer, str.pData->length, maxLength );
897 }
898#endif
899
912#if defined LIBO_INTERNAL_ONLY
913 sal_Int32 reverseCompareTo(std::u16string_view sv) const {
915 pData->buffer, pData->length, sv.data(), sv.size());
916 }
917#else
918 sal_Int32 reverseCompareTo( const OUString & str ) const
919 {
920 return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
921 str.pData->buffer, str.pData->length );
922 }
923#endif
924
930 template< typename T >
932 {
933 assert(
936 pData->buffer, pData->length,
939 }
940
952 bool equals( const OUString & str ) const
953 {
954 if ( pData->length != str.pData->length )
955 return false;
956 if ( pData == str.pData )
957 return true;
958 return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
959 str.pData->buffer, str.pData->length ) == 0;
960 }
961
976#if defined LIBO_INTERNAL_ONLY
977 bool equalsIgnoreAsciiCase(std::u16string_view sv) const {
978 if ( sal_uInt32(pData->length) != sv.size() )
979 return false;
980 if ( pData->buffer == sv.data() )
981 return true;
982 return
984 pData->buffer, pData->length, sv.data(), sv.size())
985 == 0;
986 }
987#else
988 bool equalsIgnoreAsciiCase( const OUString & str ) const
989 {
990 if ( pData->length != str.pData->length )
991 return false;
992 if ( pData == str.pData )
993 return true;
994 return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
995 str.pData->buffer, str.pData->length ) == 0;
996 }
997#endif
998
1014#if defined LIBO_INTERNAL_ONLY
1015 sal_Int32 compareToIgnoreAsciiCase(std::u16string_view sv) const {
1017 pData->buffer, pData->length, sv.data(), sv.size());
1018 }
1019#else
1020 sal_Int32 compareToIgnoreAsciiCase( const OUString & str ) const
1021 {
1022 return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
1023 str.pData->buffer, str.pData->length );
1024 }
1025#endif
1026
1032 template< typename T >
1034 {
1035 assert(
1037 return
1038 (pData->length
1041 pData->buffer, pData->length,
1043 literal))
1044 == 0);
1045 }
1046
1062#if defined LIBO_INTERNAL_ONLY
1063 bool match(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
1064 return
1066 pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1067 sv.size())
1068 == 0;
1069 }
1070#else
1071 bool match( const OUString & str, sal_Int32 fromIndex = 0 ) const
1072 {
1073 return rtl_ustr_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1074 str.pData->buffer, str.pData->length, str.pData->length ) == 0;
1075 }
1076#endif
1077
1083 template< typename T >
1084 typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
1085 {
1086 assert(
1088 return
1090 pData->buffer+fromIndex, pData->length-fromIndex,
1092 literal),
1094 == 0;
1095 }
1096
1115#if defined LIBO_INTERNAL_ONLY
1116 bool matchIgnoreAsciiCase(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
1117 return
1119 pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1120 sv.size())
1121 == 0;
1122 }
1123#else
1124 bool matchIgnoreAsciiCase( const OUString & str, sal_Int32 fromIndex = 0 ) const
1125 {
1126 return rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1127 str.pData->buffer, str.pData->length,
1128 str.pData->length ) == 0;
1129 }
1130#endif
1131
1137 template< typename T >
1139 {
1140 assert(
1142 return matchIgnoreAsciiCaseAsciiL(
1145 }
1146
1163 sal_Int32 compareToAscii( const char* asciiStr ) const
1164 {
1165 return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length, asciiStr );
1166 }
1167
1191 "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
1192 sal_Int32 compareToAscii( const char * asciiStr, sal_Int32 maxLength ) const
1193 {
1194 return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer, pData->length,
1195 asciiStr, maxLength );
1196 }
1197
1216 sal_Int32 reverseCompareToAsciiL( const char * asciiStr, sal_Int32 asciiStrLength ) const
1217 {
1218 return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
1219 asciiStr, asciiStrLength );
1220 }
1221
1237 bool equalsAscii( const char* asciiStr ) const
1238 {
1239 return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length,
1240 asciiStr ) == 0;
1241 }
1242
1259 bool equalsAsciiL( const char* asciiStr, sal_Int32 asciiStrLength ) const
1260 {
1261 if ( pData->length != asciiStrLength )
1262 return false;
1263
1265 pData->buffer, asciiStr, asciiStrLength );
1266 }
1267
1286 bool equalsIgnoreAsciiCaseAscii( const char * asciiStr ) const
1287 {
1288 return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1289 }
1290
1309 sal_Int32 compareToIgnoreAsciiCaseAscii( const char * asciiStr ) const
1310 {
1311 return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr );
1312 }
1313
1333 bool equalsIgnoreAsciiCaseAsciiL( const char * asciiStr, sal_Int32 asciiStrLength ) const
1334 {
1335 if ( pData->length != asciiStrLength )
1336 return false;
1337
1338 return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1339 }
1340
1361 bool matchAsciiL( const char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1362 {
1363 return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1364 asciiStr, asciiStrLength ) == 0;
1365 }
1366
1367 // This overload is left undefined, to detect calls of matchAsciiL that
1368 // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1369 // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1370 // platforms):
1371#if SAL_TYPES_SIZEOFLONG == 8
1372 void matchAsciiL(char const *, sal_Int32, rtl_TextEncoding) const;
1373#endif
1374
1398 bool matchIgnoreAsciiCaseAsciiL( const char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1399 {
1400 return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1401 asciiStr, asciiStrLength ) == 0;
1402 }
1403
1404 // This overload is left undefined, to detect calls of
1405 // matchIgnoreAsciiCaseAsciiL that erroneously use
1406 // RTL_CONSTASCII_USTRINGPARAM instead of RTL_CONSTASCII_STRINGPARAM (but
1407 // would lead to ambiguities on 32 bit platforms):
1408#if SAL_TYPES_SIZEOFLONG == 8
1409 void matchIgnoreAsciiCaseAsciiL(char const *, sal_Int32, rtl_TextEncoding)
1410 const;
1411#endif
1412
1427#if defined LIBO_INTERNAL_ONLY
1428 bool startsWith(std::u16string_view sv, OUString * rest = nullptr) const {
1429 auto const b = match(sv);
1430 if (b && rest != nullptr) {
1431 *rest = copy(sv.size());
1432 }
1433 return b;
1434 }
1435#else
1436 bool startsWith(OUString const & str, OUString * rest = NULL) const {
1437 bool b = match(str);
1438 if (b && rest != NULL) {
1439 *rest = copy(str.getLength());
1440 }
1441 return b;
1442 }
1443#endif
1444
1450 template< typename T >
1452 T & literal, OUString * rest = NULL) const
1453 {
1454 assert(
1456 bool b
1458 <= sal_uInt32(pData->length))
1460 pData->buffer,
1462 literal),
1464 if (b && rest != NULL) {
1465 *rest = copy(
1467 }
1468 return b;
1469 }
1470
1491#if defined LIBO_INTERNAL_ONLY
1492 bool startsWithIgnoreAsciiCase(std::u16string_view sv, OUString * rest = nullptr) const {
1493 auto const b = matchIgnoreAsciiCase(sv);
1494 if (b && rest != nullptr) {
1495 *rest = copy(sv.size());
1496 }
1497 return b;
1498 }
1499#else
1500 bool startsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL)
1501 const
1502 {
1503 bool b = matchIgnoreAsciiCase(str);
1504 if (b && rest != NULL) {
1505 *rest = copy(str.getLength());
1506 }
1507 return b;
1508 }
1509#endif
1510
1516 template< typename T >
1518 startsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1519 {
1520 assert(
1522 bool b
1524 <= sal_uInt32(pData->length))
1526 pData->buffer,
1529 literal),
1531 == 0);
1532 if (b && rest != NULL) {
1533 *rest = copy(
1535 }
1536 return b;
1537 }
1538
1553#if defined LIBO_INTERNAL_ONLY
1554 bool endsWith(std::u16string_view sv, OUString * rest = nullptr) const {
1555 auto const b = sv.size() <= sal_uInt32(pData->length)
1556 && match(sv, pData->length - sv.size());
1557 if (b && rest != nullptr) {
1558 *rest = copy(0, (pData->length - sv.size()));
1559 }
1560 return b;
1561 }
1562#else
1563 bool endsWith(OUString const & str, OUString * rest = NULL) const {
1564 bool b = str.getLength() <= getLength()
1565 && match(str, getLength() - str.getLength());
1566 if (b && rest != NULL) {
1567 *rest = copy(0, getLength() - str.getLength());
1568 }
1569 return b;
1570 }
1571#endif
1572
1578 template< typename T >
1580 endsWith(T & literal, OUString * rest = NULL) const
1581 {
1582 assert(
1584 bool b
1586 <= sal_uInt32(pData->length))
1588 (pData->buffer + pData->length
1591 literal),
1593 if (b && rest != NULL) {
1594 *rest = copy(
1595 0,
1596 (getLength()
1598 }
1599 return b;
1600 }
1601
1613 bool endsWithAsciiL(char const * asciiStr, sal_Int32 asciiStrLength)
1614 const
1615 {
1616 return asciiStrLength <= pData->length
1618 pData->buffer + pData->length - asciiStrLength, asciiStr,
1619 asciiStrLength);
1620 }
1621
1642#if defined LIBO_INTERNAL_ONLY
1643 bool endsWithIgnoreAsciiCase(std::u16string_view sv, OUString * rest = nullptr) const {
1644 auto const b = sv.size() <= sal_uInt32(pData->length)
1645 && matchIgnoreAsciiCase(sv, pData->length - sv.size());
1646 if (b && rest != nullptr) {
1647 *rest = copy(0, pData->length - sv.size());
1648 }
1649 return b;
1650 }
1651#else
1652 bool endsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL) const
1653 {
1654 bool b = str.getLength() <= getLength()
1655 && matchIgnoreAsciiCase(str, getLength() - str.getLength());
1656 if (b && rest != NULL) {
1657 *rest = copy(0, getLength() - str.getLength());
1658 }
1659 return b;
1660 }
1661#endif
1662
1668 template< typename T >
1670 endsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1671 {
1672 assert(
1674 bool b
1676 <= sal_uInt32(pData->length))
1678 (pData->buffer + pData->length
1682 literal),
1684 == 0);
1685 if (b && rest != NULL) {
1686 *rest = copy(
1687 0,
1688 (getLength()
1690 }
1691 return b;
1692 }
1693
1705 char const * asciiStr, sal_Int32 asciiStrLength) const
1706 {
1707 return asciiStrLength <= pData->length
1709 pData->buffer + pData->length - asciiStrLength,
1710 asciiStrLength, asciiStr, asciiStrLength)
1711 == 0);
1712 }
1713
1714 friend bool operator == ( const OUString& rStr1, const OUString& rStr2 )
1715 { return rStr1.equals(rStr2); }
1716
1717 friend bool operator != ( const OUString& rStr1, const OUString& rStr2 )
1718 { return !(operator == ( rStr1, rStr2 )); }
1719
1720 friend bool operator < ( const OUString& rStr1, const OUString& rStr2 )
1721 { return rStr1.compareTo( rStr2 ) < 0; }
1722 friend bool operator > ( const OUString& rStr1, const OUString& rStr2 )
1723 { return rStr1.compareTo( rStr2 ) > 0; }
1724 friend bool operator <= ( const OUString& rStr1, const OUString& rStr2 )
1725 { return rStr1.compareTo( rStr2 ) <= 0; }
1726 friend bool operator >= ( const OUString& rStr1, const OUString& rStr2 )
1727 { return rStr1.compareTo( rStr2 ) >= 0; }
1728
1729#if defined LIBO_INTERNAL_ONLY
1730
1731 template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1732 operator ==(OUString const & s1, T const & s2) {
1734 == 0;
1735 }
1736
1737 template<typename T>
1738 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1739 operator ==(OUString const & s1, T & s2) {
1740 return rtl_ustr_compare_WithLength(s1.getStr(), s1.getLength(), s2, rtl_ustr_getLength(s2))
1741 == 0;
1742 }
1743
1744 template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1745 operator ==(T const & s1, OUString const & s2) {
1746 return rtl_ustr_compare_WithLength(s1, rtl_ustr_getLength(s1), s2.getStr(), s2.getLength())
1747 == 0;
1748 }
1749
1750 template<typename T>
1751 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1752 operator ==(T & s1, OUString const & s2) {
1753 return rtl_ustr_compare_WithLength(s1, rtl_ustr_getLength(s1), s2.getStr(), s2.getLength())
1754 == 0;
1755 }
1756
1757 template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1758 operator !=(OUString const & s1, T const & s2) { return !(s1 == s2); }
1759
1760 template<typename T>
1761 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1762 operator !=(OUString const & s1, T & s2) { return !(s1 == s2); }
1763
1764 template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1765 operator !=(T const & s1, OUString const & s2) { return !(s1 == s2); }
1766
1767 template<typename T>
1768 friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1769 operator !=(T & s1, OUString const & s2) { return !(s1 == s2); }
1770
1771#else
1772
1773 friend bool operator == ( const OUString& rStr1, const sal_Unicode * pStr2 )
1774 { return rStr1.compareTo( pStr2 ) == 0; }
1775 friend bool operator == ( const sal_Unicode * pStr1, const OUString& rStr2 )
1776 { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
1777
1778 friend bool operator != ( const OUString& rStr1, const sal_Unicode * pStr2 )
1779 { return !(operator == ( rStr1, pStr2 )); }
1780 friend bool operator != ( const sal_Unicode * pStr1, const OUString& rStr2 )
1781 { return !(operator == ( pStr1, rStr2 )); }
1782
1783#endif
1784
1792 template< typename T >
1794 {
1795 assert(
1797 return rString.equalsAsciiL(
1800 }
1808 template< typename T >
1810 {
1811 assert(
1813 return rString.equalsAsciiL(
1816 }
1824 template< typename T >
1826 {
1827 assert(
1829 return !rString.equalsAsciiL(
1832 }
1840 template< typename T >
1842 {
1843 assert(
1845 return !rString.equalsAsciiL(
1848 }
1849
1850#if defined LIBO_INTERNAL_ONLY
1852 template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1853 operator ==(OUString const & string, T & literal) {
1854 return
1856 string.pData->buffer, string.pData->length,
1858 literal),
1860 == 0;
1861 }
1863 template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1864 operator ==(T & literal, OUString const & string) {
1865 return
1867 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1868 literal),
1869 libreoffice_internal::ConstCharArrayDetector<T>::length,
1870 string.pData->buffer, string.pData->length)
1871 == 0;
1872 }
1874 template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1875 operator !=(OUString const & string, T & literal) {
1876 return
1878 string.pData->buffer, string.pData->length,
1879 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1880 literal),
1881 libreoffice_internal::ConstCharArrayDetector<T>::length)
1882 != 0;
1883 }
1885 template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1886 operator !=(T & literal, OUString const & string) {
1887 return
1889 libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1890 literal),
1891 libreoffice_internal::ConstCharArrayDetector<T>::length,
1892 string.pData->buffer, string.pData->length)
1893 != 0;
1894 }
1895#endif
1896
1904 sal_Int32 hashCode() const
1905 {
1906 return rtl_ustr_hashCode_WithLength( pData->buffer, pData->length );
1907 }
1908
1922 sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
1923 {
1924 sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1925 return (ret < 0 ? ret : ret+fromIndex);
1926 }
1927
1937 sal_Int32 lastIndexOf( sal_Unicode ch ) const
1938 {
1939 return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1940 }
1941
1954 sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
1955 {
1956 return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1957 }
1958
1974#if defined LIBO_INTERNAL_ONLY
1975 sal_Int32 indexOf(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
1976 auto const n = rtl_ustr_indexOfStr_WithLength(
1977 pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size());
1978 return n < 0 ? n : n + fromIndex;
1979 }
1980#else
1981 sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
1982 {
1983 sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1984 str.pData->buffer, str.pData->length );
1985 return (ret < 0 ? ret : ret+fromIndex);
1986 }
1987#endif
1988
1994 template< typename T >
1995 typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1996 {
1997 assert(
2000 pData->buffer + fromIndex, pData->length - fromIndex,
2003 return n < 0 ? n : n + fromIndex;
2004 }
2005
2029 sal_Int32 indexOfAsciiL(
2030 char const * str, sal_Int32 len, sal_Int32 fromIndex = 0) const
2031 {
2032 sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
2033 pData->buffer + fromIndex, pData->length - fromIndex, str, len);
2034 return ret < 0 ? ret : ret + fromIndex;
2035 }
2036
2037 // This overload is left undefined, to detect calls of indexOfAsciiL that
2038 // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
2039 // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
2040 // platforms):
2041#if SAL_TYPES_SIZEOFLONG == 8
2042 void indexOfAsciiL(char const *, sal_Int32 len, rtl_TextEncoding) const;
2043#endif
2044
2060#if defined LIBO_INTERNAL_ONLY
2061 sal_Int32 lastIndexOf(std::u16string_view sv) const {
2063 pData->buffer, pData->length, sv.data(), sv.size());
2064 }
2065#else
2066 sal_Int32 lastIndexOf( const OUString & str ) const
2067 {
2068 return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
2069 str.pData->buffer, str.pData->length );
2070 }
2071#endif
2072
2090#if defined LIBO_INTERNAL_ONLY
2091 sal_Int32 lastIndexOf(std::u16string_view sv, sal_Int32 fromIndex) const {
2092 return rtl_ustr_lastIndexOfStr_WithLength(pData->buffer, fromIndex, sv.data(), sv.size());
2093 }
2094#else
2095 sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
2096 {
2097 return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
2098 str.pData->buffer, str.pData->length );
2099 }
2100#endif
2101
2107 template< typename T >
2109 {
2110 assert(
2113 pData->buffer, pData->length,
2116 }
2117
2137 sal_Int32 lastIndexOfAsciiL(char const * str, sal_Int32 len) const
2138 {
2140 pData->buffer, pData->length, str, len);
2141 }
2142
2153 SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex ) const
2154 {
2155 return copy(beginIndex, getLength() - beginIndex);
2156 }
2157
2170 SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const
2171 {
2172 rtl_uString *pNew = NULL;
2173 rtl_uString_newFromSubString( &pNew, pData, beginIndex, count );
2174 return OUString( pNew, SAL_NO_ACQUIRE );
2175 }
2176
2177#if defined LIBO_INTERNAL_ONLY
2188 SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex ) const
2189 {
2190 assert(beginIndex >= 0);
2191 assert(beginIndex <= getLength());
2192 return subView(beginIndex, getLength() - beginIndex);
2193 }
2194
2207 SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex, sal_Int32 count ) const
2208 {
2209 assert(beginIndex >= 0);
2210 assert(count >= 0);
2211 assert(beginIndex <= getLength());
2212 assert(count <= getLength() - beginIndex);
2213 return std::u16string_view(*this).substr(beginIndex, count);
2214 }
2215#endif
2216
2217#ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2226 SAL_WARN_UNUSED_RESULT OUString concat( const OUString & str ) const
2227 {
2228 rtl_uString* pNew = NULL;
2229 rtl_uString_newConcat( &pNew, pData, str.pData );
2230 return OUString( pNew, SAL_NO_ACQUIRE );
2231 }
2232#endif
2233
2234#ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2235 friend OUString operator+( const OUString& rStr1, const OUString& rStr2 )
2236 {
2237 return rStr1.concat( rStr2 );
2238 }
2239#endif
2240
2241// hide this from internal code to avoid ambiguous lookup error
2242#ifndef LIBO_INTERNAL_ONLY
2256 SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const
2257 {
2258 rtl_uString* pNew = NULL;
2259 rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
2260 return OUString( pNew, SAL_NO_ACQUIRE );
2261 }
2262#endif
2263
2264#ifdef LIBO_INTERNAL_ONLY
2265 SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, std::u16string_view newStr ) const
2266 {
2267 rtl_uString* pNew = NULL;
2268 rtl_uString_newReplaceStrAtUtf16L( &pNew, pData, index, count, newStr.data(), newStr.size() );
2269 return OUString( pNew, SAL_NO_ACQUIRE );
2270 }
2271#endif
2272
2287 {
2288 rtl_uString* pNew = NULL;
2289 rtl_uString_newReplace( &pNew, pData, oldChar, newChar );
2290 return OUString( pNew, SAL_NO_ACQUIRE );
2291 }
2292
2311#if defined LIBO_INTERNAL_ONLY
2312 [[nodiscard]] OUString replaceFirst(
2313 std::u16string_view from, std::u16string_view to, sal_Int32 * index = nullptr) const
2314 {
2315 rtl_uString * s = nullptr;
2316 sal_Int32 i = 0;
2318 &s, pData, from.data(), from.size(), to.data(), to.size(),
2319 index == nullptr ? &i : index);
2320 return OUString(s, SAL_NO_ACQUIRE);
2321 }
2322#else
2324 OUString const & from, OUString const & to, sal_Int32 * index = NULL) const
2325 {
2326 rtl_uString * s = NULL;
2327 sal_Int32 i = 0;
2329 &s, pData, from.pData, to.pData, index == NULL ? &i : index);
2330 return OUString(s, SAL_NO_ACQUIRE);
2331 }
2332#endif
2333
2352#if defined LIBO_INTERNAL_ONLY
2353 template<typename T> [[nodiscard]]
2355 T & from, std::u16string_view to, sal_Int32 * index = nullptr) const
2356 {
2358 rtl_uString * s = nullptr;
2359 sal_Int32 i = 0;
2363 index == nullptr ? &i : index);
2364 return OUString(s, SAL_NO_ACQUIRE);
2365 }
2366#else
2367 template< typename T >
2369 sal_Int32 * index = NULL) const
2370 {
2372 rtl_uString * s = NULL;
2373 sal_Int32 i = 0;
2375 &s, pData,
2378 index == NULL ? &i : index);
2379 return OUString(s, SAL_NO_ACQUIRE);
2380 }
2381#endif
2382
2401#if defined LIBO_INTERNAL_ONLY
2402 template<typename T> [[nodiscard]]
2404 std::u16string_view from, T & to, sal_Int32 * index = nullptr) const
2405 {
2407 rtl_uString * s = nullptr;
2408 sal_Int32 i = 0;
2410 &s, pData, from.data(), from.size(),
2412 libreoffice_internal::ConstCharArrayDetector<T>::length, index == nullptr ? &i : index);
2413 return OUString(s, SAL_NO_ACQUIRE);
2414 }
2415#else
2416 template< typename T >
2418 sal_Int32 * index = NULL) const
2419 {
2421 rtl_uString * s = NULL;
2422 sal_Int32 i = 0;
2424 &s, pData, from.pData,
2427 index == NULL ? &i : index);
2428 return OUString(s, SAL_NO_ACQUIRE);
2429 }
2430#endif
2431
2450 template< typename T1, typename T2 >
2452 replaceFirst( T1& from, T2& to, sal_Int32 * index = NULL) const
2453 {
2456 rtl_uString * s = NULL;
2457 sal_Int32 i = 0;
2459 &s, pData,
2464 index == NULL ? &i : index);
2465 return OUString(s, SAL_NO_ACQUIRE);
2466 }
2467
2483#if defined LIBO_INTERNAL_ONLY
2484 [[nodiscard]] OUString replaceAll(
2485 std::u16string_view from, std::u16string_view to, sal_Int32 fromIndex = 0) const
2486 {
2487 rtl_uString * s = nullptr;
2488 rtl_uString_newReplaceAllFromIndexUtf16LUtf16L(
2489 &s, pData, from.data(), from.size(), to.data(), to.size(), fromIndex);
2490 return OUString(s, SAL_NO_ACQUIRE);
2491 }
2492#else
2494 OUString const & from, OUString const & to, sal_Int32 fromIndex = 0) const
2495 {
2496 rtl_uString * s = NULL;
2497 rtl_uString_newReplaceAllFromIndex(&s, pData, from.pData, to.pData, fromIndex);
2498 return OUString(s, SAL_NO_ACQUIRE);
2499 }
2500#endif
2501
2515#if defined LIBO_INTERNAL_ONLY
2516 template<typename T> [[nodiscard]]
2518 T & from, std::u16string_view to) const
2519 {
2521 rtl_uString * s = nullptr;
2525 return OUString(s, SAL_NO_ACQUIRE);
2526 }
2527#else
2528 template< typename T >
2530 {
2532 rtl_uString * s = NULL;
2534 &s, pData,
2537 return OUString(s, SAL_NO_ACQUIRE);
2538 }
2539#endif
2540
2554#if defined LIBO_INTERNAL_ONLY
2555 template<typename T> [[nodiscard]]
2557 std::u16string_view from, T & to) const
2558 {
2560 rtl_uString * s = nullptr;
2562 &s, pData, from.data(), from.size(),
2565 return OUString(s, SAL_NO_ACQUIRE);
2566 }
2567#else
2568 template< typename T >
2570 {
2572 rtl_uString * s = NULL;
2574 &s, pData, from.pData,
2577 return OUString(s, SAL_NO_ACQUIRE);
2578 }
2579#endif
2580
2594 template< typename T1, typename T2 >
2596 replaceAll( T1& from, T2& to ) const
2597 {
2600 rtl_uString * s = NULL;
2602 &s, pData,
2607 return OUString(s, SAL_NO_ACQUIRE);
2608 }
2609
2621 {
2622 rtl_uString* pNew = NULL;
2623 rtl_uString_newToAsciiLowerCase( &pNew, pData );
2624 return OUString( pNew, SAL_NO_ACQUIRE );
2625 }
2626
2638 {
2639 rtl_uString* pNew = NULL;
2640 rtl_uString_newToAsciiUpperCase( &pNew, pData );
2641 return OUString( pNew, SAL_NO_ACQUIRE );
2642 }
2643
2658 {
2659 rtl_uString* pNew = NULL;
2660 rtl_uString_newTrim( &pNew, pData );
2661 return OUString( pNew, SAL_NO_ACQUIRE );
2662 }
2663
2688 OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const
2689 {
2690 rtl_uString * pNew = NULL;
2691 index = rtl_uString_getToken( &pNew, pData, token, cTok, index );
2692 return OUString( pNew, SAL_NO_ACQUIRE );
2693 }
2694
2708 OUString getToken(sal_Int32 count, sal_Unicode separator) const {
2709 sal_Int32 n = 0;
2710 return getToken(count, separator, n);
2711 }
2712
2721 bool toBoolean() const
2722 {
2723 return rtl_ustr_toBoolean( pData->buffer );
2724 }
2725
2733 {
2734 return pData->buffer[0];
2735 }
2736
2747 sal_Int32 toInt32( sal_Int16 radix = 10 ) const
2748 {
2749 return rtl_ustr_toInt32( pData->buffer, radix );
2750 }
2751
2764 sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
2765 {
2766 return rtl_ustr_toUInt32( pData->buffer, radix );
2767 }
2768
2779 sal_Int64 toInt64( sal_Int16 radix = 10 ) const
2780 {
2781 return rtl_ustr_toInt64( pData->buffer, radix );
2782 }
2783
2796 sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
2797 {
2798 return rtl_ustr_toUInt64( pData->buffer, radix );
2799 }
2800
2809 float toFloat() const
2810 {
2811 return rtl_ustr_toFloat( pData->buffer );
2812 }
2813
2822 double toDouble() const
2823 {
2824 return rtl_ustr_toDouble( pData->buffer );
2825 }
2826
2827
2844 {
2845 rtl_uString * pNew = NULL;
2846 rtl_uString_intern( &pNew, pData );
2847 if (pNew == NULL) {
2848 throw std::bad_alloc();
2849 }
2850 return OUString( pNew, SAL_NO_ACQUIRE );
2851 }
2852
2878 static OUString intern( const char * value, sal_Int32 length,
2879 rtl_TextEncoding encoding,
2880 sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS,
2881 sal_uInt32 *pInfo = NULL )
2882 {
2883 rtl_uString * pNew = NULL;
2884 rtl_uString_internConvert( &pNew, value, length, encoding,
2885 convertFlags, pInfo );
2886 if (pNew == NULL) {
2887 throw std::bad_alloc();
2888 }
2889 return OUString( pNew, SAL_NO_ACQUIRE );
2890 }
2891
2916 bool convertToString(OString * pTarget, rtl_TextEncoding nEncoding,
2917 sal_uInt32 nFlags) const
2918 {
2919 return rtl_convertUStringToString(&pTarget->pData, pData->buffer,
2920 pData->length, nEncoding, nFlags);
2921 }
2922
2975 sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1) const
2976 {
2978 pData, indexUtf16, incrementCodePoints);
2979 }
2980
2990#if defined LIBO_INTERNAL_ONLY
2991 static OUString fromUtf8(std::string_view rSource)
2992 {
2993 OUString aTarget;
2994 bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
2995 rSource.data(),
2996 rSource.length(),
2999 (void) bSuccess;
3000 assert(bSuccess);
3001 return aTarget;
3002 }
3003#else
3004 static OUString fromUtf8(const OString& rSource)
3005 {
3006 OUString aTarget;
3007 bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
3008 rSource.getStr(),
3009 rSource.getLength(),
3012 (void) bSuccess;
3013 assert(bSuccess);
3014 return aTarget;
3015 }
3016#endif
3017
3029 {
3030 OString aTarget;
3031 bool bSuccess = rtl_convertUStringToString(&aTarget.pData,
3032 getStr(),
3033 getLength(),
3036 (void) bSuccess;
3037 assert(bSuccess);
3038 return aTarget;
3039 }
3040
3041#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3042
3043 static OUStringNumber< int > number( int i, sal_Int16 radix = 10 )
3044 {
3045 return OUStringNumber< int >( i, radix );
3046 }
3047 static OUStringNumber< long long > number( long long ll, sal_Int16 radix = 10 )
3048 {
3049 return OUStringNumber< long long >( ll, radix );
3050 }
3051 static OUStringNumber< unsigned long long > number( unsigned long long ll, sal_Int16 radix = 10 )
3052 {
3053 return OUStringNumber< unsigned long long >( ll, radix );
3054 }
3055 static OUStringNumber< unsigned long long > number( unsigned int i, sal_Int16 radix = 10 )
3056 {
3057 return number( static_cast< unsigned long long >( i ), radix );
3058 }
3059 static OUStringNumber< long long > number( long i, sal_Int16 radix = 10)
3060 {
3061 return number( static_cast< long long >( i ), radix );
3062 }
3063 static OUStringNumber< unsigned long long > number( unsigned long i, sal_Int16 radix = 10 )
3064 {
3065 return number( static_cast< unsigned long long >( i ), radix );
3066 }
3067 static OUStringNumber< float > number( float f )
3068 {
3069 return OUStringNumber< float >( f );
3070 }
3071 static OUStringNumber< double > number( double d )
3072 {
3073 return OUStringNumber< double >( d );
3074 }
3075#else
3086 static OUString number( int i, sal_Int16 radix = 10 )
3087 {
3089 return OUString(aBuf, rtl_ustr_valueOfInt32(aBuf, i, radix));
3090 }
3093 static OUString number( unsigned int i, sal_Int16 radix = 10 )
3094 {
3095 return number( static_cast< unsigned long long >( i ), radix );
3096 }
3099 static OUString number( long i, sal_Int16 radix = 10)
3100 {
3101 return number( static_cast< long long >( i ), radix );
3102 }
3105 static OUString number( unsigned long i, sal_Int16 radix = 10 )
3106 {
3107 return number( static_cast< unsigned long long >( i ), radix );
3108 }
3111 static OUString number( long long ll, sal_Int16 radix = 10 )
3112 {
3114 return OUString(aBuf, rtl_ustr_valueOfInt64(aBuf, ll, radix));
3115 }
3118 static OUString number( unsigned long long ll, sal_Int16 radix = 10 )
3119 {
3121 return OUString(aBuf, rtl_ustr_valueOfUInt64(aBuf, ll, radix));
3122 }
3123
3133 static OUString number( float f )
3134 {
3136 return OUString(aBuf, rtl_ustr_valueOfFloat(aBuf, f));
3137 }
3138
3148 static OUString number( double d )
3149 {
3151 return OUString(aBuf, rtl_ustr_valueOfDouble(aBuf, d));
3152 }
3153#endif
3154
3166 SAL_DEPRECATED("use boolean()") static OUString valueOf( sal_Bool b )
3167 {
3168 return boolean(b);
3169 }
3170
3182 static OUString boolean( bool b )
3183 {
3185 return OUString(aBuf, rtl_ustr_valueOfBoolean(aBuf, b));
3186 }
3187
3195 SAL_DEPRECATED("convert to OUString or use directly") static OUString valueOf( sal_Unicode c )
3196 {
3197 return OUString( &c, 1 );
3198 }
3199
3210 SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
3211 {
3212 return number( i, radix );
3213 }
3214
3225 SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
3226 {
3227 return number( ll, radix );
3228 }
3229
3239 SAL_DEPRECATED("use number()") static OUString valueOf( float f )
3240 {
3241 return number(f);
3242 }
3243
3253 SAL_DEPRECATED("use number()") static OUString valueOf( double d )
3254 {
3255 return number(d);
3256 }
3257
3273 static OUString createFromAscii( const char * value )
3274 {
3275 rtl_uString* pNew = NULL;
3276 rtl_uString_newFromAscii( &pNew, value );
3277 return OUString( pNew, SAL_NO_ACQUIRE );
3278 }
3279
3280#if defined LIBO_INTERNAL_ONLY
3281 static OUString createFromAscii(std::string_view value) {
3282 rtl_uString * p = nullptr;
3283 rtl_uString_newFromLiteral(&p, value.data(), value.size(), 0); //TODO: check for overflow
3284 return OUString(p, SAL_NO_ACQUIRE);
3285 }
3286 #endif
3287
3288#if defined LIBO_INTERNAL_ONLY
3289 operator std::u16string_view() const { return {getStr(), sal_uInt32(getLength())}; }
3290#endif
3291
3292#if defined LIBO_INTERNAL_ONLY
3293 // A wrapper for the first expression in an
3294 //
3295 // OUString::Concat(e1) + e2 + ...
3296 //
3297 // concatenation chain, when neither of the first two e1, e2 is one of our rtl string-related
3298 // classes (so something like
3299 //
3300 // OUString s = "a" + (b ? std::u16string_view(u"c") : std::u16string_view(u"dd"));
3301 //
3302 // would not compile):
3303 template<typename T> [[nodiscard]] static
3304 OUStringConcat<OUStringConcatMarker, T>
3305 Concat(T const & value) { return OUStringConcat<OUStringConcatMarker, T>({}, value); }
3306
3307 // This overload is needed so that an argument of type 'char const[N]' ends up as
3308 // 'OUStringConcat<rtl::OUStringConcatMarker, char const[N]>' rather than as
3309 // 'OUStringConcat<rtl::OUStringConcatMarker, char[N]>':
3310 template<typename T, std::size_t N> [[nodiscard]] static
3311 OUStringConcat<OUStringConcatMarker, T[N]>
3312 Concat(T (& value)[N]) { return OUStringConcat<OUStringConcatMarker, T[N]>({}, value); }
3313#endif
3314
3315private:
3316 OUString & internalAppend( rtl_uString* pOtherData )
3317 {
3318 rtl_uString* pNewData = NULL;
3319 rtl_uString_newConcat( &pNewData, pData, pOtherData );
3320 if (pNewData == NULL) {
3321 throw std::bad_alloc();
3322 }
3323 rtl_uString_assign(&pData, pNewData);
3324 rtl_uString_release(pNewData);
3325 return *this;
3326 }
3327
3328};
3329
3330#if defined LIBO_INTERNAL_ONLY
3331// Can only define this after we define OUString
3332inline OUStringConstExpr::operator const OUString &() const { return OUString::unacquired(&pData); }
3333#endif
3334
3335#if defined LIBO_INTERNAL_ONLY
3336// Prevent the operator ==/!= overloads with 'sal_Unicode const *' parameter from
3337// being selected for nonsensical code like
3338//
3339// if (ouIdAttr == nullptr)
3340//
3341void operator ==(OUString const &, std::nullptr_t) = delete;
3342void operator ==(std::nullptr_t, OUString const &) = delete;
3343void operator !=(OUString const &, std::nullptr_t) = delete;
3344void operator !=(std::nullptr_t, OUString const &) = delete;
3345#endif
3346
3347#if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3348inline bool operator ==(OUString const & lhs, StringConcatenation<char16_t> const & rhs)
3349{ return lhs == std::u16string_view(rhs); }
3350inline bool operator !=(OUString const & lhs, StringConcatenation<char16_t> const & rhs)
3351{ return lhs != std::u16string_view(rhs); }
3352inline bool operator ==(StringConcatenation<char16_t> const & lhs, OUString const & rhs)
3353{ return std::u16string_view(lhs) == rhs; }
3354inline bool operator !=(StringConcatenation<char16_t> const & lhs, OUString const & rhs)
3355{ return std::u16string_view(lhs) != rhs; }
3356#endif
3357
3358#if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3360
3364template<>
3365struct ToStringHelper< OUString >
3366{
3367 static std::size_t length( const OUString& s ) { return s.getLength(); }
3368 sal_Unicode* operator() ( sal_Unicode* buffer, const OUString& s ) const { return addDataHelper( buffer, s.getStr(), s.getLength()); }
3369};
3370
3374template<std::size_t N>
3375struct ToStringHelper< OUStringLiteral<N> >
3376{
3377 static std::size_t length( const OUStringLiteral<N>& str ) { return str.getLength(); }
3378 sal_Unicode* operator()( sal_Unicode* buffer, const OUStringLiteral<N>& str ) const { return addDataHelper( buffer, str.getStr(), str.getLength() ); }
3379};
3380
3384template< typename charT, typename traits, typename T1, typename T2 >
3385inline std::basic_ostream<charT, traits> & operator <<(
3386 std::basic_ostream<charT, traits> & stream, OUStringConcat< T1, T2 >&& concat)
3387{
3388 return stream << OUString( std::move(concat) );
3389}
3390
3392#endif
3393
3400{
3410 size_t operator()(const OUString& rString) const
3411 { return static_cast<size_t>(rString.hashCode()); }
3412};
3413
3414/* ======================================================================= */
3415
3433#if defined LIBO_INTERNAL_ONLY
3434inline OUString OStringToOUString( std::string_view rStr,
3435 rtl_TextEncoding encoding,
3436 sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
3437{
3438 return OUString( rStr.data(), rStr.length(), encoding, convertFlags );
3439}
3440#else
3442 rtl_TextEncoding encoding,
3443 sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
3444{
3445 return OUString( rStr.getStr(), rStr.getLength(), encoding, convertFlags );
3446}
3447#endif
3448
3466#if defined LIBO_INTERNAL_ONLY
3467inline OString OUStringToOString( std::u16string_view rUnicode,
3468 rtl_TextEncoding encoding,
3469 sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
3470{
3471 return OString( rUnicode.data(), rUnicode.length(), encoding, convertFlags );
3472}
3473#else
3474inline OString OUStringToOString( const OUString & rUnicode,
3475 rtl_TextEncoding encoding,
3476 sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
3477{
3478 return OString( rUnicode.getStr(), rUnicode.getLength(), encoding, convertFlags );
3479}
3480#endif
3481
3482/* ======================================================================= */
3483
3492template< typename charT, typename traits >
3493inline std::basic_ostream<charT, traits> & operator <<(
3494 std::basic_ostream<charT, traits> & stream, OUString const & rString)
3495{
3496 return stream <<
3498 // best effort; potentially loses data due to conversion failures
3499 // (stray surrogate halves) and embedded null characters
3500}
3501
3502} // namespace
3503
3504#ifdef RTL_STRING_UNITTEST
3505namespace rtl
3506{
3507typedef rtlunittest::OUString OUString;
3508}
3509#endif
3510
3511// In internal code, allow to use classes like OUString without having to
3512// explicitly refer to the rtl namespace, which is kind of superfluous given
3513// that OUString itself is namespaced by its OU prefix:
3514#if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3515using ::rtl::OUString;
3516using ::rtl::OUStringHash;
3519using ::rtl::OUStringLiteral;
3520using ::rtl::OUStringChar;
3521using ::rtl::Concat2View;
3522#endif
3523
3525
3530#if defined LIBO_INTERNAL_ONLY
3531namespace std {
3532
3533template<>
3534struct hash<::rtl::OUString>
3535{
3536 std::size_t operator()(::rtl::OUString const & s) const
3537 {
3538 if constexpr (sizeof(std::size_t) == 8)
3539 {
3540 // return a hash that uses the full 64-bit range instead of a 32-bit value
3541 size_t n = 0;
3542 for (sal_Int32 i = 0, len = s.getLength(); i < len; ++i)
3543 n = 31 * n + s[i];
3544 return n;
3545 }
3546 else
3547 return std::size_t(s.hashCode());
3548 }
3549};
3550
3551}
3552
3553#endif
3555
3556#endif /* _RTL_USTRING_HXX */
3557
3558/* 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:2187
#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
#define RTL_TEXTENCODING_UTF8
Definition: textenc.h:117
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:37
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
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:2325
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:3441
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:3474
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:663
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:216
const char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:663
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:637
Definition: stringutils.hxx:140
Definition: stringutils.hxx:143
A string buffer implements a mutable sequence of characters.
Definition: ustrbuf.hxx:72
This String class provides base functionality for C++ like Unicode character array handling.
Definition: ustring.hxx:203
static OUString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: ustring.hxx:3086
OUString intern() const
Return a canonical representation for a string.
Definition: ustring.hxx:2843
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:1995
bool endsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string ends with a given substring.
Definition: ustring.hxx:1563
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:1704
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:2620
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:2529
const sal_Unicode * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:828
bool equalsIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:988
bool endsWithAsciiL(char const *asciiStr, sal_Int32 asciiStrLength) const
Check whether this string ends with a given ASCII string.
Definition: ustring.hxx:1613
OUString(const OUString &str)
New string from OUString.
Definition: ustring.hxx:223
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:2974
static OUString fromUtf8(const OString &rSource)
Convert an OString to an OUString, assuming that the OString is UTF-8-encoded.
Definition: ustring.hxx:3004
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:1084
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: ustring.hxx:2747
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: ustring.hxx:793
bool equalsIgnoreAsciiCaseAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1333
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:3118
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:2029
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:2596
~OUString()
Release the string data.
Definition: ustring.hxx:524
sal_Int32 compareTo(const OUString &str, sal_Int32 maxLength) const
Compares two strings with a maximum count of characters.
Definition: ustring.hxx:893
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:2137
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:1922
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:2569
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:3111
bool matchAsciiL(const char *asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:1361
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:2493
float toFloat() const
Returns the float value from this string.
Definition: ustring.hxx:2809
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:3105
static OUString createFromAscii(const char *value)
Returns an OUString copied without conversion from an ASCII character string.
Definition: ustring.hxx:3273
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:2368
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:2452
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:2286
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: ustring.hxx:1904
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:931
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1809
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1793
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:3099
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:1033
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: ustring.hxx:2796
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:1398
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:1518
OString toUtf8() const
Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully.
Definition: ustring.hxx:3028
sal_Int32 reverseCompareToAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Compares two strings in reverse order.
Definition: ustring.hxx:1216
bool equalsAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform a comparison of two strings.
Definition: ustring.hxx:1259
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:3093
bool convertToString(OString *pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) const
Converts to an OString, signalling failure.
Definition: ustring.hxx:2916
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:1451
OUString(rtl_uString *str)
New string from OUString data.
Definition: ustring.hxx:249
OUString(const sal_Unicode *value, sal_Int32 length)
New string from a Unicode character buffer array.
Definition: ustring.hxx:328
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:1652
sal_Int32 compareTo(const OUString &str) const
Compares two strings.
Definition: ustring.hxx:864
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1825
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:599
bool startsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: ustring.hxx:1436
sal_Int32 lastIndexOf(sal_Unicode ch) const
Returns the index within this string of the last occurrence of the specified character,...
Definition: ustring.hxx:1937
sal_Int32 compareToIgnoreAsciiCaseAscii(const char *asciiStr) const
Compares two ASCII strings ignoring case.
Definition: ustring.hxx:1309
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:2417
OUString(sal_Unicode value)
New string from a single Unicode character.
Definition: ustring.hxx:271
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:2323
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: ustring.hxx:2779
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: ustring.hxx:2764
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:1500
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:2095
static OUString const & unacquired(rtl_uString *const *ppHandle)
Provides an OUString const & passing a storage pointer of an rtl_uString * handle.
Definition: ustring.hxx:540
double toDouble() const
Returns the double value from this string.
Definition: ustring.hxx:2822
bool equalsAscii(const char *asciiStr) const
Perform a comparison of two strings.
Definition: ustring.hxx:1237
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:1138
OUString getToken(sal_Int32 token, sal_Unicode cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: ustring.hxx:2688
sal_Int32 getLength() const
Returns the length of this string.
Definition: ustring.hxx:806
bool equalsIgnoreAsciiCaseAscii(const char *asciiStr) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1286
OUString()
New string containing no characters.
Definition: ustring.hxx:212
OUString(const sal_Unicode *value)
New string from a Unicode character buffer array.
Definition: ustring.hxx:312
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:446
OUString & operator=(const OUString &str)
Assign a new string.
Definition: ustring.hxx:564
static OUString number(float f)
Returns the string representation of the float argument.
Definition: ustring.hxx:3133
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:816
sal_Int32 compareToIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1020
OUString(sal_uInt32 const *codePoints, sal_Int32 codePointCount)
Create a new string from an array of Unicode code points.
Definition: ustring.hxx:473
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:1580
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition: ustring.hxx:677
sal_Unicode toChar() const
Returns the first character from this string.
Definition: ustring.hxx:2732
OUString getToken(sal_Int32 count, sal_Unicode separator) const
Returns a token from the string.
Definition: ustring.hxx:2708
static OUString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: ustring.hxx:3182
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:2108
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:2170
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:1670
OUString(rtl_uString *str, __sal_NoAcquire)
New OUString from OUString data without acquiring it.
Definition: ustring.hxx:263
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:1954
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:2657
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:2637
SAL_WARN_UNUSED_RESULT OUString concat(const OUString &str) const
Concatenates the specified string to the end of this string.
Definition: ustring.hxx:2226
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:2256
bool match(const OUString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:1071
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:1124
sal_Int32 compareToAscii(const char *asciiStr) const
Compares two strings.
Definition: ustring.hxx:1163
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:350
sal_Int32 reverseCompareTo(const OUString &str) const
Compares two strings in reverse order.
Definition: ustring.hxx:918
static OUString number(double d)
Returns the string representation of the double argument.
Definition: ustring.hxx:3148
friend OUString operator+(const OUString &rStr1, const OUString &rStr2)
Definition: ustring.hxx:2235
SAL_WARN_UNUSED_RESULT OUString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: ustring.hxx:2153
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1841
bool equals(const OUString &str) const
Perform a comparison of two strings.
Definition: ustring.hxx:952
sal_Int32 lastIndexOf(const OUString &str) const
Returns the index within this string of the last occurrence of the specified substring,...
Definition: ustring.hxx:2066
bool toBoolean() const
Returns the Boolean value from this string.
Definition: ustring.hxx:2721
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:1981
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:2878
A helper to use OUStrings with hash maps.
Definition: ustring.hxx:3400
size_t operator()(const OUString &rString) const
Compute a hash code for a string.
Definition: ustring.hxx:3410