LibreOffice
LibreOffice 24.8 SDK C/C++ API Reference
ustring.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 /*
21  * This file is part of LibreOffice published API.
22  */
23 
24 #ifndef INCLUDED_RTL_USTRING_HXX
25 #define INCLUDED_RTL_USTRING_HXX
26 
27 #include "sal/config.h"
28 
29 #include <cassert>
30 #include <cstddef>
31 #include <cstdlib>
32 #include <limits>
33 #include <new>
34 #include <ostream>
35 #include <utility>
36 
37 #if defined LIBO_INTERNAL_ONLY
38 #include <algorithm>
39 #include <string_view>
40 #include <type_traits>
41 #endif
42 
43 #include "rtl/math.h"
44 #include "rtl/ustring.h"
45 #include "rtl/string.hxx"
46 #include "rtl/stringutils.hxx"
47 #include "rtl/textenc.h"
48 
49 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
50 #include "config_global.h"
51 #include "o3tl/safeint.hxx"
52 #include "rtl/stringconcat.hxx"
53 #endif
54 
55 #ifdef RTL_STRING_UNITTEST
56 extern bool rtl_string_unittest_invalid_conversion;
57 #endif
58 
59 // The unittest uses slightly different code to help check that the proper
60 // calls are made. The class is put into a different namespace to make
61 // sure the compiler generates a different (if generating also non-inline)
62 // copy of the function and does not merge them together. The class
63 // is "brought" into the proper rtl namespace by a typedef below.
64 #ifdef RTL_STRING_UNITTEST
65 #define rtl rtlunittest
66 #endif
67 
68 namespace rtl
69 {
70 
71 class OUStringBuffer;
72 
73 #ifdef RTL_STRING_UNITTEST
74 #undef rtl
75 #endif
76 
77 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
78 
86 template<std::size_t N> class SAL_WARN_UNUSED OUStringLiteral {
87  static_assert(N != 0);
88  static_assert(N - 1 <= std::numeric_limits<sal_Int32>::max(), "literal too long");
89 
90 public:
91 #if HAVE_CPP_CONSTEVAL
92  consteval
93 #else
94  constexpr
95 #endif
96  OUStringLiteral(char16_t const (&literal)[N]) {
97  assertLayout();
98  assert(literal[N - 1] == '\0');
99  std::copy_n(literal, N, more.buffer);
100  }
101 
102  constexpr sal_Int32 getLength() const { return more.length; }
103 
104  constexpr sal_Unicode const * getStr() const SAL_RETURNS_NONNULL { return more.buffer; }
105 
106  constexpr operator std::u16string_view() const { return {more.buffer, sal_uInt32(more.length)}; }
107 
108 private:
109  static constexpr void assertLayout() {
110  // These static_asserts verifying the layout compatibility with rtl_uString cannot be class
111  // member declarations, as offsetof requires a complete type, so defer them to here:
112  static_assert(std::is_standard_layout_v<OUStringLiteral>);
113  static_assert(offsetof(OUStringLiteral, str.refCount) == offsetof(OUStringLiteral, more.refCount));
114  static_assert(offsetof(OUStringLiteral, str.length) == offsetof(OUStringLiteral, more.length));
115  static_assert(offsetof(OUStringLiteral, str.buffer) == offsetof(OUStringLiteral, more.buffer));
116  }
117 
118  struct Data {
119  Data() = default;
120 
121  oslInterlockedCount refCount = 0x40000000; // SAL_STRING_STATIC_FLAG (sal/rtl/strimp.hxx)
122  sal_Int32 length = N - 1;
123  sal_Unicode buffer[N];
124  };
125 
126 public:
127  // (Data members must be public so that OUStringLiteral is a structural type that can be used as
128  // a non-type template parameter type for operator ""_ustr:)
129  union {
130  rtl_uString str;
131  Data more = {};
132  };
133 };
134 
135 #if defined RTL_STRING_UNITTEST
136 namespace libreoffice_internal {
137 template<std::size_t N> struct ExceptConstCharArrayDetector<OUStringLiteral<N>> {};
138 template<std::size_t N> struct ExceptCharArrayDetector<OUStringLiteral<N>> {};
139 }
140 #endif
141 
143 #endif
144 
145 /* ======================================================================= */
146 
170 // coverity[ missing_move_assignment : SUPPRESS] - don't report the suppressed move assignment
171 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OUString
172 {
173 public:
175  rtl_uString * pData;
177 
182  {
183  pData = NULL;
184  rtl_uString_new( &pData );
185  }
186 
192 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
193  constexpr
194 #endif
195  OUString( const OUString & str )
196  {
197  pData = str.pData;
198 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
199  if (std::is_constant_evaluated()) {
200  //TODO: We would want to
201  //
202  // assert(SAL_STRING_IS_STATIC(pData));
203  //
204  // here, but that wouldn't work because read of member `str` of OUStringLiteral's
205  // anonymous union with active member `more` is not allowed in a constant expression.
206  } else
207 #endif
208  rtl_uString_acquire( pData );
209  }
210 
211 #if defined LIBO_INTERNAL_ONLY
212 #if !defined(__COVERITY__) // suppress COPY_INSTEAD_OF_MOVE suggestions
213 
219 #if !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
220  constexpr
221 #endif
222  OUString( OUString && str ) noexcept
223  {
224  pData = str.pData;
225 #if !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
226  if (std::is_constant_evaluated()) {
227  //TODO: We would want to
228  //
229  // assert(SAL_STRING_IS_STATIC(pData));
230  //
231  // here, but that wouldn't work because read of member `str` of OUStringLiteral's
232  // anonymous union with active member `more` is not allowed in a constant expression.
233  return;
234  }
235 #endif
236  str.pData = nullptr;
237  rtl_uString_new( &str.pData );
238  }
239 #endif
240 #endif
241 
247  OUString( rtl_uString * str )
248  {
249  pData = str;
250  rtl_uString_acquire( pData );
251  }
252 
253 #if defined LIBO_INTERNAL_ONLY
254  // Catch inadvertent conversions to the above ctor:
256  OUString(std::nullptr_t) = delete;
258 #endif
259 
268  OUString( rtl_uString * str, __sal_NoAcquire )
269  { pData = str; }
270 
276  explicit OUString( sal_Unicode value )
277  : pData (NULL)
278  {
279  rtl_uString_newFromStr_WithLength( &pData, &value, 1 );
280  }
281 
282 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
283  // Catch inadvertent conversions to the above ctor (but still allow
285  // construction from char literals):
286  OUString(int) = delete;
287  explicit OUString(char c):
288  OUString(sal_Unicode(static_cast<unsigned char>(c)))
289  {}
291 #endif
292 
293 #if defined LIBO_INTERNAL_ONLY
294 
295  template<typename T> explicit OUString(
296  T const & value,
297  typename libreoffice_internal::CharPtrDetector<T, libreoffice_internal::Dummy>::TypeUtf16
298  = libreoffice_internal::Dummy()):
299  pData(nullptr)
300  { rtl_uString_newFromStr(&pData, value); }
301 
302  template<typename T> explicit OUString(
303  T & value,
304  typename
305  libreoffice_internal::NonConstCharArrayDetector<T, libreoffice_internal::Dummy>::TypeUtf16
306  = libreoffice_internal::Dummy()):
307  pData(nullptr)
308  { rtl_uString_newFromStr(&pData, value); }
309 
310 #else
311 
317  OUString( const sal_Unicode * value )
318  {
319  pData = NULL;
320  rtl_uString_newFromStr( &pData, value );
321  }
322 
323 #endif
324 
333  OUString( const sal_Unicode * value, sal_Int32 length )
334  {
335  pData = NULL;
336  rtl_uString_newFromStr_WithLength( &pData, value, length );
337  }
338 
354  template< typename T >
356  {
357  assert(
359  pData = NULL;
361  rtl_uString_new(&pData);
362  } else {
364  &pData,
366  literal),
368  }
369 #ifdef RTL_STRING_UNITTEST
370  rtl_string_unittest_const_literal = true;
371 #endif
372  }
373 
374 #if defined LIBO_INTERNAL_ONLY
375  // Rather use a u""_ustr literal (but don't remove this entirely, to avoid implicit support for
376  // it via std::u16string_view from kicking in):
377  template<typename T> OUString(
378  T &,
380  T, libreoffice_internal::Dummy>::TypeUtf16
381  = libreoffice_internal::Dummy()) = delete;
382 
383  OUString(OUStringChar c): pData(nullptr) { rtl_uString_newFromStr_WithLength(&pData, &c.c, 1); }
384 #endif
385 
386 #if defined LIBO_INTERNAL_ONLY && defined RTL_STRING_UNITTEST
387 
392  template< typename T >
393  OUString( T&, typename libreoffice_internal::ExceptConstCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
394  {
395  pData = NULL;
396  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
397  rtl_string_unittest_invalid_conversion = true;
398  }
403  template< typename T >
404  OUString( const T&, typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
405  {
406  pData = NULL;
407  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
408  rtl_string_unittest_invalid_conversion = true;
409  }
411 #endif
412 
413 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
414 
420  template<std::size_t N> constexpr OUString(OUStringLiteral<N> const & literal):
421  pData(const_cast<rtl_uString *>(&literal.str)) {}
422  template<std::size_t N> OUString(OUStringLiteral<N> &&) = delete;
424 #endif
425 
426 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
427  // For operator ""_tstr:
428  template<OStringLiteral L> OUString(detail::OStringHolder<L> const & holder) {
429  pData = nullptr;
430  if (holder.literal.getLength() == 0) {
431  rtl_uString_new(&pData);
432  } else {
434  &pData, holder.literal.getStr(), holder.literal.getLength(), 0);
435  }
436  }
437 #endif
438 
453  OUString( const char * value, sal_Int32 length,
454  rtl_TextEncoding encoding,
455  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
456  {
457  pData = NULL;
458  rtl_string2UString( &pData, value, length, encoding, convertFlags );
459  if (pData == NULL) {
460  throw std::bad_alloc();
461  }
462  }
463 
480  explicit OUString(
481  sal_uInt32 const * codePoints, sal_Int32 codePointCount):
482  pData(NULL)
483  {
484  rtl_uString_newFromCodePoints(&pData, codePoints, codePointCount);
485  if (pData == NULL) {
486  throw std::bad_alloc();
487  }
488  }
489 
490 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
491 
495  template< typename T1, typename T2 >
496  OUString( OUStringConcat< T1, T2 >&& c )
497  {
498  const sal_Int32 l = c.length();
499  pData = rtl_uString_alloc( l );
500  if (l != 0)
501  {
502  sal_Unicode* end = c.addData( pData->buffer );
503  pData->length = l;
504  *end = '\0';
505  }
506  }
507 
512  template< std::size_t N >
513  OUString( OUStringNumber< N >&& n )
514  : OUString( n.buf, n.length )
515  {}
516 #endif
517 
518 #if defined LIBO_INTERNAL_ONLY
519  explicit OUString(std::u16string_view sv) {
520  if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
521  throw std::bad_alloc();
522  }
523  pData = nullptr;
524  rtl_uString_newFromStr_WithLength(&pData, sv.data(), sv.size());
525  }
526 #endif
527 
531 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
532  constexpr
533 #endif
535  {
536 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
537  if (std::is_constant_evaluated()) {
538  //TODO: We would want to
539  //
540  // assert(SAL_STRING_IS_STATIC(pData));
541  //
542  // here, but that wouldn't work because read of member `str` of OUStringLiteral's
543  // anonymous union with active member `more` is not allowed in a constant expression.
544  } else
545 #endif
546  rtl_uString_release( pData );
547  }
548 
560  static OUString const & unacquired( rtl_uString * const * ppHandle )
561  { return * reinterpret_cast< OUString const * >( ppHandle ); }
562 
563 #if defined LIBO_INTERNAL_ONLY
564 
576  static OUString const& unacquired(const OUStringBuffer& str);
577 #endif
578 
584  OUString & operator=( const OUString & str )
585  {
586  rtl_uString_assign( &pData, str.pData );
587  return *this;
588  }
589 
590 #if defined LIBO_INTERNAL_ONLY
591 #if !defined(__COVERITY__) // suppress COPY_INSTEAD_OF_MOVE suggestions
592 
598  OUString & operator=( OUString && str ) noexcept
599  {
600  std::swap(pData, str.pData);
601  return *this;
602  }
603 #endif
604 #endif
605 
618  template< typename T >
620  {
621  assert(
624  rtl_uString_new(&pData);
625  } else {
627  &pData,
629  literal),
631  }
632  return *this;
633  }
634 
635 #if defined LIBO_INTERNAL_ONLY
636  // Rather assign from a u""_ustr literal (but don't remove this entirely, to avoid implicit
637  // support for it via std::u16string_view from kicking in):
638  template<typename T>
639  typename
641  operator =(T &) = delete;
642 
643  OUString & operator =(OUStringChar c) {
644  rtl_uString_newFromStr_WithLength(&pData, &c.c, 1);
645  return *this;
646  }
647 
649  template<std::size_t N> OUString & operator =(OUStringLiteral<N> const & literal) {
650  rtl_uString_release(pData);
651  pData = const_cast<rtl_uString *>(&literal.str);
652  return *this;
653  }
654  template<std::size_t N> OUString & operator =(OUStringLiteral<N> &&) = delete;
655 
656  template <std::size_t N>
657  OUString & operator =(OUStringNumber<N> && n) {
658  // n.length should never be zero, so no need to add an optimization for that case
659  rtl_uString_newFromStr_WithLength(&pData, n.buf, n.length);
660  return *this;
661  }
662 
663  OUString & operator =(std::u16string_view sv) {
664  if (sv.empty()) {
665  rtl_uString_new(&pData);
666  } else {
667  rtl_uString_newFromStr_WithLength(&pData, sv.data(), sv.size());
668  }
669  return *this;
670  }
671 #endif
672 
673 #if defined LIBO_INTERNAL_ONLY
674 
682  inline OUString & operator+=( const OUStringBuffer & str ) &;
683 #endif
684 
692  OUString & operator+=( const OUString & str )
693 #if defined LIBO_INTERNAL_ONLY
694  &
695 #endif
696  {
697  return internalAppend(str.pData);
698  }
699 #if defined LIBO_INTERNAL_ONLY
700  void operator+=(OUString const &) && = delete;
701 #endif
702 
709  template<typename T>
711  operator +=(T & literal)
712 #if defined LIBO_INTERNAL_ONLY
713  &
714 #endif
715  {
716  assert(
719  &pData, pData,
722  return *this;
723  }
724 #if defined LIBO_INTERNAL_ONLY
725  template<typename T>
727  operator +=(T &) && = delete;
728 #endif
729 
730 #if defined LIBO_INTERNAL_ONLY
731 
732  template<typename T>
733  typename
735  operator +=(T & literal) & {
737  &pData, pData,
740  return *this;
741  }
742  template<typename T>
743  typename
744  libreoffice_internal::ConstCharArrayDetector<T, OUString &>::TypeUtf16
745  operator +=(T &) && = delete;
746 
748  template<std::size_t N> OUString & operator +=(OUStringLiteral<N> const & literal) & {
749  rtl_uString_newConcatUtf16L(&pData, pData, literal.getStr(), literal.getLength());
750  return *this;
751  }
752  template<std::size_t N> void operator +=(OUStringLiteral<N> const &) && = delete;
753 
754  OUString & operator +=(std::u16string_view sv) & {
755  if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
756  throw std::bad_alloc();
757  }
758  rtl_uString_newConcatUtf16L(&pData, pData, sv.data(), sv.size());
759  return *this;
760  }
761  void operator +=(std::u16string_view) && = delete;
762 #endif
763 
764 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
765 
769  template< typename T1, typename T2 >
770  OUString& operator+=( OUStringConcat< T1, T2 >&& c ) & {
771  sal_Int32 l = c.length();
772  if( l == 0 )
773  return *this;
774  l += pData->length;
775  rtl_uString_ensureCapacity( &pData, l );
776  sal_Unicode* end = c.addData( pData->buffer + pData->length );
777  *end = '\0';
778  pData->length = l;
779  return *this;
780  }
781  template<typename T1, typename T2> void operator +=(
782  OUStringConcat<T1, T2> &&) && = delete;
783 
788  template< std::size_t N >
789  OUString& operator+=( OUStringNumber< N >&& n ) & {
790  sal_Int32 l = n.length;
791  if( l == 0 )
792  return *this;
793  l += pData->length;
794  rtl_uString_ensureCapacity( &pData, l );
795  sal_Unicode* end = addDataHelper( pData->buffer + pData->length, n.buf, n.length );
796  *end = '\0';
797  pData->length = l;
798  return *this;
799  }
800  template<std::size_t N> void operator +=(
801  OUStringNumber<N> &&) && = delete;
802 #endif
803 
808  void clear()
809  {
810  rtl_uString_new( &pData );
811  }
812 
821  sal_Int32 getLength() const { return pData->length; }
822 
831  bool isEmpty() const
832  {
833  return pData->length == 0;
834  }
835 
843  const sal_Unicode * getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
844 
854  sal_Unicode operator [](sal_Int32 index) const {
855  // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
856  assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
857  return getStr()[index];
858  }
859 
872 #if defined LIBO_INTERNAL_ONLY
873  sal_Int32 compareTo( std::u16string_view str ) const
874  {
875  return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
876  str.data(), str.length() );
877  }
878 #else
879  sal_Int32 compareTo( const OUString & str ) const
880  {
881  return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
882  str.pData->buffer, str.pData->length );
883  }
884 #endif
885 
901 #if defined LIBO_INTERNAL_ONLY
902  sal_Int32 compareTo( std::u16string_view str, sal_Int32 maxLength ) const
903  {
904  return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
905  str.data(), str.length(), maxLength );
906  }
907 #else
908  sal_Int32 compareTo( const OUString & str, sal_Int32 maxLength ) const
909  {
910  return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
911  str.pData->buffer, str.pData->length, maxLength );
912  }
913 #endif
914 
927 #if defined LIBO_INTERNAL_ONLY
928  sal_Int32 reverseCompareTo(std::u16string_view sv) const {
930  pData->buffer, pData->length, sv.data(), sv.size());
931  }
932 #else
933  sal_Int32 reverseCompareTo( const OUString & str ) const
934  {
935  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
936  str.pData->buffer, str.pData->length );
937  }
938 #endif
939 
945  template< typename T >
947  {
948  assert(
951  pData->buffer, pData->length,
954  }
955 
967  bool equals( 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_reverseCompare_WithLength( pData->buffer, pData->length,
974  str.pData->buffer, str.pData->length ) == 0;
975  }
976 
991 #if defined LIBO_INTERNAL_ONLY
992  bool equalsIgnoreAsciiCase(std::u16string_view sv) const {
993  if ( sal_uInt32(pData->length) != sv.size() )
994  return false;
995  if ( pData->buffer == sv.data() )
996  return true;
997  return
999  pData->buffer, pData->length, sv.data(), sv.size())
1000  == 0;
1001  }
1002 #else
1003  bool equalsIgnoreAsciiCase( const OUString & str ) const
1004  {
1005  if ( pData->length != str.pData->length )
1006  return false;
1007  if ( pData == str.pData )
1008  return true;
1009  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
1010  str.pData->buffer, str.pData->length ) == 0;
1011  }
1012 #endif
1013 
1029 #if defined LIBO_INTERNAL_ONLY
1030  sal_Int32 compareToIgnoreAsciiCase(std::u16string_view sv) const {
1032  pData->buffer, pData->length, sv.data(), sv.size());
1033  }
1034 #else
1035  sal_Int32 compareToIgnoreAsciiCase( const OUString & str ) const
1036  {
1037  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
1038  str.pData->buffer, str.pData->length );
1039  }
1040 #endif
1041 
1047  template< typename T >
1049  {
1050  assert(
1052  return
1053  (pData->length
1056  pData->buffer, pData->length,
1058  literal))
1059  == 0);
1060  }
1061 
1077 #if defined LIBO_INTERNAL_ONLY
1078  bool match(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
1079  return
1081  pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1082  sv.size())
1083  == 0;
1084  }
1085 #else
1086  bool match( const OUString & str, sal_Int32 fromIndex = 0 ) const
1087  {
1088  return rtl_ustr_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1089  str.pData->buffer, str.pData->length, str.pData->length ) == 0;
1090  }
1091 #endif
1092 
1098  template< typename T >
1099  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
1100  {
1101  assert(
1103  return
1105  pData->buffer+fromIndex, pData->length-fromIndex,
1107  literal),
1109  == 0;
1110  }
1111 
1130 #if defined LIBO_INTERNAL_ONLY
1131  bool matchIgnoreAsciiCase(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
1132  return
1134  pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1135  sv.size())
1136  == 0;
1137  }
1138 #else
1139  bool matchIgnoreAsciiCase( const OUString & str, sal_Int32 fromIndex = 0 ) const
1140  {
1141  return rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1142  str.pData->buffer, str.pData->length,
1143  str.pData->length ) == 0;
1144  }
1145 #endif
1146 
1152  template< typename T >
1153  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
1154  {
1155  assert(
1157  return matchIgnoreAsciiCaseAsciiL(
1160  }
1161 
1178  sal_Int32 compareToAscii( const char* asciiStr ) const
1179  {
1180  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length, asciiStr );
1181  }
1182 
1206  "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
1207  sal_Int32 compareToAscii( const char * asciiStr, sal_Int32 maxLength ) const
1208  {
1209  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer, pData->length,
1210  asciiStr, maxLength );
1211  }
1212 
1231  sal_Int32 reverseCompareToAsciiL( const char * asciiStr, sal_Int32 asciiStrLength ) const
1232  {
1233  return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
1234  asciiStr, asciiStrLength );
1235  }
1236 
1252  bool equalsAscii( const char* asciiStr ) const
1253  {
1254  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length,
1255  asciiStr ) == 0;
1256  }
1257 
1274  bool equalsAsciiL( const char* asciiStr, sal_Int32 asciiStrLength ) const
1275  {
1276  if ( pData->length != asciiStrLength )
1277  return false;
1278 
1280  pData->buffer, asciiStr, asciiStrLength );
1281  }
1282 
1301  bool equalsIgnoreAsciiCaseAscii( const char * asciiStr ) const
1302  {
1303  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1304  }
1305 
1306 #if defined LIBO_INTERNAL_ONLY
1307  bool equalsIgnoreAsciiCaseAscii( std::string_view asciiStr ) const
1308  {
1309  return o3tl::make_unsigned(pData->length) == asciiStr.length()
1311  pData->buffer, pData->length, asciiStr.data(), asciiStr.length()) == 0;
1312  }
1313 #endif
1314 
1333  sal_Int32 compareToIgnoreAsciiCaseAscii( const char * asciiStr ) const
1334  {
1335  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr );
1336  }
1337 
1338 #if defined LIBO_INTERNAL_ONLY
1339  sal_Int32 compareToIgnoreAsciiCaseAscii( std::string_view asciiStr ) const
1340  {
1341  sal_Int32 nMax = std::min<size_t>(asciiStr.length(), std::numeric_limits<sal_Int32>::max());
1343  pData->buffer, pData->length, asciiStr.data(), nMax);
1344  if (result == 0 && o3tl::make_unsigned(pData->length) < asciiStr.length())
1345  result = -1;
1346  return result;
1347  }
1348 #endif
1349 
1369  bool equalsIgnoreAsciiCaseAsciiL( const char * asciiStr, sal_Int32 asciiStrLength ) const
1370  {
1371  if ( pData->length != asciiStrLength )
1372  return false;
1373 
1374  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1375  }
1376 
1397  bool matchAsciiL( const char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1398  {
1399  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1400  asciiStr, asciiStrLength ) == 0;
1401  }
1402 
1403  // This overload is left undefined, to detect calls of matchAsciiL that
1404  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1405  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1406  // platforms):
1407 #if SAL_TYPES_SIZEOFLONG == 8
1408  void matchAsciiL(char const *, sal_Int32, rtl_TextEncoding) const;
1409 #endif
1410 
1434  bool matchIgnoreAsciiCaseAsciiL( const char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1435  {
1436  return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1437  asciiStr, asciiStrLength ) == 0;
1438  }
1439 
1440  // This overload is left undefined, to detect calls of
1441  // matchIgnoreAsciiCaseAsciiL that erroneously use
1442  // RTL_CONSTASCII_USTRINGPARAM instead of RTL_CONSTASCII_STRINGPARAM (but
1443  // would lead to ambiguities on 32 bit platforms):
1444 #if SAL_TYPES_SIZEOFLONG == 8
1445  void matchIgnoreAsciiCaseAsciiL(char const *, sal_Int32, rtl_TextEncoding)
1446  const;
1447 #endif
1448 
1463 #if defined LIBO_INTERNAL_ONLY
1464  bool startsWith(std::u16string_view sv, OUString * rest = nullptr) const {
1465  auto const b = match(sv);
1466  if (b && rest != nullptr) {
1467  *rest = copy(sv.size());
1468  }
1469  return b;
1470  }
1471 #else
1472  bool startsWith(OUString const & str, OUString * rest = NULL) const {
1473  bool b = match(str);
1474  if (b && rest != NULL) {
1475  *rest = copy(str.getLength());
1476  }
1477  return b;
1478  }
1479 #endif
1480 
1486  template< typename T >
1488  T & literal, OUString * rest = NULL) const
1489  {
1490  assert(
1492  bool b
1494  <= sal_uInt32(pData->length))
1496  pData->buffer,
1498  literal),
1500  if (b && rest != NULL) {
1501  *rest = copy(
1503  }
1504  return b;
1505  }
1506 
1527 #if defined LIBO_INTERNAL_ONLY
1528  bool startsWithIgnoreAsciiCase(std::u16string_view sv, OUString * rest = nullptr) const {
1529  auto const b = matchIgnoreAsciiCase(sv);
1530  if (b && rest != nullptr) {
1531  *rest = copy(sv.size());
1532  }
1533  return b;
1534  }
1535 #else
1536  bool startsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL)
1537  const
1538  {
1539  bool b = matchIgnoreAsciiCase(str);
1540  if (b && rest != NULL) {
1541  *rest = copy(str.getLength());
1542  }
1543  return b;
1544  }
1545 #endif
1546 
1552  template< typename T >
1554  startsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1555  {
1556  assert(
1558  bool b
1560  <= sal_uInt32(pData->length))
1562  pData->buffer,
1565  literal),
1567  == 0);
1568  if (b && rest != NULL) {
1569  *rest = copy(
1571  }
1572  return b;
1573  }
1574 
1589 #if defined LIBO_INTERNAL_ONLY
1590  bool endsWith(std::u16string_view sv, OUString * rest = nullptr) const {
1591  auto const b = sv.size() <= sal_uInt32(pData->length)
1592  && match(sv, pData->length - sv.size());
1593  if (b && rest != nullptr) {
1594  *rest = copy(0, (pData->length - sv.size()));
1595  }
1596  return b;
1597  }
1598 #else
1599  bool endsWith(OUString const & str, OUString * rest = NULL) const {
1600  bool b = str.getLength() <= getLength()
1601  && match(str, getLength() - str.getLength());
1602  if (b && rest != NULL) {
1603  *rest = copy(0, getLength() - str.getLength());
1604  }
1605  return b;
1606  }
1607 #endif
1608 
1614  template< typename T >
1616  endsWith(T & literal, OUString * rest = NULL) const
1617  {
1618  assert(
1620  bool b
1622  <= sal_uInt32(pData->length))
1624  (pData->buffer + pData->length
1627  literal),
1629  if (b && rest != NULL) {
1630  *rest = copy(
1631  0,
1632  (getLength()
1634  }
1635  return b;
1636  }
1637 
1649  bool endsWithAsciiL(char const * asciiStr, sal_Int32 asciiStrLength)
1650  const
1651  {
1652  return asciiStrLength <= pData->length
1654  pData->buffer + pData->length - asciiStrLength, asciiStr,
1655  asciiStrLength);
1656  }
1657 
1678 #if defined LIBO_INTERNAL_ONLY
1679  bool endsWithIgnoreAsciiCase(std::u16string_view sv, OUString * rest = nullptr) const {
1680  auto const b = sv.size() <= sal_uInt32(pData->length)
1681  && matchIgnoreAsciiCase(sv, pData->length - sv.size());
1682  if (b && rest != nullptr) {
1683  *rest = copy(0, pData->length - sv.size());
1684  }
1685  return b;
1686  }
1687 #else
1688  bool endsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL) const
1689  {
1690  bool b = str.getLength() <= getLength()
1691  && matchIgnoreAsciiCase(str, getLength() - str.getLength());
1692  if (b && rest != NULL) {
1693  *rest = copy(0, getLength() - str.getLength());
1694  }
1695  return b;
1696  }
1697 #endif
1698 
1704  template< typename T >
1706  endsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1707  {
1708  assert(
1710  bool b
1712  <= sal_uInt32(pData->length))
1714  (pData->buffer + pData->length
1718  literal),
1720  == 0);
1721  if (b && rest != NULL) {
1722  *rest = copy(
1723  0,
1724  (getLength()
1726  }
1727  return b;
1728  }
1729 
1741  char const * asciiStr, sal_Int32 asciiStrLength) const
1742  {
1743  return asciiStrLength <= pData->length
1745  pData->buffer + pData->length - asciiStrLength,
1746  asciiStrLength, asciiStr, asciiStrLength)
1747  == 0);
1748  }
1749 
1750  friend bool operator == ( const OUString& rStr1, const OUString& rStr2 )
1751  { return rStr1.equals(rStr2); }
1752 
1753  friend bool operator != ( const OUString& rStr1, const OUString& rStr2 )
1754  { return !(operator == ( rStr1, rStr2 )); }
1755 
1756  friend bool operator < ( const OUString& rStr1, const OUString& rStr2 )
1757  { return rStr1.compareTo( rStr2 ) < 0; }
1758  friend bool operator > ( const OUString& rStr1, const OUString& rStr2 )
1759  { return rStr1.compareTo( rStr2 ) > 0; }
1760  friend bool operator <= ( const OUString& rStr1, const OUString& rStr2 )
1761  { return rStr1.compareTo( rStr2 ) <= 0; }
1762  friend bool operator >= ( const OUString& rStr1, const OUString& rStr2 )
1763  { return rStr1.compareTo( rStr2 ) >= 0; }
1764 
1765 #if defined LIBO_INTERNAL_ONLY
1766 
1767  template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1768  operator ==(OUString const & s1, T const & s2) {
1770  == 0;
1771  }
1772 
1773  template<typename T>
1774  friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1775  operator ==(OUString const & s1, T & s2) {
1776  return rtl_ustr_compare_WithLength(s1.getStr(), s1.getLength(), s2, rtl_ustr_getLength(s2))
1777  == 0;
1778  }
1779 
1780  template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1781  operator ==(T const & s1, OUString const & s2) {
1782  return rtl_ustr_compare_WithLength(s1, rtl_ustr_getLength(s1), s2.getStr(), s2.getLength())
1783  == 0;
1784  }
1785 
1786  template<typename T>
1787  friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1788  operator ==(T & s1, OUString const & s2) {
1789  return rtl_ustr_compare_WithLength(s1, rtl_ustr_getLength(s1), s2.getStr(), s2.getLength())
1790  == 0;
1791  }
1792 
1793  template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1794  operator !=(OUString const & s1, T const & s2) { return !(s1 == s2); }
1795 
1796  template<typename T>
1797  friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1798  operator !=(OUString const & s1, T & s2) { return !(s1 == s2); }
1799 
1800  template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1801  operator !=(T const & s1, OUString const & s2) { return !(s1 == s2); }
1802 
1803  template<typename T>
1804  friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1805  operator !=(T & s1, OUString const & s2) { return !(s1 == s2); }
1806 
1807 #else
1808 
1809  friend bool operator == ( const OUString& rStr1, const sal_Unicode * pStr2 )
1810  { return rStr1.compareTo( pStr2 ) == 0; }
1811  friend bool operator == ( const sal_Unicode * pStr1, const OUString& rStr2 )
1812  { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
1813 
1814  friend bool operator != ( const OUString& rStr1, const sal_Unicode * pStr2 )
1815  { return !(operator == ( rStr1, pStr2 )); }
1816  friend bool operator != ( const sal_Unicode * pStr1, const OUString& rStr2 )
1817  { return !(operator == ( pStr1, rStr2 )); }
1818 
1819 #endif
1820 
1828  template< typename T >
1830  {
1831  assert(
1833  return rString.equalsAsciiL(
1836  }
1844  template< typename T >
1846  {
1847  assert(
1849  return rString.equalsAsciiL(
1852  }
1860  template< typename T >
1862  {
1863  assert(
1865  return !rString.equalsAsciiL(
1868  }
1876  template< typename T >
1878  {
1879  assert(
1881  return !rString.equalsAsciiL(
1884  }
1885 
1886 #if defined LIBO_INTERNAL_ONLY
1887 
1888  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1889  operator ==(OUString const & string, T & literal) {
1890  return
1892  string.pData->buffer, string.pData->length,
1894  literal),
1896  == 0;
1897  }
1899  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1900  operator ==(T & literal, OUString const & string) {
1901  return
1903  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1904  literal),
1905  libreoffice_internal::ConstCharArrayDetector<T>::length,
1906  string.pData->buffer, string.pData->length)
1907  == 0;
1908  }
1910  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1911  operator !=(OUString const & string, T & literal) {
1912  return
1914  string.pData->buffer, string.pData->length,
1915  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1916  literal),
1917  libreoffice_internal::ConstCharArrayDetector<T>::length)
1918  != 0;
1919  }
1921  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1922  operator !=(T & literal, OUString const & string) {
1923  return
1925  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1926  literal),
1927  libreoffice_internal::ConstCharArrayDetector<T>::length,
1928  string.pData->buffer, string.pData->length)
1929  != 0;
1930  }
1931 #endif
1932 
1940  sal_Int32 hashCode() const
1941  {
1942  return rtl_ustr_hashCode_WithLength( pData->buffer, pData->length );
1943  }
1944 
1958  sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
1959  {
1960  sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1961  return (ret < 0 ? ret : ret+fromIndex);
1962  }
1963 
1973  sal_Int32 lastIndexOf( sal_Unicode ch ) const
1974  {
1975  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1976  }
1977 
1990  sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
1991  {
1992  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1993  }
1994 
2010 #if defined LIBO_INTERNAL_ONLY
2011  sal_Int32 indexOf(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
2012  auto const n = rtl_ustr_indexOfStr_WithLength(
2013  pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size());
2014  return n < 0 ? n : n + fromIndex;
2015  }
2016 #else
2017  sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
2018  {
2019  sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
2020  str.pData->buffer, str.pData->length );
2021  return (ret < 0 ? ret : ret+fromIndex);
2022  }
2023 #endif
2024 
2030  template< typename T >
2031  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
2032  {
2033  assert(
2035  sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
2036  pData->buffer + fromIndex, pData->length - fromIndex,
2039  return n < 0 ? n : n + fromIndex;
2040  }
2041 
2065  sal_Int32 indexOfAsciiL(
2066  char const * str, sal_Int32 len, sal_Int32 fromIndex = 0) const
2067  {
2068  sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
2069  pData->buffer + fromIndex, pData->length - fromIndex, str, len);
2070  return ret < 0 ? ret : ret + fromIndex;
2071  }
2072 
2073  // This overload is left undefined, to detect calls of indexOfAsciiL that
2074  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
2075  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
2076  // platforms):
2077 #if SAL_TYPES_SIZEOFLONG == 8
2078  void indexOfAsciiL(char const *, sal_Int32 len, rtl_TextEncoding) const;
2079 #endif
2080 
2096 #if defined LIBO_INTERNAL_ONLY
2097  sal_Int32 lastIndexOf(std::u16string_view sv) const {
2099  pData->buffer, pData->length, sv.data(), sv.size());
2100  }
2101 #else
2102  sal_Int32 lastIndexOf( const OUString & str ) const
2103  {
2104  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
2105  str.pData->buffer, str.pData->length );
2106  }
2107 #endif
2108 
2126 #if defined LIBO_INTERNAL_ONLY
2127  sal_Int32 lastIndexOf(std::u16string_view sv, sal_Int32 fromIndex) const {
2128  return rtl_ustr_lastIndexOfStr_WithLength(pData->buffer, fromIndex, sv.data(), sv.size());
2129  }
2130 #else
2131  sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
2132  {
2133  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
2134  str.pData->buffer, str.pData->length );
2135  }
2136 #endif
2137 
2143  template< typename T >
2145  {
2146  assert(
2149  pData->buffer, pData->length,
2152  }
2153 
2173  sal_Int32 lastIndexOfAsciiL(char const * str, sal_Int32 len) const
2174  {
2176  pData->buffer, pData->length, str, len);
2177  }
2178 
2189  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex ) const
2190  {
2191  return copy(beginIndex, getLength() - beginIndex);
2192  }
2193 
2206  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const
2207  {
2208  rtl_uString *pNew = NULL;
2209  rtl_uString_newFromSubString( &pNew, pData, beginIndex, count );
2210  return OUString( pNew, SAL_NO_ACQUIRE );
2211  }
2212 
2213 #if defined LIBO_INTERNAL_ONLY
2214 
2224  SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex ) const
2225  {
2226  assert(beginIndex >= 0);
2227  assert(beginIndex <= getLength());
2228  return subView(beginIndex, getLength() - beginIndex);
2229  }
2230 
2243  SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex, sal_Int32 count ) const
2244  {
2245  assert(beginIndex >= 0);
2246  assert(count >= 0);
2247  assert(beginIndex <= getLength());
2248  assert(count <= getLength() - beginIndex);
2249  return std::u16string_view(*this).substr(beginIndex, count);
2250  }
2251 #endif
2252 
2253 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2254 
2263  {
2264  rtl_uString* pNew = NULL;
2265  rtl_uString_newConcat( &pNew, pData, str.pData );
2266  return OUString( pNew, SAL_NO_ACQUIRE );
2267  }
2268 #endif
2269 
2270 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2271  friend OUString operator+( const OUString& rStr1, const OUString& rStr2 )
2272  {
2273  return rStr1.concat( rStr2 );
2274  }
2275 #endif
2276 
2277 // hide this from internal code to avoid ambiguous lookup error
2278 #ifndef LIBO_INTERNAL_ONLY
2279 
2292  SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const
2293  {
2294  rtl_uString* pNew = NULL;
2295  rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
2296  return OUString( pNew, SAL_NO_ACQUIRE );
2297  }
2298 #endif
2299 
2300 #ifdef LIBO_INTERNAL_ONLY
2301  SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, std::u16string_view newStr ) const
2302  {
2303  rtl_uString* pNew = NULL;
2304  rtl_uString_newReplaceStrAtUtf16L( &pNew, pData, index, count, newStr.data(), newStr.size() );
2305  return OUString( pNew, SAL_NO_ACQUIRE );
2306  }
2307 #endif
2308 
2323  {
2324  rtl_uString* pNew = NULL;
2325  rtl_uString_newReplace( &pNew, pData, oldChar, newChar );
2326  return OUString( pNew, SAL_NO_ACQUIRE );
2327  }
2328 
2347 #if defined LIBO_INTERNAL_ONLY
2348  [[nodiscard]] OUString replaceFirst(
2349  std::u16string_view from, std::u16string_view to, sal_Int32 * index = nullptr) const
2350  {
2351  rtl_uString * s = nullptr;
2352  sal_Int32 i = 0;
2354  &s, pData, from.data(), from.size(), to.data(), to.size(),
2355  index == nullptr ? &i : index);
2356  return OUString(s, SAL_NO_ACQUIRE);
2357  }
2358 #else
2360  OUString const & from, OUString const & to, sal_Int32 * index = NULL) const
2361  {
2362  rtl_uString * s = NULL;
2363  sal_Int32 i = 0;
2365  &s, pData, from.pData, to.pData, index == NULL ? &i : index);
2366  return OUString(s, SAL_NO_ACQUIRE);
2367  }
2368 #endif
2369 
2388 #if defined LIBO_INTERNAL_ONLY
2389  template<typename T> [[nodiscard]]
2391  T & from, std::u16string_view to, sal_Int32 * index = nullptr) const
2392  {
2394  rtl_uString * s = nullptr;
2395  sal_Int32 i = 0;
2399  index == nullptr ? &i : index);
2400  return OUString(s, SAL_NO_ACQUIRE);
2401  }
2402 #else
2403  template< typename T >
2405  sal_Int32 * index = NULL) const
2406  {
2408  rtl_uString * s = NULL;
2409  sal_Int32 i = 0;
2411  &s, pData,
2414  index == NULL ? &i : index);
2415  return OUString(s, SAL_NO_ACQUIRE);
2416  }
2417 #endif
2418 
2437 #if defined LIBO_INTERNAL_ONLY
2438  template<typename T> [[nodiscard]]
2440  std::u16string_view from, T & to, sal_Int32 * index = nullptr) const
2441  {
2443  rtl_uString * s = nullptr;
2444  sal_Int32 i = 0;
2446  &s, pData, from.data(), from.size(),
2448  libreoffice_internal::ConstCharArrayDetector<T>::length, index == nullptr ? &i : index);
2449  return OUString(s, SAL_NO_ACQUIRE);
2450  }
2451 #else
2452  template< typename T >
2454  sal_Int32 * index = NULL) const
2455  {
2457  rtl_uString * s = NULL;
2458  sal_Int32 i = 0;
2460  &s, pData, from.pData,
2463  index == NULL ? &i : index);
2464  return OUString(s, SAL_NO_ACQUIRE);
2465  }
2466 #endif
2467 
2486  template< typename T1, typename T2 >
2488  replaceFirst( T1& from, T2& to, sal_Int32 * index = NULL) const
2489  {
2492  rtl_uString * s = NULL;
2493  sal_Int32 i = 0;
2495  &s, pData,
2500  index == NULL ? &i : index);
2501  return OUString(s, SAL_NO_ACQUIRE);
2502  }
2503 
2519 #if defined LIBO_INTERNAL_ONLY
2520  [[nodiscard]] OUString replaceAll(
2521  std::u16string_view from, std::u16string_view to, sal_Int32 fromIndex = 0) const
2522  {
2523  rtl_uString * s = nullptr;
2524  rtl_uString_newReplaceAllFromIndexUtf16LUtf16L(
2525  &s, pData, from.data(), from.size(), to.data(), to.size(), fromIndex);
2526  return OUString(s, SAL_NO_ACQUIRE);
2527  }
2528 #else
2530  OUString const & from, OUString const & to, sal_Int32 fromIndex = 0) const
2531  {
2532  rtl_uString * s = NULL;
2533  rtl_uString_newReplaceAllFromIndex(&s, pData, from.pData, to.pData, fromIndex);
2534  return OUString(s, SAL_NO_ACQUIRE);
2535  }
2536 #endif
2537 
2551 #if defined LIBO_INTERNAL_ONLY
2552  template<typename T> [[nodiscard]]
2554  T & from, std::u16string_view to) const
2555  {
2557  rtl_uString * s = nullptr;
2561  return OUString(s, SAL_NO_ACQUIRE);
2562  }
2563 #else
2564  template< typename T >
2566  {
2568  rtl_uString * s = NULL;
2570  &s, pData,
2573  return OUString(s, SAL_NO_ACQUIRE);
2574  }
2575 #endif
2576 
2590 #if defined LIBO_INTERNAL_ONLY
2591  template<typename T> [[nodiscard]]
2593  std::u16string_view from, T & to) const
2594  {
2596  rtl_uString * s = nullptr;
2598  &s, pData, from.data(), from.size(),
2601  return OUString(s, SAL_NO_ACQUIRE);
2602  }
2603 #else
2604  template< typename T >
2606  {
2608  rtl_uString * s = NULL;
2610  &s, pData, from.pData,
2613  return OUString(s, SAL_NO_ACQUIRE);
2614  }
2615 #endif
2616 
2630  template< typename T1, typename T2 >
2632  replaceAll( T1& from, T2& to ) const
2633  {
2636  rtl_uString * s = NULL;
2638  &s, pData,
2643  return OUString(s, SAL_NO_ACQUIRE);
2644  }
2645 
2657  {
2658  rtl_uString* pNew = NULL;
2659  rtl_uString_newToAsciiLowerCase( &pNew, pData );
2660  return OUString( pNew, SAL_NO_ACQUIRE );
2661  }
2662 
2674  {
2675  rtl_uString* pNew = NULL;
2676  rtl_uString_newToAsciiUpperCase( &pNew, pData );
2677  return OUString( pNew, SAL_NO_ACQUIRE );
2678  }
2679 
2694  {
2695  rtl_uString* pNew = NULL;
2696  rtl_uString_newTrim( &pNew, pData );
2697  return OUString( pNew, SAL_NO_ACQUIRE );
2698  }
2699 
2724  OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const
2725  {
2726  rtl_uString * pNew = NULL;
2727  index = rtl_uString_getToken( &pNew, pData, token, cTok, index );
2728  return OUString( pNew, SAL_NO_ACQUIRE );
2729  }
2730 
2744  OUString getToken(sal_Int32 count, sal_Unicode separator) const {
2745  sal_Int32 n = 0;
2746  return getToken(count, separator, n);
2747  }
2748 
2757  bool toBoolean() const
2758  {
2759  return rtl_ustr_toBoolean( pData->buffer );
2760  }
2761 
2769  {
2770  return pData->buffer[0];
2771  }
2772 
2783  sal_Int32 toInt32( sal_Int16 radix = 10 ) const
2784  {
2785  return rtl_ustr_toInt32( pData->buffer, radix );
2786  }
2787 
2800  sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
2801  {
2802  return rtl_ustr_toUInt32( pData->buffer, radix );
2803  }
2804 
2815  sal_Int64 toInt64( sal_Int16 radix = 10 ) const
2816  {
2817  return rtl_ustr_toInt64( pData->buffer, radix );
2818  }
2819 
2832  sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
2833  {
2834  return rtl_ustr_toUInt64( pData->buffer, radix );
2835  }
2836 
2845  float toFloat() const
2846  {
2847  return rtl_ustr_toFloat( pData->buffer );
2848  }
2849 
2858  double toDouble() const
2859  {
2860  return rtl_ustr_toDouble( pData->buffer );
2861  }
2862 
2863 
2880  {
2881  rtl_uString * pNew = NULL;
2882  rtl_uString_intern( &pNew, pData );
2883  if (pNew == NULL) {
2884  throw std::bad_alloc();
2885  }
2886  return OUString( pNew, SAL_NO_ACQUIRE );
2887  }
2888 
2914  static OUString intern( const char * value, sal_Int32 length,
2915  rtl_TextEncoding encoding,
2916  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS,
2917  sal_uInt32 *pInfo = NULL )
2918  {
2919  rtl_uString * pNew = NULL;
2920  rtl_uString_internConvert( &pNew, value, length, encoding,
2921  convertFlags, pInfo );
2922  if (pNew == NULL) {
2923  throw std::bad_alloc();
2924  }
2925  return OUString( pNew, SAL_NO_ACQUIRE );
2926  }
2927 
2952  bool convertToString(OString * pTarget, rtl_TextEncoding nEncoding,
2953  sal_uInt32 nFlags) const
2954  {
2955  return rtl_convertUStringToString(&pTarget->pData, pData->buffer,
2956  pData->length, nEncoding, nFlags);
2957  }
2958 
3010  sal_uInt32 iterateCodePoints(
3011  sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1) const
3012  {
3014  pData, indexUtf16, incrementCodePoints);
3015  }
3016 
3026 #if defined LIBO_INTERNAL_ONLY
3027  static OUString fromUtf8(std::string_view rSource)
3028  {
3029  OUString aTarget;
3030  bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
3031  rSource.data(),
3032  rSource.length(),
3035  (void) bSuccess;
3036  assert(bSuccess);
3037  return aTarget;
3038  }
3039 #else
3040  static OUString fromUtf8(const OString& rSource)
3041  {
3042  OUString aTarget;
3043  bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
3044  rSource.getStr(),
3045  rSource.getLength(),
3048  (void) bSuccess;
3049  assert(bSuccess);
3050  return aTarget;
3051  }
3052 #endif
3053 
3064  OString toUtf8() const
3065  {
3066  OString aTarget;
3067  bool bSuccess = rtl_convertUStringToString(&aTarget.pData,
3068  getStr(),
3069  getLength(),
3072  (void) bSuccess;
3073  assert(bSuccess);
3074  return aTarget;
3075  }
3076 
3077 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3078 
3079  static auto number( int i, sal_Int16 radix = 10 )
3080  {
3081  return OUStringNumber<RTL_USTR_MAX_VALUEOFINT32>(rtl_ustr_valueOfInt32, i, radix);
3082  }
3083  static auto number( long long ll, sal_Int16 radix = 10 )
3084  {
3085  return OUStringNumber<RTL_USTR_MAX_VALUEOFINT64>(rtl_ustr_valueOfInt64, ll, radix);
3086  }
3087  static auto number( unsigned long long ll, sal_Int16 radix = 10 )
3088  {
3089  return OUStringNumber<RTL_USTR_MAX_VALUEOFUINT64>(rtl_ustr_valueOfUInt64, ll, radix);
3090  }
3091  static auto number( unsigned int i, sal_Int16 radix = 10 )
3092  {
3093  return number( static_cast< unsigned long long >( i ), radix );
3094  }
3095  static auto number( long i, sal_Int16 radix = 10)
3096  {
3097  return number( static_cast< long long >( i ), radix );
3098  }
3099  static auto number( unsigned long i, sal_Int16 radix = 10 )
3100  {
3101  return number( static_cast< unsigned long long >( i ), radix );
3102  }
3103 #else
3104 
3114  static OUString number( int i, sal_Int16 radix = 10 )
3115  {
3117  return OUString(aBuf, rtl_ustr_valueOfInt32(aBuf, i, radix));
3118  }
3121  static OUString number( unsigned int i, sal_Int16 radix = 10 )
3122  {
3123  return number( static_cast< unsigned long long >( i ), radix );
3124  }
3127  static OUString number( long i, sal_Int16 radix = 10)
3128  {
3129  return number( static_cast< long long >( i ), radix );
3130  }
3133  static OUString number( unsigned long i, sal_Int16 radix = 10 )
3134  {
3135  return number( static_cast< unsigned long long >( i ), radix );
3136  }
3139  static OUString number( long long ll, sal_Int16 radix = 10 )
3140  {
3142  return OUString(aBuf, rtl_ustr_valueOfInt64(aBuf, ll, radix));
3143  }
3146  static OUString number( unsigned long long ll, sal_Int16 radix = 10 )
3147  {
3149  return OUString(aBuf, rtl_ustr_valueOfUInt64(aBuf, ll, radix));
3150  }
3151 #endif
3152 
3162  static OUString number( float f )
3163  {
3164  rtl_uString* pNew = NULL;
3165  // Same as rtl::str::valueOfFP, used for rtl_ustr_valueOfFloat
3167  RTL_USTR_MAX_VALUEOFFLOAT - SAL_N_ELEMENTS("-x.E-xxx") + 1, '.',
3168  NULL, 0, true);
3169  if (pNew == NULL)
3170  throw std::bad_alloc();
3171 
3172  return OUString(pNew, SAL_NO_ACQUIRE);
3173  }
3174 
3184  static OUString number( double d )
3185  {
3186  rtl_uString* pNew = NULL;
3187  // Same as rtl::str::valueOfFP, used for rtl_ustr_valueOfDouble
3189  RTL_USTR_MAX_VALUEOFDOUBLE - SAL_N_ELEMENTS("-x.E-xxx") + 1, '.',
3190  NULL, 0, true);
3191  if (pNew == NULL)
3192  throw std::bad_alloc();
3193 
3194  return OUString(pNew, SAL_NO_ACQUIRE);
3195  }
3196 
3197 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3198  static auto boolean(bool b)
3199  {
3200  return OUStringNumber<RTL_USTR_MAX_VALUEOFBOOLEAN>(rtl_ustr_valueOfBoolean, b);
3201  }
3202 #else
3203 
3214  SAL_DEPRECATED("use boolean()") static OUString valueOf( sal_Bool b )
3215  {
3216  return boolean(b);
3217  }
3218 
3230  static OUString boolean( bool b )
3231  {
3233  return OUString(aBuf, rtl_ustr_valueOfBoolean(aBuf, b));
3234  }
3235 #endif
3236 
3244  SAL_DEPRECATED("convert to OUString or use directly") static OUString valueOf( sal_Unicode c )
3245  {
3246  return OUString( &c, 1 );
3247  }
3248 
3259  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
3260  {
3261  return number( i, radix );
3262  }
3263 
3274  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
3275  {
3276  return number( ll, radix );
3277  }
3278 
3288  SAL_DEPRECATED("use number()") static OUString valueOf( float f )
3289  {
3290  return number(f);
3291  }
3292 
3302  SAL_DEPRECATED("use number()") static OUString valueOf( double d )
3303  {
3304  return number(d);
3305  }
3306 
3322  static OUString createFromAscii( const char * value )
3323  {
3324  rtl_uString* pNew = NULL;
3325  rtl_uString_newFromAscii( &pNew, value );
3326  return OUString( pNew, SAL_NO_ACQUIRE );
3327  }
3328 
3329 #if defined LIBO_INTERNAL_ONLY
3330  static OUString createFromAscii(std::string_view value) {
3331  rtl_uString * p = nullptr;
3332  rtl_uString_newFromLiteral(&p, value.data(), value.size(), 0); //TODO: check for overflow
3333  return OUString(p, SAL_NO_ACQUIRE);
3334  }
3335  #endif
3336 
3337 #if defined LIBO_INTERNAL_ONLY
3338  operator std::u16string_view() const { return {getStr(), sal_uInt32(getLength())}; }
3339 #endif
3340 
3341 #if defined LIBO_INTERNAL_ONLY
3342  // A wrapper for the first expression in an
3343  //
3344  // OUString::Concat(e1) + e2 + ...
3345  //
3346  // concatenation chain, when neither of the first two e1, e2 is one of our rtl string-related
3347  // classes (so something like
3348  //
3349  // OUString s = "a" + (b ? std::u16string_view(u"c") : std::u16string_view(u"dd"));
3350  //
3351  // would not compile):
3352  template<typename T> [[nodiscard]] static
3353  OUStringConcat<OUStringConcatMarker, T>
3354  Concat(T const & value) { return OUStringConcat<OUStringConcatMarker, T>(value); }
3355 
3356  // This overload is needed so that an argument of type 'char const[N]' ends up as
3357  // 'OUStringConcat<rtl::OUStringConcatMarker, char const[N]>' rather than as
3358  // 'OUStringConcat<rtl::OUStringConcatMarker, char[N]>':
3359  template<typename T, std::size_t N> [[nodiscard]] static
3360  OUStringConcat<OUStringConcatMarker, T[N]>
3361  Concat(T (& value)[N]) { return OUStringConcat<OUStringConcatMarker, T[N]>(value); }
3362 #endif
3363 
3364 private:
3365  OUString & internalAppend( rtl_uString* pOtherData )
3366  {
3367  rtl_uString* pNewData = NULL;
3368  rtl_uString_newConcat( &pNewData, pData, pOtherData );
3369  if (pNewData == NULL) {
3370  throw std::bad_alloc();
3371  }
3372  rtl_uString_assign(&pData, pNewData);
3373  rtl_uString_release(pNewData);
3374  return *this;
3375  }
3376 
3377 };
3378 
3379 #if defined LIBO_INTERNAL_ONLY
3380 // Prevent the operator ==/!= overloads with 'sal_Unicode const *' parameter from
3381 // being selected for nonsensical code like
3382 //
3383 // if (ouIdAttr == nullptr)
3384 //
3385 void operator ==(OUString const &, std::nullptr_t) = delete;
3386 void operator ==(std::nullptr_t, OUString const &) = delete;
3387 void operator !=(OUString const &, std::nullptr_t) = delete;
3388 void operator !=(std::nullptr_t, OUString const &) = delete;
3389 #endif
3390 
3391 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3392 inline bool operator ==(OUString const & lhs, StringConcatenation<char16_t> const & rhs)
3393 { return lhs == std::u16string_view(rhs); }
3394 inline bool operator !=(OUString const & lhs, StringConcatenation<char16_t> const & rhs)
3395 { return lhs != std::u16string_view(rhs); }
3396 inline bool operator ==(StringConcatenation<char16_t> const & lhs, OUString const & rhs)
3397 { return std::u16string_view(lhs) == rhs; }
3398 inline bool operator !=(StringConcatenation<char16_t> const & lhs, OUString const & rhs)
3399 { return std::u16string_view(lhs) != rhs; }
3400 #endif
3401 
3402 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3403 
3408 template<>
3409 struct ToStringHelper< OUString >
3410 {
3411  static std::size_t length( const OUString& s ) { return s.getLength(); }
3412  sal_Unicode* operator() ( sal_Unicode* buffer, const OUString& s ) const { return addDataHelper( buffer, s.getStr(), s.getLength()); }
3413 };
3414 
3418 template<std::size_t N>
3419 struct ToStringHelper< OUStringLiteral<N> >
3420 {
3421  static std::size_t length( const OUStringLiteral<N>& str ) { return str.getLength(); }
3422  sal_Unicode* operator()( sal_Unicode* buffer, const OUStringLiteral<N>& str ) const { return addDataHelper( buffer, str.getStr(), str.getLength() ); }
3423 };
3424 
3428 template< typename charT, typename traits, typename T1, typename T2 >
3429 inline std::basic_ostream<charT, traits> & operator <<(
3430  std::basic_ostream<charT, traits> & stream, OUStringConcat< T1, T2 >&& concat)
3431 {
3432  return stream << OUString( std::move(concat) );
3433 }
3434 
3436 #endif
3437 
3444 {
3454  size_t operator()(const OUString& rString) const
3455  { return static_cast<size_t>(rString.hashCode()); }
3456 };
3457 
3458 /* ======================================================================= */
3459 
3477 #if defined LIBO_INTERNAL_ONLY
3478 inline OUString OStringToOUString( std::string_view rStr,
3479  rtl_TextEncoding encoding,
3480  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
3481 {
3482  return OUString( rStr.data(), rStr.length(), encoding, convertFlags );
3483 }
3484 #else
3485 inline OUString OStringToOUString( const OString & rStr,
3486  rtl_TextEncoding encoding,
3487  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
3488 {
3489  return OUString( rStr.getStr(), rStr.getLength(), encoding, convertFlags );
3490 }
3491 #endif
3492 
3510 #if defined LIBO_INTERNAL_ONLY
3511 inline OString OUStringToOString( std::u16string_view rUnicode,
3512  rtl_TextEncoding encoding,
3513  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
3514 {
3515  return OString( rUnicode.data(), rUnicode.length(), encoding, convertFlags );
3516 }
3517 #else
3518 inline OString OUStringToOString( const OUString & rUnicode,
3519  rtl_TextEncoding encoding,
3520  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
3521 {
3522  return OString( rUnicode.getStr(), rUnicode.getLength(), encoding, convertFlags );
3523 }
3524 #endif
3525 
3526 /* ======================================================================= */
3527 
3536 template< typename charT, typename traits >
3537 inline std::basic_ostream<charT, traits> & operator <<(
3538  std::basic_ostream<charT, traits> & stream, OUString const & rString)
3539 {
3540  return stream <<
3542  // best effort; potentially loses data due to conversion failures
3543  // (stray surrogate halves) and embedded null characters
3544 }
3545 
3546 } // namespace
3547 
3548 #ifdef RTL_STRING_UNITTEST
3549 namespace rtl
3550 {
3551 typedef rtlunittest::OUString OUString;
3552 }
3553 #endif
3554 
3555 // In internal code, allow to use classes like OUString without having to
3556 // explicitly refer to the rtl namespace, which is kind of superfluous given
3557 // that OUString itself is namespaced by its OU prefix:
3558 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3559 using ::rtl::OUString;
3560 using ::rtl::OUStringHash;
3563 using ::rtl::OUStringLiteral;
3564 using ::rtl::OUStringChar;
3565 using ::rtl::Concat2View;
3566 #endif
3567 
3568 #if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && defined _MANAGED)
3569 
3570 template<
3571 #if defined RTL_STRING_UNITTEST
3572  rtlunittest::
3573 #endif
3574  OUStringLiteral L>
3575 constexpr
3576 #if defined RTL_STRING_UNITTEST
3577  rtlunittest::
3578 #endif
3579  OUString
3580 operator ""_ustr() { return L; }
3581 
3582 #endif
3583 
3585 
3590 #if defined LIBO_INTERNAL_ONLY
3591 namespace std {
3592 
3593 template<>
3594 struct hash<::rtl::OUString>
3595 {
3596  std::size_t operator()(::rtl::OUString const & s) const
3597  {
3598  if constexpr (sizeof(std::size_t) == 8)
3599  {
3600  // return a hash that uses the full 64-bit range instead of a 32-bit value
3601  size_t n = s.getLength();
3602  for (sal_Int32 i = 0, len = s.getLength(); i < len; ++i)
3603  n = 37 * n + s[i];
3604  return n;
3605  }
3606  else
3607  return std::size_t(s.hashCode());
3608  }
3609 };
3610 
3611 }
3612 
3613 #endif
3614 
3616 #endif /* _RTL_USTRING_HXX */
3617 
3618 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_WARN_UNUSED_RESULT OUString replaceAll(OUString const &from, OUString const &to, sal_Int32 fromIndex=0) const
Returns a new string resulting from replacing all occurrences of a given substring with another subst...
Definition: ustring.hxx:2529
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1350
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters, ignoring the case of ASCII characters...
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:664
SAL_WARN_UNUSED_RESULT OUString concat(const OUString &str) const
Concatenates the specified string to the end of this string.
Definition: ustring.hxx:2262
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:3518
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: ustring.hxx:2832
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type reverseCompareTo(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:946
SAL_WARN_UNUSED_RESULT OUString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: ustring.hxx:2189
OUString()
New string containing no characters.
Definition: ustring.hxx:181
sal_Int32 getLength() const
Returns the length of this string.
Definition: ustring.hxx:821
#define RTL_TEXTENCODING_UTF8
Definition: textenc.h:117
SAL_DLLPUBLIC void rtl_uString_newReplaceAllFromIndex(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, rtl_uString const *to, sal_Int32 fromIndex) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
SAL_DLLPUBLIC void rtl_uString_intern(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Return a canonical representation for a string.
#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:68
SAL_DLLPUBLIC void rtl_uString_newTrim(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Create a new string by removing white space from both ends of another string.
OUString OStringToOUString(const OString &rStr, rtl_TextEncoding encoding, sal_uInt32 convertFlags=OSTRING_TO_OUSTRING_CVTFLAGS)
Convert an OString to an OUString, using a specific text encoding.
Definition: ustring.hxx:3485
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:3146
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstToAsciiL(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, char const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:2031
SAL_DLLPUBLIC void rtl_math_doubleToUString(rtl_uString **pResult, sal_Int32 *pResultCapacity, sal_Int32 nResultOffset, double fValue, enum rtl_math_StringFormat eFormat, sal_Int32 nDecPlaces, sal_Unicode cDecSeparator, sal_Int32 const *pGroups, sal_Unicode cGroupSeparator, sal_Bool bEraseTrailingDecZeros) SAL_THROW_EXTERN_C()
Conversions analogous to sprintf() using internal rounding.
sal_Int32 indexOf(const OUString &str, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
Definition: ustring.hxx:2017
SAL_DLLPUBLIC void rtl_uString_newToAsciiUpperCase(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Create a new string by converting all ASCII lowercase letters to uppercase within another string...
double toDouble() const
Returns the double value from this string.
Definition: ustring.hxx:2858
sal_Unicode toChar() const
Returns the first character from this string.
Definition: ustring.hxx:2768
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:1139
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfChar_WithLength(const sal_Unicode *str, sal_Int32 len, sal_Unicode ch) SAL_THROW_EXTERN_C()
Search for the last occurrence of a character within a string.
bool equalsAscii(const char *asciiStr) const
Perform a comparison of two strings.
Definition: ustring.hxx:1252
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:2360
SAL_DLLPUBLIC void rtl_string2UString(rtl_uString **newStr, const char *str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags) SAL_THROW_EXTERN_C()
Create a new Unicode string by converting a byte string, using a specific text encoding.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_compare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings.
const char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:690
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:1153
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWith(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:1487
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:1099
#define RTL_USTR_MAX_VALUEOFFLOAT
Definition: ustring.h:1026
bool startsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: ustring.hxx:1472
static OUString const & unacquired(rtl_uString *const *ppHandle)
Provides an OUString const & passing a storage pointer of an rtl_uString * handle.
Definition: ustring.hxx:560
#define RTL_USTR_MAX_VALUEOFUINT64
Definition: ustring.h:1007
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:1048
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstAsciiLAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
friend OUString operator+(const OUString &rStr1, const OUString &rStr2)
Definition: ustring.hxx:2271
sal_Int32 reverseCompareToAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Compares two strings in reverse order.
Definition: ustring.hxx:1231
static OUString fromUtf8(const OString &rSource)
Convert an OString to an OUString, assuming that the OString is UTF-8-encoded.
Definition: ustring.hxx:3040
SAL_DLLPUBLIC void rtl_uString_internConvert(rtl_uString **newStr, const char *str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags, sal_uInt32 *pInfo) SAL_THROW_EXTERN_C()
Return a canonical representation for a string.
sal_uInt32 iterateCodePoints(sal_Int32 *indexUtf16, sal_Int32 incrementCodePoints=1) const
Iterate through this string based on code points instead of UTF-16 code units.
Definition: ustring.hxx:3010
SAL_DLLPUBLIC void rtl_uString_newReplaceStrAt(rtl_uString **newStr, rtl_uString *str, sal_Int32 idx, sal_Int32 count, rtl_uString *subStr) SAL_THROW_EXTERN_C()
Create a new string by replacing a substring of another string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_compareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
static OUString number(unsigned int i, sal_Int16 radix=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:3121
A string buffer implements a mutable sequence of characters.
Definition: ustrbuf.hxx:72
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
bool operator!=(const Any &rAny, const C &value)
Template inequality operator: compares set value of left side any to right side value.
Definition: Any.hxx:677
const sal_Unicode * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:843
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:93
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1829
SAL_DLLPUBLIC void rtl_uString_newReplaceAllAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, rtl_uString const *to) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
SAL_DLLPUBLIC void rtl_uString_newToAsciiLowerCase(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Create a new string by converting all ASCII uppercase letters to lowercase within another string...
SAL_DLLPUBLIC sal_Bool rtl_ustr_asciil_reverseEquals_WithLength(const sal_Unicode *first, const char *second, sal_Int32 len) SAL_THROW_EXTERN_C()
Compare two strings from back to front for equality.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfBoolean(sal_Unicode *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWithIgnoreAsciiCase(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:1554
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type endsWithIgnoreAsciiCase(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:1706
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:103
bool equalsAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform a comparison of two strings.
Definition: ustring.hxx:1274
SAL_DLLPUBLIC sal_Int32 rtl_ustr_shortenedCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfStr_WithLength(const sal_Unicode *str, sal_Int32 len, const sal_Unicode *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of a substring within a string.
SAL_DLLPUBLIC sal_Bool rtl_convertStringToUString(rtl_uString **target, char const *source, sal_Int32 length, rtl_TextEncoding encoding, sal_uInt32 flags) SAL_THROW_EXTERN_C()
Converts a byte string to a Unicode string, signalling failure.
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:113
SAL_DLLPUBLIC sal_uInt64 rtl_ustr_toUInt64(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned long integer.
Definition: stringutils.hxx:146
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don&#39;t use, it&#39;s evil.") void doit(int nPara);.
Definition: types.h:492
sal_Int32 compareTo(const OUString &str) const
Compares two strings.
Definition: ustring.hxx:879
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:611
SAL_DLLPUBLIC sal_Int32 rtl_ustr_toInt32(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an integer.
static OUString intern(const char *value, sal_Int32 length, rtl_TextEncoding encoding, sal_uInt32 convertFlags=OSTRING_TO_OUSTRING_CVTFLAGS, sal_uInt32 *pInfo=NULL)
Return a canonical representation for a converted string.
Definition: ustring.hxx:2914
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:2131
SAL_DLLPUBLIC void rtl_uString_newConcatUtf16L(rtl_uString **newString, rtl_uString *left, sal_Unicode const *right, sal_Int32 rightLength)
Create a new string that is the concatenation of two other strings.
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T1, typename libreoffice_internal::ConstCharArrayDetector< T2, OUString >::Type >::Type replaceAll(T1 &from, T2 &to) const
Returns a new string resulting from replacing all occurrences of a given substring with another subst...
Definition: ustring.hxx:2632
sal_Int32 compareToIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1035
SAL_DLLPUBLIC void rtl_uString_assign(rtl_uString **str, rtl_uString *rightValue) SAL_THROW_EXTERN_C()
Assign a new value to a string.
SAL_DLLPUBLIC float rtl_ustr_toFloat(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a float.
SAL_DLLPUBLIC void rtl_uString_acquire(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Increment the reference count of a string.
OUString getToken(sal_Int32 token, sal_Unicode cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: ustring.hxx:2724
bool convertToString(OString *pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) const
Converts to an OString, signalling failure.
Definition: ustring.hxx:2952
#define RTL_USTR_MAX_VALUEOFDOUBLE
Definition: ustring.h:1045
SAL_DLLPUBLIC void rtl_uString_newFromAscii(rtl_uString **newStr, const char *value) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
SAL_WARN_UNUSED_RESULT OUString toAsciiLowerCase() const
Converts from this string all ASCII uppercase characters (65-90) to ASCII lowercase characters (97-12...
Definition: ustring.hxx:2656
SAL_DLLPUBLIC sal_uInt32 rtl_ustr_toUInt32(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned integer.
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: ustring.hxx:2783
#define RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR
Definition: textcvt.h:151
SAL_WARN_UNUSED_RESULT OUString copy(sal_Int32 beginIndex, sal_Int32 count) const
Returns a new string that is a substring of this string.
Definition: ustring.hxx:2206
SAL_DLLPUBLIC void rtl_uString_newFromStr_WithLength(rtl_uString **newStr, const sal_Unicode *value, sal_Int32 len) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T, OUString >::Type replaceAll(OUString const &from, T &to) const
Returns a new string resulting from replacing all occurrences of a given substring with another subst...
Definition: ustring.hxx:2605
sal_uInt16 sal_Unicode
Definition: types.h:123
SAL_DLLPUBLIC void rtl_uString_newConcat(rtl_uString **newStr, rtl_uString *left, rtl_uString *right) SAL_THROW_EXTERN_C()
Create a new string that is the concatenation of two other strings.
SAL_DLLPUBLIC void rtl_uString_newFromLiteral(rtl_uString **newStr, const char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
unsigned char sal_Bool
Definition: types.h:38
static OUString createFromAscii(const char *value)
Returns an OUString copied without conversion from an ASCII character string.
Definition: ustring.hxx:3322
sal_Int32 compareTo(const OUString &str, sal_Int32 maxLength) const
Compares two strings with a maximum count of characters.
Definition: ustring.hxx:908
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:2673
__sal_NoAcquire
Definition: types.h:370
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Decrement the reference count of a string.
Like sprintf() G, &#39;F&#39; or &#39;E&#39; format is used depending on which one is more compact.
Definition: math.h:53
sal_Int32 indexOfAsciiL(char const *str, sal_Int32 len, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified ASCII substring...
Definition: ustring.hxx:2065
A helper to use OUStrings with hash maps.
Definition: ustring.hxx:3443
static OUString number(float f)
Returns the string representation of the float argument.
Definition: ustring.hxx:3162
sal_Int32 compareToAscii(const char *asciiStr) const
Compares two strings.
Definition: ustring.hxx:1178
SAL_DLLPUBLIC void rtl_uString_new(rtl_uString **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
#define OSTRING_TO_OUSTRING_CVTFLAGS
Definition: ustring.h:2180
SAL_DLLPUBLIC sal_Bool rtl_ustr_toBoolean(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
#define RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR
Definition: textcvt.h:75
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T, OUString >::Type replaceAll(T &from, OUString const &to) const
Returns a new string resulting from replacing all occurrences of a given substring with another subst...
Definition: ustring.hxx:2565
bool equalsIgnoreAsciiCaseAscii(const char *asciiStr) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1301
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:1958
SAL_DLLPUBLIC void rtl_uString_ensureCapacity(rtl_uString **str, sal_Int32 size) SAL_THROW_EXTERN_C()
Ensure a string has enough space for a given number of characters.
SAL_DLLPUBLIC rtl_uString * rtl_uString_alloc(sal_Int32 nLen) SAL_THROW_EXTERN_C()
Allocate a new string containing space for a given number of characters.
OUString(rtl_uString *str)
New string from OUString data.
Definition: ustring.hxx:247
SAL_DLLPUBLIC sal_Int32 rtl_ustr_hashCode_WithLength(const sal_Unicode *str, sal_Int32 len) SAL_THROW_EXTERN_C()
Return a hash code for a string.
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type endsWith(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:1616
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, rtl_uString const *to, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:37
SAL_DLLPUBLIC sal_Int32 rtl_uString_getToken(rtl_uString **newStr, rtl_uString *str, sal_Int32 token, sal_Unicode cTok, sal_Int32 idx) SAL_THROW_EXTERN_C()
Create a new string by extracting a single token from another string.
bool matchAsciiL(const char *asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:1397
#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:145
SAL_DLLPUBLIC sal_Int64 rtl_ustr_toInt64(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as a long integer.
Definition: bootstrap.hxx:33
SAL_WARN_UNUSED_RESULT OUString replace(sal_Unicode oldChar, sal_Unicode newChar) const
Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar...
Definition: ustring.hxx:2322
SAL_DLLPUBLIC void rtl_uString_newReplace(rtl_uString **newStr, rtl_uString *str, sal_Unicode oldChar, sal_Unicode newChar) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a single character within another string...
bool equalsIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1003
bool match(const OUString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:1086
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:2453
SAL_DLLPUBLIC sal_Int32 rtl_ustr_asciil_reverseCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings from back to front.
SAL_DLLPUBLIC sal_uInt32 rtl_uString_iterateCodePoints(rtl_uString const *string, sal_Int32 *indexUtf16, sal_Int32 incrementCodePoints)
Iterate through a string based on code points instead of UTF-16 code units.
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1861
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: ustring.hxx:2800
SAL_DLLPUBLIC void rtl_uString_newConcatAsciiL(rtl_uString **newString, rtl_uString *left, char const *right, sal_Int32 rightLength)
Create a new string that is the concatenation of two other strings.
bool equals(const OUString &str) const
Perform a comparison of two strings.
Definition: ustring.hxx:967
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(sal_Unicode const *first, sal_Int32 firstLen, char const *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_compare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second) SAL_THROW_EXTERN_C()
Compare two strings.
bool matchIgnoreAsciiCaseAsciiL(const char *asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string, ignoring the case of ASCII letters.
Definition: ustring.hxx:1434
static OUString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: ustring.hxx:3114
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfStr_WithLength(const sal_Unicode *str, sal_Int32 len, const sal_Unicode *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of a substring within a string.
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition: ustring.hxx:692
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:192
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:171
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:619
definition of a no acquire enum for ctors
Definition: types.h:374
~OUString()
Release the string data.
Definition: ustring.hxx:534
OString toUtf8() const
Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully.
Definition: ustring.hxx:3064
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:453
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:2404
#define SAL_N_ELEMENTS(arr)
Definition: macros.h:51
sal_Int32 lastIndexOf(const OUString &str) const
Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the end.
Definition: ustring.hxx:2102
bool endsWithAsciiL(char const *asciiStr, sal_Int32 asciiStrLength) const
Check whether this string ends with a given ASCII string.
Definition: ustring.hxx:1649
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfAscii_WithLength(sal_Unicode const *str, sal_Int32 len, char const *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of an ASCII substring within a string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfInt32(sal_Unicode *str, sal_Int32 i, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an integer.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters, ignoring the case of ASCII characters...
OUString(rtl_uString *str, __sal_NoAcquire)
New OUString from OUString data without acquiring it.
Definition: ustring.hxx:268
SAL_DLLPUBLIC void rtl_uString_newReplaceAllUtf16LAsciiL(rtl_uString **newStr, rtl_uString *str, sal_Unicode const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
static OUString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: ustring.hxx:3230
SAL_DLLPUBLIC void rtl_uString_newReplaceAllAsciiLAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfChar_WithLength(const sal_Unicode *str, sal_Int32 len, sal_Unicode ch) SAL_THROW_EXTERN_C()
Search for the first occurrence of a character within a string.
OUString(const sal_Unicode *value)
New string from a Unicode character buffer array.
Definition: ustring.hxx:317
SAL_DLLPUBLIC void rtl_uString_newReplaceFirst(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, rtl_uString const *to, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
sal_Int32 oslInterlockedCount
Definition: interlck.h:44
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstUtf16LAsciiL(rtl_uString **newStr, rtl_uString *str, sal_Unicode const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
SAL_DLLPUBLIC sal_Int32 rtl_ustr_getLength(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Return the length of a string.
sal_Int32 lastIndexOf(sal_Unicode ch) const
Returns the index within this string of the last occurrence of the specified character, searching backward starting at the end.
Definition: ustring.hxx:1973
OUString(const OUString &str)
New string from OUString.
Definition: ustring.hxx:195
Definition: stringutils.hxx:148
sal_Int32 lastIndexOfAsciiL(char const *str, sal_Int32 len) const
Returns the index within this string of the last occurrence of the specified ASCII substring...
Definition: ustring.hxx:2173
SAL_DLLPUBLIC void rtl_uString_newFromStr(rtl_uString **newStr, const sal_Unicode *value) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfInt64(sal_Unicode *str, sal_Int64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of a long integer.
SAL_WARN_UNUSED_RESULT OUString replaceAt(sal_Int32 index, sal_Int32 count, const OUString &newStr) const
Returns a new string resulting from replacing n = count characters from position index in this string...
Definition: ustring.hxx:2292
bool equalsIgnoreAsciiCaseAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1369
SAL_DLLPUBLIC sal_Int32 rtl_ustr_reverseCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings from back to front.
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:831
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...
#define SAL_CONSTEXPR
C++11 "constexpr" feature.
Definition: types.h:422
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:2693
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:1536
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be used.
Definition: types.h:288
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: ustring.hxx:2815
OUString(const sal_Unicode *value, sal_Int32 length)
New string from a Unicode character buffer array.
Definition: ustring.hxx:333
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:584
#define RTL_USTR_MAX_VALUEOFBOOLEAN
Definition: ustring.h:919
SAL_DLLPUBLIC void rtl_uString_newFromSubString(rtl_uString **newStr, const rtl_uString *from, sal_Int32 beginIndex, sal_Int32 count) SAL_THROW_EXTERN_C()
Allocate a new string that is a substring of this string.
OUString(T &literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
New string from an 8-Bit string literal that is expected to contain only characters in the ASCII set ...
Definition: ustring.hxx:355
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_shortenedCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters.
size_t operator()(const OUString &rString) const
Compute a hash code for a string.
Definition: ustring.hxx:3454
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:2488
sal_Int32 compareToIgnoreAsciiCaseAscii(const char *asciiStr) const
Compares two ASCII strings ignoring case.
Definition: ustring.hxx:1333
SAL_DLLPUBLIC void rtl_uString_newReplaceAllAsciiLUtf16L(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, sal_Unicode const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type lastIndexOf(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:2144
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstUtf16LUtf16L(rtl_uString **newStr, rtl_uString *str, sal_Unicode const *from, sal_Int32 fromLength, sal_Unicode const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfAscii_WithLength(sal_Unicode const *str, sal_Int32 len, char const *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of an ASCII substring within a string.
bool endsWithIgnoreAsciiCase(OUString const &str, OUString *rest=NULL) const
Check whether this string ends with a given string, ignoring the case of ASCII letters.
Definition: ustring.hxx:1688
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:3139
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1845
bool endsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string ends with a given substring.
Definition: ustring.hxx:1599
#define RTL_USTR_MAX_VALUEOFINT32
Definition: ustring.h:961
SAL_DLLPUBLIC double rtl_ustr_toDouble(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a double.
SAL_DLLPUBLIC void rtl_uString_newReplaceAllToAsciiL(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, char const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
float toFloat() const
Returns the float value from this string.
Definition: ustring.hxx:2845
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: ustring.hxx:808
#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
Definition: textcvt.h:72
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfUInt64(sal_Unicode *str, sal_uInt64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an unsigned long integer.
OUString intern() const
Return a canonical representation for a string.
Definition: ustring.hxx:2879
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:3127
#define RTL_USTR_MAX_VALUEOFINT64
Definition: ustring.h:984
static OUString number(double d)
Returns the string representation of the double argument.
Definition: ustring.hxx:3184
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1877
OUString(sal_uInt32 const *codePoints, sal_Int32 codePointCount)
Create a new string from an array of Unicode code points.
Definition: ustring.hxx:480
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:2359
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:3133
OUString getToken(sal_Int32 count, sal_Unicode separator) const
Returns a token from the string.
Definition: ustring.hxx:2744
sal_Int32 reverseCompareTo(const OUString &str) const
Compares two strings in reverse order.
Definition: ustring.hxx:933
OUString(sal_Unicode value)
New string from a single Unicode character.
Definition: ustring.hxx:276
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:1990
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:1740
bool toBoolean() const
Returns the Boolean value from this string.
Definition: ustring.hxx:2757
SAL_DLLPUBLIC sal_Bool rtl_convertUStringToString(rtl_String **pTarget, sal_Unicode const *pSource, sal_Int32 nLength, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) SAL_THROW_EXTERN_C()
Converts a Unicode string to a byte string, signalling failure.
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: ustring.hxx:1940