LibreOffice
LibreOffice 5.3 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 <config_global.h>
37 #include <rtl/stringconcat.hxx>
38 #endif
39 
40 #include <sal/log.hxx>
41 
42 // The unittest uses slightly different code to help check that the proper
43 // calls are made. The class is put into a different namespace to make
44 // sure the compiler generates a different (if generating also non-inline)
45 // copy of the function and does not merge them together. The class
46 // is "brought" into the proper rtl namespace by a typedef below.
47 #ifdef RTL_STRING_UNITTEST
48 #define rtl rtlunittest
49 #endif
50 
51 namespace rtl
52 {
53 
55 #ifdef RTL_STRING_UNITTEST
56 #undef rtl
57 // helper macro to make functions appear more readable
58 #define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true;
59 #else
60 #define RTL_STRING_CONST_FUNCTION
61 #endif
62 
64 /* ======================================================================= */
65 
90 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OString
91 {
92 public:
94  rtl_String * pData;
96 
101  {
102  pData = NULL;
103  rtl_string_new( &pData );
104  }
105 
111  OString( const OString & str )
112  {
113  pData = str.pData;
114  rtl_string_acquire( pData );
115  }
116 
117 #ifndef _MSC_VER // TODO?
118 #if defined LIBO_INTERNAL_ONLY
119 
125  OString( OString && str )
126  {
127  pData = str.pData;
128  str.pData = nullptr;
129  rtl_string_new( &str.pData );
130  }
131 #endif
132 #endif
133 
139  OString( rtl_String * str )
140  {
141  pData = str;
142  rtl_string_acquire( pData );
143  }
144 
152  inline OString( rtl_String * str, __sal_NoAcquire )
153  {
154  pData = str;
155  }
156 
162  explicit OString( sal_Char value )
163  : pData (NULL)
164  {
165  rtl_string_newFromStr_WithLength( &pData, &value, 1 );
166  }
167 
176  template< typename T >
178  {
179  pData = NULL;
180  rtl_string_newFromStr( &pData, value );
181  }
182 
183  template< typename T >
185  {
186  pData = NULL;
187  rtl_string_newFromStr( &pData, value );
188  }
189 
200  template< typename T >
202  {
203  assert(
205  pData = NULL;
207  rtl_string_new(&pData);
208  } else {
210  &pData,
212  literal),
214  }
215 #ifdef RTL_STRING_UNITTEST
216  rtl_string_unittest_const_literal = true;
217 #endif
218  }
219 
228  OString( const sal_Char * value, sal_Int32 length )
229  {
230  pData = NULL;
231  rtl_string_newFromStr_WithLength( &pData, value, length );
232  }
233 
248  OString( const sal_Unicode * value, sal_Int32 length,
249  rtl_TextEncoding encoding,
250  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
251  {
252  pData = NULL;
253  rtl_uString2String( &pData, value, length, encoding, convertFlags );
254  if (pData == NULL) {
255  throw std::bad_alloc();
256  }
257  }
258 
259 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
260 
264  template< typename T1, typename T2 >
265  OString( const OStringConcat< T1, T2 >& c )
266  {
267  const sal_Int32 l = c.length();
268  pData = rtl_string_alloc( l );
269  if (l != 0)
270  {
271  char* end = c.addData( pData->buffer );
272  pData->length = l;
273  *end = '\0';
274  }
275  }
276 #endif
277 
278 #ifdef LIBO_INTERNAL_ONLY
279  OString(std::nullptr_t) = delete;
280 #endif
281 
286  {
287  rtl_string_release( pData );
288  }
289 
295  OString & operator=( const OString & str )
296  {
297  rtl_string_assign( &pData, str.pData );
298  return *this;
299  }
300 
301 #ifndef _MSC_VER // TODO?
302 #if defined LIBO_INTERNAL_ONLY
303 
309  OString & operator=( OString && str )
310  {
311  rtl_string_release( pData );
312  pData = str.pData;
313  str.pData = nullptr;
314  rtl_string_new( &str.pData );
315  return *this;
316  }
317 #endif
318 #endif
319 
325  template< typename T >
327  {
328  RTL_STRING_CONST_FUNCTION
329  assert(
332  rtl_string_new(&pData);
333  } else {
335  &pData,
337  literal),
339  }
340  return *this;
341  }
342 
348  OString & operator+=( const OString & str )
349 #if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
350  &
351 #endif
352  {
353  rtl_string_newConcat( &pData, pData, str.pData );
354  return *this;
355  }
356 #if defined LIBO_INTERNAL_ONLY && HAVE_CXX11_REF_QUALIFIER
357  void operator+=(OString const &) && = delete;
358 #endif
359 
360 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
361 
365  template< typename T1, typename T2 >
366  OString& operator+=( const OStringConcat< T1, T2 >& c )
367 #if HAVE_CXX11_REF_QUALIFIER
368  &
369 #endif
370  {
371  sal_Int32 l = c.length();
372  if( l == 0 )
373  return *this;
374  l += pData->length;
375  rtl_string_ensureCapacity( &pData, l );
376  char* end = c.addData( pData->buffer + pData->length );
377  *end = '\0';
378  pData->length = l;
379  return *this;
380  }
381 #if HAVE_CXX11_REF_QUALIFIER
382  template<typename T1, typename T2> void operator +=(
383  OStringConcat<T1, T2> const &) && = delete;
384 #endif
385 #endif
386 
391  void clear()
392  {
393  rtl_string_new( &pData );
394  }
395 
404  sal_Int32 getLength() const { return pData->length; }
405 
414  bool isEmpty() const
415  {
416  return pData->length == 0;
417  }
418 
430  const sal_Char * getStr() const { return pData->buffer; }
431 
441  sal_Char operator [](sal_Int32 index) const {
442  // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
443  assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
444  return getStr()[index];
445  }
446 
459  sal_Int32 compareTo( const OString & str ) const
460  {
461  return rtl_str_compare_WithLength( pData->buffer, pData->length,
462  str.pData->buffer, str.pData->length );
463  }
464 
478  sal_Int32 compareTo( const OString & rObj, sal_Int32 maxLength ) const
479  {
480  return rtl_str_shortenedCompare_WithLength( pData->buffer, pData->length,
481  rObj.pData->buffer, rObj.pData->length, maxLength );
482  }
483 
496  sal_Int32 reverseCompareTo( const OString & str ) const
497  {
498  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
499  str.pData->buffer, str.pData->length );
500  }
501 
513  bool equals( const OString & str ) const
514  {
515  if ( pData->length != str.pData->length )
516  return false;
517  if ( pData == str.pData )
518  return true;
519  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
520  str.pData->buffer, str.pData->length ) == 0;
521  }
522 
538  bool equalsL( const sal_Char* value, sal_Int32 length ) const
539  {
540  if ( pData->length != length )
541  return false;
542 
543  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
544  value, length ) == 0;
545  }
546 
561  bool equalsIgnoreAsciiCase( const OString & str ) const
562  {
563  if ( pData->length != str.pData->length )
564  return false;
565  if ( pData == str.pData )
566  return true;
567  return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
568  str.pData->buffer, str.pData->length ) == 0;
569  }
570 
592  template< typename T >
594  {
595  return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
596  }
597 
598  template< typename T >
600  {
601  return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
602  }
603 
609  template< typename T >
611  {
612  RTL_STRING_CONST_FUNCTION
613  assert(
615  return
616  (pData->length
619  pData->buffer, pData->length,
621  literal),
623  == 0);
624  }
625 
645  bool equalsIgnoreAsciiCaseL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
646  {
647  if ( pData->length != asciiStrLength )
648  return false;
649 
650  return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
651  asciiStr, asciiStrLength ) == 0;
652  }
653 
669  bool match( const OString & str, sal_Int32 fromIndex = 0 ) const
670  {
671  return rtl_str_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
672  str.pData->buffer, str.pData->length, str.pData->length ) == 0;
673  }
674 
680  template< typename T >
681  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
682  {
683  RTL_STRING_CONST_FUNCTION
684  assert(
686  return
688  pData->buffer + fromIndex, pData->length - fromIndex,
690  literal),
693  == 0;
694  }
695 
712  bool matchL(
713  char const * str, sal_Int32 strLength, sal_Int32 fromIndex = 0)
714  const
715  {
717  pData->buffer + fromIndex, pData->length - fromIndex,
718  str, strLength, strLength) == 0;
719  }
720 
721  // This overload is left undefined, to detect calls of matchL that
722  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
723  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
724  // platforms):
725 #if SAL_TYPES_SIZEOFLONG == 8
726  void matchL(char const *, sal_Int32, rtl_TextEncoding) const;
727 #endif
728 
747  bool matchIgnoreAsciiCase( const OString & str, sal_Int32 fromIndex = 0 ) const
748  {
749  return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
750  str.pData->buffer, str.pData->length,
751  str.pData->length ) == 0;
752  }
753 
759  template< typename T >
760  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
761  {
762  RTL_STRING_CONST_FUNCTION
763  assert(
765  return
767  pData->buffer+fromIndex, pData->length-fromIndex,
769  literal),
772  == 0;
773  }
774 
789  bool startsWith(OString const & str, OString * rest = NULL) const {
790  bool b = match(str);
791  if (b && rest != NULL) {
792  *rest = copy(str.getLength());
793  }
794  return b;
795  }
796 
802  template< typename T >
804  T & literal, OString * rest = NULL) const
805  {
806  RTL_STRING_CONST_FUNCTION
807  bool b = match(literal, 0);
808  if (b && rest != NULL) {
809  *rest = copy(
811  }
812  return b;
813  }
814 
834  bool startsWithIgnoreAsciiCase(OString const & str, OString * rest = NULL)
835  const
836  {
837  bool b = matchIgnoreAsciiCase(str);
838  if (b && rest != NULL) {
839  *rest = copy(str.getLength());
840  }
841  return b;
842  }
843 
849  template< typename T >
851  startsWithIgnoreAsciiCase(T & literal, OString * rest = NULL) const
852  {
853  RTL_STRING_CONST_FUNCTION
854  assert(
856  bool b = matchIgnoreAsciiCase(literal);
857  if (b && rest != NULL) {
858  *rest = copy(
860  }
861  return b;
862  }
863 
878  bool endsWith(OString const & str, OString * rest = NULL) const {
879  bool b = str.getLength() <= getLength()
880  && match(str, getLength() - str.getLength());
881  if (b && rest != NULL) {
882  *rest = copy(0, getLength() - str.getLength());
883  }
884  return b;
885  }
886 
892  template< typename T >
894  T & literal, OString * rest = NULL) const
895  {
896  RTL_STRING_CONST_FUNCTION
897  assert(
899  bool b
901  <= sal_uInt32(getLength()))
902  && match(
904  literal),
905  (getLength()
907  if (b && rest != NULL) {
908  *rest = copy(
909  0,
910  (getLength()
912  }
913  return b;
914  }
915 
929  bool endsWithL(char const * str, sal_Int32 strLength) const {
930  return strLength <= getLength()
931  && matchL(str, strLength, getLength() - strLength);
932  }
933 
934  friend bool operator == ( const OString& rStr1, const OString& rStr2 )
935  { return rStr1.equals(rStr2); }
936  friend bool operator != ( const OString& rStr1, const OString& rStr2 )
937  { return !(operator == ( rStr1, rStr2 )); }
938  friend bool operator < ( const OString& rStr1, const OString& rStr2 )
939  { return rStr1.compareTo( rStr2 ) < 0; }
940  friend bool operator > ( const OString& rStr1, const OString& rStr2 )
941  { return rStr1.compareTo( rStr2 ) > 0; }
942  friend bool operator <= ( const OString& rStr1, const OString& rStr2 )
943  { return rStr1.compareTo( rStr2 ) <= 0; }
944  friend bool operator >= ( const OString& rStr1, const OString& rStr2 )
945  { return rStr1.compareTo( rStr2 ) >= 0; }
946 
947  template< typename T >
948  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator==( const OString& rStr1, const T& value )
949  {
950  return rStr1.compareTo( value ) == 0;
951  }
952 
953  template< typename T >
955  {
956  return rStr1.compareTo( value ) == 0;
957  }
958 
959  template< typename T >
960  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator==( const T& value, const OString& rStr2 )
961  {
962  return rStr2.compareTo( value ) == 0;
963  }
964 
965  template< typename T >
967  {
968  return rStr2.compareTo( value ) == 0;
969  }
970 
976  template< typename T >
978  {
979  RTL_STRING_CONST_FUNCTION
980  assert(
982  return
983  (rStr.getLength()
986  rStr.pData->buffer, rStr.pData->length,
988  literal),
990  == 0);
991  }
992 
998  template< typename T >
1000  {
1001  RTL_STRING_CONST_FUNCTION
1002  assert(
1004  return
1005  (rStr.getLength()
1008  rStr.pData->buffer, rStr.pData->length,
1010  literal),
1012  == 0);
1013  }
1014 
1015  template< typename T >
1016  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=( const OString& rStr1, const T& value )
1017  {
1018  return !(operator == ( rStr1, value ));
1019  }
1020 
1021  template< typename T >
1023  {
1024  return !(operator == ( rStr1, value ));
1025  }
1026 
1027  template< typename T >
1028  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=( const T& value, const OString& rStr2 )
1029  {
1030  return !(operator == ( value, rStr2 ));
1031  }
1032 
1033  template< typename T >
1035  {
1036  return !(operator == ( value, rStr2 ));
1037  }
1038 
1044  template< typename T >
1046  {
1047  return !( rStr == literal );
1048  }
1049 
1055  template< typename T >
1057  {
1058  return !( literal == rStr );
1059  }
1060 
1068  sal_Int32 hashCode() const
1069  {
1070  return rtl_str_hashCode_WithLength( pData->buffer, pData->length );
1071  }
1072 
1086  sal_Int32 indexOf( sal_Char ch, sal_Int32 fromIndex = 0 ) const
1087  {
1088  sal_Int32 ret = rtl_str_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1089  return (ret < 0 ? ret : ret+fromIndex);
1090  }
1091 
1101  sal_Int32 lastIndexOf( sal_Char ch ) const
1102  {
1103  return rtl_str_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1104  }
1105 
1118  sal_Int32 lastIndexOf( sal_Char ch, sal_Int32 fromIndex ) const
1119  {
1120  return rtl_str_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1121  }
1122 
1138  sal_Int32 indexOf( const OString & str, sal_Int32 fromIndex = 0 ) const
1139  {
1140  sal_Int32 ret = rtl_str_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1141  str.pData->buffer, str.pData->length );
1142  return (ret < 0 ? ret : ret+fromIndex);
1143  }
1144 
1150  template< typename T >
1151  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1152  {
1153  RTL_STRING_CONST_FUNCTION
1154  assert(
1156  sal_Int32 n = rtl_str_indexOfStr_WithLength(
1157  pData->buffer + fromIndex, pData->length - fromIndex,
1160  return n < 0 ? n : n + fromIndex;
1161  }
1162 
1181  sal_Int32 indexOfL(char const * str, sal_Int32 len, sal_Int32 fromIndex = 0)
1182  const
1183  {
1184  sal_Int32 n = rtl_str_indexOfStr_WithLength(
1185  pData->buffer + fromIndex, pData->length - fromIndex, str, len);
1186  return n < 0 ? n : n + fromIndex;
1187  }
1188 
1189  // This overload is left undefined, to detect calls of indexOfL that
1190  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1191  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1192  // platforms):
1193 #if SAL_TYPES_SIZEOFLONG == 8
1194  void indexOfL(char const *, sal_Int32, rtl_TextEncoding) const;
1195 #endif
1196 
1212  sal_Int32 lastIndexOf( const OString & str ) const
1213  {
1214  return rtl_str_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1215  str.pData->buffer, str.pData->length );
1216  }
1217 
1235  sal_Int32 lastIndexOf( const OString & str, sal_Int32 fromIndex ) const
1236  {
1237  return rtl_str_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1238  str.pData->buffer, str.pData->length );
1239  }
1240 
1251  SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex ) const
1252  {
1253  rtl_String *pNew = NULL;
1254  rtl_string_newFromSubString( &pNew, pData, beginIndex, getLength() - beginIndex );
1255  return OString( pNew, SAL_NO_ACQUIRE );
1256  }
1257 
1270  SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex, sal_Int32 count ) const
1271  {
1272  rtl_String *pNew = NULL;
1273  rtl_string_newFromSubString( &pNew, pData, beginIndex, count );
1274  return OString( pNew, SAL_NO_ACQUIRE );
1275  }
1276 
1286  {
1287  rtl_String* pNew = NULL;
1288  rtl_string_newConcat( &pNew, pData, str.pData );
1289  return OString( pNew, SAL_NO_ACQUIRE );
1290  }
1291 
1292 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1293  friend OString operator+( const OString & str1, const OString & str2 )
1294  {
1295  return str1.concat( str2 );
1296  }
1297 #endif
1298 
1312  SAL_WARN_UNUSED_RESULT OString replaceAt( sal_Int32 index, sal_Int32 count, const OString& newStr ) const
1313  {
1314  rtl_String* pNew = NULL;
1315  rtl_string_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
1316  return OString( pNew, SAL_NO_ACQUIRE );
1317  }
1318 
1333  {
1334  rtl_String* pNew = NULL;
1335  rtl_string_newReplace( &pNew, pData, oldChar, newChar );
1336  return OString( pNew, SAL_NO_ACQUIRE );
1337  }
1338 
1358  OString const & from, OString const & to, sal_Int32 * index = NULL) const
1359  {
1360  rtl_String * s = NULL;
1361  sal_Int32 i = 0;
1363  &s, pData, from.pData->buffer, from.pData->length,
1364  to.pData->buffer, to.pData->length, index == NULL ? &i : index);
1365  return OString(s, SAL_NO_ACQUIRE);
1366  }
1367 
1381  SAL_WARN_UNUSED_RESULT OString replaceAll(OString const & from, OString const & to) const {
1382  rtl_String * s = NULL;
1384  &s, pData, from.pData->buffer, from.pData->length,
1385  to.pData->buffer, to.pData->length);
1386  return OString(s, SAL_NO_ACQUIRE);
1387  }
1388 
1400  {
1401  rtl_String* pNew = NULL;
1402  rtl_string_newToAsciiLowerCase( &pNew, pData );
1403  return OString( pNew, SAL_NO_ACQUIRE );
1404  }
1405 
1417  {
1418  rtl_String* pNew = NULL;
1419  rtl_string_newToAsciiUpperCase( &pNew, pData );
1420  return OString( pNew, SAL_NO_ACQUIRE );
1421  }
1422 
1435  {
1436  rtl_String* pNew = NULL;
1437  rtl_string_newTrim( &pNew, pData );
1438  return OString( pNew, SAL_NO_ACQUIRE );
1439  }
1440 
1465  OString getToken( sal_Int32 token, sal_Char cTok, sal_Int32& index ) const
1466  {
1467  rtl_String * pNew = NULL;
1468  index = rtl_string_getToken( &pNew, pData, token, cTok, index );
1469  return OString( pNew, SAL_NO_ACQUIRE );
1470  }
1471 
1485  OString getToken(sal_Int32 count, char separator) const {
1486  sal_Int32 n = 0;
1487  return getToken(count, separator, n);
1488  }
1489 
1498  bool toBoolean() const
1499  {
1500  return rtl_str_toBoolean( pData->buffer );
1501  }
1502 
1510  {
1511  return pData->buffer[0];
1512  }
1513 
1524  sal_Int32 toInt32( sal_Int16 radix = 10 ) const
1525  {
1526  return rtl_str_toInt32( pData->buffer, radix );
1527  }
1528 
1541  sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
1542  {
1543  return rtl_str_toUInt32( pData->buffer, radix );
1544  }
1545 
1556  sal_Int64 toInt64( sal_Int16 radix = 10 ) const
1557  {
1558  return rtl_str_toInt64( pData->buffer, radix );
1559  }
1560 
1573  sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
1574  {
1575  return rtl_str_toUInt64( pData->buffer, radix );
1576  }
1577 
1586  float toFloat() const
1587  {
1588  return rtl_str_toFloat( pData->buffer );
1589  }
1590 
1599  double toDouble() const
1600  {
1601  return rtl_str_toDouble( pData->buffer );
1602  }
1603 
1614  static OString number( int i, sal_Int16 radix = 10 )
1615  {
1616  return number( static_cast< long long >( i ), radix );
1617  }
1620  static OString number( unsigned int i, sal_Int16 radix = 10 )
1621  {
1622  return number( static_cast< unsigned long long >( i ), radix );
1623  }
1626  static OString number( long i, sal_Int16 radix = 10 )
1627  {
1628  return number( static_cast< long long >( i ), radix );
1629  }
1632  static OString number( unsigned long i, sal_Int16 radix = 10 )
1633  {
1634  return number( static_cast< unsigned long long >( i ), radix );
1635  }
1638  static OString number( long long ll, sal_Int16 radix = 10 )
1639  {
1641  rtl_String* pNewData = NULL;
1642  rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfInt64( aBuf, ll, radix ) );
1643  return OString( pNewData, SAL_NO_ACQUIRE );
1644  }
1647  static OString number( unsigned long long ll, sal_Int16 radix = 10 )
1648  {
1650  rtl_String* pNewData = NULL;
1651  rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfUInt64( aBuf, ll, radix ) );
1652  return OString( pNewData, SAL_NO_ACQUIRE );
1653  }
1654 
1664  static OString number( float f )
1665  {
1667  rtl_String* pNewData = NULL;
1668  rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfFloat( aBuf, f ) );
1669  return OString( pNewData, SAL_NO_ACQUIRE );
1670  }
1671 
1681  static OString number( double d )
1682  {
1684  rtl_String* pNewData = NULL;
1685  rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfDouble( aBuf, d ) );
1686  return OString( pNewData, SAL_NO_ACQUIRE );
1687  }
1688 
1700  SAL_DEPRECATED("use boolean()") static OString valueOf( sal_Bool b )
1701  {
1702  return boolean(b);
1703  }
1704 
1716  static OString boolean( bool b )
1717  {
1719  rtl_String* pNewData = NULL;
1720  rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfBoolean( aBuf, b ) );
1721  return OString( pNewData, SAL_NO_ACQUIRE );
1722  }
1723 
1731  SAL_DEPRECATED("convert to OString or use directly") static OString valueOf( sal_Char c )
1732  {
1733  return OString( &c, 1 );
1734  }
1735 
1746  SAL_DEPRECATED("use number()") static OString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
1747  {
1748  return number( i, radix );
1749  }
1750 
1761  SAL_DEPRECATED("use number()") static OString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
1762  {
1763  return number( ll, radix );
1764  }
1765 
1775  SAL_DEPRECATED("use number()") static OString valueOf( float f )
1776  {
1777  return number(f);
1778  }
1779 
1789  SAL_DEPRECATED("use number()") static OString valueOf( double d )
1790  {
1791  return number(d);
1792  }
1793 
1794 };
1795 
1796 /* ======================================================================= */
1797 
1798 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1799 
1807 struct SAL_WARN_UNUSED OStringLiteral
1808 {
1809  template< int N >
1810  explicit OStringLiteral( const char (&str)[ N ] ) : size( N - 1 ), data( str ) { assert( strlen( str ) == N - 1 ); }
1811  int size;
1812  const char* data;
1813 };
1814 
1818 template<>
1819 struct ToStringHelper< OString >
1820  {
1821  static int length( const OString& s ) { return s.getLength(); }
1822  static char* addData( char* buffer, const OString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
1823  static const bool allowOStringConcat = true;
1824  static const bool allowOUStringConcat = false;
1825  };
1826 
1830 template<>
1831 struct ToStringHelper< OStringLiteral >
1832  {
1833  static int length( const OStringLiteral& str ) { return str.size; }
1834  static char* addData( char* buffer, const OStringLiteral& str ) { return addDataHelper( buffer, str.data, str.size ); }
1835  static const bool allowOStringConcat = true;
1836  static const bool allowOUStringConcat = false;
1837  };
1838 
1842 template< typename charT, typename traits, typename T1, typename T2 >
1843 inline std::basic_ostream<charT, traits> & operator <<(
1844  std::basic_ostream<charT, traits> & stream, const OStringConcat< T1, T2 >& concat)
1845 {
1846  return stream << OString( concat );
1847 }
1848 #endif
1849 
1850 
1857 {
1867  size_t operator()( const OString& rString ) const
1868  { return (size_t)rString.hashCode(); }
1869 };
1870 
1873 {
1874  bool operator()( const char* p1, const char* p2) const
1875  { return rtl_str_compare(p1, p2) == 0; }
1876 };
1877 
1880 {
1881  size_t operator()(const char* p) const
1882  { return rtl_str_hashCode(p); }
1883 };
1884 
1885 /* ======================================================================= */
1886 
1893 template< typename charT, typename traits > std::basic_ostream<charT, traits> &
1895  std::basic_ostream<charT, traits> & stream, OString const & rString)
1896 {
1897  return stream << rString.getStr();
1898  // best effort; potentially loses data due to embedded null characters
1899 }
1900 
1901 } /* Namespace */
1902 
1903 #ifdef RTL_STRING_UNITTEST
1904 namespace rtl
1905 {
1906 typedef rtlunittest::OString OString;
1907 }
1908 #undef RTL_STRING_CONST_FUNCTION
1909 #endif
1910 
1911 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
1912 using ::rtl::OString;
1913 using ::rtl::OStringHash;
1914 using ::rtl::OStringLiteral;
1915 #endif
1916 
1917 #endif // INCLUDED_RTL_STRING_HXX
1918 
1919 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC sal_Bool rtl_str_toBoolean(const sal_Char *str) SAL_THROW_EXTERN_C()
Interpret a string as a boolean.
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &stream, OString const &rString)
Support for rtl::OString in std::ostream (and thus in CPPUNIT_ASSERT or SAL_INFO macros, for example).
Definition: string.hxx:1894
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_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 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...
sal_Char toChar() const
Returns the first character from this string.
Definition: string.hxx:1509
friend OString operator+(const OString &str1, const OString &str2)
Definition: string.hxx:1293
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:681
SAL_DLLPUBLIC float rtl_str_toFloat(const sal_Char *str) SAL_THROW_EXTERN_C()
Interpret a string as a float.
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.
float toFloat() const
Returns the float value from this string.
Definition: string.hxx:1586
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:1086
#define RTL_STR_MAX_VALUEOFDOUBLE
Definition: string.h:711
sal_Int32 reverseCompareTo(const OString &str) const
Compares two strings in reverse order.
Definition: string.hxx:496
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type endsWith(T &literal, OString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:893
OString(rtl_String *str)
New string from OString data.
Definition: string.hxx:139
char sal_Char
A legacy synonym for char.
Definition: types.h:130
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.
OString getToken(sal_Int32 count, char separator) const
Returns a token from the string.
Definition: string.hxx:1485
bool equals(const OString &str) const
Perform a comparison of two strings.
Definition: string.hxx:513
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.
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...
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:326
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:1138
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWith(T &literal, OString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:803
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=(const OString &rStr1, const T &value)
Definition: string.hxx:1016
sal_Int32 compareTo(const OString &rObj, sal_Int32 maxLength) const
Compares two strings with an maximum count of characters.
Definition: string.hxx:478
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:624
OString getToken(sal_Int32 token, sal_Char cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: string.hxx:1465
SAL_DLLPUBLIC void rtl_string_newFromLiteral(rtl_String **newStr, const sal_Char *value, sal_Int32 len, sal_Int32 allocExtra) SAL_THROW_EXTERN_C()
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator!=(T &value, const OString &rStr2)
Definition: string.hxx:1034
OString & operator+=(const OString &str)
Append a string to this string.
Definition: string.hxx:348
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:610
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:1151
SAL_DLLPUBLIC sal_Int32 rtl_str_hashCode(const sal_Char *str) SAL_THROW_EXTERN_C()
Return a hash code for a string.
~OString()
Release the string data.
Definition: string.hxx:285
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.
A helper to use OStrings with hash maps.
Definition: string.hxx:1856
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...
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...
OString(const OString &str)
New string from OString.
Definition: string.hxx:111
static OString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: string.hxx:1716
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:248
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:1212
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:1647
OString(const sal_Char *value, sal_Int32 length)
New string from a character buffer array.
Definition: string.hxx:228
SAL_DLLPUBLIC sal_Int32 rtl_str_compare(const sal_Char *first, const sal_Char *second) SAL_THROW_EXTERN_C()
Compare two strings.
bool equalsL(const sal_Char *value, sal_Int32 length) const
Perform a comparison of two strings.
Definition: string.hxx:538
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:1235
SAL_WARN_UNUSED_RESULT OString replaceFirst(OString const &from, OString const &to, sal_Int32 *index=NULL) const
Returns a new string resulting from replacing the first occurrence of a given substring with another ...
Definition: string.hxx:1357
#define RTL_STR_MAX_VALUEOFUINT64
Definition: string.h:673
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:1101
static OString number(double d)
Returns the string representation of the double argument.
Definition: string.hxx:1681
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==(T &literal, const OString &rStr)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:999
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:1332
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.
OString(sal_Char value)
New string from a single character.
Definition: string.hxx:162
bool startsWithIgnoreAsciiCase(OString const &str, OString *rest=NULL) const
Check whether this string starts with a given string, ignoring the case of ASCII letters.
Definition: string.hxx:834
unsigned char sal_Bool
Definition: types.h:48
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:96
const sal_Char * getStr() const
Returns a pointer to the characters of this string.
Definition: string.hxx:430
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: string.hxx:391
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=(const T &value, const OString &rStr2)
Definition: string.hxx:1028
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:1626
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 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:1381
sal_Int32 compareTo(const OString &str) const
Compares two strings.
Definition: string.hxx:459
bool isEmpty() const
Checks if a string is empty.
Definition: string.hxx:414
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.
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator==(const T &value, const OString &rStr2)
Definition: string.hxx:960
bool equalsIgnoreAsciiCaseL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform a ASCII lowercase comparison of two strings.
Definition: string.hxx:645
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::NonConstCharArrayDetector< T, bool >::Type operator==(const OString &rStr1, T &value)
Definition: string.hxx:954
OString(T &literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
New string from a string literal.
Definition: string.hxx:201
bool operator>(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:106
SAL_WARN_UNUSED_RESULT OString concat(const OString &str) const
Concatenates the specified string to the end of this string.
Definition: string.hxx:1285
bool operator!=(const Any &rAny, const C &value)
Template unequality operator: compares set value of left side any to right side value.
Definition: Any.hxx:606
__sal_NoAcquire
Definition: types.h:384
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:760
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.
#define SAL_WARN_UNUSED_RESULT
Use this as markup for functions and methods whose return value must be checked.
Definition: types.h:325
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:1056
Definition: stringutils.hxx:117
bool operator()(const char *p1, const char *p2) const
Definition: string.hxx:1874
SAL_DLLPUBLIC sal_Int32 rtl_str_toInt32(const sal_Char *str, sal_Int16 radix) SAL_THROW_EXTERN_C()
Interpret a string as an integer.
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.
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_uInt16 sal_Unicode
Definition: types.h:155
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:1270
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.
libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type equalsIgnoreAsciiCase(T &asciiStr) const
Definition: string.hxx:599
SAL_DLLPUBLIC sal_Int32 rtl_str_valueOfFloat(sal_Char *str, float f) SAL_THROW_EXTERN_C()
Create the string representation of a float.
#define RTL_STR_MAX_VALUEOFBOOLEAN
Definition: string.h:585
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.
bool endsWith(OString const &str, OString *rest=NULL) const
Check whether this string ends with a given substring.
Definition: string.hxx:878
bool toBoolean() const
Returns the Boolean value from this string.
Definition: string.hxx:1498
SAL_WARN_UNUSED_RESULT OString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: string.hxx:1251
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: string.hxx:1541
SAL_DLLPUBLIC void rtl_string_release(rtl_String *str) SAL_THROW_EXTERN_C()
Decrement the reference count of a string.
bool equalsIgnoreAsciiCase(const OString &str) const
Perform a ASCII lowercase comparison of two strings.
Definition: string.hxx:561
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:39
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:1632
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: string.hxx:1068
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.
static OString number(int i, sal_Int16 radix=10)
Returns the string representation of the integer argument.
Definition: string.hxx:1614
OString & operator=(const OString &str)
Assign a new string.
Definition: string.hxx:295
libreoffice_internal::CharPtrDetector< T, bool >::Type equalsIgnoreAsciiCase(const T &asciiStr) const
Perform a ASCII lowercase comparison of two strings.
Definition: string.hxx:593
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:1181
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:1312
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:1620
definition of a no acquire enum for ctors
Definition: types.h:388
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator==(const OString &rStr1, const T &value)
Definition: string.hxx:948
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED(&quot;Don&#39;t use, it&#39;s evil.&quot;) void doit(int nPara);.
Definition: types.h:509
SAL_DLLPUBLIC void rtl_string_new(rtl_String **newStr) SAL_THROW_EXTERN_C()
Allocate a new string containing no characters.
sal_uInt64 toUInt64(sal_Int16 radix=10) const
Returns the uint64 value from this string.
Definition: string.hxx:1573
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator!=(const OString &rStr1, T &value)
Definition: string.hxx:1022
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:404
bool match(const OString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: string.hxx:669
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator==(T &value, const OString &rStr2)
Definition: string.hxx:966
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.
OString(T &value, typename libreoffice_internal::NonConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
Definition: string.hxx:184
SAL_DLLPUBLIC void rtl_string_acquire(rtl_String *str) SAL_THROW_EXTERN_C()
Increment the reference count of a string.
bool endsWithL(char const *str, sal_Int32 strLength) const
Check whether this string ends with a given substring.
Definition: string.hxx:929
Hashing functor for classic c-strings (i.e., null-terminated char* strings).
Definition: string.hxx:1879
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:1416
bool operator==(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:116
static OString number(float f)
Returns the string representation of the float argument.
Definition: string.hxx:1664
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:1399
OString()
New string containing no characters.
Definition: string.hxx:100
SAL_DLLPUBLIC double rtl_str_toDouble(const sal_Char *str) SAL_THROW_EXTERN_C()
Interpret a string as a double.
sal_Int64 toInt64(sal_Int16 radix=10) const
Returns the int64 value from this string.
Definition: string.hxx:1556
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:977
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_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.
Definition: stringutils.hxx:115
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...
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:177
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.
size_t operator()(const OString &rString) const
Compute a hash code for a string.
Definition: string.hxx:1867
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:1434
#define RTL_STR_MAX_VALUEOFINT64
Definition: string.h:650
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.
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:1045
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: string.hxx:1524
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:1118
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:1638
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.
double toDouble() const
Returns the double value from this string.
Definition: string.hxx:1599
bool matchL(char const *str, sal_Int32 strLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: string.hxx:712
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.
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.
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:747
size_t operator()(const char *p) const
Definition: string.hxx:1881
OString(rtl_String *str, __sal_NoAcquire)
New string from OString data without acquiring it.
Definition: string.hxx:152
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.
#define RTL_STR_MAX_VALUEOFFLOAT
Definition: string.h:692
SAL_DLLPUBLIC void rtl_string_assign(rtl_String **str, rtl_String *rightValue) SAL_THROW_EXTERN_C()
Assign a new value to a string.
This String class provide base functionality for C++ like 8-Bit character array handling.
Definition: string.hxx:90
libreoffice_internal::ConstCharArrayDetector< T, bool >::Type startsWithIgnoreAsciiCase(T &literal, OString *rest=NULL) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: string.hxx:851
Equality functor for classic c-strings (i.e., null-terminated char* strings).
Definition: string.hxx:1872
bool startsWith(OString const &str, OString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: string.hxx:789
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1324