LibreOffice
LibreOffice 6.2 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 
30 #include "rtl/ustring.h"
31 #include "rtl/string.hxx"
32 #include "rtl/stringutils.hxx"
33 #include "rtl/textenc.h"
34 
35 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
36 #include "config_global.h"
37 #include "rtl/stringconcat.hxx"
38 #endif
39 
40 #ifdef RTL_STRING_UNITTEST
41 extern bool rtl_string_unittest_invalid_conversion;
42 #endif
43 
44 // The unittest uses slightly different code to help check that the proper
45 // calls are made. The class is put into a different namespace to make
46 // sure the compiler generates a different (if generating also non-inline)
47 // copy of the function and does not merge them together. The class
48 // is "brought" into the proper rtl namespace by a typedef below.
49 #ifdef RTL_STRING_UNITTEST
50 #define rtl rtlunittest
51 #endif
52 
53 namespace rtl
54 {
55 
56 class OUStringBuffer;
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  // So we can use this struct in some places interchangeably with OUString
92  constexpr sal_Int32 getLength() const { return size; }
93 };
94 
96 #endif
97 
98 /* ======================================================================= */
99 
123 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OUString
124 {
125 public:
127  rtl_uString * pData;
129 
134  {
135  pData = NULL;
136  rtl_uString_new( &pData );
137  }
138 
144  OUString( const OUString & str )
145  {
146  pData = str.pData;
147  rtl_uString_acquire( pData );
148  }
149 
150 #ifndef _MSC_VER // TODO?
151 #if defined LIBO_INTERNAL_ONLY
152 
158  OUString( OUString && str )
159  {
160  pData = str.pData;
161  str.pData = nullptr;
162  rtl_uString_new( &str.pData );
163  }
164 #endif
165 #endif
166 
172  OUString( rtl_uString * str )
173  {
174  pData = str;
175  rtl_uString_acquire( pData );
176  }
177 
186  OUString( rtl_uString * str, __sal_NoAcquire )
187  { pData = str; }
188 
194  explicit OUString( sal_Unicode value )
195  : pData (NULL)
196  {
197  rtl_uString_newFromStr_WithLength( &pData, &value, 1 );
198  }
199 
200 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
201  // Catch inadvertent conversions to the above ctor (but still allow
203  // construction from char literals):
204  OUString(int) = delete;
205  explicit OUString(char c):
206  OUString(sal_Unicode(static_cast<unsigned char>(c)))
207  {}
209 #endif
210 
216  OUString( const sal_Unicode * value )
217  {
218  pData = NULL;
219  rtl_uString_newFromStr( &pData, value );
220  }
221 
230  OUString( const sal_Unicode * value, sal_Int32 length )
231  {
232  pData = NULL;
233  rtl_uString_newFromStr_WithLength( &pData, value, length );
234  }
235 
251  template< typename T >
253  {
254  assert(
256  pData = NULL;
258  rtl_uString_new(&pData);
259  } else {
261  &pData,
263  literal),
265  }
266 #ifdef RTL_STRING_UNITTEST
267  rtl_string_unittest_const_literal = true;
268 #endif
269  }
270 
271 #if defined LIBO_INTERNAL_ONLY
272 
273  template<typename T> OUString(
274  T & literal,
276  T, libreoffice_internal::Dummy>::TypeUtf16
278  pData(nullptr)
279  {
281  rtl_uString_new(&pData);
282  } else {
284  &pData,
286  literal),
288  }
289  }
290 #endif
291 
292 #ifdef RTL_STRING_UNITTEST
293 
297  template< typename T >
299  {
300  pData = NULL;
301  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
302  rtl_string_unittest_invalid_conversion = true;
303  }
308  template< typename T >
310  {
311  pData = NULL;
312  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
313  rtl_string_unittest_invalid_conversion = true;
314  }
315 #endif
316 
317 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
318 
334  OUString(OUStringLiteral literal): pData(NULL) {
335  rtl_uString_newFromLiteral(&pData, literal.data, literal.size, 0);
336  }
338 #endif
339 
354  OUString( const sal_Char * value, sal_Int32 length,
355  rtl_TextEncoding encoding,
356  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
357  {
358  pData = NULL;
359  rtl_string2UString( &pData, value, length, encoding, convertFlags );
360  if (pData == NULL) {
361  throw std::bad_alloc();
362  }
363  }
364 
381  explicit OUString(
382  sal_uInt32 const * codePoints, sal_Int32 codePointCount):
383  pData(NULL)
384  {
385  rtl_uString_newFromCodePoints(&pData, codePoints, codePointCount);
386  if (pData == NULL) {
387  throw std::bad_alloc();
388  }
389  }
390 
391 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
392 
396  template< typename T1, typename T2 >
397  OUString( OUStringConcat< T1, T2 >&& c )
398  {
399  const sal_Int32 l = c.length();
400  pData = rtl_uString_alloc( l );
401  if (l != 0)
402  {
403  sal_Unicode* end = c.addData( pData->buffer );
404  pData->length = l;
405  *end = '\0';
406  // TODO realloc in case pData->length is noticeably smaller than l?
407  }
408  }
409 #endif
410 
415  {
416  rtl_uString_release( pData );
417  }
418 
430  static OUString const & unacquired( rtl_uString * const * ppHandle )
431  { return * reinterpret_cast< OUString const * >( ppHandle ); }
432 
438  OUString & operator=( const OUString & str )
439  {
440  rtl_uString_assign( &pData, str.pData );
441  return *this;
442  }
443 
444 #ifndef _MSC_VER // TODO?
445 #if defined LIBO_INTERNAL_ONLY
446 
452  OUString & operator=( OUString && str )
453  {
454  rtl_uString_release( pData );
455  pData = str.pData;
456  str.pData = nullptr;
457  rtl_uString_new( &str.pData );
458  return *this;
459  }
460 #endif
461 #endif
462 
475  template< typename T >
477  {
478  assert(
481  rtl_uString_new(&pData);
482  } else {
484  &pData,
486  literal),
488  }
489  return *this;
490  }
491 
492 #if defined LIBO_INTERNAL_ONLY
493 
494  template<typename T>
495  typename
497  operator =(T & literal) {
499  rtl_uString_new(&pData);
500  } else {
502  &pData,
504  literal),
506  }
507  return *this;
508  }
509 
511  OUString & operator =(OUStringLiteral const & literal) {
512  if (literal.size == 0) {
513  rtl_uString_new(&pData);
514  } else {
515  rtl_uString_newFromLiteral(&pData, literal.data, literal.size, 0);
516  }
517  return *this;
518  }
519 #endif
520 
521 #if defined LIBO_INTERNAL_ONLY
522 
530  inline OUString & operator+=( const OUStringBuffer & str ) &;
531 #endif
532 
540  OUString & operator+=( const OUString & str )
541 #if defined LIBO_INTERNAL_ONLY
542  &
543 #endif
544  {
545  return internalAppend(str.pData);
546  }
547 #if defined LIBO_INTERNAL_ONLY
548  void operator+=(OUString const &) && = delete;
549 #endif
550 
557  template<typename T>
559  operator +=(T & literal)
560 #if defined LIBO_INTERNAL_ONLY
561  &
562 #endif
563  {
564  assert(
567  &pData, pData,
570  return *this;
571  }
572 #if defined LIBO_INTERNAL_ONLY
573  template<typename T>
575  operator +=(T &) && = delete;
576 #endif
577 
578 #if defined LIBO_INTERNAL_ONLY
579 
580  template<typename T>
581  typename
583  operator +=(T & literal) & {
585  &pData, pData,
588  return *this;
589  }
590  template<typename T>
591  typename
593  operator +=(T &) && = delete;
594 
596  OUString & operator +=(OUStringLiteral const & literal) & {
597  rtl_uString_newConcatAsciiL(&pData, pData, literal.data, literal.size);
598  return *this;
599  }
600  void operator +=(OUStringLiteral const &) && = delete;
601 #endif
602 
603 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
604 
608  template< typename T1, typename T2 >
609  OUString& operator+=( OUStringConcat< T1, T2 >&& c ) & {
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  template<typename T1, typename T2> void operator +=(
621  OUStringConcat<T1, T2> &&) && = delete;
622 #endif
623 
628  void clear()
629  {
630  rtl_uString_new( &pData );
631  }
632 
641  sal_Int32 getLength() const { return pData->length; }
642 
651  bool isEmpty() const
652  {
653  return pData->length == 0;
654  }
655 
663  const sal_Unicode * getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
664 
674  sal_Unicode operator [](sal_Int32 index) const {
675  // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
676  assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
677  return getStr()[index];
678  }
679 
692  sal_Int32 compareTo( const OUString & str ) const
693  {
694  return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
695  str.pData->buffer, str.pData->length );
696  }
697 
713  sal_Int32 compareTo( const OUString & str, sal_Int32 maxLength ) const
714  {
715  return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
716  str.pData->buffer, str.pData->length, maxLength );
717  }
718 
731  sal_Int32 reverseCompareTo( const OUString & str ) const
732  {
733  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
734  str.pData->buffer, str.pData->length );
735  }
736 
742  template< typename T >
744  {
745  assert(
748  pData->buffer, pData->length,
751  }
752 
753 #if defined LIBO_INTERNAL_ONLY
754 
755  template<typename T>
756  typename
758  reverseCompareTo(T & literal) const {
760  pData->buffer, pData->length,
763  }
764 
766  sal_Int32 reverseCompareTo(OUStringLiteral const & literal) const {
768  pData->buffer, pData->length, literal.data, literal.size);
769  }
770 #endif
771 
783  bool equals( const OUString & str ) const
784  {
785  if ( pData->length != str.pData->length )
786  return false;
787  if ( pData == str.pData )
788  return true;
789  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
790  str.pData->buffer, str.pData->length ) == 0;
791  }
792 
807  bool equalsIgnoreAsciiCase( const OUString & str ) const
808  {
809  if ( pData->length != str.pData->length )
810  return false;
811  if ( pData == str.pData )
812  return true;
813  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
814  str.pData->buffer, str.pData->length ) == 0;
815  }
816 
832  sal_Int32 compareToIgnoreAsciiCase( const OUString & str ) const
833  {
834  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
835  str.pData->buffer, str.pData->length );
836  }
837 
838 
844  template< typename T >
846  {
847  assert(
849  return
850  (pData->length
853  pData->buffer, pData->length,
855  literal))
856  == 0);
857  }
858 
859 #if defined LIBO_INTERNAL_ONLY
860 
861  template<typename T>
863  equalsIgnoreAsciiCase(T & literal) const {
864  return
866  pData->buffer, pData->length,
868  literal),
870  == 0;
871  }
872 
874  bool equalsIgnoreAsciiCase(OUStringLiteral const & literal) const {
875  return pData->length == literal.size
877  pData->buffer, pData->length, literal.data)
878  == 0);
879  }
880 #endif
881 
897  bool match( const OUString & str, sal_Int32 fromIndex = 0 ) const
898  {
899  return rtl_ustr_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
900  str.pData->buffer, str.pData->length, str.pData->length ) == 0;
901  }
902 
908  template< typename T >
909  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
910  {
911  assert(
913  return
915  pData->buffer+fromIndex, pData->length-fromIndex,
917  literal),
919  == 0;
920  }
921 
922 #if defined LIBO_INTERNAL_ONLY
923 
924  template<typename T>
926  match(T & literal, sal_Int32 fromIndex = 0) const {
927  assert(fromIndex >= 0);
928  return
930  pData->buffer + fromIndex, pData->length - fromIndex,
932  literal),
935  == 0;
936  }
937 
939  bool match(OUStringLiteral const & literal, sal_Int32 fromIndex = 0) const {
940  return
942  pData->buffer + fromIndex, pData->length - fromIndex,
943  literal.data, literal.size)
944  == 0;
945  }
946 #endif
947 
966  bool matchIgnoreAsciiCase( const OUString & str, sal_Int32 fromIndex = 0 ) const
967  {
968  return rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
969  str.pData->buffer, str.pData->length,
970  str.pData->length ) == 0;
971  }
972 
978  template< typename T >
979  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
980  {
981  assert(
983  return
985  pData->buffer+fromIndex, pData->length-fromIndex,
987  literal),
989  == 0;
990  }
991 
992 #if defined LIBO_INTERNAL_ONLY
993 
994  template<typename T>
996  matchIgnoreAsciiCase(T & literal, sal_Int32 fromIndex = 0) const {
997  assert(fromIndex >= 0);
998  return
1000  pData->buffer + fromIndex, pData->length - fromIndex,
1002  literal),
1005  == 0;
1006  }
1007 
1009  bool matchIgnoreAsciiCase(
1010  OUStringLiteral const & literal, sal_Int32 fromIndex = 0) const
1011  {
1012  return
1014  pData->buffer+fromIndex, pData->length-fromIndex, literal.data,
1015  literal.size)
1016  == 0;
1017  }
1018 #endif
1019 
1036  sal_Int32 compareToAscii( const sal_Char* asciiStr ) const
1037  {
1038  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length, asciiStr );
1039  }
1040 
1064  "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
1065  sal_Int32 compareToAscii( const sal_Char * asciiStr, sal_Int32 maxLength ) const
1066  {
1067  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer, pData->length,
1068  asciiStr, maxLength );
1069  }
1070 
1090  sal_Int32 reverseCompareToAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
1091  {
1092  return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
1093  asciiStr, asciiStrLength );
1094  }
1095 
1111  bool equalsAscii( const sal_Char* asciiStr ) const
1112  {
1113  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length,
1114  asciiStr ) == 0;
1115  }
1116 
1134  bool equalsAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength ) const
1135  {
1136  if ( pData->length != asciiStrLength )
1137  return false;
1138 
1140  pData->buffer, asciiStr, asciiStrLength );
1141  }
1142 
1161  bool equalsIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const
1162  {
1163  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1164  }
1165 
1184  sal_Int32 compareToIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const
1185  {
1186  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr );
1187  }
1188 
1209  bool equalsIgnoreAsciiCaseAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
1210  {
1211  if ( pData->length != asciiStrLength )
1212  return false;
1213 
1214  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1215  }
1216 
1238  bool matchAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1239  {
1240  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1241  asciiStr, asciiStrLength ) == 0;
1242  }
1243 
1244  // This overload is left undefined, to detect calls of matchAsciiL that
1245  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1246  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1247  // platforms):
1248 #if SAL_TYPES_SIZEOFLONG == 8
1249  void matchAsciiL(char const *, sal_Int32, rtl_TextEncoding) const;
1250 #endif
1251 
1276  bool matchIgnoreAsciiCaseAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1277  {
1278  return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1279  asciiStr, asciiStrLength ) == 0;
1280  }
1281 
1282  // This overload is left undefined, to detect calls of
1283  // matchIgnoreAsciiCaseAsciiL that erroneously use
1284  // RTL_CONSTASCII_USTRINGPARAM instead of RTL_CONSTASCII_STRINGPARAM (but
1285  // would lead to ambiguities on 32 bit platforms):
1286 #if SAL_TYPES_SIZEOFLONG == 8
1287  void matchIgnoreAsciiCaseAsciiL(char const *, sal_Int32, rtl_TextEncoding)
1288  const;
1289 #endif
1290 
1305  bool startsWith(OUString const & str, OUString * rest = NULL) const {
1306  bool b = match(str);
1307  if (b && rest != NULL) {
1308  *rest = copy(str.getLength());
1309  }
1310  return b;
1311  }
1312 
1318  template< typename T >
1320  T & literal, OUString * rest = NULL) const
1321  {
1322  assert(
1324  bool b
1326  <= sal_uInt32(pData->length))
1328  pData->buffer,
1330  literal),
1332  if (b && rest != NULL) {
1333  *rest = copy(
1335  }
1336  return b;
1337  }
1338 
1339 #if defined LIBO_INTERNAL_ONLY
1340 
1341  template<typename T>
1343  startsWith(T & literal, OUString * rest = nullptr) const {
1344  bool b
1346  <= sal_uInt32(pData->length))
1348  pData->buffer,
1351  literal),
1353  == 0);
1354  if (b && rest != nullptr) {
1355  *rest = copy(
1357  }
1358  return b;
1359  }
1360 
1362  bool startsWith(OUStringLiteral const & literal, OUString * rest = nullptr)
1363  const
1364  {
1365  bool b = literal.size <= pData->length
1367  pData->buffer, literal.data, literal.size);
1368  if (b && rest != nullptr) {
1369  *rest = copy(literal.size);
1370  }
1371  return b;
1372  }
1373 #endif
1374 
1395  bool startsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL)
1396  const
1397  {
1398  bool b = matchIgnoreAsciiCase(str);
1399  if (b && rest != NULL) {
1400  *rest = copy(str.getLength());
1401  }
1402  return b;
1403  }
1404 
1410  template< typename T >
1412  startsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1413  {
1414  assert(
1416  bool b
1418  pData->buffer,
1421  literal),
1423  == 0);
1424  if (b && rest != NULL) {
1425  *rest = copy(
1427  }
1428  return b;
1429  }
1430 
1431 #if defined LIBO_INTERNAL_ONLY
1432 
1433  template<typename T>
1435  startsWithIgnoreAsciiCase(T & literal, OUString * rest = nullptr) const {
1436  bool b
1438  <= sal_uInt32(pData->length))
1440  pData->buffer,
1443  literal),
1445  == 0);
1446  if (b && rest != nullptr) {
1447  *rest = copy(
1449  }
1450  return b;
1451  }
1452 
1454  bool startsWithIgnoreAsciiCase(
1455  OUStringLiteral const & literal, OUString * rest = nullptr) const
1456  {
1457  bool b
1459  pData->buffer, literal.size, literal.data, literal.size)
1460  == 0);
1461  if (b && rest != nullptr) {
1462  *rest = copy(literal.size);
1463  }
1464  return b;
1465  }
1466 #endif
1467 
1482  bool endsWith(OUString const & str, OUString * rest = NULL) const {
1483  bool b = str.getLength() <= getLength()
1484  && match(str, getLength() - str.getLength());
1485  if (b && rest != NULL) {
1486  *rest = copy(0, getLength() - str.getLength());
1487  }
1488  return b;
1489  }
1490 
1496  template< typename T >
1498  endsWith(T & literal, OUString * rest = NULL) const
1499  {
1500  assert(
1502  bool b
1504  <= sal_uInt32(pData->length))
1506  (pData->buffer + pData->length
1509  literal),
1511  if (b && rest != NULL) {
1512  *rest = copy(
1513  0,
1514  (getLength()
1516  }
1517  return b;
1518  }
1519 
1520 #if defined LIBO_INTERNAL_ONLY
1521 
1522  template<typename T>
1524  endsWith(T & literal, OUString * rest = nullptr) const {
1525  bool b
1527  <= sal_uInt32(pData->length))
1529  (pData->buffer + pData->length
1533  literal),
1535  == 0);
1536  if (b && rest != nullptr) {
1537  *rest = copy(
1538  0,
1539  (getLength()
1541  }
1542  return b;
1543  }
1544 
1546  bool endsWith(OUStringLiteral const & literal, OUString * rest = nullptr)
1547  const
1548  {
1549  bool b = literal.size <= pData->length
1551  pData->buffer + pData->length - literal.size,
1552  literal.data, literal.size);
1553  if (b && rest != nullptr) {
1554  *rest = copy(0, (getLength() - literal.size));
1555  }
1556  return b;
1557  }
1558 #endif
1559 
1571  bool endsWithAsciiL(char const * asciiStr, sal_Int32 asciiStrLength)
1572  const
1573  {
1574  return asciiStrLength <= pData->length
1576  pData->buffer + pData->length - asciiStrLength, asciiStr,
1577  asciiStrLength);
1578  }
1579 
1600  bool endsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL) const
1601  {
1602  bool b = str.getLength() <= getLength()
1603  && matchIgnoreAsciiCase(str, getLength() - str.getLength());
1604  if (b && rest != NULL) {
1605  *rest = copy(0, getLength() - str.getLength());
1606  }
1607  return b;
1608  }
1609 
1615  template< typename T >
1617  endsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1618  {
1619  assert(
1621  bool b
1623  <= sal_uInt32(pData->length))
1625  (pData->buffer + pData->length
1629  literal),
1631  == 0);
1632  if (b && rest != NULL) {
1633  *rest = copy(
1634  0,
1635  (getLength()
1637  }
1638  return b;
1639  }
1640 
1641 #if defined LIBO_INTERNAL_ONLY
1642 
1643  template<typename T>
1645  endsWithIgnoreAsciiCase(T & literal, OUString * rest = nullptr) const {
1646  bool b
1648  <= sal_uInt32(pData->length))
1650  (pData->buffer + pData->length
1654  literal),
1656  == 0);
1657  if (b && rest != nullptr) {
1658  *rest = copy(
1659  0,
1660  (getLength()
1662  }
1663  return b;
1664  }
1665 
1667  bool endsWithIgnoreAsciiCase(
1668  OUStringLiteral const & literal, OUString * rest = nullptr) const
1669  {
1670  bool b = literal.size <= pData->length
1672  pData->buffer + pData->length - literal.size,
1673  literal.size, literal.data, literal.size)
1674  == 0);
1675  if (b && rest != nullptr) {
1676  *rest = copy(0, getLength() - literal.size);
1677  }
1678  return b;
1679  }
1680 #endif
1681 
1693  char const * asciiStr, sal_Int32 asciiStrLength) const
1694  {
1695  return asciiStrLength <= pData->length
1697  pData->buffer + pData->length - asciiStrLength,
1698  asciiStrLength, asciiStr, asciiStrLength)
1699  == 0);
1700  }
1701 
1702  friend bool operator == ( const OUString& rStr1, const OUString& rStr2 )
1703  { return rStr1.equals(rStr2); }
1704  friend bool operator == ( const OUString& rStr1, const sal_Unicode * pStr2 )
1705  { return rStr1.compareTo( pStr2 ) == 0; }
1706  friend bool operator == ( const sal_Unicode * pStr1, const OUString& rStr2 )
1707  { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
1708 
1709  friend bool operator != ( const OUString& rStr1, const OUString& rStr2 )
1710  { return !(operator == ( rStr1, rStr2 )); }
1711  friend bool operator != ( const OUString& rStr1, const sal_Unicode * pStr2 )
1712  { return !(operator == ( rStr1, pStr2 )); }
1713  friend bool operator != ( const sal_Unicode * pStr1, const OUString& rStr2 )
1714  { return !(operator == ( pStr1, rStr2 )); }
1715 
1716  friend bool operator < ( const OUString& rStr1, const OUString& rStr2 )
1717  { return rStr1.compareTo( rStr2 ) < 0; }
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 
1732  template< typename T >
1734  {
1735  assert(
1737  return rString.equalsAsciiL(
1740  }
1748  template< typename T >
1750  {
1751  assert(
1753  return rString.equalsAsciiL(
1756  }
1764  template< typename T >
1766  {
1767  assert(
1769  return !rString.equalsAsciiL(
1772  }
1780  template< typename T >
1782  {
1783  assert(
1785  return !rString.equalsAsciiL(
1788  }
1789 
1790 #if defined LIBO_INTERNAL_ONLY
1791 
1792  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1793  operator ==(OUString & string, T & literal) {
1794  return
1796  string.pData->buffer, string.pData->length,
1798  literal),
1800  == 0;
1801  }
1803  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1804  operator ==(T & literal, OUString & string) {
1805  return
1808  literal),
1810  string.pData->buffer, string.pData->length)
1811  == 0;
1812  }
1814  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1815  operator !=(OUString & string, T & literal) {
1816  return
1818  string.pData->buffer, string.pData->length,
1820  literal),
1822  != 0;
1823  }
1825  template<typename T> friend typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1826  operator !=(T & literal, OUString & string) {
1827  return
1830  literal),
1832  string.pData->buffer, string.pData->length)
1833  != 0;
1834  }
1835 #endif
1836 
1837 #if defined LIBO_INTERNAL_ONLY
1838 
1840  /* Comparison between OUString and OUStringLiteral.
1841 
1842  @since LibreOffice 5.0
1843  */
1844 
1845  friend bool operator ==(OUString const & lhs, OUStringLiteral const & rhs) {
1846  return lhs.equalsAsciiL(rhs.data, rhs.size);
1847  }
1848 
1849  friend bool operator !=(OUString const & lhs, OUStringLiteral const & rhs) {
1850  return !lhs.equalsAsciiL(rhs.data, rhs.size);
1851  }
1852 
1853  friend bool operator <(OUString const & lhs, OUStringLiteral const & rhs) {
1854  return
1856  lhs.pData->buffer, lhs.pData->length, rhs.data))
1857  < 0;
1858  }
1859 
1860  friend bool operator <=(OUString const & lhs, OUStringLiteral const & rhs) {
1861  return
1863  lhs.pData->buffer, lhs.pData->length, rhs.data))
1864  <= 0;
1865  }
1866 
1867  friend bool operator >(OUString const & lhs, OUStringLiteral const & rhs) {
1868  return
1870  lhs.pData->buffer, lhs.pData->length, rhs.data))
1871  > 0;
1872  }
1873 
1874  friend bool operator >=(OUString const & lhs, OUStringLiteral const & rhs) {
1875  return
1877  lhs.pData->buffer, lhs.pData->length, rhs.data))
1878  >= 0;
1879  }
1880 
1881  friend bool operator ==(OUStringLiteral const & lhs, OUString const & rhs) {
1882  return rhs.equalsAsciiL(lhs.data, lhs.size);
1883  }
1884 
1885  friend bool operator !=(OUStringLiteral const & lhs, OUString const & rhs) {
1886  return !rhs.equalsAsciiL(lhs.data, lhs.size);
1887  }
1888 
1889  friend bool operator <(OUStringLiteral const & lhs, OUString const & rhs) {
1890  return
1892  rhs.pData->buffer, rhs.pData->length, lhs.data))
1893  >= 0;
1894  }
1895 
1896  friend bool operator <=(OUStringLiteral const & lhs, OUString const & rhs) {
1897  return
1899  rhs.pData->buffer, rhs.pData->length, lhs.data))
1900  > 0;
1901  }
1902 
1903  friend bool operator >(OUStringLiteral const & lhs, OUString const & rhs) {
1904  return
1906  rhs.pData->buffer, rhs.pData->length, lhs.data))
1907  <= 0;
1908  }
1909 
1910  friend bool operator >=(OUStringLiteral const & lhs, OUString const & rhs) {
1911  return
1913  rhs.pData->buffer, rhs.pData->length, lhs.data))
1914  < 0;
1915  }
1916 
1918 #endif
1919 
1927  sal_Int32 hashCode() const
1928  {
1929  return rtl_ustr_hashCode_WithLength( pData->buffer, pData->length );
1930  }
1931 
1945  sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
1946  {
1947  sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1948  return (ret < 0 ? ret : ret+fromIndex);
1949  }
1950 
1960  sal_Int32 lastIndexOf( sal_Unicode ch ) const
1961  {
1962  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1963  }
1964 
1977  sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
1978  {
1979  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1980  }
1981 
1997  sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
1998  {
1999  sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
2000  str.pData->buffer, str.pData->length );
2001  return (ret < 0 ? ret : ret+fromIndex);
2002  }
2003 
2009  template< typename T >
2010  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
2011  {
2012  assert(
2014  sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
2015  pData->buffer + fromIndex, pData->length - fromIndex,
2018  return n < 0 ? n : n + fromIndex;
2019  }
2020 
2021 #if defined LIBO_INTERNAL_ONLY
2022 
2023  template<typename T>
2024  typename
2026  indexOf(T & literal, sal_Int32 fromIndex = 0) const {
2027  assert(fromIndex >= 0);
2029  pData->buffer + fromIndex, pData->length - fromIndex,
2032  return n < 0 ? n : n + fromIndex;
2033  }
2034 
2036  sal_Int32 indexOf(OUStringLiteral const & literal, sal_Int32 fromIndex = 0)
2037  const
2038  {
2039  sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
2040  pData->buffer + fromIndex, pData->length - fromIndex, literal.data,
2041  literal.size);
2042  return n < 0 ? n : n + fromIndex;
2043  }
2044 #endif
2045 
2069  sal_Int32 indexOfAsciiL(
2070  char const * str, sal_Int32 len, sal_Int32 fromIndex = 0) const
2071  {
2072  sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
2073  pData->buffer + fromIndex, pData->length - fromIndex, str, len);
2074  return ret < 0 ? ret : ret + fromIndex;
2075  }
2076 
2077  // This overload is left undefined, to detect calls of indexOfAsciiL that
2078  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
2079  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
2080  // platforms):
2081 #if SAL_TYPES_SIZEOFLONG == 8
2082  void indexOfAsciiL(char const *, sal_Int32 len, rtl_TextEncoding) const;
2083 #endif
2084 
2100  sal_Int32 lastIndexOf( const OUString & str ) const
2101  {
2102  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
2103  str.pData->buffer, str.pData->length );
2104  }
2105 
2123  sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
2124  {
2125  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
2126  str.pData->buffer, str.pData->length );
2127  }
2128 
2134  template< typename T >
2136  {
2137  assert(
2140  pData->buffer, pData->length,
2143  }
2144 
2145 #if defined LIBO_INTERNAL_ONLY
2146 
2147  template<typename T>
2148  typename
2150  lastIndexOf(T & literal) const {
2152  pData->buffer, pData->length,
2155  }
2156 
2158  sal_Int32 lastIndexOf(OUStringLiteral const & literal) const {
2160  pData->buffer, pData->length, literal.data, literal.size);
2161  }
2162 #endif
2163 
2183  sal_Int32 lastIndexOfAsciiL(char const * str, sal_Int32 len) const
2184  {
2186  pData->buffer, pData->length, str, len);
2187  }
2188 
2199  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex ) const
2200  {
2201  rtl_uString *pNew = NULL;
2202  rtl_uString_newFromSubString( &pNew, pData, beginIndex, getLength() - beginIndex );
2203  return OUString( pNew, SAL_NO_ACQUIRE );
2204  }
2205 
2218  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const
2219  {
2220  rtl_uString *pNew = NULL;
2221  rtl_uString_newFromSubString( &pNew, pData, beginIndex, count );
2222  return OUString( pNew, SAL_NO_ACQUIRE );
2223  }
2224 
2234  {
2235  rtl_uString* pNew = NULL;
2236  rtl_uString_newConcat( &pNew, pData, str.pData );
2237  return OUString( pNew, SAL_NO_ACQUIRE );
2238  }
2239 
2240 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2241  friend OUString operator+( const OUString& rStr1, const OUString& rStr2 )
2242  {
2243  return rStr1.concat( rStr2 );
2244  }
2245 #endif
2246 
2260  SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const
2261  {
2262  rtl_uString* pNew = NULL;
2263  rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
2264  return OUString( pNew, SAL_NO_ACQUIRE );
2265  }
2266 
2281  {
2282  rtl_uString* pNew = NULL;
2283  rtl_uString_newReplace( &pNew, pData, oldChar, newChar );
2284  return OUString( pNew, SAL_NO_ACQUIRE );
2285  }
2286 
2306  OUString const & from, OUString const & to, sal_Int32 * index = NULL) const
2307  {
2308  rtl_uString * s = NULL;
2309  sal_Int32 i = 0;
2311  &s, pData, from.pData, to.pData, index == NULL ? &i : index);
2312  return OUString(s, SAL_NO_ACQUIRE);
2313  }
2314 
2333  template< typename T >
2335  sal_Int32 * index = NULL) const
2336  {
2338  rtl_uString * s = NULL;
2339  sal_Int32 i = 0;
2341  &s, pData,
2344  index == NULL ? &i : index);
2345  return OUString(s, SAL_NO_ACQUIRE);
2346  }
2347 
2366  template< typename T >
2368  sal_Int32 * index = NULL) const
2369  {
2371  rtl_uString * s = NULL;
2372  sal_Int32 i = 0;
2374  &s, pData, from.pData,
2377  index == NULL ? &i : index);
2378  return OUString(s, SAL_NO_ACQUIRE);
2379  }
2380 
2399  template< typename T1, typename T2 >
2401  replaceFirst( T1& from, T2& to, sal_Int32 * index = NULL) const
2402  {
2405  rtl_uString * s = NULL;
2406  sal_Int32 i = 0;
2408  &s, pData,
2413  index == NULL ? &i : index);
2414  return OUString(s, SAL_NO_ACQUIRE);
2415  }
2416 
2417 #if defined LIBO_INTERNAL_ONLY
2418 
2419  template<typename T> SAL_WARN_UNUSED_RESULT
2420  typename
2422  replaceFirst(T & from, OUString const & to, sal_Int32 * index = nullptr)
2423  const
2424  {
2425  rtl_uString * s = nullptr;
2426  sal_Int32 i = 0;
2428  &s, pData,
2431  to.pData->buffer, to.pData->length, index == nullptr ? &i : index);
2432  if (s == nullptr) {
2433  throw std::bad_alloc();
2434  // should be std::length_error if resulting would be too large
2435  }
2436  return OUString(s, SAL_NO_ACQUIRE);
2437  }
2439  template<typename T> SAL_WARN_UNUSED_RESULT
2440  typename
2442  replaceFirst(OUString const & from, T & to, sal_Int32 * index = nullptr)
2443  const
2444  {
2445  rtl_uString * s = nullptr;
2446  sal_Int32 i = 0;
2448  &s, pData, from.pData->buffer, from.pData->length,
2451  index == nullptr ? &i : index);
2452  if (s == nullptr) {
2453  throw std::bad_alloc();
2454  // should be std::length_error if resulting would be too large
2455  }
2456  return OUString(s, SAL_NO_ACQUIRE);
2457  }
2459  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2460  typename
2462  T1,
2464  T2, OUString>::TypeUtf16
2465  >::TypeUtf16
2466  replaceFirst(T1 & from, T2 & to, sal_Int32 * index = nullptr) const {
2467  rtl_uString * s = nullptr;
2468  sal_Int32 i = 0;
2470  &s, pData,
2475  index == nullptr ? &i : index);
2476  if (s == nullptr) {
2477  throw std::bad_alloc();
2478  // should be std::length_error if resulting would be too large
2479  }
2480  return OUString(s, SAL_NO_ACQUIRE);
2481  }
2483  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2484  typename
2486  T1,
2488  T2, OUString>::Type
2489  >::TypeUtf16
2490  replaceFirst(T1 & from, T2 & to, sal_Int32 * index = nullptr) const {
2491  rtl_uString * s = nullptr;
2492  sal_Int32 i = 0;
2494  &s, pData,
2499  index == nullptr ? &i : index);
2500  if (s == nullptr) {
2501  throw std::bad_alloc();
2502  // should be std::length_error if resulting would be too large
2503  }
2504  return OUString(s, SAL_NO_ACQUIRE);
2505  }
2507  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2508  typename
2510  T1,
2512  T2, OUString>::TypeUtf16
2513  >::Type
2514  replaceFirst(T1 & from, T2 & to, sal_Int32 * index = nullptr) const {
2515  rtl_uString * s = nullptr;
2516  sal_Int32 i = 0;
2518  &s, pData,
2523  index == nullptr ? &i : index);
2524  if (s == nullptr) {
2525  throw std::bad_alloc();
2526  // should be std::length_error if resulting would be too large
2527  }
2528  return OUString(s, SAL_NO_ACQUIRE);
2529  }
2530 
2532  SAL_WARN_UNUSED_RESULT OUString replaceFirst(
2533  OUStringLiteral const & from, OUString const & to,
2534  sal_Int32 * index = nullptr) const
2535  {
2536  rtl_uString * s = nullptr;
2537  sal_Int32 i = 0;
2539  &s, pData, from.data, from.size, to.pData,
2540  index == nullptr ? &i : index);
2541  return OUString(s, SAL_NO_ACQUIRE);
2542  }
2544  SAL_WARN_UNUSED_RESULT OUString replaceFirst(
2545  OUString const & from, OUStringLiteral const & to,
2546  sal_Int32 * index = nullptr) const
2547  {
2548  rtl_uString * s = nullptr;
2549  sal_Int32 i = 0;
2551  &s, pData, from.pData, to.data, to.size,
2552  index == nullptr ? &i : index);
2553  return OUString(s, SAL_NO_ACQUIRE);
2554  }
2556  SAL_WARN_UNUSED_RESULT OUString replaceFirst(
2557  OUStringLiteral const & from, OUStringLiteral const & to,
2558  sal_Int32 * index = nullptr) const
2559  {
2560  rtl_uString * s = nullptr;
2561  sal_Int32 i = 0;
2563  &s, pData, from.data, from.size, to.data, to.size,
2564  index == nullptr ? &i : index);
2565  return OUString(s, SAL_NO_ACQUIRE);
2566  }
2568  template<typename T> SAL_WARN_UNUSED_RESULT
2570  replaceFirst(
2571  OUStringLiteral const & from, T & to, sal_Int32 * index = nullptr) const
2572  {
2574  rtl_uString * s = nullptr;
2575  sal_Int32 i = 0;
2577  &s, pData, from.data, from.size,
2580  index == nullptr ? &i : index);
2581  return OUString(s, SAL_NO_ACQUIRE);
2582  }
2584  template<typename T> SAL_WARN_UNUSED_RESULT
2586  replaceFirst(
2587  T & from, OUStringLiteral const & to, sal_Int32 * index = nullptr) const
2588  {
2590  rtl_uString * s = nullptr;
2591  sal_Int32 i = 0;
2593  &s, pData,
2596  to.size, index == nullptr ? &i : index);
2597  return OUString(s, SAL_NO_ACQUIRE);
2598  }
2600  template<typename T> SAL_WARN_UNUSED_RESULT
2601  typename
2603  replaceFirst(
2604  OUStringLiteral const & from, T & to, sal_Int32 * index = nullptr) const
2605  {
2607  rtl_uString * s = nullptr;
2608  sal_Int32 i = 0;
2610  &s, pData, from.data, from.size,
2613  index == nullptr ? &i : index);
2614  return OUString(s, SAL_NO_ACQUIRE);
2615  }
2617  template<typename T> SAL_WARN_UNUSED_RESULT
2618  typename
2620  replaceFirst(
2621  T & from, OUStringLiteral const & to, sal_Int32 * index = nullptr) const
2622  {
2624  rtl_uString * s = nullptr;
2625  sal_Int32 i = 0;
2627  &s, pData,
2630  to.size, index == nullptr ? &i : index);
2631  return OUString(s, SAL_NO_ACQUIRE);
2632  }
2633 #endif
2634 
2651  OUString const & from, OUString const & to, sal_Int32 fromIndex = 0) const
2652  {
2653  rtl_uString * s = NULL;
2654  rtl_uString_newReplaceAllFromIndex(&s, pData, from.pData, to.pData, fromIndex);
2655  return OUString(s, SAL_NO_ACQUIRE);
2656  }
2657 
2671  template< typename T >
2673  {
2675  rtl_uString * s = NULL;
2677  &s, pData,
2680  return OUString(s, SAL_NO_ACQUIRE);
2681  }
2682 
2696  template< typename T >
2698  {
2700  rtl_uString * s = NULL;
2702  &s, pData, from.pData,
2705  return OUString(s, SAL_NO_ACQUIRE);
2706  }
2707 
2721  template< typename T1, typename T2 >
2723  replaceAll( T1& from, T2& to ) const
2724  {
2727  rtl_uString * s = NULL;
2729  &s, pData,
2734  return OUString(s, SAL_NO_ACQUIRE);
2735  }
2736 
2737 #if defined LIBO_INTERNAL_ONLY
2738 
2739  template<typename T> SAL_WARN_UNUSED_RESULT
2740  typename
2742  replaceAll(T & from, OUString const & to) const {
2743  rtl_uString * s = nullptr;
2745  &s, pData,
2748  to.pData->buffer, to.pData->length);
2749  if (s == nullptr) {
2750  throw std::bad_alloc();
2751  // should be std::length_error if resulting would be too large
2752  }
2753  return OUString(s, SAL_NO_ACQUIRE);
2754  }
2756  template<typename T> SAL_WARN_UNUSED_RESULT
2757  typename
2759  replaceAll(OUString const & from, T & to) const {
2760  rtl_uString * s = nullptr;
2762  &s, pData, from.pData->buffer, from.pData->length,
2765  if (s == nullptr) {
2766  throw std::bad_alloc();
2767  // should be std::length_error if resulting would be too large
2768  }
2769  return OUString(s, SAL_NO_ACQUIRE);
2770  }
2772  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2773  typename
2775  T1,
2777  T2, OUString>::TypeUtf16
2778  >::TypeUtf16
2779  replaceAll(T1 & from, T2 & to) const {
2780  rtl_uString * s = nullptr;
2782  &s, pData,
2787  if (s == nullptr) {
2788  throw std::bad_alloc();
2789  // should be std::length_error if resulting would be too large
2790  }
2791  return OUString(s, SAL_NO_ACQUIRE);
2792  }
2794  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2795  typename
2797  T1,
2799  T2, OUString>::Type
2800  >::TypeUtf16
2801  replaceAll(T1 & from, T2 & to) const {
2802  rtl_uString * s = nullptr;
2804  &s, pData,
2809  if (s == nullptr) {
2810  throw std::bad_alloc();
2811  // should be std::length_error if resulting would be too large
2812  }
2813  return OUString(s, SAL_NO_ACQUIRE);
2814  }
2816  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2817  typename
2819  T1,
2821  T2, OUString>::TypeUtf16
2822  >::Type
2823  replaceAll(T1 & from, T2 & to) const {
2824  rtl_uString * s = nullptr;
2826  &s, pData,
2831  if (s == nullptr) {
2832  throw std::bad_alloc();
2833  // should be std::length_error if resulting would be too large
2834  }
2835  return OUString(s, SAL_NO_ACQUIRE);
2836  }
2837 
2839  SAL_WARN_UNUSED_RESULT OUString replaceAll(
2840  OUStringLiteral const & from, OUString const & to) const
2841  {
2842  rtl_uString * s = nullptr;
2844  &s, pData, from.data, from.size, to.pData);
2845  return OUString(s, SAL_NO_ACQUIRE);
2846  }
2848  SAL_WARN_UNUSED_RESULT OUString replaceAll(
2849  OUString const & from, OUStringLiteral const & to) const
2850  {
2851  rtl_uString * s = nullptr;
2853  &s, pData, from.pData, to.data, to.size);
2854  return OUString(s, SAL_NO_ACQUIRE);
2855  }
2857  SAL_WARN_UNUSED_RESULT OUString replaceAll(
2858  OUStringLiteral const & from, OUStringLiteral const & to) const
2859  {
2860  rtl_uString * s = nullptr;
2862  &s, pData, from.data, from.size, to.data, to.size);
2863  return OUString(s, SAL_NO_ACQUIRE);
2864  }
2866  template<typename T> SAL_WARN_UNUSED_RESULT
2868  replaceAll(OUStringLiteral const & from, T & to) const {
2870  rtl_uString * s = nullptr;
2872  &s, pData, from.data, from.size,
2875  return OUString(s, SAL_NO_ACQUIRE);
2876  }
2878  template<typename T> SAL_WARN_UNUSED_RESULT
2880  replaceAll(T & from, OUStringLiteral const & to) const {
2882  rtl_uString * s = nullptr;
2884  &s, pData,
2887  to.size);
2888  return OUString(s, SAL_NO_ACQUIRE);
2889  }
2891  template<typename T> SAL_WARN_UNUSED_RESULT
2892  typename
2894  replaceAll(OUStringLiteral const & from, T & to) const {
2896  rtl_uString * s = nullptr;
2898  &s, pData, from.data, from.size,
2901  return OUString(s, SAL_NO_ACQUIRE);
2902  }
2904  template<typename T> SAL_WARN_UNUSED_RESULT
2905  typename
2907  replaceAll(T & from, OUStringLiteral const & to) const {
2909  rtl_uString * s = nullptr;
2911  &s, pData,
2914  to.size);
2915  return OUString(s, SAL_NO_ACQUIRE);
2916  }
2917 #endif
2918 
2930  {
2931  rtl_uString* pNew = NULL;
2932  rtl_uString_newToAsciiLowerCase( &pNew, pData );
2933  return OUString( pNew, SAL_NO_ACQUIRE );
2934  }
2935 
2947  {
2948  rtl_uString* pNew = NULL;
2949  rtl_uString_newToAsciiUpperCase( &pNew, pData );
2950  return OUString( pNew, SAL_NO_ACQUIRE );
2951  }
2952 
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 private:
3551  OUString & internalAppend( rtl_uString* pOtherData )
3552  {
3553  rtl_uString* pNewData = NULL;
3554  rtl_uString_newConcat( &pNewData, pData, pOtherData );
3555  if (pNewData == NULL) {
3556  throw std::bad_alloc();
3557  }
3558  rtl_uString_assign(&pData, pNewData);
3559  rtl_uString_release(pNewData);
3560  return *this;
3561  }
3562 
3563 };
3564 
3565 #if defined LIBO_INTERNAL_ONLY
3566 // Prevent the operator ==/!= overloads with 'sal_Unicode const *' parameter from
3567 // being selected for nonsensical code like
3568 //
3569 // if (ouIdAttr == nullptr)
3570 //
3571 void operator ==(OUString const &, std::nullptr_t) = delete;
3572 void operator ==(std::nullptr_t, OUString const &) = delete;
3573 void operator !=(OUString const &, std::nullptr_t) = delete;
3574 void operator !=(std::nullptr_t, OUString const &) = delete;
3575 #endif
3576 
3577 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3578 
3583 template<>
3584 struct ToStringHelper< OUString >
3585  {
3586  static int length( const OUString& s ) { return s.getLength(); }
3587  static sal_Unicode* addData( sal_Unicode* buffer, const OUString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
3588  static const bool allowOStringConcat = false;
3589  static const bool allowOUStringConcat = true;
3590  };
3591 
3595 template<>
3596 struct ToStringHelper< OUStringLiteral >
3597  {
3598  static int length( const OUStringLiteral& str ) { return str.size; }
3599  static sal_Unicode* addData( sal_Unicode* buffer, const OUStringLiteral& str ) { return addDataLiteral( buffer, str.data, str.size ); }
3600  static const bool allowOStringConcat = false;
3601  static const bool allowOUStringConcat = true;
3602  };
3603 
3607 template< typename charT, typename traits, typename T1, typename T2 >
3608 inline std::basic_ostream<charT, traits> & operator <<(
3609  std::basic_ostream<charT, traits> & stream, OUStringConcat< T1, T2 >&& concat)
3610 {
3611  return stream << OUString( std::move(concat) );
3612 }
3613 
3615 #endif
3616 
3623 {
3633  size_t operator()(const OUString& rString) const
3634  { return static_cast<size_t>(rString.hashCode()); }
3635 };
3636 
3637 /* ======================================================================= */
3638 
3656 inline OUString OStringToOUString( const OString & rStr,
3657  rtl_TextEncoding encoding,
3658  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
3659 {
3660  return OUString( rStr.getStr(), rStr.getLength(), encoding, convertFlags );
3661 }
3662 
3680 inline OString OUStringToOString( const OUString & rUnicode,
3681  rtl_TextEncoding encoding,
3682  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
3683 {
3684  return OString( rUnicode.getStr(), rUnicode.getLength(), encoding, convertFlags );
3685 }
3686 
3687 /* ======================================================================= */
3688 
3697 template< typename charT, typename traits >
3698 inline std::basic_ostream<charT, traits> & operator <<(
3699  std::basic_ostream<charT, traits> & stream, OUString const & rString)
3700 {
3701  return stream <<
3703  // best effort; potentially loses data due to conversion failures
3704  // (stray surrogate halves) and embedded null characters
3705 }
3706 
3707 } // namespace
3708 
3709 #ifdef RTL_STRING_UNITTEST
3710 namespace rtl
3711 {
3712 typedef rtlunittest::OUString OUString;
3713 }
3714 #endif
3715 
3716 // In internal code, allow to use classes like OUString without having to
3717 // explicitly refer to the rtl namespace, which is kind of superfluous given
3718 // that OUString itself is namespaced by its OU prefix:
3719 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3720 using ::rtl::OUString;
3721 using ::rtl::OUStringHash;
3724 using ::rtl::OUStringLiteral;
3725 using ::rtl::OUStringLiteral1;
3726 #endif
3727 
3729 
3734 #if defined LIBO_INTERNAL_ONLY
3735 namespace std {
3736 
3737 template<>
3738 struct hash<::rtl::OUString>
3739 {
3740  std::size_t operator()(::rtl::OUString const & s) const
3741  { return std::size_t(s.hashCode()); }
3742 };
3743 
3744 }
3745 
3746 #endif
3747 
3749 #endif /* _RTL_USTRING_HXX */
3750 
3751 /* 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:3450
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:2069
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
OUString()
New string containing no characters.
Definition: ustring.hxx:133
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:3131
#define OSTRING_TO_OUSTRING_CVTFLAGS
Definition: ustring.h:2120
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: ustring.hxx:3056
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:743
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: ustring.hxx:628
bool equalsIgnoreAsciiCaseAscii(const sal_Char *asciiStr) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1161
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:641
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:1276
OUString & operator=(const OUString &str)
Assign a new string.
Definition: ustring.hxx:438
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:1482
OUString intern() const
Return a canonical representation for a string.
Definition: ustring.hxx:3152
static OUString const & unacquired(rtl_uString *const *ppHandle)
Provides an OUString const & passing a storage pointer of an rtl_uString * handle.
Definition: ustring.hxx:430
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:3105
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1733
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:120
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:3372
#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...
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:194
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:3354
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:602
OUString(sal_uInt32 const *codePoints, sal_Int32 codePointCount)
Create a new string from an array of Unicode code points.
Definition: ustring.hxx:381
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_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:3633
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:3030
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:3017
SAL_WARN_UNUSED_RESULT OUString concat(const OUString &str) const
Concatenates the specified string to the end of this string.
Definition: ustring.hxx:2233
bool equals(const OUString &str) const
Perform a comparison of two strings.
Definition: ustring.hxx:783
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:1238
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:2183
const sal_Char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:426
bool convertToString(OString *pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) const
Converts to an OString, signalling failure.
Definition: ustring.hxx:3225
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:2241
sal_Int32 compareTo(const OUString &str, sal_Int32 maxLength) const
Compares two strings with a maximum count of characters.
Definition: ustring.hxx:713
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:2100
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:3381
unsigned char sal_Bool
Definition: types.h:38
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfFloat(sal_Unicode *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
SAL_DLLPUBLIC 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:1977
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:845
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:2010
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:1600
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:1617
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_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:3283
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:2218
bool equalsAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform a comparison of two strings.
Definition: ustring.hxx:1134
bool operator!=(const Any &rAny, const C &value)
Template unequality operator: compares set value of left side any to right side value.
Definition: Any.hxx:645
sal_Int32 reverseCompareTo(const OUString &str) const
Compares two strings in reverse order.
Definition: ustring.hxx:731
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:1890
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:370
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:2260
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:302
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:2305
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:897
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: ustring.hxx:3073
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:2672
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:651
OString toUtf8() const
Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully.
Definition: ustring.hxx:3322
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1781
OUString(rtl_uString *str)
New string from OUString data.
Definition: ustring.hxx:172
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:2199
#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:1319
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:966
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:141
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:90
const sal_Unicode * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:663
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1749
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.
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:110
OUString getToken(sal_Int32 token, sal_Unicode cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: ustring.hxx:2997
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:2929
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:1036
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:1395
sal_Unicode toChar() const
Returns the first character from this string.
Definition: ustring.hxx:3041
bool equalsIgnoreAsciiCaseAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1209
static OUString number(float f)
Returns the string representation of the float argument.
Definition: ustring.hxx:3398
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:2123
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:1945
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:2367
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:100
float toFloat() const
Returns the float value from this string.
Definition: ustring.hxx:3118
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:1960
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: ustring.hxx:3088
sal_Int32 compareToIgnoreAsciiCaseAscii(const sal_Char *asciiStr) const
Compares two ASCII strings ignoring case.
Definition: ustring.hxx:1184
Definition: bootstrap.hxx:29
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:2723
A helper to use OUStrings with hash maps.
Definition: ustring.hxx:3622
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:123
definition of a no acquire enum for ctors
Definition: types.h:374
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1765
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:979
#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:489
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:692
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:252
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:400
bool endsWithAsciiL(char const *asciiStr, sal_Int32 asciiStrLength) const
Check whether this string ends with a given ASCII string.
Definition: ustring.hxx:1571
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:354
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:909
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:2946
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: ustring.hxx:1927
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:2650
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:3656
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
OUString(const sal_Unicode *value)
New string from a Unicode character buffer array.
Definition: ustring.hxx:216
sal_Int32 compareToIgnoreAsciiCase(const OUString &str) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:832
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:2334
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_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:144
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:2280
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:3680
Definition: stringutils.hxx:118
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:1498
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition: ustring.hxx:540
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
#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:1997
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:1111
~OUString()
Release the string data.
Definition: ustring.hxx:414
static OUString number(double d)
Returns the string representation of the double argument.
Definition: ustring.hxx:3415
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.
A string buffer implements a mutable sequence of characters.
Definition: ustrbuf.hxx:59
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:1090
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:2135
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:1412
bool equalsIgnoreAsciiCase(const OUString &str) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:807
OUString(rtl_uString *str, __sal_NoAcquire)
New OUString from OUString data without acquiring it.
Definition: ustring.hxx:186
bool startsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: ustring.hxx:1305
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:1692
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:2401
OUString(const sal_Unicode *value, sal_Int32 length)
New string from a Unicode character buffer array.
Definition: ustring.hxx:230
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:3345
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:2697
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:476
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:92
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:1325