LibreOffice
LibreOffice 5.3 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ustring.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_RTL_USTRING_HXX
21 #define INCLUDED_RTL_USTRING_HXX
22 
23 #include <sal/config.h>
24 
25 #include <cassert>
26 #include <cstddef>
27 #include <new>
28 #include <ostream>
29 #include <string.h>
30 
31 #include <rtl/ustring.h>
32 #include <rtl/string.hxx>
33 #include <rtl/stringutils.hxx>
34 #include <rtl/textenc.h>
35 #include <sal/log.hxx>
36 
37 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
38 #include <config_global.h>
39 #include <rtl/stringconcat.hxx>
40 #endif
41 
42 // The unittest uses slightly different code to help check that the proper
43 // calls are made. The class is put into a different namespace to make
44 // sure the compiler generates a different (if generating also non-inline)
45 // copy of the function and does not merge them together. The class
46 // is "brought" into the proper rtl namespace by a typedef below.
47 #ifdef RTL_STRING_UNITTEST
48 #define rtl rtlunittest
49 #endif
50 
51 namespace rtl
52 {
53 
54 #ifdef RTL_STRING_UNITTEST
55 #undef rtl
56 #endif
57 
58 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
59 
69 struct SAL_WARN_UNUSED OUStringLiteral
70 {
71  template< int N >
72  explicit SAL_CONSTEXPR OUStringLiteral( const char (&str)[ N ] ) : size( N - 1 ), data( str )
73  { /* only C++14 constexpr: assert( strlen( str ) == N - 1 ); */ }
74  int size;
75  const char* data;
76 };
77 
79 #endif
80 
81 /* ======================================================================= */
82 
106 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OUString
107 {
108 public:
110  rtl_uString * pData;
112 
117  {
118  pData = NULL;
119  rtl_uString_new( &pData );
120  }
121 
127  OUString( const OUString & str )
128  {
129  pData = str.pData;
130  rtl_uString_acquire( pData );
131  }
132 
133 #ifndef _MSC_VER // TODO?
134 #if defined LIBO_INTERNAL_ONLY
135 
141  OUString( OUString && str )
142  {
143  pData = str.pData;
144  str.pData = nullptr;
145  rtl_uString_new( &str.pData );
146  }
147 #endif
148 #endif
149 
155  OUString( rtl_uString * str )
156  {
157  pData = str;
158  rtl_uString_acquire( pData );
159  }
160 
169  inline OUString( rtl_uString * str, __sal_NoAcquire )
170  { pData = str; }
171 
177  explicit OUString( sal_Unicode value )
178  : pData (NULL)
179  {
180  rtl_uString_newFromStr_WithLength( &pData, &value, 1 );
181  }
182 
183 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
184  // Catch inadvertent conversions to the above ctor (but still allow
186  // construction from char literals):
187  OUString(int) = delete;
188  explicit OUString(char c):
189  OUString(sal_Unicode(static_cast<unsigned char>(c)))
190  {}
192 #endif
193 
199  OUString( const sal_Unicode * value )
200  {
201  pData = NULL;
202  rtl_uString_newFromStr( &pData, value );
203  }
204 
213  OUString( const sal_Unicode * value, sal_Int32 length )
214  {
215  pData = NULL;
216  rtl_uString_newFromStr_WithLength( &pData, value, length );
217  }
218 
234  template< typename T >
236  {
237  assert(
239  pData = NULL;
241  rtl_uString_new(&pData);
242  } else {
244  &pData,
246  literal),
248  }
249 #ifdef RTL_STRING_UNITTEST
250  rtl_string_unittest_const_literal = true;
251 #endif
252  }
253 
254 #if defined LIBO_INTERNAL_ONLY
255 
256  template<typename T> OUString(
257  T & literal,
259  T, libreoffice_internal::Dummy>::TypeUtf16
261  pData(nullptr)
262  {
264  rtl_uString_new(&pData);
265  } else {
267  &pData,
268  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
269  literal),
270  libreoffice_internal::ConstCharArrayDetector<T>::length);
271  }
272  }
273 #endif
274 
275 #ifdef RTL_STRING_UNITTEST
276 
280  template< typename T >
281  OUString( T&, typename libreoffice_internal::ExceptConstCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
282  {
283  pData = NULL;
284  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
285  rtl_string_unittest_invalid_conversion = true;
286  }
291  template< typename T >
292  OUString( const T&, typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
293  {
294  pData = NULL;
295  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
296  rtl_string_unittest_invalid_conversion = true;
297  }
298 #endif
299 
300 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
301 
317  OUString(OUStringLiteral literal): pData(NULL) {
318  rtl_uString_newFromLiteral(&pData, literal.data, literal.size, 0);
319  }
321 #endif
322 
337  OUString( const sal_Char * value, sal_Int32 length,
338  rtl_TextEncoding encoding,
339  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
340  {
341  pData = NULL;
342  rtl_string2UString( &pData, value, length, encoding, convertFlags );
343  if (pData == NULL) {
344  throw std::bad_alloc();
345  }
346  }
347 
364  inline explicit OUString(
365  sal_uInt32 const * codePoints, sal_Int32 codePointCount):
366  pData(NULL)
367  {
368  rtl_uString_newFromCodePoints(&pData, codePoints, codePointCount);
369  if (pData == NULL) {
370  throw std::bad_alloc();
371  }
372  }
373 
374 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
375 
379  template< typename T1, typename T2 >
380  OUString( const OUStringConcat< T1, T2 >& c )
381  {
382  const sal_Int32 l = c.length();
383  pData = rtl_uString_alloc( l );
384  if (l != 0)
385  {
386  sal_Unicode* end = c.addData( pData->buffer );
387  pData->length = l;
388  *end = '\0';
389  // TODO realloc in case pData->length is noticeably smaller than l?
390  }
391  }
392 #endif
393 
398  {
399  rtl_uString_release( pData );
400  }
401 
413  static inline OUString const & unacquired( rtl_uString * const * ppHandle )
414  { return * reinterpret_cast< OUString const * >( ppHandle ); }
415 
421  OUString & operator=( const OUString & str )
422  {
423  rtl_uString_assign( &pData, str.pData );
424  return *this;
425  }
426 
427 #ifndef _MSC_VER // TODO?
428 #if defined LIBO_INTERNAL_ONLY
429 
435  OUString & operator=( OUString && str )
436  {
437  rtl_uString_release( pData );
438  pData = str.pData;
439  str.pData = nullptr;
440  rtl_uString_new( &str.pData );
441  return *this;
442  }
443 #endif
444 #endif
445 
458  template< typename T >
460  {
461  assert(
464  rtl_uString_new(&pData);
465  } else {
467  &pData,
469  literal),
471  }
472  return *this;
473  }
474 
475 #if defined LIBO_INTERNAL_ONLY
476 
477  template<typename T>
478  typename
480  operator =(T & literal) {
482  rtl_uString_new(&pData);
483  } else {
485  &pData,
486  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
487  literal),
488  libreoffice_internal::ConstCharArrayDetector<T>::length);
489  }
490  return *this;
491  }
492 #endif
493 
499  OUString & operator+=( const OUString & str )
500 #if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
501  &
502 #endif
503  {
504  rtl_uString_newConcat( &pData, pData, str.pData );
505  return *this;
506  }
507 #if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
508  void operator+=(OUString const &) && = delete;
509 #endif
510 
517  template<typename T>
519  operator +=(T & literal)
520 #if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
521  &
522 #endif
523  {
524  assert(
527  &pData, pData,
530  return *this;
531  }
532 #if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
533  template<typename T>
535  operator +=(T &) && = delete;
536 #endif
537 
538 #if defined LIBO_INTERNAL_ONLY
539 
540  template<typename T>
541  typename
543  operator +=(T & literal)
544 #if HAVE_CXX11_REF_QUALIFIER
545  &
546 #endif
547  {
549  &pData, pData,
552  return *this;
553  }
554 #if HAVE_CXX11_REF_QUALIFIER
555  template<typename T>
556  typename
557  libreoffice_internal::ConstCharArrayDetector<T, OUString &>::TypeUtf16
558  operator +=(T &) && = delete;
559 #endif
560 #endif
561 
562 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
563 
567  template< typename T1, typename T2 >
568  OUString& operator+=( const OUStringConcat< T1, T2 >& c )
569 #if HAVE_CXX11_REF_QUALIFIER
570  &
571 #endif
572  {
573  sal_Int32 l = c.length();
574  if( l == 0 )
575  return *this;
576  l += pData->length;
577  rtl_uString_ensureCapacity( &pData, l );
578  sal_Unicode* end = c.addData( pData->buffer + pData->length );
579  *end = '\0';
580  pData->length = l;
581  return *this;
582  }
583 #if HAVE_CXX11_REF_QUALIFIER
584  template<typename T1, typename T2> void operator +=(
585  OUStringConcat<T1, T2> const &) && = delete;
586 #endif
587 #endif
588 
593  void clear()
594  {
595  rtl_uString_new( &pData );
596  }
597 
606  sal_Int32 getLength() const { return pData->length; }
607 
616  bool isEmpty() const
617  {
618  return pData->length == 0;
619  }
620 
628  const sal_Unicode * getStr() const { return pData->buffer; }
629 
639  sal_Unicode operator [](sal_Int32 index) const {
640  // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
641  assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
642  return getStr()[index];
643  }
644 
657  sal_Int32 compareTo( const OUString & str ) const
658  {
659  return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
660  str.pData->buffer, str.pData->length );
661  }
662 
678  sal_Int32 compareTo( const OUString & str, sal_Int32 maxLength ) const
679  {
680  return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
681  str.pData->buffer, str.pData->length, maxLength );
682  }
683 
696  sal_Int32 reverseCompareTo( const OUString & str ) const
697  {
698  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
699  str.pData->buffer, str.pData->length );
700  }
701 
707  template< typename T >
709  {
710  assert(
713  pData->buffer, pData->length,
716  }
717 
718 #if defined LIBO_INTERNAL_ONLY
719 
720  template<typename T>
721  typename
723  reverseCompareTo(T & literal) const {
725  pData->buffer, pData->length,
728  }
729 #endif
730 
742  bool equals( const OUString & str ) const
743  {
744  if ( pData->length != str.pData->length )
745  return false;
746  if ( pData == str.pData )
747  return true;
748  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
749  str.pData->buffer, str.pData->length ) == 0;
750  }
751 
766  bool equalsIgnoreAsciiCase( const OUString & str ) const
767  {
768  if ( pData->length != str.pData->length )
769  return false;
770  if ( pData == str.pData )
771  return true;
772  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
773  str.pData->buffer, str.pData->length ) == 0;
774  }
775 
791  sal_Int32 compareToIgnoreAsciiCase( const OUString & str ) const
792  {
793  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
794  str.pData->buffer, str.pData->length );
795  }
796 
797 
803  template< typename T >
805  {
806  assert(
808  return
809  (pData->length
812  pData->buffer, pData->length,
814  literal))
815  == 0);
816  }
817 
818 #if defined LIBO_INTERNAL_ONLY
819 
820  template<typename T>
822  equalIgnoreAsciiCase(T & literal) const {
823  return
825  pData->buffer, pData->length,
827  literal),
829  == 0;
830  }
831 #endif
832 
848  bool match( const OUString & str, sal_Int32 fromIndex = 0 ) const
849  {
850  return rtl_ustr_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
851  str.pData->buffer, str.pData->length, str.pData->length ) == 0;
852  }
853 
859  template< typename T >
860  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
861  {
862  assert(
864  return
866  pData->buffer+fromIndex, pData->length-fromIndex,
868  literal),
870  == 0;
871  }
872 
873 #if defined LIBO_INTERNAL_ONLY
874 
875  template<typename T>
877  match(T & literal, sal_Int32 fromIndex = 0) const {
878  assert(fromIndex >= 0);
879  return
881  pData->buffer + fromIndex, pData->length - fromIndex,
883  literal),
886  == 0;
887  }
888 #endif
889 
908  bool matchIgnoreAsciiCase( const OUString & str, sal_Int32 fromIndex = 0 ) const
909  {
910  return rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
911  str.pData->buffer, str.pData->length,
912  str.pData->length ) == 0;
913  }
914 
920  template< typename T >
921  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
922  {
923  assert(
925  return
927  pData->buffer+fromIndex, pData->length-fromIndex,
929  literal),
931  == 0;
932  }
933 
934 #if defined LIBO_INTERNAL_ONLY
935 
936  template<typename T>
938  matchIgnoreAsciiCase(T & literal, sal_Int32 fromIndex = 0) const {
939  assert(fromIndex >= 0);
940  return
942  pData->buffer + fromIndex, pData->length - fromIndex,
944  literal),
947  == 0;
948  }
949 #endif
950 
967  sal_Int32 compareToAscii( const sal_Char* asciiStr ) const
968  {
969  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length, asciiStr );
970  }
971 
995  "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
996  sal_Int32 compareToAscii( const sal_Char * asciiStr, sal_Int32 maxLength ) const
997  {
998  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer, pData->length,
999  asciiStr, maxLength );
1000  }
1001 
1021  sal_Int32 reverseCompareToAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
1022  {
1023  return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
1024  asciiStr, asciiStrLength );
1025  }
1026 
1042  bool equalsAscii( const sal_Char* asciiStr ) const
1043  {
1044  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length,
1045  asciiStr ) == 0;
1046  }
1047 
1065  bool equalsAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength ) const
1066  {
1067  if ( pData->length != asciiStrLength )
1068  return false;
1069 
1071  pData->buffer, asciiStr, asciiStrLength );
1072  }
1073 
1092  bool equalsIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const
1093  {
1094  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1095  }
1096 
1115  sal_Int32 compareToIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const
1116  {
1117  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr );
1118  }
1119 
1140  bool equalsIgnoreAsciiCaseAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
1141  {
1142  if ( pData->length != asciiStrLength )
1143  return false;
1144 
1145  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
1146  }
1147 
1169  bool matchAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1170  {
1171  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1172  asciiStr, asciiStrLength ) == 0;
1173  }
1174 
1175  // This overload is left undefined, to detect calls of matchAsciiL that
1176  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1177  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1178  // platforms):
1179 #if SAL_TYPES_SIZEOFLONG == 8
1180  void matchAsciiL(char const *, sal_Int32, rtl_TextEncoding) const;
1181 #endif
1182 
1207  bool matchIgnoreAsciiCaseAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1208  {
1209  return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1210  asciiStr, asciiStrLength ) == 0;
1211  }
1212 
1213  // This overload is left undefined, to detect calls of
1214  // matchIgnoreAsciiCaseAsciiL that erroneously use
1215  // RTL_CONSTASCII_USTRINGPARAM instead of RTL_CONSTASCII_STRINGPARAM (but
1216  // would lead to ambiguities on 32 bit platforms):
1217 #if SAL_TYPES_SIZEOFLONG == 8
1218  void matchIgnoreAsciiCaseAsciiL(char const *, sal_Int32, rtl_TextEncoding)
1219  const;
1220 #endif
1221 
1236  bool startsWith(OUString const & str, OUString * rest = NULL) const {
1237  bool b = match(str);
1238  if (b && rest != NULL) {
1239  *rest = copy(str.getLength());
1240  }
1241  return b;
1242  }
1243 
1249  template< typename T >
1251  T & literal, OUString * rest = NULL) const
1252  {
1253  assert(
1255  bool b
1257  <= sal_uInt32(pData->length))
1259  pData->buffer,
1261  literal),
1263  if (b && rest != NULL) {
1264  *rest = copy(
1266  }
1267  return b;
1268  }
1269 
1270 #if defined LIBO_INTERNAL_ONLY
1271 
1272  template<typename T>
1274  startsWith(T & literal, OUString * rest = nullptr) const {
1275  bool b
1277  <= sal_uInt32(pData->length))
1279  pData->buffer,
1282  literal),
1284  == 0);
1285  if (b && rest != nullptr) {
1286  *rest = copy(
1288  }
1289  return b;
1290  }
1291 #endif
1292 
1313  bool startsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL)
1314  const
1315  {
1316  bool b = matchIgnoreAsciiCase(str);
1317  if (b && rest != NULL) {
1318  *rest = copy(str.getLength());
1319  }
1320  return b;
1321  }
1322 
1328  template< typename T >
1330  startsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1331  {
1332  assert(
1334  bool b
1336  pData->buffer,
1339  literal),
1341  == 0);
1342  if (b && rest != NULL) {
1343  *rest = copy(
1345  }
1346  return b;
1347  }
1348 
1349 #if defined LIBO_INTERNAL_ONLY
1350 
1351  template<typename T>
1353  startsWithIgnoreAsciiCase(T & literal, OUString * rest = nullptr) const {
1354  bool b
1356  <= sal_uInt32(pData->length))
1358  pData->buffer,
1361  literal),
1363  == 0);
1364  if (b && rest != nullptr) {
1365  *rest = copy(
1367  }
1368  return b;
1369  }
1370 #endif
1371 
1386  bool endsWith(OUString const & str, OUString * rest = NULL) const {
1387  bool b = str.getLength() <= getLength()
1388  && match(str, getLength() - str.getLength());
1389  if (b && rest != NULL) {
1390  *rest = copy(0, getLength() - str.getLength());
1391  }
1392  return b;
1393  }
1394 
1400  template< typename T >
1402  endsWith(T & literal, OUString * rest = NULL) const
1403  {
1404  assert(
1406  bool b
1408  <= sal_uInt32(pData->length))
1410  (pData->buffer + pData->length
1413  literal),
1415  if (b && rest != NULL) {
1416  *rest = copy(
1417  0,
1418  (getLength()
1420  }
1421  return b;
1422  }
1423 
1424 #if defined LIBO_INTERNAL_ONLY
1425 
1426  template<typename T>
1428  endsWith(T & literal, OUString * rest = nullptr) const {
1429  bool b
1431  <= sal_uInt32(pData->length))
1433  (pData->buffer + pData->length
1437  literal),
1439  == 0);
1440  if (b && rest != nullptr) {
1441  *rest = copy(
1442  0,
1443  (getLength()
1445  }
1446  return b;
1447  }
1448 #endif
1449 
1461  inline bool endsWithAsciiL(char const * asciiStr, sal_Int32 asciiStrLength)
1462  const
1463  {
1464  return asciiStrLength <= pData->length
1466  pData->buffer + pData->length - asciiStrLength, asciiStr,
1467  asciiStrLength);
1468  }
1469 
1490  bool endsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL) const
1491  {
1492  bool b = str.getLength() <= getLength()
1493  && matchIgnoreAsciiCase(str, getLength() - str.getLength());
1494  if (b && rest != NULL) {
1495  *rest = copy(0, getLength() - str.getLength());
1496  }
1497  return b;
1498  }
1499 
1505  template< typename T >
1507  endsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1508  {
1509  assert(
1511  bool b
1513  <= sal_uInt32(pData->length))
1515  (pData->buffer + pData->length
1519  literal),
1521  == 0);
1522  if (b && rest != NULL) {
1523  *rest = copy(
1524  0,
1525  (getLength()
1527  }
1528  return b;
1529  }
1530 
1531 #if defined LIBO_INTERNAL_ONLY
1532 
1533  template<typename T>
1535  endsWithIgnoreAsciiCase(T & literal, OUString * rest = nullptr) const {
1536  bool b
1538  <= sal_uInt32(pData->length))
1540  (pData->buffer + pData->length
1544  literal),
1546  == 0);
1547  if (b && rest != nullptr) {
1548  *rest = copy(
1549  0,
1550  (getLength()
1552  }
1553  return b;
1554  }
1555 #endif
1556 
1568  char const * asciiStr, sal_Int32 asciiStrLength) const
1569  {
1570  return asciiStrLength <= pData->length
1572  pData->buffer + pData->length - asciiStrLength,
1573  asciiStrLength, asciiStr, asciiStrLength)
1574  == 0);
1575  }
1576 
1577  friend bool operator == ( const OUString& rStr1, const OUString& rStr2 )
1578  { return rStr1.equals(rStr2); }
1579  friend bool operator == ( const OUString& rStr1, const sal_Unicode * pStr2 )
1580  { return rStr1.compareTo( pStr2 ) == 0; }
1581  friend bool operator == ( const sal_Unicode * pStr1, const OUString& rStr2 )
1582  { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
1583 
1584  friend bool operator != ( const OUString& rStr1, const OUString& rStr2 )
1585  { return !(operator == ( rStr1, rStr2 )); }
1586  friend bool operator != ( const OUString& rStr1, const sal_Unicode * pStr2 )
1587  { return !(operator == ( rStr1, pStr2 )); }
1588  friend bool operator != ( const sal_Unicode * pStr1, const OUString& rStr2 )
1589  { return !(operator == ( pStr1, rStr2 )); }
1590 
1591  friend bool operator < ( const OUString& rStr1, const OUString& rStr2 )
1592  { return rStr1.compareTo( rStr2 ) < 0; }
1593  friend bool operator > ( const OUString& rStr1, const OUString& rStr2 )
1594  { return rStr1.compareTo( rStr2 ) > 0; }
1595  friend bool operator <= ( const OUString& rStr1, const OUString& rStr2 )
1596  { return rStr1.compareTo( rStr2 ) <= 0; }
1597  friend bool operator >= ( const OUString& rStr1, const OUString& rStr2 )
1598  { return rStr1.compareTo( rStr2 ) >= 0; }
1599 
1607  template< typename T >
1608  friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==( const OUString& rString, T& literal )
1609  {
1610  assert(
1612  return rString.equalsAsciiL(
1615  }
1623  template< typename T >
1624  friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==( T& literal, const OUString& rString )
1625  {
1626  assert(
1628  return rString.equalsAsciiL(
1631  }
1639  template< typename T >
1640  friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=( const OUString& rString, T& literal )
1641  {
1642  assert(
1644  return !rString.equalsAsciiL(
1647  }
1655  template< typename T >
1656  friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=( T& literal, const OUString& rString )
1657  {
1658  assert(
1660  return !rString.equalsAsciiL(
1663  }
1664 
1665 #if defined LIBO_INTERNAL_ONLY
1666 
1667  template<typename T> friend inline
1669  operator ==(OUString & string, T & literal) {
1670  return
1672  string.pData->buffer, string.pData->length,
1674  literal),
1676  == 0;
1677  }
1679  template<typename T> friend inline
1680  typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1681  operator ==(T & literal, OUString & string) {
1682  return
1684  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1685  literal),
1686  libreoffice_internal::ConstCharArrayDetector<T>::length,
1687  string.pData->buffer, string.pData->length)
1688  == 0;
1689  }
1691  template<typename T> friend inline
1692  typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1693  operator !=(OUString & string, T & literal) {
1694  return
1696  string.pData->buffer, string.pData->length,
1697  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1698  literal),
1699  libreoffice_internal::ConstCharArrayDetector<T>::length)
1700  != 0;
1701  }
1703  template<typename T> friend inline
1704  typename libreoffice_internal::ConstCharArrayDetector<T, bool>::TypeUtf16
1705  operator !=(T & literal, OUString & string) {
1706  return
1708  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(
1709  literal),
1710  libreoffice_internal::ConstCharArrayDetector<T>::length,
1711  string.pData->buffer, string.pData->length)
1712  != 0;
1713  }
1714 #endif
1715 
1716 #if defined LIBO_INTERNAL_ONLY
1717 
1719  /* Comparison between OUString and OUStringLiteral.
1720 
1721  @since LibreOffice 5.0
1722  */
1723 
1724  friend bool operator ==(OUString const & lhs, OUStringLiteral const & rhs) {
1725  return lhs.equalsAsciiL(rhs.data, rhs.size);
1726  }
1727 
1728  friend bool operator !=(OUString const & lhs, OUStringLiteral const & rhs) {
1729  return !lhs.equalsAsciiL(rhs.data, rhs.size);
1730  }
1731 
1732  friend bool operator <(OUString const & lhs, OUStringLiteral const & rhs) {
1733  return
1735  lhs.pData->buffer, lhs.pData->length, rhs.data))
1736  < 0;
1737  }
1738 
1739  friend bool operator <=(OUString const & lhs, OUStringLiteral const & rhs) {
1740  return
1742  lhs.pData->buffer, lhs.pData->length, rhs.data))
1743  <= 0;
1744  }
1745 
1746  friend bool operator >(OUString const & lhs, OUStringLiteral const & rhs) {
1747  return
1749  lhs.pData->buffer, lhs.pData->length, rhs.data))
1750  > 0;
1751  }
1752 
1753  friend bool operator >=(OUString const & lhs, OUStringLiteral const & rhs) {
1754  return
1756  lhs.pData->buffer, lhs.pData->length, rhs.data))
1757  >= 0;
1758  }
1759 
1760  friend bool operator ==(OUStringLiteral const & lhs, OUString const & rhs) {
1761  return rhs.equalsAsciiL(lhs.data, lhs.size);
1762  }
1763 
1764  friend bool operator !=(OUStringLiteral const & lhs, OUString const & rhs) {
1765  return !rhs.equalsAsciiL(lhs.data, lhs.size);
1766  }
1767 
1768  friend bool operator <(OUStringLiteral const & lhs, OUString const & rhs) {
1769  return
1771  rhs.pData->buffer, rhs.pData->length, lhs.data))
1772  >= 0;
1773  }
1774 
1775  friend bool operator <=(OUStringLiteral const & lhs, OUString const & rhs) {
1776  return
1778  rhs.pData->buffer, rhs.pData->length, lhs.data))
1779  > 0;
1780  }
1781 
1782  friend bool operator >(OUStringLiteral const & lhs, OUString const & rhs) {
1783  return
1785  rhs.pData->buffer, rhs.pData->length, lhs.data))
1786  <= 0;
1787  }
1788 
1789  friend bool operator >=(OUStringLiteral const & lhs, OUString const & rhs) {
1790  return
1792  rhs.pData->buffer, rhs.pData->length, lhs.data))
1793  < 0;
1794  }
1795 
1797 #endif
1798 
1806  sal_Int32 hashCode() const
1807  {
1808  return rtl_ustr_hashCode_WithLength( pData->buffer, pData->length );
1809  }
1810 
1824  sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
1825  {
1826  sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1827  return (ret < 0 ? ret : ret+fromIndex);
1828  }
1829 
1839  sal_Int32 lastIndexOf( sal_Unicode ch ) const
1840  {
1841  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1842  }
1843 
1856  sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
1857  {
1858  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1859  }
1860 
1876  sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
1877  {
1878  sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1879  str.pData->buffer, str.pData->length );
1880  return (ret < 0 ? ret : ret+fromIndex);
1881  }
1882 
1888  template< typename T >
1889  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1890  {
1891  assert(
1893  sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
1894  pData->buffer + fromIndex, pData->length - fromIndex,
1897  return n < 0 ? n : n + fromIndex;
1898  }
1899 
1900 #if defined LIBO_INTERNAL_ONLY
1901 
1902  template<typename T>
1903  typename
1905  indexOf(T & literal, sal_Int32 fromIndex = 0) const {
1906  assert(fromIndex >= 0);
1908  pData->buffer + fromIndex, pData->length - fromIndex,
1911  return n < 0 ? n : n + fromIndex;
1912  }
1913 #endif
1914 
1938  sal_Int32 indexOfAsciiL(
1939  char const * str, sal_Int32 len, sal_Int32 fromIndex = 0) const
1940  {
1941  sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
1942  pData->buffer + fromIndex, pData->length - fromIndex, str, len);
1943  return ret < 0 ? ret : ret + fromIndex;
1944  }
1945 
1946  // This overload is left undefined, to detect calls of indexOfAsciiL that
1947  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1948  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1949  // platforms):
1950 #if SAL_TYPES_SIZEOFLONG == 8
1951  void indexOfAsciiL(char const *, sal_Int32 len, rtl_TextEncoding) const;
1952 #endif
1953 
1969  sal_Int32 lastIndexOf( const OUString & str ) const
1970  {
1971  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1972  str.pData->buffer, str.pData->length );
1973  }
1974 
1992  sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
1993  {
1994  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1995  str.pData->buffer, str.pData->length );
1996  }
1997 
2003  template< typename T >
2005  {
2006  assert(
2009  pData->buffer, pData->length,
2012  }
2013 
2014 #if defined LIBO_INTERNAL_ONLY
2015 
2016  template<typename T>
2017  typename
2019  lastIndexOf(T & literal) const {
2021  pData->buffer, pData->length,
2024  }
2025 #endif
2026 
2046  sal_Int32 lastIndexOfAsciiL(char const * str, sal_Int32 len) const
2047  {
2049  pData->buffer, pData->length, str, len);
2050  }
2051 
2062  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex ) const
2063  {
2064  rtl_uString *pNew = NULL;
2065  rtl_uString_newFromSubString( &pNew, pData, beginIndex, getLength() - beginIndex );
2066  return OUString( pNew, SAL_NO_ACQUIRE );
2067  }
2068 
2081  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const
2082  {
2083  rtl_uString *pNew = NULL;
2084  rtl_uString_newFromSubString( &pNew, pData, beginIndex, count );
2085  return OUString( pNew, SAL_NO_ACQUIRE );
2086  }
2087 
2097  {
2098  rtl_uString* pNew = NULL;
2099  rtl_uString_newConcat( &pNew, pData, str.pData );
2100  return OUString( pNew, SAL_NO_ACQUIRE );
2101  }
2102 
2103 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2104  friend OUString operator+( const OUString& rStr1, const OUString& rStr2 )
2105  {
2106  return rStr1.concat( rStr2 );
2107  }
2108 #endif
2109 
2123  SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const
2124  {
2125  rtl_uString* pNew = NULL;
2126  rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
2127  return OUString( pNew, SAL_NO_ACQUIRE );
2128  }
2129 
2144  {
2145  rtl_uString* pNew = NULL;
2146  rtl_uString_newReplace( &pNew, pData, oldChar, newChar );
2147  return OUString( pNew, SAL_NO_ACQUIRE );
2148  }
2149 
2169  OUString const & from, OUString const & to, sal_Int32 * index = NULL) const
2170  {
2171  rtl_uString * s = NULL;
2172  sal_Int32 i = 0;
2174  &s, pData, from.pData, to.pData, index == NULL ? &i : index);
2175  return OUString(s, SAL_NO_ACQUIRE);
2176  }
2177 
2196  template< typename T >
2198  sal_Int32 * index = NULL) const
2199  {
2201  rtl_uString * s = NULL;
2202  sal_Int32 i = 0;
2204  &s, pData,
2207  index == NULL ? &i : index);
2208  return OUString(s, SAL_NO_ACQUIRE);
2209  }
2210 
2229  template< typename T >
2231  sal_Int32 * index = NULL) const
2232  {
2234  rtl_uString * s = NULL;
2235  sal_Int32 i = 0;
2237  &s, pData, from.pData,
2240  index == NULL ? &i : index);
2241  return OUString(s, SAL_NO_ACQUIRE);
2242  }
2243 
2262  template< typename T1, typename T2 >
2264  replaceFirst( T1& from, T2& to, sal_Int32 * index = NULL) const
2265  {
2268  rtl_uString * s = NULL;
2269  sal_Int32 i = 0;
2271  &s, pData,
2276  index == NULL ? &i : index);
2277  return OUString(s, SAL_NO_ACQUIRE);
2278  }
2279 
2280 #if defined LIBO_INTERNAL_ONLY
2281 
2282  template<typename T> SAL_WARN_UNUSED_RESULT
2283  typename
2285  replaceFirst(T & from, OUString const & to, sal_Int32 * index = nullptr)
2286  const
2287  {
2288  rtl_uString * s = nullptr;
2289  sal_Int32 i = 0;
2291  &s, pData,
2294  to.pData->buffer, to.pData->length, index == nullptr ? &i : index);
2295  if (s == nullptr) {
2296  throw std::bad_alloc();
2297  // should be std::length_error if resulting would be too large
2298  }
2299  return OUString(s, SAL_NO_ACQUIRE);
2300  }
2302  template<typename T> SAL_WARN_UNUSED_RESULT
2303  typename
2304  libreoffice_internal::ConstCharArrayDetector<T, OUString>::TypeUtf16
2305  replaceFirst(OUString const & from, T & to, sal_Int32 * index = nullptr)
2306  const
2307  {
2308  rtl_uString * s = nullptr;
2309  sal_Int32 i = 0;
2311  &s, pData, from.pData->buffer, from.pData->length,
2312  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(to),
2313  libreoffice_internal::ConstCharArrayDetector<T>::length,
2314  index == nullptr ? &i : index);
2315  if (s == nullptr) {
2316  throw std::bad_alloc();
2317  // should be std::length_error if resulting would be too large
2318  }
2319  return OUString(s, SAL_NO_ACQUIRE);
2320  }
2322  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2323  typename
2324  libreoffice_internal::ConstCharArrayDetector<
2325  T1,
2326  typename libreoffice_internal::ConstCharArrayDetector<
2327  T2, OUString>::TypeUtf16
2328  >::TypeUtf16
2329  replaceFirst(T1 & from, T2 & to, sal_Int32 * index = nullptr) const {
2330  rtl_uString * s = nullptr;
2331  sal_Int32 i = 0;
2333  &s, pData,
2334  libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2335  libreoffice_internal::ConstCharArrayDetector<T1>::length,
2336  libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2337  libreoffice_internal::ConstCharArrayDetector<T2>::length,
2338  index == nullptr ? &i : index);
2339  if (s == nullptr) {
2340  throw std::bad_alloc();
2341  // should be std::length_error if resulting would be too large
2342  }
2343  return OUString(s, SAL_NO_ACQUIRE);
2344  }
2346  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2347  typename
2348  libreoffice_internal::ConstCharArrayDetector<
2349  T1,
2350  typename libreoffice_internal::ConstCharArrayDetector<
2351  T2, OUString>::Type
2352  >::TypeUtf16
2353  replaceFirst(T1 & from, T2 & to, sal_Int32 * index = nullptr) const {
2354  rtl_uString * s = nullptr;
2355  sal_Int32 i = 0;
2357  &s, pData,
2358  libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2359  libreoffice_internal::ConstCharArrayDetector<T1>::length,
2360  libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2361  libreoffice_internal::ConstCharArrayDetector<T2>::length,
2362  index == nullptr ? &i : index);
2363  if (s == nullptr) {
2364  throw std::bad_alloc();
2365  // should be std::length_error if resulting would be too large
2366  }
2367  return OUString(s, SAL_NO_ACQUIRE);
2368  }
2370  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2371  typename
2372  libreoffice_internal::ConstCharArrayDetector<
2373  T1,
2374  typename libreoffice_internal::ConstCharArrayDetector<
2375  T2, OUString>::TypeUtf16
2376  >::Type
2377  replaceFirst(T1 & from, T2 & to, sal_Int32 * index = nullptr) const {
2378  rtl_uString * s = nullptr;
2379  sal_Int32 i = 0;
2381  &s, pData,
2382  libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2383  libreoffice_internal::ConstCharArrayDetector<T1>::length,
2384  libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2385  libreoffice_internal::ConstCharArrayDetector<T2>::length,
2386  index == nullptr ? &i : index);
2387  if (s == nullptr) {
2388  throw std::bad_alloc();
2389  // should be std::length_error if resulting would be too large
2390  }
2391  return OUString(s, SAL_NO_ACQUIRE);
2392  }
2393 #endif
2394 
2411  OUString const & from, OUString const & to, sal_Int32 fromIndex = 0) const
2412  {
2413  rtl_uString * s = NULL;
2414  rtl_uString_newReplaceAllFromIndex(&s, pData, from.pData, to.pData, fromIndex);
2415  return OUString(s, SAL_NO_ACQUIRE);
2416  }
2417 
2431  template< typename T >
2433  {
2435  rtl_uString * s = NULL;
2437  &s, pData,
2440  return OUString(s, SAL_NO_ACQUIRE);
2441  }
2442 
2456  template< typename T >
2458  {
2460  rtl_uString * s = NULL;
2462  &s, pData, from.pData,
2465  return OUString(s, SAL_NO_ACQUIRE);
2466  }
2467 
2481  template< typename T1, typename T2 >
2483  replaceAll( T1& from, T2& to ) const
2484  {
2487  rtl_uString * s = NULL;
2489  &s, pData,
2494  return OUString(s, SAL_NO_ACQUIRE);
2495  }
2496 
2497 #if defined LIBO_INTERNAL_ONLY
2498 
2499  template<typename T> SAL_WARN_UNUSED_RESULT
2500  typename
2502  replaceAll(T & from, OUString const & to) const {
2503  rtl_uString * s = nullptr;
2505  &s, pData,
2508  to.pData->buffer, to.pData->length);
2509  if (s == nullptr) {
2510  throw std::bad_alloc();
2511  // should be std::length_error if resulting would be too large
2512  }
2513  return OUString(s, SAL_NO_ACQUIRE);
2514  }
2516  template<typename T> SAL_WARN_UNUSED_RESULT
2517  typename
2518  libreoffice_internal::ConstCharArrayDetector<T, OUString>::TypeUtf16
2519  replaceAll(OUString const & from, T & to) const {
2520  rtl_uString * s = nullptr;
2522  &s, pData, from.pData->buffer, from.pData->length,
2523  libreoffice_internal::ConstCharArrayDetector<T>::toPointer(to),
2524  libreoffice_internal::ConstCharArrayDetector<T>::length);
2525  if (s == nullptr) {
2526  throw std::bad_alloc();
2527  // should be std::length_error if resulting would be too large
2528  }
2529  return OUString(s, SAL_NO_ACQUIRE);
2530  }
2532  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2533  typename
2534  libreoffice_internal::ConstCharArrayDetector<
2535  T1,
2536  typename libreoffice_internal::ConstCharArrayDetector<
2537  T2, OUString>::TypeUtf16
2538  >::TypeUtf16
2539  replaceAll(T1 & from, T2 & to) const {
2540  rtl_uString * s = nullptr;
2542  &s, pData,
2543  libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2544  libreoffice_internal::ConstCharArrayDetector<T1>::length,
2545  libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2546  libreoffice_internal::ConstCharArrayDetector<T2>::length);
2547  if (s == nullptr) {
2548  throw std::bad_alloc();
2549  // should be std::length_error if resulting would be too large
2550  }
2551  return OUString(s, SAL_NO_ACQUIRE);
2552  }
2554  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2555  typename
2556  libreoffice_internal::ConstCharArrayDetector<
2557  T1,
2558  typename libreoffice_internal::ConstCharArrayDetector<
2559  T2, OUString>::Type
2560  >::TypeUtf16
2561  replaceAll(T1 & from, T2 & to) const {
2562  rtl_uString * s = nullptr;
2564  &s, pData,
2565  libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2566  libreoffice_internal::ConstCharArrayDetector<T1>::length,
2567  libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2568  libreoffice_internal::ConstCharArrayDetector<T2>::length);
2569  if (s == nullptr) {
2570  throw std::bad_alloc();
2571  // should be std::length_error if resulting would be too large
2572  }
2573  return OUString(s, SAL_NO_ACQUIRE);
2574  }
2576  template<typename T1, typename T2> SAL_WARN_UNUSED_RESULT
2577  typename
2578  libreoffice_internal::ConstCharArrayDetector<
2579  T1,
2580  typename libreoffice_internal::ConstCharArrayDetector<
2581  T2, OUString>::TypeUtf16
2582  >::Type
2583  replaceAll(T1 & from, T2 & to) const {
2584  rtl_uString * s = nullptr;
2586  &s, pData,
2587  libreoffice_internal::ConstCharArrayDetector<T1>::toPointer(from),
2588  libreoffice_internal::ConstCharArrayDetector<T1>::length,
2589  libreoffice_internal::ConstCharArrayDetector<T2>::toPointer(to),
2590  libreoffice_internal::ConstCharArrayDetector<T2>::length);
2591  if (s == nullptr) {
2592  throw std::bad_alloc();
2593  // should be std::length_error if resulting would be too large
2594  }
2595  return OUString(s, SAL_NO_ACQUIRE);
2596  }
2597 #endif
2598 
2610  {
2611  rtl_uString* pNew = NULL;
2612  rtl_uString_newToAsciiLowerCase( &pNew, pData );
2613  return OUString( pNew, SAL_NO_ACQUIRE );
2614  }
2615 
2627  {
2628  rtl_uString* pNew = NULL;
2629  rtl_uString_newToAsciiUpperCase( &pNew, pData );
2630  return OUString( pNew, SAL_NO_ACQUIRE );
2631  }
2632 
2645  {
2646  rtl_uString* pNew = NULL;
2647  rtl_uString_newTrim( &pNew, pData );
2648  return OUString( pNew, SAL_NO_ACQUIRE );
2649  }
2650 
2675  OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const
2676  {
2677  rtl_uString * pNew = NULL;
2678  index = rtl_uString_getToken( &pNew, pData, token, cTok, index );
2679  return OUString( pNew, SAL_NO_ACQUIRE );
2680  }
2681 
2695  OUString getToken(sal_Int32 count, sal_Unicode separator) const {
2696  sal_Int32 n = 0;
2697  return getToken(count, separator, n);
2698  }
2699 
2708  bool toBoolean() const
2709  {
2710  return rtl_ustr_toBoolean( pData->buffer );
2711  }
2712 
2720  {
2721  return pData->buffer[0];
2722  }
2723 
2734  sal_Int32 toInt32( sal_Int16 radix = 10 ) const
2735  {
2736  return rtl_ustr_toInt32( pData->buffer, radix );
2737  }
2738 
2751  sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
2752  {
2753  return rtl_ustr_toUInt32( pData->buffer, radix );
2754  }
2755 
2766  sal_Int64 toInt64( sal_Int16 radix = 10 ) const
2767  {
2768  return rtl_ustr_toInt64( pData->buffer, radix );
2769  }
2770 
2783  sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
2784  {
2785  return rtl_ustr_toUInt64( pData->buffer, radix );
2786  }
2787 
2796  float toFloat() const
2797  {
2798  return rtl_ustr_toFloat( pData->buffer );
2799  }
2800 
2809  double toDouble() const
2810  {
2811  return rtl_ustr_toDouble( pData->buffer );
2812  }
2813 
2814 
2831  {
2832  rtl_uString * pNew = NULL;
2833  rtl_uString_intern( &pNew, pData );
2834  if (pNew == NULL) {
2835  throw std::bad_alloc();
2836  }
2837  return OUString( pNew, SAL_NO_ACQUIRE );
2838  }
2839 
2865  static OUString intern( const sal_Char * value, sal_Int32 length,
2866  rtl_TextEncoding encoding,
2867  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS,
2868  sal_uInt32 *pInfo = NULL )
2869  {
2870  rtl_uString * pNew = NULL;
2871  rtl_uString_internConvert( &pNew, value, length, encoding,
2872  convertFlags, pInfo );
2873  if (pNew == NULL) {
2874  throw std::bad_alloc();
2875  }
2876  return OUString( pNew, SAL_NO_ACQUIRE );
2877  }
2878 
2903  inline bool convertToString(OString * pTarget, rtl_TextEncoding nEncoding,
2904  sal_uInt32 nFlags) const
2905  {
2906  return rtl_convertUStringToString(&pTarget->pData, pData->buffer,
2907  pData->length, nEncoding, nFlags);
2908  }
2909 
2961  inline sal_uInt32 iterateCodePoints(
2962  sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1) const
2963  {
2965  pData, indexUtf16, incrementCodePoints);
2966  }
2967 
2977  static inline OUString fromUtf8(const OString& rSource)
2978  {
2979  OUString aTarget;
2980  bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
2981  rSource.getStr(),
2982  rSource.getLength(),
2985  (void) bSuccess;
2986  assert(bSuccess);
2987  return aTarget;
2988  }
2989 
3000  inline OString toUtf8() const
3001  {
3002  OString aTarget;
3003  bool bSuccess = rtl_convertUStringToString(&aTarget.pData,
3004  getStr(),
3005  getLength(),
3008  (void) bSuccess;
3009  assert(bSuccess);
3010  return aTarget;
3011  }
3012 
3023  static OUString number( int i, sal_Int16 radix = 10 )
3024  {
3026  rtl_uString* pNewData = NULL;
3027  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt32( aBuf, i, radix ) );
3028  return OUString( pNewData, SAL_NO_ACQUIRE );
3029  }
3032  static OUString number( unsigned int i, sal_Int16 radix = 10 )
3033  {
3034  return number( static_cast< unsigned long long >( i ), radix );
3035  }
3038  static OUString number( long i, sal_Int16 radix = 10)
3039  {
3040  return number( static_cast< long long >( i ), radix );
3041  }
3044  static OUString number( unsigned long i, sal_Int16 radix = 10 )
3045  {
3046  return number( static_cast< unsigned long long >( i ), radix );
3047  }
3050  static OUString number( long long ll, sal_Int16 radix = 10 )
3051  {
3053  rtl_uString* pNewData = NULL;
3054  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt64( aBuf, ll, radix ) );
3055  return OUString( pNewData, SAL_NO_ACQUIRE );
3056  }
3059  static OUString number( unsigned long long ll, sal_Int16 radix = 10 )
3060  {
3062  rtl_uString* pNewData = NULL;
3063  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfUInt64( aBuf, ll, radix ) );
3064  return OUString( pNewData, SAL_NO_ACQUIRE );
3065  }
3066 
3076  static OUString number( float f )
3077  {
3079  rtl_uString* pNewData = NULL;
3080  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfFloat( aBuf, f ) );
3081  return OUString( pNewData, SAL_NO_ACQUIRE );
3082  }
3083 
3093  static OUString number( double d )
3094  {
3096  rtl_uString* pNewData = NULL;
3097  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfDouble( aBuf, d ) );
3098  return OUString( pNewData, SAL_NO_ACQUIRE );
3099  }
3100 
3112  SAL_DEPRECATED("use boolean()") static OUString valueOf( sal_Bool b )
3113  {
3114  return boolean(b);
3115  }
3116 
3128  static OUString boolean( bool b )
3129  {
3131  rtl_uString* pNewData = NULL;
3132  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfBoolean( aBuf, b ) );
3133  return OUString( pNewData, SAL_NO_ACQUIRE );
3134  }
3135 
3143  SAL_DEPRECATED("convert to OUString or use directly") static OUString valueOf( sal_Unicode c )
3144  {
3145  return OUString( &c, 1 );
3146  }
3147 
3158  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
3159  {
3160  return number( i, radix );
3161  }
3162 
3173  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
3174  {
3175  return number( ll, radix );
3176  }
3177 
3187  SAL_DEPRECATED("use number()") static OUString valueOf( float f )
3188  {
3189  return number(f);
3190  }
3191 
3201  SAL_DEPRECATED("use number()") static OUString valueOf( double d )
3202  {
3203  return number(d);
3204  }
3205 
3221  static OUString createFromAscii( const sal_Char * value )
3222  {
3223  rtl_uString* pNew = NULL;
3224  rtl_uString_newFromAscii( &pNew, value );
3225  return OUString( pNew, SAL_NO_ACQUIRE );
3226  }
3227 };
3228 
3229 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
3230 
3235 template<>
3236 struct ToStringHelper< OUString >
3237  {
3238  static int length( const OUString& s ) { return s.getLength(); }
3239  static sal_Unicode* addData( sal_Unicode* buffer, const OUString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
3240  static const bool allowOStringConcat = false;
3241  static const bool allowOUStringConcat = true;
3242  };
3243 
3247 template<>
3248 struct ToStringHelper< OUStringLiteral >
3249  {
3250  static int length( const OUStringLiteral& str ) { return str.size; }
3251  static sal_Unicode* addData( sal_Unicode* buffer, const OUStringLiteral& str ) { return addDataLiteral( buffer, str.data, str.size ); }
3252  static const bool allowOStringConcat = false;
3253  static const bool allowOUStringConcat = true;
3254  };
3255 
3259 template< typename charT, typename traits, typename T1, typename T2 >
3260 inline std::basic_ostream<charT, traits> & operator <<(
3261  std::basic_ostream<charT, traits> & stream, const OUStringConcat< T1, T2 >& concat)
3262 {
3263  return stream << OUString( concat );
3264 }
3265 
3267 #endif
3268 
3275 {
3285  size_t operator()(const OUString& rString) const
3286  { return (size_t)rString.hashCode(); }
3287 };
3288 
3289 /* ======================================================================= */
3290 
3308 inline OUString OStringToOUString( const OString & rStr,
3309  rtl_TextEncoding encoding,
3310  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
3311 {
3312  return OUString( rStr.getStr(), rStr.getLength(), encoding, convertFlags );
3313 }
3314 
3332 inline OString OUStringToOString( const OUString & rUnicode,
3333  rtl_TextEncoding encoding,
3334  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
3335 {
3336  return OString( rUnicode.getStr(), rUnicode.getLength(), encoding, convertFlags );
3337 }
3338 
3339 /* ======================================================================= */
3340 
3349 template< typename charT, typename traits >
3350 inline std::basic_ostream<charT, traits> & operator <<(
3351  std::basic_ostream<charT, traits> & stream, OUString const & rString)
3352 {
3353  return stream <<
3355  // best effort; potentially loses data due to conversion failures
3356  // (stray surrogate halves) and embedded null characters
3357 }
3358 
3359 } // namespace
3360 
3361 #ifdef RTL_STRING_UNITTEST
3362 namespace rtl
3363 {
3364 typedef rtlunittest::OUString OUString;
3365 }
3366 #endif
3367 
3368 // In internal code, allow to use classes like OUString without having to
3369 // explicitly refer to the rtl namespace, which is kind of superfluous given
3370 // that OUString itself is namespaced by its OU prefix:
3371 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
3372 using ::rtl::OUString;
3373 using ::rtl::OUStringHash;
3376 using ::rtl::OUStringLiteral;
3377 using ::rtl::OUStringLiteral1;
3378 #endif
3379 
3380 #endif /* _RTL_USTRING_HXX */
3381 
3382 /* 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:3128
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:1938
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:2865
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:1894
OUString()
New string containing no characters.
Definition: ustring.hxx:116
SAL_DLLPUBLIC sal_Int32 rtl_ustr_hashCode_WithLength(const sal_Unicode *str, sal_Int32 len) SAL_THROW_EXTERN_C()
Return a hash code for a string.
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:2809
#define OSTRING_TO_OUSTRING_CVTFLAGS
Definition: ustring.h:2117
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: ustring.hxx:2734
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:708
const sal_Unicode * getStr() const
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:628
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: ustring.hxx:593
bool equalsIgnoreAsciiCaseAscii(const sal_Char *asciiStr) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1092
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:606
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:1207
OUString & operator=(const OUString &str)
Assign a new string.
Definition: ustring.hxx:421
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:1386
OUString intern() const
Return a canonical representation for a string.
Definition: ustring.hxx:2830
static OUString const & unacquired(rtl_uString *const *ppHandle)
Provides an OUString const &amp; passing a storage pointer of an rtl_uString * handle.
Definition: ustring.hxx:413
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:2783
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1608
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:130
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:3050
#define RTL_TEXTENCODING_UTF8
Definition: textenc.h:121
SAL_DLLPUBLIC sal_Int32 rtl_ustr_compare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings.
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstUtf16LAsciiL(rtl_uString **newStr, rtl_uString *str, sal_Unicode const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
OUString OStringToOUString(const OString &rStr, rtl_TextEncoding encoding, sal_uInt32 convertFlags=OSTRING_TO_OUSTRING_CVTFLAGS)
Convert an OString to an OUString, using a specific text encoding.
Definition: ustring.hxx:3308
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:177
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:3032
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:624
OUString(sal_uInt32 const *codePoints, sal_Int32 codePointCount)
Create a new string from an array of Unicode code points.
Definition: ustring.hxx:364
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:3332
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:3038
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:3285
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:2708
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:2695
SAL_WARN_UNUSED_RESULT OUString concat(const OUString &str) const
Concatenates the specified string to the end of this string.
Definition: ustring.hxx:2096
bool equals(const OUString &str) const
Perform a comparison of two strings.
Definition: ustring.hxx:742
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:1169
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:2046
bool convertToString(OString *pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) const
Converts to an OString, signalling failure.
Definition: ustring.hxx:2903
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:2104
sal_Int32 compareTo(const OUString &str, sal_Int32 maxLength) const
Compares two strings with a maximum count of characters.
Definition: ustring.hxx:678
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:1969
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:3059
unsigned char sal_Bool
Definition: types.h:48
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfFloat(sal_Unicode *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:96
const sal_Char * getStr() const
Returns a pointer to the characters of this string.
Definition: string.hxx:430
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:1856
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:804
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:1889
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:1490
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:1507
static OUString fromUtf8(const OString &rSource)
Convert an OString to an OUString, assuming that the OString is UTF-8-encoded.
Definition: ustring.hxx:2977
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:2961
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:106
SAL_WARN_UNUSED_RESULT OUString copy(sal_Int32 beginIndex, sal_Int32 count) const
Returns a new string that is a substring of this string.
Definition: ustring.hxx:2081
bool equalsAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform a comparison of two strings.
Definition: ustring.hxx:1065
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:606
sal_Int32 reverseCompareTo(const OUString &str) const
Compares two strings in reverse order.
Definition: ustring.hxx:696
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:384
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:2123
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:325
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:2168
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:848
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: ustring.hxx:2751
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:2432
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:616
OString toUtf8() const
Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully.
Definition: ustring.hxx:3000
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1656
OUString(rtl_uString *str)
New string from OUString data.
Definition: ustring.hxx:155
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:2062
#define RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR
Definition: textcvt.h:134
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:1250
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:908
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:155
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OUString &rString)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1624
SAL_DLLPUBLIC void rtl_uString_newFromStr(rtl_uString **newStr, const sal_Unicode *value) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
OUString getToken(sal_Int32 token, sal_Unicode cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: ustring.hxx:2675
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:2609
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:39
sal_Int32 compareToAscii(const sal_Char *asciiStr) const
Compares two strings.
Definition: ustring.hxx:967
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:1313
sal_Unicode toChar() const
Returns the first character from this string.
Definition: ustring.hxx:2719
bool equalsIgnoreAsciiCaseAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:1140
static OUString number(float f)
Returns the string representation of the float argument.
Definition: ustring.hxx:3076
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:1992
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:1824
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:2230
float toFloat() const
Returns the float value from this string.
Definition: ustring.hxx:2796
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:1839
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: ustring.hxx:2766
sal_Int32 compareToIgnoreAsciiCaseAscii(const sal_Char *asciiStr) const
Compares two ASCII strings ignoring case.
Definition: ustring.hxx:1115
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:2483
A helper to use OUStrings with hash maps.
Definition: ustring.hxx:3274
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:106
definition of a no acquire enum for ctors
Definition: types.h:388
#define SAL_CONSTEXPR
C++11 &quot;constexpr&quot; feature.
Definition: types.h:445
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OUString &rString, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1640
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:921
#define RTL_USTR_MAX_VALUEOFDOUBLE
Definition: ustring.h:1041
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED(&quot;Don&#39;t use, it&#39;s evil.&quot;) void doit(int nPara);.
Definition: types.h:509
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:657
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:235
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:404
bool endsWithAsciiL(char const *asciiStr, sal_Int32 asciiStrLength) const
Check whether this string ends with a given ASCII string.
Definition: ustring.hxx:1461
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:337
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:860
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:2626
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: ustring.hxx:1806
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:2410
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:116
SAL_WARN_UNUSED_RESULT OUString trim() const
Returns a new string resulting from removing white space from both ends of the string.
Definition: ustring.hxx:2644
OUString(const sal_Unicode *value)
New string from a Unicode character buffer array.
Definition: ustring.hxx:199
sal_Int32 compareToIgnoreAsciiCase(const OUString &str) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:791
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:2197
static OUString createFromAscii(const sal_Char *value)
Returns a OUString copied without conversion from an ASCII character string.
Definition: ustring.hxx:3221
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:127
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:2143
Definition: stringutils.hxx:115
SAL_DLLPUBLIC void rtl_uString_assign(rtl_uString **str, rtl_uString *rightValue) SAL_THROW_EXTERN_C()
Assign a new value to a string.
SAL_DLLPUBLIC void rtl_uString_newConcat(rtl_uString **newStr, rtl_uString *left, rtl_uString *right) SAL_THROW_EXTERN_C()
Create a new string that is the concatenation of two other strings.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfStr_WithLength(const sal_Unicode *str, sal_Int32 len, const sal_Unicode *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of a substring within a string.
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type endsWith(T &literal, OUString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1402
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition: ustring.hxx:499
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:3044
#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:128
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:1876
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:1042
~OUString()
Release the string data.
Definition: ustring.hxx:397
static OUString number(double d)
Returns the string representation of the double argument.
Definition: ustring.hxx:3093
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfStr_WithLength(const sal_Unicode *str, sal_Int32 len, const sal_Unicode *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of a substring within a string.
SAL_DLLPUBLIC void rtl_uString_newReplaceStrAt(rtl_uString **newStr, rtl_uString *str, sal_Int32 idx, sal_Int32 count, rtl_uString *subStr) SAL_THROW_EXTERN_C()
Create a new string by replacing a substring of another string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfChar_WithLength(const sal_Unicode *str, sal_Int32 len, sal_Unicode ch) SAL_THROW_EXTERN_C()
Search for the first occurrence of a character within a string.
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfChar_WithLength(const sal_Unicode *str, sal_Int32 len, sal_Unicode ch) SAL_THROW_EXTERN_C()
Search for the last occurrence of a character within a string.
SAL_DLLPUBLIC void rtl_uString_newReplaceFirstAsciiLAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, char const *to, sal_Int32 toLength, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
sal_Int32 reverseCompareToAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Compares two strings in reverse order.
Definition: ustring.hxx:1021
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:2004
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:1330
bool equalsIgnoreAsciiCase(const OUString &str) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:766
OUString(rtl_uString *str, __sal_NoAcquire)
New OUString from OUString data without acquiring it.
Definition: ustring.hxx:169
bool startsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: ustring.hxx:1236
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:1567
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:2264
OUString(const sal_Unicode *value, sal_Int32 length)
New string from a Unicode character buffer array.
Definition: ustring.hxx:213
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:3023
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:2457
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:459
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:90
SAL_DLLPUBLIC float rtl_ustr_toFloat(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a float.
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1324