LibreOffice
LibreOffice 5.1 SDK C/C++ API Reference
ustring.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_RTL_USTRING_HXX
21 #define INCLUDED_RTL_USTRING_HXX
22 
23 #include <sal/config.h>
24 
25 #include <cassert>
26 #include <cstddef>
27 #include <new>
28 #include <ostream>
29 #include <string.h>
30 
31 #include <rtl/ustring.h>
32 #include <rtl/string.hxx>
33 #include <rtl/stringutils.hxx>
34 #include <rtl/textenc.h>
35 #include <sal/log.hxx>
36 
37 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
38 #include <config_global.h>
39 #include <rtl/stringconcat.hxx>
40 #endif
41 
42 // 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 
138  OUString( rtl_uString * str )
139  {
140  pData = str;
141  rtl_uString_acquire( pData );
142  }
143 
152  inline OUString( rtl_uString * str, __sal_NoAcquire )
153  { pData = str; }
154 
160  explicit OUString( sal_Unicode value )
161  : pData (NULL)
162  {
163  rtl_uString_newFromStr_WithLength( &pData, &value, 1 );
164  }
165 
166 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
167  // Catch inadvertent conversions to the above ctor (but still allow
169  // construction from char literals):
170  OUString(int) = delete;
171  explicit OUString(char c):
172  OUString(sal_Unicode(static_cast<unsigned char>(c)))
173  {}
175 #endif
176 
182  OUString( const sal_Unicode * value )
183  {
184  pData = NULL;
185  rtl_uString_newFromStr( &pData, value );
186  }
187 
196  OUString( const sal_Unicode * value, sal_Int32 length )
197  {
198  pData = NULL;
199  rtl_uString_newFromStr_WithLength( &pData, value, length );
200  }
201 
217  template< typename T >
219  {
220  assert(
222  pData = NULL;
224  rtl_uString_new(&pData);
225  } else {
227  &pData,
229  literal),
231  }
232 #ifdef RTL_STRING_UNITTEST
233  rtl_string_unittest_const_literal = true;
234 #endif
235  }
236 
237 #ifdef RTL_STRING_UNITTEST
238 
242  template< typename T >
244  {
245  pData = NULL;
246  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
247  rtl_string_unittest_invalid_conversion = true;
248  }
253  template< typename T >
255  {
256  pData = NULL;
257  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
258  rtl_string_unittest_invalid_conversion = true;
259  }
260 #endif
261 
262 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
263 
279  OUString(OUStringLiteral literal): pData(NULL) {
280  rtl_uString_newFromLiteral(&pData, literal.data, literal.size, 0);
281  }
283 #endif
284 
299  OUString( const sal_Char * value, sal_Int32 length,
300  rtl_TextEncoding encoding,
301  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
302  {
303  pData = NULL;
304  rtl_string2UString( &pData, value, length, encoding, convertFlags );
305  if (pData == NULL) {
306  throw std::bad_alloc();
307  }
308  }
309 
326  inline explicit OUString(
327  sal_uInt32 const * codePoints, sal_Int32 codePointCount):
328  pData(NULL)
329  {
330  rtl_uString_newFromCodePoints(&pData, codePoints, codePointCount);
331  if (pData == NULL) {
332  throw std::bad_alloc();
333  }
334  }
335 
336 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
337 
341  template< typename T1, typename T2 >
342  OUString( const OUStringConcat< T1, T2 >& c )
343  {
344  const sal_Int32 l = c.length();
345  pData = rtl_uString_alloc( l );
346  if (l != 0)
347  {
348  sal_Unicode* end = c.addData( pData->buffer );
349  pData->length = l;
350  *end = '\0';
351  // TODO realloc in case pData->length is noticeably smaller than l?
352  }
353  }
354 #endif
355 
360  {
361  rtl_uString_release( pData );
362  }
363 
375  static inline OUString const & unacquired( rtl_uString * const * ppHandle )
376  { return * reinterpret_cast< OUString const * >( ppHandle ); }
377 
383  OUString & operator=( const OUString & str )
384  {
385  rtl_uString_assign( &pData, str.pData );
386  return *this;
387  }
388 
401  template< typename T >
403  {
404  assert(
407  rtl_uString_new(&pData);
408  } else {
410  &pData,
412  literal),
414  }
415  return *this;
416  }
417 
423  OUString & operator+=( const OUString & str )
424 #if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
425  &
426 #endif
427  {
428  rtl_uString_newConcat( &pData, pData, str.pData );
429  return *this;
430  }
431 #if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
432  void operator+=(OUString const &) && = delete;
433 #endif
434 
441  template<typename T>
443  operator +=(T & literal)
444 #if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
445  &
446 #endif
447  {
448  assert(
451  &pData, pData,
454  return *this;
455  }
456 #if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
457  template<typename T>
459  operator +=(T &) && = delete;
460 #endif
461 
462 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
463 
467  template< typename T1, typename T2 >
468  OUString& operator+=( const OUStringConcat< T1, T2 >& c )
469 #if HAVE_CXX11_REF_QUALIFIER
470  &
471 #endif
472  {
473  sal_Int32 l = c.length();
474  if( l == 0 )
475  return *this;
476  l += pData->length;
477  rtl_uString_ensureCapacity( &pData, l );
478  sal_Unicode* end = c.addData( pData->buffer + pData->length );
479  *end = '\0';
480  pData->length = l;
481  return *this;
482  }
483 #if HAVE_CXX11_REF_QUALIFIER
484  template<typename T1, typename T2> void operator +=(
485  OUStringConcat<T1, T2> const &) && = delete;
486 #endif
487 #endif
488 
493  void clear()
494  {
495  rtl_uString_new( &pData );
496  }
497 
506  sal_Int32 getLength() const { return pData->length; }
507 
516  bool isEmpty() const
517  {
518  return pData->length == 0;
519  }
520 
528  const sal_Unicode * getStr() const { return pData->buffer; }
529 
539  sal_Unicode operator [](sal_Int32 index) const {
540  // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
541  assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
542  return getStr()[index];
543  }
544 
557  sal_Int32 compareTo( const OUString & str ) const
558  {
559  return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
560  str.pData->buffer, str.pData->length );
561  }
562 
578  sal_Int32 compareTo( const OUString & str, sal_Int32 maxLength ) const
579  {
580  return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
581  str.pData->buffer, str.pData->length, maxLength );
582  }
583 
596  sal_Int32 reverseCompareTo( const OUString & str ) const
597  {
598  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
599  str.pData->buffer, str.pData->length );
600  }
601 
607  template< typename T >
609  {
610  assert(
613  pData->buffer, pData->length,
616  }
617 
629  bool equals( const OUString & str ) const
630  {
631  if ( pData->length != str.pData->length )
632  return false;
633  if ( pData == str.pData )
634  return true;
635  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
636  str.pData->buffer, str.pData->length ) == 0;
637  }
638 
653  bool equalsIgnoreAsciiCase( const OUString & str ) const
654  {
655  if ( pData->length != str.pData->length )
656  return false;
657  if ( pData == str.pData )
658  return true;
659  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
660  str.pData->buffer, str.pData->length ) == 0;
661  }
662 
678  sal_Int32 compareToIgnoreAsciiCase( const OUString & str ) const
679  {
680  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
681  str.pData->buffer, str.pData->length );
682  }
683 
684 
690  template< typename T >
692  {
693  assert(
695  return
696  (pData->length
699  pData->buffer, pData->length,
701  literal))
702  == 0);
703  }
704 
720  bool match( const OUString & str, sal_Int32 fromIndex = 0 ) const
721  {
722  return rtl_ustr_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
723  str.pData->buffer, str.pData->length, str.pData->length ) == 0;
724  }
725 
731  template< typename T >
732  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
733  {
734  assert(
736  return
738  pData->buffer+fromIndex, pData->length-fromIndex,
740  literal),
742  == 0;
743  }
744 
763  bool matchIgnoreAsciiCase( const OUString & str, sal_Int32 fromIndex = 0 ) const
764  {
765  return rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
766  str.pData->buffer, str.pData->length,
767  str.pData->length ) == 0;
768  }
769 
775  template< typename T >
776  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
777  {
778  assert(
780  return
782  pData->buffer+fromIndex, pData->length-fromIndex,
784  literal),
786  == 0;
787  }
788 
805  sal_Int32 compareToAscii( const sal_Char* asciiStr ) const
806  {
807  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length, asciiStr );
808  }
809 
833  "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
834  sal_Int32 compareToAscii( const sal_Char * asciiStr, sal_Int32 maxLength ) const
835  {
836  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer, pData->length,
837  asciiStr, maxLength );
838  }
839 
859  sal_Int32 reverseCompareToAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
860  {
861  return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
862  asciiStr, asciiStrLength );
863  }
864 
880  bool equalsAscii( const sal_Char* asciiStr ) const
881  {
882  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length,
883  asciiStr ) == 0;
884  }
885 
903  bool equalsAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength ) const
904  {
905  if ( pData->length != asciiStrLength )
906  return false;
907 
909  pData->buffer, asciiStr, asciiStrLength );
910  }
911 
930  bool equalsIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const
931  {
932  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
933  }
934 
953  sal_Int32 compareToIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const
954  {
955  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr );
956  }
957 
978  bool equalsIgnoreAsciiCaseAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
979  {
980  if ( pData->length != asciiStrLength )
981  return false;
982 
983  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
984  }
985 
1007  bool matchAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1008  {
1009  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1010  asciiStr, asciiStrLength ) == 0;
1011  }
1012 
1013  // This overload is left undefined, to detect calls of matchAsciiL that
1014  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1015  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1016  // platforms):
1017 #if SAL_TYPES_SIZEOFLONG == 8
1018  void matchAsciiL(char const *, sal_Int32, rtl_TextEncoding) const;
1019 #endif
1020 
1045  bool matchIgnoreAsciiCaseAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1046  {
1047  return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1048  asciiStr, asciiStrLength ) == 0;
1049  }
1050 
1051  // This overload is left undefined, to detect calls of
1052  // matchIgnoreAsciiCaseAsciiL that erroneously use
1053  // RTL_CONSTASCII_USTRINGPARAM instead of RTL_CONSTASCII_STRINGPARAM (but
1054  // would lead to ambiguities on 32 bit platforms):
1055 #if SAL_TYPES_SIZEOFLONG == 8
1056  void matchIgnoreAsciiCaseAsciiL(char const *, sal_Int32, rtl_TextEncoding)
1057  const;
1058 #endif
1059 
1074  bool startsWith(OUString const & str, OUString * rest = NULL) const {
1075  bool b = match(str);
1076  if (b && rest != NULL) {
1077  *rest = copy(str.getLength());
1078  }
1079  return b;
1080  }
1081 
1087  template< typename T >
1089  T & literal, OUString * rest = NULL) const
1090  {
1091  assert(
1093  bool b
1095  <= sal_uInt32(pData->length))
1097  pData->buffer,
1099  literal),
1101  if (b && rest != NULL) {
1102  *rest = copy(
1104  }
1105  return b;
1106  }
1107 
1128  bool startsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL)
1129  const
1130  {
1131  bool b = matchIgnoreAsciiCase(str);
1132  if (b && rest != NULL) {
1133  *rest = copy(str.getLength());
1134  }
1135  return b;
1136  }
1137 
1143  template< typename T >
1145  startsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1146  {
1147  assert(
1149  bool b
1151  pData->buffer,
1154  literal),
1156  == 0);
1157  if (b && rest != NULL) {
1158  *rest = copy(
1160  }
1161  return b;
1162  }
1163 
1178  bool endsWith(OUString const & str, OUString * rest = NULL) const {
1179  bool b = str.getLength() <= getLength()
1180  && match(str, getLength() - str.getLength());
1181  if (b && rest != NULL) {
1182  *rest = copy(0, getLength() - str.getLength());
1183  }
1184  return b;
1185  }
1186 
1192  template< typename T >
1194  endsWith(T & literal, OUString * rest = NULL) const
1195  {
1196  assert(
1198  bool b
1200  <= sal_uInt32(pData->length))
1202  (pData->buffer + pData->length
1205  literal),
1207  if (b && rest != NULL) {
1208  *rest = copy(
1209  0,
1210  (getLength()
1212  }
1213  return b;
1214  }
1215 
1227  inline bool endsWithAsciiL(char const * asciiStr, sal_Int32 asciiStrLength)
1228  const
1229  {
1230  return asciiStrLength <= pData->length
1232  pData->buffer + pData->length - asciiStrLength, asciiStr,
1233  asciiStrLength);
1234  }
1235 
1256  bool endsWithIgnoreAsciiCase(OUString const & str, OUString * rest = NULL) const
1257  {
1258  bool b = str.getLength() <= getLength()
1259  && matchIgnoreAsciiCase(str, getLength() - str.getLength());
1260  if (b && rest != NULL) {
1261  *rest = copy(0, getLength() - str.getLength());
1262  }
1263  return b;
1264  }
1265 
1271  template< typename T >
1273  endsWithIgnoreAsciiCase(T & literal, OUString * rest = NULL) const
1274  {
1275  assert(
1277  bool b
1279  <= sal_uInt32(pData->length))
1281  (pData->buffer + pData->length
1285  literal),
1287  == 0);
1288  if (b && rest != NULL) {
1289  *rest = copy(
1290  0,
1291  (getLength()
1293  }
1294  return b;
1295  }
1296 
1308  char const * asciiStr, sal_Int32 asciiStrLength) const
1309  {
1310  return asciiStrLength <= pData->length
1312  pData->buffer + pData->length - asciiStrLength,
1313  asciiStrLength, asciiStr, asciiStrLength)
1314  == 0);
1315  }
1316 
1317  friend bool operator == ( const OUString& rStr1, const OUString& rStr2 )
1318  { return rStr1.equals(rStr2); }
1319  friend bool operator == ( const OUString& rStr1, const sal_Unicode * pStr2 )
1320  { return rStr1.compareTo( pStr2 ) == 0; }
1321  friend bool operator == ( const sal_Unicode * pStr1, const OUString& rStr2 )
1322  { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
1323 
1324  friend bool operator != ( const OUString& rStr1, const OUString& rStr2 )
1325  { return !(operator == ( rStr1, rStr2 )); }
1326  friend bool operator != ( const OUString& rStr1, const sal_Unicode * pStr2 )
1327  { return !(operator == ( rStr1, pStr2 )); }
1328  friend bool operator != ( const sal_Unicode * pStr1, const OUString& rStr2 )
1329  { return !(operator == ( pStr1, rStr2 )); }
1330 
1331  friend bool operator < ( const OUString& rStr1, const OUString& rStr2 )
1332  { return rStr1.compareTo( rStr2 ) < 0; }
1333  friend bool operator > ( const OUString& rStr1, const OUString& rStr2 )
1334  { return rStr1.compareTo( rStr2 ) > 0; }
1335  friend bool operator <= ( const OUString& rStr1, const OUString& rStr2 )
1336  { return rStr1.compareTo( rStr2 ) <= 0; }
1337  friend bool operator >= ( const OUString& rStr1, const OUString& rStr2 )
1338  { return rStr1.compareTo( rStr2 ) >= 0; }
1339 
1347  template< typename T >
1348  friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==( const OUString& string, T& literal )
1349  {
1350  assert(
1352  return string.equalsAsciiL(
1355  }
1363  template< typename T >
1364  friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==( T& literal, const OUString& string )
1365  {
1366  assert(
1368  return string.equalsAsciiL(
1371  }
1379  template< typename T >
1380  friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=( const OUString& string, T& literal )
1381  {
1382  assert(
1384  return !string.equalsAsciiL(
1387  }
1395  template< typename T >
1396  friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=( T& literal, const OUString& string )
1397  {
1398  assert(
1400  return !string.equalsAsciiL(
1403  }
1404 
1405 #if defined LIBO_INTERNAL_ONLY
1406 
1408  /* Comparison between OUString and OUStringLiteral.
1409 
1410  @since LibreOffice 5.0
1411  */
1412 
1413  friend bool operator ==(OUString const & lhs, OUStringLiteral const & rhs) {
1414  return lhs.equalsAsciiL(rhs.data, rhs.size);
1415  }
1416 
1417  friend bool operator !=(OUString const & lhs, OUStringLiteral const & rhs) {
1418  return !lhs.equalsAsciiL(rhs.data, rhs.size);
1419  }
1420 
1421  friend bool operator <(OUString const & lhs, OUStringLiteral const & rhs) {
1422  return
1424  lhs.pData->buffer, lhs.pData->length, rhs.data))
1425  < 0;
1426  }
1427 
1428  friend bool operator <=(OUString const & lhs, OUStringLiteral const & rhs) {
1429  return
1431  lhs.pData->buffer, lhs.pData->length, rhs.data))
1432  <= 0;
1433  }
1434 
1435  friend bool operator >(OUString const & lhs, OUStringLiteral const & rhs) {
1436  return
1438  lhs.pData->buffer, lhs.pData->length, rhs.data))
1439  > 0;
1440  }
1441 
1442  friend bool operator >=(OUString const & lhs, OUStringLiteral const & rhs) {
1443  return
1445  lhs.pData->buffer, lhs.pData->length, rhs.data))
1446  >= 0;
1447  }
1448 
1449  friend bool operator ==(OUStringLiteral const & lhs, OUString const & rhs) {
1450  return rhs.equalsAsciiL(lhs.data, lhs.size);
1451  }
1452 
1453  friend bool operator !=(OUStringLiteral const & lhs, OUString const & rhs) {
1454  return !rhs.equalsAsciiL(lhs.data, lhs.size);
1455  }
1456 
1457  friend bool operator <(OUStringLiteral const & lhs, OUString const & rhs) {
1458  return
1460  rhs.pData->buffer, rhs.pData->length, lhs.data))
1461  >= 0;
1462  }
1463 
1464  friend bool operator <=(OUStringLiteral const & lhs, OUString const & rhs) {
1465  return
1467  rhs.pData->buffer, rhs.pData->length, lhs.data))
1468  > 0;
1469  }
1470 
1471  friend bool operator >(OUStringLiteral const & lhs, OUString const & rhs) {
1472  return
1474  rhs.pData->buffer, rhs.pData->length, lhs.data))
1475  <= 0;
1476  }
1477 
1478  friend bool operator >=(OUStringLiteral const & lhs, OUString const & rhs) {
1479  return
1481  rhs.pData->buffer, rhs.pData->length, lhs.data))
1482  < 0;
1483  }
1484 
1486 #endif
1487 
1495  sal_Int32 hashCode() const
1496  {
1497  return rtl_ustr_hashCode_WithLength( pData->buffer, pData->length );
1498  }
1499 
1513  sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
1514  {
1515  sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1516  return (ret < 0 ? ret : ret+fromIndex);
1517  }
1518 
1528  sal_Int32 lastIndexOf( sal_Unicode ch ) const
1529  {
1530  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1531  }
1532 
1545  sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
1546  {
1547  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1548  }
1549 
1565  sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
1566  {
1567  sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1568  str.pData->buffer, str.pData->length );
1569  return (ret < 0 ? ret : ret+fromIndex);
1570  }
1571 
1577  template< typename T >
1578  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1579  {
1580  assert(
1582  sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
1583  pData->buffer + fromIndex, pData->length - fromIndex,
1586  return n < 0 ? n : n + fromIndex;
1587  }
1588 
1612  sal_Int32 indexOfAsciiL(
1613  char const * str, sal_Int32 len, sal_Int32 fromIndex = 0) const
1614  {
1615  sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
1616  pData->buffer + fromIndex, pData->length - fromIndex, str, len);
1617  return ret < 0 ? ret : ret + fromIndex;
1618  }
1619 
1620  // This overload is left undefined, to detect calls of indexOfAsciiL that
1621  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1622  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1623  // platforms):
1624 #if SAL_TYPES_SIZEOFLONG == 8
1625  void indexOfAsciiL(char const *, sal_Int32 len, rtl_TextEncoding) const;
1626 #endif
1627 
1643  sal_Int32 lastIndexOf( const OUString & str ) const
1644  {
1645  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1646  str.pData->buffer, str.pData->length );
1647  }
1648 
1666  sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
1667  {
1668  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1669  str.pData->buffer, str.pData->length );
1670  }
1671 
1677  template< typename T >
1679  {
1680  assert(
1683  pData->buffer, pData->length,
1686  }
1687 
1707  sal_Int32 lastIndexOfAsciiL(char const * str, sal_Int32 len) const
1708  {
1710  pData->buffer, pData->length, str, len);
1711  }
1712 
1723  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex ) const
1724  {
1725  rtl_uString *pNew = NULL;
1726  rtl_uString_newFromSubString( &pNew, pData, beginIndex, getLength() - beginIndex );
1727  return OUString( pNew, SAL_NO_ACQUIRE );
1728  }
1729 
1742  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const
1743  {
1744  rtl_uString *pNew = NULL;
1745  rtl_uString_newFromSubString( &pNew, pData, beginIndex, count );
1746  return OUString( pNew, SAL_NO_ACQUIRE );
1747  }
1748 
1758  {
1759  rtl_uString* pNew = NULL;
1760  rtl_uString_newConcat( &pNew, pData, str.pData );
1761  return OUString( pNew, SAL_NO_ACQUIRE );
1762  }
1763 
1764 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1765  friend OUString operator+( const OUString& rStr1, const OUString& rStr2 )
1766  {
1767  return rStr1.concat( rStr2 );
1768  }
1769 #endif
1770 
1784  SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const
1785  {
1786  rtl_uString* pNew = NULL;
1787  rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
1788  return OUString( pNew, SAL_NO_ACQUIRE );
1789  }
1790 
1805  {
1806  rtl_uString* pNew = NULL;
1807  rtl_uString_newReplace( &pNew, pData, oldChar, newChar );
1808  return OUString( pNew, SAL_NO_ACQUIRE );
1809  }
1810 
1830  OUString const & from, OUString const & to, sal_Int32 * index = NULL) const
1831  {
1832  rtl_uString * s = NULL;
1833  sal_Int32 i = 0;
1835  &s, pData, from.pData, to.pData, index == NULL ? &i : index);
1836  return OUString(s, SAL_NO_ACQUIRE);
1837  }
1838 
1857  template< typename T >
1859  sal_Int32 * index = NULL) const
1860  {
1862  rtl_uString * s = NULL;
1863  sal_Int32 i = 0;
1865  &s, pData,
1868  index == NULL ? &i : index);
1869  return OUString(s, SAL_NO_ACQUIRE);
1870  }
1871 
1890  template< typename T >
1892  sal_Int32 * index = NULL) const
1893  {
1895  rtl_uString * s = NULL;
1896  sal_Int32 i = 0;
1898  &s, pData, from.pData,
1901  index == NULL ? &i : index);
1902  return OUString(s, SAL_NO_ACQUIRE);
1903  }
1904 
1923  template< typename T1, typename T2 >
1925  replaceFirst( T1& from, T2& to, sal_Int32 * index = NULL) const
1926  {
1929  rtl_uString * s = NULL;
1930  sal_Int32 i = 0;
1932  &s, pData,
1937  index == NULL ? &i : index);
1938  return OUString(s, SAL_NO_ACQUIRE);
1939  }
1940 
1957  OUString const & from, OUString const & to, sal_Int32 fromIndex = 0) const
1958  {
1959  rtl_uString * s = NULL;
1960  rtl_uString_newReplaceAllFromIndex(&s, pData, from.pData, to.pData, fromIndex);
1961  return OUString(s, SAL_NO_ACQUIRE);
1962  }
1963 
1977  template< typename T >
1979  {
1981  rtl_uString * s = NULL;
1983  &s, pData,
1986  return OUString(s, SAL_NO_ACQUIRE);
1987  }
1988 
2002  template< typename T >
2004  {
2006  rtl_uString * s = NULL;
2008  &s, pData, from.pData,
2011  return OUString(s, SAL_NO_ACQUIRE);
2012  }
2013 
2027  template< typename T1, typename T2 >
2029  replaceAll( T1& from, T2& to ) const
2030  {
2033  rtl_uString * s = NULL;
2035  &s, pData,
2040  return OUString(s, SAL_NO_ACQUIRE);
2041  }
2042 
2054  {
2055  rtl_uString* pNew = NULL;
2056  rtl_uString_newToAsciiLowerCase( &pNew, pData );
2057  return OUString( pNew, SAL_NO_ACQUIRE );
2058  }
2059 
2071  {
2072  rtl_uString* pNew = NULL;
2073  rtl_uString_newToAsciiUpperCase( &pNew, pData );
2074  return OUString( pNew, SAL_NO_ACQUIRE );
2075  }
2076 
2089  {
2090  rtl_uString* pNew = NULL;
2091  rtl_uString_newTrim( &pNew, pData );
2092  return OUString( pNew, SAL_NO_ACQUIRE );
2093  }
2094 
2119  OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const
2120  {
2121  rtl_uString * pNew = NULL;
2122  index = rtl_uString_getToken( &pNew, pData, token, cTok, index );
2123  return OUString( pNew, SAL_NO_ACQUIRE );
2124  }
2125 
2139  OUString getToken(sal_Int32 count, sal_Unicode separator) const {
2140  sal_Int32 n = 0;
2141  return getToken(count, separator, n);
2142  }
2143 
2152  bool toBoolean() const
2153  {
2154  return rtl_ustr_toBoolean( pData->buffer );
2155  }
2156 
2164  {
2165  return pData->buffer[0];
2166  }
2167 
2178  sal_Int32 toInt32( sal_Int16 radix = 10 ) const
2179  {
2180  return rtl_ustr_toInt32( pData->buffer, radix );
2181  }
2182 
2195  sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
2196  {
2197  return rtl_ustr_toUInt32( pData->buffer, radix );
2198  }
2199 
2210  sal_Int64 toInt64( sal_Int16 radix = 10 ) const
2211  {
2212  return rtl_ustr_toInt64( pData->buffer, radix );
2213  }
2214 
2227  sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
2228  {
2229  return rtl_ustr_toUInt64( pData->buffer, radix );
2230  }
2231 
2240  float toFloat() const
2241  {
2242  return rtl_ustr_toFloat( pData->buffer );
2243  }
2244 
2253  double toDouble() const
2254  {
2255  return rtl_ustr_toDouble( pData->buffer );
2256  }
2257 
2258 
2275  {
2276  rtl_uString * pNew = NULL;
2277  rtl_uString_intern( &pNew, pData );
2278  if (pNew == NULL) {
2279  throw std::bad_alloc();
2280  }
2281  return OUString( pNew, SAL_NO_ACQUIRE );
2282  }
2283 
2309  static OUString intern( const sal_Char * value, sal_Int32 length,
2310  rtl_TextEncoding encoding,
2311  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS,
2312  sal_uInt32 *pInfo = NULL )
2313  {
2314  rtl_uString * pNew = NULL;
2315  rtl_uString_internConvert( &pNew, value, length, encoding,
2316  convertFlags, pInfo );
2317  if (pNew == NULL) {
2318  throw std::bad_alloc();
2319  }
2320  return OUString( pNew, SAL_NO_ACQUIRE );
2321  }
2322 
2347  inline bool convertToString(OString * pTarget, rtl_TextEncoding nEncoding,
2348  sal_uInt32 nFlags) const
2349  {
2350  return rtl_convertUStringToString(&pTarget->pData, pData->buffer,
2351  pData->length, nEncoding, nFlags);
2352  }
2353 
2405  inline sal_uInt32 iterateCodePoints(
2406  sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1) const
2407  {
2409  pData, indexUtf16, incrementCodePoints);
2410  }
2411 
2421  static inline OUString fromUtf8(const OString& rSource)
2422  {
2423  OUString aTarget;
2424  bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
2425  rSource.getStr(),
2426  rSource.getLength(),
2429  (void) bSuccess;
2430  assert(bSuccess);
2431  return aTarget;
2432  }
2433 
2444  inline OString toUtf8() const
2445  {
2446  OString aTarget;
2447  bool bSuccess = rtl_convertUStringToString(&aTarget.pData,
2448  getStr(),
2449  getLength(),
2452  (void) bSuccess;
2453  assert(bSuccess);
2454  return aTarget;
2455  }
2456 
2467  static OUString number( int i, sal_Int16 radix = 10 )
2468  {
2470  rtl_uString* pNewData = NULL;
2471  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt32( aBuf, i, radix ) );
2472  return OUString( pNewData, SAL_NO_ACQUIRE );
2473  }
2476  static OUString number( unsigned int i, sal_Int16 radix = 10 )
2477  {
2478  return number( static_cast< unsigned long long >( i ), radix );
2479  }
2482  static OUString number( long i, sal_Int16 radix = 10)
2483  {
2484  return number( static_cast< long long >( i ), radix );
2485  }
2488  static OUString number( unsigned long i, sal_Int16 radix = 10 )
2489  {
2490  return number( static_cast< unsigned long long >( i ), radix );
2491  }
2494  static OUString number( long long ll, sal_Int16 radix = 10 )
2495  {
2497  rtl_uString* pNewData = NULL;
2498  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt64( aBuf, ll, radix ) );
2499  return OUString( pNewData, SAL_NO_ACQUIRE );
2500  }
2503  static OUString number( unsigned long long ll, sal_Int16 radix = 10 )
2504  {
2506  rtl_uString* pNewData = NULL;
2507  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfUInt64( aBuf, ll, radix ) );
2508  return OUString( pNewData, SAL_NO_ACQUIRE );
2509  }
2510 
2520  static OUString number( float f )
2521  {
2523  rtl_uString* pNewData = NULL;
2524  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfFloat( aBuf, f ) );
2525  return OUString( pNewData, SAL_NO_ACQUIRE );
2526  }
2527 
2537  static OUString number( double d )
2538  {
2540  rtl_uString* pNewData = NULL;
2541  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfDouble( aBuf, d ) );
2542  return OUString( pNewData, SAL_NO_ACQUIRE );
2543  }
2544 
2556  SAL_DEPRECATED("use boolean()") static OUString valueOf( sal_Bool b )
2557  {
2558  return boolean(b);
2559  }
2560 
2572  static OUString boolean( bool b )
2573  {
2575  rtl_uString* pNewData = NULL;
2576  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfBoolean( aBuf, b ) );
2577  return OUString( pNewData, SAL_NO_ACQUIRE );
2578  }
2579 
2587  SAL_DEPRECATED("convert to OUString or use directly") static OUString valueOf( sal_Unicode c )
2588  {
2589  return OUString( &c, 1 );
2590  }
2591 
2602  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
2603  {
2604  return number( i, radix );
2605  }
2606 
2617  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
2618  {
2619  return number( ll, radix );
2620  }
2621 
2631  SAL_DEPRECATED("use number()") static OUString valueOf( float f )
2632  {
2633  return number(f);
2634  }
2635 
2645  SAL_DEPRECATED("use number()") static OUString valueOf( double d )
2646  {
2647  return number(d);
2648  }
2649 
2665  static OUString createFromAscii( const sal_Char * value )
2666  {
2667  rtl_uString* pNew = NULL;
2668  rtl_uString_newFromAscii( &pNew, value );
2669  return OUString( pNew, SAL_NO_ACQUIRE );
2670  }
2671 };
2672 
2673 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2674 
2679 template<>
2680 struct ToStringHelper< OUString >
2681  {
2682  static int length( const OUString& s ) { return s.getLength(); }
2683  static sal_Unicode* addData( sal_Unicode* buffer, const OUString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
2684  static const bool allowOStringConcat = false;
2685  static const bool allowOUStringConcat = true;
2686  };
2687 
2691 template<>
2692 struct ToStringHelper< OUStringLiteral >
2693  {
2694  static int length( const OUStringLiteral& str ) { return str.size; }
2695  static sal_Unicode* addData( sal_Unicode* buffer, const OUStringLiteral& str ) { return addDataLiteral( buffer, str.data, str.size ); }
2696  static const bool allowOStringConcat = false;
2697  static const bool allowOUStringConcat = true;
2698  };
2699 
2703 template< typename charT, typename traits, typename T1, typename T2 >
2704 inline std::basic_ostream<charT, traits> & operator <<(
2705  std::basic_ostream<charT, traits> & stream, const OUStringConcat< T1, T2 >& concat)
2706 {
2707  return stream << OUString( concat );
2708 }
2709 
2711 #endif
2712 
2719 {
2729  size_t operator()(const OUString& rString) const
2730  { return (size_t)rString.hashCode(); }
2731 };
2732 
2733 /* ======================================================================= */
2734 
2752 inline OUString OStringToOUString( const OString & rStr,
2753  rtl_TextEncoding encoding,
2754  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
2755 {
2756  return OUString( rStr.getStr(), rStr.getLength(), encoding, convertFlags );
2757 }
2758 
2776 inline OString OUStringToOString( const OUString & rUnicode,
2777  rtl_TextEncoding encoding,
2778  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
2779 {
2780  return OString( rUnicode.getStr(), rUnicode.getLength(), encoding, convertFlags );
2781 }
2782 
2783 /* ======================================================================= */
2784 
2793 template< typename charT, typename traits >
2794 inline std::basic_ostream<charT, traits> & operator <<(
2795  std::basic_ostream<charT, traits> & stream, OUString const & string)
2796 {
2797  return stream <<
2799  // best effort; potentially loses data due to conversion failures
2800  // (stray surrogate halves) and embedded null characters
2801 }
2802 
2803 } // namespace
2804 
2805 #ifdef RTL_STRING_UNITTEST
2806 namespace rtl
2807 {
2808 typedef rtlunittest::OUString OUString;
2809 }
2810 #endif
2811 
2812 // In internal code, allow to use classes like OUString without having to
2813 // explicitly refer to the rtl namespace, which is kind of superfluous given
2814 // that OUString itself is namespaced by its OU prefix:
2815 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
2816 using ::rtl::OUString;
2817 using ::rtl::OUStringHash;
2820 using ::rtl::OUStringLiteral;
2821 using ::rtl::OUStringLiteral1;
2822 #endif
2823 
2824 #endif /* _RTL_USTRING_HXX */
2825 
2826 /* 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:2572
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:1612
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:2309
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.
double toDouble() const
Returns the double value from this string.
Definition: ustring.hxx:2253
#define OSTRING_TO_OUSTRING_CVTFLAGS
Definition: ustring.h:1894
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: ustring.hxx:2178
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:608
const sal_Unicode * getStr() const
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:528
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: ustring.hxx:493
bool equalsIgnoreAsciiCaseAscii(const sal_Char *asciiStr) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:930
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:506
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:1045
OUString & operator=(const OUString &str)
Assign a new string.
Definition: ustring.hxx:383
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:1178
OUString intern() const
Return a canonical representation for a string.
Definition: ustring.hxx:2274
static OUString const & unacquired(rtl_uString *const *ppHandle)
Provides an OUString const & passing a storage pointer of an rtl_uString * handle.
Definition: ustring.hxx:375
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:2227
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:2494
#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.
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:2752
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.
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(const OUString &string, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1348
#define RTL_USTR_MAX_VALUEOFBOOLEAN
Definition: ustring.h:915
OUString(sal_Unicode value)
New string from a single Unicode character.
Definition: ustring.hxx:160
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:2476
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:612
OUString(sal_uInt32 const *codePoints, sal_Int32 codePointCount)
Create a new string from an array of Unicode code points.
Definition: ustring.hxx:326
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:2776
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:2482
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.
size_t operator()(const OUString &rString) const
Compute a hash code for a string.
Definition: ustring.hxx:2729
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:2152
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:2139
SAL_WARN_UNUSED_RESULT OUString concat(const OUString &str) const
Concatenates the specified string to the end of this string.
Definition: ustring.hxx:1757
bool equals(const OUString &str) const
Perform a comparison of two strings.
Definition: ustring.hxx:629
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:1007
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:1707
bool convertToString(OString *pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) const
Converts to an OString, signalling failure.
Definition: ustring.hxx:2347
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &stream, OString const &string)
Support for rtl::OString in std::ostream (and thus in CPPUNIT_ASSERT or SAL_INFO macros, for example).
Definition: string.hxx:1858
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:1765
sal_Int32 compareTo(const OUString &str, sal_Int32 maxLength) const
Compares two strings with a maximum count of characters.
Definition: ustring.hxx:578
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:1643
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:2503
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:394
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:1545
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:691
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:1578
SAL_DLLPUBLIC void rtl_uString_acquire(rtl_uString *str) SAL_THROW_EXTERN_C()
Increment the reference count of a string.
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:1256
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:1273
static OUString fromUtf8(const OString &rSource)
Convert an OString to an OUString, assuming that the OString is UTF-8-encoded.
Definition: ustring.hxx:2421
SAL_DLLPUBLIC sal_Bool rtl_ustr_toBoolean(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
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:2405
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:1742
bool equalsAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform a comparison of two strings.
Definition: ustring.hxx:903
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OUString &string)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1396
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:584
sal_Int32 reverseCompareTo(const OUString &str) const
Compares two strings in reverse order.
Definition: ustring.hxx:596
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:382
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:1784
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:323
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:1829
bool match(const OUString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:720
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: ustring.hxx:2195
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:1978
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:516
OString toUtf8() const
Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully.
Definition: ustring.hxx:2444
OUString(rtl_uString *str)
New string from OUString data.
Definition: ustring.hxx:138
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:1723
#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:1088
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:763
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!=(const OUString &string, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1380
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:2119
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:2053
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:805
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:1128
sal_Unicode toChar() const
Returns the first character from this string.
Definition: ustring.hxx:2163
bool equalsIgnoreAsciiCaseAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:978
static OUString number(float f)
Returns the string representation of the float argument.
Definition: ustring.hxx:2520
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:1666
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:1513
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:1891
float toFloat() const
Returns the float value from this string.
Definition: ustring.hxx:2240
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:1528
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: ustring.hxx:2210
sal_Int32 compareToIgnoreAsciiCaseAscii(const sal_Char *asciiStr) const
Compares two ASCII strings ignoring case.
Definition: ustring.hxx:953
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:2029
A helper to use OUStrings with hash maps.
Definition: ustring.hxx:2718
Definition: bootstrap.hxx:29
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:386
#define SAL_CONSTEXPR
C++11 "constexpr" feature.
Definition: types.h:443
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:776
#define RTL_USTR_MAX_VALUEOFDOUBLE
Definition: ustring.h:1041
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Dont use, its evil.") void doit(int nPara);.
Definition: types.h:499
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:557
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:218
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:368
bool endsWithAsciiL(char const *asciiStr, sal_Int32 asciiStrLength) const
Check whether this string ends with a given ASCII string.
Definition: ustring.hxx:1227
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:299
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:732
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:2070
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: ustring.hxx:1495
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:1956
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:2088
OUString(const sal_Unicode *value)
New string from a Unicode character buffer array.
Definition: ustring.hxx:182
sal_Int32 compareToIgnoreAsciiCase(const OUString &str) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:678
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:1858
static OUString createFromAscii(const sal_Char *value)
Returns a OUString copied without conversion from an ASCII character string.
Definition: ustring.hxx:2665
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:1804
Definition: stringutils.hxx:117
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:1194
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition: ustring.hxx:423
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:2488
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
#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:1565
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:880
~OUString()
Release the string data.
Definition: ustring.hxx:359
static OUString number(double d)
Returns the string representation of the double argument.
Definition: ustring.hxx:2537
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:859
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:1678
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:1145
bool equalsIgnoreAsciiCase(const OUString &str) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:653
OUString(rtl_uString *str, __sal_NoAcquire)
New OUString from OUString data without acquiring it.
Definition: ustring.hxx:152
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OUString &string)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1364
bool startsWith(OUString const &str, OUString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: ustring.hxx:1074
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:1307
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:1925
OUString(const sal_Unicode *value, sal_Int32 length)
New string from a Unicode character buffer array.
Definition: ustring.hxx:196
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:2467
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:2003
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:402
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