LibreOffice
LibreOffice 7.1 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 #ifndef INCLUDED_RTL_USTRING_HXX
21 #define INCLUDED_RTL_USTRING_HXX
22 
23 #include "sal/config.h"
24 
25 #include <cassert>
26 #include <cstddef>
27 #include <cstdlib>
28 #include <limits>
29 #include <new>
30 #include <ostream>
31 #include <utility>
32 
33 #if defined LIBO_INTERNAL_ONLY
34 #include <string_view>
35 #include <type_traits>
36 #endif
37 
38 #include "rtl/ustring.h"
39 #include "rtl/string.hxx"
40 #include "rtl/stringutils.hxx"
41 #include "rtl/textenc.h"
42 
43 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
44 #include "config_global.h"
45 #include "rtl/stringconcat.hxx"
46 #endif
47 
48 #ifdef RTL_STRING_UNITTEST
49 extern bool rtl_string_unittest_invalid_conversion;
50 #endif
51 
52 // The unittest uses slightly different code to help check that the proper
53 // calls are made. The class is put into a different namespace to make
54 // sure the compiler generates a different (if generating also non-inline)
55 // copy of the function and does not merge them together. The class
56 // is "brought" into the proper rtl namespace by a typedef below.
57 #ifdef RTL_STRING_UNITTEST
58 #define rtl rtlunittest
59 #endif
60 
61 namespace rtl
62 {
63 
64 class OUStringBuffer;
65 
66 #ifdef RTL_STRING_UNITTEST
67 #undef rtl
68 #endif
69 
70 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
72 
79 template<std::size_t N> class SAL_WARN_UNUSED OUStringLiteral {
80  static_assert(N != 0);
81  static_assert(N - 1 <= std::numeric_limits<sal_Int32>::max(), "literal too long");
82 
83 public:
84 #if HAVE_CPP_CONSTEVAL
85  consteval
86 #else
87  constexpr
88 #endif
89  OUStringLiteral(char16_t const (&literal)[N]) {
90  assertLayout();
91  assert(literal[N - 1] == '\0');
92  //TODO: Use C++20 constexpr std::copy_n (P0202R3):
93  for (std::size_t i = 0; i != N; ++i) {
94  buffer[i] = literal[i];
95  }
96  }
97 
98  constexpr sal_Int32 getLength() const { return length; }
99 
100  constexpr sal_Unicode const * getStr() const SAL_RETURNS_NONNULL { return buffer; }
101 
102  constexpr operator std::u16string_view() const { return {buffer, sal_uInt32(length)}; }
103 
104 private:
105  static constexpr void assertLayout() {
106  // These static_asserts verifying the layout compatibility with rtl_uString cannot be class
107  // member declarations, as offsetof requires a complete type, so defer them to here:
108  static_assert(offsetof(OUStringLiteral, refCount) == offsetof(rtl_uString, refCount));
109  static_assert(std::is_same_v<decltype(refCount), decltype(rtl_uString::refCount)>);
110  static_assert(offsetof(OUStringLiteral, length) == offsetof(rtl_uString, length));
111  static_assert(std::is_same_v<decltype(length), decltype(rtl_uString::length)>);
112  static_assert(offsetof(OUStringLiteral, buffer) == offsetof(rtl_uString, buffer));
113  static_assert(
114  std::is_same_v<
115  std::remove_extent_t<decltype(buffer)>,
116  std::remove_extent_t<decltype(rtl_uString::buffer)>>);
117  }
118 
119  // Same layout as rtl_uString (include/rtl/ustring.h):
120  oslInterlockedCount refCount = 0x40000000; // SAL_STRING_STATIC_FLAG (sal/rtl/strimp.hxx)
121  sal_Int32 length = N - 1;
122  sal_Unicode buffer[N] = {}; //TODO: drop initialization for C++20 (P1331R2)
123 };
124 
125 #if defined RTL_STRING_UNITTEST
126 namespace libreoffice_internal {
127 template<std::size_t N> struct ExceptConstCharArrayDetector<OUStringLiteral<N>> {};
128 template<std::size_t N> struct ExceptCharArrayDetector<OUStringLiteral<N>> {};
129 }
130 #endif
131 
133 #endif
134 
135 /* ======================================================================= */
136 
160 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OUString
161 {
162 public:
164  rtl_uString * pData;
166 
171  {
172  pData = NULL;
173  rtl_uString_new( &pData );
174  }
175 
181  OUString( const OUString & str )
182  {
183  pData = str.pData;
184  rtl_uString_acquire( pData );
185  }
186 
187 #if defined LIBO_INTERNAL_ONLY
194  OUString( OUString && str ) noexcept
195  {
196  pData = str.pData;
197  str.pData = nullptr;
198  rtl_uString_new( &str.pData );
199  }
200 #endif
201 
207  OUString( rtl_uString * str )
208  {
209  pData = str;
210  rtl_uString_acquire( pData );
211  }
212 
221  OUString( rtl_uString * str, __sal_NoAcquire )
222  { pData = str; }
223 
229  explicit OUString( sal_Unicode value )
230  : pData (NULL)
231  {
232  rtl_uString_newFromStr_WithLength( &pData, &value, 1 );
233  }
234 
235 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
237  // Catch inadvertent conversions to the above ctor (but still allow
238  // construction from char literals):
239  OUString(int) = delete;
240  explicit OUString(char c):
241  OUString(sal_Unicode(static_cast<unsigned char>(c)))
242  {}
244 #endif
245 
246 #if defined LIBO_INTERNAL_ONLY
247 
248  template<typename T> explicit OUString(
249  T const & value,
250  typename libreoffice_internal::CharPtrDetector<T, libreoffice_internal::Dummy>::TypeUtf16
251  = libreoffice_internal::Dummy()):
252  pData(nullptr)
253  { rtl_uString_newFromStr(&pData, value); }
254 
255  template<typename T> explicit OUString(
256  T & value,
257  typename
258  libreoffice_internal::NonConstCharArrayDetector<T, libreoffice_internal::Dummy>::TypeUtf16
259  = libreoffice_internal::Dummy()):
260  pData(nullptr)
261  { rtl_uString_newFromStr(&pData, value); }
262 
263 #else
264 
270  OUString( const sal_Unicode * value )
271  {
272  pData = NULL;
273  rtl_uString_newFromStr( &pData, value );
274  }
275 
276 #endif
277 
286  OUString( const sal_Unicode * value, sal_Int32 length )
287  {
288  pData = NULL;
289  rtl_uString_newFromStr_WithLength( &pData, value, length );
290  }
291 
307  template< typename T >
309  {
310  assert(
312  pData = NULL;
314  rtl_uString_new(&pData);
315  } else {
317  &pData,
319  literal),
321  }
322 #ifdef RTL_STRING_UNITTEST
323  rtl_string_unittest_const_literal = true;
324 #endif
325  }
326 
327 #if defined LIBO_INTERNAL_ONLY
329  template<typename T> OUString(
330  T & literal,
332  T, libreoffice_internal::Dummy>::TypeUtf16
334  pData(nullptr)
335  {
336  assert(
339  rtl_uString_new(&pData);
340  } else {
342  &pData,
343  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
344  literal),
345  libreoffice_internal::ConstCharArrayDetector<T>::length);
346  }
347  }
348 #endif
349 
350 #if defined LIBO_INTERNAL_ONLY && defined RTL_STRING_UNITTEST
352 
356  template< typename T >
357  OUString( T&, typename libreoffice_internal::ExceptConstCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
358  {
359  pData = NULL;
360  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
361  rtl_string_unittest_invalid_conversion = true;
362  }
367  template< typename T >
368  OUString( const T&, typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
369  {
370  pData = NULL;
371  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
372  rtl_string_unittest_invalid_conversion = true;
373  }
375 #endif
376 
377 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
379 
384  template<std::size_t N> OUString(OUStringLiteral<N> const & literal):
385  pData(const_cast<rtl_uString *>(reinterpret_cast<rtl_uString const *>(&literal))) {}
386  template<std::size_t N> OUString(OUStringLiteral<N> &&) = delete;
388 #endif
389 
404  OUString( const char * value, sal_Int32 length,
405  rtl_TextEncoding encoding,
406  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
407  {
408  pData = NULL;
409  rtl_string2UString( &pData, value, length, encoding, convertFlags );
410  if (pData == NULL) {
411  throw std::bad_alloc();
412  }
413  }
414 
431  explicit OUString(
432  sal_uInt32 const * codePoints, sal_Int32 codePointCount):
433  pData(NULL)
434  {
435  rtl_uString_newFromCodePoints(&pData, codePoints, codePointCount);
436  if (pData == NULL) {
437  throw std::bad_alloc();
438  }
439  }
440 
441 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
446  template< typename T1, typename T2 >
447  OUString( OUStringConcat< T1, T2 >&& c )
448  {
449  const sal_Int32 l = c.length();
450  pData = rtl_uString_alloc( l );
451  if (l != 0)
452  {
453  sal_Unicode* end = c.addData( pData->buffer );
454  pData->length = l;
455  *end = '\0';
456  // TODO realloc in case pData->length is noticeably smaller than l?
457  }
458  }
459 
464  template< typename T >
465  OUString( OUStringNumber< T >&& n )
466  : OUString( n.buf, n.length )
467  {}
468 #endif
469 
470 #if defined LIBO_INTERNAL_ONLY
471  OUString(std::u16string_view sv) {
472  if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
473  throw std::bad_alloc();
474  }
475  pData = nullptr;
476  rtl_uString_newFromStr_WithLength(&pData, sv.data(), sv.size());
477  }
478 #endif
479 
484  {
485  rtl_uString_release( pData );
486  }
487 
499  static OUString const & unacquired( rtl_uString * const * ppHandle )
500  { return * reinterpret_cast< OUString const * >( ppHandle ); }
501 
507  OUString & operator=( const OUString & str )
508  {
509  rtl_uString_assign( &pData, str.pData );
510  return *this;
511  }
512 
513 #if defined LIBO_INTERNAL_ONLY
520  OUString & operator=( OUString && str ) noexcept
521  {
522  rtl_uString_release( pData );
523  pData = str.pData;
524  str.pData = nullptr;
525  rtl_uString_new( &str.pData );
526  return *this;
527  }
528 #endif
529 
542  template< typename T >
544  {
545  assert(
548  rtl_uString_new(&pData);
549  } else {
551  &pData,
553  literal),
555  }
556  return *this;
557  }
558 
559 #if defined LIBO_INTERNAL_ONLY
561  template<typename T>
562  typename
564  operator =(T & literal) {
566  rtl_uString_new(&pData);
567  } else {
569  &pData,
570  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
571  literal),
572  libreoffice_internal::ConstCharArrayDetector<T>::length);
573  }
574  return *this;
575  }
576 
578  template<std::size_t N> OUString & operator =(OUStringLiteral<N> const & literal) {
579  if (literal.getLength() == 0) {
580  rtl_uString_new(&pData);
581  } else {
582  rtl_uString_newFromStr_WithLength(&pData, literal.getStr(), literal.getLength());
583  }
584  return *this;
585  }
586 
587  template<typename T>
588  OUString & operator =(OUStringNumber<T> && n) {
589  // n.length should never be zero, so no need to add an optimization for that case
590  rtl_uString_newFromStr_WithLength(&pData, n.buf, n.length);
591  return *this;
592  }
593 
594  OUString & operator =(std::u16string_view sv) {
595  if (sv.empty()) {
596  rtl_uString_new(&pData);
597  } else {
598  rtl_uString_newFromStr_WithLength(&pData, sv.data(), sv.size());
599  }
600  return *this;
601  }
602 #endif
603 
604 #if defined LIBO_INTERNAL_ONLY
613  inline OUString & operator+=( const OUStringBuffer & str ) &;
614 #endif
615 
623  OUString & operator+=( const OUString & str )
624 #if defined LIBO_INTERNAL_ONLY
625  &
626 #endif
627  {
628  return internalAppend(str.pData);
629  }
630 #if defined LIBO_INTERNAL_ONLY
631  void operator+=(OUString const &) && = delete;
632 #endif
633 
640  template<typename T>
642  operator +=(T & literal)
643 #if defined LIBO_INTERNAL_ONLY
644  &
645 #endif
646  {
647  assert(
650  &pData, pData,
653  return *this;
654  }
655 #if defined LIBO_INTERNAL_ONLY
656  template<typename T>
658  operator +=(T &) && = delete;
659 #endif
660 
661 #if defined LIBO_INTERNAL_ONLY
663  template<typename T>
664  typename
666  operator +=(T & literal) & {
668  &pData, pData,
671  return *this;
672  }
673  template<typename T>
674  typename
675  libreoffice_internal::ConstCharArrayDetector<T, OUString &>::TypeUtf16
676  operator +=(T &) && = delete;
677 
679  template<std::size_t N> OUString & operator +=(OUStringLiteral<N> const & literal) & {
680  rtl_uString_newConcatUtf16L(&pData, pData, literal.getStr(), literal.getLength());
681  return *this;
682  }
683  template<std::size_t N> void operator +=(OUStringLiteral<N> const &) && = delete;
684 
685  OUString & operator +=(std::u16string_view sv) & {
686  if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
687  throw std::bad_alloc();
688  }
689  rtl_uString_newConcatUtf16L(&pData, pData, sv.data(), sv.size());
690  return *this;
691  }
692  void operator +=(std::u16string_view) && = delete;
693 #endif
694 
695 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
700  template< typename T1, typename T2 >
701  OUString& operator+=( OUStringConcat< T1, T2 >&& c ) & {
702  sal_Int32 l = c.length();
703  if( l == 0 )
704  return *this;
705  l += pData->length;
706  rtl_uString_ensureCapacity( &pData, l );
707  sal_Unicode* end = c.addData( pData->buffer + pData->length );
708  *end = '\0';
709  pData->length = l;
710  return *this;
711  }
712  template<typename T1, typename T2> void operator +=(
713  OUStringConcat<T1, T2> &&) && = delete;
714 
719  template< typename T >
720  OUString& operator+=( OUStringNumber< T >&& n ) & {
721  sal_Int32 l = n.length;
722  if( l == 0 )
723  return *this;
724  l += pData->length;
725  rtl_uString_ensureCapacity( &pData, l );
726  sal_Unicode* end = addDataHelper( pData->buffer + pData->length, n.buf, n.length );
727  *end = '\0';
728  pData->length = l;
729  return *this;
730  }
731  template<typename T> void operator +=(
732  OUStringNumber<T> &&) && = delete;
733 #endif
734 
739  void clear()
740  {
741  rtl_uString_new( &pData );
742  }
743 
752  sal_Int32 getLength() const { return pData->length; }
753 
762  bool isEmpty() const
763  {
764  return pData->length == 0;
765  }
766 
774  const sal_Unicode * getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
775 
785  sal_Unicode operator [](sal_Int32 index) const {
786  // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
787  assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
788  return getStr()[index];
789  }
790 
803  sal_Int32 compareTo( const OUString & str ) const
804  {
805  return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
806  str.pData->buffer, str.pData->length );
807  }
808 
824  sal_Int32 compareTo( const OUString & str, sal_Int32 maxLength ) const
825  {
826  return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
827  str.pData->buffer, str.pData->length, maxLength );
828  }
829 
842 #if defined LIBO_INTERNAL_ONLY
843  sal_Int32 reverseCompareTo(std::u16string_view sv) const {
845  pData->buffer, pData->length, sv.data(), sv.size());
846  }
847 #else
848  sal_Int32 reverseCompareTo( const OUString & str ) const
849  {
850  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
851  str.pData->buffer, str.pData->length );
852  }
853 #endif
854 
860  template< typename T >
862  {
863  assert(
866  pData->buffer, pData->length,
869  }
870 
882  bool equals( const OUString & str ) const
883  {
884  if ( pData->length != str.pData->length )
885  return false;
886  if ( pData == str.pData )
887  return true;
888  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
889  str.pData->buffer, str.pData->length ) == 0;
890  }
891 
906 #if defined LIBO_INTERNAL_ONLY
907  bool equalsIgnoreAsciiCase(std::u16string_view sv) const {
908  return
910  pData->buffer, pData->length, sv.data(), sv.size())
911  == 0;
912  }
913 #else
914  bool equalsIgnoreAsciiCase( const OUString & str ) const
915  {
916  if ( pData->length != str.pData->length )
917  return false;
918  if ( pData == str.pData )
919  return true;
920  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
921  str.pData->buffer, str.pData->length ) == 0;
922  }
923 #endif
924 
940 #if defined LIBO_INTERNAL_ONLY
941  sal_Int32 compareToIgnoreAsciiCase(std::u16string_view sv) const {
943  pData->buffer, pData->length, sv.data(), sv.size());
944  }
945 #else
946  sal_Int32 compareToIgnoreAsciiCase( const OUString & str ) const
947  {
948  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
949  str.pData->buffer, str.pData->length );
950  }
951 #endif
952 
958  template< typename T >
960  {
961  assert(
963  return
964  (pData->length
967  pData->buffer, pData->length,
969  literal))
970  == 0);
971  }
972 
988 #if defined LIBO_INTERNAL_ONLY
989  bool match(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
990  return
992  pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
993  sv.size())
994  == 0;
995  }
996 #else
997  bool match( const OUString & str, sal_Int32 fromIndex = 0 ) const
998  {
999  return rtl_ustr_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1000  str.pData->buffer, str.pData->length, str.pData->length ) == 0;
1001  }
1002 #endif
1003 
1009  template< typename T >
1010  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
1011  {
1012  assert(
1014  return
1016  pData->buffer+fromIndex, pData->length-fromIndex,
1018  literal),
1020  == 0;
1021  }
1022 
1041 #if defined LIBO_INTERNAL_ONLY
1042  bool matchIgnoreAsciiCase(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
1043  return
1045  pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size(),
1046  sv.size())
1047  == 0;
1048  }
1049 #else
1050  bool matchIgnoreAsciiCase( const OUString & str, sal_Int32 fromIndex = 0 ) const
1051  {
1052  return rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1053  str.pData->buffer, str.pData->length,
1054  str.pData->length ) == 0;
1055  }
1056 #endif
1057 
1063  template< typename T >
1064  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
1065  {
1066  assert(
1068  return
1070  pData->buffer+fromIndex, pData->length-fromIndex,
1072  literal),
1074  == 0;
1075  }
1076 
1093  sal_Int32 compareToAscii( const char* asciiStr ) const
1094  {
1095  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length, asciiStr );
1096  }
1097 
1121  "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
1122  sal_Int32 compareToAscii( const char * asciiStr, sal_Int32 maxLength ) const
1123  {
1124  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer, pData->length,
1125  asciiStr, maxLength );
1126  }
1127 
1147  sal_Int32 reverseCompareToAsciiL( const char * asciiStr, sal_Int32 asciiStrLength ) const
1148  {
1149  return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
1150  asciiStr, asciiStrLength );
1151  }
1152 
1168  bool equalsAscii( const char* asciiStr ) const
1169  {
1170  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length,
1171  asciiStr ) == 0;
1172  }
1173 
1191  bool equalsAsciiL( const char* asciiStr, sal_Int32 asciiStrLength ) const
1192  {
1193  if ( pData->length != asciiStrLength )
1194  return false;
1195 
1197  pData->buffer, asciiStr, asciiStrLength );
1198  }
1199 
1218  bool equalsIgnoreAsciiCaseAscii( const char * asciiStr ) const
1219  {
1220  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1221  }
1222 
1241  sal_Int32 compareToIgnoreAsciiCaseAscii( const char * asciiStr ) const
1242  {
1243  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr );
1244  }
1245 
1266  bool equalsIgnoreAsciiCaseAsciiL( const char * asciiStr, sal_Int32 asciiStrLength ) const
1267  {
1268  if ( pData->length != asciiStrLength )
1269  return false;
1270 
1271  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1272  }
1273 
1295  bool matchAsciiL( const char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1296  {
1297  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1298  asciiStr, asciiStrLength ) == 0;
1299  }
1300 
1301  // This overload is left undefined, to detect calls of matchAsciiL that
1302  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1303  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1304  // platforms):
1305 #if SAL_TYPES_SIZEOFLONG == 8
1306  void matchAsciiL(char const *, sal_Int32, rtl_TextEncoding) const;
1307 #endif
1308 
1333  bool matchIgnoreAsciiCaseAsciiL( const char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1334  {
1335  return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1336  asciiStr, asciiStrLength ) == 0;
1337  }
1338 
1339  // This overload is left undefined, to detect calls of
1340  // matchIgnoreAsciiCaseAsciiL that erroneously use
1341  // RTL_CONSTASCII_USTRINGPARAM instead of RTL_CONSTASCII_STRINGPARAM (but
1342  // would lead to ambiguities on 32 bit platforms):
1343 #if SAL_TYPES_SIZEOFLONG == 8
1344  void matchIgnoreAsciiCaseAsciiL(char const *, sal_Int32, rtl_TextEncoding)
1345  const;
1346 #endif
1347 
1362 #if defined LIBO_INTERNAL_ONLY
1363  bool startsWith(std::u16string_view sv, OUString * rest = nullptr) const {
1364  auto const b = match(sv);
1365  if (b && rest != nullptr) {
1366  *rest = copy(sv.size());
1367  }
1368  return b;
1369  }
1370 #else
1371  bool startsWith(OUString const & str, OUString * rest = NULL) const {
1372  bool b = match(str);
1373  if (b && rest != NULL) {
1374  *rest = copy(str.getLength());
1375  }
1376  return b;
1377  }
1378 #endif
1379 
1385  template< typename T >
1387  T & literal, OUString * rest = NULL) const
1388  {
1389  assert(
1391  bool b
1393  <= sal_uInt32(pData->length))
1395  pData->buffer,
1397  literal),
1399  if (b && rest != NULL) {
1400  *rest = copy(
1402  }
1403  return b;
1404  }
1405 
1426 #if defined LIBO_INTERNAL_ONLY
1427  bool startsWithIgnoreAsciiCase(std::u16string_view sv, OUString * rest = nullptr) const {
1428  auto const b = matchIgnoreAsciiCase(sv);
1429  if (b && rest != nullptr) {
1430  *rest = copy(sv.size());
1431  }
1432  return b;
1433  }
1434 #else
1435  bool startsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL)
1436  const
1437  {
1438  bool b = matchIgnoreAsciiCase(str);
1439  if (b && rest != NULL) {
1440  *rest = copy(str.getLength());
1441  }
1442  return b;
1443  }
1444 #endif
1445 
1451  template< typename T >
1453  startsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1454  {
1455  assert(
1457  bool b
1459  pData->buffer,
1462  literal),
1464  == 0);
1465  if (b && rest != NULL) {
1466  *rest = copy(
1468  }
1469  return b;
1470  }
1471 
1486 #if defined LIBO_INTERNAL_ONLY
1487  bool endsWith(std::u16string_view sv, OUString * rest = nullptr) const {
1488  auto const b = sv.size() <= sal_uInt32(pData->length)
1489  && match(sv, pData->length - sv.size());
1490  if (b && rest != nullptr) {
1491  *rest = copy(0, (pData->length - sv.size()));
1492  }
1493  return b;
1494  }
1495 #else
1496  bool endsWith(OUString const & str, OUString * rest = NULL) const {
1497  bool b = str.getLength() <= getLength()
1498  && match(str, getLength() - str.getLength());
1499  if (b && rest != NULL) {
1500  *rest = copy(0, getLength() - str.getLength());
1501  }
1502  return b;
1503  }
1504 #endif
1505 
1511  template< typename T >
1513  endsWith(T & literal, OUString * rest = NULL) const
1514  {
1515  assert(
1517  bool b
1519  <= sal_uInt32(pData->length))
1521  (pData->buffer + pData->length
1524  literal),
1526  if (b && rest != NULL) {
1527  *rest = copy(
1528  0,
1529  (getLength()
1531  }
1532  return b;
1533  }
1534 
1546  bool endsWithAsciiL(char const * asciiStr, sal_Int32 asciiStrLength)
1547  const
1548  {
1549  return asciiStrLength <= pData->length
1551  pData->buffer + pData->length - asciiStrLength, asciiStr,
1552  asciiStrLength);
1553  }
1554 
1575 #if defined LIBO_INTERNAL_ONLY
1576  bool endsWithIgnoreAsciiCase(std::u16string_view sv, OUString * rest = nullptr) const {
1577  auto const b = sv.size() <= sal_uInt32(pData->length)
1578  && matchIgnoreAsciiCase(sv, pData->length - sv.size());
1579  if (b && rest != nullptr) {
1580  *rest = copy(0, pData->length - sv.size());
1581  }
1582  return b;
1583  }
1584 #else
1585  bool endsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL) const
1586  {
1587  bool b = str.getLength() <= getLength()
1588  && matchIgnoreAsciiCase(str, getLength() - str.getLength());
1589  if (b && rest != NULL) {
1590  *rest = copy(0, getLength() - str.getLength());
1591  }
1592  return b;
1593  }
1594 #endif
1595 
1601  template< typename T >
1603  endsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1604  {
1605  assert(
1607  bool b
1609  <= sal_uInt32(pData->length))
1611  (pData->buffer + pData->length
1615  literal),
1617  == 0);
1618  if (b && rest != NULL) {
1619  *rest = copy(
1620  0,
1621  (getLength()
1623  }
1624  return b;
1625  }
1626 
1638  char const * asciiStr, sal_Int32 asciiStrLength) const
1639  {
1640  return asciiStrLength <= pData->length
1642  pData->buffer + pData->length - asciiStrLength,
1643  asciiStrLength, asciiStr, asciiStrLength)
1644  == 0);
1645  }
1646 
1647  friend bool operator == ( const OUString& rStr1, const OUString& rStr2 )
1648  { return rStr1.equals(rStr2); }
1649 
1650  friend bool operator != ( const OUString& rStr1, const OUString& rStr2 )
1651  { return !(operator == ( rStr1, rStr2 )); }
1652 
1653  friend bool operator < ( const OUString& rStr1, const OUString& rStr2 )
1654  { return rStr1.compareTo( rStr2 ) < 0; }
1655  friend bool operator > ( const OUString& rStr1, const OUString& rStr2 )
1656  { return rStr1.compareTo( rStr2 ) > 0; }
1657  friend bool operator <= ( const OUString& rStr1, const OUString& rStr2 )
1658  { return rStr1.compareTo( rStr2 ) <= 0; }
1659  friend bool operator >= ( const OUString& rStr1, const OUString& rStr2 )
1660  { return rStr1.compareTo( rStr2 ) >= 0; }
1661 
1662 #if defined LIBO_INTERNAL_ONLY
1663 
1664  template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1665  operator ==(OUString const & s1, T const & s2) {
1667  == 0;
1668  }
1669 
1670  template<typename T>
1671  friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1672  operator ==(OUString const & s1, T & s2) {
1673  return rtl_ustr_compare_WithLength(s1.getStr(), s1.getLength(), s2, rtl_ustr_getLength(s2))
1674  == 0;
1675  }
1676 
1677  template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1678  operator ==(T const & s1, OUString const & s2) {
1679  return rtl_ustr_compare_WithLength(s1, rtl_ustr_getLength(s1), s2.getStr(), s2.getLength())
1680  == 0;
1681  }
1682 
1683  template<typename T>
1684  friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1685  operator ==(T & s1, OUString const & s2) {
1686  return rtl_ustr_compare_WithLength(s1, rtl_ustr_getLength(s1), s2.getStr(), s2.getLength())
1687  == 0;
1688  }
1689 
1690  template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1691  operator !=(OUString const & s1, T const & s2) { return !(s1 == s2); }
1692 
1693  template<typename T>
1694  friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1695  operator !=(OUString const & s1, T & s2) { return !(s1 == s2); }
1696 
1697  template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
1698  operator !=(T const & s1, OUString const & s2) { return !(s1 == s2); }
1699 
1700  template<typename T>
1701  friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
1702  operator !=(T & s1, OUString const & s2) { return !(s1 == s2); }
1703 
1704 #else
1705 
1706  friend bool operator == ( const OUString& rStr1, const sal_Unicode * pStr2 )
1707  { return rStr1.compareTo( pStr2 ) == 0; }
1708  friend bool operator == ( const sal_Unicode * pStr1, const OUString& rStr2 )
1709  { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
1710 
1711  friend bool operator != ( const OUString& rStr1, const sal_Unicode * pStr2 )
1712  { return !(operator == ( rStr1, pStr2 )); }
1713  friend bool operator != ( const sal_Unicode * pStr1, const OUString& rStr2 )
1714  { return !(operator == ( pStr1, rStr2 )); }
1715 
1716 #endif
1717 
1725  template< typename T >
1727  {
1728  assert(
1730  return rString.equalsAsciiL(
1733  }
1741  template< typename T >
1743  {
1744  assert(
1746  return rString.equalsAsciiL(
1749  }
1757  template< typename T >
1759  {
1760  assert(
1762  return !rString.equalsAsciiL(
1765  }
1773  template< typename T >
1775  {
1776  assert(
1778  return !rString.equalsAsciiL(
1781  }
1782 
1783 #if defined LIBO_INTERNAL_ONLY
1785  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1786  operator ==(OUString const & string, T & literal) {
1787  return
1789  string.pData->buffer, string.pData->length,
1791  literal),
1793  == 0;
1794  }
1796  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1797  operator ==(T & literal, OUString const & string) {
1798  return
1800  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1801  literal),
1802  libreoffice_internal::ConstCharArrayDetector<T>::length,
1803  string.pData->buffer, string.pData->length)
1804  == 0;
1805  }
1807  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1808  operator !=(OUString const & string, T & literal) {
1809  return
1811  string.pData->buffer, string.pData->length,
1812  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1813  literal),
1814  libreoffice_internal::ConstCharArrayDetector<T>::length)
1815  != 0;
1816  }
1818  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1819  operator !=(T & literal, OUString const & string) {
1820  return
1822  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1823  literal),
1824  libreoffice_internal::ConstCharArrayDetector<T>::length,
1825  string.pData->buffer, string.pData->length)
1826  != 0;
1827  }
1828 #endif
1829 
1830 #if defined LIBO_INTERNAL_ONLY
1832 
1833  /* Comparison between OUString and OUStringLiteral.
1834 
1835  @since LibreOffice 5.0
1836  */
1837 
1838  template<std::size_t N>
1839  friend bool operator ==(OUString const & lhs, OUStringLiteral<N> const & rhs) {
1840  return
1842  lhs.pData->buffer, lhs.pData->length, rhs.getStr(), rhs.getLength())
1843  == 0;
1844  }
1845 
1846  template<std::size_t N>
1847  friend bool operator !=(OUString const & lhs, OUStringLiteral<N> const & rhs) {
1848  return
1850  lhs.pData->buffer, lhs.pData->length, rhs.getStr(), rhs.getLength())
1851  != 0;
1852  }
1853 
1854  template<std::size_t N>
1855  friend bool operator <(OUString const & lhs, OUStringLiteral<N> const & rhs) {
1856  return
1858  lhs.pData->buffer, lhs.pData->length, rhs.getStr(), rhs.getLength()))
1859  < 0;
1860  }
1861 
1862  template<std::size_t N>
1863  friend bool operator <=(OUString const & lhs, OUStringLiteral<N> const & rhs) {
1864  return
1866  lhs.pData->buffer, lhs.pData->length, rhs.getStr(), rhs.getLength()))
1867  <= 0;
1868  }
1869 
1870  template<std::size_t N>
1871  friend bool operator >(OUString const & lhs, OUStringLiteral<N> const & rhs) {
1872  return
1874  lhs.pData->buffer, lhs.pData->length, rhs.getStr(), rhs.getLength()))
1875  > 0;
1876  }
1877 
1878  template<std::size_t N>
1879  friend bool operator >=(OUString const & lhs, OUStringLiteral<N> const & rhs) {
1880  return
1882  lhs.pData->buffer, lhs.pData->length, rhs.getStr(), rhs.getLength()))
1883  >= 0;
1884  }
1885 
1886  template<std::size_t N>
1887  friend bool operator ==(OUStringLiteral<N> const & lhs, OUString const & rhs) {
1888  return
1890  lhs.getStr(), lhs.getLength(), rhs.pData->buffer, rhs.pData->length)
1891  == 0;
1892  }
1893 
1894  template<std::size_t N>
1895  friend bool operator !=(OUStringLiteral<N> const & lhs, OUString const & rhs) {
1896  return
1898  lhs.getStr(), lhs.getLength(), rhs.pData->buffer, rhs.pData->length)
1899  != 0;
1900  }
1901 
1902  template<std::size_t N>
1903  friend bool operator <(OUStringLiteral<N> const & lhs, OUString const & rhs) {
1904  return
1906  lhs.getStr(), lhs.getLength(), rhs.pData->buffer, rhs.pData->length))
1907  < 0;
1908  }
1909 
1910  template<std::size_t N>
1911  friend bool operator <=(OUStringLiteral<N> const & lhs, OUString const & rhs) {
1912  return
1914  lhs.getStr(), lhs.getLength(), rhs.pData->buffer, rhs.pData->length))
1915  <= 0;
1916  }
1917 
1918  template<std::size_t N>
1919  friend bool operator >(OUStringLiteral<N> const & lhs, OUString const & rhs) {
1920  return
1922  lhs.getStr(), lhs.getLength(), rhs.pData->buffer, rhs.pData->length))
1923  > 0;
1924  }
1925 
1926  template<std::size_t N>
1927  friend bool operator >=(OUStringLiteral<N> const & lhs, OUString const & rhs) {
1928  return
1930  lhs.getStr(), lhs.getLength(), rhs.pData->buffer, rhs.pData->length))
1931  >= 0;
1932  }
1933 
1935 #endif
1936 
1937 #if defined LIBO_INTERNAL_ONLY
1938  friend bool operator ==(OUString const & lhs, std::u16string_view rhs) {
1939  return
1941  lhs.pData->buffer, lhs.pData->length, rhs.data(), rhs.size())
1942  == 0;
1943  }
1944 
1945  friend bool operator !=(OUString const & lhs, std::u16string_view rhs) {
1946  return
1948  lhs.pData->buffer, lhs.pData->length, rhs.data(), rhs.size())
1949  != 0;
1950  }
1951 
1952  friend bool operator <(OUString const & lhs, std::u16string_view rhs) {
1953  return
1955  lhs.pData->buffer, lhs.pData->length, rhs.data(), rhs.size()))
1956  < 0;
1957  }
1958 
1959  friend bool operator <=(OUString const & lhs, std::u16string_view rhs) {
1960  return
1962  lhs.pData->buffer, lhs.pData->length, rhs.data(), rhs.size()))
1963  <= 0;
1964  }
1965 
1966  friend bool operator >(OUString const & lhs, std::u16string_view rhs) {
1967  return
1969  lhs.pData->buffer, lhs.pData->length, rhs.data(), rhs.size()))
1970  > 0;
1971  }
1972 
1973  friend bool operator >=(OUString const & lhs, std::u16string_view rhs) {
1974  return
1976  lhs.pData->buffer, lhs.pData->length, rhs.data(), rhs.size()))
1977  >= 0;
1978  }
1979 
1980  friend bool operator ==(std::u16string_view lhs, OUString const & rhs) {
1981  return
1983  lhs.data(), lhs.size(), rhs.pData->buffer, rhs.pData->length)
1984  == 0;
1985  }
1986 
1987  friend bool operator !=(std::u16string_view lhs, OUString const & rhs) {
1988  return
1990  lhs.data(), lhs.size(), rhs.pData->buffer, rhs.pData->length)
1991  != 0;
1992  }
1993 
1994  friend bool operator <(std::u16string_view lhs, OUString const & rhs) {
1995  return
1997  lhs.data(), lhs.size(), rhs.pData->buffer, rhs.pData->length))
1998  < 0;
1999  }
2000 
2001  friend bool operator <=(std::u16string_view lhs, OUString const & rhs) {
2002  return
2004  lhs.data(), lhs.size(), rhs.pData->buffer, rhs.pData->length))
2005  <= 0;
2006  }
2007 
2008  friend bool operator >(std::u16string_view lhs, OUString const & rhs) {
2009  return
2011  lhs.data(), lhs.size(), rhs.pData->buffer, rhs.pData->length))
2012  > 0;
2013  }
2014 
2015  friend bool operator >=(std::u16string_view lhs, OUString const & rhs) {
2016  return
2018  lhs.data(), lhs.size(), rhs.pData->buffer, rhs.pData->length))
2019  >= 0;
2020  }
2021 #endif
2022 
2030  sal_Int32 hashCode() const
2031  {
2032  return rtl_ustr_hashCode_WithLength( pData->buffer, pData->length );
2033  }
2034 
2048  sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
2049  {
2050  sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
2051  return (ret < 0 ? ret : ret+fromIndex);
2052  }
2053 
2063  sal_Int32 lastIndexOf( sal_Unicode ch ) const
2064  {
2065  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
2066  }
2067 
2080  sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
2081  {
2082  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
2083  }
2084 
2100 #if defined LIBO_INTERNAL_ONLY
2101  sal_Int32 indexOf(std::u16string_view sv, sal_Int32 fromIndex = 0) const {
2102  auto const n = rtl_ustr_indexOfStr_WithLength(
2103  pData->buffer + fromIndex, pData->length - fromIndex, sv.data(), sv.size());
2104  return n < 0 ? n : n + fromIndex;
2105  }
2106 #else
2107  sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
2108  {
2109  sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
2110  str.pData->buffer, str.pData->length );
2111  return (ret < 0 ? ret : ret+fromIndex);
2112  }
2113 #endif
2114 
2120  template< typename T >
2121  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
2122  {
2123  assert(
2125  sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
2126  pData->buffer + fromIndex, pData->length - fromIndex,
2129  return n < 0 ? n : n + fromIndex;
2130  }
2131 
2155  sal_Int32 indexOfAsciiL(
2156  char const * str, sal_Int32 len, sal_Int32 fromIndex = 0) const
2157  {
2158  sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
2159  pData->buffer + fromIndex, pData->length - fromIndex, str, len);
2160  return ret < 0 ? ret : ret + fromIndex;
2161  }
2162 
2163  // This overload is left undefined, to detect calls of indexOfAsciiL that
2164  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
2165  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
2166  // platforms):
2167 #if SAL_TYPES_SIZEOFLONG == 8
2168  void indexOfAsciiL(char const *, sal_Int32 len, rtl_TextEncoding) const;
2169 #endif
2170 
2186 #if defined LIBO_INTERNAL_ONLY
2187  sal_Int32 lastIndexOf(std::u16string_view sv) const {
2189  pData->buffer, pData->length, sv.data(), sv.size());
2190  }
2191 #else
2192  sal_Int32 lastIndexOf( const OUString & str ) const
2193  {
2194  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
2195  str.pData->buffer, str.pData->length );
2196  }
2197 #endif
2198 
2216 #if defined LIBO_INTERNAL_ONLY
2217  sal_Int32 lastIndexOf(std::u16string_view sv, sal_Int32 fromIndex) const {
2218  return rtl_ustr_lastIndexOfStr_WithLength(pData->buffer, fromIndex, sv.data(), sv.size());
2219  }
2220 #else
2221  sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
2222  {
2223  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
2224  str.pData->buffer, str.pData->length );
2225  }
2226 #endif
2227 
2233  template< typename T >
2235  {
2236  assert(
2239  pData->buffer, pData->length,
2242  }
2243 
2263  sal_Int32 lastIndexOfAsciiL(char const * str, sal_Int32 len) const
2264  {
2266  pData->buffer, pData->length, str, len);
2267  }
2268 
2279  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex ) const
2280  {
2281  return copy(beginIndex, getLength() - beginIndex);
2282  }
2283 
2296  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const
2297  {
2298  rtl_uString *pNew = NULL;
2299  rtl_uString_newFromSubString( &pNew, pData, beginIndex, count );
2300  return OUString( pNew, SAL_NO_ACQUIRE );
2301  }
2302 
2303 #if defined LIBO_INTERNAL_ONLY
2314  SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex ) const
2315  {
2316  assert(beginIndex >= 0);
2317  assert(beginIndex <= getLength());
2318  return subView(beginIndex, getLength() - beginIndex);
2319  }
2320 
2333  SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex, sal_Int32 count ) const
2334  {
2335  assert(beginIndex >= 0);
2336  assert(count >= 0);
2337  assert(beginIndex <= getLength());
2338  assert(count <= getLength() - beginIndex);
2339  return std::u16string_view(*this).substr(beginIndex, count);
2340  }
2341 #endif
2342 
2343 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2352  SAL_WARN_UNUSED_RESULT OUString concat( const OUString & str ) const
2353  {
2354  rtl_uString* pNew = NULL;
2355  rtl_uString_newConcat( &pNew, pData, str.pData );
2356  return OUString( pNew, SAL_NO_ACQUIRE );
2357  }
2358 #endif
2359 
2360 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2361  friend OUString operator+( const OUString& rStr1, const OUString& rStr2 )
2362  {
2363  return rStr1.concat( rStr2 );
2364  }
2365 #endif
2366 
2380  SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const
2381  {
2382  rtl_uString* pNew = NULL;
2383  rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
2384  return OUString( pNew, SAL_NO_ACQUIRE );
2385  }
2386 
2401  {
2402  rtl_uString* pNew = NULL;
2403  rtl_uString_newReplace( &pNew, pData, oldChar, newChar );
2404  return OUString( pNew, SAL_NO_ACQUIRE );
2405  }
2406 
2425 #if defined LIBO_INTERNAL_ONLY
2426  [[nodiscard]] OUString replaceFirst(
2427  std::u16string_view from, std::u16string_view to, sal_Int32 * index = nullptr) const
2428  {
2429  rtl_uString * s = nullptr;
2430  sal_Int32 i = 0;
2432  &s, pData, from.data(), from.size(), to.data(), to.size(),
2433  index == nullptr ? &i : index);
2434  return OUString(s, SAL_NO_ACQUIRE);
2435  }
2436 #else
2438  OUString const & from, OUString const & to, sal_Int32 * index = NULL) const
2439  {
2440  rtl_uString * s = NULL;
2441  sal_Int32 i = 0;
2443  &s, pData, from.pData, to.pData, index == NULL ? &i : index);
2444  return OUString(s, SAL_NO_ACQUIRE);
2445  }
2446 #endif
2447 
2466 #if defined LIBO_INTERNAL_ONLY
2467  template<typename T> [[nodiscard]]
2469  T & from, std::u16string_view to, sal_Int32 * index = nullptr) const
2470  {
2472  rtl_uString * s = nullptr;
2473  sal_Int32 i = 0;
2477  index == nullptr ? &i : index);
2478  return OUString(s, SAL_NO_ACQUIRE);
2479  }
2480 #else
2481  template< typename T >
2483  sal_Int32 * index = NULL) const
2484  {
2486  rtl_uString * s = NULL;
2487  sal_Int32 i = 0;
2489  &s, pData,
2492  index == NULL ? &i : index);
2493  return OUString(s, SAL_NO_ACQUIRE);
2494  }
2495 #endif
2496 
2515 #if defined LIBO_INTERNAL_ONLY
2516  template<typename T> [[nodiscard]]
2518  std::u16string_view from, T & to, sal_Int32 * index = nullptr) const
2519  {
2521  rtl_uString * s = nullptr;
2522  sal_Int32 i = 0;
2524  &s, pData, from.data(), from.size(),
2526  libreoffice_internal::ConstCharArrayDetector<T>::length, index == nullptr ? &i : index);
2527  return OUString(s, SAL_NO_ACQUIRE);
2528  }
2529 #else
2530  template< typename T >
2532  sal_Int32 * index = NULL) const
2533  {
2535  rtl_uString * s = NULL;
2536  sal_Int32 i = 0;
2538  &s, pData, from.pData,
2541  index == NULL ? &i : index);
2542  return OUString(s, SAL_NO_ACQUIRE);
2543  }
2544 #endif
2545 
2564  template< typename T1, typename T2 >
2566  replaceFirst( T1& from, T2& to, sal_Int32 * index = NULL) const
2567  {
2570  rtl_uString * s = NULL;
2571  sal_Int32 i = 0;
2573  &s, pData,
2578  index == NULL ? &i : index);
2579  return OUString(s, SAL_NO_ACQUIRE);
2580  }
2581 
2597 #if defined LIBO_INTERNAL_ONLY
2598  [[nodiscard]] OUString replaceAll(
2599  std::u16string_view from, std::u16string_view to, sal_Int32 fromIndex = 0) const
2600  {
2601  rtl_uString * s = nullptr;
2602  rtl_uString_newReplaceAllFromIndexUtf16LUtf16L(
2603  &s, pData, from.data(), from.size(), to.data(), to.size(), fromIndex);
2604  return OUString(s, SAL_NO_ACQUIRE);
2605  }
2606 #else
2608  OUString const & from, OUString const & to, sal_Int32 fromIndex = 0) const
2609  {
2610  rtl_uString * s = NULL;
2611  rtl_uString_newReplaceAllFromIndex(&s, pData, from.pData, to.pData, fromIndex);
2612  return OUString(s, SAL_NO_ACQUIRE);
2613  }
2614 #endif
2615 
2629 #if defined LIBO_INTERNAL_ONLY
2630  template<typename T> [[nodiscard]]
2632  T & from, std::u16string_view to) const
2633  {
2635  rtl_uString * s = nullptr;
2639  return OUString(s, SAL_NO_ACQUIRE);
2640  }
2641 #else
2642  template< typename T >
2644  {
2646  rtl_uString * s = NULL;
2648  &s, pData,
2651  return OUString(s, SAL_NO_ACQUIRE);
2652  }
2653 #endif
2654 
2668 #if defined LIBO_INTERNAL_ONLY
2669  template<typename T> [[nodiscard]]
2671  std::u16string_view from, T & to) const
2672  {
2674  rtl_uString * s = nullptr;
2676  &s, pData, from.data(), from.size(),
2679  return OUString(s, SAL_NO_ACQUIRE);
2680  }
2681 #else
2682  template< typename T >
2684  {
2686  rtl_uString * s = NULL;
2688  &s, pData, from.pData,
2691  return OUString(s, SAL_NO_ACQUIRE);
2692  }
2693 #endif
2694 
2708  template< typename T1, typename T2 >
2710  replaceAll( T1& from, T2& to ) const
2711  {
2714  rtl_uString * s = NULL;
2716  &s, pData,
2721  return OUString(s, SAL_NO_ACQUIRE);
2722  }
2723 
2735  {
2736  rtl_uString* pNew = NULL;
2737  rtl_uString_newToAsciiLowerCase( &pNew, pData );
2738  return OUString( pNew, SAL_NO_ACQUIRE );
2739  }
2740 
2752  {
2753  rtl_uString* pNew = NULL;
2754  rtl_uString_newToAsciiUpperCase( &pNew, pData );
2755  return OUString( pNew, SAL_NO_ACQUIRE );
2756  }
2757 
2772  {
2773  rtl_uString* pNew = NULL;
2774  rtl_uString_newTrim( &pNew, pData );
2775  return OUString( pNew, SAL_NO_ACQUIRE );
2776  }
2777 
2802  OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const
2803  {
2804  rtl_uString * pNew = NULL;
2805  index = rtl_uString_getToken( &pNew, pData, token, cTok, index );
2806  return OUString( pNew, SAL_NO_ACQUIRE );
2807  }
2808 
2822  OUString getToken(sal_Int32 count, sal_Unicode separator) const {
2823  sal_Int32 n = 0;
2824  return getToken(count, separator, n);
2825  }
2826 
2835  bool toBoolean() const
2836  {
2837  return rtl_ustr_toBoolean( pData->buffer );
2838  }
2839 
2847  {
2848  return pData->buffer[0];
2849  }
2850 
2861  sal_Int32 toInt32( sal_Int16 radix = 10 ) const
2862  {
2863  return rtl_ustr_toInt32( pData->buffer, radix );
2864  }
2865 
2878  sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
2879  {
2880  return rtl_ustr_toUInt32( pData->buffer, radix );
2881  }
2882 
2893  sal_Int64 toInt64( sal_Int16 radix = 10 ) const
2894  {
2895  return rtl_ustr_toInt64( pData->buffer, radix );
2896  }
2897 
2910  sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
2911  {
2912  return rtl_ustr_toUInt64( pData->buffer, radix );
2913  }
2914 
2923  float toFloat() const
2924  {
2925  return rtl_ustr_toFloat( pData->buffer );
2926  }
2927 
2936  double toDouble() const
2937  {
2938  return rtl_ustr_toDouble( pData->buffer );
2939  }
2940 
2941 
2958  {
2959  rtl_uString * pNew = NULL;
2960  rtl_uString_intern( &pNew, pData );
2961  if (pNew == NULL) {
2962  throw std::bad_alloc();
2963  }
2964  return OUString( pNew, SAL_NO_ACQUIRE );
2965  }
2966 
2992  static OUString intern( const char * value, sal_Int32 length,
2993  rtl_TextEncoding encoding,
2994  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS,
2995  sal_uInt32 *pInfo = NULL )
2996  {
2997  rtl_uString * pNew = NULL;
2998  rtl_uString_internConvert( &pNew, value, length, encoding,
2999  convertFlags, pInfo );
3000  if (pNew == NULL) {
3001  throw std::bad_alloc();
3002  }
3003  return OUString( pNew, SAL_NO_ACQUIRE );
3004  }
3005 
3030  bool convertToString(OString * pTarget, rtl_TextEncoding nEncoding,
3031  sal_uInt32 nFlags) const
3032  {
3033  return rtl_convertUStringToString(&pTarget->pData, pData->buffer,
3034  pData->length, nEncoding, nFlags);
3035  }
3036 
3088  sal_uInt32 iterateCodePoints(
3089  sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1) const
3090  {
3092  pData, indexUtf16, incrementCodePoints);
3093  }
3094 
3104  static OUString fromUtf8(const OString& rSource)
3105  {
3106  OUString aTarget;
3107  bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
3108  rSource.getStr(),
3109  rSource.getLength(),
3112  (void) bSuccess;
3113  assert(bSuccess);
3114  return aTarget;
3115  }
3116 
3127  OString toUtf8() const
3128  {
3129  OString aTarget;
3130  bool bSuccess = rtl_convertUStringToString(&aTarget.pData,
3131  getStr(),
3132  getLength(),
3135  (void) bSuccess;
3136  assert(bSuccess);
3137  return aTarget;
3138  }
3139 
3140 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3141 
3142  static OUStringNumber< int > number( int i, sal_Int16 radix = 10 )
3143  {
3144  return OUStringNumber< int >( i, radix );
3145  }
3146  static OUStringNumber< long long > number( long long ll, sal_Int16 radix = 10 )
3147  {
3148  return OUStringNumber< long long >( ll, radix );
3149  }
3150  static OUStringNumber< unsigned long long > number( unsigned long long ll, sal_Int16 radix = 10 )
3151  {
3152  return OUStringNumber< unsigned long long >( ll, radix );
3153  }
3154  static OUStringNumber< unsigned long long > number( unsigned int i, sal_Int16 radix = 10 )
3155  {
3156  return number( static_cast< unsigned long long >( i ), radix );
3157  }
3158  static OUStringNumber< long long > number( long i, sal_Int16 radix = 10)
3159  {
3160  return number( static_cast< long long >( i ), radix );
3161  }
3162  static OUStringNumber< unsigned long long > number( unsigned long i, sal_Int16 radix = 10 )
3163  {
3164  return number( static_cast< unsigned long long >( i ), radix );
3165  }
3166  static OUStringNumber< float > number( float f )
3167  {
3168  return OUStringNumber< float >( f );
3169  }
3170  static OUStringNumber< double > number( double d )
3171  {
3172  return OUStringNumber< double >( d );
3173  }
3174 #else
3185  static OUString number( int i, sal_Int16 radix = 10 )
3186  {
3188  return OUString(aBuf, rtl_ustr_valueOfInt32(aBuf, i, radix));
3189  }
3192  static OUString number( unsigned int i, sal_Int16 radix = 10 )
3193  {
3194  return number( static_cast< unsigned long long >( i ), radix );
3195  }
3198  static OUString number( long i, sal_Int16 radix = 10)
3199  {
3200  return number( static_cast< long long >( i ), radix );
3201  }
3204  static OUString number( unsigned long i, sal_Int16 radix = 10 )
3205  {
3206  return number( static_cast< unsigned long long >( i ), radix );
3207  }
3210  static OUString number( long long ll, sal_Int16 radix = 10 )
3211  {
3213  return OUString(aBuf, rtl_ustr_valueOfInt64(aBuf, ll, radix));
3214  }
3217  static OUString number( unsigned long long ll, sal_Int16 radix = 10 )
3218  {
3220  return OUString(aBuf, rtl_ustr_valueOfUInt64(aBuf, ll, radix));
3221  }
3222 
3232  static OUString number( float f )
3233  {
3235  return OUString(aBuf, rtl_ustr_valueOfFloat(aBuf, f));
3236  }
3237 
3247  static OUString number( double d )
3248  {
3250  return OUString(aBuf, rtl_ustr_valueOfDouble(aBuf, d));
3251  }
3252 #endif
3253 
3265  SAL_DEPRECATED("use boolean()") static OUString valueOf( sal_Bool b )
3266  {
3267  return boolean(b);
3268  }
3269 
3281  static OUString boolean( bool b )
3282  {
3284  return OUString(aBuf, rtl_ustr_valueOfBoolean(aBuf, b));
3285  }
3286 
3294  SAL_DEPRECATED("convert to OUString or use directly") static OUString valueOf( sal_Unicode c )
3295  {
3296  return OUString( &c, 1 );
3297  }
3298 
3309  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
3310  {
3311  return number( i, radix );
3312  }
3313 
3324  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
3325  {
3326  return number( ll, radix );
3327  }
3328 
3338  SAL_DEPRECATED("use number()") static OUString valueOf( float f )
3339  {
3340  return number(f);
3341  }
3342 
3352  SAL_DEPRECATED("use number()") static OUString valueOf( double d )
3353  {
3354  return number(d);
3355  }
3356 
3372  static OUString createFromAscii( const char * value )
3373  {
3374  rtl_uString* pNew = NULL;
3375  rtl_uString_newFromAscii( &pNew, value );
3376  return OUString( pNew, SAL_NO_ACQUIRE );
3377  }
3378 
3379 #if defined LIBO_INTERNAL_ONLY
3380  static OUString createFromAscii(std::string_view value) {
3381  rtl_uString * p = nullptr;
3382  rtl_uString_newFromLiteral(&p, value.data(), value.size(), 0); //TODO: check for overflow
3383  return OUString(p, SAL_NO_ACQUIRE);
3384  }
3385  #endif
3386 
3387 #if defined LIBO_INTERNAL_ONLY
3388  operator std::u16string_view() const { return {getStr(), sal_uInt32(getLength())}; }
3389 #endif
3390 
3391 #if defined LIBO_INTERNAL_ONLY
3392  // A wrapper for the first expression in an
3393  //
3394  // OUString::Concat(e1) + e2 + ...
3395  //
3396  // concatenation chain, when neither of the first two e1, e2 is one of our rtl string-related
3397  // classes (so something like
3398  //
3399  // OUString s = "a" + (b ? std::u16string_view(u"c") : std::u16string_view(u"dd"));
3400  //
3401  // would not compile):
3402  template<typename T> [[nodiscard]] static
3403  typename std::enable_if_t<
3404  ToStringHelper<T>::allowOUStringConcat, OUStringConcat<OUStringConcatMarker, T>>
3405  Concat(T const & value) { return OUStringConcat<OUStringConcatMarker, T>({}, value); }
3406 
3407  // This overload is needed so that an argument of type 'char const[N]' ends up as
3408  // 'OUStringConcat<rtl::OUStringConcatMarker, char const[N]>' rather than as
3409  // 'OUStringConcat<rtl::OUStringConcatMarker, char[N]>':
3410  template<typename T, std::size_t N> [[nodiscard]] static
3411  typename std::enable_if_t<
3412  ToStringHelper<T[N]>::allowOUStringConcat, OUStringConcat<OUStringConcatMarker, T[N]>>
3413  Concat(T (& value)[N]) { return OUStringConcat<OUStringConcatMarker, T[N]>({}, value); }
3414 #endif
3415 
3416 private:
3417  OUString & internalAppend( rtl_uString* pOtherData )
3418  {
3419  rtl_uString* pNewData = NULL;
3420  rtl_uString_newConcat( &pNewData, pData, pOtherData );
3421  if (pNewData == NULL) {
3422  throw std::bad_alloc();
3423  }
3424  rtl_uString_assign(&pData, pNewData);
3425  rtl_uString_release(pNewData);
3426  return *this;
3427  }
3428 
3429 };
3430 
3431 #if defined LIBO_INTERNAL_ONLY
3432 // Prevent the operator ==/!= overloads with 'sal_Unicode const *' parameter from
3433 // being selected for nonsensical code like
3434 //
3435 // if (ouIdAttr == nullptr)
3436 //
3437 void operator ==(OUString const &, std::nullptr_t) = delete;
3438 void operator ==(std::nullptr_t, OUString const &) = delete;
3439 void operator !=(OUString const &, std::nullptr_t) = delete;
3440 void operator !=(std::nullptr_t, OUString const &) = delete;
3441 #endif
3442 
3443 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3445 
3449 template<>
3450 struct ToStringHelper< OUString >
3451  {
3452  static std::size_t length( const OUString& s ) { return s.getLength(); }
3453  static sal_Unicode* addData( sal_Unicode* buffer, const OUString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
3454  static const bool allowOStringConcat = false;
3455  static const bool allowOUStringConcat = true;
3456  };
3457 
3461 template<std::size_t N>
3462 struct ToStringHelper< OUStringLiteral<N> >
3463  {
3464  static std::size_t length( const OUStringLiteral<N>& str ) { return str.getLength(); }
3465  static sal_Unicode* addData( sal_Unicode* buffer, const OUStringLiteral<N>& str ) { return addDataHelper( buffer, str.getStr(), str.getLength() ); }
3466  static const bool allowOStringConcat = false;
3467  static const bool allowOUStringConcat = true;
3468  };
3469 
3473 template< typename charT, typename traits, typename T1, typename T2 >
3474 inline std::basic_ostream<charT, traits> & operator <<(
3475  std::basic_ostream<charT, traits> & stream, OUStringConcat< T1, T2 >&& concat)
3476 {
3477  return stream << OUString( std::move(concat) );
3478 }
3479 
3481 #endif
3482 
3489 {
3499  size_t operator()(const OUString& rString) const
3500  { return static_cast<size_t>(rString.hashCode()); }
3501 };
3502 
3503 /* ======================================================================= */
3504 
3522 inline OUString OStringToOUString( const OString & rStr,
3523  rtl_TextEncoding encoding,
3524  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
3525 {
3526  return OUString( rStr.getStr(), rStr.getLength(), encoding, convertFlags );
3527 }
3528 
3546 inline OString OUStringToOString( const OUString & rUnicode,
3547  rtl_TextEncoding encoding,
3548  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
3549 {
3550  return OString( rUnicode.getStr(), rUnicode.getLength(), encoding, convertFlags );
3551 }
3552 
3553 /* ======================================================================= */
3554 
3563 template< typename charT, typename traits >
3564 inline std::basic_ostream<charT, traits> & operator <<(
3565  std::basic_ostream<charT, traits> & stream, OUString const & rString)
3566 {
3567  return stream <<
3569  // best effort; potentially loses data due to conversion failures
3570  // (stray surrogate halves) and embedded null characters
3571 }
3572 
3573 } // namespace
3574 
3575 #ifdef RTL_STRING_UNITTEST
3576 namespace rtl
3577 {
3578 typedef rtlunittest::OUString OUString;
3579 }
3580 #endif
3581 
3582 // In internal code, allow to use classes like OUString without having to
3583 // explicitly refer to the rtl namespace, which is kind of superfluous given
3584 // that OUString itself is namespaced by its OU prefix:
3585 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3586 using ::rtl::OUString;
3587 using ::rtl::OUStringHash;
3590 using ::rtl::OUStringLiteral;
3591 using ::rtl::OUStringChar;
3592 #endif
3593 
3595 
3600 #if defined LIBO_INTERNAL_ONLY
3601 namespace std {
3602 
3603 template<>
3604 struct hash<::rtl::OUString>
3605 {
3606  std::size_t operator()(::rtl::OUString const & s) const
3607  { return std::size_t(s.hashCode()); }
3608 };
3609 
3610 }
3611 
3612 #endif
3614 
3615 #endif /* _RTL_USTRING_HXX */
3616 
3617 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don't use, it's evil.") void doit(int nPara);.
Definition: types.h:445
__sal_NoAcquire
Definition: types.h:349
@ SAL_NO_ACQUIRE
definition of a no acquire enum for ctors
Definition: types.h:352
unsigned char sal_Bool
Definition: types.h:34
sal_uInt16 sal_Unicode
Definition: types.h:119
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:280
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:558
SAL_DLLPUBLIC sal_Bool rtl_convertUStringToString(rtl_String **pTarget, sal_Unicode const *pSource, sal_Int32 nLength, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) SAL_THROW_EXTERN_C()
Converts a Unicode string to a byte string, signalling failure.
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1350
#define RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR
Definition: textcvt.h:147
#define RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR
Definition: textcvt.h:71
#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
Definition: textcvt.h:68
#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:64
#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:141
#define RTL_TEXTENCODING_UTF8
Definition: textenc.h:113
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:33
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(sal_Unicode const *first, sal_Int32 firstLen, char const *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
SAL_DLLPUBLIC void rtl_uString_assign(rtl_uString **str, rtl_uString *rightValue) SAL_THROW_EXTERN_C()
Assign a new value to a string.
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstUtf16LUtf16L(rtl_uString **newStr, rtl_uString *str, sal_Unicode const *from, sal_Int32 fromLength, sal_Unicode const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring.
SAL_DLLPUBLIC float rtl_ustr_toFloat(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a float.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_shortenedCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters.
SAL_DLLPUBLIC void rtl_uString_new(rtl_uString **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
#define OSTRING_TO_OUSTRING_CVTFLAGS
Definition: ustring.h:2180
#define RTL_USTR_MAX_VALUEOFFLOAT
Definition: ustring.h:1022
SAL_DLLPUBLIC sal_Int32 rtl_ustr_compare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings.
SAL_DLLPUBLIC void rtl_uString_newConcatUtf16L(rtl_uString **newString, rtl_uString *left, sal_Unicode const *right, sal_Int32 rightLength)
Create a new string that is the concatenation of two other strings.
SAL_DLLPUBLIC void rtl_uString_newReplaceAllAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, rtl_uString const *to) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring.
SAL_DLLPUBLIC void rtl_uString_newReplaceAllFromIndex(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, rtl_uString const *to, sal_Int32 fromIndex) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters, ignoring the case of ASCII characters.
SAL_DLLPUBLIC sal_Int32 rtl_uString_getToken(rtl_uString **newStr, rtl_uString *str, sal_Int32 token, sal_Unicode cTok, sal_Int32 idx) SAL_THROW_EXTERN_C()
Create a new string by extracting a single token from another string.
#define RTL_USTR_MAX_VALUEOFDOUBLE
Definition: ustring.h:1041
SAL_DLLPUBLIC void rtl_uString_newFromStr_WithLength(rtl_uString **newStr, const sal_Unicode *value, sal_Int32 len) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
SAL_DLLPUBLIC sal_Bool rtl_ustr_asciil_reverseEquals_WithLength(const sal_Unicode *first, const char *second, sal_Int32 len) SAL_THROW_EXTERN_C()
Compare two strings from back to front for equality.
SAL_DLLPUBLIC void rtl_uString_newFromLiteral(rtl_uString **newStr, const char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
SAL_DLLPUBLIC void rtl_uString_newReplaceAllAsciiLUtf16L(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, sal_Unicode const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfBoolean(sal_Unicode *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
SAL_DLLPUBLIC double rtl_ustr_toDouble(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a double.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfFloat(sal_Unicode *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstUtf16LAsciiL(rtl_uString **newStr, rtl_uString *str, sal_Unicode const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring.
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstToAsciiL(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, char const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfDouble(sal_Unicode *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
SAL_DLLPUBLIC void rtl_uString_newConcat(rtl_uString **newStr, rtl_uString *left, rtl_uString *right) SAL_THROW_EXTERN_C()
Create a new string that is the concatenation of two other strings.
#define RTL_USTR_MAX_VALUEOFINT64
Definition: ustring.h:980
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
SAL_DLLPUBLIC rtl_uString * rtl_uString_alloc(sal_Int32 nLen) SAL_THROW_EXTERN_C()
Allocate a new string containing space for a given number of characters.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfStr_WithLength(const sal_Unicode *str, sal_Int32 len, const sal_Unicode *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of a substring within a string.
SAL_DLLPUBLIC void rtl_uString_internConvert(rtl_uString **newStr, const char *str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags, sal_uInt32 *pInfo) SAL_THROW_EXTERN_C()
Return a canonical representation for a string.
SAL_DLLPUBLIC void rtl_uString_acquire(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Increment the reference count of a string.
SAL_DLLPUBLIC sal_Int64 rtl_ustr_toInt64(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as a long integer.
SAL_DLLPUBLIC void rtl_uString_newReplaceStrAt(rtl_uString **newStr, rtl_uString *str, sal_Int32 idx, sal_Int32 count, rtl_uString *subStr) SAL_THROW_EXTERN_C()
Create a new string by replacing a substring of another string.
#define RTL_USTR_MAX_VALUEOFUINT64
Definition: ustring.h:1003
SAL_DLLPUBLIC sal_Bool rtl_convertStringToUString(rtl_uString **target, char const *source, sal_Int32 length, rtl_TextEncoding encoding, sal_uInt32 flags) SAL_THROW_EXTERN_C()
Converts a byte string to a Unicode string, signalling failure.
SAL_DLLPUBLIC void rtl_uString_newReplaceAllToAsciiL(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, char const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring.
SAL_DLLPUBLIC sal_uInt32 rtl_uString_iterateCodePoints(rtl_uString const *string, sal_Int32 *indexUtf16, sal_Int32 incrementCodePoints)
Iterate through a string based on code points instead of UTF-16 code units.
SAL_DLLPUBLIC void rtl_uString_newToAsciiLowerCase(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Create a new string by converting all ASCII uppercase letters to lowercase within another string.
SAL_DLLPUBLIC void rtl_uString_ensureCapacity(rtl_uString **str, sal_Int32 size) SAL_THROW_EXTERN_C()
Ensure a string has enough space for a given number of characters.
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Decrement the reference count of a string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_getLength(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Return the length of a string.
SAL_DLLPUBLIC void rtl_uString_newFromAscii(rtl_uString **newStr, const char *value) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfInt64(sal_Unicode *str, sal_Int64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of a long integer.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfAscii_WithLength(sal_Unicode const *str, sal_Int32 len, char const *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of an ASCII substring within a string.
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, rtl_uString const *to, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfAscii_WithLength(sal_Unicode const *str, sal_Int32 len, char const *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of an ASCII substring within a string.
SAL_DLLPUBLIC sal_uInt64 rtl_ustr_toUInt64(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned long integer.
SAL_DLLPUBLIC void rtl_uString_newReplaceAllUtf16LAsciiL(rtl_uString **newStr, rtl_uString *str, sal_Unicode const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters, ignoring the case of ASCII characters.
SAL_DLLPUBLIC void rtl_uString_newTrim(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Create a new string by removing white space from both ends of another string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfChar_WithLength(const sal_Unicode *str, sal_Int32 len, sal_Unicode ch) SAL_THROW_EXTERN_C()
Search for the last occurrence of a character within a string.
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstAsciiLAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring.
SAL_DLLPUBLIC sal_uInt32 rtl_ustr_toUInt32(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned integer.
SAL_DLLPUBLIC void rtl_uString_intern(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Return a canonical representation for a string.
SAL_DLLPUBLIC void rtl_string2UString(rtl_uString **newStr, const char *str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags) SAL_THROW_EXTERN_C()
Create a new Unicode string by converting a byte string, using a specific text encoding.
SAL_DLLPUBLIC void rtl_uString_newFromStr(rtl_uString **newStr, const sal_Unicode *value) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_asciil_reverseCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings from back to front.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_compare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const char *second) SAL_THROW_EXTERN_C()
Compare two strings.
#define RTL_USTR_MAX_VALUEOFBOOLEAN
Definition: ustring.h:915
SAL_DLLPUBLIC sal_Int32 rtl_ustr_toInt32(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an integer.
SAL_DLLPUBLIC void rtl_uString_newReplaceAllAsciiLAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfUInt64(sal_Unicode *str, sal_uInt64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an unsigned long integer.
SAL_DLLPUBLIC void rtl_uString_newFromCodePoints(rtl_uString **newString, sal_uInt32 const *codePoints, sal_Int32 codePointCount) SAL_THROW_EXTERN_C()
Allocate a new string from an array of Unicode code points.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_compareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_reverseCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings from back to front.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_shortenedCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfInt32(sal_Unicode *str, sal_Int32 i, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an integer.
SAL_DLLPUBLIC sal_Bool rtl_ustr_toBoolean(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
SAL_DLLPUBLIC void rtl_uString_newReplace(rtl_uString **newStr, rtl_uString *str, sal_Unicode oldChar, sal_Unicode newChar) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a single character within another string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_hashCode_WithLength(const sal_Unicode *str, sal_Int32 len) SAL_THROW_EXTERN_C()
Return a hash code for a string.
SAL_DLLPUBLIC void rtl_uString_newReplaceFirst(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, rtl_uString const *to, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring.
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstAsciiLUtf16L(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, sal_Unicode const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring.
SAL_DLLPUBLIC void rtl_uString_newToAsciiUpperCase(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Create a new string by converting all ASCII lowercase letters to uppercase within another string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfStr_WithLength(const sal_Unicode *str, sal_Int32 len, const sal_Unicode *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of a substring within a string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfChar_WithLength(const sal_Unicode *str, sal_Int32 len, sal_Unicode ch) SAL_THROW_EXTERN_C()
Search for the first occurrence of a character within a string.
SAL_DLLPUBLIC void rtl_uString_newFromSubString(rtl_uString **newStr, const rtl_uString *from, sal_Int32 beginIndex, sal_Int32 count) SAL_THROW_EXTERN_C()
Allocate a new string that is a substring of this string.
SAL_DLLPUBLIC void rtl_uString_newConcatAsciiL(rtl_uString **newString, rtl_uString *left, char const *right, sal_Int32 rightLength)
Create a new string that is the concatenation of two other strings.
#define RTL_USTR_MAX_VALUEOFINT32
Definition: ustring.h:957
sal_Int32 oslInterlockedCount
Definition: interlck.h:40
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:90
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:100
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:110
Definition: bootstrap.hxx:30
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:3522
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:3546
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &stream, OString const &rString)
Support for rtl::OString in std::ostream (and thus in CPPUNIT_ASSERT or SAL_INFO macros,...
Definition: string.hxx:2095
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:664
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:171
const char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:551
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:525
Definition: stringutils.hxx:131
Definition: stringutils.hxx:134
This String class provides base functionality for C++ like Unicode character array handling.
Definition: ustring.hxx:161
static OUString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: ustring.hxx:3185
OUString intern() const
Return a canonical representation for a string.
Definition: ustring.hxx:2957
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:2121
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:2566
bool endsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string ends with a given substring.
Definition: ustring.hxx:1496
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:1637
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:2734
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:2643
bool equalsIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:914
bool endsWithAsciiL(char const *asciiStr, sal_Int32 asciiStrLength) const
Check whether this string ends with a given ASCII string.
Definition: ustring.hxx:1546
OUString(const OUString &str)
New string from OUString.
Definition: ustring.hxx:181
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:3088
static OUString fromUtf8(const OString &rSource)
Convert an OString to an OUString, assuming that the OString is UTF-8-encoded.
Definition: ustring.hxx:3104
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1010
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: ustring.hxx:2861
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: ustring.hxx:739
bool equalsIgnoreAsciiCaseAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1266
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:3217
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:2155
~OUString()
Release the string data.
Definition: ustring.hxx:483
sal_Int32 compareTo(const OUString &str, sal_Int32 maxLength) const
Compares two strings with a maximum count of characters.
Definition: ustring.hxx:824
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:2263
sal_Int32 indexOf(sal_Unicode ch, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified character,...
Definition: ustring.hxx:2048
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:2683
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:3210
bool matchAsciiL(const char *asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:1295
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:2607
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:543
float toFloat() const
Returns the float value from this string.
Definition: ustring.hxx:2923
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:3204
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:2710
static OUString createFromAscii(const char *value)
Returns an OUString copied without conversion from an ASCII character string.
Definition: ustring.hxx:3372
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:2482
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:2400
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: ustring.hxx:2030
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type reverseCompareTo(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:861
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1742
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1726
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:3198
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:959
const sal_Unicode * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:774
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: ustring.hxx:2910
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:1333
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition: ustring.hxx:623
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWithIgnoreAsciiCase(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1453
OString toUtf8() const
Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully.
Definition: ustring.hxx:3127
sal_Int32 reverseCompareToAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Compares two strings in reverse order.
Definition: ustring.hxx:1147
bool equalsAsciiL(const char *asciiStr, sal_Int32 asciiStrLength) const
Perform a comparison of two strings.
Definition: ustring.hxx:1191
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:3192
bool convertToString(OString *pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) const
Converts to an OString, signalling failure.
Definition: ustring.hxx:3030
OUString & operator=(const OUString &str)
Assign a new string.
Definition: ustring.hxx:507
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWith(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1386
OUString(rtl_uString *str)
New string from OUString data.
Definition: ustring.hxx:207
OUString(const sal_Unicode *value, sal_Int32 length)
New string from a Unicode character buffer array.
Definition: ustring.hxx:286
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:1585
sal_Int32 compareTo(const OUString &str) const
Compares two strings.
Definition: ustring.hxx:803
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1758
bool startsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: ustring.hxx:1371
sal_Int32 lastIndexOf(sal_Unicode ch) const
Returns the index within this string of the last occurrence of the specified character,...
Definition: ustring.hxx:2063
sal_Int32 compareToIgnoreAsciiCaseAscii(const char *asciiStr) const
Compares two ASCII strings ignoring case.
Definition: ustring.hxx:1241
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:2531
OUString(sal_Unicode value)
New string from a single Unicode character.
Definition: ustring.hxx:229
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:2437
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: ustring.hxx:2893
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: ustring.hxx:2878
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:1435
sal_Int32 lastIndexOf(const OUString &str, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified substring,...
Definition: ustring.hxx:2221
double toDouble() const
Returns the double value from this string.
Definition: ustring.hxx:2936
bool equalsAscii(const char *asciiStr) const
Perform a comparison of two strings.
Definition: ustring.hxx:1168
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1064
OUString getToken(sal_Int32 token, sal_Unicode cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: ustring.hxx:2802
sal_Int32 getLength() const
Returns the length of this string.
Definition: ustring.hxx:752
bool equalsIgnoreAsciiCaseAscii(const char *asciiStr) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1218
OUString()
New string containing no characters.
Definition: ustring.hxx:170
static OUString const & unacquired(rtl_uString *const *ppHandle)
Provides an OUString const & passing a storage pointer of an rtl_uString * handle.
Definition: ustring.hxx:499
OUString(const sal_Unicode *value)
New string from a Unicode character buffer array.
Definition: ustring.hxx:270
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:404
static OUString number(float f)
Returns the string representation of the float argument.
Definition: ustring.hxx:3232
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:762
sal_Int32 compareToIgnoreAsciiCase(const OUString &str) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:946
OUString(sal_uInt32 const *codePoints, sal_Int32 codePointCount)
Create a new string from an array of Unicode code points.
Definition: ustring.hxx:431
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type endsWith(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1513
sal_Unicode toChar() const
Returns the first character from this string.
Definition: ustring.hxx:2846
OUString getToken(sal_Int32 count, sal_Unicode separator) const
Returns a token from the string.
Definition: ustring.hxx:2822
static OUString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: ustring.hxx:3281
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type lastIndexOf(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:2234
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:2296
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type endsWithIgnoreAsciiCase(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1603
OUString(rtl_uString *str, __sal_NoAcquire)
New OUString from OUString data without acquiring it.
Definition: ustring.hxx:221
sal_Int32 lastIndexOf(sal_Unicode ch, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified character,...
Definition: ustring.hxx:2080
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:2771
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:2751
SAL_WARN_UNUSED_RESULT OUString concat(const OUString &str) const
Concatenates the specified string to the end of this string.
Definition: ustring.hxx:2352
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:2380
bool match(const OUString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:997
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:1050
sal_Int32 compareToAscii(const char *asciiStr) const
Compares two strings.
Definition: ustring.hxx:1093
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:308
sal_Int32 reverseCompareTo(const OUString &str) const
Compares two strings in reverse order.
Definition: ustring.hxx:848
static OUString number(double d)
Returns the string representation of the double argument.
Definition: ustring.hxx:3247
friend OUString operator+(const OUString &rStr1, const OUString &rStr2)
Definition: ustring.hxx:2361
SAL_WARN_UNUSED_RESULT OUString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: ustring.hxx:2279
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1774
bool equals(const OUString &str) const
Perform a comparison of two strings.
Definition: ustring.hxx:882
sal_Int32 lastIndexOf(const OUString &str) const
Returns the index within this string of the last occurrence of the specified substring,...
Definition: ustring.hxx:2192
bool toBoolean() const
Returns the Boolean value from this string.
Definition: ustring.hxx:2835
sal_Int32 indexOf(const OUString &str, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified substring,...
Definition: ustring.hxx:2107
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:2992
A helper to use OUStrings with hash maps.
Definition: ustring.hxx:3489
size_t operator()(const OUString &rString) const
Compute a hash code for a string.
Definition: ustring.hxx:3499