LibreOffice
LibreOffice 5.1 SDK C/C++ API Reference
string.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_STRING_HXX
21 #define INCLUDED_RTL_STRING_HXX
22 
23 #include <sal/config.h>
24 
25 #include <cassert>
26 #include <cstddef>
27 #include <new>
28 #include <ostream>
29 #include <string.h>
30 
31 #include <rtl/textenc.h>
32 #include <rtl/string.h>
33 #include <rtl/stringutils.hxx>
34 
35 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
36 #include <rtl/stringconcat.hxx>
37 #endif
38 
39 #include <sal/log.hxx>
40 
41 // The unittest uses slightly different code to help check that the proper
42 // calls are made. The class is put into a different namespace to make
43 // sure the compiler generates a different (if generating also non-inline)
44 // copy of the function and does not merge them together. The class
45 // is "brought" into the proper rtl namespace by a typedef below.
46 #ifdef RTL_STRING_UNITTEST
47 #define rtl rtlunittest
48 #endif
49 
50 namespace rtl
51 {
52 
54 #ifdef RTL_STRING_UNITTEST
55 #undef rtl
56 // helper macro to make functions appear more readable
57 #define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true;
58 #else
59 #define RTL_STRING_CONST_FUNCTION
60 #endif
61 
63 /* ======================================================================= */
64 
89 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OString
90 {
91 public:
93  rtl_String * pData;
95 
100  {
101  pData = 0;
102  rtl_string_new( &pData );
103  }
104 
110  OString( const OString & str )
111  {
112  pData = str.pData;
113  rtl_string_acquire( pData );
114  }
115 
121  OString( rtl_String * str )
122  {
123  pData = str;
124  rtl_string_acquire( pData );
125  }
126 
134  inline OString( rtl_String * str, __sal_NoAcquire )
135  {
136  pData = str;
137  }
138 
144  explicit OString( sal_Char value )
145  : pData (0)
146  {
147  rtl_string_newFromStr_WithLength( &pData, &value, 1 );
148  }
149 
158  template< typename T >
160  {
161  pData = 0;
162  rtl_string_newFromStr( &pData, value );
163  }
164 
165  template< typename T >
167  {
168  pData = 0;
169  rtl_string_newFromStr( &pData, value );
170  }
171 
182  template< typename T >
184  {
185  assert(
187  pData = 0;
189  rtl_string_new(&pData);
190  } else {
192  &pData,
194  literal),
196  }
197 #ifdef RTL_STRING_UNITTEST
198  rtl_string_unittest_const_literal = true;
199 #endif
200  }
201 
210  OString( const sal_Char * value, sal_Int32 length )
211  {
212  pData = 0;
213  rtl_string_newFromStr_WithLength( &pData, value, length );
214  }
215 
230  OString( const sal_Unicode * value, sal_Int32 length,
231  rtl_TextEncoding encoding,
232  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
233  {
234  pData = 0;
235  rtl_uString2String( &pData, value, length, encoding, convertFlags );
236  if (pData == 0) {
237  throw std::bad_alloc();
238  }
239  }
240 
241 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
242 
246  template< typename T1, typename T2 >
247  OString( const OStringConcat< T1, T2 >& c )
248  {
249  const sal_Int32 l = c.length();
250  pData = rtl_string_alloc( l );
251  if (l != 0)
252  {
253  char* end = c.addData( pData->buffer );
254  pData->length = l;
255  *end = '\0';
256  }
257  }
258 #endif
259 
260 #ifdef LIBO_INTERNAL_ONLY
261  OString(std::nullptr_t) = delete;
262 #endif
263 
268  {
269  rtl_string_release( pData );
270  }
271 
277  OString & operator=( const OString & str )
278  {
279  rtl_string_assign( &pData, str.pData );
280  return *this;
281  }
282 
288  template< typename T >
290  {
291  RTL_STRING_CONST_FUNCTION
292  assert(
295  rtl_string_new(&pData);
296  } else {
298  &pData,
300  literal),
302  }
303  return *this;
304  }
305 
311  OString & operator+=( const OString & str )
312  {
313  rtl_string_newConcat( &pData, pData, str.pData );
314  return *this;
315  }
316 
317 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
318 
322  template< typename T1, typename T2 >
323  OString& operator+=( const OStringConcat< T1, T2 >& c )
324  {
325  sal_Int32 l = c.length();
326  if( l == 0 )
327  return *this;
328  l += pData->length;
329  rtl_string_ensureCapacity( &pData, l );
330  char* end = c.addData( pData->buffer + pData->length );
331  *end = '\0';
332  pData->length = l;
333  return *this;
334  }
335 #endif
336 
341  void clear()
342  {
343  rtl_string_new( &pData );
344  }
345 
354  sal_Int32 getLength() const { return pData->length; }
355 
364  bool isEmpty() const
365  {
366  return pData->length == 0;
367  }
368 
380  const sal_Char * getStr() const { return pData->buffer; }
381 
391  sal_Char operator [](sal_Int32 index) const {
392  // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
393  assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
394  return getStr()[index];
395  }
396 
409  sal_Int32 compareTo( const OString & str ) const
410  {
411  return rtl_str_compare_WithLength( pData->buffer, pData->length,
412  str.pData->buffer, str.pData->length );
413  }
414 
428  sal_Int32 compareTo( const OString & rObj, sal_Int32 maxLength ) const
429  {
430  return rtl_str_shortenedCompare_WithLength( pData->buffer, pData->length,
431  rObj.pData->buffer, rObj.pData->length, maxLength );
432  }
433 
446  sal_Int32 reverseCompareTo( const OString & str ) const
447  {
448  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
449  str.pData->buffer, str.pData->length );
450  }
451 
463  bool equals( const OString & str ) const
464  {
465  if ( pData->length != str.pData->length )
466  return false;
467  if ( pData == str.pData )
468  return true;
469  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
470  str.pData->buffer, str.pData->length ) == 0;
471  }
472 
488  bool equalsL( const sal_Char* value, sal_Int32 length ) const
489  {
490  if ( pData->length != length )
491  return false;
492 
493  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
494  value, length ) == 0;
495  }
496 
511  bool equalsIgnoreAsciiCase( const OString & str ) const
512  {
513  if ( pData->length != str.pData->length )
514  return false;
515  if ( pData == str.pData )
516  return true;
517  return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
518  str.pData->buffer, str.pData->length ) == 0;
519  }
520 
542  template< typename T >
544  {
545  return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
546  }
547 
548  template< typename T >
550  {
551  return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
552  }
553 
559  template< typename T >
561  {
562  RTL_STRING_CONST_FUNCTION
563  assert(
565  return
566  (pData->length
569  pData->buffer, pData->length,
571  literal),
573  == 0);
574  }
575 
595  bool equalsIgnoreAsciiCaseL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
596  {
597  if ( pData->length != asciiStrLength )
598  return false;
599 
600  return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
601  asciiStr, asciiStrLength ) == 0;
602  }
603 
619  bool match( const OString & str, sal_Int32 fromIndex = 0 ) const
620  {
621  return rtl_str_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
622  str.pData->buffer, str.pData->length, str.pData->length ) == 0;
623  }
624 
630  template< typename T >
631  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
632  {
633  RTL_STRING_CONST_FUNCTION
634  assert(
636  return
638  pData->buffer + fromIndex, pData->length - fromIndex,
640  literal),
643  == 0;
644  }
645 
662  bool matchL(
663  char const * str, sal_Int32 strLength, sal_Int32 fromIndex = 0)
664  const
665  {
667  pData->buffer + fromIndex, pData->length - fromIndex,
668  str, strLength, strLength) == 0;
669  }
670 
671  // This overload is left undefined, to detect calls of matchL that
672  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
673  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
674  // platforms):
675 #if SAL_TYPES_SIZEOFLONG == 8
676  void matchL(char const *, sal_Int32, rtl_TextEncoding) const;
677 #endif
678 
697  bool matchIgnoreAsciiCase( const OString & str, sal_Int32 fromIndex = 0 ) const
698  {
699  return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
700  str.pData->buffer, str.pData->length,
701  str.pData->length ) == 0;
702  }
703 
709  template< typename T >
710  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
711  {
712  RTL_STRING_CONST_FUNCTION
713  assert(
715  return
717  pData->buffer+fromIndex, pData->length-fromIndex,
719  literal),
722  == 0;
723  }
724 
739  bool startsWith(OString const & str, OString * rest = 0) const {
740  bool b = match(str);
741  if (b && rest != 0) {
742  *rest = copy(str.getLength());
743  }
744  return b;
745  }
746 
752  template< typename T >
754  T & literal, OString * rest = 0) const
755  {
756  RTL_STRING_CONST_FUNCTION
757  bool b = match(literal, 0);
758  if (b && rest != 0) {
759  *rest = copy(
761  }
762  return b;
763  }
764 
784  bool startsWithIgnoreAsciiCase(OString const & str, OString * rest = 0)
785  const
786  {
787  bool b = matchIgnoreAsciiCase(str);
788  if (b && rest != 0) {
789  *rest = copy(str.getLength());
790  }
791  return b;
792  }
793 
799  template< typename T >
801  startsWithIgnoreAsciiCase(T & literal, OString * rest = 0) const
802  {
803  RTL_STRING_CONST_FUNCTION
804  assert(
806  bool b = matchIgnoreAsciiCase(literal);
807  if (b && rest != 0) {
808  *rest = copy(
810  }
811  return b;
812  }
813 
828  bool endsWith(OString const & str, OString * rest = 0) const {
829  bool b = str.getLength() <= getLength()
830  && match(str, getLength() - str.getLength());
831  if (b && rest != 0) {
832  *rest = copy(0, getLength() - str.getLength());
833  }
834  return b;
835  }
836 
842  template< typename T >
844  T & literal, OString * rest = 0) const
845  {
846  RTL_STRING_CONST_FUNCTION
847  assert(
849  bool b
851  <= sal_uInt32(getLength()))
852  && match(
854  literal),
855  (getLength()
857  if (b && rest != 0) {
858  *rest = copy(
859  0,
860  (getLength()
862  }
863  return b;
864  }
865 
879  bool endsWithL(char const * str, sal_Int32 strLength) const {
880  return strLength <= getLength()
881  && matchL(str, strLength, getLength() - strLength);
882  }
883 
884  friend bool operator == ( const OString& rStr1, const OString& rStr2 )
885  { return rStr1.equals(rStr2); }
886  friend bool operator != ( const OString& rStr1, const OString& rStr2 )
887  { return !(operator == ( rStr1, rStr2 )); }
888  friend bool operator < ( const OString& rStr1, const OString& rStr2 )
889  { return rStr1.compareTo( rStr2 ) < 0; }
890  friend bool operator > ( const OString& rStr1, const OString& rStr2 )
891  { return rStr1.compareTo( rStr2 ) > 0; }
892  friend bool operator <= ( const OString& rStr1, const OString& rStr2 )
893  { return rStr1.compareTo( rStr2 ) <= 0; }
894  friend bool operator >= ( const OString& rStr1, const OString& rStr2 )
895  { return rStr1.compareTo( rStr2 ) >= 0; }
896 
897  template< typename T >
898  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator==( const OString& rStr1, const T& value )
899  {
900  return rStr1.compareTo( value ) == 0;
901  }
902 
903  template< typename T >
905  {
906  return rStr1.compareTo( value ) == 0;
907  }
908 
909  template< typename T >
910  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator==( const T& value, const OString& rStr2 )
911  {
912  return rStr2.compareTo( value ) == 0;
913  }
914 
915  template< typename T >
917  {
918  return rStr2.compareTo( value ) == 0;
919  }
920 
926  template< typename T >
928  {
929  RTL_STRING_CONST_FUNCTION
930  assert(
932  return
933  (rStr.getLength()
936  rStr.pData->buffer, rStr.pData->length,
938  literal),
940  == 0);
941  }
942 
948  template< typename T >
950  {
951  RTL_STRING_CONST_FUNCTION
952  assert(
954  return
955  (rStr.getLength()
958  rStr.pData->buffer, rStr.pData->length,
960  literal),
962  == 0);
963  }
964 
965  template< typename T >
966  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=( const OString& rStr1, const T& value )
967  {
968  return !(operator == ( rStr1, value ));
969  }
970 
971  template< typename T >
973  {
974  return !(operator == ( rStr1, value ));
975  }
976 
977  template< typename T >
978  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=( const T& value, const OString& rStr2 )
979  {
980  return !(operator == ( value, rStr2 ));
981  }
982 
983  template< typename T >
985  {
986  return !(operator == ( value, rStr2 ));
987  }
988 
994  template< typename T >
996  {
997  return !( rStr == literal );
998  }
999 
1005  template< typename T >
1007  {
1008  return !( literal == rStr );
1009  }
1010 
1018  sal_Int32 hashCode() const
1019  {
1020  return rtl_str_hashCode_WithLength( pData->buffer, pData->length );
1021  }
1022 
1036  sal_Int32 indexOf( sal_Char ch, sal_Int32 fromIndex = 0 ) const
1037  {
1038  sal_Int32 ret = rtl_str_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1039  return (ret < 0 ? ret : ret+fromIndex);
1040  }
1041 
1051  sal_Int32 lastIndexOf( sal_Char ch ) const
1052  {
1053  return rtl_str_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1054  }
1055 
1068  sal_Int32 lastIndexOf( sal_Char ch, sal_Int32 fromIndex ) const
1069  {
1070  return rtl_str_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1071  }
1072 
1088  sal_Int32 indexOf( const OString & str, sal_Int32 fromIndex = 0 ) const
1089  {
1090  sal_Int32 ret = rtl_str_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1091  str.pData->buffer, str.pData->length );
1092  return (ret < 0 ? ret : ret+fromIndex);
1093  }
1094 
1100  template< typename T >
1101  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1102  {
1103  RTL_STRING_CONST_FUNCTION
1104  assert(
1106  sal_Int32 n = rtl_str_indexOfStr_WithLength(
1107  pData->buffer + fromIndex, pData->length - fromIndex,
1110  return n < 0 ? n : n + fromIndex;
1111  }
1112 
1131  sal_Int32 indexOfL(char const * str, sal_Int32 len, sal_Int32 fromIndex = 0)
1132  const
1133  {
1134  sal_Int32 n = rtl_str_indexOfStr_WithLength(
1135  pData->buffer + fromIndex, pData->length - fromIndex, str, len);
1136  return n < 0 ? n : n + fromIndex;
1137  }
1138 
1139  // This overload is left undefined, to detect calls of indexOfL that
1140  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1141  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1142  // platforms):
1143 #if SAL_TYPES_SIZEOFLONG == 8
1144  void indexOfL(char const *, sal_Int32, rtl_TextEncoding) const;
1145 #endif
1146 
1162  sal_Int32 lastIndexOf( const OString & str ) const
1163  {
1164  return rtl_str_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1165  str.pData->buffer, str.pData->length );
1166  }
1167 
1185  sal_Int32 lastIndexOf( const OString & str, sal_Int32 fromIndex ) const
1186  {
1187  return rtl_str_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1188  str.pData->buffer, str.pData->length );
1189  }
1190 
1201  SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex ) const
1202  {
1203  rtl_String *pNew = 0;
1204  rtl_string_newFromSubString( &pNew, pData, beginIndex, getLength() - beginIndex );
1205  return OString( pNew, SAL_NO_ACQUIRE );
1206  }
1207 
1220  SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex, sal_Int32 count ) const
1221  {
1222  rtl_String *pNew = 0;
1223  rtl_string_newFromSubString( &pNew, pData, beginIndex, count );
1224  return OString( pNew, SAL_NO_ACQUIRE );
1225  }
1226 
1236  {
1237  rtl_String* pNew = 0;
1238  rtl_string_newConcat( &pNew, pData, str.pData );
1239  return OString( pNew, SAL_NO_ACQUIRE );
1240  }
1241 
1242 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1243  friend OString operator+( const OString & str1, const OString & str2 )
1244  {
1245  return str1.concat( str2 );
1246  }
1247 #endif
1248 
1262  SAL_WARN_UNUSED_RESULT OString replaceAt( sal_Int32 index, sal_Int32 count, const OString& newStr ) const
1263  {
1264  rtl_String* pNew = 0;
1265  rtl_string_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
1266  return OString( pNew, SAL_NO_ACQUIRE );
1267  }
1268 
1283  {
1284  rtl_String* pNew = 0;
1285  rtl_string_newReplace( &pNew, pData, oldChar, newChar );
1286  return OString( pNew, SAL_NO_ACQUIRE );
1287  }
1288 
1308  OString const & from, OString const & to, sal_Int32 * index = 0) const
1309  {
1310  rtl_String * s = 0;
1311  sal_Int32 i = 0;
1313  &s, pData, from.pData->buffer, from.pData->length,
1314  to.pData->buffer, to.pData->length, index == 0 ? &i : index);
1315  return OString(s, SAL_NO_ACQUIRE);
1316  }
1317 
1331  SAL_WARN_UNUSED_RESULT OString replaceAll(OString const & from, OString const & to) const {
1332  rtl_String * s = 0;
1334  &s, pData, from.pData->buffer, from.pData->length,
1335  to.pData->buffer, to.pData->length);
1336  return OString(s, SAL_NO_ACQUIRE);
1337  }
1338 
1350  {
1351  rtl_String* pNew = 0;
1352  rtl_string_newToAsciiLowerCase( &pNew, pData );
1353  return OString( pNew, SAL_NO_ACQUIRE );
1354  }
1355 
1367  {
1368  rtl_String* pNew = 0;
1369  rtl_string_newToAsciiUpperCase( &pNew, pData );
1370  return OString( pNew, SAL_NO_ACQUIRE );
1371  }
1372 
1385  {
1386  rtl_String* pNew = 0;
1387  rtl_string_newTrim( &pNew, pData );
1388  return OString( pNew, SAL_NO_ACQUIRE );
1389  }
1390 
1415  OString getToken( sal_Int32 token, sal_Char cTok, sal_Int32& index ) const
1416  {
1417  rtl_String * pNew = 0;
1418  index = rtl_string_getToken( &pNew, pData, token, cTok, index );
1419  return OString( pNew, SAL_NO_ACQUIRE );
1420  }
1421 
1435  OString getToken(sal_Int32 count, char separator) const {
1436  sal_Int32 n = 0;
1437  return getToken(count, separator, n);
1438  }
1439 
1448  bool toBoolean() const
1449  {
1450  return rtl_str_toBoolean( pData->buffer );
1451  }
1452 
1460  {
1461  return pData->buffer[0];
1462  }
1463 
1474  sal_Int32 toInt32( sal_Int16 radix = 10 ) const
1475  {
1476  return rtl_str_toInt32( pData->buffer, radix );
1477  }
1478 
1491  sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
1492  {
1493  return rtl_str_toUInt32( pData->buffer, radix );
1494  }
1495 
1506  sal_Int64 toInt64( sal_Int16 radix = 10 ) const
1507  {
1508  return rtl_str_toInt64( pData->buffer, radix );
1509  }
1510 
1523  sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
1524  {
1525  return rtl_str_toUInt64( pData->buffer, radix );
1526  }
1527 
1536  float toFloat() const
1537  {
1538  return rtl_str_toFloat( pData->buffer );
1539  }
1540 
1549  double toDouble() const
1550  {
1551  return rtl_str_toDouble( pData->buffer );
1552  }
1553 
1564  static OString number( int i, sal_Int16 radix = 10 )
1565  {
1566  return number( static_cast< long long >( i ), radix );
1567  }
1570  static OString number( unsigned int i, sal_Int16 radix = 10 )
1571  {
1572  return number( static_cast< unsigned long long >( i ), radix );
1573  }
1576  static OString number( long i, sal_Int16 radix = 10 )
1577  {
1578  return number( static_cast< long long >( i ), radix );
1579  }
1582  static OString number( unsigned long i, sal_Int16 radix = 10 )
1583  {
1584  return number( static_cast< unsigned long long >( i ), radix );
1585  }
1588  static OString number( long long ll, sal_Int16 radix = 10 )
1589  {
1591  rtl_String* pNewData = 0;
1592  rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfInt64( aBuf, ll, radix ) );
1593  return OString( pNewData, SAL_NO_ACQUIRE );
1594  }
1597  static OString number( unsigned long long ll, sal_Int16 radix = 10 )
1598  {
1600  rtl_String* pNewData = 0;
1601  rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfUInt64( aBuf, ll, radix ) );
1602  return OString( pNewData, SAL_NO_ACQUIRE );
1603  }
1604 
1614  static OString number( float f )
1615  {
1617  rtl_String* pNewData = 0;
1618  rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfFloat( aBuf, f ) );
1619  return OString( pNewData, SAL_NO_ACQUIRE );
1620  }
1621 
1631  static OString number( double d )
1632  {
1634  rtl_String* pNewData = 0;
1635  rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfDouble( aBuf, d ) );
1636  return OString( pNewData, SAL_NO_ACQUIRE );
1637  }
1638 
1650  SAL_DEPRECATED("use boolean()") static OString valueOf( sal_Bool b )
1651  {
1652  return boolean(b);
1653  }
1654 
1666  static OString boolean( bool b )
1667  {
1669  rtl_String* pNewData = 0;
1670  rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfBoolean( aBuf, b ) );
1671  return OString( pNewData, SAL_NO_ACQUIRE );
1672  }
1673 
1681  SAL_DEPRECATED("convert to OString or use directly") static OString valueOf( sal_Char c )
1682  {
1683  return OString( &c, 1 );
1684  }
1685 
1696  SAL_DEPRECATED("use number()") static OString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
1697  {
1698  return number( i, radix );
1699  }
1700 
1711  SAL_DEPRECATED("use number()") static OString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
1712  {
1713  return number( ll, radix );
1714  }
1715 
1725  SAL_DEPRECATED("use number()") static OString valueOf( float f )
1726  {
1727  return number(f);
1728  }
1729 
1739  SAL_DEPRECATED("use number()") static OString valueOf( double d )
1740  {
1741  return number(d);
1742  }
1743 
1744 };
1745 
1746 /* ======================================================================= */
1747 
1748 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1749 
1757 struct SAL_WARN_UNUSED OStringLiteral
1758 {
1759  template< int N >
1760  explicit OStringLiteral( const char (&str)[ N ] ) : size( N - 1 ), data( str ) { assert( strlen( str ) == N - 1 ); }
1761  int size;
1762  const char* data;
1763 };
1764 
1768 template<>
1769 struct ToStringHelper< OString >
1770  {
1771  static int length( const OString& s ) { return s.getLength(); }
1772  static char* addData( char* buffer, const OString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
1773  static const bool allowOStringConcat = true;
1774  static const bool allowOUStringConcat = false;
1775  };
1776 
1780 template<>
1781 struct ToStringHelper< OStringLiteral >
1782  {
1783  static int length( const OStringLiteral& str ) { return str.size; }
1784  static char* addData( char* buffer, const OStringLiteral& str ) { return addDataHelper( buffer, str.data, str.size ); }
1785  static const bool allowOStringConcat = true;
1786  static const bool allowOUStringConcat = false;
1787  };
1788 
1792 template< typename charT, typename traits, typename T1, typename T2 >
1793 inline std::basic_ostream<charT, traits> & operator <<(
1794  std::basic_ostream<charT, traits> & stream, const OStringConcat< T1, T2 >& concat)
1795 {
1796  return stream << OString( concat );
1797 }
1798 #endif
1799 
1800 
1807 {
1817  size_t operator()( const OString& rString ) const
1818  { return (size_t)rString.hashCode(); }
1819 };
1820 
1823 {
1824  bool operator()( const char* p1, const char* p2) const
1825  { return rtl_str_compare(p1, p2) == 0; }
1826 };
1827 
1830 {
1831  size_t operator()(const char* p) const
1832  { return rtl_str_hashCode(p); }
1833 };
1834 
1835 /* ======================================================================= */
1836 
1843 template< typename charT, typename traits > std::basic_ostream<charT, traits> &
1845  std::basic_ostream<charT, traits> & stream, OString const & string)
1846 {
1847  return stream << string.getStr();
1848  // best effort; potentially loses data due to embedded null characters
1849 }
1850 
1851 } /* Namespace */
1852 
1853 #ifdef RTL_STRING_UNITTEST
1854 namespace rtl
1855 {
1856 typedef rtlunittest::OString OString;
1857 }
1858 #undef RTL_STRING_CONST_FUNCTION
1859 #endif
1860 
1861 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
1862 using ::rtl::OString;
1863 using ::rtl::OStringHash;
1864 using ::rtl::OStringLiteral;
1865 #endif
1866 
1867 #endif // INCLUDED_RTL_STRING_HXX
1868 
1869 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define RTL_STR_MAX_VALUEOFUINT64
Definition: string.h:673
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:116
SAL_DLLPUBLIC sal_Int32 rtl_str_hashCode(const sal_Char *str) SAL_THROW_EXTERN_C()
Return a hash code for a string.
libreoffice_internal::ConstCharArrayDetector< T, OString & >::Type operator=(T &literal)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:289
SAL_DLLPUBLIC void rtl_string_release(rtl_String *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
SAL_DLLPUBLIC void rtl_string_newConcat(rtl_String **newStr, rtl_String *left, rtl_String *right) SAL_THROW_EXTERN_C()
Create a new string that is the concatenation of two other strings.
sal_Int32 indexOf(sal_Char 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: string.hxx:1036
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
sal_Int32 indexOfL(char const *str, sal_Int32 len, 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: string.hxx:1131
sal_Int32 lastIndexOf(const OString &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: string.hxx:1185
SAL_DLLPUBLIC sal_Int64 rtl_str_toInt64(const sal_Char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as a long integer.
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(const OString &rStr, T &literal)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:995
static OString number(double d)
Returns the string representation of the double argument.
Definition: string.hxx:1631
SAL_DLLPUBLIC sal_Int32 rtl_string_getToken(rtl_String **newStr, rtl_String *str, sal_Int32 token, sal_Char cTok, sal_Int32 idx) SAL_THROW_EXTERN_C()
Create a new string by extracting a single token from another string.
float toFloat() const
Returns the float value from this string.
Definition: string.hxx:1536
#define RTL_STR_MAX_VALUEOFDOUBLE
Definition: string.h:711
OString(const OString &str)
New string from OString.
Definition: string.hxx:110
static OString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: string.hxx:1666
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: string.hxx:1523
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:608
OString(const sal_Unicode *value, sal_Int32 length, rtl_TextEncoding encoding, sal_uInt32 convertFlags=OUSTRING_TO_OSTRING_CVTFLAGS)
New string from a Unicode character buffer array.
Definition: string.hxx:230
SAL_DLLPUBLIC sal_Int32 rtl_str_compare(const sal_Char *first, const sal_Char *second) SAL_THROW_EXTERN_C()
Compare two strings.
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfFloat(sal_Char *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
OString & operator+=(const OString &str)
Append a string to this string.
Definition: string.hxx:311
SAL_WARN_UNUSED_RESULT OString replaceFirst(OString const &from, OString const &to, sal_Int32 *index=0) const
Returns a new string resulting from replacing the first occurrence of a given substring with another ...
Definition: string.hxx:1307
SAL_DLLPUBLIC sal_Int32 rtl_str_lastIndexOfChar_WithLength(const sal_Char *str, sal_Int32 len, sal_Char ch) SAL_THROW_EXTERN_C()
Search for the last occurrence of a character within a string.
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: string.hxx:1101
SAL_DLLPUBLIC void rtl_string_newFromLiteral(rtl_String **newStr, const sal_Char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
char sal_Char
A legacy synonym for char.
Definition: types.h:130
Definition: stringutils.hxx:116
SAL_WARN_UNUSED_RESULT OString toAsciiLowerCase() const
Converts from this string all ASCII uppercase characters (65-90) to ASCII lowercase characters (97-12...
Definition: string.hxx:1349
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:89
sal_Int32 lastIndexOf(const OString &str) const
Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the end.
Definition: string.hxx:1162
SAL_DLLPUBLIC void rtl_uString2String(rtl_String **newStr, const sal_Unicode *str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags) SAL_THROW_EXTERN_C()
Create a new byte string by converting a Unicode string, using a specific text encoding.
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:106
OString(sal_Char value)
New string from a single character.
Definition: string.hxx:144
unsigned char sal_Bool
Definition: types.h:48
SAL_DLLPUBLIC sal_Int32 rtl_str_lastIndexOfStr_WithLength(const sal_Char *str, sal_Int32 len, const sal_Char *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the last occurrence of a substring within a string.
bool endsWith(OString const &str, OString *rest=0) const
Check whether this string ends with a given substring.
Definition: string.hxx:828
SAL_DLLPUBLIC sal_Int32 rtl_str_shortenedCompare_WithLength(const sal_Char *first, sal_Int32 firstLen, const sal_Char *second, sal_Int32 secondLen, sal_Int32 shortenedLen) SAL_THROW_EXTERN_C()
Compare two strings with a maximum count of characters.
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: string.hxx:560
friend OString operator+(const OString &str1, const OString &str2)
Definition: string.hxx:1243
SAL_WARN_UNUSED_RESULT OString trim() const
Returns a new string resulting from removing white space from both ends of the string.
Definition: string.hxx:1384
SAL_DLLPUBLIC sal_Int32 rtl_str_reverseCompare_WithLength(const sal_Char *first, sal_Int32 firstLen, const sal_Char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings from back to front.
sal_Int32 lastIndexOf(sal_Char ch) const
Returns the index within this string of the last occurrence of the specified character, searching backward starting at the end.
Definition: string.hxx:1051
sal_Int32 indexOf(const OString &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: string.hxx:1088
bool isEmpty() const
Checks if a string is empty.
Definition: string.hxx:364
SAL_DLLPUBLIC void rtl_string_newReplace(rtl_String **newStr, rtl_String *str, sal_Char oldChar, sal_Char newChar) SAL_THROW_EXTERN_C()
Create a new string by replacing all occurrences of a single character within another string...
SAL_DLLPUBLIC sal_Bool rtl_str_toBoolean(const sal_Char *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
bool operator()(const char *p1, const char *p2) const
Definition: string.hxx:1824
SAL_DLLPUBLIC sal_Int32 rtl_str_indexOfStr_WithLength(const sal_Char *str, sal_Int32 len, const sal_Char *subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C()
Search for the first occurrence of a substring within a string.
SAL_DLLPUBLIC float rtl_str_toFloat(const sal_Char *str) SAL_THROW_EXTERN_C()
Interpret a string as a float.
size_t operator()(const OString &rString) const
Compute a hash code for a string.
Definition: string.hxx:1817
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator==(const OString &rStr1, T &value)
Definition: string.hxx:904
OString(T &literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
New string from a string literal.
Definition: string.hxx:183
OString(const sal_Char *value, sal_Int32 length)
New string from a character buffer array.
Definition: string.hxx:210
const sal_Char * getStr() const
Returns a pointer to the characters of this string.
Definition: string.hxx:380
Equality functor for classic c-strings (i.e., null-terminated char* strings).
Definition: string.hxx:1822
SAL_DLLPUBLIC sal_uInt32 rtl_str_toUInt32(const sal_Char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned integer.
SAL_WARN_UNUSED_RESULT OString replaceAll(OString const &from, OString const &to) const
Returns a new string resulting from replacing all occurrences of a given substring with another subst...
Definition: string.hxx:1331
bool equalsIgnoreAsciiCase(const OString &str) const
Perform a ASCII lowercase comparison of two strings.
Definition: string.hxx:511
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=(const OString &rStr1, const T &value)
Definition: string.hxx:966
SAL_DLLPUBLIC void rtl_string_newToAsciiLowerCase(rtl_String **newStr, rtl_String *str) SAL_THROW_EXTERN_C()
Create a new string by converting all ASCII uppercase letters to lowercase within another string...
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1324
SAL_DLLPUBLIC void rtl_string_new(rtl_String **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
SAL_WARN_UNUSED_RESULT OString concat(const OString &str) const
Concatenates the specified string to the end of this string.
Definition: string.hxx:1235
#define RTL_STR_MAX_VALUEOFBOOLEAN
Definition: string.h:585
libreoffice_internal::CharPtrDetector< T, bool >::Type equalsIgnoreAsciiCase(const T &asciiStr) const
Perform a ASCII lowercase comparison of two strings.
Definition: string.hxx:543
~OString()
Release the string data.
Definition: string.hxx:267
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=(const T &value, const OString &rStr2)
Definition: string.hxx:978
SAL_DLLPUBLIC void rtl_string_ensureCapacity(rtl_String **str, sal_Int32 size) SAL_THROW_EXTERN_C()
Ensure a string has enough space for a given number of characters.
static OString 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: string.hxx:1570
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: string.hxx:1491
SAL_DLLPUBLIC void rtl_string_newReplaceStrAt(rtl_String **newStr, rtl_String *str, sal_Int32 idx, sal_Int32 count, rtl_String *subStr) SAL_THROW_EXTERN_C()
Create a new string by replacing a substring of another string.
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: string.hxx:1474
static OString 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: string.hxx:1588
bool startsWithIgnoreAsciiCase(OString const &str, OString *rest=0) const
Check whether this string starts with a given string, ignoring the case of ASCII letters.
Definition: string.hxx:784
bool equalsIgnoreAsciiCaseL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform a ASCII lowercase comparison of two strings.
Definition: string.hxx:595
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator==(T &value, const OString &rStr2)
Definition: string.hxx:916
definition of a no acquire enum for ctors
Definition: types.h:382
size_t operator()(const char *p) const
Definition: string.hxx:1831
__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
#define RTL_STR_MAX_VALUEOFFLOAT
Definition: string.h:692
bool toBoolean() const
Returns the Boolean value from this string.
Definition: string.hxx:1448
OString getToken(sal_Int32 count, char separator) const
Returns a token from the string.
Definition: string.hxx:1435
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:650
sal_Int32 compareTo(const OString &str) const
Compares two strings.
Definition: string.hxx:409
SAL_DLLPUBLIC void rtl_string_newFromStr(rtl_String **newStr, const sal_Char *value) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
SAL_WARN_UNUSED_RESULT OString replace(sal_Char oldChar, sal_Char newChar) const
Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar...
Definition: string.hxx:1282
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator!=(const OString &rStr1, T &value)
Definition: string.hxx:972
SAL_DLLPUBLIC void rtl_string_newReplaceAll(rtl_String **newStr, rtl_String *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...
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfUInt64(sal_Char *str, sal_uInt64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of an unsigned long integer.
SAL_DLLPUBLIC rtl_String * rtl_string_alloc(sal_Int32 nLen) SAL_THROW_EXTERN_C()
Allocate a new string containing space for a given number of characters.
sal_uInt16 sal_Unicode
Definition: types.h:152
bool match(const OString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: string.hxx:619
SAL_DLLPUBLIC sal_Int32 rtl_str_hashCode_WithLength(const sal_Char *str, sal_Int32 len) SAL_THROW_EXTERN_C()
Return a hash code for a string.
SAL_DLLPUBLIC sal_Int32 rtl_str_indexOfChar_WithLength(const sal_Char *str, sal_Int32 len, sal_Char ch) SAL_THROW_EXTERN_C()
Search for the first occurrence of a character within a string.
SAL_DLLPUBLIC void rtl_string_newReplaceFirst(rtl_String **newStr, rtl_String *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...
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator!=(T &value, const OString &rStr2)
Definition: string.hxx:984
OString(const T &value, typename libreoffice_internal::CharPtrDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
New string from a character buffer array.
Definition: string.hxx:159
A helper to use OStrings with hash maps.
Definition: string.hxx:1806
sal_Char toChar() const
Returns the first character from this string.
Definition: string.hxx:1459
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: string.hxx:631
SAL_DLLPUBLIC void rtl_string_assign(rtl_String **str, rtl_String *rightValue) SAL_THROW_EXTERN_C()
Assign a new value to a string.
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator!=(T &literal, const OString &rStr)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1006
bool startsWith(OString const &str, OString *rest=0) const
Check whether this string starts with a given substring.
Definition: string.hxx:739
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:39
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWithIgnoreAsciiCase(T &literal, OString *rest=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:801
SAL_DLLPUBLIC sal_Int32 rtl_str_compare_WithLength(const sal_Char *first, sal_Int32 firstLen, const sal_Char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings.
SAL_DLLPUBLIC sal_Int32 rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(const sal_Char *first, sal_Int32 firstLen, const sal_Char *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...
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator==(const T &value, const OString &rStr2)
Definition: string.hxx:910
SAL_DLLPUBLIC void rtl_string_newFromSubString(rtl_String **newStr, const rtl_String *from, sal_Int32 beginIndex, sal_Int32 count) SAL_THROW_EXTERN_C()
Allocate a new string that is a substring of this string.
static OString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: string.hxx:1564
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfInt64(sal_Char *str, sal_Int64 l, sal_Int16 radix) SAL_THROW_EXTERN_C()
Create the string representation of a long integer.
SAL_DLLPUBLIC sal_Int32 rtl_str_toInt32(const sal_Char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an integer.
bool equalsL(const sal_Char *value, sal_Int32 length) const
Perform a comparison of two strings.
Definition: string.hxx:488
libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase(T &asciiStr) const
Definition: string.hxx:549
bool matchIgnoreAsciiCase(const OString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string, ignoring the case of ASCII letters.
Definition: string.hxx:697
Definition: stringutils.hxx:118
static OString number(float f)
Returns the string representation of the float argument.
Definition: string.hxx:1614
bool equals(const OString &str) const
Perform a comparison of two strings.
Definition: string.hxx:463
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator==(const OString &rStr1, const T &value)
Definition: string.hxx:898
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(T &literal, const OString &rStr)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:949
static OString 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: string.hxx:1582
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Dont use, its evil.") void doit(int nPara);.
Definition: types.h:495
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type endsWith(T &literal, OString *rest=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:843
bool matchL(char const *str, sal_Int32 strLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: string.hxx:662
OString getToken(sal_Int32 token, sal_Char cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: string.hxx:1415
SAL_WARN_UNUSED_RESULT OString copy(sal_Int32 beginIndex, sal_Int32 count) const
Returns a new string that is a substring of this string.
Definition: string.hxx:1220
OString & operator=(const OString &str)
Assign a new string.
Definition: string.hxx:277
OString(T &value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition: string.hxx:166
SAL_WARN_UNUSED_RESULT OString replaceAt(sal_Int32 index, sal_Int32 count, const OString &newStr) const
Returns a new string resulting from replacing n = count characters from position index in this string...
Definition: string.hxx:1262
SAL_DLLPUBLIC void rtl_string_newTrim(rtl_String **newStr, rtl_String *str) SAL_THROW_EXTERN_C()
Create a new string by removing white space from both ends of another string.
SAL_WARN_UNUSED_RESULT OString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: string.hxx:1201
OString()
New string containing no characters.
Definition: string.hxx:99
sal_Int32 lastIndexOf(sal_Char 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: string.hxx:1068
SAL_DLLPUBLIC double rtl_str_toDouble(const sal_Char *str) SAL_THROW_EXTERN_C()
Interpret a string as a double.
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: string.hxx:1018
SAL_DLLPUBLIC void rtl_string_newToAsciiUpperCase(rtl_String **newStr, rtl_String *str) SAL_THROW_EXTERN_C()
Create a new string by converting all ASCII lowercase letters to uppercase within another string...
SAL_DLLPUBLIC void rtl_string_newFromStr_WithLength(rtl_String **newStr, const sal_Char *value, sal_Int32 len) SAL_THROW_EXTERN_C()
Allocate a new string that contains a copy of a character array.
friend libreoffice_internal::ConstCharArrayDetector< T, bool >::Type operator==(const OString &rStr, T &literal)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:927
static OString 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: string.hxx:1597
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfBoolean(sal_Char *str, sal_Bool b) SAL_THROW_EXTERN_C()
Create the string representation of a boolean.
sal_Int32 reverseCompareTo(const OString &str) const
Compares two strings in reverse order.
Definition: string.hxx:446
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfDouble(sal_Char *str, double d) SAL_THROW_EXTERN_C()
Create the string representation of a double.
SAL_DLLPUBLIC sal_uInt64 rtl_str_toUInt64(const sal_Char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an unsigned long integer.
SAL_DLLPUBLIC sal_Int32 rtl_str_compareIgnoreAsciiCase_WithLength(const sal_Char *first, sal_Int32 firstLen, const sal_Char *second, sal_Int32 secondLen) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
bool endsWithL(char const *str, sal_Int32 strLength) const
Check whether this string ends with a given substring.
Definition: string.hxx:879
Definition: bootstrap.hxx:24
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: string.hxx:710
SAL_WARN_UNUSED_RESULT OString toAsciiUpperCase() const
Converts from this string all ASCII lowercase characters (97-122) to ASCII uppercase characters (65-9...
Definition: string.hxx:1366
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:319
sal_Int32 compareTo(const OString &rObj, sal_Int32 maxLength) const
Compares two strings with an maximum count of characters.
Definition: string.hxx:428
double toDouble() const
Returns the double value from this string.
Definition: string.hxx:1549
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: string.hxx:1506
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 startsWith(T &literal, OString *rest=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:753
SAL_DLLPUBLIC sal_Int32 rtl_str_compareIgnoreAsciiCase(const sal_Char *first, const sal_Char *second) SAL_THROW_EXTERN_C()
Compare two strings, ignoring the case of ASCII characters.
OString(rtl_String *str)
New string from OString data.
Definition: string.hxx:121
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: string.hxx:341
Hashing functor for classic c-strings (i.e., null-terminated char* strings).
Definition: string.hxx:1829
OString(rtl_String *str, __sal_NoAcquire)
New string from OString data without acquiring it.
Definition: string.hxx:134
static OString number(long i, sal_Int16 radix=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:1576
SAL_DLLPUBLIC void rtl_string_acquire(rtl_String *str) SAL_THROW_EXTERN_C()
Increment the reference count of a string.