LibreOffice
LibreOffice 5.0 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ustring.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_RTL_USTRING_HXX
21 #define INCLUDED_RTL_USTRING_HXX
22 
23 #include <sal/config.h>
24 
25 #include <cassert>
26 #include <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 
81 template<char C> struct SAL_WARN_UNUSED OUStringLiteral1 {
82  static_assert(
83  static_cast<unsigned char>(C) < 0x80,
84  "non-ASCII character in OUStringLiteral1");
85 };
86 
88 #endif
89 
90 /* ======================================================================= */
91 
115 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OUString
116 {
117 public:
119  rtl_uString * pData;
121 
126  {
127  pData = 0;
128  rtl_uString_new( &pData );
129  }
130 
136  OUString( const OUString & str )
137  {
138  pData = str.pData;
139  rtl_uString_acquire( pData );
140  }
141 
147  OUString( rtl_uString * str )
148  {
149  pData = str;
150  rtl_uString_acquire( pData );
151  }
152 
161  inline OUString( rtl_uString * str, __sal_NoAcquire )
162  { pData = str; }
163 
169  explicit OUString( sal_Unicode value )
170  : pData (0)
171  {
172  rtl_uString_newFromStr_WithLength( &pData, &value, 1 );
173  }
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( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
219  pData = 0;
221  rtl_uString_new( &pData );
222  else
224 #ifdef RTL_STRING_UNITTEST
225  rtl_string_unittest_const_literal = true;
226 #endif
227  }
228 
229 #ifdef RTL_STRING_UNITTEST
230 
234  template< typename T >
236  {
237  pData = 0;
238  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
239  rtl_string_unittest_invalid_conversion = true;
240  }
245  template< typename T >
246  OUString( const T&, typename libreoffice_internal::ExceptCharArrayDetector< T >::Type = libreoffice_internal::Dummy() )
247  {
248  pData = 0;
249  rtl_uString_newFromLiteral( &pData, "!!br0ken!!", 10, 0 ); // set to garbage
250  rtl_string_unittest_invalid_conversion = true;
251  }
252 #endif
253 
254 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
255 
271  OUString(OUStringLiteral literal): pData(0) {
272  rtl_uString_newFromLiteral(&pData, literal.data, literal.size, 0);
273  }
275 #endif
276 
291  OUString( const sal_Char * value, sal_Int32 length,
292  rtl_TextEncoding encoding,
293  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
294  {
295  pData = 0;
296  rtl_string2UString( &pData, value, length, encoding, convertFlags );
297  if (pData == 0) {
298  throw std::bad_alloc();
299  }
300  }
301 
318  inline explicit OUString(
319  sal_uInt32 const * codePoints, sal_Int32 codePointCount):
320  pData(NULL)
321  {
322  rtl_uString_newFromCodePoints(&pData, codePoints, codePointCount);
323  if (pData == NULL) {
324  throw std::bad_alloc();
325  }
326  }
327 
328 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
329 
333  template< typename T1, typename T2 >
334  OUString( const OUStringConcat< T1, T2 >& c )
335  {
336  const sal_Int32 l = c.length();
337  pData = rtl_uString_alloc( l );
338  if (l != 0)
339  {
340  sal_Unicode* end = c.addData( pData->buffer );
341  pData->length = end - pData->buffer;
342  *end = '\0';
343  // TODO realloc in case pData->length is noticeably smaller than l?
344  }
345  }
346 #endif
347 
352  {
353  rtl_uString_release( pData );
354  }
355 
367  static inline OUString const & unacquired( rtl_uString * const * ppHandle )
368  { return * reinterpret_cast< OUString const * >( ppHandle ); }
369 
375  OUString & operator=( const OUString & str )
376  {
377  rtl_uString_assign( &pData, str.pData );
378  return *this;
379  }
380 
393  template< typename T >
395  {
396  assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
398  rtl_uString_new( &pData );
399  else
401  return *this;
402  }
403 
404 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
405 
410  template<char C> OUString & operator =(OUStringLiteral1<C>) {
411  sal_Unicode const c = C;
412  rtl_uString_newFromStr_WithLength(&pData, &c, 1);
413  return *this;
414  }
416 #endif
417 
423  OUString & operator+=( const OUString & str )
424  {
425  rtl_uString_newConcat( &pData, pData, str.pData );
426  return *this;
427  }
428 
429 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
430 
434  template< typename T1, typename T2 >
435  OUString& operator+=( const OUStringConcat< T1, T2 >& c )
436  {
437  const int l = c.length();
438  if( l == 0 )
439  return *this;
440  rtl_uString_ensureCapacity( &pData, pData->length + l );
441  sal_Unicode* end = c.addData( pData->buffer + pData->length );
442  *end = '\0';
443  pData->length = end - pData->buffer;
444  return *this;
445  }
446 #endif
447 
452  void clear()
453  {
454  rtl_uString_new( &pData );
455  }
456 
465  sal_Int32 getLength() const { return pData->length; }
466 
475  bool isEmpty() const
476  {
477  return pData->length == 0;
478  }
479 
487  const sal_Unicode * getStr() const { return pData->buffer; }
488 
498  sal_Unicode operator [](sal_Int32 index) const {
499  // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
500  assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
501  return getStr()[index];
502  }
503 
516  sal_Int32 compareTo( const OUString & str ) const
517  {
518  return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
519  str.pData->buffer, str.pData->length );
520  }
521 
537  sal_Int32 compareTo( const OUString & str, sal_Int32 maxLength ) const
538  {
539  return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
540  str.pData->buffer, str.pData->length, maxLength );
541  }
542 
555  sal_Int32 reverseCompareTo( const OUString & str ) const
556  {
557  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
558  str.pData->buffer, str.pData->length );
559  }
560 
566  template< typename T >
568  {
569  assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
570  return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
572  }
573 
585  bool equals( const OUString & str ) const
586  {
587  if ( pData->length != str.pData->length )
588  return false;
589  if ( pData == str.pData )
590  return true;
591  return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
592  str.pData->buffer, str.pData->length ) == 0;
593  }
594 
609  bool equalsIgnoreAsciiCase( const OUString & str ) const
610  {
611  if ( pData->length != str.pData->length )
612  return false;
613  if ( pData == str.pData )
614  return true;
615  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
616  str.pData->buffer, str.pData->length ) == 0;
617  }
618 
634  sal_Int32 compareToIgnoreAsciiCase( const OUString & str ) const
635  {
636  return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
637  str.pData->buffer, str.pData->length );
638  }
639 
640 
646  template< typename T >
648  {
649  assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
651  return false;
652 
653  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, literal ) == 0;
654  }
655 
671  bool match( const OUString & str, sal_Int32 fromIndex = 0 ) const
672  {
673  return rtl_ustr_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
674  str.pData->buffer, str.pData->length, str.pData->length ) == 0;
675  }
676 
682  template< typename T >
683  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
684  {
685  assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
686  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
688  }
689 
708  bool matchIgnoreAsciiCase( const OUString & str, sal_Int32 fromIndex = 0 ) const
709  {
710  return rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
711  str.pData->buffer, str.pData->length,
712  str.pData->length ) == 0;
713  }
714 
720  template< typename T >
721  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
722  {
723  assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
724  return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
726  }
727 
744  sal_Int32 compareToAscii( const sal_Char* asciiStr ) const
745  {
746  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length, asciiStr );
747  }
748 
772  "replace s1.compareToAscii(s2, strlen(s2)) == 0 with s1.startsWith(s2)")
773  sal_Int32 compareToAscii( const sal_Char * asciiStr, sal_Int32 maxLength ) const
774  {
775  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer, pData->length,
776  asciiStr, maxLength );
777  }
778 
798  sal_Int32 reverseCompareToAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
799  {
800  return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
801  asciiStr, asciiStrLength );
802  }
803 
819  bool equalsAscii( const sal_Char* asciiStr ) const
820  {
821  return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length,
822  asciiStr ) == 0;
823  }
824 
842  bool equalsAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength ) const
843  {
844  if ( pData->length != asciiStrLength )
845  return false;
846 
848  pData->buffer, asciiStr, asciiStrLength );
849  }
850 
869  bool equalsIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const
870  {
871  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
872  }
873 
892  sal_Int32 compareToIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const
893  {
894  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr );
895  }
896 
917  bool equalsIgnoreAsciiCaseAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
918  {
919  if ( pData->length != asciiStrLength )
920  return false;
921 
922  return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
923  }
924 
946  bool matchAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
947  {
948  return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
949  asciiStr, asciiStrLength ) == 0;
950  }
951 
952  // This overload is left undefined, to detect calls of matchAsciiL that
953  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
954  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
955  // platforms):
956 #if SAL_TYPES_SIZEOFLONG == 8
957  void matchAsciiL(char const *, sal_Int32, rtl_TextEncoding) const;
958 #endif
959 
984  bool matchIgnoreAsciiCaseAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const
985  {
986  return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
987  asciiStr, asciiStrLength ) == 0;
988  }
989 
990  // This overload is left undefined, to detect calls of
991  // matchIgnoreAsciiCaseAsciiL that erroneously use
992  // RTL_CONSTASCII_USTRINGPARAM instead of RTL_CONSTASCII_STRINGPARAM (but
993  // would lead to ambiguities on 32 bit platforms):
994 #if SAL_TYPES_SIZEOFLONG == 8
995  void matchIgnoreAsciiCaseAsciiL(char const *, sal_Int32, rtl_TextEncoding)
996  const;
997 #endif
998 
1013  bool startsWith(OUString const & str, OUString * rest = 0) const {
1014  bool b = match(str, 0);
1015  if (b && rest != 0) {
1016  *rest = copy(str.getLength());
1017  }
1018  return b;
1019  }
1020 
1026  template< typename T >
1028  T & literal, OUString * rest = 0) const
1029  {
1030  assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
1032  && rtl_ustr_asciil_reverseEquals_WithLength( pData->buffer, literal,
1034  if (b && rest != 0) {
1036  }
1037  return b;
1038  }
1039 
1060  bool startsWithIgnoreAsciiCase(OUString const & str, OUString * rest = 0)
1061  const
1062  {
1063  bool b = matchIgnoreAsciiCase(str, 0);
1064  if (b && rest != 0) {
1065  *rest = copy(str.getLength());
1066  }
1067  return b;
1068  }
1069 
1075  template< typename T >
1077  startsWithIgnoreAsciiCase(T & literal, OUString * rest = 0) const
1078  {
1079  assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
1081  pData->buffer,
1084  == 0);
1085  if (b && rest != 0) {
1087  }
1088  return b;
1089  }
1090 
1105  bool endsWith(OUString const & str, OUString * rest = 0) const {
1106  bool b = str.getLength() <= getLength()
1107  && match(str, getLength() - str.getLength());
1108  if (b && rest != 0) {
1109  *rest = copy(0, getLength() - str.getLength());
1110  }
1111  return b;
1112  }
1113 
1119  template< typename T >
1121  endsWith(T & literal, OUString * rest = 0) const
1122  {
1123  assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
1126  pData->buffer + pData->length - ( libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 ), literal,
1128  if (b && rest != 0) {
1129  *rest = copy(
1130  0,
1131  (getLength()
1133  }
1134  return b;
1135  }
1136 
1148  inline bool endsWithAsciiL(char const * asciiStr, sal_Int32 asciiStrLength)
1149  const
1150  {
1151  return asciiStrLength <= pData->length
1153  pData->buffer + pData->length - asciiStrLength, asciiStr,
1154  asciiStrLength);
1155  }
1156 
1177  bool endsWithIgnoreAsciiCase(OUString const & str, OUString * rest = 0) const
1178  {
1179  bool b = str.getLength() <= getLength()
1180  && matchIgnoreAsciiCase(str, getLength() - str.getLength());
1181  if (b && rest != 0) {
1182  *rest = copy(0, getLength() - str.getLength());
1183  }
1184  return b;
1185  }
1186 
1192  template< typename T >
1194  endsWithIgnoreAsciiCase(T & literal, OUString * rest = 0) const
1195  {
1196  assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
1199  pData->buffer + pData->length - ( libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 ),
1202  == 0);
1203  if (b && rest != 0) {
1204  *rest = copy(
1205  0,
1206  (getLength()
1208  }
1209  return b;
1210  }
1211 
1223  char const * asciiStr, sal_Int32 asciiStrLength) const
1224  {
1225  return asciiStrLength <= pData->length
1227  pData->buffer + pData->length - asciiStrLength,
1228  asciiStrLength, asciiStr, asciiStrLength)
1229  == 0);
1230  }
1231 
1232  friend bool operator == ( const OUString& rStr1, const OUString& rStr2 )
1233  { return rStr1.equals(rStr2); }
1234  friend bool operator == ( const OUString& rStr1, const sal_Unicode * pStr2 )
1235  { return rStr1.compareTo( pStr2 ) == 0; }
1236  friend bool operator == ( const sal_Unicode * pStr1, const OUString& rStr2 )
1237  { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
1238 
1239  friend bool operator != ( const OUString& rStr1, const OUString& rStr2 )
1240  { return !(operator == ( rStr1, rStr2 )); }
1241  friend bool operator != ( const OUString& rStr1, const sal_Unicode * pStr2 )
1242  { return !(operator == ( rStr1, pStr2 )); }
1243  friend bool operator != ( const sal_Unicode * pStr1, const OUString& rStr2 )
1244  { return !(operator == ( pStr1, rStr2 )); }
1245 
1246  friend bool operator < ( const OUString& rStr1, const OUString& rStr2 )
1247  { return rStr1.compareTo( rStr2 ) < 0; }
1248  friend bool operator > ( const OUString& rStr1, const OUString& rStr2 )
1249  { return rStr1.compareTo( rStr2 ) > 0; }
1250  friend bool operator <= ( const OUString& rStr1, const OUString& rStr2 )
1251  { return rStr1.compareTo( rStr2 ) <= 0; }
1252  friend bool operator >= ( const OUString& rStr1, const OUString& rStr2 )
1253  { return rStr1.compareTo( rStr2 ) >= 0; }
1254 
1262  template< typename T >
1263  friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==( const OUString& string, T& literal )
1264  {
1265  assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
1266  return string.equalsAsciiL( literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 );
1267  }
1275  template< typename T >
1276  friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==( T& literal, const OUString& string )
1277  {
1278  assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
1279  return string.equalsAsciiL( literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 );
1280  }
1288  template< typename T >
1289  friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=( const OUString& string, T& literal )
1290  {
1291  assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
1292  return !string.equalsAsciiL( literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 );
1293  }
1301  template< typename T >
1302  friend inline typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=( T& literal, const OUString& string )
1303  {
1304  assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
1305  return !string.equalsAsciiL( literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1 );
1306  }
1307 
1308 #if defined LIBO_INTERNAL_ONLY
1309 
1311  /* Comparison between OUString and OUStringLiteral.
1312 
1313  @since LibreOffice 5.0
1314  */
1315 
1316  friend bool operator ==(OUString const & lhs, OUStringLiteral const & rhs) {
1317  return lhs.equalsAsciiL(rhs.data, rhs.size);
1318  }
1319 
1320  friend bool operator !=(OUString const & lhs, OUStringLiteral const & rhs) {
1321  return !lhs.equalsAsciiL(rhs.data, rhs.size);
1322  }
1323 
1324  friend bool operator <(OUString const & lhs, OUStringLiteral const & rhs) {
1325  return
1327  lhs.pData->buffer, lhs.pData->length, rhs.data))
1328  < 0;
1329  }
1330 
1331  friend bool operator <=(OUString const & lhs, OUStringLiteral const & rhs) {
1332  return
1334  lhs.pData->buffer, lhs.pData->length, rhs.data))
1335  <= 0;
1336  }
1337 
1338  friend bool operator >(OUString const & lhs, OUStringLiteral const & rhs) {
1339  return
1341  lhs.pData->buffer, lhs.pData->length, rhs.data))
1342  > 0;
1343  }
1344 
1345  friend bool operator >=(OUString const & lhs, OUStringLiteral const & rhs) {
1346  return
1348  lhs.pData->buffer, lhs.pData->length, rhs.data))
1349  >= 0;
1350  }
1351 
1352  friend bool operator ==(OUStringLiteral const & lhs, OUString const & rhs) {
1353  return rhs.equalsAsciiL(lhs.data, lhs.size);
1354  }
1355 
1356  friend bool operator !=(OUStringLiteral const & lhs, OUString const & rhs) {
1357  return !rhs.equalsAsciiL(lhs.data, lhs.size);
1358  }
1359 
1360  friend bool operator <(OUStringLiteral const & lhs, OUString const & rhs) {
1361  return
1363  rhs.pData->buffer, rhs.pData->length, lhs.data))
1364  >= 0;
1365  }
1366 
1367  friend bool operator <=(OUStringLiteral const & lhs, OUString const & rhs) {
1368  return
1370  rhs.pData->buffer, rhs.pData->length, lhs.data))
1371  > 0;
1372  }
1373 
1374  friend bool operator >(OUStringLiteral const & lhs, OUString const & rhs) {
1375  return
1377  rhs.pData->buffer, rhs.pData->length, lhs.data))
1378  <= 0;
1379  }
1380 
1381  friend bool operator >=(OUStringLiteral const & lhs, OUString const & rhs) {
1382  return
1384  rhs.pData->buffer, rhs.pData->length, lhs.data))
1385  < 0;
1386  }
1387 
1389 #endif
1390 
1398  sal_Int32 hashCode() const
1399  {
1400  return rtl_ustr_hashCode_WithLength( pData->buffer, pData->length );
1401  }
1402 
1416  sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const
1417  {
1418  sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1419  return (ret < 0 ? ret : ret+fromIndex);
1420  }
1421 
1431  sal_Int32 lastIndexOf( sal_Unicode ch ) const
1432  {
1433  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1434  }
1435 
1448  sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const
1449  {
1450  return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1451  }
1452 
1468  sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
1469  {
1470  sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1471  str.pData->buffer, str.pData->length );
1472  return (ret < 0 ? ret : ret+fromIndex);
1473  }
1474 
1480  template< typename T >
1481  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1482  {
1483  assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
1484  sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
1485  pData->buffer + fromIndex, pData->length - fromIndex, literal,
1487  return ret < 0 ? ret : ret + fromIndex;
1488  }
1489 
1513  sal_Int32 indexOfAsciiL(
1514  char const * str, sal_Int32 len, sal_Int32 fromIndex = 0) const
1515  {
1516  sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
1517  pData->buffer + fromIndex, pData->length - fromIndex, str, len);
1518  return ret < 0 ? ret : ret + fromIndex;
1519  }
1520 
1521  // This overload is left undefined, to detect calls of indexOfAsciiL that
1522  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1523  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1524  // platforms):
1525 #if SAL_TYPES_SIZEOFLONG == 8
1526  void indexOfAsciiL(char const *, sal_Int32 len, rtl_TextEncoding) const;
1527 #endif
1528 
1544  sal_Int32 lastIndexOf( const OUString & str ) const
1545  {
1546  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1547  str.pData->buffer, str.pData->length );
1548  }
1549 
1567  sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const
1568  {
1569  return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1570  str.pData->buffer, str.pData->length );
1571  }
1572 
1578  template< typename T >
1580  {
1581  assert( strlen( literal ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
1583  pData->buffer, pData->length, literal, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1);
1584  }
1585 
1605  sal_Int32 lastIndexOfAsciiL(char const * str, sal_Int32 len) const
1606  {
1608  pData->buffer, pData->length, str, len);
1609  }
1610 
1621  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex ) const
1622  {
1623  rtl_uString *pNew = 0;
1624  rtl_uString_newFromSubString( &pNew, pData, beginIndex, getLength() - beginIndex );
1625  return OUString( pNew, SAL_NO_ACQUIRE );
1626  }
1627 
1640  SAL_WARN_UNUSED_RESULT OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const
1641  {
1642  rtl_uString *pNew = 0;
1643  rtl_uString_newFromSubString( &pNew, pData, beginIndex, count );
1644  return OUString( pNew, SAL_NO_ACQUIRE );
1645  }
1646 
1656  {
1657  rtl_uString* pNew = 0;
1658  rtl_uString_newConcat( &pNew, pData, str.pData );
1659  return OUString( pNew, SAL_NO_ACQUIRE );
1660  }
1661 
1662 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1663  friend OUString operator+( const OUString& rStr1, const OUString& rStr2 )
1664  {
1665  return rStr1.concat( rStr2 );
1666  }
1667 #endif
1668 
1682  SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const
1683  {
1684  rtl_uString* pNew = 0;
1685  rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
1686  return OUString( pNew, SAL_NO_ACQUIRE );
1687  }
1688 
1703  {
1704  rtl_uString* pNew = 0;
1705  rtl_uString_newReplace( &pNew, pData, oldChar, newChar );
1706  return OUString( pNew, SAL_NO_ACQUIRE );
1707  }
1708 
1728  OUString const & from, OUString const & to, sal_Int32 * index = 0) const
1729  {
1730  rtl_uString * s = 0;
1731  sal_Int32 i = 0;
1733  &s, pData, from.pData, to.pData, index == 0 ? &i : index);
1734  return OUString(s, SAL_NO_ACQUIRE);
1735  }
1736 
1755  template< typename T >
1757  sal_Int32 * index = 0) const
1758  {
1759  rtl_uString * s = 0;
1760  sal_Int32 i = 0;
1761  assert( strlen( from ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
1763  &s, pData, from, libreoffice_internal::ConstCharArrayDetector< T, void >::size - 1, to.pData, index == 0 ? &i : index);
1764  return OUString(s, SAL_NO_ACQUIRE);
1765  }
1766 
1785  template< typename T1, typename T2 >
1787  replaceFirst( T1& from, T2& to, sal_Int32 * index = 0) const
1788  {
1789  rtl_uString * s = 0;
1790  sal_Int32 i = 0;
1791  assert( strlen( from ) == libreoffice_internal::ConstCharArrayDetector< T1 >::size - 1 );
1792  assert( strlen( to ) == libreoffice_internal::ConstCharArrayDetector< T2 >::size - 1 );
1796  return OUString(s, SAL_NO_ACQUIRE);
1797  }
1798 
1815  OUString const & from, OUString const & to, sal_Int32 fromIndex = 0) const
1816  {
1817  rtl_uString * s = 0;
1818  rtl_uString_newReplaceAllFromIndex(&s, pData, from.pData, to.pData, fromIndex);
1819  return OUString(s, SAL_NO_ACQUIRE);
1820  }
1821 
1835  template< typename T >
1837  {
1838  rtl_uString * s = 0;
1839  assert( strlen( from ) == libreoffice_internal::ConstCharArrayDetector< T >::size - 1 );
1841  return OUString(s, SAL_NO_ACQUIRE);
1842  }
1843 
1857  template< typename T1, typename T2 >
1859  replaceAll( T1& from, T2& to ) const
1860  {
1861  rtl_uString * s = 0;
1862  assert( strlen( from ) == libreoffice_internal::ConstCharArrayDetector< T1 >::size - 1 );
1863  assert( strlen( to ) == libreoffice_internal::ConstCharArrayDetector< T2 >::size - 1 );
1867  return OUString(s, SAL_NO_ACQUIRE);
1868  }
1869 
1881  {
1882  rtl_uString* pNew = 0;
1883  rtl_uString_newToAsciiLowerCase( &pNew, pData );
1884  return OUString( pNew, SAL_NO_ACQUIRE );
1885  }
1886 
1898  {
1899  rtl_uString* pNew = 0;
1900  rtl_uString_newToAsciiUpperCase( &pNew, pData );
1901  return OUString( pNew, SAL_NO_ACQUIRE );
1902  }
1903 
1916  {
1917  rtl_uString* pNew = 0;
1918  rtl_uString_newTrim( &pNew, pData );
1919  return OUString( pNew, SAL_NO_ACQUIRE );
1920  }
1921 
1946  OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const
1947  {
1948  rtl_uString * pNew = 0;
1949  index = rtl_uString_getToken( &pNew, pData, token, cTok, index );
1950  return OUString( pNew, SAL_NO_ACQUIRE );
1951  }
1952 
1966  OUString getToken(sal_Int32 count, sal_Unicode separator) const {
1967  sal_Int32 n = 0;
1968  return getToken(count, separator, n);
1969  }
1970 
1979  bool toBoolean() const
1980  {
1981  return rtl_ustr_toBoolean( pData->buffer );
1982  }
1983 
1991  {
1992  return pData->buffer[0];
1993  }
1994 
2005  sal_Int32 toInt32( sal_Int16 radix = 10 ) const
2006  {
2007  return rtl_ustr_toInt32( pData->buffer, radix );
2008  }
2009 
2022  sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
2023  {
2024  return rtl_ustr_toUInt32( pData->buffer, radix );
2025  }
2026 
2037  sal_Int64 toInt64( sal_Int16 radix = 10 ) const
2038  {
2039  return rtl_ustr_toInt64( pData->buffer, radix );
2040  }
2041 
2054  sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
2055  {
2056  return rtl_ustr_toUInt64( pData->buffer, radix );
2057  }
2058 
2067  float toFloat() const
2068  {
2069  return rtl_ustr_toFloat( pData->buffer );
2070  }
2071 
2080  double toDouble() const
2081  {
2082  return rtl_ustr_toDouble( pData->buffer );
2083  }
2084 
2085 
2102  {
2103  rtl_uString * pNew = 0;
2104  rtl_uString_intern( &pNew, pData );
2105  if (pNew == 0) {
2106  throw std::bad_alloc();
2107  }
2108  return OUString( pNew, SAL_NO_ACQUIRE );
2109  }
2110 
2136  static OUString intern( const sal_Char * value, sal_Int32 length,
2137  rtl_TextEncoding encoding,
2138  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS,
2139  sal_uInt32 *pInfo = NULL )
2140  {
2141  rtl_uString * pNew = 0;
2142  rtl_uString_internConvert( &pNew, value, length, encoding,
2143  convertFlags, pInfo );
2144  if (pNew == 0) {
2145  throw std::bad_alloc();
2146  }
2147  return OUString( pNew, SAL_NO_ACQUIRE );
2148  }
2149 
2174  inline bool convertToString(OString * pTarget, rtl_TextEncoding nEncoding,
2175  sal_uInt32 nFlags) const
2176  {
2177  return rtl_convertUStringToString(&pTarget->pData, pData->buffer,
2178  pData->length, nEncoding, nFlags);
2179  }
2180 
2232  inline sal_uInt32 iterateCodePoints(
2233  sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1) const
2234  {
2236  pData, indexUtf16, incrementCodePoints);
2237  }
2238 
2248  static inline OUString fromUtf8(const OString& rSource)
2249  {
2250  OUString aTarget;
2251  bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
2252  rSource.getStr(),
2253  rSource.getLength(),
2256  (void) bSuccess;
2257  assert(bSuccess);
2258  return aTarget;
2259  }
2260 
2271  inline OString toUtf8() const
2272  {
2273  OString aTarget;
2274  bool bSuccess = rtl_convertUStringToString(&aTarget.pData,
2275  getStr(),
2276  getLength(),
2279  (void) bSuccess;
2280  assert(bSuccess);
2281  return aTarget;
2282  }
2283 
2294  static OUString number( int i, sal_Int16 radix = 10 )
2295  {
2297  rtl_uString* pNewData = 0;
2298  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt32( aBuf, i, radix ) );
2299  return OUString( pNewData, SAL_NO_ACQUIRE );
2300  }
2303  static OUString number( unsigned int i, sal_Int16 radix = 10 )
2304  {
2305  return number( static_cast< unsigned long long >( i ), radix );
2306  }
2309  static OUString number( long i, sal_Int16 radix = 10)
2310  {
2311  return number( static_cast< long long >( i ), radix );
2312  }
2315  static OUString number( unsigned long i, sal_Int16 radix = 10 )
2316  {
2317  return number( static_cast< unsigned long long >( i ), radix );
2318  }
2321  static OUString number( long long ll, sal_Int16 radix = 10 )
2322  {
2324  rtl_uString* pNewData = 0;
2325  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt64( aBuf, ll, radix ) );
2326  return OUString( pNewData, SAL_NO_ACQUIRE );
2327  }
2330  static OUString number( unsigned long long ll, sal_Int16 radix = 10 )
2331  {
2333  rtl_uString* pNewData = 0;
2334  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfUInt64( aBuf, ll, radix ) );
2335  return OUString( pNewData, SAL_NO_ACQUIRE );
2336  }
2337 
2347  static OUString number( float f )
2348  {
2350  rtl_uString* pNewData = 0;
2351  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfFloat( aBuf, f ) );
2352  return OUString( pNewData, SAL_NO_ACQUIRE );
2353  }
2354 
2364  static OUString number( double d )
2365  {
2367  rtl_uString* pNewData = 0;
2368  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfDouble( aBuf, d ) );
2369  return OUString( pNewData, SAL_NO_ACQUIRE );
2370  }
2371 
2383  SAL_DEPRECATED("use boolean()") static OUString valueOf( sal_Bool b )
2384  {
2385  return boolean(b);
2386  }
2387 
2399  static OUString boolean( bool b )
2400  {
2402  rtl_uString* pNewData = 0;
2403  rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfBoolean( aBuf, b ) );
2404  return OUString( pNewData, SAL_NO_ACQUIRE );
2405  }
2406 
2414  SAL_DEPRECATED("convert to OUString or use directly") static OUString valueOf( sal_Unicode c )
2415  {
2416  return OUString( &c, 1 );
2417  }
2418 
2429  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
2430  {
2431  return number( i, radix );
2432  }
2433 
2444  SAL_DEPRECATED("use number()") static OUString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
2445  {
2446  return number( ll, radix );
2447  }
2448 
2458  SAL_DEPRECATED("use number()") static OUString valueOf( float f )
2459  {
2460  return number(f);
2461  }
2462 
2472  SAL_DEPRECATED("use number()") static OUString valueOf( double d )
2473  {
2474  return number(d);
2475  }
2476 
2492  static OUString createFromAscii( const sal_Char * value )
2493  {
2494  rtl_uString* pNew = 0;
2495  rtl_uString_newFromAscii( &pNew, value );
2496  return OUString( pNew, SAL_NO_ACQUIRE );
2497  }
2498 };
2499 
2500 #if defined LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
2501 
2507 template<char C> bool operator ==(OUString const & string, OUStringLiteral1<C>)
2508 {
2509  char const c = C;
2510  return string.equalsAsciiL(&c, 1);
2511 }
2512 
2517 template<char C> bool operator !=(
2518  OUString const & string, OUStringLiteral1<C> literal)
2519 {
2520  return !(string == literal);
2521 }
2522 
2526 template<>
2527 struct ToStringHelper< OUString >
2528  {
2529  static int length( const OUString& s ) { return s.getLength(); }
2530  static sal_Unicode* addData( sal_Unicode* buffer, const OUString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
2531  static const bool allowOStringConcat = false;
2532  static const bool allowOUStringConcat = true;
2533  };
2534 
2538 template<>
2539 struct ToStringHelper< OUStringLiteral >
2540  {
2541  static int length( const OUStringLiteral& str ) { return str.size; }
2542  static sal_Unicode* addData( sal_Unicode* buffer, const OUStringLiteral& str ) { return addDataLiteral( buffer, str.data, str.size ); }
2543  static const bool allowOStringConcat = false;
2544  static const bool allowOUStringConcat = true;
2545  };
2546 
2550 template<char C> struct ToStringHelper<OUStringLiteral1<C>>
2551 {
2552  static int length(OUStringLiteral1<C>) { return 1; }
2553  static sal_Unicode * addData(sal_Unicode * buffer, OUStringLiteral1<C>)
2554  { *buffer++ = C; return buffer; }
2555  static const bool allowOStringConcat = false;
2556  static const bool allowOUStringConcat = true;
2557 };
2558 
2562 template< typename charT, typename traits, typename T1, typename T2 >
2563 inline std::basic_ostream<charT, traits> & operator <<(
2564  std::basic_ostream<charT, traits> & stream, const OUStringConcat< T1, T2 >& concat)
2565 {
2566  return stream << OUString( concat );
2567 }
2568 
2570 #endif
2571 
2578 {
2588  size_t operator()(const OUString& rString) const
2589  { return (size_t)rString.hashCode(); }
2590 };
2591 
2592 /* ======================================================================= */
2593 
2611 inline OUString OStringToOUString( const OString & rStr,
2612  rtl_TextEncoding encoding,
2613  sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
2614 {
2615  return OUString( rStr.getStr(), rStr.getLength(), encoding, convertFlags );
2616 }
2617 
2635 inline OString OUStringToOString( const OUString & rUnicode,
2636  rtl_TextEncoding encoding,
2637  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
2638 {
2639  return OString( rUnicode.getStr(), rUnicode.getLength(), encoding, convertFlags );
2640 }
2641 
2642 /* ======================================================================= */
2643 
2652 template< typename charT, typename traits >
2653 inline std::basic_ostream<charT, traits> & operator <<(
2654  std::basic_ostream<charT, traits> & stream, OUString const & string)
2655 {
2656  return stream <<
2658  // best effort; potentially loses data due to conversion failures
2659  // (stray surrogate halves) and embedded null characters
2660 }
2661 
2662 } // namespace
2663 
2664 #ifdef RTL_STRING_UNITTEST
2665 namespace rtl
2666 {
2667 typedef rtlunittest::OUString OUString;
2668 }
2669 #endif
2670 
2671 // In internal code, allow to use classes like OUString without having to
2672 // explicitly refer to the rtl namespace, which is kind of superfluous given
2673 // that OUString itself is namespaced by its OU prefix:
2674 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
2675 using ::rtl::OUString;
2676 using ::rtl::OUStringHash;
2679 using ::rtl::OUStringLiteral;
2680 using ::rtl::OUStringLiteral1;
2681 #endif
2682 
2683 #endif /* _RTL_USTRING_HXX */
2684 
2685 /* 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:118
OUString getToken(sal_Int32 token, sal_Unicode cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: ustring.hxx:1946
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:136
bool equals(const OUString &str) const
Perform a comparison of two strings.
Definition: ustring.hxx:585
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:2347
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:1567
float toFloat() const
Returns the float value from this string.
Definition: ustring.hxx:2067
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:1431
bool convertToString(OString *pTarget, rtl_TextEncoding nEncoding, sal_uInt32 nFlags) const
Converts to an OString, signalling failure.
Definition: ustring.hxx:2174
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:423
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:1468
#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_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:1817
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:1682
bool match(const OUString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: ustring.hxx:671
#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_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:1544
sal_Int32 reverseCompareToAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Compares two strings in reverse order.
Definition: ustring.hxx:798
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:161
#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:1222
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:1289
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:1897
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:1481
Definition: stringutils.hxx:58
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:1915
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:88
sal_Int32 compareToIgnoreAsciiCase(const OUString &str) const
Perform a ASCII lowercase comparison of two strings.
Definition: ustring.hxx:634
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:744
bool equalsIgnoreAsciiCaseAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform an ASCII lowercase comparison of two strings.
Definition: ustring.hxx:917
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:1702
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:2232
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:108
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:2136
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: ustring.hxx:2037
sal_Int32 compareToIgnoreAsciiCaseAscii(const sal_Char *asciiStr) const
Compares two ASCII strings ignoring case.
Definition: ustring.hxx:892
bool equalsAsciiL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform a comparison of two strings.
Definition: ustring.hxx:842
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:1859
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:2080
size_t operator()(const OUString &rString) const
Compute a hash code for a string.
Definition: ustring.hxx:2588
~OUString()
Release the string data.
Definition: ustring.hxx:351
static OUString number(double d)
Returns the string representation of the double argument.
Definition: ustring.hxx:2364
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:567
OString toUtf8() const
Convert this string to an OString, assuming that the string can be UTF-8-encoded successfully.
Definition: ustring.hxx:2271
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:609
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:2101
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:1194
const sal_Char * getStr() const
Returns a pointer to the characters of this string.
Definition: string.hxx:362
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:291
#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:2321
static OUString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: ustring.hxx:2294
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:394
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:1787
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(const OUString &string, T &literal)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1263
#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:2399
OUString(sal_uInt32 const *codePoints, sal_Int32 codePointCount)
Create a new string from an array of Unicode code points.
Definition: ustring.hxx:318
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:1177
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:2309
OUString()
New string containing no characters.
Definition: ustring.hxx:125
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:2315
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:819
const sal_Unicode * getStr() const
Returns a pointer to the Unicode character buffer for this string.
Definition: ustring.hxx:487
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: ustring.hxx:452
#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:1966
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:984
OUString & operator=(const OUString &str)
Assign a new string.
Definition: ustring.hxx:375
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:1276
bool startsWith(OUString const &str, OUString *rest=0) const
Check whether this string starts with a given substring.
Definition: ustring.hxx:1013
bool endsWithAsciiL(char const *asciiStr, sal_Int32 asciiStrLength) const
Check whether this string ends with a given ASCII string.
Definition: ustring.hxx:1148
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:1733
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:1814
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:1663
#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:2492
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:169
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:1756
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:2330
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:1105
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:1448
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:647
bool toBoolean() const
Returns the Boolean value from this string.
Definition: ustring.hxx:1979
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:1727
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:869
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:2248
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:1655
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:1579
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:946
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:1605
static OUString const & unacquired(rtl_uString *const *ppHandle)
Provides an OUString const & passing a storage pointer of an rtl_uString * handle.
Definition: ustring.hxx:367
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:1640
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OUString &string)
Compare string to an ASCII string literal.
Definition: ustring.hxx:1302
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:2611
sal_Int32 compareTo(const OUString &str, sal_Int32 maxLength) const
Compares two strings with a maximum count of characters.
Definition: ustring.hxx:537
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:2022
#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:147
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:2303
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:2635
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:1513
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:1077
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:2005
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:1880
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:1121
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:465
sal_Unicode toChar() const
Returns the first character from this string.
Definition: ustring.hxx:1990
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:1416
A helper to use OUStrings with hash maps.
Definition: ustring.hxx:2577
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:2054
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:555
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:1027
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:115
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:721
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:1836
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:475
sal_Int32 compareTo(const OUString &str) const
Compares two strings.
Definition: ustring.hxx:516
SAL_WARN_UNUSED_RESULT OUString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: ustring.hxx:1621
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:708
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:1060
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:336
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:98
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:683
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:1398
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.