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 <new>
27 #include <ostream>
28 #include <string.h>
29 
30 #include <rtl/ustring.h>
31 #include <rtl/string.hxx>
32 #include <rtl/stringutils.hxx>
33 #include <rtl/textenc.h>
34 #include <sal/log.hxx>
35 
36 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
37 #include <rtl/stringconcat.hxx>
38 #endif
39 
40 // The unittest uses slightly different code to help check that the proper
41 // calls are made. The class is put into a different namespace to make
42 // sure the compiler generates a different (if generating also non-inline)
43 // copy of the function and does not merge them together. The class
44 // is "brought" into the proper rtl namespace by a typedef below.
45 #ifdef RTL_STRING_UNITTEST
46 #define rtl rtlunittest
47 #endif
48 
49 namespace rtl
50 {
51 
52 #ifdef RTL_STRING_UNITTEST
53 #undef rtl
54 #endif
55 
56 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
57 
67 struct SAL_WARN_UNUSED OUStringLiteral
68 {
69  template< int N >
70  explicit SAL_CONSTEXPR OUStringLiteral( const char (&str)[ N ] ) : size( N - 1 ), data( str )
71  { /* only C++14 constexpr: assert( strlen( str ) == N - 1 ); */ }
72  int size;
73  const char* data;
74 };
75 
77 #endif
78 
79 /* ======================================================================= */
80 
104 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OUString
105 {
106 public:
108  rtl_uString * pData;
110 
115  {
116  pData = 0;
117  rtl_uString_new( &pData );
118  }
119 
125  OUString( const OUString & str )
126  {
127  pData = str.pData;
128  rtl_uString_acquire( pData );
129  }
130 
136  OUString( rtl_uString * str )
137  {
138  pData = str;
139  rtl_uString_acquire( pData );
140  }
141 
150  inline OUString( rtl_uString * str, __sal_NoAcquire )
151  { pData = str; }
152 
158  explicit OUString( sal_Unicode value )
159  : pData (0)
160  {
161  rtl_uString_newFromStr_WithLength( &pData, &value, 1 );
162  }
163 
164 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
165  // Catch inadvertent conversions to the above ctor (but still allow
167  // construction from char literals):
168  OUString(int) = delete;
169  explicit OUString(char c):
170  OUString(sal_Unicode(static_cast<unsigned char>(c)))
171  {}
173 #endif
174 
180  OUString( const sal_Unicode * value )
181  {
182  pData = 0;
183  rtl_uString_newFromStr( &pData, value );
184  }
185 
194  OUString( const sal_Unicode * value, sal_Int32 length )
195  {
196  pData = 0;
197  rtl_uString_newFromStr_WithLength( &pData, value, length );
198  }
199 
215  template< typename T >
217  {
218  assert(
220  pData = 0;
222  rtl_uString_new(&pData);
223  } else {
225  &pData,
227  literal),
229  }
230 #ifdef RTL_STRING_UNITTEST
231  rtl_string_unittest_const_literal = true;
232 #endif
233  }
234 
235 #ifdef RTL_STRING_UNITTEST
236 
240  template< typename T >
242  {
243  pData = 0;
244  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
245  rtl_string_unittest_invalid_conversion = true;
246  }
251  template< typename T >
252  OUString( const T&, typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
253  {
254  pData = 0;
255  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
256  rtl_string_unittest_invalid_conversion = true;
257  }
258 #endif
259 
260 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
261 
277  OUString(OUStringLiteral literal): pData(0) {
278  rtl_uString_newFromLiteral(&pData, literal.data, literal.size, 0);
279  }
281 #endif
282 
297  OUString( const sal_Char * value, sal_Int32 length,
298  rtl_TextEncoding encoding,
299  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
300  {
301  pData = 0;
302  rtl_string2UString( &pData, value, length, encoding, convertFlags );
303  if (pData == 0) {
304  throw std::bad_alloc();
305  }
306  }
307 
324  inline explicit OUString(
325  sal_uInt32 const * codePoints, sal_Int32 codePointCount):
326  pData(NULL)
327  {
328  rtl_uString_newFromCodePoints(&pData, codePoints, codePointCount);
329  if (pData == NULL) {
330  throw std::bad_alloc();
331  }
332  }
333 
334 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
335 
339  template< typename T1, typename T2 >
340  OUString( const OUStringConcat< T1, T2 >& c )
341  {
342  const sal_Int32 l = c.length();
343  pData = rtl_uString_alloc( l );
344  if (l != 0)
345  {
346  sal_Unicode* end = c.addData( pData->buffer );
347  pData->length = l;
348  *end = '\0';
349  // TODO realloc in case pData->length is noticeably smaller than l?
350  }
351  }
352 #endif
353 
358  {
359  rtl_uString_release( pData );
360  }
361 
373  static inline OUString const & unacquired( rtl_uString * const * ppHandle )
374  { return * reinterpret_cast< OUString const * >( ppHandle ); }
375 
381  OUString & operator=( const OUString & str )
382  {
383  rtl_uString_assign( &pData, str.pData );
384  return *this;
385  }
386 
399  template< typename T >
401  {
402  assert(
405  rtl_uString_new(&pData);
406  } else {
408  &pData,
410  literal),
412  }
413  return *this;
414  }
415 
421  OUString & operator+=( const OUString & str )
422  {
423  rtl_uString_newConcat( &pData, pData, str.pData );
424  return *this;
425  }
426 
433  template<typename T>
435  operator +=(T & literal) {
436  assert(
439  &pData, pData,
442  return *this;
443  }
444 
445 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
446 
450  template< typename T1, typename T2 >
451  OUString& operator+=( const OUStringConcat< T1, T2 >& c )
452  {
453  sal_Int32 l = c.length();
454  if( l == 0 )
455  return *this;
456  l += pData->length;
457  rtl_uString_ensureCapacity( &pData, l );
458  sal_Unicode* end = c.addData( pData->buffer + pData->length );
459  *end = '\0';
460  pData->length = l;
461  return *this;
462  }
463 #endif
464 
469  void clear()
470  {
471  rtl_uString_new( &pData );
472  }
473 
482  sal_Int32 getLength() const { return pData->length; }
483 
492  bool isEmpty() const
493  {
494  return pData->length == 0;
495  }
496 
504  const sal_Unicode * getStr() const { return pData->buffer; }
505 
515  sal_Unicode operator [](sal_Int32 index) const {
516  // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
517  assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
518  return getStr()[index];
519  }
520 
533  sal_Int32 compareTo( const OUString & str ) const
534  {
535  return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
536  str.pData->buffer, str.pData->length );
537  }
538 
554  sal_Int32 compareTo( const OUString & str, sal_Int32 maxLength ) const
555  {
556  return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
557  str.pData->buffer, str.pData->length, maxLength );
558  }
559 
572  sal_Int32 reverseCompareTo( const OUString & str ) const
573  {
574  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
575  str.pData->buffer, str.pData->length );
576  }
577 
583  template< typename T >
585  {
586  assert(
589  pData->buffer, pData->length,
592  }
593 
605  bool equals( const OUString & str ) const
606  {
607  if ( pData->length != str.pData->length )
608  return false;
609  if ( pData == str.pData )
610  return true;
611  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
612  str.pData->buffer, str.pData->length ) == 0;
613  }
614 
629  bool equalsIgnoreAsciiCase( 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_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
636  str.pData->buffer, str.pData->length ) == 0;
637  }
638 
654  sal_Int32 compareToIgnoreAsciiCase( const OUString & str ) const
655  {
656  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
657  str.pData->buffer, str.pData->length );
658  }
659 
660 
666  template< typename T >
668  {
669  assert(
671  return
672  (pData->length
675  pData->buffer, pData->length,
677  literal))
678  == 0);
679  }
680 
696  bool match( const OUString & str, sal_Int32 fromIndex = 0 ) const
697  {
698  return rtl_ustr_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
699  str.pData->buffer, str.pData->length, str.pData->length ) == 0;
700  }
701 
707  template< typename T >
708  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
709  {
710  assert(
712  return
714  pData->buffer+fromIndex, pData->length-fromIndex,
716  literal),
718  == 0;
719  }
720 
739  bool matchIgnoreAsciiCase( const OUString & str, sal_Int32 fromIndex = 0 ) const
740  {
741  return rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
742  str.pData->buffer, str.pData->length,
743  str.pData->length ) == 0;
744  }
745 
751  template< typename T >
752  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
753  {
754  assert(
756  return
758  pData->buffer+fromIndex, pData->length-fromIndex,
760  literal),
762  == 0;
763  }
764 
781  sal_Int32 compareToAscii( const sal_Char* asciiStr ) const
782  {
783  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length, asciiStr );
784  }
785 
809  "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
810  sal_Int32 compareToAscii( const sal_Char * asciiStr, sal_Int32 maxLength ) const
811  {
812  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer, pData->length,
813  asciiStr, maxLength );
814  }
815 
835  sal_Int32 reverseCompareToAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
836  {
837  return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
838  asciiStr, asciiStrLength );
839  }
840 
856  bool equalsAscii( const sal_Char* asciiStr ) const
857  {
858  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length,
859  asciiStr ) == 0;
860  }
861 
879  bool equalsAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength ) const
880  {
881  if ( pData->length != asciiStrLength )
882  return false;
883 
885  pData->buffer, asciiStr, asciiStrLength );
886  }
887 
906  bool equalsIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const
907  {
908  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
909  }
910 
929  sal_Int32 compareToIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const
930  {
931  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr );
932  }
933 
954  bool equalsIgnoreAsciiCaseAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
955  {
956  if ( pData->length != asciiStrLength )
957  return false;
958 
959  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
960  }
961 
983  bool matchAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
984  {
985  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
986  asciiStr, asciiStrLength ) == 0;
987  }
988 
989  // This overload is left undefined, to detect calls of matchAsciiL that
990  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
991  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
992  // platforms):
993 #if SAL_TYPES_SIZEOFLONG == 8
994  void matchAsciiL(char const *, sal_Int32, rtl_TextEncoding) const;
995 #endif
996 
1021  bool matchIgnoreAsciiCaseAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
1022  {
1023  return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1024  asciiStr, asciiStrLength ) == 0;
1025  }
1026 
1027  // This overload is left undefined, to detect calls of
1028  // matchIgnoreAsciiCaseAsciiL that erroneously use
1029  // RTL_CONSTASCII_USTRINGPARAM instead of RTL_CONSTASCII_STRINGPARAM (but
1030  // would lead to ambiguities on 32 bit platforms):
1031 #if SAL_TYPES_SIZEOFLONG == 8
1032  void matchIgnoreAsciiCaseAsciiL(char const *, sal_Int32, rtl_TextEncoding)
1033  const;
1034 #endif
1035 
1050  bool startsWith(OUString const & str, OUString * rest = 0) const {
1051  bool b = match(str);
1052  if (b && rest != 0) {
1053  *rest = copy(str.getLength());
1054  }
1055  return b;
1056  }
1057 
1063  template< typename T >
1065  T & literal, OUString * rest = 0) const
1066  {
1067  assert(
1069  bool b
1071  <= sal_uInt32(pData->length))
1073  pData->buffer,
1075  literal),
1077  if (b && rest != 0) {
1078  *rest = copy(
1080  }
1081  return b;
1082  }
1083 
1104  bool startsWithIgnoreAsciiCase(OUString const & str, OUString * rest = 0)
1105  const
1106  {
1107  bool b = matchIgnoreAsciiCase(str);
1108  if (b && rest != 0) {
1109  *rest = copy(str.getLength());
1110  }
1111  return b;
1112  }
1113 
1119  template< typename T >
1121  startsWithIgnoreAsciiCase(T & literal, OUString * rest = 0) const
1122  {
1123  assert(
1125  bool b
1127  pData->buffer,
1130  literal),
1132  == 0);
1133  if (b && rest != 0) {
1134  *rest = copy(
1136  }
1137  return b;
1138  }
1139 
1154  bool endsWith(OUString const & str, OUString * rest = 0) const {
1155  bool b = str.getLength() <= getLength()
1156  && match(str, getLength() - str.getLength());
1157  if (b && rest != 0) {
1158  *rest = copy(0, getLength() - str.getLength());
1159  }
1160  return b;
1161  }
1162 
1168  template< typename T >
1170  endsWith(T & literal, OUString * rest = 0) const
1171  {
1172  assert(
1174  bool b
1176  <= sal_uInt32(pData->length))
1178  (pData->buffer + pData->length
1181  literal),
1183  if (b && rest != 0) {
1184  *rest = copy(
1185  0,
1186  (getLength()
1188  }
1189  return b;
1190  }
1191 
1203  inline bool endsWithAsciiL(char const * asciiStr, sal_Int32 asciiStrLength)
1204  const
1205  {
1206  return asciiStrLength <= pData->length
1208  pData->buffer + pData->length - asciiStrLength, asciiStr,
1209  asciiStrLength);
1210  }
1211 
1232  bool endsWithIgnoreAsciiCase(OUString const & str, OUString * rest = 0) const
1233  {
1234  bool b = str.getLength() <= getLength()
1235  && matchIgnoreAsciiCase(str, getLength() - str.getLength());
1236  if (b && rest != 0) {
1237  *rest = copy(0, getLength() - str.getLength());
1238  }
1239  return b;
1240  }
1241 
1247  template< typename T >
1249  endsWithIgnoreAsciiCase(T & literal, OUString * rest = 0) const
1250  {
1251  assert(
1253  bool b
1255  <= sal_uInt32(pData->length))
1257  (pData->buffer + pData->length
1261  literal),
1263  == 0);
1264  if (b && rest != 0) {
1265  *rest = copy(
1266  0,
1267  (getLength()
1269  }
1270  return b;
1271  }
1272 
1284  char const * asciiStr, sal_Int32 asciiStrLength) const
1285  {
1286  return asciiStrLength <= pData->length
1288  pData->buffer + pData->length - asciiStrLength,
1289  asciiStrLength, asciiStr, asciiStrLength)
1290  == 0);
1291  }
1292 
1293  friend bool operator == ( const OUString& rStr1, const OUString& rStr2 )
1294  { return rStr1.equals(rStr2); }
1295  friend bool operator == ( const OUString& rStr1, const sal_Unicode * pStr2 )
1296  { return rStr1.compareTo( pStr2 ) == 0; }
1297  friend bool operator == ( const sal_Unicode * pStr1, const OUString& rStr2 )
1298  { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
1299 
1300  friend bool operator != ( const OUString& rStr1, const OUString& rStr2 )
1301  { return !(operator == ( rStr1, rStr2 )); }
1302  friend bool operator != ( const OUString& rStr1, const sal_Unicode * pStr2 )
1303  { return !(operator == ( rStr1, pStr2 )); }
1304  friend bool operator != ( const sal_Unicode * pStr1, const OUString& rStr2 )
1305  { return !(operator == ( pStr1, rStr2 )); }
1306 
1307  friend bool operator < ( const OUString& rStr1, const OUString& rStr2 )
1308  { return rStr1.compareTo( rStr2 ) < 0; }
1309  friend bool operator > ( const OUString& rStr1, const OUString& rStr2 )
1310  { return rStr1.compareTo( rStr2 ) > 0; }
1311  friend bool operator <= ( const OUString& rStr1, const OUString& rStr2 )
1312  { return rStr1.compareTo( rStr2 ) <= 0; }
1313  friend bool operator >= ( const OUString& rStr1, const OUString& rStr2 )
1314  { return rStr1.compareTo( rStr2 ) >= 0; }
1315 
1323  template< typename T >
1324  friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==( const OUString& string, T& literal )
1325  {
1326  assert(
1328  return string.equalsAsciiL(
1331  }
1339  template< typename T >
1340  friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==( T& literal, const OUString& string )
1341  {
1342  assert(
1344  return string.equalsAsciiL(
1347  }
1355  template< typename T >
1356  friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=( const OUString& string, T& literal )
1357  {
1358  assert(
1360  return !string.equalsAsciiL(
1363  }
1371  template< typename T >
1372  friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=( T& literal, const OUString& string )
1373  {
1374  assert(
1376  return !string.equalsAsciiL(
1379  }
1380 
1381 #if defined LIBO_INTERNAL_ONLY
1382 
1384  /* Comparison between OUString and OUStringLiteral.
1385 
1386  @since LibreOffice 5.0
1387  */
1388 
1389  friend bool operator ==(OUString const & lhs, OUStringLiteral const & rhs) {
1390  return lhs.equalsAsciiL(rhs.data, rhs.size);
1391  }
1392 
1393  friend bool operator !=(OUString const & lhs, OUStringLiteral const & rhs) {
1394  return !lhs.equalsAsciiL(rhs.data, rhs.size);
1395  }
1396 
1397  friend bool operator <(OUString const & lhs, OUStringLiteral const & rhs) {
1398  return
1400  lhs.pData->buffer, lhs.pData->length, rhs.data))
1401  < 0;
1402  }
1403 
1404  friend bool operator <=(OUString const & lhs, OUStringLiteral const & rhs) {
1405  return
1407  lhs.pData->buffer, lhs.pData->length, rhs.data))
1408  <= 0;
1409  }
1410 
1411  friend bool operator >(OUString const & lhs, OUStringLiteral const & rhs) {
1412  return
1414  lhs.pData->buffer, lhs.pData->length, rhs.data))
1415  > 0;
1416  }
1417 
1418  friend bool operator >=(OUString const & lhs, OUStringLiteral const & rhs) {
1419  return
1421  lhs.pData->buffer, lhs.pData->length, rhs.data))
1422  >= 0;
1423  }
1424 
1425  friend bool operator ==(OUStringLiteral const & lhs, OUString const & rhs) {
1426  return rhs.equalsAsciiL(lhs.data, lhs.size);
1427  }
1428 
1429  friend bool operator !=(OUStringLiteral const & lhs, OUString const & rhs) {
1430  return !rhs.equalsAsciiL(lhs.data, lhs.size);
1431  }
1432 
1433  friend bool operator <(OUStringLiteral const & lhs, OUString const & rhs) {
1434  return
1436  rhs.pData->buffer, rhs.pData->length, lhs.data))
1437  >= 0;
1438  }
1439 
1440  friend bool operator <=(OUStringLiteral const & lhs, OUString const & rhs) {
1441  return
1443  rhs.pData->buffer, rhs.pData->length, lhs.data))
1444  > 0;
1445  }
1446 
1447  friend bool operator >(OUStringLiteral const & lhs, OUString const & rhs) {
1448  return
1450  rhs.pData->buffer, rhs.pData->length, lhs.data))
1451  <= 0;
1452  }
1453 
1454  friend bool operator >=(OUStringLiteral const & lhs, OUString const & rhs) {
1455  return
1457  rhs.pData->buffer, rhs.pData->length, lhs.data))
1458  < 0;
1459  }
1460 
1462 #endif
1463 
1471  sal_Int32 hashCode() const
1472  {
1473  return rtl_ustr_hashCode_WithLength( pData->buffer, pData->length );
1474  }
1475 
1489  sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
1490  {
1491  sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1492  return (ret < 0 ? ret : ret+fromIndex);
1493  }
1494 
1504  sal_Int32 lastIndexOf( sal_Unicode ch ) const
1505  {
1506  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1507  }
1508 
1521  sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
1522  {
1523  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1524  }
1525 
1541  sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
1542  {
1543  sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1544  str.pData->buffer, str.pData->length );
1545  return (ret < 0 ? ret : ret+fromIndex);
1546  }
1547 
1553  template< typename T >
1554  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1555  {
1556  assert(
1558  sal_Int32 n = rtl_ustr_indexOfAscii_WithLength(
1559  pData->buffer + fromIndex, pData->length - fromIndex,
1562  return n < 0 ? n : n + fromIndex;
1563  }
1564 
1588  sal_Int32 indexOfAsciiL(
1589  char const * str, sal_Int32 len, sal_Int32 fromIndex = 0) const
1590  {
1591  sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
1592  pData->buffer + fromIndex, pData->length - fromIndex, str, len);
1593  return ret < 0 ? ret : ret + fromIndex;
1594  }
1595 
1596  // This overload is left undefined, to detect calls of indexOfAsciiL that
1597  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1598  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1599  // platforms):
1600 #if SAL_TYPES_SIZEOFLONG == 8
1601  void indexOfAsciiL(char const *, sal_Int32 len, rtl_TextEncoding) const;
1602 #endif
1603 
1619  sal_Int32 lastIndexOf( const OUString & str ) const
1620  {
1621  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1622  str.pData->buffer, str.pData->length );
1623  }
1624 
1642  sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
1643  {
1644  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1645  str.pData->buffer, str.pData->length );
1646  }
1647 
1653  template< typename T >
1655  {
1656  assert(
1659  pData->buffer, pData->length,
1662  }
1663 
1683  sal_Int32 lastIndexOfAsciiL(char const * str, sal_Int32 len) const
1684  {
1686  pData->buffer, pData->length, str, len);
1687  }
1688 
1699  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex ) const
1700  {
1701  rtl_uString *pNew = 0;
1702  rtl_uString_newFromSubString( &pNew, pData, beginIndex, getLength() - beginIndex );
1703  return OUString( pNew, SAL_NO_ACQUIRE );
1704  }
1705 
1718  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const
1719  {
1720  rtl_uString *pNew = 0;
1721  rtl_uString_newFromSubString( &pNew, pData, beginIndex, count );
1722  return OUString( pNew, SAL_NO_ACQUIRE );
1723  }
1724 
1734  {
1735  rtl_uString* pNew = 0;
1736  rtl_uString_newConcat( &pNew, pData, str.pData );
1737  return OUString( pNew, SAL_NO_ACQUIRE );
1738  }
1739 
1740 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1741  friend OUString operator+( const OUString& rStr1, const OUString& rStr2 )
1742  {
1743  return rStr1.concat( rStr2 );
1744  }
1745 #endif
1746 
1760  SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const
1761  {
1762  rtl_uString* pNew = 0;
1763  rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
1764  return OUString( pNew, SAL_NO_ACQUIRE );
1765  }
1766 
1781  {
1782  rtl_uString* pNew = 0;
1783  rtl_uString_newReplace( &pNew, pData, oldChar, newChar );
1784  return OUString( pNew, SAL_NO_ACQUIRE );
1785  }
1786 
1806  OUString const & from, OUString const & to, sal_Int32 * index = 0) const
1807  {
1808  rtl_uString * s = 0;
1809  sal_Int32 i = 0;
1811  &s, pData, from.pData, to.pData, index == 0 ? &i : index);
1812  return OUString(s, SAL_NO_ACQUIRE);
1813  }
1814 
1833  template< typename T >
1835  sal_Int32 * index = 0) const
1836  {
1838  rtl_uString * s = 0;
1839  sal_Int32 i = 0;
1841  &s, pData,
1844  index == 0 ? &i : index);
1845  return OUString(s, SAL_NO_ACQUIRE);
1846  }
1847 
1866  template< typename T >
1868  sal_Int32 * index = 0) const
1869  {
1871  rtl_uString * s = 0;
1872  sal_Int32 i = 0;
1874  &s, pData, from.pData,
1877  index == 0 ? &i : index);
1878  return OUString(s, SAL_NO_ACQUIRE);
1879  }
1880 
1899  template< typename T1, typename T2 >
1901  replaceFirst( T1& from, T2& to, sal_Int32 * index = 0) const
1902  {
1905  rtl_uString * s = 0;
1906  sal_Int32 i = 0;
1908  &s, pData,
1913  index == 0 ? &i : index);
1914  return OUString(s, SAL_NO_ACQUIRE);
1915  }
1916 
1933  OUString const & from, OUString const & to, sal_Int32 fromIndex = 0) const
1934  {
1935  rtl_uString * s = 0;
1936  rtl_uString_newReplaceAllFromIndex(&s, pData, from.pData, to.pData, fromIndex);
1937  return OUString(s, SAL_NO_ACQUIRE);
1938  }
1939 
1953  template< typename T >
1955  {
1957  rtl_uString * s = 0;
1959  &s, pData,
1962  return OUString(s, SAL_NO_ACQUIRE);
1963  }
1964 
1978  template< typename T >
1980  {
1982  rtl_uString * s = 0;
1984  &s, pData, from.pData,
1987  return OUString(s, SAL_NO_ACQUIRE);
1988  }
1989 
2003  template< typename T1, typename T2 >
2005  replaceAll( T1& from, T2& to ) const
2006  {
2009  rtl_uString * s = 0;
2011  &s, pData,
2016  return OUString(s, SAL_NO_ACQUIRE);
2017  }
2018 
2030  {
2031  rtl_uString* pNew = 0;
2032  rtl_uString_newToAsciiLowerCase( &pNew, pData );
2033  return OUString( pNew, SAL_NO_ACQUIRE );
2034  }
2035 
2047  {
2048  rtl_uString* pNew = 0;
2049  rtl_uString_newToAsciiUpperCase( &pNew, pData );
2050  return OUString( pNew, SAL_NO_ACQUIRE );
2051  }
2052 
2065  {
2066  rtl_uString* pNew = 0;
2067  rtl_uString_newTrim( &pNew, pData );
2068  return OUString( pNew, SAL_NO_ACQUIRE );
2069  }
2070 
2095  OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const
2096  {
2097  rtl_uString * pNew = 0;
2098  index = rtl_uString_getToken( &pNew, pData, token, cTok, index );
2099  return OUString( pNew, SAL_NO_ACQUIRE );
2100  }
2101 
2115  OUString getToken(sal_Int32 count, sal_Unicode separator) const {
2116  sal_Int32 n = 0;
2117  return getToken(count, separator, n);
2118  }
2119 
2128  bool toBoolean() const
2129  {
2130  return rtl_ustr_toBoolean( pData->buffer );
2131  }
2132 
2140  {
2141  return pData->buffer[0];
2142  }
2143 
2154  sal_Int32 toInt32( sal_Int16 radix = 10 ) const
2155  {
2156  return rtl_ustr_toInt32( pData->buffer, radix );
2157  }
2158 
2171  sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
2172  {
2173  return rtl_ustr_toUInt32( pData->buffer, radix );
2174  }
2175 
2186  sal_Int64 toInt64( sal_Int16 radix = 10 ) const
2187  {
2188  return rtl_ustr_toInt64( pData->buffer, radix );
2189  }
2190 
2203  sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
2204  {
2205  return rtl_ustr_toUInt64( pData->buffer, radix );
2206  }
2207 
2216  float toFloat() const
2217  {
2218  return rtl_ustr_toFloat( pData->buffer );
2219  }
2220 
2229  double toDouble() const
2230  {
2231  return rtl_ustr_toDouble( pData->buffer );
2232  }
2233 
2234 
2251  {
2252  rtl_uString * pNew = 0;
2253  rtl_uString_intern( &pNew, pData );
2254  if (pNew == 0) {
2255  throw std::bad_alloc();
2256  }
2257  return OUString( pNew, SAL_NO_ACQUIRE );
2258  }
2259 
2285  static OUString intern( const sal_Char * value, sal_Int32 length,
2286  rtl_TextEncoding encoding,
2287  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS,
2288  sal_uInt32 *pInfo = NULL )
2289  {
2290  rtl_uString * pNew = 0;
2291  rtl_uString_internConvert( &pNew, value, length, encoding,
2292  convertFlags, pInfo );
2293  if (pNew == 0) {
2294  throw std::bad_alloc();
2295  }
2296  return OUString( pNew, SAL_NO_ACQUIRE );
2297  }
2298 
2323  inline bool convertToString(OString * pTarget, rtl_TextEncoding nEncoding,
2324  sal_uInt32 nFlags) const
2325  {
2326  return rtl_convertUStringToString(&pTarget->pData, pData->buffer,
2327  pData->length, nEncoding, nFlags);
2328  }
2329 
2381  inline sal_uInt32 iterateCodePoints(
2382  sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1) const
2383  {
2385  pData, indexUtf16, incrementCodePoints);
2386  }
2387 
2397  static inline OUString fromUtf8(const OString& rSource)
2398  {
2399  OUString aTarget;
2400  bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
2401  rSource.getStr(),
2402  rSource.getLength(),
2405  (void) bSuccess;
2406  assert(bSuccess);
2407  return aTarget;
2408  }
2409 
2420  inline OString toUtf8() const
2421  {
2422  OString aTarget;
2423  bool bSuccess = rtl_convertUStringToString(&aTarget.pData,
2424  getStr(),
2425  getLength(),
2428  (void) bSuccess;
2429  assert(bSuccess);
2430  return aTarget;
2431  }
2432 
2443  static OUString number( int i, sal_Int16 radix = 10 )
2444  {
2446  rtl_uString* pNewData = 0;
2447  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt32( aBuf, i, radix ) );
2448  return OUString( pNewData, SAL_NO_ACQUIRE );
2449  }
2452  static OUString number( unsigned int i, sal_Int16 radix = 10 )
2453  {
2454  return number( static_cast< unsigned long long >( i ), radix );
2455  }
2458  static OUString number( long i, sal_Int16 radix = 10)
2459  {
2460  return number( static_cast< long long >( i ), radix );
2461  }
2464  static OUString number( unsigned long i, sal_Int16 radix = 10 )
2465  {
2466  return number( static_cast< unsigned long long >( i ), radix );
2467  }
2470  static OUString number( long long ll, sal_Int16 radix = 10 )
2471  {
2473  rtl_uString* pNewData = 0;
2474  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt64( aBuf, ll, radix ) );
2475  return OUString( pNewData, SAL_NO_ACQUIRE );
2476  }
2479  static OUString number( unsigned long long ll, sal_Int16 radix = 10 )
2480  {
2482  rtl_uString* pNewData = 0;
2483  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfUInt64( aBuf, ll, radix ) );
2484  return OUString( pNewData, SAL_NO_ACQUIRE );
2485  }
2486 
2496  static OUString number( float f )
2497  {
2499  rtl_uString* pNewData = 0;
2500  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfFloat( aBuf, f ) );
2501  return OUString( pNewData, SAL_NO_ACQUIRE );
2502  }
2503 
2513  static OUString number( double d )
2514  {
2516  rtl_uString* pNewData = 0;
2517  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfDouble( aBuf, d ) );
2518  return OUString( pNewData, SAL_NO_ACQUIRE );
2519  }
2520 
2532  SAL_DEPRECATED("use boolean()") static OUString valueOf( sal_Bool b )
2533  {
2534  return boolean(b);
2535  }
2536 
2548  static OUString boolean( bool b )
2549  {
2551  rtl_uString* pNewData = 0;
2552  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfBoolean( aBuf, b ) );
2553  return OUString( pNewData, SAL_NO_ACQUIRE );
2554  }
2555 
2563  SAL_DEPRECATED("convert to OUString or use directly") static OUString valueOf( sal_Unicode c )
2564  {
2565  return OUString( &c, 1 );
2566  }
2567 
2578  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
2579  {
2580  return number( i, radix );
2581  }
2582 
2593  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
2594  {
2595  return number( ll, radix );
2596  }
2597 
2607  SAL_DEPRECATED("use number()") static OUString valueOf( float f )
2608  {
2609  return number(f);
2610  }
2611 
2621  SAL_DEPRECATED("use number()") static OUString valueOf( double d )
2622  {
2623  return number(d);
2624  }
2625 
2641  static OUString createFromAscii( const sal_Char * value )
2642  {
2643  rtl_uString* pNew = 0;
2644  rtl_uString_newFromAscii( &pNew, value );
2645  return OUString( pNew, SAL_NO_ACQUIRE );
2646  }
2647 };
2648 
2649 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2650 
2655 template<>
2656 struct ToStringHelper< OUString >
2657  {
2658  static int length( const OUString& s ) { return s.getLength(); }
2659  static sal_Unicode* addData( sal_Unicode* buffer, const OUString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
2660  static const bool allowOStringConcat = false;
2661  static const bool allowOUStringConcat = true;
2662  };
2663 
2667 template<>
2668 struct ToStringHelper< OUStringLiteral >
2669  {
2670  static int length( const OUStringLiteral& str ) { return str.size; }
2671  static sal_Unicode* addData( sal_Unicode* buffer, const OUStringLiteral& str ) { return addDataLiteral( buffer, str.data, str.size ); }
2672  static const bool allowOStringConcat = false;
2673  static const bool allowOUStringConcat = true;
2674  };
2675 
2679 template< typename charT, typename traits, typename T1, typename T2 >
2680 inline std::basic_ostream<charT, traits> & operator <<(
2681  std::basic_ostream<charT, traits> & stream, const OUStringConcat< T1, T2 >& concat)
2682 {
2683  return stream << OUString( concat );
2684 }
2685 
2687 #endif
2688 
2695 {
2705  size_t operator()(const OUString& rString) const
2706  { return (size_t)rString.hashCode(); }
2707 };
2708 
2709 /* ======================================================================= */
2710 
2728 inline OUString OStringToOUString( const OString & rStr,
2729  rtl_TextEncoding encoding,
2730  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
2731 {
2732  return OUString( rStr.getStr(), rStr.getLength(), encoding, convertFlags );
2733 }
2734 
2752 inline OString OUStringToOString( const OUString & rUnicode,
2753  rtl_TextEncoding encoding,
2754  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
2755 {
2756  return OString( rUnicode.getStr(), rUnicode.getLength(), encoding, convertFlags );
2757 }
2758 
2759 /* ======================================================================= */
2760 
2769 template< typename charT, typename traits >
2770 inline std::basic_ostream<charT, traits> & operator <<(
2771  std::basic_ostream<charT, traits> & stream, OUString const & string)
2772 {
2773  return stream <<
2775  // best effort; potentially loses data due to conversion failures
2776  // (stray surrogate halves) and embedded null characters
2777 }
2778 
2779 } // namespace
2780 
2781 #ifdef RTL_STRING_UNITTEST
2782 namespace rtl
2783 {
2784 typedef rtlunittest::OUString OUString;
2785 }
2786 #endif
2787 
2788 // In internal code, allow to use classes like OUString without having to
2789 // explicitly refer to the rtl namespace, which is kind of superfluous given
2790 // that OUString itself is namespaced by its OU prefix:
2791 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
2792 using ::rtl::OUString;
2793 using ::rtl::OUStringHash;
2796 using ::rtl::OUStringLiteral;
2797 using ::rtl::OUStringLiteral1;
2798 #endif
2799 
2800 #endif /* _RTL_USTRING_HXX */
2801 
2802 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define RTL_STR_MAX_VALUEOFUINT64
Definition: string.h:673
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.
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:116
OUString getToken(sal_Int32 token, sal_Unicode cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: ustring.hxx:2095
SAL_DLLPUBLIC void rtl_uString_newConcatAsciiL(rtl_uString **newString, rtl_uString *left, char const *right, sal_Int32 rightLength)
Create a new string that is the concatenation of two other strings.
SAL_DLLPUBLIC sal_Int64 rtl_ustr_toInt64(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as a long integer.
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.
OUString(const sal_Unicode *value)
New string from a Unicode character buffer array.
Definition: ustring.hxx:180
#define RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR
Definition: textcvt.h:134
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...
OUString(const OUString &str)
New string from OUString.
Definition: ustring.hxx:125
bool equals(const OUString &str) const
Perform a comparison of two strings.
Definition: ustring.hxx:605
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.
SAL_DLLPUBLIC void rtl_uString_new(rtl_uString **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
static OUString number(float f)
Returns the string representation of the float argument.
Definition: ustring.hxx:2496
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:1642
float toFloat() const
Returns the float value from this string.
Definition: ustring.hxx:2216
SAL_DLLPUBLIC void rtl_uString_assign(rtl_uString **str, rtl_uString *rightValue) SAL_THROW_EXTERN_C()
Assign a new value to a string.
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:1504
bool convertToString(OString *pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) const
Converts to an OString, signalling failure.
Definition: ustring.hxx:2323
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:583
OUString & operator+=(const OUString &str)
Append a string to this string.
Definition: ustring.hxx:421
SAL_DLLPUBLIC void rtl_uString_release(rtl_uString *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
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:1541
#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
Definition: textcvt.h:68
SAL_DLLPUBLIC void rtl_uString_newReplaceAllAsciiL(rtl_uString **newStr, rtl_uString *str, char const *from, sal_Int32 fromLength, rtl_uString const *to) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a given substring with another substring...
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T, OUString >::Type replaceFirst(OUString const &from, T &to, sal_Int32 *index=0) const
Returns a new string resulting from replacing the first occurrence of a given substring with another ...
Definition: ustring.hxx:1867
SAL_DLLPUBLIC void rtl_uString_intern(rtl_uString **newStr, rtl_uString *str) SAL_THROW_EXTERN_C()
Return a canonical representation for a string.
#define OSTRING_TO_OUSTRING_CVTFLAGS
Definition: ustring.h:1894
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:1760
bool match(const OUString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:696
#define RTL_USTR_MAX_VALUEOFINT32
Definition: ustring.h:957
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 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_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:1619
sal_Int32 reverseCompareToAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Compares two strings in reverse order.
Definition: ustring.hxx:835
SAL_DLLPUBLIC void rtl_uString_newReplaceFirst(rtl_uString **newStr, rtl_uString *str, rtl_uString const *from, rtl_uString const *to, sal_Int32 *index) SAL_THROW_EXTERN_C()
Create a new string by replacing the first occurrence of a given substring with another substring...
SAL_DLLPUBLIC void rtl_uString_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...
OUString(rtl_uString *str, __sal_NoAcquire)
New OUString from OUString data without acquiring it.
Definition: ustring.hxx:150
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:608
SAL_DLLPUBLIC sal_Int32 rtl_ustr_valueOfFloat(sal_Unicode *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
SAL_DLLPUBLIC 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.
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:1283
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.
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OUString &string, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1356
SAL_DLLPUBLIC sal_Int32 rtl_ustr_shortenedCompare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters.
SAL_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:2046
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.
char sal_Char
A legacy synonym for char.
Definition: types.h:130
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.
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:1554
Definition: stringutils.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:2064
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:89
sal_Int32 compareToIgnoreAsciiCase(const OUString &str) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:654
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_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:64
sal_Int32 compareToAscii(const sal_Char *asciiStr) const
Compares two strings.
Definition: ustring.hxx:781
bool equalsIgnoreAsciiCaseAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:954
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:1780
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:2381
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:106
unsigned char sal_Bool
Definition: types.h:48
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:2285
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: ustring.hxx:2186
sal_Int32 compareToIgnoreAsciiCaseAscii(const sal_Char *asciiStr) const
Compares two ASCII strings ignoring case.
Definition: ustring.hxx:929
bool equalsAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform a comparison of two strings.
Definition: ustring.hxx:879
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:2005
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_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_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 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.
double toDouble() const
Returns the double value from this string.
Definition: ustring.hxx:2229
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...
size_t operator()(const OUString &rString) const
Compute a hash code for a string.
Definition: ustring.hxx:2705
~OUString()
Release the string data.
Definition: ustring.hxx:357
static OUString number(double d)
Returns the string representation of the double argument.
Definition: ustring.hxx:2513
SAL_DLLPUBLIC sal_Int32 rtl_ustr_toInt32(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an integer.
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:584
OString toUtf8() const
Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully.
Definition: ustring.hxx:2420
SAL_DLLPUBLIC void rtl_string2UString(rtl_uString **newStr, const sal_Char *str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags) SAL_THROW_EXTERN_C()
Create a new Unicode string by converting a byte string, using a specific text encoding.
bool equalsIgnoreAsciiCase(const OUString &str) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:629
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.
OUString intern() const
Return a canonical representation for a string.
Definition: ustring.hxx:2250
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type endsWithIgnoreAsciiCase(T &literal, OUString *rest=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1249
const sal_Char * getStr() const
Returns a pointer to the characters of this string.
Definition: string.hxx:380
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:297
#define RTL_USTR_MAX_VALUEOFFLOAT
Definition: ustring.h:1022
OUString(const sal_Unicode *value, sal_Int32 length)
New string from a Unicode character buffer array.
Definition: ustring.hxx:194
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:2470
static OUString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: ustring.hxx:2443
SAL_DLLPUBLIC void rtl_uString_acquire(rtl_uString *str) SAL_THROW_EXTERN_C()
Increment the reference count of a string.
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:400
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T1, typename libreoffice_internal::ConstCharArrayDetector< T2, OUString >::Type >::Type replaceFirst(T1 &from, T2 &to, sal_Int32 *index=0) const
Returns a new string resulting from replacing the first occurrence of a given substring with another ...
Definition: ustring.hxx:1901
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(const OUString &string, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1324
#define RTL_USTR_MAX_VALUEOFBOOLEAN
Definition: ustring.h:915
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.
SAL_DLLPUBLIC sal_Bool rtl_ustr_toBoolean(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1324
static OUString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: ustring.hxx:2548
OUString(sal_uInt32 const *codePoints, sal_Int32 codePointCount)
Create a new string from an array of Unicode code points.
Definition: ustring.hxx:324
bool endsWithIgnoreAsciiCase(OUString const &str, OUString *rest=0) const
Check whether this string ends with a given string, ignoring the case of ASCII letters.
Definition: ustring.hxx:1232
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:2458
OUString()
New string containing no characters.
Definition: ustring.hxx:114
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:2464
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...
#define SAL_CONSTEXPR
C++11 "constexpr" feature.
Definition: types.h:439
bool equalsAscii(const sal_Char *asciiStr) const
Perform a comparison of two strings.
Definition: ustring.hxx:856
const sal_Unicode * getStr() const
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:504
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: ustring.hxx:469
#define RTL_USTR_MAX_VALUEOFDOUBLE
Definition: ustring.h:1041
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_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:2115
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:1021
OUString & operator=(const OUString &str)
Assign a new string.
Definition: ustring.hxx:381
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:216
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OUString &string)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1340
bool startsWith(OUString const &str, OUString *rest=0) const
Check whether this string starts with a given substring.
Definition: ustring.hxx:1050
bool endsWithAsciiL(char const *asciiStr, sal_Int32 asciiStrLength) const
Check whether this string ends with a given ASCII string.
Definition: ustring.hxx:1203
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...
definition of a no acquire enum for ctors
Definition: types.h:382
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_NoAcquire
Definition: types.h:378
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:1844
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:1932
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.
friend OUString operator+(const OUString &rStr1, const OUString &rStr2)
Definition: ustring.hxx:1741
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:650
static OUString createFromAscii(const sal_Char *value)
Returns a OUString copied without conversion from an ASCII character string.
Definition: ustring.hxx:2641
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.
OUString(sal_Unicode value)
New string from a single Unicode character.
Definition: ustring.hxx:158
SAL_WARN_UNUSED_RESULT libreoffice_internal::ConstCharArrayDetector< T, OUString >::Type replaceFirst(T &from, OUString const &to, sal_Int32 *index=0) const
Returns a new string resulting from replacing the first occurrence of a given substring with another ...
Definition: ustring.hxx:1834
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.
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:2479
sal_uInt16 sal_Unicode
Definition: types.h:152
bool endsWith(OUString const &str, OUString *rest=0) const
Check whether this string ends with a given substring.
Definition: ustring.hxx:1154
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:1521
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:667
bool toBoolean() const
Returns the Boolean value from this string.
Definition: ustring.hxx:2128
SAL_WARN_UNUSED_RESULT OUString replaceFirst(OUString const &from, OUString const &to, sal_Int32 *index=0) const
Returns a new string resulting from replacing the first occurrence of a given substring with another ...
Definition: ustring.hxx:1805
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...
bool equalsIgnoreAsciiCaseAscii(const sal_Char *asciiStr) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:906
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.
static OUString fromUtf8(const OString &rSource)
Convert an OString to an OUString, assuming that the OString is UTF-8-encoded.
Definition: ustring.hxx:2397
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:39
SAL_DLLPUBLIC sal_Int32 rtl_ustr_compareIgnoreAsciiCase_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Unicode *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
SAL_WARN_UNUSED_RESULT OUString concat(const OUString &str) const
Concatenates the specified string to the end of this string.
Definition: ustring.hxx:1733
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:1654
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:983
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:1683
static OUString const & unacquired(rtl_uString *const *ppHandle)
Provides an OUString const & passing a storage pointer of an rtl_uString * handle.
Definition: ustring.hxx:373
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:1718
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OUString &string)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1372
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:2728
sal_Int32 compareTo(const OUString &str, sal_Int32 maxLength) const
Compares two strings with a maximum count of characters.
Definition: ustring.hxx:554
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:1979
SAL_DLLPUBLIC sal_uInt64 rtl_ustr_toUInt64(const sal_Unicode *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned long integer.
SAL_DLLPUBLIC 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_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: ustring.hxx:2171
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Dont use, its evil.") void doit(int nPara);.
Definition: types.h:495
#define RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR
Definition: textcvt.h:71
OUString(rtl_uString *str)
New string from OUString data.
Definition: ustring.hxx:136
SAL_DLLPUBLIC sal_Int32 rtl_ustr_ascii_compare_WithLength(const sal_Unicode *first, sal_Int32 firstLen, const sal_Char *second) SAL_THROW_EXTERN_C()
Compare two strings.
static OUString number(unsigned 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:2452
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...
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:2752
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:1588
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWithIgnoreAsciiCase(T &literal, OUString *rest=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1121
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.
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: ustring.hxx:2154
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:2029
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type endsWith(T &literal, OUString *rest=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1170
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 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 getLength() const
Returns the length of this string.
Definition: ustring.hxx:482
sal_Unicode toChar() const
Returns the first character from this string.
Definition: ustring.hxx:2139
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:1489
A helper to use OUStrings with hash maps.
Definition: ustring.hxx:2694
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.
#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
Definition: textcvt.h:128
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: ustring.hxx:2203
SAL_DLLPUBLIC sal_Int32 rtl_ustr_indexOfStr_WithLength(const sal_Unicode *str, sal_Int32 len, const sal_Unicode *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of a substring within a string.
sal_Int32 reverseCompareTo(const OUString &str) const
Compares two strings in reverse order.
Definition: ustring.hxx:572
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWith(T &literal, OUString *rest=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ustring.hxx:1064
Definition: bootstrap.hxx:24
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.
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:104
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.
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:319
#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.
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:752
SAL_DLLPUBLIC sal_Int32 rtl_ustr_lastIndexOfStr_WithLength(const sal_Unicode *str, sal_Int32 len, const sal_Unicode *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of a substring within a string.
SAL_DLLPUBLIC sal_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...
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:1954
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.
bool isEmpty() const
Checks if a string is empty.
Definition: ustring.hxx:492
sal_Int32 compareTo(const OUString &str) const
Compares two strings.
Definition: ustring.hxx:533
SAL_WARN_UNUSED_RESULT OUString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: ustring.hxx:1699
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:739
SAL_DLLPUBLIC float rtl_ustr_toFloat(const sal_Unicode *str) SAL_THROW_EXTERN_C()
Interpret a string as a float.
bool startsWithIgnoreAsciiCase(OUString const &str, OUString *rest=0) const
Check whether this string starts with a given string, ignoring the case of ASCII letters.
Definition: ustring.hxx:1104
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:354
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:96
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:708
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_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_Int32 hashCode() const
Returns a hashcode for this string.
Definition: ustring.hxx:1471
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.