LibreOffice
LibreOffice 6.0 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 #ifdef RTL_STRING_UNITTEST
42 extern bool rtl_string_unittest_const_literal;
43 extern bool rtl_string_unittest_const_literal_function;
44 #endif
45 
46 // The unittest uses slightly different code to help check that the proper
47 // calls are made. The class is put into a different namespace to make
48 // sure the compiler generates a different (if generating also non-inline)
49 // copy of the function and does not merge them together. The class
50 // is "brought" into the proper rtl namespace by a typedef below.
51 #ifdef RTL_STRING_UNITTEST
52 #define rtl rtlunittest
53 #endif
54 
55 namespace rtl
56 {
57 
59 #ifdef RTL_STRING_UNITTEST
60 #undef rtl
61 // helper macro to make functions appear more readable
62 #define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true;
63 #else
64 #define RTL_STRING_CONST_FUNCTION
65 #endif
66 
68 /* ======================================================================= */
69 
94 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI OString
95 {
96 public:
98  rtl_String * pData;
100 
105  {
106  pData = NULL;
107  rtl_string_new( &pData );
108  }
109 
115  OString( const OString & str )
116  {
117  pData = str.pData;
118  rtl_string_acquire( pData );
119  }
120 
121 #ifndef _MSC_VER // TODO?
122 #if defined LIBO_INTERNAL_ONLY
123 
129  OString( OString && str )
130  {
131  pData = str.pData;
132  str.pData = nullptr;
133  rtl_string_new( &str.pData );
134  }
135 #endif
136 #endif
137 
143  OString( rtl_String * str )
144  {
145  pData = str;
146  rtl_string_acquire( pData );
147  }
148 
156  OString( rtl_String * str, __sal_NoAcquire )
157  {
158  pData = str;
159  }
160 
166  explicit OString( sal_Char value )
167  : pData (NULL)
168  {
169  rtl_string_newFromStr_WithLength( &pData, &value, 1 );
170  }
171 
180  template< typename T >
182  {
183  pData = NULL;
184  rtl_string_newFromStr( &pData, value );
185  }
186 
187  template< typename T >
189  {
190  pData = NULL;
191  rtl_string_newFromStr( &pData, value );
192  }
193 
204  template< typename T >
206  {
207  assert(
209  pData = NULL;
211  rtl_string_new(&pData);
212  } else {
214  &pData,
216  literal),
218  }
219 #ifdef RTL_STRING_UNITTEST
220  rtl_string_unittest_const_literal = true;
221 #endif
222  }
223 
232  OString( const sal_Char * value, sal_Int32 length )
233  {
234  pData = NULL;
235  rtl_string_newFromStr_WithLength( &pData, value, length );
236  }
237 
252  OString( const sal_Unicode * value, sal_Int32 length,
253  rtl_TextEncoding encoding,
254  sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
255  {
256  pData = NULL;
257  rtl_uString2String( &pData, value, length, encoding, convertFlags );
258  if (pData == NULL) {
259  throw std::bad_alloc();
260  }
261  }
262 
263 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
264 
268  template< typename T1, typename T2 >
269  OString( const OStringConcat< T1, T2 >& c )
270  {
271  const sal_Int32 l = c.length();
272  pData = rtl_string_alloc( l );
273  if (l != 0)
274  {
275  char* end = c.addData( pData->buffer );
276  pData->length = l;
277  *end = '\0';
278  }
279  }
280 #endif
281 
282 #ifdef LIBO_INTERNAL_ONLY
283  OString(std::nullptr_t) = delete;
284 #endif
285 
290  {
291  rtl_string_release( pData );
292  }
293 
299  OString & operator=( const OString & str )
300  {
301  rtl_string_assign( &pData, str.pData );
302  return *this;
303  }
304 
305 #ifndef _MSC_VER // TODO?
306 #if defined LIBO_INTERNAL_ONLY
307 
313  OString & operator=( OString && str )
314  {
315  rtl_string_release( pData );
316  pData = str.pData;
317  str.pData = nullptr;
318  rtl_string_new( &str.pData );
319  return *this;
320  }
321 #endif
322 #endif
323 
329  template< typename T >
331  {
332  RTL_STRING_CONST_FUNCTION
333  assert(
336  rtl_string_new(&pData);
337  } else {
339  &pData,
341  literal),
343  }
344  return *this;
345  }
346 
352  OString & operator+=( const OString & str )
353 #if defined LIBO_INTERNAL_ONLY
354  &
355 #endif
356  {
357  rtl_string_newConcat( &pData, pData, str.pData );
358  return *this;
359  }
360 #if defined LIBO_INTERNAL_ONLY
361  void operator+=(OString const &) && = delete;
362 #endif
363 
364 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
365 
369  template< typename T1, typename T2 >
370  OString& operator+=( const OStringConcat< T1, T2 >& c ) & {
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  template<typename T1, typename T2> void operator +=(
382  OStringConcat<T1, T2> const &) && = delete;
383 #endif
384 
389  void clear()
390  {
391  rtl_string_new( &pData );
392  }
393 
402  sal_Int32 getLength() const { return pData->length; }
403 
412  bool isEmpty() const
413  {
414  return pData->length == 0;
415  }
416 
428  const sal_Char * getStr() const SAL_RETURNS_NONNULL { return pData->buffer; }
429 
439  sal_Char operator [](sal_Int32 index) const {
440  // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
441  assert(index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
442  return getStr()[index];
443  }
444 
457  sal_Int32 compareTo( const OString & str ) const
458  {
459  return rtl_str_compare_WithLength( pData->buffer, pData->length,
460  str.pData->buffer, str.pData->length );
461  }
462 
476  sal_Int32 compareTo( const OString & rObj, sal_Int32 maxLength ) const
477  {
478  return rtl_str_shortenedCompare_WithLength( pData->buffer, pData->length,
479  rObj.pData->buffer, rObj.pData->length, maxLength );
480  }
481 
494  sal_Int32 reverseCompareTo( const OString & str ) const
495  {
496  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
497  str.pData->buffer, str.pData->length );
498  }
499 
511  bool equals( 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_reverseCompare_WithLength( pData->buffer, pData->length,
518  str.pData->buffer, str.pData->length ) == 0;
519  }
520 
536  bool equalsL( const sal_Char* value, sal_Int32 length ) const
537  {
538  if ( pData->length != length )
539  return false;
540 
541  return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
542  value, length ) == 0;
543  }
544 
559  bool equalsIgnoreAsciiCase( const OString & str ) const
560  {
561  if ( pData->length != str.pData->length )
562  return false;
563  if ( pData == str.pData )
564  return true;
565  return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
566  str.pData->buffer, str.pData->length ) == 0;
567  }
568 
590  template< typename T >
592  {
593  return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
594  }
595 
596  template< typename T >
598  {
599  return rtl_str_compareIgnoreAsciiCase( pData->buffer, asciiStr ) == 0;
600  }
601 
607  template< typename T >
609  {
610  RTL_STRING_CONST_FUNCTION
611  assert(
613  return
614  (pData->length
617  pData->buffer, pData->length,
619  literal),
621  == 0);
622  }
623 
643  bool equalsIgnoreAsciiCaseL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const
644  {
645  if ( pData->length != asciiStrLength )
646  return false;
647 
648  return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
649  asciiStr, asciiStrLength ) == 0;
650  }
651 
667  bool match( const OString & str, sal_Int32 fromIndex = 0 ) const
668  {
669  return rtl_str_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
670  str.pData->buffer, str.pData->length, str.pData->length ) == 0;
671  }
672 
678  template< typename T >
679  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type match( T& literal, sal_Int32 fromIndex = 0 ) const
680  {
681  RTL_STRING_CONST_FUNCTION
682  assert(
684  return
686  pData->buffer + fromIndex, pData->length - fromIndex,
688  literal),
691  == 0;
692  }
693 
710  bool matchL(
711  char const * str, sal_Int32 strLength, sal_Int32 fromIndex = 0)
712  const
713  {
715  pData->buffer + fromIndex, pData->length - fromIndex,
716  str, strLength, strLength) == 0;
717  }
718 
719  // This overload is left undefined, to detect calls of matchL that
720  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
721  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
722  // platforms):
723 #if SAL_TYPES_SIZEOFLONG == 8
724  void matchL(char const *, sal_Int32, rtl_TextEncoding) const;
725 #endif
726 
745  bool matchIgnoreAsciiCase( const OString & str, sal_Int32 fromIndex = 0 ) const
746  {
747  return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
748  str.pData->buffer, str.pData->length,
749  str.pData->length ) == 0;
750  }
751 
757  template< typename T >
758  typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type matchIgnoreAsciiCase( T& literal, sal_Int32 fromIndex = 0 ) const
759  {
760  RTL_STRING_CONST_FUNCTION
761  assert(
763  return
765  pData->buffer+fromIndex, pData->length-fromIndex,
767  literal),
770  == 0;
771  }
772 
787  bool startsWith(OString const & str, OString * rest = NULL) const {
788  bool b = match(str);
789  if (b && rest != NULL) {
790  *rest = copy(str.getLength());
791  }
792  return b;
793  }
794 
800  template< typename T >
802  T & literal, OString * rest = NULL) const
803  {
804  RTL_STRING_CONST_FUNCTION
805  bool b = match(literal, 0);
806  if (b && rest != NULL) {
807  *rest = copy(
809  }
810  return b;
811  }
812 
832  bool startsWithIgnoreAsciiCase(OString const & str, OString * rest = NULL)
833  const
834  {
835  bool b = matchIgnoreAsciiCase(str);
836  if (b && rest != NULL) {
837  *rest = copy(str.getLength());
838  }
839  return b;
840  }
841 
847  template< typename T >
849  startsWithIgnoreAsciiCase(T & literal, OString * rest = NULL) const
850  {
851  RTL_STRING_CONST_FUNCTION
852  assert(
854  bool b = matchIgnoreAsciiCase(literal);
855  if (b && rest != NULL) {
856  *rest = copy(
858  }
859  return b;
860  }
861 
876  bool endsWith(OString const & str, OString * rest = NULL) const {
877  bool b = str.getLength() <= getLength()
878  && match(str, getLength() - str.getLength());
879  if (b && rest != NULL) {
880  *rest = copy(0, getLength() - str.getLength());
881  }
882  return b;
883  }
884 
890  template< typename T >
892  T & literal, OString * rest = NULL) const
893  {
894  RTL_STRING_CONST_FUNCTION
895  assert(
897  bool b
899  <= sal_uInt32(getLength()))
900  && match(
902  literal),
903  (getLength()
905  if (b && rest != NULL) {
906  *rest = copy(
907  0,
908  (getLength()
910  }
911  return b;
912  }
913 
927  bool endsWithL(char const * str, sal_Int32 strLength) const {
928  return strLength <= getLength()
929  && matchL(str, strLength, getLength() - strLength);
930  }
931 
932  friend bool operator == ( const OString& rStr1, const OString& rStr2 )
933  { return rStr1.equals(rStr2); }
934  friend bool operator != ( const OString& rStr1, const OString& rStr2 )
935  { return !(operator == ( rStr1, rStr2 )); }
936  friend bool operator < ( const OString& rStr1, const OString& rStr2 )
937  { return rStr1.compareTo( rStr2 ) < 0; }
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 
945  template< typename T >
946  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator==( const OString& rStr1, const T& value )
947  {
948  return rStr1.compareTo( value ) == 0;
949  }
950 
951  template< typename T >
953  {
954  return rStr1.compareTo( value ) == 0;
955  }
956 
957  template< typename T >
958  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator==( const T& value, const OString& rStr2 )
959  {
960  return rStr2.compareTo( value ) == 0;
961  }
962 
963  template< typename T >
965  {
966  return rStr2.compareTo( value ) == 0;
967  }
968 
974  template< typename T >
976  {
977  RTL_STRING_CONST_FUNCTION
978  assert(
980  return
981  (rStr.getLength()
984  rStr.pData->buffer, rStr.pData->length,
986  literal),
988  == 0);
989  }
990 
996  template< typename T >
998  {
999  RTL_STRING_CONST_FUNCTION
1000  assert(
1002  return
1003  (rStr.getLength()
1006  rStr.pData->buffer, rStr.pData->length,
1008  literal),
1010  == 0);
1011  }
1012 
1013  template< typename T >
1014  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=( const OString& rStr1, const T& value )
1015  {
1016  return !(operator == ( rStr1, value ));
1017  }
1018 
1019  template< typename T >
1021  {
1022  return !(operator == ( rStr1, value ));
1023  }
1024 
1025  template< typename T >
1026  friend typename libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=( const T& value, const OString& rStr2 )
1027  {
1028  return !(operator == ( value, rStr2 ));
1029  }
1030 
1031  template< typename T >
1033  {
1034  return !(operator == ( value, rStr2 ));
1035  }
1036 
1042  template< typename T >
1044  {
1045  return !( rStr == literal );
1046  }
1047 
1053  template< typename T >
1055  {
1056  return !( literal == rStr );
1057  }
1058 
1066  sal_Int32 hashCode() const
1067  {
1068  return rtl_str_hashCode_WithLength( pData->buffer, pData->length );
1069  }
1070 
1084  sal_Int32 indexOf( sal_Char ch, sal_Int32 fromIndex = 0 ) const
1085  {
1086  sal_Int32 ret = rtl_str_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
1087  return (ret < 0 ? ret : ret+fromIndex);
1088  }
1089 
1099  sal_Int32 lastIndexOf( sal_Char ch ) const
1100  {
1101  return rtl_str_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
1102  }
1103 
1116  sal_Int32 lastIndexOf( sal_Char ch, sal_Int32 fromIndex ) const
1117  {
1118  return rtl_str_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
1119  }
1120 
1136  sal_Int32 indexOf( const OString & str, sal_Int32 fromIndex = 0 ) const
1137  {
1138  sal_Int32 ret = rtl_str_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
1139  str.pData->buffer, str.pData->length );
1140  return (ret < 0 ? ret : ret+fromIndex);
1141  }
1142 
1148  template< typename T >
1149  typename libreoffice_internal::ConstCharArrayDetector< T, sal_Int32 >::Type indexOf( T& literal, sal_Int32 fromIndex = 0 ) const
1150  {
1151  RTL_STRING_CONST_FUNCTION
1152  assert(
1154  sal_Int32 n = rtl_str_indexOfStr_WithLength(
1155  pData->buffer + fromIndex, pData->length - fromIndex,
1158  return n < 0 ? n : n + fromIndex;
1159  }
1160 
1179  sal_Int32 indexOfL(char const * str, sal_Int32 len, sal_Int32 fromIndex = 0)
1180  const
1181  {
1182  sal_Int32 n = rtl_str_indexOfStr_WithLength(
1183  pData->buffer + fromIndex, pData->length - fromIndex, str, len);
1184  return n < 0 ? n : n + fromIndex;
1185  }
1186 
1187  // This overload is left undefined, to detect calls of indexOfL that
1188  // erroneously use RTL_CONSTASCII_USTRINGPARAM instead of
1189  // RTL_CONSTASCII_STRINGPARAM (but would lead to ambiguities on 32 bit
1190  // platforms):
1191 #if SAL_TYPES_SIZEOFLONG == 8
1192  void indexOfL(char const *, sal_Int32, rtl_TextEncoding) const;
1193 #endif
1194 
1210  sal_Int32 lastIndexOf( const OString & str ) const
1211  {
1212  return rtl_str_lastIndexOfStr_WithLength( pData->buffer, pData->length,
1213  str.pData->buffer, str.pData->length );
1214  }
1215 
1233  sal_Int32 lastIndexOf( const OString & str, sal_Int32 fromIndex ) const
1234  {
1235  return rtl_str_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
1236  str.pData->buffer, str.pData->length );
1237  }
1238 
1249  SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex ) const
1250  {
1251  rtl_String *pNew = NULL;
1252  rtl_string_newFromSubString( &pNew, pData, beginIndex, getLength() - beginIndex );
1253  return OString( pNew, SAL_NO_ACQUIRE );
1254  }
1255 
1268  SAL_WARN_UNUSED_RESULT OString copy( sal_Int32 beginIndex, sal_Int32 count ) const
1269  {
1270  rtl_String *pNew = NULL;
1271  rtl_string_newFromSubString( &pNew, pData, beginIndex, count );
1272  return OString( pNew, SAL_NO_ACQUIRE );
1273  }
1274 
1284  {
1285  rtl_String* pNew = NULL;
1286  rtl_string_newConcat( &pNew, pData, str.pData );
1287  return OString( pNew, SAL_NO_ACQUIRE );
1288  }
1289 
1290 #ifndef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1291  friend OString operator+( const OString & str1, const OString & str2 )
1292  {
1293  return str1.concat( str2 );
1294  }
1295 #endif
1296 
1310  SAL_WARN_UNUSED_RESULT OString replaceAt( sal_Int32 index, sal_Int32 count, const OString& newStr ) const
1311  {
1312  rtl_String* pNew = NULL;
1313  rtl_string_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
1314  return OString( pNew, SAL_NO_ACQUIRE );
1315  }
1316 
1331  {
1332  rtl_String* pNew = NULL;
1333  rtl_string_newReplace( &pNew, pData, oldChar, newChar );
1334  return OString( pNew, SAL_NO_ACQUIRE );
1335  }
1336 
1356  OString const & from, OString const & to, sal_Int32 * index = NULL) const
1357  {
1358  rtl_String * s = NULL;
1359  sal_Int32 i = 0;
1361  &s, pData, from.pData->buffer, from.pData->length,
1362  to.pData->buffer, to.pData->length, index == NULL ? &i : index);
1363  return OString(s, SAL_NO_ACQUIRE);
1364  }
1365 
1379  SAL_WARN_UNUSED_RESULT OString replaceAll(OString const & from, OString const & to) const {
1380  rtl_String * s = NULL;
1382  &s, pData, from.pData->buffer, from.pData->length,
1383  to.pData->buffer, to.pData->length);
1384  return OString(s, SAL_NO_ACQUIRE);
1385  }
1386 
1398  {
1399  rtl_String* pNew = NULL;
1400  rtl_string_newToAsciiLowerCase( &pNew, pData );
1401  return OString( pNew, SAL_NO_ACQUIRE );
1402  }
1403 
1415  {
1416  rtl_String* pNew = NULL;
1417  rtl_string_newToAsciiUpperCase( &pNew, pData );
1418  return OString( pNew, SAL_NO_ACQUIRE );
1419  }
1420 
1433  {
1434  rtl_String* pNew = NULL;
1435  rtl_string_newTrim( &pNew, pData );
1436  return OString( pNew, SAL_NO_ACQUIRE );
1437  }
1438 
1463  OString getToken( sal_Int32 token, sal_Char cTok, sal_Int32& index ) const
1464  {
1465  rtl_String * pNew = NULL;
1466  index = rtl_string_getToken( &pNew, pData, token, cTok, index );
1467  return OString( pNew, SAL_NO_ACQUIRE );
1468  }
1469 
1483  OString getToken(sal_Int32 count, char separator) const {
1484  sal_Int32 n = 0;
1485  return getToken(count, separator, n);
1486  }
1487 
1496  bool toBoolean() const
1497  {
1498  return rtl_str_toBoolean( pData->buffer );
1499  }
1500 
1508  {
1509  return pData->buffer[0];
1510  }
1511 
1522  sal_Int32 toInt32( sal_Int16 radix = 10 ) const
1523  {
1524  return rtl_str_toInt32( pData->buffer, radix );
1525  }
1526 
1539  sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const
1540  {
1541  return rtl_str_toUInt32( pData->buffer, radix );
1542  }
1543 
1554  sal_Int64 toInt64( sal_Int16 radix = 10 ) const
1555  {
1556  return rtl_str_toInt64( pData->buffer, radix );
1557  }
1558 
1571  sal_uInt64 toUInt64( sal_Int16 radix = 10 ) const
1572  {
1573  return rtl_str_toUInt64( pData->buffer, radix );
1574  }
1575 
1584  float toFloat() const
1585  {
1586  return rtl_str_toFloat( pData->buffer );
1587  }
1588 
1597  double toDouble() const
1598  {
1599  return rtl_str_toDouble( pData->buffer );
1600  }
1601 
1612  static OString number( int i, sal_Int16 radix = 10 )
1613  {
1614  return number( static_cast< long long >( i ), radix );
1615  }
1618  static OString number( unsigned int i, sal_Int16 radix = 10 )
1619  {
1620  return number( static_cast< unsigned long long >( i ), radix );
1621  }
1624  static OString number( long i, sal_Int16 radix = 10 )
1625  {
1626  return number( static_cast< long long >( i ), radix );
1627  }
1630  static OString number( unsigned long i, sal_Int16 radix = 10 )
1631  {
1632  return number( static_cast< unsigned long long >( i ), radix );
1633  }
1636  static OString number( long long ll, sal_Int16 radix = 10 )
1637  {
1639  rtl_String* pNewData = NULL;
1640  rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfInt64( aBuf, ll, radix ) );
1641  return OString( pNewData, SAL_NO_ACQUIRE );
1642  }
1645  static OString number( unsigned long long ll, sal_Int16 radix = 10 )
1646  {
1648  rtl_String* pNewData = NULL;
1649  rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfUInt64( aBuf, ll, radix ) );
1650  return OString( pNewData, SAL_NO_ACQUIRE );
1651  }
1652 
1662  static OString number( float f )
1663  {
1665  rtl_String* pNewData = NULL;
1666  rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfFloat( aBuf, f ) );
1667  return OString( pNewData, SAL_NO_ACQUIRE );
1668  }
1669 
1679  static OString number( double d )
1680  {
1682  rtl_String* pNewData = NULL;
1683  rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfDouble( aBuf, d ) );
1684  return OString( pNewData, SAL_NO_ACQUIRE );
1685  }
1686 
1698  SAL_DEPRECATED("use boolean()") static OString valueOf( sal_Bool b )
1699  {
1700  return boolean(b);
1701  }
1702 
1714  static OString boolean( bool b )
1715  {
1717  rtl_String* pNewData = NULL;
1718  rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfBoolean( aBuf, b ) );
1719  return OString( pNewData, SAL_NO_ACQUIRE );
1720  }
1721 
1729  SAL_DEPRECATED("convert to OString or use directly") static OString valueOf( sal_Char c )
1730  {
1731  return OString( &c, 1 );
1732  }
1733 
1744  SAL_DEPRECATED("use number()") static OString valueOf( sal_Int32 i, sal_Int16 radix = 10 )
1745  {
1746  return number( i, radix );
1747  }
1748 
1759  SAL_DEPRECATED("use number()") static OString valueOf( sal_Int64 ll, sal_Int16 radix = 10 )
1760  {
1761  return number( ll, radix );
1762  }
1763 
1773  SAL_DEPRECATED("use number()") static OString valueOf( float f )
1774  {
1775  return number(f);
1776  }
1777 
1787  SAL_DEPRECATED("use number()") static OString valueOf( double d )
1788  {
1789  return number(d);
1790  }
1791 
1792 };
1793 
1794 /* ======================================================================= */
1795 
1796 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
1797 
1805 struct SAL_WARN_UNUSED OStringLiteral
1806 {
1807  template< int N >
1808  explicit OStringLiteral( const char (&str)[ N ] ) : size( N - 1 ), data( str ) { assert( strlen( str ) == N - 1 ); }
1809  int size;
1810  const char* data;
1811 };
1812 
1816 template<>
1817 struct ToStringHelper< OString >
1818  {
1819  static int length( const OString& s ) { return s.getLength(); }
1820  static char* addData( char* buffer, const OString& s ) { return addDataHelper( buffer, s.getStr(), s.getLength()); }
1821  static const bool allowOStringConcat = true;
1822  static const bool allowOUStringConcat = false;
1823  };
1824 
1828 template<>
1829 struct ToStringHelper< OStringLiteral >
1830  {
1831  static int length( const OStringLiteral& str ) { return str.size; }
1832  static char* addData( char* buffer, const OStringLiteral& str ) { return addDataHelper( buffer, str.data, str.size ); }
1833  static const bool allowOStringConcat = true;
1834  static const bool allowOUStringConcat = false;
1835  };
1836 
1840 template< typename charT, typename traits, typename T1, typename T2 >
1841 inline std::basic_ostream<charT, traits> & operator <<(
1842  std::basic_ostream<charT, traits> & stream, const OStringConcat< T1, T2 >& concat)
1843 {
1844  return stream << OString( concat );
1845 }
1846 #endif
1847 
1848 
1855 {
1865  size_t operator()( const OString& rString ) const
1866  { return (size_t)rString.hashCode(); }
1867 };
1868 
1871 {
1872  bool operator()( const char* p1, const char* p2) const
1873  { return rtl_str_compare(p1, p2) == 0; }
1874 };
1875 
1878 {
1879  size_t operator()(const char* p) const
1880  { return rtl_str_hashCode(p); }
1881 };
1882 
1883 /* ======================================================================= */
1884 
1891 template< typename charT, typename traits > std::basic_ostream<charT, traits> &
1893  std::basic_ostream<charT, traits> & stream, OString const & rString)
1894 {
1895  return stream << rString.getStr();
1896  // best effort; potentially loses data due to embedded null characters
1897 }
1898 
1899 } /* Namespace */
1900 
1901 #ifdef RTL_STRING_UNITTEST
1902 namespace rtl
1903 {
1904 typedef rtlunittest::OString OString;
1905 }
1906 #undef RTL_STRING_CONST_FUNCTION
1907 #endif
1908 
1909 #if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST
1910 using ::rtl::OString;
1911 using ::rtl::OStringHash;
1912 using ::rtl::OStringLiteral;
1913 #endif
1914 
1915 #endif // INCLUDED_RTL_STRING_HXX
1916 
1917 /* 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:1892
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:1507
friend OString operator+(const OString &str1, const OString &str2)
Definition: string.hxx:1291
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:679
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:1584
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:1084
#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:494
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:891
OString(rtl_String *str)
New string from OString data.
Definition: string.hxx:143
char sal_Char
A legacy synonym for char.
Definition: types.h:121
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:1483
bool equals(const OString &str) const
Perform a comparison of two strings.
Definition: string.hxx:511
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:330
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:1136
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:801
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=(const OString &rStr1, const T &value)
Definition: string.hxx:1014
sal_Int32 compareTo(const OString &rObj, sal_Int32 maxLength) const
Compares two strings with an maximum count of characters.
Definition: string.hxx:476
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:608
OString getToken(sal_Int32 token, sal_Char cTok, sal_Int32 &index) const
Returns a token in the string.
Definition: string.hxx:1463
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:1032
OString & operator+=(const OString &str)
Append a string to this string.
Definition: string.hxx:352
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:608
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:1149
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:289
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:1854
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:115
static OString boolean(bool b)
Returns the string representation of the boolean argument.
Definition: string.hxx:1714
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:252
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:1210
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:1645
const sal_Char * getStr() const SAL_RETURNS_NONNULL
Returns a pointer to the characters of this string.
Definition: string.hxx:428
OString(const sal_Char *value, sal_Int32 length)
New string from a character buffer array.
Definition: string.hxx:232
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:536
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:1233
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:1355
#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:1099
static OString number(double d)
Returns the string representation of the double argument.
Definition: string.hxx:1679
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:997
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:1330
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:166
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:832
unsigned char sal_Bool
Definition: types.h:39
bool operator<(const TTimeValue &rTimeA, const TTimeValue &rTimeB)
Definition: timer.hxx:96
void clear()
Clears the string, i.e, makes a zero-character string.
Definition: string.hxx:389
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator!=(const T &value, const OString &rStr2)
Definition: string.hxx:1026
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:1624
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:1379
sal_Int32 compareTo(const OString &str) const
Compares two strings.
Definition: string.hxx:457
bool isEmpty() const
Checks if a string is empty.
Definition: string.hxx:412
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:958
bool equalsIgnoreAsciiCaseL(const sal_Char *asciiStr, sal_Int32 asciiStrLength) const
Perform a ASCII lowercase comparison of two strings.
Definition: string.hxx:643
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:952
OString(T &literal, typename libreoffice_internal::ConstCharArrayDetector< T, libreoffice_internal::Dummy >::Type=libreoffice_internal::Dummy())
New string from a string literal.
Definition: string.hxx:205
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:1283
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:633
__sal_NoAcquire
Definition: types.h:376
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:758
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:307
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:1054
Definition: stringutils.hxx:117
bool operator()(const char *p1, const char *p2) const
Definition: string.hxx:1872
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:142
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:1268
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:597
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:876
bool toBoolean() const
Returns the Boolean value from this string.
Definition: string.hxx:1496
SAL_WARN_UNUSED_RESULT OString copy(sal_Int32 beginIndex) const
Returns a new string that is a substring of this string.
Definition: string.hxx:1249
sal_uInt32 toUInt32(sal_Int16 radix=10) const
Returns the uint32 value from this string.
Definition: string.hxx:1539
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:559
sal_uInt16 rtl_TextEncoding
The various supported text encodings.
Definition: textenc.h:33
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:1630
sal_Int32 hashCode() const
Returns a hashcode for this string.
Definition: string.hxx:1066
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:1612
OString & operator=(const OString &str)
Assign a new string.
Definition: string.hxx:299
libreoffice_internal::CharPtrDetector< T, bool >::Type equalsIgnoreAsciiCase(const T &asciiStr) const
Perform a ASCII lowercase comparison of two strings.
Definition: string.hxx:591
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:1179
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:1310
Definition: bootstrap.hxx:29
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:1618
definition of a no acquire enum for ctors
Definition: types.h:380
friend libreoffice_internal::CharPtrDetector< T, bool >::Type operator==(const OString &rStr1, const T &value)
Definition: string.hxx:946
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don&#39;t use, it&#39;s evil.") void doit(int nPara);.
Definition: types.h:493
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:1571
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator!=(const OString &rStr1, T &value)
Definition: string.hxx:1020
sal_Int32 getLength() const
Returns the length of this string.
Definition: string.hxx:402
bool match(const OString &str, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: string.hxx:667
friend libreoffice_internal::NonConstCharArrayDetector< T, bool >::Type operator==(T &value, const OString &rStr2)
Definition: string.hxx:964
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:188
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:927
Hashing functor for classic c-strings (i.e., null-terminated char* strings).
Definition: string.hxx:1877
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:1414
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:1662
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:1397
OString()
New string containing no characters.
Definition: string.hxx:104
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:1554
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:975
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:181
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:1865
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:1432
#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:1043
sal_Int32 toInt32(sal_Int16 radix=10) const
Returns the int32 value from this string.
Definition: string.hxx:1522
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:1116
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:1636
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:1597
bool matchL(char const *str, sal_Int32 strLength, sal_Int32 fromIndex=0) const
Match against a substring appearing in this string.
Definition: string.hxx:710
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:745
size_t operator()(const char *p) const
Definition: string.hxx:1879
OString(rtl_String *str, __sal_NoAcquire)
New string from OString data without acquiring it.
Definition: string.hxx:156
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:94
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:849
Equality functor for classic c-strings (i.e., null-terminated char* strings).
Definition: string.hxx:1870
bool startsWith(OString const &str, OString *rest=NULL) const
Check whether this string starts with a given substring.
Definition: string.hxx:787
#define OUSTRING_TO_OSTRING_CVTFLAGS
Definition: string.h:1324