LibreOffice
LibreOffice 24.2 SDK C/C++ API Reference
ustring.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 /*
21  * This file is part of LibreOffice published API.
22  */
23 
24 #ifndef INCLUDED_RTL_USTRING_HXX
25 #define INCLUDED_RTL_USTRING_HXX
26 
27 #include "sal/config.h"
28 
29 #include <cassert>
30 #include <cstddef>
31 #include <cstdlib>
32 #include <limits>
33 #include <new>
34 #include <ostream>
35 #include <utility>
36 
37 #if defined LIBO_INTERNAL_ONLY
38 #include <algorithm>
39 #include <string_view>
40 #include <type_traits>
41 #endif
42 
43 #include "rtl/math.h"
44 #include "rtl/ustring.h"
45 #include "rtl/string.hxx"
46 #include "rtl/stringutils.hxx"
47 #include "rtl/textenc.h"
48 
49 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
50 #include "config_global.h"
51 #include "o3tl/safeint.hxx"
52 #include "rtl/stringconcat.hxx"
53 #endif
54 
55 #ifdef RTL_STRING_UNITTEST
56 extern bool rtl_string_unittest_invalid_conversion;
57 #endif
58 
59 // The unittest uses slightly different code to help check that the proper
60 // calls are made. The class is put into a different namespace to make
61 // sure the compiler generates a different (if generating also non-inline)
62 // copy of the function and does not merge them together. The class
63 // is "brought" into the proper rtl namespace by a typedef below.
64 #ifdef RTL_STRING_UNITTEST
65 #define rtl rtlunittest
66 #endif
67 
68 namespace rtl
69 {
70 
71 class OUStringBuffer;
72 
73 #ifdef RTL_STRING_UNITTEST
74 #undef rtl
75 #endif
76 
77 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
78 
86 template<std::size_t N> class SAL_WARN_UNUSED OUStringLiteral {
87  static_assert(N != 0);
88  static_assert(N - 1 <= std::numeric_limits<sal_Int32>::max(), "literal too long");
89 
90 public:
91 #if HAVE_CPP_CONSTEVAL
92  consteval
93 #else
94  constexpr
95 #endif
96  OUStringLiteral(char16_t const (&literal)[N]) {
97  assertLayout();
98  assert(literal[N - 1] == '\0');
99  std::copy_n(literal, N, more.buffer);
100  }
101 
102  constexpr sal_Int32 getLength() const { return more.length; }
103 
104  constexpr sal_Unicode const * getStr() const SAL_RETURNS_NONNULL { return more.buffer; }
105 
106  constexpr operator std::u16string_view() const { return {more.buffer, sal_uInt32(more.length)}; }
107 
108 private:
109  static constexpr void assertLayout() {
110  // These static_asserts verifying the layout compatibility with rtl_uString cannot be class
111  // member declarations, as offsetof requires a complete type, so defer them to here:
112  static_assert(std::is_standard_layout_v<OUStringLiteral>);
113  static_assert(offsetof(OUStringLiteral, str.refCount) == offsetof(OUStringLiteral, more.refCount));
114  static_assert(offsetof(OUStringLiteral, str.length) == offsetof(OUStringLiteral, more.length));
115  static_assert(offsetof(OUStringLiteral, str.buffer) == offsetof(OUStringLiteral, more.buffer));
116  }
117 
118  struct Data {
119  Data() = default;
120 
121  oslInterlockedCount refCount = 0x40000000; // SAL_STRING_STATIC_FLAG (sal/rtl/strimp.hxx)
122  sal_Int32 length = N - 1;
123  sal_Unicode buffer[N];
124  };
125 
126 public:
127  // (Data members must be public so that OUStringLiteral is a structural type that can be used as
128  // a non-type template parameter type for operator ""_ustr:)
129  union {
130  rtl_uString str;
131  Data more = {};
132  };
133 };
134 
135 #if defined RTL_STRING_UNITTEST
136 namespace libreoffice_internal {
137 template<std::size_t N> struct ExceptConstCharArrayDetector<OUStringLiteral<N>> {};
138 template<std::size_t N> struct ExceptCharArrayDetector<OUStringLiteral<N>> {};
139 }
140 #endif
141 
143 #endif
144 
145 /* ======================================================================= */
146 
170 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OUString
171 {
172 public:
174  rtl_uString * pData;
176 
181  {
182  pData = NULL;
183  rtl_uString_new( &pData );
184  }
185 
191 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
192  constexpr
193 #endif
194  OUString( const OUString & str )
195  {
196  pData = str.pData;
197 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
198  if (std::is_constant_evaluated()) {
199  //TODO: We would want to
200  //
201  // assert(SAL_STRING_IS_STATIC(pData));
202  //
203  // here, but that wouldn't work because read of member `str` of OUStringLiteral's
204  // anonymous union with active member `more` is not allowed in a constant expression.
205  } else
206 #endif
207  rtl_uString_acquire( pData );
208  }
209 
210 #if defined LIBO_INTERNAL_ONLY
211 
217 #if !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
218  constexpr
219 #endif
220  OUString( OUString && str ) noexcept
221  {
222  pData = str.pData;
223 #if !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
224  if (std::is_constant_evaluated()) {
225  //TODO: We would want to
226  //
227  // assert(SAL_STRING_IS_STATIC(pData));
228  //
229  // here, but that wouldn't work because read of member `str` of OUStringLiteral's
230  // anonymous union with active member `more` is not allowed in a constant expression.
231  return;
232  }
233 #endif
234  str.pData = nullptr;
235  rtl_uString_new( &str.pData );
236  }
237 #endif
238 
244  OUString( rtl_uString * str )
245  {
246  pData = str;
247  rtl_uString_acquire( pData );
248  }
249 
250 #if defined LIBO_INTERNAL_ONLY
251  // Catch inadvertent conversions to the above ctor:
253  OUString(std::nullptr_t) = delete;
255 #endif
256 
265  OUString( rtl_uString * str, __sal_NoAcquire )
266  { pData = str; }
267 
273  explicit OUString( sal_Unicode value )
274  : pData (NULL)
275  {
276  rtl_uString_newFromStr_WithLength( &pData, &value, 1 );
277  }
278 
279 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
280  // Catch inadvertent conversions to the above ctor (but still allow
282  // construction from char literals):
283  OUString(int) = delete;
284  explicit OUString(char c):
285  OUString(sal_Unicode(static_cast<unsigned char>(c)))
286  {}
288 #endif
289 
290 #if defined LIBO_INTERNAL_ONLY
291 
292  template<typename T> explicit OUString(
293  T const & value,
294  typename libreoffice_internal::CharPtrDetector<T, libreoffice_internal::Dummy>::TypeUtf16
295  = libreoffice_internal::Dummy()):
296  pData(nullptr)
297  { rtl_uString_newFromStr(&pData, value); }
298 
299  template<typename T> explicit OUString(
300  T & value,
301  typename
302  libreoffice_internal::NonConstCharArrayDetector<T, libreoffice_internal::Dummy>::TypeUtf16
303  = libreoffice_internal::Dummy()):
304  pData(nullptr)
305  { rtl_uString_newFromStr(&pData, value); }
306 
307 #else
308 
314  OUString( const sal_Unicode * value )
315  {
316  pData = NULL;
317  rtl_uString_newFromStr( &pData, value );
318  }
319 
320 #endif
321 
330  OUString( const sal_Unicode * value, sal_Int32 length )
331  {
332  pData = NULL;
333  rtl_uString_newFromStr_WithLength( &pData, value, length );
334  }
335 
351  template< typename T >
353  {
354  assert(
356  pData = NULL;
358  rtl_uString_new(&pData);
359  } else {
361  &pData,
363  literal),
365  }
366 #ifdef RTL_STRING_UNITTEST
367  rtl_string_unittest_const_literal = true;
368 #endif
369  }
370 
371 #if defined LIBO_INTERNAL_ONLY
372  // Rather use a u""_ustr literal (but don't remove this entirely, to avoid implicit support for
373  // it via std::u16string_view from kicking in):
374  template<typename T> OUString(
375  T &,
377  T, libreoffice_internal::Dummy>::TypeUtf16
378  = libreoffice_internal::Dummy()) = delete;
379 
380  OUString(OUStringChar c): pData(nullptr) { rtl_uString_newFromStr_WithLength(&pData, &c.c, 1); }
381 #endif
382 
383 #if defined LIBO_INTERNAL_ONLY && defined RTL_STRING_UNITTEST
384 
389  template< typename T >
390  OUString( T&, typename libreoffice_internal::ExceptConstCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
391  {
392  pData = NULL;
393  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
394  rtl_string_unittest_invalid_conversion = true;
395  }
400  template< typename T >
401  OUString( const T&, typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
402  {
403  pData = NULL;
404  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
405  rtl_string_unittest_invalid_conversion = true;
406  }
408 #endif
409 
410 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
411 
417  template<std::size_t N> constexpr OUString(OUStringLiteral<N> const & literal):
418  pData(const_cast<rtl_uString *>(&literal.str)) {}
419  template<std::size_t N> OUString(OUStringLiteral<N> &&) = delete;
421 #endif
422 
423 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
424  // For operator ""_tstr:
425  template<OStringLiteral L> OUString(detail::OStringHolder<L> const & holder) {
426  pData = nullptr;
427  if (holder.literal.getLength() == 0) {
428  rtl_uString_new(&pData);
429  } else {
431  &pData, holder.literal.getStr(), holder.literal.getLength(), 0);
432  }
433  }
434 #endif
435 
450  OUString( const char * value, sal_Int32 length,
451  rtl_TextEncoding encoding,
452  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
453  {
454  pData = NULL;
455  rtl_string2UString( &pData, value, length, encoding, convertFlags );
456  if (pData == NULL) {
457  throw std::bad_alloc();
458  }
459  }
460 
477  explicit OUString(
478  sal_uInt32 const * codePoints, sal_Int32 codePointCount):
479  pData(NULL)
480  {
481  rtl_uString_newFromCodePoints(&pData, codePoints, codePointCount);
482  if (pData == NULL) {
483  throw std::bad_alloc();
484  }
485  }
486 
487 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
488 
492  template< typename T1, typename T2 >
493  OUString( OUStringConcat< T1, T2 >&& c )
494  {
495  const sal_Int32 l = c.length();
496  pData = rtl_uString_alloc( l );
497  if (l != 0)
498  {
499  sal_Unicode* end = c.addData( pData->buffer );
500  pData->length = l;
501  *end = '\0';
502  }
503  }
504 
509  template< std::size_t N >
510  OUString( OUStringNumber< N >&& n )
511  : OUString( n.buf, n.length )
512  {}
513 #endif
514 
515 #if defined LIBO_INTERNAL_ONLY
516  explicit OUString(std::u16string_view sv) {
517  if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
518  throw std::bad_alloc();
519  }
520  pData = nullptr;
521  rtl_uString_newFromStr_WithLength(&pData, sv.data(), sv.size());
522  }
523 #endif
524 
528 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
529  constexpr
530 #endif
532  {
533 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
534  if (std::is_constant_evaluated()) {
535  //TODO: We would want to
536  //
537  // assert(SAL_STRING_IS_STATIC(pData));
538  //
539  // here, but that wouldn't work because read of member `str` of OUStringLiteral's
540  // anonymous union with active member `more` is not allowed in a constant expression.
541  } else
542 #endif
543  rtl_uString_release( pData );
544  }
545 
557  static OUString const & unacquired( rtl_uString * const * ppHandle )
558  { return * reinterpret_cast< OUString const * >( ppHandle ); }
559 
560 #if defined LIBO_INTERNAL_ONLY
561 
573  static OUString const& unacquired(const OUStringBuffer& str);
574 #endif
575 
581  OUString & operator=( const OUString & str )
582  {
583  rtl_uString_assign( &pData, str.pData );
584  return *this;
585  }
586 
587 #if defined LIBO_INTERNAL_ONLY
588 
594  OUString & operator=( OUString && str ) noexcept
595  {
596  std::swap(pData, str.pData);
597  return *this;
598  }
599 #endif
600 
613  template< typename T >
615  {
616  assert(
619  rtl_uString_new(&pData);
620  } else {
622  &pData,
624  literal),
626  }
627  return *this;
628  }
629 
630 #if defined LIBO_INTERNAL_ONLY
631  // Rather assign from a u""_ustr literal (but don't remove this entirely, to avoid implicit
632  // support for it via std::u16string_view from kicking in):
633  template<typename T>
634  typename
636  operator =(T &) = delete;
637 
638  OUString & operator =(OUStringChar c) {
639  rtl_uString_newFromStr_WithLength(&pData, &c.c, 1);
640  return *this;
641  }
642 
644  template<std::size_t N> OUString & operator =(OUStringLiteral<N> const & literal) {
645  rtl_uString_release(pData);
646  pData = const_cast<rtl_uString *>(&literal.str);
647  return *this;
648  }
649  template<std::size_t N> OUString & operator =(OUStringLiteral<N> &&) = delete;
650 
651  template <std::size_t N>
652  OUString & operator =(OUStringNumber<N> && n) {
653  // n.length should never be zero, so no need to add an optimization for that case
654  rtl_uString_newFromStr_WithLength(&pData, n.buf, n.length);
655  return *this;
656  }
657 
658  OUString & operator =(std::u16string_view sv) {
659  if (sv.empty()) {
660  rtl_uString_new(&pData);
661  } else {
662  rtl_uString_newFromStr_WithLength(&pData, sv.data(), sv.size());
663  }
664  return *this;
665  }
666 #endif
667 
668 #if defined LIBO_INTERNAL_ONLY
669 
677  inline OUString & operator+=( const OUStringBuffer & str ) &;
678 #endif
679 
687  OUString & operator+=( const OUString & str )
688 #if defined LIBO_INTERNAL_ONLY
689  &
690 #endif
691  {
692  return internalAppend(str.pData);
693  }
694 #if defined LIBO_INTERNAL_ONLY
695  void operator+=(OUString const &) && = delete;
696 #endif
697 
704  template<typename T>
706  operator +=(T & literal)
707 #if defined LIBO_INTERNAL_ONLY
708  &
709 #endif
710  {
711  assert(
714  &pData, pData,
717  return *this;
718  }
719 #if defined LIBO_INTERNAL_ONLY
720  template<typename T>
722  operator +=(T &) && = delete;
723 #endif
724 
725 #if defined LIBO_INTERNAL_ONLY
726 
727  template<typename T>
728  typename
730  operator +=(T & literal) & {
732  &pData, pData,
735  return *this;
736  }
737  template<typename T>
738  typename
739  libreoffice_internal::ConstCharArrayDetector<T, OUString &>::TypeUtf16
740  operator +=(T &) && = delete;
741 
743  template<std::size_t N> OUString & operator +=(OUStringLiteral<N> const & literal) & {
744  rtl_uString_newConcatUtf16L(&pData, pData, literal.getStr(), literal.getLength());
745  return *this;
746  }
747  template<std::size_t N> void operator +=(OUStringLiteral<N> const &) && = delete;
748 
749  OUString & operator +=(std::u16string_view sv) & {
750  if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
751  throw std::bad_alloc();
752  }
753  rtl_uString_newConcatUtf16L(&pData, pData, sv.data(), sv.size());
754  return *this;
755  }
756  void operator +=(std::u16string_view) && = delete;
757 #endif
758 
759 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
760 
764  template< typename T1, typename T2 >
765  OUString& operator+=( OUStringConcat< T1, T2 >&& c ) & {
766  sal_Int32 l = c.length();
767  if( l == 0 )
768  return *this;
769  l += pData->length;
770  rtl_uString_ensureCapacity( &pData, l );
771  sal_Unicode* end = c.addData( pData->buffer + pData->length );
772  *end = '\0';
773  pData->length = l;
774  return *this;
775  }
776  template<typename T1, typename T2> void operator +=(
777  OUStringConcat<T1, T2> &&) && = delete;
778 
783  template< std::size_t N >
784  OUString& operator+=( OUStringNumber< N >&& n ) & {
785  sal_Int32 l = n.length;
786  if( l == 0 )
787  return *this;
788  l += pData->length;
789  rtl_uString_ensureCapacity( &pData, l );
790  sal_Unicode* end = addDataHelper( pData->buffer + pData->length, n.buf, n.length );
791  *end = '\0';
792  pData->length = l;
793  return *this;
794  }
795  template<std::size_t N> void operator +=(
796  OUStringNumber<N> &&) && = delete;
797 #endif
798 
803  void clear()
804  {
805  rtl_uString_new( &pData );
806  }
807 
816  sal_Int32 getLength() const { return pData->length; }
817 
826  bool isEmpty() const
827  {
828  return pData->length == 0;
829  }
830 
838  const sal_Unicode * getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
839 
849  sal_Unicode operator [](sal_Int32 index) const {
850  // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
851  assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
852  return getStr()[index];
853  }
854 
867 #if defined LIBO_INTERNAL_ONLY
868  sal_Int32 compareTo( std::u16string_view str ) const
869  {
870  return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
871  str.data(), str.length() );
872  }
873 #else
874  sal_Int32 compareTo( const OUString & str ) const
875  {
876  return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
877  str.pData->buffer, str.pData->length );
878  }
879 #endif
880 
896 #if defined LIBO_INTERNAL_ONLY
897  sal_Int32 compareTo( std::u16string_view str, sal_Int32 maxLength ) const
898  {
899  return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
900  str.data(), str.length(), maxLength );
901  }
902 #else
903  sal_Int32 compareTo( const OUString & str, sal_Int32 maxLength ) const
904  {
905  return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
906  str.pData->buffer, str.pData->length, maxLength );
907  }
908 #endif
909 
922 #if defined LIBO_INTERNAL_ONLY
923  sal_Int32 reverseCompareTo(std::u16string_view sv) const {
925  pData->buffer, pData->length, sv.data(), sv.size());
926  }
927 #else
928  sal_Int32 reverseCompareTo( const OUString & str ) const
929  {
930  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
931  str.pData->buffer, str.pData->length );
932  }
933 #endif
934 
940  template< typename T >
942  {
943  assert(
946  pData->buffer, pData->length,
949  }
950 
962  bool equals( const OUString & str ) const
963  {
964  if ( pData->length != str.pData->length )
965  return false;
966  if ( pData == str.pData )
967  return true;
968  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
969  str.pData->buffer, str.pData->length ) == 0;
970  }
971 
986 #if defined LIBO_INTERNAL_ONLY
987  bool equalsIgnoreAsciiCase(std::u16string_view sv) const {
988  if ( sal_uInt32(pData->length) != sv.size() )
989  return false;
990  if ( pData->buffer == sv.data() )
991  return true;
992  return
994  pData->buffer, pData->length, sv.data(), sv.size())
995  == 0;
996  }
997 #else
998  bool equalsIgnoreAsciiCase( const OUString & str ) const
999  {
1000  if ( pData->length != str.pData->length )
1001  return false;
1002  if ( pData == str.pData )
1003  return true;
1004  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
1005  str.pData->buffer, str.pData->length ) == 0;
1006  }
1007 #endif
1008 
1024 #if defined LIBO_INTERNAL_ONLY
1025  sal_Int32 compareToIgnoreAsciiCase(std::u16string_view sv) const {
1027  pData->buffer, pData->length, sv.data(), sv.size());
1028  }
1029 #else
1030  sal_Int32 compareToIgnoreAsciiCase( const OUString & str ) const
1031  {
1032  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
1033  str.pData->buffer, str.pData->length );
1034  }
1035 #endif
1036 
1042  template< typename T >
1044  {
1045  assert(
1047  return
1048  (pData->length
1051  pData->buffer, pData->length,
1053  literal))
1054  == 0);
1055  }
1056 
1072 #if defined LIBO_INTERNAL_ONLY
1073  bool match(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
1074  return
1076  pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1077  sv.size())
1078  == 0;
1079  }
1080 #else
1081  bool match( const OUString & str, sal_Int32 fromIndex = 0 ) const
1082  {
1083  return rtl_ustr_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1084  str.pData->buffer, str.pData->length, str.pData->length ) == 0;
1085  }
1086 #endif
1087 
1093  template< typename T >
1094  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
1095  {
1096  assert(
1098  return
1100  pData->buffer+fromIndex, pData->length-fromIndex,
1102  literal),
1104  == 0;
1105  }
1106 
1125 #if defined LIBO_INTERNAL_ONLY
1126  bool matchIgnoreAsciiCase(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
1127  return
1129  pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1130  sv.size())
1131  == 0;
1132  }
1133 #else
1134  bool matchIgnoreAsciiCase( const OUString & str, sal_Int32 fromIndex = 0 ) const
1135  {
1136  return rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1137  str.pData->buffer, str.pData->length,
1138  str.pData->length ) == 0;
1139  }
1140 #endif
1141 
1147  template< typename T >
1148  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
1149  {
1150  assert(
1152  return matchIgnoreAsciiCaseAsciiL(
1155  }
1156 
1173  sal_Int32 compareToAscii( const char* asciiStr ) const
1174  {
1175  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length, asciiStr );
1176  }
1177 
1201  "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
1202  sal_Int32 compareToAscii( const char * asciiStr, sal_Int32 maxLength ) const
1203  {
1204  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer, pData->length,
1205  asciiStr, maxLength );
1206  }
1207 
1226  sal_Int32 reverseCompareToAsciiL( const char * asciiStr, sal_Int32 asciiStrLength ) const
1227  {
1228  return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
1229  asciiStr, asciiStrLength );
1230  }
1231 
1247  bool equalsAscii( const char* asciiStr ) const
1248  {
1249  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length,
1250  asciiStr ) == 0;
1251  }
1252 
1269  bool equalsAsciiL( const char* asciiStr, sal_Int32 asciiStrLength ) const
1270  {
1271  if ( pData->length != asciiStrLength )
1272  return false;
1273 
1275  pData->buffer, asciiStr, asciiStrLength );
1276  }
1277 
1296  bool equalsIgnoreAsciiCaseAscii( const char * asciiStr ) const
1297  {
1298  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1299  }
1300 
1301 #if defined LIBO_INTERNAL_ONLY
1302  bool equalsIgnoreAsciiCaseAscii( std::string_view asciiStr ) const
1303  {
1304  return o3tl::make_unsigned(pData->length) == asciiStr.length()
1306  pData->buffer, pData->length, asciiStr.data(), asciiStr.length()) == 0;
1307  }
1308 #endif
1309 
1328  sal_Int32 compareToIgnoreAsciiCaseAscii( const char * asciiStr ) const
1329  {
1330  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr );
1331  }
1332 
1333 #if defined LIBO_INTERNAL_ONLY
1334  sal_Int32 compareToIgnoreAsciiCaseAscii( std::string_view asciiStr ) const
1335  {
1336  sal_Int32 nMax = std::min<size_t>(asciiStr.length(), std::numeric_limits<sal_Int32>::max());
1338  pData->buffer, pData->length, asciiStr.data(), nMax);
1339  if (result == 0 && o3tl::make_unsigned(pData->length) < asciiStr.length())
1340  result = -1;
1341  return result;
1342  }
1343 #endif
1344 
1364  bool equalsIgnoreAsciiCaseAsciiL( const char * asciiStr, sal_Int32 asciiStrLength ) const
1365  {
1366  if ( pData->length != asciiStrLength )
1367  return false;
1368 
1369  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1370  }
1371 
1392  bool matchAsciiL( const char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1393  {
1394  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1395  asciiStr, asciiStrLength ) == 0;
1396  }
1397 
1398  // This overload is left undefined, to detect calls of matchAsciiL that
1399  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1400  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1401  // platforms):
1402 #if SAL_TYPES_SIZEOFLONG == 8
1403  void matchAsciiL(char const *, sal_Int32, rtl_TextEncoding) const;
1404 #endif
1405 
1429  bool matchIgnoreAsciiCaseAsciiL( const char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1430  {
1431  return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1432  asciiStr, asciiStrLength ) == 0;
1433  }
1434 
1435  // This overload is left undefined, to detect calls of
1436  // matchIgnoreAsciiCaseAsciiL that erroneously use
1437  // RTL_CONSTASCII_USTRINGPARAM instead of RTL_CONSTASCII_STRINGPARAM (but
1438  // would lead to ambiguities on 32 bit platforms):
1439 #if SAL_TYPES_SIZEOFLONG == 8
1440  void matchIgnoreAsciiCaseAsciiL(char const *, sal_Int32, rtl_TextEncoding)
1441  const;
1442 #endif
1443 
1458 #if defined LIBO_INTERNAL_ONLY
1459  bool startsWith(std::u16string_view sv, OUString * rest = nullptr) const {
1460  auto const b = match(sv);
1461  if (b && rest != nullptr) {
1462  *rest = copy(sv.size());
1463  }
1464  return b;
1465  }
1466 #else
1467  bool startsWith(OUString const & str, OUString * rest = NULL) const {
1468  bool b = match(str);
1469  if (b && rest != NULL) {
1470  *rest = copy(str.getLength());
1471  }
1472  return b;
1473  }
1474 #endif
1475 
1481  template< typename T >
1483  T & literal, OUString * rest = NULL) const
1484  {
1485  assert(
1487  bool b
1489  <= sal_uInt32(pData->length))
1491  pData->buffer,
1493  literal),
1495  if (b && rest != NULL) {
1496  *rest = copy(
1498  }
1499  return b;
1500  }
1501 
1522 #if defined LIBO_INTERNAL_ONLY
1523  bool startsWithIgnoreAsciiCase(std::u16string_view sv, OUString * rest = nullptr) const {
1524  auto const b = matchIgnoreAsciiCase(sv);
1525  if (b && rest != nullptr) {
1526  *rest = copy(sv.size());
1527  }
1528  return b;
1529  }
1530 #else
1531  bool startsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL)
1532  const
1533  {
1534  bool b = matchIgnoreAsciiCase(str);
1535  if (b && rest != NULL) {
1536  *rest = copy(str.getLength());
1537  }
1538  return b;
1539  }
1540 #endif
1541 
1547  template< typename T >
1549  startsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1550  {
1551  assert(
1553  bool b
1555  <= sal_uInt32(pData->length))
1557  pData->buffer,
1560  literal),
1562  == 0);
1563  if (b && rest != NULL) {
1564  *rest = copy(
1566  }
1567  return b;
1568  }
1569 
1584 #if defined LIBO_INTERNAL_ONLY
1585  bool endsWith(std::u16string_view sv, OUString * rest = nullptr) const {
1586  auto const b = sv.size() <= sal_uInt32(pData->length)
1587  && match(sv, pData->length - sv.size());
1588  if (b && rest != nullptr) {
1589  *rest = copy(0, (pData->length - sv.size()));
1590  }
1591  return b;
1592  }
1593 #else
1594  bool endsWith(OUString const & str, OUString * rest = NULL) const {
1595  bool b = str.getLength() <= getLength()
1596  && match(str, getLength() - str.getLength());
1597  if (b && rest != NULL) {
1598  *rest = copy(0, getLength() - str.getLength());
1599  }
1600  return b;
1601  }
1602 #endif
1603 
1609  template< typename T >
1611  endsWith(T & literal, OUString * rest = NULL) const
1612  {
1613  assert(
1615  bool b
1617  <= sal_uInt32(pData->length))
1619  (pData->buffer + pData->length
1622  literal),
1624  if (b && rest != NULL) {
1625  *rest = copy(
1626  0,
1627  (getLength()
1629  }
1630  return b;
1631  }
1632 
1644  bool endsWithAsciiL(char const * asciiStr, sal_Int32 asciiStrLength)
1645  const
1646  {
1647  return asciiStrLength <= pData->length
1649  pData->buffer + pData->length - asciiStrLength, asciiStr,
1650  asciiStrLength);
1651  }
1652 
1673 #if defined LIBO_INTERNAL_ONLY
1674  bool endsWithIgnoreAsciiCase(std::u16string_view sv, OUString * rest = nullptr) const {
1675  auto const b = sv.size() <= sal_uInt32(pData->length)
1676  && matchIgnoreAsciiCase(sv, pData->length - sv.size());
1677  if (b && rest != nullptr) {
1678  *rest = copy(0, pData->length - sv.size());
1679  }
1680  return b;
1681  }
1682 #else
1683  bool endsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL) const
1684  {
1685  bool b = str.getLength() <= getLength()
1686  && matchIgnoreAsciiCase(str, getLength() - str.getLength());
1687  if (b && rest != NULL) {
1688  *rest = copy(0, getLength() - str.getLength());
1689  }
1690  return b;
1691  }
1692 #endif
1693 
1699  template< typename T >
1701  endsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1702  {
1703  assert(
1705  bool b
1707  <= sal_uInt32(pData->length))
1709  (pData->buffer + pData->length
1713  literal),
1715  == 0);
1716  if (b && rest != NULL) {
1717  *rest = copy(
1718  0,
1719  (getLength()
1721  }
1722  return b;
1723  }
1724 
1736  char const * asciiStr, sal_Int32 asciiStrLength) const
1737  {
1738  return asciiStrLength <= pData->length
1740  pData->buffer + pData->length - asciiStrLength,
1741  asciiStrLength, asciiStr, asciiStrLength)
1742  == 0);
1743  }
1744 
1745  friend bool operator == ( const OUString& rStr1, const OUString& rStr2 )
1746  { return rStr1.equals(rStr2); }
1747 
1748  friend bool operator != ( const OUString& rStr1, const OUString& rStr2 )
1749  { return !(operator == ( rStr1, rStr2 )); }
1750 
1751  friend bool operator < ( const OUString& rStr1, const OUString& rStr2 )
1752  { return rStr1.compareTo( rStr2 ) < 0; }
1753  friend bool operator > ( const OUString& rStr1, const OUString& rStr2 )
1754  { return rStr1.compareTo( rStr2 ) > 0; }
1755  friend bool operator <= ( const OUString& rStr1, const OUString& rStr2 )
1756  { return rStr1.compareTo( rStr2 ) <= 0; }
1757  friend bool operator >= ( const OUString& rStr1, const OUString& rStr2 )
1758  { return rStr1.compareTo( rStr2 ) >= 0; }
1759 
1760 #if defined LIBO_INTERNAL_ONLY
1761 
1762  template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1763  operator ==(OUString const & s1, T const & s2) {
1765  == 0;
1766  }
1767 
1768  template<typename T>
1769  friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1770  operator ==(OUString const & s1, T & s2) {
1771  return rtl_ustr_compare_WithLength(s1.getStr(), s1.getLength(), s2, rtl_ustr_getLength(s2))
1772  == 0;
1773  }
1774 
1775  template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1776  operator ==(T const & s1, OUString const & s2) {
1777  return rtl_ustr_compare_WithLength(s1, rtl_ustr_getLength(s1), s2.getStr(), s2.getLength())
1778  == 0;
1779  }
1780 
1781  template<typename T>
1782  friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1783  operator ==(T & s1, OUString const & s2) {
1784  return rtl_ustr_compare_WithLength(s1, rtl_ustr_getLength(s1), s2.getStr(), s2.getLength())
1785  == 0;
1786  }
1787 
1788  template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1789  operator !=(OUString const & s1, T const & s2) { return !(s1 == s2); }
1790 
1791  template<typename T>
1792  friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1793  operator !=(OUString const & s1, T & s2) { return !(s1 == s2); }
1794 
1795  template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1796  operator !=(T const & s1, OUString const & s2) { return !(s1 == s2); }
1797 
1798  template<typename T>
1799  friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1800  operator !=(T & s1, OUString const & s2) { return !(s1 == s2); }
1801 
1802 #else
1803 
1804  friend bool operator == ( const OUString& rStr1, const sal_Unicode * pStr2 )
1805  { return rStr1.compareTo( pStr2 ) == 0; }
1806  friend bool operator == ( const sal_Unicode * pStr1, const OUString& rStr2 )
1807  { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
1808 
1809  friend bool operator != ( const OUString& rStr1, const sal_Unicode * pStr2 )
1810  { return !(operator == ( rStr1, pStr2 )); }
1811  friend bool operator != ( const sal_Unicode * pStr1, const OUString& rStr2 )
1812  { return !(operator == ( pStr1, rStr2 )); }
1813 
1814 #endif
1815 
1823  template< typename T >
1825  {
1826  assert(
1828  return rString.equalsAsciiL(
1831  }
1839  template< typename T >
1841  {
1842  assert(
1844  return rString.equalsAsciiL(
1847  }
1855  template< typename T >
1857  {
1858  assert(
1860  return !rString.equalsAsciiL(
1863  }
1871  template< typename T >
1873  {
1874  assert(
1876  return !rString.equalsAsciiL(
1879  }
1880 
1881 #if defined LIBO_INTERNAL_ONLY
1882 
1883  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1884  operator ==(OUString const & string, T & literal) {
1885  return
1887  string.pData->buffer, string.pData->length,
1889  literal),
1891  == 0;
1892  }
1894  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1895  operator ==(T & literal, OUString const & string) {
1896  return
1898  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1899  literal),
1900  libreoffice_internal::ConstCharArrayDetector<T>::length,
1901  string.pData->buffer, string.pData->length)
1902  == 0;
1903  }
1905  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1906  operator !=(OUString const & string, T & literal) {
1907  return
1909  string.pData->buffer, string.pData->length,
1910  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1911  literal),
1912  libreoffice_internal::ConstCharArrayDetector<T>::length)
1913  != 0;
1914  }
1916  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1917  operator !=(T & literal, OUString const & string) {
1918  return
1920  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1921  literal),
1922  libreoffice_internal::ConstCharArrayDetector<T>::length,
1923  string.pData->buffer, string.pData->length)
1924  != 0;
1925  }
1926 #endif
1927 
1935  sal_Int32 hashCode() const
1936  {
1937  return rtl_ustr_hashCode_WithLength( pData->buffer, pData->length );
1938  }
1939 
1953  sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
1954  {
1955  sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1956  return (ret < 0 ? ret : ret+fromIndex);
1957  }
1958 
1968  sal_Int32 lastIndexOf( sal_Unicode ch ) const
1969  {
1970  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1971  }
1972 
1985  sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
1986  {
1987  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1988  }
1989 
2005 #if defined LIBO_INTERNAL_ONLY
2006  sal_Int32 indexOf(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
2007  auto const n = rtl_ustr_indexOfStr_WithLength(
2008  pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size());
2009  return n < 0 ? n : n + fromIndex;
2010  }
2011 #else
2012  sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
2013  {
2014  sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
2015  str.pData->buffer, str.pData->length );
2016  return (ret < 0 ? ret : ret+fromIndex);
2017  }
2018 #endif
2019 
2025  template< typename T >
2026  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
2027  {
2028  assert(
2030  sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
2031  pData->buffer + fromIndex, pData->length - fromIndex,
2034  return n < 0 ? n : n + fromIndex;
2035  }
2036 
2060  sal_Int32 indexOfAsciiL(
2061  char const * str, sal_Int32 len, sal_Int32 fromIndex = 0) const
2062  {
2063  sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
2064  pData->buffer + fromIndex, pData->length - fromIndex, str, len);
2065  return ret < 0 ? ret : ret + fromIndex;
2066  }
2067 
2068  // This overload is left undefined, to detect calls of indexOfAsciiL that
2069  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
2070  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
2071  // platforms):
2072 #if SAL_TYPES_SIZEOFLONG == 8
2073  void indexOfAsciiL(char const *, sal_Int32 len, rtl_TextEncoding) const;
2074 #endif
2075 
2091 #if defined LIBO_INTERNAL_ONLY
2092  sal_Int32 lastIndexOf(std::u16string_view sv) const {
2094  pData->buffer, pData->length, sv.data(), sv.size());
2095  }
2096 #else
2097  sal_Int32 lastIndexOf( const OUString & str ) const
2098  {
2099  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
2100  str.pData->buffer, str.pData->length );
2101  }
2102 #endif
2103 
2121 #if defined LIBO_INTERNAL_ONLY
2122  sal_Int32 lastIndexOf(std::u16string_view sv, sal_Int32 fromIndex) const {
2123  return rtl_ustr_lastIndexOfStr_WithLength(pData->buffer, fromIndex, sv.data(), sv.size());
2124  }
2125 #else
2126  sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
2127  {
2128  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
2129  str.pData->buffer, str.pData->length );
2130  }
2131 #endif
2132 
2138  template< typename T >
2140  {
2141  assert(
2144  pData->buffer, pData->length,
2147  }
2148 
2168  sal_Int32 lastIndexOfAsciiL(char const * str, sal_Int32 len) const
2169  {
2171  pData->buffer, pData->length, str, len);
2172  }
2173 
2184  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex ) const
2185  {
2186  return copy(beginIndex, getLength() - beginIndex);
2187  }
2188 
2201  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const
2202  {
2203  rtl_uString *pNew = NULL;
2204  rtl_uString_newFromSubString( &pNew, pData, beginIndex, count );
2205  return OUString( pNew, SAL_NO_ACQUIRE );
2206  }
2207 
2208 #if defined LIBO_INTERNAL_ONLY
2209 
2219  SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex ) const
2220  {
2221  assert(beginIndex >= 0);
2222  assert(beginIndex <= getLength());
2223  return subView(beginIndex, getLength() - beginIndex);
2224  }
2225 
2238  SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex, sal_Int32 count ) const
2239  {
2240  assert(beginIndex >= 0);
2241  assert(count >= 0);
2242  assert(beginIndex <= getLength());
2243  assert(count <= getLength() - beginIndex);
2244  return std::u16string_view(*this).substr(beginIndex, count);
2245  }
2246 #endif
2247 
2248 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2249 
2258  {
2259  rtl_uString* pNew = NULL;
2260  rtl_uString_newConcat( &pNew, pData, str.pData );
2261  return OUString( pNew, SAL_NO_ACQUIRE );
2262  }
2263 #endif
2264 
2265 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2266  friend OUString operator+( const OUString& rStr1, const OUString& rStr2 )
2267  {
2268  return rStr1.concat( rStr2 );
2269  }
2270 #endif
2271 
2272 // hide this from internal code to avoid ambiguous lookup error
2273 #ifndef LIBO_INTERNAL_ONLY
2274 
2287  SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const
2288  {
2289  rtl_uString* pNew = NULL;
2290  rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
2291  return OUString( pNew, SAL_NO_ACQUIRE );
2292  }
2293 #endif
2294 
2295 #ifdef LIBO_INTERNAL_ONLY
2296  SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, std::u16string_view newStr ) const
2297  {
2298  rtl_uString* pNew = NULL;
2299  rtl_uString_newReplaceStrAtUtf16L( &pNew, pData, index, count, newStr.data(), newStr.size() );
2300  return OUString( pNew, SAL_NO_ACQUIRE );
2301  }
2302 #endif
2303 
2318  {
2319  rtl_uString* pNew = NULL;
2320  rtl_uString_newReplace( &pNew, pData, oldChar, newChar );
2321  return OUString( pNew, SAL_NO_ACQUIRE );
2322  }
2323 
2342 #if defined LIBO_INTERNAL_ONLY
2343  [[nodiscard]] OUString replaceFirst(
2344  std::u16string_view from, std::u16string_view to, sal_Int32 * index = nullptr) const
2345  {
2346  rtl_uString * s = nullptr;
2347  sal_Int32 i = 0;
2349  &s, pData, from.data(), from.size(), to.data(), to.size(),
2350  index == nullptr ? &i : index);
2351  return OUString(s, SAL_NO_ACQUIRE);
2352  }
2353 #else
2355  OUString const & from, OUString const & to, sal_Int32 * index = NULL) const
2356  {
2357  rtl_uString * s = NULL;
2358  sal_Int32 i = 0;
2360  &s, pData, from.pData, to.pData, index == NULL ? &i : index);
2361  return OUString(s, SAL_NO_ACQUIRE);
2362  }
2363 #endif
2364 
2383 #if defined LIBO_INTERNAL_ONLY
2384  template<typename T> [[nodiscard]]
2386  T & from, std::u16string_view to, sal_Int32 * index = nullptr) const
2387  {
2389  rtl_uString * s = nullptr;
2390  sal_Int32 i = 0;
2394  index == nullptr ? &i : index);
2395  return OUString(s, SAL_NO_ACQUIRE);
2396  }
2397 #else
2398  template< typename T >
2400  sal_Int32 * index = NULL) const
2401  {
2403  rtl_uString * s = NULL;
2404  sal_Int32 i = 0;
2406  &s, pData,
2409  index == NULL ? &i : index);
2410  return OUString(s, SAL_NO_ACQUIRE);
2411  }
2412 #endif
2413 
2432 #if defined LIBO_INTERNAL_ONLY
2433  template<typename T> [[nodiscard]]
2435  std::u16string_view from, T & to, sal_Int32 * index = nullptr) const
2436  {
2438  rtl_uString * s = nullptr;
2439  sal_Int32 i = 0;
2441  &s, pData, from.data(), from.size(),
2443  libreoffice_internal::ConstCharArrayDetector<T>::length, index == nullptr ? &i : index);
2444  return OUString(s, SAL_NO_ACQUIRE);
2445  }
2446 #else
2447  template< typename T >
2449  sal_Int32 * index = NULL) const
2450  {
2452  rtl_uString * s = NULL;
2453  sal_Int32 i = 0;
2455  &s, pData, from.pData,
2458  index == NULL ? &i : index);
2459  return OUString(s, SAL_NO_ACQUIRE);
2460  }
2461 #endif
2462 
2481  template< typename T1, typename T2 >
2483  replaceFirst( T1& from, T2& to, sal_Int32 * index = NULL) const
2484  {
2487  rtl_uString * s = NULL;
2488  sal_Int32 i = 0;
2490  &s, pData,
2495  index == NULL ? &i : index);
2496  return OUString(s, SAL_NO_ACQUIRE);
2497  }
2498 
2514 #if defined LIBO_INTERNAL_ONLY
2515  [[nodiscard]] OUString replaceAll(
2516  std::u16string_view from, std::u16string_view to, sal_Int32 fromIndex = 0) const
2517  {
2518  rtl_uString * s = nullptr;
2519  rtl_uString_newReplaceAllFromIndexUtf16LUtf16L(
2520  &s, pData, from.data(), from.size(), to.data(), to.size(), fromIndex);
2521  return OUString(s, SAL_NO_ACQUIRE);
2522  }
2523 #else
2525  OUString const & from, OUString const & to, sal_Int32 fromIndex = 0) const
2526  {
2527  rtl_uString * s = NULL;
2528  rtl_uString_newReplaceAllFromIndex(&s, pData, from.pData, to.pData, fromIndex);
2529  return OUString(s, SAL_NO_ACQUIRE);
2530  }
2531 #endif
2532 
2546 #if defined LIBO_INTERNAL_ONLY
2547  template<typename T> [[nodiscard]]
2549  T & from, std::u16string_view to) const
2550  {
2552  rtl_uString * s = nullptr;
2556  return OUString(s, SAL_NO_ACQUIRE);
2557  }
2558 #else
2559  template< typename T >
2561  {
2563  rtl_uString * s = NULL;
2565  &s, pData,
2568  return OUString(s, SAL_NO_ACQUIRE);
2569  }
2570 #endif
2571 
2585 #if defined LIBO_INTERNAL_ONLY
2586  template<typename T> [[nodiscard]]
2588  std::u16string_view from, T & to) const
2589  {
2591  rtl_uString * s = nullptr;
2593  &s, pData, from.data(), from.size(),
2596  return OUString(s, SAL_NO_ACQUIRE);
2597  }
2598 #else
2599  template< typename T >
2601  {
2603  rtl_uString * s = NULL;
2605  &s, pData, from.pData,
2608  return OUString(s, SAL_NO_ACQUIRE);
2609  }
2610 #endif
2611 
2625  template< typename T1, typename T2 >
2627  replaceAll( T1& from, T2& to ) const
2628  {
2631  rtl_uString * s = NULL;
2633  &s, pData,
2638  return OUString(s, SAL_NO_ACQUIRE);
2639  }
2640 
2652  {
2653  rtl_uString* pNew = NULL;
2654  rtl_uString_newToAsciiLowerCase( &pNew, pData );
2655  return OUString( pNew, SAL_NO_ACQUIRE );
2656  }
2657 
2669  {
2670  rtl_uString* pNew = NULL;
2671  rtl_uString_newToAsciiUpperCase( &pNew, pData );
2672  return OUString( pNew, SAL_NO_ACQUIRE );
2673  }
2674 
2689  {
2690  rtl_uString* pNew = NULL;
2691  rtl_uString_newTrim( &pNew, pData );
2692  return OUString( pNew, SAL_NO_ACQUIRE );
2693  }
2694 
2719  OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const
2720  {
2721  rtl_uString * pNew = NULL;
2722  index = rtl_uString_getToken( &pNew, pData, token, cTok, index );
2723  return OUString( pNew, SAL_NO_ACQUIRE );
2724  }
2725 
2739  OUString getToken(sal_Int32 count, sal_Unicode separator) const {
2740  sal_Int32 n = 0;
2741  return getToken(count, separator, n);
2742  }
2743 
2752  bool toBoolean() const
2753  {
2754  return rtl_ustr_toBoolean( pData->buffer );
2755  }
2756 
2764  {
2765  return pData->buffer[0];
2766  }
2767 
2778  sal_Int32 toInt32( sal_Int16 radix = 10 ) const
2779  {
2780  return rtl_ustr_toInt32( pData->buffer, radix );
2781  }
2782 
2795  sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
2796  {
2797  return rtl_ustr_toUInt32( pData->buffer, radix );
2798  }
2799 
2810  sal_Int64 toInt64( sal_Int16 radix = 10 ) const
2811  {
2812  return rtl_ustr_toInt64( pData->buffer, radix );
2813  }
2814 
2827  sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
2828  {
2829  return rtl_ustr_toUInt64( pData->buffer, radix );
2830  }
2831 
2840  float toFloat() const
2841  {
2842  return rtl_ustr_toFloat( pData->buffer );
2843  }
2844 
2853  double toDouble() const
2854  {
2855  return rtl_ustr_toDouble( pData->buffer );
2856  }
2857 
2858 
2875  {
2876  rtl_uString * pNew = NULL;
2877  rtl_uString_intern( &pNew, pData );
2878  if (pNew == NULL) {
2879  throw std::bad_alloc();
2880  }
2881  return OUString( pNew, SAL_NO_ACQUIRE );
2882  }
2883 
2909  static OUString intern( const char * value, sal_Int32 length,
2910  rtl_TextEncoding encoding,
2911  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS,
2912  sal_uInt32 *pInfo = NULL )
2913  {
2914  rtl_uString * pNew = NULL;
2915  rtl_uString_internConvert( &pNew, value, length, encoding,
2916  convertFlags, pInfo );
2917  if (pNew == NULL) {
2918  throw std::bad_alloc();
2919  }
2920  return OUString( pNew, SAL_NO_ACQUIRE );
2921  }
2922 
2947  bool convertToString(OString * pTarget, rtl_TextEncoding nEncoding,
2948  sal_uInt32 nFlags) const
2949  {
2950  return rtl_convertUStringToString(&pTarget->pData, pData->buffer,
2951  pData->length, nEncoding, nFlags);
2952  }
2953 
3005  sal_uInt32 iterateCodePoints(
3006  sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1) const
3007  {
3009  pData, indexUtf16, incrementCodePoints);
3010  }
3011 
3021 #if defined LIBO_INTERNAL_ONLY
3022  static OUString fromUtf8(std::string_view rSource)
3023  {
3024  OUString aTarget;
3025  bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
3026  rSource.data(),
3027  rSource.length(),
3030  (void) bSuccess;
3031  assert(bSuccess);
3032  return aTarget;
3033  }
3034 #else
3035  static OUString fromUtf8(const OString& rSource)
3036  {
3037  OUString aTarget;
3038  bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
3039  rSource.getStr(),
3040  rSource.getLength(),
3043  (void) bSuccess;
3044  assert(bSuccess);
3045  return aTarget;
3046  }
3047 #endif
3048 
3059  OString toUtf8() const
3060  {
3061  OString aTarget;
3062  bool bSuccess = rtl_convertUStringToString(&aTarget.pData,
3063  getStr(),
3064  getLength(),
3067  (void) bSuccess;
3068  assert(bSuccess);
3069  return aTarget;
3070  }
3071 
3072 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3073 
3074  static auto number( int i, sal_Int16 radix = 10 )
3075  {
3076  return OUStringNumber<RTL_USTR_MAX_VALUEOFINT32>(rtl_ustr_valueOfInt32, i, radix);
3077  }
3078  static auto number( long long ll, sal_Int16 radix = 10 )
3079  {
3080  return OUStringNumber<RTL_USTR_MAX_VALUEOFINT64>(rtl_ustr_valueOfInt64, ll, radix);
3081  }
3082  static auto number( unsigned long long ll, sal_Int16 radix = 10 )
3083  {
3084  return OUStringNumber<RTL_USTR_MAX_VALUEOFUINT64>(rtl_ustr_valueOfUInt64, ll, radix);
3085  }
3086  static auto number( unsigned int i, sal_Int16 radix = 10 )
3087  {
3088  return number( static_cast< unsigned long long >( i ), radix );
3089  }
3090  static auto number( long i, sal_Int16 radix = 10)
3091  {
3092  return number( static_cast< long long >( i ), radix );
3093  }
3094  static auto number( unsigned long i, sal_Int16 radix = 10 )
3095  {
3096  return number( static_cast< unsigned long long >( i ), radix );
3097  }
3098 #else
3099 
3109  static OUString number( int i, sal_Int16 radix = 10 )
3110  {
3112  return OUString(aBuf, rtl_ustr_valueOfInt32(aBuf, i, radix));
3113  }
3116  static OUString number( unsigned int i, sal_Int16 radix = 10 )
3117  {
3118  return number( static_cast< unsigned long long >( i ), radix );
3119  }
3122  static OUString number( long i, sal_Int16 radix = 10)
3123  {
3124  return number( static_cast< long long >( i ), radix );
3125  }
3128  static OUString number( unsigned long i, sal_Int16 radix = 10 )
3129  {
3130  return number( static_cast< unsigned long long >( i ), radix );
3131  }
3134  static OUString number( long long ll, sal_Int16 radix = 10 )
3135  {
3137  return OUString(aBuf, rtl_ustr_valueOfInt64(aBuf, ll, radix));
3138  }
3141  static OUString number( unsigned long long ll, sal_Int16 radix = 10 )
3142  {
3144  return OUString(aBuf, rtl_ustr_valueOfUInt64(aBuf, ll, radix));
3145  }
3146 #endif
3147 
3157  static OUString number( float f )
3158  {
3159  rtl_uString* pNew = NULL;
3160  // Same as rtl::str::valueOfFP, used for rtl_ustr_valueOfFloat
3162  RTL_USTR_MAX_VALUEOFFLOAT - SAL_N_ELEMENTS("-x.E-xxx") + 1, '.',
3163  NULL, 0, true);
3164  if (pNew == NULL)
3165  throw std::bad_alloc();
3166 
3167  return OUString(pNew, SAL_NO_ACQUIRE);
3168  }
3169 
3179  static OUString number( double d )
3180  {
3181  rtl_uString* pNew = NULL;
3182  // Same as rtl::str::valueOfFP, used for rtl_ustr_valueOfDouble
3184  RTL_USTR_MAX_VALUEOFDOUBLE - SAL_N_ELEMENTS("-x.E-xxx") + 1, '.',
3185  NULL, 0, true);
3186  if (pNew == NULL)
3187  throw std::bad_alloc();
3188 
3189  return OUString(pNew, SAL_NO_ACQUIRE);
3190  }
3191 
3192 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3193  static auto boolean(bool b)
3194  {
3195  return OUStringNumber<RTL_USTR_MAX_VALUEOFBOOLEAN>(rtl_ustr_valueOfBoolean, b);
3196  }
3197 #else
3198 
3209  SAL_DEPRECATED("use boolean()") static OUString valueOf( sal_Bool b )
3210  {
3211  return boolean(b);
3212  }
3213 
3225  static OUString boolean( bool b )
3226  {
3228  return OUString(aBuf, rtl_ustr_valueOfBoolean(aBuf, b));
3229  }
3230 #endif
3231 
3239  SAL_DEPRECATED("convert to OUString or use directly") static OUString valueOf( sal_Unicode c )
3240  {
3241  return OUString( &c, 1 );
3242  }
3243 
3254  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
3255  {
3256  return number( i, radix );
3257  }
3258 
3269  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
3270  {
3271  return number( ll, radix );
3272  }
3273 
3283  SAL_DEPRECATED("use number()") static OUString valueOf( float f )
3284  {
3285  return number(f);
3286  }
3287 
3297  SAL_DEPRECATED("use number()") static OUString valueOf( double d )
3298  {
3299  return number(d);
3300  }
3301 
3317  static OUString createFromAscii( const char * value )
3318  {
3319  rtl_uString* pNew = NULL;
3320  rtl_uString_newFromAscii( &pNew, value );
3321  return OUString( pNew, SAL_NO_ACQUIRE );
3322  }
3323 
3324 #if defined LIBO_INTERNAL_ONLY
3325  static OUString createFromAscii(std::string_view value) {
3326  rtl_uString * p = nullptr;
3327  rtl_uString_newFromLiteral(&p, value.data(), value.size(), 0); //TODO: check for overflow
3328  return OUString(p, SAL_NO_ACQUIRE);
3329  }
3330  #endif
3331 
3332 #if defined LIBO_INTERNAL_ONLY
3333  operator std::u16string_view() const { return {getStr(), sal_uInt32(getLength())}; }
3334 #endif
3335 
3336 #if defined LIBO_INTERNAL_ONLY
3337  // A wrapper for the first expression in an
3338  //
3339  // OUString::Concat(e1) + e2 + ...
3340  //
3341  // concatenation chain, when neither of the first two e1, e2 is one of our rtl string-related
3342  // classes (so something like
3343  //
3344  // OUString s = "a" + (b ? std::u16string_view(u"c") : std::u16string_view(u"dd"));
3345  //
3346  // would not compile):
3347  template<typename T> [[nodiscard]] static
3348  OUStringConcat<OUStringConcatMarker, T>
3349  Concat(T const & value) { return OUStringConcat<OUStringConcatMarker, T>(value); }
3350 
3351  // This overload is needed so that an argument of type 'char const[N]' ends up as
3352  // 'OUStringConcat<rtl::OUStringConcatMarker, char const[N]>' rather than as
3353  // 'OUStringConcat<rtl::OUStringConcatMarker, char[N]>':
3354  template<typename T, std::size_t N> [[nodiscard]] static
3355  OUStringConcat<OUStringConcatMarker, T[N]>
3356  Concat(T (& value)[N]) { return OUStringConcat<OUStringConcatMarker, T[N]>(value); }
3357 #endif
3358 
3359 private:
3360  OUString & internalAppend( rtl_uString* pOtherData )
3361  {
3362  rtl_uString* pNewData = NULL;
3363  rtl_uString_newConcat( &pNewData, pData, pOtherData );
3364  if (pNewData == NULL) {
3365  throw std::bad_alloc();
3366  }
3367  rtl_uString_assign(&pData, pNewData);
3368  rtl_uString_release(pNewData);
3369  return *this;
3370  }
3371 
3372 };
3373 
3374 #if defined LIBO_INTERNAL_ONLY
3375 // Prevent the operator ==/!= overloads with 'sal_Unicode const *' parameter from
3376 // being selected for nonsensical code like
3377 //
3378 // if (ouIdAttr == nullptr)
3379 //
3380 void operator ==(OUString const &, std::nullptr_t) = delete;
3381 void operator ==(std::nullptr_t, OUString const &) = delete;
3382 void operator !=(OUString const &, std::nullptr_t) = delete;
3383 void operator !=(std::nullptr_t, OUString const &) = delete;
3384 #endif
3385 
3386 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3387 inline bool operator ==(OUString const & lhs, StringConcatenation<char16_t> const & rhs)
3388 { return lhs == std::u16string_view(rhs); }
3389 inline bool operator !=(OUString const & lhs, StringConcatenation<char16_t> const & rhs)
3390 { return lhs != std::u16string_view(rhs); }
3391 inline bool operator ==(StringConcatenation<char16_t> const & lhs, OUString const & rhs)
3392 { return std::u16string_view(lhs) == rhs; }
3393 inline bool operator !=(StringConcatenation<char16_t> const & lhs, OUString const & rhs)
3394 { return std::u16string_view(lhs) != rhs; }
3395 #endif
3396 
3397 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3398 
3403 template<>
3404 struct ToStringHelper< OUString >
3405 {
3406  static std::size_t length( const OUString& s ) { return s.getLength(); }
3407  sal_Unicode* operator() ( sal_Unicode* buffer, const OUString& s ) const { return addDataHelper( buffer, s.getStr(), s.getLength()); }
3408 };
3409 
3413 template<std::size_t N>
3414 struct ToStringHelper< OUStringLiteral<N> >
3415 {
3416  static std::size_t length( const OUStringLiteral<N>& str ) { return str.getLength(); }
3417  sal_Unicode* operator()( sal_Unicode* buffer, const OUStringLiteral<N>& str ) const { return addDataHelper( buffer, str.getStr(), str.getLength() ); }
3418 };
3419 
3423 template< typename charT, typename traits, typename T1, typename T2 >
3424 inline std::basic_ostream<charT, traits> & operator <<(
3425  std::basic_ostream<charT, traits> & stream, OUStringConcat< T1, T2 >&& concat)
3426 {
3427  return stream << OUString( std::move(concat) );
3428 }
3429 
3431 #endif
3432 
3439 {
3449  size_t operator()(const OUString& rString) const
3450  { return static_cast<size_t>(rString.hashCode()); }
3451 };
3452 
3453 /* ======================================================================= */
3454 
3472 #if defined LIBO_INTERNAL_ONLY
3473 inline OUString OStringToOUString( std::string_view rStr,
3474  rtl_TextEncoding encoding,
3475  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
3476 {
3477  return OUString( rStr.data(), rStr.length(), encoding, convertFlags );
3478 }
3479 #else
3480 inline OUString OStringToOUString( const OString & rStr,
3481  rtl_TextEncoding encoding,
3482  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
3483 {
3484  return OUString( rStr.getStr(), rStr.getLength(), encoding, convertFlags );
3485 }
3486 #endif
3487 
3505 #if defined LIBO_INTERNAL_ONLY
3506 inline OString OUStringToOString( std::u16string_view rUnicode,
3507  rtl_TextEncoding encoding,
3508  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
3509 {
3510  return OString( rUnicode.data(), rUnicode.length(), encoding, convertFlags );
3511 }
3512 #else
3513 inline OString OUStringToOString( const OUString & rUnicode,
3514  rtl_TextEncoding encoding,
3515  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
3516 {
3517  return OString( rUnicode.getStr(), rUnicode.getLength(), encoding, convertFlags );
3518 }
3519 #endif
3520 
3521 /* ======================================================================= */
3522 
3531 template< typename charT, typename traits >
3532 inline std::basic_ostream<charT, traits> & operator <<(
3533  std::basic_ostream<charT, traits> & stream, OUString const & rString)
3534 {
3535  return stream <<
3537  // best effort; potentially loses data due to conversion failures
3538  // (stray surrogate halves) and embedded null characters
3539 }
3540 
3541 } // namespace
3542 
3543 #ifdef RTL_STRING_UNITTEST
3544 namespace rtl
3545 {
3546 typedef rtlunittest::OUString OUString;
3547 }
3548 #endif
3549 
3550 // In internal code, allow to use classes like OUString without having to
3551 // explicitly refer to the rtl namespace, which is kind of superfluous given
3552 // that OUString itself is namespaced by its OU prefix:
3553 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3554 using ::rtl::OUString;
3555 using ::rtl::OUStringHash;
3558 using ::rtl::OUStringLiteral;
3559 using ::rtl::OUStringChar;
3560 using ::rtl::Concat2View;
3561 #endif
3562 
3563 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
3564 
3565 template<
3566 #if defined RTL_STRING_UNITTEST
3567  rtlunittest::
3568 #endif
3569  OUStringLiteral L>
3570 constexpr
3571 #if defined RTL_STRING_UNITTEST
3572  rtlunittest::
3573 #endif
3574  OUString
3575 operator ""_ustr() { return L; }
3576 
3577 #endif
3578 
3580 
3585 #if defined LIBO_INTERNAL_ONLY
3586 namespace std {
3587 
3588 template<>
3589 struct hash<::rtl::OUString>
3590 {
3591  std::size_t operator()(::rtl::OUString const & s) const
3592  {
3593  if constexpr (sizeof(std::size_t) == 8)
3594  {
3595  // return a hash that uses the full 64-bit range instead of a 32-bit value
3596  size_t n = s.getLength();
3597  for (sal_Int32 i = 0, len = s.getLength(); i < len; ++i)
3598  n = 37 * n + s[i];
3599  return n;
3600  }
3601  else
3602  return std::size_t(s.hashCode());
3603  }
3604 };
3605 
3606 }
3607 
3608 #endif
3609 
3611 #endif /* _RTL_USTRING_HXX */
3612 
3613 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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:2524
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1350
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_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:659
SAL_WARN_UNUSED_RESULT OUString concat(const OUString &str) const
Concatenates the specified string to the end of this string.
Definition: ustring.hxx:2257
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:3513
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: ustring.hxx:2827
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 ...
Definition: ustring.hxx:941
SAL_WARN_UNUSED_RESULT OUString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: ustring.hxx:2184
OUString()
New string containing no characters.
Definition: ustring.hxx:180
sal_Int32 getLength() const
Returns the length of this string.
Definition: ustring.hxx:816
#define RTL_TEXTENCODING_UTF8
Definition: textenc.h:117
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 void rtl_uString_intern(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Return a canonical representation for a string.
#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:68
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.
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:3480
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:3141
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...
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 ...
Definition: ustring.hxx:2026
SAL_DLLPUBLIC void rtl_math_doubleToUString(rtl_uString **pResult, sal_Int32 *pResultCapacity, sal_Int32 nResultOffset, double fValue, enum rtl_math_StringFormat eFormat, sal_Int32 nDecPlaces, sal_Unicode cDecSeparator, sal_Int32 const *pGroups, sal_Unicode cGroupSeparator, sal_Bool bEraseTrailingDecZeros) SAL_THROW_EXTERN_C()
Conversions analogous to sprintf() using internal rounding.
sal_Int32 indexOf(const OUString &str, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
Definition: ustring.hxx:2012
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...
double toDouble() const
Returns the double value from this string.
Definition: ustring.hxx:2853
sal_Unicode toChar() const
Returns the first character from this string.
Definition: ustring.hxx:2763
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:1134
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.
bool equalsAscii(const char *asciiStr) const
Perform a comparison of two strings.
Definition: ustring.hxx:1247
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &stream, OString const &rString)
Support for rtl::OString in std::ostream (and thus in CPPUNIT_ASSERT or SAL_INFO macros, for example).
Definition: string.hxx:2355
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 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.
const char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:685
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 ...
Definition: ustring.hxx:1148
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 ...
Definition: ustring.hxx:1482
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 ...
Definition: ustring.hxx:1094
#define RTL_USTR_MAX_VALUEOFFLOAT
Definition: ustring.h:1026
bool startsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: ustring.hxx:1467
static OUString const & unacquired(rtl_uString *const *ppHandle)
Provides an OUString const & passing a storage pointer of an rtl_uString * handle.
Definition: ustring.hxx:557
#define RTL_USTR_MAX_VALUEOFUINT64
Definition: ustring.h:1007
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 ...
Definition: ustring.hxx:1043
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...
friend OUString operator+(const OUString &rStr1, const OUString &rStr2)
Definition: ustring.hxx:2266
sal_Int32 reverseCompareToAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Compares two strings in reverse order.
Definition: ustring.hxx:1226
static OUString fromUtf8(const OString &rSource)
Convert an OString to an OUString, assuming that the OString is UTF-8-encoded.
Definition: ustring.hxx:3035
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_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:3005
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.
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.
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:3116
A string buffer implements a mutable sequence of characters.
Definition: ustrbuf.hxx:72
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.
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:675
const sal_Unicode * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:838
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:93
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1824
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_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 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 sal_Int32 rtl_ustr_valueOfBoolean(sal_Unicode *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
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 ...
Definition: ustring.hxx:1549
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 ...
Definition: ustring.hxx:1701
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:103
bool equalsAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform a comparison of two strings.
Definition: ustring.hxx:1269
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_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_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.
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:113
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.
Definition: stringutils.hxx:146
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don&#39;t use, it&#39;s evil.") void doit(int nPara);.
Definition: types.h:474
sal_Int32 compareTo(const OUString &str) const
Compares two strings.
Definition: ustring.hxx:874
#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_toInt32(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an integer.
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:2909
sal_Int32 lastIndexOf(const OUString &str, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified substring, searching backward starting before the specified index.
Definition: ustring.hxx:2126
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_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T1, typename libreoffice_internal::ConstCharArrayDetector< T2, OUString >::Type >::Type replaceAll(T1 &from, T2 &to) const
Returns a new string resulting from replacing all occurrences of a given substring with another subst...
Definition: ustring.hxx:2627
sal_Int32 compareToIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1030
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 float rtl_ustr_toFloat(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a float.
SAL_DLLPUBLIC void rtl_uString_acquire(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Increment the reference count of a string.
OUString getToken(sal_Int32 token, sal_Unicode cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: ustring.hxx:2719
bool convertToString(OString *pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) const
Converts to an OString, signalling failure.
Definition: ustring.hxx:2947
#define RTL_USTR_MAX_VALUEOFDOUBLE
Definition: ustring.h:1045
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_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:2651
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_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: ustring.hxx:2778
#define RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR
Definition: textcvt.h:151
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:2201
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_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:2600
sal_uInt16 sal_Unicode
Definition: types.h:123
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.
SAL_DLLPUBLIC void rtl_uString_newFromLiteral(rtl_uString **newStr, const char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
unsigned char sal_Bool
Definition: types.h:38
static OUString createFromAscii(const char *value)
Returns an OUString copied without conversion from an ASCII character string.
Definition: ustring.hxx:3317
sal_Int32 compareTo(const OUString &str, sal_Int32 maxLength) const
Compares two strings with a maximum count of characters.
Definition: ustring.hxx:903
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:2668
__sal_NoAcquire
Definition: types.h:352
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Decrement the reference count of a string.
Like sprintf() G, &#39;F&#39; or &#39;E&#39; format is used depending on which one is more compact.
Definition: math.h:53
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:2060
A helper to use OUStrings with hash maps.
Definition: ustring.hxx:3438
static OUString number(float f)
Returns the string representation of the float argument.
Definition: ustring.hxx:3157
sal_Int32 compareToAscii(const char *asciiStr) const
Compares two strings.
Definition: ustring.hxx:1173
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:2179
SAL_DLLPUBLIC sal_Bool rtl_ustr_toBoolean(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
#define RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR
Definition: textcvt.h:75
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:2560
bool equalsIgnoreAsciiCaseAscii(const char *asciiStr) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1296
sal_Int32 indexOf(sal_Unicode ch, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.
Definition: ustring.hxx:1953
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 rtl_uString * rtl_uString_alloc(sal_Int32 nLen) SAL_THROW_EXTERN_C()
Allocate a new string containing space for a given number of characters.
OUString(rtl_uString *str)
New string from OUString data.
Definition: ustring.hxx:244
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.
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 ...
Definition: ustring.hxx:1611
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_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:37
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.
bool matchAsciiL(const char *asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:1392
#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:145
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.
Definition: bootstrap.hxx:33
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:2317
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...
bool equalsIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:998
bool match(const OUString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:1081
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:2448
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_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.
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1856
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: ustring.hxx:2795
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.
bool equals(const OUString &str) const
Perform a comparison of two strings.
Definition: ustring.hxx:962
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 sal_Int32 rtl_ustr_ascii_compare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second) SAL_THROW_EXTERN_C()
Compare two strings.
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:1429
static OUString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: ustring.hxx:3109
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.
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition: ustring.hxx:687
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:191
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:170
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:614
definition of a no acquire enum for ctors
Definition: types.h:356
~OUString()
Release the string data.
Definition: ustring.hxx:531
OString toUtf8() const
Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully.
Definition: ustring.hxx:3059
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:450
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:2399
#define SAL_N_ELEMENTS(arr)
Definition: macros.h:51
sal_Int32 lastIndexOf(const OUString &str) const
Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the end.
Definition: ustring.hxx:2097
bool endsWithAsciiL(char const *asciiStr, sal_Int32 asciiStrLength) const
Check whether this string ends with a given ASCII string.
Definition: ustring.hxx:1644
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 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_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...
OUString(rtl_uString *str, __sal_NoAcquire)
New OUString from OUString data without acquiring it.
Definition: ustring.hxx:265
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...
static OUString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: ustring.hxx:3225
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_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.
OUString(const sal_Unicode *value)
New string from a Unicode character buffer array.
Definition: ustring.hxx:314
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_Int32 oslInterlockedCount
Definition: interlck.h:44
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 sal_Int32 rtl_ustr_getLength(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Return the length of a string.
sal_Int32 lastIndexOf(sal_Unicode ch) const
Returns the index within this string of the last occurrence of the specified character, searching backward starting at the end.
Definition: ustring.hxx:1968
OUString(const OUString &str)
New string from OUString.
Definition: ustring.hxx:194
Definition: stringutils.hxx:148
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:2168
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_valueOfInt64(sal_Unicode *str, sal_Int64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of a long integer.
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:2287
bool equalsIgnoreAsciiCaseAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1364
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.
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:826
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_WARN_UNUSED_RESULT OUString trim() const
Returns a new string resulting from removing white space from both ends of the string.
Definition: ustring.hxx:2688
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:1531
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:284
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: ustring.hxx:2810
OUString(const sal_Unicode *value, sal_Int32 length)
New string from a Unicode character buffer array.
Definition: ustring.hxx:330
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.
OUString & operator=(const OUString &str)
Assign a new string.
Definition: ustring.hxx:581
#define RTL_USTR_MAX_VALUEOFBOOLEAN
Definition: ustring.h:919
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.
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:352
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.
size_t operator()(const OUString &rString) const
Compute a hash code for a string.
Definition: ustring.hxx:3449
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T1, typename libreoffice_internal::ConstCharArrayDetector< T2, OUString >::Type >::Type replaceFirst(T1 &from, T2 &to, sal_Int32 *index=NULL) const
Returns a new string resulting from replacing the first occurrence of a given substring with another ...
Definition: ustring.hxx:2483
sal_Int32 compareToIgnoreAsciiCaseAscii(const char *asciiStr) const
Compares two ASCII strings ignoring case.
Definition: ustring.hxx:1328
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...
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 ...
Definition: ustring.hxx:2139
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 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.
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:1683
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:3134
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1840
bool endsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string ends with a given substring.
Definition: ustring.hxx:1594
#define RTL_USTR_MAX_VALUEOFINT32
Definition: ustring.h:961
SAL_DLLPUBLIC double rtl_ustr_toDouble(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a double.
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...
float toFloat() const
Returns the float value from this string.
Definition: ustring.hxx:2840
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: ustring.hxx:803
#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
Definition: textcvt.h:72
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.
OUString intern() const
Return a canonical representation for a string.
Definition: ustring.hxx:2874
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:3122
#define RTL_USTR_MAX_VALUEOFINT64
Definition: ustring.h:984
static OUString number(double d)
Returns the string representation of the double argument.
Definition: ustring.hxx:3179
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1872
OUString(sal_uInt32 const *codePoints, sal_Int32 codePointCount)
Create a new string from an array of Unicode code points.
Definition: ustring.hxx:477
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:2354
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:3128
OUString getToken(sal_Int32 count, sal_Unicode separator) const
Returns a token from the string.
Definition: ustring.hxx:2739
sal_Int32 reverseCompareTo(const OUString &str) const
Compares two strings in reverse order.
Definition: ustring.hxx:928
OUString(sal_Unicode value)
New string from a single Unicode character.
Definition: ustring.hxx:273
sal_Int32 lastIndexOf(sal_Unicode ch, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified character, searching backward starting before the specified index.
Definition: ustring.hxx:1985
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:1735
bool toBoolean() const
Returns the Boolean value from this string.
Definition: ustring.hxx:2752
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.
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: ustring.hxx:1935