LibreOffice
LibreOffice 6.0 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 <new>
28 #include <ostream>
29 #include <utility>
30 #include <string.h>
31 
32 #include "rtl/ustring.h"
33 #include "rtl/string.hxx"
34 #include "rtl/stringutils.hxx"
35 #include "rtl/textenc.h"
36 #include "sal/log.hxx"
37 
38 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
39 #include "config_global.h"
40 #include "rtl/stringconcat.hxx"
41 #endif
42 
43 #ifdef RTL_STRING_UNITTEST
44 extern bool rtl_string_unittest_invalid_conversion;
45 #endif
46 
47 // The unittest uses slightly different code to help check that the proper
48 // calls are made. The class is put into a different namespace to make
49 // sure the compiler generates a different (if generating also non-inline)
50 // copy of the function and does not merge them together. The class
51 // is "brought" into the proper rtl namespace by a typedef below.
52 #ifdef RTL_STRING_UNITTEST
53 #define rtl rtlunittest
54 #endif
55 
56 namespace rtl
57 {
58 
59 #ifdef RTL_STRING_UNITTEST
60 #undef rtl
61 #endif
62 
63 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
64 
72 struct SAL_WARN_UNUSED OUStringLiteral
73 {
74  template<typename T> constexpr OUStringLiteral(
75  T & literal,
76  typename libreoffice_internal::ConstCharArrayDetector<
77  T, libreoffice_internal::Dummy>::Type
78  = libreoffice_internal::Dummy()):
79  size(libreoffice_internal::ConstCharArrayDetector<T>::length),
80  data(
81  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal))
82  {
83 #if HAVE_CXX14_CONSTEXPR
84  assert(
85  libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
86 #endif
87  }
88 
89  int size;
90  const char* data;
91 };
92 
94 #endif
95 
96 /* ======================================================================= */
97 
121 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OUString
122 {
123 public:
125  rtl_uString * pData;
127 
132  {
133  pData = NULL;
134  rtl_uString_new( &pData );
135  }
136 
142  OUString( const OUString & str )
143  {
144  pData = str.pData;
145  rtl_uString_acquire( pData );
146  }
147 
148 #ifndef _MSC_VER // TODO?
149 #if defined LIBO_INTERNAL_ONLY
150 
156  OUString( OUString && str )
157  {
158  pData = str.pData;
159  str.pData = nullptr;
160  rtl_uString_new( &str.pData );
161  }
162 #endif
163 #endif
164 
170  OUString( rtl_uString * str )
171  {
172  pData = str;
173  rtl_uString_acquire( pData );
174  }
175 
184  OUString( rtl_uString * str, __sal_NoAcquire )
185  { pData = str; }
186 
192  explicit OUString( sal_Unicode value )
193  : pData (NULL)
194  {
195  rtl_uString_newFromStr_WithLength( &pData, &value, 1 );
196  }
197 
198 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
199  // Catch inadvertent conversions to the above ctor (but still allow
201  // construction from char literals):
202  OUString(int) = delete;
203  explicit OUString(char c):
204  OUString(sal_Unicode(static_cast<unsigned char>(c)))
205  {}
207 #endif
208 
214  OUString( const sal_Unicode * value )
215  {
216  pData = NULL;
217  rtl_uString_newFromStr( &pData, value );
218  }
219 
228  OUString( const sal_Unicode * value, sal_Int32 length )
229  {
230  pData = NULL;
231  rtl_uString_newFromStr_WithLength( &pData, value, length );
232  }
233 
249  template< typename T >
251  {
252  assert(
254  pData = NULL;
256  rtl_uString_new(&pData);
257  } else {
259  &pData,
261  literal),
263  }
264 #ifdef RTL_STRING_UNITTEST
265  rtl_string_unittest_const_literal = true;
266 #endif
267  }
268 
269 #if defined LIBO_INTERNAL_ONLY
270 
271  template<typename T> OUString(
272  T & literal,
274  T, libreoffice_internal::Dummy>::TypeUtf16
276  pData(nullptr)
277  {
279  rtl_uString_new(&pData);
280  } else {
282  &pData,
283  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
284  literal),
285  libreoffice_internal::ConstCharArrayDetector<T>::length);
286  }
287  }
288 #endif
289 
290 #ifdef RTL_STRING_UNITTEST
291 
295  template< typename T >
296  OUString( T&, typename libreoffice_internal::ExceptConstCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
297  {
298  pData = NULL;
299  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
300  rtl_string_unittest_invalid_conversion = true;
301  }
306  template< typename T >
307  OUString( const T&, typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
308  {
309  pData = NULL;
310  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
311  rtl_string_unittest_invalid_conversion = true;
312  }
313 #endif
314 
315 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
316 
332  OUString(OUStringLiteral literal): pData(NULL) {
333  rtl_uString_newFromLiteral(&pData, literal.data, literal.size, 0);
334  }
336 #endif
337 
352  OUString( const sal_Char * value, sal_Int32 length,
353  rtl_TextEncoding encoding,
354  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
355  {
356  pData = NULL;
357  rtl_string2UString( &pData, value, length, encoding, convertFlags );
358  if (pData == NULL) {
359  throw std::bad_alloc();
360  }
361  }
362 
379  explicit OUString(
380  sal_uInt32 const * codePoints, sal_Int32 codePointCount):
381  pData(NULL)
382  {
383  rtl_uString_newFromCodePoints(&pData, codePoints, codePointCount);
384  if (pData == NULL) {
385  throw std::bad_alloc();
386  }
387  }
388 
389 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
390 
394  template< typename T1, typename T2 >
395  OUString( OUStringConcat< T1, T2 >&& c )
396  {
397  const sal_Int32 l = c.length();
398  pData = rtl_uString_alloc( l );
399  if (l != 0)
400  {
401  sal_Unicode* end = c.addData( pData->buffer );
402  pData->length = l;
403  *end = '\0';
404  // TODO realloc in case pData->length is noticeably smaller than l?
405  }
406  }
407 #endif
408 
413  {
414  rtl_uString_release( pData );
415  }
416 
428  static OUString const & unacquired( rtl_uString * const * ppHandle )
429  { return * reinterpret_cast< OUString const * >( ppHandle ); }
430 
436  OUString & operator=( const OUString & str )
437  {
438  rtl_uString_assign( &pData, str.pData );
439  return *this;
440  }
441 
442 #ifndef _MSC_VER // TODO?
443 #if defined LIBO_INTERNAL_ONLY
444 
450  OUString & operator=( OUString && str )
451  {
452  rtl_uString_release( pData );
453  pData = str.pData;
454  str.pData = nullptr;
455  rtl_uString_new( &str.pData );
456  return *this;
457  }
458 #endif
459 #endif
460 
473  template< typename T >
475  {
476  assert(
479  rtl_uString_new(&pData);
480  } else {
482  &pData,
484  literal),
486  }
487  return *this;
488  }
489 
490 #if defined LIBO_INTERNAL_ONLY
491 
492  template<typename T>
493  typename
495  operator =(T & literal) {
497  rtl_uString_new(&pData);
498  } else {
500  &pData,
501  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
502  literal),
503  libreoffice_internal::ConstCharArrayDetector<T>::length);
504  }
505  return *this;
506  }
507 
509  OUString & operator =(OUStringLiteral const & literal) {
510  if (literal.size == 0) {
511  rtl_uString_new(&pData);
512  } else {
513  rtl_uString_newFromLiteral(&pData, literal.data, literal.size, 0);
514  }
515  return *this;
516  }
517 #endif
518 
526  OUString & operator+=( const OUString & str )
527 #if defined LIBO_INTERNAL_ONLY
528  &
529 #endif
530  {
531  rtl_uString* pNewData = NULL;
532  rtl_uString_newConcat( &pNewData, pData, str.pData );
533  if (pNewData == NULL) {
534  throw std::bad_alloc();
535  }
536  rtl_uString_assign(&pData, pNewData);
537  rtl_uString_release(pNewData);
538  return *this;
539  }
540 #if defined LIBO_INTERNAL_ONLY
541  void operator+=(OUString const &) && = delete;
542 #endif
543 
550  template<typename T>
552  operator +=(T & literal)
553 #if defined LIBO_INTERNAL_ONLY
554  &
555 #endif
556  {
557  assert(
560  &pData, pData,
563  return *this;
564  }
565 #if defined LIBO_INTERNAL_ONLY
566  template<typename T>
568  operator +=(T &) && = delete;
569 #endif
570 
571 #if defined LIBO_INTERNAL_ONLY
572 
573  template<typename T>
574  typename
576  operator +=(T & literal) & {
578  &pData, pData,
581  return *this;
582  }
583  template<typename T>
584  typename
585  libreoffice_internal::ConstCharArrayDetector<T, OUString &>::TypeUtf16
586  operator +=(T &) && = delete;
587 
589  OUString & operator +=(OUStringLiteral const & literal) & {
590  rtl_uString_newConcatAsciiL(&pData, pData, literal.data, literal.size);
591  return *this;
592  }
593  void operator +=(OUStringLiteral const &) && = delete;
594 #endif
595 
596 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
597 
601  template< typename T1, typename T2 >
602  OUString& operator+=( OUStringConcat< T1, T2 >&& c ) & {
603  sal_Int32 l = c.length();
604  if( l == 0 )
605  return *this;
606  l += pData->length;
607  rtl_uString_ensureCapacity( &pData, l );
608  sal_Unicode* end = c.addData( pData->buffer + pData->length );
609  *end = '\0';
610  pData->length = l;
611  return *this;
612  }
613  template<typename T1, typename T2> void operator +=(
614  OUStringConcat<T1, T2> &&) && = delete;
615 #endif
616 
621  void clear()
622  {
623  rtl_uString_new( &pData );
624  }
625 
634  sal_Int32 getLength() const { return pData->length; }
635 
644  bool isEmpty() const
645  {
646  return pData->length == 0;
647  }
648 
656  const sal_Unicode * getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
657 
667  sal_Unicode operator [](sal_Int32 index) const {
668  // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
669  assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
670  return getStr()[index];
671  }
672 
685  sal_Int32 compareTo( const OUString & str ) const
686  {
687  return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
688  str.pData->buffer, str.pData->length );
689  }
690 
706  sal_Int32 compareTo( const OUString & str, sal_Int32 maxLength ) const
707  {
708  return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
709  str.pData->buffer, str.pData->length, maxLength );
710  }
711 
724  sal_Int32 reverseCompareTo( const OUString & str ) const
725  {
726  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
727  str.pData->buffer, str.pData->length );
728  }
729 
735  template< typename T >
737  {
738  assert(
741  pData->buffer, pData->length,
744  }
745 
746 #if defined LIBO_INTERNAL_ONLY
747 
748  template<typename T>
749  typename
751  reverseCompareTo(T & literal) const {
753  pData->buffer, pData->length,
756  }
757 
759  sal_Int32 reverseCompareTo(OUStringLiteral const & literal) const {
761  pData->buffer, pData->length, literal.data, literal.size);
762  }
763 #endif
764 
776  bool equals( const OUString & str ) const
777  {
778  if ( pData->length != str.pData->length )
779  return false;
780  if ( pData == str.pData )
781  return true;
782  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
783  str.pData->buffer, str.pData->length ) == 0;
784  }
785 
800  bool equalsIgnoreAsciiCase( const OUString & str ) const
801  {
802  if ( pData->length != str.pData->length )
803  return false;
804  if ( pData == str.pData )
805  return true;
806  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
807  str.pData->buffer, str.pData->length ) == 0;
808  }
809 
825  sal_Int32 compareToIgnoreAsciiCase( const OUString & str ) const
826  {
827  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
828  str.pData->buffer, str.pData->length );
829  }
830 
831 
837  template< typename T >
839  {
840  assert(
842  return
843  (pData->length
846  pData->buffer, pData->length,
848  literal))
849  == 0);
850  }
851 
852 #if defined LIBO_INTERNAL_ONLY
853 
854  template<typename T>
856  equalsIgnoreAsciiCase(T & literal) const {
857  return
859  pData->buffer, pData->length,
861  literal),
863  == 0;
864  }
865 
867  bool equalsIgnoreAsciiCase(OUStringLiteral const & literal) const {
868  return pData->length == literal.size
870  pData->buffer, pData->length, literal.data)
871  == 0);
872  }
873 #endif
874 
890  bool match( const OUString & str, sal_Int32 fromIndex = 0 ) const
891  {
892  return rtl_ustr_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
893  str.pData->buffer, str.pData->length, str.pData->length ) == 0;
894  }
895 
901  template< typename T >
902  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
903  {
904  assert(
906  return
908  pData->buffer+fromIndex, pData->length-fromIndex,
910  literal),
912  == 0;
913  }
914 
915 #if defined LIBO_INTERNAL_ONLY
916 
917  template<typename T>
919  match(T & literal, sal_Int32 fromIndex = 0) const {
920  assert(fromIndex >= 0);
921  return
923  pData->buffer + fromIndex, pData->length - fromIndex,
925  literal),
928  == 0;
929  }
930 
932  bool match(OUStringLiteral const & literal, sal_Int32 fromIndex = 0) const {
933  return
935  pData->buffer + fromIndex, pData->length - fromIndex,
936  literal.data, literal.size)
937  == 0;
938  }
939 #endif
940 
959  bool matchIgnoreAsciiCase( const OUString & str, sal_Int32 fromIndex = 0 ) const
960  {
961  return rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
962  str.pData->buffer, str.pData->length,
963  str.pData->length ) == 0;
964  }
965 
971  template< typename T >
972  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
973  {
974  assert(
976  return
978  pData->buffer+fromIndex, pData->length-fromIndex,
980  literal),
982  == 0;
983  }
984 
985 #if defined LIBO_INTERNAL_ONLY
986 
987  template<typename T>
989  matchIgnoreAsciiCase(T & literal, sal_Int32 fromIndex = 0) const {
990  assert(fromIndex >= 0);
991  return
993  pData->buffer + fromIndex, pData->length - fromIndex,
995  literal),
998  == 0;
999  }
1000 
1002  bool matchIgnoreAsciiCase(
1003  OUStringLiteral const & literal, sal_Int32 fromIndex = 0) const
1004  {
1005  return
1007  pData->buffer+fromIndex, pData->length-fromIndex, literal.data,
1008  literal.size)
1009  == 0;
1010  }
1011 #endif
1012 
1029  sal_Int32 compareToAscii( const sal_Char* asciiStr ) const
1030  {
1031  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length, asciiStr );
1032  }
1033 
1057  "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
1058  sal_Int32 compareToAscii( const sal_Char * asciiStr, sal_Int32 maxLength ) const
1059  {
1060  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer, pData->length,
1061  asciiStr, maxLength );
1062  }
1063 
1083  sal_Int32 reverseCompareToAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
1084  {
1085  return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
1086  asciiStr, asciiStrLength );
1087  }
1088 
1104  bool equalsAscii( const sal_Char* asciiStr ) const
1105  {
1106  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length,
1107  asciiStr ) == 0;
1108  }
1109 
1127  bool equalsAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength ) const
1128  {
1129  if ( pData->length != asciiStrLength )
1130  return false;
1131 
1133  pData->buffer, asciiStr, asciiStrLength );
1134  }
1135 
1154  bool equalsIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const
1155  {
1156  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1157  }
1158 
1177  sal_Int32 compareToIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const
1178  {
1179  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr );
1180  }
1181 
1202  bool equalsIgnoreAsciiCaseAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
1203  {
1204  if ( pData->length != asciiStrLength )
1205  return false;
1206 
1207  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1208  }
1209 
1231  bool matchAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1232  {
1233  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1234  asciiStr, asciiStrLength ) == 0;
1235  }
1236 
1237  // This overload is left undefined, to detect calls of matchAsciiL that
1238  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1239  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1240  // platforms):
1241 #if SAL_TYPES_SIZEOFLONG == 8
1242  void matchAsciiL(char const *, sal_Int32, rtl_TextEncoding) const;
1243 #endif
1244 
1269  bool matchIgnoreAsciiCaseAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1270  {
1271  return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1272  asciiStr, asciiStrLength ) == 0;
1273  }
1274 
1275  // This overload is left undefined, to detect calls of
1276  // matchIgnoreAsciiCaseAsciiL that erroneously use
1277  // RTL_CONSTASCII_USTRINGPARAM instead of RTL_CONSTASCII_STRINGPARAM (but
1278  // would lead to ambiguities on 32 bit platforms):
1279 #if SAL_TYPES_SIZEOFLONG == 8
1280  void matchIgnoreAsciiCaseAsciiL(char const *, sal_Int32, rtl_TextEncoding)
1281  const;
1282 #endif
1283 
1298  bool startsWith(OUString const & str, OUString * rest = NULL) const {
1299  bool b = match(str);
1300  if (b && rest != NULL) {
1301  *rest = copy(str.getLength());
1302  }
1303  return b;
1304  }
1305 
1311  template< typename T >
1313  T & literal, OUString * rest = NULL) const
1314  {
1315  assert(
1317  bool b
1319  <= sal_uInt32(pData->length))
1321  pData->buffer,
1323  literal),
1325  if (b && rest != NULL) {
1326  *rest = copy(
1328  }
1329  return b;
1330  }
1331 
1332 #if defined LIBO_INTERNAL_ONLY
1333 
1334  template<typename T>
1336  startsWith(T & literal, OUString * rest = nullptr) const {
1337  bool b
1339  <= sal_uInt32(pData->length))
1341  pData->buffer,
1344  literal),
1346  == 0);
1347  if (b && rest != nullptr) {
1348  *rest = copy(
1350  }
1351  return b;
1352  }
1353 
1355  bool startsWith(OUStringLiteral const & literal, OUString * rest = nullptr)
1356  const
1357  {
1358  bool b = literal.size <= pData->length
1360  pData->buffer, literal.data, literal.size);
1361  if (b && rest != nullptr) {
1362  *rest = copy(literal.size);
1363  }
1364  return b;
1365  }
1366 #endif
1367 
1388  bool startsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL)
1389  const
1390  {
1391  bool b = matchIgnoreAsciiCase(str);
1392  if (b && rest != NULL) {
1393  *rest = copy(str.getLength());
1394  }
1395  return b;
1396  }
1397 
1403  template< typename T >
1405  startsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1406  {
1407  assert(
1409  bool b
1411  pData->buffer,
1414  literal),
1416  == 0);
1417  if (b && rest != NULL) {
1418  *rest = copy(
1420  }
1421  return b;
1422  }
1423 
1424 #if defined LIBO_INTERNAL_ONLY
1425 
1426  template<typename T>
1428  startsWithIgnoreAsciiCase(T & literal, OUString * rest = nullptr) const {
1429  bool b
1431  <= sal_uInt32(pData->length))
1433  pData->buffer,
1436  literal),
1438  == 0);
1439  if (b && rest != nullptr) {
1440  *rest = copy(
1442  }
1443  return b;
1444  }
1445 
1447  bool startsWithIgnoreAsciiCase(
1448  OUStringLiteral const & literal, OUString * rest = nullptr) const
1449  {
1450  bool b
1452  pData->buffer, literal.size, literal.data, literal.size)
1453  == 0);
1454  if (b && rest != nullptr) {
1455  *rest = copy(literal.size);
1456  }
1457  return b;
1458  }
1459 #endif
1460 
1475  bool endsWith(OUString const & str, OUString * rest = NULL) const {
1476  bool b = str.getLength() <= getLength()
1477  && match(str, getLength() - str.getLength());
1478  if (b && rest != NULL) {
1479  *rest = copy(0, getLength() - str.getLength());
1480  }
1481  return b;
1482  }
1483 
1489  template< typename T >
1491  endsWith(T & literal, OUString * rest = NULL) const
1492  {
1493  assert(
1495  bool b
1497  <= sal_uInt32(pData->length))
1499  (pData->buffer + pData->length
1502  literal),
1504  if (b && rest != NULL) {
1505  *rest = copy(
1506  0,
1507  (getLength()
1509  }
1510  return b;
1511  }
1512 
1513 #if defined LIBO_INTERNAL_ONLY
1514 
1515  template<typename T>
1517  endsWith(T & literal, OUString * rest = nullptr) const {
1518  bool b
1520  <= sal_uInt32(pData->length))
1522  (pData->buffer + pData->length
1526  literal),
1528  == 0);
1529  if (b && rest != nullptr) {
1530  *rest = copy(
1531  0,
1532  (getLength()
1534  }
1535  return b;
1536  }
1537 
1539  bool endsWith(OUStringLiteral const & literal, OUString * rest = nullptr)
1540  const
1541  {
1542  bool b = literal.size <= pData->length
1544  pData->buffer + pData->length - literal.size,
1545  literal.data, literal.size);
1546  if (b && rest != nullptr) {
1547  *rest = copy(0, (getLength() - literal.size));
1548  }
1549  return b;
1550  }
1551 #endif
1552 
1564  bool endsWithAsciiL(char const * asciiStr, sal_Int32 asciiStrLength)
1565  const
1566  {
1567  return asciiStrLength <= pData->length
1569  pData->buffer + pData->length - asciiStrLength, asciiStr,
1570  asciiStrLength);
1571  }
1572 
1593  bool endsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL) const
1594  {
1595  bool b = str.getLength() <= getLength()
1596  && matchIgnoreAsciiCase(str, getLength() - str.getLength());
1597  if (b && rest != NULL) {
1598  *rest = copy(0, getLength() - str.getLength());
1599  }
1600  return b;
1601  }
1602 
1608  template< typename T >
1610  endsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1611  {
1612  assert(
1614  bool b
1616  <= sal_uInt32(pData->length))
1618  (pData->buffer + pData->length
1622  literal),
1624  == 0);
1625  if (b && rest != NULL) {
1626  *rest = copy(
1627  0,
1628  (getLength()
1630  }
1631  return b;
1632  }
1633 
1634 #if defined LIBO_INTERNAL_ONLY
1635 
1636  template<typename T>
1638  endsWithIgnoreAsciiCase(T & literal, OUString * rest = nullptr) const {
1639  bool b
1641  <= sal_uInt32(pData->length))
1643  (pData->buffer + pData->length
1647  literal),
1649  == 0);
1650  if (b && rest != nullptr) {
1651  *rest = copy(
1652  0,
1653  (getLength()
1655  }
1656  return b;
1657  }
1658 
1660  bool endsWithIgnoreAsciiCase(
1661  OUStringLiteral const & literal, OUString * rest = nullptr) const
1662  {
1663  bool b = literal.size <= pData->length
1665  pData->buffer + pData->length - literal.size,
1666  literal.size, literal.data, literal.size)
1667  == 0);
1668  if (b && rest != nullptr) {
1669  *rest = copy(0, getLength() - literal.size);
1670  }
1671  return b;
1672  }
1673 #endif
1674 
1686  char const * asciiStr, sal_Int32 asciiStrLength) const
1687  {
1688  return asciiStrLength <= pData->length
1690  pData->buffer + pData->length - asciiStrLength,
1691  asciiStrLength, asciiStr, asciiStrLength)
1692  == 0);
1693  }
1694 
1695  friend bool operator == ( const OUString& rStr1, const OUString& rStr2 )
1696  { return rStr1.equals(rStr2); }
1697  friend bool operator == ( const OUString& rStr1, const sal_Unicode * pStr2 )
1698  { return rStr1.compareTo( pStr2 ) == 0; }
1699  friend bool operator == ( const sal_Unicode * pStr1, const OUString& rStr2 )
1700  { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
1701 
1702  friend bool operator != ( const OUString& rStr1, const OUString& rStr2 )
1703  { return !(operator == ( rStr1, rStr2 )); }
1704  friend bool operator != ( const OUString& rStr1, const sal_Unicode * pStr2 )
1705  { return !(operator == ( rStr1, pStr2 )); }
1706  friend bool operator != ( const sal_Unicode * pStr1, const OUString& rStr2 )
1707  { return !(operator == ( pStr1, rStr2 )); }
1708 
1709  friend bool operator < ( const OUString& rStr1, const OUString& rStr2 )
1710  { return rStr1.compareTo( rStr2 ) < 0; }
1711  friend bool operator > ( const OUString& rStr1, const OUString& rStr2 )
1712  { return rStr1.compareTo( rStr2 ) > 0; }
1713  friend bool operator <= ( const OUString& rStr1, const OUString& rStr2 )
1714  { return rStr1.compareTo( rStr2 ) <= 0; }
1715  friend bool operator >= ( const OUString& rStr1, const OUString& rStr2 )
1716  { return rStr1.compareTo( rStr2 ) >= 0; }
1717 
1725  template< typename T >
1727  {
1728  assert(
1730  return rString.equalsAsciiL(
1733  }
1741  template< typename T >
1743  {
1744  assert(
1746  return rString.equalsAsciiL(
1749  }
1757  template< typename T >
1759  {
1760  assert(
1762  return !rString.equalsAsciiL(
1765  }
1773  template< typename T >
1775  {
1776  assert(
1778  return !rString.equalsAsciiL(
1781  }
1782 
1783 #if defined LIBO_INTERNAL_ONLY
1784 
1785  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1786  operator ==(OUString & string, T & literal) {
1787  return
1789  string.pData->buffer, string.pData->length,
1791  literal),
1793  == 0;
1794  }
1796  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1797  operator ==(T & literal, OUString & string) {
1798  return
1800  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1801  literal),
1802  libreoffice_internal::ConstCharArrayDetector<T>::length,
1803  string.pData->buffer, string.pData->length)
1804  == 0;
1805  }
1807  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1808  operator !=(OUString & string, T & literal) {
1809  return
1811  string.pData->buffer, string.pData->length,
1812  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1813  literal),
1814  libreoffice_internal::ConstCharArrayDetector<T>::length)
1815  != 0;
1816  }
1818  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1819  operator !=(T & literal, OUString & string) {
1820  return
1822  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1823  literal),
1824  libreoffice_internal::ConstCharArrayDetector<T>::length,
1825  string.pData->buffer, string.pData->length)
1826  != 0;
1827  }
1828 #endif
1829 
1830 #if defined LIBO_INTERNAL_ONLY
1831 
1833  /* Comparison between OUString and OUStringLiteral.
1834 
1835  @since LibreOffice 5.0
1836  */
1837 
1838  friend bool operator ==(OUString const & lhs, OUStringLiteral const & rhs) {
1839  return lhs.equalsAsciiL(rhs.data, rhs.size);
1840  }
1841 
1842  friend bool operator !=(OUString const & lhs, OUStringLiteral const & rhs) {
1843  return !lhs.equalsAsciiL(rhs.data, rhs.size);
1844  }
1845 
1846  friend bool operator <(OUString const & lhs, OUStringLiteral const & rhs) {
1847  return
1849  lhs.pData->buffer, lhs.pData->length, rhs.data))
1850  < 0;
1851  }
1852 
1853  friend bool operator <=(OUString const & lhs, OUStringLiteral const & rhs) {
1854  return
1856  lhs.pData->buffer, lhs.pData->length, rhs.data))
1857  <= 0;
1858  }
1859 
1860  friend bool operator >(OUString const & lhs, OUStringLiteral const & rhs) {
1861  return
1863  lhs.pData->buffer, lhs.pData->length, rhs.data))
1864  > 0;
1865  }
1866 
1867  friend bool operator >=(OUString const & lhs, OUStringLiteral const & rhs) {
1868  return
1870  lhs.pData->buffer, lhs.pData->length, rhs.data))
1871  >= 0;
1872  }
1873 
1874  friend bool operator ==(OUStringLiteral const & lhs, OUString const & rhs) {
1875  return rhs.equalsAsciiL(lhs.data, lhs.size);
1876  }
1877 
1878  friend bool operator !=(OUStringLiteral const & lhs, OUString const & rhs) {
1879  return !rhs.equalsAsciiL(lhs.data, lhs.size);
1880  }
1881 
1882  friend bool operator <(OUStringLiteral const & lhs, OUString const & rhs) {
1883  return
1885  rhs.pData->buffer, rhs.pData->length, lhs.data))
1886  >= 0;
1887  }
1888 
1889  friend bool operator <=(OUStringLiteral const & lhs, OUString const & rhs) {
1890  return
1892  rhs.pData->buffer, rhs.pData->length, lhs.data))
1893  > 0;
1894  }
1895 
1896  friend bool operator >(OUStringLiteral const & lhs, OUString const & rhs) {
1897  return
1899  rhs.pData->buffer, rhs.pData->length, lhs.data))
1900  <= 0;
1901  }
1902 
1903  friend bool operator >=(OUStringLiteral const & lhs, OUString const & rhs) {
1904  return
1906  rhs.pData->buffer, rhs.pData->length, lhs.data))
1907  < 0;
1908  }
1909 
1911 #endif
1912 
1920  sal_Int32 hashCode() const
1921  {
1922  return rtl_ustr_hashCode_WithLength( pData->buffer, pData->length );
1923  }
1924 
1938  sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
1939  {
1940  sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1941  return (ret < 0 ? ret : ret+fromIndex);
1942  }
1943 
1953  sal_Int32 lastIndexOf( sal_Unicode ch ) const
1954  {
1955  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1956  }
1957 
1970  sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
1971  {
1972  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1973  }
1974 
1990  sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
1991  {
1992  sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1993  str.pData->buffer, str.pData->length );
1994  return (ret < 0 ? ret : ret+fromIndex);
1995  }
1996 
2002  template< typename T >
2003  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
2004  {
2005  assert(
2007  sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
2008  pData->buffer + fromIndex, pData->length - fromIndex,
2011  return n < 0 ? n : n + fromIndex;
2012  }
2013 
2014 #if defined LIBO_INTERNAL_ONLY
2015 
2016  template<typename T>
2017  typename
2019  indexOf(T & literal, sal_Int32 fromIndex = 0) const {
2020  assert(fromIndex >= 0);
2022  pData->buffer + fromIndex, pData->length - fromIndex,
2025  return n < 0 ? n : n + fromIndex;
2026  }
2027 
2029  sal_Int32 indexOf(OUStringLiteral const & literal, sal_Int32 fromIndex = 0)
2030  const
2031  {
2032  sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
2033  pData->buffer + fromIndex, pData->length - fromIndex, literal.data,
2034  literal.size);
2035  return n < 0 ? n : n + fromIndex;
2036  }
2037 #endif
2038 
2062  sal_Int32 indexOfAsciiL(
2063  char const * str, sal_Int32 len, sal_Int32 fromIndex = 0) const
2064  {
2065  sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
2066  pData->buffer + fromIndex, pData->length - fromIndex, str, len);
2067  return ret < 0 ? ret : ret + fromIndex;
2068  }
2069 
2070  // This overload is left undefined, to detect calls of indexOfAsciiL that
2071  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
2072  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
2073  // platforms):
2074 #if SAL_TYPES_SIZEOFLONG == 8
2075  void indexOfAsciiL(char const *, sal_Int32 len, rtl_TextEncoding) const;
2076 #endif
2077 
2093  sal_Int32 lastIndexOf( const OUString & str ) const
2094  {
2095  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
2096  str.pData->buffer, str.pData->length );
2097  }
2098 
2116  sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
2117  {
2118  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
2119  str.pData->buffer, str.pData->length );
2120  }
2121 
2127  template< typename T >
2129  {
2130  assert(
2133  pData->buffer, pData->length,
2136  }
2137 
2138 #if defined LIBO_INTERNAL_ONLY
2139 
2140  template<typename T>
2141  typename
2143  lastIndexOf(T & literal) const {
2145  pData->buffer, pData->length,
2148  }
2149 
2151  sal_Int32 lastIndexOf(OUStringLiteral const & literal) const {
2153  pData->buffer, pData->length, literal.data, literal.size);
2154  }
2155 #endif
2156 
2176  sal_Int32 lastIndexOfAsciiL(char const * str, sal_Int32 len) const
2177  {
2179  pData->buffer, pData->length, str, len);
2180  }
2181 
2192  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex ) const
2193  {
2194  rtl_uString *pNew = NULL;
2195  rtl_uString_newFromSubString( &pNew, pData, beginIndex, getLength() - beginIndex );
2196  return OUString( pNew, SAL_NO_ACQUIRE );
2197  }
2198 
2211  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const
2212  {
2213  rtl_uString *pNew = NULL;
2214  rtl_uString_newFromSubString( &pNew, pData, beginIndex, count );
2215  return OUString( pNew, SAL_NO_ACQUIRE );
2216  }
2217 
2227  {
2228  rtl_uString* pNew = NULL;
2229  rtl_uString_newConcat( &pNew, pData, str.pData );
2230  return OUString( pNew, SAL_NO_ACQUIRE );
2231  }
2232 
2233 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2234  friend OUString operator+( const OUString& rStr1, const OUString& rStr2 )
2235  {
2236  return rStr1.concat( rStr2 );
2237  }
2238 #endif
2239 
2253  SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const
2254  {
2255  rtl_uString* pNew = NULL;
2256  rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
2257  return OUString( pNew, SAL_NO_ACQUIRE );
2258  }
2259 
2274  {
2275  rtl_uString* pNew = NULL;
2276  rtl_uString_newReplace( &pNew, pData, oldChar, newChar );
2277  return OUString( pNew, SAL_NO_ACQUIRE );
2278  }
2279 
2299  OUString const & from, OUString const & to, sal_Int32 * index = NULL) const
2300  {
2301  rtl_uString * s = NULL;
2302  sal_Int32 i = 0;
2304  &s, pData, from.pData, to.pData, index == NULL ? &i : index);
2305  return OUString(s, SAL_NO_ACQUIRE);
2306  }
2307 
2326  template< typename T >
2328  sal_Int32 * index = NULL) const
2329  {
2331  rtl_uString * s = NULL;
2332  sal_Int32 i = 0;
2334  &s, pData,
2337  index == NULL ? &i : index);
2338  return OUString(s, SAL_NO_ACQUIRE);
2339  }
2340 
2359  template< typename T >
2361  sal_Int32 * index = NULL) const
2362  {
2364  rtl_uString * s = NULL;
2365  sal_Int32 i = 0;
2367  &s, pData, from.pData,
2370  index == NULL ? &i : index);
2371  return OUString(s, SAL_NO_ACQUIRE);
2372  }
2373 
2392  template< typename T1, typename T2 >
2394  replaceFirst( T1& from, T2& to, sal_Int32 * index = NULL) const
2395  {
2398  rtl_uString * s = NULL;
2399  sal_Int32 i = 0;
2401  &s, pData,
2406  index == NULL ? &i : index);
2407  return OUString(s, SAL_NO_ACQUIRE);
2408  }
2409 
2410 #if defined LIBO_INTERNAL_ONLY
2411 
2412  template<typename T> SAL_WARN_UNUSED_RESULT
2413  typename
2415  replaceFirst(T & from, OUString const & to, sal_Int32 * index = nullptr)
2416  const
2417  {
2418  rtl_uString * s = nullptr;
2419  sal_Int32 i = 0;
2421  &s, pData,
2424  to.pData->buffer, to.pData->length, index == nullptr ? &i : index);
2425  if (s == nullptr) {
2426  throw std::bad_alloc();
2427  // should be std::length_error if resulting would be too large
2428  }
2429  return OUString(s, SAL_NO_ACQUIRE);
2430  }
2432  template<typename T> SAL_WARN_UNUSED_RESULT
2433  typename
2434  libreoffice_internal::ConstCharArrayDetector<T, OUString>::TypeUtf16
2435  replaceFirst(OUString const & from, T & to, sal_Int32 * index = nullptr)
2436  const
2437  {
2438  rtl_uString * s = nullptr;
2439  sal_Int32 i = 0;
2441  &s, pData, from.pData->buffer, from.pData->length,
2442  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(to),
2443  libreoffice_internal::ConstCharArrayDetector<T>::length,
2444  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 T1, typename T2> SAL_WARN_UNUSED_RESULT
2453  typename
2454  libreoffice_internal::ConstCharArrayDetector<
2455  T1,
2456  typename libreoffice_internal::ConstCharArrayDetector<
2457  T2, OUString>::TypeUtf16
2458  >::TypeUtf16
2459  replaceFirst(T1 & from, T2 & to, sal_Int32 * index = nullptr) const {
2460  rtl_uString * s = nullptr;
2461  sal_Int32 i = 0;
2463  &s, pData,
2464  libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2465  libreoffice_internal::ConstCharArrayDetector<T1>::length,
2466  libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2467  libreoffice_internal::ConstCharArrayDetector<T2>::length,
2468  index == nullptr ? &i : index);
2469  if (s == nullptr) {
2470  throw std::bad_alloc();
2471  // should be std::length_error if resulting would be too large
2472  }
2473  return OUString(s, SAL_NO_ACQUIRE);
2474  }
2476  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2477  typename
2478  libreoffice_internal::ConstCharArrayDetector<
2479  T1,
2480  typename libreoffice_internal::ConstCharArrayDetector<
2481  T2, OUString>::Type
2482  >::TypeUtf16
2483  replaceFirst(T1 & from, T2 & to, sal_Int32 * index = nullptr) const {
2484  rtl_uString * s = nullptr;
2485  sal_Int32 i = 0;
2487  &s, pData,
2488  libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2489  libreoffice_internal::ConstCharArrayDetector<T1>::length,
2490  libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2491  libreoffice_internal::ConstCharArrayDetector<T2>::length,
2492  index == nullptr ? &i : index);
2493  if (s == nullptr) {
2494  throw std::bad_alloc();
2495  // should be std::length_error if resulting would be too large
2496  }
2497  return OUString(s, SAL_NO_ACQUIRE);
2498  }
2500  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2501  typename
2502  libreoffice_internal::ConstCharArrayDetector<
2503  T1,
2504  typename libreoffice_internal::ConstCharArrayDetector<
2505  T2, OUString>::TypeUtf16
2506  >::Type
2507  replaceFirst(T1 & from, T2 & to, sal_Int32 * index = nullptr) const {
2508  rtl_uString * s = nullptr;
2509  sal_Int32 i = 0;
2511  &s, pData,
2512  libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2513  libreoffice_internal::ConstCharArrayDetector<T1>::length,
2514  libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2515  libreoffice_internal::ConstCharArrayDetector<T2>::length,
2516  index == nullptr ? &i : index);
2517  if (s == nullptr) {
2518  throw std::bad_alloc();
2519  // should be std::length_error if resulting would be too large
2520  }
2521  return OUString(s, SAL_NO_ACQUIRE);
2522  }
2523 
2525  SAL_WARN_UNUSED_RESULT OUString replaceFirst(
2526  OUStringLiteral const & from, OUString const & to,
2527  sal_Int32 * index = nullptr) const
2528  {
2529  rtl_uString * s = nullptr;
2530  sal_Int32 i = 0;
2532  &s, pData, from.data, from.size, to.pData,
2533  index == nullptr ? &i : index);
2534  return OUString(s, SAL_NO_ACQUIRE);
2535  }
2537  SAL_WARN_UNUSED_RESULT OUString replaceFirst(
2538  OUString const & from, OUStringLiteral const & to,
2539  sal_Int32 * index = nullptr) const
2540  {
2541  rtl_uString * s = nullptr;
2542  sal_Int32 i = 0;
2544  &s, pData, from.pData, to.data, to.size,
2545  index == nullptr ? &i : index);
2546  return OUString(s, SAL_NO_ACQUIRE);
2547  }
2549  SAL_WARN_UNUSED_RESULT OUString replaceFirst(
2550  OUStringLiteral const & from, OUStringLiteral const & to,
2551  sal_Int32 * index = nullptr) const
2552  {
2553  rtl_uString * s = nullptr;
2554  sal_Int32 i = 0;
2556  &s, pData, from.data, from.size, to.data, to.size,
2557  index == nullptr ? &i : index);
2558  return OUString(s, SAL_NO_ACQUIRE);
2559  }
2561  template<typename T> SAL_WARN_UNUSED_RESULT
2562  typename libreoffice_internal::ConstCharArrayDetector<T, OUString >::Type
2563  replaceFirst(
2564  OUStringLiteral const & from, T & to, sal_Int32 * index = nullptr) const
2565  {
2566  assert(libreoffice_internal::ConstCharArrayDetector<T>::isValid(to));
2567  rtl_uString * s = nullptr;
2568  sal_Int32 i = 0;
2570  &s, pData, from.data, from.size,
2571  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(to),
2572  libreoffice_internal::ConstCharArrayDetector<T>::length,
2573  index == nullptr ? &i : index);
2574  return OUString(s, SAL_NO_ACQUIRE);
2575  }
2577  template<typename T> SAL_WARN_UNUSED_RESULT
2578  typename libreoffice_internal::ConstCharArrayDetector<T, OUString >::Type
2579  replaceFirst(
2580  T & from, OUStringLiteral const & to, sal_Int32 * index = nullptr) const
2581  {
2582  assert(libreoffice_internal::ConstCharArrayDetector<T>::isValid(from));
2583  rtl_uString * s = nullptr;
2584  sal_Int32 i = 0;
2586  &s, pData,
2587  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(from),
2588  libreoffice_internal::ConstCharArrayDetector<T>::length, to.data,
2589  to.size, index == nullptr ? &i : index);
2590  return OUString(s, SAL_NO_ACQUIRE);
2591  }
2593  template<typename T> SAL_WARN_UNUSED_RESULT
2594  typename
2595  libreoffice_internal::ConstCharArrayDetector<T, OUString >::TypeUtf16
2596  replaceFirst(
2597  OUStringLiteral const & from, T & to, sal_Int32 * index = nullptr) const
2598  {
2599  assert(libreoffice_internal::ConstCharArrayDetector<T>::isValid(to));
2600  rtl_uString * s = nullptr;
2601  sal_Int32 i = 0;
2603  &s, pData, from.data, from.size,
2604  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(to),
2605  libreoffice_internal::ConstCharArrayDetector<T>::length,
2606  index == nullptr ? &i : index);
2607  return OUString(s, SAL_NO_ACQUIRE);
2608  }
2610  template<typename T> SAL_WARN_UNUSED_RESULT
2611  typename
2612  libreoffice_internal::ConstCharArrayDetector<T, OUString >::TypeUtf16
2613  replaceFirst(
2614  T & from, OUStringLiteral const & to, sal_Int32 * index = nullptr) const
2615  {
2616  assert(libreoffice_internal::ConstCharArrayDetector<T>::isValid(from));
2617  rtl_uString * s = nullptr;
2618  sal_Int32 i = 0;
2620  &s, pData,
2621  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(from),
2622  libreoffice_internal::ConstCharArrayDetector<T>::length, to.data,
2623  to.size, index == nullptr ? &i : index);
2624  return OUString(s, SAL_NO_ACQUIRE);
2625  }
2626 #endif
2627 
2644  OUString const & from, OUString const & to, sal_Int32 fromIndex = 0) const
2645  {
2646  rtl_uString * s = NULL;
2647  rtl_uString_newReplaceAllFromIndex(&s, pData, from.pData, to.pData, fromIndex);
2648  return OUString(s, SAL_NO_ACQUIRE);
2649  }
2650 
2664  template< typename T >
2666  {
2668  rtl_uString * s = NULL;
2670  &s, pData,
2673  return OUString(s, SAL_NO_ACQUIRE);
2674  }
2675 
2689  template< typename T >
2691  {
2693  rtl_uString * s = NULL;
2695  &s, pData, from.pData,
2698  return OUString(s, SAL_NO_ACQUIRE);
2699  }
2700 
2714  template< typename T1, typename T2 >
2716  replaceAll( T1& from, T2& to ) const
2717  {
2720  rtl_uString * s = NULL;
2722  &s, pData,
2727  return OUString(s, SAL_NO_ACQUIRE);
2728  }
2729 
2730 #if defined LIBO_INTERNAL_ONLY
2731 
2732  template<typename T> SAL_WARN_UNUSED_RESULT
2733  typename
2735  replaceAll(T & from, OUString const & to) const {
2736  rtl_uString * s = nullptr;
2738  &s, pData,
2741  to.pData->buffer, to.pData->length);
2742  if (s == nullptr) {
2743  throw std::bad_alloc();
2744  // should be std::length_error if resulting would be too large
2745  }
2746  return OUString(s, SAL_NO_ACQUIRE);
2747  }
2749  template<typename T> SAL_WARN_UNUSED_RESULT
2750  typename
2751  libreoffice_internal::ConstCharArrayDetector<T, OUString>::TypeUtf16
2752  replaceAll(OUString const & from, T & to) const {
2753  rtl_uString * s = nullptr;
2755  &s, pData, from.pData->buffer, from.pData->length,
2756  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(to),
2757  libreoffice_internal::ConstCharArrayDetector<T>::length);
2758  if (s == nullptr) {
2759  throw std::bad_alloc();
2760  // should be std::length_error if resulting would be too large
2761  }
2762  return OUString(s, SAL_NO_ACQUIRE);
2763  }
2765  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2766  typename
2767  libreoffice_internal::ConstCharArrayDetector<
2768  T1,
2769  typename libreoffice_internal::ConstCharArrayDetector<
2770  T2, OUString>::TypeUtf16
2771  >::TypeUtf16
2772  replaceAll(T1 & from, T2 & to) const {
2773  rtl_uString * s = nullptr;
2775  &s, pData,
2776  libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2777  libreoffice_internal::ConstCharArrayDetector<T1>::length,
2778  libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2779  libreoffice_internal::ConstCharArrayDetector<T2>::length);
2780  if (s == nullptr) {
2781  throw std::bad_alloc();
2782  // should be std::length_error if resulting would be too large
2783  }
2784  return OUString(s, SAL_NO_ACQUIRE);
2785  }
2787  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2788  typename
2789  libreoffice_internal::ConstCharArrayDetector<
2790  T1,
2791  typename libreoffice_internal::ConstCharArrayDetector<
2792  T2, OUString>::Type
2793  >::TypeUtf16
2794  replaceAll(T1 & from, T2 & to) const {
2795  rtl_uString * s = nullptr;
2797  &s, pData,
2798  libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2799  libreoffice_internal::ConstCharArrayDetector<T1>::length,
2800  libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2801  libreoffice_internal::ConstCharArrayDetector<T2>::length);
2802  if (s == nullptr) {
2803  throw std::bad_alloc();
2804  // should be std::length_error if resulting would be too large
2805  }
2806  return OUString(s, SAL_NO_ACQUIRE);
2807  }
2809  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2810  typename
2811  libreoffice_internal::ConstCharArrayDetector<
2812  T1,
2813  typename libreoffice_internal::ConstCharArrayDetector<
2814  T2, OUString>::TypeUtf16
2815  >::Type
2816  replaceAll(T1 & from, T2 & to) const {
2817  rtl_uString * s = nullptr;
2819  &s, pData,
2820  libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2821  libreoffice_internal::ConstCharArrayDetector<T1>::length,
2822  libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2823  libreoffice_internal::ConstCharArrayDetector<T2>::length);
2824  if (s == nullptr) {
2825  throw std::bad_alloc();
2826  // should be std::length_error if resulting would be too large
2827  }
2828  return OUString(s, SAL_NO_ACQUIRE);
2829  }
2830 
2832  SAL_WARN_UNUSED_RESULT OUString replaceAll(
2833  OUStringLiteral const & from, OUString const & to) const
2834  {
2835  rtl_uString * s = nullptr;
2837  &s, pData, from.data, from.size, to.pData);
2838  return OUString(s, SAL_NO_ACQUIRE);
2839  }
2841  SAL_WARN_UNUSED_RESULT OUString replaceAll(
2842  OUString const & from, OUStringLiteral const & to) const
2843  {
2844  rtl_uString * s = nullptr;
2846  &s, pData, from.pData, to.data, to.size);
2847  return OUString(s, SAL_NO_ACQUIRE);
2848  }
2850  SAL_WARN_UNUSED_RESULT OUString replaceAll(
2851  OUStringLiteral const & from, OUStringLiteral const & to) const
2852  {
2853  rtl_uString * s = nullptr;
2855  &s, pData, from.data, from.size, to.data, to.size);
2856  return OUString(s, SAL_NO_ACQUIRE);
2857  }
2859  template<typename T> SAL_WARN_UNUSED_RESULT
2860  typename libreoffice_internal::ConstCharArrayDetector<T, OUString >::Type
2861  replaceAll(OUStringLiteral const & from, T & to) const {
2862  assert(libreoffice_internal::ConstCharArrayDetector<T>::isValid(to));
2863  rtl_uString * s = nullptr;
2865  &s, pData, from.data, from.size,
2866  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(to),
2867  libreoffice_internal::ConstCharArrayDetector<T>::length);
2868  return OUString(s, SAL_NO_ACQUIRE);
2869  }
2871  template<typename T> SAL_WARN_UNUSED_RESULT
2872  typename libreoffice_internal::ConstCharArrayDetector<T, OUString >::Type
2873  replaceAll(T & from, OUStringLiteral const & to) const {
2874  assert(libreoffice_internal::ConstCharArrayDetector<T>::isValid(from));
2875  rtl_uString * s = nullptr;
2877  &s, pData,
2878  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(from),
2879  libreoffice_internal::ConstCharArrayDetector<T>::length, to.data,
2880  to.size);
2881  return OUString(s, SAL_NO_ACQUIRE);
2882  }
2884  template<typename T> SAL_WARN_UNUSED_RESULT
2885  typename
2886  libreoffice_internal::ConstCharArrayDetector<T, OUString >::TypeUtf16
2887  replaceAll(OUStringLiteral const & from, T & to) const {
2888  assert(libreoffice_internal::ConstCharArrayDetector<T>::isValid(to));
2889  rtl_uString * s = nullptr;
2891  &s, pData, from.data, from.size,
2892  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(to),
2893  libreoffice_internal::ConstCharArrayDetector<T>::length);
2894  return OUString(s, SAL_NO_ACQUIRE);
2895  }
2897  template<typename T> SAL_WARN_UNUSED_RESULT
2898  typename
2899  libreoffice_internal::ConstCharArrayDetector<T, OUString >::TypeUtf16
2900  replaceAll(T & from, OUStringLiteral const & to) const {
2901  assert(libreoffice_internal::ConstCharArrayDetector<T>::isValid(from));
2902  rtl_uString * s = nullptr;
2904  &s, pData,
2905  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(from),
2906  libreoffice_internal::ConstCharArrayDetector<T>::length, to.data,
2907  to.size);
2908  return OUString(s, SAL_NO_ACQUIRE);
2909  }
2910 #endif
2911 
2923  {
2924  rtl_uString* pNew = NULL;
2925  rtl_uString_newToAsciiLowerCase( &pNew, pData );
2926  return OUString( pNew, SAL_NO_ACQUIRE );
2927  }
2928 
2940  {
2941  rtl_uString* pNew = NULL;
2942  rtl_uString_newToAsciiUpperCase( &pNew, pData );
2943  return OUString( pNew, SAL_NO_ACQUIRE );
2944  }
2945 
2960  {
2961  rtl_uString* pNew = NULL;
2962  rtl_uString_newTrim( &pNew, pData );
2963  return OUString( pNew, SAL_NO_ACQUIRE );
2964  }
2965 
2990  OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const
2991  {
2992  rtl_uString * pNew = NULL;
2993  index = rtl_uString_getToken( &pNew, pData, token, cTok, index );
2994  return OUString( pNew, SAL_NO_ACQUIRE );
2995  }
2996 
3010  OUString getToken(sal_Int32 count, sal_Unicode separator) const {
3011  sal_Int32 n = 0;
3012  return getToken(count, separator, n);
3013  }
3014 
3023  bool toBoolean() const
3024  {
3025  return rtl_ustr_toBoolean( pData->buffer );
3026  }
3027 
3035  {
3036  return pData->buffer[0];
3037  }
3038 
3049  sal_Int32 toInt32( sal_Int16 radix = 10 ) const
3050  {
3051  return rtl_ustr_toInt32( pData->buffer, radix );
3052  }
3053 
3066  sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
3067  {
3068  return rtl_ustr_toUInt32( pData->buffer, radix );
3069  }
3070 
3081  sal_Int64 toInt64( sal_Int16 radix = 10 ) const
3082  {
3083  return rtl_ustr_toInt64( pData->buffer, radix );
3084  }
3085 
3098  sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
3099  {
3100  return rtl_ustr_toUInt64( pData->buffer, radix );
3101  }
3102 
3111  float toFloat() const
3112  {
3113  return rtl_ustr_toFloat( pData->buffer );
3114  }
3115 
3124  double toDouble() const
3125  {
3126  return rtl_ustr_toDouble( pData->buffer );
3127  }
3128 
3129 
3146  {
3147  rtl_uString * pNew = NULL;
3148  rtl_uString_intern( &pNew, pData );
3149  if (pNew == NULL) {
3150  throw std::bad_alloc();
3151  }
3152  return OUString( pNew, SAL_NO_ACQUIRE );
3153  }
3154 
3180  static OUString intern( const sal_Char * value, sal_Int32 length,
3181  rtl_TextEncoding encoding,
3182  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS,
3183  sal_uInt32 *pInfo = NULL )
3184  {
3185  rtl_uString * pNew = NULL;
3186  rtl_uString_internConvert( &pNew, value, length, encoding,
3187  convertFlags, pInfo );
3188  if (pNew == NULL) {
3189  throw std::bad_alloc();
3190  }
3191  return OUString( pNew, SAL_NO_ACQUIRE );
3192  }
3193 
3218  bool convertToString(OString * pTarget, rtl_TextEncoding nEncoding,
3219  sal_uInt32 nFlags) const
3220  {
3221  return rtl_convertUStringToString(&pTarget->pData, pData->buffer,
3222  pData->length, nEncoding, nFlags);
3223  }
3224 
3276  sal_uInt32 iterateCodePoints(
3277  sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1) const
3278  {
3280  pData, indexUtf16, incrementCodePoints);
3281  }
3282 
3292  static OUString fromUtf8(const OString& rSource)
3293  {
3294  OUString aTarget;
3295  bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
3296  rSource.getStr(),
3297  rSource.getLength(),
3300  (void) bSuccess;
3301  assert(bSuccess);
3302  return aTarget;
3303  }
3304 
3315  OString toUtf8() const
3316  {
3317  OString aTarget;
3318  bool bSuccess = rtl_convertUStringToString(&aTarget.pData,
3319  getStr(),
3320  getLength(),
3323  (void) bSuccess;
3324  assert(bSuccess);
3325  return aTarget;
3326  }
3327 
3338  static OUString number( int i, sal_Int16 radix = 10 )
3339  {
3341  rtl_uString* pNewData = NULL;
3342  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt32( aBuf, i, radix ) );
3343  return OUString( pNewData, SAL_NO_ACQUIRE );
3344  }
3347  static OUString number( unsigned int i, sal_Int16 radix = 10 )
3348  {
3349  return number( static_cast< unsigned long long >( i ), radix );
3350  }
3353  static OUString number( long i, sal_Int16 radix = 10)
3354  {
3355  return number( static_cast< long long >( i ), radix );
3356  }
3359  static OUString number( unsigned long i, sal_Int16 radix = 10 )
3360  {
3361  return number( static_cast< unsigned long long >( i ), radix );
3362  }
3365  static OUString number( long long ll, sal_Int16 radix = 10 )
3366  {
3368  rtl_uString* pNewData = NULL;
3369  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt64( aBuf, ll, radix ) );
3370  return OUString( pNewData, SAL_NO_ACQUIRE );
3371  }
3374  static OUString number( unsigned long long ll, sal_Int16 radix = 10 )
3375  {
3377  rtl_uString* pNewData = NULL;
3378  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfUInt64( aBuf, ll, radix ) );
3379  return OUString( pNewData, SAL_NO_ACQUIRE );
3380  }
3381 
3391  static OUString number( float f )
3392  {
3394  rtl_uString* pNewData = NULL;
3395  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfFloat( aBuf, f ) );
3396  return OUString( pNewData, SAL_NO_ACQUIRE );
3397  }
3398 
3408  static OUString number( double d )
3409  {
3411  rtl_uString* pNewData = NULL;
3412  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfDouble( aBuf, d ) );
3413  return OUString( pNewData, SAL_NO_ACQUIRE );
3414  }
3415 
3427  SAL_DEPRECATED("use boolean()") static OUString valueOf( sal_Bool b )
3428  {
3429  return boolean(b);
3430  }
3431 
3443  static OUString boolean( bool b )
3444  {
3446  rtl_uString* pNewData = NULL;
3447  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfBoolean( aBuf, b ) );
3448  return OUString( pNewData, SAL_NO_ACQUIRE );
3449  }
3450 
3458  SAL_DEPRECATED("convert to OUString or use directly") static OUString valueOf( sal_Unicode c )
3459  {
3460  return OUString( &c, 1 );
3461  }
3462 
3473  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
3474  {
3475  return number( i, radix );
3476  }
3477 
3488  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
3489  {
3490  return number( ll, radix );
3491  }
3492 
3502  SAL_DEPRECATED("use number()") static OUString valueOf( float f )
3503  {
3504  return number(f);
3505  }
3506 
3516  SAL_DEPRECATED("use number()") static OUString valueOf( double d )
3517  {
3518  return number(d);
3519  }
3520 
3536  static OUString createFromAscii( const sal_Char * value )
3537  {
3538  rtl_uString* pNew = NULL;
3539  rtl_uString_newFromAscii( &pNew, value );
3540  return OUString( pNew, SAL_NO_ACQUIRE );
3541  }
3542 };
3543 
3544 #if defined LIBO_INTERNAL_ONLY
3545 // Prevent the operator ==/!= overloads with 'sal_Unicode const *' parameter from
3546 // being selected for nonsensical code like
3547 //
3548 // if (ouIdAttr == nullptr)
3549 //
3550 void operator ==(OUString const &, std::nullptr_t) = delete;
3551 void operator ==(std::nullptr_t, OUString const &) = delete;
3552 void operator !=(OUString const &, std::nullptr_t) = delete;
3553 void operator !=(std::nullptr_t, OUString const &) = delete;
3554 #endif
3555 
3556 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3557 
3562 template<>
3563 struct ToStringHelper< OUString >
3564  {
3565  static int length( const OUString& s ) { return s.getLength(); }
3566  static sal_Unicode* addData( sal_Unicode* buffer, const OUString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
3567  static const bool allowOStringConcat = false;
3568  static const bool allowOUStringConcat = true;
3569  };
3570 
3574 template<>
3575 struct ToStringHelper< OUStringLiteral >
3576  {
3577  static int length( const OUStringLiteral& str ) { return str.size; }
3578  static sal_Unicode* addData( sal_Unicode* buffer, const OUStringLiteral& str ) { return addDataLiteral( buffer, str.data, str.size ); }
3579  static const bool allowOStringConcat = false;
3580  static const bool allowOUStringConcat = true;
3581  };
3582 
3586 template< typename charT, typename traits, typename T1, typename T2 >
3587 inline std::basic_ostream<charT, traits> & operator <<(
3588  std::basic_ostream<charT, traits> & stream, OUStringConcat< T1, T2 >&& concat)
3589 {
3590  return stream << OUString( std::move(concat) );
3591 }
3592 
3594 #endif
3595 
3602 {
3612  size_t operator()(const OUString& rString) const
3613  { return (size_t)rString.hashCode(); }
3614 };
3615 
3616 /* ======================================================================= */
3617 
3635 inline OUString OStringToOUString( const OString & rStr,
3636  rtl_TextEncoding encoding,
3637  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
3638 {
3639  return OUString( rStr.getStr(), rStr.getLength(), encoding, convertFlags );
3640 }
3641 
3659 inline OString OUStringToOString( const OUString & rUnicode,
3660  rtl_TextEncoding encoding,
3661  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
3662 {
3663  return OString( rUnicode.getStr(), rUnicode.getLength(), encoding, convertFlags );
3664 }
3665 
3666 /* ======================================================================= */
3667 
3676 template< typename charT, typename traits >
3677 inline std::basic_ostream<charT, traits> & operator <<(
3678  std::basic_ostream<charT, traits> & stream, OUString const & rString)
3679 {
3680  return stream <<
3682  // best effort; potentially loses data due to conversion failures
3683  // (stray surrogate halves) and embedded null characters
3684 }
3685 
3686 } // namespace
3687 
3688 #ifdef RTL_STRING_UNITTEST
3689 namespace rtl
3690 {
3691 typedef rtlunittest::OUString OUString;
3692 }
3693 #endif
3694 
3695 // In internal code, allow to use classes like OUString without having to
3696 // explicitly refer to the rtl namespace, which is kind of superfluous given
3697 // that OUString itself is namespaced by its OU prefix:
3698 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3699 using ::rtl::OUString;
3700 using ::rtl::OUStringHash;
3703 using ::rtl::OUStringLiteral;
3704 using ::rtl::OUStringLiteral1;
3705 #endif
3706 
3708 
3713 #if defined LIBO_INTERNAL_ONLY
3714 namespace std {
3715 
3716 template<>
3717 struct hash<::rtl::OUString>
3718 {
3719  std::size_t operator()(::rtl::OUString const & s) const
3720  { return std::size_t(s.hashCode()); }
3721 };
3722 
3723 }
3724 
3725 #endif
3726 
3728 #endif /* _RTL_USTRING_HXX */
3729 
3730 /* 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.
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:1324
bool toBoolean() const
Returns the Boolean value from this string.
Definition: ustring.hxx:3023
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.
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &stream, OString const &rString)
Support for rtl::OString in std::ostream (and thus in CPPUNIT_ASSERT or SAL_INFO macros, for example).
Definition: string.hxx:1893
bool equals(const OUString &str) const
Perform a comparison of two strings.
Definition: ustring.hxx:776
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:2211
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.
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: ustring.hxx:3066
static OUString createFromAscii(const sal_Char *value)
Returns a OUString copied without conversion from an ASCII character string.
Definition: ustring.hxx:3536
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:33
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:3359
~OUString()
Release the string data.
Definition: ustring.hxx:412
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:2062
#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.
OUString(rtl_uString *str, __sal_NoAcquire)
New OUString from OUString data without acquiring it.
Definition: ustring.hxx:184
float toFloat() const
Returns the float value from this string.
Definition: ustring.hxx:3111
SAL_WARN_UNUSED_RESULT OUString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: ustring.hxx:2192
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:352
SAL_DLLPUBLIC void rtl_uString_newReplaceAllUtf16LAsciiL(rtl_uString **newStr, rtl_uString *str, sal_Unicode const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
static OUString number(double d)
Returns the string representation of the double argument.
Definition: ustring.hxx:3408
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:2665
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.
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1726
SAL_DLLPUBLIC sal_Bool rtl_ustr_toBoolean(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
static OUString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: ustring.hxx:3338
bool startsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: ustring.hxx:1298
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...
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1742
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...
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:116
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.
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:1269
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition: ustring.hxx:526
#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.
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:2959
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...
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:96
bool equalsIgnoreAsciiCaseAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1202
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.
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:3353
OUString intern() const
Return a canonical representation for a string.
Definition: ustring.hxx:3145
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:106
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
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:3347
sal_Unicode toChar() const
Returns the first character from this string.
Definition: ustring.hxx:3034
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.
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.
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: ustring.hxx:3049
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:3365
#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.
A helper to use OUStrings with hash maps.
Definition: ustring.hxx:3601
double toDouble() const
Returns the double value from this string.
Definition: ustring.hxx:3124
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.
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: ustring.hxx:621
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...
const sal_Unicode * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:656
bool convertToString(OString *pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) const
Converts to an OString, signalling failure.
Definition: ustring.hxx:3218
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:95
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
OUString(sal_uInt32 const *codePoints, sal_Int32 codePointCount)
Create a new string from an array of Unicode code points.
Definition: ustring.hxx:379
#define RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR
Definition: textcvt.h:71
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:2643
SAL_DLLPUBLIC void rtl_uString_newFromStr(rtl_uString **newStr, const sal_Unicode *value) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: ustring.hxx:3098
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:902
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don&#39;t use, it&#39;s evil.") void doit(int nPara);.
Definition: types.h:493
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:606
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.
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:3374
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.
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:838
#define RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR
Definition: textcvt.h:138
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:959
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:644
bool equalsIgnoreAsciiCase(const OUString &str) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:800
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.
bool equalsAscii(const sal_Char *asciiStr) const
Perform a comparison of two strings.
Definition: ustring.hxx:1104
#define RTL_USTR_MAX_VALUEOFBOOLEAN
Definition: ustring.h:915
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type lastIndexOf(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:2128
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfDouble(sal_Unicode *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
SAL_DLLPUBLIC void rtl_uString_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...
static OUString number(float f)
Returns the string representation of the float argument.
Definition: ustring.hxx:3391
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...
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:121
OUString(const OUString &str)
New string from OUString.
Definition: ustring.hxx:142
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.
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type endsWith(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:1491
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1758
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:474
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...
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWithIgnoreAsciiCase(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:1405
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfUInt64(sal_Unicode *str, sal_uInt64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an unsigned long integer.
sal_uInt16 sal_Unicode
Definition: types.h:142
sal_Int32 compareTo(const OUString &str) const
Compares two strings.
Definition: ustring.hxx:685
static OUString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: ustring.hxx:3443
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:3180
sal_Int32 reverseCompareToAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Compares two strings in reverse order.
Definition: ustring.hxx:1083
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
unsigned char sal_Bool
Definition: types.h:39
__sal_NoAcquire
Definition: types.h:376
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:2253
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:3635
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1774
friend OUString operator+(const OUString &rStr1, const OUString &rStr2)
Definition: ustring.hxx:2234
Definition: stringutils.hxx:115
OUString(rtl_uString *str)
New string from OUString data.
Definition: ustring.hxx:170
sal_Int32 reverseCompareTo(const OUString &str) const
Compares two strings in reverse order.
Definition: ustring.hxx:724
Dummy Type
Definition: stringutils.hxx:204
#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...
bool endsWithAsciiL(char const *asciiStr, sal_Int32 asciiStrLength) const
Check whether this string ends with a given ASCII string.
Definition: ustring.hxx:1564
OUString(const sal_Unicode *value)
New string from a Unicode character buffer array.
Definition: ustring.hxx:214
Definition: bootstrap.hxx:29
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfChar_WithLength(const sal_Unicode *str, sal_Int32 len, sal_Unicode ch) SAL_THROW_EXTERN_C()
Search for the last occurrence of a character within a string.
sal_Int32 compareToAscii(const sal_Char *asciiStr) const
Compares two strings.
Definition: ustring.hxx:1029
SAL_DLLPUBLIC sal_Int32 rtl_ustr_compare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings.
sal_Int32 lastIndexOf(sal_Unicode ch) const
Returns the index within this string of the last occurrence of the specified character, searching backward starting at the end.
Definition: ustring.hxx:1953
bool endsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string ends with a given substring.
Definition: ustring.hxx:1475
OString toUtf8() const
Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully.
Definition: ustring.hxx:3315
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:2273
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...
Dummy Type
Definition: stringutils.hxx:231
OUString & operator=(const OUString &str)
Assign a new string.
Definition: ustring.hxx:436
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:972
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:3659
definition of a no acquire enum for ctors
Definition: types.h:380
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_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:2394
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:1593
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 hashCode() const
Returns a hashcode for this string.
Definition: ustring.hxx:1920
bool equalsIgnoreAsciiCaseAscii(const sal_Char *asciiStr) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1154
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfBoolean(sal_Unicode *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:2003
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstToAsciiL(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, char const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
SAL_DLLPUBLIC sal_Int32 rtl_ustr_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.
const sal_Char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:429
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_Int32 compareTo(const OUString &str, sal_Int32 maxLength) const
Compares two strings with a maximum count of characters.
Definition: ustring.hxx:706
static OUString fromUtf8(const OString &rSource)
Convert an OString to an OUString, assuming that the OString is UTF-8-encoded.
Definition: ustring.hxx:3292
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:2360
sal_Int32 lastIndexOf(sal_Unicode ch, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified character, searching backward starting before the specified index.
Definition: ustring.hxx:1970
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:307
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:1685
char sal_Char
A legacy synonym for char.
Definition: types.h:121
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:2176
#define RTL_USTR_MAX_VALUEOFFLOAT
Definition: ustring.h:1022
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:2716
sal_Int32 compareToIgnoreAsciiCase(const OUString &str) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:825
SAL_DLLPUBLIC void rtl_uString_newFromLiteral(rtl_uString **newStr, const sal_Char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
bool startsWithIgnoreAsciiCase(OUString const &str, OUString *rest=NULL) const
Check whether this string starts with a given string, ignoring the case of ASCII letters.
Definition: ustring.hxx:1388
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:2939
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstAsciiLAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
OUString()
New string containing no characters.
Definition: ustring.hxx:131
OUString getToken(sal_Int32 count, sal_Unicode separator) const
Returns a token from the string.
Definition: ustring.hxx:3010
OUString(sal_Unicode value)
New string from a single Unicode character.
Definition: ustring.hxx:192
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:2298
#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.
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: ustring.hxx:3081
SAL_DLLPUBLIC sal_uInt32 rtl_ustr_toUInt32(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned integer.
SAL_DLLPUBLIC void rtl_uString_newFromAscii(rtl_uString **newStr, const sal_Char *value) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
bool match(const OUString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:890
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.
size_t operator()(const OUString &rString) const
Compute a hash code for a string.
Definition: ustring.hxx:3612
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.
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.
static OUString const & unacquired(rtl_uString *const *ppHandle)
Provides an OUString const & passing a storage pointer of an rtl_uString * handle.
Definition: ustring.hxx:428
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:2690
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type endsWithIgnoreAsciiCase(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:1610
SAL_WARN_UNUSED_RESULT OUString concat(const OUString &str) const
Concatenates the specified string to the end of this string.
Definition: ustring.hxx:2226
sal_Int32 lastIndexOf(const OUString &str) const
Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the end.
Definition: ustring.hxx:2093
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:3276
OUString getToken(sal_Int32 token, sal_Unicode cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: ustring.hxx:2990
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:2327
SAL_DLLPUBLIC sal_uInt64 rtl_ustr_toUInt64(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned long integer.
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Decrement the reference count of a string.
OUString(const sal_Unicode *value, sal_Int32 length)
New string from a Unicode character buffer array.
Definition: ustring.hxx:228
sal_Int32 compareToIgnoreAsciiCaseAscii(const sal_Char *asciiStr) const
Compares two ASCII strings ignoring case.
Definition: ustring.hxx:1177
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_Int32 getLength() const
Returns the length of this string.
Definition: ustring.hxx:634
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWith(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:1312
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.
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:250
#define OSTRING_TO_OUSTRING_CVTFLAGS
Definition: ustring.h:2119
sal_Int32 lastIndexOf(const OUString &str, sal_Int32 fromIndex) const
Returns the index within this string of the last occurrence of the specified substring, searching backward starting before the specified index.
Definition: ustring.hxx:2116
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:2922
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.
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:1231
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.
bool equalsAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform a comparison of two strings.
Definition: ustring.hxx:1127
sal_Int32 indexOf(sal_Unicode ch, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.
Definition: ustring.hxx:1938
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type reverseCompareTo(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function ...
Definition: ustring.hxx:736
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_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:403
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_Int32 indexOf(const OUString &str, sal_Int32 fromIndex=0) const
Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
Definition: ustring.hxx:1990
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.
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.