LibreOffice
LibreOffice 5.4 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 <string.h>
30 
31 #include <rtl/ustring.h>
32 #include <rtl/string.hxx>
33 #include <rtl/stringutils.hxx>
34 #include <rtl/textenc.h>
35 #include <sal/log.hxx>
36 
37 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
38 #include <config_global.h>
39 #include <rtl/stringconcat.hxx>
40 #endif
41 
42 #ifdef RTL_STRING_UNITTEST
43 extern bool rtl_string_unittest_invalid_conversion;
44 #endif
45 
46 // The unittest uses slightly different code to help check that the proper
47 // calls are made. The class is put into a different namespace to make
48 // sure the compiler generates a different (if generating also non-inline)
49 // copy of the function and does not merge them together. The class
50 // is "brought" into the proper rtl namespace by a typedef below.
51 #ifdef RTL_STRING_UNITTEST
52 #define rtl rtlunittest
53 #endif
54 
55 namespace rtl
56 {
57 
58 #ifdef RTL_STRING_UNITTEST
59 #undef rtl
60 #endif
61 
62 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
63 
71 struct SAL_WARN_UNUSED OUStringLiteral
72 {
73  template<typename T> constexpr OUStringLiteral(
74  T & literal,
75  typename libreoffice_internal::ConstCharArrayDetector<
76  T, libreoffice_internal::Dummy>::Type
77  = libreoffice_internal::Dummy()):
78  size(libreoffice_internal::ConstCharArrayDetector<T>::length),
79  data(
80  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal))
81  {
82 #if HAVE_CXX14_CONSTEXPR
83  assert(
84  libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
85 #endif
86  }
87 
88  int size;
89  const char* data;
90 };
91 
93 #endif
94 
95 /* ======================================================================= */
96 
120 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OUString
121 {
122 public:
124  rtl_uString * pData;
126 
131  {
132  pData = NULL;
133  rtl_uString_new( &pData );
134  }
135 
141  OUString( const OUString & str )
142  {
143  pData = str.pData;
144  rtl_uString_acquire( pData );
145  }
146 
147 #ifndef _MSC_VER // TODO?
148 #if defined LIBO_INTERNAL_ONLY
149 
155  OUString( OUString && str )
156  {
157  pData = str.pData;
158  str.pData = nullptr;
159  rtl_uString_new( &str.pData );
160  }
161 #endif
162 #endif
163 
169  OUString( rtl_uString * str )
170  {
171  pData = str;
172  rtl_uString_acquire( pData );
173  }
174 
183  OUString( rtl_uString * str, __sal_NoAcquire )
184  { pData = str; }
185 
191  explicit OUString( sal_Unicode value )
192  : pData (NULL)
193  {
194  rtl_uString_newFromStr_WithLength( &pData, &value, 1 );
195  }
196 
197 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
198  // Catch inadvertent conversions to the above ctor (but still allow
200  // construction from char literals):
201  OUString(int) = delete;
202  explicit OUString(char c):
203  OUString(sal_Unicode(static_cast<unsigned char>(c)))
204  {}
206 #endif
207 
213  OUString( const sal_Unicode * value )
214  {
215  pData = NULL;
216  rtl_uString_newFromStr( &pData, value );
217  }
218 
227  OUString( const sal_Unicode * value, sal_Int32 length )
228  {
229  pData = NULL;
230  rtl_uString_newFromStr_WithLength( &pData, value, length );
231  }
232 
248  template< typename T >
250  {
251  assert(
253  pData = NULL;
255  rtl_uString_new(&pData);
256  } else {
258  &pData,
260  literal),
262  }
263 #ifdef RTL_STRING_UNITTEST
264  rtl_string_unittest_const_literal = true;
265 #endif
266  }
267 
268 #if defined LIBO_INTERNAL_ONLY
269 
270  template<typename T> OUString(
271  T & literal,
273  T, libreoffice_internal::Dummy>::TypeUtf16
275  pData(nullptr)
276  {
278  rtl_uString_new(&pData);
279  } else {
281  &pData,
283  literal),
285  }
286  }
287 #endif
288 
289 #ifdef RTL_STRING_UNITTEST
290 
294  template< typename T >
296  {
297  pData = NULL;
298  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
299  rtl_string_unittest_invalid_conversion = true;
300  }
305  template< typename T >
307  {
308  pData = NULL;
309  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
310  rtl_string_unittest_invalid_conversion = true;
311  }
312 #endif
313 
314 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
315 
331  OUString(OUStringLiteral literal): pData(NULL) {
332  rtl_uString_newFromLiteral(&pData, literal.data, literal.size, 0);
333  }
335 #endif
336 
351  OUString( const sal_Char * value, sal_Int32 length,
352  rtl_TextEncoding encoding,
353  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
354  {
355  pData = NULL;
356  rtl_string2UString( &pData, value, length, encoding, convertFlags );
357  if (pData == NULL) {
358  throw std::bad_alloc();
359  }
360  }
361 
378  explicit OUString(
379  sal_uInt32 const * codePoints, sal_Int32 codePointCount):
380  pData(NULL)
381  {
382  rtl_uString_newFromCodePoints(&pData, codePoints, codePointCount);
383  if (pData == NULL) {
384  throw std::bad_alloc();
385  }
386  }
387 
388 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
389 
393  template< typename T1, typename T2 >
394  OUString( const OUStringConcat< T1, T2 >& c )
395  {
396  const sal_Int32 l = c.length();
397  pData = rtl_uString_alloc( l );
398  if (l != 0)
399  {
400  sal_Unicode* end = c.addData( pData->buffer );
401  pData->length = l;
402  *end = '\0';
403  // TODO realloc in case pData->length is noticeably smaller than l?
404  }
405  }
406 #endif
407 
412  {
413  rtl_uString_release( pData );
414  }
415 
427  static OUString const & unacquired( rtl_uString * const * ppHandle )
428  { return * reinterpret_cast< OUString const * >( ppHandle ); }
429 
435  OUString & operator=( const OUString & str )
436  {
437  rtl_uString_assign( &pData, str.pData );
438  return *this;
439  }
440 
441 #ifndef _MSC_VER // TODO?
442 #if defined LIBO_INTERNAL_ONLY
443 
449  OUString & operator=( OUString && str )
450  {
451  rtl_uString_release( pData );
452  pData = str.pData;
453  str.pData = nullptr;
454  rtl_uString_new( &str.pData );
455  return *this;
456  }
457 #endif
458 #endif
459 
472  template< typename T >
474  {
475  assert(
478  rtl_uString_new(&pData);
479  } else {
481  &pData,
483  literal),
485  }
486  return *this;
487  }
488 
489 #if defined LIBO_INTERNAL_ONLY
490 
491  template<typename T>
492  typename
494  operator =(T & literal) {
496  rtl_uString_new(&pData);
497  } else {
499  &pData,
501  literal),
503  }
504  return *this;
505  }
506 
508  OUString & operator =(OUStringLiteral const & literal) {
509  if (literal.size == 0) {
510  rtl_uString_new(&pData);
511  } else {
512  rtl_uString_newFromLiteral(&pData, literal.data, literal.size, 0);
513  }
514  return *this;
515  }
516 #endif
517 
523  OUString & operator+=( const OUString & str )
524 #if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
525  &
526 #endif
527  {
528  rtl_uString_newConcat( &pData, pData, str.pData );
529  return *this;
530  }
531 #if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
532  void operator+=(OUString const &) && = delete;
533 #endif
534 
541  template<typename T>
543  operator +=(T & literal)
544 #if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
545  &
546 #endif
547  {
548  assert(
551  &pData, pData,
554  return *this;
555  }
556 #if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
557  template<typename T>
559  operator +=(T &) && = delete;
560 #endif
561 
562 #if defined LIBO_INTERNAL_ONLY
563 
564  template<typename T>
565  typename
567  operator +=(T & literal)
568 #if HAVE_CXX11_REF_QUALIFIER
569  &
570 #endif
571  {
573  &pData, pData,
576  return *this;
577  }
578 #if HAVE_CXX11_REF_QUALIFIER
579  template<typename T>
580  typename
582  operator +=(T &) && = delete;
583 #endif
584 
586  OUString & operator +=(OUStringLiteral const & literal)
587 #if HAVE_CXX11_REF_QUALIFIER
588  &
589 #endif
590  {
591  rtl_uString_newConcatAsciiL(&pData, pData, literal.data, literal.size);
592  return *this;
593  }
594 #if HAVE_CXX11_REF_QUALIFIER
595  void operator +=(OUStringLiteral const &) && = delete;
596 #endif
597 #endif
598 
599 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
600 
604  template< typename T1, typename T2 >
605  OUString& operator+=( const OUStringConcat< T1, T2 >& c )
606 #if HAVE_CXX11_REF_QUALIFIER
607  &
608 #endif
609  {
610  sal_Int32 l = c.length();
611  if( l == 0 )
612  return *this;
613  l += pData->length;
614  rtl_uString_ensureCapacity( &pData, l );
615  sal_Unicode* end = c.addData( pData->buffer + pData->length );
616  *end = '\0';
617  pData->length = l;
618  return *this;
619  }
620 #if HAVE_CXX11_REF_QUALIFIER
621  template<typename T1, typename T2> void operator +=(
622  OUStringConcat<T1, T2> const &) && = delete;
623 #endif
624 #endif
625 
630  void clear()
631  {
632  rtl_uString_new( &pData );
633  }
634 
643  sal_Int32 getLength() const { return pData->length; }
644 
653  bool isEmpty() const
654  {
655  return pData->length == 0;
656  }
657 
665  const sal_Unicode * getStr() const { return pData->buffer; }
666 
676  sal_Unicode operator [](sal_Int32 index) const {
677  // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
678  assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
679  return getStr()[index];
680  }
681 
694  sal_Int32 compareTo( const OUString & str ) const
695  {
696  return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
697  str.pData->buffer, str.pData->length );
698  }
699 
715  sal_Int32 compareTo( const OUString & str, sal_Int32 maxLength ) const
716  {
717  return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
718  str.pData->buffer, str.pData->length, maxLength );
719  }
720 
733  sal_Int32 reverseCompareTo( const OUString & str ) const
734  {
735  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
736  str.pData->buffer, str.pData->length );
737  }
738 
744  template< typename T >
746  {
747  assert(
750  pData->buffer, pData->length,
753  }
754 
755 #if defined LIBO_INTERNAL_ONLY
756 
757  template<typename T>
758  typename
760  reverseCompareTo(T & literal) const {
762  pData->buffer, pData->length,
765  }
766 
768  sal_Int32 reverseCompareTo(OUStringLiteral const & literal) const {
770  pData->buffer, pData->length, literal.data, literal.size);
771  }
772 #endif
773 
785  bool equals( const OUString & str ) const
786  {
787  if ( pData->length != str.pData->length )
788  return false;
789  if ( pData == str.pData )
790  return true;
791  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
792  str.pData->buffer, str.pData->length ) == 0;
793  }
794 
809  bool equalsIgnoreAsciiCase( const OUString & str ) const
810  {
811  if ( pData->length != str.pData->length )
812  return false;
813  if ( pData == str.pData )
814  return true;
815  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
816  str.pData->buffer, str.pData->length ) == 0;
817  }
818 
834  sal_Int32 compareToIgnoreAsciiCase( const OUString & str ) const
835  {
836  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
837  str.pData->buffer, str.pData->length );
838  }
839 
840 
846  template< typename T >
848  {
849  assert(
851  return
852  (pData->length
855  pData->buffer, pData->length,
857  literal))
858  == 0);
859  }
860 
861 #if defined LIBO_INTERNAL_ONLY
862 
863  template<typename T>
865  equalsIgnoreAsciiCase(T & literal) const {
866  return
868  pData->buffer, pData->length,
870  literal),
872  == 0;
873  }
874 
876  bool equalsIgnoreAsciiCase(OUStringLiteral const & literal) const {
877  return pData->length == literal.size
879  pData->buffer, pData->length, literal.data)
880  == 0);
881  }
882 #endif
883 
899  bool match( const OUString & str, sal_Int32 fromIndex = 0 ) const
900  {
901  return rtl_ustr_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
902  str.pData->buffer, str.pData->length, str.pData->length ) == 0;
903  }
904 
910  template< typename T >
911  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
912  {
913  assert(
915  return
917  pData->buffer+fromIndex, pData->length-fromIndex,
919  literal),
921  == 0;
922  }
923 
924 #if defined LIBO_INTERNAL_ONLY
925 
926  template<typename T>
928  match(T & literal, sal_Int32 fromIndex = 0) const {
929  assert(fromIndex >= 0);
930  return
932  pData->buffer + fromIndex, pData->length - fromIndex,
934  literal),
937  == 0;
938  }
939 
941  bool match(OUStringLiteral const & literal, sal_Int32 fromIndex = 0) const {
942  return
944  pData->buffer + fromIndex, pData->length - fromIndex,
945  literal.data, literal.size)
946  == 0;
947  }
948 #endif
949 
968  bool matchIgnoreAsciiCase( const OUString & str, sal_Int32 fromIndex = 0 ) const
969  {
970  return rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
971  str.pData->buffer, str.pData->length,
972  str.pData->length ) == 0;
973  }
974 
980  template< typename T >
981  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
982  {
983  assert(
985  return
987  pData->buffer+fromIndex, pData->length-fromIndex,
989  literal),
991  == 0;
992  }
993 
994 #if defined LIBO_INTERNAL_ONLY
995 
996  template<typename T>
998  matchIgnoreAsciiCase(T & literal, sal_Int32 fromIndex = 0) const {
999  assert(fromIndex >= 0);
1000  return
1002  pData->buffer + fromIndex, pData->length - fromIndex,
1004  literal),
1007  == 0;
1008  }
1009 
1011  bool matchIgnoreAsciiCase(
1012  OUStringLiteral const & literal, sal_Int32 fromIndex = 0) const
1013  {
1014  return
1016  pData->buffer+fromIndex, pData->length-fromIndex, literal.data,
1017  literal.size)
1018  == 0;
1019  }
1020 #endif
1021 
1038  sal_Int32 compareToAscii( const sal_Char* asciiStr ) const
1039  {
1040  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length, asciiStr );
1041  }
1042 
1066  "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
1067  sal_Int32 compareToAscii( const sal_Char * asciiStr, sal_Int32 maxLength ) const
1068  {
1069  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer, pData->length,
1070  asciiStr, maxLength );
1071  }
1072 
1092  sal_Int32 reverseCompareToAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
1093  {
1094  return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
1095  asciiStr, asciiStrLength );
1096  }
1097 
1113  bool equalsAscii( const sal_Char* asciiStr ) const
1114  {
1115  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length,
1116  asciiStr ) == 0;
1117  }
1118 
1136  bool equalsAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength ) const
1137  {
1138  if ( pData->length != asciiStrLength )
1139  return false;
1140 
1142  pData->buffer, asciiStr, asciiStrLength );
1143  }
1144 
1163  bool equalsIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const
1164  {
1165  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1166  }
1167 
1186  sal_Int32 compareToIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const
1187  {
1188  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr );
1189  }
1190 
1211  bool equalsIgnoreAsciiCaseAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
1212  {
1213  if ( pData->length != asciiStrLength )
1214  return false;
1215 
1216  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1217  }
1218 
1240  bool matchAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1241  {
1242  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1243  asciiStr, asciiStrLength ) == 0;
1244  }
1245 
1246  // This overload is left undefined, to detect calls of matchAsciiL that
1247  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1248  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1249  // platforms):
1250 #if SAL_TYPES_SIZEOFLONG == 8
1251  void matchAsciiL(char const *, sal_Int32, rtl_TextEncoding) const;
1252 #endif
1253 
1278  bool matchIgnoreAsciiCaseAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1279  {
1280  return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1281  asciiStr, asciiStrLength ) == 0;
1282  }
1283 
1284  // This overload is left undefined, to detect calls of
1285  // matchIgnoreAsciiCaseAsciiL that erroneously use
1286  // RTL_CONSTASCII_USTRINGPARAM instead of RTL_CONSTASCII_STRINGPARAM (but
1287  // would lead to ambiguities on 32 bit platforms):
1288 #if SAL_TYPES_SIZEOFLONG == 8
1289  void matchIgnoreAsciiCaseAsciiL(char const *, sal_Int32, rtl_TextEncoding)
1290  const;
1291 #endif
1292 
1307  bool startsWith(OUString const & str, OUString * rest = NULL) const {
1308  bool b = match(str);
1309  if (b && rest != NULL) {
1310  *rest = copy(str.getLength());
1311  }
1312  return b;
1313  }
1314 
1320  template< typename T >
1322  T & literal, OUString * rest = NULL) const
1323  {
1324  assert(
1326  bool b
1328  <= sal_uInt32(pData->length))
1330  pData->buffer,
1332  literal),
1334  if (b && rest != NULL) {
1335  *rest = copy(
1337  }
1338  return b;
1339  }
1340 
1341 #if defined LIBO_INTERNAL_ONLY
1342 
1343  template<typename T>
1345  startsWith(T & literal, OUString * rest = nullptr) const {
1346  bool b
1348  <= sal_uInt32(pData->length))
1350  pData->buffer,
1353  literal),
1355  == 0);
1356  if (b && rest != nullptr) {
1357  *rest = copy(
1359  }
1360  return b;
1361  }
1362 
1364  bool startsWith(OUStringLiteral const & literal, OUString * rest = nullptr)
1365  const
1366  {
1367  bool b = literal.size <= pData->length
1369  pData->buffer, literal.data, literal.size);
1370  if (b && rest != nullptr) {
1371  *rest = copy(literal.size);
1372  }
1373  return b;
1374  }
1375 #endif
1376 
1397  bool startsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL)
1398  const
1399  {
1400  bool b = matchIgnoreAsciiCase(str);
1401  if (b && rest != NULL) {
1402  *rest = copy(str.getLength());
1403  }
1404  return b;
1405  }
1406 
1412  template< typename T >
1414  startsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1415  {
1416  assert(
1418  bool b
1420  pData->buffer,
1423  literal),
1425  == 0);
1426  if (b && rest != NULL) {
1427  *rest = copy(
1429  }
1430  return b;
1431  }
1432 
1433 #if defined LIBO_INTERNAL_ONLY
1434 
1435  template<typename T>
1437  startsWithIgnoreAsciiCase(T & literal, OUString * rest = nullptr) const {
1438  bool b
1440  <= sal_uInt32(pData->length))
1442  pData->buffer,
1445  literal),
1447  == 0);
1448  if (b && rest != nullptr) {
1449  *rest = copy(
1451  }
1452  return b;
1453  }
1454 
1456  bool startsWithIgnoreAsciiCase(
1457  OUStringLiteral const & literal, OUString * rest = nullptr) const
1458  {
1459  bool b
1461  pData->buffer, literal.size, literal.data, literal.size)
1462  == 0);
1463  if (b && rest != nullptr) {
1464  *rest = copy(literal.size);
1465  }
1466  return b;
1467  }
1468 #endif
1469 
1484  bool endsWith(OUString const & str, OUString * rest = NULL) const {
1485  bool b = str.getLength() <= getLength()
1486  && match(str, getLength() - str.getLength());
1487  if (b && rest != NULL) {
1488  *rest = copy(0, getLength() - str.getLength());
1489  }
1490  return b;
1491  }
1492 
1498  template< typename T >
1500  endsWith(T & literal, OUString * rest = NULL) const
1501  {
1502  assert(
1504  bool b
1506  <= sal_uInt32(pData->length))
1508  (pData->buffer + pData->length
1511  literal),
1513  if (b && rest != NULL) {
1514  *rest = copy(
1515  0,
1516  (getLength()
1518  }
1519  return b;
1520  }
1521 
1522 #if defined LIBO_INTERNAL_ONLY
1523 
1524  template<typename T>
1526  endsWith(T & literal, OUString * rest = nullptr) const {
1527  bool b
1529  <= sal_uInt32(pData->length))
1531  (pData->buffer + pData->length
1535  literal),
1537  == 0);
1538  if (b && rest != nullptr) {
1539  *rest = copy(
1540  0,
1541  (getLength()
1543  }
1544  return b;
1545  }
1546 
1548  bool endsWith(OUStringLiteral const & literal, OUString * rest = nullptr)
1549  const
1550  {
1551  bool b = literal.size <= pData->length
1553  pData->buffer + pData->length - literal.size,
1554  literal.data, literal.size);
1555  if (b && rest != nullptr) {
1556  *rest = copy(0, (getLength() - literal.size));
1557  }
1558  return b;
1559  }
1560 #endif
1561 
1573  bool endsWithAsciiL(char const * asciiStr, sal_Int32 asciiStrLength)
1574  const
1575  {
1576  return asciiStrLength <= pData->length
1578  pData->buffer + pData->length - asciiStrLength, asciiStr,
1579  asciiStrLength);
1580  }
1581 
1602  bool endsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL) const
1603  {
1604  bool b = str.getLength() <= getLength()
1605  && matchIgnoreAsciiCase(str, getLength() - str.getLength());
1606  if (b && rest != NULL) {
1607  *rest = copy(0, getLength() - str.getLength());
1608  }
1609  return b;
1610  }
1611 
1617  template< typename T >
1619  endsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1620  {
1621  assert(
1623  bool b
1625  <= sal_uInt32(pData->length))
1627  (pData->buffer + pData->length
1631  literal),
1633  == 0);
1634  if (b && rest != NULL) {
1635  *rest = copy(
1636  0,
1637  (getLength()
1639  }
1640  return b;
1641  }
1642 
1643 #if defined LIBO_INTERNAL_ONLY
1644 
1645  template<typename T>
1647  endsWithIgnoreAsciiCase(T & literal, OUString * rest = nullptr) const {
1648  bool b
1650  <= sal_uInt32(pData->length))
1652  (pData->buffer + pData->length
1656  literal),
1658  == 0);
1659  if (b && rest != nullptr) {
1660  *rest = copy(
1661  0,
1662  (getLength()
1664  }
1665  return b;
1666  }
1667 
1669  bool endsWithIgnoreAsciiCase(
1670  OUStringLiteral const & literal, OUString * rest = nullptr) const
1671  {
1672  bool b = literal.size <= pData->length
1674  pData->buffer + pData->length - literal.size,
1675  literal.size, literal.data, literal.size)
1676  == 0);
1677  if (b && rest != nullptr) {
1678  *rest = copy(0, getLength() - literal.size);
1679  }
1680  return b;
1681  }
1682 #endif
1683 
1695  char const * asciiStr, sal_Int32 asciiStrLength) const
1696  {
1697  return asciiStrLength <= pData->length
1699  pData->buffer + pData->length - asciiStrLength,
1700  asciiStrLength, asciiStr, asciiStrLength)
1701  == 0);
1702  }
1703 
1704  friend bool operator == ( const OUString& rStr1, const OUString& rStr2 )
1705  { return rStr1.equals(rStr2); }
1706  friend bool operator == ( const OUString& rStr1, const sal_Unicode * pStr2 )
1707  { return rStr1.compareTo( pStr2 ) == 0; }
1708  friend bool operator == ( const sal_Unicode * pStr1, const OUString& rStr2 )
1709  { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
1710 
1711  friend bool operator != ( const OUString& rStr1, const OUString& rStr2 )
1712  { return !(operator == ( rStr1, rStr2 )); }
1713  friend bool operator != ( const OUString& rStr1, const sal_Unicode * pStr2 )
1714  { return !(operator == ( rStr1, pStr2 )); }
1715  friend bool operator != ( const sal_Unicode * pStr1, const OUString& rStr2 )
1716  { return !(operator == ( pStr1, rStr2 )); }
1717 
1718  friend bool operator < ( const OUString& rStr1, const OUString& rStr2 )
1719  { return rStr1.compareTo( rStr2 ) < 0; }
1720  friend bool operator > ( const OUString& rStr1, const OUString& rStr2 )
1721  { return rStr1.compareTo( rStr2 ) > 0; }
1722  friend bool operator <= ( const OUString& rStr1, const OUString& rStr2 )
1723  { return rStr1.compareTo( rStr2 ) <= 0; }
1724  friend bool operator >= ( const OUString& rStr1, const OUString& rStr2 )
1725  { return rStr1.compareTo( rStr2 ) >= 0; }
1726 
1734  template< typename T >
1736  {
1737  assert(
1739  return rString.equalsAsciiL(
1742  }
1750  template< typename T >
1752  {
1753  assert(
1755  return rString.equalsAsciiL(
1758  }
1766  template< typename T >
1768  {
1769  assert(
1771  return !rString.equalsAsciiL(
1774  }
1782  template< typename T >
1784  {
1785  assert(
1787  return !rString.equalsAsciiL(
1790  }
1791 
1792 #if defined LIBO_INTERNAL_ONLY
1793 
1794  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1795  operator ==(OUString & string, T & literal) {
1796  return
1798  string.pData->buffer, string.pData->length,
1800  literal),
1802  == 0;
1803  }
1805  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1806  operator ==(T & literal, OUString & string) {
1807  return
1810  literal),
1812  string.pData->buffer, string.pData->length)
1813  == 0;
1814  }
1816  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1817  operator !=(OUString & string, T & literal) {
1818  return
1820  string.pData->buffer, string.pData->length,
1822  literal),
1824  != 0;
1825  }
1827  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1828  operator !=(T & literal, OUString & string) {
1829  return
1832  literal),
1834  string.pData->buffer, string.pData->length)
1835  != 0;
1836  }
1837 #endif
1838 
1839 #if defined LIBO_INTERNAL_ONLY
1840 
1842  /* Comparison between OUString and OUStringLiteral.
1843 
1844  @since LibreOffice 5.0
1845  */
1846 
1847  friend bool operator ==(OUString const & lhs, OUStringLiteral const & rhs) {
1848  return lhs.equalsAsciiL(rhs.data, rhs.size);
1849  }
1850 
1851  friend bool operator !=(OUString const & lhs, OUStringLiteral const & rhs) {
1852  return !lhs.equalsAsciiL(rhs.data, rhs.size);
1853  }
1854 
1855  friend bool operator <(OUString const & lhs, OUStringLiteral const & rhs) {
1856  return
1858  lhs.pData->buffer, lhs.pData->length, rhs.data))
1859  < 0;
1860  }
1861 
1862  friend bool operator <=(OUString const & lhs, OUStringLiteral const & rhs) {
1863  return
1865  lhs.pData->buffer, lhs.pData->length, rhs.data))
1866  <= 0;
1867  }
1868 
1869  friend bool operator >(OUString const & lhs, OUStringLiteral const & rhs) {
1870  return
1872  lhs.pData->buffer, lhs.pData->length, rhs.data))
1873  > 0;
1874  }
1875 
1876  friend bool operator >=(OUString const & lhs, OUStringLiteral const & rhs) {
1877  return
1879  lhs.pData->buffer, lhs.pData->length, rhs.data))
1880  >= 0;
1881  }
1882 
1883  friend bool operator ==(OUStringLiteral const & lhs, OUString const & rhs) {
1884  return rhs.equalsAsciiL(lhs.data, lhs.size);
1885  }
1886 
1887  friend bool operator !=(OUStringLiteral const & lhs, OUString const & rhs) {
1888  return !rhs.equalsAsciiL(lhs.data, lhs.size);
1889  }
1890 
1891  friend bool operator <(OUStringLiteral const & lhs, OUString const & rhs) {
1892  return
1894  rhs.pData->buffer, rhs.pData->length, lhs.data))
1895  >= 0;
1896  }
1897 
1898  friend bool operator <=(OUStringLiteral const & lhs, OUString const & rhs) {
1899  return
1901  rhs.pData->buffer, rhs.pData->length, lhs.data))
1902  > 0;
1903  }
1904 
1905  friend bool operator >(OUStringLiteral const & lhs, OUString const & rhs) {
1906  return
1908  rhs.pData->buffer, rhs.pData->length, lhs.data))
1909  <= 0;
1910  }
1911 
1912  friend bool operator >=(OUStringLiteral const & lhs, OUString const & rhs) {
1913  return
1915  rhs.pData->buffer, rhs.pData->length, lhs.data))
1916  < 0;
1917  }
1918 
1920 #endif
1921 
1929  sal_Int32 hashCode() const
1930  {
1931  return rtl_ustr_hashCode_WithLength( pData->buffer, pData->length );
1932  }
1933 
1947  sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
1948  {
1949  sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1950  return (ret < 0 ? ret : ret+fromIndex);
1951  }
1952 
1962  sal_Int32 lastIndexOf( sal_Unicode ch ) const
1963  {
1964  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1965  }
1966 
1979  sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
1980  {
1981  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1982  }
1983 
1999  sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
2000  {
2001  sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
2002  str.pData->buffer, str.pData->length );
2003  return (ret < 0 ? ret : ret+fromIndex);
2004  }
2005 
2011  template< typename T >
2012  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
2013  {
2014  assert(
2016  sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
2017  pData->buffer + fromIndex, pData->length - fromIndex,
2020  return n < 0 ? n : n + fromIndex;
2021  }
2022 
2023 #if defined LIBO_INTERNAL_ONLY
2024 
2025  template<typename T>
2026  typename
2028  indexOf(T & literal, sal_Int32 fromIndex = 0) const {
2029  assert(fromIndex >= 0);
2031  pData->buffer + fromIndex, pData->length - fromIndex,
2034  return n < 0 ? n : n + fromIndex;
2035  }
2036 
2038  sal_Int32 indexOf(OUStringLiteral const & literal, sal_Int32 fromIndex = 0)
2039  const
2040  {
2041  sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
2042  pData->buffer + fromIndex, pData->length - fromIndex, literal.data,
2043  literal.size);
2044  return n < 0 ? n : n + fromIndex;
2045  }
2046 #endif
2047 
2071  sal_Int32 indexOfAsciiL(
2072  char const * str, sal_Int32 len, sal_Int32 fromIndex = 0) const
2073  {
2074  sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
2075  pData->buffer + fromIndex, pData->length - fromIndex, str, len);
2076  return ret < 0 ? ret : ret + fromIndex;
2077  }
2078 
2079  // This overload is left undefined, to detect calls of indexOfAsciiL that
2080  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
2081  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
2082  // platforms):
2083 #if SAL_TYPES_SIZEOFLONG == 8
2084  void indexOfAsciiL(char const *, sal_Int32 len, rtl_TextEncoding) const;
2085 #endif
2086 
2102  sal_Int32 lastIndexOf( const OUString & str ) const
2103  {
2104  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
2105  str.pData->buffer, str.pData->length );
2106  }
2107 
2125  sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
2126  {
2127  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
2128  str.pData->buffer, str.pData->length );
2129  }
2130 
2136  template< typename T >
2138  {
2139  assert(
2142  pData->buffer, pData->length,
2145  }
2146 
2147 #if defined LIBO_INTERNAL_ONLY
2148 
2149  template<typename T>
2150  typename
2152  lastIndexOf(T & literal) const {
2154  pData->buffer, pData->length,
2157  }
2158 
2160  sal_Int32 lastIndexOf(OUStringLiteral const & literal) const {
2162  pData->buffer, pData->length, literal.data, literal.size);
2163  }
2164 #endif
2165 
2185  sal_Int32 lastIndexOfAsciiL(char const * str, sal_Int32 len) const
2186  {
2188  pData->buffer, pData->length, str, len);
2189  }
2190 
2201  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex ) const
2202  {
2203  rtl_uString *pNew = NULL;
2204  rtl_uString_newFromSubString( &pNew, pData, beginIndex, getLength() - beginIndex );
2205  return OUString( pNew, SAL_NO_ACQUIRE );
2206  }
2207 
2220  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const
2221  {
2222  rtl_uString *pNew = NULL;
2223  rtl_uString_newFromSubString( &pNew, pData, beginIndex, count );
2224  return OUString( pNew, SAL_NO_ACQUIRE );
2225  }
2226 
2236  {
2237  rtl_uString* pNew = NULL;
2238  rtl_uString_newConcat( &pNew, pData, str.pData );
2239  return OUString( pNew, SAL_NO_ACQUIRE );
2240  }
2241 
2242 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2243  friend OUString operator+( const OUString& rStr1, const OUString& rStr2 )
2244  {
2245  return rStr1.concat( rStr2 );
2246  }
2247 #endif
2248 
2262  SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const
2263  {
2264  rtl_uString* pNew = NULL;
2265  rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
2266  return OUString( pNew, SAL_NO_ACQUIRE );
2267  }
2268 
2283  {
2284  rtl_uString* pNew = NULL;
2285  rtl_uString_newReplace( &pNew, pData, oldChar, newChar );
2286  return OUString( pNew, SAL_NO_ACQUIRE );
2287  }
2288 
2308  OUString const & from, OUString const & to, sal_Int32 * index = NULL) const
2309  {
2310  rtl_uString * s = NULL;
2311  sal_Int32 i = 0;
2313  &s, pData, from.pData, to.pData, index == NULL ? &i : index);
2314  return OUString(s, SAL_NO_ACQUIRE);
2315  }
2316 
2335  template< typename T >
2337  sal_Int32 * index = NULL) const
2338  {
2340  rtl_uString * s = NULL;
2341  sal_Int32 i = 0;
2343  &s, pData,
2346  index == NULL ? &i : index);
2347  return OUString(s, SAL_NO_ACQUIRE);
2348  }
2349 
2368  template< typename T >
2370  sal_Int32 * index = NULL) const
2371  {
2373  rtl_uString * s = NULL;
2374  sal_Int32 i = 0;
2376  &s, pData, from.pData,
2379  index == NULL ? &i : index);
2380  return OUString(s, SAL_NO_ACQUIRE);
2381  }
2382 
2401  template< typename T1, typename T2 >
2403  replaceFirst( T1& from, T2& to, sal_Int32 * index = NULL) const
2404  {
2407  rtl_uString * s = NULL;
2408  sal_Int32 i = 0;
2410  &s, pData,
2415  index == NULL ? &i : index);
2416  return OUString(s, SAL_NO_ACQUIRE);
2417  }
2418 
2419 #if defined LIBO_INTERNAL_ONLY
2420 
2421  template<typename T> SAL_WARN_UNUSED_RESULT
2422  typename
2424  replaceFirst(T & from, OUString const & to, sal_Int32 * index = nullptr)
2425  const
2426  {
2427  rtl_uString * s = nullptr;
2428  sal_Int32 i = 0;
2430  &s, pData,
2433  to.pData->buffer, to.pData->length, index == nullptr ? &i : index);
2434  if (s == nullptr) {
2435  throw std::bad_alloc();
2436  // should be std::length_error if resulting would be too large
2437  }
2438  return OUString(s, SAL_NO_ACQUIRE);
2439  }
2441  template<typename T> SAL_WARN_UNUSED_RESULT
2442  typename
2444  replaceFirst(OUString const & from, T & to, sal_Int32 * index = nullptr)
2445  const
2446  {
2447  rtl_uString * s = nullptr;
2448  sal_Int32 i = 0;
2450  &s, pData, from.pData->buffer, from.pData->length,
2453  index == nullptr ? &i : index);
2454  if (s == nullptr) {
2455  throw std::bad_alloc();
2456  // should be std::length_error if resulting would be too large
2457  }
2458  return OUString(s, SAL_NO_ACQUIRE);
2459  }
2461  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2462  typename
2464  T1,
2466  T2, OUString>::TypeUtf16
2467  >::TypeUtf16
2468  replaceFirst(T1 & from, T2 & to, sal_Int32 * index = nullptr) const {
2469  rtl_uString * s = nullptr;
2470  sal_Int32 i = 0;
2472  &s, pData,
2477  index == nullptr ? &i : index);
2478  if (s == nullptr) {
2479  throw std::bad_alloc();
2480  // should be std::length_error if resulting would be too large
2481  }
2482  return OUString(s, SAL_NO_ACQUIRE);
2483  }
2485  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2486  typename
2488  T1,
2490  T2, OUString>::Type
2491  >::TypeUtf16
2492  replaceFirst(T1 & from, T2 & to, sal_Int32 * index = nullptr) const {
2493  rtl_uString * s = nullptr;
2494  sal_Int32 i = 0;
2496  &s, pData,
2501  index == nullptr ? &i : index);
2502  if (s == nullptr) {
2503  throw std::bad_alloc();
2504  // should be std::length_error if resulting would be too large
2505  }
2506  return OUString(s, SAL_NO_ACQUIRE);
2507  }
2509  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2510  typename
2512  T1,
2514  T2, OUString>::TypeUtf16
2515  >::Type
2516  replaceFirst(T1 & from, T2 & to, sal_Int32 * index = nullptr) const {
2517  rtl_uString * s = nullptr;
2518  sal_Int32 i = 0;
2520  &s, pData,
2525  index == nullptr ? &i : index);
2526  if (s == nullptr) {
2527  throw std::bad_alloc();
2528  // should be std::length_error if resulting would be too large
2529  }
2530  return OUString(s, SAL_NO_ACQUIRE);
2531  }
2532 
2534  SAL_WARN_UNUSED_RESULT OUString replaceFirst(
2535  OUStringLiteral const & from, OUString const & to,
2536  sal_Int32 * index = nullptr) const
2537  {
2538  rtl_uString * s = nullptr;
2539  sal_Int32 i = 0;
2541  &s, pData, from.data, from.size, to.pData,
2542  index == nullptr ? &i : index);
2543  return OUString(s, SAL_NO_ACQUIRE);
2544  }
2546  SAL_WARN_UNUSED_RESULT OUString replaceFirst(
2547  OUString const & from, OUStringLiteral const & to,
2548  sal_Int32 * index = nullptr) const
2549  {
2550  rtl_uString * s = nullptr;
2551  sal_Int32 i = 0;
2553  &s, pData, from.pData, to.data, to.size,
2554  index == nullptr ? &i : index);
2555  return OUString(s, SAL_NO_ACQUIRE);
2556  }
2558  SAL_WARN_UNUSED_RESULT OUString replaceFirst(
2559  OUStringLiteral const & from, OUStringLiteral const & to,
2560  sal_Int32 * index = nullptr) const
2561  {
2562  rtl_uString * s = nullptr;
2563  sal_Int32 i = 0;
2565  &s, pData, from.data, from.size, to.data, to.size,
2566  index == nullptr ? &i : index);
2567  return OUString(s, SAL_NO_ACQUIRE);
2568  }
2570  template<typename T> SAL_WARN_UNUSED_RESULT
2572  replaceFirst(
2573  OUStringLiteral const & from, T & to, sal_Int32 * index = nullptr) const
2574  {
2576  rtl_uString * s = nullptr;
2577  sal_Int32 i = 0;
2579  &s, pData, from.data, from.size,
2582  index == nullptr ? &i : index);
2583  return OUString(s, SAL_NO_ACQUIRE);
2584  }
2586  template<typename T> SAL_WARN_UNUSED_RESULT
2588  replaceFirst(
2589  T & from, OUStringLiteral const & to, sal_Int32 * index = nullptr) const
2590  {
2592  rtl_uString * s = nullptr;
2593  sal_Int32 i = 0;
2595  &s, pData,
2598  to.size, index == nullptr ? &i : index);
2599  return OUString(s, SAL_NO_ACQUIRE);
2600  }
2602  template<typename T> SAL_WARN_UNUSED_RESULT
2603  typename
2605  replaceFirst(
2606  OUStringLiteral const & from, T & to, sal_Int32 * index = nullptr) const
2607  {
2609  rtl_uString * s = nullptr;
2610  sal_Int32 i = 0;
2612  &s, pData, from.data, from.size,
2615  index == nullptr ? &i : index);
2616  return OUString(s, SAL_NO_ACQUIRE);
2617  }
2619  template<typename T> SAL_WARN_UNUSED_RESULT
2620  typename
2622  replaceFirst(
2623  T & from, OUStringLiteral const & to, sal_Int32 * index = nullptr) const
2624  {
2626  rtl_uString * s = nullptr;
2627  sal_Int32 i = 0;
2629  &s, pData,
2632  to.size, index == nullptr ? &i : index);
2633  return OUString(s, SAL_NO_ACQUIRE);
2634  }
2635 #endif
2636 
2653  OUString const & from, OUString const & to, sal_Int32 fromIndex = 0) const
2654  {
2655  rtl_uString * s = NULL;
2656  rtl_uString_newReplaceAllFromIndex(&s, pData, from.pData, to.pData, fromIndex);
2657  return OUString(s, SAL_NO_ACQUIRE);
2658  }
2659 
2673  template< typename T >
2675  {
2677  rtl_uString * s = NULL;
2679  &s, pData,
2682  return OUString(s, SAL_NO_ACQUIRE);
2683  }
2684 
2698  template< typename T >
2700  {
2702  rtl_uString * s = NULL;
2704  &s, pData, from.pData,
2707  return OUString(s, SAL_NO_ACQUIRE);
2708  }
2709 
2723  template< typename T1, typename T2 >
2725  replaceAll( T1& from, T2& to ) const
2726  {
2729  rtl_uString * s = NULL;
2731  &s, pData,
2736  return OUString(s, SAL_NO_ACQUIRE);
2737  }
2738 
2739 #if defined LIBO_INTERNAL_ONLY
2740 
2741  template<typename T> SAL_WARN_UNUSED_RESULT
2742  typename
2744  replaceAll(T & from, OUString const & to) const {
2745  rtl_uString * s = nullptr;
2747  &s, pData,
2750  to.pData->buffer, to.pData->length);
2751  if (s == nullptr) {
2752  throw std::bad_alloc();
2753  // should be std::length_error if resulting would be too large
2754  }
2755  return OUString(s, SAL_NO_ACQUIRE);
2756  }
2758  template<typename T> SAL_WARN_UNUSED_RESULT
2759  typename
2761  replaceAll(OUString const & from, T & to) const {
2762  rtl_uString * s = nullptr;
2764  &s, pData, from.pData->buffer, from.pData->length,
2767  if (s == nullptr) {
2768  throw std::bad_alloc();
2769  // should be std::length_error if resulting would be too large
2770  }
2771  return OUString(s, SAL_NO_ACQUIRE);
2772  }
2774  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2775  typename
2777  T1,
2779  T2, OUString>::TypeUtf16
2780  >::TypeUtf16
2781  replaceAll(T1 & from, T2 & to) const {
2782  rtl_uString * s = nullptr;
2784  &s, pData,
2789  if (s == nullptr) {
2790  throw std::bad_alloc();
2791  // should be std::length_error if resulting would be too large
2792  }
2793  return OUString(s, SAL_NO_ACQUIRE);
2794  }
2796  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2797  typename
2799  T1,
2801  T2, OUString>::Type
2802  >::TypeUtf16
2803  replaceAll(T1 & from, T2 & to) const {
2804  rtl_uString * s = nullptr;
2806  &s, pData,
2811  if (s == nullptr) {
2812  throw std::bad_alloc();
2813  // should be std::length_error if resulting would be too large
2814  }
2815  return OUString(s, SAL_NO_ACQUIRE);
2816  }
2818  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2819  typename
2821  T1,
2823  T2, OUString>::TypeUtf16
2824  >::Type
2825  replaceAll(T1 & from, T2 & to) const {
2826  rtl_uString * s = nullptr;
2828  &s, pData,
2833  if (s == nullptr) {
2834  throw std::bad_alloc();
2835  // should be std::length_error if resulting would be too large
2836  }
2837  return OUString(s, SAL_NO_ACQUIRE);
2838  }
2839 
2841  SAL_WARN_UNUSED_RESULT OUString replaceAll(
2842  OUStringLiteral const & from, OUString const & to) const
2843  {
2844  rtl_uString * s = nullptr;
2846  &s, pData, from.data, from.size, to.pData);
2847  return OUString(s, SAL_NO_ACQUIRE);
2848  }
2850  SAL_WARN_UNUSED_RESULT OUString replaceAll(
2851  OUString const & from, OUStringLiteral const & to) const
2852  {
2853  rtl_uString * s = nullptr;
2855  &s, pData, from.pData, to.data, to.size);
2856  return OUString(s, SAL_NO_ACQUIRE);
2857  }
2859  SAL_WARN_UNUSED_RESULT OUString replaceAll(
2860  OUStringLiteral const & from, OUStringLiteral const & to) const
2861  {
2862  rtl_uString * s = nullptr;
2864  &s, pData, from.data, from.size, to.data, to.size);
2865  return OUString(s, SAL_NO_ACQUIRE);
2866  }
2868  template<typename T> SAL_WARN_UNUSED_RESULT
2870  replaceAll(OUStringLiteral const & from, T & to) const {
2872  rtl_uString * s = nullptr;
2874  &s, pData, from.data, from.size,
2877  return OUString(s, SAL_NO_ACQUIRE);
2878  }
2880  template<typename T> SAL_WARN_UNUSED_RESULT
2882  replaceAll(T & from, OUStringLiteral const & to) const {
2884  rtl_uString * s = nullptr;
2886  &s, pData,
2889  to.size);
2890  return OUString(s, SAL_NO_ACQUIRE);
2891  }
2893  template<typename T> SAL_WARN_UNUSED_RESULT
2894  typename
2896  replaceAll(OUStringLiteral const & from, T & to) const {
2898  rtl_uString * s = nullptr;
2900  &s, pData, from.data, from.size,
2903  return OUString(s, SAL_NO_ACQUIRE);
2904  }
2906  template<typename T> SAL_WARN_UNUSED_RESULT
2907  typename
2909  replaceAll(T & from, OUStringLiteral const & to) const {
2911  rtl_uString * s = nullptr;
2913  &s, pData,
2916  to.size);
2917  return OUString(s, SAL_NO_ACQUIRE);
2918  }
2919 #endif
2920 
2932  {
2933  rtl_uString* pNew = NULL;
2934  rtl_uString_newToAsciiLowerCase( &pNew, pData );
2935  return OUString( pNew, SAL_NO_ACQUIRE );
2936  }
2937 
2949  {
2950  rtl_uString* pNew = NULL;
2951  rtl_uString_newToAsciiUpperCase( &pNew, pData );
2952  return OUString( pNew, SAL_NO_ACQUIRE );
2953  }
2954 
2967  {
2968  rtl_uString* pNew = NULL;
2969  rtl_uString_newTrim( &pNew, pData );
2970  return OUString( pNew, SAL_NO_ACQUIRE );
2971  }
2972 
2997  OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const
2998  {
2999  rtl_uString * pNew = NULL;
3000  index = rtl_uString_getToken( &pNew, pData, token, cTok, index );
3001  return OUString( pNew, SAL_NO_ACQUIRE );
3002  }
3003 
3017  OUString getToken(sal_Int32 count, sal_Unicode separator) const {
3018  sal_Int32 n = 0;
3019  return getToken(count, separator, n);
3020  }
3021 
3030  bool toBoolean() const
3031  {
3032  return rtl_ustr_toBoolean( pData->buffer );
3033  }
3034 
3042  {
3043  return pData->buffer[0];
3044  }
3045 
3056  sal_Int32 toInt32( sal_Int16 radix = 10 ) const
3057  {
3058  return rtl_ustr_toInt32( pData->buffer, radix );
3059  }
3060 
3073  sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
3074  {
3075  return rtl_ustr_toUInt32( pData->buffer, radix );
3076  }
3077 
3088  sal_Int64 toInt64( sal_Int16 radix = 10 ) const
3089  {
3090  return rtl_ustr_toInt64( pData->buffer, radix );
3091  }
3092 
3105  sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
3106  {
3107  return rtl_ustr_toUInt64( pData->buffer, radix );
3108  }
3109 
3118  float toFloat() const
3119  {
3120  return rtl_ustr_toFloat( pData->buffer );
3121  }
3122 
3131  double toDouble() const
3132  {
3133  return rtl_ustr_toDouble( pData->buffer );
3134  }
3135 
3136 
3153  {
3154  rtl_uString * pNew = NULL;
3155  rtl_uString_intern( &pNew, pData );
3156  if (pNew == NULL) {
3157  throw std::bad_alloc();
3158  }
3159  return OUString( pNew, SAL_NO_ACQUIRE );
3160  }
3161 
3187  static OUString intern( const sal_Char * value, sal_Int32 length,
3188  rtl_TextEncoding encoding,
3189  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS,
3190  sal_uInt32 *pInfo = NULL )
3191  {
3192  rtl_uString * pNew = NULL;
3193  rtl_uString_internConvert( &pNew, value, length, encoding,
3194  convertFlags, pInfo );
3195  if (pNew == NULL) {
3196  throw std::bad_alloc();
3197  }
3198  return OUString( pNew, SAL_NO_ACQUIRE );
3199  }
3200 
3225  bool convertToString(OString * pTarget, rtl_TextEncoding nEncoding,
3226  sal_uInt32 nFlags) const
3227  {
3228  return rtl_convertUStringToString(&pTarget->pData, pData->buffer,
3229  pData->length, nEncoding, nFlags);
3230  }
3231 
3283  sal_uInt32 iterateCodePoints(
3284  sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1) const
3285  {
3287  pData, indexUtf16, incrementCodePoints);
3288  }
3289 
3299  static OUString fromUtf8(const OString& rSource)
3300  {
3301  OUString aTarget;
3302  bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
3303  rSource.getStr(),
3304  rSource.getLength(),
3307  (void) bSuccess;
3308  assert(bSuccess);
3309  return aTarget;
3310  }
3311 
3322  OString toUtf8() const
3323  {
3324  OString aTarget;
3325  bool bSuccess = rtl_convertUStringToString(&aTarget.pData,
3326  getStr(),
3327  getLength(),
3330  (void) bSuccess;
3331  assert(bSuccess);
3332  return aTarget;
3333  }
3334 
3345  static OUString number( int i, sal_Int16 radix = 10 )
3346  {
3348  rtl_uString* pNewData = NULL;
3349  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt32( aBuf, i, radix ) );
3350  return OUString( pNewData, SAL_NO_ACQUIRE );
3351  }
3354  static OUString number( unsigned int i, sal_Int16 radix = 10 )
3355  {
3356  return number( static_cast< unsigned long long >( i ), radix );
3357  }
3360  static OUString number( long i, sal_Int16 radix = 10)
3361  {
3362  return number( static_cast< long long >( i ), radix );
3363  }
3366  static OUString number( unsigned long i, sal_Int16 radix = 10 )
3367  {
3368  return number( static_cast< unsigned long long >( i ), radix );
3369  }
3372  static OUString number( long long ll, sal_Int16 radix = 10 )
3373  {
3375  rtl_uString* pNewData = NULL;
3376  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt64( aBuf, ll, radix ) );
3377  return OUString( pNewData, SAL_NO_ACQUIRE );
3378  }
3381  static OUString number( unsigned long long ll, sal_Int16 radix = 10 )
3382  {
3384  rtl_uString* pNewData = NULL;
3385  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfUInt64( aBuf, ll, radix ) );
3386  return OUString( pNewData, SAL_NO_ACQUIRE );
3387  }
3388 
3398  static OUString number( float f )
3399  {
3401  rtl_uString* pNewData = NULL;
3402  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfFloat( aBuf, f ) );
3403  return OUString( pNewData, SAL_NO_ACQUIRE );
3404  }
3405 
3415  static OUString number( double d )
3416  {
3418  rtl_uString* pNewData = NULL;
3419  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfDouble( aBuf, d ) );
3420  return OUString( pNewData, SAL_NO_ACQUIRE );
3421  }
3422 
3434  SAL_DEPRECATED("use boolean()") static OUString valueOf( sal_Bool b )
3435  {
3436  return boolean(b);
3437  }
3438 
3450  static OUString boolean( bool b )
3451  {
3453  rtl_uString* pNewData = NULL;
3454  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfBoolean( aBuf, b ) );
3455  return OUString( pNewData, SAL_NO_ACQUIRE );
3456  }
3457 
3465  SAL_DEPRECATED("convert to OUString or use directly") static OUString valueOf( sal_Unicode c )
3466  {
3467  return OUString( &c, 1 );
3468  }
3469 
3480  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
3481  {
3482  return number( i, radix );
3483  }
3484 
3495  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
3496  {
3497  return number( ll, radix );
3498  }
3499 
3509  SAL_DEPRECATED("use number()") static OUString valueOf( float f )
3510  {
3511  return number(f);
3512  }
3513 
3523  SAL_DEPRECATED("use number()") static OUString valueOf( double d )
3524  {
3525  return number(d);
3526  }
3527 
3543  static OUString createFromAscii( const sal_Char * value )
3544  {
3545  rtl_uString* pNew = NULL;
3546  rtl_uString_newFromAscii( &pNew, value );
3547  return OUString( pNew, SAL_NO_ACQUIRE );
3548  }
3549 };
3550 
3551 #if defined LIBO_INTERNAL_ONLY
3552 // Prevent the operator ==/!= overloads with 'sal_Unicode const *' parameter from
3553 // being selected for nonsensical code like
3554 //
3555 // if (ouIdAttr == nullptr)
3556 //
3557 void operator ==(OUString const &, std::nullptr_t) = delete;
3558 void operator ==(std::nullptr_t, OUString const &) = delete;
3559 void operator !=(OUString const &, std::nullptr_t) = delete;
3560 void operator !=(std::nullptr_t, OUString const &) = delete;
3561 #endif
3562 
3563 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3564 
3569 template<>
3570 struct ToStringHelper< OUString >
3571  {
3572  static int length( const OUString& s ) { return s.getLength(); }
3573  static sal_Unicode* addData( sal_Unicode* buffer, const OUString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
3574  static const bool allowOStringConcat = false;
3575  static const bool allowOUStringConcat = true;
3576  };
3577 
3581 template<>
3582 struct ToStringHelper< OUStringLiteral >
3583  {
3584  static int length( const OUStringLiteral& str ) { return str.size; }
3585  static sal_Unicode* addData( sal_Unicode* buffer, const OUStringLiteral& str ) { return addDataLiteral( buffer, str.data, str.size ); }
3586  static const bool allowOStringConcat = false;
3587  static const bool allowOUStringConcat = true;
3588  };
3589 
3593 template< typename charT, typename traits, typename T1, typename T2 >
3594 inline std::basic_ostream<charT, traits> & operator <<(
3595  std::basic_ostream<charT, traits> & stream, const OUStringConcat< T1, T2 >& concat)
3596 {
3597  return stream << OUString( concat );
3598 }
3599 
3601 #endif
3602 
3609 {
3619  size_t operator()(const OUString& rString) const
3620  { return (size_t)rString.hashCode(); }
3621 };
3622 
3623 /* ======================================================================= */
3624 
3642 inline OUString OStringToOUString( const OString & rStr,
3643  rtl_TextEncoding encoding,
3644  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
3645 {
3646  return OUString( rStr.getStr(), rStr.getLength(), encoding, convertFlags );
3647 }
3648 
3666 inline OString OUStringToOString( const OUString & rUnicode,
3667  rtl_TextEncoding encoding,
3668  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
3669 {
3670  return OString( rUnicode.getStr(), rUnicode.getLength(), encoding, convertFlags );
3671 }
3672 
3673 /* ======================================================================= */
3674 
3683 template< typename charT, typename traits >
3684 inline std::basic_ostream<charT, traits> & operator <<(
3685  std::basic_ostream<charT, traits> & stream, OUString const & rString)
3686 {
3687  return stream <<
3689  // best effort; potentially loses data due to conversion failures
3690  // (stray surrogate halves) and embedded null characters
3691 }
3692 
3693 } // namespace
3694 
3695 #ifdef RTL_STRING_UNITTEST
3696 namespace rtl
3697 {
3698 typedef rtlunittest::OUString OUString;
3699 }
3700 #endif
3701 
3702 // In internal code, allow to use classes like OUString without having to
3703 // explicitly refer to the rtl namespace, which is kind of superfluous given
3704 // that OUString itself is namespaced by its OU prefix:
3705 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3706 using ::rtl::OUString;
3707 using ::rtl::OUStringHash;
3710 using ::rtl::OUStringLiteral;
3711 using ::rtl::OUStringLiteral1;
3712 #endif
3713 
3714 #endif /* _RTL_USTRING_HXX */
3715 
3716 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 lastIndexOf(const OUString &str) const
Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the end.
Definition: ustring.hxx:2102
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
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.
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:981
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...
static OUString createFromAscii(const sal_Char *value)
Returns a OUString copied without conversion from an ASCII character string.
Definition: ustring.hxx:3543
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_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:2185
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:39
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:653
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:3366
bool equalsAscii(const sal_Char *asciiStr) const
Perform a comparison of two strings.
Definition: ustring.hxx:1113
#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.
SAL_DLLPUBLIC void rtl_uString_newReplaceAllUtf16LAsciiL(rtl_uString **newStr, rtl_uString *str, sal_Unicode const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
SAL_DLLPUBLIC 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.
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: ustring.hxx:3056
SAL_DLLPUBLIC sal_Bool rtl_ustr_toBoolean(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
SAL_DLLPUBLIC void rtl_uString_newReplaceFirst(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, rtl_uString const *to, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
SAL_DLLPUBLIC void rtl_uString_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...
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:2220
SAL_DLLPUBLIC sal_Int32 rtl_ustr_hashCode_WithLength(const sal_Unicode *str, sal_Int32 len) SAL_THROW_EXTERN_C()
Return a hash code for a string.
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWithIgnoreAsciiCase(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1414
#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.
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:1278
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...
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: ustring.hxx:630
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfFloat(sal_Unicode *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
OUString intern() const
Return a canonical representation for a string.
Definition: ustring.hxx:3152
SAL_DLLPUBLIC void rtl_uString_newFromSubString(rtl_uString **newStr, const rtl_uString *from, sal_Int32 beginIndex, sal_Int32 count) SAL_THROW_EXTERN_C()
Allocate a new string that is a substring of this string.
sal_Int32 compareToIgnoreAsciiCaseAscii(const sal_Char *asciiStr) const
Compares two ASCII strings ignoring case.
Definition: ustring.hxx:1186
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.
static OUString number(double d)
Returns the string representation of the double argument.
Definition: ustring.hxx:3415
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.
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:3381
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1783
OUString(rtl_uString *str)
New string from OUString data.
Definition: ustring.hxx:169
#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.
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:1999
const sal_Char * getStr() const
Returns a pointer to the characters of this string.
Definition: string.hxx:435
bool convertToString(OString *pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) const
Converts to an OString, signalling failure.
Definition: ustring.hxx:3225
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfInt32(sal_Unicode *str, sal_Int32 i, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an integer.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters, ignoring the case of ASCII characters...
double toDouble() const
Returns the double value from this string.
Definition: ustring.hxx:3131
bool toBoolean() const
Returns the Boolean value from this string.
Definition: ustring.hxx:3030
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.
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1767
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: ustring.hxx:1929
bool equals(const OUString &str) const
Perform a comparison of two strings.
Definition: ustring.hxx:785
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWith(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1321
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:2652
#define RTL_TEXTENCODING_UTF8
Definition: textenc.h:121
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:911
#define RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR
Definition: textcvt.h:71
SAL_DLLPUBLIC void rtl_uString_newFromStr(rtl_uString **newStr, const sal_Unicode *value) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don&#39;t use, it&#39;s evil.") void doit(int nPara);.
Definition: types.h:483
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:598
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:1240
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfInt64(sal_Unicode *str, sal_Int64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of a long integer.
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:847
SAL_DLLPUBLIC sal_Int32 rtl_ustr_reverseCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings from back to front.
#define RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR
Definition: textcvt.h:134
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type reverseCompareTo(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:745
sal_Int32 compareTo(const OUString &str, sal_Int32 maxLength) const
Compares two strings with a maximum count of characters.
Definition: ustring.hxx:715
static OUString fromUtf8(const OString &rSource)
Convert an OString to an OUString, assuming that the OString is UTF-8-encoded.
Definition: ustring.hxx:3299
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.
#define RTL_USTR_MAX_VALUEOFBOOLEAN
Definition: ustring.h:915
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:2071
OUString(rtl_uString *str, __sal_NoAcquire)
New OUString from OUString data without acquiring it.
Definition: ustring.hxx:183
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfDouble(sal_Unicode *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
static OUString number(float f)
Returns the string representation of the float argument.
Definition: ustring.hxx:3398
SAL_DLLPUBLIC void rtl_uString_newReplaceAllAsciiLUtf16L(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, sal_Unicode const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
SAL_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:2674
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1735
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...
bool equalsIgnoreAsciiCaseAscii(const sal_Char *asciiStr) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1163
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.
OUString(const OUString &str)
New string from OUString.
Definition: ustring.hxx:141
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...
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:95
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:2966
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: ustring.hxx:3088
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.
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:96
sal_uInt16 sal_Unicode
Definition: types.h:142
sal_Int32 compareTo(const OUString &str) const
Compares two strings.
Definition: ustring.hxx:694
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:968
bool equalsIgnoreAsciiCase(const OUString &str) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:809
bool match(const OUString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:899
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:2369
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:128
unsigned char sal_Bool
Definition: types.h:39
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type lastIndexOf(T &literal) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:2137
__sal_NoAcquire
Definition: types.h:366
sal_Int32 compareToIgnoreAsciiCase(const OUString &str) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:834
static OUString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: ustring.hxx:3345
bool startsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: ustring.hxx:1307
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1751
OUString getToken(sal_Int32 token, sal_Unicode cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: ustring.hxx:2997
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:473
#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:1573
bool equalsIgnoreAsciiCaseAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1211
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:2931
sal_Int32 compareToAscii(const sal_Char *asciiStr) const
Compares two strings.
Definition: ustring.hxx:1038
static OUString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: ustring.hxx:3450
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfChar_WithLength(const sal_Unicode *str, sal_Int32 len, sal_Unicode ch) SAL_THROW_EXTERN_C()
Search for the last occurrence of a character within a string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_compare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings.
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:3360
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:2699
OUString(sal_uInt32 const *codePoints, sal_Int32 codePointCount)
Create a new string from an array of Unicode code points.
Definition: ustring.hxx:378
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:2262
OUString(const sal_Unicode *value, sal_Int32 length)
New string from a Unicode character buffer array.
Definition: ustring.hxx:227
sal_Int32 reverseCompareTo(const OUString &str) const
Compares two strings in reverse order.
Definition: ustring.hxx:733
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:116
OUString & operator=(const OUString &str)
Assign a new string.
Definition: ustring.hxx:435
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:3666
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...
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:249
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:1979
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:1694
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:2125
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:2403
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:633
definition of a no acquire enum for ctors
Definition: types.h:370
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.
size_t operator()(const OUString &rString) const
Compute a hash code for a string.
Definition: ustring.hxx:3619
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_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:2725
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:1602
bool endsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string ends with a given substring.
Definition: ustring.hxx:1484
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfBoolean(sal_Unicode *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type endsWith(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1500
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.
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: ustring.hxx:3105
float toFloat() const
Returns the float value from this string.
Definition: ustring.hxx:3118
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:120
SAL_WARN_UNUSED_RESULT OUString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: ustring.hxx:2201
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:351
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfStr_WithLength(const sal_Unicode *str, sal_Int32 len, const sal_Unicode *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of a substring within a string.
SAL_DLLPUBLIC sal_Bool rtl_convertStringToUString(rtl_uString **target, char const *source, sal_Int32 length, rtl_TextEncoding encoding, sal_uInt32 flags) SAL_THROW_EXTERN_C()
Converts a byte string to a Unicode string, signalling failure.
SAL_WARN_UNUSED_RESULT 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:2282
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:3187
sal_Int32 reverseCompareToAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Compares two strings in reverse order.
Definition: ustring.hxx:1092
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:1899
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:307
char sal_Char
A legacy synonym for char.
Definition: types.h:121
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition: ustring.hxx:523
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:3642
#define RTL_USTR_MAX_VALUEOFFLOAT
Definition: ustring.h:1022
SAL_DLLPUBLIC void rtl_uString_newFromLiteral(rtl_uString **newStr, const sal_Char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf(T &literal, sal_Int32 fromIndex=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:2012
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:106
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstAsciiLAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
SAL_WARN_UNUSED_RESULT 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:2336
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:2307
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:2948
OUString getToken(sal_Int32 count, sal_Unicode separator) const
Returns a token from the string.
Definition: ustring.hxx:3017
OUString(sal_Unicode value)
New string from a single Unicode character.
Definition: ustring.hxx:191
#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_Unicode toChar() const
Returns the first character from this string.
Definition: ustring.hxx:3041
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.
Definition: stringutils.hxx:115
OUString(const sal_Unicode *value)
New string from a Unicode character buffer array.
Definition: ustring.hxx:213
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.
const sal_Unicode * getStr() const
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:665
bool equalsAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform a comparison of two strings.
Definition: ustring.hxx:1136
SAL_DLLPUBLIC void rtl_uString_internConvert(rtl_uString **newStr, const sal_Char *str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags, sal_uInt32 *pInfo) SAL_THROW_EXTERN_C()
Return a canonical representation for a string.
sal_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:1947
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_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:1962
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.
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:409
static OUString const & unacquired(rtl_uString *const *ppHandle)
Provides an OUString const & passing a storage pointer of an rtl_uString * handle.
Definition: ustring.hxx:427
Definition: bootstrap.hxx:29
SAL_WARN_UNUSED_RESULT OUString concat(const OUString &str) const
Concatenates the specified string to the end of this string.
Definition: ustring.hxx:2235
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:1397
friend OUString operator+(const OUString &rStr1, const OUString &rStr2)
Definition: ustring.hxx:2243
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()
New string containing no characters.
Definition: ustring.hxx:130
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:3283
sal_Int32 getLength() const
Returns the length of this string.
Definition: ustring.hxx:643
SAL_DLLPUBLIC sal_Int32 rtl_ustr_toInt32(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an integer.
static OUString 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:3354
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.
#define OSTRING_TO_OUSTRING_CVTFLAGS
Definition: ustring.h:2117
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: ustring.hxx:3073
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.
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:3372
SAL_DLLPUBLIC rtl_uString * rtl_uString_alloc(sal_Int32 nLen) SAL_THROW_EXTERN_C()
Allocate a new string containing space for a given number of characters.
SAL_DLLPUBLIC 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.
A helper to use OUStrings with hash maps.
Definition: ustring.hxx:3608
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.
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type endsWithIgnoreAsciiCase(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1619
~OUString()
Release the string data.
Definition: ustring.hxx:411
OString toUtf8() const
Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully.
Definition: ustring.hxx:3322
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.