AlterOffice
AlterOffice 2026.0 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 #include <vector>
17 
18 #if defined LIBO_INTERNAL_ONLY
19 #include <string_view>
20 #include <type_traits>
21 #endif
22 
23 #include "rtl/ustring.h"
24 #include "rtl/string.hxx"
25 #include "rtl/stringutils.hxx"
26 #include "rtl/textenc.h"
27 
28 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
29 #include "config_global.h"
30 #include "rtl/stringconcat.hxx"
31 #endif
32 
33 #ifdef RTL_STRING_UNITTEST
34 extern bool rtl_string_unittest_invalid_conversion;
35 #endif
36 
37 // The unittest uses slightly different code to help check that the proper
38 // calls are made. The class is put into a different namespace to make
39 // sure the compiler generates a different (if generating also non-inline)
40 // copy of the function and does not merge them together. The class
41 // is "brought" into the proper rtl namespace by a typedef below.
42 #ifdef RTL_STRING_UNITTEST
43 #define rtl rtlunittest
44 #endif
45 
46 namespace rtl
47 {
48 
49 class OUStringBuffer;
50 
51 #ifdef RTL_STRING_UNITTEST
52 #undef rtl
53 #endif
54 
55 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
56 
64 template<std::size_t N> class SAL_WARN_UNUSED OUStringLiteral {
65  static_assert(N != 0);
66  static_assert(N - 1 <= std::numeric_limits<sal_Int32>::max(), "literal too long");
67  friend class OUString;
68  friend class OUStringConstExpr;
69 
70 public:
71 #if HAVE_CPP_CONSTEVAL
72  consteval
73 #else
74  constexpr
75 #endif
76  OUStringLiteral(char16_t const (&literal)[N]) {
77  assertLayout();
78  assert(literal[N - 1] == '\0');
79  //TODO: Use C++20 constexpr std::copy_n (P0202R3):
80  for (std::size_t i = 0; i != N; ++i) {
81  more.buffer[i] = literal[i];
82  }
83  }
84 
85  constexpr sal_Int32 getLength() const { return more.length; }
86 
87  constexpr sal_Unicode const * getStr() const SAL_RETURNS_NONNULL { return more.buffer; }
88 
89  constexpr operator std::u16string_view() const { return {more.buffer, sal_uInt32(more.length)}; }
90 
91 private:
92  static constexpr void assertLayout() {
93  // These static_asserts verifying the layout compatibility with rtl_uString cannot be class
94  // member declarations, as offsetof requires a complete type, so defer them to here:
95  static_assert(std::is_standard_layout_v<OUStringLiteral>);
96  static_assert(offsetof(OUStringLiteral, str.refCount) == offsetof(OUStringLiteral, more.refCount));
97  static_assert(offsetof(OUStringLiteral, str.length) == offsetof(OUStringLiteral, more.length));
98  static_assert(offsetof(OUStringLiteral, str.buffer) == offsetof(OUStringLiteral, more.buffer));
99  }
100 
101  struct Data {
102  Data() = default;
103 
104  oslInterlockedCount refCount = 0x40000000; // SAL_STRING_STATIC_FLAG (sal/rtl/strimp.hxx)
105  sal_Int32 length = N - 1;
106  sal_Unicode buffer[N] = {}; //TODO: drop initialization for C++20 (P1331R2)
107  };
108 
109  union {
110  rtl_uString str;
111  Data more = {};
112  };
113 };
114 
115 #if defined RTL_STRING_UNITTEST
116 namespace libreoffice_internal {
117 template<std::size_t N> struct ExceptConstCharArrayDetector<OUStringLiteral<N>> {};
118 template<std::size_t N> struct ExceptCharArrayDetector<OUStringLiteral<N>> {};
119 }
120 #endif
121 
130 class OUString;
131 class OUStringConstExpr
132 {
133 public:
134  template<std::size_t N> constexpr OUStringConstExpr(OUStringLiteral<N> const & literal):
135  pData(const_cast<rtl_uString *>(&literal.str)) {}
136 
137  // prevent mis-use
138  template<std::size_t N> constexpr OUStringConstExpr(OUStringLiteral<N> && literal)
139  = delete;
140 
141  // no destructor necessary because we know we are pointing at a compile-time
142  // constant OUStringLiteral, which bypasses ref-counting.
143 
147  constexpr std::u16string_view asView() const { return std::u16string_view(pData->buffer, pData->length); }
148 
149  inline operator const OUString&() const;
150 
151 private:
152  rtl_uString* pData;
153 };
154 
156 #endif
157 
158 /* ======================================================================= */
159 
183 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OUString
184 {
185 public:
187  rtl_uString * pData;
189 
194  {
195  pData = NULL;
196  rtl_uString_new( &pData );
197  }
198 
204  OUString( const OUString & str )
205  {
206  pData = str.pData;
207  rtl_uString_acquire( pData );
208  }
209 
210 #if defined LIBO_INTERNAL_ONLY
211 
217  OUString( OUString && str ) noexcept
218  {
219  pData = str.pData;
220  str.pData = nullptr;
221  rtl_uString_new( &str.pData );
222  }
223 #endif
224 
230  OUString( rtl_uString * str )
231  {
232  pData = str;
233  rtl_uString_acquire( pData );
234  }
235 
244  OUString( rtl_uString * str, __sal_NoAcquire )
245  { pData = str; }
246 
252  explicit OUString( sal_Unicode value )
253  : pData (NULL)
254  {
255  rtl_uString_newFromStr_WithLength( &pData, &value, 1 );
256  }
257 
258 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
259  // Catch inadvertent conversions to the above ctor (but still allow
261  // construction from char literals):
262  OUString(int) = delete;
263  explicit OUString(char c):
264  OUString(sal_Unicode(static_cast<unsigned char>(c)))
265  {}
267 #endif
268 
269 #if defined LIBO_INTERNAL_ONLY
270 
271  template<typename T> explicit OUString(
272  T const & value,
273  typename libreoffice_internal::CharPtrDetector<T, libreoffice_internal::Dummy>::TypeUtf16
274  = libreoffice_internal::Dummy()):
275  pData(nullptr)
276  { rtl_uString_newFromStr(&pData, value); }
277 
278  template<typename T> explicit OUString(
279  T & value,
280  typename
281  libreoffice_internal::NonConstCharArrayDetector<T, libreoffice_internal::Dummy>::TypeUtf16
282  = libreoffice_internal::Dummy()):
283  pData(nullptr)
284  { rtl_uString_newFromStr(&pData, value); }
285 
286 #else
287 
293  OUString( const sal_Unicode * value )
294  {
295  pData = NULL;
296  rtl_uString_newFromStr( &pData, value );
297  }
298 
299 #endif
300 
309  OUString( const sal_Unicode * value, sal_Int32 length )
310  {
311  pData = NULL;
312  rtl_uString_newFromStr_WithLength( &pData, value, length );
313  }
314 
330  template< typename T >
332  {
333  assert(
335  pData = NULL;
337  rtl_uString_new(&pData);
338  } else {
340  &pData,
342  literal),
344  }
345 #ifdef RTL_STRING_UNITTEST
346  rtl_string_unittest_const_literal = true;
347 #endif
348  }
349 
350 #if defined LIBO_INTERNAL_ONLY
351 
352  template<typename T> OUString(
353  T & literal,
354  typename libreoffice_internal::ConstCharArrayDetector<
355  T, libreoffice_internal::Dummy>::TypeUtf16
356  = libreoffice_internal::Dummy()):
357  pData(nullptr)
358  {
359  assert(
360  libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
361  if (libreoffice_internal::ConstCharArrayDetector<T>::length == 0) {
362  rtl_uString_new(&pData);
363  } else {
365  &pData,
366  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
367  literal),
368  libreoffice_internal::ConstCharArrayDetector<T>::length);
369  }
370  }
371 #endif
372 
373 #if defined LIBO_INTERNAL_ONLY && defined RTL_STRING_UNITTEST
374 
379  template< typename T >
380  OUString( T&, typename libreoffice_internal::ExceptConstCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
381  {
382  pData = NULL;
383  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
384  rtl_string_unittest_invalid_conversion = true;
385  }
390  template< typename T >
391  OUString( const T&, typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
392  {
393  pData = NULL;
394  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
395  rtl_string_unittest_invalid_conversion = true;
396  }
398 #endif
399 
400 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
401 
407  template<std::size_t N> constexpr OUString(OUStringLiteral<N> const & literal):
408  pData(const_cast<rtl_uString *>(&literal.str)) {}
409  template<std::size_t N> OUString(OUStringLiteral<N> &&) = delete;
411 #endif
412 
427  OUString( const char * value, sal_Int32 length,
428  rtl_TextEncoding encoding,
429  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
430  {
431  pData = NULL;
432  rtl_string2UString( &pData, value, length, encoding, convertFlags );
433  if (pData == NULL) {
434  throw std::bad_alloc();
435  }
436  }
437 
454  explicit OUString(
455  sal_uInt32 const * codePoints, sal_Int32 codePointCount):
456  pData(NULL)
457  {
458  rtl_uString_newFromCodePoints(&pData, codePoints, codePointCount);
459  if (pData == NULL) {
460  throw std::bad_alloc();
461  }
462  }
463 
464 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
465 
469  template< typename T1, typename T2 >
470  OUString( OUStringConcat< T1, T2 >&& c )
471  {
472  const sal_Int32 l = c.length();
473  pData = rtl_uString_alloc( l );
474  if (l != 0)
475  {
476  sal_Unicode* end = c.addData( pData->buffer );
477  pData->length = l;
478  *end = '\0';
479  }
480  }
481 
486  template< typename T, std::size_t N >
487  OUString( StringNumberBase< sal_Unicode, T, N >&& n )
488  : OUString( n.buf, n.length )
489  {}
490 #endif
491 
492 #if defined LIBO_INTERNAL_ONLY
493  explicit OUString(std::u16string_view sv) {
494  if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
495  throw std::bad_alloc();
496  }
497  pData = nullptr;
498  rtl_uString_newFromStr_WithLength(&pData, sv.data(), sv.size());
499  }
500 #endif
501 
506  {
507  rtl_uString_release( pData );
508  }
509 
521  static OUString const & unacquired( rtl_uString * const * ppHandle )
522  { return * reinterpret_cast< OUString const * >( ppHandle ); }
523 
524 #if defined LIBO_INTERNAL_ONLY
525 
537  static OUString const& unacquired(const OUStringBuffer& str);
538 #endif
539 
545  OUString & operator=( const OUString & str )
546  {
547  rtl_uString_assign( &pData, str.pData );
548  return *this;
549  }
550 
551 #if defined LIBO_INTERNAL_ONLY
552 
558  OUString & operator=( OUString && str ) noexcept
559  {
560  std::swap(pData, str.pData);
561  return *this;
562  }
563 #endif
564 
577  template< typename T >
579  {
580  assert(
583  rtl_uString_new(&pData);
584  } else {
586  &pData,
588  literal),
590  }
591  return *this;
592  }
593 
594 #if defined LIBO_INTERNAL_ONLY
595 
596  template<typename T>
597  typename
599  operator =(T & literal) {
601  rtl_uString_new(&pData);
602  } else {
604  &pData,
605  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
606  literal),
607  libreoffice_internal::ConstCharArrayDetector<T>::length);
608  }
609  return *this;
610  }
611 
613  template<std::size_t N> OUString & operator =(OUStringLiteral<N> const & literal) {
614  rtl_uString_release(pData);
615  pData = const_cast<rtl_uString *>(&literal.str);
616  return *this;
617  }
618  template<std::size_t N> OUString & operator =(OUStringLiteral<N> &&) = delete;
619 
620  template <typename T, std::size_t N>
621  OUString & operator =(StringNumberBase<sal_Unicode, T, N> && n) {
622  // n.length should never be zero, so no need to add an optimization for that case
623  rtl_uString_newFromStr_WithLength(&pData, n.buf, n.length);
624  return *this;
625  }
626 
627  OUString & operator =(std::u16string_view sv) {
628  if (sv.empty()) {
629  rtl_uString_new(&pData);
630  } else {
631  rtl_uString_newFromStr_WithLength(&pData, sv.data(), sv.size());
632  }
633  return *this;
634  }
635 #endif
636 
637 #if defined LIBO_INTERNAL_ONLY
638 
646  inline OUString & operator+=( const OUStringBuffer & str ) &;
647 #endif
648 
656  OUString & operator+=( const OUString & str )
657 #if defined LIBO_INTERNAL_ONLY
658  &
659 #endif
660  {
661  return internalAppend(str.pData);
662  }
663 #if defined LIBO_INTERNAL_ONLY
664  void operator+=(OUString const &) && = delete;
665 #endif
666 
673  template<typename T>
675  operator +=(T & literal)
676 #if defined LIBO_INTERNAL_ONLY
677  &
678 #endif
679  {
680  assert(
683  &pData, pData,
686  return *this;
687  }
688 #if defined LIBO_INTERNAL_ONLY
689  template<typename T>
691  operator +=(T &) && = delete;
692 #endif
693 
694 #if defined LIBO_INTERNAL_ONLY
695 
696  template<typename T>
697  typename
699  operator +=(T & literal) & {
701  &pData, pData,
704  return *this;
705  }
706  template<typename T>
707  typename
708  libreoffice_internal::ConstCharArrayDetector<T, OUString &>::TypeUtf16
709  operator +=(T &) && = delete;
710 
712  template<std::size_t N> OUString & operator +=(OUStringLiteral<N> const & literal) & {
713  rtl_uString_newConcatUtf16L(&pData, pData, literal.getStr(), literal.getLength());
714  return *this;
715  }
716  template<std::size_t N> void operator +=(OUStringLiteral<N> const &) && = delete;
717 
718  OUString & operator +=(std::u16string_view sv) & {
719  if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
720  throw std::bad_alloc();
721  }
722  rtl_uString_newConcatUtf16L(&pData, pData, sv.data(), sv.size());
723  return *this;
724  }
725  void operator +=(std::u16string_view) && = delete;
726 #endif
727 
728 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
729 
733  template< typename T1, typename T2 >
734  OUString& operator+=( OUStringConcat< T1, T2 >&& c ) & {
735  sal_Int32 l = c.length();
736  if( l == 0 )
737  return *this;
738  l += pData->length;
739  rtl_uString_ensureCapacity( &pData, l );
740  sal_Unicode* end = c.addData( pData->buffer + pData->length );
741  *end = '\0';
742  pData->length = l;
743  return *this;
744  }
745  template<typename T1, typename T2> void operator +=(
746  OUStringConcat<T1, T2> &&) && = delete;
747 
752  template< typename T, std::size_t N >
753  OUString& operator+=( StringNumberBase< sal_Unicode, T, N >&& n ) & {
754  sal_Int32 l = n.length;
755  if( l == 0 )
756  return *this;
757  l += pData->length;
758  rtl_uString_ensureCapacity( &pData, l );
759  sal_Unicode* end = addDataHelper( pData->buffer + pData->length, n.buf, n.length );
760  *end = '\0';
761  pData->length = l;
762  return *this;
763  }
764  template<typename T, std::size_t N> void operator +=(
765  StringNumberBase<sal_Unicode, T, N> &&) && = delete;
766 #endif
767 
772  void clear()
773  {
774  rtl_uString_new( &pData );
775  }
776 
785  sal_Int32 getLength() const { return pData->length; }
786 
795  bool isEmpty() const
796  {
797  return pData->length == 0;
798  }
799 
807  const sal_Unicode * getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
808 
818  sal_Unicode operator [](sal_Int32 index) const {
819  // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
820  assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
821  return getStr()[index];
822  }
823 
836 #if defined LIBO_INTERNAL_ONLY
837  sal_Int32 compareTo( std::u16string_view str ) const
838  {
839  return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
840  str.data(), str.length() );
841  }
842 #else
843  sal_Int32 compareTo( const OUString & str ) const
844  {
845  return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
846  str.pData->buffer, str.pData->length );
847  }
848 #endif
849 
865 #if defined LIBO_INTERNAL_ONLY
866  sal_Int32 compareTo( std::u16string_view str, sal_Int32 maxLength ) const
867  {
868  return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
869  str.data(), str.length(), maxLength );
870  }
871 #else
872  sal_Int32 compareTo( const OUString & str, sal_Int32 maxLength ) const
873  {
874  return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
875  str.pData->buffer, str.pData->length, maxLength );
876  }
877 #endif
878 
891 #if defined LIBO_INTERNAL_ONLY
892  sal_Int32 reverseCompareTo(std::u16string_view sv) const {
894  pData->buffer, pData->length, sv.data(), sv.size());
895  }
896 #else
897  sal_Int32 reverseCompareTo( const OUString & str ) const
898  {
899  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
900  str.pData->buffer, str.pData->length );
901  }
902 #endif
903 
909  template< typename T >
911  {
912  assert(
915  pData->buffer, pData->length,
918  }
919 
931  bool equals( const OUString & str ) const
932  {
933  if ( pData->length != str.pData->length )
934  return false;
935  if ( pData == str.pData )
936  return true;
937  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
938  str.pData->buffer, str.pData->length ) == 0;
939  }
940 
955 #if defined LIBO_INTERNAL_ONLY
956  bool equalsIgnoreAsciiCase(std::u16string_view sv) const {
957  if ( sal_uInt32(pData->length) != sv.size() )
958  return false;
959  if ( pData->buffer == sv.data() )
960  return true;
961  return
963  pData->buffer, pData->length, sv.data(), sv.size())
964  == 0;
965  }
966 #else
967  bool equalsIgnoreAsciiCase( const OUString & str ) const
968  {
969  if ( pData->length != str.pData->length )
970  return false;
971  if ( pData == str.pData )
972  return true;
973  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
974  str.pData->buffer, str.pData->length ) == 0;
975  }
976 #endif
977 
993 #if defined LIBO_INTERNAL_ONLY
994  sal_Int32 compareToIgnoreAsciiCase(std::u16string_view sv) const {
996  pData->buffer, pData->length, sv.data(), sv.size());
997  }
998 #else
999  sal_Int32 compareToIgnoreAsciiCase( const OUString & str ) const
1000  {
1001  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
1002  str.pData->buffer, str.pData->length );
1003  }
1004 #endif
1005 
1011  template< typename T >
1013  {
1014  assert(
1016  return
1017  (pData->length
1020  pData->buffer, pData->length,
1022  literal))
1023  == 0);
1024  }
1025 
1041 #if defined LIBO_INTERNAL_ONLY
1042  bool match(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
1043  return
1045  pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1046  sv.size())
1047  == 0;
1048  }
1049 #else
1050  bool match( const OUString & str, sal_Int32 fromIndex = 0 ) const
1051  {
1052  return rtl_ustr_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1053  str.pData->buffer, str.pData->length, str.pData->length ) == 0;
1054  }
1055 #endif
1056 
1062  template< typename T >
1063  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
1064  {
1065  assert(
1067  return
1069  pData->buffer+fromIndex, pData->length-fromIndex,
1071  literal),
1073  == 0;
1074  }
1075 
1094 #if defined LIBO_INTERNAL_ONLY
1095  bool matchIgnoreAsciiCase(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
1096  return
1098  pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1099  sv.size())
1100  == 0;
1101  }
1102 #else
1103  bool matchIgnoreAsciiCase( const OUString & str, sal_Int32 fromIndex = 0 ) const
1104  {
1105  return rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1106  str.pData->buffer, str.pData->length,
1107  str.pData->length ) == 0;
1108  }
1109 #endif
1110 
1116  template< typename T >
1117  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
1118  {
1119  assert(
1121  return matchIgnoreAsciiCaseAsciiL(
1124  }
1125 
1142  sal_Int32 compareToAscii( const char* asciiStr ) const
1143  {
1144  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length, asciiStr );
1145  }
1146 
1170  "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
1171  sal_Int32 compareToAscii( const char * asciiStr, sal_Int32 maxLength ) const
1172  {
1173  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer, pData->length,
1174  asciiStr, maxLength );
1175  }
1176 
1195  sal_Int32 reverseCompareToAsciiL( const char * asciiStr, sal_Int32 asciiStrLength ) const
1196  {
1197  return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
1198  asciiStr, asciiStrLength );
1199  }
1200 
1216  bool equalsAscii( const char* asciiStr ) const
1217  {
1218  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length,
1219  asciiStr ) == 0;
1220  }
1221 
1238  bool equalsAsciiL( const char* asciiStr, sal_Int32 asciiStrLength ) const
1239  {
1240  if ( pData->length != asciiStrLength )
1241  return false;
1242 
1244  pData->buffer, asciiStr, asciiStrLength );
1245  }
1246 
1265  bool equalsIgnoreAsciiCaseAscii( const char * asciiStr ) const
1266  {
1267  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1268  }
1269 
1288  sal_Int32 compareToIgnoreAsciiCaseAscii( const char * asciiStr ) const
1289  {
1290  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr );
1291  }
1292 
1312  bool equalsIgnoreAsciiCaseAsciiL( const char * asciiStr, sal_Int32 asciiStrLength ) const
1313  {
1314  if ( pData->length != asciiStrLength )
1315  return false;
1316 
1317  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1318  }
1319 
1340  bool matchAsciiL( const char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1341  {
1342  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1343  asciiStr, asciiStrLength ) == 0;
1344  }
1345 
1346  // This overload is left undefined, to detect calls of matchAsciiL that
1347  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1348  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1349  // platforms):
1350 #if SAL_TYPES_SIZEOFLONG == 8
1351  void matchAsciiL(char const *, sal_Int32, rtl_TextEncoding) const;
1352 #endif
1353 
1377  bool matchIgnoreAsciiCaseAsciiL( const char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1378  {
1379  return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1380  asciiStr, asciiStrLength ) == 0;
1381  }
1382 
1383  // This overload is left undefined, to detect calls of
1384  // matchIgnoreAsciiCaseAsciiL that erroneously use
1385  // RTL_CONSTASCII_USTRINGPARAM instead of RTL_CONSTASCII_STRINGPARAM (but
1386  // would lead to ambiguities on 32 bit platforms):
1387 #if SAL_TYPES_SIZEOFLONG == 8
1388  void matchIgnoreAsciiCaseAsciiL(char const *, sal_Int32, rtl_TextEncoding)
1389  const;
1390 #endif
1391 
1406 #if defined LIBO_INTERNAL_ONLY
1407  bool startsWith(std::u16string_view sv, OUString * rest = nullptr) const {
1408  auto const b = match(sv);
1409  if (b && rest != nullptr) {
1410  *rest = copy(sv.size());
1411  }
1412  return b;
1413  }
1414 #else
1415  bool startsWith(OUString const & str, OUString * rest = NULL) const {
1416  bool b = match(str);
1417  if (b && rest != NULL) {
1418  *rest = copy(str.getLength());
1419  }
1420  return b;
1421  }
1422 #endif
1423 
1429  template< typename T >
1431  T & literal, OUString * rest = NULL) const
1432  {
1433  assert(
1435  bool b
1437  <= sal_uInt32(pData->length))
1439  pData->buffer,
1441  literal),
1443  if (b && rest != NULL) {
1444  *rest = copy(
1446  }
1447  return b;
1448  }
1449 
1470 #if defined LIBO_INTERNAL_ONLY
1471  bool startsWithIgnoreAsciiCase(std::u16string_view sv, OUString * rest = nullptr) const {
1472  auto const b = matchIgnoreAsciiCase(sv);
1473  if (b && rest != nullptr) {
1474  *rest = copy(sv.size());
1475  }
1476  return b;
1477  }
1478 #else
1479  bool startsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL)
1480  const
1481  {
1482  bool b = matchIgnoreAsciiCase(str);
1483  if (b && rest != NULL) {
1484  *rest = copy(str.getLength());
1485  }
1486  return b;
1487  }
1488 #endif
1489 
1495  template< typename T >
1497  startsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1498  {
1499  assert(
1501  bool b
1503  <= sal_uInt32(pData->length))
1505  pData->buffer,
1508  literal),
1510  == 0);
1511  if (b && rest != NULL) {
1512  *rest = copy(
1514  }
1515  return b;
1516  }
1517 
1532 #if defined LIBO_INTERNAL_ONLY
1533  bool endsWith(std::u16string_view sv, OUString * rest = nullptr) const {
1534  auto const b = sv.size() <= sal_uInt32(pData->length)
1535  && match(sv, pData->length - sv.size());
1536  if (b && rest != nullptr) {
1537  *rest = copy(0, (pData->length - sv.size()));
1538  }
1539  return b;
1540  }
1541 #else
1542  bool endsWith(OUString const & str, OUString * rest = NULL) const {
1543  bool b = str.getLength() <= getLength()
1544  && match(str, getLength() - str.getLength());
1545  if (b && rest != NULL) {
1546  *rest = copy(0, getLength() - str.getLength());
1547  }
1548  return b;
1549  }
1550 #endif
1551 
1557  template< typename T >
1559  endsWith(T & literal, OUString * rest = NULL) const
1560  {
1561  assert(
1563  bool b
1565  <= sal_uInt32(pData->length))
1567  (pData->buffer + pData->length
1570  literal),
1572  if (b && rest != NULL) {
1573  *rest = copy(
1574  0,
1575  (getLength()
1577  }
1578  return b;
1579  }
1580 
1592  bool endsWithAsciiL(char const * asciiStr, sal_Int32 asciiStrLength)
1593  const
1594  {
1595  return asciiStrLength <= pData->length
1597  pData->buffer + pData->length - asciiStrLength, asciiStr,
1598  asciiStrLength);
1599  }
1600 
1621 #if defined LIBO_INTERNAL_ONLY
1622  bool endsWithIgnoreAsciiCase(std::u16string_view sv, OUString * rest = nullptr) const {
1623  auto const b = sv.size() <= sal_uInt32(pData->length)
1624  && matchIgnoreAsciiCase(sv, pData->length - sv.size());
1625  if (b && rest != nullptr) {
1626  *rest = copy(0, pData->length - sv.size());
1627  }
1628  return b;
1629  }
1630 #else
1631  bool endsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL) const
1632  {
1633  bool b = str.getLength() <= getLength()
1634  && matchIgnoreAsciiCase(str, getLength() - str.getLength());
1635  if (b && rest != NULL) {
1636  *rest = copy(0, getLength() - str.getLength());
1637  }
1638  return b;
1639  }
1640 #endif
1641 
1647  template< typename T >
1649  endsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1650  {
1651  assert(
1653  bool b
1655  <= sal_uInt32(pData->length))
1657  (pData->buffer + pData->length
1661  literal),
1663  == 0);
1664  if (b && rest != NULL) {
1665  *rest = copy(
1666  0,
1667  (getLength()
1669  }
1670  return b;
1671  }
1672 
1684  char const * asciiStr, sal_Int32 asciiStrLength) const
1685  {
1686  return asciiStrLength <= pData->length
1688  pData->buffer + pData->length - asciiStrLength,
1689  asciiStrLength, asciiStr, asciiStrLength)
1690  == 0);
1691  }
1692 
1693  friend bool operator == ( const OUString& rStr1, const OUString& rStr2 )
1694  { return rStr1.equals(rStr2); }
1695 
1696  friend bool operator != ( const OUString& rStr1, const OUString& rStr2 )
1697  { return !(operator == ( rStr1, rStr2 )); }
1698 
1699  friend bool operator < ( const OUString& rStr1, const OUString& rStr2 )
1700  { return rStr1.compareTo( rStr2 ) < 0; }
1701  friend bool operator > ( const OUString& rStr1, const OUString& rStr2 )
1702  { return rStr1.compareTo( rStr2 ) > 0; }
1703  friend bool operator <= ( const OUString& rStr1, const OUString& rStr2 )
1704  { return rStr1.compareTo( rStr2 ) <= 0; }
1705  friend bool operator >= ( const OUString& rStr1, const OUString& rStr2 )
1706  { return rStr1.compareTo( rStr2 ) >= 0; }
1707 
1708 #if defined LIBO_INTERNAL_ONLY
1709 
1710  template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1711  operator ==(OUString const & s1, T const & s2) {
1713  == 0;
1714  }
1715 
1716  template<typename T>
1717  friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1718  operator ==(OUString const & s1, T & s2) {
1719  return rtl_ustr_compare_WithLength(s1.getStr(), s1.getLength(), s2, rtl_ustr_getLength(s2))
1720  == 0;
1721  }
1722 
1723  template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1724  operator ==(T const & s1, OUString const & s2) {
1725  return rtl_ustr_compare_WithLength(s1, rtl_ustr_getLength(s1), s2.getStr(), s2.getLength())
1726  == 0;
1727  }
1728 
1729  template<typename T>
1730  friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1731  operator ==(T & s1, OUString const & s2) {
1732  return rtl_ustr_compare_WithLength(s1, rtl_ustr_getLength(s1), s2.getStr(), s2.getLength())
1733  == 0;
1734  }
1735 
1736  template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1737  operator !=(OUString const & s1, T const & s2) { return !(s1 == s2); }
1738 
1739  template<typename T>
1740  friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1741  operator !=(OUString const & s1, T & s2) { return !(s1 == s2); }
1742 
1743  template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1744  operator !=(T const & s1, OUString const & s2) { return !(s1 == s2); }
1745 
1746  template<typename T>
1747  friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1748  operator !=(T & s1, OUString const & s2) { return !(s1 == s2); }
1749 
1750 #else
1751 
1752  friend bool operator == ( const OUString& rStr1, const sal_Unicode * pStr2 )
1753  { return rStr1.compareTo( pStr2 ) == 0; }
1754  friend bool operator == ( const sal_Unicode * pStr1, const OUString& rStr2 )
1755  { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
1756 
1757  friend bool operator != ( const OUString& rStr1, const sal_Unicode * pStr2 )
1758  { return !(operator == ( rStr1, pStr2 )); }
1759  friend bool operator != ( const sal_Unicode * pStr1, const OUString& rStr2 )
1760  { return !(operator == ( pStr1, rStr2 )); }
1761 
1762 #endif
1763 
1771  template< typename T >
1773  {
1774  assert(
1776  return rString.equalsAsciiL(
1779  }
1787  template< typename T >
1789  {
1790  assert(
1792  return rString.equalsAsciiL(
1795  }
1803  template< typename T >
1805  {
1806  assert(
1808  return !rString.equalsAsciiL(
1811  }
1819  template< typename T >
1821  {
1822  assert(
1824  return !rString.equalsAsciiL(
1827  }
1828 
1829 #if defined LIBO_INTERNAL_ONLY
1830 
1831  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1832  operator ==(OUString const & string, T & literal) {
1833  return
1835  string.pData->buffer, string.pData->length,
1837  literal),
1839  == 0;
1840  }
1842  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1843  operator ==(T & literal, OUString const & string) {
1844  return
1846  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1847  literal),
1848  libreoffice_internal::ConstCharArrayDetector<T>::length,
1849  string.pData->buffer, string.pData->length)
1850  == 0;
1851  }
1853  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1854  operator !=(OUString const & string, T & literal) {
1855  return
1857  string.pData->buffer, string.pData->length,
1858  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1859  literal),
1860  libreoffice_internal::ConstCharArrayDetector<T>::length)
1861  != 0;
1862  }
1864  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1865  operator !=(T & literal, OUString const & string) {
1866  return
1868  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1869  literal),
1870  libreoffice_internal::ConstCharArrayDetector<T>::length,
1871  string.pData->buffer, string.pData->length)
1872  != 0;
1873  }
1874 #endif
1875 
1883  sal_Int32 hashCode() const
1884  {
1885  return rtl_ustr_hashCode_WithLength( pData->buffer, pData->length );
1886  }
1887 
1901  sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
1902  {
1903  sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1904  return (ret < 0 ? ret : ret+fromIndex);
1905  }
1906 
1916  sal_Int32 lastIndexOf( sal_Unicode ch ) const
1917  {
1918  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1919  }
1920 
1933  sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
1934  {
1935  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1936  }
1937 
1953 #if defined LIBO_INTERNAL_ONLY
1954  sal_Int32 indexOf(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
1955  auto const n = rtl_ustr_indexOfStr_WithLength(
1956  pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size());
1957  return n < 0 ? n : n + fromIndex;
1958  }
1959 #else
1960  sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
1961  {
1962  sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1963  str.pData->buffer, str.pData->length );
1964  return (ret < 0 ? ret : ret+fromIndex);
1965  }
1966 #endif
1967 
1973  template< typename T >
1974  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1975  {
1976  assert(
1978  sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
1979  pData->buffer + fromIndex, pData->length - fromIndex,
1982  return n < 0 ? n : n + fromIndex;
1983  }
1984 
2008  sal_Int32 indexOfAsciiL(
2009  char const * str, sal_Int32 len, sal_Int32 fromIndex = 0) const
2010  {
2011  sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
2012  pData->buffer + fromIndex, pData->length - fromIndex, str, len);
2013  return ret < 0 ? ret : ret + fromIndex;
2014  }
2015 
2016  // This overload is left undefined, to detect calls of indexOfAsciiL that
2017  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
2018  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
2019  // platforms):
2020 #if SAL_TYPES_SIZEOFLONG == 8
2021  void indexOfAsciiL(char const *, sal_Int32 len, rtl_TextEncoding) const;
2022 #endif
2023 
2039 #if defined LIBO_INTERNAL_ONLY
2040  sal_Int32 lastIndexOf(std::u16string_view sv) const {
2042  pData->buffer, pData->length, sv.data(), sv.size());
2043  }
2044 #else
2045  sal_Int32 lastIndexOf( const OUString & str ) const
2046  {
2047  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
2048  str.pData->buffer, str.pData->length );
2049  }
2050 #endif
2051 
2069 #if defined LIBO_INTERNAL_ONLY
2070  sal_Int32 lastIndexOf(std::u16string_view sv, sal_Int32 fromIndex) const {
2071  return rtl_ustr_lastIndexOfStr_WithLength(pData->buffer, fromIndex, sv.data(), sv.size());
2072  }
2073 #else
2074  sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
2075  {
2076  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
2077  str.pData->buffer, str.pData->length );
2078  }
2079 #endif
2080 
2086  template< typename T >
2088  {
2089  assert(
2092  pData->buffer, pData->length,
2095  }
2096 
2116  sal_Int32 lastIndexOfAsciiL(char const * str, sal_Int32 len) const
2117  {
2119  pData->buffer, pData->length, str, len);
2120  }
2121 
2132  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex ) const
2133  {
2134  return copy(beginIndex, getLength() - beginIndex);
2135  }
2136 
2149  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const
2150  {
2151  rtl_uString *pNew = NULL;
2152  rtl_uString_newFromSubString( &pNew, pData, beginIndex, count );
2153  return OUString( pNew, SAL_NO_ACQUIRE );
2154  }
2155 
2156 #if defined LIBO_INTERNAL_ONLY
2157 
2167  SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex ) const
2168  {
2169  assert(beginIndex >= 0);
2170  assert(beginIndex <= getLength());
2171  return subView(beginIndex, getLength() - beginIndex);
2172  }
2173 
2186  SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex, sal_Int32 count ) const
2187  {
2188  assert(beginIndex >= 0);
2189  assert(count >= 0);
2190  assert(beginIndex <= getLength());
2191  assert(count <= getLength() - beginIndex);
2192  return std::u16string_view(*this).substr(beginIndex, count);
2193  }
2194 
2201  SAL_WARN_UNUSED_RESULT std::vector<std::u16string_view> split(const std::u16string &separator = u" ") const
2202  {
2203  std::vector<std::u16string_view> output;
2204  std::u16string_view stringView(*this);
2205  std::size_t index;
2206 
2207  do
2208  {
2209  index = stringView.find(separator);
2210  if (index != stringView.npos)
2211  {
2212  if (index != 0)
2213  output.push_back(stringView.substr(0, index));
2214 
2215  if (index != stringView.length() - separator.length())
2216  stringView
2217  = stringView.substr(index + separator.length(),
2218  stringView.length() - index - separator.length());
2219  else
2220  index = stringView.npos;
2221  }
2222  else
2223  output.push_back(stringView);
2224  } while (index != stringView.npos);
2225 
2226  return output;
2227  }
2228 #endif
2229 
2230 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2231 
2240  {
2241  rtl_uString* pNew = NULL;
2242  rtl_uString_newConcat( &pNew, pData, str.pData );
2243  return OUString( pNew, SAL_NO_ACQUIRE );
2244  }
2245 #endif
2246 
2247 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2248  friend OUString operator+( const OUString& rStr1, const OUString& rStr2 )
2249  {
2250  return rStr1.concat( rStr2 );
2251  }
2252 #endif
2253 
2254 // hide this from internal code to avoid ambiguous lookup error
2255 #ifndef LIBO_INTERNAL_ONLY
2256 
2269  SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const
2270  {
2271  rtl_uString* pNew = NULL;
2272  rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
2273  return OUString( pNew, SAL_NO_ACQUIRE );
2274  }
2275 #endif
2276 
2277 #ifdef LIBO_INTERNAL_ONLY
2278  SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, std::u16string_view newStr ) const
2279  {
2280  rtl_uString* pNew = NULL;
2281  rtl_uString_newReplaceStrAtUtf16L( &pNew, pData, index, count, newStr.data(), newStr.size() );
2282  return OUString( pNew, SAL_NO_ACQUIRE );
2283  }
2284 #endif
2285 
2300  {
2301  rtl_uString* pNew = NULL;
2302  rtl_uString_newReplace( &pNew, pData, oldChar, newChar );
2303  return OUString( pNew, SAL_NO_ACQUIRE );
2304  }
2305 
2324 #if defined LIBO_INTERNAL_ONLY
2325  [[nodiscard]] OUString replaceFirst(
2326  std::u16string_view from, std::u16string_view to, sal_Int32 * index = nullptr) const
2327  {
2328  rtl_uString * s = nullptr;
2329  sal_Int32 i = 0;
2331  &s, pData, from.data(), from.size(), to.data(), to.size(),
2332  index == nullptr ? &i : index);
2333  return OUString(s, SAL_NO_ACQUIRE);
2334  }
2335 #else
2337  OUString const & from, OUString const & to, sal_Int32 * index = NULL) const
2338  {
2339  rtl_uString * s = NULL;
2340  sal_Int32 i = 0;
2342  &s, pData, from.pData, to.pData, index == NULL ? &i : index);
2343  return OUString(s, SAL_NO_ACQUIRE);
2344  }
2345 #endif
2346 
2365 #if defined LIBO_INTERNAL_ONLY
2366  template<typename T> [[nodiscard]]
2368  T & from, std::u16string_view to, sal_Int32 * index = nullptr) const
2369  {
2371  rtl_uString * s = nullptr;
2372  sal_Int32 i = 0;
2376  index == nullptr ? &i : index);
2377  return OUString(s, SAL_NO_ACQUIRE);
2378  }
2379 #else
2380  template< typename T >
2382  sal_Int32 * index = NULL) const
2383  {
2385  rtl_uString * s = NULL;
2386  sal_Int32 i = 0;
2388  &s, pData,
2391  index == NULL ? &i : index);
2392  return OUString(s, SAL_NO_ACQUIRE);
2393  }
2394 #endif
2395 
2414 #if defined LIBO_INTERNAL_ONLY
2415  template<typename T> [[nodiscard]]
2417  std::u16string_view from, T & to, sal_Int32 * index = nullptr) const
2418  {
2420  rtl_uString * s = nullptr;
2421  sal_Int32 i = 0;
2423  &s, pData, from.data(), from.size(),
2425  libreoffice_internal::ConstCharArrayDetector<T>::length, index == nullptr ? &i : index);
2426  return OUString(s, SAL_NO_ACQUIRE);
2427  }
2428 #else
2429  template< typename T >
2431  sal_Int32 * index = NULL) const
2432  {
2434  rtl_uString * s = NULL;
2435  sal_Int32 i = 0;
2437  &s, pData, from.pData,
2440  index == NULL ? &i : index);
2441  return OUString(s, SAL_NO_ACQUIRE);
2442  }
2443 #endif
2444 
2463  template< typename T1, typename T2 >
2465  replaceFirst( T1& from, T2& to, sal_Int32 * index = NULL) const
2466  {
2469  rtl_uString * s = NULL;
2470  sal_Int32 i = 0;
2472  &s, pData,
2477  index == NULL ? &i : index);
2478  return OUString(s, SAL_NO_ACQUIRE);
2479  }
2480 
2496 #if defined LIBO_INTERNAL_ONLY
2497  [[nodiscard]] OUString replaceAll(
2498  std::u16string_view from, std::u16string_view to, sal_Int32 fromIndex = 0) const
2499  {
2500  rtl_uString * s = nullptr;
2501  rtl_uString_newReplaceAllFromIndexUtf16LUtf16L(
2502  &s, pData, from.data(), from.size(), to.data(), to.size(), fromIndex);
2503  return OUString(s, SAL_NO_ACQUIRE);
2504  }
2505 #else
2507  OUString const & from, OUString const & to, sal_Int32 fromIndex = 0) const
2508  {
2509  rtl_uString * s = NULL;
2510  rtl_uString_newReplaceAllFromIndex(&s, pData, from.pData, to.pData, fromIndex);
2511  return OUString(s, SAL_NO_ACQUIRE);
2512  }
2513 #endif
2514 
2528 #if defined LIBO_INTERNAL_ONLY
2529  template<typename T> [[nodiscard]]
2531  T & from, std::u16string_view to) const
2532  {
2534  rtl_uString * s = nullptr;
2538  return OUString(s, SAL_NO_ACQUIRE);
2539  }
2540 #else
2541  template< typename T >
2543  {
2545  rtl_uString * s = NULL;
2547  &s, pData,
2550  return OUString(s, SAL_NO_ACQUIRE);
2551  }
2552 #endif
2553 
2567 #if defined LIBO_INTERNAL_ONLY
2568  template<typename T> [[nodiscard]]
2570  std::u16string_view from, T & to) const
2571  {
2573  rtl_uString * s = nullptr;
2575  &s, pData, from.data(), from.size(),
2578  return OUString(s, SAL_NO_ACQUIRE);
2579  }
2580 #else
2581  template< typename T >
2583  {
2585  rtl_uString * s = NULL;
2587  &s, pData, from.pData,
2590  return OUString(s, SAL_NO_ACQUIRE);
2591  }
2592 #endif
2593 
2607  template< typename T1, typename T2 >
2609  replaceAll( T1& from, T2& to ) const
2610  {
2613  rtl_uString * s = NULL;
2615  &s, pData,
2620  return OUString(s, SAL_NO_ACQUIRE);
2621  }
2622 
2634  {
2635  rtl_uString* pNew = NULL;
2636  rtl_uString_newToAsciiLowerCase( &pNew, pData );
2637  return OUString( pNew, SAL_NO_ACQUIRE );
2638  }
2639 
2651  {
2652  rtl_uString* pNew = NULL;
2653  rtl_uString_newToAsciiUpperCase( &pNew, pData );
2654  return OUString( pNew, SAL_NO_ACQUIRE );
2655  }
2656 
2671  {
2672  rtl_uString* pNew = NULL;
2673  rtl_uString_newTrim( &pNew, pData );
2674  return OUString( pNew, SAL_NO_ACQUIRE );
2675  }
2676 
2701  OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const
2702  {
2703  rtl_uString * pNew = NULL;
2704  index = rtl_uString_getToken( &pNew, pData, token, cTok, index );
2705  return OUString( pNew, SAL_NO_ACQUIRE );
2706  }
2707 
2721  OUString getToken(sal_Int32 count, sal_Unicode separator) const {
2722  sal_Int32 n = 0;
2723  return getToken(count, separator, n);
2724  }
2725 
2734  bool toBoolean() const
2735  {
2736  return rtl_ustr_toBoolean( pData->buffer );
2737  }
2738 
2746  {
2747  return pData->buffer[0];
2748  }
2749 
2760  sal_Int32 toInt32( sal_Int16 radix = 10 ) const
2761  {
2762  return rtl_ustr_toInt32( pData->buffer, radix );
2763  }
2764 
2777  sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
2778  {
2779  return rtl_ustr_toUInt32( pData->buffer, radix );
2780  }
2781 
2792  sal_Int64 toInt64( sal_Int16 radix = 10 ) const
2793  {
2794  return rtl_ustr_toInt64( pData->buffer, radix );
2795  }
2796 
2809  sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
2810  {
2811  return rtl_ustr_toUInt64( pData->buffer, radix );
2812  }
2813 
2822  float toFloat() const
2823  {
2824  return rtl_ustr_toFloat( pData->buffer );
2825  }
2826 
2835  double toDouble() const
2836  {
2837  return rtl_ustr_toDouble( pData->buffer );
2838  }
2839 
2840 
2857  {
2858  rtl_uString * pNew = NULL;
2859  rtl_uString_intern( &pNew, pData );
2860  if (pNew == NULL) {
2861  throw std::bad_alloc();
2862  }
2863  return OUString( pNew, SAL_NO_ACQUIRE );
2864  }
2865 
2891  static OUString intern( const char * value, sal_Int32 length,
2892  rtl_TextEncoding encoding,
2893  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS,
2894  sal_uInt32 *pInfo = NULL )
2895  {
2896  rtl_uString * pNew = NULL;
2897  rtl_uString_internConvert( &pNew, value, length, encoding,
2898  convertFlags, pInfo );
2899  if (pNew == NULL) {
2900  throw std::bad_alloc();
2901  }
2902  return OUString( pNew, SAL_NO_ACQUIRE );
2903  }
2904 
2929  bool convertToString(OString * pTarget, rtl_TextEncoding nEncoding,
2930  sal_uInt32 nFlags) const
2931  {
2932  return rtl_convertUStringToString(&pTarget->pData, pData->buffer,
2933  pData->length, nEncoding, nFlags);
2934  }
2935 
2987  sal_uInt32 iterateCodePoints(
2988  sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1) const
2989  {
2991  pData, indexUtf16, incrementCodePoints);
2992  }
2993 
3003 #if defined LIBO_INTERNAL_ONLY
3004  static OUString fromUtf8(std::string_view rSource)
3005  {
3006  OUString aTarget;
3007  bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
3008  rSource.data(),
3009  rSource.length(),
3012  (void) bSuccess;
3013  assert(bSuccess);
3014  return aTarget;
3015  }
3016 #else
3017  static OUString fromUtf8(const OString& rSource)
3018  {
3019  OUString aTarget;
3020  bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
3021  rSource.getStr(),
3022  rSource.getLength(),
3025  (void) bSuccess;
3026  assert(bSuccess);
3027  return aTarget;
3028  }
3029 #endif
3030 
3041  OString toUtf8() const
3042  {
3043  OString aTarget;
3044  bool bSuccess = rtl_convertUStringToString(&aTarget.pData,
3045  getStr(),
3046  getLength(),
3049  (void) bSuccess;
3050  assert(bSuccess);
3051  return aTarget;
3052  }
3053 
3054 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3055 
3056  static OUStringNumber< int > number( int i, sal_Int16 radix = 10 )
3057  {
3058  return OUStringNumber< int >( i, radix );
3059  }
3060  static OUStringNumber< long long > number( long long ll, sal_Int16 radix = 10 )
3061  {
3062  return OUStringNumber< long long >( ll, radix );
3063  }
3064  static OUStringNumber< unsigned long long > number( unsigned long long ll, sal_Int16 radix = 10 )
3065  {
3066  return OUStringNumber< unsigned long long >( ll, radix );
3067  }
3068  static OUStringNumber< unsigned long long > number( unsigned int i, sal_Int16 radix = 10 )
3069  {
3070  return number( static_cast< unsigned long long >( i ), radix );
3071  }
3072  static OUStringNumber< long long > number( long i, sal_Int16 radix = 10)
3073  {
3074  return number( static_cast< long long >( i ), radix );
3075  }
3076  static OUStringNumber< unsigned long long > number( unsigned long i, sal_Int16 radix = 10 )
3077  {
3078  return number( static_cast< unsigned long long >( i ), radix );
3079  }
3080  static OUStringNumber< float > number( float f )
3081  {
3082  return OUStringNumber< float >( f );
3083  }
3084  static OUStringNumber< double > number( double d )
3085  {
3086  return OUStringNumber< double >( d );
3087  }
3088 #else
3089 
3099  static OUString number( int i, sal_Int16 radix = 10 )
3100  {
3102  return OUString(aBuf, rtl_ustr_valueOfInt32(aBuf, i, radix));
3103  }
3106  static OUString number( unsigned int i, sal_Int16 radix = 10 )
3107  {
3108  return number( static_cast< unsigned long long >( i ), radix );
3109  }
3112  static OUString number( long i, sal_Int16 radix = 10)
3113  {
3114  return number( static_cast< long long >( i ), radix );
3115  }
3118  static OUString number( unsigned long i, sal_Int16 radix = 10 )
3119  {
3120  return number( static_cast< unsigned long long >( i ), radix );
3121  }
3124  static OUString number( long long ll, sal_Int16 radix = 10 )
3125  {
3127  return OUString(aBuf, rtl_ustr_valueOfInt64(aBuf, ll, radix));
3128  }
3131  static OUString number( unsigned long long ll, sal_Int16 radix = 10 )
3132  {
3134  return OUString(aBuf, rtl_ustr_valueOfUInt64(aBuf, ll, radix));
3135  }
3136 
3146  static OUString number( float f )
3147  {
3149  return OUString(aBuf, rtl_ustr_valueOfFloat(aBuf, f));
3150  }
3151 
3161  static OUString number( double d )
3162  {
3164  return OUString(aBuf, rtl_ustr_valueOfDouble(aBuf, d));
3165  }
3166 #endif
3167 
3179  SAL_DEPRECATED("use boolean()") static OUString valueOf( sal_Bool b )
3180  {
3181  return boolean(b);
3182  }
3183 
3195  static OUString boolean( bool b )
3196  {
3198  return OUString(aBuf, rtl_ustr_valueOfBoolean(aBuf, b));
3199  }
3200 
3208  SAL_DEPRECATED("convert to OUString or use directly") static OUString valueOf( sal_Unicode c )
3209  {
3210  return OUString( &c, 1 );
3211  }
3212 
3223  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
3224  {
3225  return number( i, radix );
3226  }
3227 
3238  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
3239  {
3240  return number( ll, radix );
3241  }
3242 
3252  SAL_DEPRECATED("use number()") static OUString valueOf( float f )
3253  {
3254  return number(f);
3255  }
3256 
3266  SAL_DEPRECATED("use number()") static OUString valueOf( double d )
3267  {
3268  return number(d);
3269  }
3270 
3286  static OUString createFromAscii( const char * value )
3287  {
3288  rtl_uString* pNew = NULL;
3289  rtl_uString_newFromAscii( &pNew, value );
3290  return OUString( pNew, SAL_NO_ACQUIRE );
3291  }
3292 
3293 #if defined LIBO_INTERNAL_ONLY
3294  static OUString createFromAscii(std::string_view value) {
3295  rtl_uString * p = nullptr;
3296  rtl_uString_newFromLiteral(&p, value.data(), value.size(), 0); //TODO: check for overflow
3297  return OUString(p, SAL_NO_ACQUIRE);
3298  }
3299  #endif
3300 
3301 #if defined LIBO_INTERNAL_ONLY
3302  operator std::u16string_view() const { return {getStr(), sal_uInt32(getLength())}; }
3303 #endif
3304 
3305 #if defined LIBO_INTERNAL_ONLY
3306  // A wrapper for the first expression in an
3307  //
3308  // OUString::Concat(e1) + e2 + ...
3309  //
3310  // concatenation chain, when neither of the first two e1, e2 is one of our rtl string-related
3311  // classes (so something like
3312  //
3313  // OUString s = "a" + (b ? std::u16string_view(u"c") : std::u16string_view(u"dd"));
3314  //
3315  // would not compile):
3316  template<typename T> [[nodiscard]] static
3317  OUStringConcat<OUStringConcatMarker, T>
3318  Concat(T const & value) { return OUStringConcat<OUStringConcatMarker, T>({}, value); }
3319 
3320  // This overload is needed so that an argument of type 'char const[N]' ends up as
3321  // 'OUStringConcat<rtl::OUStringConcatMarker, char const[N]>' rather than as
3322  // 'OUStringConcat<rtl::OUStringConcatMarker, char[N]>':
3323  template<typename T, std::size_t N> [[nodiscard]] static
3324  OUStringConcat<OUStringConcatMarker, T[N]>
3325  Concat(T (& value)[N]) { return OUStringConcat<OUStringConcatMarker, T[N]>({}, value); }
3326 #endif
3327 
3328 private:
3329  OUString & internalAppend( rtl_uString* pOtherData )
3330  {
3331  rtl_uString* pNewData = NULL;
3332  rtl_uString_newConcat( &pNewData, pData, pOtherData );
3333  if (pNewData == NULL) {
3334  throw std::bad_alloc();
3335  }
3336  rtl_uString_assign(&pData, pNewData);
3337  rtl_uString_release(pNewData);
3338  return *this;
3339  }
3340 
3341 };
3342 
3343 #if defined LIBO_INTERNAL_ONLY
3344 // Can only define this after we define OUString
3345 inline OUStringConstExpr::operator const OUString &() const { return OUString::unacquired(&pData); }
3346 #endif
3347 
3348 #if defined LIBO_INTERNAL_ONLY
3349 // Prevent the operator ==/!= overloads with 'sal_Unicode const *' parameter from
3350 // being selected for nonsensical code like
3351 //
3352 // if (ouIdAttr == nullptr)
3353 //
3354 void operator ==(OUString const &, std::nullptr_t) = delete;
3355 void operator ==(std::nullptr_t, OUString const &) = delete;
3356 void operator !=(OUString const &, std::nullptr_t) = delete;
3357 void operator !=(std::nullptr_t, OUString const &) = delete;
3358 #endif
3359 
3360 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3361 inline bool operator ==(OUString const & lhs, StringConcatenation<char16_t> const & rhs)
3362 { return lhs == std::u16string_view(rhs); }
3363 inline bool operator !=(OUString const & lhs, StringConcatenation<char16_t> const & rhs)
3364 { return lhs != std::u16string_view(rhs); }
3365 inline bool operator ==(StringConcatenation<char16_t> const & lhs, OUString const & rhs)
3366 { return std::u16string_view(lhs) == rhs; }
3367 inline bool operator !=(StringConcatenation<char16_t> const & lhs, OUString const & rhs)
3368 { return std::u16string_view(lhs) != rhs; }
3369 #endif
3370 
3371 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3372 
3377 template<>
3378 struct ToStringHelper< OUString >
3379 {
3380  static std::size_t length( const OUString& s ) { return s.getLength(); }
3381  sal_Unicode* operator() ( sal_Unicode* buffer, const OUString& s ) const { return addDataHelper( buffer, s.getStr(), s.getLength()); }
3382 };
3383 
3387 template<std::size_t N>
3388 struct ToStringHelper< OUStringLiteral<N> >
3389 {
3390  static std::size_t length( const OUStringLiteral<N>& str ) { return str.getLength(); }
3391  sal_Unicode* operator()( sal_Unicode* buffer, const OUStringLiteral<N>& str ) const { return addDataHelper( buffer, str.getStr(), str.getLength() ); }
3392 };
3393 
3397 template< typename charT, typename traits, typename T1, typename T2 >
3398 inline std::basic_ostream<charT, traits> & operator <<(
3399  std::basic_ostream<charT, traits> & stream, OUStringConcat< T1, T2 >&& concat)
3400 {
3401  return stream << OUString( std::move(concat) );
3402 }
3403 
3404 
3406 #endif
3407 
3414 {
3424  size_t operator()(const OUString& rString) const
3425  { return static_cast<size_t>(rString.hashCode()); }
3426 };
3427 
3428 /* ======================================================================= */
3429 
3447 #if defined LIBO_INTERNAL_ONLY
3448 inline OUString OStringToOUString( std::string_view rStr,
3449  rtl_TextEncoding encoding,
3450  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
3451 {
3452  return OUString( rStr.data(), rStr.length(), encoding, convertFlags );
3453 }
3454 #else
3455 inline OUString OStringToOUString( const OString & rStr,
3456  rtl_TextEncoding encoding,
3457  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
3458 {
3459  return OUString( rStr.getStr(), rStr.getLength(), encoding, convertFlags );
3460 }
3461 #endif
3462 
3480 #if defined LIBO_INTERNAL_ONLY
3481 inline OString OUStringToOString( std::u16string_view rUnicode,
3482  rtl_TextEncoding encoding,
3483  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
3484 {
3485  return OString( rUnicode.data(), rUnicode.length(), encoding, convertFlags );
3486 }
3487 #else
3488 inline OString OUStringToOString( const OUString & rUnicode,
3489  rtl_TextEncoding encoding,
3490  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
3491 {
3492  return OString( rUnicode.getStr(), rUnicode.getLength(), encoding, convertFlags );
3493 }
3494 #endif
3495 
3496 /* ======================================================================= */
3497 
3506 template< typename charT, typename traits >
3507 inline std::basic_ostream<charT, traits> & operator <<(
3508  std::basic_ostream<charT, traits> & stream, OUString const & rString)
3509 {
3510  return stream <<
3512  // best effort; potentially loses data due to conversion failures
3513  // (stray surrogate halves) and embedded null characters
3514 }
3515 
3516 } // namespace
3517 
3518 #ifdef RTL_STRING_UNITTEST
3519 namespace rtl
3520 {
3521 typedef rtlunittest::OUString OUString;
3522 }
3523 #endif
3524 
3525 // In internal code, allow to use classes like OUString without having to
3526 // explicitly refer to the rtl namespace, which is kind of superfluous given
3527 // that OUString itself is namespaced by its OU prefix:
3528 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3529 using ::rtl::OUString;
3530 using ::rtl::OUStringHash;
3533 using ::rtl::OUStringLiteral;
3534 using ::rtl::OUStringChar;
3535 using ::rtl::Concat2View;
3536 #endif
3537 
3539 
3544 #if defined LIBO_INTERNAL_ONLY
3545 namespace std {
3546 
3547 template<>
3548 struct hash<::rtl::OUString>
3549 {
3550  std::size_t operator()(::rtl::OUString const & s) const
3551  {
3552  if constexpr (sizeof(std::size_t) == 8)
3553  {
3554  // return a hash that uses the full 64-bit range instead of a 32-bit value
3555  size_t n = 0;
3556  for (sal_Int32 i = 0, len = s.getLength(); i < len; ++i)
3557  n = 31 * n + s[i];
3558  return n;
3559  }
3560  else
3561  return std::size_t(s.hashCode());
3562  }
3563 };
3564 
3565 }
3566 
3567 #endif
3568 
3570 #endif /* _RTL_USTRING_HXX */
3571 
3572 /* 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:1559
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:1497
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition: ustring.hxx:656
bool convertToString(OString *pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) const
Converts to an OString, signalling failure.
Definition: ustring.hxx:2929
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:1117
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:2465
#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:2299
double toDouble() const
Returns the double value from this string.
Definition: ustring.hxx:2835
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:2132
bool match(const OUString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:1050
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:545
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:2650
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:897
OUString(const sal_Unicode *value, sal_Int32 length)
New string from a Unicode character buffer array.
Definition: ustring.hxx:309
float toFloat() const
Returns the float value from this string.
Definition: ustring.hxx:2822
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:1377
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:967
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:1960
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:183
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:2792
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:1103
#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:2269
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:3106
bool equals(const OUString &str) const
Perform a comparison of two strings.
Definition: ustring.hxx:931
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:244
sal_Int32 compareToIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:999
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:2582
#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:2045
OUString intern() const
Return a canonical representation for a string.
Definition: ustring.hxx:2856
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:1288
#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:1238
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:2633
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:2891
bool endsWithAsciiL(char const *asciiStr, sal_Int32 asciiStrLength) const
Check whether this string ends with a given ASCII string.
Definition: ustring.hxx:1592
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:204
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:2087
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:2381
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:2506
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:1631
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:427
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: ustring.hxx:2777
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:2745
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:2987
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:521
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:2609
const sal_Unicode * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:807
~OUString()
Release the string data.
Definition: ustring.hxx:505
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:2336
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:2734
#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:2074
pData
Definition: ustring.hxx:335
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:1916
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:872
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:1974
#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:1142
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:2760
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: ustring.hxx:2809
OUString(const sal_Unicode *value)
New string from a Unicode character buffer array.
Definition: ustring.hxx:293
OUString(rtl_uString *str)
New string from OUString data.
Definition: ustring.hxx:230
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:2008
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:1216
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:3124
static OUString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: ustring.hxx:3195
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:2116
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:3413
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:3118
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1804
OUString()
New string containing no characters.
Definition: ustring.hxx:193
sal_Int32 reverseCompareToAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Compares two strings in reverse order.
Definition: ustring.hxx:1195
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: ustring.hxx:772
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:2430
sal_Int32 compareTo(const OUString &str) const
Compares two strings.
Definition: ustring.hxx:843
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:2149
sal_Int32 oslInterlockedCount
Definition: interlck.h:24
sal_Int32 getLength() const
Returns the length of this string.
Definition: ustring.hxx:785
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:1340
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:252
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:1901
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: ustring.hxx:1883
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:1933
bool equalsIgnoreAsciiCaseAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1312
OUString(sal_uInt32 const *codePoints, sal_Int32 codePointCount)
Create a new string from an array of Unicode code points.
Definition: ustring.hxx:454
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:3131
friend OUString operator+(const OUString &rStr1, const OUString &rStr2)
Definition: ustring.hxx:2248
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:3099
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:1063
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:578
bool equalsIgnoreAsciiCaseAscii(const char *asciiStr) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1265
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:1430
OString toUtf8() const
Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully.
Definition: ustring.hxx:3041
OUString getToken(sal_Int32 count, sal_Unicode separator) const
Returns a token from the string.
Definition: ustring.hxx:2721
size_t operator()(const OUString &rString) const
Compute a hash code for a string.
Definition: ustring.hxx:3424
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:3488
#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:1415
static OUString fromUtf8(const OString &rSource)
Convert an OString to an OUString, assuming that the OString is UTF-8-encoded.
Definition: ustring.hxx:3017
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:3455
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:2239
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:1012
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:3112
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:3146
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:1683
OUString getToken(sal_Int32 token, sal_Unicode cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: ustring.hxx:2701
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:910
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:1772
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:3161
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:1649
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:1479
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:2670
#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:3286
bool endsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string ends with a given substring.
Definition: ustring.hxx:1542
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:2542
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:795
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1820
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:1788
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.