LibreOffice
LibreOffice 6.3 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 <limits>
28 #include <new>
29 #include <ostream>
30 #include <utility>
31 
32 #if defined LIBO_INTERNAL_ONLY
33 #include <string_view>
34 #endif
35 
36 #include "rtl/ustring.h"
37 #include "rtl/string.hxx"
38 #include "rtl/stringutils.hxx"
39 #include "rtl/textenc.h"
40 
41 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
42 #include "rtl/stringconcat.hxx"
43 #endif
44 
45 #ifdef RTL_STRING_UNITTEST
46 extern bool rtl_string_unittest_invalid_conversion;
47 #endif
48 
49 // The unittest uses slightly different code to help check that the proper
50 // calls are made. The class is put into a different namespace to make
51 // sure the compiler generates a different (if generating also non-inline)
52 // copy of the function and does not merge them together. The class
53 // is "brought" into the proper rtl namespace by a typedef below.
54 #ifdef RTL_STRING_UNITTEST
55 #define rtl rtlunittest
56 #endif
57 
58 namespace rtl
59 {
60 
61 class OUStringBuffer;
62 
63 #ifdef RTL_STRING_UNITTEST
64 #undef rtl
65 #endif
66 
67 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
68 
76 struct SAL_WARN_UNUSED OUStringLiteral
77 {
78  template<typename T> constexpr OUStringLiteral(
79  T & literal,
80  typename libreoffice_internal::ConstCharArrayDetector<
81  T, libreoffice_internal::Dummy>::Type
82  = libreoffice_internal::Dummy()):
83  size(libreoffice_internal::ConstCharArrayDetector<T>::length),
84  data(
85  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal))
86  {
87  assert(
88  libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
89  }
90 
91  int size;
92  const char* data;
93 
94  // So we can use this struct in some places interchangeably with OUString
95  constexpr sal_Int32 getLength() const { return size; }
96 };
97 
99 #endif
100 
101 /* ======================================================================= */
102 
126 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OUString
127 {
128 public:
130  rtl_uString * pData;
132 
137  {
138  pData = NULL;
139  rtl_uString_new( &pData );
140  }
141 
147  OUString( const OUString & str )
148  {
149  pData = str.pData;
150  rtl_uString_acquire( pData );
151  }
152 
153 #ifndef _MSC_VER // TODO?
154 #if defined LIBO_INTERNAL_ONLY
155 
161  OUString( OUString && str )
162  {
163  pData = str.pData;
164  str.pData = nullptr;
165  rtl_uString_new( &str.pData );
166  }
167 #endif
168 #endif
169 
175  OUString( rtl_uString * str )
176  {
177  pData = str;
178  rtl_uString_acquire( pData );
179  }
180 
189  OUString( rtl_uString * str, __sal_NoAcquire )
190  { pData = str; }
191 
197  explicit OUString( sal_Unicode value )
198  : pData (NULL)
199  {
200  rtl_uString_newFromStr_WithLength( &pData, &value, 1 );
201  }
202 
203 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
204  // Catch inadvertent conversions to the above ctor (but still allow
206  // construction from char literals):
207  OUString(int) = delete;
208  explicit OUString(char c):
209  OUString(sal_Unicode(static_cast<unsigned char>(c)))
210  {}
212 #endif
213 
219  OUString( const sal_Unicode * value )
220  {
221  pData = NULL;
222  rtl_uString_newFromStr( &pData, value );
223  }
224 
233  OUString( const sal_Unicode * value, sal_Int32 length )
234  {
235  pData = NULL;
236  rtl_uString_newFromStr_WithLength( &pData, value, length );
237  }
238 
254  template< typename T >
256  {
257  assert(
259  pData = NULL;
261  rtl_uString_new(&pData);
262  } else {
264  &pData,
266  literal),
268  }
269 #ifdef RTL_STRING_UNITTEST
270  rtl_string_unittest_const_literal = true;
271 #endif
272  }
273 
274 #if defined LIBO_INTERNAL_ONLY
275 
276  template<typename T> OUString(
277  T & literal,
279  T, libreoffice_internal::Dummy>::TypeUtf16
281  pData(nullptr)
282  {
284  rtl_uString_new(&pData);
285  } else {
287  &pData,
288  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
289  literal),
290  libreoffice_internal::ConstCharArrayDetector<T>::length);
291  }
292  }
293 #endif
294 
295 #ifdef RTL_STRING_UNITTEST
296 
300  template< typename T >
301  OUString( T&, typename libreoffice_internal::ExceptConstCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
302  {
303  pData = NULL;
304  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
305  rtl_string_unittest_invalid_conversion = true;
306  }
311  template< typename T >
312  OUString( const T&, typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
313  {
314  pData = NULL;
315  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
316  rtl_string_unittest_invalid_conversion = true;
317  }
318 #endif
319 
320 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
321 
337  OUString(OUStringLiteral literal): pData(NULL) {
338  rtl_uString_newFromLiteral(&pData, literal.data, literal.size, 0);
339  }
341 #endif
342 
357  OUString( const sal_Char * value, sal_Int32 length,
358  rtl_TextEncoding encoding,
359  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
360  {
361  pData = NULL;
362  rtl_string2UString( &pData, value, length, encoding, convertFlags );
363  if (pData == NULL) {
364  throw std::bad_alloc();
365  }
366  }
367 
384  explicit OUString(
385  sal_uInt32 const * codePoints, sal_Int32 codePointCount):
386  pData(NULL)
387  {
388  rtl_uString_newFromCodePoints(&pData, codePoints, codePointCount);
389  if (pData == NULL) {
390  throw std::bad_alloc();
391  }
392  }
393 
394 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
395 
399  template< typename T1, typename T2 >
400  OUString( OUStringConcat< T1, T2 >&& c )
401  {
402  const sal_Int32 l = c.length();
403  pData = rtl_uString_alloc( l );
404  if (l != 0)
405  {
406  sal_Unicode* end = c.addData( pData->buffer );
407  pData->length = l;
408  *end = '\0';
409  // TODO realloc in case pData->length is noticeably smaller than l?
410  }
411  }
412 #endif
413 
414 #if defined LIBO_INTERNAL_ONLY
415  OUString(std::u16string_view sv) {
416  if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
417  throw std::bad_alloc();
418  }
419  pData = nullptr;
420  rtl_uString_newFromStr_WithLength(&pData, sv.data(), sv.size());
421  }
422 #endif
423 
428  {
429  rtl_uString_release( pData );
430  }
431 
443  static OUString const & unacquired( rtl_uString * const * ppHandle )
444  { return * reinterpret_cast< OUString const * >( ppHandle ); }
445 
451  OUString & operator=( const OUString & str )
452  {
453  rtl_uString_assign( &pData, str.pData );
454  return *this;
455  }
456 
457 #ifndef _MSC_VER // TODO?
458 #if defined LIBO_INTERNAL_ONLY
459 
465  OUString & operator=( OUString && str )
466  {
467  rtl_uString_release( pData );
468  pData = str.pData;
469  str.pData = nullptr;
470  rtl_uString_new( &str.pData );
471  return *this;
472  }
473 #endif
474 #endif
475 
488  template< typename T >
490  {
491  assert(
494  rtl_uString_new(&pData);
495  } else {
497  &pData,
499  literal),
501  }
502  return *this;
503  }
504 
505 #if defined LIBO_INTERNAL_ONLY
506 
507  template<typename T>
508  typename
510  operator =(T & literal) {
512  rtl_uString_new(&pData);
513  } else {
515  &pData,
516  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
517  literal),
518  libreoffice_internal::ConstCharArrayDetector<T>::length);
519  }
520  return *this;
521  }
522 
524  OUString & operator =(OUStringLiteral const & literal) {
525  if (literal.size == 0) {
526  rtl_uString_new(&pData);
527  } else {
528  rtl_uString_newFromLiteral(&pData, literal.data, literal.size, 0);
529  }
530  return *this;
531  }
532 #endif
533 
534 #if defined LIBO_INTERNAL_ONLY
535 
543  inline OUString & operator+=( const OUStringBuffer & str ) &;
544 #endif
545 
553  OUString & operator+=( const OUString & str )
554 #if defined LIBO_INTERNAL_ONLY
555  &
556 #endif
557  {
558  return internalAppend(str.pData);
559  }
560 #if defined LIBO_INTERNAL_ONLY
561  void operator+=(OUString const &) && = delete;
562 #endif
563 
570  template<typename T>
572  operator +=(T & literal)
573 #if defined LIBO_INTERNAL_ONLY
574  &
575 #endif
576  {
577  assert(
580  &pData, pData,
583  return *this;
584  }
585 #if defined LIBO_INTERNAL_ONLY
586  template<typename T>
588  operator +=(T &) && = delete;
589 #endif
590 
591 #if defined LIBO_INTERNAL_ONLY
592 
593  template<typename T>
594  typename
596  operator +=(T & literal) & {
598  &pData, pData,
601  return *this;
602  }
603  template<typename T>
604  typename
605  libreoffice_internal::ConstCharArrayDetector<T, OUString &>::TypeUtf16
606  operator +=(T &) && = delete;
607 
609  OUString & operator +=(OUStringLiteral const & literal) & {
610  rtl_uString_newConcatAsciiL(&pData, pData, literal.data, literal.size);
611  return *this;
612  }
613  void operator +=(OUStringLiteral const &) && = delete;
614 #endif
615 
616 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
617 
621  template< typename T1, typename T2 >
622  OUString& operator+=( OUStringConcat< T1, T2 >&& c ) & {
623  sal_Int32 l = c.length();
624  if( l == 0 )
625  return *this;
626  l += pData->length;
627  rtl_uString_ensureCapacity( &pData, l );
628  sal_Unicode* end = c.addData( pData->buffer + pData->length );
629  *end = '\0';
630  pData->length = l;
631  return *this;
632  }
633  template<typename T1, typename T2> void operator +=(
634  OUStringConcat<T1, T2> &&) && = delete;
635 #endif
636 
641  void clear()
642  {
643  rtl_uString_new( &pData );
644  }
645 
654  sal_Int32 getLength() const { return pData->length; }
655 
664  bool isEmpty() const
665  {
666  return pData->length == 0;
667  }
668 
676  const sal_Unicode * getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
677 
687  sal_Unicode operator [](sal_Int32 index) const {
688  // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
689  assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
690  return getStr()[index];
691  }
692 
705  sal_Int32 compareTo( const OUString & str ) const
706  {
707  return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
708  str.pData->buffer, str.pData->length );
709  }
710 
726  sal_Int32 compareTo( const OUString & str, sal_Int32 maxLength ) const
727  {
728  return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
729  str.pData->buffer, str.pData->length, maxLength );
730  }
731 
744  sal_Int32 reverseCompareTo( const OUString & str ) const
745  {
746  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
747  str.pData->buffer, str.pData->length );
748  }
749 
755  template< typename T >
757  {
758  assert(
761  pData->buffer, pData->length,
764  }
765 
766 #if defined LIBO_INTERNAL_ONLY
767 
768  template<typename T>
769  typename
771  reverseCompareTo(T & literal) const {
773  pData->buffer, pData->length,
776  }
777 
779  sal_Int32 reverseCompareTo(OUStringLiteral const & literal) const {
781  pData->buffer, pData->length, literal.data, literal.size);
782  }
783 #endif
784 
796  bool equals( const OUString & str ) const
797  {
798  if ( pData->length != str.pData->length )
799  return false;
800  if ( pData == str.pData )
801  return true;
802  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
803  str.pData->buffer, str.pData->length ) == 0;
804  }
805 
820  bool equalsIgnoreAsciiCase( const OUString & str ) const
821  {
822  if ( pData->length != str.pData->length )
823  return false;
824  if ( pData == str.pData )
825  return true;
826  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
827  str.pData->buffer, str.pData->length ) == 0;
828  }
829 
845  sal_Int32 compareToIgnoreAsciiCase( const OUString & str ) const
846  {
847  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
848  str.pData->buffer, str.pData->length );
849  }
850 
851 
857  template< typename T >
859  {
860  assert(
862  return
863  (pData->length
866  pData->buffer, pData->length,
868  literal))
869  == 0);
870  }
871 
872 #if defined LIBO_INTERNAL_ONLY
873 
874  template<typename T>
876  equalsIgnoreAsciiCase(T & literal) const {
877  return
879  pData->buffer, pData->length,
881  literal),
883  == 0;
884  }
885 
887  bool equalsIgnoreAsciiCase(OUStringLiteral const & literal) const {
888  return pData->length == literal.size
890  pData->buffer, pData->length, literal.data)
891  == 0);
892  }
893 #endif
894 
910  bool match( const OUString & str, sal_Int32 fromIndex = 0 ) const
911  {
912  return rtl_ustr_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
913  str.pData->buffer, str.pData->length, str.pData->length ) == 0;
914  }
915 
921  template< typename T >
922  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
923  {
924  assert(
926  return
928  pData->buffer+fromIndex, pData->length-fromIndex,
930  literal),
932  == 0;
933  }
934 
935 #if defined LIBO_INTERNAL_ONLY
936 
937  template<typename T>
939  match(T & literal, sal_Int32 fromIndex = 0) const {
940  assert(fromIndex >= 0);
941  return
943  pData->buffer + fromIndex, pData->length - fromIndex,
945  literal),
948  == 0;
949  }
950 
952  bool match(OUStringLiteral const & literal, sal_Int32 fromIndex = 0) const {
953  return
955  pData->buffer + fromIndex, pData->length - fromIndex,
956  literal.data, literal.size)
957  == 0;
958  }
959 #endif
960 
979  bool matchIgnoreAsciiCase( const OUString & str, sal_Int32 fromIndex = 0 ) const
980  {
981  return rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
982  str.pData->buffer, str.pData->length,
983  str.pData->length ) == 0;
984  }
985 
991  template< typename T >
992  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
993  {
994  assert(
996  return
998  pData->buffer+fromIndex, pData->length-fromIndex,
1000  literal),
1002  == 0;
1003  }
1004 
1005 #if defined LIBO_INTERNAL_ONLY
1006 
1007  template<typename T>
1009  matchIgnoreAsciiCase(T & literal, sal_Int32 fromIndex = 0) const {
1010  assert(fromIndex >= 0);
1011  return
1013  pData->buffer + fromIndex, pData->length - fromIndex,
1015  literal),
1018  == 0;
1019  }
1020 
1022  bool matchIgnoreAsciiCase(
1023  OUStringLiteral const & literal, sal_Int32 fromIndex = 0) const
1024  {
1025  return
1027  pData->buffer+fromIndex, pData->length-fromIndex, literal.data,
1028  literal.size)
1029  == 0;
1030  }
1031 #endif
1032 
1049  sal_Int32 compareToAscii( const sal_Char* asciiStr ) const
1050  {
1051  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length, asciiStr );
1052  }
1053 
1077  "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
1078  sal_Int32 compareToAscii( const sal_Char * asciiStr, sal_Int32 maxLength ) const
1079  {
1080  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer, pData->length,
1081  asciiStr, maxLength );
1082  }
1083 
1103  sal_Int32 reverseCompareToAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
1104  {
1105  return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
1106  asciiStr, asciiStrLength );
1107  }
1108 
1124  bool equalsAscii( const sal_Char* asciiStr ) const
1125  {
1126  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length,
1127  asciiStr ) == 0;
1128  }
1129 
1147  bool equalsAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength ) const
1148  {
1149  if ( pData->length != asciiStrLength )
1150  return false;
1151 
1153  pData->buffer, asciiStr, asciiStrLength );
1154  }
1155 
1174  bool equalsIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const
1175  {
1176  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1177  }
1178 
1197  sal_Int32 compareToIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const
1198  {
1199  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr );
1200  }
1201 
1222  bool equalsIgnoreAsciiCaseAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
1223  {
1224  if ( pData->length != asciiStrLength )
1225  return false;
1226 
1227  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1228  }
1229 
1251  bool matchAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1252  {
1253  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1254  asciiStr, asciiStrLength ) == 0;
1255  }
1256 
1257  // This overload is left undefined, to detect calls of matchAsciiL that
1258  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1259  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1260  // platforms):
1261 #if SAL_TYPES_SIZEOFLONG == 8
1262  void matchAsciiL(char const *, sal_Int32, rtl_TextEncoding) const;
1263 #endif
1264 
1289  bool matchIgnoreAsciiCaseAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1290  {
1291  return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1292  asciiStr, asciiStrLength ) == 0;
1293  }
1294 
1295  // This overload is left undefined, to detect calls of
1296  // matchIgnoreAsciiCaseAsciiL that erroneously use
1297  // RTL_CONSTASCII_USTRINGPARAM instead of RTL_CONSTASCII_STRINGPARAM (but
1298  // would lead to ambiguities on 32 bit platforms):
1299 #if SAL_TYPES_SIZEOFLONG == 8
1300  void matchIgnoreAsciiCaseAsciiL(char const *, sal_Int32, rtl_TextEncoding)
1301  const;
1302 #endif
1303 
1318  bool startsWith(OUString const & str, OUString * rest = NULL) const {
1319  bool b = match(str);
1320  if (b && rest != NULL) {
1321  *rest = copy(str.getLength());
1322  }
1323  return b;
1324  }
1325 
1331  template< typename T >
1333  T & literal, OUString * rest = NULL) const
1334  {
1335  assert(
1337  bool b
1339  <= sal_uInt32(pData->length))
1341  pData->buffer,
1343  literal),
1345  if (b && rest != NULL) {
1346  *rest = copy(
1348  }
1349  return b;
1350  }
1351 
1352 #if defined LIBO_INTERNAL_ONLY
1353 
1354  template<typename T>
1356  startsWith(T & literal, OUString * rest = nullptr) const {
1357  bool b
1359  <= sal_uInt32(pData->length))
1361  pData->buffer,
1364  literal),
1366  == 0);
1367  if (b && rest != nullptr) {
1368  *rest = copy(
1370  }
1371  return b;
1372  }
1373 
1375  bool startsWith(OUStringLiteral const & literal, OUString * rest = nullptr)
1376  const
1377  {
1378  bool b = literal.size <= pData->length
1380  pData->buffer, literal.data, literal.size);
1381  if (b && rest != nullptr) {
1382  *rest = copy(literal.size);
1383  }
1384  return b;
1385  }
1386 #endif
1387 
1408  bool startsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL)
1409  const
1410  {
1411  bool b = matchIgnoreAsciiCase(str);
1412  if (b && rest != NULL) {
1413  *rest = copy(str.getLength());
1414  }
1415  return b;
1416  }
1417 
1423  template< typename T >
1425  startsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1426  {
1427  assert(
1429  bool b
1431  pData->buffer,
1434  literal),
1436  == 0);
1437  if (b && rest != NULL) {
1438  *rest = copy(
1440  }
1441  return b;
1442  }
1443 
1444 #if defined LIBO_INTERNAL_ONLY
1445 
1446  template<typename T>
1448  startsWithIgnoreAsciiCase(T & literal, OUString * rest = nullptr) const {
1449  bool b
1451  <= sal_uInt32(pData->length))
1453  pData->buffer,
1456  literal),
1458  == 0);
1459  if (b && rest != nullptr) {
1460  *rest = copy(
1462  }
1463  return b;
1464  }
1465 
1467  bool startsWithIgnoreAsciiCase(
1468  OUStringLiteral const & literal, OUString * rest = nullptr) const
1469  {
1470  bool b
1472  pData->buffer, literal.size, literal.data, literal.size)
1473  == 0);
1474  if (b && rest != nullptr) {
1475  *rest = copy(literal.size);
1476  }
1477  return b;
1478  }
1479 #endif
1480 
1495  bool endsWith(OUString const & str, OUString * rest = NULL) const {
1496  bool b = str.getLength() <= getLength()
1497  && match(str, getLength() - str.getLength());
1498  if (b && rest != NULL) {
1499  *rest = copy(0, getLength() - str.getLength());
1500  }
1501  return b;
1502  }
1503 
1509  template< typename T >
1511  endsWith(T & literal, OUString * rest = NULL) const
1512  {
1513  assert(
1515  bool b
1517  <= sal_uInt32(pData->length))
1519  (pData->buffer + pData->length
1522  literal),
1524  if (b && rest != NULL) {
1525  *rest = copy(
1526  0,
1527  (getLength()
1529  }
1530  return b;
1531  }
1532 
1533 #if defined LIBO_INTERNAL_ONLY
1534 
1535  template<typename T>
1537  endsWith(T & literal, OUString * rest = nullptr) const {
1538  bool b
1540  <= sal_uInt32(pData->length))
1542  (pData->buffer + pData->length
1546  literal),
1548  == 0);
1549  if (b && rest != nullptr) {
1550  *rest = copy(
1551  0,
1552  (getLength()
1554  }
1555  return b;
1556  }
1557 
1559  bool endsWith(OUStringLiteral const & literal, OUString * rest = nullptr)
1560  const
1561  {
1562  bool b = literal.size <= pData->length
1564  pData->buffer + pData->length - literal.size,
1565  literal.data, literal.size);
1566  if (b && rest != nullptr) {
1567  *rest = copy(0, (getLength() - literal.size));
1568  }
1569  return b;
1570  }
1571 #endif
1572 
1584  bool endsWithAsciiL(char const * asciiStr, sal_Int32 asciiStrLength)
1585  const
1586  {
1587  return asciiStrLength <= pData->length
1589  pData->buffer + pData->length - asciiStrLength, asciiStr,
1590  asciiStrLength);
1591  }
1592 
1613  bool endsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL) const
1614  {
1615  bool b = str.getLength() <= getLength()
1616  && matchIgnoreAsciiCase(str, getLength() - str.getLength());
1617  if (b && rest != NULL) {
1618  *rest = copy(0, getLength() - str.getLength());
1619  }
1620  return b;
1621  }
1622 
1628  template< typename T >
1630  endsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1631  {
1632  assert(
1634  bool b
1636  <= sal_uInt32(pData->length))
1638  (pData->buffer + pData->length
1642  literal),
1644  == 0);
1645  if (b && rest != NULL) {
1646  *rest = copy(
1647  0,
1648  (getLength()
1650  }
1651  return b;
1652  }
1653 
1654 #if defined LIBO_INTERNAL_ONLY
1655 
1656  template<typename T>
1658  endsWithIgnoreAsciiCase(T & literal, OUString * rest = nullptr) const {
1659  bool b
1661  <= sal_uInt32(pData->length))
1663  (pData->buffer + pData->length
1667  literal),
1669  == 0);
1670  if (b && rest != nullptr) {
1671  *rest = copy(
1672  0,
1673  (getLength()
1675  }
1676  return b;
1677  }
1678 
1680  bool endsWithIgnoreAsciiCase(
1681  OUStringLiteral const & literal, OUString * rest = nullptr) const
1682  {
1683  bool b = literal.size <= pData->length
1685  pData->buffer + pData->length - literal.size,
1686  literal.size, literal.data, literal.size)
1687  == 0);
1688  if (b && rest != nullptr) {
1689  *rest = copy(0, getLength() - literal.size);
1690  }
1691  return b;
1692  }
1693 #endif
1694 
1706  char const * asciiStr, sal_Int32 asciiStrLength) const
1707  {
1708  return asciiStrLength <= pData->length
1710  pData->buffer + pData->length - asciiStrLength,
1711  asciiStrLength, asciiStr, asciiStrLength)
1712  == 0);
1713  }
1714 
1715  friend bool operator == ( const OUString& rStr1, const OUString& rStr2 )
1716  { return rStr1.equals(rStr2); }
1717  friend bool operator == ( const OUString& rStr1, const sal_Unicode * pStr2 )
1718  { return rStr1.compareTo( pStr2 ) == 0; }
1719  friend bool operator == ( const sal_Unicode * pStr1, const OUString& rStr2 )
1720  { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
1721 
1722  friend bool operator != ( const OUString& rStr1, const OUString& rStr2 )
1723  { return !(operator == ( rStr1, rStr2 )); }
1724  friend bool operator != ( const OUString& rStr1, const sal_Unicode * pStr2 )
1725  { return !(operator == ( rStr1, pStr2 )); }
1726  friend bool operator != ( const sal_Unicode * pStr1, const OUString& rStr2 )
1727  { return !(operator == ( pStr1, rStr2 )); }
1728 
1729  friend bool operator < ( const OUString& rStr1, const OUString& rStr2 )
1730  { return rStr1.compareTo( rStr2 ) < 0; }
1731  friend bool operator > ( const OUString& rStr1, const OUString& rStr2 )
1732  { return rStr1.compareTo( rStr2 ) > 0; }
1733  friend bool operator <= ( const OUString& rStr1, const OUString& rStr2 )
1734  { return rStr1.compareTo( rStr2 ) <= 0; }
1735  friend bool operator >= ( const OUString& rStr1, const OUString& rStr2 )
1736  { return rStr1.compareTo( rStr2 ) >= 0; }
1737 
1745  template< typename T >
1747  {
1748  assert(
1750  return rString.equalsAsciiL(
1753  }
1761  template< typename T >
1763  {
1764  assert(
1766  return rString.equalsAsciiL(
1769  }
1777  template< typename T >
1779  {
1780  assert(
1782  return !rString.equalsAsciiL(
1785  }
1793  template< typename T >
1795  {
1796  assert(
1798  return !rString.equalsAsciiL(
1801  }
1802 
1803 #if defined LIBO_INTERNAL_ONLY
1804 
1805  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1806  operator ==(OUString & string, T & literal) {
1807  return
1809  string.pData->buffer, string.pData->length,
1811  literal),
1813  == 0;
1814  }
1816  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1817  operator ==(T & literal, OUString & string) {
1818  return
1820  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1821  literal),
1822  libreoffice_internal::ConstCharArrayDetector<T>::length,
1823  string.pData->buffer, string.pData->length)
1824  == 0;
1825  }
1827  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1828  operator !=(OUString & string, T & literal) {
1829  return
1831  string.pData->buffer, string.pData->length,
1832  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1833  literal),
1834  libreoffice_internal::ConstCharArrayDetector<T>::length)
1835  != 0;
1836  }
1838  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1839  operator !=(T & literal, OUString & string) {
1840  return
1842  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1843  literal),
1844  libreoffice_internal::ConstCharArrayDetector<T>::length,
1845  string.pData->buffer, string.pData->length)
1846  != 0;
1847  }
1848 #endif
1849 
1850 #if defined LIBO_INTERNAL_ONLY
1851 
1853  /* Comparison between OUString and OUStringLiteral.
1854 
1855  @since LibreOffice 5.0
1856  */
1857 
1858  friend bool operator ==(OUString const & lhs, OUStringLiteral const & rhs) {
1859  return lhs.equalsAsciiL(rhs.data, rhs.size);
1860  }
1861 
1862  friend bool operator !=(OUString const & lhs, OUStringLiteral const & rhs) {
1863  return !lhs.equalsAsciiL(rhs.data, rhs.size);
1864  }
1865 
1866  friend bool operator <(OUString const & lhs, OUStringLiteral const & rhs) {
1867  return
1869  lhs.pData->buffer, lhs.pData->length, rhs.data))
1870  < 0;
1871  }
1872 
1873  friend bool operator <=(OUString const & lhs, OUStringLiteral const & rhs) {
1874  return
1876  lhs.pData->buffer, lhs.pData->length, rhs.data))
1877  <= 0;
1878  }
1879 
1880  friend bool operator >(OUString const & lhs, OUStringLiteral const & rhs) {
1881  return
1883  lhs.pData->buffer, lhs.pData->length, rhs.data))
1884  > 0;
1885  }
1886 
1887  friend bool operator >=(OUString const & lhs, OUStringLiteral const & rhs) {
1888  return
1890  lhs.pData->buffer, lhs.pData->length, rhs.data))
1891  >= 0;
1892  }
1893 
1894  friend bool operator ==(OUStringLiteral const & lhs, OUString const & rhs) {
1895  return rhs.equalsAsciiL(lhs.data, lhs.size);
1896  }
1897 
1898  friend bool operator !=(OUStringLiteral const & lhs, OUString const & rhs) {
1899  return !rhs.equalsAsciiL(lhs.data, lhs.size);
1900  }
1901 
1902  friend bool operator <(OUStringLiteral const & lhs, OUString const & rhs) {
1903  return
1905  rhs.pData->buffer, rhs.pData->length, lhs.data))
1906  >= 0;
1907  }
1908 
1909  friend bool operator <=(OUStringLiteral const & lhs, OUString const & rhs) {
1910  return
1912  rhs.pData->buffer, rhs.pData->length, lhs.data))
1913  > 0;
1914  }
1915 
1916  friend bool operator >(OUStringLiteral const & lhs, OUString const & rhs) {
1917  return
1919  rhs.pData->buffer, rhs.pData->length, lhs.data))
1920  <= 0;
1921  }
1922 
1923  friend bool operator >=(OUStringLiteral const & lhs, OUString const & rhs) {
1924  return
1926  rhs.pData->buffer, rhs.pData->length, lhs.data))
1927  < 0;
1928  }
1929 
1931 #endif
1932 
1940  sal_Int32 hashCode() const
1941  {
1942  return rtl_ustr_hashCode_WithLength( pData->buffer, pData->length );
1943  }
1944 
1958  sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
1959  {
1960  sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1961  return (ret < 0 ? ret : ret+fromIndex);
1962  }
1963 
1973  sal_Int32 lastIndexOf( sal_Unicode ch ) const
1974  {
1975  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1976  }
1977 
1990  sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
1991  {
1992  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1993  }
1994 
2010  sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
2011  {
2012  sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
2013  str.pData->buffer, str.pData->length );
2014  return (ret < 0 ? ret : ret+fromIndex);
2015  }
2016 
2022  template< typename T >
2023  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
2024  {
2025  assert(
2027  sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
2028  pData->buffer + fromIndex, pData->length - fromIndex,
2031  return n < 0 ? n : n + fromIndex;
2032  }
2033 
2034 #if defined LIBO_INTERNAL_ONLY
2035 
2036  template<typename T>
2037  typename
2039  indexOf(T & literal, sal_Int32 fromIndex = 0) const {
2040  assert(fromIndex >= 0);
2042  pData->buffer + fromIndex, pData->length - fromIndex,
2045  return n < 0 ? n : n + fromIndex;
2046  }
2047 
2049  sal_Int32 indexOf(OUStringLiteral const & literal, sal_Int32 fromIndex = 0)
2050  const
2051  {
2052  sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
2053  pData->buffer + fromIndex, pData->length - fromIndex, literal.data,
2054  literal.size);
2055  return n < 0 ? n : n + fromIndex;
2056  }
2057 #endif
2058 
2082  sal_Int32 indexOfAsciiL(
2083  char const * str, sal_Int32 len, sal_Int32 fromIndex = 0) const
2084  {
2085  sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
2086  pData->buffer + fromIndex, pData->length - fromIndex, str, len);
2087  return ret < 0 ? ret : ret + fromIndex;
2088  }
2089 
2090  // This overload is left undefined, to detect calls of indexOfAsciiL that
2091  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
2092  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
2093  // platforms):
2094 #if SAL_TYPES_SIZEOFLONG == 8
2095  void indexOfAsciiL(char const *, sal_Int32 len, rtl_TextEncoding) const;
2096 #endif
2097 
2113  sal_Int32 lastIndexOf( const OUString & str ) const
2114  {
2115  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
2116  str.pData->buffer, str.pData->length );
2117  }
2118 
2136  sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
2137  {
2138  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
2139  str.pData->buffer, str.pData->length );
2140  }
2141 
2147  template< typename T >
2149  {
2150  assert(
2153  pData->buffer, pData->length,
2156  }
2157 
2158 #if defined LIBO_INTERNAL_ONLY
2159 
2160  template<typename T>
2161  typename
2163  lastIndexOf(T & literal) const {
2165  pData->buffer, pData->length,
2168  }
2169 
2171  sal_Int32 lastIndexOf(OUStringLiteral const & literal) const {
2173  pData->buffer, pData->length, literal.data, literal.size);
2174  }
2175 #endif
2176 
2196  sal_Int32 lastIndexOfAsciiL(char const * str, sal_Int32 len) const
2197  {
2199  pData->buffer, pData->length, str, len);
2200  }
2201 
2212  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex ) const
2213  {
2214  rtl_uString *pNew = NULL;
2215  rtl_uString_newFromSubString( &pNew, pData, beginIndex, getLength() - beginIndex );
2216  return OUString( pNew, SAL_NO_ACQUIRE );
2217  }
2218 
2231  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const
2232  {
2233  rtl_uString *pNew = NULL;
2234  rtl_uString_newFromSubString( &pNew, pData, beginIndex, count );
2235  return OUString( pNew, SAL_NO_ACQUIRE );
2236  }
2237 
2247  {
2248  rtl_uString* pNew = NULL;
2249  rtl_uString_newConcat( &pNew, pData, str.pData );
2250  return OUString( pNew, SAL_NO_ACQUIRE );
2251  }
2252 
2253 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2254  friend OUString operator+( const OUString& rStr1, const OUString& rStr2 )
2255  {
2256  return rStr1.concat( rStr2 );
2257  }
2258 #endif
2259 
2273  SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const
2274  {
2275  rtl_uString* pNew = NULL;
2276  rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
2277  return OUString( pNew, SAL_NO_ACQUIRE );
2278  }
2279 
2294  {
2295  rtl_uString* pNew = NULL;
2296  rtl_uString_newReplace( &pNew, pData, oldChar, newChar );
2297  return OUString( pNew, SAL_NO_ACQUIRE );
2298  }
2299 
2319  OUString const & from, OUString const & to, sal_Int32 * index = NULL) const
2320  {
2321  rtl_uString * s = NULL;
2322  sal_Int32 i = 0;
2324  &s, pData, from.pData, to.pData, index == NULL ? &i : index);
2325  return OUString(s, SAL_NO_ACQUIRE);
2326  }
2327 
2346  template< typename T >
2348  sal_Int32 * index = NULL) const
2349  {
2351  rtl_uString * s = NULL;
2352  sal_Int32 i = 0;
2354  &s, pData,
2357  index == NULL ? &i : index);
2358  return OUString(s, SAL_NO_ACQUIRE);
2359  }
2360 
2379  template< typename T >
2381  sal_Int32 * index = NULL) const
2382  {
2384  rtl_uString * s = NULL;
2385  sal_Int32 i = 0;
2387  &s, pData, from.pData,
2390  index == NULL ? &i : index);
2391  return OUString(s, SAL_NO_ACQUIRE);
2392  }
2393 
2412  template< typename T1, typename T2 >
2414  replaceFirst( T1& from, T2& to, sal_Int32 * index = NULL) const
2415  {
2418  rtl_uString * s = NULL;
2419  sal_Int32 i = 0;
2421  &s, pData,
2426  index == NULL ? &i : index);
2427  return OUString(s, SAL_NO_ACQUIRE);
2428  }
2429 
2430 #if defined LIBO_INTERNAL_ONLY
2431 
2432  template<typename T> [[nodiscard]]
2433  typename
2435  replaceFirst(T & from, OUString const & to, sal_Int32 * index = nullptr)
2436  const
2437  {
2438  rtl_uString * s = nullptr;
2439  sal_Int32 i = 0;
2441  &s, pData,
2444  to.pData->buffer, to.pData->length, index == nullptr ? &i : index);
2445  if (s == nullptr) {
2446  throw std::bad_alloc();
2447  // should be std::length_error if resulting would be too large
2448  }
2449  return OUString(s, SAL_NO_ACQUIRE);
2450  }
2452  template<typename T> [[nodiscard]]
2453  typename
2454  libreoffice_internal::ConstCharArrayDetector<T, OUString>::TypeUtf16
2455  replaceFirst(OUString const & from, T & to, sal_Int32 * index = nullptr)
2456  const
2457  {
2458  rtl_uString * s = nullptr;
2459  sal_Int32 i = 0;
2461  &s, pData, from.pData->buffer, from.pData->length,
2462  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(to),
2463  libreoffice_internal::ConstCharArrayDetector<T>::length,
2464  index == nullptr ? &i : index);
2465  if (s == nullptr) {
2466  throw std::bad_alloc();
2467  // should be std::length_error if resulting would be too large
2468  }
2469  return OUString(s, SAL_NO_ACQUIRE);
2470  }
2472  template<typename T1, typename T2> [[nodiscard]]
2473  typename
2474  libreoffice_internal::ConstCharArrayDetector<
2475  T1,
2476  typename libreoffice_internal::ConstCharArrayDetector<
2477  T2, OUString>::TypeUtf16
2478  >::TypeUtf16
2479  replaceFirst(T1 & from, T2 & to, sal_Int32 * index = nullptr) const {
2480  rtl_uString * s = nullptr;
2481  sal_Int32 i = 0;
2483  &s, pData,
2484  libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2485  libreoffice_internal::ConstCharArrayDetector<T1>::length,
2486  libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2487  libreoffice_internal::ConstCharArrayDetector<T2>::length,
2488  index == nullptr ? &i : index);
2489  if (s == nullptr) {
2490  throw std::bad_alloc();
2491  // should be std::length_error if resulting would be too large
2492  }
2493  return OUString(s, SAL_NO_ACQUIRE);
2494  }
2496  template<typename T1, typename T2> [[nodiscard]]
2497  typename
2498  libreoffice_internal::ConstCharArrayDetector<
2499  T1,
2500  typename libreoffice_internal::ConstCharArrayDetector<
2501  T2, OUString>::Type
2502  >::TypeUtf16
2503  replaceFirst(T1 & from, T2 & to, sal_Int32 * index = nullptr) const {
2504  rtl_uString * s = nullptr;
2505  sal_Int32 i = 0;
2507  &s, pData,
2508  libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2509  libreoffice_internal::ConstCharArrayDetector<T1>::length,
2510  libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2511  libreoffice_internal::ConstCharArrayDetector<T2>::length,
2512  index == nullptr ? &i : index);
2513  if (s == nullptr) {
2514  throw std::bad_alloc();
2515  // should be std::length_error if resulting would be too large
2516  }
2517  return OUString(s, SAL_NO_ACQUIRE);
2518  }
2520  template<typename T1, typename T2> [[nodiscard]]
2521  typename
2522  libreoffice_internal::ConstCharArrayDetector<
2523  T1,
2524  typename libreoffice_internal::ConstCharArrayDetector<
2525  T2, OUString>::TypeUtf16
2526  >::Type
2527  replaceFirst(T1 & from, T2 & to, sal_Int32 * index = nullptr) const {
2528  rtl_uString * s = nullptr;
2529  sal_Int32 i = 0;
2531  &s, pData,
2532  libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2533  libreoffice_internal::ConstCharArrayDetector<T1>::length,
2534  libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2535  libreoffice_internal::ConstCharArrayDetector<T2>::length,
2536  index == nullptr ? &i : index);
2537  if (s == nullptr) {
2538  throw std::bad_alloc();
2539  // should be std::length_error if resulting would be too large
2540  }
2541  return OUString(s, SAL_NO_ACQUIRE);
2542  }
2543 
2545  [[nodiscard]] OUString replaceFirst(
2546  OUStringLiteral const & from, OUString const & to,
2547  sal_Int32 * index = nullptr) const
2548  {
2549  rtl_uString * s = nullptr;
2550  sal_Int32 i = 0;
2552  &s, pData, from.data, from.size, to.pData,
2553  index == nullptr ? &i : index);
2554  return OUString(s, SAL_NO_ACQUIRE);
2555  }
2557  [[nodiscard]] OUString replaceFirst(
2558  OUString const & from, OUStringLiteral const & to,
2559  sal_Int32 * index = nullptr) const
2560  {
2561  rtl_uString * s = nullptr;
2562  sal_Int32 i = 0;
2564  &s, pData, from.pData, to.data, to.size,
2565  index == nullptr ? &i : index);
2566  return OUString(s, SAL_NO_ACQUIRE);
2567  }
2569  [[nodiscard]] OUString replaceFirst(
2570  OUStringLiteral const & from, OUStringLiteral const & to,
2571  sal_Int32 * index = nullptr) const
2572  {
2573  rtl_uString * s = nullptr;
2574  sal_Int32 i = 0;
2576  &s, pData, from.data, from.size, to.data, to.size,
2577  index == nullptr ? &i : index);
2578  return OUString(s, SAL_NO_ACQUIRE);
2579  }
2581  template<typename T> [[nodiscard]]
2582  typename libreoffice_internal::ConstCharArrayDetector<T, OUString >::Type
2583  replaceFirst(
2584  OUStringLiteral const & from, T & to, sal_Int32 * index = nullptr) const
2585  {
2586  assert(libreoffice_internal::ConstCharArrayDetector<T>::isValid(to));
2587  rtl_uString * s = nullptr;
2588  sal_Int32 i = 0;
2590  &s, pData, from.data, from.size,
2591  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(to),
2592  libreoffice_internal::ConstCharArrayDetector<T>::length,
2593  index == nullptr ? &i : index);
2594  return OUString(s, SAL_NO_ACQUIRE);
2595  }
2597  template<typename T> [[nodiscard]]
2598  typename libreoffice_internal::ConstCharArrayDetector<T, OUString >::Type
2599  replaceFirst(
2600  T & from, OUStringLiteral const & to, sal_Int32 * index = nullptr) const
2601  {
2602  assert(libreoffice_internal::ConstCharArrayDetector<T>::isValid(from));
2603  rtl_uString * s = nullptr;
2604  sal_Int32 i = 0;
2606  &s, pData,
2607  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(from),
2608  libreoffice_internal::ConstCharArrayDetector<T>::length, to.data,
2609  to.size, index == nullptr ? &i : index);
2610  return OUString(s, SAL_NO_ACQUIRE);
2611  }
2613  template<typename T> [[nodiscard]]
2614  typename
2615  libreoffice_internal::ConstCharArrayDetector<T, OUString >::TypeUtf16
2616  replaceFirst(
2617  OUStringLiteral const & from, T & to, sal_Int32 * index = nullptr) const
2618  {
2619  assert(libreoffice_internal::ConstCharArrayDetector<T>::isValid(to));
2620  rtl_uString * s = nullptr;
2621  sal_Int32 i = 0;
2623  &s, pData, from.data, from.size,
2624  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(to),
2625  libreoffice_internal::ConstCharArrayDetector<T>::length,
2626  index == nullptr ? &i : index);
2627  return OUString(s, SAL_NO_ACQUIRE);
2628  }
2630  template<typename T> [[nodiscard]]
2631  typename
2632  libreoffice_internal::ConstCharArrayDetector<T, OUString >::TypeUtf16
2633  replaceFirst(
2634  T & from, OUStringLiteral const & to, sal_Int32 * index = nullptr) const
2635  {
2636  assert(libreoffice_internal::ConstCharArrayDetector<T>::isValid(from));
2637  rtl_uString * s = nullptr;
2638  sal_Int32 i = 0;
2640  &s, pData,
2641  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(from),
2642  libreoffice_internal::ConstCharArrayDetector<T>::length, to.data,
2643  to.size, index == nullptr ? &i : index);
2644  return OUString(s, SAL_NO_ACQUIRE);
2645  }
2646 #endif
2647 
2664  OUString const & from, OUString const & to, sal_Int32 fromIndex = 0) const
2665  {
2666  rtl_uString * s = NULL;
2667  rtl_uString_newReplaceAllFromIndex(&s, pData, from.pData, to.pData, fromIndex);
2668  return OUString(s, SAL_NO_ACQUIRE);
2669  }
2670 
2684  template< typename T >
2686  {
2688  rtl_uString * s = NULL;
2690  &s, pData,
2693  return OUString(s, SAL_NO_ACQUIRE);
2694  }
2695 
2709  template< typename T >
2711  {
2713  rtl_uString * s = NULL;
2715  &s, pData, from.pData,
2718  return OUString(s, SAL_NO_ACQUIRE);
2719  }
2720 
2734  template< typename T1, typename T2 >
2736  replaceAll( T1& from, T2& to ) const
2737  {
2740  rtl_uString * s = NULL;
2742  &s, pData,
2747  return OUString(s, SAL_NO_ACQUIRE);
2748  }
2749 
2750 #if defined LIBO_INTERNAL_ONLY
2751 
2752  template<typename T> [[nodiscard]]
2753  typename
2755  replaceAll(T & from, OUString const & to) const {
2756  rtl_uString * s = nullptr;
2758  &s, pData,
2761  to.pData->buffer, to.pData->length);
2762  if (s == nullptr) {
2763  throw std::bad_alloc();
2764  // should be std::length_error if resulting would be too large
2765  }
2766  return OUString(s, SAL_NO_ACQUIRE);
2767  }
2769  template<typename T> [[nodiscard]]
2770  typename
2771  libreoffice_internal::ConstCharArrayDetector<T, OUString>::TypeUtf16
2772  replaceAll(OUString const & from, T & to) const {
2773  rtl_uString * s = nullptr;
2775  &s, pData, from.pData->buffer, from.pData->length,
2776  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(to),
2777  libreoffice_internal::ConstCharArrayDetector<T>::length);
2778  if (s == nullptr) {
2779  throw std::bad_alloc();
2780  // should be std::length_error if resulting would be too large
2781  }
2782  return OUString(s, SAL_NO_ACQUIRE);
2783  }
2785  template<typename T1, typename T2> [[nodiscard]]
2786  typename
2787  libreoffice_internal::ConstCharArrayDetector<
2788  T1,
2789  typename libreoffice_internal::ConstCharArrayDetector<
2790  T2, OUString>::TypeUtf16
2791  >::TypeUtf16
2792  replaceAll(T1 & from, T2 & to) const {
2793  rtl_uString * s = nullptr;
2795  &s, pData,
2796  libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2797  libreoffice_internal::ConstCharArrayDetector<T1>::length,
2798  libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2799  libreoffice_internal::ConstCharArrayDetector<T2>::length);
2800  if (s == nullptr) {
2801  throw std::bad_alloc();
2802  // should be std::length_error if resulting would be too large
2803  }
2804  return OUString(s, SAL_NO_ACQUIRE);
2805  }
2807  template<typename T1, typename T2> [[nodiscard]]
2808  typename
2809  libreoffice_internal::ConstCharArrayDetector<
2810  T1,
2811  typename libreoffice_internal::ConstCharArrayDetector<
2812  T2, OUString>::Type
2813  >::TypeUtf16
2814  replaceAll(T1 & from, T2 & to) const {
2815  rtl_uString * s = nullptr;
2817  &s, pData,
2818  libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2819  libreoffice_internal::ConstCharArrayDetector<T1>::length,
2820  libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2821  libreoffice_internal::ConstCharArrayDetector<T2>::length);
2822  if (s == nullptr) {
2823  throw std::bad_alloc();
2824  // should be std::length_error if resulting would be too large
2825  }
2826  return OUString(s, SAL_NO_ACQUIRE);
2827  }
2829  template<typename T1, typename T2> [[nodiscard]]
2830  typename
2831  libreoffice_internal::ConstCharArrayDetector<
2832  T1,
2833  typename libreoffice_internal::ConstCharArrayDetector<
2834  T2, OUString>::TypeUtf16
2835  >::Type
2836  replaceAll(T1 & from, T2 & to) const {
2837  rtl_uString * s = nullptr;
2839  &s, pData,
2840  libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2841  libreoffice_internal::ConstCharArrayDetector<T1>::length,
2842  libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2843  libreoffice_internal::ConstCharArrayDetector<T2>::length);
2844  if (s == nullptr) {
2845  throw std::bad_alloc();
2846  // should be std::length_error if resulting would be too large
2847  }
2848  return OUString(s, SAL_NO_ACQUIRE);
2849  }
2850 
2852  [[nodiscard]] OUString replaceAll(
2853  OUStringLiteral const & from, OUString const & to) const
2854  {
2855  rtl_uString * s = nullptr;
2857  &s, pData, from.data, from.size, to.pData);
2858  return OUString(s, SAL_NO_ACQUIRE);
2859  }
2861  [[nodiscard]] OUString replaceAll(
2862  OUString const & from, OUStringLiteral const & to) const
2863  {
2864  rtl_uString * s = nullptr;
2866  &s, pData, from.pData, to.data, to.size);
2867  return OUString(s, SAL_NO_ACQUIRE);
2868  }
2870  [[nodiscard]] OUString replaceAll(
2871  OUStringLiteral const & from, OUStringLiteral const & to) const
2872  {
2873  rtl_uString * s = nullptr;
2875  &s, pData, from.data, from.size, to.data, to.size);
2876  return OUString(s, SAL_NO_ACQUIRE);
2877  }
2879  template<typename T> [[nodiscard]]
2880  typename libreoffice_internal::ConstCharArrayDetector<T, OUString >::Type
2881  replaceAll(OUStringLiteral const & from, T & to) const {
2882  assert(libreoffice_internal::ConstCharArrayDetector<T>::isValid(to));
2883  rtl_uString * s = nullptr;
2885  &s, pData, from.data, from.size,
2886  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(to),
2887  libreoffice_internal::ConstCharArrayDetector<T>::length);
2888  return OUString(s, SAL_NO_ACQUIRE);
2889  }
2891  template<typename T> [[nodiscard]]
2892  typename libreoffice_internal::ConstCharArrayDetector<T, OUString >::Type
2893  replaceAll(T & from, OUStringLiteral const & to) const {
2894  assert(libreoffice_internal::ConstCharArrayDetector<T>::isValid(from));
2895  rtl_uString * s = nullptr;
2897  &s, pData,
2898  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(from),
2899  libreoffice_internal::ConstCharArrayDetector<T>::length, to.data,
2900  to.size);
2901  return OUString(s, SAL_NO_ACQUIRE);
2902  }
2904  template<typename T> [[nodiscard]]
2905  typename
2906  libreoffice_internal::ConstCharArrayDetector<T, OUString >::TypeUtf16
2907  replaceAll(OUStringLiteral const & from, T & to) const {
2908  assert(libreoffice_internal::ConstCharArrayDetector<T>::isValid(to));
2909  rtl_uString * s = nullptr;
2911  &s, pData, from.data, from.size,
2912  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(to),
2913  libreoffice_internal::ConstCharArrayDetector<T>::length);
2914  return OUString(s, SAL_NO_ACQUIRE);
2915  }
2917  template<typename T> [[nodiscard]]
2918  typename
2919  libreoffice_internal::ConstCharArrayDetector<T, OUString >::TypeUtf16
2920  replaceAll(T & from, OUStringLiteral const & to) const {
2921  assert(libreoffice_internal::ConstCharArrayDetector<T>::isValid(from));
2922  rtl_uString * s = nullptr;
2924  &s, pData,
2925  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(from),
2926  libreoffice_internal::ConstCharArrayDetector<T>::length, to.data,
2927  to.size);
2928  return OUString(s, SAL_NO_ACQUIRE);
2929  }
2930 #endif
2931 
2943  {
2944  rtl_uString* pNew = NULL;
2945  rtl_uString_newToAsciiLowerCase( &pNew, pData );
2946  return OUString( pNew, SAL_NO_ACQUIRE );
2947  }
2948 
2960  {
2961  rtl_uString* pNew = NULL;
2962  rtl_uString_newToAsciiUpperCase( &pNew, pData );
2963  return OUString( pNew, SAL_NO_ACQUIRE );
2964  }
2965 
2980  {
2981  rtl_uString* pNew = NULL;
2982  rtl_uString_newTrim( &pNew, pData );
2983  return OUString( pNew, SAL_NO_ACQUIRE );
2984  }
2985 
3010  OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const
3011  {
3012  rtl_uString * pNew = NULL;
3013  index = rtl_uString_getToken( &pNew, pData, token, cTok, index );
3014  return OUString( pNew, SAL_NO_ACQUIRE );
3015  }
3016 
3030  OUString getToken(sal_Int32 count, sal_Unicode separator) const {
3031  sal_Int32 n = 0;
3032  return getToken(count, separator, n);
3033  }
3034 
3043  bool toBoolean() const
3044  {
3045  return rtl_ustr_toBoolean( pData->buffer );
3046  }
3047 
3055  {
3056  return pData->buffer[0];
3057  }
3058 
3069  sal_Int32 toInt32( sal_Int16 radix = 10 ) const
3070  {
3071  return rtl_ustr_toInt32( pData->buffer, radix );
3072  }
3073 
3086  sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
3087  {
3088  return rtl_ustr_toUInt32( pData->buffer, radix );
3089  }
3090 
3101  sal_Int64 toInt64( sal_Int16 radix = 10 ) const
3102  {
3103  return rtl_ustr_toInt64( pData->buffer, radix );
3104  }
3105 
3118  sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
3119  {
3120  return rtl_ustr_toUInt64( pData->buffer, radix );
3121  }
3122 
3131  float toFloat() const
3132  {
3133  return rtl_ustr_toFloat( pData->buffer );
3134  }
3135 
3144  double toDouble() const
3145  {
3146  return rtl_ustr_toDouble( pData->buffer );
3147  }
3148 
3149 
3166  {
3167  rtl_uString * pNew = NULL;
3168  rtl_uString_intern( &pNew, pData );
3169  if (pNew == NULL) {
3170  throw std::bad_alloc();
3171  }
3172  return OUString( pNew, SAL_NO_ACQUIRE );
3173  }
3174 
3200  static OUString intern( const sal_Char * value, sal_Int32 length,
3201  rtl_TextEncoding encoding,
3202  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS,
3203  sal_uInt32 *pInfo = NULL )
3204  {
3205  rtl_uString * pNew = NULL;
3206  rtl_uString_internConvert( &pNew, value, length, encoding,
3207  convertFlags, pInfo );
3208  if (pNew == NULL) {
3209  throw std::bad_alloc();
3210  }
3211  return OUString( pNew, SAL_NO_ACQUIRE );
3212  }
3213 
3238  bool convertToString(OString * pTarget, rtl_TextEncoding nEncoding,
3239  sal_uInt32 nFlags) const
3240  {
3241  return rtl_convertUStringToString(&pTarget->pData, pData->buffer,
3242  pData->length, nEncoding, nFlags);
3243  }
3244 
3296  sal_uInt32 iterateCodePoints(
3297  sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1) const
3298  {
3300  pData, indexUtf16, incrementCodePoints);
3301  }
3302 
3312  static OUString fromUtf8(const OString& rSource)
3313  {
3314  OUString aTarget;
3315  bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
3316  rSource.getStr(),
3317  rSource.getLength(),
3320  (void) bSuccess;
3321  assert(bSuccess);
3322  return aTarget;
3323  }
3324 
3335  OString toUtf8() const
3336  {
3337  OString aTarget;
3338  bool bSuccess = rtl_convertUStringToString(&aTarget.pData,
3339  getStr(),
3340  getLength(),
3343  (void) bSuccess;
3344  assert(bSuccess);
3345  return aTarget;
3346  }
3347 
3358  static OUString number( int i, sal_Int16 radix = 10 )
3359  {
3361  rtl_uString* pNewData = NULL;
3362  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt32( aBuf, i, radix ) );
3363  return OUString( pNewData, SAL_NO_ACQUIRE );
3364  }
3367  static OUString number( unsigned int i, sal_Int16 radix = 10 )
3368  {
3369  return number( static_cast< unsigned long long >( i ), radix );
3370  }
3373  static OUString number( long i, sal_Int16 radix = 10)
3374  {
3375  return number( static_cast< long long >( i ), radix );
3376  }
3379  static OUString number( unsigned long i, sal_Int16 radix = 10 )
3380  {
3381  return number( static_cast< unsigned long long >( i ), radix );
3382  }
3385  static OUString number( long long ll, sal_Int16 radix = 10 )
3386  {
3388  rtl_uString* pNewData = NULL;
3389  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt64( aBuf, ll, radix ) );
3390  return OUString( pNewData, SAL_NO_ACQUIRE );
3391  }
3394  static OUString number( unsigned long long ll, sal_Int16 radix = 10 )
3395  {
3397  rtl_uString* pNewData = NULL;
3398  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfUInt64( aBuf, ll, radix ) );
3399  return OUString( pNewData, SAL_NO_ACQUIRE );
3400  }
3401 
3411  static OUString number( float f )
3412  {
3414  rtl_uString* pNewData = NULL;
3415  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfFloat( aBuf, f ) );
3416  return OUString( pNewData, SAL_NO_ACQUIRE );
3417  }
3418 
3428  static OUString number( double d )
3429  {
3431  rtl_uString* pNewData = NULL;
3432  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfDouble( aBuf, d ) );
3433  return OUString( pNewData, SAL_NO_ACQUIRE );
3434  }
3435 
3447  SAL_DEPRECATED("use boolean()") static OUString valueOf( sal_Bool b )
3448  {
3449  return boolean(b);
3450  }
3451 
3463  static OUString boolean( bool b )
3464  {
3466  rtl_uString* pNewData = NULL;
3467  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfBoolean( aBuf, b ) );
3468  return OUString( pNewData, SAL_NO_ACQUIRE );
3469  }
3470 
3478  SAL_DEPRECATED("convert to OUString or use directly") static OUString valueOf( sal_Unicode c )
3479  {
3480  return OUString( &c, 1 );
3481  }
3482 
3493  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
3494  {
3495  return number( i, radix );
3496  }
3497 
3508  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
3509  {
3510  return number( ll, radix );
3511  }
3512 
3522  SAL_DEPRECATED("use number()") static OUString valueOf( float f )
3523  {
3524  return number(f);
3525  }
3526 
3536  SAL_DEPRECATED("use number()") static OUString valueOf( double d )
3537  {
3538  return number(d);
3539  }
3540 
3556  static OUString createFromAscii( const sal_Char * value )
3557  {
3558  rtl_uString* pNew = NULL;
3559  rtl_uString_newFromAscii( &pNew, value );
3560  return OUString( pNew, SAL_NO_ACQUIRE );
3561  }
3562 
3563 #if defined LIBO_INTERNAL_ONLY
3564  operator std::u16string_view() const { return {getStr(), sal_uInt32(getLength())}; }
3565 #endif
3566 
3567 private:
3568  OUString & internalAppend( rtl_uString* pOtherData )
3569  {
3570  rtl_uString* pNewData = NULL;
3571  rtl_uString_newConcat( &pNewData, pData, pOtherData );
3572  if (pNewData == NULL) {
3573  throw std::bad_alloc();
3574  }
3575  rtl_uString_assign(&pData, pNewData);
3576  rtl_uString_release(pNewData);
3577  return *this;
3578  }
3579 
3580 };
3581 
3582 #if defined LIBO_INTERNAL_ONLY
3583 // Prevent the operator ==/!= overloads with 'sal_Unicode const *' parameter from
3584 // being selected for nonsensical code like
3585 //
3586 // if (ouIdAttr == nullptr)
3587 //
3588 void operator ==(OUString const &, std::nullptr_t) = delete;
3589 void operator ==(std::nullptr_t, OUString const &) = delete;
3590 void operator !=(OUString const &, std::nullptr_t) = delete;
3591 void operator !=(std::nullptr_t, OUString const &) = delete;
3592 #endif
3593 
3594 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3595 
3600 template<>
3601 struct ToStringHelper< OUString >
3602  {
3603  static int length( const OUString& s ) { return s.getLength(); }
3604  static sal_Unicode* addData( sal_Unicode* buffer, const OUString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
3605  static const bool allowOStringConcat = false;
3606  static const bool allowOUStringConcat = true;
3607  };
3608 
3612 template<>
3613 struct ToStringHelper< OUStringLiteral >
3614  {
3615  static int length( const OUStringLiteral& str ) { return str.size; }
3616  static sal_Unicode* addData( sal_Unicode* buffer, const OUStringLiteral& str ) { return addDataLiteral( buffer, str.data, str.size ); }
3617  static const bool allowOStringConcat = false;
3618  static const bool allowOUStringConcat = true;
3619  };
3620 
3624 template< typename charT, typename traits, typename T1, typename T2 >
3625 inline std::basic_ostream<charT, traits> & operator <<(
3626  std::basic_ostream<charT, traits> & stream, OUStringConcat< T1, T2 >&& concat)
3627 {
3628  return stream << OUString( std::move(concat) );
3629 }
3630 
3632 #endif
3633 
3640 {
3650  size_t operator()(const OUString& rString) const
3651  { return static_cast<size_t>(rString.hashCode()); }
3652 };
3653 
3654 /* ======================================================================= */
3655 
3673 inline OUString OStringToOUString( const OString & rStr,
3674  rtl_TextEncoding encoding,
3675  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
3676 {
3677  return OUString( rStr.getStr(), rStr.getLength(), encoding, convertFlags );
3678 }
3679 
3697 inline OString OUStringToOString( const OUString & rUnicode,
3698  rtl_TextEncoding encoding,
3699  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
3700 {
3701  return OString( rUnicode.getStr(), rUnicode.getLength(), encoding, convertFlags );
3702 }
3703 
3704 /* ======================================================================= */
3705 
3714 template< typename charT, typename traits >
3715 inline std::basic_ostream<charT, traits> & operator <<(
3716  std::basic_ostream<charT, traits> & stream, OUString const & rString)
3717 {
3718  return stream <<
3720  // best effort; potentially loses data due to conversion failures
3721  // (stray surrogate halves) and embedded null characters
3722 }
3723 
3724 } // namespace
3725 
3726 #ifdef RTL_STRING_UNITTEST
3727 namespace rtl
3728 {
3729 typedef rtlunittest::OUString OUString;
3730 }
3731 #endif
3732 
3733 // In internal code, allow to use classes like OUString without having to
3734 // explicitly refer to the rtl namespace, which is kind of superfluous given
3735 // that OUString itself is namespaced by its OU prefix:
3736 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3737 using ::rtl::OUString;
3738 using ::rtl::OUStringHash;
3741 using ::rtl::OUStringLiteral;
3742 using ::rtl::OUStringLiteral1;
3743 #endif
3744 
3746 
3751 #if defined LIBO_INTERNAL_ONLY
3752 namespace std {
3753 
3754 template<>
3755 struct hash<::rtl::OUString>
3756 {
3757  std::size_t operator()(::rtl::OUString const & s) const
3758  { return std::size_t(s.hashCode()); }
3759 };
3760 
3761 }
3762 
3763 #endif
3764 
3766 #endif /* _RTL_USTRING_HXX */
3767 
3768 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC sal_Bool rtl_ustr_asciil_reverseEquals_WithLength(const sal_Unicode *first, const sal_Char *second, sal_Int32 len) SAL_THROW_EXTERN_C()
Compare two strings from back to front for equality.
static OUString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: ustring.hxx:3463
SAL_DLLPUBLIC void rtl_uString_newReplace(rtl_uString **newStr, rtl_uString *str, sal_Unicode oldChar, sal_Unicode newChar) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a single character within another string.
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1325
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:3373
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.
OUString intern() const
Return a canonical representation for a string.
Definition: ustring.hxx:3165
sal_Int32 compareToAscii(const sal_Char *asciiStr) const
Compares two strings.
Definition: ustring.hxx:1049
sal_Int32 lastIndexOf(sal_Unicode ch) const
Returns the index within this string of the last occurrence of the specified character,...
Definition: ustring.hxx:1973
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_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_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.
static OUString const & unacquired(rtl_uString *const *ppHandle)
Provides an OUString const & passing a storage pointer of an rtl_uString * handle.
Definition: ustring.hxx:443
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:2273
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:3673
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:2710
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:33
sal_Int32 lastIndexOf(const OUString &str) const
Returns the index within this string of the last occurrence of the specified substring,...
Definition: ustring.hxx:2113
OUString(rtl_uString *str)
New string from OUString data.
Definition: ustring.hxx:175
Dummy Type
Definition: stringutils.hxx:241
#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:64
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.
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: ustring.hxx:641
bool convertToString(OString *pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) const
Converts to an OString, signalling failure.
Definition: ustring.hxx:3238
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.
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:992
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 void rtl_uString_new(rtl_uString **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
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:255
SAL_DLLPUBLIC sal_Bool rtl_ustr_toBoolean(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
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:2942
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.
bool endsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string ends with a given substring.
Definition: ustring.hxx:1495
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:2414
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.
#define RTL_STR_MAX_VALUEOFUINT64
Definition: string.h:673
SAL_DLLPUBLIC void rtl_uString_newReplaceAllUtf16LUtf16L(rtl_uString **newStr, rtl_uString *str, sal_Unicode 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.
OUString(sal_uInt32 const *codePoints, sal_Int32 codePointCount)
Create a new string from an array of Unicode code points.
Definition: ustring.hxx:384
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:922
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_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:405
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:650
SAL_DLLPUBLIC void rtl_string2UString(rtl_uString **newStr, const sal_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.
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:3394
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:858
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 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_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.
bool operator!=(const Any &rAny, const C &value)
Template unequality operator: compares set value of left side any to right side value.
Definition: Any.hxx:645
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:1902
Definition: bootstrap.hxx:29
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:1990
static OUString number(float f)
Returns the string representation of the float argument.
Definition: ustring.hxx:3411
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:1613
SAL_DLLPUBLIC void rtl_uString_newConcatAsciiL(rtl_uString **newString, rtl_uString *left, char const *right, sal_Int32 rightLength)
Create a new string that is the concatenation of two other strings.
SAL_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.
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:1705
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfAscii_WithLength(sal_Unicode const *str, sal_Int32 len, char const *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of an ASCII substring within a string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_compare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Char *second) SAL_THROW_EXTERN_C()
Compare two strings.
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1778
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: ustring.hxx:1940
bool equalsIgnoreAsciiCaseAscii(const sal_Char *asciiStr) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1174
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:2023
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:2736
#define RTL_USTR_MAX_VALUEOFINT32
Definition: ustring.h:957
SAL_DLLPUBLIC double rtl_ustr_toDouble(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a double.
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:3379
static OUString intern(const sal_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:3200
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfInt32(sal_Unicode *str, sal_Int32 i, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an integer.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters, ignoring the case of ASCII characters.
sal_Int32 reverseCompareToAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Compares two strings in reverse order.
Definition: ustring.hxx:1103
SAL_WARN_UNUSED_RESULT OUString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: ustring.hxx:2212
OUString(const sal_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:357
static OUString fromUtf8(const OString &rSource)
Convert an OString to an OUString, assuming that the OString is UTF-8-encoded.
Definition: ustring.hxx:3312
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.
#define RTL_TEXTENCODING_UTF8
Definition: textenc.h:113
#define RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR
Definition: textcvt.h:71
SAL_DLLPUBLIC void rtl_uString_newFromStr(rtl_uString **newStr, const sal_Unicode *value) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don't use, it's evil.") void doit(int nPara);.
Definition: types.h:465
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:578
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:1408
bool matchIgnoreAsciiCaseAsciiL(const sal_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:1289
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.
friend OUString operator+(const OUString &rStr1, const OUString &rStr2)
Definition: ustring.hxx:2254
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.
#define RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR
Definition: textcvt.h:138
OUString()
New string containing no characters.
Definition: ustring.hxx:136
OUString getToken(sal_Int32 count, sal_Unicode separator) const
Returns a token from the string.
Definition: ustring.hxx:3030
OUString(sal_Unicode value)
New string from a single Unicode character.
Definition: ustring.hxx:197
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_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: ustring.hxx:3101
#define RTL_USTR_MAX_VALUEOFBOOLEAN
Definition: ustring.h:915
bool endsWithAsciiL(char const *asciiStr, sal_Int32 asciiStrLength) const
Check whether this string ends with a given ASCII string.
Definition: ustring.hxx:1584
OUString(const sal_Unicode *value)
New string from a Unicode character buffer array.
Definition: ustring.hxx:219
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfDouble(sal_Unicode *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
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:1332
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:3367
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.
bool match(const OUString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:910
sal_Unicode toChar() const
Returns the first character from this string.
Definition: ustring.hxx:3054
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstUtf16LUtf16L(rtl_uString **newStr, rtl_uString *str, sal_Unicode const *from, sal_Int32 fromLength, sal_Unicode const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_shortenedCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Char *second, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters.
bool equalsAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform a comparison of two strings.
Definition: ustring.hxx:1147
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:1630
OString toUtf8() const
Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully.
Definition: ustring.hxx:3335
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:756
SAL_WARN_UNUSED_RESULT OUString concat(const OUString &str) const
Concatenates the specified string to the end of this string.
Definition: ustring.hxx:2246
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:2010
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_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:3296
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfUInt64(sal_Unicode *str, sal_uInt64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an unsigned long integer.
OUString getToken(sal_Int32 token, sal_Unicode cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: ustring.hxx:3010
sal_uInt16 sal_Unicode
Definition: types.h:141
OUString(const sal_Unicode *value, sal_Int32 length)
New string from a Unicode character buffer array.
Definition: ustring.hxx:233
bool toBoolean() const
Returns the Boolean value from this string.
Definition: ustring.hxx:3043
OUString & operator=(const OUString &str)
Assign a new string.
Definition: ustring.hxx:451
SAL_DLLPUBLIC void rtl_uString_intern(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Return a canonical representation for a string.
#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:132
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:2136
unsigned char sal_Bool
Definition: types.h:38
__sal_NoAcquire
Definition: types.h:370
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: ustring.hxx:3086
static OUString createFromAscii(const sal_Char *value)
Returns a OUString copied without conversion from an ASCII character string.
Definition: ustring.hxx:3556
A helper to use OUStrings with hash maps.
Definition: ustring.hxx:3639
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:979
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:664
bool equalsIgnoreAsciiCase(const OUString &str) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:820
const sal_Char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:431
#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
Definition: textcvt.h:68
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.
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:2148
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfChar_WithLength(const sal_Unicode *str, sal_Int32 len, sal_Unicode ch) SAL_THROW_EXTERN_C()
Search for the last occurrence of a character within a string.
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:100
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:2685
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1746
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:2231
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.
bool startsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: ustring.hxx:1318
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1762
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:2196
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:90
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:2318
sal_Int32 compareTo(const OUString &str) const
Compares two strings.
Definition: ustring.hxx:705
float toFloat() const
Returns the float value from this string.
Definition: ustring.hxx:3131
SAL_DLLPUBLIC sal_Int32 rtl_ustr_compareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
SAL_DLLPUBLIC void rtl_uString_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.
static OUString number(double d)
Returns the string representation of the double argument.
Definition: ustring.hxx:3428
definition of a no acquire enum for ctors
Definition: types.h:374
SAL_DLLPUBLIC sal_Int32 rtl_ustr_asciil_reverseCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings from back to front.
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 void rtl_uString_newToAsciiLowerCase(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Create a new string by converting all ASCII uppercase letters to lowercase within another string.
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: ustring.hxx:3069
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 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.
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1794
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition: ustring.hxx:553
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:3697
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_Int32 reverseCompareTo(const OUString &str) const
Compares two strings in reverse order.
Definition: ustring.hxx:744
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:97
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfStr_WithLength(const sal_Unicode *str, sal_Int32 len, const sal_Unicode *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of a substring within a string.
SAL_DLLPUBLIC sal_Bool rtl_convertStringToUString(rtl_uString **target, char const *source, sal_Int32 length, rtl_TextEncoding encoding, sal_uInt32 flags) SAL_THROW_EXTERN_C()
Converts a byte string to a Unicode string, signalling failure.
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:2347
sal_Int32 compareToIgnoreAsciiCaseAscii(const sal_Char *asciiStr) const
Compares two ASCII strings ignoring case.
Definition: ustring.hxx:1197
sal_Int32 getLength() const
Returns the length of this string.
Definition: ustring.hxx:654
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:302
char sal_Char
A legacy synonym for char.
Definition: types.h:120
bool matchAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:1251
#define RTL_USTR_MAX_VALUEOFFLOAT
Definition: ustring.h:1022
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:2663
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:1958
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:3385
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: ustring.hxx:3118
SAL_DLLPUBLIC void rtl_uString_newFromLiteral(rtl_uString **newStr, const sal_Char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
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_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:2293
double toDouble() const
Returns the double value from this string.
Definition: ustring.hxx:3144
#define RTL_USTR_MAX_VALUEOFDOUBLE
Definition: ustring.h:1041
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.
const sal_Unicode * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:676
This String class provides base functionality for C++ like Unicode character array handling.
Definition: ustring.hxx:126
Dummy Type
Definition: stringutils.hxx:263
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.
size_t operator()(const OUString &rString) const
Compute a hash code for a string.
Definition: ustring.hxx:3650
bool equals(const OUString &str) const
Perform a comparison of two strings.
Definition: ustring.hxx:796
SAL_DLLPUBLIC void rtl_uString_newFromAscii(rtl_uString **newStr, const sal_Char *value) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
SAL_DLLPUBLIC void rtl_uString_internConvert(rtl_uString **newStr, const sal_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_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_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_Int32 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Char *second) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
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:1511
SAL_DLLPUBLIC void rtl_uString_newConcat(rtl_uString **newStr, rtl_uString *left, rtl_uString *right) SAL_THROW_EXTERN_C()
Create a new string that is the concatenation of two other strings.
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:110
bool equalsAscii(const sal_Char *asciiStr) const
Perform a comparison of two strings.
Definition: ustring.hxx:1124
~OUString()
Release the string data.
Definition: ustring.hxx:427
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_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:2082
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Decrement the reference count of a string.
OUString(rtl_uString *str, __sal_NoAcquire)
New OUString from OUString data without acquiring it.
Definition: ustring.hxx:189
sal_Int32 compareTo(const OUString &str, sal_Int32 maxLength) const
Compares two strings with a maximum count of characters.
Definition: ustring.hxx:726
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_newConcatUtf16L(rtl_uString **newString, rtl_uString *left, sal_Unicode const *right, sal_Int32 rightLength)
Create a new string that is the concatenation of two other strings.
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< 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:2380
#define OSTRING_TO_OUSTRING_CVTFLAGS
Definition: ustring.h:2120
static OUString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: ustring.hxx:3358
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.
OUString(const OUString &str)
New string from OUString.
Definition: ustring.hxx:147
Definition: stringutils.hxx:103
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.
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:489
sal_Int32 compareToIgnoreAsciiCase(const OUString &str) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:845
SAL_DLLPUBLIC void rtl_uString_assign(rtl_uString **str, rtl_uString *rightValue) SAL_THROW_EXTERN_C()
Assign a new value to a string.
SAL_DLLPUBLIC float rtl_ustr_toFloat(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a float.
SAL_DLLPUBLIC void rtl_uString_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 void rtl_uString_acquire(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Increment the reference count of a string.
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:2979
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:1425
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:2959
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.
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.
bool equalsIgnoreAsciiCaseAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1222
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.