LibreOffice
LibreOffice 7.4 SDK C/C++ API Reference
ustring.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 /*
21  * This file is part of LibreOffice published API.
22  */
23 
24 #ifndef INCLUDED_RTL_USTRING_HXX
25 #define INCLUDED_RTL_USTRING_HXX
26 
27 #include "sal/config.h"
28 
29 #include <cassert>
30 #include <cstddef>
31 #include <cstdlib>
32 #include <limits>
33 #include <new>
34 #include <ostream>
35 #include <utility>
36 
37 #if defined LIBO_INTERNAL_ONLY
38 #include <string_view>
39 #include <type_traits>
40 #endif
41 
42 #include "rtl/ustring.h"
43 #include "rtl/string.hxx"
44 #include "rtl/stringutils.hxx"
45 #include "rtl/textenc.h"
46 
47 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
48 #include "config_global.h"
49 #include "rtl/stringconcat.hxx"
50 #endif
51 
52 #ifdef RTL_STRING_UNITTEST
53 extern bool rtl_string_unittest_invalid_conversion;
54 #endif
55 
56 // The unittest uses slightly different code to help check that the proper
57 // calls are made. The class is put into a different namespace to make
58 // sure the compiler generates a different (if generating also non-inline)
59 // copy of the function and does not merge them together. The class
60 // is "brought" into the proper rtl namespace by a typedef below.
61 #ifdef RTL_STRING_UNITTEST
62 #define rtl rtlunittest
63 #endif
64 
65 namespace rtl
66 {
67 
68 class OUStringBuffer;
69 
70 #ifdef RTL_STRING_UNITTEST
71 #undef rtl
72 #endif
73 
74 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
76 
83 template<std::size_t N> class SAL_WARN_UNUSED OUStringLiteral {
84  static_assert(N != 0);
85  static_assert(N - 1 <= std::numeric_limits<sal_Int32>::max(), "literal too long");
86  friend class OUString;
87  friend class OUStringConstExpr;
88 
89 public:
90 #if HAVE_CPP_CONSTEVAL
91  consteval
92 #else
93  constexpr
94 #endif
95  OUStringLiteral(char16_t const (&literal)[N]) {
96  assertLayout();
97  assert(literal[N - 1] == '\0');
98  //TODO: Use C++20 constexpr std::copy_n (P0202R3):
99  for (std::size_t i = 0; i != N; ++i) {
100  more.buffer[i] = literal[i];
101  }
102  }
103 
104  constexpr sal_Int32 getLength() const { return more.length; }
105 
106  constexpr sal_Unicode const * getStr() const SAL_RETURNS_NONNULL { return more.buffer; }
107 
108  constexpr operator std::u16string_view() const { return {more.buffer, sal_uInt32(more.length)}; }
109 
110 private:
111  static constexpr void assertLayout() {
112  // These static_asserts verifying the layout compatibility with rtl_uString cannot be class
113  // member declarations, as offsetof requires a complete type, so defer them to here:
114  static_assert(std::is_standard_layout_v<OUStringLiteral>);
115  static_assert(offsetof(OUStringLiteral, str.refCount) == offsetof(OUStringLiteral, more.refCount));
116  static_assert(offsetof(OUStringLiteral, str.length) == offsetof(OUStringLiteral, more.length));
117  static_assert(offsetof(OUStringLiteral, str.buffer) == offsetof(OUStringLiteral, more.buffer));
118  }
119 
120  struct Data {
121  Data() = default;
122 
123  oslInterlockedCount refCount = 0x40000000; // SAL_STRING_STATIC_FLAG (sal/rtl/strimp.hxx)
124  sal_Int32 length = N - 1;
125  sal_Unicode buffer[N] = {}; //TODO: drop initialization for C++20 (P1331R2)
126  };
127 
128  union {
129  rtl_uString str;
130  Data more = {};
131  };
132 };
133 
134 #if defined RTL_STRING_UNITTEST
135 namespace libreoffice_internal {
136 template<std::size_t N> struct ExceptConstCharArrayDetector<OUStringLiteral<N>> {};
137 template<std::size_t N> struct ExceptCharArrayDetector<OUStringLiteral<N>> {};
138 }
139 #endif
140 
149 class OUString;
150 class OUStringConstExpr
151 {
152 public:
153  template<std::size_t N> constexpr OUStringConstExpr(OUStringLiteral<N> const & literal):
154  pData(const_cast<rtl_uString *>(&literal.str)) {}
155 
156  // prevent mis-use
157  template<std::size_t N> constexpr OUStringConstExpr(OUStringLiteral<N> && literal)
158  = delete;
159 
160  // no destructor necessary because we know we are pointing at a compile-time
161  // constant OUStringLiteral, which bypasses ref-counting.
162 
166  constexpr std::u16string_view asView() const { return {pData->buffer, static_cast<sal_uInt32>(pData->length)}; }
167 
168  inline operator const OUString&() const;
169 
170 private:
171  rtl_uString* pData;
172 };
173 
175 #endif
176 
177 /* ======================================================================= */
178 
202 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OUString
203 {
204 public:
206  rtl_uString * pData;
208 
213  {
214  pData = NULL;
215  rtl_uString_new( &pData );
216  }
217 
223  OUString( const OUString & str )
224  {
225  pData = str.pData;
226  rtl_uString_acquire( pData );
227  }
228 
229 #if defined LIBO_INTERNAL_ONLY
236  OUString( OUString && str ) noexcept
237  {
238  pData = str.pData;
239  str.pData = nullptr;
240  rtl_uString_new( &str.pData );
241  }
242 #endif
243 
249  OUString( rtl_uString * str )
250  {
251  pData = str;
252  rtl_uString_acquire( pData );
253  }
254 
263  OUString( rtl_uString * str, __sal_NoAcquire )
264  { pData = str; }
265 
271  explicit OUString( sal_Unicode value )
272  : pData (NULL)
273  {
274  rtl_uString_newFromStr_WithLength( &pData, &value, 1 );
275  }
276 
277 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
279  // Catch inadvertent conversions to the above ctor (but still allow
280  // construction from char literals):
281  OUString(int) = delete;
282  explicit OUString(char c):
283  OUString(sal_Unicode(static_cast<unsigned char>(c)))
284  {}
286 #endif
287 
288 #if defined LIBO_INTERNAL_ONLY
289 
290  template<typename T> explicit OUString(
291  T const & value,
292  typename libreoffice_internal::CharPtrDetector<T, libreoffice_internal::Dummy>::TypeUtf16
293  = libreoffice_internal::Dummy()):
294  pData(nullptr)
295  { rtl_uString_newFromStr(&pData, value); }
296 
297  template<typename T> explicit OUString(
298  T & value,
299  typename
300  libreoffice_internal::NonConstCharArrayDetector<T, libreoffice_internal::Dummy>::TypeUtf16
301  = libreoffice_internal::Dummy()):
302  pData(nullptr)
303  { rtl_uString_newFromStr(&pData, value); }
304 
305 #else
306 
312  OUString( const sal_Unicode * value )
313  {
314  pData = NULL;
315  rtl_uString_newFromStr( &pData, value );
316  }
317 
318 #endif
319 
328  OUString( const sal_Unicode * value, sal_Int32 length )
329  {
330  pData = NULL;
331  rtl_uString_newFromStr_WithLength( &pData, value, length );
332  }
333 
349  template< typename T >
351  {
352  assert(
354  pData = NULL;
356  rtl_uString_new(&pData);
357  } else {
359  &pData,
361  literal),
363  }
364 #ifdef RTL_STRING_UNITTEST
365  rtl_string_unittest_const_literal = true;
366 #endif
367  }
368 
369 #if defined LIBO_INTERNAL_ONLY
371  template<typename T> OUString(
372  T & literal,
374  T, libreoffice_internal::Dummy>::TypeUtf16
376  pData(nullptr)
377  {
378  assert(
381  rtl_uString_new(&pData);
382  } else {
384  &pData,
385  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
386  literal),
387  libreoffice_internal::ConstCharArrayDetector<T>::length);
388  }
389  }
390 #endif
391 
392 #if defined LIBO_INTERNAL_ONLY && defined RTL_STRING_UNITTEST
394 
398  template< typename T >
399  OUString( T&, typename libreoffice_internal::ExceptConstCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
400  {
401  pData = NULL;
402  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
403  rtl_string_unittest_invalid_conversion = true;
404  }
409  template< typename T >
410  OUString( const T&, typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
411  {
412  pData = NULL;
413  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
414  rtl_string_unittest_invalid_conversion = true;
415  }
417 #endif
418 
419 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
421 
426  template<std::size_t N> constexpr OUString(OUStringLiteral<N> const & literal):
427  pData(const_cast<rtl_uString *>(&literal.str)) {}
428  template<std::size_t N> OUString(OUStringLiteral<N> &&) = delete;
430 #endif
431 
446  OUString( const char * value, sal_Int32 length,
447  rtl_TextEncoding encoding,
448  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
449  {
450  pData = NULL;
451  rtl_string2UString( &pData, value, length, encoding, convertFlags );
452  if (pData == NULL) {
453  throw std::bad_alloc();
454  }
455  }
456 
473  explicit OUString(
474  sal_uInt32 const * codePoints, sal_Int32 codePointCount):
475  pData(NULL)
476  {
477  rtl_uString_newFromCodePoints(&pData, codePoints, codePointCount);
478  if (pData == NULL) {
479  throw std::bad_alloc();
480  }
481  }
482 
483 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
488  template< typename T1, typename T2 >
489  OUString( OUStringConcat< T1, T2 >&& c )
490  {
491  const sal_Int32 l = c.length();
492  pData = rtl_uString_alloc( l );
493  if (l != 0)
494  {
495  sal_Unicode* end = c.addData( pData->buffer );
496  pData->length = l;
497  *end = '\0';
498  }
499  }
500 
505  template< typename T >
506  OUString( OUStringNumber< T >&& n )
507  : OUString( n.buf, n.length )
508  {}
509 #endif
510 
511 #if defined LIBO_INTERNAL_ONLY
512  explicit OUString(std::u16string_view sv) {
513  if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
514  throw std::bad_alloc();
515  }
516  pData = nullptr;
517  rtl_uString_newFromStr_WithLength(&pData, sv.data(), sv.size());
518  }
519 #endif
520 
525  {
526  rtl_uString_release( pData );
527  }
528 
540  static OUString const & unacquired( rtl_uString * const * ppHandle )
541  { return * reinterpret_cast< OUString const * >( ppHandle ); }
542 
543 #if defined LIBO_INTERNAL_ONLY
556  static OUString const& unacquired(const OUStringBuffer& str);
557 #endif
558 
564  OUString & operator=( const OUString & str )
565  {
566  rtl_uString_assign( &pData, str.pData );
567  return *this;
568  }
569 
570 #if defined LIBO_INTERNAL_ONLY
577  OUString & operator=( OUString && str ) noexcept
578  {
579  rtl_uString_release( pData );
580  pData = str.pData;
581  str.pData = nullptr;
582  rtl_uString_new( &str.pData );
583  return *this;
584  }
585 #endif
586 
599  template< typename T >
601  {
602  assert(
605  rtl_uString_new(&pData);
606  } else {
608  &pData,
610  literal),
612  }
613  return *this;
614  }
615 
616 #if defined LIBO_INTERNAL_ONLY
618  template<typename T>
619  typename
621  operator =(T & literal) {
623  rtl_uString_new(&pData);
624  } else {
626  &pData,
627  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
628  literal),
629  libreoffice_internal::ConstCharArrayDetector<T>::length);
630  }
631  return *this;
632  }
633 
635  template<std::size_t N> OUString & operator =(OUStringLiteral<N> const & literal) {
636  rtl_uString_release(pData);
637  pData = const_cast<rtl_uString *>(&literal.str);
638  return *this;
639  }
640  template<std::size_t N> OUString & operator =(OUStringLiteral<N> &&) = delete;
641 
642  template<typename T>
643  OUString & operator =(OUStringNumber<T> && n) {
644  // n.length should never be zero, so no need to add an optimization for that case
645  rtl_uString_newFromStr_WithLength(&pData, n.buf, n.length);
646  return *this;
647  }
648 
649  OUString & operator =(std::u16string_view sv) {
650  if (sv.empty()) {
651  rtl_uString_new(&pData);
652  } else {
653  rtl_uString_newFromStr_WithLength(&pData, sv.data(), sv.size());
654  }
655  return *this;
656  }
657 #endif
658 
659 #if defined LIBO_INTERNAL_ONLY
668  inline OUString & operator+=( const OUStringBuffer & str ) &;
669 #endif
670 
678  OUString & operator+=( const OUString & str )
679 #if defined LIBO_INTERNAL_ONLY
680  &
681 #endif
682  {
683  return internalAppend(str.pData);
684  }
685 #if defined LIBO_INTERNAL_ONLY
686  void operator+=(OUString const &) && = delete;
687 #endif
688 
695  template<typename T>
697  operator +=(T & literal)
698 #if defined LIBO_INTERNAL_ONLY
699  &
700 #endif
701  {
702  assert(
705  &pData, pData,
708  return *this;
709  }
710 #if defined LIBO_INTERNAL_ONLY
711  template<typename T>
713  operator +=(T &) && = delete;
714 #endif
715 
716 #if defined LIBO_INTERNAL_ONLY
718  template<typename T>
719  typename
721  operator +=(T & literal) & {
723  &pData, pData,
726  return *this;
727  }
728  template<typename T>
729  typename
730  libreoffice_internal::ConstCharArrayDetector<T, OUString &>::TypeUtf16
731  operator +=(T &) && = delete;
732 
734  template<std::size_t N> OUString & operator +=(OUStringLiteral<N> const & literal) & {
735  rtl_uString_newConcatUtf16L(&pData, pData, literal.getStr(), literal.getLength());
736  return *this;
737  }
738  template<std::size_t N> void operator +=(OUStringLiteral<N> const &) && = delete;
739 
740  OUString & operator +=(std::u16string_view sv) & {
741  if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
742  throw std::bad_alloc();
743  }
744  rtl_uString_newConcatUtf16L(&pData, pData, sv.data(), sv.size());
745  return *this;
746  }
747  void operator +=(std::u16string_view) && = delete;
748 #endif
749 
750 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
755  template< typename T1, typename T2 >
756  OUString& operator+=( OUStringConcat< T1, T2 >&& c ) & {
757  sal_Int32 l = c.length();
758  if( l == 0 )
759  return *this;
760  l += pData->length;
761  rtl_uString_ensureCapacity( &pData, l );
762  sal_Unicode* end = c.addData( pData->buffer + pData->length );
763  *end = '\0';
764  pData->length = l;
765  return *this;
766  }
767  template<typename T1, typename T2> void operator +=(
768  OUStringConcat<T1, T2> &&) && = delete;
769 
774  template< typename T >
775  OUString& operator+=( OUStringNumber< T >&& n ) & {
776  sal_Int32 l = n.length;
777  if( l == 0 )
778  return *this;
779  l += pData->length;
780  rtl_uString_ensureCapacity( &pData, l );
781  sal_Unicode* end = addDataHelper( pData->buffer + pData->length, n.buf, n.length );
782  *end = '\0';
783  pData->length = l;
784  return *this;
785  }
786  template<typename T> void operator +=(
787  OUStringNumber<T> &&) && = delete;
788 #endif
789 
794  void clear()
795  {
796  rtl_uString_new( &pData );
797  }
798 
807  sal_Int32 getLength() const { return pData->length; }
808 
817  bool isEmpty() const
818  {
819  return pData->length == 0;
820  }
821 
829  const sal_Unicode * getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
830 
840  sal_Unicode operator [](sal_Int32 index) const {
841  // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
842  assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
843  return getStr()[index];
844  }
845 
858 #if defined LIBO_INTERNAL_ONLY
859  sal_Int32 compareTo( std::u16string_view str ) const
860  {
861  return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
862  str.data(), str.length() );
863  }
864 #else
865  sal_Int32 compareTo( const OUString & str ) const
866  {
867  return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
868  str.pData->buffer, str.pData->length );
869  }
870 #endif
871 
887 #if defined LIBO_INTERNAL_ONLY
888  sal_Int32 compareTo( std::u16string_view str, sal_Int32 maxLength ) const
889  {
890  return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
891  str.data(), str.length(), maxLength );
892  }
893 #else
894  sal_Int32 compareTo( const OUString & str, sal_Int32 maxLength ) const
895  {
896  return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
897  str.pData->buffer, str.pData->length, maxLength );
898  }
899 #endif
900 
913 #if defined LIBO_INTERNAL_ONLY
914  sal_Int32 reverseCompareTo(std::u16string_view sv) const {
916  pData->buffer, pData->length, sv.data(), sv.size());
917  }
918 #else
919  sal_Int32 reverseCompareTo( const OUString & str ) const
920  {
921  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
922  str.pData->buffer, str.pData->length );
923  }
924 #endif
925 
931  template< typename T >
933  {
934  assert(
937  pData->buffer, pData->length,
940  }
941 
953  bool equals( const OUString & str ) const
954  {
955  if ( pData->length != str.pData->length )
956  return false;
957  if ( pData == str.pData )
958  return true;
959  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
960  str.pData->buffer, str.pData->length ) == 0;
961  }
962 
977 #if defined LIBO_INTERNAL_ONLY
978  bool equalsIgnoreAsciiCase(std::u16string_view sv) const {
979  if ( sal_uInt32(pData->length) != sv.size() )
980  return false;
981  if ( pData->buffer == sv.data() )
982  return true;
983  return
985  pData->buffer, pData->length, sv.data(), sv.size())
986  == 0;
987  }
988 #else
989  bool equalsIgnoreAsciiCase( const OUString & str ) const
990  {
991  if ( pData->length != str.pData->length )
992  return false;
993  if ( pData == str.pData )
994  return true;
995  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
996  str.pData->buffer, str.pData->length ) == 0;
997  }
998 #endif
999 
1015 #if defined LIBO_INTERNAL_ONLY
1016  sal_Int32 compareToIgnoreAsciiCase(std::u16string_view sv) const {
1018  pData->buffer, pData->length, sv.data(), sv.size());
1019  }
1020 #else
1021  sal_Int32 compareToIgnoreAsciiCase( const OUString & str ) const
1022  {
1023  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
1024  str.pData->buffer, str.pData->length );
1025  }
1026 #endif
1027 
1033  template< typename T >
1035  {
1036  assert(
1038  return
1039  (pData->length
1042  pData->buffer, pData->length,
1044  literal))
1045  == 0);
1046  }
1047 
1063 #if defined LIBO_INTERNAL_ONLY
1064  bool match(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
1065  return
1067  pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1068  sv.size())
1069  == 0;
1070  }
1071 #else
1072  bool match( const OUString & str, sal_Int32 fromIndex = 0 ) const
1073  {
1074  return rtl_ustr_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1075  str.pData->buffer, str.pData->length, str.pData->length ) == 0;
1076  }
1077 #endif
1078 
1084  template< typename T >
1085  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
1086  {
1087  assert(
1089  return
1091  pData->buffer+fromIndex, pData->length-fromIndex,
1093  literal),
1095  == 0;
1096  }
1097 
1116 #if defined LIBO_INTERNAL_ONLY
1117  bool matchIgnoreAsciiCase(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
1118  return
1120  pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1121  sv.size())
1122  == 0;
1123  }
1124 #else
1125  bool matchIgnoreAsciiCase( const OUString & str, sal_Int32 fromIndex = 0 ) const
1126  {
1127  return rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1128  str.pData->buffer, str.pData->length,
1129  str.pData->length ) == 0;
1130  }
1131 #endif
1132 
1138  template< typename T >
1139  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
1140  {
1141  assert(
1143  return matchIgnoreAsciiCaseAsciiL(
1146  }
1147 
1164  sal_Int32 compareToAscii( const char* asciiStr ) const
1165  {
1166  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length, asciiStr );
1167  }
1168 
1192  "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
1193  sal_Int32 compareToAscii( const char * asciiStr, sal_Int32 maxLength ) const
1194  {
1195  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer, pData->length,
1196  asciiStr, maxLength );
1197  }
1198 
1218  sal_Int32 reverseCompareToAsciiL( const char * asciiStr, sal_Int32 asciiStrLength ) const
1219  {
1220  return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
1221  asciiStr, asciiStrLength );
1222  }
1223 
1239  bool equalsAscii( const char* asciiStr ) const
1240  {
1241  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length,
1242  asciiStr ) == 0;
1243  }
1244 
1262  bool equalsAsciiL( const char* asciiStr, sal_Int32 asciiStrLength ) const
1263  {
1264  if ( pData->length != asciiStrLength )
1265  return false;
1266 
1268  pData->buffer, asciiStr, asciiStrLength );
1269  }
1270 
1289  bool equalsIgnoreAsciiCaseAscii( const char * asciiStr ) const
1290  {
1291  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1292  }
1293 
1312  sal_Int32 compareToIgnoreAsciiCaseAscii( const char * asciiStr ) const
1313  {
1314  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr );
1315  }
1316 
1337  bool equalsIgnoreAsciiCaseAsciiL( const char * asciiStr, sal_Int32 asciiStrLength ) const
1338  {
1339  if ( pData->length != asciiStrLength )
1340  return false;
1341 
1342  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1343  }
1344 
1366  bool matchAsciiL( const char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1367  {
1368  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1369  asciiStr, asciiStrLength ) == 0;
1370  }
1371 
1372  // This overload is left undefined, to detect calls of matchAsciiL that
1373  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1374  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1375  // platforms):
1376 #if SAL_TYPES_SIZEOFLONG == 8
1377  void matchAsciiL(char const *, sal_Int32, rtl_TextEncoding) const;
1378 #endif
1379 
1404  bool matchIgnoreAsciiCaseAsciiL( const char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1405  {
1406  return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1407  asciiStr, asciiStrLength ) == 0;
1408  }
1409 
1410  // This overload is left undefined, to detect calls of
1411  // matchIgnoreAsciiCaseAsciiL that erroneously use
1412  // RTL_CONSTASCII_USTRINGPARAM instead of RTL_CONSTASCII_STRINGPARAM (but
1413  // would lead to ambiguities on 32 bit platforms):
1414 #if SAL_TYPES_SIZEOFLONG == 8
1415  void matchIgnoreAsciiCaseAsciiL(char const *, sal_Int32, rtl_TextEncoding)
1416  const;
1417 #endif
1418 
1433 #if defined LIBO_INTERNAL_ONLY
1434  bool startsWith(std::u16string_view sv, OUString * rest = nullptr) const {
1435  auto const b = match(sv);
1436  if (b && rest != nullptr) {
1437  *rest = copy(sv.size());
1438  }
1439  return b;
1440  }
1441 #else
1442  bool startsWith(OUString const & str, OUString * rest = NULL) const {
1443  bool b = match(str);
1444  if (b && rest != NULL) {
1445  *rest = copy(str.getLength());
1446  }
1447  return b;
1448  }
1449 #endif
1450 
1456  template< typename T >
1458  T & literal, OUString * rest = NULL) const
1459  {
1460  assert(
1462  bool b
1464  <= sal_uInt32(pData->length))
1466  pData->buffer,
1468  literal),
1470  if (b && rest != NULL) {
1471  *rest = copy(
1473  }
1474  return b;
1475  }
1476 
1497 #if defined LIBO_INTERNAL_ONLY
1498  bool startsWithIgnoreAsciiCase(std::u16string_view sv, OUString * rest = nullptr) const {
1499  auto const b = matchIgnoreAsciiCase(sv);
1500  if (b && rest != nullptr) {
1501  *rest = copy(sv.size());
1502  }
1503  return b;
1504  }
1505 #else
1506  bool startsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL)
1507  const
1508  {
1509  bool b = matchIgnoreAsciiCase(str);
1510  if (b && rest != NULL) {
1511  *rest = copy(str.getLength());
1512  }
1513  return b;
1514  }
1515 #endif
1516 
1522  template< typename T >
1524  startsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1525  {
1526  assert(
1528  bool b
1530  <= sal_uInt32(pData->length))
1532  pData->buffer,
1535  literal),
1537  == 0);
1538  if (b && rest != NULL) {
1539  *rest = copy(
1541  }
1542  return b;
1543  }
1544 
1559 #if defined LIBO_INTERNAL_ONLY
1560  bool endsWith(std::u16string_view sv, OUString * rest = nullptr) const {
1561  auto const b = sv.size() <= sal_uInt32(pData->length)
1562  && match(sv, pData->length - sv.size());
1563  if (b && rest != nullptr) {
1564  *rest = copy(0, (pData->length - sv.size()));
1565  }
1566  return b;
1567  }
1568 #else
1569  bool endsWith(OUString const & str, OUString * rest = NULL) const {
1570  bool b = str.getLength() <= getLength()
1571  && match(str, getLength() - str.getLength());
1572  if (b && rest != NULL) {
1573  *rest = copy(0, getLength() - str.getLength());
1574  }
1575  return b;
1576  }
1577 #endif
1578 
1584  template< typename T >
1586  endsWith(T & literal, OUString * rest = NULL) const
1587  {
1588  assert(
1590  bool b
1592  <= sal_uInt32(pData->length))
1594  (pData->buffer + pData->length
1597  literal),
1599  if (b && rest != NULL) {
1600  *rest = copy(
1601  0,
1602  (getLength()
1604  }
1605  return b;
1606  }
1607 
1619  bool endsWithAsciiL(char const * asciiStr, sal_Int32 asciiStrLength)
1620  const
1621  {
1622  return asciiStrLength <= pData->length
1624  pData->buffer + pData->length - asciiStrLength, asciiStr,
1625  asciiStrLength);
1626  }
1627 
1648 #if defined LIBO_INTERNAL_ONLY
1649  bool endsWithIgnoreAsciiCase(std::u16string_view sv, OUString * rest = nullptr) const {
1650  auto const b = sv.size() <= sal_uInt32(pData->length)
1651  && matchIgnoreAsciiCase(sv, pData->length - sv.size());
1652  if (b && rest != nullptr) {
1653  *rest = copy(0, pData->length - sv.size());
1654  }
1655  return b;
1656  }
1657 #else
1658  bool endsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL) const
1659  {
1660  bool b = str.getLength() <= getLength()
1661  && matchIgnoreAsciiCase(str, getLength() - str.getLength());
1662  if (b && rest != NULL) {
1663  *rest = copy(0, getLength() - str.getLength());
1664  }
1665  return b;
1666  }
1667 #endif
1668 
1674  template< typename T >
1676  endsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1677  {
1678  assert(
1680  bool b
1682  <= sal_uInt32(pData->length))
1684  (pData->buffer + pData->length
1688  literal),
1690  == 0);
1691  if (b && rest != NULL) {
1692  *rest = copy(
1693  0,
1694  (getLength()
1696  }
1697  return b;
1698  }
1699 
1711  char const * asciiStr, sal_Int32 asciiStrLength) const
1712  {
1713  return asciiStrLength <= pData->length
1715  pData->buffer + pData->length - asciiStrLength,
1716  asciiStrLength, asciiStr, asciiStrLength)
1717  == 0);
1718  }
1719 
1720  friend bool operator == ( const OUString& rStr1, const OUString& rStr2 )
1721  { return rStr1.equals(rStr2); }
1722 
1723  friend bool operator != ( const OUString& rStr1, const OUString& rStr2 )
1724  { return !(operator == ( rStr1, rStr2 )); }
1725 
1726  friend bool operator < ( const OUString& rStr1, const OUString& rStr2 )
1727  { return rStr1.compareTo( rStr2 ) < 0; }
1728  friend bool operator > ( const OUString& rStr1, const OUString& rStr2 )
1729  { return rStr1.compareTo( rStr2 ) > 0; }
1730  friend bool operator <= ( const OUString& rStr1, const OUString& rStr2 )
1731  { return rStr1.compareTo( rStr2 ) <= 0; }
1732  friend bool operator >= ( const OUString& rStr1, const OUString& rStr2 )
1733  { return rStr1.compareTo( rStr2 ) >= 0; }
1734 
1735 #if defined LIBO_INTERNAL_ONLY
1736 
1737  template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1738  operator ==(OUString const & s1, T const & s2) {
1740  == 0;
1741  }
1742 
1743  template<typename T>
1744  friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1745  operator ==(OUString const & s1, T & s2) {
1746  return rtl_ustr_compare_WithLength(s1.getStr(), s1.getLength(), s2, rtl_ustr_getLength(s2))
1747  == 0;
1748  }
1749 
1750  template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1751  operator ==(T const & s1, OUString const & s2) {
1752  return rtl_ustr_compare_WithLength(s1, rtl_ustr_getLength(s1), s2.getStr(), s2.getLength())
1753  == 0;
1754  }
1755 
1756  template<typename T>
1757  friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1758  operator ==(T & s1, OUString const & s2) {
1759  return rtl_ustr_compare_WithLength(s1, rtl_ustr_getLength(s1), s2.getStr(), s2.getLength())
1760  == 0;
1761  }
1762 
1763  template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1764  operator !=(OUString const & s1, T const & s2) { return !(s1 == s2); }
1765 
1766  template<typename T>
1767  friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1768  operator !=(OUString const & s1, T & s2) { return !(s1 == s2); }
1769 
1770  template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1771  operator !=(T const & s1, OUString const & s2) { return !(s1 == s2); }
1772 
1773  template<typename T>
1774  friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1775  operator !=(T & s1, OUString const & s2) { return !(s1 == s2); }
1776 
1777 #else
1778 
1779  friend bool operator == ( const OUString& rStr1, const sal_Unicode * pStr2 )
1780  { return rStr1.compareTo( pStr2 ) == 0; }
1781  friend bool operator == ( const sal_Unicode * pStr1, const OUString& rStr2 )
1782  { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
1783 
1784  friend bool operator != ( const OUString& rStr1, const sal_Unicode * pStr2 )
1785  { return !(operator == ( rStr1, pStr2 )); }
1786  friend bool operator != ( const sal_Unicode * pStr1, const OUString& rStr2 )
1787  { return !(operator == ( pStr1, rStr2 )); }
1788 
1789 #endif
1790 
1798  template< typename T >
1800  {
1801  assert(
1803  return rString.equalsAsciiL(
1806  }
1814  template< typename T >
1816  {
1817  assert(
1819  return rString.equalsAsciiL(
1822  }
1830  template< typename T >
1832  {
1833  assert(
1835  return !rString.equalsAsciiL(
1838  }
1846  template< typename T >
1848  {
1849  assert(
1851  return !rString.equalsAsciiL(
1854  }
1855 
1856 #if defined LIBO_INTERNAL_ONLY
1858  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1859  operator ==(OUString const & string, T & literal) {
1860  return
1862  string.pData->buffer, string.pData->length,
1864  literal),
1866  == 0;
1867  }
1869  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1870  operator ==(T & literal, OUString const & string) {
1871  return
1873  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1874  literal),
1875  libreoffice_internal::ConstCharArrayDetector<T>::length,
1876  string.pData->buffer, string.pData->length)
1877  == 0;
1878  }
1880  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1881  operator !=(OUString const & string, T & literal) {
1882  return
1884  string.pData->buffer, string.pData->length,
1885  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1886  literal),
1887  libreoffice_internal::ConstCharArrayDetector<T>::length)
1888  != 0;
1889  }
1891  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1892  operator !=(T & literal, OUString const & string) {
1893  return
1895  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1896  literal),
1897  libreoffice_internal::ConstCharArrayDetector<T>::length,
1898  string.pData->buffer, string.pData->length)
1899  != 0;
1900  }
1901 #endif
1902 
1910  sal_Int32 hashCode() const
1911  {
1912  return rtl_ustr_hashCode_WithLength( pData->buffer, pData->length );
1913  }
1914 
1928  sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
1929  {
1930  sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1931  return (ret < 0 ? ret : ret+fromIndex);
1932  }
1933 
1943  sal_Int32 lastIndexOf( sal_Unicode ch ) const
1944  {
1945  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1946  }
1947 
1960  sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
1961  {
1962  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1963  }
1964 
1980 #if defined LIBO_INTERNAL_ONLY
1981  sal_Int32 indexOf(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
1982  auto const n = rtl_ustr_indexOfStr_WithLength(
1983  pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size());
1984  return n < 0 ? n : n + fromIndex;
1985  }
1986 #else
1987  sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
1988  {
1989  sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1990  str.pData->buffer, str.pData->length );
1991  return (ret < 0 ? ret : ret+fromIndex);
1992  }
1993 #endif
1994 
2000  template< typename T >
2001  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
2002  {
2003  assert(
2005  sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
2006  pData->buffer + fromIndex, pData->length - fromIndex,
2009  return n < 0 ? n : n + fromIndex;
2010  }
2011 
2035  sal_Int32 indexOfAsciiL(
2036  char const * str, sal_Int32 len, sal_Int32 fromIndex = 0) const
2037  {
2038  sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
2039  pData->buffer + fromIndex, pData->length - fromIndex, str, len);
2040  return ret < 0 ? ret : ret + fromIndex;
2041  }
2042 
2043  // This overload is left undefined, to detect calls of indexOfAsciiL that
2044  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
2045  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
2046  // platforms):
2047 #if SAL_TYPES_SIZEOFLONG == 8
2048  void indexOfAsciiL(char const *, sal_Int32 len, rtl_TextEncoding) const;
2049 #endif
2050 
2066 #if defined LIBO_INTERNAL_ONLY
2067  sal_Int32 lastIndexOf(std::u16string_view sv) const {
2069  pData->buffer, pData->length, sv.data(), sv.size());
2070  }
2071 #else
2072  sal_Int32 lastIndexOf( const OUString & str ) const
2073  {
2074  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
2075  str.pData->buffer, str.pData->length );
2076  }
2077 #endif
2078 
2096 #if defined LIBO_INTERNAL_ONLY
2097  sal_Int32 lastIndexOf(std::u16string_view sv, sal_Int32 fromIndex) const {
2098  return rtl_ustr_lastIndexOfStr_WithLength(pData->buffer, fromIndex, sv.data(), sv.size());
2099  }
2100 #else
2101  sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
2102  {
2103  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
2104  str.pData->buffer, str.pData->length );
2105  }
2106 #endif
2107 
2113  template< typename T >
2115  {
2116  assert(
2119  pData->buffer, pData->length,
2122  }
2123 
2143  sal_Int32 lastIndexOfAsciiL(char const * str, sal_Int32 len) const
2144  {
2146  pData->buffer, pData->length, str, len);
2147  }
2148 
2159  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex ) const
2160  {
2161  return copy(beginIndex, getLength() - beginIndex);
2162  }
2163 
2176  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const
2177  {
2178  rtl_uString *pNew = NULL;
2179  rtl_uString_newFromSubString( &pNew, pData, beginIndex, count );
2180  return OUString( pNew, SAL_NO_ACQUIRE );
2181  }
2182 
2183 #if defined LIBO_INTERNAL_ONLY
2194  SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex ) const
2195  {
2196  assert(beginIndex >= 0);
2197  assert(beginIndex <= getLength());
2198  return subView(beginIndex, getLength() - beginIndex);
2199  }
2200 
2213  SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex, sal_Int32 count ) const
2214  {
2215  assert(beginIndex >= 0);
2216  assert(count >= 0);
2217  assert(beginIndex <= getLength());
2218  assert(count <= getLength() - beginIndex);
2219  return std::u16string_view(*this).substr(beginIndex, count);
2220  }
2221 #endif
2222 
2223 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2232  SAL_WARN_UNUSED_RESULT OUString concat( const OUString & str ) const
2233  {
2234  rtl_uString* pNew = NULL;
2235  rtl_uString_newConcat( &pNew, pData, str.pData );
2236  return OUString( pNew, SAL_NO_ACQUIRE );
2237  }
2238 #endif
2239 
2240 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2241  friend OUString operator+( const OUString& rStr1, const OUString& rStr2 )
2242  {
2243  return rStr1.concat( rStr2 );
2244  }
2245 #endif
2246 
2247 // hide this from internal code to avoid ambiguous lookup error
2248 #ifndef LIBO_INTERNAL_ONLY
2262  SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const
2263  {
2264  rtl_uString* pNew = NULL;
2265  rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
2266  return OUString( pNew, SAL_NO_ACQUIRE );
2267  }
2268 #endif
2269 
2270 #ifdef LIBO_INTERNAL_ONLY
2271  SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, std::u16string_view newStr ) const
2272  {
2273  rtl_uString* pNew = NULL;
2274  rtl_uString_newReplaceStrAtUtf16L( &pNew, pData, index, count, newStr.data(), newStr.size() );
2275  return OUString( pNew, SAL_NO_ACQUIRE );
2276  }
2277 #endif
2278 
2293  {
2294  rtl_uString* pNew = NULL;
2295  rtl_uString_newReplace( &pNew, pData, oldChar, newChar );
2296  return OUString( pNew, SAL_NO_ACQUIRE );
2297  }
2298 
2317 #if defined LIBO_INTERNAL_ONLY
2318  [[nodiscard]] OUString replaceFirst(
2319  std::u16string_view from, std::u16string_view to, sal_Int32 * index = nullptr) const
2320  {
2321  rtl_uString * s = nullptr;
2322  sal_Int32 i = 0;
2324  &s, pData, from.data(), from.size(), to.data(), to.size(),
2325  index == nullptr ? &i : index);
2326  return OUString(s, SAL_NO_ACQUIRE);
2327  }
2328 #else
2330  OUString const & from, OUString const & to, sal_Int32 * index = NULL) const
2331  {
2332  rtl_uString * s = NULL;
2333  sal_Int32 i = 0;
2335  &s, pData, from.pData, to.pData, index == NULL ? &i : index);
2336  return OUString(s, SAL_NO_ACQUIRE);
2337  }
2338 #endif
2339 
2358 #if defined LIBO_INTERNAL_ONLY
2359  template<typename T> [[nodiscard]]
2361  T & from, std::u16string_view to, sal_Int32 * index = nullptr) const
2362  {
2364  rtl_uString * s = nullptr;
2365  sal_Int32 i = 0;
2369  index == nullptr ? &i : index);
2370  return OUString(s, SAL_NO_ACQUIRE);
2371  }
2372 #else
2373  template< typename T >
2375  sal_Int32 * index = NULL) const
2376  {
2378  rtl_uString * s = NULL;
2379  sal_Int32 i = 0;
2381  &s, pData,
2384  index == NULL ? &i : index);
2385  return OUString(s, SAL_NO_ACQUIRE);
2386  }
2387 #endif
2388 
2407 #if defined LIBO_INTERNAL_ONLY
2408  template<typename T> [[nodiscard]]
2410  std::u16string_view from, T & to, sal_Int32 * index = nullptr) const
2411  {
2413  rtl_uString * s = nullptr;
2414  sal_Int32 i = 0;
2416  &s, pData, from.data(), from.size(),
2418  libreoffice_internal::ConstCharArrayDetector<T>::length, index == nullptr ? &i : index);
2419  return OUString(s, SAL_NO_ACQUIRE);
2420  }
2421 #else
2422  template< typename T >
2424  sal_Int32 * index = NULL) const
2425  {
2427  rtl_uString * s = NULL;
2428  sal_Int32 i = 0;
2430  &s, pData, from.pData,
2433  index == NULL ? &i : index);
2434  return OUString(s, SAL_NO_ACQUIRE);
2435  }
2436 #endif
2437 
2456  template< typename T1, typename T2 >
2458  replaceFirst( T1& from, T2& to, sal_Int32 * index = NULL) const
2459  {
2462  rtl_uString * s = NULL;
2463  sal_Int32 i = 0;
2465  &s, pData,
2470  index == NULL ? &i : index);
2471  return OUString(s, SAL_NO_ACQUIRE);
2472  }
2473 
2489 #if defined LIBO_INTERNAL_ONLY
2490  [[nodiscard]] OUString replaceAll(
2491  std::u16string_view from, std::u16string_view to, sal_Int32 fromIndex = 0) const
2492  {
2493  rtl_uString * s = nullptr;
2494  rtl_uString_newReplaceAllFromIndexUtf16LUtf16L(
2495  &s, pData, from.data(), from.size(), to.data(), to.size(), fromIndex);
2496  return OUString(s, SAL_NO_ACQUIRE);
2497  }
2498 #else
2500  OUString const & from, OUString const & to, sal_Int32 fromIndex = 0) const
2501  {
2502  rtl_uString * s = NULL;
2503  rtl_uString_newReplaceAllFromIndex(&s, pData, from.pData, to.pData, fromIndex);
2504  return OUString(s, SAL_NO_ACQUIRE);
2505  }
2506 #endif
2507 
2521 #if defined LIBO_INTERNAL_ONLY
2522  template<typename T> [[nodiscard]]
2524  T & from, std::u16string_view to) const
2525  {
2527  rtl_uString * s = nullptr;
2531  return OUString(s, SAL_NO_ACQUIRE);
2532  }
2533 #else
2534  template< typename T >
2536  {
2538  rtl_uString * s = NULL;
2540  &s, pData,
2543  return OUString(s, SAL_NO_ACQUIRE);
2544  }
2545 #endif
2546 
2560 #if defined LIBO_INTERNAL_ONLY
2561  template<typename T> [[nodiscard]]
2563  std::u16string_view from, T & to) const
2564  {
2566  rtl_uString * s = nullptr;
2568  &s, pData, from.data(), from.size(),
2571  return OUString(s, SAL_NO_ACQUIRE);
2572  }
2573 #else
2574  template< typename T >
2576  {
2578  rtl_uString * s = NULL;
2580  &s, pData, from.pData,
2583  return OUString(s, SAL_NO_ACQUIRE);
2584  }
2585 #endif
2586 
2600  template< typename T1, typename T2 >
2602  replaceAll( T1& from, T2& to ) const
2603  {
2606  rtl_uString * s = NULL;
2608  &s, pData,
2613  return OUString(s, SAL_NO_ACQUIRE);
2614  }
2615 
2627  {
2628  rtl_uString* pNew = NULL;
2629  rtl_uString_newToAsciiLowerCase( &pNew, pData );
2630  return OUString( pNew, SAL_NO_ACQUIRE );
2631  }
2632 
2644  {
2645  rtl_uString* pNew = NULL;
2646  rtl_uString_newToAsciiUpperCase( &pNew, pData );
2647  return OUString( pNew, SAL_NO_ACQUIRE );
2648  }
2649 
2664  {
2665  rtl_uString* pNew = NULL;
2666  rtl_uString_newTrim( &pNew, pData );
2667  return OUString( pNew, SAL_NO_ACQUIRE );
2668  }
2669 
2694  OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const
2695  {
2696  rtl_uString * pNew = NULL;
2697  index = rtl_uString_getToken( &pNew, pData, token, cTok, index );
2698  return OUString( pNew, SAL_NO_ACQUIRE );
2699  }
2700 
2714  OUString getToken(sal_Int32 count, sal_Unicode separator) const {
2715  sal_Int32 n = 0;
2716  return getToken(count, separator, n);
2717  }
2718 
2727  bool toBoolean() const
2728  {
2729  return rtl_ustr_toBoolean( pData->buffer );
2730  }
2731 
2739  {
2740  return pData->buffer[0];
2741  }
2742 
2753  sal_Int32 toInt32( sal_Int16 radix = 10 ) const
2754  {
2755  return rtl_ustr_toInt32( pData->buffer, radix );
2756  }
2757 
2770  sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
2771  {
2772  return rtl_ustr_toUInt32( pData->buffer, radix );
2773  }
2774 
2785  sal_Int64 toInt64( sal_Int16 radix = 10 ) const
2786  {
2787  return rtl_ustr_toInt64( pData->buffer, radix );
2788  }
2789 
2802  sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
2803  {
2804  return rtl_ustr_toUInt64( pData->buffer, radix );
2805  }
2806 
2815  float toFloat() const
2816  {
2817  return rtl_ustr_toFloat( pData->buffer );
2818  }
2819 
2828  double toDouble() const
2829  {
2830  return rtl_ustr_toDouble( pData->buffer );
2831  }
2832 
2833 
2850  {
2851  rtl_uString * pNew = NULL;
2852  rtl_uString_intern( &pNew, pData );
2853  if (pNew == NULL) {
2854  throw std::bad_alloc();
2855  }
2856  return OUString( pNew, SAL_NO_ACQUIRE );
2857  }
2858 
2884  static OUString intern( const char * value, sal_Int32 length,
2885  rtl_TextEncoding encoding,
2886  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS,
2887  sal_uInt32 *pInfo = NULL )
2888  {
2889  rtl_uString * pNew = NULL;
2890  rtl_uString_internConvert( &pNew, value, length, encoding,
2891  convertFlags, pInfo );
2892  if (pNew == NULL) {
2893  throw std::bad_alloc();
2894  }
2895  return OUString( pNew, SAL_NO_ACQUIRE );
2896  }
2897 
2922  bool convertToString(OString * pTarget, rtl_TextEncoding nEncoding,
2923  sal_uInt32 nFlags) const
2924  {
2925  return rtl_convertUStringToString(&pTarget->pData, pData->buffer,
2926  pData->length, nEncoding, nFlags);
2927  }
2928 
2980  sal_uInt32 iterateCodePoints(
2981  sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1) const
2982  {
2984  pData, indexUtf16, incrementCodePoints);
2985  }
2986 
2996 #if defined LIBO_INTERNAL_ONLY
2997  static OUString fromUtf8(std::string_view rSource)
2998  {
2999  OUString aTarget;
3000  bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
3001  rSource.data(),
3002  rSource.length(),
3005  (void) bSuccess;
3006  assert(bSuccess);
3007  return aTarget;
3008  }
3009 #else
3010  static OUString fromUtf8(const OString& rSource)
3011  {
3012  OUString aTarget;
3013  bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
3014  rSource.getStr(),
3015  rSource.getLength(),
3018  (void) bSuccess;
3019  assert(bSuccess);
3020  return aTarget;
3021  }
3022 #endif
3023 
3034  OString toUtf8() const
3035  {
3036  OString aTarget;
3037  bool bSuccess = rtl_convertUStringToString(&aTarget.pData,
3038  getStr(),
3039  getLength(),
3042  (void) bSuccess;
3043  assert(bSuccess);
3044  return aTarget;
3045  }
3046 
3047 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3048 
3049  static OUStringNumber< int > number( int i, sal_Int16 radix = 10 )
3050  {
3051  return OUStringNumber< int >( i, radix );
3052  }
3053  static OUStringNumber< long long > number( long long ll, sal_Int16 radix = 10 )
3054  {
3055  return OUStringNumber< long long >( ll, radix );
3056  }
3057  static OUStringNumber< unsigned long long > number( unsigned long long ll, sal_Int16 radix = 10 )
3058  {
3059  return OUStringNumber< unsigned long long >( ll, radix );
3060  }
3061  static OUStringNumber< unsigned long long > number( unsigned int i, sal_Int16 radix = 10 )
3062  {
3063  return number( static_cast< unsigned long long >( i ), radix );
3064  }
3065  static OUStringNumber< long long > number( long i, sal_Int16 radix = 10)
3066  {
3067  return number( static_cast< long long >( i ), radix );
3068  }
3069  static OUStringNumber< unsigned long long > number( unsigned long i, sal_Int16 radix = 10 )
3070  {
3071  return number( static_cast< unsigned long long >( i ), radix );
3072  }
3073  static OUStringNumber< float > number( float f )
3074  {
3075  return OUStringNumber< float >( f );
3076  }
3077  static OUStringNumber< double > number( double d )
3078  {
3079  return OUStringNumber< double >( d );
3080  }
3081 #else
3092  static OUString number( int i, sal_Int16 radix = 10 )
3093  {
3095  return OUString(aBuf, rtl_ustr_valueOfInt32(aBuf, i, radix));
3096  }
3099  static OUString number( unsigned int i, sal_Int16 radix = 10 )
3100  {
3101  return number( static_cast< unsigned long long >( i ), radix );
3102  }
3105  static OUString number( long i, sal_Int16 radix = 10)
3106  {
3107  return number( static_cast< long long >( i ), radix );
3108  }
3111  static OUString number( unsigned long i, sal_Int16 radix = 10 )
3112  {
3113  return number( static_cast< unsigned long long >( i ), radix );
3114  }
3117  static OUString number( long long ll, sal_Int16 radix = 10 )
3118  {
3120  return OUString(aBuf, rtl_ustr_valueOfInt64(aBuf, ll, radix));
3121  }
3124  static OUString number( unsigned long long ll, sal_Int16 radix = 10 )
3125  {
3127  return OUString(aBuf, rtl_ustr_valueOfUInt64(aBuf, ll, radix));
3128  }
3129 
3139  static OUString number( float f )
3140  {
3142  return OUString(aBuf, rtl_ustr_valueOfFloat(aBuf, f));
3143  }
3144 
3154  static OUString number( double d )
3155  {
3157  return OUString(aBuf, rtl_ustr_valueOfDouble(aBuf, d));
3158  }
3159 #endif
3160 
3172  SAL_DEPRECATED("use boolean()") static OUString valueOf( sal_Bool b )
3173  {
3174  return boolean(b);
3175  }
3176 
3188  static OUString boolean( bool b )
3189  {
3191  return OUString(aBuf, rtl_ustr_valueOfBoolean(aBuf, b));
3192  }
3193 
3201  SAL_DEPRECATED("convert to OUString or use directly") static OUString valueOf( sal_Unicode c )
3202  {
3203  return OUString( &c, 1 );
3204  }
3205 
3216  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
3217  {
3218  return number( i, radix );
3219  }
3220 
3231  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
3232  {
3233  return number( ll, radix );
3234  }
3235 
3245  SAL_DEPRECATED("use number()") static OUString valueOf( float f )
3246  {
3247  return number(f);
3248  }
3249 
3259  SAL_DEPRECATED("use number()") static OUString valueOf( double d )
3260  {
3261  return number(d);
3262  }
3263 
3279  static OUString createFromAscii( const char * value )
3280  {
3281  rtl_uString* pNew = NULL;
3282  rtl_uString_newFromAscii( &pNew, value );
3283  return OUString( pNew, SAL_NO_ACQUIRE );
3284  }
3285 
3286 #if defined LIBO_INTERNAL_ONLY
3287  static OUString createFromAscii(std::string_view value) {
3288  rtl_uString * p = nullptr;
3289  rtl_uString_newFromLiteral(&p, value.data(), value.size(), 0); //TODO: check for overflow
3290  return OUString(p, SAL_NO_ACQUIRE);
3291  }
3292  #endif
3293 
3294 #if defined LIBO_INTERNAL_ONLY
3295  operator std::u16string_view() const { return {getStr(), sal_uInt32(getLength())}; }
3296 #endif
3297 
3298 #if defined LIBO_INTERNAL_ONLY
3299  // A wrapper for the first expression in an
3300  //
3301  // OUString::Concat(e1) + e2 + ...
3302  //
3303  // concatenation chain, when neither of the first two e1, e2 is one of our rtl string-related
3304  // classes (so something like
3305  //
3306  // OUString s = "a" + (b ? std::u16string_view(u"c") : std::u16string_view(u"dd"));
3307  //
3308  // would not compile):
3309  template<typename T> [[nodiscard]] static
3310  typename std::enable_if_t<
3311  ToStringHelper<T>::allowOUStringConcat, OUStringConcat<OUStringConcatMarker, T>>
3312  Concat(T const & value) { return OUStringConcat<OUStringConcatMarker, T>({}, value); }
3313 
3314  // This overload is needed so that an argument of type 'char const[N]' ends up as
3315  // 'OUStringConcat<rtl::OUStringConcatMarker, char const[N]>' rather than as
3316  // 'OUStringConcat<rtl::OUStringConcatMarker, char[N]>':
3317  template<typename T, std::size_t N> [[nodiscard]] static
3318  typename std::enable_if_t<
3319  ToStringHelper<T[N]>::allowOUStringConcat, OUStringConcat<OUStringConcatMarker, T[N]>>
3320  Concat(T (& value)[N]) { return OUStringConcat<OUStringConcatMarker, T[N]>({}, value); }
3321 #endif
3322 
3323 private:
3324  OUString & internalAppend( rtl_uString* pOtherData )
3325  {
3326  rtl_uString* pNewData = NULL;
3327  rtl_uString_newConcat( &pNewData, pData, pOtherData );
3328  if (pNewData == NULL) {
3329  throw std::bad_alloc();
3330  }
3331  rtl_uString_assign(&pData, pNewData);
3332  rtl_uString_release(pNewData);
3333  return *this;
3334  }
3335 
3336 };
3337 
3338 #if defined LIBO_INTERNAL_ONLY
3339 // Can only define this after we define OUString
3340 inline OUStringConstExpr::operator const OUString &() const { return OUString::unacquired(&pData); }
3341 #endif
3342 
3343 #if defined LIBO_INTERNAL_ONLY
3344 // Prevent the operator ==/!= overloads with 'sal_Unicode const *' parameter from
3345 // being selected for nonsensical code like
3346 //
3347 // if (ouIdAttr == nullptr)
3348 //
3349 void operator ==(OUString const &, std::nullptr_t) = delete;
3350 void operator ==(std::nullptr_t, OUString const &) = delete;
3351 void operator !=(OUString const &, std::nullptr_t) = delete;
3352 void operator !=(std::nullptr_t, OUString const &) = delete;
3353 #endif
3354 
3355 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3356 inline bool operator ==(OUString const & lhs, OUStringConcatenation const & rhs)
3357 { return lhs == std::u16string_view(rhs); }
3358 inline bool operator !=(OUString const & lhs, OUStringConcatenation const & rhs)
3359 { return lhs != std::u16string_view(rhs); }
3360 inline bool operator ==(OUStringConcatenation const & lhs, OUString const & rhs)
3361 { return std::u16string_view(lhs) == rhs; }
3362 inline bool operator !=(OUStringConcatenation const & lhs, OUString const & rhs)
3363 { return std::u16string_view(lhs) != rhs; }
3364 #endif
3365 
3366 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3368 
3372 template<>
3373 struct ToStringHelper< OUString >
3374  {
3375  static std::size_t length( const OUString& s ) { return s.getLength(); }
3376  static sal_Unicode* addData( sal_Unicode* buffer, const OUString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
3377  static const bool allowOStringConcat = false;
3378  static const bool allowOUStringConcat = true;
3379  };
3380 
3384 template<std::size_t N>
3385 struct ToStringHelper< OUStringLiteral<N> >
3386  {
3387  static std::size_t length( const OUStringLiteral<N>& str ) { return str.getLength(); }
3388  static sal_Unicode* addData( sal_Unicode* buffer, const OUStringLiteral<N>& str ) { return addDataHelper( buffer, str.getStr(), str.getLength() ); }
3389  static const bool allowOStringConcat = false;
3390  static const bool allowOUStringConcat = true;
3391  };
3392 
3396 template< typename charT, typename traits, typename T1, typename T2 >
3397 inline std::basic_ostream<charT, traits> & operator <<(
3398  std::basic_ostream<charT, traits> & stream, OUStringConcat< T1, T2 >&& concat)
3399 {
3400  return stream << OUString( std::move(concat) );
3401 }
3402 
3403 
3405 #endif
3406 
3413 {
3423  size_t operator()(const OUString& rString) const
3424  { return static_cast<size_t>(rString.hashCode()); }
3425 };
3426 
3427 /* ======================================================================= */
3428 
3446 #if defined LIBO_INTERNAL_ONLY
3447 inline OUString OStringToOUString( std::string_view rStr,
3448  rtl_TextEncoding encoding,
3449  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
3450 {
3451  return OUString( rStr.data(), rStr.length(), encoding, convertFlags );
3452 }
3453 #else
3454 inline OUString OStringToOUString( const OString & rStr,
3455  rtl_TextEncoding encoding,
3456  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
3457 {
3458  return OUString( rStr.getStr(), rStr.getLength(), encoding, convertFlags );
3459 }
3460 #endif
3461 
3479 #if defined LIBO_INTERNAL_ONLY
3480 inline OString OUStringToOString( std::u16string_view rUnicode,
3481  rtl_TextEncoding encoding,
3482  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
3483 {
3484  return OString( rUnicode.data(), rUnicode.length(), encoding, convertFlags );
3485 }
3486 #else
3487 inline OString OUStringToOString( const OUString & rUnicode,
3488  rtl_TextEncoding encoding,
3489  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
3490 {
3491  return OString( rUnicode.getStr(), rUnicode.getLength(), encoding, convertFlags );
3492 }
3493 #endif
3494 
3495 /* ======================================================================= */
3496 
3505 template< typename charT, typename traits >
3506 inline std::basic_ostream<charT, traits> & operator <<(
3507  std::basic_ostream<charT, traits> & stream, OUString const & rString)
3508 {
3509  return stream <<
3511  // best effort; potentially loses data due to conversion failures
3512  // (stray surrogate halves) and embedded null characters
3513 }
3514 
3515 } // namespace
3516 
3517 #ifdef RTL_STRING_UNITTEST
3518 namespace rtl
3519 {
3520 typedef rtlunittest::OUString OUString;
3521 }
3522 #endif
3523 
3524 // In internal code, allow to use classes like OUString without having to
3525 // explicitly refer to the rtl namespace, which is kind of superfluous given
3526 // that OUString itself is namespaced by its OU prefix:
3527 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3528 using ::rtl::OUString;
3529 using ::rtl::OUStringHash;
3532 using ::rtl::OUStringLiteral;
3533 using ::rtl::OUStringChar;
3534 using ::rtl::OUStringConcatenation;
3535 #endif
3536 
3538 
3543 #if defined LIBO_INTERNAL_ONLY
3544 namespace std {
3545 
3546 template<>
3547 struct hash<::rtl::OUString>
3548 {
3549  std::size_t operator()(::rtl::OUString const & s) const
3550  { return std::size_t(s.hashCode()); }
3551 };
3552 
3553 }
3554 
3555 #endif
3557 
3558 #endif /* _RTL_USTRING_HXX */
3559 
3560 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don't use, it's evil.") void doit(int nPara);.
Definition: types.h:474
__sal_NoAcquire
Definition: types.h:353
@ SAL_NO_ACQUIRE
definition of a no acquire enum for ctors
Definition: types.h:356
unsigned char sal_Bool
Definition: types.h:38
sal_uInt16 sal_Unicode
Definition: types.h:123
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:284
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:587
SAL_DLLPUBLIC sal_Bool rtl_convertUStringToString(rtl_String **pTarget, sal_Unicode const *pSource, sal_Int32 nLength, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) SAL_THROW_EXTERN_C()
Converts a Unicode string to a byte string, signalling failure.
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1358
#define RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR
Definition: textcvt.h:151
#define RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR
Definition: textcvt.h:75
#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
Definition: textcvt.h:72
#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:68
#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:145
#define RTL_TEXTENCODING_UTF8
Definition: textenc.h:117
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:37
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(sal_Unicode const *first, sal_Int32 firstLen, char const *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
SAL_DLLPUBLIC void rtl_uString_assign(rtl_uString **str, rtl_uString *rightValue) SAL_THROW_EXTERN_C()
Assign a new value to a string.
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstUtf16LUtf16L(rtl_uString **newStr, rtl_uString *str, sal_Unicode const *from, sal_Int32 fromLength, sal_Unicode const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring.
SAL_DLLPUBLIC float rtl_ustr_toFloat(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a float.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_shortenedCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters.
SAL_DLLPUBLIC void rtl_uString_new(rtl_uString **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
#define OSTRING_TO_OUSTRING_CVTFLAGS
Definition: ustring.h:2188
#define RTL_USTR_MAX_VALUEOFFLOAT
Definition: ustring.h:1026
SAL_DLLPUBLIC sal_Int32 rtl_ustr_compare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings.
SAL_DLLPUBLIC void rtl_uString_newConcatUtf16L(rtl_uString **newString, rtl_uString *left, sal_Unicode const *right, sal_Int32 rightLength)
Create a new string that is the concatenation of two other strings.
SAL_DLLPUBLIC void rtl_uString_newReplaceAllAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, rtl_uString const *to) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring.
SAL_DLLPUBLIC void rtl_uString_newReplaceAllFromIndex(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, rtl_uString const *to, sal_Int32 fromIndex) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters, ignoring the case of ASCII characters.
SAL_DLLPUBLIC sal_Int32 rtl_uString_getToken(rtl_uString **newStr, rtl_uString *str, sal_Int32 token, sal_Unicode cTok, sal_Int32 idx) SAL_THROW_EXTERN_C()
Create a new string by extracting a single token from another string.
#define RTL_USTR_MAX_VALUEOFDOUBLE
Definition: ustring.h:1045
SAL_DLLPUBLIC void rtl_uString_newFromStr_WithLength(rtl_uString **newStr, const sal_Unicode *value, sal_Int32 len) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
SAL_DLLPUBLIC sal_Bool rtl_ustr_asciil_reverseEquals_WithLength(const sal_Unicode *first, const char *second, sal_Int32 len) SAL_THROW_EXTERN_C()
Compare two strings from back to front for equality.
SAL_DLLPUBLIC void rtl_uString_newFromLiteral(rtl_uString **newStr, const char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
SAL_DLLPUBLIC void rtl_uString_newReplaceAllAsciiLUtf16L(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, sal_Unicode const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfBoolean(sal_Unicode *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
SAL_DLLPUBLIC double rtl_ustr_toDouble(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a double.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfFloat(sal_Unicode *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstUtf16LAsciiL(rtl_uString **newStr, rtl_uString *str, sal_Unicode const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring.
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstToAsciiL(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, char const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfDouble(sal_Unicode *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
SAL_DLLPUBLIC void rtl_uString_newConcat(rtl_uString **newStr, rtl_uString *left, rtl_uString *right) SAL_THROW_EXTERN_C()
Create a new string that is the concatenation of two other strings.
#define RTL_USTR_MAX_VALUEOFINT64
Definition: ustring.h:984
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
SAL_DLLPUBLIC rtl_uString * rtl_uString_alloc(sal_Int32 nLen) SAL_THROW_EXTERN_C()
Allocate a new string containing space for a given number of characters.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfStr_WithLength(const sal_Unicode *str, sal_Int32 len, const sal_Unicode *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of a substring within a string.
SAL_DLLPUBLIC void rtl_uString_internConvert(rtl_uString **newStr, const char *str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags, sal_uInt32 *pInfo) SAL_THROW_EXTERN_C()
Return a canonical representation for a string.
SAL_DLLPUBLIC void rtl_uString_acquire(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Increment the reference count of a string.
SAL_DLLPUBLIC sal_Int64 rtl_ustr_toInt64(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as a long integer.
SAL_DLLPUBLIC void rtl_uString_newReplaceStrAt(rtl_uString **newStr, rtl_uString *str, sal_Int32 idx, sal_Int32 count, rtl_uString *subStr) SAL_THROW_EXTERN_C()
Create a new string by replacing a substring of another string.
#define RTL_USTR_MAX_VALUEOFUINT64
Definition: ustring.h:1007
SAL_DLLPUBLIC sal_Bool rtl_convertStringToUString(rtl_uString **target, char const *source, sal_Int32 length, rtl_TextEncoding encoding, sal_uInt32 flags) SAL_THROW_EXTERN_C()
Converts a byte string to a Unicode string, signalling failure.
SAL_DLLPUBLIC void rtl_uString_newReplaceAllToAsciiL(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, char const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring.
SAL_DLLPUBLIC sal_uInt32 rtl_uString_iterateCodePoints(rtl_uString const *string, sal_Int32 *indexUtf16, sal_Int32 incrementCodePoints)
Iterate through a string based on code points instead of UTF-16 code units.
SAL_DLLPUBLIC void rtl_uString_newToAsciiLowerCase(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Create a new string by converting all ASCII uppercase letters to lowercase within another string.
SAL_DLLPUBLIC void rtl_uString_ensureCapacity(rtl_uString **str, sal_Int32 size) SAL_THROW_EXTERN_C()
Ensure a string has enough space for a given number of characters.
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Decrement the reference count of a string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_getLength(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Return the length of a string.
SAL_DLLPUBLIC void rtl_uString_newFromAscii(rtl_uString **newStr, const char *value) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfInt64(sal_Unicode *str, sal_Int64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of a long integer.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfAscii_WithLength(sal_Unicode const *str, sal_Int32 len, char const *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of an ASCII substring within a string.
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, rtl_uString const *to, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfAscii_WithLength(sal_Unicode const *str, sal_Int32 len, char const *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of an ASCII substring within a string.
SAL_DLLPUBLIC sal_uInt64 rtl_ustr_toUInt64(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned long integer.
SAL_DLLPUBLIC void rtl_uString_newReplaceAllUtf16LAsciiL(rtl_uString **newStr, rtl_uString *str, sal_Unicode const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters, ignoring the case of ASCII characters.
SAL_DLLPUBLIC void rtl_uString_newTrim(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Create a new string by removing white space from both ends of another string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfChar_WithLength(const sal_Unicode *str, sal_Int32 len, sal_Unicode ch) SAL_THROW_EXTERN_C()
Search for the last occurrence of a character within a string.
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstAsciiLAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring.
SAL_DLLPUBLIC sal_uInt32 rtl_ustr_toUInt32(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned integer.
SAL_DLLPUBLIC void rtl_uString_intern(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Return a canonical representation for a string.
SAL_DLLPUBLIC void rtl_string2UString(rtl_uString **newStr, const char *str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags) SAL_THROW_EXTERN_C()
Create a new Unicode string by converting a byte string, using a specific text encoding.
SAL_DLLPUBLIC void rtl_uString_newFromStr(rtl_uString **newStr, const sal_Unicode *value) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_asciil_reverseCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings from back to front.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_compare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second) SAL_THROW_EXTERN_C()
Compare two strings.
#define RTL_USTR_MAX_VALUEOFBOOLEAN
Definition: ustring.h:919
SAL_DLLPUBLIC sal_Int32 rtl_ustr_toInt32(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an integer.
SAL_DLLPUBLIC void rtl_uString_newReplaceAllAsciiLAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfUInt64(sal_Unicode *str, sal_uInt64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an unsigned long integer.
SAL_DLLPUBLIC void rtl_uString_newFromCodePoints(rtl_uString **newString, sal_uInt32 const *codePoints, sal_Int32 codePointCount) SAL_THROW_EXTERN_C()
Allocate a new string from an array of Unicode code points.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_compareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_reverseCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings from back to front.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_shortenedCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfInt32(sal_Unicode *str, sal_Int32 i, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an integer.
SAL_DLLPUBLIC sal_Bool rtl_ustr_toBoolean(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
SAL_DLLPUBLIC void rtl_uString_newReplace(rtl_uString **newStr, rtl_uString *str, sal_Unicode oldChar, sal_Unicode newChar) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a single character within another string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_hashCode_WithLength(const sal_Unicode *str, sal_Int32 len) SAL_THROW_EXTERN_C()
Return a hash code for a string.
SAL_DLLPUBLIC void rtl_uString_newReplaceFirst(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, rtl_uString const *to, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring.
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstAsciiLUtf16L(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, sal_Unicode const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring.
SAL_DLLPUBLIC void rtl_uString_newToAsciiUpperCase(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Create a new string by converting all ASCII lowercase letters to uppercase within another string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfStr_WithLength(const sal_Unicode *str, sal_Int32 len, const sal_Unicode *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of a substring within a string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfChar_WithLength(const sal_Unicode *str, sal_Int32 len, sal_Unicode ch) SAL_THROW_EXTERN_C()
Search for the first occurrence of a character within a string.
SAL_DLLPUBLIC void rtl_uString_newFromSubString(rtl_uString **newStr, const rtl_uString *from, sal_Int32 beginIndex, sal_Int32 count) SAL_THROW_EXTERN_C()
Allocate a new string that is a substring of this string.
SAL_DLLPUBLIC void rtl_uString_newConcatAsciiL(rtl_uString **newString, rtl_uString *left, char const *right, sal_Int32 rightLength)
Create a new string that is the concatenation of two other strings.
#define RTL_USTR_MAX_VALUEOFINT32
Definition: ustring.h:961
sal_Int32 oslInterlockedCount
Definition: interlck.h:44
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:93
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:103
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:113
Definition: bootstrap.hxx:34
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:3454
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:3487
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &stream, OString const &rString)
Support for rtl::OString in std::ostream (and thus in CPPUNIT_ASSERT or SAL_INFO macros,...
Definition: string.hxx:2266
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:665
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:180
const char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:602
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:576
Definition: stringutils.hxx:140
Definition: stringutils.hxx:143
A string buffer implements a mutable sequence of characters.
Definition: ustrbuf.hxx:71
This String class provides base functionality for C++ like Unicode character array handling.
Definition: ustring.hxx:203
static OUString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: ustring.hxx:3092
OUString intern() const
Return a canonical representation for a string.
Definition: ustring.hxx:2849
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:2001
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:2458
bool endsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string ends with a given substring.
Definition: ustring.hxx:1569
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:1710
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:2626
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:2535
bool equalsIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:989
bool endsWithAsciiL(char const *asciiStr, sal_Int32 asciiStrLength) const
Check whether this string ends with a given ASCII string.
Definition: ustring.hxx:1619
OUString(const OUString &str)
New string from OUString.
Definition: ustring.hxx:223
sal_uInt32 iterateCodePoints(sal_Int32 *indexUtf16, sal_Int32 incrementCodePoints=1) const
Iterate through this string based on code points instead of UTF-16 code units.
Definition: ustring.hxx:2980
static OUString fromUtf8(const OString &rSource)
Convert an OString to an OUString, assuming that the OString is UTF-8-encoded.
Definition: ustring.hxx:3010
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1085
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: ustring.hxx:2753
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: ustring.hxx:794
bool equalsIgnoreAsciiCaseAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1337
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:3124
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:2035
~OUString()
Release the string data.
Definition: ustring.hxx:524
sal_Int32 compareTo(const OUString &str, sal_Int32 maxLength) const
Compares two strings with a maximum count of characters.
Definition: ustring.hxx:894
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:2143
sal_Int32 indexOf(sal_Unicode ch, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified character,...
Definition: ustring.hxx:1928
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:2575
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:3117
bool matchAsciiL(const char *asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:1366
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:2499
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:600
float toFloat() const
Returns the float value from this string.
Definition: ustring.hxx:2815
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:3111
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:2602
static OUString createFromAscii(const char *value)
Returns an OUString copied without conversion from an ASCII character string.
Definition: ustring.hxx:3279
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:2374
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:2292
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: ustring.hxx:1910
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type reverseCompareTo(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:932
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1815
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1799
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:3105
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1034
const sal_Unicode * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:829
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: ustring.hxx:2802
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:1404
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition: ustring.hxx:678
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWithIgnoreAsciiCase(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1524
OString toUtf8() const
Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully.
Definition: ustring.hxx:3034
sal_Int32 reverseCompareToAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Compares two strings in reverse order.
Definition: ustring.hxx:1218
bool equalsAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform a comparison of two strings.
Definition: ustring.hxx:1262
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:3099
bool convertToString(OString *pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) const
Converts to an OString, signalling failure.
Definition: ustring.hxx:2922
OUString & operator=(const OUString &str)
Assign a new string.
Definition: ustring.hxx:564
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWith(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1457
OUString(rtl_uString *str)
New string from OUString data.
Definition: ustring.hxx:249
OUString(const sal_Unicode *value, sal_Int32 length)
New string from a Unicode character buffer array.
Definition: ustring.hxx:328
bool endsWithIgnoreAsciiCase(OUString const &str, OUString *rest=NULL) const
Check whether this string ends with a given string, ignoring the case of ASCII letters.
Definition: ustring.hxx:1658
sal_Int32 compareTo(const OUString &str) const
Compares two strings.
Definition: ustring.hxx:865
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1831
bool startsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: ustring.hxx:1442
sal_Int32 lastIndexOf(sal_Unicode ch) const
Returns the index within this string of the last occurrence of the specified character,...
Definition: ustring.hxx:1943
sal_Int32 compareToIgnoreAsciiCaseAscii(const char *asciiStr) const
Compares two ASCII strings ignoring case.
Definition: ustring.hxx:1312
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:2423
OUString(sal_Unicode value)
New string from a single Unicode character.
Definition: ustring.hxx:271
SAL_WARN_UNUSED_RESULT OUString replaceFirst(OUString const &from, OUString const &to, sal_Int32 *index=NULL) const
Returns a new string resulting from replacing the first occurrence of a given substring with another ...
Definition: ustring.hxx:2329
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: ustring.hxx:2785
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: ustring.hxx:2770
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:1506
sal_Int32 lastIndexOf(const OUString &str, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified substring,...
Definition: ustring.hxx:2101
double toDouble() const
Returns the double value from this string.
Definition: ustring.hxx:2828
bool equalsAscii(const char *asciiStr) const
Perform a comparison of two strings.
Definition: ustring.hxx:1239
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1139
OUString getToken(sal_Int32 token, sal_Unicode cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: ustring.hxx:2694
sal_Int32 getLength() const
Returns the length of this string.
Definition: ustring.hxx:807
bool equalsIgnoreAsciiCaseAscii(const char *asciiStr) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1289
OUString()
New string containing no characters.
Definition: ustring.hxx:212
static OUString const & unacquired(rtl_uString *const *ppHandle)
Provides an OUString const & passing a storage pointer of an rtl_uString * handle.
Definition: ustring.hxx:540
OUString(const sal_Unicode *value)
New string from a Unicode character buffer array.
Definition: ustring.hxx:312
OUString(const char *value, sal_Int32 length, rtl_TextEncoding encoding, sal_uInt32 convertFlags=OSTRING_TO_OUSTRING_CVTFLAGS)
New string from an 8-Bit character buffer array.
Definition: ustring.hxx:446
static OUString number(float f)
Returns the string representation of the float argument.
Definition: ustring.hxx:3139
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:817
sal_Int32 compareToIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1021
OUString(sal_uInt32 const *codePoints, sal_Int32 codePointCount)
Create a new string from an array of Unicode code points.
Definition: ustring.hxx:473
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type endsWith(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1586
sal_Unicode toChar() const
Returns the first character from this string.
Definition: ustring.hxx:2738
OUString getToken(sal_Int32 count, sal_Unicode separator) const
Returns a token from the string.
Definition: ustring.hxx:2714
static OUString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: ustring.hxx:3188
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type lastIndexOf(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:2114
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:2176
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type endsWithIgnoreAsciiCase(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1676
OUString(rtl_uString *str, __sal_NoAcquire)
New OUString from OUString data without acquiring it.
Definition: ustring.hxx:263
sal_Int32 lastIndexOf(sal_Unicode ch, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified character,...
Definition: ustring.hxx:1960
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:2663
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:2643
SAL_WARN_UNUSED_RESULT OUString concat(const OUString &str) const
Concatenates the specified string to the end of this string.
Definition: ustring.hxx:2232
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:2262
bool match(const OUString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:1072
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:1125
sal_Int32 compareToAscii(const char *asciiStr) const
Compares two strings.
Definition: ustring.hxx:1164
OUString(T &literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
New string from an 8-Bit string literal that is expected to contain only characters in the ASCII set ...
Definition: ustring.hxx:350
sal_Int32 reverseCompareTo(const OUString &str) const
Compares two strings in reverse order.
Definition: ustring.hxx:919
static OUString number(double d)
Returns the string representation of the double argument.
Definition: ustring.hxx:3154
friend OUString operator+(const OUString &rStr1, const OUString &rStr2)
Definition: ustring.hxx:2241
SAL_WARN_UNUSED_RESULT OUString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: ustring.hxx:2159
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1847
bool equals(const OUString &str) const
Perform a comparison of two strings.
Definition: ustring.hxx:953
sal_Int32 lastIndexOf(const OUString &str) const
Returns the index within this string of the last occurrence of the specified substring,...
Definition: ustring.hxx:2072
bool toBoolean() const
Returns the Boolean value from this string.
Definition: ustring.hxx:2727
sal_Int32 indexOf(const OUString &str, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified substring,...
Definition: ustring.hxx:1987
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:2884
A helper to use OUStrings with hash maps.
Definition: ustring.hxx:3413
size_t operator()(const OUString &rString) const
Compute a hash code for a string.
Definition: ustring.hxx:3423