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 <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 
525  OUString & operator+=( const OUString & str )
526 #if defined LIBO_INTERNAL_ONLY
527  &
528 #endif
529  {
530  rtl_uString* pNewData = NULL;
531  rtl_uString_newConcat( &pNewData, pData, str.pData );
532  if (pNewData == NULL) {
533  throw std::bad_alloc();
534  }
535  rtl_uString_assign(&pData, pNewData);
536  rtl_uString_release(pNewData);
537  return *this;
538  }
539 #if defined LIBO_INTERNAL_ONLY
540  void operator+=(OUString const &) && = delete;
541 #endif
542 
549  template<typename T>
551  operator +=(T & literal)
552 #if defined LIBO_INTERNAL_ONLY
553  &
554 #endif
555  {
556  assert(
559  &pData, pData,
562  return *this;
563  }
564 #if defined LIBO_INTERNAL_ONLY
565  template<typename T>
567  operator +=(T &) && = delete;
568 #endif
569 
570 #if defined LIBO_INTERNAL_ONLY
571 
572  template<typename T>
573  typename
575  operator +=(T & literal) & {
577  &pData, pData,
580  return *this;
581  }
582  template<typename T>
583  typename
585  operator +=(T &) && = delete;
586 
588  OUString & operator +=(OUStringLiteral const & literal) & {
589  rtl_uString_newConcatAsciiL(&pData, pData, literal.data, literal.size);
590  return *this;
591  }
592  void operator +=(OUStringLiteral const &) && = delete;
593 #endif
594 
595 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
596 
600  template< typename T1, typename T2 >
601  OUString& operator+=( const OUStringConcat< T1, T2 >& c ) & {
602  sal_Int32 l = c.length();
603  if( l == 0 )
604  return *this;
605  l += pData->length;
606  rtl_uString_ensureCapacity( &pData, l );
607  sal_Unicode* end = c.addData( pData->buffer + pData->length );
608  *end = '\0';
609  pData->length = l;
610  return *this;
611  }
612  template<typename T1, typename T2> void operator +=(
613  OUStringConcat<T1, T2> const &) && = delete;
614 #endif
615 
620  void clear()
621  {
622  rtl_uString_new( &pData );
623  }
624 
633  sal_Int32 getLength() const { return pData->length; }
634 
643  bool isEmpty() const
644  {
645  return pData->length == 0;
646  }
647 
655  const sal_Unicode * getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
656 
666  sal_Unicode operator [](sal_Int32 index) const {
667  // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
668  assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
669  return getStr()[index];
670  }
671 
684  sal_Int32 compareTo( const OUString & str ) const
685  {
686  return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
687  str.pData->buffer, str.pData->length );
688  }
689 
705  sal_Int32 compareTo( const OUString & str, sal_Int32 maxLength ) const
706  {
707  return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
708  str.pData->buffer, str.pData->length, maxLength );
709  }
710 
723  sal_Int32 reverseCompareTo( const OUString & str ) const
724  {
725  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
726  str.pData->buffer, str.pData->length );
727  }
728 
734  template< typename T >
736  {
737  assert(
740  pData->buffer, pData->length,
743  }
744 
745 #if defined LIBO_INTERNAL_ONLY
746 
747  template<typename T>
748  typename
750  reverseCompareTo(T & literal) const {
752  pData->buffer, pData->length,
755  }
756 
758  sal_Int32 reverseCompareTo(OUStringLiteral const & literal) const {
760  pData->buffer, pData->length, literal.data, literal.size);
761  }
762 #endif
763 
775  bool equals( const OUString & str ) const
776  {
777  if ( pData->length != str.pData->length )
778  return false;
779  if ( pData == str.pData )
780  return true;
781  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
782  str.pData->buffer, str.pData->length ) == 0;
783  }
784 
799  bool equalsIgnoreAsciiCase( const OUString & str ) const
800  {
801  if ( pData->length != str.pData->length )
802  return false;
803  if ( pData == str.pData )
804  return true;
805  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
806  str.pData->buffer, str.pData->length ) == 0;
807  }
808 
824  sal_Int32 compareToIgnoreAsciiCase( const OUString & str ) const
825  {
826  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
827  str.pData->buffer, str.pData->length );
828  }
829 
830 
836  template< typename T >
838  {
839  assert(
841  return
842  (pData->length
845  pData->buffer, pData->length,
847  literal))
848  == 0);
849  }
850 
851 #if defined LIBO_INTERNAL_ONLY
852 
853  template<typename T>
855  equalsIgnoreAsciiCase(T & literal) const {
856  return
858  pData->buffer, pData->length,
860  literal),
862  == 0;
863  }
864 
866  bool equalsIgnoreAsciiCase(OUStringLiteral const & literal) const {
867  return pData->length == literal.size
869  pData->buffer, pData->length, literal.data)
870  == 0);
871  }
872 #endif
873 
889  bool match( const OUString & str, sal_Int32 fromIndex = 0 ) const
890  {
891  return rtl_ustr_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
892  str.pData->buffer, str.pData->length, str.pData->length ) == 0;
893  }
894 
900  template< typename T >
901  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
902  {
903  assert(
905  return
907  pData->buffer+fromIndex, pData->length-fromIndex,
909  literal),
911  == 0;
912  }
913 
914 #if defined LIBO_INTERNAL_ONLY
915 
916  template<typename T>
918  match(T & literal, sal_Int32 fromIndex = 0) const {
919  assert(fromIndex >= 0);
920  return
922  pData->buffer + fromIndex, pData->length - fromIndex,
924  literal),
927  == 0;
928  }
929 
931  bool match(OUStringLiteral const & literal, sal_Int32 fromIndex = 0) const {
932  return
934  pData->buffer + fromIndex, pData->length - fromIndex,
935  literal.data, literal.size)
936  == 0;
937  }
938 #endif
939 
958  bool matchIgnoreAsciiCase( const OUString & str, sal_Int32 fromIndex = 0 ) const
959  {
960  return rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
961  str.pData->buffer, str.pData->length,
962  str.pData->length ) == 0;
963  }
964 
970  template< typename T >
971  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
972  {
973  assert(
975  return
977  pData->buffer+fromIndex, pData->length-fromIndex,
979  literal),
981  == 0;
982  }
983 
984 #if defined LIBO_INTERNAL_ONLY
985 
986  template<typename T>
988  matchIgnoreAsciiCase(T & literal, sal_Int32 fromIndex = 0) const {
989  assert(fromIndex >= 0);
990  return
992  pData->buffer + fromIndex, pData->length - fromIndex,
994  literal),
997  == 0;
998  }
999 
1001  bool matchIgnoreAsciiCase(
1002  OUStringLiteral const & literal, sal_Int32 fromIndex = 0) const
1003  {
1004  return
1006  pData->buffer+fromIndex, pData->length-fromIndex, literal.data,
1007  literal.size)
1008  == 0;
1009  }
1010 #endif
1011 
1028  sal_Int32 compareToAscii( const sal_Char* asciiStr ) const
1029  {
1030  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length, asciiStr );
1031  }
1032 
1056  "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
1057  sal_Int32 compareToAscii( const sal_Char * asciiStr, sal_Int32 maxLength ) const
1058  {
1059  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer, pData->length,
1060  asciiStr, maxLength );
1061  }
1062 
1082  sal_Int32 reverseCompareToAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
1083  {
1084  return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
1085  asciiStr, asciiStrLength );
1086  }
1087 
1103  bool equalsAscii( const sal_Char* asciiStr ) const
1104  {
1105  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length,
1106  asciiStr ) == 0;
1107  }
1108 
1126  bool equalsAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength ) const
1127  {
1128  if ( pData->length != asciiStrLength )
1129  return false;
1130 
1132  pData->buffer, asciiStr, asciiStrLength );
1133  }
1134 
1153  bool equalsIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const
1154  {
1155  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1156  }
1157 
1176  sal_Int32 compareToIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const
1177  {
1178  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr );
1179  }
1180 
1201  bool equalsIgnoreAsciiCaseAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
1202  {
1203  if ( pData->length != asciiStrLength )
1204  return false;
1205 
1206  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1207  }
1208 
1230  bool matchAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1231  {
1232  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1233  asciiStr, asciiStrLength ) == 0;
1234  }
1235 
1236  // This overload is left undefined, to detect calls of matchAsciiL that
1237  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1238  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1239  // platforms):
1240 #if SAL_TYPES_SIZEOFLONG == 8
1241  void matchAsciiL(char const *, sal_Int32, rtl_TextEncoding) const;
1242 #endif
1243 
1268  bool matchIgnoreAsciiCaseAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1269  {
1270  return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1271  asciiStr, asciiStrLength ) == 0;
1272  }
1273 
1274  // This overload is left undefined, to detect calls of
1275  // matchIgnoreAsciiCaseAsciiL that erroneously use
1276  // RTL_CONSTASCII_USTRINGPARAM instead of RTL_CONSTASCII_STRINGPARAM (but
1277  // would lead to ambiguities on 32 bit platforms):
1278 #if SAL_TYPES_SIZEOFLONG == 8
1279  void matchIgnoreAsciiCaseAsciiL(char const *, sal_Int32, rtl_TextEncoding)
1280  const;
1281 #endif
1282 
1297  bool startsWith(OUString const & str, OUString * rest = NULL) const {
1298  bool b = match(str);
1299  if (b && rest != NULL) {
1300  *rest = copy(str.getLength());
1301  }
1302  return b;
1303  }
1304 
1310  template< typename T >
1312  T & literal, OUString * rest = NULL) const
1313  {
1314  assert(
1316  bool b
1318  <= sal_uInt32(pData->length))
1320  pData->buffer,
1322  literal),
1324  if (b && rest != NULL) {
1325  *rest = copy(
1327  }
1328  return b;
1329  }
1330 
1331 #if defined LIBO_INTERNAL_ONLY
1332 
1333  template<typename T>
1335  startsWith(T & literal, OUString * rest = nullptr) const {
1336  bool b
1338  <= sal_uInt32(pData->length))
1340  pData->buffer,
1343  literal),
1345  == 0);
1346  if (b && rest != nullptr) {
1347  *rest = copy(
1349  }
1350  return b;
1351  }
1352 
1354  bool startsWith(OUStringLiteral const & literal, OUString * rest = nullptr)
1355  const
1356  {
1357  bool b = literal.size <= pData->length
1359  pData->buffer, literal.data, literal.size);
1360  if (b && rest != nullptr) {
1361  *rest = copy(literal.size);
1362  }
1363  return b;
1364  }
1365 #endif
1366 
1387  bool startsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL)
1388  const
1389  {
1390  bool b = matchIgnoreAsciiCase(str);
1391  if (b && rest != NULL) {
1392  *rest = copy(str.getLength());
1393  }
1394  return b;
1395  }
1396 
1402  template< typename T >
1404  startsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1405  {
1406  assert(
1408  bool b
1410  pData->buffer,
1413  literal),
1415  == 0);
1416  if (b && rest != NULL) {
1417  *rest = copy(
1419  }
1420  return b;
1421  }
1422 
1423 #if defined LIBO_INTERNAL_ONLY
1424 
1425  template<typename T>
1427  startsWithIgnoreAsciiCase(T & literal, OUString * rest = nullptr) const {
1428  bool b
1430  <= sal_uInt32(pData->length))
1432  pData->buffer,
1435  literal),
1437  == 0);
1438  if (b && rest != nullptr) {
1439  *rest = copy(
1441  }
1442  return b;
1443  }
1444 
1446  bool startsWithIgnoreAsciiCase(
1447  OUStringLiteral const & literal, OUString * rest = nullptr) const
1448  {
1449  bool b
1451  pData->buffer, literal.size, literal.data, literal.size)
1452  == 0);
1453  if (b && rest != nullptr) {
1454  *rest = copy(literal.size);
1455  }
1456  return b;
1457  }
1458 #endif
1459 
1474  bool endsWith(OUString const & str, OUString * rest = NULL) const {
1475  bool b = str.getLength() <= getLength()
1476  && match(str, getLength() - str.getLength());
1477  if (b && rest != NULL) {
1478  *rest = copy(0, getLength() - str.getLength());
1479  }
1480  return b;
1481  }
1482 
1488  template< typename T >
1490  endsWith(T & literal, OUString * rest = NULL) const
1491  {
1492  assert(
1494  bool b
1496  <= sal_uInt32(pData->length))
1498  (pData->buffer + pData->length
1501  literal),
1503  if (b && rest != NULL) {
1504  *rest = copy(
1505  0,
1506  (getLength()
1508  }
1509  return b;
1510  }
1511 
1512 #if defined LIBO_INTERNAL_ONLY
1513 
1514  template<typename T>
1516  endsWith(T & literal, OUString * rest = nullptr) const {
1517  bool b
1519  <= sal_uInt32(pData->length))
1521  (pData->buffer + pData->length
1525  literal),
1527  == 0);
1528  if (b && rest != nullptr) {
1529  *rest = copy(
1530  0,
1531  (getLength()
1533  }
1534  return b;
1535  }
1536 
1538  bool endsWith(OUStringLiteral const & literal, OUString * rest = nullptr)
1539  const
1540  {
1541  bool b = literal.size <= pData->length
1543  pData->buffer + pData->length - literal.size,
1544  literal.data, literal.size);
1545  if (b && rest != nullptr) {
1546  *rest = copy(0, (getLength() - literal.size));
1547  }
1548  return b;
1549  }
1550 #endif
1551 
1563  bool endsWithAsciiL(char const * asciiStr, sal_Int32 asciiStrLength)
1564  const
1565  {
1566  return asciiStrLength <= pData->length
1568  pData->buffer + pData->length - asciiStrLength, asciiStr,
1569  asciiStrLength);
1570  }
1571 
1592  bool endsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL) const
1593  {
1594  bool b = str.getLength() <= getLength()
1595  && matchIgnoreAsciiCase(str, getLength() - str.getLength());
1596  if (b && rest != NULL) {
1597  *rest = copy(0, getLength() - str.getLength());
1598  }
1599  return b;
1600  }
1601 
1607  template< typename T >
1609  endsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1610  {
1611  assert(
1613  bool b
1615  <= sal_uInt32(pData->length))
1617  (pData->buffer + pData->length
1621  literal),
1623  == 0);
1624  if (b && rest != NULL) {
1625  *rest = copy(
1626  0,
1627  (getLength()
1629  }
1630  return b;
1631  }
1632 
1633 #if defined LIBO_INTERNAL_ONLY
1634 
1635  template<typename T>
1637  endsWithIgnoreAsciiCase(T & literal, OUString * rest = nullptr) const {
1638  bool b
1640  <= sal_uInt32(pData->length))
1642  (pData->buffer + pData->length
1646  literal),
1648  == 0);
1649  if (b && rest != nullptr) {
1650  *rest = copy(
1651  0,
1652  (getLength()
1654  }
1655  return b;
1656  }
1657 
1659  bool endsWithIgnoreAsciiCase(
1660  OUStringLiteral const & literal, OUString * rest = nullptr) const
1661  {
1662  bool b = literal.size <= pData->length
1664  pData->buffer + pData->length - literal.size,
1665  literal.size, literal.data, literal.size)
1666  == 0);
1667  if (b && rest != nullptr) {
1668  *rest = copy(0, getLength() - literal.size);
1669  }
1670  return b;
1671  }
1672 #endif
1673 
1685  char const * asciiStr, sal_Int32 asciiStrLength) const
1686  {
1687  return asciiStrLength <= pData->length
1689  pData->buffer + pData->length - asciiStrLength,
1690  asciiStrLength, asciiStr, asciiStrLength)
1691  == 0);
1692  }
1693 
1694  friend bool operator == ( const OUString& rStr1, const OUString& rStr2 )
1695  { return rStr1.equals(rStr2); }
1696  friend bool operator == ( const OUString& rStr1, const sal_Unicode * pStr2 )
1697  { return rStr1.compareTo( pStr2 ) == 0; }
1698  friend bool operator == ( const sal_Unicode * pStr1, const OUString& rStr2 )
1699  { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
1700 
1701  friend bool operator != ( const OUString& rStr1, const OUString& rStr2 )
1702  { return !(operator == ( rStr1, rStr2 )); }
1703  friend bool operator != ( const OUString& rStr1, const sal_Unicode * pStr2 )
1704  { return !(operator == ( rStr1, pStr2 )); }
1705  friend bool operator != ( const sal_Unicode * pStr1, const OUString& rStr2 )
1706  { return !(operator == ( pStr1, rStr2 )); }
1707 
1708  friend bool operator < ( const OUString& rStr1, const OUString& rStr2 )
1709  { return rStr1.compareTo( rStr2 ) < 0; }
1710  friend bool operator > ( const OUString& rStr1, const OUString& rStr2 )
1711  { return rStr1.compareTo( rStr2 ) > 0; }
1712  friend bool operator <= ( const OUString& rStr1, const OUString& rStr2 )
1713  { return rStr1.compareTo( rStr2 ) <= 0; }
1714  friend bool operator >= ( const OUString& rStr1, const OUString& rStr2 )
1715  { return rStr1.compareTo( rStr2 ) >= 0; }
1716 
1724  template< typename T >
1726  {
1727  assert(
1729  return rString.equalsAsciiL(
1732  }
1740  template< typename T >
1742  {
1743  assert(
1745  return rString.equalsAsciiL(
1748  }
1756  template< typename T >
1758  {
1759  assert(
1761  return !rString.equalsAsciiL(
1764  }
1772  template< typename T >
1774  {
1775  assert(
1777  return !rString.equalsAsciiL(
1780  }
1781 
1782 #if defined LIBO_INTERNAL_ONLY
1783 
1784  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1785  operator ==(OUString & string, T & literal) {
1786  return
1788  string.pData->buffer, string.pData->length,
1790  literal),
1792  == 0;
1793  }
1795  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1796  operator ==(T & literal, OUString & string) {
1797  return
1800  literal),
1802  string.pData->buffer, string.pData->length)
1803  == 0;
1804  }
1806  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1807  operator !=(OUString & string, T & literal) {
1808  return
1810  string.pData->buffer, string.pData->length,
1812  literal),
1814  != 0;
1815  }
1817  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1818  operator !=(T & literal, OUString & string) {
1819  return
1822  literal),
1824  string.pData->buffer, string.pData->length)
1825  != 0;
1826  }
1827 #endif
1828 
1829 #if defined LIBO_INTERNAL_ONLY
1830 
1832  /* Comparison between OUString and OUStringLiteral.
1833 
1834  @since LibreOffice 5.0
1835  */
1836 
1837  friend bool operator ==(OUString const & lhs, OUStringLiteral const & rhs) {
1838  return lhs.equalsAsciiL(rhs.data, rhs.size);
1839  }
1840 
1841  friend bool operator !=(OUString const & lhs, OUStringLiteral const & rhs) {
1842  return !lhs.equalsAsciiL(rhs.data, rhs.size);
1843  }
1844 
1845  friend bool operator <(OUString const & lhs, OUStringLiteral const & rhs) {
1846  return
1848  lhs.pData->buffer, lhs.pData->length, rhs.data))
1849  < 0;
1850  }
1851 
1852  friend bool operator <=(OUString const & lhs, OUStringLiteral const & rhs) {
1853  return
1855  lhs.pData->buffer, lhs.pData->length, rhs.data))
1856  <= 0;
1857  }
1858 
1859  friend bool operator >(OUString const & lhs, OUStringLiteral const & rhs) {
1860  return
1862  lhs.pData->buffer, lhs.pData->length, rhs.data))
1863  > 0;
1864  }
1865 
1866  friend bool operator >=(OUString const & lhs, OUStringLiteral const & rhs) {
1867  return
1869  lhs.pData->buffer, lhs.pData->length, rhs.data))
1870  >= 0;
1871  }
1872 
1873  friend bool operator ==(OUStringLiteral const & lhs, OUString const & rhs) {
1874  return rhs.equalsAsciiL(lhs.data, lhs.size);
1875  }
1876 
1877  friend bool operator !=(OUStringLiteral const & lhs, OUString const & rhs) {
1878  return !rhs.equalsAsciiL(lhs.data, lhs.size);
1879  }
1880 
1881  friend bool operator <(OUStringLiteral const & lhs, OUString const & rhs) {
1882  return
1884  rhs.pData->buffer, rhs.pData->length, lhs.data))
1885  >= 0;
1886  }
1887 
1888  friend bool operator <=(OUStringLiteral const & lhs, OUString const & rhs) {
1889  return
1891  rhs.pData->buffer, rhs.pData->length, lhs.data))
1892  > 0;
1893  }
1894 
1895  friend bool operator >(OUStringLiteral const & lhs, OUString const & rhs) {
1896  return
1898  rhs.pData->buffer, rhs.pData->length, lhs.data))
1899  <= 0;
1900  }
1901 
1902  friend bool operator >=(OUStringLiteral const & lhs, OUString const & rhs) {
1903  return
1905  rhs.pData->buffer, rhs.pData->length, lhs.data))
1906  < 0;
1907  }
1908 
1910 #endif
1911 
1919  sal_Int32 hashCode() const
1920  {
1921  return rtl_ustr_hashCode_WithLength( pData->buffer, pData->length );
1922  }
1923 
1937  sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
1938  {
1939  sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1940  return (ret < 0 ? ret : ret+fromIndex);
1941  }
1942 
1952  sal_Int32 lastIndexOf( sal_Unicode ch ) const
1953  {
1954  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1955  }
1956 
1969  sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
1970  {
1971  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1972  }
1973 
1989  sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
1990  {
1991  sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1992  str.pData->buffer, str.pData->length );
1993  return (ret < 0 ? ret : ret+fromIndex);
1994  }
1995 
2001  template< typename T >
2002  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
2003  {
2004  assert(
2006  sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
2007  pData->buffer + fromIndex, pData->length - fromIndex,
2010  return n < 0 ? n : n + fromIndex;
2011  }
2012 
2013 #if defined LIBO_INTERNAL_ONLY
2014 
2015  template<typename T>
2016  typename
2018  indexOf(T & literal, sal_Int32 fromIndex = 0) const {
2019  assert(fromIndex >= 0);
2021  pData->buffer + fromIndex, pData->length - fromIndex,
2024  return n < 0 ? n : n + fromIndex;
2025  }
2026 
2028  sal_Int32 indexOf(OUStringLiteral const & literal, sal_Int32 fromIndex = 0)
2029  const
2030  {
2031  sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
2032  pData->buffer + fromIndex, pData->length - fromIndex, literal.data,
2033  literal.size);
2034  return n < 0 ? n : n + fromIndex;
2035  }
2036 #endif
2037 
2061  sal_Int32 indexOfAsciiL(
2062  char const * str, sal_Int32 len, sal_Int32 fromIndex = 0) const
2063  {
2064  sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
2065  pData->buffer + fromIndex, pData->length - fromIndex, str, len);
2066  return ret < 0 ? ret : ret + fromIndex;
2067  }
2068 
2069  // This overload is left undefined, to detect calls of indexOfAsciiL that
2070  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
2071  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
2072  // platforms):
2073 #if SAL_TYPES_SIZEOFLONG == 8
2074  void indexOfAsciiL(char const *, sal_Int32 len, rtl_TextEncoding) const;
2075 #endif
2076 
2092  sal_Int32 lastIndexOf( const OUString & str ) const
2093  {
2094  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
2095  str.pData->buffer, str.pData->length );
2096  }
2097 
2115  sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
2116  {
2117  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
2118  str.pData->buffer, str.pData->length );
2119  }
2120 
2126  template< typename T >
2128  {
2129  assert(
2132  pData->buffer, pData->length,
2135  }
2136 
2137 #if defined LIBO_INTERNAL_ONLY
2138 
2139  template<typename T>
2140  typename
2142  lastIndexOf(T & literal) const {
2144  pData->buffer, pData->length,
2147  }
2148 
2150  sal_Int32 lastIndexOf(OUStringLiteral const & literal) const {
2152  pData->buffer, pData->length, literal.data, literal.size);
2153  }
2154 #endif
2155 
2175  sal_Int32 lastIndexOfAsciiL(char const * str, sal_Int32 len) const
2176  {
2178  pData->buffer, pData->length, str, len);
2179  }
2180 
2191  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex ) const
2192  {
2193  rtl_uString *pNew = NULL;
2194  rtl_uString_newFromSubString( &pNew, pData, beginIndex, getLength() - beginIndex );
2195  return OUString( pNew, SAL_NO_ACQUIRE );
2196  }
2197 
2210  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const
2211  {
2212  rtl_uString *pNew = NULL;
2213  rtl_uString_newFromSubString( &pNew, pData, beginIndex, count );
2214  return OUString( pNew, SAL_NO_ACQUIRE );
2215  }
2216 
2226  {
2227  rtl_uString* pNew = NULL;
2228  rtl_uString_newConcat( &pNew, pData, str.pData );
2229  return OUString( pNew, SAL_NO_ACQUIRE );
2230  }
2231 
2232 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2233  friend OUString operator+( const OUString& rStr1, const OUString& rStr2 )
2234  {
2235  return rStr1.concat( rStr2 );
2236  }
2237 #endif
2238 
2252  SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const
2253  {
2254  rtl_uString* pNew = NULL;
2255  rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
2256  return OUString( pNew, SAL_NO_ACQUIRE );
2257  }
2258 
2273  {
2274  rtl_uString* pNew = NULL;
2275  rtl_uString_newReplace( &pNew, pData, oldChar, newChar );
2276  return OUString( pNew, SAL_NO_ACQUIRE );
2277  }
2278 
2298  OUString const & from, OUString const & to, sal_Int32 * index = NULL) const
2299  {
2300  rtl_uString * s = NULL;
2301  sal_Int32 i = 0;
2303  &s, pData, from.pData, to.pData, index == NULL ? &i : index);
2304  return OUString(s, SAL_NO_ACQUIRE);
2305  }
2306 
2325  template< typename T >
2327  sal_Int32 * index = NULL) const
2328  {
2330  rtl_uString * s = NULL;
2331  sal_Int32 i = 0;
2333  &s, pData,
2336  index == NULL ? &i : index);
2337  return OUString(s, SAL_NO_ACQUIRE);
2338  }
2339 
2358  template< typename T >
2360  sal_Int32 * index = NULL) const
2361  {
2363  rtl_uString * s = NULL;
2364  sal_Int32 i = 0;
2366  &s, pData, from.pData,
2369  index == NULL ? &i : index);
2370  return OUString(s, SAL_NO_ACQUIRE);
2371  }
2372 
2391  template< typename T1, typename T2 >
2393  replaceFirst( T1& from, T2& to, sal_Int32 * index = NULL) const
2394  {
2397  rtl_uString * s = NULL;
2398  sal_Int32 i = 0;
2400  &s, pData,
2405  index == NULL ? &i : index);
2406  return OUString(s, SAL_NO_ACQUIRE);
2407  }
2408 
2409 #if defined LIBO_INTERNAL_ONLY
2410 
2411  template<typename T> SAL_WARN_UNUSED_RESULT
2412  typename
2414  replaceFirst(T & from, OUString const & to, sal_Int32 * index = nullptr)
2415  const
2416  {
2417  rtl_uString * s = nullptr;
2418  sal_Int32 i = 0;
2420  &s, pData,
2423  to.pData->buffer, to.pData->length, index == nullptr ? &i : index);
2424  if (s == nullptr) {
2425  throw std::bad_alloc();
2426  // should be std::length_error if resulting would be too large
2427  }
2428  return OUString(s, SAL_NO_ACQUIRE);
2429  }
2431  template<typename T> SAL_WARN_UNUSED_RESULT
2432  typename
2434  replaceFirst(OUString const & from, T & to, sal_Int32 * index = nullptr)
2435  const
2436  {
2437  rtl_uString * s = nullptr;
2438  sal_Int32 i = 0;
2440  &s, pData, from.pData->buffer, from.pData->length,
2443  index == nullptr ? &i : index);
2444  if (s == nullptr) {
2445  throw std::bad_alloc();
2446  // should be std::length_error if resulting would be too large
2447  }
2448  return OUString(s, SAL_NO_ACQUIRE);
2449  }
2451  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2452  typename
2454  T1,
2456  T2, OUString>::TypeUtf16
2457  >::TypeUtf16
2458  replaceFirst(T1 & from, T2 & to, sal_Int32 * index = nullptr) const {
2459  rtl_uString * s = nullptr;
2460  sal_Int32 i = 0;
2462  &s, pData,
2467  index == nullptr ? &i : index);
2468  if (s == nullptr) {
2469  throw std::bad_alloc();
2470  // should be std::length_error if resulting would be too large
2471  }
2472  return OUString(s, SAL_NO_ACQUIRE);
2473  }
2475  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2476  typename
2478  T1,
2480  T2, OUString>::Type
2481  >::TypeUtf16
2482  replaceFirst(T1 & from, T2 & to, sal_Int32 * index = nullptr) const {
2483  rtl_uString * s = nullptr;
2484  sal_Int32 i = 0;
2486  &s, pData,
2491  index == nullptr ? &i : index);
2492  if (s == nullptr) {
2493  throw std::bad_alloc();
2494  // should be std::length_error if resulting would be too large
2495  }
2496  return OUString(s, SAL_NO_ACQUIRE);
2497  }
2499  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2500  typename
2502  T1,
2504  T2, OUString>::TypeUtf16
2505  >::Type
2506  replaceFirst(T1 & from, T2 & to, sal_Int32 * index = nullptr) const {
2507  rtl_uString * s = nullptr;
2508  sal_Int32 i = 0;
2510  &s, pData,
2515  index == nullptr ? &i : index);
2516  if (s == nullptr) {
2517  throw std::bad_alloc();
2518  // should be std::length_error if resulting would be too large
2519  }
2520  return OUString(s, SAL_NO_ACQUIRE);
2521  }
2522 
2524  SAL_WARN_UNUSED_RESULT OUString replaceFirst(
2525  OUStringLiteral const & from, OUString const & to,
2526  sal_Int32 * index = nullptr) const
2527  {
2528  rtl_uString * s = nullptr;
2529  sal_Int32 i = 0;
2531  &s, pData, from.data, from.size, to.pData,
2532  index == nullptr ? &i : index);
2533  return OUString(s, SAL_NO_ACQUIRE);
2534  }
2536  SAL_WARN_UNUSED_RESULT OUString replaceFirst(
2537  OUString const & from, OUStringLiteral const & to,
2538  sal_Int32 * index = nullptr) const
2539  {
2540  rtl_uString * s = nullptr;
2541  sal_Int32 i = 0;
2543  &s, pData, from.pData, to.data, to.size,
2544  index == nullptr ? &i : index);
2545  return OUString(s, SAL_NO_ACQUIRE);
2546  }
2548  SAL_WARN_UNUSED_RESULT OUString replaceFirst(
2549  OUStringLiteral const & from, OUStringLiteral const & to,
2550  sal_Int32 * index = nullptr) const
2551  {
2552  rtl_uString * s = nullptr;
2553  sal_Int32 i = 0;
2555  &s, pData, from.data, from.size, to.data, to.size,
2556  index == nullptr ? &i : index);
2557  return OUString(s, SAL_NO_ACQUIRE);
2558  }
2560  template<typename T> SAL_WARN_UNUSED_RESULT
2562  replaceFirst(
2563  OUStringLiteral const & from, T & to, sal_Int32 * index = nullptr) const
2564  {
2566  rtl_uString * s = nullptr;
2567  sal_Int32 i = 0;
2569  &s, pData, from.data, from.size,
2572  index == nullptr ? &i : index);
2573  return OUString(s, SAL_NO_ACQUIRE);
2574  }
2576  template<typename T> SAL_WARN_UNUSED_RESULT
2578  replaceFirst(
2579  T & from, OUStringLiteral const & to, sal_Int32 * index = nullptr) const
2580  {
2582  rtl_uString * s = nullptr;
2583  sal_Int32 i = 0;
2585  &s, pData,
2588  to.size, index == nullptr ? &i : index);
2589  return OUString(s, SAL_NO_ACQUIRE);
2590  }
2592  template<typename T> SAL_WARN_UNUSED_RESULT
2593  typename
2595  replaceFirst(
2596  OUStringLiteral const & from, T & to, sal_Int32 * index = nullptr) const
2597  {
2599  rtl_uString * s = nullptr;
2600  sal_Int32 i = 0;
2602  &s, pData, from.data, from.size,
2605  index == nullptr ? &i : index);
2606  return OUString(s, SAL_NO_ACQUIRE);
2607  }
2609  template<typename T> SAL_WARN_UNUSED_RESULT
2610  typename
2612  replaceFirst(
2613  T & from, OUStringLiteral const & to, sal_Int32 * index = nullptr) const
2614  {
2616  rtl_uString * s = nullptr;
2617  sal_Int32 i = 0;
2619  &s, pData,
2622  to.size, index == nullptr ? &i : index);
2623  return OUString(s, SAL_NO_ACQUIRE);
2624  }
2625 #endif
2626 
2643  OUString const & from, OUString const & to, sal_Int32 fromIndex = 0) const
2644  {
2645  rtl_uString * s = NULL;
2646  rtl_uString_newReplaceAllFromIndex(&s, pData, from.pData, to.pData, fromIndex);
2647  return OUString(s, SAL_NO_ACQUIRE);
2648  }
2649 
2663  template< typename T >
2665  {
2667  rtl_uString * s = NULL;
2669  &s, pData,
2672  return OUString(s, SAL_NO_ACQUIRE);
2673  }
2674 
2688  template< typename T >
2690  {
2692  rtl_uString * s = NULL;
2694  &s, pData, from.pData,
2697  return OUString(s, SAL_NO_ACQUIRE);
2698  }
2699 
2713  template< typename T1, typename T2 >
2715  replaceAll( T1& from, T2& to ) const
2716  {
2719  rtl_uString * s = NULL;
2721  &s, pData,
2726  return OUString(s, SAL_NO_ACQUIRE);
2727  }
2728 
2729 #if defined LIBO_INTERNAL_ONLY
2730 
2731  template<typename T> SAL_WARN_UNUSED_RESULT
2732  typename
2734  replaceAll(T & from, OUString const & to) const {
2735  rtl_uString * s = nullptr;
2737  &s, pData,
2740  to.pData->buffer, to.pData->length);
2741  if (s == nullptr) {
2742  throw std::bad_alloc();
2743  // should be std::length_error if resulting would be too large
2744  }
2745  return OUString(s, SAL_NO_ACQUIRE);
2746  }
2748  template<typename T> SAL_WARN_UNUSED_RESULT
2749  typename
2751  replaceAll(OUString const & from, T & to) const {
2752  rtl_uString * s = nullptr;
2754  &s, pData, from.pData->buffer, from.pData->length,
2757  if (s == nullptr) {
2758  throw std::bad_alloc();
2759  // should be std::length_error if resulting would be too large
2760  }
2761  return OUString(s, SAL_NO_ACQUIRE);
2762  }
2764  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2765  typename
2767  T1,
2769  T2, OUString>::TypeUtf16
2770  >::TypeUtf16
2771  replaceAll(T1 & from, T2 & to) const {
2772  rtl_uString * s = nullptr;
2774  &s, pData,
2779  if (s == nullptr) {
2780  throw std::bad_alloc();
2781  // should be std::length_error if resulting would be too large
2782  }
2783  return OUString(s, SAL_NO_ACQUIRE);
2784  }
2786  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2787  typename
2789  T1,
2791  T2, OUString>::Type
2792  >::TypeUtf16
2793  replaceAll(T1 & from, T2 & to) const {
2794  rtl_uString * s = nullptr;
2796  &s, pData,
2801  if (s == nullptr) {
2802  throw std::bad_alloc();
2803  // should be std::length_error if resulting would be too large
2804  }
2805  return OUString(s, SAL_NO_ACQUIRE);
2806  }
2808  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2809  typename
2811  T1,
2813  T2, OUString>::TypeUtf16
2814  >::Type
2815  replaceAll(T1 & from, T2 & to) const {
2816  rtl_uString * s = nullptr;
2818  &s, pData,
2823  if (s == nullptr) {
2824  throw std::bad_alloc();
2825  // should be std::length_error if resulting would be too large
2826  }
2827  return OUString(s, SAL_NO_ACQUIRE);
2828  }
2829 
2831  SAL_WARN_UNUSED_RESULT OUString replaceAll(
2832  OUStringLiteral const & from, OUString const & to) const
2833  {
2834  rtl_uString * s = nullptr;
2836  &s, pData, from.data, from.size, to.pData);
2837  return OUString(s, SAL_NO_ACQUIRE);
2838  }
2840  SAL_WARN_UNUSED_RESULT OUString replaceAll(
2841  OUString const & from, OUStringLiteral const & to) const
2842  {
2843  rtl_uString * s = nullptr;
2845  &s, pData, from.pData, to.data, to.size);
2846  return OUString(s, SAL_NO_ACQUIRE);
2847  }
2849  SAL_WARN_UNUSED_RESULT OUString replaceAll(
2850  OUStringLiteral const & from, OUStringLiteral const & to) const
2851  {
2852  rtl_uString * s = nullptr;
2854  &s, pData, from.data, from.size, to.data, to.size);
2855  return OUString(s, SAL_NO_ACQUIRE);
2856  }
2858  template<typename T> SAL_WARN_UNUSED_RESULT
2860  replaceAll(OUStringLiteral const & from, T & to) const {
2862  rtl_uString * s = nullptr;
2864  &s, pData, from.data, from.size,
2867  return OUString(s, SAL_NO_ACQUIRE);
2868  }
2870  template<typename T> SAL_WARN_UNUSED_RESULT
2872  replaceAll(T & from, OUStringLiteral const & to) const {
2874  rtl_uString * s = nullptr;
2876  &s, pData,
2879  to.size);
2880  return OUString(s, SAL_NO_ACQUIRE);
2881  }
2883  template<typename T> SAL_WARN_UNUSED_RESULT
2884  typename
2886  replaceAll(OUStringLiteral const & from, T & to) const {
2888  rtl_uString * s = nullptr;
2890  &s, pData, from.data, from.size,
2893  return OUString(s, SAL_NO_ACQUIRE);
2894  }
2896  template<typename T> SAL_WARN_UNUSED_RESULT
2897  typename
2899  replaceAll(T & from, OUStringLiteral const & to) const {
2901  rtl_uString * s = nullptr;
2903  &s, pData,
2906  to.size);
2907  return OUString(s, SAL_NO_ACQUIRE);
2908  }
2909 #endif
2910 
2922  {
2923  rtl_uString* pNew = NULL;
2924  rtl_uString_newToAsciiLowerCase( &pNew, pData );
2925  return OUString( pNew, SAL_NO_ACQUIRE );
2926  }
2927 
2939  {
2940  rtl_uString* pNew = NULL;
2941  rtl_uString_newToAsciiUpperCase( &pNew, pData );
2942  return OUString( pNew, SAL_NO_ACQUIRE );
2943  }
2944 
2959  {
2960  rtl_uString* pNew = NULL;
2961  rtl_uString_newTrim( &pNew, pData );
2962  return OUString( pNew, SAL_NO_ACQUIRE );
2963  }
2964 
2989  OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const
2990  {
2991  rtl_uString * pNew = NULL;
2992  index = rtl_uString_getToken( &pNew, pData, token, cTok, index );
2993  return OUString( pNew, SAL_NO_ACQUIRE );
2994  }
2995 
3009  OUString getToken(sal_Int32 count, sal_Unicode separator) const {
3010  sal_Int32 n = 0;
3011  return getToken(count, separator, n);
3012  }
3013 
3022  bool toBoolean() const
3023  {
3024  return rtl_ustr_toBoolean( pData->buffer );
3025  }
3026 
3034  {
3035  return pData->buffer[0];
3036  }
3037 
3048  sal_Int32 toInt32( sal_Int16 radix = 10 ) const
3049  {
3050  return rtl_ustr_toInt32( pData->buffer, radix );
3051  }
3052 
3065  sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
3066  {
3067  return rtl_ustr_toUInt32( pData->buffer, radix );
3068  }
3069 
3080  sal_Int64 toInt64( sal_Int16 radix = 10 ) const
3081  {
3082  return rtl_ustr_toInt64( pData->buffer, radix );
3083  }
3084 
3097  sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
3098  {
3099  return rtl_ustr_toUInt64( pData->buffer, radix );
3100  }
3101 
3110  float toFloat() const
3111  {
3112  return rtl_ustr_toFloat( pData->buffer );
3113  }
3114 
3123  double toDouble() const
3124  {
3125  return rtl_ustr_toDouble( pData->buffer );
3126  }
3127 
3128 
3145  {
3146  rtl_uString * pNew = NULL;
3147  rtl_uString_intern( &pNew, pData );
3148  if (pNew == NULL) {
3149  throw std::bad_alloc();
3150  }
3151  return OUString( pNew, SAL_NO_ACQUIRE );
3152  }
3153 
3179  static OUString intern( const sal_Char * value, sal_Int32 length,
3180  rtl_TextEncoding encoding,
3181  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS,
3182  sal_uInt32 *pInfo = NULL )
3183  {
3184  rtl_uString * pNew = NULL;
3185  rtl_uString_internConvert( &pNew, value, length, encoding,
3186  convertFlags, pInfo );
3187  if (pNew == NULL) {
3188  throw std::bad_alloc();
3189  }
3190  return OUString( pNew, SAL_NO_ACQUIRE );
3191  }
3192 
3217  bool convertToString(OString * pTarget, rtl_TextEncoding nEncoding,
3218  sal_uInt32 nFlags) const
3219  {
3220  return rtl_convertUStringToString(&pTarget->pData, pData->buffer,
3221  pData->length, nEncoding, nFlags);
3222  }
3223 
3275  sal_uInt32 iterateCodePoints(
3276  sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1) const
3277  {
3279  pData, indexUtf16, incrementCodePoints);
3280  }
3281 
3291  static OUString fromUtf8(const OString& rSource)
3292  {
3293  OUString aTarget;
3294  bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
3295  rSource.getStr(),
3296  rSource.getLength(),
3299  (void) bSuccess;
3300  assert(bSuccess);
3301  return aTarget;
3302  }
3303 
3314  OString toUtf8() const
3315  {
3316  OString aTarget;
3317  bool bSuccess = rtl_convertUStringToString(&aTarget.pData,
3318  getStr(),
3319  getLength(),
3322  (void) bSuccess;
3323  assert(bSuccess);
3324  return aTarget;
3325  }
3326 
3337  static OUString number( int i, sal_Int16 radix = 10 )
3338  {
3340  rtl_uString* pNewData = NULL;
3341  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt32( aBuf, i, radix ) );
3342  return OUString( pNewData, SAL_NO_ACQUIRE );
3343  }
3346  static OUString number( unsigned int i, sal_Int16 radix = 10 )
3347  {
3348  return number( static_cast< unsigned long long >( i ), radix );
3349  }
3352  static OUString number( long i, sal_Int16 radix = 10)
3353  {
3354  return number( static_cast< long long >( i ), radix );
3355  }
3358  static OUString number( unsigned long i, sal_Int16 radix = 10 )
3359  {
3360  return number( static_cast< unsigned long long >( i ), radix );
3361  }
3364  static OUString number( long long ll, sal_Int16 radix = 10 )
3365  {
3367  rtl_uString* pNewData = NULL;
3368  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt64( aBuf, ll, radix ) );
3369  return OUString( pNewData, SAL_NO_ACQUIRE );
3370  }
3373  static OUString number( unsigned long long ll, sal_Int16 radix = 10 )
3374  {
3376  rtl_uString* pNewData = NULL;
3377  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfUInt64( aBuf, ll, radix ) );
3378  return OUString( pNewData, SAL_NO_ACQUIRE );
3379  }
3380 
3390  static OUString number( float f )
3391  {
3393  rtl_uString* pNewData = NULL;
3394  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfFloat( aBuf, f ) );
3395  return OUString( pNewData, SAL_NO_ACQUIRE );
3396  }
3397 
3407  static OUString number( double d )
3408  {
3410  rtl_uString* pNewData = NULL;
3411  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfDouble( aBuf, d ) );
3412  return OUString( pNewData, SAL_NO_ACQUIRE );
3413  }
3414 
3426  SAL_DEPRECATED("use boolean()") static OUString valueOf( sal_Bool b )
3427  {
3428  return boolean(b);
3429  }
3430 
3442  static OUString boolean( bool b )
3443  {
3445  rtl_uString* pNewData = NULL;
3446  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfBoolean( aBuf, b ) );
3447  return OUString( pNewData, SAL_NO_ACQUIRE );
3448  }
3449 
3457  SAL_DEPRECATED("convert to OUString or use directly") static OUString valueOf( sal_Unicode c )
3458  {
3459  return OUString( &c, 1 );
3460  }
3461 
3472  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
3473  {
3474  return number( i, radix );
3475  }
3476 
3487  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
3488  {
3489  return number( ll, radix );
3490  }
3491 
3501  SAL_DEPRECATED("use number()") static OUString valueOf( float f )
3502  {
3503  return number(f);
3504  }
3505 
3515  SAL_DEPRECATED("use number()") static OUString valueOf( double d )
3516  {
3517  return number(d);
3518  }
3519 
3535  static OUString createFromAscii( const sal_Char * value )
3536  {
3537  rtl_uString* pNew = NULL;
3538  rtl_uString_newFromAscii( &pNew, value );
3539  return OUString( pNew, SAL_NO_ACQUIRE );
3540  }
3541 };
3542 
3543 #if defined LIBO_INTERNAL_ONLY
3544 // Prevent the operator ==/!= overloads with 'sal_Unicode const *' parameter from
3545 // being selected for nonsensical code like
3546 //
3547 // if (ouIdAttr == nullptr)
3548 //
3549 void operator ==(OUString const &, std::nullptr_t) = delete;
3550 void operator ==(std::nullptr_t, OUString const &) = delete;
3551 void operator !=(OUString const &, std::nullptr_t) = delete;
3552 void operator !=(std::nullptr_t, OUString const &) = delete;
3553 #endif
3554 
3555 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3556 
3561 template<>
3562 struct ToStringHelper< OUString >
3563  {
3564  static int length( const OUString& s ) { return s.getLength(); }
3565  static sal_Unicode* addData( sal_Unicode* buffer, const OUString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
3566  static const bool allowOStringConcat = false;
3567  static const bool allowOUStringConcat = true;
3568  };
3569 
3573 template<>
3574 struct ToStringHelper< OUStringLiteral >
3575  {
3576  static int length( const OUStringLiteral& str ) { return str.size; }
3577  static sal_Unicode* addData( sal_Unicode* buffer, const OUStringLiteral& str ) { return addDataLiteral( buffer, str.data, str.size ); }
3578  static const bool allowOStringConcat = false;
3579  static const bool allowOUStringConcat = true;
3580  };
3581 
3585 template< typename charT, typename traits, typename T1, typename T2 >
3586 inline std::basic_ostream<charT, traits> & operator <<(
3587  std::basic_ostream<charT, traits> & stream, const OUStringConcat< T1, T2 >& concat)
3588 {
3589  return stream << OUString( concat );
3590 }
3591 
3593 #endif
3594 
3601 {
3611  size_t operator()(const OUString& rString) const
3612  { return (size_t)rString.hashCode(); }
3613 };
3614 
3615 /* ======================================================================= */
3616 
3634 inline OUString OStringToOUString( const OString & rStr,
3635  rtl_TextEncoding encoding,
3636  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
3637 {
3638  return OUString( rStr.getStr(), rStr.getLength(), encoding, convertFlags );
3639 }
3640 
3658 inline OString OUStringToOString( const OUString & rUnicode,
3659  rtl_TextEncoding encoding,
3660  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
3661 {
3662  return OString( rUnicode.getStr(), rUnicode.getLength(), encoding, convertFlags );
3663 }
3664 
3665 /* ======================================================================= */
3666 
3675 template< typename charT, typename traits >
3676 inline std::basic_ostream<charT, traits> & operator <<(
3677  std::basic_ostream<charT, traits> & stream, OUString const & rString)
3678 {
3679  return stream <<
3681  // best effort; potentially loses data due to conversion failures
3682  // (stray surrogate halves) and embedded null characters
3683 }
3684 
3685 } // namespace
3686 
3687 #ifdef RTL_STRING_UNITTEST
3688 namespace rtl
3689 {
3690 typedef rtlunittest::OUString OUString;
3691 }
3692 #endif
3693 
3694 // In internal code, allow to use classes like OUString without having to
3695 // explicitly refer to the rtl namespace, which is kind of superfluous given
3696 // that OUString itself is namespaced by its OU prefix:
3697 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3698 using ::rtl::OUString;
3699 using ::rtl::OUStringHash;
3702 using ::rtl::OUStringLiteral;
3703 using ::rtl::OUStringLiteral1;
3704 #endif
3705 
3706 #endif /* _RTL_USTRING_HXX */
3707 
3708 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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...
static OUString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: ustring.hxx:3442
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:2061
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:3179
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:1892
OUString()
New string containing no characters.
Definition: ustring.hxx:130
SAL_DLLPUBLIC sal_Int32 rtl_ustr_hashCode_WithLength(const sal_Unicode *str, sal_Int32 len) SAL_THROW_EXTERN_C()
Return a hash code for a string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(sal_Unicode const *first, sal_Int32 firstLen, char const *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
SAL_DLLPUBLIC void rtl_uString_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...
double toDouble() const
Returns the double value from this string.
Definition: ustring.hxx:3123
#define OSTRING_TO_OUSTRING_CVTFLAGS
Definition: ustring.h:2119
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: ustring.hxx:3048
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.
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:735
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: ustring.hxx:620
bool equalsIgnoreAsciiCaseAscii(const sal_Char *asciiStr) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1153
SAL_DLLPUBLIC void rtl_uString_newReplaceFirst(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, rtl_uString const *to, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
sal_Int32 getLength() const
Returns the length of this string.
Definition: ustring.hxx:633
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:1268
OUString & operator=(const OUString &str)
Assign a new string.
Definition: ustring.hxx:435
SAL_DLLPUBLIC void rtl_uString_new(rtl_uString **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
bool endsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string ends with a given substring.
Definition: ustring.hxx:1474
OUString intern() const
Return a canonical representation for a string.
Definition: ustring.hxx:3144
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
SAL_DLLPUBLIC void rtl_uString_ensureCapacity(rtl_uString **str, sal_Int32 size) SAL_THROW_EXTERN_C()
Ensure a string has enough space for a given number of characters.
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: ustring.hxx:3097
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1725
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.
char sal_Char
A legacy synonym for char.
Definition: types.h:121
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.
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:3364
#define RTL_TEXTENCODING_UTF8
Definition: textenc.h:113
SAL_DLLPUBLIC sal_Int32 rtl_ustr_compare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings.
SAL_DLLPUBLIC void rtl_uString_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...
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:3634
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.
#define RTL_USTR_MAX_VALUEOFBOOLEAN
Definition: ustring.h:915
OUString(sal_Unicode value)
New string from a single Unicode character.
Definition: ustring.hxx:191
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 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_TEXTTOUNICODE_FLAGS_INVALID_ERROR
Definition: textcvt.h:71
#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:64
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:3346
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:608
OUString(sal_uInt32 const *codePoints, sal_Int32 codePointCount)
Create a new string from an array of Unicode code points.
Definition: ustring.hxx:378
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:3658
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:3352
SAL_DLLPUBLIC void rtl_uString_newReplaceAllUtf16LAsciiL(rtl_uString **newStr, rtl_uString *str, sal_Unicode const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
SAL_DLLPUBLIC sal_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_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 double rtl_ustr_toDouble(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a double.
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_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_acquire(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Increment the reference count of a string.
size_t operator()(const OUString &rString) const
Compute a hash code for a string.
Definition: ustring.hxx:3611
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstAsciiLUtf16L(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, sal_Unicode const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
SAL_DLLPUBLIC sal_Int64 rtl_ustr_toInt64(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as a long integer.
bool toBoolean() const
Returns the Boolean value from this string.
Definition: ustring.hxx:3022
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 void rtl_uString_newReplace(rtl_uString **newStr, rtl_uString *str, sal_Unicode oldChar, sal_Unicode newChar) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a single character within another string...
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfInt64(sal_Unicode *str, sal_Int64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of a long integer.
OUString getToken(sal_Int32 count, sal_Unicode separator) const
Returns a token from the string.
Definition: ustring.hxx:3009
SAL_WARN_UNUSED_RESULT OUString concat(const OUString &str) const
Concatenates the specified string to the end of this string.
Definition: ustring.hxx:2225
bool equals(const OUString &str) const
Perform a comparison of two strings.
Definition: ustring.hxx:775
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.
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:1230
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:2175
const sal_Char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:428
bool convertToString(OString *pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) const
Converts to an OString, signalling failure.
Definition: ustring.hxx:3217
SAL_DLLPUBLIC void rtl_uString_intern(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Return a canonical representation for a string.
SAL_DLLPUBLIC void rtl_uString_newReplaceAllToAsciiL(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, char const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
SAL_DLLPUBLIC 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.
#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
Definition: textcvt.h:68
#define RTL_STR_MAX_VALUEOFUINT64
Definition: string.h:673
friend OUString operator+(const OUString &rStr1, const OUString &rStr2)
Definition: ustring.hxx:2233
sal_Int32 compareTo(const OUString &str, sal_Int32 maxLength) const
Compares two strings with a maximum count of characters.
Definition: ustring.hxx:705
SAL_DLLPUBLIC sal_Int32 rtl_ustr_toInt32(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an integer.
SAL_DLLPUBLIC 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.
#define RTL_USTR_MAX_VALUEOFINT32
Definition: ustring.h:957
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:2092
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_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...
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:3373
unsigned char sal_Bool
Definition: types.h:39
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfFloat(sal_Unicode *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:96
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.
#define RTL_USTR_MAX_VALUEOFFLOAT
Definition: ustring.h:1022
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:1969
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.
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:837
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:2002
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:1592
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:1609
static OUString fromUtf8(const OString &rSource)
Convert an OString to an OUString, assuming that the OString is UTF-8-encoded.
Definition: ustring.hxx:3291
SAL_DLLPUBLIC void rtl_uString_newReplaceAllAsciiLUtf16L(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, sal_Unicode const *to, sal_Int32 toLength) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
SAL_DLLPUBLIC sal_Bool rtl_ustr_toBoolean(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C() SAL_HOT
Decrement the reference count of a string.
sal_uInt32 iterateCodePoints(sal_Int32 *indexUtf16, sal_Int32 incrementCodePoints=1) const
Iterate through this string based on code points instead of UTF-16 code units.
Definition: ustring.hxx:3275
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:106
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:2210
bool equalsAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform a comparison of two strings.
Definition: ustring.hxx:1126
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
sal_Int32 reverseCompareTo(const OUString &str) const
Compares two strings in reverse order.
Definition: ustring.hxx:723
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_NoAcquire
Definition: types.h:376
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_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:2252
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:307
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:2297
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 match(const OUString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:889
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: ustring.hxx:3065
SAL_DLLPUBLIC void rtl_uString_newConcatUtf16L(rtl_uString **newString, rtl_uString *left, sal_Unicode const *right, sal_Int32 rightLength)
Create a new string that is the concatenation of two other strings.
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T, OUString >::Type 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:2664
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:643
OString toUtf8() const
Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully.
Definition: ustring.hxx:3314
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1773
OUString(rtl_uString *str)
New string from OUString data.
Definition: ustring.hxx:169
SAL_DLLPUBLIC void rtl_uString_newReplaceAllFromIndex(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, rtl_uString const *to, sal_Int32 fromIndex) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
SAL_WARN_UNUSED_RESULT OUString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: ustring.hxx:2191
#define RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR
Definition: textcvt.h:138
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:1311
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:958
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_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_uInt16 sal_Unicode
Definition: types.h:142
const sal_Unicode * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:655
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1741
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.
OUString getToken(sal_Int32 token, sal_Unicode cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: ustring.hxx:2989
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:2921
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_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:33
sal_Int32 compareToAscii(const sal_Char *asciiStr) const
Compares two strings.
Definition: ustring.hxx:1028
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.
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:1387
sal_Unicode toChar() const
Returns the first character from this string.
Definition: ustring.hxx:3033
bool equalsIgnoreAsciiCaseAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1201
static OUString number(float f)
Returns the string representation of the float argument.
Definition: ustring.hxx:3390
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.
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:2115
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:1937
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:2359
float toFloat() const
Returns the float value from this string.
Definition: ustring.hxx:3110
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:1952
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: ustring.hxx:3080
sal_Int32 compareToIgnoreAsciiCaseAscii(const sal_Char *asciiStr) const
Compares two ASCII strings ignoring case.
Definition: ustring.hxx:1176
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:2715
A helper to use OUStrings with hash maps.
Definition: ustring.hxx:3600
Definition: bootstrap.hxx:29
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:120
definition of a no acquire enum for ctors
Definition: types.h:380
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1757
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:971
#define RTL_USTR_MAX_VALUEOFDOUBLE
Definition: ustring.h:1041
#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
SAL_DLLPUBLIC sal_Int32 rtl_ustr_reverseCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings from back to front.
sal_Int32 compareTo(const OUString &str) const
Compares two strings.
Definition: ustring.hxx:684
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 getLength() const
Returns the length of this string.
Definition: string.hxx:402
bool endsWithAsciiL(char const *asciiStr, sal_Int32 asciiStrLength) const
Check whether this string ends with a given ASCII string.
Definition: ustring.hxx:1563
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...
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
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:901
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfBoolean(sal_Unicode *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
SAL_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:2938
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: ustring.hxx:1919
SAL_DLLPUBLIC void rtl_uString_newFromLiteral(rtl_uString **newStr, const sal_Char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
SAL_DLLPUBLIC void rtl_uString_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_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:2642
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:116
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:2958
OUString(const sal_Unicode *value)
New string from a Unicode character buffer array.
Definition: ustring.hxx:213
sal_Int32 compareToIgnoreAsciiCase(const OUString &str) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:824
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:2326
static OUString createFromAscii(const sal_Char *value)
Returns a OUString copied without conversion from an ASCII character string.
Definition: ustring.hxx:3535
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.
OUString(const OUString &str)
New string from OUString.
Definition: ustring.hxx:141
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:2272
Definition: stringutils.hxx:115
SAL_DLLPUBLIC void rtl_uString_assign(rtl_uString **str, rtl_uString *rightValue) SAL_THROW_EXTERN_C()
Assign a new value to a string.
SAL_DLLPUBLIC void rtl_uString_newConcat(rtl_uString **newStr, rtl_uString *left, rtl_uString *right) SAL_THROW_EXTERN_C()
Create a new string that is the concatenation of two other strings.
SAL_DLLPUBLIC 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.
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:1490
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition: ustring.hxx:525
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:3358
#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:132
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:1989
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...
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:650
bool equalsAscii(const sal_Char *asciiStr) const
Perform a comparison of two strings.
Definition: ustring.hxx:1103
~OUString()
Release the string data.
Definition: ustring.hxx:411
static OUString number(double d)
Returns the string representation of the double argument.
Definition: ustring.hxx:3407
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 void rtl_uString_newReplaceStrAt(rtl_uString **newStr, rtl_uString *str, sal_Int32 idx, sal_Int32 count, rtl_uString *subStr) SAL_THROW_EXTERN_C()
Create a new string by replacing a substring of another string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfChar_WithLength(const sal_Unicode *str, sal_Int32 len, sal_Unicode ch) SAL_THROW_EXTERN_C()
Search for the first occurrence of a character within a string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfChar_WithLength(const sal_Unicode *str, sal_Int32 len, sal_Unicode ch) SAL_THROW_EXTERN_C()
Search for the last occurrence of a character within a string.
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstAsciiLAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
sal_Int32 reverseCompareToAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Compares two strings in reverse order.
Definition: ustring.hxx:1082
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfDouble(sal_Unicode *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
libreoffice_internal::ConstCharArrayDetector< T, 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:2127
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:1404
bool equalsIgnoreAsciiCase(const OUString &str) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:799
OUString(rtl_uString *str, __sal_NoAcquire)
New OUString from OUString data without acquiring it.
Definition: ustring.hxx:183
bool startsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: ustring.hxx:1297
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:1684
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:2393
OUString(const sal_Unicode *value, sal_Int32 length)
New string from a Unicode character buffer array.
Definition: ustring.hxx:227
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.
static OUString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: ustring.hxx:3337
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_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:2689
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
SAL_DLLPUBLIC sal_uInt32 rtl_uString_iterateCodePoints(rtl_uString const *string, sal_Int32 *indexUtf16, sal_Int32 incrementCodePoints)
Iterate through a string based on code points instead of UTF-16 code units.
SAL_DLLPUBLIC 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...
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:94
SAL_DLLPUBLIC float rtl_ustr_toFloat(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a float.
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1324