AlterOffice
AlterOffice 3.4 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
4 #ifndef INCLUDED_RTL_USTRING_HXX
5 #define INCLUDED_RTL_USTRING_HXX
6 
7 #include "sal/config.h"
8 
9 #include <cassert>
10 #include <cstddef>
11 #include <cstdlib>
12 #include <limits>
13 #include <new>
14 #include <ostream>
15 #include <utility>
16 
17 #if defined LIBO_INTERNAL_ONLY
18 #include <string_view>
19 #include <type_traits>
20 #endif
21 
22 #include "rtl/ustring.h"
23 #include "rtl/string.hxx"
24 #include "rtl/stringutils.hxx"
25 #include "rtl/textenc.h"
26 
27 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
28 #include "config_global.h"
29 #include "rtl/stringconcat.hxx"
30 #endif
31 
32 #ifdef RTL_STRING_UNITTEST
33 extern bool rtl_string_unittest_invalid_conversion;
34 #endif
35 
36 // The unittest uses slightly different code to help check that the proper
37 // calls are made. The class is put into a different namespace to make
38 // sure the compiler generates a different (if generating also non-inline)
39 // copy of the function and does not merge them together. The class
40 // is "brought" into the proper rtl namespace by a typedef below.
41 #ifdef RTL_STRING_UNITTEST
42 #define rtl rtlunittest
43 #endif
44 
45 namespace rtl
46 {
47 
48 class OUStringBuffer;
49 
50 #ifdef RTL_STRING_UNITTEST
51 #undef rtl
52 #endif
53 
54 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
55 
63 template<std::size_t N> class SAL_WARN_UNUSED OUStringLiteral {
64  static_assert(N != 0);
65  static_assert(N - 1 <= std::numeric_limits<sal_Int32>::max(), "literal too long");
66  friend class OUString;
67  friend class OUStringConstExpr;
68 
69 public:
70 #if HAVE_CPP_CONSTEVAL
71  consteval
72 #else
73  constexpr
74 #endif
75  OUStringLiteral(char16_t const (&literal)[N]) {
76  assertLayout();
77  assert(literal[N - 1] == '\0');
78  //TODO: Use C++20 constexpr std::copy_n (P0202R3):
79  for (std::size_t i = 0; i != N; ++i) {
80  more.buffer[i] = literal[i];
81  }
82  }
83 
84  constexpr sal_Int32 getLength() const { return more.length; }
85 
86  constexpr sal_Unicode const * getStr() const SAL_RETURNS_NONNULL { return more.buffer; }
87 
88  constexpr operator std::u16string_view() const { return {more.buffer, sal_uInt32(more.length)}; }
89 
90 private:
91  static constexpr void assertLayout() {
92  // These static_asserts verifying the layout compatibility with rtl_uString cannot be class
93  // member declarations, as offsetof requires a complete type, so defer them to here:
94  static_assert(std::is_standard_layout_v<OUStringLiteral>);
95  static_assert(offsetof(OUStringLiteral, str.refCount) == offsetof(OUStringLiteral, more.refCount));
96  static_assert(offsetof(OUStringLiteral, str.length) == offsetof(OUStringLiteral, more.length));
97  static_assert(offsetof(OUStringLiteral, str.buffer) == offsetof(OUStringLiteral, more.buffer));
98  }
99 
100  struct Data {
101  Data() = default;
102 
103  oslInterlockedCount refCount = 0x40000000; // SAL_STRING_STATIC_FLAG (sal/rtl/strimp.hxx)
104  sal_Int32 length = N - 1;
105  sal_Unicode buffer[N] = {}; //TODO: drop initialization for C++20 (P1331R2)
106  };
107 
108  union {
109  rtl_uString str;
110  Data more = {};
111  };
112 };
113 
114 #if defined RTL_STRING_UNITTEST
115 namespace libreoffice_internal {
116 template<std::size_t N> struct ExceptConstCharArrayDetector<OUStringLiteral<N>> {};
117 template<std::size_t N> struct ExceptCharArrayDetector<OUStringLiteral<N>> {};
118 }
119 #endif
120 
129 class OUString;
130 class OUStringConstExpr
131 {
132 public:
133  template<std::size_t N> constexpr OUStringConstExpr(OUStringLiteral<N> const & literal):
134  pData(const_cast<rtl_uString *>(&literal.str)) {}
135 
136  // prevent mis-use
137  template<std::size_t N> constexpr OUStringConstExpr(OUStringLiteral<N> && literal)
138  = delete;
139 
140  // no destructor necessary because we know we are pointing at a compile-time
141  // constant OUStringLiteral, which bypasses ref-counting.
142 
146  constexpr std::u16string_view asView() const { return std::u16string_view(pData->buffer, pData->length); }
147 
148  inline operator const OUString&() const;
149 
150 private:
151  rtl_uString* pData;
152 };
153 
155 #endif
156 
157 /* ======================================================================= */
158 
182 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OUString
183 {
184 public:
186  rtl_uString * pData;
188 
193  {
194  pData = NULL;
195  rtl_uString_new( &pData );
196  }
197 
203  OUString( const OUString & str )
204  {
205  pData = str.pData;
206  rtl_uString_acquire( pData );
207  }
208 
209 #if defined LIBO_INTERNAL_ONLY
210 
216  OUString( OUString && str ) noexcept
217  {
218  pData = str.pData;
219  str.pData = nullptr;
220  rtl_uString_new( &str.pData );
221  }
222 #endif
223 
229  OUString( rtl_uString * str )
230  {
231  pData = str;
232  rtl_uString_acquire( pData );
233  }
234 
243  OUString( rtl_uString * str, __sal_NoAcquire )
244  { pData = str; }
245 
251  explicit OUString( sal_Unicode value )
252  : pData (NULL)
253  {
254  rtl_uString_newFromStr_WithLength( &pData, &value, 1 );
255  }
256 
257 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
258  // Catch inadvertent conversions to the above ctor (but still allow
260  // construction from char literals):
261  OUString(int) = delete;
262  explicit OUString(char c):
263  OUString(sal_Unicode(static_cast<unsigned char>(c)))
264  {}
266 #endif
267 
268 #if defined LIBO_INTERNAL_ONLY
269 
270  template<typename T> explicit OUString(
271  T const & value,
272  typename libreoffice_internal::CharPtrDetector<T, libreoffice_internal::Dummy>::TypeUtf16
273  = libreoffice_internal::Dummy()):
274  pData(nullptr)
275  { rtl_uString_newFromStr(&pData, value); }
276 
277  template<typename T> explicit OUString(
278  T & value,
279  typename
280  libreoffice_internal::NonConstCharArrayDetector<T, libreoffice_internal::Dummy>::TypeUtf16
281  = libreoffice_internal::Dummy()):
282  pData(nullptr)
283  { rtl_uString_newFromStr(&pData, value); }
284 
285 #else
286 
292  OUString( const sal_Unicode * value )
293  {
294  pData = NULL;
295  rtl_uString_newFromStr( &pData, value );
296  }
297 
298 #endif
299 
308  OUString( const sal_Unicode * value, sal_Int32 length )
309  {
310  pData = NULL;
311  rtl_uString_newFromStr_WithLength( &pData, value, length );
312  }
313 
329  template< typename T >
331  {
332  assert(
334  pData = NULL;
336  rtl_uString_new(&pData);
337  } else {
339  &pData,
341  literal),
343  }
344 #ifdef RTL_STRING_UNITTEST
345  rtl_string_unittest_const_literal = true;
346 #endif
347  }
348 
349 #if defined LIBO_INTERNAL_ONLY
350 
351  template<typename T> OUString(
352  T & literal,
353  typename libreoffice_internal::ConstCharArrayDetector<
354  T, libreoffice_internal::Dummy>::TypeUtf16
355  = libreoffice_internal::Dummy()):
356  pData(nullptr)
357  {
358  assert(
359  libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
360  if (libreoffice_internal::ConstCharArrayDetector<T>::length == 0) {
361  rtl_uString_new(&pData);
362  } else {
364  &pData,
365  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
366  literal),
367  libreoffice_internal::ConstCharArrayDetector<T>::length);
368  }
369  }
370 #endif
371 
372 #if defined LIBO_INTERNAL_ONLY && defined RTL_STRING_UNITTEST
373 
378  template< typename T >
379  OUString( T&, typename libreoffice_internal::ExceptConstCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
380  {
381  pData = NULL;
382  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
383  rtl_string_unittest_invalid_conversion = true;
384  }
389  template< typename T >
390  OUString( const T&, typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
391  {
392  pData = NULL;
393  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
394  rtl_string_unittest_invalid_conversion = true;
395  }
397 #endif
398 
399 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
400 
406  template<std::size_t N> constexpr OUString(OUStringLiteral<N> const & literal):
407  pData(const_cast<rtl_uString *>(&literal.str)) {}
408  template<std::size_t N> OUString(OUStringLiteral<N> &&) = delete;
410 #endif
411 
426  OUString( const char * value, sal_Int32 length,
427  rtl_TextEncoding encoding,
428  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
429  {
430  pData = NULL;
431  rtl_string2UString( &pData, value, length, encoding, convertFlags );
432  if (pData == NULL) {
433  throw std::bad_alloc();
434  }
435  }
436 
453  explicit OUString(
454  sal_uInt32 const * codePoints, sal_Int32 codePointCount):
455  pData(NULL)
456  {
457  rtl_uString_newFromCodePoints(&pData, codePoints, codePointCount);
458  if (pData == NULL) {
459  throw std::bad_alloc();
460  }
461  }
462 
463 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
464 
468  template< typename T1, typename T2 >
469  OUString( OUStringConcat< T1, T2 >&& c )
470  {
471  const sal_Int32 l = c.length();
472  pData = rtl_uString_alloc( l );
473  if (l != 0)
474  {
475  sal_Unicode* end = c.addData( pData->buffer );
476  pData->length = l;
477  *end = '\0';
478  }
479  }
480 
485  template< typename T, std::size_t N >
486  OUString( StringNumberBase< sal_Unicode, T, N >&& n )
487  : OUString( n.buf, n.length )
488  {}
489 #endif
490 
491 #if defined LIBO_INTERNAL_ONLY
492  explicit OUString(std::u16string_view sv) {
493  if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
494  throw std::bad_alloc();
495  }
496  pData = nullptr;
497  rtl_uString_newFromStr_WithLength(&pData, sv.data(), sv.size());
498  }
499 #endif
500 
505  {
506  rtl_uString_release( pData );
507  }
508 
520  static OUString const & unacquired( rtl_uString * const * ppHandle )
521  { return * reinterpret_cast< OUString const * >( ppHandle ); }
522 
523 #if defined LIBO_INTERNAL_ONLY
524 
536  static OUString const& unacquired(const OUStringBuffer& str);
537 #endif
538 
544  OUString & operator=( const OUString & str )
545  {
546  rtl_uString_assign( &pData, str.pData );
547  return *this;
548  }
549 
550 #if defined LIBO_INTERNAL_ONLY
551 
557  OUString & operator=( OUString && str ) noexcept
558  {
559  std::swap(pData, str.pData);
560  return *this;
561  }
562 #endif
563 
576  template< typename T >
578  {
579  assert(
582  rtl_uString_new(&pData);
583  } else {
585  &pData,
587  literal),
589  }
590  return *this;
591  }
592 
593 #if defined LIBO_INTERNAL_ONLY
594 
595  template<typename T>
596  typename
598  operator =(T & literal) {
600  rtl_uString_new(&pData);
601  } else {
603  &pData,
604  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
605  literal),
606  libreoffice_internal::ConstCharArrayDetector<T>::length);
607  }
608  return *this;
609  }
610 
612  template<std::size_t N> OUString & operator =(OUStringLiteral<N> const & literal) {
613  rtl_uString_release(pData);
614  pData = const_cast<rtl_uString *>(&literal.str);
615  return *this;
616  }
617  template<std::size_t N> OUString & operator =(OUStringLiteral<N> &&) = delete;
618 
619  template <typename T, std::size_t N>
620  OUString & operator =(StringNumberBase<sal_Unicode, T, N> && n) {
621  // n.length should never be zero, so no need to add an optimization for that case
622  rtl_uString_newFromStr_WithLength(&pData, n.buf, n.length);
623  return *this;
624  }
625 
626  OUString & operator =(std::u16string_view sv) {
627  if (sv.empty()) {
628  rtl_uString_new(&pData);
629  } else {
630  rtl_uString_newFromStr_WithLength(&pData, sv.data(), sv.size());
631  }
632  return *this;
633  }
634 #endif
635 
636 #if defined LIBO_INTERNAL_ONLY
637 
645  inline OUString & operator+=( const OUStringBuffer & str ) &;
646 #endif
647 
655  OUString & operator+=( const OUString & str )
656 #if defined LIBO_INTERNAL_ONLY
657  &
658 #endif
659  {
660  return internalAppend(str.pData);
661  }
662 #if defined LIBO_INTERNAL_ONLY
663  void operator+=(OUString const &) && = delete;
664 #endif
665 
672  template<typename T>
674  operator +=(T & literal)
675 #if defined LIBO_INTERNAL_ONLY
676  &
677 #endif
678  {
679  assert(
682  &pData, pData,
685  return *this;
686  }
687 #if defined LIBO_INTERNAL_ONLY
688  template<typename T>
690  operator +=(T &) && = delete;
691 #endif
692 
693 #if defined LIBO_INTERNAL_ONLY
694 
695  template<typename T>
696  typename
698  operator +=(T & literal) & {
700  &pData, pData,
703  return *this;
704  }
705  template<typename T>
706  typename
707  libreoffice_internal::ConstCharArrayDetector<T, OUString &>::TypeUtf16
708  operator +=(T &) && = delete;
709 
711  template<std::size_t N> OUString & operator +=(OUStringLiteral<N> const & literal) & {
712  rtl_uString_newConcatUtf16L(&pData, pData, literal.getStr(), literal.getLength());
713  return *this;
714  }
715  template<std::size_t N> void operator +=(OUStringLiteral<N> const &) && = delete;
716 
717  OUString & operator +=(std::u16string_view sv) & {
718  if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
719  throw std::bad_alloc();
720  }
721  rtl_uString_newConcatUtf16L(&pData, pData, sv.data(), sv.size());
722  return *this;
723  }
724  void operator +=(std::u16string_view) && = delete;
725 #endif
726 
727 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
728 
732  template< typename T1, typename T2 >
733  OUString& operator+=( OUStringConcat< T1, T2 >&& c ) & {
734  sal_Int32 l = c.length();
735  if( l == 0 )
736  return *this;
737  l += pData->length;
738  rtl_uString_ensureCapacity( &pData, l );
739  sal_Unicode* end = c.addData( pData->buffer + pData->length );
740  *end = '\0';
741  pData->length = l;
742  return *this;
743  }
744  template<typename T1, typename T2> void operator +=(
745  OUStringConcat<T1, T2> &&) && = delete;
746 
751  template< typename T, std::size_t N >
752  OUString& operator+=( StringNumberBase< sal_Unicode, T, N >&& n ) & {
753  sal_Int32 l = n.length;
754  if( l == 0 )
755  return *this;
756  l += pData->length;
757  rtl_uString_ensureCapacity( &pData, l );
758  sal_Unicode* end = addDataHelper( pData->buffer + pData->length, n.buf, n.length );
759  *end = '\0';
760  pData->length = l;
761  return *this;
762  }
763  template<typename T, std::size_t N> void operator +=(
764  StringNumberBase<sal_Unicode, T, N> &&) && = delete;
765 #endif
766 
771  void clear()
772  {
773  rtl_uString_new( &pData );
774  }
775 
784  sal_Int32 getLength() const { return pData->length; }
785 
794  bool isEmpty() const
795  {
796  return pData->length == 0;
797  }
798 
806  const sal_Unicode * getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
807 
817  sal_Unicode operator [](sal_Int32 index) const {
818  // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
819  assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
820  return getStr()[index];
821  }
822 
835 #if defined LIBO_INTERNAL_ONLY
836  sal_Int32 compareTo( std::u16string_view str ) const
837  {
838  return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
839  str.data(), str.length() );
840  }
841 #else
842  sal_Int32 compareTo( const OUString & str ) const
843  {
844  return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
845  str.pData->buffer, str.pData->length );
846  }
847 #endif
848 
864 #if defined LIBO_INTERNAL_ONLY
865  sal_Int32 compareTo( std::u16string_view str, sal_Int32 maxLength ) const
866  {
867  return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
868  str.data(), str.length(), maxLength );
869  }
870 #else
871  sal_Int32 compareTo( const OUString & str, sal_Int32 maxLength ) const
872  {
873  return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
874  str.pData->buffer, str.pData->length, maxLength );
875  }
876 #endif
877 
890 #if defined LIBO_INTERNAL_ONLY
891  sal_Int32 reverseCompareTo(std::u16string_view sv) const {
893  pData->buffer, pData->length, sv.data(), sv.size());
894  }
895 #else
896  sal_Int32 reverseCompareTo( const OUString & str ) const
897  {
898  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
899  str.pData->buffer, str.pData->length );
900  }
901 #endif
902 
908  template< typename T >
910  {
911  assert(
914  pData->buffer, pData->length,
917  }
918 
930  bool equals( const OUString & str ) const
931  {
932  if ( pData->length != str.pData->length )
933  return false;
934  if ( pData == str.pData )
935  return true;
936  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
937  str.pData->buffer, str.pData->length ) == 0;
938  }
939 
954 #if defined LIBO_INTERNAL_ONLY
955  bool equalsIgnoreAsciiCase(std::u16string_view sv) const {
956  if ( sal_uInt32(pData->length) != sv.size() )
957  return false;
958  if ( pData->buffer == sv.data() )
959  return true;
960  return
962  pData->buffer, pData->length, sv.data(), sv.size())
963  == 0;
964  }
965 #else
966  bool equalsIgnoreAsciiCase( const OUString & str ) const
967  {
968  if ( pData->length != str.pData->length )
969  return false;
970  if ( pData == str.pData )
971  return true;
972  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
973  str.pData->buffer, str.pData->length ) == 0;
974  }
975 #endif
976 
992 #if defined LIBO_INTERNAL_ONLY
993  sal_Int32 compareToIgnoreAsciiCase(std::u16string_view sv) const {
995  pData->buffer, pData->length, sv.data(), sv.size());
996  }
997 #else
998  sal_Int32 compareToIgnoreAsciiCase( const OUString & str ) const
999  {
1000  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
1001  str.pData->buffer, str.pData->length );
1002  }
1003 #endif
1004 
1010  template< typename T >
1012  {
1013  assert(
1015  return
1016  (pData->length
1019  pData->buffer, pData->length,
1021  literal))
1022  == 0);
1023  }
1024 
1040 #if defined LIBO_INTERNAL_ONLY
1041  bool match(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
1042  return
1044  pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1045  sv.size())
1046  == 0;
1047  }
1048 #else
1049  bool match( const OUString & str, sal_Int32 fromIndex = 0 ) const
1050  {
1051  return rtl_ustr_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1052  str.pData->buffer, str.pData->length, str.pData->length ) == 0;
1053  }
1054 #endif
1055 
1061  template< typename T >
1062  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
1063  {
1064  assert(
1066  return
1068  pData->buffer+fromIndex, pData->length-fromIndex,
1070  literal),
1072  == 0;
1073  }
1074 
1093 #if defined LIBO_INTERNAL_ONLY
1094  bool matchIgnoreAsciiCase(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
1095  return
1097  pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1098  sv.size())
1099  == 0;
1100  }
1101 #else
1102  bool matchIgnoreAsciiCase( const OUString & str, sal_Int32 fromIndex = 0 ) const
1103  {
1104  return rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1105  str.pData->buffer, str.pData->length,
1106  str.pData->length ) == 0;
1107  }
1108 #endif
1109 
1115  template< typename T >
1116  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
1117  {
1118  assert(
1120  return matchIgnoreAsciiCaseAsciiL(
1123  }
1124 
1141  sal_Int32 compareToAscii( const char* asciiStr ) const
1142  {
1143  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length, asciiStr );
1144  }
1145 
1169  "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
1170  sal_Int32 compareToAscii( const char * asciiStr, sal_Int32 maxLength ) const
1171  {
1172  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer, pData->length,
1173  asciiStr, maxLength );
1174  }
1175 
1194  sal_Int32 reverseCompareToAsciiL( const char * asciiStr, sal_Int32 asciiStrLength ) const
1195  {
1196  return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
1197  asciiStr, asciiStrLength );
1198  }
1199 
1215  bool equalsAscii( const char* asciiStr ) const
1216  {
1217  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length,
1218  asciiStr ) == 0;
1219  }
1220 
1237  bool equalsAsciiL( const char* asciiStr, sal_Int32 asciiStrLength ) const
1238  {
1239  if ( pData->length != asciiStrLength )
1240  return false;
1241 
1243  pData->buffer, asciiStr, asciiStrLength );
1244  }
1245 
1264  bool equalsIgnoreAsciiCaseAscii( const char * asciiStr ) const
1265  {
1266  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1267  }
1268 
1287  sal_Int32 compareToIgnoreAsciiCaseAscii( const char * asciiStr ) const
1288  {
1289  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr );
1290  }
1291 
1311  bool equalsIgnoreAsciiCaseAsciiL( const char * asciiStr, sal_Int32 asciiStrLength ) const
1312  {
1313  if ( pData->length != asciiStrLength )
1314  return false;
1315 
1316  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1317  }
1318 
1339  bool matchAsciiL( const char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1340  {
1341  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1342  asciiStr, asciiStrLength ) == 0;
1343  }
1344 
1345  // This overload is left undefined, to detect calls of matchAsciiL that
1346  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1347  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1348  // platforms):
1349 #if SAL_TYPES_SIZEOFLONG == 8
1350  void matchAsciiL(char const *, sal_Int32, rtl_TextEncoding) const;
1351 #endif
1352 
1376  bool matchIgnoreAsciiCaseAsciiL( const char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1377  {
1378  return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1379  asciiStr, asciiStrLength ) == 0;
1380  }
1381 
1382  // This overload is left undefined, to detect calls of
1383  // matchIgnoreAsciiCaseAsciiL that erroneously use
1384  // RTL_CONSTASCII_USTRINGPARAM instead of RTL_CONSTASCII_STRINGPARAM (but
1385  // would lead to ambiguities on 32 bit platforms):
1386 #if SAL_TYPES_SIZEOFLONG == 8
1387  void matchIgnoreAsciiCaseAsciiL(char const *, sal_Int32, rtl_TextEncoding)
1388  const;
1389 #endif
1390 
1405 #if defined LIBO_INTERNAL_ONLY
1406  bool startsWith(std::u16string_view sv, OUString * rest = nullptr) const {
1407  auto const b = match(sv);
1408  if (b && rest != nullptr) {
1409  *rest = copy(sv.size());
1410  }
1411  return b;
1412  }
1413 #else
1414  bool startsWith(OUString const & str, OUString * rest = NULL) const {
1415  bool b = match(str);
1416  if (b && rest != NULL) {
1417  *rest = copy(str.getLength());
1418  }
1419  return b;
1420  }
1421 #endif
1422 
1428  template< typename T >
1430  T & literal, OUString * rest = NULL) const
1431  {
1432  assert(
1434  bool b
1436  <= sal_uInt32(pData->length))
1438  pData->buffer,
1440  literal),
1442  if (b && rest != NULL) {
1443  *rest = copy(
1445  }
1446  return b;
1447  }
1448 
1469 #if defined LIBO_INTERNAL_ONLY
1470  bool startsWithIgnoreAsciiCase(std::u16string_view sv, OUString * rest = nullptr) const {
1471  auto const b = matchIgnoreAsciiCase(sv);
1472  if (b && rest != nullptr) {
1473  *rest = copy(sv.size());
1474  }
1475  return b;
1476  }
1477 #else
1478  bool startsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL)
1479  const
1480  {
1481  bool b = matchIgnoreAsciiCase(str);
1482  if (b && rest != NULL) {
1483  *rest = copy(str.getLength());
1484  }
1485  return b;
1486  }
1487 #endif
1488 
1494  template< typename T >
1496  startsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1497  {
1498  assert(
1500  bool b
1502  <= sal_uInt32(pData->length))
1504  pData->buffer,
1507  literal),
1509  == 0);
1510  if (b && rest != NULL) {
1511  *rest = copy(
1513  }
1514  return b;
1515  }
1516 
1531 #if defined LIBO_INTERNAL_ONLY
1532  bool endsWith(std::u16string_view sv, OUString * rest = nullptr) const {
1533  auto const b = sv.size() <= sal_uInt32(pData->length)
1534  && match(sv, pData->length - sv.size());
1535  if (b && rest != nullptr) {
1536  *rest = copy(0, (pData->length - sv.size()));
1537  }
1538  return b;
1539  }
1540 #else
1541  bool endsWith(OUString const & str, OUString * rest = NULL) const {
1542  bool b = str.getLength() <= getLength()
1543  && match(str, getLength() - str.getLength());
1544  if (b && rest != NULL) {
1545  *rest = copy(0, getLength() - str.getLength());
1546  }
1547  return b;
1548  }
1549 #endif
1550 
1556  template< typename T >
1558  endsWith(T & literal, OUString * rest = NULL) const
1559  {
1560  assert(
1562  bool b
1564  <= sal_uInt32(pData->length))
1566  (pData->buffer + pData->length
1569  literal),
1571  if (b && rest != NULL) {
1572  *rest = copy(
1573  0,
1574  (getLength()
1576  }
1577  return b;
1578  }
1579 
1591  bool endsWithAsciiL(char const * asciiStr, sal_Int32 asciiStrLength)
1592  const
1593  {
1594  return asciiStrLength <= pData->length
1596  pData->buffer + pData->length - asciiStrLength, asciiStr,
1597  asciiStrLength);
1598  }
1599 
1620 #if defined LIBO_INTERNAL_ONLY
1621  bool endsWithIgnoreAsciiCase(std::u16string_view sv, OUString * rest = nullptr) const {
1622  auto const b = sv.size() <= sal_uInt32(pData->length)
1623  && matchIgnoreAsciiCase(sv, pData->length - sv.size());
1624  if (b && rest != nullptr) {
1625  *rest = copy(0, pData->length - sv.size());
1626  }
1627  return b;
1628  }
1629 #else
1630  bool endsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL) const
1631  {
1632  bool b = str.getLength() <= getLength()
1633  && matchIgnoreAsciiCase(str, getLength() - str.getLength());
1634  if (b && rest != NULL) {
1635  *rest = copy(0, getLength() - str.getLength());
1636  }
1637  return b;
1638  }
1639 #endif
1640 
1646  template< typename T >
1648  endsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1649  {
1650  assert(
1652  bool b
1654  <= sal_uInt32(pData->length))
1656  (pData->buffer + pData->length
1660  literal),
1662  == 0);
1663  if (b && rest != NULL) {
1664  *rest = copy(
1665  0,
1666  (getLength()
1668  }
1669  return b;
1670  }
1671 
1683  char const * asciiStr, sal_Int32 asciiStrLength) const
1684  {
1685  return asciiStrLength <= pData->length
1687  pData->buffer + pData->length - asciiStrLength,
1688  asciiStrLength, asciiStr, asciiStrLength)
1689  == 0);
1690  }
1691 
1692  friend bool operator == ( const OUString& rStr1, const OUString& rStr2 )
1693  { return rStr1.equals(rStr2); }
1694 
1695  friend bool operator != ( const OUString& rStr1, const OUString& rStr2 )
1696  { return !(operator == ( rStr1, rStr2 )); }
1697 
1698  friend bool operator < ( const OUString& rStr1, const OUString& rStr2 )
1699  { return rStr1.compareTo( rStr2 ) < 0; }
1700  friend bool operator > ( const OUString& rStr1, const OUString& rStr2 )
1701  { return rStr1.compareTo( rStr2 ) > 0; }
1702  friend bool operator <= ( const OUString& rStr1, const OUString& rStr2 )
1703  { return rStr1.compareTo( rStr2 ) <= 0; }
1704  friend bool operator >= ( const OUString& rStr1, const OUString& rStr2 )
1705  { return rStr1.compareTo( rStr2 ) >= 0; }
1706 
1707 #if defined LIBO_INTERNAL_ONLY
1708 
1709  template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1710  operator ==(OUString const & s1, T const & s2) {
1712  == 0;
1713  }
1714 
1715  template<typename T>
1716  friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1717  operator ==(OUString const & s1, T & s2) {
1718  return rtl_ustr_compare_WithLength(s1.getStr(), s1.getLength(), s2, rtl_ustr_getLength(s2))
1719  == 0;
1720  }
1721 
1722  template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1723  operator ==(T const & s1, OUString const & s2) {
1724  return rtl_ustr_compare_WithLength(s1, rtl_ustr_getLength(s1), s2.getStr(), s2.getLength())
1725  == 0;
1726  }
1727 
1728  template<typename T>
1729  friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1730  operator ==(T & s1, OUString const & s2) {
1731  return rtl_ustr_compare_WithLength(s1, rtl_ustr_getLength(s1), s2.getStr(), s2.getLength())
1732  == 0;
1733  }
1734 
1735  template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1736  operator !=(OUString const & s1, T const & s2) { return !(s1 == s2); }
1737 
1738  template<typename T>
1739  friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1740  operator !=(OUString const & s1, T & s2) { return !(s1 == s2); }
1741 
1742  template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1743  operator !=(T const & s1, OUString const & s2) { return !(s1 == s2); }
1744 
1745  template<typename T>
1746  friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1747  operator !=(T & s1, OUString const & s2) { return !(s1 == s2); }
1748 
1749 #else
1750 
1751  friend bool operator == ( const OUString& rStr1, const sal_Unicode * pStr2 )
1752  { return rStr1.compareTo( pStr2 ) == 0; }
1753  friend bool operator == ( const sal_Unicode * pStr1, const OUString& rStr2 )
1754  { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
1755 
1756  friend bool operator != ( const OUString& rStr1, const sal_Unicode * pStr2 )
1757  { return !(operator == ( rStr1, pStr2 )); }
1758  friend bool operator != ( const sal_Unicode * pStr1, const OUString& rStr2 )
1759  { return !(operator == ( pStr1, rStr2 )); }
1760 
1761 #endif
1762 
1770  template< typename T >
1772  {
1773  assert(
1775  return rString.equalsAsciiL(
1778  }
1786  template< typename T >
1788  {
1789  assert(
1791  return rString.equalsAsciiL(
1794  }
1802  template< typename T >
1804  {
1805  assert(
1807  return !rString.equalsAsciiL(
1810  }
1818  template< typename T >
1820  {
1821  assert(
1823  return !rString.equalsAsciiL(
1826  }
1827 
1828 #if defined LIBO_INTERNAL_ONLY
1829 
1830  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1831  operator ==(OUString const & string, T & literal) {
1832  return
1834  string.pData->buffer, string.pData->length,
1836  literal),
1838  == 0;
1839  }
1841  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1842  operator ==(T & literal, OUString const & string) {
1843  return
1845  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1846  literal),
1847  libreoffice_internal::ConstCharArrayDetector<T>::length,
1848  string.pData->buffer, string.pData->length)
1849  == 0;
1850  }
1852  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1853  operator !=(OUString const & string, T & literal) {
1854  return
1856  string.pData->buffer, string.pData->length,
1857  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1858  literal),
1859  libreoffice_internal::ConstCharArrayDetector<T>::length)
1860  != 0;
1861  }
1863  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1864  operator !=(T & literal, OUString const & string) {
1865  return
1867  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1868  literal),
1869  libreoffice_internal::ConstCharArrayDetector<T>::length,
1870  string.pData->buffer, string.pData->length)
1871  != 0;
1872  }
1873 #endif
1874 
1882  sal_Int32 hashCode() const
1883  {
1884  return rtl_ustr_hashCode_WithLength( pData->buffer, pData->length );
1885  }
1886 
1900  sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
1901  {
1902  sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1903  return (ret < 0 ? ret : ret+fromIndex);
1904  }
1905 
1915  sal_Int32 lastIndexOf( sal_Unicode ch ) const
1916  {
1917  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1918  }
1919 
1932  sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
1933  {
1934  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1935  }
1936 
1952 #if defined LIBO_INTERNAL_ONLY
1953  sal_Int32 indexOf(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
1954  auto const n = rtl_ustr_indexOfStr_WithLength(
1955  pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size());
1956  return n < 0 ? n : n + fromIndex;
1957  }
1958 #else
1959  sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
1960  {
1961  sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1962  str.pData->buffer, str.pData->length );
1963  return (ret < 0 ? ret : ret+fromIndex);
1964  }
1965 #endif
1966 
1972  template< typename T >
1973  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1974  {
1975  assert(
1977  sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
1978  pData->buffer + fromIndex, pData->length - fromIndex,
1981  return n < 0 ? n : n + fromIndex;
1982  }
1983 
2007  sal_Int32 indexOfAsciiL(
2008  char const * str, sal_Int32 len, sal_Int32 fromIndex = 0) const
2009  {
2010  sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
2011  pData->buffer + fromIndex, pData->length - fromIndex, str, len);
2012  return ret < 0 ? ret : ret + fromIndex;
2013  }
2014 
2015  // This overload is left undefined, to detect calls of indexOfAsciiL that
2016  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
2017  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
2018  // platforms):
2019 #if SAL_TYPES_SIZEOFLONG == 8
2020  void indexOfAsciiL(char const *, sal_Int32 len, rtl_TextEncoding) const;
2021 #endif
2022 
2038 #if defined LIBO_INTERNAL_ONLY
2039  sal_Int32 lastIndexOf(std::u16string_view sv) const {
2041  pData->buffer, pData->length, sv.data(), sv.size());
2042  }
2043 #else
2044  sal_Int32 lastIndexOf( const OUString & str ) const
2045  {
2046  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
2047  str.pData->buffer, str.pData->length );
2048  }
2049 #endif
2050 
2068 #if defined LIBO_INTERNAL_ONLY
2069  sal_Int32 lastIndexOf(std::u16string_view sv, sal_Int32 fromIndex) const {
2070  return rtl_ustr_lastIndexOfStr_WithLength(pData->buffer, fromIndex, sv.data(), sv.size());
2071  }
2072 #else
2073  sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
2074  {
2075  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
2076  str.pData->buffer, str.pData->length );
2077  }
2078 #endif
2079 
2085  template< typename T >
2087  {
2088  assert(
2091  pData->buffer, pData->length,
2094  }
2095 
2115  sal_Int32 lastIndexOfAsciiL(char const * str, sal_Int32 len) const
2116  {
2118  pData->buffer, pData->length, str, len);
2119  }
2120 
2131  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex ) const
2132  {
2133  return copy(beginIndex, getLength() - beginIndex);
2134  }
2135 
2148  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const
2149  {
2150  rtl_uString *pNew = NULL;
2151  rtl_uString_newFromSubString( &pNew, pData, beginIndex, count );
2152  return OUString( pNew, SAL_NO_ACQUIRE );
2153  }
2154 
2155 #if defined LIBO_INTERNAL_ONLY
2156 
2166  SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex ) const
2167  {
2168  assert(beginIndex >= 0);
2169  assert(beginIndex <= getLength());
2170  return subView(beginIndex, getLength() - beginIndex);
2171  }
2172 
2185  SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex, sal_Int32 count ) const
2186  {
2187  assert(beginIndex >= 0);
2188  assert(count >= 0);
2189  assert(beginIndex <= getLength());
2190  assert(count <= getLength() - beginIndex);
2191  return std::u16string_view(*this).substr(beginIndex, count);
2192  }
2193 #endif
2194 
2195 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2196 
2205  {
2206  rtl_uString* pNew = NULL;
2207  rtl_uString_newConcat( &pNew, pData, str.pData );
2208  return OUString( pNew, SAL_NO_ACQUIRE );
2209  }
2210 #endif
2211 
2212 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2213  friend OUString operator+( const OUString& rStr1, const OUString& rStr2 )
2214  {
2215  return rStr1.concat( rStr2 );
2216  }
2217 #endif
2218 
2219 // hide this from internal code to avoid ambiguous lookup error
2220 #ifndef LIBO_INTERNAL_ONLY
2221 
2234  SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const
2235  {
2236  rtl_uString* pNew = NULL;
2237  rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
2238  return OUString( pNew, SAL_NO_ACQUIRE );
2239  }
2240 #endif
2241 
2242 #ifdef LIBO_INTERNAL_ONLY
2243  SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, std::u16string_view newStr ) const
2244  {
2245  rtl_uString* pNew = NULL;
2246  rtl_uString_newReplaceStrAtUtf16L( &pNew, pData, index, count, newStr.data(), newStr.size() );
2247  return OUString( pNew, SAL_NO_ACQUIRE );
2248  }
2249 #endif
2250 
2265  {
2266  rtl_uString* pNew = NULL;
2267  rtl_uString_newReplace( &pNew, pData, oldChar, newChar );
2268  return OUString( pNew, SAL_NO_ACQUIRE );
2269  }
2270 
2289 #if defined LIBO_INTERNAL_ONLY
2290  [[nodiscard]] OUString replaceFirst(
2291  std::u16string_view from, std::u16string_view to, sal_Int32 * index = nullptr) const
2292  {
2293  rtl_uString * s = nullptr;
2294  sal_Int32 i = 0;
2296  &s, pData, from.data(), from.size(), to.data(), to.size(),
2297  index == nullptr ? &i : index);
2298  return OUString(s, SAL_NO_ACQUIRE);
2299  }
2300 #else
2302  OUString const & from, OUString const & to, sal_Int32 * index = NULL) const
2303  {
2304  rtl_uString * s = NULL;
2305  sal_Int32 i = 0;
2307  &s, pData, from.pData, to.pData, index == NULL ? &i : index);
2308  return OUString(s, SAL_NO_ACQUIRE);
2309  }
2310 #endif
2311 
2330 #if defined LIBO_INTERNAL_ONLY
2331  template<typename T> [[nodiscard]]
2333  T & from, std::u16string_view to, sal_Int32 * index = nullptr) const
2334  {
2336  rtl_uString * s = nullptr;
2337  sal_Int32 i = 0;
2341  index == nullptr ? &i : index);
2342  return OUString(s, SAL_NO_ACQUIRE);
2343  }
2344 #else
2345  template< typename T >
2347  sal_Int32 * index = NULL) const
2348  {
2350  rtl_uString * s = NULL;
2351  sal_Int32 i = 0;
2353  &s, pData,
2356  index == NULL ? &i : index);
2357  return OUString(s, SAL_NO_ACQUIRE);
2358  }
2359 #endif
2360 
2379 #if defined LIBO_INTERNAL_ONLY
2380  template<typename T> [[nodiscard]]
2382  std::u16string_view from, T & to, sal_Int32 * index = nullptr) const
2383  {
2385  rtl_uString * s = nullptr;
2386  sal_Int32 i = 0;
2388  &s, pData, from.data(), from.size(),
2390  libreoffice_internal::ConstCharArrayDetector<T>::length, index == nullptr ? &i : index);
2391  return OUString(s, SAL_NO_ACQUIRE);
2392  }
2393 #else
2394  template< typename T >
2396  sal_Int32 * index = NULL) const
2397  {
2399  rtl_uString * s = NULL;
2400  sal_Int32 i = 0;
2402  &s, pData, from.pData,
2405  index == NULL ? &i : index);
2406  return OUString(s, SAL_NO_ACQUIRE);
2407  }
2408 #endif
2409 
2428  template< typename T1, typename T2 >
2430  replaceFirst( T1& from, T2& to, sal_Int32 * index = NULL) const
2431  {
2434  rtl_uString * s = NULL;
2435  sal_Int32 i = 0;
2437  &s, pData,
2442  index == NULL ? &i : index);
2443  return OUString(s, SAL_NO_ACQUIRE);
2444  }
2445 
2461 #if defined LIBO_INTERNAL_ONLY
2462  [[nodiscard]] OUString replaceAll(
2463  std::u16string_view from, std::u16string_view to, sal_Int32 fromIndex = 0) const
2464  {
2465  rtl_uString * s = nullptr;
2466  rtl_uString_newReplaceAllFromIndexUtf16LUtf16L(
2467  &s, pData, from.data(), from.size(), to.data(), to.size(), fromIndex);
2468  return OUString(s, SAL_NO_ACQUIRE);
2469  }
2470 #else
2472  OUString const & from, OUString const & to, sal_Int32 fromIndex = 0) const
2473  {
2474  rtl_uString * s = NULL;
2475  rtl_uString_newReplaceAllFromIndex(&s, pData, from.pData, to.pData, fromIndex);
2476  return OUString(s, SAL_NO_ACQUIRE);
2477  }
2478 #endif
2479 
2493 #if defined LIBO_INTERNAL_ONLY
2494  template<typename T> [[nodiscard]]
2496  T & from, std::u16string_view to) const
2497  {
2499  rtl_uString * s = nullptr;
2503  return OUString(s, SAL_NO_ACQUIRE);
2504  }
2505 #else
2506  template< typename T >
2508  {
2510  rtl_uString * s = NULL;
2512  &s, pData,
2515  return OUString(s, SAL_NO_ACQUIRE);
2516  }
2517 #endif
2518 
2532 #if defined LIBO_INTERNAL_ONLY
2533  template<typename T> [[nodiscard]]
2535  std::u16string_view from, T & to) const
2536  {
2538  rtl_uString * s = nullptr;
2540  &s, pData, from.data(), from.size(),
2543  return OUString(s, SAL_NO_ACQUIRE);
2544  }
2545 #else
2546  template< typename T >
2548  {
2550  rtl_uString * s = NULL;
2552  &s, pData, from.pData,
2555  return OUString(s, SAL_NO_ACQUIRE);
2556  }
2557 #endif
2558 
2572  template< typename T1, typename T2 >
2574  replaceAll( T1& from, T2& to ) const
2575  {
2578  rtl_uString * s = NULL;
2580  &s, pData,
2585  return OUString(s, SAL_NO_ACQUIRE);
2586  }
2587 
2599  {
2600  rtl_uString* pNew = NULL;
2601  rtl_uString_newToAsciiLowerCase( &pNew, pData );
2602  return OUString( pNew, SAL_NO_ACQUIRE );
2603  }
2604 
2616  {
2617  rtl_uString* pNew = NULL;
2618  rtl_uString_newToAsciiUpperCase( &pNew, pData );
2619  return OUString( pNew, SAL_NO_ACQUIRE );
2620  }
2621 
2636  {
2637  rtl_uString* pNew = NULL;
2638  rtl_uString_newTrim( &pNew, pData );
2639  return OUString( pNew, SAL_NO_ACQUIRE );
2640  }
2641 
2666  OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const
2667  {
2668  rtl_uString * pNew = NULL;
2669  index = rtl_uString_getToken( &pNew, pData, token, cTok, index );
2670  return OUString( pNew, SAL_NO_ACQUIRE );
2671  }
2672 
2686  OUString getToken(sal_Int32 count, sal_Unicode separator) const {
2687  sal_Int32 n = 0;
2688  return getToken(count, separator, n);
2689  }
2690 
2699  bool toBoolean() const
2700  {
2701  return rtl_ustr_toBoolean( pData->buffer );
2702  }
2703 
2711  {
2712  return pData->buffer[0];
2713  }
2714 
2725  sal_Int32 toInt32( sal_Int16 radix = 10 ) const
2726  {
2727  return rtl_ustr_toInt32( pData->buffer, radix );
2728  }
2729 
2742  sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
2743  {
2744  return rtl_ustr_toUInt32( pData->buffer, radix );
2745  }
2746 
2757  sal_Int64 toInt64( sal_Int16 radix = 10 ) const
2758  {
2759  return rtl_ustr_toInt64( pData->buffer, radix );
2760  }
2761 
2774  sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
2775  {
2776  return rtl_ustr_toUInt64( pData->buffer, radix );
2777  }
2778 
2787  float toFloat() const
2788  {
2789  return rtl_ustr_toFloat( pData->buffer );
2790  }
2791 
2800  double toDouble() const
2801  {
2802  return rtl_ustr_toDouble( pData->buffer );
2803  }
2804 
2805 
2822  {
2823  rtl_uString * pNew = NULL;
2824  rtl_uString_intern( &pNew, pData );
2825  if (pNew == NULL) {
2826  throw std::bad_alloc();
2827  }
2828  return OUString( pNew, SAL_NO_ACQUIRE );
2829  }
2830 
2856  static OUString intern( const char * value, sal_Int32 length,
2857  rtl_TextEncoding encoding,
2858  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS,
2859  sal_uInt32 *pInfo = NULL )
2860  {
2861  rtl_uString * pNew = NULL;
2862  rtl_uString_internConvert( &pNew, value, length, encoding,
2863  convertFlags, pInfo );
2864  if (pNew == NULL) {
2865  throw std::bad_alloc();
2866  }
2867  return OUString( pNew, SAL_NO_ACQUIRE );
2868  }
2869 
2894  bool convertToString(OString * pTarget, rtl_TextEncoding nEncoding,
2895  sal_uInt32 nFlags) const
2896  {
2897  return rtl_convertUStringToString(&pTarget->pData, pData->buffer,
2898  pData->length, nEncoding, nFlags);
2899  }
2900 
2952  sal_uInt32 iterateCodePoints(
2953  sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1) const
2954  {
2956  pData, indexUtf16, incrementCodePoints);
2957  }
2958 
2968 #if defined LIBO_INTERNAL_ONLY
2969  static OUString fromUtf8(std::string_view rSource)
2970  {
2971  OUString aTarget;
2972  bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
2973  rSource.data(),
2974  rSource.length(),
2977  (void) bSuccess;
2978  assert(bSuccess);
2979  return aTarget;
2980  }
2981 #else
2982  static OUString fromUtf8(const OString& rSource)
2983  {
2984  OUString aTarget;
2985  bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
2986  rSource.getStr(),
2987  rSource.getLength(),
2990  (void) bSuccess;
2991  assert(bSuccess);
2992  return aTarget;
2993  }
2994 #endif
2995 
3006  OString toUtf8() const
3007  {
3008  OString aTarget;
3009  bool bSuccess = rtl_convertUStringToString(&aTarget.pData,
3010  getStr(),
3011  getLength(),
3014  (void) bSuccess;
3015  assert(bSuccess);
3016  return aTarget;
3017  }
3018 
3019 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3020 
3021  static OUStringNumber< int > number( int i, sal_Int16 radix = 10 )
3022  {
3023  return OUStringNumber< int >( i, radix );
3024  }
3025  static OUStringNumber< long long > number( long long ll, sal_Int16 radix = 10 )
3026  {
3027  return OUStringNumber< long long >( ll, radix );
3028  }
3029  static OUStringNumber< unsigned long long > number( unsigned long long ll, sal_Int16 radix = 10 )
3030  {
3031  return OUStringNumber< unsigned long long >( ll, radix );
3032  }
3033  static OUStringNumber< unsigned long long > number( unsigned int i, sal_Int16 radix = 10 )
3034  {
3035  return number( static_cast< unsigned long long >( i ), radix );
3036  }
3037  static OUStringNumber< long long > number( long i, sal_Int16 radix = 10)
3038  {
3039  return number( static_cast< long long >( i ), radix );
3040  }
3041  static OUStringNumber< unsigned long long > number( unsigned long i, sal_Int16 radix = 10 )
3042  {
3043  return number( static_cast< unsigned long long >( i ), radix );
3044  }
3045  static OUStringNumber< float > number( float f )
3046  {
3047  return OUStringNumber< float >( f );
3048  }
3049  static OUStringNumber< double > number( double d )
3050  {
3051  return OUStringNumber< double >( d );
3052  }
3053 #else
3054 
3064  static OUString number( int i, sal_Int16 radix = 10 )
3065  {
3067  return OUString(aBuf, rtl_ustr_valueOfInt32(aBuf, i, radix));
3068  }
3071  static OUString number( unsigned int i, sal_Int16 radix = 10 )
3072  {
3073  return number( static_cast< unsigned long long >( i ), radix );
3074  }
3077  static OUString number( long i, sal_Int16 radix = 10)
3078  {
3079  return number( static_cast< long long >( i ), radix );
3080  }
3083  static OUString number( unsigned long i, sal_Int16 radix = 10 )
3084  {
3085  return number( static_cast< unsigned long long >( i ), radix );
3086  }
3089  static OUString number( long long ll, sal_Int16 radix = 10 )
3090  {
3092  return OUString(aBuf, rtl_ustr_valueOfInt64(aBuf, ll, radix));
3093  }
3096  static OUString number( unsigned long long ll, sal_Int16 radix = 10 )
3097  {
3099  return OUString(aBuf, rtl_ustr_valueOfUInt64(aBuf, ll, radix));
3100  }
3101 
3111  static OUString number( float f )
3112  {
3114  return OUString(aBuf, rtl_ustr_valueOfFloat(aBuf, f));
3115  }
3116 
3126  static OUString number( double d )
3127  {
3129  return OUString(aBuf, rtl_ustr_valueOfDouble(aBuf, d));
3130  }
3131 #endif
3132 
3144  SAL_DEPRECATED("use boolean()") static OUString valueOf( sal_Bool b )
3145  {
3146  return boolean(b);
3147  }
3148 
3160  static OUString boolean( bool b )
3161  {
3163  return OUString(aBuf, rtl_ustr_valueOfBoolean(aBuf, b));
3164  }
3165 
3173  SAL_DEPRECATED("convert to OUString or use directly") static OUString valueOf( sal_Unicode c )
3174  {
3175  return OUString( &c, 1 );
3176  }
3177 
3188  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
3189  {
3190  return number( i, radix );
3191  }
3192 
3203  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
3204  {
3205  return number( ll, radix );
3206  }
3207 
3217  SAL_DEPRECATED("use number()") static OUString valueOf( float f )
3218  {
3219  return number(f);
3220  }
3221 
3231  SAL_DEPRECATED("use number()") static OUString valueOf( double d )
3232  {
3233  return number(d);
3234  }
3235 
3251  static OUString createFromAscii( const char * value )
3252  {
3253  rtl_uString* pNew = NULL;
3254  rtl_uString_newFromAscii( &pNew, value );
3255  return OUString( pNew, SAL_NO_ACQUIRE );
3256  }
3257 
3258 #if defined LIBO_INTERNAL_ONLY
3259  static OUString createFromAscii(std::string_view value) {
3260  rtl_uString * p = nullptr;
3261  rtl_uString_newFromLiteral(&p, value.data(), value.size(), 0); //TODO: check for overflow
3262  return OUString(p, SAL_NO_ACQUIRE);
3263  }
3264  #endif
3265 
3266 #if defined LIBO_INTERNAL_ONLY
3267  operator std::u16string_view() const { return {getStr(), sal_uInt32(getLength())}; }
3268 #endif
3269 
3270 #if defined LIBO_INTERNAL_ONLY
3271  // A wrapper for the first expression in an
3272  //
3273  // OUString::Concat(e1) + e2 + ...
3274  //
3275  // concatenation chain, when neither of the first two e1, e2 is one of our rtl string-related
3276  // classes (so something like
3277  //
3278  // OUString s = "a" + (b ? std::u16string_view(u"c") : std::u16string_view(u"dd"));
3279  //
3280  // would not compile):
3281  template<typename T> [[nodiscard]] static
3282  OUStringConcat<OUStringConcatMarker, T>
3283  Concat(T const & value) { return OUStringConcat<OUStringConcatMarker, T>({}, value); }
3284 
3285  // This overload is needed so that an argument of type 'char const[N]' ends up as
3286  // 'OUStringConcat<rtl::OUStringConcatMarker, char const[N]>' rather than as
3287  // 'OUStringConcat<rtl::OUStringConcatMarker, char[N]>':
3288  template<typename T, std::size_t N> [[nodiscard]] static
3289  OUStringConcat<OUStringConcatMarker, T[N]>
3290  Concat(T (& value)[N]) { return OUStringConcat<OUStringConcatMarker, T[N]>({}, value); }
3291 #endif
3292 
3293 private:
3294  OUString & internalAppend( rtl_uString* pOtherData )
3295  {
3296  rtl_uString* pNewData = NULL;
3297  rtl_uString_newConcat( &pNewData, pData, pOtherData );
3298  if (pNewData == NULL) {
3299  throw std::bad_alloc();
3300  }
3301  rtl_uString_assign(&pData, pNewData);
3302  rtl_uString_release(pNewData);
3303  return *this;
3304  }
3305 
3306 };
3307 
3308 #if defined LIBO_INTERNAL_ONLY
3309 // Can only define this after we define OUString
3310 inline OUStringConstExpr::operator const OUString &() const { return OUString::unacquired(&pData); }
3311 #endif
3312 
3313 #if defined LIBO_INTERNAL_ONLY
3314 // Prevent the operator ==/!= overloads with 'sal_Unicode const *' parameter from
3315 // being selected for nonsensical code like
3316 //
3317 // if (ouIdAttr == nullptr)
3318 //
3319 void operator ==(OUString const &, std::nullptr_t) = delete;
3320 void operator ==(std::nullptr_t, OUString const &) = delete;
3321 void operator !=(OUString const &, std::nullptr_t) = delete;
3322 void operator !=(std::nullptr_t, OUString const &) = delete;
3323 #endif
3324 
3325 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3326 inline bool operator ==(OUString const & lhs, StringConcatenation<char16_t> const & rhs)
3327 { return lhs == std::u16string_view(rhs); }
3328 inline bool operator !=(OUString const & lhs, StringConcatenation<char16_t> const & rhs)
3329 { return lhs != std::u16string_view(rhs); }
3330 inline bool operator ==(StringConcatenation<char16_t> const & lhs, OUString const & rhs)
3331 { return std::u16string_view(lhs) == rhs; }
3332 inline bool operator !=(StringConcatenation<char16_t> const & lhs, OUString const & rhs)
3333 { return std::u16string_view(lhs) != rhs; }
3334 #endif
3335 
3336 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3337 
3342 template<>
3343 struct ToStringHelper< OUString >
3344 {
3345  static std::size_t length( const OUString& s ) { return s.getLength(); }
3346  sal_Unicode* operator() ( sal_Unicode* buffer, const OUString& s ) const { return addDataHelper( buffer, s.getStr(), s.getLength()); }
3347 };
3348 
3352 template<std::size_t N>
3353 struct ToStringHelper< OUStringLiteral<N> >
3354 {
3355  static std::size_t length( const OUStringLiteral<N>& str ) { return str.getLength(); }
3356  sal_Unicode* operator()( sal_Unicode* buffer, const OUStringLiteral<N>& str ) const { return addDataHelper( buffer, str.getStr(), str.getLength() ); }
3357 };
3358 
3362 template< typename charT, typename traits, typename T1, typename T2 >
3363 inline std::basic_ostream<charT, traits> & operator <<(
3364  std::basic_ostream<charT, traits> & stream, OUStringConcat< T1, T2 >&& concat)
3365 {
3366  return stream << OUString( std::move(concat) );
3367 }
3368 
3369 
3371 #endif
3372 
3379 {
3389  size_t operator()(const OUString& rString) const
3390  { return static_cast<size_t>(rString.hashCode()); }
3391 };
3392 
3393 /* ======================================================================= */
3394 
3412 #if defined LIBO_INTERNAL_ONLY
3413 inline OUString OStringToOUString( std::string_view rStr,
3414  rtl_TextEncoding encoding,
3415  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
3416 {
3417  return OUString( rStr.data(), rStr.length(), encoding, convertFlags );
3418 }
3419 #else
3420 inline OUString OStringToOUString( const OString & rStr,
3421  rtl_TextEncoding encoding,
3422  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
3423 {
3424  return OUString( rStr.getStr(), rStr.getLength(), encoding, convertFlags );
3425 }
3426 #endif
3427 
3445 #if defined LIBO_INTERNAL_ONLY
3446 inline OString OUStringToOString( std::u16string_view rUnicode,
3447  rtl_TextEncoding encoding,
3448  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
3449 {
3450  return OString( rUnicode.data(), rUnicode.length(), encoding, convertFlags );
3451 }
3452 #else
3453 inline OString OUStringToOString( const OUString & rUnicode,
3454  rtl_TextEncoding encoding,
3455  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
3456 {
3457  return OString( rUnicode.getStr(), rUnicode.getLength(), encoding, convertFlags );
3458 }
3459 #endif
3460 
3461 /* ======================================================================= */
3462 
3471 template< typename charT, typename traits >
3472 inline std::basic_ostream<charT, traits> & operator <<(
3473  std::basic_ostream<charT, traits> & stream, OUString const & rString)
3474 {
3475  return stream <<
3477  // best effort; potentially loses data due to conversion failures
3478  // (stray surrogate halves) and embedded null characters
3479 }
3480 
3481 } // namespace
3482 
3483 #ifdef RTL_STRING_UNITTEST
3484 namespace rtl
3485 {
3486 typedef rtlunittest::OUString OUString;
3487 }
3488 #endif
3489 
3490 // In internal code, allow to use classes like OUString without having to
3491 // explicitly refer to the rtl namespace, which is kind of superfluous given
3492 // that OUString itself is namespaced by its OU prefix:
3493 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3494 using ::rtl::OUString;
3495 using ::rtl::OUStringHash;
3498 using ::rtl::OUStringLiteral;
3499 using ::rtl::OUStringChar;
3500 using ::rtl::Concat2View;
3501 #endif
3502 
3504 
3509 #if defined LIBO_INTERNAL_ONLY
3510 namespace std {
3511 
3512 template<>
3513 struct hash<::rtl::OUString>
3514 {
3515  std::size_t operator()(::rtl::OUString const & s) const
3516  {
3517  if constexpr (sizeof(std::size_t) == 8)
3518  {
3519  // return a hash that uses the full 64-bit range instead of a 32-bit value
3520  size_t n = 0;
3521  for (sal_Int32 i = 0, len = s.getLength(); i < len; ++i)
3522  n = 31 * n + s[i];
3523  return n;
3524  }
3525  else
3526  return std::size_t(s.hashCode());
3527  }
3528 };
3529 
3530 }
3531 
3532 #endif
3533 
3535 #endif /* _RTL_USTRING_HXX */
3536 
3537 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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:1558
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:1496
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition: ustring.hxx:655
bool convertToString(OString *pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) const
Converts to an OString, signalling failure.
Definition: ustring.hxx:2894
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:1116
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:2430
#define RTL_TEXTENCODING_UTF8
Definition: textenc.h:97
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:2264
double toDouble() const
Returns the double value from this string.
Definition: ustring.hxx:2800
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.
SAL_WARN_UNUSED_RESULT OUString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: ustring.hxx:2131
bool match(const OUString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:1049
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 float rtl_ustr_toFloat(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a float.
SAL_DLLPUBLIC void rtl_uString_newFromCodePoints(rtl_uString **newString, sal_uInt32 const *codePoints, sal_Int32 codePointCount) SAL_THROW_EXTERN_C()
Allocate a new string from an array of Unicode code points.
OUString & operator=(const OUString &str)
Assign a new string.
Definition: ustring.hxx:544
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...
unsigned char sal_Bool
Definition: types.h:18
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:2615
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_Int32 rtl_ustr_getLength(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Return the length of a string.
SAL_DLLPUBLIC void rtl_uString_acquire(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Increment the reference count of a string.
#define OSTRING_TO_OUSTRING_CVTFLAGS
Definition: ustring.h:2167
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:93
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 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_Int32 reverseCompareTo(const OUString &str) const
Compares two strings in reverse order.
Definition: ustring.hxx:896
OUString(const sal_Unicode *value, sal_Int32 length)
New string from a Unicode character buffer array.
Definition: ustring.hxx:308
float toFloat() const
Returns the float value from this string.
Definition: ustring.hxx:2787
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.
pData
New string from a character buffer array.
Definition: string.hxx:289
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:1376
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:17
bool equalsIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:966
sal_Int32 indexOf(const OUString &str, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
Definition: ustring.hxx:1959
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:182
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_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: ustring.hxx:2757
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:1102
#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:125
__sal_NoAcquire
Definition: types.h:332
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:2234
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:3071
bool equals(const OUString &str) const
Perform a comparison of two strings.
Definition: ustring.hxx:930
const char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:644
OUString(rtl_uString *str, __sal_NoAcquire)
New OUString from OUString data without acquiring it.
Definition: ustring.hxx:243
sal_Int32 compareToIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:998
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_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:2547
#define RTL_USTR_MAX_VALUEOFBOOLEAN
Definition: ustring.h:899
sal_Int32 lastIndexOf(const OUString &str) const
Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the end.
Definition: ustring.hxx:2044
OUString intern() const
Return a canonical representation for a string.
Definition: ustring.hxx:2821
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, rtl_uString const *to, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
sal_uInt16 sal_Unicode
Definition: types.h:103
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:73
sal_Int32 compareToIgnoreAsciiCaseAscii(const char *asciiStr) const
Compares two ASCII strings ignoring case.
Definition: ustring.hxx:1287
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1338
bool equalsAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform a comparison of two strings.
Definition: ustring.hxx:1237
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:618
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:2598
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.
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:196
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.
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:2856
bool endsWithAsciiL(char const *asciiStr, sal_Int32 asciiStrLength) const
Check whether this string ends with a given ASCII string.
Definition: ustring.hxx:1591
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...
OUString(const OUString &str)
New string from OUString.
Definition: ustring.hxx:203
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.
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:2086
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:2346
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Decrement the reference count of a string.
SAL_DLLPUBLIC void rtl_uString_assign(rtl_uString **str, rtl_uString *rightValue) SAL_THROW_EXTERN_C()
Assign a new value to a string.
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:83
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:2471
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.
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:1630
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:426
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: ustring.hxx:2742
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_Unicode toChar() const
Returns the first character from this string.
Definition: ustring.hxx:2710
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_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:2952
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.
static OUString const & unacquired(rtl_uString *const *ppHandle)
Provides an OUString const &amp; passing a storage pointer of an rtl_uString * handle.
Definition: ustring.hxx:520
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 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 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 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...
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED(&quot;Don&#39;t use, it&#39;s evil.&quot;) void doit(int nPara);.
Definition: types.h:454
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:2574
const sal_Unicode * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:806
~OUString()
Release the string data.
Definition: ustring.hxx:504
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:2301
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...
bool toBoolean() const
Returns the Boolean value from this string.
Definition: ustring.hxx:2699
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:567
sal_Int32 lastIndexOf(const OUString &str, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified substring, searching backward starting before the specified index.
Definition: ustring.hxx:2073
pData
Definition: ustring.hxx:334
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfFloat(sal_Unicode *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
sal_Int32 lastIndexOf(sal_Unicode ch) const
Returns the index within this string of the last occurrence of the specified character, searching backward starting at the end.
Definition: ustring.hxx:1915
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.
#define RTL_USTR_MAX_VALUEOFINT64
Definition: ustring.h:964
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_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_Int32 compareTo(const OUString &str, sal_Int32 maxLength) const
Compares two strings with a maximum count of characters.
Definition: ustring.hxx:871
Definition: stringutils.hxx:142
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:1973
#define RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR
Definition: textcvt.h:55
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_new(rtl_uString **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
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_Bool rtl_ustr_toBoolean(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
sal_Int32 compareToAscii(const char *asciiStr) const
Compares two strings.
Definition: ustring.hxx:1141
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_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: ustring.hxx:2725
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: ustring.hxx:2774
OUString(const sal_Unicode *value)
New string from a Unicode character buffer array.
Definition: ustring.hxx:292
OUString(rtl_uString *str)
New string from OUString data.
Definition: ustring.hxx:229
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_hashCode_WithLength(const sal_Unicode *str, sal_Int32 len) SAL_THROW_EXTERN_C()
Return a hash code for a string.
SAL_DLLPUBLIC sal_uInt32 rtl_ustr_toUInt32(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned integer.
sal_Int32 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:2007
definition of a no acquire enum for ctors
Definition: types.h:336
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:264
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_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...
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:653
bool equalsAscii(const char *asciiStr) const
Perform a comparison of two strings.
Definition: ustring.hxx:1215
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &stream, OString const &rString)
Support for rtl::OString in std::ostream (and thus in CPPUNIT_ASSERT or SAL_INFO macros, for example).
Definition: string.hxx:2338
#define RTL_USTR_MAX_VALUEOFDOUBLE
Definition: ustring.h:1025
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:3089
static OUString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: ustring.hxx:3160
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:2115
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...
A helper to use OUStrings with hash maps.
Definition: ustring.hxx:3378
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:3083
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1803
OUString()
New string containing no characters.
Definition: ustring.hxx:192
sal_Int32 reverseCompareToAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Compares two strings in reverse order.
Definition: ustring.hxx:1194
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: ustring.hxx:771
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:2395
sal_Int32 compareTo(const OUString &str) const
Compares two strings.
Definition: ustring.hxx:842
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:2148
sal_Int32 oslInterlockedCount
Definition: interlck.h:24
sal_Int32 getLength() const
Returns the length of this string.
Definition: ustring.hxx:784
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...
#define RTL_USTR_MAX_VALUEOFUINT64
Definition: ustring.h:987
SAL_DLLPUBLIC sal_Int32 rtl_uString_getToken(rtl_uString **newStr, rtl_uString *str, sal_Int32 token, sal_Unicode cTok, sal_Int32 idx) SAL_THROW_EXTERN_C()
Create a new string by extracting a single token from another string.
bool matchAsciiL(const char *asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:1339
SAL_DLLPUBLIC void rtl_uString_newTrim(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Create a new string by removing white space from both ends of another string.
OUString(sal_Unicode value)
New string from a single Unicode character.
Definition: ustring.hxx:251
sal_Int32 indexOf(sal_Unicode ch, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.
Definition: ustring.hxx:1900
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: ustring.hxx:1882
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 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_Int32 lastIndexOf(sal_Unicode ch, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified character, searching backward starting before the specified index.
Definition: ustring.hxx:1932
bool equalsIgnoreAsciiCaseAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1311
OUString(sal_uInt32 const *codePoints, sal_Int32 codePointCount)
Create a new string from an array of Unicode code points.
Definition: ustring.hxx:453
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:3096
friend OUString operator+(const OUString &rStr1, const OUString &rStr2)
Definition: ustring.hxx:2213
SAL_DLLPUBLIC double rtl_ustr_toDouble(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a double.
SAL_DLLPUBLIC void rtl_uString_intern(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Return a canonical representation for a string.
static OUString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: ustring.hxx:3064
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_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...
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:1062
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 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...
#define RTL_USTR_MAX_VALUEOFINT32
Definition: ustring.h:941
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:577
bool equalsIgnoreAsciiCaseAscii(const char *asciiStr) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1264
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:1429
OString toUtf8() const
Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully.
Definition: ustring.hxx:3006
OUString getToken(sal_Int32 count, sal_Unicode separator) const
Returns a token from the string.
Definition: ustring.hxx:2686
size_t operator()(const OUString &rString) const
Compute a hash code for a string.
Definition: ustring.hxx:3389
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:3453
#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:48
bool startsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: ustring.hxx:1414
static OUString fromUtf8(const OString &rSource)
Convert an OString to an OUString, assuming that the OString is UTF-8-encoded.
Definition: ustring.hxx:2982
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:3420
Definition: stringutils.hxx:140
SAL_WARN_UNUSED_RESULT OUString concat(const OUString &str) const
Concatenates the specified string to the end of this string.
Definition: ustring.hxx:2204
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:1011
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.
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:3077
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfBoolean(sal_Unicode *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
static OUString number(float f)
Returns the string representation of the float argument.
Definition: ustring.hxx:3111
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_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...
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:1682
OUString getToken(sal_Int32 token, sal_Unicode cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: ustring.hxx:2666
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 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.
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:909
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.
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1771
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 RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR
Definition: textcvt.h:131
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.
#define RTL_USTR_MAX_VALUEOFFLOAT
Definition: ustring.h:1006
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.
static OUString number(double d)
Returns the string representation of the double argument.
Definition: ustring.hxx:3126
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.
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:1648
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_newFromLiteral(rtl_uString **newStr, const char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
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:1478
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.
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:2635
#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
Definition: textcvt.h:52
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...
static OUString createFromAscii(const char *value)
Returns an OUString copied without conversion from an ASCII character string.
Definition: ustring.hxx:3251
bool endsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string ends with a given substring.
Definition: ustring.hxx:1541
A string buffer implements a mutable sequence of characters.
Definition: ustrbuf.hxx:51
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:2507
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:794
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1819
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 sal_Int32 rtl_ustr_valueOfDouble(sal_Unicode *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1787
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.